Package ptolemy.cg.lib.syntactic
Class SyntacticName
- java.lang.Object
-
- ptolemy.cg.lib.syntactic.SyntacticName
-
- All Implemented Interfaces:
SyntacticTerm
public class SyntacticName extends java.lang.Object implements SyntacticTerm
This class represents a named SyntacticTerm. It could be either a a bound name referring to another term, possibly an expression, or a SyntacticNode. These terms are the leaves of the expression tree created using SyntacticTerm expression constructs. This mechanism could also be used for recursion, although this idea has not been completely worked out.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Chris Shaver
- Pt.AcceptedRating:
- Red
- Pt.ProposedRating:
- Red (shaver)
-
-
Constructor Summary
Constructors Constructor Description SyntacticName()Make named term with no reference or name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(SyntacticTerm term)Bind a given term to this named term.java.lang.StringgenerateCode()Generate the lexical representation of the term.java.lang.StringgenerateDefinitionCode()Generate definition code for name in terms of the expression it is bound to.SyntacticTermgetBound()Get the term bound to this name.java.util.List<SyntacticPort>getInputs()Get a list of the input ports to the operator.java.lang.StringgetName()Get the name of the term.intgetOrder()Get the sort order of the term.java.util.List<SyntacticPort>getOutputs()Get a list of output ports to the operator.booleanhasCode()Decide whether code can be generated from this term.java.lang.IntegerinputIndex(SyntacticPort port)Get the index of an input port given a reference to it.java.lang.IntegeroutputIndex(SyntacticPort port)Get the index of an output port given a reference to it.SyntacticRankrank()Get the rank of the term.voidsetName(java.lang.String name)Set the name of the term.intsizeInputs()Get the number of inputs to the term.intsizeOutputs()Get the number of outputs from the term.
-
-
-
Method Detail
-
getInputs
public java.util.List<SyntacticPort> getInputs()
Get a list of the input ports to the operator. If there is no kernel null is returned.- Specified by:
getInputsin interfaceSyntacticTerm- Returns:
- list of input ports.
-
getOutputs
public java.util.List<SyntacticPort> getOutputs()
Get a list of output ports to the operator. If there is no kernel null is returned.- Specified by:
getOutputsin interfaceSyntacticTerm- Returns:
- list of output ports.
-
sizeInputs
public int sizeInputs()
Get the number of inputs to the term.- Specified by:
sizeInputsin interfaceSyntacticTerm- Returns:
- number of inputs or zero if no kernel.
-
sizeOutputs
public int sizeOutputs()
Get the number of outputs from the term.- Specified by:
sizeOutputsin interfaceSyntacticTerm- Returns:
- number of outputs or zero if no kernel.
-
rank
public SyntacticRank rank()
Get the rank of the term.- Specified by:
rankin interfaceSyntacticTerm- Returns:
- rank of term.
-
inputIndex
public java.lang.Integer inputIndex(SyntacticPort port)
Get the index of an input port given a reference to it. null is returned if the port does not exist in the term or the kernel is absent.- Specified by:
inputIndexin interfaceSyntacticTerm- Parameters:
port- Port to find the index of.- Returns:
- the index of the port or null if none.
-
outputIndex
public java.lang.Integer outputIndex(SyntacticPort port)
Get the index of an output port given a reference to it. null is returned if the port does not exist in the term or the kernel is absent.- Specified by:
outputIndexin interfaceSyntacticTerm- Parameters:
port- Port to find the index of.- Returns:
- the index of the port or null if none.
-
generateCode
public java.lang.String generateCode()
Generate the lexical representation of the term. Since this is a leaf of the expression tree, the term is simply the name annotated with the rank: name< rank >- Specified by:
generateCodein interfaceSyntacticTerm- Returns:
- lexical representation of term.
-
generateDefinitionCode
public java.lang.String generateDefinitionCode()
Generate definition code for name in terms of the expression it is bound to. This code is of the form: node = term expression- Returns:
- definition statement for the named term.
-
getOrder
public int getOrder()
Get the sort order of the term.- Specified by:
getOrderin interfaceSyntacticTerm- Returns:
- sort order of the term.
-
hasCode
public boolean hasCode()
Decide whether code can be generated from this term.- Specified by:
hasCodein interfaceSyntacticTerm- Returns:
- whether code can be generated.
-
setName
public void setName(java.lang.String name)
Set the name of the term.- Parameters:
name- Name for the term.- See Also:
getName()
-
bind
public void bind(SyntacticTerm term)
Bind a given term to this named term.- Parameters:
term- Term to bind to name.
-
getName
public java.lang.String getName()
Get the name of the term.- Returns:
- name of term.
- See Also:
setName(java.lang.String)
-
getBound
public SyntacticTerm getBound()
Get the term bound to this name.- Returns:
- term bound.
-
-