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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# `util`
|
|
2
|
+
|
|
3
|
+
> Part of [Node extension: implemented](../node.md) · [简体中文](../../zh-CN/implemented/node/util.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/extensions/node/util/index.ts`, `runtime/ext_node/util/util.c`
|
|
6
|
+
|
|
7
|
+
Both named imports (`import { format } from "util"`) and namespace calls
|
|
8
|
+
(`import util from "util"` / `import * as util from "util"`) are supported.
|
|
9
|
+
|
|
10
|
+
| Function | Notes |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `format(fmt, ...args)` | `%s` `%d` `%i` `%f` `%j` `%o` `%O` `%c` `%%` placeholders |
|
|
13
|
+
| `formatWithOptions(opts, fmt, ...args)` | options accepted and ignored |
|
|
14
|
+
| `inspect(value)` | recursive printer (depth-limited, strings quoted) |
|
|
15
|
+
| `isDeepStrictEqual(a, b)` | structural comparison (`NaN` equals `NaN`) |
|
|
16
|
+
| `inherits(ctor, superCtor)` | prototype wiring |
|
|
17
|
+
| `deprecate(fn, msg)` | returns `fn` unchanged (there is no warning channel) |
|
|
18
|
+
| `promisify(fn)` | wraps a trailing-callback function into a `Promise` |
|
|
19
|
+
| `isString` `isNumber` `isBoolean` `isUndefined` `isNull` `isFunction` `isArray` `isObject` `isBuffer` `isDate` `isRegExp` `isPromise` `isError` | type predicates |
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { format, promisify } from "util";
|
|
23
|
+
|
|
24
|
+
console.log(format("%s=%d", "n", 3)); // n=3
|
|
25
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# `worker_threads`
|
|
2
|
+
|
|
3
|
+
> Part of [Node extension: implemented](../node.md) · [简体中文](../../zh-CN/implemented/node/worker-threads.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/extensions/node/worker_threads/index.ts`, `runtime/ext_node/worker_threads/worker_threads.c`
|
|
6
|
+
|
|
7
|
+
- `Worker`, `isMainThread`, `workerData`, `parentPort`.
|
|
8
|
+
- xbintsc emulates a worker by re-running the current executable as a child
|
|
9
|
+
process; `isMainThread` / `workerData` / `parentPort` are value bindings
|
|
10
|
+
(nullary runtime getters) and `Worker` is a constructor.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# `zlib`
|
|
2
|
+
|
|
3
|
+
> Part of [Node extension: implemented](../node.md) · [简体中文](../../zh-CN/implemented/node/zlib.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/extensions/node/zlib/index.ts`, `runtime/ext_node/zlib/zlib.c`
|
|
6
|
+
|
|
7
|
+
- Only `createGzip()` is implemented. It returns a gzip transform consumed by
|
|
8
|
+
[`stream/promises`](./stream-promises.md) `pipeline`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Node extension: implemented
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/node.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/extensions/node/`, `runtime/ext_node/`
|
|
6
|
+
|
|
7
|
+
The `node` extension is optional: enable it with `--ext node` (or
|
|
8
|
+
`"extensions": ["node"]` in `xbintsc.config.json`). It is a platform extension:
|
|
9
|
+
one subdirectory per Node module, pairing the TypeScript exports with the C
|
|
10
|
+
implementation. Adding a module does not change the core compiler; the extension
|
|
11
|
+
contract is described in [Extension mechanism](./extensions.md).
|
|
12
|
+
|
|
13
|
+
Every module has its own page so a change to one module does not collide with
|
|
14
|
+
work on another. Missing or different behaviour is recorded under
|
|
15
|
+
[Node extension: unimplemented](../unimplemented/node.md).
|
|
16
|
+
|
|
17
|
+
## Modules
|
|
18
|
+
|
|
19
|
+
| Module | Page | Notes |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `fs` | [fs](./node/fs.md) | synchronous API only |
|
|
22
|
+
| `fs/promises` | [fs/promises](./node/fs-promises.md) | reactor-driven file and `FileHandle` operations on the async I/O pool |
|
|
23
|
+
| `path` | [path](./node/path.md) | `path.<name>(...)` namespace calls |
|
|
24
|
+
| `os` | [os](./node/os.md) | `os.<name>(...)` namespace calls |
|
|
25
|
+
| `process` | [process](./node/process.md) | object: methods and properties |
|
|
26
|
+
| `buffer` | [buffer](./node/buffer.md) | `Buffer` represented as a plain object |
|
|
27
|
+
| `stream` | [stream](./node/stream.md) | `Readable` / `Writable` / `Duplex` / `Transform` / `PassThrough` |
|
|
28
|
+
| `stream/promises` | [stream/promises](./node/stream-promises.md) | `pipeline` only |
|
|
29
|
+
| `net` | [net](./node/net.md) | TCP server and client |
|
|
30
|
+
| `dgram` | [dgram](./node/dgram.md) | UDP sockets |
|
|
31
|
+
| `http` | [http](./node/http.md) | server and client, `Connection: close` |
|
|
32
|
+
| `child_process` | [child_process](./node/child-process.md) | `spawnSync` only |
|
|
33
|
+
| `events` | [events](./node/events.md) | `EventEmitter` (global and named export) |
|
|
34
|
+
| `util` | [util](./node/util.md) | formatting, inspection and predicates |
|
|
35
|
+
| `querystring` | [querystring](./node/querystring.md) | parse / stringify / escape |
|
|
36
|
+
| `assert` | [assert](./node/assert.md) | assertion functions |
|
|
37
|
+
| `test` | [test](./node/test.md) | minimal TAP runner |
|
|
38
|
+
| `crypto` | [crypto](./node/crypto.md) | `createHash` (SHA-1 / SHA-256) |
|
|
39
|
+
| `url` | [url](./node/url.md) | `pathToFileURL` / `fileURLToPath` |
|
|
40
|
+
| `zlib` | [zlib](./node/zlib.md) | `createGzip` only |
|
|
41
|
+
| `worker_threads` | [worker_threads](./node/worker-threads.md) | emulated with child processes |
|
|
42
|
+
|
|
43
|
+
## Where does a change belong?
|
|
44
|
+
|
|
45
|
+
A Node module change normally touches `src/extensions/node/<module>/` and
|
|
46
|
+
`runtime/ext_node/<module>/`; document it in `node/<module>.md` and, if it
|
|
47
|
+
changes a limitation, in the matching page under
|
|
48
|
+
`../../unimplemented/node/`. The compiler core does not change.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Operators and assignment
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/operators.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/codegen/llvm.ts` (`BINARY_RUNTIME`, `emitPrefix`, `emitPostfix`, `emitAssignment`)
|
|
6
|
+
|
|
7
|
+
## Arithmetic
|
|
8
|
+
|
|
9
|
+
`+ - * / % **` (`**` is right-associative)
|
|
10
|
+
|
|
11
|
+
## Comparison and equality
|
|
12
|
+
|
|
13
|
+
`< <= > >=`, `== !=` (loose equality), `=== !==` (strict equality)
|
|
14
|
+
|
|
15
|
+
## Logical and short-circuit
|
|
16
|
+
|
|
17
|
+
`&& || ??` (with short-circuit evaluation), `!`
|
|
18
|
+
|
|
19
|
+
## Bitwise
|
|
20
|
+
|
|
21
|
+
`& | ^ ~ << >> >>>`
|
|
22
|
+
|
|
23
|
+
## Unary
|
|
24
|
+
|
|
25
|
+
`+ - ! ~`, prefix / postfix `++ --`
|
|
26
|
+
|
|
27
|
+
## Assignment
|
|
28
|
+
|
|
29
|
+
`= += -= *= /= %= **= <<= >>= >>>= &= |= ^= &&= ||= ??=`
|
|
30
|
+
|
|
31
|
+
## Other expression operators
|
|
32
|
+
|
|
33
|
+
- Comma expression `,`
|
|
34
|
+
- `in` operator (`key in obj`, mapped to `xt_in`)
|
|
35
|
+
- `delete obj.key` / `delete obj[key]` (mapped to `xt_delete`)
|
|
36
|
+
- `instanceof` (mapped to `xt_instance_of`, walking the prototype chain)
|
|
37
|
+
|
|
38
|
+
> `typeof` / `void` are implemented as unary operators.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Parser
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/parser.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/parser/parser.ts`, `src/ast/nodes.ts`
|
|
6
|
+
|
|
7
|
+
Module syntax (`import` / `export`, import attributes) and the driver-level bundling that gives it runtime meaning are covered in [Module system](./modules.md).
|
|
8
|
+
|
|
9
|
+
## Statements
|
|
10
|
+
|
|
11
|
+
- Variable declarations: `var` / `let` / `const`, with multiple declarators `const a = 1, b = 2;`
|
|
12
|
+
- Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`)
|
|
13
|
+
- `class` declarations / class expressions (constructor, fields, methods, `static`, `extends`)
|
|
14
|
+
- `if` / `else`
|
|
15
|
+
- `while`, `do...while`
|
|
16
|
+
- `for` (init, condition and increment may all be omitted)
|
|
17
|
+
- `for...of`, `for...in`
|
|
18
|
+
- `return`, `break`, `continue`, `throw` (including labeled `break label` / `continue label`)
|
|
19
|
+
- `switch` / `case` / `default` (including fall-through)
|
|
20
|
+
- `try` / `catch` / `finally` (catchable exceptions based on a runtime setjmp frame)
|
|
21
|
+
- `export var` / `export let` / `export const` (modifier parsed then erased)
|
|
22
|
+
- Block statement `{}`, empty statement `;`, `debugger;`
|
|
23
|
+
- Expression statements
|
|
24
|
+
|
|
25
|
+
## Expressions
|
|
26
|
+
|
|
27
|
+
- All common operators with precedence / associativity (see [Operators](./operators.md))
|
|
28
|
+
- Assignment expressions and all compound assignments (see [Operators](./operators.md))
|
|
29
|
+
- Conditional (ternary) expressions `a ? b : c`
|
|
30
|
+
- Arrow functions `() => expr` / `() => { ... }` (including type parameters and return type annotations)
|
|
31
|
+
- Function expressions `function () {}` and named function expressions `function g() {}`
|
|
32
|
+
- Call expressions `f(...)`, member access `a.b`, element access `a[i]`
|
|
33
|
+
- Array literals `[1, 2]`, sparse array elision, spread `[...a]` (also over strings, `Map` and `Set`)
|
|
34
|
+
- Object literals `{ a: 1 }`, shorthand properties `{ a }`, method shorthand `{ m() {} }`, getter / setter shorthand `{ get x() {} }` / `{ set x(v) {} }`, computed keys `{ [expr]: 1 }`, object spread `{ ...obj }`
|
|
35
|
+
- Template literal `${}` substitutions, tagged templates (with raw strings and `String.raw`)
|
|
36
|
+
- Parenthesized expressions, `as` / `satisfies` / non-null assertion `!` (type erasure)
|
|
37
|
+
- Unary: `+ - ! ~ typeof void`, prefix / postfix `++ --`
|
|
38
|
+
- Optional chaining `?.` / `?.[]` / `?.()` (with nullish short-circuit semantics)
|
|
39
|
+
- `delete` expressions (delete an object property)
|
|
40
|
+
|
|
41
|
+
## TypeScript type syntax (parsed only, structure preserved then erased)
|
|
42
|
+
|
|
43
|
+
- Type annotations, return type annotations, type parameters `<T>` and constraints `<T extends U>`, type parameter defaults
|
|
44
|
+
- Type references, qualified names `A.B`
|
|
45
|
+
- Unions `|`, intersections `&`, arrays `T[]`, tuples `[T, U]`, optional tuple members `T?`, rest tuple members `...T`
|
|
46
|
+
- Function types `(a: T) => U`, construct signatures `new () => T`
|
|
47
|
+
- Object type literals, property signatures, method signatures, index signatures `[k: string]: T`
|
|
48
|
+
- Conditional types `T extends U ? X : Y`, mapped types `{ [K in T]: U }`, `infer`
|
|
49
|
+
- Type operators `keyof`, `unique`, `readonly`
|
|
50
|
+
- `typeof` (type query), indexed access types `T[K]`
|
|
51
|
+
- Literal types, `this` types
|
|
52
|
+
- Type predicates `x is T` / `asserts x is T`
|
|
53
|
+
- Interfaces, type aliases, enums, namespace / module declarations
|
|
54
|
+
- The various forms of `import` / `export` (structural parsing)
|
|
55
|
+
|
|
56
|
+
## ASI
|
|
57
|
+
|
|
58
|
+
- Automatic Semicolon Insertion, based on `precededByLineBreak` / `}` / EOF.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Compilation pipeline
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/pipeline.md)
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
source.ts
|
|
7
|
+
│ lexer src/lexer/scanner.ts + token.ts
|
|
8
|
+
▼
|
|
9
|
+
tokens
|
|
10
|
+
│ parser src/parser/parser.ts → AST src/ast/
|
|
11
|
+
▼
|
|
12
|
+
AST
|
|
13
|
+
│ binder src/binder/binder.ts → scopes/symbols/closure capture
|
|
14
|
+
▼
|
|
15
|
+
bound AST
|
|
16
|
+
│ codegen src/codegen/llvm.ts + values.ts → LLVM IR text
|
|
17
|
+
▼
|
|
18
|
+
module.ll ── clang ──► module.o ──link──► executable
|
|
19
|
+
▲
|
|
20
|
+
runtime/*.c (C runtime, split by function)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- Front end, back end, runtime and extensions are fully decoupled.
|
|
24
|
+
- The flow is orchestrated by `src/driver/compiler.ts`: `read → parse → bind → IR → object file → link`. The front end lives in `src/driver/frontend.ts`, the cache key in `src/driver/build-key.ts`, runtime compilation in `src/driver/runtime-objects.ts`, and platform artifacts in `src/driver/app-artifacts.ts`.
|
|
25
|
+
- **Self-hosting**: `xbintsc` compiles its own front end. Building `src/cli/main.ts`
|
|
26
|
+
with the compiler yields a working `xbintsc` binary, and that binary rebuilds
|
|
27
|
+
itself with byte-identical LLVM IR (source ≡ generation 1 ≡ generation 2 ≡
|
|
28
|
+
generation 3). The runtime is still hand-written C.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# C runtime core
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/runtime-core.md)
|
|
4
|
+
|
|
5
|
+
Location: `runtime/xt_alloc.c`, `runtime/xt_values.c`, `runtime/xt_containers.c`,
|
|
6
|
+
`runtime/xt_builtins.c`, `runtime/xt_constructors.c`, `runtime/xt_io.c`, sharing the
|
|
7
|
+
private header `runtime/rt_internal.h`; the public ABI is in `runtime/rt.h`.
|
|
8
|
+
|
|
9
|
+
Strings, symbols, typed arrays, collections, promises/async, `fetch` and the
|
|
10
|
+
standard-library surface have their own pages:
|
|
11
|
+
|
|
12
|
+
- [Strings and text](./strings.md)
|
|
13
|
+
- [Standard library](./stdlib.md)
|
|
14
|
+
- [Collections](./collections.md)
|
|
15
|
+
- [Typed arrays and binary data](./typed-arrays.md)
|
|
16
|
+
- [Async, promises and generators](./async.md)
|
|
17
|
+
- [fetch](./fetch.md)
|
|
18
|
+
|
|
19
|
+
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan).
|
|
20
|
+
- Value construction: `xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`.
|
|
21
|
+
- Type conversion: `xt_truthy`, `xt_to_number`, `xt_to_string`, `xt_typeof`.
|
|
22
|
+
- Arithmetic: `add/sub/mul/div/mod/pow/neg/pos`.
|
|
23
|
+
- Bitwise: `and/or/xor/not/shl/shr/ushr` (including `ToInt32` semantics).
|
|
24
|
+
- Comparison: `lt/le/gt/ge`, loose / strict equality, `not`, `is_nullish`.
|
|
25
|
+
- Objects: linear property list, `object_new/get/set/has/keys/values/entries/assign/spread`.
|
|
26
|
+
- Arrays: `array_new/get/set/push/length/spread`; assigning `arr.length` truncates or extends (matching JS); `iter_length` / `iter_value` expose a uniform iteration view over arrays, strings (by code point), `Map` and `Set`.
|
|
27
|
+
- Generic member access: `xt_get` / `xt_set` (dispatch over arrays / objects / strings).
|
|
28
|
+
- Operator helpers: `xt_in` (`in`), `xt_delete` (`delete`), `xt_rest_args` (rest parameters / `arguments`).
|
|
29
|
+
- Box: `box_new/get/set` (for closure-captured variables).
|
|
30
|
+
- Functions and closures: `arg`, `closure_new/call/env/arity`.
|
|
31
|
+
- Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines.
|
|
32
|
+
- Objects / functions: `xt_object` with a prototype chain, `xt_function` with a property bag (static members and `prototype`); `xt_new` (instantiation), `xt_instance_of` (prototype chain), `xt_object_freeze/is_frozen/from_entries`; `xt_constructors.c` holds the first-class constructor cache, constructor prototypes and static-value dispatch.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Standard library
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/stdlib.md)
|
|
4
|
+
|
|
5
|
+
Location: `runtime/xt_stdlib.c`, `runtime/xt_stdlib2.c`, `runtime/xt_symbol.c`,
|
|
6
|
+
`runtime/xt_builtins.c`, `runtime/xt_constructors.c`, `runtime/xt_io.c`,
|
|
7
|
+
`runtime/xt_structured_clone.c`, `runtime/xt_url.c`.
|
|
8
|
+
|
|
9
|
+
The dispatch layer is `xt_call_method` (array / string methods and function
|
|
10
|
+
properties on objects), `xt_math_call` (`Math.*` and constants) and the
|
|
11
|
+
`xt_*` entry point of each constructor. Well-known symbols and the iterator
|
|
12
|
+
protocol are in [Symbol](#symbol) below; collections and typed arrays have their
|
|
13
|
+
own pages: [Collections](./collections.md), [Typed arrays and binary data](./typed-arrays.md).
|
|
14
|
+
|
|
15
|
+
## Objects
|
|
16
|
+
|
|
17
|
+
- `Object.keys` / `values` / `entries` / `assign` / `getOwnPropertyNames` / `groupBy`, object spread `{...obj}`.
|
|
18
|
+
- `Object.defineProperty` / `getOwnPropertyDescriptor(s)` — data and accessor descriptors; the attribute flags are reported but not enforced on later writes/enumeration.
|
|
19
|
+
- `Object.freeze` / `is_frozen` / `from_entries`, `Object.getPrototypeOf`.
|
|
20
|
+
- `Object.prototype`: `hasOwnProperty` / `toString` / `valueOf` / `isPrototypeOf` / `propertyIsEnumerable` / `__proto__`; `Object.getPrototypeOf({}) === Object.prototype`.
|
|
21
|
+
- First-class built-in constructors (`const A = Array`, `new A(...)`, `A.isArray`, `x instanceof A`) are covered in [Codegen](./codegen.md#llvm-ir-code-generation-codegen).
|
|
22
|
+
|
|
23
|
+
## Arrays
|
|
24
|
+
|
|
25
|
+
- `push` `pop` `shift` `unshift` `join` `slice` `splice` `indexOf` `lastIndexOf` `includes` `concat` `reverse` `forEach` `map` `filter` `reduce` `reduceRight` `find` `findIndex` `findLast` `findLastIndex` `some` `every` `sort` `flat` `flatMap` `fill` `copyWithin` `at` `keys` `values` `entries`
|
|
26
|
+
- Immutable helpers: `toReversed` / `toSorted` / `toSpliced` / `with`.
|
|
27
|
+
- Statics: `Array.isArray` / `of` / `from`.
|
|
28
|
+
- Default `sort` is stable and compares string forms, like Node; assigning `arr.length` truncates or extends the array.
|
|
29
|
+
|
|
30
|
+
## Numbers, BigInt and Math
|
|
31
|
+
|
|
32
|
+
- Number formatting and coercion match Node: `toFixed` / `toPrecision` / `toExponential`, hex / octal / binary parsing, and the full `+` / relational `ToPrimitive` rules. These are covered by the differential tests.
|
|
33
|
+
- `BigInt` literals and values: arbitrary precision arithmetic, bitwise and shift operators, comparisons, `toString(radix)`, `BigInt()`, `BigInt.asIntN` / `BigInt.asUintN`.
|
|
34
|
+
- `Math`: the full function set and constants.
|
|
35
|
+
- `Number` statics and `Number()` conversion; `parseInt` / `parseFloat` / `isNaN` / `isFinite`.
|
|
36
|
+
|
|
37
|
+
## JSON
|
|
38
|
+
|
|
39
|
+
- `JSON.parse` with a `reviver`.
|
|
40
|
+
- `JSON.stringify` with a function or array `replacer`, `toJSON`, and `space` (number or string, clamped to 10). `undefined` / function / symbol values follow the standard omission rules.
|
|
41
|
+
- Object keys are emitted in insertion order, with integer keys ordered numerically; circular references throw.
|
|
42
|
+
|
|
43
|
+
## Date
|
|
44
|
+
|
|
45
|
+
- `Date` backed by `gmtime_r`; ISO 8601 parsing through `Date.parse` / `new Date(string)`.
|
|
46
|
+
|
|
47
|
+
## RegExp
|
|
48
|
+
|
|
49
|
+
- `RegExp` uses POSIX ERE (`regcomp` / `regexec`) for `test` / `exec`, with capture groups exposed through `exec` / `match` / `replace` / `split` / `search`.
|
|
50
|
+
- Matching is byte-oriented and `/g` / `/y` `lastIndex` is not honoured — see [Runtime deviations](../unimplemented/deviations.md).
|
|
51
|
+
|
|
52
|
+
## Symbol
|
|
53
|
+
|
|
54
|
+
- `Symbol(description)` primitives (`XT_OBJECT_KIND_SYMBOL`), the 13 well-known symbols (`Symbol.iterator`, `Symbol.asyncIterator`, `Symbol.match`, ...), `Symbol.for` / `Symbol.keyFor` global registry, `symbol.description` / `toString()` / `valueOf()`.
|
|
55
|
+
- Symbols are valid property keys (`Object.getOwnPropertySymbols`, symbol keyed `get`/`set`/`in`/`delete`), are skipped by `Object.keys` / `values` / `entries` / `for...in` / `JSON.stringify`, and print as `Symbol(desc)`.
|
|
56
|
+
|
|
57
|
+
## URLSearchParams
|
|
58
|
+
|
|
59
|
+
- `URLSearchParams` is implemented in `runtime/xt_url.c`.
|
|
60
|
+
|
|
61
|
+
## Errors
|
|
62
|
+
|
|
63
|
+
- The `Error` family: `Error`, `TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`, `URIError`, `AggregateError` — `new`, `instanceof`, `extends`, `String(err)` / `err.toString()` and `.stack`.
|
|
64
|
+
- `Promise.any` rejects with an `AggregateError`.
|
|
65
|
+
- `.stack` contains function-level frames (`at name (file:line)`), captured from the runtime shadow call stack; the exact limitations are in [Runtime deviations](../unimplemented/deviations.md).
|
|
66
|
+
|
|
67
|
+
## console
|
|
68
|
+
|
|
69
|
+
- `xt_print` / `xt_println` / `xt_console_log` / `info` / `warn` / `error`; `info` / `log` go to stdout, `warn` / `error` to stderr.
|
|
70
|
+
- Node-style inspection: arrays `[ a, b ]`, objects `{ k: v }`, UTF-8-aware, with circular references marked.
|
|
71
|
+
- `dir` / `trace` / `assert` / `count` / `countReset` / `group` / `groupEnd` / `table` / `time` / `timeEnd` / `timeLog`.
|
|
72
|
+
|
|
73
|
+
## Global functions
|
|
74
|
+
|
|
75
|
+
- `parseInt` `parseFloat` `isNaN` `isFinite` `Number` `String` `Boolean` `encodeURI` `decodeURI` `encodeURIComponent` `decodeURIComponent`.
|
|
76
|
+
- `btoa` / `atob` base64 encoding and decoding (core globals; not Node-extension-only).
|
|
77
|
+
- `structuredClone`: arrays, objects, `Map`, `Set`, `Date`, `RegExp` and typed arrays, preserving cycles and shared references; functions, symbols, promises and generators are rejected.
|
|
78
|
+
- Timers, `queueMicrotask` and `performance.now` are described in [Async, promises and generators](./async.md); `fetch` in [fetch](./fetch.md).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Strings and text
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/strings.md)
|
|
4
|
+
|
|
5
|
+
Location: the string value lives in the core runtime (`runtime/xt_values.c`);
|
|
6
|
+
the method surface is dispatched from `runtime/xt_stdlib.c` / `xt_stdlib2.c`;
|
|
7
|
+
`TextEncoder` / `TextDecoder` live in `runtime/xt_text_codec.c`.
|
|
8
|
+
|
|
9
|
+
## Value model
|
|
10
|
+
|
|
11
|
+
- UTF-8 storage exposed through JavaScript's UTF-16 view: `length`, indexing, `slice`, `indexOf`, `split`, `padStart` and `codePointAt` count code units; `for...of` and `Array.from` count code points; lone surrogate halves are kept as WTF-8 and recombined on concatenation.
|
|
12
|
+
- Lazy cons-node concatenation: bytes are flattened on first observation, so append loops stay linear.
|
|
13
|
+
- Equality comparison, and formatted number-to-string.
|
|
14
|
+
- `xt_string_length` reports bytes for I/O; `xt_string_utf16_length` reports the JavaScript length.
|
|
15
|
+
|
|
16
|
+
## Methods
|
|
17
|
+
|
|
18
|
+
- `charAt` `charCodeAt` `codePointAt` `indexOf` `lastIndexOf` `includes` `startsWith` `endsWith` `slice` `substring` `substr` `split` `match` `replace` `replaceAll` `search` `toUpperCase` `toLowerCase` `trim` `trimStart` `trimEnd` `padStart` `padEnd` `repeat` `concat` `at` `localeCompare` `valueOf`
|
|
19
|
+
- `String.match` / `lastIndexOf` / `split` with a limit; RegExp capture groups flow through `match` / `replace` / `split` / `search` (see [Standard library](./stdlib.md)).
|
|
20
|
+
- `String` statics: `fromCharCode` / `fromCodePoint` / `raw`; tagged templates keep their raw strings.
|
|
21
|
+
|
|
22
|
+
## Text encoding
|
|
23
|
+
|
|
24
|
+
- `TextEncoder` / `TextDecoder` encode and decode through a `Uint8Array`; only the UTF-8 encoding is supported.
|
|
25
|
+
|
|
26
|
+
Known divergences (`String.prototype.normalize`, byte-oriented RegExp matching)
|
|
27
|
+
are listed in [Unimplemented: standard library](../unimplemented/stdlib.md).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Tests
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/tests.md)
|
|
4
|
+
|
|
5
|
+
Location: `tests/` (`lexer` / `parser` / `binder` / `codegen` / `driver` / `extensions` / `cli` / `e2e`)
|
|
6
|
+
|
|
7
|
+
- Per-module unit tests mirror the source tree.
|
|
8
|
+
- `tests/e2e/` compiles real programs and runs the resulting binaries. When `clang` is absent the suite skips itself automatically; it is not a silent pass.
|
|
9
|
+
- `tests/e2e/differential-*.test.ts` runs the same source through both `xbintsc` and Node and compares output byte-for-byte. When semantics change, add a differential case instead of a hand-written expected string.
|
|
10
|
+
- Feature pages in this directory record the supported behaviour; the tests are the executable form of that contract. See [Contributing](../ai/contributing.md) for the gate (`npm run typecheck && npm run lint && npm test`).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Typed arrays and binary data
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/typed-arrays.md)
|
|
4
|
+
|
|
5
|
+
Location: `runtime/xt_typed_array.c`, `runtime/xt_array_buffer.c`.
|
|
6
|
+
|
|
7
|
+
## Typed arrays
|
|
8
|
+
|
|
9
|
+
- `Uint8Array`, `Int8Array`, `Uint8ClampedArray`, `Uint16Array`, `Int16Array`, `Uint32Array`, `Int32Array`, `Float32Array`, `Float64Array`.
|
|
10
|
+
- Construction: `new X(n)` / `new X(iterable)` / `new X(buffer[, offset[, length]])` / `X.from` / `X.of`.
|
|
11
|
+
- Properties: `length` / `byteLength` / `byteOffset` / `.buffer` / `BYTES_PER_ELEMENT`.
|
|
12
|
+
- Element reads/writes apply the per-type coercion (`ToIntN` / `ToUintN`, `Uint8ClampedArray` rounding, `Float32` single-precision rounding).
|
|
13
|
+
- Prototype methods: `fill` / `set` / `slice` / `subarray` / `join` / `toString` / `indexOf` / `lastIndexOf` / `includes` / `forEach` / `map` / `filter` / `every` / `some` / `find` / `findIndex` / `reduce` / `reverse` / `sort` / `copyWithin` / `at` / `keys` / `values` / `entries`. Iterator methods still return arrays, not iterator objects.
|
|
14
|
+
- Typed arrays are views over an `ArrayBuffer`; `subarray` shares the buffer and `slice` copies.
|
|
15
|
+
|
|
16
|
+
## ArrayBuffer and DataView
|
|
17
|
+
|
|
18
|
+
- `ArrayBuffer`: `byteLength`, `slice`, `ArrayBuffer.isView`.
|
|
19
|
+
- `DataView`: big-endian by default, optional `littleEndian`, with `get` / `set` for Uint8 / Int8 / Uint16 / Int16 / Uint32 / Int32 / Float32 / Float64.
|
|
20
|
+
- Multiple views over one buffer share its bytes.
|
|
21
|
+
|
|
22
|
+
## Not implemented
|
|
23
|
+
|
|
24
|
+
- `BigInt64Array` / `BigUint64Array`.
|
|
25
|
+
- `Buffer`-backed typed-array views.
|
|
26
|
+
- `TextEncoder` / `TextDecoder` are implemented (UTF-8) and documented in [Strings and text](./strings.md); `structuredClone` copies typed arrays.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Value model and calling convention
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/value-model.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/codegen/values.ts`, `runtime/rt.h`
|
|
6
|
+
|
|
7
|
+
- All JS values are unified as a 64-bit `xt_value` (NaN-boxing).
|
|
8
|
+
- Doubles are not boxed; other types are tagged pointers with a 16-bit tag in the high bits and a 48-bit payload.
|
|
9
|
+
- Tags: `undefined` / `null` / `false` / `true` / `string` / `object` / `array` / `function`.
|
|
10
|
+
- Uniform function ABI:
|
|
11
|
+
|
|
12
|
+
```c
|
|
13
|
+
xt_value fn(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- `thisValue` is threaded as the first ABI parameter (exception-safe, supports nesting); arrow functions inherit `this` lexically from an extra environment slot.
|
|
17
|
+
- Closures thread captured variables through `env` (by reference, boxed); direct calls and closure calls share one code path.
|
|
18
|
+
- `xt_object` carries a prototype field, and property lookup walks the prototype chain; `xt_function` carries a `prototype` and a property bag (static members). `xt_array` also carries a `[[Prototype]]` (Array.prototype). `Object.prototype` is the root of ordinary objects and provides `hasOwnProperty` / `toString` / `valueOf` / `isPrototypeOf` / `propertyIsEnumerable` / `__proto__`; `Object.getPrototypeOf({}) === Object.prototype`.
|