public JSTypeInference(IR ir, IClassHierarchy cha) { super(ir, new PointType(cha.lookupClass(JavaScriptTypes.Boolean)), true); }
@Override public ContextItem get(ContextKey name) { if (name == ContextKey.RECEIVER) { return type; } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); return new FilteredPointerKey.SingleClassFilter(cls); } else { return null; } } else { return null; } }
public boolean isArrayType() { return getType().isArrayClass(); }
public JSTypeInference(IR ir, IClassHierarchy cha) { super(ir, new PointType(cha.lookupClass(JavaScriptTypes.Boolean)), true); }
public boolean isArrayType() { return getType().isArrayClass(); }
@Override public ContextItem get(ContextKey name) { if (name == ContextKey.RECEIVER) { return type; } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); return new FilteredPointerKey.SingleClassFilter(cls); } else { return null; } } else { return null; } }
/** * If the {@link CallSiteReference} invokes a method we understand and c is a type constant, return a {@link JavaTypeContext} * representing the type named by s, if we can resolve it in the {@link IClassHierarchy}. */ @Override public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { if (receiver != null && receiver.length > 0 && mayUnderstand(callee, receiver[0])) { return new JavaTypeContext(new PointType(getTypeConstant(receiver[0]))); } return null; }
public SetType(PointType[] points) { if (points == null) { throw new IllegalArgumentException("points is null"); } if (points.length == 0) { throw new IllegalArgumentException("points.length == 0"); } types = HashSetFactory.make(points.length); int h = 0; for (int i = 0; i < points.length; i++) { if (points[i] == null) { throw new IllegalArgumentException("points[" + i + "] is null"); } TypeReference T = points[i].getType().getReference(); h ^= T.hashCode(); types.add(T); } hashCode = h; }
/** * @param c a context * @return If this is an object-sensitive context that identifies a unique class for the receiver object, then return the unique * class. Else, return null. * @throws IllegalArgumentException if c is null */ public static IClass getConcreteClassFromContext(Context c) { if (c == null) { throw new IllegalArgumentException("c is null"); } ContextItem item = c.get(ContextKey.RECEIVER); if (item == null) { return null; } else { if (item instanceof PointType) { return ((PointType) item).getIClass(); } else if (item instanceof InstanceKey) { return ((InstanceKey) item).getConcreteType(); } else { Assertions.UNREACHABLE("Unexpected: " + item.getClass()); return null; } } }
/** * If the {@link CallSiteReference} invokes a method we understand and c is a type constant, return a {@link JavaTypeContext} * representing the type named by s, if we can resolve it in the {@link IClassHierarchy}. */ @Override public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { if (receiver != null && receiver.length > 0 && mayUnderstand(callee, receiver[0])) { return new JavaTypeContext(new PointType(getTypeConstant(receiver[0]))); } return null; }
public SetType(PointType[] points) { if (points == null) { throw new IllegalArgumentException("points is null"); } if (points.length == 0) { throw new IllegalArgumentException("points.length == 0"); } types = HashSetFactory.make(points.length); int h = 0; for (int i = 0; i < points.length; i++) { if (points[i] == null) { throw new IllegalArgumentException("points[" + i + "] is null"); } TypeReference T = points[i].getType().getReference(); h ^= T.hashCode(); types.add(T); } hashCode = h; }
/** * @param c a context * @return If this is an object-sensitive context that identifies a unique class for the receiver object, then return the unique * class. Else, return null. * @throws IllegalArgumentException if c is null */ public static IClass getConcreteClassFromContext(Context c) { if (c == null) { throw new IllegalArgumentException("c is null"); } ContextItem item = c.get(ContextKey.RECEIVER); if (item == null) { return null; } else { if (item instanceof PointType) { return ((PointType) item).getIClass(); } else if (item instanceof InstanceKey) { return ((InstanceKey) item).getConcreteType(); } else { Assertions.UNREACHABLE("Unexpected: " + item.getClass()); return null; } } }
public TypeAbstraction getTypeForNewInstance(int bcIndex, IClassHierarchy cha) { if (cha == null) { throw new IllegalArgumentException("null cha"); } Set<TypeReference> S = map.get(Integer.valueOf(bcIndex)); if (S == null) { return null; } else { PointType[] p = new PointType[S.size()]; Iterator<TypeReference> it = S.iterator(); for (int i = 0; i < p.length; i++) { TypeReference T = it.next(); IClass klass = cha.lookupClass(T); assert klass != null : "null type for " + T; p[i] = new PointType(klass); } return new SetType(p); } }
return other.meet(new ConeType(this.getType())); } else { Assertions.UNREACHABLE("Unexpected type: " + rhs.getClass());
@Override public ContextItem get(ContextKey name) { if (name == ContextKey.RECEIVER) { return type; } else if (name == ContextKey.NAME) { return new NameItem(); } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); return new FilteredPointerKey.SingleClassFilter(cls); } else { return null; } } else if (name == ContextKey.PARAMETERS[1]) { return new FilteredPointerKey.SingleClassFilter(this.name.getConcreteType()); } else { return null; } }
public TypeAbstraction getTypeForNewInstance(int bcIndex, IClassHierarchy cha) { if (cha == null) { throw new IllegalArgumentException("null cha"); } Set<TypeReference> S = map.get(Integer.valueOf(bcIndex)); if (S == null) { return null; } else { PointType[] p = new PointType[S.size()]; Iterator<TypeReference> it = S.iterator(); for (int i = 0; i < p.length; i++) { TypeReference T = it.next(); IClass klass = cha.lookupClass(T); assert klass != null : "null type for " + T; p[i] = new PointType(klass); } return new SetType(p); } }
elementType = ((PointType) arrayType).getType().getReference().getArrayElementType(); } else if (arrayType instanceof ConeType) { elementType = ((ConeType) arrayType).getType().getReference().getArrayElementType(); TypeReference tType = null; if (lhs.getType() instanceof PointType) { tType = ((PointType) lhs.getType()).getType().getReference(); } else if (lhs.getType() instanceof ConeType) { tType = ((ConeType) lhs.getType()).getType().getReference();
@Override public ContextItem get(ContextKey name) { if (name == ContextKey.RECEIVER) { return type; } else if (name == ContextKey.NAME) { return new NameItem(); } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); return new FilteredPointerKey.SingleClassFilter(cls); } else { return null; } } else if (name == ContextKey.PARAMETERS[1]) { return new FilteredPointerKey.SingleClassFilter(this.name.getConcreteType()); } else { return null; } }
@Override public void visitNew(SSANewInstruction instruction) { TypeReference type = instruction.getConcreteType(); IClass klass = cha.lookupClass(type); if (klass == null) { // a type that cannot be loaded. // be pessimistic result = new DeclaredTypeOperator(BOTTOM); } else { result = new DeclaredTypeOperator(new PointType(klass)); } }
return other.meet(new ConeType(this.getType())); } else { Assertions.UNREACHABLE("Unexpected type: " + rhs.getClass());