|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectptolemy.actor.ptalon.AbstractPtalonEvaluator
ptolemy.actor.ptalon.PtalonEvaluator
public class PtalonEvaluator
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.
| Yellow (celaine) |
| Yellow (celaine) |
| Nested Class Summary | |
|---|---|
private class |
PtalonEvaluator.ActorTree
This class is a tree whose structure mimics that of a nested actor declaration. |
| Nested classes/interfaces inherited from class ptolemy.actor.ptalon.AbstractPtalonEvaluator |
|---|
AbstractPtalonEvaluator.IfTree, AbstractPtalonEvaluator.PtalonExpressionScope |
| Field Summary | |
|---|---|
private PtalonEvaluator.ActorTree |
_currentActorTree
This represents the current point in the scope of a nested actor declaration. |
private boolean |
_danglingPortsOkay
If this is true, then dangling, or unconnected ports of actors contained in the PtalonActor should be left alone. |
private java.util.Map<java.lang.String,java.lang.Integer> |
_instanceNumbers
This map gives the number for the next instance of the specified symbol. |
private java.util.List<PtalonEvaluator.ActorTree> |
_trees
Each tree in this list represents a nested actor declaration, like Foo(a := Foo(a: = Bar(), b := Bar()), b := Bar()) |
| Fields inherited from class ptolemy.actor.ptalon.AbstractPtalonEvaluator |
|---|
_actor, _currentIfTree, _imports, _scope, _transparentRelations |
| Constructor Summary | |
|---|---|
PtalonEvaluator(PtalonActor actor)
Create a new PtalonEvaluator. |
|
| Method Summary | |
|---|---|
private java.lang.String |
_parameterToImport(java.lang.String expression)
The reverse of _importToParameter |
private java.lang.String[] |
_parseActorExpression(java.lang.String expression)
Break an expression like: a(x := <1/>, y := <2/>)(z := b(y := <2/>, z := <2/>)) into an array of expressions like: a x <1/> y <2/> z b(y : = <2/>, z := <2/>) |
private java.lang.String |
_uniqueSymbol(java.lang.String symbol)
Return a unique symbol for the given symbol. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private PtalonEvaluator.ActorTree _currentActorTree
private boolean _danglingPortsOkay
private java.util.Map<java.lang.String,java.lang.Integer> _instanceNumbers
private java.util.List<PtalonEvaluator.ActorTree> _trees
| Constructor Detail |
|---|
public PtalonEvaluator(PtalonActor actor)
actor - The ptalon actor for this manager.| Method Detail |
|---|
public void addActor(java.lang.String name)
throws PtalonRuntimeException
name - The unique name of the actor declaration.
PtalonRuntimeException - If there is any trouble
loading the actor.
public void addParameterAssign(java.lang.String parameterName,
java.lang.String expression)
throws PtalonScopeException
parameterName - The name of the parameter.expression - The expression to be assigned to the parameter.
PtalonScopeException - If this is not a top-level
actor declaration with respect to the assignment, or if
connectPoint is not a port or relation.
public void addPortAssign(java.lang.String portName,
java.lang.String connectPoint)
throws PtalonScopeException
portName - The name of the port in thisconnectPoint - The name of the container's port or relation.
PtalonScopeException - If this is not a top-level
actor declaration with respect to the assignment, or if
connectPoint is not a port or relation.
public void addPortAssign(java.lang.String portName,
java.lang.String connectPointPrefix,
java.lang.String connectPointExpression)
throws PtalonScopeException
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.
PtalonScopeException - If this is not a top-level
actor declaration with respect to the assignment, or if
connectPoint is not a port or relation.
public void addSymbol(java.lang.String name,
java.lang.String type)
throws PtalonScopeException
addSymbol in class AbstractPtalonEvaluatorname - The symbol name.type - The symbol type.
PtalonScopeException - If a symbol with this name has
already been added somewhere in the current scope.
public void addUnknownLeftSide(java.lang.String prefix,
java.lang.String expression)
prefix - The prefix for the unknown left side.expression - The suffix expression for the unknown left side.
public void enterActorDeclaration(java.lang.String name)
throws PtalonRuntimeException
name - The name of the actor declaration.
PtalonRuntimeException - If such an actor declaration
does not exist.
public void exitActorDeclaration()
throws PtalonRuntimeException
PtalonRuntimeException - If already at the top-level
if scope.
public boolean isActorReady()
throws PtalonRuntimeException
PtalonRuntimeException - If thrown trying to access a
parameter, or if there is no actor declaration to create.
public java.lang.String popActorDeclaration()
throws PtalonScopeException
PtalonScopeException - If not inside an actor
declaration.
public void pushActorDeclaration(java.lang.String actorName)
throws PtalonScopeException
actorName - The name of the actor.
PtalonScopeException - If actorName is not a valid
parameter or import in the current scope.
public void setActorParameter(java.lang.String paramName)
throws PtalonScopeException
paramName - The name of the parameter.
PtalonScopeException - If not inside the scope of an
actor declaration.
public void setActorSymbol(java.lang.String symbol)
throws PtalonScopeException
setActorSymbol in class AbstractPtalonEvaluatorsymbol - The name of this actor in the Ptalon file.
PtalonScopeException - If the symbol has been added
already, or if there is some problem accessing its associated
file.public void setDanglingPortsOkay(boolean value)
value - true if dangling ports should be left alone.public void startAtTop()
startAtTop in class AbstractPtalonEvaluatorprivate java.lang.String _parameterToImport(java.lang.String expression)
expression - The expression to convert.
private java.lang.String[] _parseActorExpression(java.lang.String expression)
a(x := <1/>, y := <2/>)(z := b(y := <2/>, z := <2/>))
into an array of expressions like:
a
x
<1/>
y
<2/>
z
b(y : = <2/>, z := <2/>)
expression - The expression to split.
private java.lang.String _uniqueSymbol(java.lang.String symbol)
throws PtalonScopeException
symbol - The symbol from which to derive the unique symbol.
PtalonScopeException - If the symbol does not refer to
a parameter or import valid in the current scope.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||