Program: 76272
Project: 76272
Buggy source:
/** 
 * Return true if it transfers data from an output port of the current refinement (an opaque composite actor) to the ports it is connected to on the outside. This method will transfer all available tokens on channel 0 of the output port. Put the transfered data in the FIFO token queue associated with the output 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 output port.  If  channel 0 of the output 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 output port and that is connected to the output port. Therefore, it is necessary that all output 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 output port to transfer data from.
 * @exception IllegalActionException If the port is not an opaqueoutput port or if the port is not connected to the current refining state of the FSM.
 * @return True if data are transfered.
 */
public boolean transferOutputs(IOPort port) throws IllegalActionException {
  if (_debugging)   _debug("String_Node_Str" + port.getName());
  if (!port.isOutput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  boolean trans=false;
  Receiver insideReceiver=(port.getInsideReceivers())[0][0];
  CompositeActor cont=(CompositeActor)getContainer();
  IOPort p=(IOPort)cont.getPort(port.getName());
  ArrayFIFOQueue guardTokenArray=(ArrayFIFOQueue)_portNameToArrayFIFOQueue.get(p.getFullName());
  while (insideReceiver.hasToken()) {
    try {
      Token t=insideReceiver.get();
      guardTokenArray.take();
      guardTokenArray.put(t);
      _controller.currentState().setLocalInputVar(port.getName(),t);
      if (p != null) {
        Receiver rec=(p.getInsideReceivers())[0][0];
        rec.put(t);
        if (_debugging)         _debug("String_Node_Str");
      }
 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" + "String_Node_Str" + ex.getMessage());
    }
  }
  Variable[] guardVarArray=(Variable[])_outputPortNameToVariableArray.get(p.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 output port of the current refinement (an opaque composite actor) to the ports it is connected to on the outside. This method will transfer all available tokens on channel 0 of the output port. Put the transfered data in the FIFO token queue associated with the output 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 output port.  If  channel 0 of the output 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 output port and that is connected to the output port. Therefore, it is necessary that all output 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 output port to transfer data from.
 * @exception IllegalActionException If the port is not an opaqueoutput port or if the port is not connected to the current refining state of the FSM.
 * @return True if data are transfered.
 */
public boolean transferOutputs(IOPort port) throws IllegalActionException {
  if (!port.isOutput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  boolean trans=false;
  Receiver insideReceiver=(port.getInsideReceivers())[0][0];
  CompositeActor cont=(CompositeActor)getContainer();
  IOPort p=(IOPort)cont.getPort(port.getName());
  ArrayFIFOQueue guardTokenArray=(ArrayFIFOQueue)_portNameToArrayFIFOQueue.get(p.getFullName());
  while (insideReceiver.hasToken()) {
    try {
      Token t=insideReceiver.get();
      guardTokenArray.take();
      guardTokenArray.put(t);
      _controller.currentState().setLocalInputVar(port.getName(),t);
      if (p != null) {
        Receiver rec=(p.getInsideReceivers())[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" + "String_Node_Str" + ex.getMessage());
    }
  }
  Variable[] guardVarArray=(Variable[])_outputPortNameToVariableArray.get(p.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;
}