xbintsc 0.3.87 → 0.5.20

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.
Files changed (458) hide show
  1. package/AGENTS.md +23 -11
  2. package/README.md +11 -9
  3. package/README.zh-CN.md +7 -7
  4. package/dist/src/binder/declarations.js +14 -3
  5. package/dist/src/binder/declarations.js.map +1 -1
  6. package/dist/src/cli/hints.js +7 -1
  7. package/dist/src/cli/hints.js.map +1 -1
  8. package/dist/src/cli/main.js +115 -15
  9. package/dist/src/cli/main.js.map +1 -1
  10. package/dist/src/cli/watch.d.ts +25 -0
  11. package/dist/src/cli/watch.js +93 -0
  12. package/dist/src/cli/watch.js.map +1 -0
  13. package/dist/src/codegen/generator/calls/access.js +17 -4
  14. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  15. package/dist/src/codegen/generator/calls/closures.js +13 -1
  16. package/dist/src/codegen/generator/calls/closures.js.map +1 -1
  17. package/dist/src/codegen/generator/calls/invocation.js +4 -3
  18. package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
  19. package/dist/src/codegen/generator/context.d.ts +8 -0
  20. package/dist/src/codegen/generator/context.js +22 -3
  21. package/dist/src/codegen/generator/context.js.map +1 -1
  22. package/dist/src/codegen/generator/expressions/operators.js +17 -15
  23. package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
  24. package/dist/src/codegen/generator/expressions/primary.js +11 -1
  25. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  26. package/dist/src/codegen/generator/module.d.ts +0 -1
  27. package/dist/src/codegen/generator/module.js +10 -17
  28. package/dist/src/codegen/generator/module.js.map +1 -1
  29. package/dist/src/codegen/generator/numeric.d.ts +6 -3
  30. package/dist/src/codegen/generator/numeric.js +54 -11
  31. package/dist/src/codegen/generator/numeric.js.map +1 -1
  32. package/dist/src/codegen/generator/state.js +27 -0
  33. package/dist/src/codegen/generator/state.js.map +1 -1
  34. package/dist/src/codegen/generator/statements/control-flow.js +2 -7
  35. package/dist/src/codegen/generator/statements/control-flow.js.map +1 -1
  36. package/dist/src/codegen/generator/statements/loops.js +48 -16
  37. package/dist/src/codegen/generator/statements/loops.js.map +1 -1
  38. package/dist/src/codegen/generator/tables.d.ts +9 -0
  39. package/dist/src/codegen/generator/tables.js +100 -3
  40. package/dist/src/codegen/generator/tables.js.map +1 -1
  41. package/dist/src/diagnostics/diagnostic.d.ts +3 -1
  42. package/dist/src/diagnostics/diagnostic.js +23 -3
  43. package/dist/src/diagnostics/diagnostic.js.map +1 -1
  44. package/dist/src/driver/app-artifacts.d.ts +42 -0
  45. package/dist/src/driver/app-artifacts.js +53 -0
  46. package/dist/src/driver/app-artifacts.js.map +1 -0
  47. package/dist/src/driver/build-key.d.ts +29 -0
  48. package/dist/src/driver/build-key.js +35 -0
  49. package/dist/src/driver/build-key.js.map +1 -0
  50. package/dist/src/driver/bundler/graph.js +61 -12
  51. package/dist/src/driver/bundler/graph.js.map +1 -1
  52. package/dist/src/driver/bundler/merge.js +7 -1
  53. package/dist/src/driver/bundler/merge.js.map +1 -1
  54. package/dist/src/driver/compiler.d.ts +10 -67
  55. package/dist/src/driver/compiler.js +94 -230
  56. package/dist/src/driver/compiler.js.map +1 -1
  57. package/dist/src/driver/config.d.ts +3 -0
  58. package/dist/src/driver/config.js +8 -0
  59. package/dist/src/driver/config.js.map +1 -1
  60. package/dist/src/driver/frontend.d.ts +37 -0
  61. package/dist/src/driver/frontend.js +92 -0
  62. package/dist/src/driver/frontend.js.map +1 -0
  63. package/dist/src/driver/index.d.ts +1 -1
  64. package/dist/src/driver/index.js.map +1 -1
  65. package/dist/src/driver/options.d.ts +64 -0
  66. package/dist/src/driver/options.js +9 -0
  67. package/dist/src/driver/options.js.map +1 -0
  68. package/dist/src/driver/runtime-objects.d.ts +38 -0
  69. package/dist/src/driver/runtime-objects.js +111 -0
  70. package/dist/src/driver/runtime-objects.js.map +1 -0
  71. package/dist/src/driver/toolchain-provider.d.ts +4 -0
  72. package/dist/src/driver/toolchain-provider.js +4 -0
  73. package/dist/src/driver/toolchain-provider.js.map +1 -1
  74. package/dist/src/driver/toolchain.d.ts +32 -1
  75. package/dist/src/driver/toolchain.js +115 -11
  76. package/dist/src/driver/toolchain.js.map +1 -1
  77. package/dist/src/driver/version.d.ts +12 -0
  78. package/dist/src/driver/version.js +13 -0
  79. package/dist/src/driver/version.js.map +1 -0
  80. package/dist/src/driver/win-icon.d.ts +7 -9
  81. package/dist/src/driver/win-icon.js +37 -35
  82. package/dist/src/driver/win-icon.js.map +1 -1
  83. package/dist/src/parser/declarations/classes.js +5 -0
  84. package/dist/src/parser/declarations/classes.js.map +1 -1
  85. package/dist/src/parser/declarations/functions.js +13 -1
  86. package/dist/src/parser/declarations/functions.js.map +1 -1
  87. package/dist/src/parser/modules.js +8 -3
  88. package/dist/src/parser/modules.js.map +1 -1
  89. package/dist/src/parser/parser.d.ts +1 -0
  90. package/dist/src/parser/parser.js +23 -0
  91. package/dist/src/parser/parser.js.map +1 -1
  92. package/dist/tests/cli/check.test.d.ts +6 -0
  93. package/dist/tests/cli/check.test.js +68 -0
  94. package/dist/tests/cli/check.test.js.map +1 -0
  95. package/dist/tests/cli/main.test.js +19 -0
  96. package/dist/tests/cli/main.test.js.map +1 -1
  97. package/dist/tests/cli/watch.test.d.ts +6 -0
  98. package/dist/tests/cli/watch.test.js +72 -0
  99. package/dist/tests/cli/watch.test.js.map +1 -0
  100. package/dist/tests/codegen/closures.test.js +8 -0
  101. package/dist/tests/codegen/closures.test.js.map +1 -1
  102. package/dist/tests/codegen/expressions.test.js +15 -3
  103. package/dist/tests/codegen/expressions.test.js.map +1 -1
  104. package/dist/tests/codegen/llvm.test.js +16 -0
  105. package/dist/tests/codegen/llvm.test.js.map +1 -1
  106. package/dist/tests/diagnostics/diagnostic.test.js +8 -0
  107. package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
  108. package/dist/tests/docs/structure.test.d.ts +1 -0
  109. package/dist/tests/docs/structure.test.js +92 -0
  110. package/dist/tests/docs/structure.test.js.map +1 -0
  111. package/dist/tests/driver/compiler.test.js +6 -0
  112. package/dist/tests/driver/compiler.test.js.map +1 -1
  113. package/dist/tests/driver/config.test.js +9 -0
  114. package/dist/tests/driver/config.test.js.map +1 -1
  115. package/dist/tests/driver/icon.test.js +19 -32
  116. package/dist/tests/driver/icon.test.js.map +1 -1
  117. package/dist/tests/driver/invalid-input.test.d.ts +10 -0
  118. package/dist/tests/driver/invalid-input.test.js +29 -0
  119. package/dist/tests/driver/invalid-input.test.js.map +1 -0
  120. package/dist/tests/driver/modules.test.js +42 -3
  121. package/dist/tests/driver/modules.test.js.map +1 -1
  122. package/dist/tests/driver/toolchain-provider.test.js +27 -1
  123. package/dist/tests/driver/toolchain-provider.test.js.map +1 -1
  124. package/dist/tests/driver/toolchain.test.js +60 -2
  125. package/dist/tests/driver/toolchain.test.js.map +1 -1
  126. package/dist/tests/e2e/array-buffer.test.d.ts +5 -0
  127. package/dist/tests/e2e/array-buffer.test.js +38 -0
  128. package/dist/tests/e2e/array-buffer.test.js.map +1 -0
  129. package/dist/tests/e2e/array-from-iterables.test.d.ts +7 -0
  130. package/dist/tests/e2e/array-from-iterables.test.js +34 -0
  131. package/dist/tests/e2e/array-from-iterables.test.js.map +1 -0
  132. package/dist/tests/e2e/array-symbol-iterator.test.d.ts +8 -0
  133. package/dist/tests/e2e/array-symbol-iterator.test.js +42 -0
  134. package/dist/tests/e2e/array-symbol-iterator.test.js.map +1 -0
  135. package/dist/tests/e2e/async-await.test.d.ts +10 -0
  136. package/dist/tests/e2e/async-await.test.js +247 -0
  137. package/dist/tests/e2e/async-await.test.js.map +1 -0
  138. package/dist/tests/e2e/async-generators.test.d.ts +1 -0
  139. package/dist/tests/e2e/async-generators.test.js +154 -0
  140. package/dist/tests/e2e/async-generators.test.js.map +1 -0
  141. package/dist/tests/e2e/await-ordering.test.d.ts +5 -0
  142. package/dist/tests/e2e/await-ordering.test.js +37 -0
  143. package/dist/tests/e2e/await-ordering.test.js.map +1 -0
  144. package/dist/tests/e2e/compile-builtins.test.js +1 -1
  145. package/dist/tests/e2e/compile-modules.test.js +7 -0
  146. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  147. package/dist/tests/e2e/date-parse.test.d.ts +8 -0
  148. package/dist/tests/e2e/date-parse.test.js +38 -0
  149. package/dist/tests/e2e/date-parse.test.js.map +1 -0
  150. package/dist/tests/e2e/default-anonymous-exports.test.d.ts +7 -0
  151. package/dist/tests/e2e/default-anonymous-exports.test.js +23 -0
  152. package/dist/tests/e2e/default-anonymous-exports.test.js.map +1 -0
  153. package/dist/tests/e2e/globals-microtask.test.d.ts +9 -0
  154. package/dist/tests/e2e/globals-microtask.test.js +37 -0
  155. package/dist/tests/e2e/globals-microtask.test.js.map +1 -0
  156. package/dist/tests/e2e/gui-media.test.js +8 -1
  157. package/dist/tests/e2e/gui-media.test.js.map +1 -1
  158. package/dist/tests/e2e/inspect-builtins.test.d.ts +10 -0
  159. package/dist/tests/e2e/inspect-builtins.test.js +43 -0
  160. package/dist/tests/e2e/inspect-builtins.test.js.map +1 -0
  161. package/dist/tests/e2e/json-builtin-objects.test.d.ts +9 -0
  162. package/dist/tests/e2e/json-builtin-objects.test.js +23 -0
  163. package/dist/tests/e2e/json-builtin-objects.test.js.map +1 -0
  164. package/dist/tests/e2e/json-circular.test.d.ts +6 -0
  165. package/dist/tests/e2e/json-circular.test.js +43 -0
  166. package/dist/tests/e2e/json-circular.test.js.map +1 -0
  167. package/dist/tests/e2e/json-parse-reviver.test.d.ts +6 -0
  168. package/dist/tests/e2e/json-parse-reviver.test.js +29 -0
  169. package/dist/tests/e2e/json-parse-reviver.test.js.map +1 -0
  170. package/dist/tests/e2e/json-stringify-replacer.test.d.ts +6 -0
  171. package/dist/tests/e2e/json-stringify-replacer.test.js +27 -0
  172. package/dist/tests/e2e/json-stringify-replacer.test.js.map +1 -0
  173. package/dist/tests/e2e/json-stringify-space.test.d.ts +6 -0
  174. package/dist/tests/e2e/json-stringify-space.test.js +23 -0
  175. package/dist/tests/e2e/json-stringify-space.test.js.map +1 -0
  176. package/dist/tests/e2e/method-dispatch-errors.test.d.ts +9 -0
  177. package/dist/tests/e2e/method-dispatch-errors.test.js +38 -0
  178. package/dist/tests/e2e/method-dispatch-errors.test.js.map +1 -0
  179. package/dist/tests/e2e/native-extensions.test.js +1 -1
  180. package/dist/tests/e2e/native-extensions.test.js.map +1 -1
  181. package/dist/tests/e2e/promise-with-resolvers.test.d.ts +5 -0
  182. package/dist/tests/e2e/promise-with-resolvers.test.js +20 -0
  183. package/dist/tests/e2e/promise-with-resolvers.test.js.map +1 -0
  184. package/dist/tests/e2e/property-descriptors.test.d.ts +5 -0
  185. package/dist/tests/e2e/property-descriptors.test.js +25 -0
  186. package/dist/tests/e2e/property-descriptors.test.js.map +1 -0
  187. package/dist/tests/e2e/property-ic.test.d.ts +1 -0
  188. package/dist/tests/e2e/property-ic.test.js +55 -0
  189. package/dist/tests/e2e/property-ic.test.js.map +1 -0
  190. package/dist/tests/e2e/runtime-coverage-globals.test.js +46 -0
  191. package/dist/tests/e2e/runtime-coverage-globals.test.js.map +1 -1
  192. package/dist/tests/e2e/runtime-errors.test.d.ts +10 -0
  193. package/dist/tests/e2e/runtime-errors.test.js +52 -0
  194. package/dist/tests/e2e/runtime-errors.test.js.map +1 -0
  195. package/dist/tests/e2e/string-utf16.test.d.ts +6 -0
  196. package/dist/tests/e2e/string-utf16.test.js +133 -0
  197. package/dist/tests/e2e/string-utf16.test.js.map +1 -0
  198. package/dist/tests/e2e/structured-clone.test.d.ts +6 -0
  199. package/dist/tests/e2e/structured-clone.test.js +49 -0
  200. package/dist/tests/e2e/structured-clone.test.js.map +1 -0
  201. package/dist/tests/e2e/text-codec.test.d.ts +6 -0
  202. package/dist/tests/e2e/text-codec.test.js +24 -0
  203. package/dist/tests/e2e/text-codec.test.js.map +1 -0
  204. package/dist/tests/e2e/typed-array-views.test.d.ts +6 -0
  205. package/dist/tests/e2e/typed-array-views.test.js +39 -0
  206. package/dist/tests/e2e/typed-array-views.test.js.map +1 -0
  207. package/dist/tests/e2e/url-search-params.test.d.ts +5 -0
  208. package/dist/tests/e2e/url-search-params.test.js +30 -0
  209. package/dist/tests/e2e/url-search-params.test.js.map +1 -0
  210. package/dist/tests/e2e/weak-collections.test.d.ts +1 -0
  211. package/dist/tests/e2e/weak-collections.test.js +88 -0
  212. package/dist/tests/e2e/weak-collections.test.js.map +1 -0
  213. package/dist/tests/parser/declarations.test.js +12 -0
  214. package/dist/tests/parser/declarations.test.js.map +1 -1
  215. package/dist/tests/parser/module-syntax.test.js +9 -0
  216. package/dist/tests/parser/module-syntax.test.js.map +1 -1
  217. package/dist/tests/parser/parser.test.js +7 -0
  218. package/dist/tests/parser/parser.test.js.map +1 -1
  219. package/dist/tests/version.test.js +5 -1
  220. package/dist/tests/version.test.js.map +1 -1
  221. package/doc/ai/README.md +4 -3
  222. package/doc/ai/cli.md +41 -0
  223. package/doc/ai/contributing.md +26 -21
  224. package/doc/ai/extensions.md +12 -9
  225. package/doc/ai/language-support.md +26 -19
  226. package/doc/ai/troubleshooting.md +15 -12
  227. package/doc/ai/zh-CN/README.md +3 -2
  228. package/doc/ai/zh-CN/cli.md +35 -0
  229. package/doc/ai/zh-CN/contributing.md +19 -18
  230. package/doc/ai/zh-CN/extensions.md +10 -7
  231. package/doc/ai/zh-CN/language-support.md +26 -20
  232. package/doc/ai/zh-CN/troubleshooting.md +12 -10
  233. package/doc/gui/build.md +13 -4
  234. package/doc/gui/known-issues.md +9 -5
  235. package/doc/gui/rendering.md +3 -1
  236. package/doc/gui.md +4 -3
  237. package/doc/icon.md +5 -4
  238. package/doc/implemented/async.md +38 -0
  239. package/doc/implemented/binder.md +13 -0
  240. package/doc/implemented/cli.md +47 -0
  241. package/doc/implemented/codegen.md +33 -0
  242. package/doc/implemented/collections.md +26 -0
  243. package/doc/implemented/driver.md +19 -0
  244. package/doc/implemented/extensions.md +19 -0
  245. package/doc/implemented/fetch.md +12 -0
  246. package/doc/implemented/lexer.md +23 -0
  247. package/doc/implemented/modules.md +28 -0
  248. package/doc/implemented/node/assert.md +17 -0
  249. package/doc/implemented/node/buffer.md +29 -0
  250. package/doc/implemented/node/child-process.md +29 -0
  251. package/doc/implemented/node/crypto.md +9 -0
  252. package/doc/implemented/node/dgram.md +15 -0
  253. package/doc/implemented/node/events.md +37 -0
  254. package/doc/implemented/node/fs-promises.md +38 -0
  255. package/doc/implemented/node/fs.md +112 -0
  256. package/doc/implemented/node/http.md +21 -0
  257. package/doc/implemented/node/net.md +17 -0
  258. package/doc/implemented/node/os.md +22 -0
  259. package/doc/implemented/node/path.md +33 -0
  260. package/doc/implemented/node/process.md +23 -0
  261. package/doc/implemented/node/querystring.md +20 -0
  262. package/doc/implemented/node/stream-promises.md +8 -0
  263. package/doc/implemented/node/stream.md +19 -0
  264. package/doc/implemented/node/test.md +10 -0
  265. package/doc/implemented/node/url.md +8 -0
  266. package/doc/implemented/node/util.md +25 -0
  267. package/doc/implemented/node/worker-threads.md +10 -0
  268. package/doc/implemented/node/zlib.md +8 -0
  269. package/doc/implemented/node.md +48 -0
  270. package/doc/implemented/operators.md +38 -0
  271. package/doc/implemented/parser.md +58 -0
  272. package/doc/implemented/pipeline.md +28 -0
  273. package/doc/implemented/runtime-core.md +32 -0
  274. package/doc/implemented/stdlib.md +78 -0
  275. package/doc/implemented/strings.md +27 -0
  276. package/doc/implemented/tests.md +10 -0
  277. package/doc/implemented/typed-arrays.md +26 -0
  278. package/doc/implemented/value-model.md +18 -0
  279. package/doc/implemented.md +54 -352
  280. package/doc/node-implemented.md +3 -585
  281. package/doc/node-unimplemented.md +3 -164
  282. package/doc/requirements.md +23 -8
  283. package/doc/unimplemented/classes.md +22 -0
  284. package/doc/unimplemented/deviations.md +27 -0
  285. package/doc/unimplemented/expressions.md +26 -0
  286. package/doc/unimplemented/functions.md +21 -0
  287. package/doc/unimplemented/modules.md +22 -0
  288. package/doc/unimplemented/node/async.md +17 -0
  289. package/doc/unimplemented/node/bun.md +9 -0
  290. package/doc/unimplemented/node/fs-promises.md +16 -0
  291. package/doc/unimplemented/node/fs.md +31 -0
  292. package/doc/unimplemented/node/globals.md +23 -0
  293. package/doc/unimplemented/node/modules.md +21 -0
  294. package/doc/unimplemented/node.md +21 -0
  295. package/doc/unimplemented/statements.md +18 -0
  296. package/doc/unimplemented/stdlib.md +54 -0
  297. package/doc/unimplemented/toolchain.md +14 -0
  298. package/doc/unimplemented/types.md +12 -0
  299. package/doc/unimplemented.md +18 -274
  300. package/doc/xbintsc.config.schema.json +12 -0
  301. package/doc/zh-CN/gui/build.md +11 -3
  302. package/doc/zh-CN/gui/known-issues.md +9 -4
  303. package/doc/zh-CN/gui/rendering.md +2 -1
  304. package/doc/zh-CN/gui.md +3 -2
  305. package/doc/zh-CN/icon.md +5 -4
  306. package/doc/zh-CN/implemented/async.md +38 -0
  307. package/doc/zh-CN/implemented/binder.md +13 -0
  308. package/doc/zh-CN/implemented/cli.md +46 -0
  309. package/doc/zh-CN/implemented/codegen.md +33 -0
  310. package/doc/zh-CN/implemented/collections.md +26 -0
  311. package/doc/zh-CN/implemented/driver.md +19 -0
  312. package/doc/zh-CN/implemented/extensions.md +19 -0
  313. package/doc/zh-CN/implemented/fetch.md +12 -0
  314. package/doc/zh-CN/implemented/lexer.md +23 -0
  315. package/doc/zh-CN/implemented/modules.md +28 -0
  316. package/doc/zh-CN/implemented/node/assert.md +17 -0
  317. package/doc/zh-CN/implemented/node/buffer.md +25 -0
  318. package/doc/zh-CN/implemented/node/child-process.md +27 -0
  319. package/doc/zh-CN/implemented/node/crypto.md +9 -0
  320. package/doc/zh-CN/implemented/node/dgram.md +15 -0
  321. package/doc/zh-CN/implemented/node/events.md +36 -0
  322. package/doc/zh-CN/implemented/node/fs-promises.md +27 -0
  323. package/doc/zh-CN/implemented/node/fs.md +105 -0
  324. package/doc/zh-CN/implemented/node/http.md +17 -0
  325. package/doc/zh-CN/implemented/node/net.md +17 -0
  326. package/doc/zh-CN/implemented/node/os.md +21 -0
  327. package/doc/zh-CN/implemented/node/path.md +26 -0
  328. package/doc/zh-CN/implemented/node/process.md +23 -0
  329. package/doc/zh-CN/implemented/node/querystring.md +20 -0
  330. package/doc/zh-CN/implemented/node/stream-promises.md +8 -0
  331. package/doc/zh-CN/implemented/node/stream.md +15 -0
  332. package/doc/zh-CN/implemented/node/test.md +10 -0
  333. package/doc/zh-CN/implemented/node/url.md +8 -0
  334. package/doc/zh-CN/implemented/node/util.md +25 -0
  335. package/doc/zh-CN/implemented/node/worker-threads.md +9 -0
  336. package/doc/zh-CN/implemented/node/zlib.md +8 -0
  337. package/doc/zh-CN/implemented/node.md +45 -0
  338. package/doc/zh-CN/implemented/operators.md +38 -0
  339. package/doc/zh-CN/implemented/parser.md +58 -0
  340. package/doc/zh-CN/implemented/pipeline.md +25 -0
  341. package/doc/zh-CN/implemented/runtime-core.md +31 -0
  342. package/doc/zh-CN/implemented/stdlib.md +76 -0
  343. package/doc/zh-CN/implemented/strings.md +27 -0
  344. package/doc/zh-CN/implemented/tests.md +10 -0
  345. package/doc/zh-CN/implemented/typed-arrays.md +26 -0
  346. package/doc/zh-CN/implemented/value-model.md +18 -0
  347. package/doc/zh-CN/implemented.md +50 -347
  348. package/doc/zh-CN/node-implemented.md +4 -531
  349. package/doc/zh-CN/node-unimplemented.md +4 -139
  350. package/doc/zh-CN/plan-require-node-modules.md +4 -4
  351. package/doc/zh-CN/requirements.md +20 -6
  352. package/doc/zh-CN/unimplemented/classes.md +22 -0
  353. package/doc/zh-CN/unimplemented/deviations.md +24 -0
  354. package/doc/zh-CN/unimplemented/expressions.md +24 -0
  355. package/doc/zh-CN/unimplemented/functions.md +21 -0
  356. package/doc/zh-CN/unimplemented/modules.md +19 -0
  357. package/doc/zh-CN/unimplemented/node/async.md +17 -0
  358. package/doc/zh-CN/unimplemented/node/bun.md +8 -0
  359. package/doc/zh-CN/unimplemented/node/fs-promises.md +12 -0
  360. package/doc/zh-CN/unimplemented/node/fs.md +24 -0
  361. package/doc/zh-CN/unimplemented/node/globals.md +14 -0
  362. package/doc/zh-CN/unimplemented/node/modules.md +15 -0
  363. package/doc/zh-CN/unimplemented/node.md +18 -0
  364. package/doc/zh-CN/unimplemented/statements.md +15 -0
  365. package/doc/zh-CN/unimplemented/stdlib.md +54 -0
  366. package/doc/zh-CN/unimplemented/toolchain.md +14 -0
  367. package/doc/zh-CN/unimplemented/types.md +11 -0
  368. package/doc/zh-CN/unimplemented.md +14 -236
  369. package/llms.txt +32 -4
  370. package/package.json +1 -1
  371. package/runtime/ext_gui/renderer_shaders.h +2 -2
  372. package/runtime/ext_gui/stb_image.h +1 -17
  373. package/runtime/ext_node/child_process/child_process.c +173 -73
  374. package/runtime/rt.h +47 -0
  375. package/runtime/rt_internal.h +205 -10
  376. package/runtime/xt_alloc.c +49 -7
  377. package/runtime/xt_array_buffer.c +284 -0
  378. package/runtime/xt_async.c +222 -0
  379. package/runtime/xt_bigint/helpers.inc +3 -3
  380. package/runtime/xt_builtins.c +59 -51
  381. package/runtime/xt_constructors.c +399 -0
  382. package/runtime/xt_containers/access.inc +195 -14
  383. package/runtime/xt_containers/arrays.inc +26 -2
  384. package/runtime/xt_containers/objects.inc +226 -5
  385. package/runtime/xt_containers/shapes.inc +71 -0
  386. package/runtime/xt_containers.c +1 -0
  387. package/runtime/xt_coroutine.c +229 -0
  388. package/runtime/xt_generator.c +325 -167
  389. package/runtime/xt_io/inspect.inc +147 -2
  390. package/runtime/xt_loop.c +35 -4
  391. package/runtime/xt_performance.c +37 -0
  392. package/runtime/xt_promise.c +125 -18
  393. package/runtime/xt_stdlib/arrays.inc +1 -1
  394. package/runtime/xt_stdlib/dispatch.inc +64 -13
  395. package/runtime/xt_stdlib/strings.inc +74 -17
  396. package/runtime/xt_stdlib2/array-statics.inc +28 -3
  397. package/runtime/xt_stdlib2/arrays.inc +5 -3
  398. package/runtime/xt_stdlib2/container.inc +5 -0
  399. package/runtime/xt_stdlib2/date.inc +111 -3
  400. package/runtime/xt_stdlib2/error.inc +35 -0
  401. package/runtime/xt_stdlib2/json.inc +353 -33
  402. package/runtime/xt_stdlib2/number-string-statics.inc +24 -15
  403. package/runtime/xt_stdlib2/objects.inc +123 -1
  404. package/runtime/xt_stdlib2/regexp-match.inc +2 -2
  405. package/runtime/xt_stdlib2/set.inc +7 -1
  406. package/runtime/xt_stdlib2/strings.inc +70 -40
  407. package/runtime/xt_structured_clone.c +159 -0
  408. package/runtime/xt_symbol.c +2 -2
  409. package/runtime/xt_text_codec.c +69 -0
  410. package/runtime/xt_typed_array/construction.inc +78 -7
  411. package/runtime/xt_typed_array/elements.inc +159 -0
  412. package/runtime/xt_typed_array/methods.inc +21 -5
  413. package/runtime/xt_typed_array.c +11 -10
  414. package/runtime/xt_url.c +375 -0
  415. package/runtime/xt_values/arithmetic.inc +2 -2
  416. package/runtime/xt_values/constructors.inc +8 -0
  417. package/runtime/xt_values/conversions.inc +1 -1
  418. package/runtime/xt_values/strings.inc +19 -3
  419. package/runtime/xt_values/utf16.inc +340 -0
  420. package/runtime/xt_values.c +1 -0
  421. package/runtime/xt_weak.c +281 -0
  422. package/scripts/build-gui.ts +133 -60
  423. package/scripts/check-version.ts +3 -3
  424. package/src/binder/declarations.ts +14 -3
  425. package/src/cli/hints.ts +8 -1
  426. package/src/cli/main.ts +119 -18
  427. package/src/cli/watch.ts +101 -0
  428. package/src/codegen/generator/calls/access.ts +17 -4
  429. package/src/codegen/generator/calls/closures.ts +12 -1
  430. package/src/codegen/generator/calls/invocation.ts +4 -3
  431. package/src/codegen/generator/context.ts +23 -3
  432. package/src/codegen/generator/expressions/operators.ts +27 -13
  433. package/src/codegen/generator/expressions/primary.ts +10 -1
  434. package/src/codegen/generator/module.ts +10 -19
  435. package/src/codegen/generator/numeric.ts +85 -11
  436. package/src/codegen/generator/state.ts +27 -0
  437. package/src/codegen/generator/statements/control-flow.ts +2 -6
  438. package/src/codegen/generator/statements/loops.ts +50 -16
  439. package/src/codegen/generator/tables.ts +110 -3
  440. package/src/diagnostics/diagnostic.ts +23 -3
  441. package/src/driver/app-artifacts.ts +77 -0
  442. package/src/driver/build-key.ts +55 -0
  443. package/src/driver/bundler/graph.ts +63 -13
  444. package/src/driver/bundler/merge.ts +4 -1
  445. package/src/driver/compiler.ts +93 -324
  446. package/src/driver/config.ts +11 -0
  447. package/src/driver/frontend.ts +120 -0
  448. package/src/driver/index.ts +0 -1
  449. package/src/driver/options.ts +70 -0
  450. package/src/driver/runtime-objects.ts +133 -0
  451. package/src/driver/toolchain-provider.ts +4 -0
  452. package/src/driver/toolchain.ts +154 -10
  453. package/src/driver/version.ts +12 -0
  454. package/src/driver/win-icon.ts +36 -36
  455. package/src/parser/declarations/classes.ts +4 -0
  456. package/src/parser/declarations/functions.ts +12 -1
  457. package/src/parser/modules.ts +8 -4
  458. package/src/parser/parser.ts +28 -0
@@ -16,15 +16,11 @@ npm test # 单元测试 + 端到端测试
16
16
  (见 [troubleshooting.md](./troubleshooting.md))。`xbintsc emit` 既不需要 clang 也不需要
17
17
  运行时库,因此它是最快的内循环。
18
18
 
19
- 可选但推荐——安装仓库钩子:
20
-
21
- ```bash
22
- git config core.hooksPath .githooks
23
- ```
24
-
25
- `.githooks/pre-commit` **会在每次提交时把补丁版本号 +1**,并把 `package.json` 与
26
- `package-lock.json` 一起折进该提交(`npm version patch --no-git-tag-version`)。请预期
27
- 你的提交里会带版本号变更,不要对抗它。发布标签由 `release.yml` 创建,钩子从不打标签。
19
+ 可选:安装仓库钩子 `git config core.hooksPath .githooks`。它只在
20
+ `main`/`master` 上把补丁版本号 +1(同时更新 `package.json`、
21
+ `package-lock.json` 与 `src/driver/version.ts`)。功能分支从不改动这些文件,
22
+ 这正是两个功能分支不会在版本行上冲突的原因;不要在功能分支上改版本号。
23
+ 发布标签由 `release.yml` 创建,钩子从不打标签。
28
24
 
29
25
  ## 测试套件
30
26
 
@@ -67,11 +63,11 @@ gen2 --emit--> gen3.ll # 必须等于 ref.ll
67
63
  必须逐字节确定——包括迭代顺序、生成的符号名与编号。绝不要把不确定性(未受控的
68
64
  `Map`/`Set` 迭代顺序、时间戳、依赖文件系统顺序的东西)引入代码生成。
69
65
 
70
- 第二个推论是字符串模型:编译器自身源码文本在各代中必须含义一致。编译后的字符串是
71
- UTF-8 字节,所以自举后的 `readFileSync`(`--ext node`)交给扫描器的是文件字节,而
72
- Node 交给它的是同一个文件已解码后的文本——读取源码文件一律走 `decodeUtf8`
73
- ([src/diagnostics/utf8.ts](../../../src/diagnostics/utf8.ts)),不要假设一个码元就是
74
- 一个字节或一个字符。弄错的表现是:`gen2.ll` 里非 ASCII 字面量(比如提示语里的 `—`)
66
+ 第二个推论是字符串模型:编译器自身源码文本在各代中必须含义一致。编译后的字符串以 UTF-8
67
+ 存储,但索引按 UTF-16 码元进行,所以自举后的 `readFileSync`(`--ext node`)交给扫描器的是
68
+ 字节串(一个码元一个字节,全部 `<= 0xFF`),而 Node 交给它的是同一个文件已解码后的文本——
69
+ 读取源码文件一律走 `sourceTextBytes`([src/diagnostics/source-text.ts](../../../src/diagnostics/source-text.ts)),
70
+ 不要假设一个码元就是一个字节或一个字符。弄错的表现是:`gen2.ll` 里非 ASCII 字面量(比如提示语里的 `—`)
75
71
  被重新编码,这也正是这里逐字节比较 IR 而不是逐行比较的原因。
76
72
 
77
73
  本地验证:
@@ -111,7 +107,7 @@ npm run runtime # tsx scripts/build-runtime.ts -> runtime/lib/<os>-<a
111
107
  npm run runtime:clean # 删除 build/runtime-obj 与 runtime/lib
112
108
  ```
113
109
 
114
- 新增 C 文件时必须同时更新列出运行时源文件的地方([../../../src/driver/compiler.ts](../../../src/driver/compiler.ts)
110
+ 新增 C 文件时必须同时更新列出运行时源文件的地方([../../../src/driver/runtime-objects.ts](../../../src/driver/runtime-objects.ts)
115
111
  里的 `RUNTIME_SOURCES`),因为那份列表决定什么会被编译和链接。扩展的 C 源由扩展自己声明。
116
112
 
117
113
  ## 新增或扩展一个扩展
@@ -153,13 +149,18 @@ src/extensions/node/fs/index.ts runtime/ext_node/fs/read_file.c
153
149
 
154
150
  | 文档 | 何时更新 |
155
151
  | --- | --- |
156
- | [../../zh-CN/implemented.md](../../zh-CN/implemented.md) | 某特性开始可用 |
157
- | [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) | 出现或解除了某个限制 |
158
- | [../../zh-CN/node-implemented.md](../../zh-CN/node-implemented.md) / [../../zh-CN/node-unimplemented.md](../../zh-CN/node-unimplemented.md) | Node 模块覆盖变化 |
152
+ | [../../zh-CN/implemented/](../../zh-CN/implemented/) 中拥有该功能的页面 | 某特性开始可用 |
153
+ | [../../zh-CN/unimplemented/](../../zh-CN/unimplemented/) 中拥有该限制的页面 | 出现或解除了某个限制 |
154
+ | [../../zh-CN/implemented.md](../../zh-CN/implemented.md) / [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) | 新增整页时(在索引里加链接) |
155
+ | [../../zh-CN/implemented/node.md](../../zh-CN/implemented/node.md) / [../../zh-CN/unimplemented/node.md](../../zh-CN/unimplemented/node.md) | Node 模块覆盖变化 |
159
156
  | [language-support.md](./language-support.md) | 上述内容的 AI 摘要变化 |
160
157
  | [../../zh-CN/requirements.md](../../zh-CN/requirements.md) | 工具链或平台要求变化 |
161
158
  | [cli.md](./cli.md) | 参数、配置字段或环境变量变化 |
162
159
 
160
+ 每个功能域只拥有一个小页面,因此功能分支改自己领域的页面(以及它的中文翻译),
161
+ 而不是一份大文档。索引页的「改动应该写在哪一页?」表把改动映射到页面。
162
+ `tests/docs/structure.test.ts` 会检查每个英文页面都有中文对应页,且都被索引链接。
163
+
163
164
  中文翻译(`doc/zh-CN/`、`doc/ai/zh-CN/`)要与英文源同步;半翻译的页面比没有更糟,因为
164
165
  它会静默过期。
165
166
 
@@ -49,11 +49,12 @@ xbintsc run app.ts --ext node
49
49
  | `util`、`querystring`、`url`、`assert`、`test`、`zlib` | |
50
50
 
51
51
  各模块的具体覆盖(确切函数与选项)见
52
- [../../zh-CN/node-implemented.md](../../zh-CN/node-implemented.md),缺失项见
53
- [../../zh-CN/node-unimplemented.md](../../zh-CN/node-unimplemented.md)。
52
+ [../../zh-CN/implemented/node.md](../../zh-CN/implemented/node.md),缺失项见
53
+ [../../zh-CN/unimplemented/node.md](../../zh-CN/unimplemented/node.md)。
54
54
 
55
55
  在 `net`/`http` 上搭东西之前,先记住运行时模型:事件循环在**程序主体之后**才运行,
56
- 而 `async`/`await` 是同步微任务模型。见 [language-support.md](./language-support.md)。
56
+ 但 `async`/`await` 现在会在 pending Promise 上挂起,因此由套接字回调 settle 的 Promise
57
+ 可以被 await。见 [language-support.md](./language-support.md)。
57
58
 
58
59
  ### `gui` —— HTML/CSS 窗口
59
60
 
@@ -81,9 +82,10 @@ Windows 唯一不支持的:Windows 的 `gui.a` 不构建 FFmpeg,媒体槽位
81
82
 
82
83
  ## 第三方 npm 包
83
84
 
84
- 没有被已启用扩展认领的裸说明符,会在 `node_modules` 里查找并**作为源码**打包。不是
85
- 纯 ESM TypeScript/JavaScript 的包——或依赖 CommonJS、`require`、`__dirname`、循环
86
- 依赖的包——都不会工作。`require()` 会被拒绝并提示改用 `import`。
85
+ 没有被已启用扩展认领的裸说明符,会在 `node_modules` 里查找并**作为源码**打包,
86
+ CommonJS 包也在支持范围内(打包器会给它合成 `module`/`exports`,并降级其中的
87
+ `require` 调用)。不支持的场景:动态 `require(<表达式>)`、依赖 `__dirname` 等 Node
88
+ 全局变量的包,以及循环依赖。自己源码里的 `require()` 会被拒绝并提示改用 `import`。
87
89
 
88
90
  实践结论:写 Node 程序时,正确做法通常就是开 `--ext node`;只有确实必要时才去依赖
89
91
  npm 包。
@@ -126,7 +128,8 @@ xbintsc build demo.ts --ext-native a.json,b.json # 多个
126
128
  与值的辅助函数。关键 ABI 事实:值是 64 位 NaN-boxed 字;字符串**不**以 NUL 结尾,
127
129
  所以要把 `xt_string_data` 与 `xt_string_length_value` 配对使用;运行时交给你的内存
128
130
  不会被移动或释放。请使用与 xbintsc 解析到的同一个 clang/ABI 构建(`xbintsc doctor`
129
- 会打印它);在 Windows 上要在 **x64/ARM64 Native Tools 命令提示符**里构建。
131
+ 会打印它)。Windows 上必须是面向 MSVC 的 clang,通常就是 Visual Studio 自带的
132
+ LLVM;不需要开发者命令提示符。
130
133
 
131
134
  可直接照抄的工程:[`examples/extensions/cpp`](../../../examples/extensions/cpp) 与
132
135
  [`examples/extensions/rust`](../../../examples/extensions/rust);完整指南见
@@ -6,8 +6,8 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
6
6
  权威细节(始终最新、篇幅长得多):
7
7
 
8
8
  - [../../zh-CN/implemented.md](../../zh-CN/implemented.md) —— 所有已实现能力,按编译器阶段组织
9
- - [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) —— 不支持的语法、行为偏差、速查表
10
- - [../../zh-CN/node-implemented.md](../../zh-CN/node-implemented.md) / [../../zh-CN/node-unimplemented.md](../../zh-CN/node-unimplemented.md) —— Node 扩展
9
+ - [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) —— 不支持的语法、行为偏差,按领域分页
10
+ - [../../zh-CN/implemented/node.md](../../zh-CN/implemented/node.md) / [../../zh-CN/unimplemented/node.md](../../zh-CN/unimplemented/node.md) —— Node 扩展
11
11
 
12
12
  ## 图例
13
13
 
@@ -28,7 +28,7 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
28
28
  | `function`、箭头函数、默认参数/剩余参数 | ✅ | |
29
29
  | `namespace`/`module` 声明 | 🚫 | 解析 ✓,代码生成 ✗ |
30
30
  | `with`、`debugger` | 🚫 | 不支持 |
31
- | 顶层 `await` | 🚫 | 请包进 `async` 函数 |
31
+ | 顶层 `await` | ⚠️ | 会在事件循环上阻塞直到 Promise settle(不会像 ES module 那样让出模块主体);建议包进 `async` 函数 |
32
32
 
33
33
  ## 表达式与运算符
34
34
 
@@ -60,7 +60,7 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
60
60
  | `#private` 字段/方法/静态成员 | ⚠️ | 以字面量 `#x` 键存储;不做访问控制;父子类同名可能互相覆盖 |
61
61
  | `enum`/`const enum` | ✅ | 正向 + 反向映射 |
62
62
  | `private`/`protected`/`public`/`readonly`/`abstract`/`implements` | — | 被擦除,无访问控制 |
63
- | 生成器 `function*`、`yield`、`yield*` | ✅ | 不支持 `async` 生成器 |
63
+ | 生成器 `function*`、`yield`、`yield*` | ✅ | 同步与 `async function*`;支持 `for await...of` 与 `Symbol.asyncIterator` |
64
64
  | `arguments` 对象 | ✅ | 隐式提供;箭头函数看到的是自己的参数 |
65
65
  | 参数个数校验 | 🚫 | 从不校验,虽然 `fn.length` 会报声明元数 |
66
66
 
@@ -68,10 +68,13 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
68
68
 
69
69
  | 特性 | 状态 | 说明 |
70
70
  | --- | --- | --- |
71
- | `async`/`await`、`Promise`、`Promise.all` | ⚠️ | **同步微任务模型**——`await` 一个已敲定的 Promise 会同步继续 |
72
- | `setTimeout` 与回调 | ⚠️ | 事件循环在**程序主体之后**才运行,因此定时器里敲定的 Promise 无法被 await |
73
- | 套接字/服务端(`http`、`net`、`dgram`) | ⚠️ | 同一模型:回调在程序主体之后的循环里执行 |
74
- | 真正的异步事件循环、worker 线程 | 🚫 | 未实现 |
71
+ | `async`/`await`、`Promise`、`Promise.all` | ✅ | 真实挂起:async 函数体运行在栈式协程上,等待**未 settle** 的 Promise 时暂停,settle 后恢复。每次 `await` 都会让出一次,已 settle 的值或非 Promise 也会像 Node 一样排入微任务 |
72
+ | `setTimeout` 与回调 | ✅ | 定时器运行在核心事件循环上;`await new Promise(r => setTimeout(r, ms))` 可用 |
73
+ | `queueMicrotask` / `setImmediate` / `performance.now` | ✅ | 微任务与 Promise 共用 FIFO 队列;`setImmediate` 是零延迟定时器,返回数字 id;`performance.now` 返回单调递增的毫秒小数 |
74
+ | 套接字/服务端(`http`、`net`、`dgram`) | ✅ | 回调在事件循环上执行,可以 settle 你正在 await 的 Promise(测试含 `net`/`http` 示例) |
75
+ | `fs/promises` | ⚠️ | 可以 await,但每次调用仍先同步完成 I/O 再 settle,I/O 期间不会让出 |
76
+ | worker 线程 | 🚫 | worker 是子进程 |
77
+ | `async` 生成器 | ✅ | 可在 `await` 与 `yield` 处挂起;每次 `.next()` 返回 Promise;支持 `for await...of` |
75
78
 
76
79
  ## 类型:解析后擦除
77
80
 
@@ -90,20 +93,22 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
90
93
 
91
94
  ## 标准库
92
95
 
93
- 已实现:`Math`、`JSON`、`Date`、`RegExp`、`Map`、`Set`、`WeakMap`/`WeakSet`、
96
+ 已实现:`Math`、`JSON`、`Date`、`RegExp`、`Map`、`Set`、`WeakMap`/`WeakSet`/`WeakRef`、
94
97
  `Symbol`、`Error` 家族、`BigInt`、`Array`/`String`/`Number`/`Object` 方法、TypedArray、
95
98
  带捕获组的 `String.prototype.match`/`split`/`replace`、不可变数组方法
96
- (`toReversed`、`toSorted`、`toSpliced`、`with`)、全局 URI 函数。
99
+ (`toReversed`、`toSorted`、`toSpliced`、`with`)、全局 URI 函数、
100
+ 一等公民内建构造器(`const A = Array; new A(...)`、`A.isArray`、`x instanceof A`)
101
+ 与 `Object.prototype`(`Object.getPrototypeOf({}) === Object.prototype`)。
97
102
 
98
103
  | 缺失或行为不同 | 状态 |
99
104
  | --- | --- |
100
- | `String.prototype.normalize`、`structuredClone` | 🚫 |
105
+ | `String.prototype.normalize` | 🚫 |
106
+ | `structuredClone` | ✅ 数组、对象、Map、Set、Date、RegExp 与类型化数组 |
101
107
  | `Error.stack` 采集 | ⚠️ 函数级帧(名称/文件/行号),没有列号;生成器函数体不产生帧 |
102
- | `Object.getPrototypeOf({})` | ⚠️ 返回 `undefined`,而非 `Object.prototype` |
103
108
  | 全局 RegExp `lastIndex` | ⚠️ `/g`、`/y` 下 `test`/`exec` 忽略它 |
104
109
  | 稀疏数组空洞、数组越界 | ⚠️ 不区分空洞;越界读得 `undefined` |
105
110
 
106
- 完整列表见 [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) 第 3 节。
111
+ 完整列表见[未实现:标准库](../../unimplemented/stdlib.md)。
107
112
 
108
113
  ## 模块
109
114
 
@@ -113,9 +118,9 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
113
118
  | 相对路径多文件打包 | ✅ | `./helper.js` 会解析到 `helper.ts` |
114
119
  | `import * as ns`、默认导入与具名导入 | ✅ | |
115
120
  | Node 内置模块 | ✅ | 仅在 `--ext node` 下——见 [extensions.md](./extensions.md) |
116
- | 裸第三方 npm 包 | 🚫 | 只有当没有扩展认领该说明符时,`node_modules` 的 ESM 包才会作为源码打包 |
117
- | `require()` / CommonJS | 🚫 | 被拒绝,并提示改用 `import` |
118
- | 循环依赖 | 🚫 | |
121
+ | 裸第三方 npm 包 | ⚠️ | 从 `node_modules` 解析并作为源码打包(ESM 和 CommonJS 均支持);运行时不做包查找,循环依赖会被拒绝 |
122
+ | `require()` / CommonJS | ⚠️ | 在自己的源码里会被拒绝并提示改用 `import`;`node_modules` 内的 CommonJS 包由打包器处理 |
123
+ | 循环依赖 | 🚫 | 仅限值导入;`import type` / `export type` 会被擦除,不构成依赖边 |
119
124
  | 实时绑定 | ⚠️ | 导入与命名空间成员都是快照 |
120
125
  | `__dirname`、`__filename` | 🚫 | 请使用 `import.meta.dirname` / `import.meta.filename` |
121
126
 
@@ -123,17 +128,18 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
123
128
 
124
129
  | 项目 | 行为 |
125
130
  | --- | --- |
126
- | `String.prototype.length` | ⚠️ 按 **UTF-8 字节**计,不是 UTF-16 码元:`"é".length === 1`,`"😀".length === 4`;`codePointAt` 相应不同 |
131
+ | `String.prototype.length` | ✅ UTF-16 码元(`"中文😀".length === 4`);索引、`slice`、`indexOf`、`split`、`padStart`、`codePointAt` 使用同一模型。底层仍以 UTF-8 存储 |
132
+ | 正则 Unicode 匹配 | ⚠️ 引擎按字节工作:字面量 `中` 仍能匹配,但 `.` 与字符类每次只消费一个字节,`\d`/`\w` 仍是 ASCII。匹配偏移(`match.index`、`search`、替换回调)按 UTF-16 码元报告 |
127
133
  | 数字格式化与强转 | ✅ 与 Node 一致(`toFixed`、`toPrecision`、十六/八/二进制解析) |
128
134
  | `BigInt` | ✅ 已实现 |
129
- | 垃圾回收 | ✅ 非移动标记清扫;显式根 + C 栈保守扫描;单线程、stop-the-world;无弱引用 |
135
+ | 垃圾回收 | ✅ 非移动标记清扫;显式根 + C 栈保守扫描;单线程、stop-the-world。`WeakMap`/`WeakSet` 键使用 ephemeron 不动点,`WeakRef` 目标不可达时清空;保守栈上的残留字可能延迟清空 |
130
136
  | 线程 | 🚫 单线程;`worker_threads` 只存在于 Node 扩展中 |
131
137
 
132
138
  ## 平台
133
139
 
134
140
  构建目标覆盖 macOS、Linux、Windows 的 x64 与 arm64。Windows 上是 **MSVC ABI**,
135
- clang 需要 MSVC/SDK 环境——见 [../../zh-CN/requirements.md](../../zh-CN/requirements.md)。
136
- 需要 clang **16 或更新**。
141
+ 编译器必须是面向 MSVC 的 clang(Visual Studio 自带的 LLVM 即可)——见
142
+ [../../zh-CN/requirements.md](../../zh-CN/requirements.md)。需要 clang **16 或更新**。
137
143
 
138
144
  ## 写大程序之前
139
145
 
@@ -47,10 +47,10 @@ export xbintsc_CLANG=/usr/lib/llvm-18/bin/clang
47
47
  xbintsc run app.ts --ext node
48
48
  ```
49
49
 
50
- ### `module '<pkg>' is not supported: xbintsc can import built-in platform modules, relative '.ts' files and ESM packages under node_modules; CommonJS packages are not supported`
50
+ ### `module '<pkg>' is not supported: expected a Node built-in (with --ext node), a relative .ts/.js file, or a package in node_modules`
51
51
 
52
- 一个没人认领、也链不进来的裸第三方导入。要么该包是 CommonJS(不支持),要么它是
53
- 打包失败的 ESM 包。优先改用 `node` 扩展提供的 Node 内置模块;可打包的范围见
52
+ 一个既没有被已启用扩展认领、也没能在 `node_modules` 里解析到的裸导入。检查包名和它的
53
+ `exports`/`main` 字段,或改用 `node` 扩展提供的 Node 内置模块;可打包的范围见
54
54
  [extensions.md](./extensions.md)。
55
55
 
56
56
  ### ``CommonJS `require()` is not supported``
@@ -91,9 +91,10 @@ clang 自身失败。抛出的消息包含完整的 clang 命令与 stderr——
91
91
  第一行。常见原因:
92
92
 
93
93
  - 工具链太旧(见上文);
94
- - Windows 上 clang 因为环境没导入而找不到 MSVC/SDK 头文件或库。请在
95
- **x64 Native Tools Command Prompt for VS 2022**(ARM64 机器上是 **ARM64 Native
96
- Tools**)里运行,或先导入环境:
94
+ - Windows 上解析到的 clang 找不到 MSVC/SDK 头文件或库。`xbintsc doctor` 会显示
95
+ 编译器及其目标;优先使用 Visual Studio 自带的 LLVM,它会自行定位 SDK。如果你的
96
+ 安装仍需要显式导入环境,请在 **x64 Native Tools Command Prompt for VS 2022**
97
+ (ARM64 机器上是 **ARM64 Native Tools**)里运行,或先导入环境:
97
98
  ```powershell
98
99
  & "$env:ProgramFiles\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
99
100
  ```
@@ -110,8 +111,8 @@ clang 自身失败。抛出的消息包含完整的 clang 命令与 stderr——
110
111
  ### `Icon file not found` / 图标工具缺失
111
112
 
112
113
  `--icon`/`app.icon` 的路径相对配置文件目录解析。Windows 上嵌入 PE 图标需要
113
- `llvm-rc` 或 `windres`;`doctor` 会报告找到了哪个,只有在确实请求了图标时缺失才是
114
- 致命错误。
114
+ `llvm-rc`(随 LLVM 一起安装);`doctor` 会报告解析到的工具,只有在确实请求了
115
+ 图标时缺失才是致命错误。
115
116
 
116
117
  ## 怎么看堆栈
117
118
 
@@ -166,8 +167,9 @@ gdb ./build/app # 或 lldb ./build/app,Windows 用 WinDbg 打开 .exe
166
167
 
167
168
  ### 程序输出顺序出乎意料
168
169
 
169
- `async`/`await` 是同步微任务模型,且事件循环只在程序主体之后运行,所以定时器和套接字
170
- 回调会晚触发;见 [language-support.md](./language-support.md)。
170
+ `async`/`await` 只在 **pending** Promise 上挂起;等待已 settle 的值会同步继续,而 Node
171
+ 会排入微任务,因此顺序可能不同。事件循环仍在程序主体之后启动,定时器与套接字回调依然
172
+ 在主体之后触发;见 [language-support.md](./language-support.md)。
171
173
 
172
174
  ## 该去源码哪里看
173
175
 
package/doc/gui/build.md CHANGED
@@ -19,10 +19,19 @@
19
19
  - `src/extensions/gui/index.ts` exposes the archive through `nativeObjects()`
20
20
  (via `findRuntimeLibrary`, so `.a`/`.lib` both work) and the OS frameworks
21
21
  through `linkerFlags()`.
22
+ - `scripts/build-gui.ts` compiles with the *same* clang the driver resolves
23
+ (`src/driver/toolchain-provider.ts`); on Windows that is the MSVC-targeting
24
+ LLVM bundled with Visual Studio, and its sibling `clang++`/`llvm-ar` are used
25
+ for CMake, the engine and the archive merge. There are no `gcc`/`g++`
26
+ fallbacks, and Windows always uses `llvm-ar`, so the archive cannot mix object
27
+ formats or C++ runtimes. The Visual Studio toolchain is found by absolute
28
+ path, so no developer prompt is required. On Windows SDL_GPU selects the
29
+ Vulkan backend; no DXIL/`dxc` toolchain is needed.
22
30
  - CI builds `gui.a` before assembling the release archive so it ships inside
23
31
  `runtime/lib/<slug>/` (the release tarball copies the whole `runtime/` tree).
24
32
  The archive is built and the example is run on Linux (under Xvfb, with the
25
- lavapipe software Vulkan driver) and macOS; Windows is provisional.
33
+ lavapipe software Vulkan driver) and macOS; Windows is provisional because the
34
+ hosted runners have no GPU/Vulkan driver.
26
35
  - The existing cache fingerprint already hashes `nativeObjects()` contents, so
27
36
  rebuilding `gui.a` invalidates cached binaries automatically.
28
37
  - CMake build trees live *next to* their sources (`vendor/sdl-build`,
@@ -60,9 +69,9 @@ working directory, so run it from the repository root:
60
69
  Set `XT_GUI_AUTOCLOSE_MS=<n>` to close all windows after `n` milliseconds,
61
70
  which the e2e test (`tests/e2e/gui-*.test.ts`) uses to run headlessly.
62
71
 
63
- Those suites are skipped on Windows by default (the archive is built there but
64
- the run is not validated in CI). With a `gui.lib` and a working GPU, opt in with
65
- `xbintsc_GUI_TESTS=1`:
72
+ Those suites are skipped on Windows by default (the archive is built and runs
73
+ locally through Vulkan, but CI runners have no GPU driver to run it). With a
74
+ `gui.lib` and a working GPU, opt in with `xbintsc_GUI_TESTS=1`:
66
75
 
67
76
  ```bat
68
77
  set xbintsc_GUI_TESTS=1
@@ -57,14 +57,17 @@
57
57
  collide: `LNK2038: mismatch detected for 'RuntimeLibrary'` plus a wall of
58
58
  `LNK2005: already defined`, surfaced as `clang: linker command failed with exit
59
59
  code 1169`. `src/extensions/gui/index.ts` now lists only the OS libraries
60
- (`user32`, `gdi32`, `d3d12`, …). A Windows link is also the only place the
61
- MSVC environment matters, so build from an x64 Native Tools prompt.
60
+ (`user32`, `gdi32`, `d3d12`, …). `scripts/build-gui.ts` resolves the same
61
+ MSVC-targeting clang as the driver (the LLVM bundled with Visual Studio when
62
+ no newer one is on `PATH`), so a developer prompt is not required.
62
63
  - Windows: an MSVC-compatible `gui.lib` (COFF objects + `ar -M`/`llvm-ar`) is
63
64
  produced by `scripts/build-gui.ts` but is not validated in CI, so the Windows
64
65
  step is provisional (the job stays green) and `package` skips it. Building and
65
66
  running `examples/gui/pelican-svg` and `examples/gui/pelican-bike` on a
66
- developer machine works. It also needs an SDL3 build with the D3D12/DXIL
67
- backend (DXIL requires `dxc`).
67
+ developer machine works. SDL_GPU selects the **Vulkan** backend there
68
+ (`win.driver()` reports `"vulkan"`), so the archive needs no DXIL/`dxc`
69
+ toolchain; the hosted Windows runners have no GPU/Vulkan driver, which is why
70
+ the CI run stays provisional.
68
71
  - **Media on Windows:** the media decoders (FFmpeg) are only built and merged
69
72
  into the POSIX `gui.a`; the Windows `gui.lib` is produced without them, so
70
73
  `<video>`/`<audio>` are inert there (failures fire `error`). Enabling it needs
@@ -75,4 +78,5 @@
75
78
  and embedded, so the non-Metal path no longer skips geometry. DXIL remains
76
79
  unusable on **SDL 3.2.10**: its D3D12 backend rejects any graphics pipeline
77
80
  whose shaders declare a uniform buffer, and the engine passes the viewport that
78
- way. Re-check after an SDL upgrade.
81
+ way. This does not affect Windows in practice because SDL_GPU selects Vulkan
82
+ there; re-check after an SDL upgrade if the D3D12 path is ever forced.
@@ -43,7 +43,9 @@ its own GPU scissor rectangle (scaled to device pixels), so painter order and
43
43
  Note that SDL 3.2.10's Direct3D 12 backend cannot create a graphics pipeline
44
44
  whose shaders declare a uniform buffer (it fails with `E_INVALIDARG`); the
45
45
  engine passes the viewport that way, so the DXIL path is built but not usable
46
- until that is resolved upstream.
46
+ until that is resolved upstream. Windows does not hit this: SDL_GPU selects the
47
+ Vulkan backend there (confirmed by `win.driver()`), which consumes the SPIR-V
48
+ blobs.
47
49
  - A **rounded-rectangle distance field** in the shape fragment shader gives
48
50
  antialiased fills; the vertex carries `position`, `local`, `half extents`,
49
51
  `radius` and colour, and a viewport-size push constant does the projection.
package/doc/gui.md CHANGED
@@ -179,9 +179,10 @@ engine were Rust.
179
179
  `runtime/`).
180
180
  - `vendor/` (SDL3/FreeType/HarfBuzz, the slow part) is cached per OS/arch,
181
181
  keyed by `scripts/build-gui.ts`.
182
- - Windows (build + run) stays provisional until the MSVC-compatible
183
- `gui.lib` and D3D12/DXIL shader path are validated; a failure is logged
184
- without annotating the run (see [Open questions](./gui/known-issues.md#open-questions)).
182
+ - Windows (build + run) stays provisional in CI: the MSVC-compatible
183
+ `gui.lib` builds and runs locally through SDL_GPU's Vulkan backend, but the
184
+ hosted runners have no GPU/Vulkan driver. A failure is logged without
185
+ annotating the run (see [Open questions](./gui/known-issues.md#open-questions)).
185
186
  8. **M8 — interactive DOM** ✅
186
187
  - Element/document handles with stable identity, read/write properties via
187
188
  runtime accessors, traversal/attributes/queries, mutation with lazy
package/doc/icon.md CHANGED
@@ -160,7 +160,8 @@ does).
160
160
 
161
161
  - `src/cli/main.ts`: `--icon`, `--bundle`, `--app-name`, `--app-id`, `--config`,
162
162
  `--no-config`; merged with the config (`mergeAppConfig`).
163
- - `src/driver/compiler.ts`: `BuildOptions.icon` and `BuildOptions.app`.
163
+ - `src/driver/options.ts`: `BuildOptions.icon` and `BuildOptions.app` (assembled
164
+ into the cache key by `src/driver/build-key.ts`).
164
165
  - The icon **content hash** and the packaging options are part of the
165
166
  executable `cacheKey`, so changing the icon rebuilds.
166
167
  - The icon object and (on win32) the resource object are appended to the link
@@ -175,8 +176,8 @@ does).
175
176
  1. A PNG input is wrapped in a minimal ICO container (`ICONDIR` +
176
177
  `ICONDIRENTRY` pointing at the PNG payload); Vista+ accepts PNG-in-ICO.
177
178
  2. A `.rc` (`1 ICON "icon-<hash>.ico"`) is written next to it in the cache.
178
- 3. `llvm-rc /fo app.res app.rc` (preferred, next to the resolved clang or on
179
- `PATH`), else MinGW `windres app.rc -O coff -o app_res.o`. Override with
179
+ 3. `llvm-rc /fo app.res app.rc` (next to the resolved clang, or on `PATH`).
180
+ `llvm-rc` is probed with `/?` — it has no `--version`. Override it with
180
181
  `xbintsc_RC`.
181
182
  4. If no resource compiler exists, the build continues with the runtime icon only
182
183
  (a cosmetic feature never hard-fails a build).
@@ -234,7 +235,7 @@ ELF has no icon convention. The only in-binary use is the runtime window icon
234
235
 
235
236
  - `tests/driver/config.test.ts` — parse/validate, discovery, path resolution.
236
237
  - `tests/driver/icon.test.ts` — format sniffing, generated C, ICO conversion,
237
- icon object caching, `llvm-rc`/`windres` command lines, mac bundle layout and
238
+ icon object caching, `llvm-rc` command lines, mac bundle layout and
238
239
  fallbacks, and `build()` integration (icon objects linked, missing icon ⇒
239
240
  `DiagnosticCode.IOError`).
240
241
  - `tests/e2e/icon.test.ts` — compiles a real GUI program with `app.icon`,
@@ -0,0 +1,38 @@
1
+ # Async, promises and generators
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/async.md)
4
+
5
+ Location: `runtime/xt_async.c`, `runtime/xt_coroutine.c`, `runtime/xt_promise.c`,
6
+ `runtime/xt_generator.c`, `runtime/xt_loop.c`, `runtime/xt_performance.c`.
7
+
8
+ ## async / await
9
+
10
+ - `async` closures are marked with `xt_function_set_async`; calling one runs the body on a stackful coroutine (`xt_coroutine.c`, `xt_async.c`) and immediately returns a promise.
11
+ - The body runs synchronously until the first `await` of a pending promise, then suspends; settlement queues a microtask that resumes the coroutine.
12
+ - An exception that escapes the body rejects that promise instead of throwing synchronously.
13
+ - `await` on a non-promise or settled promise keeps the synchronous fast path and raises on rejection.
14
+ - Each `async` call owns a private stack and swaps its `try` frame stack and GC stack region, so `await` survives `try`/`finally`, loops and closures. A promise settled from a timer, a socket callback or another coroutine resumes the suspended body on the microtask queue.
15
+
16
+ ## async generators
17
+
18
+ - `async function*` closures are marked with `xt_function_set_async_generator`; each `.next()` / `.throw()` / `.return()` enqueues a request and returns a promise.
19
+ - The body runs on the generator coroutine and may suspend at either `yield` or `await`; `xt_generator_await` parks it on the awaited promise and leaves the current request pending until the next yield or completion.
20
+ - `for await...of` lowers to `xt_async_iter_open` / `xt_async_iter_next` + `xt_await`, so it consumes both async iterables and the synchronous iteration protocol. `Symbol.asyncIterator` is supported.
21
+
22
+ ## Generators
23
+
24
+ - `function*` / `yield` / `yield*`, with `.next()` / `.throw()` / `.return()`, is implemented on the same stackful-coroutine runtime.
25
+ - `for...of`, spread and delegation are supported.
26
+
27
+ ## Promise
28
+
29
+ - Microtask queue (`xt_microtasks`); `xt_promise_ctor/resolve/reject/static` (including `withResolvers`), instance `then` / `catch` / `finally`.
30
+ - `xt_drain_microtasks` empties the queue at program exit, and the event loop drains it between callbacks.
31
+ - `xt_await` queues a microtask for a non-promise or settled value, and suspends the running async coroutine on a pending promise until it settles.
32
+
33
+ ## Timers and the event loop
34
+
35
+ - `setTimeout` / `clearTimeout` / `setInterval` / `clearInterval` / `setImmediate` / `clearImmediate` / `queueMicrotask` and `performance.now` (monotonic fractional milliseconds).
36
+ - Timers use numeric ids; `Timeout` / `Immediate` objects are not implemented.
37
+ - A promise settled from a timer can be awaited: the async body suspends on the pending promise and resumes when the timer fires. Sockets and servers (`net`, `http`, `dgram`) deliver their callbacks on the same loop.
38
+ - `fetch` is blocking and `fs/promises` performs its I/O synchronously before settling — see [Runtime deviations](../unimplemented/deviations.md). Async generator cleanup limits are listed on the same page.
@@ -0,0 +1,13 @@
1
+ # Name binding and scopes (Binder)
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/binder.md)
4
+
5
+ Location: `src/binder/binder.ts`
6
+
7
+ - Scope kinds: module, function, block, `for`, `catch`
8
+ - Symbol kinds: `var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
9
+ - `var` and function declarations hoist to the function scope; `let` / `const` stay block-scoped
10
+ - Identifier → declaration resolution; unresolved identifier collection (`CannotFindName`)
11
+ - Closure capture analysis: outer variables referenced by an inner function are marked `captured` / `boxed`, and capture indices are threaded through intermediate closures
12
+ - Parameters are registered as local symbols; the self-name of a named function expression is registered as `const`
13
+ - Type-only declarations (interface / type alias) do not participate in value capture
@@ -0,0 +1,47 @@
1
+ # CLI and programmatic API
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/cli.md)
4
+
5
+ Location: `src/cli/main.ts`, `src/index.ts`, `bin/xbintsc.js`
6
+
7
+ ## CLI commands
8
+
9
+ ```
10
+ xbintsc build <file.ts> [options] compile to a native binary
11
+ xbintsc run <file.ts> [-- args] compile and run
12
+ xbintsc emit <file.ts> print LLVM IR
13
+ xbintsc version print the version
14
+ xbintsc help help
15
+ ```
16
+
17
+ ## CLI options
18
+
19
+ ```
20
+ -o, --output <path> Output path
21
+ --out <dir> Output directory (default: build/)
22
+ --emit <kind> exe | obj | ir (default: exe)
23
+ -O0..-O3 Optimization level (default: -O2)
24
+ --ext <names> Comma separated extensions (e.g. node)
25
+ --ext-native <m> Register a C++/Rust extension from a JSON manifest
26
+ --config <path> Use a project config (default: xbintsc.config.json)
27
+ --no-config Do not read any project config
28
+ --icon <path> Embed an application icon (PNG/ICO/ICNS)
29
+ --bundle macOS: also produce a .app bundle
30
+ --app-name <name> Bundle / display name
31
+ --app-id <id> macOS bundle identifier (e.g. com.example.demo)
32
+ --force Ignore the incremental cache
33
+ --verbose Print progress information
34
+ ```
35
+
36
+ ## Programmatic API
37
+
38
+ ```ts
39
+ import { build, compileString } from "xbintsc";
40
+
41
+ const { ir } = compileString("console.log(1 + 1);");
42
+ const result = build("program.ts", { emit: "exe", outDir: "build" });
43
+ ```
44
+
45
+ The option and result types (`BuildOptions`, `BuildResult`, `EmitKind`,
46
+ `PhaseTiming`) live in `src/driver/options.ts` and are re-exported from
47
+ `src/driver/compiler.ts` / `xbintsc`.
@@ -0,0 +1,33 @@
1
+ # LLVM IR code generation (Codegen)
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/codegen.md)
4
+
5
+ Location: `src/codegen/llvm.ts`
6
+
7
+ - Emits LLVM IR text (`.ll`); no custom register allocation (relies on `alloca` + mem2reg).
8
+ - Statement / block boundary values live in `alloca`; conditionals and short-circuits materialize into temporary slots instead of `phi`.
9
+ - Property reads are inline-cached per source site: each access owns a zeroed `[2 x i64]` global (`@ic.N`) passed to `xt_get_ic`. Ordinary objects carry an interned hidden-class shape (`xt_shape`, a `(parent, key)` transition tree) and the cache stores `(shape, property index)`, so a hit is a shape-pointer compare plus one key check instead of a linear property scan. Inserts/deletes and integer-key reordering rebuild or transition the shape, which invalidates stale caches; arrays, functions and containers fall back to `xt_get`.
10
+ - Numeric operators keep the inline two-double fast path; operands that are numeric literals skip their tag check. Conditions whose expression is a comparison, `in`, `instanceof` or `!` are already boolean tags, so codegen emits `icmp eq i64 value, XT_TRUE` instead of calling `xt_truthy` (this removes the call from the hot loop condition).
11
+ - Control flow: `if` / `while` / `do` / `for` / `for...of` / `for...in`, `switch`, `try/catch/finally`, `break` / `continue` / `return`.
12
+ - `for...of` and spread iterate arrays, strings, typed arrays, `Map`, `Set`, generators and any object exposing `[Symbol.iterator]()` through `xt_iter_open` → `xt_iter_has` / `xt_iter_value` (`Map` yields `[key, value]` pairs); a non-iterable throws `TypeError`. Arrays also expose a stable `Array.prototype[Symbol.iterator]`; calling it returns an iterator object with `next()` that is itself iterable.
13
+ - `switch` tests each `case` with strict equality, executes on a hit, and falls through until `break`.
14
+ - `try/catch/finally` is implemented with a runtime `_setjmp` frame: `xt_try_enter` pushes, `_setjmp` catches, `xt_throw` long-jumps. The IR passes the caller's frame address (`@llvm.frameaddress(0)`) as the second `_setjmp` argument, matching clang's MSVC lowering: the Windows UCRT `_setjmp` stores that frame in `_JUMP_BUFFER.Frame` and `longjmp` feeds it to `RtlUnwind`, so omitting it made `longjmp` unwind to a bogus target (`STATUS_BAD_FUNCTION_TABLE`). `_setjmp` is used rather than the exported `setjmp` symbol, whose Windows ABI is an incompatible two-argument routine. Functions containing `try` force local variables to stay in memory (inline-asm escape points) so values survive a long jump.
15
+ - `for...in` reuses `xt_object_keys` to enumerate keys (arrays / strings yield string indices).
16
+ - Expressions:
17
+ - Identifiers, numbers, BigInt (arbitrary precision), strings, templates, booleans, `null`, `undefined`, `arguments`
18
+ - Arithmetic / comparison / logical / short-circuit / conditional / bitwise / unary (including `typeof` `void`) / prefix-postfix increment-decrement / compound assignment / logical assignment
19
+ - Array literals (including spread `[...]`), object literals (including shorthand / methods / object spread `{...obj}`)
20
+ - Typed arrays, `ArrayBuffer`, `DataView`, `TextEncoder` / `TextDecoder`: see [Typed arrays and binary data](./typed-arrays.md) and [Strings and text](./strings.md)
21
+ - Property access (with a `length` special case, `Math` constants), element access, calls
22
+ - First-class built-in constructors (`const A = Array`, `const M = Map`, `const E = TypeError`, typed arrays): a bare reference lowers to `xt_builtin_constructor`, giving a cached function with `name` / `length`, a `prototype`, and its statics (`A.isArray`, `A.from`, `M.prototype`, ...). Calling or `new`-ing an alias dispatches to the same runtime constructor, and `x instanceof A` walks the shared prototype chain.
23
+ - Optional chaining `?.` / `?.[]` / `?.()`: nullish check short-circuits to `undefined`
24
+ - `delete`, `in`, `instanceof`
25
+ - `this` (saved to the function's `%saved.this`; arrow functions read from an environment slot), `super` (`super.x` / `super(...)`), `new`, `await`
26
+ - Closures (arrow functions / function expressions) and capture environment construction
27
+ - Classes: constructor closure + prototype object, stored in an LLVM global (`@class.<id>`); instance fields are initialized before the constructor body; `static` members live in the constructor's property bag; `extends` sets up the prototype chain; `super(...)` is invoked through a hidden `__ctor` on the prototype.
28
+ - `async` / `async function*`: closures are marked with `xt_function_set_async` / `xt_function_set_async_generator` and run on stackful coroutines — see [Async, promises and generators](./async.md).
29
+ - Standard library calls dispatch through `xt_call_method` / `xt_math_call` / `xt_object_*` and the per-constructor `xt_*` entry points; the surface is listed in [Standard library](./stdlib.md).
30
+ - Global string pool (`@.str.N` private constants, UTF-8 escaped).
31
+ - Builtin calls: `console.log` / `info` / `warn` / `error`, `Math.*`, `Object.*`, array / string methods, global functions, extension builtins (uniform `(argc, argv)` ABI).
32
+ - `main` entry point (returns 0, calls the module function, then drains microtasks and runs the event loop until no timers or descriptors remain).
33
+ - Unsupported nodes uniformly report `UnsupportedFeature`; they never crash.
@@ -0,0 +1,26 @@
1
+ # Collections
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/collections.md)
4
+
5
+ Location: `runtime/xt_stdlib2/container.inc` (Map / Set) and
6
+ `runtime/xt_weak.c` (WeakMap / WeakSet / WeakRef).
7
+
8
+ ## Map and Set
9
+
10
+ - `new Map()` / `new Map(iterable)` and `new Set()` / `new Set(iterable)`.
11
+ - `Map`: `size`, `get` / `set` / `has` / `delete` / `clear` / `forEach` / `keys` / `values` / `entries`.
12
+ - `Set`: `size`, `add` / `has` / `delete` / `clear` / `forEach` / `values` / `keys` / `entries`.
13
+ - `for...of` and spread iterate them through `[Symbol.iterator]`; a `Map` yields `[key, value]` pairs, and `keys` / `values` / `entries` return arrays in insertion order.
14
+ - `Object.keys` / `values` / `entries` do not see collection internals.
15
+ - `structuredClone` supports `Map` and `Set`, preserving cycles and shared references.
16
+
17
+ ## WeakMap, WeakSet and WeakRef
18
+
19
+ - `WeakMap`: `get` / `set` / `has` / `delete`; `WeakSet`: `add` / `has` / `delete`; `WeakRef`: `deref()`.
20
+ - Keys (and `WeakRef` targets) do not keep their referents alive: `WeakMap` / `WeakSet` keys are **ephemerons** (a value is retained only while its key is reachable) and a `WeakRef` target is cleared when it becomes unreachable.
21
+ - The stack scan is conservative, so a stale stack word can delay clearing a weak target. The full GC description is in [Runtime deviations](../unimplemented/deviations.md) and [Unimplemented: toolchain](../unimplemented/toolchain.md).
22
+
23
+ ## Iteration
24
+
25
+ - Any object exposing `[Symbol.iterator]()` is iterable in `for...of` and spread. `Array.prototype[Symbol.iterator]` is stable, and calling it returns an iterator object with `next()` that is itself iterable.
26
+ - Iteration is described further in [Codegen](./codegen.md#llvm-ir-code-generation-codegen) and [Symbol](./stdlib.md#symbol).
@@ -0,0 +1,19 @@
1
+ # Driver, incremental compilation and toolchain
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/driver.md)
4
+
5
+ Location: `src/driver/compiler.ts` (orchestration), `src/driver/frontend.ts`,
6
+ `src/driver/build-key.ts`, `src/driver/runtime-objects.ts`,
7
+ `src/driver/app-artifacts.ts`, `src/driver/cache.ts`, `src/driver/toolchain.ts`,
8
+ `src/driver/paths.ts`, `src/driver/version.ts`.
9
+
10
+ - Compilation pipeline: read source → module bundling (`src/driver/modules.ts`, when the entry contains `import`/`export`) → parse → bind/check → IR → object file → link.
11
+ - Incremental cache: keyed on "compiler version + source hash + emit kind + optimization level + LTO/PGO mode + platform + extension fingerprint (names, linker flags, native object contents)"; if the artifacts exist and are fresh, the build is skipped. `--pgo-use` always rebuilds because the profile data can change without the source. The key is assembled in `src/driver/build-key.ts`.
12
+ - C runtime and extension sources are cached as object files by content hash and compiled only once (the cache key includes the LTO/PGO flags). `RUNTIME_SOURCES` in `src/driver/runtime-objects.ts` lists the core translation units.
13
+ - Toolchain wrapper: locates `clang` (overridable with `xbintsc_CLANG`), compiles IR, compiles C, links.
14
+ - LTO (`--lto` / `"lto": true`): the program and runtime compile to LLVM bitcode (`-flto`) and link with `-fuse-ld=lld`; lld is required.
15
+ - PGO (`--pgo-generate[=dir]` then `--pgo-use[=dir]`, or `"pgo"` / `"pgoDir"`): the generated IR and runtime C are instrumented with `-fprofile-generate=<dir>`; after running the instrumented binary, `--pgo-use` merges `.profraw` files with `llvm-profdata` (preferring the copy next to clang, overridable with `xbintsc_LLVM_PROFDATA`) and rebuilds with `-fprofile-use=<dir>`.
16
+ - Link flags: `-lm` is added automatically on non-Windows; extensions may append extra link flags.
17
+ - Project config (`src/driver/config.ts`, `xbintsc.config.json`): `entry`, `outDir`, `output`, `optimize`, `lto`, `pgo`, `pgoDir`, `extensions`, `extNative`, `force` and `app` (`name`, `icon`, `bundle`, `bundleId`). Discovered by walking up from the entry/cwd, overridable with `--config`, disabled with `--no-config`; every path resolves against the config directory; CLI flags win over config values.
18
+ - Application icon (`src/driver/icon.ts`, `win-icon.ts`, `mac-bundle.ts`, `--icon`/`app.icon`): PNG/ICO/ICNS is embedded as `xt_app_icon_*` symbols, synthesized into a PE resource via `llvm-rc` on Windows, and packaged into `Foo.app` (with `AppIcon.icns` via `sips`/`iconutil`) on macOS. The `gui` extension calls `SDL_SetWindowIcon` from the embedded bytes. `xbintsc_RC` overrides the resource compiler.
19
+ - Compiler version: `COMPILER_VERSION` lives in `src/driver/version.ts` and is part of the cache key. The pre-commit hook bumps it (together with `package.json`) only on `main`/`master`, so feature branches never touch the version files.
@@ -0,0 +1,19 @@
1
+ # Extension mechanism
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/extensions.md)
4
+
5
+ Location: `src/extensions/registry.ts`, `src/extensions/node/`
6
+
7
+ - An extension is a plain object: `runtimeSources()` (extra C sources), `linkerFlags()` (extra link flags), `builtins()` (global identifier → runtime symbol, uniform `(argc, argv)` ABI) and `modules()` (import specifier → named exports / namespace).
8
+ - `ExtensionRegistry`: register / unregister / lookup / aggregate builtins, modules, runtime sources and link flags.
9
+ - The built-in core extension `core`: exposes `print` (mapped to `xt_println`), always registered.
10
+ - The Node extension `node`:
11
+ - Modular organisation: `src/extensions/node/fs/` + `runtime/ext_node/fs/read_file.c`
12
+ - Exposes importable modules (`fs`, `fs/promises`, `path`, `os`, `process`, ...) under both bare and `node:`-prefixed specifiers; `import { readFileSync } from "fs"` resolves to `xt_node_read_text_file`, and `path`/`os`/`process` map exports onto the namespace dispatchers.
13
+ - Adding a new module only requires a new directory plus a C implementation; the core compiler never changes.
14
+ - Native C++/Rust extensions (`src/extensions/native.ts`, `--ext-native`):
15
+ - `nativeObjects()` links pre-built objects/static archives that expose `extern "C"` symbols with the `(argc, argv)` ABI; a JSON manifest maps them onto builtins/modules (`linkerFlags` / `linkerFlagsByPlatform` cover C++/Rust runtimes).
16
+ - Authoring helpers live in `runtime/xt_ext.h` (C/C++) and `runtime/xt_ext.rs` (Rust); runnable projects are under `examples/extensions/`.
17
+ - The driver links the artifacts verbatim and the incremental cache fingerprints their contents, so a rebuilt library invalidates the cached binary.
18
+ - CI builds both language examples on Linux, macOS and Windows; on Windows the system clang links with the MSVC ABI (C++ `-lmsvcprt`, Rust `*-pc-windows-msvc` plus the Windows system libraries).
19
+ - Node module coverage is documented in [Node extension](./node.md).