xbintsc 0.6.28 → 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/binder/declarations.d.ts +1 -0
- package/dist/src/binder/declarations.js +37 -0
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/binder/references.js +12 -0
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/checker/globals.js +1 -0
- package/dist/src/checker/globals.js.map +1 -1
- package/dist/src/checker/source.js +4 -0
- package/dist/src/checker/source.js.map +1 -1
- package/dist/src/checker/type-system.d.ts +5 -0
- package/dist/src/checker/type-system.js +22 -3
- package/dist/src/checker/type-system.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 +29 -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 +95 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls/super.js +3 -4
- package/dist/src/codegen/generator/calls/super.js.map +1 -1
- package/dist/src/codegen/generator/calls/unwrap.d.ts +18 -0
- package/dist/src/codegen/generator/calls/unwrap.js +45 -0
- package/dist/src/codegen/generator/calls/unwrap.js.map +1 -0
- 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 +24 -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/module-values.d.ts +6 -0
- package/dist/src/codegen/generator/expressions/module-values.js +51 -17
- package/dist/src/codegen/generator/expressions/module-values.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +13 -29
- 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/generator.js +4 -0
- package/dist/src/codegen/generator/generator.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/lookup-tables.d.ts +22 -0
- package/dist/src/codegen/generator/lookup-tables.js +48 -0
- package/dist/src/codegen/generator/lookup-tables.js.map +1 -0
- package/dist/src/codegen/generator/module.js +38 -7
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.js +21 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +2 -6
- package/dist/src/codegen/generator/tables.js +18 -12
- package/dist/src/codegen/generator/tables.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/commonjs.d.ts +9 -2
- package/dist/src/driver/bundler/commonjs.js +11 -4
- package/dist/src/driver/bundler/commonjs.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.d.ts +20 -0
- package/dist/src/driver/bundler/concatenate.js +79 -8
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/deferred.d.ts +29 -1
- package/dist/src/driver/bundler/deferred.js +114 -5
- package/dist/src/driver/bundler/deferred.js.map +1 -1
- package/dist/src/driver/bundler/dynamic-import.d.ts +6 -0
- package/dist/src/driver/bundler/dynamic-import.js +59 -3
- package/dist/src/driver/bundler/dynamic-import.js.map +1 -1
- package/dist/src/driver/bundler/graph.d.ts +13 -0
- package/dist/src/driver/bundler/graph.js +4 -4
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +43 -13
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/namespace-object.d.ts +11 -0
- package/dist/src/driver/bundler/namespace-object.js +32 -0
- package/dist/src/driver/bundler/namespace-object.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +11 -2
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/bundler/symbols.d.ts +4 -0
- package/dist/src/driver/bundler/symbols.js +14 -1
- package/dist/src/driver/bundler/symbols.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/config.d.ts +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/options.d.ts +1 -4
- package/dist/src/driver/runtime-lib.d.ts +27 -0
- package/dist/src/driver/runtime-lib.js +78 -2
- package/dist/src/driver/runtime-lib.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +28 -5
- 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/driver/version.js.map +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/node/buffer/index.d.ts +5 -4
- package/dist/src/extensions/node/buffer/index.js +5 -4
- package/dist/src/extensions/node/buffer/index.js.map +1 -1
- package/dist/src/extensions/node/events/index.js +8 -1
- package/dist/src/extensions/node/events/index.js.map +1 -1
- package/dist/src/extensions/node/fs/callbacks.d.ts +9 -0
- package/dist/src/extensions/node/fs/callbacks.js +42 -0
- package/dist/src/extensions/node/fs/callbacks.js.map +1 -0
- package/dist/src/extensions/node/fs/index.d.ts +2 -3
- package/dist/src/extensions/node/fs/index.js +11 -4
- package/dist/src/extensions/node/fs/index.js.map +1 -1
- package/dist/src/extensions/node/process/index.d.ts +10 -3
- package/dist/src/extensions/node/process/index.js +30 -5
- package/dist/src/extensions/node/process/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +27 -0
- package/dist/src/extensions/registry.js +13 -4
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/lexer/scanner.d.ts +7 -1
- package/dist/src/lexer/scanner.js +15 -0
- package/dist/src/lexer/scanner.js.map +1 -1
- package/dist/src/parser/context.d.ts +10 -0
- package/dist/src/parser/context.js +42 -3
- package/dist/src/parser/context.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/src/parser/literals.js +6 -2
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/binder/binder.test.js +43 -0
- package/dist/tests/binder/binder.test.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 +28 -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/bundler-resolve.test.js +12 -0
- package/dist/tests/driver/bundler-resolve.test.js.map +1 -1
- package/dist/tests/driver/commonjs-prelude.test.d.ts +11 -0
- package/dist/tests/driver/commonjs-prelude.test.js +69 -0
- package/dist/tests/driver/commonjs-prelude.test.js.map +1 -0
- package/dist/tests/driver/compiler.test.js +42 -1
- package/dist/tests/driver/compiler.test.js.map +1 -1
- package/dist/tests/driver/html-deferred-cycles.test.d.ts +10 -0
- package/dist/tests/driver/html-deferred-cycles.test.js +75 -0
- package/dist/tests/driver/html-deferred-cycles.test.js.map +1 -0
- package/dist/tests/driver/namespace-type-exports.test.d.ts +9 -0
- package/dist/tests/driver/namespace-type-exports.test.js +59 -0
- package/dist/tests/driver/namespace-type-exports.test.js.map +1 -0
- package/dist/tests/driver/runtime-lib.test.js +49 -1
- package/dist/tests/driver/runtime-lib.test.js.map +1 -1
- 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-basics.test.js +53 -0
- package/dist/tests/e2e/compile-basics.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-deferred-marker.test.d.ts +14 -0
- package/dist/tests/e2e/compile-deferred-marker.test.js +68 -0
- package/dist/tests/e2e/compile-deferred-marker.test.js.map +1 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.d.ts +12 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.js +89 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.js.map +1 -0
- package/dist/tests/e2e/compile-error-module.test.d.ts +9 -0
- package/dist/tests/e2e/compile-error-module.test.js +29 -0
- package/dist/tests/e2e/compile-error-module.test.js.map +1 -0
- package/dist/tests/e2e/compile-gc-promises.test.d.ts +11 -0
- package/dist/tests/e2e/compile-gc-promises.test.js +52 -0
- package/dist/tests/e2e/compile-gc-promises.test.js.map +1 -0
- package/dist/tests/e2e/compile-modules.test.js +53 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-node-fs-callbacks.test.d.ts +6 -0
- package/dist/tests/e2e/compile-node-fs-callbacks.test.js +46 -0
- package/dist/tests/e2e/compile-node-fs-callbacks.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-inheritance.test.d.ts +6 -0
- package/dist/tests/e2e/compile-node-inheritance.test.js +48 -0
- package/dist/tests/e2e/compile-node-inheritance.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-require.test.d.ts +9 -0
- package/dist/tests/e2e/compile-node-require.test.js +29 -0
- package/dist/tests/e2e/compile-node-require.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-stats.test.d.ts +8 -0
- package/dist/tests/e2e/compile-node-stats.test.js +26 -0
- package/dist/tests/e2e/compile-node-stats.test.js.map +1 -0
- 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/compile-proxy.test.d.ts +6 -0
- package/dist/tests/e2e/compile-proxy.test.js +66 -0
- package/dist/tests/e2e/compile-proxy.test.js.map +1 -0
- package/dist/tests/e2e/compile-web-globals.test.d.ts +6 -0
- package/dist/tests/e2e/compile-web-globals.test.js +94 -0
- package/dist/tests/e2e/compile-web-globals.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/fetch.test.js +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-script-import-order.test.js +24 -0
- package/dist/tests/e2e/gui-script-import-order.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/json-stringify-to-json.test.d.ts +10 -0
- package/dist/tests/e2e/json-stringify-to-json.test.js +61 -0
- package/dist/tests/e2e/json-stringify-to-json.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/node-process.test.d.ts +7 -0
- package/dist/tests/e2e/node-process.test.js +50 -0
- package/dist/tests/e2e/node-process.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/runtime-coverage-buffer.test.js +31 -0
- package/dist/tests/e2e/runtime-coverage-buffer.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/e2e/web-streams.test.js +44 -29
- package/dist/tests/e2e/web-streams.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/dist/tests/parser/literals.test.js +19 -0
- package/dist/tests/parser/literals.test.js.map +1 -1
- package/dist/tests/parser/statements.test.js +13 -0
- package/dist/tests/parser/statements.test.js.map +1 -1
- package/doc/ai/cli.md +1 -0
- 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/cli.md +1 -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/binder.md +2 -1
- package/doc/implemented/checker.md +14 -0
- package/doc/implemented/codegen.md +7 -0
- package/doc/implemented/lexer.md +1 -1
- package/doc/implemented/modules.md +23 -1
- package/doc/implemented/node/buffer.md +18 -5
- package/doc/implemented/node/fs.md +22 -1
- package/doc/implemented/node/process.md +65 -5
- package/doc/implemented/node.md +7 -1
- package/doc/implemented/operators.md +3 -1
- package/doc/implemented/parser.md +3 -2
- package/doc/implemented/runtime-core.md +13 -2
- package/doc/implemented/stdlib.md +79 -4
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/unimplemented/classes.md +1 -0
- package/doc/unimplemented/modules.md +1 -0
- package/doc/unimplemented/stdlib.md +2 -1
- package/doc/xbintsc.config.schema.json +5 -0
- 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/binder.md +2 -1
- package/doc/zh-CN/implemented/checker.md +10 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- package/doc/zh-CN/implemented/lexer.md +1 -1
- package/doc/zh-CN/implemented/modules.md +17 -1
- package/doc/zh-CN/implemented/node/buffer.md +3 -1
- package/doc/zh-CN/implemented/node/fs.md +19 -1
- package/doc/zh-CN/implemented/node/process.md +59 -5
- package/doc/zh-CN/implemented/node.md +1 -1
- package/doc/zh-CN/implemented/operators.md +2 -1
- package/doc/zh-CN/implemented/parser.md +3 -2
- package/doc/zh-CN/implemented/runtime-core.md +10 -2
- package/doc/zh-CN/implemented/stdlib.md +64 -4
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/doc/zh-CN/unimplemented/classes.md +1 -0
- package/doc/zh-CN/unimplemented/modules.md +1 -0
- package/doc/zh-CN/unimplemented/stdlib.md +2 -1
- 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/ext_node/buffer/buffer.c +5 -4
- package/runtime/ext_node/buffer/parts/byte-access.inc +115 -11
- package/runtime/ext_node/buffer/parts/prototype.inc +4 -1
- package/runtime/ext_node/events/events.c +9 -0
- package/runtime/ext_node/fs/callbacks.c +138 -0
- package/runtime/ext_node/fs/fs_ops.c +28 -15
- package/runtime/ext_node/module/module.c +18 -9
- package/runtime/ext_node/process/process.c +117 -32
- package/runtime/ext_node/process/streams.c +370 -0
- package/runtime/ext_node/process/streams.h +20 -0
- package/runtime/rt.h +63 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +61 -69
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +154 -181
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_async_io.c +3 -0
- package/runtime/xt_builtins.c +29 -24
- package/runtime/xt_constructors.c +102 -2
- package/runtime/xt_containers/access.inc +125 -12
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/function_prototypes.inc +58 -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 +59 -75
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +5 -0
- package/runtime/xt_exit.c +34 -0
- package/runtime/xt_fetch/headers.inc +1 -0
- package/runtime/xt_fetch/response.inc +28 -8
- package/runtime/xt_fetch/webapi.inc +82 -0
- package/runtime/xt_fetch.c +5 -0
- package/runtime/xt_gc_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +136 -0
- package/runtime/xt_intl.c +224 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +66 -1
- 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_module_values.c +82 -0
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_proxy.c +140 -0
- package/runtime/xt_stdlib/dispatch.inc +104 -9
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/json.inc +28 -0
- package/runtime/xt_stdlib2/json_stringify.inc +71 -55
- 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/runtime/xt_web.h +27 -0
- package/runtime/xt_web_abort.c +373 -0
- package/scripts/build-runtime.ts +8 -0
- package/src/ast/common.ts +10 -0
- package/src/binder/declarations.ts +34 -0
- package/src/binder/references.ts +12 -0
- package/src/checker/globals.ts +1 -0
- package/src/checker/source.ts +3 -0
- package/src/checker/type-system.ts +23 -3
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +28 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +99 -1
- package/src/codegen/generator/calls/super.ts +5 -4
- package/src/codegen/generator/calls/unwrap.ts +47 -0
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +26 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/module-values.ts +57 -19
- package/src/codegen/generator/expressions/primary.ts +13 -36
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/generator.ts +4 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/lookup-tables.ts +63 -0
- package/src/codegen/generator/module.ts +38 -7
- package/src/codegen/generator/state.ts +22 -0
- package/src/codegen/generator/tables.ts +18 -12
- 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/commonjs.ts +12 -5
- package/src/driver/bundler/concatenate.ts +96 -12
- package/src/driver/bundler/deferred.ts +122 -6
- package/src/driver/bundler/dynamic-import.ts +75 -2
- package/src/driver/bundler/graph.ts +4 -4
- package/src/driver/bundler/merge.ts +42 -9
- package/src/driver/bundler/namespace-object.ts +44 -0
- package/src/driver/bundler/reexport-resolution.ts +14 -2
- package/src/driver/bundler/symbols.ts +17 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/config.ts +1 -1
- package/src/driver/frontend.ts +3 -4
- package/src/driver/options.ts +1 -4
- package/src/driver/runtime-lib.ts +87 -2
- package/src/driver/runtime-objects.ts +28 -5
- 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/node/buffer/index.ts +5 -4
- package/src/extensions/node/events/index.ts +8 -1
- package/src/extensions/node/fs/callbacks.ts +45 -0
- package/src/extensions/node/fs/index.ts +11 -4
- package/src/extensions/node/process/index.ts +30 -5
- package/src/extensions/registry.ts +41 -4
- package/src/lexer/scanner.ts +16 -1
- package/src/parser/context.ts +39 -3
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
- package/src/parser/literals.ts +6 -2
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — `AbortController` / `AbortSignal`.
|
|
3
|
+
*
|
|
4
|
+
* A signal is an ordinary object carrying its state under `__`-prefixed own
|
|
5
|
+
* properties (aborted flag, reason, listener array, timeout handle); the
|
|
6
|
+
* public surface lives on the prototype, so `signal instanceof AbortSignal`
|
|
7
|
+
* holds and methods are shared. `aborted` / `reason` / `onabort` are accessors
|
|
8
|
+
* over that state.
|
|
9
|
+
*
|
|
10
|
+
* Covered: `abort(reason?)`, `addEventListener("abort", fn[, { once }])`,
|
|
11
|
+
* `removeEventListener`, `onabort`, `throwIfAborted()`, and the statics
|
|
12
|
+
* `AbortSignal.abort()`, `AbortSignal.timeout(ms)`, `AbortSignal.any([...])`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
#include "rt_internal.h"
|
|
16
|
+
|
|
17
|
+
#include <stdlib.h>
|
|
18
|
+
#include <string.h>
|
|
19
|
+
|
|
20
|
+
/* Prototypes are built once and kept alive for the life of the program. */
|
|
21
|
+
static xt_value xt_web_abort_signal_proto_value = XT_UNDEFINED;
|
|
22
|
+
static xt_value xt_web_abort_controller_proto_value = XT_UNDEFINED;
|
|
23
|
+
|
|
24
|
+
/* Method bodies, defined below and installed on the prototypes. */
|
|
25
|
+
static xt_value xt_web_signal_add_listener(xt_value thisValue, xt_value env, int32_t argc,
|
|
26
|
+
xt_value *argv);
|
|
27
|
+
static xt_value xt_web_signal_remove_listener(xt_value thisValue, xt_value env, int32_t argc,
|
|
28
|
+
xt_value *argv);
|
|
29
|
+
static xt_value xt_web_signal_throw_if_aborted(xt_value thisValue, xt_value env, int32_t argc,
|
|
30
|
+
xt_value *argv);
|
|
31
|
+
static xt_value xt_web_controller_abort(xt_value thisValue, xt_value env, int32_t argc,
|
|
32
|
+
xt_value *argv);
|
|
33
|
+
static xt_value xt_web_timeout_fire(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
34
|
+
static xt_value xt_web_chain_fire(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
35
|
+
|
|
36
|
+
static void xt_web_abort_define(xt_value object, const char *name, xt_code_fn fn,
|
|
37
|
+
int32_t arity) {
|
|
38
|
+
xt_value key = xt_string_from_cstr(name);
|
|
39
|
+
xt_value closure = xt_closure_new((void *)fn, 0, NULL);
|
|
40
|
+
xt_function_set_metadata(closure, key, arity);
|
|
41
|
+
xt_object_set(object, key, closure);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static void xt_web_abort_define_accessor(xt_value object, const char *name, xt_code_fn getter,
|
|
45
|
+
xt_code_fn setter) {
|
|
46
|
+
xt_value key = xt_string_from_cstr(name);
|
|
47
|
+
xt_value getterValue = xt_closure_new((void *)getter, 0, NULL);
|
|
48
|
+
xt_function_set_metadata(getterValue, key, 0);
|
|
49
|
+
xt_object_define_getter(object, key, getterValue);
|
|
50
|
+
if (!setter) return;
|
|
51
|
+
xt_value setterValue = xt_closure_new((void *)setter, 0, NULL);
|
|
52
|
+
xt_function_set_metadata(setterValue, key, 1);
|
|
53
|
+
xt_object_define_setter(object, key, setterValue);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* -- state ---------------------------------------------------------------- */
|
|
57
|
+
|
|
58
|
+
static int xt_web_signal_is_aborted(xt_value signal) {
|
|
59
|
+
return xt_truthy(xt_object_get_cstr(signal, "__aborted"));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static xt_value xt_web_signal_listeners(xt_value signal) {
|
|
63
|
+
xt_value listeners = xt_object_get_cstr(signal, "__listeners");
|
|
64
|
+
if (!XT_IS_ARRAY(listeners)) {
|
|
65
|
+
listeners = xt_array_new(0, NULL);
|
|
66
|
+
xt_object_set(signal, xt_string_from_cstr("__listeners"), listeners);
|
|
67
|
+
}
|
|
68
|
+
return listeners;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static int32_t xt_web_count(xt_value array) {
|
|
72
|
+
if (!XT_IS_ARRAY(array)) return 0;
|
|
73
|
+
return (int32_t)xt_to_number(xt_array_length(array));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* `<name>Error` with a message, shaped like the platform's DOMException
|
|
77
|
+
* (`error.name` is what programs branch on). */
|
|
78
|
+
static xt_value xt_web_named_error(const char *name, const char *message) {
|
|
79
|
+
xt_value arguments[1];
|
|
80
|
+
arguments[0] = xt_string_from_cstr(message);
|
|
81
|
+
xt_value error = xt_error_ctor_by_name(xt_string_from_cstr("Error"), 1, arguments);
|
|
82
|
+
if (XT_IS_OBJECT(error)) {
|
|
83
|
+
xt_object_set(error, xt_string_from_cstr("name"), xt_string_from_cstr(name));
|
|
84
|
+
}
|
|
85
|
+
return error;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static xt_value xt_web_abort_reason_default(void) {
|
|
89
|
+
return xt_web_named_error("AbortError", "This operation was aborted");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static xt_value xt_web_timeout_reason(void) {
|
|
93
|
+
return xt_web_named_error("TimeoutError", "The operation was aborted due to timeout");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* -- aborting ------------------------------------------------------------- */
|
|
97
|
+
|
|
98
|
+
/* Fire the `abort` event: `onabort` first, then every registered listener in
|
|
99
|
+
* registration order; `{ once: true }` entries are dropped after the call. */
|
|
100
|
+
static void xt_web_signal_fire(xt_value signal) {
|
|
101
|
+
xt_value event = xt_object_new();
|
|
102
|
+
xt_object_set(event, xt_string_from_cstr("type"), xt_string_from_cstr("abort"));
|
|
103
|
+
xt_object_set(event, xt_string_from_cstr("target"), signal);
|
|
104
|
+
xt_object_set(event, xt_string_from_cstr("currentTarget"), signal);
|
|
105
|
+
|
|
106
|
+
xt_value handler = xt_object_get_cstr(signal, "__onabort");
|
|
107
|
+
if (XT_IS_FUNCTION(handler)) xt_call_with_this(handler, signal, 1, &event);
|
|
108
|
+
|
|
109
|
+
xt_value listeners = xt_web_signal_listeners(signal);
|
|
110
|
+
int32_t count = xt_web_count(listeners);
|
|
111
|
+
if (count == 0) return;
|
|
112
|
+
/* Snapshot first: a listener may add or remove listeners. */
|
|
113
|
+
xt_value snapshot = xt_array_new(0, NULL);
|
|
114
|
+
for (int32_t index = 0; index < count; index++) {
|
|
115
|
+
xt_array_push(snapshot, xt_array_get(listeners, xt_number((double)index)));
|
|
116
|
+
}
|
|
117
|
+
int32_t snapshotCount = xt_web_count(snapshot);
|
|
118
|
+
for (int32_t index = 0; index < snapshotCount; index++) {
|
|
119
|
+
xt_value entry = xt_array_get(snapshot, xt_number((double)index));
|
|
120
|
+
if (!XT_IS_OBJECT(entry)) continue;
|
|
121
|
+
xt_value fn = xt_object_get_cstr(entry, "fn");
|
|
122
|
+
if (XT_IS_FUNCTION(fn)) xt_call_with_this(fn, signal, 1, &event);
|
|
123
|
+
}
|
|
124
|
+
/* Drop every `once` entry that fired. */
|
|
125
|
+
int32_t remaining = 0;
|
|
126
|
+
for (int32_t index = 0; index < count; index++) {
|
|
127
|
+
xt_value entry = xt_array_get(listeners, xt_number((double)index));
|
|
128
|
+
if (XT_IS_OBJECT(entry) && xt_truthy(xt_object_get_cstr(entry, "once"))) continue;
|
|
129
|
+
if (remaining != index) {
|
|
130
|
+
xt_array_set(listeners, xt_number((double)remaining), entry);
|
|
131
|
+
}
|
|
132
|
+
remaining++;
|
|
133
|
+
}
|
|
134
|
+
xt_as_array(listeners)->length = remaining;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static void xt_web_signal_abort(xt_value signal, xt_value reason) {
|
|
138
|
+
if (xt_web_signal_is_aborted(signal)) return;
|
|
139
|
+
xt_object_set(signal, xt_string_from_cstr("__aborted"), XT_TRUE);
|
|
140
|
+
xt_object_set(signal, xt_string_from_cstr("__reason"), reason);
|
|
141
|
+
xt_web_signal_fire(signal);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* A signal that is not aborted yet, chained onto the signal prototype. */
|
|
145
|
+
static xt_value xt_web_signal_new(void) {
|
|
146
|
+
xt_value signal = xt_object_new();
|
|
147
|
+
xt_object_set_prototype(signal, xt_web_abort_signal_proto());
|
|
148
|
+
xt_object_set(signal, xt_string_from_cstr("__aborted"), XT_FALSE);
|
|
149
|
+
xt_object_set(signal, xt_string_from_cstr("__reason"), XT_UNDEFINED);
|
|
150
|
+
xt_object_set(signal, xt_string_from_cstr("__listeners"), xt_array_new(0, NULL));
|
|
151
|
+
return signal;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* -- AbortSignal methods -------------------------------------------------- */
|
|
155
|
+
|
|
156
|
+
static xt_value xt_web_signal_add_listener(xt_value thisValue, xt_value env, int32_t argc,
|
|
157
|
+
xt_value *argv) {
|
|
158
|
+
(void)env;
|
|
159
|
+
xt_value type = xt_arg(argc, argv, 0);
|
|
160
|
+
xt_value listener = xt_arg(argc, argv, 1);
|
|
161
|
+
xt_value options = xt_arg(argc, argv, 2);
|
|
162
|
+
const char *name = XT_IS_STRING(type) ? xt_string_data(type) : NULL;
|
|
163
|
+
if (!name || strcmp(name, "abort") != 0) return XT_UNDEFINED;
|
|
164
|
+
if (!XT_IS_FUNCTION(listener)) return XT_UNDEFINED;
|
|
165
|
+
/* Registering after the signal aborted never fires (same as the platform). */
|
|
166
|
+
if (xt_web_signal_is_aborted(thisValue)) return XT_UNDEFINED;
|
|
167
|
+
int once = 0;
|
|
168
|
+
if (XT_IS_OBJECT(options)) once = xt_truthy(xt_object_get_cstr(options, "once"));
|
|
169
|
+
xt_value entry = xt_object_new();
|
|
170
|
+
xt_object_set(entry, xt_string_from_cstr("fn"), listener);
|
|
171
|
+
xt_object_set(entry, xt_string_from_cstr("once"), once ? XT_TRUE : XT_FALSE);
|
|
172
|
+
xt_array_push(xt_web_signal_listeners(thisValue), entry);
|
|
173
|
+
return XT_UNDEFINED;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static xt_value xt_web_signal_remove_listener(xt_value thisValue, xt_value env, int32_t argc,
|
|
177
|
+
xt_value *argv) {
|
|
178
|
+
(void)env;
|
|
179
|
+
xt_value type = xt_arg(argc, argv, 0);
|
|
180
|
+
xt_value listener = xt_arg(argc, argv, 1);
|
|
181
|
+
const char *name = XT_IS_STRING(type) ? xt_string_data(type) : NULL;
|
|
182
|
+
if (!name || strcmp(name, "abort") != 0 || !XT_IS_FUNCTION(listener)) return XT_UNDEFINED;
|
|
183
|
+
xt_value listeners = xt_web_signal_listeners(thisValue);
|
|
184
|
+
int32_t count = xt_web_count(listeners);
|
|
185
|
+
int32_t remaining = 0;
|
|
186
|
+
for (int32_t index = 0; index < count; index++) {
|
|
187
|
+
xt_value entry = xt_array_get(listeners, xt_number((double)index));
|
|
188
|
+
xt_value fn = XT_IS_OBJECT(entry) ? xt_object_get_cstr(entry, "fn") : XT_UNDEFINED;
|
|
189
|
+
if (fn == listener) continue;
|
|
190
|
+
if (remaining != index) xt_array_set(listeners, xt_number((double)remaining), entry);
|
|
191
|
+
remaining++;
|
|
192
|
+
}
|
|
193
|
+
xt_as_array(listeners)->length = remaining;
|
|
194
|
+
return XT_UNDEFINED;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static xt_value xt_web_signal_throw_if_aborted(xt_value thisValue, xt_value env, int32_t argc,
|
|
198
|
+
xt_value *argv) {
|
|
199
|
+
(void)env;
|
|
200
|
+
(void)argc;
|
|
201
|
+
(void)argv;
|
|
202
|
+
if (!xt_web_signal_is_aborted(thisValue)) return XT_UNDEFINED;
|
|
203
|
+
xt_throw(xt_object_get_cstr(thisValue, "__reason"));
|
|
204
|
+
return XT_UNDEFINED;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static xt_value xt_web_signal_get_aborted(xt_value thisValue, xt_value env, int32_t argc,
|
|
208
|
+
xt_value *argv) {
|
|
209
|
+
(void)env;
|
|
210
|
+
(void)argc;
|
|
211
|
+
(void)argv;
|
|
212
|
+
return xt_web_signal_is_aborted(thisValue) ? XT_TRUE : XT_FALSE;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static xt_value xt_web_signal_get_reason(xt_value thisValue, xt_value env, int32_t argc,
|
|
216
|
+
xt_value *argv) {
|
|
217
|
+
(void)env;
|
|
218
|
+
(void)argc;
|
|
219
|
+
(void)argv;
|
|
220
|
+
return xt_object_get_cstr(thisValue, "__reason");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
static xt_value xt_web_signal_get_onabort(xt_value thisValue, xt_value env, int32_t argc,
|
|
224
|
+
xt_value *argv) {
|
|
225
|
+
(void)env;
|
|
226
|
+
(void)argc;
|
|
227
|
+
(void)argv;
|
|
228
|
+
return xt_object_get_cstr(thisValue, "__onabort");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
static xt_value xt_web_signal_set_onabort(xt_value thisValue, xt_value env, int32_t argc,
|
|
232
|
+
xt_value *argv) {
|
|
233
|
+
(void)env;
|
|
234
|
+
xt_value handler = xt_arg(argc, argv, 0);
|
|
235
|
+
if (!XT_IS_FUNCTION(handler) && handler != XT_NULL && handler != XT_UNDEFINED) return XT_UNDEFINED;
|
|
236
|
+
xt_object_set(thisValue, xt_string_from_cstr("__onabort"),
|
|
237
|
+
XT_IS_FUNCTION(handler) ? handler : XT_UNDEFINED);
|
|
238
|
+
return XT_UNDEFINED;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* -- AbortController methods ---------------------------------------------- */
|
|
242
|
+
|
|
243
|
+
static xt_value xt_web_controller_abort(xt_value thisValue, xt_value env, int32_t argc,
|
|
244
|
+
xt_value *argv) {
|
|
245
|
+
(void)env;
|
|
246
|
+
xt_value signal = xt_object_get_cstr(thisValue, "signal");
|
|
247
|
+
if (!XT_IS_OBJECT(signal)) return XT_UNDEFINED;
|
|
248
|
+
xt_value reason = xt_arg(argc, argv, 0);
|
|
249
|
+
if (reason == XT_UNDEFINED) reason = xt_web_abort_reason_default();
|
|
250
|
+
xt_web_signal_abort(signal, reason);
|
|
251
|
+
return XT_UNDEFINED;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* -- prototypes ----------------------------------------------------------- */
|
|
255
|
+
|
|
256
|
+
xt_value xt_web_abort_signal_proto(void) {
|
|
257
|
+
if (xt_web_abort_signal_proto_value != XT_UNDEFINED) return xt_web_abort_signal_proto_value;
|
|
258
|
+
xt_value proto = xt_object_new();
|
|
259
|
+
xt_web_abort_signal_proto_value = proto;
|
|
260
|
+
xt_gc_add_root(&xt_web_abort_signal_proto_value);
|
|
261
|
+
xt_web_abort_define(proto, "addEventListener", xt_web_signal_add_listener, 2);
|
|
262
|
+
xt_web_abort_define(proto, "removeEventListener", xt_web_signal_remove_listener, 2);
|
|
263
|
+
xt_web_abort_define(proto, "throwIfAborted", xt_web_signal_throw_if_aborted, 0);
|
|
264
|
+
xt_web_abort_define_accessor(proto, "aborted", xt_web_signal_get_aborted, NULL);
|
|
265
|
+
xt_web_abort_define_accessor(proto, "reason", xt_web_signal_get_reason, NULL);
|
|
266
|
+
xt_web_abort_define_accessor(proto, "onabort", xt_web_signal_get_onabort,
|
|
267
|
+
xt_web_signal_set_onabort);
|
|
268
|
+
return proto;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
xt_value xt_web_abort_controller_proto(void) {
|
|
272
|
+
if (xt_web_abort_controller_proto_value != XT_UNDEFINED) {
|
|
273
|
+
return xt_web_abort_controller_proto_value;
|
|
274
|
+
}
|
|
275
|
+
xt_value proto = xt_object_new();
|
|
276
|
+
xt_web_abort_controller_proto_value = proto;
|
|
277
|
+
xt_gc_add_root(&xt_web_abort_controller_proto_value);
|
|
278
|
+
xt_web_abort_define(proto, "abort", xt_web_controller_abort, 1);
|
|
279
|
+
return proto;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* -- constructors --------------------------------------------------------- */
|
|
283
|
+
|
|
284
|
+
xt_value xt_abort_signal_ctor(int32_t argc, xt_value *argv) {
|
|
285
|
+
(void)argc;
|
|
286
|
+
(void)argv;
|
|
287
|
+
/* `new AbortSignal()` is illegal in the platform API. */
|
|
288
|
+
xt_throw(xt_error_from_message("TypeError: Illegal constructor"));
|
|
289
|
+
return XT_UNDEFINED;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
xt_value xt_abort_controller_ctor(int32_t argc, xt_value *argv) {
|
|
293
|
+
(void)argc;
|
|
294
|
+
(void)argv;
|
|
295
|
+
xt_value controller = xt_object_new();
|
|
296
|
+
xt_object_set_prototype(controller, xt_web_abort_controller_proto());
|
|
297
|
+
xt_object_set(controller, xt_string_from_cstr("signal"), xt_web_signal_new());
|
|
298
|
+
return controller;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* -- statics -------------------------------------------------------------- */
|
|
302
|
+
|
|
303
|
+
static xt_value xt_web_signal_aborted(int32_t argc, xt_value *argv) {
|
|
304
|
+
xt_value signal = xt_web_signal_new();
|
|
305
|
+
xt_value reason = xt_arg(argc, argv, 0);
|
|
306
|
+
if (reason == XT_UNDEFINED) reason = xt_web_abort_reason_default();
|
|
307
|
+
xt_web_signal_abort(signal, reason);
|
|
308
|
+
return signal;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
static xt_value xt_web_signal_timeout(int32_t argc, xt_value *argv) {
|
|
312
|
+
double milliseconds = xt_to_number(xt_arg(argc, argv, 0));
|
|
313
|
+
if (!(milliseconds >= 0)) milliseconds = 0;
|
|
314
|
+
xt_value signal = xt_web_signal_new();
|
|
315
|
+
xt_value environment[1] = {signal};
|
|
316
|
+
xt_value callback = xt_closure_new((void *)xt_web_timeout_fire, 1, environment);
|
|
317
|
+
xt_value arguments[2] = {callback, xt_number(milliseconds)};
|
|
318
|
+
xt_value handle = xt_set_timeout(2, arguments);
|
|
319
|
+
xt_object_set(signal, xt_string_from_cstr("__timer"), handle);
|
|
320
|
+
return signal;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
static xt_value xt_web_timeout_fire(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
324
|
+
(void)thisValue;
|
|
325
|
+
(void)argc;
|
|
326
|
+
(void)argv;
|
|
327
|
+
xt_value signal = xt_closure_env(env, 0);
|
|
328
|
+
xt_web_signal_abort(signal, xt_web_timeout_reason());
|
|
329
|
+
return XT_UNDEFINED;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* `AbortSignal.any(signals)`: abort with the first input's reason. */
|
|
333
|
+
static xt_value xt_web_signal_any(int32_t argc, xt_value *argv) {
|
|
334
|
+
xt_value inputs = xt_arg(argc, argv, 0);
|
|
335
|
+
xt_value combined = xt_web_signal_new();
|
|
336
|
+
if (!XT_IS_ARRAY(inputs)) return combined;
|
|
337
|
+
int32_t count = xt_web_count(inputs);
|
|
338
|
+
for (int32_t index = 0; index < count; index++) {
|
|
339
|
+
xt_value input = xt_array_get(inputs, xt_number((double)index));
|
|
340
|
+
if (!XT_IS_OBJECT(input)) continue;
|
|
341
|
+
if (xt_web_signal_is_aborted(input)) {
|
|
342
|
+
xt_web_signal_abort(combined, xt_object_get_cstr(input, "__reason"));
|
|
343
|
+
return combined;
|
|
344
|
+
}
|
|
345
|
+
xt_value environment[2] = {combined, input};
|
|
346
|
+
xt_value closure = xt_closure_new((void *)xt_web_chain_fire, 2, environment);
|
|
347
|
+
xt_value entry = xt_object_new();
|
|
348
|
+
xt_object_set(entry, xt_string_from_cstr("fn"), closure);
|
|
349
|
+
xt_object_set(entry, xt_string_from_cstr("once"), XT_TRUE);
|
|
350
|
+
xt_array_push(xt_web_signal_listeners(input), entry);
|
|
351
|
+
}
|
|
352
|
+
return combined;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
static xt_value xt_web_chain_fire(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
356
|
+
(void)thisValue;
|
|
357
|
+
(void)argc;
|
|
358
|
+
(void)argv;
|
|
359
|
+
xt_value combined = xt_closure_env(env, 0);
|
|
360
|
+
xt_value input = xt_closure_env(env, 1);
|
|
361
|
+
xt_web_signal_abort(combined, xt_object_get_cstr(input, "__reason"));
|
|
362
|
+
return XT_UNDEFINED;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/* `AbortSignal.<method>(...)`: the code generator's static dispatcher. */
|
|
366
|
+
xt_value xt_abort_signal_static(xt_value method, int32_t argc, xt_value *argv) {
|
|
367
|
+
const char *name = XT_IS_STRING(method) ? xt_string_data(method) : NULL;
|
|
368
|
+
if (!name) return XT_UNDEFINED;
|
|
369
|
+
if (strcmp(name, "abort") == 0) return xt_web_signal_aborted(argc, argv);
|
|
370
|
+
if (strcmp(name, "timeout") == 0) return xt_web_signal_timeout(argc, argv);
|
|
371
|
+
if (strcmp(name, "any") == 0) return xt_web_signal_any(argc, argv);
|
|
372
|
+
return XT_UNDEFINED;
|
|
373
|
+
}
|
package/scripts/build-runtime.ts
CHANGED
|
@@ -26,9 +26,11 @@ import { basename, dirname, join, resolve } from "node:path";
|
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
27
27
|
import { RUNTIME_SOURCES } from "../src/driver/compiler.js";
|
|
28
28
|
import { platformSlug } from "../src/driver/paths.js";
|
|
29
|
+
import { runtimeSourceFingerprint, writeRuntimeStamp } from "../src/driver/runtime-lib.js";
|
|
29
30
|
import { applyMacosDeploymentTarget } from "../src/driver/platform-support.js";
|
|
30
31
|
import { resolveToolchain } from "../src/driver/toolchain-provider.js";
|
|
31
32
|
import { RUNTIME_CFLAGS, sysrootFlags } from "../src/driver/toolchain.js";
|
|
33
|
+
import { COMPILER_VERSION } from "../src/driver/version.js";
|
|
32
34
|
import { nodeExtension } from "../src/extensions/node/index.js";
|
|
33
35
|
|
|
34
36
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
@@ -117,3 +119,9 @@ const nodeSources = nodeExtension.runtimeSources?.() ?? [];
|
|
|
117
119
|
if (nodeSources.length > 0) {
|
|
118
120
|
archive(`ext_node${archiveSuffix}`, compile(nodeSources, "node"), ar);
|
|
119
121
|
}
|
|
122
|
+
|
|
123
|
+
/* Record which sources these archives came from: the driver only links them
|
|
124
|
+
* while the runtime sources on disk still match, and otherwise compiles from
|
|
125
|
+
* source (a stale archive would silently run an old runtime). */
|
|
126
|
+
writeRuntimeStamp(outDir, runtimeSourceFingerprint(runtimeDir, COMPILER_VERSION, RUNTIME_CFLAGS), COMPILER_VERSION);
|
|
127
|
+
console.log(`xbintsc: stamped ${join(outDir, "runtime-stamp.json")}`);
|
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
|
}
|
|
@@ -92,6 +92,7 @@ export interface DeclarationMethods {
|
|
|
92
92
|
predeclareVariableList(this: Binder, list: VariableDeclarationList, scope: Scope): void;
|
|
93
93
|
predeclareImport(this: Binder, node: ImportDeclaration, scope: Scope): void;
|
|
94
94
|
collectFunctionScoped(this: Binder, statements: readonly Statement[], fn: MutableFunction): void;
|
|
95
|
+
reuseHoistedVar(this: Binder, name: BindingName, scope: Scope): boolean;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
export const declarationMethods: DeclarationMethods = {
|
|
@@ -215,10 +216,43 @@ export const declarationMethods: DeclarationMethods = {
|
|
|
215
216
|
? SymbolKind.Var
|
|
216
217
|
: SymbolKind.Let;
|
|
217
218
|
for (const declaration of list.declarations) {
|
|
219
|
+
if (kind === SymbolKind.Var) {
|
|
220
|
+
if (this.reuseHoistedVar(declaration.name, scope)) continue;
|
|
221
|
+
/* `var` is function scoped even when the declaration sits in a block
|
|
222
|
+
* or in a `for` head, so it always lands in the function scope. */
|
|
223
|
+
this.declareBinding(declaration.name, kind, declaration, scope.fn.scope ?? scope, true);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
218
226
|
this.declareBinding(declaration.name, kind, declaration, scope, kind !== SymbolKind.Const);
|
|
219
227
|
}
|
|
220
228
|
},
|
|
221
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Point a `var` declaration that sits in a nested block (or in a `for` head)
|
|
232
|
+
* at the symbol `collectFunctionScoped` already hoisted into the function
|
|
233
|
+
* scope. Declaring it again in the block would *shadow* the hoisted name, so
|
|
234
|
+
* `{ var x = 1 }` would write a block-local `x` the rest of the function
|
|
235
|
+
* never sees — the bug behind `if (c) { var label = "big" }` losing its
|
|
236
|
+
* value in minified bundles.
|
|
237
|
+
*/
|
|
238
|
+
reuseHoistedVar(name: BindingName, scope: Scope): boolean {
|
|
239
|
+
const functionScope = scope.fn.scope;
|
|
240
|
+
if (functionScope === undefined || scope === functionScope) return false;
|
|
241
|
+
if (name.kind === SyntaxKind.Identifier) {
|
|
242
|
+
const hoisted = functionScope.symbols.get(name.text);
|
|
243
|
+
if (!hoisted || hoisted.kind !== SymbolKind.Var) return false;
|
|
244
|
+
this.symbolOfDeclaration.set(name, hoisted);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
const pattern = name as ArrayBindingPattern | ObjectBindingPattern;
|
|
248
|
+
let reused = true;
|
|
249
|
+
for (const element of pattern.elements) {
|
|
250
|
+
if (!element) continue;
|
|
251
|
+
if (!this.reuseHoistedVar(element.name, scope)) reused = false;
|
|
252
|
+
}
|
|
253
|
+
return reused;
|
|
254
|
+
},
|
|
255
|
+
|
|
222
256
|
predeclareImport(node: ImportDeclaration, scope: Scope): void {
|
|
223
257
|
const clause = node.importClause;
|
|
224
258
|
if (!clause) return;
|
package/src/binder/references.ts
CHANGED
|
@@ -339,6 +339,12 @@ export const referenceMethods: ReferenceMethods = {
|
|
|
339
339
|
const paramSymbol = this.declareBinding(parameter.name, SymbolKind.Parameter, parameter, scope, true);
|
|
340
340
|
if (paramSymbol) params.push(paramSymbol);
|
|
341
341
|
if (parameter.initializer) this.bindNode(parameter.initializer, scope);
|
|
342
|
+
/* A destructuring parameter binds its names through `declareBinding`
|
|
343
|
+
* above, but the *default values* inside the pattern are expressions:
|
|
344
|
+
* `({ noNewArrows = !(e => e) })` contains an arrow that has to get a
|
|
345
|
+
* FunctionInfo of its own, or codegen reports "does not yet support this
|
|
346
|
+
* closure". */
|
|
347
|
+
this.bindBindingPattern(parameter.name, scope);
|
|
342
348
|
}
|
|
343
349
|
(fn as { params: SymbolInfo[] }).params = params;
|
|
344
350
|
|
|
@@ -402,6 +408,12 @@ export const referenceMethods: ReferenceMethods = {
|
|
|
402
408
|
|
|
403
409
|
const classScope = this.createScope(ScopeKind.Block, node, scope);
|
|
404
410
|
this.scopes.set(node, classScope);
|
|
411
|
+
/* A class *expression* binds its own name inside the class body only: the
|
|
412
|
+
* enclosing scope never sees it (`const A = class Inner { m() { return Inner } }`).
|
|
413
|
+
* A declaration's name already lives in the enclosing scope. */
|
|
414
|
+
if (node.kind === SyntaxKind.ClassExpression && node.name && !classScope.symbols.has(node.name.text)) {
|
|
415
|
+
this.declare(node.name.text, SymbolKind.Class, node, classScope, false);
|
|
416
|
+
}
|
|
405
417
|
|
|
406
418
|
let constructor: FunctionInfo | undefined;
|
|
407
419
|
/* `static { ... }` functions, so the field pass below can interleave them
|
package/src/checker/globals.ts
CHANGED
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
|
}
|
|
@@ -68,7 +68,10 @@ type TypeDeclaration =
|
|
|
68
68
|
|
|
69
69
|
/** Resolve type syntax and symbol annotations into the small model above. */
|
|
70
70
|
export class TypeResolver {
|
|
71
|
+
/** Module-scope declarations, visible from every file in the bundle. */
|
|
71
72
|
private readonly declarations = new Map<string, TypeDeclaration | undefined>();
|
|
73
|
+
/** Declarations nested inside a function body, visible only in their file. */
|
|
74
|
+
private readonly localDeclarations = new Map<string, Map<string, TypeDeclaration | undefined>>();
|
|
72
75
|
private readonly symbolTypes = new Map<number, Type>();
|
|
73
76
|
private readonly resolvingSymbols = new Set<number>();
|
|
74
77
|
private readonly resolvingAliases = new Set<string>();
|
|
@@ -116,11 +119,28 @@ export class TypeResolver {
|
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
private addDeclaration(name: string, declaration: TypeDeclaration): void {
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
/* A class declared inside a function body is scoped to that function: a
|
|
123
|
+
* bundled dependency is full of them (`babel.cjs` has its own `class
|
|
124
|
+
* Token`), and treating those as program-wide would hijack a type the
|
|
125
|
+
* importing file meant (`import type { Token } from "marked"`). */
|
|
126
|
+
const symbol = this.binding.symbolOfDeclaration.get(declaration.node);
|
|
127
|
+
if (symbol && !symbol.fn.isModule) {
|
|
128
|
+
const file = this.sourceFile.origins?.get(declaration.node) ?? this.sourceFile.fileName;
|
|
129
|
+
const local = this.localDeclarations.get(file) ?? new Map<string, TypeDeclaration | undefined>();
|
|
130
|
+
this.localDeclarations.set(file, local);
|
|
131
|
+
local.set(name, local.has(name) ? undefined : declaration);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// A duplicate means bundling made the name ambiguous; `any` is the only safe answer.
|
|
121
135
|
this.declarations.set(name, this.declarations.has(name) ? undefined : declaration);
|
|
122
136
|
}
|
|
123
137
|
|
|
138
|
+
/** The declaration a type reference in `node` names, if one is in scope. */
|
|
139
|
+
private declarationFor(name: string, node: Node): TypeDeclaration | undefined {
|
|
140
|
+
const file = this.sourceFile.origins?.get(node) ?? this.sourceFile.fileName;
|
|
141
|
+
return this.localDeclarations.get(file)?.get(name) ?? this.declarations.get(name);
|
|
142
|
+
}
|
|
143
|
+
|
|
124
144
|
private collectDynamicClasses(): void {
|
|
125
145
|
walk(this.sourceFile, (node) => {
|
|
126
146
|
if (node.kind === SyntaxKind.BinaryExpression) {
|
|
@@ -334,7 +354,7 @@ export class TypeResolver {
|
|
|
334
354
|
if (typeParams.has(name)) return typeParams.get(name)!;
|
|
335
355
|
const builtin = this.builtinType(name, node.typeArguments.map((argument) => this.resolve(argument, typeParams)));
|
|
336
356
|
if (builtin) return builtin;
|
|
337
|
-
const declaration = this.
|
|
357
|
+
const declaration = this.declarationFor(name, node);
|
|
338
358
|
if (!declaration) return { kind: "typeParam", name };
|
|
339
359
|
if (declaration.kind === "interface") return this.interfaceType(declaration.node, node.typeArguments.map((argument) => this.resolve(argument, typeParams)));
|
|
340
360
|
if (declaration.kind === "alias") return this.aliasType(declaration.node, node.typeArguments.map((argument) => this.resolve(argument, typeParams)));
|
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}`);
|
|
@@ -16,6 +16,7 @@ import { i64, numberLiteral, XT_TRUE, XT_UNDEFINED } from "../../values.js";
|
|
|
16
16
|
import { MATH_CONSTANTS, NAMESPACE_PROPERTIES, NUMBER_CONSTANTS, SYMBOL_WELL_KNOWN, TYPED_ARRAYS } from "../tables.js";
|
|
17
17
|
import { isSuperKeyword } from "./super.js";
|
|
18
18
|
import type { Generator } from "../generator.js";
|
|
19
|
+
import { globalObjectReceiver } from "./unwrap.js";
|
|
19
20
|
|
|
20
21
|
export interface AccessCallMethods {
|
|
21
22
|
emitDelete(this: Generator, node: DeleteExpression): string;
|
|
@@ -58,6 +59,28 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
58
59
|
this.emit(` ${value} = call i64 @xt_get(i64 ${parentProto}, i64 ${key})`);
|
|
59
60
|
return value;
|
|
60
61
|
}
|
|
62
|
+
/* `globalThis.fetch` / `global.Deno`: the global object *is* the global
|
|
63
|
+
* scope, so a *known* global reads as the bare global name. Without this the
|
|
64
|
+
* receiver would be the global bag and every feature probe
|
|
65
|
+
* (`globalThis.Deno ? ... : ...`) would miss the real global. `global` is
|
|
66
|
+
* Node's alias for the same object. Parentheses and `as`/`!` wrappers are
|
|
67
|
+
* transparent here.
|
|
68
|
+
*
|
|
69
|
+
* A name the compiler does not know is an ordinary property read on the
|
|
70
|
+
* global bag instead: `global.gracefulQueue = q` stores there, so
|
|
71
|
+
* `global.gracefulQueue` must read it back (libraries publish state on
|
|
72
|
+
* `global` this way). */
|
|
73
|
+
{
|
|
74
|
+
const receiver = globalObjectReceiver(node.expression);
|
|
75
|
+
if (receiver && !this.binding.symbolOfIdentifier.get(receiver)) {
|
|
76
|
+
/* `globalThis.require` is how bundled CommonJS detects the loader. It is
|
|
77
|
+
* a probe, not a use: an absent global property reads as `undefined`.
|
|
78
|
+
* Only invoking it (`globalThis.require("x")`) is a CommonJS call, and
|
|
79
|
+
* the invocation path reports that. */
|
|
80
|
+
if (node.name.text === "require") return i64(XT_UNDEFINED);
|
|
81
|
+
if (this.globalTypeOf(node.name.text) !== undefined) return this.emitIdentifier(node.name);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
61
84
|
if (
|
|
62
85
|
node.name.text in MATH_CONSTANTS &&
|
|
63
86
|
node.expression.kind === SyntaxKind.Identifier &&
|
|
@@ -143,19 +166,13 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
143
166
|
* inside a `static` method), not from the `super` keyword itself. */
|
|
144
167
|
const isSuper = isSuperKeyword(node.expression);
|
|
145
168
|
const object = isSuper ? this.emitSuperHolder() : this.emitExpression(node.expression);
|
|
146
|
-
|
|
169
|
+
if (isSuper) {
|
|
147
170
|
const key = this.emitExpression(node.argumentExpression);
|
|
148
171
|
const result = this.reg();
|
|
149
|
-
|
|
150
|
-
* a numeric literal; every other key may benefit from it. */
|
|
151
|
-
if (isSuper || node.argumentExpression.kind === SyntaxKind.NumericLiteral) {
|
|
152
|
-
this.emit(` ${result} = call i64 @xt_get(i64 ${object}, i64 ${key})`);
|
|
153
|
-
} else {
|
|
154
|
-
const cache = this.icCachePointer();
|
|
155
|
-
this.emit(` ${result} = call i64 @xt_get_ic(i64 ${object}, i64 ${key}, i64* ${cache})`);
|
|
156
|
-
}
|
|
172
|
+
this.emit(` ${result} = call i64 @xt_get(i64 ${object}, i64 ${key})`);
|
|
157
173
|
return result;
|
|
158
|
-
}
|
|
174
|
+
}
|
|
175
|
+
const access = (): string => this.emitElementRead(object, this.emitExpression(node.argumentExpression));
|
|
159
176
|
return node.optional ? this.emitOptional(object, access) : access();
|
|
160
177
|
},
|
|
161
178
|
|
|
@@ -321,3 +338,4 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
321
338
|
return merged;
|
|
322
339
|
},
|
|
323
340
|
};
|
|
341
|
+
|