Program: 75416
Project: 75416
Buggy source:
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node) throws IllegalActionException {
  _debug(node);
  int numChildren=node.jjtGetNumChildren();
  int argCount=numChildren - 1;
  for (int i=1; i < numChildren; i++) {
    _generateChild(node,i);
  }
  if (_isValidName(node.getFunctionName())) {
    Local local=_getLocalForName(node.getFunctionName());
    Local resultLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.tokenClass));
    _body.getLocals().add(resultLocal);
    if (argCount == 1) {
      Local tokenCastLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.arrayTokenClass));
      _body.getLocals().add(tokenCastLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(tokenCastLocal,Jimple.v().newCastExpr(local,RefType.v(PtolemyUtilities.arrayTokenClass))),_insertPoint);
      Local indexTokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(1));
      _units.insertBefore(Jimple.v().newAssignStmt(indexTokenLocal,Jimple.v().newCastExpr(indexTokenLocal,RefType.v(PtolemyUtilities.intTokenClass))),_insertPoint);
      Local indexLocal=Jimple.v().newLocal("String_Node_Str",IntType.v());
      _body.getLocals().add(indexLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(indexLocal,Jimple.v().newVirtualInvokeExpr(indexTokenLocal,PtolemyUtilities.intValueMethod)),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(resultLocal,Jimple.v().newVirtualInvokeExpr(tokenCastLocal,PtolemyUtilities.arrayGetElementMethod,indexLocal)),_insertPoint);
    }
 else     if (argCount == 2) {
      Local tokenCastLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.matrixTokenClass));
      _body.getLocals().add(tokenCastLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(tokenCastLocal,Jimple.v().newCastExpr(local,RefType.v(PtolemyUtilities.matrixTokenClass))),_insertPoint);
      Local rowIndexTokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(1));
      Local columnIndexTokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(1));
      _units.insertBefore(Jimple.v().newAssignStmt(rowIndexTokenLocal,Jimple.v().newCastExpr(rowIndexTokenLocal,RefType.v(PtolemyUtilities.intTokenClass))),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(columnIndexTokenLocal,Jimple.v().newCastExpr(columnIndexTokenLocal,RefType.v(PtolemyUtilities.intTokenClass))),_insertPoint);
      Local rowIndexLocal=Jimple.v().newLocal("String_Node_Str",IntType.v());
      _body.getLocals().add(rowIndexLocal);
      Local columnIndexLocal=Jimple.v().newLocal("String_Node_Str",IntType.v());
      _body.getLocals().add(columnIndexLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(rowIndexLocal,Jimple.v().newVirtualInvokeExpr(rowIndexTokenLocal,PtolemyUtilities.intValueMethod)),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(columnIndexLocal,Jimple.v().newVirtualInvokeExpr(columnIndexTokenLocal,PtolemyUtilities.intValueMethod)),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(resultLocal,Jimple.v().newVirtualInvokeExpr(tokenCastLocal,PtolemyUtilities.matrixGetElementAsTokenMethod,rowIndexLocal,columnIndexLocal)),_insertPoint);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + node.getFunctionName());
    }
    _nodeToLocal.put(node,resultLocal);
    return;
  }
  if (node.getFunctionName().compareTo("String_Node_Str") == 0) {
    throw new IllegalActionException("String_Node_Str");
  }
  if (node.getFunctionName().compareTo("String_Node_Str") == 0) {
    throw new IllegalActionException("String_Node_Str");
  }
  ptolemy.data.type.Type[] argTypes=new ptolemy.data.type.Type[argCount];
  for (int i=0; i < argCount; i++) {
    argTypes[i]=((ASTPtRootNode)node.jjtGetChild(i + 1)).getType();
  }
  CachedMethod cachedMethod=CachedMethod.findMethod(node.getFunctionName(),argTypes,CachedMethod.FUNCTION);
  if (!cachedMethod.isValid()) {
    throw new IllegalActionException("String_Node_Str" + cachedMethod + "String_Node_Str");
  }
  if (cachedMethod instanceof CachedMethod.BaseConvertCachedMethod || 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);
  List args=new LinkedList();
  CachedMethod.ArgumentConversion[] conversions=cachedMethod.getConversions();
  for (int i=0; i < argCount; i++) {
    Local tokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(i + 1));
    Local argLocal=_convertTokenArgToJavaArg(tokenLocal,argTypes[i],conversions[i]);
    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().newStaticInvokeExpr(sootMethod,args)),_insertPoint);
  Local tokenLocal=_convertJavaResultToToken(returnLocal,returnType);
  _nodeToLocal.put(node,tokenLocal);
}

Fixed version (ground truth):
public void visitFunctionApplicationNode(ASTPtFunctionApplicationNode node) throws IllegalActionException {
  _debug(node);
  int numChildren=node.jjtGetNumChildren();
  int argCount=numChildren - 1;
  for (int i=1; i < numChildren; i++) {
    _generateChild(node,i);
  }
  if (_isValidName(node.getFunctionName())) {
    Local local=_getLocalForName(node.getFunctionName());
    Local resultLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.tokenClass));
    _body.getLocals().add(resultLocal);
    if (argCount == 1) {
      Local tokenCastLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.arrayTokenClass));
      _body.getLocals().add(tokenCastLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(tokenCastLocal,Jimple.v().newCastExpr(local,RefType.v(PtolemyUtilities.arrayTokenClass))),_insertPoint);
      Local indexTokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(1));
      _units.insertBefore(Jimple.v().newAssignStmt(indexTokenLocal,Jimple.v().newCastExpr(indexTokenLocal,RefType.v(PtolemyUtilities.intTokenClass))),_insertPoint);
      Local indexLocal=Jimple.v().newLocal("String_Node_Str",IntType.v());
      _body.getLocals().add(indexLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(indexLocal,Jimple.v().newVirtualInvokeExpr(indexTokenLocal,PtolemyUtilities.intValueMethod)),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(resultLocal,Jimple.v().newVirtualInvokeExpr(tokenCastLocal,PtolemyUtilities.arrayGetElementMethod,indexLocal)),_insertPoint);
    }
 else     if (argCount == 2) {
      Local tokenCastLocal=Jimple.v().newLocal("String_Node_Str",RefType.v(PtolemyUtilities.matrixTokenClass));
      _body.getLocals().add(tokenCastLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(tokenCastLocal,Jimple.v().newCastExpr(local,RefType.v(PtolemyUtilities.matrixTokenClass))),_insertPoint);
      Local rowIndexTokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(1));
      Local columnIndexTokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(2));
      _units.insertBefore(Jimple.v().newAssignStmt(rowIndexTokenLocal,Jimple.v().newCastExpr(rowIndexTokenLocal,RefType.v(PtolemyUtilities.intTokenClass))),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(columnIndexTokenLocal,Jimple.v().newCastExpr(columnIndexTokenLocal,RefType.v(PtolemyUtilities.intTokenClass))),_insertPoint);
      Local rowIndexLocal=Jimple.v().newLocal("String_Node_Str",IntType.v());
      _body.getLocals().add(rowIndexLocal);
      Local columnIndexLocal=Jimple.v().newLocal("String_Node_Str",IntType.v());
      _body.getLocals().add(columnIndexLocal);
      _units.insertBefore(Jimple.v().newAssignStmt(rowIndexLocal,Jimple.v().newVirtualInvokeExpr(rowIndexTokenLocal,PtolemyUtilities.intValueMethod)),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(columnIndexLocal,Jimple.v().newVirtualInvokeExpr(columnIndexTokenLocal,PtolemyUtilities.intValueMethod)),_insertPoint);
      _units.insertBefore(Jimple.v().newAssignStmt(resultLocal,Jimple.v().newVirtualInvokeExpr(tokenCastLocal,PtolemyUtilities.matrixGetElementAsTokenMethod,rowIndexLocal,columnIndexLocal)),_insertPoint);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + node.getFunctionName());
    }
    _nodeToLocal.put(node,resultLocal);
    return;
  }
  if (node.getFunctionName().compareTo("String_Node_Str") == 0) {
    throw new IllegalActionException("String_Node_Str");
  }
  if (node.getFunctionName().compareTo("String_Node_Str") == 0) {
    throw new IllegalActionException("String_Node_Str");
  }
  ptolemy.data.type.Type[] argTypes=new ptolemy.data.type.Type[argCount];
  for (int i=0; i < argCount; i++) {
    argTypes[i]=((ASTPtRootNode)node.jjtGetChild(i + 1)).getType();
  }
  CachedMethod cachedMethod=CachedMethod.findMethod(node.getFunctionName(),argTypes,CachedMethod.FUNCTION);
  if (!cachedMethod.isValid()) {
    throw new IllegalActionException("String_Node_Str" + cachedMethod + "String_Node_Str");
  }
  if (cachedMethod instanceof CachedMethod.BaseConvertCachedMethod || 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);
  List args=new LinkedList();
  CachedMethod.ArgumentConversion[] conversions=cachedMethod.getConversions();
  for (int i=0; i < argCount; i++) {
    Local tokenLocal=(Local)_nodeToLocal.get(node.jjtGetChild(i + 1));
    Local argLocal=_convertTokenArgToJavaArg(tokenLocal,argTypes[i],conversions[i]);
    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().newStaticInvokeExpr(sootMethod,args)),_insertPoint);
  Local tokenLocal=_convertJavaResultToToken(returnLocal,returnType);
  _nodeToLocal.put(node,tokenLocal);
}