nus-yam/ex-repair huggingface dataset:
Program: 75558
Project: 75558
Buggy source:
/** 
 * Return true if the transition is enabled, that is the guard is true, or some event has been detected.
 * @return True if the transition is enabled and some event is detected.
 * @exception IllegalActionException If thrown when evaluating the guard.
 */
public boolean isEnabled() throws IllegalActionException {
  try {
    if (!_relationList.isEmpty()) {
      _parseTreeEvaluator.setEvaluationPhase(false);
    }
    Token token=_guard.getToken();
    if (token == null) {
      return false;
    }
    boolean result=((BooleanToken)token).booleanValue() || _relationList.hasEvent();
    return result;
  }
 catch (  UnknownResultException ex) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Return true if the transition is enabled, that is the guard is true, or some event has been detected.
 * @return True if the transition is enabled and some event is detected.
 * @exception IllegalActionException If thrown when evaluating the guard.
 */
public boolean isEnabled() throws IllegalActionException {
  try {
    if (!_relationList.isEmpty()) {
      _parseTreeEvaluator.setEvaluationMode(false);
    }
    Token token=_guard.getToken();
    if (token == null) {
      return false;
    }
    boolean result=((BooleanToken)token).booleanValue() || _relationList.hasEvent();
    return result;
  }
 catch (  UnknownResultException ex) {
    return false;
  }
}
Program: 75559
Project: 75559
Buggy source:
/** 
 * Construct a parse tree evaluator for guard expression. The relatoin list is used to store the information of the relation nodes and leaf nodes with boolean tokens. If the relation list is empty, the evaluator is in construction mode, otherwise, it is in update mode.
 * @param relationList The relation list.
 */
public ParseTreeEvaluatorForGuardExpression(RelationList relationList){
  if (relationList.isEmpty()) {
    _construction=true;
  }
 else {
    _construction=false;
  }
  _relationList=relationList;
}

Fixed version (ground truth):
/** 
 * Construct a parse tree evaluator for guard expression. The relatoin list is used to store the information of the relation nodes and leaf nodes with boolean tokens. If the relation list is empty, the evaluator is in construction mode, otherwise, it is in update mode.
 * @param relationList The relation list.
 */
public ParseTreeEvaluatorForGuardExpression(RelationList relationList){
  if (relationList.isEmpty()) {
    _construction=true;
  }
 else {
    _construction=false;
  }
  _relationList=relationList;
  _relationIndex=0;
  _absentDiscreteVariables=new LinkedList();
  _variableCollector=new ParseTreeFreeVariableCollector();
}
Program: 75560
Project: 75560
Buggy source:
/** 
 * Visit the leaf node. It is evaluated the same way as normal parse tree evaluator, except that if the the result is a boolean token, the information about the node (the difference and relationType) is either added into the relation list or used to update the according element in the relation list, depending on the evaluator mode.
 * @param node The leaf node to be evaluated.
 * @exception IllegalActionException If the super class methodvisitLeafNode throws the IllegalActionException.
 */
public void visitLeafNode(ASTPtLeafNode node) throws IllegalActionException {
  super.visitLeafNode(node);
  ptolemy.data.Token result=node.getToken();
  if (!(result instanceof BooleanToken))   return;
  if (((BooleanToken)result).booleanValue()) {
    _relationType=1;
  }
 else {
    _relationType=2;
  }
  _difference=0.0;
  if (_construction) {
    _relationList.addRelation(_relationType,_difference);
  }
 else {
    _relationList.setRelation(_relationType,_difference);
  }
}

Fixed version (ground truth):
/** 
 * Visit the leaf node. It is evaluated the same way as normal parse tree evaluator, except that if the the result is a boolean token, the information about the node (the difference and relationType) is either added into the relation list or used to update the according element in the relation list, depending on the evaluator mode.
 * @param node The leaf node to be evaluated.
 * @exception IllegalActionException If the super class methodvisitLeafNode throws the IllegalActionException.
 */
public void visitLeafNode(ASTPtLeafNode node) throws IllegalActionException {
  String nodeName=node.getName();
  String discreteVariableName="String_Node_Str";
  if (nodeName != null) {
    int variableNameEndIndex=nodeName.indexOf("String_Node_Str");
    if (variableNameEndIndex != -1) {
      discreteVariableName=nodeName.substring(0,variableNameEndIndex);
    }
  }
  if (_absentDiscreteVariables.contains(nodeName)) {
    node.setToken(new BooleanToken(false));
    if (_construction) {
      _relationList.addRelation(0,0.0);
    }
    _relationIndex++;
    return;
  }
  super.visitLeafNode(node);
  ptolemy.data.Token result=node.getToken();
  if (!(result instanceof BooleanToken))   return;
  if (((BooleanToken)result).booleanValue()) {
    _relationType=1;
    if (_absentDiscreteVariables.contains(discreteVariableName)) {
      _absentDiscreteVariables.remove(discreteVariableName);
    }
  }
 else {
    _relationType=2;
    if (!_absentDiscreteVariables.contains(discreteVariableName)) {
      _absentDiscreteVariables.add(discreteVariableName);
    }
  }
  _difference=0.0;
  if (_construction) {
    _relationList.addRelation(_relationType,_difference);
  }
 else {
    _relationList.setRelation(_relationIndex,_relationType,_difference);
  }
  _relationIndex++;
}
Program: 75562
Project: 75562
Buggy source:
/** 
 * Constructor to construct a relation node with given type and difference information.
 */
public RelationNode(int type,double difference){
  _currentType=type;
  _formerType=type;
  _difference=difference;
}

Fixed version (ground truth):
/** 
 * Constructor to construct a relation node with given type and difference information.
 */
public RelationNode(int type,double difference){
  _currentType=type;
  _formerType=type;
  _difference=difference;
  _formerDifference=difference;
}
Program: 75563
Project: 75563
Buggy source:
/** 
 * Update the according relation in the relation list with the given type and difference information.
 * @parameter type The current type of the relation.
 * @parameter difference The current difference of the relation.
 */
public void setRelation(int type,double difference){
  RelationNode relationNode=(RelationNode)_relationList.get(_index);
  relationNode.setValue(type);
  relationNode.setDifference(difference);
  _index++;
  if (_index == _relationNumber) {
    _index-=_relationNumber;
  }
}

Fixed version (ground truth):
/** 
 * Update the according relation in the relation list with the given type and difference information.
 * @parameter type The current type of the relation.
 * @parameter difference The current difference of the relation.
 */
public void setRelation(int relationIndex,int type,double difference){
  int index=relationIndex - relationIndex / _relationNumber * _relationNumber;
  RelationNode relationNode=(RelationNode)_relationList.get(index);
  relationNode.setValue(type);
  relationNode.setDifference(difference);
}
Program: 75564
Project: 75564
Buggy source:
/** 
 * Return a conversion to convert the second argument into the class given by the first argument. If no such conversion is possible, then the returned conversion is IMPOSSIBLE.
 */
protected static ArgumentConversion _getConversion(Class formal,Type actual){
  if (formal.isAssignableFrom(actual.getTokenClass()))   return IDENTITY;
  if (actual instanceof ArrayType && formal.isArray() && formal.getComponentType().isAssignableFrom(ptolemy.data.Token.class))   return ARRAYTOKEN;
  try {
    Class typeClass=ASTPtFunctionNode.convertTokenTypeToJavaType(actual);
    if (formal.isAssignableFrom(ASTPtFunctionNode.convertTokenTypeToJavaType(actual))) {
      return NATIVE;
    }
  }
 catch (  IllegalActionException ex) {
  }
  try {
    if (formal.isPrimitive()) {
      Type type=ASTPtFunctionNode.convertJavaTypeToTokenType(formal);
      if (ptolemy.graph.CPO.LOWER == TypeLattice.compare(actual,type)) {
        return NATIVE;
      }
    }
  }
 catch (  IllegalActionException ex) {
  }
  return IMPOSSIBLE;
}

Fixed version (ground truth):
/** 
 * Return a conversion to convert the second argument into the class given by the first argument. If no such conversion is possible, then the returned conversion is IMPOSSIBLE.
 */
protected static ArgumentConversion _getConversion(Class formal,Type actual){
  if (formal.isAssignableFrom(actual.getTokenClass()))   return IDENTITY;
  if (actual instanceof ArrayType && formal.isArray() && formal.getComponentType().isAssignableFrom(ptolemy.data.Token.class))   return ARRAYTOKEN;
  try {
    if (formal.isAssignableFrom(ASTPtFunctionNode.convertTokenTypeToJavaType(actual))) {
      return NATIVE;
    }
  }
 catch (  IllegalActionException ex) {
  }
  try {
    if (formal.isPrimitive()) {
      Type type=ASTPtFunctionNode.convertJavaTypeToTokenType(formal);
      if (ptolemy.graph.CPO.LOWER == TypeLattice.compare(actual,type)) {
        return NATIVE;
      }
    }
  }
 catch (  IllegalActionException ex) {
  }
  return IMPOSSIBLE;
}
Program: 75566
Project: 75566
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then sets the parameter public members to refer to the parameters of the new actor.
 * @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 {
  Clock newObject=(Clock)super.clone(workspace);
  ArrayType valuesArrayType=(ArrayType)newObject.values.getType();
  InequalityTerm elementTerm=valuesArrayType.getElementTypeTerm();
  newObject.output.setTypeAtLeast(elementTerm);
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then sets the parameter public members to refer to the parameters of the new actor.
 * @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 {
  ContinuousClock newObject=(ContinuousClock)super.clone(workspace);
  ArrayType valuesArrayType=(ArrayType)newObject.values.getType();
  InequalityTerm elementTerm=valuesArrayType.getElementTypeTerm();
  newObject.output.setTypeAtLeast(elementTerm);
  return newObject;
}
Program: 75567
Project: 75567
Buggy source:
/** 
 * Override the base class and set the origin, the rotating angle and the type of interpolation to use.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the function is not recognized.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == interpolationType) {
    String typeName=interpolationType.getExpression();
    if (typeName.equals("String_Node_Str")) {
      _interpolationType=_BICUBIC;
    }
 else     if (typeName.equals("String_Node_Str")) {
      _interpolationType=_BICUBIC2;
    }
 else     if (typeName.equals("String_Node_Str")) {
      _interpolationType=_BILINEAR;
    }
 else     if (typeName.equals("String_Node_Str")) {
      _interpolationType=_NEARESTNEIGHBOR;
    }
 else {
      throw new IllegalActionException(this,"String_Node_Str" + typeName);
    }
  }
 else   if (attribute == subSampleBits) {
    _subSampleBits=((IntToken)subSampleBits.getToken()).intValue();
  }
 else   if (attribute == xOrigin) {
    _xOrigin=((IntToken)xOrigin.getToken()).intValue();
  }
 else   if (attribute == yOrigin) {
    _xOrigin=((IntToken)yOrigin.getToken()).intValue();
  }
 else   if (attribute == degrees) {
    _degrees=((DoubleToken)degrees.getToken()).doubleValue();
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * Override the base class and set the origin, the rotating angle and the type of interpolation to use.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the function is not recognized.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == interpolationType) {
    String typeName=interpolationType.getExpression();
    if (typeName.equals("String_Node_Str")) {
      _interpolationType=_BICUBIC;
    }
 else     if (typeName.equals("String_Node_Str")) {
      _interpolationType=_BICUBIC2;
    }
 else     if (typeName.equals("String_Node_Str")) {
      _interpolationType=_BILINEAR;
    }
 else     if (typeName.equals("String_Node_Str")) {
      _interpolationType=_NEARESTNEIGHBOR;
    }
 else {
      throw new IllegalActionException(this,"String_Node_Str" + typeName);
    }
  }
 else   if (attribute == subSampleBits) {
    _subSampleBits=((IntToken)subSampleBits.getToken()).intValue();
  }
 else   if (attribute == xOrigin) {
    _xOrigin=((IntToken)xOrigin.getToken()).intValue();
  }
 else   if (attribute == yOrigin) {
    _yOrigin=((IntToken)yOrigin.getToken()).intValue();
  }
 else   if (attribute == degrees) {
    _degrees=((DoubleToken)degrees.getToken()).doubleValue();
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 75569
Project: 75569
Buggy source:
/** 
 * Preinitialize the actors associated with this director and initialize the number of iterations to zero.  The order in which the actors are preinitialized is non-deterministic.
 * @exception IllegalActionException If the preinitialize() method ofone of the associated actors throws it.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  _iteration=0;
}

Fixed version (ground truth):
/** 
 * Preinitialize the actors associated with this director and initialize the number of iterations to zero.  The order in which the actors are preinitialized is non-deterministic.
 * @exception IllegalActionException If the preinitialize() method ofone of the associated actors throws it.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  Scheduler scheduler=getScheduler();
  if (scheduler == null)   throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  if (_debugging)   _debug("String_Node_Str");
  try {
    Schedule sched=scheduler.getSchedule();
  }
 catch (  Exception ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
}
Program: 75570
Project: 75570
Buggy source:
/** 
 * Initialize all the actors associated with this director. Perform some internal initialization for this director.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _buildActorTable();
}

Fixed version (ground truth):
/** 
 * Initialize all the actors associated with this director. Perform some internal initialization for this director.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _buildActorTable();
  _iteration=0;
}
Program: 75572
Project: 75572
Buggy source:
/** 
 * Increase the count of stopped actors by one.  This method is called by instances of ProcessThread in response to a call to their stopThread method. This method may be overridden in derived classes to added domain specific functionality. Implementations of this method must be synchronized.
 */
protected synchronized void _actorHasStopped(){
  _stoppedActorCount++;
  notifyAll();
}

Fixed version (ground truth):
/** 
 * Increase the count of stopped actors by one.  This method is called by instances of ProcessThread in response to a call to their stopThread() method. This method may be overridden in derived classes to added domain specific functionality. Implementations of this method must be synchronized.
 */
protected synchronized void _actorHasStopped(){
  _stoppedActorCount++;
  notifyAll();
}
Program: 75573
Project: 75573
Buggy source:
/** 
 * Wait until a deadlock is detected. Then deal with the deadlock by calling the protected method _resolveDeadlock() and return. This method is synchronized on the director.
 * @exception IllegalActionException If a derived class throws it.
 */
public void fire() throws IllegalActionException {
  Workspace workspace=workspace();
synchronized (this) {
    while (!_areActorsDeadlocked() && !_areAllActorsStopped()) {
      workspace.wait(this);
    }
    if (_areActorsDeadlocked()) {
      _notDone=_resolveDeadlock();
    }
  }
}

Fixed version (ground truth):
/** 
 * Wait until a deadlock is detected. Then deal with the deadlock by calling the protected method _resolveDeadlock() and return. This method is synchronized on the director.
 * @exception IllegalActionException If a derived class throws it.
 */
public void fire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  Workspace workspace=workspace();
synchronized (this) {
    while (!_areActorsDeadlocked() && !_areAllActorsStopped()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      workspace.wait(this);
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    if (_areActorsDeadlocked() && !_stopRequested) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      _notDone=_resolveDeadlock();
    }
  }
}
Program: 75575
Project: 75575
Buggy source:
/** 
 * Return false if the model has reached deadlock and can be terminated if desired. Return true otherwise. This flag is set on detection of a deadlock in the fire() method.
 * @return false if the director has detected a deadlock and can beterminated if desired.
 * @exception IllegalActionException If a derived class throws it.
 */
public boolean postfire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str" + _notDone);
    _debug("String_Node_Str" + _stopRequested);
  }
  _notDone=_notDone && !_stopRequested;
  if (_debugging) {
    _debug(_name + "String_Node_Str" + _notDone);
  }
  return _notDone;
}

Fixed version (ground truth):
/** 
 * Return false if a stop has been requested or if the model has reached deadlock. Return true otherwise.
 * @return False if the director has detected a deadlock ora stop has been requested.
 * @exception IllegalActionException If a derived class throws it.
 */
public boolean postfire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
    _debug("String_Node_Str" + _notDone);
    _debug("String_Node_Str" + _stopRequested);
  }
  _notDone=_notDone && !_stopRequested;
  if (_debugging) {
    _debug("String_Node_Str" + _notDone);
  }
  return _notDone;
}
Program: 75576
Project: 75576
Buggy source:
/** 
 * Request that the director cease execution altogether. This causes a call to stop() on all actors contained by the container of this director, and a call to stopThread() on each of the process threads that contain actors controlled by this director. This also sets a flag so that the next call to postfire() returns false.
 */
public void stop(){
  Iterator threads=_actorThreadList.iterator();
  while (threads.hasNext()) {
    ProcessThread thread=(ProcessThread)threads.next();
    thread.stopThread();
    thread.getActor().stop();
  }
  _stopRequested=true;
}

Fixed version (ground truth):
/** 
 * Request that the director cease execution altogether. This causes a call to stop() on all actors contained by the container of this director, and a call to stopThread() on each of the process threads that contain actors controlled by this director. This also sets a flag so that the next call to postfire() returns false.
 */
public void stop(){
  _stopRequested=true;
  Iterator threads=_actorThreadList.iterator();
  while (threads.hasNext()) {
    ProcessThread thread=(ProcessThread)threads.next();
    thread.stopThread();
    thread.getActor().stop();
  }
  _stopRequested=true;
}
Program: 75577
Project: 75577
Buggy source:
/** 
 * Initialize the given actor.  This class overrides the base class to reset the flags for all of the receivers, and to create a new ProcessThread for each actor being controlled. This class does *NOT* directly call the initialize method of the actor. That method is instead called by the actor's thread itself. This allows actors in process domains to create tokens during initialization, since sending data in a process-based domain requires threads for each actor.
 * @exception IllegalActionException If the actor is notacceptable to the domain.  Not thrown in this base class.
 */
public void initialize(Actor actor) throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str" + ((NamedObj)actor).getName());
  }
  Iterator ports=actor.inputPortList().iterator();
  while (ports.hasNext()) {
    IOPort port=(IOPort)ports.next();
    Receiver[][] receivers=port.getReceivers();
    for (int i=0; i < receivers.length; i++) {
      for (int j=0; j < receivers[i].length; j++) {
        ((ProcessReceiver)receivers[i][j]).reset();
      }
    }
  }
  ProcessThread processThread=_getProcessThread(actor,this);
  _actorThreadList.addFirst(processThread);
  _newActorThreadList.addFirst(processThread);
}

Fixed version (ground truth):
/** 
 * Initialize the given actor.  This class overrides the base class to reset the flags for all of the receivers, and to create a new ProcessThread for each actor being controlled. This class does *NOT* directly call the initialize method of the actor. That method is instead called by the actor's thread itself. This allows actors in process domains to create tokens during initialization, since sending data in a process-based domain requires threads for each actor.
 * @exception IllegalActionException If the actor is notacceptable to the domain.  Not thrown in this base class.
 */
public void initialize(Actor actor) throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str" + ((NamedObj)actor).getFullName());
  }
  Iterator ports=actor.inputPortList().iterator();
  while (ports.hasNext()) {
    IOPort port=(IOPort)ports.next();
    Receiver[][] receivers=port.getReceivers();
    for (int i=0; i < receivers.length; i++) {
      for (int j=0; j < receivers[i].length; j++) {
        ((ProcessReceiver)receivers[i][j]).reset();
      }
    }
  }
  ProcessThread processThread=_getProcessThread(actor,this);
  _actorThreadList.addFirst(processThread);
  _newActorThreadList.addFirst(processThread);
}
Program: 75578
Project: 75578
Buggy source:
/** 
 * End the execution of the actor under the control of this thread. Subclasses are encouraged to override this method as necessary for domain specific functionality.
 * @exception IllegalActionException If an error occurs whileending execution of the actor under the control of this thread.
 */
public void wrapup() throws IllegalActionException {
  _actor.wrapup();
}

Fixed version (ground truth):
/** 
 * End the execution of the actor under the control of this thread. Subclasses are encouraged to override this method as necessary for domain specific functionality.
 * @exception IllegalActionException If an error occurs whileending execution of the actor under the control of this thread.
 */
public void wrapup() throws IllegalActionException {
  _debug("String_Node_Str");
  _actor.wrapup();
}
Program: 75579
Project: 75579
Buggy source:
/** 
 * Initialize the actor, iterate it through the execution cycle until it terminates. At the end of the termination, calls wrapup on the actor.
 */
public void run(){
  Workspace workspace=_director.workspace();
  boolean iterate=true;
  try {
    _actor.initialize();
    while (iterate) {
      if (_threadStopRequested) {
        _director._actorHasStopped();
synchronized (_director) {
          while (_threadStopRequested) {
            workspace.wait(_director);
          }
        }
      }
      if (((Entity)_actor).getContainer() != null) {
        if (_actor.prefire()) {
          _actor.fire();
          iterate=_actor.postfire();
        }
      }
    }
  }
 catch (  TerminateProcessException t) {
  }
catch (  IllegalActionException e) {
    _manager.notifyListenersOfException(e);
  }
 finally {
    try {
      wrapup();
    }
 catch (    IllegalActionException e) {
      _manager.notifyListenersOfException(e);
    }
    _director._decreaseActiveCount();
  }
}

Fixed version (ground truth):
/** 
 * Initialize the actor, iterate it through the execution cycle until it terminates. At the end of the termination, calls wrapup on the actor.
 */
public void run(){
  _debug("String_Node_Str");
  Workspace workspace=_director.workspace();
  boolean iterate=true;
  try {
    _actor.initialize();
    while (iterate) {
      if (_director.isStopRequested()) {
        _debug("String_Node_Str");
        break;
      }
      if (_threadStopRequested) {
        _debug("String_Node_Str");
synchronized (_director) {
          _director._actorHasStopped();
          while (_threadStopRequested) {
            _debug("String_Node_Str");
            workspace.wait(_director);
          }
        }
        _debug("String_Node_Str");
      }
      if (((Entity)_actor).getContainer() != null) {
        if (_actor.prefire()) {
          _actor.fire();
          iterate=_actor.postfire();
        }
      }
    }
  }
 catch (  TerminateProcessException t) {
    _debug("String_Node_Str");
  }
catch (  IllegalActionException e) {
    _debug("String_Node_Str" + e);
    _manager.notifyListenersOfException(e);
  }
 finally {
    try {
      wrapup();
    }
 catch (    IllegalActionException e) {
      _debug("String_Node_Str" + e);
      _manager.notifyListenersOfException(e);
    }
 finally {
      _director._decreaseActiveCount();
      _debug("String_Node_Str");
    }
  }
}
Program: 75580
Project: 75580
Buggy source:
/** 
 * Request that execution of the actor controlled by this thread continue.  This is normally called by the ProcessDirector in the prefire method.
 */
public void cancelStopThread(){
  _threadStopRequested=false;
}

Fixed version (ground truth):
/** 
 * Request that execution of the actor controlled by this thread continue.  This is normally called by the ProcessDirector in the prefire method.
 */
public void cancelStopThread(){
  if (_threadStopRequested) {
    _debug("String_Node_Str");
  }
  _threadStopRequested=false;
}
Program: 75581
Project: 75581
Buggy source:
/** 
 * Construct a thread to be used for the execution of the iteration methods of the actor. This increases the count of active actors in the director.
 * @param actor The actor that needs to be executed.
 * @param director The director responsible for the execution of thisactor.
 */
public ProcessThread(Actor actor,ProcessDirector director){
  super();
  _actor=actor;
  _director=director;
  _manager=((CompositeActor)((NamedObj)actor).getContainer()).getManager();
  _director._increaseActiveCount();
  _name=((Nameable)_actor).getName();
  setName(((Nameable)_actor).getFullName());
}

Fixed version (ground truth):
/** 
 * Construct a thread to be used for the execution of the iteration methods of the actor. This increases the count of active actors in the director.
 * @param actor The actor that needs to be executed.
 * @param director The director responsible for the execution of thisactor.
 */
public ProcessThread(Actor actor,ProcessDirector director){
  super();
  _actor=actor;
  _director=director;
  _manager=((CompositeActor)((NamedObj)actor).getContainer()).getManager();
  _director._increaseActiveCount();
  if (_actor instanceof NamedObj) {
    _name=((NamedObj)_actor).getFullName();
    addDebugListener((NamedObj)_actor);
  }
 else {
    _name="String_Node_Str";
  }
  setName(_name);
}
Program: 75582
Project: 75582
Buggy source:
/** 
 * Request that execution of the actor controlled by this thread stop. Call stopFire() on all composite actors that are contained by the composite actor that contains this director.
 */
public void stopThread(){
  _threadStopRequested=true;
}

Fixed version (ground truth):
/** 
 * Request that execution of the actor controlled by this thread stop. Call stopFire() on all composite actors that are contained by the composite actor that contains this director.
 */
public void stopThread(){
  _threadStopRequested=true;
  _debug("String_Node_Str");
}
Program: 75585
Project: 75585
Buggy source:
/** 
 * Return the argument contained by this entity that is return. If there is no such argument, return null. This method is read-synchronized on the workspace.
 * @return the argument return, or null if none exists.
 */
public Argument getArgumentReturn(){
  try {
    _workspace.getReadAccess();
    Iterator arguments=argumentsList().iterator();
    Argument returnValue=null;
    while (arguments.hasNext()) {
      Argument argument=(Argument)arguments.next();
      if (argument != null && argument.isReturn()) {
        return (Argument)argument;
      }
    }
    return (Argument)returnValue;
  }
  finally {
    _workspace.doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Return the argument contained by this entity that is return. If there is no such argument, return null. This method is read-synchronized on the workspace.
 * @return the argument return, or null if none exists.
 */
public Argument getArgumentReturn(){
  try {
    _workspace.getReadAccess();
    Iterator arguments=this.argumentsList().iterator();
    Argument returnValue=null;
    while (arguments.hasNext()) {
      Argument argument=(Argument)arguments.next();
      if (argument != null && argument.isReturn()) {
        return (Argument)argument;
      }
    }
    return (Argument)returnValue;
  }
  finally {
    _workspace.doneReading();
  }
}
Program: 75589
Project: 75589
Buggy source:
/** 
 * If <i>trainingMode</i> is <i>true</i>, then take the collected training tokens and store them as an array in <i>correctValues</i>.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  boolean training=((BooleanToken)trainingMode.getToken()).booleanValue();
  if (training && _trainingTokens != null) {
    Object[] newValues=_trainingTokens.toArray();
    Token[] newTokens=new Token[newValues.length];
    for (int i=0; i < newValues.length; i++) {
      newTokens[i]=(Token)newValues[i];
    }
    correctValues.setToken(new ArrayToken(newTokens));
  }
}

Fixed version (ground truth):
/** 
 * If <i>trainingMode</i> is <i>true</i>, then take the collected training tokens and store them as an array in <i>correctValues</i>.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  boolean training=((BooleanToken)trainingMode.getToken()).booleanValue();
  if (training && _trainingTokens != null && _trainingTokens.size() > 0) {
    Object[] newValues=_trainingTokens.toArray();
    Token[] newTokens=new Token[newValues.length];
    for (int i=0; i < newValues.length; i++) {
      newTokens[i]=(Token)newValues[i];
    }
    correctValues.setToken(new ArrayToken(newTokens));
  }
}
Program: 75590
Project: 75590
Buggy source:
/** 
 * If the specified actor has not be prefired() in the current iteration, then prefire() it.
 * @param actor The actor to prefire().
 * @exception IllegalActionException If the actor returns false.
 */
protected void _prefireIfNecessary(Actor actor) throws IllegalActionException {
  CTDirector dir=(CTDirector)getContainer();
  if (dir.isPrefireComplete(actor)) {
    _debug(getFullName() + "String_Node_Str" + ((Nameable)actor).getName());
    dir.setPrefireComplete(actor);
    if (!actor.prefire()) {
      throw new IllegalActionException((Nameable)actor,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * If the specified actor has not be prefired() in the current iteration, then prefire() it.
 * @param actor The actor to prefire().
 * @exception IllegalActionException If the actor returns false.
 */
protected void _prefireIfNecessary(Actor actor) throws IllegalActionException {
  CTDirector dir=(CTDirector)getContainer();
  if (!dir.isPrefireComplete(actor)) {
    _debug(getFullName() + "String_Node_Str" + ((Nameable)actor).getName());
    dir.setPrefireComplete(actor);
    if (!actor.prefire()) {
      throw new IllegalActionException((Nameable)actor,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
  }
}
Program: 75591
Project: 75591
Buggy source:
/** 
 * Return a MoML String that will delete the given node from the Ptolemy model.
 * @return A valid MoML string.
 */
public String getDeleteNodeMoML(Object node){
  ComponentRelation deleteObj=(ComponentRelation)((Vertex)node).getContainer();
  NamedObj container=_getChangeRequestParent(getPtolemyModel());
  System.out.println("String_Node_Str" + container.getFullName());
  String moml="String_Node_Str" + deleteObj.getName(container) + "String_Node_Str";
  return moml;
}

Fixed version (ground truth):
/** 
 * Return a MoML String that will delete the given node from the Ptolemy model.
 * @return A valid MoML string.
 */
public String getDeleteNodeMoML(Object node){
  ComponentRelation deleteObj=(ComponentRelation)((Vertex)node).getContainer();
  NamedObj container=_getChangeRequestParent(getPtolemyModel());
  String moml="String_Node_Str" + deleteObj.getName(container) + "String_Node_Str";
  return moml;
}
Program: 75595
Project: 75595
Buggy source:
/** 
 * Set the desired location of this node.  Throw an exception if the node can not be given a desired location.
 * @exception IllegalActionException Not thrown in this base class.
 */
public void setLocation(Object node,double[] location) throws IllegalActionException {
  if (node instanceof Locatable) {
    ((Locatable)node).setLocation(location);
  }
 else   throw new RuntimeException("String_Node_Str" + node + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Set the desired location of this node.  Throw an exception if the node can not be given a desired location.
 * @exception IllegalActionException Not thrown in this base class.
 */
public void setLocation(Object node,double[] location) throws IllegalActionException {
  if (location != null && location.length != 2) {
    throw new RuntimeException("String_Node_Str" + location + "String_Node_Str");
  }
  if (node instanceof Locatable) {
    ((Locatable)node).setLocation(location);
  }
 else   throw new RuntimeException("String_Node_Str" + node + "String_Node_Str");
}
Program: 75596
Project: 75596
Buggy source:
/** 
 * Return true if the node is associated with a desired location. In this base class, return true if the the node's semantic object is an instance of Locatable.
 */
public boolean hasLocation(Object node){
  if (node instanceof Locatable) {
    Locatable object=(Locatable)node;
    double[] location=object.getLocation();
    if (location != null)     return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Return true if the node is associated with a desired location. In this base class, return true if the the node's semantic object is an instance of Locatable.
 */
public boolean hasLocation(Object node){
  if (node instanceof Locatable) {
    Locatable object=(Locatable)node;
    double[] location=object.getLocation();
    if (location != null && location.length == 2) {
      return true;
    }
  }
  return false;
}
Program: 75601
Project: 75601
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 Assertion(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  assertion=new Parameter(this,"String_Node_Str");
  _errorTolerance=(double)Complex.episilon;
  errorTolerance=new Parameter(this,"String_Node_Str",new DoubleToken(_errorTolerance));
}

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 Assertion(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  assertion=new Parameter(this,"String_Node_Str");
  _errorTolerance=(double)Complex.epsilon;
  errorTolerance=new Parameter(this,"String_Node_Str",new DoubleToken(_errorTolerance));
}
Program: 75602
Project: 75602
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 {
  Assertion newObject=(Assertion)super.clone(workspace);
  newObject._tokenMap=null;
  newObject._errorTolerance=(double)Complex.episilon;
  newObject._parseTree=null;
  newObject._parseTreeEvaluator=null;
  newObject._scope=null;
  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 {
  Assertion newObject=(Assertion)super.clone(workspace);
  newObject._tokenMap=null;
  newObject._errorTolerance=(double)Complex.epsilon;
  newObject._parseTree=null;
  newObject._parseTreeEvaluator=null;
  newObject._scope=null;
  return newObject;
}
Program: 75603
Project: 75603
Buggy source:
/** 
 * Write the model to the specified file.  This method delegates to the top effigy containing the associated Tableau, if there is one, and otherwise throws an exception. This ensures that the data written is the description of the entire model, not just the portion within some composite actor.
 * @param file The file to write to.
 * @exception IOException If the write fails.
 */
protected void _writeFile(File file) throws IOException {
  Tableau tableau=getTableau();
  if (tableau != null) {
    Effigy effigy=(Effigy)tableau.getContainer();
    if (effigy != null) {
      effigy.topEffigy().writeFile(file);
      return;
    }
  }
  throw new IOException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Write the model to the specified file.  This method delegates to the top effigy containing the associated Tableau, if there is one, and otherwise throws an exception. This ensures that the data written is the description of the entire model, not just the portion within some composite actor.   It also adjusts the URIAttribute in the model to match the specified file, if necessary, and creates one otherwise.
 * @param file The file to write to.
 * @exception IOException If the write fails.
 */
protected void _writeFile(File file) throws IOException {
  Tableau tableau=getTableau();
  if (tableau != null) {
    Effigy effigy=(Effigy)tableau.getContainer();
    if (effigy != null) {
      Effigy topEffigy=effigy.topEffigy();
      topEffigy.writeFile(file);
      if (topEffigy instanceof PtolemyEffigy) {
        NamedObj model=((PtolemyEffigy)topEffigy).getModel();
        try {
          URIAttribute uri=new URIAttribute(model,"String_Node_Str");
          uri.setURI(file.toURI());
        }
 catch (        KernelException ex) {
          throw new InternalErrorException("String_Node_Str");
        }
      }
      return;
    }
  }
  throw new IOException("String_Node_Str");
}
Program: 75605
Project: 75605
Buggy source:
/** 
 * Simulate the consumption of tokens by the actor during execution of the given number of firings. The entries in the waitingTokens map will be modified to reflect the number of tokens still waiting after the actor has consumed the minimum required number of tokens for all firings. Also determine if enough tokens still remain at the inputs of the actor for it to fire again immediately.
 * @param currentActor The actor that is being simulated.
 * @param waitingTokens A map between each input IOPort and the number oftokens in the queue for that port.  This will be updated to reflect the new number of waiting tokens.
 * @param firingCount The number of firings to simulate.
 * @return true If the actor can fire again right awayafter it has consumed tokens.
 * @exception IllegalActionException If the rate parameters are invalid.
 */
private boolean _simulateInputConsumption(ComponentEntity currentActor,Map waitingTokens,int firingCount) throws IllegalActionException {
  boolean stillReadyToSchedule=true;
  Iterator inputPorts=((Actor)currentActor).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    int[] tokens=(int[])waitingTokens.get(inputPort);
    int tokenRate=getTokenConsumptionRate(inputPort);
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      tokens[channel]-=tokenRate;
      if (tokens[channel] < tokenRate) {
        stillReadyToSchedule=false;
      }
    }
  }
  return stillReadyToSchedule;
}

Fixed version (ground truth):
/** 
 * Simulate the consumption of tokens by the actor during execution of the given number of firings. The entries in the waitingTokens map will be modified to reflect the number of tokens still waiting after the actor has consumed the minimum required number of tokens for all firings. Also determine if enough tokens still remain at the inputs of the actor for it to fire again immediately.
 * @param currentActor The actor that is being simulated.
 * @param waitingTokens A map between each input IOPort and the number oftokens in the queue for that port.  This will be updated to reflect the new number of waiting tokens.
 * @param firingCount The number of firings to simulate.
 * @return true If the actor can fire again right awayafter it has consumed tokens.
 * @exception IllegalActionException If the rate parameters are invalid.
 */
private boolean _simulateInputConsumption(ComponentEntity currentActor,Map waitingTokens,int firingCount) throws IllegalActionException {
  boolean stillReadyToSchedule=true;
  Iterator inputPorts=((Actor)currentActor).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    int[] tokens=(int[])waitingTokens.get(inputPort);
    int tokenRate=getTokenConsumptionRate(inputPort);
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      tokens[channel]-=(tokenRate * firingCount);
      if (tokens[channel] < tokenRate) {
        stillReadyToSchedule=false;
      }
    }
  }
  return stillReadyToSchedule;
}
Program: 75608
Project: 75608
Buggy source:
/** 
 * Remove an edge from this graph if it exists in the graph. The edge may be hidden. An edge that is removed from a graph can be re-inserted into the graph at a later time (using   {@link #addEdge(Edge)}), provided that the incident nodes are still in the graph. <p>This is an <em>O(e)</em> operation. A similar operation can be performed in <em>O(1)</em> time using   {@link #hideEdge(Edge)}.
 * @param edge The edge to be removed.
 * @return True if the edge was removed.
 * @see #hideEdge(Edge)
 */
public boolean removeEdge(Edge edge){
  if (!_edges.contains(edge)) {
    return false;
  }
  _edges.remove(edge);
  if (!hidden(edge)) {
    _disconnectEdge(edge);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Remove an edge from this graph if it exists in the graph. The edge may be hidden. An edge that is removed from a graph can be re-inserted into the graph at a later time (using   {@link #addEdge(Edge)}), provided that the incident nodes are still in the graph. <p>This is an <em>O(e)</em> operation. A similar operation can be performed in <em>O(1)</em> time using   {@link #hideEdge(Edge)}.
 * @param edge The edge to be removed.
 * @return True if the edge was removed.
 * @see #hideEdge(Edge)
 */
public boolean removeEdge(Edge edge){
  if (!_edges.contains(edge)) {
    return false;
  }
  _edges.remove(edge);
  if (hidden(edge)) {
    _hiddenEdgeSet.remove(edge);
  }
 else {
    _disconnectEdge(edge);
  }
  return true;
}
Program: 75609
Project: 75609
Buggy source:
/** 
 * Remove an edge from this graph if it exists in the graph. The edge may be hidden. An edge that is removed from a graph can be re-inserted into the graph at a later time (using   {@link #addEdge(Edge)}), provided that the incident nodes are still in the graph. <p>This is an <em>O(e)</em> operation. A similar operation can be performed in <em>O(1)</em> time using   {@link #hideEdge(Edge)}.
 * @param edge The edge to be removed.
 * @return True if the edge was removed.
 * @see #hideEdge(Edge)
 */
public boolean removeEdge(Edge edge){
  if (!_edges.contains(edge)) {
    return false;
  }
  _edges.remove(edge);
  if (hidden(edge)) {
    _hiddenEdgeSet.remove(edge);
    return false;
  }
 else {
    _disconnectEdge(edge);
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Remove an edge from this graph if it exists in the graph. The edge may be hidden. An edge that is removed from a graph can be re-inserted into the graph at a later time (using   {@link #addEdge(Edge)}), provided that the incident nodes are still in the graph. <p>This is an <em>O(e)</em> operation. A similar operation can be performed in <em>O(1)</em> time using   {@link #hideEdge(Edge)}.
 * @param edge The edge to be removed.
 * @return True if the edge was removed.
 * @see #hideEdge(Edge)
 */
public boolean removeEdge(Edge edge){
  if (!_edges.contains(edge)) {
    return false;
  }
  _edges.remove(edge);
  if (hidden(edge)) {
    _hiddenEdgeSet.remove(edge);
  }
 else {
    _disconnectEdge(edge);
  }
  return true;
}
Program: 75610
Project: 75610
Buggy source:
/** 
 * Restore an edge if the edge exists in the graph and is presently hidden. This is an <em>O(1)</em> operation.
 * @param edge The edge to restore.
 * @return true If the edge is in the graph and was hidden.
 * @exception IllegalArgumentException If the source node and sink nodeof the given edge are not both in the graph.
 * @see #hideEdge(Edge)
 */
public boolean restoreEdge(Edge edge){
  if (_hiddenEdgeSet.remove(edge)) {
    if (!containsNode(edge.source())) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + _edgeDump(edge));
    }
    if (!containsNode(edge.sink())) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + _edgeDump(edge));
    }
    _connectEdge(edge);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Restore an edge if the edge exists in the graph and is presently hidden. This is an <em>O(1)</em> operation.
 * @param edge The edge to restore.
 * @return True if the edge is in the graph and was hidden.
 * @exception IllegalArgumentException If the source node and sink nodeof the given edge are not both in the graph.
 * @see #hideEdge(Edge)
 */
public boolean restoreEdge(Edge edge){
  if (_hiddenEdgeSet.remove(edge)) {
    if (!containsNode(edge.source())) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + _edgeDump(edge));
    }
    if (!containsNode(edge.sink())) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + _edgeDump(edge));
    }
    _connectEdge(edge);
    return true;
  }
 else {
    return false;
  }
}