@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 forLoop) { forLoop.getCollectionExpression().visit(this); forLoop.getLoopBlock().visit(this); }
public void visitForLoop(ForStatement forLoop) { forLoop.setCollectionExpression(transform(forLoop.getCollectionExpression())); super.visitForLoop(forLoop); }
@Override public void visitForLoop(ForStatement stat) { stat.getCollectionExpression().visit(this); stat.setLoopBlock(replace(stat.getLoopBlock())); }
public void visitForLoop(final ForStatement forLoop) { assertStatementAuthorized(forLoop); forLoop.getCollectionExpression().visit(this); forLoop.getLoopBlock().visit(this); }
@Override public void visitForLoop(ForStatement stat) { stat.setCollectionExpression(replaceExpr(stat.getCollectionExpression())); stat.setLoopBlock(replace(stat.getLoopBlock())); }
@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); } }
Expression collectionExpression = forLoop.getCollectionExpression(); if (collectionExpression instanceof ClosureListExpression) {
controller.getCompileStack().pushLoop(loop.getVariableScope(), loop.getStatementLabels()); ClosureListExpression clExpr = (ClosureListExpression) loop.getCollectionExpression(); controller.getCompileStack().pushVariableScope(clExpr.getVariableScope());
@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(); }
MethodCallExpression iterator = new MethodCallExpression(loop.getCollectionExpression(), "iterator", new ArgumentListExpression()); iterator.visit(controller.getAcg()); operandStack.doGroovyCast(ClassHelper.Iterator_TYPE);
@Override public void visitForLoop(ForStatement forLoop) { children.add(forLoop.getCollectionExpression()); children.add(forLoop.getLoopBlock()); }
@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 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 forLoop) { forLoop.setCollectionExpression(transform(forLoop.getCollectionExpression())); super.visitForLoop(forLoop); }
public void visitForLoop(ForStatement forLoop) { forLoop.setCollectionExpression(transform(forLoop.getCollectionExpression())); super.visitForLoop(forLoop); }
public void visitForLoop(final ForStatement forLoop) { assertStatementAuthorized(forLoop); forLoop.getCollectionExpression().visit(this); forLoop.getLoopBlock().visit(this); }
@Override public void visitForLoop(ForStatement stat) { stat.getCollectionExpression().visit(this); stat.setLoopBlock(replace(stat.getLoopBlock())); }
@Override public void visitForLoop(ForStatement stat) { stat.setCollectionExpression(replaceExpr(stat.getCollectionExpression())); stat.setLoopBlock(replace(stat.getLoopBlock())); }
@Override public void run() { loc(forLoop); literal(forLoop.getStatementLabel()); literal(forLoop.getVariableType()); literal(forLoop.getVariable().getName()); visit(forLoop.getCollectionExpression()); visitWithSafepoint(forLoop.getLoopBlock()); } });