@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.
Files changed (198) hide show
  1. package/dist/THIRD_PARTY_NOTICES +1 -1
  2. package/dist/bin/scriptc +0 -0
  3. package/dist/bin/scriptc.json +1 -1
  4. package/dist/lib/declarations/scriptc-node-fallback.d.ts +158 -31
  5. package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
  6. package/dist/lib/llvm/package.json +1 -1
  7. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
  8. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
  9. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
  10. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
  11. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
  12. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
  13. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
  14. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
  15. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
  16. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
  17. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
  18. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
  19. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
  20. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
  21. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
  22. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.o +0 -0
  23. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
  24. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
  25. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
  26. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url_params.o +0 -0
  27. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util_compare.o +0 -0
  28. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util_style.o +0 -0
  29. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
  30. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
  31. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
  32. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
  33. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
  34. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
  35. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
  36. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
  37. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
  38. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
  39. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
  40. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
  41. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
  42. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
  43. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
  44. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
  45. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
  46. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
  47. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
  48. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
  49. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url_params.o +0 -0
  50. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util_compare.o +0 -0
  51. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util_style.o +0 -0
  52. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
  53. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  54. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  55. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
  56. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
  57. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
  58. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
  59. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
  60. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
  61. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
  62. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
  63. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
  64. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
  65. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
  66. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
  67. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
  68. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url_params.o +0 -0
  69. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  70. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
  71. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
  72. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
  73. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
  74. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
  75. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
  76. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
  77. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
  78. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
  79. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
  80. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
  81. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
  82. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
  83. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url_params.o +0 -0
  84. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  85. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
  86. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
  87. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
  88. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
  89. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
  90. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
  91. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
  92. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
  93. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
  94. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
  95. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
  96. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
  97. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
  98. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url_params.o +0 -0
  99. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  100. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
  101. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
  102. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
  103. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
  104. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
  105. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
  106. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
  107. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
  108. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
  109. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
  110. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
  111. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
  112. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
  113. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url_params.o +0 -0
  114. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  115. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
  116. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
  117. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
  118. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
  119. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
  120. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
  121. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
  122. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
  123. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
  124. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
  125. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
  126. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
  127. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
  128. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
  129. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
  130. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.o +0 -0
  131. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
  132. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
  133. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
  134. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url_params.o +0 -0
  135. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util_compare.o +0 -0
  136. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util_style.o +0 -0
  137. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
  138. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
  139. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
  140. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
  141. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
  142. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
  143. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
  144. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
  145. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
  146. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
  147. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
  148. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
  149. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
  150. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
  151. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
  152. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
  153. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
  154. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
  155. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
  156. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
  157. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url_params.o +0 -0
  158. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util_compare.o +0 -0
  159. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util_style.o +0 -0
  160. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
  161. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  162. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  163. package/dist/lib/runtime-darwin-x64/package.json +1 -1
  164. package/dist/lib/runtime-darwin-x64/runtime-pack.json +423 -297
  165. package/dist/lib/runtime-sources/package.json +1 -1
  166. package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
  167. package/dist/lib/runtime-sources/src/scr_array.c +5 -0
  168. package/dist/lib/runtime-sources/src/scr_assert.c +26 -0
  169. package/dist/lib/runtime-sources/src/scr_async.c +56 -4
  170. package/dist/lib/runtime-sources/src/scr_async_dyn.c +118 -24
  171. package/dist/lib/runtime-sources/src/scr_bytes.c +226 -0
  172. package/dist/lib/runtime-sources/src/scr_bytes_io.c +355 -51
  173. package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
  174. package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +181 -43
  175. package/dist/lib/runtime-sources/src/scr_events.c +9 -0
  176. package/dist/lib/runtime-sources/src/scr_exception.c +1 -0
  177. package/dist/lib/runtime-sources/src/scr_fetch.c +45 -1
  178. package/dist/lib/runtime-sources/src/scr_file_handle.c +42 -0
  179. package/dist/lib/runtime-sources/src/scr_island.c +2166 -786
  180. package/dist/lib/runtime-sources/src/scr_island_manifest.h +19 -13
  181. package/dist/lib/runtime-sources/src/scr_json.c +584 -54
  182. package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
  183. package/dist/lib/runtime-sources/src/scr_lib.c +1192 -43
  184. package/dist/lib/runtime-sources/src/scr_map.c +8 -0
  185. package/dist/lib/runtime-sources/src/scr_node_builtin.c +78 -0
  186. package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
  187. package/dist/lib/runtime-sources/src/scr_regex.c +107 -5
  188. package/dist/lib/runtime-sources/src/scr_runtime.h +136 -9
  189. package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
  190. package/dist/lib/runtime-sources/src/scr_system_errors.h +573 -0
  191. package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +12 -12
  192. package/dist/lib/runtime-sources/src/scr_url.c +547 -64
  193. package/dist/lib/runtime-sources/src/scr_url_internal.h +6 -0
  194. package/dist/lib/runtime-sources/src/scr_url_params.c +10 -0
  195. package/dist/lib/runtime-sources/src/scr_util_compare.c +222 -0
  196. package/dist/lib/runtime-sources/src/scr_util_style.c +337 -0
  197. package/dist/lib/runtime-sources/src/scr_web.c +849 -264
  198. 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 retain the documented
443
- * empty-string representation. */
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
- scr_arr_push_ref(out, scr_str_new("", 0));
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 = "" — match()'s rule) drained EAGERLY into
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
- scr_arr_push_ref(row, scr_str_new("", 0));
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