|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.javascript.rhino.Node
public class Node
This class implements the root of the intermediate representation.
Nested Class Summary | |
---|---|
static class |
Node.AncestorIterable
Iterator to go up the ancestor tree. |
class |
Node.FileLevelJsDocBuilder
An inner class that provides back-door access to the license property of the JSDocInfo property for this node. |
static class |
Node.SideEffectFlags
A helper class for getting and setting the side-effect flags. |
Field Summary | |
---|---|
static int |
ATTRIBUTE_FLAG
|
static int |
BOTH
|
static int |
BRACELESS_TYPE
|
static int |
BREAK_PROP
|
static int |
CASEARRAY_PROP
|
static int |
CASES_PROP
|
static int |
CATCH_SCOPE_PROP
|
static int |
CODEOFFSET_PROP
|
static int |
COLUMN_BITS
COLUMN_BITS represents how many of the lower-order bits of sourcePosition are reserved for storing the column number. |
static int |
COLUMN_MASK
COLUMN_MASK stores a value where bits storing the column number are set, and bits storing the line are not set. |
static int |
CONTINUE_PROP
|
static int |
DEBUGSOURCE_PROP
|
static int |
DECR_FLAG
|
static int |
DEFAULT_PROP
|
static int |
DESCENDANTS_FLAG
|
static int |
DIRECT_EVAL
|
static int |
DIRECTCALL_PROP
|
static int |
DIRECTIVES
|
static int |
EMPTY_BLOCK
|
static int |
ENUM_PROP
|
static int |
FINALLY_PROP
|
static int |
FIXUPS_PROP
|
static int |
FLAG_ARGUMENTS_UNMODIFIED
|
static int |
FLAG_GLOBAL_STATE_UNMODIFIED
|
static int |
FLAG_LOCAL_RESULTS
|
static int |
FLAG_NO_THROWS
|
static int |
FLAG_THIS_UNMODIFIED
|
static int |
FREE_CALL
|
static int |
FUNCTION_PROP
|
static int |
INCRDECR_PROP
|
static int |
IS_CONSTANT_NAME
|
static int |
IS_DISPATCHER
|
static int |
IS_NAMESPACE
|
static int |
IS_OPTIONAL_PARAM
|
static int |
IS_VAR_ARGS_PARAM
|
static int |
ISNUMBER_PROP
|
static int |
JSDOC_INFO_PROP
|
static int |
LABEL_ID_PROP
|
static int |
LABEL_PROP
|
static int |
LAST_PROP
|
static int |
LASTUSE_PROP
|
static int |
LEFT
|
static int |
LOCAL_BLOCK_PROP
|
static int |
LOCAL_PROP
|
static int |
LOCALCOUNT_PROP
|
static int |
MAX_COLUMN_NUMBER
MAX_COLUMN_NUMBER represents the maximum column number that can be represented. |
static int |
MEMBER_TYPE_PROP
|
static int |
NAME_PROP
|
static int |
NO_SIDE_EFFECTS
|
static int |
NON_SPECIALCALL
|
static int |
OBJECT_IDS_PROP
|
static int |
OPT_ARG_NAME
|
static int |
ORIGINALNAME_PROP
|
static int |
PARENTHESIZED_PROP
|
static int |
POST_FLAG
|
static int |
PROPERTY_FLAG
|
static int |
QUOTED_PROP
|
static int |
REGEXP_PROP
|
static int |
RIGHT
|
static int |
SIDE_EFFECT_FLAGS
|
static int |
SIDE_EFFECTS_ALL
|
static int |
SIDE_EFFECTS_FLAGS_MASK
|
static int |
SKIP_INDEXES_PROP
|
static int |
SOURCENAME_PROP
|
static int |
SPECIAL_PROP_PROP
|
static int |
SPECIALCALL_EVAL
|
static int |
SPECIALCALL_PROP
|
static int |
SPECIALCALL_WITH
|
static int |
SYNTHETIC_BLOCK_PROP
|
static int |
TARGET_PROP
|
static int |
TARGETBLOCK_PROP
|
static int |
TEMP_PROP
|
static int |
TYPE_PROP
|
static int |
USES_PROP
|
static int |
VAR_ARGS_NAME
|
static int |
VARIABLE_PROP
|
static int |
VARS_PROP
|
Constructor Summary | |
---|---|
Node(int nodeType)
|
|
Node(int nodeType,
int lineno,
int charno)
|
|
Node(int nodeType,
Node child)
|
|
Node(int nodeType,
Node[] children)
|
|
Node(int nodeType,
Node[] children,
int lineno,
int charno)
|
|
Node(int nodeType,
Node child,
int lineno,
int charno)
|
|
Node(int nodeType,
Node left,
Node right)
|
|
Node(int nodeType,
Node left,
Node right,
int lineno,
int charno)
|
|
Node(int nodeType,
Node left,
Node mid,
Node right)
|
|
Node(int nodeType,
Node left,
Node mid,
Node right,
int lineno,
int charno)
|
|
Node(int nodeType,
Node left,
Node mid,
Node mid2,
Node right)
|
|
Node(int nodeType,
Node left,
Node mid,
Node mid2,
Node right,
int lineno,
int charno)
|
Method Summary | |
---|---|
void |
addChildAfter(Node newChild,
Node node)
Add 'child' after 'node'. |
void |
addChildBefore(Node newChild,
Node node)
Add 'child' before 'node'. |
void |
addChildrenToBack(Node children)
|
void |
addChildrenToFront(Node children)
|
void |
addChildToBack(Node child)
|
void |
addChildToFront(Node child)
|
void |
addSuppression(String warning)
Adds a warning to be suppressed. |
void |
appendStringTree(Appendable appendable)
|
String |
checkTreeEquals(Node node2)
Checks if the subtree under this node is the same as another subtree. |
boolean |
checkTreeEqualsSilent(Node node2)
If this is a compilation pass and not a test, do not construct error strings. |
boolean |
checkTreeTypeAwareEqualsSilent(Node node2)
Checks if the subtree under this node is the same as another subtree including types. |
Iterable<Node> |
children()
Return an iterable object that iterates over this nodes's children. |
Node |
cloneNode()
|
Node |
clonePropsFrom(Node other)
Clone the properties from the provided node without copying the property object. |
Node |
cloneTree()
|
Node |
copyInformationFrom(Node other)
Copies source file and name information from the other node given to the current node. |
Node |
copyInformationFromForTree(Node other)
Copies source file and name information from the other node to the entire tree rooted at this node. |
void |
detachChildren()
Removes all children from this node and isolates the children from each other. |
Node |
detachFromParent()
Removes this node from its parent. |
protected static int |
extractCharno(int lineCharNo)
Extracts the character number and character number from a merged line char number (see mergeLineCharNo(int, int) ). |
protected static int |
extractLineno(int lineCharNo)
Extracts the line number and character number from a merged line char number (see mergeLineCharNo(int, int) ). |
Node |
getAncestor(int level)
Gets the ancestor node relative to this. |
Node.AncestorIterable |
getAncestors()
Iterates all of the node's ancestors excluding itself. |
boolean |
getBooleanProp(int propType)
|
int |
getCharno()
|
Node |
getChildAtIndex(int i)
|
Node |
getChildBefore(Node child)
|
int |
getChildCount()
|
Set<String> |
getDirectives()
Returns the set of ES5 directives for this node. |
double |
getDouble()
Can only be called when getType() == TokenStream.NUMBER |
int |
getExistingIntProp(int propType)
|
Node |
getFirstChild()
|
int |
getIntProp(int propType)
Returns the integer value for the property, or 0 if the property is not defined. |
Node.FileLevelJsDocBuilder |
getJsDocBuilderForNode()
|
JSDocInfo |
getJSDocInfo()
Get the JSDocInfo attached to this node. |
JSType |
getJSType()
|
Node |
getLastChild()
|
Node |
getLastSibling()
|
int |
getLineno()
|
Node |
getNext()
|
Node |
getParent()
|
Object |
getProp(int propType)
|
String |
getQualifiedName()
This function takes a set of GETPROP nodes and produces a string that is each property separated by dots. |
int |
getSideEffectFlags()
Returns the side effects flags for this node. |
String |
getString()
Can only be called when node has String context. |
int |
getType()
|
boolean |
hasChild(Node child)
|
boolean |
hasChildren()
|
boolean |
hasMoreThanOneChild()
Check for more than one child more efficiently than by iterating over all the children as is done with Node.getChildCount(). |
boolean |
hasOneChild()
Check for one child more efficiently than by iterating over all the children as is done with Node.getChildCount(). |
boolean |
hasSideEffects()
|
boolean |
isEquivalentTo(Node node)
Returns true if this node is equivalent semantically to another |
boolean |
isLocalResultCall()
Returns true if this node is a function or constructor call that returns a primitive or a local object (an object that has no other references). |
boolean |
isNoSideEffectsCall()
Returns true if this node is a function or constructor call that has no side effects. |
boolean |
isOnlyModifiesThisCall()
|
boolean |
isOptionalArg()
Returns whether this node is an optional argument node. |
boolean |
isQualifiedName()
Returns whether a node corresponds to a simple or a qualified name, such as x or a.b.c or this.a . |
boolean |
isQuotedString()
This should only be called for STRING nodes children of OBJECTLIT. |
boolean |
isSyntheticBlock()
Returns whether this is a synthetic block that should not be considered a real source block. |
boolean |
isUnscopedQualifiedName()
Returns whether a node corresponds to a simple or a qualified name without a "this" reference, such as a.b.c , but not this.a
. |
boolean |
isVarArgs()
Returns whether this node is a variable length argument node. |
protected static int |
mergeLineCharNo(int lineno,
int charno)
Merges the line number and character number in one integer. |
static Node |
newNumber(double number)
|
static Node |
newNumber(double number,
int lineno,
int charno)
|
static Node |
newString(int type,
String str)
|
static Node |
newString(int type,
String str,
int lineno,
int charno)
|
static Node |
newString(String str)
|
static Node |
newString(String str,
int lineno,
int charno)
|
void |
putBooleanProp(int propType,
boolean value)
|
void |
putIntProp(int propType,
int value)
|
void |
putProp(int propType,
Object value)
|
void |
removeChild(Node child)
Detach a child from its parent and siblings. |
Node |
removeChildAfter(Node prev)
|
Node |
removeChildren()
|
Node |
removeFirstChild()
Removes the first child of Node. |
void |
removeProp(int propType)
|
void |
replaceChild(Node child,
Node newChild)
Detaches child from Node and replaces it with newChild. |
void |
replaceChildAfter(Node prevChild,
Node newChild)
|
void |
setCharno(int charno)
|
void |
setDirectives(Set<String> val)
Sets the ES5 directives on this node. |
void |
setDouble(double s)
Can only be called when getType() == TokenStream.NUMBER |
void |
setIsSyntheticBlock(boolean val)
Sets whether this is a synthetic block that should not be considered a real source block. |
void |
setJSDocInfo(JSDocInfo info)
Sets the JSDocInfo attached to this node. |
void |
setJSType(JSType jsType)
|
void |
setLineno(int lineno)
|
void |
setOptionalArg(boolean optionalArg)
Sets whether this node is an optional argument node. |
void |
setQuotedString()
This should only be called for STRING nodes children of OBJECTLIT. |
void |
setSideEffectFlags(int flags)
Marks this function or constructor call's side effect flags. |
void |
setSideEffectFlags(Node.SideEffectFlags flags)
|
void |
setString(String s)
Can only be called when node has String context. |
void |
setType(int type)
|
void |
setVarArgs(boolean varArgs)
Sets whether this node is a variable length argument node. |
void |
setWasEmptyNode(boolean val)
Sets whether this is a synthetic block that should not be considered a real source block. |
Iterable<Node> |
siblings()
Return an iterable object that iterates over this nodes's siblings. |
static String |
tokenToName(int token)
|
String |
toString()
|
String |
toString(boolean printSource,
boolean printAnnotations,
boolean printType)
|
String |
toStringTree()
|
boolean |
wasEmptyNode()
Returns whether this is a synthetic block that should not be considered a real source block. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int LOCAL_BLOCK_PROP
public static final int OBJECT_IDS_PROP
public static final int CATCH_SCOPE_PROP
public static final int LABEL_ID_PROP
public static final int TARGET_PROP
public static final int BREAK_PROP
public static final int CONTINUE_PROP
public static final int ENUM_PROP
public static final int FUNCTION_PROP
public static final int TEMP_PROP
public static final int LOCAL_PROP
public static final int CODEOFFSET_PROP
public static final int FIXUPS_PROP
public static final int VARS_PROP
public static final int USES_PROP
public static final int REGEXP_PROP
public static final int CASES_PROP
public static final int DEFAULT_PROP
public static final int CASEARRAY_PROP
public static final int SOURCENAME_PROP
public static final int TYPE_PROP
public static final int SPECIAL_PROP_PROP
public static final int LABEL_PROP
public static final int FINALLY_PROP
public static final int LOCALCOUNT_PROP
public static final int TARGETBLOCK_PROP
public static final int VARIABLE_PROP
public static final int LASTUSE_PROP
public static final int ISNUMBER_PROP
public static final int DIRECTCALL_PROP
public static final int SPECIALCALL_PROP
public static final int DEBUGSOURCE_PROP
public static final int JSDOC_INFO_PROP
public static final int VAR_ARGS_NAME
public static final int SKIP_INDEXES_PROP
public static final int INCRDECR_PROP
public static final int MEMBER_TYPE_PROP
public static final int NAME_PROP
public static final int PARENTHESIZED_PROP
public static final int QUOTED_PROP
public static final int OPT_ARG_NAME
public static final int SYNTHETIC_BLOCK_PROP
public static final int EMPTY_BLOCK
public static final int ORIGINALNAME_PROP
public static final int BRACELESS_TYPE
public static final int SIDE_EFFECT_FLAGS
public static final int IS_CONSTANT_NAME
public static final int IS_OPTIONAL_PARAM
public static final int IS_VAR_ARGS_PARAM
public static final int IS_NAMESPACE
public static final int IS_DISPATCHER
public static final int DIRECTIVES
public static final int DIRECT_EVAL
public static final int FREE_CALL
public static final int LAST_PROP
public static final int BOTH
public static final int LEFT
public static final int RIGHT
public static final int NON_SPECIALCALL
public static final int SPECIALCALL_EVAL
public static final int SPECIALCALL_WITH
public static final int DECR_FLAG
public static final int POST_FLAG
public static final int PROPERTY_FLAG
public static final int ATTRIBUTE_FLAG
public static final int DESCENDANTS_FLAG
public static final int COLUMN_BITS
public static final int MAX_COLUMN_NUMBER
public static final int COLUMN_MASK
public static final int FLAG_GLOBAL_STATE_UNMODIFIED
public static final int FLAG_THIS_UNMODIFIED
public static final int FLAG_ARGUMENTS_UNMODIFIED
public static final int FLAG_NO_THROWS
public static final int FLAG_LOCAL_RESULTS
public static final int SIDE_EFFECTS_FLAGS_MASK
public static final int SIDE_EFFECTS_ALL
public static final int NO_SIDE_EFFECTS
Constructor Detail |
---|
public Node(int nodeType)
public Node(int nodeType, Node child)
public Node(int nodeType, Node left, Node right)
public Node(int nodeType, Node left, Node mid, Node right)
public Node(int nodeType, Node left, Node mid, Node mid2, Node right)
public Node(int nodeType, int lineno, int charno)
public Node(int nodeType, Node child, int lineno, int charno)
public Node(int nodeType, Node left, Node right, int lineno, int charno)
public Node(int nodeType, Node left, Node mid, Node right, int lineno, int charno)
public Node(int nodeType, Node left, Node mid, Node mid2, Node right, int lineno, int charno)
public Node(int nodeType, Node[] children, int lineno, int charno)
public Node(int nodeType, Node[] children)
Method Detail |
---|
public static Node newNumber(double number)
public static Node newNumber(double number, int lineno, int charno)
public static Node newString(String str)
public static Node newString(int type, String str)
public static Node newString(String str, int lineno, int charno)
public static Node newString(int type, String str, int lineno, int charno)
public int getType()
public void setType(int type)
public boolean hasChildren()
public Node getFirstChild()
public Node getLastChild()
public Node getNext()
public Node getChildBefore(Node child)
public Node getChildAtIndex(int i)
public Node getLastSibling()
public void addChildToFront(Node child)
public void addChildToBack(Node child)
public void addChildrenToFront(Node children)
public void addChildrenToBack(Node children)
public void addChildBefore(Node newChild, Node node)
public void addChildAfter(Node newChild, Node node)
public void removeChild(Node child)
public void replaceChild(Node child, Node newChild)
public void replaceChildAfter(Node prevChild, Node newChild)
public Node clonePropsFrom(Node other)
other
- The node to clone properties from.
public void removeProp(int propType)
public Object getProp(int propType)
public boolean getBooleanProp(int propType)
public int getIntProp(int propType)
public int getExistingIntProp(int propType)
public void putProp(int propType, Object value)
public void putBooleanProp(int propType, boolean value)
public void putIntProp(int propType, int value)
public int getLineno()
public int getCharno()
public double getDouble() throws UnsupportedOperationException
UnsupportedOperationException
public void setDouble(double s) throws UnsupportedOperationException
UnsupportedOperationException
public String getString() throws UnsupportedOperationException
UnsupportedOperationException
public void setString(String s) throws UnsupportedOperationException
UnsupportedOperationException
public String toString()
toString
in class Object
public String toString(boolean printSource, boolean printAnnotations, boolean printType)
public String toStringTree()
public void appendStringTree(Appendable appendable) throws IOException
IOException
public void setLineno(int lineno)
public void setCharno(int charno)
protected static int mergeLineCharNo(int lineno, int charno)
212-1
it is
adjusted to 212-1
.
protected static int extractLineno(int lineCharNo)
mergeLineCharNo(int, int)
).
protected static int extractCharno(int lineCharNo)
mergeLineCharNo(int, int)
).
public Iterable<Node> children()
Return an iterable object that iterates over this nodes's children.
The iterator does not support the optional operation
Iterator.remove()
.
To iterate over a node's siblings, one can write
Node n = ...; for (Node child : n.children()) { ...
public Iterable<Node> siblings()
Return an iterable object that iterates over this nodes's siblings.
The iterator does not support the optional operation
Iterator.remove()
.
To iterate over a node's siblings, one can write
Node n = ...; for (Node sibling : n.siblings()) { ...
public Node getParent()
public Node getAncestor(int level)
level
- 0 = this, 1 = the parent, etc.public Node.AncestorIterable getAncestors()
public boolean hasOneChild()
public boolean hasMoreThanOneChild()
public int getChildCount()
public boolean hasChild(Node child)
public String checkTreeEquals(Node node2)
public boolean checkTreeEqualsSilent(Node node2)
public boolean checkTreeTypeAwareEqualsSilent(Node node2)
public static String tokenToName(int token)
public boolean isEquivalentTo(Node node)
public boolean hasSideEffects()
public String getQualifiedName()
public boolean isQualifiedName()
x
or a.b.c
or this.a
.
public boolean isUnscopedQualifiedName()
a.b.c
, but not this.a
.
public Node detachFromParent()
public Node removeFirstChild()
public Node removeChildren()
public void detachChildren()
public Node removeChildAfter(Node prev)
public Node cloneNode()
public Node cloneTree()
public Node copyInformationFrom(Node other)
public Node copyInformationFromForTree(Node other)
public JSType getJSType()
public void setJSType(JSType jsType)
public Node.FileLevelJsDocBuilder getJsDocBuilderForNode()
public JSDocInfo getJSDocInfo()
JSDocInfo
attached to this node.
null
if no JSDoc is attached to this
nodepublic void setJSDocInfo(JSDocInfo info)
JSDocInfo
attached to this node.
public void setVarArgs(boolean varArgs)
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.
public boolean isVarArgs()
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.
public void setOptionalArg(boolean optionalArg)
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.
public boolean isOptionalArg()
Token.NAME
nodes
used to define a Token.FUNCTION
's argument list.
public void setIsSyntheticBlock(boolean val)
public boolean isSyntheticBlock()
public void setDirectives(Set<String> val)
public Set<String> getDirectives()
public void addSuppression(String warning)
@suppress
tag in the code.
public void setWasEmptyNode(boolean val)
public boolean wasEmptyNode()
public void setSideEffectFlags(int flags)
Token.CALL
and
Token.NEW
nodes.
public void setSideEffectFlags(Node.SideEffectFlags flags)
public int getSideEffectFlags()
public boolean isOnlyModifiesThisCall()
public boolean isNoSideEffectsCall()
public boolean isLocalResultCall()
public boolean isQuotedString()
public void setQuotedString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |