Program: 74471
Project: 74471
Buggy source:
/** 
 * This function is trying to generate the definition for modules contained in a controller. It need to check whether a signal is visible by the controller. If not, then this signal should be passed from outside, and the required signal set (extended by guard signals) for the controller should add up this signal. If a signal is visible by the controller, then we know that this signal is only passed between modules of the controller. We can list out the location of the signal.
 * @param controller The controller which contains those modules
 * @return An ArrayList containing all submodule definitions
 * @throws IllegalActionException Undefined behavior happens.
 */
private static ArrayList<StringBuffer> _retrieveSubSystemModuleNameParameterInfo(FSMActor controller) throws IllegalActionException {
  ArrayList<StringBuffer> returnList=new ArrayList<StringBuffer>();
  Iterator states=controller.entityList().iterator();
  while (states.hasNext()) {
    NamedObj state=(NamedObj)states.next();
    if (state instanceof State) {
      String refinementList=((State)state).refinementName.getExpression();
      if ((refinementList == null) || (refinementList.equalsIgnoreCase("String_Node_Str"))) {
        continue;
      }
 else {
        TypedActor[] actors=((State)state).getRefinement();
        if (actors != null) {
          if (actors.length == 1) {
            TypedActor innerActor=actors[0];
            if (innerActor instanceof FSMActor) {
              StringBuffer moduleDescription=new StringBuffer("String_Node_Str");
              moduleDescription.append("String_Node_Str" + innerActor.getName() + "String_Node_Str"+ innerActor.getName()+ "String_Node_Str");
              ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerActor.getName());
              if (signalInfo != null) {
                for (int i=0; i < signalInfo.size(); i++) {
                  String signalName=signalInfo.get(i);
                  boolean containInTheSystem=false;
                  boolean containInTheModule=false;
                  String location="String_Node_Str";
                  Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
                  while (it.hasNext()) {
                    String place=it.next();
                    if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                      location=place;
                      containInTheSystem=true;
                      break;
                    }
                  }
                  if (_globalSignalNestedRetrivalInfo.get(controller.getName()).contains(signalName)) {
                    containInTheModule=true;
                  }
                  if (containInTheSystem == true) {
                    if (containInTheModule == true) {
                      if (i == signalInfo.size() - 1) {
                        moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                      }
 else {
                        moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                      }
                    }
 else {
                      if (_globalSignalDistributionInfo.get(controller.getName()).contains(signalName) == false) {
                        _globalSignalDistributionInfo.get(controller.getName()).add(signalName);
                      }
                      if (i == signalInfo.size() - 1) {
                        moduleDescription.append(signalName + "String_Node_Str");
                      }
 else {
                        moduleDescription.append(signalName + "String_Node_Str");
                      }
                    }
                  }
 else {
                    if (i == signalInfo.size() - 1) {
                      moduleDescription.append("String_Node_Str");
                    }
 else {
                      moduleDescription.append("String_Node_Str");
                    }
                  }
                }
              }
              if ((signalInfo != null) && (signalInfo.size() > 0)) {
                moduleDescription.append("String_Node_Str");
              }
 else {
                moduleDescription.append("String_Node_Str");
              }
              returnList.add(moduleDescription);
            }
 else             if (innerActor instanceof CompositeActor) {
              Director director=((CompositeActor)innerActor).getDirector();
              if (!(director instanceof SRDirector)) {
                throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
              }
 else {
                for (Iterator innerInnerActors=(((CompositeActor)innerActor).entityList()).iterator(); innerInnerActors.hasNext(); ) {
                  StringBuffer moduleDescription=new StringBuffer("String_Node_Str");
                  Entity innerInnerEntity=(Entity)innerInnerActors.next();
                  if (innerInnerEntity instanceof FSMActor) {
                    moduleDescription.append("String_Node_Str" + innerInnerEntity.getName() + "String_Node_Str"+ innerInnerEntity.getName()+ "String_Node_Str");
                    ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerInnerEntity.getName());
                    if (signalInfo != null) {
                      for (int i=0; i < signalInfo.size(); i++) {
                        String signalName=signalInfo.get(i);
                        boolean containInTheSystem=false;
                        boolean containInTheModule=false;
                        String location="String_Node_Str";
                        Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
                        while (it.hasNext()) {
                          String place=it.next();
                          if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                            location=place;
                            containInTheSystem=true;
                            break;
                          }
                        }
                        if (_globalSignalNestedRetrivalInfo.get(controller.getName()).contains(signalName) == true) {
                          containInTheModule=true;
                        }
                        if (containInTheSystem == true) {
                          if (containInTheModule == true) {
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
 else {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
                          }
 else {
                            if (_globalSignalDistributionInfo.get(controller.getName()).contains(signalName) == false) {
                              _globalSignalDistributionInfo.get(controller.getName()).add(signalName);
                            }
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
 else {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
                          }
                        }
 else {
                          if (i == signalInfo.size() - 1) {
                            moduleDescription.append("String_Node_Str");
                          }
 else {
                            moduleDescription.append("String_Node_Str");
                          }
                        }
                      }
                    }
                    if ((signalInfo != null) && (signalInfo.size() > 0)) {
                      moduleDescription.append("String_Node_Str");
                    }
 else {
                      moduleDescription.append("String_Node_Str");
                    }
                    returnList.add(moduleDescription);
                  }
 else                   if (innerInnerEntity instanceof ModalModel) {
                    moduleDescription.append("String_Node_Str" + innerInnerEntity.getName() + "String_Node_Str"+ innerInnerEntity.getName()+ "String_Node_Str");
                    ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerInnerEntity.getName());
                    if (signalInfo != null) {
                      for (int i=0; i < signalInfo.size(); i++) {
                        String signalName=signalInfo.get(i);
                        boolean containInTheSystem=false;
                        boolean containInTheModule=false;
                        String location="String_Node_Str";
                        Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
                        while (it.hasNext()) {
                          String place=it.next();
                          if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                            location=place;
                            containInTheSystem=true;
                            break;
                          }
                        }
                        if (_globalSignalNestedRetrivalInfo.get(controller.getName()).contains(signalName) == true) {
                          containInTheModule=true;
                        }
                        if (containInTheSystem == true) {
                          if (containInTheModule == true) {
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
 else {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
                          }
 else {
                            if (_globalSignalDistributionInfo.get(controller.getName()).contains(signalName) == false) {
                              _globalSignalDistributionInfo.get(controller.getName()).add(signalName);
                            }
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
 else {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
                          }
                        }
 else {
                          if (i == signalInfo.size() - 1) {
                            moduleDescription.append("String_Node_Str");
                          }
 else {
                            moduleDescription.append("String_Node_Str");
                          }
                        }
                      }
                    }
                    if ((signalInfo != null) && (signalInfo.size() > 0)) {
                      moduleDescription.append("String_Node_Str");
                    }
 else {
                      moduleDescription.append("String_Node_Str");
                    }
                    returnList.add(moduleDescription);
                  }
                }
              }
            }
 else {
            }
          }
 else {
            throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
          }
        }
      }
    }
  }
  return returnList;
}

Fixed version (ground truth):
/** 
 * This function is trying to generate the definition for modules contained in a controller. It need to check whether a signal is visible by the controller. If not, then this signal should be passed from outside, and the required signal set (extended by guard signals) for the controller should add up this signal. If a signal is visible by the controller, then we know that this signal is only passed between modules of the controller. We can list out the location of the signal.
 * @param controller The controller which contains those modules
 * @return An ArrayList containing all submodule definitions
 * @throws IllegalActionException Undefined behavior happens.
 */
private static ArrayList<StringBuffer> _retrieveSubSystemModuleNameParameterInfo(FSMActor controller) throws IllegalActionException {
  ArrayList<StringBuffer> returnList=new ArrayList<StringBuffer>();
  Iterator states=controller.entityList().iterator();
  while (states.hasNext()) {
    NamedObj state=(NamedObj)states.next();
    if (state instanceof State) {
      String refinementList=((State)state).refinementName.getExpression();
      if ((refinementList == null) || (refinementList.equalsIgnoreCase("String_Node_Str"))) {
        continue;
      }
 else {
        TypedActor[] actors=((State)state).getRefinement();
        if (actors != null) {
          if (actors.length == 1) {
            TypedActor innerActor=actors[0];
            if (innerActor instanceof FSMActor) {
              StringBuffer moduleDescription=new StringBuffer("String_Node_Str");
              moduleDescription.append("String_Node_Str" + innerActor.getName() + "String_Node_Str"+ innerActor.getName()+ "String_Node_Str");
              ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerActor.getName());
              if (signalInfo != null) {
                for (int i=0; i < signalInfo.size(); i++) {
                  String signalName=signalInfo.get(i);
                  boolean containInTheSystem=false;
                  boolean containInTheModule=false;
                  String location="String_Node_Str";
                  Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
                  while (it.hasNext()) {
                    String place=it.next();
                    if (_globalSignalRetrivalInfo.get(place) != null) {
                      if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                        location=place;
                        containInTheSystem=true;
                        break;
                      }
                    }
                  }
                  if (_globalSignalNestedRetrivalInfo.get(controller.getName()) != null) {
                    if (_globalSignalNestedRetrivalInfo.get(controller.getName()).contains(signalName)) {
                      containInTheModule=true;
                    }
                  }
                  if (containInTheSystem == true) {
                    if (containInTheModule == true) {
                      if (i == signalInfo.size() - 1) {
                        moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                      }
 else {
                        moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                      }
                    }
 else {
                      if (_globalSignalDistributionInfo.get(controller.getName()) != null) {
                        if (_globalSignalDistributionInfo.get(controller.getName()).contains(signalName) == false) {
                          _globalSignalDistributionInfo.get(controller.getName()).add(signalName);
                        }
                      }
                      if (i == signalInfo.size() - 1) {
                        moduleDescription.append(signalName + "String_Node_Str");
                      }
 else {
                        moduleDescription.append(signalName + "String_Node_Str");
                      }
                    }
                  }
 else {
                    if (i == signalInfo.size() - 1) {
                      moduleDescription.append("String_Node_Str");
                    }
 else {
                      moduleDescription.append("String_Node_Str");
                    }
                  }
                }
              }
              if ((signalInfo != null) && (signalInfo.size() > 0)) {
                moduleDescription.append("String_Node_Str");
              }
 else {
                moduleDescription.append("String_Node_Str");
              }
              returnList.add(moduleDescription);
            }
 else             if (innerActor instanceof CompositeActor) {
              Director director=((CompositeActor)innerActor).getDirector();
              if (!(director instanceof SRDirector)) {
                throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
              }
 else {
                for (Iterator innerInnerActors=(((CompositeActor)innerActor).entityList()).iterator(); innerInnerActors.hasNext(); ) {
                  StringBuffer moduleDescription=new StringBuffer("String_Node_Str");
                  Entity innerInnerEntity=(Entity)innerInnerActors.next();
                  if (innerInnerEntity instanceof FSMActor) {
                    moduleDescription.append("String_Node_Str" + innerInnerEntity.getName() + "String_Node_Str"+ innerInnerEntity.getName()+ "String_Node_Str");
                    ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerInnerEntity.getName());
                    if (signalInfo != null) {
                      for (int i=0; i < signalInfo.size(); i++) {
                        String signalName=signalInfo.get(i);
                        boolean containInTheSystem=false;
                        boolean containInTheModule=false;
                        String location="String_Node_Str";
                        Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
                        while (it.hasNext()) {
                          String place=it.next();
                          if (_globalSignalRetrivalInfo.get(place) != null) {
                            if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                              location=place;
                              containInTheSystem=true;
                              break;
                            }
                          }
                        }
                        if (_globalSignalNestedRetrivalInfo.get(controller.getName()) != null) {
                          if (_globalSignalNestedRetrivalInfo.get(controller.getName()).contains(signalName) == true) {
                            containInTheModule=true;
                          }
                        }
                        if (containInTheSystem == true) {
                          if (containInTheModule == true) {
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
 else {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
                          }
 else {
                            if (_globalSignalDistributionInfo.get(controller.getName()) != null) {
                              if (_globalSignalDistributionInfo.get(controller.getName()).contains(signalName) == false) {
                                _globalSignalDistributionInfo.get(controller.getName()).add(signalName);
                              }
                            }
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
 else {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
                          }
                        }
 else {
                          if (i == signalInfo.size() - 1) {
                            moduleDescription.append("String_Node_Str");
                          }
 else {
                            moduleDescription.append("String_Node_Str");
                          }
                        }
                      }
                    }
                    if ((signalInfo != null) && (signalInfo.size() > 0)) {
                      moduleDescription.append("String_Node_Str");
                    }
 else {
                      moduleDescription.append("String_Node_Str");
                    }
                    returnList.add(moduleDescription);
                  }
 else                   if (innerInnerEntity instanceof ModalModel) {
                    moduleDescription.append("String_Node_Str" + innerInnerEntity.getName() + "String_Node_Str"+ innerInnerEntity.getName()+ "String_Node_Str");
                    ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerInnerEntity.getName());
                    if (signalInfo != null) {
                      for (int i=0; i < signalInfo.size(); i++) {
                        String signalName=signalInfo.get(i);
                        boolean containInTheSystem=false;
                        boolean containInTheModule=false;
                        String location="String_Node_Str";
                        Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
                        while (it.hasNext()) {
                          String place=it.next();
                          if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                            location=place;
                            containInTheSystem=true;
                            break;
                          }
                        }
                        if (_globalSignalNestedRetrivalInfo.get(controller.getName()) != null) {
                          if (_globalSignalNestedRetrivalInfo.get(controller.getName()).contains(signalName) == true) {
                            containInTheModule=true;
                          }
                        }
                        if (containInTheSystem == true) {
                          if (containInTheModule == true) {
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
 else {
                              moduleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
                            }
                          }
 else {
                            if (_globalSignalDistributionInfo.get(controller.getName()) != null) {
                              if (_globalSignalDistributionInfo.get(controller.getName()).contains(signalName) == false) {
                                _globalSignalDistributionInfo.get(controller.getName()).add(signalName);
                              }
                            }
                            if (i == signalInfo.size() - 1) {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
 else {
                              moduleDescription.append(signalName + "String_Node_Str");
                            }
                          }
                        }
 else {
                          if (i == signalInfo.size() - 1) {
                            moduleDescription.append("String_Node_Str");
                          }
 else {
                            moduleDescription.append("String_Node_Str");
                          }
                        }
                      }
                    }
                    if ((signalInfo != null) && (signalInfo.size() > 0)) {
                      moduleDescription.append("String_Node_Str");
                    }
 else {
                      moduleDescription.append("String_Node_Str");
                    }
                    returnList.add(moduleDescription);
                  }
                }
              }
            }
 else {
            }
          }
 else {
            throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
          }
        }
      }
    }
  }
  return returnList;
}