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
//! Sequence encoder for IR node lists.
use put_node;
use crateWireEncodeErr;
use crateput_len_u32;
use crateNode;
/// Append a length-prefixed sequence of IR nodes to `out`.
///
/// # Role
///
/// This is the canonical encoder for statement lists: entry bodies,
/// `If`/`Loop`/`Block` children, and any other `[Node]` slice. The
/// wire format represents every list as a little-endian `u32` count
/// followed by that many encoded nodes.
///
/// # Invariants
///
/// * `out` is appended to only.
/// * The length field written equals `nodes.len()`; truncation or
/// padding would corrupt the decoder's bounds checks (I10).
///
/// # Pre-conditions
///
/// `nodes.len()` must fit in `u32`; otherwise the wire format cannot
/// represent the sequence.
///
/// # Return semantics
///
/// * `Ok(())` – count and all nodes were appended.
/// * `Err(String)` – an actionable diagnostic starting with `Fix:`.
///
/// # Failure modes
///
/// * **Length overflow** – `put_len_u32` rejects `nodes.len()` >
/// `u32::MAX` with a `Fix:` error advising the caller to split
/// the program.
/// * **Node encoding failure** – any error from [`put_node`] is
/// propagated upward unchanged.