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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! Process-global registry of builtin signatures.
//!
//! `harn-vm` owns the implementations and emits one `&'static BuiltinDef<H>`
//! per `#[harn_builtin]`-annotated function via the `harn-builtin-macros`
//! crate. At startup the driver (CLI, LSP, lint, serve, dap, tests) installs
//! the full slice of signatures here; the parser/typechecker then reads them
//! through [`installed_signatures`].
//!
//! This decouples `harn-parser` (which needs to see signatures to typecheck)
//! from `harn-vm` (which owns the impls) without a dependency cycle —
//! `harn-parser` depends only on this crate plus `harn-builtin-meta`, never
//! on the vm.
use OnceLock;
use BuiltinSignature;
/// A complete description of one builtin: its signature, its aliases, the
/// runtime handler (typed by the consumer via `H`), and optional metadata.
///
/// `H` is parametric so this crate stays free of any handler-type
/// dependency. `harn-vm` instantiates it as
/// `BuiltinDef<VmBuiltinHandler>`; parser-only consumers ignore the handler
/// and read just the [`Self::sig`] field.
/// Process-global slice of installed signatures, populated once by the
/// driver. Reads via [`installed_signatures`] are O(1); writes via
/// [`install_builtin_signatures`] are one-shot.
static INSTALLED: = new;
/// Install the process-global signature registry. Called once by the driver
/// (CLI, LSP, lint, serve, dap) at startup. Test harnesses that build a Vm
/// via `harn_vm::stdlib::stdlib_probe_vm()` inherit the install through that
/// helper.
///
/// # Panics
/// Panics if called more than once with different slices. Repeat calls with
/// the same pointer are tolerated (CLI + test harness can both call it).
/// Reset the installed slice — only callable from tests (`#[cfg(test)]`
/// guarded). Avoids leaking state across in-process unit tests that need
/// to swap the installed slice. **Not** for production use.
/// Read the installed signature slice. Returns an empty slice before the
/// first call to [`install_builtin_signatures`] (e.g. in pure-parser unit
/// tests that don't need a registry).
/// True when the registry has been populated. Useful for guards in parser
/// code that wants to assert it's running in a configured driver context.