Program: 74603
Project: 74603
Buggy source:
/** 
 * Add an actor to the PtalonActor.  In the case of an actor specified by an import statement, the actor will be a PtalonActor.  In the case of an actor specified by a  parameter, the actor will be arbitrary.
 * @param name The unique name of the actor declaration.
 * @exception PtalonRuntimeException If there is any troubleloading the actor.
 */
public void addActor(String name) throws PtalonRuntimeException {
  try {
    if (_currentActorTree == null) {
      throw new PtalonRuntimeException("String_Node_Str");
    }
    String symbol=_currentActorTree.getSymbol();
    if (symbol.equals("String_Node_Str")) {
      _currentActorTree.created=true;
      if (_inNewWhileIteration()) {
        if (_currentIfTree.isForStatement) {
          _currentActorTree.createdIteration=_currentIfTree.entered;
        }
 else {
          IfTree tree=_currentIfTree;
          while (!tree.isForStatement) {
            tree=tree.getParent();
            if (tree == null) {
              throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
            }
          }
          _currentActorTree.createdIteration=tree.entered;
        }
      }
 else {
        _currentActorTree.createdIteration=_currentIfTree.entered;
      }
      _currentActorTree.assignPtalonParameters(_actor);
      _currentActorTree.makeThisConnections();
      _currentActorTree.removeDynamicLeftHandSides();
      return;
    }
    String uniqueName=_actor.uniqueName(symbol);
    if (_getType(symbol).equals("String_Node_Str")) {
      PtalonActor actor=new PtalonActor(_actor,uniqueName);
      FileParameter location=actor.ptalonCodeLocation;
      File file=_imports.get(symbol);
      location.setToken(new StringToken(file.toString()));
      actor.setNestedDepth(_actor.getNestedDepth() + 1);
      _currentActorTree.assignPtalonParameters(actor);
      _currentActorTree.makeConnections(actor);
      _currentActorTree.removeDynamicLeftHandSides();
    }
 else     if (_getType(symbol).equals("String_Node_Str")) {
      PtalonParameter parameter=(PtalonParameter)_actor.getAttribute(getMappedName(symbol));
      if (!parameter.hasValue()) {
        throw new PtalonRuntimeException("String_Node_Str" + symbol + "String_Node_Str");
      }
      String expression=parameter.getExpression();
      String[] parsedExpression;
      if (expression.contains("String_Node_Str")) {
        parsedExpression=_parseActorExpression(expression);
      }
 else {
        parsedExpression=new String[1];
        parsedExpression[0]=expression;
      }
      String actor=parsedExpression[0];
      if (actor.startsWith("String_Node_Str")) {
        File file=new File(_parameterToImport(actor));
        PtalonActor ptalonActor=new PtalonActor(_actor,uniqueName);
        ptalonActor.ptalonCodeLocation.setToken(new StringToken(file.toString()));
        ptalonActor.setNestedDepth(_actor.getNestedDepth() + 1);
        for (int i=1; i < parsedExpression.length; i=i + 2) {
          String lhs=parsedExpression[i];
          String rhs=parsedExpression[i + 1];
          if (rhs.startsWith("String_Node_Str")) {
            rhs=rhs.substring(1,rhs.length() - 2);
          }
          Parameter param=(Parameter)ptalonActor.getAttribute(lhs);
          param.setToken(rhs);
        }
        _currentActorTree.assignPtalonParameters(ptalonActor);
        _currentActorTree.makeConnections(ptalonActor);
        _currentActorTree.removeDynamicLeftHandSides();
      }
 else {
        NamedObj context=_actor;
        MoMLParser momlParser=null;
        if (context != null) {
          momlParser=ParserAttribute.getParser(context);
          momlParser.reset();
        }
        if (momlParser == null) {
          momlParser=new MoMLParser();
        }
        if (context != null) {
          momlParser.setContext(context);
        }
        String description="String_Node_Str" + uniqueName + "String_Node_Str"+ actor+ "String_Node_Str";
        momlParser.parse(null,description);
        ComponentEntity entity=_actor.getEntity(uniqueName);
        if (entity == null) {
          throw new PtalonRuntimeException("String_Node_Str");
        }
        for (int i=1; i < parsedExpression.length; i=i + 2) {
          String lhs=parsedExpression[i];
          String rhs=parsedExpression[i + 1];
          if (rhs.startsWith("String_Node_Str")) {
            rhs=rhs.substring(1,rhs.length() - 2);
          }
          Parameter param=(Parameter)entity.getAttribute(lhs);
          param.setToken(rhs);
        }
        _currentActorTree.makeConnections(entity);
        _currentActorTree.assignNonPtalonParameters(entity);
        _currentActorTree.removeDynamicLeftHandSides();
      }
      _currentActorTree.created=true;
      if (_inNewWhileIteration()) {
        if (_currentIfTree.isForStatement) {
          _currentActorTree.createdIteration=_currentIfTree.entered;
        }
 else {
          IfTree tree=_currentIfTree;
          while (!tree.isForStatement) {
            tree=tree.getParent();
            if (tree == null) {
              throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
            }
          }
          _currentActorTree.createdIteration=tree.entered;
        }
      }
 else {
        _currentActorTree.createdIteration=_currentIfTree.entered;
      }
    }
 else {
      throw new PtalonRuntimeException("String_Node_Str" + name);
    }
  }
 catch (  Exception ex) {
    throw new PtalonRuntimeException("String_Node_Str" + name,ex);
  }
}

Fixed version (ground truth):
/** 
 * Add an actor to the PtalonActor.  In the case of an actor specified by an import statement, the actor will be a PtalonActor.  In the case of an actor specified by a  parameter, the actor will be arbitrary.
 * @param name The unique name of the actor declaration.
 * @exception PtalonRuntimeException If there is any troubleloading the actor.
 */
public void addActor(String name) throws PtalonRuntimeException {
  try {
    if (_currentActorTree == null) {
      throw new PtalonRuntimeException("String_Node_Str");
    }
    String symbol=_currentActorTree.getSymbol();
    if (symbol.equals("String_Node_Str")) {
      _currentActorTree.created=true;
      if (_inNewWhileIteration()) {
        if (_currentIfTree.isForStatement) {
          _currentActorTree.createdIteration=_currentIfTree.entered;
        }
 else {
          IfTree tree=_currentIfTree;
          while (!tree.isForStatement) {
            tree=tree.getParent();
            if (tree == null) {
              throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
            }
          }
          _currentActorTree.createdIteration=tree.entered;
        }
      }
 else {
        _currentActorTree.createdIteration=_currentIfTree.entered;
      }
      _currentActorTree.assignPtalonParameters(_actor);
      _currentActorTree.makeThisConnections();
      _currentActorTree.removeDynamicLeftHandSides();
      return;
    }
    String uniqueName=_actor.uniqueName(symbol);
    if (_getType(symbol).equals("String_Node_Str")) {
      PtalonActor actor=new PtalonActor(_actor,uniqueName);
      FileParameter location=actor.ptalonCodeLocation;
      File file=_imports.get(symbol);
      location.setToken(new StringToken(file.toString()));
      actor.setNestedDepth(_actor.getNestedDepth() + 1);
      _currentActorTree.assignPtalonParameters(actor);
      _currentActorTree.makeConnections(actor);
      _currentActorTree.removeDynamicLeftHandSides();
    }
 else     if (_getType(symbol).equals("String_Node_Str")) {
      PtalonParameter parameter=(PtalonParameter)_actor.getAttribute(getMappedName(symbol));
      if (!parameter.hasValue()) {
        throw new PtalonRuntimeException("String_Node_Str" + symbol + "String_Node_Str");
      }
      String expression=parameter.getExpression();
      String[] parsedExpression;
      if (expression.contains("String_Node_Str")) {
        parsedExpression=_parseActorExpression(expression);
      }
 else {
        parsedExpression=new String[1];
        parsedExpression[0]=expression;
      }
      String actor=parsedExpression[0];
      if (actor.startsWith("String_Node_Str")) {
        File file=new File(_parameterToImport(actor));
        PtalonActor ptalonActor=new PtalonActor(_actor,uniqueName);
        ptalonActor.ptalonCodeLocation.setToken(new StringToken(file.toString()));
        ptalonActor.setNestedDepth(_actor.getNestedDepth() + 1);
        for (int i=1; i < parsedExpression.length; i=i + 2) {
          String lhs=parsedExpression[i];
          String rhs=parsedExpression[i + 1];
          if (rhs.startsWith("String_Node_Str")) {
            rhs=rhs.substring(1,rhs.length() - 2);
          }
          Parameter param=(Parameter)ptalonActor.getAttribute(lhs);
          param.setToken(rhs);
        }
        _currentActorTree.assignPtalonParameters(ptalonActor);
        _currentActorTree.makeConnections(ptalonActor);
        _currentActorTree.removeDynamicLeftHandSides();
      }
 else {
        NamedObj context=_actor;
        MoMLParser momlParser=null;
        if (context != null) {
          momlParser=ParserAttribute.getParser(context);
          momlParser.reset();
        }
        if (momlParser == null) {
          momlParser=new MoMLParser();
        }
        if (context != null) {
          momlParser.setContext(context);
        }
        String description="String_Node_Str" + uniqueName + "String_Node_Str"+ actor+ "String_Node_Str";
        momlParser.parse(null,description);
        ComponentEntity entity=null;
        if (_actor != null) {
          entity=_actor.getEntity(uniqueName);
        }
        if (_actor == null || entity == null) {
          throw new PtalonRuntimeException("String_Node_Str");
        }
        for (int i=1; i < parsedExpression.length; i=i + 2) {
          String lhs=parsedExpression[i];
          String rhs=parsedExpression[i + 1];
          if (rhs.startsWith("String_Node_Str")) {
            rhs=rhs.substring(1,rhs.length() - 2);
          }
          Parameter param=(Parameter)entity.getAttribute(lhs);
          param.setToken(rhs);
        }
        _currentActorTree.makeConnections(entity);
        _currentActorTree.assignNonPtalonParameters(entity);
        _currentActorTree.removeDynamicLeftHandSides();
      }
      _currentActorTree.created=true;
      if (_inNewWhileIteration()) {
        if (_currentIfTree.isForStatement) {
          _currentActorTree.createdIteration=_currentIfTree.entered;
        }
 else {
          IfTree tree=_currentIfTree;
          while (!tree.isForStatement) {
            tree=tree.getParent();
            if (tree == null) {
              throw new PtalonRuntimeException("String_Node_Str" + "String_Node_Str");
            }
          }
          _currentActorTree.createdIteration=tree.entered;
        }
      }
 else {
        _currentActorTree.createdIteration=_currentIfTree.entered;
      }
    }
 else {
      throw new PtalonRuntimeException("String_Node_Str" + name);
    }
  }
 catch (  Exception ex) {
    throw new PtalonRuntimeException("String_Node_Str" + name,ex);
  }
}