Program: 74041
Project: 74041
Buggy source:
/** 
 * Return the list of property constraints.
 * @return The list of property constraints.
 * @exception IllegalActionException If{@link #_constraintObject(ConstraintType,Object,List)} throws it.
 */
public List<Inequality> constraintList() throws IllegalActionException {
  HashMap<NamedObj,List<ASTPtRootNode>> outputActionMap=new HashMap<NamedObj,List<ASTPtRootNode>>();
  HashMap<NamedObj,List<ASTPtRootNode>> setActionMap=new HashMap<NamedObj,List<ASTPtRootNode>>();
  ptolemy.domains.fsm.kernel.FSMActor actor=(ptolemy.domains.fsm.kernel.FSMActor)getComponent();
  List propertyableList=getPropertyables();
  Iterator states=actor.entityList(State.class).iterator();
  while (states.hasNext()) {
    State state=(State)states.next();
    Iterator transitions=state.outgoingPort.linkedRelationList().iterator();
    while (transitions.hasNext()) {
      Transition transition=(Transition)transitions.next();
      Iterator propertyables=propertyableList.iterator();
      while (propertyables.hasNext()) {
        Object propertyable=propertyables.next();
        if (propertyable instanceof NamedObj) {
          NamedObj namedObj=(NamedObj)propertyable;
          OutputActionsAttribute outputActions=transition.outputActions;
          if (outputActions.getDestinationNameList().contains(namedObj.getName())) {
            ASTPtRootNode parseTree=outputActions.getParseTree(namedObj.getName());
            if (!outputActionMap.containsKey(namedObj)) {
              outputActionMap.put(namedObj,new ArrayList<ASTPtRootNode>());
            }
            outputActionMap.get(namedObj).add(parseTree);
          }
          CommitActionsAttribute setActions=transition.setActions;
          if (setActions.getDestinationNameList().contains(namedObj.getName())) {
            ASTPtRootNode parseTree=setActions.getParseTree(namedObj.getName());
            if (!setActionMap.containsKey(namedObj)) {
              setActionMap.put(namedObj,new ArrayList<ASTPtRootNode>());
            }
            setActionMap.get(namedObj).add(parseTree);
          }
        }
      }
    }
  }
  boolean constraintSource=interconnectConstraintType == ConstraintType.SRC_EQUALS_MEET || interconnectConstraintType == ConstraintType.SRC_EQUALS_GREATER;
  Iterator outputActions=outputActionMap.entrySet().iterator();
  while (outputActions.hasNext()) {
    Entry entry=(Entry)outputActions.next();
    Object destination=entry.getKey();
    List<Object> expressions=(List<Object>)entry.getValue();
    if (constraintSource) {
      Iterator roots=expressions.iterator();
      while (roots.hasNext()) {
        ASTPtRootNode root=(ASTPtRootNode)roots.next();
        List<Object> sinkAsList=new ArrayList<Object>();
        sinkAsList.add(destination);
        _constraintObject(interconnectConstraintType,root,sinkAsList);
      }
    }
 else {
      _constraintObject(interconnectConstraintType,destination,expressions);
    }
  }
  Iterator setActions=setActionMap.entrySet().iterator();
  while (setActions.hasNext()) {
    Entry entry=(Entry)setActions.next();
    Object destination=entry.getKey();
    List<Object> expressions=(List<Object>)entry.getValue();
    if (constraintSource) {
      Iterator roots=expressions.iterator();
      while (roots.hasNext()) {
        ASTPtRootNode root=(ASTPtRootNode)roots.next();
        List<Object> sinkAsList=new ArrayList<Object>();
        sinkAsList.add(destination);
        _constraintObject(interconnectConstraintType,root,sinkAsList);
      }
    }
 else {
      _constraintObject(interconnectConstraintType,destination,expressions);
    }
  }
  _checkIneffectiveOutputPorts(actor,outputActionMap.keySet(),setActionMap.keySet());
  return _union(_ownConstraints,_subHelperConstraints);
}

Fixed version (ground truth):
/** 
 * Return the list of property constraints. Return the constraints for the setAction and outputAction expressions associated with transitions of each contained states. For example, if there is a setAction for assigning the value of the variable V, this creates constraints between the properties of V and the assigned expression.
 * @return The list of property constraints.
 * @exception IllegalActionException Thrown if any error occurs whencreating the constraints.
 */
public List<Inequality> constraintList() throws IllegalActionException {
  ptolemy.domains.fsm.kernel.FSMActor actor=(ptolemy.domains.fsm.kernel.FSMActor)getComponent();
  HashMap<NamedObj,List<ASTPtRootNode>> outputActionMap=new HashMap<NamedObj,List<ASTPtRootNode>>();
  HashMap<NamedObj,List<ASTPtRootNode>> setActionMap=new HashMap<NamedObj,List<ASTPtRootNode>>();
  for (  State state : (List<State>)actor.entityList(State.class)) {
    List<Transition> transitions=state.outgoingPort.linkedRelationList();
    for (    Transition transition : transitions) {
      for (      Object propertyable : getPropertyables()) {
        if (propertyable instanceof NamedObj) {
          NamedObj namedObj=(NamedObj)propertyable;
          OutputActionsAttribute outputActions=transition.outputActions;
          if (outputActions.getDestinationNameList().contains(namedObj.getName())) {
            ASTPtRootNode parseTree=outputActions.getParseTree(namedObj.getName());
            if (!outputActionMap.containsKey(namedObj)) {
              outputActionMap.put(namedObj,new ArrayList<ASTPtRootNode>());
            }
            outputActionMap.get(namedObj).add(parseTree);
          }
          CommitActionsAttribute setActions=transition.setActions;
          if (setActions.getDestinationNameList().contains(namedObj.getName())) {
            ASTPtRootNode parseTree=setActions.getParseTree(namedObj.getName());
            if (!setActionMap.containsKey(namedObj)) {
              setActionMap.put(namedObj,new ArrayList<ASTPtRootNode>());
            }
            setActionMap.get(namedObj).add(parseTree);
          }
        }
      }
    }
  }
  boolean constraintSource=interconnectConstraintType == ConstraintType.SRC_EQUALS_MEET || interconnectConstraintType == ConstraintType.SRC_EQUALS_GREATER;
  for (  Entry entry : outputActionMap.entrySet()) {
    Object destination=entry.getKey();
    List<ASTPtRootNode> expressions=(List<ASTPtRootNode>)entry.getValue();
    if (constraintSource) {
      for (      ASTPtRootNode root : expressions) {
        List<Object> sinkAsList=new ArrayList<Object>();
        sinkAsList.add(destination);
        _constraintObject(interconnectConstraintType,root,sinkAsList);
      }
    }
 else {
      _constraintObject(interconnectConstraintType,destination,expressions);
    }
  }
  for (  Entry entry : setActionMap.entrySet()) {
    Object destination=entry.getKey();
    List<ASTPtRootNode> expressions=(List<ASTPtRootNode>)entry.getValue();
    if (constraintSource) {
      for (      ASTPtRootNode root : expressions) {
        List<Object> sinkAsList=new ArrayList<Object>();
        sinkAsList.add(destination);
        _constraintObject(interconnectConstraintType,root,sinkAsList);
      }
    }
 else {
      _constraintObject(interconnectConstraintType,destination,expressions);
    }
  }
  _checkIneffectiveOutputPorts(actor,outputActionMap.keySet(),setActionMap.keySet());
  return _union(_ownConstraints,_subHelperConstraints);
}