Class ASTPtFunctionDefinitionNode

  • All Implemented Interfaces:
    java.lang.Cloneable, Node

    public class ASTPtFunctionDefinitionNode
    extends ASTPtRootNode
    The parse tree created from function definitions of the form:
     function (x) x + 5
     
    which defines a function of one argument. The above is assumed to have arguments declared of type general. Monomorphic type-safe functions can be declared using syntax like:
     function (x:int) x+5
     
    This declares that the function only takes integer arguments. The return type (in this case integer, since the result of adding 5 to an integer is an integer) is inferred automatically. FIXME: check argument name duplication
    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Xiaojun Liu, Steve Neuendorffer
    See Also:
    ASTPtRootNode, PtParser, Token
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (nsmyth)
    • Field Detail

      • _argList

        protected java.util.ArrayList _argList
      • _argTypes

        protected Type[] _argTypes
    • Constructor Detail

      • ASTPtFunctionDefinitionNode

        public ASTPtFunctionDefinitionNode​(int id)
        Create a function definition node with an id.
        Parameters:
        id - the id.
      • ASTPtFunctionDefinitionNode

        public ASTPtFunctionDefinitionNode​(PtParser p,
                                           int id)
        Create a function definition node with a parser and an id.
        Parameters:
        p - The parser
        id - the id
    • Method Detail

      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clone the parse tree node by invoking the clone() method of the base class. The new node copies the list of operators (+, -) represented by this node.
        Overrides:
        clone in class ASTPtRootNode
        Returns:
        A new parse tree node.
        Throws:
        java.lang.CloneNotSupportedException - If the superclass clone() method throws it.
      • getArgumentNameList

        public java.util.List getArgumentNameList()
        Return the list of argument names.
        Returns:
        The list of argument names.
      • getArgumentTypes

        public Type[] getArgumentTypes()
        Return the type of the arguments, or null if type inference has not occurred yet.
        Returns:
        the type of the arguments, or null if type inference has not occurred yet.
      • getExpressionTree

        public ASTPtRootNode getExpressionTree()
        Return the parse tree of the expression for this function.
        Returns:
        the parse tree of the expression for this function.
      • isCongruent

        public boolean isCongruent​(ASTPtRootNode node,
                                   java.util.Map renaming)
        Return true if this node is (hierarchically) congruent to the given node, under the given renaming of bound identifiers. Derived classes should extend this method to add additional necessary congruency checks.
        Overrides:
        isCongruent in class ASTPtRootNode
        Parameters:
        node - The node to compare to.
        renaming - A map from String to String that gives a renaming from identifiers in this node to identifiers in the given node.
        Returns:
        True if the node is congruent.