@scriptc/cli-darwin-x64 0.2.3 → 0.2.5
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/dist/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +915 -215
- package/dist/lib/declarations/scriptc-overrides.d.ts +5 -1
- package/dist/lib/declarations/scriptc.d.ts +22 -2
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/runtime-pack.json +215 -215
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_array.c +317 -40
- package/dist/lib/runtime-sources/src/scr_async.test.ts +16 -6
- package/dist/lib/runtime-sources/src/scr_bigint.c +15 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +437 -216
- package/dist/lib/runtime-sources/src/scr_bytes.test.c +85 -0
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +0 -34
- package/dist/lib/runtime-sources/src/scr_copying.c +12 -2
- package/dist/lib/runtime-sources/src/scr_cycle.c +84 -60
- package/dist/lib/runtime-sources/src/scr_json.c +494 -161
- package/dist/lib/runtime-sources/src/scr_json.test.c +323 -1
- package/dist/lib/runtime-sources/src/scr_json.test.ts +58 -25
- package/dist/lib/runtime-sources/src/scr_key.h +68 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +177 -89
- package/dist/lib/runtime-sources/src/scr_map.c +268 -96
- package/dist/lib/runtime-sources/src/scr_number.c +2 -4
- package/dist/lib/runtime-sources/src/scr_numeric.h +25 -0
- package/dist/lib/runtime-sources/src/scr_numeric.test.c +37 -0
- package/dist/lib/runtime-sources/src/scr_numeric.test.ts +33 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +255 -145
- package/dist/lib/runtime-sources/src/scr_runtime.h +76 -19
- package/dist/lib/runtime-sources/src/scr_string.c +184 -42
- package/package.json +1 -1
|
@@ -297,7 +297,7 @@ void scr_library_bytes_out(ScrBytes *b, const uint8_t **out, size_t *out_len);
|
|
|
297
297
|
* The collector is synchronous Bacon–Rajan trial deletion: a release that
|
|
298
298
|
* leaves a candidate's rc above zero buffers it as a possible cycle root;
|
|
299
299
|
* collection walks the buffer (markGray: trial-decrement internal edges;
|
|
300
|
-
* scan: restore externally-referenced subgraphs;
|
|
300
|
+
* scan: restore externally-referenced subgraphs; gather: free the
|
|
301
301
|
* dead cycle members, releasing only edges that LEAVE the white set).
|
|
302
302
|
* It is GENERATIONAL: each header carries a generation, a pass names the
|
|
303
303
|
* oldest one it will walk, and objects that survive a pass are promoted out
|
|
@@ -322,9 +322,9 @@ typedef void (*ScrTraceVisit)(void *child, void *ctx);
|
|
|
322
322
|
typedef void (*ScrTraceFn)(void *obj, ScrTraceVisit visit, void *ctx);
|
|
323
323
|
typedef void (*ScrCycFreeFn)(void *obj);
|
|
324
324
|
|
|
325
|
-
/* DOOMED
|
|
326
|
-
*
|
|
327
|
-
*
|
|
325
|
+
/* DOOMED identifies the gathered dead set during re-buffering and weak
|
|
326
|
+
* observer teardown. WHITE candidates may still become black when a later
|
|
327
|
+
* outside root restores them; only the settled white set becomes DOOMED. */
|
|
328
328
|
enum {
|
|
329
329
|
SCR_CYC_BLACK = 0, SCR_CYC_PURPLE = 1, SCR_CYC_GRAY = 2, SCR_CYC_WHITE = 3,
|
|
330
330
|
SCR_CYC_DOOMED = 4
|
|
@@ -437,7 +437,7 @@ typedef struct ScrVt {
|
|
|
437
437
|
*
|
|
438
438
|
* cap is the usable byte capacity of data[] excluding the NUL (allocation
|
|
439
439
|
* is sizeof(ScrStr) + cap + 1); cap == len for interned literals and plain
|
|
440
|
-
* allocations.
|
|
440
|
+
* allocations. Builders and concat results may have spare capacity so
|
|
441
441
|
* scr_str_concat can append in place when the left operand is uniquely
|
|
442
442
|
* owned (rc == 1) — observable immutability is preserved: a string with
|
|
443
443
|
* rc > 1 or rc == SIZE_MAX is never mutated.
|
|
@@ -454,7 +454,7 @@ ScrStr *scr_str_new(const char *bytes, size_t len); /* returns +1 */
|
|
|
454
454
|
* malformed subsequences with U+FFFD. NULL with len == 0 is an empty span. */
|
|
455
455
|
ScrStr *scr_str_from_utf8_lossy(const uint8_t *bytes, size_t len); /* +1 */
|
|
456
456
|
|
|
457
|
-
/* Internal allocators for buffer builders
|
|
457
|
+
/* Internal allocators for buffer builders: a +1 string with
|
|
458
458
|
* UNINITIALIZED data (the builder fills bytes, then len and the NUL), and
|
|
459
459
|
* an rc==1-only realloc that grows capacity in place. Both keep the RC
|
|
460
460
|
* audit's live count exact. */
|
|
@@ -470,6 +470,8 @@ void scr_str_release(ScrStr *s); /* NULL-tolerant (uninitialized locals) */
|
|
|
470
470
|
|
|
471
471
|
/* Borrow both args, return +1. */
|
|
472
472
|
ScrStr *scr_str_concat(ScrStr *a, ScrStr *b);
|
|
473
|
+
/* Borrow each part without mutation; return one independently owned result. */
|
|
474
|
+
ScrStr *scr_str_concat_parts(ScrStr *const *parts, size_t count);
|
|
473
475
|
|
|
474
476
|
bool scr_str_eq(ScrStr *a, ScrStr *b);
|
|
475
477
|
|
|
@@ -1030,7 +1032,7 @@ typedef struct ScrArr {
|
|
|
1030
1032
|
void (*elem_release)(void *);
|
|
1031
1033
|
ScrTraceFn elem_trace;
|
|
1032
1034
|
uint64_t *data;
|
|
1033
|
-
uint8_t *present; /* one
|
|
1035
|
+
uint8_t *present; /* one state per dense slot; heap arrays share data allocation */
|
|
1034
1036
|
struct ScrArrSparseSlot *sparse;
|
|
1035
1037
|
size_t sparse_len;
|
|
1036
1038
|
size_t sparse_cap;
|
|
@@ -1109,6 +1111,13 @@ void scr_arr_copy_range(ScrArr *dst, size_t dst_start, const ScrArr *src,
|
|
|
1109
1111
|
void scr_arr_copy_range_ex(ScrArr *dst, size_t dst_start, const ScrArr *src,
|
|
1110
1112
|
size_t src_start, size_t count, bool reverse,
|
|
1111
1113
|
bool materialize_holes);
|
|
1114
|
+
/* Mutating indexed operations borrow the receiver and value, preserve
|
|
1115
|
+
* sparse presence, and return the receiver retained. */
|
|
1116
|
+
ScrArr *scr_arr_copy_within(ScrArr *a, double target, double start, double end);
|
|
1117
|
+
ScrArr *scr_arr_fill_f64(ScrArr *a, double value, double start, double end);
|
|
1118
|
+
ScrArr *scr_arr_fill_bool(ScrArr *a, bool value, double start, double end);
|
|
1119
|
+
ScrArr *scr_arr_fill_ref(ScrArr *a, void *value, double start, double end);
|
|
1120
|
+
ScrArr *scr_arr_fill_undefined(ScrArr *a, double start, double end);
|
|
1112
1121
|
/* Math.max(...xs) / Math.min(...xs) over an f64-element array: the JS
|
|
1113
1122
|
* fold (NaN poisons, ±0 by the JS preferences, empty → ∓Infinity). */
|
|
1114
1123
|
double scr_math_max_arr(ScrArr *a);
|
|
@@ -1168,6 +1177,10 @@ ScrArr *scr_arr_with_undefined(ScrArr *a, double index);
|
|
|
1168
1177
|
double scr_arr_push_f64(ScrArr *a, double v);
|
|
1169
1178
|
double scr_arr_push_bool(ScrArr *a, bool v);
|
|
1170
1179
|
double scr_arr_push_ref(ScrArr *a, void *v);
|
|
1180
|
+
/* Compiler-built slot buffers do not alias array storage. Both operations
|
|
1181
|
+
* move ownership of every slot and preserve the evaluated argument order. */
|
|
1182
|
+
double scr_arr_push_many(ScrArr *a, size_t count, const uint64_t *slots);
|
|
1183
|
+
double scr_arr_unshift_many(ScrArr *a, size_t count, const uint64_t *slots);
|
|
1171
1184
|
/* Append a same-element-kind array through the JS iterator contract: holes
|
|
1172
1185
|
* become present undefined states. The source is borrowed and self-spread
|
|
1173
1186
|
* duplicates the original indexed state. */
|
|
@@ -1321,10 +1334,10 @@ ScrArr *scr_regex_match_all_into(ScrStr *s, ScrRegex *re, ScrArr *indices);
|
|
|
1321
1334
|
* are visited (they append), deleted entries are skipped (tombstones), and
|
|
1322
1335
|
* a delete + re-add moves the key to the end (Node-verified).
|
|
1323
1336
|
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
* the
|
|
1337
|
+
* Primitive keys compare by value and reference keys by identity. Numbers
|
|
1338
|
+
* use SameValueZero: NaN equals NaN and -0 is stored as +0. Union wrappers
|
|
1339
|
+
* are representations, never identities; their arm descriptors select
|
|
1340
|
+
* the primitive or reference comparison, including null and undefined.
|
|
1328
1341
|
*
|
|
1329
1342
|
* Values are one uniform kind per map (like ScrArr elements): f64, bool, or
|
|
1330
1343
|
* a refcounted pointer whose RC entry points arrive as function pointers at
|
|
@@ -1351,13 +1364,17 @@ ScrArr *scr_regex_match_all_into(ScrStr *s, ScrRegex *re, ScrArr *indices);
|
|
|
1351
1364
|
* DYN owns a checked-value box and compares its JavaScript value using
|
|
1352
1365
|
* SameValueZero, including reference identity for object payloads.
|
|
1353
1366
|
* These key kinds serve both Maps and Sets. */
|
|
1354
|
-
typedef enum {
|
|
1367
|
+
typedef enum {
|
|
1368
|
+
SCR_MAP_KEY_F64, SCR_MAP_KEY_STR, SCR_MAP_KEY_REF, SCR_MAP_KEY_UNION_REF, SCR_MAP_KEY_DYN,
|
|
1369
|
+
SCR_MAP_KEY_BIGINT, SCR_MAP_KEY_BOOL, SCR_MAP_KEY_UNION_VALUE,
|
|
1370
|
+
SCR_MAP_KEY_NULL, SCR_MAP_KEY_UNDEFINED /* tag-only union arms */
|
|
1371
|
+
} ScrMapKeyKind;
|
|
1355
1372
|
typedef enum { SCR_MAP_VAL_F64, SCR_MAP_VAL_BOOL, SCR_MAP_VAL_REF } ScrMapValKind;
|
|
1356
1373
|
|
|
1357
1374
|
typedef struct {
|
|
1358
1375
|
uint64_t key; /* double bits (normalized), ScrStr* (owned), or ref ptr (owned) */
|
|
1359
1376
|
uint64_t val; /* double bits, bool, or owned pointer */
|
|
1360
|
-
|
|
1377
|
+
uint64_t hash; /* nonzero cached hash; zero = tombstone (key/val released) */
|
|
1361
1378
|
} ScrMapEntry;
|
|
1362
1379
|
|
|
1363
1380
|
/* Checked views use the original storage. Slot converters borrow on reads
|
|
@@ -1380,7 +1397,7 @@ typedef struct ScrMap {
|
|
|
1380
1397
|
void *(*val_retain)(void *);
|
|
1381
1398
|
void (*val_release)(void *);
|
|
1382
1399
|
ScrTraceFn val_trace;
|
|
1383
|
-
/*
|
|
1400
|
+
/* Reference-represented keys, including bigint and union values. */
|
|
1384
1401
|
void *(*key_retain)(void *);
|
|
1385
1402
|
void (*key_release)(void *);
|
|
1386
1403
|
ScrTraceFn key_trace;
|
|
@@ -1388,12 +1405,21 @@ typedef struct ScrMap {
|
|
|
1388
1405
|
size_t nlive; /* live entries (Map.size) */
|
|
1389
1406
|
size_t ecap; /* entries capacity */
|
|
1390
1407
|
ScrMapEntry *entries;
|
|
1391
|
-
size_t nbuckets; /* power of two
|
|
1408
|
+
size_t nbuckets; /* zero for small linear maps; otherwise power of two >= 2 * nentries */
|
|
1392
1409
|
size_t *buckets; /* entry indices; SIZE_MAX = empty */
|
|
1393
1410
|
size_t iter_depth; /* > 0: an iteration is active — no compaction */
|
|
1394
1411
|
const ScrMapDynOps *dyn_ops;
|
|
1412
|
+
const uint8_t *union_keys; /* immutable key-kind table indexed by union tag */
|
|
1395
1413
|
} ScrMap;
|
|
1396
1414
|
|
|
1415
|
+
/* Called once on a fresh UNION_VALUE collection, before its first insert. */
|
|
1416
|
+
void scr_map_union_keys(ScrMap *map, const uint8_t *kinds);
|
|
1417
|
+
/* Fresh shallow copies with compact storage and independent mutation.
|
|
1418
|
+
* keys_only selects a Set; checked views materialize their boxed values. */
|
|
1419
|
+
ScrMap *scr_map_clone(const ScrMap *source, bool keys_only);
|
|
1420
|
+
ScrMap *scr_map_clone_dyn(const ScrMap *source, bool keys_only);
|
|
1421
|
+
void scr_map_values_into(ScrMap *set, const ScrMap *source, bool checked);
|
|
1422
|
+
|
|
1397
1423
|
void scr_map_dyn_attach(ScrMap *map, const ScrMapDynOps *ops);
|
|
1398
1424
|
struct ScrDyn *scr_map_dyn_key(const ScrMap *map, double index);
|
|
1399
1425
|
struct ScrDyn *scr_map_dyn_value(const ScrMap *map, double index);
|
|
@@ -1426,9 +1452,11 @@ double scr_map_size(const ScrMap *m); /* live entries (Map.size) */
|
|
|
1426
1452
|
void scr_map_clear(ScrMap *m);
|
|
1427
1453
|
|
|
1428
1454
|
bool scr_map_has_f64(const ScrMap *m, double key);
|
|
1455
|
+
bool scr_map_has_bool(const ScrMap *m, bool key);
|
|
1429
1456
|
bool scr_map_has_str(const ScrMap *m, const ScrStr *key);
|
|
1430
1457
|
bool scr_map_has_ref(const ScrMap *m, const void *key);
|
|
1431
1458
|
bool scr_map_delete_f64(ScrMap *m, double key);
|
|
1459
|
+
bool scr_map_delete_bool(ScrMap *m, bool key);
|
|
1432
1460
|
bool scr_map_delete_str(ScrMap *m, const ScrStr *key);
|
|
1433
1461
|
bool scr_map_delete_ref(ScrMap *m, const void *key);
|
|
1434
1462
|
|
|
@@ -1438,6 +1466,9 @@ bool scr_map_delete_ref(ScrMap *m, const void *key);
|
|
|
1438
1466
|
void scr_map_set_f64_f64(ScrMap *m, double key, double v);
|
|
1439
1467
|
void scr_map_set_f64_bool(ScrMap *m, double key, bool v);
|
|
1440
1468
|
void scr_map_set_f64_ref(ScrMap *m, double key, void *v);
|
|
1469
|
+
void scr_map_set_bool_f64(ScrMap *m, bool key, double v);
|
|
1470
|
+
void scr_map_set_bool_bool(ScrMap *m, bool key, bool v);
|
|
1471
|
+
void scr_map_set_bool_ref(ScrMap *m, bool key, void *v);
|
|
1441
1472
|
void scr_map_set_str_f64(ScrMap *m, ScrStr *key, double v);
|
|
1442
1473
|
void scr_map_set_str_bool(ScrMap *m, ScrStr *key, bool v);
|
|
1443
1474
|
void scr_map_set_str_ref(ScrMap *m, ScrStr *key, void *v);
|
|
@@ -1452,6 +1483,9 @@ void scr_map_set_ref_ref(ScrMap *m, void *key, void *v);
|
|
|
1452
1483
|
bool scr_map_get_f64_f64(const ScrMap *m, double key, double *out);
|
|
1453
1484
|
bool scr_map_get_f64_bool(const ScrMap *m, double key, bool *out);
|
|
1454
1485
|
void *scr_map_get_f64_ref(const ScrMap *m, double key);
|
|
1486
|
+
bool scr_map_get_bool_f64(const ScrMap *m, bool key, double *out);
|
|
1487
|
+
bool scr_map_get_bool_bool(const ScrMap *m, bool key, bool *out);
|
|
1488
|
+
void *scr_map_get_bool_ref(const ScrMap *m, bool key);
|
|
1455
1489
|
bool scr_map_get_str_f64(const ScrMap *m, const ScrStr *key, double *out);
|
|
1456
1490
|
bool scr_map_get_str_bool(const ScrMap *m, const ScrStr *key, bool *out);
|
|
1457
1491
|
void *scr_map_get_str_ref(const ScrMap *m, const ScrStr *key);
|
|
@@ -1467,6 +1501,7 @@ void *scr_map_get_ref_ref(const ScrMap *m, const void *key);
|
|
|
1467
1501
|
double scr_map_iter_count(const ScrMap *m); /* entries incl. tombstones */
|
|
1468
1502
|
bool scr_map_iter_live(const ScrMap *m, double i);
|
|
1469
1503
|
double scr_map_iter_key_f64(const ScrMap *m, double i);
|
|
1504
|
+
bool scr_map_iter_key_bool(const ScrMap *m, double i);
|
|
1470
1505
|
ScrStr *scr_map_iter_key_str(const ScrMap *m, double i); /* +1 */
|
|
1471
1506
|
void *scr_map_iter_key_ref(const ScrMap *m, double i); /* +1 */
|
|
1472
1507
|
double scr_map_iter_val_f64(const ScrMap *m, double i);
|
|
@@ -1484,6 +1519,7 @@ void scr_set_add_all(ScrMap *set, ScrArr *values);
|
|
|
1484
1519
|
/* `[...set]` (scr_lib.c): the live entries drained into a fresh +1 elem[]
|
|
1485
1520
|
* in insertion order. Borrows the set; string elements retained in. */
|
|
1486
1521
|
ScrArr *scr_set_to_arr_f64(const ScrMap *s);
|
|
1522
|
+
ScrArr *scr_set_to_arr_bool(const ScrMap *s);
|
|
1487
1523
|
ScrArr *scr_set_to_arr_str(const ScrMap *s);
|
|
1488
1524
|
ScrArr *scr_set_to_arr_ref(const ScrMap *s);
|
|
1489
1525
|
ScrArr *scr_set_to_arr_dyn(const ScrMap *s);
|
|
@@ -3397,6 +3433,7 @@ ScrBigInt *scr_bigint_xor(ScrBigInt *a, ScrBigInt *b);
|
|
|
3397
3433
|
ScrBigInt *scr_bigint_shl(ScrBigInt *a, ScrBigInt *count);
|
|
3398
3434
|
ScrBigInt *scr_bigint_shr(ScrBigInt *a, ScrBigInt *count);
|
|
3399
3435
|
bool scr_bigint_eq(ScrBigInt *a, ScrBigInt *b);
|
|
3436
|
+
uint64_t scr_bigint_hash(const ScrBigInt *value); /* normalized value, no allocation */
|
|
3400
3437
|
bool scr_bigint_eq_string(ScrBigInt *a, ScrStr *b); /* StringToBigInt failure is false */
|
|
3401
3438
|
double scr_bigint_cmp_string(ScrBigInt *a, ScrStr *b); /* 2 = invalid StringToBigInt */
|
|
3402
3439
|
double scr_bigint_cmp_f64(ScrBigInt *a, ScrBigInt *b); /* -1, 0, 1 */
|
|
@@ -3655,7 +3692,7 @@ typedef struct ScrJsval ScrJsval; /* opaque island cell (C11 repeat; the
|
|
|
3655
3692
|
* result as an owned (+1) dyn value. `args` entries are BORROWED. */
|
|
3656
3693
|
typedef ScrDyn *(*ScrDynThunk)(ScrClosure *clo, ScrDyn *const *args, size_t argc);
|
|
3657
3694
|
|
|
3658
|
-
/* Object member. Keys
|
|
3695
|
+
/* Object member. Keys own shared immutable UTF-8 bytes (NUL-terminated for
|
|
3659
3696
|
* convenience; key_len excludes the NUL) — duplicate keys were already
|
|
3660
3697
|
* collapsed at parse time (later wins, like JS JSON.parse). */
|
|
3661
3698
|
typedef struct {
|
|
@@ -3664,13 +3701,22 @@ typedef struct {
|
|
|
3664
3701
|
ScrDyn *value; /* owned */
|
|
3665
3702
|
ScrDyn *getter; /* owned when this is an accessor property */
|
|
3666
3703
|
ScrDyn *setter; /* owned when this is an accessor property */
|
|
3667
|
-
bool accessor;
|
|
3704
|
+
bool accessor : 1;
|
|
3705
|
+
/* Snapshot written by trace before visiting children. Collected teardown
|
|
3706
|
+
* must not inspect the value: an earlier cycle member may already be freed.
|
|
3707
|
+
* Ordinary mutations need not maintain this collector-only decision. */
|
|
3708
|
+
bool value_traced : 1;
|
|
3668
3709
|
/* Ordinary object insertion sets all three attributes true. */
|
|
3669
3710
|
bool writable;
|
|
3670
3711
|
bool enumerable;
|
|
3671
3712
|
bool configurable;
|
|
3672
3713
|
} ScrDynEntry;
|
|
3673
3714
|
|
|
3715
|
+
_Static_assert(sizeof(ScrDynEntry) == (sizeof(void *) == 8 ? 48 : 24),
|
|
3716
|
+
"LLVM checked-object readers use the target entry stride");
|
|
3717
|
+
_Static_assert(offsetof(ScrDynEntry, value) == 2 * sizeof(void *),
|
|
3718
|
+
"LLVM checked-object readers use the third pointer-sized field");
|
|
3719
|
+
|
|
3674
3720
|
struct ScrDyn {
|
|
3675
3721
|
size_t rc; /* SIZE_MAX = immortal (unused for dyn; kept per convention) */
|
|
3676
3722
|
ScrDynKind kind;
|
|
@@ -3713,6 +3759,7 @@ struct ScrDyn {
|
|
|
3713
3759
|
* interfaces may request a fresh snapshot with the true arm. */
|
|
3714
3760
|
void *source_identity;
|
|
3715
3761
|
ScrDyn *(*source_access)(void *, bool materialize);
|
|
3762
|
+
struct ScrDynObjectIndex *index; /* optional wide-object lookup; owns no values */
|
|
3716
3763
|
} obj; /* owned */
|
|
3717
3764
|
/* SCR_DYN_FUNC: the boxed closure (owned) + its call descriptor. `sig`
|
|
3718
3765
|
* and `name` are static compiler-emitted literals (never freed); name
|
|
@@ -3899,6 +3946,12 @@ void scr_dyn_install_async_iterator_symbol(ScrDyn *key);
|
|
|
3899
3946
|
ScrDyn *scr_dyn_array_values_function(void);
|
|
3900
3947
|
ScrDyn *scr_dyn_array_from_iterator(const ScrDyn *value);
|
|
3901
3948
|
ScrDyn *scr_dyn_iterator_result(ScrDyn *value);
|
|
3949
|
+
/* Internal consumption of a captured builtin next method. Check can_step
|
|
3950
|
+
* once before entering the loop. step returns an owned ordinary value;
|
|
3951
|
+
* read step_done immediately afterward, before running any user code. */
|
|
3952
|
+
bool scr_dyn_iterator_can_step(const ScrDyn *iterator, const ScrDyn *next);
|
|
3953
|
+
ScrDyn *scr_dyn_iterator_step(const ScrDyn *iterator);
|
|
3954
|
+
bool scr_dyn_iterator_step_done(const ScrDyn *iterator);
|
|
3902
3955
|
/* The ordinary object snapshot plus a retained typed source. source_access
|
|
3903
3956
|
* releases that source when materialize=false and returns a fresh snapshot
|
|
3904
3957
|
* when true. */
|
|
@@ -4498,6 +4551,8 @@ typedef struct {
|
|
|
4498
4551
|
} ScrJsonBuf;
|
|
4499
4552
|
|
|
4500
4553
|
void scr_jb_init(ScrJsonBuf *b);
|
|
4554
|
+
/* Append a borrowed byte span verbatim, including embedded NUL bytes. */
|
|
4555
|
+
void scr_jb_write(ScrJsonBuf *b, const char *s, size_t n);
|
|
4501
4556
|
/* Append one borrowed runtime string verbatim (no JSON quoting). */
|
|
4502
4557
|
void scr_jb_put_str(ScrJsonBuf *b, const ScrStr *s);
|
|
4503
4558
|
/* Push a container onto the circular-detection stack before serializing
|
|
@@ -5793,9 +5848,10 @@ ScrBytes *scr_array_buffer_view_dv(ScrDyn *, ScrDyn *, ScrDyn *);
|
|
|
5793
5848
|
/* Native callback boundary: exact owned u8 copy. NULL with len == 0 is an
|
|
5794
5849
|
* empty span. */
|
|
5795
5850
|
ScrBytes *scr_bytes_from_data(const uint8_t *data, size_t len); /* +1 */
|
|
5851
|
+
ScrBytes *scr_bytes_take_data(uint8_t *data, size_t len); /* +1, consumes malloc storage */
|
|
5796
5852
|
|
|
5797
|
-
/*
|
|
5798
|
-
*
|
|
5853
|
+
/* Same-element-kind copy, preserving the raw representation. Cross-kind
|
|
5854
|
+
* construction uses scr_bytes_convert. Borrows src. Never throws. */
|
|
5799
5855
|
ScrBytes *scr_bytes_copy(const ScrBytes *src); /* +1 */
|
|
5800
5856
|
|
|
5801
5857
|
/* `new Uint8Array([1, 2, 3])` / Buffer.from(number[]): each f64 element
|
|
@@ -5959,6 +6015,7 @@ ScrStr *scr_text_decode_legacy(const ScrBytes *b, double encoding);
|
|
|
5959
6015
|
* "utf16le" writes LE code units, surrogate pairs included. Borrows
|
|
5960
6016
|
* both; +1 u8 result. Never throws. */
|
|
5961
6017
|
ScrBytes *scr_bytes_from_str(const ScrStr *s, const ScrStr *enc);
|
|
6018
|
+
ScrBytes *scr_bytes_from_str_checked(const ScrStr *s, const ScrStr *enc);
|
|
5962
6019
|
|
|
5963
6020
|
/* Buffer.byteLength(string, enc) — enc NORMALIZED like from_str — and
|
|
5964
6021
|
* Buffer.isEncoding(name) (case-insensitive over Node's alias set).
|