@oseo/runtime-c 0.0.0-stage → 0.1.0-canary.370

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +674 -0
  2. package/MIT-LICENSE.txt +21 -0
  3. package/README.md +28 -2
  4. package/UNICODE-LICENSE.txt +39 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +269 -0
  8. package/dist/index.js.map +1 -0
  9. package/native/oseo_runtime.h +2618 -0
  10. package/native/runtime_agent.c +1717 -0
  11. package/native/runtime_arguments.c +379 -0
  12. package/native/runtime_array.c +5766 -0
  13. package/native/runtime_array_buffer.c +1748 -0
  14. package/native/runtime_async_generator.c +972 -0
  15. package/native/runtime_atomics.c +1283 -0
  16. package/native/runtime_bigint.c +1387 -0
  17. package/native/runtime_bigint_object.c +626 -0
  18. package/native/runtime_binding.c +1029 -0
  19. package/native/runtime_boolean.c +320 -0
  20. package/native/runtime_clock.c +181 -0
  21. package/native/runtime_clock_posix.c +599 -0
  22. package/native/runtime_core.c +488 -0
  23. package/native/runtime_data_view.c +1135 -0
  24. package/native/runtime_date.c +1997 -0
  25. package/native/runtime_descriptor.c +1104 -0
  26. package/native/runtime_disposal.c +1667 -0
  27. package/native/runtime_enumeration.c +636 -0
  28. package/native/runtime_error.c +997 -0
  29. package/native/runtime_event_loop.c +653 -0
  30. package/native/runtime_function.c +3667 -0
  31. package/native/runtime_generator.c +1120 -0
  32. package/native/runtime_internal.h +5578 -0
  33. package/native/runtime_iterator.c +5379 -0
  34. package/native/runtime_json.c +1992 -0
  35. package/native/runtime_map.c +1563 -0
  36. package/native/runtime_math.c +918 -0
  37. package/native/runtime_memory.c +1365 -0
  38. package/native/runtime_module.c +884 -0
  39. package/native/runtime_number.c +2077 -0
  40. package/native/runtime_object.c +423 -0
  41. package/native/runtime_object_builtin.c +3901 -0
  42. package/native/runtime_primitive.c +2268 -0
  43. package/native/runtime_process.c +744 -0
  44. package/native/runtime_promise.c +3378 -0
  45. package/native/runtime_property.c +815 -0
  46. package/native/runtime_proxy.c +1557 -0
  47. package/native/runtime_realm.c +435 -0
  48. package/native/runtime_reflect.c +648 -0
  49. package/native/runtime_regexp.c +3519 -0
  50. package/native/runtime_regexp_matcher.c +3559 -0
  51. package/native/runtime_regexp_symbol.c +1495 -0
  52. package/native/runtime_set.c +1775 -0
  53. package/native/runtime_string.c +2886 -0
  54. package/native/runtime_string_match.c +1185 -0
  55. package/native/runtime_symbol.c +1010 -0
  56. package/native/runtime_typed_array.c +5137 -0
  57. package/native/runtime_unicode_tables.h +14670 -0
  58. package/native/runtime_uri.c +700 -0
  59. package/native/runtime_weak_collection.c +1299 -0
  60. package/package.json +38 -3
@@ -0,0 +1,2618 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Oseo C runtime library.
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2026 Hong Minhee <https://hongminhee.org/>
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in
17
+ * all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ #ifndef OSEO_RUNTIME_H
29
+ #define OSEO_RUNTIME_H
30
+
31
+ #include <stdbool.h>
32
+ #include <stddef.h>
33
+ #include <stdint.h>
34
+
35
+ /* Shared frame ceiling, also used to omit bodies that cannot be entered. */
36
+ #define OSEO_MAX_ACTIVE_FRAME_SLOTS 65536u
37
+
38
+ /* Toolchains describe callable C temporaries independently of heap roots. */
39
+ #ifndef OSEO_CALLABLE_FRAME_MULTIPLIER
40
+ #define OSEO_CALLABLE_FRAME_MULTIPLIER 1u
41
+ #endif
42
+ #ifndef OSEO_CALLABLE_FRAME_BASE_SLOTS
43
+ #define OSEO_CALLABLE_FRAME_BASE_SLOTS 32u
44
+ #endif
45
+ #define OSEO_CALLABLE_FRAME_COST(slots) \
46
+ ((slots) <= OSEO_CALLABLE_FRAME_BASE_SLOTS ? (slots) : \
47
+ (slots) > OSEO_CALLABLE_FRAME_BASE_SLOTS + \
48
+ (OSEO_MAX_ACTIVE_FRAME_SLOTS - OSEO_CALLABLE_FRAME_BASE_SLOTS) / \
49
+ OSEO_CALLABLE_FRAME_MULTIPLIER ? \
50
+ OSEO_MAX_ACTIVE_FRAME_SLOTS + 1u : \
51
+ OSEO_CALLABLE_FRAME_BASE_SLOTS + \
52
+ ((slots) - OSEO_CALLABLE_FRAME_BASE_SLOTS) * \
53
+ OSEO_CALLABLE_FRAME_MULTIPLIER)
54
+
55
+ typedef uint64_t OseoValue;
56
+
57
+ typedef enum {
58
+ OSEO_STATUS_NORMAL = 0,
59
+ OSEO_STATUS_THROW = 1,
60
+ /*
61
+ * A PrepareForTailCall site recorded the call it owes in the context
62
+ * and discarded its own frame. Only a generated function body that
63
+ * returns `oseo_tail_call`'s result, and the runtime's own
64
+ * PrepareForTailCall sites, produce it. `oseo_call_function` and
65
+ * `oseo_call_complete` perform every recorded call before they
66
+ * return, so no other consumer ever observes this status.
67
+ */
68
+ OSEO_STATUS_TAIL_CALL = 2,
69
+ } OseoStatus;
70
+
71
+ typedef enum {
72
+ OSEO_FUNCTION_ORDINARY = 0,
73
+ OSEO_FUNCTION_ARROW = 1,
74
+ OSEO_FUNCTION_ASYNC = 2,
75
+ OSEO_FUNCTION_ASYNC_ARROW = 3,
76
+ OSEO_FUNCTION_INTERNAL = 4,
77
+ /* Dynamic `this`, like ordinary, but never constructible and without
78
+ * an own `prototype` property, matching MethodDefinition semantics.
79
+ * Getter and setter closures share this kind: SetFunctionName's
80
+ * "get "/"set " prefix is orthogonal to constructibility and is
81
+ * requested separately through OseoFunctionNamePrefix. */
82
+ OSEO_FUNCTION_METHOD = 5,
83
+ /* Dynamic `this` and never constructible. Calling one runs only the
84
+ * environment and parameter prologue and returns a suspended
85
+ * generator whose `prototype` object reaches the realm-owned
86
+ * %GeneratorPrototype% methods. */
87
+ OSEO_FUNCTION_GENERATOR = 6,
88
+ /* A class constructor: constructible, with a non-writable,
89
+ * non-enumerable, non-configurable `prototype` object that carries
90
+ * the class's methods, and never callable without `new`. */
91
+ OSEO_FUNCTION_CLASS = 7,
92
+ /* Like OSEO_FUNCTION_GENERATOR, but the generator it returns reports
93
+ * every step through a promise and its body suspends to await as
94
+ * well as to yield. Its `prototype` object reaches the realm-owned
95
+ * %AsyncGeneratorPrototype% methods. */
96
+ OSEO_FUNCTION_ASYNC_GENERATOR = 8,
97
+ /* BoundFunction exotic object. Calls prepend the captured arguments and
98
+ * use the captured receiver; construction forwards to a constructible
99
+ * target and substitutes that target for the bound new target. */
100
+ OSEO_FUNCTION_BOUND = 9,
101
+ } OseoFunctionKind;
102
+
103
+ /*
104
+ * The SetFunctionName prefix applied to an accessor closure's `name`
105
+ * after the ordinary static-key or computed-key name resolves, so both
106
+ * paths share one prefixing step.
107
+ */
108
+ typedef enum {
109
+ OSEO_FUNCTION_NAME_PREFIX_NONE = 0,
110
+ OSEO_FUNCTION_NAME_PREFIX_GET = 1,
111
+ OSEO_FUNCTION_NAME_PREFIX_SET = 2,
112
+ } OseoFunctionNamePrefix;
113
+
114
+ typedef struct {
115
+ OseoStatus status;
116
+ OseoValue value;
117
+ } OseoResult;
118
+
119
+ typedef struct OseoRootFrame OseoRootFrame;
120
+ typedef struct OseoHeapObject OseoHeapObject;
121
+ typedef struct OseoContext OseoContext;
122
+ typedef struct OseoConstructorScope OseoConstructorScope;
123
+ typedef struct OseoActivation OseoActivation;
124
+
125
+ typedef OseoResult (*OseoFunctionDispatcher)(
126
+ OseoContext *context,
127
+ OseoValue callee,
128
+ OseoValue receiver,
129
+ size_t argument_count,
130
+ const OseoValue *arguments,
131
+ OseoValue new_target
132
+ );
133
+
134
+ /* One immutable host Script, compiled and linked before execution. */
135
+ typedef struct {
136
+ const uint16_t *source;
137
+ size_t source_length;
138
+ OseoFunctionDispatcher evaluate;
139
+ size_t frame_cost;
140
+ bool syntax_error;
141
+ const char *message;
142
+ } OseoHostScript;
143
+
144
+ /*
145
+ * Enters one generator body at its saved resume point. The runtime
146
+ * never resumes a generator without this dispatcher, which generated
147
+ * code installs alongside the function dispatcher.
148
+ */
149
+ typedef OseoResult (*OseoGeneratorDispatcher)(
150
+ OseoContext *context,
151
+ OseoValue generator
152
+ );
153
+
154
+ typedef enum {
155
+ OSEO_PROMISE_PENDING = 0,
156
+ OSEO_PROMISE_FULFILLED = 1,
157
+ OSEO_PROMISE_REJECTED = 2,
158
+ OSEO_PROMISE_INVALID = 3,
159
+ } OseoPromiseState;
160
+
161
+ /*
162
+ * The host's decision at a rejection checkpoint that finds an unhandled
163
+ * rejection (ADR 0030). Both policies mark the promise reported and count
164
+ * it. Fatal, the zero value every context starts with, then returns the
165
+ * first reason as a throw so the program fails. Observe continues. Only
166
+ * generated setup for a test262 harness run selects it, through an
167
+ * explicit compiler option that ordinary executables never set.
168
+ */
169
+ typedef enum {
170
+ OSEO_UNHANDLED_REJECTION_FATAL = 0,
171
+ OSEO_UNHANDLED_REJECTION_OBSERVE = 1,
172
+ } OseoUnhandledRejectionPolicy;
173
+
174
+ /*
175
+ * The named error intrinsics owned by the runtime. The enumerators
176
+ * index the per-context constructor and prototype tables, so they
177
+ * must stay contiguous from zero.
178
+ */
179
+ typedef enum {
180
+ OSEO_ERROR_ERROR = 0,
181
+ OSEO_ERROR_EVAL = 1,
182
+ OSEO_ERROR_RANGE = 2,
183
+ OSEO_ERROR_REFERENCE = 3,
184
+ OSEO_ERROR_SYNTAX = 4,
185
+ OSEO_ERROR_TYPE = 5,
186
+ OSEO_ERROR_URI = 6,
187
+ OSEO_ERROR_AGGREGATE = 7,
188
+ OSEO_ERROR_SUPPRESSED = 8,
189
+ } OseoErrorKind;
190
+
191
+ /*
192
+ * Realm-owned intrinsic identities. The table is the single permanent
193
+ * collector root for intrinsic objects and functions; component-specific
194
+ * builders fill their assigned slots without creating parallel caches.
195
+ */
196
+ typedef enum {
197
+ OSEO_INTRINSIC_OBJECT_PROTOTYPE = 0,
198
+ OSEO_INTRINSIC_FUNCTION_PROTOTYPE = 1,
199
+ OSEO_INTRINSIC_ARRAY_PROTOTYPE = 2,
200
+ OSEO_INTRINSIC_PROMISE_PROTOTYPE = 3,
201
+ OSEO_INTRINSIC_ITERATOR_PROTOTYPE = 4,
202
+ OSEO_INTRINSIC_ARRAY_ITERATOR_PROTOTYPE = 5,
203
+ OSEO_INTRINSIC_GENERATOR_PROTOTYPE = 6,
204
+ OSEO_INTRINSIC_ASYNC_ITERATOR_PROTOTYPE = 7,
205
+ OSEO_INTRINSIC_ASYNC_GENERATOR_PROTOTYPE = 8,
206
+ OSEO_INTRINSIC_ASYNC_GENERATOR_FUNCTION_PROTOTYPE = 9,
207
+ OSEO_INTRINSIC_ASYNC_GENERATOR_FUNCTION = 10,
208
+ OSEO_INTRINSIC_SYMBOL_PROTOTYPE = 11,
209
+ OSEO_INTRINSIC_SYMBOL = 12,
210
+ OSEO_INTRINSIC_ERROR_PROTOTYPE = 13,
211
+ OSEO_INTRINSIC_EVAL_ERROR_PROTOTYPE = 14,
212
+ OSEO_INTRINSIC_RANGE_ERROR_PROTOTYPE = 15,
213
+ OSEO_INTRINSIC_REFERENCE_ERROR_PROTOTYPE = 16,
214
+ OSEO_INTRINSIC_SYNTAX_ERROR_PROTOTYPE = 17,
215
+ OSEO_INTRINSIC_TYPE_ERROR_PROTOTYPE = 18,
216
+ OSEO_INTRINSIC_URI_ERROR_PROTOTYPE = 19,
217
+ OSEO_INTRINSIC_AGGREGATE_ERROR_PROTOTYPE = 20,
218
+ OSEO_INTRINSIC_ERROR = 21,
219
+ OSEO_INTRINSIC_EVAL_ERROR = 22,
220
+ OSEO_INTRINSIC_RANGE_ERROR = 23,
221
+ OSEO_INTRINSIC_REFERENCE_ERROR = 24,
222
+ OSEO_INTRINSIC_SYNTAX_ERROR = 25,
223
+ OSEO_INTRINSIC_TYPE_ERROR = 26,
224
+ OSEO_INTRINSIC_URI_ERROR = 27,
225
+ OSEO_INTRINSIC_AGGREGATE_ERROR = 28,
226
+ OSEO_INTRINSIC_THROW_TYPE_ERROR = 29,
227
+ OSEO_INTRINSIC_ARRAY_PUSH = 30,
228
+ OSEO_INTRINSIC_ARRAY_VALUES = 31,
229
+ OSEO_INTRINSIC_ARRAY_ITERATOR_NEXT = 32,
230
+ OSEO_INTRINSIC_ITERATOR_SELF = 33,
231
+ OSEO_INTRINSIC_GENERATOR_NEXT = 34,
232
+ OSEO_INTRINSIC_GENERATOR_RETURN = 35,
233
+ OSEO_INTRINSIC_GENERATOR_THROW = 36,
234
+ OSEO_INTRINSIC_PROMISE_THEN = 37,
235
+ OSEO_INTRINSIC_PROMISE_CATCH = 38,
236
+ OSEO_INTRINSIC_PROMISE_FINALLY = 39,
237
+ OSEO_INTRINSIC_ASYNC_GENERATOR_NEXT = 40,
238
+ OSEO_INTRINSIC_ASYNC_GENERATOR_RETURN = 41,
239
+ OSEO_INTRINSIC_ASYNC_GENERATOR_THROW = 42,
240
+ OSEO_INTRINSIC_ASYNC_ITERATOR_SELF = 43,
241
+ OSEO_INTRINSIC_OBJECT = 44,
242
+ OSEO_INTRINSIC_OBJECT_HAS_OWN_PROPERTY = 45,
243
+ OSEO_INTRINSIC_OBJECT_IS_PROTOTYPE_OF = 46,
244
+ OSEO_INTRINSIC_OBJECT_PROPERTY_IS_ENUMERABLE = 47,
245
+ OSEO_INTRINSIC_OBJECT_TO_STRING = 48,
246
+ OSEO_INTRINSIC_OBJECT_TO_LOCALE_STRING = 49,
247
+ OSEO_INTRINSIC_OBJECT_VALUE_OF = 50,
248
+ OSEO_INTRINSIC_OBJECT_GET_PROTOTYPE_OF = 51,
249
+ OSEO_INTRINSIC_OBJECT_IS = 52,
250
+ OSEO_INTRINSIC_OBJECT_SET_PROTOTYPE_OF = 53,
251
+ OSEO_INTRINSIC_BOOLEAN_PROTOTYPE = 54,
252
+ OSEO_INTRINSIC_STRING_PROTOTYPE = 55,
253
+ OSEO_INTRINSIC_BIGINT_PROTOTYPE = 56,
254
+ OSEO_INTRINSIC_FUNCTION = 57,
255
+ OSEO_INTRINSIC_FUNCTION_APPLY = 58,
256
+ OSEO_INTRINSIC_FUNCTION_BIND = 59,
257
+ OSEO_INTRINSIC_FUNCTION_CALL = 60,
258
+ OSEO_INTRINSIC_FUNCTION_TO_STRING = 61,
259
+ OSEO_INTRINSIC_FUNCTION_HAS_INSTANCE = 62,
260
+ OSEO_INTRINSIC_ITERATOR = 63,
261
+ OSEO_INTRINSIC_ITERATOR_FROM = 64,
262
+ OSEO_INTRINSIC_WRAP_FOR_VALID_ITERATOR_PROTOTYPE = 65,
263
+ OSEO_INTRINSIC_WRAP_FOR_VALID_ITERATOR_NEXT = 66,
264
+ OSEO_INTRINSIC_WRAP_FOR_VALID_ITERATOR_RETURN = 67,
265
+ OSEO_INTRINSIC_ITERATOR_CONSTRUCTOR_GETTER = 68,
266
+ OSEO_INTRINSIC_ITERATOR_CONSTRUCTOR_SETTER = 69,
267
+ OSEO_INTRINSIC_ITERATOR_TAG_GETTER = 70,
268
+ OSEO_INTRINSIC_ITERATOR_TAG_SETTER = 71,
269
+ OSEO_INTRINSIC_NUMBER_PROTOTYPE = 72,
270
+ OSEO_INTRINSIC_NUMBER = 73,
271
+ OSEO_INTRINSIC_NUMBER_IS_FINITE = 74,
272
+ OSEO_INTRINSIC_NUMBER_IS_INTEGER = 75,
273
+ OSEO_INTRINSIC_NUMBER_IS_NAN = 76,
274
+ OSEO_INTRINSIC_NUMBER_IS_SAFE_INTEGER = 77,
275
+ OSEO_INTRINSIC_NUMBER_PARSE_FLOAT = 78,
276
+ OSEO_INTRINSIC_NUMBER_PARSE_INT = 79,
277
+ OSEO_INTRINSIC_PROMISE = 80,
278
+ OSEO_INTRINSIC_PROMISE_ALL = 81,
279
+ OSEO_INTRINSIC_PROMISE_ALL_SETTLED = 82,
280
+ OSEO_INTRINSIC_PROMISE_ANY = 83,
281
+ OSEO_INTRINSIC_PROMISE_RACE = 84,
282
+ OSEO_INTRINSIC_PROMISE_REJECT = 85,
283
+ OSEO_INTRINSIC_PROMISE_RESOLVE = 86,
284
+ OSEO_INTRINSIC_PROMISE_TRY = 87,
285
+ OSEO_INTRINSIC_PROMISE_WITH_RESOLVERS = 88,
286
+ OSEO_INTRINSIC_PROMISE_SPECIES = 89,
287
+ OSEO_INTRINSIC_ARRAY_BUFFER_PROTOTYPE = 90,
288
+ OSEO_INTRINSIC_ARRAY_BUFFER = 91,
289
+ OSEO_INTRINSIC_ARRAY_BUFFER_IS_VIEW = 92,
290
+ OSEO_INTRINSIC_ARRAY_BUFFER_BYTE_LENGTH = 93,
291
+ OSEO_INTRINSIC_ARRAY_BUFFER_DETACHED = 94,
292
+ OSEO_INTRINSIC_ARRAY_BUFFER_MAX_BYTE_LENGTH = 95,
293
+ OSEO_INTRINSIC_ARRAY_BUFFER_RESIZABLE = 96,
294
+ OSEO_INTRINSIC_ARRAY_BUFFER_RESIZE = 97,
295
+ OSEO_INTRINSIC_ARRAY_BUFFER_SLICE = 98,
296
+ OSEO_INTRINSIC_ARRAY_BUFFER_TRANSFER = 99,
297
+ OSEO_INTRINSIC_ARRAY_BUFFER_TRANSFER_TO_FIXED_LENGTH = 100,
298
+ OSEO_INTRINSIC_ARRAY_BUFFER_SPECIES = 101,
299
+ OSEO_INTRINSIC_ARRAY = 102,
300
+ OSEO_INTRINSIC_ARRAY_FROM = 103,
301
+ OSEO_INTRINSIC_ARRAY_IS_ARRAY = 104,
302
+ OSEO_INTRINSIC_ARRAY_OF = 105,
303
+ OSEO_INTRINSIC_ARRAY_SPECIES_GETTER = 106,
304
+ OSEO_INTRINSIC_STRING = 107,
305
+ OSEO_INTRINSIC_STRING_FROM_CHAR_CODE = 108,
306
+ OSEO_INTRINSIC_STRING_FROM_CODE_POINT = 109,
307
+ OSEO_INTRINSIC_STRING_RAW = 110,
308
+ OSEO_INTRINSIC_REGEXP_STRING_ITERATOR_PROTOTYPE = 111,
309
+ OSEO_INTRINSIC_REGEXP_STRING_ITERATOR_NEXT = 112,
310
+ OSEO_INTRINSIC_MAP_ITERATOR_PROTOTYPE = 113,
311
+ OSEO_INTRINSIC_MAP_ITERATOR_NEXT = 114,
312
+ OSEO_INTRINSIC_MAP_PROTOTYPE = 115,
313
+ OSEO_INTRINSIC_MAP_GET = 116,
314
+ OSEO_INTRINSIC_MAP_SET = 117,
315
+ OSEO_INTRINSIC_MAP_HAS = 118,
316
+ OSEO_INTRINSIC_MAP_DELETE = 119,
317
+ OSEO_INTRINSIC_MAP_CLEAR = 120,
318
+ OSEO_INTRINSIC_MAP_FOR_EACH = 121,
319
+ OSEO_INTRINSIC_MAP_ENTRIES = 122,
320
+ OSEO_INTRINSIC_MAP_KEYS = 123,
321
+ OSEO_INTRINSIC_MAP_VALUES = 124,
322
+ OSEO_INTRINSIC_MAP_SIZE_GETTER = 125,
323
+ OSEO_INTRINSIC_MAP = 126,
324
+ OSEO_INTRINSIC_MAP_GROUP_BY = 127,
325
+ OSEO_INTRINSIC_MAP_SPECIES = 128,
326
+ OSEO_INTRINSIC_BIGINT = 129,
327
+ OSEO_INTRINSIC_BIGINT_AS_INT_N = 130,
328
+ OSEO_INTRINSIC_BIGINT_AS_UINT_N = 131,
329
+ OSEO_INTRINSIC_BIGINT_TO_STRING = 132,
330
+ OSEO_INTRINSIC_BIGINT_TO_LOCALE_STRING = 133,
331
+ OSEO_INTRINSIC_BIGINT_VALUE_OF = 134,
332
+ OSEO_INTRINSIC_DATA_VIEW_PROTOTYPE = 135,
333
+ OSEO_INTRINSIC_DATA_VIEW = 136,
334
+ OSEO_INTRINSIC_DATA_VIEW_BUFFER = 137,
335
+ OSEO_INTRINSIC_DATA_VIEW_BYTE_LENGTH = 138,
336
+ OSEO_INTRINSIC_DATA_VIEW_BYTE_OFFSET = 139,
337
+ OSEO_INTRINSIC_DATA_VIEW_GET_INT8 = 140,
338
+ OSEO_INTRINSIC_DATA_VIEW_GET_UINT8 = 141,
339
+ OSEO_INTRINSIC_DATA_VIEW_GET_INT16 = 142,
340
+ OSEO_INTRINSIC_DATA_VIEW_GET_UINT16 = 143,
341
+ OSEO_INTRINSIC_DATA_VIEW_GET_INT32 = 144,
342
+ OSEO_INTRINSIC_DATA_VIEW_GET_UINT32 = 145,
343
+ OSEO_INTRINSIC_DATA_VIEW_GET_FLOAT16 = 146,
344
+ OSEO_INTRINSIC_DATA_VIEW_GET_FLOAT32 = 147,
345
+ OSEO_INTRINSIC_DATA_VIEW_GET_FLOAT64 = 148,
346
+ OSEO_INTRINSIC_DATA_VIEW_GET_BIG_INT64 = 149,
347
+ OSEO_INTRINSIC_DATA_VIEW_GET_BIG_UINT64 = 150,
348
+ OSEO_INTRINSIC_DATA_VIEW_SET_INT8 = 151,
349
+ OSEO_INTRINSIC_DATA_VIEW_SET_UINT8 = 152,
350
+ OSEO_INTRINSIC_DATA_VIEW_SET_INT16 = 153,
351
+ OSEO_INTRINSIC_DATA_VIEW_SET_UINT16 = 154,
352
+ OSEO_INTRINSIC_DATA_VIEW_SET_INT32 = 155,
353
+ OSEO_INTRINSIC_DATA_VIEW_SET_UINT32 = 156,
354
+ OSEO_INTRINSIC_DATA_VIEW_SET_FLOAT16 = 157,
355
+ OSEO_INTRINSIC_DATA_VIEW_SET_FLOAT32 = 158,
356
+ OSEO_INTRINSIC_DATA_VIEW_SET_FLOAT64 = 159,
357
+ OSEO_INTRINSIC_DATA_VIEW_SET_BIG_INT64 = 160,
358
+ OSEO_INTRINSIC_DATA_VIEW_SET_BIG_UINT64 = 161,
359
+ OSEO_INTRINSIC_REGEXP_PROTOTYPE = 162,
360
+ OSEO_INTRINSIC_REGEXP = 163,
361
+ OSEO_INTRINSIC_REGEXP_SPECIES = 164,
362
+ OSEO_INTRINSIC_MATH = 165,
363
+ OSEO_INTRINSIC_GENERATOR_FUNCTION_PROTOTYPE = 166,
364
+ OSEO_INTRINSIC_GENERATOR_FUNCTION = 167,
365
+ OSEO_INTRINSIC_ASYNC_FUNCTION_PROTOTYPE = 168,
366
+ OSEO_INTRINSIC_ASYNC_FUNCTION = 169,
367
+ OSEO_INTRINSIC_ITERATOR_MAP = 170,
368
+ OSEO_INTRINSIC_ITERATOR_FILTER = 171,
369
+ OSEO_INTRINSIC_ITERATOR_TAKE = 172,
370
+ OSEO_INTRINSIC_ITERATOR_DROP = 173,
371
+ OSEO_INTRINSIC_ITERATOR_FLAT_MAP = 174,
372
+ OSEO_INTRINSIC_ITERATOR_HELPER_PROTOTYPE = 175,
373
+ OSEO_INTRINSIC_ITERATOR_HELPER_NEXT = 176,
374
+ OSEO_INTRINSIC_ITERATOR_HELPER_RETURN = 177,
375
+ OSEO_INTRINSIC_DECODE_URI = 178,
376
+ OSEO_INTRINSIC_DECODE_URI_COMPONENT = 179,
377
+ OSEO_INTRINSIC_ENCODE_URI = 180,
378
+ OSEO_INTRINSIC_ENCODE_URI_COMPONENT = 181,
379
+ OSEO_INTRINSIC_IS_FINITE = 182,
380
+ OSEO_INTRINSIC_IS_NAN = 183,
381
+ OSEO_INTRINSIC_REFLECT = 184,
382
+ OSEO_INTRINSIC_ARRAY_KEYS = 185,
383
+ OSEO_INTRINSIC_ARRAY_ENTRIES = 186,
384
+ OSEO_INTRINSIC_PROXY = 187,
385
+ OSEO_INTRINSIC_ITERATOR_REDUCE = 188,
386
+ OSEO_INTRINSIC_ITERATOR_TO_ARRAY = 189,
387
+ OSEO_INTRINSIC_ITERATOR_FOR_EACH = 190,
388
+ OSEO_INTRINSIC_ITERATOR_SOME = 191,
389
+ OSEO_INTRINSIC_ITERATOR_EVERY = 192,
390
+ OSEO_INTRINSIC_ITERATOR_FIND = 193,
391
+ OSEO_INTRINSIC_DATE_PROTOTYPE = 194,
392
+ OSEO_INTRINSIC_DATE = 195,
393
+ OSEO_INTRINSIC_STRING_ITERATOR_PROTOTYPE = 196,
394
+ OSEO_INTRINSIC_STRING_ITERATOR_NEXT = 197,
395
+ OSEO_INTRINSIC_STRING_PROTOTYPE_ITERATOR = 198,
396
+ OSEO_INTRINSIC_JSON = 199,
397
+ OSEO_INTRINSIC_JSON_PARSE = 200,
398
+ OSEO_INTRINSIC_SET_PROTOTYPE = 201,
399
+ OSEO_INTRINSIC_SET = 202,
400
+ OSEO_INTRINSIC_SET_ADD = 203,
401
+ OSEO_INTRINSIC_SET_CLEAR = 204,
402
+ OSEO_INTRINSIC_SET_DELETE = 205,
403
+ OSEO_INTRINSIC_SET_ENTRIES = 206,
404
+ OSEO_INTRINSIC_SET_FOR_EACH = 207,
405
+ OSEO_INTRINSIC_SET_HAS = 208,
406
+ OSEO_INTRINSIC_SET_SIZE = 209,
407
+ OSEO_INTRINSIC_SET_VALUES = 210,
408
+ OSEO_INTRINSIC_SET_ITERATOR_PROTOTYPE = 211,
409
+ OSEO_INTRINSIC_SET_ITERATOR_NEXT = 212,
410
+ OSEO_INTRINSIC_SET_SPECIES = 213,
411
+ OSEO_INTRINSIC_TYPED_ARRAY_PROTOTYPE = 214,
412
+ OSEO_INTRINSIC_TYPED_ARRAY = 215,
413
+ OSEO_INTRINSIC_INT8_ARRAY_PROTOTYPE = 216,
414
+ OSEO_INTRINSIC_INT8_ARRAY = 217,
415
+ OSEO_INTRINSIC_UINT8_ARRAY_PROTOTYPE = 218,
416
+ OSEO_INTRINSIC_UINT8_ARRAY = 219,
417
+ OSEO_INTRINSIC_UINT8_CLAMPED_ARRAY_PROTOTYPE = 220,
418
+ OSEO_INTRINSIC_UINT8_CLAMPED_ARRAY = 221,
419
+ OSEO_INTRINSIC_INT16_ARRAY_PROTOTYPE = 222,
420
+ OSEO_INTRINSIC_INT16_ARRAY = 223,
421
+ OSEO_INTRINSIC_UINT16_ARRAY_PROTOTYPE = 224,
422
+ OSEO_INTRINSIC_UINT16_ARRAY = 225,
423
+ OSEO_INTRINSIC_INT32_ARRAY_PROTOTYPE = 226,
424
+ OSEO_INTRINSIC_INT32_ARRAY = 227,
425
+ OSEO_INTRINSIC_UINT32_ARRAY_PROTOTYPE = 228,
426
+ OSEO_INTRINSIC_UINT32_ARRAY = 229,
427
+ OSEO_INTRINSIC_FLOAT32_ARRAY_PROTOTYPE = 230,
428
+ OSEO_INTRINSIC_FLOAT32_ARRAY = 231,
429
+ OSEO_INTRINSIC_FLOAT64_ARRAY_PROTOTYPE = 232,
430
+ OSEO_INTRINSIC_FLOAT64_ARRAY = 233,
431
+ OSEO_INTRINSIC_BIGINT64_ARRAY_PROTOTYPE = 234,
432
+ OSEO_INTRINSIC_BIGINT64_ARRAY = 235,
433
+ OSEO_INTRINSIC_BIGUINT64_ARRAY_PROTOTYPE = 236,
434
+ OSEO_INTRINSIC_BIGUINT64_ARRAY = 237,
435
+ OSEO_INTRINSIC_ARRAY_TO_STRING = 238,
436
+ OSEO_INTRINSIC_SHARED_ARRAY_BUFFER_PROTOTYPE = 239,
437
+ OSEO_INTRINSIC_SHARED_ARRAY_BUFFER = 240,
438
+ OSEO_INTRINSIC_SHARED_ARRAY_BUFFER_SPECIES = 241,
439
+ OSEO_INTRINSIC_ATOMICS = 242,
440
+ OSEO_INTRINSIC_WEAK_MAP_PROTOTYPE = 243,
441
+ OSEO_INTRINSIC_WEAK_MAP = 244,
442
+ OSEO_INTRINSIC_WEAK_MAP_DELETE = 245,
443
+ OSEO_INTRINSIC_WEAK_MAP_GET = 246,
444
+ OSEO_INTRINSIC_WEAK_MAP_HAS = 247,
445
+ OSEO_INTRINSIC_WEAK_MAP_SET = 248,
446
+ OSEO_INTRINSIC_WEAK_SET_PROTOTYPE = 249,
447
+ OSEO_INTRINSIC_WEAK_SET = 250,
448
+ OSEO_INTRINSIC_WEAK_SET_ADD = 251,
449
+ OSEO_INTRINSIC_WEAK_SET_DELETE = 252,
450
+ OSEO_INTRINSIC_WEAK_SET_HAS = 253,
451
+ OSEO_INTRINSIC_WEAK_REF_PROTOTYPE = 254,
452
+ OSEO_INTRINSIC_WEAK_REF = 255,
453
+ OSEO_INTRINSIC_WEAK_REF_DEREF = 256,
454
+ OSEO_INTRINSIC_FINALIZATION_REGISTRY_PROTOTYPE = 257,
455
+ OSEO_INTRINSIC_FINALIZATION_REGISTRY = 258,
456
+ OSEO_INTRINSIC_FINALIZATION_REGISTRY_REGISTER = 259,
457
+ OSEO_INTRINSIC_FINALIZATION_REGISTRY_UNREGISTER = 260,
458
+ OSEO_INTRINSIC_SYMBOL_FOR = 261,
459
+ OSEO_INTRINSIC_SYMBOL_KEY_FOR = 262,
460
+ OSEO_INTRINSIC_SYMBOL_TO_STRING = 263,
461
+ OSEO_INTRINSIC_SYMBOL_VALUE_OF = 264,
462
+ OSEO_INTRINSIC_SYMBOL_TO_PRIMITIVE = 265,
463
+ OSEO_INTRINSIC_SYMBOL_DESCRIPTION_GETTER = 266,
464
+ OSEO_INTRINSIC_BOOLEAN = 267,
465
+ OSEO_INTRINSIC_BOOLEAN_TO_STRING = 268,
466
+ OSEO_INTRINSIC_BOOLEAN_VALUE_OF = 269,
467
+ OSEO_INTRINSIC_EVAL = 270,
468
+ OSEO_INTRINSIC_FLOAT16_ARRAY_PROTOTYPE = 271,
469
+ OSEO_INTRINSIC_FLOAT16_ARRAY = 272,
470
+ OSEO_INTRINSIC_ESCAPE = 273,
471
+ OSEO_INTRINSIC_UNESCAPE = 274,
472
+ OSEO_INTRINSIC_SUPPRESSED_ERROR_PROTOTYPE = 275,
473
+ OSEO_INTRINSIC_SUPPRESSED_ERROR = 276,
474
+ OSEO_INTRINSIC_DISPOSABLE_STACK_PROTOTYPE = 277,
475
+ OSEO_INTRINSIC_DISPOSABLE_STACK = 278,
476
+ OSEO_INTRINSIC_ASYNC_DISPOSABLE_STACK_PROTOTYPE = 279,
477
+ OSEO_INTRINSIC_ASYNC_DISPOSABLE_STACK = 280,
478
+ OSEO_INTRINSIC_PROCESS = 281,
479
+ OSEO_INTRINSIC_PROCESS_ARGV = 282,
480
+ OSEO_INTRINSIC_PROCESS_ENV = 283,
481
+ OSEO_INTRINSIC_PROCESS_STDOUT = 284,
482
+ OSEO_INTRINSIC_PROCESS_STDERR = 285,
483
+ OSEO_INTRINSIC_PROCESS_FS = 286,
484
+ OSEO_INTRINSIC_PROCESS_EXIT = 287,
485
+ OSEO_INTRINSIC_PROCESS_STDOUT_WRITE = 288,
486
+ OSEO_INTRINSIC_PROCESS_STDERR_WRITE = 289,
487
+ OSEO_INTRINSIC_PROCESS_READ_FILE_SYNC = 290,
488
+ OSEO_INTRINSIC_PROCESS_EXIT_CODE_GET = 291,
489
+ OSEO_INTRINSIC_PROCESS_EXIT_CODE_SET = 292,
490
+ OSEO_INTRINSIC_COUNT = 293,
491
+ } OseoIntrinsic;
492
+
493
+ typedef struct {
494
+ bool configurable;
495
+ bool enumerable;
496
+ /* Meaningless when accessor is true; an accessor descriptor has
497
+ * [[Get]]/[[Set]] instead of [[Writable]]. */
498
+ bool writable;
499
+ bool accessor;
500
+ } OseoPropertyAttributes;
501
+
502
+ typedef struct {
503
+ size_t shape_id;
504
+ size_t slot;
505
+ } OseoPropertyCache;
506
+
507
+ /*
508
+ * One saved abrupt completion of generated code. `kind` is 0 normal,
509
+ * 1 return, 2 throw, and 3 jump; `target` and `depth` name the block
510
+ * and cleanup nesting a jump resumes at, and the remaining fields
511
+ * restore the diagnostic location of a saved throw. The completion's
512
+ * value lives in the owning frame's root slots so the collector traces
513
+ * it. A generator body's records belong to its generator record, so
514
+ * they survive suspension along with the roots they describe.
515
+ */
516
+ typedef struct {
517
+ int kind;
518
+ size_t target;
519
+ size_t depth;
520
+ size_t line;
521
+ size_t column;
522
+ const char *source_id;
523
+ size_t source_id_length;
524
+ const char *error_code;
525
+ const char *error_message;
526
+ } OseoCompletionRecord;
527
+
528
+ struct OseoRootFrame {
529
+ OseoRootFrame *previous;
530
+ OseoValue *slots;
531
+ size_t slot_count;
532
+ };
533
+
534
+ /*
535
+ * The clock and wakeup adapter boundary that ADR 0025 accepts from
536
+ * PLAN-NIO.md.
537
+ *
538
+ * The scheduler reads two independent clock domains through this table
539
+ * and waits through it. `monotonic` reports nanoseconds from an
540
+ * adapter-chosen origin that never decrease, and only that domain drives
541
+ * timer deadlines. `real_time` reports milliseconds from the Unix epoch,
542
+ * which may move in either direction and never drives a deadline.
543
+ * `wait` blocks until the monotonic `deadline` passes, or indefinitely
544
+ * when `has_deadline` is false, unless a wakeup arrives first; it may
545
+ * also return early, so a caller rereads the monotonic clock instead of
546
+ * trusting the reason. `wake` is the one operation another thread may
547
+ * call, and wakeups that arrive while nobody waits coalesce into one
548
+ * early return. `describe` names the selected facilities, with NULL for
549
+ * an absent capability, and `close` releases the adapter state once the
550
+ * last waker has stopped.
551
+ *
552
+ * The table carries behavior only. No operation runs JavaScript, owns a
553
+ * job queue, or keeps an executable alive: liveness stays a scheduler
554
+ * query over its own referenced work, and no platform handle crosses
555
+ * this boundary. Synthetic clock and completion commands belong to a
556
+ * deterministic test adapter's own interface, never to this table.
557
+ */
558
+ typedef enum {
559
+ OSEO_CLOCK_WAIT_DEADLINE = 0,
560
+ OSEO_CLOCK_WAIT_WAKEUP = 1,
561
+ OSEO_CLOCK_WAIT_FAILED = 2,
562
+ } OseoClockWaitResult;
563
+
564
+ /*
565
+ * The capability record of one clock adapter. `fallback` is true when
566
+ * the adapter selected a recorded fallback for waiting or real time
567
+ * instead of the target's primary facility.
568
+ */
569
+ typedef struct {
570
+ const char *backend;
571
+ const char *monotonic;
572
+ const char *real_time;
573
+ const char *wait;
574
+ const char *wakeup;
575
+ bool fallback;
576
+ } OseoClockCapabilities;
577
+
578
+ typedef struct {
579
+ bool (*monotonic)(void *state, uint64_t *nanoseconds);
580
+ bool (*real_time)(void *state, double *milliseconds);
581
+ OseoClockWaitResult (*wait)(
582
+ void *state,
583
+ bool has_deadline,
584
+ uint64_t deadline
585
+ );
586
+ bool (*wake)(void *state);
587
+ void (*describe)(void *state, OseoClockCapabilities *capabilities);
588
+ void (*close)(void *state);
589
+ } OseoClockAdapter;
590
+
591
+ /*
592
+ * Facilities the platform clock adapter treats as unavailable when it
593
+ * opens, as a restricted sandbox or an older kernel would. They exercise
594
+ * the recorded fallback and owned-failure paths at the same selection
595
+ * point a real setup failure reaches; they are not adapter operations.
596
+ */
597
+ #define OSEO_CLOCK_RESTRICT_MONOTONIC ((unsigned)1u << 0u)
598
+ #define OSEO_CLOCK_RESTRICT_REAL_TIME ((unsigned)1u << 1u)
599
+ #define OSEO_CLOCK_RESTRICT_PRIMARY_WAKEUP ((unsigned)1u << 2u)
600
+ #define OSEO_CLOCK_RESTRICT_PIPE_WAKEUP ((unsigned)1u << 3u)
601
+
602
+ /*
603
+ * The realm-owned state of one Realm Record (ADR 0027). A context starts
604
+ * with its initial realm and may create more; each realm has its own
605
+ * intrinsic graph, global object, literal caches, and Math.random state,
606
+ * while the context it belongs to keeps the agent's heap and queues.
607
+ * Generated code never reads these fields: it reaches them through the
608
+ * runtime entry points, which consult the running realm.
609
+ */
610
+ typedef struct {
611
+ /* The realm's single intrinsic graph, indexed by OseoIntrinsic. */
612
+ OseoValue intrinsics[OSEO_INTRINSIC_COUNT];
613
+ /*
614
+ * The realm's global this value, which is the [[GlobalThisValue]] a
615
+ * Global Environment Record binds. It is created on first use and
616
+ * permanently rooted afterwards so every Script top-level `this` and
617
+ * every non-strict nullish receiver observe one identity.
618
+ */
619
+ OseoValue global_this;
620
+ /* Private declarative storage, never exposed as global properties. */
621
+ OseoValue global_lexicals;
622
+ /*
623
+ * Realm-local GetTemplateObject cache, which is the realm's
624
+ * [[TemplateMap]]. The private entry layout stays behind this public
625
+ * generated-code boundary.
626
+ */
627
+ void *template_cache;
628
+ size_t template_cache_count;
629
+ size_t template_cache_capacity;
630
+ /*
631
+ * Realm-local ahead-of-time regular expression literal cache. The
632
+ * private entry layout and its addressing stay behind this public
633
+ * generated-code boundary; `capacity` is the table size and `count`
634
+ * is how many of its slots are occupied.
635
+ */
636
+ void *regexp_literal_cache;
637
+ size_t regexp_literal_cache_count;
638
+ size_t regexp_literal_cache_capacity;
639
+ /*
640
+ * The realm's Math.random source. ECMA-262 leaves the strategy to
641
+ * the implementation but requires distinct realms to draw distinct
642
+ * sequences, and this runtime keeps every observable schedule
643
+ * reproducible, so the generator is a xorshift128+ state seeded from
644
+ * the realm's own initialization ordinal rather than host entropy.
645
+ */
646
+ uint64_t random_state[2];
647
+ } OseoRealm;
648
+
649
+ struct OseoContext {
650
+ const OseoHostScript *host_scripts;
651
+ size_t host_script_count;
652
+ OseoRootFrame *roots;
653
+ OseoHeapObject *objects;
654
+ OseoFunctionDispatcher function_dispatcher;
655
+ OseoGeneratorDispatcher generator_dispatcher;
656
+ OseoValue async_call_capability;
657
+ OseoValue microtask_head;
658
+ OseoValue microtask_tail;
659
+ OseoValue pending_rejections;
660
+ OseoValue pending_rejection_tail;
661
+ /*
662
+ * The initial realm, created with the context, and the running
663
+ * execution context's realm. `realm` points at `initial_realm` or at
664
+ * the record inside the realm heap object `realm_record` names;
665
+ * `realm_record` is undefined exactly while the initial realm runs.
666
+ * Every realm of one context shares its heap, collector, job queues,
667
+ * well-known symbols, and symbol registry (ADR 0027).
668
+ */
669
+ /* Startup strings outlive the context; snapshots are traced intrinsics. */
670
+ int process_argc;
671
+ char **process_argv;
672
+ bool process_has_exit_code;
673
+ int32_t process_exit_code;
674
+ bool process_stdout_closed;
675
+ bool process_stderr_closed;
676
+ OseoRealm initial_realm;
677
+ OseoRealm *realm;
678
+ OseoValue realm_record;
679
+ /* Saved caller realm for result checks; the call scope owns its life. */
680
+ OseoConstructorScope *constructor_scope;
681
+ /*
682
+ * The most recent function activation that is still running, or NULL
683
+ * at top level and in job dispatch. Each record lives in the frame of
684
+ * the call that started it, and the legacy `caller` and `arguments`
685
+ * properties of non-strict functions read the chain (ADR 0034).
686
+ */
687
+ OseoActivation *activation;
688
+ /*
689
+ * The `arguments` and `caller` key strings, created on the first own-key
690
+ * listing of a function that has them and rooted for the context's
691
+ * lifetime, so a listing never allocates them in its copying pass.
692
+ */
693
+ OseoValue legacy_function_keys[2];
694
+ /*
695
+ * The agent's well-known symbols are a separate edition-fixed table
696
+ * that every realm of the context shares.
697
+ */
698
+ OseoValue well_known_symbols[15];
699
+ /*
700
+ * The agent's representatives of GlobalSymbolRegistry entries. The
701
+ * registry itself is process-wide; this open-addressed table, whose
702
+ * empty slots hold undefined, gives each entry one collector-rooted
703
+ * Symbol per context, so `Symbol.for` returns the same heap value on
704
+ * every call in every realm of the context. Identity is the entry, so
705
+ * two contexts' representatives of one entry compare equal wherever a
706
+ * symbol identity rule applies. Registered symbols cannot be
707
+ * collected, which matches their unbounded observable lifetime.
708
+ */
709
+ OseoValue *registered_symbols;
710
+ size_t registered_symbol_count;
711
+ size_t registered_symbol_capacity;
712
+ /* Private stack of active array stringification receivers. */
713
+ void *array_string_stack;
714
+ OseoValue timer_head;
715
+ /*
716
+ * The realm's WaiterList store: every pending `Atomics.waitAsync`
717
+ * waiter in the FIFO order its call added it. The private record
718
+ * layout stays behind this public generated-code boundary.
719
+ */
720
+ OseoValue atomics_waiter_head;
721
+ OseoValue atomics_waiter_tail;
722
+ /*
723
+ * This realm's agent record when `oseo_test262_host_install` or an
724
+ * agent start made it one agent of a multi-agent cluster, and NULL
725
+ * for the only agent of an ordinary program. The private layout stays
726
+ * behind this public generated-code boundary.
727
+ */
728
+ void *agent;
729
+ /* Agent [[CanBlock]], shared by its realms; child contexts start true. */
730
+ bool agent_can_block;
731
+ /* The callback `$262.agent.receiveBroadcast` registered, rooted. */
732
+ OseoValue agent_broadcast_callback;
733
+ /* Collector-owned FIFO of finalization cells ready for a later runtime
734
+ * checkpoint. Collection queues records but never invokes user code. */
735
+ OseoValue finalization_head;
736
+ OseoValue finalization_tail;
737
+ uint64_t next_finalization_order;
738
+ size_t finalization_pending_count;
739
+ /*
740
+ * Exact counts of published records on this context's object list,
741
+ * including unreachable and consumed records until its sweep removes
742
+ * them. Only empty owner-local weak/finalization scans may use these;
743
+ * strong and ephemeron tracing can also visit another context's heap.
744
+ */
745
+ size_t ephemeron_table_count;
746
+ size_t weak_reference_count;
747
+ size_t finalization_registry_count;
748
+ size_t finalization_cell_count;
749
+ /*
750
+ * The current job's KeptAlive set. The private open-addressed layout
751
+ * stays behind this public generated-code boundary; every occupied
752
+ * slot is a strong root until the event loop clears it.
753
+ */
754
+ void *kept_objects;
755
+ size_t kept_object_count;
756
+ size_t kept_object_capacity;
757
+ /*
758
+ * The pending tail call between the PrepareForTailCall site that
759
+ * recorded it and the trampoline that performs it, NULL until the
760
+ * first one. The private record layout stays behind this public
761
+ * generated-code boundary; the collector traces it while a call is
762
+ * pending.
763
+ */
764
+ void *tail_call;
765
+ /*
766
+ * Live short strings this context shares instead of allocating again,
767
+ * NULL until the first one. The private table layout stays behind
768
+ * this public generated-code boundary; its entries are weak, and each
769
+ * collection forgets the strings it frees.
770
+ */
771
+ void *string_table;
772
+ /*
773
+ * The module table a module graph's top-level script installs, NULL
774
+ * for a Script program. The private layout stays behind this public
775
+ * generated-code boundary; the collector traces every entry's values.
776
+ */
777
+ void *module_table;
778
+ const char *source_id;
779
+ size_t source_id_length;
780
+ const char *error_code;
781
+ const char *error_message;
782
+ bool has_diagnostic;
783
+ size_t active_frame_slots;
784
+ size_t call_depth;
785
+ size_t line;
786
+ size_t column;
787
+ size_t guard_hits;
788
+ size_t guard_misses;
789
+ size_t overflow_misses;
790
+ size_t generic_addition_calls;
791
+ size_t next_shape_id;
792
+ size_t allocations;
793
+ size_t allocation_attempts;
794
+ size_t collections;
795
+ size_t rejection_handled_count;
796
+ size_t unhandled_rejection_count;
797
+ /* Shared by this context's realms; child agents copy the main's. */
798
+ OseoUnhandledRejectionPolicy unhandled_rejection_policy;
799
+ /*
800
+ * The realm's clock adapter and its state, NULL until the first
801
+ * clock use opens the platform adapter or an embedder installs one.
802
+ * `clock_origin` is the monotonic reading at the first scheduler
803
+ * clock use, and `clock_milliseconds` is the scheduler time cached
804
+ * for the current task: whole milliseconds elapsed since that origin,
805
+ * read once when a timer turn starts so that every deadline one task
806
+ * computes shares one base.
807
+ */
808
+ const OseoClockAdapter *clock_adapter;
809
+ void *clock_state;
810
+ uint64_t clock_origin;
811
+ unsigned clock_restrictions;
812
+ bool clock_started;
813
+ uint64_t clock_milliseconds;
814
+ uint64_t next_timer_id;
815
+ uint64_t next_timer_order;
816
+ size_t fail_allocation_at;
817
+ bool observe_specialization;
818
+ bool collect_every_safepoint;
819
+ };
820
+
821
+ /* The normalized RegExp flag set, shared by the constructor, the
822
+ * prototype accessors, and the matcher. */
823
+ #define OSEO_REGEXP_FLAG_D ((uint16_t)1u << 0u)
824
+ #define OSEO_REGEXP_FLAG_G ((uint16_t)1u << 1u)
825
+ #define OSEO_REGEXP_FLAG_I ((uint16_t)1u << 2u)
826
+ #define OSEO_REGEXP_FLAG_M ((uint16_t)1u << 3u)
827
+ #define OSEO_REGEXP_FLAG_S ((uint16_t)1u << 4u)
828
+ #define OSEO_REGEXP_FLAG_U ((uint16_t)1u << 5u)
829
+ #define OSEO_REGEXP_FLAG_V ((uint16_t)1u << 6u)
830
+ #define OSEO_REGEXP_FLAG_Y ((uint16_t)1u << 7u)
831
+
832
+ /*
833
+ * One matcher instruction opcode.
834
+ *
835
+ * runtime_regexp_matcher.c executes the program these build into and
836
+ * is the runtime's semantic authority for choice order, captures,
837
+ * assertions, and Unicode traversal. The encoding is generated-code
838
+ * ABI because an ahead-of-time literal descriptor supplies a program
839
+ * the build already compiled.
840
+ */
841
+ typedef enum {
842
+ OSEO_REGEXP_OP_ACCEPT = 0,
843
+ OSEO_REGEXP_OP_FAIL = 1,
844
+ OSEO_REGEXP_OP_CONSUME = 2,
845
+ OSEO_REGEXP_OP_EDGE = 3,
846
+ OSEO_REGEXP_OP_BOUNDARY = 4,
847
+ OSEO_REGEXP_OP_SAVE = 5,
848
+ OSEO_REGEXP_OP_FORK = 6,
849
+ OSEO_REGEXP_OP_JUMP = 7,
850
+ OSEO_REGEXP_OP_REPEAT = 8,
851
+ OSEO_REGEXP_OP_REPEAT_INIT = 9,
852
+ OSEO_REGEXP_OP_REPEAT_ENTER = 10,
853
+ OSEO_REGEXP_OP_REPEAT_END = 11,
854
+ OSEO_REGEXP_OP_LOOK_START = 12,
855
+ OSEO_REGEXP_OP_LOOK_END = 13,
856
+ OSEO_REGEXP_OP_BACKREFERENCE = 14,
857
+ } OseoRegExpOpcode;
858
+
859
+ /* Per-instruction modifiers. `END_EDGE` distinguishes `$` from `^`. */
860
+ #define OSEO_REGEXP_INSTRUCTION_BACKWARD ((uint8_t)0x01u)
861
+ #define OSEO_REGEXP_INSTRUCTION_NEGATED ((uint8_t)0x02u)
862
+ #define OSEO_REGEXP_INSTRUCTION_GREEDY ((uint8_t)0x04u)
863
+ #define OSEO_REGEXP_INSTRUCTION_MULTILINE ((uint8_t)0x08u)
864
+ #define OSEO_REGEXP_INSTRUCTION_IGNORE_CASE ((uint8_t)0x10u)
865
+ #define OSEO_REGEXP_INSTRUCTION_END_EDGE ((uint8_t)0x20u)
866
+
867
+ /*
868
+ * One matcher instruction.
869
+ *
870
+ * The four operands are opcode-specific: a set index, a register slot, a
871
+ * program address, or a repetition-bound index. Keeping them uniform
872
+ * makes the program one flat array an ahead-of-time lowering emits
873
+ * without reshaping.
874
+ */
875
+ typedef struct {
876
+ uint8_t opcode;
877
+ uint8_t modifiers;
878
+ uint32_t operands[4];
879
+ } OseoRegExpInstruction;
880
+
881
+ /*
882
+ * One quantifier's repetition metadata, held out of line so an
883
+ * instruction stays four 32-bit operands wide. `clear_from` through
884
+ * `clear_to` is the capture register range each iteration resets, which
885
+ * is empty when the quantified atom encloses no capturing group.
886
+ */
887
+ typedef struct {
888
+ uint64_t minimum;
889
+ uint64_t maximum;
890
+ uint32_t clear_from;
891
+ uint32_t clear_to;
892
+ } OseoRegExpRepeat;
893
+
894
+ /* One capturing group's optional name, as a span of `name_units`. */
895
+ typedef struct {
896
+ uint32_t name_offset;
897
+ uint32_t name_length;
898
+ bool named;
899
+ } OseoRegExpCapture;
900
+
901
+ /*
902
+ * One immutable compiled matcher program.
903
+ *
904
+ * A program built from a dynamic pattern owns every array as a single
905
+ * allocation reachable only through the artifact that holds it, so
906
+ * publication transfers ownership and destruction releases it. A program
907
+ * an ahead-of-time literal descriptor supplies is static generated data
908
+ * the artifact only borrows. The program holds no managed value and no
909
+ * mutable field either way, so equal programs are shared while each
910
+ * evaluation still owns its object identity and `lastIndex`.
911
+ *
912
+ * Register 0 and 1 hold the whole match and registers `2 * index` and
913
+ * `2 * index + 1` hold capturing group `index`. The remaining registers
914
+ * are repetition counters, repetition positions, and lookaround frames.
915
+ */
916
+ typedef struct {
917
+ OseoRegExpInstruction *instructions;
918
+ size_t instruction_count;
919
+ /* Concatenated inversion lists; set `index` is the half-open range
920
+ * `set_offsets[index]` through `set_offsets[index + 1]`. */
921
+ uint32_t *set_boundaries;
922
+ uint32_t *set_offsets;
923
+ size_t set_count;
924
+ OseoRegExpRepeat *repeats;
925
+ size_t repeat_count;
926
+ uint16_t *name_units;
927
+ size_t name_unit_count;
928
+ OseoRegExpCapture *captures;
929
+ size_t capture_count;
930
+ size_t registers;
931
+ /*
932
+ * The optional `Canonicalize` table an ahead-of-time descriptor
933
+ * carries. `canonical_characters` ascends, and the character it
934
+ * holds at one position canonicalizes to `canonical_values` at the
935
+ * same position. A program without the table answers from the rule
936
+ * the runtime links, which decides ASCII exactly and refuses a
937
+ * pattern whose sets can reach a class it cannot decide.
938
+ */
939
+ const uint32_t *canonical_characters;
940
+ const uint32_t *canonical_values;
941
+ size_t canonical_count;
942
+ bool unicode_mode;
943
+ bool ignore_case;
944
+ bool has_group_names;
945
+ } OseoRegExpProgram;
946
+
947
+ /*
948
+ * One regular expression literal the build already compiled.
949
+ *
950
+ * The descriptor is immutable generated data: `program` is the matcher
951
+ * artifact `@oseo/compiler` produced for this literal, and `source_units`
952
+ * and `flag_units` are the written pattern and flag text the `source`,
953
+ * `flags`, and `toString` behavior reports. Every evaluation of the
954
+ * literal allocates a fresh object with its own `lastIndex` over one
955
+ * shared artifact, so nothing here is per-evaluation state.
956
+ */
957
+ typedef struct {
958
+ const uint16_t *source_units;
959
+ size_t source_length;
960
+ const uint16_t *flag_units;
961
+ size_t flag_length;
962
+ OseoRegExpProgram *program;
963
+ uint16_t flag_mask;
964
+ } OseoRegExpLiteral;
965
+
966
+ /* Private inline primitives used by generated guarded native paths. */
967
+ static inline bool oseo_value_is_smi(OseoValue value) {
968
+ return (value & UINT64_C(0x7fff000000000000)) ==
969
+ UINT64_C(0x7ff9000000000000);
970
+ }
971
+
972
+ static inline int64_t oseo_value_unbox_smi(OseoValue value) {
973
+ uint64_t payload = value & UINT64_C(0x0000ffffffffffff);
974
+ if ((payload & UINT64_C(0x0000800000000000)) == 0u) {
975
+ return (int64_t)payload;
976
+ }
977
+ uint64_t magnitude =
978
+ ((~payload) & UINT64_C(0x0000ffffffffffff)) + UINT64_C(1);
979
+ return -(int64_t)magnitude;
980
+ }
981
+
982
+ static inline bool oseo_smi_try_add(
983
+ int64_t left,
984
+ int64_t right,
985
+ int64_t *result
986
+ ) {
987
+ const int64_t minimum = INT64_C(-140737488355328);
988
+ const int64_t maximum = INT64_C(140737488355327);
989
+ if (left < minimum || left > maximum ||
990
+ right < minimum || right > maximum) {
991
+ return false;
992
+ }
993
+ if ((right > 0 && left > maximum - right) ||
994
+ (right < 0 && left < minimum - right)) {
995
+ return false;
996
+ }
997
+ *result = left + right;
998
+ return true;
999
+ }
1000
+
1001
+ static inline OseoValue oseo_value_box_smi(int64_t value) {
1002
+ return UINT64_C(0x7ff9000000000000) |
1003
+ ((uint64_t)value & UINT64_C(0x0000ffffffffffff));
1004
+ }
1005
+
1006
+ void oseo_context_init(
1007
+ OseoContext *context,
1008
+ const char *source_id,
1009
+ size_t source_id_length
1010
+ );
1011
+ /* Materializes and returns one realm-owned intrinsic identity. */
1012
+ OseoResult oseo_intrinsic(OseoContext *context, OseoIntrinsic intrinsic);
1013
+ void oseo_context_destroy(OseoContext *context);
1014
+ void oseo_context_fail_allocation_at(OseoContext *context, size_t attempt);
1015
+ /*
1016
+ * Clock boundary operations. `oseo_context_set_clock` installs an adapter
1017
+ * before the realm's first clock use and hands its state to the realm,
1018
+ * which closes it when the context is destroyed.
1019
+ * `oseo_context_restrict_clock` applies OSEO_CLOCK_RESTRICT_* bits to the
1020
+ * platform adapter before it opens. `oseo_clock_open` opens the adapter
1021
+ * on the realm's own thread and reports whether cross-thread wakeup is
1022
+ * available; after it returns, `oseo_clock_wake` may be called from any
1023
+ * thread until destruction. `oseo_clock_real_time` reads epoch
1024
+ * milliseconds and never touches the scheduler clock.
1025
+ */
1026
+ void oseo_context_set_clock(
1027
+ OseoContext *context,
1028
+ const OseoClockAdapter *adapter,
1029
+ void *state
1030
+ );
1031
+ void oseo_context_restrict_clock(
1032
+ OseoContext *context,
1033
+ unsigned restrictions
1034
+ );
1035
+ bool oseo_clock_open(OseoContext *context);
1036
+ bool oseo_clock_wake(OseoContext *context);
1037
+ bool oseo_clock_real_time(OseoContext *context, double *milliseconds);
1038
+ void oseo_clock_capabilities(
1039
+ OseoContext *context,
1040
+ OseoClockCapabilities *capabilities
1041
+ );
1042
+ void oseo_context_clear_language_error(OseoContext *context);
1043
+ void oseo_context_location(
1044
+ OseoContext *context,
1045
+ size_t line,
1046
+ size_t column
1047
+ );
1048
+ void oseo_context_source_location(
1049
+ OseoContext *context,
1050
+ const char *source_id,
1051
+ size_t source_id_length,
1052
+ size_t line,
1053
+ size_t column
1054
+ );
1055
+ void oseo_context_print_error(const OseoContext *context);
1056
+ void oseo_context_print_thrown(OseoContext *context, OseoValue thrown);
1057
+ void oseo_context_print_observations(const OseoContext *context);
1058
+ void oseo_context_set_function_dispatcher(
1059
+ OseoContext *context,
1060
+ OseoFunctionDispatcher dispatcher
1061
+ );
1062
+ void oseo_context_set_generator_dispatcher(
1063
+ OseoContext *context,
1064
+ OseoGeneratorDispatcher dispatcher
1065
+ );
1066
+
1067
+ OseoResult oseo_call_enter(OseoContext *context);
1068
+ void oseo_call_leave(OseoContext *context);
1069
+ OseoResult oseo_frame_enter(OseoContext *context, size_t slot_count);
1070
+ void oseo_frame_leave(OseoContext *context, size_t slot_count);
1071
+
1072
+ void oseo_roots_push(OseoContext *context, OseoRootFrame *frame);
1073
+ void oseo_roots_pop(OseoContext *context, OseoRootFrame *frame);
1074
+ OseoResult oseo_roots_allocate(
1075
+ OseoContext *context,
1076
+ OseoRootFrame *frame,
1077
+ size_t slot_count
1078
+ );
1079
+ void oseo_roots_release(OseoContext *context, OseoRootFrame *frame);
1080
+ void oseo_collect(OseoContext *context);
1081
+
1082
+ OseoValue oseo_undefined(void);
1083
+ OseoValue oseo_uninitialized(void);
1084
+ OseoResult oseo_read_binding(OseoContext *context, OseoValue value);
1085
+ OseoResult oseo_write_immutable_binding(OseoContext *context);
1086
+ OseoValue oseo_null(void);
1087
+ OseoValue oseo_boolean(bool value);
1088
+ OseoValue oseo_number(double value);
1089
+ bool oseo_to_boolean(OseoValue value);
1090
+
1091
+ /* Capture the native invocation before any user code can observe process. */
1092
+ void oseo_process_start(OseoContext *context, int argc, char **argv);
1093
+ /* Flush streams and select the normal-completion exit status. */
1094
+ int oseo_process_finish(OseoContext *context);
1095
+ /* Compiler-owned builtin export lookup; arguments are module/export indexes. */
1096
+ OseoResult oseo_builtin_export(
1097
+ OseoContext *context,
1098
+ size_t argument_count,
1099
+ const OseoValue *arguments
1100
+ );
1101
+
1102
+ OseoResult oseo_string_from_units(
1103
+ OseoContext *context,
1104
+ const uint16_t *units,
1105
+ size_t length
1106
+ );
1107
+ OseoResult oseo_environment_create(OseoContext *context, size_t slot_count);
1108
+ OseoResult oseo_environment_clone(
1109
+ OseoContext *context,
1110
+ OseoValue environment
1111
+ );
1112
+ OseoResult oseo_environment_get(
1113
+ OseoContext *context,
1114
+ OseoValue environment,
1115
+ size_t index
1116
+ );
1117
+ OseoResult oseo_environment_set(
1118
+ OseoContext *context,
1119
+ OseoValue environment,
1120
+ size_t index,
1121
+ OseoValue value
1122
+ );
1123
+ OseoResult oseo_cell_create(OseoContext *context, OseoValue value);
1124
+ /*
1125
+ * A hidden cell standing for one unresolvable global reference. The
1126
+ * compiler emits it for a name no realm binding resolves, so reading the
1127
+ * cell throws exactly the ReferenceError GetValue produces for an
1128
+ * unresolvable Reference. `message` is a generated static string naming
1129
+ * that reference and must outlive the program; nothing writes the cell.
1130
+ */
1131
+ OseoResult oseo_unresolvable_cell_create(
1132
+ OseoContext *context,
1133
+ const char *message
1134
+ );
1135
+ /* A statically selected native operation's operands and source position.
1136
+ * first/second are environment slot/binding ID for a read, object/key slots
1137
+ * for a property get, and input slot/unused for key conversion. output is
1138
+ * the destination root slot. All slots belong to the caller's rooted frame.
1139
+ * A null source_id preserves the current source identity, like
1140
+ * oseo_context_location. This record does not select an operation. */
1141
+ typedef struct {
1142
+ size_t output, first, second;
1143
+ const char *source_id;
1144
+ size_t source_id_length, line, column;
1145
+ } OseoGeneratedOperation;
1146
+
1147
+ bool oseo_generated_binding_read_at(
1148
+ OseoContext *context, OseoValue *roots,
1149
+ const OseoGeneratedOperation *operation, OseoResult *result
1150
+ );
1151
+ void oseo_generated_property_key_at(
1152
+ OseoContext *context, OseoValue *roots,
1153
+ const OseoGeneratedOperation *operation, OseoResult *result
1154
+ );
1155
+ void oseo_generated_property_get_at(
1156
+ OseoContext *context, OseoValue *roots,
1157
+ const OseoGeneratedOperation *operation, OseoResult *result
1158
+ );
1159
+ void oseo_generated_operation_location(
1160
+ OseoContext *context, const OseoGeneratedOperation *operation
1161
+ );
1162
+
1163
+ /* Generated operation compositions keep result and root stores in the archive.
1164
+ * A false binding-read result means environment lookup failed, before the
1165
+ * cell read and output store; a cell's throw still reaches the MIR handler. */
1166
+ bool oseo_generated_binding_read(
1167
+ OseoContext *context, OseoValue environment, size_t index,
1168
+ OseoResult *result, OseoValue *output
1169
+ );
1170
+ void oseo_generated_property_key(
1171
+ OseoContext *context, OseoValue input,
1172
+ OseoResult *result, OseoValue *output
1173
+ );
1174
+ void oseo_generated_property_get(
1175
+ OseoContext *context, OseoValue object, OseoValue key,
1176
+ OseoResult *result, OseoValue *output
1177
+ );
1178
+
1179
+ OseoResult oseo_cell_get(OseoContext *context, OseoValue cell);
1180
+ OseoResult oseo_cell_initialize(
1181
+ OseoContext *context,
1182
+ OseoValue cell,
1183
+ OseoValue value
1184
+ );
1185
+ OseoResult oseo_cell_set(
1186
+ OseoContext *context,
1187
+ OseoValue cell,
1188
+ OseoValue value
1189
+ );
1190
+ OseoResult oseo_module_namespace_create(
1191
+ OseoContext *context,
1192
+ OseoValue environment,
1193
+ size_t count,
1194
+ const uint16_t *const *names,
1195
+ const size_t *name_lengths,
1196
+ const size_t *binding_ids
1197
+ );
1198
+ /*
1199
+ * GlobalDeclarationInstantiation's binding creation for one Script.
1200
+ * Lexical names are checked for restricted non-configurable global
1201
+ * properties before any mutation. Each var or function entry then
1202
+ * preserves an existing property or creates a writable, enumerable,
1203
+ * non-configurable own property whose storage is the binding cell in
1204
+ * `environment`. A preserved property remains ordinary object storage;
1205
+ * its environment cell retains the object and key so reads and writes
1206
+ * continue to observe inherited properties, deletion, accessors, and
1207
+ * descriptor changes. The caller passes names in ECMA-262 creation order,
1208
+ * and the cells must already exist. Module code never calls this; it adds no
1209
+ * global object property. The line and column tables locate the matching
1210
+ * declarations so a failed global-record check reports the declaration it
1211
+ * rejected. An entry that `web_legacy_functions` marks, which may be NULL
1212
+ * when none is, is an Annex B.3.2.2 block-level function name: it skips the
1213
+ * checks that reject a declaration, and creation leaves its cell detached
1214
+ * from the global object when a lexical binding holds the name or the
1215
+ * object is not extensible and lacks the property. Successive calls do not
1216
+ * retain the Global Environment Record's [[VarNames]] or declarative names,
1217
+ * so multi-Script realm sequencing remains outside this ABI. The realm also
1218
+ * installs every admitted intrinsic global,
1219
+ * the standard `Infinity`, `NaN`, and `undefined` value properties, and the
1220
+ * writable, non-enumerable, configurable `globalThis` property that binds
1221
+ * the global object to itself.
1222
+ */
1223
+ OseoResult oseo_global_object_create(
1224
+ OseoContext *context,
1225
+ OseoValue environment,
1226
+ size_t lexical_count,
1227
+ const uint16_t *const *lexical_names,
1228
+ const size_t *lexical_name_lengths,
1229
+ const size_t *lexical_lines,
1230
+ const size_t *lexical_columns,
1231
+ size_t binding_count,
1232
+ const uint16_t *const *names,
1233
+ const size_t *name_lengths,
1234
+ const size_t *binding_lines,
1235
+ const size_t *binding_columns,
1236
+ const size_t *binding_ids,
1237
+ const bool *function_declarations,
1238
+ const bool *web_legacy_functions
1239
+ );
1240
+ /*
1241
+ * SetMutableBinding for a binding the global object also exposes as a
1242
+ * property. It writes the cell unless [[DefineOwnProperty]] made that
1243
+ * property non-writable, in which case the assignment fails the way the
1244
+ * equivalent property assignment fails: with a TypeError in strict code
1245
+ * and silently outside it.
1246
+ */
1247
+ /* Resolve an identifier against persistent Script lexicals, then globals. */
1248
+ OseoResult oseo_global_environment(OseoContext *context, OseoValue key);
1249
+ /* Publish validated Script lexical cells from a fresh Script environment. */
1250
+ OseoResult oseo_script_lexicals_install(
1251
+ OseoContext *context, OseoValue environment, size_t count,
1252
+ const uint16_t *const *names, const size_t *lengths,
1253
+ const size_t *ids, const bool *mutable_bindings
1254
+ );
1255
+
1256
+ OseoResult oseo_global_binding_set(
1257
+ OseoContext *context,
1258
+ OseoValue cell,
1259
+ OseoValue value,
1260
+ bool strict
1261
+ );
1262
+ /*
1263
+ * Initializes a newly created global binding, but preserves the value of an
1264
+ * existing global object property whose cell was reused during declaration
1265
+ * instantiation.
1266
+ */
1267
+ OseoResult oseo_global_binding_initialize(
1268
+ OseoContext *context,
1269
+ OseoValue cell,
1270
+ OseoValue value
1271
+ );
1272
+ /* Initializes or replaces a permitted global function declaration. */
1273
+ OseoResult oseo_global_function_initialize(
1274
+ OseoContext *context,
1275
+ OseoValue cell,
1276
+ OseoValue value
1277
+ );
1278
+ OseoResult oseo_function_create(
1279
+ OseoContext *context,
1280
+ size_t code_id,
1281
+ OseoValue environment,
1282
+ const uint16_t *name_units,
1283
+ size_t name_length,
1284
+ size_t parameter_count,
1285
+ OseoFunctionKind function_kind,
1286
+ OseoValue lexical_this,
1287
+ OseoValue inferred_name,
1288
+ OseoFunctionNamePrefix name_prefix
1289
+ );
1290
+ /*
1291
+ * `oseo_function_create` for a function whose code is non-strict. Such a
1292
+ * function can be reported as another function's legacy `caller`, and a
1293
+ * non-strict OSEO_FUNCTION_ORDINARY function also gets the own `caller`
1294
+ * and `arguments` properties that ADR 0034 defines.
1295
+ */
1296
+ OseoResult oseo_function_create_non_strict(
1297
+ OseoContext *context,
1298
+ size_t code_id,
1299
+ OseoValue environment,
1300
+ const uint16_t *name_units,
1301
+ size_t name_length,
1302
+ size_t parameter_count,
1303
+ OseoFunctionKind function_kind,
1304
+ OseoValue lexical_this,
1305
+ OseoValue inferred_name,
1306
+ OseoFunctionNamePrefix name_prefix
1307
+ );
1308
+ /** Retains the original ECMAScript source text for callable reflection. */
1309
+ OseoResult oseo_function_set_source(
1310
+ OseoContext *context,
1311
+ OseoValue function_value,
1312
+ const uint16_t *source_units,
1313
+ size_t source_length
1314
+ );
1315
+ OseoResult oseo_function_environment(
1316
+ OseoContext *context,
1317
+ OseoValue function
1318
+ );
1319
+ OseoResult oseo_function_code_id(
1320
+ OseoContext *context,
1321
+ OseoValue function,
1322
+ size_t *code_id
1323
+ );
1324
+ OseoResult oseo_unknown_function(OseoContext *context, size_t code_id);
1325
+ OseoResult oseo_call_function(
1326
+ OseoContext *context,
1327
+ OseoValue callee,
1328
+ OseoValue receiver,
1329
+ size_t argument_count,
1330
+ const OseoValue *arguments,
1331
+ OseoValue new_target
1332
+ );
1333
+ /*
1334
+ * EvaluateCall for a call in tail position, after its arguments are
1335
+ * evaluated. A value that is not callable throws here, in the calling
1336
+ * frame, exactly as `oseo_call_function` would. Otherwise the call is
1337
+ * recorded with the running realm and OSEO_STATUS_TAIL_CALL is returned;
1338
+ * the generated body releases its roots and returns that result, and the
1339
+ * enclosing `oseo_call_function` or `oseo_call_complete` performs the
1340
+ * call. The arguments are copied, so they may live in the caller's
1341
+ * frame.
1342
+ */
1343
+ OseoResult oseo_tail_call(
1344
+ OseoContext *context,
1345
+ OseoValue callee,
1346
+ OseoValue receiver,
1347
+ size_t argument_count,
1348
+ const OseoValue *arguments
1349
+ );
1350
+ /*
1351
+ * `oseo_tail_call` from a derived class constructor body. The `this`
1352
+ * binding cell travels with the call, and once the chain completes
1353
+ * normally the trampoline applies the derived constructor result rules
1354
+ * to its value in the realm that made the call.
1355
+ */
1356
+ OseoResult oseo_tail_call_derived(
1357
+ OseoContext *context,
1358
+ OseoValue callee,
1359
+ OseoValue receiver,
1360
+ size_t argument_count,
1361
+ const OseoValue *arguments,
1362
+ OseoValue this_cell
1363
+ );
1364
+ /*
1365
+ * The host intrinsics a generated body may call in tail position without
1366
+ * a callable value of their own. The calling frame is discarded before
1367
+ * each intrinsic, including `clearTimeout`, as PrepareForTailCall
1368
+ * requires even when the target runs no user code or allocation.
1369
+ */
1370
+ typedef enum {
1371
+ OSEO_TAIL_HOST_CONSOLE_LOG = 1,
1372
+ OSEO_TAIL_HOST_SET_TIMEOUT = 2,
1373
+ OSEO_TAIL_HOST_CLEAR_TIMEOUT = 3,
1374
+ } OseoTailHost;
1375
+ /*
1376
+ * `oseo_tail_call` for one host intrinsic: the arguments are copied and
1377
+ * the intrinsic runs as the next trampoline step, in the realm that made
1378
+ * the call. `clearTimeout` uses its first argument or undefined when
1379
+ * absent, ignores extra arguments after their evaluation, and preserves
1380
+ * the direct intrinsic's numeric-handle-only contract and undefined result.
1381
+ */
1382
+ OseoResult oseo_tail_host_call(
1383
+ OseoContext *context,
1384
+ OseoTailHost host,
1385
+ size_t argument_count,
1386
+ const OseoValue *arguments
1387
+ );
1388
+ /* `oseo_tail_host_call` from a derived class constructor body. */
1389
+ OseoResult oseo_tail_host_call_derived(
1390
+ OseoContext *context,
1391
+ OseoTailHost host,
1392
+ size_t argument_count,
1393
+ const OseoValue *arguments,
1394
+ OseoValue this_cell
1395
+ );
1396
+ /*
1397
+ * Completes a direct call of a generated function body: a result with
1398
+ * OSEO_STATUS_TAIL_CALL performs the recorded calls, and any other result
1399
+ * is returned unchanged.
1400
+ */
1401
+ OseoResult oseo_call_complete(OseoContext *context, OseoResult result);
1402
+ /*
1403
+ * Creates one suspended generator for a call to `callee`. The record
1404
+ * owns `slot_count` collector-traced root slots and `completion_count`
1405
+ * saved completion records, so the generator body's frame survives every
1406
+ * suspension. The generator's [[Prototype]] is the function's
1407
+ * `prototype` object when that is an object, and null otherwise.
1408
+ */
1409
+ OseoResult oseo_generator_create(
1410
+ OseoContext *context,
1411
+ OseoValue callee,
1412
+ OseoValue receiver,
1413
+ size_t slot_count,
1414
+ size_t completion_count
1415
+ );
1416
+ /*
1417
+ * The generator record's stable interior pointers and saved state.
1418
+ * Generated body code reacquires each on entry; the collector never
1419
+ * moves a generator, so the pointers stay valid across safepoints.
1420
+ */
1421
+ OseoValue *oseo_generator_slots(OseoValue generator);
1422
+ OseoCompletionRecord *oseo_generator_completions(OseoValue generator);
1423
+ OseoValue oseo_generator_callee(OseoValue generator);
1424
+ OseoValue oseo_generator_receiver(OseoValue generator);
1425
+ OseoValue oseo_generator_sent(OseoValue generator);
1426
+ size_t oseo_generator_resume_point(OseoValue generator);
1427
+ /*
1428
+ * How the pending resumption delivers `sent`. A normal resumption
1429
+ * continues at the suspension's resume block; a return resumption leaves
1430
+ * the body from the suspension point, so generated code branches to the
1431
+ * block that runs the enclosing `finally` and iterator-close chain; a
1432
+ * throw resumption raises `sent` at the suspension point. The prototype
1433
+ * throw methods deliver a throw resumption to either body kind, and an
1434
+ * awaited rejection delivers one to an asynchronous body.
1435
+ */
1436
+ #define OSEO_GENERATOR_RESUME_NEXT ((size_t)0u)
1437
+ #define OSEO_GENERATOR_RESUME_RETURN ((size_t)1u)
1438
+ #define OSEO_GENERATOR_RESUME_THROW ((size_t)2u)
1439
+ size_t oseo_generator_resume_kind(OseoValue generator);
1440
+ /*
1441
+ * What a pending suspension asked its driver for. A yield leaves an
1442
+ * iteration step; an await leaves an operand the driver settles before
1443
+ * it resumes the body, and no consumer observes it. Only an asynchronous
1444
+ * generator body suspends to await.
1445
+ */
1446
+ #define OSEO_GENERATOR_SUSPEND_YIELD ((size_t)0u)
1447
+ #define OSEO_GENERATOR_SUSPEND_AWAIT ((size_t)1u)
1448
+ /*
1449
+ * Records the block that the next resumption continues at and marks the
1450
+ * generator suspended. Generated code calls this immediately before
1451
+ * leaving a body with a yielded or awaited value. `result_object` is
1452
+ * true when that value already is a complete iterator result object, as
1453
+ * it is for a synchronous `yield*`, which forwards the inner iterator's
1454
+ * own result unchanged.
1455
+ */
1456
+ void oseo_generator_suspend(
1457
+ OseoContext *context,
1458
+ OseoValue generator,
1459
+ size_t resume_point,
1460
+ bool result_object,
1461
+ size_t suspend_reason
1462
+ );
1463
+ /*
1464
+ * %GeneratorPrototype%.next: resumes a suspended generator with `sent`
1465
+ * and returns a fresh { value, done } object. A completed generator
1466
+ * returns { undefined, true } without entering the body, and a running
1467
+ * one throws a TypeError.
1468
+ */
1469
+ OseoResult oseo_generator_next(
1470
+ OseoContext *context,
1471
+ OseoValue generator,
1472
+ OseoValue sent
1473
+ );
1474
+ /*
1475
+ * %GeneratorPrototype%.return: resumes a suspended generator with a
1476
+ * return completion so every enclosing `finally` and iterator close in
1477
+ * the body runs, then returns a fresh { value, done } object. A body
1478
+ * that yields again from a `finally` reports { yielded, false }. A
1479
+ * generator suspended at its start or already completed returns
1480
+ * { value, true } without entering the body, and a running one throws a
1481
+ * TypeError. `IteratorClose` reaches this through the `return` method.
1482
+ */
1483
+ OseoResult oseo_generator_return(
1484
+ OseoContext *context,
1485
+ OseoValue generator,
1486
+ OseoValue value
1487
+ );
1488
+ /*
1489
+ * %GeneratorPrototype%.throw: resumes a suspended generator with a
1490
+ * throw completion. An unstarted or completed generator completes
1491
+ * immediately and re-throws the value. A running generator throws a
1492
+ * TypeError.
1493
+ */
1494
+ OseoResult oseo_generator_throw(
1495
+ OseoContext *context,
1496
+ OseoValue generator,
1497
+ OseoValue value
1498
+ );
1499
+ /*
1500
+ * %AsyncGeneratorPrototype%.next, .return, and .throw. Each enqueues one
1501
+ * AsyncGeneratorRequest and returns its promise immediately: the step
1502
+ * runs only while the queue's head owns it, so a call that arrives while
1503
+ * the body is running or awaiting waits its turn instead of reaching a
1504
+ * running body. A completed generator reports { undefined, true } from
1505
+ * `next`, awaits the value it reports done from `return`, and rejects
1506
+ * from `throw`. A receiver that is not an asynchronous generator rejects
1507
+ * with a TypeError rather than throwing it.
1508
+ */
1509
+ OseoResult oseo_async_generator_next(
1510
+ OseoContext *context,
1511
+ OseoValue generator,
1512
+ OseoValue sent
1513
+ );
1514
+ OseoResult oseo_async_generator_return(
1515
+ OseoContext *context,
1516
+ OseoValue generator,
1517
+ OseoValue value
1518
+ );
1519
+ OseoResult oseo_async_generator_throw(
1520
+ OseoContext *context,
1521
+ OseoValue generator,
1522
+ OseoValue reason
1523
+ );
1524
+ /*
1525
+ * Starts the hidden traced frame of an ordinary asynchronous function, or
1526
+ * converts an abrupt parameter prologue into its returned rejection.
1527
+ */
1528
+ OseoResult oseo_async_function_start(
1529
+ OseoContext *context,
1530
+ OseoValue frame
1531
+ );
1532
+ OseoResult oseo_async_function_reject(
1533
+ OseoContext *context,
1534
+ OseoValue reason
1535
+ );
1536
+ OseoResult oseo_argument_list_create(OseoContext *context);
1537
+ OseoResult oseo_argument_list_append(
1538
+ OseoContext *context,
1539
+ OseoValue list,
1540
+ OseoValue value
1541
+ );
1542
+ OseoResult oseo_argument_list_view(
1543
+ OseoContext *context,
1544
+ OseoValue list,
1545
+ size_t *count,
1546
+ const OseoValue **arguments
1547
+ );
1548
+ OseoResult oseo_function_prototype(
1549
+ OseoContext *context,
1550
+ OseoValue function
1551
+ );
1552
+ OseoResult oseo_constructor_result(
1553
+ OseoContext *context,
1554
+ OseoValue returned,
1555
+ OseoValue receiver
1556
+ );
1557
+ OseoResult oseo_constructor_receiver(
1558
+ OseoContext *context,
1559
+ OseoValue prototype
1560
+ );
1561
+ /*
1562
+ * Links a derived class to its `extends` operand. `heritage` must be
1563
+ * null or a constructor whose `prototype` is an object or null;
1564
+ * otherwise this throws a TypeError. On success the constructor's
1565
+ * [[Prototype]] becomes `heritage` and the class `prototype` object's
1566
+ * [[Prototype]] becomes the parent's `prototype`, so static and instance
1567
+ * lookups both walk into the parent. A null heritage leaves both null,
1568
+ * which is what an ordinary function's [[Prototype]] already is here,
1569
+ * and leaves `super()` with no constructor to reach.
1570
+ */
1571
+ OseoResult oseo_class_heritage(
1572
+ OseoContext *context,
1573
+ OseoValue constructor,
1574
+ OseoValue heritage
1575
+ );
1576
+ /*
1577
+ * Appends one instance field to a class constructor's [[Fields]]: the
1578
+ * key the class body evaluated and the closure that produces the value,
1579
+ * or `undefined` for a field declared without an initializer. Fields
1580
+ * are recorded in class-body order and run in that order.
1581
+ */
1582
+ OseoResult oseo_class_field_define(
1583
+ OseoContext *context,
1584
+ OseoValue constructor,
1585
+ OseoValue key,
1586
+ OseoValue initializer
1587
+ );
1588
+ /*
1589
+ * Creates one Private Name. Identity is the allocation itself, so a
1590
+ * class body evaluated twice produces names that never match and an
1591
+ * instance of one evaluation fails the other's brand check.
1592
+ */
1593
+ OseoResult oseo_private_name_create(OseoContext *context);
1594
+ /*
1595
+ * Replace one lexical cell and initialize it to a fresh private identity.
1596
+ * All intermediate roots live only until this bounded operation returns;
1597
+ * closures from earlier evaluations retain their original cells.
1598
+ */
1599
+ OseoResult oseo_private_name_bind(
1600
+ OseoContext *context,
1601
+ OseoValue environment,
1602
+ size_t binding_id
1603
+ );
1604
+ /*
1605
+ * Appends one private field to a class constructor's element list: the
1606
+ * private name and the closure that produces the value, or `undefined`
1607
+ * for a field declared without an initializer.
1608
+ */
1609
+ OseoResult oseo_class_private_field_define(
1610
+ OseoContext *context,
1611
+ OseoValue constructor,
1612
+ OseoValue name,
1613
+ OseoValue initializer
1614
+ );
1615
+ /* Which half of a private element one class body definition supplies. */
1616
+ typedef enum {
1617
+ OSEO_PRIVATE_METHOD = 0,
1618
+ OSEO_PRIVATE_GETTER = 1,
1619
+ OSEO_PRIVATE_SETTER = 2,
1620
+ } OseoPrivateMethodKind;
1621
+ /*
1622
+ * Appends one private method or accessor half to a class constructor's
1623
+ * element list. A getter and a setter recorded under the same private
1624
+ * name merge into the one accessor element that name reaches, whichever
1625
+ * order the class body defines them in.
1626
+ */
1627
+ OseoResult oseo_class_private_method_define(
1628
+ OseoContext *context,
1629
+ OseoValue constructor,
1630
+ OseoValue name,
1631
+ OseoValue value,
1632
+ OseoPrivateMethodKind kind
1633
+ );
1634
+ /*
1635
+ * Installs one static private method or accessor half directly on
1636
+ * the class constructor. A getter and setter under the same private
1637
+ * name merge into one accessor element, whichever order defines them.
1638
+ */
1639
+ OseoResult oseo_class_static_private_method_define(
1640
+ OseoContext *context,
1641
+ OseoValue constructor,
1642
+ OseoValue name,
1643
+ OseoValue value,
1644
+ OseoPrivateMethodKind kind
1645
+ );
1646
+ /*
1647
+ * PrivateGet: the value `object` carries under one private name. A
1648
+ * field or method element yields its value, an accessor element runs
1649
+ * its getter against the object, and an object whose class never
1650
+ * installed the element throws a TypeError, because a private name
1651
+ * cannot be an absent property key.
1652
+ */
1653
+ OseoResult oseo_private_get(
1654
+ OseoContext *context,
1655
+ OseoValue object,
1656
+ OseoValue name
1657
+ );
1658
+ /*
1659
+ * PrivateBrandCheck: reports whether `object` carries an element under
1660
+ * one private name. An object with another brand returns false. A
1661
+ * non-object operand throws a TypeError.
1662
+ */
1663
+ OseoResult oseo_private_in(
1664
+ OseoContext *context,
1665
+ OseoValue object,
1666
+ OseoValue name
1667
+ );
1668
+ /*
1669
+ * PrivateSet: replaces the value `object` carries under one private
1670
+ * name and reports the assigned value. Only a field element and an
1671
+ * accessor element with a setter accept a write; a method element, a
1672
+ * getter-only accessor, and an object without the element all throw a
1673
+ * TypeError.
1674
+ */
1675
+ OseoResult oseo_private_set(
1676
+ OseoContext *context,
1677
+ OseoValue object,
1678
+ OseoValue name,
1679
+ OseoValue value
1680
+ );
1681
+ /*
1682
+ * InitializeInstanceElements: installs `constructor`'s recorded private
1683
+ * methods and accessors on `instance`, then runs its field
1684
+ * initializers in class-body order. Each public field result becomes an
1685
+ * own writable, enumerable, configurable data property and each private
1686
+ * field result becomes a private element. Every initializer is called
1687
+ * with the instance as its receiver and no arguments, and an abrupt
1688
+ * completion stops the remaining elements.
1689
+ */
1690
+ OseoResult oseo_initialize_instance_elements(
1691
+ OseoContext *context,
1692
+ OseoValue constructor,
1693
+ OseoValue instance
1694
+ );
1695
+ /*
1696
+ * DefineField with a class constructor as the receiver, which is how a
1697
+ * `static` field is initialized. The initializer, or `undefined` for a
1698
+ * field declared without one, is called with the constructor as its
1699
+ * receiver and no arguments, and the result becomes an own writable,
1700
+ * enumerable, configurable data property of the constructor.
1701
+ */
1702
+ OseoResult oseo_class_static_field_define(
1703
+ OseoContext *context,
1704
+ OseoValue constructor,
1705
+ OseoValue key,
1706
+ OseoValue initializer
1707
+ );
1708
+ /*
1709
+ * The same definition for a `static #name` field, whose result becomes
1710
+ * a private element the constructor itself carries rather than a
1711
+ * property. A private reference whose lexical environment resolves the
1712
+ * name reaches it only when its selected object has that element.
1713
+ */
1714
+ OseoResult oseo_class_static_private_field_define(
1715
+ OseoContext *context,
1716
+ OseoValue constructor,
1717
+ OseoValue name,
1718
+ OseoValue initializer
1719
+ );
1720
+ /*
1721
+ * Records one class element's [[HomeObject]]: the class prototype
1722
+ * object for an instance element and the constructor for a static one.
1723
+ * A value that is not a function is ignored, because only a function
1724
+ * carries the slot.
1725
+ */
1726
+ void oseo_bind_home_object(OseoValue function, OseoValue home);
1727
+ /*
1728
+ * Captures an arrow function's lexical execution context. The receiver
1729
+ * is already supplied to function creation; this adds the enclosing
1730
+ * function's home object and super-constructor context plus new.target.
1731
+ */
1732
+ void oseo_bind_arrow_context(
1733
+ OseoValue function,
1734
+ OseoValue enclosing,
1735
+ OseoValue new_target
1736
+ );
1737
+ /*
1738
+ * GetSuperBase: the [[Prototype]] of the running function's home
1739
+ * object, where a `super` property reference starts its lookup. A
1740
+ * function without a home object, or a home object without a prototype,
1741
+ * yields a nullish value that the reference itself rejects, so this
1742
+ * reports no completion of its own.
1743
+ */
1744
+ OseoValue oseo_super_base(OseoValue callee);
1745
+ /*
1746
+ * A `super.x` read. The lookup starts at `base` while a getter runs
1747
+ * against `receiver`, which is the `this` of the class element holding
1748
+ * the reference.
1749
+ */
1750
+ OseoResult oseo_super_get(
1751
+ OseoContext *context,
1752
+ OseoValue base,
1753
+ OseoValue key,
1754
+ OseoValue receiver
1755
+ );
1756
+ /*
1757
+ * A `super.x = v` write, which is Set with a receiver distinct from the
1758
+ * object the lookup walks. A setter found on `base` or its prototype
1759
+ * chain runs against `receiver`; otherwise the assignment creates or
1760
+ * updates an own property of `receiver` and never reaches a setter that
1761
+ * only `receiver`'s own chain would find. A read-only property on
1762
+ * either side reports a TypeError in strict code and is ignored
1763
+ * otherwise.
1764
+ */
1765
+ OseoResult oseo_super_set(
1766
+ OseoContext *context,
1767
+ OseoValue base,
1768
+ OseoValue key,
1769
+ OseoValue value,
1770
+ OseoValue receiver,
1771
+ bool strict
1772
+ );
1773
+ /*
1774
+ * The `delete` evaluation's rejection of a `super` property reference.
1775
+ * The receiver and the key expression have already been evaluated and
1776
+ * the key was deliberately not converted, so this only raises the
1777
+ * ReferenceError that step and reports no normal completion.
1778
+ */
1779
+ OseoResult oseo_super_property_delete(OseoContext *context);
1780
+ /*
1781
+ * GetSuperConstructor: the running constructor's own [[Prototype]],
1782
+ * read before the `super(...)` arguments are evaluated, 13.3.7.1 step 3.
1783
+ * It never throws; the value may be any object or undefined.
1784
+ */
1785
+ OseoResult oseo_super_constructor(
1786
+ OseoContext *context,
1787
+ OseoValue callee
1788
+ );
1789
+ /*
1790
+ * SuperCall step 5: throws a TypeError when the value GetSuperConstructor
1791
+ * read is not a constructor, which is how `class C extends null {}`
1792
+ * rejects `super()`. It runs after the arguments are evaluated, so an
1793
+ * argument side effect is observed even when the call then throws.
1794
+ */
1795
+ OseoResult oseo_super_constructor_check(
1796
+ OseoContext *context,
1797
+ OseoValue parent
1798
+ );
1799
+ /*
1800
+ * SuperCall's OrdinaryCreateFromConstructor: the receiver the super
1801
+ * constructor's [[Construct]] starts from, taken from the running
1802
+ * constructor's new target. The `prototype` read is a real Get when the
1803
+ * super constructor is an ordinary or base class constructor, whose
1804
+ * clause performs it at this position, and the synthetic slot when it
1805
+ * is a built-in, whose clause performs its own Get later. The result is
1806
+ * undefined when the super constructor is itself derived, because that
1807
+ * clause creates no receiver at all.
1808
+ */
1809
+ OseoResult oseo_super_constructor_receiver(
1810
+ OseoContext *context,
1811
+ OseoValue parent,
1812
+ OseoValue new_target
1813
+ );
1814
+ /*
1815
+ * BindThisValue. A derived constructor's `this` cell starts
1816
+ * uninitialized, so a second `super()` in the same invocation throws a
1817
+ * ReferenceError rather than replacing the receiver.
1818
+ */
1819
+ OseoResult oseo_bind_this(
1820
+ OseoContext *context,
1821
+ OseoValue cell,
1822
+ OseoValue value
1823
+ );
1824
+ /*
1825
+ * A derived constructor's completion value. An object stands as
1826
+ * written, `undefined` yields the bound `this` and therefore throws a
1827
+ * ReferenceError when `super()` never ran, and any other value is a
1828
+ * TypeError.
1829
+ */
1830
+ OseoResult oseo_derived_constructor_result(
1831
+ OseoContext *context,
1832
+ OseoValue returned,
1833
+ OseoValue cell
1834
+ );
1835
+ OseoResult oseo_array_create(OseoContext *context, size_t length);
1836
+ /*
1837
+ * Append operations are for monotonic generated array accumulation. The
1838
+ * array must not already own the property named by its current length.
1839
+ */
1840
+ OseoResult oseo_array_append(
1841
+ OseoContext *context,
1842
+ OseoValue array,
1843
+ OseoValue value
1844
+ );
1845
+ OseoResult oseo_array_append_hole(
1846
+ OseoContext *context,
1847
+ OseoValue array
1848
+ );
1849
+ /*
1850
+ * Returns the frozen template object for one generated parse site, creating
1851
+ * its frozen raw array and realm-local cache entry on first evaluation.
1852
+ */
1853
+ OseoResult oseo_template_object(
1854
+ OseoContext *context,
1855
+ const void *site,
1856
+ size_t count,
1857
+ const uint16_t *const *cooked,
1858
+ const size_t *cooked_lengths,
1859
+ const bool *cooked_defined,
1860
+ const uint16_t *const *raw,
1861
+ const size_t *raw_lengths
1862
+ );
1863
+ /*
1864
+ * Evaluates one ahead-of-time compiled regular expression literal.
1865
+ *
1866
+ * The descriptor is compiled generated data, so no pattern is parsed or
1867
+ * compiled here. The realm keeps one immutable matcher artifact per
1868
+ * descriptor and this returns a fresh RegExp object over it whose own
1869
+ * `lastIndex` starts at zero, which is what keeps repeated evaluation of
1870
+ * one literal from sharing observable state.
1871
+ */
1872
+ OseoResult oseo_regexp_literal(
1873
+ OseoContext *context,
1874
+ const OseoRegExpLiteral *literal
1875
+ );
1876
+ OseoResult oseo_object_create(OseoContext *context, OseoValue prototype);
1877
+ OseoResult oseo_object_literal_create(OseoContext *context);
1878
+ /*
1879
+ * CreateUnmappedArgumentsObject (10.4.4.6) for one admitted function
1880
+ * invocation that is strict, has a non-simple parameter list, or both.
1881
+ * Indexed properties snapshot the call arguments and `length` records
1882
+ * their count; `callee` is the non-configurable poisoned accessor whose
1883
+ * [[Get]] and [[Set]] are both %ThrowTypeError%, so the object never
1884
+ * exposes the running function. A non-strict function with a simple
1885
+ * parameter list instead calls oseo_mapped_arguments_create, which is
1886
+ * the only shape that keeps `callee` an ordinary data property.
1887
+ */
1888
+ OseoResult oseo_arguments_create(
1889
+ OseoContext *context,
1890
+ size_t argument_count,
1891
+ const OseoValue *arguments
1892
+ );
1893
+ /*
1894
+ * Creates the mapped arguments exotic object (10.4.4.7) for one
1895
+ * admitted non-strict function invocation whose parameter list is
1896
+ * simple. Indexed properties snapshot the call arguments the same way
1897
+ * oseo_arguments_create does; `mapped_indices` then names, in
1898
+ * ascending order, the `mapped_count` indices that alias their
1899
+ * parameter's own binding cell in `environment`, keyed by
1900
+ * `mapped_binding_ids` at the same position. `length` and `callee`
1901
+ * match the unmapped object's own attributes and values.
1902
+ */
1903
+ OseoResult oseo_mapped_arguments_create(
1904
+ OseoContext *context,
1905
+ OseoValue environment,
1906
+ OseoValue callee,
1907
+ size_t argument_count,
1908
+ const OseoValue *arguments,
1909
+ const size_t *mapped_indices,
1910
+ const size_t *mapped_binding_ids,
1911
+ size_t mapped_count
1912
+ );
1913
+ /* ToObject: retain objects; box primitives; reject null and undefined. */
1914
+ OseoResult oseo_to_object(OseoContext *context, OseoValue value);
1915
+ OseoResult oseo_require_object_coercible(
1916
+ OseoContext *context,
1917
+ OseoValue value
1918
+ );
1919
+ OseoResult oseo_require_delete_object_coercible(
1920
+ OseoContext *context,
1921
+ OseoValue value
1922
+ );
1923
+ OseoResult oseo_object_rest(
1924
+ OseoContext *context,
1925
+ OseoValue source,
1926
+ size_t excluded_count,
1927
+ const OseoValue *excluded_keys
1928
+ );
1929
+ OseoResult oseo_object_spread(
1930
+ OseoContext *context,
1931
+ OseoValue target,
1932
+ OseoValue source
1933
+ );
1934
+ OseoResult oseo_property_key(OseoContext *context, OseoValue value);
1935
+ OseoResult oseo_object_define(
1936
+ OseoContext *context,
1937
+ OseoValue object,
1938
+ OseoValue key,
1939
+ OseoValue value,
1940
+ OseoPropertyAttributes attributes
1941
+ );
1942
+ /*
1943
+ * Defines an accessor property descriptor, generalizing
1944
+ * PropertyDefinitionEvaluation for an object literal getter or setter
1945
+ * clause (has_getter xor has_setter, attributes always
1946
+ * {true, true, false, true}) and Object.defineProperty's accessor
1947
+ * descriptors (either slot present, explicit attributes). When the
1948
+ * existing own property is already an accessor, an absent slot is
1949
+ * preserved from it; otherwise, including when converting an existing
1950
+ * data property, an absent slot starts undefined. attributes.accessor
1951
+ * must be true and attributes.writable is ignored.
1952
+ */
1953
+ OseoResult oseo_object_define_accessor(
1954
+ OseoContext *context,
1955
+ OseoValue object,
1956
+ OseoValue key,
1957
+ OseoValue getter,
1958
+ OseoValue setter,
1959
+ bool has_getter,
1960
+ bool has_setter,
1961
+ OseoPropertyAttributes attributes
1962
+ );
1963
+ OseoResult oseo_object_delete(
1964
+ OseoContext *context,
1965
+ OseoValue object,
1966
+ OseoValue key,
1967
+ bool strict
1968
+ );
1969
+ OseoResult oseo_object_get(
1970
+ OseoContext *context,
1971
+ OseoValue object,
1972
+ OseoValue key
1973
+ );
1974
+ bool oseo_value_is_object(OseoValue value);
1975
+ bool oseo_property_cache_matches(
1976
+ OseoValue object,
1977
+ const OseoPropertyCache *cache
1978
+ );
1979
+ OseoValue oseo_property_cache_load(
1980
+ OseoValue object,
1981
+ const OseoPropertyCache *cache
1982
+ );
1983
+ void oseo_property_cache_update(
1984
+ OseoValue object,
1985
+ OseoValue key,
1986
+ OseoPropertyCache *cache
1987
+ );
1988
+ OseoResult oseo_object_has_own(
1989
+ OseoContext *context,
1990
+ OseoValue object,
1991
+ OseoValue key
1992
+ );
1993
+ OseoResult oseo_object_set(
1994
+ OseoContext *context,
1995
+ OseoValue object,
1996
+ OseoValue key,
1997
+ OseoValue value,
1998
+ bool strict
1999
+ );
2000
+ OseoResult oseo_object_set_prototype(
2001
+ OseoContext *context,
2002
+ OseoValue object,
2003
+ OseoValue prototype
2004
+ );
2005
+ /** Implements the object-literal prototype setter while leaving the existing
2006
+ * object prototype mutation path authoritative for object and null values. */
2007
+ OseoResult oseo_object_literal_set_prototype(
2008
+ OseoContext *context,
2009
+ OseoValue object,
2010
+ OseoValue prototype
2011
+ );
2012
+ OseoResult oseo_object_builtin_create(
2013
+ OseoContext *context,
2014
+ size_t argument_count,
2015
+ const OseoValue *arguments
2016
+ );
2017
+ OseoResult oseo_object_builtin_define_property(
2018
+ OseoContext *context,
2019
+ size_t argument_count,
2020
+ const OseoValue *arguments
2021
+ );
2022
+ OseoResult oseo_object_builtin_get_own_property_descriptor(
2023
+ OseoContext *context,
2024
+ size_t argument_count,
2025
+ const OseoValue *arguments
2026
+ );
2027
+ OseoResult oseo_object_builtin_keys(
2028
+ OseoContext *context,
2029
+ size_t argument_count,
2030
+ const OseoValue *arguments
2031
+ );
2032
+ OseoResult oseo_object_builtin_set_prototype_of(
2033
+ OseoContext *context,
2034
+ size_t argument_count,
2035
+ const OseoValue *arguments
2036
+ );
2037
+ /*
2038
+ * EnumerateObjectProperties (14.7.5.9), the only consumer of which is a
2039
+ * for-in head. It is not the iterator protocol: acquisition reads no
2040
+ * `Symbol.iterator` and no `next` method, no step runs user code, and
2041
+ * the record is never closed, so an abrupt head target or body leaves
2042
+ * the loop without a cleanup call.
2043
+ *
2044
+ * `oseo_enumerate_get` reports `done` for a nullish subject and leaves
2045
+ * `record` undefined, which is the break completion
2046
+ * ForIn/OfHeadEvaluation returns before ToObject runs.
2047
+ * `oseo_enumerate_next` reports `done` once every own and inherited
2048
+ * enumerable string key has been reported at most once.
2049
+ */
2050
+ OseoResult oseo_enumerate_get(
2051
+ OseoContext *context,
2052
+ OseoValue subject,
2053
+ OseoValue *record,
2054
+ bool *done
2055
+ );
2056
+ OseoResult oseo_enumerate_next(
2057
+ OseoContext *context,
2058
+ OseoValue record,
2059
+ OseoValue *key,
2060
+ bool *done
2061
+ );
2062
+ /*
2063
+ * Acquire a synchronous iterator and read its next property once.
2064
+ * On success, result.value is the iterator and *next_method is the
2065
+ * captured value, which need not be callable. Getter errors propagate
2066
+ * during acquisition; callability is checked when stepping.
2067
+ * next_method points to a caller-owned output slot. On a normal return,
2068
+ * no allocation occurs between storing the captured value and returning.
2069
+ * Root the returned iterator and captured value before any subsequent
2070
+ * allocation, suspension, or step.
2071
+ */
2072
+ OseoResult oseo_iterator_get(
2073
+ OseoContext *context,
2074
+ OseoValue iterable,
2075
+ OseoValue *next_method
2076
+ );
2077
+ /*
2078
+ * Step with the captured next value without rereading the property.
2079
+ * The caller must keep next_method rooted throughout each call; this
2080
+ * helper roots the iterator and result values, but not that captured
2081
+ * method. Keep *value rooted if it must survive later allocations.
2082
+ */
2083
+ OseoResult oseo_iterator_next(
2084
+ OseoContext *context,
2085
+ OseoValue iterator,
2086
+ OseoValue next_method,
2087
+ OseoValue *value,
2088
+ bool *done
2089
+ );
2090
+ OseoResult oseo_iterator_close(
2091
+ OseoContext *context,
2092
+ OseoValue iterator,
2093
+ bool from_error
2094
+ );
2095
+ /*
2096
+ * The DisposeCapability of one `using` or `await using` scope (ADR 0017
2097
+ * cleanup region). `create` makes an empty capability, and `add` performs
2098
+ * AddDisposableResource for one declared value and returns that value.
2099
+ * `dispose` runs DisposeResources synchronously from the pending
2100
+ * completion, given whether it is a throw and its value; it throws only
2101
+ * when a dispose method failed, with that error or a SuppressedError
2102
+ * chain, and otherwise lets the region resume its own completion.
2103
+ *
2104
+ * The asynchronous form runs in the generated frame (ADR 0011). `begin`
2105
+ * starts DisposeResources and stops at its first Await; while `awaiting`
2106
+ * answers true, generated code awaits `await_value` and passes the
2107
+ * settlement to `continue`, which runs to the next Await or the end.
2108
+ * `result` then reports the final completion the way `dispose` does. A
2109
+ * scope that holds no resource finishes inside `begin` without awaiting.
2110
+ */
2111
+ OseoResult oseo_dispose_scope_create(OseoContext *context, bool async);
2112
+ OseoResult oseo_dispose_scope_add(
2113
+ OseoContext *context,
2114
+ OseoValue scope,
2115
+ OseoValue value,
2116
+ bool async
2117
+ );
2118
+ OseoResult oseo_dispose_scope_dispose(
2119
+ OseoContext *context,
2120
+ OseoValue scope,
2121
+ bool throwing,
2122
+ OseoValue completion
2123
+ );
2124
+ OseoResult oseo_dispose_scope_begin(
2125
+ OseoContext *context,
2126
+ OseoValue scope,
2127
+ bool throwing,
2128
+ OseoValue completion
2129
+ );
2130
+ OseoResult oseo_dispose_scope_awaiting(OseoContext *context, OseoValue scope);
2131
+ OseoResult oseo_dispose_scope_await_value(
2132
+ OseoContext *context,
2133
+ OseoValue scope
2134
+ );
2135
+ OseoResult oseo_dispose_scope_continue(
2136
+ OseoContext *context,
2137
+ OseoValue scope,
2138
+ bool fulfilled,
2139
+ OseoValue value
2140
+ );
2141
+ OseoResult oseo_dispose_scope_result(OseoContext *context, OseoValue scope);
2142
+ /*
2143
+ * Acquire an asynchronous iterator through Symbol.asyncIterator, or wrap
2144
+ * a synchronous iterator when that method is absent. On success, direct
2145
+ * async acquisition captures a callable next_method. The sync fallback
2146
+ * returns a wrapper and the arbitrary, possibly non-callable next value
2147
+ * captured by oseo_iterator_get.
2148
+ * next_method must point to a caller-owned output slot rooted before
2149
+ * entry: the fallback allocates its wrapper after writing that slot.
2150
+ * Keep the returned iterator and captured value rooted across later
2151
+ * allocations, suspension, and steps. The step and close entry points
2152
+ * accept either iterator form; steps await results and report value
2153
+ * and done through their output parameters.
2154
+ */
2155
+ OseoResult oseo_async_iterator_get(
2156
+ OseoContext *context,
2157
+ OseoValue iterable,
2158
+ OseoValue *next_method
2159
+ );
2160
+ OseoResult oseo_async_iterator_next(
2161
+ OseoContext *context,
2162
+ OseoValue iterator,
2163
+ OseoValue next_method,
2164
+ OseoValue *value,
2165
+ bool *done
2166
+ );
2167
+ /*
2168
+ * Start one asynchronous iterator step without draining jobs. The returned
2169
+ * value is the operand of the generated traced-frame Await, which owns the
2170
+ * step's sole PromiseResolve. The settled result is inspected through
2171
+ * oseo_async_iterator_result after the frame resumes.
2172
+ */
2173
+ OseoResult oseo_async_iterator_next_start(
2174
+ OseoContext *context,
2175
+ OseoValue iterator,
2176
+ OseoValue next_method
2177
+ );
2178
+ OseoResult oseo_async_iterator_result(
2179
+ OseoContext *context,
2180
+ OseoValue settled,
2181
+ bool value_only,
2182
+ bool value_when_done,
2183
+ OseoValue iterator,
2184
+ bool throw_on_value_only,
2185
+ OseoValue *value,
2186
+ bool *done
2187
+ );
2188
+ OseoResult oseo_async_iterator_close(
2189
+ OseoContext *context,
2190
+ OseoValue iterator,
2191
+ bool from_error
2192
+ );
2193
+ /*
2194
+ * Start and finish AsyncIteratorClose around a traced-frame suspension.
2195
+ * `needs_await` is false when no asynchronous return result exists.
2196
+ * The saved throw mode preserves an in-flight throw. `skip_validation`
2197
+ * is always false: a wrapped synchronous iterator resolves its promise
2198
+ * with a result object whose inherited `then` may fulfill it with a
2199
+ * primitive, so every awaited close result is validated.
2200
+ */
2201
+ OseoResult oseo_async_iterator_close_start(
2202
+ OseoContext *context,
2203
+ OseoValue iterator,
2204
+ bool from_error,
2205
+ OseoValue *skip_validation,
2206
+ bool *needs_await
2207
+ );
2208
+ OseoResult oseo_async_iterator_close_result(
2209
+ OseoContext *context,
2210
+ OseoValue settled,
2211
+ bool ignore_result,
2212
+ bool skip_validation
2213
+ );
2214
+ /*
2215
+ * One `yield*` delegation step over a normal resumption: call the
2216
+ * iterator record's captured next method with `sent`, then read `done`
2217
+ * and `value` from the result. Unlike oseo_iterator_next, `value`
2218
+ * receives IteratorValue even when the result is done, because the
2219
+ * delegating expression reports that value as its own.
2220
+ */
2221
+ OseoResult oseo_iterator_delegate_next(
2222
+ OseoContext *context,
2223
+ OseoValue iterator,
2224
+ OseoValue next_method,
2225
+ OseoValue sent,
2226
+ OseoValue *value,
2227
+ bool *done
2228
+ );
2229
+ /*
2230
+ * One `yield*` delegation step over a return resumption: read the
2231
+ * iterator's `return` method and, when it exists, call it with `sent`
2232
+ * and report the result's `done` and `value`. An iterator with no
2233
+ * `return` method reports done with `sent` itself, which is the return
2234
+ * completion the delegating body then leaves through.
2235
+ */
2236
+ OseoResult oseo_iterator_delegate_return(
2237
+ OseoContext *context,
2238
+ OseoValue iterator,
2239
+ OseoValue sent,
2240
+ OseoValue *value,
2241
+ bool *done
2242
+ );
2243
+ /*
2244
+ * One `yield*` delegation step over a throw resumption: read the
2245
+ * iterator's `throw` method and, when it exists, call it with `sent`
2246
+ * and report the result's `done` and `value`. An iterator with no
2247
+ * `throw` method closes the iterator and throws a TypeError.
2248
+ */
2249
+ OseoResult oseo_iterator_delegate_throw(
2250
+ OseoContext *context,
2251
+ OseoValue iterator,
2252
+ OseoValue sent,
2253
+ OseoValue *value,
2254
+ bool *done
2255
+ );
2256
+ /*
2257
+ * The three delegation steps a `yield*` inside an asynchronous generator
2258
+ * takes. Each awaits the inner iterator's result before reading `done`
2259
+ * and `value`, and each accepts either an asynchronous iterator or the
2260
+ * wrapper `oseo_async_iterator_get` builds over a synchronous one.
2261
+ *
2262
+ * A return step over an iterator with no `return` method reports done
2263
+ * with `sent`, which is the return completion the delegating body then
2264
+ * leaves through. A throw step over an iterator with no `throw` method
2265
+ * closes that iterator and reports a TypeError, because the delegating
2266
+ * body has no way to deliver the throw completion it received.
2267
+ */
2268
+ OseoResult oseo_async_iterator_delegate_next(
2269
+ OseoContext *context,
2270
+ OseoValue iterator,
2271
+ OseoValue next_method,
2272
+ OseoValue sent,
2273
+ OseoValue *value,
2274
+ bool *done
2275
+ );
2276
+ OseoResult oseo_async_iterator_delegate_return(
2277
+ OseoContext *context,
2278
+ OseoValue iterator,
2279
+ OseoValue sent,
2280
+ OseoValue *value,
2281
+ bool *done
2282
+ );
2283
+ OseoResult oseo_async_iterator_delegate_throw(
2284
+ OseoContext *context,
2285
+ OseoValue iterator,
2286
+ OseoValue reason,
2287
+ OseoValue *value,
2288
+ bool *done
2289
+ );
2290
+ /*
2291
+ * Start asynchronous yield-delegation steps without draining jobs. Each
2292
+ * returned value is the operand of the generated traced-frame Await, which
2293
+ * owns the step's sole PromiseResolve. `value_only` is true only when a
2294
+ * native asynchronous iterator has no `return` method and that Await directly
2295
+ * consumes the delivered completion value.
2296
+ */
2297
+ OseoResult oseo_async_iterator_delegate_next_start(
2298
+ OseoContext *context,
2299
+ OseoValue iterator,
2300
+ OseoValue next_method,
2301
+ OseoValue sent,
2302
+ OseoValue *value_only
2303
+ );
2304
+ OseoResult oseo_async_iterator_delegate_return_start(
2305
+ OseoContext *context,
2306
+ OseoValue iterator,
2307
+ OseoValue sent,
2308
+ OseoValue *value_only
2309
+ );
2310
+ OseoResult oseo_async_iterator_delegate_throw_start(
2311
+ OseoContext *context,
2312
+ OseoValue iterator,
2313
+ OseoValue reason,
2314
+ OseoValue *value_only
2315
+ );
2316
+ OseoResult oseo_error_intrinsic(OseoContext *context, OseoErrorKind kind);
2317
+ OseoResult oseo_symbol_intrinsic(OseoContext *context);
2318
+ /*
2319
+ * ResolveThisBinding for a this environment whose [[ThisMode]] is
2320
+ * global. A nullish receiver resolves to the realm's global this value,
2321
+ * which this call creates on first use and then keeps permanently
2322
+ * rooted. Other receivers go through ToObject in the running callee realm:
2323
+ * an object retains its identity and a primitive gets a fresh branded box.
2324
+ * Generated non-strict function entries call this once before parameters
2325
+ * and retain the result as their receiver, including across suspension.
2326
+ * Script top level reaches the global value through its undefined receiver.
2327
+ * The global value is an ordinary extensible object
2328
+ * whose own properties include the standard value properties, its own
2329
+ * `globalThis` self reference, and the var-scoped bindings
2330
+ * `oseo_global_object_create` installed for the running Script.
2331
+ */
2332
+ OseoResult oseo_this_value(OseoContext *context, OseoValue receiver);
2333
+ OseoResult oseo_negate(OseoContext *context, OseoValue value);
2334
+ OseoResult oseo_typeof(OseoContext *context, OseoValue value);
2335
+ OseoResult oseo_bigint_literal(
2336
+ OseoContext *context,
2337
+ const char *digits,
2338
+ uint32_t radix
2339
+ );
2340
+ OseoResult oseo_to_number(OseoContext *context, OseoValue value);
2341
+ OseoResult oseo_to_numeric(OseoContext *context, OseoValue value);
2342
+ OseoResult oseo_numeric_one(OseoContext *context, OseoValue value);
2343
+ OseoResult oseo_to_string(OseoContext *context, OseoValue value);
2344
+ OseoResult oseo_bitwise_not(OseoContext *context, OseoValue value);
2345
+ OseoResult oseo_add(
2346
+ OseoContext *context,
2347
+ OseoValue left,
2348
+ OseoValue right
2349
+ );
2350
+ OseoResult oseo_subtract(
2351
+ OseoContext *context,
2352
+ OseoValue left,
2353
+ OseoValue right
2354
+ );
2355
+ OseoResult oseo_multiply(
2356
+ OseoContext *context,
2357
+ OseoValue left,
2358
+ OseoValue right
2359
+ );
2360
+ OseoResult oseo_divide(
2361
+ OseoContext *context,
2362
+ OseoValue left,
2363
+ OseoValue right
2364
+ );
2365
+ OseoResult oseo_remainder(
2366
+ OseoContext *context,
2367
+ OseoValue left,
2368
+ OseoValue right
2369
+ );
2370
+ OseoResult oseo_exponentiate(
2371
+ OseoContext *context,
2372
+ OseoValue left,
2373
+ OseoValue right
2374
+ );
2375
+ OseoResult oseo_bitwise_and(
2376
+ OseoContext *context,
2377
+ OseoValue left,
2378
+ OseoValue right
2379
+ );
2380
+ OseoResult oseo_bitwise_or(
2381
+ OseoContext *context,
2382
+ OseoValue left,
2383
+ OseoValue right
2384
+ );
2385
+ OseoResult oseo_bitwise_xor(
2386
+ OseoContext *context,
2387
+ OseoValue left,
2388
+ OseoValue right
2389
+ );
2390
+ OseoResult oseo_shift_left(
2391
+ OseoContext *context,
2392
+ OseoValue left,
2393
+ OseoValue right
2394
+ );
2395
+ OseoResult oseo_shift_right(
2396
+ OseoContext *context,
2397
+ OseoValue left,
2398
+ OseoValue right
2399
+ );
2400
+ OseoResult oseo_shift_right_unsigned(
2401
+ OseoContext *context,
2402
+ OseoValue left,
2403
+ OseoValue right
2404
+ );
2405
+ OseoResult oseo_strict_equal(
2406
+ OseoContext *context,
2407
+ OseoValue left,
2408
+ OseoValue right
2409
+ );
2410
+ OseoResult oseo_loose_equal(
2411
+ OseoContext *context,
2412
+ OseoValue left,
2413
+ OseoValue right
2414
+ );
2415
+ OseoResult oseo_not_loose_equal(
2416
+ OseoContext *context,
2417
+ OseoValue left,
2418
+ OseoValue right
2419
+ );
2420
+ OseoResult oseo_has_property(
2421
+ OseoContext *context,
2422
+ OseoValue key,
2423
+ OseoValue object_value
2424
+ );
2425
+ OseoResult oseo_instanceof(
2426
+ OseoContext *context,
2427
+ OseoValue left,
2428
+ OseoValue right
2429
+ );
2430
+ OseoResult oseo_not_strict_equal(
2431
+ OseoContext *context,
2432
+ OseoValue left,
2433
+ OseoValue right
2434
+ );
2435
+ OseoResult oseo_less_than(
2436
+ OseoContext *context,
2437
+ OseoValue left,
2438
+ OseoValue right
2439
+ );
2440
+ OseoResult oseo_less_equal(
2441
+ OseoContext *context,
2442
+ OseoValue left,
2443
+ OseoValue right
2444
+ );
2445
+ OseoResult oseo_greater_than(
2446
+ OseoContext *context,
2447
+ OseoValue left,
2448
+ OseoValue right
2449
+ );
2450
+ OseoResult oseo_greater_equal(
2451
+ OseoContext *context,
2452
+ OseoValue left,
2453
+ OseoValue right
2454
+ );
2455
+ OseoResult oseo_console_log(
2456
+ OseoContext *context,
2457
+ size_t argument_count,
2458
+ const OseoValue *arguments
2459
+ );
2460
+ /*
2461
+ * Installs a module graph's table and performs Evaluate on its entry,
2462
+ * returning the entry's top-level capability promise. The arguments are
2463
+ * the entry index, the module count, and per module its evaluator, a
2464
+ * top-level await flag of 0 or 1, its namespace object or undefined, its
2465
+ * requested module count, and the requested module indices in source
2466
+ * order. An entry index equal to the module count installs the table
2467
+ * without evaluating any module and returns undefined, for a Script
2468
+ * whose `import()` calls are the only requests.
2469
+ */
2470
+ OseoResult oseo_module_graph_evaluate(
2471
+ OseoContext *context,
2472
+ size_t argument_count,
2473
+ const OseoValue *arguments
2474
+ );
2475
+ /*
2476
+ * EvaluateImportCall for one static-specifier `import()` whose target is
2477
+ * the module table entry named by the single argument. Returns a new
2478
+ * promise from the current realm's intrinsic %Promise%; the target is
2479
+ * linked and evaluated only in a later job.
2480
+ */
2481
+ OseoResult oseo_module_import(
2482
+ OseoContext *context,
2483
+ size_t argument_count,
2484
+ const OseoValue *arguments
2485
+ );
2486
+ /*
2487
+ * Performs Evaluate on one installed module table entry and returns its
2488
+ * cycle root's top-level capability promise, creating it when absent.
2489
+ */
2490
+ OseoResult oseo_module_evaluate(OseoContext *context, size_t module_index);
2491
+
2492
+ OseoResult oseo_promise_resolve(
2493
+ OseoContext *context,
2494
+ OseoValue value
2495
+ );
2496
+ OseoResult oseo_promise_all(
2497
+ OseoContext *context,
2498
+ OseoValue iterable
2499
+ );
2500
+ OseoResult oseo_promise_resolve_into(
2501
+ OseoContext *context,
2502
+ OseoValue promise,
2503
+ OseoValue value
2504
+ );
2505
+ OseoResult oseo_promise_reject_into(
2506
+ OseoContext *context,
2507
+ OseoValue promise,
2508
+ OseoValue reason
2509
+ );
2510
+ OseoResult oseo_promise_then(
2511
+ OseoContext *context,
2512
+ OseoValue promise,
2513
+ OseoValue on_fulfilled,
2514
+ OseoValue on_rejected
2515
+ );
2516
+ OseoResult oseo_promise_async_call(
2517
+ OseoContext *context,
2518
+ OseoValue execution
2519
+ );
2520
+ OseoResult oseo_promise_await_then(
2521
+ OseoContext *context,
2522
+ OseoValue promise,
2523
+ OseoValue on_fulfilled
2524
+ );
2525
+ OseoResult oseo_promise_finally(
2526
+ OseoContext *context,
2527
+ OseoValue promise,
2528
+ OseoValue on_finally
2529
+ );
2530
+ OseoPromiseState oseo_promise_state(OseoValue promise);
2531
+ OseoResult oseo_promise_result(
2532
+ OseoContext *context,
2533
+ OseoValue promise
2534
+ );
2535
+ OseoResult oseo_jobs_drain(OseoContext *context);
2536
+ OseoResult oseo_rejection_checkpoint(OseoContext *context);
2537
+ OseoResult oseo_set_timeout(
2538
+ OseoContext *context,
2539
+ size_t argument_count,
2540
+ const OseoValue *arguments
2541
+ );
2542
+ OseoResult oseo_clear_timeout(
2543
+ OseoContext *context,
2544
+ OseoValue handle
2545
+ );
2546
+ OseoResult oseo_entry_task_checkpoint(
2547
+ OseoContext *context,
2548
+ OseoResult completion
2549
+ );
2550
+ OseoResult oseo_event_loop_run(
2551
+ OseoContext *context,
2552
+ OseoValue entry_promise
2553
+ );
2554
+
2555
+ /*
2556
+ * One literal run of an agent source template. The units are the cooked
2557
+ * UTF-16 text between two numeric holes.
2558
+ */
2559
+ typedef struct {
2560
+ const uint16_t *units;
2561
+ size_t length;
2562
+ } OseoAgentSegment;
2563
+
2564
+ /*
2565
+ * The generated evaluation of one agent Script: it installs the program's
2566
+ * dispatchers on an agent realm the runtime already initialized, evaluates
2567
+ * the Script, and runs that agent's event loop, returning the completion.
2568
+ */
2569
+ typedef OseoResult (*OseoAgentEntry)(OseoContext *context);
2570
+
2571
+ /*
2572
+ * One agent program compiled ahead of time from a `$262.agent.start`
2573
+ * source template. `segments` holds `segment_count` literal runs with one
2574
+ * numeric hole between each adjacent pair; `$262.agent.start` evaluates
2575
+ * this program when its source text is exactly those runs around decimal
2576
+ * integer or BigInt literals, and each hole's value is what
2577
+ * `oseo_agent_hole` reads.
2578
+ */
2579
+ typedef struct {
2580
+ const OseoAgentSegment *segments;
2581
+ size_t segment_count;
2582
+ OseoAgentEntry entry;
2583
+ const char *source_id;
2584
+ size_t source_id_length;
2585
+ } OseoAgentProgram;
2586
+
2587
+ /*
2588
+ * Makes this realm the main agent of a new agent cluster and installs the
2589
+ * test262 host object `$262`, whose `agent` property starts the listed
2590
+ * agent programs. Generated code calls it once, after the dispatchers are
2591
+ * set and before the Script evaluates. The table is static generated data
2592
+ * that must outlive the process's agents.
2593
+ */
2594
+ OseoResult oseo_test262_host_install(
2595
+ OseoContext *context,
2596
+ const OseoAgentProgram *programs,
2597
+ size_t program_count
2598
+ );
2599
+ /*
2600
+ * The value of one numeric hole of the running agent program: the Number
2601
+ * or, for a literal with the `n` suffix, the BigInt its source text held.
2602
+ */
2603
+ OseoResult oseo_agent_hole(OseoContext *context, size_t index);
2604
+ /*
2605
+ * Sets an agent program function's source text: `run_count` literal runs
2606
+ * with, between each adjacent pair, the literal text the running agent's
2607
+ * start source held at hole `holes[i]`, so reflection reads the source the
2608
+ * agent was started with.
2609
+ */
2610
+ OseoResult oseo_agent_function_set_source(
2611
+ OseoContext *context,
2612
+ OseoValue function_value,
2613
+ const OseoAgentSegment *runs,
2614
+ size_t run_count,
2615
+ const size_t *holes
2616
+ );
2617
+
2618
+ #endif