@Test public void accept() throws Exception { BinaryExpr be = new BinaryExpr(new IntConstantExpr("1"), new IntConstantExpr("1"), BinOp.ADD); BinaryExpr theExpr = new BinaryExpr(be.clone(), be.clone(), BinOp.ADD); theExpr = new BinaryExpr(theExpr.clone(), theExpr.clone(), BinOp.ADD); int numBinariesInExpr = new StandardVisitor() { private int numBinaries; @Override public void visitBinaryExpr(BinaryExpr binaryExpr) { super.visitBinaryExpr(binaryExpr); numBinaries++; } int getNumBinaries(Expr e) { numBinaries = 0; visit(e); return numBinaries; } }.getNumBinaries(theExpr); assertEquals(7, numBinariesInExpr); }
@Override public void accept(IAstVisitor visitor) { visitor.visitBinaryExpr(this); }
BinaryExpr extends Expr { @Override public void accept(IAstVisitor visitor) { visitor.visitBinaryExpr(this); } }
BinaryExpr extends Expr { @Override public void accept(IAstVisitor visitor) { visitor.visitBinaryExpr(this); } BinaryExpr(Expr lhs, Expr rhs, BinOp op); }
BinaryExpr extends Expr { @Override public void accept(IAstVisitor visitor) { visitor.visitBinaryExpr(this); } BinaryExpr(Expr lhs, Expr rhs, BinOp op); Expr getLhs(); void setLhs(Expr lhs); Expr getRhs(); void setRhs(Expr rhs); BinOp getOp(); @Override void accept(IAstVisitor visitor); @Override BinaryExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren(); }
BinaryExpr extends Expr { @Override public void accept(IAstVisitor visitor) { visitor.visitBinaryExpr(this); } BinaryExpr(Expr lhs, Expr rhs, BinOp op); Expr getLhs(); void setLhs(Expr lhs); Expr getRhs(); void setRhs(Expr rhs); BinOp getOp(); @Override void accept(IAstVisitor visitor); @Override BinaryExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren();  }