Program: 75425
Project: 75425
Buggy source:
public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException {
  _debug(node);
  int argCount=node.jjtGetNumChildren();
  _generateAllChildren(node);
  ptolemy.data.type.Type baseTokenType=((ASTPtRootNode)node.jjtGetChild(0)).getType();
  if (argCount == 1 && baseTokenType instanceof RecordType) {
    RecordType type=(RecordType)baseTokenType;
    if (type.labelSet().contains(node.getMethodName())) {
      Local originalBaseLocal=(Local)_nodeToLocal.get(node.jjtGetChild(0));
      Local baseLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.recordTokenClass));
      _body.getLocals().add(baseLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(baseLocal,Jimple.v().newCastExpr(originalBaseLocal,RefType.v(PtolemyUtilities.recordTokenClass))),_insertPoint);
      Local returnLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.tokenClass));
      _body.getLocals().add(returnLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(returnLocal,Jimple.v().newVirtualInvokeExpr(baseLocal,PtolemyUtilities.recordGetMethod,StringConstant.v(node.getMethodName()))),_insertPoint);
      _nodeToLocal.put(node,returnLocal);
      return;
    }
  }
  ptolemy.data.type.Type[] argTypes=new ptolemy.data.type.Type[node.jjtGetNumChildren()];
  for (int i=0; i < node.jjtGetNumChildren(); i++) {
    argTypes[i]=((ASTPtRootNode)node.jjtGetChild(i)).getType();
  }
  CachedMethod cachedMethod=CachedMethod.findMethod(node.getMethodName(),argTypes,CachedMethod.METHOD);
  if (!cachedMethod.isValid()) {
    throw new IllegalActionException("String_Node_Str" + cachedMethod + "String_Node_Str");
  }
  if (cachedMethod instanceof CachedMethod.ArrayMapCachedMethod || cachedMethod instanceof CachedMethod.MatrixMapCachedMethod) {
    throw new IllegalActionException("String_Node_Str" + cachedMethod.getClass());
  }
  Method method=cachedMethod.getMethod();
  SootMethod sootMethod=SootUtilities.getSootMethodForMethod(method);
  Local originalBaseLocal=(Local)_nodeToLocal.get(node.jjtGetChild(0));
  RefType baseType=RefType.v(sootMethod.getDeclaringClass());
  Local baseLocal=Jimple.v().newLocal("String_Node_Str",baseType);
  _body.getLocals().add(baseLocal);
  if (cachedMethod instanceof CachedMethod.BaseConvertCachedMethod) {
    RefType tempBaseType=PtolemyUtilities.getSootTypeForTokenType(argTypes[0]);
    Local tempBaseLocal=_convertTokenArgToJavaArg(originalBaseLocal,argTypes[0],((CachedMethod.BaseConvertCachedMethod)cachedMethod).getBaseConversion());
    _units.insertBefore(Jimple.v().newAssignStmt(baseLocal,Jimple.v().newCastExpr(tempBaseLocal,baseType)),_insertPoint);
  }
 else {
    _units.insertBefore(Jimple.v().newAssignStmt(baseLocal,Jimple.v().newCastExpr(originalBaseLocal,baseType)),_insertPoint);
  }
  List args=new LinkedList();
  CachedMethod.ArgumentConversion[] conversions=cachedMethod.getConversions();
  for (int i=1; i < node.jjtGetNumChildren(); i++) {
    Local tokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(i));
    Local argLocal=_convertTokenArgToJavaArg(tokenLocal,argTypes[i - 1],conversions[i - 1]);
    args.add(argLocal);
  }
  Type returnType=sootMethod.getReturnType();
  Local returnLocal=Jimple.v().newLocal("String_Node_Str",returnType);
  _body.getLocals().add(returnLocal);
  _units.insertBefore(Jimple.v().newAssignStmt(returnLocal,Jimple.v().newVirtualInvokeExpr(baseLocal,sootMethod,args)),_insertPoint);
  Local tokenLocal=_convertJavaResultToToken(returnLocal,returnType);
  _nodeToLocal.put(node,tokenLocal);
}

Fixed version (ground truth):
public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException {
  _debug(node);
  int argCount=node.jjtGetNumChildren();
  _generateAllChildren(node);
  ptolemy.data.type.Type baseTokenType=((ASTPtRootNode)node.jjtGetChild(0)).getType();
  if (argCount == 1 && baseTokenType instanceof RecordType) {
    RecordType type=(RecordType)baseTokenType;
    if (type.labelSet().contains(node.getMethodName())) {
      Local originalBaseLocal=(Local)_nodeToLocal.get(node.jjtGetChild(0));
      Local baseLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.recordTokenClass));
      _body.getLocals().add(baseLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(baseLocal,Jimple.v().newCastExpr(originalBaseLocal,RefType.v(PtolemyUtilities.recordTokenClass))),_insertPoint);
      Local returnLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.tokenClass));
      _body.getLocals().add(returnLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(returnLocal,Jimple.v().newVirtualInvokeExpr(baseLocal,PtolemyUtilities.recordGetMethod,StringConstant.v(node.getMethodName()))),_insertPoint);
      _nodeToLocal.put(node,returnLocal);
      return;
    }
  }
  ptolemy.data.type.Type[] argTypes=new ptolemy.data.type.Type[node.jjtGetNumChildren()];
  for (int i=0; i < node.jjtGetNumChildren(); i++) {
    argTypes[i]=((ASTPtRootNode)node.jjtGetChild(i)).getType();
  }
  CachedMethod cachedMethod=CachedMethod.findMethod(node.getMethodName(),argTypes,CachedMethod.METHOD);
  if (!cachedMethod.isValid()) {
    throw new IllegalActionException("String_Node_Str" + cachedMethod + "String_Node_Str");
  }
  if (cachedMethod instanceof CachedMethod.ArrayMapCachedMethod || cachedMethod instanceof CachedMethod.MatrixMapCachedMethod) {
    throw new IllegalActionException("String_Node_Str" + cachedMethod.getClass());
  }
  Method method=cachedMethod.getMethod();
  SootMethod sootMethod=SootUtilities.getSootMethodForMethod(method);
  Local originalBaseLocal=(Local)_nodeToLocal.get(node.jjtGetChild(0));
  RefType baseType=RefType.v(sootMethod.getDeclaringClass());
  Local baseLocal=Jimple.v().newLocal("String_Node_Str",baseType);
  _body.getLocals().add(baseLocal);
  if (cachedMethod instanceof CachedMethod.BaseConvertCachedMethod) {
    RefType tempBaseType=PtolemyUtilities.getSootTypeForTokenType(argTypes[0]);
    Local tempBaseLocal=_convertTokenArgToJavaArg(originalBaseLocal,argTypes[0],((CachedMethod.BaseConvertCachedMethod)cachedMethod).getBaseConversion());
    _units.insertBefore(Jimple.v().newAssignStmt(baseLocal,Jimple.v().newCastExpr(tempBaseLocal,baseType)),_insertPoint);
  }
 else {
    _units.insertBefore(Jimple.v().newAssignStmt(baseLocal,Jimple.v().newCastExpr(originalBaseLocal,baseType)),_insertPoint);
  }
  List args=new LinkedList();
  CachedMethod.ArgumentConversion[] conversions=cachedMethod.getConversions();
  for (int i=1; i < node.jjtGetNumChildren(); i++) {
    Local tokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(i));
    Local argLocal=_convertTokenArgToJavaArg(tokenLocal,argTypes[i],conversions[i - 1]);
    args.add(argLocal);
  }
  Type returnType=sootMethod.getReturnType();
  Local returnLocal=Jimple.v().newLocal("String_Node_Str",returnType);
  _body.getLocals().add(returnLocal);
  _units.insertBefore(Jimple.v().newAssignStmt(returnLocal,Jimple.v().newVirtualInvokeExpr(baseLocal,sootMethod,args)),_insertPoint);
  Local tokenLocal=_convertJavaResultToToken(returnLocal,returnType);
  _nodeToLocal.put(node,tokenLocal);
}