public class CParseTreeCodeGenerator extends ProceduralParseTreeCodeGenerator
This class has the following limitations:
ASTPtRootNode
_childCode, _depth, _evaluatedChildToken, _functionMap, _generator, _initializeCode, _preinitializeCode, _scope, _sharedCode, _trace, _typeInference, _wrapupCode
Constructor and Description |
---|
CParseTreeCodeGenerator(ProgramCodeGenerator generator)
Create a CParseTreeCodeGenerator that is used by
the given code generator to generate code for expressions.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
_codeGenType(Type ptType)
Get the corresponding type in code generation from the given Ptolemy
type.
|
protected void |
_evaluateArrayIndex(ASTPtRootNode node,
Token value,
Type type)
Evaluate the array index operation represented by the given node.
|
protected Token |
_evaluateChild(ASTPtRootNode node,
int i)
Evaluate the child with the given index of the given node.
|
protected java.lang.String |
_powCall(java.lang.String x,
java.lang.String y)
Return the string for the the pow() call.
|
void |
visitArrayConstructNode(ASTPtArrayConstructNode node)
Construct an ArrayToken that contains the tokens from the
children of the specified node.
|
void |
visitFunctionalIfNode(ASTPtFunctionalIfNode node)
Evaluate the first child, and depending on its (boolean) result,
evaluate either the second or the third child.
|
void |
visitFunctionDefinitionNode(ASTPtFunctionDefinitionNode node)
Define a function, where the children specify the argument types
and the expression.
|
void |
visitLeafNode(ASTPtLeafNode node)
Evaluate a numeric constant or an identifier.
|
void |
visitMatrixConstructNode(ASTPtMatrixConstructNode node)
Construct a matrix containing the children nodes.
|
void |
visitProductNode(ASTPtProductNode node)
Multiply the children of the specified node.
|
_assert, _evaluateAllChildren, _specializeArgument, _specializeReturnValue, _trace, _traceEnter, _traceLeave, escapeForTargetLanguage, evaluateParseTree, evaluateParseTree, generateFireCode, generateInitializeCode, generatePreinitializeCode, generateSharedCode, generateWrapupCode, traceParseTreeEvaluation, visitBitwiseNode, visitFunctionApplicationNode, visitLogicalNode, visitMethodCallNode, visitPowerNode, visitRecordConstructNode, visitRelationalNode, visitShiftNode, visitSumNode, visitUnaryNode
_unsupportedVisitException, _visitAllChildren, _visitChild, visitAssignmentNode, visitUnionConstructNode
public CParseTreeCodeGenerator(ProgramCodeGenerator generator)
generator
- The given code generator.public void visitArrayConstructNode(ASTPtArrayConstructNode node) throws IllegalActionException
visitArrayConstructNode
in interface ParseTreeVisitor
visitArrayConstructNode
in class ProceduralParseTreeCodeGenerator
node
- The specified node.IllegalActionException
- If an parse error occurs.public void visitFunctionDefinitionNode(ASTPtFunctionDefinitionNode node) throws IllegalActionException
visitFunctionDefinitionNode
in interface ParseTreeVisitor
visitFunctionDefinitionNode
in class ProceduralParseTreeCodeGenerator
node
- The specified node.IllegalActionException
- If an parse error occurs.public void visitFunctionalIfNode(ASTPtFunctionalIfNode node) throws IllegalActionException
visitFunctionalIfNode
in interface ParseTreeVisitor
visitFunctionalIfNode
in class ProceduralParseTreeCodeGenerator
node
- The specified node.IllegalActionException
- If an parse error occurs.public void visitLeafNode(ASTPtLeafNode node) throws IllegalActionException
visitLeafNode
in interface ParseTreeVisitor
visitLeafNode
in class ProceduralParseTreeCodeGenerator
node
- The specified node.IllegalActionException
- If an parse error occurs.public void visitMatrixConstructNode(ASTPtMatrixConstructNode node) throws IllegalActionException
visitMatrixConstructNode
in interface ParseTreeVisitor
visitMatrixConstructNode
in class ProceduralParseTreeCodeGenerator
node
- The specified node.IllegalActionException
- If an parse error occurs.public void visitProductNode(ASTPtProductNode node) throws IllegalActionException
visitProductNode
in interface ParseTreeVisitor
visitProductNode
in class ProceduralParseTreeCodeGenerator
node
- The specified node.IllegalActionException
- If an parse error occurs.protected java.lang.String _codeGenType(Type ptType)
_codeGenType
in class ProceduralParseTreeCodeGenerator
ptType
- The given Ptolemy type.protected void _evaluateArrayIndex(ASTPtRootNode node, Token value, Type type) throws IllegalActionException
_evaluateArrayIndex
in class ProceduralParseTreeCodeGenerator
node
- The node that caused this method to be called.value
- The token that is being indexed into, which must
be an ArrayToken.type
- The element type.IllegalActionException
- If an parse error occurs.protected Token _evaluateChild(ASTPtRootNode node, int i) throws IllegalActionException
_evaluateChild
in class ProceduralParseTreeCodeGenerator
node
- The given node.i
- The given index.IllegalActionException
- If an parse error occurs.protected java.lang.String _powCall(java.lang.String x, java.lang.String y)
_powCall
in class ProceduralParseTreeCodeGenerator
x
- The first argument for pow().y
- The second argument for pow().