@scriptc/cli-darwin-x64 0.2.1 → 0.2.3
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 +158 -31
- 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_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.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_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.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_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url_params.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/default/scr_util_style.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_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.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_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.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_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url_params.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/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.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_assert.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_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.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_node_builtin.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url_params.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_assert.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_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.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_node_builtin.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url_params.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_assert.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_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.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_node_builtin.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url_params.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_assert.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_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.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_node_builtin.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url_params.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_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.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_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.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_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url_params.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/default/scr_util_style.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_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.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_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.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_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.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_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url_params.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/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.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 +423 -297
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
- package/dist/lib/runtime-sources/src/scr_array.c +5 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +26 -0
- package/dist/lib/runtime-sources/src/scr_async.c +56 -4
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +118 -24
- package/dist/lib/runtime-sources/src/scr_bytes.c +226 -0
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +355 -51
- package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +181 -43
- 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_fetch.c +45 -1
- package/dist/lib/runtime-sources/src/scr_file_handle.c +42 -0
- package/dist/lib/runtime-sources/src/scr_island.c +2166 -786
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +19 -13
- package/dist/lib/runtime-sources/src/scr_json.c +584 -54
- package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +1192 -43
- package/dist/lib/runtime-sources/src/scr_map.c +8 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +78 -0
- package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +107 -5
- package/dist/lib/runtime-sources/src/scr_runtime.h +136 -9
- 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_text_decoder_labels.h +12 -12
- package/dist/lib/runtime-sources/src/scr_url.c +547 -64
- 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 +849 -264
- package/package.json +1 -1
|
@@ -649,6 +649,14 @@ void scr_map_dyn_set(ScrMap *map, const ScrDyn *key, const ScrDyn *value, bool s
|
|
|
649
649
|
scr_map_release_key(map, key_slot);
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
+
ScrArr *scr_set_to_arr_dyn(const ScrMap *map) {
|
|
653
|
+
ScrArr *out = scr_arr_new_ref(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v, map->nlive);
|
|
654
|
+
for (size_t i = 0; i < map->nentries; i++) {
|
|
655
|
+
if (scr_map_iter_live(map, (double)i)) scr_arr_push_ref(out, scr_map_dyn_key(map, (double)i));
|
|
656
|
+
}
|
|
657
|
+
return out;
|
|
658
|
+
}
|
|
659
|
+
|
|
652
660
|
void *scr_map_iter_val_ref(const ScrMap *m, double i) {
|
|
653
661
|
return m->val_retain(scr_map_slot_to_ptr(scr_map_iter_at(m, i)->val)); /* +1 */
|
|
654
662
|
}
|
|
@@ -1,11 +1,89 @@
|
|
|
1
1
|
/* Native builtin export objects. The compiler supplies the existing static
|
|
2
2
|
* callable implementations; this unit owns lookup, identity, and mutations. */
|
|
3
3
|
#include "scr_runtime.h"
|
|
4
|
+
#include "scr_system_errors.h"
|
|
4
5
|
|
|
5
6
|
#include <stdlib.h>
|
|
6
7
|
#include <string.h>
|
|
7
8
|
#include <math.h>
|
|
8
9
|
|
|
10
|
+
typedef struct { int value; const char *name; const char *message; } ScrSystemError;
|
|
11
|
+
#define SCR_SYSTEM_ERROR(name, message) { SCR_NODE_UV__##name, #name, message },
|
|
12
|
+
static const ScrSystemError scr_system_errors[] = {
|
|
13
|
+
SCR_NODE_UV_ERRNO_MAP(SCR_SYSTEM_ERROR)
|
|
14
|
+
};
|
|
15
|
+
#undef SCR_SYSTEM_ERROR
|
|
16
|
+
|
|
17
|
+
static bool scr_system_error_number(const ScrDyn *error, double *number) {
|
|
18
|
+
if (!error || error->kind != SCR_DYN_NUM) {
|
|
19
|
+
scr_dyn_arg_type_fail("err", "of type number", error ? error : scr_dyn_undefined());
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
double n = error->v.num;
|
|
23
|
+
if (!(isfinite(n) && n < 0 && trunc(n) == n && n >= -9007199254740991.0)) {
|
|
24
|
+
char received[48];
|
|
25
|
+
scr_num_received(n, received);
|
|
26
|
+
if (n == 0 && signbit(n)) strcpy(received, "-0");
|
|
27
|
+
ScrJsonBuf buffer;
|
|
28
|
+
scr_jb_init(&buffer);
|
|
29
|
+
scr_jb_puts(&buffer, "The value of \"err\" is out of range. It must be a negative integer. Received ");
|
|
30
|
+
scr_jb_puts(&buffer, received);
|
|
31
|
+
ScrStr *message = scr_jb_finish(&buffer);
|
|
32
|
+
scr_throw_error_msg_code(SCR_ERR_RANGE, message->data, message->len, "ERR_OUT_OF_RANGE");
|
|
33
|
+
scr_str_release(message);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
*number = n;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static ScrStr *scr_system_error_lookup(double number, bool message) {
|
|
41
|
+
/* Node's name helper looks up the original safe integer. Its message
|
|
42
|
+
* binding uses V8's saturating Int32 extraction instead. */
|
|
43
|
+
double lookup = message && number < -2147483648.0 ? -2147483648.0 : number;
|
|
44
|
+
for (size_t i = 0; i < sizeof scr_system_errors / sizeof scr_system_errors[0]; i++) {
|
|
45
|
+
if (lookup == scr_system_errors[i].value) {
|
|
46
|
+
const char *text = message ? scr_system_errors[i].message : scr_system_errors[i].name;
|
|
47
|
+
return scr_str_new(text, strlen(text));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
ScrJsonBuf buffer;
|
|
51
|
+
scr_jb_init(&buffer);
|
|
52
|
+
scr_jb_puts(&buffer, "Unknown system error ");
|
|
53
|
+
ScrStr *rendered = scr_f64_to_scrstr(lookup);
|
|
54
|
+
scr_jb_put_str(&buffer, rendered);
|
|
55
|
+
scr_str_release(rendered);
|
|
56
|
+
return scr_jb_finish(&buffer);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ScrStr *scr_util_system_error_name(const ScrDyn *error) {
|
|
60
|
+
double number;
|
|
61
|
+
return scr_system_error_number(error, &number) ? scr_system_error_lookup(number, false) : NULL;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ScrStr *scr_util_system_error_message(const ScrDyn *error) {
|
|
65
|
+
double number;
|
|
66
|
+
return scr_system_error_number(error, &number) ? scr_system_error_lookup(number, true) : NULL;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
ScrDyn *scr_util_system_error_entries(void) {
|
|
70
|
+
ScrDyn *entries = scr_dyn_new_arr();
|
|
71
|
+
for (size_t i = 0; i < sizeof scr_system_errors / sizeof scr_system_errors[0]; i++) {
|
|
72
|
+
const ScrSystemError *error = &scr_system_errors[i];
|
|
73
|
+
ScrDyn *entry = scr_dyn_new_arr(), *pair = scr_dyn_new_arr();
|
|
74
|
+
ScrStr *name = scr_str_new(error->name, strlen(error->name));
|
|
75
|
+
ScrStr *message = scr_str_new(error->message, strlen(error->message));
|
|
76
|
+
scr_dyn_arr_push(pair, scr_dyn_new_str(name));
|
|
77
|
+
scr_dyn_arr_push(pair, scr_dyn_new_str(message));
|
|
78
|
+
scr_str_release(name);
|
|
79
|
+
scr_str_release(message);
|
|
80
|
+
scr_dyn_arr_push(entry, scr_dyn_new_num(error->value));
|
|
81
|
+
scr_dyn_arr_push(entry, pair);
|
|
82
|
+
scr_dyn_arr_push(entries, entry);
|
|
83
|
+
}
|
|
84
|
+
return entries;
|
|
85
|
+
}
|
|
86
|
+
|
|
9
87
|
static SCR_TL ScrDyn *scr_global_known;
|
|
10
88
|
static SCR_TL ScrDyn *scr_global_own;
|
|
11
89
|
static SCR_TL bool scr_global_cleanup_registered;
|
|
@@ -460,6 +460,12 @@ static void qs_stringify_value(QsBuf *b, const ScrDyn *v) {
|
|
|
460
460
|
|
|
461
461
|
ScrStr *scr_qs_stringify(const ScrDyn *obj, const ScrStr *sep,
|
|
462
462
|
const ScrStr *eq) {
|
|
463
|
+
if (obj && obj->kind == SCR_DYN_TYPED_REF) {
|
|
464
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(obj);
|
|
465
|
+
ScrStr *result = view && !scr_exc_pending() ? scr_qs_stringify(view, sep, eq) : NULL;
|
|
466
|
+
scr_dyn_release(view);
|
|
467
|
+
return result;
|
|
468
|
+
}
|
|
463
469
|
const char *sep_b = (sep && sep->len) ? sep->data : "&";
|
|
464
470
|
size_t sep_len = (sep && sep->len) ? sep->len : 1;
|
|
465
471
|
const char *eq_b = (eq && eq->len) ? eq->data : "=";
|
|
@@ -475,6 +481,9 @@ ScrStr *scr_qs_stringify(const ScrDyn *obj, const ScrStr *sep,
|
|
|
475
481
|
const ScrStr *k = kd->v.str;
|
|
476
482
|
const ScrDyn *v = scr_dyn_obj_get(obj, k->data, k->len);
|
|
477
483
|
if (!v) continue; /* unreachable: keys came from the object */
|
|
484
|
+
ScrDyn *view = v->kind == SCR_DYN_TYPED_REF ? scr_dyn_typed_ref_materialize(v) : NULL;
|
|
485
|
+
if (view) v = view;
|
|
486
|
+
if (scr_exc_pending()) { scr_dyn_release(view); scr_dyn_release(keys); free(fields.data); return NULL; }
|
|
478
487
|
ScrStr *ks = scr_str_encode_uri_component((ScrStr *)k);
|
|
479
488
|
if (v->kind == SCR_DYN_ARR) {
|
|
480
489
|
for (size_t j = 0; j < v->v.arr.len; j++) {
|
|
@@ -490,6 +499,7 @@ ScrStr *scr_qs_stringify(const ScrDyn *obj, const ScrStr *sep,
|
|
|
490
499
|
qs_stringify_value(&fields, v);
|
|
491
500
|
}
|
|
492
501
|
scr_str_release(ks);
|
|
502
|
+
scr_dyn_release(view);
|
|
493
503
|
}
|
|
494
504
|
scr_dyn_release(keys);
|
|
495
505
|
return qb_take(&fields);
|
|
@@ -439,8 +439,8 @@ static int scr_regex_start(ScrRegex *re, int len) {
|
|
|
439
439
|
/* re.exec(s): a fresh string[] of [whole match, ...captures], or NULL
|
|
440
440
|
* for no match (the compiler wraps the `string[] | null` union). Global
|
|
441
441
|
* and sticky regexes start at lastIndex, set it to the match end, and
|
|
442
|
-
* reset it on failure. Nonparticipating captures
|
|
443
|
-
* empty
|
|
442
|
+
* reset it on failure. Nonparticipating captures are present undefined
|
|
443
|
+
* elements, distinct from participating empty captures and array holes. */
|
|
444
444
|
ScrArr *scr_regex_exec(ScrStr *s, ScrRegex *re) {
|
|
445
445
|
uint8_t *bc = scr_regex_bc(re);
|
|
446
446
|
bool stateful = (lre_get_flags(bc) & (LRE_FLAG_GLOBAL | LRE_FLAG_STICKY)) != 0;
|
|
@@ -462,7 +462,7 @@ ScrArr *scr_regex_exec(ScrStr *s, ScrRegex *re) {
|
|
|
462
462
|
for (int k = 0; k < count; k++) {
|
|
463
463
|
const uint8_t *cs = capture[2 * k], *ce = capture[2 * k + 1];
|
|
464
464
|
if (cs == NULL || ce == NULL) {
|
|
465
|
-
|
|
465
|
+
scr_arr_set_undefined(out, (double)out->len);
|
|
466
466
|
} else {
|
|
467
467
|
scr_arr_push_ref(
|
|
468
468
|
out, scr_str_from_utf16(u, (int)((cs - ubase) >> 1), (int)((ce - ubase) >> 1)));
|
|
@@ -525,7 +525,7 @@ double scr_regex_search(ScrStr *s, ScrRegex *re) {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
/* matchAll(re): every match as its honest slice string[] (whole match +
|
|
528
|
-
* captures, nonparticipating =
|
|
528
|
+
* captures, nonparticipating = undefined — match()'s rule) drained EAGERLY into
|
|
529
529
|
* a fresh string[][]. The lazy iterator is unobservable across the
|
|
530
530
|
* lowered surface: strings are immutable and the spec clones the regex at
|
|
531
531
|
* the call, so nothing can perturb the drain. Non-global regexes throw
|
|
@@ -559,7 +559,7 @@ static ScrArr *scr_regex_match_all_core(ScrStr *s, ScrRegex *re, ScrArr *indices
|
|
|
559
559
|
for (int k = 0; k < capture_count; k++) {
|
|
560
560
|
const uint8_t *cs = capture[2 * k], *ce = capture[2 * k + 1];
|
|
561
561
|
if (cs == NULL || ce == NULL) {
|
|
562
|
-
|
|
562
|
+
scr_arr_set_undefined(row, (double)row->len);
|
|
563
563
|
} else {
|
|
564
564
|
scr_arr_push_ref(
|
|
565
565
|
row, scr_str_from_utf16(u, (int)((cs - ubase) >> 1), (int)((ce - ubase) >> 1)));
|
|
@@ -719,6 +719,60 @@ ScrStr *scr_regex_replace(ScrStr *s, ScrRegex *re, ScrStr *rep) {
|
|
|
719
719
|
return scr_replace_impl(s, re, rep);
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
+
|
|
723
|
+
/* The pinned Node ANSI matcher derives from ansi-regex, copyright (c)
|
|
724
|
+
* Sindre Sorhus <sindresorhus@gmail.com>, used under the MIT license:
|
|
725
|
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
726
|
+
* copy of this software and associated documentation files (the "Software"),
|
|
727
|
+
* to deal in the Software without restriction, including without limitation
|
|
728
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
729
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
730
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
731
|
+
* The above copyright notice and this permission notice shall be included
|
|
732
|
+
* in all copies or substantial portions of the Software.
|
|
733
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
734
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
735
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
736
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
737
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
738
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
739
|
+
* DEALINGS IN THE SOFTWARE.
|
|
740
|
+
* Keep the pattern equivalent to Node v24.15.0 internal/util/inspect.js. */
|
|
741
|
+
#define SCR_VT_PATTERN "[\\u001B\\u009B][[\\]()#;?]*" \
|
|
742
|
+
"(?:(?:(?:(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]+)*" \
|
|
743
|
+
"|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]*)*)?" \
|
|
744
|
+
"(?:\\u0007|\\u001B\\u005C|\\u009C))" \
|
|
745
|
+
"|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
746
|
+
|
|
747
|
+
ScrStr *scr_util_strip_vt(const ScrDyn *input) {
|
|
748
|
+
if (!input || input->kind != SCR_DYN_STR) {
|
|
749
|
+
scr_dyn_arg_type_fail("str", "of type string", input ? input : scr_dyn_undefined());
|
|
750
|
+
return NULL;
|
|
751
|
+
}
|
|
752
|
+
ScrStr *subject = input->v.str;
|
|
753
|
+
bool escape = false;
|
|
754
|
+
for (size_t i = 0; i < subject->len; i++) {
|
|
755
|
+
if (subject->data[i] == '\x1b' || ((unsigned char)subject->data[i] == 0xc2 &&
|
|
756
|
+
i + 1 < subject->len && (unsigned char)subject->data[i + 1] == 0x9b)) {
|
|
757
|
+
escape = true;
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (!escape) return scr_str_retain(subject);
|
|
762
|
+
static const struct { size_t rc, len, cap; char data[sizeof SCR_VT_PATTERN]; }
|
|
763
|
+
source = { SIZE_MAX, sizeof SCR_VT_PATTERN - 1, sizeof SCR_VT_PATTERN - 1, SCR_VT_PATTERN };
|
|
764
|
+
static const struct { size_t rc, len, cap; char data[2]; }
|
|
765
|
+
flags = { SIZE_MAX, 1, 1, "g" };
|
|
766
|
+
static SCR_TL ScrRegex template = { SIZE_MAX, (ScrStr *)&source, (ScrStr *)&flags, NULL, 0, NULL };
|
|
767
|
+
ScrRegex *regex = scr_regex_literal(&template);
|
|
768
|
+
ScrStr *empty = scr_str_new("", 0);
|
|
769
|
+
ScrStr *result = scr_regex_replace(subject, regex, empty);
|
|
770
|
+
scr_str_release(empty);
|
|
771
|
+
scr_regex_release(regex);
|
|
772
|
+
return result;
|
|
773
|
+
}
|
|
774
|
+
#undef SCR_VT_PATTERN
|
|
775
|
+
|
|
722
776
|
ScrStr *scr_regex_replace_all(ScrStr *s, ScrRegex *re, ScrStr *rep) {
|
|
723
777
|
if (!(lre_get_flags(scr_regex_bc(re)) & LRE_FLAG_GLOBAL)) {
|
|
724
778
|
/* Node's exact TypeError — a real instance now: catch bindings narrow
|
|
@@ -923,6 +977,43 @@ static ScrStr *scr_str_case_conv(const ScrStr *s, int to_lower) {
|
|
|
923
977
|
ScrStr *scr_str_to_lower(const ScrStr *s) { return scr_str_case_conv(s, 1); }
|
|
924
978
|
ScrStr *scr_str_to_upper(const ScrStr *s) { return scr_str_case_conv(s, 0); }
|
|
925
979
|
|
|
980
|
+
static void *scr_normalize_realloc(void *opaque, void *ptr, size_t size) {
|
|
981
|
+
(void)opaque;
|
|
982
|
+
if (!size) { free(ptr); return NULL; }
|
|
983
|
+
return realloc(ptr, size);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
ScrStr *scr_str_normalize(const ScrStr *s, const ScrStr *form) {
|
|
987
|
+
UnicodeNormalizationEnum mode;
|
|
988
|
+
if (form->len == 3 && !memcmp(form->data, "NFC", 3)) mode = UNICODE_NFC;
|
|
989
|
+
else if (form->len == 3 && !memcmp(form->data, "NFD", 3)) mode = UNICODE_NFD;
|
|
990
|
+
else if (form->len == 4 && !memcmp(form->data, "NFKC", 4)) mode = UNICODE_NFKC;
|
|
991
|
+
else if (form->len == 4 && !memcmp(form->data, "NFKD", 4)) mode = UNICODE_NFKD;
|
|
992
|
+
else {
|
|
993
|
+
static const char message[] = "The normalization form should be one of NFC, NFD, NFKC, NFKD.";
|
|
994
|
+
scr_throw_error(SCR_ERR_RANGE, scr_str_new(message, sizeof message - 1));
|
|
995
|
+
return NULL;
|
|
996
|
+
}
|
|
997
|
+
if (s->len > INT32_MAX / sizeof(uint32_t)) scr_regex_oom();
|
|
998
|
+
uint32_t *input = malloc((s->len + 1) * sizeof(uint32_t));
|
|
999
|
+
if (!input) scr_regex_oom();
|
|
1000
|
+
int length = 0;
|
|
1001
|
+
for (size_t offset = 0; offset < s->len;) {
|
|
1002
|
+
size_t step;
|
|
1003
|
+
input[length++] = scr_case_decode(s->data + offset, &step);
|
|
1004
|
+
offset += step;
|
|
1005
|
+
}
|
|
1006
|
+
uint32_t *output = NULL;
|
|
1007
|
+
int count = unicode_normalize(&output, input, length, mode, NULL, scr_normalize_realloc);
|
|
1008
|
+
free(input);
|
|
1009
|
+
if (count < 0) scr_regex_oom();
|
|
1010
|
+
ScrJsonBuf buffer;
|
|
1011
|
+
scr_jb_init(&buffer);
|
|
1012
|
+
for (int i = 0; i < count; i++) scr_case_put_cp(&buffer, output[i]);
|
|
1013
|
+
free(output);
|
|
1014
|
+
return scr_jb_finish(&buffer);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
926
1017
|
/* ── assert.match / assert.doesNotMatch ──────────────────────────────────
|
|
927
1018
|
* Lives here because it needs the matcher. Assertion matching follows
|
|
928
1019
|
* RegExp.test, including global and sticky lastIndex transitions. */
|
|
@@ -1021,6 +1112,17 @@ bool scr_assert_regex_err_test(ScrRegex *re, ScrError *err) {
|
|
|
1021
1112
|
return matched;
|
|
1022
1113
|
}
|
|
1023
1114
|
|
|
1115
|
+
bool scr_assert_regex_dyn_test(ScrRegex *re, ScrDyn *actual) {
|
|
1116
|
+
// String(symbol) accepts a direct Symbol; object conversion uses the
|
|
1117
|
+
// string hint, including Symbol.toPrimitive and custom Error formatters.
|
|
1118
|
+
ScrStr *str = actual->kind == SCR_DYN_SYMBOL
|
|
1119
|
+
? scr_dyn_string_constructor(actual) : scr_util_to_usv_string(actual);
|
|
1120
|
+
if (!str) return false;
|
|
1121
|
+
bool matched = scr_assert_regex_hits(re, str);
|
|
1122
|
+
scr_str_release(str);
|
|
1123
|
+
return matched;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1024
1126
|
/* The regex-valued shape slot (assert.throws(fn, {message: /re/})):
|
|
1025
1127
|
* test the stashed actual key eagerly and store verdict + rendering, so
|
|
1026
1128
|
* scr_assert.c's comparison and diff stay libregexp-free. An absent
|