Program: 73109
Project: 73109
Buggy source:
/** 
 * Generate the initialize code for this director. The initialize code for the director is generated by appending the initialize code for each actor.
 * @return The generated initialize code.
 * @exception IllegalActionException If the adapter associated withan actor throws it while generating initialize code for the actor.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  boolean variablesAsArrays=((BooleanToken)getCodeGenerator().variablesAsArrays.getToken()).booleanValue();
  if (variablesAsArrays) {
    CompositeActor container=(CompositeActor)_director.getContainer();
    StringBuffer code2=new StringBuffer();
    Iterator<?> ports=container.inputPortList().iterator();
    while (ports.hasNext()) {
      TypedIOPort port=(TypedIOPort)ports.next();
      int rate=DFUtilities.getTokenInitProduction(port);
      if (rate > 0) {
        int bufferSize=_ports.getBufferSize(port);
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ "String_Node_Str"+ bufferSize+ "String_Node_Str"+ _eol);
      }
 else       if (port.getWidth() > 1 || port.getWidthInside() > 1) {
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ _eol);
      }
    }
    ports=container.outputPortList().iterator();
    while (ports.hasNext()) {
      TypedIOPort port=(TypedIOPort)ports.next();
      int rate=DFUtilities.getTokenInitProduction(port);
      if (rate > 0) {
        int bufferSize=_ports.getBufferSize(port);
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ "String_Node_Str"+ bufferSize+ "String_Node_Str"+ _eol);
      }
 else       if (port.getWidth() > 1 || port.getWidthInside() > 1) {
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ _eol);
      }
    }
    if (code2.length() > 0) {
      code.append(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str") + code2.toString());
    }
    code.append(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str"));
    Iterator<?> actors=container.deepEntityList().iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      NamedProgramCodeGeneratorAdapter adapterObject=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(actor);
      if (actor instanceof CompositeActor && ((CompositeActor)actor).isOpaque()) {
        code.append(getCodeGenerator().comment("String_Node_Str" + actor.getFullName()));
      }
 else {
        code.append(_generatePortVariableDeclaration(adapterObject));
        if (variablesAsArrays) {
          code.append(getCodeGenerator().comment("String_Node_Str"));
          ports=actor.outputPortList().iterator();
          while (ports.hasNext()) {
            TypedIOPort port=(TypedIOPort)ports.next();
            int rate=DFUtilities.getTokenInitProduction(port);
            int bufferSize=_ports.getBufferSize(port);
            if (port.isMultiport() && rate > 0) {
              code.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ "String_Node_Str"+ bufferSize+ "String_Node_Str"+ _eol);
            }
          }
        }
      }
    }
  }
  code.append(super.generateInitializeCode());
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the initialize code for this director. The initialize code for the director is generated by appending the initialize code for each actor.
 * @return The generated initialize code.
 * @exception IllegalActionException If the adapter associated withan actor throws it while generating initialize code for the actor.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  boolean variablesAsArrays=((BooleanToken)getCodeGenerator().variablesAsArrays.getToken()).booleanValue();
  if (variablesAsArrays) {
    CompositeActor container=(CompositeActor)_director.getContainer();
    StringBuffer code2=new StringBuffer();
    Iterator<?> ports=container.inputPortList().iterator();
    while (ports.hasNext()) {
      TypedIOPort port=(TypedIOPort)ports.next();
      int rate=DFUtilities.getTokenInitConsumption(port);
      if (rate > 0) {
        int bufferSize=_ports.getBufferSize(port);
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ "String_Node_Str"+ bufferSize+ "String_Node_Str"+ _eol);
      }
 else       if (port.getWidth() > 1 || port.getWidthInside() > 1) {
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ _eol);
      }
    }
    ports=container.outputPortList().iterator();
    while (ports.hasNext()) {
      TypedIOPort port=(TypedIOPort)ports.next();
      int rate=DFUtilities.getTokenInitProduction(port);
      if (rate > 0) {
        int bufferSize=_ports.getBufferSize(port);
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ "String_Node_Str"+ bufferSize+ "String_Node_Str"+ _eol);
      }
 else       if (port.getWidth() > 1 || port.getWidthInside() > 1) {
        code2.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ _eol);
      }
    }
    if (code2.length() > 0) {
      code.append(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str") + code2.toString());
    }
    code.append(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str"));
    Iterator<?> actors=container.deepEntityList().iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      NamedProgramCodeGeneratorAdapter adapterObject=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(actor);
      if (actor instanceof CompositeActor && ((CompositeActor)actor).isOpaque()) {
        code.append(getCodeGenerator().comment("String_Node_Str" + actor.getFullName()));
      }
 else {
        code.append(_generatePortVariableDeclaration(adapterObject));
        if (variablesAsArrays) {
          code.append(getCodeGenerator().comment("String_Node_Str"));
          ports=actor.outputPortList().iterator();
          while (ports.hasNext()) {
            TypedIOPort port=(TypedIOPort)ports.next();
            int rate=DFUtilities.getTokenInitProduction(port);
            int bufferSize=_ports.getBufferSize(port);
            if (port.isMultiport() && rate > 0) {
              code.append(generatePortName(port) + "String_Node_Str" + targetType(port.getType())+ "String_Node_Str"+ java.lang.Math.max(port.getWidth(),port.getWidthInside())+ "String_Node_Str"+ "String_Node_Str"+ bufferSize+ "String_Node_Str"+ _eol);
            }
          }
        }
      }
    }
  }
  code.append(super.generateInitializeCode());
  return code.toString();
}