@Override public void endVisit(VariableDeclarationStatement node) { Collection<VMVariableDeclarationFragment> vars = new ArrayList<VMVariableDeclarationFragment>(); for (int i = 0; i < node.fragments().size(); i++) { vars.add((VMVariableDeclarationFragment) (expressions.pop())); } VMVariableDeclarationStatement statement = VM.asVariableDeclarationStatement(node, vars); topBlock.getStatements().add(statement); }
@Override public void endVisit(ClassInstanceCreation node) { Stack<VMExpression> arguments = new Stack<VMExpression>(); for (int i = 0; i < node.arguments().size(); i++) { arguments.push((VMExpression) expressions.pop()); } VMClassInstanceCreation classInstanceCreation = VM.createClassInstanceCreation(node.getType(), node); while (!arguments.empty()) classInstanceCreation.getArguments().add(arguments.pop()); expressions.push(classInstanceCreation); };
public boolean visit(TryStatement node) { VMTryStatement tryStatement = VM.createTryStatement(node); topBlock = tryStatement; blocks.push(tryStatement); return true; }
public boolean visit(ForStatement node) { VMForStatement forStatement = VM.createForStatement(node); topBlock = forStatement; blocks.push(forStatement); return true; }
public boolean visit(WhileStatement node) { VMWhileStatement whileStatement = VM.createWhileStatement(node); topBlock = whileStatement; blocks.push(whileStatement); return true; }
public boolean visit(IfStatement node) { VMIfStatement ifStatement = VM.createIfStatement(node); topBlock = ifStatement; blocks.push(ifStatement); return true; }
@Override public void endVisit(ExpressionStatement node) { VMExpressionStatement statement = VM.asVMExpressionStatement(node, (VMExpression) (expressions.pop())); topBlock.getStatements().add(statement); }