Program: 75475
Project: 75475
Buggy source:
/** 
 * Create shadow variables for the port, if it is an input port, and otherwise do nothing. The shadow variables are contained by this actor and can be referenced in the guard and trigger expressions of transitions.  The shadow variables are lazy so that they are not evaluated until their values are needed, so the guard and trigger transitions should also be lazy. <p> If the given port is not a multiport, but is connected to something, then three variables are created: one is input status variable with name "<i>portName</i>_isPresent"; the second is input value variable with name "<i>portName</i>"; The third is input array variable with name "<i>portName</i>Array". The input status variable always contains a BooleanToken. When this actor is fired, the status variable is set to <i>true</i> if the port has a token, and to <i>false</i> otherwise. The input value variable always contains the latest token received from the port. The input array variable contains an ArrayToken, which contains an array of tokens when the port rate is greater than one. By default, its last token is the latest token, and  hence is the same token in input  value variable. <p> If the given port is a multiport, a status variable, a value variable, and an array variable are created for each channel.  The status variable is named  "<i>portName</i>_<i>channelIndex</i>_isPresent". The value variable is named "<i>portName</i>_<i>channelIndex</i>". The array variable is named "<i>portName</i>_<i>channelIndex</i>Array". <p> If a variable to be created has the same name as an attribute already contained by this actor, that attribute will be removed from this actor by setting its container to null.
 * @param port The port for which to create a shadow variable.
 * @exception IllegalActionException If the port is not containedby this FSMActor.
 */
protected void _createInputVariables(IOPort port) throws IllegalActionException {
  if (port.getContainer() != this) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (!port.isInput()) {
    return;
  }
  if (_inputVariableMap.get(port) != null) {
    _removeInputVariables(port);
  }
  int width=port.getWidth();
  if (width == 0) {
    return;
  }
  Variable[][] shadowVariables=new Variable[width][3];
  String portName=port.getName();
  for (int channelIndex=0; channelIndex < width; ++channelIndex) {
    String shadowName=null;
    if (port.isMultiport()) {
      shadowName=portName + "String_Node_Str" + channelIndex;
    }
 else {
      shadowName=portName;
    }
    String predicateName=shadowName + "String_Node_Str";
    Attribute previousAttribute=getAttribute(predicateName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][0]=new Variable(this,predicateName);
      shadowVariables[channelIndex][0].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InternalErrorException(getName() + "String_Node_Str" + "String_Node_Str"+ portName+ "String_Node_Str"+ ex.getMessage());
    }
    previousAttribute=getAttribute(shadowName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][1]=new Variable(this,shadowName);
      shadowVariables[channelIndex][1].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
    }
    String shadowArrayName=shadowName + "String_Node_Str";
    previousAttribute=getAttribute(shadowArrayName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][2]=new Variable(this,shadowArrayName);
      shadowVariables[channelIndex][2].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
    }
  }
  _inputVariableMap.put(port,shadowVariables);
}

Fixed version (ground truth):
/** 
 * Create shadow variables for the port, if it is an input port, and otherwise do nothing. The shadow variables are contained by this actor and can be referenced in the guard and trigger expressions of transitions.  The shadow variables are lazy so that they are not evaluated until their values are needed, so the guard and trigger transitions should also be lazy. <p> If the given port is not a multiport, but is connected to something, then three variables are created: one is input status variable with name "<i>portName</i>_isPresent"; the second is input value variable with name "<i>portName</i>"; The third is input array variable with name "<i>portName</i>Array". The input status variable always contains a BooleanToken. When this actor is fired, the status variable is set to <i>true</i> if the port has a token, and to <i>false</i> otherwise. The input value variable always contains the latest token received from the port. The input array variable contains an ArrayToken, which contains an array of tokens when the port rate is greater than one. By default, its last token is the latest token, and  hence is the same token in input  value variable. <p> If the given port is a multiport, a status variable, a value variable, and an array variable are created for each channel.  The status variable is named  "<i>portName</i>_<i>channelIndex</i>_isPresent". The value variable is named "<i>portName</i>_<i>channelIndex</i>". The array variable is named "<i>portName</i>_<i>channelIndex</i>Array". <p> If a variable to be created has the same name as an attribute already contained by this actor, that attribute will be removed from this actor by setting its container to null.
 * @param port The port for which to create a shadow variable.
 * @exception IllegalActionException If the port is not containedby this FSMActor.
 */
protected void _createInputVariables(IOPort port) throws IllegalActionException {
  if (port.getContainer() != this) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (!port.isInput()) {
    return;
  }
  if (_inputVariableMap.get(port) != null) {
    _removeInputVariables(port);
  }
  int width=port.getWidth();
  if (width == 0) {
    return;
  }
  Variable[][] shadowVariables=new Variable[width][3];
  String portName=port.getName();
  for (int channelIndex=0; channelIndex < width; ++channelIndex) {
    String shadowName=null;
    if (port.isMultiport()) {
      shadowName=portName + "String_Node_Str" + channelIndex;
    }
 else {
      shadowName=portName;
    }
    String predicateName=shadowName + "String_Node_Str";
    Attribute previousAttribute=getAttribute(predicateName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][0]=new Variable(this,predicateName);
      shadowVariables[channelIndex][0].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InternalErrorException(getName() + "String_Node_Str" + "String_Node_Str"+ portName+ "String_Node_Str"+ ex.getMessage());
    }
    previousAttribute=getAttribute(shadowName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][1]=new Variable(this,shadowName);
      shadowVariables[channelIndex][1].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
    }
    String shadowArrayName=shadowName + "String_Node_Str";
    previousAttribute=getAttribute(shadowArrayName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][2]=new Variable(this,shadowArrayName);
      shadowVariables[channelIndex][2].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
    }
  }
  _inputVariableMap.put(port,shadowVariables);
  _inputVariableVersion=_workspace.getVersion();
}