1 package polyglot.ext.jl.types; 2 3 import polyglot.types.*; 4 import polyglot.util.*; 5 import polyglot.types.Package; 6 import java.io.*; 7 8 13 public abstract class Type_c extends TypeObject_c implements Type 14 { 15 16 protected Type_c() { } 17 18 19 public Type_c(TypeSystem ts) { 20 this(ts, null); 21 } 22 23 24 public Type_c(TypeSystem ts, Position pos) { 25 super(ts, pos); 26 } 27 28 33 public abstract String translate(Resolver c); 34 35 public boolean isType() { return true; } 36 public boolean isPackage() { return false; } 37 public Type toType() { return this; } 38 public Package toPackage() { return null; } 39 40 41 public boolean isCanonical() { return false; } 42 43 public boolean isPrimitive() { return false; } 44 public boolean isNumeric() { return false; } 45 public boolean isIntOrLess() { return false; } 46 public boolean isLongOrLess() { return false; } 47 public boolean isVoid() { return false; } 48 public boolean isBoolean() { return false; } 49 public boolean isChar() { return false; } 50 public boolean isByte() { return false; } 51 public boolean isShort() { return false; } 52 public boolean isInt() { return false; } 53 public boolean isLong() { return false; } 54 public boolean isFloat() { return false; } 55 public boolean isDouble() { return false; } 56 57 public boolean isReference() { return false; } 58 public boolean isNull() { return false; } 59 public boolean isClass() { return false; } 60 public boolean isArray() { return false; } 61 62 65 public boolean isThrowable() { 66 return false; 67 } 68 69 72 public boolean isUncheckedException() { 73 return false; 74 } 75 76 77 public ClassType toClass() { 78 return null; 79 } 80 81 82 public NullType toNull() { 83 return null; 84 } 85 86 87 public ReferenceType toReference() { 88 return null; 89 } 90 91 92 public PrimitiveType toPrimitive() { 93 return null; 94 } 95 96 97 public ArrayType toArray() { 98 return null; 99 } 100 101 104 public ArrayType arrayOf(int dims) { 105 return ts.arrayOf(this, dims); 106 } 107 108 111 public ArrayType arrayOf() { 112 return ts.arrayOf(this); 113 } 114 115 118 public final boolean isSubtype(Type t) { 119 return ts.isSubtype(this, t); 120 } 121 122 125 public boolean isSubtypeImpl(Type t) { 126 return ts.equals(this, t) || ts.descendsFrom(this, t); 127 } 128 129 132 public final boolean descendsFrom(Type t) { 133 return ts.descendsFrom(this, t); 134 } 135 136 139 public boolean descendsFromImpl(Type t) { 140 return false; 141 } 142 143 146 public final boolean isCastValid(Type toType) { 147 return ts.isCastValid(this, toType); 148 } 149 150 153 public boolean isCastValidImpl(Type toType) { 154 return false; 155 } 156 157 161 public final boolean isImplicitCastValid(Type toType) { 162 return ts.isImplicitCastValid(this, toType); 163 } 164 165 169 public boolean isImplicitCastValidImpl(Type toType) { 170 return false; 171 } 172 173 177 public final boolean numericConversionValid(long value) { 178 return ts.numericConversionValid(this, value); 179 } 180 181 185 public boolean numericConversionValidImpl(long value) { 186 return false; 187 } 188 189 192 public final boolean numericConversionValid(Object value) { 193 return ts.numericConversionValid(this, value); 194 } 195 196 199 public boolean numericConversionValidImpl(Object value) { 200 return false; 201 } 202 203 207 public boolean isComparable(Type t) { 208 return t.typeSystem() == ts; 209 } 210 211 222 public abstract String toString(); 223 224 private void writeObject(ObjectOutputStream out) throws IOException { 225 if (this instanceof Named) { 228 String name = ((Named) this).fullName(); 229 out.writeObject(name); 230 String memberName = null; 231 if (name != null && this.isClass() && this.toClass().isMember()) { 232 memberName = this.typeSystem().getTransformedClassName(this.toClass()); 233 } 234 out.writeObject(memberName); 235 } 236 237 out.defaultWriteObject(); 238 } 239 240 private void readObject(ObjectInputStream in) 241 throws IOException, ClassNotFoundException 242 { 243 if (this instanceof Named) { 245 String name = (String ) in.readObject(); 246 String memberName = (String ) in.readObject(); 247 TypeSystem ts = ((TypeInputStream) in).getTypeSystem(); 248 249 if (name != null) { 250 ((CachingResolver) ts.systemResolver()).install(name, (Named) this); 251 } 252 253 if (memberName != null) { 254 ((CachingResolver) ts.systemResolver()).install(memberName, (Named) this); 255 } 256 } 257 258 in.defaultReadObject(); 259 } 260 } 261 | Popular Tags |