Program: 73324
Project: 73324
Buggy source:
/** 
 * Generate the fire code.  <p>Generate code that creates tokens, sends them to the input(s) of inner Ptolemy actor, calls fire() on the actor and reads the outputs.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
protected String _generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer(getCodeGenerator().comment("String_Node_Str"));
  Iterator inputPorts=((Actor)getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    String name=inputPort.getName();
    Type type=inputPort.getType();
    if (!inputPort.isMultiport() && inputPort.isOutsideConnected() && ((inputPort instanceof ParameterPort) || inputPort.numLinks() > 0)) {
      code.append(_generateSendInside(name,name,type,0));
    }
 else {
      int sources=inputPort.numberOfSources();
      for (int i=0; i < sources; i++) {
        code.append(_generateSendInside(name,name + "String_Node_Str" + i,type,i));
      }
      int sinks=inputPort.numberOfSinks();
      int width=inputPort.getWidth();
      if (width < sinks) {
        sinks=width;
      }
      for (int i=0; i < sinks; i++) {
        code.append(_generateSendInside(name,name + "String_Node_Str" + i,type,i));
      }
    }
  }
  code.append("String_Node_Str" + _eol);
  Iterator outputPorts=((Actor)getComponent()).outputPortList().iterator();
  while (outputPorts.hasNext()) {
    TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
    String name=outputPort.getName();
    Type type=outputPort.getType();
    if (!outputPort.isMultiport()) {
      if (outputPort.isOutsideConnected()) {
        code.append("String_Node_Str" + _eol + _generateGetInsideDeclarations(name,name,type,0)+ _generateGetInside(name,name,type,0)+ _eol+ "String_Node_Str"+ _eol);
      }
    }
 else {
      int sources=outputPort.numberOfSources();
      for (int i=0; i < sources; i++) {
        code.append("String_Node_Str" + _eol + _generateGetInsideDeclarations(name,name + "String_Node_Str" + i,type,i)+ _generateGetInside(name,name + "String_Node_Str" + i,type,i)+ _eol+ "String_Node_Str"+ _eol);
      }
      int sinks=outputPort.numberOfSinks();
      for (int i=0; i < sinks; i++) {
        code.append("String_Node_Str" + _eol + _generateGetInsideDeclarations(name,name + "String_Node_Str" + i,type,i)+ _generateGetInside(name,name + "String_Node_Str" + i,type,i)+ _eol+ "String_Node_Str"+ _eol);
      }
    }
  }
  String[] splitFireCode=getCodeGenerator()._splitBody("String_Node_Str",code.toString());
  return "String_Node_Str" + _eol + splitFireCode[0]+ _eol+ splitFireCode[1]+ _eol+ "String_Node_Str"+ _eol;
}

Fixed version (ground truth):
/** 
 * Generate the fire code.  <p>Generate code that creates tokens, sends them to the input(s) of inner Ptolemy actor, calls fire() on the actor and reads the outputs.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
protected String _generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer(getCodeGenerator().comment("String_Node_Str"));
  Iterator inputPorts=((Actor)getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    String name=inputPort.getName();
    Type type=inputPort.getType();
    if (!inputPort.isMultiport() && inputPort.isOutsideConnected() && ((inputPort instanceof ParameterPort) || inputPort.numLinks() > 0)) {
      code.append(_generateSendInside(name,name,type,0));
    }
 else {
      int sources=inputPort.numberOfSources();
      for (int i=0; i < sources; i++) {
        code.append(_generateSendInside(name,name + "String_Node_Str" + i,type,i));
      }
      int sinks=inputPort.numberOfSinks();
      int width=inputPort.getWidth();
      if (width < sinks) {
        sinks=width;
      }
      for (int i=0; i < sinks; i++) {
        code.append(_generateSendInside(name,name + "String_Node_Str" + i,type,i));
      }
    }
  }
  code.append("String_Node_Str" + _eol);
  Iterator outputPorts=((Actor)getComponent()).outputPortList().iterator();
  while (outputPorts.hasNext()) {
    TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
    String name=outputPort.getName();
    Type type=outputPort.getType();
    if (!outputPort.isMultiport()) {
      if (outputPort.isOutsideConnected()) {
        code.append("String_Node_Str" + _eol + _generateGetInsideDeclarations(name,name,type,0)+ _eol+ "String_Node_Str"+ _eol);
      }
    }
 else {
      int sources=outputPort.numberOfSources();
      for (int i=0; i < sources; i++) {
        code.append("String_Node_Str" + _eol + _generateGetInsideDeclarations(name,name + "String_Node_Str" + i,type,i)+ _eol+ "String_Node_Str"+ _eol);
      }
      int sinks=outputPort.numberOfSinks();
      for (int i=0; i < sinks; i++) {
        code.append("String_Node_Str" + _eol + _generateGetInsideDeclarations(name,name + "String_Node_Str" + i,type,i)+ _eol+ "String_Node_Str"+ _eol);
      }
    }
  }
  String[] splitFireCode=getCodeGenerator()._splitBody("String_Node_Str",code.toString());
  return "String_Node_Str" + _eol + splitFireCode[0]+ _eol+ splitFireCode[1]+ _eol+ "String_Node_Str"+ _eol;
}