< prev index next >

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

Print this page

        

*** 95,104 **** --- 95,105 ---- */ @Logger(name="lower") final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Loggable { private final DebugLogger log; + private final boolean es6; // Conservative pattern to test if element names consist of characters valid for identifiers. // This matches any non-zero length alphanumeric string including _ and $ and not starting with a digit. private static final Pattern SAFE_PROPERTY_NAME = Pattern.compile("[a-zA-Z_$][\\w$]*");
*** 142,151 **** --- 143,153 ---- return block.setIsTerminal(this, false); } }); this.log = initLogger(compiler.getContext()); + this.es6 = compiler.getScriptEnvironment()._es6; } @Override public DebugLogger getLogger() { return log;
*** 255,266 **** if (!forNode.isForIn() && isAlwaysTrue(test)) { newForNode = forNode.setTest(lc, null); } newForNode = checkEscape(newForNode); ! if(newForNode.isForIn()) { ! // Wrap it in a block so its internally created iterator is restricted in scope addStatementEnclosedInBlock(newForNode); } else { addStatement(newForNode); } return newForNode; --- 257,269 ---- if (!forNode.isForIn() && isAlwaysTrue(test)) { newForNode = forNode.setTest(lc, null); } newForNode = checkEscape(newForNode); ! if(!es6 && newForNode.isForIn()) { ! // Wrap it in a block so its internally created iterator is restricted in scope, unless we are running ! // in ES6 mode, in which case the parser already created a block to capture let/const declarations. addStatementEnclosedInBlock(newForNode); } else { addStatement(newForNode); } return newForNode;
< prev index next >