1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// @author kazuya kawaguchi (a.k.a. kazupon)
// @license MIT
//
//! Per-Kind `write_*` helpers (Phase 1.0b: signatures only).
//!
//! There is one `write_*` function per concrete node Kind (15 comment AST
//! kinds + 45 TypeNode kinds = 60 helpers, organized in two submodules).
//! `Sentinel` and `NodeList` are emitted internally by [`super::BinaryWriter`]
//! and have no dedicated helper.
//!
//! Each helper:
//! 1. Resolves a [`NodeIndex`] for the new node (= `nodes_buffer.len() / 24`),
//! 2. Writes a 24-byte node record (`Kind` + Common Data + padding +
//! Pos/End + Node Data + parent_index + next_sibling),
//! 3. For Extended-type Kinds, reserves Extended Data via
//! [`super::ExtendedDataBuilder::reserve`] and writes the per-Kind
//! payload,
//! 4. Backpatches the previous sibling's `next_sibling` field if needed,
//! 5. Returns the new [`NodeIndex`] so the caller can wire it as a child.
//!
//! Phase 1.0b only ships the function signatures with `unimplemented!()`
//! bodies — Phase 1.1a will fill them in following the per-Kind layouts in
//! `format::node_record` and the spec text in
//! `design/007-binary-ast/format.md`.
use NonZeroU32;
/// Index into the **Nodes** section.
///
/// Newtype around `u32` (with `0` reserved for the `node[0]` sentinel; the
/// wrapper itself uses `NonZeroU32` storage so `Option<NodeIndex>` is
/// 4 bytes).
;