@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,624 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /* Copyright (c) 2026 Hong Minhee; see ../MIT-LICENSE.txt. */
3
+
4
+ #include "runtime_internal.h"
5
+
6
+ #include <string.h>
7
+
8
+ /*
9
+ * The Reflect namespace object of 28.1: the thirteen function
10
+ * properties that expose one essential internal method each, and the
11
+ * @@toStringTag value property. Reflect is an ordinary object, not a
12
+ * function, so it has neither [[Call]] nor [[Construct]], and its
13
+ * function properties are ordinary built-in functions that are not
14
+ * constructors either.
15
+ *
16
+ * Every function here requires an object target and reports the
17
+ * specification's boolean instead of raising the language error the
18
+ * matching `Object` static raises. The refusal rules stay in the
19
+ * descriptor, property, and object components, which report a refusal
20
+ * through a message the throwing forms turn back into a TypeError.
21
+ */
22
+
23
+ /*
24
+ * One Reflect function property. The array order is the order the
25
+ * namespace object creates its properties in and the order the code IDs
26
+ * count down from `OSEO_REFLECT_FUNCTION_CODE_ID_LAST`, so an entry's
27
+ * index is the only identity the builder and the dispatcher share.
28
+ */
29
+ typedef enum {
30
+ OSEO_REFLECT_APPLY = 0,
31
+ OSEO_REFLECT_CONSTRUCT = 1,
32
+ OSEO_REFLECT_DEFINE_PROPERTY = 2,
33
+ OSEO_REFLECT_DELETE_PROPERTY = 3,
34
+ OSEO_REFLECT_GET = 4,
35
+ OSEO_REFLECT_GET_OWN_PROPERTY_DESCRIPTOR = 5,
36
+ OSEO_REFLECT_GET_PROTOTYPE_OF = 6,
37
+ OSEO_REFLECT_HAS = 7,
38
+ OSEO_REFLECT_IS_EXTENSIBLE = 8,
39
+ OSEO_REFLECT_OWN_KEYS = 9,
40
+ OSEO_REFLECT_PREVENT_EXTENSIONS = 10,
41
+ OSEO_REFLECT_SET = 11,
42
+ OSEO_REFLECT_SET_PROTOTYPE_OF = 12,
43
+ } OseoReflectOperation;
44
+
45
+ typedef struct {
46
+ const char *name;
47
+ size_t length;
48
+ } OseoReflectFunction;
49
+
50
+ static const OseoReflectFunction reflect_functions[] = {
51
+ {"apply", 3u},
52
+ {"construct", 2u},
53
+ {"defineProperty", 3u},
54
+ {"deleteProperty", 2u},
55
+ {"get", 2u},
56
+ {"getOwnPropertyDescriptor", 2u},
57
+ {"getPrototypeOf", 1u},
58
+ {"has", 2u},
59
+ {"isExtensible", 1u},
60
+ {"ownKeys", 1u},
61
+ {"preventExtensions", 1u},
62
+ {"set", 3u},
63
+ {"setPrototypeOf", 2u},
64
+ };
65
+
66
+ _Static_assert(
67
+ sizeof(reflect_functions) / sizeof(reflect_functions[0]) ==
68
+ OSEO_REFLECT_FUNCTION_COUNT,
69
+ "The Reflect function table must match its reviewed code-ID range."
70
+ );
71
+
72
+ static OseoValue reflect_argument(
73
+ size_t argument_count,
74
+ const OseoValue *arguments,
75
+ size_t index
76
+ ) {
77
+ return index < argument_count ? arguments[index] : oseo_undefined();
78
+ }
79
+
80
+ static OseoResult type_error(OseoContext *context, const char *message) {
81
+ return oseo_internal_throw_error(context, OSEO_ERROR_TYPE, message);
82
+ }
83
+
84
+ /*
85
+ * The shared first step of every Reflect function but `apply` and
86
+ * `construct`: a target that is not an object is a TypeError rather
87
+ * than a coercion or a `false` result. `reflect_call` applies it once
88
+ * for all eleven, so no individual body repeats it.
89
+ */
90
+ static OseoResult reflect_object_target(
91
+ OseoContext *context,
92
+ OseoValue target
93
+ ) {
94
+ if (is_object(target)) return normal(target);
95
+ return type_error(context, "A Reflect target must be an object.");
96
+ }
97
+
98
+ /* Reflect.apply(target, thisArgument, argumentsList). */
99
+ static OseoResult reflect_apply(
100
+ OseoContext *context,
101
+ size_t argument_count,
102
+ const OseoValue *arguments
103
+ ) {
104
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
105
+ if (!is_callable(target)) {
106
+ return type_error(context, "Reflect.apply requires a callable target.");
107
+ }
108
+ OseoValue slots[4] = {
109
+ target,
110
+ reflect_argument(argument_count, arguments, 1u),
111
+ reflect_argument(argument_count, arguments, 2u),
112
+ oseo_undefined(),
113
+ };
114
+ OseoRootFrame frame = {NULL, slots, 4u};
115
+ oseo_roots_push(context, &frame);
116
+ OseoResult result = oseo_internal_array_like_list(
117
+ context,
118
+ slots[2],
119
+ &slots[3]
120
+ );
121
+ size_t forwarded_count = 0u;
122
+ const OseoValue *forwarded = NULL;
123
+ if (result.status == OSEO_STATUS_NORMAL) {
124
+ result = oseo_argument_list_view(
125
+ context,
126
+ slots[3],
127
+ &forwarded_count,
128
+ &forwarded
129
+ );
130
+ }
131
+ /* Reflect.apply step 3 performs PrepareForTailCall. */
132
+ if (result.status == OSEO_STATUS_NORMAL) {
133
+ result = oseo_internal_tail_call(
134
+ context,
135
+ slots[0],
136
+ slots[1],
137
+ forwarded_count,
138
+ forwarded
139
+ );
140
+ }
141
+ oseo_roots_pop(context, &frame);
142
+ return result;
143
+ }
144
+
145
+ /* Reflect.construct(target, argumentsList [, newTarget]). */
146
+ static OseoResult reflect_construct(
147
+ OseoContext *context,
148
+ size_t argument_count,
149
+ const OseoValue *arguments
150
+ ) {
151
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
152
+ if (!function_is_constructible(target)) {
153
+ return type_error(
154
+ context,
155
+ "Reflect.construct requires a constructor target."
156
+ );
157
+ }
158
+ OseoValue new_target = argument_count > 2u ? arguments[2] : target;
159
+ if (!function_is_constructible(new_target)) {
160
+ return type_error(
161
+ context,
162
+ "Reflect.construct requires a constructor new target."
163
+ );
164
+ }
165
+ /*
166
+ * Slots: 0 target, 1 new target, 2 the array-like source, 3 the
167
+ * collected argument list, 4 the receiver
168
+ * OrdinaryCreateFromConstructor builds from the new target's
169
+ * `prototype`, undefined when the target's own clause creates it.
170
+ */
171
+ OseoValue slots[5] = {
172
+ target,
173
+ new_target,
174
+ reflect_argument(argument_count, arguments, 1u),
175
+ oseo_undefined(),
176
+ oseo_undefined(),
177
+ };
178
+ OseoRootFrame frame = {NULL, slots, 5u};
179
+ oseo_roots_push(context, &frame);
180
+ OseoResult result = oseo_internal_array_like_list(
181
+ context,
182
+ slots[2],
183
+ &slots[3]
184
+ );
185
+ if (result.status == OSEO_STATUS_NORMAL) {
186
+ /* OrdinaryCreateFromConstructor on the target's behalf, which
187
+ * reads nothing and creates nothing when the target is a
188
+ * derived class constructor, because its own `super()` does
189
+ * both once the body reaches it. */
190
+ result = oseo_internal_construct_receiver(
191
+ context,
192
+ slots[0],
193
+ slots[1]
194
+ );
195
+ slots[4] = result.value;
196
+ }
197
+ size_t forwarded_count = 0u;
198
+ const OseoValue *forwarded = NULL;
199
+ if (result.status == OSEO_STATUS_NORMAL) {
200
+ result = oseo_argument_list_view(
201
+ context,
202
+ slots[3],
203
+ &forwarded_count,
204
+ &forwarded
205
+ );
206
+ }
207
+ if (result.status == OSEO_STATUS_NORMAL) {
208
+ result = oseo_call_function(
209
+ context,
210
+ slots[0],
211
+ slots[4],
212
+ forwarded_count,
213
+ forwarded,
214
+ slots[1]
215
+ );
216
+ }
217
+ if (result.status == OSEO_STATUS_NORMAL) {
218
+ result = oseo_constructor_result(context, result.value, slots[4]);
219
+ }
220
+ oseo_roots_pop(context, &frame);
221
+ return result;
222
+ }
223
+
224
+ /* Reflect.defineProperty(target, propertyKey, attributes). */
225
+ static OseoResult reflect_define_property(
226
+ OseoContext *context,
227
+ size_t argument_count,
228
+ const OseoValue *arguments
229
+ ) {
230
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
231
+ OseoValue slots[3] = {
232
+ target,
233
+ reflect_argument(argument_count, arguments, 2u),
234
+ oseo_undefined(),
235
+ };
236
+ OseoRootFrame frame = {NULL, slots, 3u};
237
+ oseo_roots_push(context, &frame);
238
+ OseoResult result = oseo_property_key(
239
+ context,
240
+ reflect_argument(argument_count, arguments, 1u)
241
+ );
242
+ slots[2] = result.value;
243
+ const char *refusal = NULL;
244
+ if (result.status == OSEO_STATUS_NORMAL) {
245
+ result = oseo_internal_define_from_descriptor(
246
+ context,
247
+ slots[0],
248
+ slots[2],
249
+ slots[1],
250
+ &refusal
251
+ );
252
+ }
253
+ if (result.status == OSEO_STATUS_NORMAL) {
254
+ result = normal(oseo_boolean(refusal == NULL));
255
+ }
256
+ oseo_roots_pop(context, &frame);
257
+ return result;
258
+ }
259
+
260
+ /* Reflect.deleteProperty(target, propertyKey). */
261
+ static OseoResult reflect_delete_property(
262
+ OseoContext *context,
263
+ size_t argument_count,
264
+ const OseoValue *arguments
265
+ ) {
266
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
267
+ OseoValue slots[2] = {target, oseo_undefined()};
268
+ OseoRootFrame frame = {NULL, slots, 2u};
269
+ oseo_roots_push(context, &frame);
270
+ OseoResult result = oseo_property_key(
271
+ context,
272
+ reflect_argument(argument_count, arguments, 1u)
273
+ );
274
+ slots[1] = result.value;
275
+ if (result.status == OSEO_STATUS_NORMAL) {
276
+ /* The non-strict delete is the one that reports the
277
+ * specification's boolean instead of raising a TypeError. */
278
+ result = oseo_object_delete(context, slots[0], slots[1], false);
279
+ }
280
+ oseo_roots_pop(context, &frame);
281
+ return result;
282
+ }
283
+
284
+ /* Reflect.get(target, propertyKey [, receiver]). */
285
+ static OseoResult reflect_get(
286
+ OseoContext *context,
287
+ size_t argument_count,
288
+ const OseoValue *arguments
289
+ ) {
290
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
291
+ OseoValue slots[3] = {
292
+ target,
293
+ argument_count > 2u ? arguments[2] : target,
294
+ oseo_undefined(),
295
+ };
296
+ OseoRootFrame frame = {NULL, slots, 3u};
297
+ oseo_roots_push(context, &frame);
298
+ OseoResult result = oseo_property_key(
299
+ context,
300
+ reflect_argument(argument_count, arguments, 1u)
301
+ );
302
+ slots[2] = result.value;
303
+ if (result.status == OSEO_STATUS_NORMAL) {
304
+ result = oseo_super_get(context, slots[0], slots[2], slots[1]);
305
+ }
306
+ oseo_roots_pop(context, &frame);
307
+ return result;
308
+ }
309
+
310
+ /* Reflect.set(target, propertyKey, V [, receiver]). */
311
+ static OseoResult reflect_set(
312
+ OseoContext *context,
313
+ size_t argument_count,
314
+ const OseoValue *arguments
315
+ ) {
316
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
317
+ OseoValue slots[4] = {
318
+ target,
319
+ reflect_argument(argument_count, arguments, 2u),
320
+ argument_count > 3u ? arguments[3] : target,
321
+ oseo_undefined(),
322
+ };
323
+ OseoRootFrame frame = {NULL, slots, 4u};
324
+ oseo_roots_push(context, &frame);
325
+ OseoResult result = oseo_property_key(
326
+ context,
327
+ reflect_argument(argument_count, arguments, 1u)
328
+ );
329
+ slots[3] = result.value;
330
+ const char *refusal = NULL;
331
+ if (result.status == OSEO_STATUS_NORMAL) {
332
+ result = oseo_internal_set_with_receiver(
333
+ context,
334
+ slots[0],
335
+ slots[3],
336
+ slots[1],
337
+ slots[2],
338
+ &refusal
339
+ );
340
+ }
341
+ if (result.status == OSEO_STATUS_NORMAL) {
342
+ result = normal(oseo_boolean(refusal == NULL));
343
+ }
344
+ oseo_roots_pop(context, &frame);
345
+ return result;
346
+ }
347
+
348
+ /* Reflect.setPrototypeOf(target, proto). */
349
+ static OseoResult reflect_set_prototype_of(
350
+ OseoContext *context,
351
+ size_t argument_count,
352
+ const OseoValue *arguments
353
+ ) {
354
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
355
+ OseoValue prototype = reflect_argument(argument_count, arguments, 1u);
356
+ if (tag_of(prototype) != OSEO_TAG_NULL && !is_object(prototype)) {
357
+ return type_error(
358
+ context,
359
+ "Reflect.setPrototypeOf requires an object or null prototype."
360
+ );
361
+ }
362
+ const char *refusal = NULL;
363
+ OseoResult result = oseo_internal_set_prototype_reported(
364
+ context,
365
+ target,
366
+ prototype,
367
+ &refusal
368
+ );
369
+ if (result.status != OSEO_STATUS_NORMAL) return result;
370
+ return normal(oseo_boolean(refusal == NULL));
371
+ }
372
+
373
+ static OseoResult reflect_call(
374
+ OseoContext *context,
375
+ size_t operation,
376
+ size_t argument_count,
377
+ const OseoValue *arguments
378
+ ) {
379
+ if (operation == OSEO_REFLECT_APPLY) {
380
+ return reflect_apply(context, argument_count, arguments);
381
+ }
382
+ if (operation == OSEO_REFLECT_CONSTRUCT) {
383
+ return reflect_construct(context, argument_count, arguments);
384
+ }
385
+ /* The eleven remaining functions share one first step: an object
386
+ * target, checked before any key or descriptor conversion. */
387
+ OseoValue target = reflect_argument(argument_count, arguments, 0u);
388
+ OseoResult checked = reflect_object_target(context, target);
389
+ if (checked.status != OSEO_STATUS_NORMAL) return checked;
390
+ switch (operation) {
391
+ case OSEO_REFLECT_DEFINE_PROPERTY:
392
+ return reflect_define_property(context, argument_count, arguments);
393
+ case OSEO_REFLECT_DELETE_PROPERTY:
394
+ return reflect_delete_property(context, argument_count, arguments);
395
+ case OSEO_REFLECT_GET:
396
+ return reflect_get(context, argument_count, arguments);
397
+ case OSEO_REFLECT_SET:
398
+ return reflect_set(context, argument_count, arguments);
399
+ case OSEO_REFLECT_SET_PROTOTYPE_OF:
400
+ return reflect_set_prototype_of(
401
+ context,
402
+ argument_count,
403
+ arguments
404
+ );
405
+ case OSEO_REFLECT_GET_OWN_PROPERTY_DESCRIPTOR:
406
+ return oseo_object_builtin_get_own_property_descriptor(
407
+ context,
408
+ argument_count,
409
+ arguments
410
+ );
411
+ case OSEO_REFLECT_GET_PROTOTYPE_OF:
412
+ return oseo_internal_get_prototype(context, target);
413
+ case OSEO_REFLECT_HAS: {
414
+ OseoValue slots[2] = {target, oseo_undefined()};
415
+ OseoRootFrame frame = {NULL, slots, 2u};
416
+ oseo_roots_push(context, &frame);
417
+ OseoResult result = oseo_property_key(
418
+ context,
419
+ reflect_argument(argument_count, arguments, 1u)
420
+ );
421
+ slots[1] = result.value;
422
+ if (result.status == OSEO_STATUS_NORMAL) {
423
+ result = oseo_has_property(context, slots[1], slots[0]);
424
+ }
425
+ oseo_roots_pop(context, &frame);
426
+ return result;
427
+ }
428
+ case OSEO_REFLECT_IS_EXTENSIBLE:
429
+ return oseo_internal_is_extensible(context, target);
430
+ case OSEO_REFLECT_OWN_KEYS:
431
+ return oseo_internal_own_key_array(
432
+ context,
433
+ target,
434
+ OSEO_OWN_KEY_ALL
435
+ );
436
+ case OSEO_REFLECT_PREVENT_EXTENSIONS:
437
+ {
438
+ const char *refusal = NULL;
439
+ OseoResult result = oseo_internal_prevent_extensions_reported(
440
+ context, target, &refusal);
441
+ if (result.status != OSEO_STATUS_NORMAL) return result;
442
+ return normal(oseo_boolean(refusal == NULL));
443
+ }
444
+ default: break;
445
+ }
446
+ return failure(context, "OSEO2001", "Unknown Reflect operation.");
447
+ }
448
+
449
+ OseoResult oseo_internal_reflect_builtin_dispatch(
450
+ OseoContext *context,
451
+ size_t code_id,
452
+ OseoValue callee,
453
+ OseoValue receiver,
454
+ size_t argument_count,
455
+ const OseoValue *arguments,
456
+ OseoValue new_target
457
+ ) {
458
+ (void)callee;
459
+ (void)receiver;
460
+ if (code_id < OSEO_REFLECT_FUNCTION_CODE_ID_FIRST ||
461
+ code_id > OSEO_REFLECT_FUNCTION_CODE_ID_LAST) {
462
+ return oseo_unknown_function(context, code_id);
463
+ }
464
+ if (tag_of(new_target) != OSEO_TAG_UNDEFINED) {
465
+ return type_error(context, "Reflect method is not a constructor.");
466
+ }
467
+ size_t operation = OSEO_REFLECT_FUNCTION_CODE_ID_LAST - code_id;
468
+ return reflect_call(context, operation, argument_count, arguments);
469
+ }
470
+
471
+ /* One Reflect function property, created without a `prototype`. */
472
+ static OseoResult create_reflect_function(
473
+ OseoContext *context,
474
+ size_t operation
475
+ ) {
476
+ const OseoReflectFunction *entry = &reflect_functions[operation];
477
+ size_t name_length = strlen(entry->name);
478
+ uint16_t units[32];
479
+ if (name_length > sizeof(units) / sizeof(*units)) {
480
+ return failure(context, "OSEO2001", "Built-in name is too long.");
481
+ }
482
+ for (size_t index = 0u; index < name_length; index += 1u) {
483
+ units[index] = (uint16_t)(unsigned char)entry->name[index];
484
+ }
485
+ OseoValue environment = oseo_undefined();
486
+ OseoRootFrame frame = {NULL, &environment, 1u};
487
+ oseo_roots_push(context, &frame);
488
+ OseoResult result = oseo_environment_create(context, 0u);
489
+ environment = result.value;
490
+ if (result.status == OSEO_STATUS_NORMAL) {
491
+ result = oseo_function_create(
492
+ context,
493
+ OSEO_REFLECT_FUNCTION_CODE_ID_LAST - operation,
494
+ environment,
495
+ units,
496
+ name_length,
497
+ entry->length,
498
+ OSEO_FUNCTION_INTERNAL,
499
+ oseo_undefined(),
500
+ oseo_undefined(),
501
+ OSEO_FUNCTION_NAME_PREFIX_NONE
502
+ );
503
+ }
504
+ oseo_roots_pop(context, &frame);
505
+ return result;
506
+ }
507
+
508
+ static OseoResult define_reflect_property(
509
+ OseoContext *context,
510
+ OseoValue object,
511
+ OseoValue key,
512
+ OseoValue value,
513
+ OseoPropertyAttributes attributes
514
+ ) {
515
+ OseoValue slots[3] = {object, key, value};
516
+ OseoRootFrame frame = {NULL, slots, 3u};
517
+ oseo_roots_push(context, &frame);
518
+ OseoResult result = oseo_object_define(
519
+ context,
520
+ slots[0],
521
+ slots[1],
522
+ slots[2],
523
+ attributes
524
+ );
525
+ oseo_roots_pop(context, &frame);
526
+ return result;
527
+ }
528
+
529
+ OseoResult oseo_internal_reflect_intrinsic(OseoContext *context) {
530
+ OseoValue *slot = &context->realm->intrinsics[OSEO_INTRINSIC_REFLECT];
531
+ if (is_object(*slot)) return normal(*slot);
532
+ size_t entry_allocations = context->allocations;
533
+ OseoRootFrame frame = {NULL, NULL, 0u};
534
+ OseoResult result = oseo_roots_allocate(context, &frame, 3u);
535
+ if (result.status != OSEO_STATUS_NORMAL) return result;
536
+ result = oseo_internal_intrinsic(
537
+ context,
538
+ OSEO_INTRINSIC_OBJECT_PROTOTYPE
539
+ );
540
+ frame.slots[0] = result.value;
541
+ if (result.status == OSEO_STATUS_NORMAL) {
542
+ result = oseo_object_create(context, frame.slots[0]);
543
+ frame.slots[0] = result.value;
544
+ }
545
+ if (result.status == OSEO_STATUS_NORMAL) {
546
+ *slot = frame.slots[0];
547
+ }
548
+ static const OseoPropertyAttributes method_attributes =
549
+ {true, false, true, false};
550
+ for (size_t index = 0u;
551
+ result.status == OSEO_STATUS_NORMAL &&
552
+ index < OSEO_REFLECT_FUNCTION_COUNT;
553
+ index += 1u) {
554
+ result = create_reflect_function(context, index);
555
+ frame.slots[1] = result.value;
556
+ if (result.status != OSEO_STATUS_NORMAL) break;
557
+ result = oseo_internal_ascii_string(
558
+ context,
559
+ reflect_functions[index].name
560
+ );
561
+ frame.slots[2] = result.value;
562
+ if (result.status != OSEO_STATUS_NORMAL) break;
563
+ result = define_reflect_property(
564
+ context,
565
+ frame.slots[0],
566
+ frame.slots[2],
567
+ frame.slots[1],
568
+ method_attributes
569
+ );
570
+ }
571
+ if (result.status == OSEO_STATUS_NORMAL) {
572
+ result = oseo_internal_well_known_symbol(
573
+ context,
574
+ OSEO_WELL_KNOWN_TO_STRING_TAG
575
+ );
576
+ frame.slots[1] = result.value;
577
+ }
578
+ if (result.status == OSEO_STATUS_NORMAL) {
579
+ result = oseo_internal_ascii_string(context, "Reflect");
580
+ frame.slots[2] = result.value;
581
+ }
582
+ if (result.status == OSEO_STATUS_NORMAL) {
583
+ result = define_reflect_property(
584
+ context,
585
+ frame.slots[0],
586
+ frame.slots[1],
587
+ frame.slots[2],
588
+ (OseoPropertyAttributes){true, false, false, false}
589
+ );
590
+ }
591
+ if (result.status != OSEO_STATUS_NORMAL) {
592
+ *slot = oseo_undefined();
593
+ } else if (context->observe_specialization) {
594
+ context->allocations = entry_allocations;
595
+ }
596
+ oseo_roots_release(context, &frame);
597
+ return result.status == OSEO_STATUS_NORMAL ? normal(*slot) : result;
598
+ }
599
+
600
+ OseoResult oseo_internal_install_reflect_global(
601
+ OseoContext *context,
602
+ OseoValue global
603
+ ) {
604
+ OseoValue slots[3] = {global, oseo_undefined(), oseo_undefined()};
605
+ OseoRootFrame frame = {NULL, slots, 3u};
606
+ oseo_roots_push(context, &frame);
607
+ OseoResult result = oseo_internal_reflect_intrinsic(context);
608
+ slots[1] = result.value;
609
+ if (result.status == OSEO_STATUS_NORMAL) {
610
+ result = oseo_internal_ascii_string(context, "Reflect");
611
+ slots[2] = result.value;
612
+ }
613
+ if (result.status == OSEO_STATUS_NORMAL) {
614
+ result = oseo_object_define(
615
+ context,
616
+ slots[0],
617
+ slots[2],
618
+ slots[1],
619
+ (OseoPropertyAttributes){true, false, true, false}
620
+ );
621
+ }
622
+ oseo_roots_pop(context, &frame);
623
+ return result.status == OSEO_STATUS_NORMAL ? normal(slots[0]) : result;
624
+ }