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
|
@@ -20,44 +20,69 @@
|
|
|
20
20
|
#include <stdlib.h>
|
|
21
21
|
#include <string.h>
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
static xt_value xt_ab_data(xt_value buffer) { if (!XT_IS_OBJECT(buffer)) return XT_UNDEFINED;
|
|
36
|
-
return xt_object_get(buffer, xt_ab_data_key());
|
|
37
|
-
}
|
|
23
|
+
/*
|
|
24
|
+
* Storage: an ArrayBuffer is an ordinary object of kind
|
|
25
|
+
* `XT_OBJECT_KIND_ARRAY_BUFFER` whose bytes live in one `calloc`ed block
|
|
26
|
+
* (`buffer_bytes`). Typed arrays and DataViews index that block directly, so a
|
|
27
|
+
* geometry loop reads memory instead of paying a property lookup per byte.
|
|
28
|
+
*
|
|
29
|
+
* The block belongs to the buffer object and the collector frees it when the
|
|
30
|
+
* buffer is swept (see `xt_gc_release`). `byteLength` and `slice` are served by
|
|
31
|
+
* `xt_get` from this kind instead of being own properties, so an ArrayBuffer has
|
|
32
|
+
* no enumerable keys (`Object.keys(buffer)` is empty) like on the platform.
|
|
33
|
+
*/
|
|
38
34
|
|
|
39
35
|
static int xt_ab_is_buffer(xt_value value) {
|
|
40
|
-
return
|
|
36
|
+
return XT_IS_OBJECT(value) &&
|
|
37
|
+
((xt_object *)XT_GET_PTR(value))->header.kind == XT_OBJECT_KIND_ARRAY_BUFFER;
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
static xt_value xt_ab_new(uint32_t length) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
/* Instances sit on `ArrayBuffer.prototype`, so `buffer instanceof ArrayBuffer`
|
|
42
|
+
* and `buffer.constructor` behave like the platform (the properties are still
|
|
43
|
+
* served from the kind, not from the prototype). */
|
|
44
|
+
xt_value proto = xt_builtin_prototype_for_kind(XT_OBJECT_KIND_ARRAY_BUFFER);
|
|
45
|
+
xt_value buffer = XT_IS_OBJECT(proto) ? xt_object_new_with_proto(proto) : xt_object_new();
|
|
46
|
+
xt_object *object = (xt_object *)XT_GET_PTR(buffer);
|
|
47
|
+
object->header.kind = (uint8_t)XT_OBJECT_KIND_ARRAY_BUFFER;
|
|
48
|
+
/* A zero-length buffer keeps a NULL block: nothing ever indexes it. */
|
|
49
|
+
object->buffer_bytes = length > 0 ? (uint8_t *)calloc(1, length) : NULL;
|
|
50
|
+
object->buffer_length = object->buffer_bytes != NULL ? length : 0;
|
|
49
51
|
return buffer;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
static xt_value xt_ab_slice(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
53
|
-
|
|
55
|
+
|
|
56
|
+
/** The single `slice` method value `xt_get` hands out for an ArrayBuffer. */
|
|
57
|
+
xt_value xt_array_buffer_slice_value(void) {
|
|
58
|
+
static xt_value cached = XT_UNDEFINED;
|
|
59
|
+
if (XT_IS_FUNCTION(cached)) return cached;
|
|
60
|
+
cached = xt_closure_new((void *)xt_ab_slice, 0, NULL);
|
|
61
|
+
xt_gc_add_root(&cached);
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The properties an ArrayBuffer serves from its kind rather than from a
|
|
66
|
+
* property bag: `byteLength` and `slice`. `xt_get` and `xt_object_get` both
|
|
67
|
+
* consult this, so a C helper and JavaScript code agree. */
|
|
68
|
+
xt_value xt_array_buffer_served_property(xt_value buffer, xt_value key) {
|
|
69
|
+
if (!XT_IS_STRING(key)) return XT_UNDEFINED;
|
|
70
|
+
xt_object *object = (xt_object *)XT_GET_PTR(buffer);
|
|
71
|
+
xt_string *name = xt_as_string(key);
|
|
72
|
+
if (name == NULL) return XT_UNDEFINED;
|
|
73
|
+
if (name->length == 10 && memcmp(xt_string_bytes(name), "byteLength", 10) == 0) {
|
|
74
|
+
return xt_number((double)object->buffer_length);
|
|
75
|
+
}
|
|
76
|
+
if (name->length == 5 && memcmp(xt_string_bytes(name), "slice", 5) == 0) {
|
|
77
|
+
return xt_array_buffer_slice_value();
|
|
78
|
+
}
|
|
79
|
+
return XT_UNDEFINED;
|
|
80
|
+
}
|
|
54
81
|
|
|
55
82
|
xt_value xt_array_buffer_ctor(int32_t argc, xt_value *argv) {
|
|
56
83
|
double length = xt_to_number(xt_arg_at(argc, argv, 0));
|
|
57
84
|
if (!(length >= 0) || length > 4294967295.0) length = 0;
|
|
58
|
-
|
|
59
|
-
xt_ab_install(buffer, "slice", (void *)xt_ab_slice);
|
|
60
|
-
return buffer;
|
|
85
|
+
return xt_ab_new((uint32_t)length);
|
|
61
86
|
}
|
|
62
87
|
|
|
63
88
|
xt_value xt_array_buffer_alloc(uint32_t byte_length) { return xt_ab_new(byte_length); }
|
|
@@ -65,55 +90,61 @@ xt_value xt_array_buffer_alloc(uint32_t byte_length) { return xt_ab_new(byte_len
|
|
|
65
90
|
int xt_is_array_buffer(xt_value value) { return xt_ab_is_buffer(value); }
|
|
66
91
|
|
|
67
92
|
uint32_t xt_array_buffer_byte_length(xt_value value) {
|
|
68
|
-
if (!
|
|
69
|
-
|
|
93
|
+
if (!XT_IS_OBJECT(value)) return 0;
|
|
94
|
+
xt_object *object = (xt_object *)XT_GET_PTR(value);
|
|
95
|
+
if (object->header.kind != XT_OBJECT_KIND_ARRAY_BUFFER) return 0;
|
|
96
|
+
return object->buffer_length;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
uint8_t *xt_array_buffer_bytes(xt_value buffer, uint32_t *byte_length) {
|
|
100
|
+
if (byte_length != NULL) *byte_length = 0;
|
|
101
|
+
if (!XT_IS_OBJECT(buffer)) return NULL;
|
|
102
|
+
xt_object *object = (xt_object *)XT_GET_PTR(buffer);
|
|
103
|
+
if (object->header.kind != XT_OBJECT_KIND_ARRAY_BUFFER) return NULL;
|
|
104
|
+
if (byte_length != NULL) *byte_length = object->buffer_length;
|
|
105
|
+
return object->buffer_bytes;
|
|
70
106
|
}
|
|
71
107
|
|
|
72
108
|
uint8_t xt_array_buffer_get_byte(xt_value buffer, uint32_t index) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
109
|
+
uint32_t length = 0;
|
|
110
|
+
uint8_t *bytes = xt_array_buffer_bytes(buffer, &length);
|
|
111
|
+
if (bytes == NULL || index >= length) return 0;
|
|
112
|
+
return bytes[index];
|
|
76
113
|
}
|
|
77
114
|
|
|
78
115
|
void xt_array_buffer_set_byte(xt_value buffer, uint32_t index, uint8_t value) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
116
|
+
uint32_t length = 0;
|
|
117
|
+
uint8_t *bytes = xt_array_buffer_bytes(buffer, &length);
|
|
118
|
+
if (bytes == NULL || index >= length) return;
|
|
119
|
+
bytes[index] = value;
|
|
82
120
|
}
|
|
83
121
|
|
|
84
|
-
/* Bulk byte access
|
|
85
|
-
* property read per byte, which is far too slow for a multi-megabyte file. The
|
|
86
|
-
* backing store is an `xt_array` of numbers; reading its `items` directly is
|
|
87
|
-
* the same representation `xt_ab_new` writes. */
|
|
122
|
+
/* Bulk byte access for decoders and wasm memories. */
|
|
88
123
|
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
89
124
|
uint32_t count) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
125
|
+
uint32_t length = 0;
|
|
126
|
+
uint8_t *bytes = xt_array_buffer_bytes(buffer, &length);
|
|
127
|
+
if (bytes == NULL || dst == NULL) return 0;
|
|
128
|
+
if (offset >= length) return 0;
|
|
129
|
+
if (count > length - offset) count = length - offset;
|
|
130
|
+
memcpy(dst, bytes + offset, count);
|
|
97
131
|
return count;
|
|
98
132
|
}
|
|
99
133
|
|
|
100
134
|
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
101
135
|
uint32_t count) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
136
|
+
uint32_t length = 0;
|
|
137
|
+
uint8_t *bytes = xt_array_buffer_bytes(buffer, &length);
|
|
138
|
+
if (bytes == NULL || src == NULL) return 0;
|
|
139
|
+
if (offset >= length) return 0;
|
|
140
|
+
if (count > length - offset) count = length - offset;
|
|
141
|
+
memcpy(bytes + offset, src, count);
|
|
109
142
|
return count;
|
|
110
143
|
}
|
|
111
144
|
|
|
112
145
|
static xt_value xt_ab_slice(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
113
146
|
(void)env;
|
|
114
|
-
|
|
115
|
-
if (!XT_IS_ARRAY(data)) return xt_ab_new(0);
|
|
116
|
-
int32_t length = xt_to_int32(xt_array_length(data));
|
|
147
|
+
int32_t length = (int32_t)xt_array_buffer_byte_length(thisValue);
|
|
117
148
|
int32_t start = argc > 0 && argv[0] != XT_UNDEFINED ? xt_to_int32(argv[0]) : 0;
|
|
118
149
|
int32_t end = argc > 1 && argv[1] != XT_UNDEFINED ? xt_to_int32(argv[1]) : length;
|
|
119
150
|
if (start < 0) start += length;
|
|
@@ -121,18 +152,12 @@ static xt_value xt_ab_slice(xt_value thisValue, xt_value env, int32_t argc, xt_v
|
|
|
121
152
|
if (start < 0) start = 0;
|
|
122
153
|
if (end > length) end = length;
|
|
123
154
|
if (end < start) end = start;
|
|
124
|
-
xt_value result = xt_ab_new(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
for (int32_t i = start; i < end; i++) xt_array_push(source, xt_get(data, xt_number((double)i)));
|
|
128
|
-
xt_object_set(result, xt_string_from_cstr("byteLength"), xt_number((double)(end - start)));
|
|
155
|
+
xt_value result = xt_ab_new((uint32_t)(end - start));
|
|
156
|
+
xt_array_buffer_copy_bytes_out(thisValue, (uint32_t)start,
|
|
157
|
+
xt_array_buffer_bytes(result, NULL), (uint32_t)(end - start));
|
|
129
158
|
return result;
|
|
130
159
|
}
|
|
131
160
|
|
|
132
|
-
static void xt_ab_install(xt_value object, const char *name, void *fn) {
|
|
133
|
-
xt_object_set(object, xt_string_from_cstr(name), xt_closure_new(fn, 0, NULL));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
161
|
xt_value xt_array_buffer_static(xt_value name, int32_t argc, xt_value *argv) {
|
|
137
162
|
const char *method = xt_string_data(name);
|
|
138
163
|
if (!method) return XT_UNDEFINED;
|
|
@@ -182,8 +207,8 @@ static int xt_dv_signed(int kind) {
|
|
|
182
207
|
return kind == XT_DV_I8 || kind == XT_DV_I16 || kind == XT_DV_I32;
|
|
183
208
|
}
|
|
184
209
|
|
|
185
|
-
static xt_value
|
|
186
|
-
return
|
|
210
|
+
static xt_value xt_dv_buffer(xt_value view) {
|
|
211
|
+
return xt_get(view, xt_string_from_cstr("buffer"));
|
|
187
212
|
}
|
|
188
213
|
|
|
189
214
|
static uint32_t xt_dv_offset(xt_value view) {
|
|
@@ -207,23 +232,25 @@ static int xt_dv_check(xt_value view, xt_value indexValue, uint32_t width, uint3
|
|
|
207
232
|
}
|
|
208
233
|
|
|
209
234
|
static uint64_t xt_dv_read_bits(xt_value view, uint32_t offset, uint32_t width, int little) {
|
|
210
|
-
|
|
235
|
+
uint32_t length = 0;
|
|
236
|
+
uint8_t *bytes = xt_array_buffer_bytes(xt_dv_buffer(view), &length);
|
|
211
237
|
uint64_t value = 0;
|
|
238
|
+
if (bytes == NULL || offset + width > length) return 0;
|
|
212
239
|
for (uint32_t i = 0; i < width; i++) {
|
|
213
240
|
uint32_t index = little ? offset + width - 1 - i : offset + i;
|
|
214
|
-
|
|
215
|
-
value = (value << 8) | (byte & 0xff);
|
|
241
|
+
value = (value << 8) | (uint64_t)bytes[index];
|
|
216
242
|
}
|
|
217
243
|
return value;
|
|
218
244
|
}
|
|
219
245
|
|
|
220
246
|
static void xt_dv_write_bits(xt_value view, uint32_t offset, uint32_t width, uint64_t value,
|
|
221
247
|
int little) {
|
|
222
|
-
|
|
248
|
+
uint32_t length = 0;
|
|
249
|
+
uint8_t *bytes = xt_array_buffer_bytes(xt_dv_buffer(view), &length);
|
|
250
|
+
if (bytes == NULL || offset + width > length) return;
|
|
223
251
|
for (uint32_t i = 0; i < width; i++) {
|
|
224
252
|
uint32_t shift = little ? i * 8 : (width - 1 - i) * 8;
|
|
225
|
-
|
|
226
|
-
xt_set(data, xt_number((double)index), xt_number((double)((value >> shift) & 0xff)));
|
|
253
|
+
bytes[offset + i] = (uint8_t)((value >> shift) & 0xff);
|
|
227
254
|
}
|
|
228
255
|
}
|
|
229
256
|
|
|
@@ -312,3 +339,4 @@ xt_value xt_data_view_ctor(int32_t argc, xt_value *argv) {
|
|
|
312
339
|
}
|
|
313
340
|
return view;
|
|
314
341
|
}
|
|
342
|
+
|
package/runtime/xt_async_io.c
CHANGED
|
@@ -230,6 +230,9 @@ static void xt_async_register_roots(void) {
|
|
|
230
230
|
/* -- worker threads -------------------------------------------------------- */
|
|
231
231
|
|
|
232
232
|
static void xt_async_worker_run(void) {
|
|
233
|
+
/* Workers allocate result values but must never collect: the collector scans
|
|
234
|
+
* the main thread's stack region and is not thread-safe. */
|
|
235
|
+
xt_gc_worker_thread = 1;
|
|
233
236
|
for (;;) {
|
|
234
237
|
XT_ASYNC_LOCK();
|
|
235
238
|
xt_async_job *job = xt_async_pop_work();
|
package/runtime/xt_builtins.c
CHANGED
|
@@ -117,7 +117,7 @@ xt_value xt_object_rest(xt_value source, int32_t argc, xt_value *argv) {
|
|
|
117
117
|
if (!XT_IS_OBJECT(source) && !XT_IS_FUNCTION(source)) return result;
|
|
118
118
|
xt_object *object = xt_as_object(source);
|
|
119
119
|
if (!object) return result;
|
|
120
|
-
if (object->header.kind
|
|
120
|
+
if (!xt_kind_is_object(object->header.kind)) {
|
|
121
121
|
/* Map/Set/Date/RegExp/Promise have no own enumerable string properties. */
|
|
122
122
|
return result;
|
|
123
123
|
}
|
|
@@ -385,28 +385,6 @@ XT_BUILTIN_TRAMPOLINE(xt_builtin_value_queueMicrotask, xt_queue_microtask)
|
|
|
385
385
|
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_structuredClone, xt_structured_clone)
|
|
386
386
|
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_fetch, xt_fetch)
|
|
387
387
|
|
|
388
|
-
xt_value xt_in(xt_value key, xt_value value) {
|
|
389
|
-
if (XT_IS_OBJECT(value)) return xt_object_has(value, key);
|
|
390
|
-
if (XT_IS_ARRAY(value)) {
|
|
391
|
-
if (xt_is_symbol(key)) {
|
|
392
|
-
xt_array *array = (xt_array *)XT_GET_PTR(value);
|
|
393
|
-
if (!XT_IS_OBJECT(array->extra)) return XT_FALSE;
|
|
394
|
-
return xt_object_has_own(array->extra, key);
|
|
395
|
-
}
|
|
396
|
-
int32_t index = xt_to_int32(key);
|
|
397
|
-
return xt_bool(index >= 0 && (uint32_t)index < xt_as_array(value)->length);
|
|
398
|
-
}
|
|
399
|
-
if (XT_IS_STRING(value)) {
|
|
400
|
-
if (xt_is_symbol(key)) return XT_FALSE;
|
|
401
|
-
xt_string *s = xt_as_string(value);
|
|
402
|
-
xt_string *k = xt_as_string(xt_to_string(key));
|
|
403
|
-
if (k->length == 6 && memcmp(xt_string_bytes(k), "length", 6) == 0) return XT_TRUE;
|
|
404
|
-
int32_t index = xt_to_int32(key);
|
|
405
|
-
return xt_bool(index >= 0 && (uint32_t)index < xt_string_utf16_length(s));
|
|
406
|
-
}
|
|
407
|
-
return XT_FALSE;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
388
|
xt_value xt_rest_args(int32_t argc, xt_value *argv, int32_t start) {
|
|
411
389
|
if (start < 0) start = 0;
|
|
412
390
|
int32_t count = argc - start;
|
|
@@ -443,6 +421,7 @@ xt_value xt_closure_new(void *fn, int32_t env_count, xt_value *env) {
|
|
|
443
421
|
}
|
|
444
422
|
|
|
445
423
|
xt_value xt_closure_call(xt_value value, int32_t argc, xt_value *argv) {
|
|
424
|
+
XT_PROFILE_TICK(XT_PROFILE_CLOSURE_CALL);
|
|
446
425
|
return xt_call_with_this(value, XT_UNDEFINED, argc, argv);
|
|
447
426
|
}
|
|
448
427
|
|
|
@@ -482,13 +461,38 @@ xt_value xt_new(xt_value ctor, int32_t argc, xt_value *argv) {
|
|
|
482
461
|
return XT_UNDEFINED;
|
|
483
462
|
}
|
|
484
463
|
xt_function *function = (xt_function *)XT_GET_PTR(ctor);
|
|
485
|
-
|
|
464
|
+
/* Share the lazily created `.prototype` with `ctor.prototype`, so ES5 code
|
|
465
|
+
* that assigns methods after the declaration builds a working chain. */
|
|
466
|
+
xt_value proto = xt_function_prototype_object(ctor);
|
|
486
467
|
xt_value instance = xt_object_new_with_proto(XT_IS_OBJECT(proto) ? proto : XT_UNDEFINED);
|
|
487
468
|
xt_value result = function->code(instance, ctor, argc, argv);
|
|
488
469
|
if (XT_IS_OBJECT(result) || XT_IS_ARRAY(result) || XT_IS_FUNCTION(result)) return result;
|
|
489
470
|
return instance;
|
|
490
471
|
}
|
|
491
472
|
|
|
473
|
+
/* The global object (`globalThis`, and Node's alias `global`).
|
|
474
|
+
*
|
|
475
|
+
* xbintsc resolves a bare global *name* directly (there is no scope object), so
|
|
476
|
+
* this object is a plain property bag: it exists for code that treats the
|
|
477
|
+
* global object as a value — feature probes, `global[key]` lookups, and
|
|
478
|
+
* libraries that publish state under a symbol key on `global`. Property access
|
|
479
|
+
* spelled `globalThis.foo` still lowers to the bare global `foo`, so the two
|
|
480
|
+
* forms agree for names the compiler knows; a miss simply reads `undefined`. */
|
|
481
|
+
static xt_value g_global_object = XT_UNDEFINED;
|
|
482
|
+
static int g_global_object_rooted = 0;
|
|
483
|
+
|
|
484
|
+
xt_value xt_global_object(void) {
|
|
485
|
+
if (g_global_object == XT_UNDEFINED) {
|
|
486
|
+
g_global_object = xt_object_new();
|
|
487
|
+
if (!g_global_object_rooted) {
|
|
488
|
+
xt_gc_add_root_range(&g_global_object, 1);
|
|
489
|
+
g_global_object_rooted = 1;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return g_global_object;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
|
|
492
496
|
xt_value xt_instance_of(xt_value value, xt_value ctor) {
|
|
493
497
|
if (!XT_IS_FUNCTION(ctor)) return XT_FALSE;
|
|
494
498
|
xt_value proto = ((xt_function *)XT_GET_PTR(ctor))->prototype;
|
|
@@ -592,3 +596,4 @@ xt_value xt_function_set_metadata(xt_value value, xt_value name, int32_t arity)
|
|
|
592
596
|
return value;
|
|
593
597
|
}
|
|
594
598
|
|
|
599
|
+
|
|
@@ -40,6 +40,11 @@ xt_value xt_count_queuing_strategy_ctor(int32_t argc, xt_value *argv);
|
|
|
40
40
|
xt_value xt_byte_length_queuing_strategy_ctor(int32_t argc, xt_value *argv);
|
|
41
41
|
xt_value xt_text_encoder_stream_ctor(int32_t argc, xt_value *argv);
|
|
42
42
|
xt_value xt_text_decoder_stream_ctor(int32_t argc, xt_value *argv);
|
|
43
|
+
/* DataView's constructor and ArrayBuffer's statics live with the ArrayBuffer
|
|
44
|
+
* implementation; the proxy constructor lives with its hooks. */
|
|
45
|
+
xt_value xt_data_view_ctor(int32_t argc, xt_value *argv);
|
|
46
|
+
xt_value xt_proxy_ctor(int32_t argc, xt_value *argv);
|
|
47
|
+
xt_value xt_array_buffer_static(xt_value method, int32_t argc, xt_value *argv);
|
|
43
48
|
int xt_streams_has_static(const char *name, const char *method);
|
|
44
49
|
xt_value xt_streams_static(xt_value name, int32_t argc, xt_value *argv);
|
|
45
50
|
|
|
@@ -54,7 +59,11 @@ enum {
|
|
|
54
59
|
XT_PROTO_WRITABLE_STREAM,
|
|
55
60
|
XT_PROTO_TRANSFORM_STREAM,
|
|
56
61
|
XT_PROTO_COUNT_STRATEGY,
|
|
57
|
-
XT_PROTO_BYTE_STRATEGY
|
|
62
|
+
XT_PROTO_BYTE_STRATEGY,
|
|
63
|
+
XT_PROTO_ABORT_CONTROLLER,
|
|
64
|
+
XT_PROTO_ABORT_SIGNAL,
|
|
65
|
+
XT_PROTO_HEADERS,
|
|
66
|
+
XT_PROTO_RESPONSE
|
|
58
67
|
};
|
|
59
68
|
|
|
60
69
|
typedef struct {
|
|
@@ -104,7 +113,14 @@ typedef struct {
|
|
|
104
113
|
X(CountQueuingStrategy, 1, XT_PROTO_COUNT_STRATEGY) \
|
|
105
114
|
X(ByteLengthQueuingStrategy, 1, XT_PROTO_BYTE_STRATEGY) \
|
|
106
115
|
X(TextEncoderStream, 0, XT_PROTO_TRANSFORM_STREAM) \
|
|
107
|
-
X(TextDecoderStream, 0, XT_PROTO_TRANSFORM_STREAM)
|
|
116
|
+
X(TextDecoderStream, 0, XT_PROTO_TRANSFORM_STREAM) \
|
|
117
|
+
X(AbortController, 0, XT_PROTO_ABORT_CONTROLLER) \
|
|
118
|
+
X(AbortSignal, 0, XT_PROTO_ABORT_SIGNAL) \
|
|
119
|
+
X(Headers, 1, XT_PROTO_HEADERS) \
|
|
120
|
+
X(Response, 2, XT_PROTO_RESPONSE) \
|
|
121
|
+
X(ArrayBuffer, 1, XT_PROTO_PLAIN) \
|
|
122
|
+
X(DataView, 1, XT_PROTO_PLAIN) \
|
|
123
|
+
X(Proxy, 2, XT_PROTO_PLAIN)
|
|
108
124
|
|
|
109
125
|
#define XT_CTOR_ENUM(name, arity, proto) XT_CTOR_##name,
|
|
110
126
|
enum { XT_CTOR_SPECS(XT_CTOR_ENUM) XT_CTOR_COUNT };
|
|
@@ -220,6 +236,13 @@ static xt_value xt_builtin_ctor_call(const char *name, int32_t argc, xt_value *a
|
|
|
220
236
|
if (strcmp(name, "ByteLengthQueuingStrategy") == 0) return xt_byte_length_queuing_strategy_ctor(argc, argv);
|
|
221
237
|
if (strcmp(name, "TextEncoderStream") == 0) return xt_text_encoder_stream_ctor(argc, argv);
|
|
222
238
|
if (strcmp(name, "TextDecoderStream") == 0) return xt_text_decoder_stream_ctor(argc, argv);
|
|
239
|
+
if (strcmp(name, "AbortController") == 0) return xt_abort_controller_ctor(argc, argv);
|
|
240
|
+
if (strcmp(name, "AbortSignal") == 0) return xt_abort_signal_ctor(argc, argv);
|
|
241
|
+
if (strcmp(name, "Headers") == 0) return xt_headers_ctor(argc, argv);
|
|
242
|
+
if (strcmp(name, "Response") == 0) return xt_response_ctor(argc, argv);
|
|
243
|
+
if (strcmp(name, "ArrayBuffer") == 0) return xt_array_buffer_ctor(argc, argv);
|
|
244
|
+
if (strcmp(name, "DataView") == 0) return xt_data_view_ctor(argc, argv);
|
|
245
|
+
if (strcmp(name, "Proxy") == 0) return xt_proxy_ctor(argc, argv);
|
|
223
246
|
if (xt_ctor_is_typed_array(name)) return xt_typed_array_ctor_by_name(nameValue, argc, argv);
|
|
224
247
|
if (xt_ctor_is_error(name)) return xt_error_ctor_by_name(nameValue, argc, argv);
|
|
225
248
|
return XT_UNDEFINED;
|
|
@@ -261,10 +284,21 @@ static xt_value xt_ctor_prototype(int index, xt_value nameValue) {
|
|
|
261
284
|
return xt_stream_count_strategy_proto();
|
|
262
285
|
case XT_PROTO_BYTE_STRATEGY:
|
|
263
286
|
return xt_stream_byte_strategy_proto();
|
|
287
|
+
case XT_PROTO_ABORT_CONTROLLER:
|
|
288
|
+
return xt_web_abort_controller_proto();
|
|
289
|
+
case XT_PROTO_ABORT_SIGNAL:
|
|
290
|
+
return xt_web_abort_signal_proto();
|
|
291
|
+
case XT_PROTO_HEADERS:
|
|
292
|
+
return xt_web_headers_proto();
|
|
293
|
+
case XT_PROTO_RESPONSE:
|
|
294
|
+
return xt_web_response_proto();
|
|
264
295
|
case XT_PROTO_PLAIN:
|
|
265
296
|
default:
|
|
266
297
|
if (xt_ctor_plain_protos[index] == XT_UNDEFINED) {
|
|
267
298
|
xt_ctor_plain_protos[index] = xt_object_new();
|
|
299
|
+
/* `Map.prototype.get`, `String.prototype.slice`, ... are ordinary
|
|
300
|
+
* values; libraries bind them (`Map.prototype.get.bind(map)`). */
|
|
301
|
+
xt_install_proto_methods(xt_ctor_plain_protos[index], spec->name);
|
|
268
302
|
}
|
|
269
303
|
return xt_ctor_plain_protos[index];
|
|
270
304
|
}
|
|
@@ -337,6 +371,8 @@ static const char *const XT_DATE_STATICS[] = {"now", "parse", "UTC"};
|
|
|
337
371
|
static const char *const XT_PROMISE_STATICS[] = {
|
|
338
372
|
"resolve", "reject", "all", "allSettled", "race", "any", "withResolvers",
|
|
339
373
|
};
|
|
374
|
+
static const char *const XT_ABORT_SIGNAL_STATICS[] = {"abort", "timeout", "any"};
|
|
375
|
+
static const char *const XT_ARRAY_BUFFER_STATICS[] = {"isView"};
|
|
340
376
|
static const char *const XT_TYPED_ARRAY_STATICS[] = {"from", "of"};
|
|
341
377
|
|
|
342
378
|
static int xt_name_in(const char *name, const char *const *names, size_t count) {
|
|
@@ -367,6 +403,10 @@ static int xt_ctor_has_static(const char *namespace, const char *method) {
|
|
|
367
403
|
return xt_name_in(method, XT_PROMISE_STATICS, XT_NAMES_COUNT(XT_PROMISE_STATICS));
|
|
368
404
|
if (xt_ctor_is_typed_array(namespace))
|
|
369
405
|
return xt_name_in(method, XT_TYPED_ARRAY_STATICS, XT_NAMES_COUNT(XT_TYPED_ARRAY_STATICS));
|
|
406
|
+
if (strcmp(namespace, "AbortSignal") == 0)
|
|
407
|
+
return xt_name_in(method, XT_ABORT_SIGNAL_STATICS, XT_NAMES_COUNT(XT_ABORT_SIGNAL_STATICS));
|
|
408
|
+
if (strcmp(namespace, "ArrayBuffer") == 0)
|
|
409
|
+
return xt_name_in(method, XT_ARRAY_BUFFER_STATICS, XT_NAMES_COUNT(XT_ARRAY_BUFFER_STATICS));
|
|
370
410
|
if (xt_streams_has_static(namespace, method)) return 1;
|
|
371
411
|
return 0;
|
|
372
412
|
}
|
|
@@ -385,6 +425,8 @@ static xt_value xt_builtin_static_call(const char *namespace, const char *method
|
|
|
385
425
|
if (strcmp(namespace, "Promise") == 0) return xt_promise_static(methodValue, argc, argv);
|
|
386
426
|
if (xt_ctor_is_typed_array(namespace))
|
|
387
427
|
return xt_typed_array_static_by_name(nameValue, methodValue, argc, argv);
|
|
428
|
+
if (strcmp(namespace, "AbortSignal") == 0) return xt_abort_signal_static(methodValue, argc, argv);
|
|
429
|
+
if (strcmp(namespace, "ArrayBuffer") == 0) return xt_array_buffer_static(methodValue, argc, argv);
|
|
388
430
|
if (xt_streams_has_static(namespace, method)) return xt_streams_static(methodValue, argc, argv);
|
|
389
431
|
return XT_UNDEFINED;
|
|
390
432
|
}
|
|
@@ -445,8 +487,66 @@ xt_value xt_builtin_prototype_for_kind(int32_t kind) {
|
|
|
445
487
|
case XT_OBJECT_KIND_REGEXP: name = "RegExp"; break;
|
|
446
488
|
case XT_OBJECT_KIND_PROMISE: name = "Promise"; break;
|
|
447
489
|
case XT_OBJECT_KIND_SYMBOL: name = "Symbol"; break;
|
|
490
|
+
case XT_OBJECT_KIND_ARRAY_BUFFER: name = "ArrayBuffer"; break;
|
|
448
491
|
default: return XT_UNDEFINED;
|
|
449
492
|
}
|
|
450
493
|
xt_value constructor = xt_builtin_constructor(xt_string_from_cstr(name));
|
|
451
494
|
return xt_function_get_prototype(constructor);
|
|
452
495
|
}
|
|
496
|
+
|
|
497
|
+
/*
|
|
498
|
+
* `super(...)` and the `extends` prototype link.
|
|
499
|
+
*
|
|
500
|
+
* A class statement chains its prototype onto the parent class's prototype and
|
|
501
|
+
* runs the parent constructor from the derived one. A user class publishes its
|
|
502
|
+
* constructor closure as `__ctor` on its prototype, which is what a subclass's
|
|
503
|
+
* `super(...)` must run. A native/extension class (`class X extends
|
|
504
|
+
* EventEmitter`) has no such hook: its constructor function is the class
|
|
505
|
+
* value's own [[Prototype]] (the class statement links the two for static
|
|
506
|
+
* inheritance), and its prototype object only exists once it has constructed
|
|
507
|
+
* something. Both helpers hide that difference from the code generator.
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
xt_value xt_super_construct(xt_value thisValue, xt_value owner, xt_value parentProto,
|
|
511
|
+
int32_t argc, xt_value *argv) {
|
|
512
|
+
xt_value ctor = xt_get(parentProto, xt_string_from_cstr("__ctor"));
|
|
513
|
+
if (XT_IS_FUNCTION(ctor)) return xt_call_with_this(ctor, thisValue, argc, argv);
|
|
514
|
+
xt_value parentCtor = xt_object_get_prototype(owner);
|
|
515
|
+
if (!XT_IS_FUNCTION(parentCtor)) return XT_UNDEFINED;
|
|
516
|
+
/* Run the parent constructor and carry over the state it put on the instance
|
|
517
|
+
* it allocated. Constructors exposed this way (EventEmitter, the streams) are
|
|
518
|
+
* stateful only in lazily created properties, so this is usually a no-op. */
|
|
519
|
+
xt_value parent = xt_new(parentCtor, argc, argv);
|
|
520
|
+
if (!XT_IS_OBJECT(parent)) return thisValue;
|
|
521
|
+
xt_value keys = xt_object_keys(parent);
|
|
522
|
+
int32_t count = (int32_t)xt_to_number(xt_array_length(keys));
|
|
523
|
+
for (int32_t index = 0; index < count; index++) {
|
|
524
|
+
xt_value key = xt_array_get(keys, xt_number((double)index));
|
|
525
|
+
xt_set(thisValue, key, xt_get(parent, key));
|
|
526
|
+
}
|
|
527
|
+
return thisValue;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
xt_value xt_parent_prototype(xt_value ctor) {
|
|
531
|
+
if (!XT_IS_FUNCTION(ctor)) return XT_UNDEFINED;
|
|
532
|
+
/* A class value publishes its prototype object. Every other callable gets the
|
|
533
|
+
* lazily created plain object a function's `.prototype` is in JavaScript —
|
|
534
|
+
* never an instance: `class X extends SomeConstructor` must not run the
|
|
535
|
+
* parent's body at class-definition time (it may need arguments, or have
|
|
536
|
+
* side effects the program did not ask for). An extension class that wants a
|
|
537
|
+
* real prototype publishes it when its constructor value is built. */
|
|
538
|
+
return xt_function_prototype_object(ctor);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/* `new <name>(...)` where the callee is not a constructor: name the callee so
|
|
542
|
+
* the error points at the source (`new missing.Thing()`), not at nothing. */
|
|
543
|
+
xt_value xt_new_named(xt_value ctor, xt_value name, int32_t argc, xt_value *argv) {
|
|
544
|
+
if (!XT_IS_FUNCTION(ctor)) {
|
|
545
|
+
xt_value label = XT_IS_STRING(name) ? name : xt_string_from_cstr("(expression)");
|
|
546
|
+
xt_value message = xt_add(xt_string_from_cstr("TypeError: new "),
|
|
547
|
+
xt_add(label, xt_string_from_cstr(" is not a constructor")));
|
|
548
|
+
xt_throw(xt_error_from_message(xt_string_data(message)));
|
|
549
|
+
return XT_UNDEFINED;
|
|
550
|
+
}
|
|
551
|
+
return xt_new(ctor, argc, argv);
|
|
552
|
+
}
|