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
|
@@ -6,8 +6,8 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
6
6
|
权威细节(始终最新、篇幅长得多):
|
|
7
7
|
|
|
8
8
|
- [../../zh-CN/implemented.md](../../zh-CN/implemented.md) —— 所有已实现能力,按编译器阶段组织
|
|
9
|
-
- [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) ——
|
|
10
|
-
- [../../zh-CN/node
|
|
9
|
+
- [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) —— 不支持的语法、行为偏差,按领域分页
|
|
10
|
+
- [../../zh-CN/implemented/node.md](../../zh-CN/implemented/node.md) / [../../zh-CN/unimplemented/node.md](../../zh-CN/unimplemented/node.md) —— Node 扩展
|
|
11
11
|
|
|
12
12
|
## 图例
|
|
13
13
|
|
|
@@ -60,7 +60,7 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
60
60
|
| `#private` 字段/方法/静态成员 | ⚠️ | 以字面量 `#x` 键存储;不做访问控制;父子类同名可能互相覆盖 |
|
|
61
61
|
| `enum`/`const enum` | ✅ | 正向 + 反向映射 |
|
|
62
62
|
| `private`/`protected`/`public`/`readonly`/`abstract`/`implements` | — | 被擦除,无访问控制 |
|
|
63
|
-
| 生成器 `function*`、`yield`、`yield*` | ✅ |
|
|
63
|
+
| 生成器 `function*`、`yield`、`yield*` | ✅ | 同步与 `async function*`;支持 `for await...of` 与 `Symbol.asyncIterator` |
|
|
64
64
|
| `arguments` 对象 | ✅ | 隐式提供;箭头函数看到的是自己的参数 |
|
|
65
65
|
| 参数个数校验 | 🚫 | 从不校验,虽然 `fn.length` 会报声明元数 |
|
|
66
66
|
|
|
@@ -68,11 +68,14 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
68
68
|
|
|
69
69
|
| 特性 | 状态 | 说明 |
|
|
70
70
|
| --- | --- | --- |
|
|
71
|
-
| `async`/`await`、`Promise`、`Promise.all` | ✅ | 真实挂起:async 函数体运行在栈式协程上,等待**未 settle** 的 Promise 时暂停,settle
|
|
71
|
+
| `async`/`await`、`Promise`、`Promise.all` | ✅ | 真实挂起:async 函数体运行在栈式协程上,等待**未 settle** 的 Promise 时暂停,settle 后恢复。每次 `await` 都会让出一次,已 settle 的值或非 Promise 也会像 Node 一样排入微任务 |
|
|
72
72
|
| `setTimeout` 与回调 | ✅ | 定时器运行在核心事件循环上;`await new Promise(r => setTimeout(r, ms))` 可用 |
|
|
73
|
+
| `queueMicrotask` / `setImmediate` / `performance.now` | ✅ | 微任务与 Promise 共用 FIFO 队列;`setImmediate` 是零延迟定时器,返回数字 id;`performance.now` 返回单调递增的毫秒小数 |
|
|
73
74
|
| 套接字/服务端(`http`、`net`、`dgram`) | ✅ | 回调在事件循环上执行,可以 settle 你正在 await 的 Promise(测试含 `net`/`http` 示例) |
|
|
74
|
-
| `fs/promises` |
|
|
75
|
-
| `
|
|
75
|
+
| `fs/promises` | ✅ | 文件、目录与 `FileHandle` 操作跑在异步 I/O 线程池上,并在 reactor 上 settle,等待期间定时器与套接字继续运行 |
|
|
76
|
+
| 全局 `fetch` | ✅ | HTTP/1.1 客户端,connect/send/receive 跑在同一线程池;`await fetch(...)` 会让出,重定向在 reactor 上处理。仅 `http://`(无 TLS),resolve 前缓冲整个响应体 |
|
|
77
|
+
| worker 线程 | 🚫 | worker 是子进程 |
|
|
78
|
+
| `async` 生成器 | ✅ | 可在 `await` 与 `yield` 处挂起;每次 `.next()` 返回 Promise;支持 `for await...of` |
|
|
76
79
|
|
|
77
80
|
## 类型:解析后擦除
|
|
78
81
|
|
|
@@ -91,7 +94,7 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
91
94
|
|
|
92
95
|
## 标准库
|
|
93
96
|
|
|
94
|
-
已实现:`Math`、`JSON`、`Date`、`RegExp`、`Map`、`Set`、`WeakMap`/`WeakSet`、
|
|
97
|
+
已实现:`Math`、`JSON`、`Date`、`RegExp`、`Map`、`Set`、`WeakMap`/`WeakSet`/`WeakRef`、
|
|
95
98
|
`Symbol`、`Error` 家族、`BigInt`、`Array`/`String`/`Number`/`Object` 方法、TypedArray、
|
|
96
99
|
带捕获组的 `String.prototype.match`/`split`/`replace`、不可变数组方法
|
|
97
100
|
(`toReversed`、`toSorted`、`toSpliced`、`with`)、全局 URI 函数、
|
|
@@ -100,12 +103,13 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
100
103
|
|
|
101
104
|
| 缺失或行为不同 | 状态 |
|
|
102
105
|
| --- | --- |
|
|
103
|
-
| `String.prototype.normalize
|
|
106
|
+
| `String.prototype.normalize` | 🚫 |
|
|
107
|
+
| `structuredClone` | ✅ 数组、对象、Map、Set、Date、RegExp 与类型化数组 |
|
|
104
108
|
| `Error.stack` 采集 | ⚠️ 函数级帧(名称/文件/行号),没有列号;生成器函数体不产生帧 |
|
|
105
109
|
| 全局 RegExp `lastIndex` | ⚠️ `/g`、`/y` 下 `test`/`exec` 忽略它 |
|
|
106
110
|
| 稀疏数组空洞、数组越界 | ⚠️ 不区分空洞;越界读得 `undefined` |
|
|
107
111
|
|
|
108
|
-
完整列表见
|
|
112
|
+
完整列表见[未实现:标准库](../../unimplemented/stdlib.md)。
|
|
109
113
|
|
|
110
114
|
## 模块
|
|
111
115
|
|
|
@@ -115,9 +119,9 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
115
119
|
| 相对路径多文件打包 | ✅ | `./helper.js` 会解析到 `helper.ts` |
|
|
116
120
|
| `import * as ns`、默认导入与具名导入 | ✅ | |
|
|
117
121
|
| Node 内置模块 | ✅ | 仅在 `--ext node` 下——见 [extensions.md](./extensions.md) |
|
|
118
|
-
| 裸第三方 npm 包 |
|
|
119
|
-
| `require()` / CommonJS |
|
|
120
|
-
| 循环依赖 | 🚫 | |
|
|
122
|
+
| 裸第三方 npm 包 | ⚠️ | 从 `node_modules` 解析并作为源码打包(ESM 和 CommonJS 均支持);运行时不做包查找,循环依赖会被拒绝 |
|
|
123
|
+
| `require()` / CommonJS | ⚠️ | 在自己的源码里会被拒绝并提示改用 `import`;`node_modules` 内的 CommonJS 包由打包器处理 |
|
|
124
|
+
| 循环依赖 | 🚫 | 仅限值导入;`import type` / `export type` 会被擦除,不构成依赖边 |
|
|
121
125
|
| 实时绑定 | ⚠️ | 导入与命名空间成员都是快照 |
|
|
122
126
|
| `__dirname`、`__filename` | 🚫 | 请使用 `import.meta.dirname` / `import.meta.filename` |
|
|
123
127
|
|
|
@@ -129,14 +133,14 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
129
133
|
| 正则 Unicode 匹配 | ⚠️ 引擎按字节工作:字面量 `中` 仍能匹配,但 `.` 与字符类每次只消费一个字节,`\d`/`\w` 仍是 ASCII。匹配偏移(`match.index`、`search`、替换回调)按 UTF-16 码元报告 |
|
|
130
134
|
| 数字格式化与强转 | ✅ 与 Node 一致(`toFixed`、`toPrecision`、十六/八/二进制解析) |
|
|
131
135
|
| `BigInt` | ✅ 已实现 |
|
|
132
|
-
| 垃圾回收 | ✅ 非移动标记清扫;显式根 + C 栈保守扫描;单线程、stop-the-world
|
|
136
|
+
| 垃圾回收 | ✅ 非移动标记清扫;显式根 + C 栈保守扫描;单线程、stop-the-world。`WeakMap`/`WeakSet` 键使用 ephemeron 不动点,`WeakRef` 目标不可达时清空;保守栈上的残留字可能延迟清空 |
|
|
133
137
|
| 线程 | 🚫 单线程;`worker_threads` 只存在于 Node 扩展中 |
|
|
134
138
|
|
|
135
139
|
## 平台
|
|
136
140
|
|
|
137
141
|
构建目标覆盖 macOS、Linux、Windows 的 x64 与 arm64。Windows 上是 **MSVC ABI**,
|
|
138
|
-
clang
|
|
139
|
-
|
|
142
|
+
编译器必须是面向 MSVC 的 clang(Visual Studio 自带的 LLVM 即可)——见
|
|
143
|
+
[../../zh-CN/requirements.md](../../zh-CN/requirements.md)。需要 clang **16 或更新**。
|
|
140
144
|
|
|
141
145
|
## 写大程序之前
|
|
142
146
|
|
|
@@ -47,10 +47,10 @@ export xbintsc_CLANG=/usr/lib/llvm-18/bin/clang
|
|
|
47
47
|
xbintsc run app.ts --ext node
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
### `module '<pkg>' is not supported:
|
|
50
|
+
### `module '<pkg>' is not supported: expected a Node built-in (with --ext node), a relative .ts/.js file, or a package in node_modules`
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
一个既没有被已启用扩展认领、也没能在 `node_modules` 里解析到的裸导入。检查包名和它的
|
|
53
|
+
`exports`/`main` 字段,或改用 `node` 扩展提供的 Node 内置模块;可打包的范围见
|
|
54
54
|
[extensions.md](./extensions.md)。
|
|
55
55
|
|
|
56
56
|
### ``CommonJS `require()` is not supported``
|
|
@@ -91,9 +91,10 @@ clang 自身失败。抛出的消息包含完整的 clang 命令与 stderr——
|
|
|
91
91
|
第一行。常见原因:
|
|
92
92
|
|
|
93
93
|
- 工具链太旧(见上文);
|
|
94
|
-
- Windows
|
|
95
|
-
|
|
96
|
-
Tools
|
|
94
|
+
- Windows 上解析到的 clang 找不到 MSVC/SDK 头文件或库。`xbintsc doctor` 会显示
|
|
95
|
+
编译器及其目标;优先使用 Visual Studio 自带的 LLVM,它会自行定位 SDK。如果你的
|
|
96
|
+
安装仍需要显式导入环境,请在 **x64 Native Tools Command Prompt for VS 2022**
|
|
97
|
+
(ARM64 机器上是 **ARM64 Native Tools**)里运行,或先导入环境:
|
|
97
98
|
```powershell
|
|
98
99
|
& "$env:ProgramFiles\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
|
|
99
100
|
```
|
|
@@ -110,8 +111,8 @@ clang 自身失败。抛出的消息包含完整的 clang 命令与 stderr——
|
|
|
110
111
|
### `Icon file not found` / 图标工具缺失
|
|
111
112
|
|
|
112
113
|
`--icon`/`app.icon` 的路径相对配置文件目录解析。Windows 上嵌入 PE 图标需要
|
|
113
|
-
`llvm-rc
|
|
114
|
-
|
|
114
|
+
`llvm-rc`(随 LLVM 一起安装);`doctor` 会报告解析到的工具,只有在确实请求了
|
|
115
|
+
图标时缺失才是致命错误。
|
|
115
116
|
|
|
116
117
|
## 怎么看堆栈
|
|
117
118
|
|
package/doc/gui/api.md
CHANGED
|
@@ -65,6 +65,7 @@ win.documentTree() // serialized DOM (debugging)
|
|
|
65
65
|
win.layoutTree() // serialized layout boxes (debugging)
|
|
66
66
|
win.paintCount() // number of shapes in the display list
|
|
67
67
|
win.paintList() // serialized display list (debugging)
|
|
68
|
+
win.inlineSvg(selector) // serialized inline <svg>: { markup, width, height, shapes }
|
|
68
69
|
win.measureText(text, fontSize?, family?) // shaped advance width in pixels
|
|
69
70
|
win.fontMetrics(fontSize?, family?) // { ascent, descent, lineHeight, ready }
|
|
70
71
|
win.hitTest(x, y) // deepest element descriptor, or ""
|
|
@@ -73,6 +74,13 @@ win.advance(ms) // step the CSS transition clock (testing
|
|
|
73
74
|
win.stats() // engine/runtime counters (memory debugging)
|
|
74
75
|
```
|
|
75
76
|
|
|
77
|
+
`win.inlineSvg(selector)` returns the standalone SVG document the engine builds
|
|
78
|
+
from the first `<svg>` element matching `selector` (`markup`), together with the
|
|
79
|
+
intrinsic size and shape count NanoSVG parses out of it; it is `undefined` when
|
|
80
|
+
nothing matches or the element is not an `<svg>`. It makes the serializer's
|
|
81
|
+
canonical casing (`viewBox`, `linearGradient`, `gradientUnits`, …) testable
|
|
82
|
+
without a GPU — the HTML parser delivers those names lowercased.
|
|
83
|
+
|
|
76
84
|
`win.stats()` returns `{ heapBytes, heapAllocations, treeNodes, detachedRoots,`
|
|
77
85
|
`detachedNodes, handles, handleSlots, listeners }`: the live runtime heap, the
|
|
78
86
|
size of the DOM tree, the detached-node pool, and the element-handle tables. In a
|
package/doc/gui/build.md
CHANGED
|
@@ -19,10 +19,19 @@
|
|
|
19
19
|
- `src/extensions/gui/index.ts` exposes the archive through `nativeObjects()`
|
|
20
20
|
(via `findRuntimeLibrary`, so `.a`/`.lib` both work) and the OS frameworks
|
|
21
21
|
through `linkerFlags()`.
|
|
22
|
+
- `scripts/build-gui.ts` compiles with the *same* clang the driver resolves
|
|
23
|
+
(`src/driver/toolchain-provider.ts`); on Windows that is the MSVC-targeting
|
|
24
|
+
LLVM bundled with Visual Studio, and its sibling `clang++`/`llvm-ar` are used
|
|
25
|
+
for CMake, the engine and the archive merge. There are no `gcc`/`g++`
|
|
26
|
+
fallbacks, and Windows always uses `llvm-ar`, so the archive cannot mix object
|
|
27
|
+
formats or C++ runtimes. The Visual Studio toolchain is found by absolute
|
|
28
|
+
path, so no developer prompt is required. On Windows SDL_GPU selects the
|
|
29
|
+
Vulkan backend; no DXIL/`dxc` toolchain is needed.
|
|
22
30
|
- CI builds `gui.a` before assembling the release archive so it ships inside
|
|
23
31
|
`runtime/lib/<slug>/` (the release tarball copies the whole `runtime/` tree).
|
|
24
32
|
The archive is built and the example is run on Linux (under Xvfb, with the
|
|
25
|
-
lavapipe software Vulkan driver) and macOS; Windows is provisional
|
|
33
|
+
lavapipe software Vulkan driver) and macOS; Windows is provisional because the
|
|
34
|
+
hosted runners have no GPU/Vulkan driver.
|
|
26
35
|
- The existing cache fingerprint already hashes `nativeObjects()` contents, so
|
|
27
36
|
rebuilding `gui.a` invalidates cached binaries automatically.
|
|
28
37
|
- CMake build trees live *next to* their sources (`vendor/sdl-build`,
|
|
@@ -60,9 +69,9 @@ working directory, so run it from the repository root:
|
|
|
60
69
|
Set `XT_GUI_AUTOCLOSE_MS=<n>` to close all windows after `n` milliseconds,
|
|
61
70
|
which the e2e test (`tests/e2e/gui-*.test.ts`) uses to run headlessly.
|
|
62
71
|
|
|
63
|
-
Those suites are skipped on Windows by default (the archive is built
|
|
64
|
-
|
|
65
|
-
`xbintsc_GUI_TESTS=1`:
|
|
72
|
+
Those suites are skipped on Windows by default (the archive is built and runs
|
|
73
|
+
locally through Vulkan, but CI runners have no GPU driver to run it). With a
|
|
74
|
+
`gui.lib` and a working GPU, opt in with `xbintsc_GUI_TESTS=1`:
|
|
66
75
|
|
|
67
76
|
```bat
|
|
68
77
|
set xbintsc_GUI_TESTS=1
|
package/doc/gui/known-issues.md
CHANGED
|
@@ -34,20 +34,21 @@
|
|
|
34
34
|
*class change* on a flex container has also been observed to crash the same
|
|
35
35
|
way; `examples/gui/pelican-bike` reveals its game-over overlay with `opacity`
|
|
36
36
|
instead.
|
|
37
|
+
- **SVG is NanoSVG's subset.** SVG *files* (`<img src="logo.svg">`) and inline
|
|
38
|
+
`<svg>` trees share the vendored NanoSVG parser/rasteriser
|
|
39
|
+
(`runtime/ext_gui/svg.cpp`, `inline_svg.cpp`), which renders
|
|
40
|
+
`path`/`rect`/`circle`/`ellipse`/`line`/`polyline`/`polygon`, groups, `defs`
|
|
41
|
+
gradients and class-based `<style>` rules. `<text>`, `<use>`, filters, masks
|
|
42
|
+
and clip paths are not rendered, and CSS applied by the document cascade does
|
|
43
|
+
not reach inside the artwork (fill/stroke are SVG presentation attributes,
|
|
44
|
+
not CSS properties here). Vector art that needs those has to be rasterised
|
|
45
|
+
beforehand, drawn from boxes, or restricted to the supported syntax. See
|
|
46
|
+
[Media](./media.md#images-m6a).
|
|
37
47
|
|
|
38
48
|
## Open questions
|
|
39
49
|
|
|
40
50
|
- Whether Linux ships X11, Wayland, or both in the first cut. (Decision:
|
|
41
51
|
X11 first, Wayland later.)
|
|
42
|
-
- **SVG:** SVG *files* are supported through the image loader
|
|
43
|
-
(`<img src="logo.svg">`): `runtime/ext_gui/svg.cpp` wraps the vendored
|
|
44
|
-
**NanoSVG** parser/rasteriser and `image.{h,cpp}` treats an SVG as a vector
|
|
45
|
-
image, rasterised at the drawn pixel size. Inline `<svg>` **trees** in a
|
|
46
|
-
document are still not supported: the HTML parser knows elements and
|
|
47
|
-
attributes, the layout engine knows boxes, and paint knows
|
|
48
|
-
rectangles/text/images, so `<svg>` subtrees would need a whole second
|
|
49
|
-
geometry+paint path. Vector art therefore has to arrive as an SVG/PNG file or
|
|
50
|
-
be drawn from boxes, as `examples/gui/pelican-bike` does.
|
|
51
52
|
- **Windows: the C++ runtime must not be named on the link line.** `gui.lib` is
|
|
52
53
|
built with the *static* CRT (`CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`) and
|
|
53
54
|
every engine object records `libcpmt` as a dependent library, which is also
|
|
@@ -57,14 +58,17 @@
|
|
|
57
58
|
collide: `LNK2038: mismatch detected for 'RuntimeLibrary'` plus a wall of
|
|
58
59
|
`LNK2005: already defined`, surfaced as `clang: linker command failed with exit
|
|
59
60
|
code 1169`. `src/extensions/gui/index.ts` now lists only the OS libraries
|
|
60
|
-
(`user32`, `gdi32`, `d3d12`, …).
|
|
61
|
-
MSVC
|
|
61
|
+
(`user32`, `gdi32`, `d3d12`, …). `scripts/build-gui.ts` resolves the same
|
|
62
|
+
MSVC-targeting clang as the driver (the LLVM bundled with Visual Studio when
|
|
63
|
+
no newer one is on `PATH`), so a developer prompt is not required.
|
|
62
64
|
- Windows: an MSVC-compatible `gui.lib` (COFF objects + `ar -M`/`llvm-ar`) is
|
|
63
65
|
produced by `scripts/build-gui.ts` but is not validated in CI, so the Windows
|
|
64
66
|
step is provisional (the job stays green) and `package` skips it. Building and
|
|
65
67
|
running `examples/gui/pelican-svg` and `examples/gui/pelican-bike` on a
|
|
66
|
-
developer machine works.
|
|
67
|
-
|
|
68
|
+
developer machine works. SDL_GPU selects the **Vulkan** backend there
|
|
69
|
+
(`win.driver()` reports `"vulkan"`), so the archive needs no DXIL/`dxc`
|
|
70
|
+
toolchain; the hosted Windows runners have no GPU/Vulkan driver, which is why
|
|
71
|
+
the CI run stays provisional.
|
|
68
72
|
- **Media on Windows:** the media decoders (FFmpeg) are only built and merged
|
|
69
73
|
into the POSIX `gui.a`; the Windows `gui.lib` is produced without them, so
|
|
70
74
|
`<video>`/`<audio>` are inert there (failures fire `error`). Enabling it needs
|
|
@@ -75,4 +79,5 @@
|
|
|
75
79
|
and embedded, so the non-Metal path no longer skips geometry. DXIL remains
|
|
76
80
|
unusable on **SDL 3.2.10**: its D3D12 backend rejects any graphics pipeline
|
|
77
81
|
whose shaders declare a uniform buffer, and the engine passes the viewport that
|
|
78
|
-
way.
|
|
82
|
+
way. This does not affect Windows in practice because SDL_GPU selects Vulkan
|
|
83
|
+
there; re-check after an SDL upgrade if the D3D12 path is ever forced.
|
package/doc/gui/media.md
CHANGED
|
@@ -12,7 +12,9 @@ size cache (`stbi_info`). Paths accept a `file://` prefix and percent-encoding.
|
|
|
12
12
|
library (parse + anti-aliased scanline rasteriser), detects an SVG by extension
|
|
13
13
|
or by its contents, and produces the same RGBA8 `Image` the pipeline already
|
|
14
14
|
consumes. `stb_image` cannot decode SVG, so this is what makes
|
|
15
|
-
`<img src="logo.svg">` work.
|
|
15
|
+
`<img src="logo.svg">` work. The same parser is used for an inline `<svg>`
|
|
16
|
+
subtree, whose DOM nodes are serialized into a document first
|
|
17
|
+
(`inline_svg.{h,cpp}`).
|
|
16
18
|
|
|
17
19
|
- `<img>` is a replaced element (`display: inline-block`): layout gives it the
|
|
18
20
|
CSS size when set, otherwise the intrinsic pixel size, and preserves the
|
|
@@ -27,12 +29,39 @@ consumes. `stb_image` cannot decode SVG, so this is what makes
|
|
|
27
29
|
pixels (logical size × the window's pixel density), preserving the viewBox
|
|
28
30
|
aspect ratio, and cached by that size, so scaling or a HiDPI display produces
|
|
29
31
|
a crisp render instead of a magnified bitmap.
|
|
32
|
+
- An **inline** `<svg>` element is a replaced element like `<img>`, but its
|
|
33
|
+
source is the DOM subtree itself. `runtime/ext_gui/inline_svg.{h,cpp}`
|
|
34
|
+
serializes that subtree back into a standalone SVG document, restoring the
|
|
35
|
+
case-sensitive spellings NanoSVG matches (`viewBox`, `preserveAspectRatio`,
|
|
36
|
+
`linearGradient`, `gradientUnits`, …) that the HTML parser lowercased. Layout
|
|
37
|
+
sizes the box from the `width`/`height` attributes, else the `viewBox`, else
|
|
38
|
+
300x150; paint carries the markup on its image op and the renderer parses and
|
|
39
|
+
rasterises it at the drawn device pixel size through the same NanoSVG cache as
|
|
40
|
+
an SVG file. A DOM mutation re-serializes the subtree on the next layout (so
|
|
41
|
+
`setAttribute` and `innerHTML` both repaint the artwork), and the markup cache
|
|
42
|
+
is bounded (least-recently-used) so an animated document cannot grow it
|
|
43
|
+
without limit.
|
|
30
44
|
- The parse is cached per path; the parse and rasteriser state are released in
|
|
31
45
|
`xt_svg_shutdown` (`xt_image_shutdown`).
|
|
32
46
|
|
|
47
|
+
Document CSS styles the `<svg>` **box** — size, margins, background, borders,
|
|
48
|
+
`transform`, opacity, `display` — exactly as it styles any other element. The
|
|
49
|
+
artwork inside it keeps SVG semantics: presentation attributes and the
|
|
50
|
+
`class`-based rules of an SVG `<style>` block are read by NanoSVG, not by the
|
|
51
|
+
HTML cascade, so `fill`/`stroke` are not CSS properties here. For layout, paint,
|
|
52
|
+
hit testing and events the whole `<svg>` is one replaced box: its children get no
|
|
53
|
+
DOM boxes, so a click's `e.target` is the `<svg>` element, not a `<rect>`. The
|
|
54
|
+
renderer caches one texture per markup-and-size pair, so a program that rewrites
|
|
55
|
+
its artwork every frame keeps a texture per variant; prefer animating the box
|
|
56
|
+
(`transform`, `opacity`) or swapping between a small set of documents.
|
|
57
|
+
|
|
33
58
|
Still to do for images: CSS `background-image: url(...)`, `data:` URIs,
|
|
34
|
-
`object-fit
|
|
35
|
-
|
|
59
|
+
`object-fit` and 9-slice borders.
|
|
60
|
+
|
|
61
|
+
Both kinds of SVG share NanoSVG's subset: `path`, `rect`, `circle`, `ellipse`,
|
|
62
|
+
`line`, `polyline`, `polygon`, groups (`g`), `defs` with linear/radial gradients
|
|
63
|
+
and class-based `<style>` rules rasterise; `<text>`, `<use>`, filters, masks and
|
|
64
|
+
clip paths are not rendered (see [Known issues](./known-issues.md)).
|
|
36
65
|
|
|
37
66
|
## Video & audio (M13)
|
|
38
67
|
|
package/doc/gui/rendering.md
CHANGED
|
@@ -43,7 +43,9 @@ its own GPU scissor rectangle (scaled to device pixels), so painter order and
|
|
|
43
43
|
Note that SDL 3.2.10's Direct3D 12 backend cannot create a graphics pipeline
|
|
44
44
|
whose shaders declare a uniform buffer (it fails with `E_INVALIDARG`); the
|
|
45
45
|
engine passes the viewport that way, so the DXIL path is built but not usable
|
|
46
|
-
until that is resolved upstream.
|
|
46
|
+
until that is resolved upstream. Windows does not hit this: SDL_GPU selects the
|
|
47
|
+
Vulkan backend there (confirmed by `win.driver()`), which consumes the SPIR-V
|
|
48
|
+
blobs.
|
|
47
49
|
- A **rounded-rectangle distance field** in the shape fragment shader gives
|
|
48
50
|
antialiased fills; the vertex carries `position`, `local`, `half extents`,
|
|
49
51
|
`radius` and colour, and a viewport-size push constant does the projection.
|
package/doc/gui.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# xbintsc GUI extension (self-hosted HTML/CSS renderer)
|
|
2
2
|
|
|
3
|
-
Status: **
|
|
3
|
+
Status: **M16** — features (M1–M15) are complete: HTML parsing, CSS selector
|
|
4
4
|
matching, the cascade, computed styles and layout (block, inline, Flexbox and
|
|
5
5
|
CSS positioning) are
|
|
6
6
|
in place, and the engine *paints*: it builds a display list of rectangles, images
|
|
@@ -9,7 +9,9 @@ tested and delivered to native TS handlers, `:hover`/`:focus` are matched
|
|
|
9
9
|
dynamically, `<img>` is sized from its intrinsic dimensions and drawn from a
|
|
10
10
|
texture — PNG/JPEG/… bitmaps and SVG files alike, the latter rasterised at the
|
|
11
11
|
drawn size so vector art stays crisp — and CSS transitions animate paint
|
|
12
|
-
properties. **
|
|
12
|
+
properties. **M16** gives inline `<svg>` trees the same treatment: the subtree is
|
|
13
|
+
serialized back into an SVG document and rasterised at the drawn device size, so
|
|
14
|
+
an icon needs no separate file. **M8** adds an interactive
|
|
13
15
|
DOM: element handles with stable identity, mutation (`appendChild`, `textContent`,
|
|
14
16
|
`classList`, `style`, …) and element-level events with capture/bubbling.
|
|
15
17
|
**M9** compiles `<script>` bodies ahead of time (inline and `<script src>`) — see
|
|
@@ -179,9 +181,10 @@ engine were Rust.
|
|
|
179
181
|
`runtime/`).
|
|
180
182
|
- `vendor/` (SDL3/FreeType/HarfBuzz, the slow part) is cached per OS/arch,
|
|
181
183
|
keyed by `scripts/build-gui.ts`.
|
|
182
|
-
- Windows (build + run) stays provisional
|
|
183
|
-
`gui.lib` and
|
|
184
|
-
|
|
184
|
+
- Windows (build + run) stays provisional in CI: the MSVC-compatible
|
|
185
|
+
`gui.lib` builds and runs locally through SDL_GPU's Vulkan backend, but the
|
|
186
|
+
hosted runners have no GPU/Vulkan driver. A failure is logged without
|
|
187
|
+
annotating the run (see [Open questions](./gui/known-issues.md#open-questions)).
|
|
185
188
|
8. **M8 — interactive DOM** ✅
|
|
186
189
|
- Element/document handles with stable identity, read/write properties via
|
|
187
190
|
runtime accessors, traversal/attributes/queries, mutation with lazy
|
|
@@ -256,6 +259,18 @@ engine were Rust.
|
|
|
256
259
|
[Layout](./gui/layout.md#transforms-m15) and
|
|
257
260
|
[Animation](./gui/animation.md#css-transforms-m15); e2e in
|
|
258
261
|
`tests/e2e/gui-transform.test.ts` and `tests/e2e/gui-example-svg.test.ts`.
|
|
262
|
+
16. **M16 — inline `<svg>`** ✅
|
|
263
|
+
- `<svg>` is a replaced element (`layout.*`): its intrinsic size comes from
|
|
264
|
+
the `width`/`height` attributes, else the `viewBox`, else 300x150, and the
|
|
265
|
+
normal box walk does not descend into its children.
|
|
266
|
+
- `inline_svg.{h,cpp}` serializes the subtree into a standalone SVG document,
|
|
267
|
+
restoring the case-sensitive names the HTML parser lowercased (`viewBox`,
|
|
268
|
+
`preserveAspectRatio`, `linearGradient`, `gradientUnits`, …).
|
|
269
|
+
- Paint carries the markup on its image op (`PaintImage::svg`) and the
|
|
270
|
+
renderer parses/rasterises it at the drawn device size through the same
|
|
271
|
+
NanoSVG cache as an SVG file (`svg.{h,cpp}`); the markup cache is bounded
|
|
272
|
+
and a DOM mutation re-serializes on the next layout. e2e in
|
|
273
|
+
`tests/e2e/gui-inline-svg.test.ts`.
|
|
259
274
|
|
|
260
275
|
## Progress log
|
|
261
276
|
|
|
@@ -354,4 +369,12 @@ engine were Rust.
|
|
|
354
369
|
through the inverse, and `getBoundingClientRect` returns the transformed AABB.
|
|
355
370
|
`examples/gui/pelican-svg` animates its artwork with it; e2e in
|
|
356
371
|
`tests/e2e/gui-transform.test.ts` and `tests/e2e/gui-example-svg.test.ts`.
|
|
372
|
+
- **M16** ✅ inline `<svg>`. `buildBoxTree` treats an `<svg>` element as a
|
|
373
|
+
replaced box (intrinsic size from `width`/`height`, then `viewBox`, then
|
|
374
|
+
300x150) and stops descending, `inline_svg.{h,cpp}` serializes the subtree with
|
|
375
|
+
canonical SVG casing, paint carries the markup on `PaintImage::svg`, and
|
|
376
|
+
`renderer_image.cpp` rasterises it at the drawn device pixel size through the
|
|
377
|
+
NanoSVG cache (`svg.{h,cpp}`, bounded LRU for markup). The `win.inlineSvg`
|
|
378
|
+
diagnostic exposes the serialized document, and `tests/e2e/gui-inline-svg.test.ts`
|
|
379
|
+
pins sizing, hit testing, gradients, CSS box styling and mutation.
|
|
357
380
|
|
package/doc/icon.md
CHANGED
|
@@ -160,7 +160,8 @@ does).
|
|
|
160
160
|
|
|
161
161
|
- `src/cli/main.ts`: `--icon`, `--bundle`, `--app-name`, `--app-id`, `--config`,
|
|
162
162
|
`--no-config`; merged with the config (`mergeAppConfig`).
|
|
163
|
-
- `src/driver/
|
|
163
|
+
- `src/driver/options.ts`: `BuildOptions.icon` and `BuildOptions.app` (assembled
|
|
164
|
+
into the cache key by `src/driver/build-key.ts`).
|
|
164
165
|
- The icon **content hash** and the packaging options are part of the
|
|
165
166
|
executable `cacheKey`, so changing the icon rebuilds.
|
|
166
167
|
- The icon object and (on win32) the resource object are appended to the link
|
|
@@ -175,8 +176,8 @@ does).
|
|
|
175
176
|
1. A PNG input is wrapped in a minimal ICO container (`ICONDIR` +
|
|
176
177
|
`ICONDIRENTRY` pointing at the PNG payload); Vista+ accepts PNG-in-ICO.
|
|
177
178
|
2. A `.rc` (`1 ICON "icon-<hash>.ico"`) is written next to it in the cache.
|
|
178
|
-
3. `llvm-rc /fo app.res app.rc` (
|
|
179
|
-
`
|
|
179
|
+
3. `llvm-rc /fo app.res app.rc` (next to the resolved clang, or on `PATH`).
|
|
180
|
+
`llvm-rc` is probed with `/?` — it has no `--version`. Override it with
|
|
180
181
|
`xbintsc_RC`.
|
|
181
182
|
4. If no resource compiler exists, the build continues with the runtime icon only
|
|
182
183
|
(a cosmetic feature never hard-fails a build).
|
|
@@ -234,7 +235,7 @@ ELF has no icon convention. The only in-binary use is the runtime window icon
|
|
|
234
235
|
|
|
235
236
|
- `tests/driver/config.test.ts` — parse/validate, discovery, path resolution.
|
|
236
237
|
- `tests/driver/icon.test.ts` — format sniffing, generated C, ICO conversion,
|
|
237
|
-
icon object caching, `llvm-rc
|
|
238
|
+
icon object caching, `llvm-rc` command lines, mac bundle layout and
|
|
238
239
|
fallbacks, and `build()` integration (icon objects linked, missing icon ⇒
|
|
239
240
|
`DiagnosticCode.IOError`).
|
|
240
241
|
- `tests/e2e/icon.test.ts` — compiles a real GUI program with `app.icon`,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Async, promises and generators
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/async.md)
|
|
4
|
+
|
|
5
|
+
Location: `runtime/xt_async.c`, `runtime/xt_coroutine.c`, `runtime/xt_promise.c`,
|
|
6
|
+
`runtime/xt_generator.c`, `runtime/xt_loop.c`, `runtime/xt_async_io.c`,
|
|
7
|
+
`runtime/xt_performance.c`.
|
|
8
|
+
|
|
9
|
+
## async / await
|
|
10
|
+
|
|
11
|
+
- `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.
|
|
12
|
+
- The body runs synchronously until the first `await` of a pending promise, then suspends; settlement queues a microtask that resumes the coroutine.
|
|
13
|
+
- An exception that escapes the body rejects that promise instead of throwing synchronously.
|
|
14
|
+
- `await` on a non-promise or settled promise keeps the synchronous fast path and raises on rejection.
|
|
15
|
+
- Each `async` call owns a private stack and swaps its `try` frame stack and GC stack region, so `await` survives `try`/`finally`, loops and closures. A promise settled from a timer, a socket callback, an offloaded file operation or another coroutine resumes the suspended body on the microtask queue.
|
|
16
|
+
|
|
17
|
+
## async generators
|
|
18
|
+
|
|
19
|
+
- `async function*` closures are marked with `xt_function_set_async_generator`; each `.next()` / `.throw()` / `.return()` enqueues a request and returns a promise.
|
|
20
|
+
- The body runs on the generator coroutine and may suspend at either `yield` or `await`; `xt_generator_await` parks it on the awaited promise and leaves the current request pending until the next yield or completion.
|
|
21
|
+
- `for await...of` lowers to `xt_async_iter_open` / `xt_async_iter_next` + `xt_await`, so it consumes both async iterables and the synchronous iteration protocol. `Symbol.asyncIterator` is supported.
|
|
22
|
+
|
|
23
|
+
## Generators
|
|
24
|
+
|
|
25
|
+
- `function*` / `yield` / `yield*`, with `.next()` / `.throw()` / `.return()`, is implemented on the same stackful-coroutine runtime.
|
|
26
|
+
- `for...of`, spread and delegation are supported.
|
|
27
|
+
|
|
28
|
+
## Promise
|
|
29
|
+
|
|
30
|
+
- Microtask queue (`xt_microtasks`); `xt_promise_ctor/resolve/reject/static` (including `withResolvers`), instance `then` / `catch` / `finally`.
|
|
31
|
+
- `xt_drain_microtasks` empties the queue at program exit, and the event loop drains it between callbacks.
|
|
32
|
+
- `xt_await` queues a microtask for a non-promise or settled value, and suspends the running async coroutine on a pending promise until it settles.
|
|
33
|
+
|
|
34
|
+
## Timers and the event loop
|
|
35
|
+
|
|
36
|
+
- `setTimeout` / `clearTimeout` / `setInterval` / `clearInterval` / `setImmediate` / `clearImmediate` / `queueMicrotask` and `performance.now` (monotonic fractional milliseconds).
|
|
37
|
+
- Timers use numeric ids; `Timeout` / `Immediate` objects are not implemented.
|
|
38
|
+
- A promise settled from a timer can be awaited: the async body suspends on the pending promise and resumes when the timer fires. Sockets and servers (`net`, `http`, `dgram`) deliver their callbacks on the same loop.
|
|
39
|
+
- `fetch` and `fs/promises` are reactor-driven rather than blocking — see the next section.
|
|
40
|
+
|
|
41
|
+
## Asynchronous I/O offload
|
|
42
|
+
|
|
43
|
+
- `runtime/xt_async_io.c` owns a small pool of worker threads (four by default, created lazily). Jobs are split in two halves: a `run` function on a worker that may only touch plain C memory, and a `complete` function on the main thread that builds values and settles the promise. The split is what keeps the collector and the value model single-threaded.
|
|
44
|
+
- A completed job wakes `select(2)` through a self-pipe (POSIX) or a loopback UDP socket (Windows); the reactor also polls the pool, so a failed wakeup degrades to a short wait instead of a hang.
|
|
45
|
+
- While a job is queued or running, up to four values per job (its promise, and for `fetch` the headers object) are kept in the job's root slots and scanned by the collector.
|
|
46
|
+
- `fetch` runs each request/redirect hop as a job; `fs/promises` runs every file and descriptor operation as a job. Neither blocks timers, sockets or other `await`s.
|
|
47
|
+
- The event loop stays alive while jobs are outstanding (`xt_loop_has_work`), and exits once the pool is idle again.
|
|
48
|
+
|
|
49
|
+
Known limits of the asynchronous surface (no TLS/streaming `fetch`, inert
|
|
50
|
+
`fs.watch`, four-worker pool) are listed in
|
|
51
|
+
[Runtime deviations](../unimplemented/deviations.md) and the Node pages.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Name binding and scopes (Binder)
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/binder.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/binder/binder.ts`
|
|
6
|
+
|
|
7
|
+
- Scope kinds: module, function, block, `for`, `catch`
|
|
8
|
+
- Symbol kinds: `var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
|
|
9
|
+
- `var` and function declarations hoist to the function scope; `let` / `const` stay block-scoped
|
|
10
|
+
- Identifier → declaration resolution; unresolved identifier collection (`CannotFindName`)
|
|
11
|
+
- Closure capture analysis: outer variables referenced by an inner function are marked `captured` / `boxed`, and capture indices are threaded through intermediate closures
|
|
12
|
+
- Parameters are registered as local symbols; the self-name of a named function expression is registered as `const`
|
|
13
|
+
- Type-only declarations (interface / type alias) do not participate in value capture
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# CLI and programmatic API
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/cli.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/cli/main.ts`, `src/index.ts`, `bin/xbintsc.js`
|
|
6
|
+
|
|
7
|
+
## CLI commands
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
xbintsc build <file.ts> [options] compile to a native binary
|
|
11
|
+
xbintsc run <file.ts> [-- args] compile and run
|
|
12
|
+
xbintsc emit <file.ts> print LLVM IR
|
|
13
|
+
xbintsc version print the version
|
|
14
|
+
xbintsc help help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## CLI options
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
-o, --output <path> Output path
|
|
21
|
+
--out <dir> Output directory (default: build/)
|
|
22
|
+
--emit <kind> exe | obj | ir (default: exe)
|
|
23
|
+
-O0..-O3 Optimization level (default: -O2)
|
|
24
|
+
--ext <names> Comma separated extensions (e.g. node)
|
|
25
|
+
--ext-native <m> Register a C++/Rust extension from a JSON manifest
|
|
26
|
+
--config <path> Use a project config (default: xbintsc.config.json)
|
|
27
|
+
--no-config Do not read any project config
|
|
28
|
+
--icon <path> Embed an application icon (PNG/ICO/ICNS)
|
|
29
|
+
--bundle macOS: also produce a .app bundle
|
|
30
|
+
--app-name <name> Bundle / display name
|
|
31
|
+
--app-id <id> macOS bundle identifier (e.g. com.example.demo)
|
|
32
|
+
--force Ignore the incremental cache
|
|
33
|
+
--verbose Print progress information
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Programmatic API
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { build, compileString } from "xbintsc";
|
|
40
|
+
|
|
41
|
+
const { ir } = compileString("console.log(1 + 1);");
|
|
42
|
+
const result = build("program.ts", { emit: "exe", outDir: "build" });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The option and result types (`BuildOptions`, `BuildResult`, `EmitKind`,
|
|
46
|
+
`PhaseTiming`) live in `src/driver/options.ts` and are re-exported from
|
|
47
|
+
`src/driver/compiler.ts` / `xbintsc`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# LLVM IR code generation (Codegen)
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/codegen.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/codegen/llvm.ts`
|
|
6
|
+
|
|
7
|
+
- Emits LLVM IR text (`.ll`); no custom register allocation (relies on `alloca` + mem2reg).
|
|
8
|
+
- Statement / block boundary values live in `alloca`; conditionals and short-circuits materialize into temporary slots instead of `phi`.
|
|
9
|
+
- Property reads are inline-cached per source site: each access owns a zeroed `[2 x i64]` global (`@ic.N`) passed to `xt_get_ic`. Ordinary objects carry an interned hidden-class shape (`xt_shape`, a `(parent, key)` transition tree) and the cache stores `(shape, property index)`, so a hit is a shape-pointer compare plus one key check instead of a linear property scan. Inserts/deletes and integer-key reordering rebuild or transition the shape, which invalidates stale caches; arrays, functions and containers fall back to `xt_get`.
|
|
10
|
+
- Numeric operators keep the inline two-double fast path; operands that are numeric literals skip their tag check. Conditions whose expression is a comparison, `in`, `instanceof` or `!` are already boolean tags, so codegen emits `icmp eq i64 value, XT_TRUE` instead of calling `xt_truthy` (this removes the call from the hot loop condition).
|
|
11
|
+
- Control flow: `if` / `while` / `do` / `for` / `for...of` / `for...in`, `switch`, `try/catch/finally`, `break` / `continue` / `return`.
|
|
12
|
+
- `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`. Arrays also expose a stable `Array.prototype[Symbol.iterator]`; calling it returns an iterator object with `next()` that is itself iterable.
|
|
13
|
+
- `switch` tests each `case` with strict equality, executes on a hit, and falls through until `break`.
|
|
14
|
+
- `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.
|
|
15
|
+
- `for...in` reuses `xt_object_keys` to enumerate keys (arrays / strings yield string indices).
|
|
16
|
+
- Expressions:
|
|
17
|
+
- Identifiers, numbers, BigInt (arbitrary precision), strings, templates, booleans, `null`, `undefined`, `arguments`
|
|
18
|
+
- Arithmetic / comparison / logical / short-circuit / conditional / bitwise / unary (including `typeof` `void`) / prefix-postfix increment-decrement / compound assignment / logical assignment
|
|
19
|
+
- Array literals (including spread `[...]`), object literals (including shorthand / methods / object spread `{...obj}`)
|
|
20
|
+
- Typed arrays, `ArrayBuffer`, `DataView`, `TextEncoder` / `TextDecoder`: see [Typed arrays and binary data](./typed-arrays.md) and [Strings and text](./strings.md)
|
|
21
|
+
- Property access (with a `length` special case, `Math` constants), element access, calls
|
|
22
|
+
- 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.
|
|
23
|
+
- Optional chaining `?.` / `?.[]` / `?.()`: nullish check short-circuits to `undefined`
|
|
24
|
+
- `delete`, `in`, `instanceof`
|
|
25
|
+
- `this` (saved to the function's `%saved.this`; arrow functions read from an environment slot), `super` (`super.x` / `super(...)`), `new`, `await`
|
|
26
|
+
- Closures (arrow functions / function expressions) and capture environment construction
|
|
27
|
+
- 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.
|
|
28
|
+
- `async` / `async function*`: closures are marked with `xt_function_set_async` / `xt_function_set_async_generator` and run on stackful coroutines — see [Async, promises and generators](./async.md).
|
|
29
|
+
- Standard library calls dispatch through `xt_call_method` / `xt_math_call` / `xt_object_*` and the per-constructor `xt_*` entry points; the surface is listed in [Standard library](./stdlib.md).
|
|
30
|
+
- Global string pool (`@.str.N` private constants, UTF-8 escaped).
|
|
31
|
+
- Builtin calls: `console.log` / `info` / `warn` / `error`, `Math.*`, `Object.*`, array / string methods, global functions, extension builtins (uniform `(argc, argv)` ABI).
|
|
32
|
+
- `main` entry point (returns 0, calls the module function, then drains microtasks and runs the event loop until no timers or descriptors remain).
|
|
33
|
+
- Unsupported nodes uniformly report `UnsupportedFeature`; they never crash.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Collections
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/collections.md)
|
|
4
|
+
|
|
5
|
+
Location: `runtime/xt_stdlib2/container.inc` (Map / Set) and
|
|
6
|
+
`runtime/xt_weak.c` (WeakMap / WeakSet / WeakRef).
|
|
7
|
+
|
|
8
|
+
## Map and Set
|
|
9
|
+
|
|
10
|
+
- `new Map()` / `new Map(iterable)` and `new Set()` / `new Set(iterable)`.
|
|
11
|
+
- `Map`: `size`, `get` / `set` / `has` / `delete` / `clear` / `forEach` / `keys` / `values` / `entries`.
|
|
12
|
+
- `Set`: `size`, `add` / `has` / `delete` / `clear` / `forEach` / `values` / `keys` / `entries`.
|
|
13
|
+
- `for...of` and spread iterate them through `[Symbol.iterator]`; a `Map` yields `[key, value]` pairs, and `keys` / `values` / `entries` return arrays in insertion order.
|
|
14
|
+
- `Object.keys` / `values` / `entries` do not see collection internals.
|
|
15
|
+
- `structuredClone` supports `Map` and `Set`, preserving cycles and shared references.
|
|
16
|
+
|
|
17
|
+
## WeakMap, WeakSet and WeakRef
|
|
18
|
+
|
|
19
|
+
- `WeakMap`: `get` / `set` / `has` / `delete`; `WeakSet`: `add` / `has` / `delete`; `WeakRef`: `deref()`.
|
|
20
|
+
- Keys (and `WeakRef` targets) do not keep their referents alive: `WeakMap` / `WeakSet` keys are **ephemerons** (a value is retained only while its key is reachable) and a `WeakRef` target is cleared when it becomes unreachable.
|
|
21
|
+
- The stack scan is conservative, so a stale stack word can delay clearing a weak target. The full GC description is in [Runtime deviations](../unimplemented/deviations.md) and [Unimplemented: toolchain](../unimplemented/toolchain.md).
|
|
22
|
+
|
|
23
|
+
## Iteration
|
|
24
|
+
|
|
25
|
+
- Any object exposing `[Symbol.iterator]()` is iterable in `for...of` and spread. `Array.prototype[Symbol.iterator]` is stable, and calling it returns an iterator object with `next()` that is itself iterable.
|
|
26
|
+
- Iteration is described further in [Codegen](./codegen.md#llvm-ir-code-generation-codegen) and [Symbol](./stdlib.md#symbol).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Driver, incremental compilation and toolchain
|
|
2
|
+
|
|
3
|
+
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/driver.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/driver/compiler.ts` (orchestration), `src/driver/frontend.ts`,
|
|
6
|
+
`src/driver/build-key.ts`, `src/driver/runtime-objects.ts`,
|
|
7
|
+
`src/driver/app-artifacts.ts`, `src/driver/cache.ts`, `src/driver/toolchain.ts`,
|
|
8
|
+
`src/driver/paths.ts`, `src/driver/version.ts`.
|
|
9
|
+
|
|
10
|
+
- Compilation pipeline: read source → module bundling (`src/driver/modules.ts`, when the entry contains `import`/`export`) → parse → bind/check → IR → object file → link.
|
|
11
|
+
- Incremental cache: keyed on "compiler version + source hash + emit kind + optimization level + LTO/PGO mode + platform + extension fingerprint (names, linker flags, native object contents)"; if the artifacts exist and are fresh, the build is skipped. `--pgo-use` always rebuilds because the profile data can change without the source. The key is assembled in `src/driver/build-key.ts`.
|
|
12
|
+
- C runtime and extension sources are cached as object files by content hash and compiled only once (the cache key includes the LTO/PGO flags). `RUNTIME_SOURCES` in `src/driver/runtime-objects.ts` lists the core translation units.
|
|
13
|
+
- Toolchain wrapper: locates `clang` (overridable with `xbintsc_CLANG`), compiles IR, compiles C, links.
|
|
14
|
+
- LTO (`--lto` / `"lto": true`): the program and runtime compile to LLVM bitcode (`-flto`) and link with `-fuse-ld=lld`; lld is required.
|
|
15
|
+
- PGO (`--pgo-generate[=dir]` then `--pgo-use[=dir]`, or `"pgo"` / `"pgoDir"`): the generated IR and runtime C are instrumented with `-fprofile-generate=<dir>`; after running the instrumented binary, `--pgo-use` merges `.profraw` files with `llvm-profdata` (preferring the copy next to clang, overridable with `xbintsc_LLVM_PROFDATA`) and rebuilds with `-fprofile-use=<dir>`.
|
|
16
|
+
- Link flags: `-lm` is added automatically on non-Windows; extensions may append extra link flags.
|
|
17
|
+
- Project config (`src/driver/config.ts`, `xbintsc.config.json`): `entry`, `outDir`, `output`, `optimize`, `lto`, `pgo`, `pgoDir`, `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.
|
|
18
|
+
- 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` 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.
|
|
19
|
+
- Compiler version: `COMPILER_VERSION` lives in `src/driver/version.ts` and is part of the cache key. The pre-commit hook bumps it (together with `package.json`) only on `main`/`master`, so feature branches never touch the version files.
|