xbintsc 0.3.35 → 0.3.49
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 +95 -0
- package/README.md +31 -3
- package/README.zh-CN.md +23 -0
- package/dist/src/cli/hints.d.ts +54 -0
- package/dist/src/cli/hints.js +165 -0
- package/dist/src/cli/hints.js.map +1 -0
- package/dist/src/cli/main.js +73 -9
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/module.js +10 -0
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.js +4 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +26 -0
- package/dist/src/codegen/generator/tables.js +64 -12
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +22 -0
- package/dist/src/diagnostics/source-text.js +76 -0
- package/dist/src/diagnostics/source-text.js.map +1 -0
- package/dist/src/driver/bundler/graph.js +2 -1
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/compiler.js +3 -2
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/lexer/scanner/strings.js +16 -3
- package/dist/src/lexer/scanner/strings.js.map +1 -1
- package/dist/tests/cli/hints.test.d.ts +9 -0
- package/dist/tests/cli/hints.test.js +143 -0
- package/dist/tests/cli/hints.test.js.map +1 -0
- package/dist/tests/cli/main.test.js +6 -4
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +17 -2
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/e2e/gc.test.d.ts +1 -0
- package/dist/tests/e2e/gc.test.js +168 -0
- package/dist/tests/e2e/gc.test.js.map +1 -0
- package/dist/tests/e2e/harness.d.ts +2 -0
- package/dist/tests/e2e/harness.js +1 -0
- package/dist/tests/e2e/harness.js.map +1 -1
- package/dist/tests/helpers.js +3 -2
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/lexer/strings.test.js +14 -2
- package/dist/tests/lexer/strings.test.js.map +1 -1
- package/doc/DESIGN.md +117 -0
- package/doc/ai/README.md +63 -0
- package/doc/ai/build-recipe.md +137 -0
- package/doc/ai/cli.md +142 -0
- package/doc/ai/contributing.md +196 -0
- package/doc/ai/extensions.md +148 -0
- package/doc/ai/language-support.md +152 -0
- package/doc/ai/troubleshooting.md +163 -0
- package/doc/ai/zh-CN/README.md +56 -0
- package/doc/ai/zh-CN/build-recipe.md +132 -0
- package/doc/ai/zh-CN/cli.md +127 -0
- package/doc/ai/zh-CN/contributing.md +173 -0
- package/doc/ai/zh-CN/extensions.md +139 -0
- package/doc/ai/zh-CN/language-support.md +147 -0
- package/doc/ai/zh-CN/troubleshooting.md +150 -0
- package/doc/gui-scripts.md +350 -0
- package/doc/gui.md +646 -0
- package/doc/icon.md +265 -0
- package/doc/implemented.md +373 -0
- package/doc/node-implemented.md +588 -0
- package/doc/node-unimplemented.md +167 -0
- package/doc/post/announce.md +43 -0
- package/doc/requirements.md +145 -0
- package/doc/unimplemented.md +286 -0
- package/doc/xbintsc.config.schema.json +67 -0
- package/doc/zh-CN/DESIGN.md +104 -0
- package/doc/zh-CN/gui-scripts.md +329 -0
- package/doc/zh-CN/gui.md +588 -0
- package/doc/zh-CN/icon.md +241 -0
- package/doc/zh-CN/implemented.md +365 -0
- package/doc/zh-CN/node-implemented.md +533 -0
- package/doc/zh-CN/node-unimplemented.md +141 -0
- package/doc/zh-CN/plan-require-node-modules.md +284 -0
- package/doc/zh-CN/post/announce.md +47 -0
- package/doc/zh-CN/requirements.md +134 -0
- package/doc/zh-CN/unimplemented.md +247 -0
- package/llms.txt +45 -0
- package/package.json +6 -2
- package/runtime/ext_gui/dom_api_proto.cpp +5 -0
- package/runtime/ext_gui/gui.cpp +3 -1
- package/runtime/ext_gui/renderer.cpp +13 -11
- package/runtime/ext_gui/renderer_image.cpp +12 -8
- package/runtime/ext_gui/renderer_shaders.h +131 -4
- package/runtime/ext_gui/renderer_shaders_data.h +1809 -0
- package/runtime/ext_gui/renderer_text.cpp +12 -8
- package/runtime/ext_gui/shaders.hlsl +98 -0
- package/runtime/ext_gui/spirv/fill.frag +19 -0
- package/runtime/ext_gui/spirv/fill.vert +42 -0
- package/runtime/ext_gui/spirv/image.frag +16 -0
- package/runtime/ext_gui/spirv/quad.vert +30 -0
- package/runtime/ext_gui/spirv/text.frag +16 -0
- package/runtime/ext_gui/window.cpp +1 -0
- package/runtime/ext_node/buffer/parts/prototype.inc +1 -0
- package/runtime/ext_node/dgram/dgram.c +1 -0
- package/runtime/ext_node/events/events.c +1 -0
- package/runtime/ext_node/fs/fs_ops.c +10 -25
- package/runtime/ext_node/fs/glob.c +13 -30
- package/runtime/ext_node/fs/promises.c +1 -0
- package/runtime/ext_node/http/parts/prototypes.inc +5 -0
- package/runtime/ext_node/net/parts/prototypes.inc +2 -0
- package/runtime/ext_node/process/process.c +9 -7
- package/runtime/ext_node/stream/stream.c +1 -0
- package/runtime/ext_node/util/util.c +6 -6
- package/runtime/rt.h +10 -0
- package/runtime/rt_internal.h +63 -2
- package/runtime/xt_alloc.c +442 -5
- package/runtime/xt_generator.c +95 -1
- package/runtime/xt_loop.c +35 -1
- package/runtime/xt_promise.c +46 -0
- package/runtime/xt_stdlib2/error.inc +1 -0
- package/runtime/xt_stdlib2/regexp-match.inc +8 -7
- package/runtime/xt_symbol.c +2 -0
- package/runtime/xt_typed_array/construction.inc +142 -0
- package/runtime/xt_typed_array/elements.inc +92 -0
- package/runtime/xt_typed_array/methods.inc +329 -0
- package/runtime/xt_typed_array.c +6 -548
- package/runtime/xt_values/number-format.inc +26 -0
- package/scripts/build-gui-shaders.mjs +204 -0
- package/scripts/build-gui.ts +35 -0
- package/scripts/check-file-length.ts +89 -0
- package/src/cli/hints.ts +194 -0
- package/src/cli/main.ts +82 -9
- package/src/codegen/generator/module.ts +10 -0
- package/src/codegen/generator/state.ts +4 -0
- package/src/codegen/generator/tables.ts +60 -14
- package/src/diagnostics/source-text.ts +78 -0
- package/src/driver/bundler/graph.ts +2 -1
- package/src/driver/compiler.ts +3 -2
- package/src/lexer/scanner/strings.ts +16 -3
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# xbintsc Node Extension Unimplemented Features
|
|
2
|
+
|
|
3
|
+
This document was compiled by checking the Node extension source
|
|
4
|
+
(`src/extensions/node/`) and the C runtime (`runtime/ext_node/`) file by file,
|
|
5
|
+
and lists the features that the **Node extension currently does not implement /
|
|
6
|
+
is missing**.
|
|
7
|
+
|
|
8
|
+
> Related documents:
|
|
9
|
+
> - Core language capabilities: [implemented.md](./implemented.md) / [unimplemented.md](./unimplemented.md)
|
|
10
|
+
> - Implemented parts of the Node extension: [node-implemented.md](./node-implemented.md)
|
|
11
|
+
|
|
12
|
+
> Language: **English** | [简体中文](./zh-CN/node-unimplemented.md)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Unimplemented in the `fs` module
|
|
17
|
+
|
|
18
|
+
`fs` now implements the **synchronous** API surface (files, directories,
|
|
19
|
+
descriptors, metadata, links, `cp`, `glob`, `Dir`, `constants`) and
|
|
20
|
+
`fs/promises` wraps each synchronous function in an already-settled Promise
|
|
21
|
+
(see [node-implemented.md](./node-implemented.md)). The rest is still
|
|
22
|
+
unimplemented because xbintsc has **no asynchronous I/O scheduler** for file
|
|
23
|
+
operations (the `fs` module has no reactor backend; the core event loop does
|
|
24
|
+
provide timers and sockets):
|
|
25
|
+
|
|
26
|
+
| Unimplemented API | Category |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `readFile` / `writeFile` / `appendFile` / `open` / `close` / `read` / `write` / `stat` / … | callback-style async file operations (`fs/promises` provides the Promise forms) |
|
|
29
|
+
| `createReadStream` / `createWriteStream` | streaming read/write |
|
|
30
|
+
| `watch` / `watchFile` | **real** file watching: the functions exist but the returned objects never emit (there is no inotify/kqueue backend) |
|
|
31
|
+
| `openAsBlob`, `statfs` callback form, `rmdir` `maxRetries` / `retryDelay` | misc. options requiring async retry |
|
|
32
|
+
| `glob` `exclude` / `follow`, `cp` `filter` | option callbacks |
|
|
33
|
+
|
|
34
|
+
### 1.1 Read semantics gaps
|
|
35
|
+
|
|
36
|
+
- `readFileSync` supports encoding options (default/`utf8`/`ascii`/`latin1`/`binary`/ `hex`/`base64`/`base64url`), but **does not return a `Buffer`** by default: even though `Buffer` exists (simulated as a plain object), `readFileSync` still returns a string. Pass a `Buffer`-producing path or read raw bytes explicitly.
|
|
37
|
+
- `utf16le` / `ucs2` decoding is not implemented (the bytes are returned as text).
|
|
38
|
+
- `watch` / `watchFile` / `unwatchFile` return API-shaped emitter objects whose `.close()` / `.on()` methods exist but which **never fire** events.
|
|
39
|
+
- `Dir.read(cb)` / `Dir.close(cb)` and the async form of `FileHandle` methods complete **synchronously** (the callback/Promise is invoked immediately).
|
|
40
|
+
- `mkdtempSync` always appends 6 random characters to the prefix (it does not require a trailing `XXXXXX`).
|
|
41
|
+
- `globSync` supports `*`, `?`, `[...]` and `**` but not the `exclude` callback or `follow`; `**` does not descend through symlinks (matching Node's default).
|
|
42
|
+
- `cpSync` symlink handling follows Node for the common cases but `verbatimSymlinks` is not supported.
|
|
43
|
+
- Platform deviations: on Windows `readlinkSync` raises `ENOSYS` and `chmodSync` / `lchmodSync` / `chownSync` / `lchownSync` / `fchmodSync` / `fchownSync` are no-ops; `statfsSync` returns zeroed fields on Windows/AIX/Sun; `lutimesSync` falls back to `utimesSync` on macOS/Windows.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 2. Other Node modules fully unimplemented
|
|
48
|
+
|
|
49
|
+
The following Node built-in modules have no corresponding extension / builtin
|
|
50
|
+
(`fs` / `fs/promises` / `path` / `os` / `process` / `buffer` / `stream` /
|
|
51
|
+
`dgram` / `http` / `events` / `util` / `querystring` / `assert` / `test` are
|
|
52
|
+
implemented, and `crypto` / `url` / `child_process` / `zlib` /
|
|
53
|
+
`stream/promises` / `worker_threads` are partially implemented; see
|
|
54
|
+
[node-implemented.md](./node-implemented.md)):
|
|
55
|
+
|
|
56
|
+
| Module | Notes |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `https` | TLS version of HTTP |
|
|
59
|
+
| `readline` | command-line reading |
|
|
60
|
+
| `tls` / `cluster` / `vm` / `os` (partially) etc. | other modules not listed |
|
|
61
|
+
|
|
62
|
+
> `crypto` (only `createHash`, now with the streaming API), `url` (only
|
|
63
|
+
> `pathToFileURL` / `fileURLToPath`), `child_process` (only `spawnSync`),
|
|
64
|
+
> `zlib` (only `createGzip`) and `worker_threads` (only `Worker` /
|
|
65
|
+
> `isMainThread` / `workerData` / `parentPort`) are partially implemented.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 3. Node global objects / namespaces
|
|
70
|
+
|
|
71
|
+
| Unimplemented | Notes |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| `global` / `globalThis` | none |
|
|
74
|
+
| `__dirname` / `__filename` | none |
|
|
75
|
+
| `require` / `module` / `exports` | only inside `node_modules` packages (the bundler lowers them); user code must use ESM `import` |
|
|
76
|
+
| `fs.readFileSync(...)` without an `import` | ✗ unsupported. `fs` is not a global; import it first (`import fs from "fs"` or `import * as fs from "node:fs"`) and `fs.readFileSync(...)` lowers to the module's runtime symbol. |
|
|
77
|
+
|
|
78
|
+
Node modules are reached through `import` with a bare or `node:`-prefixed
|
|
79
|
+
specifier (`import { readFileSync } from "fs"`, `import path from "path"`,
|
|
80
|
+
`import { platform } from "node:os"`). Named and namespace imports both resolve
|
|
81
|
+
to the extension module's runtime entries.
|
|
82
|
+
|
|
83
|
+
Supported namespace calls: `path.*`, `os.*`, `process.*`, `fs.*`,
|
|
84
|
+
`fs/promises.*` (methods), `child_process.*`, `crypto.*`, `url.*` once imported
|
|
85
|
+
(a namespace/default import or, for `path`/`os`/`process`, the global name),
|
|
86
|
+
plus the dispatcher-backed namespaces `Buffer.*`, `stream.*`, `net.*`,
|
|
87
|
+
`dgram.*`, `http.*` and properties such as `process.platform` /
|
|
88
|
+
`process.argv`. `Readable` / `Writable` / `Duplex` / `Transform` / `PassThrough`
|
|
89
|
+
/ `Buffer` can also be used as global constructors.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 4. Async / event loop model
|
|
94
|
+
|
|
95
|
+
Implemented:
|
|
96
|
+
|
|
97
|
+
- Core event loop `runtime/xt_loop.c` (a `select(2)` reactor); `net` / `dgram` / `http` are all built on it.
|
|
98
|
+
- `Promise`, `async` / `await` are available (see the core documents); `fs/promises` returns Promises.
|
|
99
|
+
- Timers are available as globals: `setTimeout` / `clearTimeout` / `setInterval` / `clearInterval` run on the core reactor and keep the process alive until no timer remains.
|
|
100
|
+
- A standalone `EventEmitter` is provided by the `events` module (also a global constructor); streams and sockets additionally carry internal emitter methods (`on` / `addListener` / `once` / `off` / `removeListener` / `emit`).
|
|
101
|
+
|
|
102
|
+
Still unimplemented:
|
|
103
|
+
|
|
104
|
+
- `setImmediate` / `queueMicrotask` and Node's `Timeout` object (`setTimeout` returns a numeric id).
|
|
105
|
+
- A real asynchronous I/O scheduler: `fs/promises` is essentially an immediate-settle wrapper around synchronous operations and does not yield while waiting for I/O.
|
|
106
|
+
- On streams and sockets the built-in `once` is equivalent to `on` (no "remove after firing once" semantics); the `events` module's `EventEmitter` does implement real `once`.
|
|
107
|
+
- `net`'s `connect` is blocking; HTTP responses require `Connection: close`, with no keep-alive / chunked transfer / pipelining.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 5. Bun extension unimplemented
|
|
112
|
+
|
|
113
|
+
The `Bun.file` and other Bun APIs mentioned in the design document are only
|
|
114
|
+
design examples of the extension mechanism and are **not yet implemented**:
|
|
115
|
+
|
|
116
|
+
- No `bun` extension directory, no Bun builtins, no Bun C runtime.
|
|
117
|
+
- Under `src/extensions/` there is currently only the single platform extension `node` (plus the core extension).
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 6. Quick reference: Node extension unimplemented list
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Implemented (fs): the full synchronous surface — readFileSync (with encoding), readTextFile,
|
|
125
|
+
writeFileSync, appendFileSync, existsSync, readdirSync (withFileTypes/recursive),
|
|
126
|
+
mkdirSync, rmSync, unlinkSync, rmdirSync, renameSync, copyFileSync, cpSync,
|
|
127
|
+
realpathSync, statSync, lstatSync, statfsSync, accessSync, chmodSync, lchmodSync,
|
|
128
|
+
chownSync, lchownSync, truncateSync, utimesSync, lutimesSync, mkdtempSync,
|
|
129
|
+
linkSync, symlinkSync, readlinkSync, opendirSync (Dir), globSync, watch,
|
|
130
|
+
watchFile, unwatchFile, constants,
|
|
131
|
+
openSync, closeSync, readSync, writeSync, readvSync, writevSync, fstatSync,
|
|
132
|
+
fsyncSync, fdatasyncSync, ftruncateSync, fchmodSync, fchownSync, futimesSync
|
|
133
|
+
Implemented (fs/promises): readFile, writeFile, appendFile, mkdir, readdir, rm, unlink,
|
|
134
|
+
rmdir, rename, copyFile, cp, realpath, stat, lstat, statfs, access,
|
|
135
|
+
open (FileHandle), chmod, lchmod, chown, lchown, truncate, utimes,
|
|
136
|
+
lutimes, link, symlink, readlink, mkdtemp, opendir, glob, watch, constants
|
|
137
|
+
Implemented (other modules): path (join/resolve/normalize/dirname/basename/extname/isAbsolute/relative),
|
|
138
|
+
os (platform/arch/type/release/endianness/homedir/tmpdir/hostname/totalmem/freemem/cpus),
|
|
139
|
+
process (cwd/exit/uptime/hrtime/getuid/platform/arch/pid/ppid/argv/env/version/title),
|
|
140
|
+
buffer (from/alloc/isBuffer/byteLength/concat/compare + instance methods),
|
|
141
|
+
stream (Readable/Writable/Duplex/Transform/PassThrough, pipe),
|
|
142
|
+
net (createServer/connect/isIP + Server/Socket),
|
|
143
|
+
dgram (createSocket + bind/send/close/address),
|
|
144
|
+
http (createServer/request/get + req/res),
|
|
145
|
+
events (EventEmitter: on/once/off/emit/listeners/listenerCount/eventNames),
|
|
146
|
+
util (format/inspect/isDeepStrictEqual/inherits/promisify + isX),
|
|
147
|
+
querystring (parse/stringify/escape/unescape),
|
|
148
|
+
crypto (createHash + streaming, SHA-1/SHA-256),
|
|
149
|
+
url (pathToFileURL/fileURLToPath only),
|
|
150
|
+
child_process (spawnSync only),
|
|
151
|
+
zlib (createGzip only), stream/promises (pipeline only),
|
|
152
|
+
worker_threads (Worker/isMainThread/workerData/parentPort only)
|
|
153
|
+
|
|
154
|
+
Unimplemented (fs): callback-style async file operations (readFile/writeFile/appendFile/open/
|
|
155
|
+
read/write/close), createReadStream/createWriteStream, real file watching
|
|
156
|
+
(watch/watchFile objects never emit),
|
|
157
|
+
glob exclude/follow, cp filter, utf16le decoding, Buffer return from readFileSync
|
|
158
|
+
|
|
159
|
+
Unimplemented (other modules): https, readline, tls, cluster, vm
|
|
160
|
+
|
|
161
|
+
Unimplemented (global/namespace): global/globalThis, __dirname, __filename,
|
|
162
|
+
require/module/exports, fs.readFileSync(...) namespace calls
|
|
163
|
+
|
|
164
|
+
Unimplemented (async): setImmediate / queueMicrotask, real async I/O scheduling, keep-alive
|
|
165
|
+
|
|
166
|
+
Unimplemented (platform): Bun extension (design example only)
|
|
167
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Guys, TypeScript can now be compiled into native binaries
|
|
2
|
+
|
|
3
|
+
## Background
|
|
4
|
+
|
|
5
|
+
Back in 2019 I spent some time studying compilers. I wrote a mini JS compiler that only supported the `function` and `number` types — but don't underestimate just those two types: it took me nearly two weeks to implement. That's when I realized a compiler demands an enormous amount of time and effort, and I sighed that I would probably never manage to build a relatively complete one in my lifetime.
|
|
6
|
+
|
|
7
|
+
Then one afternoon in September 2026, someone in a group chat remarked that frontend / JS / TS will always sit at the very bottom of the food chain, because unlike C++ and Rust it can't produce binary files.
|
|
8
|
+
|
|
9
|
+
## The Trigger
|
|
10
|
+
|
|
11
|
+
It was like something in my core got triggered. A thought kept flooding my mind, so I went back and dug up the articles I had written about compilers back then. No! That's not right! If using Ai,it might actually be possible now. So I started laying out my ideas and wrote my first document, DESIGN.md. Then I opened pi and started hacking!
|
|
12
|
+
|
|
13
|
+
Very quickly — in under an hour — the first prototype appeared. Looking at how ugly and simplistic it was, not even as good as the demo I wrote years ago, I decided to rewrite the entire framework from scratch. After several days I finally reached the level I wanted. Then I started a second attempt: I fired up pi again, and this time I found that although the AI was only so-so at architecture, once the architecture was in place it completed features unbelievably fast. So I kicked off a rapid iteration process.
|
|
14
|
+
|
|
15
|
+
## Core Progress
|
|
16
|
+
|
|
17
|
+
* The vast majority of JS/TS syntax plus mainstream Node.js APIs (as optional packages)
|
|
18
|
+
* Support for C++ and Rust extensions, so users can freely extend it
|
|
19
|
+
* Self-hosting achieved — it compiles itself
|
|
20
|
+
* Runs with no GNU dependency
|
|
21
|
+
|
|
22
|
+
Of course, what's not implemented is listed here:
|
|
23
|
+
[unimplemented.md](https://github.com/zy445566/xbintsc/blob/main/doc/unimplemented.md)
|
|
24
|
+
[node-unimplemented.md](https://github.com/zy445566/xbintsc/blob/main/doc/node-unimplemented.md)
|
|
25
|
+
|
|
26
|
+
The biggest advantages of binary compilation come down to two things:
|
|
27
|
+
* Tiny bundle size — the compiled binary is as small as 200 KB (--ext node 300KB) and runs directly, with no need to bundle a tens-of-MB Node.js runtime anymore
|
|
28
|
+
* Blazing-fast cold start — measured on my machine at roughly 120–200× faster than native Node.js
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Download the zst archive from the [releases page](https://github.com/zy445566/xbintsc/releases), extract it, and run it. Here's a Windows example:
|
|
33
|
+
```
|
|
34
|
+
# Build
|
|
35
|
+
.\xbintsc-win32-x64\bin\xbintsc.exe build .\hello.ts --out .\build
|
|
36
|
+
# Run
|
|
37
|
+
.\build\hello.exe
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# Appendix
|
|
41
|
+
|
|
42
|
+
GitHub: [https://github.com/zy445566/xbintsc](https://github.com/zy445566/xbintsc)
|
|
43
|
+
If you're interested, let's dig into it together `;)`
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# xbintsc Requirements
|
|
2
|
+
|
|
3
|
+
This page lists what a machine needs in order for `xbintsc` to **compile and
|
|
4
|
+
link native binaries**. xbintsc does not bundle a compiler, so every host needs
|
|
5
|
+
a clang-compatible toolchain installed. `xbintsc emit` (pure LLVM IR text) has
|
|
6
|
+
no requirements on any platform.
|
|
7
|
+
|
|
8
|
+
## Minimum versions
|
|
9
|
+
|
|
10
|
+
| Requirement | Minimum | Notes |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| clang / LLVM | **16** | The emitted IR uses opaque pointers, which LLVM 16 made the only pointer representation. |
|
|
13
|
+
| Node.js | **22** | Only to run or build the compiler from source; released binaries are standalone and need no Node. |
|
|
14
|
+
|
|
15
|
+
clang 15 and older fail on the first string literal in any program, with:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
build/app.ll:382:37: error: '@.str.0' defined with type '[6 x i8]*' but expected 'i8*'
|
|
19
|
+
%r0 = call i64 @xt_string_new(i8* @.str.0, i64 5)
|
|
20
|
+
```
|
|
21
|
+
|
|
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 check `clang --version` before anything else, and point xbintsc at a newer
|
|
24
|
+
build with `xbintsc_CLANG` when the system clang is older. `xbintsc doctor`
|
|
25
|
+
reports the resolved toolchain and its version. Working around the limitation by
|
|
26
|
+
compiling the IR elsewhere is not supported.
|
|
27
|
+
|
|
28
|
+
## Summary
|
|
29
|
+
|
|
30
|
+
| Platform | Requirement | Provided by |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| Linux | `clang` + `lld` (a glibc distribution) | the user (package manager) |
|
|
33
|
+
| macOS | **Xcode Command Line Tools** | the user (install once) |
|
|
34
|
+
| Windows | **LLVM** + **Visual Studio C++ build tools** (MSVC ABI) | the user (install once) |
|
|
35
|
+
| any | `xbintsc emit` | nothing |
|
|
36
|
+
|
|
37
|
+
The Windows release targets the **MSVC ABI**: clang uses the
|
|
38
|
+
Windows SDK and the MSVC C/C++ runtime/headers.
|
|
39
|
+
|
|
40
|
+
## Prebuilt releases (recommended)
|
|
41
|
+
|
|
42
|
+
Download the archive for your platform from
|
|
43
|
+
[GitHub Releases](https://github.com/zy445566/xbintsc/releases/latest) (each one
|
|
44
|
+
has a `.sha256` beside it):
|
|
45
|
+
|
|
46
|
+
| Platform | Archive |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| Windows x64 / arm64 | `xbintsc-<version>-win32-x64.tar.zst` / `xbintsc-<version>-win32-arm64.tar.zst` |
|
|
49
|
+
| Linux x64 / arm64 | `xbintsc-<version>-linux-x64.tar.zst` / `xbintsc-<version>-linux-arm64.tar.zst` |
|
|
50
|
+
| macOS x64 / arm64 (Apple Silicon) | `xbintsc-<version>-darwin-x64.tar.zst` / `xbintsc-<version>-darwin-arm64.tar.zst` |
|
|
51
|
+
|
|
52
|
+
(`.tar.gz` is used only when `zstd` is unavailable on the build machine.)
|
|
53
|
+
|
|
54
|
+
`<version>` is the release version (for example `0.3.14`), embedded in the asset
|
|
55
|
+
name so downloads from different releases do not collide.
|
|
56
|
+
|
|
57
|
+
Every archive unpacks to the same layout:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
xbintsc-<os>-<arch>/
|
|
61
|
+
bin/xbintsc[.exe] the compiler
|
|
62
|
+
runtime/ C runtime sources + prebuilt runtime/lib/<os>-<arch>/
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Windows archives omit the prebuilt `runtime/lib/`; the driver compiles the C
|
|
66
|
+
runtime on demand with the user's clang.
|
|
67
|
+
|
|
68
|
+
Unpack it, put `bin/` on `PATH` (or call `bin/xbintsc` directly), and install the
|
|
69
|
+
toolchain for your platform below. Verify the download against the checksum
|
|
70
|
+
first:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
sha256sum -c xbintsc-<version>-linux-x64.tar.zst.sha256 # macOS: shasum -a 256 -c
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## macOS — install Xcode Command Line Tools
|
|
77
|
+
|
|
78
|
+
xbintsc uses the linker and system SDK (`libSystem`, …) that ship with the
|
|
79
|
+
Command Line Tools to produce executables. Install them once:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
xcode-select --install
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Verify:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
xcode-select -p # prints the active developer directory
|
|
89
|
+
xcrun --show-sdk-path # prints the SDK path
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Linux — install clang and lld
|
|
93
|
+
|
|
94
|
+
A normal glibc-based distribution plus `clang` and `lld` is enough:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
sudo apt-get install -y clang lld # Debian / Ubuntu
|
|
98
|
+
sudo dnf install -y clang lld # Fedora / RHEL
|
|
99
|
+
sudo pacman -S --needed clang lld # Arch
|
|
100
|
+
sudo zypper install -y clang lld # openSUSE
|
|
101
|
+
sudo apk add clang lld # Alpine
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Verify with `clang --version`. If xbintsc uses the wrong linker, set
|
|
105
|
+
`xbintsc_CLANG` to the clang you want and/or pass extra flags through
|
|
106
|
+
`xbintsc_LINKER_ARGS` (for example `-fuse-ld=lld`).
|
|
107
|
+
|
|
108
|
+
## Windows — install LLVM and the MSVC C++ build tools
|
|
109
|
+
|
|
110
|
+
Install LLVM and the Visual Studio C++ build tools with `winget`:
|
|
111
|
+
|
|
112
|
+
```powershell
|
|
113
|
+
winget install -e --id LLVM.LLVM
|
|
114
|
+
winget install -e --id Microsoft.VisualStudio.2022.BuildTools `
|
|
115
|
+
--override "--quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
clang needs the MSVC/SDK environment (`INCLUDE`, `LIB`, `PATH`) to find the C
|
|
119
|
+
standard library headers, the import libraries and the linker. Open an
|
|
120
|
+
**x64 Native Tools Command Prompt for VS 2022** (or an **ARM64 Native Tools**
|
|
121
|
+
prompt on Windows on ARM) before running `xbintsc`, or import the environment
|
|
122
|
+
yourself:
|
|
123
|
+
|
|
124
|
+
```powershell
|
|
125
|
+
& "$env:ProgramFiles\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Verify with `clang --version` (chocolatey also works: `choco install llvm`).
|
|
129
|
+
|
|
130
|
+
## Building from source (contributors only)
|
|
131
|
+
|
|
132
|
+
- Node.js ≥ 22 is required only to run/build the compiler itself. The released
|
|
133
|
+
standalone binaries do **not** need Node.
|
|
134
|
+
- A C compiler is required to rebuild the runtime (`npm run runtime`).
|
|
135
|
+
- `npm run package-release` assembles the per-platform release archive
|
|
136
|
+
(`xbintsc-<os>-<arch>.tar.{gz,zst}` + `.sha256`) into `dist/release/`.
|
|
137
|
+
|
|
138
|
+
## Checking your environment
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
xbintsc doctor
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`doctor` reports the resolved toolchain (env / system), its version and location,
|
|
145
|
+
and the runtime-library directory.
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# xbintsc Unimplemented Syntax and Features
|
|
2
|
+
|
|
3
|
+
This document was compiled by checking the source (`src/`, `runtime/`) and tests
|
|
4
|
+
(`tests/`) file by file, and lists the syntax and features that are
|
|
5
|
+
**currently unimplemented / only partially implemented / semantically different
|
|
6
|
+
from the standard**.
|
|
7
|
+
|
|
8
|
+
Criteria (ordered by severity):
|
|
9
|
+
|
|
10
|
+
1. **Not parsed**: the parser reports a syntax error immediately; code generation is never reached.
|
|
11
|
+
2. **Parsed but codegen errors**: the AST / binding can be built, but `codegen` reports `UnsupportedFeature`.
|
|
12
|
+
3. **Parsed and compilable, but semantics are missing or differ**: a binary is produced, but the runtime result does not match ECMAScript / TypeScript semantics.
|
|
13
|
+
|
|
14
|
+
> Language: **English** | [简体中文](./zh-CN/unimplemented.md)
|
|
15
|
+
|
|
16
|
+
> Recently completed: **ECMAScript semantics + differential testing** — number
|
|
17
|
+
> formatting / coercion (`toFixed` / `toPrecision` / `toExponential`, hex / octal
|
|
18
|
+
> / binary parsing, full `+` and relational `ToPrimitive`), `JSON.stringify`
|
|
19
|
+
> omission rules, default `Array.prototype.sort` (stable, string order),
|
|
20
|
+
> insertion-ordered integer keys, whole-chain optional chaining, `finally` on
|
|
21
|
+
> early `return` / `break` / `continue`, object-key insertion order, UTF-8-aware
|
|
22
|
+
> `console` inspection with circular references, `Array.prototype.splice`,
|
|
23
|
+
> `String.prototype.match` / `lastIndexOf` / `split` with limit, RegExp capture
|
|
24
|
+
> groups (`exec` / `match` / `replace` / `split` / `search`), immutable array
|
|
25
|
+
> methods (`toReversed` / `toSorted` / `toSpliced` / `with`),
|
|
26
|
+
> `Object.getOwnPropertyNames` / `groupBy`, global URI functions, labeled
|
|
27
|
+
> statements, `#private` fields / methods / statics, tagged templates (with raw
|
|
28
|
+
> strings and `String.raw`), and `import * as ns` for relative modules. The test
|
|
29
|
+
> suite now includes a **differential harness** that runs every case through both
|
|
30
|
+
> xbintsc and Node and compares output byte-for-byte.
|
|
31
|
+
|
|
32
|
+
> Also completed: `class` declarations / class expressions, `new` / `this`,
|
|
33
|
+
> inheritance `extends` / `super`, `instanceof`, methods / static members /
|
|
34
|
+
> instance fields / getters and setters / constructor parameter properties,
|
|
35
|
+
> `async` / `await` + `Promise`, multi-file `import` / `export` bundling
|
|
36
|
+
> (including `.js` → `.ts` specifier resolution and namespace imports), `Map` /
|
|
37
|
+
> `Set` / `Date` / `RegExp` / `JSON` / `BigInt`, destructuring bindings and
|
|
38
|
+
> parameters, `enum` / `const enum`, and **self-hosting** (the emitted LLVM IR
|
|
39
|
+
> reaches a byte-identical fixpoint).
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 1. Unimplemented at the statement level
|
|
44
|
+
|
|
45
|
+
### 1.1 Parsed but codegen reports `UnsupportedFeature`
|
|
46
|
+
|
|
47
|
+
| Syntax | Status | Notes |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `namespace` / `module` declarations | parse ✓, codegen ✗ | → "does not yet support this statement (module declaration)" |
|
|
50
|
+
|
|
51
|
+
> Labeled statements (`label: statement`, `break label`, `continue label`) are
|
|
52
|
+
> implemented, including labels on non-loop statements.
|
|
53
|
+
|
|
54
|
+
### 1.2 Not supported by the parser (immediate syntax error)
|
|
55
|
+
|
|
56
|
+
None known at the statement level. The parser is intentionally permissive and
|
|
57
|
+
accepts most TypeScript statement syntax; unsupported forms are rejected later
|
|
58
|
+
by code generation (see above).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 2. Unimplemented at the expression level
|
|
63
|
+
|
|
64
|
+
### 2.1 Parsed but codegen reports `UnsupportedFeature`
|
|
65
|
+
|
|
66
|
+
None — generators are implemented.
|
|
67
|
+
|
|
68
|
+
> Tagged templates are implemented, including raw strings and `String.raw`.
|
|
69
|
+
> Generators (`function*`, `yield`, `yield*`) are implemented with stackful
|
|
70
|
+
> coroutines, including `next`/`throw`/`return`, `for...of`, spread and
|
|
71
|
+
> delegation. `import.meta` is parsed but has no runtime value; `async`
|
|
72
|
+
> generators are not yet supported.
|
|
73
|
+
|
|
74
|
+
### 2.2 Not supported by the parser
|
|
75
|
+
|
|
76
|
+
None known at the expression level.
|
|
77
|
+
|
|
78
|
+
### 2.3 Unimplemented operators
|
|
79
|
+
|
|
80
|
+
| Operator | Status | Notes |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| `new.target` | ✗ | not implemented |
|
|
83
|
+
| `typeof` / `void` / `in` / `delete` / `instanceof` | ✓ | mapped to runtime helpers (`xt_typeof`, `xt_in`, `xt_delete`, `xt_instance_of`) |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 3. Unimplemented standard library
|
|
88
|
+
|
|
89
|
+
### 3.1 Implemented (summary)
|
|
90
|
+
|
|
91
|
+
- Arrays: `push` `pop` `shift` `unshift` `join` `slice` `splice` `indexOf` `lastIndexOf` `includes` `concat` `reverse` `forEach` `map` `filter` `reduce` `reduceRight` `find` `findIndex` `findLast` `findLastIndex` `some` `every` `sort` `flat` `flatMap` `fill` `copyWithin` `at` `keys` `values` `entries` and the immutable `toReversed` / `toSorted` / `toSpliced` / `with`
|
|
92
|
+
- Strings: `charAt` `charCodeAt` `codePointAt` `indexOf` `lastIndexOf` `includes` `startsWith` `endsWith` `slice` `substring` `substr` `split` `match` `replace` `replaceAll` `search` `toUpperCase` `toLowerCase` `trim` `trimStart` `trimEnd` `padStart` `padEnd` `repeat` `concat` `at` `localeCompare` `valueOf`
|
|
93
|
+
- `Math`: full set of functions and constants
|
|
94
|
+
- `Object.keys` / `values` / `entries` / `assign` / `getOwnPropertyNames` / `groupBy`, object spread `{...obj}`
|
|
95
|
+
- Global functions: `parseInt` `parseFloat` `isNaN` `isFinite` `Number` `String` `Boolean` `encodeURI` `decodeURI` `encodeURIComponent` `decodeURIComponent`
|
|
96
|
+
- `console.log` / `info` / `warn` / `error` / `dir` / `trace` / `assert` / `count` / `group` / `table` / `time`
|
|
97
|
+
|
|
98
|
+
### 3.2 Completed
|
|
99
|
+
|
|
100
|
+
- `JSON.parse` / `JSON.stringify`
|
|
101
|
+
- `Date`, `RegExp` (POSIX ERE subset with capture groups), `Map`, `Set`, `Promise`, `BigInt`
|
|
102
|
+
- `Array` statics (`isArray/of/from`), `Object` statics, `Number` statics, `String` statics (`fromCharCode` / `fromCodePoint` / `raw`)
|
|
103
|
+
- `Error` family (`Error`, `TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`, `URIError`, `AggregateError`): `new`, `instanceof`, `extends`, `String(err)` / `err.toString()` and `.stack`
|
|
104
|
+
|
|
105
|
+
### 3.3 Still unimplemented
|
|
106
|
+
|
|
107
|
+
| Category | Status |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `Symbol` constructor and symbol primitives | ✓ `Symbol(description)`, well-known symbols, `Symbol.for` / `Symbol.keyFor`, symbol property keys and `Object.getOwnPropertySymbols` |
|
|
110
|
+
| `String.prototype.normalize` | ✗ not implemented |
|
|
111
|
+
| `structuredClone` | ✗ not implemented |
|
|
112
|
+
| Built-in error subclasses (`TypeError`, `RangeError`, …) | ✓ first-class constructors and prototypes; `instanceof Error` holds for the whole family |
|
|
113
|
+
| `AggregateError` constructor | ✓ `new AggregateError(errors, message)`; `Promise.any` now rejects with one |
|
|
114
|
+
| Iterator protocol / `Symbol.iterator` / custom `for...of` iterables | ✓ arrays, strings, `Map`, `Set`, generators and any object exposing `[Symbol.iterator]()` are iterable in `for...of` / spread |
|
|
115
|
+
| Generators (`function*`, `yield`, `yield*`, `next`/`throw`/`return`) | ✓ implemented with stackful coroutines; `for...of`, spread and delegation supported. `return()` completes without running `finally` |
|
|
116
|
+
| Timers | ✓ `setTimeout` / `clearTimeout` / `setInterval` / `clearInterval` on the core event loop (numeric ids, no `Timeout` object; no `setImmediate` / `queueMicrotask`) |
|
|
117
|
+
| I/O / process and other host APIs | only via extensions (e.g. Node `fs`) |
|
|
118
|
+
|
|
119
|
+
### 3.4 Typed arrays
|
|
120
|
+
|
|
121
|
+
Implemented: `Uint8Array`, `Int8Array`, `Uint8ClampedArray`, `Uint16Array`,
|
|
122
|
+
`Int16Array`, `Uint32Array`, `Int32Array`, `Float32Array`, `Float64Array` with
|
|
123
|
+
`new X(n)` / `new X(arrayLike)`, `X.from` / `X.of`, `BYTES_PER_ELEMENT`, coerced
|
|
124
|
+
element writes, and `fill` / `set` / `slice` / `subarray` / `join` / `toString` /
|
|
125
|
+
`indexOf` / `lastIndexOf` / `includes` / `forEach` / `map` / `filter` / `every` /
|
|
126
|
+
`some` / `find` / `findIndex` / `reduce` / `reverse` / `sort` / `copyWithin` /
|
|
127
|
+
`at` / `keys` / `values` / `entries`. Known divergences:
|
|
128
|
+
|
|
129
|
+
| Feature | Status |
|
|
130
|
+
| --- | --- |
|
|
131
|
+
| `subarray` | ~ returns a copy, not a view over a shared buffer |
|
|
132
|
+
| `keys` / `values` / `entries` | ~ return arrays, not iterator objects |
|
|
133
|
+
| `ArrayBuffer` / `DataView` / `.buffer` / `.byteOffset` semantics | ✗ no backing buffer type; `.byteOffset` is always 0 |
|
|
134
|
+
| `BigInt64Array` / `BigUint64Array` | ✗ not implemented |
|
|
135
|
+
| `instanceof Uint8Array` | ✗ global constructors are not first-class values, so `x instanceof Uint8Array` fails with `Cannot find name 'Uint8Array'` |
|
|
136
|
+
| Typed-array views over a `Buffer` / `ArrayBuffer` | ✗ constructors copy from a length / array-like / typed array only |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 4. Module system
|
|
141
|
+
|
|
142
|
+
| Feature | Status |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| Multi-file / module resolution and linking | ✓ driver-layer AST bundling (`src/driver/modules.ts`): parse each module, rename top-level symbols by module prefix, rewrite references, merge into one file and rebind |
|
|
145
|
+
| Named import/export | ✓ `import { a, b as c }` / `export { a as b }` / `export const/let/var/function/class` |
|
|
146
|
+
| Default import/export | ✓ `export default` / `import d from` |
|
|
147
|
+
| Re-export `export { x } from` / `export * from` | ✓ (`export *` copies the dependency's exports) |
|
|
148
|
+
| Namespace import `import * as ns` | ✓ lowered to a synthetic object literal holding every export |
|
|
149
|
+
| Circular dependencies | ✗ errors out (no circular initialization semantics) |
|
|
150
|
+
| Live bindings | ✗ namespace objects and imported bindings are snapshots at module-evaluation time |
|
|
151
|
+
| ESM `node_modules` packages | ✓ bare specifiers resolve up the tree through `exports` / `module` / `main`, including scoped packages and subpaths; the package sources are bundled like relative modules |
|
|
152
|
+
| CommonJS `require` / `module.exports` | ✓ inside `node_modules` only: the bundler gives each CommonJS package a synthetic `module` / `exports` pair, lowers `require("x")` to the bundled dependency's exports, and hoists external/built-in `require`s into ESM imports. `require()` in user code (outside `node_modules`) is still rejected with a diagnostic pointing at the ESM `import` form. |
|
|
153
|
+
|
|
154
|
+
> Extension modules (such as `fs`) are importable by bare or `node:`-prefixed
|
|
155
|
+
> specifier — `import { readFileSync } from "fs"` / `import path from "path"` —
|
|
156
|
+
> and resolve to their runtime entries (named, default and namespace forms).
|
|
157
|
+
> Relative modules and ESM packages under `node_modules` are bundled at the driver layer.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 5. Unimplemented function features (or missing semantics)
|
|
162
|
+
|
|
163
|
+
| Feature | Parse | Semantics |
|
|
164
|
+
| --- | --- | --- |
|
|
165
|
+
| Default parameters `function f(a = 5)` | ✓ | ✓ implemented |
|
|
166
|
+
| Rest parameters `function f(...args)` | ✓ | ✓ implemented |
|
|
167
|
+
| Spread in call arguments `f(...args)` | ✓ | ✓ implemented |
|
|
168
|
+
| Destructuring parameters / bindings | ✓ | ✓ implemented |
|
|
169
|
+
| `arguments` object | ✓ (implicit) | ✓ implemented (arrow functions get their own parameters, not the outer function's `arguments`, unlike JS) |
|
|
170
|
+
| `this` binding / method call semantics | ✓ | ✓ implemented (`this` is threaded as the first ABI parameter; arrow functions inherit lexically) |
|
|
171
|
+
| `async` / `await` / Promise | ✓ | ✓ implemented (synchronous microtask model) |
|
|
172
|
+
| `new.target` | ✗ | not implemented |
|
|
173
|
+
| Generators / iterators / `yield` | ✓ implemented | `function*`, `yield`, `yield*`, `.next/.throw/.return`; `async` generators not supported |
|
|
174
|
+
| Closure `arity` | — | `xt_closure_arity` is always -1, never filled in |
|
|
175
|
+
| `fn.call` / `fn.apply` / `fn.bind` | ✓ | ✓ implemented (the bound closure does not track partial-argument `length`) |
|
|
176
|
+
| `fn.name` / `fn.length` | ✓ | ✓ implemented (inferred from the declaration / assignment / property key; bound functions use `"bound ..."` and adjusted arity) |
|
|
177
|
+
| First-class built-in methods (`typeof arr.map`, `const f = arr.push`, `obj.method?.()`) | ✓ | ✓ implemented as *unbound* method values: reading `arr.map` yields a function, `arr.map?.(cb)` and `obj.method?.()` bind the receiver as `this`, and a detached call (`const f = arr.map; f(cb)`) throws exactly like JavaScript. Method `name`/`length` are exposed |
|
|
178
|
+
| `fn.toString()` | ~ | returns a native-style placeholder (`function name() { [native code] }`) instead of the original source text |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 6. Classes and object orientation
|
|
183
|
+
|
|
184
|
+
| Feature | Status |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| `class` declarations / class expressions | ✓ implemented |
|
|
187
|
+
| `constructor` | ✓ |
|
|
188
|
+
| Instance fields / property declarations | ✓ |
|
|
189
|
+
| Methods | ✓ |
|
|
190
|
+
| `static` fields / methods | ✓ |
|
|
191
|
+
| Inheritance `extends` / `super` | ✓ (single level correct; `super` takes the prototype of `this`'s prototype — see section 8) |
|
|
192
|
+
| Prototype chain / method lookup | ✓ |
|
|
193
|
+
| `instanceof` | ✓ |
|
|
194
|
+
| `new` / instantiation | ✓ |
|
|
195
|
+
| `get` / `set` accessors | ✓ implemented |
|
|
196
|
+
| Parameter properties `constructor(public x: T)` | ✓ implemented |
|
|
197
|
+
| Private fields `#x` | ✓ implemented (stored under a literal `#x` key; no accessibility enforcement) |
|
|
198
|
+
| `enum` / `const enum` | ✓ implemented (forward + reverse mapping) |
|
|
199
|
+
| `private` / `protected` / `public` / `readonly` modifiers | ✗ no access control (erased) |
|
|
200
|
+
| `abstract` / `implements` | ✗ (erased) |
|
|
201
|
+
| Parent/child `#x` name collisions | ✗ may alias (same literal key) |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 7. Unimplemented type system (parsed only, not checked)
|
|
206
|
+
|
|
207
|
+
Type syntax is parsed into the AST and then **erased entirely** during binding /
|
|
208
|
+
code generation; no type checking is performed:
|
|
209
|
+
|
|
210
|
+
- Type annotations, return types, type parameters, type aliases, interfaces, generic constraints, etc.: parse ✓, check ✗.
|
|
211
|
+
- Checker diagnostic codes (`TypeMismatch` `NotCallable` `PropertyNotFound` `ArgumentCountMismatch`) are defined but **unused**.
|
|
212
|
+
- `as` / `satisfies` / non-null assertion `!`: erased directly, no assertion semantics.
|
|
213
|
+
- Generics: no runtime instantiation; type parameters are ignored.
|
|
214
|
+
- Optional chaining `?.` type narrowing: none (runtime short-circuit is implemented, but there is no type-level narrowing).
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 8. Runtime / semantics differing from the standard (known deviations)
|
|
219
|
+
|
|
220
|
+
These features **compile and run**, but the result does not fully match ECMAScript:
|
|
221
|
+
|
|
222
|
+
| Item | Deviation |
|
|
223
|
+
| --- | --- |
|
|
224
|
+
| String `length` | Counted in UTF-8 bytes, not UTF-16 code units (`"\u00e9".length` reports 1 instead of 2; `"\u{1F600}".length` reports 4 instead of 2; `codePointAt` likewise differs) |
|
|
225
|
+
| `Object.getPrototypeOf({})` | Returns `undefined` instead of the `Object.prototype` object |
|
|
226
|
+
| Global RegExp `lastIndex` | `test` / `exec` do not advance or honour a caller-set `lastIndex` for `/g` / `/y` regexes |
|
|
227
|
+
| String `normalize` / `structuredClone` | Not implemented |
|
|
228
|
+
| First-class built-in methods | Implemented as unbound method values (see section 5); `fn.toString()` returns a placeholder rather than source text |
|
|
229
|
+
| `for...in` | Enumerates own keys of objects / arrays / strings; does not include prototype-chain properties |
|
|
230
|
+
| Array out-of-bounds / sparse | Out-of-bounds access returns `undefined`; assigning `arr.length` truncates / extends, but sparse holes are not tracked distinctly |
|
|
231
|
+
| Memory management | Non-moving mark-sweep collector behind `xt_alloc`: explicit roots, subsystem root providers and a conservative C-stack scan. Single-threaded and stop-the-world; no moving/compaction or generational mode |
|
|
232
|
+
| Function `arity` / argument count | No argument count validation; `fn.length` reports the declared arity but calls are never checked against it |
|
|
233
|
+
| `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
|
+
| `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` | Not captured |
|
|
236
|
+
| Module live bindings | Namespace imports and imported bindings are snapshots (see section 4) |
|
|
237
|
+
| `import.meta` | Parsed but has no value |
|
|
238
|
+
|
|
239
|
+
> Number formatting, loose equality, `+` / relational `ToPrimitive`, whole-chain
|
|
240
|
+
> optional chaining, `finally` on early exit and object-key ordering have all
|
|
241
|
+
> been brought in line with Node and are covered by the differential tests, so
|
|
242
|
+
> they are no longer listed as deviations.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 9. Unimplemented toolchain / platform / engineering
|
|
247
|
+
|
|
248
|
+
| Item | Status |
|
|
249
|
+
| --- | --- |
|
|
250
|
+
| GC (garbage collection) | ✓ non-moving mark-sweep in `xt_alloc.c`, armed by a live-heap threshold (`XT_GC_THRESHOLD`) or `xt_gc_collect()`; explicit roots + root providers + conservative active-stack scan. No compaction, weak references or background collection |
|
|
251
|
+
| Self-hosting | ✓ the compiler compiles itself: `xbintsc build src/cli/main.ts` produces a working binary, and the emitted IR is stable from generation 1 onward. The runtime is still C |
|
|
252
|
+
| Type checker | ✗ only diagnostic codes are defined; no checker |
|
|
253
|
+
| Full standard library | partial: Math / JSON / Date / Map / Set / RegExp / `Error` / `BigInt` / `Symbol` implemented; String.normalize / structuredClone missing |
|
|
254
|
+
| Multi-file module bundling | partial: relative-path `.ts` bundling, ESM `node_modules` packages, namespace imports and bare-specifier extension module imports implemented; circular dependencies / CommonJS / live bindings not implemented |
|
|
255
|
+
| A real async runtime / event loop | ✗ (Promise is a synchronous microtask model) |
|
|
256
|
+
| Windows binary artifact verification | adapted at the build layer (`.exe` suffix, link flag branch), verified in CI |
|
|
257
|
+
| Precise ECMAScript number / string / comparison semantics | partial, see section 8 |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 10. Quick reference: unimplemented / partially implemented list
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
Unimplemented (statements): namespace/module declarations
|
|
265
|
+
|
|
266
|
+
Unimplemented (expressions): new.target, import.meta value
|
|
267
|
+
|
|
268
|
+
Unimplemented (functions): `fn.toString()` source text, async generators
|
|
269
|
+
|
|
270
|
+
Unimplemented (classes/OO): abstract/implements, access control,
|
|
271
|
+
parent/child #x collision
|
|
272
|
+
|
|
273
|
+
Unimplemented (standard library): String.normalize, structuredClone
|
|
274
|
+
|
|
275
|
+
Unimplemented (modules): circular dependencies, live bindings, dynamic
|
|
276
|
+
`require(expr)`, `require.resolve` / `require.cache`,
|
|
277
|
+
`__dirname` / `__filename`
|
|
278
|
+
|
|
279
|
+
Unimplemented (type system): type checking, generic instantiation, assertion
|
|
280
|
+
semantics, optional-chaining narrowing
|
|
281
|
+
|
|
282
|
+
Unimplemented (runtime): a real async event loop, UTF-16 string length,
|
|
283
|
+
Object.prototype identity, global-regex lastIndex
|
|
284
|
+
|
|
285
|
+
Unimplemented (engineering): type checker
|
|
286
|
+
```
|