xbintsc 0.6.10 → 0.6.13

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 (204) hide show
  1. package/dist/src/ast/expressions.d.ts +6 -0
  2. package/dist/src/checker/globals.js +2 -1
  3. package/dist/src/checker/globals.js.map +1 -1
  4. package/dist/src/checker/type-infer.js +1 -1
  5. package/dist/src/checker/type-infer.js.map +1 -1
  6. package/dist/src/cli/help.d.ts +1 -1
  7. package/dist/src/codegen/generator/calls/literals.js +4 -1
  8. package/dist/src/codegen/generator/calls/literals.js.map +1 -1
  9. package/dist/src/codegen/generator/expressions/assignment.js +3 -1
  10. package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
  11. package/dist/src/codegen/generator/expressions/operators.js +2 -6
  12. package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
  13. package/dist/src/codegen/generator/expressions/primary.d.ts +9 -0
  14. package/dist/src/codegen/generator/expressions/primary.js +44 -7
  15. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  16. package/dist/src/codegen/generator/state.js +3 -0
  17. package/dist/src/codegen/generator/state.js.map +1 -1
  18. package/dist/src/codegen/generator/tables.js +3 -0
  19. package/dist/src/codegen/generator/tables.js.map +1 -1
  20. package/dist/src/driver/bundler/commonjs.js +1 -1
  21. package/dist/src/driver/bundler/commonjs.js.map +1 -1
  22. package/dist/src/driver/bundler/symbols.js +6 -0
  23. package/dist/src/driver/bundler/symbols.js.map +1 -1
  24. package/dist/src/driver/compiler.js +1 -1
  25. package/dist/src/driver/compiler.js.map +1 -1
  26. package/dist/src/driver/runtime-objects.d.ts +1 -1
  27. package/dist/src/driver/runtime-objects.js +2 -0
  28. package/dist/src/driver/runtime-objects.js.map +1 -1
  29. package/dist/src/driver/version.d.ts +1 -1
  30. package/dist/src/driver/version.js +1 -1
  31. package/dist/src/extensions/node/crypto/index.js +12 -1
  32. package/dist/src/extensions/node/crypto/index.js.map +1 -1
  33. package/dist/src/extensions/node/index.js +2 -0
  34. package/dist/src/extensions/node/index.js.map +1 -1
  35. package/dist/src/extensions/node/readline/index.d.ts +12 -0
  36. package/dist/src/extensions/node/readline/index.js +27 -0
  37. package/dist/src/extensions/node/readline/index.js.map +1 -0
  38. package/dist/src/parser/declarations/functions.js +6 -0
  39. package/dist/src/parser/declarations/functions.js.map +1 -1
  40. package/dist/src/parser/literals.js +1 -1
  41. package/dist/src/parser/literals.js.map +1 -1
  42. package/dist/tests/e2e/compile-builtins.test.js +26 -0
  43. package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
  44. package/dist/tests/e2e/compile-modules.test.js +22 -0
  45. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  46. package/dist/tests/e2e/compile-node.test.js +37 -1
  47. package/dist/tests/e2e/compile-node.test.js.map +1 -1
  48. package/dist/tests/e2e/crypto-random.test.d.ts +9 -0
  49. package/dist/tests/e2e/crypto-random.test.js +63 -0
  50. package/dist/tests/e2e/crypto-random.test.js.map +1 -0
  51. package/dist/tests/e2e/date-parse.test.js +44 -1
  52. package/dist/tests/e2e/date-parse.test.js.map +1 -1
  53. package/dist/tests/e2e/gui-browser.test.js +61 -0
  54. package/dist/tests/e2e/gui-browser.test.js.map +1 -1
  55. package/dist/tests/e2e/gui-css-coverage.test.js +40 -1
  56. package/dist/tests/e2e/gui-css-coverage.test.js.map +1 -1
  57. package/dist/tests/e2e/gui-css-features.test.js +100 -0
  58. package/dist/tests/e2e/gui-css-features.test.js.map +1 -1
  59. package/dist/tests/e2e/gui-dom.test.js +63 -0
  60. package/dist/tests/e2e/gui-dom.test.js.map +1 -1
  61. package/dist/tests/e2e/gui-errors.test.d.ts +11 -0
  62. package/dist/tests/e2e/gui-errors.test.js +68 -0
  63. package/dist/tests/e2e/gui-errors.test.js.map +1 -0
  64. package/dist/tests/e2e/gui-form.test.d.ts +9 -0
  65. package/dist/tests/e2e/gui-form.test.js +359 -0
  66. package/dist/tests/e2e/gui-form.test.js.map +1 -0
  67. package/dist/tests/e2e/gui-script-import-order.test.js +6 -1
  68. package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
  69. package/dist/tests/e2e/gui-style.test.js +82 -0
  70. package/dist/tests/e2e/gui-style.test.js.map +1 -1
  71. package/dist/tests/e2e/gui-unsupported.test.js +4 -3
  72. package/dist/tests/e2e/gui-unsupported.test.js.map +1 -1
  73. package/dist/tests/e2e/gui-webgl2-shadow-sampler.test.js +7 -1
  74. package/dist/tests/e2e/gui-webgl2-shadow-sampler.test.js.map +1 -1
  75. package/dist/tests/e2e/harness.d.ts +4 -0
  76. package/dist/tests/e2e/harness.js +2 -0
  77. package/dist/tests/e2e/harness.js.map +1 -1
  78. package/dist/tests/e2e/json-parse-errors.test.d.ts +9 -0
  79. package/dist/tests/e2e/json-parse-errors.test.js +48 -0
  80. package/dist/tests/e2e/json-parse-errors.test.js.map +1 -0
  81. package/dist/tests/e2e/readline.test.d.ts +7 -0
  82. package/dist/tests/e2e/readline.test.js +73 -0
  83. package/dist/tests/e2e/readline.test.js.map +1 -0
  84. package/doc/ai/language-support.md +2 -1
  85. package/doc/ai/zh-CN/language-support.md +2 -1
  86. package/doc/gui/api.md +24 -3
  87. package/doc/gui/dom.md +28 -14
  88. package/doc/gui/input.md +74 -3
  89. package/doc/gui/known-issues.md +2 -1
  90. package/doc/gui/layout.md +5 -1
  91. package/doc/implemented/node/crypto.md +8 -0
  92. package/doc/implemented/node/fs.md +1 -1
  93. package/doc/implemented/node/readline.md +34 -0
  94. package/doc/implemented/node.md +1 -0
  95. package/doc/implemented/stdlib.md +10 -2
  96. package/doc/unimplemented/node/modules.md +2 -3
  97. package/doc/unimplemented/node.md +2 -2
  98. package/doc/zh-CN/gui/api.md +20 -3
  99. package/doc/zh-CN/gui/dom.md +23 -13
  100. package/doc/zh-CN/gui/input.md +65 -4
  101. package/doc/zh-CN/gui/known-issues.md +2 -1
  102. package/doc/zh-CN/gui/layout.md +4 -1
  103. package/doc/zh-CN/implemented/node/crypto.md +6 -0
  104. package/doc/zh-CN/implemented/node/fs.md +1 -1
  105. package/doc/zh-CN/implemented/node/readline.md +33 -0
  106. package/doc/zh-CN/implemented/node.md +1 -0
  107. package/doc/zh-CN/implemented/stdlib.md +10 -2
  108. package/doc/zh-CN/unimplemented/node/modules.md +1 -2
  109. package/doc/zh-CN/unimplemented/node.md +2 -2
  110. package/package.json +7 -7
  111. package/runtime/ext_gui/browser_abort.cpp +2 -2
  112. package/runtime/ext_gui/browser_loop.cpp +1 -0
  113. package/runtime/ext_gui/browser_media.cpp +1 -1
  114. package/runtime/ext_gui/css_match.cpp +21 -1
  115. package/runtime/ext_gui/css_selector.cpp +2 -2
  116. package/runtime/ext_gui/document.cpp +12 -0
  117. package/runtime/ext_gui/dom.h +41 -2
  118. package/runtime/ext_gui/dom_api_canvas_image.cpp +2 -1
  119. package/runtime/ext_gui/dom_api_document.cpp +28 -0
  120. package/runtime/ext_gui/dom_api_events.cpp +18 -15
  121. package/runtime/ext_gui/dom_api_form.cpp +567 -0
  122. package/runtime/ext_gui/dom_api_internal.h +48 -214
  123. package/runtime/ext_gui/dom_api_mutation.cpp +1 -1
  124. package/runtime/ext_gui/dom_api_node.cpp +28 -15
  125. package/runtime/ext_gui/dom_api_node_read.cpp +28 -1
  126. package/runtime/ext_gui/dom_api_proto.cpp +47 -0
  127. package/runtime/ext_gui/dom_api_webgl_methods.h +217 -0
  128. package/runtime/ext_gui/dom_parse.cpp +114 -1
  129. package/runtime/ext_gui/error_report.cpp +166 -0
  130. package/runtime/ext_gui/form_focus.cpp +293 -0
  131. package/runtime/ext_gui/form_input.cpp +448 -0
  132. package/runtime/ext_gui/form_internal.h +30 -0
  133. package/runtime/ext_gui/form_shared.cpp +126 -0
  134. package/runtime/ext_gui/form_state.cpp +536 -0
  135. package/runtime/ext_gui/form_state.h +97 -0
  136. package/runtime/ext_gui/gui.cpp +16 -0
  137. package/runtime/ext_gui/gui_engine.h +53 -4
  138. package/runtime/ext_gui/gui_events.cpp +67 -49
  139. package/runtime/ext_gui/layout.cpp +6 -0
  140. package/runtime/ext_gui/layout.h +4 -0
  141. package/runtime/ext_gui/layout_flow.cpp +23 -1
  142. package/runtime/ext_gui/layout_inline.cpp +46 -14
  143. package/runtime/ext_gui/paint.cpp +26 -1
  144. package/runtime/ext_gui/paint_form.cpp +389 -0
  145. package/runtime/ext_gui/paint_internal.h +6 -0
  146. package/runtime/ext_gui/script.cpp +1 -1
  147. package/runtime/ext_gui/style.cpp +1 -0
  148. package/runtime/ext_gui/style.h +13 -0
  149. package/runtime/ext_gui/style_print.cpp +129 -0
  150. package/runtime/ext_gui/style_text.cpp +79 -0
  151. package/runtime/ext_gui/style_ua.cpp +42 -0
  152. package/runtime/ext_gui/warnings.cpp +5 -7
  153. package/runtime/ext_gui/webgl_texture.cpp +0 -8
  154. package/runtime/ext_gui/window.cpp +52 -62
  155. package/runtime/ext_gui/window_diagnostics.cpp +58 -0
  156. package/runtime/ext_gui/window_emit.cpp +51 -0
  157. package/runtime/ext_node/crypto/crypto.c +3 -2
  158. package/runtime/ext_node/crypto/crypto_hash.h +13 -0
  159. package/runtime/ext_node/crypto/crypto_random.c +339 -0
  160. package/runtime/ext_node/fs/async_worker.c +1 -1
  161. package/runtime/ext_node/fs/fs_ops.c +1 -1
  162. package/runtime/ext_node/fs/parts/platform.inc +67 -0
  163. package/runtime/ext_node/readline/readline.c +572 -0
  164. package/runtime/rt.h +42 -0
  165. package/runtime/rt_internal.h +3 -2
  166. package/runtime/xt_crypto.c +132 -0
  167. package/runtime/xt_io/exception.inc +29 -6
  168. package/runtime/xt_loop.c +36 -1
  169. package/runtime/xt_promise.c +26 -2
  170. package/runtime/xt_random.c +143 -0
  171. package/runtime/xt_regex/matcher.inc +9 -28
  172. package/runtime/xt_regex/parser.inc +65 -2
  173. package/runtime/xt_regex/types.inc +11 -1
  174. package/runtime/xt_regex.h +6 -2
  175. package/runtime/xt_stdlib/dispatch.inc +2 -0
  176. package/runtime/xt_stdlib/math.inc +1 -1
  177. package/runtime/xt_stdlib2/date.inc +206 -6
  178. package/runtime/xt_stdlib2/json.inc +4 -546
  179. package/runtime/xt_stdlib2/json_parse.inc +347 -0
  180. package/runtime/xt_stdlib2/json_stringify.inc +368 -0
  181. package/runtime/xt_stdlib2/regexp-match.inc +6 -11
  182. package/runtime/xt_stdlib2.c +0 -4
  183. package/runtime/xt_typed_array/elements.inc +2 -6
  184. package/runtime/xt_url.c +0 -6
  185. package/runtime/xt_url_object.c +1 -1
  186. package/src/ast/expressions.ts +6 -0
  187. package/src/checker/globals.ts +2 -0
  188. package/src/checker/type-infer.ts +1 -1
  189. package/src/codegen/generator/calls/literals.ts +4 -1
  190. package/src/codegen/generator/expressions/assignment.ts +3 -1
  191. package/src/codegen/generator/expressions/operators.ts +2 -6
  192. package/src/codegen/generator/expressions/primary.ts +58 -6
  193. package/src/codegen/generator/state.ts +3 -0
  194. package/src/codegen/generator/tables.ts +3 -0
  195. package/src/driver/bundler/commonjs.ts +1 -1
  196. package/src/driver/bundler/symbols.ts +6 -0
  197. package/src/driver/compiler.ts +1 -1
  198. package/src/driver/runtime-objects.ts +2 -0
  199. package/src/driver/version.ts +1 -1
  200. package/src/extensions/node/crypto/index.ts +12 -1
  201. package/src/extensions/node/index.ts +2 -0
  202. package/src/extensions/node/readline/index.ts +31 -0
  203. package/src/parser/declarations/functions.ts +6 -0
  204. package/src/parser/literals.ts +1 -1
@@ -0,0 +1,368 @@
1
+
2
+ static void xt_json_stringify_value(xt_value value, xt_value indent, int depth, xt_value *out);
3
+
4
+ /* The indentation unit for the `space` argument: up to 10 spaces for a
5
+ * number, or the first 10 UTF-16 code units of a string (any characters,
6
+ * not just spaces), matching JSON.stringify. An empty string means compact. */
7
+ static xt_value xt_json_space_unit(xt_value space) {
8
+ if (XT_IS_NUMBER(space)) {
9
+ int count = xt_to_int32(space);
10
+ if (count < 0) count = 0;
11
+ if (count > 10) count = 10;
12
+ char spaces[10];
13
+ memset(spaces, ' ', (size_t)count);
14
+ return xt_string_new(spaces, (size_t)count);
15
+ }
16
+ if (XT_IS_STRING(space)) {
17
+ xt_string *s = xt_as_string(space);
18
+ const char *bytes = xt_string_bytes(s);
19
+ size_t offset = 0;
20
+ size_t end = 0;
21
+ uint32_t units = 0;
22
+ while (offset < s->length && units < 10) {
23
+ size_t width = 0;
24
+ uint32_t code = xt_utf8_decode(bytes + offset, s->length - offset, &width);
25
+ units += code >= 0x10000 ? 2 : 1;
26
+ offset += width;
27
+ if (units <= 10) end = offset;
28
+ }
29
+ return xt_string_new(bytes, end);
30
+ }
31
+ return xt_string_from_cstr("");
32
+ }
33
+
34
+ static int xt_json_indented(xt_value unit) {
35
+ return XT_IS_STRING(unit) && xt_as_string(unit)->length > 0;
36
+ }
37
+
38
+ static void xt_json_indent(xt_value *out, xt_value unit, int depth) {
39
+ if (!xt_json_indented(unit)) return;
40
+ *out = xt_add(*out, xt_string_from_cstr("\n"));
41
+ for (int i = 0; i < depth; i++) *out = xt_add(*out, unit);
42
+ }
43
+
44
+ /* Containers on the current serialization path. A repeated pointer is a cycle;
45
+ * serializing it would recurse until the native stack overflowed (a hard crash,
46
+ * not the TypeError the platform throws). */
47
+ static xt_value *xt_json_path = NULL;
48
+ static uint32_t xt_json_path_count = 0;
49
+ static uint32_t xt_json_path_capacity = 0;
50
+
51
+ static void xt_json_enter(xt_value value) {
52
+ for (uint32_t i = 0; i < xt_json_path_count; i++) {
53
+ if (xt_json_path[i] == value) {
54
+ xt_value message = xt_string_from_cstr("Converting circular structure to JSON");
55
+ xt_throw(xt_type_error_ctor(1, &message));
56
+ }
57
+ }
58
+ if (xt_json_path_count >= xt_json_path_capacity) {
59
+ uint32_t capacity = xt_json_path_capacity == 0 ? 16 : xt_json_path_capacity * 2;
60
+ xt_value *path = (xt_value *)realloc(xt_json_path, sizeof(xt_value) * capacity);
61
+ if (!path) abort();
62
+ xt_json_path = path;
63
+ xt_json_path_capacity = capacity;
64
+ }
65
+ xt_json_path[xt_json_path_count++] = value;
66
+ }
67
+
68
+ static void xt_json_leave(void) {
69
+ if (xt_json_path_count > 0) xt_json_path_count--;
70
+ }
71
+
72
+ static void xt_json_stringify_array(xt_value value, xt_value indent, int depth, xt_value *out) {
73
+ xt_array *array = xt_as_array(value);
74
+ if (!array || array->length == 0) { *out = xt_add(*out, xt_string_from_cstr("[]")); return; }
75
+ *out = xt_add(*out, xt_string_from_cstr("["));
76
+ xt_json_enter(value);
77
+ for (uint32_t i = 0; i < array->length; i++) {
78
+ if (i > 0) *out = xt_add(*out, xt_string_from_cstr(","));
79
+ xt_json_indent(out, indent, depth + 1);
80
+ xt_json_stringify_value(array->items[i], indent, depth + 1, out);
81
+ }
82
+ xt_json_indent(out, indent, depth);
83
+ xt_json_leave();
84
+ *out = xt_add(*out, xt_string_from_cstr("]"));
85
+ }
86
+
87
+ static void xt_json_stringify_object(xt_value value, xt_value indent, int depth, xt_value *out) {
88
+ xt_value keys = xt_object_keys(value);
89
+ xt_array *array = xt_as_array(keys);
90
+ if (!array) { *out = xt_add(*out, xt_string_from_cstr("{}")); return; }
91
+ int any = 0;
92
+ for (uint32_t i = 0; i < array->length; i++) {
93
+ xt_value item = xt_get(value, array->items[i]);
94
+ if (item != XT_UNDEFINED && !XT_IS_FUNCTION(item) && !xt_is_symbol(item)) { any = 1; break; }
95
+ }
96
+ if (!any) { *out = xt_add(*out, xt_string_from_cstr("{}")); return; }
97
+ *out = xt_add(*out, xt_string_from_cstr("{"));
98
+ xt_json_enter(value);
99
+ int written = 0;
100
+ for (uint32_t i = 0; i < array->length; i++) {
101
+ xt_value key = array->items[i];
102
+ xt_value item = xt_get(value, key);
103
+ /* `undefined`, functions and symbols are omitted from objects. */
104
+ if (item == XT_UNDEFINED || XT_IS_FUNCTION(item) || xt_is_symbol(item)) continue;
105
+ if (written > 0) *out = xt_add(*out, xt_string_from_cstr(","));
106
+ written++;
107
+ xt_json_indent(out, indent, depth + 1);
108
+ *out = xt_add(*out, xt_string_from_cstr("\""));
109
+ *out = xt_add(*out, key);
110
+ *out = xt_add(*out, xt_string_from_cstr("\":"));
111
+ if (xt_json_indented(indent)) *out = xt_add(*out, xt_string_from_cstr(" "));
112
+ xt_json_stringify_value(item, indent, depth + 1, out);
113
+ }
114
+ xt_json_indent(out, indent, depth);
115
+ xt_json_leave();
116
+ *out = xt_add(*out, xt_string_from_cstr("}"));
117
+ }
118
+
119
+ static void xt_json_stringify_value(xt_value value, xt_value indent, int depth, xt_value *out) {
120
+ if (value == XT_UNDEFINED || value == XT_NULL || XT_IS_FUNCTION(value) || xt_is_symbol(value)) {
121
+ *out = xt_add(*out, xt_string_from_cstr("null"));
122
+ return;
123
+ }
124
+ if (XT_IS_BIGINT(value)) {
125
+ xt_throw(xt_error_from_message("TypeError: Do not know how to serialize a BigInt"));
126
+ return;
127
+ }
128
+ if (XT_IS_BOOL(value)) { *out = xt_add(*out, value == XT_TRUE ? xt_string_from_cstr("true") : xt_string_from_cstr("false")); return; }
129
+ if (XT_IS_NUMBER(value)) {
130
+ double d = xt_to_double(value);
131
+ if (!isfinite(d)) *out = xt_add(*out, xt_string_from_cstr("null"));
132
+ else *out = xt_add(*out, xt_to_string(value));
133
+ return;
134
+ }
135
+ if (XT_IS_STRING(value)) {
136
+ xt_string *s = xt_as_string(value);
137
+ const char *bytes = xt_string_bytes(s);
138
+ *out = xt_add(*out, xt_string_from_cstr("\""));
139
+ size_t offset = 0;
140
+ while (offset < s->length) {
141
+ size_t width = 0;
142
+ uint32_t code = xt_utf8_decode(bytes + offset, s->length - offset, &width);
143
+ const char *escape = NULL;
144
+ char buffer[8];
145
+ if (code == '"') escape = "\\\"";
146
+ else if (code == '\\') escape = "\\\\";
147
+ else if (code == '\b') escape = "\\b";
148
+ else if (code == '\f') escape = "\\f";
149
+ else if (code == '\n') escape = "\\n";
150
+ else if (code == '\r') escape = "\\r";
151
+ else if (code == '\t') escape = "\\t";
152
+ else if (code < 0x20 || (code >= 0xD800 && code <= 0xDFFF)) {
153
+ snprintf(buffer, sizeof(buffer), "\\u%04x", (unsigned)code);
154
+ escape = buffer;
155
+ }
156
+ if (escape) *out = xt_add(*out, xt_string_from_cstr(escape));
157
+ else *out = xt_add(*out, xt_string_new(bytes + offset, width));
158
+ offset += width;
159
+ }
160
+ *out = xt_add(*out, xt_string_from_cstr("\""));
161
+ return;
162
+ }
163
+ if (XT_IS_ARRAY(value)) { xt_json_stringify_array(value, indent, depth, out); return; }
164
+ if (XT_IS_OBJECT(value)) {
165
+ /* Map/Set/Date/RegExp/Promise/generators are not property-bag objects;
166
+ * handing them to xt_json_stringify_object reads their fields as a property
167
+ * table and crashed with an access violation. JSON sees no enumerable own
168
+ * properties on the first group and calls Date.prototype.toJSON. */
169
+ xt_object *object = (xt_object *)XT_GET_PTR(value);
170
+ switch (object->header.kind) {
171
+ case XT_OBJECT_KIND_MAP:
172
+ case XT_OBJECT_KIND_SET:
173
+ case XT_OBJECT_KIND_REGEXP:
174
+ case XT_OBJECT_KIND_PROMISE:
175
+ case XT_OBJECT_KIND_GENERATOR:
176
+ case XT_OBJECT_KIND_ITERATOR:
177
+ case XT_OBJECT_KIND_ASYNC:
178
+ *out = xt_add(*out, xt_string_from_cstr("{}"));
179
+ return;
180
+ case XT_OBJECT_KIND_DATE: {
181
+ xt_value time = xt_call_method(value, xt_string_from_cstr("getTime"), 0, NULL);
182
+ if (isnan(xt_to_number(time))) {
183
+ *out = xt_add(*out, xt_string_from_cstr("null"));
184
+ return;
185
+ }
186
+ xt_value text = xt_call_method(value, xt_string_from_cstr("toJSON"), 0, NULL);
187
+ xt_json_stringify_value(text, indent, depth, out);
188
+ return;
189
+ }
190
+ default:
191
+ break;
192
+ }
193
+ xt_json_stringify_object(value, indent, depth, out);
194
+ return;
195
+ }
196
+ *out = xt_add(*out, xt_string_from_cstr("null"));
197
+ }
198
+
199
+ /* -- replacer-aware stringify -------------------------------------------- */
200
+ /*
201
+ * The replacer overload needs the holder and key of every value, so it gets a
202
+ * separate walk instead of complicating the fast path. It also calls `toJSON`
203
+ * and filters object keys through an array replacer.
204
+ */
205
+ typedef struct {
206
+ xt_value replacer;
207
+ xt_value indent;
208
+ xt_value *path;
209
+ uint32_t path_count;
210
+ uint32_t path_capacity;
211
+ } xt_json_replacer_context;
212
+
213
+ static void xt_json_replacer_enter(xt_json_replacer_context *ctx, xt_value value) {
214
+ for (uint32_t i = 0; i < ctx->path_count; i++) {
215
+ if (ctx->path[i] == value) {
216
+ xt_value message = xt_string_from_cstr("Converting circular structure to JSON");
217
+ xt_throw(xt_type_error_ctor(1, &message));
218
+ }
219
+ }
220
+ if (ctx->path_count >= ctx->path_capacity) {
221
+ uint32_t capacity = ctx->path_capacity == 0 ? 16 : ctx->path_capacity * 2;
222
+ xt_value *path = (xt_value *)realloc(ctx->path, sizeof(xt_value) * capacity);
223
+ if (!path) abort();
224
+ ctx->path = path;
225
+ ctx->path_capacity = capacity;
226
+ }
227
+ ctx->path[ctx->path_count++] = value;
228
+ }
229
+
230
+ static void xt_json_replacer_leave(xt_json_replacer_context *ctx) {
231
+ if (ctx->path_count > 0) ctx->path_count--;
232
+ }
233
+
234
+ static void xt_json_replacer_indent(xt_json_replacer_context *ctx, int depth, xt_value *out) {
235
+ xt_json_indent(out, ctx->indent, depth);
236
+ }
237
+
238
+ static int xt_json_replacer_allows(xt_value replacer, xt_value key) {
239
+ if (!XT_IS_ARRAY(replacer)) return 1;
240
+ xt_array *allowed = xt_as_array(replacer);
241
+ for (uint32_t i = 0; i < allowed->length; i++) {
242
+ xt_value item = allowed->items[i];
243
+ if (!XT_IS_STRING(item) && !XT_IS_NUMBER(item)) continue;
244
+ xt_value text = xt_to_string(item);
245
+ xt_string *a = xt_as_string(text);
246
+ xt_string *b = xt_as_string(key);
247
+ if (a && b && xt_string_equals(a, b)) return 1;
248
+ }
249
+ return 0;
250
+ }
251
+
252
+ static int xt_json_replacer_write(xt_json_replacer_context *ctx, xt_value holder, xt_value key,
253
+ int depth, xt_value *out);
254
+
255
+ static int xt_json_replacer_container(xt_json_replacer_context *ctx, xt_value value, int depth,
256
+ xt_value *out) {
257
+ xt_json_replacer_enter(ctx, value);
258
+ if (XT_IS_ARRAY(value)) {
259
+ xt_array *array = xt_as_array(value);
260
+ *out = xt_add(*out, xt_string_from_cstr("["));
261
+ for (uint32_t i = 0; i < array->length; i++) {
262
+ if (i > 0) *out = xt_add(*out, xt_string_from_cstr(","));
263
+ xt_json_replacer_indent(ctx, depth + 1, out);
264
+ char keyBuffer[16];
265
+ snprintf(keyBuffer, sizeof(keyBuffer), "%u", i);
266
+ xt_value temporary = xt_string_from_cstr("");
267
+ int wrote = xt_json_replacer_write(ctx, value, xt_string_from_cstr(keyBuffer), depth + 1,
268
+ &temporary);
269
+ *out = xt_add(*out, wrote ? temporary : xt_string_from_cstr("null"));
270
+ }
271
+ xt_json_replacer_indent(ctx, depth, out);
272
+ xt_json_replacer_leave(ctx);
273
+ *out = xt_add(*out, xt_string_from_cstr("]"));
274
+ return 1;
275
+ }
276
+
277
+ xt_value keys = xt_object_keys(value);
278
+ xt_array *list = xt_as_array(keys);
279
+ *out = xt_add(*out, xt_string_from_cstr("{"));
280
+ int written = 0;
281
+ if (list) {
282
+ for (uint32_t i = 0; i < list->length; i++) {
283
+ xt_value childKey = list->items[i];
284
+ if (!xt_json_replacer_allows(ctx->replacer, childKey)) continue;
285
+ xt_value temporary = xt_string_from_cstr("");
286
+ int wrote = xt_json_replacer_write(ctx, value, childKey, depth + 1, &temporary);
287
+ if (!wrote) continue;
288
+ if (written > 0) *out = xt_add(*out, xt_string_from_cstr(","));
289
+ written++;
290
+ xt_json_replacer_indent(ctx, depth + 1, out);
291
+ *out = xt_add(*out, xt_string_from_cstr("\""));
292
+ *out = xt_add(*out, childKey);
293
+ *out = xt_add(*out, xt_string_from_cstr("\":"));
294
+ if (xt_json_indented(ctx->indent)) *out = xt_add(*out, xt_string_from_cstr(" "));
295
+ *out = xt_add(*out, temporary);
296
+ }
297
+ }
298
+ xt_json_replacer_indent(ctx, depth, out);
299
+ xt_json_replacer_leave(ctx);
300
+ *out = xt_add(*out, xt_string_from_cstr("}"));
301
+ return 1;
302
+ }
303
+
304
+ static int xt_json_replacer_write(xt_json_replacer_context *ctx, xt_value holder, xt_value key,
305
+ int depth, xt_value *out) {
306
+ xt_value value = xt_get(holder, key);
307
+ if (XT_IS_FUNCTION(ctx->replacer)) {
308
+ xt_value args[2] = {key, value};
309
+ value = xt_call_with_this(ctx->replacer, holder, 2, args);
310
+ }
311
+ if (xt_is_date(value)) {
312
+ value = xt_call_method(value, xt_string_from_cstr("toJSON"), 1, &key);
313
+ } else if (XT_IS_ARRAY(value) ||
314
+ (XT_IS_OBJECT(value) &&
315
+ (((xt_object *)XT_GET_PTR(value))->header.kind == XT_OBJECT_KIND_OBJECT ||
316
+ ((xt_object *)XT_GET_PTR(value))->header.kind == XT_OBJECT_KIND_ERROR))) {
317
+ xt_value toJSON = XT_IS_ARRAY(value) ? xt_get(value, xt_string_from_cstr("toJSON"))
318
+ : xt_object_get(value, xt_string_from_cstr("toJSON"));
319
+ if (XT_IS_FUNCTION(toJSON)) {
320
+ xt_value args[1] = {key};
321
+ value = xt_call_with_this(toJSON, value, 1, args);
322
+ }
323
+ }
324
+ if (value == XT_UNDEFINED || XT_IS_FUNCTION(value) || xt_is_symbol(value)) return 0;
325
+ if (XT_IS_BIGINT(value)) {
326
+ xt_value message = xt_string_from_cstr("Do not know how to serialize a BigInt");
327
+ xt_throw(xt_type_error_ctor(1, &message));
328
+ }
329
+ if (XT_IS_ARRAY(value)) return xt_json_replacer_container(ctx, value, depth, out);
330
+ if (XT_IS_OBJECT(value)) {
331
+ int kind = ((xt_object *)XT_GET_PTR(value))->header.kind;
332
+ if (kind == XT_OBJECT_KIND_MAP || kind == XT_OBJECT_KIND_SET ||
333
+ kind == XT_OBJECT_KIND_REGEXP || kind == XT_OBJECT_KIND_PROMISE ||
334
+ kind == XT_OBJECT_KIND_GENERATOR || kind == XT_OBJECT_KIND_ITERATOR ||
335
+ kind == XT_OBJECT_KIND_ASYNC) {
336
+ *out = xt_add(*out, xt_string_from_cstr("{}"));
337
+ return 1;
338
+ }
339
+ return xt_json_replacer_container(ctx, value, depth, out);
340
+ }
341
+ xt_json_stringify_value(value, ctx->indent, depth, out);
342
+ return 1;
343
+ }
344
+
345
+ xt_value xt_json_stringify(int32_t argc, xt_value *argv) {
346
+ xt_value value = xt_arg_at(argc, argv, 0);
347
+ if (value == XT_UNDEFINED || XT_IS_FUNCTION(value) || xt_is_symbol(value)) return XT_UNDEFINED;
348
+ /* Signature: stringify(value, replacer, space). The replacer is argv[1] and
349
+ * the indentation is argv[2]; reading argv[1] as `space` silently ignored
350
+ * `JSON.stringify(value, null, 2)`. */
351
+ xt_value indent = xt_json_space_unit(xt_arg_at(argc, argv, 2));
352
+ xt_value replacer = xt_arg_at(argc, argv, 1);
353
+ if (XT_IS_FUNCTION(replacer) || XT_IS_ARRAY(replacer)) {
354
+ xt_json_replacer_context context = {replacer, indent, NULL, 0, 0};
355
+ xt_value wrapper = xt_object_new();
356
+ xt_object_set(wrapper, xt_string_from_cstr(""), value);
357
+ xt_value out = xt_string_from_cstr("");
358
+ int wrote = xt_json_replacer_write(&context, wrapper, xt_string_from_cstr(""), 0, &out);
359
+ free(context.path);
360
+ return wrote ? out : XT_UNDEFINED;
361
+ }
362
+ /* A caught circular-structure error longjmps past xt_json_leave; start every
363
+ * top-level serialization with a clean path. */
364
+ xt_json_path_count = 0;
365
+ xt_value out = xt_string_from_cstr("");
366
+ xt_json_stringify_value(value, indent, 0, &out);
367
+ return out;
368
+ }
@@ -1,13 +1,8 @@
1
- #if defined(_WIN32)
2
- #define XT_REG_MULTILINE REG_MULTILINE
3
- #else
4
- #define XT_REG_MULTILINE REG_NEWLINE
5
- #endif
6
-
7
- /* RegExp support built on POSIX ERE. JavaScript patterns are translated to
8
- * their POSIX equivalents, capturing groups are tracked so the JS capture
9
- * indices stay correct even after `(?:` groups are lowered, and the resulting
10
- * `regmatch_t` offsets are converted back to offsets into the input string. */
1
+ /* RegExp support built on the runtime's self-contained ERE matcher. JavaScript
2
+ * patterns are translated to their ERE equivalents, capturing groups are
3
+ * tracked so the JS capture indices stay correct even after `(?:` groups are
4
+ * lowered, and the resulting `regmatch_t` offsets are converted back to offsets
5
+ * into the input string. */
11
6
 
12
7
  static int xt_regex_hex_digit(char c) {
13
8
  if (c >= '0' && c <= '9') return c - '0';
@@ -135,7 +130,7 @@ static int xt_regexp_run(xt_value regexpValue, xt_value input, int32_t start,
135
130
  const char *flagBytes = xt_string_bytes(f);
136
131
  for (uint32_t i = 0; i < f->length; i++) {
137
132
  if (flagBytes[i] == 'i') flags |= REG_ICASE;
138
- if (flagBytes[i] == 'm') flags |= XT_REG_MULTILINE;
133
+ if (flagBytes[i] == 'm') flags |= REG_MULTILINE;
139
134
  }
140
135
  }
141
136
  char *translated = xt_regexp_translate_js(xt_string_bytes(pattern), jsGroups, groupCount);
@@ -13,11 +13,7 @@
13
13
 
14
14
  #include <ctype.h>
15
15
  #include <math.h>
16
- #if defined(_WIN32)
17
16
  #include "xt_regex.h"
18
- #else
19
- #include <regex.h>
20
- #endif
21
17
  #include <stdio.h>
22
18
  #include <stdlib.h>
23
19
  #include <string.h>
@@ -254,11 +254,7 @@ static int32_t xt_ta_relative(int32_t index, int32_t length) {
254
254
  return index;
255
255
  }
256
256
 
257
- static xt_value xt_ta_append(xt_value array, int kind, xt_value value) {
258
- uint32_t length = xt_ta_length(array);
259
- xt_object_set(array, xt_string_from_cstr("length"), xt_number((double)(length + 1)));
260
- xt_object_set(array, xt_string_from_cstr("byteLength"), xt_number((double)(length + 1) * xt_ta_bytes[kind]));
261
- xt_ta_store(array, kind, length, xt_to_number(value));
262
- return array;
257
+ uint32_t xt_typed_array_length(xt_value value) {
258
+ return xt_typed_array_kind_of(value) >= 0 ? xt_ta_length(value) : 0;
263
259
  }
264
260
 
package/runtime/xt_url.c CHANGED
@@ -99,12 +99,6 @@ static void xt_url_append_pair(xt_value entries, xt_value key, xt_value value) {
99
99
  xt_array_push(entries, pair);
100
100
  }
101
101
 
102
- static xt_value xt_url_string_at(xt_value text, size_t start, size_t length) {
103
- xt_string *string = xt_as_string(text);
104
- const char *bytes = xt_string_bytes(string);
105
- return xt_string_new(bytes + start, length);
106
- }
107
-
108
102
  /* Split a query string on `&`, then each item on the first `=`; decode both
109
103
  * halves and append them. A leading `?` is ignored. */
110
104
  static void xt_url_parse_into(xt_value params, xt_value input) {
@@ -339,11 +339,11 @@ xt_value xt_url_ctor(int32_t argc, xt_value *argv) {
339
339
  /* A reference without a scheme is a filesystem path. With no explicit base
340
340
  * it resolves against the working directory, so `new URL("./a.txt")` is a
341
341
  * `file://` URL rather than an unparseable relative one. */
342
- char adjusted[XT_URL_MAX];
343
342
  if (base[0] == 0 && xt_url_scheme_length(inputText) == 0) {
344
343
  xt_url_cwd_base(base, sizeof(base));
345
344
  }
346
345
  #if defined(_WIN32)
346
+ char adjusted[XT_URL_MAX];
347
347
  if (xt_url_scheme_length(inputText) == 0 && isalpha((unsigned char)inputText[0]) &&
348
348
  inputText[1] == ':' && (inputText[2] == '\\' || inputText[2] == '/')) {
349
349
  /* `C:\dir\file` -> `/C:/dir/file`, the path part of a file URL. */
@@ -122,6 +122,12 @@ export interface PropertyAssignment extends Node {
122
122
  export interface ShorthandPropertyAssignment extends Node {
123
123
  readonly kind: SyntaxKind.ShorthandPropertyAssignment;
124
124
  readonly name: Identifier;
125
+ /**
126
+ * The literal property key as written (`"a"` in `{ a }`). Kept separate from
127
+ * `name.text`, which the bundler rewrites when it renames the binding: the
128
+ * key is part of the object shape, not a reference to the binding.
129
+ */
130
+ readonly propertyName: string;
125
131
  /** Present for `{ a = default }` when used as a destructuring target. */
126
132
  readonly initializer?: Expression;
127
133
  }
@@ -14,6 +14,7 @@ import {
14
14
  GLOBAL_FUNCTIONS,
15
15
  NAMESPACE_PROPERTIES,
16
16
  NAMESPACE_STATICS,
17
+ NAMESPACE_VALUES,
17
18
  TYPED_ARRAYS,
18
19
  } from "../codegen/generator/tables.js";
19
20
 
@@ -25,6 +26,7 @@ const KNOWN_GLOBALS: ReadonlySet<string> = new Set<string>([
25
26
  ...Object.keys(TYPED_ARRAYS),
26
27
  ...Object.keys(NAMESPACE_STATICS),
27
28
  ...Object.keys(NAMESPACE_PROPERTIES),
29
+ ...Object.keys(NAMESPACE_VALUES),
28
30
  ...FIRST_CLASS_CONSTRUCTORS,
29
31
  // Handled directly in `emitIdentifier` rather than through a table.
30
32
  "console",
@@ -156,7 +156,7 @@ function objectLiteralType(context: InferenceContext, literal: ObjectLiteralExpr
156
156
  if (!(property.accessor === "set" && properties.has(name))) properties.set(name, { type, optional: false });
157
157
  } else if (element.kind === SyntaxKind.ShorthandPropertyAssignment) {
158
158
  const shorthand = element as ShorthandPropertyAssignment;
159
- properties.set(shorthand.name.text, { type: inferTypeOfExpression(context, shorthand.name), optional: false });
159
+ properties.set(shorthand.propertyName, { type: inferTypeOfExpression(context, shorthand.name), optional: false });
160
160
  } else {
161
161
  return ANY; // spread: the shape is not static
162
162
  }
@@ -68,7 +68,10 @@ export const literalCallMethods: LiteralCallMethods = {
68
68
  continue;
69
69
  }
70
70
  const identifier = property.name;
71
- const key = this.stringValue(identifier.text);
71
+ /* The key is the spelling in the source; `identifier.text` may have
72
+ * been rewritten to a bundler-mangled name when the variable itself is
73
+ * renamed. */
74
+ const key = this.stringValue(property.propertyName);
72
75
  const value = this.emitIdentifier(identifier);
73
76
  this.emit(` call i64 @xt_set(i64 ${object}, i64 ${key}, i64 ${value})`);
74
77
  } else if (property.kind === SyntaxKind.SpreadElement) {
@@ -217,7 +217,9 @@ export const assignmentExpressionMethods: AssignmentExpressionMethods = {
217
217
  continue;
218
218
  }
219
219
  const shorthand = property as ShorthandPropertyAssignment;
220
- const key = this.stringValue(shorthand.name.text);
220
+ /* A destructuring target reads the source key, not the (possibly
221
+ * bundler-renamed) binding name. */
222
+ const key = this.stringValue(shorthand.propertyName);
221
223
  excludedKeys.push(key);
222
224
  let elementValue = this.reg();
223
225
  this.emit(` ${elementValue} = call i64 @xt_get(i64 ${value}, i64 ${key})`);
@@ -184,12 +184,8 @@ export const operatorExpressionMethods: OperatorExpressionMethods = {
184
184
  this.emit(` ${result} = call i64 @xt_bit_not(i64 ${operand})`);
185
185
  return result;
186
186
  }
187
- case PrefixUnaryOperator.TypeOf: {
188
- const operand = this.emitExpression(node.operand);
189
- const result = this.reg();
190
- this.emit(` ${result} = call i64 @xt_typeof(i64 ${operand})`);
191
- return result;
192
- }
187
+ case PrefixUnaryOperator.TypeOf:
188
+ return this.emitTypeOf(node.operand);
193
189
  case PrefixUnaryOperator.Void:
194
190
  if (node.operand) this.emitExpression(node.operand);
195
191
  return i64(XT_UNDEFINED);
@@ -34,6 +34,9 @@ import {
34
34
  CTOR_FUNCTIONS,
35
35
  ERROR_CONSTRUCTORS,
36
36
  FIRST_CLASS_CONSTRUCTORS,
37
+ GLOBAL_FUNCTIONS,
38
+ NAMESPACE_PROPERTIES,
39
+ NAMESPACE_STATICS,
37
40
  NAMESPACE_VALUES,
38
41
  } from "../tables.js";
39
42
  import type { GlobalValue } from "../../../extensions/registry.js";
@@ -42,6 +45,15 @@ import type { Generator } from "../generator.js";
42
45
  export interface PrimaryExpressionMethods {
43
46
  emitExpression(this: Generator, node: Expression): string;
44
47
  emitIdentifier(this: Generator, identifier: Identifier): string;
48
+ /**
49
+ * `typeof` lowering. Host globals the compiler knows about but that have no
50
+ * first-class value (the console object, `JSON`, `performance`, extension
51
+ * builtins such as `requestAnimationFrame`) used to lower their operand as
52
+ * an undefined constant, so `typeof` reported "undefined" for a global the
53
+ * program could call. Answer these from the known global kinds instead.
54
+ */
55
+ emitTypeOf(this: Generator, operand: Expression): string;
56
+ globalTypeOf(this: Generator, name: string): string | undefined;
45
57
  emitGlobalValue(this: Generator, value: GlobalValue): string;
46
58
  emitFunctionValue(this: Generator, symbol: SymbolInfo): string;
47
59
  emitTemplate(this: Generator, node: TemplateLiteral): string;
@@ -111,12 +123,8 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
111
123
  return this.emitExpression((node as { expression: Expression }).expression);
112
124
  case SyntaxKind.DeleteExpression:
113
125
  return this.emitDelete(node as DeleteExpression);
114
- case SyntaxKind.TypeOfExpression: {
115
- const operand = this.emitExpression((node as { expression: Expression }).expression);
116
- const result = this.reg();
117
- this.emit(` ${result} = call i64 @xt_typeof(i64 ${operand})`);
118
- return result;
119
- }
126
+ case SyntaxKind.TypeOfExpression:
127
+ return this.emitTypeOf((node as { expression: Expression }).expression);
120
128
  case SyntaxKind.VoidExpression:
121
129
  this.emitExpression((node as { expression: Expression }).expression);
122
130
  return i64(XT_UNDEFINED);
@@ -166,6 +174,50 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
166
174
  }
167
175
  },
168
176
 
177
+ emitTypeOf(operand: Expression): string {
178
+ if (operand.kind === SyntaxKind.Identifier) {
179
+ const identifier = operand as Identifier;
180
+ /* A real binding (including an import) shadows the global, so lower it
181
+ * normally. Only an unresolved name can be a host global. */
182
+ if (!this.binding.symbolOfIdentifier.get(identifier)) {
183
+ const kind = this.globalTypeOf(identifier.text);
184
+ if (kind !== undefined) return this.stringValue(kind);
185
+ }
186
+ }
187
+ const value = this.emitExpression(operand);
188
+ const result = this.reg();
189
+ this.emit(` ${result} = call i64 @xt_typeof(i64 ${value})`);
190
+ return result;
191
+ },
192
+
193
+ /** Known kind of an unresolved global name, or undefined when the runtime
194
+ * getter should answer (`window`, `document`, `localStorage`, …). */
195
+ globalTypeOf(this: Generator, name: string): string | undefined {
196
+ /* A host extension function has no object value yet, but it is callable. */
197
+ if (this.builtins[name]) return "function";
198
+ /* Extension values are real host objects (or deliberately undefined for an
199
+ * unsupported type), so let `xt_typeof` inspect the getter's result. */
200
+ if (this.globalValues[name]) return undefined;
201
+ if (
202
+ ERROR_CONSTRUCTORS[name] ||
203
+ FIRST_CLASS_CONSTRUCTORS.has(name) ||
204
+ CTOR_FUNCTIONS[name] ||
205
+ BUILTIN_FUNCTION_VALUES[name] ||
206
+ GLOBAL_FUNCTIONS[name]
207
+ ) {
208
+ return "function";
209
+ }
210
+ if (
211
+ name === "console" ||
212
+ NAMESPACE_STATICS[name] ||
213
+ NAMESPACE_VALUES[name] ||
214
+ NAMESPACE_PROPERTIES[name]
215
+ ) {
216
+ return "object";
217
+ }
218
+ return undefined;
219
+ },
220
+
169
221
  emitIdentifier(identifier: Identifier): string {
170
222
  const symbol = this.binding.symbolOfIdentifier.get(identifier);
171
223
  if (symbol) {
@@ -151,6 +151,9 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
151
151
  "declare i64 @xt_number_static(i64, i32, i64*)",
152
152
  "declare i64 @xt_string_static(i64, i32, i64*)",
153
153
  "declare i64 @xt_date_static(i64, i32, i64*)",
154
+ "declare i64 @xt_crypto_static(i64, i32, i64*)",
155
+ "declare i64 @xt_crypto_object(i32, i64*)",
156
+ "declare i64 @xt_crypto_get(i64)",
154
157
  "declare i64 @xt_path_static(i64, i32, i64*)",
155
158
  "declare i64 @xt_os_static(i64, i32, i64*)",
156
159
  "declare i64 @xt_buffer_static(i64, i32, i64*)",
@@ -243,6 +243,7 @@ export const NAMESPACE_STATICS: Record<string, string> = {
243
243
  BigInt: "xt_bigint_static",
244
244
  Symbol: "xt_symbol_static",
245
245
  Date: "xt_date_static",
246
+ crypto: "xt_crypto_static",
246
247
  Promise: "xt_promise_static",
247
248
  ArrayBuffer: "xt_array_buffer_static",
248
249
  path: "xt_path_static",
@@ -286,6 +287,7 @@ export const SYMBOL_WELL_KNOWN = new Set<string>([
286
287
  /** Namespaces that also exist as a first-class object value (`Math.cos`). */
287
288
  export const NAMESPACE_VALUES: Record<string, string> = {
288
289
  Math: "xt_math_object",
290
+ crypto: "xt_crypto_object",
289
291
  };
290
292
 
291
293
  /** Namespace identifiers whose property access maps to a runtime getter. */
@@ -294,6 +296,7 @@ export const NAMESPACE_PROPERTIES: Record<string, string> = {
294
296
  "import.meta": "xt_import_meta",
295
297
  Symbol: "xt_symbol_get",
296
298
  performance: "xt_performance_get",
299
+ crypto: "xt_crypto_get",
297
300
  };
298
301
 
299
302
  /** Global constructors called as `new X(...)` (all have signature `(i32, i64*)`). */
@@ -292,7 +292,7 @@ function isModuleExports(expression: Expression, bind: BindResult): boolean {
292
292
 
293
293
  function literalPropertyName(property: ObjectLiteralElementLike): string | undefined {
294
294
  if (property.kind === SyntaxKind.ShorthandPropertyAssignment) {
295
- return (property as unknown as { name: Identifier }).name.text;
295
+ return (property as unknown as { propertyName: string }).propertyName;
296
296
  }
297
297
  if (property.kind === SyntaxKind.PropertyAssignment) {
298
298
  const name = (property as unknown as { name: Node }).name;