< prev index next >

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

Print this page

        

*** 1759,1769 **** public boolean enterForNode(final ForNode forNode) { if(!method.isReachable()) { return false; } enterStatement(forNode); ! if (forNode.isForIn()) { enterForIn(forNode); } else { final Expression init = forNode.getInit(); if (init != null) { loadAndDiscard(init); --- 1759,1769 ---- public boolean enterForNode(final ForNode forNode) { if(!method.isReachable()) { return false; } enterStatement(forNode); ! if (forNode.isForIn() || forNode.isForOf()) { enterForIn(forNode); } else { final Expression init = forNode.getInit(); if (init != null) { loadAndDiscard(init);
*** 1774,1784 **** return false; } private void enterForIn(final ForNode forNode) { loadExpression(forNode.getModify(), TypeBounds.OBJECT); ! method.invoke(forNode.isForEach() ? ScriptRuntime.TO_VALUE_ITERATOR : ScriptRuntime.TO_PROPERTY_ITERATOR); final Symbol iterSymbol = forNode.getIterator(); final int iterSlot = iterSymbol.getSlot(Type.OBJECT); method.store(iterSymbol, ITERATOR_TYPE); method.beforeJoinPoint(forNode); --- 1774,1792 ---- return false; } private void enterForIn(final ForNode forNode) { loadExpression(forNode.getModify(), TypeBounds.OBJECT); ! if (forNode.isForEach()) { ! method.invoke(ScriptRuntime.TO_VALUE_ITERATOR); ! } else if (forNode.isForIn()) { ! method.invoke(ScriptRuntime.TO_PROPERTY_ITERATOR); ! } else if (forNode.isForOf()) { ! method.invoke(ScriptRuntime.TO_ES6_ITERATOR); ! } else { ! throw new IllegalArgumentException("Unexpected for node"); ! } final Symbol iterSymbol = forNode.getIterator(); final int iterSlot = iterSymbol.getSlot(Type.OBJECT); method.store(iterSymbol, ITERATOR_TYPE); method.beforeJoinPoint(forNode);
*** 3324,3334 **** // However, don't do this for CONST which always has an initializer except in the special case of // for-in/of loops, in which it is initialized in the loop header and should be left untouched here. if (needsScope && varNode.isLet()) { method.loadCompilerConstant(SCOPE); method.loadUndefined(Type.OBJECT); ! final int flags = getScopeCallSiteFlags(identSymbol) | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0); assert isFastScope(identSymbol); storeFastScopeVar(identSymbol, flags); } return false; } --- 3332,3342 ---- // However, don't do this for CONST which always has an initializer except in the special case of // for-in/of loops, in which it is initialized in the loop header and should be left untouched here. if (needsScope && varNode.isLet()) { method.loadCompilerConstant(SCOPE); method.loadUndefined(Type.OBJECT); ! final int flags = getScopeCallSiteFlags(identSymbol) | CALLSITE_DECLARE; assert isFastScope(identSymbol); storeFastScopeVar(identSymbol, flags); } return false; }
< prev index next >