public void writeForStatement(ForStatement loop) { Parameter loopVar = loop.getVariable(); if (loopVar == ForStatement.FOR_LOOP_DUMMY) { writeForLoopWithClosureList(loop); } else { writeForInLoop(loop); } }
@Override public void visitForLoop(final ForStatement forLoop) { super.visitForLoop(forLoop); Expression collectionExpression = forLoop.getCollectionExpression(); if (!(collectionExpression instanceof ClosureListExpression)) { final ClassNode collectionType = getType(forLoop.getCollectionExpression()); ClassNode forLoopVariableType = forLoop.getVariableType(); ClassNode componentType; if (Character_TYPE.equals(ClassHelper.getWrapper(forLoopVariableType)) && STRING_TYPE.equals(collectionType)) { // we allow auto-coercion here componentType = forLoopVariableType; } else { componentType = inferLoopElementType(collectionType); } forLoop.getVariable().setType(componentType); forLoop.getVariable().setOriginType(componentType); } }
@Override protected void writeForInLoop(final ForStatement loop) { controller.getAcg().onLineNumber(loop,"visitForLoop"); writeStatementLabel(loop); CompileStack compileStack = controller.getCompileStack(); MethodVisitor mv = controller.getMethodVisitor(); OperandStack operandStack = controller.getOperandStack(); compileStack.pushLoop(loop.getVariableScope(), loop.getStatementLabels()); // Identify type of collection TypeChooser typeChooser = controller.getTypeChooser(); Expression collectionExpression = loop.getCollectionExpression(); ClassNode collectionType = typeChooser.resolveType(collectionExpression, controller.getClassNode()); Parameter loopVariable = loop.getVariable(); int size = operandStack.getStackLength(); if (collectionType.isArray() && loopVariable.getOriginType().equals(collectionType.getComponentType())) { writeOptimizedForEachLoop(compileStack, operandStack, mv, loop, collectionExpression, collectionType, loopVariable); } else if (ENUMERATION_CLASSNODE.equals(collectionType)) { writeEnumerationBasedForEachLoop(compileStack, operandStack, mv, loop, collectionExpression, collectionType, loopVariable); } else { writeIteratorBasedForEachLoop(compileStack, operandStack, mv, loop, collectionExpression, collectionType, loopVariable); } operandStack.popDownTo(size); compileStack.pop(); }
@Override public void visitForLoop(ForStatement forLoop) { Expression exp = forLoop.getCollectionExpression(); exp.visit(this); Parameter loopParam = forLoop.getVariable(); if (loopParam != null) { varStack.getLast().add(loopParam.getName()); } super.visitForLoop(forLoop); }
typeCheckingContext.controlStructureVariables.put(forLoop.getVariable(), componentType); try { super.visitForLoop(forLoop); } finally { typeCheckingContext.controlStructureVariables.remove(forLoop.getVariable());
BytecodeVariable variable = compileStack.defineVariable(loop.getVariable(), false);
public void visitForLoop(ForStatement expression) { assertValidIdentifier(expression.getVariable().getName(), "for loop variable name", expression); super.visitForLoop(expression); }
@Override public void run() { loc(forLoop); literal(forLoop.getStatementLabel()); literal(forLoop.getVariableType()); literal(forLoop.getVariable().getName()); visit(forLoop.getCollectionExpression()); visitWithSafepoint(forLoop.getLoopBlock()); } });
public void visitForLoop(ForStatement forLoop) { pushState(); forLoop.setVariableScope(currentScope); Parameter p = forLoop.getVariable(); p.setInStaticContext(currentScope.isInStaticContext()); if (p != ForStatement.FOR_LOOP_DUMMY) declare(p, forLoop); super.visitForLoop(forLoop); popState(); }
@Override public void visitForLoop(ForStatement forLoop) { if (!blocks.remove(forLoop)) { return; } Parameter param = forLoop.getVariable(); if (param != ForStatement.FOR_LOOP_DUMMY) { variables.put(param.getName(), param); } super.visitForLoop(forLoop); }
public void writeForStatement(ForStatement loop) { Parameter loopVar = loop.getVariable(); if (loopVar == ForStatement.FOR_LOOP_DUMMY) { writeForLoopWithClosureList(loop); } else { writeForInLoop(loop); } }
public void visitForLoop(ForStatement forLoop) { Expression exp = forLoop.getCollectionExpression(); exp.visit(this); Parameter loopParam = forLoop.getVariable(); if (loopParam != null) { varStack.getLast().add(loopParam.getName()); } super.visitForLoop(forLoop); }
@Override public void visitForLoop(ForStatement forLoop) { Expression exp = forLoop.getCollectionExpression(); exp.visit(this); Parameter loopParam = forLoop.getVariable(); if (loopParam != null) { varStack.getLast().add(loopParam.getName()); } super.visitForLoop(forLoop); }
public void visitForLoop(ForStatement expression) { assertValidIdentifier(expression.getVariable().getName(), "for loop variable name", expression); super.visitForLoop(expression); }
public void visitForLoop(ForStatement expression) { assertValidIdentifier(expression.getVariable().getName(), "for loop variable name", expression); super.visitForLoop(expression); }
public void visitForLoop(ForStatement expression) { assertValidIdentifier(expression.getVariable().getName(), "for loop variable name", expression); super.visitForLoop(expression); }
public void visitForLoop(ForStatement forLoop) { pushState(); forLoop.setVariableScope(currentScope); Parameter p = forLoop.getVariable(); p.setInStaticContext(currentScope.isInStaticContext()); if (p != ForStatement.FOR_LOOP_DUMMY) declare(p, forLoop); super.visitForLoop(forLoop); popState(); }
public void visitForLoop(ForStatement forLoop) { pushState(); forLoop.setVariableScope(currentScope); Parameter p = (Parameter) forLoop.getVariable(); p.setInStaticContext(currentScope.isInStaticContext()); if (p != ForStatement.FOR_LOOP_DUMMY) declare(p, forLoop); super.visitForLoop(forLoop); popState(); }
public void visitForLoop(ForStatement forLoop) { pushState(); forLoop.setVariableScope(currentScope); Parameter p = (Parameter) forLoop.getVariable(); p.setInStaticContext(currentScope.isInStaticContext()); if (p != ForStatement.FOR_LOOP_DUMMY) declare(p, forLoop); super.visitForLoop(forLoop); popState(); }
public void visitForLoop(ForStatement forLoop) { pushState(); forLoop.setVariableScope(currentScope); Parameter p = (Parameter) forLoop.getVariable(); p.setInStaticContext(currentScope.isInStaticContext()); if (p != ForStatement.FOR_LOOP_DUMMY) declare(p, forLoop); super.visitForLoop(forLoop); popState(); }