|
@@ -52,6 +52,30 @@ function getOpType (op) {
|
|
|
return TYPES.LOGIC;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @param {Commands.IfThenElse} ifthenelse
|
|
|
+ * */
|
|
|
+function ifThenElseWalker (ifthenelse) {
|
|
|
+ //ifthenelse.
|
|
|
+ const expression = expressionWalker(ifthenelse.condition);
|
|
|
+ const ifTrue = ifthenelse.ifTrue.commands.map(commandWalker)
|
|
|
+ let ifFalse = [];
|
|
|
+ if (ifthenelse.ifFalse) {
|
|
|
+ if (ifthenelse.ifFalse instanceof Commands.CommandBlock) {
|
|
|
+ ifFalse = ifthenelse.ifFalse.commands.map(commandWalker)
|
|
|
+ } else {
|
|
|
+ ifFalse = [ifThenElseWalker(ifthenelse.ifFalse)]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ type: "iftrue",
|
|
|
+ expression,
|
|
|
+ ifTrue,
|
|
|
+ ifFalse
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* @param {Commands.Assign} assingment
|
|
|
* */
|
|
@@ -96,6 +120,8 @@ function commandWalker (command) {
|
|
|
return functionCallWalker(command)
|
|
|
} else if (command instanceof Commands.Assign) {
|
|
|
return assignmentWalker(command)
|
|
|
+ } else if (command instanceof Commands.IfThenElse) {
|
|
|
+ return ifThenElseWalker(command)
|
|
|
}
|
|
|
throw new Error("not implemented")
|
|
|
}
|