|
@@ -220,42 +220,47 @@ export class IVProgProcessor {
|
|
}
|
|
}
|
|
|
|
|
|
executeCommand (store, cmd) {
|
|
executeCommand (store, cmd) {
|
|
- if(this.forceKill) {
|
|
|
|
- return Promise.reject("FORCED_KILL!");
|
|
|
|
- } else if (store.mode === Modes.PAUSE) {
|
|
|
|
- return Promise.resolve(this.executeCommand(store, cmd));
|
|
|
|
- } else if(store.mode === Modes.RETURN) {
|
|
|
|
- return Promise.resolve(store);
|
|
|
|
- } else if(this.checkContext(Context.BREAKABLE) && store.mode === Modes.BREAK) {
|
|
|
|
- return Promise.resolve(store);
|
|
|
|
- }
|
|
|
|
- if (cmd instanceof Commands.Declaration) {
|
|
|
|
- return this.executeDeclaration(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.ArrayIndexAssign) {
|
|
|
|
- return this.executeArrayIndexAssign(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.Assign) {
|
|
|
|
- return this.executeAssign(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.Break) {
|
|
|
|
- return this.executeBreak(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.Return) {
|
|
|
|
- return this.executeReturn(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.IfThenElse) {
|
|
|
|
- return this.executeIfThenElse(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.RepeatUntil) {
|
|
|
|
- return this.executeRepeatUntil(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.While) {
|
|
|
|
- return this.executeWhile(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.For) {
|
|
|
|
- return this.executeFor(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.Switch) {
|
|
|
|
- return this.executeSwitch(store, cmd);
|
|
|
|
- } else if (cmd instanceof Expressions.FunctionCall) {
|
|
|
|
- return this.executeFunctionCall(store, cmd);
|
|
|
|
- } else if (cmd instanceof Commands.SysCall) {
|
|
|
|
- return this.executeSysCall(store, cmd);
|
|
|
|
- } else {
|
|
|
|
- return Promise.reject(ProcessorErrorFactory.unknown_command(cmd.sourceInfo))
|
|
|
|
- }
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if(this.forceKill) {
|
|
|
|
+ return reject("FORCED_KILL!");
|
|
|
|
+ } else if (store.mode === Modes.PAUSE) {
|
|
|
|
+ return resolve(this.executeCommand(store, cmd));
|
|
|
|
+ } else if(store.mode === Modes.RETURN) {
|
|
|
|
+ return resolve(store);
|
|
|
|
+ } else if(this.checkContext(Context.BREAKABLE) && store.mode === Modes.BREAK) {
|
|
|
|
+ return resolve(store);
|
|
|
|
+ }
|
|
|
|
+ if (cmd instanceof Commands.Declaration) {
|
|
|
|
+ return resolve(this.executeDeclaration(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.ArrayIndexAssign) {
|
|
|
|
+ return resolve(this.executeArrayIndexAssign(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.Assign) {
|
|
|
|
+ return resolve(this.executeAssign(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.Break) {
|
|
|
|
+ return resolve(this.executeBreak(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.Return) {
|
|
|
|
+ return resolve(this.executeReturn(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.IfThenElse) {
|
|
|
|
+ return resolve(this.executeIfThenElse(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.RepeatUntil) {
|
|
|
|
+ return resolve(this.executeRepeatUntil(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.While) {
|
|
|
|
+ return resolve(this.executeWhile(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.For) {
|
|
|
|
+ return resolve(this.executeFor(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.Switch) {
|
|
|
|
+ return resolve(this.executeSwitch(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Expressions.FunctionCall) {
|
|
|
|
+ return resolve(this.executeFunctionCall(store, cmd));
|
|
|
|
+ } else if (cmd instanceof Commands.SysCall) {
|
|
|
|
+ return resolve(this.executeSysCall(store, cmd));
|
|
|
|
+ } else {
|
|
|
|
+ return reject(ProcessorErrorFactory.unknown_command(cmd.sourceInfo))
|
|
|
|
+ }
|
|
|
|
+ }, 5);
|
|
|
|
+ })
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
executeSysCall (store, cmd) {
|
|
executeSysCall (store, cmd) {
|