Package com.ibm.wala.cast.tree
Interface CAstNode
-
- All Known Implementing Classes:
CAstImpl.CAstNodeImpl,CAstImpl.CAstValueImpl,CAstOperator,CAstValueImpl.CAstNodeValueImpl,CAstValueImpl.CAstValueValueImpl
public interface CAstNodeThis 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
Fields Modifier and Type Field Description static intANDOR_EXPRstatic intARRAY_LENGTHstatic intARRAY_LITERALstatic intARRAY_REFstatic intASSERTstatic intASSIGNstatic intASSIGN_POST_OPstatic intASSIGN_PRE_OPstatic intBINARY_EXPRstatic intBLOCK_EXPRRepresents a block of sequentially-executed nodes, the last of which produces the value for the entire block (like progn from lisp).static intBLOCK_STMTRepresents a block of sequential statements.static intBREAKstatic intCALLstatic intCASTstatic intCATCHstatic intCHOICE_CASEstatic intCHOICE_EXPRstatic intCONSTANTstatic intCONTINUEstatic intDECL_STMTstatic intEACH_ELEMENT_GETstatic intEACH_ELEMENT_HAS_NEXTstatic intECHOstatic intEMPTYstatic intEMPTY_LIST_EXPRstatic intERRORstatic intEXPR_LISTstatic intEXPR_STMTRepresents an expression statement (e.g.static intFORIN_LOOPstatic intFUNCTION_EXPRstatic intFUNCTION_STMTstatic intGET_CAUGHT_EXCEPTIONstatic intGOTOstatic intIF_EXPRstatic intIF_STMTstatic intIFGOTOstatic intINCLUDEstatic intINSTANCEOFstatic intIS_DEFINED_EXPRstatic intLABEL_STMTstatic intLIST_EXPRstatic intLOCAL_SCOPEstatic intLOOPRepresents a standard while loop.static intMACRO_VARstatic intMONITOR_ENTERstatic intMONITOR_EXITstatic intNAMED_ENTITY_REFstatic intNEWstatic intNEW_ENCLOSINGstatic intOBJECT_LITERALstatic intOBJECT_REFstatic intOPERATORstatic intPRIMITIVEstatic intRETURNstatic intRETURN_WITHOUT_BRANCHstatic intSPECIAL_PARENT_SCOPEstatic intSUB_LANGUAGE_BASEstatic intSUPERstatic intSWITCHRepresents a standard case statement.static intTHISstatic intTHROWstatic intTRYRepresents a standard try/catch statement.static intTYPE_LITERAL_EXPRstatic intTYPE_OFstatic intUNARY_EXPRstatic intUNWINDstatic intVARstatic intVOIDstatic intYIELD_STMT
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CAstNodegetChild(int n)Return the nth child of this node.intgetChildCount()How many children does this node have?intgetKind()What kind of node is this? Should return some constant from this file.ObjectgetValue()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:- expression denoting the loop condition
- statement denoting the loop body
- See Also:
- Constant Field Values
-
BLOCK_STMT
static final int BLOCK_STMT
Represents a block of sequential statements. Children:- statement #1
- statement #2
- ...
- 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:- the code of the try block.
- the code of the catch block
- ...
- See Also:
- Constant Field Values
-
EXPR_STMT
static final int EXPR_STMT
Represents an expression statement (e.g. "foo();"). Children:- the expression
- 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
-
YIELD_STMT
static final int YIELD_STMT
- See Also:
- Constant Field Values
-
FORIN_LOOP
static final int FORIN_LOOP
- 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:- node 1
- node 2
- ...
- block value expression
- 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
-
MACRO_VAR
static final int MACRO_VAR
- See Also:
- Constant Field Values
-
NEW_ENCLOSING
static final int NEW_ENCLOSING
- See Also:
- Constant Field Values
-
LOCAL_SCOPE
static final int LOCAL_SCOPE
- See Also:
- Constant Field Values
-
SPECIAL_PARENT_SCOPE
static final int SPECIAL_PARENT_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
-
INCLUDE
static final int INCLUDE
- See Also:
- Constant Field Values
-
NAMED_ENTITY_REF
static final int NAMED_ENTITY_REF
- 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
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?
-
-