xbintsc 0.5.6 → 0.5.21
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/AGENTS.md +20 -10
- package/README.md +8 -7
- package/README.zh-CN.md +6 -6
- package/dist/src/binder/declarations.js +14 -3
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/cli/hints.js +7 -1
- package/dist/src/cli/hints.js.map +1 -1
- package/dist/src/cli/main.js +115 -15
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/cli/watch.d.ts +25 -0
- package/dist/src/cli/watch.js +93 -0
- package/dist/src/cli/watch.js.map +1 -0
- package/dist/src/codegen/generator/calls/access.js +11 -2
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/closures.js +12 -4
- package/dist/src/codegen/generator/calls/closures.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +8 -0
- package/dist/src/codegen/generator/context.js +22 -3
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/expressions/operators.js +17 -15
- package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.js +5 -0
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/module.js +0 -7
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/numeric.d.ts +6 -3
- package/dist/src/codegen/generator/numeric.js +54 -11
- package/dist/src/codegen/generator/numeric.js.map +1 -1
- package/dist/src/codegen/generator/state.js +23 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/control-flow.js +1 -4
- package/dist/src/codegen/generator/statements/control-flow.js.map +1 -1
- package/dist/src/codegen/generator/statements/loops.js +48 -16
- package/dist/src/codegen/generator/statements/loops.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +26 -1
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.d.ts +3 -1
- package/dist/src/diagnostics/diagnostic.js +23 -3
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/driver/app-artifacts.d.ts +42 -0
- package/dist/src/driver/app-artifacts.js +53 -0
- package/dist/src/driver/app-artifacts.js.map +1 -0
- package/dist/src/driver/build-key.d.ts +29 -0
- package/dist/src/driver/build-key.js +35 -0
- package/dist/src/driver/build-key.js.map +1 -0
- package/dist/src/driver/bundler/graph.js +61 -12
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +7 -1
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/compiler.d.ts +10 -67
- package/dist/src/driver/compiler.js +95 -234
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/config.d.ts +3 -0
- package/dist/src/driver/config.js +8 -0
- package/dist/src/driver/config.js.map +1 -1
- package/dist/src/driver/frontend.d.ts +37 -0
- package/dist/src/driver/frontend.js +92 -0
- package/dist/src/driver/frontend.js.map +1 -0
- package/dist/src/driver/index.d.ts +1 -1
- package/dist/src/driver/index.js.map +1 -1
- package/dist/src/driver/options.d.ts +64 -0
- package/dist/src/driver/options.js +9 -0
- package/dist/src/driver/options.js.map +1 -0
- package/dist/src/driver/runtime-objects.d.ts +38 -0
- package/dist/src/driver/runtime-objects.js +112 -0
- package/dist/src/driver/runtime-objects.js.map +1 -0
- package/dist/src/driver/toolchain-provider.d.ts +4 -0
- package/dist/src/driver/toolchain-provider.js +4 -0
- package/dist/src/driver/toolchain-provider.js.map +1 -1
- package/dist/src/driver/toolchain.d.ts +32 -1
- package/dist/src/driver/toolchain.js +115 -11
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +12 -0
- package/dist/src/driver/version.js +13 -0
- package/dist/src/driver/version.js.map +1 -0
- package/dist/src/driver/win-icon.d.ts +7 -9
- package/dist/src/driver/win-icon.js +37 -35
- package/dist/src/driver/win-icon.js.map +1 -1
- package/dist/src/extensions/node/fs/index.d.ts +4 -3
- package/dist/src/extensions/node/fs/index.js +12 -3
- package/dist/src/extensions/node/fs/index.js.map +1 -1
- package/dist/src/extensions/node/fs-promises/index.d.ts +5 -5
- package/dist/src/extensions/node/fs-promises/index.js +15 -6
- package/dist/src/extensions/node/fs-promises/index.js.map +1 -1
- package/dist/src/parser/declarations/classes.js +5 -0
- package/dist/src/parser/declarations/classes.js.map +1 -1
- package/dist/src/parser/declarations/functions.js +13 -1
- package/dist/src/parser/declarations/functions.js.map +1 -1
- package/dist/src/parser/modules.js +8 -3
- package/dist/src/parser/modules.js.map +1 -1
- package/dist/src/parser/parser.d.ts +1 -0
- package/dist/src/parser/parser.js +23 -0
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/tests/cli/check.test.d.ts +6 -0
- package/dist/tests/cli/check.test.js +68 -0
- package/dist/tests/cli/check.test.js.map +1 -0
- package/dist/tests/cli/main.test.js +19 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/cli/watch.test.d.ts +6 -0
- package/dist/tests/cli/watch.test.js +72 -0
- package/dist/tests/cli/watch.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +15 -3
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +16 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +8 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/docs/structure.test.d.ts +1 -0
- package/dist/tests/docs/structure.test.js +92 -0
- package/dist/tests/docs/structure.test.js.map +1 -0
- package/dist/tests/driver/compiler.test.js +6 -0
- package/dist/tests/driver/compiler.test.js.map +1 -1
- package/dist/tests/driver/config.test.js +9 -0
- package/dist/tests/driver/config.test.js.map +1 -1
- package/dist/tests/driver/icon.test.js +19 -32
- package/dist/tests/driver/icon.test.js.map +1 -1
- package/dist/tests/driver/invalid-input.test.d.ts +10 -0
- package/dist/tests/driver/invalid-input.test.js +29 -0
- package/dist/tests/driver/invalid-input.test.js.map +1 -0
- package/dist/tests/driver/modules.test.js +42 -3
- package/dist/tests/driver/modules.test.js.map +1 -1
- package/dist/tests/driver/toolchain-provider.test.js +27 -1
- package/dist/tests/driver/toolchain-provider.test.js.map +1 -1
- package/dist/tests/driver/toolchain.test.js +60 -2
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/e2e/array-buffer.test.d.ts +5 -0
- package/dist/tests/e2e/array-buffer.test.js +38 -0
- package/dist/tests/e2e/array-buffer.test.js.map +1 -0
- package/dist/tests/e2e/array-from-iterables.test.d.ts +7 -0
- package/dist/tests/e2e/array-from-iterables.test.js +34 -0
- package/dist/tests/e2e/array-from-iterables.test.js.map +1 -0
- package/dist/tests/e2e/array-symbol-iterator.test.d.ts +8 -0
- package/dist/tests/e2e/array-symbol-iterator.test.js +42 -0
- package/dist/tests/e2e/array-symbol-iterator.test.js.map +1 -0
- package/dist/tests/e2e/async-await.test.js +1 -1
- package/dist/tests/e2e/async-fs.test.d.ts +9 -0
- package/dist/tests/e2e/async-fs.test.js +119 -0
- package/dist/tests/e2e/async-fs.test.js.map +1 -0
- package/dist/tests/e2e/async-generators.test.d.ts +1 -0
- package/dist/tests/e2e/async-generators.test.js +154 -0
- package/dist/tests/e2e/async-generators.test.js.map +1 -0
- package/dist/tests/e2e/await-ordering.test.d.ts +5 -0
- package/dist/tests/e2e/await-ordering.test.js +37 -0
- package/dist/tests/e2e/await-ordering.test.js.map +1 -0
- package/dist/tests/e2e/compile-builtins.test.js +1 -1
- package/dist/tests/e2e/compile-modules.test.js +7 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/date-parse.test.d.ts +8 -0
- package/dist/tests/e2e/date-parse.test.js +38 -0
- package/dist/tests/e2e/date-parse.test.js.map +1 -0
- package/dist/tests/e2e/default-anonymous-exports.test.d.ts +7 -0
- package/dist/tests/e2e/default-anonymous-exports.test.js +23 -0
- package/dist/tests/e2e/default-anonymous-exports.test.js.map +1 -0
- package/dist/tests/e2e/fetch.test.js +24 -0
- package/dist/tests/e2e/fetch.test.js.map +1 -1
- package/dist/tests/e2e/globals-microtask.test.d.ts +9 -0
- package/dist/tests/e2e/globals-microtask.test.js +37 -0
- package/dist/tests/e2e/globals-microtask.test.js.map +1 -0
- package/dist/tests/e2e/gui-inline-svg.test.d.ts +11 -0
- package/dist/tests/e2e/gui-inline-svg.test.js +160 -0
- package/dist/tests/e2e/gui-inline-svg.test.js.map +1 -0
- package/dist/tests/e2e/gui-media.test.js +8 -1
- package/dist/tests/e2e/gui-media.test.js.map +1 -1
- package/dist/tests/e2e/inspect-builtins.test.d.ts +10 -0
- package/dist/tests/e2e/inspect-builtins.test.js +43 -0
- package/dist/tests/e2e/inspect-builtins.test.js.map +1 -0
- package/dist/tests/e2e/json-builtin-objects.test.d.ts +9 -0
- package/dist/tests/e2e/json-builtin-objects.test.js +23 -0
- package/dist/tests/e2e/json-builtin-objects.test.js.map +1 -0
- package/dist/tests/e2e/json-circular.test.d.ts +6 -0
- package/dist/tests/e2e/json-circular.test.js +43 -0
- package/dist/tests/e2e/json-circular.test.js.map +1 -0
- package/dist/tests/e2e/json-parse-reviver.test.d.ts +6 -0
- package/dist/tests/e2e/json-parse-reviver.test.js +29 -0
- package/dist/tests/e2e/json-parse-reviver.test.js.map +1 -0
- package/dist/tests/e2e/json-stringify-replacer.test.d.ts +6 -0
- package/dist/tests/e2e/json-stringify-replacer.test.js +27 -0
- package/dist/tests/e2e/json-stringify-replacer.test.js.map +1 -0
- package/dist/tests/e2e/json-stringify-space.test.d.ts +6 -0
- package/dist/tests/e2e/json-stringify-space.test.js +23 -0
- package/dist/tests/e2e/json-stringify-space.test.js.map +1 -0
- package/dist/tests/e2e/method-dispatch-errors.test.d.ts +9 -0
- package/dist/tests/e2e/method-dispatch-errors.test.js +38 -0
- package/dist/tests/e2e/method-dispatch-errors.test.js.map +1 -0
- package/dist/tests/e2e/native-extensions.test.js +1 -1
- package/dist/tests/e2e/native-extensions.test.js.map +1 -1
- package/dist/tests/e2e/promise-with-resolvers.test.d.ts +5 -0
- package/dist/tests/e2e/promise-with-resolvers.test.js +20 -0
- package/dist/tests/e2e/promise-with-resolvers.test.js.map +1 -0
- package/dist/tests/e2e/property-descriptors.test.d.ts +5 -0
- package/dist/tests/e2e/property-descriptors.test.js +25 -0
- package/dist/tests/e2e/property-descriptors.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.d.ts +1 -0
- package/dist/tests/e2e/property-ic.test.js +55 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -0
- package/dist/tests/e2e/runtime-errors.test.d.ts +10 -0
- package/dist/tests/e2e/runtime-errors.test.js +52 -0
- package/dist/tests/e2e/runtime-errors.test.js.map +1 -0
- package/dist/tests/e2e/structured-clone.test.d.ts +6 -0
- package/dist/tests/e2e/structured-clone.test.js +49 -0
- package/dist/tests/e2e/structured-clone.test.js.map +1 -0
- package/dist/tests/e2e/text-codec.test.d.ts +6 -0
- package/dist/tests/e2e/text-codec.test.js +24 -0
- package/dist/tests/e2e/text-codec.test.js.map +1 -0
- package/dist/tests/e2e/typed-array-views.test.d.ts +6 -0
- package/dist/tests/e2e/typed-array-views.test.js +39 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -0
- package/dist/tests/e2e/url-search-params.test.d.ts +5 -0
- package/dist/tests/e2e/url-search-params.test.js +30 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -0
- package/dist/tests/e2e/weak-collections.test.d.ts +1 -0
- package/dist/tests/e2e/weak-collections.test.js +88 -0
- package/dist/tests/e2e/weak-collections.test.js.map +1 -0
- package/dist/tests/parser/declarations.test.js +12 -0
- package/dist/tests/parser/declarations.test.js.map +1 -1
- package/dist/tests/parser/module-syntax.test.js +9 -0
- package/dist/tests/parser/module-syntax.test.js.map +1 -1
- package/dist/tests/parser/parser.test.js +7 -0
- package/dist/tests/parser/parser.test.js.map +1 -1
- package/dist/tests/version.test.js +5 -1
- package/dist/tests/version.test.js.map +1 -1
- package/doc/ai/README.md +4 -3
- package/doc/ai/cli.md +41 -0
- package/doc/ai/contributing.md +20 -16
- package/doc/ai/extensions.md +13 -10
- package/doc/ai/language-support.md +19 -14
- package/doc/ai/troubleshooting.md +11 -9
- package/doc/ai/zh-CN/README.md +3 -2
- package/doc/ai/zh-CN/cli.md +35 -0
- package/doc/ai/zh-CN/contributing.md +16 -15
- package/doc/ai/zh-CN/extensions.md +12 -9
- package/doc/ai/zh-CN/language-support.md +19 -15
- package/doc/ai/zh-CN/troubleshooting.md +9 -8
- package/doc/gui/api.md +8 -0
- package/doc/gui/build.md +13 -4
- package/doc/gui/known-issues.md +19 -14
- package/doc/gui/media.md +32 -3
- package/doc/gui/rendering.md +3 -1
- package/doc/gui.md +28 -5
- package/doc/icon.md +5 -4
- package/doc/implemented/async.md +51 -0
- package/doc/implemented/binder.md +13 -0
- package/doc/implemented/cli.md +47 -0
- package/doc/implemented/codegen.md +33 -0
- package/doc/implemented/collections.md +26 -0
- package/doc/implemented/driver.md +19 -0
- package/doc/implemented/extensions.md +19 -0
- package/doc/implemented/fetch.md +44 -0
- package/doc/implemented/lexer.md +23 -0
- package/doc/implemented/modules.md +28 -0
- package/doc/implemented/node/assert.md +17 -0
- package/doc/implemented/node/buffer.md +29 -0
- package/doc/implemented/node/child-process.md +29 -0
- package/doc/implemented/node/crypto.md +9 -0
- package/doc/implemented/node/dgram.md +15 -0
- package/doc/implemented/node/events.md +37 -0
- package/doc/implemented/node/fs-promises.md +49 -0
- package/doc/implemented/node/fs.md +112 -0
- package/doc/implemented/node/http.md +21 -0
- package/doc/implemented/node/net.md +17 -0
- package/doc/implemented/node/os.md +22 -0
- package/doc/implemented/node/path.md +33 -0
- package/doc/implemented/node/process.md +23 -0
- package/doc/implemented/node/querystring.md +20 -0
- package/doc/implemented/node/stream-promises.md +8 -0
- package/doc/implemented/node/stream.md +19 -0
- package/doc/implemented/node/test.md +10 -0
- package/doc/implemented/node/url.md +8 -0
- package/doc/implemented/node/util.md +25 -0
- package/doc/implemented/node/worker-threads.md +10 -0
- package/doc/implemented/node/zlib.md +8 -0
- package/doc/implemented/node.md +48 -0
- package/doc/implemented/operators.md +38 -0
- package/doc/implemented/parser.md +58 -0
- package/doc/implemented/pipeline.md +28 -0
- package/doc/implemented/runtime-core.md +32 -0
- package/doc/implemented/stdlib.md +78 -0
- package/doc/implemented/strings.md +27 -0
- package/doc/implemented/tests.md +10 -0
- package/doc/implemented/typed-arrays.md +26 -0
- package/doc/implemented/value-model.md +18 -0
- package/doc/implemented.md +54 -355
- package/doc/node-implemented.md +3 -585
- package/doc/node-unimplemented.md +3 -164
- package/doc/requirements.md +23 -8
- package/doc/unimplemented/classes.md +22 -0
- package/doc/unimplemented/deviations.md +27 -0
- package/doc/unimplemented/expressions.md +26 -0
- package/doc/unimplemented/functions.md +21 -0
- package/doc/unimplemented/modules.md +22 -0
- package/doc/unimplemented/node/async.md +20 -0
- package/doc/unimplemented/node/bun.md +9 -0
- package/doc/unimplemented/node/fs-promises.md +20 -0
- package/doc/unimplemented/node/fs.md +30 -0
- package/doc/unimplemented/node/globals.md +23 -0
- package/doc/unimplemented/node/modules.md +21 -0
- package/doc/unimplemented/node.md +21 -0
- package/doc/unimplemented/statements.md +18 -0
- package/doc/unimplemented/stdlib.md +54 -0
- package/doc/unimplemented/toolchain.md +14 -0
- package/doc/unimplemented/types.md +12 -0
- package/doc/unimplemented.md +18 -275
- package/doc/xbintsc.config.schema.json +12 -0
- package/doc/zh-CN/gui/api.md +7 -0
- package/doc/zh-CN/gui/build.md +11 -3
- package/doc/zh-CN/gui/known-issues.md +17 -11
- package/doc/zh-CN/gui/media.md +26 -2
- package/doc/zh-CN/gui/rendering.md +2 -1
- package/doc/zh-CN/gui.md +21 -3
- package/doc/zh-CN/icon.md +5 -4
- package/doc/zh-CN/implemented/async.md +49 -0
- package/doc/zh-CN/implemented/binder.md +13 -0
- package/doc/zh-CN/implemented/cli.md +46 -0
- package/doc/zh-CN/implemented/codegen.md +33 -0
- package/doc/zh-CN/implemented/collections.md +26 -0
- package/doc/zh-CN/implemented/driver.md +19 -0
- package/doc/zh-CN/implemented/extensions.md +19 -0
- package/doc/zh-CN/implemented/fetch.md +31 -0
- package/doc/zh-CN/implemented/lexer.md +23 -0
- package/doc/zh-CN/implemented/modules.md +28 -0
- package/doc/zh-CN/implemented/node/assert.md +17 -0
- package/doc/zh-CN/implemented/node/buffer.md +25 -0
- package/doc/zh-CN/implemented/node/child-process.md +27 -0
- package/doc/zh-CN/implemented/node/crypto.md +9 -0
- package/doc/zh-CN/implemented/node/dgram.md +15 -0
- package/doc/zh-CN/implemented/node/events.md +36 -0
- package/doc/zh-CN/implemented/node/fs-promises.md +30 -0
- package/doc/zh-CN/implemented/node/fs.md +105 -0
- package/doc/zh-CN/implemented/node/http.md +17 -0
- package/doc/zh-CN/implemented/node/net.md +17 -0
- package/doc/zh-CN/implemented/node/os.md +21 -0
- package/doc/zh-CN/implemented/node/path.md +26 -0
- package/doc/zh-CN/implemented/node/process.md +23 -0
- package/doc/zh-CN/implemented/node/querystring.md +20 -0
- package/doc/zh-CN/implemented/node/stream-promises.md +8 -0
- package/doc/zh-CN/implemented/node/stream.md +15 -0
- package/doc/zh-CN/implemented/node/test.md +10 -0
- package/doc/zh-CN/implemented/node/url.md +8 -0
- package/doc/zh-CN/implemented/node/util.md +25 -0
- package/doc/zh-CN/implemented/node/worker-threads.md +9 -0
- package/doc/zh-CN/implemented/node/zlib.md +8 -0
- package/doc/zh-CN/implemented/node.md +45 -0
- package/doc/zh-CN/implemented/operators.md +38 -0
- package/doc/zh-CN/implemented/parser.md +58 -0
- package/doc/zh-CN/implemented/pipeline.md +25 -0
- package/doc/zh-CN/implemented/runtime-core.md +31 -0
- package/doc/zh-CN/implemented/stdlib.md +76 -0
- package/doc/zh-CN/implemented/strings.md +27 -0
- package/doc/zh-CN/implemented/tests.md +10 -0
- package/doc/zh-CN/implemented/typed-arrays.md +26 -0
- package/doc/zh-CN/implemented/value-model.md +18 -0
- package/doc/zh-CN/implemented.md +50 -350
- package/doc/zh-CN/node-implemented.md +4 -531
- package/doc/zh-CN/node-unimplemented.md +4 -139
- package/doc/zh-CN/plan-require-node-modules.md +4 -4
- package/doc/zh-CN/requirements.md +20 -6
- package/doc/zh-CN/unimplemented/classes.md +22 -0
- package/doc/zh-CN/unimplemented/deviations.md +24 -0
- package/doc/zh-CN/unimplemented/expressions.md +24 -0
- package/doc/zh-CN/unimplemented/functions.md +21 -0
- package/doc/zh-CN/unimplemented/modules.md +19 -0
- package/doc/zh-CN/unimplemented/node/async.md +20 -0
- package/doc/zh-CN/unimplemented/node/bun.md +8 -0
- package/doc/zh-CN/unimplemented/node/fs-promises.md +12 -0
- package/doc/zh-CN/unimplemented/node/fs.md +24 -0
- package/doc/zh-CN/unimplemented/node/globals.md +14 -0
- package/doc/zh-CN/unimplemented/node/modules.md +15 -0
- package/doc/zh-CN/unimplemented/node.md +18 -0
- package/doc/zh-CN/unimplemented/statements.md +15 -0
- package/doc/zh-CN/unimplemented/stdlib.md +54 -0
- package/doc/zh-CN/unimplemented/toolchain.md +14 -0
- package/doc/zh-CN/unimplemented/types.md +11 -0
- package/doc/zh-CN/unimplemented.md +14 -237
- package/llms.txt +32 -4
- package/package.json +1 -1
- package/runtime/ext_gui/inline_svg.cpp +219 -0
- package/runtime/ext_gui/inline_svg.h +41 -0
- package/runtime/ext_gui/layout.cpp +18 -0
- package/runtime/ext_gui/layout.h +7 -0
- package/runtime/ext_gui/layout_flow.cpp +4 -3
- package/runtime/ext_gui/paint.cpp +14 -0
- package/runtime/ext_gui/paint.h +5 -1
- package/runtime/ext_gui/renderer_image.cpp +53 -25
- package/runtime/ext_gui/renderer_shaders.h +2 -2
- package/runtime/ext_gui/stb_image.h +1 -17
- package/runtime/ext_gui/style_ua.cpp +3 -0
- package/runtime/ext_gui/svg.cpp +122 -39
- package/runtime/ext_gui/svg.h +14 -3
- package/runtime/ext_gui/window.cpp +28 -0
- package/runtime/ext_node/child_process/child_process.c +173 -73
- package/runtime/ext_node/fs/async_api.c +314 -0
- package/runtime/ext_node/fs/async_complete.c +99 -0
- package/runtime/ext_node/fs/async_fh.c +206 -0
- package/runtime/ext_node/fs/async_job.c +81 -0
- package/runtime/ext_node/fs/async_job.h +132 -0
- package/runtime/ext_node/fs/async_worker.c +534 -0
- package/runtime/ext_node/fs/async_worker_dir.c +439 -0
- package/runtime/ext_node/fs/async_worker_dir.h +33 -0
- package/runtime/ext_node/fs/async_worker_fd.c +74 -0
- package/runtime/ext_node/fs/dir.c +60 -15
- package/runtime/ext_node/fs/fs_common.h +9 -0
- package/runtime/ext_node/fs/fs_ops.c +18 -29
- package/runtime/ext_node/fs/parts/builtins.inc +34 -0
- package/runtime/ext_node/fs/parts/platform.inc +66 -0
- package/runtime/ext_node/fs/promises.c +44 -234
- package/runtime/rt.h +15 -0
- package/runtime/rt_internal.h +108 -0
- package/runtime/xt_alloc.c +43 -7
- package/runtime/xt_array_buffer.c +284 -0
- package/runtime/xt_async.c +46 -21
- package/runtime/xt_async_io.c +333 -0
- package/runtime/xt_async_io.h +47 -0
- package/runtime/xt_bigint/helpers.inc +3 -3
- package/runtime/xt_builtins.c +21 -17
- package/runtime/xt_constructors.c +12 -2
- package/runtime/xt_containers/access.inc +148 -3
- package/runtime/xt_containers/objects.inc +26 -2
- package/runtime/xt_containers/shapes.inc +71 -0
- package/runtime/xt_containers.c +1 -0
- package/runtime/xt_coroutine.c +17 -0
- package/runtime/xt_fetch/async.inc +295 -0
- package/runtime/xt_fetch/request.inc +6 -183
- package/runtime/xt_fetch/socket.inc +5 -4
- package/runtime/xt_fetch.c +6 -4
- package/runtime/xt_generator.c +299 -10
- package/runtime/xt_io/inspect.inc +112 -0
- package/runtime/xt_loop.c +79 -7
- package/runtime/xt_performance.c +37 -0
- package/runtime/xt_promise.c +63 -1
- package/runtime/xt_stdlib/arrays.inc +1 -1
- package/runtime/xt_stdlib/dispatch.inc +46 -11
- package/runtime/xt_stdlib/strings.inc +1 -1
- package/runtime/xt_stdlib2/array-statics.inc +25 -0
- package/runtime/xt_stdlib2/arrays.inc +5 -3
- package/runtime/xt_stdlib2/container.inc +5 -0
- package/runtime/xt_stdlib2/date.inc +111 -3
- package/runtime/xt_stdlib2/error.inc +24 -0
- package/runtime/xt_stdlib2/json.inc +310 -19
- package/runtime/xt_stdlib2/number-string-statics.inc +1 -1
- package/runtime/xt_stdlib2/objects.inc +122 -0
- package/runtime/xt_stdlib2/set.inc +1 -1
- package/runtime/xt_structured_clone.c +159 -0
- package/runtime/xt_symbol.c +2 -2
- package/runtime/xt_text_codec.c +69 -0
- package/runtime/xt_typed_array/construction.inc +35 -5
- package/runtime/xt_typed_array/elements.inc +159 -0
- package/runtime/xt_typed_array/methods.inc +21 -5
- package/runtime/xt_typed_array.c +7 -10
- package/runtime/xt_url.c +375 -0
- package/runtime/xt_values/arithmetic.inc +2 -2
- package/runtime/xt_values/conversions.inc +1 -1
- package/runtime/xt_weak.c +281 -0
- package/scripts/build-gui.ts +133 -60
- package/scripts/check-version.ts +3 -3
- package/src/binder/declarations.ts +14 -3
- package/src/cli/hints.ts +8 -1
- package/src/cli/main.ts +119 -18
- package/src/cli/watch.ts +101 -0
- package/src/codegen/generator/calls/access.ts +10 -2
- package/src/codegen/generator/calls/closures.ts +12 -4
- package/src/codegen/generator/context.ts +23 -3
- package/src/codegen/generator/expressions/operators.ts +27 -13
- package/src/codegen/generator/expressions/primary.ts +4 -0
- package/src/codegen/generator/module.ts +0 -7
- package/src/codegen/generator/numeric.ts +85 -11
- package/src/codegen/generator/state.ts +23 -0
- package/src/codegen/generator/statements/control-flow.ts +1 -4
- package/src/codegen/generator/statements/loops.ts +50 -16
- package/src/codegen/generator/tables.ts +26 -1
- package/src/diagnostics/diagnostic.ts +23 -3
- package/src/driver/app-artifacts.ts +77 -0
- package/src/driver/build-key.ts +55 -0
- package/src/driver/bundler/graph.ts +63 -13
- package/src/driver/bundler/merge.ts +4 -1
- package/src/driver/compiler.ts +94 -328
- package/src/driver/config.ts +11 -0
- package/src/driver/frontend.ts +120 -0
- package/src/driver/index.ts +0 -1
- package/src/driver/options.ts +70 -0
- package/src/driver/runtime-objects.ts +134 -0
- package/src/driver/toolchain-provider.ts +4 -0
- package/src/driver/toolchain.ts +154 -10
- package/src/driver/version.ts +12 -0
- package/src/driver/win-icon.ts +36 -36
- package/src/extensions/node/fs/index.ts +12 -3
- package/src/extensions/node/fs-promises/index.ts +15 -6
- package/src/parser/declarations/classes.ts +4 -0
- package/src/parser/declarations/functions.ts +12 -1
- package/src/parser/modules.ts +8 -4
- package/src/parser/parser.ts +28 -0
|
@@ -32,7 +32,77 @@ static void xt_throw_read_of_nullish(xt_value target, xt_value key) {
|
|
|
32
32
|
char message[256];
|
|
33
33
|
snprintf(message, sizeof(message),
|
|
34
34
|
"TypeError: Cannot read properties of %s (reading '%s')", base, keybuf);
|
|
35
|
-
xt_throw(
|
|
35
|
+
xt_throw(xt_error_from_message(message));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* -- Array.prototype[Symbol.iterator] -------------------------------------- */
|
|
39
|
+
/*
|
|
40
|
+
* `for...of` and spread use the internal index protocol, but libraries also
|
|
41
|
+
* call the iterator method explicitly (`arr[Symbol.iterator]()`, `Array.from`,
|
|
42
|
+
* manual `.next()`). Build a small iterator object per call: `next` closes over
|
|
43
|
+
* the array and a one-element box holding the current index, and the iterator
|
|
44
|
+
* is itself iterable so it can be passed back to `for...of` / spread.
|
|
45
|
+
*/
|
|
46
|
+
static xt_value xt_array_iterator_next(xt_value thisValue, xt_value env, int32_t argc,
|
|
47
|
+
xt_value *argv) {
|
|
48
|
+
(void)thisValue;
|
|
49
|
+
(void)argc;
|
|
50
|
+
(void)argv;
|
|
51
|
+
xt_value array = xt_closure_env(env, 0);
|
|
52
|
+
xt_value indexBox = xt_closure_env(env, 1);
|
|
53
|
+
int32_t index = xt_to_int32(xt_get(indexBox, xt_number(0)));
|
|
54
|
+
xt_array *items = xt_as_array(array);
|
|
55
|
+
xt_value result = xt_object_new();
|
|
56
|
+
if (!items || index < 0 || (uint32_t)index >= items->length) {
|
|
57
|
+
xt_object_set(result, xt_string_from_cstr("value"), XT_UNDEFINED);
|
|
58
|
+
xt_object_set(result, xt_string_from_cstr("done"), XT_TRUE);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
xt_object_set(result, xt_string_from_cstr("value"), items->items[index]);
|
|
62
|
+
xt_object_set(result, xt_string_from_cstr("done"), XT_FALSE);
|
|
63
|
+
xt_set(indexBox, xt_number(0), xt_number(index + 1));
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static xt_value xt_iterator_return_this(xt_value thisValue, xt_value env, int32_t argc,
|
|
68
|
+
xt_value *argv) {
|
|
69
|
+
(void)env;
|
|
70
|
+
(void)argc;
|
|
71
|
+
(void)argv;
|
|
72
|
+
return thisValue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static xt_value xt_array_iterator(xt_value thisValue, xt_value env, int32_t argc,
|
|
76
|
+
xt_value *argv) {
|
|
77
|
+
(void)env;
|
|
78
|
+
(void)argc;
|
|
79
|
+
(void)argv;
|
|
80
|
+
if (!XT_IS_ARRAY(thisValue)) {
|
|
81
|
+
xt_value message =
|
|
82
|
+
xt_string_from_cstr("Array.prototype[Symbol.iterator] called on a non-array");
|
|
83
|
+
xt_throw(xt_type_error_ctor(1, &message));
|
|
84
|
+
}
|
|
85
|
+
xt_value indexBox = xt_array_new(0, NULL);
|
|
86
|
+
xt_array_push(indexBox, xt_number(0));
|
|
87
|
+
xt_value captured[2] = {thisValue, indexBox};
|
|
88
|
+
xt_value iterator = xt_object_new();
|
|
89
|
+
xt_object_set(iterator, xt_string_from_cstr("next"),
|
|
90
|
+
xt_closure_new((void *)xt_array_iterator_next, 2, captured));
|
|
91
|
+
xt_object_set(iterator, xt_symbol_well_known("iterator"),
|
|
92
|
+
xt_closure_new((void *)xt_iterator_return_this, 0, NULL));
|
|
93
|
+
return iterator;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* The method value is stable (`arr[Symbol.iterator] === arr[Symbol.iterator]`),
|
|
97
|
+
* so cache it and root the cache for the collector. */
|
|
98
|
+
static xt_value xt_array_iterator_method_value = XT_UNDEFINED;
|
|
99
|
+
|
|
100
|
+
static xt_value xt_array_iterator_method(void) {
|
|
101
|
+
if (!XT_IS_FUNCTION(xt_array_iterator_method_value)) {
|
|
102
|
+
xt_array_iterator_method_value = xt_closure_new((void *)xt_array_iterator, 0, NULL);
|
|
103
|
+
xt_gc_add_root(&xt_array_iterator_method_value);
|
|
104
|
+
}
|
|
105
|
+
return xt_array_iterator_method_value;
|
|
36
106
|
}
|
|
37
107
|
|
|
38
108
|
xt_value xt_get(xt_value target, xt_value key) {
|
|
@@ -71,6 +141,9 @@ xt_value xt_get(xt_value target, xt_value key) {
|
|
|
71
141
|
xt_value value = xt_object_get(extra, key);
|
|
72
142
|
if (value != XT_UNDEFINED) return value;
|
|
73
143
|
}
|
|
144
|
+
/* Array.prototype[Symbol.iterator] is the fallback, after any own
|
|
145
|
+
* symbol property the program assigned. */
|
|
146
|
+
if (key == xt_symbol_well_known("iterator")) return xt_array_iterator_method();
|
|
74
147
|
xt_value method = xt_method_value(target, key);
|
|
75
148
|
if (method != XT_UNDEFINED) return method;
|
|
76
149
|
xt_value proto = ((xt_array *)XT_GET_PTR(target))->prototype;
|
|
@@ -105,6 +178,17 @@ xt_value xt_get(xt_value target, xt_value key) {
|
|
|
105
178
|
/* Map/Set expose `.size`; promises, dates and regexps have their own
|
|
106
179
|
* getters implemented in the standard library. */
|
|
107
180
|
xt_object *obj = (xt_object *)XT_GET_PTR(target);
|
|
181
|
+
if (obj->header.kind == XT_OBJECT_KIND_GENERATOR && xt_is_symbol(key)) {
|
|
182
|
+
/* Generators are iterable objects: `Symbol.iterator` returns the
|
|
183
|
+
* generator itself, and an async generator also exposes
|
|
184
|
+
* `Symbol.asyncIterator`. */
|
|
185
|
+
if (key == xt_symbol_well_known("asyncIterator") && xt_is_async_generator(target)) {
|
|
186
|
+
return xt_async_iterator_method();
|
|
187
|
+
}
|
|
188
|
+
if (key == xt_symbol_well_known("iterator") && !xt_is_async_generator(target)) {
|
|
189
|
+
return xt_async_iterator_method();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
108
192
|
if (obj->header.kind == XT_OBJECT_KIND_SYMBOL) {
|
|
109
193
|
if (XT_IS_STRING(key)) {
|
|
110
194
|
xt_string *k = xt_as_string(key);
|
|
@@ -138,6 +222,25 @@ xt_value xt_get(xt_value target, xt_value key) {
|
|
|
138
222
|
}
|
|
139
223
|
}
|
|
140
224
|
{
|
|
225
|
+
/* Typed arrays keep their elements in a shared ArrayBuffer: serve
|
|
226
|
+
* `.buffer` / element reads from it instead of the property bag. */
|
|
227
|
+
int typed = xt_typed_array_kind_of(target);
|
|
228
|
+
if (typed >= 0) {
|
|
229
|
+
if (XT_IS_STRING(key)) {
|
|
230
|
+
xt_string *k = xt_as_string(key);
|
|
231
|
+
if (k->length == 6 && memcmp(xt_string_bytes(k), "buffer", 6) == 0) {
|
|
232
|
+
return xt_typed_array_buffer_of(target);
|
|
233
|
+
}
|
|
234
|
+
if (k->length == 10 && memcmp(xt_string_bytes(k), "byteOffset", 10) == 0) {
|
|
235
|
+
return xt_number((double)xt_typed_array_byte_offset_of(target));
|
|
236
|
+
}
|
|
237
|
+
uint32_t index = 0;
|
|
238
|
+
if (xt_key_is_array_index(k, &index)) return xt_typed_array_read(target, index);
|
|
239
|
+
} else if (XT_IS_NUMBER(key)) {
|
|
240
|
+
int32_t index = xt_to_int32(key);
|
|
241
|
+
if (index >= 0) return xt_typed_array_read(target, (uint32_t)index);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
141
244
|
xt_value value = xt_object_get(target, key);
|
|
142
245
|
if (value != XT_UNDEFINED) return value;
|
|
143
246
|
xt_value method = xt_method_value(target, key);
|
|
@@ -174,6 +277,47 @@ xt_value xt_get(xt_value target, xt_value key) {
|
|
|
174
277
|
return XT_UNDEFINED;
|
|
175
278
|
}
|
|
176
279
|
|
|
280
|
+
/* Inline-cached property read. The generated code gives every source-level
|
|
281
|
+
* property access two zeroed i64 words; the first stores the receiver's shape
|
|
282
|
+
* and the second the property index. A shape hit is a pointer compare plus one
|
|
283
|
+
* key check, which avoids the linear property scan. Only ordinary objects and
|
|
284
|
+
* errors use the cache; arrays, functions, strings and containers fall back to
|
|
285
|
+
* the generic path. */
|
|
286
|
+
xt_value xt_get_ic(xt_value target, xt_value key, int64_t *cache) {
|
|
287
|
+
if (!cache || !XT_IS_OBJECT(target)) return xt_get(target, key);
|
|
288
|
+
xt_object *obj = (xt_object *)XT_GET_PTR(target);
|
|
289
|
+
if (obj->header.kind != XT_OBJECT_KIND_OBJECT && obj->header.kind != XT_OBJECT_KIND_ERROR) {
|
|
290
|
+
return xt_get(target, key);
|
|
291
|
+
}
|
|
292
|
+
if (!XT_IS_STRING(key) && !xt_is_symbol(key)) return xt_get(target, key);
|
|
293
|
+
xt_shape *shape = obj->shape;
|
|
294
|
+
uintptr_t cachedShape = (uintptr_t)cache[0];
|
|
295
|
+
int64_t cachedIndex = cache[1];
|
|
296
|
+
if (shape && cachedShape == (uintptr_t)shape && cachedIndex >= 0 &&
|
|
297
|
+
cachedIndex < (int64_t)obj->count) {
|
|
298
|
+
xt_property *prop = &obj->properties[cachedIndex];
|
|
299
|
+
if (prop->key == key || xt_property_key_equals(prop->key, key)) {
|
|
300
|
+
if (prop->getter != XT_UNDEFINED && XT_IS_FUNCTION(prop->getter)) {
|
|
301
|
+
return xt_call_with_this(prop->getter, target, 0, NULL);
|
|
302
|
+
}
|
|
303
|
+
if (prop->getter != XT_UNDEFINED) return XT_UNDEFINED;
|
|
304
|
+
return prop->value;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
xt_value propertyKey = xt_to_property_key(key);
|
|
308
|
+
xt_property *prop = xt_object_find_property(obj, propertyKey);
|
|
309
|
+
if (prop) {
|
|
310
|
+
cache[0] = (int64_t)(uintptr_t)shape;
|
|
311
|
+
cache[1] = (int64_t)(prop - obj->properties);
|
|
312
|
+
if (prop->getter != XT_UNDEFINED && XT_IS_FUNCTION(prop->getter)) {
|
|
313
|
+
return xt_call_with_this(prop->getter, target, 0, NULL);
|
|
314
|
+
}
|
|
315
|
+
if (prop->getter != XT_UNDEFINED) return XT_UNDEFINED;
|
|
316
|
+
return prop->value;
|
|
317
|
+
}
|
|
318
|
+
return xt_get(target, key);
|
|
319
|
+
}
|
|
320
|
+
|
|
177
321
|
xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
178
322
|
if (XT_IS_ARRAY(target)) {
|
|
179
323
|
/* Assigning `arr.length` truncates or extends the array. */
|
|
@@ -209,7 +353,7 @@ xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
|
209
353
|
if ((k->length == 6 && memcmp(xt_string_bytes(k), "length", 6) == 0) ||
|
|
210
354
|
(k->length == 10 && memcmp(xt_string_bytes(k), "byteLength", 10) == 0) ||
|
|
211
355
|
(k->length == 10 && memcmp(xt_string_bytes(k), "byteOffset", 10) == 0)) {
|
|
212
|
-
xt_throw(
|
|
356
|
+
xt_throw(xt_error_from_message("TypeError: Cannot assign to read only property"));
|
|
213
357
|
return value;
|
|
214
358
|
}
|
|
215
359
|
}
|
|
@@ -227,7 +371,8 @@ xt_value xt_set(xt_value target, xt_value key, xt_value value) {
|
|
|
227
371
|
if (isIndex) {
|
|
228
372
|
double length = xt_to_number(xt_object_get_cstr(target, "length"));
|
|
229
373
|
if (index >= (uint32_t)length) return value; /* out-of-bounds writes are ignored */
|
|
230
|
-
|
|
374
|
+
xt_typed_array_write(target, index, value);
|
|
375
|
+
return value;
|
|
231
376
|
}
|
|
232
377
|
}
|
|
233
378
|
return xt_object_set(target, key, value);
|
|
@@ -47,6 +47,9 @@ static const char *xt_object_tag_of(xt_value value) {
|
|
|
47
47
|
case XT_OBJECT_KIND_ERROR: return "Error";
|
|
48
48
|
case XT_OBJECT_KIND_MAP: return "Map";
|
|
49
49
|
case XT_OBJECT_KIND_SET: return "Set";
|
|
50
|
+
case XT_OBJECT_KIND_WEAK_MAP: return "WeakMap";
|
|
51
|
+
case XT_OBJECT_KIND_WEAK_SET: return "WeakSet";
|
|
52
|
+
case XT_OBJECT_KIND_WEAK_REF: return "WeakRef";
|
|
50
53
|
case XT_OBJECT_KIND_DATE: return "Date";
|
|
51
54
|
case XT_OBJECT_KIND_REGEXP: return "RegExp";
|
|
52
55
|
case XT_OBJECT_KIND_PROMISE: return "Promise";
|
|
@@ -68,13 +71,13 @@ static xt_value xt_object_proto_method(xt_value thisValue, xt_value env, int32_t
|
|
|
68
71
|
if (!name) return XT_UNDEFINED;
|
|
69
72
|
if (strcmp(name, "hasOwnProperty") == 0) {
|
|
70
73
|
if (thisValue == XT_UNDEFINED || thisValue == XT_NULL) {
|
|
71
|
-
xt_throw(
|
|
74
|
+
xt_throw(xt_error_from_message("TypeError: Cannot convert undefined or null to object"));
|
|
72
75
|
}
|
|
73
76
|
return xt_object_has_own(thisValue, xt_arg_at(argc, argv, 0));
|
|
74
77
|
}
|
|
75
78
|
if (strcmp(name, "propertyIsEnumerable") == 0) {
|
|
76
79
|
if (thisValue == XT_UNDEFINED || thisValue == XT_NULL) {
|
|
77
|
-
xt_throw(
|
|
80
|
+
xt_throw(xt_error_from_message("TypeError: Cannot convert undefined or null to object"));
|
|
78
81
|
}
|
|
79
82
|
/* Enumerability is not tracked; every own property is enumerable. */
|
|
80
83
|
return xt_object_has_own(thisValue, xt_arg_at(argc, argv, 0));
|
|
@@ -163,6 +166,7 @@ xt_value xt_object_new_with_proto(xt_value proto) {
|
|
|
163
166
|
obj->count = 0;
|
|
164
167
|
obj->capacity = 0;
|
|
165
168
|
obj->properties = NULL;
|
|
169
|
+
obj->shape = xt_shape_empty();
|
|
166
170
|
obj->prototype = proto;
|
|
167
171
|
obj->frozen = 0;
|
|
168
172
|
obj->is_array_base = 0;
|
|
@@ -229,6 +233,7 @@ static xt_property *xt_object_insert_property(xt_object *obj, xt_value key) {
|
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
}
|
|
236
|
+
uint32_t oldCount = obj->count;
|
|
232
237
|
xt_object_reserve(obj, obj->count + 1);
|
|
233
238
|
for (uint32_t i = obj->count; i > position; i--) obj->properties[i] = obj->properties[i - 1];
|
|
234
239
|
xt_property *prop = &obj->properties[position];
|
|
@@ -237,6 +242,10 @@ static xt_property *xt_object_insert_property(xt_object *obj, xt_value key) {
|
|
|
237
242
|
prop->getter = XT_UNDEFINED;
|
|
238
243
|
prop->setter = XT_UNDEFINED;
|
|
239
244
|
obj->count++;
|
|
245
|
+
/* Appending follows a transition; inserting an integer key into the middle
|
|
246
|
+
* reorders the list, so rebuild the canonical shape from the new layout. */
|
|
247
|
+
if (position == oldCount && obj->shape) obj->shape = xt_shape_transition(obj->shape, key);
|
|
248
|
+
else xt_object_shape_changed(obj);
|
|
240
249
|
return prop;
|
|
241
250
|
}
|
|
242
251
|
|
|
@@ -382,6 +391,9 @@ xt_value xt_object_get_prototype(xt_value value) {
|
|
|
382
391
|
case XT_OBJECT_KIND_SYMBOL:
|
|
383
392
|
case XT_OBJECT_KIND_MAP:
|
|
384
393
|
case XT_OBJECT_KIND_SET:
|
|
394
|
+
case XT_OBJECT_KIND_WEAK_MAP:
|
|
395
|
+
case XT_OBJECT_KIND_WEAK_SET:
|
|
396
|
+
case XT_OBJECT_KIND_WEAK_REF:
|
|
385
397
|
case XT_OBJECT_KIND_DATE:
|
|
386
398
|
case XT_OBJECT_KIND_REGEXP:
|
|
387
399
|
case XT_OBJECT_KIND_PROMISE:
|
|
@@ -482,6 +494,18 @@ xt_value xt_object_own_property_symbols(xt_value value) {
|
|
|
482
494
|
|
|
483
495
|
xt_value xt_object_keys(xt_value value) {
|
|
484
496
|
xt_value result = xt_array_new(0, NULL);
|
|
497
|
+
/* A typed array's enumerable own keys are its indices; `length` and the
|
|
498
|
+
* buffer metadata are observable but not enumerable. */
|
|
499
|
+
int typed = xt_typed_array_kind_of(value);
|
|
500
|
+
if (typed >= 0) {
|
|
501
|
+
uint32_t length = (uint32_t)xt_to_number(xt_object_get_cstr(value, "length"));
|
|
502
|
+
for (uint32_t i = 0; i < length; i++) {
|
|
503
|
+
char buffer[32];
|
|
504
|
+
snprintf(buffer, sizeof(buffer), "%u", i);
|
|
505
|
+
xt_array_push(result, xt_string_from_cstr(buffer));
|
|
506
|
+
}
|
|
507
|
+
return result;
|
|
508
|
+
}
|
|
485
509
|
if (XT_IS_OBJECT(value)) {
|
|
486
510
|
xt_object *obj = (xt_object *)XT_GET_PTR(value);
|
|
487
511
|
for (uint32_t i = 0; i < obj->count; i++) {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* ------------------------------------------------------------------------- */
|
|
2
|
+
/* Hidden classes */
|
|
3
|
+
/* ------------------------------------------------------------------------- */
|
|
4
|
+
|
|
5
|
+
/* Shapes are interned by their (parent, property key) transition. They are
|
|
6
|
+
* immortal metadata, but their keys are ordinary strings/symbols, so a root
|
|
7
|
+
* provider keeps those keys alive. Pointer identity is enough to share a
|
|
8
|
+
* transition between the same interned literal; dynamically built keys simply
|
|
9
|
+
* get their own shape, which is still a correct layout identity for the IC. */
|
|
10
|
+
#define XT_SHAPE_BUCKETS 256
|
|
11
|
+
/* Interned shapes are immortal metadata. A program that creates property names
|
|
12
|
+
* dynamically would otherwise leak one shape per name forever, so stop
|
|
13
|
+
* interning after a bounded number; those objects simply fall back to the
|
|
14
|
+
* uncached lookup (a NULL shape). */
|
|
15
|
+
#define XT_SHAPE_LIMIT 16384
|
|
16
|
+
static xt_shape *g_shapes[XT_SHAPE_BUCKETS];
|
|
17
|
+
static xt_shape *g_shape_all = NULL;
|
|
18
|
+
static xt_shape *g_shape_root = NULL;
|
|
19
|
+
static uint32_t g_shape_count = 0;
|
|
20
|
+
|
|
21
|
+
static size_t xt_shape_bucket(xt_shape *parent, xt_value key) {
|
|
22
|
+
uintptr_t mixed = ((uintptr_t)parent >> 4) ^ ((uintptr_t)XT_GET_PTR(key) >> 4);
|
|
23
|
+
return (size_t)mixed & (XT_SHAPE_BUCKETS - 1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static void xt_shape_gc_roots(void) {
|
|
27
|
+
for (xt_shape *shape = g_shape_all; shape; shape = shape->all_next) xt_gc_mark_value(shape->key);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static xt_shape *xt_shape_empty(void) {
|
|
31
|
+
if (g_shape_root) return g_shape_root;
|
|
32
|
+
xt_shape *shape = (xt_shape *)calloc(1, sizeof(xt_shape));
|
|
33
|
+
if (!shape) abort();
|
|
34
|
+
shape->key = XT_UNDEFINED;
|
|
35
|
+
g_shape_root = shape;
|
|
36
|
+
g_shape_all = shape;
|
|
37
|
+
xt_gc_register_root_provider(xt_shape_gc_roots);
|
|
38
|
+
return shape;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
xt_shape *xt_shape_transition(xt_shape *parent, xt_value key) {
|
|
42
|
+
if (!parent) parent = xt_shape_empty();
|
|
43
|
+
size_t bucket = xt_shape_bucket(parent, key);
|
|
44
|
+
for (xt_shape *shape = g_shapes[bucket]; shape; shape = shape->next) {
|
|
45
|
+
if (shape->parent == parent && shape->key == key) return shape;
|
|
46
|
+
}
|
|
47
|
+
if (g_shape_count >= XT_SHAPE_LIMIT) return NULL;
|
|
48
|
+
xt_shape *shape = (xt_shape *)calloc(1, sizeof(xt_shape));
|
|
49
|
+
if (!shape) abort();
|
|
50
|
+
shape->key = key;
|
|
51
|
+
shape->count = parent->count + 1;
|
|
52
|
+
shape->parent = parent;
|
|
53
|
+
shape->next = g_shapes[bucket];
|
|
54
|
+
g_shapes[bucket] = shape;
|
|
55
|
+
shape->all_next = g_shape_all;
|
|
56
|
+
g_shape_all = shape;
|
|
57
|
+
g_shape_count++;
|
|
58
|
+
return shape;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void xt_object_shape_changed(xt_object *obj) {
|
|
62
|
+
xt_shape *shape = xt_shape_empty();
|
|
63
|
+
for (uint32_t i = 0; i < obj->count; i++) {
|
|
64
|
+
shape = xt_shape_transition(shape, obj->properties[i].key);
|
|
65
|
+
if (!shape) {
|
|
66
|
+
obj->shape = NULL;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
obj->shape = shape;
|
|
71
|
+
}
|
package/runtime/xt_containers.c
CHANGED
package/runtime/xt_coroutine.c
CHANGED
|
@@ -48,6 +48,11 @@ struct xt_coroutine {
|
|
|
48
48
|
int booted;
|
|
49
49
|
int started;
|
|
50
50
|
void *saved_try_top;
|
|
51
|
+
/* Coroutine that was current when this one was entered. Used to answer
|
|
52
|
+
* "which JavaScript execution context is running?" so a nested async
|
|
53
|
+
* function inside an async generator (or vice versa) does not mistake the
|
|
54
|
+
* outer coroutine for its own. */
|
|
55
|
+
xt_coroutine *previous;
|
|
51
56
|
#ifdef _WIN32
|
|
52
57
|
void *fiber;
|
|
53
58
|
void *caller_fiber;
|
|
@@ -65,6 +70,14 @@ struct xt_coroutine {
|
|
|
65
70
|
/* Filled in just before a coroutine is first entered (POSIX has no portable
|
|
66
71
|
* way to pass a pointer to `makecontext`). */
|
|
67
72
|
static xt_coroutine *g_boot_coroutine = NULL;
|
|
73
|
+
/* The coroutine whose body is executing right now (NULL on the main stack). */
|
|
74
|
+
static xt_coroutine *g_current_coroutine = NULL;
|
|
75
|
+
|
|
76
|
+
xt_coroutine *xt_coroutine_current(void) { return g_current_coroutine; }
|
|
77
|
+
|
|
78
|
+
int xt_coroutine_is_current(xt_coroutine *co) {
|
|
79
|
+
return co != NULL && g_current_coroutine == co;
|
|
80
|
+
}
|
|
68
81
|
#ifdef _WIN32
|
|
69
82
|
static void *g_main_fiber = NULL;
|
|
70
83
|
#else
|
|
@@ -150,6 +163,8 @@ void xt_coroutine_enter(xt_coroutine *co) {
|
|
|
150
163
|
}
|
|
151
164
|
void *caller_try = xt_try_mark();
|
|
152
165
|
xt_try_restore(co->saved_try_top);
|
|
166
|
+
co->previous = g_current_coroutine;
|
|
167
|
+
g_current_coroutine = co;
|
|
153
168
|
#ifdef _WIN32
|
|
154
169
|
_setjmp(co->caller_regs);
|
|
155
170
|
co->has_caller_regs = 1;
|
|
@@ -158,6 +173,7 @@ void xt_coroutine_enter(xt_coroutine *co) {
|
|
|
158
173
|
#else
|
|
159
174
|
swapcontext(&co->caller, &co->ctx);
|
|
160
175
|
#endif
|
|
176
|
+
g_current_coroutine = co->previous;
|
|
161
177
|
co->saved_try_top = xt_try_mark();
|
|
162
178
|
xt_try_restore(caller_try);
|
|
163
179
|
if (co->stack_pushed) {
|
|
@@ -168,6 +184,7 @@ void xt_coroutine_enter(xt_coroutine *co) {
|
|
|
168
184
|
|
|
169
185
|
void xt_coroutine_leave(xt_coroutine *co) {
|
|
170
186
|
co->saved_try_top = xt_try_mark();
|
|
187
|
+
g_current_coroutine = co->previous;
|
|
171
188
|
#ifdef _WIN32
|
|
172
189
|
SwitchToFiber(co->caller_fiber);
|
|
173
190
|
#else
|