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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Copyright (c) 2025-2026 Anton Kundenko <singaraiona@gmail.com>
* All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* Create function objects. Name stored inline in aux[0..15].
* The function pointer is in the i64 field. */
ray_t* ;
ray_t* ;
ray_t* ;
/* Read builtin name from aux[2..15] (null-terminated, max 13 chars).
* Bytes 0-1 reserved for DAG opcode on all function types. */
static inline const char*
/* Global environment: symbol -> function object dict */
ray_err_t ;
void ;
ray_t* ;
ray_t* ;
/* User-facing binder. Refuses any name starting with `.` — that root is
* reserved for system namespaces (.sys, .os, .io, .ipc, …) populated by
* builtin registration. Returns RAY_ERR_RESERVED in that case. */
ray_err_t ;
/* Internal binder used by builtin registration. Identical to ray_env_set
* but WITHOUT the reserved-namespace guard. Do NOT call this from user-
* exposed paths; it is the intended way to populate `.sys` / `.os` etc.
* during ray_lang_init. */
ray_err_t ;
/* Flat variant of ray_env_bind: writes the binding directly into the
* global env hash without traversing dotted-segment dict upserts.
* Used to register every fully-qualified builtin name (`.sys.gc`,
* `.os.getenv`, …) alongside the root namespace dict, so prefix
* lookup (REPL completion + highlighter) enumerates them all. */
ray_err_t ;
/* True if a symbol's interned name starts with `.` — i.e. it belongs to
* the reserved namespace populated at startup by builtin registration.
* User-level binders (ray_env_set, ray_env_set_local, lambda parameter
* installer) refuse such names so system bindings can't be shadowed. */
bool ;
/* True if a symbol is one of the five user-settable IPC connection-hook
* names: `.ipc.on.open`, `.ipc.on.close`, `.ipc.on.sync`, `.ipc.on.async`,
* `.ipc.on.auth`. These are the narrow carve-out from the reserved-name
* reject in `ray_env_set` / `ray_env_set_local` and the compile-time `let`
* guard; everything else under `.ipc.*` stays unsettable. Lazy-interned
* on first probe — idempotent within one sym-table lifetime; the cache
* is invalidated in `ray_env_destroy` so it survives runtime cycles. */
bool ;
/* Stable index → sym-id accessor for the five IPC hook names. Used by
* `src/core/ipc.c` to look up hook bindings from `g_env` without having
* to maintain its own duplicate cache (and its own stale-cache bug
* across runtime cycles). `idx` must be one of:
* 0 = .ipc.on.open
* 1 = .ipc.on.close
* 2 = .ipc.on.sync
* 3 = .ipc.on.async
* 4 = .ipc.on.auth
* Out-of-range returns -1. */
int64_t ;
/* Resolve a name for a Rayfall expression (tree-walking eval or bytecode
* op_resolve): returns an OWNED ref (rc >= 1) that the caller must
* release, or NULL if undefined. Unlike ray_env_get which returns a
* borrowed ref and leaves refcount management to the caller, env_resolve
* retains before returning — so name-resolution sites can drop their
* manual ray_retain and still participate in the dotted-sym temporal
* extraction path (e.g. `trades.Time.dd`), which allocates fresh values
* mid-walk. */
ray_t* ;
/* Prefix lookup: scan global env + keywords for names starting with prefix.
* Fills results[] with pointers to interned name strings (valid until next
* sym table mutation). Returns count of matches (up to max_results).
* Results are sorted alphabetically. */
int64_t ;
/* True iff `name[0..len)` is an exact-match global env binding or
* keyword. Does NOT intern the probed string (unlike ray_env_get which
* would need a sym_id). Used by the REPL highlighter to decide whether
* to paint the current word green — the prefix-lookup API returns only
* the first-matching entry, which would misclassify `de` as non-builtin
* when an alphabetically-earlier `desc`/`del` hits the same prefix. */
bool ;
/* Iterate global environment entries.
* Fills sym_ids[] and vals[] with up to max_entries items.
* Returns count of entries written. */
int32_t ;
/* Iterate ONLY user-defined bindings (slots last written via ray_env_set,
* not ray_env_bind). Powers the journal snapshot — the .qdb file would
* otherwise carry every builtin, which is wasteful and breaks on reload
* because builtin function objects hold absolute pointers from the prior
* process. A user `(set + 42)` over a builtin flips the slot to user-
* defined, so explicit overrides are preserved. */
int32_t ;
/* Total number of bindings currently in the global env (builtins +
* user). Useful for sizing buffers before ray_env_list. */
int32_t ;
/* Reverse-map a builtin function object to the sym_id it is bound under in the
* global env, or -1 if it is not a registered global builtin. Serialization
* uses this to recover a builtin's full name, which the object only inlines to
* 13 bytes (ray_fn_name). */
int64_t ;
/* Local scope stack for lexical binding (let, do, lambda) */
ray_err_t ;
ray_err_t ;
void ;
int32_t ;
ray_err_t ;
ray_t* ;
bool ;
ray_err_t ;
ray_t* ;
ray_err_t ;
/* Compiled-lambda local materialization (OP_SCOPE_BEGIN / OP_SCOPE_END).
* bind: push a fresh frame and bind syms[i] -> slots[i] (NULL slots —
* let-locals whose initializer hasn't run yet — are skipped) plus
* `self` -> self_obj, so a dynamic tree-walk eval inside bytecode
* resolves the same names the tree-walk fallback would.
* sync: write the frame's (possibly let-updated) values back into the
* slots, then pop the frame. */
ray_err_t ;
void ;
/* RAY_ENV_H */