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
// @author kazuya kawaguchi (a.k.a. kazupon)
// @license MIT
//
//! Extended Data section constants.
//!
//! See `design/007-binary-ast/format.md#extended-data-section` for the full
//! specification. Per-Kind layouts (e.g. `JsdocBlock` 18 / 40 bytes,
//! `JsdocTag` 8 / 22 bytes) live in the per-Kind layout helpers shipped in
//! later sub-phases (Phase 1.1a writer / 1.1b decoder).
/// Alignment requirement for each Extended Data record start (8 bytes).
///
/// The encoder inserts zero-fill padding before each new record so that
/// every offset reserved in the 30-bit Node Data payload is divisible by
/// [`EXTENDED_DATA_ALIGNMENT`]. This guarantees that u32 fields can be read
/// without unaligned-access penalties on every supported target.
pub const EXTENDED_DATA_ALIGNMENT: usize = 8;
/// Maximum byte offset that fits in the 30-bit Node Data payload
/// (`2^30 - 1`). Cross-checked against
/// [`super::node_record::PAYLOAD_MAX`].
pub const EXTENDED_DATA_MAX_OFFSET: u32 = - 1;
/// Size of one **NodeList metadata** slot stored inline inside a parent's
/// Extended Data block. Layout: `head_index: u32` followed by `count: u16`.
///
/// Parents with one or more variable-length child lists (`JsdocBlock.tags`,
/// `TypeUnion.elements`, …) reserve `LIST_METADATA_SIZE` bytes per list at
/// known per-Kind offsets. The writer patches `(head_index, count)` after
/// the last child of each list is emitted; the decoder reads the head and
/// walks `next_sibling` exactly `count` times. This replaces the Kind 0x7F
/// `NodeList` wrapper that previously sat between the parent and its
/// children.
pub const LIST_METADATA_SIZE: usize = 4 + 2;