Interface Node

All Superinterfaces:
AttributedObject
All Known Subinterfaces:
ExpressionInternal, Statement, VariableInternal
All Known Implementing Classes:
AssignmentStatement, BlockStatement, BreakStatement, CaseBranch, ClassGeneratorImpl, DefinitionStatement, ExpressionFactory.ArrayIndexExpression, ExpressionFactory.ArrayLengthExpression, ExpressionFactory.BinaryOperatorExpression, ExpressionFactory.CallExpression, ExpressionFactory.CastExpression, ExpressionFactory.ConstantExpression, ExpressionFactory.ExpressionBase, ExpressionFactory.FieldAccessExpressionBase, ExpressionFactory.IfExpression, ExpressionFactory.InstofExpression, ExpressionFactory.NewArrExpression, ExpressionFactory.NewObjExpression, ExpressionFactory.NonStaticCallExpression, ExpressionFactory.NonStaticFieldAccessExpression, ExpressionFactory.StaticCallExpression, ExpressionFactory.StaticFieldAccessExpression, ExpressionFactory.SuperCallExpression, ExpressionFactory.SuperObjExpression, ExpressionFactory.ThisExpression, ExpressionFactory.ThisObjExpression, ExpressionFactory.UnaryOperatorExpression, ExpressionFactory.VariableImpl, ExpressionFactory.VoidExpression, FieldGenerator, IfStatement, MethodGenerator, NodeBase, ReturnStatement, StatementBase, SwitchStatement, ThrowStatement, TryStatement, WhileStatement

public interface Node extends AttributedObject
Represents a node in the AST used to generate code. All nodes support the dynamic attribute facility.
Author:
Ken Cavanaugh
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(Visitor visitor)
    Accept the visitor and allow it to perform actions on this Node.
    <T extends Node>
    T
    copy(Class<T> cls)
    Make a deep copy of this node.
    <T extends Node>
    T
    copy(Node newParent, Class<T> cls)
    Copy setting a new parent in the result.
    <T extends Node>
    T
    getAncestor(Class<T> type)
    Return the first ancestor of this node of the given type, if any.
    int
    id()
    Return the unique ID of this node.
    Return the Node that contains (and created) this Node.
    void
    parent(Node node)
    Set the parent to a new value.

    Methods inherited from interface org.glassfish.pfl.dynamic.codegen.impl.AttributedObject

    attributes, get, set
  • Method Details

    • parent

      Node parent()
      Return the Node that contains (and created) this Node.
    • id

      int id()
      Return the unique ID of this node. This starts at 1 and is incremented for each new Node that is created.
    • parent

      void parent(Node node)
      Set the parent to a new value. Should only be called inside NodeBase.
    • getAncestor

      <T extends Node> T getAncestor(Class<T> type)
      Return the first ancestor of this node of the given type, if any. Throws IllegalArgumentException if not found.
    • copy

      <T extends Node> T copy(Class<T> cls)
      Make a deep copy of this node. If nn = n.copy(), then n.parent() == nn.parent(), which also means that the parent is NOT copied.
    • copy

      <T extends Node> T copy(Node newParent, Class<T> cls)
      Copy setting a new parent in the result.
    • accept

      void accept(Visitor visitor)
      Accept the visitor and allow it to perform actions on this Node.