--- old/src/jdk/nashorn/internal/ir/ForNode.java 2014-11-27 17:14:24.955205845 +0100 +++ new/src/jdk/nashorn/internal/ir/ForNode.java 2014-11-27 17:14:24.811205848 +0100 @@ -45,14 +45,14 @@ /** Iterator symbol. */ private Symbol iterator; - /** Is this a normal for loop? */ - public static final int IS_FOR = 1 << 0; - /** Is this a normal for in loop? */ - public static final int IS_FOR_IN = 1 << 1; + public static final int IS_FOR_IN = 1 << 0; /** Is this a normal for each in loop? */ - public static final int IS_FOR_EACH = 1 << 2; + public static final int IS_FOR_EACH = 1 << 1; + + /** Does this loop need a per-iteration scope because its init contain a LET declaration? */ + public static final int PER_ITERATION_SCOPE = 1 << 2; private final int flags; @@ -273,4 +273,18 @@ JoinPredecessor setLocalVariableConversionChanged(final LexicalContext lc, final LocalVariableConversion conversion) { return Node.replaceInLexicalContext(lc, this, new ForNode(this, init, test, body, modify, flags, controlFlowEscapes, conversion)); } + + @Override + public boolean hasPerIterationScope() { + return (flags & PER_ITERATION_SCOPE) != 0; + } + + /** + * Set the per-iteration-scope flag on this node. + * @param lc lexical context + * @return the node with flag set + */ + public ForNode setPerIterationScope(final LexicalContext lc) { + return setFlags(lc, flags | PER_ITERATION_SCOPE); + } }