|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectptolemy.actor.ptalon.model.AbstractPtalonModelEvaluator
public abstract class AbstractPtalonModelEvaluator
A helper class to store information, like variable scope info, for the Ptalon compiler. This class manages references to all elements created as a result of parsing a Ptalon file, and whether they have been instantiated in Ptolemy.
| Yellow (celaine) |
| Yellow (celaine) |
| Nested Class Summary | |
|---|---|
protected class |
AbstractPtalonModelEvaluator.IfTree
This is a representation of an if/else construct in Ptalon. |
protected class |
AbstractPtalonModelEvaluator.PtalonExpressionScope
FIXME comment |
| Field Summary | |
|---|---|
protected PtalonModel |
_actor
The actor in which this PtalonCompilerInfo is used. |
private int |
_counter
A counter used to associate a unique number with each if-block. |
protected AbstractPtalonModelEvaluator.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. |
private AbstractPtalonModelEvaluator.IfTree |
_root
The root of the tree containing the symbol tables for each level of the if-statement hierarchy. |
protected AbstractPtalonModelEvaluator.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. |
private java.util.List<PtalonParameter> |
_unassignedParameters
_unassignedParameters and _unassignedParameterValues are used to store parameters which need to be set by Ptalon; i.e. constant parameters. |
private java.util.List<java.lang.String> |
_unassignedParameterValues
_unassignedParameters and _unassignedParameterValues are used to store parameters which need to be set by Ptalon; i.e. constant parameters. |
| Constructor Summary | |
|---|---|
AbstractPtalonModelEvaluator(PtalonModel actor)
Create a new AbstractPtalonEvaluator in the specified PtalonActor. |
|
| Method Summary | |
|---|---|
protected static java.lang.String |
_getIndentPrefix(int level)
Return a number of spaces that is proportional to the argument. |
private java.lang.String |
_getNextIfSymbol()
FIXME |
private java.util.Set<java.lang.String> |
_getParameters()
FIXME |
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. |
private Type |
_getTypeOf(java.lang.String param)
Get the type associated with the specified parameter. |
private InequalityTerm |
_getTypeTermOf(java.lang.String param)
Get the type term associated with the specified parameter. |
private Token |
_getValueOf(java.lang.String param)
Get the value associated with the specified parameter. |
protected boolean |
_inNewWhileIteration()
Return true if in a new iteration of a while block. |
void |
addActorParameter(java.lang.String name)
Add a PtalonParameter to the PtalonModel with the specified name. |
void |
addActorParameter(java.lang.String name,
java.lang.String expression)
Add an invisible PtalonParameter to the PtalonModel with the specified name. |
void |
addInPort(java.lang.String name)
Add a TypedIOPort to the PtalonModel with the specified name, and input flow type. |
void |
addOutPort(java.lang.String name)
Add a TypedIOPort to the PtalonModel with the specified name, and output flow type. |
void |
addParameter(java.lang.String name)
Add a Parameter to the PtalonModel with the specified name. |
void |
addParameter(java.lang.String name,
java.lang.String expression)
Add an invisible Parameter to the PtalonModel with the specified name and the given expression as its value. |
void |
addPort(java.lang.String name)
Add a TypedIOPort to the PtalonModel with the specified name. |
void |
addRelation(java.lang.String name)
Add a TypedIORelation to the PtalonModel 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 PtalonModel 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. |
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. |
java.lang.String |
getMappedName(java.lang.String symbol)
Get the unique name for the symbol in the PtalonModel. |
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 PtalonModel 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. |
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 |
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 |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected PtalonModel _actor
protected AbstractPtalonModelEvaluator.IfTree _currentIfTree
protected java.util.Hashtable<java.lang.String,java.net.URL> _imports
protected AbstractPtalonModelEvaluator.PtalonExpressionScope _scope
protected java.util.Map<java.lang.String,TypedIOPort> _transparentRelations
private int _counter
private AbstractPtalonModelEvaluator.IfTree _root
private java.util.List<PtalonParameter> _unassignedParameters
private java.util.List<java.lang.String> _unassignedParameterValues
| Constructor Detail |
|---|
public AbstractPtalonModelEvaluator(PtalonModel actor)
actor - The actor to manage the code for.| Method Detail |
|---|
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 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 java.lang.String getMappedName(java.lang.String symbol)
throws PtalonRuntimeException
symbol - The symbol to test.
PtalonRuntimeException - If no such symbol exists.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 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 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 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()
private java.lang.String _getNextIfSymbol()
private java.util.Set<java.lang.String> _getParameters()
throws PtalonScopeException
PtalonScopeException - If there is any problem
getting the type of a symbol.
private Type _getTypeOf(java.lang.String param)
throws PtalonRuntimeException
param - The parameter's name in the Ptalon code.
PtalonRuntimeException - If the parameter does not exist.
private InequalityTerm _getTypeTermOf(java.lang.String param)
throws PtalonRuntimeException
param - The parameter's name in the Ptalon code.
PtalonRuntimeException - If the parameter does not exist.
private Token _getValueOf(java.lang.String param)
throws PtalonRuntimeException
param - The parameter's name in the Ptalon code.
PtalonRuntimeException - If the parameter does not exist.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||