nus-yam/ex-repair huggingface dataset:
Program: 73392
Project: 73392
Buggy source:
/** 
 * Return an unique label for the given port channel referenced by the given helper.
 * @param port The given port.
 * @param channelAndOffset The given channel and offset.
 * @param forComposite Whether the given helper is associated witha CompositeActor
 * @param isWrite The type of the reference. True if this isa write reference; otherwise, this is a read reference.
 * @param helper The specified helper.
 * @return an unique reference label for the given port channel.
 * @exception IllegalActionException If the helper throws it whilegenerating the label.
 */
public String getReference(TypedIOPort port,String[] channelAndOffset,boolean forComposite,boolean isWrite,CodeGeneratorHelper helper) throws IllegalActionException {
  Actor actor=(Actor)port.getContainer();
  Director director=actor.getDirector();
  if (_debugging) {
    _debug("String_Node_Str" + port.getFullName() + "String_Node_Str"+ actor.getFullName()+ "String_Node_Str"+ director.getFullName());
  }
  if (port.isOutput() && forComposite == false && !director.getFullName().contains("String_Node_Str")) {
    if (channelAndOffset[0] == "String_Node_Str") {
      channelAndOffset[0]="String_Node_Str";
    }
    return CodeGeneratorHelper.generateName(port);
  }
 else {
    return super.getReference(port,channelAndOffset,forComposite,isWrite,helper);
  }
}

Fixed version (ground truth):
/** 
 * Return an unique label for the given port channel referenced by the given helper.
 * @param port The given port.
 * @param channelAndOffset The given channel and offset.
 * @param forComposite Whether the given helper is associated witha CompositeActor
 * @param isWrite The type of the reference. True if this isa write reference; otherwise, this is a read reference.
 * @param helper The specified helper.
 * @return an unique reference label for the given port channel.
 * @exception IllegalActionException If the helper throws it whilegenerating the label.
 */
public String getReference(TypedIOPort port,String[] channelAndOffset,boolean forComposite,boolean isWrite,CodeGeneratorHelper helper) throws IllegalActionException {
  Actor actor=(Actor)port.getContainer();
  Director director=actor.getDirector();
  if (_debugging) {
    _debug("String_Node_Str" + port.getFullName() + "String_Node_Str"+ actor.getFullName()+ "String_Node_Str"+ director.getFullName());
  }
  if (port.isOutput() && forComposite == false && !director.getFullName().contains("String_Node_Str")) {
    if (channelAndOffset[0].equals("String_Node_Str")) {
      channelAndOffset[0]="String_Node_Str";
    }
    return CodeGeneratorHelper.generateName(port);
  }
 else {
    return super.getReference(port,channelAndOffset,forComposite,isWrite,helper);
  }
}
Program: 73394
Project: 73394
Buggy source:
public static void main(String[] args){
  final int WINDOW_WIDTH=320;
  final int WINDOW_HEIGHT=240;
  final String WINDOW_TITLE="String_Node_Str";
  JFrame frame=new JFrame();
  final cubeTriangle joglMain=new cubeTriangle();
  frame.setContentPane(joglMain);
  frame.addWindowListener(new WindowAdapter(){
    @Override public void windowClosing(    WindowEvent e){
      new Thread(){
        @Override public void run(){
          joglMain.animator.stop();
          System.exit(0);
        }
      }
.start();
    }
  }
);
  frame.setSize(WINDOW_WIDTH,WINDOW_HEIGHT);
  frame.setTitle(WINDOW_TITLE);
  frame.setVisible(true);
  joglMain.animator.start();
}

Fixed version (ground truth):
public static void main(String[] args){
  final int WINDOW_WIDTH=320;
  final int WINDOW_HEIGHT=240;
  final String WINDOW_TITLE="String_Node_Str";
  try {
    Runnable doActions=new Runnable(){
      public void run(){
        try {
          JFrame frame=new JFrame();
          final cubeTriangle joglMain=new cubeTriangle();
          frame.setContentPane(joglMain);
          frame.addWindowListener(new WindowAdapter(){
            @Override public void windowClosing(            WindowEvent e){
              new Thread(){
                @Override public void run(){
                  joglMain.animator.stop();
                  System.exit(0);
                }
              }
.start();
            }
          }
);
          frame.setSize(WINDOW_WIDTH,WINDOW_HEIGHT);
          frame.setTitle(WINDOW_TITLE);
          frame.setVisible(true);
          joglMain.animator.start();
        }
 catch (        Exception ex) {
          System.err.println(ex.toString());
          ex.printStackTrace();
        }
      }
    }
;
    SwingUtilities.invokeAndWait(doActions);
  }
 catch (  Exception ex) {
    System.err.println(ex.toString());
    ex.printStackTrace();
  }
}
Program: 73395
Project: 73395
Buggy source:
/** 
 * Set iteration number of the actor, which is the number of times internal entities are called.  and set corresponding attribute
 * @param repetition The number of times this actor is fired.
 */
public void setIterations(Integer[] repetition){
  String repetitionString="String_Node_Str";
  for (int i=0; i < repetition.length; i++) {
    repetitionString+=repetition[i];
    if (i < repetition.length - 1) {
      repetitionString+="String_Node_Str";
    }
  }
  repetitionString+="String_Node_Str";
  Attribute repetitions=getAttribute(PthalesCompositeActor._REPETITIONS);
  if (repetitions != null && repetitions instanceof Parameter) {
    ((Parameter)repetitions).setExpression(repetitionString);
  }
}

Fixed version (ground truth):
/** 
 * Set iteration number of the actor, which is the number of times internal entities are called.  and set corresponding attribute
 * @param repetition The number of times this actor is fired.
 */
public void setIterations(Integer[] repetition){
  StringBuffer repetitionStringBuffer=new StringBuffer("String_Node_Str");
  for (int i=0; i < repetition.length; i++) {
    repetitionStringBuffer.append(repetition[i]);
    if (i < repetition.length - 1) {
      repetitionStringBuffer.append("String_Node_Str");
    }
  }
  repetitionStringBuffer.append("String_Node_Str");
  Attribute repetitions=getAttribute(PthalesCompositeActor._REPETITIONS);
  if (repetitions != null && repetitions instanceof Parameter) {
    ((Parameter)repetitions).setExpression(repetitionStringBuffer.toString());
  }
}
Program: 73396
Project: 73396
Buggy source:
/** 
 * Modify th pattern of the specified port with dimensions (after propagate).
 * @param port associated port
 * @param dims dimension names
 * @param dimSizes dimension sizes
 */
public static void modifyPattern(IOPort port,String[] dims,int[] dimSizes){
  Attribute pattern=port.getAttribute(PATTERN);
  if (port.getAttribute(PATTERN) == null) {
    try {
      pattern=new Parameter(port,PATTERN);
    }
 catch (    IllegalActionException e) {
      e.printStackTrace();
    }
catch (    NameDuplicationException e) {
      e.printStackTrace();
    }
  }
  String s="String_Node_Str";
  if (pattern instanceof Parameter) {
    for (int i=0; i < dims.length; i++) {
      s+=dims[i] + "String_Node_Str" + dimSizes[i]+ "String_Node_Str";
      if (i < dims.length - 1) {
        s+="String_Node_Str";
      }
    }
  }
  s+="String_Node_Str";
  ((Parameter)pattern).setExpression(s);
}

Fixed version (ground truth):
/** 
 * Modify th pattern of the specified port with dimensions (after propagate).
 * @param port associated port
 * @param dims dimension names
 * @param dimSizes dimension sizes
 */
public static void modifyPattern(IOPort port,String[] dims,int[] dimSizes){
  Attribute pattern=port.getAttribute(PATTERN);
  if (port.getAttribute(PATTERN) == null) {
    try {
      pattern=new Parameter(port,PATTERN);
    }
 catch (    IllegalActionException e) {
      e.printStackTrace();
    }
catch (    NameDuplicationException e) {
      e.printStackTrace();
    }
  }
  StringBuffer s=new StringBuffer("String_Node_Str");
  if (pattern instanceof Parameter) {
    for (int i=0; i < dims.length; i++) {
      s.append(dims[i] + "String_Node_Str" + dimSizes[i]+ "String_Node_Str");
      if (i < dims.length - 1) {
        s.append("String_Node_Str");
      }
    }
  }
  s.append("String_Node_Str");
  ((Parameter)pattern).setExpression(s.toString());
}
Program: 73400
Project: 73400
Buggy source:
/** 
 * Construct an actor with the specified container and name.
 * @param container The composite entity to contain this one.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public AbsoluteDelay(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  outputTime=new TypedIOPort(this,"String_Node_Str",true,false);
  _zero=new Time(getDirector());
  Set<Port> dependentPorts=_causalityMarker.causalityMarker.get(0);
  dependentPorts.add(input);
  dependentPorts.add(outputTime);
  _causalityMarker.addDependentPortSet(dependentPorts);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the specified container and name.
 * @param container The composite entity to contain this one.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public AbsoluteDelay(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  outputTime=new TypedIOPort(this,"String_Node_Str",true,false);
  Set<Port> dependentPorts=_causalityMarker.causalityMarker.get(0);
  dependentPorts.add(input);
  dependentPorts.add(outputTime);
  _causalityMarker.addDependentPortSet(dependentPorts);
}
Program: 73401
Project: 73401
Buggy source:
/** 
 * Process the current input if it has not been processed. Schedule a firing to produce the earliest output token.
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time time=currentTime.subtract(_outputTime);
  if (time.compareTo(_zero) < 0) {
    _delay=-time.getDoubleValue();
  }
 else {
    _delay=0;
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Process the current input if it has not been processed. Schedule a firing to produce the earliest output token.
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time time=currentTime.subtract(_outputTime);
  if (time.isNegative()) {
    _delay=-time.getDoubleValue();
  }
 else {
    _delay=0;
  }
  return super.postfire();
}
Program: 73405
Project: 73405
Buggy source:
/** 
 * Generate preinitialize code. Read the <code>CommonPreinitBlock</code> from MovingAverage.c replace macros with their values and return the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generatePreinitializeCode() throws IllegalActionException {
  super.generatePreinitializeCode();
  ptolemy.actor.lib.MovingAverage actor=(ptolemy.actor.lib.MovingAverage)getComponent();
  ArrayList<String> args=new ArrayList<String>();
  CodeStream codeStream=_templateParser.getCodeStream();
  Type type=actor.output.getType();
  if (getCodeGenerator().isPrimitive(type)) {
    args.add(targetType(type).toString());
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
 else {
    throw new IllegalActionException("String_Node_Str" + type + "String_Node_Str");
  }
  return processCode(codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate preinitialize code. Read the <code>CommonPreinitBlock</code> from MovingAverage.c replace macros with their values and return the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generatePreinitializeCode() throws IllegalActionException {
  super.generatePreinitializeCode();
  ptolemy.actor.lib.MovingAverage actor=(ptolemy.actor.lib.MovingAverage)getComponent();
  ArrayList<String> args=new ArrayList<String>();
  CodeStream codeStream=_templateParser.getCodeStream();
  Type type=actor.output.getType();
  if (getCodeGenerator().isPrimitive(type)) {
    args.add(targetType(type));
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
 else {
    throw new IllegalActionException("String_Node_Str" + type + "String_Node_Str");
  }
  return processCode(codeStream.toString());
}
Program: 73406
Project: 73406
Buggy source:
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from Subscriber.c and replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.SubscriptionAggregator actor=(ptolemy.actor.lib.SubscriptionAggregator)getComponent();
  CodeStream codeStream=_templateParser.getCodeStream();
  if (actor.input.isOutsideConnected()) {
    codeStream.appendCodeBlock("String_Node_Str",false);
    ArrayList<String> args=new ArrayList<String>();
    args.add(Integer.toString(0));
    for (int i=1; i < actor.input.getWidth(); i++) {
      args.set(0,Integer.toString(i));
      if (actor.operation.stringValue().equals("String_Node_Str")) {
        codeStream.appendCodeBlock("String_Node_Str",args);
      }
 else       if (actor.operation.stringValue().equals("String_Node_Str")) {
        codeStream.appendCodeBlock("String_Node_Str",args);
      }
 else {
        throw new IllegalActionException("String_Node_Str" + actor.operation + "String_Node_Str");
      }
    }
    codeStream.appendCodeBlock("String_Node_Str",false);
  }
  return processCode(codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from Subscriber.c and replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.SubscriptionAggregator actor=(ptolemy.actor.lib.SubscriptionAggregator)getComponent();
  CodeStream codeStream=_templateParser.getCodeStream();
  if (actor.input.isOutsideConnected()) {
    codeStream.appendCodeBlock("String_Node_Str",false);
    ArrayList<String> args=new ArrayList<String>();
    args.add("String_Node_Str");
    for (int i=1; i < actor.input.getWidth(); i++) {
      args.set(0,Integer.toString(i));
      if (actor.operation.stringValue().equals("String_Node_Str")) {
        codeStream.appendCodeBlock("String_Node_Str",args);
      }
 else       if (actor.operation.stringValue().equals("String_Node_Str")) {
        codeStream.appendCodeBlock("String_Node_Str",args);
      }
 else {
        throw new IllegalActionException("String_Node_Str" + actor.operation + "String_Node_Str");
      }
    }
    codeStream.appendCodeBlock("String_Node_Str",false);
  }
  return processCode(codeStream.toString());
}
Program: 73407
Project: 73407
Buggy source:
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from VectorAssembler.c, replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.VectorAssembler actor=(ptolemy.actor.lib.VectorAssembler)getComponent();
  StringBuffer fireCode=new StringBuffer();
  ArrayList<String> args=new ArrayList<String>();
  args.add(Integer.toString(0));
  Type type=actor.input.getType();
  if (getCodeGenerator().isPrimitive(type)) {
    args.add(getCodeGenerator().codeGenType(type).toString());
  }
  for (int i=0; i < actor.input.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args));
  }
  return processCode(fireCode.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from VectorAssembler.c, replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.VectorAssembler actor=(ptolemy.actor.lib.VectorAssembler)getComponent();
  StringBuffer fireCode=new StringBuffer();
  ArrayList<String> args=new ArrayList<String>();
  args.add("String_Node_Str");
  Type type=actor.input.getType();
  if (getCodeGenerator().isPrimitive(type)) {
    args.add(getCodeGenerator().codeGenType(type).toString());
  }
  for (int i=0; i < actor.input.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args));
  }
  return processCode(fireCode.toString());
}
Program: 73408
Project: 73408
Buggy source:
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from VectorDisassembler.c, replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.VectorDisassembler actor=(ptolemy.actor.lib.VectorDisassembler)getComponent();
  StringBuffer fireCode=new StringBuffer();
  ArrayList<String> args=new ArrayList<String>();
  args.add(Integer.toString(actor.output.getWidth()));
  fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args));
  ArrayList<String> args2=new ArrayList<String>();
  Type type=actor.output.getType();
  if (getCodeGenerator().isPrimitive(type)) {
    args2.add(getCodeGenerator().codeGenType(type).toString());
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args2));
  }
 else {
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args2));
  }
  ArrayList<String> args3=new ArrayList<String>();
  args3.add(Integer.toString(0));
  for (int i=0; i < actor.output.numberOfSinks(); i++) {
    args3.set(0,Integer.toString(i));
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args3));
  }
  return processCode(fireCode.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. The method reads in <code>fireBlock</code> from VectorDisassembler.c, replaces macros with their values and returns the processed code block.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.VectorDisassembler actor=(ptolemy.actor.lib.VectorDisassembler)getComponent();
  StringBuffer fireCode=new StringBuffer();
  ArrayList<String> args=new ArrayList<String>();
  args.add(Integer.toString(actor.output.getWidth()));
  fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args));
  ArrayList<String> args2=new ArrayList<String>();
  Type type=actor.output.getType();
  if (getCodeGenerator().isPrimitive(type)) {
    args2.add(getCodeGenerator().codeGenType(type));
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args2));
  }
 else {
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args2));
  }
  ArrayList<String> args3=new ArrayList<String>();
  args3.add(Integer.toString(0));
  for (int i=0; i < actor.output.numberOfSinks(); i++) {
    args3.set(0,Integer.toString(i));
    fireCode.append(getTemplateParser().generateBlockCode("String_Node_Str",args3));
  }
  return processCode(fireCode.toString());
}
Program: 73409
Project: 73409
Buggy source:
/** 
 * Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
 * @return code The generated code.
 * @exception IllegalActionException If the adapter class for the modeldirector cannot be found.
 */
@Override public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer(super.generateVariableDeclaration());
  Iterator refinements=((CompositeActor)getComponent()).deepEntityList().iterator();
  while (refinements.hasNext()) {
    CompositeActor refinement=(CompositeActor)refinements.next();
    code.append(getCodeGenerator().comment("String_Node_Str" + refinement.getFullName()));
    NamedProgramCodeGeneratorAdapter refinementAdapter=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(refinement);
  }
  Iterator<?> ports=((ptolemy.kernel.Entity)getComponent()).portList().iterator();
  while (ports.hasNext()) {
    ptolemy.actor.TypedIOPort port=(ptolemy.actor.TypedIOPort)ports.next();
    code.append(getCodeGenerator().comment("String_Node_Str" + port.getFullName()));
    NamedProgramCodeGeneratorAdapter portAdapter=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(port);
    _portVariableDeclaration(code,port);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
 * @return code The generated code.
 * @exception IllegalActionException If the adapter class for the modeldirector cannot be found.
 */
@Override public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer(super.generateVariableDeclaration());
  Iterator refinements=((CompositeActor)getComponent()).deepEntityList().iterator();
  while (refinements.hasNext()) {
    CompositeActor refinement=(CompositeActor)refinements.next();
    code.append(getCodeGenerator().comment("String_Node_Str" + refinement.getFullName()));
  }
  Iterator<?> ports=((ptolemy.kernel.Entity)getComponent()).portList().iterator();
  while (ports.hasNext()) {
    ptolemy.actor.TypedIOPort port=(ptolemy.actor.TypedIOPort)ports.next();
    code.append(getCodeGenerator().comment("String_Node_Str" + port.getFullName()));
    _portVariableDeclaration(code,port);
  }
  return code.toString();
}
Program: 73410
Project: 73410
Buggy source:
/** 
 * Generate a string that represents the offset for a dynamically determined channel of a multiport.
 * @param port The referenced port.
 * @param isWrite Whether to generate the write or read offset.
 * @param channelString The string that will determine the channel.
 * @return The expression that represents the offset for a channel determineddynamically in the generated code.
 */
private String _generateChannelOffset(IOPort port,boolean isWrite,String channelString) throws IllegalActionException {
  if (channelString.equals("String_Node_Str")) {
    channelString="String_Node_Str";
  }
  String channelOffset=generatePortName((TypedIOPort)port) + ((isWrite) ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ channelString+ "String_Node_Str";
  return channelOffset;
}

Fixed version (ground truth):
/** 
 * Generate a string that represents the offset for a dynamically determined channel of a multiport.
 * @param port The referenced port.
 * @param isWrite Whether to generate the write or read offset.
 * @param channelString The string that will determine the channel.
 * @return The expression that represents the offset for a channel determineddynamically in the generated code.
 */
private String _generateChannelOffset(TypedIOPort port,boolean isWrite,String channelString) throws IllegalActionException {
  if (channelString.equals("String_Node_Str")) {
    channelString="String_Node_Str";
  }
  String channelOffset=generatePortName(port) + ((isWrite) ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ channelString+ "String_Node_Str";
  return channelOffset;
}
Program: 73416
Project: 73416
Buggy source:
/** 
 * Write the code to a directory named by the codeDirectory parameter, with a file name that is a sanitized version of the model name, and an extension that is the last package of the generatorPackage.
 * @param code The StringBuffer containing the code.
 * @return The name of the file that was written.
 * @exception IllegalActionException  If there is a problem readinga parameter, if there is a problem creating the codeDirectory directory or if there is a problem writing the code to a file.
 */
protected String _writeCode(StringBuffer code) throws IllegalActionException {
  String codeFileName=_getOutputFilename();
  boolean overwriteFile=((BooleanToken)overwriteFiles.getToken()).booleanValue();
  if (_executeCommands != null) {
    _executeCommands.stdout("String_Node_Str" + (codeFileName == null ? "String_Node_Str" : codeFileName) + "String_Node_Str"+ (codeDirectory == null ? "String_Node_Str" : codeDirectory.getBaseDirectory())+ "String_Node_Str"+ (code == null ? 0 : code.length())+ "String_Node_Str");
  }
  return _writeCodeFileName(code,codeFileName,overwriteFile,false);
}

Fixed version (ground truth):
/** 
 * Write the code to a directory named by the codeDirectory parameter, with a file name that is a sanitized version of the model name, and an extension that is the last package of the generatorPackage.
 * @param code The StringBuffer containing the code.
 * @return The name of the file that was written.
 * @exception IllegalActionException  If there is a problem readinga parameter, if there is a problem creating the codeDirectory directory or if there is a problem writing the code to a file.
 */
protected String _writeCode(StringBuffer code) throws IllegalActionException {
  String codeFileName=_getOutputFilename();
  boolean overwriteFile=((BooleanToken)overwriteFiles.getToken()).booleanValue();
  if (_executeCommands != null) {
    _executeCommands.stdout("String_Node_Str" + codeFileName + "String_Node_Str"+ (codeDirectory == null ? "String_Node_Str" : codeDirectory.getBaseDirectory())+ "String_Node_Str"+ (code == null ? 0 : code.length())+ "String_Node_Str");
  }
  return _writeCodeFileName(code,codeFileName,overwriteFile,false);
}
Program: 73418
Project: 73418
Buggy source:
/** 
 * Return the function output from the given input arguments. The output concept is a UnitConcept that is the result of multiplication or division of the two input UnitConcepts, or the top of the ontology lattice if there is no UnitConcept in the ontology that represents the product or quotient of the two input concepts.
 * @param argValues The 2 UnitConcept input arguments.
 * @return The output UnitConcept.
 * @throws IllegalActionException Thrown if there is a problem creatingthe output RecordConcept.
 */
protected Concept _evaluateFunction(List<Concept> argValues) throws IllegalActionException {
  Concept arg1=argValues.get(0);
  Concept arg2=argValues.get(1);
  if (arg1.equals(_bottomOfTheLattice) || arg2.equals(_bottomOfTheLattice)) {
    return _bottomOfTheLattice;
  }
 else   if (arg1.equals(_topOfTheLattice) || arg2.equals(_topOfTheLattice)) {
    return _topOfTheLattice;
  }
 else   if (arg1 instanceof FlatTokenInfiniteConcept && arg2 instanceof FlatTokenInfiniteConcept) {
    if (_isDivisionAndSecondArgumentIsZero((FlatTokenInfiniteConcept)arg2)) {
      return _bottomOfTheLattice;
    }
 else {
      return _getMathOperationResultConcept((FlatTokenInfiniteConcept)arg1,(FlatTokenInfiniteConcept)arg2);
    }
  }
 else {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + arg1 + "String_Node_Str"+ arg2+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Return the function output from the given input arguments. The output concept is a FlatTokenInfiniteConcept that is the result of the addition, subtraction, multiplication or division of the two input FlatTokenInfiniteConcepts.
 * @param argValues The 2 FlatTokenInfiniteConcept input arguments.
 * @return The output FlatTokenInfiniteConcept.
 * @throws IllegalActionException Thrown if there is a problem creatingthe output FlatTokenInfiniteConcept.
 */
protected Concept _evaluateFunction(List<Concept> argValues) throws IllegalActionException {
  Concept arg1=argValues.get(0);
  Concept arg2=argValues.get(1);
  if (arg1.equals(_bottomOfTheLattice) || arg2.equals(_bottomOfTheLattice)) {
    return _bottomOfTheLattice;
  }
 else   if (arg1.equals(_topOfTheLattice) || arg2.equals(_topOfTheLattice)) {
    return _topOfTheLattice;
  }
 else   if (arg1 instanceof FlatTokenInfiniteConcept && arg2 instanceof FlatTokenInfiniteConcept) {
    if (_isDivisionAndSecondArgumentIsZero((FlatTokenInfiniteConcept)arg2)) {
      return _bottomOfTheLattice;
    }
 else {
      return _getMathOperationResultConcept((FlatTokenInfiniteConcept)arg1,(FlatTokenInfiniteConcept)arg2);
    }
  }
 else {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + arg1 + "String_Node_Str"+ arg2+ "String_Node_Str");
  }
}
Program: 73419
Project: 73419
Buggy source:
/** 
 * Create a new ConstPropagationMathFunctions concept function.
 * @param ontology The domain and range unit system ontology for thisconcept function. 
 * @param mathOperation Indicates whether this concept function will performmultiplication or division for the unit system concepts.
 * @throws IllegalActionException Thrown if the concept function cannot be created.
 */
public ConstPropagationMathFunctions(Ontology ontology,String mathOperation) throws IllegalActionException {
  super("String_Node_Str" + mathOperation,2,ontology);
  _mathOperation=mathOperation;
  _constPropagationOntology=ontology;
  ConceptGraph ontologyGraph=_constPropagationOntology.getConceptGraph();
  if (ontologyGraph == null) {
    throw new IllegalActionException("String_Node_Str" + _constPropagationOntology + "String_Node_Str");
  }
 else {
    _topOfTheLattice=ontologyGraph.top();
    _bottomOfTheLattice=ontologyGraph.bottom();
  }
}

Fixed version (ground truth):
/** 
 * Create a new ConstPropagationMathFunctions concept function.
 * @param ontology The domain and range unit system ontology for thisconcept function. 
 * @param mathOperation Indicates whether this concept function will performaddition, subtraction, multiplication or division for the FlatTokenInfiniteConcepts.
 * @throws IllegalActionException Thrown if the concept function cannot be created.
 */
public ConstPropagationMathFunctions(Ontology ontology,String mathOperation) throws IllegalActionException {
  super("String_Node_Str" + mathOperation,2,ontology);
  _mathOperation=mathOperation;
  _constPropagationOntology=ontology;
  ConceptGraph ontologyGraph=_constPropagationOntology.getConceptGraph();
  if (ontologyGraph == null) {
    throw new IllegalActionException("String_Node_Str" + _constPropagationOntology + "String_Node_Str");
  }
 else {
    _topOfTheLattice=ontologyGraph.top();
    _bottomOfTheLattice=ontologyGraph.bottom();
  }
}
Program: 73420
Project: 73420
Buggy source:
/** 
 * Return the function output from the given input arguments. The output concept is a UnitConcept that is the result of multiplication or division of the two input UnitConcepts, or the top of the ontology lattice if there is no UnitConcept in the ontology that represents the product or quotient of the two input concepts.
 * @param argValues The 2 UnitConcept input arguments.
 * @return The output UnitConcept.
 * @throws IllegalActionException Thrown if there is a problem creatingthe output RecordConcept.
 */
protected Concept _evaluateFunction(List<Concept> argValues) throws IllegalActionException {
  Concept arg1=argValues.get(0);
  Concept arg2=argValues.get(1);
  if (arg1.equals(_bottomOfTheLattice) || arg2.equals(_bottomOfTheLattice)) {
    return _bottomOfTheLattice;
  }
 else   if (arg1.equals(_topOfTheLattice) || arg2.equals(_topOfTheLattice)) {
    return _topOfTheLattice;
  }
 else {
    if (_isDivisionAndSecondArgumentIsZero(arg2)) {
      return _bottomOfTheLattice;
    }
 else {
      return _getMathOperationResultConcept(arg1,arg2);
    }
  }
}

Fixed version (ground truth):
/** 
 * Return the function output from the given input arguments. The output concept is a FlatScalarTokenInfiniteConcept that is the result of the addition, subtraction, multiplication or division of the two input FlatScalarTokenInfiniteConcepts. If the operation results in a value of zero, return the finite Zero concept in the constPropagationAbsInt ontology.
 * @param argValues The 2 FlatScalarTokenInfiniteConcept input arguments.
 * @return The output FlatScalarTokenInfiniteConcept.
 * @throws IllegalActionException Thrown if there is a problem creatingthe output FlatScalarTokenInfiniteConcept.
 */
protected Concept _evaluateFunction(List<Concept> argValues) throws IllegalActionException {
  Concept arg1=argValues.get(0);
  Concept arg2=argValues.get(1);
  if (arg1.equals(_bottomOfTheLattice) || arg2.equals(_bottomOfTheLattice)) {
    return _bottomOfTheLattice;
  }
 else   if (arg1.equals(_topOfTheLattice) || arg2.equals(_topOfTheLattice)) {
    return _topOfTheLattice;
  }
 else {
    if (_isDivisionAndSecondArgumentIsZero(arg2)) {
      return _bottomOfTheLattice;
    }
 else {
      return _getMathOperationResultConcept(arg1,arg2);
    }
  }
}
Program: 73421
Project: 73421
Buggy source:
/** 
 * Create a new ConstPropagationAbsIntMathFunctions concept function.
 * @param ontology The domain and range unit system ontology for thisconcept function. 
 * @param mathOperation Indicates whether this concept function will performmultiplication or division for the unit system concepts.
 * @throws IllegalActionException Thrown if the concept function cannot be created.
 */
public ConstPropagationAbsIntMathFunctions(Ontology ontology,String mathOperation) throws IllegalActionException {
  super("String_Node_Str" + mathOperation,2,ontology);
  _mathOperation=mathOperation;
  _constPropagationAbsIntOntology=ontology;
  _positiveRepresentative=(FlatScalarTokenRepresentativeConcept)_constPropagationAbsIntOntology.getConceptByString("String_Node_Str");
  _negativeRepresentative=(FlatScalarTokenRepresentativeConcept)_constPropagationAbsIntOntology.getConceptByString("String_Node_Str");
  _zeroConcept=_constPropagationAbsIntOntology.getConceptByString("String_Node_Str");
  ConceptGraph ontologyGraph=_constPropagationAbsIntOntology.getConceptGraph();
  if (ontologyGraph == null) {
    throw new IllegalActionException("String_Node_Str" + _constPropagationAbsIntOntology + "String_Node_Str");
  }
 else {
    _topOfTheLattice=ontologyGraph.top();
    _bottomOfTheLattice=ontologyGraph.bottom();
  }
}

Fixed version (ground truth):
/** 
 * Create a new ConstPropagationAbsIntMathFunctions concept function.
 * @param ontology The domain and range unit system ontology for thisconcept function. 
 * @param mathOperation Indicates whether this concept function will performaddition, subtraction, multiplication or division for the FlatScalarTokenInfiniteConcepts.
 * @throws IllegalActionException Thrown if the concept function cannot be created.
 */
public ConstPropagationAbsIntMathFunctions(Ontology ontology,String mathOperation) throws IllegalActionException {
  super("String_Node_Str" + mathOperation,2,ontology);
  _mathOperation=mathOperation;
  _constPropagationAbsIntOntology=ontology;
  _positiveRepresentative=(FlatScalarTokenRepresentativeConcept)_constPropagationAbsIntOntology.getConceptByString("String_Node_Str");
  _negativeRepresentative=(FlatScalarTokenRepresentativeConcept)_constPropagationAbsIntOntology.getConceptByString("String_Node_Str");
  _zeroConcept=_constPropagationAbsIntOntology.getConceptByString("String_Node_Str");
  ConceptGraph ontologyGraph=_constPropagationAbsIntOntology.getConceptGraph();
  if (ontologyGraph == null) {
    throw new IllegalActionException("String_Node_Str" + _constPropagationAbsIntOntology + "String_Node_Str");
  }
 else {
    _topOfTheLattice=ontologyGraph.top();
    _bottomOfTheLattice=ontologyGraph.bottom();
  }
}
Program: 73424
Project: 73424
Buggy source:
private String _momlAnnotate(NamedObj entity,String color,String expression){
  String colorProperty=null;
  StringAttribute currentColor=(StringAttribute)(entity.getAttribute("String_Node_Str"));
  if ((currentColor != null) && (color == null)) {
    colorProperty="String_Node_Str";
  }
 else   if (color != null) {
    colorProperty="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + color + "String_Node_Str";
  }
  return "String_Node_Str" + entity.getElementName() + "String_Node_Str"+ entity.getName()+ "String_Node_Str"+ entity.getClassName()+ "String_Node_Str"+ colorProperty+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ expression+ "String_Node_Str"+ entity.getElementName()+ "String_Node_Str";
}

Fixed version (ground truth):
private String _momlAnnotate(NamedObj entity,String color,String expression){
  String colorProperty=null;
  ColorAttribute currentColor=(ColorAttribute)(entity.getAttribute("String_Node_Str"));
  if ((currentColor != null) && (color == null)) {
    colorProperty="String_Node_Str";
  }
 else   if (color != null) {
    colorProperty="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + color + "String_Node_Str";
  }
  return "String_Node_Str" + entity.getElementName() + "String_Node_Str"+ entity.getName()+ "String_Node_Str"+ entity.getClassName()+ "String_Node_Str"+ colorProperty+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ expression+ "String_Node_Str"+ entity.getElementName()+ "String_Node_Str";
}
Program: 73427
Project: 73427
Buggy source:
/** 
 * Clone this actor into the specified workspace. The new actor is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container.  A container must be set before much can be done with this actor.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return A new Bus.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  CrossbarSwitch newObject=(CrossbarSwitch)super.clone(workspace);
  newObject._actorPorts=new HashMap();
  newObject._receivers=new Hashtable();
  newObject._nextFireTime=null;
  newObject._inputTokens=new HashMap();
  newObject._outputTokens=new HashMap();
  newObject._switchFabricQueue=new HashMap();
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone this actor into the specified workspace. The new actor is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container.  A container must be set before much can be done with this actor.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return A new Bus.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  CrossbarSwitch newObject=(CrossbarSwitch)super.clone(workspace);
  newObject._actorPorts=new HashMap();
  newObject._receivers=new Hashtable();
  newObject._nextFireTime=null;
  newObject._inputTokens=new HashMap();
  newObject._outputTokens=new HashMap();
  newObject._switchFabricQueue=new HashMap();
  newObject._waitingOnSwitchFabricQueue=(HashMap)newObject._waitingOnSwitchFabricQueue;
  return newObject;
}
Program: 73429
Project: 73429
Buggy source:
/** 
 * Create a new BaseUnitConcept, belonging to the given ontology.
 * @param ontology The ontology to which this concept belongs.
 * @param representative The finite concept that represents the physicaldimension for the set infinite concepts that represent units for this dimension in the ontology lattice.
 * @param unitInfo The record token value that has the name and scalefactor information for this unit.
 * @throws NameDuplicationException Should never be thrown.
 * @throws IllegalActionException If the base class throws it.
 */
protected BaseUnitConcept(Ontology ontology,BaseDimensionRepresentativeConcept representative,RecordToken unitInfo) throws IllegalActionException, NameDuplicationException {
  super(ontology,representative,unitInfo);
  Token unitFactor=unitInfo.get(UnitConversionInfo.unitFactorLabel);
  if (unitFactor instanceof ScalarToken) {
    _unitFactor=(ScalarToken)unitFactor;
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + unitFactor);
  }
  Token unitOffset=unitInfo.get(UnitConversionInfo.unitOffsetLabel);
  if (unitFactor instanceof ScalarToken) {
    _unitOffset=(ScalarToken)unitOffset;
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + unitOffset);
  }
}

Fixed version (ground truth):
/** 
 * Create a new BaseUnitConcept, belonging to the given ontology.
 * @param ontology The ontology to which this concept belongs.
 * @param representative The finite concept that represents the physicaldimension for the set infinite concepts that represent units for this dimension in the ontology lattice.
 * @param unitInfo The record token value that has the name and scalefactor information for this unit.
 * @throws NameDuplicationException Should never be thrown.
 * @throws IllegalActionException If the base class throws it.
 */
protected BaseUnitConcept(Ontology ontology,BaseDimensionRepresentativeConcept representative,RecordToken unitInfo) throws IllegalActionException, NameDuplicationException {
  super(ontology,representative,unitInfo);
  Token unitFactor=unitInfo.get(UnitConversionInfo.unitFactorLabel);
  if (unitFactor instanceof ScalarToken) {
    _unitFactor=(ScalarToken)unitFactor;
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + unitFactor);
  }
  Token unitOffset=unitInfo.get(UnitConversionInfo.unitOffsetLabel);
  if (unitOffset instanceof ScalarToken) {
    _unitOffset=(ScalarToken)unitOffset;
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + unitOffset);
  }
}
Program: 73430
Project: 73430
Buggy source:
/** 
 * Get the integer exponent value from a dimensionRecord record token.
 * @param dimensionRecord The record token that specifies the dimensionand its exponent.
 * @return The integer exponent for the dimension contained in the record token.
 * @throws IllegalActionException Thrown if the dimension record tokenor the exponent value in the record token is zero or invalid.
 */
private Integer _getExponentValue(RecordToken dimensionRecord) throws IllegalActionException {
  Token exponentToken=dimensionRecord.get(_exponentLabel);
  if (exponentToken instanceof IntToken) {
    int exponentValue=(((IntToken)exponentToken).intValue());
    if (exponentValue == 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
 else {
      return new Integer(exponentValue);
    }
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + dimensionRecord);
  }
}

Fixed version (ground truth):
/** 
 * Get the integer exponent value from a dimensionRecord record token.
 * @param dimensionRecord The record token that specifies the dimensionand its exponent.
 * @return The integer exponent for the dimension contained in the record token.
 * @throws IllegalActionException Thrown if the dimension record tokenor the exponent value in the record token is zero or invalid.
 */
private Integer _getExponentValue(RecordToken dimensionRecord) throws IllegalActionException {
  Token exponentToken=dimensionRecord.get(_exponentLabel);
  if (exponentToken instanceof IntToken) {
    int exponentValue=(((IntToken)exponentToken).intValue());
    if (exponentValue == 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
 else {
      return Integer.valueOf(exponentValue);
    }
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + dimensionRecord);
  }
}
Program: 73431
Project: 73431
Buggy source:
/** 
 * Increment the base dimension exponent by the given exponent value.
 * @param baseDimensionsMap The map of base dimensions being updated.
 * @param dimension The specified base dimension to be incremented.
 * @param exponentValue The exponent value by which the base dimensionexponent will be incremented.
 * @throws IllegalActionException Thrown if the base dimension concept isinvalid.
 */
private static void _incrementBaseDimensionExponent(Map<BaseDimensionRepresentativeConcept,Integer> baseDimensionsMap,BaseDimensionRepresentativeConcept dimension,int exponentValue) throws IllegalActionException {
  Integer currentExponent=baseDimensionsMap.get(dimension);
  if (currentExponent == null && exponentValue != 0) {
    baseDimensionsMap.put(dimension,new Integer(exponentValue));
  }
 else {
    int newExponentValue=currentExponent.intValue() + exponentValue;
    if (newExponentValue != 0) {
      baseDimensionsMap.put(dimension,new Integer(newExponentValue));
    }
 else {
      baseDimensionsMap.remove(dimension);
    }
  }
}

Fixed version (ground truth):
/** 
 * Increment the base dimension exponent by the given exponent value.
 * @param baseDimensionsMap The map of base dimensions being updated.
 * @param dimension The specified base dimension to be incremented.
 * @param exponentValue The exponent value by which the base dimensionexponent will be incremented.
 * @throws IllegalActionException Thrown if the base dimension concept isinvalid.
 */
private static void _incrementBaseDimensionExponent(Map<BaseDimensionRepresentativeConcept,Integer> baseDimensionsMap,BaseDimensionRepresentativeConcept dimension,int exponentValue) throws IllegalActionException {
  Integer currentExponent=baseDimensionsMap.get(dimension);
  if (currentExponent == null) {
    if (exponentValue != 0) {
      baseDimensionsMap.put(dimension,Integer.valueOf(exponentValue));
    }
  }
 else {
    int newExponentValue=currentExponent.intValue() + exponentValue;
    if (newExponentValue != 0) {
      baseDimensionsMap.put(dimension,Integer.valueOf(newExponentValue));
    }
 else {
      baseDimensionsMap.remove(dimension);
    }
  }
}