Program: 74176
Project: 74176
Buggy source:
/** 
 * Generate a main loop for an execution under the control of this director. If the associated director has a parameter named <i>iterations</i> with a value greater than zero, then wrap code generated by generateFireCode() in a loop that executes the specified number of iterations. Otherwise, wrap it in a loop that executes forever. In the loop, first get the code returned by generateFireCode(), and follow that with the code produced by the container help for generateModeTransitionCode(). That code will make state transitions in modal models at the conclusion of each iteration. Next, this code calls postfire(), and that returns false, breaks out of the main loop. Finally, if the director has a parameter named <i>period</i>, then increment the variable _currentTime after each pass through the loop.
 * @return Code for the main loop of an execution.
 * @exception IllegalActionException If something goes wrong.
 */
public String generateMainLoop() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Attribute iterations=_director.getAttribute("String_Node_Str");
  if (iterations == null) {
    code.append(_eol + "String_Node_Str" + _eol);
  }
 else {
    int iterationCount=((IntToken)((Variable)iterations).getToken()).intValue();
    if (iterationCount <= 0) {
      code.append(_eol + "String_Node_Str" + _eol);
    }
 else {
      code.append(_eol + "String_Node_Str" + _eol);
      code.append("String_Node_Str" + iterationCount + "String_Node_Str"+ _eol);
    }
  }
  code.append(generateFireCode());
  ActorCodeGenerator modelAdapter=getCodeGenerator().getAdapter(_director.getContainer());
  modelAdapter.generateModeTransitionCode(code);
  _generateUpdatePortOffsetCode(code,(Actor)_director.getContainer());
  code.append(generatePostfireCode());
  Attribute period=_director.getAttribute("String_Node_Str");
  if (period != null) {
    Double periodValue=((DoubleToken)((Variable)period).getToken()).doubleValue();
    if (periodValue != 0.0) {
      code.append("String_Node_Str" + periodValue + "String_Node_Str"+ _eol);
    }
    code.append("String_Node_Str" + _eol);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate a main loop for an execution under the control of this director. If the associated director has a parameter named <i>iterations</i> with a value greater than zero, then wrap code generated by generateFireCode() in a loop that executes the specified number of iterations. Otherwise, wrap it in a loop that executes forever. In the loop, first get the code returned by generateFireCode(), and follow that with the code produced by the container help for generateModeTransitionCode(). That code will make state transitions in modal models at the conclusion of each iteration. Next, this code calls postfire(), and that returns false, breaks out of the main loop. Finally, if the director has a parameter named <i>period</i>, then increment the variable _currentTime after each pass through the loop.
 * @return Code for the main loop of an execution.
 * @exception IllegalActionException If something goes wrong.
 */
public String generateMainLoop() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Attribute iterations=_director.getAttribute("String_Node_Str");
  if (iterations == null) {
    code.append(_eol + "String_Node_Str" + _eol);
  }
 else {
    int iterationCount=((IntToken)((Variable)iterations).getToken()).intValue();
    if (iterationCount <= 0) {
      code.append(_eol + "String_Node_Str" + _eol);
    }
 else {
      code.append(_eol + "String_Node_Str" + _eol);
      code.append("String_Node_Str" + iterationCount + "String_Node_Str"+ _eol);
    }
  }
  code.append(generateFireCode());
  CodeGeneratorAdapter modelAdapter=getCodeGenerator().getAdapter(_director.getContainer());
  modelAdapter.generateModeTransitionCode(code);
  _generateUpdatePortOffsetCode(code,(Actor)_director.getContainer());
  code.append(generatePostfireCode());
  Attribute period=_director.getAttribute("String_Node_Str");
  if (period != null) {
    Double periodValue=((DoubleToken)((Variable)period).getToken()).doubleValue();
    if (periodValue != 0.0) {
      code.append("String_Node_Str" + periodValue + "String_Node_Str"+ _eol);
    }
    code.append("String_Node_Str" + _eol);
  }
  return code.toString();
}