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 AmbExpr_c extends Expr_c implements AmbExpr 14 { 15 protected String name; 16 17 public AmbExpr_c(Position pos, String name) { 18 super(pos); 19 this.name = name; 20 } 21 22 23 public Precedence precedence() { 24 return Precedence.LITERAL; 25 } 26 27 28 public String name() { 29 return this.name; 30 } 31 32 33 public AmbExpr name(String name) { 34 AmbExpr_c n = (AmbExpr_c) copy(); 35 n.name = name; 36 return n; 37 } 38 39 40 public Node disambiguate(AmbiguityRemover ar) throws SemanticException { 41 Node n = ar.nodeFactory().disamb().disambiguate(this, ar, position(), 42 null, name); 43 44 if (n instanceof Expr) { 45 return n; 46 } 47 48 throw new SemanticException("Could not find field or local " + 49 "variable \"" + name + "\".", position()); 50 } 51 52 53 public Node typeCheck(TypeChecker tc) throws SemanticException { 54 throw new InternalCompilerError(position(), 55 "Cannot type check ambiguous node " 56 + this + "."); 57 } 58 59 60 public Node exceptionCheck(ExceptionChecker ec) throws SemanticException { 61 throw new InternalCompilerError(position(), 62 "Cannot exception check ambiguous node " 63 + this + "."); 64 } 65 66 67 public void prettyPrint(CodeWriter w, PrettyPrinter tr) { 68 w.write(name); 69 } 70 71 public void translate(CodeWriter w, Translator tr) { 72 throw new InternalCompilerError(position(), 73 "Cannot translate ambiguous node " 74 + this + "."); 75 } 76 77 public String toString() { 78 return name + "{amb}"; 79 } 80 81 85 public Term entry() { 86 return this; 87 } 88 89 92 public List acceptCFG(CFGBuilder v, List succs) { 93 return succs; 94 } 95 96 public void dump(CodeWriter w) { 97 super.dump(w); 98 w.allowBreak(4, " "); 99 w.begin(0); 100 w.write("(name \"" + name + "\")"); 101 w.end(); 102 } 103 } 104 | Popular Tags |