/** * Creates a BlockExpression that contains the given statements. */ public static BlockStatement block( Iterable<? extends Statement> statements) { return block((Type) null, statements); }
public BlockStatement visit(BlockStatement blockStatement, List<Statement> statements) { return statements.equals(blockStatement.statements) ? blockStatement : Expressions.block(statements); }
/** * Creates a BlockExpression that contains the given statements, * using varargs. */ public static BlockStatement block(Statement... statements) { return block(toList(statements)); }
/** * Creates a BlockExpression that contains the given statements * and has a specific result type, using varargs. */ public static BlockStatement block(Type type, Statement... statements) { return block(type, toList(statements)); }
/** * Prepends a statement to a block. */ public static BlockStatement create(Statement statement, BlockStatement block) { return Expressions.block( Expressions.list(statement).appendAll(block.statements)); }
private static BlockStatement toFunctionBlock(Node body, boolean function) { if (body instanceof BlockStatement) { return (BlockStatement) body; } Statement statement; if (body instanceof Statement) { statement = (Statement) body; } else if (body instanceof Expression) { if (((Expression) body).getType() == Void.TYPE && function) { statement = Expressions.statement((Expression) body); } else { statement = Expressions.return_(null, (Expression) body); } } else { throw new AssertionError("block cannot contain node that is neither " + "statement nor expression: " + body); } return Expressions.block(statement); }
/** * Returns a block consisting of the current list of statements. */ public BlockStatement toBlock() { if (optimizing) { // We put an artificial limit of 10 iterations just to prevent an endless // loop. Optimize should not loop forever, however it is hard to prove if // it always finishes in reasonable time. for (int i = 0; i < 10; i++) { if (!optimize(createOptimizeShuttle(), true)) { break; } } optimize(createFinishingOptimizeShuttle(), false); } return Expressions.block(statements); }
input.type))); final BlockStatement block = Expressions.block( Iterables.concat( ImmutableList.of(
input.type))); final BlockStatement block = Expressions.block( Iterables.concat( stashed,
null, Expressions.constant(true)))); moveNextBody = Expressions.block( Expressions.while_( Expressions.call(
null, Expressions.constant(true)))); moveNextBody = Expressions.block( Expressions.while_( Expressions.call(