Program: 73845
Project: 73845
Buggy source:
/** 
 * Generate code for transferring enough tokens to fulfill the output production rate.
 * @param outputPort The port to transfer tokens.
 * @param code The string buffer that the generated code is appended to.
 * @exception IllegalActionException If thrown while transferring tokens.
 */
public void generateTransferOutputsCode(IOPort outputPort,StringBuffer code) throws IllegalActionException {
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str")));
  int rate=DFUtilities.getTokenProductionRate(outputPort);
  CompositeActor container=(CompositeActor)getComponent().getContainer();
  TypedCompositeActor compositeActorAdapter=(TypedCompositeActor)getCodeGenerator().getAdapter(container);
  if (container instanceof CompiledCompositeActor && ((BooleanToken)getCodeGenerator().generateEmbeddedCode.getToken()).booleanValue()) {
    if (_portNumber == 0) {
      int numberOfOutputPorts=container.outputPortList().size();
      code.append("String_Node_Str" + "String_Node_Str" + String.valueOf(numberOfOutputPorts) + "String_Node_Str"+ _eol);
    }
    String portName=outputPort.getName();
    String tokensToThisPort="String_Node_Str" + portName;
    if (!(outputPort instanceof TypedIOPort)) {
      throw new InternalErrorException(outputPort,null,"String_Node_Str");
    }
    Type type=((TypedIOPort)outputPort).getType();
    int numberOfChannels=outputPort.getWidthInside();
    if (type == BaseType.INT) {
      code.append("String_Node_Str" + tokensToThisPort + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(numberOfChannels)+ "String_Node_Str"+ rate+ "String_Node_Str"+ _eol);
    }
 else     if (type == BaseType.DOUBLE) {
      code.append("String_Node_Str" + tokensToThisPort + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(numberOfChannels)+ "String_Node_Str"+ rate+ "String_Node_Str"+ _eol);
    }
 else     if (type == BaseType.BOOLEAN) {
      code.append("String_Node_Str" + tokensToThisPort + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(numberOfChannels)+ "String_Node_Str"+ rate+ "String_Node_Str"+ _eol);
    }
 else {
    }
    for (int i=0; i < outputPort.getWidthInside(); i++) {
      String portNameWithChannelNumber=portName;
      if (outputPort.isMultiport()) {
        portNameWithChannelNumber=portName + '#' + i;
      }
      for (int k=0; k < rate; k++) {
        String portReference=compositeActorAdapter.getReference("String_Node_Str" + portNameWithChannelNumber + "String_Node_Str"+ k);
        code.append(tokensToThisPort + "String_Node_Str" + i+ "String_Node_Str"+ k+ "String_Node_Str"+ portReference+ "String_Node_Str"+ _eol);
      }
    }
    code.append("String_Node_Str" + String.valueOf(_portNumber) + "String_Node_Str"+ tokensToThisPort+ "String_Node_Str"+ _eol);
    _portNumber++;
  }
 else {
    for (int i=0; i < outputPort.getWidthInside(); i++) {
      if (i < outputPort.getWidth()) {
        String name=outputPort.getName();
        if (outputPort.isMultiport()) {
          name=name + '#' + i;
        }
        for (int k=0; k < rate; k++) {
          code.append(CodeStream.indent(compositeActorAdapter.getReference(name + "String_Node_Str" + k)));
          code.append("String_Node_Str" + _eol);
          code.append(CodeStream.indent(compositeActorAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k)));
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  _updatePortOffset(outputPort,code,rate);
}

Fixed version (ground truth):
/** 
 * Generate code for transferring enough tokens to fulfill the output production rate.
 * @param outputPort The port to transfer tokens.
 * @param code The string buffer that the generated code is appended to.
 * @exception IllegalActionException If thrown while transferring tokens.
 */
public void generateTransferOutputsCode(IOPort outputPort,StringBuffer code) throws IllegalActionException {
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str")));
  int rate=DFUtilities.getTokenProductionRate(outputPort);
  CompositeActor container=(CompositeActor)getComponent().getContainer();
  TypedCompositeActor compositeActorAdapter=(TypedCompositeActor)getCodeGenerator().getAdapter(container);
  if (container instanceof CompiledCompositeActor && ((BooleanToken)getCodeGenerator().generateEmbeddedCode.getToken()).booleanValue()) {
    if (_portNumber == 0) {
      int numberOfOutputPorts=container.outputPortList().size();
      code.append("String_Node_Str" + "String_Node_Str" + String.valueOf(numberOfOutputPorts) + "String_Node_Str"+ _eol);
    }
    String portName=outputPort.getName();
    String tokensToThisPort="String_Node_Str" + portName;
    if (!(outputPort instanceof TypedIOPort)) {
      throw new InternalErrorException(outputPort,null,"String_Node_Str");
    }
    Type type=((TypedIOPort)outputPort).getType();
    int numberOfChannels=outputPort.getWidthInside();
    if (type == BaseType.INT) {
      code.append("String_Node_Str" + tokensToThisPort + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(numberOfChannels)+ "String_Node_Str"+ rate+ "String_Node_Str"+ _eol);
    }
 else     if (type == BaseType.DOUBLE) {
      code.append("String_Node_Str" + tokensToThisPort + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(numberOfChannels)+ "String_Node_Str"+ rate+ "String_Node_Str"+ _eol);
    }
 else     if (type == BaseType.BOOLEAN) {
      code.append("String_Node_Str" + tokensToThisPort + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(numberOfChannels)+ "String_Node_Str"+ rate+ "String_Node_Str"+ _eol);
    }
 else {
    }
    for (int i=0; i < outputPort.getWidthInside(); i++) {
      String portNameWithChannelNumber=portName;
      if (outputPort.isMultiport()) {
        portNameWithChannelNumber=portName + '#' + i;
      }
      for (int k=0; k < rate; k++) {
        String portReference=compositeActorAdapter.getReference("String_Node_Str" + portNameWithChannelNumber + "String_Node_Str"+ k,false);
        code.append(tokensToThisPort + "String_Node_Str" + i+ "String_Node_Str"+ k+ "String_Node_Str"+ portReference+ "String_Node_Str"+ _eol);
      }
    }
    code.append("String_Node_Str" + String.valueOf(_portNumber) + "String_Node_Str"+ tokensToThisPort+ "String_Node_Str"+ _eol);
    _portNumber++;
  }
 else {
    for (int i=0; i < outputPort.getWidthInside(); i++) {
      if (i < outputPort.getWidth()) {
        String name=outputPort.getName();
        if (outputPort.isMultiport()) {
          name=name + '#' + i;
        }
        for (int k=0; k < rate; k++) {
          code.append(CodeStream.indent(compositeActorAdapter.getReference(name + "String_Node_Str" + k,false)));
          code.append("String_Node_Str" + _eol);
          code.append(CodeStream.indent(compositeActorAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k,false)));
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  _updatePortOffset(outputPort,code,rate);
}