/** * Return the type computed for a particular value number */ public TypeAbstraction getType(int valueNumber) { if (valueNumber < 0) { throw new IllegalArgumentException("bad value number " + valueNumber); } TypeVariable variable = getVariable(valueNumber); assert variable != null : "null variable for value number " + valueNumber; return variable.getType(); }
/** * Return the type computed for a particular value number */ public TypeAbstraction getType(int valueNumber) { if (valueNumber < 0) { throw new IllegalArgumentException("bad value number " + valueNumber); } TypeVariable variable = getVariable(valueNumber); assert variable != null : "null variable for value number " + valueNumber; return variable.getType(); }
/** * TODO: work on efficiency shortcuts for this. */ @Override public byte evaluate(TypeVariable lhs, TypeVariable[] rhsOperands) { TypeAbstraction lhsType = lhs.getType(); TypeVariable rhs = rhsOperands[0]; TypeAbstraction rhsType = rhs.getType(); if (lhsType.equals(rhsType)) { return NOT_CHANGED; } else { lhs.setType(rhsType); return CHANGED; } }
/** * TODO: work on efficiency shortcuts for this. */ @Override public byte evaluate(TypeVariable lhs, TypeVariable[] rhsOperands) { TypeAbstraction lhsType = lhs.getType(); TypeVariable rhs = rhsOperands[0]; TypeAbstraction rhsType = rhs.getType(); if (lhsType.equals(rhsType)) { return NOT_CHANGED; } else { lhs.setType(rhsType); 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 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; } }
public boolean isUndefined(int valueNumber) { // TODO: Julian, you seem to be using BOTTOM in the European style. // Steve's code assumes American style (god forbid), so what you're getting // here // is not undefined, but java.lang.Object [NR/EY] if (getVariable(valueNumber) == null) { return true; } TypeAbstraction ta = getVariable(valueNumber).getType(); return ta == BOTTOM || ta.getType() == null; }
public boolean isUndefined(int valueNumber) { // TODO: Julian, you seem to be using BOTTOM in the European style. // Steve's code assumes American style (god forbid), so what you're getting // here // is not undefined, but java.lang.Object [NR/EY] if (getVariable(valueNumber) == null) { return true; } TypeAbstraction ta = getVariable(valueNumber).getType(); return ta == BOTTOM || ta.getType() == null; }
/** * Extract all results of the type inference analysis. * * @return an array, where the i'th variable holds the type abstraction of the i'th value number. */ public TypeAbstraction[] extractAllResults() { int numberOfVars = ir.getSymbolTable().getMaxValueNumber() + 1; TypeAbstraction[] ret = new TypeAbstraction[numberOfVars]; for (int i = 0; i < numberOfVars; ++i) { TypeVariable var = getVariable(i); ret[i] = var == null ? null : var.getType(); } return ret; }
/** * Extract all results of the type inference analysis. * * @return an array, where the i'th variable holds the type abstraction of the i'th value number. */ public TypeAbstraction[] extractAllResults() { int numberOfVars = ir.getSymbolTable().getMaxValueNumber() + 1; TypeAbstraction[] ret = new TypeAbstraction[numberOfVars]; for (int i = 0; i < numberOfVars; ++i) { TypeVariable var = getVariable(i); ret[i] = var == null ? null : var.getType(); } return ret; }
if (doPrimitives && lhs.getType() == TypeAbstraction.TOP) { lhs.setType(PrimitiveType.getPrimitive(elementType)); return CHANGED; if (lhs.getType() != TypeAbstraction.TOP) { 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(); } else { Assertions.UNREACHABLE("Unexpected type " + lhs.getType().getClass());
if (doPrimitives && lhs.getType() == TypeAbstraction.TOP) { lhs.setType(PrimitiveType.getPrimitive(elementType)); return CHANGED; if (lhs.getType() != TypeAbstraction.TOP) { 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(); } else { Assertions.UNREACHABLE("Unexpected type " + lhs.getType().getClass());
@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; } }