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
|
@@ -113,6 +113,7 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
113
113
|
"declare i64 @xt_arg(i32, i64*, i32)",
|
|
114
114
|
"declare i64 @xt_closure_new(i8*, i32, i64*)",
|
|
115
115
|
"declare i64 @xt_fnptr_trampoline(i64, i64, i32, i64*)",
|
|
116
|
+
"declare i64 @xt_voidptr_trampoline(i64, i64, i32, i64*)",
|
|
116
117
|
"declare i64 @xt_method_trampoline(i64, i64, i32, i64*)",
|
|
117
118
|
"declare i64 @xt_function_set_metadata(i64, i64, i32)",
|
|
118
119
|
"declare i64 @xt_function_set_generator(i64)",
|
|
@@ -125,6 +126,10 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
125
126
|
"declare i64 @xt_call_with_this(i64, i64, i32, i64*)",
|
|
126
127
|
"declare i64 @xt_this()",
|
|
127
128
|
"declare i64 @xt_new(i64, i32, i64*)",
|
|
129
|
+
"declare i64 @xt_new_named(i64, i64, i32, i64*)",
|
|
130
|
+
"declare i64 @xt_super_construct(i64, i64, i64, i32, i64*)",
|
|
131
|
+
"declare i64 @xt_parent_prototype(i64)",
|
|
132
|
+
"declare i64 @xt_global_object()",
|
|
128
133
|
"declare i64 @xt_instance_of(i64, i64)",
|
|
129
134
|
"declare i64 @xt_instance_of_builtin(i64, i32)",
|
|
130
135
|
"declare i64 @xt_builtin_constructor(i64)",
|
|
@@ -140,9 +145,12 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
140
145
|
"declare i64 @xt_await(i64)",
|
|
141
146
|
"declare void @xt_drain_microtasks()",
|
|
142
147
|
"declare void @xt_run_event_loop()",
|
|
148
|
+
"declare i32 @xt_finish()",
|
|
143
149
|
"declare void @xt_gc_init()",
|
|
144
150
|
"declare void @xt_gc_set_stack_base(i8*)",
|
|
145
151
|
"declare void @xt_gc_arm()",
|
|
152
|
+
"declare void @xt_gc_begin_startup()",
|
|
153
|
+
"declare void @xt_gc_end_startup()",
|
|
146
154
|
"declare void @xt_gc_add_root(i64*)",
|
|
147
155
|
"declare i64 @xt_promise_resolve(i64)",
|
|
148
156
|
"declare i64 @xt_promise_reject(i64)",
|
|
@@ -158,6 +166,7 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
158
166
|
"declare i64 @xt_crypto_get(i64)",
|
|
159
167
|
"declare i64 @xt_webassembly_static(i64, i32, i64*)",
|
|
160
168
|
"declare i64 @xt_webassembly_object(i32, i64*)",
|
|
169
|
+
"declare i64 @xt_intl_object(i32, i64*)",
|
|
161
170
|
"declare i64 @xt_path_static(i64, i32, i64*)",
|
|
162
171
|
"declare i64 @xt_os_static(i64, i32, i64*)",
|
|
163
172
|
"declare i64 @xt_buffer_static(i64, i32, i64*)",
|
|
@@ -214,6 +223,13 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
214
223
|
"declare i64 @xt_byte_length_queuing_strategy_ctor(i32, i64*)",
|
|
215
224
|
"declare i64 @xt_text_encoder_stream_ctor(i32, i64*)",
|
|
216
225
|
"declare i64 @xt_text_decoder_stream_ctor(i32, i64*)",
|
|
226
|
+
"declare i64 @xt_abort_controller_ctor(i32, i64*)",
|
|
227
|
+
"declare i64 @xt_abort_signal_ctor(i32, i64*)",
|
|
228
|
+
"declare i64 @xt_abort_signal_static(i64, i32, i64*)",
|
|
229
|
+
"declare i64 @xt_headers_ctor(i32, i64*)",
|
|
230
|
+
"declare i64 @xt_proxy_ctor(i32, i64*)",
|
|
231
|
+
"declare i64 @xt_response_ctor(i32, i64*)",
|
|
232
|
+
"declare i64 @xt_defer_module(i32, i64*)",
|
|
217
233
|
"declare i64 @xt_date_ctor(i32, i64*)",
|
|
218
234
|
"declare i64 @xt_regexp_ctor(i32, i64*)",
|
|
219
235
|
"declare i64 @xt_url_ctor(i32, i64*)",
|
|
@@ -359,6 +375,9 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
359
375
|
"declare i64 @xt_symbol_static(i64, i32, i64*)",
|
|
360
376
|
"declare i64 @xt_symbol_get(i64)",
|
|
361
377
|
"declare i64 @xt_get(i64, i64)",
|
|
378
|
+
"declare i64 @xt_get_element(i64, i64, i64*)",
|
|
379
|
+
"declare i64 @xt_set_element(i64, i64, i64)",
|
|
380
|
+
"declare double @llvm.trunc.f64(double)",
|
|
362
381
|
"declare i64 @xt_get_ic(i64, i64, i64*)",
|
|
363
382
|
"declare i64 @xt_set(i64, i64, i64)",
|
|
364
383
|
"declare i64 @xt_box_new(i64)",
|
|
@@ -372,10 +391,13 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
372
391
|
"declare i64 @xt_try_exception(i8*)",
|
|
373
392
|
"declare void @xt_try_leave(i8*)",
|
|
374
393
|
"declare void @xt_stack_push(i8*, i8*, i32)",
|
|
394
|
+
"declare void @xt_stack_set_module(i8*)",
|
|
375
395
|
"declare void @xt_stack_pop()",
|
|
376
396
|
"declare void @xt_stack_set_line(i32)",
|
|
377
397
|
"declare void @xt_console_log(i32, i64*)",
|
|
378
398
|
"declare void @xt_console_info(i32, i64*)",
|
|
379
399
|
"declare void @xt_console_warn(i32, i64*)",
|
|
380
400
|
"declare void @xt_console_error(i32, i64*)",
|
|
401
|
+
"declare i64 @xt_console_object(i32, i64*)",
|
|
381
402
|
];
|
|
403
|
+
|
|
@@ -166,6 +166,7 @@ export const GLOBAL_FUNCTIONS: Record<string, string> = {
|
|
|
166
166
|
queueMicrotask: "xt_queue_microtask",
|
|
167
167
|
structuredClone: "xt_structured_clone",
|
|
168
168
|
fetch: "xt_fetch",
|
|
169
|
+
__xt_defer: "xt_defer_module",
|
|
169
170
|
Number: "xt_number_ctor",
|
|
170
171
|
String: "xt_string_ctor",
|
|
171
172
|
Boolean: "xt_boolean_ctor",
|
|
@@ -263,6 +264,7 @@ export const NAMESPACE_STATICS: Record<string, string> = {
|
|
|
263
264
|
Duplex: "xt_stream_static",
|
|
264
265
|
Transform: "xt_stream_static",
|
|
265
266
|
PassThrough: "xt_stream_static",
|
|
267
|
+
AbortSignal: "xt_abort_signal_static",
|
|
266
268
|
net: "xt_net_static",
|
|
267
269
|
dgram: "xt_dgram_static",
|
|
268
270
|
http: "xt_http_static",
|
|
@@ -294,28 +296,20 @@ export const SYMBOL_WELL_KNOWN = new Set<string>([
|
|
|
294
296
|
/** Namespaces that also exist as a first-class object value (`Math.cos`). */
|
|
295
297
|
export const NAMESPACE_VALUES: Record<string, string> = {
|
|
296
298
|
Math: "xt_math_object",
|
|
299
|
+
JSON: "xt_json_object",
|
|
297
300
|
crypto: "xt_crypto_object",
|
|
298
301
|
WebAssembly: "xt_webassembly_object",
|
|
302
|
+
Intl: "xt_intl_object",
|
|
299
303
|
};
|
|
300
304
|
|
|
301
|
-
/**
|
|
302
|
-
*
|
|
303
|
-
* type-checks, but with no runtime implementation yet: they lower to
|
|
304
|
-
* `undefined`. A construct such as `new AbortController()` therefore fails at
|
|
305
|
-
* run time rather than being reported as an unknown name.
|
|
306
|
-
*/
|
|
305
|
+
/** Web-platform globals recognized for type checking but not implemented: they
|
|
306
|
+
* lower to `undefined` and fail at run time, not as an unknown name. */
|
|
307
307
|
export const WEB_GLOBALS: ReadonlySet<string> = new Set<string>([
|
|
308
308
|
"globalThis",
|
|
309
|
-
"AbortController",
|
|
310
|
-
"AbortSignal",
|
|
311
309
|
"Reflect",
|
|
312
|
-
"Proxy",
|
|
313
|
-
"Intl",
|
|
314
310
|
"FormData",
|
|
315
311
|
"Blob",
|
|
316
|
-
"Headers",
|
|
317
312
|
"Request",
|
|
318
|
-
"Response",
|
|
319
313
|
"EventTarget",
|
|
320
314
|
]);
|
|
321
315
|
|
|
@@ -362,6 +356,11 @@ export const CTOR_FUNCTIONS: Record<string, string> = {
|
|
|
362
356
|
TextDecoderStream: "xt_text_decoder_stream_ctor",
|
|
363
357
|
ArrayBuffer: "xt_array_buffer_ctor",
|
|
364
358
|
DataView: "xt_data_view_ctor",
|
|
359
|
+
AbortController: "xt_abort_controller_ctor",
|
|
360
|
+
AbortSignal: "xt_abort_signal_ctor",
|
|
361
|
+
Headers: "xt_headers_ctor",
|
|
362
|
+
Response: "xt_response_ctor",
|
|
363
|
+
Proxy: "xt_proxy_ctor",
|
|
365
364
|
...ERROR_CONSTRUCTORS,
|
|
366
365
|
...TYPED_ARRAY_CTORS,
|
|
367
366
|
};
|
|
@@ -399,6 +398,13 @@ export const FIRST_CLASS_CONSTRUCTORS = new Set<string>([
|
|
|
399
398
|
"ByteLengthQueuingStrategy",
|
|
400
399
|
"TextEncoderStream",
|
|
401
400
|
"TextDecoderStream",
|
|
401
|
+
"AbortController",
|
|
402
|
+
"AbortSignal",
|
|
403
|
+
"Headers",
|
|
404
|
+
"Response",
|
|
405
|
+
"ArrayBuffer",
|
|
406
|
+
"DataView",
|
|
407
|
+
"Proxy",
|
|
402
408
|
]);
|
|
403
409
|
|
|
404
410
|
export const BUILTIN_METHODS = new Set<string>([
|
|
@@ -120,7 +120,7 @@ export function formatDiagnostic(d: Diagnostic, source?: SourceFile): string {
|
|
|
120
120
|
if (source && d.start !== undefined) {
|
|
121
121
|
const { line, column } = source.positionAt(d.start);
|
|
122
122
|
location = `${source.fileName}:${line}:${column}`;
|
|
123
|
-
const lineText = source.
|
|
123
|
+
const lineText = source.lineText(line);
|
|
124
124
|
const end = d.end ?? d.start;
|
|
125
125
|
const endCol = source.positionAt(end).column;
|
|
126
126
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source text is a byte sequence.
|
|
2
|
+
* Source text is a byte sequence, one code unit per UTF-8 byte.
|
|
3
3
|
*
|
|
4
4
|
* A compiled string is a sequence of UTF-8 bytes (`"e".length` is 1 for an
|
|
5
5
|
* accent and 4 for an emoji - see doc/ai/language-support.md), and the compiler
|
|
@@ -7,26 +7,116 @@
|
|
|
7
7
|
* file's own bytes, one per code unit, and the runtime has no UTF-8 decoder to
|
|
8
8
|
* change that. A host whose strings are UTF-16 must be given the text in the
|
|
9
9
|
* same shape, or the same program emits different bytes depending on which
|
|
10
|
-
* generation of the compiler read it
|
|
11
|
-
* up double-encoded and broke the self-hosting fixpoint.
|
|
10
|
+
* generation of the compiler read it.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* The conversion is explicit at the boundary:
|
|
13
|
+
*
|
|
14
|
+
* - `sourceTextBytes(hostText)` UTF-8 encodes text a host decoded for us (a
|
|
15
|
+
* `compileString` argument, a test fixture);
|
|
16
|
+
* - `sourceTextFromBytes(fileBytes)` keeps a file's bytes as they are, which is
|
|
17
|
+
* the only correct reading for a source file on either host;
|
|
18
|
+
* - `readSourceText(path)` reads a UTF-8 source file through the second one.
|
|
19
|
+
*
|
|
20
|
+
* There is deliberately no "does this string look like text?" heuristic: a
|
|
21
|
+
* Latin-1-range character such as `é` has the same code unit (`0xE9`) whether
|
|
22
|
+
* it was decoded from UTF-8 or is a raw byte, and guessing wrong emitted it as
|
|
23
|
+
* a single invalid byte instead of the two-byte UTF-8 sequence.
|
|
16
24
|
*/
|
|
17
25
|
|
|
26
|
+
import { readFileSync } from "node:fs";
|
|
27
|
+
|
|
18
28
|
/**
|
|
19
|
-
* The UTF-8 bytes of
|
|
20
|
-
*
|
|
21
|
-
*
|
|
29
|
+
* The UTF-8 bytes of host text, one code unit each.
|
|
30
|
+
*
|
|
31
|
+
* Use this only for text a host decoded (a string literal in a test, a
|
|
32
|
+
* `compileString` argument). A file's bytes must go through
|
|
33
|
+
* {@link sourceTextFromBytes}; encoding those again doubles the non-ASCII
|
|
34
|
+
* sequence and breaks the self-hosting fixpoint.
|
|
22
35
|
*/
|
|
23
36
|
export function sourceTextBytes(text: string): string {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
return stripBom(encodeUtf8(text));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Internal source text from a file's raw bytes.
|
|
42
|
+
*
|
|
43
|
+
* `readFileSync` returns a `Buffer` on Node and a byte string (one code unit
|
|
44
|
+
* per byte) in a self-hosted xbintsc; both arrive here. A UTF-8 BOM is dropped
|
|
45
|
+
* so positions match the scanner's normalized text.
|
|
46
|
+
*/
|
|
47
|
+
export function sourceTextFromBytes(bytes: Uint8Array | string): string {
|
|
48
|
+
return stripBom(typeof bytes === "string" ? bytes : bytesToString(bytes));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Read a UTF-8 source file as internal (byte-string) text. */
|
|
52
|
+
export function readSourceText(path: string): string {
|
|
53
|
+
const data: Uint8Array | string = readFileSync(path);
|
|
54
|
+
return sourceTextFromBytes(data);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Decode internal byte text back to host text for display (diagnostics).
|
|
59
|
+
*
|
|
60
|
+
* Invalid sequences decode to U+FFFD, which is what a terminal would show for
|
|
61
|
+
* a malformed byte; the parser never consumes the result.
|
|
62
|
+
*/
|
|
63
|
+
export function decodeSourceBytes(bytes: string): string {
|
|
64
|
+
const chunks: string[] = [];
|
|
65
|
+
const units: number[] = [];
|
|
66
|
+
let index = 0;
|
|
67
|
+
while (index < bytes.length) {
|
|
68
|
+
const lead = bytes.charCodeAt(index) & 0xff;
|
|
69
|
+
if (lead < 0x80) {
|
|
70
|
+
units.push(lead);
|
|
71
|
+
index += 1;
|
|
72
|
+
} else if ((lead & 0xe0) === 0xc0) {
|
|
73
|
+
const b1 = bytes.charCodeAt(index + 1);
|
|
74
|
+
if ((b1 & 0xc0) === 0x80) {
|
|
75
|
+
units.push(((lead & 0x1f) << 6) | (b1 & 0x3f));
|
|
76
|
+
index += 2;
|
|
77
|
+
} else {
|
|
78
|
+
units.push(0xfffd);
|
|
79
|
+
index += 1;
|
|
80
|
+
}
|
|
81
|
+
} else if ((lead & 0xf0) === 0xe0) {
|
|
82
|
+
const b1 = bytes.charCodeAt(index + 1);
|
|
83
|
+
const b2 = bytes.charCodeAt(index + 2);
|
|
84
|
+
if ((b1 & 0xc0) === 0x80 && (b2 & 0xc0) === 0x80) {
|
|
85
|
+
units.push(((lead & 0x0f) << 12) | ((b1 & 0x3f) << 6) | (b2 & 0x3f));
|
|
86
|
+
index += 3;
|
|
87
|
+
} else {
|
|
88
|
+
units.push(0xfffd);
|
|
89
|
+
index += 1;
|
|
90
|
+
}
|
|
91
|
+
} else if ((lead & 0xf8) === 0xf0) {
|
|
92
|
+
const b1 = bytes.charCodeAt(index + 1);
|
|
93
|
+
const b2 = bytes.charCodeAt(index + 2);
|
|
94
|
+
const b3 = bytes.charCodeAt(index + 3);
|
|
95
|
+
if ((b1 & 0xc0) === 0x80 && (b2 & 0xc0) === 0x80 && (b3 & 0xc0) === 0x80) {
|
|
96
|
+
let code = ((lead & 0x07) << 18) | ((b1 & 0x3f) << 12) | ((b2 & 0x3f) << 6) | (b3 & 0x3f);
|
|
97
|
+
if (code > 0x10ffff) code = 0xfffd;
|
|
98
|
+
if (code >= 0x10000) {
|
|
99
|
+
code -= 0x10000;
|
|
100
|
+
units.push(0xd800 + (code >> 10), 0xdc00 + (code & 0x3ff));
|
|
101
|
+
} else {
|
|
102
|
+
units.push(code);
|
|
103
|
+
}
|
|
104
|
+
index += 4;
|
|
105
|
+
} else {
|
|
106
|
+
units.push(0xfffd);
|
|
107
|
+
index += 1;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
units.push(0xfffd);
|
|
111
|
+
index += 1;
|
|
112
|
+
}
|
|
113
|
+
if (units.length >= 512) flushUnits(units, chunks);
|
|
114
|
+
}
|
|
115
|
+
flushUnits(units, chunks);
|
|
116
|
+
return chunks.join("");
|
|
27
117
|
}
|
|
28
118
|
|
|
29
|
-
/** Encode text as UTF-8
|
|
119
|
+
/** Encode host text as a UTF-8 byte string. */
|
|
30
120
|
function encodeUtf8(text: string): string {
|
|
31
121
|
const chunks: string[] = [];
|
|
32
122
|
const units: number[] = [];
|
|
@@ -57,17 +147,23 @@ function encodeUtf8(text: string): string {
|
|
|
57
147
|
return chunks.join("");
|
|
58
148
|
}
|
|
59
149
|
|
|
60
|
-
/**
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
150
|
+
/** One code unit per byte of a file buffer. */
|
|
151
|
+
function bytesToString(bytes: Uint8Array): string {
|
|
152
|
+
const chunks: string[] = [];
|
|
153
|
+
const units: number[] = [];
|
|
154
|
+
for (let index = 0; index < bytes.length; index++) {
|
|
155
|
+
units.push(bytes[index]!);
|
|
156
|
+
if (units.length >= 512) flushUnits(units, chunks);
|
|
64
157
|
}
|
|
65
|
-
|
|
158
|
+
flushUnits(units, chunks);
|
|
159
|
+
return chunks.join("");
|
|
66
160
|
}
|
|
67
161
|
|
|
68
|
-
/** Whether
|
|
69
|
-
function
|
|
70
|
-
return text.charCodeAt(0) === 0xef && text.charCodeAt(1) === 0xbb && text.charCodeAt(2) === 0xbf
|
|
162
|
+
/** Whether the text starts with the UTF-8 encoding of a BOM. */
|
|
163
|
+
function stripBom(text: string): string {
|
|
164
|
+
return text.charCodeAt(0) === 0xef && text.charCodeAt(1) === 0xbb && text.charCodeAt(2) === 0xbf
|
|
165
|
+
? text.slice(3)
|
|
166
|
+
: text;
|
|
71
167
|
}
|
|
72
168
|
|
|
73
169
|
/** Append the pending code units as one chunk of the byte string. */
|
|
@@ -75,4 +171,4 @@ function flushUnits(units: number[], chunks: string[]): void {
|
|
|
75
171
|
if (units.length === 0) return;
|
|
76
172
|
chunks.push(String.fromCharCode(...units));
|
|
77
173
|
units.length = 0;
|
|
78
|
-
}
|
|
174
|
+
}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source file abstraction: owns the raw text plus a line-offset index so
|
|
3
|
-
* positions (
|
|
2
|
+
* Source file abstraction: owns the raw byte text plus a line-offset index so
|
|
3
|
+
* that positions (byte offsets) can be mapped back to line/column pairs for
|
|
4
4
|
* diagnostics and for incremental-compilation fingerprints.
|
|
5
|
+
*
|
|
6
|
+
* `text` is the compiler's internal representation: UTF-8 bytes, one code unit
|
|
7
|
+
* per byte (see `source-text.ts`). Offsets in the AST and diagnostics are
|
|
8
|
+
* indexes into that byte string. `positionAt` reports the line and the column
|
|
9
|
+
* a reader sees, so the column is counted in UTF-16 code units after decoding
|
|
10
|
+
* the line prefix; the raw byte column would drift from an editor's column as
|
|
11
|
+
* soon as a line contains non-ASCII text.
|
|
5
12
|
*/
|
|
6
13
|
|
|
14
|
+
import { decodeSourceBytes } from "./source-text.js";
|
|
15
|
+
|
|
7
16
|
export interface LineAndColumn {
|
|
8
17
|
/** 1-based line number. */
|
|
9
18
|
readonly line: number;
|
|
10
|
-
/** 1-based column number (UTF-16 code units). */
|
|
19
|
+
/** 1-based column number (UTF-16 code units, as an editor counts). */
|
|
11
20
|
readonly column: number;
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
/**
|
|
15
|
-
* A text position. `offset` is a
|
|
16
|
-
*
|
|
24
|
+
* A text position. `offset` is a byte index into the source's internal UTF-8
|
|
25
|
+
* representation (`SourceFile.text`), not a UTF-16 code-unit index.
|
|
17
26
|
*/
|
|
18
27
|
export interface TextPosition {
|
|
19
28
|
readonly offset: number;
|
|
@@ -26,6 +35,7 @@ export interface TextRange {
|
|
|
26
35
|
|
|
27
36
|
export class SourceFile {
|
|
28
37
|
readonly fileName: string;
|
|
38
|
+
/** Internal UTF-8 byte text: one code unit per byte. */
|
|
29
39
|
readonly text: string;
|
|
30
40
|
/** Content hash used by the incremental compiler. */
|
|
31
41
|
readonly hash: string;
|
|
@@ -34,6 +44,8 @@ export class SourceFile {
|
|
|
34
44
|
constructor(fileName: string, text: string) {
|
|
35
45
|
this.fileName = fileName;
|
|
36
46
|
// Normalize BOM and line endings so downstream stages only deal with "\n".
|
|
47
|
+
// A file read through `readSourceText` already dropped the byte BOM; a
|
|
48
|
+
// host text argument may still carry the U+FEFF code unit.
|
|
37
49
|
const normalized = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
38
50
|
this.text = normalized.replace(/\r\n?/g, "\n");
|
|
39
51
|
this.hash = hashText(this.text);
|
|
@@ -66,10 +78,20 @@ export class SourceFile {
|
|
|
66
78
|
if (starts[mid]! <= clamped) lo = mid;
|
|
67
79
|
else hi = mid - 1;
|
|
68
80
|
}
|
|
69
|
-
|
|
81
|
+
const prefix = this.text.slice(starts[lo]!, clamped);
|
|
82
|
+
return { line: lo + 1, column: decodeSourceBytes(prefix).length + 1 };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The display text of a 1-based line, without its trailing newline. */
|
|
86
|
+
lineText(line: number): string {
|
|
87
|
+
const starts = this.getLineStarts();
|
|
88
|
+
if (line < 1 || line > starts.length) return "";
|
|
89
|
+
const start = starts[line - 1]!;
|
|
90
|
+
const next = line < starts.length ? starts[line]! - 1 : this.text.length;
|
|
91
|
+
return decodeSourceBytes(this.text.slice(start, next));
|
|
70
92
|
}
|
|
71
93
|
|
|
72
|
-
/** Extract the raw source text covered by a range. */
|
|
94
|
+
/** Extract the raw source text covered by a range (internal byte text). */
|
|
73
95
|
slice(range: TextRange): string {
|
|
74
96
|
return this.text.slice(range.start, range.end);
|
|
75
97
|
}
|
package/src/driver/build-key.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface CacheKeyInput {
|
|
|
27
27
|
readonly sourceText: string;
|
|
28
28
|
readonly emit: string;
|
|
29
29
|
readonly optimize: string;
|
|
30
|
+
/** Host architecture; a shared cache must not serve an x64 binary to arm64. */
|
|
31
|
+
readonly arch: string;
|
|
30
32
|
readonly registry: ExtensionRegistry;
|
|
31
33
|
readonly runtimeDir: string;
|
|
32
34
|
readonly icon?: IconInfo;
|
|
@@ -41,11 +43,24 @@ export interface CacheKeyInput {
|
|
|
41
43
|
readonly pgoDir: string;
|
|
42
44
|
/** Active optional link features; they change which objects/archives link. */
|
|
43
45
|
readonly features?: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* The compiler the build will invoke. `undefined` for `emit: "ir"`, which
|
|
48
|
+
* needs no toolchain. A different clang/SDK produces a different binary, so
|
|
49
|
+
* it must invalidate the cache.
|
|
50
|
+
*/
|
|
51
|
+
readonly toolchain?: CacheKeyToolchain;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The toolchain inputs that change the linked output. */
|
|
55
|
+
export interface CacheKeyToolchain {
|
|
56
|
+
readonly clang: string;
|
|
57
|
+
readonly sdkRoot?: string;
|
|
58
|
+
readonly linkerArgs: readonly string[];
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
/** Hash every input that can change the produced binary. */
|
|
47
62
|
export function buildCacheKey(input: CacheKeyInput): string {
|
|
48
|
-
const { app, icon, pgo, storage } = input;
|
|
63
|
+
const { app, icon, pgo, storage, toolchain } = input;
|
|
49
64
|
return hashParts([
|
|
50
65
|
COMPILER_VERSION,
|
|
51
66
|
compilerFingerprint(),
|
|
@@ -53,6 +68,10 @@ export function buildCacheKey(input: CacheKeyInput): string {
|
|
|
53
68
|
input.emit,
|
|
54
69
|
input.optimize,
|
|
55
70
|
process.platform,
|
|
71
|
+
input.arch,
|
|
72
|
+
toolchain?.clang ?? "",
|
|
73
|
+
toolchain?.sdkRoot ?? "",
|
|
74
|
+
[...(toolchain?.linkerArgs ?? [])].join(" "),
|
|
56
75
|
registryFingerprint(input.registry),
|
|
57
76
|
runtimeFingerprint(input.runtimeDir),
|
|
58
77
|
vendoredRuntimeFingerprint(input.runtimeDir),
|
|
@@ -60,6 +79,7 @@ export function buildCacheKey(input: CacheKeyInput): string {
|
|
|
60
79
|
app.name ?? "",
|
|
61
80
|
String(app.bundle ?? false),
|
|
62
81
|
app.bundleId ?? "",
|
|
82
|
+
String(app.console === true),
|
|
63
83
|
storage.backend,
|
|
64
84
|
storage.path,
|
|
65
85
|
String(input.debug),
|
|
@@ -105,9 +105,16 @@ export interface CommonJSLoweringContext {
|
|
|
105
105
|
* free references, and record its export surface (whole-object `default` plus
|
|
106
106
|
* every syntactically detectable named export). Runs before the ESM export
|
|
107
107
|
* collection so re-exports of a CommonJS module resolve.
|
|
108
|
+
*
|
|
109
|
+
* Returns the statements that must run *before any* module body: the
|
|
110
|
+
* `module`/`exports` pair. Node creates them when a module starts loading, so a
|
|
111
|
+
* `require` cycle sees the earlier module's (partly filled) object; keeping them
|
|
112
|
+
* in the module's own block would leave the later module reading an object that
|
|
113
|
+
* does not exist yet. The caller hoists them into a program-wide prelude, and
|
|
114
|
+
* the module keeps only its body plus the export snapshot at the end.
|
|
108
115
|
*/
|
|
109
|
-
export function prepareCommonJS(record: ModuleRecord):
|
|
110
|
-
if (!record.commonjs) return;
|
|
116
|
+
export function prepareCommonJS(record: ModuleRecord): Statement[] {
|
|
117
|
+
if (!record.commonjs) return [];
|
|
111
118
|
const statements = record.sourceFile.statements as Statement[];
|
|
112
119
|
const anchor = statements[0]?.start ?? record.sourceFile.start;
|
|
113
120
|
|
|
@@ -125,12 +132,12 @@ export function prepareCommonJS(record: ModuleRecord): void {
|
|
|
125
132
|
else if (identifier.text === "exports" && hasExports) (identifier as { text: string }).text = exportsName;
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
const
|
|
135
|
+
const preludeStatements: Statement[] = [
|
|
129
136
|
variableStatement(moduleName, objectLiteral([propertyAssignment("exports", objectLiteral([]))]), anchor),
|
|
130
137
|
];
|
|
131
138
|
// `exports` may be reassigned (`exports = module.exports = {}`), so the alias
|
|
132
139
|
// is a `let`, not a `const`.
|
|
133
|
-
|
|
140
|
+
preludeStatements.push(variableStatement(exportsName, member(moduleName, "exports", anchor), anchor, "let"));
|
|
134
141
|
|
|
135
142
|
const suffixStatements: Statement[] = [];
|
|
136
143
|
const defaultName = `${record.prefix}$cjs_default`;
|
|
@@ -142,8 +149,8 @@ export function prepareCommonJS(record: ModuleRecord): void {
|
|
|
142
149
|
record.exports.set(name, local);
|
|
143
150
|
}
|
|
144
151
|
|
|
145
|
-
statements.unshift(...prefixStatements);
|
|
146
152
|
statements.push(...suffixStatements);
|
|
153
|
+
return preludeStatements;
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
/**
|