org.mozilla.javascript

Class Node

Known Direct Subclasses:
Node.Jump, ScriptOrFnNode

public class Node
extends java.lang.Object

This class implements the root of the intermediate representation.
Authors:
Norris Boyd
Mike McCabe

Nested Class Summary

static class
Node.Jump

Field Summary

static int
ATTRIBUTE_FLAG
static int
BOTH
static int
CASEARRAY_PROP
static int
CATCH_SCOPE_PROP
static int
CONTROL_BLOCK_PROP
static int
DECR_FLAG
static int
DESCENDANTS_FLAG
static int
DIRECTCALL_PROP
static int
FUNCTION_PROP
static int
INCRDECR_PROP
static int
ISNUMBER_PROP
static int
LABEL_ID_PROP
static int
LAST_PROP
static int
LEFT
static int
LOCAL_BLOCK_PROP
static int
LOCAL_PROP
static int
MEMBER_TYPE_PROP
static int
NAME_PROP
static int
NON_SPECIALCALL
static int
OBJECT_IDS_PROP
static int
PARENTHESIZED_PROP
static int
POST_FLAG
static int
PROPERTY_FLAG
static int
REGEXP_PROP
static int
RIGHT
static int
SKIP_INDEXES_PROP
static int
SPECIALCALL_EVAL
static int
SPECIALCALL_PROP
static int
SPECIALCALL_WITH
static int
TARGETBLOCK_PROP
static int
VARIABLE_PROP

Constructor Summary

Node(int nodeType)
Node(int nodeType, int line)
Node(int nodeType, Node child)
Node(int nodeType, Node child, int line)
Node(int nodeType, Node left, Node right)
Node(int nodeType, Node left, Node right, int line)
Node(int nodeType, Node left, Node mid, Node right)
Node(int nodeType, Node left, Node mid, Node right, int line)

Method Summary

void
addChildAfter(Node newChild, Node node)
Add 'child' after 'node'.
void
addChildBefore(Node newChild, Node node)
Add 'child' before 'node'.
void
addChildToBack(Node child)
void
addChildToFront(Node child)
void
addChildrenToBack(Node children)
void
addChildrenToFront(Node children)
Node
getChildBefore(Node child)
double
getDouble()
Can only be called when getType() == Token.NUMBER
int
getExistingIntProp(int propType)
Node
getFirstChild()
int
getIntProp(int propType, int defaultValue)
Node
getLastChild()
Node
getLastSibling()
int
getLineno()
Node
getNext()
Object
getProp(int propType)
String
getString()
Can only be called when node has String context.
int
getType()
boolean
hasChildren()
boolean
hasConsistentReturnUsage()
Checks that every return usage in a function body is consistent with the requirements of strict-mode.
boolean
hasSideEffects()
int
labelId()
void
labelId(int labelId)
static Node
newNumber(double number)
static Node
newString(String str)
static Node
newString(int type, String str)
static Node
newTarget()
void
putIntProp(int propType, int prop)
void
putProp(int propType, Object prop)
void
removeChild(Node child)
void
removeProp(int propType)
void
replaceChild(Node child, Node newChild)
void
replaceChildAfter(Node prevChild, Node newChild)
void
setDouble(double number)
void
setString(String s)
Can only be called when node has String context.
void
setType(int type)
String
toString()
String
toStringTree(ScriptOrFnNode treeTop)

Field Details

ATTRIBUTE_FLAG

public static final int ATTRIBUTE_FLAG
Field Value:
2

BOTH

public static final int BOTH
Field Value:
0

CASEARRAY_PROP

public static final int CASEARRAY_PROP
Field Value:
5

CATCH_SCOPE_PROP

public static final int CATCH_SCOPE_PROP
Field Value:
14

CONTROL_BLOCK_PROP

public static final int CONTROL_BLOCK_PROP
Field Value:
18

DECR_FLAG

public static final int DECR_FLAG
Field Value:
1

DESCENDANTS_FLAG

public static final int DESCENDANTS_FLAG
Field Value:
4

DIRECTCALL_PROP

public static final int DIRECTCALL_PROP
Field Value:
9

FUNCTION_PROP

public static final int FUNCTION_PROP
Field Value:
1

INCRDECR_PROP

public static final int INCRDECR_PROP
Field Value:
13

ISNUMBER_PROP

public static final int ISNUMBER_PROP
Field Value:
8

LABEL_ID_PROP

public static final int LABEL_ID_PROP
Field Value:
15

LAST_PROP

public static final int LAST_PROP
Field Value:
19

LEFT

public static final int LEFT
Field Value:
1

LOCAL_BLOCK_PROP

public static final int LOCAL_BLOCK_PROP
Field Value:
3

LOCAL_PROP

public static final int LOCAL_PROP
Field Value:
2

MEMBER_TYPE_PROP

public static final int MEMBER_TYPE_PROP
Field Value:
16

NAME_PROP

public static final int NAME_PROP
Field Value:
17

NON_SPECIALCALL

public static final int NON_SPECIALCALL
Field Value:
0

OBJECT_IDS_PROP

public static final int OBJECT_IDS_PROP
Field Value:
12

PARENTHESIZED_PROP

public static final int PARENTHESIZED_PROP
Field Value:
19

POST_FLAG

public static final int POST_FLAG
Field Value:
2

PROPERTY_FLAG

public static final int PROPERTY_FLAG
Field Value:
1

REGEXP_PROP

public static final int REGEXP_PROP
Field Value:
4

RIGHT

public static final int RIGHT
Field Value:
2

SKIP_INDEXES_PROP

public static final int SKIP_INDEXES_PROP
Field Value:
11

SPECIALCALL_EVAL

public static final int SPECIALCALL_EVAL
Field Value:
1

SPECIALCALL_PROP

public static final int SPECIALCALL_PROP
Field Value:
10

SPECIALCALL_WITH

public static final int SPECIALCALL_WITH
Field Value:
2

TARGETBLOCK_PROP

public static final int TARGETBLOCK_PROP
Field Value:
6

VARIABLE_PROP

public static final int VARIABLE_PROP
Field Value:
7

Constructor Details

Node

public Node(int nodeType)

Node

public Node(int nodeType,
            int line)

Node

public Node(int nodeType,
            Node child)

Node

public Node(int nodeType,
            Node child,
            int line)

Node

public Node(int nodeType,
            Node left,
            Node right)

Node

public Node(int nodeType,
            Node left,
            Node right,
            int line)

Node

public Node(int nodeType,
            Node left,
            Node mid,
            Node right)

Node

public Node(int nodeType,
            Node left,
            Node mid,
            Node right,
            int line)

Method Details

addChildAfter

public void addChildAfter(Node newChild,
                          Node node)
Add 'child' after 'node'.

addChildBefore

public void addChildBefore(Node newChild,
                           Node node)
Add 'child' before 'node'.

addChildToBack

public void addChildToBack(Node child)

addChildToFront

public void addChildToFront(Node child)

addChildrenToBack

public void addChildrenToBack(Node children)

addChildrenToFront

public void addChildrenToFront(Node children)

getChildBefore

public Node getChildBefore(Node child)

getDouble

public final double getDouble()
Can only be called when getType() == Token.NUMBER

getExistingIntProp

public int getExistingIntProp(int propType)

getFirstChild

public Node getFirstChild()

getIntProp

public int getIntProp(int propType,
                      int defaultValue)

getLastChild

public Node getLastChild()

getLastSibling

public Node getLastSibling()

getLineno

public int getLineno()

getNext

public Node getNext()

getProp

public Object getProp(int propType)

getString

public final String getString()
Can only be called when node has String context.

getType

public int getType()

hasChildren

public boolean hasChildren()

hasConsistentReturnUsage

public boolean hasConsistentReturnUsage()
Checks that every return usage in a function body is consistent with the requirements of strict-mode.
Returns:
true if the function satisfies strict mode requirement.

hasSideEffects

public boolean hasSideEffects()

labelId

public final int labelId()

labelId

public void labelId(int labelId)

newNumber

public static Node newNumber(double number)

newString

public static Node newString(String str)

newString

public static Node newString(int type,
                             String str)

newTarget

public static Node newTarget()

putIntProp

public void putIntProp(int propType,
                       int prop)

putProp

public void putProp(int propType,
                    Object prop)

removeChild

public void removeChild(Node child)

removeProp

public void removeProp(int propType)

replaceChild

public void replaceChild(Node child,
                         Node newChild)

replaceChildAfter

public void replaceChildAfter(Node prevChild,
                              Node newChild)

setDouble

public final void setDouble(double number)

setString

public final void setString(String s)
Can only be called when node has String context.

setType

public void setType(int type)

toString

public String toString()

toStringTree

public String toStringTree(ScriptOrFnNode treeTop)