Class Node
- java.lang.Object
- 
- org.mozilla.javascript.Node
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classNode.NodeIteratorIterates over the children of this Node.
 - 
Field SummaryFields Modifier and Type Field Description static intARROW_FUNCTION_PROPstatic intATTRIBUTE_FLAGstatic intBOTHstatic intCASEARRAY_PROPstatic intCATCH_SCOPE_PROPstatic intCONTROL_BLOCK_PROPstatic intDECR_FLAGstatic intDESCENDANTS_FLAGstatic intDESTRUCTURING_ARRAY_LENGTHstatic intDESTRUCTURING_NAMESstatic intDESTRUCTURING_PARAMSstatic intDIRECTCALL_PROPstatic intEND_DROPS_OFFstatic intEND_RETURNSstatic intEND_RETURNS_VALUEstatic intEND_UNREACHEDThese flags enumerate the possible ways a statement/function can terminate.static intEND_YIELDSstatic intEXPRESSION_CLOSURE_PROPprotected Nodefirststatic intFUNCTION_PROPstatic intGENERATOR_END_PROPstatic intINCRDECR_PROPstatic intISNUMBER_PROPstatic intJSDOC_PROPstatic intLABEL_ID_PROPprotected Nodelaststatic intLAST_PROPstatic intLEFTprotected intlinenostatic intLOCAL_BLOCK_PROPstatic intLOCAL_PROPstatic intMEMBER_TYPE_PROPstatic intNAME_PROPprotected Nodenextstatic intNON_SPECIALCALLstatic intOBJECT_IDS_PROPstatic intPARENTHESIZED_PROPstatic intPOST_FLAGstatic intPROPERTY_FLAGprotected org.mozilla.javascript.Node.PropListItempropListHeadLinked list of properties.static intREGEXP_PROPstatic intRIGHTstatic intSHORTHAND_PROPERTY_NAMEstatic intSKIP_INDEXES_PROPstatic intSPECIALCALL_EVALstatic intSPECIALCALL_PROPstatic intSPECIALCALL_WITHstatic intTARGETBLOCK_PROPstatic intTEMPLATE_LITERAL_PROPstatic intTRAILING_COMMAprotected inttypestatic intVARIABLE_PROP
 - 
Constructor SummaryConstructors Constructor Description 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 SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildAfter(Node newChild, Node node)Add 'child' after 'node'.voidaddChildBefore(Node newChild, Node node)Add 'child' before 'node'.voidaddChildrenToBack(Node children)voidaddChildrenToFront(Node children)voidaddChildToBack(Node child)voidaddChildToFront(Node child)java.math.BigIntegergetBigInt()Can only be called whengetType() == Token.BIGINTNodegetChildBefore(Node child)doublegetDouble()Can only be called whengetType() == Token.NUMBERintgetExistingIntProp(int propType)NodegetFirstChild()intgetIntProp(int propType, int defaultValue)java.lang.StringgetJsDoc()Gets the JsDoc comment string attached to this node.CommentgetJsDocNode()Gets the JsDoc Comment object attached to this node.NodegetLastChild()NodegetLastSibling()intgetLineno()Return the line number recorded for this node.NodegetNext()java.lang.ObjectgetProp(int propType)ScopegetScope()Can only be called when node has String context.java.lang.StringgetString()Can only be called when node has String context.intgetType()booleanhasChildren()booleanhasConsistentReturnUsage()Checks that every return usage in a function body is consistent with the requirements of strict-mode.booleanhasSideEffects()java.util.Iterator<Node>iterator()Returns anIteratorover the node's children.intlabelId()voidlabelId(int labelId)static NodenewNumber(double number)static NodenewString(int type, java.lang.String str)static NodenewString(java.lang.String str)static NodenewTarget()voidputIntProp(int propType, int prop)voidputProp(int propType, java.lang.Object prop)voidremoveChild(Node child)voidremoveChildren()voidremoveProp(int propType)voidreplaceChild(Node child, Node newChild)voidreplaceChildAfter(Node prevChild, Node newChild)voidresetTargets()Recursively unlabel every TARGET or YIELD node in the tree.voidsetBigInt(java.math.BigInteger bigInt)voidsetDouble(double number)voidsetJsDocNode(Comment jsdocNode)Sets the JsDoc comment string attached to this node.voidsetLineno(int lineno)voidsetScope(Scope s)Can only be called when node has String context.voidsetString(java.lang.String s)Can only be called when node has String context.NodesetType(int type)Sets the node type and returns this node.java.lang.StringtoString()java.lang.StringtoStringTree(ScriptNode treeTop)
 
- 
- 
- 
Field Detail- 
FUNCTION_PROPpublic static final int FUNCTION_PROP - See Also:
- Constant Field Values
 
 - 
LOCAL_PROPpublic static final int LOCAL_PROP - See Also:
- Constant Field Values
 
 - 
LOCAL_BLOCK_PROPpublic static final int LOCAL_BLOCK_PROP - See Also:
- Constant Field Values
 
 - 
REGEXP_PROPpublic static final int REGEXP_PROP - See Also:
- Constant Field Values
 
 - 
CASEARRAY_PROPpublic static final int CASEARRAY_PROP - See Also:
- Constant Field Values
 
 - 
TARGETBLOCK_PROPpublic static final int TARGETBLOCK_PROP - See Also:
- Constant Field Values
 
 - 
VARIABLE_PROPpublic static final int VARIABLE_PROP - See Also:
- Constant Field Values
 
 - 
ISNUMBER_PROPpublic static final int ISNUMBER_PROP - See Also:
- Constant Field Values
 
 - 
DIRECTCALL_PROPpublic static final int DIRECTCALL_PROP - See Also:
- Constant Field Values
 
 - 
SPECIALCALL_PROPpublic static final int SPECIALCALL_PROP - See Also:
- Constant Field Values
 
 - 
SKIP_INDEXES_PROPpublic static final int SKIP_INDEXES_PROP - See Also:
- Constant Field Values
 
 - 
OBJECT_IDS_PROPpublic static final int OBJECT_IDS_PROP - See Also:
- Constant Field Values
 
 - 
INCRDECR_PROPpublic static final int INCRDECR_PROP - See Also:
- Constant Field Values
 
 - 
CATCH_SCOPE_PROPpublic static final int CATCH_SCOPE_PROP - See Also:
- Constant Field Values
 
 - 
LABEL_ID_PROPpublic static final int LABEL_ID_PROP - See Also:
- Constant Field Values
 
 - 
MEMBER_TYPE_PROPpublic static final int MEMBER_TYPE_PROP - See Also:
- Constant Field Values
 
 - 
NAME_PROPpublic static final int NAME_PROP - See Also:
- Constant Field Values
 
 - 
CONTROL_BLOCK_PROPpublic static final int CONTROL_BLOCK_PROP - See Also:
- Constant Field Values
 
 - 
PARENTHESIZED_PROPpublic static final int PARENTHESIZED_PROP - See Also:
- Constant Field Values
 
 - 
GENERATOR_END_PROPpublic static final int GENERATOR_END_PROP - See Also:
- Constant Field Values
 
 - 
DESTRUCTURING_ARRAY_LENGTHpublic static final int DESTRUCTURING_ARRAY_LENGTH - See Also:
- Constant Field Values
 
 - 
DESTRUCTURING_NAMESpublic static final int DESTRUCTURING_NAMES - See Also:
- Constant Field Values
 
 - 
DESTRUCTURING_PARAMSpublic static final int DESTRUCTURING_PARAMS - See Also:
- Constant Field Values
 
 - 
JSDOC_PROPpublic static final int JSDOC_PROP - See Also:
- Constant Field Values
 
 - 
EXPRESSION_CLOSURE_PROPpublic static final int EXPRESSION_CLOSURE_PROP - See Also:
- Constant Field Values
 
 - 
SHORTHAND_PROPERTY_NAMEpublic static final int SHORTHAND_PROPERTY_NAME - See Also:
- Constant Field Values
 
 - 
ARROW_FUNCTION_PROPpublic static final int ARROW_FUNCTION_PROP - See Also:
- Constant Field Values
 
 - 
TEMPLATE_LITERAL_PROPpublic static final int TEMPLATE_LITERAL_PROP - See Also:
- Constant Field Values
 
 - 
TRAILING_COMMApublic static final int TRAILING_COMMA - See Also:
- Constant Field Values
 
 - 
LAST_PROPpublic static final int LAST_PROP - See Also:
- Constant Field Values
 
 - 
BOTHpublic static final int BOTH - See Also:
- Constant Field Values
 
 - 
LEFTpublic static final int LEFT - See Also:
- Constant Field Values
 
 - 
RIGHTpublic static final int RIGHT - See Also:
- Constant Field Values
 
 - 
NON_SPECIALCALLpublic static final int NON_SPECIALCALL - See Also:
- Constant Field Values
 
 - 
SPECIALCALL_EVALpublic static final int SPECIALCALL_EVAL - See Also:
- Constant Field Values
 
 - 
SPECIALCALL_WITHpublic static final int SPECIALCALL_WITH - See Also:
- Constant Field Values
 
 - 
DECR_FLAGpublic static final int DECR_FLAG - See Also:
- Constant Field Values
 
 - 
POST_FLAGpublic static final int POST_FLAG - See Also:
- Constant Field Values
 
 - 
PROPERTY_FLAGpublic static final int PROPERTY_FLAG - See Also:
- Constant Field Values
 
 - 
ATTRIBUTE_FLAGpublic static final int ATTRIBUTE_FLAG - See Also:
- Constant Field Values
 
 - 
DESCENDANTS_FLAGpublic static final int DESCENDANTS_FLAG - See Also:
- Constant Field Values
 
 - 
END_UNREACHEDpublic static final int END_UNREACHED These flags enumerate the possible ways a statement/function can terminate. These flags are used by endCheck() and by the Parser to detect inconsistent return usage.END_UNREACHED is reserved for code paths that are assumed to always be able to execute (example: throw, continue) END_DROPS_OFF indicates if the statement can transfer control to the next one. Statement such as return dont. A compound statement may have some branch that drops off control to the next statement. END_RETURNS indicates that the statement can return (without arguments) END_RETURNS_VALUE indicates that the statement can return a value. A compound statement such as if (condition) { return value; } Will be detected as (END_DROPS_OFF | END_RETURN_VALUE) by endCheck() - See Also:
- Constant Field Values
 
 - 
END_DROPS_OFFpublic static final int END_DROPS_OFF - See Also:
- Constant Field Values
 
 - 
END_RETURNSpublic static final int END_RETURNS - See Also:
- Constant Field Values
 
 - 
END_RETURNS_VALUEpublic static final int END_RETURNS_VALUE - See Also:
- Constant Field Values
 
 - 
END_YIELDSpublic static final int END_YIELDS - See Also:
- Constant Field Values
 
 - 
typeprotected int type 
 - 
nextprotected Node next 
 - 
firstprotected Node first 
 - 
lastprotected Node last 
 - 
linenoprotected int lineno 
 - 
propListHeadprotected org.mozilla.javascript.Node.PropListItem propListHead Linked list of properties. Since vast majority of nodes would have no more then 2 properties, linked list saves memory and provides fast lookup. If this does not holds, propListHead can be replaced by UintMap.
 
- 
 - 
Method Detail- 
newNumberpublic static Node newNumber(double number) 
 - 
newStringpublic static Node newString(java.lang.String str) 
 - 
newStringpublic static Node newString(int type, java.lang.String str) 
 - 
getTypepublic int getType() 
 - 
setTypepublic Node setType(int type) Sets the node type and returns this node.
 - 
getJsDocpublic java.lang.String getJsDoc() Gets the JsDoc comment string attached to this node.- Returns:
- the comment string or nullif no JsDoc is attached to this node
 
 - 
getJsDocNodepublic Comment getJsDocNode() Gets the JsDoc Comment object attached to this node.- Returns:
- the Comment or nullif no JsDoc is attached to this node
 
 - 
setJsDocNodepublic void setJsDocNode(Comment jsdocNode) Sets the JsDoc comment string attached to this node.
 - 
hasChildrenpublic boolean hasChildren() 
 - 
getFirstChildpublic Node getFirstChild() 
 - 
getLastChildpublic Node getLastChild() 
 - 
getNextpublic Node getNext() 
 - 
getLastSiblingpublic Node getLastSibling() 
 - 
addChildToFrontpublic void addChildToFront(Node child) 
 - 
addChildToBackpublic void addChildToBack(Node child) 
 - 
addChildrenToFrontpublic void addChildrenToFront(Node children) 
 - 
addChildrenToBackpublic void addChildrenToBack(Node children) 
 - 
removeChildpublic void removeChild(Node child) 
 - 
removeChildrenpublic void removeChildren() 
 - 
iteratorpublic java.util.Iterator<Node> iterator() Returns anIteratorover the node's children.- Specified by:
- iteratorin interface- java.lang.Iterable<Node>
 
 - 
removeProppublic void removeProp(int propType) 
 - 
getProppublic java.lang.Object getProp(int propType) 
 - 
getIntProppublic int getIntProp(int propType, int defaultValue)
 - 
getExistingIntProppublic int getExistingIntProp(int propType) 
 - 
putProppublic void putProp(int propType, java.lang.Object prop)
 - 
putIntProppublic void putIntProp(int propType, int prop)
 - 
getLinenopublic int getLineno() Return the line number recorded for this node.- Returns:
- the line number
 
 - 
setLinenopublic void setLineno(int lineno) 
 - 
getDoublepublic final double getDouble() Can only be called whengetType() == Token.NUMBER
 - 
setDoublepublic final void setDouble(double number) 
 - 
getBigIntpublic java.math.BigInteger getBigInt() Can only be called whengetType() == Token.BIGINT
 - 
setBigIntpublic void setBigInt(java.math.BigInteger bigInt) 
 - 
getStringpublic final java.lang.String getString() Can only be called when node has String context.
 - 
setStringpublic final void setString(java.lang.String s) Can only be called when node has String context.
 - 
getScopepublic Scope getScope() Can only be called when node has String context.
 - 
setScopepublic void setScope(Scope s) Can only be called when node has String context.
 - 
newTargetpublic static Node newTarget() 
 - 
labelIdpublic final int labelId() 
 - 
labelIdpublic void labelId(int labelId) 
 - 
hasConsistentReturnUsagepublic 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.
 
 - 
hasSideEffectspublic boolean hasSideEffects() 
 - 
resetTargetspublic void resetTargets() Recursively unlabel every TARGET or YIELD node in the tree.This is used and should only be used for inlining finally blocks where jsr instructions used to be. It is somewhat hackish, but implementing a clone() operation would take much, much more effort. This solution works for inlining finally blocks because you should never be writing any given block to the class file simultaneously. Therefore, an unlabeling will never occur in the middle of a block. 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
toStringTreepublic java.lang.String toStringTree(ScriptNode treeTop) 
 
- 
 
-