src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java

Print this page

        

*** 341,352 **** // Any access to LET and CONST variables before their declaration must throw ReferenceError. // This is called the temporal dead zone (TDZ). See https://gist.github.com/rwaldron/f0807a758aa03bcdd58a private void checkTemporalDeadZone(final IdentNode identNode) { if (identNode.isDead()) { ! method.load(identNode.getSymbol().getName()); ! method.invoke(ScriptRuntime.THROW_REFERENCE_ERROR); } } private boolean isRestOf() { return continuationEntryPoints != null; --- 341,358 ---- // Any access to LET and CONST variables before their declaration must throw ReferenceError. // This is called the temporal dead zone (TDZ). See https://gist.github.com/rwaldron/f0807a758aa03bcdd58a private void checkTemporalDeadZone(final IdentNode identNode) { if (identNode.isDead()) { ! method.load(identNode.getSymbol().getName()).invoke(ScriptRuntime.THROW_REFERENCE_ERROR); ! } ! } ! ! // Runtime check for assignment to ES6 const ! private void checkAssignTarget(final Expression expression) { ! if (expression instanceof IdentNode && ((IdentNode)expression).getSymbol().isConst()) { ! method.load(((IdentNode)expression).getSymbol().getName()).invoke(ScriptRuntime.THROW_CONST_TYPE_ERROR); } } private boolean isRestOf() { return continuationEntryPoints != null;
*** 785,860 **** --- 791,878 ---- return false; } @Override public boolean enterASSIGN(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN(binaryNode); return false; } @Override public boolean enterASSIGN_ADD(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_ADD(binaryNode); return false; } @Override public boolean enterASSIGN_BIT_AND(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_BIT_AND(binaryNode); return false; } @Override public boolean enterASSIGN_BIT_OR(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_BIT_OR(binaryNode); return false; } @Override public boolean enterASSIGN_BIT_XOR(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_BIT_XOR(binaryNode); return false; } @Override public boolean enterASSIGN_DIV(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_DIV(binaryNode); return false; } @Override public boolean enterASSIGN_MOD(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_MOD(binaryNode); return false; } @Override public boolean enterASSIGN_MUL(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_MUL(binaryNode); return false; } @Override public boolean enterASSIGN_SAR(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_SAR(binaryNode); return false; } @Override public boolean enterASSIGN_SHL(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_SHL(binaryNode); return false; } @Override public boolean enterASSIGN_SHR(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_SHR(binaryNode); return false; } @Override public boolean enterASSIGN_SUB(final BinaryNode binaryNode) { + checkAssignTarget(binaryNode.lhs()); loadASSIGN_SUB(binaryNode); return false; } @Override
*** 1060,1069 **** --- 1078,1088 ---- return false; } @Override public boolean enterDECINC(final UnaryNode unaryNode) { + checkAssignTarget(unaryNode.getExpression()); loadDECINC(unaryNode); return false; } @Override