pub struct Node {
pub id: NodeId,
pub expr: Arc<Expr>,
pub decorators: Vec<Decorator>,
pub directives: Vec<Directive>,
pub type_hint: Option<TypeNode>,
pub range: TokenRange,
pub doc_comment: Option<String>,
}Fields§
§id: NodeIdStable identity assigned at construction. Analyzer side-tables key off this; not part of structural equality.
expr: Arc<Expr>Arc rather than Box so analyzer side-tables (node_index) and
every walker that snapshots a Node share the body via reference
counting instead of recursively deep-cloning the subtree. The AST
is effectively immutable after parsing; the lone in-place rewrite
(closure desugar in lower.rs) reassigns the field on a freshly
built node before any shared clones exist.
decorators: Vec<Decorator>@name(...) decorators stacked above this node — value-transform
hooks (host-registered + user-definable).
directives: Vec<Directive>#name ... directives stacked above this node — structural /
declarative attributes (host-registered only). Parsed in source
order; the analyzer interprets them by name + shape.
type_hint: Option<TypeNode>§range: TokenRange§doc_comment: Option<String>Documentation extracted from leading comments immediately preceding the node.
Implementations§
Source§impl Node
impl Node
pub fn new(expr: Expr, range: TokenRange) -> Self
Sourcepub fn with_id(id: NodeId, expr: Expr, range: TokenRange) -> Self
pub fn with_id(id: NodeId, expr: Expr, range: TokenRange) -> Self
Construct a Node with a caller-supplied NodeId. Used by tests
and (rarely) by AST rewriters that want to preserve the original
node’s identity after a structural transform.