public abstract class AbstractPtalonEvaluator
extends java.lang.Object
Yellow (celaine) |
Yellow (celaine) |
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractPtalonEvaluator.IfTree
This is a representation of an if/else construct in Ptalon.
|
protected class |
AbstractPtalonEvaluator.PtalonExpressionScope
FIXME comment
|
Modifier and Type | Field and Description |
---|---|
protected PtalonActor |
_actor
The actor in which this PtalonCompilerInfo is used.
|
protected AbstractPtalonEvaluator.IfTree |
_currentIfTree
Some descendent of the root tree to which new input symbols
should be added.
|
protected java.util.Hashtable<java.lang.String,java.net.URL> |
_imports
A list of the import symbols and their corresponding files.
|
protected AbstractPtalonEvaluator.PtalonExpressionScope |
_scope
The expression scope for this code manager.
|
protected java.util.Map<java.lang.String,TypedIOPort> |
_transparentRelations
Maps names of transparent relations to ports, which should be
multiports.
|
Constructor and Description |
---|
AbstractPtalonEvaluator(PtalonActor actor)
Create a new AbstractPtalonEvaluator in the specified
PtalonActor.
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
_getIndentPrefix(int level)
Return a number of spaces that is proportional to the
argument.
|
protected int |
_getTimesEntered()
Return the number of times the current if tree has been
entered.
|
protected java.lang.String |
_getType(java.lang.String symbol)
Return the type associated with the given symbol in the
current scope.
|
protected java.lang.String |
_getTypeForScope(java.lang.String symbol)
Return the type associated with the given symbol in the
current scope.
|
protected boolean |
_inNewWhileIteration()
Return true if in a new iteration of a while block.
|
protected boolean |
_isPreservingTransformation() |
protected void |
_processAttributes(NamedObj object) |
protected void |
_resetParameters(boolean reset)
Set whether to reset parameters when the actor is populated and the
parameters already exist for the actor.
|
protected void |
_setPreservingTransformation(boolean b) |
void |
addActorParameter(java.lang.String name)
Add a PtalonParameter to the PtalonActor with the specified
name.
|
void |
addActorParameter(java.lang.String name,
java.lang.String expression)
Add an invisible PtalonParameter to the PtalonActor with the
specified name.
|
void |
addInPort(java.lang.String name)
Add a TypedIOPort to the PtalonActor with the specified name,
and input flow type.
|
void |
addOutPort(java.lang.String name)
Add a TypedIOPort to the PtalonActor with the specified name,
and output flow type.
|
void |
addParameter(java.lang.String name)
Add a Parameter to the PtalonActor with the specified name.
|
void |
addParameter(java.lang.String name,
java.lang.String expression)
Add an invisible Parameter to the PtalonActor with the
specified name and the given expression as its value.
|
void |
addPort(java.lang.String name)
Add a TypedIOPort to the PtalonActor with the specified name.
|
void |
addRelation(java.lang.String name)
Add a TypedIORelation to the PtalonActor with the specified name.
|
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 |
addTransparentRelation(java.lang.String name)
Add a transparent relation to the PtalonActor with the
specified name.
|
void |
assignInternalParameters()
Assign any internal parameters in the order they were set.
|
void |
enterForScope(java.lang.String scope,
PtalonAST forBlock,
PtalonPopulator populator)
Enter the named for-block subscope.
|
void |
enterIfScope(java.lang.String scope)
Enter the named subscope.
|
void |
enterTransformation(boolean incremental) |
boolean |
evaluateBoolean(java.lang.String expression)
Evaluate the given expression and return its boolean
value.
|
Token |
evaluateExpression(java.lang.String expression)
Evaluate the given expression and return the corresponding token.
|
void |
evaluateForScope()
Evaluate the current for block, assuming there is one.
|
java.lang.String |
evaluateString(java.lang.String expression)
Evaluate the given input expression and return a string
representation of it, or null, if there is some reason it
cannot be evaluated.
|
void |
exitForScope()
Exit the current for scope.
|
void |
exitIfScope()
Exit the current if scope.
|
void |
exitTransformation() |
java.lang.String |
getMappedName(java.lang.String symbol)
Get the unique name for the symbol in the PtalonActor.
|
boolean |
hasUnassignedParameters()
Return whether there are unassigned parameters to be handled with the
assignInternalParameters() method. |
boolean |
inScope(java.lang.String symbol)
Return true if the given symbol exists in the current scope.
|
boolean |
isCreated(java.lang.String symbol)
Return true if an entity was created in PtalonActor for the
given symbol.
|
boolean |
isForReady()
Return true if the boolean for the current conditional is
ready to be entered.
|
boolean |
isIfReady()
Return true if the boolean for the current conditional is
ready to be entered.
|
boolean |
isReady()
Return true if the current piece of code is ready to be
entered.
|
void |
negateObject(java.lang.String name) |
void |
optionalObject(java.lang.String name) |
java.lang.String |
popForStatement()
Pop out of the scope of the current for statement and into its
container block's scope.
|
java.lang.String |
popIfStatement()
Pop out of the scope of the current if statement and into its
container block's scope.
|
void |
preserveObject(java.lang.String name) |
void |
pushForStatement(java.lang.String variable,
java.lang.String initExpr,
java.lang.String satExpr)
Push into the scope of a new for statement contained as a
sub-block of the current (FIXME: if or for) statement.
|
void |
pushIfStatement()
Push into the scope of a new if statement contained as a
sub-block of the current if statement.
|
void |
removeObject(java.lang.String name) |
void |
setActiveBranch(boolean branch)
Set the active branch for the current if statement.
|
void |
setActorSymbol(java.lang.String symbol)
Set the symbol in the PtalonCode which represents this
AbstractPtalonEvaluator's actor.
|
void |
setCurrentBranch(boolean branch)
Set the current branch that's being walked.
|
void |
setNextExpression(java.lang.String nextExpr)
Set the next expression for the current for statement scope,
assuming the current scope is a for statement and not an if
statement.
|
void |
startAtTop()
Prepare the compiler to start at the outermost scope of the
Ptalon program during run time.
|
protected PtalonActor _actor
protected AbstractPtalonEvaluator.IfTree _currentIfTree
protected java.util.Hashtable<java.lang.String,java.net.URL> _imports
protected AbstractPtalonEvaluator.PtalonExpressionScope _scope
protected java.util.Map<java.lang.String,TypedIOPort> _transparentRelations
public AbstractPtalonEvaluator(PtalonActor actor)
actor
- The actor to manage the code for.public void addActorParameter(java.lang.String name) throws PtalonRuntimeException
name
- The name of the parameter.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a parameter associated
with it, or if an IllegalActionException is thrown trying to
create the parameter.public void addActorParameter(java.lang.String name, java.lang.String expression) throws PtalonRuntimeException
name
- The name of the parameter.expression
- The expression representing the parameter.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a parameter associated
with it, or if an IllegalActionException is thrown trying to
create the parameter.public void addInPort(java.lang.String name) throws PtalonRuntimeException
name
- The name of the port.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a port associated with it,
or if an IllegalActionException is thrown trying to create the
port.public void addOutPort(java.lang.String name) throws PtalonRuntimeException
name
- The name of the port.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a port associated with it,
or if an IllegalActionException is thrown trying to create the
port.public void addParameter(java.lang.String name) throws PtalonRuntimeException
name
- The name of the parameter.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a parameter associated
with it, or if an IllegalActionException is thrown trying to
create the parameter.public void addParameter(java.lang.String name, java.lang.String expression) throws PtalonRuntimeException
name
- The name of the parameter.expression
- The expression representing the parameter.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a parameter associated
with it, or if an IllegalActionException is thrown trying to
create the parameter.public void addPort(java.lang.String name) throws PtalonRuntimeException
name
- The name of the port.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a port associated with it,
or if an IllegalActionException is thrown trying to create the
port.public void addRelation(java.lang.String name) throws PtalonRuntimeException
name
- The name of the relation.PtalonRuntimeException
- If the symbol does not
exist, or if the symbol already has a relation associated with
it, or if an IllegalActionException is thrown trying to create
the relation.public void addSymbol(java.lang.String name, java.lang.String type) throws PtalonScopeException
name
- 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 addTransparentRelation(java.lang.String name) throws PtalonRuntimeException
name
- The name of the relation.PtalonRuntimeException
- If in a new for iteration
but no containing for block is found.public void assignInternalParameters() throws PtalonRuntimeException
PtalonRuntimeException
- If there is any trouble
assigning parameter values.public void enterForScope(java.lang.String scope, PtalonAST forBlock, PtalonPopulator populator) throws PtalonRuntimeException
scope
- The named subscope.forBlock
- The AST for the subscope.populator
- The PtalonPopulator that called this statement.PtalonRuntimeException
- If the subscope does not exist.public void enterIfScope(java.lang.String scope) throws PtalonRuntimeException
scope
- The named subscope.PtalonRuntimeException
- If the subscope does not exist.public void enterTransformation(boolean incremental) throws PtalonRuntimeException
PtalonRuntimeException
public boolean evaluateBoolean(java.lang.String expression) throws PtalonRuntimeException
expression
- The expression to evaluate.PtalonRuntimeException
- If the result is not a
boolean.public Token evaluateExpression(java.lang.String expression) throws PtalonRuntimeException
expression
- The expression to evaluate.PtalonRuntimeException
- If unable to evaluate the
expression.public void evaluateForScope() throws PtalonRuntimeException
PtalonRuntimeException
- If there is any trouble
evaluating this for block.public java.lang.String evaluateString(java.lang.String expression)
expression
- The input expression.public void exitForScope() throws PtalonRuntimeException
PtalonRuntimeException
- If not in a for-block scope.public void exitIfScope() throws PtalonRuntimeException
PtalonRuntimeException
- If already at the top-level
if scope.public void exitTransformation() throws PtalonRuntimeException
PtalonRuntimeException
public java.lang.String getMappedName(java.lang.String symbol) throws PtalonRuntimeException
symbol
- The symbol to test.PtalonRuntimeException
- If no such symbol exists.public boolean hasUnassignedParameters()
assignInternalParameters()
method.public boolean inScope(java.lang.String symbol)
symbol
- The symbol to test.public boolean isCreated(java.lang.String symbol) throws PtalonRuntimeException
symbol
- The symbol to test.PtalonRuntimeException
- If the symbol is not in the
current scope.public boolean isForReady() throws PtalonRuntimeException
PtalonRuntimeException
- If it is thrown trying to
access a parameter.public boolean isIfReady() throws PtalonRuntimeException
PtalonRuntimeException
- If it is thrown trying to
access a parameter.public boolean isReady() throws PtalonRuntimeException
PtalonRuntimeException
- If it is thrown trying to
access a parameter.public void negateObject(java.lang.String name) throws PtalonRuntimeException
PtalonRuntimeException
public void optionalObject(java.lang.String name) throws PtalonRuntimeException
PtalonRuntimeException
public java.lang.String popForStatement() throws PtalonScopeException
PtalonScopeException
- If the current scope is
already the outermost scope.public java.lang.String popIfStatement() throws PtalonScopeException
PtalonScopeException
- If the current scope is
already the outermost scope.public void preserveObject(java.lang.String name) throws PtalonRuntimeException
PtalonRuntimeException
public void pushForStatement(java.lang.String variable, java.lang.String initExpr, java.lang.String satExpr)
variable
- The variable associated with the for
statement.initExpr
- The expression representing the initial value
for the variable.satExpr
- The expression evaluated before executing the
for statement body.public void pushIfStatement()
public void removeObject(java.lang.String name) throws PtalonRuntimeException
PtalonRuntimeException
public void setActiveBranch(boolean branch)
branch
- The branch to set.public void setActorSymbol(java.lang.String symbol) throws PtalonScopeException
symbol
- 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 setCurrentBranch(boolean branch)
branch
- True if the true branch is being walked.public void setNextExpression(java.lang.String nextExpr)
nextExpr
- The expression to represent the next statement.public void startAtTop()
protected static java.lang.String _getIndentPrefix(int level)
level
- The level of indenting represented by the spaces.protected int _getTimesEntered()
protected java.lang.String _getType(java.lang.String symbol) throws PtalonScopeException
symbol
- The symbol under test.PtalonScopeException
- If the symbol is not in the
current scope.protected java.lang.String _getTypeForScope(java.lang.String symbol) throws PtalonScopeException
symbol
- The symbol under test.PtalonScopeException
- If the symbol is not in the
current scope.protected boolean _inNewWhileIteration()
protected boolean _isPreservingTransformation()
protected void _processAttributes(NamedObj object) throws PtalonRuntimeException
object
- PtalonRuntimeException
protected void _resetParameters(boolean reset)
reset
- Whether to reset parameters.protected void _setPreservingTransformation(boolean b)