static <T extends Statement> Statement accept(T node, Shuttle shuttle) { if (node == null) { return null; } return node.accept(shuttle); }
@Override public abstract Statement accept(Shuttle shuttle); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } TryStatement that = (TryStatement) o; if (!body.equals(that.body)) { return false; } if (!catchBlocks.equals(that.catchBlocks)) { return false; } if (fynally != null ? !fynally.equals(that.fynally) : that.fynally != null) { return false; } return true; }
public TryStatement(Statement body, List<CatchBlock> catchBlocks, Statement fynally) { super(ExpressionType.Try, body.getType()); this.body = Objects.requireNonNull(body); this.catchBlocks = Objects.requireNonNull(catchBlocks); this.fynally = fynally; }
@Override public Object evaluate(Evaluator evaluator) { Object o = null; for (Statement statement : statements) { o = statement.evaluate(evaluator); } return o; }
/** * Creates a BlockExpression that contains the given expressions, * has no variables and has specific result type. */ public static BlockStatement block(Type type, Iterable<? extends Statement> expressions) { List<Statement> list = toList(expressions); if (type == null) { if (list.size() > 0) { type = list.get(list.size() - 1).getType(); } else { type = Void.TYPE; } } return new BlockStatement(list, type); }
public R visit(TryStatement tryStatement) { R r = tryStatement.body.accept(this); for (CatchBlock catchBlock : tryStatement.catchBlocks) { r = catchBlock.parameter.accept(this); r = catchBlock.body.accept(this); } if (tryStatement.fynally != null) { r = tryStatement.fynally.accept(this); } return r; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } BlockStatement that = (BlockStatement) o; if (!statements.equals(that.statements)) { return false; } return true; }
public R visit(WhileStatement whileStatement) { R r0 = whileStatement.condition.accept(this); return whileStatement.body.accept(this); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } ConditionalStatement that = (ConditionalStatement) o; if (!expressionList.equals(that.expressionList)) { return false; } return true; }
static List<Statement> acceptStatements(List<Statement> statements, Shuttle shuttle) { if (statements.isEmpty()) { return statements; // short cut } final List<Statement> statements1 = new ArrayList<>(); for (Statement statement : statements) { Statement newStatement = statement.accept(shuttle); if (newStatement instanceof GotoStatement) { GotoStatement goto_ = (GotoStatement) newStatement; if (goto_.kind == GotoExpressionKind.Sequence && goto_.expression == null) { // ignore empty statements continue; } } statements1.add(newStatement); } return statements1; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } WhileStatement that = (WhileStatement) o; if (!body.equals(that.body)) { return false; } if (!condition.equals(that.condition)) { return false; } return true; }
@Override void accept0(ExpressionWriter writer) { if (statements.isEmpty()) { writer.append("{}"); return; } writer.begin("{\n"); for (Statement node : statements) { node.accept(writer, 0, 0); } writer.end("}\n"); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CatchBlock that = (CatchBlock) o; if (body != null ? !body.equals(that.body) : that.body != null) { return false; } if (parameter != null ? !parameter.equals(that.parameter) : that .parameter != null) { return false; } return true; }
@Override public Statement accept(Shuttle shuttle) { shuttle = shuttle.preVisit(this); final Expression condition1 = condition.accept(shuttle); final Statement body1 = body.accept(shuttle); return shuttle.visit(this, condition1, body1); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } ThrowStatement that = (ThrowStatement) o; if (expression != null ? !expression.equals(that.expression) : that .expression != null) { return false; } return true; }
public R visit(ForStatement forStatement) { R r0 = Expressions.acceptNodes(forStatement.declarations, this); R r1 = forStatement.condition.accept(this); R r2 = forStatement.post.accept(this); return forStatement.body.accept(this); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } LabelStatement that = (LabelStatement) o; if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that .defaultValue != null) { return false; } return true; }
statement.accept(useCounter); Statement beforeOptimize = oldStatement; if (!subMap.isEmpty()) { oldStatement = oldStatement.accept(visitor); // remap oldStatement = oldStatement.accept(optimizer); if (beforeOptimize != oldStatement) { ++optimizeCount; Statement beforeOptimize = oldStatement; if (!subMap.isEmpty()) { oldStatement = oldStatement.accept(visitor); // remap oldStatement = oldStatement.accept(optimizer); if (beforeOptimize != oldStatement) { ++optimizeCount;
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } ForStatement that = (ForStatement) o; if (!body.equals(that.body)) { return false; } if (condition != null ? !condition.equals(that.condition) : that .condition != null) { return false; } if (!declarations.equals(that.declarations)) { return false; } if (post != null ? !post.equals(that.post) : that.post != null) { return false; } return true; }