Program: 73848
Project: 73848
Buggy source:
/** 
 * Generate the code for the firing of actors according to the SDF schedule.
 * @return The generated fire code.
 * @exception IllegalActionException If the SDF director does not have anattribute called "iterations" or a valid schedule, or the actor to be fired cannot find its associated adapter.
 */
public String generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str")));
  boolean inline=((BooleanToken)getCodeGenerator().inline.getToken()).booleanValue();
  ptolemy.actor.sched.StaticSchedulingDirector director=(ptolemy.actor.sched.StaticSchedulingDirector)getComponent();
  Schedule schedule=director.getScheduler().getSchedule();
  Iterator<?> actorsToFire=schedule.firingIterator();
  while (actorsToFire.hasNext()) {
    Firing firing=(Firing)actorsToFire.next();
    Actor actor=firing.getActor();
    NamedProgramCodeGeneratorAdapter adapter=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(actor);
    if (actor instanceof ModularCodeGenTypedCompositeActor || actor instanceof ModularCompiledSDFTypedCompositeActor) {
      String className=NamedProgramCodeGeneratorAdapter.generateName((NamedObj)actor);
      String actorName=ModularCodeGenTypedCompositeActor.classToActorName(className);
      code.append(actorName + "String_Node_Str");
      NamedProgramCodeGeneratorAdapter codegeneratorAdaptor=(NamedProgramCodeGeneratorAdapter)getAdapter((NamedObj)actor);
      Iterator<?> inputPorts=actor.inputPortList().iterator();
      boolean addComma=false;
      while (inputPorts.hasNext()) {
        TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
        for (int i=0; i < inputPort.getWidth(); i++) {
          if (addComma) {
            code.append("String_Node_Str");
          }
          code.append(codegeneratorAdaptor.getReference(inputPort.getName() + "String_Node_Str" + i));
          addComma=true;
        }
      }
      code.append("String_Node_Str" + _eol);
      Iterator<?> outputPorts=actor.outputPortList().iterator();
      while (outputPorts.hasNext()) {
        TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
        int rate=DFUtilities.getTokenProductionRate(outputPort);
        for (int i=0; i < outputPort.getWidth(); i++) {
          if (rate <= 1) {
            code.append(codegeneratorAdaptor.getReference(outputPort.getName() + "String_Node_Str" + i) + "String_Node_Str" + actorName+ "String_Node_Str"+ codegeneratorAdaptor.getReference("String_Node_Str" + outputPort.getName() + "String_Node_Str"+ i)+ "String_Node_Str"+ _eol);
          }
 else {
            for (int k=0; k < rate; k++) {
              code.append(codegeneratorAdaptor.getReference(outputPort.getName() + "String_Node_Str" + i) + "String_Node_Str" + actorName+ "String_Node_Str"+ codegeneratorAdaptor.getReference("String_Node_Str" + outputPort.getName() + "String_Node_Str"+ i)+ "String_Node_Str"+ _eol);
            }
          }
        }
      }
    }
 else {
      if (inline) {
        for (int i=0; i < firing.getIterationCount(); i++) {
          code.append(adapter.generateFireCode());
          _generateUpdatePortOffsetCode(code,actor);
        }
      }
 else {
        int count=firing.getIterationCount();
        if (count > 1) {
          code.append("String_Node_Str" + count + "String_Node_Str"+ _eol);
        }
        code.append(generateName((NamedObj)actor) + "String_Node_Str" + _eol);
        _generateUpdatePortOffsetCode(code,actor);
        if (count > 1) {
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the code for the firing of actors according to the SDF schedule.
 * @return The generated fire code.
 * @exception IllegalActionException If the SDF director does not have anattribute called "iterations" or a valid schedule, or the actor to be fired cannot find its associated adapter.
 */
public String generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str")));
  boolean inline=((BooleanToken)getCodeGenerator().inline.getToken()).booleanValue();
  ptolemy.actor.sched.StaticSchedulingDirector director=(ptolemy.actor.sched.StaticSchedulingDirector)getComponent();
  Schedule schedule=director.getScheduler().getSchedule();
  Iterator<?> actorsToFire=schedule.firingIterator();
  while (actorsToFire.hasNext()) {
    Firing firing=(Firing)actorsToFire.next();
    Actor actor=firing.getActor();
    NamedProgramCodeGeneratorAdapter adapter=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(actor);
    if (actor instanceof ModularCodeGenTypedCompositeActor || actor instanceof ModularCompiledSDFTypedCompositeActor) {
      String className=NamedProgramCodeGeneratorAdapter.generateName((NamedObj)actor);
      String actorName=ModularCodeGenTypedCompositeActor.classToActorName(className);
      code.append(actorName + "String_Node_Str");
      NamedProgramCodeGeneratorAdapter codegeneratorAdaptor=(NamedProgramCodeGeneratorAdapter)getAdapter((NamedObj)actor);
      Iterator<?> inputPorts=actor.inputPortList().iterator();
      boolean addComma=false;
      while (inputPorts.hasNext()) {
        TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
        for (int i=0; i < inputPort.getWidth(); i++) {
          if (addComma) {
            code.append("String_Node_Str");
          }
          code.append(codegeneratorAdaptor.getReference(inputPort.getName() + "String_Node_Str" + i));
          addComma=true;
        }
      }
      code.append("String_Node_Str" + _eol);
      Iterator<?> outputPorts=actor.outputPortList().iterator();
      while (outputPorts.hasNext()) {
        TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
        int rate=DFUtilities.getTokenProductionRate(outputPort);
        for (int i=0; i < outputPort.getWidth(); i++) {
          if (rate <= 1) {
            code.append(codegeneratorAdaptor.getReference(outputPort.getName() + "String_Node_Str" + i) + "String_Node_Str" + actorName+ "String_Node_Str"+ codegeneratorAdaptor.getReference("String_Node_Str" + outputPort.getName() + "String_Node_Str"+ i)+ "String_Node_Str"+ _eol);
          }
 else {
            for (int k=0; k < rate; k++) {
              code.append(codegeneratorAdaptor.getReference(outputPort.getName() + "String_Node_Str" + i+ "String_Node_Str"+ k) + "String_Node_Str" + actorName+ "String_Node_Str"+ codegeneratorAdaptor.getReference("String_Node_Str" + outputPort.getName() + "String_Node_Str"+ i+ "String_Node_Str"+ k)+ "String_Node_Str"+ _eol);
            }
          }
        }
      }
    }
 else {
      if (inline) {
        for (int i=0; i < firing.getIterationCount(); i++) {
          code.append(adapter.generateFireCode());
          _generateUpdatePortOffsetCode(code,actor);
        }
      }
 else {
        int count=firing.getIterationCount();
        if (count > 1) {
          code.append("String_Node_Str" + count + "String_Node_Str"+ _eol);
        }
        code.append(generateName((NamedObj)actor) + "String_Node_Str" + _eol);
        _generateUpdatePortOffsetCode(code,actor);
        if (count > 1) {
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  return code.toString();
}