@Override public TypeReference getTypeReference() { Iterator ti = types.iterator(); TypeAbstraction T = (TypeAbstraction) ti.next(); while (ti.hasNext()) { T = T.meet((TypeAbstraction) ti.next()); } return T.getTypeReference(); }
@Override public TypeReference getTypeReference() { Iterator ti = types.iterator(); TypeAbstraction T = (TypeAbstraction) ti.next(); while (ti.hasNext()) { T = T.meet((TypeAbstraction) ti.next()); } return T.getTypeReference(); }
private TypeAbstraction meetDeclaredExceptionTypes(SSAGetCaughtExceptionInstruction s) { ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode(s.getBasicBlockNumber()); Iterator<TypeReference> it = bb.getCaughtExceptionTypes(); TypeReference t = it.next(); IClass klass = cha.lookupClass(t); TypeAbstraction result = null; if (klass == null) { // a type that cannot be loaded. // be pessimistic result = BOTTOM; } else { result = new ConeType(klass); } while (it.hasNext()) { t = it.next(); IClass tClass = cha.lookupClass(t); if (tClass == null) { result = BOTTOM; } else { result = result.meet(new ConeType(tClass)); } } return result; }
private TypeAbstraction meetDeclaredExceptionTypes(SSAGetCaughtExceptionInstruction s) { ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode(s.getBasicBlockNumber()); Iterator<TypeReference> it = bb.getCaughtExceptionTypes(); TypeReference t = it.next(); IClass klass = cha.lookupClass(t); TypeAbstraction result = null; if (klass == null) { // a type that cannot be loaded. // be pessimistic result = BOTTOM; } else { result = new ConeType(klass); } while (it.hasNext()) { t = it.next(); IClass tClass = cha.lookupClass(t); if (tClass == null) { result = BOTTOM; } else { result = result.meet(new ConeType(tClass)); } } return result; }
@Override public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) { TypeAbstraction lhsType = lhs.getType(); TypeAbstraction meet = TypeAbstraction.TOP; for (TypeVariable r : rhs) { if (r != null && r.getType() != null) { meet = meet.meet(r.getType()); } } if (lhsType.equals(meet)) { return NOT_CHANGED; } else { lhs.setType(meet); return CHANGED; } }
@Override public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) { TypeAbstraction lhsType = lhs.getType(); TypeAbstraction meet = TypeAbstraction.TOP; for (TypeVariable r : rhs) { if (r != null && r.getType() != null) { meet = meet.meet(r.getType()); } } if (lhsType.equals(meet)) { return NOT_CHANGED; } else { lhs.setType(meet); return CHANGED; } }
@Override public TypeAbstraction meet(TypeAbstraction rhs) { if (rhs == TOP) { return this; } else if (rhs instanceof ConeType) { ConeType other = (ConeType) rhs; if (type.equals(other.type)) { return this; } else if (type.isArrayClass() || other.type.isArrayClass()) { // give up on arrays. We don't care anyway. return new ConeType(type.getClassHierarchy().getRootClass()); } else { return new ConeType(type.getClassHierarchy().getLeastCommonSuperclass(this.type, other.type)); } } else if (rhs instanceof PointType) { return rhs.meet(this); } else if (rhs instanceof PrimitiveType) { return TOP; } else { Assertions.UNREACHABLE("unexpected type " + rhs.getClass()); return null; } }
@Override public TypeAbstraction meet(TypeAbstraction rhs) { if (rhs == TOP) { return this; } else if (rhs instanceof ConeType) { ConeType other = (ConeType) rhs; if (type.equals(other.type)) { return this; } else if (type.isArrayClass() || other.type.isArrayClass()) { // give up on arrays. We don't care anyway. return new ConeType(type.getClassHierarchy().getRootClass()); } else { return new ConeType(type.getClassHierarchy().getLeastCommonSuperclass(this.type, other.type)); } } else if (rhs instanceof PointType) { return rhs.meet(this); } else if (rhs instanceof PrimitiveType) { return TOP; } else { Assertions.UNREACHABLE("unexpected type " + rhs.getClass()); return null; } }
for (TypeVariable r : rhs) { if (r != null && r.getType() != null) { meet = meet.meet(r.getType());
for (TypeVariable r : rhs) { if (r != null && r.getType() != null) { meet = meet.meet(r.getType());
@Override public void visitCheckCast(SSACheckCastInstruction instruction) { TypeAbstraction typeAbs = null; for (TypeReference type : instruction.getDeclaredResultTypes()) { IClass klass = cha.lookupClass(type); if (klass == null) { // a type that cannot be loaded. // be pessimistic typeAbs = BOTTOM; } else { TypeAbstraction x = null; if (doPrimitives && type.isPrimitiveType()) { x = language.getPrimitive(type); } else if (type.isReferenceType()) { x = new ConeType(klass); } if (x != null) { if (typeAbs == null) { typeAbs = x; } else { typeAbs = typeAbs.meet(x); } } } } result = new DeclaredTypeOperator(typeAbs); }
@Override public void visitCheckCast(SSACheckCastInstruction instruction) { TypeAbstraction typeAbs = null; for (TypeReference type : instruction.getDeclaredResultTypes()) { IClass klass = cha.lookupClass(type); if (klass == null) { // a type that cannot be loaded. // be pessimistic typeAbs = BOTTOM; } else { TypeAbstraction x = null; if (doPrimitives && type.isPrimitiveType()) { x = language.getPrimitive(type); } else if (type.isReferenceType()) { x = new ConeType(klass); } if (x != null) { if (typeAbs == null) { typeAbs = x; } else { typeAbs = typeAbs.meet(x); } } } } result = new DeclaredTypeOperator(typeAbs); }
@Override public byte evaluate(TypeVariable _lhs, TypeVariable[] _rhs) { /** * TODO: Find a better solution than downcasting. Downcasting is * really ugly, although I can be sure here that it succeeds because * I control what type the parameters have. There must be a cleaner * solution which does not cause tons of changes in WALA's code, but * I don't see it yet... */ assert _lhs instanceof DalvikTypeVariable; assert _rhs instanceof DalvikTypeVariable[]; DalvikTypeVariable lhs = (DalvikTypeVariable) _lhs; DalvikTypeVariable[] rhs = (DalvikTypeVariable[]) _rhs; TypeAbstraction lhsType = lhs.getType(); TypeAbstraction meet = TypeAbstraction.TOP; boolean ignoreZero = containsNonPrimitiveAndZero(rhs); for (int i = 0; i < rhs.length; i++) { if (rhs[i] != null && rhs[i].getType() != null && !(ignoreZero && rhs[i].isIntZeroConstant())) { TypeVariable r = rhs[i]; meet = meet.meet(r.getType()); } } if (lhsType.equals(meet)) { return NOT_CHANGED; } else { lhs.setType(meet); return CHANGED; } }
@Override public byte evaluate(TypeVariable _lhs, TypeVariable[] _rhs) { /** * TODO: Find a better solution than downcasting. Downcasting is * really ugly, although I can be sure here that it succeeds because * I control what type the parameters have. There must be a cleaner * solution which does not cause tons of changes in WALA's code, but * I don't see it yet... */ assert _lhs instanceof DalvikTypeVariable; assert _rhs instanceof DalvikTypeVariable[]; DalvikTypeVariable lhs = (DalvikTypeVariable) _lhs; DalvikTypeVariable[] rhs = (DalvikTypeVariable[]) _rhs; TypeAbstraction lhsType = lhs.getType(); TypeAbstraction meet = TypeAbstraction.TOP; boolean ignoreZero = containsNonPrimitiveAndZero(rhs); for (int i = 0; i < rhs.length; i++) { if (rhs[i] != null && rhs[i].getType() != null && !(ignoreZero && rhs[i].isIntZeroConstant())) { TypeVariable r = rhs[i]; meet = meet.meet(r.getType()); } } if (lhsType.equals(meet)) { return NOT_CHANGED; } else { lhs.setType(meet); return CHANGED; } }