Program: 75261
Project: 75261
Buggy source:
/** 
 * Attempt to determine the constant value of the given local, which is assumed to have a variable type.  Walk backwards through all the possible places that the local may have been defined and try to symbolically evaluate the value of the variable. If the value can be determined, then return it, otherwise throw an exception
 */
public static ptolemy.data.type.Type getTypeValue(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=(Value)stmt.getRightOp();
    if (value instanceof Local) {
      return getTypeValue(method,(Local)value,stmt,localDefs,localUses);
    }
 else     if (value instanceof CastExpr) {
      return getTypeValue(method,(Local)((CastExpr)value).getOp(),stmt,localDefs,localUses);
    }
 else     if (value instanceof FieldRef) {
      SootField field=((FieldRef)value).getField();
      if (field.equals(unknownTypeField)) {
        return ptolemy.data.type.BaseType.UNKNOWN;
      }
 else       if (field.equals(booleanTypeField)) {
        return ptolemy.data.type.BaseType.BOOLEAN;
      }
 else       if (field.equals(booleanMatrixTypeField)) {
        return ptolemy.data.type.BaseType.BOOLEAN_MATRIX;
      }
 else       if (field.equals(byteTypeField)) {
        return ptolemy.data.type.BaseType.UNSIGNED_BYTE;
      }
 else       if (field.equals(complexTypeField)) {
        return ptolemy.data.type.BaseType.COMPLEX;
      }
 else       if (field.equals(complexMatrixTypeField)) {
        return ptolemy.data.type.BaseType.COMPLEX_MATRIX;
      }
 else       if (field.equals(doubleTypeField)) {
        return ptolemy.data.type.BaseType.DOUBLE;
      }
 else       if (field.equals(doubleMatrixTypeField)) {
        return ptolemy.data.type.BaseType.DOUBLE_MATRIX;
      }
 else       if (field.equals(fixTypeField)) {
        return ptolemy.data.type.BaseType.FIX;
      }
 else       if (field.equals(fixMatrixTypeField)) {
        return ptolemy.data.type.BaseType.FIX_MATRIX;
      }
 else       if (field.equals(intTypeField)) {
        return ptolemy.data.type.BaseType.INT;
      }
 else       if (field.equals(intMatrixTypeField)) {
        return ptolemy.data.type.BaseType.INT_MATRIX;
      }
 else       if (field.equals(longTypeField)) {
        return ptolemy.data.type.BaseType.LONG;
      }
 else       if (field.equals(longMatrixTypeField)) {
        return ptolemy.data.type.BaseType.LONG_MATRIX;
      }
 else       if (field.equals(objectTypeField)) {
        return ptolemy.data.type.BaseType.OBJECT;
      }
 else       if (field.equals(stringTypeField)) {
        return ptolemy.data.type.BaseType.STRING;
      }
 else {
        throw new RuntimeException("String_Node_Str" + field);
      }
    }
 else     if (value instanceof NewExpr) {
      Iterator pairs=localUses.getUsesOf(stmt).iterator();
      while (pairs.hasNext()) {
        UnitValueBoxPair pair=(UnitValueBoxPair)pairs.next();
        if (pair.getUnit() instanceof InvokeStmt) {
          InvokeStmt useStmt=(InvokeStmt)pair.getUnit();
          if (useStmt.getInvokeExpr() instanceof SpecialInvokeExpr) {
            SpecialInvokeExpr constructorExpr=(SpecialInvokeExpr)useStmt.getInvokeExpr();
            if (constructorExpr.getMethod().getSignature().equals("String_Node_Str")) {
              Local arg1Local=(Local)constructorExpr.getArg(0);
              ptolemy.data.type.Type elementType=getTypeValue(method,arg1Local,useStmt,localDefs,localUses);
              return new ptolemy.data.type.ArrayType(elementType);
            }
 else {
              throw new RuntimeException("String_Node_Str" + stmt);
            }
          }
        }
      }
      throw new RuntimeException("String_Node_Str");
    }
 else     if (value instanceof NullConstant) {
      return null;
    }
 else {
      throw new RuntimeException("String_Node_Str" + value + "String_Node_Str"+ method);
    }
  }
 else {
    String string="String_Node_Str" + local + "String_Node_Str";
    for (Iterator i=definitionList.iterator(); i.hasNext(); ) {
      string+="String_Node_Str" + i.next().toString();
    }
    throw new RuntimeException(string);
  }
}

Fixed version (ground truth):
/** 
 * Attempt to determine the constant value of the given local, which is assumed to have a variable type.  Walk backwards through all the possible places that the local may have been defined and try to symbolically evaluate the value of the variable. If the value can be determined, then return it, otherwise throw an exception
 */
public static ptolemy.data.type.Type getTypeValue(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=(Value)stmt.getRightOp();
    if (value instanceof Local) {
      return getTypeValue(method,(Local)value,stmt,localDefs,localUses);
    }
 else     if (value instanceof CastExpr) {
      return getTypeValue(method,(Local)((CastExpr)value).getOp(),stmt,localDefs,localUses);
    }
 else     if (value instanceof FieldRef) {
      SootField field=((FieldRef)value).getField();
      if (field.equals(unknownTypeField)) {
        return ptolemy.data.type.BaseType.UNKNOWN;
      }
 else       if (field.equals(booleanTypeField)) {
        return ptolemy.data.type.BaseType.BOOLEAN;
      }
 else       if (field.equals(booleanMatrixTypeField)) {
        return ptolemy.data.type.BaseType.BOOLEAN_MATRIX;
      }
 else       if (field.equals(byteTypeField)) {
        return ptolemy.data.type.BaseType.UNSIGNED_BYTE;
      }
 else       if (field.equals(complexTypeField)) {
        return ptolemy.data.type.BaseType.COMPLEX;
      }
 else       if (field.equals(complexMatrixTypeField)) {
        return ptolemy.data.type.BaseType.COMPLEX_MATRIX;
      }
 else       if (field.equals(doubleTypeField)) {
        return ptolemy.data.type.BaseType.DOUBLE;
      }
 else       if (field.equals(doubleMatrixTypeField)) {
        return ptolemy.data.type.BaseType.DOUBLE_MATRIX;
      }
 else       if (field.equals(fixTypeField)) {
        return ptolemy.data.type.BaseType.FIX;
      }
 else       if (field.equals(fixMatrixTypeField)) {
        return ptolemy.data.type.BaseType.FIX_MATRIX;
      }
 else       if (field.equals(intTypeField)) {
        return ptolemy.data.type.BaseType.INT;
      }
 else       if (field.equals(intMatrixTypeField)) {
        return ptolemy.data.type.BaseType.INT_MATRIX;
      }
 else       if (field.equals(longTypeField)) {
        return ptolemy.data.type.BaseType.LONG;
      }
 else       if (field.equals(longMatrixTypeField)) {
        return ptolemy.data.type.BaseType.LONG_MATRIX;
      }
 else       if (field.equals(objectTypeField)) {
        return ptolemy.data.type.BaseType.OBJECT;
      }
 else       if (field.equals(stringTypeField)) {
        return ptolemy.data.type.BaseType.STRING;
      }
 else {
        throw new RuntimeException("String_Node_Str" + field);
      }
    }
 else     if (value instanceof InstanceInvokeExpr) {
      InstanceInvokeExpr r=(InstanceInvokeExpr)value;
      if (r.getMethod().getName().equals("String_Node_Str")) {
        ptolemy.data.type.ArrayType arrayType=(ptolemy.data.type.ArrayType)getTypeValue(method,(Local)r.getBase(),stmt,localDefs,localUses);
        return arrayType.getElementType();
      }
 else {
        throw new RuntimeException("String_Node_Str" + r);
      }
    }
 else     if (value instanceof NewExpr) {
      Iterator pairs=localUses.getUsesOf(stmt).iterator();
      while (pairs.hasNext()) {
        UnitValueBoxPair pair=(UnitValueBoxPair)pairs.next();
        if (pair.getUnit() instanceof InvokeStmt) {
          InvokeStmt useStmt=(InvokeStmt)pair.getUnit();
          if (useStmt.getInvokeExpr() instanceof SpecialInvokeExpr) {
            SpecialInvokeExpr constructorExpr=(SpecialInvokeExpr)useStmt.getInvokeExpr();
            if (constructorExpr.getMethod().getSignature().equals("String_Node_Str")) {
              Local arg1Local=(Local)constructorExpr.getArg(0);
              ptolemy.data.type.Type elementType=getTypeValue(method,arg1Local,useStmt,localDefs,localUses);
              return new ptolemy.data.type.ArrayType(elementType);
            }
 else {
              throw new RuntimeException("String_Node_Str" + constructorExpr);
            }
          }
        }
      }
      throw new RuntimeException("String_Node_Str");
    }
 else     if (value instanceof NullConstant) {
      return null;
    }
 else {
      throw new RuntimeException("String_Node_Str" + value + "String_Node_Str"+ method);
    }
  }
 else {
    String string="String_Node_Str" + local + "String_Node_Str";
    for (Iterator i=definitionList.iterator(); i.hasNext(); ) {
      string+="String_Node_Str" + i.next().toString();
    }
    throw new RuntimeException(string);
  }
}