public static TypedIOPort getPortValue(SootMethod method, Local local,
Unit location, LocalDefs localDefs, LocalUses localUses) {
List definitionList = localDefs.getDefsOfAt(local, location);
if (definitionList.size() == 1) {
DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
Value value = stmt.getRightOp();
if (value instanceof Local) {
return getPortValue(method, (Local) value, stmt, localDefs,
localUses);
} else if (value instanceof CastExpr) {
return getPortValue(method, (Local) ((CastExpr) value).getOp(),
stmt, localDefs, localUses);
} else if (value instanceof FieldRef) {
SootField field = ((FieldRef) value).getField();
return _getFieldValueTag(field);
} else if (value instanceof NewExpr) {
// If we get to an object creation, then try
// to figure out where the variable is stored into a field.
Iterator pairs = localUses.getUsesOf(stmt).iterator();
while (pairs.hasNext()) {
UnitValueBoxPair pair = (UnitValueBoxPair) pairs.next();
if (pair.getUnit() instanceof DefinitionStmt) {
DefinitionStmt useStmt = (DefinitionStmt) pair
.getUnit();
if (useStmt.getLeftOp() instanceof FieldRef) {
SootField field = ((FieldRef) useStmt.getLeftOp())
.getField();
return _getFieldValueTag(field);
}
}
}