@scriptc/runtime 0.0.10 → 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 +29 -9
- package/src/scr_async_dyn.c +24 -24
- package/src/scr_bytes.c +40 -3
- 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 +59 -6
- 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_library.c +15 -0
- package/src/scr_net.c +1 -1
- package/src/scr_qs.c +1 -1
- package/src/scr_regex.c +39 -6
- package/src/scr_runtime.h +204 -131
- package/src/scr_stream.c +218 -11
- package/src/scr_tls.c +3 -3
- package/src/scr_web.c +1 -1
package/src/scr_runtime.h
CHANGED
|
@@ -163,6 +163,12 @@ ScrStr *scr_library_str_in(const uint8_t *p, size_t len); /* +1 */
|
|
|
163
163
|
* (structured trap-teaching bytes naming this entry's symbol), delivered
|
|
164
164
|
* through the funnel when len falls outside the marshalling class. */
|
|
165
165
|
ScrBytes *scr_library_bytes_in(const uint8_t *p, size_t len, const char *trap_msg); /* +1, u8 */
|
|
166
|
+
/* The inbound declared-integer edge (ask 4's i64/u64 parameter classes):
|
|
167
|
+
* exact conversion for |v| <= 2^53-1, the host-contract trap (same
|
|
168
|
+
* assembled SC4012 message shape as the bytes trap) past it — silent
|
|
169
|
+
* rounding is a coercion the author never wrote. */
|
|
170
|
+
double scr_library_i64_in(int64_t v, const char *trap_msg);
|
|
171
|
+
double scr_library_u64_in(uint64_t v, const char *trap_msg);
|
|
166
172
|
void scr_library_str_out(ScrStr *s, const uint8_t **out, size_t *out_len);
|
|
167
173
|
void scr_library_bytes_out(ScrBytes *b, const uint8_t **out, size_t *out_len);
|
|
168
174
|
|
|
@@ -391,7 +397,7 @@ enum {
|
|
|
391
397
|
|
|
392
398
|
extern ScrVt scr_error_vts[5]; /* indexed by SCR_ERR_*; main() stamps pre/post */
|
|
393
399
|
|
|
394
|
-
struct ScrDyn; /* full declaration below (the
|
|
400
|
+
struct ScrDyn; /* full declaration below (the checked-dynamic tree section) */
|
|
395
401
|
|
|
396
402
|
/* DOMException: the ScrError prefix (identical member order — an upcast is
|
|
397
403
|
* a pointer reinterpret) plus the WebIDL slots. The extra slots are HIDDEN
|
|
@@ -409,11 +415,11 @@ typedef struct ScrDomException {
|
|
|
409
415
|
struct ScrDyn *cause; /* owned; NULL when has_cause is false */
|
|
410
416
|
} ScrDomException;
|
|
411
417
|
|
|
412
|
-
/* new DOMException(message?, nameOrOptions?) — both
|
|
413
|
-
* NULL-tolerant (NULL = absent = the
|
|
414
|
-
* 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
|
|
415
421
|
* values); the dyn-free half below stays in scr_error.c so the error
|
|
416
|
-
* unit links without the
|
|
422
|
+
* unit links without the checked-dynamic tree. */
|
|
417
423
|
ScrError *scr_domex_new(const struct ScrDyn *message, const struct ScrDyn *name_or_options);
|
|
418
424
|
/* scr_error.c's dyn-free DOMException half: the blank allocation the
|
|
419
425
|
* constructors fill, the WebIDL name→legacy-code table, and the cause
|
|
@@ -423,7 +429,7 @@ double scr_domex_code_of(const ScrStr *name);
|
|
|
423
429
|
void scr_domex_install_cause_drop(void (*fn)(void *obj));
|
|
424
430
|
double scr_domex_code(ScrError *e); /* borrowed receiver */
|
|
425
431
|
bool scr_domex_has_cause(ScrError *e); /* borrowed receiver */
|
|
426
|
-
struct ScrDyn *scr_domex_cause(ScrError *e); /* +1 (
|
|
432
|
+
struct ScrDyn *scr_domex_cause(ScrError *e); /* +1 (dyn undefined when absent) */
|
|
427
433
|
/* structuredClone of a DOMException: WebIDL serialization — name/message
|
|
428
434
|
* copy, the code re-derives, cause does not serialize. Borrowed receiver
|
|
429
435
|
* and options (validated; throws on bad options / non-empty transfer).
|
|
@@ -666,9 +672,9 @@ void scr_qs_parse_into(ScrMap *out, const ScrStr *qs, const ScrStr *sep,
|
|
|
666
672
|
const ScrStr *eq, double max_keys, uint32_t str_tag,
|
|
667
673
|
uint32_t arr_tag);
|
|
668
674
|
|
|
669
|
-
/* querystring.stringify — Node's stringify over a borrowed
|
|
675
|
+
/* querystring.stringify — Node's stringify over a borrowed dyn value (the
|
|
670
676
|
* frontend dynFroms the typed record; JS-world dyn values pass straight
|
|
671
|
-
* through). Non-object
|
|
677
|
+
* through). Non-object dyn values answer "" like Node; object keys iterate in
|
|
672
678
|
* JS own-key order (scr_dyn_obj_keys — array-index keys ascending first,
|
|
673
679
|
* then insertion order, Node's ObjectKeys). Values serialize per Node's
|
|
674
680
|
* encodeStringified: strings escape, finite numbers render shortest-
|
|
@@ -686,8 +692,8 @@ ScrStr *scr_qs_stringify(const struct ScrDyn *obj, const ScrStr *sep,
|
|
|
686
692
|
* well-formed-UTF-8 invariant. Borrows s; result +1. */
|
|
687
693
|
ScrStr *scr_encode_uri(ScrStr *s);
|
|
688
694
|
/* atob/btoa — the WHATWG base64 globals (Node globals since v16). The
|
|
689
|
-
* argument is a borrowed
|
|
690
|
-
*
|
|
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
|
|
691
697
|
* forgiving-base64 (ASCII whitespace stripped, %4==0 strips up to two
|
|
692
698
|
* '=', %4==1 refuses, leftover bits discarded) into the latin1 code
|
|
693
699
|
* points as a UTF-8 string; malformed input THROWS the catchable
|
|
@@ -1362,6 +1368,10 @@ bool scr_emitter_emit_error(ScrEmitter *em, ScrStr *name, ScrError *err);
|
|
|
1362
1368
|
double scr_emitter_listener_count(ScrEmitter *em, ScrStr *name);
|
|
1363
1369
|
double scr_emitter_listener_count_fn(ScrEmitter *em, ScrStr *name, ScrClosure *fn);
|
|
1364
1370
|
ScrArr *scr_emitter_event_names(ScrEmitter *em); /* +1 string[] */
|
|
1371
|
+
/* Pre-create a name's eventNames() rank with no listener (Node's stream
|
|
1372
|
+
* classes pre-create their known _events keys; empty = absent for every
|
|
1373
|
+
* other read). The stream constructors call this. */
|
|
1374
|
+
void scr_emitter_reserve(ScrEmitter *em, const char *name);
|
|
1365
1375
|
ScrArr *scr_emitter_listeners(ScrEmitter *em, ScrStr *name); /* +1 closures */
|
|
1366
1376
|
ScrEmitter *scr_emitter_set_max(ScrEmitter *em, double n); /* returns em +1 */
|
|
1367
1377
|
double scr_emitter_get_max(ScrEmitter *em);
|
|
@@ -1548,7 +1558,7 @@ void scr_stream_st_trace(ScrStreamState *st, ScrTraceVisit visit, void *ctx);
|
|
|
1548
1558
|
/* The dyn-flavored completion-callback glues (the JS lane's implicitly-
|
|
1549
1559
|
* any option callbacks / underscore methods): the emitted invoke thunks
|
|
1550
1560
|
* mint a callable dyn (scr_dyn_new_func) over a 1-cap closure boxing the
|
|
1551
|
-
* retained stream, with the kind's glue — arguments arrive as
|
|
1561
|
+
* retained stream, with the kind's glue — arguments arrive as dyn
|
|
1552
1562
|
* values (error: null/undefined, a {message} object, or a string;
|
|
1553
1563
|
* transform/flush data: bytes, a string, or absent). */
|
|
1554
1564
|
typedef struct ScrDyn ScrDyn; /* full declaration below (C11 repeat) */
|
|
@@ -1562,6 +1572,13 @@ ScrDyn *scr_stream_done_dyn_l(ScrClosure *clo, ScrDyn *const *args, size_t argc)
|
|
|
1562
1572
|
* utf8, Node's decodeStrings default); push answers the below-hwm bool. */
|
|
1563
1573
|
bool scr_stream_push(ScrStream *s, ScrBytes *chunk);
|
|
1564
1574
|
bool scr_stream_push_str(ScrStream *s, ScrStr *str);
|
|
1575
|
+
/* push(chunk, enc): the per-call literal encoding (canonical); overrides
|
|
1576
|
+
* the stream's defaultEncoding. Borrows both. */
|
|
1577
|
+
bool scr_stream_push_str_enc(ScrStream *s, ScrStr *str, ScrStr *enc);
|
|
1578
|
+
/* The defaultEncoding option's push side: how push(string) decodes chunks
|
|
1579
|
+
* (Buffer.from(chunk, enc)). Canonical literal, never "utf8". Receiver
|
|
1580
|
+
* answers +1 (the setEncoding chaining shape). */
|
|
1581
|
+
ScrStream *scr_stream_set_push_encoding(ScrStream *s, ScrStr *enc);
|
|
1565
1582
|
bool scr_stream_push_null(ScrStream *s);
|
|
1566
1583
|
void scr_stream_unshift(ScrStream *s, ScrBytes *chunk);
|
|
1567
1584
|
void scr_stream_unshift_str(ScrStream *s, ScrStr *str);
|
|
@@ -1591,6 +1608,18 @@ ScrPromise *scr_stream_next_chunk_dyn(ScrStream *s);
|
|
|
1591
1608
|
* Streams borrowed; +1 promises. */
|
|
1592
1609
|
ScrPromise *scr_sp_finished(ScrStream *s);
|
|
1593
1610
|
ScrPromise *scr_sp_pipeline(double n, ScrStream **streams);
|
|
1611
|
+
/* node:stream/consumers — the promise consumers over the readable
|
|
1612
|
+
* machinery: accumulate every chunk (string chunks as their utf8 bytes)
|
|
1613
|
+
* and settle at the terminal point (right after 'close', the eos timing
|
|
1614
|
+
* Node's consumers share) — text answers the utf8 decode, json parses
|
|
1615
|
+
* the text (malformed input rejects with the parse's SyntaxError; the
|
|
1616
|
+
* result is a +1 DOM tree), buffer the concatenated bytes. Stream
|
|
1617
|
+
* errors reject; an early close rejects ERR_STREAM_PREMATURE_CLOSE; a
|
|
1618
|
+
* stream with no readable side rejects Node's async-iterable TypeError.
|
|
1619
|
+
* Streams borrowed; +1 promises. */
|
|
1620
|
+
ScrPromise *scr_sc_text(ScrStream *s);
|
|
1621
|
+
ScrPromise *scr_sc_json(ScrStream *s);
|
|
1622
|
+
ScrPromise *scr_sc_buffer(ScrStream *s);
|
|
1594
1623
|
/* Readable.from(array): +1 fully-seeded object-entry stream (one WHOLE
|
|
1595
1624
|
* chunk per element — strings or Buffers per the flag; hwm 1, already
|
|
1596
1625
|
* EOF'd). Borrows arr. */
|
|
@@ -1780,7 +1809,7 @@ ScrStr *scr_caught_to_string(const ScrCaught *c);
|
|
|
1780
1809
|
* checks. */
|
|
1781
1810
|
void *scr_caught_check_obj(const ScrCaught *c, size_t pre, size_t post,
|
|
1782
1811
|
const char *cls);
|
|
1783
|
-
/* The snapshot as a
|
|
1812
|
+
/* The snapshot as a dyn value (scr_json.c): identity-preserving for dyn
|
|
1784
1813
|
* payloads and %Error instances, scalars by value, the type-erased empty
|
|
1785
1814
|
* object for the rest (SEMANTICS.md 67). Borrows the box; +1. */
|
|
1786
1815
|
typedef struct ScrDyn ScrDyn; /* full definition below (C11 repeat) */
|
|
@@ -2033,7 +2062,7 @@ ScrPromise *scr_tp_set_immediate(void);
|
|
|
2033
2062
|
* A process-global name→channel registry; channel handles are 1-based
|
|
2034
2063
|
* f64 indexes into it (Node's channels are process-lived too, its
|
|
2035
2064
|
* WeakRef machinery aside — the registry tears down atexit before the
|
|
2036
|
-
* RC audit). Subscribers are
|
|
2065
|
+
* RC audit). Subscribers are dyn FUNCTION values, identity-matched by
|
|
2037
2066
|
* unsubscribe (the underlying closure, so re-boxings of one function
|
|
2038
2067
|
* still match — JS has ONE function object). publish calls each
|
|
2039
2068
|
* subscriber of a SNAPSHOT with (message, name); a subscriber's throw
|
|
@@ -2057,8 +2086,8 @@ ScrStr *scr_dc_chan_name(double handle);
|
|
|
2057
2086
|
* handlers object's five event keys (truthy slots route to the per-channel
|
|
2058
2087
|
* add/remove — a non-function slot throws there, Node's order);
|
|
2059
2088
|
* unsubscribe answers Node's all-found conjunction. traceSync/traceCallback
|
|
2060
|
-
* mirror Node's publish choreography over the
|
|
2061
|
-
* 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
|
|
2062
2091
|
* an ARR of the call arguments); the traced call binds thisArg as the
|
|
2063
2092
|
* ambient receiver; result/error stamp onto ctx before end/error publish;
|
|
2064
2093
|
* a traced throw and a subscriber throw both propagate (MAY THROW). All
|
|
@@ -2524,15 +2553,15 @@ double scr_os_ifaddrs_scopeid(const ScrIfaddrs *s, size_t i);
|
|
|
2524
2553
|
void scr_os_ifaddrs_free(ScrIfaddrs *s);
|
|
2525
2554
|
|
|
2526
2555
|
/* ── JSON + dynamic values (scr_json.c) ─────────────────────────────
|
|
2527
|
-
* 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
|
|
2528
2557
|
* tree: the result of JSON.parse, inert until a CHECKED CAST validates it
|
|
2529
2558
|
* against a static type. The compiler emits the validation walkers
|
|
2530
2559
|
* (sc_dc_* builders / sc_dm_* match predicates) and the type-directed
|
|
2531
2560
|
* stringify serializers (sc_jw_*) per program; this runtime slice provides
|
|
2532
|
-
* the
|
|
2561
|
+
* the checked-dynamic tree itself, the RFC 8259 parser, the shared failure path
|
|
2533
2562
|
* (scr_dyn_check_fail), and the output buffer the serializers append to.
|
|
2534
2563
|
*
|
|
2535
|
-
* Ownership: the
|
|
2564
|
+
* Ownership: the checked-dynamic tree owns its children (strings, items, entry keys+values);
|
|
2536
2565
|
* releasing the root releases the tree recursively. scr_json_parse borrows
|
|
2537
2566
|
* the text and returns +1 — or THROWS a catchable string shaped like Node's
|
|
2538
2567
|
* V8 messages ("Unexpected end of JSON input"; approximate fidelity, see
|
|
@@ -2548,15 +2577,15 @@ typedef enum {
|
|
|
2548
2577
|
SCR_DYN_ARR,
|
|
2549
2578
|
SCR_DYN_OBJ,
|
|
2550
2579
|
/* The undefined VALUE. Never produced by the parser (JSON text has no
|
|
2551
|
-
* undefined) — it enters the
|
|
2580
|
+
* undefined) — it enters the checked-dynamic tree through index-signature overflow reads
|
|
2552
2581
|
* (a missing key), optional-chain unit paths on dyn results, and the
|
|
2553
|
-
* compiler's static→
|
|
2582
|
+
* compiler's static→dyn converters (an undefined-armed union's unit
|
|
2554
2583
|
* arm). One immortal instance (scr_dyn_undefined); JSON serialization
|
|
2555
2584
|
* drops object members holding it and prints null for array slots,
|
|
2556
2585
|
* exactly Node. dynCheck matches it against exactly the undefined arm. */
|
|
2557
2586
|
SCR_DYN_UNDEF,
|
|
2558
2587
|
/* A Uint8Array/Buffer VALUE. Never produced by the parser — it enters
|
|
2559
|
-
* the
|
|
2588
|
+
* the checked-dynamic tree through the compiler's static→dyn converters (a bytes<u8>
|
|
2560
2589
|
* value flowing into an `unknown` slot: stdin chunks passed to
|
|
2561
2590
|
* unknown-typed helpers). Owns a ScrBytes payload (a COPY of the static
|
|
2562
2591
|
* source — the boundary's aliasing stance). typeof answers "object"
|
|
@@ -2565,13 +2594,13 @@ typedef enum {
|
|
|
2565
2594
|
* object form ({"0":1}), and dynCheck extracts a fresh copy against a
|
|
2566
2595
|
* Uint8Array target. */
|
|
2567
2596
|
SCR_DYN_BYTES,
|
|
2568
|
-
/* A FUNCTION value. Never produced by the parser — it enters the
|
|
2569
|
-
* 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
|
|
2570
2599
|
* into an `unknown` slot: `mustCall(fn)`-style untyped JS helpers). Owns
|
|
2571
2600
|
* a ScrClosure plus a compiler-emitted CALL THUNK that validates dyn
|
|
2572
2601
|
* arguments into the closure's declared parameter types (per-arg
|
|
2573
2602
|
* dynCheck — JS arity semantics: extra args ignored, missing args are
|
|
2574
|
-
* the undefined
|
|
2603
|
+
* the undefined dyn value) and converts the result back to a dyn value.
|
|
2575
2604
|
* `sig` is the compiler's interned signature key: dynCheck against an
|
|
2576
2605
|
* IDENTICAL function type unwraps the closure directly; any other
|
|
2577
2606
|
* (adaptable) function target wraps the box in a per-target adapter
|
|
@@ -2583,7 +2612,7 @@ typedef enum {
|
|
|
2583
2612
|
/* A NATIVE HANDLE value (httpReq/httpRes/netSocket crossing the checked-
|
|
2584
2613
|
* dynamic boundary — `server.on('request', mustCall((req, res) => ...))`
|
|
2585
2614
|
* makes the listener dyn, so the event tuple must box). Never produced
|
|
2586
|
-
* by the parser — it enters the
|
|
2615
|
+
* by the parser — it enters the checked-dynamic tree through the compiler's static→dyn
|
|
2587
2616
|
* converters and the per-target function adapters. Boxes by REFERENCE
|
|
2588
2617
|
* (a retained pointer + a handle-type tag): handles are stateful I/O
|
|
2589
2618
|
* objects, so identity is the HANDLE, not the box — strict equality
|
|
@@ -2598,12 +2627,12 @@ typedef enum {
|
|
|
2598
2627
|
* "[object Object]" (Object.prototype.toString — Node's answer for
|
|
2599
2628
|
* these classes), JSON serialization and util.inspect fence loudly. */
|
|
2600
2629
|
SCR_DYN_HANDLE,
|
|
2601
|
-
/* A PROMISE value. Never produced by the parser — it enters the
|
|
2602
|
-
* 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
|
|
2603
2632
|
* an `any`/`unknown` slot: the traced-function boundary of
|
|
2604
2633
|
* dc.tracingChannel.tracePromise, a dyn-boxed async closure's return).
|
|
2605
2634
|
* Boxes by REFERENCE (a retained ScrPromise + the boundary contract
|
|
2606
|
-
* that a
|
|
2635
|
+
* that a dyn-crossing promise settles with a dyn payload: promise<dyn>
|
|
2607
2636
|
* boxes its ScrPromise directly, other inner types box an ADAPTER
|
|
2608
2637
|
* promise whose emitted settle callback converts the payload — see
|
|
2609
2638
|
* scr_dyn_new_promise_adapting). Identity is the PROMISE, not the box
|
|
@@ -2617,31 +2646,31 @@ typedef enum {
|
|
|
2617
2646
|
* (the dyn→closure stance): a cycle THROUGH a dyn-boxed promise is
|
|
2618
2647
|
* merely never collected. */
|
|
2619
2648
|
SCR_DYN_PROMISE,
|
|
2620
|
-
/* An ISLAND (engine-held) value — the jsval→
|
|
2621
|
-
* 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
|
|
2622
2651
|
* constructor scr_dyn_from_jsval (scr_island.c): an 'any'-typed value
|
|
2623
2652
|
* flowing into an 'unknown'/'object'/JS-residue slot. Boxes by
|
|
2624
2653
|
* REFERENCE (a retained ScrJsval cell). The constructor SCALAR-
|
|
2625
2654
|
* NORMALIZES: engine numbers/strings/booleans/null/undefined convert
|
|
2626
|
-
* to the native
|
|
2655
|
+
* to the native dyn kinds at wrap time, so JSVAL nodes only ever hold
|
|
2627
2656
|
* engine objects, arrays, and functions (plus the symbol/bigint edge —
|
|
2628
|
-
* kinds the
|
|
2657
|
+
* kinds the checked-dynamic tree cannot represent at all). Identity is the CELL's
|
|
2629
2658
|
* engine value: strict equality routes to the engine's === (two wraps
|
|
2630
2659
|
* of one engine value compare equal), and scr_jsval_from_dyn unwraps
|
|
2631
2660
|
* the SAME cell back (+1) — the boundary is identity-preserving for
|
|
2632
2661
|
* engine-born values. typeof/truthiness/String() route to the engine
|
|
2633
|
-
* per use (scr_dyn_jsval_ops); every
|
|
2662
|
+
* per use (scr_dyn_jsval_ops); every dyn walk without an armed route
|
|
2634
2663
|
* (JSON, structuredClone, deepStrictEqual, inspect, keyed access,
|
|
2635
2664
|
* calls, iteration) throws the LOUD "not supported yet" ladder — never
|
|
2636
2665
|
* a silent wrong answer. The dyn→cell edge is NOT visible to the cycle
|
|
2637
|
-
* collector (the dyn→closure stance): a cycle
|
|
2638
|
-
* object → host closure →
|
|
2666
|
+
* collector (the dyn→closure stance): a cycle dyn → cell → engine
|
|
2667
|
+
* object → host closure → dyn is merely never collected (the
|
|
2639
2668
|
* documented cross-boundary-cycle divergence). Enum position: LAST —
|
|
2640
2669
|
* the LLVM backend hardcodes the preceding kind numbers. */
|
|
2641
2670
|
SCR_DYN_JSVAL,
|
|
2642
2671
|
} ScrDynKind;
|
|
2643
2672
|
|
|
2644
|
-
/* The handle-type tags the
|
|
2673
|
+
/* The handle-type tags the checked-dynamic tree can carry. The set is deliberately the
|
|
2645
2674
|
* HANDLE kinds whose member surfaces already have complete static
|
|
2646
2675
|
* lowerings (the http/net receiver surface); new kinds join by adding a
|
|
2647
2676
|
* tag + an ops registration in their owning unit. */
|
|
@@ -2659,7 +2688,7 @@ typedef struct ScrDyn ScrDyn;
|
|
|
2659
2688
|
typedef struct ScrBytes ScrBytes; /* full definition below (C11 repeat) */
|
|
2660
2689
|
typedef struct ScrClosure ScrClosure; /* full definition below (C11 repeat) */
|
|
2661
2690
|
typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
2662
|
-
* always-linked
|
|
2691
|
+
* always-linked dyn core never touches
|
|
2663
2692
|
* its engine value — only the gated ops
|
|
2664
2693
|
* installed by scr_dyn_from_jsval do) */
|
|
2665
2694
|
|
|
@@ -2667,7 +2696,7 @@ typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
|
2667
2696
|
* dyn arguments against the boxed closure's declared parameter types (a
|
|
2668
2697
|
* mismatch throws the catchable path-annotated TypeError and returns NULL
|
|
2669
2698
|
* with the exception pending), calls through the closure, and returns the
|
|
2670
|
-
* result as an owned (+1)
|
|
2699
|
+
* result as an owned (+1) dyn value. `args` entries are BORROWED. */
|
|
2671
2700
|
typedef ScrDyn *(*ScrDynThunk)(ScrClosure *clo, ScrDyn *const *args, size_t argc);
|
|
2672
2701
|
|
|
2673
2702
|
/* Object member. Keys are malloc'd UTF-8 bytes (NUL-terminated for
|
|
@@ -2688,7 +2717,7 @@ struct ScrDyn {
|
|
|
2688
2717
|
* its elements ("1,2,3"). Everything else ignores it. */
|
|
2689
2718
|
bool buffer;
|
|
2690
2719
|
/* SCR_DYN_OBJ flavor: true for Object.create(null)'s dictionary — an
|
|
2691
|
-
* object with NO prototype. Method dispatch needs nothing (the
|
|
2720
|
+
* object with NO prototype. Method dispatch needs nothing (the checked-dynamic tree's
|
|
2692
2721
|
* OBJ dispatch is already own-member-only, which IS Node's null-proto
|
|
2693
2722
|
* answer); util.inspect prefixes "[Object: null prototype]", and
|
|
2694
2723
|
* deepStrictEqual separates it from plain objects (Node compares
|
|
@@ -2719,7 +2748,7 @@ struct ScrDyn {
|
|
|
2719
2748
|
* settle — the settle-releases-listeners story. */
|
|
2720
2749
|
struct { void *ptr; ScrDynHandleTag tag; } handle;
|
|
2721
2750
|
/* SCR_DYN_PROMISE: the retained promise. The boundary contract: it
|
|
2722
|
-
* settles with a
|
|
2751
|
+
* settles with a dyn payload (SCR_EXC_REF ScrDyn fulfillment or a
|
|
2723
2752
|
* void fulfillment awaiters read as the undefined value) — the
|
|
2724
2753
|
* emitted converters guarantee it (direct box for promise<dyn>,
|
|
2725
2754
|
* adapter promise otherwise). */
|
|
@@ -2747,22 +2776,22 @@ ScrDyn *scr_json_parse(ScrStr *text);
|
|
|
2747
2776
|
/* BORROWED member lookup on a SCR_DYN_OBJ; NULL when the key is absent. */
|
|
2748
2777
|
ScrDyn *scr_dyn_obj_get(const ScrDyn *d, const char *key, size_t key_len);
|
|
2749
2778
|
|
|
2750
|
-
/* Object.keys/values/entries over the
|
|
2751
|
-
* 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
|
|
2752
2781
|
* member nodes. null/undefined receivers throw Node's catchable
|
|
2753
2782
|
* TypeError. */
|
|
2754
2783
|
ScrDyn *scr_dyn_obj_keys(const ScrDyn *v);
|
|
2755
|
-
/* Object.hasOwn over a
|
|
2784
|
+
/* Object.hasOwn over a dyn receiver: OBJ member presence, ARR index
|
|
2756
2785
|
* bounds ("length" included); nullish receivers throw Node's ToObject
|
|
2757
2786
|
* TypeError; every other kind answers false. */
|
|
2758
2787
|
bool scr_dyn_has_own(const ScrDyn *v, const ScrStr *key);
|
|
2759
|
-
/* Object.assign over
|
|
2788
|
+
/* Object.assign over dyn values (+1 target back; ToObject TypeError on a
|
|
2760
2789
|
* nullish target). Sources copy their own enumerable keys exactly as
|
|
2761
2790
|
* Object.keys lists them: OBJ members, ARR/STR/BYTES index keys; nullish
|
|
2762
2791
|
* and scalar/function/handle sources copy nothing. */
|
|
2763
2792
|
ScrDyn *scr_dyn_assign(ScrDyn *target, const ScrDyn *src);
|
|
2764
2793
|
/* Variadic Object.assign (the spread-source form): the compiler packs
|
|
2765
|
-
* every source into one fresh
|
|
2794
|
+
* every source into one fresh dyn array — pack_push retains a plain
|
|
2766
2795
|
* source in (BORROWED), pack_push_spread flattens a spread source through
|
|
2767
2796
|
* the spread-call walk (V8's exact TypeError texts, `what` spelling the
|
|
2768
2797
|
* spread expression; MAY THROW pending) — then assign_all copies each
|
|
@@ -2778,8 +2807,8 @@ ScrDyn *scr_dyn_assign_all(ScrDyn *target, const ScrDyn *sources);
|
|
|
2778
2807
|
ScrDyn *scr_dyn_obj_values(const ScrDyn *v);
|
|
2779
2808
|
ScrDyn *scr_dyn_obj_entries(const ScrDyn *v);
|
|
2780
2809
|
|
|
2781
|
-
/*
|
|
2782
|
-
* 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.
|
|
2783
2812
|
* Constructors return +1; _new_str RETAINS the string into the node.
|
|
2784
2813
|
* arr_push and obj_set take OWNERSHIP of the value (+1 moves in); obj_set
|
|
2785
2814
|
* COPIES the key bytes and replaces a duplicate key's value (later wins,
|
|
@@ -2807,25 +2836,32 @@ ScrBytes *scr_dyn_bytes_copy_out(const ScrDyn *d);
|
|
|
2807
2836
|
void scr_dyn_arr_push(ScrDyn *arr, ScrDyn *item);
|
|
2808
2837
|
/* Spread completion for a runtime-arity argument list (`f(...xs)` in the
|
|
2809
2838
|
* checked-dynamic tier): flattens `src` into `arr` per JS's spread over the
|
|
2810
|
-
*
|
|
2839
|
+
* dyn's iterable kinds — arrays element-by-element (retained), strings by
|
|
2811
2840
|
* code POINT (the string iterator), bytes by byte — and throws V8's exact
|
|
2812
2841
|
* SPREAD-CALL TypeError for every other kind (pending; callers check):
|
|
2813
2842
|
* nullish sources spell the spread expression (`what`), everything else is
|
|
2814
2843
|
* the generic "Spread syntax requires ..." text. Borrows src. */
|
|
2815
2844
|
void scr_dyn_arr_push_spread(ScrDyn *arr, const ScrDyn *src, const char *what);
|
|
2816
|
-
/* Destructuring pack over a
|
|
2845
|
+
/* Destructuring pack over a dyn source: iterable kinds (arrays, strings by
|
|
2817
2846
|
* code point, bytes) collect into a fresh array (+1); every other kind
|
|
2818
2847
|
* throws V8's destructuring TypeError — `msg` verbatim when non-empty (the
|
|
2819
2848
|
* compile-time source spelling), else the runtime kind wording. Borrows
|
|
2820
2849
|
* both; NULL with the exception pending on the throw. */
|
|
2821
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);
|
|
2822
2858
|
void scr_dyn_obj_set(ScrDyn *obj, const char *key, size_t key_len, ScrDyn *value);
|
|
2823
2859
|
/* The checked-dynamic keyed WRITE (`h.k = v` on a dyn receiver): OBJ sets
|
|
2824
2860
|
* the member (JS: later writes win, insertion order); undefined/null and
|
|
2825
2861
|
* non-object kinds throw Node's catchable TypeErrors (strict-mode
|
|
2826
2862
|
* wording). All three operands BORROWED (the value is retained in). */
|
|
2827
2863
|
void scr_dyn_key_set(ScrDyn *recv, ScrStr *key, ScrDyn *value);
|
|
2828
|
-
/* Bare `typeof v` on a dyn value: the
|
|
2864
|
+
/* Bare `typeof v` on a dyn value: the dyn kind's JS answer (+1 string;
|
|
2829
2865
|
* null answers "object"). Never throws. */
|
|
2830
2866
|
ScrStr *scr_dyn_typeof(const ScrDyn *d);
|
|
2831
2867
|
/* Receiver-kind-dispatched toString() (Buffer-flavored bytes decode per
|
|
@@ -2836,7 +2872,7 @@ ScrStr *scr_dyn_to_string(const ScrDyn *d, const ScrStr *enc);
|
|
|
2836
2872
|
* null-prototype dictionary throws "<what> is not a function" — its
|
|
2837
2873
|
* prototype chain has no toString (Node's answer). */
|
|
2838
2874
|
ScrStr *scr_dyn_to_string_method(const ScrDyn *d, const ScrStr *enc, const ScrStr *what);
|
|
2839
|
-
/* JS String() over the
|
|
2875
|
+
/* JS String() over the dyn kind (units render "null"/"undefined" where
|
|
2840
2876
|
* scr_dyn_to_string throws) — the web globals' WebIDL ToString. +1. */
|
|
2841
2877
|
ScrStr *scr_dyn_string_coerce(const ScrDyn *d);
|
|
2842
2878
|
/* JS ToString WITH the object protocol (user toString/valueOf members
|
|
@@ -2845,14 +2881,14 @@ ScrStr *scr_dyn_string_coerce(const ScrDyn *d);
|
|
|
2845
2881
|
ScrStr *scr_dyn_string_coerce_js(const ScrDyn *d);
|
|
2846
2882
|
|
|
2847
2883
|
/* `d instanceof TypeError` (and the other builtin error classes) on a
|
|
2848
|
-
* checked-dynamic value: the from_error cache resolves the
|
|
2884
|
+
* checked-dynamic value: the from_error cache resolves the dyn encoding
|
|
2849
2885
|
* back to its runtime error and the class's stamped preorder interval
|
|
2850
|
-
* answers. A
|
|
2886
|
+
* answers. A dyn value that never came from an error answers false. */
|
|
2851
2887
|
bool scr_dyn_err_instanceof(const ScrDyn *d, double kind);
|
|
2852
2888
|
|
|
2853
|
-
/* structuredClone over the
|
|
2889
|
+
/* structuredClone over the checked-dynamic tree: JSON-safe data + bytes deep-copy;
|
|
2854
2890
|
* functions/handles throw the spec's catchable DataCloneError; cycles
|
|
2855
|
-
* throw the scriptc fence (the
|
|
2891
|
+
* throw the scriptc fence (the checked-dynamic tree cannot represent them). Option
|
|
2856
2892
|
* validation (shared with scr_domex_clone) throws Node's exact
|
|
2857
2893
|
* TypeErrors; any non-empty transfer list throws DataCloneError. The
|
|
2858
2894
|
* _missing form is the zero-argument call: always throws Node's
|
|
@@ -2860,13 +2896,13 @@ bool scr_dyn_err_instanceof(const ScrDyn *d, double kind);
|
|
|
2860
2896
|
ScrDyn *scr_structured_clone(const ScrDyn *value, const ScrDyn *options);
|
|
2861
2897
|
ScrDyn *scr_structured_clone_missing(void);
|
|
2862
2898
|
ScrDyn *scr_structured_clone_transfer_fail(void); /* always throws DataCloneError */
|
|
2863
|
-
/* Validates a structuredClone options
|
|
2899
|
+
/* Validates a structuredClone options dyn value (throws on failure —
|
|
2864
2900
|
* callers must check scr_exc_pending). Borrowed, NULL-tolerant. */
|
|
2865
2901
|
void scr_sc_validate_options(const ScrDyn *options);
|
|
2866
|
-
/* An %Error as the boundary's
|
|
2902
|
+
/* An %Error as the boundary's dyn shape ({name, message[, code]}).
|
|
2867
2903
|
* Borrows; +1. */
|
|
2868
2904
|
ScrDyn *scr_dyn_from_error(const ScrError *e);
|
|
2869
|
-
/* The reverse extraction, riding the same identity cache: a
|
|
2905
|
+
/* The reverse extraction, riding the same identity cache: a dyn error
|
|
2870
2906
|
* that came from a runtime ScrError answers THAT instance (+1;
|
|
2871
2907
|
* out-and-back crossings compare reference-equal); alien %error objects
|
|
2872
2908
|
* rebuild once and enter the cache. Borrows d. */
|
|
@@ -2875,16 +2911,16 @@ ScrError *scr_error_from_dyn(const ScrDyn *d); /* scr_async_dyn.c (gated) */
|
|
|
2875
2911
|
* the gated extraction reads/writes through these). */
|
|
2876
2912
|
ScrError *scr_errdyn_err_of(const ScrDyn *d); /* +1 or NULL */
|
|
2877
2913
|
void scr_errdyn_put(ScrError *e, ScrDyn *d); /* retains both sides */
|
|
2878
|
-
/* ToBoolean over the
|
|
2914
|
+
/* ToBoolean over the dyn kind (JS-exact); borrowed, never throws. */
|
|
2879
2915
|
bool scr_dyn_truthy(const ScrDyn *d);
|
|
2880
|
-
/* JS String() over a
|
|
2916
|
+
/* JS String() over a dyn value (arrays join, [object Object], the error
|
|
2881
2917
|
* encoding renders "name: message"); borrowed, result +1, never throws. */
|
|
2882
2918
|
ScrStr *scr_dyn_display(const ScrDyn *d);
|
|
2883
|
-
/* JS === over two
|
|
2919
|
+
/* JS === over two dyn values: scalars by value, units by kind, everything
|
|
2884
2920
|
* reference-shaped by node identity. Borrowed; never throws. */
|
|
2885
2921
|
bool scr_dyn_strict_eq(const ScrDyn *a, const ScrDyn *b);
|
|
2886
2922
|
/* Prototype-method dispatch on a dyn receiver (`recv.m(...)` where `m` is
|
|
2887
|
-
* a name a
|
|
2923
|
+
* a name a dyn-representable prototype declares — push/slice/forEach/
|
|
2888
2924
|
* apply/...): implemented (kind, name) pairs run JS-exact semantics; a
|
|
2889
2925
|
* real-but-unimplemented method throws a LOUD "not supported yet" Error;
|
|
2890
2926
|
* a name the kind's prototype lacks throws Node's "<what> is not a
|
|
@@ -2896,14 +2932,14 @@ ScrDyn *scr_dyn_invoke(ScrDyn *recv, const char *method, ScrDyn *const *args, si
|
|
|
2896
2932
|
* for anonymous) and "length" (the boxed arity). Returns +1, or NULL when
|
|
2897
2933
|
* the key answers nothing (the caller's undefined). Never throws. */
|
|
2898
2934
|
ScrDyn *scr_dyn_fn_get(const ScrDyn *d, const char *key, size_t key_len);
|
|
2899
|
-
/* Object.defineProperties over
|
|
2935
|
+
/* Object.defineProperties over dyn values (targets: OBJ and FUNC): each
|
|
2900
2936
|
* descriptor's `value` becomes a plain own property — writable/enumerable/
|
|
2901
|
-
* configurable are accepted and IGNORED (
|
|
2937
|
+
* configurable are accepted and IGNORED (dyn properties are plain data
|
|
2902
2938
|
* properties; SEMANTICS.md), get/set throw the loud unsupported Error.
|
|
2903
2939
|
* Returns the target (+1, JS's return), or NULL with a pending catchable
|
|
2904
2940
|
* TypeError (non-object target/descriptor — Node's messages). */
|
|
2905
2941
|
ScrDyn *scr_dyn_define_props(ScrDyn *target, ScrDyn *descs);
|
|
2906
|
-
/* Boxes a closure as a callable
|
|
2942
|
+
/* Boxes a closure as a callable dyn value. Ownership of `clo` MOVES in
|
|
2907
2943
|
* (callers retain first when they keep their own reference); `sig`/`name`
|
|
2908
2944
|
* must be static literals (the box never frees them; name may be NULL). */
|
|
2909
2945
|
ScrDyn *scr_dyn_new_func(ScrClosure *clo, ScrDynThunk thunk, uint32_t arity, const char *sig, const char *name);
|
|
@@ -2913,7 +2949,7 @@ ScrDyn *scr_dyn_new_func(ScrClosure *clo, ScrDynThunk thunk, uint32_t arity, con
|
|
|
2913
2949
|
* boxed thunk (per-arg checks live there). `args` entries are BORROWED;
|
|
2914
2950
|
* the result is owned (+1), or NULL with the exception pending. */
|
|
2915
2951
|
ScrDyn *scr_dyn_call(const ScrDyn *d, ScrDyn *const *args, size_t argc, const char *what);
|
|
2916
|
-
/* scr_dyn_call over a
|
|
2952
|
+
/* scr_dyn_call over a dyn ARRAY's elements (the spread-application form —
|
|
2917
2953
|
* `f(...args)` after the emitted argument array is built): argv IS the
|
|
2918
2954
|
* array's items. Borrows both; result owned (+1), or NULL pending. */
|
|
2919
2955
|
ScrDyn *scr_dyn_apply(const ScrDyn *d, const ScrDyn *args, const char *what);
|
|
@@ -2935,7 +2971,7 @@ typedef struct ScrDynPath {
|
|
|
2935
2971
|
* scriptc-specific behavior — JS `as` never checks (SEMANTICS.md). */
|
|
2936
2972
|
void scr_dyn_check_fail(const ScrDynPath *path, const char *want, const ScrDyn *got);
|
|
2937
2973
|
|
|
2938
|
-
/* ── native handles in the
|
|
2974
|
+
/* ── native handles in the checked-dynamic tree (SCR_DYN_HANDLE) ────────────────────────
|
|
2939
2975
|
* Per-tag dispatch ops, registered by the handle's owning unit
|
|
2940
2976
|
* (scr_http_dyn_install / scr_net_dyn_install — emitted main() calls
|
|
2941
2977
|
* them exactly when the unit is linked, the scr_net_install story), so
|
|
@@ -2954,7 +2990,7 @@ typedef struct ScrDynHandleOps {
|
|
|
2954
2990
|
ScrDyn *(*invoke)(void *h, ScrDyn *self, const char *method, ScrDyn *const *args, size_t argc, const char *what);
|
|
2955
2991
|
/* Property READ with a static equivalent (req.url, res.statusCode):
|
|
2956
2992
|
* +1 boxed value; NULL = no such modeled property (the caller answers
|
|
2957
|
-
* the undefined singleton — the
|
|
2993
|
+
* the undefined singleton — the checked-dynamic tree's own-property stance); may throw
|
|
2958
2994
|
* the loud ladder for real-but-unmodeled names (NULL + pending). */
|
|
2959
2995
|
ScrDyn *(*get)(void *h, const char *key, size_t key_len);
|
|
2960
2996
|
/* Property WRITE with a static equivalent (res.statusCode = 200):
|
|
@@ -2990,13 +3026,13 @@ ScrDyn *scr_dyn_new_handle(void *h, ScrDynHandleTag tag);
|
|
|
2990
3026
|
void *scr_dyn_handle_unbox(const ScrDyn *d, ScrDynHandleTag tag, const ScrDynPath *path, const char *want);
|
|
2991
3027
|
/* Keyed read on a HANDLE box (the emitted sc_dyn_key_get's arm): the
|
|
2992
3028
|
* tag's modeled properties answer boxed values; everything else answers
|
|
2993
|
-
* the undefined singleton (the
|
|
3029
|
+
* the undefined singleton (the checked-dynamic tree's own-property stance — SEMANTICS.md)
|
|
2994
3030
|
* unless the ops fence it loudly. +1, or NULL with a pending exception. */
|
|
2995
3031
|
ScrDyn *scr_dyn_handle_key_get(const ScrDyn *d, const ScrStr *k);
|
|
2996
3032
|
|
|
2997
|
-
/* ── promises in the
|
|
3033
|
+
/* ── promises in the checked-dynamic tree (SCR_DYN_PROMISE) ────────────────────────────
|
|
2998
3034
|
* Boxes by REFERENCE (+1 box; retains p). The boundary contract: p
|
|
2999
|
-
* settles with a
|
|
3035
|
+
* settles with a dyn payload — promise<dyn> boxes directly; other inner
|
|
3000
3036
|
* types go through scr_dyn_new_promise_adapting, which parks an emitted
|
|
3001
3037
|
* payload-converting adapter (the Promise.race cb-waiter machinery) on
|
|
3002
3038
|
* `src` and boxes the fresh destination promise instead. Rejections copy
|
|
@@ -3013,7 +3049,7 @@ ScrDyn *scr_dyn_new_promise_adapting(ScrPromise *src,
|
|
|
3013
3049
|
/* BORROWED peek at the boxed promise; NULL when d is not a promise box. */
|
|
3014
3050
|
ScrPromise *scr_dyn_promise_of(const ScrDyn *d);
|
|
3015
3051
|
|
|
3016
|
-
/* ── island values in the
|
|
3052
|
+
/* ── island values in the checked-dynamic tree (SCR_DYN_JSVAL) ─────────────────────────
|
|
3017
3053
|
* Engine routing ops for JSVAL nodes, installed by the gated constructor
|
|
3018
3054
|
* (scr_dyn_from_jsval, scr_island.c — the scr_dyn_alloc_promise hook
|
|
3019
3055
|
* story: JSVAL nodes exist only after the constructor ran, so the ops
|
|
@@ -3033,7 +3069,7 @@ typedef struct ScrDynJsvalOps {
|
|
|
3033
3069
|
/* ── the routed operation set (lane dyn-routing-ops) ────────────────
|
|
3034
3070
|
* Each routes to the engine at the moment of use and converts at the
|
|
3035
3071
|
* boundary: dyn ARGUMENTS cross through scr_jsval_from_dyn (wrapped
|
|
3036
|
-
* cells unwrap by reference,
|
|
3072
|
+
* cells unwrap by reference, dyn data deep-copies, dyn FUNC boxes
|
|
3037
3073
|
* cross through the generic host-function shim), engine RESULTS come
|
|
3038
3074
|
* back through scr_dyn_from_jsval (scalar-normalizing). Fallible ops
|
|
3039
3075
|
* bridge the ENGINE's exception catchably and answer NULL/false/-1. */
|
|
@@ -3048,19 +3084,28 @@ typedef struct ScrDynJsvalOps {
|
|
|
3048
3084
|
bool (*is_nullish)(ScrJsval *cell); /* engine undefined/null; never throws
|
|
3049
3085
|
* (always false today — the wrap
|
|
3050
3086
|
* constructor scalar-normalizes) */
|
|
3051
|
-
/* Object.keys/values/entries (mode 0/1/2) as a NATIVE
|
|
3052
|
-
* keys are
|
|
3053
|
-
*
|
|
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. */
|
|
3054
3090
|
ScrDyn *(*obj_walk)(ScrJsval *cell, int mode);
|
|
3055
3091
|
int (*has_own)(ScrJsval *cell, const ScrStr *k); /* 0/1; -1 = pending */
|
|
3056
3092
|
/* Object.assign(target, src) with the ENGINE target: src converts per
|
|
3057
|
-
* member semantics (a wrapped src spreads by reference;
|
|
3093
|
+
* member semantics (a wrapped src spreads by reference; dyn data
|
|
3058
3094
|
* enters as the usual deep copy). false = pending. */
|
|
3059
3095
|
bool (*assign)(ScrJsval *cell, const ScrDyn *src);
|
|
3060
3096
|
/* JSON.stringify text of the engine value (+1) — the engine's own
|
|
3061
3097
|
* stringify (toJSON protocols, cycle TypeErrors). NULL + pending when
|
|
3062
3098
|
* not JSON-representable. */
|
|
3063
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);
|
|
3064
3109
|
} ScrDynJsvalOps;
|
|
3065
3110
|
|
|
3066
3111
|
/* The allocator view the gated constructor uses (installs the ops);
|
|
@@ -3086,7 +3131,7 @@ bool scr_dyn_isl_fence(const ScrDyn *d, const char *what);
|
|
|
3086
3131
|
* normalized) — the retired `.length -> fence` row. d MUST be a JSVAL
|
|
3087
3132
|
* node; NULL with the engine's exception bridged catchably. */
|
|
3088
3133
|
ScrDyn *scr_dyn_isl_key_get(const ScrDyn *d, const ScrStr *k);
|
|
3089
|
-
/* The `??`/optional-chain nullish test over a
|
|
3134
|
+
/* The `??`/optional-chain nullish test over a dyn value: UNDEF/NULL
|
|
3090
3135
|
* native, JSVAL through the engine's own test (defensively — the wrap
|
|
3091
3136
|
* constructor scalar-normalizes engine null/undefined away), every other
|
|
3092
3137
|
* kind false. Never throws. */
|
|
@@ -3112,7 +3157,7 @@ bool scr_dyn_is_nullish(const ScrDyn *d);
|
|
|
3112
3157
|
void scr_dyn_this_push(void *h, ScrDynHandleTag tag); /* h BORROWED (the firing site holds it); NULL binds undefined */
|
|
3113
3158
|
void scr_dyn_this_push_dyn(const ScrDyn *v); /* retained for the window */
|
|
3114
3159
|
void scr_dyn_this_pop(void);
|
|
3115
|
-
/* The innermost binding as a
|
|
3160
|
+
/* The innermost binding as a dyn value (+1): a boxed handle, the pushed
|
|
3116
3161
|
* dyn value, or the undefined singleton (empty stack, NULL handle, or a
|
|
3117
3162
|
* handle whose tag has no installed ops — a unit that fires without its
|
|
3118
3163
|
* dyn half never binds). */
|
|
@@ -3124,7 +3169,7 @@ ScrDyn *scr_dyn_this_get(void);
|
|
|
3124
3169
|
void scr_dyn_chunk_enc(bool utf8);
|
|
3125
3170
|
ScrDyn *scr_dyn_new_chunk(const ScrBytes *b);
|
|
3126
3171
|
|
|
3127
|
-
/* util.format's %j over a
|
|
3172
|
+
/* util.format's %j over a dyn value: the JSON.stringify text (+1),
|
|
3128
3173
|
* "undefined" when the root drops (undefined/function), or NULL with a
|
|
3129
3174
|
* pending exception (a runtime handle inside the tree fences loudly). */
|
|
3130
3175
|
ScrStr *scr_dyn_format_j(const ScrDyn *d);
|
|
@@ -3162,7 +3207,7 @@ void scr_throw_lowering_fence(const ScrStr *msg);
|
|
|
3162
3207
|
size_t scr_num_received(double v, char out[48]);
|
|
3163
3208
|
/* Listener-closure builders for the handle dispatchers' .on(...) paths:
|
|
3164
3209
|
* a runtime-built ScrClosure whose capture is the boxed dyn listener and
|
|
3165
|
-
* 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
|
|
3166
3211
|
* the checked-dynamic machinery. The matching fn-pointer shapes are the
|
|
3167
3212
|
* per-event thunk types the registration entries take (fire0's zero-arg
|
|
3168
3213
|
* convention / ScrNetDataFn / ScrChildErrFn). cb borrowed; result +1. */
|
|
@@ -3221,7 +3266,7 @@ void scr_jb_edge_idx(ScrJsonBuf *b, size_t i);
|
|
|
3221
3266
|
|
|
3222
3267
|
/* Circular guard for the compiler-emitted typed→dyn converters (sc_td_*
|
|
3223
3268
|
* over cycle-capable containers): enter TRAPS on a value already being
|
|
3224
|
-
* converted (a cyclic value has no finite
|
|
3269
|
+
* converted (a cyclic value has no finite dyn copy — Node shares the
|
|
3225
3270
|
* reference instead; SEMANTICS.md), else pushes. */
|
|
3226
3271
|
void scr_dyn_from_enter(const void *v);
|
|
3227
3272
|
void scr_dyn_from_leave(void);
|
|
@@ -3240,7 +3285,7 @@ void scr_jb_put_json_str(ScrJsonBuf *b, const ScrStr *s);
|
|
|
3240
3285
|
* the exception PENDING and appends nothing — the loud path, never a
|
|
3241
3286
|
* fabricated rendering. */
|
|
3242
3287
|
void scr_dyn_isl_tostr_buf(ScrJsonBuf *b, const ScrDyn *d);
|
|
3243
|
-
/* JSON-serialize a
|
|
3288
|
+
/* JSON-serialize a dyn value into the buffer — the sc_jw_* walker for the
|
|
3244
3289
|
* dyn leaves the compiler cannot type: object members holding undefined
|
|
3245
3290
|
* DROP, array slots holding undefined print null (exactly Node). */
|
|
3246
3291
|
void scr_jb_put_dyn(ScrJsonBuf *b, const ScrDyn *d);
|
|
@@ -3284,23 +3329,23 @@ bool scr_await_bool(ScrPromise *p);
|
|
|
3284
3329
|
ScrStr *scr_await_str(ScrPromise *p); /* +1 */
|
|
3285
3330
|
void *scr_await_ref(ScrPromise *p); /* +1 via the stored retain */
|
|
3286
3331
|
void scr_await_void(ScrPromise *p);
|
|
3287
|
-
/* The
|
|
3288
|
-
* 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
|
|
3289
3334
|
* value), or NULL with the rejection re-thrown into the awaiter. */
|
|
3290
3335
|
ScrDyn *scr_await_dyn(ScrPromise *p);
|
|
3291
|
-
/* `await v` over a checked-dynamic VALUE:
|
|
3336
|
+
/* `await v` over a checked-dynamic VALUE: dyn promises adopt, everything
|
|
3292
3337
|
* else takes JS's one-hop non-thenable await and answers itself (+1). */
|
|
3293
3338
|
ScrDyn *scr_await_dyn_value(ScrDyn *v);
|
|
3294
|
-
/* .then/.catch/.finally over a
|
|
3339
|
+
/* .then/.catch/.finally over a dyn promise (scr_dyn_invoke's promise arm
|
|
3295
3340
|
* and the compiled dyn-receiver path): one reaction fiber per
|
|
3296
|
-
* registration — awaits src, runs the
|
|
3297
|
-
* 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
|
|
3298
3343
|
* settles a fresh result promise, answered BOXED (+1). Microtask-exact
|
|
3299
3344
|
* ordering rides the fiber machinery. */
|
|
3300
3345
|
ScrDyn *scr_dyn_promise_then(ScrPromise *src, ScrDyn *onf, ScrDyn *onr, ScrDyn *onfin);
|
|
3301
3346
|
/* ── AsyncLocalStorage (node:async_hooks — scr_async.c) ───────────────
|
|
3302
3347
|
* Stores are process-lived f64 handles; the CONTEXT is an immutable
|
|
3303
|
-
* refcounted snapshot of (store →
|
|
3348
|
+
* refcounted snapshot of (store → dyn value) entries riding the fiber
|
|
3304
3349
|
* machinery: one active-slot pointer (the exc-cell pattern) swapped at
|
|
3305
3350
|
* every fiber switch, inherited by spawned fibers (Node's init-time
|
|
3306
3351
|
* capture). enter answers the PREVIOUS snapshot (owned) for restore —
|
|
@@ -3328,12 +3373,12 @@ ScrAlsCtx *scr_als_enter_absent(double id); /* exit()'s cleared arm */
|
|
|
3328
3373
|
void scr_als_restore(ScrAlsCtx *prev); /* moves prev back in */
|
|
3329
3374
|
void scr_als_enter_with(double id, ScrDyn *value); /* no restore point (enterWith) */
|
|
3330
3375
|
void scr_als_disable(double id);
|
|
3331
|
-
/* run/exit: enter (or clear), call the
|
|
3376
|
+
/* run/exit: enter (or clear), call the dyn function with the forwarded
|
|
3332
3377
|
* argument vector, restore (the finally). Result +1 or NULL pending. */
|
|
3333
3378
|
ScrDyn *scr_als_run(double id, ScrDyn *value, ScrDyn *fn, ScrDyn *args);
|
|
3334
3379
|
ScrDyn *scr_als_exit_run(double id, ScrDyn *fn, ScrDyn *args);
|
|
3335
3380
|
|
|
3336
|
-
/* process.on('unhandledRejection', fn):
|
|
3381
|
+
/* process.on('unhandledRejection', fn): dyn listeners dispatched per
|
|
3337
3382
|
* never-observed rejection at loop end — (reason, promise), suppressing
|
|
3338
3383
|
* the default report and the exit-1 (Node's handled-event contract; the
|
|
3339
3384
|
* end-of-turn vs loop-end timing is a SEMANTICS.md divergence). Throws
|
|
@@ -3343,15 +3388,15 @@ void scr_process_on_unhandled_rejection(ScrDyn *fn);
|
|
|
3343
3388
|
* (scr_async_dyn.c → scr_report_unhandled_rejections; NULL = default
|
|
3344
3389
|
* report). Runtime-internal. */
|
|
3345
3390
|
extern bool (*scr_urj_deliver_fn)(ScrPromise *p);
|
|
3346
|
-
/* A rejected promise's reason as a
|
|
3391
|
+
/* A rejected promise's reason as a dyn value (identity-preserving for
|
|
3347
3392
|
* dyn payloads and %Error instances). +1. */
|
|
3348
3393
|
ScrDyn *scr_promise_reason_dyn(const ScrPromise *p);
|
|
3349
3394
|
/* process warnings (scr_lib.c — always linked so any unit can emit a
|
|
3350
|
-
* deprecation):
|
|
3395
|
+
* deprecation): dyn listeners plus Node's default stderr report
|
|
3351
3396
|
* ("(node:pid) [CODE] Name: message" and a detail second line). Emission
|
|
3352
3397
|
* is SYNCHRONOUS at the call (Node defers a tick — SEMANTICS.md 138's
|
|
3353
3398
|
* precedent). scr_process_emit_warning takes the ARGUMENT VECTOR as one
|
|
3354
|
-
*
|
|
3399
|
+
* dyn array and applies Node's full grammar/TypeErrors; scr_emit_warning
|
|
3355
3400
|
* is the C-side deprecation entry. */
|
|
3356
3401
|
void scr_process_on_warning(ScrDyn *fn);
|
|
3357
3402
|
void scr_process_off_warning(ScrDyn *fn);
|
|
@@ -3431,7 +3476,7 @@ void scr_set_timeout(ScrClosure *cb, double ms); /* cb ownership moves in */
|
|
|
3431
3476
|
* works). An unknown handle is a no-op, like Node. */
|
|
3432
3477
|
double scr_set_interval(ScrClosure *cb, double ms); /* cb ownership moves in */
|
|
3433
3478
|
/* `new Promise(setImmediate)`: a fresh promise an armed immediate
|
|
3434
|
-
* fulfills with the undefined
|
|
3479
|
+
* fulfills with the undefined dyn value (+1). */
|
|
3435
3480
|
ScrPromise *scr_immediate_promise(void);
|
|
3436
3481
|
void scr_clear_interval(double handle);
|
|
3437
3482
|
/* The island timer bridge (scr_web.c): a one-shot entry WITH a clear
|
|
@@ -3468,7 +3513,7 @@ double scr_set_immediate(ScrClosure *cb); /* cb ownership moves in */
|
|
|
3468
3513
|
* synchronously on a non-function; borrowed. */
|
|
3469
3514
|
void scr_queue_microtask(ScrClosure *cb);
|
|
3470
3515
|
void scr_queue_microtask_dyn(const ScrDyn *cb);
|
|
3471
|
-
/* setImmediate AS A
|
|
3516
|
+
/* setImmediate AS A dyn VALUE (the traceCallback shape): a minted dyn
|
|
3472
3517
|
* callable that schedules args[0](args[1..]) on the immediate queue and
|
|
3473
3518
|
* answers undefined; a non-function first argument throws Node's
|
|
3474
3519
|
* ERR_INVALID_ARG_TYPE. Result +1. */
|
|
@@ -3487,6 +3532,11 @@ bool scr_immediate_has_ref(double handle);
|
|
|
3487
3532
|
* teardown (they must never run yet must not leak). cb ownership moves
|
|
3488
3533
|
* in. */
|
|
3489
3534
|
void scr_next_tick(ScrClosure *cb);
|
|
3535
|
+
/* A raw C-hook entry on the SAME queue: the stream unit enqueues one
|
|
3536
|
+
* marker per deferred stream emission, so stream ticks and user
|
|
3537
|
+
* nextTicks run in true FIFO order (in Node they are the same queue).
|
|
3538
|
+
* Teardown drops markers without running them. */
|
|
3539
|
+
void scr_next_tick_raw(void (*fn)(void));
|
|
3490
3540
|
void scr_nticks_teardown(void);
|
|
3491
3541
|
/* ── the events unit (scr_events.c — OPTIONAL, link-gated) ────────────
|
|
3492
3542
|
* Process signal/exit events and the piped-stdin surface. The unit links
|
|
@@ -3913,24 +3963,24 @@ ScrJsval *scr_jsval_from_f64(double v);
|
|
|
3913
3963
|
ScrJsval *scr_jsval_from_bool(bool v);
|
|
3914
3964
|
ScrJsval *scr_jsval_from_str(const ScrStr *s);
|
|
3915
3965
|
ScrJsval *scr_jsval_from_json(const ScrStr *json);
|
|
3916
|
-
/* A CHECKED-DYNAMIC (
|
|
3966
|
+
/* A CHECKED-DYNAMIC (dyn) value entering the island — deep copy for data
|
|
3917
3967
|
* kinds (a boxed handle/promise throws the catchable TypeError). A JSVAL
|
|
3918
3968
|
* node unwraps to its OWN cell (+1) — an engine value that crossed into
|
|
3919
|
-
* the
|
|
3969
|
+
* the checked-dynamic tree and back is the SAME engine value, by reference (nested JSVAL
|
|
3920
3970
|
* members embed their engine values directly). A boxed FUNCTION crosses
|
|
3921
3971
|
* as one generic host-function shim over its uniform ScrDynThunk: the
|
|
3922
|
-
* shim wraps engine arguments as
|
|
3923
|
-
* 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
|
|
3924
3974
|
* fresh engine function (identity is not preserved for re-crossings;
|
|
3925
3975
|
* SEMANTICS.md). NULL with a pending exception on failure. Borrows d. */
|
|
3926
3976
|
ScrJsval *scr_jsval_from_dyn(const ScrDyn *d);
|
|
3927
3977
|
|
|
3928
|
-
/* The jsval→
|
|
3978
|
+
/* The jsval→dyn crossing (the IR's dynFromJsval): wraps an island value
|
|
3929
3979
|
* as a SCR_DYN_JSVAL node, SCALAR-NORMALIZING first — engine numbers/
|
|
3930
|
-
* strings/booleans/null/undefined convert to the native
|
|
3980
|
+
* strings/booleans/null/undefined convert to the native dyn kinds (the
|
|
3931
3981
|
* strict exits cannot fail on engine-reported scalars), so JSVAL nodes
|
|
3932
3982
|
* only ever hold engine objects/arrays/functions (and the symbol/bigint
|
|
3933
|
-
* edge). Installs the
|
|
3983
|
+
* edge). Installs the checked-dynamic tree's engine-routing ops on first use. Borrows
|
|
3934
3984
|
* the cell (retains it into the node); +1 out; never throws. */
|
|
3935
3985
|
ScrDyn *scr_dyn_from_jsval(ScrJsval *cell);
|
|
3936
3986
|
|
|
@@ -4024,6 +4074,11 @@ enum {
|
|
|
4024
4074
|
SCR_ISLP_BOOL = 2,
|
|
4025
4075
|
SCR_ISLP_STR = 3,
|
|
4026
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,
|
|
4027
4082
|
};
|
|
4028
4083
|
|
|
4029
4084
|
/* Wrap a scriptc promise as an ENGINE promise (async callbacks crossing
|
|
@@ -4084,6 +4139,11 @@ ScrStr *scr_jsval_exit_str(ScrJsval *v);
|
|
|
4084
4139
|
/* Uint8Array exit (engine Buffers pass — they ARE Uint8Arrays): a fresh
|
|
4085
4140
|
* u8 COPY (+1), the boundary's aliasing stance; NULL = thrown. */
|
|
4086
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);
|
|
4087
4147
|
ScrStr *scr_jsval_to_json(ScrJsval *v);
|
|
4088
4148
|
|
|
4089
4149
|
/* The import boundary (libCall island.import): loads an embedded module —
|
|
@@ -4207,13 +4267,15 @@ double scr_bit_not(double a);
|
|
|
4207
4267
|
/* ── typed arrays / Buffer (scr_bytes.c) ──────────────────────────────
|
|
4208
4268
|
* ONE runtime representation for Uint8Array/Uint32Array/Float32Array,
|
|
4209
4269
|
* Node's Buffer (a Uint8Array subclass), and DataView: a refcounted,
|
|
4210
|
-
* MUTABLE, fixed-length element buffer.
|
|
4211
|
-
* (backing == NULL
|
|
4212
|
-
*
|
|
4213
|
-
*
|
|
4214
|
-
*
|
|
4215
|
-
*
|
|
4216
|
-
*
|
|
4270
|
+
* MUTABLE, fixed-length element buffer. An ScrBytes either OWNS its
|
|
4271
|
+
* storage (backing == NULL, byteOffset 0) or is a VIEW: its `data` points
|
|
4272
|
+
* INTO an owner's storage and its `backing` retains that owner (chain
|
|
4273
|
+
* depth is always exactly 1 — views over views resolve to the owner at
|
|
4274
|
+
* construction), so reads/writes through the view alias the source
|
|
4275
|
+
* JS-exactly. Views come from DataView (scr_dataview_new) and from
|
|
4276
|
+
* subarray()/Buffer-slice() (scr_bytes_subarray — Buffer's slice is
|
|
4277
|
+
* subarray's deprecated alias in Node); only the plain typed arrays'
|
|
4278
|
+
* slice() copies (scr_bytes_slice, matching JS).
|
|
4217
4279
|
* Elements are scalars only and the backing edge is acyclic by
|
|
4218
4280
|
* construction (owners point at nothing): never part of a cycle, no
|
|
4219
4281
|
* trace. Element reads widen to double; writes coerce JS-exactly (ToUint8
|
|
@@ -4236,10 +4298,10 @@ typedef struct ScrBytes {
|
|
|
4236
4298
|
size_t len; /* ELEMENT count, fixed at construction */
|
|
4237
4299
|
ScrBytesElem elem;
|
|
4238
4300
|
uint8_t *data; /* len * elem_size bytes; owned unless backing is set */
|
|
4239
|
-
/* NULL for owners (
|
|
4240
|
-
* the retained OWNER it aliases (chain depth is always exactly 1:
|
|
4241
|
-
* over
|
|
4242
|
-
*
|
|
4301
|
+
/* NULL for owners. A view (DataView, subarray, Buffer-slice) sets this
|
|
4302
|
+
* to the retained OWNER it aliases (chain depth is always exactly 1:
|
|
4303
|
+
* views over views resolve to the owner at construction) and its `data`
|
|
4304
|
+
* points into backing->data — released, never freed. */
|
|
4243
4305
|
struct ScrBytes *backing;
|
|
4244
4306
|
} ScrBytes;
|
|
4245
4307
|
|
|
@@ -4344,10 +4406,21 @@ void scr_bytes_set(ScrBytes *b, double i, double v);
|
|
|
4344
4406
|
|
|
4345
4407
|
/* TypedArray.prototype.slice(start, end): relative indices clamp like
|
|
4346
4408
|
* string/array slice (ToIntegerOrInfinity, negatives from the end); the
|
|
4347
|
-
* result is a fresh same-kind copy.
|
|
4348
|
-
* the documented divergence. Never throws. */
|
|
4409
|
+
* result is a fresh same-kind copy. Never throws. */
|
|
4349
4410
|
ScrBytes *scr_bytes_slice(const ScrBytes *b, double start, double end); /* +1 */
|
|
4350
4411
|
|
|
4412
|
+
/* TypedArray.prototype.fill on non-u8 receivers: per-element fill with
|
|
4413
|
+
* the element write's coercion, slice-clamped relative indices; answers
|
|
4414
|
+
* the receiver +1 (chaining). Never throws. */
|
|
4415
|
+
ScrBytes *scr_bytes_fill_elem(ScrBytes *b, double v, double start, double end); /* +1 */
|
|
4416
|
+
|
|
4417
|
+
/* TypedArray.prototype.subarray(start, end) — and Buffer's slice(), its
|
|
4418
|
+
* deprecated alias: a same-elem VIEW aliasing the receiver's storage
|
|
4419
|
+
* (mutations visible both ways, JS-exactly). The view retains the OWNER
|
|
4420
|
+
* (chain depth exactly 1, the DataView rule) and its byteOffset composes.
|
|
4421
|
+
* Same index clamping as slice; never throws. */
|
|
4422
|
+
ScrBytes *scr_bytes_subarray(ScrBytes *b, double start, double end); /* +1 */
|
|
4423
|
+
|
|
4351
4424
|
/* dst.set(src, offset): same-kind bulk copy (memmove — dst may be src).
|
|
4352
4425
|
* offset goes through ToIntegerOrInfinity; a negative offset or
|
|
4353
4426
|
* src.len + offset > dst.len THROWS Node's "offset is out of bounds"
|
|
@@ -4410,7 +4483,7 @@ double scr_bytes_compare(const ScrBytes *src, const ScrBytes *target, double nar
|
|
|
4410
4483
|
* Returns false after arming the pending throw. */
|
|
4411
4484
|
bool scr_bytes_validate_off(const char *name, double value, double max);
|
|
4412
4485
|
/* The checked-dynamic compare/equals validators (scr_bytes_io.c): Node's
|
|
4413
|
-
* argument ladder over
|
|
4486
|
+
* argument ladder over dyn-boxed arguments — a non-bytes value throws
|
|
4414
4487
|
* ERR_INVALID_ARG_TYPE with the API's own argument name ("buf1"/"buf2",
|
|
4415
4488
|
* "otherBuffer", "target"), non-number offsets ERR_INVALID_ARG_TYPE
|
|
4416
4489
|
* "of type number", out-of-range numbers the validateOffset RangeError;
|
|
@@ -4423,12 +4496,12 @@ double scr_bytes_compare_chk(const ScrBytes *src, const ScrDyn *target,
|
|
|
4423
4496
|
/* new Buffer(number, encoding)'s string-arm type error (always throws;
|
|
4424
4497
|
* borrowed). */
|
|
4425
4498
|
ScrBytes *scr_buffer_new_string_fail(const ScrDyn *got);
|
|
4426
|
-
/* fs._toUnixTimestamp over a
|
|
4499
|
+
/* fs._toUnixTimestamp over a dyn time value: numeric strings and finite
|
|
4427
4500
|
* numbers coerce (negatives answer now/1000), the rest throw Node's
|
|
4428
4501
|
* ERR_INVALID_ARG_TYPE. Borrowed. */
|
|
4429
4502
|
double scr_fs_to_unix_timestamp(const ScrDyn *t);
|
|
4430
4503
|
/* The fs argument-validation ladders (the fs.*Chk libCalls): Node-order
|
|
4431
|
-
* validation over
|
|
4504
|
+
* validation over dyn values with Node's exact typed errors; a pass
|
|
4432
4505
|
* meets the real operation where one exists (mkdtempSync, macOS
|
|
4433
4506
|
* lchmodSync) or the compiler-rendered fence. All borrowed; the Chk
|
|
4434
4507
|
* forms without results always leave an exception pending. */
|
|
@@ -4489,7 +4562,7 @@ ScrStr *scr_insp_buffer(ScrBytes *b); /* <Buffer aa bb ...>, 50-byte cap */
|
|
|
4489
4562
|
* depth when a code makes it composite. */
|
|
4490
4563
|
ScrStr *scr_insp_error(ScrError *e, double recurse, double depth);
|
|
4491
4564
|
/* The checked-dynamic tree: shape lives in the value, so the whole
|
|
4492
|
-
* traversal is here. dyn-boxed bytes render in the
|
|
4565
|
+
* traversal is here. dyn-boxed bytes render in the checked-dynamic tree's documented
|
|
4493
4566
|
* Uint8Array identity. */
|
|
4494
4567
|
ScrStr *scr_insp_dyn(ScrDyn *d, double recurse, double depth);
|
|
4495
4568
|
/* format's %s / rest-args twin: dyn strings pass verbatim. */
|
|
@@ -4550,7 +4623,7 @@ double scr_bytes_write_var(ScrBytes *b, double value, double offset, double byte
|
|
|
4550
4623
|
* Buffer forms of scr_lib.c's utf8 pair, byte-exact and NUL-safe.
|
|
4551
4624
|
* Failures THROW catchably (scr_fs_throw, Node-shaped messages). */
|
|
4552
4625
|
ScrBytes *scr_fs_read_file_bytes(ScrStr *path); /* +1 */
|
|
4553
|
-
/* 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
|
|
4554
4627
|
* value — a Buffer box for undefined/null, a string for utf8 — or NULL
|
|
4555
4628
|
* with the exception pending. */
|
|
4556
4629
|
ScrDyn *scr_fs_read_file_sync_dyn(ScrStr *path, const ScrDyn *enc);
|
|
@@ -4780,7 +4853,7 @@ void scr_net_conn_thunk_sock(ScrClosure *cb, ScrNetSocket *sock);
|
|
|
4780
4853
|
void scr_net_install(void);
|
|
4781
4854
|
/* Registers the netSocket handle-dispatch ops (SCR_DYNH_NET_SOCKET) —
|
|
4782
4855
|
* emitted main() calls this alongside scr_net_install exactly when the
|
|
4783
|
-
* net unit is linked, so the always-linked
|
|
4856
|
+
* net unit is linked, so the always-linked dyn core never references
|
|
4784
4857
|
* this unit's entry points. */
|
|
4785
4858
|
void scr_net_dyn_install(void);
|
|
4786
4859
|
#ifdef SCR_RC_AUDIT
|
|
@@ -4875,7 +4948,7 @@ ScrNetServer *scr_tls_create_server(const char *cert, size_t cert_len, const cha
|
|
|
4875
4948
|
* drop exactly like Node drops them). cert/key values are PEM strings,
|
|
4876
4949
|
* Buffers, or one-element arrays of those; `ca` (client side)
|
|
4877
4950
|
* concatenates array entries into one trust-anchor bundle. The *_dyn
|
|
4878
|
-
* creators walk a
|
|
4951
|
+
* creators walk a dyn options record (the checked-dynamic JS lane's
|
|
4879
4952
|
* shape) and mint the same servers the literal path mints; NULL returns
|
|
4880
4953
|
* carry a pending exception. scr_tls_pem_from_dyn is the literal path's
|
|
4881
4954
|
* runtime-valued cert/key extraction (`what` names the fence). */
|
|
@@ -5302,7 +5375,7 @@ void scr_http2_goaway_thunk0(ScrClosure *cb, double code, double last);
|
|
|
5302
5375
|
|
|
5303
5376
|
void scr_net_sock_set_native_established(ScrNetSocket *s, ScrNetNativeEventFn fn);
|
|
5304
5377
|
|
|
5305
|
-
/* Registers the h2 session/stream
|
|
5378
|
+
/* Registers the h2 session/stream dyn handle ops (the emitted main()
|
|
5306
5379
|
* calls it when the unit is linked — the scr_net_dyn_install story). */
|
|
5307
5380
|
void scr_http2_dyn_install(void);
|
|
5308
5381
|
|
|
@@ -5365,7 +5438,7 @@ void scr_dgram_bind(ScrDgramSocket *s, double port, ScrStr *host /*borrowed*/, S
|
|
|
5365
5438
|
void scr_dgram_connect(ScrDgramSocket *s, double port, ScrStr *host /*borrowed*/, ScrClosure *cb /*moves, nullable*/);
|
|
5366
5439
|
void scr_dgram_send_str(ScrDgramSocket *s, ScrStr *data /*borrowed*/, double port, ScrStr *host /*borrowed*/);
|
|
5367
5440
|
void scr_dgram_send_bytes(ScrDgramSocket *s, ScrBytes *data /*borrowed*/, double port, ScrStr *host /*borrowed*/);
|
|
5368
|
-
/* The send argument-validation ladder over
|
|
5441
|
+
/* The send argument-validation ladder over dyn arguments (Node's
|
|
5369
5442
|
* signature shuffle, slice bounds, list/type contracts, port/address
|
|
5370
5443
|
* validation, and the connected-state errors); a fully-validated
|
|
5371
5444
|
* unconnected single-payload send RUNS, the rest meet the fence. */
|
|
@@ -5529,14 +5602,14 @@ void scr_assert_neq_fail(const char *insp, size_t ilen, bool deep,
|
|
|
5529
5602
|
ScrStr *msg, bool has_msg);
|
|
5530
5603
|
/* strictEqual/notStrictEqual/deepStrictEqual/notDeepStrictEqual where
|
|
5531
5604
|
* either operand is a checked-dynamic value (the frontend boxes a static
|
|
5532
|
-
* side into the
|
|
5605
|
+
* side into the checked-dynamic tree first). Strict pair: SameValue over the dyn kinds —
|
|
5533
5606
|
* Object.is numbers, byte-equal strings, units by kind, node identity
|
|
5534
5607
|
* for arrays/objects/bytes, BOXED-CLOSURE identity for functions. Deep
|
|
5535
|
-
* pair: the structural
|
|
5608
|
+
* pair: the structural dyn walk (per-element arrays, key-set objects,
|
|
5536
5609
|
* brand-aware bytes via the buffer flavor bit, closure identity for
|
|
5537
5610
|
* functions). Generated messages reproduce assertion_error.js — the
|
|
5538
5611
|
* scalar simple/stacked forms byte-exactly, composite values rendered
|
|
5539
|
-
* compact:false/sorted through the
|
|
5612
|
+
* compact:false/sorted through the checked-dynamic tree and diffed with the real myers
|
|
5540
5613
|
* line printer (the design note atop scr_assert.c's dyn section lists
|
|
5541
5614
|
* the divergences). Borrows everything; throws on the failing verdict. */
|
|
5542
5615
|
void scr_assert_eq_dyn(ScrDyn *a, ScrDyn *b, bool negated, bool deep,
|
|
@@ -5545,7 +5618,7 @@ void scr_assert_eq_dyn(ScrDyn *a, ScrDyn *b, bool negated, bool deep,
|
|
|
5545
5618
|
* promise fulfilled): "Missing expected exception|rejection" with Node's
|
|
5546
5619
|
* details — ` (${expected.name})` when the expected class/shape carries a
|
|
5547
5620
|
* name (has_ename), then `: message` or `.`. */
|
|
5548
|
-
/* Node's expectsError over an error-INSTANCE expected: the expected
|
|
5621
|
+
/* Node's expectsError over an error-INSTANCE expected: the expected dyn
|
|
5549
5622
|
* error's keys (minus the %error marker) each deep-compare against the
|
|
5550
5623
|
* caught value's; mismatches throw the deep-equal AssertionError. */
|
|
5551
5624
|
void scr_assert_expects_err_dyn(ScrDyn *actual, ScrDyn *expected, ScrStr *msg, bool has_msg);
|
|
@@ -5583,7 +5656,7 @@ void scr_assert_iferror_err(ScrError *err);
|
|
|
5583
5656
|
void scr_assert_iferror_f64(double x);
|
|
5584
5657
|
void scr_assert_iferror_str(ScrStr *s);
|
|
5585
5658
|
void scr_assert_iferror_bool(bool b);
|
|
5586
|
-
/* The checked-dynamic argument:
|
|
5659
|
+
/* The checked-dynamic argument: dyn-kind dispatch — units pass quietly,
|
|
5587
5660
|
* %error-marked objects throw with the error's message, everything else
|
|
5588
5661
|
* with the inspection. */
|
|
5589
5662
|
void scr_assert_iferror_dyn(const ScrDyn *v);
|