public void visitWhileLoop(WhileStatement loop) { loop.getBooleanExpression().visit(this); loop.getLoopBlock().visit(this); }
@Override public void visitWhileLoop(WhileStatement stat) { stat.setBooleanExpression((BooleanExpression)replaceExpr(stat.getBooleanExpression())); stat.setLoopBlock(replace(stat.getLoopBlock())); }
@Override public void visitWhileLoop(WhileStatement stat) { stat.getBooleanExpression().visit(this); stat.setLoopBlock(replace(stat.getLoopBlock())); }
public void visitWhileLoop(WhileStatement loop) { loop.setBooleanExpression((BooleanExpression) transform(loop.getBooleanExpression())); super.visitWhileLoop(loop); }
@Override public void run() { literal(loop.getStatementLabel()); visit(loop.getBooleanExpression()); visitWithSafepoint(loop.getLoopBlock()); } });
public void writeWhileLoop(WhileStatement loop) { controller.getAcg().onLineNumber(loop,"visitWhileLoop"); writeStatementLabel(loop); MethodVisitor mv = controller.getMethodVisitor(); controller.getCompileStack().pushLoop(loop.getStatementLabels()); Label continueLabel = controller.getCompileStack().getContinueLabel(); Label breakLabel = controller.getCompileStack().getBreakLabel(); mv.visitLabel(continueLabel); BooleanExpression bool = loop.getBooleanExpression(); boolean boolHandled = false; if (bool.getExpression() instanceof ConstantExpression) { ConstantExpression constant = (ConstantExpression) bool.getExpression(); if (constant.getValue()==Boolean.TRUE) { boolHandled = true; // do nothing } else if (constant.getValue()==Boolean.FALSE) { boolHandled = true; mv.visitJumpInsn(GOTO, breakLabel); } } if(!boolHandled) { bool.visit(controller.getAcg()); controller.getOperandStack().jump(IFEQ, breakLabel); } loop.getLoopBlock().visit(controller.getAcg()); mv.visitJumpInsn(GOTO, continueLabel); mv.visitLabel(breakLabel); controller.getCompileStack().pop(); }
} else if (statement instanceof WhileStatement) { WhileStatement ws = (WhileStatement) statement; Statement loopBlock = ws.getLoopBlock(); BlockStatement newLoopBlock = new BlockStatement(); addStatementToNewQuery(loopBlock, newLoopBlock, addAll, propertyNames, variableScope); ws.setLoopBlock(flattenStatementIfNecessary(newLoopBlock)); newCode.addStatement(ws); } else if (statement instanceof TryCatchStatement) {
protected Statement whileStatement(AST whileNode) { AST node = whileNode.getFirstChild(); assertNodeType(EXPR, node); // TODO remove this once we support declarations in the while condition if (isType(VARIABLE_DEF, node.getFirstChild())) { throw new ASTRuntimeException(whileNode, "While loop condition contains a declaration; this is currently unsupported."); } BooleanExpression booleanExpression = booleanExpression(node); node = node.getNextSibling(); Statement block; if (isType(SEMI, node)) { block = EmptyStatement.INSTANCE; } else { block = statement(node); } WhileStatement whileStatement = new WhileStatement(booleanExpression, block); configureAST(whileStatement, whileNode); return whileStatement; }
public void visitWhileLoop(WhileStatement loop) { onLineNumber(loop, "visitWhileLoop"); visitStatement(loop); compileStack.pushLoop(loop.getStatementLabel()); Label continueLabel = compileStack.getContinueLabel(); Label breakLabel = compileStack.getBreakLabel(); mv.visitLabel(continueLabel); Expression bool = loop.getBooleanExpression(); boolean boolHandled = false; if (bool instanceof ConstantExpression) { ConstantExpression constant = (ConstantExpression) bool; if (constant.getValue()==Boolean.TRUE) { boolHandled = true; // do nothing } else if (constant.getValue()==Boolean.FALSE) { boolHandled = true; mv.visitJumpInsn(GOTO, breakLabel); } } if(!boolHandled) { bool.visit(this); mv.visitJumpInsn(IFEQ, breakLabel); } loop.getLoopBlock().visit(this); mv.visitJumpInsn(GOTO, continueLabel); mv.visitLabel(breakLabel); compileStack.pop(); }
public void visitWhileLoop(WhileStatement loop) { loop.setBooleanExpression((BooleanExpression) transform(loop.getBooleanExpression())); super.visitWhileLoop(loop); }
@Override public void visitWhileLoop(WhileStatement stat) { stat.getBooleanExpression().visit(this); stat.setLoopBlock(replace(stat.getLoopBlock())); }
/** * Represents a while statement. A while loop is a control flow * statement that executes maybe repeatedly a code block, * depending on a given boolean condition. * * @param booleanExpr boolean condition * @param loopBlock the block that could be repeated * @return an instance of type {@link DoWhileStatement} * @since 0.2.7 */ public static WhileStatement whileS(final BooleanExpression booleanExpr, final Statement loopBlock) { return new WhileStatement(booleanExpr, loopBlock); }
public void visitWhileLoop(final WhileStatement loop) { assertStatementAuthorized(loop); loop.getBooleanExpression().visit(this); loop.getLoopBlock().visit(this); }
public void visitWhileLoop(WhileStatement loop) { onLineNumber(loop, "visitWhileLoop"); visitStatement(loop); compileStack.pushLoop(loop.getStatementLabel()); Label continueLabel = compileStack.getContinueLabel(); Label breakLabel = compileStack.getBreakLabel(); mv.visitLabel(continueLabel); Expression bool = loop.getBooleanExpression(); boolean boolHandled = false; if (bool instanceof ConstantExpression) { ConstantExpression constant = (ConstantExpression) bool; if (constant.getValue()==Boolean.TRUE) { boolHandled = true; // do nothing } else if (constant.getValue()==Boolean.FALSE) { boolHandled = true; mv.visitJumpInsn(GOTO, breakLabel); } } if(!boolHandled) { bool.visit(this); mv.visitJumpInsn(IFEQ, breakLabel); } loop.getLoopBlock().visit(this); mv.visitJumpInsn(GOTO, continueLabel); mv.visitLabel(breakLabel); compileStack.pop(); }
@Override public void visitWhileLoop(WhileStatement stat) { stat.setBooleanExpression((BooleanExpression) replaceExpr(stat.getBooleanExpression())); stat.setLoopBlock(replace(stat.getLoopBlock())); }
public void visitWhileLoop(WhileStatement loop) { loop.setBooleanExpression((BooleanExpression) transform(loop.getBooleanExpression())); super.visitWhileLoop(loop); }
protected Statement whileStatement(AST whileNode) { AST node = whileNode.getFirstChild(); assertNodeType(EXPR, node); // TODO remove this once we support declarations in the while condition if (isType(VARIABLE_DEF, node.getFirstChild())) { throw new ASTRuntimeException(whileNode, "While loop condition contains a declaration; this is currently unsupported."); } BooleanExpression booleanExpression = booleanExpression(node); node = node.getNextSibling(); Statement block; if (isType(SEMI, node)) { block = EmptyStatement.INSTANCE; } else { block = statement(node); } WhileStatement whileStatement = new WhileStatement(booleanExpression, block); configureAST(whileStatement, whileNode); return whileStatement; }
@Override public void visitWhileLoop(WhileStatement loop) { children.add(loop.getBooleanExpression()); children.add(loop.getLoopBlock()); }
public void visitWhileLoop(WhileStatement loop) { onLineNumber(loop, "visitWhileLoop"); visitStatement(loop); compileStack.pushLoop(loop.getStatementLabel()); Label continueLabel = compileStack.getContinueLabel(); Label breakLabel = compileStack.getBreakLabel(); mv.visitLabel(continueLabel); Expression bool = loop.getBooleanExpression(); boolean boolHandled = false; if (bool instanceof ConstantExpression) { ConstantExpression constant = (ConstantExpression) bool; if (constant.getValue()==Boolean.TRUE) { boolHandled = true; // do nothing } else if (constant.getValue()==Boolean.FALSE) { boolHandled = true; mv.visitJumpInsn(GOTO, breakLabel); } } if(!boolHandled) { bool.visit(this); mv.visitJumpInsn(IFEQ, breakLabel); } loop.getLoopBlock().visit(this); mv.visitJumpInsn(GOTO, continueLabel); mv.visitLabel(breakLabel); compileStack.pop(); }
public void visitWhileLoop(WhileStatement loop) { loop.setBooleanExpression((BooleanExpression) transform(loop.getBooleanExpression())); super.visitWhileLoop(loop); }