1 package polyglot.ext.jl.ast; 2 3 import polyglot.ast.*; 4 import polyglot.types.*; 5 import polyglot.visit.*; 6 import polyglot.util.*; 7 import java.util.*; 8 9 13 public class Eval_c extends Stmt_c implements Eval 14 { 15 protected Expr expr; 16 17 public Eval_c(Position pos, Expr expr) { 18 super(pos); 19 this.expr = expr; 20 } 21 22 23 public Expr expr() { 24 return this.expr; 25 } 26 27 28 public Eval expr(Expr expr) { 29 Eval_c n = (Eval_c) copy(); 30 n.expr = expr; 31 return n; 32 } 33 34 35 protected Eval_c reconstruct(Expr expr) { 36 if (expr != this.expr) { 37 Eval_c n = (Eval_c) copy(); 38 n.expr = expr; 39 return n; 40 } 41 42 return this; 43 } 44 45 public Type childExpectedType(Expr child, AscriptionVisitor av) { 46 TypeSystem ts = av.typeSystem(); 47 48 if (child == expr) { 49 return ts.Void(); 50 } 51 52 return child.type(); 53 } 54 55 56 public Node visitChildren(NodeVisitor v) { 57 Expr expr = (Expr) visitChild(this.expr, v); 58 return reconstruct(expr); 59 } 60 61 public String toString() { 62 return "eval(" + expr.toString() + ");"; 63 } 64 65 66 public void prettyPrint(CodeWriter w, PrettyPrinter tr) { 67 boolean semi = tr.appendSemicolon(true); 68 69 print(expr, w, tr); 70 71 if (semi) { 72 w.write(";"); 73 } 74 75 tr.appendSemicolon(semi); 76 } 77 78 public Term entry() { 79 return expr.entry(); 80 } 81 82 public List acceptCFG(CFGBuilder v, List succs) { 83 v.visitCFG(expr, this); 84 return succs; 85 } 86 } 87 | Popular Tags |