1 19 20 package jode.type; 21 import jode.GlobalOptions; 22 import jode.bytecode.ClassInfo; 23 import java.util.Vector ; 24 import java.util.Stack ; 25 26 47 public abstract class ReferenceType extends Type { 48 public ReferenceType(int typecode) { 49 super(typecode); 50 } 51 52 59 public abstract Type getSpecializedType(Type type); 60 68 public abstract Type getGeneralizedType(Type type); 69 78 public abstract Type createRangeType(ReferenceType bottom); 79 80 91 protected static boolean implementsAllIfaces(ClassInfo clazz, 92 ClassInfo[] ifaces, 93 ClassInfo[] otherIfaces) { 94 big: 95 for (int i=0; i < otherIfaces.length; i++) { 96 ClassInfo iface = otherIfaces[i]; 97 if (clazz != null && iface.implementedBy(clazz)) 98 continue big; 99 for (int j=0; j < ifaces.length; j++) { 100 if (iface.implementedBy(ifaces[j])) 101 continue big; 102 } 103 return false; 104 } 105 return true; 106 } 107 108 public Type getSuperType() { 109 return (this == tObject) ? tObject : tRange(tObject, this); 110 } 111 112 public abstract Type getSubType(); 113 114 119 public Type intersection(Type type) { 120 if (type == tError) 121 return type; 122 if (type == Type.tUnknown) 123 return this; 124 125 Type newBottom = getSpecializedType(type); 126 Type newTop = getGeneralizedType(type); 127 Type result; 128 if (newTop.equals(newBottom)) 129 result = newTop; 130 else if (newTop instanceof ReferenceType 131 && newBottom instanceof ReferenceType) 132 result = ((ReferenceType) newTop) 133 .createRangeType((ReferenceType) newBottom); 134 else 135 result = tError; 136 137 if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_TYPES) != 0) { 138 GlobalOptions.err.println("intersecting "+ this +" and "+ type + 139 " to " + result); 140 } 141 return result; 142 } 143 } 144 | Popular Tags |