|
@@ -148,11 +148,11 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
run_lambda();
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
associateParameters (formal_params, effective_params, caller_store, callee_store) {
|
|
|
- const funcName = callee_store.name === IVProgProcessor.MAIN_INTERNAL_ID ?
|
|
|
+ const funcName = callee_store.name === IVProgProcessor.MAIN_INTERNAL_ID ?
|
|
|
LanguageDefinedFunction.getMainFunctionName() : callee_store.name;
|
|
|
|
|
|
if (formal_params.length != effective_params.length) {
|
|
@@ -261,7 +261,7 @@ export class IVProgProcessor {
|
|
|
} else if (cmd instanceof Commands.Switch) {
|
|
|
return resolve(this.executeSwitch(store, cmd));
|
|
|
} else if (cmd instanceof Expressions.FunctionCall) {
|
|
|
- return resolve(this.executeFunctionCall(store, cmd));
|
|
|
+ return resolve(this.executeFunctionCall(store, cmd));
|
|
|
} else if (cmd instanceof Commands.SysCall) {
|
|
|
return resolve(this.executeSysCall(store, cmd));
|
|
|
} else {
|
|
@@ -297,7 +297,7 @@ export class IVProgProcessor {
|
|
|
.then(sto => {
|
|
|
sto.destroy();
|
|
|
if(!Types.VOID.isCompatible(func.returnType) && sto.mode !== Modes.RETURN) {
|
|
|
- const funcName = func.name === IVProgProcessor.MAIN_INTERNAL_ID ?
|
|
|
+ const funcName = func.name === IVProgProcessor.MAIN_INTERNAL_ID ?
|
|
|
LanguageDefinedFunction.getMainFunctionName() : func.name;
|
|
|
return Promise.reject(ProcessorErrorFactory.function_no_return(funcName));
|
|
|
} else {
|
|
@@ -342,9 +342,9 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param {Store} store
|
|
|
- * @param {Commands.For} cmd
|
|
|
+ *
|
|
|
+ * @param {Store} store
|
|
|
+ * @param {Commands.For} cmd
|
|
|
*/
|
|
|
executeFor (store, cmd) {
|
|
|
//BEGIN for -> while rewrite
|
|
@@ -358,9 +358,9 @@ export class IVProgProcessor {
|
|
|
expression_tuple.push(this.evaluateExpression(store, new Expressions.InfixApp(Operators.GE, cmd.for_pass, new Expressions.IntLiteral(toInt(0)))));
|
|
|
expression_tuple.push(Promise.resolve(null));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return Promise.all(expression_tuple).then (results => {
|
|
|
- console.log(results);
|
|
|
+ // console.log(results);
|
|
|
let is_forward = true;
|
|
|
let is_end_gt_init = undefined;
|
|
|
let condition = null;
|
|
@@ -373,13 +373,13 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
|
|
|
if(is_end_gt_init == null) {
|
|
|
- console.log("pass is not null and is forward? ", is_forward);
|
|
|
+ // console.log("pass is not null and is forward? ", is_forward);
|
|
|
if(is_forward) {
|
|
|
condition = new Expressions.InfixApp(Operators.LE, cmd.for_id, cmd.for_to);
|
|
|
} else {
|
|
|
condition = new Expressions.InfixApp(Operators.GE, cmd.for_id, cmd.for_to);
|
|
|
}
|
|
|
- console.log("Cond", condition);
|
|
|
+ // console.log("Cond", condition);
|
|
|
} else if(is_end_gt_init) {
|
|
|
pass_value = new Expressions.IntLiteral(toInt(1));
|
|
|
condition = new Expressions.InfixApp(Operators.LE, cmd.for_id, cmd.for_to);
|
|
@@ -454,7 +454,7 @@ export class IVProgProcessor {
|
|
|
return Promise.reject(ProcessorErrorFactory.loop_condition_type_full(cmd.expression.toString(), cmd.sourceInfo));
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
return Promise.reject(error);
|
|
|
}
|
|
@@ -487,13 +487,13 @@ export class IVProgProcessor {
|
|
|
|
|
|
executeReturn (store, cmd) {
|
|
|
try {
|
|
|
- const funcName = store.name === IVProgProcessor.MAIN_INTERNAL_ID ?
|
|
|
+ const funcName = store.name === IVProgProcessor.MAIN_INTERNAL_ID ?
|
|
|
LanguageDefinedFunction.getMainFunctionName() : store.name;
|
|
|
// console.log(funcName, store.name === IVProgProcessor.MAIN_INTERNAL_ID);
|
|
|
const func = this.findFunction(store.name);
|
|
|
const funcType = func.returnType;
|
|
|
const $value = this.evaluateExpression(store, cmd.expression);
|
|
|
-
|
|
|
+
|
|
|
return $value.then(value => {
|
|
|
|
|
|
let real_value = value;
|
|
@@ -559,11 +559,11 @@ export class IVProgProcessor {
|
|
|
return Promise.reject(ProcessorErrorFactory.invalid_vector_assignment_full(cmd.id, inStore.lines, exp, realValue.lines, cmd.sourceInfo));
|
|
|
} else {
|
|
|
return Promise.reject(ProcessorErrorFactory.invalid_matrix_assignment_full(cmd.id, inStore.lines, inStore.columns, exp, realValue.lines, realValue.columns, cmd.sourceInfo));
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- store.updateStore(cmd.id, realValue)
|
|
|
+
|
|
|
+ store.updateStore(cmd.id, realValue)
|
|
|
return store;
|
|
|
});
|
|
|
} catch (error) {
|
|
@@ -646,9 +646,9 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param {Store} store
|
|
|
- * @param {Commands.Declaration} cmd
|
|
|
+ *
|
|
|
+ * @param {Store} store
|
|
|
+ * @param {Commands.Declaration} cmd
|
|
|
*/
|
|
|
executeDeclaration (store, cmd) {
|
|
|
try {
|
|
@@ -689,9 +689,9 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param {Store} store
|
|
|
- * @param {Commands.ArrayDeclaration} cmd
|
|
|
+ *
|
|
|
+ * @param {Store} store
|
|
|
+ * @param {Commands.ArrayDeclaration} cmd
|
|
|
*/
|
|
|
executeArrayDeclaration (store, cmd) {
|
|
|
const $lines = this.evaluateExpression(store, cmd.lines);
|
|
@@ -772,7 +772,7 @@ export class IVProgProcessor {
|
|
|
expression_lambda();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
evaluateFunctionCall (store, exp) {
|
|
@@ -800,10 +800,10 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param {Store} store
|
|
|
- * @param {Expressions.ArrayLiteral} exp
|
|
|
- * @param {ArrayType} type
|
|
|
+ *
|
|
|
+ * @param {Store} store
|
|
|
+ * @param {Expressions.ArrayLiteral} exp
|
|
|
+ * @param {ArrayType} type
|
|
|
*/
|
|
|
evaluateArrayLiteral (store, exp, type, lines, columns) {
|
|
|
if(!exp.isVector) {
|
|
@@ -827,8 +827,8 @@ export class IVProgProcessor {
|
|
|
|
|
|
/**
|
|
|
* Evalautes a list of literals and expression composing the vector
|
|
|
- * @param {Store} store
|
|
|
- * @param {Expressions.ArrayLiteral} exps
|
|
|
+ * @param {Store} store
|
|
|
+ * @param {Expressions.ArrayLiteral} exps
|
|
|
* @param {ArrayType} type
|
|
|
* @param {number} n_elements
|
|
|
* @returns {Promise<StoreValue[]>} store object list
|
|
@@ -859,8 +859,8 @@ export class IVProgProcessor {
|
|
|
|
|
|
/**
|
|
|
* Evaluates a list of array literals composing the matrix
|
|
|
- * @param {Store} store
|
|
|
- * @param {Expressions.ArrayLiteral} exps
|
|
|
+ * @param {Store} store
|
|
|
+ * @param {Expressions.ArrayLiteral} exps
|
|
|
* @param {ArrayType} type
|
|
|
* @returns {Promise<StoreValue[]>[]}
|
|
|
*/
|
|
@@ -1022,7 +1022,7 @@ export class IVProgProcessor {
|
|
|
}
|
|
|
result = leftValue.modulo(rightValue);
|
|
|
return new StoreValue(resultType, (result));
|
|
|
- }
|
|
|
+ }
|
|
|
case Operators.GT.ord: {
|
|
|
let leftValue = left.get();
|
|
|
let rightValue = right.get();
|
|
@@ -1123,4 +1123,4 @@ export class IVProgProcessor {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|