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
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
/* Generic member access */
|
|
3
3
|
/* ------------------------------------------------------------------------- */
|
|
4
4
|
|
|
5
|
+
/* Whether `key` is a canonical array index (`0 .. 2^32-2`, integral). Returns
|
|
6
|
+
* 1 when it is, 0 for a non-numeric key and -1 for a numeric non-index
|
|
7
|
+
* (`1.5`, `-1`, `2^32`), which is an ordinary property name — `arr[1.5]` must
|
|
8
|
+
* not read element 1. */
|
|
9
|
+
static int xt_index_key(xt_value key, uint32_t *index) {
|
|
10
|
+
if (!XT_IS_NUMBER(key)) return 0;
|
|
11
|
+
double raw = xt_to_double(key);
|
|
12
|
+
if (!(raw >= 0) || raw > 4294967294.0) return -1;
|
|
13
|
+
uint32_t truncated = (uint32_t)raw;
|
|
14
|
+
if ((double)truncated != raw) return -1;
|
|
15
|
+
*index = truncated;
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
/* Inherited lookup for values whose representation is not an `xt_object`
|
|
6
20
|
* property table (Map/Set/Date/RegExp/Promise/Symbol). `__proto__` returns the
|
|
7
21
|
* prototype itself instead of invoking Object.prototype's getter with the
|
|
@@ -236,15 +250,27 @@ xt_value xt_get(xt_value target, xt_value key) { if (target == XT_UNDEFINED ||
|
|
|
236
250
|
uint32_t index = 0;
|
|
237
251
|
if (xt_key_is_array_index(k, &index)) return xt_typed_array_read(target, index);
|
|
238
252
|
} else if (XT_IS_NUMBER(key)) {
|
|
239
|
-
|
|
240
|
-
if (index
|
|
253
|
+
uint32_t index = 0;
|
|
254
|
+
if (xt_index_key(key, &index) > 0) return xt_typed_array_read(target, index);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/* An ArrayBuffer's `byteLength` and `slice` are not own properties: an
|
|
258
|
+
* ArrayBuffer has no enumerable keys, so `Object.keys(buffer)` is empty
|
|
259
|
+
* like on the platform. */
|
|
260
|
+
if (obj->header.kind == XT_OBJECT_KIND_ARRAY_BUFFER && XT_IS_STRING(key)) {
|
|
261
|
+
xt_string *k = xt_as_string(key);
|
|
262
|
+
if (k->length == 10 && memcmp(xt_string_bytes(k), "byteLength", 10) == 0) {
|
|
263
|
+
return xt_number((double)obj->buffer_length);
|
|
264
|
+
}
|
|
265
|
+
if (k->length == 5 && memcmp(xt_string_bytes(k), "slice", 5) == 0) {
|
|
266
|
+
return xt_array_buffer_slice_value();
|
|
241
267
|
}
|
|
242
268
|
}
|
|
243
269
|
xt_value value = xt_object_get(target, key);
|
|
244
270
|
if (value != XT_UNDEFINED) return value;
|
|
245
271
|
xt_value method = xt_method_value(target, key);
|
|
246
272
|
if (method != XT_UNDEFINED) return method;
|
|
247
|
-
if (obj->header.kind
|
|
273
|
+
if (!xt_kind_is_object(obj->header.kind)) {
|
|
248
274
|
return xt_get_inherited(target, key);
|
|
249
275
|
}
|
|
250
276
|
return XT_UNDEFINED;
|
|
@@ -283,9 +309,10 @@ xt_value xt_get(xt_value target, xt_value key) { if (target == XT_UNDEFINED ||
|
|
|
283
309
|
* errors use the cache; arrays, functions, strings and containers fall back to
|
|
284
310
|
* the generic path. */
|
|
285
311
|
xt_value xt_get_ic(xt_value target, xt_value key, int64_t *cache) {
|
|
312
|
+
XT_PROFILE_TICK(XT_PROFILE_GET_IC);
|
|
286
313
|
if (!cache || !XT_IS_OBJECT(target)) return xt_get(target, key);
|
|
287
314
|
xt_object *obj = (xt_object *)XT_GET_PTR(target);
|
|
288
|
-
if (obj->header.kind
|
|
315
|
+
if (!xt_kind_is_object(obj->header.kind)) {
|
|
289
316
|
return xt_get(target, key);
|
|
290
317
|
}
|
|
291
318
|
/* A host view answers keys dynamically, outside the shape cache. */
|
|
@@ -319,7 +346,58 @@ xt_value xt_get_ic(xt_value target, xt_value key, int64_t *cache) {
|
|
|
319
346
|
return xt_get(target, key);
|
|
320
347
|
}
|
|
321
348
|
|
|
349
|
+
/* ------------------------------------------------------------------------- */
|
|
350
|
+
/* Element access (`obj[key]`) */
|
|
351
|
+
/* ------------------------------------------------------------------------- */
|
|
352
|
+
|
|
353
|
+
/*
|
|
354
|
+
* `obj[key]` is the hottest access in array/geometry code, and its receiver is
|
|
355
|
+
* almost always a typed array or a plain array. Those two shapes are answered
|
|
356
|
+
* here in a handful of instructions (a kind check, a numeric-key test and a
|
|
357
|
+
* bounds check) instead of walking the general `xt_get` dispatch and its
|
|
358
|
+
* per-kind branches. Everything else — string keys on objects, Map/Set, host
|
|
359
|
+
* views, out-of-range or negative keys — falls through to the ordinary
|
|
360
|
+
* `xt_get_ic` / `xt_set` paths, so semantics are unchanged.
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
/* ------------------------------------------------------------------------- */
|
|
364
|
+
/* Element access (`obj[key]`) */
|
|
365
|
+
/* ------------------------------------------------------------------------- */
|
|
366
|
+
|
|
367
|
+
xt_value xt_get_element(xt_value target, xt_value key, int64_t *cache) {
|
|
368
|
+
uint32_t index = 0;
|
|
369
|
+
if (XT_IS_ARRAY(target)) {
|
|
370
|
+
int isIndex = xt_index_key(key, &index);
|
|
371
|
+
if (isIndex > 0) return xt_array_get(target, key);
|
|
372
|
+
} else if (XT_IS_OBJECT(target)) {
|
|
373
|
+
xt_object *object = (xt_object *)XT_GET_PTR(target);
|
|
374
|
+
if (object->header.kind == XT_OBJECT_KIND_OBJECT && object->view_bytes != NULL &&
|
|
375
|
+
xt_index_key(key, &index) > 0) {
|
|
376
|
+
return xt_typed_array_read(target, index);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return xt_get_ic(target, key, cache);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
xt_value xt_set_element(xt_value target, xt_value key, xt_value value) {
|
|
383
|
+
uint32_t index = 0;
|
|
384
|
+
if (XT_IS_ARRAY(target)) {
|
|
385
|
+
int isIndex = xt_index_key(key, &index);
|
|
386
|
+
if (isIndex > 0) return xt_array_set(target, key, value);
|
|
387
|
+
} else if (XT_IS_OBJECT(target)) {
|
|
388
|
+
xt_object *object = (xt_object *)XT_GET_PTR(target);
|
|
389
|
+
if (object->header.kind == XT_OBJECT_KIND_OBJECT && object->view_bytes != NULL &&
|
|
390
|
+
xt_index_key(key, &index) > 0) {
|
|
391
|
+
/* Out-of-range writes to a typed array are ignored, like the platform. */
|
|
392
|
+
xt_typed_array_write(target, index, value);
|
|
393
|
+
return value;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return xt_set(target, key, value);
|
|
397
|
+
}
|
|
398
|
+
|
|
322
399
|
xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
400
|
+
XT_PROFILE_TICK(XT_PROFILE_SET);
|
|
323
401
|
if (XT_IS_ARRAY(target)) {
|
|
324
402
|
/* Assigning `arr.length` truncates or extends the array. */
|
|
325
403
|
if (XT_IS_STRING(key)) {
|
|
@@ -361,11 +439,9 @@ xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
|
361
439
|
uint32_t index = 0;
|
|
362
440
|
int isIndex = 0;
|
|
363
441
|
if (XT_IS_NUMBER(key)) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
isIndex = 1;
|
|
368
|
-
}
|
|
442
|
+
/* Only a canonical index names an element: `ta[1.5] = v` stores the
|
|
443
|
+
* property "1.5", exactly like the platform. */
|
|
444
|
+
isIndex = xt_index_key(key, &index) > 0;
|
|
369
445
|
} else if (XT_IS_STRING(key)) {
|
|
370
446
|
isIndex = xt_key_is_array_index(xt_as_string(key), &index);
|
|
371
447
|
}
|
|
@@ -376,6 +452,12 @@ xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
|
376
452
|
return value;
|
|
377
453
|
}
|
|
378
454
|
}
|
|
455
|
+
if (((xt_object *)XT_GET_PTR(target))->header.kind == XT_OBJECT_KIND_ARRAY_BUFFER &&
|
|
456
|
+
XT_IS_STRING(key)) {
|
|
457
|
+
/* `byteLength` is read-only (it is not an own property, see `xt_get`). */
|
|
458
|
+
xt_string *k = xt_as_string(key);
|
|
459
|
+
if (k->length == 10 && memcmp(xt_string_bytes(k), "byteLength", 10) == 0) return value;
|
|
460
|
+
}
|
|
379
461
|
if (((xt_object *)XT_GET_PTR(target))->header.kind == XT_OBJECT_KIND_REGEXP &&
|
|
380
462
|
XT_IS_STRING(key)) {
|
|
381
463
|
xt_string *k = xt_as_string(key);
|
|
@@ -396,7 +478,7 @@ xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
|
396
478
|
xt_value xt_object_set_hooks(xt_value value, const xt_object_hooks *hooks, void *data) {
|
|
397
479
|
xt_object *obj = xt_as_object(value);
|
|
398
480
|
if (!obj) return value;
|
|
399
|
-
if (obj->header.kind
|
|
481
|
+
if (!xt_kind_is_object(obj->header.kind)) {
|
|
400
482
|
return value;
|
|
401
483
|
}
|
|
402
484
|
obj->hooks = hooks;
|
|
@@ -468,7 +550,7 @@ xt_value xt_object_has_own(xt_value value, xt_value key) {
|
|
|
468
550
|
if (!obj) return XT_FALSE;
|
|
469
551
|
/* Map/Set/Date/RegExp/Promise/Symbol use their own struct layout and have no
|
|
470
552
|
* property bag; interpreting them as `xt_object` would read past the end. */
|
|
471
|
-
if (obj->header.kind
|
|
553
|
+
if (!xt_kind_is_object(obj->header.kind)) {
|
|
472
554
|
return XT_FALSE;
|
|
473
555
|
}
|
|
474
556
|
xt_value propertyKey = xt_to_property_key(key);
|
|
@@ -478,4 +560,35 @@ xt_value xt_object_has_own(xt_value value, xt_value key) {
|
|
|
478
560
|
return XT_TRUE;
|
|
479
561
|
}
|
|
480
562
|
return XT_FALSE;
|
|
481
|
-
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/* `length` / `name` / `prototype` are synthesised by `xt_get` for functions and
|
|
566
|
+
* have no property-bag entry, so `"length" in fn` must answer for them. */
|
|
567
|
+
static int xt_in_function_key(xt_value value, xt_value key) {
|
|
568
|
+
if (!XT_IS_FUNCTION(value) || !XT_IS_STRING(key)) return 0;
|
|
569
|
+
xt_string *k = xt_as_string(key);
|
|
570
|
+
if (k->length == 6 && memcmp(xt_string_bytes(k), "length", 6) == 0) return 1;
|
|
571
|
+
if (k->length == 4 && memcmp(xt_string_bytes(k), "name", 4) == 0) return 1;
|
|
572
|
+
if (k->length == 9 && memcmp(xt_string_bytes(k), "prototype", 9) == 0) return 1;
|
|
573
|
+
return 0;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/* `key in value`, including the prototype chain and the built-in methods that
|
|
577
|
+
* live in the runtime's method tables rather than in a property bag. Without
|
|
578
|
+
* this the operator only answered for own properties, so `"map" in []` and
|
|
579
|
+
* `"call" in someFunction` were false. */
|
|
580
|
+
xt_value xt_in(xt_value key, xt_value value) {
|
|
581
|
+
if (xt_truthy(xt_object_has_own(value, key))) return XT_TRUE;
|
|
582
|
+
if (xt_in_function_key(value, key)) return XT_TRUE;
|
|
583
|
+
if (xt_method_value(value, key) != XT_UNDEFINED) return XT_TRUE;
|
|
584
|
+
xt_value proto = xt_object_get_prototype(value);
|
|
585
|
+
while (proto != XT_UNDEFINED && proto != XT_NULL) {
|
|
586
|
+
if (xt_truthy(xt_object_has_own(proto, key))) return XT_TRUE;
|
|
587
|
+
if (xt_method_value(proto, key) != XT_UNDEFINED) return XT_TRUE;
|
|
588
|
+
proto = xt_object_get_prototype(proto);
|
|
589
|
+
}
|
|
590
|
+
return XT_FALSE;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
@@ -6,7 +6,7 @@ void xt_array_reserve(xt_array *array, uint32_t needed) {
|
|
|
6
6
|
if (needed <= array->capacity) return;
|
|
7
7
|
uint32_t capacity = array->capacity ? array->capacity * 2 : 8;
|
|
8
8
|
while (capacity < needed) capacity *= 2;
|
|
9
|
-
array->items = (xt_value *)
|
|
9
|
+
array->items = (xt_value *)xt_raw_realloc(array->items, sizeof(xt_value) * capacity);
|
|
10
10
|
if (!array->items) {
|
|
11
11
|
fprintf(stderr, "xbintsc: out of memory growing array\n");
|
|
12
12
|
abort();
|
|
@@ -64,6 +64,7 @@ static xt_value xt_array_extra(xt_array *array, int create) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
xt_value xt_array_get(xt_value value, xt_value index) {
|
|
67
|
+
XT_PROFILE_TICK(XT_PROFILE_ARRAY_GET);
|
|
67
68
|
if (!XT_IS_ARRAY(value)) return XT_UNDEFINED;
|
|
68
69
|
xt_array *array = (xt_array *)XT_GET_PTR(value);
|
|
69
70
|
int32_t i = xt_to_int32(index);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — interned C-string property lookups.
|
|
3
|
+
*
|
|
4
|
+
* Included by xt_containers.c after objects.inc; see xt_object_get_cstr`n * there for why the table exists.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* Convenience used by codegen for `obj.prop`.
|
|
8
|
+
*
|
|
9
|
+
* The C-string property lookups a host makes (`xt_object_get_cstr(w, "length")`
|
|
10
|
+
* from the GUI engine, the typed-array helpers, every runtime helper) used to
|
|
11
|
+
* allocate a fresh `xt_string` on every call. A three.js page made millions of
|
|
12
|
+
* them per second, which was most of the collector's allocation pressure. The
|
|
13
|
+
* table below interns the string by contents, so a repeated lookup reuses one
|
|
14
|
+
* heap string; the strings are roots because the table itself is invisible to
|
|
15
|
+
* the collector. */
|
|
16
|
+
#define XT_CSTR_CACHE_SLOTS 1024
|
|
17
|
+
|
|
18
|
+
static xt_value g_cstr_cache[XT_CSTR_CACHE_SLOTS];
|
|
19
|
+
static int g_cstr_cache_ready = 0;
|
|
20
|
+
|
|
21
|
+
xt_value xt_object_get_cstr(xt_value value, const char *key) {
|
|
22
|
+
if (key == NULL) return xt_object_get(value, XT_UNDEFINED);
|
|
23
|
+
if (xt_profile_on) xt_profile_note_cstr(key);
|
|
24
|
+
if (!g_cstr_cache_ready) {
|
|
25
|
+
/* Registered before the first entry is stored, so a collection can never
|
|
26
|
+
* see a half-populated cache. */
|
|
27
|
+
xt_gc_add_root_range(g_cstr_cache, XT_CSTR_CACHE_SLOTS);
|
|
28
|
+
g_cstr_cache_ready = 1;
|
|
29
|
+
}
|
|
30
|
+
const size_t length = strlen(key);
|
|
31
|
+
uint64_t hash = 1469598103934665603ull;
|
|
32
|
+
for (size_t i = 0; i < length; i++) {
|
|
33
|
+
hash ^= (unsigned char)key[i];
|
|
34
|
+
hash *= 1099511628211ull;
|
|
35
|
+
}
|
|
36
|
+
const size_t start = (size_t)(hash & (XT_CSTR_CACHE_SLOTS - 1));
|
|
37
|
+
for (size_t probe = 0; probe < 4; probe++) {
|
|
38
|
+
xt_value slot = g_cstr_cache[(start + probe) & (XT_CSTR_CACHE_SLOTS - 1)];
|
|
39
|
+
if (slot == 0) {
|
|
40
|
+
xt_value created = xt_string_from_cstr(key);
|
|
41
|
+
g_cstr_cache[(start + probe) & (XT_CSTR_CACHE_SLOTS - 1)] = created;
|
|
42
|
+
return xt_object_get(value, created);
|
|
43
|
+
}
|
|
44
|
+
if (xt_string_length_value(slot) == (int32_t)length && XT_IS_STRING(slot)) {
|
|
45
|
+
const char *text = xt_string_data(slot);
|
|
46
|
+
if (text != NULL && memcmp(text, key, length) == 0) return xt_object_get(value, slot);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/* Four probes collided: replace the primary slot. The evicted string stays
|
|
50
|
+
* alive while anything references it; a later lookup simply interns it
|
|
51
|
+
* again. */
|
|
52
|
+
xt_value created = xt_string_from_cstr(key);
|
|
53
|
+
g_cstr_cache[start] = created;
|
|
54
|
+
return xt_object_get(value, created);
|
|
55
|
+
}
|
|
56
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Function values and their `.prototype` objects.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `objects.inc` to keep both files inside the repository's
|
|
5
|
+
* length budget; included before it because `xt_object_get` resolves
|
|
6
|
+
* `fn.prototype` through `xt_function_prototype_object`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/* The `.prototype` object of a function value, created on first use with a
|
|
10
|
+
* `constructor` back-reference. `xt_new` and `fn.prototype` must agree on it so
|
|
11
|
+
* the ES5 pattern `function Foo() {}; Foo.prototype.bar = ...` keeps working.
|
|
12
|
+
*
|
|
13
|
+
* Every reference to a declared function builds a fresh closure value (`Foo`
|
|
14
|
+
* inside `Foo.prototype` is not the same value as the `Foo` used by `new`), so
|
|
15
|
+
* the prototype is keyed by the compiled code pointer and shared by all
|
|
16
|
+
* closures of that declaration. Without this, `new Foo()` had a different
|
|
17
|
+
* prototype than `Foo.prototype` and instance methods were invisible. */
|
|
18
|
+
typedef struct xt_function_proto_slot {
|
|
19
|
+
xt_code_fn code;
|
|
20
|
+
xt_value proto;
|
|
21
|
+
struct xt_function_proto_slot *next;
|
|
22
|
+
} xt_function_proto_slot;
|
|
23
|
+
|
|
24
|
+
static xt_function_proto_slot *xt_function_proto_slots = NULL;
|
|
25
|
+
static int xt_function_proto_registered = 0;
|
|
26
|
+
|
|
27
|
+
static void xt_function_proto_roots(void) {
|
|
28
|
+
for (xt_function_proto_slot *slot = xt_function_proto_slots; slot; slot = slot->next) {
|
|
29
|
+
xt_gc_mark_value(slot->proto);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
xt_value xt_function_prototype_object(xt_value value) {
|
|
34
|
+
if (!XT_IS_FUNCTION(value)) return XT_UNDEFINED;
|
|
35
|
+
xt_function *function = (xt_function *)XT_GET_PTR(value);
|
|
36
|
+
if (function->prototype != XT_UNDEFINED) return function->prototype;
|
|
37
|
+
if (!xt_function_proto_registered) {
|
|
38
|
+
xt_function_proto_registered = 1;
|
|
39
|
+
xt_gc_register_root_provider(xt_function_proto_roots);
|
|
40
|
+
}
|
|
41
|
+
for (xt_function_proto_slot *slot = xt_function_proto_slots; slot; slot = slot->next) {
|
|
42
|
+
if (slot->code == function->code) {
|
|
43
|
+
function->prototype = slot->proto;
|
|
44
|
+
return slot->proto;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
xt_value proto = xt_object_new();
|
|
48
|
+
xt_object_set(proto, xt_string_from_cstr("constructor"), value);
|
|
49
|
+
xt_function_proto_slot *slot = (xt_function_proto_slot *)malloc(sizeof(xt_function_proto_slot));
|
|
50
|
+
if (slot) {
|
|
51
|
+
slot->code = function->code;
|
|
52
|
+
slot->proto = proto;
|
|
53
|
+
slot->next = xt_function_proto_slots;
|
|
54
|
+
xt_function_proto_slots = slot;
|
|
55
|
+
}
|
|
56
|
+
function->prototype = proto;
|
|
57
|
+
return proto;
|
|
58
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Method calls with a monomorphic inline cache; included by xt_containers.c
|
|
3
|
+
* after access.inc.
|
|
4
|
+
*/
|
|
5
|
+
/* ------------------------------------------------------------------------- */
|
|
6
|
+
/* Method-call inline cache */
|
|
7
|
+
/* ------------------------------------------------------------------------- */
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* A method call used to resolve the callee on every invocation: the container
|
|
11
|
+
* and built-in dispatch tables, the receiver's own property bag, then a walk up
|
|
12
|
+
* the prototype chain (`new Vector3().applyMatrix4(m)` pays all of it per
|
|
13
|
+
* vertex). A monomorphic site — the common case in numeric code — always lands
|
|
14
|
+
* on the same *slot* of the same holder, so the cache records that holder and
|
|
15
|
+
* slot and re-reads the slot on a hit:
|
|
16
|
+
*
|
|
17
|
+
* - `cache[0]` is the holder: `0` means empty, `XT_UNDEFINED` the receiver
|
|
18
|
+
* itself, anything else is the prototype value the method was found on;
|
|
19
|
+
* - `cache[1]` is the holder's shape pointer and `cache[2]` the property
|
|
20
|
+
* index. The slot's key is compared on every hit, so a slot whose contents
|
|
21
|
+
* were deleted and reused cannot mis-dispatch;
|
|
22
|
+
* - the *value* is re-read rather than cached, so reassigning the method
|
|
23
|
+
* (`obj.f = other`) is observed immediately — exactly like the property IC.
|
|
24
|
+
*
|
|
25
|
+
* A hit still calls through `xt_call_with_this` (the closure ABI needs `this`),
|
|
26
|
+
* but skips the resolution. The cache is filled *after* a slow-path call, so it
|
|
27
|
+
* never changes what that call does; a receiver whose shape, holder or prototype
|
|
28
|
+
* changed simply misses again.
|
|
29
|
+
*/
|
|
30
|
+
static void xt_method_cache_fill(int64_t *cache, xt_value target, xt_value name) {
|
|
31
|
+
if (cache == NULL || !XT_IS_OBJECT(target)) return;
|
|
32
|
+
xt_object *object = (xt_object *)XT_GET_PTR(target);
|
|
33
|
+
if (object->header.kind != XT_OBJECT_KIND_OBJECT || object->hooks != NULL) return;
|
|
34
|
+
/* Only the receiver and its immediate prototype can be cached: the hit path
|
|
35
|
+
* checks `object->prototype == holder`, so a method found deeper in the chain
|
|
36
|
+
* would always miss anyway. */
|
|
37
|
+
xt_object *holder = object;
|
|
38
|
+
xt_value holderValue = XT_UNDEFINED;
|
|
39
|
+
xt_property *prop = xt_object_find(object, name);
|
|
40
|
+
if (prop == NULL) {
|
|
41
|
+
xt_value proto = object->prototype;
|
|
42
|
+
if (!XT_IS_OBJECT(proto)) return;
|
|
43
|
+
holderValue = proto;
|
|
44
|
+
holder = (xt_object *)XT_GET_PTR(proto);
|
|
45
|
+
if (holder->header.kind != XT_OBJECT_KIND_OBJECT || holder->hooks != NULL) return;
|
|
46
|
+
prop = xt_object_find(holder, name);
|
|
47
|
+
}
|
|
48
|
+
if (prop == NULL) return;
|
|
49
|
+
if (!XT_IS_FUNCTION(prop->value) || prop->getter != XT_UNDEFINED) return;
|
|
50
|
+
cache[0] = (int64_t)holderValue;
|
|
51
|
+
cache[1] = (int64_t)(uintptr_t)holder->shape;
|
|
52
|
+
cache[2] = (int64_t)(prop - holder->properties);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
xt_value xt_call_method_ic(xt_value target, xt_value name, int32_t argc, xt_value *argv,
|
|
56
|
+
int64_t *cache) {
|
|
57
|
+
XT_PROFILE_TICK(XT_PROFILE_METHOD_IC);
|
|
58
|
+
if (cache != NULL && (cache[0] != 0 || cache[1] != 0) && XT_IS_OBJECT(target)) {
|
|
59
|
+
xt_object *object = (xt_object *)XT_GET_PTR(target);
|
|
60
|
+
if (object->header.kind == XT_OBJECT_KIND_OBJECT && object->hooks == NULL) {
|
|
61
|
+
xt_object *holder = NULL;
|
|
62
|
+
int64_t holderValue = cache[0];
|
|
63
|
+
if ((xt_value)holderValue == XT_UNDEFINED) {
|
|
64
|
+
holder = object;
|
|
65
|
+
} else if (XT_IS_OBJECT((xt_value)holderValue) && object->prototype == (xt_value)holderValue) {
|
|
66
|
+
holder = (xt_object *)XT_GET_PTR((xt_value)holderValue);
|
|
67
|
+
if (holder->header.kind != XT_OBJECT_KIND_OBJECT || holder->hooks != NULL) holder = NULL;
|
|
68
|
+
}
|
|
69
|
+
if (holder != NULL) {
|
|
70
|
+
int64_t slot = cache[2];
|
|
71
|
+
if (holder->shape == (xt_shape *)(uintptr_t)cache[1] && slot >= 0 && slot < (int64_t)holder->count) {
|
|
72
|
+
xt_property *prop = &holder->properties[slot];
|
|
73
|
+
if (prop->getter == XT_UNDEFINED && XT_IS_FUNCTION(prop->value) &&
|
|
74
|
+
(prop->key == name || xt_property_key_equals(prop->key, name))) {
|
|
75
|
+
return xt_call_with_this(prop->value, target, argc, argv);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
xt_value result = xt_call_method(target, name, argc, argv);
|
|
82
|
+
xt_method_cache_fill(cache, target, name);
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Inline-cached property write, the store counterpart of `xt_get_ic`. A store
|
|
87
|
+
* site in a hot loop (three.js's `this.x = x` in every constructor, the page's
|
|
88
|
+
* per-vertex writes) used to resolve the property on every assignment: an own
|
|
89
|
+
* property scan, a prototype-chain walk for inherited setters, then the insert
|
|
90
|
+
* path. The cache records the receiver's shape and the slot the key lives in;
|
|
91
|
+
* a hit is a shape compare, a key check and one field write.
|
|
92
|
+
*
|
|
93
|
+
* The cache is filled *after* the generic store, and only for an own data
|
|
94
|
+
* property, so an accessor, a frozen object or a host view keeps the generic
|
|
95
|
+
* semantics. A shape change (a new property, a delete) misses and refills. */
|
|
96
|
+
xt_value xt_set_ic(xt_value target, xt_value key, xt_value value, int64_t *cache) {
|
|
97
|
+
XT_PROFILE_TICK(XT_PROFILE_SET);
|
|
98
|
+
if (cache != NULL && XT_IS_OBJECT(target)) {
|
|
99
|
+
xt_object *obj = (xt_object *)XT_GET_PTR(target);
|
|
100
|
+
if (obj->header.kind == XT_OBJECT_KIND_OBJECT && obj->hooks == NULL && !obj->frozen &&
|
|
101
|
+
obj->shape != NULL && (uintptr_t)cache[0] == (uintptr_t)obj->shape && cache[1] >= 0 &&
|
|
102
|
+
cache[1] < (int64_t)obj->count) {
|
|
103
|
+
xt_property *prop = &obj->properties[cache[1]];
|
|
104
|
+
if ((prop->key == key || xt_property_key_equals(prop->key, key)) &&
|
|
105
|
+
prop->getter == XT_UNDEFINED && prop->setter == XT_UNDEFINED) {
|
|
106
|
+
prop->value = value;
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
xt_value stored = xt_set(target, key, value);
|
|
111
|
+
if (obj->header.kind == XT_OBJECT_KIND_OBJECT && obj->hooks == NULL && !obj->frozen) {
|
|
112
|
+
xt_property *prop = xt_object_find(obj, xt_to_property_key(key));
|
|
113
|
+
if (prop != NULL && prop->getter == XT_UNDEFINED && prop->setter == XT_UNDEFINED) {
|
|
114
|
+
cache[0] = (int64_t)(uintptr_t)obj->shape;
|
|
115
|
+
cache[1] = (int64_t)(prop - obj->properties);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return stored;
|
|
119
|
+
}
|
|
120
|
+
return xt_set(target, key, value);
|
|
121
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
xt_value xt_object_keys(xt_value value) {
|
|
2
|
+
xt_value result = xt_array_new(0, NULL);
|
|
3
|
+
/* A typed array's enumerable own keys are its indices; `length` and the
|
|
4
|
+
* buffer metadata are observable but not enumerable. */
|
|
5
|
+
int typed = xt_typed_array_kind_of(value);
|
|
6
|
+
if (typed >= 0) {
|
|
7
|
+
uint32_t length = (uint32_t)xt_to_number(xt_object_get_cstr(value, "length"));
|
|
8
|
+
for (uint32_t i = 0; i < length; i++) {
|
|
9
|
+
char buffer[32];
|
|
10
|
+
snprintf(buffer, sizeof(buffer), "%u", i);
|
|
11
|
+
xt_array_push(result, xt_string_from_cstr(buffer));
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
if (XT_IS_OBJECT(value)) {
|
|
16
|
+
xt_object *obj = (xt_object *)XT_GET_PTR(value);
|
|
17
|
+
/* Map/Set/Date/RegExp/Promise/Symbol use their own layout and have no
|
|
18
|
+
* property bag; reading `obj->count` there walked off the end of the
|
|
19
|
+
* allocation (`Object.getOwnPropertyNames(new Map())` crashed). */
|
|
20
|
+
if (!xt_kind_is_object(obj->header.kind)) {
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
for (uint32_t i = 0; i < obj->count; i++) {
|
|
24
|
+
if (XT_IS_STRING(obj->properties[i].key)) xt_array_push(result, obj->properties[i].key);
|
|
25
|
+
}
|
|
26
|
+
/* Dynamic keys of a host view (`element.dataset`, ...), appended without
|
|
27
|
+
* repeating a real property that was just pushed. */
|
|
28
|
+
xt_object_append_dynamic_keys(obj, value, result);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
if (XT_IS_ARRAY(value)) {
|
|
32
|
+
xt_array *array = (xt_array *)XT_GET_PTR(value);
|
|
33
|
+
for (uint32_t i = 0; i < array->length; i++) {
|
|
34
|
+
char buffer[32];
|
|
35
|
+
snprintf(buffer, sizeof(buffer), "%u", i);
|
|
36
|
+
xt_array_push(result, xt_string_from_cstr(buffer));
|
|
37
|
+
}
|
|
38
|
+
if (XT_IS_OBJECT(array->extra)) {
|
|
39
|
+
xt_object *extra = (xt_object *)XT_GET_PTR(array->extra);
|
|
40
|
+
for (uint32_t i = 0; i < extra->count; i++) {
|
|
41
|
+
if (XT_IS_STRING(extra->properties[i].key)) xt_array_push(result, extra->properties[i].key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
if (XT_IS_STRING(value)) {
|
|
47
|
+
xt_string *s = xt_as_string(value);
|
|
48
|
+
uint32_t units = xt_string_utf16_length(s);
|
|
49
|
+
for (uint32_t i = 0; i < units; i++) {
|
|
50
|
+
char buffer[32];
|
|
51
|
+
snprintf(buffer, sizeof(buffer), "%u", i);
|
|
52
|
+
xt_array_push(result, xt_string_from_cstr(buffer));
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|