Program: 73404
Project: 73404
Buggy source:
/** 
 * Generate the fire code of the associated composite actor. This method first generates code for transferring any data from the input ports of this composite to the ports connected on the inside by calling the generateTransferInputsCode() method of the local director adapter. It then invokes the generateFireCode() method of its local director adapter.  After the generateFireCode() method of the director adapter returns, generate code for transferring any output data created by calling the local director adapter's generateTransferOutputsCode() method.
 * @return The generated fire code.
 * @exception IllegalActionException If the adapter associatedwith an actor throws it while generating fire code for the actor, or the director adapter throws it while generating code for transferring data.
 */
@Override protected String _generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(getCodeGenerator().comment(2,"String_Node_Str" + getComponent().getName()));
  Director directorAdapter=(Director)getCodeGenerator().getAdapter(((ptolemy.actor.CompositeActor)getComponent()).getDirector());
  Iterator<?> inputPorts=((ptolemy.actor.CompositeActor)getComponent()).inputPortList().iterator();
  StringBuffer tempCode=new StringBuffer();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    if (inputPort instanceof ParameterPort && inputPort.isOutsideConnected()) {
      PortParameter portParameter=((ParameterPort)inputPort).getParameter();
      tempCode.append(CodeStream.indent(getCodeGenerator().generateVariableName(portParameter)));
      tempCode.append("String_Node_Str");
      String reference=getReference(inputPort.getName(),false);
      if (reference != "String_Node_Str") {
        tempCode.append(reference);
      }
 else {
        tempCode.append(getReference(inputPort.getName(),true));
      }
      tempCode.append("String_Node_Str" + _eol);
    }
  }
  if (tempCode.length() > 0) {
    code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + getComponent().getName() + "String_Node_Str")));
    code.append(tempCode);
  }
  inputPorts=((ptolemy.actor.CompositeActor)getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    if (!(inputPort instanceof ParameterPort)) {
      directorAdapter.generateTransferInputsCode(inputPort,code);
    }
  }
  code.append(directorAdapter.generateFireCode());
  Iterator<?> outputPorts=((ptolemy.actor.CompositeActor)getComponent()).outputPortList().iterator();
  if ((getComponent() instanceof ModularCodeGenTypedCompositeActor) && ((ptolemy.actor.CompositeActor)getComponent()).outputPortList().size() > 0)   code.append("String_Node_Str" + _eol);
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    directorAdapter.generateTransferOutputsCode(outputPort,code);
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Generate the fire code of the associated composite actor. This method first generates code for transferring any data from the input ports of this composite to the ports connected on the inside by calling the generateTransferInputsCode() method of the local director adapter. It then invokes the generateFireCode() method of its local director adapter.  After the generateFireCode() method of the director adapter returns, generate code for transferring any output data created by calling the local director adapter's generateTransferOutputsCode() method.
 * @return The generated fire code.
 * @exception IllegalActionException If the adapter associatedwith an actor throws it while generating fire code for the actor, or the director adapter throws it while generating code for transferring data.
 */
@Override protected String _generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(getCodeGenerator().comment(2,"String_Node_Str" + getComponent().getName()));
  Director directorAdapter=(Director)getCodeGenerator().getAdapter(((ptolemy.actor.CompositeActor)getComponent()).getDirector());
  Iterator<?> inputPorts=((ptolemy.actor.CompositeActor)getComponent()).inputPortList().iterator();
  StringBuffer tempCode=new StringBuffer();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    if (inputPort instanceof ParameterPort && inputPort.isOutsideConnected()) {
      PortParameter portParameter=((ParameterPort)inputPort).getParameter();
      tempCode.append(CodeStream.indent(getCodeGenerator().generateVariableName(portParameter)));
      tempCode.append("String_Node_Str");
      String reference=getReference(inputPort.getName(),false);
      if (!reference.equals("String_Node_Str")) {
        tempCode.append(reference);
      }
 else {
        tempCode.append(getReference(inputPort.getName(),true));
      }
      tempCode.append("String_Node_Str" + _eol);
    }
  }
  if (tempCode.length() > 0) {
    code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + getComponent().getName() + "String_Node_Str")));
    code.append(tempCode);
  }
  inputPorts=((ptolemy.actor.CompositeActor)getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    if (!(inputPort instanceof ParameterPort)) {
      directorAdapter.generateTransferInputsCode(inputPort,code);
    }
  }
  code.append(directorAdapter.generateFireCode());
  Iterator<?> outputPorts=((ptolemy.actor.CompositeActor)getComponent()).outputPortList().iterator();
  if ((getComponent() instanceof ModularCodeGenTypedCompositeActor) && ((ptolemy.actor.CompositeActor)getComponent()).outputPortList().size() > 0)   code.append("String_Node_Str" + _eol);
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    directorAdapter.generateTransferOutputsCode(outputPort,code);
  }
  return processCode(code.toString());
}