Class PtalonEvaluator

  • Direct Known Subclasses:
    TransformationEvaluator

    public class PtalonEvaluator
    extends AbstractPtalonEvaluator
    A code manager that manages the extra complexity of dealing with parsing Ptalon actors or values and setting them to parameters of PtalonActors (ones declared in a Ptalon file). FIXME: This implementation could be improved by investigating ways to better address partial evaluation. A lot of memory gets eaten up by IfTrees, and it would be better to keep only the minimum subset in order to free up memory.
    Since:
    Ptolemy II 6.1
    Version:
    $Id$
    Author:
    Adam Cataldo, Elaine Cheong
    Pt.AcceptedRating:
    Yellow (celaine)
    Pt.ProposedRating:
    Yellow (celaine)
    • Constructor Detail

      • PtalonEvaluator

        public PtalonEvaluator​(PtalonActor actor)
        Create a new PtalonEvaluator.
        Parameters:
        actor - The ptalon actor for this manager.
    • Method Detail

      • addActor

        public void addActor​(java.lang.String name)
                      throws PtalonRuntimeException
        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.
        Parameters:
        name - The unique name of the actor declaration.
        Throws:
        PtalonRuntimeException - If there is any trouble loading the actor.
      • addParameterAssign

        public void addParameterAssign​(java.lang.String parameterName,
                                       java.lang.String expression)
                                throws PtalonScopeException
        Add an assignment of the specified parameter of this actor declaration to the specified actor declaration. This is not allowed in nested actor declarations, only top-level declarations. For instance: Foo(port := containing) port is okay, but not Bar(a := Foo(port := containing))
        Parameters:
        parameterName - The name of the parameter.
        expression - The expression to be assigned to the parameter.
        Throws:
        PtalonScopeException - If this is not a top-level actor declaration with respect to the assignment, or if connectPoint is not a port or relation.
      • addPortAssign

        public void addPortAssign​(java.lang.String portName,
                                  java.lang.String connectPoint)
                           throws PtalonScopeException
        Add an assignment of the specified port of this actor declaration to the containing Ptalon actor connection point, which is either a port or a relation. This is not allowed in nested actor declarations, only top-level declarations. For instance, Foo(port := containing) port is okay, but not Bar(a := Foo(port := containing))
        Parameters:
        portName - The name of the port in this
        connectPoint - The name of the container's port or relation.
        Throws:
        PtalonScopeException - If this is not a top-level actor declaration with respect to the assignment, or if connectPoint is not a port or relation.
      • addPortAssign

        public void addPortAssign​(java.lang.String portName,
                                  java.lang.String connectPointPrefix,
                                  java.lang.String connectPointExpression)
                           throws PtalonScopeException
        Add an assignment of the specified port of this actor declaration to the containing Ptalon actor connection point, which is either a port or a relation. This is not allowed in nested actor declarations, only top-level declarations. For instance, Foo(port := containing) port is okay, but not Bar(a := Foo(port := containing))
        Parameters:
        portName - The name of the port in this
        connectPointPrefix - The prefix of the name of the container's port or relation.
        connectPointExpression - The variable suffix of the name of the container's port or relation.
        Throws:
        PtalonScopeException - If this is not a top-level actor declaration with respect to the assignment, or if connectPoint is not a port or relation.
      • addSymbol

        public void addSymbol​(java.lang.String name,
                              java.lang.String type)
                       throws PtalonScopeException
        Add a symbol with the given name and type to the symbol table at the current level of the if-tree hierarchy.
        Overrides:
        addSymbol in class AbstractPtalonEvaluator
        Parameters:
        name - The symbol name.
        type - The symbol type.
        Throws:
        PtalonScopeException - If a symbol with this name has already been added somewhere in the current scope.
      • addUnknownLeftSide

        public void addUnknownLeftSide​(java.lang.String prefix,
                                       java.lang.String expression)
        Add the unknown left side to this actor declaration.
        Parameters:
        prefix - The prefix for the unknown left side.
        expression - The suffix expression for the unknown left side.
      • enterActorDeclaration

        public void enterActorDeclaration​(java.lang.String name)
                                   throws PtalonRuntimeException
        Enter the named actor declaration.
        Parameters:
        name - The name of the actor declaration.
        Throws:
        PtalonRuntimeException - If such an actor declaration does not exist.
      • isActorReady

        public boolean isActorReady()
                             throws PtalonRuntimeException
        Returns true if the current actor declaration is ready to be created.
        Returns:
        true If the current actor declaration is ready to be created.
        Throws:
        PtalonRuntimeException - If thrown trying to access a parameter, or if there is no actor declaration to create.
      • popActorDeclaration

        public java.lang.String popActorDeclaration()
                                             throws PtalonScopeException
        Pop an actor off of the current tree and return the name.
        Returns:
        The unique name of the actor declaration being popped from.
        Throws:
        PtalonScopeException - If not inside an actor declaration.
      • pushActorDeclaration

        public void pushActorDeclaration​(java.lang.String actorName)
                                  throws PtalonScopeException
        Push an actor name onto the current tree, or create a new tree if entering a new nested actor declaration.
        Parameters:
        actorName - The name of the actor.
        Throws:
        PtalonScopeException - If actorName is not a valid parameter or import in the current scope.
      • setActorParameter

        public void setActorParameter​(java.lang.String paramName)
                               throws PtalonScopeException
        Set the parameter name for the current actor declaration, if any, to the given parameter name.
        Parameters:
        paramName - The name of the parameter.
        Throws:
        PtalonScopeException - If not inside the scope of an actor declaration.
      • setActorSymbol

        public void setActorSymbol​(java.lang.String symbol)
                            throws PtalonScopeException
        Set the symbol in the PtalonCode which represents this AbstractPtalonEvaluator's actor.
        Overrides:
        setActorSymbol in class AbstractPtalonEvaluator
        Parameters:
        symbol - The name of this actor in the Ptalon file.
        Throws:
        PtalonScopeException - If the symbol has been added already, or if there is some problem accessing its associated file.
      • setDanglingPortsOkay

        public void setDanglingPortsOkay​(boolean value)
        Set whether or not dangling ports are okay. If this input is false, then dangling ports will be connected to the outside of this PtalonActor, the default behavior. Setting this to true means that this is not desired.
        Parameters:
        value - true if dangling ports should be left alone.
      • startAtTop

        public void startAtTop()
        Prepare the compiler to start at the outermost scope of the Ptalon program during run time.
        Overrides:
        startAtTop in class AbstractPtalonEvaluator