Class ClassNode

All Implemented Interfaces:
LexicalContextNode, LexicalContextScope, Cloneable

public class ClassNode extends Expression implements LexicalContextScope
IR representation for class definitions.
  • 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 - token
      finish - finish
  • Method Details

    • getIdent

      public IdentNode getIdent()
      Class identifier. Optional.
    • getClassHeritage

      public Expression getClassHeritage()
      The expression of the extends clause. Optional.
    • getConstructor

      public ClassElement getConstructor()
      Get the constructor method definition.
    • setConstructor

      public ClassNode setConstructor(ClassElement constructor)
    • getClassElements

      public List<ClassElement> getClassElements()
      Get method definitions except the constructor.
    • setClassElements

      public ClassNode setClassElements(List<ClassElement> classElements)
    • getDecorators

      public List<Expression> getDecorators()
      Decorators.
    • setDecorators

      public ClassNode setDecorators(List<Expression> decorators)
    • accept

      public Node accept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor)
      Description copied from interface: LexicalContextNode
      Accept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context
      Specified by:
      accept in interface LexicalContextNode
      Parameters:
      lc - lexical context
      visitor - node visitor
      Returns:
      new node or same node depending on state change
    • accept

      public <R> R accept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
      Specified by:
      accept in interface LexicalContextNode
    • getScope

      public Scope getScope()
      Specified by:
      getScope in interface LexicalContextScope
    • getClassHeadScope

      public Scope 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

      public void toString(StringBuilder sb, boolean printType)
      Description copied from class: Node
      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 value
      Specified by:
      toString in class Node
      Parameters:
      sb - string builder
      printType - print type?
    • accept

      public final Node accept(NodeVisitor<? extends LexicalContext> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      Specified by:
      accept in interface LexicalContextNode
      Specified by:
      accept in class Node
      Parameters:
      visitor - Node visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required
    • accept

      public final <R> R accept(TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      Specified by:
      accept in interface LexicalContextNode
      Specified by:
      accept in class Node
      Parameters:
      visitor - Node visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required