1 package polyglot.ext.jl.ast; 2 3 import polyglot.ast.*; 4 import polyglot.types.*; 5 import polyglot.visit.*; 6 import polyglot.util.*; 7 8 12 public class AmbPrefix_c extends Node_c implements AmbPrefix 13 { 14 protected Prefix prefix; 15 protected String name; 16 17 public AmbPrefix_c(Position pos, Prefix prefix, String name) { 18 super(pos); 19 this.prefix = prefix; 20 this.name = name; 21 } 22 23 24 public String name() { 25 return this.name; 26 } 27 28 29 public AmbPrefix name(String name) { 30 AmbPrefix_c n = (AmbPrefix_c) copy(); 31 n.name = name; 32 return n; 33 } 34 35 36 public Prefix prefix() { 37 return this.prefix; 38 } 39 40 41 public AmbPrefix prefix(Prefix prefix) { 42 AmbPrefix_c n = (AmbPrefix_c) copy(); 43 n.prefix = prefix; 44 return n; 45 } 46 47 48 protected AmbPrefix_c reconstruct(Prefix prefix) { 49 if (prefix != this.prefix) { 50 AmbPrefix_c n = (AmbPrefix_c) copy(); 51 n.prefix = prefix; 52 return n; 53 } 54 55 return this; 56 } 57 58 59 public Node visitChildren(NodeVisitor v) { 60 Prefix prefix = (Prefix) visitChild(this.prefix, v); 61 return reconstruct(prefix); 62 } 63 64 65 public Node disambiguate(AmbiguityRemover ar) throws SemanticException { 66 return ar.nodeFactory().disamb().disambiguate(this, ar, position(), prefix, name); 67 } 68 69 70 public Node typeCheck(TypeChecker tc) throws SemanticException { 71 throw new InternalCompilerError(position(), 72 "Cannot type check ambiguous node " + this + "."); 73 } 74 75 76 public Node exceptionCheck(ExceptionChecker ec) throws SemanticException { 77 throw new InternalCompilerError(position(), 78 "Cannot exception check ambiguous node " + this + "."); 79 } 80 81 82 public void prettyPrint(CodeWriter w, PrettyPrinter tr) { 83 if (prefix != null) { 84 print(prefix, w, tr); 85 w.write("."); 86 } 87 88 w.write(name); 89 } 90 91 public void translate(CodeWriter w, Translator tr) { 92 throw new InternalCompilerError(position(), 93 "Cannot translate ambiguous node " + this + "."); 94 } 95 96 public String toString() { 97 return (prefix == null 98 ? name 99 : prefix.toString() + "." + name) + "{amb}"; 100 } 101 } 102 | Popular Tags |