1 package polyglot.ext.jl.types; 2 3 import polyglot.types.*; 4 import polyglot.util.*; 5 6 10 public class NullType_c extends Type_c implements NullType 11 { 12 13 protected NullType_c() { } 14 15 public NullType_c(TypeSystem ts) { 16 super(ts); 17 } 18 19 public String translate(Resolver c) { 20 throw new InternalCompilerError("Cannot translate a null type."); 21 } 22 23 public String toString() { 24 return "type(null)"; 25 } 26 27 public boolean equalsImpl(TypeObject t) { 28 return t instanceof NullType; 29 } 30 31 public int hashCode() { 32 return 6060842; 33 } 34 35 public boolean isCanonical() { return true; } 36 public boolean isNull() { return true; } 37 38 public NullType toNull() { return this; } 39 40 public boolean descendsFromImpl(Type ancestor) { 41 if (ancestor.isNull()) return false; 42 if (ancestor.isReference()) return true; 43 return false; 44 } 45 46 public boolean isImplicitCastValidImpl(Type toType) { 47 return toType.isNull() || toType.isReference(); 48 } 49 50 56 public boolean isCastValidImpl(Type toType) { 57 return toType.isNull() || toType.isReference(); 58 } 59 } 60 | Popular Tags |