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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `Buffer` module.
|
|
3
3
|
*
|
|
4
|
-
* Buffers are
|
|
5
|
-
* plus `length`) with methods
|
|
6
|
-
*
|
|
7
|
-
* without a dedicated binary value type
|
|
4
|
+
* Buffers are ordinary xbintsc objects whose bytes live in an `ArrayBuffer`
|
|
5
|
+
* store behind dynamic-property hooks (plus a `length` property) with methods
|
|
6
|
+
* supplied by the C runtime, so `Buffer.from`, `Buffer.alloc` and the instance
|
|
7
|
+
* methods (`toString`, `slice`, ...) work without a dedicated binary value type
|
|
8
|
+
* in the compiler, and `buf[i]` still reads a byte.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import type { NodeModule } from "../module.js";
|
|
@@ -14,7 +14,14 @@ import type { ModuleExports } from "../../registry.js";
|
|
|
14
14
|
const methods = ["listenerCount", "getEventListeners", "getMaxListeners", "setMaxListeners", "once", "addAbortListener"] as const;
|
|
15
15
|
|
|
16
16
|
const exports: ModuleExports = {
|
|
17
|
-
EventEmitter: {
|
|
17
|
+
EventEmitter: {
|
|
18
|
+
symbol: "xt_event_emitter_ctor",
|
|
19
|
+
isConstructor: true,
|
|
20
|
+
// `class X extends EventEmitter` chains onto this prototype, so the
|
|
21
|
+
// inherited listener API is reachable (and `x instanceof EventEmitter`
|
|
22
|
+
// holds when the same constructor value is compared).
|
|
23
|
+
prototypeSymbol: "xt_events_prototype",
|
|
24
|
+
},
|
|
18
25
|
defaultMaxListeners: { valueSymbol: "xt_events_default_max_listeners" },
|
|
19
26
|
...Object.fromEntries(methods.map((method) => [method, { namespace: "events", method }])),
|
|
20
27
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The callback forms of Node's `fs` API.
|
|
3
|
+
*
|
|
4
|
+
* Each name forwards to the promise implementation in `callbacks.c`, which
|
|
5
|
+
* attaches `callback(null, value)` / `callback(error)` handlers. `exists` keeps
|
|
6
|
+
* Node's odd shape: one boolean argument and no error.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { BuiltinFunction } from "../../registry.js";
|
|
10
|
+
|
|
11
|
+
const callback = (name: string): BuiltinFunction => ({ symbol: `xt_node_${name}_cb` });
|
|
12
|
+
|
|
13
|
+
export const fsCallbackBuiltins: Readonly<Record<string, BuiltinFunction>> = {
|
|
14
|
+
readFile: callback("read_file"),
|
|
15
|
+
writeFile: callback("write_file"),
|
|
16
|
+
appendFile: callback("append_file"),
|
|
17
|
+
mkdir: callback("mkdir"),
|
|
18
|
+
mkdtemp: callback("mkdtemp"),
|
|
19
|
+
readdir: callback("readdir"),
|
|
20
|
+
rm: callback("rm"),
|
|
21
|
+
rmdir: callback("rmdir"),
|
|
22
|
+
unlink: callback("unlink"),
|
|
23
|
+
rename: callback("rename"),
|
|
24
|
+
copyFile: callback("copy_file"),
|
|
25
|
+
cp: callback("cp"),
|
|
26
|
+
realpath: callback("realpath"),
|
|
27
|
+
stat: callback("stat"),
|
|
28
|
+
lstat: callback("lstat"),
|
|
29
|
+
statfs: callback("statfs"),
|
|
30
|
+
access: callback("access"),
|
|
31
|
+
open: callback("open"),
|
|
32
|
+
chmod: callback("chmod"),
|
|
33
|
+
lchmod: callback("lchmod"),
|
|
34
|
+
chown: callback("chown"),
|
|
35
|
+
lchown: callback("lchown"),
|
|
36
|
+
truncate: callback("truncate"),
|
|
37
|
+
utimes: callback("utimes"),
|
|
38
|
+
lutimes: callback("lutimes"),
|
|
39
|
+
link: callback("link"),
|
|
40
|
+
symlink: callback("symlink"),
|
|
41
|
+
readlink: callback("readlink"),
|
|
42
|
+
opendir: callback("opendir"),
|
|
43
|
+
glob: callback("glob"),
|
|
44
|
+
exists: callback("exists"),
|
|
45
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `fs` module: synchronous file and directory operations backed by
|
|
3
|
-
* `runtime/ext_node/fs`,
|
|
4
|
-
*
|
|
5
|
-
* `readFile`/`writeFile` forms are not supported; `*Sync` and `fs.promises` are.
|
|
3
|
+
* `runtime/ext_node/fs`, the callback forms (`readFile`, `writeFile`, `stat`,
|
|
4
|
+
* …) built on the asynchronous I/O pool, and the `fs.promises` namespace.
|
|
6
5
|
* `watch`/`watchFile` return API-shaped watchers that never emit.
|
|
7
6
|
*
|
|
8
7
|
* `fs.constants` and `fs.promises` are exposed as value getters, so both
|
|
@@ -16,9 +15,16 @@ import type { ModuleExports } from "../../registry.js";
|
|
|
16
15
|
import { readFileBuiltins } from "./read-file.js";
|
|
17
16
|
import { writeFileBuiltins } from "./write-file.js";
|
|
18
17
|
import { fsOpsBuiltins } from "./fs-ops.js";
|
|
18
|
+
import { fsCallbackBuiltins } from "./callbacks.js";
|
|
19
19
|
import { fsStreamBuiltins } from "./streams.js";
|
|
20
20
|
|
|
21
|
-
const builtins = {
|
|
21
|
+
const builtins = {
|
|
22
|
+
...readFileBuiltins,
|
|
23
|
+
...writeFileBuiltins,
|
|
24
|
+
...fsOpsBuiltins,
|
|
25
|
+
...fsCallbackBuiltins,
|
|
26
|
+
...fsStreamBuiltins,
|
|
27
|
+
};
|
|
22
28
|
|
|
23
29
|
const exports: ModuleExports = {
|
|
24
30
|
...builtins,
|
|
@@ -31,6 +37,7 @@ export const fsModule: NodeModule = {
|
|
|
31
37
|
runtimeSources: () => [
|
|
32
38
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/read_file.c"),
|
|
33
39
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/write_file.c"),
|
|
40
|
+
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/callbacks.c"),
|
|
34
41
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/fs_ops.c"),
|
|
35
42
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/fd_ops.c"),
|
|
36
43
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/meta_ops.c"),
|
|
@@ -2,18 +2,40 @@
|
|
|
2
2
|
* Node's `process` object backed by `runtime/ext_node/process`.
|
|
3
3
|
*
|
|
4
4
|
* The compiler lowers `process.<method>(...)` to
|
|
5
|
-
* `xt_process_call(<method>, argc, argv)
|
|
6
|
-
* `xt_process_get(<property>)`
|
|
7
|
-
*
|
|
5
|
+
* `xt_process_call(<method>, argc, argv)`, `process.<property>` to
|
|
6
|
+
* `xt_process_get(<property>)` and `process.<property> = value` to
|
|
7
|
+
* `xt_process_set(<property>, value)` (see `NAMESPACE_STATICS` /
|
|
8
|
+
* `NAMESPACE_PROPERTIES` / `NAMESPACE_PROPERTY_SETTERS` in
|
|
9
|
+
* `src/codegen/generator/tables.ts`). Importing the module aliases that
|
|
8
10
|
* namespace (`import process from "process"`); named method exports dispatch
|
|
9
11
|
* through `xt_process_call`.
|
|
12
|
+
*
|
|
13
|
+
* The object is also an EventEmitter (`on`/`once`/`off`/`emit`, with "exit"
|
|
14
|
+
* fired before the process ends) and owns the three standard streams, so
|
|
15
|
+
* `process.stdin.setRawMode(true)` and `process.stdout.columns` reach the same
|
|
16
|
+
* singletons.
|
|
10
17
|
*/
|
|
11
18
|
|
|
12
19
|
import type { NodeModule } from "../module.js";
|
|
13
20
|
import { resolveFrom } from "../module.js";
|
|
14
21
|
import type { ModuleExports } from "../../registry.js";
|
|
15
22
|
|
|
16
|
-
const methods = [
|
|
23
|
+
const methods = [
|
|
24
|
+
"cwd",
|
|
25
|
+
"exit",
|
|
26
|
+
"uptime",
|
|
27
|
+
"hrtime",
|
|
28
|
+
"getuid",
|
|
29
|
+
"on",
|
|
30
|
+
"once",
|
|
31
|
+
"addListener",
|
|
32
|
+
"prependListener",
|
|
33
|
+
"off",
|
|
34
|
+
"removeListener",
|
|
35
|
+
"removeAllListeners",
|
|
36
|
+
"emit",
|
|
37
|
+
"nextTick",
|
|
38
|
+
] as const;
|
|
17
39
|
|
|
18
40
|
const exports: ModuleExports = Object.fromEntries(
|
|
19
41
|
methods.map((method) => [method, { namespace: "process", method }]),
|
|
@@ -22,7 +44,10 @@ const exports: ModuleExports = Object.fromEntries(
|
|
|
22
44
|
export const processModule: NodeModule = {
|
|
23
45
|
name: "process",
|
|
24
46
|
namespace: "process",
|
|
25
|
-
runtimeSources: () => [
|
|
47
|
+
runtimeSources: () => [
|
|
48
|
+
resolveFrom(import.meta.url, "../../../../runtime/ext_node/process/process.c"),
|
|
49
|
+
resolveFrom(import.meta.url, "../../../../runtime/ext_node/process/streams.c"),
|
|
50
|
+
],
|
|
26
51
|
builtins: () => ({}),
|
|
27
52
|
exports: () => exports,
|
|
28
53
|
};
|
|
@@ -38,6 +38,20 @@ export interface GlobalValue {
|
|
|
38
38
|
readonly symbol: string;
|
|
39
39
|
/** Passed as the only argument; omit to call the getter with none. */
|
|
40
40
|
readonly argument?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Read (and call) this global as a *member of the object `symbol` returns*
|
|
43
|
+
* instead of as the getter's own result.
|
|
44
|
+
*
|
|
45
|
+
* Browsers put `innerWidth`, `location` or `addEventListener` in the global
|
|
46
|
+
* scope because the global object *is* the window; xbintsc's globals are
|
|
47
|
+
* compiler-provided names with no global object behind them. Declaring
|
|
48
|
+
* `{ symbol: "xt_browser_window", member: "innerWidth" }` gives the name the
|
|
49
|
+
* browser semantics with the host object the extension already exposes: a
|
|
50
|
+
* read lowers to `xt_get(window, "innerWidth")` (getters run with the window
|
|
51
|
+
* as `this`, so the value is live rather than snapshotted at startup) and a
|
|
52
|
+
* call lowers to `xt_call_method(window, "addEventListener", …)`.
|
|
53
|
+
*/
|
|
54
|
+
readonly member?: string;
|
|
41
55
|
}
|
|
42
56
|
|
|
43
57
|
/**
|
|
@@ -63,6 +77,13 @@ export interface ModuleExport {
|
|
|
63
77
|
* used as `new EventEmitter()`.
|
|
64
78
|
*/
|
|
65
79
|
readonly isConstructor?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Runtime getter `(i32, i64*)` returning the prototype object a constructor
|
|
82
|
+
* *value* carries, so `class X extends EventEmitter` chains onto
|
|
83
|
+
* `EventEmitter.prototype` instead of a fresh plain object. Only meaningful
|
|
84
|
+
* together with `isConstructor`.
|
|
85
|
+
*/
|
|
86
|
+
readonly prototypeSymbol?: string;
|
|
66
87
|
}
|
|
67
88
|
|
|
68
89
|
export type ModuleExports = Readonly<Record<string, ModuleExport>>;
|
|
@@ -103,6 +124,12 @@ export interface AssetSourceRange {
|
|
|
103
124
|
readonly start: number;
|
|
104
125
|
readonly end: number;
|
|
105
126
|
readonly file: string;
|
|
127
|
+
/**
|
|
128
|
+
* The copied source is plain JavaScript even though `file` is not a `.js`
|
|
129
|
+
* file (an inline `<script>` body in an HTML page). Nodes inside the span
|
|
130
|
+
* then skip the type checker, exactly like an external `.js` script.
|
|
131
|
+
*/
|
|
132
|
+
readonly untyped?: boolean;
|
|
106
133
|
}
|
|
107
134
|
|
|
108
135
|
/** Rewrites an imported file (selected by extension) into a TS module. */
|
|
@@ -173,6 +200,16 @@ export interface LinkFeatureDeclaration {
|
|
|
173
200
|
readonly extension: string;
|
|
174
201
|
}
|
|
175
202
|
|
|
203
|
+
/**
|
|
204
|
+
* A lookup table keyed by names the program writes. A plain object literal
|
|
205
|
+
* inherits `Object.prototype`, so `table["toString"]` would answer with
|
|
206
|
+
* `Object.prototype.toString` and the generator would emit that function's text
|
|
207
|
+
* as an LLVM symbol.
|
|
208
|
+
*/
|
|
209
|
+
function lookupTable<T>(): Record<string, T> {
|
|
210
|
+
return Object.create(null) as Record<string, T>;
|
|
211
|
+
}
|
|
212
|
+
|
|
176
213
|
export class ExtensionRegistry {
|
|
177
214
|
private readonly extensions = new Map<string, Extension>();
|
|
178
215
|
/**
|
|
@@ -259,7 +296,7 @@ export class ExtensionRegistry {
|
|
|
259
296
|
|
|
260
297
|
/** Flatten every registered builtin into one lookup table. */
|
|
261
298
|
builtins(): Readonly<Record<string, BuiltinFunction>> {
|
|
262
|
-
const merged
|
|
299
|
+
const merged = lookupTable<BuiltinFunction>();
|
|
263
300
|
for (const extension of this.extensions.values()) {
|
|
264
301
|
const builtins = extension.builtins?.();
|
|
265
302
|
if (builtins) Object.assign(merged, builtins);
|
|
@@ -269,7 +306,7 @@ export class ExtensionRegistry {
|
|
|
269
306
|
|
|
270
307
|
/** Flatten every registered extension's global values into one lookup. */
|
|
271
308
|
globalValues(): Readonly<Record<string, GlobalValue>> {
|
|
272
|
-
const merged
|
|
309
|
+
const merged = lookupTable<GlobalValue>();
|
|
273
310
|
for (const extension of this.extensions.values()) {
|
|
274
311
|
const values = extension.globalValues?.();
|
|
275
312
|
if (values) Object.assign(merged, values);
|
|
@@ -279,7 +316,7 @@ export class ExtensionRegistry {
|
|
|
279
316
|
|
|
280
317
|
/** Flatten every registered extension's importable modules. */
|
|
281
318
|
modules(): Readonly<Record<string, ExtensionModule>> {
|
|
282
|
-
const merged
|
|
319
|
+
const merged = lookupTable<ExtensionModule>();
|
|
283
320
|
for (const extension of this.extensions.values()) {
|
|
284
321
|
const modules = extension.modules?.();
|
|
285
322
|
if (!modules) continue;
|
|
@@ -300,7 +337,7 @@ export class ExtensionRegistry {
|
|
|
300
337
|
* extension (mirroring `modules()`).
|
|
301
338
|
*/
|
|
302
339
|
assetLoaders(): Readonly<Record<string, AssetLoader>> {
|
|
303
|
-
const merged
|
|
340
|
+
const merged = lookupTable<AssetLoader>();
|
|
304
341
|
for (const extension of this.extensions.values()) {
|
|
305
342
|
const loaders = extension.assetLoaders?.();
|
|
306
343
|
if (loaders) Object.assign(merged, loaders);
|
package/src/lexer/scanner.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { punctuationMethods, type PunctuationMethods } from "./scanner/punctuati
|
|
|
20
20
|
export class Scanner {
|
|
21
21
|
text: string;
|
|
22
22
|
pos = 0;
|
|
23
|
-
|
|
23
|
+
diagnostics: DiagnosticBag;
|
|
24
24
|
readonly source: SourceFile;
|
|
25
25
|
_token: Token = {
|
|
26
26
|
kind: TokenKind.EndOfFile,
|
|
@@ -54,6 +54,21 @@ export class Scanner {
|
|
|
54
54
|
this.pos = Math.max(0, Math.min(offset, this.text.length));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Run `scan` with diagnostics collected into `sink` instead of the main bag.
|
|
59
|
+
* The parser uses this for lookahead: tokens read only to decide how to
|
|
60
|
+
* parse must not report errors, because the parser may discard them.
|
|
61
|
+
*/
|
|
62
|
+
withDiagnostics<T>(sink: DiagnosticBag, scan: () => T): T {
|
|
63
|
+
const saved = this.diagnostics;
|
|
64
|
+
this.diagnostics = sink;
|
|
65
|
+
try {
|
|
66
|
+
return scan();
|
|
67
|
+
} finally {
|
|
68
|
+
this.diagnostics = saved;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
57
72
|
/** Advance to the next token. */
|
|
58
73
|
nextToken(): Token {
|
|
59
74
|
this._token = this.scan();
|
package/src/parser/context.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* needs.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { DiagnosticBag, DiagnosticCode } from "../diagnostics/diagnostic.js";
|
|
10
|
+
import { DiagnosticBag, DiagnosticCode, type Diagnostic } from "../diagnostics/diagnostic.js";
|
|
11
11
|
import type { SourceFile } from "../diagnostics/source.js";
|
|
12
12
|
import { Scanner } from "../lexer/scanner.js";
|
|
13
13
|
import { isIdentifierNameToken, isKeywordKind, Token, TokenKind } from "../lexer/token.js";
|
|
@@ -56,6 +56,10 @@ export class ParserContext {
|
|
|
56
56
|
* current token so a template that was only seen by lookahead stays coherent.
|
|
57
57
|
*/
|
|
58
58
|
private readonly templateStates = new WeakMap<Token, TemplateState>();
|
|
59
|
+
/** Side bag that receives the diagnostics of lookahead-only scans. */
|
|
60
|
+
private readonly lookaheadSink = new DiagnosticBag();
|
|
61
|
+
/** Scan errors held back until the parser reaches the token that produced them. */
|
|
62
|
+
private readonly deferredTokenDiagnostics = new WeakMap<Token, Diagnostic[]>();
|
|
59
63
|
|
|
60
64
|
constructor(source: SourceFile, diagnostics: DiagnosticBag) {
|
|
61
65
|
this.source = source;
|
|
@@ -85,7 +89,7 @@ export class ParserContext {
|
|
|
85
89
|
|
|
86
90
|
lookAhead(k: number): Token {
|
|
87
91
|
while (this.tokens.length <= this.index + k) {
|
|
88
|
-
this.tokens.push(this.scanToken());
|
|
92
|
+
this.tokens.push(this.scanToken(true));
|
|
89
93
|
}
|
|
90
94
|
return this.tokens[this.index + k]!;
|
|
91
95
|
}
|
|
@@ -99,9 +103,21 @@ export class ParserContext {
|
|
|
99
103
|
this.tokens = [this.scanToken()];
|
|
100
104
|
this.index = 0;
|
|
101
105
|
}
|
|
106
|
+
this.reportDeferred(this.tokens[this.index]!);
|
|
102
107
|
return current;
|
|
103
108
|
}
|
|
104
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Report the scan errors held back for `token` once the parser actually
|
|
112
|
+
* reaches it (see {@link scanToken}).
|
|
113
|
+
*/
|
|
114
|
+
private reportDeferred(token: Token): void {
|
|
115
|
+
const pending = this.deferredTokenDiagnostics.get(token);
|
|
116
|
+
if (pending === undefined) return;
|
|
117
|
+
this.deferredTokenDiagnostics.delete(token);
|
|
118
|
+
for (const diagnostic of pending) this.diagnostics.add(diagnostic);
|
|
119
|
+
}
|
|
120
|
+
|
|
105
121
|
/**
|
|
106
122
|
* Scan the next token, keeping a template literal together. A `${ … }`
|
|
107
123
|
* substitution is ordinary token stream (so the parser can parse the
|
|
@@ -111,7 +127,27 @@ export class ParserContext {
|
|
|
111
127
|
* lookahead - and `findMatchingParen` would then count characters that are
|
|
112
128
|
* part of the literal.
|
|
113
129
|
*/
|
|
114
|
-
private scanToken(): Token {
|
|
130
|
+
private scanToken(quiet = false): Token {
|
|
131
|
+
if (!quiet) return this.scanTokenBody();
|
|
132
|
+
/* Lookahead may read source the parser never consumes, and it may read it
|
|
133
|
+
* with the wrong `/` interpretation (a regex is scanned as a division
|
|
134
|
+
* because the previous token ended an expression, as in
|
|
135
|
+
* `for (;;) /re/.test(x)`). Collect scan errors in a side bag and attach
|
|
136
|
+
* them to the scanned token: they are reported only if the parser reaches
|
|
137
|
+
* that token, and dropped when the token is discarded by `rescanFrom`. */
|
|
138
|
+
const mark = this.lookaheadSink.mark();
|
|
139
|
+
const token = this.scanner.withDiagnostics(this.lookaheadSink, () => this.scanTokenBody());
|
|
140
|
+
const produced = this.lookaheadSink.diagnostics.slice(mark);
|
|
141
|
+
if (produced.length > 0) {
|
|
142
|
+
this.lookaheadSink.reset(mark);
|
|
143
|
+
const pending = this.deferredTokenDiagnostics.get(token);
|
|
144
|
+
if (pending === undefined) this.deferredTokenDiagnostics.set(token, produced);
|
|
145
|
+
else pending.push(...produced);
|
|
146
|
+
}
|
|
147
|
+
return token;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private scanTokenBody(): Token {
|
|
115
151
|
let token: Token;
|
|
116
152
|
if (this.pendingTemplateOffset !== undefined) {
|
|
117
153
|
const offset = this.pendingTemplateOffset;
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
binaryPrecedence,
|
|
33
33
|
prefixUnaryOperator,
|
|
34
34
|
} from "./operators.js";
|
|
35
|
-
import { isAssignmentTarget } from "./helpers.js";
|
|
35
|
+
import { endsExpression, isAssignmentTarget } from "./helpers.js";
|
|
36
36
|
import { SpeculationError } from "./speculation.js";
|
|
37
37
|
import type { Parser } from "./parser.js";
|
|
38
38
|
|
|
@@ -284,7 +284,7 @@ export const expressionMethods: ExpressionMethods = {
|
|
|
284
284
|
this.nextToken();
|
|
285
285
|
delegate = true;
|
|
286
286
|
}
|
|
287
|
-
if (!this.canInsertSemicolon() && !
|
|
287
|
+
if (!this.canInsertSemicolon() && !endsExpression(this.token.kind)) {
|
|
288
288
|
expression = this.parseAssignmentExpression();
|
|
289
289
|
}
|
|
290
290
|
return { kind: SyntaxKind.YieldExpression, expression, delegate, start: token.start, end: expression?.end ?? token.end };
|
package/src/parser/helpers.ts
CHANGED
|
@@ -3,8 +3,30 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { SyntaxKind } from "../ast/kinds.js";
|
|
6
|
+
import { TokenKind } from "../lexer/token.js";
|
|
6
7
|
import type { Expression, PropertyName } from "../ast/nodes.js";
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Whether a token can never begin an expression, so an operand-optional prefix
|
|
11
|
+
* operator (`yield`, `return`) placed before it has no operand. `yield, x` and
|
|
12
|
+
* `[yield]` are the common minified shapes: `yield` on its own is a valid
|
|
13
|
+
* expression, and a comma or a closing bracket ends it.
|
|
14
|
+
*/
|
|
15
|
+
export function endsExpression(kind: TokenKind): boolean {
|
|
16
|
+
switch (kind) {
|
|
17
|
+
case TokenKind.Comma:
|
|
18
|
+
case TokenKind.Semicolon:
|
|
19
|
+
case TokenKind.Colon:
|
|
20
|
+
case TokenKind.CloseParen:
|
|
21
|
+
case TokenKind.CloseBracket:
|
|
22
|
+
case TokenKind.CloseBrace:
|
|
23
|
+
case TokenKind.EndOfFile:
|
|
24
|
+
return true;
|
|
25
|
+
default:
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
8
30
|
export function expressionToPropertyName(expr: Expression): PropertyName | undefined {
|
|
9
31
|
switch (expr.kind) {
|
|
10
32
|
case SyntaxKind.StringLiteral:
|
package/src/parser/literals.ts
CHANGED
|
@@ -198,7 +198,10 @@ export const literalMethods: LiteralMethods = {
|
|
|
198
198
|
flags |= NodeFlags.Generator;
|
|
199
199
|
}
|
|
200
200
|
let name: Identifier | undefined;
|
|
201
|
-
|
|
201
|
+
/* A function *expression* may be named after a contextual keyword:
|
|
202
|
+
* `(function get() {})`, `(function constructor() {})`, `(function type() {})`.
|
|
203
|
+
* Only hard-reserved words are excluded, which `isIdentifierLike` decides. */
|
|
204
|
+
if (this.isIdentifierLike(this.token)) name = this.parseIdentifier();
|
|
202
205
|
const typeParameters = this.parseTypeParameters();
|
|
203
206
|
const parameters = this.parseParameters();
|
|
204
207
|
let returnType: TypeNode | undefined;
|
|
@@ -213,7 +216,8 @@ export const literalMethods: LiteralMethods = {
|
|
|
213
216
|
parseClassExpression(this: Parser): ClassExpression {
|
|
214
217
|
const start = this.parseExpected(TokenKind.ClassKeyword).start;
|
|
215
218
|
let name: Identifier | undefined;
|
|
216
|
-
|
|
219
|
+
/* `(class type {})` — same contextual-keyword allowance as a function name. */
|
|
220
|
+
if (this.isIdentifierLike(this.token)) name = this.parseIdentifier();
|
|
217
221
|
const typeParameters = this.parseTypeParameters();
|
|
218
222
|
const heritage = this.parseHeritageClauses();
|
|
219
223
|
const members = this.parseClassMembers();
|