Program: 74910
Project: 74910
Buggy source:
/** 
 * Generate type resolution code. Determine the proper code put into the source to support dynamic type resolution. First, find out the different types used in the model. Second, find out the different polymorphic functions used. (note: types and functions are independent of each other). Third, append code blocks according to the functions used, and read from files according to the types referenced. Fourth, generate type resolution code, which consists of constants (MAX_NUM_TYPE, MAX_NUM_FUNC), the type map, the function map, function definitions read from the files, and function table.
 * @return The type resolution code.
 * @throws IllegalActionException If an error ocurrs when generatingthe type resolution code, or if the helper class for the model director cannot be found, or if an error occurs when the helper actor generates the type resolution code.
 */
public String generateTypeResolutionCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(comment("String_Node_Str" + getContainer().getFullName()));
  TypedCompositeActor compositeActorHelper=(TypedCompositeActor)_getHelper(getContainer());
  CodeStream sharedStream=new CodeStream("String_Node_Str");
  sharedStream.appendCodeBlock("String_Node_Str");
  code.append(sharedStream.toString());
  HashSet functions=new HashSet();
  HashSet types=new HashSet();
  types.addAll(_primitiveTypes);
  functions.addAll(_typeFuncUsed);
  types.addAll(_newTypesUsed);
  if (types.contains("String_Node_Str")) {
    functions.add("String_Node_Str");
  }
  Object[] typesArray=types.toArray();
  CodeStream[] typeStreams=new CodeStream[types.size()];
  String typeMembers=new String();
  for (int i=0; i < types.size(); i++) {
    typeStreams[i]=new CodeStream("String_Node_Str" + typesArray[i] + "String_Node_Str");
    code.append("String_Node_Str" + typesArray[i] + "String_Node_Str"+ i+ "String_Node_Str");
    typeMembers+="String_Node_Str" + typesArray[i] + "String_Node_Str"+ typesArray[i]+ "String_Node_Str";
  }
  Object[] functionsArray=functions.toArray();
  for (int i=0; i < functions.size(); i++) {
    code.append("String_Node_Str" + functionsArray[i] + "String_Node_Str"+ i+ "String_Node_Str");
  }
  code.append("String_Node_Str");
  for (int i=0; i < types.size(); i++) {
    typeStreams[i].appendCodeBlock("String_Node_Str");
    code.append(typeStreams[i].toString());
  }
  if (!typeMembers.equals("String_Node_Str")) {
    ArrayList args=new ArrayList();
    args.add(typeMembers);
    sharedStream.clear();
    sharedStream.appendCodeBlock("String_Node_Str",args);
    code.append(sharedStream.toString());
  }
  for (int i=0; i < types.size(); i++) {
    typeStreams[i].clear();
    typeStreams[i].appendCodeBlock("String_Node_Str");
    code.append(typeStreams[i].toString());
  }
  sharedStream.clear();
  sharedStream.appendCodeBlock("String_Node_Str");
  code.append(sharedStream.toString());
  if (functions.size() > 0 && types.size() > 0) {
    code.append("String_Node_Str" + types.size() + "String_Node_Str");
    code.append("String_Node_Str" + functions.size() + "String_Node_Str");
    code.append("String_Node_Str" + "String_Node_Str");
    for (int i=0; i < types.size(); i++) {
      code.append("String_Node_Str");
      for (int j=0; j < functions.size(); j++) {
        code.append(typesArray[i] + "String_Node_Str" + functionsArray[j]);
        if ((i != (types.size() - 1)) || (j != (functions.size() - 1))) {
          code.append("String_Node_Str");
        }
      }
      code.append("String_Node_Str");
    }
    code.append("String_Node_Str");
  }
  for (int i=0; i < types.size(); i++) {
    typeStreams[i].clear();
    typeStreams[i].appendCodeBlock("String_Node_Str");
    for (int j=0; j < functions.size(); j++) {
      try {
        typeStreams[i].appendCodeBlock(functionsArray[j] + "String_Node_Str");
      }
 catch (      IllegalActionException ex) {
        typeStreams[i].append("String_Node_Str" + typesArray[i] + "String_Node_Str"+ functionsArray[j]+ "String_Node_Str");
      }
    }
    code.append(typeStreams[i].toString());
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate type resolution code. Determine the proper code put into the source to support dynamic type resolution. First, find out the different types used in the model. Second, find out the different polymorphic functions used. (note: types and functions are independent of each other). Third, append code blocks according to the functions used, and read from files according to the types referenced. Fourth, generate type resolution code, which consists of constants (MAX_NUM_TYPE, MAX_NUM_FUNC), the type map, the function map, function definitions read from the files, and function table.
 * @return The type resolution code.
 * @throws IllegalActionException If an error ocurrs when generatingthe type resolution code, or if the helper class for the model director cannot be found, or if an error occurs when the helper actor generates the type resolution code.
 */
public String generateTypeResolutionCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(comment("String_Node_Str" + getContainer().getFullName()));
  CodeStream sharedStream=new CodeStream("String_Node_Str");
  sharedStream.appendCodeBlock("String_Node_Str");
  code.append(sharedStream.toString());
  HashSet functions=new HashSet();
  HashSet types=new HashSet();
  types.addAll(_primitiveTypes);
  functions.addAll(_typeFuncUsed);
  types.addAll(_newTypesUsed);
  if (types.contains("String_Node_Str")) {
    functions.add("String_Node_Str");
  }
  Object[] typesArray=types.toArray();
  CodeStream[] typeStreams=new CodeStream[types.size()];
  String typeMembers=new String();
  for (int i=0; i < types.size(); i++) {
    typeStreams[i]=new CodeStream("String_Node_Str" + typesArray[i] + "String_Node_Str");
    code.append("String_Node_Str" + typesArray[i] + "String_Node_Str"+ i+ "String_Node_Str");
    typeMembers+="String_Node_Str" + typesArray[i] + "String_Node_Str"+ typesArray[i]+ "String_Node_Str";
  }
  Object[] functionsArray=functions.toArray();
  for (int i=0; i < functions.size(); i++) {
    code.append("String_Node_Str" + functionsArray[i] + "String_Node_Str"+ i+ "String_Node_Str");
  }
  code.append("String_Node_Str");
  for (int i=0; i < types.size(); i++) {
    typeStreams[i].appendCodeBlock("String_Node_Str");
    code.append(typeStreams[i].toString());
  }
  if (!typeMembers.equals("String_Node_Str")) {
    ArrayList args=new ArrayList();
    args.add(typeMembers);
    sharedStream.clear();
    sharedStream.appendCodeBlock("String_Node_Str",args);
    code.append(sharedStream.toString());
  }
  for (int i=0; i < types.size(); i++) {
    typeStreams[i].clear();
    typeStreams[i].appendCodeBlock("String_Node_Str");
    code.append(typeStreams[i].toString());
  }
  sharedStream.clear();
  sharedStream.appendCodeBlock("String_Node_Str");
  code.append(sharedStream.toString());
  if (functions.size() > 0 && types.size() > 0) {
    code.append("String_Node_Str" + types.size() + "String_Node_Str");
    code.append("String_Node_Str" + functions.size() + "String_Node_Str");
    code.append("String_Node_Str" + "String_Node_Str");
    for (int i=0; i < types.size(); i++) {
      code.append("String_Node_Str");
      for (int j=0; j < functions.size(); j++) {
        code.append(typesArray[i] + "String_Node_Str" + functionsArray[j]);
        if ((i != (types.size() - 1)) || (j != (functions.size() - 1))) {
          code.append("String_Node_Str");
        }
      }
      code.append("String_Node_Str");
    }
    code.append("String_Node_Str");
  }
  for (int i=0; i < types.size(); i++) {
    typeStreams[i].clear();
    typeStreams[i].appendCodeBlock("String_Node_Str");
    for (int j=0; j < functions.size(); j++) {
      try {
        typeStreams[i].appendCodeBlock(functionsArray[j] + "String_Node_Str");
      }
 catch (      IllegalActionException ex) {
        typeStreams[i].append("String_Node_Str" + typesArray[i] + "String_Node_Str"+ functionsArray[j]+ "String_Node_Str");
      }
    }
    code.append(typeStreams[i].toString());
  }
  return code.toString();
}