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
package/doc/implemented.md
CHANGED
|
@@ -1,377 +1,76 @@
|
|
|
1
1
|
# xbintsc Implemented Syntax and Features
|
|
2
2
|
|
|
3
|
-
This
|
|
4
|
-
(`tests/`) file by file, and lists only the syntax and features that are
|
|
3
|
+
This documentation was compiled by checking the source (`src/`, `runtime/`) and
|
|
4
|
+
tests (`tests/`) file by file, and lists only the syntax and features that are
|
|
5
5
|
**actually usable today**. Implementation locations are noted for traceability.
|
|
6
6
|
|
|
7
|
+
The pages are split by compiler stage and feature area so a change lands in one
|
|
8
|
+
small file instead of a single monolithic document.
|
|
9
|
+
|
|
7
10
|
> Note: the compiler *parses* much more than it *generates code* for. Many
|
|
8
11
|
> TypeScript constructs can be parsed, and even bound, but the code generation
|
|
9
12
|
> stage reports `UnsupportedFeature`. Those are **not** listed here; see the
|
|
10
|
-
> [unimplemented
|
|
13
|
+
> [unimplemented documentation](./unimplemented.md).
|
|
11
14
|
|
|
12
15
|
> Language: **English** | [简体中文](./zh-CN/implemented.md)
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## 1. Compilation pipeline (fully implemented)
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
source.ts
|
|
20
|
-
│ lexer src/lexer/scanner.ts + token.ts
|
|
21
|
-
▼
|
|
22
|
-
tokens
|
|
23
|
-
│ parser src/parser/parser.ts → AST src/ast/
|
|
24
|
-
▼
|
|
25
|
-
AST
|
|
26
|
-
│ binder src/binder/binder.ts → scopes/symbols/closure capture
|
|
27
|
-
▼
|
|
28
|
-
bound AST
|
|
29
|
-
│ codegen src/codegen/llvm.ts + values.ts → LLVM IR text
|
|
30
|
-
▼
|
|
31
|
-
module.ll ── clang ──► module.o ──link──► executable
|
|
32
|
-
▲
|
|
33
|
-
runtime/*.c (C runtime, split by function)
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
- Front end, back end, runtime and extensions are fully decoupled.
|
|
37
|
-
- The flow is orchestrated by `src/driver/compiler.ts`: `read → parse → bind → IR → object file → link`.
|
|
38
|
-
- **Self-hosting**: `xbintsc` compiles its own front end. Building `src/cli/main.ts`
|
|
39
|
-
with the compiler yields a working `xbintsc` binary, and that binary rebuilds
|
|
40
|
-
itself with byte-identical LLVM IR (source ≡ generation 1 ≡ generation 2 ≡
|
|
41
|
-
generation 3). The runtime is still hand-written C.
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## 2. Lexer (implemented)
|
|
46
|
-
|
|
47
|
-
Location: `src/lexer/scanner.ts`, `src/lexer/token.ts`
|
|
48
|
-
|
|
49
|
-
- Full token classification: identifiers, keywords, private identifiers, numbers, strings, templates, regex (scanning), all punctuation and operators.
|
|
50
|
-
- Full keyword table: `abstract any as asserts async await bigint boolean break case catch class const constructor continue debugger declare default delete do else enum export extends false finally for from function get if implements import in infer instanceof interface is keyof let module namespace never new null number object package private protected public readonly return satisfies set static string super switch symbol this throw true try type typeof undefined unique unknown var void while with yield`
|
|
51
|
-
- Numeric literals:
|
|
52
|
-
- Decimal, `0x` hex, `0o` octal, `0b` binary
|
|
53
|
-
- Underscore separators `1_000_000`
|
|
54
|
-
- Fractions, exponents `1.5e3`
|
|
55
|
-
- BigInt literals (`10n`, `0xFFn`) evaluate to arbitrary-precision integers (arithmetic, bitwise, shifts, comparisons, `toString(radix)`, `BigInt()` / `BigInt.asIntN` / `BigInt.asUintN`)
|
|
56
|
-
- BigInt literal values are parsed exactly into `bigint` (never routed through `Number`), so the token / AST value of a literal beyond 2^53 keeps full precision
|
|
57
|
-
- String literals:
|
|
58
|
-
- Single / double quotes
|
|
59
|
-
- Escapes: `\n \t \r \b \f \0 \\ \' \"`, `\xHH`, `\uHHHH`, `\u{...}`
|
|
60
|
-
- Template literals (lexer level): no-substitution templates, `TemplateHead`, `TemplateMiddle`, `TemplateTail`, with `${}` and escapes.
|
|
61
|
-
- Regex literal scanning (`/pattern/flags`), distinguishing division `/`.
|
|
62
|
-
- Private identifiers `#name`.
|
|
63
|
-
- Comments: line `//` and block `/* */` (with unterminated diagnostics).
|
|
64
|
-
- Newline and whitespace tracking (for ASI), BOM / CRLF normalization (`SourceFile`).
|
|
65
|
-
- Lexical diagnostics: unterminated string / template / comment, illegal character, illegal number, illegal escape.
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## 3. Parser (implemented)
|
|
70
|
-
|
|
71
|
-
Location: `src/parser/parser.ts`, `src/ast/nodes.ts`
|
|
72
|
-
|
|
73
|
-
### 3.1 Statements
|
|
74
|
-
|
|
75
|
-
- Variable declarations: `var` / `let` / `const`, with multiple declarators `const a = 1, b = 2;`
|
|
76
|
-
- Function declarations, function expressions and methods, including the `async` modifier and generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`)
|
|
77
|
-
- `class` declarations / class expressions (constructor, fields, methods, `static`, `extends`)
|
|
78
|
-
- `if` / `else`
|
|
79
|
-
- `while`, `do...while`
|
|
80
|
-
- `for` (init, condition and increment may all be omitted)
|
|
81
|
-
- `for...of`, `for...in` (see the semantic limits in 3.5)
|
|
82
|
-
- `return`, `break`, `continue`, `throw` (including labeled `break label` / `continue label`)
|
|
83
|
-
- `switch` / `case` / `default` (including fall-through)
|
|
84
|
-
- `try` / `catch` / `finally` (catchable exceptions based on a runtime setjmp frame)
|
|
85
|
-
- `export var` / `export let` / `export const` (modifier parsed then erased)
|
|
86
|
-
- Block statement `{}`, empty statement `;`, `debugger;`
|
|
87
|
-
- Expression statements
|
|
88
|
-
|
|
89
|
-
### 3.2 Expressions
|
|
90
|
-
|
|
91
|
-
- All common operators with precedence / associativity (see section 5)
|
|
92
|
-
- Assignment expressions and all compound assignments (see section 5)
|
|
93
|
-
- Conditional (ternary) expressions `a ? b : c`
|
|
94
|
-
- Arrow functions `() => expr` / `() => { ... }` (including type parameters and return type annotations)
|
|
95
|
-
- Function expressions `function () {}` and named function expressions `function g() {}`
|
|
96
|
-
- Call expressions `f(...)`, member access `a.b`, element access `a[i]`
|
|
97
|
-
- Array literals `[1, 2]`, sparse array elision, spread `[...a]` (also over strings, `Map` and `Set`)
|
|
98
|
-
- 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 }`
|
|
99
|
-
- Template literal `${}` substitutions, tagged templates (with raw strings and `String.raw`)
|
|
100
|
-
- Parenthesized expressions, `as` / `satisfies` / non-null assertion `!` (type erasure)
|
|
101
|
-
- Unary: `+ - ! ~ typeof void`, prefix / postfix `++ --`
|
|
102
|
-
- Optional chaining `?.` / `?.[]` / `?.()` (with nullish short-circuit semantics)
|
|
103
|
-
- `delete` expressions (delete an object property)
|
|
104
|
-
|
|
105
|
-
### 3.3 TypeScript type syntax (parsed only, structure preserved then erased)
|
|
106
|
-
|
|
107
|
-
- Type annotations, return type annotations, type parameters `<T>` and constraints `<T extends U>`, type parameter defaults
|
|
108
|
-
- Type references, qualified names `A.B`
|
|
109
|
-
- Unions `|`, intersections `&`, arrays `T[]`, tuples `[T, U]`, optional tuple members `T?`, rest tuple members `...T`
|
|
110
|
-
- Function types `(a: T) => U`, construct signatures `new () => T`
|
|
111
|
-
- Object type literals, property signatures, method signatures, index signatures `[k: string]: T`
|
|
112
|
-
- Conditional types `T extends U ? X : Y`, mapped types `{ [K in T]: U }`, `infer`
|
|
113
|
-
- Type operators `keyof`, `unique`, `readonly`
|
|
114
|
-
- `typeof` (type query), indexed access types `T[K]`
|
|
115
|
-
- Literal types, `this` types
|
|
116
|
-
- Type predicates `x is T` / `asserts x is T`
|
|
117
|
-
- Interfaces, type aliases, enums, namespace / module declarations
|
|
118
|
-
- The various forms of `import` / `export` (structural parsing)
|
|
119
|
-
|
|
120
|
-
### 3.4 Module syntax (structural parsing + driver bundling)
|
|
121
|
-
|
|
122
|
-
- `import default, { named } from "..."`, `import * as ns from "..."` (namespace imports of relative modules are lowered to a synthetic object literal; extension modules such as `path` are also supported), `import type`
|
|
123
|
-
- `export default`, `export { a as b }`, `export *`, `export =`
|
|
124
|
-
- Import attributes (`with` / `assert`)
|
|
125
|
-
- The **runtime semantics** of `import` / `export` are handled at the driver layer by `src/driver/modules.ts`: it recursively resolves relative dependencies *and* bare `node_modules` packages (following `exports` / `module` / `main` and package subpaths), renames top-level symbols with a per-module prefix, rewrites references, merges into a single file and rebinds. Packages may be ESM or CommonJS: a CommonJS file under `node_modules` gets a synthetic `module`/`exports` pair, its `require` calls are lowered to the bundled dependency's exports, and its statically-detected exports are exposed to ESM importers. `require()` outside `node_modules` is still rejected with a hint to use `import`. Circular dependencies error out.
|
|
126
|
-
|
|
127
|
-
### 3.5 ASI
|
|
128
|
-
|
|
129
|
-
- Automatic Semicolon Insertion, based on `precededByLineBreak` / `}` / EOF.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## 4. Name binding and scopes (Binder, implemented)
|
|
134
|
-
|
|
135
|
-
Location: `src/binder/binder.ts`
|
|
136
|
-
|
|
137
|
-
- Scope kinds: module, function, block, `for`, `catch`
|
|
138
|
-
- Symbol kinds: `var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
|
|
139
|
-
- `var` and function declarations hoist to the function scope; `let` / `const` stay block-scoped
|
|
140
|
-
- Identifier → declaration resolution; unresolved identifier collection (`CannotFindName`)
|
|
141
|
-
- Closure capture analysis: outer variables referenced by an inner function are marked `captured` / `boxed`, and capture indices are threaded through intermediate closures
|
|
142
|
-
- Parameters are registered as local symbols; the self-name of a named function expression is registered as `const`
|
|
143
|
-
- Type-only declarations (interface / type alias) do not participate in value capture
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## 5. Operators and assignment (codegen implemented)
|
|
148
|
-
|
|
149
|
-
Location: `src/codegen/llvm.ts` (`BINARY_RUNTIME`, `emitPrefix`, `emitPostfix`, `emitAssignment`)
|
|
150
|
-
|
|
151
|
-
### 5.1 Arithmetic
|
|
152
|
-
|
|
153
|
-
`+ - * / % **` (`**` is right-associative)
|
|
154
|
-
|
|
155
|
-
### 5.2 Comparison and equality
|
|
156
|
-
|
|
157
|
-
`< <= > >=`, `== !=` (loose equality), `=== !==` (strict equality)
|
|
158
|
-
|
|
159
|
-
### 5.3 Logical and short-circuit
|
|
160
|
-
|
|
161
|
-
`&& || ??` (with short-circuit evaluation), `!`
|
|
162
|
-
|
|
163
|
-
### 5.4 Bitwise
|
|
164
|
-
|
|
165
|
-
`& | ^ ~ << >> >>>`
|
|
166
|
-
|
|
167
|
-
### 5.5 Unary
|
|
168
|
-
|
|
169
|
-
`+ - ! ~`, prefix / postfix `++ --`
|
|
170
|
-
|
|
171
|
-
### 5.6 Assignment
|
|
172
|
-
|
|
173
|
-
`= += -= *= /= %= **= <<= >>= >>>= &= |= ^= &&= ||= ??=`
|
|
174
|
-
|
|
175
|
-
### 5.7 Other expression operators
|
|
176
|
-
|
|
177
|
-
- Comma expression `,`
|
|
178
|
-
- `in` operator (`key in obj`, mapped to `xt_in`)
|
|
179
|
-
- `delete obj.key` / `delete obj[key]` (mapped to `xt_delete`)
|
|
180
|
-
- `instanceof` (mapped to `xt_instance_of`, walking the prototype chain)
|
|
181
|
-
|
|
182
|
-
> `typeof` / `void` are implemented as unary operators.
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## 6. Value model and calling convention (implemented)
|
|
187
|
-
|
|
188
|
-
Location: `src/codegen/values.ts`, `runtime/rt.h`
|
|
189
|
-
|
|
190
|
-
- All JS values are unified as a 64-bit `xt_value` (NaN-boxing).
|
|
191
|
-
- Doubles are not boxed; other types are tagged pointers with a 16-bit tag in the high bits and a 48-bit payload.
|
|
192
|
-
- Tags: `undefined` / `null` / `false` / `true` / `string` / `object` / `array` / `function`.
|
|
193
|
-
- Uniform function ABI:
|
|
194
|
-
|
|
195
|
-
```c
|
|
196
|
-
xt_value fn(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
- `thisValue` is threaded as the first ABI parameter (exception-safe, supports nesting); arrow functions inherit `this` lexically from an extra environment slot.
|
|
200
|
-
- Closures thread captured variables through `env` (by reference, boxed); direct calls and closure calls share one code path.
|
|
201
|
-
- `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`.
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## 7. LLVM IR code generation (Codegen, implemented)
|
|
206
|
-
|
|
207
|
-
Location: `src/codegen/llvm.ts`
|
|
208
|
-
|
|
209
|
-
- Emits LLVM IR text (`.ll`); no custom register allocation (relies on `alloca` + mem2reg).
|
|
210
|
-
- Statement / block boundary values live in `alloca`; conditionals and short-circuits materialize into temporary slots instead of `phi`.
|
|
211
|
-
- Control flow: `if` / `while` / `do` / `for` / `for...of` / `for...in`, `switch`, `try/catch/finally`, `break` / `continue` / `return`.
|
|
212
|
-
- `for...of` and spread iterate arrays, strings, typed arrays, `Map`, `Set`, generators and any object exposing `[Symbol.iterator]()` through `xt_iter_open` → `xt_iter_has` / `xt_iter_value` (`Map` yields `[key, value]` pairs); a non-iterable throws `TypeError`.
|
|
213
|
-
- `switch` tests each `case` with strict equality, executes on a hit, and falls through until `break`.
|
|
214
|
-
- `try/catch/finally` is implemented with a runtime `_setjmp` frame: `xt_try_enter` pushes, `_setjmp` catches, `xt_throw` long-jumps. The IR passes the caller's frame address (`@llvm.frameaddress(0)`) as the second `_setjmp` argument, matching clang's MSVC lowering: the Windows UCRT `_setjmp` stores that frame in `_JUMP_BUFFER.Frame` and `longjmp` feeds it to `RtlUnwind`, so omitting it made `longjmp` unwind to a bogus target (`STATUS_BAD_FUNCTION_TABLE`). `_setjmp` is used rather than the exported `setjmp` symbol, whose Windows ABI is an incompatible two-argument routine. Functions containing `try` force local variables to stay in memory (inline-asm escape points) so values survive a long jump.
|
|
215
|
-
- `for...in` reuses `xt_object_keys` to enumerate keys (arrays / strings yield string indices).
|
|
216
|
-
- Expressions:
|
|
217
|
-
- Identifiers, numbers, BigInt (arbitrary precision), strings, templates, booleans, `null`, `undefined`, `arguments`
|
|
218
|
-
- Arithmetic / comparison / logical / short-circuit / conditional / bitwise / unary (including `typeof` `void`) / prefix-postfix increment-decrement / compound assignment / logical assignment
|
|
219
|
-
- Array literals (including spread `[...]`), object literals (including shorthand / methods / object spread `{...obj}`)
|
|
220
|
-
- Typed arrays (`Uint8Array`, `Int8Array`, `Uint8ClampedArray`, `Uint16Array`, `Int16Array`, `Uint32Array`, `Int32Array`, `Float32Array`, `Float64Array`): construction (`new X(n)` / `new X(iterable)` / `X.from` / `X.of`), `length` / `byteLength` / `byteOffset` / `BYTES_PER_ELEMENT`, element reads/writes with per-type coercion (`ToIntN` / `ToUintN`, `Uint8ClampedArray` rounding, `Float32` single-precision rounding) and the 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`. See the unimplemented document for the deliberate divergences (`subarray` copies, iterator methods return arrays, no `ArrayBuffer`/`DataView`).
|
|
221
|
-
- Property access (with a `length` special case, `Math` constants), element access, calls
|
|
222
|
-
- First-class built-in constructors (`const A = Array`, `const M = Map`, `const E = TypeError`, typed arrays): a bare reference lowers to `xt_builtin_constructor`, giving a cached function with `name` / `length`, a `prototype`, and its statics (`A.isArray`, `A.from`, `M.prototype`, ...). Calling or `new`-ing an alias dispatches to the same runtime constructor, and `x instanceof A` walks the shared prototype chain.
|
|
223
|
-
- Optional chaining `?.` / `?.[]` / `?.()`: nullish check short-circuits to `undefined`
|
|
224
|
-
- `delete`, `in`, `instanceof`
|
|
225
|
-
- `this` (saved to the function's `%saved.this`; arrow functions read from an environment slot), `super` (`super.x` / `super(...)`), `new`, `await`
|
|
226
|
-
- Closures (arrow functions / function expressions) and capture environment construction
|
|
227
|
-
- Classes: constructor closure + prototype object, stored in an LLVM global (`@class.<id>`); instance fields are initialized before the constructor body; `static` members live in the constructor's property bag; `extends` sets up the prototype chain; `super(...)` is invoked through a hidden `__ctor` on the prototype.
|
|
228
|
-
- `async`: closures are marked with `xt_function_set_async`; calling one runs the body on a stackful coroutine (`xt_coroutine.c`, `xt_async.c`) and immediately returns a promise. The body runs synchronously until the first `await` of a pending promise, then suspends; settlement queues a microtask that resumes the coroutine. An exception that escapes the body rejects that promise instead of throwing synchronously. `await` on a non-promise or settled promise keeps the synchronous fast path and raises on rejection.
|
|
229
|
-
- Standard library calls: `console.*`, `Math.*`, `Object.*`, array / string methods all go through `xt_call_method` / `xt_math_call` / `xt_object_*`; `JSON`/`Date`/`Map`/`Set`/`RegExp`/`Promise` statics and constructors go through their `xt_*` functions; global functions (`parseInt`, `setTimeout`, etc.) go through `xt_parse_int`, `xt_set_timeout`, etc.
|
|
230
|
-
- Global string pool (`@.str.N` private constants, UTF-8 escaped).
|
|
231
|
-
- Builtin calls: `console.log` / `info` / `warn` / `error`, `Math.*`, `Object.*`, array / string methods, global functions, extension builtins (uniform `(argc, argv)` ABI).
|
|
232
|
-
- `main` entry point (returns 0, calls the module function, then drains microtasks and runs the event loop until no timers or descriptors remain).
|
|
233
|
-
- Unsupported nodes uniformly report `UnsupportedFeature`; they never crash.
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
## 8. C runtime (Runtime, implemented)
|
|
238
|
-
|
|
239
|
-
Location: `runtime/xt_alloc.c`, `runtime/xt_values.c`, `runtime/xt_containers.c`,
|
|
240
|
-
`runtime/xt_stdlib.c`, `runtime/xt_stdlib2.c`, `runtime/xt_promise.c`, `runtime/xt_async.c`,
|
|
241
|
-
`runtime/xt_coroutine.c`, `runtime/xt_builtins.c`,
|
|
242
|
-
`runtime/xt_io.c`, sharing the private header `runtime/rt_internal.h`; the public ABI is in `runtime/rt.h`.
|
|
243
|
-
|
|
244
|
-
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan).
|
|
245
|
-
- Value construction: `xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`.
|
|
246
|
-
- Strings: 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), lazy cons-node concatenation (bytes are flattened on first observation, so append loops stay linear), equality comparison, formatted number-to-string. `xt_string_length` reports bytes for I/O; `xt_string_utf16_length` reports the JavaScript length.
|
|
247
|
-
- Type conversion: `xt_truthy`, `xt_to_number`, `xt_to_string`, `xt_typeof`.
|
|
248
|
-
- Arithmetic: `add/sub/mul/div/mod/pow/neg/pos`.
|
|
249
|
-
- Bitwise: `and/or/xor/not/shl/shr/ushr` (including `ToInt32` semantics).
|
|
250
|
-
- Comparison: `lt/le/gt/ge`, loose / strict equality, `not`, `is_nullish`.
|
|
251
|
-
- Objects: linear property list, `object_new/get/set/has/keys/values/entries/assign/spread`.
|
|
252
|
-
- 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`.
|
|
253
|
-
- Typed arrays (`xt_typed_array.c`): typed arrays as property-bag objects with one prototype per element kind; element reads return the stored value and writes are coerced to the element type; `from` / `of` statics plus the full prototype method set; `subarray` copies.
|
|
254
|
-
- Symbols (`xt_symbol.c`): `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()`; 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)`.
|
|
255
|
-
- Generic member access: `xt_get` / `xt_set` (dispatch over arrays / objects / strings).
|
|
256
|
-
- Standard library: `xt_call_method` (uniform dispatch of array / string methods and function properties on objects), `xt_math_call` (`Math.*` and constants), global functions `xt_parse_int/parse_float/is_nan/is_finite/number_ctor/string_ctor/boolean_ctor/fetch`.
|
|
257
|
-
- Operator helpers: `xt_in` (`in`), `xt_delete` (`delete`), `xt_rest_args` (rest parameters / `arguments`).
|
|
258
|
-
- Box: `box_new/get/set` (for closure-captured variables).
|
|
259
|
-
- Functions and closures: `arg`, `closure_new/call/env/arity`.
|
|
260
|
-
- 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): `Error.stack` captures it, 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.
|
|
261
|
-
- Output: `xt_print/xt_println/xt_console_log/info/warn/error` (Node-style inspect: arrays `[ a, b ]`, objects `{ k: v }`; `info`/`log` to stdout, `warn`/`error` to stderr), plus `dir/trace/assert/count/countReset/group/groupEnd/table/time/timeEnd/timeLog`.
|
|
262
|
-
- 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.
|
|
263
|
-
- Standard library extensions (`xt_stdlib2.c`): extended array / string / number / object methods; `Object` / `Array` / `Number` / `String` statics; `JSON.parse` / `JSON.stringify`; `Map` / `Set`; `Date` (`gmtime_r`); `RegExp` (POSIX ERE `regcomp`/`regexec` `test`/`exec`).
|
|
264
|
-
- Promise (`xt_promise.c`): microtask queue (`xt_microtasks`); `xt_promise_ctor/resolve/reject/static`, instance `then/catch/finally`; `xt_drain_microtasks` empties the queue at program exit and the event loop drains it between callbacks. `xt_await` (in `xt_async.c`) returns a settled value synchronously, or suspends the running async coroutine and registers a waiter when the promise is pending.
|
|
265
|
-
- Async coroutines (`xt_async.c`) on the shared stackful-coroutine runtime (`xt_coroutine.c`, POSIX `ucontext` / Windows fibers): each `async` call owns a private stack, swaps its `try` frame stack and GC stack region, and survives `await` across `try`/`finally`, loops and closures. A promise settled from a timer, a socket callback or another coroutine resumes the suspended body on the microtask queue.
|
|
266
|
-
- Fetch (`xt_fetch.c`): global `fetch(input, init)` is a blocking HTTP/1.1 client whose promise is already settled (the exchange happens synchronously; it is not scheduled on the reactor). It accepts `http://` URLs only — `https://` rejects with a `TypeError` because no TLS backend is linked — and supports `method`, `headers` (plain object or `Headers`), `body` and `redirect` (`follow` / `manual` / `error`), following up to 20 redirects and switching POST to GET on 301/302/303. The resolved `Response`-shaped object exposes `ok` / `status` / `statusText` / `url` / `headers` plus `text()` / `json()` / `arrayBuffer()` / `bytes()` / `clone()`, and `Headers` is case-insensitive with `get` / `has` / `set` / `append` / `delete` / `keys` / `values` / `entries` / `forEach` / `getSetCookie`. Invalid URLs and network failures reject with a `TypeError`.
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## 9. Extension mechanism (Extensions, implemented)
|
|
271
|
-
|
|
272
|
-
Location: `src/extensions/registry.ts`, `src/extensions/node/`
|
|
273
|
-
|
|
274
|
-
- An extension is a plain object: `runtimeSources()` (extra C sources), `linkerFlags()` (extra link flags), `builtins()` (global identifier → runtime symbol, uniform `(argc, argv)` ABI) and `modules()` (import specifier → named exports / namespace).
|
|
275
|
-
- `ExtensionRegistry`: register / unregister / lookup / aggregate builtins, modules, runtime sources and link flags.
|
|
276
|
-
- The built-in core extension `core`: exposes `print` (mapped to `xt_println`), always registered.
|
|
277
|
-
- The Node extension `node`:
|
|
278
|
-
- Modular organisation: `src/extensions/node/fs/` + `runtime/ext_node/fs/read_file.c`
|
|
279
|
-
- Exposes importable modules (`fs`, `fs/promises`, `path`, `os`, `process`, …) under both bare and `node:`-prefixed specifiers; `import { readFileSync } from "fs"` resolves to `xt_node_read_text_file`, and `path`/`os`/`process` map exports onto the namespace dispatchers.
|
|
280
|
-
- Adding a new module only requires a new directory plus a C implementation; the core compiler never changes.
|
|
281
|
-
- Native C++/Rust extensions (`src/extensions/native.ts`, `--ext-native`):
|
|
282
|
-
- `nativeObjects()` links pre-built objects/static archives that expose `extern "C"` symbols with the `(argc, argv)` ABI; a JSON manifest maps them onto builtins/modules (`linkerFlags` / `linkerFlagsByPlatform` cover C++/Rust runtimes).
|
|
283
|
-
- Authoring helpers live in `runtime/xt_ext.h` (C/C++) and `runtime/xt_ext.rs` (Rust); runnable projects are under `examples/extensions/`.
|
|
284
|
-
- The driver links the artifacts verbatim and the incremental cache fingerprints their contents, so a rebuilt library invalidates the cached binary.
|
|
285
|
-
- CI builds both language examples on Linux, macOS and Windows; on Windows the system clang links with the MSVC ABI (C++ `-lmsvcprt`, Rust `*-pc-windows-msvc` plus the Windows system libraries).
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## 10. Driver, incremental compilation and toolchain (implemented)
|
|
290
|
-
|
|
291
|
-
Location: `src/driver/compiler.ts`, `src/driver/cache.ts`, `src/driver/toolchain.ts`, `src/driver/paths.ts`
|
|
292
|
-
|
|
293
|
-
- Compilation pipeline: read source → module bundling (`src/driver/modules.ts`, when the entry contains `import`/`export`) → parse → bind/check → IR → object file → link.
|
|
294
|
-
- Incremental cache: keyed on "compiler version + source hash + emit kind + optimization level + platform + extension fingerprint (names, linker flags, native object contents)"; if the artifacts exist and are fresh, the build is skipped.
|
|
295
|
-
- C runtime and extension sources are cached as object files by content hash and compiled only once.
|
|
296
|
-
- Toolchain wrapper: locates `clang` (overridable with `xbintsc_CLANG`), compiles IR, compiles C, links.
|
|
297
|
-
- Link flags: `-lm` is added automatically on non-Windows; extensions may append extra link flags.
|
|
298
|
-
- Project config (`src/driver/config.ts`, `xbintsc.config.json`): `entry`, `outDir`, `output`, `optimize`, `extensions`, `extNative`, `force` and `app` (`name`, `icon`, `bundle`, `bundleId`). Discovered by walking up from the entry/cwd, overridable with `--config`, disabled with `--no-config`; every path resolves against the config directory; CLI flags win over config values.
|
|
299
|
-
- Application icon (`src/driver/icon.ts`, `win-icon.ts`, `mac-bundle.ts`, `--icon`/`app.icon`): PNG/ICO/ICNS is embedded as `xt_app_icon_*` symbols, synthesized into a PE resource via `llvm-rc`/`windres` on Windows, and packaged into `Foo.app` (with `AppIcon.icns` via `sips`/`iconutil`) on macOS. The `gui` extension calls `SDL_SetWindowIcon` from the embedded bytes. `xbintsc_RC` overrides the resource compiler.
|
|
300
|
-
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
## 11. CLI and programmatic API (implemented)
|
|
304
|
-
|
|
305
|
-
Location: `src/cli/main.ts`, `src/index.ts`, `bin/xbintsc.js`
|
|
306
|
-
|
|
307
|
-
### 11.1 CLI commands
|
|
308
|
-
|
|
309
|
-
```
|
|
310
|
-
xbintsc build <file.ts> [options] compile to a native binary
|
|
311
|
-
xbintsc run <file.ts> [-- args] compile and run
|
|
312
|
-
xbintsc emit <file.ts> print LLVM IR
|
|
313
|
-
xbintsc version print the version
|
|
314
|
-
xbintsc help help
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### 11.2 CLI options
|
|
17
|
+
## Contents
|
|
318
18
|
|
|
319
|
-
|
|
320
|
-
-o, --output <path> Output path
|
|
321
|
-
--out <dir> Output directory (default: build/)
|
|
322
|
-
--emit <kind> exe | obj | ir (default: exe)
|
|
323
|
-
-O0..-O3 Optimization level (default: -O2)
|
|
324
|
-
--ext <names> Comma separated extensions (e.g. node)
|
|
325
|
-
--ext-native <m> Register a C++/Rust extension from a JSON manifest
|
|
326
|
-
--config <path> Use a project config (default: xbintsc.config.json)
|
|
327
|
-
--no-config Do not read any project config
|
|
328
|
-
--icon <path> Embed an application icon (PNG/ICO/ICNS)
|
|
329
|
-
--bundle macOS: also produce a .app bundle
|
|
330
|
-
--app-name <name> Bundle / display name
|
|
331
|
-
--app-id <id> macOS bundle identifier (e.g. com.example.demo)
|
|
332
|
-
--force Ignore the incremental cache
|
|
333
|
-
--verbose Print progress information
|
|
334
|
-
```
|
|
19
|
+
### Pipeline and front end
|
|
335
20
|
|
|
336
|
-
|
|
21
|
+
- [Compilation pipeline](./implemented/pipeline.md) — source → tokens → AST → IR → binary, self-hosting
|
|
22
|
+
- [Lexer](./implemented/lexer.md) — tokens, literals, keywords, lexical diagnostics
|
|
23
|
+
- [Parser](./implemented/parser.md) — statements, expressions, type syntax, ASI
|
|
24
|
+
- [Name binding and scopes](./implemented/binder.md) — scopes, symbols, closure capture
|
|
337
25
|
|
|
338
|
-
|
|
339
|
-
import { build, compileString } from "xbintsc";
|
|
26
|
+
### Semantics and code generation
|
|
340
27
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
28
|
+
- [Operators and assignment](./implemented/operators.md) — arithmetic, comparison, logical, bitwise, assignment
|
|
29
|
+
- [Value model and calling convention](./implemented/value-model.md) — NaN-boxing, function ABI, closures, prototypes
|
|
30
|
+
- [LLVM IR code generation](./implemented/codegen.md) — control flow, expressions, classes, inline caches, entry point
|
|
344
31
|
|
|
345
|
-
|
|
32
|
+
### Runtime and standard library
|
|
346
33
|
|
|
347
|
-
|
|
34
|
+
- [C runtime core](./implemented/runtime-core.md) — allocator/GC, values, conversions, objects, exceptions
|
|
35
|
+
- [Strings and text](./implemented/strings.md) — UTF-8/UTF-16 model, string methods, text codecs
|
|
36
|
+
- [Standard library](./implemented/stdlib.md) — Object, Array, Number/BigInt/Math, JSON, Date, RegExp, Symbol, errors, console
|
|
37
|
+
- [Collections](./implemented/collections.md) — Map, Set, WeakMap, WeakSet, WeakRef, iteration
|
|
38
|
+
- [Typed arrays and binary data](./implemented/typed-arrays.md) — typed arrays, ArrayBuffer, DataView
|
|
39
|
+
- [Async, promises and generators](./implemented/async.md) — async/await, async generators, promises, timers
|
|
40
|
+
- [fetch](./implemented/fetch.md) — reactor-driven HTTP/1.1 client and Headers
|
|
348
41
|
|
|
349
|
-
|
|
42
|
+
### Modules and tooling
|
|
350
43
|
|
|
351
|
-
-
|
|
352
|
-
-
|
|
44
|
+
- [Module system](./implemented/modules.md) — import/export, bundling, `node_modules`, `import.meta`
|
|
45
|
+
- [Extension mechanism](./implemented/extensions.md) — registry, the `node` extension, native C++/Rust extensions
|
|
46
|
+
- [Node extension](./implemented/node.md) — 21 Node built-in modules, one page per module
|
|
47
|
+
- [Driver, incremental compilation and toolchain](./implemented/driver.md) — cache, clang/LTO/PGO, config, icons
|
|
48
|
+
- [CLI and programmatic API](./implemented/cli.md) — commands, flags, embedder API
|
|
49
|
+
- [Tests](./implemented/tests.md) — unit, e2e and the differential harness
|
|
353
50
|
|
|
354
|
-
|
|
51
|
+
## Where does a change belong?
|
|
355
52
|
|
|
356
|
-
|
|
53
|
+
Pick the page that owns the feature; that keeps unrelated branches out of the
|
|
54
|
+
same file.
|
|
357
55
|
|
|
358
|
-
|
|
|
56
|
+
| You changed... | Edit |
|
|
359
57
|
| --- | --- |
|
|
360
|
-
|
|
|
361
|
-
|
|
|
362
|
-
|
|
|
363
|
-
|
|
|
364
|
-
|
|
|
365
|
-
|
|
|
366
|
-
|
|
|
367
|
-
|
|
|
368
|
-
|
|
|
369
|
-
|
|
|
370
|
-
|
|
|
371
|
-
|
|
|
372
|
-
|
|
|
373
|
-
|
|
|
374
|
-
|
|
|
375
|
-
|
|
|
376
|
-
|
|
|
377
|
-
|
|
|
58
|
+
| tokenizer, literals, keywords | [Lexer](./implemented/lexer.md) |
|
|
59
|
+
| statement/expression/type syntax | [Parser](./implemented/parser.md) |
|
|
60
|
+
| scopes, symbols, captures | [Name binding](./implemented/binder.md) |
|
|
61
|
+
| operators, assignment lowering | [Operators](./implemented/operators.md) |
|
|
62
|
+
| value representation, function ABI | [Value model](./implemented/value-model.md) |
|
|
63
|
+
| control flow, expression lowering, classes, `main` | [Codegen](./implemented/codegen.md) |
|
|
64
|
+
| allocator, GC, conversion, exceptions | [Runtime core](./implemented/runtime-core.md) |
|
|
65
|
+
| string model and methods | [Strings](./implemented/strings.md) |
|
|
66
|
+
| Object/Array/Number/Math/JSON/Date/RegExp/Symbol/errors/console | [Standard library](./implemented/stdlib.md) |
|
|
67
|
+
| Map/Set/WeakMap/WeakSet/WeakRef/iteration | [Collections](./implemented/collections.md) |
|
|
68
|
+
| typed arrays, ArrayBuffer, DataView | [Typed arrays](./implemented/typed-arrays.md) |
|
|
69
|
+
| async/await, promises, generators, timers | [Async](./implemented/async.md) |
|
|
70
|
+
| HTTP client | [fetch](./implemented/fetch.md) |
|
|
71
|
+
| import/export and bundling | [Modules](./implemented/modules.md) |
|
|
72
|
+
| extension registry or the `node` extension | [Extensions](./implemented/extensions.md) |
|
|
73
|
+
| a specific Node module (`fs`, `path`, `http`, ...) | [Node extension](./implemented/node.md) |
|
|
74
|
+
| build cache, clang, LTO/PGO, config, icons | [Driver](./implemented/driver.md) |
|
|
75
|
+
| CLI flags or the embedder API | [CLI](./implemented/cli.md) |
|
|
76
|
+
| tests and the differential harness | [Tests](./implemented/tests.md) |
|