Skip to content

Commit 9db8fab

Browse files
committed
Add javadoc to the Node class.
1 parent 0267812 commit 9db8fab

File tree

1 file changed

+36
-1
lines changed
  • truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes

1 file changed

+36
-1
lines changed

truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,43 @@
6868
import com.oracle.truffle.api.source.SourceSection;
6969

7070
/**
71-
* Abstract base class for all Truffle nodes.
71+
* Abstract base class for all nodes in the Truffle Abstract Syntax Tree (AST).
72+
* <p>
73+
* The {@code Node} class serves as the foundational class for all nodes within the Truffle
74+
* framework. It provides the core functionality required to build interpreters for guest languages
75+
* by allowing language implementers to define custom nodes representing language constructs.
76+
* <p>
77+
* Key responsibilities and features of the {@code Node} class include:
78+
* <ul>
79+
* <li>Managing the parent-child relationships between nodes, ensuring the integrity of the
80+
* AST.</li>
81+
* <li>Providing mechanisms for adopting and replacing child nodes within the AST, facilitating
82+
* dynamic language features and optimizations.</li>
83+
* <li>Handling source code associations, allowing nodes to represent specific segments of the guest
84+
* language source code via {@link #getSourceSection()}.</li>
85+
* <li>Supporting node cloning and deep copying, enabling the creation of modified copies of node
86+
* trees.</li>
87+
* <li>Facilitating node visitation patterns through the {@link #accept(NodeVisitor)} method and
88+
* providing iteration over child nodes via {@link #getChildren()}.</li>
89+
* <li>Ensuring thread safety and synchronization for modifications to the AST with atomic
90+
* operations and locks via {@link #atomic(Runnable)} and {@link #getLock()}.</li>
91+
* <li>Integrating with Truffle's instrumentation and debugging facilities, allowing for runtime
92+
* observation and modification of AST nodes.</li>
93+
* <li>Reporting polymorphic specializations through {@link #reportPolymorphicSpecialize()}, aiding
94+
* in the optimization processes of the Truffle framework.</li>
95+
* </ul>
96+
* <p>
97+
* Language implementers typically create subclasses of {@code Node} to represent specific language
98+
* constructs and operations. Subclasses can use the {@link Child} and {@link Children} annotations
99+
* to declare child nodes, which the Truffle framework manages automatically.
100+
* <p>
101+
* The {@code Node} class also provides important methods such as {@link #replace(Node)} for
102+
* replacing nodes in the AST, {@link #getParent()} and {@link #getRootNode()} for navigating the
103+
* tree, and {@link #getDescription()} for obtaining a user-readable description of the node.
72104
*
105+
* @see RootNode
106+
* @see NodeVisitor
107+
* @see NodeInterface
73108
* @since 0.8 or earlier
74109
*/
75110
public abstract class Node implements NodeInterface, Cloneable {

0 commit comments

Comments
 (0)