mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
IF block perf/memory
This commit is contained in:
parent
45f690eb4d
commit
920fcbc095
20
EXRAIL2.cpp
20
EXRAIL2.cpp
|
@ -519,27 +519,17 @@ bool RMFT2::skipIfBlock() {
|
||||||
while (nest > 0) {
|
while (nest > 0) {
|
||||||
SKIPOP;
|
SKIPOP;
|
||||||
byte opcode = GET_OPCODE;
|
byte opcode = GET_OPCODE;
|
||||||
switch(opcode) {
|
// all other IF type commands increase the nesting level
|
||||||
|
if (opcode>IF_TYPE_OPCODES) nest++;
|
||||||
|
else switch(opcode) {
|
||||||
case OPCODE_ENDEXRAIL:
|
case OPCODE_ENDEXRAIL:
|
||||||
kill(F("missing ENDIF"), nest);
|
kill(F("missing ENDIF"), nest);
|
||||||
return false;
|
return false;
|
||||||
case OPCODE_IF:
|
|
||||||
case OPCODE_IFCLOSED:
|
|
||||||
case OPCODE_IFGTE:
|
|
||||||
case OPCODE_IFLT:
|
|
||||||
case OPCODE_IFNOT:
|
|
||||||
case OPCODE_IFRANDOM:
|
|
||||||
case OPCODE_IFRESERVE:
|
|
||||||
case OPCODE_IFTHROWN:
|
|
||||||
case OPCODE_IFTIMEOUT:
|
|
||||||
case OPCODE_IFRED:
|
|
||||||
case OPCODE_IFAMBER:
|
|
||||||
case OPCODE_IFGREEN:
|
|
||||||
nest++;
|
|
||||||
break;
|
|
||||||
case OPCODE_ENDIF:
|
case OPCODE_ENDIF:
|
||||||
nest--;
|
nest--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPCODE_ELSE:
|
case OPCODE_ELSE:
|
||||||
// if nest==1 then this is the ELSE for the IF we are skipping
|
// if nest==1 then this is the ELSE for the IF we are skipping
|
||||||
if (nest==1) nest=0; // cause loop exit and return after ELSE
|
if (nest==1) nest=0; // cause loop exit and return after ELSE
|
||||||
|
|
20
EXRAIL2.h
20
EXRAIL2.h
|
@ -35,10 +35,9 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
||||||
OPCODE_RESERVE,OPCODE_FREE,
|
OPCODE_RESERVE,OPCODE_FREE,
|
||||||
OPCODE_AT,OPCODE_AFTER,OPCODE_AUTOSTART,
|
OPCODE_AT,OPCODE_AFTER,OPCODE_AUTOSTART,
|
||||||
OPCODE_ATGTE,OPCODE_ATLT,
|
OPCODE_ATGTE,OPCODE_ATLT,
|
||||||
OPCODE_ATTIMEOUT1,OPCODE_ATTIMEOUT2,OPCODE_IFTIMEOUT,
|
OPCODE_ATTIMEOUT1,OPCODE_ATTIMEOUT2,
|
||||||
OPCODE_LATCH,OPCODE_UNLATCH,OPCODE_SET,OPCODE_RESET,
|
OPCODE_LATCH,OPCODE_UNLATCH,OPCODE_SET,OPCODE_RESET,
|
||||||
OPCODE_IF,OPCODE_IFNOT,OPCODE_ENDIF,OPCODE_IFRANDOM,OPCODE_IFRESERVE,
|
OPCODE_ENDIF,OPCODE_ELSE,
|
||||||
OPCODE_IFCLOSED, OPCODE_IFTHROWN,OPCODE_ELSE,
|
|
||||||
OPCODE_DELAY,OPCODE_DELAYMINS,OPCODE_DELAYMS,OPCODE_RANDWAIT,
|
OPCODE_DELAY,OPCODE_DELAYMINS,OPCODE_DELAYMS,OPCODE_RANDWAIT,
|
||||||
OPCODE_FON,OPCODE_FOFF,OPCODE_XFON,OPCODE_XFOFF,
|
OPCODE_FON,OPCODE_FOFF,OPCODE_XFON,OPCODE_XFOFF,
|
||||||
OPCODE_RED,OPCODE_GREEN,OPCODE_AMBER,OPCODE_DRIVE,
|
OPCODE_RED,OPCODE_GREEN,OPCODE_AMBER,OPCODE_DRIVE,
|
||||||
|
@ -49,10 +48,21 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
||||||
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,OPCODE_POWERON,
|
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,OPCODE_POWERON,
|
||||||
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
||||||
OPCODE_PRINT,OPCODE_DCCACTIVATE,
|
OPCODE_PRINT,OPCODE_DCCACTIVATE,
|
||||||
OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFGTE,OPCODE_IFLT,
|
OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,
|
||||||
OPCODE_ROSTER,OPCODE_KILLALL,
|
OPCODE_ROSTER,OPCODE_KILLALL,
|
||||||
|
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,
|
||||||
|
OPCODE_ENDTASK,OPCODE_ENDEXRAIL,
|
||||||
|
|
||||||
|
// OPcodes below this point are skip-nesting IF operations
|
||||||
|
// placed here so that they may be skipped as a group
|
||||||
|
// see skipIfBlock()
|
||||||
|
IF_TYPE_OPCODES, // do not move this...
|
||||||
OPCODE_IFRED,OPCODE_IFAMBER,OPCODE_IFGREEN,
|
OPCODE_IFRED,OPCODE_IFAMBER,OPCODE_IFGREEN,
|
||||||
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
OPCODE_IFGTE,OPCODE_IFLT,
|
||||||
|
OPCODE_IFTIMEOUT,
|
||||||
|
OPCODE_IF,OPCODE_IFNOT,
|
||||||
|
OPCODE_IFRANDOM,OPCODE_IFRESERVE,
|
||||||
|
OPCODE_IFCLOSED, OPCODE_IFTHROWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user