nus-yam/ex-repair huggingface dataset:
Program: 74755
Project: 74755
Buggy source:
/** 
 * Override the base class to return a different site for each connection to a multiport.
 * @return The connection site.
 */
public Site getHeadSite(){
  if ((_headPort == null) || !_headPort.isMultiport()) {
    return super.getHeadSite();
  }
  Site result=super.getHeadSite();
  if (result instanceof PortConnectSite) {
    PortTerminal terminal=((PortConnectSite)result).getTerminal();
    int orderIndex=terminal.getOrderIndex(this);
    if (orderIndex >= 0) {
      return new PortConnectSite(result.getFigure(),terminal,orderIndex + 1,result.getNormal());
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Override the base class to return a different site for each connection to a multiport.
 * @return The connection site.
 */
public Site getHeadSite(){
  Site result=super.getHeadSite();
  if ((_headPort == null) || !_headPort.isMultiport()) {
    return result;
  }
  if (result instanceof PortConnectSite) {
    PortTerminal terminal=((PortConnectSite)result).getTerminal();
    int orderIndex=terminal.getOrderIndex(this);
    if (orderIndex >= 0) {
      if (_headSites == null) {
        _headSites=new ArrayList();
      }
      if (_headSites.size() > orderIndex) {
        if (_headSites.get(orderIndex) == null) {
          result=new PortConnectSite(result.getFigure(),terminal,orderIndex + 1,result.getNormal());
        }
 else {
          result=(Site)_headSites.get(orderIndex);
        }
        _headSites.set(orderIndex,result);
      }
 else {
        result=new PortConnectSite(result.getFigure(),terminal,orderIndex + 1,result.getNormal());
        while (_headSites.size() < orderIndex) {
          _headSites.add(null);
        }
        _headSites.add(result);
      }
    }
  }
  return result;
}
Program: 74756
Project: 74756
Buggy source:
/** 
 * Override the base class to return a different site for each connection to a multiport.
 * @return The connection site.
 */
public Site getTailSite(){
  if ((_tailPort == null) || !_tailPort.isMultiport()) {
    return super.getTailSite();
  }
  Site result=super.getTailSite();
  if (result instanceof PortConnectSite) {
    PortTerminal terminal=((PortConnectSite)result).getTerminal();
    int orderIndex=terminal.getOrderIndex(this);
    if (orderIndex >= 0) {
      return new PortConnectSite(result.getFigure(),terminal,orderIndex + 1,result.getNormal());
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Override the base class to return a different site for each connection to a multiport.
 * @return The connection site.
 */
public Site getTailSite(){
  Site result=super.getTailSite();
  if ((_tailPort == null) || !_tailPort.isMultiport()) {
    return result;
  }
  if (result instanceof PortConnectSite) {
    PortTerminal terminal=((PortConnectSite)result).getTerminal();
    int orderIndex=terminal.getOrderIndex(this);
    if (orderIndex >= 0) {
      if (_tailSites == null) {
        _tailSites=new ArrayList();
      }
      if (_tailSites.size() > orderIndex) {
        if (_tailSites.get(orderIndex) == null) {
          result=new PortConnectSite(result.getFigure(),terminal,orderIndex + 1,result.getNormal());
        }
 else {
          result=(Site)_tailSites.get(orderIndex);
        }
        _tailSites.set(orderIndex,result);
      }
 else {
        result=new PortConnectSite(result.getFigure(),terminal,orderIndex + 1,result.getNormal());
        while (_tailSites.size() < orderIndex) {
          _tailSites.add(null);
        }
        _tailSites.add(result);
      }
    }
  }
  return result;
}
Program: 74757
Project: 74757
Buggy source:
/** 
 * Add a transparent to the PtalonActor with the specified name.  A transparent relation is not  really a relation.  Instead, it provides a means for connecting multiple ports to an input port.  It is transparent in that it provides an invisible means to connect to the specified 
 * @param name The name of the relation.
 */
public void addTransparentRelation(String name){
  _currentIfTree.setStatus(name,true);
  _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
}

Fixed version (ground truth):
/** 
 * Add a transparent to the PtalonActor with the specified name.  A transparent relation is not  really a relation.  Instead, it provides a means for connecting multiple ports to an input port.  It is transparent in that it provides an invisible means to connect to the specified 
 * @param name The name of the relation.
 */
public void addTransparentRelation(String name) throws PtalonRuntimeException {
  _currentIfTree.setStatus(name,true);
  if (_inNewWhileIteration()) {
    if (_currentIfTree.isForStatement) {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
 else {
      IfTree tree=_currentIfTree;
      while (!tree.isForStatement) {
        tree=tree.getParent();
        if (tree == null) {
          throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
        }
      }
      _currentIfTree.setEnteredIteration(name,tree.entered);
    }
  }
 else {
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
  }
}
Program: 74758
Project: 74758
Buggy source:
/** 
 * Create a new if tree.
 * @param name The name to give this if tree.
 * @parem parent The paretn to this tree, which may be nullif this is the root of a tree.
 */
public IfTree(IfTree parent,String name){
  super(parent,name);
  _nameMappings=new Hashtable<String,String>();
  _setStatus=new Hashtable<String,Boolean>();
  _symbols=new Hashtable<String,String>();
}

Fixed version (ground truth):
/** 
 * Create a new if tree.
 * @param name The name to give this if tree.
 * @parem parent The paretn to this tree, which may be nullif this is the root of a tree.
 */
public IfTree(IfTree parent,String name){
  super(parent,name);
  _trueNameMappings=new Hashtable<String,String>();
  _trueSetStatus=new Hashtable<String,Boolean>();
  _trueSymbols=new Hashtable<String,String>();
  _falseNameMappings=new Hashtable<String,String>();
  _falseSetStatus=new Hashtable<String,Boolean>();
  _falseSymbols=new Hashtable<String,String>();
}
Program: 74759
Project: 74759
Buggy source:
/** 
 * Return true if the given symbol is in this scope, or deeply in this scope through some for loop.
 * @param symbol The symbol to test.
 * @return true if symbol is in the right scope.
 */
public boolean inDeepScope(String symbol){
  if (_symbols.containsKey(symbol)) {
    return true;
  }
  for (  IfTree child : _children) {
    if (child.isForStatement) {
      if (child.inDeepScope(symbol)) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Return true if the given symbol is in this scope, or deeply in this scope through some for loop.
 * @param symbol The symbol to test.
 * @return true if symbol is in the right scope.
 */
public boolean inDeepScope(String symbol){
  if ((_currentBranch || isForStatement) && _trueSymbols.containsKey(symbol)) {
    return true;
  }
 else   if (!(_currentBranch || isForStatement) && _falseSymbols.containsKey(symbol)) {
    return true;
  }
  for (  IfTree child : _children) {
    if (child.isForStatement) {
      if (child.inDeepScope(symbol)) {
        return true;
      }
    }
  }
  return false;
}
Program: 74760
Project: 74760
Buggy source:
/** 
 * @return All symbols in the scope of the if-block.
 */
public Set<String> getSymbols(){
  return _symbols.keySet();
}

Fixed version (ground truth):
/** 
 * @return All symbols in the scope of the if-block.
 */
public Set<String> getSymbols(){
  if (_currentBranch || isForStatement) {
    return _trueSymbols.keySet();
  }
 else {
    return _falseSymbols.keySet();
  }
}
Program: 74761
Project: 74761
Buggy source:
/** 
 * Add a symbol to the scope of this if statement.
 * @param symbol The sybmol to add.
 * @param type Its corresponding type.
 * @param status It's statust, that is whether it has been loaded or not.
 * @param uniqueName The unique name of this 
 */
public void addSymbol(String symbol,String type,boolean status,String uniqueName){
  _symbols.put(symbol,type);
  _nameMappings.put(symbol,uniqueName);
  _setStatus.put(symbol,status);
}

Fixed version (ground truth):
/** 
 * Add a symbol to the scope of this if statement.
 * @param symbol The sybmol to add.
 * @param type Its corresponding type.
 * @param status It's statust, that is whether it has been loaded or not.
 * @param uniqueName The unique name of this 
 */
public void addSymbol(String symbol,String type,boolean status,String uniqueName){
  if (_currentBranch || isForStatement) {
    _trueSymbols.put(symbol,type);
    _trueNameMappings.put(symbol,uniqueName);
    _trueSetStatus.put(symbol,status);
  }
 else {
    _falseSymbols.put(symbol,type);
    _falseNameMappings.put(symbol,uniqueName);
    _falseSetStatus.put(symbol,status);
  }
}
Program: 74762
Project: 74762
Buggy source:
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name.
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(true);
    port.setOutput(true);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}

Fixed version (ground truth):
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name.
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(true);
    port.setOutput(true);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        _currentIfTree.setEnteredIteration(name,tree.entered);
      }
    }
 else {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}
Program: 74763
Project: 74763
Buggy source:
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name, and output flow type
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addOutPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(false);
    port.setOutput(true);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}

Fixed version (ground truth):
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name, and output flow type
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addOutPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(false);
    port.setOutput(true);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        _currentIfTree.setEnteredIteration(name,tree.entered);
      }
    }
 else {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}
Program: 74764
Project: 74764
Buggy source:
/** 
 * Add an invisible Parameter to the PtalonActor with the specified name and the given expression as its value.
 * @param name The name of the parameter.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a parameter associated with it, or if an IllegalActionException is thrown trying to create the parameter.
 */
public void addParameter(String name,String expression) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    PtalonExpressionParameter parameter=new PtalonExpressionParameter(_actor,uniqueName);
    parameter.setVisibility(Settable.NONE);
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
    _unassignedParameters.add(parameter);
    _unassignedParameterValues.add(expression);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Add an invisible Parameter to the PtalonActor with the specified name and the given expression as its value.
 * @param name The name of the parameter.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a parameter associated with it, or if an IllegalActionException is thrown trying to create the parameter.
 */
public void addParameter(String name,String expression) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    PtalonExpressionParameter parameter=new PtalonExpressionParameter(_actor,uniqueName);
    parameter.setVisibility(Settable.NONE);
    _currentIfTree.setStatus(name,true);
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        _currentIfTree.setEnteredIteration(name,tree.entered);
      }
    }
 else {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
    _currentIfTree.mapName(name,uniqueName);
    _unassignedParameters.add(parameter);
    _unassignedParameterValues.add(expression);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}
Program: 74765
Project: 74765
Buggy source:
/** 
 * Map a name of a symbol from a Ptalon program to a name in the PtalonActor which creates it.
 * @param symbol The name for the symbol in the Ptalon program.
 * @param uniqueName The unique name for the symbol in the PtalonActor.
 * @exception PtalonRuntimeException If the symbol does not exist.
 */
public void mapName(String symbol,String uniqueName) throws PtalonRuntimeException {
  String value=_symbols.get(symbol);
  if (value == null) {
    String message=symbol.concat("String_Node_Str");
    throw new PtalonRuntimeException(message);
  }
  _nameMappings.put(symbol,uniqueName);
}

Fixed version (ground truth):
/** 
 * Map a name of a symbol from a Ptalon program to a name in the PtalonActor which creates it.
 * @param symbol The name for the symbol in the Ptalon program.
 * @param uniqueName The unique name for the symbol in the PtalonActor.
 * @exception PtalonRuntimeException If the symbol does not exist.
 */
public void mapName(String symbol,String uniqueName) throws PtalonRuntimeException {
  String value;
  if (_currentBranch || isForStatement) {
    value=_trueSymbols.get(symbol);
    if (value == null) {
      String message=symbol.concat("String_Node_Str");
      throw new PtalonRuntimeException(message);
    }
    _trueNameMappings.put(symbol,uniqueName);
  }
 else {
    value=_falseSymbols.get(symbol);
    if (value == null) {
      String message=symbol.concat("String_Node_Str");
      throw new PtalonRuntimeException(message);
    }
    _falseNameMappings.put(symbol,uniqueName);
  }
}
Program: 74766
Project: 74766
Buggy source:
/** 
 * Add a TypedIORelation to the PtalonActor with the specified name.
 * @param name The name of the relation.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a relation associated with it, or if an IllegalActionException is thrown trying to create the relation.
 */
public void addRelation(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIORelation relation=new TypedIORelation(_actor,uniqueName);
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Add a TypedIORelation to the PtalonActor with the specified name.
 * @param name The name of the relation.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a relation associated with it, or if an IllegalActionException is thrown trying to create the relation.
 */
public void addRelation(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIORelation relation=new TypedIORelation(_actor,uniqueName);
    _currentIfTree.setStatus(name,true);
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        _currentIfTree.setEnteredIteration(name,tree.entered);
      }
    }
 else {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}
Program: 74767
Project: 74767
Buggy source:
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name, and input flow type
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addInPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(true);
    port.setOutput(false);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}

Fixed version (ground truth):
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name, and input flow type
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addInPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(true);
    port.setOutput(false);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        _currentIfTree.setEnteredIteration(name,tree.entered);
      }
    }
 else {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}
Program: 74768
Project: 74768
Buggy source:
/** 
 * Return true if an entity was created in PtalonActor for the given  symbol.  This symbol is assumed to be in the current scope.
 * @param symbol The symbol to test.
 * @return true if an entity was created for this symbol.
 * @exception PtalonRuntimeException If the symbol is not in the currentscope.
 */
public boolean isCreated(String symbol) throws PtalonRuntimeException {
  Boolean status=_setStatus.get(symbol);
  if (status == null) {
    return false;
  }
  return status;
}

Fixed version (ground truth):
/** 
 * Return true if an entity was created in PtalonActor for the given  symbol.  This symbol is assumed to be in the current scope.
 * @param symbol The symbol to test.
 * @return true if an entity was created for this symbol.
 * @exception PtalonRuntimeException If the symbol is not in the currentscope.
 */
public boolean isCreated(String symbol) throws PtalonRuntimeException {
  Boolean status;
  if (_currentBranch || isForStatement) {
    status=_trueSetStatus.get(symbol);
  }
 else {
    status=_falseSetStatus.get(symbol);
  }
  if (status == null) {
    return false;
  }
  return status;
}
Program: 74769
Project: 74769
Buggy source:
/** 
 * Add an invisible PtalonParameter to the PtalonActor with the specified name.
 * @param name The name of the parameter.
 * @param expression The expression representing the parameter.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a parameter associated with it, or if an IllegalActionException is thrown trying to create the parameter.
 */
public void addActorParameter(String name,String expression) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    PtalonParameter parameter=new PtalonParameter(_actor,uniqueName);
    parameter.setVisibility(Settable.NONE);
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
    _unassignedParameters.add(parameter);
    _unassignedParameterValues.add(expression);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Add an invisible PtalonParameter to the PtalonActor with the specified name.
 * @param name The name of the parameter.
 * @param expression The expression representing the parameter.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a parameter associated with it, or if an IllegalActionException is thrown trying to create the parameter.
 */
public void addActorParameter(String name,String expression) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    PtalonParameter parameter=new PtalonParameter(_actor,uniqueName);
    parameter.setVisibility(Settable.NONE);
    _currentIfTree.setStatus(name,true);
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        _currentIfTree.setEnteredIteration(name,tree.entered);
      }
    }
 else {
      _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    }
    _currentIfTree.mapName(name,uniqueName);
    _unassignedParameters.add(parameter);
    _unassignedParameterValues.add(expression);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}
Program: 74770
Project: 74770
Buggy source:
/** 
 * Get the unique name for the symbol in the PtalonActor. 
 * @param symbol The symbol to test.
 * @return The unique name.
 * @exception PtalonRuntimeException If no such symbol exists.
 */
public String getMappedName(String symbol) throws PtalonRuntimeException {
  String output=_nameMappings.get(symbol);
  if (output == null) {
    throw new PtalonRuntimeException("String_Node_Str" + symbol + "String_Node_Str");
  }
  return output;
}

Fixed version (ground truth):
/** 
 * Get the unique name for the symbol in the PtalonActor. 
 * @param symbol The symbol to test.
 * @return The unique name.
 * @exception PtalonRuntimeException If no such symbol exists.
 */
public String getMappedName(String symbol) throws PtalonRuntimeException {
  String output;
  if (_currentBranch || isForStatement) {
    output=_trueNameMappings.get(symbol);
  }
 else {
    output=_falseNameMappings.get(symbol);
  }
  if (output == null) {
    throw new PtalonRuntimeException("String_Node_Str" + symbol + "String_Node_Str");
  }
  return output;
}
Program: 74771
Project: 74771
Buggy source:
/** 
 * Return true if all the symbols in this if block have been assigned a value.  A symbol has been  assigned a value if a corresponding entity for the symbol has been created in the PtalonActor, and in the case of parameters, that the user has provided a value for the parameter.
 * @return True if all the symbols in this if blockhave been assigned a value. 
 * @exception PtalonRuntimeException If there is any problem accessinga parameter.
 */
public boolean isFullyAssigned() throws PtalonRuntimeException {
  for (  String symbol : _setStatus.keySet()) {
    if (!_setStatus.get(symbol)) {
      return false;
    }
    if (_symbols.get(symbol).endsWith("String_Node_Str")) {
      try {
        PtalonParameter param=(PtalonParameter)_actor.getAttribute(_nameMappings.get(symbol));
        if (!param.hasValue()) {
          return false;
        }
      }
 catch (      Exception e) {
        throw new PtalonRuntimeException("String_Node_Str" + symbol,e);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return true if all the symbols in this if block have been assigned a value.  A symbol has been  assigned a value if a corresponding entity for the symbol has been created in the PtalonActor, and in the case of parameters, that the user has provided a value for the parameter.
 * @return True if all the symbols in this if blockhave been assigned a value. 
 * @exception PtalonRuntimeException If there is any problem accessinga parameter.
 */
public boolean isFullyAssigned() throws PtalonRuntimeException {
  if (_currentBranch || isForStatement) {
    for (    String symbol : _trueSetStatus.keySet()) {
      if (!_trueSetStatus.get(symbol)) {
        return false;
      }
      if (_trueSymbols.get(symbol).endsWith("String_Node_Str")) {
        try {
          PtalonParameter param=(PtalonParameter)_actor.getAttribute(_trueNameMappings.get(symbol));
          if (!param.hasValue()) {
            return false;
          }
        }
 catch (        Exception e) {
          throw new PtalonRuntimeException("String_Node_Str" + symbol,e);
        }
      }
    }
    return true;
  }
 else {
    for (    String symbol : _falseSetStatus.keySet()) {
      if (!_falseSetStatus.get(symbol)) {
        return false;
      }
      if (_falseSymbols.get(symbol).endsWith("String_Node_Str")) {
        try {
          PtalonParameter param=(PtalonParameter)_actor.getAttribute(_falseNameMappings.get(symbol));
          if (!param.hasValue()) {
            return false;
          }
        }
 catch (        Exception e) {
          throw new PtalonRuntimeException("String_Node_Str" + symbol,e);
        }
      }
    }
    return true;
  }
}
Program: 74772
Project: 74772
Buggy source:
/** 
 * Set the status of the symbol to true, if the symbol is ready, and false otherwise.
 * @param symbol The symbol.
 * @param status The status.
 */
public void setStatus(String symbol,boolean status){
  _setStatus.put(symbol,status);
}

Fixed version (ground truth):
/** 
 * Set the status of the symbol to true, if the symbol is ready, and false otherwise.
 * @param symbol The symbol.
 * @param status The status.
 */
public void setStatus(String symbol,boolean status){
  if (_currentBranch || isForStatement) {
    _trueSetStatus.put(symbol,status);
  }
 else {
    _falseSetStatus.put(symbol,status);
  }
}
Program: 74774
Project: 74774
Buggy source:
/** 
 * Clean up any dynamic left hand sides added.
 */
public void removeDynamicLeftHandSides(){
  for (  String prefix : _unknownLeftSides.keySet()) {
    String suffix=evaluateString(_unknownLeftSides.get(prefix));
    if (suffix == null) {
      break;
    }
    String name=prefix + suffix;
    if (_parameters.containsKey(name)) {
      _parameters.remove(name);
    }
    if (_ports.containsKey(name)) {
      _parameters.remove(name);
    }
    if (_relations.containsKey(name)) {
      _relations.remove(name);
    }
    if (_transparencies.containsKey(name)) {
      _transparencies.remove(name);
    }
    if (_unknownExpressions.containsKey(name)) {
      _unknownExpressions.remove(name);
    }
    if (_unknownPrefixes.containsKey(name)) {
      _unknownExpressions.remove(name);
    }
  }
}

Fixed version (ground truth):
/** 
 * Clean up any dynamic left hand sides added.
 */
public void removeDynamicLeftHandSides(){
  for (  String prefix : _unknownLeftSides.keySet()) {
    String suffix=evaluateString(_unknownLeftSides.get(prefix));
    if (suffix == null) {
      continue;
    }
    String name=prefix + suffix;
    if (_parameters.containsKey(name)) {
      _parameters.remove(name);
    }
    if (_ports.containsKey(name)) {
      _parameters.remove(name);
    }
    if (_relations.containsKey(name)) {
      _relations.remove(name);
    }
    if (_transparencies.containsKey(name)) {
      _transparencies.remove(name);
    }
    if (_unknownExpressions.containsKey(name)) {
      _unknownExpressions.remove(name);
    }
    if (_unknownPrefixes.containsKey(name)) {
      _unknownPrefixes.remove(name);
    }
  }
}
Program: 74775
Project: 74775
Buggy source:
/** 
 * @return true if the current actor declaration is ready to be created.
 * @exception PtalonRuntimeException If it is thrown trying to access a parameter,or if there is no actor declaration to create..
 */
public boolean isActorReady() throws PtalonRuntimeException {
  if (_currentActorTree == null) {
    throw new PtalonRuntimeException("String_Node_Str");
  }
  if ((_currentActorTree.created)) {
    if (_inNewWhileIteration()) {
      int iteration=_currentActorTree.createdIteration;
      if ((iteration == 0) || (iteration == _currentIfTree.entered)) {
      }
 else {
        return false;
      }
    }
 else {
      return false;
    }
  }
  if (isReady()) {
    return _currentActorTree.isReady();
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @return true if the current actor declaration is ready to be created.
 * @exception PtalonRuntimeException If it is thrown trying to access a parameter,or if there is no actor declaration to create..
 */
public boolean isActorReady() throws PtalonRuntimeException {
  if (_currentActorTree == null) {
    throw new PtalonRuntimeException("String_Node_Str");
  }
  if ((_currentActorTree.created)) {
    if (_inNewWhileIteration()) {
      if (_currentIfTree.isForStatement) {
        int iteration=_currentActorTree.createdIteration;
        if ((iteration == 0) || (iteration == _currentIfTree.entered)) {
        }
 else {
          return false;
        }
      }
 else {
        IfTree tree=_currentIfTree;
        while (!tree.isForStatement) {
          tree=tree.getParent();
          if (tree == null) {
            throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
          }
        }
        int iteration=_currentActorTree.createdIteration;
        if ((iteration == 0) || (iteration == tree.entered)) {
        }
 else {
          return false;
        }
      }
    }
 else {
      return false;
    }
  }
  if (isReady()) {
    return _currentActorTree.isReady();
  }
  return false;
}
Program: 74778
Project: 74778
Buggy source:
/** 
 * Return a list of names corresponding to the identifiers defined by this scope.  If an identifier is returned in this list, then get() and getType() will return a value for the identifier.  Note that generally speaking, this list is extremely expensive to compute, and users should avoid calling it.  It is primarily used for debugging purposes.
 * @exception IllegalActionException If constructing the list causesit.
 */
public Set identifierSet() throws IllegalActionException {
  try {
    ;
    Set<String> out=getParameters();
    out.addAll(_variables.keySet());
    return out;
  }
 catch (  PtalonScopeException e) {
    throw new IllegalActionException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Return a list of names corresponding to the identifiers defined by this scope.  If an identifier is returned in this list, then get() and getType() will return a value for the identifier.  Note that generally speaking, this list is extremely expensive to compute, and users should avoid calling it.  It is primarily used for debugging purposes.
 * @exception IllegalActionException If constructing the list causesit.
 */
public Set identifierSet() throws IllegalActionException {
  try {
    ;
    Set<String> out=_getParameters();
    out.addAll(_variables.keySet());
    return out;
  }
 catch (  PtalonScopeException e) {
    throw new IllegalActionException("String_Node_Str");
  }
}
Program: 74779
Project: 74779
Buggy source:
/** 
 * Add a transparent to the PtalonActor with the specified name.  A transparent relation is not  really a relation.  Instead, it provides a means for connecting multiple ports to an input port.  It is transparent in that it provides an invisible means to connect to the specified 
 * @param name The name of the relation.
 */
public void addTransparentRelation(String name){
  _currentTree.setStatus(name,true);
}

Fixed version (ground truth):
/** 
 * Add a transparent to the PtalonActor with the specified name.  A transparent relation is not  really a relation.  Instead, it provides a means for connecting multiple ports to an input port.  It is transparent in that it provides an invisible means to connect to the specified 
 * @param name The name of the relation.
 */
public void addTransparentRelation(String name){
  _currentIfTree.setStatus(name,true);
  _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
}
Program: 74780
Project: 74780
Buggy source:
/** 
 * Exit the current if scope.
 * @exception PtalonRuntimeException If already at the top-level if scope.
 */
public void exitIfScope() throws PtalonRuntimeException {
  if (_currentTree.getParent() == null) {
    throw new PtalonRuntimeException("String_Node_Str");
  }
  _currentTree=_currentTree.getParent();
}

Fixed version (ground truth):
/** 
 * Exit the current if scope.
 * @exception PtalonRuntimeException If already at the top-level if scope.
 */
public void exitIfScope() throws PtalonRuntimeException {
  if (_currentIfTree.getParent() == null) {
    throw new PtalonRuntimeException("String_Node_Str");
  }
  _currentIfTree=_currentIfTree.getParent();
}
Program: 74781
Project: 74781
Buggy source:
/** 
 * Create a new CodeManager in the specified actor.
 * @param actor The actor to manage the code for.
 */
public CodeManager(PtalonActor actor){
  _actor=actor;
  _actorSet=false;
  _counter=0;
  _root=new IfTree(null,getNextIfSymbol());
  _root.setActiveBranch(true);
  _imports=new Hashtable<String,File>();
  _currentTree=_root;
}

Fixed version (ground truth):
/** 
 * Create a new CodeManager in the specified actor.
 * @param actor The actor to manage the code for.
 */
public CodeManager(PtalonActor actor){
  _actor=actor;
  _counter=0;
  _root=new IfTree(null,_getNextIfSymbol());
  _imports=new Hashtable<String,File>();
  _currentIfTree=_root;
}
Program: 74782
Project: 74782
Buggy source:
/** 
 * Set the next expression for the current for statement scope, assuming the current scope is a for statement and not an if statement.
 * @param nextExpr The expression to representthe next statement.
 */
public void setNextExpression(String nextExpr){
  _currentTree.nextExpr=nextExpr;
}

Fixed version (ground truth):
/** 
 * Set the next expression for the current for statement scope, assuming the current scope is a for statement and not an if statement.
 * @param nextExpr The expression to representthe next statement.
 */
public void setNextExpression(String nextExpr){
  _currentIfTree.nextExpr=nextExpr;
}
Program: 74783
Project: 74783
Buggy source:
/** 
 * Look up and return the type of the value with the specified name in the scope. Return null if the name is not defined in this scope.
 * @return The token associated with the given name in the scope.
 * @exception IllegalActionException If a value in the scopeexists with the given name, but cannot be evaluated.
 */
public Type getType(String name) throws IllegalActionException {
  try {
    if (_variables.containsKey(name)) {
      return _variables.get(name).getType();
    }
    if (!getTypeForScope(name).equals("String_Node_Str")) {
      throw new IllegalActionException(name + "String_Node_Str");
    }
    return getTypeOf(name);
  }
 catch (  PtalonScopeException e) {
    return null;
  }
catch (  PtalonRuntimeException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Look up and return the type of the value with the specified name in the scope. Return null if the name is not defined in this scope.
 * @return The token associated with the given name in the scope.
 * @exception IllegalActionException If a value in the scopeexists with the given name, but cannot be evaluated.
 */
public Type getType(String name) throws IllegalActionException {
  try {
    if (_variables.containsKey(name)) {
      return _variables.get(name).getType();
    }
    if (!_getTypeForScope(name).equals("String_Node_Str")) {
      throw new IllegalActionException(name + "String_Node_Str");
    }
    return _getTypeOf(name);
  }
 catch (  PtalonScopeException e) {
    return null;
  }
catch (  PtalonRuntimeException e) {
    return null;
  }
}
Program: 74784
Project: 74784
Buggy source:
/** 
 * Look up and return the type term for the specified name in the scope. Return null if the name is not defined in this scope, or is a constant type.
 * @return The InequalityTerm associated with the given name inthe scope.
 * @exception IllegalActionException If a value in the scopeexists with the given name, but cannot be evaluated.
 */
public InequalityTerm getTypeTerm(String name) throws IllegalActionException {
  try {
    if (_variables.containsKey(name)) {
      return null;
    }
    if (!getTypeForScope(name).equals("String_Node_Str")) {
      throw new IllegalActionException(name + "String_Node_Str");
    }
    return getTypeTermOf(name);
  }
 catch (  PtalonScopeException e) {
    return null;
  }
catch (  PtalonRuntimeException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Look up and return the type term for the specified name in the scope. Return null if the name is not defined in this scope, or is a constant type.
 * @return The InequalityTerm associated with the given name inthe scope.
 * @exception IllegalActionException If a value in the scopeexists with the given name, but cannot be evaluated.
 */
public InequalityTerm getTypeTerm(String name) throws IllegalActionException {
  try {
    if (_variables.containsKey(name)) {
      return null;
    }
    if (!_getTypeForScope(name).equals("String_Node_Str")) {
      throw new IllegalActionException(name + "String_Node_Str");
    }
    return _getTypeTermOf(name);
  }
 catch (  PtalonScopeException e) {
    return null;
  }
catch (  PtalonRuntimeException e) {
    return null;
  }
}
Program: 74785
Project: 74785
Buggy source:
/** 
 * Return true if the current peice of code is ready to be entered.  This is used by port, parameter, and relation declarations only.  It is ready when all ports, parameters, and relations in the containing scope have been created, when all parameters in the containing scope have been assigned values, and when in a branch of an if-block that is active.  
 * @return true if the current if-block scope is ready to be entered.
 * @exception PtalonRuntimeException If it is thrown trying to access a parameter.
 */
public boolean isReady() throws PtalonRuntimeException {
  IfTree parent=_currentTree.getParent();
  if (parent == null) {
    return true;
  }
  List<IfTree> ancestors=parent.getAncestors();
  for (  IfTree tree : ancestors) {
    if (!tree.isFullyAssigned()) {
      return false;
    }
  }
  if (_currentTree.getActiveBranch() == null) {
    return false;
  }
  return (_currentTree.getActiveBranch() == _currentTree.getCurrentBranch());
}

Fixed version (ground truth):
/** 
 * Return true if the current peice of code is ready to be entered.  This is used by port, parameter, and relation declarations only.  It is ready when all ports, parameters, and relations in the containing scope have been created, when all parameters in the containing scope have been assigned values, and when in a branch of an if-block that is active.  
 * @return true if the current if-block scope is ready to be entered.
 * @exception PtalonRuntimeException If it is thrown trying to access a parameter.
 */
public boolean isReady() throws PtalonRuntimeException {
  IfTree parent=_currentIfTree.getParent();
  if (parent == null) {
    return true;
  }
  List<IfTree> ancestors=parent.getAncestors();
  for (  IfTree tree : ancestors) {
    if (!tree.isFullyAssigned()) {
      return false;
    }
  }
  if (_currentIfTree.getActiveBranch() == null) {
    return false;
  }
  return (_currentIfTree.getActiveBranch() == _currentIfTree.getCurrentBranch());
}
Program: 74786
Project: 74786
Buggy source:
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name.
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(true);
    port.setOutput(true);
    if (_currentTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentTree.setStatus(name,true);
    _currentTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}

Fixed version (ground truth):
/** 
 * Add a TypedIOPort to the PtalonActor with the specified name.
 * @param name The name of the port.
 * @exception PtalonRuntimeException If the symbol does not exist, or ifthe symbol already has a port associated with it, or if an IllegalActionException is thrown trying to create the port.
 */
public void addPort(String name) throws PtalonRuntimeException {
  String uniqueName=_actor.uniqueName(name);
  try {
    TypedIOPort port=new TypedIOPort(_actor,uniqueName);
    port.setInput(true);
    port.setOutput(true);
    if (_currentIfTree.getType(name).equals("String_Node_Str")) {
      port.setMultiport(true);
    }
    _currentIfTree.setStatus(name,true);
    _currentIfTree.setEnteredIteration(name,_currentIfTree.entered);
    _currentIfTree.mapName(name,uniqueName);
  }
 catch (  NameDuplicationException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  IllegalActionException e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
catch (  PtalonScopeException e) {
    throw new PtalonRuntimeException("String_Node_Str" + name,e);
  }
}