|
@ -709,12 +709,14 @@ function execVarAssignement(ctx, ast) { |
|
|
|
|
|
|
|
|
if (num.type == "COMPONENT") return execInstantiateComponet(ctx, v, ast.values[1]); |
|
|
if (num.type == "COMPONENT") return execInstantiateComponet(ctx, v, ast.values[1]); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
// if (num.type == "SIGNAL") return error(ctx, ast, "Cannot assign to a signal with `=` use <-- or <== ops");
|
|
|
|
|
|
|
|
|
if ((num.type == "SIGNAL")&&(ast.op == "=")) return error(ctx, ast, "Cannot assign to a signal with `=` use <-- or <== ops"); |
|
|
|
|
|
if ((["NUMBER", "COMPONENT"].indexOf(num.type) >= 0 )&&(ast.op != "=")) return error(ctx, ast, `Cannot assign to a var with ${ast.op}. use = op`); |
|
|
|
|
|
|
|
|
const res = exec(ctx, ast.values[1]); |
|
|
const res = exec(ctx, ast.values[1]); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
|
|
|
|
|
|
setScope(ctx, v.name, v.selectors, res); |
|
|
|
|
|
|
|
|
Object.assign(num, res); |
|
|
|
|
|
// setScope(ctx, v.name, v.selectors, res);
|
|
|
|
|
|
|
|
|
return v; |
|
|
return v; |
|
|
} |
|
|
} |
|
@ -986,13 +988,13 @@ function execMul(ctx, ast) { |
|
|
function execVarAddAssignement(ctx, ast) { |
|
|
function execVarAddAssignement(ctx, ast) { |
|
|
const res = execAdd(ctx,{ values: [ast.values[0], ast.values[1]] } ); |
|
|
const res = execAdd(ctx,{ values: [ast.values[0], ast.values[1]] } ); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
return execVarAssignement(ctx, { values: [ast.values[0], res] }); |
|
|
|
|
|
|
|
|
return execVarAssignement(ctx, { op:"=", values: [ast.values[0], res] }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function execVarMulAssignement(ctx, ast) { |
|
|
function execVarMulAssignement(ctx, ast) { |
|
|
const res = execMul(ctx,{ values: [ast.values[0], ast.values[1]] } ); |
|
|
const res = execMul(ctx,{ values: [ast.values[0], ast.values[1]] } ); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
return execVarAssignement(ctx, { values: [ast.values[0], res] }); |
|
|
|
|
|
|
|
|
return execVarAssignement(ctx, { op:"=", values: [ast.values[0], res] }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function execPlusPlusRight(ctx, ast) { |
|
|
function execPlusPlusRight(ctx, ast) { |
|
@ -1000,7 +1002,7 @@ function execPlusPlusRight(ctx, ast) { |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
const resAfter = execAdd(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
const resAfter = execAdd(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
execVarAssignement(ctx, { values: [ast.values[0], resAfter] }); |
|
|
|
|
|
|
|
|
execVarAssignement(ctx, { op:"=", values: [ast.values[0], resAfter] }); |
|
|
return resBefore; |
|
|
return resBefore; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1008,7 +1010,7 @@ function execPlusPlusLeft(ctx, ast) { |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
const resAfter = execAdd(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
const resAfter = execAdd(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
execVarAssignement(ctx, { values: [ast.values[0], resAfter] }); |
|
|
|
|
|
|
|
|
execVarAssignement(ctx, { op:"=", values: [ast.values[0], resAfter] }); |
|
|
return resAfter; |
|
|
return resAfter; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1017,7 +1019,7 @@ function execMinusMinusRight(ctx, ast) { |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
const resAfter = execSub(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
const resAfter = execSub(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
execVarAssignement(ctx, { values: [ast.values[0], resAfter] }); |
|
|
|
|
|
|
|
|
execVarAssignement(ctx, { op:"=", values: [ast.values[0], resAfter] }); |
|
|
return resBefore; |
|
|
return resBefore; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1025,7 +1027,7 @@ function execMinusMinusLeft(ctx, ast) { |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
const resAfter = execSub(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
const resAfter = execSub(ctx,{ values: [ast.values[0], {type: "NUMBER", value: bigInt(1)}] } ); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|
execVarAssignement(ctx, { values: [ast.values[0], resAfter] }); |
|
|
|
|
|
|
|
|
execVarAssignement(ctx, { op:"=", values: [ast.values[0], resAfter] }); |
|
|
return resAfter; |
|
|
return resAfter; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|