xbintsc 0.7.0 → 0.7.6
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/src/ast/common.d.ts +10 -0
- package/dist/src/checker/source.js +4 -0
- package/dist/src/checker/source.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +15 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +4 -11
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
- package/dist/src/codegen/generator/calls/element-inline.js +388 -0
- package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.js +82 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls.d.ts +3 -1
- package/dist/src/codegen/generator/calls.js +3 -1
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +20 -3
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +10 -2
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
- package/dist/src/codegen/generator/expressions/global-values.js +49 -0
- package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
- package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +4 -24
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +2 -1
- package/dist/src/codegen/generator/expressions.js +2 -1
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/layout.d.ts +65 -0
- package/dist/src/codegen/generator/layout.js +50 -0
- package/dist/src/codegen/generator/layout.js.map +1 -0
- package/dist/src/codegen/generator/state.js +4 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.js +1 -1
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +37 -9
- package/dist/src/diagnostics/source-text.js +124 -23
- package/dist/src/diagnostics/source-text.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +16 -6
- package/dist/src/diagnostics/source.js +25 -4
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +14 -0
- package/dist/src/driver/build-key.js +6 -1
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.js +11 -4
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +2 -2
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +11 -5
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +3 -0
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/compiler.js +13 -3
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +4 -0
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.js +28 -5
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/html.js +42 -10
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +48 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +20 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/parser/expressions.js +2 -2
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/helpers.d.ts +8 -0
- package/dist/src/parser/helpers.js +21 -0
- package/dist/src/parser/helpers.js.map +1 -1
- package/dist/tests/cli/main.test.js +9 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/element-layout.test.d.ts +19 -0
- package/dist/tests/codegen/element-layout.test.js +80 -0
- package/dist/tests/codegen/element-layout.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +25 -0
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +13 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +9 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
- package/dist/tests/diagnostics/source-text.test.js +50 -0
- package/dist/tests/diagnostics/source-text.test.js.map +1 -0
- package/dist/tests/diagnostics/source.test.js +17 -0
- package/dist/tests/diagnostics/source.test.js.map +1 -1
- package/dist/tests/driver/build-key.test.d.ts +1 -0
- package/dist/tests/driver/build-key.test.js +49 -0
- package/dist/tests/driver/build-key.test.js.map +1 -0
- package/dist/tests/driver/toolchain.test.js +8 -1
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/driver/usage.test.js +2 -1
- package/dist/tests/driver/usage.test.js.map +1 -1
- package/dist/tests/e2e/async-await.test.js +16 -0
- package/dist/tests/e2e/async-await.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +29 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-modules.test.js +13 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.js +25 -0
- package/dist/tests/e2e/differential-language.test.js.map +1 -1
- package/dist/tests/e2e/differential-values.test.js +59 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gc.test.js +22 -0
- package/dist/tests/e2e/gc.test.js.map +1 -1
- package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
- package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
- package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
- package/dist/tests/e2e/gui-browser.test.js +35 -2
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +88 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
- package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.js +59 -1
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
- package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
- package/dist/tests/e2e/hang-watchdog.test.js +50 -0
- package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
- package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
- package/dist/tests/e2e/method-call-cache.test.js +65 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
- package/dist/tests/e2e/performance-now.test.d.ts +9 -0
- package/dist/tests/e2e/performance-now.test.js +36 -0
- package/dist/tests/e2e/performance-now.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.js +33 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -1
- package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
- package/dist/tests/e2e/shape-interning.test.js +55 -0
- package/dist/tests/e2e/shape-interning.test.js.map +1 -0
- package/dist/tests/e2e/string-utf16.test.js +9 -0
- package/dist/tests/e2e/string-utf16.test.js.map +1 -1
- package/dist/tests/e2e/typed-array-views.test.js +26 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
- package/dist/tests/e2e/url-search-params.test.js +19 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +16 -1
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/doc/ai/contributing.md +8 -5
- package/doc/ai/extensions.md +12 -3
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/troubleshooting.md +14 -0
- package/doc/ai/zh-CN/contributing.md +6 -3
- package/doc/ai/zh-CN/extensions.md +10 -2
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/ai/zh-CN/troubleshooting.md +12 -0
- package/doc/gui/api.md +26 -4
- package/doc/gui/dom.md +8 -0
- package/doc/gui/known-issues.md +35 -6
- package/doc/gui/runtime.md +16 -1
- package/doc/gui/webgl.md +97 -26
- package/doc/gui-scripts.md +2 -1
- package/doc/gui.md +8 -5
- package/doc/implemented/checker.md +9 -0
- package/doc/implemented/codegen.md +7 -0
- package/doc/implemented/parser.md +2 -1
- package/doc/implemented/runtime-core.md +9 -2
- package/doc/implemented/stdlib.md +10 -2
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/zh-CN/gui/api.md +19 -5
- package/doc/zh-CN/gui/dom.md +6 -0
- package/doc/zh-CN/gui/known-issues.md +24 -5
- package/doc/zh-CN/gui/runtime.md +13 -1
- package/doc/zh-CN/gui/webgl.md +20 -7
- package/doc/zh-CN/gui-scripts.md +2 -1
- package/doc/zh-CN/gui.md +4 -1
- package/doc/zh-CN/implemented/checker.md +7 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- package/doc/zh-CN/implemented/parser.md +2 -1
- package/doc/zh-CN/implemented/runtime-core.md +9 -2
- package/doc/zh-CN/implemented/stdlib.md +6 -2
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/package.json +7 -7
- package/runtime/ext_gui/audio.cpp +39 -3
- package/runtime/ext_gui/audio_extra.cpp +353 -0
- package/runtime/ext_gui/audio_extra.h +47 -0
- package/runtime/ext_gui/audio_fft.h +76 -0
- package/runtime/ext_gui/audio_internal.h +21 -0
- package/runtime/ext_gui/audio_mixer.cpp +46 -1
- package/runtime/ext_gui/audio_mixer.h +89 -1
- package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
- package/runtime/ext_gui/audio_nodes.cpp +242 -0
- package/runtime/ext_gui/audio_nodes_internal.h +81 -0
- package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
- package/runtime/ext_gui/browser.cpp +9 -0
- package/runtime/ext_gui/browser_screen.cpp +73 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
- package/runtime/ext_gui/dom_api_internal.h +3 -0
- package/runtime/ext_gui/dom_api_node.cpp +21 -0
- package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
- package/runtime/ext_gui/dom_api_proto.cpp +3 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
- package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
- package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
- package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
- package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +4 -2
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
- package/runtime/ext_gui/gui.cpp +6 -1
- package/runtime/ext_gui/gui_engine.h +2 -0
- package/runtime/ext_gui/gui_events.cpp +13 -8
- package/runtime/ext_gui/gui_webgl.cpp +3 -2
- package/runtime/ext_gui/style_ua.cpp +4 -0
- package/runtime/ext_gui/warnings.cpp +1 -1
- package/runtime/ext_gui/webgl.h +102 -7
- package/runtime/ext_gui/webgl_api.h +3 -2
- package/runtime/ext_gui/webgl_blit.cpp +109 -15
- package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
- package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
- package/runtime/ext_gui/webgl_buffer.cpp +20 -170
- package/runtime/ext_gui/webgl_context.cpp +117 -169
- package/runtime/ext_gui/webgl_draw.cpp +116 -5
- package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
- package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
- package/runtime/ext_gui/webgl_draw_state.h +2 -0
- package/runtime/ext_gui/webgl_feature.cpp +2 -2
- package/runtime/ext_gui/webgl_feature.h +4 -3
- package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
- package/runtime/ext_gui/webgl_objects.h +16 -2
- package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
- package/runtime/ext_gui/webgl_state.cpp +45 -36
- package/runtime/ext_gui/webgl_targets.cpp +440 -0
- package/runtime/ext_gui/webgl_texture.cpp +81 -25
- package/runtime/ext_gui/window.cpp +8 -0
- package/runtime/rt.h +27 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +52 -60
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +88 -133
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_builtins.c +3 -1
- package/runtime/xt_constructors.c +1 -0
- package/runtime/xt_containers/access.inc +96 -11
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/method_cache.inc +121 -0
- package/runtime/xt_containers/object_keys.inc +58 -0
- package/runtime/xt_containers/objects.inc +47 -79
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +4 -0
- package/runtime/xt_gc_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +1 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +32 -6
- package/runtime/xt_io/watchdog.inc +101 -0
- package/runtime/xt_io.c +1 -0
- package/runtime/xt_loop.c +23 -3
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_stdlib/dispatch.inc +7 -1
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/json_stringify.inc +1 -2
- package/runtime/xt_stdlib2/regexp-match.inc +17 -0
- package/runtime/xt_storage/indexed_db.c +4 -1
- package/runtime/xt_structured_clone.c +2 -1
- package/runtime/xt_typed_array/construction.inc +10 -0
- package/runtime/xt_typed_array/elements.inc +43 -23
- package/runtime/xt_url.c +50 -0
- package/runtime/xt_values/constructors.inc +4 -1
- package/runtime/xt_values/strings.inc +3 -1
- package/src/ast/common.ts +10 -0
- package/src/checker/source.ts +3 -0
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +5 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +87 -1
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +11 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/primary.ts +4 -27
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/state.ts +5 -0
- package/src/diagnostics/diagnostic.ts +1 -1
- package/src/diagnostics/source-text.ts +118 -22
- package/src/diagnostics/source.ts +29 -7
- package/src/driver/build-key.ts +21 -1
- package/src/driver/bundler/concatenate.ts +12 -5
- package/src/driver/bundler/graph.ts +2 -2
- package/src/driver/bundler/merge.ts +11 -4
- package/src/driver/bundler/reexport-resolution.ts +2 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/frontend.ts +3 -4
- package/src/driver/runtime-objects.ts +4 -0
- package/src/driver/toolchain.ts +28 -5
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/html.ts +41 -11
- package/src/extensions/gui/index.ts +50 -1
- package/src/extensions/registry.ts +20 -0
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
|
@@ -75,6 +75,23 @@ static char *xt_regexp_translate_js(const char *pattern, int *jsGroups, int *gro
|
|
|
75
75
|
default: break;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
if (!replacement && !literal && !consume) {
|
|
79
|
+
/* Any other escape is a literal (`\[`, `\]`, `\(`, `\.`, …). Copy the
|
|
80
|
+
* pair verbatim and skip the escaped character, so `\[` does not open a
|
|
81
|
+
* bracket expression and `\(` does not count as a group: the matcher
|
|
82
|
+
* reads `\[` as "a literal `[`", which is what the JavaScript pattern
|
|
83
|
+
* means. Dropping the backslash here used to turn `\[\s*i\s*\]` into a
|
|
84
|
+
* bracket expression and made three.js's unroll regex match nothing. */
|
|
85
|
+
if (written + 3 > capacity) {
|
|
86
|
+
capacity = capacity * 2 + 16;
|
|
87
|
+
out = (char *)realloc(out, capacity);
|
|
88
|
+
if (!out) abort();
|
|
89
|
+
}
|
|
90
|
+
out[written++] = '\\';
|
|
91
|
+
if (next != '\0') out[written++] = next;
|
|
92
|
+
i += next != '\0' ? 1 : 0;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
78
95
|
} else if (c == '[') {
|
|
79
96
|
inClass = 1;
|
|
80
97
|
} else if (c == ']') {
|
|
@@ -399,10 +399,13 @@ xt_value xt_storage_indexed_db(int32_t argc, xt_value *argv) {
|
|
|
399
399
|
(void)argc;
|
|
400
400
|
(void)argv;
|
|
401
401
|
if (!XT_IS_OBJECT(g_indexed_db)) {
|
|
402
|
+
/* Root the slot before allocating: `xt_storage_method` allocates, and a
|
|
403
|
+
* collection in between would sweep the object still reachable only from
|
|
404
|
+
* this static. */
|
|
405
|
+
xt_gc_add_root(&g_indexed_db);
|
|
402
406
|
g_indexed_db = xt_object_new();
|
|
403
407
|
xt_storage_method(g_indexed_db, "open", (void *)idb_open);
|
|
404
408
|
xt_storage_method(g_indexed_db, "deleteDatabase", (void *)idb_delete_database);
|
|
405
|
-
xt_gc_add_root(&g_indexed_db);
|
|
406
409
|
}
|
|
407
410
|
return g_indexed_db;
|
|
408
411
|
}
|
|
@@ -136,7 +136,7 @@ static xt_value xt_clone_value(xt_clone_context *context, xt_value value) {
|
|
|
136
136
|
/* Plain objects and Errors are cloned as data: own enumerable string keys,
|
|
137
137
|
* no prototype. That is what the platform algorithm does for ordinary
|
|
138
138
|
* objects and class instances. */
|
|
139
|
-
if (object->header.kind
|
|
139
|
+
if (!xt_kind_is_object(object->header.kind)) {
|
|
140
140
|
xt_clone_fail("value");
|
|
141
141
|
}
|
|
142
142
|
xt_value clone = xt_object_new();
|
|
@@ -157,3 +157,4 @@ xt_value xt_structured_clone(int32_t argc, xt_value *argv) {
|
|
|
157
157
|
free(context.entries);
|
|
158
158
|
return clone;
|
|
159
159
|
}
|
|
160
|
+
|
|
@@ -58,6 +58,16 @@ static xt_value xt_ta_view(int kind, xt_value buffer, uint32_t byteOffset, uint3
|
|
|
58
58
|
xt_object_set(array, xt_string_from_cstr("byteOffset"), xt_number((double)byteOffset));
|
|
59
59
|
xt_object_set(array, xt_ta_buffer_key(), buffer);
|
|
60
60
|
xt_object_set(array, xt_ta_offset_key(), xt_number((double)byteOffset));
|
|
61
|
+
/* Resolve the storage once for the per-element path (`xt_typed_array_read`).
|
|
62
|
+
* A buffer's byte block never moves while the buffer is alive and this view
|
|
63
|
+
* keeps the buffer reachable, so the pointer needs no invalidation. */
|
|
64
|
+
uint32_t buffer_length = 0;
|
|
65
|
+
uint8_t *bytes = xt_array_buffer_bytes(buffer, &buffer_length);
|
|
66
|
+
if (bytes != NULL && byteOffset <= buffer_length) {
|
|
67
|
+
xt_object *object = (xt_object *)XT_GET_PTR(array);
|
|
68
|
+
object->view_bytes = bytes + byteOffset;
|
|
69
|
+
object->view_length = buffer_length - byteOffset;
|
|
70
|
+
}
|
|
61
71
|
return array;
|
|
62
72
|
}
|
|
63
73
|
|
|
@@ -47,8 +47,15 @@ int xt_typed_array_kind_of(xt_value value) {
|
|
|
47
47
|
if (!XT_IS_OBJECT(value)) return -1;
|
|
48
48
|
xt_object *object = (xt_object *)XT_GET_PTR(value);
|
|
49
49
|
if (object->header.kind != XT_OBJECT_KIND_OBJECT) return -1;
|
|
50
|
+
/* The prototype lookup is memoized in `reserved2` (kind + 1): a typed array's
|
|
51
|
+
* kind never changes, and this is on the per-element path. `Object.setPrototypeOf`
|
|
52
|
+
* clears the slot, so a re-prototyped view falls back to the scan. */
|
|
53
|
+
if (object->reserved2 != 0) return (int)object->reserved2 - 1;
|
|
50
54
|
for (int kind = 0; kind < XT_TA_KIND_COUNT; kind++) {
|
|
51
|
-
if (xt_ta_protos[kind] && object->prototype == xt_ta_protos[kind])
|
|
55
|
+
if (xt_ta_protos[kind] && object->prototype == xt_ta_protos[kind]) {
|
|
56
|
+
object->reserved2 = (uint16_t)(kind + 1);
|
|
57
|
+
return kind;
|
|
58
|
+
}
|
|
52
59
|
}
|
|
53
60
|
return -1;
|
|
54
61
|
}
|
|
@@ -105,20 +112,36 @@ uint32_t xt_typed_array_byte_offset_of(xt_value array) {
|
|
|
105
112
|
return (uint32_t)xt_to_number(xt_object_get(array, xt_ta_offset_key()));
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
/* Views with no resolved byte block: a view over a zero-length buffer (reads are
|
|
116
|
+
* out of range) or a view built without a real ArrayBuffer, which keeps its
|
|
117
|
+
* elements as ordinary properties. */
|
|
118
|
+
static xt_value xt_ta_read_unbacked(xt_value array, int kind, uint32_t index) {
|
|
119
|
+
(void)kind;
|
|
120
|
+
if (xt_is_array_buffer(xt_typed_array_buffer_of(array))) return XT_UNDEFINED;
|
|
121
|
+
char key[24];
|
|
122
|
+
snprintf(key, sizeof(key), "%u", index);
|
|
123
|
+
return xt_object_get_cstr(array, key);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static void xt_ta_write_unbacked(xt_value array, int kind, uint32_t index, xt_value value) {
|
|
127
|
+
if (xt_is_array_buffer(xt_typed_array_buffer_of(array))) return;
|
|
128
|
+
char key[24];
|
|
129
|
+
snprintf(key, sizeof(key), "%u", index);
|
|
130
|
+
xt_object_set(array, xt_string_from_cstr(key),
|
|
131
|
+
xt_number(xt_typed_array_coerce(kind, xt_to_number(value))));
|
|
132
|
+
}
|
|
133
|
+
|
|
108
134
|
xt_value xt_typed_array_read(xt_value array, uint32_t index) {
|
|
135
|
+
XT_PROFILE_TICK(XT_PROFILE_TYPED_READ);
|
|
109
136
|
int kind = xt_typed_array_kind_of(array);
|
|
110
137
|
if (kind < 0) return XT_UNDEFINED;
|
|
111
|
-
xt_value buffer = xt_typed_array_buffer_of(array);
|
|
112
|
-
if (!xt_is_array_buffer(buffer)) {
|
|
113
|
-
char key[24];
|
|
114
|
-
snprintf(key, sizeof(key), "%u", index);
|
|
115
|
-
return xt_object_get_cstr(array, key);
|
|
116
|
-
}
|
|
117
138
|
uint32_t width = (uint32_t)xt_ta_bytes[kind];
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
xt_object *object = (xt_object *)XT_GET_PTR(array);
|
|
140
|
+
uint8_t *base = object->view_bytes;
|
|
141
|
+
if (base == NULL) return xt_ta_read_unbacked(array, kind, index);
|
|
142
|
+
uint32_t offset = index * width;
|
|
143
|
+
if (offset + width > object->view_length) return XT_UNDEFINED;
|
|
144
|
+
const uint8_t *raw = base + offset;
|
|
122
145
|
switch (kind) {
|
|
123
146
|
case XT_TA_U8:
|
|
124
147
|
return xt_number((double)raw[0]);
|
|
@@ -160,22 +183,20 @@ xt_value xt_typed_array_read(xt_value array, uint32_t index) {
|
|
|
160
183
|
}
|
|
161
184
|
|
|
162
185
|
void xt_typed_array_write(xt_value array, uint32_t index, xt_value value) {
|
|
186
|
+
XT_PROFILE_TICK(XT_PROFILE_TYPED_WRITE);
|
|
163
187
|
int kind = xt_typed_array_kind_of(array);
|
|
164
188
|
if (kind < 0) return;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
xt_number(xt_typed_array_coerce(kind, xt_to_number(value))));
|
|
189
|
+
uint32_t width = (uint32_t)xt_ta_bytes[kind];
|
|
190
|
+
xt_object *object = (xt_object *)XT_GET_PTR(array);
|
|
191
|
+
uint8_t *base = object->view_bytes;
|
|
192
|
+
if (base == NULL) {
|
|
193
|
+
xt_ta_write_unbacked(array, kind, index, value);
|
|
171
194
|
return;
|
|
172
195
|
}
|
|
173
|
-
uint32_t
|
|
174
|
-
|
|
175
|
-
if (offset + width > xt_array_buffer_byte_length(buffer)) return;
|
|
196
|
+
uint32_t offset = index * width;
|
|
197
|
+
if (offset + width > object->view_length) return;
|
|
176
198
|
double coerced = xt_typed_array_coerce(kind, xt_to_number(value));
|
|
177
|
-
uint8_t raw
|
|
178
|
-
memset(raw, 0, sizeof(raw));
|
|
199
|
+
uint8_t *raw = base + offset;
|
|
179
200
|
switch (kind) {
|
|
180
201
|
case XT_TA_U8:
|
|
181
202
|
case XT_TA_U8C:
|
|
@@ -215,7 +236,6 @@ void xt_typed_array_write(xt_value array, uint32_t index, xt_value value) {
|
|
|
215
236
|
break;
|
|
216
237
|
}
|
|
217
238
|
}
|
|
218
|
-
for (uint32_t i = 0; i < width; i++) xt_array_buffer_set_byte(buffer, offset + i, raw[i]);
|
|
219
239
|
}
|
|
220
240
|
|
|
221
241
|
/* -- element storage ------------------------------------------------------ */
|
package/runtime/xt_url.c
CHANGED
|
@@ -344,6 +344,52 @@ static xt_value xt_url_method_entries(xt_value thisValue, xt_value env, int32_t
|
|
|
344
344
|
return result;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
static xt_value xt_url_iterator_self(xt_value self, xt_value env, int32_t argc, xt_value *argv) {
|
|
348
|
+
(void)env;
|
|
349
|
+
(void)argc;
|
|
350
|
+
(void)argv;
|
|
351
|
+
return self;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** One step of the `[Symbol.iterator]` walk: `{ value: [key, value], done }`. */
|
|
355
|
+
static xt_value xt_url_iterator_next(xt_value self, xt_value env, int32_t argc,
|
|
356
|
+
xt_value *argv) {
|
|
357
|
+
(void)self;
|
|
358
|
+
(void)argc;
|
|
359
|
+
(void)argv;
|
|
360
|
+
xt_array *entries = xt_as_array(xt_closure_env(env, 0));
|
|
361
|
+
xt_value indexBox = xt_closure_env(env, 1);
|
|
362
|
+
int32_t index = (int32_t)xt_to_number(xt_get(indexBox, xt_number(0)));
|
|
363
|
+
xt_value result = xt_object_new();
|
|
364
|
+
if (entries == NULL || index < 0 || (uint32_t)index >= entries->length) {
|
|
365
|
+
xt_object_set(result, xt_string_from_cstr("value"), XT_UNDEFINED);
|
|
366
|
+
xt_object_set(result, xt_string_from_cstr("done"), XT_TRUE);
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
xt_object_set(result, xt_string_from_cstr("value"), entries->items[index]);
|
|
370
|
+
xt_object_set(result, xt_string_from_cstr("done"), XT_FALSE);
|
|
371
|
+
xt_set(indexBox, xt_number(0), xt_number(index + 1));
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/* `URLSearchParams` is iterable — `[...params]`, `for (const [k, v] of params)`
|
|
376
|
+
* and `Object.fromEntries(params)` all rely on it. The iterator is itself
|
|
377
|
+
* iterable, as the iteration protocol requires. */
|
|
378
|
+
static xt_value xt_url_iterator(xt_value thisValue, xt_value env, int32_t argc,
|
|
379
|
+
xt_value *argv) {
|
|
380
|
+
(void)env;
|
|
381
|
+
(void)argc;
|
|
382
|
+
(void)argv;
|
|
383
|
+
xt_value captured[2] = {xt_url_entries(thisValue), xt_array_new(0, NULL)};
|
|
384
|
+
xt_array_push(captured[1], xt_number(0));
|
|
385
|
+
xt_value iterator = xt_object_new();
|
|
386
|
+
xt_object_set(iterator, xt_string_from_cstr("next"),
|
|
387
|
+
xt_closure_new((void *)xt_url_iterator_next, 2, captured));
|
|
388
|
+
xt_object_set(iterator, xt_symbol_well_known("iterator"),
|
|
389
|
+
xt_closure_new((void *)xt_url_iterator_self, 0, NULL));
|
|
390
|
+
return iterator;
|
|
391
|
+
}
|
|
392
|
+
|
|
347
393
|
static void xt_url_install(xt_value params, const char *name, void *fn) {
|
|
348
394
|
xt_object_set(params, xt_string_from_cstr(name), xt_closure_new(fn, 0, NULL));
|
|
349
395
|
}
|
|
@@ -364,6 +410,10 @@ xt_value xt_url_search_params_ctor(int32_t argc, xt_value *argv) {
|
|
|
364
410
|
xt_url_install(params, "keys", (void *)xt_url_method_keys);
|
|
365
411
|
xt_url_install(params, "values", (void *)xt_url_method_values);
|
|
366
412
|
xt_url_install(params, "entries", (void *)xt_url_method_entries);
|
|
413
|
+
xt_url_install(params, "keys", (void *)xt_url_method_keys);
|
|
414
|
+
xt_url_install(params, "values", (void *)xt_url_method_values);
|
|
415
|
+
xt_object_set(params, xt_symbol_well_known("iterator"),
|
|
416
|
+
xt_closure_new((void *)xt_url_iterator, 0, NULL));
|
|
367
417
|
xt_url_ctor_from_value(params, xt_arg_at(argc, argv, 0));
|
|
368
418
|
return params;
|
|
369
419
|
}
|
|
@@ -32,7 +32,10 @@ xt_value xt_string_new(const char *data, size_t len) {
|
|
|
32
32
|
return XT_FROM_PTR(XT_TAG_STRING, s);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
xt_value xt_string_from_cstr(const char *data) {
|
|
35
|
+
xt_value xt_string_from_cstr(const char *data) {
|
|
36
|
+
XT_PROFILE_TICK(XT_PROFILE_STRING_CSTR);
|
|
37
|
+
return xt_string_new(data, strlen(data));
|
|
38
|
+
}
|
|
36
39
|
|
|
37
40
|
xt_string *xt_as_string(xt_value v);
|
|
38
41
|
|
|
@@ -105,8 +105,10 @@ int xt_string_equals(xt_string *a, xt_string *b) {
|
|
|
105
105
|
/* Interned literals (property names above all) are shared, so identity is the
|
|
106
106
|
* common case and skips the length, flattening and byte comparison entirely. */
|
|
107
107
|
if (a == b) return 1;
|
|
108
|
+
/* Length first: a property scan compares many different keys, and a cons
|
|
109
|
+
* string only materialises its bytes on the first `xt_string_bytes` call. */
|
|
110
|
+
if (a->length != b->length) return 0;
|
|
108
111
|
const char *aBytes = xt_string_bytes(a);
|
|
109
112
|
const char *bBytes = xt_string_bytes(b);
|
|
110
|
-
if (a->length != b->length) return 0;
|
|
111
113
|
return memcmp(aBytes, bBytes, a->length) == 0;
|
|
112
114
|
}
|
package/src/ast/common.ts
CHANGED
|
@@ -234,4 +234,14 @@ export interface SourceFileNode extends Node {
|
|
|
234
234
|
* `fail`, not `m1_fail`.
|
|
235
235
|
*/
|
|
236
236
|
readonly modulePrefixes?: readonly string[];
|
|
237
|
+
/**
|
|
238
|
+
* For a bundled program: nodes whose source is plain JavaScript even though
|
|
239
|
+
* their origin file is not a `.js` file.
|
|
240
|
+
*
|
|
241
|
+
* An inline `<script>` body in an HTML page is JavaScript by default — only a
|
|
242
|
+
* `lang="ts"` / `type="text/typescript"` tag opts into TypeScript semantics —
|
|
243
|
+
* so the checker must treat its nodes the way it treats an external `.js`
|
|
244
|
+
* script rather than inferring types from unannotated code.
|
|
245
|
+
*/
|
|
246
|
+
readonly untypedNodes?: ReadonlySet<object>;
|
|
237
247
|
}
|
package/src/checker/source.ts
CHANGED
|
@@ -42,6 +42,9 @@ export function isDependencyNode(sourceFile: SourceFileNode, node: Node): boolea
|
|
|
42
42
|
* reported, but no type, arity or property diagnostic is produced.
|
|
43
43
|
*/
|
|
44
44
|
export function isPlainJavaScriptNode(sourceFile: SourceFileNode, node: Node): boolean {
|
|
45
|
+
/* An inline `<script>` body in an HTML page (no `lang="ts"`): the bundler
|
|
46
|
+
* marks its nodes, because the origin file is the page, not a `.js` file. */
|
|
47
|
+
if (sourceFile.untypedNodes?.has(node)) return true;
|
|
45
48
|
const origin = sourceFile.origins?.get(node) ?? sourceFile.fileName;
|
|
46
49
|
return /\.(js|mjs|cjs|jsx)$/i.test(origin);
|
|
47
50
|
}
|
package/src/cli/main.ts
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { spawnSync } from "node:child_process";
|
|
16
|
-
import { readFileSync } from "node:fs";
|
|
17
16
|
import { dirname, resolve } from "node:path";
|
|
18
17
|
import { pathToFileURL } from "node:url";
|
|
19
18
|
import { formatDiagnostic, type Diagnostic } from "../diagnostics/diagnostic.js";
|
|
20
19
|
import { SourceFile } from "../diagnostics/source.js";
|
|
20
|
+
import { readSourceText } from "../diagnostics/source-text.js";
|
|
21
21
|
import { build, compileEntry, COMPILER_VERSION, type EmitKind, type PhaseTiming } from "../driver/compiler.js";
|
|
22
22
|
import { findRuntimeDir, platformSlug } from "../driver/paths.js";
|
|
23
23
|
import { supportFloor } from "../driver/platform-support.js";
|
|
@@ -149,7 +149,7 @@ function printDiagnostics(diagnostics: readonly Diagnostic[], fileName: string,
|
|
|
149
149
|
const sourceFor = (name: string): SourceFile | undefined => {
|
|
150
150
|
if (!sources.has(name)) {
|
|
151
151
|
try {
|
|
152
|
-
sources.set(name, new SourceFile(name,
|
|
152
|
+
sources.set(name, new SourceFile(name, readSourceText(name)));
|
|
153
153
|
} catch {
|
|
154
154
|
sources.set(name, undefined);
|
|
155
155
|
}
|
|
@@ -558,7 +558,18 @@ function dispatch(argv: readonly string[], io: CliIo): number {
|
|
|
558
558
|
return 1;
|
|
559
559
|
}
|
|
560
560
|
const executed = spawnSync(result.outputPath, args.passthrough, { stdio: "inherit" });
|
|
561
|
-
|
|
561
|
+
/* `status === null` means the program never ran or was killed by a signal;
|
|
562
|
+
* reporting 0 there would hide a crash from CI. */
|
|
563
|
+
if (executed.error) {
|
|
564
|
+
io.stderr(`xbintsc: failed to run ${result.outputPath}: ${executed.error.message}\n`);
|
|
565
|
+
return 1;
|
|
566
|
+
}
|
|
567
|
+
if (executed.status !== null) return executed.status;
|
|
568
|
+
if (executed.signal) {
|
|
569
|
+
io.stderr(`xbintsc: ${result.outputPath} terminated by signal ${executed.signal}\n`);
|
|
570
|
+
return 1;
|
|
571
|
+
}
|
|
572
|
+
return 1;
|
|
562
573
|
}
|
|
563
574
|
|
|
564
575
|
io.stderr(`xbintsc: unknown command '${command}'\n\n${HELP}`);
|
|
@@ -166,19 +166,13 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
166
166
|
* inside a `static` method), not from the `super` keyword itself. */
|
|
167
167
|
const isSuper = isSuperKeyword(node.expression);
|
|
168
168
|
const object = isSuper ? this.emitSuperHolder() : this.emitExpression(node.expression);
|
|
169
|
-
|
|
169
|
+
if (isSuper) {
|
|
170
170
|
const key = this.emitExpression(node.argumentExpression);
|
|
171
171
|
const result = this.reg();
|
|
172
|
-
|
|
173
|
-
* a numeric literal; every other key may benefit from it. */
|
|
174
|
-
if (isSuper || node.argumentExpression.kind === SyntaxKind.NumericLiteral) {
|
|
175
|
-
this.emit(` ${result} = call i64 @xt_get(i64 ${object}, i64 ${key})`);
|
|
176
|
-
} else {
|
|
177
|
-
const cache = this.icCachePointer();
|
|
178
|
-
this.emit(` ${result} = call i64 @xt_get_ic(i64 ${object}, i64 ${key}, i64* ${cache})`);
|
|
179
|
-
}
|
|
172
|
+
this.emit(` ${result} = call i64 @xt_get(i64 ${object}, i64 ${key})`);
|
|
180
173
|
return result;
|
|
181
|
-
}
|
|
174
|
+
}
|
|
175
|
+
const access = (): string => this.emitElementRead(object, this.emitExpression(node.argumentExpression));
|
|
182
176
|
return node.optional ? this.emitOptional(object, access) : access();
|
|
183
177
|
},
|
|
184
178
|
|
|
@@ -344,3 +338,4 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
344
338
|
return merged;
|
|
345
339
|
},
|
|
346
340
|
};
|
|
341
|
+
|