xbintsc 0.3.79 → 0.3.87
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/README.md +13 -5
- package/README.zh-CN.md +13 -6
- package/dist/src/ast/common.d.ts +23 -0
- package/dist/src/cli/main.js +68 -24
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +5 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +50 -0
- package/dist/src/codegen/generator/context.js +124 -13
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/debug.d.ts +33 -0
- package/dist/src/codegen/generator/debug.js +97 -0
- package/dist/src/codegen/generator/debug.js.map +1 -0
- package/dist/src/codegen/generator/expressions/assignment.js +9 -5
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/operators.js +35 -9
- package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.js +5 -2
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/generator.d.ts +3 -1
- package/dist/src/codegen/generator/generator.js +3 -1
- package/dist/src/codegen/generator/generator.js.map +1 -1
- package/dist/src/codegen/generator/module.d.ts +1 -0
- package/dist/src/codegen/generator/module.js +76 -6
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/numeric.d.ts +26 -0
- package/dist/src/codegen/generator/numeric.js +127 -0
- package/dist/src/codegen/generator/numeric.js.map +1 -0
- package/dist/src/codegen/generator/state.d.ts +17 -0
- package/dist/src/codegen/generator/state.js +5 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/control-flow.js +1 -1
- package/dist/src/codegen/generator/statements/control-flow.js.map +1 -1
- package/dist/src/codegen/generator/statements/dispatch.js +3 -0
- package/dist/src/codegen/generator/statements/dispatch.js.map +1 -1
- package/dist/src/codegen/generator/statements/variables.js +8 -2
- package/dist/src/codegen/generator/statements/variables.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +7 -0
- package/dist/src/codegen/generator/tables.js +25 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +41 -5
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/compiler.d.ts +22 -3
- package/dist/src/driver/compiler.js +49 -58
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/fingerprint.d.ts +27 -0
- package/dist/src/driver/fingerprint.js +88 -0
- package/dist/src/driver/fingerprint.js.map +1 -0
- package/dist/src/driver/toolchain-provider.d.ts +9 -2
- package/dist/src/driver/toolchain-provider.js +15 -15
- package/dist/src/driver/toolchain-provider.js.map +1 -1
- package/dist/src/driver/toolchain.d.ts +58 -1
- package/dist/src/driver/toolchain.js +169 -22
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/extensions/gui/index.js +10 -2
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/parser/expressions.js +20 -1
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/tests/cli/main.test.js +41 -1
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/expressions.test.js +14 -3
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +23 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/driver/toolchain-provider.test.js +49 -2
- package/dist/tests/driver/toolchain-provider.test.js.map +1 -1
- package/dist/tests/driver/toolchain.test.js +62 -3
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/e2e/child-process.test.d.ts +10 -0
- package/dist/tests/e2e/child-process.test.js +59 -0
- package/dist/tests/e2e/child-process.test.js.map +1 -0
- package/dist/tests/e2e/compile-objects-classes.test.js +47 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/error-stack.test.d.ts +9 -0
- package/dist/tests/e2e/error-stack.test.js +94 -0
- package/dist/tests/e2e/error-stack.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-svg.test.d.ts +21 -0
- package/dist/tests/e2e/gui-example-svg.test.js +105 -0
- package/dist/tests/e2e/gui-example-svg.test.js.map +1 -0
- package/dist/tests/e2e/gui-transform.test.d.ts +7 -0
- package/dist/tests/e2e/gui-transform.test.js +198 -0
- package/dist/tests/e2e/gui-transform.test.js.map +1 -0
- package/dist/tests/e2e/string-concat.test.d.ts +9 -0
- package/dist/tests/e2e/string-concat.test.js +102 -0
- package/dist/tests/e2e/string-concat.test.js.map +1 -0
- package/dist/tests/helpers.d.ts +9 -0
- package/dist/tests/helpers.js +26 -3
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +7 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/dist/tests/version.test.d.ts +1 -0
- package/dist/tests/version.test.js +24 -0
- package/dist/tests/version.test.js.map +1 -0
- package/doc/DESIGN.md +20 -12
- package/doc/ai/cli.md +7 -0
- package/doc/ai/contributing.md +7 -1
- package/doc/ai/extensions.md +5 -1
- package/doc/ai/language-support.md +4 -4
- package/doc/ai/troubleshooting.md +39 -2
- package/doc/ai/zh-CN/cli.md +2 -0
- package/doc/ai/zh-CN/contributing.md +6 -2
- package/doc/ai/zh-CN/extensions.md +5 -1
- package/doc/ai/zh-CN/language-support.md +4 -4
- package/doc/ai/zh-CN/troubleshooting.md +35 -2
- package/doc/gui/animation.md +53 -2
- package/doc/gui/api.md +1 -1
- package/doc/gui/dom.md +6 -1
- package/doc/gui/input.md +4 -1
- package/doc/gui/known-issues.md +16 -4
- package/doc/gui/layout.md +36 -0
- package/doc/gui/rendering.md +15 -0
- package/doc/gui.md +32 -3
- package/doc/implemented.md +4 -4
- package/doc/requirements.md +13 -4
- package/doc/unimplemented.md +11 -10
- package/doc/zh-CN/DESIGN.md +15 -9
- package/doc/zh-CN/gui/animation.md +49 -2
- package/doc/zh-CN/gui/api.md +1 -1
- package/doc/zh-CN/gui/dom.md +6 -1
- package/doc/zh-CN/gui/input.md +2 -0
- package/doc/zh-CN/gui/known-issues.md +12 -2
- package/doc/zh-CN/gui/layout.md +31 -0
- package/doc/zh-CN/gui/rendering.md +11 -0
- package/doc/zh-CN/gui.md +28 -3
- package/doc/zh-CN/implemented.md +4 -4
- package/doc/zh-CN/requirements.md +12 -3
- package/doc/zh-CN/unimplemented.md +10 -9
- package/package.json +3 -1
- package/runtime/ext_gui/document.cpp +21 -3
- package/runtime/ext_gui/document.h +4 -1
- package/runtime/ext_gui/dom_api_node.cpp +6 -4
- package/runtime/ext_gui/layout.cpp +78 -1
- package/runtime/ext_gui/layout.h +21 -0
- package/runtime/ext_gui/paint.cpp +48 -15
- package/runtime/ext_gui/paint.h +8 -2
- package/runtime/ext_gui/renderer.cpp +4 -2
- package/runtime/ext_gui/renderer_image.cpp +2 -1
- package/runtime/ext_gui/renderer_internal.h +6 -1
- package/runtime/ext_gui/renderer_text.cpp +37 -15
- package/runtime/ext_gui/style.h +10 -0
- package/runtime/ext_gui/style_print.cpp +6 -0
- package/runtime/ext_gui/style_values.cpp +43 -0
- package/runtime/ext_gui/transform.cpp +412 -0
- package/runtime/ext_gui/transform.h +112 -0
- package/runtime/ext_gui/window.cpp +6 -4
- package/runtime/ext_node/buffer/parts/construction.inc +2 -2
- package/runtime/ext_node/buffer/parts/methods.inc +1 -1
- package/runtime/ext_node/buffer/parts/search.inc +1 -1
- package/runtime/ext_node/child_process/child_process.c +25 -0
- package/runtime/ext_node/fs/fd_ops.c +1 -1
- package/runtime/rt.h +17 -1
- package/runtime/rt_internal.h +47 -4
- package/runtime/xt_alloc.c +14 -2
- package/runtime/xt_bigint/conversions.inc +1 -1
- package/runtime/xt_builtins.c +136 -14
- package/runtime/xt_containers/access.inc +17 -16
- package/runtime/xt_containers/objects.inc +4 -3
- package/runtime/xt_io/exception.inc +171 -2
- package/runtime/xt_io/inspect.inc +15 -13
- package/runtime/xt_io.c +5 -0
- package/runtime/xt_stdlib/arrays.inc +2 -2
- package/runtime/xt_stdlib/dispatch.inc +2 -2
- package/runtime/xt_stdlib/strings.inc +33 -21
- package/runtime/xt_stdlib2/array-statics.inc +2 -1
- package/runtime/xt_stdlib2/arrays.inc +1 -1
- package/runtime/xt_stdlib2/error.inc +22 -6
- package/runtime/xt_stdlib2/json.inc +3 -2
- package/runtime/xt_stdlib2/number-string-statics.inc +3 -1
- package/runtime/xt_stdlib2/regexp-match.inc +48 -33
- package/runtime/xt_stdlib2/strings.inc +23 -14
- package/runtime/xt_symbol.c +1 -1
- package/runtime/xt_values/comparison.inc +2 -2
- package/runtime/xt_values/constructors.inc +10 -5
- package/runtime/xt_values/conversions.inc +4 -3
- package/runtime/xt_values/strings.inc +78 -4
- package/scripts/bench.ts +172 -0
- package/scripts/build-runtime.ts +2 -1
- package/scripts/check-version.ts +53 -0
- package/src/ast/common.ts +23 -0
- package/src/cli/main.ts +68 -26
- package/src/codegen/generator/calls/invocation.ts +5 -0
- package/src/codegen/generator/context.ts +129 -18
- package/src/codegen/generator/debug.ts +132 -0
- package/src/codegen/generator/expressions/assignment.ts +9 -5
- package/src/codegen/generator/expressions/operators.ts +47 -8
- package/src/codegen/generator/expressions/primary.ts +5 -2
- package/src/codegen/generator/generator.ts +18 -2
- package/src/codegen/generator/module.ts +78 -6
- package/src/codegen/generator/numeric.ts +158 -0
- package/src/codegen/generator/state.ts +22 -0
- package/src/codegen/generator/statements/control-flow.ts +1 -1
- package/src/codegen/generator/statements/dispatch.ts +3 -0
- package/src/codegen/generator/statements/variables.ts +8 -2
- package/src/codegen/generator/tables.ts +26 -0
- package/src/driver/bundler/merge.ts +39 -5
- package/src/driver/compiler.ts +68 -56
- package/src/driver/fingerprint.ts +85 -0
- package/src/driver/toolchain-provider.ts +17 -16
- package/src/driver/toolchain.ts +210 -21
- package/src/extensions/gui/index.ts +10 -2
- package/src/parser/expressions.ts +20 -1
package/doc/implemented.md
CHANGED
|
@@ -241,7 +241,7 @@ Location: `runtime/xt_alloc.c`, `runtime/xt_values.c`, `runtime/xt_containers.c`
|
|
|
241
241
|
|
|
242
242
|
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan).
|
|
243
243
|
- Value construction: `xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`.
|
|
244
|
-
- Strings: UTF-8 storage, concatenation, equality comparison, formatted number-to-string.
|
|
244
|
+
- Strings: UTF-8 storage, lazy cons-node concatenation (bytes are flattened on first observation, so append loops stay linear), equality comparison, formatted number-to-string.
|
|
245
245
|
- Type conversion: `xt_truthy`, `xt_to_number`, `xt_to_string`, `xt_typeof`.
|
|
246
246
|
- Arithmetic: `add/sub/mul/div/mod/pow/neg/pos`.
|
|
247
247
|
- Bitwise: `and/or/xor/not/shl/shr/ushr` (including `ToInt32` semantics).
|
|
@@ -255,7 +255,7 @@ Location: `runtime/xt_alloc.c`, `runtime/xt_values.c`, `runtime/xt_containers.c`
|
|
|
255
255
|
- Operator helpers: `xt_in` (`in`), `xt_delete` (`delete`), `xt_rest_args` (rest parameters / `arguments`).
|
|
256
256
|
- Box: `box_new/get/set` (for closure-captured variables).
|
|
257
257
|
- Functions and closures: `arg`, `closure_new/call/env/arity`.
|
|
258
|
-
- 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.
|
|
258
|
+
- 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.
|
|
259
259
|
- 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`.
|
|
260
260
|
- 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`.
|
|
261
261
|
- 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`).
|
|
@@ -346,7 +346,7 @@ const result = build("program.ts", { emit: "exe", outDir: "build" });
|
|
|
346
346
|
Location: `tests/` (`lexer` / `parser` / `binder` / `codegen` / `driver` / `extensions` / `cli` / `e2e`)
|
|
347
347
|
|
|
348
348
|
- Per-module unit tests; when `clang` is present, e2e really compiles and runs binaries, otherwise it is skipped automatically.
|
|
349
|
-
- e2e coverage: arithmetic and printing, recursive functions, loops / arrays / string concatenation, closures capturing by reference, JS-style printing of objects / arrays, the Node `fs` extension via `import`, `switch` fall-through, array / string methods, `Math` and global functions and all `console` levels, default / rest parameters and `arguments`, `Object` helpers and spread and `in`/`delete`, `for...in` object key enumeration, `try/catch/finally`, optional chaining, classes and `new`/`this`/`static`/`extends`/`super`/`instanceof`, `async`/`await` and `Promise`, `Map`/`Set`/`JSON` and extended standard library, `for...of` over `Map`/`Set`, array `length` assignment and iterable spread, multi-file `import`/`export` (including `.js` specifiers and plain JavaScript sources), destructuring bindings and assignments, `enum`/`const enum`, regular-expression literals and `new Error(...)`, the `Error` family and `AggregateError`, generators and `Symbol` with custom `Symbol.iterator` iterables, typed arrays (element coercion, `from`/`of`, iteration and the prototype methods), and the global `fetch` (HTTP GET/POST, headers, redirects, JSON/text/binary bodies and `TypeError` rejection).
|
|
349
|
+
- e2e coverage: arithmetic and printing, recursive functions, loops / arrays / string concatenation, closures capturing by reference, JS-style printing of objects / arrays, the Node `fs` extension via `import`, `switch` fall-through, array / string methods, `Math` and global functions and all `console` levels, default / rest parameters and `arguments`, `Object` helpers and spread and `in`/`delete`, `for...in` object key enumeration, `try/catch/finally`, optional chaining, classes and `new`/`this`/`static`/`extends`/`super`/`instanceof`, `async`/`await` and `Promise`, `Map`/`Set`/`JSON` and extended standard library, `for...of` over `Map`/`Set`, array `length` assignment and iterable spread, multi-file `import`/`export` (including `.js` specifiers and plain JavaScript sources), destructuring bindings and assignments (including object rest), built-in `instanceof`, `enum`/`const enum`, regular-expression literals and `new Error(...)`, the `Error` family and `AggregateError`, generators and `Symbol` with custom `Symbol.iterator` iterables, typed arrays (element coercion, `from`/`of`, iteration and the prototype methods), and the global `fetch` (HTTP GET/POST, headers, redirects, JSON/text/binary bodies and `TypeError` rejection).
|
|
350
350
|
|
|
351
351
|
---
|
|
352
352
|
|
|
@@ -366,7 +366,7 @@ Location: `tests/` (`lexer` / `parser` / `binder` / `codegen` / `driver` / `exte
|
|
|
366
366
|
| Value model | 64-bit NaN-boxing, uniform function ABI (including `this`), closure environments, object prototype chains |
|
|
367
367
|
| Runtime | Strings / objects / arrays / typed arrays / closures / arithmetic / comparison / catchable exceptions / Promise / collections / symbols / generators / `fetch` / `console` |
|
|
368
368
|
| Extensions | Extension registry, `core` (print), `node` (fs / path / os / process / buffer / stream / net / dgram / http imported by specifier) |
|
|
369
|
-
| GUI (`gui` extension) | Self-hosted HTML/CSS renderer window (SDL3 + SDL_GPU): DOM/CSS/layout, `<img>`/SVG, `<video>`/`<audio>`, `<canvas>` 2D, events, transitions |
|
|
369
|
+
| GUI (`gui` extension) | Self-hosted HTML/CSS renderer window (SDL3 + SDL_GPU): DOM/CSS/layout, CSS `transform`/`transform-origin`, `<img>`/SVG, `<video>`/`<audio>`, `<canvas>` 2D, events, transitions (including `transform`) |
|
|
370
370
|
| Toolchain | clang compiles IR/C, linking, incremental cache |
|
|
371
371
|
| Project config | `xbintsc.config.json` (`entry` / `outDir` / `optimize` / `extensions` / `app`), discovery + CLI precedence |
|
|
372
372
|
| Application icon | compile-time embed (PNG/ICO/ICNS), PE resource on Windows, `.app` bundle on macOS, runtime window/Dock icon via `gui` |
|
package/doc/requirements.md
CHANGED
|
@@ -20,10 +20,19 @@ build/app.ll:382:37: error: '@.str.0' defined with type '[6 x i8]*' but expected
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Typed pointers were removed in LLVM 16 ([release notes](https://github.com/llvm/llvm-project/blob/release/15.x/llvm/docs/ReleaseNotes.rst#changes-to-the-llvm-ir)),
|
|
23
|
-
so
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
so xbintsc now **checks the version before it compiles anything**:
|
|
24
|
+
|
|
25
|
+
- `xbintsc build` / `run` stop immediately with an actionable error when the
|
|
26
|
+
resolved driver is older than 16, instead of emitting IR that cannot compile.
|
|
27
|
+
- `xbintsc doctor` prints `status : ok` or `status : too old` and exits non-zero
|
|
28
|
+
when the toolchain cannot build binaries, so scripts and CI can preflight it.
|
|
29
|
+
- The search prefers a clang >= 16: on Windows the LLVM bundled with Visual
|
|
30
|
+
Studio (`<VS install>\VC\Tools\Llvm\x64\bin\clang.exe`) is found even when an
|
|
31
|
+
older `clang` comes first on `PATH`. Set `xbintsc_CLANG` to override the
|
|
32
|
+
choice; an explicit older binary is rejected with a "too old" error rather
|
|
33
|
+
than silently ignored.
|
|
34
|
+
|
|
35
|
+
Working around the limitation by compiling the IR elsewhere is not supported.
|
|
27
36
|
|
|
28
37
|
## Summary
|
|
29
38
|
|
package/doc/unimplemented.md
CHANGED
|
@@ -68,8 +68,9 @@ None — generators are implemented.
|
|
|
68
68
|
> Tagged templates are implemented, including raw strings and `String.raw`.
|
|
69
69
|
> Generators (`function*`, `yield`, `yield*`) are implemented with stackful
|
|
70
70
|
> coroutines, including `next`/`throw`/`return`, `for...of`, spread and
|
|
71
|
-
> delegation. `import.meta`
|
|
72
|
-
>
|
|
71
|
+
> delegation. `import.meta` exposes `url`, `dirname` and `filename`, resolved
|
|
72
|
+
> from the running executable's path. `async function*` is **rejected with
|
|
73
|
+
> `UnsupportedFeature`** instead of silently producing a synchronous generator.
|
|
73
74
|
|
|
74
75
|
### 2.2 Not supported by the parser
|
|
75
76
|
|
|
@@ -79,7 +80,7 @@ None known at the expression level.
|
|
|
79
80
|
|
|
80
81
|
| Operator | Status | Notes |
|
|
81
82
|
| --- | --- | --- |
|
|
82
|
-
| `new.target` | ✗ |
|
|
83
|
+
| `new.target` | ✗ | parsed, then rejected with `UnsupportedFeature` (no `new.target` semantics) |
|
|
83
84
|
| `typeof` / `void` / `in` / `delete` / `instanceof` | ✓ | mapped to runtime helpers (`xt_typeof`, `xt_in`, `xt_delete`, `xt_instance_of`) |
|
|
84
85
|
|
|
85
86
|
---
|
|
@@ -132,7 +133,7 @@ element writes, and `fill` / `set` / `slice` / `subarray` / `join` / `toString`
|
|
|
132
133
|
| `keys` / `values` / `entries` | ~ return arrays, not iterator objects |
|
|
133
134
|
| `ArrayBuffer` / `DataView` / `.buffer` / `.byteOffset` semantics | ✗ no backing buffer type; `.byteOffset` is always 0 |
|
|
134
135
|
| `BigInt64Array` / `BigUint64Array` | ✗ not implemented |
|
|
135
|
-
| `instanceof
|
|
136
|
+
| `instanceof` built-in constructors | ✓ `instanceof Array` / `Object` / `Map` / `Set` / `Date` / `RegExp` / `Promise` / `Error` family / typed arrays are recognised by name; the constructors are still not first-class values (`const A = Array` fails) |
|
|
136
137
|
| Typed-array views over a `Buffer` / `ArrayBuffer` | ✗ constructors copy from a length / array-like / typed array only |
|
|
137
138
|
|
|
138
139
|
---
|
|
@@ -169,8 +170,8 @@ element writes, and `fill` / `set` / `slice` / `subarray` / `join` / `toString`
|
|
|
169
170
|
| `arguments` object | ✓ (implicit) | ✓ implemented (arrow functions get their own parameters, not the outer function's `arguments`, unlike JS) |
|
|
170
171
|
| `this` binding / method call semantics | ✓ | ✓ implemented (`this` is threaded as the first ABI parameter; arrow functions inherit lexically) |
|
|
171
172
|
| `async` / `await` / Promise | ✓ | ✓ implemented (synchronous microtask model) |
|
|
172
|
-
| `new.target` | ✗ |
|
|
173
|
-
| Generators / iterators / `yield` | ✓ implemented | `function*`, `yield`, `yield*`, `.next/.throw/.return`; `async` generators
|
|
173
|
+
| `new.target` | ✗ | parsed, then rejected with `UnsupportedFeature` (no `new.target` semantics) |
|
|
174
|
+
| Generators / iterators / `yield` | ✓ implemented | `function*`, `yield`, `yield*`, `.next/.throw/.return`; `async` generators are rejected with `UnsupportedFeature` |
|
|
174
175
|
| Closure `arity` | — | `xt_closure_arity` is always -1, never filled in |
|
|
175
176
|
| `fn.call` / `fn.apply` / `fn.bind` | ✓ | ✓ implemented (the bound closure does not track partial-argument `length`) |
|
|
176
177
|
| `fn.name` / `fn.length` | ✓ | ✓ implemented (inferred from the declaration / assignment / property key; bound functions use `"bound ..."` and adjusted arity) |
|
|
@@ -232,9 +233,9 @@ These features **compile and run**, but the result does not fully match ECMAScri
|
|
|
232
233
|
| Function `arity` / argument count | No argument count validation; `fn.length` reports the declared arity but calls are never checked against it |
|
|
233
234
|
| `async` / `await` | **Synchronous microtask model**: `await` on an already-settled promise continues synchronously. Timers and sockets run on the event loop only after the program body, so a promise settled from a timer callback cannot be awaited |
|
|
234
235
|
| `super` | `super.x` / `super(...)` takes the prototype of `this`'s prototype; single-level inheritance is correct, but depth > 1 may be inaccurate |
|
|
235
|
-
| `Error.stack` |
|
|
236
|
+
| `Error.stack` | Function-level frames only: each frame is `at name (file:line)` with the function's declaration line (updated to the construction line for the innermost frame); no column numbers and no frames for generator bodies (they switch stacks) |
|
|
236
237
|
| Module live bindings | Namespace imports and imported bindings are snapshots (see section 4) |
|
|
237
|
-
| `import.meta` |
|
|
238
|
+
| `import.meta` | ✓ `import.meta.url` / `.dirname` / `.filename`, resolved from the executable path |
|
|
238
239
|
|
|
239
240
|
> Number formatting, loose equality, `+` / relational `ToPrimitive`, whole-chain
|
|
240
241
|
> optional chaining, `finally` on early exit and object-key ordering have all
|
|
@@ -263,9 +264,9 @@ These features **compile and run**, but the result does not fully match ECMAScri
|
|
|
263
264
|
```
|
|
264
265
|
Unimplemented (statements): namespace/module declarations
|
|
265
266
|
|
|
266
|
-
Unimplemented (expressions): new.target
|
|
267
|
+
Unimplemented (expressions): new.target (clear UnsupportedFeature)
|
|
267
268
|
|
|
268
|
-
Unimplemented (functions): `fn.toString()` source text, async generators
|
|
269
|
+
Unimplemented (functions): `fn.toString()` source text, async generators (rejected)
|
|
269
270
|
|
|
270
271
|
Unimplemented (classes/OO): abstract/implements, access control,
|
|
271
272
|
parent/child #x collision
|
package/doc/zh-CN/DESIGN.md
CHANGED
|
@@ -39,13 +39,18 @@ xt_value fn(xt_value env, int32_t argc, xt_value *argv);
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
`env` 通过 box 以引用方式传递捕获变量,直接调用与闭包调用共用一条代码路径。
|
|
42
|
-
不易内联的 JS 语义(`+`
|
|
42
|
+
不易内联的 JS 语义(`+` 隐式转换、属性访问、打印)委托给 `@xt_*` 运行时调用。
|
|
43
|
+
数值算术与比较是例外:codegen 内联 double 快路径(`numeric.ts`),需要隐式转换时
|
|
44
|
+
才调用运行时。
|
|
43
45
|
|
|
44
46
|
### 运行时
|
|
45
47
|
|
|
46
|
-
`runtime
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
`runtime/` 实现字符串、对象、数组、闭包、算术、比较、异常与类 Node 的
|
|
49
|
+
`console.log` 打印。它按职责拆分为多个编译单元(`xt_values.c`、
|
|
50
|
+
`xt_containers.c`、`xt_stdlib.c`、`xt_builtins.c`、`xt_io.c`、`xt_alloc.c` 等),
|
|
51
|
+
每个单元 `#include` 自己的实现片段(`.inc`),这样文件保持小巧而不改变链接范围。
|
|
52
|
+
`xt_alloc` 背后使用非移动标记-清扫回收器(显式根、子系统根提供者与保守 C 栈扫描),
|
|
53
|
+
其内部实现对编译器保持隔离。
|
|
49
54
|
|
|
50
55
|
### llc 的替代
|
|
51
56
|
|
|
@@ -92,13 +97,14 @@ xt_value fn(xt_value env, int32_t argc, xt_value *argv);
|
|
|
92
97
|
同样覆盖:Windows 下 xbintsc 使用系统 clang 按 MSVC ABI 链接,示例即针对该 ABI 构建。
|
|
93
98
|
参见 `examples/extensions/` 与 `runtime/xt_ext.h` / `runtime/xt_ext.rs`。
|
|
94
99
|
|
|
95
|
-
##
|
|
100
|
+
## 自举
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
编译器已经能编译自身:`xbintsc build src/cli/main.ts --ext node` 会产出一个可用的
|
|
103
|
+
`xbintsc` 二进制,且从第一代起生成的 IR 就是不动点。CI 会为每个支持的平台构建这些
|
|
104
|
+
二进制并检查不动点。运行时仍使用 C;以后是否用 TS 重写只是可选项,并不是自举的前提。
|
|
99
105
|
|
|
100
106
|
## 测试
|
|
101
107
|
|
|
102
108
|
按模块划分:`tests/lexer`、`tests/parser`、`tests/binder`、`tests/codegen`、
|
|
103
|
-
`tests/driver`、`tests/extensions`、`tests/cli`、`tests/e2e
|
|
104
|
-
`
|
|
109
|
+
`tests/driver`、`tests/extensions`、`tests/cli`、`tests/e2e`。存在受支持的 clang
|
|
110
|
+
(16+,与 `build` 使用的版本门槛一致)时,e2e 会真正编译并运行二进制,否则自动跳过。
|
|
@@ -31,8 +31,10 @@ transition 的属性时,会记录一个正在运行的 transition,并在每
|
|
|
31
31
|
让测试可以确定性地推进。
|
|
32
32
|
|
|
33
33
|
- 支持的属性:`background-color`、`color`、`border-color`、
|
|
34
|
-
`border-radius`;`transition: all`
|
|
35
|
-
|
|
34
|
+
`border-radius` 与 `transform`;`transition: all` 覆盖它们。影响布局的
|
|
35
|
+
属性(width、position 等)仍不做动画——那会每帧重新布局——但 `transform`
|
|
36
|
+
是绘制期效果,因此为它做动画的代价只是每个被动画的盒子每帧一个矩阵
|
|
37
|
+
(见[布局](./layout.md#变换m15))。
|
|
36
38
|
- `transition` 简写与 `transition-property` / `-duration` / `-delay` /
|
|
37
39
|
`-timing-function` 长写都会被解析;时间值接受 `s` 与 `ms`;缓动函数为
|
|
38
40
|
`linear`、`ease`、`ease-in`、`ease-out` 与 `ease-in-out`(`ease` 是
|
|
@@ -42,5 +44,50 @@ transition 的属性时,会记录一个正在运行的 transition,并在每
|
|
|
42
44
|
- `computedStyle()` 报告显示(已插值)的值,因此 transition 在测试中可直接
|
|
43
45
|
观察。
|
|
44
46
|
|
|
47
|
+
`transform` 列表按**逐项**插值(`document.cpp`、`xt_transform_interpolate`),
|
|
48
|
+
这正是让常见的一对 `translateY(-4px) rotate(-0.35deg)` 与 `none` 之间平滑
|
|
49
|
+
滑行而不是跳变的原因:缺失的一侧会用同类型的单位(identity)操作补齐。两个
|
|
50
|
+
列表形状或单位对不上时(`rotate(10deg)` 对 `rotate(10rad)`,或函数个数不同)
|
|
51
|
+
完全不做插值——transition 直接吸附到目标值,即 CSS 的离散回退,而不是一段
|
|
52
|
+
看起来错误的扫过。
|
|
53
|
+
|
|
54
|
+
## CSS transform(M15)
|
|
55
|
+
|
|
56
|
+
`transform` 与 `transform-origin` 作为*绘制期*效果得到支持
|
|
57
|
+
(`translate`/`translate3d`/`translateX`/`translateY`、
|
|
58
|
+
`scale`/`scale3d`/`scaleX`/`scaleY`、`rotate`/`rotateZ`、`matrix`;`3d` 拼写的
|
|
59
|
+
`z` 参数会被解析后丢弃,因为引擎是 2D 的;`deg`/`rad`/`grad`/`turn`;`%`、
|
|
60
|
+
`px`、`em`、`rem`、`vw`、`vh`)。布局不受影响:几何仍是流式布局放下的位置,只有绘制结果移动,
|
|
61
|
+
因此尺寸、滚动位置或兄弟节点的位置从不依赖某一动画帧。合成规则见
|
|
62
|
+
[布局](./layout.md#变换m15),如何到达 GPU 见[绘制](./rendering.md)。
|
|
63
|
+
|
|
64
|
+
驱动方式有两种:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
// 1. 逐帧——由帧时钟算出一个姿态。不会触发重排:字符串被解析成矩阵,
|
|
68
|
+
// 显示列表在同一帧里就取用它们。
|
|
69
|
+
const tick = (t: number): void => {
|
|
70
|
+
const s = t / 1000;
|
|
71
|
+
art.style.setProperty(
|
|
72
|
+
"transform",
|
|
73
|
+
"translateY(" + (Math.sin(s * 2.4) * 5).toFixed(2) + "px) " +
|
|
74
|
+
"rotate(" + (Math.sin(s * 1.15) * 1.1).toFixed(2) + "deg)",
|
|
75
|
+
);
|
|
76
|
+
win.requestAnimationFrame(tick);
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```css
|
|
81
|
+
/* 2. 由状态变化驱动——和任何其他属性一样参与 transition 的 transform。 */
|
|
82
|
+
#caption {
|
|
83
|
+
transform-origin: 50% 100%;
|
|
84
|
+
transition: transform 260ms ease-out;
|
|
85
|
+
}
|
|
86
|
+
#caption:hover { transform: translateY(-2px) scale(1.03); }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
两种方式都由 `examples/gui/pelican-svg` 演示(逐帧摇摆 + 悬停时说明文字的
|
|
90
|
+
transition),并由 `tests/e2e/gui-transform.test.ts` 固定住。
|
|
91
|
+
|
|
45
92
|
动画仍需完成:`@keyframes` 动画与 `cubic-bezier(...)`。
|
|
46
93
|
|
package/doc/zh-CN/gui/api.md
CHANGED
|
@@ -59,7 +59,7 @@ win.on("keydown", (e) => console.log(e.key, e.code, e.ctrl, e.shift, e.alt, e.me
|
|
|
59
59
|
```ts
|
|
60
60
|
win.computedStyle(selector, property) // e.g. ("#main", "width") -> "60%"
|
|
61
61
|
win.queryCount(selector) // 匹配元素的数量
|
|
62
|
-
win.getBoundingClientRect(selector) // { x, y, width, height }
|
|
62
|
+
win.getBoundingClientRect(selector) // { x, y, width, height }(边框盒,含变换)
|
|
63
63
|
win.documentTree() // 序列化的 DOM(调试用)
|
|
64
64
|
win.layoutTree() // 序列化的布局盒(调试用)
|
|
65
65
|
win.paintCount() // 显示列表中图形的数量
|
package/doc/zh-CN/gui/dom.md
CHANGED
|
@@ -20,7 +20,12 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
|
|
|
20
20
|
有状态的 `:hover` 与 `:focus`(见[输入](./input.md))。值:长度
|
|
21
21
|
(`px`、`%`、`em`、`rem`、`vw`、`vh`、`pt`、`pc`、`in`、`cm`、`mm`、`q`)、
|
|
22
22
|
颜色(十六进制、`rgb()`/`rgba()`、一个命名子集)、数字、关键字与简写
|
|
23
|
-
(`margin`/`padding`/`border`/`flex
|
|
23
|
+
(`margin`/`padding`/`border`/`flex`)。`transform`
|
|
24
|
+
(`translate`/`translate3d`/`translateX`/`translateY`、
|
|
25
|
+
`scale`/`scale3d`/`scaleX`/`scaleY`、`rotate`/`rotateZ`、`matrix`;`3d`
|
|
26
|
+
拼写的 `z` 参数会被丢弃)与 `transform-origin`
|
|
27
|
+
会被解析进计算样式:前者是操作列表,后者是两个(未解析的)原点长度;不支持的
|
|
28
|
+
函数会让整条声明失效(见[布局](./layout.md#变换m15))。
|
|
24
29
|
|
|
25
30
|
**层叠与计算样式**(`runtime/ext_gui/style.{h,cpp}`):一份小的内置 UA
|
|
26
31
|
样式表,作者规则按 `(!important, 特异性, 源码顺序)` 排序,然后是内联
|
package/doc/zh-CN/gui/input.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
`LayoutTree::hitTest` 返回包含某点的最深盒(先探测靠后的兄弟,使最上层元素
|
|
9
9
|
胜出),`xt_dom_describe` 把元素转换为事件负载携带的 `div#id.class` 描述符。
|
|
10
|
+
被变换的盒子先把点经其逆矩阵映射,因此旋转、缩放或平移过的元素恰好在它**被画
|
|
11
|
+
出来**的位置被命中——`:hover` 跟着画面走,而不是跟着流式布局留下的盒子走。
|
|
10
12
|
|
|
11
13
|
- SDL 指针/滚轮/键盘事件会被路由到所属窗口,进行命中测试,并投递给用 `on`
|
|
12
14
|
注册的处理器。`mousedown` 还会移动焦点。
|
|
@@ -35,10 +35,20 @@
|
|
|
35
35
|
|
|
36
36
|
- Linux 首发是只发布 X11、Wayland,还是两者都发布。(决定:先 X11,
|
|
37
37
|
Wayland 随后。)
|
|
38
|
+
- **Windows:链接命令行里不能点名 C++ 运行时。** `gui.lib` 用*静态* CRT 构建
|
|
39
|
+
(`CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`),引擎每个目标文件都把 `libcpmt`
|
|
40
|
+
记为默认依赖库;这既是 clang 在 Windows 上的默认,也是 xbintsc 运行时对象所用
|
|
41
|
+
的运行时(见 `scripts/build-gui.ts`)。如果再额外要求 DLL 版运行时——gui 扩展
|
|
42
|
+
过去会传 `-lmsvcprt`——同一批符号的两份定义就会冲突:`LNK2038: mismatch detected
|
|
43
|
+
for 'RuntimeLibrary'`,外加满屏 `LNK2005: already defined`,最终表现为
|
|
44
|
+
`clang: linker command failed with exit code 1169`。现在
|
|
45
|
+
`src/extensions/gui/index.ts` 只列系统库(`user32`、`gdi32`、`d3d12` 等)。
|
|
46
|
+
Windows 链接也是唯一需要 MSVC 环境的环节,请在 x64 Native Tools 命令行里构建。
|
|
38
47
|
- Windows:`scripts/build-gui.ts` 会生成 MSVC 兼容的 `gui.lib`
|
|
39
48
|
(COFF 对象 + `ar -M`/`llvm-ar`),但尚未在 CI 中验证,因此 Windows 步骤
|
|
40
|
-
为试验性(job 保持绿色),`package`
|
|
41
|
-
|
|
49
|
+
为试验性(job 保持绿色),`package` 会跳过它;在开发者机器上构建并运行
|
|
50
|
+
`examples/gui/pelican-svg` 与 `examples/gui/pelican-bike` 是可以的。它还需要
|
|
51
|
+
一个带 D3D12/DXIL 后端的 SDL3 构建(DXIL 需要 `dxc`)。
|
|
42
52
|
- **Windows 上的媒体:** 媒体解码器(FFmpeg)只构建并合并进 POSIX 的
|
|
43
53
|
`gui.a`;Windows 的 `gui.lib` 不含它们,因此那里的 `<video>`/`<audio>` 为空
|
|
44
54
|
操作(失败会触发 `error`)。启用它需要 MSVC 兼容的 FFmpeg 构建,推迟到
|
package/doc/zh-CN/gui/layout.md
CHANGED
|
@@ -54,6 +54,37 @@
|
|
|
54
54
|
`z-index` 层叠上下文,以及 `float` 对块级子元素的影响(只有行内内容会绕排,
|
|
55
55
|
块必须 `clear`)。
|
|
56
56
|
|
|
57
|
+
## 变换(M15)
|
|
58
|
+
|
|
59
|
+
`transform` 与 `transform-origin` 是**绘制期**效果:上面的盒模型完全不变
|
|
60
|
+
(不重排、不重算几何),`xt_layout_run` 之后的一次额外遍历会给每个
|
|
61
|
+
`LayoutBox` 一个 `Matrix2D world`(整条祖先链的变换)及其 `inverse`:
|
|
62
|
+
|
|
63
|
+
- **只有元素盒参与。** 文本盒与其父元素共享同一个 `style` 指针,若两者都参与
|
|
64
|
+
就会把元素的列表应用两次;该遍历只合成元素自身的列表与祖先的。
|
|
65
|
+
- **`transform-origin` 在这里解析**,而不是在层叠阶段:计算样式保留两个
|
|
66
|
+
(可能是 `%` 的)`Length`(默认 `50% 50%`),布局按*边框盒*解析它们,应用
|
|
67
|
+
`T(origin) · M · T(-origin)`。这就是
|
|
68
|
+
`computedStyle(el, "transform-origin")` 仍报告 `50% 92%` 的原因。关键字与
|
|
69
|
+
CSS 一样带方向:单独写 `top` 等于 `center top`,两个关键字可以任意顺序
|
|
70
|
+
(`bottom right` 等于 `right bottom`)。
|
|
71
|
+
- **长度按盒子解析**:`translate()` 里的 `%` 是边框盒宽/高的比例,`em`/`rem`
|
|
72
|
+
按根字号(16px),`vw`/`vh` 按视口。
|
|
73
|
+
- **合成顺序**遵循 CSS:列表从右往左应用,所以
|
|
74
|
+
`rotate(90deg) translate(10px)` 把盒子往屏幕**下方**移动,而不是往右。
|
|
75
|
+
|
|
76
|
+
下游消费者都跟着矩阵走:
|
|
77
|
+
|
|
78
|
+
| 消费者 | 行为 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| 绘制 | 每个 op 携带矩阵(见[绘制](./rendering.md#绘制与显示列表m4am4b));被裁剪的子树按它的内边距盒经矩阵变换后的包围盒裁剪 |
|
|
81
|
+
| 命中测试 | `hitTestBox` 先把点经每个盒的逆矩阵映射,再做包含判断,所以旋转或缩放的元素在它**被画出来**的位置可点击 |
|
|
82
|
+
| `getBoundingClientRect` | **变换后**边框盒的轴对齐包围盒(`xt_layout_transformed_bounds`) |
|
|
83
|
+
| 布局几何 | 不变——`layoutTree()` 与 `offsetWidth`/`offsetHeight` 仍报告未变换的盒子 |
|
|
84
|
+
|
|
85
|
+
不支持的变换函数(`skew`、`perspective` 等)会让整条声明失效,因此一个盒子
|
|
86
|
+
要么被正确变换、要么完全不变换,而不是只应用了一部分。
|
|
87
|
+
|
|
57
88
|
**Document**(`runtime/ext_gui/document.{h,cpp}`):持有 DOM 树,把 `<style>`
|
|
58
89
|
文本汇总为一份样式表,为某个视口计算样式与布局,并提供
|
|
59
90
|
`querySelector`/`querySelectorAll`/`styleOf`/`boxOf`。
|
|
@@ -47,6 +47,17 @@
|
|
|
47
47
|
- 只有在文档或视口变化(`geometry.dirty`)时才上传几何数据,因此稳态帧
|
|
48
48
|
只需绑定并绘制。
|
|
49
49
|
|
|
50
|
+
每个 op 还携带它来自的那个盒子的 `Matrix2D`(`runtime/ext_gui/transform.h`、
|
|
51
|
+
`PaintRect::transform` 等)。它在构建顶点缓冲时应用,而不是在着色器里:
|
|
52
|
+
`pushRect` 把四个角经矩阵映射(距离场的 `local`/半尺寸/半径字段仍留在**盒子**
|
|
53
|
+
坐标系,因此圆角旋转后依然是圆的),`pushQuad`/`pushGlyph` 同样映射字形或图像
|
|
54
|
+
四边形。这样 MSL/SPIR-V/DXIL 着色器与管线都无需改动——一次变换的代价只是每个
|
|
55
|
+
顶点几次乘法,与像素数无关。被变换盒子的裁剪矩形取其内边距盒经变换后的包围盒,
|
|
56
|
+
因为 GPU 的 scissor 是轴对齐的。文本是唯一需要多于“乘一下四个角”的情况:
|
|
57
|
+
缩放型的变换会放大图集中的位图,因此向图集请求字形时用的是设备缩放**乘以矩阵的
|
|
58
|
+
放大倍率**(限制在 0.5–4 倍之间,图集容量有限),再把四边形除回逻辑单位——
|
|
59
|
+
这正是 HiDPI 缩放原本就在用的做法。
|
|
60
|
+
|
|
50
61
|
窗口背景(`setBackground`)是渲染通道的清除色。
|
|
51
62
|
|
|
52
63
|
M4 仍需完成:渐变。
|
package/doc/zh-CN/gui.md
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
> 语言 / Language:[English](../gui.md) | **简体中文**
|
|
4
4
|
|
|
5
|
-
状态:**
|
|
5
|
+
状态:**M15** —— 功能(M1–M14)已全部完成:HTML 解析、CSS 选择器匹配、层叠(cascade)、计算样式与布局(块级、行内、Flexbox 与 CSS 定位)均已就位,引擎还会**绘制**:它构建一个由矩形、图像与排版后的文本 run 组成的显示列表,并通过 SDL_GPU 渲染。输入事件会经过命中测试并投递给原生 TS 处理器,`:hover`/`:focus` 会被动态匹配,`<img>` 依据其固有尺寸确定大小并从纹理绘制——位图(PNG/JPEG/…)与 SVG 文件皆可,后者按绘制尺寸光栅化,因此矢量图保持清晰——CSS transition 会为绘制属性做动画。**M8** 增加了交互式 DOM:具有稳定标识的元素句柄、变更操作(`appendChild`、`textContent`、`classList`、`style` 等)以及支持捕获/冒泡的元素级事件。**M9** 会提前编译 `<script>` 主体(内联与 `<script src>`)——参见 `gui-scripts.md`。**M10** 增加 `requestAnimationFrame` 以及若干 DOM 辅助方法。**M11** 增加 `position: relative`/`absolute`/`fixed` 及其偏移,`examples/gui/pelican-bike`(一个可玩的 2D 游戏)就构建在它之上。**M12** 明确了 DOM 节点生命周期(哪些变更释放、哪些保留),并让引擎内存有界:参见[节点生命周期](./gui/dom.md)与[内存与 GC](./gui/runtime.md)。**M13** 真正播放
|
|
6
6
|
`<video>`/`<audio>`——一个 vendored 的最小 FFmpeg 在主线程解码,视频帧走图像
|
|
7
7
|
纹理路径、音频进入 SDL 流,DOM 媒体 API 暴露 `play`/`pause`/`currentTime`/…
|
|
8
8
|
与媒体事件。**M14** 增加了 `<canvas>`,配一个自研的 2D 软件光栅器(抗锯齿
|
|
9
9
|
填充、路径、文本与 `drawImage`),并经图像纹理路径上传——参见
|
|
10
|
-
[Canvas](./gui/canvas.md)
|
|
10
|
+
[Canvas](./gui/canvas.md)。**M15** 增加了 CSS `transform` /
|
|
11
|
+
`transform-origin`:每个布局盒一个合成好的 `Matrix2D`,由显示列表一路带到
|
|
12
|
+
渲染器,因此盒子(以及其中的文本、图像与子元素)可以被平移、缩放与旋转而
|
|
13
|
+
不触发任何重排——再加上 `transition: transform`,这些姿态可以动画(自绘的示例
|
|
14
|
+
`examples/gui/pelican-svg` 正是用它让矢量画动起来)。参见
|
|
15
|
+
[布局](./gui/layout.md#变换m15)与[动画](./gui/animation.md#css-transformm15)。本总览记录了锁定决策、架构、里程碑计划与当前进度;引擎本身按功能拆分在以上各页中。
|
|
11
16
|
|
|
12
17
|
## 目录
|
|
13
18
|
|
|
@@ -18,7 +23,7 @@
|
|
|
18
23
|
- [媒体](./gui/media.md) —— 图像、SVG、视频与音频
|
|
19
24
|
- [Canvas](./gui/canvas.md) —— `<canvas>` 与 2D 上下文
|
|
20
25
|
- [输入](./gui/input.md) —— 命中测试、事件与 `:hover`/`:focus`
|
|
21
|
-
- [动画](./gui/animation.md) —— `requestAnimationFrame
|
|
26
|
+
- [动画](./gui/animation.md) —— `requestAnimationFrame`、CSS transition 与 transform
|
|
22
27
|
- [运行时集成](./gui/runtime.md) —— 事件循环、原生桥接与内存
|
|
23
28
|
- [打包与构建](./gui/build.md) —— 构建 `gui.a` 与运行示例
|
|
24
29
|
- [已知问题与待决问题](./gui/known-issues.md)
|
|
@@ -197,6 +202,15 @@ FFmpeg `7.1`(可用 `SDL3_TAG` / `FREETYPE_VERSION` / `HARFBUZZ_VERSION` /
|
|
|
197
202
|
位图经图像路径上传为 GPU 纹理(`renderer_image.cpp`),显示列表携带
|
|
198
203
|
`canvas_id`(`paint.*`)。参见 [Canvas](./gui/canvas.md);e2e 见
|
|
199
204
|
`tests/e2e/gui-canvas.test.ts`。
|
|
205
|
+
15. **M15 — CSS `transform`** ✅
|
|
206
|
+
- `transform`/`transform-origin` 解析为 `TransformOp` 列表
|
|
207
|
+
(`transform.{h,cpp}`、`style.*`),和其他绘制属性一样参与 transition
|
|
208
|
+
(`document.*`),并在布局之后合成为每个盒子的 `world` 矩阵及其逆矩阵
|
|
209
|
+
(`layout.*`)。绘制把矩阵挂在每个 op 上,渲染器按矩阵映射四边形顶点,
|
|
210
|
+
因此着色器无需改动。命中测试与 `getBoundingClientRect` 同样跟随。参见
|
|
211
|
+
[布局](./gui/layout.md#变换m15)与[动画](./gui/animation.md#css-transformm15);
|
|
212
|
+
e2e 见 `tests/e2e/gui-transform.test.ts` 与
|
|
213
|
+
`tests/e2e/gui-example-svg.test.ts`。
|
|
200
214
|
|
|
201
215
|
## 进度日志
|
|
202
216
|
|
|
@@ -273,4 +287,15 @@ FFmpeg `7.1`(可用 `SDL3_TAG` / `FREETYPE_VERSION` / `HARFBUZZ_VERSION` /
|
|
|
273
287
|
图像纹理路径上传(`renderer_image.cpp`),显示列表携带 `canvas_id`
|
|
274
288
|
(`paint.*`)。参见 [Canvas](./gui/canvas.md);e2e 见
|
|
275
289
|
`tests/e2e/gui-canvas.test.ts`。
|
|
290
|
+
- **M15** ✅ CSS `transform` / `transform-origin`。新的翻译单元
|
|
291
|
+
(`transform.{h,cpp}`)把 `translate`/`translateX`/`translateY`/`scale`/
|
|
292
|
+
`scaleX`/`scaleY`/`rotate`/`matrix`(以及 `translate3d`/`scale3d`,其 `z` 参数被丢弃)
|
|
293
|
+
解析为 `Matrix2D` 列表,经 `computedStyle` 原样报告,并为 transition 插值
|
|
294
|
+
(形状或单位变化则吸附)。布局在常规遍历之后为每个盒子合成 `world` 矩阵与
|
|
295
|
+
逆矩阵(`applyTransforms`),`transform-origin` 按边框盒解析——所以布局几何
|
|
296
|
+
与流式排布永不改变。绘制把矩阵挂到每个形状/文本/图像 op 上,渲染器按矩阵
|
|
297
|
+
映射四边形顶点(不改着色器、不加 uniform);命中测试把点经逆矩阵映射,
|
|
298
|
+
`getBoundingClientRect` 返回变换后的包围盒。`examples/gui/pelican-svg` 用它
|
|
299
|
+
为自己的画做动画;e2e 见 `tests/e2e/gui-transform.test.ts` 与
|
|
300
|
+
`tests/e2e/gui-example-svg.test.ts`。
|
|
276
301
|
|
package/doc/zh-CN/implemented.md
CHANGED
|
@@ -233,7 +233,7 @@ xt_value fn(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
|
233
233
|
|
|
234
234
|
- 分配器:`xt_alloc` 背后的非移动标记-清扫回收器(显式根、子系统根提供者与保守 C 栈扫描)。
|
|
235
235
|
- 值构造:`xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`。
|
|
236
|
-
- 字符串:UTF-8
|
|
236
|
+
- 字符串:UTF-8 存储、惰性 cons 节点拼接(首次观察时才扁平化,因此循环追加保持线性复杂度)、相等比较、格式化数字转字符串。
|
|
237
237
|
- 类型转换:`xt_truthy`、`xt_to_number`、`xt_to_string`、`xt_typeof`。
|
|
238
238
|
- 算术:`add/sub/mul/div/mod/pow/neg/pos`。
|
|
239
239
|
- 位运算:`and/or/xor/not/shl/shr/ushr`(含 `ToInt32` 语义)。
|
|
@@ -247,7 +247,7 @@ xt_value fn(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv);
|
|
|
247
247
|
- 运算符辅助:`xt_in`(`in`)、`xt_delete`(`delete`)、`xt_rest_args`(剩余参数 / `arguments`)。
|
|
248
248
|
- Box:`box_new/get/set`(用于闭包捕获变量)。
|
|
249
249
|
- 函数与闭包:`arg`、`closure_new/call/env/arity`。
|
|
250
|
-
- 异常:`xt_try_enter` / `xt_try_exception` / `xt_try_leave` 维护 `_setjmp` 帧栈;`xt_throw` 在存在帧时长跳到最近 `try`,否则打印 `Uncaught ...` 后退出。
|
|
250
|
+
- 异常:`xt_try_enter` / `xt_try_exception` / `xt_try_leave` 维护 `_setjmp` 帧栈;`xt_throw` 在存在帧时长跳到最近 `try`,否则打印 `Uncaught ...` 后退出。codegen 还会维护一条影子调用栈(函数名、源文件、行号):`Error.stack` 用它生成堆栈,原生崩溃时致命信号处理器也会打印同一组帧。`--debug` 还会生成 `!DICompileUnit` / `!DISubprogram` / `!DILocation` 元数据,并用 `-g -fno-omit-frame-pointer` 编译,因此 gdb/lldb/WinDbg 可以把指令映射回源码行。
|
|
251
251
|
- 输出:`xt_print/xt_println/xt_console_log/info/warn/error`(Node 风格 inspect:数组 `[ a, b ]`、对象 `{ k: v }`;`info`/`log` 到 stdout,`warn`/`error` 到 stderr),以及 `dir/trace/assert/count/countReset/group/groupEnd/table/time/timeEnd/timeLog`。
|
|
252
252
|
- 对象 / 函数:`xt_object` 带原型链,`xt_function` 带属性包(静态成员与 `prototype`);`xt_new`(实例化)、`xt_instance_of`(原型链)、`xt_object_freeze/is_frozen/from_entries`。
|
|
253
253
|
- 标准库扩展(`xt_stdlib2.c`):数组 / 字符串 / 数字 / 对象的扩展方法;`Object` / `Array` / `Number` / `String` 静态方法;`JSON.parse` / `JSON.stringify`;`Map` / `Set`;`Date`(`gmtime_r`);`RegExp`(POSIX ERE `regcomp`/`regexec` 的 `test`/`exec`)。
|
|
@@ -338,7 +338,7 @@ const result = build("program.ts", { emit: "exe", outDir: "build" });
|
|
|
338
338
|
实现位置:`tests/`(`lexer` / `parser` / `binder` / `codegen` / `driver` / `extensions` / `cli` / `e2e`)
|
|
339
339
|
|
|
340
340
|
- 各模块单元测试;e2e 在存在 `clang` 时真正编译并运行二进制,否则自动跳过。
|
|
341
|
-
- e2e 覆盖:算术与打印、递归函数、循环 / 数组 / 字符串拼接、闭包按引用捕获、对象 / 数组 JS 风格打印、Node `fs` 扩展(经 `import`)、`switch` 穿透、数组 / 字符串方法、`Math` 与全局函数与 `console` 各等级、默认 / 剩余参数与 `arguments`、`Object` 助手与展开与 `in`/`delete`、`for...in` 对象键枚举、`try/catch/finally`、可选链、类与 `new`/`this`/`static`/`extends`/`super`/`instanceof`、`async`/`await` 与 `Promise`、`Map`/`Set`/`JSON` 与扩展标准库、`Map`/`Set` 的 `for...of`、数组 `length` 赋值与可迭代展开、多文件 `import`/`export`、类型化数组(元素强制转换、`from`/`of
|
|
341
|
+
- e2e 覆盖:算术与打印、递归函数、循环 / 数组 / 字符串拼接、闭包按引用捕获、对象 / 数组 JS 风格打印、Node `fs` 扩展(经 `import`)、`switch` 穿透、数组 / 字符串方法、`Math` 与全局函数与 `console` 各等级、默认 / 剩余参数与 `arguments`、`Object` 助手与展开与 `in`/`delete`、`for...in` 对象键枚举、`try/catch/finally`、可选链、类与 `new`/`this`/`static`/`extends`/`super`/`instanceof`、`async`/`await` 与 `Promise`、`Map`/`Set`/`JSON` 与扩展标准库、`Map`/`Set` 的 `for...of`、数组 `length` 赋值与可迭代展开、多文件 `import`/`export`、类型化数组(元素强制转换、`from`/`of`、迭代与原型方法)、对象 rest 解构与内建 `instanceof`,以及全局 `fetch`(HTTP GET/POST、请求头、重定向、JSON/文本/二进制响应体与 `TypeError` 拒绝)。
|
|
342
342
|
|
|
343
343
|
---
|
|
344
344
|
|
|
@@ -358,7 +358,7 @@ const result = build("program.ts", { emit: "exe", outDir: "build" });
|
|
|
358
358
|
| 值模型 | 64 位 NaN-boxing、统一函数 ABI(含 `this`)、闭包环境、对象原型链 |
|
|
359
359
|
| 运行时 | 字符串 / 对象 / 数组 / 类型化数组 / 闭包 / 算术 / 比较 / 可捕获异常 / Promise / 集合 / symbol / 生成器 / `fetch` / `console` |
|
|
360
360
|
| 扩展 | 扩展注册表、`core`(print)、`node`(fs / path / os / process / buffer / stream / net / dgram / http,按说明符导入) |
|
|
361
|
-
| GUI(`gui` 扩展) | 自托管 HTML/CSS 渲染器窗口(SDL3 + SDL_GPU):DOM/CSS
|
|
361
|
+
| GUI(`gui` 扩展) | 自托管 HTML/CSS 渲染器窗口(SDL3 + SDL_GPU):DOM/CSS/布局、CSS `transform`/`transform-origin`、`<img>`/SVG、`<video>`/`<audio>`、`<canvas>` 2D、事件、transition(含 `transform`) |
|
|
362
362
|
| 工具链 | clang 编译 IR/C、链接、增量缓存 |
|
|
363
363
|
| 项目配置 | `xbintsc.config.json`(`entry` / `outDir` / `optimize` / `extensions` / `app`),支持查找与 CLI 优先级 |
|
|
364
364
|
| 应用图标 | 编译期内嵌(PNG/ICO/ICNS),Windows PE 资源、macOS `.app` bundle、`gui` 运行时窗口/Dock 图标 |
|
|
@@ -19,9 +19,18 @@ build/app.ll:382:37: error: '@.str.0' defined with type '[6 x i8]*' but expected
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
有类型指针在 LLVM 16 中被移除([发布说明](https://github.com/llvm/llvm-project/blob/release/15.x/llvm/docs/ReleaseNotes.rst#changes-to-the-llvm-ir)),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
所以 xbintsc 现在**在编译任何东西之前先检查版本**:
|
|
23
|
+
|
|
24
|
+
- `xbintsc build` / `run` 一旦发现解析到的驱动低于 16 就立即停止,并给出可操作的错误,
|
|
25
|
+
而不是生成无法编译的 IR。
|
|
26
|
+
- `xbintsc doctor` 会打印 `status : ok` 或 `status : too old`,在工具链无法构建二进制时
|
|
27
|
+
以非零码退出,脚本和 CI 可以把它当作预检。
|
|
28
|
+
- 搜索时会优先选择 16+ 的 clang:Windows 上即使 `PATH` 里靠前的是旧 clang,
|
|
29
|
+
也能找到 Visual Studio 自带的 LLVM
|
|
30
|
+
(`<VS 安装目录>\VC\Tools\Llvm\x64\bin\clang.exe`)。可以用 `xbintsc_CLANG` 覆盖;
|
|
31
|
+
显式指定的旧版本会得到 "too old" 错误,而不是被静默忽略。
|
|
32
|
+
|
|
33
|
+
把 IR 拿到别处编译来绕过该限制是不受支持的。
|
|
25
34
|
|
|
26
35
|
## 总览
|
|
27
36
|
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
|
|
41
41
|
> 标记模板已实现,含 raw 字符串与 `String.raw`。生成器(`function*`、`yield`、`yield*`)
|
|
42
42
|
> 基于有栈协程实现,支持 `next`/`throw`/`return`、`for...of`、展开与委托;
|
|
43
|
-
> `import.meta`
|
|
43
|
+
> `import.meta` 提供 `url`、`dirname`、`filename`,由正在运行的可执行文件路径解析。
|
|
44
|
+
> `async function*` 现在会以 `UnsupportedFeature` **明确拒绝**,不再静默产出同步生成器。
|
|
44
45
|
|
|
45
46
|
### 2.2 解析器不支持
|
|
46
47
|
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
|
|
51
52
|
| 运算符 | 现状 | 说明 |
|
|
52
53
|
| --- | --- | --- |
|
|
53
|
-
| `new.target` | ✗ |
|
|
54
|
+
| `new.target` | ✗ | 已解析,但以 `UnsupportedFeature` 明确拒绝(无 `new.target` 语义) |
|
|
54
55
|
| `typeof` / `void` / `in` / `delete` / `instanceof` | ✓ | 映射到运行时辅助函数(`xt_typeof`、`xt_in`、`xt_delete`、`xt_instance_of`) |
|
|
55
56
|
|
|
56
57
|
---
|
|
@@ -103,7 +104,7 @@
|
|
|
103
104
|
| `keys` / `values` / `entries` | ~ 返回数组,而非迭代器对象 |
|
|
104
105
|
| `ArrayBuffer` / `DataView` / `.buffer` / `.byteOffset` 语义 | ✗ 无底层缓冲区类型;`.byteOffset` 恒为 0 |
|
|
105
106
|
| `BigInt64Array` / `BigUint64Array` | ✗ 未实现 |
|
|
106
|
-
| `instanceof
|
|
107
|
+
| `instanceof` 内建构造器 | ✓ `instanceof Array` / `Object` / `Map` / `Set` / `Date` / `RegExp` / `Promise` / `Error` 家族 / 类型化数组都能按名字识别;但构造器本身仍不是一等公民值(`const A = Array` 仍会失败) |
|
|
107
108
|
| 基于 `Buffer` / `ArrayBuffer` 的类型化数组视图 | ✗ 构造器仅能从长度 / 数组样 / 类型化数组复制 |
|
|
108
109
|
|
|
109
110
|
---
|
|
@@ -137,8 +138,8 @@
|
|
|
137
138
|
| `arguments` 对象 | ✓(隐式) | ✓ 已实现(箭头函数取的是自身参数,而非外层函数的 `arguments`,与 JS 不同) |
|
|
138
139
|
| `this` 绑定 / 方法调用语义 | ✓ | ✓ 已实现(`this` 作为函数首个 ABI 参数线程化;箭头函数词法继承) |
|
|
139
140
|
| `async` / `await` / Promise | ✓ | ✓ 已实现(同步微任务模型) |
|
|
140
|
-
| `new.target` | ✗ |
|
|
141
|
-
| 生成器 / 迭代器 / `yield` | ✓ 已实现 | `function*`、`yield`、`yield*`、`.next/.throw/.return
|
|
141
|
+
| `new.target` | ✗ | 已解析,但以 `UnsupportedFeature` 明确拒绝(无 `new.target` 语义) |
|
|
142
|
+
| 生成器 / 迭代器 / `yield` | ✓ 已实现 | `function*`、`yield`、`yield*`、`.next/.throw/.return`;异步生成器以 `UnsupportedFeature` 拒绝 |
|
|
142
143
|
| 闭包 `arity` | — | `xt_closure_arity` 恒为 -1,未填充 |
|
|
143
144
|
| `fn.call` / `fn.apply` / `fn.bind` | ✓ | ✓ 已实现(绑定闭包不跟踪部分参数的 `length`) |
|
|
144
145
|
| `fn.name` / `fn.length` | ✓ | ✓ 已实现(从声明 / 赋值 / 属性键推断;绑定函数为 `"bound ..."` 并调整 arity) |
|
|
@@ -199,9 +200,9 @@
|
|
|
199
200
|
| 函数 `arity` / 调用参数个数 | 无参数个数校验;`fn.length` 报告声明的 arity,但调用不做校验 |
|
|
200
201
|
| `async` / `await` | **同步微任务模型**:`await` 在已 settle 的 promise 上同步继续。定时器与套接字仅在程序主体执行完后由事件循环运行,因此无法等待由定时器回调 settle 的 promise |
|
|
201
202
|
| `super` | `super.x` / `super(...)` 取 `this` 原型的原型;单级继承正确,继承深度 > 1 时可能不准确 |
|
|
202
|
-
| `Error.stack` |
|
|
203
|
+
| `Error.stack` | 仅函数级帧:每帧为 `at 名称 (文件:行)`,行号取自函数声明(最内层帧会更新为错误构造处);没有列号,生成器函数体不产生帧(它们会切换栈) |
|
|
203
204
|
| 模块实时绑定 | 命名空间导入与导入绑定为快照(见第 4 节) |
|
|
204
|
-
| `import.meta` |
|
|
205
|
+
| `import.meta` | ✓ `import.meta.url` / `.dirname` / `.filename`,由可执行文件路径解析 |
|
|
205
206
|
|
|
206
207
|
> 数字格式化、宽松相等、`+` / 关系运算 `ToPrimitive`、整链可选链、`finally` 提前退出、对象键顺序等均已对齐 Node,并由差分测试覆盖,故不再列为偏差。
|
|
207
208
|
|
|
@@ -227,9 +228,9 @@
|
|
|
227
228
|
```
|
|
228
229
|
未实现(语句):namespace/module 声明
|
|
229
230
|
|
|
230
|
-
未实现(表达式):new.target
|
|
231
|
+
未实现(表达式):new.target(会给出明确的 UnsupportedFeature)
|
|
231
232
|
|
|
232
|
-
未实现(函数):`fn.toString()`
|
|
233
|
+
未实现(函数):`fn.toString()` 源码文本、异步生成器(已明确拒绝)
|
|
233
234
|
|
|
234
235
|
未实现(类/面向对象):abstract/implements、访问控制、父子类 #x 同名
|
|
235
236
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xbintsc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.87",
|
|
4
4
|
"description": "xbintsc - a TypeScript binary compiler (TypeScript -> LLVM IR -> native binary)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"runtime:clean": "node -e \"require('fs').rmSync('build/runtime-obj',{recursive:true,force:true});require('fs').rmSync('runtime/lib',{recursive:true,force:true})\"",
|
|
42
42
|
"xbintsc": "tsx src/cli/main.ts",
|
|
43
43
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
44
|
+
"check:version": "tsx scripts/check-version.ts",
|
|
45
|
+
"bench": "tsx scripts/bench.ts",
|
|
44
46
|
"lint": "eslint . && tsx scripts/check-file-length.ts",
|
|
45
47
|
"test": "vitest run",
|
|
46
48
|
"test:watch": "vitest",
|