xbintsc 0.5.23 → 0.5.32

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 (481) hide show
  1. package/AGENTS.md +11 -2
  2. package/README.md +47 -16
  3. package/README.zh-CN.md +21 -2
  4. package/dist/scripts/support-matrix.d.ts +18 -0
  5. package/dist/scripts/support-matrix.js +141 -0
  6. package/dist/scripts/support-matrix.js.map +1 -0
  7. package/dist/src/ast/common.d.ts +2 -2
  8. package/dist/src/ast/declarations.d.ts +7 -1
  9. package/dist/src/ast/expressions.d.ts +5 -0
  10. package/dist/src/ast/kinds.d.ts +2 -0
  11. package/dist/src/ast/kinds.js +2 -0
  12. package/dist/src/ast/kinds.js.map +1 -1
  13. package/dist/src/binder/binder.d.ts +2 -1
  14. package/dist/src/binder/binder.js +2 -0
  15. package/dist/src/binder/binder.js.map +1 -1
  16. package/dist/src/binder/declarations.d.ts +9 -0
  17. package/dist/src/binder/declarations.js +64 -0
  18. package/dist/src/binder/declarations.js.map +1 -1
  19. package/dist/src/binder/references.js +99 -4
  20. package/dist/src/binder/references.js.map +1 -1
  21. package/dist/src/binder/types.d.ts +32 -0
  22. package/dist/src/binder/types.js.map +1 -1
  23. package/dist/src/canonical.d.ts +29 -0
  24. package/dist/src/canonical.js +35 -0
  25. package/dist/src/canonical.js.map +1 -0
  26. package/dist/src/checker/assignability.d.ts +13 -0
  27. package/dist/src/checker/assignability.js +146 -0
  28. package/dist/src/checker/assignability.js.map +1 -0
  29. package/dist/src/checker/calls.d.ts +13 -0
  30. package/dist/src/checker/calls.js +127 -0
  31. package/dist/src/checker/calls.js.map +1 -0
  32. package/dist/src/checker/checker.d.ts +26 -0
  33. package/dist/src/checker/checker.js +31 -0
  34. package/dist/src/checker/checker.js.map +1 -0
  35. package/dist/src/checker/declarations.d.ts +9 -0
  36. package/dist/src/checker/declarations.js +15 -0
  37. package/dist/src/checker/declarations.js.map +1 -0
  38. package/dist/src/checker/flow.d.ts +21 -0
  39. package/dist/src/checker/flow.js +241 -0
  40. package/dist/src/checker/flow.js.map +1 -0
  41. package/dist/src/checker/globals.d.ts +9 -0
  42. package/dist/src/checker/globals.js +29 -0
  43. package/dist/src/checker/globals.js.map +1 -0
  44. package/dist/src/checker/source.d.ts +38 -0
  45. package/dist/src/checker/source.js +48 -0
  46. package/dist/src/checker/source.js.map +1 -0
  47. package/dist/src/checker/type-infer.d.ts +18 -0
  48. package/dist/src/checker/type-infer.js +173 -0
  49. package/dist/src/checker/type-infer.js.map +1 -0
  50. package/dist/src/checker/type-model.d.ts +73 -0
  51. package/dist/src/checker/type-model.js +151 -0
  52. package/dist/src/checker/type-model.js.map +1 -0
  53. package/dist/src/checker/type-system.d.ts +58 -0
  54. package/dist/src/checker/type-system.js +569 -0
  55. package/dist/src/checker/type-system.js.map +1 -0
  56. package/dist/src/checker/typecheck-types.d.ts +22 -0
  57. package/dist/src/checker/typecheck-types.js +109 -0
  58. package/dist/src/checker/typecheck-types.js.map +1 -0
  59. package/dist/src/checker/typecheck.d.ts +62 -0
  60. package/dist/src/checker/typecheck.js +574 -0
  61. package/dist/src/checker/typecheck.js.map +1 -0
  62. package/dist/src/checker/undefined.d.ts +14 -0
  63. package/dist/src/checker/undefined.js +32 -0
  64. package/dist/src/checker/undefined.js.map +1 -0
  65. package/dist/src/checker/walk.d.ts +10 -0
  66. package/dist/src/checker/walk.js +15 -0
  67. package/dist/src/checker/walk.js.map +1 -0
  68. package/dist/src/cli/help.d.ts +7 -0
  69. package/dist/src/cli/help.js +64 -0
  70. package/dist/src/cli/help.js.map +1 -0
  71. package/dist/src/cli/hints.js +2 -1
  72. package/dist/src/cli/hints.js.map +1 -1
  73. package/dist/src/cli/main.js +12 -48
  74. package/dist/src/cli/main.js.map +1 -1
  75. package/dist/src/codegen/generator/calls/access.js +8 -8
  76. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  77. package/dist/src/codegen/generator/calls/invocation.js +9 -4
  78. package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
  79. package/dist/src/codegen/generator/calls/super.d.ts +9 -1
  80. package/dist/src/codegen/generator/calls/super.js +56 -5
  81. package/dist/src/codegen/generator/calls/super.js.map +1 -1
  82. package/dist/src/codegen/generator/context.d.ts +13 -2
  83. package/dist/src/codegen/generator/context.js +25 -19
  84. package/dist/src/codegen/generator/context.js.map +1 -1
  85. package/dist/src/codegen/generator/debug.js +2 -1
  86. package/dist/src/codegen/generator/debug.js.map +1 -1
  87. package/dist/src/codegen/generator/expressions/primary.d.ts +4 -1
  88. package/dist/src/codegen/generator/expressions/primary.js +68 -8
  89. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  90. package/dist/src/codegen/generator/generator.js +11 -1
  91. package/dist/src/codegen/generator/generator.js.map +1 -1
  92. package/dist/src/codegen/generator/module.d.ts +3 -0
  93. package/dist/src/codegen/generator/module.js +116 -26
  94. package/dist/src/codegen/generator/module.js.map +1 -1
  95. package/dist/src/codegen/generator/state.d.ts +11 -1
  96. package/dist/src/codegen/generator/state.js.map +1 -1
  97. package/dist/src/codegen/generator/statements/variables.js +26 -7
  98. package/dist/src/codegen/generator/statements/variables.js.map +1 -1
  99. package/dist/src/codegen/generator/tables.d.ts +2 -0
  100. package/dist/src/codegen/generator/tables.js +4 -0
  101. package/dist/src/codegen/generator/tables.js.map +1 -1
  102. package/dist/src/driver/build-key.d.ts +2 -0
  103. package/dist/src/driver/build-key.js +1 -0
  104. package/dist/src/driver/build-key.js.map +1 -1
  105. package/dist/src/driver/bundler/graph.js +5 -1
  106. package/dist/src/driver/bundler/graph.js.map +1 -1
  107. package/dist/src/driver/bundler/merge.js +16 -1
  108. package/dist/src/driver/bundler/merge.js.map +1 -1
  109. package/dist/src/driver/bundler/types.d.ts +12 -0
  110. package/dist/src/driver/compiler.d.ts +1 -1
  111. package/dist/src/driver/compiler.js +3 -0
  112. package/dist/src/driver/compiler.js.map +1 -1
  113. package/dist/src/driver/fingerprint.js +2 -1
  114. package/dist/src/driver/fingerprint.js.map +1 -1
  115. package/dist/src/driver/frontend.d.ts +8 -6
  116. package/dist/src/driver/frontend.js +4 -0
  117. package/dist/src/driver/frontend.js.map +1 -1
  118. package/dist/src/driver/options.d.ts +6 -0
  119. package/dist/src/driver/version.d.ts +1 -1
  120. package/dist/src/driver/version.js +1 -1
  121. package/dist/src/extensions/gui/css.d.ts +26 -0
  122. package/dist/src/extensions/gui/css.js +100 -0
  123. package/dist/src/extensions/gui/css.js.map +1 -0
  124. package/dist/src/extensions/gui/html.js +28 -7
  125. package/dist/src/extensions/gui/html.js.map +1 -1
  126. package/dist/src/extensions/gui/index.js +79 -2
  127. package/dist/src/extensions/gui/index.js.map +1 -1
  128. package/dist/src/extensions/gui/three.d.ts +16 -0
  129. package/dist/src/extensions/gui/three.js +22 -0
  130. package/dist/src/extensions/gui/three.js.map +1 -0
  131. package/dist/src/extensions/media/index.d.ts +6 -5
  132. package/dist/src/extensions/media/index.js +12 -14
  133. package/dist/src/extensions/media/index.js.map +1 -1
  134. package/dist/src/extensions/registry.d.ts +38 -0
  135. package/dist/src/extensions/registry.js +10 -0
  136. package/dist/src/extensions/registry.js.map +1 -1
  137. package/dist/src/index.d.ts +1 -0
  138. package/dist/src/index.js +1 -0
  139. package/dist/src/index.js.map +1 -1
  140. package/dist/src/parser/declarations/classes.js +7 -0
  141. package/dist/src/parser/declarations/classes.js.map +1 -1
  142. package/dist/src/parser/expressions.js +14 -1
  143. package/dist/src/parser/expressions.js.map +1 -1
  144. package/dist/src/parser/literals.js +6 -2
  145. package/dist/src/parser/literals.js.map +1 -1
  146. package/dist/tests/binder/binder.test.js +29 -0
  147. package/dist/tests/binder/binder.test.js.map +1 -1
  148. package/dist/tests/canonical.test.d.ts +1 -0
  149. package/dist/tests/canonical.test.js +19 -0
  150. package/dist/tests/canonical.test.js.map +1 -0
  151. package/dist/tests/checker/checker.test.d.ts +1 -0
  152. package/dist/tests/checker/checker.test.js +245 -0
  153. package/dist/tests/checker/checker.test.js.map +1 -0
  154. package/dist/tests/cli/check.test.js +20 -0
  155. package/dist/tests/cli/check.test.js.map +1 -1
  156. package/dist/tests/conformance/matrix.test.d.ts +6 -0
  157. package/dist/tests/conformance/matrix.test.js +23 -0
  158. package/dist/tests/conformance/matrix.test.js.map +1 -0
  159. package/dist/tests/conformance/test262/manifest.d.ts +115 -0
  160. package/dist/tests/conformance/test262/manifest.js +257 -0
  161. package/dist/tests/conformance/test262/manifest.js.map +1 -0
  162. package/dist/tests/conformance/test262.test.d.ts +11 -0
  163. package/dist/tests/conformance/test262.test.js +74 -0
  164. package/dist/tests/conformance/test262.test.js.map +1 -0
  165. package/dist/tests/docs/structure.test.js +9 -11
  166. package/dist/tests/docs/structure.test.js.map +1 -1
  167. package/dist/tests/e2e/child-process.test.js +3 -2
  168. package/dist/tests/e2e/child-process.test.js.map +1 -1
  169. package/dist/tests/e2e/compile-builtins.test.js +45 -0
  170. package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
  171. package/dist/tests/e2e/compile-objects-classes.test.js +77 -0
  172. package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
  173. package/dist/tests/e2e/differential-syntax.test.d.ts +5 -0
  174. package/dist/tests/e2e/differential-syntax.test.js +95 -0
  175. package/dist/tests/e2e/differential-syntax.test.js.map +1 -0
  176. package/dist/tests/e2e/differential-values.test.js +15 -0
  177. package/dist/tests/e2e/differential-values.test.js.map +1 -1
  178. package/dist/tests/e2e/gui-browser.test.d.ts +13 -0
  179. package/dist/tests/e2e/gui-browser.test.js +163 -0
  180. package/dist/tests/e2e/gui-browser.test.js.map +1 -0
  181. package/dist/tests/e2e/gui-effects.test.d.ts +6 -0
  182. package/dist/tests/e2e/gui-effects.test.js +262 -0
  183. package/dist/tests/e2e/gui-effects.test.js.map +1 -0
  184. package/dist/tests/e2e/gui-example-browser.test.js +2 -2
  185. package/dist/tests/e2e/gui-example-browser.test.js.map +1 -1
  186. package/dist/tests/e2e/gui-example-canvas.test.js +5 -4
  187. package/dist/tests/e2e/gui-example-canvas.test.js.map +1 -1
  188. package/dist/tests/e2e/gui-example-svg.test.js +4 -3
  189. package/dist/tests/e2e/gui-example-svg.test.js.map +1 -1
  190. package/dist/tests/e2e/gui-example-webgl.test.d.ts +10 -0
  191. package/dist/tests/e2e/gui-example-webgl.test.js +75 -0
  192. package/dist/tests/e2e/gui-example-webgl.test.js.map +1 -0
  193. package/dist/tests/e2e/gui-example-webgl2.test.d.ts +8 -0
  194. package/dist/tests/e2e/gui-example-webgl2.test.js +72 -0
  195. package/dist/tests/e2e/gui-example-webgl2.test.js.map +1 -0
  196. package/dist/tests/e2e/gui-example.test.js +4 -3
  197. package/dist/tests/e2e/gui-example.test.js.map +1 -1
  198. package/dist/tests/e2e/gui-helpers.js +4 -3
  199. package/dist/tests/e2e/gui-helpers.js.map +1 -1
  200. package/dist/tests/e2e/gui-layout.test.js +48 -0
  201. package/dist/tests/e2e/gui-layout.test.js.map +1 -1
  202. package/dist/tests/e2e/gui-media.test.js +10 -8
  203. package/dist/tests/e2e/gui-media.test.js.map +1 -1
  204. package/dist/tests/e2e/gui-webgl.test.d.ts +11 -0
  205. package/dist/tests/e2e/gui-webgl.test.js +179 -0
  206. package/dist/tests/e2e/gui-webgl.test.js.map +1 -0
  207. package/dist/tests/e2e/gui-webgl2.test.d.ts +10 -0
  208. package/dist/tests/e2e/gui-webgl2.test.js +238 -0
  209. package/dist/tests/e2e/gui-webgl2.test.js.map +1 -0
  210. package/dist/tests/e2e/harness.d.ts +9 -0
  211. package/dist/tests/e2e/harness.js +14 -2
  212. package/dist/tests/e2e/harness.js.map +1 -1
  213. package/dist/tests/e2e/native-extensions.test.js +2 -1
  214. package/dist/tests/e2e/native-extensions.test.js.map +1 -1
  215. package/dist/tests/e2e/property-descriptors.test.js +20 -0
  216. package/dist/tests/e2e/property-descriptors.test.js.map +1 -1
  217. package/dist/tests/e2e/unicode-output.test.js +5 -3
  218. package/dist/tests/e2e/unicode-output.test.js.map +1 -1
  219. package/dist/tests/e2e/weak-collections.test.js +16 -2
  220. package/dist/tests/e2e/weak-collections.test.js.map +1 -1
  221. package/dist/tests/extensions/gui.test.js +41 -0
  222. package/dist/tests/extensions/gui.test.js.map +1 -1
  223. package/dist/tests/extensions/media.test.js +7 -3
  224. package/dist/tests/extensions/media.test.js.map +1 -1
  225. package/dist/tests/helpers.d.ts +1 -0
  226. package/dist/tests/helpers.js +1 -0
  227. package/dist/tests/helpers.js.map +1 -1
  228. package/dist/tests/parser/declarations.test.js +20 -0
  229. package/dist/tests/parser/declarations.test.js.map +1 -1
  230. package/dist/tests/parser/expressions.test.js +36 -0
  231. package/dist/tests/parser/expressions.test.js.map +1 -1
  232. package/dist/tests/platform.d.ts +32 -0
  233. package/dist/tests/platform.js +40 -0
  234. package/dist/tests/platform.js.map +1 -0
  235. package/dist/tests/platform.test.d.ts +12 -0
  236. package/dist/tests/platform.test.js +51 -0
  237. package/dist/tests/platform.test.js.map +1 -0
  238. package/dist/tests/version.test.js +4 -4
  239. package/dist/tests/version.test.js.map +1 -1
  240. package/doc/ai/README.md +10 -4
  241. package/doc/ai/build-recipe.md +1 -0
  242. package/doc/ai/cli.md +17 -5
  243. package/doc/ai/contributing.md +59 -2
  244. package/doc/ai/extensions.md +38 -7
  245. package/doc/ai/language-support.md +25 -16
  246. package/doc/ai/troubleshooting.md +12 -8
  247. package/doc/ai/zh-CN/README.md +9 -4
  248. package/doc/ai/zh-CN/build-recipe.md +1 -0
  249. package/doc/ai/zh-CN/cli.md +13 -3
  250. package/doc/ai/zh-CN/contributing.md +49 -3
  251. package/doc/ai/zh-CN/extensions.md +33 -6
  252. package/doc/ai/zh-CN/language-support.md +23 -14
  253. package/doc/ai/zh-CN/troubleshooting.md +10 -6
  254. package/doc/gui/api.md +47 -1
  255. package/doc/gui/build.md +72 -16
  256. package/doc/gui/canvas.md +11 -3
  257. package/doc/gui/dom.md +33 -18
  258. package/doc/gui/known-issues.md +58 -15
  259. package/doc/gui/layout.md +18 -0
  260. package/doc/gui/media.md +17 -13
  261. package/doc/gui/rendering.md +50 -3
  262. package/doc/gui/runtime.md +18 -0
  263. package/doc/gui/webgl.md +256 -0
  264. package/doc/gui-scripts.md +7 -0
  265. package/doc/gui.md +108 -17
  266. package/doc/implemented/binder.md +2 -0
  267. package/doc/implemented/checker.md +117 -0
  268. package/doc/implemented/cli.md +13 -1
  269. package/doc/implemented/codegen.md +3 -2
  270. package/doc/implemented/driver.md +2 -2
  271. package/doc/implemented/operators.md +2 -1
  272. package/doc/implemented/parser.md +3 -2
  273. package/doc/implemented/pipeline.md +8 -1
  274. package/doc/implemented/stdlib.md +2 -1
  275. package/doc/implemented/tests.md +3 -1
  276. package/doc/implemented.md +2 -0
  277. package/doc/npm-package.md +419 -0
  278. package/doc/requirements.md +22 -10
  279. package/doc/support-matrix.md +83 -0
  280. package/doc/unimplemented/classes.md +3 -0
  281. package/doc/unimplemented/deviations.md +3 -2
  282. package/doc/unimplemented/toolchain.md +1 -1
  283. package/doc/unimplemented/types.md +24 -8
  284. package/doc/unimplemented.md +1 -1
  285. package/doc/zh-CN/gui/api.md +43 -1
  286. package/doc/zh-CN/gui/build.md +64 -15
  287. package/doc/zh-CN/gui/canvas.md +9 -2
  288. package/doc/zh-CN/gui/dom.md +20 -7
  289. package/doc/zh-CN/gui/known-issues.md +46 -13
  290. package/doc/zh-CN/gui/layout.md +14 -0
  291. package/doc/zh-CN/gui/media.md +15 -11
  292. package/doc/zh-CN/gui/rendering.md +41 -4
  293. package/doc/zh-CN/gui/runtime.md +16 -0
  294. package/doc/zh-CN/gui/webgl.md +115 -0
  295. package/doc/zh-CN/gui-scripts.md +5 -0
  296. package/doc/zh-CN/gui.md +89 -14
  297. package/doc/zh-CN/implemented/binder.md +2 -0
  298. package/doc/zh-CN/implemented/checker.md +99 -0
  299. package/doc/zh-CN/implemented/cli.md +12 -1
  300. package/doc/zh-CN/implemented/codegen.md +3 -2
  301. package/doc/zh-CN/implemented/driver.md +2 -2
  302. package/doc/zh-CN/implemented/operators.md +1 -1
  303. package/doc/zh-CN/implemented/parser.md +3 -2
  304. package/doc/zh-CN/implemented/pipeline.md +3 -1
  305. package/doc/zh-CN/implemented/stdlib.md +2 -1
  306. package/doc/zh-CN/implemented/tests.md +3 -1
  307. package/doc/zh-CN/implemented.md +2 -0
  308. package/doc/zh-CN/npm-package.md +394 -0
  309. package/doc/zh-CN/post/announce.md +47 -47
  310. package/doc/zh-CN/requirements.md +16 -7
  311. package/doc/zh-CN/support-matrix.md +82 -0
  312. package/doc/zh-CN/unimplemented/classes.md +3 -0
  313. package/doc/zh-CN/unimplemented/deviations.md +3 -2
  314. package/doc/zh-CN/unimplemented/toolchain.md +1 -1
  315. package/doc/zh-CN/unimplemented/types.md +16 -6
  316. package/doc/zh-CN/unimplemented.md +1 -1
  317. package/llms.txt +6 -1
  318. package/package.json +2 -1
  319. package/runtime/ext_gui/audio.cpp +316 -0
  320. package/runtime/ext_gui/browser.cpp +573 -0
  321. package/runtime/ext_gui/browser_escape.cpp +85 -0
  322. package/runtime/ext_gui/browser_loop.cpp +83 -0
  323. package/runtime/ext_gui/canvas.cpp +12 -21
  324. package/runtime/ext_gui/canvas_internal.h +10 -0
  325. package/runtime/ext_gui/canvas_raster.cpp +79 -1
  326. package/runtime/ext_gui/clip_values.cpp +246 -0
  327. package/runtime/ext_gui/css.cpp +94 -0
  328. package/runtime/ext_gui/css.h +22 -1
  329. package/runtime/ext_gui/css_match.cpp +3 -0
  330. package/runtime/ext_gui/css_selector.cpp +9 -0
  331. package/runtime/ext_gui/css_sheet.cpp +89 -45
  332. package/runtime/ext_gui/document.cpp +4 -1
  333. package/runtime/ext_gui/document.h +2 -0
  334. package/runtime/ext_gui/dom.h +16 -0
  335. package/runtime/ext_gui/dom_api.cpp +37 -0
  336. package/runtime/ext_gui/dom_api_canvas.cpp +17 -80
  337. package/runtime/ext_gui/dom_api_canvas_extra.cpp +130 -1
  338. package/runtime/ext_gui/dom_api_canvas_pending.cpp +41 -0
  339. package/runtime/ext_gui/dom_api_document.cpp +96 -5
  340. package/runtime/ext_gui/dom_api_events.cpp +20 -0
  341. package/runtime/ext_gui/dom_api_internal.h +278 -0
  342. package/runtime/ext_gui/dom_api_proto.cpp +6 -0
  343. package/runtime/ext_gui/dom_api_webgl.cpp +376 -0
  344. package/runtime/ext_gui/dom_api_webgl2.cpp +434 -0
  345. package/runtime/ext_gui/dom_api_webgl2_draw.cpp +269 -0
  346. package/runtime/ext_gui/dom_api_webgl_buffer.cpp +212 -0
  347. package/runtime/ext_gui/dom_api_webgl_rt.h +30 -0
  348. package/runtime/ext_gui/dom_api_webgl_shader.cpp +443 -0
  349. package/runtime/ext_gui/dom_api_webgl_state.cpp +444 -0
  350. package/runtime/ext_gui/dom_api_webgl_texture.cpp +445 -0
  351. package/runtime/ext_gui/effect_values.cpp +312 -0
  352. package/runtime/ext_gui/gradient_values.cpp +476 -0
  353. package/runtime/ext_gui/grid_values.cpp +230 -0
  354. package/runtime/ext_gui/gui.cpp +90 -23
  355. package/runtime/ext_gui/gui_canvas.cpp +50 -2
  356. package/runtime/ext_gui/gui_engine.h +71 -0
  357. package/runtime/ext_gui/gui_events.cpp +4 -1
  358. package/runtime/ext_gui/gui_media.cpp +1 -1
  359. package/runtime/ext_gui/gui_webgl.cpp +83 -0
  360. package/runtime/ext_gui/layout.cpp +21 -0
  361. package/runtime/ext_gui/layout_flow.cpp +81 -4
  362. package/runtime/ext_gui/layout_flow_internal.h +31 -0
  363. package/runtime/ext_gui/layout_grid.cpp +374 -0
  364. package/runtime/ext_gui/media.h +1 -1
  365. package/runtime/ext_gui/media_api.h +2 -2
  366. package/runtime/ext_gui/media_query.cpp +211 -0
  367. package/runtime/ext_gui/paint.cpp +111 -77
  368. package/runtime/ext_gui/paint.h +33 -3
  369. package/runtime/ext_gui/paint_background.cpp +229 -0
  370. package/runtime/ext_gui/paint_clip.cpp +268 -0
  371. package/runtime/ext_gui/paint_effects.cpp +324 -0
  372. package/runtime/ext_gui/paint_internal.h +85 -0
  373. package/runtime/ext_gui/renderer.cpp +8 -31
  374. package/runtime/ext_gui/renderer_clip.cpp +196 -0
  375. package/runtime/ext_gui/renderer_image.cpp +13 -8
  376. package/runtime/ext_gui/renderer_internal.h +15 -8
  377. package/runtime/ext_gui/renderer_text.cpp +6 -31
  378. package/runtime/ext_gui/style.cpp +343 -20
  379. package/runtime/ext_gui/style.h +144 -3
  380. package/runtime/ext_gui/style_print.cpp +134 -1
  381. package/runtime/ext_gui/style_values.cpp +152 -126
  382. package/runtime/ext_gui/style_values_internal.h +35 -0
  383. package/runtime/ext_gui/webgl.h +466 -0
  384. package/runtime/ext_gui/webgl2_constants.h +274 -0
  385. package/runtime/ext_gui/webgl_buffer.cpp +565 -0
  386. package/runtime/ext_gui/webgl_constants.h +317 -0
  387. package/runtime/ext_gui/webgl_context.cpp +466 -0
  388. package/runtime/ext_gui/webgl_draw.cpp +495 -0
  389. package/runtime/ext_gui/webgl_glsl.h +125 -0
  390. package/runtime/ext_gui/webgl_glsl_compile.cpp +431 -0
  391. package/runtime/ext_gui/webgl_glsl_rewrite.cpp +349 -0
  392. package/runtime/ext_gui/webgl_glsl_scan.cpp +581 -0
  393. package/runtime/ext_gui/webgl_msl.cpp +62 -0
  394. package/runtime/ext_gui/webgl_msl.h +33 -0
  395. package/runtime/ext_gui/webgl_pipeline.cpp +274 -0
  396. package/runtime/ext_gui/webgl_program_internal.h +18 -0
  397. package/runtime/ext_gui/webgl_shader.cpp +582 -0
  398. package/runtime/ext_gui/webgl_texture.cpp +293 -0
  399. package/runtime/ext_gui/webgl_uniform.cpp +167 -0
  400. package/runtime/ext_gui/webgl_webgl2.cpp +224 -0
  401. package/runtime/ext_gui/window.cpp +9 -0
  402. package/runtime/ext_media/media.cpp +1 -1
  403. package/runtime/ext_media/media_bridge.c +9 -3
  404. package/runtime/ext_node/path/path.c +7 -7
  405. package/runtime/ext_node/url/url.c +4 -2
  406. package/runtime/rt.h +15 -0
  407. package/runtime/rt_internal.h +1 -0
  408. package/runtime/xt_constructors.c +2 -1
  409. package/runtime/xt_containers/access.inc +8 -0
  410. package/runtime/xt_containers/objects.inc +22 -2
  411. package/runtime/xt_io/exception.inc +4 -2
  412. package/runtime/xt_regex/api.inc +2 -0
  413. package/runtime/xt_regex/matcher.inc +16 -3
  414. package/runtime/xt_regex/parser.inc +8 -2
  415. package/runtime/xt_regex/types.inc +3 -0
  416. package/runtime/xt_stdlib/math.inc +62 -0
  417. package/runtime/xt_stdlib2/date.inc +7 -1
  418. package/runtime/xt_stdlib2/objects.inc +14 -0
  419. package/runtime/xt_stdlib2/regexp-match.inc +60 -21
  420. package/runtime/xt_stdlib2/regexp.inc +1 -0
  421. package/runtime/xt_typed_array.c +1 -1
  422. package/scripts/build-gui.ts +90 -3
  423. package/scripts/build-media.ts +323 -58
  424. package/scripts/setup-vs-toolchain.ps1 +152 -0
  425. package/scripts/support-matrix.ts +167 -0
  426. package/src/ast/common.ts +2 -0
  427. package/src/ast/declarations.ts +12 -1
  428. package/src/ast/expressions.ts +6 -0
  429. package/src/ast/kinds.ts +2 -0
  430. package/src/binder/binder.ts +3 -0
  431. package/src/binder/declarations.ts +70 -0
  432. package/src/binder/references.ts +97 -4
  433. package/src/binder/types.ts +30 -0
  434. package/src/canonical.ts +37 -0
  435. package/src/checker/assignability.ts +134 -0
  436. package/src/checker/calls.ts +135 -0
  437. package/src/checker/checker.ts +47 -0
  438. package/src/checker/declarations.ts +26 -0
  439. package/src/checker/flow.ts +236 -0
  440. package/src/checker/globals.ts +40 -0
  441. package/src/checker/source.ts +53 -0
  442. package/src/checker/type-infer.ts +185 -0
  443. package/src/checker/type-model.ts +212 -0
  444. package/src/checker/type-system.ts +578 -0
  445. package/src/checker/typecheck-types.ts +112 -0
  446. package/src/checker/typecheck.ts +586 -0
  447. package/src/checker/undefined.ts +43 -0
  448. package/src/checker/walk.ts +16 -0
  449. package/src/cli/help.ts +65 -0
  450. package/src/cli/hints.ts +2 -1
  451. package/src/cli/main.ts +12 -49
  452. package/src/codegen/generator/calls/access.ts +8 -8
  453. package/src/codegen/generator/calls/invocation.ts +8 -5
  454. package/src/codegen/generator/calls/super.ts +67 -5
  455. package/src/codegen/generator/context.ts +31 -19
  456. package/src/codegen/generator/debug.ts +2 -1
  457. package/src/codegen/generator/expressions/primary.ts +84 -13
  458. package/src/codegen/generator/generator.ts +11 -1
  459. package/src/codegen/generator/module.ts +115 -24
  460. package/src/codegen/generator/state.ts +11 -1
  461. package/src/codegen/generator/statements/variables.ts +26 -6
  462. package/src/codegen/generator/tables.ts +5 -0
  463. package/src/driver/build-key.ts +3 -0
  464. package/src/driver/bundler/graph.ts +6 -2
  465. package/src/driver/bundler/merge.ts +14 -1
  466. package/src/driver/bundler/types.ts +13 -0
  467. package/src/driver/compiler.ts +4 -1
  468. package/src/driver/fingerprint.ts +2 -1
  469. package/src/driver/frontend.ts +13 -2
  470. package/src/driver/options.ts +6 -0
  471. package/src/driver/version.ts +1 -1
  472. package/src/extensions/gui/css.ts +113 -0
  473. package/src/extensions/gui/html.ts +31 -11
  474. package/src/extensions/gui/index.ts +81 -2
  475. package/src/extensions/gui/three.ts +25 -0
  476. package/src/extensions/media/index.ts +13 -16
  477. package/src/extensions/registry.ts +48 -0
  478. package/src/index.ts +1 -0
  479. package/src/parser/declarations/classes.ts +7 -0
  480. package/src/parser/expressions.ts +13 -1
  481. package/src/parser/literals.ts +6 -2
@@ -0,0 +1,256 @@
1
+ # WebGL (a `<canvas>` drawn on the GPU)
2
+
3
+ > Part of the [GUI extension](../gui.md); the engine overview, locked
4
+ > decisions and roadmap live there.
5
+
6
+ A `<canvas>` can ask for a WebGL context instead of the 2D one:
7
+
8
+ ```ts
9
+ const canvas: any = document.getElementById("scene");
10
+ const gl: any = canvas.getContext("webgl2"); // or "webgl" / "experimental-webgl"
11
+ if (gl == null) {
12
+ // no GPU backend that can consume WebGL's shaders on this platform
13
+ }
14
+ ```
15
+
16
+ Unlike the 2D context, which rasterises into a CPU bitmap and uploads it as a
17
+ texture, a WebGL context **renders on the GPU**: vertex transform, lighting,
18
+ texture sampling, depth testing and blending all execute in the SDL_GPU
19
+ pipeline (Vulkan on Windows/Linux, Metal on macOS). The page composites the
20
+ context's colour texture directly, so no pixels are read back to the CPU for
21
+ display.
22
+
23
+ Both **WebGL 1.0** and **WebGL 2.0** are available. A canvas keeps the first
24
+ context kind it asks for: after `getContext("webgl2")` a later
25
+ `getContext("webgl")` answers `null`, and the other way round. A WebGL 2 context
26
+ also satisfies `instanceof WebGLRenderingContext` (its prototype inherits the
27
+ WebGL 1 one) and adds the WebGL 2 constants and methods.
28
+
29
+ ## How a frame reaches the screen
30
+
31
+ - Each context owns one offscreen `R8G8B8A8_UNORM` colour texture (the drawing
32
+ buffer) and a `D32_FLOAT` depth texture, sized from the canvas's `width` /
33
+ `height` attributes. `canvas.width = …` recreates them and discards the
34
+ contents, like the DOM rule.
35
+ - The context records into its own SDL_GPU command buffer. `clear`/`draw*`
36
+ keep a render pass open; a buffer/texture upload or a framebuffer change ends
37
+ it and starts a new pass with `LOAD`, so the drawing buffer persists between
38
+ draws just like WebGL's.
39
+ - Once per frame, before the page's own render pass, the engine submits every
40
+ WebGL command buffer. The image pipeline then samples the colour texture as
41
+ an ordinary `PaintImage`, with no CPU copy.
42
+ - WebGL's origin is bottom-left while SDL_GPU render targets are top-left, so
43
+ the framebuffer is stored top-down: `viewport`/`scissor` are converted,
44
+ `readPixels` flips rows back, and the compositor sees an upright texture.
45
+ - A fixed-function state change (`blendFunc`, `depthFunc`, `cullFace`,
46
+ `colorMask`, …) changes which `SDL_GPUGraphicsPipeline` is needed, so
47
+ pipelines are created lazily per (program, vertex layout, state) and cached on
48
+ the program.
49
+
50
+ ## Shaders: GLSL ES to SPIR-V (and on to MSL)
51
+
52
+ SDL_GPU cannot compile GLSL at run time, and each backend consumes its own
53
+ format, so the engine ships two statically linked translators:
54
+
55
+ - **glslang** compiles the rewritten GLSL to SPIR-V, which the Vulkan backend
56
+ consumes directly;
57
+ - **SPIRV-Cross** cross-compiles that same SPIR-V to Metal Shading Language text,
58
+ which the Metal backend compiles at run time.
59
+
60
+ Both live in `gui.a` / `gui.lib`; the Metal path reuses the SPIR-V module rather
61
+ than growing a second GLSL front end, so both backends accept exactly the same
62
+ shader subset. The path is:
63
+
64
+ 1. `shaderSource` stores the GLSL ES text; `compileShader` translates it once
65
+ for `COMPILE_STATUS` / `getShaderInfoLog`.
66
+ 2. `linkProgram` translates both stages again with one shared attribute and
67
+ varying location map, compiles them with glslang, and then creates the
68
+ `SDL_GPUShader` objects: from the SPIR-V on Vulkan, or from the MSL text
69
+ SPIRV-Cross produced on Metal.
70
+ 3. The generated SPIR-V is reflected to obtain the exact std140 offsets, array
71
+ strides and matrix strides of the uniform block — the shader text may size an
72
+ array with a macro, but glslang has already resolved it. SPIRV-Cross keeps
73
+ those offsets in the MSL struct, so one uniform layout serves both backends.
74
+
75
+ The translator (`runtime/ext_gui/webgl_glsl*.cpp`) handles GLSL ES 1.00 and
76
+ 3.00 sources:
77
+
78
+ | WebGL spelling | Rewritten to |
79
+ | --- | --- |
80
+ | `attribute vec3 a_pos` | `layout(location = N) in vec3 a_pos` |
81
+ | `varying vec2 v_uv` | `layout(location = N) out/in vec2 v_uv` (one shared name → location map) |
82
+ | `gl_FragColor` | `layout(location = 0) out highp vec4 xt_FragColor` |
83
+ | `texture2D`, `textureCube`, `texture2DProj` | `texture`, `texture`, `textureProj` |
84
+ | `texture2DLodEXT` / `textureCubeLodEXT` | `textureLod` |
85
+ | non-sampler uniforms | one `layout(std140) uniform XtUniforms { … }` block |
86
+ | `uniform sampler2D u_tex` | `layout(set = 2, binding = N) uniform sampler2D u_tex` (fragment) or set 0 (vertex) |
87
+ | `gl_FragData[0]` | `xt_FragColor` |
88
+ | a missing `#version` / `#version 100` | `#version 310 es` |
89
+
90
+ Non-sampler uniforms are merged across both stages and emitted as one block in
91
+ each stage (set 1 for the vertex shader, set 3 for the fragment shader), which
92
+ matches SDL_GPU's Vulkan descriptor layout. On Metal the same declarations
93
+ become `[[buffer(0)]]` and `[[texture(N)]]`/`[[sampler(N)]]`, the slots SDL_GPU's
94
+ Metal backend binds. `uniformMatrix4fv` writes column-major floats into the
95
+ reflected offsets; `uniform1i` on a sampler stores the texture unit. The block
96
+ is pushed with the dynamic uniform-buffer API on every draw.
97
+
98
+ Limits of the translator: struct-typed uniforms, user uniform blocks, uniform
99
+ arrays whose size is not resolved by the preprocessor, sampler arrays and cube
100
+ maps are rejected (the link/shader info log says so). Shader code inside
101
+ `#ifdef` is fine; non-sampler uniform declarations are moved to the enclosing
102
+ top-level position so the block stays unconditional.
103
+
104
+ ### GLSL ES 3.00 (WebGL 2)
105
+
106
+ A `#version 300 es` source is accepted as-is apart from the version bump:
107
+ top-level `in`/`out` declarations become attributes/varyings, a named fragment
108
+ output (`out vec4 fragColor;`) becomes an `xt_FragColor`-style output, and
109
+ `texture()` / `textureLod()` already match the Vulkan dialect. Multiple fragment
110
+ outputs are given sequential locations, but the render pass has one colour
111
+ target, so only the first is written. `gl_VertexID` and `gl_InstanceID` are
112
+ available from GLSL ES 3.00, which is what the instanced example uses.
113
+
114
+ ## Supported API
115
+
116
+ - **Context**: `getContext("webgl")`, `canvas`, `drawingBufferWidth/Height`,
117
+ `getParameter`, `getError`, `getSupportedExtensions`, `getExtension`,
118
+ `getContextAttributes`, `isContextLost`, `getShaderPrecisionFormat`, and the
119
+ stencil entry points (accepted; the depth target has no stencil attachment).
120
+ - **Shaders and programs**: `createShader`, `shaderSource`, `compileShader`,
121
+ `getShaderParameter`, `getShaderInfoLog`, `getShaderSource`, `deleteShader`,
122
+ `createProgram`, `attachShader`, `detachShader`, `linkProgram`,
123
+ `getProgramParameter`, `getProgramInfoLog`, `getAttachedShaders`,
124
+ `validateProgram`, `deleteProgram`, `useProgram`,
125
+ `getActiveUniform`/`getActiveAttrib`, `getUniformLocation`,
126
+ `getAttribLocation`, `bindAttribLocation`.
127
+ - **Uniforms**: `uniform1f`…`uniform4f`, `uniform1i`…`uniform4i`,
128
+ `uniform1fv`…`uniform4fv`, `uniform1iv`…`uniform4iv`,
129
+ `uniformMatrix2fv`/`3fv`/`4fv`, `getUniform`.
130
+ - **Buffers and attributes**: `createBuffer`, `bindBuffer`, `bufferData`,
131
+ `bufferSubData`, `deleteBuffer`, `getBufferParameter`,
132
+ `enableVertexAttribArray`, `disableVertexAttribArray`,
133
+ `vertexAttribPointer`, `vertexAttrib1f`…`4f` / `1fv`…`4fv`,
134
+ `getVertexAttrib`.
135
+ - **Drawing**: `drawArrays`, `drawElements` (UNSIGNED_BYTE, UNSIGNED_SHORT,
136
+ UNSIGNED_INT; `TRIANGLE_FAN` and `LINE_LOOP` are expanded to lists).
137
+ `POINTS`, `LINES`, `LINE_STRIP`, `TRIANGLES` and `TRIANGLE_STRIP` map to the
138
+ matching SDL primitive.
139
+ - **Textures**: `createTexture`, `bindTexture`, `activeTexture`,
140
+ `texParameteri`/`texParameterf`, `getTexParameter`, `texImage2D` (raw pixels,
141
+ `<img>`, `<canvas>` and `ImageData` sources), `texSubImage2D`,
142
+ `generateMipmap`, `deleteTexture`. `UNPACK_FLIP_Y_WEBGL` and
143
+ `UNPACK_PREMULTIPLY_ALPHA_WEBGL` are honoured. Everything is converted to
144
+ RGBA8; `RGBA`, `RGB`, `LUMINANCE`, `ALPHA` and `LUMINANCE_ALPHA` with
145
+ `UNSIGNED_BYTE` are accepted.
146
+ - **Framebuffers**: `createFramebuffer`, `bindFramebuffer`,
147
+ `framebufferTexture2D` (colour attachment), `checkFramebufferStatus`,
148
+ `createRenderbuffer`, `bindRenderbuffer`, `renderbufferStorage` (depth),
149
+ `framebufferRenderbuffer`, `delete*`. This is enough for render-to-texture,
150
+ shadow maps and post-processing passes.
151
+ - **State**: `enable`/`disable`/`isEnabled` for `BLEND`, `DEPTH_TEST`,
152
+ `CULL_FACE`, `SCISSOR_TEST` (stencil accepted but not applied),
153
+ `clearColor`/`clearDepth`/`clearStencil`, `clear`, `blendFunc`/
154
+ `blendFuncSeparate`, `blendEquation`/`blendEquationSeparate`, `depthFunc`,
155
+ `depthMask`, `colorMask`, `cullFace`, `frontFace`, `viewport`, `scissor`,
156
+ `pixelStorei`, `finish`.
157
+ - **Readback**: `readPixels` (RGBA/UNSIGNED_BYTE) from the default framebuffer
158
+ or a bound framebuffer. It blocks until the GPU finishes; use it for tests and
159
+ screenshots, not per frame.
160
+
161
+ WebGL 2 adds:
162
+
163
+ - **Vertex-array objects**: `createVertexArray`, `bindVertexArray`,
164
+ `deleteVertexArray`, `isVertexArray`. SDL_GPU has no VAO, so binding one
165
+ restores a saved copy of the attribute table and its element buffer.
166
+ - **Instancing**: `drawArraysInstanced`, `drawElementsInstanced`,
167
+ `drawRangeElements`, `vertexAttribDivisor`. A divisor of 1 maps to SDL's
168
+ per-instance vertex input rate; SDL 3.2 reserves larger step rates, so a
169
+ divisor above 1 is clamped to 1.
170
+ - **Integer attributes and uniforms**: `vertexAttribIPointer`, the
171
+ `vertexAttribI4*` family, `uniform1ui`…`uniform4ui`.
172
+ - **Sampler objects**: `createSampler`, `bindSampler`, `deleteSampler`,
173
+ `samplerParameteri/f`, `getSamplerParameter`; a bound sampler overrides the
174
+ texture's own filter/wrap state for that unit.
175
+ - **Immutable textures and buffer copies**: `texStorage2D` (the backend always
176
+ allocates the full mip chain), `copyBufferSubData`, `getBufferSubData`.
177
+ - **Clears**: `clearBufferfv`, `clearBufferiv`, `clearBufferuiv`,
178
+ `clearBufferfi`.
179
+ - **Queries and fences**: the objects and entry points exist
180
+ (`createQuery`/`beginQuery`/`endQuery`/`getQueryParameter`,
181
+ `fenceSync`/`clientWaitSync`/`waitSync`/`getSyncParameter`) and degrade
182
+ gracefully: a fence reports `ALREADY_SIGNALED` and query results are 0.
183
+ - **Uniform blocks**: `getUniformBlockIndex` answers `INVALID_INDEX` so a
184
+ library falls back to individual uniforms; the block entry points are no-ops.
185
+ - **Transform feedback, 3D textures and compressed formats**: the entry points
186
+ are present as no-ops so feature-probing libraries do not throw.
187
+
188
+ Textures are created with a full mip chain; sampling clamps to level 0 until
189
+ `generateMipmap` runs. Matrix vertex attributes consume the right number of
190
+ consecutive locations and read one column per location. A disabled attribute
191
+ is supplied from the last `vertexAttrib*f` value through a small constant
192
+ buffer.
193
+
194
+ ## Not implemented
195
+
196
+ Uniform buffer objects in shader source, transform feedback (the entry points
197
+ are no-ops), cube maps, 3D/array textures, float/half textures, depth textures,
198
+ compressed textures, multiple render targets (only the first fragment output is
199
+ written), `blitFramebuffer`, MSAA/sample buffers, stencil operations (state is
200
+ accepted, the stencil buffer is not written), constant blend colours,
201
+ `drawingBufferStorage`, context loss, `bufferData` with a `usage` other than
202
+ static/dynamic (the hint is ignored), `texImage2D` for
203
+ `HTMLVideoElement`/`ImageBitmap` and scissored `clear` (a clear clears the whole
204
+ attachment). Shaders that use built-in blocks, user uniform blocks or
205
+ `gl_FragDepth` beyond the supported subset are rejected with a compile/link log.
206
+
207
+ The engine advertises zero vertex texture units, so a well-behaved WebGL 1
208
+ program will not try to sample a texture in a vertex shader.
209
+
210
+ ## Platform
211
+
212
+ The pipeline is created with the shader format the SDL_GPU device accepts:
213
+ **SPIR-V** (`SDL_GPU_SHADERFORMAT_SPIRV`) on Vulkan, which is what Windows and
214
+ Linux select, or **MSL** (`SDL_GPU_SHADERFORMAT_MSL`) on Metal, which macOS
215
+ selects. Both backends go through the same GLSL front end, so a shader that
216
+ compiles on one compiles on the other. On a device whose backend accepts neither
217
+ format — Direct3D 12, which would need DXIL — `getContext("webgl")` and
218
+ `getContext("webgl2")` both answer `null`; the 2D canvas and the rest of the page
219
+ still work.
220
+
221
+ glslang and SPIRV-Cross are fetched and built by `npm run gui` and merged into
222
+ `gui.a` / `gui.lib` (see [Packaging and build](./build.md)); a program that only
223
+ uses the 2D canvas or the DOM pays no run-time cost beyond the archive size.
224
+
225
+ ## Testing
226
+
227
+ - `tests/e2e/gui-webgl.test.ts` compiles GLSL, draws a textured and a
228
+ depth-tested quad, checks face culling and reads the pixels back.
229
+ - `tests/e2e/gui-webgl2.test.ts` covers the WebGL 2 additions: `#version 300 es`
230
+ shaders, a VAO round trip, instanced draws with a divisor, `texStorage2D`,
231
+ `clearBufferfv`, buffer copies, sampler objects and struct-uniform fields.
232
+ - `examples/gui/webgl-cube` is a spinning, lit, textured cube; it runs in a
233
+ browser unchanged and is covered by
234
+ `tests/e2e/gui-example-webgl.test.ts`.
235
+ - `examples/gui/webgl2-cubes` draws 64 instanced cubes with one draw call,
236
+ `#version 300 es` and a VAO; covered by
237
+ `tests/e2e/gui-example-webgl2.test.ts`.
238
+
239
+ These suites run against whichever backend the host selects: Vulkan on Linux
240
+ (and Windows), Metal on macOS, so the SPIRV-Cross -> MSL path is covered by the
241
+ same assertions as the SPIR-V one.
242
+
243
+ ## three.js
244
+
245
+ The `.js` asset loader only patches three.js's shader unroller; `WebGLRenderer`
246
+ runs unchanged on this engine's real WebGL 2 backend, so **no Canvas2D fallback
247
+ is bundled any more**. Verified with three.js r160 through SDL_GPU:
248
+ `MeshBasicMaterial`, `MeshStandardMaterial` and `MeshPhongMaterial`,
249
+ `CanvasTexture`, linear fog, ambient/directional/point/spot/hemisphere lights,
250
+ `Sprite`, `Line`, `Points` and `InstancedMesh`.
251
+
252
+ Features outside this engine's subset still cannot be emulated: shadow maps
253
+ (depth textures), cube textures/environment maps, HDR/float render targets,
254
+ multiple render targets, transform feedback and compressed textures. A scene
255
+ that needs one of those will not render correctly; everything the previous
256
+ Canvas2D fallback could show now goes through the GPU.
@@ -170,6 +170,13 @@ Two limitations are enforced with clear errors rather than silent breakage:
170
170
  `src` URLs (`https://…`, `data:…`, `//host`) are left untouched — they are not
171
171
  compile-time assets and never run.
172
172
 
173
+ A wrapped body keeps its own file as the origin of every statement in it (the
174
+ loader reports the body's span in the generated module as a *source range*), so
175
+ a diagnostic points at `app.js:12` rather than at a column of `index.html`, and
176
+ a **plain-JavaScript** script stays untyped exactly like a `.js` module imported
177
+ directly: `state.update = …` on an object literal is not a `TS4003`. A page can
178
+ therefore ship its existing scripts unchanged.
179
+
173
180
  ```html
174
181
  <button id="b">0</button>
175
182
  <script src="./counter.ts"></script>
package/doc/gui.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # xbintsc GUI extension (self-hosted HTML/CSS renderer)
2
2
 
3
- Status: **M16** — features (M1–M15) are complete: HTML parsing, CSS selector
3
+ Status: **M19** — features (M1–M15) are complete: HTML parsing, CSS selector
4
4
  matching, the cascade, computed styles and layout (block, inline, Flexbox and
5
5
  CSS positioning) are
6
6
  in place, and the engine *paints*: it builds a display list of rectangles, images
@@ -35,6 +35,12 @@ them) can be translated, scaled and rotated without reflowing anything — and
35
35
  `transition: transform`, so those poses animate. See
36
36
  [Layout](./gui/layout.md#transforms-m15) and
37
37
  [Animation](./gui/animation.md#css-transforms-m15).
38
+ **M17** adds real **WebGL 1.0**, and **M18** adds **WebGL 2.0**: `<canvas>.getContext("webgl2")` accepts `#version 300 es` shaders, vertex-array objects, instanced draws and sampler objects, all compiled to SPIR-V by the bundled glslang (and to MSL by the bundled SPIRV-Cross on Metal) and rendered through SDL_GPU. Geometry, lighting, texture sampling and blending run on the GPU and the page composites the colour texture without a readback — see [WebGL](./gui/webgl.md).
39
+ **M19** fills in the decorative CSS layer: `@media` queries, generated content
40
+ (`::before`/`::after`), multi-layer linear/radial backgrounds, `text-shadow`,
41
+ `clip-path` and the `filter` colour/shadow effects. `backdrop-filter` and true
42
+ group blur need an offscreen compositor and remain documented approximations or
43
+ unsupported — see [Rendering](./gui/rendering.md#backgrounds-generated-content-and-effects-m19).
38
44
  This overview records the locked decisions, the architecture, the milestone plan
39
45
  and the current progress; the engine itself is documented by function in the
40
46
  pages above.
@@ -174,21 +180,27 @@ engine were Rust.
174
180
  - **M6b — transitions/animations** ✅ `transition` shorthand + longhands,
175
181
  animated `background-color`/`color`/`border-color`/`border-radius`, retargeting
176
182
  and `win.advance(ms)`. `@keyframes` remain.
177
- 7. **M7 — CI & releases** ✅ (Linux/macOS build) / 🚧 (run + Windows)
183
+ 7. **M7 — CI & releases** ✅ (Linux/macOS/Windows x64 build) / 🚧 (run + Windows arm64)
178
184
  - `compile-examples` builds `gui.a` and `media.a` on Linux and macOS
179
185
  (required), then runs the examples and `tests/e2e/gui-*.test.ts` under
180
186
  Xvfb + lavapipe on Linux (required). The macOS run is provisional until a
181
187
  WindowServer is confirmed; it is guarded so a failure is logged without
182
188
  annotating the run.
183
- - The `package` job builds `gui.a` and `media.a` before assembling the
184
- release, so both ship inside the existing runtime archive
185
- (`package-release` copies all of `runtime/`).
186
- - `vendor/` (SDL3/FreeType/HarfBuzz for `gui.a`, FFmpeg for `media.a`) is
187
- cached per OS/arch, keyed by `scripts/build-gui.ts` / `scripts/build-media.ts`.
188
- - Windows (build + run) stays provisional in CI: the MSVC-compatible
189
- `gui.lib` builds and runs locally through SDL_GPU's Vulkan backend, but the
190
- hosted runners have no GPU/Vulkan driver. A failure is logged without
191
- annotating the run (see [Open questions](./gui/known-issues.md#open-questions)).
189
+ - The `package` job builds `gui.a`/`gui.lib` and `media.a`/`media.lib` before
190
+ assembling the release, so both ship inside the existing runtime archive
191
+ (`package-release` copies all of `runtime/`). Windows x64 is included;
192
+ Windows arm64 still skips them.
193
+ - `vendor/` (SDL3/FreeType/HarfBuzz for the GUI archive, FFmpeg for `media`)
194
+ is cached per OS/arch, keyed by `scripts/build-gui.ts` /
195
+ `scripts/build-media.ts`. Windows x64 gets its own source cache plus the
196
+ installed `vendor/ffmpeg-build-msvc/dist` prefix.
197
+ - Windows x64 builds both archives in CI and links a `gui,media` program,
198
+ using the same Visual Studio `vcvarsall` + bundled LLVM toolchain as a
199
+ local build (`.github/actions/vs-toolchain`); the host has no GPU/Vulkan
200
+ driver, so *running* the GUI/media examples there remains provisional (a
201
+ failure is logged without annotating the run). The Windows arm64 job still
202
+ skips both archives (see
203
+ [Open questions](./gui/known-issues.md#open-questions)).
192
204
  8. **M8 — interactive DOM** ✅
193
205
  - Element/document handles with stable identity, read/write properties via
194
206
  runtime accessors, traversal/attributes/queries, mutation with lazy
@@ -277,6 +289,54 @@ engine were Rust.
277
289
  NanoSVG cache as an SVG file (`svg.{h,cpp}`); the markup cache is bounded
278
290
  and a DOM mutation re-serializes on the next layout. e2e in
279
291
  `tests/e2e/gui-inline-svg.test.ts`.
292
+ 17. **M17 — WebGL** ✅
293
+ - `canvas.getContext("webgl")` creates a real GPU context
294
+ (`webgl.{h,cpp}`): an offscreen RGBA8 colour texture plus a depth texture,
295
+ its own SDL_GPU command buffer, and pipelines created lazily from the
296
+ program, vertex layout and fixed-function state. The page composites the
297
+ colour texture through the existing image path, with no CPU readback.
298
+ - `webgl_glsl*.cpp` rewrites GLSL ES 1.00/3.00 to Vulkan GLSL ES 3.10
299
+ (attribute/varying locations, `gl_FragColor`, `texture2D`, one std140
300
+ uniform block per stage, explicit sampler bindings), compiles it with a
301
+ statically bundled glslang, reflects the SPIR-V for uniform offsets, and
302
+ on Metal cross-compiles that same module to MSL with the bundled
303
+ SPIRV-Cross (`webgl_msl.cpp`).
304
+ - `dom_api_webgl*.cpp` exposes the WebGL 1.0 surface, including textures,
305
+ mipmaps, render-to-texture framebuffers and `readPixels`. See
306
+ [WebGL](./gui/webgl.md); e2e in `tests/e2e/gui-webgl.test.ts` and
307
+ `tests/e2e/gui-example-webgl.test.ts`, demo in
308
+ `examples/gui/webgl-cube`.
309
+ 18. **M18 — WebGL 2** ✅
310
+ - `canvas.getContext("webgl2")` returns a context whose prototype extends
311
+ the WebGL 1 one, with the WebGL 2 constants and methods.
312
+ - GLSL ES 3.00 sources (`#version 300 es`, `in`/`out`, named fragment
313
+ outputs, `gl_InstanceID`) compile through the same rewriter.
314
+ - Vertex-array objects save/restore the attribute table, instanced draws use
315
+ SDL's per-instance input rate, and sampler objects override a texture
316
+ unit's filter/wrap state. `texStorage2D`, `copyBufferSubData`,
317
+ `getBufferSubData` and `clearBuffer*` are implemented; query/fence/UBO and
318
+ transform-feedback entry points exist and degrade gracefully. See
319
+ [WebGL](./gui/webgl.md); e2e in `tests/e2e/gui-webgl2.test.ts` and
320
+ `tests/e2e/gui-example-webgl2.test.ts`, demo in
321
+ `examples/gui/webgl2-cubes`.
322
+ 19. **M19 — decorative CSS** ✅
323
+ - `@media` blocks are parsed recursively and evaluated against the viewport
324
+ (width/height ranges, orientation, hover/pointer and preference features);
325
+ `matchMedia()` uses the same evaluator.
326
+ - Generated content: `::before`/`::after` selectors, inherited pseudo styles,
327
+ `content` strings/escapes/`attr()`, and synthetic layout boxes that never
328
+ leak into DOM traversal.
329
+ - Multi-layer `background-image` with linear and radial gradients, painted
330
+ bottom-up as solid bands (18 strips / 32 concentric ellipses).
331
+ - `text-shadow` as shadow text runs, including a nine-tap blur approximate.
332
+ - `clip-path` polygons (`inset`/`circle`/`ellipse`/`polygon`) resolved to
333
+ device space, ear-clipped and intersected with shape geometry in
334
+ `renderer_clip.cpp` — no stencil/shader change.
335
+ - `filter` colour functions, nine-tap `blur()` and silhouette
336
+ `drop-shadow()`; `backdrop-filter` parses and cascades but needs an
337
+ offscreen backdrop pass (see [Known issues](./gui/known-issues.md)).
338
+ - E2E coverage in `tests/e2e/gui-effects.test.ts`; see
339
+ [Rendering](./gui/rendering.md#backgrounds-generated-content-and-effects-m19).
280
340
 
281
341
  ## Progress log
282
342
 
@@ -306,11 +366,12 @@ engine were Rust.
306
366
  pixel size and cached by that size, so scaling and HiDPI stay crisp.
307
367
  - **M6b** ✅ CSS transitions (parsing in `style.*`, an animation clock and
308
368
  transition state in `document.*`, `advance`/`advance(ms)` hooks, e2e coverage).
309
- - **M7** ✅ builds `gui.a` (and the optional `media.a`) in CI on Linux and macOS
310
- (required) and runs the example plus the GUI e2e suite under Xvfb on Linux;
311
- `package` ships both archives, `vendor/` is cached, and the `ar -M` merge
312
- works on GNU/Linux and macOS. macOS runs and all of Windows remain provisional
313
- in CI.
369
+ - **M7** ✅ builds `gui.a`/`gui.lib` and `media.a`/`media.lib` in CI on Linux,
370
+ macOS and Windows x64 (required) and runs the example plus the GUI e2e suite
371
+ under Xvfb on Linux; `package` ships the archives (Windows x64 included),
372
+ `vendor/` is cached, and the `ar -M` merge works on GNU/Linux, macOS and
373
+ COFF/Windows. macOS runs, the Windows example *run* and Windows arm64 remain
374
+ provisional in CI.
314
375
  - **M8** ✅ element/document handles (`dom_api.*`), DOM mutation with lazy
315
376
  restyle/relayout (`document.*`, `xt_gui_flush_dom`), element event dispatch
316
377
  with capture/bubble and `stopPropagation` (`dom_api.*`, `gui.cpp`), and e2e
@@ -347,7 +408,8 @@ engine were Rust.
347
408
  every frame now runs in constant memory (see [Memory & GC](./gui/runtime.md#memory--gc)).
348
409
  - **M13** ✅ `<video>` / `<audio>` support. The optional `media` extension
349
410
  vendors and builds a minimal static FFmpeg (`scripts/build-media.ts`) and
350
- merges it into `media.a`; `runtime/ext_media/media.cpp` decodes video to RGBA
411
+ merges it into `media.a` (or `media.lib` from clang-cl/MSVC objects on
412
+ Windows); `runtime/ext_media/media.cpp` decodes video to RGBA
351
413
  frames and audio to 48 kHz stereo PCM on the main thread,
352
414
  `runtime/ext_gui/gui_media.cpp` owns the players, implements the SDL audio
353
415
  sink and pumps the media clock and events each frame,
@@ -393,4 +455,33 @@ engine were Rust.
393
455
  NanoSVG cache (`svg.{h,cpp}`, bounded LRU for markup). The `win.inlineSvg`
394
456
  diagnostic exposes the serialized document, and `tests/e2e/gui-inline-svg.test.ts`
395
457
  pins sizing, hit testing, gradients, CSS box styling and mutation.
458
+ - **M17** ✅ WebGL. `xtgui::WebGLContext` (`webgl.{h,cpp}`) owns the offscreen
459
+ colour/depth targets and the command buffer, `webgl_buffer/texture/draw/shader`
460
+ implement the GL object model, `webgl_glsl*.cpp` translate GLSL ES to SPIR-V
461
+ with the bundled glslang (`webgl_msl.cpp`/SPIRV-Cross turn that module into
462
+ MSL on Metal), and `dom_api_webgl*.cpp` bind the WebGL 1.0 API.
463
+ `renderer_image.cpp` returns the context's colour texture for a canvas id, so
464
+ the page composites GPU output directly. Demo: `examples/gui/webgl-cube`;
465
+ e2e: `tests/e2e/gui-webgl.test.ts`, `tests/e2e/gui-example-webgl.test.ts`.
466
+ - **M18** ✅ WebGL 2. `webgl2_proto()` extends the WebGL 1 prototype with the
467
+ WebGL 2 constants/methods; `webgl_webgl2.cpp` implements vertex-array objects
468
+ and sampler/query/sync handles, `webgl_draw.cpp` adds instanced draws (input
469
+ rate from `vertexAttribDivisor`) and integer attributes, and
470
+ `webgl_texture.cpp` adds `texStorage2D` and `clearBuffer*`. The shader
471
+ rewriter gives `#version 300 es` outputs sequential locations, and the block
472
+ reflection flattens struct fields for three.js lights. three.js r160 runs on
473
+ the real renderer (basic/standard/Phong materials, textures, lights, fog,
474
+ sprites, lines, points and instancing); the Canvas2D fallback was removed.
475
+ Demo: `examples/gui/webgl2-cubes` (64 cubes, one instanced draw call);
476
+ e2e: `tests/e2e/gui-webgl2.test.ts`, `tests/e2e/gui-example-webgl2.test.ts`.
477
+ - **M19** ✅ decorative CSS. `css_sheet.cpp` now parses nested `@media` blocks and
478
+ `media_query.cpp` evaluates them (and `matchMedia`) against the viewport;
479
+ `css_selector.cpp` understands `::before`/`::after`. `style.cpp` computes
480
+ pseudo styles into a per-restyle arena, resolves `content`, and layout inserts
481
+ their boxes before/after the DOM children. `gradient_values.cpp` models a
482
+ background layer list (linear/radial, shape/size/position/stops),
483
+ `paint_background.cpp` paints it, `paint_effects.cpp` applies filter colour
484
+ functions plus nine-tap blur/drop-shadow and emits `text-shadow` runs, and
485
+ `paint_clip.cpp`/`renderer_clip.cpp` clip geometry against triangulated
486
+ `clip-path` polygons. E2E: `tests/e2e/gui-effects.test.ts`.
396
487
 
@@ -7,6 +7,8 @@ Location: `src/binder/binder.ts`
7
7
  - Scope kinds: module, function, block, `for`, `catch`
8
8
  - Symbol kinds: `var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
9
9
  - `var` and function declarations hoist to the function scope; `let` / `const` stay block-scoped
10
+ - A `switch` body is one shared block scope: the declarations of every `case` / `default` clause are pre-declared before any clause is bound
11
+ - A `static { ... }` class block is bound as a hidden static function of the class (see [Classes](../unimplemented/classes.md))
10
12
  - Identifier → declaration resolution; unresolved identifier collection (`CannotFindName`)
11
13
  - Closure capture analysis: outer variables referenced by an inner function are marked `captured` / `boxed`, and capture indices are threaded through intermediate closures
12
14
  - Parameters are registered as local symbols; the self-name of a named function expression is registered as `const`
@@ -0,0 +1,117 @@
1
+ # Semantic checker
2
+
3
+ > Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/checker.md)
4
+
5
+ Location: `src/checker/` (`checker.ts`, `undefined.ts`, `declarations.ts`,
6
+ `calls.ts`, `type-system.ts`, `assignability.ts`, `flow.ts`, `typecheck.ts`),
7
+ invoked by `generate()` between binding and LLVM lowering.
8
+
9
+ The checker runs **by default**; `--no-check` (or `check: false` in the
10
+ programmatic API) turns it off. It combines inference-free checks with a small
11
+ structural type model:
12
+
13
+ | Diagnostic | Code | What is checked |
14
+ | --- | --- | --- |
15
+ | `Cannot find name` | TS3002 | An identifier that resolves to no declaration and no runtime global |
16
+ | `Duplicate identifier` | TS3001 | Same-scope declarations that cannot merge (`let x` twice, `function f` then `const f`, `let` colliding with a parameter, ...) |
17
+ | `Argument count mismatch` | TS4004 | A direct call to a locally visible function or `const`-bound arrow/function expression with too few or too many arguments |
18
+ | `Property not found` | TS4003 | A property read on a shape that is statically known |
19
+ | `Type mismatch` | TS4001 | An initializer, assignment, return value or call argument that is definitely not assignable |
20
+ | `Not callable` | TS4002 | Calling a value whose type is a primitive (number, string, boolean, ...) |
21
+
22
+ ## What the type model knows
23
+
24
+ The checker resolves the type syntax it can understand and treats everything
25
+ else as `any`:
26
+
27
+ - keyword types, literal types, `A | B` unions and object type literals;
28
+ - interfaces and type aliases (including generic aliases and `extends`);
29
+ - classes: instance fields, methods, accessors, parameter properties,
30
+ `this.x = ...` members and local ancestor classes. Static members are not
31
+ instance members;
32
+ - arrays, tuples, function types, object literals and `new LocalClass()`;
33
+ - simple generics: a type parameter is `any` at its declaration, and a call
34
+ infers it from an argument (`T`, `T[]`, `Array<T>`) or takes it from an
35
+ explicit type argument list.
36
+
37
+ Anything the model cannot name — mapped/conditional types, `keyof`,
38
+ `typeof` queries, indexed access, utility types, imported type names that
39
+ bundling renamed, an unknown base class — becomes `any`. `any` is compatible
40
+ with everything, which is the central safety property: unsupported syntax can
41
+ hide a bug, but it cannot reject working code.
42
+
43
+ ## Assignability
44
+
45
+ Checked at variable initializers, `=` assignments, `return` statements and call
46
+ arguments:
47
+
48
+ - primitives and literal types;
49
+ - object/interface/class shapes: every required target property must exist and
50
+ be assignable; extra source properties are allowed;
51
+ - arrays and tuples element-wise;
52
+ - functions: parameter count and return type (conservatively);
53
+ - unions: every source member must fit a target member, or some target member
54
+ must accept the source.
55
+
56
+ `let`/`var` infer widened types (`let x = 1` is `number`), `const` keeps the
57
+ literal. `null` and `undefined` are accepted wherever a value is expected
58
+ (there is no strict-null mode). Functional return types are not inferred: an
59
+ unannotated function returns `any`, so its callers are never rejected.
60
+
61
+ ## Property existence
62
+
63
+ Shapes come from an explicit annotation or from a `const` initialized with an
64
+ object literal / `new LocalClass(...)`. Optional properties, `Object.prototype`
65
+ members (`toString`, `hasOwnProperty`, ...), index signatures and inherited
66
+ class members are all accepted.
67
+
68
+ A shape becomes untrusted — and its variable is left alone — when it can change
69
+ after the declaration: a property write/delete/update, a call that may mutate
70
+ it (`mutate(object)`, `Object.assign(object, ...)`), aliasing (`const p =
71
+ object`), a dynamic constructor (`Object.assign(this, ...)`, `this[key] = ...`)
72
+ or prototype augmentation (`Object.assign(C.prototype, ...)`). Writes to a
73
+ missing property are allowed (xbintsc programs legitimately grow objects after
74
+ their literal); the write opens the shape instead of reporting.
75
+
76
+ Not checked: `object["x"]` element access, destructuring, shapes reached
77
+ through a function return, or aliasing through array/object containers.
78
+
79
+ ## Narrowing
80
+
81
+ Inside a branch the checker refines a variable when the condition is one of:
82
+
83
+ - `value !== null` / `!== undefined` / `!= null` (and the `===` forms);
84
+ - `typeof value === "string" | "number" | "boolean" | "bigint" | "symbol" | "undefined"`;
85
+ - `value instanceof LocalClass`;
86
+ - truthiness (`if (value)`, `value &&`, `value ||`);
87
+ - combinations through `&&`, `||`, `??` and `!`.
88
+
89
+ `if`/`else` and conditional expressions (`cond ? a : b`) apply the refinement;
90
+ other control flow does not.
91
+
92
+ ## What is deliberately not checked
93
+
94
+ - Full inference: unannotated function returns, complex generic constraints and
95
+ higher-order inference are treated as `any`.
96
+ - Excess-property checks on fresh object literals.
97
+ - `as`/`satisfies` assertions may narrow or widen freely (they are erased).
98
+ - Overload resolution, mapped types, conditional types and template-literal
99
+ types are not modeled.
100
+ - Bundled sources under `node_modules` are not checked at all: the checker is a
101
+ gate for the code you wrote, and failing on a dependency's internals would
102
+ make the default-on checker unusable with packages.
103
+
104
+ ## Behaviour without the checker
105
+
106
+ `--no-check` restores the previous permissive pipeline: type syntax is erased
107
+ and lowering continues. It also restores the silent `Duplicate identifier`
108
+ behaviour (`let value = 1; let value = 2;` compiles and the first value wins).
109
+ Prefer keeping the checker on.
110
+
111
+ ## Cache and diagnostics
112
+
113
+ `check` is part of the incremental cache key, so a `--no-check` build never
114
+ reuses a checked artifact (or vice versa). With the checker on, code generation
115
+ does not repeat its own `Cannot find name` error, so each name is reported
116
+ exactly once. `xbintsc check` runs the checker and stops before linking; it is
117
+ the fast gate for editors and pre-commit hooks.
@@ -9,11 +9,18 @@ Location: `src/cli/main.ts`, `src/index.ts`, `bin/xbintsc.js`
9
9
  ```
10
10
  xbintsc build <file.ts> [options] compile to a native binary
11
11
  xbintsc run <file.ts> [-- args] compile and run
12
+ xbintsc check <file.ts> parse, bind and check without linking
13
+ xbintsc watch <file.ts> rebuild on source-tree changes
12
14
  xbintsc emit <file.ts> print LLVM IR
15
+ xbintsc doctor report the resolved toolchain
13
16
  xbintsc version print the version
14
17
  xbintsc help help
15
18
  ```
16
19
 
20
+ `check`, `emit`, `build`, `run` and `watch` all run the semantic checker by
21
+ default; `--no-check` skips it (and is part of the cache key). See
22
+ [the checker page](./checker.md).
23
+
17
24
  ## CLI options
18
25
 
19
26
  ```
@@ -31,6 +38,9 @@ xbintsc help help
31
38
  --app-id <id> macOS bundle identifier (e.g. com.example.demo)
32
39
  --force Ignore the incremental cache
33
40
  --verbose Print progress information
41
+ --debug Emit DWARF/CodeView debug info
42
+ --check Run the semantic checker (default)
43
+ --no-check Skip the semantic checker
34
44
  ```
35
45
 
36
46
  ## Programmatic API
@@ -38,8 +48,10 @@ xbintsc help help
38
48
  ```ts
39
49
  import { build, compileString } from "xbintsc";
40
50
 
41
- const { ir } = compileString("console.log(1 + 1);");
51
+ const { ir, diagnostics } = compileString("console.log(1 + 1);");
42
52
  const result = build("program.ts", { emit: "exe", outDir: "build" });
53
+ // The checker can be disabled per call, exactly like `--no-check`:
54
+ build("program.ts", { check: false });
43
55
  ```
44
56
 
45
57
  The option and result types (`BuildOptions`, `BuildResult`, `EmitKind`,
@@ -23,8 +23,9 @@ Location: `src/codegen/llvm.ts`
23
23
  - Optional chaining `?.` / `?.[]` / `?.()`: nullish check short-circuits to `undefined`
24
24
  - `delete`, `in`, `instanceof`
25
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.
26
+ - Destructuring: a binding-pattern default (`const { a = f() } = o`) is emitted as a branch, so `f()` runs only when the property is `undefined` — never eagerly
27
+ - Closures (arrow functions / function expressions / function declarations) and capture environment construction: a capture is the symbol's *box*, so writes inside the closure reach the enclosing binding. A declared function called by name builds its environment at the call site (`fn.captures` / `fn.capturesThis` disable the direct-call fast path); otherwise it would run with a null environment and read every free variable as `undefined`.
28
+ - 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 *parent* prototype. The parent is derived from the class being defined (`getPrototype(getPrototype(@class.N))`), never from the receiver: walking `this` resolves to the wrong class once an instance of a subclass calls a base constructor, which recurses forever in a chain deeper than two levels.
28
29
  - `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
30
  - 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
31
  - Global string pool (`@.str.N` private constants, UTF-8 escaped).
@@ -7,8 +7,8 @@ Location: `src/driver/compiler.ts` (orchestration), `src/driver/frontend.ts`,
7
7
  `src/driver/app-artifacts.ts`, `src/driver/cache.ts`, `src/driver/toolchain.ts`,
8
8
  `src/driver/paths.ts`, `src/driver/version.ts`.
9
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`.
10
+ - Compilation pipeline: read source → module bundling (`src/driver/modules.ts`, when the entry contains `import`/`export`) → parse → bind → [semantic check](./checker.md) → IR → object file → link.
11
+ - Incremental cache: keyed on "compiler version + source hash + emit kind + optimization level + LTO/PGO mode + platform + `check`/`no-check` + 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
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
13
  - Toolchain wrapper: locates `clang` (overridable with `xbintsc_CLANG`), compiles IR, compiles C, links.
14
14
  - LTO (`--lto` / `"lto": true`): the program and runtime compile to LLVM bitcode (`-flto`) and link with `-fuse-ld=lld`; lld is required.