xbintsc 0.3.87 → 0.5.20
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 +23 -11
- package/README.md +11 -9
- package/README.zh-CN.md +7 -7
- 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 +17 -4
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/closures.js +13 -1
- package/dist/src/codegen/generator/calls/closures.js.map +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +4 -3
- package/dist/src/codegen/generator/calls/invocation.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 +11 -1
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/module.d.ts +0 -1
- package/dist/src/codegen/generator/module.js +10 -17
- 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 +27 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/control-flow.js +2 -7
- 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.d.ts +9 -0
- package/dist/src/codegen/generator/tables.js +100 -3
- 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 +94 -230
- 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 +111 -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/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/closures.test.js +8 -0
- package/dist/tests/codegen/closures.test.js.map +1 -1
- 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.d.ts +10 -0
- package/dist/tests/e2e/async-await.test.js +247 -0
- package/dist/tests/e2e/async-await.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/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-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-coverage-globals.test.js +46 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.js.map +1 -1
- 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/string-utf16.test.d.ts +6 -0
- package/dist/tests/e2e/string-utf16.test.js +133 -0
- package/dist/tests/e2e/string-utf16.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 +26 -21
- package/doc/ai/extensions.md +12 -9
- package/doc/ai/language-support.md +26 -19
- package/doc/ai/troubleshooting.md +15 -12
- 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 +19 -18
- package/doc/ai/zh-CN/extensions.md +10 -7
- package/doc/ai/zh-CN/language-support.md +26 -20
- package/doc/ai/zh-CN/troubleshooting.md +12 -10
- package/doc/gui/build.md +13 -4
- package/doc/gui/known-issues.md +9 -5
- package/doc/gui/rendering.md +3 -1
- package/doc/gui.md +4 -3
- package/doc/icon.md +5 -4
- package/doc/implemented/async.md +38 -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 +12 -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 +38 -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 -352
- 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 +17 -0
- package/doc/unimplemented/node/bun.md +9 -0
- package/doc/unimplemented/node/fs-promises.md +16 -0
- package/doc/unimplemented/node/fs.md +31 -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 -274
- package/doc/xbintsc.config.schema.json +12 -0
- package/doc/zh-CN/gui/build.md +11 -3
- package/doc/zh-CN/gui/known-issues.md +9 -4
- package/doc/zh-CN/gui/rendering.md +2 -1
- package/doc/zh-CN/gui.md +3 -2
- package/doc/zh-CN/icon.md +5 -4
- package/doc/zh-CN/implemented/async.md +38 -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 +12 -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 +27 -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 -347
- 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 +17 -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 -236
- package/llms.txt +32 -4
- package/package.json +1 -1
- package/runtime/ext_gui/renderer_shaders.h +2 -2
- package/runtime/ext_gui/stb_image.h +1 -17
- package/runtime/ext_node/child_process/child_process.c +173 -73
- package/runtime/rt.h +47 -0
- package/runtime/rt_internal.h +205 -10
- package/runtime/xt_alloc.c +49 -7
- package/runtime/xt_array_buffer.c +284 -0
- package/runtime/xt_async.c +222 -0
- package/runtime/xt_bigint/helpers.inc +3 -3
- package/runtime/xt_builtins.c +59 -51
- package/runtime/xt_constructors.c +399 -0
- package/runtime/xt_containers/access.inc +195 -14
- package/runtime/xt_containers/arrays.inc +26 -2
- package/runtime/xt_containers/objects.inc +226 -5
- package/runtime/xt_containers/shapes.inc +71 -0
- package/runtime/xt_containers.c +1 -0
- package/runtime/xt_coroutine.c +229 -0
- package/runtime/xt_generator.c +325 -167
- package/runtime/xt_io/inspect.inc +147 -2
- package/runtime/xt_loop.c +35 -4
- package/runtime/xt_performance.c +37 -0
- package/runtime/xt_promise.c +125 -18
- package/runtime/xt_stdlib/arrays.inc +1 -1
- package/runtime/xt_stdlib/dispatch.inc +64 -13
- package/runtime/xt_stdlib/strings.inc +74 -17
- package/runtime/xt_stdlib2/array-statics.inc +28 -3
- 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 +35 -0
- package/runtime/xt_stdlib2/json.inc +353 -33
- package/runtime/xt_stdlib2/number-string-statics.inc +24 -15
- package/runtime/xt_stdlib2/objects.inc +123 -1
- package/runtime/xt_stdlib2/regexp-match.inc +2 -2
- package/runtime/xt_stdlib2/set.inc +7 -1
- package/runtime/xt_stdlib2/strings.inc +70 -40
- 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 +78 -7
- package/runtime/xt_typed_array/elements.inc +159 -0
- package/runtime/xt_typed_array/methods.inc +21 -5
- package/runtime/xt_typed_array.c +11 -10
- package/runtime/xt_url.c +375 -0
- package/runtime/xt_values/arithmetic.inc +2 -2
- package/runtime/xt_values/constructors.inc +8 -0
- package/runtime/xt_values/conversions.inc +1 -1
- package/runtime/xt_values/strings.inc +19 -3
- package/runtime/xt_values/utf16.inc +340 -0
- package/runtime/xt_values.c +1 -0
- 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 +17 -4
- package/src/codegen/generator/calls/closures.ts +12 -1
- package/src/codegen/generator/calls/invocation.ts +4 -3
- package/src/codegen/generator/context.ts +23 -3
- package/src/codegen/generator/expressions/operators.ts +27 -13
- package/src/codegen/generator/expressions/primary.ts +10 -1
- package/src/codegen/generator/module.ts +10 -19
- package/src/codegen/generator/numeric.ts +85 -11
- package/src/codegen/generator/state.ts +27 -0
- package/src/codegen/generator/statements/control-flow.ts +2 -6
- package/src/codegen/generator/statements/loops.ts +50 -16
- package/src/codegen/generator/tables.ts +110 -3
- 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 +93 -324
- 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 +133 -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/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
package/runtime/xt_builtins.c
CHANGED
|
@@ -18,23 +18,22 @@
|
|
|
18
18
|
|
|
19
19
|
xt_value xt_object_values(xt_value value) {
|
|
20
20
|
xt_value result = xt_array_new(0, NULL);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
21
|
+
xt_value keys = xt_object_keys(value);
|
|
22
|
+
xt_array *array = xt_as_array(keys);
|
|
23
|
+
if (!array) return result;
|
|
24
|
+
for (uint32_t i = 0; i < array->length; i++) xt_array_push(result, xt_get(value, array->items[i]));
|
|
26
25
|
return result;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
xt_value xt_object_entries(xt_value value) {
|
|
30
29
|
xt_value result = xt_array_new(0, NULL);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
xt_value keys = xt_object_keys(value);
|
|
31
|
+
xt_array *array = xt_as_array(keys);
|
|
32
|
+
if (!array) return result;
|
|
33
|
+
for (uint32_t i = 0; i < array->length; i++) {
|
|
35
34
|
xt_value pair = xt_array_new(0, NULL);
|
|
36
|
-
xt_array_push(pair,
|
|
37
|
-
xt_array_push(pair,
|
|
35
|
+
xt_array_push(pair, array->items[i]);
|
|
36
|
+
xt_array_push(pair, xt_get(value, array->items[i]));
|
|
38
37
|
xt_array_push(result, pair);
|
|
39
38
|
}
|
|
40
39
|
return result;
|
|
@@ -45,8 +44,11 @@ xt_value xt_object_assign(int32_t argc, xt_value *argv) {
|
|
|
45
44
|
xt_value target = argv[0];
|
|
46
45
|
if (!XT_IS_OBJECT(target)) return target;
|
|
47
46
|
for (int32_t i = 1; i < argc; i++) {
|
|
48
|
-
if (!XT_IS_OBJECT(argv[i])) continue;
|
|
49
|
-
|
|
47
|
+
if (!XT_IS_OBJECT(argv[i]) && !XT_IS_ARRAY(argv[i]) && !XT_IS_STRING(argv[i])) continue;
|
|
48
|
+
/* Arrays and strings contribute their index properties, exactly like
|
|
49
|
+
* `{ ..."ab" }` / `Object.assign({}, [1, 2])` in ECMAScript. */
|
|
50
|
+
xt_value properties = xt_object_rest(argv[i], 0, NULL);
|
|
51
|
+
xt_object *source = (xt_object *)XT_GET_PTR(properties);
|
|
50
52
|
for (uint32_t j = 0; j < source->count; j++) {
|
|
51
53
|
xt_object_set(target, source->properties[j].key, source->properties[j].value);
|
|
52
54
|
}
|
|
@@ -85,7 +87,7 @@ static void xt_object_rest_copy(xt_value target, xt_value key, xt_value value, i
|
|
|
85
87
|
*/
|
|
86
88
|
xt_value xt_object_rest(xt_value source, int32_t argc, xt_value *argv) {
|
|
87
89
|
if (source == XT_UNDEFINED || source == XT_NULL) {
|
|
88
|
-
xt_throw(
|
|
90
|
+
xt_throw(xt_error_from_message("TypeError: Cannot destructure null or undefined"));
|
|
89
91
|
return XT_UNDEFINED;
|
|
90
92
|
}
|
|
91
93
|
xt_value result = xt_object_new();
|
|
@@ -102,11 +104,11 @@ xt_value xt_object_rest(xt_value source, int32_t argc, xt_value *argv) {
|
|
|
102
104
|
|
|
103
105
|
if (XT_IS_STRING(source)) {
|
|
104
106
|
xt_string *string = (xt_string *)XT_GET_PTR(source);
|
|
105
|
-
|
|
106
|
-
for (uint32_t i = 0; i <
|
|
107
|
+
uint32_t units = xt_string_utf16_length(string);
|
|
108
|
+
for (uint32_t i = 0; i < units; i++) {
|
|
107
109
|
char buffer[16];
|
|
108
110
|
snprintf(buffer, sizeof(buffer), "%u", i);
|
|
109
|
-
xt_object_rest_copy(result, xt_string_from_cstr(buffer),
|
|
111
|
+
xt_object_rest_copy(result, xt_string_from_cstr(buffer), xt_string_unit_value(string, (int32_t)i), argc, argv);
|
|
110
112
|
}
|
|
111
113
|
return result;
|
|
112
114
|
}
|
|
@@ -199,7 +201,7 @@ xt_value xt_is_finite(int32_t argc, xt_value *argv) {
|
|
|
199
201
|
static _Noreturn void xt_throw_uri_error(const char *message) {
|
|
200
202
|
char buffer[96];
|
|
201
203
|
snprintf(buffer, sizeof(buffer), "URIError: %s", message);
|
|
202
|
-
xt_throw(
|
|
204
|
+
xt_throw(xt_error_from_message(buffer));
|
|
203
205
|
abort();
|
|
204
206
|
}
|
|
205
207
|
|
|
@@ -376,6 +378,10 @@ XT_BUILTIN_TRAMPOLINE(xt_builtin_value_setTimeout, xt_set_timeout)
|
|
|
376
378
|
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_clearTimeout, xt_clear_timeout)
|
|
377
379
|
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_setInterval, xt_set_interval)
|
|
378
380
|
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_clearInterval, xt_clear_interval)
|
|
381
|
+
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_setImmediate, xt_set_immediate)
|
|
382
|
+
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_clearImmediate, xt_clear_immediate)
|
|
383
|
+
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_queueMicrotask, xt_queue_microtask)
|
|
384
|
+
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_structuredClone, xt_structured_clone)
|
|
379
385
|
XT_BUILTIN_TRAMPOLINE(xt_builtin_value_fetch, xt_fetch)
|
|
380
386
|
|
|
381
387
|
xt_value xt_in(xt_value key, xt_value value) {
|
|
@@ -395,7 +401,7 @@ xt_value xt_in(xt_value key, xt_value value) {
|
|
|
395
401
|
xt_string *k = xt_as_string(xt_to_string(key));
|
|
396
402
|
if (k->length == 6 && memcmp(xt_string_bytes(k), "length", 6) == 0) return XT_TRUE;
|
|
397
403
|
int32_t index = xt_to_int32(key);
|
|
398
|
-
return xt_bool(index >= 0 && (uint32_t)index < s
|
|
404
|
+
return xt_bool(index >= 0 && (uint32_t)index < xt_string_utf16_length(s));
|
|
399
405
|
}
|
|
400
406
|
return XT_FALSE;
|
|
401
407
|
}
|
|
@@ -408,6 +414,7 @@ xt_value xt_delete(xt_value value, xt_value key) {
|
|
|
408
414
|
if (xt_property_key_equals(obj->properties[i].key, k)) {
|
|
409
415
|
for (uint32_t j = i + 1; j < obj->count; j++) obj->properties[j - 1] = obj->properties[j];
|
|
410
416
|
obj->count--;
|
|
417
|
+
xt_object_shape_changed(obj);
|
|
411
418
|
break;
|
|
412
419
|
}
|
|
413
420
|
}
|
|
@@ -446,6 +453,8 @@ xt_value xt_closure_new(void *fn, int32_t env_count, xt_value *env) {
|
|
|
446
453
|
function->properties = NULL;
|
|
447
454
|
function->environment = NULL;
|
|
448
455
|
function->prototype = XT_UNDEFINED;
|
|
456
|
+
function->is_generator = function->is_async = function->is_async_generator = 0;
|
|
457
|
+
function->builtin_name = NULL;
|
|
449
458
|
if (env_count > 0) {
|
|
450
459
|
function->environment = (xt_value *)malloc(sizeof(xt_value) * (size_t)env_count);
|
|
451
460
|
for (int32_t i = 0; i < env_count; i++) function->environment[i] = env[i];
|
|
@@ -459,13 +468,17 @@ xt_value xt_closure_call(xt_value value, int32_t argc, xt_value *argv) {
|
|
|
459
468
|
|
|
460
469
|
xt_value xt_call_with_this(xt_value value, xt_value thisValue, int32_t argc, xt_value *argv) {
|
|
461
470
|
if (!XT_IS_FUNCTION(value)) {
|
|
462
|
-
xt_throw(
|
|
471
|
+
xt_throw(xt_error_from_message("TypeError: value is not a function"));
|
|
463
472
|
return XT_UNDEFINED;
|
|
464
473
|
}
|
|
465
474
|
xt_function *function = (xt_function *)XT_GET_PTR(value);
|
|
466
475
|
/* Calling a generator function returns a suspended generator instead of
|
|
467
|
-
* running the body.
|
|
476
|
+
* running the body. `async function*` is a generator whose `.next()` returns
|
|
477
|
+
* promises; `xt_generator_new` reads the marker from the closure. */
|
|
468
478
|
if (function->is_generator) return xt_generator_new(value, thisValue, argc, argv);
|
|
479
|
+
/* An `async` function runs its body on a coroutine and returns a promise,
|
|
480
|
+
* which may already be settled or may resolve after an event-loop turn. */
|
|
481
|
+
if (function->is_async) return xt_async_call(value, thisValue, argc, argv);
|
|
469
482
|
/* The closure value itself is threaded through as `env` so the callee can
|
|
470
483
|
* read its captures with xt_closure_env(env, i). */
|
|
471
484
|
return function->code(thisValue, value, argc, argv);
|
|
@@ -478,11 +491,6 @@ xt_value xt_function_set_prototype(xt_value value, xt_value proto) {
|
|
|
478
491
|
return value;
|
|
479
492
|
}
|
|
480
493
|
|
|
481
|
-
xt_value xt_function_set_generator(xt_value value) {
|
|
482
|
-
if (XT_IS_FUNCTION(value)) ((xt_function *)XT_GET_PTR(value))->is_generator = 1;
|
|
483
|
-
return value;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
494
|
xt_value xt_function_get_prototype(xt_value value) {
|
|
487
495
|
if (XT_IS_FUNCTION(value)) return ((xt_function *)XT_GET_PTR(value))->prototype;
|
|
488
496
|
return XT_UNDEFINED;
|
|
@@ -490,29 +498,29 @@ xt_value xt_function_get_prototype(xt_value value) {
|
|
|
490
498
|
|
|
491
499
|
xt_value xt_new(xt_value ctor, int32_t argc, xt_value *argv) {
|
|
492
500
|
if (!XT_IS_FUNCTION(ctor)) {
|
|
493
|
-
xt_throw(
|
|
501
|
+
xt_throw(xt_error_from_message("TypeError: constructor is not a function"));
|
|
494
502
|
return XT_UNDEFINED;
|
|
495
503
|
}
|
|
496
504
|
xt_function *function = (xt_function *)XT_GET_PTR(ctor);
|
|
497
505
|
xt_value proto = function->prototype;
|
|
498
506
|
xt_value instance = xt_object_new_with_proto(XT_IS_OBJECT(proto) ? proto : XT_UNDEFINED);
|
|
499
507
|
xt_value result = function->code(instance, ctor, argc, argv);
|
|
500
|
-
if (XT_IS_OBJECT(result) || XT_IS_ARRAY(result)) return result;
|
|
508
|
+
if (XT_IS_OBJECT(result) || XT_IS_ARRAY(result) || XT_IS_FUNCTION(result)) return result;
|
|
501
509
|
return instance;
|
|
502
510
|
}
|
|
503
511
|
|
|
504
512
|
xt_value xt_instance_of(xt_value value, xt_value ctor) {
|
|
505
513
|
if (!XT_IS_FUNCTION(ctor)) return XT_FALSE;
|
|
506
514
|
xt_value proto = ((xt_function *)XT_GET_PTR(ctor))->prototype;
|
|
507
|
-
if (
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
515
|
+
if (XT_IS_OBJECT(proto) || XT_IS_ARRAY(proto) || XT_IS_FUNCTION(proto)) {
|
|
516
|
+
/* Walk the value's [[Prototype]] chain. `xt_object_get_prototype` knows the
|
|
517
|
+
* layout of every kind (arrays carry a prototype field; Map/Set/Date/... use
|
|
518
|
+
* their built-in prototype), so this is safe for containers too. */
|
|
519
|
+
xt_value cursor = xt_object_get_prototype(value);
|
|
520
|
+
while (cursor != XT_UNDEFINED && cursor != XT_NULL) {
|
|
521
|
+
if (cursor == proto) return XT_TRUE;
|
|
522
|
+
cursor = xt_object_get_prototype(cursor);
|
|
523
|
+
}
|
|
516
524
|
}
|
|
517
525
|
return XT_FALSE;
|
|
518
526
|
}
|
|
@@ -520,10 +528,11 @@ xt_value xt_instance_of(xt_value value, xt_value ctor) {
|
|
|
520
528
|
/*
|
|
521
529
|
* `value instanceof Array` (and the rest of the built-in constructors).
|
|
522
530
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
531
|
+
* The codegen recognises the direct spelling and asks this helper instead of
|
|
532
|
+
* materialising the constructor value; an alias (`const A = Array`) goes
|
|
533
|
+
* through the ordinary prototype chain in `xt_instance_of`. Ids match
|
|
534
|
+
* `BUILTIN_INSTANCEOF` in `src/codegen/generator/tables.ts`; 16..24 map onto
|
|
535
|
+
* the runtime's `XT_TA_*` order (Uint8Array first).
|
|
527
536
|
*/
|
|
528
537
|
enum {
|
|
529
538
|
XT_INSTANCE_ARRAY = 0,
|
|
@@ -534,6 +543,7 @@ enum {
|
|
|
534
543
|
XT_INSTANCE_DATE = 5,
|
|
535
544
|
XT_INSTANCE_REGEXP = 6,
|
|
536
545
|
XT_INSTANCE_PROMISE = 7,
|
|
546
|
+
XT_INSTANCE_WEAK_MAP = 8, XT_INSTANCE_WEAK_SET = 9, XT_INSTANCE_WEAK_REF = 10,
|
|
537
547
|
XT_INSTANCE_TYPED_ARRAY_FIRST = 16,
|
|
538
548
|
XT_INSTANCE_TYPED_ARRAY_LAST = 24
|
|
539
549
|
};
|
|
@@ -550,16 +560,14 @@ xt_value xt_instance_of_builtin(xt_value value, int32_t id) {
|
|
|
550
560
|
return xt_bool(XT_IS_OBJECT(value) || XT_IS_ARRAY(value) || XT_IS_FUNCTION(value));
|
|
551
561
|
case XT_INSTANCE_FUNCTION:
|
|
552
562
|
return xt_bool(XT_IS_FUNCTION(value));
|
|
553
|
-
case XT_INSTANCE_MAP:
|
|
554
|
-
|
|
555
|
-
case
|
|
556
|
-
|
|
557
|
-
case
|
|
558
|
-
|
|
559
|
-
case XT_INSTANCE_REGEXP:
|
|
560
|
-
|
|
561
|
-
case XT_INSTANCE_PROMISE:
|
|
562
|
-
return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_PROMISE));
|
|
563
|
+
case XT_INSTANCE_MAP: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_MAP));
|
|
564
|
+
case XT_INSTANCE_SET: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_SET));
|
|
565
|
+
case XT_INSTANCE_WEAK_MAP: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_WEAK_MAP));
|
|
566
|
+
case XT_INSTANCE_WEAK_SET: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_WEAK_SET));
|
|
567
|
+
case XT_INSTANCE_WEAK_REF: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_WEAK_REF));
|
|
568
|
+
case XT_INSTANCE_DATE: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_DATE));
|
|
569
|
+
case XT_INSTANCE_REGEXP: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_REGEXP));
|
|
570
|
+
case XT_INSTANCE_PROMISE: return xt_bool(xt_value_has_kind(value, XT_OBJECT_KIND_PROMISE));
|
|
563
571
|
default:
|
|
564
572
|
if (id >= XT_INSTANCE_TYPED_ARRAY_FIRST && id <= XT_INSTANCE_TYPED_ARRAY_LAST) {
|
|
565
573
|
return xt_bool(xt_typed_array_kind_of(value) == id - XT_INSTANCE_TYPED_ARRAY_FIRST);
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime - built-in constructors as first-class values.
|
|
3
|
+
*
|
|
4
|
+
* `Array`, `Object`, `Map`, the Error family, typed arrays and the other
|
|
5
|
+
* globals were previously only recognised by name in the code generator. This
|
|
6
|
+
* unit turns them into ordinary function values:
|
|
7
|
+
*
|
|
8
|
+
* const A = Array;
|
|
9
|
+
* const a = new A(1, 2, 3);
|
|
10
|
+
* A.isArray(a); // statics travel with the value
|
|
11
|
+
* a instanceof A; // prototype chain, not the name
|
|
12
|
+
*
|
|
13
|
+
* Every constructor is cached (and registered as a GC root), has metadata
|
|
14
|
+
* (`name` / `length`), a `prototype` object and a `builtin_name` that the
|
|
15
|
+
* property path uses to resolve statics.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "rt_internal.h"
|
|
19
|
+
|
|
20
|
+
#include <math.h>
|
|
21
|
+
#include <stdio.h>
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
|
|
25
|
+
/* -- constructor table ---------------------------------------------------- */
|
|
26
|
+
|
|
27
|
+
enum {
|
|
28
|
+
XT_PROTO_OBJECT,
|
|
29
|
+
XT_PROTO_ARRAY,
|
|
30
|
+
XT_PROTO_FUNCTION,
|
|
31
|
+
XT_PROTO_PLAIN,
|
|
32
|
+
XT_PROTO_ERROR,
|
|
33
|
+
XT_PROTO_TYPED
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
typedef struct {
|
|
37
|
+
const char *name;
|
|
38
|
+
int32_t arity;
|
|
39
|
+
int32_t prototype;
|
|
40
|
+
} xt_ctor_spec;
|
|
41
|
+
|
|
42
|
+
#define XT_CTOR_SPECS(X) \
|
|
43
|
+
X(Array, 1, XT_PROTO_ARRAY) \
|
|
44
|
+
X(Object, 1, XT_PROTO_OBJECT) \
|
|
45
|
+
X(Function, 1, XT_PROTO_FUNCTION) \
|
|
46
|
+
X(Map, 0, XT_PROTO_PLAIN) \
|
|
47
|
+
X(Set, 0, XT_PROTO_PLAIN) \
|
|
48
|
+
X(WeakMap, 0, XT_PROTO_PLAIN) \
|
|
49
|
+
X(WeakSet, 0, XT_PROTO_PLAIN) \
|
|
50
|
+
X(WeakRef, 1, XT_PROTO_PLAIN) \
|
|
51
|
+
X(Date, 7, XT_PROTO_PLAIN) \
|
|
52
|
+
X(RegExp, 2, XT_PROTO_PLAIN) \
|
|
53
|
+
X(Promise, 1, XT_PROTO_PLAIN) \
|
|
54
|
+
X(Uint8Array, 3, XT_PROTO_TYPED) \
|
|
55
|
+
X(Int8Array, 3, XT_PROTO_TYPED) \
|
|
56
|
+
X(Uint8ClampedArray, 3, XT_PROTO_TYPED) \
|
|
57
|
+
X(Uint16Array, 3, XT_PROTO_TYPED) \
|
|
58
|
+
X(Int16Array, 3, XT_PROTO_TYPED) \
|
|
59
|
+
X(Uint32Array, 3, XT_PROTO_TYPED) \
|
|
60
|
+
X(Int32Array, 3, XT_PROTO_TYPED) \
|
|
61
|
+
X(Float32Array, 3, XT_PROTO_TYPED) \
|
|
62
|
+
X(Float64Array, 3, XT_PROTO_TYPED) \
|
|
63
|
+
X(Error, 1, XT_PROTO_ERROR) \
|
|
64
|
+
X(TypeError, 1, XT_PROTO_ERROR) \
|
|
65
|
+
X(RangeError, 1, XT_PROTO_ERROR) \
|
|
66
|
+
X(SyntaxError, 1, XT_PROTO_ERROR) \
|
|
67
|
+
X(ReferenceError, 1, XT_PROTO_ERROR) \
|
|
68
|
+
X(EvalError, 1, XT_PROTO_ERROR) \
|
|
69
|
+
X(URIError, 1, XT_PROTO_ERROR) \
|
|
70
|
+
X(AggregateError, 2, XT_PROTO_ERROR) \
|
|
71
|
+
X(Number, 1, XT_PROTO_PLAIN) \
|
|
72
|
+
X(String, 1, XT_PROTO_PLAIN) \
|
|
73
|
+
X(Boolean, 1, XT_PROTO_PLAIN) \
|
|
74
|
+
X(BigInt, 1, XT_PROTO_PLAIN) \
|
|
75
|
+
X(Symbol, 0, XT_PROTO_PLAIN)
|
|
76
|
+
|
|
77
|
+
#define XT_CTOR_ENUM(name, arity, proto) XT_CTOR_##name,
|
|
78
|
+
enum { XT_CTOR_SPECS(XT_CTOR_ENUM) XT_CTOR_COUNT };
|
|
79
|
+
#undef XT_CTOR_ENUM
|
|
80
|
+
|
|
81
|
+
#define XT_CTOR_ENTRY(name, arity, proto) {#name, arity, proto},
|
|
82
|
+
static const xt_ctor_spec XT_CTOR_TABLE[XT_CTOR_COUNT] = {XT_CTOR_SPECS(XT_CTOR_ENTRY)};
|
|
83
|
+
#undef XT_CTOR_ENTRY
|
|
84
|
+
|
|
85
|
+
static xt_value xt_ctor_cache[XT_CTOR_COUNT];
|
|
86
|
+
static xt_value xt_ctor_plain_protos[XT_CTOR_COUNT];
|
|
87
|
+
static int xt_ctor_cache_ready = 0;
|
|
88
|
+
|
|
89
|
+
static void xt_ctor_cache_init(void) {
|
|
90
|
+
if (xt_ctor_cache_ready) return;
|
|
91
|
+
xt_ctor_cache_ready = 1;
|
|
92
|
+
xt_gc_add_root_range(xt_ctor_cache, XT_CTOR_COUNT);
|
|
93
|
+
xt_gc_add_root_range(xt_ctor_plain_protos, XT_CTOR_COUNT);
|
|
94
|
+
for (int i = 0; i < XT_CTOR_COUNT; i++) {
|
|
95
|
+
xt_ctor_cache[i] = XT_UNDEFINED;
|
|
96
|
+
xt_ctor_plain_protos[i] = XT_UNDEFINED;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static int xt_ctor_index(const char *name) {
|
|
101
|
+
if (!name) return -1;
|
|
102
|
+
for (int i = 0; i < XT_CTOR_COUNT; i++) {
|
|
103
|
+
if (strcmp(XT_CTOR_TABLE[i].name, name) == 0) return i;
|
|
104
|
+
}
|
|
105
|
+
return -1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* -- construction --------------------------------------------------------- */
|
|
109
|
+
|
|
110
|
+
static int xt_ctor_is_typed_array(const char *name) {
|
|
111
|
+
int index = xt_ctor_index(name);
|
|
112
|
+
return index >= XT_CTOR_Uint8Array && index <= XT_CTOR_Float64Array;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static int xt_ctor_is_error(const char *name) {
|
|
116
|
+
static const char *const names[] = {
|
|
117
|
+
"Error", "TypeError", "RangeError", "SyntaxError",
|
|
118
|
+
"ReferenceError", "EvalError", "URIError", "AggregateError",
|
|
119
|
+
};
|
|
120
|
+
for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
|
|
121
|
+
if (strcmp(name, names[i]) == 0) return 1;
|
|
122
|
+
}
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
xt_value xt_array_ctor(int32_t argc, xt_value *argv) {
|
|
127
|
+
/* `Array(3)` allocates a length-3 array; any other argument list becomes the
|
|
128
|
+
* elements. */
|
|
129
|
+
if (argc == 1 && XT_IS_NUMBER(argv[0])) {
|
|
130
|
+
double length = xt_to_number(argv[0]);
|
|
131
|
+
if (!(length >= 0) || floor(length) != length || length > 4294967295.0) {
|
|
132
|
+
xt_throw(xt_error_from_message("RangeError: Invalid array length"));
|
|
133
|
+
return XT_UNDEFINED;
|
|
134
|
+
}
|
|
135
|
+
xt_value array = xt_array_new(0, NULL);
|
|
136
|
+
if (length > 0) xt_array_set(array, xt_number(length - 1), XT_UNDEFINED);
|
|
137
|
+
return array;
|
|
138
|
+
}
|
|
139
|
+
return xt_array_new(argc, argv);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
xt_value xt_object_ctor(int32_t argc, xt_value *argv) {
|
|
143
|
+
if (argc == 0) return xt_object_new();
|
|
144
|
+
xt_value value = argv[0];
|
|
145
|
+
if (value == XT_UNDEFINED || value == XT_NULL) return xt_object_new();
|
|
146
|
+
/* `Object(value)` returns the object unchanged. Primitives are not boxed in
|
|
147
|
+
* this runtime, so they pass through like `new Object(primitive)` did. */
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* `Function()` / `new Function()`: source evaluation is not supported, so the
|
|
152
|
+
* constructor gives an empty function (declared functions get their metadata
|
|
153
|
+
* from the codegen; this body simply does nothing). */
|
|
154
|
+
static xt_value xt_function_ctor_body(xt_value thisValue, xt_value env, int32_t argc,
|
|
155
|
+
xt_value *argv) {
|
|
156
|
+
(void)thisValue;
|
|
157
|
+
(void)env;
|
|
158
|
+
(void)argc;
|
|
159
|
+
(void)argv;
|
|
160
|
+
return XT_UNDEFINED;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static xt_value xt_builtin_ctor_call(const char *name, int32_t argc, xt_value *argv) {
|
|
164
|
+
xt_value nameValue = xt_string_from_cstr(name);
|
|
165
|
+
if (strcmp(name, "Array") == 0) return xt_array_ctor(argc, argv);
|
|
166
|
+
if (strcmp(name, "Object") == 0) return xt_object_ctor(argc, argv);
|
|
167
|
+
if (strcmp(name, "Function") == 0) {
|
|
168
|
+
return xt_closure_new((void *)xt_function_ctor_body, 0, NULL);
|
|
169
|
+
}
|
|
170
|
+
if (strcmp(name, "Map") == 0) return xt_map_ctor(argc, argv);
|
|
171
|
+
if (strcmp(name, "Set") == 0) return xt_set_ctor(argc, argv);
|
|
172
|
+
if (strcmp(name, "WeakMap") == 0) return xt_weak_map_ctor(argc, argv);
|
|
173
|
+
if (strcmp(name, "WeakSet") == 0) return xt_weak_set_ctor(argc, argv);
|
|
174
|
+
if (strcmp(name, "WeakRef") == 0) return xt_weak_ref_ctor(argc, argv);
|
|
175
|
+
if (strcmp(name, "Date") == 0) return xt_date_ctor(argc, argv);
|
|
176
|
+
if (strcmp(name, "RegExp") == 0) return xt_regexp_ctor(argc, argv);
|
|
177
|
+
if (strcmp(name, "Promise") == 0) return xt_promise_ctor(argc, argv);
|
|
178
|
+
if (strcmp(name, "Number") == 0) return xt_number_ctor(argc, argv);
|
|
179
|
+
if (strcmp(name, "String") == 0) return xt_string_ctor(argc, argv);
|
|
180
|
+
if (strcmp(name, "Boolean") == 0) return xt_boolean_ctor(argc, argv);
|
|
181
|
+
if (strcmp(name, "BigInt") == 0) return xt_bigint_ctor(argc, argv);
|
|
182
|
+
if (strcmp(name, "Symbol") == 0) return xt_symbol(argc, argv);
|
|
183
|
+
if (xt_ctor_is_typed_array(name)) return xt_typed_array_ctor_by_name(nameValue, argc, argv);
|
|
184
|
+
if (xt_ctor_is_error(name)) return xt_error_ctor_by_name(nameValue, argc, argv);
|
|
185
|
+
return XT_UNDEFINED;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* The closure body of every first-class constructor. The name travels in
|
|
189
|
+
* environment slot 0. */
|
|
190
|
+
static xt_value xt_builtin_ctor_invoke(xt_value thisValue, xt_value env, int32_t argc,
|
|
191
|
+
xt_value *argv) {
|
|
192
|
+
(void)thisValue;
|
|
193
|
+
xt_value nameValue = xt_closure_env(env, 0);
|
|
194
|
+
const char *name = xt_string_data(nameValue);
|
|
195
|
+
if (!name) return XT_UNDEFINED;
|
|
196
|
+
return xt_builtin_ctor_call(name, argc, argv);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* -- prototypes ----------------------------------------------------------- */
|
|
200
|
+
|
|
201
|
+
static xt_value xt_ctor_prototype(int index, xt_value nameValue) {
|
|
202
|
+
const xt_ctor_spec *spec = &XT_CTOR_TABLE[index];
|
|
203
|
+
switch (spec->prototype) {
|
|
204
|
+
case XT_PROTO_OBJECT:
|
|
205
|
+
return xt_object_prototype();
|
|
206
|
+
case XT_PROTO_ARRAY:
|
|
207
|
+
return xt_array_prototype();
|
|
208
|
+
case XT_PROTO_FUNCTION:
|
|
209
|
+
return xt_function_prototype();
|
|
210
|
+
case XT_PROTO_ERROR:
|
|
211
|
+
return xt_error_prototype(nameValue);
|
|
212
|
+
case XT_PROTO_TYPED:
|
|
213
|
+
return xt_typed_array_prototype(nameValue);
|
|
214
|
+
case XT_PROTO_PLAIN:
|
|
215
|
+
default:
|
|
216
|
+
if (xt_ctor_plain_protos[index] == XT_UNDEFINED) {
|
|
217
|
+
xt_ctor_plain_protos[index] = xt_object_new();
|
|
218
|
+
}
|
|
219
|
+
return xt_ctor_plain_protos[index];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
xt_value xt_builtin_constructor(xt_value nameValue) {
|
|
224
|
+
if (!XT_IS_STRING(nameValue)) return XT_UNDEFINED;
|
|
225
|
+
xt_ctor_cache_init();
|
|
226
|
+
const char *name = xt_string_data(nameValue);
|
|
227
|
+
int index = xt_ctor_index(name);
|
|
228
|
+
if (index < 0) return XT_UNDEFINED;
|
|
229
|
+
if (xt_ctor_cache[index] != XT_UNDEFINED) return xt_ctor_cache[index];
|
|
230
|
+
|
|
231
|
+
/* The Error family already has a first-class constructor factory that keeps
|
|
232
|
+
* one closure per prototype (`__ctor`), so reuse it to keep
|
|
233
|
+
* `err.constructor === Error` stable no matter which side is evaluated
|
|
234
|
+
* first. */
|
|
235
|
+
if (xt_ctor_is_error(name)) {
|
|
236
|
+
xt_value errorCtor = xt_error_constructor(nameValue);
|
|
237
|
+
if (errorCtor != XT_UNDEFINED) {
|
|
238
|
+
xt_ctor_cache[index] = errorCtor;
|
|
239
|
+
return errorCtor;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
xt_value env[1] = {nameValue};
|
|
244
|
+
xt_value closure = xt_closure_new((void *)xt_builtin_ctor_invoke, 1, env);
|
|
245
|
+
xt_function *function = (xt_function *)XT_GET_PTR(closure);
|
|
246
|
+
function->builtin_name = XT_CTOR_TABLE[index].name;
|
|
247
|
+
xt_function_set_metadata(closure, nameValue, XT_CTOR_TABLE[index].arity);
|
|
248
|
+
/* Cache before resolving the prototype: `Array.prototype` and
|
|
249
|
+
* `Object.prototype` install their `constructor` property by asking for the
|
|
250
|
+
* constructor again. */
|
|
251
|
+
xt_ctor_cache[index] = closure;
|
|
252
|
+
|
|
253
|
+
xt_value proto = xt_ctor_prototype(index, nameValue);
|
|
254
|
+
if (proto != XT_UNDEFINED) {
|
|
255
|
+
xt_function_set_prototype(closure, proto);
|
|
256
|
+
/* `Array.prototype` and `Object.prototype` install their own constructor
|
|
257
|
+
* while resolving the prototype above; every other prototype gets it here. */
|
|
258
|
+
int32_t kind = XT_CTOR_TABLE[index].prototype;
|
|
259
|
+
if (kind != XT_PROTO_ARRAY && kind != XT_PROTO_OBJECT) {
|
|
260
|
+
xt_object_set(proto, xt_string_from_cstr("constructor"), closure);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return closure;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* -- statics -------------------------------------------------------------- */
|
|
267
|
+
|
|
268
|
+
static const char *const XT_ARRAY_STATICS[] = {"isArray", "of", "from"};
|
|
269
|
+
static const char *const XT_OBJECT_STATICS[] = {
|
|
270
|
+
"keys", "values", "entries", "assign", "getOwnPropertyNames",
|
|
271
|
+
"getOwnPropertySymbols", "groupBy", "freeze", "isFrozen", "fromEntries",
|
|
272
|
+
"getPrototypeOf", "setPrototypeOf", "hasOwn", "is", "create",
|
|
273
|
+
"defineProperty", "getOwnPropertyDescriptor", "getOwnPropertyDescriptors",
|
|
274
|
+
};
|
|
275
|
+
static const char *const XT_NUMBER_STATICS[] = {
|
|
276
|
+
"isInteger", "isSafeInteger", "isFinite", "isNaN", "parseFloat", "parseInt",
|
|
277
|
+
};
|
|
278
|
+
static const char *const XT_NUMBER_CONSTANTS[] = {
|
|
279
|
+
"MAX_SAFE_INTEGER", "MIN_SAFE_INTEGER", "MAX_VALUE", "MIN_VALUE", "EPSILON",
|
|
280
|
+
"POSITIVE_INFINITY", "NEGATIVE_INFINITY", "NaN",
|
|
281
|
+
};
|
|
282
|
+
static const char *const XT_STRING_STATICS[] = {"fromCharCode", "fromCodePoint", "raw"};
|
|
283
|
+
static const char *const XT_BIGINT_STATICS[] = {"asIntN", "asUintN"};
|
|
284
|
+
static const char *const XT_SYMBOL_STATICS[] = {"for", "keyFor"};
|
|
285
|
+
static const char *const XT_DATE_STATICS[] = {"now", "parse", "UTC"};
|
|
286
|
+
static const char *const XT_PROMISE_STATICS[] = {
|
|
287
|
+
"resolve", "reject", "all", "allSettled", "race", "any", "withResolvers",
|
|
288
|
+
};
|
|
289
|
+
static const char *const XT_TYPED_ARRAY_STATICS[] = {"from", "of"};
|
|
290
|
+
|
|
291
|
+
static int xt_name_in(const char *name, const char *const *names, size_t count) {
|
|
292
|
+
for (size_t i = 0; i < count; i++) {
|
|
293
|
+
if (strcmp(name, names[i]) == 0) return 1;
|
|
294
|
+
}
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
#define XT_NAMES_COUNT(names) (sizeof(names) / sizeof((names)[0]))
|
|
299
|
+
|
|
300
|
+
static int xt_ctor_has_static(const char *namespace, const char *method) {
|
|
301
|
+
if (strcmp(namespace, "Array") == 0)
|
|
302
|
+
return xt_name_in(method, XT_ARRAY_STATICS, XT_NAMES_COUNT(XT_ARRAY_STATICS));
|
|
303
|
+
if (strcmp(namespace, "Object") == 0)
|
|
304
|
+
return xt_name_in(method, XT_OBJECT_STATICS, XT_NAMES_COUNT(XT_OBJECT_STATICS));
|
|
305
|
+
if (strcmp(namespace, "Number") == 0)
|
|
306
|
+
return xt_name_in(method, XT_NUMBER_STATICS, XT_NAMES_COUNT(XT_NUMBER_STATICS));
|
|
307
|
+
if (strcmp(namespace, "String") == 0)
|
|
308
|
+
return xt_name_in(method, XT_STRING_STATICS, XT_NAMES_COUNT(XT_STRING_STATICS));
|
|
309
|
+
if (strcmp(namespace, "BigInt") == 0)
|
|
310
|
+
return xt_name_in(method, XT_BIGINT_STATICS, XT_NAMES_COUNT(XT_BIGINT_STATICS));
|
|
311
|
+
if (strcmp(namespace, "Symbol") == 0)
|
|
312
|
+
return xt_name_in(method, XT_SYMBOL_STATICS, XT_NAMES_COUNT(XT_SYMBOL_STATICS));
|
|
313
|
+
if (strcmp(namespace, "Date") == 0)
|
|
314
|
+
return xt_name_in(method, XT_DATE_STATICS, XT_NAMES_COUNT(XT_DATE_STATICS));
|
|
315
|
+
if (strcmp(namespace, "Promise") == 0)
|
|
316
|
+
return xt_name_in(method, XT_PROMISE_STATICS, XT_NAMES_COUNT(XT_PROMISE_STATICS));
|
|
317
|
+
if (xt_ctor_is_typed_array(namespace))
|
|
318
|
+
return xt_name_in(method, XT_TYPED_ARRAY_STATICS, XT_NAMES_COUNT(XT_TYPED_ARRAY_STATICS));
|
|
319
|
+
return 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
static xt_value xt_builtin_static_call(const char *namespace, const char *method, int32_t argc,
|
|
323
|
+
xt_value *argv) {
|
|
324
|
+
xt_value nameValue = xt_string_from_cstr(namespace);
|
|
325
|
+
xt_value methodValue = xt_string_from_cstr(method);
|
|
326
|
+
if (strcmp(namespace, "Array") == 0) return xt_array_static(methodValue, argc, argv);
|
|
327
|
+
if (strcmp(namespace, "Object") == 0) return xt_object_static(methodValue, argc, argv);
|
|
328
|
+
if (strcmp(namespace, "Number") == 0) return xt_number_static(methodValue, argc, argv);
|
|
329
|
+
if (strcmp(namespace, "String") == 0) return xt_string_static(methodValue, argc, argv);
|
|
330
|
+
if (strcmp(namespace, "BigInt") == 0) return xt_bigint_static(methodValue, argc, argv);
|
|
331
|
+
if (strcmp(namespace, "Symbol") == 0) return xt_symbol_static(methodValue, argc, argv);
|
|
332
|
+
if (strcmp(namespace, "Date") == 0) return xt_date_static(methodValue, argc, argv);
|
|
333
|
+
if (strcmp(namespace, "Promise") == 0) return xt_promise_static(methodValue, argc, argv);
|
|
334
|
+
if (xt_ctor_is_typed_array(namespace))
|
|
335
|
+
return xt_typed_array_static_by_name(nameValue, methodValue, argc, argv);
|
|
336
|
+
return XT_UNDEFINED;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
static xt_value xt_builtin_static_invoke(xt_value thisValue, xt_value env, int32_t argc,
|
|
340
|
+
xt_value *argv) {
|
|
341
|
+
(void)thisValue;
|
|
342
|
+
const char *namespace = xt_string_data(xt_closure_env(env, 0));
|
|
343
|
+
const char *method = xt_string_data(xt_closure_env(env, 1));
|
|
344
|
+
if (!namespace || !method) return XT_UNDEFINED;
|
|
345
|
+
return xt_builtin_static_call(namespace, method, argc, argv);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
xt_value xt_builtin_static_value(xt_value ctor, xt_value key) {
|
|
349
|
+
if (!XT_IS_FUNCTION(ctor) || !XT_IS_STRING(key)) return XT_UNDEFINED;
|
|
350
|
+
xt_function *function = (xt_function *)XT_GET_PTR(ctor);
|
|
351
|
+
const char *namespace = function->builtin_name;
|
|
352
|
+
if (!namespace) return XT_UNDEFINED;
|
|
353
|
+
const char *method = xt_string_data(key);
|
|
354
|
+
if (!method) return XT_UNDEFINED;
|
|
355
|
+
|
|
356
|
+
/* Values that are not functions. */
|
|
357
|
+
if (strcmp(namespace, "Symbol") == 0) {
|
|
358
|
+
xt_value wellKnown = xt_symbol_get(key);
|
|
359
|
+
if (wellKnown != XT_UNDEFINED) return wellKnown;
|
|
360
|
+
}
|
|
361
|
+
if (strcmp(namespace, "Number") == 0 &&
|
|
362
|
+
xt_name_in(method, XT_NUMBER_CONSTANTS, XT_NAMES_COUNT(XT_NUMBER_CONSTANTS))) {
|
|
363
|
+
return xt_number_static(key, 0, NULL);
|
|
364
|
+
}
|
|
365
|
+
if (xt_ctor_is_typed_array(namespace) && strcmp(method, "BYTES_PER_ELEMENT") == 0) {
|
|
366
|
+
xt_value nameValue = xt_string_from_cstr(namespace);
|
|
367
|
+
xt_value proto = xt_typed_array_prototype(nameValue);
|
|
368
|
+
return xt_object_get(proto, key);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (!xt_ctor_has_static(namespace, method)) return XT_UNDEFINED;
|
|
372
|
+
if (xt_truthy(xt_object_has_own(ctor, key))) return xt_object_get(ctor, key);
|
|
373
|
+
|
|
374
|
+
xt_value env[2] = {xt_string_from_cstr(namespace), key};
|
|
375
|
+
xt_value closure = xt_closure_new((void *)xt_builtin_static_invoke, 2, env);
|
|
376
|
+
xt_function_set_metadata(closure, key, 0);
|
|
377
|
+
xt_object_set(ctor, key, closure);
|
|
378
|
+
return closure;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/* -- prototype lookup for runtime kinds ----------------------------------- */
|
|
382
|
+
|
|
383
|
+
xt_value xt_builtin_prototype_for_kind(int32_t kind) {
|
|
384
|
+
const char *name = NULL;
|
|
385
|
+
switch (kind) {
|
|
386
|
+
case XT_OBJECT_KIND_MAP: name = "Map"; break;
|
|
387
|
+
case XT_OBJECT_KIND_SET: name = "Set"; break;
|
|
388
|
+
case XT_OBJECT_KIND_WEAK_MAP: name = "WeakMap"; break;
|
|
389
|
+
case XT_OBJECT_KIND_WEAK_SET: name = "WeakSet"; break;
|
|
390
|
+
case XT_OBJECT_KIND_WEAK_REF: name = "WeakRef"; break;
|
|
391
|
+
case XT_OBJECT_KIND_DATE: name = "Date"; break;
|
|
392
|
+
case XT_OBJECT_KIND_REGEXP: name = "RegExp"; break;
|
|
393
|
+
case XT_OBJECT_KIND_PROMISE: name = "Promise"; break;
|
|
394
|
+
case XT_OBJECT_KIND_SYMBOL: name = "Symbol"; break;
|
|
395
|
+
default: return XT_UNDEFINED;
|
|
396
|
+
}
|
|
397
|
+
xt_value constructor = xt_builtin_constructor(xt_string_from_cstr(name));
|
|
398
|
+
return xt_function_get_prototype(constructor);
|
|
399
|
+
}
|