@scriptc/runtime 0.0.11 → 0.0.12
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.
- package/package.json +1 -1
- package/src/scr_assert.c +13 -13
- package/src/scr_async.c +5 -5
- package/src/scr_async_dyn.c +24 -24
- package/src/scr_bytes_io.c +5 -5
- package/src/scr_dc.c +8 -8
- package/src/scr_dgram.c +1 -1
- package/src/scr_dyn_handle.c +5 -5
- package/src/scr_dyn_invoke.c +15 -15
- package/src/scr_error.c +3 -3
- package/src/scr_events_emitter.c +1 -1
- package/src/scr_http.c +4 -4
- package/src/scr_http2.c +3 -3
- package/src/scr_inspect.c +3 -3
- package/src/scr_island.c +134 -25
- package/src/scr_json.c +103 -68
- package/src/scr_net.c +1 -1
- package/src/scr_qs.c +1 -1
- package/src/scr_runtime.h +144 -118
- package/src/scr_stream.c +4 -4
- package/src/scr_tls.c +3 -3
- package/src/scr_web.c +1 -1
package/src/scr_runtime.h
CHANGED
|
@@ -397,7 +397,7 @@ enum {
|
|
|
397
397
|
|
|
398
398
|
extern ScrVt scr_error_vts[5]; /* indexed by SCR_ERR_*; main() stamps pre/post */
|
|
399
399
|
|
|
400
|
-
struct ScrDyn; /* full declaration below (the
|
|
400
|
+
struct ScrDyn; /* full declaration below (the checked-dynamic tree section) */
|
|
401
401
|
|
|
402
402
|
/* DOMException: the ScrError prefix (identical member order — an upcast is
|
|
403
403
|
* a pointer reinterpret) plus the WebIDL slots. The extra slots are HIDDEN
|
|
@@ -415,11 +415,11 @@ typedef struct ScrDomException {
|
|
|
415
415
|
struct ScrDyn *cause; /* owned; NULL when has_cause is false */
|
|
416
416
|
} ScrDomException;
|
|
417
417
|
|
|
418
|
-
/* new DOMException(message?, nameOrOptions?) — both
|
|
419
|
-
* NULL-tolerant (NULL = absent = the
|
|
420
|
-
* throws (
|
|
418
|
+
/* new DOMException(message?, nameOrOptions?) — both dyn args borrowed,
|
|
419
|
+
* NULL-tolerant (NULL = absent = the dyn undefined). Returns +1. Never
|
|
420
|
+
* throws (dyn ToString is total). Lives in scr_json.c (the args are dyn
|
|
421
421
|
* values); the dyn-free half below stays in scr_error.c so the error
|
|
422
|
-
* unit links without the
|
|
422
|
+
* unit links without the checked-dynamic tree. */
|
|
423
423
|
ScrError *scr_domex_new(const struct ScrDyn *message, const struct ScrDyn *name_or_options);
|
|
424
424
|
/* scr_error.c's dyn-free DOMException half: the blank allocation the
|
|
425
425
|
* constructors fill, the WebIDL name→legacy-code table, and the cause
|
|
@@ -429,7 +429,7 @@ double scr_domex_code_of(const ScrStr *name);
|
|
|
429
429
|
void scr_domex_install_cause_drop(void (*fn)(void *obj));
|
|
430
430
|
double scr_domex_code(ScrError *e); /* borrowed receiver */
|
|
431
431
|
bool scr_domex_has_cause(ScrError *e); /* borrowed receiver */
|
|
432
|
-
struct ScrDyn *scr_domex_cause(ScrError *e); /* +1 (
|
|
432
|
+
struct ScrDyn *scr_domex_cause(ScrError *e); /* +1 (dyn undefined when absent) */
|
|
433
433
|
/* structuredClone of a DOMException: WebIDL serialization — name/message
|
|
434
434
|
* copy, the code re-derives, cause does not serialize. Borrowed receiver
|
|
435
435
|
* and options (validated; throws on bad options / non-empty transfer).
|
|
@@ -672,9 +672,9 @@ void scr_qs_parse_into(ScrMap *out, const ScrStr *qs, const ScrStr *sep,
|
|
|
672
672
|
const ScrStr *eq, double max_keys, uint32_t str_tag,
|
|
673
673
|
uint32_t arr_tag);
|
|
674
674
|
|
|
675
|
-
/* querystring.stringify — Node's stringify over a borrowed
|
|
675
|
+
/* querystring.stringify — Node's stringify over a borrowed dyn value (the
|
|
676
676
|
* frontend dynFroms the typed record; JS-world dyn values pass straight
|
|
677
|
-
* through). Non-object
|
|
677
|
+
* through). Non-object dyn values answer "" like Node; object keys iterate in
|
|
678
678
|
* JS own-key order (scr_dyn_obj_keys — array-index keys ascending first,
|
|
679
679
|
* then insertion order, Node's ObjectKeys). Values serialize per Node's
|
|
680
680
|
* encodeStringified: strings escape, finite numbers render shortest-
|
|
@@ -692,8 +692,8 @@ ScrStr *scr_qs_stringify(const struct ScrDyn *obj, const ScrStr *sep,
|
|
|
692
692
|
* well-formed-UTF-8 invariant. Borrows s; result +1. */
|
|
693
693
|
ScrStr *scr_encode_uri(ScrStr *s);
|
|
694
694
|
/* atob/btoa — the WHATWG base64 globals (Node globals since v16). The
|
|
695
|
-
* argument is a borrowed
|
|
696
|
-
*
|
|
695
|
+
* argument is a borrowed dyn value: WebIDL ToString runs here over the
|
|
696
|
+
* dyn kind (Node's atob(null) decodes "null"). scr_atob decodes
|
|
697
697
|
* forgiving-base64 (ASCII whitespace stripped, %4==0 strips up to two
|
|
698
698
|
* '=', %4==1 refuses, leftover bits discarded) into the latin1 code
|
|
699
699
|
* points as a UTF-8 string; malformed input THROWS the catchable
|
|
@@ -1558,7 +1558,7 @@ void scr_stream_st_trace(ScrStreamState *st, ScrTraceVisit visit, void *ctx);
|
|
|
1558
1558
|
/* The dyn-flavored completion-callback glues (the JS lane's implicitly-
|
|
1559
1559
|
* any option callbacks / underscore methods): the emitted invoke thunks
|
|
1560
1560
|
* mint a callable dyn (scr_dyn_new_func) over a 1-cap closure boxing the
|
|
1561
|
-
* retained stream, with the kind's glue — arguments arrive as
|
|
1561
|
+
* retained stream, with the kind's glue — arguments arrive as dyn
|
|
1562
1562
|
* values (error: null/undefined, a {message} object, or a string;
|
|
1563
1563
|
* transform/flush data: bytes, a string, or absent). */
|
|
1564
1564
|
typedef struct ScrDyn ScrDyn; /* full declaration below (C11 repeat) */
|
|
@@ -1809,7 +1809,7 @@ ScrStr *scr_caught_to_string(const ScrCaught *c);
|
|
|
1809
1809
|
* checks. */
|
|
1810
1810
|
void *scr_caught_check_obj(const ScrCaught *c, size_t pre, size_t post,
|
|
1811
1811
|
const char *cls);
|
|
1812
|
-
/* The snapshot as a
|
|
1812
|
+
/* The snapshot as a dyn value (scr_json.c): identity-preserving for dyn
|
|
1813
1813
|
* payloads and %Error instances, scalars by value, the type-erased empty
|
|
1814
1814
|
* object for the rest (SEMANTICS.md 67). Borrows the box; +1. */
|
|
1815
1815
|
typedef struct ScrDyn ScrDyn; /* full definition below (C11 repeat) */
|
|
@@ -2062,7 +2062,7 @@ ScrPromise *scr_tp_set_immediate(void);
|
|
|
2062
2062
|
* A process-global name→channel registry; channel handles are 1-based
|
|
2063
2063
|
* f64 indexes into it (Node's channels are process-lived too, its
|
|
2064
2064
|
* WeakRef machinery aside — the registry tears down atexit before the
|
|
2065
|
-
* RC audit). Subscribers are
|
|
2065
|
+
* RC audit). Subscribers are dyn FUNCTION values, identity-matched by
|
|
2066
2066
|
* unsubscribe (the underlying closure, so re-boxings of one function
|
|
2067
2067
|
* still match — JS has ONE function object). publish calls each
|
|
2068
2068
|
* subscriber of a SNAPSHOT with (message, name); a subscriber's throw
|
|
@@ -2086,8 +2086,8 @@ ScrStr *scr_dc_chan_name(double handle);
|
|
|
2086
2086
|
* handlers object's five event keys (truthy slots route to the per-channel
|
|
2087
2087
|
* add/remove — a non-function slot throws there, Node's order);
|
|
2088
2088
|
* unsubscribe answers Node's all-found conjunction. traceSync/traceCallback
|
|
2089
|
-
* mirror Node's publish choreography over the
|
|
2090
|
-
* lowering builds the default `{}`), fn/thisArg/args are
|
|
2089
|
+
* mirror Node's publish choreography over the checked-dynamic tree: ctx must be an OBJ (the
|
|
2090
|
+
* lowering builds the default `{}`), fn/thisArg/args are dyn values (args
|
|
2091
2091
|
* an ARR of the call arguments); the traced call binds thisArg as the
|
|
2092
2092
|
* ambient receiver; result/error stamp onto ctx before end/error publish;
|
|
2093
2093
|
* a traced throw and a subscriber throw both propagate (MAY THROW). All
|
|
@@ -2553,15 +2553,15 @@ double scr_os_ifaddrs_scopeid(const ScrIfaddrs *s, size_t i);
|
|
|
2553
2553
|
void scr_os_ifaddrs_free(ScrIfaddrs *s);
|
|
2554
2554
|
|
|
2555
2555
|
/* ── JSON + dynamic values (scr_json.c) ─────────────────────────────
|
|
2556
|
-
* A dyn value — the compiled form of `unknown` — is a refcounted JSON
|
|
2556
|
+
* A dyn value — the compiled form of `unknown` — is a refcounted JSON dyn
|
|
2557
2557
|
* tree: the result of JSON.parse, inert until a CHECKED CAST validates it
|
|
2558
2558
|
* against a static type. The compiler emits the validation walkers
|
|
2559
2559
|
* (sc_dc_* builders / sc_dm_* match predicates) and the type-directed
|
|
2560
2560
|
* stringify serializers (sc_jw_*) per program; this runtime slice provides
|
|
2561
|
-
* the
|
|
2561
|
+
* the checked-dynamic tree itself, the RFC 8259 parser, the shared failure path
|
|
2562
2562
|
* (scr_dyn_check_fail), and the output buffer the serializers append to.
|
|
2563
2563
|
*
|
|
2564
|
-
* Ownership: the
|
|
2564
|
+
* Ownership: the checked-dynamic tree owns its children (strings, items, entry keys+values);
|
|
2565
2565
|
* releasing the root releases the tree recursively. scr_json_parse borrows
|
|
2566
2566
|
* the text and returns +1 — or THROWS a catchable string shaped like Node's
|
|
2567
2567
|
* V8 messages ("Unexpected end of JSON input"; approximate fidelity, see
|
|
@@ -2577,15 +2577,15 @@ typedef enum {
|
|
|
2577
2577
|
SCR_DYN_ARR,
|
|
2578
2578
|
SCR_DYN_OBJ,
|
|
2579
2579
|
/* The undefined VALUE. Never produced by the parser (JSON text has no
|
|
2580
|
-
* undefined) — it enters the
|
|
2580
|
+
* undefined) — it enters the checked-dynamic tree through index-signature overflow reads
|
|
2581
2581
|
* (a missing key), optional-chain unit paths on dyn results, and the
|
|
2582
|
-
* compiler's static→
|
|
2582
|
+
* compiler's static→dyn converters (an undefined-armed union's unit
|
|
2583
2583
|
* arm). One immortal instance (scr_dyn_undefined); JSON serialization
|
|
2584
2584
|
* drops object members holding it and prints null for array slots,
|
|
2585
2585
|
* exactly Node. dynCheck matches it against exactly the undefined arm. */
|
|
2586
2586
|
SCR_DYN_UNDEF,
|
|
2587
2587
|
/* A Uint8Array/Buffer VALUE. Never produced by the parser — it enters
|
|
2588
|
-
* the
|
|
2588
|
+
* the checked-dynamic tree through the compiler's static→dyn converters (a bytes<u8>
|
|
2589
2589
|
* value flowing into an `unknown` slot: stdin chunks passed to
|
|
2590
2590
|
* unknown-typed helpers). Owns a ScrBytes payload (a COPY of the static
|
|
2591
2591
|
* source — the boundary's aliasing stance). typeof answers "object"
|
|
@@ -2594,13 +2594,13 @@ typedef enum {
|
|
|
2594
2594
|
* object form ({"0":1}), and dynCheck extracts a fresh copy against a
|
|
2595
2595
|
* Uint8Array target. */
|
|
2596
2596
|
SCR_DYN_BYTES,
|
|
2597
|
-
/* A FUNCTION value. Never produced by the parser — it enters the
|
|
2598
|
-
* through the compiler's static→
|
|
2597
|
+
/* A FUNCTION value. Never produced by the parser — it enters the checked-dynamic tree
|
|
2598
|
+
* through the compiler's static→dyn converters (a typed closure flowing
|
|
2599
2599
|
* into an `unknown` slot: `mustCall(fn)`-style untyped JS helpers). Owns
|
|
2600
2600
|
* a ScrClosure plus a compiler-emitted CALL THUNK that validates dyn
|
|
2601
2601
|
* arguments into the closure's declared parameter types (per-arg
|
|
2602
2602
|
* dynCheck — JS arity semantics: extra args ignored, missing args are
|
|
2603
|
-
* the undefined
|
|
2603
|
+
* the undefined dyn value) and converts the result back to a dyn value.
|
|
2604
2604
|
* `sig` is the compiler's interned signature key: dynCheck against an
|
|
2605
2605
|
* IDENTICAL function type unwraps the closure directly; any other
|
|
2606
2606
|
* (adaptable) function target wraps the box in a per-target adapter
|
|
@@ -2612,7 +2612,7 @@ typedef enum {
|
|
|
2612
2612
|
/* A NATIVE HANDLE value (httpReq/httpRes/netSocket crossing the checked-
|
|
2613
2613
|
* dynamic boundary — `server.on('request', mustCall((req, res) => ...))`
|
|
2614
2614
|
* makes the listener dyn, so the event tuple must box). Never produced
|
|
2615
|
-
* by the parser — it enters the
|
|
2615
|
+
* by the parser — it enters the checked-dynamic tree through the compiler's static→dyn
|
|
2616
2616
|
* converters and the per-target function adapters. Boxes by REFERENCE
|
|
2617
2617
|
* (a retained pointer + a handle-type tag): handles are stateful I/O
|
|
2618
2618
|
* objects, so identity is the HANDLE, not the box — strict equality
|
|
@@ -2627,12 +2627,12 @@ typedef enum {
|
|
|
2627
2627
|
* "[object Object]" (Object.prototype.toString — Node's answer for
|
|
2628
2628
|
* these classes), JSON serialization and util.inspect fence loudly. */
|
|
2629
2629
|
SCR_DYN_HANDLE,
|
|
2630
|
-
/* A PROMISE value. Never produced by the parser — it enters the
|
|
2631
|
-
* through the compiler's static→
|
|
2630
|
+
/* A PROMISE value. Never produced by the parser — it enters the checked-dynamic tree
|
|
2631
|
+
* through the compiler's static→dyn converters (a promise flowing into
|
|
2632
2632
|
* an `any`/`unknown` slot: the traced-function boundary of
|
|
2633
2633
|
* dc.tracingChannel.tracePromise, a dyn-boxed async closure's return).
|
|
2634
2634
|
* Boxes by REFERENCE (a retained ScrPromise + the boundary contract
|
|
2635
|
-
* that a
|
|
2635
|
+
* that a dyn-crossing promise settles with a dyn payload: promise<dyn>
|
|
2636
2636
|
* boxes its ScrPromise directly, other inner types box an ADAPTER
|
|
2637
2637
|
* promise whose emitted settle callback converts the payload — see
|
|
2638
2638
|
* scr_dyn_new_promise_adapting). Identity is the PROMISE, not the box
|
|
@@ -2646,31 +2646,31 @@ typedef enum {
|
|
|
2646
2646
|
* (the dyn→closure stance): a cycle THROUGH a dyn-boxed promise is
|
|
2647
2647
|
* merely never collected. */
|
|
2648
2648
|
SCR_DYN_PROMISE,
|
|
2649
|
-
/* An ISLAND (engine-held) value — the jsval→
|
|
2650
|
-
* produced by the parser — it enters the
|
|
2649
|
+
/* An ISLAND (engine-held) value — the jsval→dyn crossing. Never
|
|
2650
|
+
* produced by the parser — it enters the checked-dynamic tree through the gated
|
|
2651
2651
|
* constructor scr_dyn_from_jsval (scr_island.c): an 'any'-typed value
|
|
2652
2652
|
* flowing into an 'unknown'/'object'/JS-residue slot. Boxes by
|
|
2653
2653
|
* REFERENCE (a retained ScrJsval cell). The constructor SCALAR-
|
|
2654
2654
|
* NORMALIZES: engine numbers/strings/booleans/null/undefined convert
|
|
2655
|
-
* to the native
|
|
2655
|
+
* to the native dyn kinds at wrap time, so JSVAL nodes only ever hold
|
|
2656
2656
|
* engine objects, arrays, and functions (plus the symbol/bigint edge —
|
|
2657
|
-
* kinds the
|
|
2657
|
+
* kinds the checked-dynamic tree cannot represent at all). Identity is the CELL's
|
|
2658
2658
|
* engine value: strict equality routes to the engine's === (two wraps
|
|
2659
2659
|
* of one engine value compare equal), and scr_jsval_from_dyn unwraps
|
|
2660
2660
|
* the SAME cell back (+1) — the boundary is identity-preserving for
|
|
2661
2661
|
* engine-born values. typeof/truthiness/String() route to the engine
|
|
2662
|
-
* per use (scr_dyn_jsval_ops); every
|
|
2662
|
+
* per use (scr_dyn_jsval_ops); every dyn walk without an armed route
|
|
2663
2663
|
* (JSON, structuredClone, deepStrictEqual, inspect, keyed access,
|
|
2664
2664
|
* calls, iteration) throws the LOUD "not supported yet" ladder — never
|
|
2665
2665
|
* a silent wrong answer. The dyn→cell edge is NOT visible to the cycle
|
|
2666
|
-
* collector (the dyn→closure stance): a cycle
|
|
2667
|
-
* object → host closure →
|
|
2666
|
+
* collector (the dyn→closure stance): a cycle dyn → cell → engine
|
|
2667
|
+
* object → host closure → dyn is merely never collected (the
|
|
2668
2668
|
* documented cross-boundary-cycle divergence). Enum position: LAST —
|
|
2669
2669
|
* the LLVM backend hardcodes the preceding kind numbers. */
|
|
2670
2670
|
SCR_DYN_JSVAL,
|
|
2671
2671
|
} ScrDynKind;
|
|
2672
2672
|
|
|
2673
|
-
/* The handle-type tags the
|
|
2673
|
+
/* The handle-type tags the checked-dynamic tree can carry. The set is deliberately the
|
|
2674
2674
|
* HANDLE kinds whose member surfaces already have complete static
|
|
2675
2675
|
* lowerings (the http/net receiver surface); new kinds join by adding a
|
|
2676
2676
|
* tag + an ops registration in their owning unit. */
|
|
@@ -2688,7 +2688,7 @@ typedef struct ScrDyn ScrDyn;
|
|
|
2688
2688
|
typedef struct ScrBytes ScrBytes; /* full definition below (C11 repeat) */
|
|
2689
2689
|
typedef struct ScrClosure ScrClosure; /* full definition below (C11 repeat) */
|
|
2690
2690
|
typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
2691
|
-
* always-linked
|
|
2691
|
+
* always-linked dyn core never touches
|
|
2692
2692
|
* its engine value — only the gated ops
|
|
2693
2693
|
* installed by scr_dyn_from_jsval do) */
|
|
2694
2694
|
|
|
@@ -2696,7 +2696,7 @@ typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
|
2696
2696
|
* dyn arguments against the boxed closure's declared parameter types (a
|
|
2697
2697
|
* mismatch throws the catchable path-annotated TypeError and returns NULL
|
|
2698
2698
|
* with the exception pending), calls through the closure, and returns the
|
|
2699
|
-
* result as an owned (+1)
|
|
2699
|
+
* result as an owned (+1) dyn value. `args` entries are BORROWED. */
|
|
2700
2700
|
typedef ScrDyn *(*ScrDynThunk)(ScrClosure *clo, ScrDyn *const *args, size_t argc);
|
|
2701
2701
|
|
|
2702
2702
|
/* Object member. Keys are malloc'd UTF-8 bytes (NUL-terminated for
|
|
@@ -2717,7 +2717,7 @@ struct ScrDyn {
|
|
|
2717
2717
|
* its elements ("1,2,3"). Everything else ignores it. */
|
|
2718
2718
|
bool buffer;
|
|
2719
2719
|
/* SCR_DYN_OBJ flavor: true for Object.create(null)'s dictionary — an
|
|
2720
|
-
* object with NO prototype. Method dispatch needs nothing (the
|
|
2720
|
+
* object with NO prototype. Method dispatch needs nothing (the checked-dynamic tree's
|
|
2721
2721
|
* OBJ dispatch is already own-member-only, which IS Node's null-proto
|
|
2722
2722
|
* answer); util.inspect prefixes "[Object: null prototype]", and
|
|
2723
2723
|
* deepStrictEqual separates it from plain objects (Node compares
|
|
@@ -2748,7 +2748,7 @@ struct ScrDyn {
|
|
|
2748
2748
|
* settle — the settle-releases-listeners story. */
|
|
2749
2749
|
struct { void *ptr; ScrDynHandleTag tag; } handle;
|
|
2750
2750
|
/* SCR_DYN_PROMISE: the retained promise. The boundary contract: it
|
|
2751
|
-
* settles with a
|
|
2751
|
+
* settles with a dyn payload (SCR_EXC_REF ScrDyn fulfillment or a
|
|
2752
2752
|
* void fulfillment awaiters read as the undefined value) — the
|
|
2753
2753
|
* emitted converters guarantee it (direct box for promise<dyn>,
|
|
2754
2754
|
* adapter promise otherwise). */
|
|
@@ -2776,22 +2776,22 @@ ScrDyn *scr_json_parse(ScrStr *text);
|
|
|
2776
2776
|
/* BORROWED member lookup on a SCR_DYN_OBJ; NULL when the key is absent. */
|
|
2777
2777
|
ScrDyn *scr_dyn_obj_get(const ScrDyn *d, const char *key, size_t key_len);
|
|
2778
2778
|
|
|
2779
|
-
/* Object.keys/values/entries over the
|
|
2780
|
-
* keys ascending first),
|
|
2779
|
+
/* Object.keys/values/entries over the checked-dynamic tree: JS own-key order (array-index
|
|
2780
|
+
* keys ascending first), dyn-array results (+1); values/entries RETAIN
|
|
2781
2781
|
* member nodes. null/undefined receivers throw Node's catchable
|
|
2782
2782
|
* TypeError. */
|
|
2783
2783
|
ScrDyn *scr_dyn_obj_keys(const ScrDyn *v);
|
|
2784
|
-
/* Object.hasOwn over a
|
|
2784
|
+
/* Object.hasOwn over a dyn receiver: OBJ member presence, ARR index
|
|
2785
2785
|
* bounds ("length" included); nullish receivers throw Node's ToObject
|
|
2786
2786
|
* TypeError; every other kind answers false. */
|
|
2787
2787
|
bool scr_dyn_has_own(const ScrDyn *v, const ScrStr *key);
|
|
2788
|
-
/* Object.assign over
|
|
2788
|
+
/* Object.assign over dyn values (+1 target back; ToObject TypeError on a
|
|
2789
2789
|
* nullish target). Sources copy their own enumerable keys exactly as
|
|
2790
2790
|
* Object.keys lists them: OBJ members, ARR/STR/BYTES index keys; nullish
|
|
2791
2791
|
* and scalar/function/handle sources copy nothing. */
|
|
2792
2792
|
ScrDyn *scr_dyn_assign(ScrDyn *target, const ScrDyn *src);
|
|
2793
2793
|
/* Variadic Object.assign (the spread-source form): the compiler packs
|
|
2794
|
-
* every source into one fresh
|
|
2794
|
+
* every source into one fresh dyn array — pack_push retains a plain
|
|
2795
2795
|
* source in (BORROWED), pack_push_spread flattens a spread source through
|
|
2796
2796
|
* the spread-call walk (V8's exact TypeError texts, `what` spelling the
|
|
2797
2797
|
* spread expression; MAY THROW pending) — then assign_all copies each
|
|
@@ -2807,8 +2807,8 @@ ScrDyn *scr_dyn_assign_all(ScrDyn *target, const ScrDyn *sources);
|
|
|
2807
2807
|
ScrDyn *scr_dyn_obj_values(const ScrDyn *v);
|
|
2808
2808
|
ScrDyn *scr_dyn_obj_entries(const ScrDyn *v);
|
|
2809
2809
|
|
|
2810
|
-
/*
|
|
2811
|
-
* and index-signature overflow machinery build
|
|
2810
|
+
/* dyn construction — the compiler-emitted static→dyn converters (sc_td_*)
|
|
2811
|
+
* and index-signature overflow machinery build dyn values directly.
|
|
2812
2812
|
* Constructors return +1; _new_str RETAINS the string into the node.
|
|
2813
2813
|
* arr_push and obj_set take OWNERSHIP of the value (+1 moves in); obj_set
|
|
2814
2814
|
* COPIES the key bytes and replaces a duplicate key's value (later wins,
|
|
@@ -2836,25 +2836,32 @@ ScrBytes *scr_dyn_bytes_copy_out(const ScrDyn *d);
|
|
|
2836
2836
|
void scr_dyn_arr_push(ScrDyn *arr, ScrDyn *item);
|
|
2837
2837
|
/* Spread completion for a runtime-arity argument list (`f(...xs)` in the
|
|
2838
2838
|
* checked-dynamic tier): flattens `src` into `arr` per JS's spread over the
|
|
2839
|
-
*
|
|
2839
|
+
* dyn's iterable kinds — arrays element-by-element (retained), strings by
|
|
2840
2840
|
* code POINT (the string iterator), bytes by byte — and throws V8's exact
|
|
2841
2841
|
* SPREAD-CALL TypeError for every other kind (pending; callers check):
|
|
2842
2842
|
* nullish sources spell the spread expression (`what`), everything else is
|
|
2843
2843
|
* the generic "Spread syntax requires ..." text. Borrows src. */
|
|
2844
2844
|
void scr_dyn_arr_push_spread(ScrDyn *arr, const ScrDyn *src, const char *what);
|
|
2845
|
-
/* Destructuring pack over a
|
|
2845
|
+
/* Destructuring pack over a dyn source: iterable kinds (arrays, strings by
|
|
2846
2846
|
* code point, bytes) collect into a fresh array (+1); every other kind
|
|
2847
2847
|
* throws V8's destructuring TypeError — `msg` verbatim when non-empty (the
|
|
2848
2848
|
* compile-time source spelling), else the runtime kind wording. Borrows
|
|
2849
2849
|
* both; NULL with the exception pending on the throw. */
|
|
2850
2850
|
ScrDyn *scr_dyn_iter_pack(const ScrDyn *src, const ScrStr *msg);
|
|
2851
|
+
/* The for-of-over-dyn pack accessors (the emitted index loop drives them
|
|
2852
|
+
* over a scr_dyn_iter_pack result, which is ARR by construction).
|
|
2853
|
+
* scr_dyn_arr_len answers 0 for non-ARR kinds; scr_dyn_arr_at answers the
|
|
2854
|
+
* undefined singleton past the end (both never throw). scr_dyn_arr_at is
|
|
2855
|
+
* +1. */
|
|
2856
|
+
double scr_dyn_arr_len(const ScrDyn *d);
|
|
2857
|
+
ScrDyn *scr_dyn_arr_at(const ScrDyn *d, double i);
|
|
2851
2858
|
void scr_dyn_obj_set(ScrDyn *obj, const char *key, size_t key_len, ScrDyn *value);
|
|
2852
2859
|
/* The checked-dynamic keyed WRITE (`h.k = v` on a dyn receiver): OBJ sets
|
|
2853
2860
|
* the member (JS: later writes win, insertion order); undefined/null and
|
|
2854
2861
|
* non-object kinds throw Node's catchable TypeErrors (strict-mode
|
|
2855
2862
|
* wording). All three operands BORROWED (the value is retained in). */
|
|
2856
2863
|
void scr_dyn_key_set(ScrDyn *recv, ScrStr *key, ScrDyn *value);
|
|
2857
|
-
/* Bare `typeof v` on a dyn value: the
|
|
2864
|
+
/* Bare `typeof v` on a dyn value: the dyn kind's JS answer (+1 string;
|
|
2858
2865
|
* null answers "object"). Never throws. */
|
|
2859
2866
|
ScrStr *scr_dyn_typeof(const ScrDyn *d);
|
|
2860
2867
|
/* Receiver-kind-dispatched toString() (Buffer-flavored bytes decode per
|
|
@@ -2865,7 +2872,7 @@ ScrStr *scr_dyn_to_string(const ScrDyn *d, const ScrStr *enc);
|
|
|
2865
2872
|
* null-prototype dictionary throws "<what> is not a function" — its
|
|
2866
2873
|
* prototype chain has no toString (Node's answer). */
|
|
2867
2874
|
ScrStr *scr_dyn_to_string_method(const ScrDyn *d, const ScrStr *enc, const ScrStr *what);
|
|
2868
|
-
/* JS String() over the
|
|
2875
|
+
/* JS String() over the dyn kind (units render "null"/"undefined" where
|
|
2869
2876
|
* scr_dyn_to_string throws) — the web globals' WebIDL ToString. +1. */
|
|
2870
2877
|
ScrStr *scr_dyn_string_coerce(const ScrDyn *d);
|
|
2871
2878
|
/* JS ToString WITH the object protocol (user toString/valueOf members
|
|
@@ -2874,14 +2881,14 @@ ScrStr *scr_dyn_string_coerce(const ScrDyn *d);
|
|
|
2874
2881
|
ScrStr *scr_dyn_string_coerce_js(const ScrDyn *d);
|
|
2875
2882
|
|
|
2876
2883
|
/* `d instanceof TypeError` (and the other builtin error classes) on a
|
|
2877
|
-
* checked-dynamic value: the from_error cache resolves the
|
|
2884
|
+
* checked-dynamic value: the from_error cache resolves the dyn encoding
|
|
2878
2885
|
* back to its runtime error and the class's stamped preorder interval
|
|
2879
|
-
* answers. A
|
|
2886
|
+
* answers. A dyn value that never came from an error answers false. */
|
|
2880
2887
|
bool scr_dyn_err_instanceof(const ScrDyn *d, double kind);
|
|
2881
2888
|
|
|
2882
|
-
/* structuredClone over the
|
|
2889
|
+
/* structuredClone over the checked-dynamic tree: JSON-safe data + bytes deep-copy;
|
|
2883
2890
|
* functions/handles throw the spec's catchable DataCloneError; cycles
|
|
2884
|
-
* throw the scriptc fence (the
|
|
2891
|
+
* throw the scriptc fence (the checked-dynamic tree cannot represent them). Option
|
|
2885
2892
|
* validation (shared with scr_domex_clone) throws Node's exact
|
|
2886
2893
|
* TypeErrors; any non-empty transfer list throws DataCloneError. The
|
|
2887
2894
|
* _missing form is the zero-argument call: always throws Node's
|
|
@@ -2889,13 +2896,13 @@ bool scr_dyn_err_instanceof(const ScrDyn *d, double kind);
|
|
|
2889
2896
|
ScrDyn *scr_structured_clone(const ScrDyn *value, const ScrDyn *options);
|
|
2890
2897
|
ScrDyn *scr_structured_clone_missing(void);
|
|
2891
2898
|
ScrDyn *scr_structured_clone_transfer_fail(void); /* always throws DataCloneError */
|
|
2892
|
-
/* Validates a structuredClone options
|
|
2899
|
+
/* Validates a structuredClone options dyn value (throws on failure —
|
|
2893
2900
|
* callers must check scr_exc_pending). Borrowed, NULL-tolerant. */
|
|
2894
2901
|
void scr_sc_validate_options(const ScrDyn *options);
|
|
2895
|
-
/* An %Error as the boundary's
|
|
2902
|
+
/* An %Error as the boundary's dyn shape ({name, message[, code]}).
|
|
2896
2903
|
* Borrows; +1. */
|
|
2897
2904
|
ScrDyn *scr_dyn_from_error(const ScrError *e);
|
|
2898
|
-
/* The reverse extraction, riding the same identity cache: a
|
|
2905
|
+
/* The reverse extraction, riding the same identity cache: a dyn error
|
|
2899
2906
|
* that came from a runtime ScrError answers THAT instance (+1;
|
|
2900
2907
|
* out-and-back crossings compare reference-equal); alien %error objects
|
|
2901
2908
|
* rebuild once and enter the cache. Borrows d. */
|
|
@@ -2904,16 +2911,16 @@ ScrError *scr_error_from_dyn(const ScrDyn *d); /* scr_async_dyn.c (gated) */
|
|
|
2904
2911
|
* the gated extraction reads/writes through these). */
|
|
2905
2912
|
ScrError *scr_errdyn_err_of(const ScrDyn *d); /* +1 or NULL */
|
|
2906
2913
|
void scr_errdyn_put(ScrError *e, ScrDyn *d); /* retains both sides */
|
|
2907
|
-
/* ToBoolean over the
|
|
2914
|
+
/* ToBoolean over the dyn kind (JS-exact); borrowed, never throws. */
|
|
2908
2915
|
bool scr_dyn_truthy(const ScrDyn *d);
|
|
2909
|
-
/* JS String() over a
|
|
2916
|
+
/* JS String() over a dyn value (arrays join, [object Object], the error
|
|
2910
2917
|
* encoding renders "name: message"); borrowed, result +1, never throws. */
|
|
2911
2918
|
ScrStr *scr_dyn_display(const ScrDyn *d);
|
|
2912
|
-
/* JS === over two
|
|
2919
|
+
/* JS === over two dyn values: scalars by value, units by kind, everything
|
|
2913
2920
|
* reference-shaped by node identity. Borrowed; never throws. */
|
|
2914
2921
|
bool scr_dyn_strict_eq(const ScrDyn *a, const ScrDyn *b);
|
|
2915
2922
|
/* Prototype-method dispatch on a dyn receiver (`recv.m(...)` where `m` is
|
|
2916
|
-
* a name a
|
|
2923
|
+
* a name a dyn-representable prototype declares — push/slice/forEach/
|
|
2917
2924
|
* apply/...): implemented (kind, name) pairs run JS-exact semantics; a
|
|
2918
2925
|
* real-but-unimplemented method throws a LOUD "not supported yet" Error;
|
|
2919
2926
|
* a name the kind's prototype lacks throws Node's "<what> is not a
|
|
@@ -2925,14 +2932,14 @@ ScrDyn *scr_dyn_invoke(ScrDyn *recv, const char *method, ScrDyn *const *args, si
|
|
|
2925
2932
|
* for anonymous) and "length" (the boxed arity). Returns +1, or NULL when
|
|
2926
2933
|
* the key answers nothing (the caller's undefined). Never throws. */
|
|
2927
2934
|
ScrDyn *scr_dyn_fn_get(const ScrDyn *d, const char *key, size_t key_len);
|
|
2928
|
-
/* Object.defineProperties over
|
|
2935
|
+
/* Object.defineProperties over dyn values (targets: OBJ and FUNC): each
|
|
2929
2936
|
* descriptor's `value` becomes a plain own property — writable/enumerable/
|
|
2930
|
-
* configurable are accepted and IGNORED (
|
|
2937
|
+
* configurable are accepted and IGNORED (dyn properties are plain data
|
|
2931
2938
|
* properties; SEMANTICS.md), get/set throw the loud unsupported Error.
|
|
2932
2939
|
* Returns the target (+1, JS's return), or NULL with a pending catchable
|
|
2933
2940
|
* TypeError (non-object target/descriptor — Node's messages). */
|
|
2934
2941
|
ScrDyn *scr_dyn_define_props(ScrDyn *target, ScrDyn *descs);
|
|
2935
|
-
/* Boxes a closure as a callable
|
|
2942
|
+
/* Boxes a closure as a callable dyn value. Ownership of `clo` MOVES in
|
|
2936
2943
|
* (callers retain first when they keep their own reference); `sig`/`name`
|
|
2937
2944
|
* must be static literals (the box never frees them; name may be NULL). */
|
|
2938
2945
|
ScrDyn *scr_dyn_new_func(ScrClosure *clo, ScrDynThunk thunk, uint32_t arity, const char *sig, const char *name);
|
|
@@ -2942,7 +2949,7 @@ ScrDyn *scr_dyn_new_func(ScrClosure *clo, ScrDynThunk thunk, uint32_t arity, con
|
|
|
2942
2949
|
* boxed thunk (per-arg checks live there). `args` entries are BORROWED;
|
|
2943
2950
|
* the result is owned (+1), or NULL with the exception pending. */
|
|
2944
2951
|
ScrDyn *scr_dyn_call(const ScrDyn *d, ScrDyn *const *args, size_t argc, const char *what);
|
|
2945
|
-
/* scr_dyn_call over a
|
|
2952
|
+
/* scr_dyn_call over a dyn ARRAY's elements (the spread-application form —
|
|
2946
2953
|
* `f(...args)` after the emitted argument array is built): argv IS the
|
|
2947
2954
|
* array's items. Borrows both; result owned (+1), or NULL pending. */
|
|
2948
2955
|
ScrDyn *scr_dyn_apply(const ScrDyn *d, const ScrDyn *args, const char *what);
|
|
@@ -2964,7 +2971,7 @@ typedef struct ScrDynPath {
|
|
|
2964
2971
|
* scriptc-specific behavior — JS `as` never checks (SEMANTICS.md). */
|
|
2965
2972
|
void scr_dyn_check_fail(const ScrDynPath *path, const char *want, const ScrDyn *got);
|
|
2966
2973
|
|
|
2967
|
-
/* ── native handles in the
|
|
2974
|
+
/* ── native handles in the checked-dynamic tree (SCR_DYN_HANDLE) ────────────────────────
|
|
2968
2975
|
* Per-tag dispatch ops, registered by the handle's owning unit
|
|
2969
2976
|
* (scr_http_dyn_install / scr_net_dyn_install — emitted main() calls
|
|
2970
2977
|
* them exactly when the unit is linked, the scr_net_install story), so
|
|
@@ -2983,7 +2990,7 @@ typedef struct ScrDynHandleOps {
|
|
|
2983
2990
|
ScrDyn *(*invoke)(void *h, ScrDyn *self, const char *method, ScrDyn *const *args, size_t argc, const char *what);
|
|
2984
2991
|
/* Property READ with a static equivalent (req.url, res.statusCode):
|
|
2985
2992
|
* +1 boxed value; NULL = no such modeled property (the caller answers
|
|
2986
|
-
* the undefined singleton — the
|
|
2993
|
+
* the undefined singleton — the checked-dynamic tree's own-property stance); may throw
|
|
2987
2994
|
* the loud ladder for real-but-unmodeled names (NULL + pending). */
|
|
2988
2995
|
ScrDyn *(*get)(void *h, const char *key, size_t key_len);
|
|
2989
2996
|
/* Property WRITE with a static equivalent (res.statusCode = 200):
|
|
@@ -3019,13 +3026,13 @@ ScrDyn *scr_dyn_new_handle(void *h, ScrDynHandleTag tag);
|
|
|
3019
3026
|
void *scr_dyn_handle_unbox(const ScrDyn *d, ScrDynHandleTag tag, const ScrDynPath *path, const char *want);
|
|
3020
3027
|
/* Keyed read on a HANDLE box (the emitted sc_dyn_key_get's arm): the
|
|
3021
3028
|
* tag's modeled properties answer boxed values; everything else answers
|
|
3022
|
-
* the undefined singleton (the
|
|
3029
|
+
* the undefined singleton (the checked-dynamic tree's own-property stance — SEMANTICS.md)
|
|
3023
3030
|
* unless the ops fence it loudly. +1, or NULL with a pending exception. */
|
|
3024
3031
|
ScrDyn *scr_dyn_handle_key_get(const ScrDyn *d, const ScrStr *k);
|
|
3025
3032
|
|
|
3026
|
-
/* ── promises in the
|
|
3033
|
+
/* ── promises in the checked-dynamic tree (SCR_DYN_PROMISE) ────────────────────────────
|
|
3027
3034
|
* Boxes by REFERENCE (+1 box; retains p). The boundary contract: p
|
|
3028
|
-
* settles with a
|
|
3035
|
+
* settles with a dyn payload — promise<dyn> boxes directly; other inner
|
|
3029
3036
|
* types go through scr_dyn_new_promise_adapting, which parks an emitted
|
|
3030
3037
|
* payload-converting adapter (the Promise.race cb-waiter machinery) on
|
|
3031
3038
|
* `src` and boxes the fresh destination promise instead. Rejections copy
|
|
@@ -3042,7 +3049,7 @@ ScrDyn *scr_dyn_new_promise_adapting(ScrPromise *src,
|
|
|
3042
3049
|
/* BORROWED peek at the boxed promise; NULL when d is not a promise box. */
|
|
3043
3050
|
ScrPromise *scr_dyn_promise_of(const ScrDyn *d);
|
|
3044
3051
|
|
|
3045
|
-
/* ── island values in the
|
|
3052
|
+
/* ── island values in the checked-dynamic tree (SCR_DYN_JSVAL) ─────────────────────────
|
|
3046
3053
|
* Engine routing ops for JSVAL nodes, installed by the gated constructor
|
|
3047
3054
|
* (scr_dyn_from_jsval, scr_island.c — the scr_dyn_alloc_promise hook
|
|
3048
3055
|
* story: JSVAL nodes exist only after the constructor ran, so the ops
|
|
@@ -3062,7 +3069,7 @@ typedef struct ScrDynJsvalOps {
|
|
|
3062
3069
|
/* ── the routed operation set (lane dyn-routing-ops) ────────────────
|
|
3063
3070
|
* Each routes to the engine at the moment of use and converts at the
|
|
3064
3071
|
* boundary: dyn ARGUMENTS cross through scr_jsval_from_dyn (wrapped
|
|
3065
|
-
* cells unwrap by reference,
|
|
3072
|
+
* cells unwrap by reference, dyn data deep-copies, dyn FUNC boxes
|
|
3066
3073
|
* cross through the generic host-function shim), engine RESULTS come
|
|
3067
3074
|
* back through scr_dyn_from_jsval (scalar-normalizing). Fallible ops
|
|
3068
3075
|
* bridge the ENGINE's exception catchably and answer NULL/false/-1. */
|
|
@@ -3077,19 +3084,28 @@ typedef struct ScrDynJsvalOps {
|
|
|
3077
3084
|
bool (*is_nullish)(ScrJsval *cell); /* engine undefined/null; never throws
|
|
3078
3085
|
* (always false today — the wrap
|
|
3079
3086
|
* constructor scalar-normalizes) */
|
|
3080
|
-
/* Object.keys/values/entries (mode 0/1/2) as a NATIVE
|
|
3081
|
-
* keys are
|
|
3082
|
-
*
|
|
3087
|
+
/* Object.keys/values/entries (mode 0/1/2) as a NATIVE dyn array (+1):
|
|
3088
|
+
* keys are dyn strings, values wrap per element, entries are native
|
|
3089
|
+
* dyn pairs. NULL with the engine's exception pending on refusal. */
|
|
3083
3090
|
ScrDyn *(*obj_walk)(ScrJsval *cell, int mode);
|
|
3084
3091
|
int (*has_own)(ScrJsval *cell, const ScrStr *k); /* 0/1; -1 = pending */
|
|
3085
3092
|
/* Object.assign(target, src) with the ENGINE target: src converts per
|
|
3086
|
-
* member semantics (a wrapped src spreads by reference;
|
|
3093
|
+
* member semantics (a wrapped src spreads by reference; dyn data
|
|
3087
3094
|
* enters as the usual deep copy). false = pending. */
|
|
3088
3095
|
bool (*assign)(ScrJsval *cell, const ScrDyn *src);
|
|
3089
3096
|
/* JSON.stringify text of the engine value (+1) — the engine's own
|
|
3090
3097
|
* stringify (toJSON protocols, cycle TypeErrors). NULL + pending when
|
|
3091
3098
|
* not JSON-representable. */
|
|
3092
3099
|
ScrStr *(*to_json)(ScrJsval *cell);
|
|
3100
|
+
/* Drain the ENGINE's own iterator protocol into a fresh dyn array
|
|
3101
|
+
* (elements wrap back scalar-normalized) — the for-of/destructuring/
|
|
3102
|
+
* spread arm over a wrapped value. The guard's TypeError wording on a
|
|
3103
|
+
* non-iterable: spread true takes V8's spread-call text; otherwise the
|
|
3104
|
+
* compile-time spelling `spell` verbatim when non-NULL (the named-
|
|
3105
|
+
* source form), else the kind wording. An iterating getter/next throw
|
|
3106
|
+
* bridges with the ENGINE's message. +1, or NULL with the exception
|
|
3107
|
+
* pending. */
|
|
3108
|
+
ScrDyn *(*iter_drain)(ScrJsval *cell, bool spread, const ScrStr *spell);
|
|
3093
3109
|
} ScrDynJsvalOps;
|
|
3094
3110
|
|
|
3095
3111
|
/* The allocator view the gated constructor uses (installs the ops);
|
|
@@ -3115,7 +3131,7 @@ bool scr_dyn_isl_fence(const ScrDyn *d, const char *what);
|
|
|
3115
3131
|
* normalized) — the retired `.length -> fence` row. d MUST be a JSVAL
|
|
3116
3132
|
* node; NULL with the engine's exception bridged catchably. */
|
|
3117
3133
|
ScrDyn *scr_dyn_isl_key_get(const ScrDyn *d, const ScrStr *k);
|
|
3118
|
-
/* The `??`/optional-chain nullish test over a
|
|
3134
|
+
/* The `??`/optional-chain nullish test over a dyn value: UNDEF/NULL
|
|
3119
3135
|
* native, JSVAL through the engine's own test (defensively — the wrap
|
|
3120
3136
|
* constructor scalar-normalizes engine null/undefined away), every other
|
|
3121
3137
|
* kind false. Never throws. */
|
|
@@ -3141,7 +3157,7 @@ bool scr_dyn_is_nullish(const ScrDyn *d);
|
|
|
3141
3157
|
void scr_dyn_this_push(void *h, ScrDynHandleTag tag); /* h BORROWED (the firing site holds it); NULL binds undefined */
|
|
3142
3158
|
void scr_dyn_this_push_dyn(const ScrDyn *v); /* retained for the window */
|
|
3143
3159
|
void scr_dyn_this_pop(void);
|
|
3144
|
-
/* The innermost binding as a
|
|
3160
|
+
/* The innermost binding as a dyn value (+1): a boxed handle, the pushed
|
|
3145
3161
|
* dyn value, or the undefined singleton (empty stack, NULL handle, or a
|
|
3146
3162
|
* handle whose tag has no installed ops — a unit that fires without its
|
|
3147
3163
|
* dyn half never binds). */
|
|
@@ -3153,7 +3169,7 @@ ScrDyn *scr_dyn_this_get(void);
|
|
|
3153
3169
|
void scr_dyn_chunk_enc(bool utf8);
|
|
3154
3170
|
ScrDyn *scr_dyn_new_chunk(const ScrBytes *b);
|
|
3155
3171
|
|
|
3156
|
-
/* util.format's %j over a
|
|
3172
|
+
/* util.format's %j over a dyn value: the JSON.stringify text (+1),
|
|
3157
3173
|
* "undefined" when the root drops (undefined/function), or NULL with a
|
|
3158
3174
|
* pending exception (a runtime handle inside the tree fences loudly). */
|
|
3159
3175
|
ScrStr *scr_dyn_format_j(const ScrDyn *d);
|
|
@@ -3191,7 +3207,7 @@ void scr_throw_lowering_fence(const ScrStr *msg);
|
|
|
3191
3207
|
size_t scr_num_received(double v, char out[48]);
|
|
3192
3208
|
/* Listener-closure builders for the handle dispatchers' .on(...) paths:
|
|
3193
3209
|
* a runtime-built ScrClosure whose capture is the boxed dyn listener and
|
|
3194
|
-
* whose invoke boxes the event tuple back into the
|
|
3210
|
+
* whose invoke boxes the event tuple back into the checked-dynamic tree and calls through
|
|
3195
3211
|
* the checked-dynamic machinery. The matching fn-pointer shapes are the
|
|
3196
3212
|
* per-event thunk types the registration entries take (fire0's zero-arg
|
|
3197
3213
|
* convention / ScrNetDataFn / ScrChildErrFn). cb borrowed; result +1. */
|
|
@@ -3250,7 +3266,7 @@ void scr_jb_edge_idx(ScrJsonBuf *b, size_t i);
|
|
|
3250
3266
|
|
|
3251
3267
|
/* Circular guard for the compiler-emitted typed→dyn converters (sc_td_*
|
|
3252
3268
|
* over cycle-capable containers): enter TRAPS on a value already being
|
|
3253
|
-
* converted (a cyclic value has no finite
|
|
3269
|
+
* converted (a cyclic value has no finite dyn copy — Node shares the
|
|
3254
3270
|
* reference instead; SEMANTICS.md), else pushes. */
|
|
3255
3271
|
void scr_dyn_from_enter(const void *v);
|
|
3256
3272
|
void scr_dyn_from_leave(void);
|
|
@@ -3269,7 +3285,7 @@ void scr_jb_put_json_str(ScrJsonBuf *b, const ScrStr *s);
|
|
|
3269
3285
|
* the exception PENDING and appends nothing — the loud path, never a
|
|
3270
3286
|
* fabricated rendering. */
|
|
3271
3287
|
void scr_dyn_isl_tostr_buf(ScrJsonBuf *b, const ScrDyn *d);
|
|
3272
|
-
/* JSON-serialize a
|
|
3288
|
+
/* JSON-serialize a dyn value into the buffer — the sc_jw_* walker for the
|
|
3273
3289
|
* dyn leaves the compiler cannot type: object members holding undefined
|
|
3274
3290
|
* DROP, array slots holding undefined print null (exactly Node). */
|
|
3275
3291
|
void scr_jb_put_dyn(ScrJsonBuf *b, const ScrDyn *d);
|
|
@@ -3313,23 +3329,23 @@ bool scr_await_bool(ScrPromise *p);
|
|
|
3313
3329
|
ScrStr *scr_await_str(ScrPromise *p); /* +1 */
|
|
3314
3330
|
void *scr_await_ref(ScrPromise *p); /* +1 via the stored retain */
|
|
3315
3331
|
void scr_await_void(ScrPromise *p);
|
|
3316
|
-
/* The
|
|
3317
|
-
* payload as a
|
|
3332
|
+
/* The checked-dynamic tree-crossing await (SCR_DYN_PROMISE's boundary contract): the
|
|
3333
|
+
* payload as a dyn value (+1; void fulfillments answer the undefined
|
|
3318
3334
|
* value), or NULL with the rejection re-thrown into the awaiter. */
|
|
3319
3335
|
ScrDyn *scr_await_dyn(ScrPromise *p);
|
|
3320
|
-
/* `await v` over a checked-dynamic VALUE:
|
|
3336
|
+
/* `await v` over a checked-dynamic VALUE: dyn promises adopt, everything
|
|
3321
3337
|
* else takes JS's one-hop non-thenable await and answers itself (+1). */
|
|
3322
3338
|
ScrDyn *scr_await_dyn_value(ScrDyn *v);
|
|
3323
|
-
/* .then/.catch/.finally over a
|
|
3339
|
+
/* .then/.catch/.finally over a dyn promise (scr_dyn_invoke's promise arm
|
|
3324
3340
|
* and the compiled dyn-receiver path): one reaction fiber per
|
|
3325
|
-
* registration — awaits src, runs the
|
|
3326
|
-
* pass the settlement through; a returned
|
|
3341
|
+
* registration — awaits src, runs the checked-dynamic tree handler (non-callable handlers
|
|
3342
|
+
* pass the settlement through; a returned dyn promise is adopted), and
|
|
3327
3343
|
* settles a fresh result promise, answered BOXED (+1). Microtask-exact
|
|
3328
3344
|
* ordering rides the fiber machinery. */
|
|
3329
3345
|
ScrDyn *scr_dyn_promise_then(ScrPromise *src, ScrDyn *onf, ScrDyn *onr, ScrDyn *onfin);
|
|
3330
3346
|
/* ── AsyncLocalStorage (node:async_hooks — scr_async.c) ───────────────
|
|
3331
3347
|
* Stores are process-lived f64 handles; the CONTEXT is an immutable
|
|
3332
|
-
* refcounted snapshot of (store →
|
|
3348
|
+
* refcounted snapshot of (store → dyn value) entries riding the fiber
|
|
3333
3349
|
* machinery: one active-slot pointer (the exc-cell pattern) swapped at
|
|
3334
3350
|
* every fiber switch, inherited by spawned fibers (Node's init-time
|
|
3335
3351
|
* capture). enter answers the PREVIOUS snapshot (owned) for restore —
|
|
@@ -3357,12 +3373,12 @@ ScrAlsCtx *scr_als_enter_absent(double id); /* exit()'s cleared arm */
|
|
|
3357
3373
|
void scr_als_restore(ScrAlsCtx *prev); /* moves prev back in */
|
|
3358
3374
|
void scr_als_enter_with(double id, ScrDyn *value); /* no restore point (enterWith) */
|
|
3359
3375
|
void scr_als_disable(double id);
|
|
3360
|
-
/* run/exit: enter (or clear), call the
|
|
3376
|
+
/* run/exit: enter (or clear), call the dyn function with the forwarded
|
|
3361
3377
|
* argument vector, restore (the finally). Result +1 or NULL pending. */
|
|
3362
3378
|
ScrDyn *scr_als_run(double id, ScrDyn *value, ScrDyn *fn, ScrDyn *args);
|
|
3363
3379
|
ScrDyn *scr_als_exit_run(double id, ScrDyn *fn, ScrDyn *args);
|
|
3364
3380
|
|
|
3365
|
-
/* process.on('unhandledRejection', fn):
|
|
3381
|
+
/* process.on('unhandledRejection', fn): dyn listeners dispatched per
|
|
3366
3382
|
* never-observed rejection at loop end — (reason, promise), suppressing
|
|
3367
3383
|
* the default report and the exit-1 (Node's handled-event contract; the
|
|
3368
3384
|
* end-of-turn vs loop-end timing is a SEMANTICS.md divergence). Throws
|
|
@@ -3372,15 +3388,15 @@ void scr_process_on_unhandled_rejection(ScrDyn *fn);
|
|
|
3372
3388
|
* (scr_async_dyn.c → scr_report_unhandled_rejections; NULL = default
|
|
3373
3389
|
* report). Runtime-internal. */
|
|
3374
3390
|
extern bool (*scr_urj_deliver_fn)(ScrPromise *p);
|
|
3375
|
-
/* A rejected promise's reason as a
|
|
3391
|
+
/* A rejected promise's reason as a dyn value (identity-preserving for
|
|
3376
3392
|
* dyn payloads and %Error instances). +1. */
|
|
3377
3393
|
ScrDyn *scr_promise_reason_dyn(const ScrPromise *p);
|
|
3378
3394
|
/* process warnings (scr_lib.c — always linked so any unit can emit a
|
|
3379
|
-
* deprecation):
|
|
3395
|
+
* deprecation): dyn listeners plus Node's default stderr report
|
|
3380
3396
|
* ("(node:pid) [CODE] Name: message" and a detail second line). Emission
|
|
3381
3397
|
* is SYNCHRONOUS at the call (Node defers a tick — SEMANTICS.md 138's
|
|
3382
3398
|
* precedent). scr_process_emit_warning takes the ARGUMENT VECTOR as one
|
|
3383
|
-
*
|
|
3399
|
+
* dyn array and applies Node's full grammar/TypeErrors; scr_emit_warning
|
|
3384
3400
|
* is the C-side deprecation entry. */
|
|
3385
3401
|
void scr_process_on_warning(ScrDyn *fn);
|
|
3386
3402
|
void scr_process_off_warning(ScrDyn *fn);
|
|
@@ -3460,7 +3476,7 @@ void scr_set_timeout(ScrClosure *cb, double ms); /* cb ownership moves in */
|
|
|
3460
3476
|
* works). An unknown handle is a no-op, like Node. */
|
|
3461
3477
|
double scr_set_interval(ScrClosure *cb, double ms); /* cb ownership moves in */
|
|
3462
3478
|
/* `new Promise(setImmediate)`: a fresh promise an armed immediate
|
|
3463
|
-
* fulfills with the undefined
|
|
3479
|
+
* fulfills with the undefined dyn value (+1). */
|
|
3464
3480
|
ScrPromise *scr_immediate_promise(void);
|
|
3465
3481
|
void scr_clear_interval(double handle);
|
|
3466
3482
|
/* The island timer bridge (scr_web.c): a one-shot entry WITH a clear
|
|
@@ -3497,7 +3513,7 @@ double scr_set_immediate(ScrClosure *cb); /* cb ownership moves in */
|
|
|
3497
3513
|
* synchronously on a non-function; borrowed. */
|
|
3498
3514
|
void scr_queue_microtask(ScrClosure *cb);
|
|
3499
3515
|
void scr_queue_microtask_dyn(const ScrDyn *cb);
|
|
3500
|
-
/* setImmediate AS A
|
|
3516
|
+
/* setImmediate AS A dyn VALUE (the traceCallback shape): a minted dyn
|
|
3501
3517
|
* callable that schedules args[0](args[1..]) on the immediate queue and
|
|
3502
3518
|
* answers undefined; a non-function first argument throws Node's
|
|
3503
3519
|
* ERR_INVALID_ARG_TYPE. Result +1. */
|
|
@@ -3947,24 +3963,24 @@ ScrJsval *scr_jsval_from_f64(double v);
|
|
|
3947
3963
|
ScrJsval *scr_jsval_from_bool(bool v);
|
|
3948
3964
|
ScrJsval *scr_jsval_from_str(const ScrStr *s);
|
|
3949
3965
|
ScrJsval *scr_jsval_from_json(const ScrStr *json);
|
|
3950
|
-
/* A CHECKED-DYNAMIC (
|
|
3966
|
+
/* A CHECKED-DYNAMIC (dyn) value entering the island — deep copy for data
|
|
3951
3967
|
* kinds (a boxed handle/promise throws the catchable TypeError). A JSVAL
|
|
3952
3968
|
* node unwraps to its OWN cell (+1) — an engine value that crossed into
|
|
3953
|
-
* the
|
|
3969
|
+
* the checked-dynamic tree and back is the SAME engine value, by reference (nested JSVAL
|
|
3954
3970
|
* members embed their engine values directly). A boxed FUNCTION crosses
|
|
3955
3971
|
* as one generic host-function shim over its uniform ScrDynThunk: the
|
|
3956
|
-
* shim wraps engine arguments as
|
|
3957
|
-
* the thunk, and converts the
|
|
3972
|
+
* shim wraps engine arguments as dyn values (scalar-normalizing), calls
|
|
3973
|
+
* the thunk, and converts the dyn result back — each crossing mints a
|
|
3958
3974
|
* fresh engine function (identity is not preserved for re-crossings;
|
|
3959
3975
|
* SEMANTICS.md). NULL with a pending exception on failure. Borrows d. */
|
|
3960
3976
|
ScrJsval *scr_jsval_from_dyn(const ScrDyn *d);
|
|
3961
3977
|
|
|
3962
|
-
/* The jsval→
|
|
3978
|
+
/* The jsval→dyn crossing (the IR's dynFromJsval): wraps an island value
|
|
3963
3979
|
* as a SCR_DYN_JSVAL node, SCALAR-NORMALIZING first — engine numbers/
|
|
3964
|
-
* strings/booleans/null/undefined convert to the native
|
|
3980
|
+
* strings/booleans/null/undefined convert to the native dyn kinds (the
|
|
3965
3981
|
* strict exits cannot fail on engine-reported scalars), so JSVAL nodes
|
|
3966
3982
|
* only ever hold engine objects/arrays/functions (and the symbol/bigint
|
|
3967
|
-
* edge). Installs the
|
|
3983
|
+
* edge). Installs the checked-dynamic tree's engine-routing ops on first use. Borrows
|
|
3968
3984
|
* the cell (retains it into the node); +1 out; never throws. */
|
|
3969
3985
|
ScrDyn *scr_dyn_from_jsval(ScrJsval *cell);
|
|
3970
3986
|
|
|
@@ -4058,6 +4074,11 @@ enum {
|
|
|
4058
4074
|
SCR_ISLP_BOOL = 2,
|
|
4059
4075
|
SCR_ISLP_STR = 3,
|
|
4060
4076
|
SCR_ISLP_JSVAL = 4,
|
|
4077
|
+
/* Promise<any[]> — the fulfillment is a native array of engine cells
|
|
4078
|
+
* (the jsval-element-array spelling): it re-enters the engine as a
|
|
4079
|
+
* fresh engine array whose ELEMENTS are the same engine values (the
|
|
4080
|
+
* loadPlugins shape: identity crosses, the spine is a copy). */
|
|
4081
|
+
SCR_ISLP_JSVAL_ARR = 5,
|
|
4061
4082
|
};
|
|
4062
4083
|
|
|
4063
4084
|
/* Wrap a scriptc promise as an ENGINE promise (async callbacks crossing
|
|
@@ -4118,6 +4139,11 @@ ScrStr *scr_jsval_exit_str(ScrJsval *v);
|
|
|
4118
4139
|
/* Uint8Array exit (engine Buffers pass — they ARE Uint8Arrays): a fresh
|
|
4119
4140
|
* u8 COPY (+1), the boundary's aliasing stance; NULL = thrown. */
|
|
4120
4141
|
ScrBytes *scr_jsval_exit_bytes(ScrJsval *v);
|
|
4142
|
+
/* `any[]`-declared slot exit (the jsval-element-array spelling):
|
|
4143
|
+
* Array.isArray-gated, elements BY REFERENCE into a native array of
|
|
4144
|
+
* engine cells (identity crosses, the spine is a snapshot copy). +1;
|
|
4145
|
+
* NULL = thrown. */
|
|
4146
|
+
ScrArr *scr_jsval_exit_jsval_arr(ScrJsval *v);
|
|
4121
4147
|
ScrStr *scr_jsval_to_json(ScrJsval *v);
|
|
4122
4148
|
|
|
4123
4149
|
/* The import boundary (libCall island.import): loads an embedded module —
|
|
@@ -4457,7 +4483,7 @@ double scr_bytes_compare(const ScrBytes *src, const ScrBytes *target, double nar
|
|
|
4457
4483
|
* Returns false after arming the pending throw. */
|
|
4458
4484
|
bool scr_bytes_validate_off(const char *name, double value, double max);
|
|
4459
4485
|
/* The checked-dynamic compare/equals validators (scr_bytes_io.c): Node's
|
|
4460
|
-
* argument ladder over
|
|
4486
|
+
* argument ladder over dyn-boxed arguments — a non-bytes value throws
|
|
4461
4487
|
* ERR_INVALID_ARG_TYPE with the API's own argument name ("buf1"/"buf2",
|
|
4462
4488
|
* "otherBuffer", "target"), non-number offsets ERR_INVALID_ARG_TYPE
|
|
4463
4489
|
* "of type number", out-of-range numbers the validateOffset RangeError;
|
|
@@ -4470,12 +4496,12 @@ double scr_bytes_compare_chk(const ScrBytes *src, const ScrDyn *target,
|
|
|
4470
4496
|
/* new Buffer(number, encoding)'s string-arm type error (always throws;
|
|
4471
4497
|
* borrowed). */
|
|
4472
4498
|
ScrBytes *scr_buffer_new_string_fail(const ScrDyn *got);
|
|
4473
|
-
/* fs._toUnixTimestamp over a
|
|
4499
|
+
/* fs._toUnixTimestamp over a dyn time value: numeric strings and finite
|
|
4474
4500
|
* numbers coerce (negatives answer now/1000), the rest throw Node's
|
|
4475
4501
|
* ERR_INVALID_ARG_TYPE. Borrowed. */
|
|
4476
4502
|
double scr_fs_to_unix_timestamp(const ScrDyn *t);
|
|
4477
4503
|
/* The fs argument-validation ladders (the fs.*Chk libCalls): Node-order
|
|
4478
|
-
* validation over
|
|
4504
|
+
* validation over dyn values with Node's exact typed errors; a pass
|
|
4479
4505
|
* meets the real operation where one exists (mkdtempSync, macOS
|
|
4480
4506
|
* lchmodSync) or the compiler-rendered fence. All borrowed; the Chk
|
|
4481
4507
|
* forms without results always leave an exception pending. */
|
|
@@ -4536,7 +4562,7 @@ ScrStr *scr_insp_buffer(ScrBytes *b); /* <Buffer aa bb ...>, 50-byte cap */
|
|
|
4536
4562
|
* depth when a code makes it composite. */
|
|
4537
4563
|
ScrStr *scr_insp_error(ScrError *e, double recurse, double depth);
|
|
4538
4564
|
/* The checked-dynamic tree: shape lives in the value, so the whole
|
|
4539
|
-
* traversal is here. dyn-boxed bytes render in the
|
|
4565
|
+
* traversal is here. dyn-boxed bytes render in the checked-dynamic tree's documented
|
|
4540
4566
|
* Uint8Array identity. */
|
|
4541
4567
|
ScrStr *scr_insp_dyn(ScrDyn *d, double recurse, double depth);
|
|
4542
4568
|
/* format's %s / rest-args twin: dyn strings pass verbatim. */
|
|
@@ -4597,7 +4623,7 @@ double scr_bytes_write_var(ScrBytes *b, double value, double offset, double byte
|
|
|
4597
4623
|
* Buffer forms of scr_lib.c's utf8 pair, byte-exact and NUL-safe.
|
|
4598
4624
|
* Failures THROW catchably (scr_fs_throw, Node-shaped messages). */
|
|
4599
4625
|
ScrBytes *scr_fs_read_file_bytes(ScrStr *path); /* +1 */
|
|
4600
|
-
/* readFileSync's runtime-encoding form (scr_bytes_io.c's note): +1
|
|
4626
|
+
/* readFileSync's runtime-encoding form (scr_bytes_io.c's note): +1 dyn
|
|
4601
4627
|
* value — a Buffer box for undefined/null, a string for utf8 — or NULL
|
|
4602
4628
|
* with the exception pending. */
|
|
4603
4629
|
ScrDyn *scr_fs_read_file_sync_dyn(ScrStr *path, const ScrDyn *enc);
|
|
@@ -4827,7 +4853,7 @@ void scr_net_conn_thunk_sock(ScrClosure *cb, ScrNetSocket *sock);
|
|
|
4827
4853
|
void scr_net_install(void);
|
|
4828
4854
|
/* Registers the netSocket handle-dispatch ops (SCR_DYNH_NET_SOCKET) —
|
|
4829
4855
|
* emitted main() calls this alongside scr_net_install exactly when the
|
|
4830
|
-
* net unit is linked, so the always-linked
|
|
4856
|
+
* net unit is linked, so the always-linked dyn core never references
|
|
4831
4857
|
* this unit's entry points. */
|
|
4832
4858
|
void scr_net_dyn_install(void);
|
|
4833
4859
|
#ifdef SCR_RC_AUDIT
|
|
@@ -4922,7 +4948,7 @@ ScrNetServer *scr_tls_create_server(const char *cert, size_t cert_len, const cha
|
|
|
4922
4948
|
* drop exactly like Node drops them). cert/key values are PEM strings,
|
|
4923
4949
|
* Buffers, or one-element arrays of those; `ca` (client side)
|
|
4924
4950
|
* concatenates array entries into one trust-anchor bundle. The *_dyn
|
|
4925
|
-
* creators walk a
|
|
4951
|
+
* creators walk a dyn options record (the checked-dynamic JS lane's
|
|
4926
4952
|
* shape) and mint the same servers the literal path mints; NULL returns
|
|
4927
4953
|
* carry a pending exception. scr_tls_pem_from_dyn is the literal path's
|
|
4928
4954
|
* runtime-valued cert/key extraction (`what` names the fence). */
|
|
@@ -5349,7 +5375,7 @@ void scr_http2_goaway_thunk0(ScrClosure *cb, double code, double last);
|
|
|
5349
5375
|
|
|
5350
5376
|
void scr_net_sock_set_native_established(ScrNetSocket *s, ScrNetNativeEventFn fn);
|
|
5351
5377
|
|
|
5352
|
-
/* Registers the h2 session/stream
|
|
5378
|
+
/* Registers the h2 session/stream dyn handle ops (the emitted main()
|
|
5353
5379
|
* calls it when the unit is linked — the scr_net_dyn_install story). */
|
|
5354
5380
|
void scr_http2_dyn_install(void);
|
|
5355
5381
|
|
|
@@ -5412,7 +5438,7 @@ void scr_dgram_bind(ScrDgramSocket *s, double port, ScrStr *host /*borrowed*/, S
|
|
|
5412
5438
|
void scr_dgram_connect(ScrDgramSocket *s, double port, ScrStr *host /*borrowed*/, ScrClosure *cb /*moves, nullable*/);
|
|
5413
5439
|
void scr_dgram_send_str(ScrDgramSocket *s, ScrStr *data /*borrowed*/, double port, ScrStr *host /*borrowed*/);
|
|
5414
5440
|
void scr_dgram_send_bytes(ScrDgramSocket *s, ScrBytes *data /*borrowed*/, double port, ScrStr *host /*borrowed*/);
|
|
5415
|
-
/* The send argument-validation ladder over
|
|
5441
|
+
/* The send argument-validation ladder over dyn arguments (Node's
|
|
5416
5442
|
* signature shuffle, slice bounds, list/type contracts, port/address
|
|
5417
5443
|
* validation, and the connected-state errors); a fully-validated
|
|
5418
5444
|
* unconnected single-payload send RUNS, the rest meet the fence. */
|
|
@@ -5576,14 +5602,14 @@ void scr_assert_neq_fail(const char *insp, size_t ilen, bool deep,
|
|
|
5576
5602
|
ScrStr *msg, bool has_msg);
|
|
5577
5603
|
/* strictEqual/notStrictEqual/deepStrictEqual/notDeepStrictEqual where
|
|
5578
5604
|
* either operand is a checked-dynamic value (the frontend boxes a static
|
|
5579
|
-
* side into the
|
|
5605
|
+
* side into the checked-dynamic tree first). Strict pair: SameValue over the dyn kinds —
|
|
5580
5606
|
* Object.is numbers, byte-equal strings, units by kind, node identity
|
|
5581
5607
|
* for arrays/objects/bytes, BOXED-CLOSURE identity for functions. Deep
|
|
5582
|
-
* pair: the structural
|
|
5608
|
+
* pair: the structural dyn walk (per-element arrays, key-set objects,
|
|
5583
5609
|
* brand-aware bytes via the buffer flavor bit, closure identity for
|
|
5584
5610
|
* functions). Generated messages reproduce assertion_error.js — the
|
|
5585
5611
|
* scalar simple/stacked forms byte-exactly, composite values rendered
|
|
5586
|
-
* compact:false/sorted through the
|
|
5612
|
+
* compact:false/sorted through the checked-dynamic tree and diffed with the real myers
|
|
5587
5613
|
* line printer (the design note atop scr_assert.c's dyn section lists
|
|
5588
5614
|
* the divergences). Borrows everything; throws on the failing verdict. */
|
|
5589
5615
|
void scr_assert_eq_dyn(ScrDyn *a, ScrDyn *b, bool negated, bool deep,
|
|
@@ -5592,7 +5618,7 @@ void scr_assert_eq_dyn(ScrDyn *a, ScrDyn *b, bool negated, bool deep,
|
|
|
5592
5618
|
* promise fulfilled): "Missing expected exception|rejection" with Node's
|
|
5593
5619
|
* details — ` (${expected.name})` when the expected class/shape carries a
|
|
5594
5620
|
* name (has_ename), then `: message` or `.`. */
|
|
5595
|
-
/* Node's expectsError over an error-INSTANCE expected: the expected
|
|
5621
|
+
/* Node's expectsError over an error-INSTANCE expected: the expected dyn
|
|
5596
5622
|
* error's keys (minus the %error marker) each deep-compare against the
|
|
5597
5623
|
* caught value's; mismatches throw the deep-equal AssertionError. */
|
|
5598
5624
|
void scr_assert_expects_err_dyn(ScrDyn *actual, ScrDyn *expected, ScrStr *msg, bool has_msg);
|
|
@@ -5630,7 +5656,7 @@ void scr_assert_iferror_err(ScrError *err);
|
|
|
5630
5656
|
void scr_assert_iferror_f64(double x);
|
|
5631
5657
|
void scr_assert_iferror_str(ScrStr *s);
|
|
5632
5658
|
void scr_assert_iferror_bool(bool b);
|
|
5633
|
-
/* The checked-dynamic argument:
|
|
5659
|
+
/* The checked-dynamic argument: dyn-kind dispatch — units pass quietly,
|
|
5634
5660
|
* %error-marked objects throw with the error's message, everything else
|
|
5635
5661
|
* with the inspection. */
|
|
5636
5662
|
void scr_assert_iferror_dyn(const ScrDyn *v);
|