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

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