Program: 76267
Project: 76267
Buggy source:
/** 
 * Return true if it transfers data from an input port of the container to the port(s) of the current refinement (an opaque composite actor). This method will transfer all available tokens on channel 0 of the input port. Put the transfered data in the FIFO token queue associated with the input port. This token queue has a length set by setGuardTokenHistory(). The token queue is used when evaluating state transition expressions. <p> The port argument must be an opaque input port.  If  channel 0 of the input port has no data, then that channel is ignored. <p> This assumes that the name of the refining state's port must have the same name  as the input port and is connected to the input port. Therefore, it is necessary that all input ports of a heterochronous dataflow actor that refines to an FSM be connected to the corresponding ports (with the same name) of all of the refining states in the FSM.
 * @param port The input port to transfer data from.
 * @exception IllegalActionException If the port is not an opaqueinput port or if the port is not connected to the current refining state of the FSM.
 * @return True if data are transfered.
 */
public boolean transferInputs(IOPort port) throws IllegalActionException {
  if (!port.isInput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  boolean trans=false;
  Entity refine=(Entity)_controller.currentRefinement();
  if (refine == null) {
    if (_debugging)     _debug("String_Node_Str");
  }
 else {
    if (_debugging)     _debug("String_Node_Str" + refine.getFullName());
  }
  IOPort p;
  Receiver rec;
  ArrayFIFOQueue guardTokenArray=(ArrayFIFOQueue)_portNameToArrayFIFOQueue.get(port.getFullName());
  Token t=null;
  while (port.hasToken(0)) {
    try {
      t=port.get(0);
      guardTokenArray.take();
      guardTokenArray.put(t);
      if (_debugging)       _debug("String_Node_Str" + port.getFullName() + "String_Node_Str");
      if (_debugging)       _debug("String_Node_Str" + t.toString());
      if (_debugging)       _debug("String_Node_Str" + port.getName());
      if (_controller == null) {
        System.out.println("String_Node_Str");
      }
 else       if (refine == null) {
        if (_debugging)         _debug("String_Node_Str");
      }
 else {
        for (Enumeration e=refine.getPorts(); e.hasMoreElements(); ) {
          if (_debugging)           _debug("String_Node_Str" + e.nextElement());
        }
      }
      p=(IOPort)refine.getPort(port.getName());
      if (p != null) {
        rec=(p.getReceivers())[0][0];
        if (_debugging)         _debug("String_Node_Str");
        rec.put(t);
      }
 else {
        if (_debugging)         _debug("String_Node_Str");
        throw new IllegalActionException(this,port,"String_Node_Str");
      }
      trans=true;
    }
 catch (    NoTokenException ex) {
      throw new InternalErrorException("String_Node_Str" + ex.getMessage());
    }
  }
  Variable[] guardVarArray=(Variable[])_inputPortNameToVariableArray.get(port.getFullName());
  if (guardVarArray == null) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  int i;
  for (i=0; i < guardVarArray.length; i++) {
    (guardVarArray[i]).setToken((Token)guardTokenArray.get(guardVarArray.length - 1 - i));
  }
  return trans;
}

Fixed version (ground truth):
/** 
 * Return true if it transfers data from an input port of the container to the port(s) of the current refinement (an opaque composite actor). This method will transfer all available tokens on channel 0 of the input port. Put the transfered data in the FIFO token queue associated with the input port. This token queue has a length set by setGuardTokenHistory(). The token queue is used when evaluating state transition expressions. <p> The port argument must be an opaque input port.  If  channel 0 of the input port has no data, then that channel is ignored. <p> This assumes that the name of the refining state's port must have the same name  as the input port and is connected to the input port. Therefore, it is necessary that all input ports of a heterochronous dataflow actor that refines to an FSM be connected to the corresponding ports (with the same name) of all of the refining states in the FSM.
 * @param port The input port to transfer data from.
 * @exception IllegalActionException If the port is not an opaqueinput port or if the port is not connected to the current refining state of the FSM.
 * @return True if data are transfered.
 */
public boolean transferInputs(IOPort port) throws IllegalActionException {
  if (!port.isInput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  boolean trans=false;
  Entity refine=(Entity)_controller.currentRefinement();
  if (refine == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
 else {
  }
  IOPort p;
  Receiver rec;
  ArrayFIFOQueue guardTokenArray=(ArrayFIFOQueue)_portNameToArrayFIFOQueue.get(port.getFullName());
  Token t=null;
  while (port.hasToken(0)) {
    try {
      t=port.get(0);
      guardTokenArray.take();
      guardTokenArray.put(t);
      if (_controller == null) {
        throw new IllegalActionException(this,"String_Node_Str");
      }
 else       if (refine == null) {
        throw new IllegalActionException(this,"String_Node_Str");
      }
 else {
      }
      p=(IOPort)refine.getPort(port.getName());
      if (p != null) {
        rec=(p.getReceivers())[0][0];
        rec.put(t);
      }
 else {
        throw new IllegalActionException(this,port,"String_Node_Str");
      }
      trans=true;
    }
 catch (    NoTokenException ex) {
      throw new InternalErrorException("String_Node_Str" + ex.getMessage());
    }
  }
  Variable[] guardVarArray=(Variable[])_inputPortNameToVariableArray.get(port.getFullName());
  if (guardVarArray == null) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  int i;
  for (i=0; i < guardVarArray.length; i++) {
    (guardVarArray[i]).setToken((Token)guardTokenArray.get(guardVarArray.length - 1 - i));
  }
  return trans;
}