@scriptc/cli-darwin-arm64 0.2.2 → 0.2.4
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 +99 -27
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-arm64/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/runtime-pack.json +399 -273
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_array.c +55 -34
- package/dist/lib/runtime-sources/src/scr_assert.c +26 -0
- package/dist/lib/runtime-sources/src/scr_async.c +44 -0
- package/dist/lib/runtime-sources/src/scr_bigint.c +15 -0
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +305 -48
- package/dist/lib/runtime-sources/src/scr_cycle.c +84 -60
- package/dist/lib/runtime-sources/src/scr_events.c +9 -0
- package/dist/lib/runtime-sources/src/scr_exception.c +1 -0
- package/dist/lib/runtime-sources/src/scr_file_handle.c +11 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1001 -417
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -7
- package/dist/lib/runtime-sources/src/scr_json.c +150 -13
- package/dist/lib/runtime-sources/src/scr_lib.c +424 -28
- package/dist/lib/runtime-sources/src/scr_map.c +236 -40
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +78 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +112 -8
- package/dist/lib/runtime-sources/src/scr_runtime.h +108 -14
- package/dist/lib/runtime-sources/src/scr_string.c +29 -0
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_system_errors.h +573 -0
- package/dist/lib/runtime-sources/src/scr_url.c +515 -59
- package/dist/lib/runtime-sources/src/scr_url_internal.h +6 -0
- package/dist/lib/runtime-sources/src/scr_url_params.c +10 -0
- package/dist/lib/runtime-sources/src/scr_util_compare.c +222 -0
- package/dist/lib/runtime-sources/src/scr_util_style.c +337 -0
- package/dist/lib/runtime-sources/src/scr_web.c +720 -238
- package/package.json +1 -1
|
@@ -434,8 +434,10 @@ ScrArr *scr_arr_new(ScrElemKind elem, size_t initial_cap) {
|
|
|
434
434
|
* below releases none — the complement contract in scr_runtime.h. */
|
|
435
435
|
void scr_arr_trace_v(void *a0, ScrTraceVisit visit, void *ctx) {
|
|
436
436
|
ScrArr *a = (ScrArr *)a0;
|
|
437
|
-
visit(a->metadata, ctx);
|
|
438
|
-
|
|
437
|
+
if (a->metadata) visit(a->metadata, ctx);
|
|
438
|
+
/* Growth and truncation leave spare capacity empty. Sparse slots and
|
|
439
|
+
* named properties are separate edges, independent of dense length. */
|
|
440
|
+
for (size_t i = 0, end = a->len < a->cap ? a->len : a->cap; i < end; i++) {
|
|
439
441
|
if (a->present[i] == SCR_ARR_VALUE) visit(scr_slot_to_ptr(a->data[i]), ctx);
|
|
440
442
|
}
|
|
441
443
|
for (size_t i = 0; i < a->sparse_len; i++) {
|
|
@@ -503,7 +505,7 @@ void scr_arr_release(ScrArr *a) {
|
|
|
503
505
|
scr_dyn_release(a->metadata);
|
|
504
506
|
a->metadata = NULL;
|
|
505
507
|
if (scr_elem_is_ref(a->elem)) {
|
|
506
|
-
for (size_t i = 0
|
|
508
|
+
for (size_t i = 0, end = a->len < a->cap ? a->len : a->cap; i < end; i++) {
|
|
507
509
|
if (a->present[i] != SCR_ARR_HOLE) {
|
|
508
510
|
uint64_t old = a->data[i];
|
|
509
511
|
uint8_t state = a->present[i];
|
|
@@ -796,6 +798,11 @@ static bool scr_arr_read_value(const ScrArr *a, double i, uint64_t *slot) {
|
|
|
796
798
|
return state == SCR_ARR_VALUE;
|
|
797
799
|
}
|
|
798
800
|
|
|
801
|
+
void *scr_arr_peek_ref(const ScrArr *a, double i) {
|
|
802
|
+
uint64_t slot;
|
|
803
|
+
return scr_arr_read_value(a, i, &slot) ? scr_slot_to_ptr(slot) : NULL;
|
|
804
|
+
}
|
|
805
|
+
|
|
799
806
|
double scr_arr_get_number(const ScrArr *a, double i) {
|
|
800
807
|
/* Keep this hot numeric-only entry self-contained: routing it through
|
|
801
808
|
* scr_arr_read_value adds an out-of-line call at -O2 on native targets. */
|
|
@@ -1328,21 +1335,26 @@ bool scr_arr_includes_ref(ScrArr *a, void *v) {
|
|
|
1328
1335
|
|
|
1329
1336
|
/* ── join ──────────────────────────────────────────────────────────────── */
|
|
1330
1337
|
|
|
1331
|
-
static
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1338
|
+
static size_t scr_join_size(size_t len, size_t extra) {
|
|
1339
|
+
if (extra > SIZE_MAX - sizeof(ScrStr) - 1 - len) scr_arr_oom();
|
|
1340
|
+
return len + extra;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/* The builder owns the final string allocation throughout construction.
|
|
1344
|
+
* It has no aliases or index-cache entries, and no user callbacks run while
|
|
1345
|
+
* appending primitive array values. Finish by publishing the terminator. */
|
|
1346
|
+
static void scr_join_append(ScrStr **out, const char *bytes, size_t n) {
|
|
1347
|
+
ScrStr *s = *out;
|
|
1348
|
+
size_t need = scr_join_size(s->len, n);
|
|
1349
|
+
if (need > s->cap) {
|
|
1350
|
+
const size_t limit = SIZE_MAX - sizeof(ScrStr) - 1;
|
|
1351
|
+
size_t cap = s->cap;
|
|
1352
|
+
while (cap < need) cap = cap > limit / 2 ? need : cap * 2;
|
|
1353
|
+
s = scr_str_regrow(s, cap);
|
|
1354
|
+
*out = s;
|
|
1343
1355
|
}
|
|
1344
|
-
memcpy(
|
|
1345
|
-
|
|
1356
|
+
memcpy(s->data + s->len, bytes, n);
|
|
1357
|
+
s->len = need;
|
|
1346
1358
|
}
|
|
1347
1359
|
|
|
1348
1360
|
/* `a.slice(start?, end?)` — a fresh shallow copy of the index range,
|
|
@@ -1385,11 +1397,24 @@ ScrArr *scr_arr_slice(ScrArr *a, double start, double end) {
|
|
|
1385
1397
|
}
|
|
1386
1398
|
|
|
1387
1399
|
ScrStr *scr_arr_join(ScrArr *a, ScrStr *sep) {
|
|
1388
|
-
size_t cap = 64
|
|
1389
|
-
|
|
1390
|
-
|
|
1400
|
+
size_t cap = 64;
|
|
1401
|
+
/* String widths are already known. Size once to avoid growth and copying
|
|
1402
|
+
* even when the array holds holes, explicit undefined or sparse slots.
|
|
1403
|
+
* Numeric formatting stays single-pass rather than formatting twice. */
|
|
1404
|
+
if (a->elem == SCR_ELEM_STR) {
|
|
1405
|
+
const size_t limit = SIZE_MAX - sizeof(ScrStr) - 1;
|
|
1406
|
+
if (a->len > 1 && sep->len > limit / (a->len - 1)) scr_arr_oom();
|
|
1407
|
+
cap = a->len > 1 ? (a->len - 1) * sep->len : 0;
|
|
1408
|
+
for (size_t i = 0; i < a->len; i++) {
|
|
1409
|
+
uint64_t slot;
|
|
1410
|
+
if (scr_arr_state_at(a, i, &slot) != SCR_ARR_VALUE) continue;
|
|
1411
|
+
const ScrStr *s = (const ScrStr *)scr_slot_to_ptr(slot);
|
|
1412
|
+
if (s) cap = scr_join_size(cap, s->len);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
ScrStr *out = scr_str_alloc_raw(0, cap);
|
|
1391
1416
|
for (size_t i = 0; i < a->len; i++) {
|
|
1392
|
-
if (i > 0) scr_join_append(&
|
|
1417
|
+
if (i > 0) scr_join_append(&out, sep->data, sep->len);
|
|
1393
1418
|
uint64_t slot;
|
|
1394
1419
|
uint8_t state = scr_arr_state_at(a, i, &slot);
|
|
1395
1420
|
if (state != SCR_ARR_VALUE) continue;
|
|
@@ -1397,16 +1422,16 @@ ScrStr *scr_arr_join(ScrArr *a, ScrStr *sep) {
|
|
|
1397
1422
|
case SCR_ELEM_F64: {
|
|
1398
1423
|
char nb[32];
|
|
1399
1424
|
size_t n = scr_f64_to_str(scr_slot_to_f64(slot), nb);
|
|
1400
|
-
scr_join_append(&
|
|
1425
|
+
scr_join_append(&out, nb, n);
|
|
1401
1426
|
break;
|
|
1402
1427
|
}
|
|
1403
1428
|
case SCR_ELEM_BOOL:
|
|
1404
|
-
if (slot != 0) scr_join_append(&
|
|
1405
|
-
else scr_join_append(&
|
|
1429
|
+
if (slot != 0) scr_join_append(&out, "true", 4);
|
|
1430
|
+
else scr_join_append(&out, "false", 5);
|
|
1406
1431
|
break;
|
|
1407
1432
|
case SCR_ELEM_STR: {
|
|
1408
1433
|
const ScrStr *s = (const ScrStr *)scr_slot_to_ptr(slot);
|
|
1409
|
-
if (s) scr_join_append(&
|
|
1434
|
+
if (s) scr_join_append(&out, s->data, s->len);
|
|
1410
1435
|
break;
|
|
1411
1436
|
}
|
|
1412
1437
|
case SCR_ELEM_ARR:
|
|
@@ -1416,8 +1441,7 @@ ScrStr *scr_arr_join(ScrArr *a, ScrStr *sep) {
|
|
|
1416
1441
|
scr_trap("scriptc: internal error: join on a ref-element array\n");
|
|
1417
1442
|
}
|
|
1418
1443
|
}
|
|
1419
|
-
|
|
1420
|
-
free(buf);
|
|
1444
|
+
out->data[out->len] = '\0';
|
|
1421
1445
|
return out;
|
|
1422
1446
|
}
|
|
1423
1447
|
|
|
@@ -1427,25 +1451,22 @@ ScrStr *scr_arr_join(ScrArr *a, ScrStr *sep) {
|
|
|
1427
1451
|
* missing ones skip, exactly the spec's loop. Both arrays are
|
|
1428
1452
|
* SCR_ELEM_STR; borrows both; +1 result. Never throws. */
|
|
1429
1453
|
ScrStr *scr_str_raw(ScrArr *raw, ScrArr *subs) {
|
|
1430
|
-
|
|
1431
|
-
char *buf = malloc(cap);
|
|
1432
|
-
if (!buf) scr_arr_oom();
|
|
1454
|
+
ScrStr *out = scr_str_alloc_raw(0, 64);
|
|
1433
1455
|
for (size_t i = 0; i < raw->len; i++) {
|
|
1434
1456
|
uint64_t raw_slot;
|
|
1435
1457
|
if (scr_arr_slot_at(raw, i, &raw_slot)) {
|
|
1436
1458
|
const ScrStr *s = (const ScrStr *)scr_slot_to_ptr(raw_slot);
|
|
1437
|
-
if (s) scr_join_append(&
|
|
1459
|
+
if (s) scr_join_append(&out, s->data, s->len);
|
|
1438
1460
|
}
|
|
1439
1461
|
if (i + 1 < raw->len && i < subs->len) {
|
|
1440
1462
|
uint64_t sub_slot;
|
|
1441
1463
|
if (scr_arr_slot_at(subs, i, &sub_slot)) {
|
|
1442
1464
|
const ScrStr *v = (const ScrStr *)scr_slot_to_ptr(sub_slot);
|
|
1443
|
-
if (v) scr_join_append(&
|
|
1465
|
+
if (v) scr_join_append(&out, v->data, v->len);
|
|
1444
1466
|
}
|
|
1445
1467
|
}
|
|
1446
1468
|
}
|
|
1447
|
-
|
|
1448
|
-
free(buf);
|
|
1469
|
+
out->data[out->len] = '\0';
|
|
1449
1470
|
return out;
|
|
1450
1471
|
}
|
|
1451
1472
|
|
|
@@ -1481,6 +1481,32 @@ void scr_assert_unwanted_rejection(ScrError *err, ScrStr *msg, bool has_msg) {
|
|
|
1481
1481
|
scr_assert_fail_msg(ab_take(&b));
|
|
1482
1482
|
}
|
|
1483
1483
|
|
|
1484
|
+
void scr_assert_unwanted_error(ScrStr *actual_message, bool rejection, ScrStr *msg, bool has_msg) {
|
|
1485
|
+
ScrAssertBuf b = {0};
|
|
1486
|
+
ab_cstr(&b, rejection ? "Got unwanted rejection" : "Got unwanted exception");
|
|
1487
|
+
if (has_msg && msg->len) {
|
|
1488
|
+
ab_cstr(&b, ": ");
|
|
1489
|
+
ab_str(&b, msg);
|
|
1490
|
+
} else ab_char(&b, '.');
|
|
1491
|
+
ab_cstr(&b, "\nActual message: \"");
|
|
1492
|
+
ab_str(&b, actual_message);
|
|
1493
|
+
ab_char(&b, '"');
|
|
1494
|
+
scr_assert_fail_msg(ab_take(&b));
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/* Node calls validation functions with a fresh object receiver and accepts
|
|
1498
|
+
* only the boolean true. A callback exception remains the pending exception. */
|
|
1499
|
+
bool scr_assert_no_error_predicate(ScrDyn *predicate, ScrDyn *actual) {
|
|
1500
|
+
ScrDyn *receiver = scr_dyn_new_obj();
|
|
1501
|
+
scr_dyn_this_push_dyn(receiver);
|
|
1502
|
+
ScrDyn *result = scr_dyn_call(predicate, &actual, 1, "expected");
|
|
1503
|
+
scr_dyn_this_pop();
|
|
1504
|
+
scr_dyn_release(receiver);
|
|
1505
|
+
bool matched = result && result->kind == SCR_DYN_BOOL && result->v.b;
|
|
1506
|
+
scr_dyn_release(result);
|
|
1507
|
+
return matched;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1484
1510
|
/* ── assert.ifError ───────────────────────────────────────────────────
|
|
1485
1511
|
* Node throws for ANY value but null/undefined (falsy included); the
|
|
1486
1512
|
* frontend routes null/undefined to a no-op and everything else here.
|
|
@@ -1758,6 +1758,50 @@ ScrPromise *scr_fsp_chmod(ScrStr *path, double mode) {
|
|
|
1758
1758
|
return scr_promise_settled_void();
|
|
1759
1759
|
}
|
|
1760
1760
|
|
|
1761
|
+
ScrPromise *scr_fsp_utimes(const ScrDyn *path, const ScrDyn *atime, const ScrDyn *mtime) {
|
|
1762
|
+
scr_fs_utimes_checked(path, atime, mtime);
|
|
1763
|
+
return scr_promise_settled_void();
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
ScrPromise *scr_fsp_link(const ScrDyn *existing, const ScrDyn *destination) {
|
|
1767
|
+
scr_fs_link_checked(existing, destination);
|
|
1768
|
+
return scr_promise_settled_void();
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
ScrPromise *scr_fsp_symlink(const ScrDyn *target, const ScrDyn *destination, const ScrDyn *type) {
|
|
1772
|
+
scr_fs_symlink_promise_checked(target, destination, type);
|
|
1773
|
+
return scr_promise_settled_void();
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
ScrPromise *scr_fsp_readlink_dyn(const ScrDyn *path, const ScrDyn *options) {
|
|
1777
|
+
ScrDyn *result = scr_fs_readlink_checked(path, options, true);
|
|
1778
|
+
return scr_promise_settled_ref(result, scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
ScrPromise *scr_fsp_statfs(const ScrDyn *path, const ScrDyn *options) {
|
|
1782
|
+
ScrDyn *result = scr_fs_statfs_checked(path, options);
|
|
1783
|
+
return scr_promise_settled_ref(result, scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
ScrPromise *scr_fsp_readlink_str(const ScrDyn *path, const ScrDyn *options) {
|
|
1787
|
+
ScrDyn *result = scr_fs_readlink_checked(path, options, true);
|
|
1788
|
+
ScrStr *text = result && result->kind == SCR_DYN_STR ? scr_str_retain(result->v.str) : NULL;
|
|
1789
|
+
scr_dyn_release(result);
|
|
1790
|
+
return scr_promise_settled_str(text);
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
ScrPromise *scr_fsp_readlink_buffer(const ScrDyn *path, const ScrDyn *options) {
|
|
1794
|
+
ScrDyn *result = scr_fs_readlink_checked(path, options, true);
|
|
1795
|
+
ScrBytes *bytes = result ? scr_dyn_bytes_unbox(result) : NULL;
|
|
1796
|
+
scr_dyn_release(result);
|
|
1797
|
+
return scr_promise_settled_ref(bytes, scr_bytes_retain_v, scr_bytes_release_v, NULL);
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
ScrPromise *scr_fsp_lutimes(const ScrDyn *path, const ScrDyn *atime, const ScrDyn *mtime) {
|
|
1801
|
+
scr_fs_lutimes_checked(path, atime, mtime);
|
|
1802
|
+
return scr_promise_settled_void();
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1761
1805
|
ScrPromise *scr_fsp_readdir(ScrStr *path) {
|
|
1762
1806
|
ScrArr *names = scr_fs_readdir(path);
|
|
1763
1807
|
return scr_promise_settled_ref(names, &scr_arr_retain_v, &scr_arr_release_v, NULL);
|
|
@@ -132,6 +132,21 @@ static int bi_cmp(const ScrBigInt *a, const ScrBigInt *b) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
bool scr_bigint_eq(ScrBigInt *a, ScrBigInt *b) { return bi_cmp(a, b) == 0; }
|
|
135
|
+
|
|
136
|
+
uint64_t scr_bigint_hash(const ScrBigInt *value) {
|
|
137
|
+
/* BigInts are immutable and normalized. Ignore capacity and ownership;
|
|
138
|
+
* equal values made by parsing, arithmetic or conversion hash alike. */
|
|
139
|
+
uint64_t hash = UINT64_C(0xcbf29ce484222325) ^ (uint64_t)(value->sign + 1);
|
|
140
|
+
for (size_t i = 0; i < value->len; i++) {
|
|
141
|
+
hash ^= value->limb[i];
|
|
142
|
+
hash *= UINT64_C(0x100000001b3);
|
|
143
|
+
}
|
|
144
|
+
hash ^= hash >> 30;
|
|
145
|
+
hash *= UINT64_C(0xbf58476d1ce4e5b9);
|
|
146
|
+
hash ^= hash >> 27;
|
|
147
|
+
hash *= UINT64_C(0x94d049bb133111eb);
|
|
148
|
+
return hash ^ (hash >> 31);
|
|
149
|
+
}
|
|
135
150
|
double scr_bigint_cmp_f64(ScrBigInt *a, ScrBigInt *b) { return (double)bi_cmp(a, b); }
|
|
136
151
|
bool scr_bigint_truthy(ScrBigInt *v) { return v->sign != 0; }
|
|
137
152
|
|