|
@@ -1,6 +1,7 @@
|
|
|
import { IVProgParser } from "../ast/ivprogParser";
|
|
|
import * as Expressions from "../ast/expressions";
|
|
|
import { Types } from "../typeSystem/types";
|
|
|
+import { convertBoolToString } from "../typeSystem/parsers";
|
|
|
|
|
|
const TYPES = {
|
|
|
VARIABLE: "var",
|
|
@@ -67,6 +68,11 @@ function expressionWalker (expression) {
|
|
|
//const params = Array.prototype.concat.apply([], paramsList);
|
|
|
funcObj.params = paramsList;
|
|
|
result = [funcObj];
|
|
|
+ } else if (expression instanceof Expressions.UnaryApp) {
|
|
|
+ const left = expressionWalker(expression.left);
|
|
|
+ const opType = getOpType(expression.op);
|
|
|
+ const opValue = translateOp(opType, expression.op);
|
|
|
+ result = [{ instance: "operator", type: opType, value: opValue }, ...left];
|
|
|
} else if (expression instanceof Expressions.InfixApp) {
|
|
|
const left = expressionWalker(expression.left);
|
|
|
const right = expressionWalker(expression.right);
|
|
@@ -77,11 +83,6 @@ function expressionWalker (expression) {
|
|
|
{ instance: "operator", type: opType, value: opValue },
|
|
|
...right,
|
|
|
];
|
|
|
- } else if (expression instanceof Expressions.UnaryApp) {
|
|
|
- const left = expressionWalker(expression.left);
|
|
|
- const opType = getOpType(expression.op);
|
|
|
- const opValue = translateOp(opType, expression.op);
|
|
|
- result = [{ instance: "operator", type: opType, value: opValue }, ...left];
|
|
|
} else if (expression instanceof Expressions.ArrayAccess) {
|
|
|
const line = expressionWalker(expression.line);
|
|
|
let arrayClass = "vector";
|
|
@@ -100,6 +101,16 @@ function expressionWalker (expression) {
|
|
|
value: expression.id,
|
|
|
},
|
|
|
];
|
|
|
+ } else if (expression instanceof Expressions.BoolLiteral) {
|
|
|
+ const value = expression.value;
|
|
|
+ result = [
|
|
|
+ {
|
|
|
+ instance: "expression",
|
|
|
+ class: "simple",
|
|
|
+ type: TYPES.CONST,
|
|
|
+ value: convertBoolToString(value),
|
|
|
+ },
|
|
|
+ ];
|
|
|
} else {
|
|
|
let value = expression.value;
|
|
|
if (expression.value.toNumber) {
|