.. java:import:: fr.inria.tapenade.representation NewSymbolHolder .. java:import:: fr.inria.tapenade.representation TapEnv .. java:import:: fr.inria.tapenade.representation TapList .. java:import:: java.io IOException .. java:import:: java.util Enumeration .. java:import:: java.util Hashtable Tree ==== .. java:package:: fr.inria.tapenade.utils :noindex: .. java:type:: public abstract class Tree A node of an Abstract Syntax Tree. Constructors ------------ Tree ^^^^ .. java:constructor:: protected Tree(Operator operator) :outertype: Tree Build a new Tree with given operator. Methods ------- addChild ^^^^^^^^ .. java:method:: public void addChild(Tree addedChild, int rank) :outertype: Tree Adds a new child to this node. Allowed only when this is a list node. Inserts the added child so that its rank will be "rank" (rank of 1st child is 1). Negative ranks are allowed, designating positions backward from the end, e.g -1 is last child, -2 is last but one. addChildren ^^^^^^^^^^^ .. java:method:: public void addChildren(Tree[] addedChildren, int rank) :outertype: Tree Adds a set of new children to this node. Allowed only when this is a list node. Inserts the addedChildren so that the rank of the first of them will be "rank" (rank of 1st child is 1). Negative ranks are allowed, designating positions backward from the end, e.g -1 is last child, -2 is last but one. When rank is negative, it will be the position of the last of addedChildren. addChildren ^^^^^^^^^^^ .. java:method:: public void addChildren(TapList addedChildren, int rank) :outertype: Tree Adds a set of new children to this node. Allowed only when this is a list node. Inserts the addedChildren so that the rank of the first of them will be "rank" (rank of 1st child is 1). Negative ranks are allowed, designating positions backward from the end, e.g -1 is last child, -2 is last but one. When rank is negative, it will be the position of the last of addedChildren. allAnnotations ^^^^^^^^^^^^^^ .. java:method:: public Enumeration allAnnotations() :outertype: Tree :return: all annotations currently attached to this Tree. checkSyntax ^^^^^^^^^^^ .. java:method:: public boolean checkSyntax(String path) :outertype: Tree :param path: Some string that will name this Tree in potential error messages. :return: true if the syntax of this Tree is correct, i.e. all children trees non null and in correct phylum. checkSyntax ^^^^^^^^^^^ .. java:method:: protected boolean checkSyntax(Phylum phylum, String path) :outertype: Tree :return: true if the syntax of this Tree is correct, i.e. all children trees non null and in correct phylum. children ^^^^^^^^ .. java:method:: public Tree[] children() :outertype: Tree :return: the array of the children of this Tree node. Allowed only when this is either a fixed or list arity node, but not an atom node. childrenList ^^^^^^^^^^^^ .. java:method:: public TapList childrenList() :outertype: Tree :return: the ordered list of children of this Tree node. Allowed only when this is either a fixed or list arity node, but not an atom node. connectNewChild ^^^^^^^^^^^^^^^ .. java:method:: protected void connectNewChild(Tree newChild, Tree[] parentNewChildren, int index) :outertype: Tree Utility to branch a child Tree under this Tree, as its new index-th child, with a correct full management of the "parent" links. :param parentNewChildren: the future array of children of this parent tree, which may be different from the previous array, for instance in the case of variable-arity lists. copy ^^^^ .. java:method:: public abstract Tree copy() :outertype: Tree :return: a copy of this Tree, including a copy of all its annotations. Also manages copies of unfinished identifiers such as #xd#. copyAnnotations ^^^^^^^^^^^^^^^ .. java:method:: @SuppressWarnings public void copyAnnotations(Tree model) :outertype: Tree Copies the annotations of the model onto this Tree. Also manages copies of unfinished identifiers such as #xd#. TODO: annotations are dangerous: copyAnnotations() share them between copies only when the annotation already exists, Some parts on the code rely on this! This should be cleaned up, but meanwhile, we force explicit sharing upon copy for some specific annotations (see annotationsToShareAlways). cutChild ^^^^^^^^ .. java:method:: public Tree cutChild(int rank) :outertype: Tree Cuts off this Tree's child of rank "rank", and returns it (rank of 1st child is 1). Allowed only when this is either a fixed or list arity node, but not an atom node. Leaves a null in this Tree, at the location of the cut child. down ^^^^ .. java:method:: public Tree down(int rank) :outertype: Tree :return: the child of rank "rank" of this Tree node (rank of 1st child is 1). Allowed only when this is either a fixed or list arity node, but not an atom node. equalsTree ^^^^^^^^^^ .. java:method:: public abstract boolean equalsTree(Tree other) :outertype: Tree :return: True iff this Tree is equal to the other Tree. Doesn't check for equality of annotations. getAnnotation ^^^^^^^^^^^^^ .. java:method:: public T getAnnotation(String name) :outertype: Tree :return: the value of annotation "name" of this Tree, null if not present. getAnnotationPair ^^^^^^^^^^^^^^^^^ .. java:method:: @SuppressWarnings public TapPair getAnnotationPair(String name) :outertype: Tree :param name: The name of the annotation. :return: the annotation pair found, null otherwise. getRank ^^^^^^^ .. java:method:: protected int getRank(Tree child) :outertype: Tree :return: the rank of the given child node in this node (rank of 1st child is 1). getRemoveAnnotation ^^^^^^^^^^^^^^^^^^^ .. java:method:: public T getRemoveAnnotation(String name) :outertype: Tree :return: the value of annotation "name" of this Tree, null if not present, and removes it if it was present. intValue ^^^^^^^^ .. java:method:: public int intValue() :outertype: Tree :return: the integer value contained in this atom node. Allowed only when this is an integer atom node. isAtom ^^^^^^ .. java:method:: public abstract boolean isAtom() :outertype: Tree :return: True iff this Tree node is an atom. isFixed ^^^^^^^ .. java:method:: public abstract boolean isFixed() :outertype: Tree :return: True iff this Tree node is a fixed-arity node. isIntAtom ^^^^^^^^^ .. java:method:: public abstract boolean isIntAtom() :outertype: Tree :return: True iff this Tree node is an atom that contains an integer. isList ^^^^^^ .. java:method:: public abstract boolean isList() :outertype: Tree :return: True iff this Tree node is a list node. isStringAtom ^^^^^^^^^^^^ .. java:method:: public abstract boolean isStringAtom() :outertype: Tree :return: True iff this Tree node is an atom that contains a String. length ^^^^^^ .. java:method:: public int length() :outertype: Tree :return: the number of children of this Tree node. Allowed only when this is either a fixed or list arity node, but not an atom node. opCode ^^^^^^ .. java:method:: public int opCode() :outertype: Tree :return: The integer code of the Operator of this Tree node. opName ^^^^^^ .. java:method:: public String opName() :outertype: Tree :return: The name of the Operator of this Tree node. operator ^^^^^^^^ .. java:method:: public Operator operator() :outertype: Tree :return: The Operator of this Tree node. parent ^^^^^^ .. java:method:: public Tree parent() :outertype: Tree :return: the parent node of this Tree node, or null if no parent. rankInParent ^^^^^^^^^^^^ .. java:method:: public int rankInParent() :outertype: Tree :return: the rank of this node in its parent node. Rank starts at 1. @return -1 if no parent. removeAnnotation ^^^^^^^^^^^^^^^^ .. java:method:: public void removeAnnotation(String name) :outertype: Tree Removes the annotation "name" of this Tree. removeChild ^^^^^^^^^^^ .. java:method:: public void removeChild(int rank) :outertype: Tree Cuts off this Tree's child of rank "rank" (rank of 1st child is 1). Allowed only when this is a list arity node. Leaves no hole in this Tree in place of the cut child. right ^^^^^ .. java:method:: protected Tree right() :outertype: Tree Used only for TopDownTreeWalk(). Remove some later day? setAnnotation ^^^^^^^^^^^^^ .. java:method:: public TapPair setAnnotation(String name, T val) :outertype: Tree Sets the value of annotation "name" of this Tree. If the annotation is not already present, creates it. :return: the annotation pair, after setting is done. setChild ^^^^^^^^ .. java:method:: public void setChild(Tree newChild, int rank) :outertype: Tree Replaces this Tree's child of rank "rank" with the new child (rank of 1st child is 1). Allowed only when this is either a fixed or list arity node, but not an atom node. When this is a list node and rank is larger than its length, this enlarges the list and pads with null children (is this really necessary?) setOperator ^^^^^^^^^^^ .. java:method:: public void setOperator(Operator oper) :outertype: Tree setParent ^^^^^^^^^ .. java:method:: public void setParent(Tree parent) :outertype: Tree Set the parent node. setValue ^^^^^^^^ .. java:method:: public void setValue(int value) :outertype: Tree Sets the value attached to an integer atom Tree node. Allowed only when this is an integer atom node. setValue ^^^^^^^^ .. java:method:: public void setValue(String value) :outertype: Tree Sets the value attached to a string atom Tree node. Allowed only when this is a string atom node. stringValue ^^^^^^^^^^^ .. java:method:: public String stringValue() :outertype: Tree :return: the value contained in this atom node, in the form of a String. Allowed only when this is an atom node. toString ^^^^^^^^ .. java:method:: @Override public String toString() :outertype: Tree :return: a String representation of this Tree. writeToILFile ^^^^^^^^^^^^^ .. java:method:: protected abstract void writeToILFile(java.io.BufferedWriter fileWriter) throws IOException :outertype: Tree Prints into a file, as an AST. :throws IOException: if an input or output error is detected.