Package ptolemy.actor.ptalon
Class PtalonEvaluator
- java.lang.Object
-
- ptolemy.actor.ptalon.AbstractPtalonEvaluator
-
- ptolemy.actor.ptalon.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)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.actor.ptalon.AbstractPtalonEvaluator
AbstractPtalonEvaluator.IfTree, AbstractPtalonEvaluator.PtalonExpressionScope
-
-
Field Summary
-
Fields inherited from class ptolemy.actor.ptalon.AbstractPtalonEvaluator
_actor, _currentIfTree, _imports, _scope, _transparentRelations
-
-
Constructor Summary
Constructors Constructor Description PtalonEvaluator(PtalonActor actor)
Create a new PtalonEvaluator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActor(java.lang.String name)
Add an actor to the PtalonActor.void
addParameterAssign(java.lang.String parameterName, java.lang.String expression)
Add an assignment of the specified parameter of this actor declaration to the specified actor declaration.void
addPortAssign(java.lang.String portName, java.lang.String connectPoint)
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.void
addPortAssign(java.lang.String portName, java.lang.String connectPointPrefix, java.lang.String connectPointExpression)
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.void
addSymbol(java.lang.String name, java.lang.String type)
Add a symbol with the given name and type to the symbol table at the current level of the if-tree hierarchy.void
addUnknownLeftSide(java.lang.String prefix, java.lang.String expression)
Add the unknown left side to this actor declaration.void
enterActorDeclaration(java.lang.String name)
Enter the named actor declaration.void
exitActorDeclaration()
Exit the current actor declaration.boolean
isActorReady()
Returns true if the current actor declaration is ready to be created.java.lang.String
popActorDeclaration()
Pop an actor off of the current tree and return the name.void
pushActorDeclaration(java.lang.String actorName)
Push an actor name onto the current tree, or create a new tree if entering a new nested actor declaration.void
setActorParameter(java.lang.String paramName)
Set the parameter name for the current actor declaration, if any, to the given parameter name.void
setActorSymbol(java.lang.String symbol)
Set the symbol in the PtalonCode which represents this AbstractPtalonEvaluator's actor.void
setDanglingPortsOkay(boolean value)
Set whether or not dangling ports are okay.void
startAtTop()
Prepare the compiler to start at the outermost scope of the Ptalon program during run time.-
Methods inherited from class ptolemy.actor.ptalon.AbstractPtalonEvaluator
_getIndentPrefix, _getTimesEntered, _getType, _getTypeForScope, _inNewWhileIteration, _isPreservingTransformation, _processAttributes, _resetParameters, _setPreservingTransformation, addActorParameter, addActorParameter, addInPort, addOutPort, addParameter, addParameter, addPort, addRelation, addTransparentRelation, assignInternalParameters, enterForScope, enterIfScope, enterTransformation, evaluateBoolean, evaluateExpression, evaluateForScope, evaluateString, exitForScope, exitIfScope, exitTransformation, getMappedName, hasUnassignedParameters, inScope, isCreated, isForReady, isIfReady, isReady, negateObject, optionalObject, popForStatement, popIfStatement, preserveObject, pushForStatement, pushIfStatement, removeObject, setActiveBranch, setCurrentBranch, setNextExpression
-
-
-
-
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 thisconnectPoint
- 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 thisconnectPointPrefix
- 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 classAbstractPtalonEvaluator
- 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.
-
exitActorDeclaration
public void exitActorDeclaration() throws PtalonRuntimeException
Exit the current actor declaration.- Throws:
PtalonRuntimeException
- If already at the top-level if scope.
-
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 classAbstractPtalonEvaluator
- 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 classAbstractPtalonEvaluator
-
-