@scriptc/cli-darwin-arm64 0.2.4 → 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-arm64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes.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_copying.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_number.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/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes.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_copying.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_number.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-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.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_bytes.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_copying.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_number.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/text-decoder-legacy/scr_bytes.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_bytes.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_copying.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_number.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/text-decoder-legacy/scr_bytes.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_bytes.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_copying.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_number.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/text-decoder-legacy/scr_bytes.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_bytes.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_copying.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_number.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/text-decoder-legacy/scr_bytes.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_bytes.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_copying.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_number.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_util_compare.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_bytes.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_copying.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_number.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_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/runtime-pack.json +181 -181
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_array.c +267 -6
- package/dist/lib/runtime-sources/src/scr_async.test.ts +16 -6
- 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_json.c +479 -150
- 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 +132 -73
- package/dist/lib/runtime-sources/src/scr_map.c +50 -66
- 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 +238 -167
- package/dist/lib/runtime-sources/src/scr_runtime.h +37 -6
- package/dist/lib/runtime-sources/src/scr_string.c +155 -42
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#include "scr_runtime.h"
|
|
2
|
+
#include <assert.h>
|
|
3
|
+
#include <math.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
|
|
6
|
+
long scr_bytes_live_count(void);
|
|
7
|
+
|
|
8
|
+
/* Foreign wrappers may alias without a shared owner and may be unaligned. */
|
|
9
|
+
static ScrBytes *external(uint8_t *data, ScrBytesElem elem, size_t count) {
|
|
10
|
+
ScrBytes *view = scr_bytes_from_external(data, count * scr_bytes_elem_size(elem));
|
|
11
|
+
view->elem = elem;
|
|
12
|
+
view->len = count;
|
|
13
|
+
return view;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static void external_set(void) {
|
|
17
|
+
const size_t starts[] = {1, 9, 41, 3001};
|
|
18
|
+
uint8_t storage[6000], expected[6000];
|
|
19
|
+
for (ScrBytesElem from = SCR_BYTES_U8; from <= SCR_BYTES_U8C; from++) {
|
|
20
|
+
for (ScrBytesElem to = SCR_BYTES_U8; to <= SCR_BYTES_U8C; to++) {
|
|
21
|
+
for (size_t j = 0; j < sizeof starts / sizeof starts[0]; j++) {
|
|
22
|
+
memset(storage, 0x5a, sizeof storage);
|
|
23
|
+
ScrBytes *src = external(storage + 9, from, 259);
|
|
24
|
+
ScrBytes *dst = external(storage + starts[j], to, 263);
|
|
25
|
+
for (size_t i = 0; i < src->len; i++) scr_bytes_set(src, i, (double)i * 3.5 - 257);
|
|
26
|
+
memcpy(expected, storage, sizeof storage);
|
|
27
|
+
ScrBytes *want = external(expected + starts[j], to, 263);
|
|
28
|
+
for (size_t i = 0; i < src->len; i++) scr_bytes_set(want, i + 2, scr_bytes_get(src, i));
|
|
29
|
+
scr_bytes_set_from(dst, src, 2);
|
|
30
|
+
assert(!scr_exc_pending());
|
|
31
|
+
assert(memcmp(storage, expected, sizeof storage) == 0);
|
|
32
|
+
scr_bytes_release(want);
|
|
33
|
+
scr_bytes_release(dst);
|
|
34
|
+
scr_bytes_release(src);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static void copied_storage(void) {
|
|
41
|
+
/* Same-kind copies preserve NaN payloads, signed zero and ownership. */
|
|
42
|
+
const uint64_t bits[] = {UINT64_C(0x7ff8000000000042), UINT64_C(0x8000000000000000),
|
|
43
|
+
UINT64_C(0xfff0000000000000)};
|
|
44
|
+
ScrBytes *src = scr_bytes_new(SCR_BYTES_F64, 3);
|
|
45
|
+
memcpy(src->data, bits, sizeof bits);
|
|
46
|
+
ScrBytes *copy = scr_bytes_convert(SCR_BYTES_F64, src);
|
|
47
|
+
ScrBytes *slice = scr_bytes_slice(src, 0, 3);
|
|
48
|
+
assert(copy->data != src->data && slice->data != src->data);
|
|
49
|
+
assert(memcmp(copy->data, bits, sizeof bits) == 0);
|
|
50
|
+
assert(memcmp(slice->data, bits, sizeof bits) == 0);
|
|
51
|
+
ScrBytes *view = scr_bytes_subarray(copy, 1, 3);
|
|
52
|
+
scr_bytes_release(copy);
|
|
53
|
+
scr_bytes_release(src);
|
|
54
|
+
assert(memcmp(view->data, bits + 1, sizeof bits - sizeof bits[0]) == 0);
|
|
55
|
+
scr_bytes_release(view);
|
|
56
|
+
scr_bytes_release(slice);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static void filled_storage(void) {
|
|
60
|
+
uint8_t storage[2200], expected[2200];
|
|
61
|
+
const double values[] = {-0.0, -1.5, 2.5, 255.5, 4294967297.0, NAN, INFINITY};
|
|
62
|
+
for (ScrBytesElem elem = SCR_BYTES_U8; elem <= SCR_BYTES_U8C; elem++) {
|
|
63
|
+
for (size_t j = 0; j < sizeof values / sizeof values[0]; j++) {
|
|
64
|
+
memset(storage, 0xa5, sizeof storage);
|
|
65
|
+
memcpy(expected, storage, sizeof storage);
|
|
66
|
+
ScrBytes *dst = external(storage + 1, elem, 263);
|
|
67
|
+
ScrBytes *want = external(expected + 1, elem, 263);
|
|
68
|
+
for (size_t i = 2; i < 261; i++) scr_bytes_set(want, i, values[j]);
|
|
69
|
+
ScrBytes *result = scr_bytes_fill_elem(dst, values[j], 2, 261);
|
|
70
|
+
assert(result == dst && dst->rc == 2);
|
|
71
|
+
assert(memcmp(storage, expected, sizeof storage) == 0);
|
|
72
|
+
scr_bytes_release(result);
|
|
73
|
+
scr_bytes_release(dst);
|
|
74
|
+
scr_bytes_release(want);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void scr_bytes_test_bulk_storage(void) {
|
|
80
|
+
long before = scr_bytes_live_count();
|
|
81
|
+
external_set();
|
|
82
|
+
copied_storage();
|
|
83
|
+
filled_storage();
|
|
84
|
+
assert(scr_bytes_live_count() == before);
|
|
85
|
+
}
|
|
@@ -37,40 +37,6 @@ static void scr_bytes_io_oom(void) {
|
|
|
37
37
|
|
|
38
38
|
/* ── fs (the Buffer forms of scr_lib.c's utf8 pair) ────────────────────── */
|
|
39
39
|
|
|
40
|
-
ScrBytes *scr_fs_read_file_bytes(ScrStr *path) {
|
|
41
|
-
FILE *f = fopen(path->data, "rb");
|
|
42
|
-
if (!f) {
|
|
43
|
-
scr_fs_throw(errno, "open", path);
|
|
44
|
-
return NULL;
|
|
45
|
-
}
|
|
46
|
-
size_t cap = 4096, len = 0;
|
|
47
|
-
uint8_t *buf = malloc(cap);
|
|
48
|
-
if (!buf) scr_bytes_io_oom();
|
|
49
|
-
for (;;) {
|
|
50
|
-
if (cap - len < 2048) {
|
|
51
|
-
cap *= 2;
|
|
52
|
-
uint8_t *grown = realloc(buf, cap);
|
|
53
|
-
if (!grown) scr_bytes_io_oom();
|
|
54
|
-
buf = grown;
|
|
55
|
-
}
|
|
56
|
-
size_t n = fread(buf + len, 1, cap - len, f);
|
|
57
|
-
len += n;
|
|
58
|
-
if (n == 0) break;
|
|
59
|
-
}
|
|
60
|
-
if (ferror(f)) {
|
|
61
|
-
int e = errno;
|
|
62
|
-
fclose(f);
|
|
63
|
-
free(buf);
|
|
64
|
-
scr_fs_throw(e, "read", path);
|
|
65
|
-
return NULL;
|
|
66
|
-
}
|
|
67
|
-
fclose(f);
|
|
68
|
-
ScrBytes *b = scr_bytes_new(SCR_BYTES_U8, (double)len);
|
|
69
|
-
memcpy(b->data, buf, len);
|
|
70
|
-
free(buf);
|
|
71
|
-
return b;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
40
|
/* readFileSync's runtime-encoding form (a JS helper's untyped `enc`
|
|
75
41
|
* parameter — test/common fixtures.js): undefined/null answer a Buffer,
|
|
76
42
|
* utf8 answers a string, Node's other real encodings meet the loud
|
|
@@ -125,9 +125,19 @@ ScrArr *scr_arr_with_undefined(ScrArr *a, double index) {
|
|
|
125
125
|
|
|
126
126
|
ScrBytes *scr_bytes_to_reversed(const ScrBytes *b) {
|
|
127
127
|
ScrBytes *out = scr_bytes_new(b->elem, (double)b->len);
|
|
128
|
+
size_t width = scr_bytes_elem_size(b->elem);
|
|
129
|
+
/* Copy the stored representation without numeric conversion. Views may
|
|
130
|
+
* be unaligned, so fixed-width memcpy preserves both alignment safety
|
|
131
|
+
* and floating-point payload bits. The width is invariant for the loop. */
|
|
128
132
|
for (size_t i = 0; i < b->len; i++) {
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
const uint8_t *source = b->data + (b->len - i - 1) * width;
|
|
134
|
+
uint8_t *target = out->data + i * width;
|
|
135
|
+
switch (width) {
|
|
136
|
+
case 1: *target = *source; break;
|
|
137
|
+
case 2: memcpy(target, source, 2); break;
|
|
138
|
+
case 4: memcpy(target, source, 4); break;
|
|
139
|
+
case 8: memcpy(target, source, 8); break;
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
return out;
|
|
133
143
|
}
|