Class ClassNode
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Expression
com.oracle.js.parser.ir.ClassNode
- All Implemented Interfaces:
LexicalContextNode, LexicalContextScope, Cloneable
IR representation for class definitions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.oracle.truffle.api.strings.TruffleString -
Constructor Summary
ConstructorsConstructorDescriptionClassNode(long token, int finish, IdentNode ident, Expression classHeritage, ClassElement constructor, List<ClassElement> classElements, List<Expression> classDecorators, Scope scope, int staticElementCount, boolean hasPrivateMethods, boolean hasPrivateInstanceMethods, boolean hasInstanceFieldsOrAccessors, boolean hasClassElementDecorators) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaccept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor) Accept function for the node given a lexical context.<R> Raccept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor) final Nodeaccept(NodeVisitor<? extends LexicalContext> visitor) Provides a means to navigate the IR.final <R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.Get method definitions except the constructor.The expression of theextendsclause.Get the constructor method definition.Decorators.getIdent()Class identifier.intgetScope()intbooleanbooleanbooleanbooleanbooleanbooleanbooleanReturns true if the class has any instance elements that need to be initialized in the constructor (i.e.setClassElements(List<ClassElement> classElements) setConstructor(ClassElement constructor) setDecorators(List<Expression> decorators) voidtoString(StringBuilder sb, boolean printType) Print logic that decides whether to show the optimistic type or not - for example it should not be printed after just parse, when it hasn't been computed, or has been set to a trivially provable valueMethods inherited from class Expression
getFinish, getFinishWithoutParens, getStart, getStartWithoutParens, isAlwaysFalse, isAlwaysTrue, isParenthesized, isSelfModifying, makeParenthesizedMethods inherited from class Node
clone, equals, getSourceOrder, getToken, hashCode, isAssignment, isLoop, isTokenType, tokenType, toString, toStringMethods inherited from interface LexicalContextNode
accept, accept
-
Field Details
-
PRIVATE_CONSTRUCTOR_BINDING_NAME
public static final com.oracle.truffle.api.strings.TruffleString PRIVATE_CONSTRUCTOR_BINDING_NAME
-
-
Constructor Details
-
ClassNode
public ClassNode(long token, int finish, IdentNode ident, Expression classHeritage, ClassElement constructor, List<ClassElement> classElements, List<Expression> classDecorators, Scope scope, int staticElementCount, boolean hasPrivateMethods, boolean hasPrivateInstanceMethods, boolean hasInstanceFieldsOrAccessors, boolean hasClassElementDecorators) Constructor.- Parameters:
token- tokenfinish- finish
-
-
Method Details
-
getIdent
Class identifier. Optional. -
getClassHeritage
The expression of theextendsclause. Optional. -
getConstructor
Get the constructor method definition. -
setConstructor
-
getClassElements
Get method definitions except the constructor. -
setClassElements
-
getDecorators
Decorators. -
setDecorators
-
accept
Description copied from interface:LexicalContextNodeAccept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context- Specified by:
acceptin interfaceLexicalContextNode- Parameters:
lc- lexical contextvisitor- node visitor- Returns:
- new node or same node depending on state change
-
accept
- Specified by:
acceptin interfaceLexicalContextNode
-
getScope
- Specified by:
getScopein interfaceLexicalContextScope
-
getClassHeadScope
-
hasInstanceFieldsOrAccessors
public boolean hasInstanceFieldsOrAccessors() -
getInstanceElementCount
public int getInstanceElementCount() -
hasStaticElements
public boolean hasStaticElements() -
getStaticElementCount
public int getStaticElementCount() -
hasPrivateMethods
public boolean hasPrivateMethods() -
hasPrivateInstanceMethods
public boolean hasPrivateInstanceMethods() -
hasClassElementDecorators
public boolean hasClassElementDecorators() -
needsInitializeInstanceElements
public boolean needsInitializeInstanceElements()Returns true if the class has any instance elements that need to be initialized in the constructor (i.e. fields, accessors, or private methods). -
isAnonymous
public boolean isAnonymous() -
toString
Description copied from class:NodePrint logic that decides whether to show the optimistic type or not - for example it should not be printed after just parse, when it hasn't been computed, or has been set to a trivially provable value -
accept
Description copied from class:NodeProvides a means to navigate the IR.- Specified by:
acceptin interfaceLexicalContextNode- Specified by:
acceptin classNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Specified by:
acceptin interfaceLexicalContextNode- Specified by:
acceptin classNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-