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 13 public abstract class Ext_c implements Ext { 14 protected Node node; 15 protected Ext ext; 16 17 public Ext_c(Ext ext) { 18 this.node = null; 19 this.ext = ext; 20 } 21 22 public Ext_c() { 23 this(null); 24 this.node = null; 25 } 26 27 31 public void init(Node node) { 32 if (this.node != null) { 33 throw new InternalCompilerError("Already initialized."); 34 } 35 36 this.node = node; 37 38 if (this.ext != null) { 39 this.ext.init(node); 40 } 41 } 42 43 46 public Node node() { 47 return node; 48 } 49 50 53 public Ext ext() { 54 return ext; 55 } 56 57 public Ext ext(Ext ext) { 58 Ext old = this.ext; 59 this.ext = null; 60 61 Ext_c copy = (Ext_c) copy(); 62 63 copy.ext = ext; 64 65 this.ext = old; 66 67 return copy; 68 } 69 70 73 public Object copy() { 74 try { 75 Ext_c copy = (Ext_c) super.clone(); 76 if (ext != null) { 77 copy.ext = (Ext) ext.copy(); 78 } 79 copy.node = null; return copy; 81 } 82 catch (CloneNotSupportedException e) { 83 throw new InternalCompilerError("Java clone() weirdness."); 84 } 85 } 86 87 public String toString() { 88 return StringUtil.getShortNameComponent(getClass().getName()); 89 } 90 91 94 public void dump(CodeWriter w) { 95 w.write(toString()); 96 } 97 } 98 | Popular Tags |