Package ptolemy.actor.gt
Class GTParameter.Evaluator
- java.lang.Object
-
- ptolemy.data.expr.AbstractParseTreeVisitor
-
- ptolemy.data.expr.ParseTreeEvaluator
-
- ptolemy.actor.gt.GTParameter.Evaluator
-
- All Implemented Interfaces:
ParseTreeVisitor
- Enclosing class:
- GTParameter
public static class GTParameter.Evaluator extends ParseTreeEvaluator
The evaluator used in a transformation rule. It differs from other evaluators in that it uses a pattern and a match result to resolve names in both the pattern and the host model that the pattern matches in the match result. If a name is found in the host model, its value in the host model is returned, regardless of whether the same name exists in the pattern or not (even if this evaluator is used to evaluate a parameter specified in the pattern).- Since:
- Ptolemy II 7.1
- Version:
- $Id$
- Author:
- Thomas Huining Feng
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Field Summary
-
Fields inherited from class ptolemy.data.expr.ParseTreeEvaluator
_evaluatedChildToken, _typeInference
-
-
Constructor Summary
Constructors Constructor Description Evaluator(Pattern pattern, MatchResult matchResult)
Construct an evaluator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ParserScope
_createScope(Pattern pattern, MatchResult matchResult, ParserScope superScope)
Create the scope to be used for name resolution.Token
evaluateParseTree(ASTPtRootNode node, ParserScope scope)
Evaluate the parse tree with a scope that can resolve more names than the given scope.void
visitMethodCallNode(ASTPtMethodCallNode node)
Apply a method to the children of the specified node, where the first child is the object on which the method is defined and the rest of the children are arguments.-
Methods inherited from class ptolemy.data.expr.ParseTreeEvaluator
_assert, _evaluateAllChildren, _evaluateArrayIndex, _evaluateChild, _evaluateMatrixIndex, _functionCall, _methodCall, _trace, _traceEnter, _traceLeave, evaluateParseTree, traceParseTreeEvaluation, visitArrayConstructNode, visitBitwiseNode, visitFunctionalIfNode, visitFunctionApplicationNode, visitFunctionDefinitionNode, visitLeafNode, visitLogicalNode, visitMatrixConstructNode, visitPowerNode, visitProductNode, visitRecordConstructNode, visitRelationalNode, visitShiftNode, visitSumNode, visitUnaryNode, visitUnionConstructNode
-
Methods inherited from class ptolemy.data.expr.AbstractParseTreeVisitor
_unsupportedVisitException, _visitAllChildren, _visitChild, visitAssignmentNode
-
-
-
-
Constructor Detail
-
Evaluator
public Evaluator(Pattern pattern, MatchResult matchResult)
Construct an evaluator.- Parameters:
pattern
- The pattern.matchResult
- The match result for the match between the pattern and a host model.
-
-
Method Detail
-
evaluateParseTree
public Token evaluateParseTree(ASTPtRootNode node, ParserScope scope) throws IllegalActionException
Evaluate the parse tree with a scope that can resolve more names than the given scope. The used scope first searches for names in the host model. If the attempt fails, it invokes the given scope to resolve the names.- Overrides:
evaluateParseTree
in classParseTreeEvaluator
- Parameters:
node
- The node to be evaluated.scope
- The scope to be used as a fallback.- Returns:
- The result of evaluation.
- Throws:
IllegalActionException
- If an error occurs during evaluation.
-
visitMethodCallNode
public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException
Apply a method to the children of the specified node, where the first child is the object on which the method is defined and the rest of the children are arguments. This also handles indexing into a record, which looks the same.- Specified by:
visitMethodCallNode
in interfaceParseTreeVisitor
- Overrides:
visitMethodCallNode
in classParseTreeEvaluator
- Parameters:
node
- The specified node.- Throws:
IllegalActionException
- If an evaluation error occurs.
-
_createScope
protected ParserScope _createScope(Pattern pattern, MatchResult matchResult, ParserScope superScope)
Create the scope to be used for name resolution.- Parameters:
pattern
- The pattern.matchResult
- The match result.superScope
- The scope to fall back on if a name cannot be resolved.- Returns:
- The scope.
-
-