diff --git a/interp.js b/interp.js index 8b1c11e0d308e05dd7f01c279eb4830bf335b6a7..c495bc62cf1f43c12bd39ce047ae9472206af263 100644 --- a/interp.js +++ b/interp.js @@ -445,6 +445,10 @@ function trm_get(line, loc, field) { return {tag: "trm_get", loc: loc, field: field, line: line}; } +function trm_alloc(line) { + return {tag: "trm_alloc", line: line}; +} + //----------------demo--------------- var trm1 = @@ -552,7 +556,10 @@ function esprimaExprToAST(expr) { if (!isNumeric(value)) throw ("Literal not a number: " + value); return trm_number(expr.loc.start.line, expr.value); case "Identifier": - return trm_var(expr.loc.start.line, expr.name); + switch (expr.name) { + case "alloc": return trm_alloc(expr.loc.start.line); + default: return trm_var(expr.loc.start.line, expr.name); + } case "AssignmentExpression": if (expr.operator !== "=") throw ("AssignmentExpression NI: " + expr.operator); if (expr.left.type !== "MemberExpression") throw ("Expected MemberExpression");