@scriptc/compiler 0.0.35 → 0.1.1

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 (439) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +14 -11
  2. package/ambient/scriptc-overrides.d.ts +0 -7
  3. package/ambient/scriptc.d.ts +1 -1
  4. package/dist/backend/build-cache.d.ts +44 -0
  5. package/dist/backend/build-cache.js +241 -0
  6. package/dist/backend/build-cache.js.map +1 -0
  7. package/dist/backend/{emission/emit-async.d.ts → c/async.d.ts} +21 -30
  8. package/dist/backend/{emission/emit-async.js → c/async.js} +270 -286
  9. package/dist/backend/c/async.js.map +1 -0
  10. package/dist/backend/{emission/emitter.d.ts → c/c-emitter.d.ts} +6 -23
  11. package/dist/backend/{emission/emitter.js → c/c-emitter.js} +53 -107
  12. package/dist/backend/c/c-emitter.js.map +1 -0
  13. package/dist/backend/c/exprs.d.ts +8 -0
  14. package/dist/backend/c/exprs.js +7937 -0
  15. package/dist/backend/c/exprs.js.map +1 -0
  16. package/dist/backend/{emission/emit-island.d.ts → c/island.d.ts} +5 -5
  17. package/dist/backend/{emission/emit-island.js → c/island.js} +24 -22
  18. package/dist/backend/c/island.js.map +1 -0
  19. package/dist/backend/{emission → c}/may-throw.d.ts +1 -1
  20. package/dist/backend/{emission → c}/may-throw.js +4 -1
  21. package/dist/backend/c/may-throw.js.map +1 -0
  22. package/dist/backend/{emission/emit-shapes.d.ts → c/shapes.d.ts} +19 -19
  23. package/dist/backend/{emission/emit-shapes.js → c/shapes.js} +78 -87
  24. package/dist/backend/c/shapes.js.map +1 -0
  25. package/dist/backend/{emission/emit-stmts.d.ts → c/stmts.d.ts} +12 -12
  26. package/dist/backend/{emission/emit-stmts.js → c/stmts.js} +395 -343
  27. package/dist/backend/c/stmts.js.map +1 -0
  28. package/dist/backend/{emission/emit-types.d.ts → c/types.d.ts} +1 -1
  29. package/dist/backend/{emission/emit-types.js → c/types.js} +42 -286
  30. package/dist/backend/c/types.js.map +1 -0
  31. package/dist/backend/c/types.test.js +25 -0
  32. package/dist/backend/c/types.test.js.map +1 -0
  33. package/dist/backend/{emission/emit-walkers.d.ts → c/walkers.d.ts} +19 -41
  34. package/dist/backend/{emission/emit-walkers.js → c/walkers.js} +242 -304
  35. package/dist/backend/c/walkers.js.map +1 -0
  36. package/dist/backend/external-c.d.ts +33 -0
  37. package/dist/backend/external-c.js +51 -0
  38. package/dist/backend/external-c.js.map +1 -0
  39. package/dist/backend/ffi-callbacks.d.ts +1 -1
  40. package/dist/backend/ffi-callbacks.js +4 -3
  41. package/dist/backend/ffi-callbacks.js.map +1 -1
  42. package/dist/backend/{library-identity.d.ts → library-identity-markers.d.ts} +0 -4
  43. package/dist/backend/{library-identity.js → library-identity-markers.js} +10 -9
  44. package/dist/backend/library-identity-markers.js.map +1 -0
  45. package/dist/backend/link-plan.d.ts +37 -0
  46. package/dist/backend/link-plan.js +26 -0
  47. package/dist/backend/link-plan.js.map +1 -0
  48. package/dist/backend/linker.d.ts +22 -0
  49. package/dist/backend/linker.js +236 -0
  50. package/dist/backend/linker.js.map +1 -0
  51. package/dist/backend/llvm/blocks.d.ts +4 -0
  52. package/dist/backend/llvm/blocks.js +29 -0
  53. package/dist/backend/llvm/blocks.js.map +1 -1
  54. package/dist/backend/llvm/classes.d.ts +2 -19
  55. package/dist/backend/llvm/classes.js +20 -52
  56. package/dist/backend/llvm/classes.js.map +1 -1
  57. package/dist/backend/llvm/common.d.ts +4 -0
  58. package/dist/backend/llvm/common.js +27 -0
  59. package/dist/backend/llvm/common.js.map +1 -0
  60. package/dist/backend/llvm/dyn.d.ts +3 -8
  61. package/dist/backend/llvm/dyn.js +159 -224
  62. package/dist/backend/llvm/dyn.js.map +1 -1
  63. package/dist/backend/llvm/emitter.d.ts +4 -1
  64. package/dist/backend/llvm/emitter.js +548 -9988
  65. package/dist/backend/llvm/emitter.js.map +1 -1
  66. package/dist/backend/llvm/expr-async.d.ts +4 -0
  67. package/dist/backend/llvm/expr-async.js +726 -0
  68. package/dist/backend/llvm/expr-async.js.map +1 -0
  69. package/dist/backend/llvm/expr-bytes.d.ts +13 -0
  70. package/dist/backend/llvm/expr-bytes.js +456 -0
  71. package/dist/backend/llvm/expr-bytes.js.map +1 -0
  72. package/dist/backend/llvm/expr-callbacks.d.ts +22 -0
  73. package/dist/backend/llvm/expr-callbacks.js +520 -0
  74. package/dist/backend/llvm/expr-callbacks.js.map +1 -0
  75. package/dist/backend/llvm/expr-calls.d.ts +2 -0
  76. package/dist/backend/llvm/expr-calls.js +618 -0
  77. package/dist/backend/llvm/expr-calls.js.map +1 -0
  78. package/dist/backend/llvm/expr-containers.d.ts +25 -0
  79. package/dist/backend/llvm/expr-containers.js +637 -0
  80. package/dist/backend/llvm/expr-containers.js.map +1 -0
  81. package/dist/backend/llvm/expr-context.d.ts +255 -0
  82. package/dist/backend/llvm/expr-context.js +2 -0
  83. package/dist/backend/llvm/expr-context.js.map +1 -0
  84. package/dist/backend/llvm/expr-control.d.ts +2 -0
  85. package/dist/backend/llvm/expr-control.js +473 -0
  86. package/dist/backend/llvm/expr-control.js.map +1 -0
  87. package/dist/backend/llvm/expr-dispatch.d.ts +4 -0
  88. package/dist/backend/llvm/expr-dispatch.js +153 -0
  89. package/dist/backend/llvm/expr-dispatch.js.map +1 -0
  90. package/dist/backend/llvm/expr-dynamic.d.ts +2 -0
  91. package/dist/backend/llvm/expr-dynamic.js +810 -0
  92. package/dist/backend/llvm/expr-dynamic.js.map +1 -0
  93. package/dist/backend/llvm/expr-island.d.ts +15 -0
  94. package/dist/backend/llvm/expr-island.js +690 -0
  95. package/dist/backend/llvm/expr-island.js.map +1 -0
  96. package/dist/backend/llvm/expr-primitives.d.ts +6 -0
  97. package/dist/backend/llvm/expr-primitives.js +642 -0
  98. package/dist/backend/llvm/expr-primitives.js.map +1 -0
  99. package/dist/backend/llvm/expr-records.d.ts +9 -0
  100. package/dist/backend/llvm/expr-records.js +299 -0
  101. package/dist/backend/llvm/expr-records.js.map +1 -0
  102. package/dist/backend/llvm/expr-stream-bridges.d.ts +13 -0
  103. package/dist/backend/llvm/expr-stream-bridges.js +420 -0
  104. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -0
  105. package/dist/backend/llvm/expr-stream-callbacks.d.ts +12 -0
  106. package/dist/backend/llvm/expr-stream-callbacks.js +360 -0
  107. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -0
  108. package/dist/backend/llvm/lib-dispatch.d.ts +5 -0
  109. package/dist/backend/llvm/lib-dispatch.js +267 -0
  110. package/dist/backend/llvm/lib-dispatch.js.map +1 -0
  111. package/dist/backend/llvm/lib-filesystem.d.ts +6 -0
  112. package/dist/backend/llvm/lib-filesystem.js +594 -0
  113. package/dist/backend/llvm/lib-filesystem.js.map +1 -0
  114. package/dist/backend/llvm/lib-network.d.ts +2 -0
  115. package/dist/backend/llvm/lib-network.js +429 -0
  116. package/dist/backend/llvm/lib-network.js.map +1 -0
  117. package/dist/backend/llvm/lib-process.d.ts +5 -0
  118. package/dist/backend/llvm/lib-process.js +585 -0
  119. package/dist/backend/llvm/lib-process.js.map +1 -0
  120. package/dist/backend/llvm/lib-shared.d.ts +6 -0
  121. package/dist/backend/llvm/lib-shared.js +687 -0
  122. package/dist/backend/llvm/lib-shared.js.map +1 -0
  123. package/dist/backend/llvm/lib-stream.d.ts +2 -0
  124. package/dist/backend/llvm/lib-stream.js +470 -0
  125. package/dist/backend/llvm/lib-stream.js.map +1 -0
  126. package/dist/backend/llvm/shapes.d.ts +12 -2
  127. package/dist/backend/llvm/shapes.js +66 -307
  128. package/dist/backend/llvm/shapes.js.map +1 -1
  129. package/dist/backend/llvm/shapes.test.js +52 -0
  130. package/dist/backend/llvm/shapes.test.js.map +1 -0
  131. package/dist/backend/llvm/unsupported.d.ts +1 -1
  132. package/dist/backend/llvm/walkers.d.ts +2 -3
  133. package/dist/backend/llvm/walkers.js +195 -222
  134. package/dist/backend/llvm/walkers.js.map +1 -1
  135. package/dist/backend/native-codegen.d.ts +45 -0
  136. package/dist/backend/native-codegen.js +275 -0
  137. package/dist/backend/native-codegen.js.map +1 -0
  138. package/dist/backend/native-codegen.test.js +226 -0
  139. package/dist/backend/native-codegen.test.js.map +1 -0
  140. package/dist/backend/native-link-info.d.ts +96 -0
  141. package/dist/backend/native-link-info.js +243 -0
  142. package/dist/backend/native-link-info.js.map +1 -0
  143. package/dist/backend/native-link-info.test.d.ts +1 -0
  144. package/dist/backend/native-link-info.test.js +134 -0
  145. package/dist/backend/native-link-info.test.js.map +1 -0
  146. package/dist/backend/{cc.d.ts → native-toolchain.d.ts} +54 -34
  147. package/dist/backend/{cc.js → native-toolchain.js} +231 -810
  148. package/dist/backend/native-toolchain.js.map +1 -0
  149. package/dist/backend/native-toolchain.test.d.ts +1 -0
  150. package/dist/backend/{cc-cache.test.js → native-toolchain.test.js} +219 -7
  151. package/dist/backend/native-toolchain.test.js.map +1 -0
  152. package/dist/backend/object-localize.js +1 -1
  153. package/dist/backend/runtime-abi.d.ts +10 -0
  154. package/dist/backend/runtime-abi.js +11 -0
  155. package/dist/backend/runtime-abi.js.map +1 -0
  156. package/dist/backend/runtime-pack-targets.test.d.ts +1 -0
  157. package/dist/backend/runtime-pack-targets.test.js +54 -0
  158. package/dist/backend/runtime-pack-targets.test.js.map +1 -0
  159. package/dist/backend/runtime-pack.d.ts +112 -0
  160. package/dist/backend/runtime-pack.js +305 -0
  161. package/dist/backend/runtime-pack.js.map +1 -0
  162. package/dist/backend/runtime-pack.test.d.ts +1 -0
  163. package/dist/backend/runtime-pack.test.js +473 -0
  164. package/dist/backend/runtime-pack.test.js.map +1 -0
  165. package/dist/backend/targets.d.ts +76 -0
  166. package/dist/backend/targets.js +262 -0
  167. package/dist/backend/targets.js.map +1 -0
  168. package/dist/backend/targets.test.d.ts +1 -0
  169. package/dist/backend/targets.test.js +41 -0
  170. package/dist/backend/targets.test.js.map +1 -0
  171. package/dist/backend/vendor-archives.d.ts +41 -0
  172. package/dist/backend/vendor-archives.js +462 -0
  173. package/dist/backend/vendor-archives.js.map +1 -0
  174. package/dist/compat/fetch-profile.d.ts +0 -1
  175. package/dist/compat/fetch-profile.js +0 -1
  176. package/dist/compat/fetch-profile.js.map +1 -1
  177. package/dist/coverage/report.js +3 -3
  178. package/dist/coverage/report.js.map +1 -1
  179. package/dist/coverage/surface-manifest.js +35 -33
  180. package/dist/coverage/surface-manifest.js.map +1 -1
  181. package/dist/diagnostics/diagnostic.d.ts +11 -12
  182. package/dist/diagnostics/diagnostic.js +19 -17
  183. package/dist/diagnostics/diagnostic.js.map +1 -1
  184. package/dist/diagnostics/render.d.ts +1 -1
  185. package/dist/diagnostics/render.js +1 -1
  186. package/dist/diagnostics/render.js.map +1 -1
  187. package/dist/errors.d.ts +5 -0
  188. package/dist/errors.js +9 -0
  189. package/dist/errors.js.map +1 -0
  190. package/dist/executable/{early-cache.d.ts → executable-cache.d.ts} +2 -2
  191. package/dist/executable/{early-cache.js → executable-cache.js} +36 -98
  192. package/dist/executable/executable-cache.js.map +1 -0
  193. package/dist/executable/executable-cache.test.d.ts +1 -0
  194. package/dist/executable/{early-cache.test.js → executable-cache.test.js} +3 -3
  195. package/dist/executable/executable-cache.test.js.map +1 -0
  196. package/dist/ffi/{profile.js → ffi-manifest.js} +1 -1
  197. package/dist/ffi/ffi-manifest.js.map +1 -0
  198. package/dist/frontend/builtin-modules.d.ts +21 -0
  199. package/dist/frontend/builtin-modules.js +82 -0
  200. package/dist/frontend/builtin-modules.js.map +1 -0
  201. package/dist/frontend/cjs-lexer.d.ts +7 -0
  202. package/dist/frontend/cjs-lexer.js +15 -17
  203. package/dist/frontend/cjs-lexer.js.map +1 -1
  204. package/dist/frontend/dts-paths.d.ts +26 -0
  205. package/dist/frontend/dts-paths.js +41 -0
  206. package/dist/frontend/dts-paths.js.map +1 -0
  207. package/dist/frontend/input-tracker.d.ts +0 -2
  208. package/dist/frontend/input-tracker.js +1 -4
  209. package/dist/frontend/input-tracker.js.map +1 -1
  210. package/dist/frontend/lib-contract.d.ts +1 -5
  211. package/dist/frontend/lib-contract.js +1 -1
  212. package/dist/frontend/lib-contract.js.map +1 -1
  213. package/dist/frontend/lib-exports.d.ts +1 -1
  214. package/dist/frontend/lowering/array-values.d.ts +8 -0
  215. package/dist/frontend/lowering/array-values.js +60 -0
  216. package/dist/frontend/lowering/array-values.js.map +1 -0
  217. package/dist/frontend/lowering/call-position.d.ts +4 -0
  218. package/dist/frontend/lowering/call-position.js +7 -0
  219. package/dist/frontend/lowering/call-position.js.map +1 -0
  220. package/dist/frontend/lowering/callback-arg.d.ts +20 -0
  221. package/dist/frontend/lowering/callback-arg.js +44 -0
  222. package/dist/frontend/lowering/callback-arg.js.map +1 -0
  223. package/dist/frontend/lowering/lib-boundary.d.ts +1 -1
  224. package/dist/frontend/lowering/lib-boundary.js +34 -34
  225. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  226. package/dist/frontend/lowering/lower-array-sort.d.ts +22 -0
  227. package/dist/frontend/lowering/lower-array-sort.js +619 -0
  228. package/dist/frontend/lowering/lower-array-sort.js.map +1 -0
  229. package/dist/frontend/lowering/lower-assert.d.ts +3 -3
  230. package/dist/frontend/lowering/lower-assert.js +214 -241
  231. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  232. package/dist/frontend/lowering/lower-builtins.d.ts +74 -146
  233. package/dist/frontend/lowering/lower-builtins.js +1285 -1233
  234. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  235. package/dist/frontend/lowering/lower-calls.d.ts +59 -192
  236. package/dist/frontend/lowering/lower-calls.js +1644 -1506
  237. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  238. package/dist/frontend/lowering/lower-classes.d.ts +62 -125
  239. package/dist/frontend/lowering/lower-classes.js +832 -866
  240. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  241. package/dist/frontend/lowering/lower-comptime.d.ts +5 -12
  242. package/dist/frontend/lowering/lower-comptime.js +32 -31
  243. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  244. package/dist/frontend/lowering/lower-containers.d.ts +35 -135
  245. package/dist/frontend/lowering/lower-containers.js +1984 -2227
  246. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  247. package/dist/frontend/lowering/lower-dgram.d.ts +3 -7
  248. package/dist/frontend/lowering/lower-dgram.js +97 -111
  249. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  250. package/dist/frontend/lowering/lower-enums.d.ts +4 -4
  251. package/dist/frontend/lowering/lower-enums.js +30 -30
  252. package/dist/frontend/lowering/lower-enums.js.map +1 -1
  253. package/dist/frontend/lowering/{lower-emitter.d.ts → lower-event-emitter.d.ts} +7 -18
  254. package/dist/frontend/lowering/{lower-emitter.js → lower-event-emitter.js} +172 -174
  255. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -0
  256. package/dist/frontend/lowering/lower-expando.d.ts +5 -5
  257. package/dist/frontend/lowering/lower-expando.js +40 -40
  258. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  259. package/dist/frontend/lowering/lower-exprs.d.ts +60 -264
  260. package/dist/frontend/lowering/lower-exprs.js +2361 -1765
  261. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  262. package/dist/frontend/lowering/lower-generators.d.ts +6 -6
  263. package/dist/frontend/lowering/lower-generators.js +73 -72
  264. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  265. package/dist/frontend/lowering/lower-inspect.d.ts +5 -17
  266. package/dist/frontend/lowering/lower-inspect.js +273 -261
  267. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  268. package/dist/frontend/lowering/lower-island.d.ts +39 -49
  269. package/dist/frontend/lowering/lower-island.js +447 -513
  270. package/dist/frontend/lowering/lower-island.js.map +1 -1
  271. package/dist/frontend/lowering/lower-mixins.d.ts +7 -10
  272. package/dist/frontend/lowering/lower-mixins.js +85 -85
  273. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  274. package/dist/frontend/lowering/lower-modules.d.ts +12 -18
  275. package/dist/frontend/lowering/lower-modules.js +284 -283
  276. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  277. package/dist/frontend/lowering/lower-namespaces.d.ts +23 -49
  278. package/dist/frontend/lowering/lower-namespaces.js +123 -115
  279. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  280. package/dist/frontend/lowering/lower-server.d.ts +18 -25
  281. package/dist/frontend/lowering/lower-server.js +909 -899
  282. package/dist/frontend/lowering/lower-server.js.map +1 -1
  283. package/dist/frontend/lowering/lower-stmts.d.ts +30 -149
  284. package/dist/frontend/lowering/lower-stmts.js +1463 -1285
  285. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  286. package/dist/frontend/lowering/lower-stream.d.ts +12 -12
  287. package/dist/frontend/lowering/lower-stream.js +300 -301
  288. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  289. package/dist/frontend/lowering/lower-test.d.ts +5 -5
  290. package/dist/frontend/lowering/lower-test.js +82 -82
  291. package/dist/frontend/lowering/lower-test.js.map +1 -1
  292. package/dist/frontend/lowering/lowerer.d.ts +134 -22
  293. package/dist/frontend/lowering/lowerer.js +1277 -126
  294. package/dist/frontend/lowering/lowerer.js.map +1 -1
  295. package/dist/frontend/lowering/pairs-snapshot.d.ts +11 -0
  296. package/dist/frontend/lowering/pairs-snapshot.js +85 -0
  297. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -0
  298. package/dist/frontend/lowering/static-this.d.ts +6 -0
  299. package/dist/frontend/lowering/static-this.js +24 -0
  300. package/dist/frontend/lowering/static-this.js.map +1 -0
  301. package/dist/frontend/lowering/surfaces.d.ts +24 -35
  302. package/dist/frontend/lowering/surfaces.js +78 -66
  303. package/dist/frontend/lowering/surfaces.js.map +1 -1
  304. package/dist/frontend/npm-static-rewrite.js +6 -28
  305. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  306. package/dist/frontend/npm-static.d.ts +0 -10
  307. package/dist/frontend/npm-static.js +4 -7
  308. package/dist/frontend/npm-static.js.map +1 -1
  309. package/dist/frontend/npm.d.ts +0 -24
  310. package/dist/frontend/npm.js +11 -85
  311. package/dist/frontend/npm.js.map +1 -1
  312. package/dist/frontend/program.d.ts +3 -1
  313. package/dist/frontend/program.js +9 -4
  314. package/dist/frontend/program.js.map +1 -1
  315. package/dist/frontend/provenance-registry.d.ts +0 -2
  316. package/dist/frontend/provenance-registry.js +0 -10
  317. package/dist/frontend/provenance-registry.js.map +1 -1
  318. package/dist/frontend/provenance.js +4 -7
  319. package/dist/frontend/provenance.js.map +1 -1
  320. package/dist/frontend/resolve.d.ts +7 -2
  321. package/dist/frontend/resolve.js +12 -17
  322. package/dist/frontend/resolve.js.map +1 -1
  323. package/dist/frontend/resolve.test.d.ts +1 -0
  324. package/dist/frontend/resolve.test.js +29 -0
  325. package/dist/frontend/resolve.test.js.map +1 -0
  326. package/dist/frontend/ts7/adapter.d.ts +2 -2
  327. package/dist/frontend/ts7/adapter.js +1 -1
  328. package/dist/frontend/ts7/adapter.js.map +1 -1
  329. package/dist/frontend/ts7/checker.js +2 -36
  330. package/dist/frontend/ts7/checker.js.map +1 -1
  331. package/dist/frontend/ts7/enums.js +2 -1
  332. package/dist/frontend/ts7/enums.js.map +1 -1
  333. package/dist/frontend/ts7/{program.js → program-adapter.js} +7 -6
  334. package/dist/frontend/ts7/program-adapter.js.map +1 -0
  335. package/dist/frontend/ts7/world-check.d.ts +1 -3
  336. package/dist/frontend/ts7/world-check.js +3 -1
  337. package/dist/frontend/ts7/world-check.js.map +1 -1
  338. package/dist/frontend/tsc-codes.d.ts +8 -0
  339. package/dist/frontend/tsc-codes.js +109 -0
  340. package/dist/frontend/tsc-codes.js.map +1 -0
  341. package/dist/frontend/{types.d.ts → type-mapper.d.ts} +2 -25
  342. package/dist/frontend/{types.js → type-mapper.js} +12 -11
  343. package/dist/frontend/type-mapper.js.map +1 -0
  344. package/dist/frontend/workspace-registry.d.ts +26 -0
  345. package/dist/frontend/workspace-registry.js +71 -0
  346. package/dist/frontend/workspace-registry.js.map +1 -0
  347. package/dist/index.d.ts +113 -31
  348. package/dist/index.js +536 -128
  349. package/dist/index.js.map +1 -1
  350. package/dist/ir/analysis.d.ts +37 -0
  351. package/dist/ir/analysis.js +118 -0
  352. package/dist/ir/analysis.js.map +1 -0
  353. package/dist/ir/analysis.test.d.ts +1 -0
  354. package/dist/ir/analysis.test.js +21 -0
  355. package/dist/ir/analysis.test.js.map +1 -0
  356. package/dist/ir/build.d.ts +9 -0
  357. package/dist/ir/build.js +33 -0
  358. package/dist/ir/build.js.map +1 -0
  359. package/dist/ir/integer-loops.d.ts +1 -1
  360. package/dist/ir/{nodes.d.ts → ir.d.ts} +119 -37
  361. package/dist/ir/{nodes.js → ir.js} +170 -166
  362. package/dist/ir/ir.js.map +1 -0
  363. package/dist/ir/ir.test.d.ts +1 -0
  364. package/dist/ir/ir.test.js +17 -0
  365. package/dist/ir/ir.test.js.map +1 -0
  366. package/dist/ir/serialize.d.ts +2 -2
  367. package/dist/ir/serialize.js +3 -2
  368. package/dist/ir/serialize.js.map +1 -1
  369. package/dist/ir/validate.d.ts +1 -1
  370. package/dist/ir/validate.js +93 -41
  371. package/dist/ir/validate.js.map +1 -1
  372. package/dist/library/cache-primitives.d.ts +24 -0
  373. package/dist/library/cache-primitives.js +83 -0
  374. package/dist/library/cache-primitives.js.map +1 -0
  375. package/dist/library/cache-reset.test.d.ts +1 -0
  376. package/dist/library/cache-reset.test.js +47 -0
  377. package/dist/library/cache-reset.test.js.map +1 -0
  378. package/dist/library/{implementation-identity.js → compiler-self-identity.js} +1 -1
  379. package/dist/library/compiler-self-identity.js.map +1 -0
  380. package/dist/library/fence-eval.d.ts +3 -1
  381. package/dist/library/fence-eval.js +8 -2
  382. package/dist/library/fence-eval.js.map +1 -1
  383. package/dist/library/int-infer.d.ts +1 -36
  384. package/dist/library/int-infer.js +29 -18
  385. package/dist/library/int-infer.js.map +1 -1
  386. package/dist/library/int-infer.test.js +4 -4
  387. package/dist/library/{early-cache.d.ts → library-cache.d.ts} +1 -1
  388. package/dist/library/{early-cache.js → library-cache.js} +34 -89
  389. package/dist/library/library-cache.js.map +1 -0
  390. package/dist/library/library-cache.test.d.ts +1 -0
  391. package/dist/library/{early-cache.test.js → library-cache.test.js} +7 -7
  392. package/dist/library/library-cache.test.js.map +1 -0
  393. package/dist/library/{profile.d.ts → library-profile.d.ts} +4 -7
  394. package/dist/library/{profile.js → library-profile.js} +18 -11
  395. package/dist/library/library-profile.js.map +1 -0
  396. package/dist/library/semantic-source.js +2 -1
  397. package/dist/library/semantic-source.js.map +1 -1
  398. package/dist/library/sidecar.d.ts +5 -2
  399. package/dist/library/sidecar.js +11 -5
  400. package/dist/library/sidecar.js.map +1 -1
  401. package/dist/startup-cache.d.ts +11 -3
  402. package/dist/startup-cache.js +17 -2
  403. package/dist/startup-cache.js.map +1 -1
  404. package/package.json +19 -2
  405. package/surface-manifest.json +5 -5
  406. package/dist/backend/cc-cache.test.js.map +0 -1
  407. package/dist/backend/cc.js.map +0 -1
  408. package/dist/backend/emission/emit-async.js.map +0 -1
  409. package/dist/backend/emission/emit-exprs.d.ts +0 -13
  410. package/dist/backend/emission/emit-exprs.js +0 -7407
  411. package/dist/backend/emission/emit-exprs.js.map +0 -1
  412. package/dist/backend/emission/emit-island.js.map +0 -1
  413. package/dist/backend/emission/emit-shapes.js.map +0 -1
  414. package/dist/backend/emission/emit-stmts.js.map +0 -1
  415. package/dist/backend/emission/emit-types.js.map +0 -1
  416. package/dist/backend/emission/emit-walkers.js.map +0 -1
  417. package/dist/backend/emission/emitter.js.map +0 -1
  418. package/dist/backend/emission/may-throw.js.map +0 -1
  419. package/dist/backend/library-identity.js.map +0 -1
  420. package/dist/executable/early-cache.js.map +0 -1
  421. package/dist/executable/early-cache.test.js.map +0 -1
  422. package/dist/ffi/profile.js.map +0 -1
  423. package/dist/frontend/lowering/lower-emitter.js.map +0 -1
  424. package/dist/frontend/shared.d.ts +0 -82
  425. package/dist/frontend/shared.js +0 -308
  426. package/dist/frontend/shared.js.map +0 -1
  427. package/dist/frontend/ts7/program.js.map +0 -1
  428. package/dist/frontend/types.js.map +0 -1
  429. package/dist/ir/nodes.js.map +0 -1
  430. package/dist/library/early-cache.js.map +0 -1
  431. package/dist/library/early-cache.test.js.map +0 -1
  432. package/dist/library/implementation-identity.js.map +0 -1
  433. package/dist/library/profile.js.map +0 -1
  434. /package/dist/backend/{cc-cache.test.d.ts → c/types.test.d.ts} +0 -0
  435. /package/dist/{executable/early-cache.test.d.ts → backend/llvm/shapes.test.d.ts} +0 -0
  436. /package/dist/{library/early-cache.test.d.ts → backend/native-codegen.test.d.ts} +0 -0
  437. /package/dist/ffi/{profile.d.ts → ffi-manifest.d.ts} +0 -0
  438. /package/dist/frontend/ts7/{program.d.ts → program-adapter.d.ts} +0 -0
  439. /package/dist/library/{implementation-identity.d.ts → compiler-self-identity.d.ts} +0 -0
@@ -39,10 +39,11 @@
39
39
  import * as ts from "../ts7/adapter.js";
40
40
  import { dynFallbackType, newFnCtx } from "./lowerer.js";
41
41
  import { isJsSourceFile, locOf } from "../program.js";
42
- import { arrayOf, BOOL, canBoxFuncIntoDyn, canConvertToDyn, DYN, F64, isUnitType, STRING, typeEquals, typeKey, VOID } from "../../ir/nodes.js";
42
+ import { arrayOf, BOOL, canBoxFuncIntoDyn, canConvertToDyn, DYN, F64, isUnitType, STRING, typeEquals, typeKey, VOID } from "../../ir/ir.js";
43
43
  import { streamForcedTuple, streamSidesOf } from "./lower-stream.js";
44
+ import { boolLit, strLit, varRef } from "../../ir/build.js";
44
45
  /** True when the class descends from (or is) the runtime emitter. */
45
- export function emitterRooted(L, info) {
46
+ export function emitterRooted(lowerer, info) {
46
47
  for (let c = info ?? null; c; c = c.base) {
47
48
  if (c.builtinEmitter)
48
49
  return true;
@@ -58,8 +59,8 @@ const META_EVENTS = new Set(["newListener", "removeListener"]);
58
59
  * receiver classes resolve). The scan is DIAGNOSTIC-FREE: unmappable
59
60
  * types and non-literal names are simply not candidates — the touching
60
61
  * sites speak for themselves when they lower. */
61
- function emitterEvents(L) {
62
- const holder = L;
62
+ function emitterEvents(lowerer) {
63
+ const holder = lowerer;
63
64
  if (holder.emitterEventTable)
64
65
  return holder.emitterEventTable;
65
66
  const table = new Map();
@@ -73,7 +74,7 @@ function emitterEvents(L) {
73
74
  table.set("error", { tuple: [{ kind: "object", className: "%Error" }], fromEmit: true, conflict: null, dynListener: false });
74
75
  table.set("newListener", { tuple: [STRING], fromEmit: true, conflict: null, dynListener: false });
75
76
  table.set("removeListener", { tuple: [STRING], fromEmit: true, conflict: null, dynListener: false });
76
- const fmt = (t) => L.fmt(t);
77
+ const fmt = (t) => lowerer.fmt(t);
77
78
  const mergeEmit = (name, args) => {
78
79
  if (args.some((a) => a === null))
79
80
  return; // its own site will diagnose
@@ -139,7 +140,7 @@ function emitterEvents(L) {
139
140
  }
140
141
  }
141
142
  };
142
- for (const sf of L.program.getSourceFiles()) {
143
+ for (const sf of lowerer.program.getSourceFiles()) {
143
144
  if (sf.isDeclarationFile)
144
145
  continue;
145
146
  const walk = (node) => {
@@ -156,13 +157,13 @@ function emitterEvents(L) {
156
157
  let recvT = null;
157
158
  let nameT = null;
158
159
  try {
159
- recvT = L.mapTypeOf(L.typeOf(node.expression.expression));
160
- nameT = L.typeOf(arg0);
160
+ recvT = lowerer.mapTypeOf(lowerer.typeOf(node.expression.expression));
161
+ nameT = lowerer.typeOf(arg0);
161
162
  }
162
163
  catch {
163
164
  return; // checker trouble is the lowering's business, not the scan's
164
165
  }
165
- if (recvT?.kind !== "object" || !emitterRooted(L, L.classes.get(recvT.className)))
166
+ if (recvT?.kind !== "object" || !emitterRooted(lowerer, lowerer.classes.get(recvT.className)))
166
167
  return;
167
168
  if (!nameT.isStringLiteralType())
168
169
  return;
@@ -173,15 +174,15 @@ function emitterEvents(L) {
173
174
  // tuples (lower-stream.ts) — their sites never join the program-
174
175
  // global table, so a stream's 'data' cannot collide with a user
175
176
  // event named 'data' on a plain emitter.
176
- if (streamForcedTuple(L, L.classes.get(recvT.className), name) !== null)
177
+ if (streamForcedTuple(lowerer, lowerer.classes.get(recvT.className), name) !== null)
177
178
  return;
178
179
  try {
179
180
  if (isEmit) {
180
- mergeEmit(name, node.arguments.slice(1).map((a) => L.mapTypeOf(L.typeOf(a))));
181
+ mergeEmit(name, node.arguments.slice(1).map((a) => lowerer.mapTypeOf(lowerer.typeOf(a))));
181
182
  }
182
183
  else if (node.arguments[1]) {
183
- const cbCt = L.typeOf(node.arguments[1]);
184
- const cbT = L.mapTypeOf(cbCt) ?? dynFallbackType(L, node.arguments[1], cbCt);
184
+ const cbCt = lowerer.typeOf(node.arguments[1]);
185
+ const cbT = lowerer.mapTypeOf(cbCt) ?? dynFallbackType(lowerer, node.arguments[1], cbCt);
185
186
  // Dyn-flavored listeners (a checked-dynamic value, or a func
186
187
  // with dyn parameters — the JS lane) register through the
187
188
  // adapter and constrain nothing: a dyn parameter accepts any
@@ -207,21 +208,19 @@ function emitterEvents(L) {
207
208
  /** The compile-time event name of the first argument, or a pointed fence
208
209
  * (string-literal TYPE, so const bindings and literal unions of one
209
210
  * member count — the staticHeaderKeyOf stance). */
210
- function eventNameOf(L, member, arg) {
211
- const t = L.typeOf(arg);
211
+ function eventNameOf(lowerer, member, arg) {
212
+ const t = lowerer.typeOf(arg);
212
213
  if (t.isStringLiteralType())
213
214
  return t.value;
214
- L.noLowering(`${member} with a non-literal event name`, arg, "event names must be compile-time string literals (each event's argument tuple is unified statically; symbol names have no lowering)");
215
+ lowerer.noLowering(`${member} with a non-literal event name`, arg, "event names must be compile-time string literals (each event's argument tuple is unified statically; symbol names have no lowering)");
215
216
  }
216
- const strLit = (value, loc) => ({ kind: "strLit", value, type: STRING, loc });
217
- const boolLit = (value, loc) => ({ kind: "boolLit", value, type: BOOL, loc });
218
217
  /** The event's unified tuple, with conflicts reported at this site. */
219
- function tupleOf(L, table, name, blame) {
218
+ function tupleOf(lowerer, table, name, blame) {
220
219
  const sig = table.get(name);
221
220
  if (!sig)
222
221
  return [];
223
222
  if (sig.conflict) {
224
- L.noLowering(`the event '${name}' with conflicting argument types`, blame, `every emit site and listener of one event name must agree on one argument tuple — ${sig.conflict}`);
223
+ lowerer.noLowering(`the event '${name}' with conflicting argument types`, blame, `every emit site and listener of one event name must agree on one argument tuple — ${sig.conflict}`);
225
224
  }
226
225
  return sig.tuple;
227
226
  }
@@ -230,15 +229,15 @@ function tupleOf(L, table, name, blame) {
230
229
  * "func" for a function whose parameters include dyn (the JS lane's
231
230
  * unannotated listeners — their checker type is any). Null for everything
232
231
  * else (the static path, with its own diagnostics). */
233
- function dynListenerFlavor(L, node) {
232
+ function dynListenerFlavor(lowerer, node) {
234
233
  let t;
235
234
  try {
236
- const ct = L.typeOf(node);
235
+ const ct = lowerer.typeOf(node);
237
236
  // The JS declaration fallback is what the EXPRESSION lowering applies
238
237
  // to inference residue (an inline `(a) => {}` maps null as a checker
239
238
  // type but lowers as a dyn-parameter function) — classify by the same
240
239
  // rule, so the flavor always matches what lowerExpr will produce.
241
- t = L.mapTypeOf(ct) ?? dynFallbackType(L, node, ct);
240
+ t = lowerer.mapTypeOf(ct) ?? dynFallbackType(lowerer, node, ct);
242
241
  }
243
242
  catch {
244
243
  return null;
@@ -251,7 +250,7 @@ function dynListenerFlavor(L, node) {
251
250
  // null): route it through the dyn path too — the registration helper's
252
251
  // checkListener throws Node's exact ERR_INVALID_ARG_TYPE TypeError
253
252
  // (the TS lane never reaches this: tsc rejects the argument first).
254
- if (t && t.kind !== "jsval" && (isUnitType(t) || canConvertToDyn(t, (id) => L.shapes.get(id), (id) => L.unions.get(id)))) {
253
+ if (t && t.kind !== "jsval" && (isUnitType(t) || canConvertToDyn(t, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))) {
255
254
  return "dyn";
256
255
  }
257
256
  return null;
@@ -277,25 +276,25 @@ function dynListenerFlavor(L, node) {
277
276
  * payloads — 'error' events), and the meta events (Node passes the
278
277
  * listener FUNCTION second, which has no dyn conversion — a dyn listener
279
278
  * reading it would see undefined). */
280
- function lowerDynListenerCall(L, member, name, tuple, receiver, cbNode, flavor, registering, once, prepend, loc,
279
+ function lowerDynListenerCall(lowerer, member, name, tuple, receiver, cbNode, flavor, registering, once, prepend, loc,
281
280
  /** Stream 'data': the adapter registers through emitter.onDataDyn so
282
281
  * the backend emits the two-slot DATA thunk (box by runtime tag); the
283
282
  * tuple is [DYN] — the adapter passes the boxed chunk through. */
284
283
  streamData) {
285
284
  if (META_EVENTS.has(name)) {
286
- L.noLowering(`'${member}' of '${name}' with a checked-dynamic listener`, cbNode, "Node passes the listener FUNCTION as the meta event's second argument, which has no dynamic conversion — annotate the listener's parameter as a string");
285
+ lowerer.noLowering(`'${member}' of '${name}' with a checked-dynamic listener`, cbNode, "Node passes the listener FUNCTION as the meta event's second argument, which has no dynamic conversion — annotate the listener's parameter as a string");
287
286
  }
288
- const getRecord = (id) => L.shapes.get(id);
289
- const getUnion = (id) => L.unions.get(id);
287
+ const getRecord = (id) => lowerer.shapes.get(id);
288
+ const getUnion = (id) => lowerer.unions.get(id);
290
289
  for (let i = 0; i < tuple.length; i++) {
291
290
  const p = tuple[i];
292
291
  if (p.kind !== "dyn" && !canConvertToDyn(p, getRecord, getUnion)) {
293
- L.noLowering(`'${member}' of '${name}' with a checked-dynamic listener`, cbNode, `the event's argument ${i} is '${L.fmt(p)}', which cannot box into a dynamic value — annotate the listener's parameters with the emitted types`);
292
+ lowerer.noLowering(`'${member}' of '${name}' with a checked-dynamic listener`, cbNode, `the event's argument ${i} is '${lowerer.fmt(p)}', which cannot box into a dynamic value — annotate the listener's parameters with the emitted types`);
294
293
  }
295
294
  }
296
295
  let cbDyn;
297
296
  if (flavor === "dyn") {
298
- const v = L.lowerExpr(cbNode);
297
+ const v = lowerer.lowerExpr(cbNode);
299
298
  if (v.type.kind === "dyn") {
300
299
  cbDyn = v;
301
300
  }
@@ -306,13 +305,13 @@ streamData) {
306
305
  cbDyn = { kind: "dynFrom", value: v, type: DYN, loc };
307
306
  }
308
307
  else {
309
- L.noLowering(`'${member}' with a non-function listener`, cbNode);
308
+ lowerer.noLowering(`'${member}' with a non-function listener`, cbNode);
310
309
  }
311
310
  }
312
311
  else {
313
- const cb = L.lowerExpr(cbNode);
312
+ const cb = lowerer.lowerExpr(cbNode);
314
313
  if (cb.type.kind !== "func" || !canBoxFuncIntoDyn(cb.type, getRecord, getUnion)) {
315
- L.noLowering(`'${member}' with a listener of this signature`, cbNode, "a checked-dynamic listener's own parameters and return must box across the dynamic boundary");
314
+ lowerer.noLowering(`'${member}' with a listener of this signature`, cbNode, "a checked-dynamic listener's own parameters and return must box across the dynamic boundary");
316
315
  }
317
316
  cbDyn = { kind: "dynFrom", value: cb, type: DYN, loc };
318
317
  }
@@ -322,15 +321,14 @@ streamData) {
322
321
  const key = registering
323
322
  ? `${onFn}:${typeKey(recvT)}:${typeKey(adapterT)}`
324
323
  : `emitter.offDyn:${typeKey(recvT)}`;
325
- const existing = L.arrHofHelpers.get(key);
324
+ const existing = lowerer.arrHofHelpers.get(key);
326
325
  let helper = existing;
327
326
  if (!helper) {
328
- helper = `%emitter.${registering ? "onDyn" : "offDyn"}.${L.arrHofHelpers.size}`;
329
- L.arrHofHelpers.set(key, helper);
330
- const ref = (localId, type) => ({ kind: "varRef", localId, type, loc });
327
+ helper = `%emitter.${registering ? "onDyn" : "offDyn"}.${lowerer.arrHofHelpers.size}`;
328
+ lowerer.arrHofHelpers.set(key, helper);
331
329
  const check = {
332
330
  kind: "exprStmt",
333
- expr: { kind: "libCall", fn: "emitter.checkListener", args: [ref("cb.0", DYN)], type: VOID, loc },
331
+ expr: { kind: "libCall", fn: "emitter.checkListener", args: [varRef("cb.0", DYN, loc)], type: VOID, loc },
334
332
  loc,
335
333
  };
336
334
  const params = [
@@ -350,13 +348,13 @@ streamData) {
350
348
  locals.push({ id: "a.0", name: "a", type: adapterT, mutable: false });
351
349
  body = [
352
350
  check,
353
- { kind: "varDecl", localId: "a.0", init: { kind: "dynCheck", value: ref("cb.0", DYN), type: adapterT, loc }, loc },
351
+ { kind: "varDecl", localId: "a.0", init: { kind: "dynCheck", value: varRef("cb.0", DYN, loc), type: adapterT, loc }, loc },
354
352
  {
355
353
  kind: "return",
356
354
  value: {
357
355
  kind: "libCall",
358
356
  fn: onFn,
359
- args: [ref("r.0", recvT), ref("n.0", STRING), ref("cb.0", DYN), ref("a.0", adapterT), ref("o.0", BOOL), ref("p.0", BOOL)],
357
+ args: [varRef("r.0", recvT, loc), varRef("n.0", STRING, loc), varRef("cb.0", DYN, loc), varRef("a.0", adapterT, loc), varRef("o.0", BOOL, loc), varRef("p.0", BOOL, loc)],
360
358
  type: recvT,
361
359
  loc,
362
360
  },
@@ -372,7 +370,7 @@ streamData) {
372
370
  value: {
373
371
  kind: "libCall",
374
372
  fn: "emitter.offDyn",
375
- args: [ref("r.0", recvT), ref("n.0", STRING), ref("cb.0", DYN)],
373
+ args: [varRef("r.0", recvT, loc), varRef("n.0", STRING, loc), varRef("cb.0", DYN, loc)],
376
374
  type: recvT,
377
375
  loc,
378
376
  },
@@ -380,7 +378,7 @@ streamData) {
380
378
  },
381
379
  ];
382
380
  }
383
- L.liftedFns.push({ name: helper, params, returnType: recvT, locals, body, loc });
381
+ lowerer.liftedFns.push({ name: helper, params, returnType: recvT, locals, body, loc });
384
382
  }
385
383
  return {
386
384
  kind: "call",
@@ -394,7 +392,7 @@ streamData) {
394
392
  }
395
393
  /** A listener argument: lowered, checked void-returning, and its
396
394
  * parameters checked as a typeEquals PREFIX of the event tuple. */
397
- function lowerListenerArg(L, member, name, node, tuple) {
395
+ function lowerListenerArg(lowerer, member, name, node, tuple) {
398
396
  // Unannotated non-empty parameter lists have no static types (checker
399
397
  // `any`; dyn in JS sources) — say so before the blanket type fence speaks.
400
398
  if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.parameters.length > 0) {
@@ -402,21 +400,21 @@ function lowerListenerArg(L, member, name, node, tuple) {
402
400
  if (p.type === undefined && ts.isIdentifier(p.name)) {
403
401
  const mapped = (() => {
404
402
  try {
405
- return L.mapTypeOf(L.typeOf(p.name));
403
+ return lowerer.mapTypeOf(lowerer.typeOf(p.name));
406
404
  }
407
405
  catch {
408
406
  return null;
409
407
  }
410
408
  })();
411
409
  if (mapped === null || mapped.kind === "dyn" || mapped.kind === "jsval") {
412
- L.noLowering(`'${member}' listeners with unannotated parameters`, p, "EventEmitter's declared listener type is (...args: any[]) — annotate each parameter with the emitted argument's type");
410
+ lowerer.noLowering(`'${member}' listeners with unannotated parameters`, p, "EventEmitter's declared listener type is (...args: any[]) — annotate each parameter with the emitted argument's type");
413
411
  }
414
412
  }
415
413
  }
416
414
  }
417
- const cb = L.lowerExpr(node);
415
+ const cb = lowerer.lowerExpr(node);
418
416
  if (cb.type.kind !== "func") {
419
- L.noLowering(`'${member}' with a non-function listener`, node);
417
+ lowerer.noLowering(`'${member}' with a non-function listener`, node);
420
418
  }
421
419
  const cbT = cb.type;
422
420
  // Node ignores listener return values, so value-returning listeners
@@ -425,14 +423,14 @@ function lowerListenerArg(L, member, name, node, tuple) {
425
423
  // and discards (releasing refcounted results). An async listener's
426
424
  // promise is abandoned unobserved (SEMANTICS.md).
427
425
  if (META_EVENTS.has(name) && cbT.params.length > 1) {
428
- L.noLowering(`'${name}' listeners taking the listener-function argument`, node, "meta-event listeners take at most the event name (the listener argument has no unified static type)");
426
+ lowerer.noLowering(`'${name}' listeners taking the listener-function argument`, node, "meta-event listeners take at most the event name (the listener argument has no unified static type)");
429
427
  }
430
428
  if (cbT.params.length > tuple.length) {
431
- L.noLowering(`a '${name}' listener declaring ${cbT.params.length} parameters where the event's tuple has ${tuple.length}`, node, "listeners may declare a prefix of the event's emitted arguments");
429
+ lowerer.noLowering(`a '${name}' listener declaring ${cbT.params.length} parameters where the event's tuple has ${tuple.length}`, node, "listeners may declare a prefix of the event's emitted arguments");
432
430
  }
433
431
  for (let i = 0; i < cbT.params.length; i++) {
434
432
  if (!typeEquals(cbT.params[i], tuple[i])) {
435
- L.noLowering(`a '${name}' listener whose parameter ${i} is '${L.fmt(cbT.params[i])}' where the event's tuple has '${L.fmt(tuple[i])}'`, node, "every emit site and listener of one event name must agree on one argument tuple");
433
+ lowerer.noLowering(`a '${name}' listener whose parameter ${i} is '${lowerer.fmt(cbT.params[i])}' where the event's tuple has '${lowerer.fmt(tuple[i])}'`, node, "every emit site and listener of one event name must agree on one argument tuple");
436
434
  }
437
435
  }
438
436
  return cb;
@@ -446,11 +444,11 @@ function lowerListenerArg(L, member, name, node, tuple) {
446
444
  * NEVER dispatches through an override at-or-below the lexical class —
447
445
  * JS's static super dispatch (the nearest override STRICTLY ABOVE the
448
446
  * lexical class still answers, exactly like a prototype-chain walk). */
449
- export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
447
+ export function lowerEmitterMethodCall(lowerer, call, access, info, superRecv) {
450
448
  const member = access.name.text;
451
449
  const loc = locOf(call);
452
450
  const args = call.arguments;
453
- const lowerReceiver = () => superRecv?.thisRef ?? L.lowerExpr(access.expression);
451
+ const lowerReceiver = () => superRecv?.thisRef ?? lowerer.lowerExpr(access.expression);
454
452
  // The class VALUE, not an instance (`EventEmitter.setMaxListeners(n)` —
455
453
  // the receiver's checker type carries construct signatures; mapType
456
454
  // answers the instance object for every EventEmitter-symbol type, so the
@@ -459,13 +457,13 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
459
457
  // are a DIFFERENT surface: setMaxListeners(n) writes the process-wide
460
458
  // defaultMaxListeners (validated at runtime — Node's ERR_OUT_OF_RANGE);
461
459
  // everything else fences by its static name.
462
- if (superRecv === undefined && L.checker.getConstructSignatures(L.typeOf(access.expression)).length > 0) {
460
+ if (superRecv === undefined && lowerer.checker.getConstructSignatures(lowerer.typeOf(access.expression)).length > 0) {
463
461
  if (member === "setMaxListeners" && args.length === 1) {
464
- if (L.mapTypeOf(L.typeOf(args[0]))?.kind !== "f64") {
462
+ if (lowerer.mapTypeOf(lowerer.typeOf(args[0]))?.kind !== "f64") {
465
463
  // Node's runtime ladder over the dyn value ("setMaxListeners" is
466
464
  // the message's slot for the static form).
467
- const raw = L.lowerExpr(args[0]);
468
- if (raw.type.kind === "dyn" || raw.kind === "unitLit" || L.dynConvertible(raw.type)) {
465
+ const raw = lowerer.lowerExpr(args[0]);
466
+ if (raw.type.kind === "dyn" || raw.kind === "unitLit" || lowerer.dynConvertible(raw.type)) {
469
467
  const n = raw.type.kind === "dyn" ? raw : { kind: "dynFrom", value: raw, type: DYN, loc };
470
468
  return {
471
469
  kind: "libCall",
@@ -476,9 +474,9 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
476
474
  };
477
475
  }
478
476
  }
479
- const n = L.lowerExprExpecting(args[0], F64);
477
+ const n = lowerer.lowerExprExpecting(args[0], F64);
480
478
  if (n.type.kind !== "f64") {
481
- L.noLowering(`EventEmitter.setMaxListeners with a '${L.fmt(n.type)}' argument`, args[0], "the lowered form takes a number (Node throws ERR_INVALID_ARG_TYPE at runtime for other values)");
479
+ lowerer.noLowering(`EventEmitter.setMaxListeners with a '${lowerer.fmt(n.type)}' argument`, args[0], "the lowered form takes a number (Node throws ERR_INVALID_ARG_TYPE at runtime for other values)");
482
480
  }
483
481
  return { kind: "libCall", fn: "emitter.setDefaultMax", args: [n], type: VOID, loc };
484
482
  }
@@ -489,14 +487,14 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
489
487
  // when n is a pure read (identifier/literal — nothing to evaluate)
490
488
  // and the target crosses into the checked-dynamic tree for the Received tail.
491
489
  if (args.length === 2 && !args.some(ts.isSpreadElement)) {
492
- const nT = L.mapTypeOf(L.typeOf(args[0]));
493
- const tT = L.mapTypeOf(L.typeOf(args[1]));
490
+ const nT = lowerer.mapTypeOf(lowerer.typeOf(args[0]));
491
+ const tT = lowerer.mapTypeOf(lowerer.typeOf(args[1]));
494
492
  const nPure = ts.isIdentifier(args[0]) || ts.isLiteralExpression(args[0]);
495
493
  const targetNotEmitter = tT !== null && tT.kind !== "dyn" && tT.kind !== "jsval" &&
496
494
  !(tT.kind === "object");
497
495
  if (nT?.kind === "f64" && nPure && targetNotEmitter) {
498
- const raw = L.lowerExpr(args[1]);
499
- if (raw.type.kind === "dyn" || raw.kind === "unitLit" || L.dynConvertible(raw.type)) {
496
+ const raw = lowerer.lowerExpr(args[1]);
497
+ if (raw.type.kind === "dyn" || raw.kind === "unitLit" || lowerer.dynConvertible(raw.type)) {
500
498
  const got = raw.type.kind === "dyn" ? raw : { kind: "dynFrom", value: raw, type: DYN, loc };
501
499
  return {
502
500
  kind: "libCall",
@@ -512,20 +510,20 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
512
510
  }
513
511
  }
514
512
  }
515
- L.noLowering(`EventEmitter.setMaxListeners with ${args.length} arguments`, call, "the lowered static form is EventEmitter.setMaxListeners(n) — per-target application (…, ...eventTargets) has no lowering; call target.setMaxListeners(n) instead");
513
+ lowerer.noLowering(`EventEmitter.setMaxListeners with ${args.length} arguments`, call, "the lowered static form is EventEmitter.setMaxListeners(n) — per-target application (…, ...eventTargets) has no lowering; call target.setMaxListeners(n) instead");
516
514
  }
517
- L.noLowering(`the static EventEmitter.${member} form`, call, "instance emitters lower this member; the class-value statics have no lowering yet");
515
+ lowerer.noLowering(`the static EventEmitter.${member} form`, call, "instance emitters lower this member; the class-value statics have no lowering yet");
518
516
  }
519
- const table = emitterEvents(L);
517
+ const table = emitterEvents(lowerer);
520
518
  if (REGISTER_MEMBERS.has(member) || member === "off" || member === "removeListener") {
521
519
  // Node's (type, listener) signature IGNORES extra arguments — admit
522
520
  // pure-read extras (literals/identifiers: nothing to evaluate) and
523
521
  // drop them; anything with effects keeps the fence.
524
522
  const extrasPure = args.slice(2).every((a) => ts.isIdentifier(a) || ts.isLiteralExpression(a));
525
523
  if (args.length < 2 || !extrasPure) {
526
- L.noLowering(`${member} with ${args.length} arguments`, call, "the supported form is (eventName, listener)");
524
+ lowerer.noLowering(`${member} with ${args.length} arguments`, call, "the supported form is (eventName, listener)");
527
525
  }
528
- const name = eventNameOf(L, member, args[0]);
526
+ const name = eventNameOf(lowerer, member, args[0]);
529
527
  const registering = REGISTER_MEMBERS.has(member);
530
528
  // The runtime fires the meta events INTERNALLY (scr_ee_emit_meta —
531
529
  // Node calls this.emit, which would dispatch through an emit
@@ -535,7 +533,7 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
535
533
  if (registering && META_EVENTS.has(name)) {
536
534
  const ov = emitOverrideComparable(info);
537
535
  if (ov) {
538
- L.noLowering(`'${member}' of '${name}' while '${ov.def.jsName || ov.def.name}' overrides emit`, call, "the runtime fires meta events internally, which cannot route through an emit override");
536
+ lowerer.noLowering(`'${member}' of '${name}' while '${ov.def.jsName || ov.def.name}' overrides emit`, call, "the runtime fires meta events internally, which cannot route through an emit override");
539
537
  }
540
538
  }
541
539
  const receiver = lowerReceiver();
@@ -545,23 +543,23 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
545
543
  // encoded streams deliver strings; scr_stream_emit_data): listeners
546
544
  // on readable-sided receivers register through DATA thunks that
547
545
  // unwrap the declared side (typed) or box by tag (dyn).
548
- const sides = streamSidesOf(L, info);
546
+ const sides = streamSidesOf(lowerer, info);
549
547
  if (name === "data" && (sides === "r" || sides === "rw")) {
550
- const dynFlavor = dynListenerFlavor(L, args[1]);
548
+ const dynFlavor = dynListenerFlavor(lowerer, args[1]);
551
549
  if (dynFlavor !== null) {
552
- return lowerDynListenerCall(L, member, name, [DYN], receiver, args[1], dynFlavor, registering, once, prepend, loc, true);
550
+ return lowerDynListenerCall(lowerer, member, name, [DYN], receiver, args[1], dynFlavor, registering, once, prepend, loc, true);
553
551
  }
554
- const cb = L.lowerExpr(args[1]);
552
+ const cb = lowerer.lowerExpr(args[1]);
555
553
  if (cb.type.kind !== "func") {
556
- L.noLowering(`'${member}' with a non-function listener`, args[1]);
554
+ lowerer.noLowering(`'${member}' with a non-function listener`, args[1]);
557
555
  }
558
556
  const cbT = cb.type;
559
557
  if (cbT.params.length > 1) {
560
- L.noLowering(`a 'data' listener declaring ${cbT.params.length} parameters where the event carries one chunk`, args[1]);
558
+ lowerer.noLowering(`a 'data' listener declaring ${cbT.params.length} parameters where the event carries one chunk`, args[1]);
561
559
  }
562
560
  const p = cbT.params[0];
563
561
  if (p !== undefined && !(p.kind === "bytes" && p.elem === "u8") && p.kind !== "string") {
564
- L.noLowering(`a 'data' listener whose chunk parameter is '${L.fmt(p)}'`, args[1], "chunks are Buffers — or strings once setEncoding/the encoding option applies");
562
+ lowerer.noLowering(`a 'data' listener whose chunk parameter is '${lowerer.fmt(p)}'`, args[1], "chunks are Buffers — or strings once setEncoding/the encoding option applies");
565
563
  }
566
564
  if (!registering) {
567
565
  return {
@@ -583,12 +581,12 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
583
581
  // Stream-rooted receivers consult the per-base FORCED tuples first
584
582
  // (runtime-emitted 'end'/'pipe'/... payloads); the dyn-listener check
585
583
  // below then sees the forced tuple exactly like a table one.
586
- const tuple = streamForcedTuple(L, info, name) ?? tupleOf(L, table, name, call);
587
- const dynFlavor = dynListenerFlavor(L, args[1]);
584
+ const tuple = streamForcedTuple(lowerer, info, name) ?? tupleOf(lowerer, table, name, call);
585
+ const dynFlavor = dynListenerFlavor(lowerer, args[1]);
588
586
  if (dynFlavor !== null) {
589
- return lowerDynListenerCall(L, member, name, tuple, receiver, args[1], dynFlavor, registering, once, prepend, loc, false);
587
+ return lowerDynListenerCall(lowerer, member, name, tuple, receiver, args[1], dynFlavor, registering, once, prepend, loc, false);
590
588
  }
591
- const cb = lowerListenerArg(L, member, name, args[1], tuple);
589
+ const cb = lowerListenerArg(lowerer, member, name, args[1], tuple);
592
590
  return {
593
591
  kind: "libCall",
594
592
  fn: registering ? "emitter.on" : "emitter.off",
@@ -601,41 +599,41 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
601
599
  }
602
600
  if (member === "emit") {
603
601
  if (args.length === 0) {
604
- L.noLowering("emit without an event name", call);
602
+ lowerer.noLowering("emit without an event name", call);
605
603
  }
606
- const name = eventNameOf(L, member, args[0]);
604
+ const name = eventNameOf(lowerer, member, args[0]);
607
605
  const receiver = lowerReceiver();
608
606
  if (name === "error") {
609
607
  // The special event: exactly one %Error-rooted payload; no listener
610
608
  // means the runtime THROWS it (emitter.emitError, may-throw).
611
609
  if (args.length !== 2) {
612
- L.noLowering(`emit('error') with ${args.length - 1} payload arguments`, call, "the supported form is emit('error', err) with an Error-hierarchy payload (non-Error payloads would need Node's ERR_UNHANDLED_ERROR wrapping — no lowering yet)");
610
+ lowerer.noLowering(`emit('error') with ${args.length - 1} payload arguments`, call, "the supported form is emit('error', err) with an Error-hierarchy payload (non-Error payloads would need Node's ERR_UNHANDLED_ERROR wrapping — no lowering yet)");
613
611
  }
614
- const err = L.lowerExpr(args[1]);
612
+ const err = lowerer.lowerExpr(args[1]);
615
613
  const rootsAtError = (t) => {
616
614
  if (t.kind !== "object")
617
615
  return false;
618
- for (let c = L.classes.get(t.className) ?? null; c; c = c.base) {
616
+ for (let c = lowerer.classes.get(t.className) ?? null; c; c = c.base) {
619
617
  if (c.def.name === "%Error")
620
618
  return true;
621
619
  }
622
620
  return false;
623
621
  };
624
622
  if (!rootsAtError(err.type)) {
625
- L.noLowering(`emit('error') with a '${L.fmt(err.type)}' payload`, args[1], "the supported payload is an Error-hierarchy instance");
623
+ lowerer.noLowering(`emit('error') with a '${lowerer.fmt(err.type)}' payload`, args[1], "the supported payload is an Error-hierarchy instance");
626
624
  }
627
- return emitDispatchExpr(L, info, name, [{ kind: "object", className: "%Error" }], receiver, [L.upcastTo(err, "%Error")], superRecv?.cls, loc);
625
+ return emitDispatchExpr(lowerer, info, name, [{ kind: "object", className: "%Error" }], receiver, [lowerer.upcastTo(err, "%Error")], superRecv?.cls, loc);
628
626
  }
629
627
  // Stream 'data' rides the two-slot payload ABI: a user emit fills
630
628
  // the chunk's slot (bytes or string), NULLs the other.
631
- const emitSides = streamSidesOf(L, info);
629
+ const emitSides = streamSidesOf(lowerer, info);
632
630
  if (name === "data" && (emitSides === "r" || emitSides === "rw")) {
633
631
  if (args.length !== 2) {
634
- L.noLowering(`emit('data') with ${args.length - 1} payload arguments`, call, "the event carries one chunk (a Buffer or string)");
632
+ lowerer.noLowering(`emit('data') with ${args.length - 1} payload arguments`, call, "the event carries one chunk (a Buffer or string)");
635
633
  }
636
- const chunk = L.lowerExpr(args[1]);
634
+ const chunk = lowerer.lowerExpr(args[1]);
637
635
  if (!(chunk.type.kind === "bytes" && chunk.type.elem === "u8") && chunk.type.kind !== "string") {
638
- L.noLowering(`emit('data') with a '${L.fmt(chunk.type)}' chunk`, args[1], "chunks are Buffers or strings");
636
+ lowerer.noLowering(`emit('data') with a '${lowerer.fmt(chunk.type)}' chunk`, args[1], "chunks are Buffers or strings");
639
637
  }
640
638
  return {
641
639
  kind: "libCall",
@@ -645,25 +643,25 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
645
643
  loc,
646
644
  };
647
645
  }
648
- const tuple = streamForcedTuple(L, info, name) ?? tupleOf(L, table, name, call);
646
+ const tuple = streamForcedTuple(lowerer, info, name) ?? tupleOf(lowerer, table, name, call);
649
647
  if (args.length - 1 !== tuple.length) {
650
- L.noLowering(`emit('${name}') with ${args.length - 1} arguments where the event's tuple has ${tuple.length}`, call, "every emit site of one event name must supply the same argument tuple (listeners may declare a prefix)");
648
+ lowerer.noLowering(`emit('${name}') with ${args.length - 1} arguments where the event's tuple has ${tuple.length}`, call, "every emit site of one event name must supply the same argument tuple (listeners may declare a prefix)");
651
649
  }
652
- const payload = args.slice(1).map((a, i) => L.lowerExprExpecting(a, tuple[i]));
653
- return emitDispatchExpr(L, info, name, tuple, receiver, payload, superRecv?.cls, loc);
650
+ const payload = args.slice(1).map((a, i) => lowerer.lowerExprExpecting(a, tuple[i]));
651
+ return emitDispatchExpr(lowerer, info, name, tuple, receiver, payload, superRecv?.cls, loc);
654
652
  }
655
653
  // The pure-introspection members take ANY string-typed name — no tuple
656
654
  // is involved, so the literal rule has nothing to protect (a meta
657
655
  // listener naturally passes its name parameter along).
658
656
  if (member === "removeAllListeners") {
659
657
  if (args.length > 1) {
660
- L.noLowering(`removeAllListeners with ${args.length} arguments`, call);
658
+ lowerer.noLowering(`removeAllListeners with ${args.length} arguments`, call);
661
659
  }
662
660
  const all = args.length === 0;
663
661
  const receiver = lowerReceiver();
664
- const name = all ? strLit("", loc) : L.lowerExprExpecting(args[0], STRING);
662
+ const name = all ? strLit("", loc) : lowerer.lowerExprExpecting(args[0], STRING);
665
663
  if (name.type.kind !== "string") {
666
- L.noLowering(`removeAllListeners with a '${L.fmt(name.type)}' event name`, args[0] ?? call);
664
+ lowerer.noLowering(`removeAllListeners with a '${lowerer.fmt(name.type)}' event name`, args[0] ?? call);
667
665
  }
668
666
  return {
669
667
  kind: "libCall",
@@ -675,19 +673,19 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
675
673
  }
676
674
  if (member === "listenerCount") {
677
675
  if (args.length !== 1 && args.length !== 2) {
678
- L.noLowering(`listenerCount with ${args.length} arguments`, call);
676
+ lowerer.noLowering(`listenerCount with ${args.length} arguments`, call);
679
677
  }
680
678
  const receiver = lowerReceiver();
681
- const name = L.lowerExprExpecting(args[0], STRING);
679
+ const name = lowerer.lowerExprExpecting(args[0], STRING);
682
680
  if (name.type.kind !== "string") {
683
- L.noLowering(`listenerCount with a '${L.fmt(name.type)}' event name`, args[0]);
681
+ lowerer.noLowering(`listenerCount with a '${lowerer.fmt(name.type)}' event name`, args[0]);
684
682
  }
685
683
  if (args.length === 2) {
686
684
  // The fn filter matches by identity — the listener's own type is
687
685
  // its word; no tuple check is needed to count.
688
- const cb = L.lowerExpr(args[1]);
686
+ const cb = lowerer.lowerExpr(args[1]);
689
687
  if (cb.type.kind !== "func") {
690
- L.noLowering(`listenerCount with a non-function filter`, args[1]);
688
+ lowerer.noLowering(`listenerCount with a non-function filter`, args[1]);
691
689
  }
692
690
  return { kind: "libCall", fn: "emitter.countFn", args: [receiver, name, cb], type: F64, loc };
693
691
  }
@@ -704,16 +702,16 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
704
702
  // once wrapper is runtime-internal, so rawListeners' wrapper identity
705
703
  // is a documented divergence (SEMANTICS.md).
706
704
  if (args.length !== 1) {
707
- L.noLowering(`${member} with ${args.length} arguments`, call, "the supported form is (eventName)");
705
+ lowerer.noLowering(`${member} with ${args.length} arguments`, call, "the supported form is (eventName)");
708
706
  }
709
- const name = eventNameOf(L, member, args[0]);
707
+ const name = eventNameOf(lowerer, member, args[0]);
710
708
  const sig = table.get(name);
711
709
  if (sig?.dynListener) {
712
710
  // A dyn-adapted registration means the runtime bucket can hold
713
711
  // originals of MIXED signatures — no one honest element type.
714
- L.noLowering(`${member} of the event '${name}'`, call, "a listener of this event is checked-dynamic (unannotated parameters), so the listener array has no one static element type — listenerCount(name) counts");
712
+ lowerer.noLowering(`${member} of the event '${name}'`, call, "a listener of this event is checked-dynamic (unannotated parameters), so the listener array has no one static element type — listenerCount(name) counts");
715
713
  }
716
- const tuple = tupleOf(L, table, name, call);
714
+ const tuple = tupleOf(lowerer, table, name, call);
717
715
  const receiver = lowerReceiver();
718
716
  return {
719
717
  kind: "libCall",
@@ -725,30 +723,30 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
725
723
  }
726
724
  if (member === "eventNames") {
727
725
  if (args.length !== 0)
728
- L.noLowering(`eventNames with ${args.length} arguments`, call);
726
+ lowerer.noLowering(`eventNames with ${args.length} arguments`, call);
729
727
  const receiver = lowerReceiver();
730
728
  return { kind: "libCall", fn: "emitter.names", args: [receiver], type: arrayOf(STRING), loc };
731
729
  }
732
730
  if (member === "setMaxListeners") {
733
731
  if (args.length !== 1)
734
- L.noLowering(`setMaxListeners with ${args.length} arguments`, call);
732
+ lowerer.noLowering(`setMaxListeners with ${args.length} arguments`, call);
735
733
  const receiver = lowerReceiver();
736
- if (L.mapTypeOf(L.typeOf(args[0]))?.kind !== "f64") {
734
+ if (lowerer.mapTypeOf(lowerer.typeOf(args[0]))?.kind !== "f64") {
737
735
  // The invalid-input probes (string n, dyn helpers): Node's ladder
738
736
  // runs at runtime — ERR_INVALID_ARG_TYPE for non-numbers,
739
737
  // ERR_OUT_OF_RANGE below zero, and a well-typed dyn still applies.
740
- const raw = L.lowerExpr(args[0]);
741
- if (raw.type.kind === "dyn" || raw.kind === "unitLit" || L.dynConvertible(raw.type)) {
738
+ const raw = lowerer.lowerExpr(args[0]);
739
+ if (raw.type.kind === "dyn" || raw.kind === "unitLit" || lowerer.dynConvertible(raw.type)) {
742
740
  const n = raw.type.kind === "dyn" ? raw : { kind: "dynFrom", value: raw, type: DYN, loc };
743
741
  return { kind: "libCall", fn: "emitter.setMaxChk", args: [receiver, n], type: receiver.type, loc };
744
742
  }
745
743
  }
746
- const n = L.lowerExprExpecting(args[0], F64);
744
+ const n = lowerer.lowerExprExpecting(args[0], F64);
747
745
  return { kind: "libCall", fn: "emitter.setMax", args: [receiver, n], type: receiver.type, loc };
748
746
  }
749
747
  if (member === "getMaxListeners") {
750
748
  if (args.length !== 0)
751
- L.noLowering(`getMaxListeners with ${args.length} arguments`, call);
749
+ lowerer.noLowering(`getMaxListeners with ${args.length} arguments`, call);
752
750
  const receiver = lowerReceiver();
753
751
  return { kind: "libCall", fn: "emitter.getMax", args: [receiver], type: F64, loc };
754
752
  }
@@ -757,7 +755,7 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
757
755
  /** Why a subclass `emit` declaration is NOT the forwarding shape, or null
758
756
  * when it conforms. Checked at class collection; the recorded override
759
757
  * then lowers per event with no further shape questions. */
760
- export function emitOverrideShapeReason(L, member) {
758
+ export function emitOverrideShapeReason(lowerer, member) {
761
759
  if (!member.body)
762
760
  return "the declaration has no body";
763
761
  if (member.asteriskToken !== undefined)
@@ -793,14 +791,14 @@ export function emitOverrideShapeReason(L, member) {
793
791
  // lowering anyway). JS: unannotated is the only spelling (checker
794
792
  // `any`); the specialization binds it as the string it always is —
795
793
  // event names are compile-time literals program-wide.
796
- const p0T = L.mapTypeOf(L.typeOf(p0.name));
794
+ const p0T = lowerer.mapTypeOf(lowerer.typeOf(p0.name));
797
795
  const jsUnannotated = p0.type === undefined && isJsSourceFile(member.getSourceFile()) &&
798
796
  (p0T === null || p0T.kind === "dyn" || p0T.kind === "jsval");
799
797
  if (p0T?.kind !== "string" && !jsUnannotated) {
800
798
  return "the event parameter must be typed 'string' (symbol event names have no lowering)";
801
799
  }
802
- const sig = L.checker.getSignatureFromDeclaration(member);
803
- const ret = sig ? L.mapTypeOf(L.checker.getReturnTypeOfSignature(sig)) : null;
800
+ const sig = lowerer.checker.getSignatureFromDeclaration(member);
801
+ const ret = sig ? lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(sig)) : null;
804
802
  if (ret?.kind !== "bool") {
805
803
  return "every code path must return a boolean (emit's contract)";
806
804
  }
@@ -808,8 +806,8 @@ export function emitOverrideShapeReason(L, member) {
808
806
  catch {
809
807
  return "its signature does not resolve statically";
810
808
  }
811
- const eventSym = L.checker.getSymbolAtLocation(p0.name);
812
- const restSym = L.checker.getSymbolAtLocation(p1.name);
809
+ const eventSym = lowerer.checker.getSymbolAtLocation(p0.name);
810
+ const restSym = lowerer.checker.getSymbolAtLocation(p1.name);
813
811
  if (!eventSym || !restSym)
814
812
  return "its parameters do not resolve statically";
815
813
  let reason = null;
@@ -819,12 +817,12 @@ export function emitOverrideShapeReason(L, member) {
819
817
  if (ts.isIdentifier(n)) {
820
818
  let s;
821
819
  try {
822
- s = L.checker.getSymbolAtLocation(n) ?? undefined;
820
+ s = lowerer.checker.getSymbolAtLocation(n) ?? undefined;
823
821
  }
824
822
  catch {
825
823
  s = undefined;
826
824
  }
827
- if (s === restSym && !isEmitForwardSpread(L, member, n, eventSym)) {
825
+ if (s === restSym && !isEmitForwardSpread(lowerer, member, n, eventSym)) {
828
826
  reason = "the rest parameter may only forward through super.emit(event, ...args) in the method's own body";
829
827
  }
830
828
  else if (s === eventSym && n !== p0.name && isWriteTarget(n)) {
@@ -840,7 +838,7 @@ export function emitOverrideShapeReason(L, member) {
840
838
  * `super.emit(<event param>, ...<this identifier>)`, two arguments, sitting
841
839
  * in the override method's OWN body (a nested function could not reach the
842
840
  * specialization's tuple parameters). */
843
- function isEmitForwardSpread(L, method, id, eventSym) {
841
+ function isEmitForwardSpread(lowerer, method, id, eventSym) {
844
842
  const sp = id.parent;
845
843
  if (!ts.isSpreadElement(sp) || sp.expression !== id)
846
844
  return false;
@@ -857,7 +855,7 @@ function isEmitForwardSpread(L, method, id, eventSym) {
857
855
  if (!ts.isIdentifier(a0))
858
856
  return false;
859
857
  try {
860
- if (L.checker.getSymbolAtLocation(a0) !== eventSym)
858
+ if (lowerer.checker.getSymbolAtLocation(a0) !== eventSym)
861
859
  return false;
862
860
  }
863
861
  catch {
@@ -903,7 +901,7 @@ function isWriteTarget(id) {
903
901
  }
904
902
  }
905
903
  /** The nearest class at-or-above `info` declaring an emit override. */
906
- export function emitOverrideAtOrAbove(info) {
904
+ function emitOverrideAtOrAbove(info) {
907
905
  for (let c = info ?? null; c; c = c.base) {
908
906
  if (c.emitOverride)
909
907
  return c;
@@ -937,7 +935,7 @@ function topmostEmitOverridesBelow(info) {
937
935
  /** An emit-override class COMPARABLE to `info` (ancestor-or-self or
938
936
  * descendant — a dynamic instance under this static type could dispatch
939
937
  * through it), or null. The meta-registration fence's test. */
940
- export function emitOverrideComparable(info) {
938
+ function emitOverrideComparable(info) {
941
939
  const above = emitOverrideAtOrAbove(info);
942
940
  if (above)
943
941
  return above;
@@ -949,12 +947,12 @@ export function emitOverrideComparable(info) {
949
947
  * method on the class (vtable participation — the ABI is `(this, ...tuple)
950
948
  * => bool` for every declarer of one event, override-exact by
951
949
  * construction) and queues the body for the drive loop's fixpoint. */
952
- export function ensureEmitSpec(L, info, event, tuple) {
950
+ function ensureEmitSpec(lowerer, info, event, tuple) {
953
951
  const mName = `emit:${event}`;
954
952
  const key = `%${info.def.name}.${mName}`;
955
- if (L.emitSpecDone.has(key))
953
+ if (lowerer.emitSpecDone.has(key))
956
954
  return;
957
- L.emitSpecDone.add(key);
955
+ lowerer.emitSpecDone.add(key);
958
956
  if (!info.methods.has(mName)) {
959
957
  info.methods.set(mName, { params: tuple.map((t) => ({ type: t, mode: "required" })), ret: BOOL });
960
958
  if (info.def.methods)
@@ -962,56 +960,56 @@ export function ensureEmitSpec(L, info, event, tuple) {
962
960
  else
963
961
  info.def.methods = [mName];
964
962
  }
965
- const ordinal = L.emitSpecQueue.filter((q) => q.info === info).length;
966
- L.emitSpecQueue.push({ info, event, tuple, ordinal });
963
+ const ordinal = lowerer.emitSpecQueue.filter((q) => q.info === info).length;
964
+ lowerer.emitSpecQueue.push({ info, event, tuple, ordinal });
967
965
  }
968
966
  /** One specialization body: the override method's statements lowered with
969
967
  * `event` bound to the name and hidden tuple parameters standing in for
970
968
  * the rest parameter (readable ONLY through the super-forward, which the
971
969
  * collection shape check guaranteed). */
972
- export function lowerEmitOverrideSpec(L, req) {
970
+ export function lowerEmitOverrideSpec(lowerer, req) {
973
971
  const { info, event, tuple, ordinal } = req;
974
972
  const ov = info.emitOverride;
975
973
  if (!ov?.decl.body)
976
974
  return null;
977
975
  const className = info.def.name;
978
976
  const thisType = { kind: "object", className };
979
- const prevClass = L.currentClass;
980
- const prevSpec = L.emitSpecCtx;
981
- const prevSuppress = L.suppressStats;
982
- L.currentClass = info;
983
- L.suppressStats = prevSuppress || ordinal > 0;
984
- L.fnStack.push(newFnCtx(false, null, null, BOOL));
977
+ const prevClass = lowerer.currentClass;
978
+ const prevSpec = lowerer.emitSpecCtx;
979
+ const prevSuppress = lowerer.suppressStats;
980
+ lowerer.currentClass = info;
981
+ lowerer.suppressStats = prevSuppress || ordinal > 0;
982
+ lowerer.fnStack.push(newFnCtx(false, null, null, BOOL));
985
983
  try {
986
984
  const loc = locOf(ov.decl);
987
- const thisLocal = L.declareThis(thisType);
985
+ const thisLocal = lowerer.declareThis(thisType);
988
986
  const params = [{ localId: thisLocal.id, name: "this", type: thisType }];
989
987
  const tupleParams = tuple.map((t, i) => {
990
- const p = L.declareHiddenLocal(`%ee${i}`, t);
988
+ const p = lowerer.declareHiddenLocal(`%ee${i}`, t);
991
989
  params.push({ localId: p.id, name: `%ee${i}`, type: t });
992
990
  return p;
993
991
  });
994
992
  const eventDecl = ov.decl.parameters[0];
995
- const eventLocal = L.declareLocal(eventDecl.name, ts.isIdentifier(eventDecl.name) ? eventDecl.name.text : "event", STRING, true);
993
+ const eventLocal = lowerer.declareLocal(eventDecl.name, ts.isIdentifier(eventDecl.name) ? eventDecl.name.text : "event", STRING, true);
996
994
  const prologue = [
997
995
  { kind: "varDecl", localId: eventLocal.id, init: strLit(event, loc), loc },
998
996
  ];
999
- L.emitSpecCtx = { info, event, tuple, eventSym: ov.eventSym, restSym: ov.restSym, tupleParams };
1000
- const body = [...prologue, ...L.lowerStmts(ov.decl.body.statements)];
997
+ lowerer.emitSpecCtx = { info, event, tuple, eventSym: ov.eventSym, restSym: ov.restSym, tupleParams };
998
+ const body = [...prologue, ...lowerer.lowerStmts(ov.decl.body.statements)];
1001
999
  return {
1002
1000
  name: `%${className}.emit:${event}`,
1003
1001
  params,
1004
1002
  returnType: BOOL,
1005
- locals: L.ctx.locals,
1003
+ locals: lowerer.ctx.locals,
1006
1004
  body,
1007
1005
  loc,
1008
1006
  };
1009
1007
  }
1010
1008
  finally {
1011
- L.emitSpecCtx = prevSpec;
1012
- L.fnStack.pop();
1013
- L.currentClass = prevClass;
1014
- L.suppressStats = prevSuppress;
1009
+ lowerer.emitSpecCtx = prevSpec;
1010
+ lowerer.fnStack.pop();
1011
+ lowerer.currentClass = prevClass;
1012
+ lowerer.suppressStats = prevSuppress;
1015
1013
  }
1016
1014
  }
1017
1015
  /** The specialization body's `super.emit(event, ...args)` — matched
@@ -1020,30 +1018,30 @@ export function lowerEmitOverrideSpec(L, req) {
1020
1018
  * override ancestor's specialization (JS's super chain) or the runtime
1021
1019
  * emit. Null when the call is not the forward (a literal-name super.emit
1022
1020
  * rides the general super-emitter route). */
1023
- export function emitSpecSuperForward(L, call, access) {
1024
- const ctx = L.emitSpecCtx;
1021
+ export function emitSpecSuperForward(lowerer, call, access) {
1022
+ const ctx = lowerer.emitSpecCtx;
1025
1023
  if (!ctx || access.name.text !== "emit" || call.arguments.length !== 2)
1026
1024
  return null;
1027
1025
  const a0 = call.arguments[0];
1028
1026
  const a1 = call.arguments[1];
1029
1027
  if (!ts.isIdentifier(a0) || !ts.isSpreadElement(a1) || !ts.isIdentifier(a1.expression))
1030
1028
  return null;
1031
- if (L.checker.getSymbolAtLocation(a0) !== ctx.eventSym)
1029
+ if (lowerer.checker.getSymbolAtLocation(a0) !== ctx.eventSym)
1032
1030
  return null;
1033
- if (L.checker.getSymbolAtLocation(a1.expression) !== ctx.restSym)
1031
+ if (lowerer.checker.getSymbolAtLocation(a1.expression) !== ctx.restSym)
1034
1032
  return null;
1035
1033
  const loc = locOf(call);
1036
- const thisLocal = L.resolveThis();
1034
+ const thisLocal = lowerer.resolveThis();
1037
1035
  if (!thisLocal)
1038
1036
  return null;
1039
1037
  const thisRef = { kind: "varRef", localId: thisLocal.id, type: thisLocal.type, loc };
1040
1038
  const payload = ctx.tupleParams.map((p) => ({ kind: "varRef", localId: p.id, type: p.type, loc }));
1041
1039
  const anc = emitOverrideAtOrAbove(ctx.info.base);
1042
1040
  if (anc) {
1043
- ensureEmitSpec(L, anc, ctx.event, ctx.tuple);
1041
+ ensureEmitSpec(lowerer, anc, ctx.event, ctx.tuple);
1044
1042
  const callee = `%${anc.def.name}.emit:${ctx.event}`;
1045
- L.noteEdge(callee);
1046
- return { kind: "call", callee, args: [L.upcastTo(thisRef, anc.def.name), ...payload], type: BOOL, loc };
1043
+ lowerer.noteEdge(callee);
1044
+ return { kind: "call", callee, args: [lowerer.upcastTo(thisRef, anc.def.name), ...payload], type: BOOL, loc };
1047
1045
  }
1048
1046
  if (ctx.event === "error") {
1049
1047
  return { kind: "libCall", fn: "emitter.emitError", args: [thisRef, strLit(ctx.event, loc), payload[0]], type: BOOL, loc };
@@ -1054,20 +1052,20 @@ export function emitSpecSuperForward(L, call, access) {
1054
1052
  * with the current method's `this` as the receiver and STATIC dispatch
1055
1053
  * (an emit override at-or-below the lexical class never answers a super
1056
1054
  * call — JS's prototype-chain rule). */
1057
- export function lowerEmitterSuperCall(L, call, access, cls) {
1058
- const thisLocal = L.resolveThis();
1055
+ export function lowerEmitterSuperCall(lowerer, call, access, cls) {
1056
+ const thisLocal = lowerer.resolveThis();
1059
1057
  if (!thisLocal)
1060
1058
  return null;
1061
1059
  const loc = locOf(call);
1062
1060
  const thisRef = { kind: "varRef", localId: thisLocal.id, type: thisLocal.type, loc };
1063
- return lowerEmitterMethodCall(L, call, access, cls, { thisRef, cls });
1061
+ return lowerEmitterMethodCall(lowerer, call, access, cls, { thisRef, cls });
1064
1062
  }
1065
1063
  /** One emit site's dispatch: the plain runtime libCall when no override
1066
1064
  * is comparable to the receiver's static class; a direct or virtual
1067
1065
  * specialization call when an override sits at-or-above it; an interned
1068
1066
  * instanceOf-branch helper when overrides exist only strictly below
1069
1067
  * (evaluating receiver and payload exactly once as its arguments). */
1070
- function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc) {
1068
+ function emitDispatchExpr(lowerer, info, name, tuple, receiver, payload, superOf, loc) {
1071
1069
  const method = `emit:${name}`;
1072
1070
  const runtime = (recv, args) => name === "error"
1073
1071
  ? { kind: "libCall", fn: "emitter.emitError", args: [recv, strLit(name, loc), args[0]], type: BOOL, loc }
@@ -1077,10 +1075,10 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
1077
1075
  const anc = emitOverrideAtOrAbove(superOf.base);
1078
1076
  if (!anc)
1079
1077
  return runtime(receiver, payload);
1080
- ensureEmitSpec(L, anc, name, tuple);
1078
+ ensureEmitSpec(lowerer, anc, name, tuple);
1081
1079
  const callee = `%${anc.def.name}.${method}`;
1082
- L.noteEdge(callee);
1083
- return { kind: "call", callee, args: [L.upcastTo(receiver, anc.def.name), ...payload], type: BOOL, loc };
1080
+ lowerer.noteEdge(callee);
1081
+ return { kind: "call", callee, args: [lowerer.upcastTo(receiver, anc.def.name), ...payload], type: BOOL, loc };
1084
1082
  }
1085
1083
  const above = emitOverrideAtOrAbove(info);
1086
1084
  const below = [];
@@ -1091,25 +1089,25 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
1091
1089
  // gets the event's specialization (descendants intercept via the vtable;
1092
1090
  // the super-forward chain above `above` is ensured as each body lowers).
1093
1091
  if (above)
1094
- ensureEmitSpec(L, above, name, tuple);
1092
+ ensureEmitSpec(lowerer, above, name, tuple);
1095
1093
  for (const c of below)
1096
- ensureEmitSpec(L, c, name, tuple);
1094
+ ensureEmitSpec(lowerer, c, name, tuple);
1097
1095
  if (above) {
1098
1096
  if (below.length > 0) {
1099
- L.noteVirtualEdge(info, method);
1097
+ lowerer.noteVirtualEdge(info, method);
1100
1098
  return { kind: "virtualCall", className: info.def.name, method, args: [receiver, ...payload], type: BOOL, loc };
1101
1099
  }
1102
1100
  const callee = `%${above.def.name}.${method}`;
1103
- L.noteEdge(callee);
1104
- return { kind: "call", callee, args: [L.upcastTo(receiver, above.def.name), ...payload], type: BOOL, loc };
1101
+ lowerer.noteEdge(callee);
1102
+ return { kind: "call", callee, args: [lowerer.upcastTo(receiver, above.def.name), ...payload], type: BOOL, loc };
1105
1103
  }
1106
1104
  // Overrides only strictly below: the interned dispatch helper.
1107
1105
  const recvT = receiver.type;
1108
1106
  const key = `emitter.emitDispatch:${typeKey(recvT)}:${name}`;
1109
- let helper = L.arrHofHelpers.get(key);
1107
+ let helper = lowerer.arrHofHelpers.get(key);
1110
1108
  if (!helper) {
1111
- helper = `%emitter.emitDispatch.${L.arrHofHelpers.size}`;
1112
- L.arrHofHelpers.set(key, helper);
1109
+ helper = `%emitter.emitDispatch.${lowerer.arrHofHelpers.size}`;
1110
+ lowerer.arrHofHelpers.set(key, helper);
1113
1111
  const params = [
1114
1112
  { localId: "r.0", name: "r", type: recvT },
1115
1113
  ...tuple.map((t, i) => ({ localId: `a${i}.0`, name: `a${i}`, type: t })),
@@ -1125,12 +1123,12 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
1125
1123
  collectEmitOverridesBelow(o, oBelow);
1126
1124
  let target;
1127
1125
  if (oBelow.length > 0) {
1128
- L.noteVirtualEdge(o, method);
1126
+ lowerer.noteVirtualEdge(o, method);
1129
1127
  target = { kind: "virtualCall", className: o.def.name, method, args: [down, ...argRefs()], type: BOOL, loc };
1130
1128
  }
1131
1129
  else {
1132
1130
  const callee = `%${o.def.name}.${method}`;
1133
- L.noteEdge(callee);
1131
+ lowerer.noteEdge(callee);
1134
1132
  target = { kind: "call", callee, args: [down, ...argRefs()], type: BOOL, loc };
1135
1133
  }
1136
1134
  body.push({
@@ -1142,8 +1140,8 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
1142
1140
  });
1143
1141
  }
1144
1142
  body.push({ kind: "return", value: runtime(rRef(), argRefs()), loc });
1145
- L.liftedFns.push({ name: helper, params, returnType: BOOL, locals, body, loc });
1143
+ lowerer.liftedFns.push({ name: helper, params, returnType: BOOL, locals, body, loc });
1146
1144
  }
1147
1145
  return { kind: "call", callee: helper, args: [receiver, ...payload], type: BOOL, loc };
1148
1146
  }
1149
- //# sourceMappingURL=lower-emitter.js.map
1147
+ //# sourceMappingURL=lower-event-emitter.js.map