com.ibm.wala.cast.tree
Interface CAstNode

All Known Implementing Classes:
CAstImpl.CAstNodeImpl, CAstImpl.CAstValueImpl, CAstOperator, CAstValueImpl.CAstNodeValueImpl, CAstValueImpl.CAstValueValueImpl

public interface CAstNode

This interface represents nodes of CAPA Abstract Syntax Trees. It is a deliberately minimal interface, simply assuming that the nodes form a tree and have some minimal state at each node. In particular, a node has a kind---which should be one of the symbolic constants in this file---and potentially has child nodes, a constant values, or possibly both. Note that there is no support for mutating these trees. This is deliberate, and should not be changed. We do not want to force all clients of the capa ast to handle mutating programs. In particular, the DOMO infrastructure has many forms of caching and other operations that rely on the underlying program being immutable. If you need to mutate these trees for some reason---and think carefully if you really need to, since this is meant to be essentially a wire format between components---make specialized implementations that understand how to do that. Also note that this interface does not assume that you need some great big class hierarchy to structure types of nodes in an ast. Some people prefer such hierarchies as a matter of taste, but this interface is designed to not inflict this design choice on others. Finally note that the set of node types in this file is not meant to be exhaustive. As new languages are added, feel free to add new nodes types as needed.


Field Summary
static int ANDOR_EXPR
           
static int ARRAY_LENGTH
           
static int ARRAY_LITERAL
           
static int ARRAY_REF
           
static int ASSERT
           
static int ASSIGN
           
static int ASSIGN_POST_OP
           
static int ASSIGN_PRE_OP
           
static int BINARY_EXPR
           
static int BLOCK_EXPR
          Represents a block of sequentially-executed nodes, the last of which produces the value for the entire block (like progn from lisp).
static int BLOCK_STMT
          Represents a block of sequential statements.
static int BREAK
           
static int CALL
           
static int CAST
           
static int CATCH
           
static int CHOICE_CASE
           
static int CHOICE_EXPR
           
static int CONSTANT
           
static int CONTINUE
           
static int DECL_STMT
           
static int EACH_ELEMENT_GET
           
static int EACH_ELEMENT_HAS_NEXT
           
static int ECHO
           
static int EMPTY
           
static int EMPTY_LIST_EXPR
           
static int ERROR
           
static int EXPR_LIST
           
static int EXPR_STMT
          Represents an expression statement (e.g.
static int FUNCTION_EXPR
           
static int FUNCTION_STMT
           
static int GET_CAUGHT_EXCEPTION
           
static int GOTO
           
static int IF_EXPR
           
static int IF_STMT
           
static int IFGOTO
           
static int INSTANCEOF
           
static int IS_DEFINED_EXPR
           
static int LABEL_STMT
           
static int LIST_EXPR
           
static int LOCAL_SCOPE
           
static int LOOP
          Represents a standard while loop.
static int MONITOR_ENTER
           
static int MONITOR_EXIT
           
static int NEW
           
static int OBJECT_LITERAL
           
static int OBJECT_REF
           
static int OPERATOR
           
static int PRIMITIVE
           
static int RETURN
           
static int RETURN_WITHOUT_BRANCH
           
static int SUB_LANGUAGE_BASE
           
static int SUPER
           
static int SWITCH
          Represents a standard case statement.
static int THIS
           
static int THROW
           
static int TRY
          Represents a standard try/catch statement.
static int TYPE_LITERAL_EXPR
           
static int TYPE_OF
           
static int UNARY_EXPR
           
static int UNWIND
           
static int VAR
           
static int VOID
           
 
Method Summary
 CAstNode getChild(int n)
          Return the nth child of this node.
 int getChildCount()
          How many children does this node have?
 int getKind()
          What kind of node is this? Should return some constant from this file.
 java.lang.Object getValue()
          Returns the constant value represented by this node, if appropriate, and null otherwise.
 

Field Detail

SWITCH

static final int SWITCH
Represents a standard case statement. Children:
  • condition expression
  • BLOCK_STMT containing all the cases

    See Also:
    Constant Field Values

  • LOOP

    static final int LOOP
    Represents a standard while loop. Children:

    See Also:
    Constant Field Values

    BLOCK_STMT

    static final int BLOCK_STMT
    Represents a block of sequential statements. Children:

    See Also:
    Constant Field Values

    TRY

    static final int TRY
    Represents a standard try/catch statement. Note that while some languages choose to bundle together the notion of try/catch and the notion of unwind-protect (aka 'finally'), the CAst does not. There is a separate UNWIND node type. Children:

    See Also:
    Constant Field Values

    EXPR_STMT

    static final int EXPR_STMT
    Represents an expression statement (e.g. "foo();"). Children:

    See Also:
    Constant Field Values

    DECL_STMT

    static final int DECL_STMT
    See Also:
    Constant Field Values

    RETURN

    static final int RETURN
    See Also:
    Constant Field Values

    GOTO

    static final int GOTO
    See Also:
    Constant Field Values

    BREAK

    static final int BREAK
    See Also:
    Constant Field Values

    CONTINUE

    static final int CONTINUE
    See Also:
    Constant Field Values

    IF_STMT

    static final int IF_STMT
    See Also:
    Constant Field Values

    THROW

    static final int THROW
    See Also:
    Constant Field Values

    FUNCTION_STMT

    static final int FUNCTION_STMT
    See Also:
    Constant Field Values

    ASSIGN

    static final int ASSIGN
    See Also:
    Constant Field Values

    ASSIGN_PRE_OP

    static final int ASSIGN_PRE_OP
    See Also:
    Constant Field Values

    ASSIGN_POST_OP

    static final int ASSIGN_POST_OP
    See Also:
    Constant Field Values

    LABEL_STMT

    static final int LABEL_STMT
    See Also:
    Constant Field Values

    IFGOTO

    static final int IFGOTO
    See Also:
    Constant Field Values

    EMPTY

    static final int EMPTY
    See Also:
    Constant Field Values

    RETURN_WITHOUT_BRANCH

    static final int RETURN_WITHOUT_BRANCH
    See Also:
    Constant Field Values

    CATCH

    static final int CATCH
    See Also:
    Constant Field Values

    UNWIND

    static final int UNWIND
    See Also:
    Constant Field Values

    MONITOR_ENTER

    static final int MONITOR_ENTER
    See Also:
    Constant Field Values

    MONITOR_EXIT

    static final int MONITOR_EXIT
    See Also:
    Constant Field Values

    ECHO

    static final int ECHO
    See Also:
    Constant Field Values

    FUNCTION_EXPR

    static final int FUNCTION_EXPR
    See Also:
    Constant Field Values

    EXPR_LIST

    static final int EXPR_LIST
    See Also:
    Constant Field Values

    CALL

    static final int CALL
    See Also:
    Constant Field Values

    GET_CAUGHT_EXCEPTION

    static final int GET_CAUGHT_EXCEPTION
    See Also:
    Constant Field Values

    BLOCK_EXPR

    static final int BLOCK_EXPR
    Represents a block of sequentially-executed nodes, the last of which produces the value for the entire block (like progn from lisp). Children:

    See Also:
    Constant Field Values

    BINARY_EXPR

    static final int BINARY_EXPR
    See Also:
    Constant Field Values

    UNARY_EXPR

    static final int UNARY_EXPR
    See Also:
    Constant Field Values

    IF_EXPR

    static final int IF_EXPR
    See Also:
    Constant Field Values

    ANDOR_EXPR

    static final int ANDOR_EXPR
    See Also:
    Constant Field Values

    NEW

    static final int NEW
    See Also:
    Constant Field Values

    OBJECT_LITERAL

    static final int OBJECT_LITERAL
    See Also:
    Constant Field Values

    VAR

    static final int VAR
    See Also:
    Constant Field Values

    OBJECT_REF

    static final int OBJECT_REF
    See Also:
    Constant Field Values

    CHOICE_EXPR

    static final int CHOICE_EXPR
    See Also:
    Constant Field Values

    CHOICE_CASE

    static final int CHOICE_CASE
    See Also:
    Constant Field Values

    SUPER

    static final int SUPER
    See Also:
    Constant Field Values

    THIS

    static final int THIS
    See Also:
    Constant Field Values

    ARRAY_LITERAL

    static final int ARRAY_LITERAL
    See Also:
    Constant Field Values

    CAST

    static final int CAST
    See Also:
    Constant Field Values

    INSTANCEOF

    static final int INSTANCEOF
    See Also:
    Constant Field Values

    ARRAY_REF

    static final int ARRAY_REF
    See Also:
    Constant Field Values

    ARRAY_LENGTH

    static final int ARRAY_LENGTH
    See Also:
    Constant Field Values

    TYPE_OF

    static final int TYPE_OF
    See Also:
    Constant Field Values

    EACH_ELEMENT_HAS_NEXT

    static final int EACH_ELEMENT_HAS_NEXT
    See Also:
    Constant Field Values

    EACH_ELEMENT_GET

    static final int EACH_ELEMENT_GET
    See Also:
    Constant Field Values

    LIST_EXPR

    static final int LIST_EXPR
    See Also:
    Constant Field Values

    EMPTY_LIST_EXPR

    static final int EMPTY_LIST_EXPR
    See Also:
    Constant Field Values

    TYPE_LITERAL_EXPR

    static final int TYPE_LITERAL_EXPR
    See Also:
    Constant Field Values

    IS_DEFINED_EXPR

    static final int IS_DEFINED_EXPR
    See Also:
    Constant Field Values

    LOCAL_SCOPE

    static final int LOCAL_SCOPE
    See Also:
    Constant Field Values

    CONSTANT

    static final int CONSTANT
    See Also:
    Constant Field Values

    OPERATOR

    static final int OPERATOR
    See Also:
    Constant Field Values

    PRIMITIVE

    static final int PRIMITIVE
    See Also:
    Constant Field Values

    ERROR

    static final int ERROR
    See Also:
    Constant Field Values

    VOID

    static final int VOID
    See Also:
    Constant Field Values

    ASSERT

    static final int ASSERT
    See Also:
    Constant Field Values

    SUB_LANGUAGE_BASE

    static final int SUB_LANGUAGE_BASE
    See Also:
    Constant Field Values
    Method Detail

    getKind

    int getKind()
    What kind of node is this? Should return some constant from this file.


    getValue

    java.lang.Object getValue()
    Returns the constant value represented by this node, if appropriate, and null otherwise.


    getChild

    CAstNode getChild(int n)
    Return the nth child of this node. If there is no such child, this method should throw a NoSuchElementException.


    getChildCount

    int getChildCount()
    How many children does this node have?