nus-yam/ex-repair huggingface dataset:
Program: 74668
Project: 74668
Buggy source:
@SuppressWarnings("String_Node_Str") public boolean remove(Object o){
  Entry entry=findEntry((E)o);
  if (entry == null) {
    return false;
  }
 else {
    if (entry == _head) {
      _head=entry._next;
    }
    if (entry == _tail) {
      _tail=entry._previous;
    }
    if (entry._previous != null) {
      entry._previous._next=entry._next;
    }
    if (entry._next != null) {
      entry._next._previous=entry._previous;
    }
    _size--;
    return true;
  }
}

Fixed version (ground truth):
public void remove(){
  if (_previous != null) {
    _previous._next=_next;
  }
 else {
    _head=_next;
  }
  if (_next != null) {
    _next._previous=_previous;
  }
 else {
    _tail=_previous;
  }
  _size--;
}
Program: 74669
Project: 74669
Buggy source:
/** 
 * Update the state of the actor by moving to the next value in the <i>values</i> array.
 * @exception IllegalActionException If there is no director.
 */
public boolean postfire() throws IllegalActionException {
  if (_outputProduced) {
    _outputProduced=false;
    _currentIndex+=1;
    ArrayToken valuesArray=(ArrayToken)values.getToken();
    if (_currentIndex >= valuesArray.length()) {
      boolean repeatValue=((BooleanToken)repeat.getToken()).booleanValue();
      if (repeatValue) {
        _currentIndex=0;
      }
 else {
        _currentIndex=valuesArray.length();
      }
    }
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Update the state of the actor by moving to the next value in the <i>values</i> array.
 * @exception IllegalActionException If there is no director.
 */
public boolean postfire() throws IllegalActionException {
  if (_outputProduced) {
    _outputProduced=false;
    _currentIndex+=1;
    ArrayToken valuesArray=(ArrayToken)values.getToken();
    if (_currentIndex >= valuesArray.length()) {
      boolean repeatValue=((BooleanToken)repeat.getToken()).booleanValue();
      if (repeatValue) {
        _currentIndex=0;
      }
 else {
        _currentIndex=valuesArray.length() - 1;
      }
    }
  }
  return super.postfire();
}
Program: 74670
Project: 74670
Buggy source:
/** 
 * Generate type convert variable declarations.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.  
 */
protected String _generateTypeConvertVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator channels=_getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    code.append("String_Node_Str");
    code.append(targetType(((TypedIOPort)channel.port).getType()));
    code.append("String_Node_Str" + _getTypeConvertReference(channel));
    int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
    if (bufferSize > 1) {
      code.append("String_Node_Str" + bufferSize + "String_Node_Str");
    }
    code.append("String_Node_Str" + _eol);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate type convert variable declarations.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.  
 */
protected String _generateTypeConvertVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator channels=_getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      code.append("String_Node_Str" + _getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}
Program: 74673
Project: 74673
Buggy source:
/** 
 * Find out each output port that needs to be converted for the actor associated with this helper. Then, mark these ports along with the sink ports (connection). 
 * @exception IllegalActionException Not thrown in this base class.
 */
public void analyzeTypeConvert() throws IllegalActionException {
  _portConversions.clear();
  Actor actor=(Actor)_component;
  ArrayList sourcePorts=new ArrayList();
  sourcePorts.addAll(actor.outputPortList());
  if (actor instanceof CompositeActor) {
    sourcePorts.addAll(actor.inputPortList());
  }
  Iterator ports=sourcePorts.iterator();
  for (int i=0; ports.hasNext(); i++) {
    TypedIOPort sourcePort=(TypedIOPort)ports.next();
    for (int j=0; j < sourcePort.getWidth(); j++) {
      Iterator sinks=getSinkChannels(sourcePort,j).iterator();
      while (sinks.hasNext()) {
        Channel sink=(Channel)sinks.next();
        TypedIOPort sinkPort=(TypedIOPort)sink.port;
        if (!targetType(sourcePort.getType()).equals(targetType(sinkPort.getType()))) {
          _markTypeConvert(new Channel(sourcePort,j),sink);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Find out each output port that needs to be converted for the actor associated with this helper. Then, mark these ports along with the sink ports (connection). 
 * @exception IllegalActionException Not thrown in this base class.
 */
public void analyzeTypeConvert() throws IllegalActionException {
  _portConversions.clear();
  Actor actor=(Actor)_component;
  ArrayList sourcePorts=new ArrayList();
  sourcePorts.addAll(actor.outputPortList());
  if (actor instanceof CompositeActor) {
    sourcePorts.addAll(actor.inputPortList());
  }
  Iterator ports=sourcePorts.iterator();
  for (int i=0; ports.hasNext(); i++) {
    TypedIOPort sourcePort=(TypedIOPort)ports.next();
    for (int j=0; j < sourcePort.getWidth(); j++) {
      Iterator sinks=getSinkChannels(sourcePort,j).iterator();
      while (sinks.hasNext()) {
        Channel sink=(Channel)sinks.next();
        TypedIOPort sinkPort=(TypedIOPort)sink.port;
        if (!sourcePort.getType().equals(sinkPort.getType())) {
          _markTypeConvert(new Channel(sourcePort,j),sink);
        }
      }
    }
  }
}
Program: 74675
Project: 74675
Buggy source:
/** 
 * Get the size of a parameter. The size of a parameter is the length of its array if the parameter's type is array, and 1 otherwise.
 * @param name The name of the parameter.
 * @return The size of a parameter.
 * @exception IllegalActionException If no port or parameter ofthe given name is found.
 */
public int getSize(String name) throws IllegalActionException {
  Attribute attribute=_component.getAttribute(name);
  if (attribute != null) {
    if (attribute instanceof Variable) {
      Token token=((Variable)attribute).getToken();
      if (token instanceof ArrayToken) {
        return ((ArrayToken)token).length();
      }
      return 1;
    }
  }
 else {
    IOPort port=getPort(name);
    if (port != null) {
      return port.getWidth();
    }
  }
  throw new IllegalActionException(_component,"String_Node_Str" + name);
}

Fixed version (ground truth):
/** 
 * Get the size of a parameter. The size of a parameter is the length of its array if the parameter's type is array, and 1 otherwise.
 * @param name The name of the parameter.
 * @return The expression that represents the size of a parameter or port.
 * @exception IllegalActionException If no port or parameter ofthe given name is found.
 */
public String getSize(String name) throws IllegalActionException {
  Attribute attribute=_component.getAttribute(name);
  if (attribute != null) {
    if (attribute instanceof Variable) {
      Token token=((Variable)attribute).getToken();
      if (token instanceof ArrayToken) {
        return String.valueOf(((ArrayToken)token).length());
      }
      return "String_Node_Str";
    }
  }
 else {
    TypedIOPort port=getPort(name);
    if (port != null) {
      if (port.isMultiport()) {
        return String.valueOf(port.getWidth());
      }
 else {
        Type type=port.getType();
        if (type instanceof ArrayType) {
          if (((ArrayType)type).hasKnownLength()) {
            return String.valueOf(((ArrayType)type).length());
          }
 else {
            return getReference(name) + "String_Node_Str";
          }
        }
      }
    }
  }
  throw new IllegalActionException(_component,"String_Node_Str" + name);
}
Program: 74676
Project: 74676
Buggy source:
/** 
 * Return a copy of the types.
 * @return a copy of the hash table tha name types.
 */
public static TreeMap types(){
  return new TreeMap(_types);
}

Fixed version (ground truth):
/** 
 * Return a copy of the types.
 * @return a copy of the hash table tha name types.
 */
public static TreeMap types(){
  return new TreeMap((SortedMap)_types);
}
Program: 74679
Project: 74679
Buggy source:
public boolean hasNext(){
  while (!_subiterator.hasNext()) {
    _subiterator=iterator(_iterator.next());
  }
  return (_subiterator != null);
}

Fixed version (ground truth):
public boolean hasNext(){
  while (_subiterator != null && !_subiterator.hasNext()) {
    _subiterator=iterator(_iterator.next());
  }
  return (_subiterator != null);
}
Program: 74681
Project: 74681
Buggy source:
/** 
 * Override method in CodeFileGenerator and include directives for "interface header" files instead of .h files.
 */
protected String _generateIncludeDirectives(){
  StringBuffer headerCode=new StringBuffer();
  Iterator includeFiles=_context.getIncludeFiles();
  if (includeFiles.hasNext()) {
    headerCode.append(_comment("String_Node_Str"));
  }
  while (includeFiles.hasNext()) {
    if (Context.getSingleClassMode()) {
      headerCode.append("String_Node_Str");
    }
    headerCode.append("String_Node_Str");
    String fileName=(String)includeFiles.next();
    fileName=CNames.sanitize(fileName.substring(0,fileName.length() - 3)) + StubFileGenerator.stubFileNameSuffix() + "String_Node_Str";
    headerCode.append(fileName);
    if (Context.getSingleClassMode()) {
      headerCode.append("String_Node_Str");
    }
    headerCode.append("String_Node_Str");
  }
  Iterator requiredTypes=_getRequiredIncludeFiles();
  if (requiredTypes.hasNext()) {
    headerCode.append("String_Node_Str" + _comment("String_Node_Str"));
  }
  while (requiredTypes.hasNext()) {
    if (Context.getSingleClassMode()) {
      headerCode.append("String_Node_Str");
    }
    headerCode.append("String_Node_Str");
    String fileName=new String((String)requiredTypes.next());
    fileName=CNames.sanitize(fileName.substring(0,fileName.length() - 2)) + StubFileGenerator.stubFileNameSuffix() + "String_Node_Str";
    headerCode.append(fileName);
    if (Context.getSingleClassMode()) {
      headerCode.append("String_Node_Str");
    }
    headerCode.append("String_Node_Str");
  }
  return headerCode.toString();
}

Fixed version (ground truth):
/** 
 * Override method in CodeFileGenerator and include directives for "interface header" files instead of .h files.
 */
protected String _generateIncludeDirectives(){
}
Program: 74682
Project: 74682
Buggy source:
/** 
 * Perform resource allocation for this actor. Specifically, open the serial port (setting the baud rate and other communication settings) and then activate the serial port's event listening resource, directing events to the serialEvent() method of this actor.
 * @exception IllegalActionException Not thrown in this base class.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  _directorFiredAtAlready=false;
  try {
    String serialPortNameValue=serialPortName.stringValue();
    CommPortIdentifier portID=CommPortIdentifier.getPortIdentifier(serialPortNameValue);
    _serialPort=(SerialPort)portID.open("String_Node_Str",2000);
    int bits_per_second=((IntToken)(baudRate.getToken())).intValue();
    _serialPort.setSerialPortParams(bits_per_second,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
    _serialPort.addEventListener(this);
    _serialPort.notifyOnDataAvailable(true);
    _serialPort.notifyOnDSR(true);
    _serialPort.notifyOnCTS(true);
    _serialPort.notifyOnCarrierDetect(true);
    _serialPort.notifyOnRingIndicator(true);
    _stopFireRequested=false;
  }
 catch (  Exception ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Perform resource allocation for this actor. Specifically, open the serial port (setting the baud rate and other communication settings) and then activate the serial port's event listening resource, directing events to the serialEvent() method of this actor.
 * @exception IllegalActionException Not thrown in this base class.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  _directorFiredAtAlready=false;
  try {
    String serialPortNameValue=serialPortName.stringValue();
    CommPortIdentifier portID=CommPortIdentifier.getPortIdentifier(serialPortNameValue);
    if (_serialPort == null || !toplevel().getName().equals(portID.getCurrentOwner())) {
      _serialPort=(SerialPort)portID.open(toplevel().getName(),2000);
      int bits_per_second=((IntToken)(baudRate.getToken())).intValue();
      _serialPort.setSerialPortParams(bits_per_second,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
      _serialPort.addEventListener(this);
      _serialPort.notifyOnDataAvailable(true);
      _serialPort.notifyOnDSR(true);
      _serialPort.notifyOnCTS(true);
      _serialPort.notifyOnCarrierDetect(true);
      _serialPort.notifyOnRingIndicator(true);
    }
    _stopFireRequested=false;
  }
 catch (  Exception ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
}
Program: 74684
Project: 74684
Buggy source:
/** 
 * Generate fire code. Read the <code>fireBlock</code> from Stop.c, replace macros with their values and return the processed code string.
 * @return The processed code string.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generateFireCode() throws IllegalActionException {
  super.generateFireCode();
  ptolemy.actor.lib.Synchronizer actor=(ptolemy.actor.lib.Synchronizer)getComponent();
  ArrayList args=new ArrayList();
  args.add(Integer.valueOf(0));
  for (int i=0; i < actor.input.getWidth(); i++) {
    args.set(0,Integer.valueOf(i));
    _codeStream.appendCodeBlock("String_Node_Str",args);
  }
  return processCode(_codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. Read the <code>fireBlock</code> from Stop.c, replace macros with their values and return the processed code string.
 * @return The processed code string.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generateFireCode() throws IllegalActionException {
  super.generateFireCode();
  ptolemy.actor.lib.Stop actor=(ptolemy.actor.lib.Stop)getComponent();
  ArrayList args=new ArrayList();
  args.add(Integer.valueOf(0));
  for (int i=0; i < actor.input.getWidth(); i++) {
    args.set(0,Integer.valueOf(i));
    _codeStream.appendCodeBlock("String_Node_Str",args);
  }
  return processCode(_codeStream.toString());
}
Program: 74687
Project: 74687
Buggy source:
/** 
 * Multiply all of the repetition rates by the given vectorizationFactor.  This factor is normally the integer value of the vectorizationFactor parameter of the director.  Also multiply the production and consumption rates of the external ports of the model by the same amount. Also, convert the two maps in the arguments to contain Integers rather than Fractions.
 * @param vectorizationFactor An integer scaling factor to multiplythe firing vector by.
 * @param entityToFiringsPerIteration Map representing the firing vector.
 * @param externalRates Map representing production rates ofexternal ports.
 */
protected void _vectorizeFirings(int vectorizationFactor,Map entityToFiringsPerIteration,Map externalRates){
  if (_debugging && VERBOSE) {
    _debug("String_Node_Str" + vectorizationFactor);
  }
  Fraction lcmFraction=new Fraction(vectorizationFactor);
  for (Iterator actors=entityToFiringsPerIteration.keySet().iterator(); actors.hasNext(); ) {
    Object actor=actors.next();
    Fraction repetitions=(Fraction)entityToFiringsPerIteration.get(actor);
    repetitions=repetitions.multiply(lcmFraction);
    entityToFiringsPerIteration.put(actor,new Integer(repetitions.getNumerator()));
  }
  for (Iterator ports=externalRates.keySet().iterator(); ports.hasNext(); ) {
    Object port=ports.next();
    Fraction rate=(Fraction)externalRates.get(port);
    rate=rate.multiply(lcmFraction);
    externalRates.put(port,new Integer(rate.getNumerator()));
  }
}

Fixed version (ground truth):
/** 
 * Multiply all of the repetition rates by the given vectorizationFactor.  This factor is normally the integer value of the vectorizationFactor parameter of the director.  Also multiply the production and consumption rates of the external ports of the model by the same amount. Also, convert the two maps in the arguments to contain Integers rather than Fractions.
 * @param vectorizationFactor An integer scaling factor to multiplythe firing vector by.
 * @param entityToFiringsPerIteration Map representing the firing vector.
 * @param externalRates Map representing production rates ofexternal ports.
 */
protected void _vectorizeFirings(int vectorizationFactor,Map entityToFiringsPerIteration,Map externalRates){
  if (_debugging && VERBOSE) {
    _debug("String_Node_Str" + vectorizationFactor);
  }
  Fraction lcmFraction=new Fraction(vectorizationFactor);
  for (Iterator actors=entityToFiringsPerIteration.keySet().iterator(); actors.hasNext(); ) {
    Object actor=actors.next();
    Fraction repetitions=(Fraction)entityToFiringsPerIteration.get(actor);
    repetitions=repetitions.multiply(lcmFraction);
    entityToFiringsPerIteration.put(actor,new Integer(repetitions.getNumerator()));
  }
  for (Iterator portMapEntries=externalRates.entrySet().iterator(); portMapEntries.hasNext(); ) {
    Map.Entry ports=(Map.Entry)portMapEntries.next();
    Object port=ports.getKey();
    Fraction rate=(Fraction)ports.getValue();
    rate=rate.multiply(lcmFraction);
    ports.setValue(new Integer(rate.getNumerator()));
  }
}
Program: 74689
Project: 74689
Buggy source:
/** 
 * If the attribute is <i>seed</i> then create the base random number generator.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == seed) {
    long seedValue=((LongToken)(seed.getToken())).longValue();
    if (seedValue != _generatorSeed) {
      _createGenerator();
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If the attribute is <i>seed</i> then create the base random number generator.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == seed) {
    long seedValue=((LongToken)(seed.getToken())).longValue();
    if (seedValue != _generatorSeed) {
      _needNewGenerator=true;
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 74690
Project: 74690
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  RandomSource newObject=(RandomSource)(super.clone(workspace));
  try {
    newObject._createGenerator();
  }
 catch (  IllegalActionException e) {
    throw new CloneNotSupportedException("String_Node_Str");
  }
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  RandomSource newObject=(RandomSource)(super.clone(workspace));
  newObject._needNewGenerator=true;
  return newObject;
}
Program: 74691
Project: 74691
Buggy source:
/** 
 * Generate a new random number if this is the first firing of the iteration.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (_needNew) {
    _generateRandomNumber();
    _needNew=false;
  }
}

Fixed version (ground truth):
/** 
 * Generate a new random number if this is the first firing of the iteration.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (_needNewGenerator) {
    _createGenerator();
  }
  if (_needNew) {
    _generateRandomNumber();
    _needNew=false;
  }
}
Program: 74692
Project: 74692
Buggy source:
/** 
 * Create the random number generator using current parameter values. 
 */
protected void _createGenerator() throws IllegalActionException {
  long seedValue=((LongToken)(seed.getToken())).longValue();
  _generatorSeed=seedValue;
  if (seedValue == 0L) {
    seedValue=System.currentTimeMillis() + hashCode();
  }
 else {
    seedValue=seedValue + getFullName().hashCode();
  }
  _random=new Random(seedValue);
  _needNew=true;
}

Fixed version (ground truth):
/** 
 * Create the random number generator using current parameter values. 
 */
protected void _createGenerator() throws IllegalActionException {
  long seedValue=((LongToken)(seed.getToken())).longValue();
  _generatorSeed=seedValue;
  if (seedValue == 0L) {
    seedValue=System.currentTimeMillis() + hashCode();
  }
 else {
    seedValue=seedValue + getFullName().hashCode();
  }
  _random=new Random(seedValue);
  _needNewGenerator=false;
  _needNew=true;
}
Program: 74693
Project: 74693
Buggy source:
/** 
 * If the attribute is <i>generatorClass</i> then create the base random number generator.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == generatorClass) {
    String generatorClassValue=((StringToken)generatorClass.getToken()).stringValue();
    if ((generatorClassValue != null) && !generatorClassValue.equals(_generatorClassName)) {
      _createGenerator();
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If the attribute is <i>generatorClass</i> then create the base random number generator.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == generatorClass) {
    String generatorClassValue=((StringToken)generatorClass.getToken()).stringValue();
    if ((generatorClassValue != null) && !generatorClassValue.equals(_generatorClassName)) {
      _needNewGenerator=true;
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 74694
Project: 74694
Buggy source:
/** 
 * Create the random number generator using current parameter values. 
 */
protected void _createGenerator() throws IllegalActionException {
  long seedValue=((LongToken)(seed.getToken())).longValue();
  _generatorSeed=seedValue;
  if (seedValue == 0L) {
    seedValue=System.currentTimeMillis() + hashCode();
  }
 else {
    seedValue=seedValue + getFullName().hashCode();
  }
  StringToken generatorToken=((StringToken)generatorClass.getToken());
  String generatorClassValue=null;
  if (generatorToken != null) {
    generatorClassValue=generatorToken.stringValue();
  }
  _generatorClassName=generatorClassValue;
  if ((generatorClassValue == null) || generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new DRand((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new MersenneTwister((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new Ranecu((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new Ranlux((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new Ranmar((int)seedValue);
  }
  _random=new Random();
  _createdNewRandomNumberGenerator();
}

Fixed version (ground truth):
/** 
 * Create the random number generator using current parameter values. 
 */
protected void _createGenerator() throws IllegalActionException {
  long seedValue=((LongToken)(seed.getToken())).longValue();
  _generatorSeed=seedValue;
  if (seedValue == 0L) {
    seedValue=System.currentTimeMillis() + hashCode();
  }
 else {
    seedValue=seedValue + getFullName().hashCode();
  }
  StringToken generatorToken=((StringToken)generatorClass.getToken());
  String generatorClassValue=null;
  if (generatorToken != null) {
    generatorClassValue=generatorToken.stringValue();
  }
  _generatorClassName=generatorClassValue;
  if ((generatorClassValue == null) || generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new DRand((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new MersenneTwister((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new Ranecu((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new Ranlux((int)seedValue);
  }
 else   if (generatorClassValue.equals("String_Node_Str")) {
    _randomNumberGenerator=new Ranmar((int)seedValue);
  }
  _random=new Random();
  _needNewGenerator=false;
  _needNew=true;
  _createdNewRandomNumberGenerator();
}
Program: 74695
Project: 74695
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then set the filename public member.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  XSLTransformer newObject=(XSLTransformer)super.clone(workspace);
  newObject.input.setTypeEquals(BaseType.XMLTOKEN);
  newObject.output.setTypeEquals(BaseType.STRING);
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then set the filename public member.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  XSLTransformer newObject=(XSLTransformer)super.clone(workspace);
  newObject.input.setTypeEquals(BaseType.XMLTOKEN);
  newObject.output.setTypeEquals(BaseType.STRING);
  newObject.styleSheetParameterPort.setTypeAtMost(new RecordType(new String[0],new Type[0]));
  return newObject;
}
Program: 74696
Project: 74696
Buggy source:
/** 
 * Roll back to committed state. This will roll back any actors that were fired in the current iteration.
 */
public void rollBackToCommittedState(){
  Iterator actors=_actorsFired.iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    if (actor instanceof ContinuousStatefulComponent) {
      ((ContinuousStatefulComponent)actor).rollBackToCommittedState();
    }
 else     if (actor instanceof CompositeActor) {
      Iterator insideActors=((CompositeActor)actor).deepEntityList().iterator();
      while (insideActors.hasNext()) {
        Actor insideActor=(Actor)insideActors.next();
        if (insideActor instanceof ContinuousStatefulComponent) {
          ((ContinuousStatefulComponent)insideActor).rollBackToCommittedState();
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Roll back to committed state. This will roll back any actors that were fired in the current iteration.
 */
public void rollBackToCommittedState(){
  Iterator actors=_actorsFired.iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    if (actor instanceof ContinuousStatefulComponent) {
      ((ContinuousStatefulComponent)actor).rollBackToCommittedState();
    }
 else     if (actor instanceof CompositeActor) {
      Director director=actor.getDirector();
      if (director instanceof ContinuousDirector) {
        ((ContinuousDirector)director).rollBackToCommittedState();
      }
    }
  }
}
Program: 74698
Project: 74698
Buggy source:
public void removeContainer(String name){
  ContainerLayout layout=constraintsManager.getContainerLayout(name);
  if (layout == null)   throw new RuntimeException("String_Node_Str" + name + "String_Node_Str");
  constraintsManager.removeLayout(layout);
  FormEditor editor=editors.get(layout);
  tabs.remove(editor);
  newLayouts.remove(layout);
}

Fixed version (ground truth):
public void removeContainer(String name){
  ContainerLayout layout=constraintsManager.getContainerLayout(name);
  if (layout == null)   throw new RuntimeException("String_Node_Str" + name + "String_Node_Str");
  Container container=constraintsManager.getContainer(layout);
  Component[] components=container.getComponents();
  for (int i=0; i < components.length; i++) {
    if (components[i] instanceof Container) {
      String componentName=layout.getComponentName(components[i]);
      if (hasContainer(componentName)) {
        removeContainer(componentName);
      }
    }
  }
  constraintsManager.removeLayout(layout);
  FormEditor editor=editors.get(layout);
  tabs.remove(editor);
  newLayouts.remove(layout);
}
Program: 74699
Project: 74699
Buggy source:
/** 
 * Return false. This actor can produce some output event the input  receiver has status unknown.
 * @return False.
 */
public boolean isStrict(){
  try {
    int latencyValue=((ScalarToken)latency.getToken()).intValue();
    if (latencyValue > 0) {
      return false;
    }
  }
 catch (  IllegalActionException ex) {
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return false. This actor can produce some output event the input  receiver has status unknown.
 * @return False.
 */
public boolean isStrict(){
  try {
    int latencyValue=((ScalarToken)latency.getToken()).intValue();
    if (latencyValue > 0) {
      return false;
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(this,ex,"String_Node_Str");
  }
  return true;
}
Program: 74700
Project: 74700
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public SynchronousFixTransformer(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  latency=new Parameter(this,"String_Node_Str");
  latency.setExpression("String_Node_Str");
  initialValue=new Parameter(this,"String_Node_Str");
  initialValue.setTypeEquals(BaseType.SCALAR);
  initialValue.setExpression("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public SynchronousFixTransformer(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  latency=new Parameter(this,"String_Node_Str",new IntToken(0));
  initialValue=new Parameter(this,"String_Node_Str");
  initialValue.setTypeEquals(BaseType.SCALAR);
  initialValue.setExpression("String_Node_Str");
}
Program: 74701
Project: 74701
Buggy source:
/** 
 * Override the base class to declare that the <i>output</i> does not depend on the <i>input</i> in a firing.
 */
public void pruneDependencies(){
  super.pruneDependencies();
  try {
    int latencyValue=((ScalarToken)latency.getToken()).intValue();
    if (latencyValue > 0) {
      super.pruneDependencies();
      Iterator inputPorts=inputPortList().iterator();
      while (inputPorts.hasNext()) {
        IOPort input=(IOPort)inputPorts.next();
        removeDependency(input,output);
      }
    }
  }
 catch (  IllegalActionException ex) {
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to declare that the <i>output</i> does not depend on the <i>input</i> in a firing.
 */
public void pruneDependencies(){
  super.pruneDependencies();
  try {
    int latencyValue=((ScalarToken)latency.getToken()).intValue();
    if (latencyValue > 0) {
      super.pruneDependencies();
      Iterator inputPorts=inputPortList().iterator();
      while (inputPorts.hasNext()) {
        IOPort input=(IOPort)inputPorts.next();
        removeDependency(input,output);
      }
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(this,ex,"String_Node_Str");
  }
}
Program: 74703
Project: 74703
Buggy source:
/** 
 * Set quantization parameters of the output port with the given parameter expression strings. Hide the parameters in the configure dialog. 
 * @param precisionString The given expression for the precision parameter.
 * @param overflowString The given expression for the overflow parameter.
 * @param roundingString The given expression for the rounding parameter.
 */
protected void _setAndHideQuantizationParameters(String precisionString,String overflowString,String roundingString){
  Parameter precision=(Parameter)getAttribute("String_Node_Str");
  Parameter overflow=(Parameter)getAttribute("String_Node_Str");
  Parameter rounding=(Parameter)getAttribute("String_Node_Str");
  precision.setVisibility(Settable.NONE);
  overflow.setVisibility(Settable.NONE);
  rounding.setVisibility(Settable.NONE);
  precision.setExpression(precisionString);
  overflow.setExpression(overflowString);
  rounding.setExpression(roundingString);
}

Fixed version (ground truth):
/** 
 * Set quantization parameters of the output port with the given parameter expression strings. Hide the parameters in the configure dialog. 
 * @param precisionString The given expression for the precision parameter.
 * @param overflowString The given expression for the overflow parameter.
 * @param roundingString The given expression for the rounding parameter.
 */
protected void _setAndHideQuantizationParameters(String precisionString,String overflowString,String roundingString) throws IllegalActionException {
  ((Parameter)getAttribute("String_Node_Str")).setVisibility(Settable.NONE);
  ((Parameter)getAttribute("String_Node_Str")).setVisibility(Settable.NONE);
  ((Parameter)getAttribute("String_Node_Str")).setVisibility(Settable.NONE);
  _setQuantizationParameters(precisionString,overflowString,roundingString);
}
Program: 74705
Project: 74705
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Slice(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setMultiport(true);
  input.setTypeEquals(BaseType.FIX);
  width=new Parameter(this,"String_Node_Str");
  start=new Parameter(this,"String_Node_Str");
  end=new Parameter(this,"String_Node_Str");
  lsb=new StringParameter(this,"String_Node_Str");
  lsb.setExpression("String_Node_Str");
  lsb.addChoice("String_Node_Str");
  lsb.addChoice("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Slice(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setMultiport(true);
  input.setTypeEquals(BaseType.FIX);
  start=new Parameter(this,"String_Node_Str");
  end=new Parameter(this,"String_Node_Str");
  lsb=new StringParameter(this,"String_Node_Str");
  lsb.setExpression("String_Node_Str");
  lsb.addChoice("String_Node_Str");
  lsb.addChoice("String_Node_Str");
}
Program: 74706
Project: 74706
Buggy source:
/** 
 * output a consecutive subset of the input bits.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int widthValue=((IntToken)width.getToken()).intValue();
  int startValue=((IntToken)start.getToken()).intValue();
  int endValue=((IntToken)end.getToken()).intValue() + 1;
  int binaryPointValue=((IntToken)binaryPoint.getToken()).intValue();
  boolean lsbValue=((StringToken)lsb.getToken()).stringValue().equals("String_Node_Str");
  int newStartValue=(lsbValue) ? widthValue - endValue : startValue;
  int newEndValue=(lsbValue) ? widthValue - startValue : endValue;
  int shiftBits=(lsbValue) ? startValue : widthValue - endValue;
  char[] mask=new char[widthValue];
  Arrays.fill(mask,'0');
  Arrays.fill(mask,newStartValue,newEndValue,'1');
  if (input.hasToken(0)) {
    FixToken in=(FixToken)input.get(0);
    BigDecimal value=new BigDecimal(in.fixValue().getUnscaledValue().and(new BigInteger(new String(mask),2)).shiftRight(shiftBits));
    FixPoint result=new FixPoint(value,new FixPointQuantization(new Precision(0,newEndValue - newStartValue,binaryPointValue),Overflow.GROW,Rounding.HALF_EVEN));
    sendOutput(output,0,new FixToken(result));
  }
}

Fixed version (ground truth):
/** 
 * output a consecutive subset of the input bits.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (input.hasToken(0)) {
    FixToken in=(FixToken)input.get(0);
    int widthValue=in.fixValue().getPrecision().getNumberOfBits();
    int startValue=((IntToken)start.getToken()).intValue();
    int endValue=((IntToken)end.getToken()).intValue() + 1;
    boolean lsbValue=((StringToken)lsb.getToken()).stringValue().equals("String_Node_Str");
    int newStartValue=(lsbValue) ? widthValue - endValue : startValue;
    int newEndValue=(lsbValue) ? widthValue - startValue : endValue;
    int shiftBits=(lsbValue) ? startValue : widthValue - endValue;
    char[] mask=new char[widthValue];
    Arrays.fill(mask,'0');
    Arrays.fill(mask,newStartValue,newEndValue,'1');
    BigDecimal value=new BigDecimal(in.fixValue().getUnscaledValue().and(new BigInteger(new String(mask),2)).shiftRight(shiftBits));
    Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
    if ((newEndValue - newStartValue) != precision.getNumberOfBits()) {
      throw new IllegalActionException(this,"String_Node_Str" + (newEndValue - newStartValue) + "String_Node_Str"+ precision);
    }
    Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
    Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
    FixPoint result=new FixPoint(value,new FixPointQuantization(precision,overflow,rounding));
    sendOutput(output,0,new FixToken(result));
  }
}
Program: 74709
Project: 74709
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public AddSubtract(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  A=new TypedIOPort(this,"String_Node_Str",true,false);
  A.setTypeEquals(BaseType.FIX);
  B=new TypedIOPort(this,"String_Node_Str",true,false);
  B.setTypeEquals(BaseType.FIX);
  operation=new StringParameter(this,"String_Node_Str");
  operation.setExpression("String_Node_Str");
  operation.addChoice("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public AddSubtract(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  A=new TypedIOPort(this,"String_Node_Str",true,false);
  A.setTypeEquals(BaseType.FIX);
  B=new TypedIOPort(this,"String_Node_Str",true,false);
  B.setTypeEquals(BaseType.FIX);
  operation=new StringParameter(this,"String_Node_Str");
  operation.setExpression("String_Node_Str");
  operation.addChoice("String_Node_Str");
  operation.addChoice("String_Node_Str");
}
Program: 74710
Project: 74710
Buggy source:
/** 
 * Send the token in the <i>value</i> parameter to the output.
 * @exception IllegalActionException If it is thrown by thesend() method sending out the token.
 */
public void fire() throws IllegalActionException {
  super.fire();
  for (int i=0; i < trigger.getWidth(); i++) {
    if (trigger.hasToken(i)) {
      trigger.get(i);
    }
  }
  Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
  Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  FixPoint result=new FixPoint(((ScalarToken)value.getToken()).doubleValue(),new FixPointQuantization(precision,overflow,rounding));
  output.send(0,new FixToken(result));
}

Fixed version (ground truth):
/** 
 * Send the token in the <i>value</i> parameter to the output.
 * @exception IllegalActionException If it is thrown by thesend() method sending out the token.
 */
public void fire() throws IllegalActionException {
  super.fire();
  for (int i=0; i < trigger.getWidth(); i++) {
    if (trigger.hasToken(i)) {
      trigger.get(i);
    }
  }
  Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
  Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  FixPoint result=new FixPoint(((ScalarToken)value.getToken()).doubleValue(),new FixPointQuantization(precision,overflow,rounding));
  sendOutput(output,0,new FixToken(result));
}
Program: 74711
Project: 74711
Buggy source:
/** 
 * If the <i>enable</i> input is connected, then if it has a true token, produce the next output. If it is not connected, produce the next output unconditionally. Whether it is connected is determined by checking the width of the port.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  for (int i=0; i < trigger.getWidth(); i++) {
    if (trigger.hasToken(i)) {
      trigger.get(i);
    }
  }
  if ((enable.getWidth() == 0) || (enable.hasToken(0) && ((BooleanToken)enable.get(0)).booleanValue())) {
    ArrayToken valuesArray=(ArrayToken)values.getToken();
    if (_currentIndex < valuesArray.length()) {
      Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
      Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
      Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
      FixPoint result=new FixPoint(((ScalarToken)valuesArray.getElement(_currentIndex)).doubleValue(),new FixPointQuantization(precision,overflow,rounding));
      output.send(0,new FixToken(result));
      _outputProduced=true;
    }
  }
}

Fixed version (ground truth):
/** 
 * If the <i>enable</i> input is connected, then if it has a true token, produce the next output. If it is not connected, produce the next output unconditionally. Whether it is connected is determined by checking the width of the port.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  for (int i=0; i < trigger.getWidth(); i++) {
    if (trigger.hasToken(i)) {
      trigger.get(i);
    }
  }
  if ((enable.getWidth() == 0) || (enable.hasToken(0) && ((BooleanToken)enable.get(0)).booleanValue())) {
    ArrayToken valuesArray=(ArrayToken)values.getToken();
    if (_currentIndex < valuesArray.length()) {
      Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
      Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
      Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
      FixPoint result=new FixPoint(((ScalarToken)valuesArray.getElement(_currentIndex)).doubleValue(),new FixPointQuantization(precision,overflow,rounding));
      sendOutput(output,0,new FixToken(result));
      _outputProduced=true;
    }
  }
}
Program: 74713
Project: 74713
Buggy source:
/** 
 * Output the fixpoint value of the sum of the input bits.  If there is no inputs, then produce null.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  BigInteger intResult=null;
  int bitsInResult=0;
  if (A.isKnown() && A.hasToken(0)) {
    FixPoint valueA=((FixToken)A.get(0)).fixValue();
    bitsInResult=valueA.getPrecision().getNumberOfBits();
    BigInteger bigIntA=valueA.getUnscaledValue();
    intResult=bigIntA.not();
    Precision precision=new Precision(1,bitsInResult,0);
    FixToken result=new FixToken(intResult.doubleValue(),precision);
    output.send(0,result);
  }
 else {
    output.resend(0);
  }
}

Fixed version (ground truth):
/** 
 * Output the fixpoint value of the sum of the input bits.  If there is no inputs, then produce null.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  BigInteger intResult=null;
  int bitsInResult=0;
  if (A.isKnown() && A.hasToken(0)) {
    FixPoint valueA=((FixToken)A.get(0)).fixValue();
    bitsInResult=valueA.getPrecision().getNumberOfBits();
    BigInteger bigIntA=valueA.getUnscaledValue();
    intResult=bigIntA.not();
    Precision precision=new Precision(1,bitsInResult,0);
    FixToken result=new FixToken(intResult.doubleValue(),precision);
    sendOutput(output,0,result);
  }
 else {
    output.resend(0);
  }
}