All Packages Class Hierarchy This Package Previous Next Index
Class lib.Node
java.lang.Object
|
+----lib.Node
- public class Node
- extends Object
The class Node
is used to represent the syntex tree. Every
node consists of an ID, a type, a list of children, a reference to its
parent and some further data corresponding to its type.
The types a node can have are defined in class Types
.
-
access
- how to access a variable or method
-
children
- the children of the node are stored here
-
classNode
- pointer to the associated
ClassNode
-
data
- any data to be stored in the node
-
decl
- a reference to the declaration
-
etype
- if this node is part of an expression, the type is store here
-
id
- the node's ID
-
limitLocals
- the number of local variables in a method; only valid for
T_METHDEC
nodes
-
limitStack
- the maximum number of stack cells needed while executing the method;
only valid for
T_METHDEC
nodes
-
lineNo
- line number in source program
-
nextID
- next usable free ID
-
offset
- address of local variable relative to stack frame
-
parent
- the parent
-
type
- the type of the node as defines in
Types
-
Node(int)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields.
-
Node(int, int)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields.
-
Node(int, Object)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields, especially the
data
-member is set to data
.
-
Node(int, Object, int)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields, especially the
data
-member is set to data
.
-
addEdge(Node)
- This method adds an edge from this node to
dest
.
-
getChild(int)
- Returns
idx
th child of the node.
-
getChildren()
- Returns an enumeration for the children.
-
getChildrenCount()
- Returns the number of children.
-
getID()
- Returns the unique ID of the node.
nextID
protected static int nextID
- next usable free ID
id
protected int id
- the node's ID
children
protected Vector children
- the children of the node are stored here
parent
public Node parent
- the parent
classNode
public ClassNode classNode
- pointer to the associated
ClassNode
data
public Object data
- any data to be stored in the node
type
public int type
- the type of the node as defines in
Types
offset
public int offset
- address of local variable relative to stack frame
access
public int access
- how to access a variable or method
decl
public Node decl
- a reference to the declaration
etype
public String etype
- if this node is part of an expression, the type is store here
lineNo
public int lineNo
- line number in source program
limitLocals
public int limitLocals
- the number of local variables in a method; only valid for
T_METHDEC
nodes
limitStack
public int limitStack
- the maximum number of stack cells needed while executing the method;
only valid for
T_METHDEC
nodes
Node
public Node(int type)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields.
- Parameters:
- type - the type of the node
Node
public Node(int type,
int lineNo)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields.
- Parameters:
- type - the type of the node
- lineNo - line number associated with this node
Node
public Node(int type,
Object data)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields, especially the
data
-member is set to data
.
- Parameters:
- type - the type of the node
- data - the object to be stored in the node's
data
-member
Node
public Node(int type,
Object data,
int lineNo)
- The constructor creates a new instance of the object
Node
of type type
and initializes some fields, especially the
data
-member is set to data
.
- Parameters:
- type - the type of the node
- data - the object to be stored in the node's
data
-member
- lineNo - line number associated with this node
addEdge
public int addEdge(Node dest)
- This method adds an edge from this node to
dest
.
NOTE: The order in which the edges are added is significant.
- Parameters:
- dest - the destination node the edge leads to
- Returns:
- the index of the edge/child, or
-1
if an error
occured
getID
public int getID()
- Returns the unique ID of the node.
- Returns:
- the node's ID
getChildrenCount
public int getChildrenCount()
- Returns the number of children.
- Returns:
- number of children
getChild
public Node getChild(int idx)
- Returns
idx
th child of the node.
- Parameters:
- idx - index in children list
- Returns:
- the desired child
getChildren
public Enumeration getChildren()
- Returns an enumeration for the children.
- Returns:
- an
Enumeration
object
All Packages Class Hierarchy This Package Previous Next Index