@scriptc/compiler 0.2.4 → 0.2.6

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 (1201) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +972 -245
  2. package/ambient/scriptc-overrides.d.ts +5 -1
  3. package/ambient/scriptc.d.ts +22 -2
  4. package/dist/backend/build-cache.d.ts +4 -0
  5. package/dist/backend/build-cache.js +16 -2
  6. package/dist/backend/build-cache.js.map +1 -1
  7. package/dist/backend/cycle-analysis.js +17 -5
  8. package/dist/backend/cycle-analysis.js.map +1 -1
  9. package/dist/backend/cycle-analysis.test.js +50 -11
  10. package/dist/backend/cycle-analysis.test.js.map +1 -1
  11. package/dist/backend/debug-symbols.js.map +1 -1
  12. package/dist/backend/executable-features.js +3 -1
  13. package/dist/backend/executable-features.js.map +1 -1
  14. package/dist/backend/external-c.d.ts +13 -6
  15. package/dist/backend/external-c.js +15 -3
  16. package/dist/backend/external-c.js.map +1 -1
  17. package/dist/backend/ffi-callbacks.js +6 -9
  18. package/dist/backend/ffi-callbacks.js.map +1 -1
  19. package/dist/backend/library-identity-markers.js.map +1 -1
  20. package/dist/backend/library-pack.d.ts +1 -1
  21. package/dist/backend/library-pack.js +81 -24
  22. package/dist/backend/library-pack.js.map +1 -1
  23. package/dist/backend/link-plan-core.d.ts +2 -0
  24. package/dist/backend/link-plan-core.js +10 -2
  25. package/dist/backend/link-plan-core.js.map +1 -1
  26. package/dist/backend/link-plan.d.ts +2 -1
  27. package/dist/backend/link-plan.js +7 -5
  28. package/dist/backend/link-plan.js.map +1 -1
  29. package/dist/backend/linker.d.ts +1 -1
  30. package/dist/backend/linker.js +42 -23
  31. package/dist/backend/linker.js.map +1 -1
  32. package/dist/backend/literals.js +5 -4
  33. package/dist/backend/literals.js.map +1 -1
  34. package/dist/backend/literals.test.js +30 -5
  35. package/dist/backend/literals.test.js.map +1 -1
  36. package/dist/backend/llvm/blocks.test.js +5 -2
  37. package/dist/backend/llvm/blocks.test.js.map +1 -1
  38. package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
  39. package/dist/backend/llvm/borrowed-receivers.js +43 -19
  40. package/dist/backend/llvm/borrowed-receivers.js.map +1 -1
  41. package/dist/backend/llvm/byte-numbers.js +38 -5
  42. package/dist/backend/llvm/byte-numbers.js.map +1 -1
  43. package/dist/backend/llvm/byte-windows.d.ts +31 -0
  44. package/dist/backend/llvm/byte-windows.js +334 -0
  45. package/dist/backend/llvm/byte-windows.js.map +1 -0
  46. package/dist/backend/llvm/byte-windows.test.d.ts +1 -0
  47. package/dist/backend/llvm/byte-windows.test.js +244 -0
  48. package/dist/backend/llvm/byte-windows.test.js.map +1 -0
  49. package/dist/backend/llvm/bytes-bounds.js +73 -22
  50. package/dist/backend/llvm/bytes-bounds.js.map +1 -1
  51. package/dist/backend/llvm/call-lifetimes.d.ts +5 -2
  52. package/dist/backend/llvm/call-lifetimes.js +72 -19
  53. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  54. package/dist/backend/llvm/call-lifetimes.test.js +159 -28
  55. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  56. package/dist/backend/llvm/checked-value-lifetimes.d.ts +4 -0
  57. package/dist/backend/llvm/checked-value-lifetimes.js +14 -4
  58. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  59. package/dist/backend/llvm/classes.d.ts +14 -1
  60. package/dist/backend/llvm/classes.js +94 -19
  61. package/dist/backend/llvm/classes.js.map +1 -1
  62. package/dist/backend/llvm/classes.test.d.ts +1 -0
  63. package/dist/backend/llvm/classes.test.js +99 -0
  64. package/dist/backend/llvm/classes.test.js.map +1 -0
  65. package/dist/backend/llvm/common.js +4 -1
  66. package/dist/backend/llvm/common.js.map +1 -1
  67. package/dist/backend/llvm/constant-callbacks.d.ts +11 -0
  68. package/dist/backend/llvm/constant-callbacks.js +213 -0
  69. package/dist/backend/llvm/constant-callbacks.js.map +1 -0
  70. package/dist/backend/llvm/constant-callbacks.test.d.ts +1 -0
  71. package/dist/backend/llvm/constant-callbacks.test.js +124 -0
  72. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -0
  73. package/dist/backend/llvm/counted-loops.js +10 -3
  74. package/dist/backend/llvm/counted-loops.js.map +1 -1
  75. package/dist/backend/llvm/debug-info.js +33 -13
  76. package/dist/backend/llvm/debug-info.js.map +1 -1
  77. package/dist/backend/llvm/debug-info.test.js +28 -6
  78. package/dist/backend/llvm/debug-info.test.js.map +1 -1
  79. package/dist/backend/llvm/dyn.d.ts +1 -1
  80. package/dist/backend/llvm/dyn.js +75 -56
  81. package/dist/backend/llvm/dyn.js.map +1 -1
  82. package/dist/backend/llvm/emitter.d.ts +28 -3
  83. package/dist/backend/llvm/emitter.js +506 -145
  84. package/dist/backend/llvm/emitter.js.map +1 -1
  85. package/dist/backend/llvm/emitter.test.js +247 -50
  86. package/dist/backend/llvm/emitter.test.js.map +1 -1
  87. package/dist/backend/llvm/expr-async.js +25 -6
  88. package/dist/backend/llvm/expr-async.js.map +1 -1
  89. package/dist/backend/llvm/expr-bytes.js +24 -4
  90. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  91. package/dist/backend/llvm/expr-callbacks.js +10 -4
  92. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  93. package/dist/backend/llvm/expr-calls.js +110 -31
  94. package/dist/backend/llvm/expr-calls.js.map +1 -1
  95. package/dist/backend/llvm/expr-containers.d.ts +2 -0
  96. package/dist/backend/llvm/expr-containers.js +112 -41
  97. package/dist/backend/llvm/expr-containers.js.map +1 -1
  98. package/dist/backend/llvm/expr-control.js +1 -3
  99. package/dist/backend/llvm/expr-control.js.map +1 -1
  100. package/dist/backend/llvm/expr-dispatch.js +3 -1
  101. package/dist/backend/llvm/expr-dispatch.js.map +1 -1
  102. package/dist/backend/llvm/expr-dynamic.js +55 -7
  103. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  104. package/dist/backend/llvm/expr-island.js +26 -6
  105. package/dist/backend/llvm/expr-island.js.map +1 -1
  106. package/dist/backend/llvm/expr-primitives.js +95 -19
  107. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  108. package/dist/backend/llvm/expr-primitives.test.js +44 -2
  109. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  110. package/dist/backend/llvm/expr-records.js +10 -9
  111. package/dist/backend/llvm/expr-records.js.map +1 -1
  112. package/dist/backend/llvm/expr-stream-bridges.js +44 -26
  113. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  114. package/dist/backend/llvm/expr-stream-bridges.test.js +51 -14
  115. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  116. package/dist/backend/llvm/expr-stream-callbacks.js +34 -14
  117. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  118. package/dist/backend/llvm/integer-remainder.d.ts +7 -0
  119. package/dist/backend/llvm/integer-remainder.js +26 -0
  120. package/dist/backend/llvm/integer-remainder.js.map +1 -0
  121. package/dist/backend/llvm/integer-values.js +15 -4
  122. package/dist/backend/llvm/integer-values.js.map +1 -1
  123. package/dist/backend/llvm/integer-views.js +23 -7
  124. package/dist/backend/llvm/integer-views.js.map +1 -1
  125. package/dist/backend/llvm/integer-views.test.js +42 -7
  126. package/dist/backend/llvm/integer-views.test.js.map +1 -1
  127. package/dist/backend/llvm/layouts.js +1 -1
  128. package/dist/backend/llvm/layouts.js.map +1 -1
  129. package/dist/backend/llvm/lib-abi.js +20 -4
  130. package/dist/backend/llvm/lib-abi.js.map +1 -1
  131. package/dist/backend/llvm/lib-connect.js +7 -1
  132. package/dist/backend/llvm/lib-connect.js.map +1 -1
  133. package/dist/backend/llvm/lib-datagram.js +35 -10
  134. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  135. package/dist/backend/llvm/lib-dispatch.js +42 -38
  136. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  137. package/dist/backend/llvm/lib-filesystem.js +33 -18
  138. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  139. package/dist/backend/llvm/lib-http2.js +60 -15
  140. package/dist/backend/llvm/lib-http2.js.map +1 -1
  141. package/dist/backend/llvm/lib-lookup.js +12 -5
  142. package/dist/backend/llvm/lib-lookup.js.map +1 -1
  143. package/dist/backend/llvm/lib-network.js +97 -31
  144. package/dist/backend/llvm/lib-network.js.map +1 -1
  145. package/dist/backend/llvm/lib-process.js +57 -14
  146. package/dist/backend/llvm/lib-process.js.map +1 -1
  147. package/dist/backend/llvm/lib-shared.js +122 -31
  148. package/dist/backend/llvm/lib-shared.js.map +1 -1
  149. package/dist/backend/llvm/lib-stream.js +33 -14
  150. package/dist/backend/llvm/lib-stream.js.map +1 -1
  151. package/dist/backend/llvm/lib-test.js +21 -7
  152. package/dist/backend/llvm/lib-test.js.map +1 -1
  153. package/dist/backend/llvm/lib-tls.js +69 -20
  154. package/dist/backend/llvm/lib-tls.js.map +1 -1
  155. package/dist/backend/llvm/local-array-reads.d.ts +9 -2
  156. package/dist/backend/llvm/local-array-reads.js +176 -89
  157. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  158. package/dist/backend/llvm/local-array-reads.test.js +394 -62
  159. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  160. package/dist/backend/llvm/local-union-storage.d.ts +25 -0
  161. package/dist/backend/llvm/local-union-storage.js +109 -0
  162. package/dist/backend/llvm/local-union-storage.js.map +1 -0
  163. package/dist/backend/llvm/local-union-storage.test.d.ts +1 -0
  164. package/dist/backend/llvm/local-union-storage.test.js +210 -0
  165. package/dist/backend/llvm/local-union-storage.test.js.map +1 -0
  166. package/dist/backend/llvm/loop-array-borrows.d.ts +11 -0
  167. package/dist/backend/llvm/loop-array-borrows.js +70 -0
  168. package/dist/backend/llvm/loop-array-borrows.js.map +1 -0
  169. package/dist/backend/llvm/loop-array-borrows.test.d.ts +1 -0
  170. package/dist/backend/llvm/loop-array-borrows.test.js +145 -0
  171. package/dist/backend/llvm/loop-array-borrows.test.js.map +1 -0
  172. package/dist/backend/llvm/map-read-lifetimes.d.ts +11 -2
  173. package/dist/backend/llvm/map-read-lifetimes.js +64 -19
  174. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  175. package/dist/backend/llvm/map-read-lifetimes.test.js +89 -17
  176. package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
  177. package/dist/backend/llvm/reference-effects.d.ts +5 -3
  178. package/dist/backend/llvm/reference-effects.js +74 -36
  179. package/dist/backend/llvm/reference-effects.js.map +1 -1
  180. package/dist/backend/llvm/reference-effects.test.js +92 -9
  181. package/dist/backend/llvm/reference-effects.test.js.map +1 -1
  182. package/dist/backend/llvm/shapes.d.ts +4 -1
  183. package/dist/backend/llvm/shapes.js +82 -24
  184. package/dist/backend/llvm/shapes.js.map +1 -1
  185. package/dist/backend/llvm/shapes.test.js +3 -1
  186. package/dist/backend/llvm/shapes.test.js.map +1 -1
  187. package/dist/backend/llvm/split-loops.d.ts +48 -0
  188. package/dist/backend/llvm/split-loops.js +183 -0
  189. package/dist/backend/llvm/split-loops.js.map +1 -0
  190. package/dist/backend/llvm/split.js +4 -11
  191. package/dist/backend/llvm/split.js.map +1 -1
  192. package/dist/backend/llvm/split.test.js +80 -8
  193. package/dist/backend/llvm/split.test.js.map +1 -1
  194. package/dist/backend/llvm/stack-callbacks.d.ts +14 -0
  195. package/dist/backend/llvm/stack-callbacks.js +73 -0
  196. package/dist/backend/llvm/stack-callbacks.js.map +1 -0
  197. package/dist/backend/llvm/stack-captures.d.ts +25 -0
  198. package/dist/backend/llvm/stack-captures.js +150 -0
  199. package/dist/backend/llvm/stack-captures.js.map +1 -0
  200. package/dist/backend/llvm/stack-unions.js +14 -5
  201. package/dist/backend/llvm/stack-unions.js.map +1 -1
  202. package/dist/backend/llvm/stack-unions.test.js +151 -32
  203. package/dist/backend/llvm/stack-unions.test.js.map +1 -1
  204. package/dist/backend/llvm/string-construction.js.map +1 -1
  205. package/dist/backend/llvm/string-construction.test.js +32 -7
  206. package/dist/backend/llvm/string-construction.test.js.map +1 -1
  207. package/dist/backend/llvm/string-lifetimes.js +14 -8
  208. package/dist/backend/llvm/string-lifetimes.js.map +1 -1
  209. package/dist/backend/llvm/string-lifetimes.test.js +119 -29
  210. package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
  211. package/dist/backend/llvm/string-slices.d.ts +20 -0
  212. package/dist/backend/llvm/string-slices.js +87 -0
  213. package/dist/backend/llvm/string-slices.js.map +1 -0
  214. package/dist/backend/llvm/string-slices.test.d.ts +1 -0
  215. package/dist/backend/llvm/string-slices.test.js +98 -0
  216. package/dist/backend/llvm/string-slices.test.js.map +1 -0
  217. package/dist/backend/llvm/switch-dispatch.d.ts +9 -0
  218. package/dist/backend/llvm/switch-dispatch.js +114 -0
  219. package/dist/backend/llvm/switch-dispatch.js.map +1 -0
  220. package/dist/backend/llvm/switch-dispatch.test.d.ts +1 -0
  221. package/dist/backend/llvm/switch-dispatch.test.js +83 -0
  222. package/dist/backend/llvm/switch-dispatch.test.js.map +1 -0
  223. package/dist/backend/llvm/unsupported.js.map +1 -1
  224. package/dist/backend/llvm/walkers.d.ts +4 -14
  225. package/dist/backend/llvm/walkers.js +58 -313
  226. package/dist/backend/llvm/walkers.js.map +1 -1
  227. package/dist/backend/mangle.js +9 -3
  228. package/dist/backend/mangle.js.map +1 -1
  229. package/dist/backend/may-throw.js +18 -8
  230. package/dist/backend/may-throw.js.map +1 -1
  231. package/dist/backend/may-throw.test.js +119 -23
  232. package/dist/backend/may-throw.test.js.map +1 -1
  233. package/dist/backend/native/artifact-stamps.d.ts +39 -0
  234. package/dist/backend/native/artifact-stamps.js +371 -0
  235. package/dist/backend/native/artifact-stamps.js.map +1 -0
  236. package/dist/backend/native/cache-warm.d.ts +24 -0
  237. package/dist/backend/native/cache-warm.js +80 -0
  238. package/dist/backend/native/cache-warm.js.map +1 -0
  239. package/dist/backend/native/compiler-fingerprint.d.ts +19 -0
  240. package/dist/backend/native/compiler-fingerprint.js +357 -0
  241. package/dist/backend/native/compiler-fingerprint.js.map +1 -0
  242. package/dist/backend/native/contracts.d.ts +316 -0
  243. package/dist/backend/native/contracts.js +2 -0
  244. package/dist/backend/native/contracts.js.map +1 -0
  245. package/dist/backend/native/dependency-files.d.ts +5 -0
  246. package/dist/backend/native/dependency-files.js +83 -0
  247. package/dist/backend/native/dependency-files.js.map +1 -0
  248. package/dist/backend/native/driver.d.ts +50 -0
  249. package/dist/backend/native/driver.js +294 -0
  250. package/dist/backend/native/driver.js.map +1 -0
  251. package/dist/backend/native/executable.d.ts +18 -0
  252. package/dist/backend/native/executable.js +1275 -0
  253. package/dist/backend/native/executable.js.map +1 -0
  254. package/dist/backend/native/library.d.ts +2 -0
  255. package/dist/backend/native/library.js +614 -0
  256. package/dist/backend/native/library.js.map +1 -0
  257. package/dist/backend/native/linker-fingerprint.d.ts +8 -0
  258. package/dist/backend/native/linker-fingerprint.js +174 -0
  259. package/dist/backend/native/linker-fingerprint.js.map +1 -0
  260. package/dist/backend/native/object-merge.d.ts +2 -0
  261. package/dist/backend/native/object-merge.js +154 -0
  262. package/dist/backend/native/object-merge.js.map +1 -0
  263. package/dist/backend/native/process.d.ts +17 -0
  264. package/dist/backend/native/process.js +42 -0
  265. package/dist/backend/native/process.js.map +1 -0
  266. package/dist/backend/native/program-shards.d.ts +21 -0
  267. package/dist/backend/native/program-shards.js +99 -0
  268. package/dist/backend/native/program-shards.js.map +1 -0
  269. package/dist/backend/native/runtime-inputs.d.ts +12 -0
  270. package/dist/backend/native/runtime-inputs.js +165 -0
  271. package/dist/backend/native/runtime-inputs.js.map +1 -0
  272. package/dist/backend/native/runtime-inputs.test.d.ts +1 -0
  273. package/dist/backend/native/runtime-inputs.test.js +64 -0
  274. package/dist/backend/native/runtime-inputs.test.js.map +1 -0
  275. package/dist/backend/native/runtime-objects.d.ts +16 -0
  276. package/dist/backend/native/runtime-objects.js +122 -0
  277. package/dist/backend/native/runtime-objects.js.map +1 -0
  278. package/dist/backend/native/session.d.ts +12 -0
  279. package/dist/backend/native/session.js +31 -0
  280. package/dist/backend/native/session.js.map +1 -0
  281. package/dist/backend/native/tool-identity.d.ts +37 -0
  282. package/dist/backend/native/tool-identity.js +310 -0
  283. package/dist/backend/native/tool-identity.js.map +1 -0
  284. package/dist/backend/native/trace-paths.d.ts +12 -0
  285. package/dist/backend/native/trace-paths.js +73 -0
  286. package/dist/backend/native/trace-paths.js.map +1 -0
  287. package/dist/backend/native/vendor.d.ts +1 -0
  288. package/dist/backend/native/vendor.js +12 -0
  289. package/dist/backend/native/vendor.js.map +1 -0
  290. package/dist/backend/native-codegen-core.d.ts +6 -0
  291. package/dist/backend/native-codegen-core.js +23 -1
  292. package/dist/backend/native-codegen-core.js.map +1 -1
  293. package/dist/backend/native-codegen.d.ts +5 -1
  294. package/dist/backend/native-codegen.js +52 -25
  295. package/dist/backend/native-codegen.js.map +1 -1
  296. package/dist/backend/native-codegen.test.js +59 -11
  297. package/dist/backend/native-codegen.test.js.map +1 -1
  298. package/dist/backend/native-link-info-core.d.ts +1 -0
  299. package/dist/backend/native-link-info-core.js +9 -5
  300. package/dist/backend/native-link-info-core.js.map +1 -1
  301. package/dist/backend/native-link-info.js +14 -5
  302. package/dist/backend/native-link-info.js.map +1 -1
  303. package/dist/backend/native-link-info.test.js +58 -13
  304. package/dist/backend/native-link-info.test.js.map +1 -1
  305. package/dist/backend/native-toolchain.d.ts +17 -450
  306. package/dist/backend/native-toolchain.js +17 -3971
  307. package/dist/backend/native-toolchain.js.map +1 -1
  308. package/dist/backend/native-toolchain.test.js +103 -72
  309. package/dist/backend/native-toolchain.test.js.map +1 -1
  310. package/dist/backend/native-tools.d.ts +3 -1
  311. package/dist/backend/native-tools.js +30 -9
  312. package/dist/backend/native-tools.js.map +1 -1
  313. package/dist/backend/object-localize.js +17 -14
  314. package/dist/backend/object-localize.js.map +1 -1
  315. package/dist/backend/object-localize.test.js +59 -12
  316. package/dist/backend/object-localize.test.js.map +1 -1
  317. package/dist/backend/runtime-abi.d.ts +2 -2
  318. package/dist/backend/runtime-abi.js +2 -2
  319. package/dist/backend/runtime-pack-core.d.ts +1 -0
  320. package/dist/backend/runtime-pack-core.js +104 -50
  321. package/dist/backend/runtime-pack-core.js.map +1 -1
  322. package/dist/backend/runtime-pack-native.js +5 -3
  323. package/dist/backend/runtime-pack-native.js.map +1 -1
  324. package/dist/backend/runtime-pack-targets.test.js +126 -17
  325. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  326. package/dist/backend/runtime-pack.d.ts +1 -1
  327. package/dist/backend/runtime-pack.js +11 -12
  328. package/dist/backend/runtime-pack.js.map +1 -1
  329. package/dist/backend/runtime-pack.test.js +51 -25
  330. package/dist/backend/runtime-pack.test.js.map +1 -1
  331. package/dist/backend/source-locations.js.map +1 -1
  332. package/dist/backend/source-locations.test.js +7 -2
  333. package/dist/backend/source-locations.test.js.map +1 -1
  334. package/dist/backend/target-diagnostics.js +44 -14
  335. package/dist/backend/target-diagnostics.js.map +1 -1
  336. package/dist/backend/target-diagnostics.test.js +93 -20
  337. package/dist/backend/target-diagnostics.test.js.map +1 -1
  338. package/dist/backend/targets.js +230 -86
  339. package/dist/backend/targets.js.map +1 -1
  340. package/dist/backend/targets.test.js +32 -18
  341. package/dist/backend/targets.test.js.map +1 -1
  342. package/dist/backend/toolchain-environment.js +5 -1
  343. package/dist/backend/toolchain-environment.js.map +1 -1
  344. package/dist/backend/vendor-archives.d.ts +2 -2
  345. package/dist/backend/vendor-archives.js +84 -35
  346. package/dist/backend/vendor-archives.js.map +1 -1
  347. package/dist/backend/vendor-inputs.js +13 -1
  348. package/dist/backend/vendor-inputs.js.map +1 -1
  349. package/dist/backend/warm-cache.d.ts +1 -1
  350. package/dist/backend/warm-cache.js +33 -9
  351. package/dist/backend/warm-cache.js.map +1 -1
  352. package/dist/cli/command.js +39 -9
  353. package/dist/cli/command.js.map +1 -1
  354. package/dist/cli/output-options.js +14 -4
  355. package/dist/cli/output-options.js.map +1 -1
  356. package/dist/cli/paths.js.map +1 -1
  357. package/dist/cli/wasi-runner.js.map +1 -1
  358. package/dist/compat/fetch-profile.js +36 -35
  359. package/dist/compat/fetch-profile.js.map +1 -1
  360. package/dist/coverage/report.js +16 -17
  361. package/dist/coverage/report.js.map +1 -1
  362. package/dist/coverage/surface-manifest.js +112 -26
  363. package/dist/coverage/surface-manifest.js.map +1 -1
  364. package/dist/diagnostics/diagnostic.js +55 -16
  365. package/dist/diagnostics/diagnostic.js.map +1 -1
  366. package/dist/executable/executable-cache.d.ts +2 -1
  367. package/dist/executable/executable-cache.js +79 -48
  368. package/dist/executable/executable-cache.js.map +1 -1
  369. package/dist/executable/executable-cache.test.js +90 -26
  370. package/dist/executable/executable-cache.test.js.map +1 -1
  371. package/dist/executable/prepare.js +2 -2
  372. package/dist/executable/prepare.js.map +1 -1
  373. package/dist/ffi/ffi-manifest.js +78 -20
  374. package/dist/ffi/ffi-manifest.js.map +1 -1
  375. package/dist/ffi/ffi-manifest.test.js +96 -16
  376. package/dist/ffi/ffi-manifest.test.js.map +1 -1
  377. package/dist/format-integer.js.map +1 -1
  378. package/dist/frontend/analysis.js +12 -2
  379. package/dist/frontend/analysis.js.map +1 -1
  380. package/dist/frontend/arguments-usage.js.map +1 -1
  381. package/dist/frontend/binding-source.js +9 -3
  382. package/dist/frontend/binding-source.js.map +1 -1
  383. package/dist/frontend/builtin-modules.js +46 -2
  384. package/dist/frontend/builtin-modules.js.map +1 -1
  385. package/dist/frontend/cjs-resolve.js +40 -17
  386. package/dist/frontend/cjs-resolve.js.map +1 -1
  387. package/dist/frontend/cjs-syntax.js +31 -10
  388. package/dist/frontend/cjs-syntax.js.map +1 -1
  389. package/dist/frontend/comptime-node.test.js +10 -11
  390. package/dist/frontend/comptime-node.test.js.map +1 -1
  391. package/dist/frontend/dts-paths.js +7 -3
  392. package/dist/frontend/dts-paths.js.map +1 -1
  393. package/dist/frontend/fork-target.d.ts +5 -0
  394. package/dist/frontend/fork-target.js +55 -18
  395. package/dist/frontend/fork-target.js.map +1 -1
  396. package/dist/frontend/fork-target.test.d.ts +1 -0
  397. package/dist/frontend/fork-target.test.js +59 -0
  398. package/dist/frontend/fork-target.test.js.map +1 -0
  399. package/dist/frontend/function-completion.js +11 -6
  400. package/dist/frontend/function-completion.js.map +1 -1
  401. package/dist/frontend/helper-tokens.js +53 -6
  402. package/dist/frontend/helper-tokens.js.map +1 -1
  403. package/dist/frontend/helper-tokens.test.js +18 -2
  404. package/dist/frontend/helper-tokens.test.js.map +1 -1
  405. package/dist/frontend/inferred-js-diagnostics.js +32 -12
  406. package/dist/frontend/inferred-js-diagnostics.js.map +1 -1
  407. package/dist/frontend/inferred-js-diagnostics.test.js +11 -15
  408. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  409. package/dist/frontend/input-tracker.js +11 -11
  410. package/dist/frontend/input-tracker.js.map +1 -1
  411. package/dist/frontend/input-tracker.test.js +4 -1
  412. package/dist/frontend/input-tracker.test.js.map +1 -1
  413. package/dist/frontend/lib-contract.js +38 -9
  414. package/dist/frontend/lib-contract.js.map +1 -1
  415. package/dist/frontend/literal-values.js.map +1 -1
  416. package/dist/frontend/literal-values.test.js +28 -8
  417. package/dist/frontend/literal-values.test.js.map +1 -1
  418. package/dist/frontend/lowering/abstract-equality.js +53 -10
  419. package/dist/frontend/lowering/abstract-equality.js.map +1 -1
  420. package/dist/frontend/lowering/array-indexed-mutation.d.ts +1 -1
  421. package/dist/frontend/lowering/array-indexed-mutation.js +108 -106
  422. package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
  423. package/dist/frontend/lowering/array-values.js +37 -14
  424. package/dist/frontend/lowering/array-values.js.map +1 -1
  425. package/dist/frontend/lowering/binding-analysis.d.ts +50 -0
  426. package/dist/frontend/lowering/binding-analysis.js +376 -0
  427. package/dist/frontend/lowering/binding-analysis.js.map +1 -0
  428. package/dist/frontend/lowering/builtin-calls.d.ts +9 -0
  429. package/dist/frontend/lowering/builtin-calls.js +60 -0
  430. package/dist/frontend/lowering/builtin-calls.js.map +1 -0
  431. package/dist/frontend/lowering/builtins/arguments.d.ts +43 -0
  432. package/dist/frontend/lowering/builtins/arguments.js +247 -0
  433. package/dist/frontend/lowering/builtins/arguments.js.map +1 -0
  434. package/dist/frontend/lowering/builtins/async-context.d.ts +52 -0
  435. package/dist/frontend/lowering/builtins/async-context.js +436 -0
  436. package/dist/frontend/lowering/builtins/async-context.js.map +1 -0
  437. package/dist/frontend/lowering/builtins/atomics.d.ts +6 -0
  438. package/dist/frontend/lowering/builtins/atomics.js +82 -0
  439. package/dist/frontend/lowering/builtins/atomics.js.map +1 -0
  440. package/dist/frontend/lowering/builtins/callable-aliases.d.ts +13 -0
  441. package/dist/frontend/lowering/builtins/callable-aliases.js +87 -0
  442. package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -0
  443. package/dist/frontend/lowering/builtins/child-process-async.d.ts +18 -0
  444. package/dist/frontend/lowering/builtins/child-process-async.js +245 -0
  445. package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -0
  446. package/dist/frontend/lowering/builtins/child-process-methods.d.ts +21 -0
  447. package/dist/frontend/lowering/builtins/child-process-methods.js +362 -0
  448. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -0
  449. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +4 -0
  450. package/dist/frontend/lowering/builtins/child-process-sync.js +639 -0
  451. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -0
  452. package/dist/frontend/lowering/builtins/child-process.d.ts +55 -0
  453. package/dist/frontend/lowering/builtins/child-process.js +669 -0
  454. package/dist/frontend/lowering/builtins/child-process.js.map +1 -0
  455. package/dist/frontend/lowering/builtins/compression.d.ts +7 -0
  456. package/dist/frontend/lowering/builtins/compression.js +115 -0
  457. package/dist/frontend/lowering/builtins/compression.js.map +1 -0
  458. package/dist/frontend/lowering/builtins/console.d.ts +10 -0
  459. package/dist/frontend/lowering/builtins/console.js +38 -0
  460. package/dist/frontend/lowering/builtins/console.js.map +1 -0
  461. package/dist/frontend/lowering/builtins/constants.d.ts +24 -0
  462. package/dist/frontend/lowering/builtins/constants.js +141 -0
  463. package/dist/frontend/lowering/builtins/constants.js.map +1 -0
  464. package/dist/frontend/lowering/builtins/crypto.d.ts +22 -0
  465. package/dist/frontend/lowering/builtins/crypto.js +517 -0
  466. package/dist/frontend/lowering/builtins/crypto.js.map +1 -0
  467. package/dist/frontend/lowering/builtins/dates.d.ts +7 -0
  468. package/dist/frontend/lowering/builtins/dates.js +101 -0
  469. package/dist/frontend/lowering/builtins/dates.js.map +1 -0
  470. package/dist/frontend/lowering/builtins/environment.d.ts +34 -0
  471. package/dist/frontend/lowering/builtins/environment.js +95 -0
  472. package/dist/frontend/lowering/builtins/environment.js.map +1 -0
  473. package/dist/frontend/lowering/builtins/errors.d.ts +14 -0
  474. package/dist/frontend/lowering/builtins/errors.js +83 -0
  475. package/dist/frontend/lowering/builtins/errors.js.map +1 -0
  476. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +35 -0
  477. package/dist/frontend/lowering/builtins/filesystem-calls.js +725 -0
  478. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -0
  479. package/dist/frontend/lowering/builtins/filesystem.d.ts +108 -0
  480. package/dist/frontend/lowering/builtins/filesystem.js +1061 -0
  481. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -0
  482. package/dist/frontend/lowering/builtins/ipc.d.ts +8 -0
  483. package/dist/frontend/lowering/builtins/ipc.js +76 -0
  484. package/dist/frontend/lowering/builtins/ipc.js.map +1 -0
  485. package/dist/frontend/lowering/builtins/json.d.ts +12 -0
  486. package/dist/frontend/lowering/builtins/json.js +387 -0
  487. package/dist/frontend/lowering/builtins/json.js.map +1 -0
  488. package/dist/frontend/lowering/builtins/module-bindings.d.ts +85 -0
  489. package/dist/frontend/lowering/builtins/module-bindings.js +346 -0
  490. package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -0
  491. package/dist/frontend/lowering/builtins/module-calls.d.ts +8 -0
  492. package/dist/frontend/lowering/builtins/module-calls.js +308 -0
  493. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -0
  494. package/dist/frontend/lowering/builtins/module-resolution.d.ts +38 -0
  495. package/dist/frontend/lowering/builtins/module-resolution.js +344 -0
  496. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -0
  497. package/dist/frontend/lowering/builtins/numbers.d.ts +15 -0
  498. package/dist/frontend/lowering/builtins/numbers.js +124 -0
  499. package/dist/frontend/lowering/builtins/numbers.js.map +1 -0
  500. package/dist/frontend/lowering/builtins/operating-system.d.ts +13 -0
  501. package/dist/frontend/lowering/builtins/operating-system.js +148 -0
  502. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -0
  503. package/dist/frontend/lowering/builtins/performance.d.ts +13 -0
  504. package/dist/frontend/lowering/builtins/performance.js +100 -0
  505. package/dist/frontend/lowering/builtins/performance.js.map +1 -0
  506. package/dist/frontend/lowering/builtins/process.d.ts +50 -0
  507. package/dist/frontend/lowering/builtins/process.js +1138 -0
  508. package/dist/frontend/lowering/builtins/process.js.map +1 -0
  509. package/dist/frontend/lowering/builtins/promises.d.ts +14 -0
  510. package/dist/frontend/lowering/builtins/promises.js +356 -0
  511. package/dist/frontend/lowering/builtins/promises.js.map +1 -0
  512. package/dist/frontend/lowering/builtins/properties.d.ts +11 -0
  513. package/dist/frontend/lowering/builtins/properties.js +186 -0
  514. package/dist/frontend/lowering/builtins/properties.js.map +1 -0
  515. package/dist/frontend/lowering/builtins/querystring.d.ts +19 -0
  516. package/dist/frontend/lowering/builtins/querystring.js +150 -0
  517. package/dist/frontend/lowering/builtins/querystring.js.map +1 -0
  518. package/dist/frontend/lowering/builtins/readline.d.ts +13 -0
  519. package/dist/frontend/lowering/builtins/readline.js +138 -0
  520. package/dist/frontend/lowering/builtins/readline.js.map +1 -0
  521. package/dist/frontend/lowering/builtins/receiver-types.d.ts +5 -0
  522. package/dist/frontend/lowering/builtins/receiver-types.js +15 -0
  523. package/dist/frontend/lowering/builtins/receiver-types.js.map +1 -0
  524. package/dist/frontend/lowering/builtins/reflection.d.ts +13 -0
  525. package/dist/frontend/lowering/builtins/reflection.js +95 -0
  526. package/dist/frontend/lowering/builtins/reflection.js.map +1 -0
  527. package/dist/frontend/lowering/builtins/strings.d.ts +14 -0
  528. package/dist/frontend/lowering/builtins/strings.js +121 -0
  529. package/dist/frontend/lowering/builtins/strings.js.map +1 -0
  530. package/dist/frontend/lowering/builtins/text-codecs.d.ts +29 -0
  531. package/dist/frontend/lowering/builtins/text-codecs.js +590 -0
  532. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -0
  533. package/dist/frontend/lowering/builtins/timers.d.ts +22 -0
  534. package/dist/frontend/lowering/builtins/timers.js +180 -0
  535. package/dist/frontend/lowering/builtins/timers.js.map +1 -0
  536. package/dist/frontend/lowering/builtins/url.d.ts +37 -0
  537. package/dist/frontend/lowering/builtins/url.js +596 -0
  538. package/dist/frontend/lowering/builtins/url.js.map +1 -0
  539. package/dist/frontend/lowering/builtins/util-types.d.ts +7 -0
  540. package/dist/frontend/lowering/builtins/util-types.js +31 -0
  541. package/dist/frontend/lowering/builtins/util-types.js.map +1 -0
  542. package/dist/frontend/lowering/builtins/workers.d.ts +5 -0
  543. package/dist/frontend/lowering/builtins/workers.js +65 -0
  544. package/dist/frontend/lowering/builtins/workers.js.map +1 -0
  545. package/dist/frontend/lowering/call-arguments.d.ts +72 -0
  546. package/dist/frontend/lowering/call-arguments.js +618 -0
  547. package/dist/frontend/lowering/call-arguments.js.map +1 -0
  548. package/dist/frontend/lowering/call-signatures.d.ts +115 -0
  549. package/dist/frontend/lowering/call-signatures.js +719 -0
  550. package/dist/frontend/lowering/call-signatures.js.map +1 -0
  551. package/dist/frontend/lowering/callback-arg.js.map +1 -1
  552. package/dist/frontend/lowering/checked-iterable-spread.js +53 -10
  553. package/dist/frontend/lowering/checked-iterable-spread.js.map +1 -1
  554. package/dist/frontend/lowering/checked-promise-all.js +41 -9
  555. package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
  556. package/dist/frontend/lowering/class-assertions.d.ts +7 -0
  557. package/dist/frontend/lowering/class-assertions.js +96 -0
  558. package/dist/frontend/lowering/class-assertions.js.map +1 -0
  559. package/dist/frontend/lowering/class-callbacks.d.ts +1 -1
  560. package/dist/frontend/lowering/class-callbacks.js +130 -27
  561. package/dist/frontend/lowering/class-callbacks.js.map +1 -1
  562. package/dist/frontend/lowering/class-construction.d.ts +1 -1
  563. package/dist/frontend/lowering/class-construction.js +247 -50
  564. package/dist/frontend/lowering/class-construction.js.map +1 -1
  565. package/dist/frontend/lowering/class-descriptors.js +109 -29
  566. package/dist/frontend/lowering/class-descriptors.js.map +1 -1
  567. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +6 -1
  568. package/dist/frontend/lowering/class-dynamic-dispatch.js +2471 -465
  569. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  570. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +284 -44
  571. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  572. package/dist/frontend/lowering/class-instance-constructor.js +17 -5
  573. package/dist/frontend/lowering/class-instance-constructor.js.map +1 -1
  574. package/dist/frontend/lowering/class-method-values.js +199 -51
  575. package/dist/frontend/lowering/class-method-values.js.map +1 -1
  576. package/dist/frontend/lowering/class-protocols.d.ts +17 -0
  577. package/dist/frontend/lowering/class-protocols.js +126 -0
  578. package/dist/frontend/lowering/class-protocols.js.map +1 -0
  579. package/dist/frontend/lowering/class-prototypes.js +345 -86
  580. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  581. package/dist/frontend/lowering/class-runtime-statics.d.ts +1 -1
  582. package/dist/frontend/lowering/class-runtime-statics.js +80 -17
  583. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  584. package/dist/frontend/lowering/class-static-data.js +76 -16
  585. package/dist/frontend/lowering/class-static-data.js.map +1 -1
  586. package/dist/frontend/lowering/coercions/builders.d.ts +13 -0
  587. package/dist/frontend/lowering/coercions/builders.js +77 -0
  588. package/dist/frontend/lowering/coercions/builders.js.map +1 -0
  589. package/dist/frontend/lowering/coercions/function-adapters.d.ts +58 -0
  590. package/dist/frontend/lowering/coercions/function-adapters.js +430 -0
  591. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -0
  592. package/dist/frontend/lowering/coercions/island.d.ts +37 -0
  593. package/dist/frontend/lowering/coercions/island.js +350 -0
  594. package/dist/frontend/lowering/coercions/island.js.map +1 -0
  595. package/dist/frontend/lowering/coercions/state.d.ts +14 -0
  596. package/dist/frontend/lowering/coercions/state.js +16 -0
  597. package/dist/frontend/lowering/coercions/state.js.map +1 -0
  598. package/dist/frontend/lowering/coercions/structural-plans.d.ts +40 -0
  599. package/dist/frontend/lowering/coercions/structural-plans.js +447 -0
  600. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -0
  601. package/dist/frontend/lowering/coercions/structural.d.ts +63 -0
  602. package/dist/frontend/lowering/coercions/structural.js +616 -0
  603. package/dist/frontend/lowering/coercions/structural.js.map +1 -0
  604. package/dist/frontend/lowering/coercions/unions.d.ts +65 -0
  605. package/dist/frontend/lowering/coercions/unions.js +318 -0
  606. package/dist/frontend/lowering/coercions/unions.js.map +1 -0
  607. package/dist/frontend/lowering/collection-ingestion.js +355 -72
  608. package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
  609. package/dist/frontend/lowering/containers/array-callbacks.d.ts +88 -0
  610. package/dist/frontend/lowering/containers/array-callbacks.js +1611 -0
  611. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -0
  612. package/dist/frontend/lowering/containers/array-construction.d.ts +42 -0
  613. package/dist/frontend/lowering/containers/array-construction.js +1044 -0
  614. package/dist/frontend/lowering/containers/array-construction.js.map +1 -0
  615. package/dist/frontend/lowering/containers/array-iteration.d.ts +16 -0
  616. package/dist/frontend/lowering/containers/array-iteration.js +95 -0
  617. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -0
  618. package/dist/frontend/lowering/containers/array-methods.d.ts +27 -0
  619. package/dist/frontend/lowering/containers/array-methods.js +1854 -0
  620. package/dist/frontend/lowering/containers/array-methods.js.map +1 -0
  621. package/dist/frontend/lowering/containers/bytes.d.ts +17 -17
  622. package/dist/frontend/lowering/containers/bytes.js +430 -138
  623. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  624. package/dist/frontend/lowering/containers/callback-arguments.d.ts +26 -0
  625. package/dist/frontend/lowering/containers/callback-arguments.js +179 -0
  626. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -0
  627. package/dist/frontend/lowering/containers/collection-grouping.d.ts +19 -0
  628. package/dist/frontend/lowering/containers/collection-grouping.js +297 -0
  629. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -0
  630. package/dist/frontend/lowering/containers/collection-methods.d.ts +57 -0
  631. package/dist/frontend/lowering/containers/collection-methods.js +1314 -0
  632. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -0
  633. package/dist/frontend/lowering/containers/dynamic-receivers.d.ts +18 -0
  634. package/dist/frontend/lowering/containers/dynamic-receivers.js +114 -0
  635. package/dist/frontend/lowering/containers/dynamic-receivers.js.map +1 -0
  636. package/dist/frontend/lowering/containers/for-of.d.ts +60 -0
  637. package/dist/frontend/lowering/containers/for-of.js +643 -0
  638. package/dist/frontend/lowering/containers/for-of.js.map +1 -0
  639. package/dist/frontend/lowering/containers/indexed-objects.d.ts +132 -0
  640. package/dist/frontend/lowering/containers/indexed-objects.js +1743 -0
  641. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -0
  642. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +20 -0
  643. package/dist/frontend/lowering/containers/iterator-helpers.js +809 -0
  644. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -0
  645. package/dist/frontend/lowering/containers/string-and-regexp.js +601 -160
  646. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  647. package/dist/frontend/lowering/containers/string-replacement.js +213 -63
  648. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
  649. package/dist/frontend/lowering/crypto-tables.js +263 -64
  650. package/dist/frontend/lowering/crypto-tables.js.map +1 -1
  651. package/dist/frontend/lowering/deferred-module-initializers.js +172 -68
  652. package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
  653. package/dist/frontend/lowering/deferred-module-initializers.test.js +41 -8
  654. package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
  655. package/dist/frontend/lowering/error-methods.js +339 -65
  656. package/dist/frontend/lowering/error-methods.js.map +1 -1
  657. package/dist/frontend/lowering/expressions/evaluation-safety.js +3 -2
  658. package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
  659. package/dist/frontend/lowering/expressions/global-symbols.js +2 -1
  660. package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -1
  661. package/dist/frontend/lowering/expressions/native-proxy.js +11 -5
  662. package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
  663. package/dist/frontend/lowering/expressions/nullish-assignment.js +67 -13
  664. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  665. package/dist/frontend/lowering/expressions/object-literals.js +588 -165
  666. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  667. package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
  668. package/dist/frontend/lowering/expressions/optional-chains.js +68 -17
  669. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  670. package/dist/frontend/lowering/expressions/union-field-write.js +45 -18
  671. package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -1
  672. package/dist/frontend/lowering/function-context.js +5 -1
  673. package/dist/frontend/lowering/function-context.js.map +1 -1
  674. package/dist/frontend/lowering/function-returns.d.ts +67 -0
  675. package/dist/frontend/lowering/function-returns.js +392 -0
  676. package/dist/frontend/lowering/function-returns.js.map +1 -0
  677. package/dist/frontend/lowering/generator-delegation.d.ts +1 -1
  678. package/dist/frontend/lowering/generator-delegation.js +171 -39
  679. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  680. package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +1 -1
  681. package/dist/frontend/lowering/generator-dynamic-dispatch.js +176 -36
  682. package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
  683. package/dist/frontend/lowering/generic-functions.d.ts +271 -0
  684. package/dist/frontend/lowering/generic-functions.js +1730 -0
  685. package/dist/frontend/lowering/generic-functions.js.map +1 -0
  686. package/dist/frontend/lowering/import-meta.d.ts +1 -1
  687. package/dist/frontend/lowering/import-meta.js +37 -14
  688. package/dist/frontend/lowering/import-meta.js.map +1 -1
  689. package/dist/frontend/lowering/indexed-comparison.js +6 -2
  690. package/dist/frontend/lowering/indexed-comparison.js.map +1 -1
  691. package/dist/frontend/lowering/instantiation-path.d.ts +8 -0
  692. package/dist/frontend/lowering/instantiation-path.js +10 -0
  693. package/dist/frontend/lowering/instantiation-path.js.map +1 -0
  694. package/dist/frontend/lowering/instantiation-path.test.d.ts +1 -0
  695. package/dist/frontend/lowering/instantiation-path.test.js +23 -0
  696. package/dist/frontend/lowering/instantiation-path.test.js.map +1 -0
  697. package/dist/frontend/lowering/iterator-consumption.d.ts +9 -0
  698. package/dist/frontend/lowering/iterator-consumption.js +91 -0
  699. package/dist/frontend/lowering/iterator-consumption.js.map +1 -0
  700. package/dist/frontend/lowering/lib-boundary.js +40 -17
  701. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  702. package/dist/frontend/lowering/lib-boundary.test.js +49 -11
  703. package/dist/frontend/lowering/lib-boundary.test.js.map +1 -1
  704. package/dist/frontend/lowering/lower-array-sort.d.ts +0 -19
  705. package/dist/frontend/lowering/lower-array-sort.js +331 -566
  706. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  707. package/dist/frontend/lowering/lower-assert.js +248 -43
  708. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  709. package/dist/frontend/lowering/lower-async-iteration.js +71 -16
  710. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  711. package/dist/frontend/lowering/lower-builtin-values.js +430 -77
  712. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  713. package/dist/frontend/lowering/lower-calls.d.ts +39 -558
  714. package/dist/frontend/lowering/lower-calls.js +2628 -5669
  715. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  716. package/dist/frontend/lowering/lower-classes.d.ts +248 -242
  717. package/dist/frontend/lowering/lower-classes.js +1820 -775
  718. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  719. package/dist/frontend/lowering/lower-comptime.d.ts +35 -35
  720. package/dist/frontend/lowering/lower-comptime.js +39 -37
  721. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  722. package/dist/frontend/lowering/lower-dgram.js +59 -31
  723. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  724. package/dist/frontend/lowering/lower-enums.js +5 -2
  725. package/dist/frontend/lowering/lower-enums.js.map +1 -1
  726. package/dist/frontend/lowering/lower-event-emitter.js +323 -86
  727. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  728. package/dist/frontend/lowering/lower-expando.js +19 -7
  729. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  730. package/dist/frontend/lowering/lower-exprs.d.ts +194 -194
  731. package/dist/frontend/lowering/lower-exprs.js +3473 -1160
  732. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  733. package/dist/frontend/lowering/lower-functions.d.ts +23 -0
  734. package/dist/frontend/lowering/lower-functions.js +449 -0
  735. package/dist/frontend/lowering/lower-functions.js.map +1 -0
  736. package/dist/frontend/lowering/lower-generators.js +121 -32
  737. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  738. package/dist/frontend/lowering/lower-global-value.js +15 -4
  739. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  740. package/dist/frontend/lowering/lower-inspect.js +479 -89
  741. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  742. package/dist/frontend/lowering/lower-island.d.ts +79 -79
  743. package/dist/frontend/lowering/lower-island.js +366 -274
  744. package/dist/frontend/lowering/lower-island.js.map +1 -1
  745. package/dist/frontend/lowering/lower-island.test.js +7 -2
  746. package/dist/frontend/lowering/lower-island.test.js.map +1 -1
  747. package/dist/frontend/lowering/lower-mixins.js +17 -8
  748. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  749. package/dist/frontend/lowering/lower-modules.d.ts +95 -94
  750. package/dist/frontend/lowering/lower-modules.js +655 -329
  751. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  752. package/dist/frontend/lowering/lower-modules.test.js +91 -20
  753. package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
  754. package/dist/frontend/lowering/lower-namespaces.js +25 -8
  755. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  756. package/dist/frontend/lowering/lower-node-module.js +115 -34
  757. package/dist/frontend/lowering/lower-node-module.js.map +1 -1
  758. package/dist/frontend/lowering/lower-server.js +1210 -290
  759. package/dist/frontend/lowering/lower-server.js.map +1 -1
  760. package/dist/frontend/lowering/lower-stmts.d.ts +148 -148
  761. package/dist/frontend/lowering/lower-stmts.js +2324 -994
  762. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  763. package/dist/frontend/lowering/lower-stmts.test.js +13 -5
  764. package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
  765. package/dist/frontend/lowering/lower-stream.js +363 -91
  766. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  767. package/dist/frontend/lowering/lower-system-errors.js +30 -8
  768. package/dist/frontend/lowering/lower-system-errors.js.map +1 -1
  769. package/dist/frontend/lowering/lower-test.js +40 -13
  770. package/dist/frontend/lowering/lower-test.js.map +1 -1
  771. package/dist/frontend/lowering/lower-timers.d.ts +31 -0
  772. package/dist/frontend/lowering/lower-timers.js +336 -0
  773. package/dist/frontend/lowering/lower-timers.js.map +1 -0
  774. package/dist/frontend/lowering/lower-url.d.ts +1 -1
  775. package/dist/frontend/lowering/lower-url.js +46 -13
  776. package/dist/frontend/lowering/lower-url.js.map +1 -1
  777. package/dist/frontend/lowering/lowerer.d.ts +34 -352
  778. package/dist/frontend/lowering/lowerer.js +1074 -2712
  779. package/dist/frontend/lowering/lowerer.js.map +1 -1
  780. package/dist/frontend/lowering/lowerer.test.js +85 -17
  781. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  782. package/dist/frontend/lowering/module-namespace-elements.js +43 -8
  783. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  784. package/dist/frontend/lowering/native-ffi.d.ts +21 -1
  785. package/dist/frontend/lowering/native-ffi.js +487 -18
  786. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  787. package/dist/frontend/lowering/object-enumeration-receiver.js +55 -10
  788. package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
  789. package/dist/frontend/lowering/object-factory-new.d.ts +1 -1
  790. package/dist/frontend/lowering/object-factory-new.js +36 -11
  791. package/dist/frontend/lowering/object-factory-new.js.map +1 -1
  792. package/dist/frontend/lowering/optional-arguments.js +49 -20
  793. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  794. package/dist/frontend/lowering/pairs-snapshot.js +66 -14
  795. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  796. package/dist/frontend/lowering/runtime-optional-locals.js +3 -1
  797. package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -1
  798. package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -1
  799. package/dist/frontend/lowering/sanitize-class-types.js +4 -1
  800. package/dist/frontend/lowering/sanitize-class-types.js.map +1 -1
  801. package/dist/frontend/lowering/sanitize-class-types.test.js +86 -18
  802. package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -1
  803. package/dist/frontend/lowering/split-consumers.d.ts +7 -0
  804. package/dist/frontend/lowering/split-consumers.js +64 -0
  805. package/dist/frontend/lowering/split-consumers.js.map +1 -0
  806. package/dist/frontend/lowering/static-this.js +13 -6
  807. package/dist/frontend/lowering/static-this.js.map +1 -1
  808. package/dist/frontend/lowering/string-index.js +32 -10
  809. package/dist/frontend/lowering/string-index.js.map +1 -1
  810. package/dist/frontend/lowering/surfaces.d.ts +45 -46
  811. package/dist/frontend/lowering/surfaces.js +1129 -256
  812. package/dist/frontend/lowering/surfaces.js.map +1 -1
  813. package/dist/frontend/lowering/symbol-fields.js +40 -15
  814. package/dist/frontend/lowering/symbol-fields.js.map +1 -1
  815. package/dist/frontend/lowering/symbol-methods.js.map +1 -1
  816. package/dist/frontend/lowering/text-decoder-encoding.js +236 -24
  817. package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -1
  818. package/dist/frontend/lowering/text-decoder-encoding.test.js +84 -12
  819. package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -1
  820. package/dist/frontend/lowering/union-narrow.js +59 -16
  821. package/dist/frontend/lowering/union-narrow.js.map +1 -1
  822. package/dist/frontend/lowering/union-narrow.test.js +24 -7
  823. package/dist/frontend/lowering/union-narrow.test.js.map +1 -1
  824. package/dist/frontend/lowering/union-retag.js +155 -40
  825. package/dist/frontend/lowering/union-retag.js.map +1 -1
  826. package/dist/frontend/lowering/union-retag.test.js +131 -33
  827. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  828. package/dist/frontend/lowering/unregistered-class-types.js.map +1 -1
  829. package/dist/frontend/lowering/unregistered-class-types.test.js +34 -8
  830. package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -1
  831. package/dist/frontend/module-source-candidates.d.ts +10 -0
  832. package/dist/frontend/module-source-candidates.js +40 -0
  833. package/dist/frontend/module-source-candidates.js.map +1 -0
  834. package/dist/frontend/module-source-candidates.test.d.ts +1 -0
  835. package/dist/frontend/module-source-candidates.test.js +53 -0
  836. package/dist/frontend/module-source-candidates.test.js.map +1 -0
  837. package/dist/frontend/module-syntax.js +21 -8
  838. package/dist/frontend/module-syntax.js.map +1 -1
  839. package/dist/frontend/module-syntax.test.js +37 -13
  840. package/dist/frontend/module-syntax.test.js.map +1 -1
  841. package/dist/frontend/npm-fetch-analysis.js +13 -4
  842. package/dist/frontend/npm-fetch-analysis.js.map +1 -1
  843. package/dist/frontend/npm-fetch-analysis.test.js +33 -10
  844. package/dist/frontend/npm-fetch-analysis.test.js.map +1 -1
  845. package/dist/frontend/npm-fetch-node.js.map +1 -1
  846. package/dist/frontend/npm-fetch-syntax.js +4 -9
  847. package/dist/frontend/npm-fetch-syntax.js.map +1 -1
  848. package/dist/frontend/npm-node.js +3 -1
  849. package/dist/frontend/npm-node.js.map +1 -1
  850. package/dist/frontend/npm-static-bundled-cjs.js +88 -29
  851. package/dist/frontend/npm-static-bundled-cjs.js.map +1 -1
  852. package/dist/frontend/npm-static-bundled-cjs.test.js +29 -10
  853. package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -1
  854. package/dist/frontend/npm-static-declaration-syntax.js +148 -56
  855. package/dist/frontend/npm-static-declaration-syntax.js.map +1 -1
  856. package/dist/frontend/npm-static-declarations.d.ts +1 -1
  857. package/dist/frontend/npm-static-declarations.js.map +1 -1
  858. package/dist/frontend/npm-static-declarations.test.js +33 -7
  859. package/dist/frontend/npm-static-declarations.test.js.map +1 -1
  860. package/dist/frontend/npm-static-prune.js +26 -12
  861. package/dist/frontend/npm-static-prune.js.map +1 -1
  862. package/dist/frontend/npm-static-prune.test.js +17 -3
  863. package/dist/frontend/npm-static-prune.test.js.map +1 -1
  864. package/dist/frontend/npm-static-rewrite-host.js +2 -3
  865. package/dist/frontend/npm-static-rewrite-host.js.map +1 -1
  866. package/dist/frontend/npm-static-rewrite-syntax.js +64 -21
  867. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  868. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  869. package/dist/frontend/npm-static-subtyping.js +9 -4
  870. package/dist/frontend/npm-static-subtyping.js.map +1 -1
  871. package/dist/frontend/npm-static-subtyping.test.js +30 -6
  872. package/dist/frontend/npm-static-subtyping.test.js.map +1 -1
  873. package/dist/frontend/npm-static.js +15 -4
  874. package/dist/frontend/npm-static.js.map +1 -1
  875. package/dist/frontend/npm.js +122 -36
  876. package/dist/frontend/npm.js.map +1 -1
  877. package/dist/frontend/npm.test.js +30 -10
  878. package/dist/frontend/npm.test.js.map +1 -1
  879. package/dist/frontend/pipeline-native.js.map +1 -1
  880. package/dist/frontend/pipeline.js +25 -8
  881. package/dist/frontend/pipeline.js.map +1 -1
  882. package/dist/frontend/pipeline.test.js +21 -7
  883. package/dist/frontend/pipeline.test.js.map +1 -1
  884. package/dist/frontend/program-analysis.d.ts +2 -0
  885. package/dist/frontend/program-analysis.js +2 -0
  886. package/dist/frontend/program-analysis.js.map +1 -1
  887. package/dist/frontend/program-node.js +5 -3
  888. package/dist/frontend/program-node.js.map +1 -1
  889. package/dist/frontend/program.d.ts +2 -2
  890. package/dist/frontend/program.js +248 -127
  891. package/dist/frontend/program.js.map +1 -1
  892. package/dist/frontend/program.test.js +27 -27
  893. package/dist/frontend/program.test.js.map +1 -1
  894. package/dist/frontend/provenance-core.js +8 -4
  895. package/dist/frontend/provenance-core.js.map +1 -1
  896. package/dist/frontend/provenance-registry.js +1 -4
  897. package/dist/frontend/provenance-registry.js.map +1 -1
  898. package/dist/frontend/resolve.js +32 -20
  899. package/dist/frontend/resolve.js.map +1 -1
  900. package/dist/frontend/resolve.test.js +1 -1
  901. package/dist/frontend/resolve.test.js.map +1 -1
  902. package/dist/frontend/runtime-resolve.js +13 -4
  903. package/dist/frontend/runtime-resolve.js.map +1 -1
  904. package/dist/frontend/runtime-resolve.test.js +25 -9
  905. package/dist/frontend/runtime-resolve.test.js.map +1 -1
  906. package/dist/frontend/services-node.js +6 -2
  907. package/dist/frontend/services-node.js.map +1 -1
  908. package/dist/frontend/services-node.test.js +18 -6
  909. package/dist/frontend/services-node.test.js.map +1 -1
  910. package/dist/frontend/services.js +8 -4
  911. package/dist/frontend/services.js.map +1 -1
  912. package/dist/frontend/services.test.js +6 -2
  913. package/dist/frontend/services.test.js.map +1 -1
  914. package/dist/frontend/ts7/api.js +12 -4
  915. package/dist/frontend/ts7/api.js.map +1 -1
  916. package/dist/frontend/ts7/ast-bytes.js +10 -3
  917. package/dist/frontend/ts7/ast-bytes.js.map +1 -1
  918. package/dist/frontend/ts7/ast-bytes.test.js +23 -4
  919. package/dist/frontend/ts7/ast-bytes.test.js.map +1 -1
  920. package/dist/frontend/ts7/ast-guards.test.js +14 -5
  921. package/dist/frontend/ts7/ast-guards.test.js.map +1 -1
  922. package/dist/frontend/ts7/ast-node.d.ts +6 -1
  923. package/dist/frontend/ts7/ast-node.js +490 -172
  924. package/dist/frontend/ts7/ast-node.js.map +1 -1
  925. package/dist/frontend/ts7/ast-node.test.js +150 -36
  926. package/dist/frontend/ts7/ast-node.test.js.map +1 -1
  927. package/dist/frontend/ts7/ast-text.js +13 -3
  928. package/dist/frontend/ts7/ast-text.js.map +1 -1
  929. package/dist/frontend/ts7/ast-text.test.js.map +1 -1
  930. package/dist/frontend/ts7/ast-types.js.map +1 -1
  931. package/dist/frontend/ts7/ast-wire.d.ts +5 -1
  932. package/dist/frontend/ts7/ast-wire.js +83 -20
  933. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  934. package/dist/frontend/ts7/ast-wire.test.js +53 -8
  935. package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
  936. package/dist/frontend/ts7/ast.d.ts +2 -1
  937. package/dist/frontend/ts7/ast.js +53 -30
  938. package/dist/frontend/ts7/ast.js.map +1 -1
  939. package/dist/frontend/ts7/census-check.js +1 -1
  940. package/dist/frontend/ts7/census-check.js.map +1 -1
  941. package/dist/frontend/ts7/checker-cache.js.map +1 -1
  942. package/dist/frontend/ts7/checker.d.ts +8 -2
  943. package/dist/frontend/ts7/checker.js +46 -8
  944. package/dist/frontend/ts7/checker.js.map +1 -1
  945. package/dist/frontend/ts7/checker.test.js +96 -17
  946. package/dist/frontend/ts7/checker.test.js.map +1 -1
  947. package/dist/frontend/ts7/enums.test.js +9 -4
  948. package/dist/frontend/ts7/enums.test.js.map +1 -1
  949. package/dist/frontend/ts7/native-api.js.map +1 -1
  950. package/dist/frontend/ts7/native-host.js.map +1 -1
  951. package/dist/frontend/ts7/native-process.js +9 -3
  952. package/dist/frontend/ts7/native-process.js.map +1 -1
  953. package/dist/frontend/ts7/program-adapter.js +1 -1
  954. package/dist/frontend/ts7/program-adapter.js.map +1 -1
  955. package/dist/frontend/ts7/program-host.d.ts +7 -0
  956. package/dist/frontend/ts7/program-host.js +33 -6
  957. package/dist/frontend/ts7/program-host.js.map +1 -1
  958. package/dist/frontend/ts7/program-host.test.js +72 -11
  959. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  960. package/dist/frontend/ts7/rpc-api.js +3 -1
  961. package/dist/frontend/ts7/rpc-api.js.map +1 -1
  962. package/dist/frontend/ts7/rpc-client.js +15 -5
  963. package/dist/frontend/ts7/rpc-client.js.map +1 -1
  964. package/dist/frontend/ts7/rpc-client.test.js +26 -8
  965. package/dist/frontend/ts7/rpc-client.test.js.map +1 -1
  966. package/dist/frontend/ts7/rpc-filesystem.js.map +1 -1
  967. package/dist/frontend/ts7/rpc-filesystem.test.js +43 -10
  968. package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -1
  969. package/dist/frontend/ts7/rpc-process.js +16 -6
  970. package/dist/frontend/ts7/rpc-process.js.map +1 -1
  971. package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
  972. package/dist/frontend/ts7/rpc-wire.d.ts +1 -0
  973. package/dist/frontend/ts7/rpc-wire.js +41 -14
  974. package/dist/frontend/ts7/rpc-wire.js.map +1 -1
  975. package/dist/frontend/ts7/rpc-wire.test.js +36 -6
  976. package/dist/frontend/ts7/rpc-wire.test.js.map +1 -1
  977. package/dist/frontend/ts7/semantic-checker.js +209 -68
  978. package/dist/frontend/ts7/semantic-checker.js.map +1 -1
  979. package/dist/frontend/ts7/semantic-checker.test.js +29 -14
  980. package/dist/frontend/ts7/semantic-checker.test.js.map +1 -1
  981. package/dist/frontend/ts7/semantic-json.js +7 -1
  982. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  983. package/dist/frontend/ts7/semantic-json.test.js +17 -3
  984. package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
  985. package/dist/frontend/ts7/semantic-model.js +147 -51
  986. package/dist/frontend/ts7/semantic-model.js.map +1 -1
  987. package/dist/frontend/ts7/semantic-model.test.js +72 -19
  988. package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
  989. package/dist/frontend/ts7/semantic-types.d.ts +2 -2
  990. package/dist/frontend/ts7/session-cache.js +10 -3
  991. package/dist/frontend/ts7/session-cache.js.map +1 -1
  992. package/dist/frontend/ts7/session-cache.test.js +13 -4
  993. package/dist/frontend/ts7/session-cache.test.js.map +1 -1
  994. package/dist/frontend/ts7/session-path.js +25 -10
  995. package/dist/frontend/ts7/session-path.js.map +1 -1
  996. package/dist/frontend/ts7/session-path.test.js +47 -4
  997. package/dist/frontend/ts7/session-path.test.js.map +1 -1
  998. package/dist/frontend/ts7/session-timing.js +22 -3
  999. package/dist/frontend/ts7/session-timing.js.map +1 -1
  1000. package/dist/frontend/ts7/session-timing.test.js +12 -3
  1001. package/dist/frontend/ts7/session-timing.test.js.map +1 -1
  1002. package/dist/frontend/ts7/session.d.ts +1 -0
  1003. package/dist/frontend/ts7/session.js +109 -35
  1004. package/dist/frontend/ts7/session.js.map +1 -1
  1005. package/dist/frontend/ts7/session.test.js +69 -15
  1006. package/dist/frontend/ts7/session.test.js.map +1 -1
  1007. package/dist/frontend/ts7/source-parser.js +17 -6
  1008. package/dist/frontend/ts7/source-parser.js.map +1 -1
  1009. package/dist/frontend/ts7/source-parser.test.js +32 -9
  1010. package/dist/frontend/ts7/source-parser.test.js.map +1 -1
  1011. package/dist/frontend/tsc-codes.js +56 -11
  1012. package/dist/frontend/tsc-codes.js.map +1 -1
  1013. package/dist/frontend/tsc-codes.test.d.ts +1 -0
  1014. package/dist/frontend/tsc-codes.test.js +16 -0
  1015. package/dist/frontend/tsc-codes.test.js.map +1 -0
  1016. package/dist/frontend/type-mapper.d.ts +3 -0
  1017. package/dist/frontend/type-mapper.js +589 -206
  1018. package/dist/frontend/type-mapper.js.map +1 -1
  1019. package/dist/frontend/type-mapper.test.js +108 -33
  1020. package/dist/frontend/type-mapper.test.js.map +1 -1
  1021. package/dist/frontend/union-discriminants.js +8 -2
  1022. package/dist/frontend/union-discriminants.js.map +1 -1
  1023. package/dist/frontend/union-discriminants.test.js +77 -20
  1024. package/dist/frontend/union-discriminants.test.js.map +1 -1
  1025. package/dist/frontend/worker-target.d.ts +6 -0
  1026. package/dist/frontend/worker-target.js +108 -0
  1027. package/dist/frontend/worker-target.js.map +1 -0
  1028. package/dist/frontend/worker-target.test.d.ts +1 -0
  1029. package/dist/frontend/worker-target.test.js +71 -0
  1030. package/dist/frontend/worker-target.test.js.map +1 -0
  1031. package/dist/index.d.ts +9 -8
  1032. package/dist/index.js +174 -88
  1033. package/dist/index.js.map +1 -1
  1034. package/dist/ir/analysis.js +95 -38
  1035. package/dist/ir/analysis.js.map +1 -1
  1036. package/dist/ir/analysis.test.js +91 -15
  1037. package/dist/ir/analysis.test.js.map +1 -1
  1038. package/dist/ir/api.d.ts +4 -0
  1039. package/dist/ir/api.js +6 -0
  1040. package/dist/ir/api.js.map +1 -0
  1041. package/dist/ir/build.d.ts +7 -0
  1042. package/dist/ir/build.js +27 -1
  1043. package/dist/ir/build.js.map +1 -1
  1044. package/dist/ir/builtin-effects.d.ts +9 -0
  1045. package/dist/ir/builtin-effects.js +643 -0
  1046. package/dist/ir/builtin-effects.js.map +1 -0
  1047. package/dist/ir/builtin-signatures.d.ts +15 -0
  1048. package/dist/ir/builtin-signatures.js +3397 -0
  1049. package/dist/ir/builtin-signatures.js.map +1 -0
  1050. package/dist/ir/byte-numbers.js +67 -16
  1051. package/dist/ir/byte-numbers.js.map +1 -1
  1052. package/dist/ir/byte-numbers.test.js +17 -4
  1053. package/dist/ir/byte-numbers.test.js.map +1 -1
  1054. package/dist/ir/constant-tables.js +13 -5
  1055. package/dist/ir/constant-tables.js.map +1 -1
  1056. package/dist/ir/constant-tables.test.js +47 -7
  1057. package/dist/ir/constant-tables.test.js.map +1 -1
  1058. package/dist/ir/control-flow.js +2 -1
  1059. package/dist/ir/control-flow.js.map +1 -1
  1060. package/dist/ir/control-flow.test.js +35 -11
  1061. package/dist/ir/control-flow.test.js.map +1 -1
  1062. package/dist/ir/initializer-bindings.d.ts +9 -0
  1063. package/dist/ir/initializer-bindings.js +115 -0
  1064. package/dist/ir/initializer-bindings.js.map +1 -0
  1065. package/dist/ir/initializer-bindings.test.d.ts +1 -0
  1066. package/dist/ir/initializer-bindings.test.js +118 -0
  1067. package/dist/ir/initializer-bindings.test.js.map +1 -0
  1068. package/dist/ir/integer-loop-facts.d.ts +12 -0
  1069. package/dist/ir/integer-loop-facts.js +137 -0
  1070. package/dist/ir/integer-loop-facts.js.map +1 -0
  1071. package/dist/ir/integer-loops.js +85 -30
  1072. package/dist/ir/integer-loops.js.map +1 -1
  1073. package/dist/ir/integer-loops.test.js +76 -13
  1074. package/dist/ir/integer-loops.test.js.map +1 -1
  1075. package/dist/ir/integer-ranges.js +93 -21
  1076. package/dist/ir/integer-ranges.js.map +1 -1
  1077. package/dist/ir/integer-ranges.test.js +199 -21
  1078. package/dist/ir/integer-ranges.test.js.map +1 -1
  1079. package/dist/ir/intrinsic-signatures.d.ts +20 -0
  1080. package/dist/ir/intrinsic-signatures.js +57 -0
  1081. package/dist/ir/intrinsic-signatures.js.map +1 -0
  1082. package/dist/ir/ir.d.ts +15 -2160
  1083. package/dist/ir/ir.js +160 -1396
  1084. package/dist/ir/ir.js.map +1 -1
  1085. package/dist/ir/ir.test.js +98 -77
  1086. package/dist/ir/ir.test.js.map +1 -1
  1087. package/dist/ir/numeric-call-specialization.d.ts +8 -0
  1088. package/dist/ir/numeric-call-specialization.js +198 -0
  1089. package/dist/ir/numeric-call-specialization.js.map +1 -0
  1090. package/dist/ir/runtime-features.d.ts +221 -0
  1091. package/dist/ir/runtime-features.js +552 -0
  1092. package/dist/ir/runtime-features.js.map +1 -0
  1093. package/dist/ir/runtime-features.test.d.ts +1 -0
  1094. package/dist/ir/runtime-features.test.js +98 -0
  1095. package/dist/ir/runtime-features.test.js.map +1 -0
  1096. package/dist/ir/scalar-records.js +130 -40
  1097. package/dist/ir/scalar-records.js.map +1 -1
  1098. package/dist/ir/scalar-records.test.js +146 -27
  1099. package/dist/ir/scalar-records.test.js.map +1 -1
  1100. package/dist/ir/serialize.d.ts +1 -1
  1101. package/dist/ir/serialize.js +7 -5
  1102. package/dist/ir/serialize.js.map +1 -1
  1103. package/dist/ir/serialize.test.js +44 -9
  1104. package/dist/ir/serialize.test.js.map +1 -1
  1105. package/dist/ir/traverse.js +156 -43
  1106. package/dist/ir/traverse.js.map +1 -1
  1107. package/dist/ir/traverse.test.js +99 -24
  1108. package/dist/ir/traverse.test.js.map +1 -1
  1109. package/dist/ir/validate.d.ts +1 -31
  1110. package/dist/ir/validate.js +869 -1910
  1111. package/dist/ir/validate.js.map +1 -1
  1112. package/dist/ir/validate.test.js +697 -114
  1113. package/dist/ir/validate.test.js.map +1 -1
  1114. package/dist/library/cache-primitives.js +9 -10
  1115. package/dist/library/cache-primitives.js.map +1 -1
  1116. package/dist/library/cache-reset.test.js +2 -1
  1117. package/dist/library/cache-reset.test.js.map +1 -1
  1118. package/dist/library/compiler-self-identity.js +11 -5
  1119. package/dist/library/compiler-self-identity.js.map +1 -1
  1120. package/dist/library/compiler-self-identity.test.js +10 -3
  1121. package/dist/library/compiler-self-identity.test.js.map +1 -1
  1122. package/dist/library/fence-eval.js +24 -7
  1123. package/dist/library/fence-eval.js.map +1 -1
  1124. package/dist/library/fence-eval.test.js +31 -7
  1125. package/dist/library/fence-eval.test.js.map +1 -1
  1126. package/dist/library/int-infer.js +199 -59
  1127. package/dist/library/int-infer.js.map +1 -1
  1128. package/dist/library/int-infer.test.js +137 -61
  1129. package/dist/library/int-infer.test.js.map +1 -1
  1130. package/dist/library/ir-policy.d.ts +27 -0
  1131. package/dist/library/ir-policy.js +234 -0
  1132. package/dist/library/ir-policy.js.map +1 -0
  1133. package/dist/library/library-cache.js +40 -17
  1134. package/dist/library/library-cache.js.map +1 -1
  1135. package/dist/library/library-cache.test.js +29 -18
  1136. package/dist/library/library-cache.test.js.map +1 -1
  1137. package/dist/library/library-profile.js +68 -13
  1138. package/dist/library/library-profile.js.map +1 -1
  1139. package/dist/library/prepare.js +48 -20
  1140. package/dist/library/prepare.js.map +1 -1
  1141. package/dist/library/semantic-source.js +16 -14
  1142. package/dist/library/semantic-source.js.map +1 -1
  1143. package/dist/library/semantic-source.test.js +9 -14
  1144. package/dist/library/semantic-source.test.js.map +1 -1
  1145. package/dist/library/sidecar-validate.js +53 -12
  1146. package/dist/library/sidecar-validate.js.map +1 -1
  1147. package/dist/library/sidecar.js +85 -24
  1148. package/dist/library/sidecar.js.map +1 -1
  1149. package/dist/library/trap-teaching.js +11 -2
  1150. package/dist/library/trap-teaching.js.map +1 -1
  1151. package/dist/native/cache.js +10 -4
  1152. package/dist/native/cache.js.map +1 -1
  1153. package/dist/native/cli.js +34 -9
  1154. package/dist/native/cli.js.map +1 -1
  1155. package/dist/native/compiler.js +191 -54
  1156. package/dist/native/compiler.js.map +1 -1
  1157. package/dist/native/compiler.test.js +134 -33
  1158. package/dist/native/compiler.test.js.map +1 -1
  1159. package/dist/native/comptime.js +23 -7
  1160. package/dist/native/comptime.js.map +1 -1
  1161. package/dist/native/comptime.test.js +26 -6
  1162. package/dist/native/comptime.test.js.map +1 -1
  1163. package/dist/native/executable-cache.js +77 -27
  1164. package/dist/native/executable-cache.js.map +1 -1
  1165. package/dist/native/executable-cache.test.js +41 -6
  1166. package/dist/native/executable-cache.test.js.map +1 -1
  1167. package/dist/native/file-identity.js +9 -2
  1168. package/dist/native/file-identity.js.map +1 -1
  1169. package/dist/native/file-identity.test.js.map +1 -1
  1170. package/dist/native/library.js +50 -12
  1171. package/dist/native/library.js.map +1 -1
  1172. package/dist/native/prepare.js +121 -34
  1173. package/dist/native/prepare.js.map +1 -1
  1174. package/dist/native/prepare.test.js +22 -6
  1175. package/dist/native/prepare.test.js.map +1 -1
  1176. package/dist/native/runtime-typescript.js +24 -11
  1177. package/dist/native/runtime-typescript.js.map +1 -1
  1178. package/dist/native/runtime-typescript.test.js.map +1 -1
  1179. package/dist/native/sanitizer.js +71 -18
  1180. package/dist/native/sanitizer.js.map +1 -1
  1181. package/dist/native/sanitizer.test.js +78 -20
  1182. package/dist/native/sanitizer.test.js.map +1 -1
  1183. package/dist/native/task.js.map +1 -1
  1184. package/dist/native/task.test.js +7 -2
  1185. package/dist/native/task.test.js.map +1 -1
  1186. package/dist/native/toolchain.js +68 -26
  1187. package/dist/native/toolchain.js.map +1 -1
  1188. package/dist/native/toolchain.test.js +59 -20
  1189. package/dist/native/toolchain.test.js.map +1 -1
  1190. package/dist/startup-cache.d.ts +1 -1
  1191. package/dist/startup-cache.js +1 -1
  1192. package/dist/startup-cache.js.map +1 -1
  1193. package/dist/timing.js.map +1 -1
  1194. package/package.json +20 -20
  1195. package/surface-manifest.json +30 -2
  1196. package/dist/frontend/lowering/lower-builtins.d.ts +0 -601
  1197. package/dist/frontend/lowering/lower-builtins.js +0 -8986
  1198. package/dist/frontend/lowering/lower-builtins.js.map +0 -1
  1199. package/dist/frontend/lowering/lower-containers.d.ts +0 -382
  1200. package/dist/frontend/lowering/lower-containers.js +0 -7344
  1201. package/dist/frontend/lowering/lower-containers.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { dynUndefinedExpr } from "../../ir/build.js";
1
2
  import { everyStmtList, everyTypeChild } from "../../ir/traverse.js";
2
3
  import { InternalCompilerError } from "../../errors.js";
3
4
  /* Module-graph lowering: splitting each source file into its parts, the
@@ -7,29 +8,34 @@ import { InternalCompilerError } from "../../errors.js";
7
8
  import * as ts from "../ts7/adapter.js";
8
9
  import { bindingSource } from "../binding-source.js";
9
10
  import { dirname as dirnamePath, isAbsolute, resolve as resolvePath } from "node:path";
10
- import { NpmGraphBuilder, packageNameOfPath, probeNodeImportRefusal, probeNodeRequireRefusal } from "../npm.js";
11
+ import { NpmGraphBuilder, packageNameOfPath, probeNodeImportRefusal, probeNodeRequireRefusal, } from "../npm.js";
11
12
  import { isNpmStaticPackage } from "../npm-static.js";
12
13
  import { isJsSourceFileName } from "../tsc-codes.js";
13
14
  import { isRelativeSpecifier } from "../workspace-registry.js";
14
- import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport } from "../program.js";
15
- import { invalidJsonModuleDiag, npmEmbedFailedDiag, requiresDynamicImportDiag } from "../../diagnostics/diagnostic.js";
16
- import { BOOL, DYN, F64, JSVAL, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType } from "../../ir/ir.js";
17
- import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType, dynUndefinedExpr, importCallHandleType, newFnCtx, staticImportNamespaceType, uncheckedOverloadHandleCall } from "./lowerer.js";
18
- import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, createRequireSpecOf, isPromisifyCall, registerBuiltinCallableAlias, stripTypeCasts } from "./lower-builtins.js";
19
- import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, bindingNeverReassigned, deadUnmappableBinding, funcTypeFromParamShapes, implicitLocalFnInfoOf, implicitLocalFnNodeOf, nullishGenericBindingUnitOf, registerOverloadedCallableAlias } from "./lower-calls.js";
20
- import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl } from "./lower-stmts.js";
15
+ import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport, } from "../program.js";
16
+ import { invalidJsonModuleDiag, npmEmbedFailedDiag, requiresDynamicImportDiag, } from "../../diagnostics/diagnostic.js";
17
+ import { BOOL, DYN, F64, JSVAL, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType, } from "../../ir/ir.js";
18
+ import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType, importCallHandleType, newFnCtx, staticImportNamespaceType, uncheckedOverloadHandleCall, } from "./lowerer.js";
19
+ import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, createRequireSpecOf, } from "./builtins/module-bindings.js";
20
+ import { isPromisifyCall, registerBuiltinCallableAlias } from "./builtins/callable-aliases.js";
21
+ import { stripTypeCasts } from "./builtins/arguments.js";
22
+ import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, implicitLocalFnInfoOf, implicitLocalFnNodeOf, } from "./generic-functions.js";
23
+ import { bindingNeverReassigned, deadUnmappableBinding, nullishGenericBindingUnitOf, } from "./binding-analysis.js";
24
+ import { funcTypeFromParamShapes, registerOverloadedCallableAlias } from "./call-signatures.js";
25
+ import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl, } from "./lower-stmts.js";
21
26
  import { objectFactoryGlobalType } from "./object-factory-new.js";
22
27
  import { streamClassAliasDecl } from "./lower-stream.js";
23
28
  import { stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf } from "./surfaces.js";
24
29
  import { isNativeBuiltinValueInitializer } from "./lower-builtin-values.js";
25
- import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf } from "./lower-namespaces.js";
30
+ import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf, } from "./lower-namespaces.js";
26
31
  import { collectExpandoMembers } from "./lower-expando.js";
27
32
  import { recordTextCodecClass } from "../../ir/ir.js";
28
33
  import { isUnitOnlyTsType, unitOnlyUnion } from "../type-mapper.js";
29
- import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType } from "./lower-classes.js";
34
+ import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType, } from "./lower-classes.js";
30
35
  import { isMixinFnBinding, mixinResultBindingClassOf } from "./lower-mixins.js";
31
36
  import { cjsModuleRef, cjsModuleRegistryPrelude } from "./lower-node-module.js";
32
37
  import { forkTargetPaths } from "../fork-target.js";
38
+ import { workerTargetPaths } from "../worker-target.js";
33
39
  import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
34
40
  /** Program modules selected by statically resolved child_process.fork()
35
41
  * calls join the compiled graph without becoming startup dependencies of
@@ -37,9 +43,15 @@ import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
37
43
  * in a re-executed fork child. `targets` is append-only so ids stay stable
38
44
  * across the dynamic-import/fork discovery fixpoint. */
39
45
  export function appendForkModules(program, order, targets, onCycle) {
46
+ appendEntryModules(program, order, targets, forkTargetPaths(program, order), onCycle);
47
+ }
48
+ export function appendWorkerModules(program, order, targets, onCycle) {
49
+ appendEntryModules(program, order, targets, workerTargetPaths(program, order), onCycle);
50
+ }
51
+ function appendEntryModules(program, order, targets, paths, onCycle) {
40
52
  if (order.length === 0)
41
53
  return;
42
- const byPath = new Map(program.getSourceFiles().map((sf) => [resolvePath(sf.fileName), sf]));
54
+ const byPath = new Map(program.getImplementationSourceFiles().map((sf) => [resolvePath(sf.fileName), sf]));
43
55
  const state = new Map();
44
56
  for (const sf of order)
45
57
  state.set(sf, "done");
@@ -74,7 +86,7 @@ export function appendForkModules(program, order, targets, onCycle) {
74
86
  added.push(sf);
75
87
  };
76
88
  const knownTargets = new Set(targets);
77
- for (const path of forkTargetPaths(program, order)) {
89
+ for (const path of paths) {
78
90
  const target = byPath.get(resolvePath(path));
79
91
  if (!target || target.isDeclarationFile || target.fileName.endsWith(".json"))
80
92
  continue;
@@ -88,10 +100,10 @@ export function appendForkModules(program, order, targets, onCycle) {
88
100
  order.splice(order.length - 1, 0, ...added);
89
101
  }
90
102
  /** Splits each file into function/class declarations and the top-level
91
- * statements that form its init body. Node's evaluation order (depth-first
92
- * postorder, entry last), computed by preflight. Single-file programs
93
- * (tests, coverage on broken files) may arrive with an empty order — fall
94
- * back to the entry alone. */
103
+ * statements that form its init body. Node's evaluation order (depth-first
104
+ * postorder, entry last), computed by preflight. Single-file programs
105
+ * (tests, coverage on broken files) may arrive with an empty order — fall
106
+ * back to the entry alone. */
95
107
  export function splitFiles(lowerer) {
96
108
  const files = lowerer.moduleOrder.length > 0 ? lowerer.moduleOrder : [lowerer.entry];
97
109
  return files.map((sf) => {
@@ -123,10 +135,10 @@ export function splitFiles(lowerer) {
123
135
  });
124
136
  }
125
137
  /** A source file dynamic `import("<project specifier>")` can host as a COMPILED
126
- * module namespace (lowerOwnModuleImport): a non-declaration program file
127
- * that is not JSON and not CommonJS-flavored (a CJS namespace is built
128
- * from module.exports through Node's lexer — a different surface with no
129
- * static story here). Null for everything else. */
138
+ * module namespace (lowerOwnModuleImport): a non-declaration program file
139
+ * that is not JSON and not CommonJS-flavored (a CJS namespace is built
140
+ * from module.exports through Node's lexer — a different surface with no
141
+ * static story here). Null for everything else. */
130
142
  function dynamicImportProgramTargetOf(program, sf, spec) {
131
143
  const dep = resolveImport(program, sf, spec);
132
144
  if (!dep || dep.isDeclarationFile)
@@ -138,7 +150,7 @@ function dynamicImportProgramTargetOf(program, sf, spec) {
138
150
  return dep;
139
151
  }
140
152
  /** Every distinct program module a file's `import("literal")` sites name
141
- * (source order, deduped). */
153
+ * (source order, deduped). */
142
154
  function dynamicProgramImportsOf(program, sf) {
143
155
  const out = [];
144
156
  const seen = new Set();
@@ -157,21 +169,21 @@ function dynamicProgramImportsOf(program, sf) {
157
169
  return out;
158
170
  }
159
171
  /** --dynamic builds: program modules reachable ONLY through dynamic
160
- * `import()` join the compiled module graph — appended to `order` (before
161
- * the entry, which stays last) in depth-first postorder over their own
162
- * static import edges, exactly like preflight ordered the static graph.
163
- * NOTHING calls their %init at startup (%main runs only the entry's init,
164
- * and no static import header names these), so a dynamic-only module
165
- * still evaluates exactly when Node evaluates it: the import() site's
166
- * namespace builder calls the guarded init on the engine microtask.
167
- * Fixpoint: an added module's own import() sites are scanned too. Static
168
- * cycles inside the added subgraph ride preflight's own admission engine
169
- * (makeCycleAdmission — preflight only walked the entry's static graph,
170
- * so it never judged these): benign back edges are Node cache hits the
171
- * run-once init guards reproduce, and inadmissible ones get preflight's
172
- * SC1016 with the same narrowed reason via `onCycle`. Idempotent —
173
- * re-running on an already-extended order adds nothing (both lowering
174
- * passes share one array). */
172
+ * `import()` join the compiled module graph — appended to `order` (before
173
+ * the entry, which stays last) in depth-first postorder over their own
174
+ * static import edges, exactly like preflight ordered the static graph.
175
+ * NOTHING calls their %init at startup (%main runs only the entry's init,
176
+ * and no static import header names these), so a dynamic-only module
177
+ * still evaluates exactly when Node evaluates it: the import() site's
178
+ * namespace builder calls the guarded init on the engine microtask.
179
+ * Fixpoint: an added module's own import() sites are scanned too. Static
180
+ * cycles inside the added subgraph ride preflight's own admission engine
181
+ * (makeCycleAdmission — preflight only walked the entry's static graph,
182
+ * so it never judged these): benign back edges are Node cache hits the
183
+ * run-once init guards reproduce, and inadmissible ones get preflight's
184
+ * SC1016 with the same narrowed reason via `onCycle`. Idempotent —
185
+ * re-running on an already-extended order adds nothing (both lowering
186
+ * passes share one array). */
175
187
  export function appendDynamicImportModules(program, order, onCycle) {
176
188
  if (order.length === 0)
177
189
  return; // no preflight order — sites keep their fences
@@ -224,10 +236,10 @@ export function appendDynamicImportModules(program, order, onCycle) {
224
236
  order.splice(order.length - 1, 0, ...added);
225
237
  }
226
238
  /** Collect pass over the WHOLE program: signatures, class shapes, and
227
- * file-scope globals visible everywhere → hoisting, mutual recursion, and
228
- * cross-module references fall out for free. Runs in both passes —
229
- * signatures are cheap and calls resolve against them; only BODY lowering
230
- * is reachability-gated. */
239
+ * file-scope globals visible everywhere → hoisting, mutual recursion, and
240
+ * cross-module references fall out for free. Runs in both passes —
241
+ * signatures are cheap and calls resolve against them; only BODY lowering
242
+ * is reachability-gated. */
231
243
  export function collectProgram(lowerer, parts) {
232
244
  const computed = new Set();
233
245
  for (const fp of parts)
@@ -238,7 +250,9 @@ export function collectProgram(lowerer, parts) {
238
250
  }
239
251
  // Descendants need the computed ancestor's completed layout before
240
252
  // their own fields and inherited methods can be collected.
241
- const computedSymbols = new Set([...computed].map((decl) => declSymbolOf(lowerer, decl)).filter((symbol) => symbol !== undefined));
253
+ const computedSymbols = new Set([...computed]
254
+ .map((decl) => declSymbolOf(lowerer, decl))
255
+ .filter((symbol) => symbol !== undefined));
242
256
  let expanded = true;
243
257
  while (expanded) {
244
258
  expanded = false;
@@ -312,18 +326,39 @@ export function collectProgram(lowerer, parts) {
312
326
  if (value.type.kind === "dyn" || value.type.kind === "func") {
313
327
  const name = `%class.base.${lowerer.classNamer(decl)}`;
314
328
  const loc = locOf(expression);
315
- lowerer.liftedFns.push({ name, params: [], returnType: value.type, locals: context.locals,
316
- body: [{ kind: "return", value, loc }], loc });
317
- lowerer.computedCallableBases.set(decl, { kind: "call", callee: name, args: [], type: value.type, loc });
329
+ lowerer.liftedFns.push({
330
+ name,
331
+ params: [],
332
+ returnType: value.type,
333
+ locals: context.locals,
334
+ body: [{ kind: "return", value, loc }],
335
+ loc,
336
+ });
337
+ lowerer.computedCallableBases.set(decl, {
338
+ kind: "call",
339
+ callee: name,
340
+ args: [],
341
+ type: value.type,
342
+ loc,
343
+ });
318
344
  }
319
345
  if (value.type.kind === "classval") {
320
346
  const classInfo = lowerer.classes.get(value.type.className);
321
347
  if (classInfo) {
322
348
  const name = `%class.base.${lowerer.classNamer(decl)}`;
323
349
  const loc = locOf(expression);
324
- lowerer.liftedFns.push({ name, params: [], returnType: value.type, locals: context.locals,
325
- body: [{ kind: "return", value, loc }], loc });
326
- lowerer.computedClassBases.set(lowerer.classNamer(decl), { value: { kind: "call", callee: name, args: [], type: value.type, loc }, classInfo });
350
+ lowerer.liftedFns.push({
351
+ name,
352
+ params: [],
353
+ returnType: value.type,
354
+ locals: context.locals,
355
+ body: [{ kind: "return", value, loc }],
356
+ loc,
357
+ });
358
+ lowerer.computedClassBases.set(lowerer.classNamer(decl), {
359
+ value: { kind: "call", callee: name, args: [], type: value.type, loc },
360
+ classInfo,
361
+ });
327
362
  }
328
363
  }
329
364
  }
@@ -343,25 +378,28 @@ export function collectProgram(lowerer, parts) {
343
378
  lowerer.diagSink = previousSink;
344
379
  }
345
380
  if (symbol && deferred.length) {
346
- lowerer.deferredDiags.set(symbol, [...(lowerer.deferredDiags.get(symbol) ?? []), ...deferred]);
381
+ lowerer.deferredDiags.set(symbol, [
382
+ ...(lowerer.deferredDiags.get(symbol) ?? []),
383
+ ...deferred,
384
+ ]);
347
385
  lowerer.deferredClassByName.set(lowerer.classNamer(decl), symbol);
348
386
  }
349
387
  lowerer.collecting = wasCollecting;
350
388
  }
351
389
  }
352
390
  /** The npm-import chokepoint, run once per pass during collection (so
353
- * bodies lowered in ANY pass resolve the bindings). In a static build
354
- * every value-importing npm import reports the requires-dynamic
355
- * diagnostic naming the package — the package's shipped JS has exactly
356
- * one execution home, the embedded engine. Under --dynamic each value
357
- * binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
358
- * importing the same export share one global) and initialized at the
359
- * top of the importing module's %init by island.import — the engine's
360
- * module registry caches, so re-imports are lookups, not re-evaluations.
361
- * The runtime graph (the package entry plus everything it reaches)
362
- * builds here too; its failures are ordinary diagnostics at the import
363
- * site. Type-only imports are free either way: the .d.ts is a type
364
- * surface, not code. */
391
+ * bodies lowered in ANY pass resolve the bindings). In a static build
392
+ * every value-importing npm import reports the requires-dynamic
393
+ * diagnostic naming the package — the package's shipped JS has exactly
394
+ * one execution home, the embedded engine. Under --dynamic each value
395
+ * binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
396
+ * importing the same export share one global) and initialized at the
397
+ * top of the importing module's %init by island.import — the engine's
398
+ * module registry caches, so re-imports are lookups, not re-evaluations.
399
+ * The runtime graph (the package entry plus everything it reaches)
400
+ * builds here too; its failures are ordinary diagnostics at the import
401
+ * site. Type-only imports are free either way: the .d.ts is a type
402
+ * surface, not code. */
365
403
  export function collectNpmImports(lowerer, parts) {
366
404
  const services = lowerer.frontendServices;
367
405
  if (lowerer.dynamic && services === undefined)
@@ -386,9 +424,12 @@ export function collectNpmImports(lowerer, parts) {
386
424
  !stmt.moduleSpecifier.text.startsWith("#")
387
425
  ? stmt.exportClause
388
426
  : null;
389
- if (reexport === null && (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)))
427
+ if (reexport === null &&
428
+ (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)))
390
429
  continue;
391
- const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt) ? stmt.moduleSpecifier : undefined;
430
+ const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt)
431
+ ? stmt.moduleSpecifier
432
+ : undefined;
392
433
  if (specNode === undefined || !ts.isStringLiteral(specNode))
393
434
  continue;
394
435
  const clause = ts.isImportDeclaration(stmt) ? stmt.importClause : undefined;
@@ -559,18 +600,18 @@ export function collectNpmImports(lowerer, parts) {
559
600
  }
560
601
  }
561
602
  /** Literal dynamic-import collection: every
562
- * `import("literal")` in the file — whatever body it sits in — resolves
563
- * and embeds AT COLLECTION time, so the per-site lowering later just
564
- * looks its key up (the emitted tables are assembled once, here; a
565
- * site lowered in any pass finds its module embedded). Resolution
566
- * In static builds this records compiled program modules and supported
567
- * builtins without constructing an npm graph. Dynamic package-resolution
568
- * failures and unshimmed builtins are diagnostics HERE, at the import
569
- * expression, exactly like static npm imports at their statements; the
570
- * lowering poisons those sites without re-reporting. Non-literal
571
- * specifiers are skipped — the lowering owns that fence (the module
572
- * graph is a build-time artifact; there is nothing to embed for a
573
- * runtime-computed name). */
603
+ * `import("literal")` in the file — whatever body it sits in — resolves
604
+ * and embeds AT COLLECTION time, so the per-site lowering later just
605
+ * looks its key up (the emitted tables are assembled once, here; a
606
+ * site lowered in any pass finds its module embedded). Resolution
607
+ * In static builds this records compiled program modules and supported
608
+ * builtins without constructing an npm graph. Dynamic package-resolution
609
+ * failures and unshimmed builtins are diagnostics HERE, at the import
610
+ * expression, exactly like static npm imports at their statements; the
611
+ * lowering poisons those sites without re-reporting. Non-literal
612
+ * specifiers are skipped — the lowering owns that fence (the module
613
+ * graph is a build-time artifact; there is nothing to embed for a
614
+ * runtime-computed name). */
574
615
  function collectDynamicImports(lowerer, builder, sf) {
575
616
  ts.walkPreorder(sf, (node) => {
576
617
  if (ts.isCallExpression(node) &&
@@ -590,7 +631,10 @@ function collectDynamicImports(lowerer, builder, sf) {
590
631
  // says so. Only non-declaration source files count; a sibling
591
632
  // .d.mts typing shipped JS is the EMBED case, not this one.
592
633
  const modSym = lowerer.checker.getSymbolAtLocation(node.arguments[0]);
593
- const ownModule = modSym !== undefined && lowerer.checker.declarationsOf(modSym).some((d) => ts.isSourceFile(d) && !d.isDeclarationFile);
634
+ const ownModule = modSym !== undefined &&
635
+ lowerer.checker
636
+ .declarationsOf(modSym)
637
+ .some((d) => ts.isSourceFile(d) && !d.isDeclarationFile);
594
638
  const builtin = canonicalBuiltinModule(spec);
595
639
  const res = ownModule
596
640
  ? { kind: "program-module" }
@@ -613,14 +657,14 @@ function collectDynamicImports(lowerer, builder, sf) {
613
657
  });
614
658
  }
615
659
  /** The createRequire half of the npm chokepoint (--dynamic only): every
616
- * `require("bare-literal")` through a createRequire binding — whatever
617
- * body it sits in — resolves under Node's "require" condition and
618
- * embeds AT COLLECTION time, so the per-site lowering later just looks
619
- * its entry up (lowerCreateRequireCall). Builtins, relative documents,
620
- * "#" specifiers, --npm-static opt-ins, and Node-refused bare names
621
- * are the lowering's own arms — only resolvable installed packages
622
- * register here; resolution failures are diagnostics at the call
623
- * expression, exactly like static npm imports at their statements. */
660
+ * `require("bare-literal")` through a createRequire binding — whatever
661
+ * body it sits in — resolves under Node's "require" condition and
662
+ * embeds AT COLLECTION time, so the per-site lowering later just looks
663
+ * its entry up (lowerCreateRequireCall). Builtins, relative documents,
664
+ * "#" specifiers, --npm-static opt-ins, and Node-refused bare names
665
+ * are the lowering's own arms — only resolvable installed packages
666
+ * register here; resolution failures are diagnostics at the call
667
+ * expression, exactly like static npm imports at their statements. */
624
668
  function collectCreateRequires(lowerer, builder, sf) {
625
669
  const visit = (node) => {
626
670
  if (ts.isCallExpression(node)) {
@@ -654,17 +698,17 @@ function collectCreateRequires(lowerer, builder, sf) {
654
698
  visit(sf);
655
699
  }
656
700
  /** JSON module default imports (`import pkg from "../package.json"`):
657
- * the document is DATA known at build time, so the binding bakes into a
658
- * record global — the checker's structural type for the module (thanks
659
- * to resolveJsonModule) maps to a record shape, the JSON text parses in
660
- * the compiler, and comptimeValueToIr turns the value into literal IR
661
- * assigned in the importing module's %init prelude (evaluation order:
662
- * imports before the importer's body, like npm bindings). Two importers
663
- * of the same document share one global (keyed by the ALIASED symbol).
664
- * Shapes outside the bakeable surface (null-valued fields, mixed
665
- * arrays, ...) report the standard unsupported-type diagnostic at the
666
- * import site. Preflight already fenced named/namespace JSON imports
667
- * and kept .json files out of the module order. */
701
+ * the document is DATA known at build time, so the binding bakes into a
702
+ * record global — the checker's structural type for the module (thanks
703
+ * to resolveJsonModule) maps to a record shape, the JSON text parses in
704
+ * the compiler, and comptimeValueToIr turns the value into literal IR
705
+ * assigned in the importing module's %init prelude (evaluation order:
706
+ * imports before the importer's body, like npm bindings). Two importers
707
+ * of the same document share one global (keyed by the ALIASED symbol).
708
+ * Shapes outside the bakeable surface (null-valued fields, mixed
709
+ * arrays, ...) report the standard unsupported-type diagnostic at the
710
+ * import site. Preflight already fenced named/namespace JSON imports
711
+ * and kept .json files out of the module order. */
668
712
  export function collectJsonImports(lowerer, parts) {
669
713
  for (const fp of parts) {
670
714
  for (const stmt of fp.sf.statements) {
@@ -723,14 +767,14 @@ export function collectJsonImports(lowerer, parts) {
723
767
  }
724
768
  }
725
769
  /** The classes, records, and unions the emitted module carries: exactly
726
- * what the lowered functions and globals reference, closed transitively
727
- * over record fields, union arms, class field types, base chains, and
728
- * constructible descendants and their base chains. Registry entries interned while collecting
729
- * signatures nothing reaches stay out — an unreached type leaves no
730
- * trace. A referenced class with no registration had its collection
731
- * deferred: the reference flushes those diagnostics. Methods whose
732
- * bodies were not lowered leave the def's method list, so vtable slots
733
- * exist exactly for emitted overrides. */
770
+ * what the lowered functions and globals reference, closed transitively
771
+ * over record fields, union arms, class field types, base chains, and
772
+ * constructible descendants and their base chains. Registry entries interned while collecting
773
+ * signatures nothing reaches stay out — an unreached type leaves no
774
+ * trace. A referenced class with no registration had its collection
775
+ * deferred: the reference flushes those diagnostics. Methods whose
776
+ * bodies were not lowered leave the def's method list, so vtable slots
777
+ * exist exactly for emitted overrides. */
734
778
  export function moduleArtifacts(lowerer, functions) {
735
779
  const valueInstanceOfRoots = new Set();
736
780
  const classNames = new Set();
@@ -741,23 +785,30 @@ export function moduleArtifacts(lowerer, functions) {
741
785
  const pendingUnions = [];
742
786
  const boxedChild = (type, seen = new Set()) => {
743
787
  switch (type.kind) {
744
- case "child": return true;
788
+ case "child":
789
+ return true;
745
790
  case "array":
746
- case "set": return boxedChild(type.elem, seen);
747
- case "promise": return boxedChild(type.inner, seen);
748
- case "map": return boxedChild(type.key, seen) || boxedChild(type.value, seen);
749
- case "func": return boxedChild(type.ret, seen);
791
+ case "set":
792
+ return boxedChild(type.elem, seen);
793
+ case "promise":
794
+ return boxedChild(type.inner, seen);
795
+ case "map":
796
+ return boxedChild(type.key, seen) || boxedChild(type.value, seen);
797
+ case "func":
798
+ return boxedChild(type.ret, seen);
750
799
  case "record":
751
800
  if (seen.has(type.shapeId))
752
801
  return false;
753
802
  seen.add(type.shapeId);
754
- return lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ?? false;
803
+ return (lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ??
804
+ false);
755
805
  case "union":
756
806
  if (seen.has(type.unionId))
757
807
  return false;
758
808
  seen.add(type.unionId);
759
809
  return lowerer.unions.get(type.unionId)?.arms.some((arm) => boxedChild(arm, seen)) ?? false;
760
- default: return false;
810
+ default:
811
+ return false;
761
812
  }
762
813
  };
763
814
  const visitClass = (name) => {
@@ -903,9 +954,7 @@ export function moduleArtifacts(lowerer, functions) {
903
954
  pendingClasses.push(name);
904
955
  }
905
956
  }
906
- while (pendingClasses.length > 0 ||
907
- pendingShapes.length > 0 ||
908
- pendingUnions.length > 0) {
957
+ while (pendingClasses.length > 0 || pendingShapes.length > 0 || pendingUnions.length > 0) {
909
958
  while (pendingShapes.length > 0) {
910
959
  // Declared fields AND the index-signature value type: an
911
960
  // overflow-valued shape (`{ [key: string]: {script?: string} }`)
@@ -937,6 +986,8 @@ export function moduleArtifacts(lowerer, functions) {
937
986
  visitType(field.type);
938
987
  if (info.base)
939
988
  visitClass(info.base.def.name);
989
+ if (info.def.genericOf)
990
+ visitClass(info.def.genericOf);
940
991
  if (lowerer.inHierarchy(info)) {
941
992
  let root = info;
942
993
  while (root.base)
@@ -987,14 +1038,14 @@ export function moduleArtifacts(lowerer, functions) {
987
1038
  };
988
1039
  }
989
1040
  /** Registers every DIRECT top-level `const`/`let` of a file as a module
990
- * global (stable storage: cross-module live bindings, and functions can
991
- * reference them without capture). Block-scoped vars inside nested
992
- * statements keep their different symbols and stay locals. */
1041
+ * global (stable storage: cross-module live bindings, and functions can
1042
+ * reference them without capture). Block-scoped vars inside nested
1043
+ * statements keep their different symbols and stay locals. */
993
1044
  /** JS collection failures defer to runtime fences: the registration's
994
- * diagnostics move off the build (into lowerer.runtimeFences) — the declaring
995
- * statement re-fails during init lowering and compiles to the
996
- * runtimeFence trap there, and every use site cascades to its own trap.
997
- * TypeScript files keep eager collection reports. */
1045
+ * diagnostics move off the build (into lowerer.runtimeFences) — the declaring
1046
+ * statement re-fails during init lowering and compiles to the
1047
+ * runtimeFence trap there, and every use site cascades to its own trap.
1048
+ * TypeScript files keep eager collection reports. */
998
1049
  function deferJsCollectionDiags(lowerer, sf, diagsBefore) {
999
1050
  if (!isJsSourceFile(sf))
1000
1051
  return;
@@ -1027,12 +1078,14 @@ function cjsScalarLiteral(e) {
1027
1078
  function checkedGlobalReference(lowerer, expression) {
1028
1079
  if (ts.isIdentifier(expression))
1029
1080
  return lowerer.globalOf(expression)?.type.kind === "dyn";
1030
- if (!ts.isPropertyAccessExpression(expression) || !ts.isIdentifier(expression.name) || !ts.isIdentifier(expression.expression))
1081
+ if (!ts.isPropertyAccessExpression(expression) ||
1082
+ !ts.isIdentifier(expression.name) ||
1083
+ !ts.isIdentifier(expression.expression))
1031
1084
  return false;
1032
1085
  const root = lowerer.checker.getSymbolAtLocation(expression.expression);
1033
1086
  const namespace = root && lowerer.checker.declarationsOf(root).some(ts.isNamespaceImport);
1034
- return (namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
1035
- lowerer.globalOf(expression.name)?.type.kind === "dyn";
1087
+ return ((namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
1088
+ lowerer.globalOf(expression.name)?.type.kind === "dyn");
1036
1089
  }
1037
1090
  function jsDynHoldableInitializer(lowerer, init) {
1038
1091
  if (init === undefined)
@@ -1044,15 +1097,18 @@ function jsDynHoldableInitializer(lowerer, init) {
1044
1097
  e = e.expression;
1045
1098
  if (checkedGlobalReference(lowerer, e))
1046
1099
  return true;
1047
- if (ts.isCallExpression(e) && ts.isPropertyAccessExpression(e.expression) &&
1100
+ if (ts.isCallExpression(e) &&
1101
+ ts.isPropertyAccessExpression(e.expression) &&
1048
1102
  ["freeze", "seal", "preventExtensions"].includes(e.expression.name.text) &&
1049
- lowerer.stdlibGlobalMember(e.expression, "Object") !== null && e.arguments[0] &&
1103
+ lowerer.stdlibGlobalMember(e.expression, "Object") !== null &&
1104
+ e.arguments[0] &&
1050
1105
  ts.isArrayLiteralExpression(e.arguments[0]))
1051
1106
  return true;
1052
1107
  // The built-in Array constructor can create an evolving array whose
1053
1108
  // inferred element type has no native mapping. Its checked reference
1054
1109
  // must remain shared with separately declared functions and aliases.
1055
- if ((ts.isCallExpression(e) || ts.isNewExpression(e)) && lowerer.isStdlibGlobal(e.expression, "Array"))
1110
+ if ((ts.isCallExpression(e) || ts.isNewExpression(e)) &&
1111
+ lowerer.isStdlibGlobal(e.expression, "Array"))
1056
1112
  return true;
1057
1113
  // JavaScript process streams lower to native checked handles even when
1058
1114
  // their declared method overloads prevent a structural type mapping.
@@ -1061,7 +1117,8 @@ function jsDynHoldableInitializer(lowerer, init) {
1061
1117
  const member = lowerer.stdlibGlobalMember(e, "process");
1062
1118
  if (member === "stdin" || member === "stdout" || member === "stderr")
1063
1119
  return true;
1064
- if (e.name.text === "constructor" && lowerer.checker.getCallSignatures(lowerer.typeOf(e.expression)).length > 0)
1120
+ if (e.name.text === "constructor" &&
1121
+ lowerer.checker.getCallSignatures(lowerer.typeOf(e.expression)).length > 0)
1065
1122
  return true;
1066
1123
  }
1067
1124
  if (e.kind === ts.SyntaxKind.NullKeyword)
@@ -1069,45 +1126,60 @@ function jsDynHoldableInitializer(lowerer, init) {
1069
1126
  if (ts.isIdentifier(e) && e.text === "undefined")
1070
1127
  return true;
1071
1128
  if (ts.isConditionalExpression(e)) {
1072
- return jsDynHoldableInitializer(lowerer, e.whenTrue) && jsDynHoldableInitializer(lowerer, e.whenFalse);
1129
+ return (jsDynHoldableInitializer(lowerer, e.whenTrue) &&
1130
+ jsDynHoldableInitializer(lowerer, e.whenFalse));
1073
1131
  }
1074
- if (ts.isBinaryExpression(e) && (e.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
1075
- e.operatorToken.kind === ts.SyntaxKind.BarBarToken || e.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {
1132
+ if (ts.isBinaryExpression(e) &&
1133
+ (e.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
1134
+ e.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
1135
+ e.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {
1076
1136
  return jsDynHoldableInitializer(lowerer, e.left) && jsDynHoldableInitializer(lowerer, e.right);
1077
1137
  }
1078
1138
  // A member of a checked module value is itself checked, including a
1079
1139
  // callable whose inferred overloads cannot describe one native ABI.
1080
1140
  if ((ts.isPropertyAccessExpression(e) || ts.isElementAccessExpression(e)) &&
1081
- ts.isIdentifier(e.expression) && lowerer.globalOf(e.expression)?.type.kind === "dyn")
1141
+ ts.isIdentifier(e.expression) &&
1142
+ lowerer.globalOf(e.expression)?.type.kind === "dyn")
1082
1143
  return true;
1083
1144
  if (ts.isPropertyAccessExpression(e)) {
1084
1145
  const member = nsMemberIdentOf(lowerer, e);
1085
- if (member && (lowerer.globalOf(member)?.type.kind === "dyn" || lowerer.genericFnOf(member)?.implicitParams))
1146
+ if (member &&
1147
+ (lowerer.globalOf(member)?.type.kind === "dyn" || lowerer.genericFnOf(member)?.implicitParams))
1086
1148
  return true;
1087
1149
  }
1088
1150
  // Optional callable reads (for example descriptor?.get) can be held in
1089
1151
  // the same checked slot as a callable. Their nullish arm must remain
1090
1152
  // observable by functions declared outside the module initializer.
1091
- if (ts.isPropertyAccessExpression(e) || ts.isElementAccessExpression(e) || ts.isCallExpression(e)) {
1153
+ if (ts.isPropertyAccessExpression(e) ||
1154
+ ts.isElementAccessExpression(e) ||
1155
+ ts.isCallExpression(e)) {
1092
1156
  const fallback = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
1093
- if (fallback?.kind === "func" && canBoxFuncIntoDyn(fallback, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1157
+ if (fallback?.kind === "func" &&
1158
+ canBoxFuncIntoDyn(fallback, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1094
1159
  return true;
1095
1160
  const arms = fallback?.kind === "union" ? lowerer.unions.get(fallback.unionId)?.arms : undefined;
1096
- if (arms?.some(arm => arm.kind === "func") && arms.every(arm => isUnitType(arm) || (arm.kind === "func" && canBoxFuncIntoDyn(arm, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))))
1161
+ if (arms?.some((arm) => arm.kind === "func") &&
1162
+ arms.every((arm) => isUnitType(arm) ||
1163
+ (arm.kind === "func" &&
1164
+ canBoxFuncIntoDyn(arm, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))))
1097
1165
  return true;
1098
1166
  }
1099
- if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) && !e.typeParameters?.length && isJsSourceFile(e.getSourceFile()))
1167
+ if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) &&
1168
+ !e.typeParameters?.length &&
1169
+ isJsSourceFile(e.getSourceFile()))
1100
1170
  return true;
1101
1171
  if (ts.isIdentifier(e) || ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
1102
1172
  if (ts.isIdentifier(e)) {
1103
1173
  if (lowerer.globalOf(e)?.type.kind === "dyn")
1104
1174
  return true;
1105
1175
  const signature = lowerer.isTopLevelFnSymbol(e) ? lowerer.fnSigOf(e) : null;
1106
- if (signature && canBoxFuncIntoDyn(funcTypeFromParamShapes(signature.params, signature.returnType), (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1176
+ if (signature &&
1177
+ canBoxFuncIntoDyn(funcTypeFromParamShapes(signature.params, signature.returnType), (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1107
1178
  return true;
1108
1179
  }
1109
1180
  const type = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
1110
- if (type?.kind === "func" && canBoxFuncIntoDyn(type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1181
+ if (type?.kind === "func" &&
1182
+ canBoxFuncIntoDyn(type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1111
1183
  return true;
1112
1184
  }
1113
1185
  if ((ts.isCallExpression(e) || ts.isPropertyAccessExpression(e) || ts.isIdentifier(e)) &&
@@ -1192,9 +1264,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
1192
1264
  let inner = stmt.expression;
1193
1265
  while (ts.isParenthesizedExpression(inner))
1194
1266
  inner = inner.expression;
1195
- if (ts.isClassExpression(inner) && !isJsSourceFile(sf) &&
1267
+ if (ts.isClassExpression(inner) &&
1268
+ !isJsSourceFile(sf) &&
1196
1269
  inner.typeParameters === undefined &&
1197
- (decoratorNodesOf(inner).length > 0 || inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
1270
+ (decoratorNodesOf(inner).length > 0 ||
1271
+ inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
1198
1272
  guaranteedDecorationThrow(lowerer, inner) !== null) {
1199
1273
  continue;
1200
1274
  }
@@ -1214,7 +1288,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
1214
1288
  lowerer.badType(stmt.expression, tsType);
1215
1289
  // Inferred JavaScript factory exports keep their original value,
1216
1290
  // including callable objects decorated with Object.assign.
1217
- if (isJsSourceFile(sf) && ts.isCallExpression(stmt.expression) && type.kind === "record" && lowerer.dynConvertible(type))
1291
+ if (isJsSourceFile(sf) &&
1292
+ ts.isCallExpression(stmt.expression) &&
1293
+ type.kind === "record" &&
1294
+ lowerer.dynConvertible(type))
1218
1295
  type = DYN;
1219
1296
  // `export default undefined` — the unit-only union, like any
1220
1297
  // unit-only binding (`export default null` maps via mapType).
@@ -1253,7 +1330,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
1253
1330
  // tsgo answers no symbol at the attachment site's NAME (no
1254
1331
  // expando synthesis); the module symbol's exports table still
1255
1332
  // names the member — the same identity use sites resolve.
1256
- const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ?? lowerer.cjsModuleExportSymbol(sf, name);
1333
+ const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ??
1334
+ lowerer.cjsModuleExportSymbol(sf, name);
1257
1335
  if (!symbol || lowerer.globalsBySymbol.has(symbol))
1258
1336
  return;
1259
1337
  // JS exports whose strict type has no mapping take the
@@ -1281,7 +1359,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1281
1359
  lowerer.globalsByDeclNode.set(d, vG);
1282
1360
  return;
1283
1361
  }
1284
- const g = { id: `%g.${tag}%export.${name}`, name, type: vG.type, mutable: false };
1362
+ const g = {
1363
+ id: `%g.${tag}%export.${name}`,
1364
+ name,
1365
+ type: vG.type,
1366
+ mutable: false,
1367
+ };
1285
1368
  lowerer.globalsBySymbol.set(symbol, g);
1286
1369
  for (const d of lowerer.checker.declarationsOf(symbol))
1287
1370
  lowerer.globalsByDeclNode.set(d, g);
@@ -1358,7 +1441,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1358
1441
  if (factoryValued && t?.kind === "record" && lowerer.dynConvertible(t))
1359
1442
  t = DYN;
1360
1443
  if (t && t.kind !== "void") {
1361
- const g = { id: `%g.${tag}exports`, name: "exports", type: t, mutable: false };
1444
+ const g = {
1445
+ id: `%g.${tag}exports`,
1446
+ name: "exports",
1447
+ type: t,
1448
+ mutable: false,
1449
+ };
1362
1450
  lowerer.globalsByDeclNode.set(cjs.expr, g);
1363
1451
  lowerer.globalsList.push(g);
1364
1452
  }
@@ -1399,7 +1487,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
1399
1487
  if (ts.isExternalModuleReference(stmt.moduleReference) || stmt.isTypeOnly)
1400
1488
  continue;
1401
1489
  const aliasSym = lowerer.checker.getSymbolAtLocation(stmt.name);
1402
- if (!aliasSym || !(aliasSym.flags & ts.SymbolFlags.Alias) || lowerer.globalsBySymbol.has(aliasSym))
1490
+ if (!aliasSym ||
1491
+ !(aliasSym.flags & ts.SymbolFlags.Alias) ||
1492
+ lowerer.globalsBySymbol.has(aliasSym))
1403
1493
  continue;
1404
1494
  const target = lowerer.checker.getAliasedSymbol(aliasSym);
1405
1495
  const vd = lowerer.checker.valueDeclarationOf(target);
@@ -1450,10 +1540,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
1450
1540
  // require('node:process')` aliases the global process
1451
1541
  // (stdlibGlobalAliasDecl's require form) so reads through the
1452
1542
  // binding lower via the process surface.
1453
- if (isRequireStatement(stmt) && !(ts.isVariableStatement(stmt) &&
1454
- stmt.declarationList.declarations.some(decl => isNativeFfiRequire(lowerer, decl.initializer)))) {
1455
- if (ts.isVariableStatement(stmt) &&
1456
- (stmt.declarationList.flags & ts.NodeFlags.Const) !== 0) {
1543
+ if (isRequireStatement(stmt) &&
1544
+ !(ts.isVariableStatement(stmt) &&
1545
+ stmt.declarationList.declarations.some((decl) => isNativeFfiRequire(lowerer, decl.initializer)))) {
1546
+ if (ts.isVariableStatement(stmt) && (stmt.declarationList.flags & ts.NodeFlags.Const) !== 0) {
1457
1547
  for (const decl of stmt.declarationList.declarations) {
1458
1548
  stdlibGlobalAliasDecl(lowerer, decl.name, decl.initializer);
1459
1549
  }
@@ -1657,7 +1747,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
1657
1747
  // statement lowering skips the declaration by the same check. A
1658
1748
  // bad promisify target reports here (recorded once; the statement
1659
1749
  // lowering poisons too, like every collectGlobals failure).
1660
- if (ts.isIdentifier(decl.name) && decl.initializer && isPromisifyCall(lowerer, decl.initializer)) {
1750
+ if (ts.isIdentifier(decl.name) &&
1751
+ decl.initializer &&
1752
+ isPromisifyCall(lowerer, decl.initializer)) {
1661
1753
  try {
1662
1754
  lowerer.registerPromisifiedBuiltinDecl(decl.name, decl.initializer);
1663
1755
  }
@@ -1728,13 +1820,22 @@ export function collectGlobals(lowerer, sf, topStmts) {
1728
1820
  // Checked JavaScript factories can expose inferred callables by
1729
1821
  // destructuring. Keep each exported binding in module storage so
1730
1822
  // separately lowered functions see the initialized value.
1731
- if (isJsSourceFile(sf) && !ts.isIdentifier(decl.name) && decl.initializer &&
1732
- !decl.type && !hasJsTypeAnnotation(decl) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode))) {
1823
+ if (isJsSourceFile(sf) &&
1824
+ !ts.isIdentifier(decl.name) &&
1825
+ decl.initializer &&
1826
+ !decl.type &&
1827
+ !hasJsTypeAnnotation(decl) &&
1828
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode))) {
1733
1829
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1734
1830
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1735
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text,
1736
- type: DYN, mutable: isLet, source: bindingSource(nameNode),
1737
- ...(!isVarDeclared(decl) ? { tdz: true } : {}) };
1831
+ const g = {
1832
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1833
+ name: nameNode.text,
1834
+ type: DYN,
1835
+ mutable: isLet,
1836
+ source: bindingSource(nameNode),
1837
+ ...(!isVarDeclared(decl) ? { tdz: true } : {}),
1838
+ };
1738
1839
  lowerer.globalsBySymbol.set(symbol, g);
1739
1840
  lowerer.globalsList.push(g);
1740
1841
  if (isVarDeclared(decl))
@@ -1746,16 +1847,25 @@ export function collectGlobals(lowerer, sf, topStmts) {
1746
1847
  // callable ABI. Preserve checked-native values in shared storage;
1747
1848
  // adapting the loader to (string) would replace its validation.
1748
1849
  const initializer = decl.initializer ? stripTypeCasts(decl.initializer) : undefined;
1749
- if (isJsSourceFile(sf) && nameNode === decl.name && initializer &&
1850
+ if (isJsSourceFile(sf) &&
1851
+ nameNode === decl.name &&
1852
+ initializer &&
1750
1853
  (isNativeBuiltinValueInitializer(lowerer, initializer) ||
1751
- (!decl.type && !hasJsTypeAnnotation(decl) && lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
1752
- (!decl.type && !hasJsTypeAnnotation(decl) && checkedGlobalReference(lowerer, initializer)) ||
1854
+ (!decl.type &&
1855
+ !hasJsTypeAnnotation(decl) &&
1856
+ lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
1857
+ (!decl.type &&
1858
+ !hasJsTypeAnnotation(decl) &&
1859
+ checkedGlobalReference(lowerer, initializer)) ||
1753
1860
  (!lowerer.dynamic && stdlibGlobalNameOf(lowerer, initializer) === "globalThis"))) {
1754
1861
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1755
1862
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1756
1863
  const g = {
1757
- id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text,
1758
- type: DYN, mutable: isLet, source: bindingSource(nameNode),
1864
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1865
+ name: nameNode.text,
1866
+ type: DYN,
1867
+ mutable: isLet,
1868
+ source: bindingSource(nameNode),
1759
1869
  ...(!isVarDeclared(decl) ? { tdz: true } : {}),
1760
1870
  };
1761
1871
  lowerer.globalsBySymbol.set(symbol, g);
@@ -1774,12 +1884,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
1774
1884
  // storage instead of fencing per reference. Identifier
1775
1885
  // declarations only: a destructured array literal binds its
1776
1886
  // pieces, not the array.
1777
- if (isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1778
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1779
- decl.initializer !== undefined && ts.isArrayLiteralExpression(decl.initializer)) {
1887
+ if (isJsSourceFile(sf) &&
1888
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1889
+ ts.isIdentifier(decl.name) &&
1890
+ nameNode === decl.name &&
1891
+ decl.initializer !== undefined &&
1892
+ ts.isArrayLiteralExpression(decl.initializer)) {
1780
1893
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1781
1894
  if (symbol) {
1782
- const g = { id: `%g.${tag}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1895
+ const g = {
1896
+ id: `%g.${tag}${nameNode.text}`,
1897
+ name: nameNode.text,
1898
+ type: DYN,
1899
+ mutable: isLet,
1900
+ source: bindingSource(nameNode),
1901
+ };
1783
1902
  lowerer.globalsBySymbol.set(symbol, g);
1784
1903
  lowerer.globalsList.push(g);
1785
1904
  }
@@ -1789,14 +1908,26 @@ export function collectGlobals(lowerer, sf, topStmts) {
1789
1908
  // Methods and computed properties require live checked storage:
1790
1909
  // symbol identity and a method's receiver cannot be reconstructed
1791
1910
  // from a copied, inferred record shape.
1792
- if (isJsSourceFile(sf) && ts.isIdentifier(decl.name) && nameNode === decl.name &&
1793
- decl.initializer && ts.isObjectLiteralExpression(decl.initializer) &&
1911
+ if (isJsSourceFile(sf) &&
1912
+ ts.isIdentifier(decl.name) &&
1913
+ nameNode === decl.name &&
1914
+ decl.initializer &&
1915
+ ts.isObjectLiteralExpression(decl.initializer) &&
1794
1916
  decl.initializer.properties.some((p) => !ts.isSpreadAssignment(p) &&
1795
- (ts.isMethodDeclaration(p) || ts.isAccessor(p) || ts.isComputedPropertyName(p.name) ||
1796
- ts.isShorthandPropertyAssignment(p) && lowerer.checker.getCallSignatures(lowerer.typeOf(p.name)).length > 0))) {
1917
+ (ts.isMethodDeclaration(p) ||
1918
+ ts.isAccessor(p) ||
1919
+ ts.isComputedPropertyName(p.name) ||
1920
+ (ts.isShorthandPropertyAssignment(p) &&
1921
+ lowerer.checker.getCallSignatures(lowerer.typeOf(p.name)).length > 0)))) {
1797
1922
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1798
1923
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1799
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1924
+ const g = {
1925
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1926
+ name: nameNode.text,
1927
+ type: DYN,
1928
+ mutable: isLet,
1929
+ source: bindingSource(nameNode),
1930
+ };
1800
1931
  lowerer.globalsBySymbol.set(symbol, g);
1801
1932
  lowerer.globalsList.push(g);
1802
1933
  if (isVarDeclared(decl))
@@ -1821,21 +1952,31 @@ export function collectGlobals(lowerer, sf, topStmts) {
1821
1952
  // Spreads from an existing checked dictionary stay checked too;
1822
1953
  // copying its entries must not extract nested callable records.
1823
1954
  if (isJsSourceFile(sf) &&
1824
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1825
- decl.initializer !== undefined && ts.isObjectLiteralExpression(decl.initializer) &&
1955
+ ts.isIdentifier(decl.name) &&
1956
+ nameNode === decl.name &&
1957
+ decl.initializer !== undefined &&
1958
+ ts.isObjectLiteralExpression(decl.initializer) &&
1826
1959
  decl.initializer.properties.every((p) => {
1827
1960
  if (ts.isSpreadAssignment(p)) {
1828
- return ts.isIdentifier(p.expression) && lowerer.globalOf(p.expression)?.type.kind === "dyn";
1961
+ return (ts.isIdentifier(p.expression) &&
1962
+ lowerer.globalOf(p.expression)?.type.kind === "dyn");
1829
1963
  }
1830
1964
  if (!ts.isPropertyAssignment(p) || ts.isComputedPropertyName(p.name))
1831
1965
  return false;
1832
1966
  const mt = lowerer.mapTypeOf(lowerer.typeOf(p.initializer));
1833
- return mt === null || mt.kind === "dyn" ||
1834
- canConvertToDyn(mt, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id));
1967
+ return (mt === null ||
1968
+ mt.kind === "dyn" ||
1969
+ canConvertToDyn(mt, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)));
1835
1970
  })) {
1836
1971
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1837
1972
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1838
- const g = { id: `%g.${tag}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1973
+ const g = {
1974
+ id: `%g.${tag}${nameNode.text}`,
1975
+ name: nameNode.text,
1976
+ type: DYN,
1977
+ mutable: isLet,
1978
+ source: bindingSource(nameNode),
1979
+ };
1839
1980
  lowerer.globalsBySymbol.set(symbol, g);
1840
1981
  lowerer.globalsList.push(g);
1841
1982
  }
@@ -1854,13 +1995,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
1854
1995
  // decl keeps as an %init local) stay OUT: forcing those into
1855
1996
  // the checked-dynamic tree would trade their working typed representation for
1856
1997
  // fences.
1857
- if (isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1858
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1998
+ if (isJsSourceFile(sf) &&
1999
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
2000
+ ts.isIdentifier(decl.name) &&
2001
+ nameNode === decl.name &&
1859
2002
  jsDynHoldableInitializer(lowerer, decl.initializer) &&
1860
2003
  dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode))?.kind === "dyn") {
1861
2004
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1862
2005
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1863
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
2006
+ const g = {
2007
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
2008
+ name: nameNode.text,
2009
+ type: DYN,
2010
+ mutable: isLet,
2011
+ source: bindingSource(nameNode),
2012
+ };
1864
2013
  lowerer.globalsBySymbol.set(symbol, g);
1865
2014
  lowerer.globalsList.push(g);
1866
2015
  // Mutable dyn globals hold the dyn undefined from module
@@ -1879,13 +2028,23 @@ export function collectGlobals(lowerer, sf, topStmts) {
1879
2028
  // the binding holds the HANDLE — a jsval global, so exports
1880
2029
  // and separately-declared functions reach the same engine
1881
2030
  // object.
1882
- if (lowerer.dynamic && isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1883
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1884
- decl.initializer !== undefined && ts.isObjectLiteralExpression(decl.initializer) &&
2031
+ if (lowerer.dynamic &&
2032
+ isJsSourceFile(sf) &&
2033
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
2034
+ ts.isIdentifier(decl.name) &&
2035
+ nameNode === decl.name &&
2036
+ decl.initializer !== undefined &&
2037
+ ts.isObjectLiteralExpression(decl.initializer) &&
1885
2038
  decl.initializer.properties.some((p) => ts.isGetAccessorDeclaration(p))) {
1886
2039
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1887
2040
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1888
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text, type: JSVAL, mutable: isLet, source: bindingSource(nameNode) };
2041
+ const g = {
2042
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
2043
+ name: nameNode.text,
2044
+ type: JSVAL,
2045
+ mutable: isLet,
2046
+ source: bindingSource(nameNode),
2047
+ };
1889
2048
  lowerer.globalsBySymbol.set(symbol, g);
1890
2049
  lowerer.globalsList.push(g);
1891
2050
  }
@@ -1896,23 +2055,37 @@ export function collectGlobals(lowerer, sf, topStmts) {
1896
2055
  // that closure in a checked-value global so class methods and
1897
2056
  // other module functions see its declaration-position assignment.
1898
2057
  // A var starts undefined; lexical bindings retain the TDZ guard.
1899
- if (isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1900
- ts.isIdentifier(decl.name) && nameNode === decl.name && decl.initializer &&
2058
+ if (isJsSourceFile(sf) &&
2059
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
2060
+ ts.isIdentifier(decl.name) &&
2061
+ nameNode === decl.name &&
2062
+ decl.initializer &&
1901
2063
  jsDynHoldableInitializer(lowerer, decl.initializer)) {
1902
2064
  const initializer = decl.initializer;
1903
- const member = ts.isPropertyAccessExpression(initializer) ? nsMemberIdentOf(lowerer, initializer) : null;
2065
+ const member = ts.isPropertyAccessExpression(initializer)
2066
+ ? nsMemberIdentOf(lowerer, initializer)
2067
+ : null;
1904
2068
  const generic = member && lowerer.genericFnOf(member);
1905
- const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) && !initializer.typeParameters?.length
2069
+ const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) &&
2070
+ !initializer.typeParameters?.length
1906
2071
  ? lowerer.lambdaSignature(initializer).funcType
1907
- : member && lowerer.globalOf(member)?.type.kind === "dyn" ? DYN
1908
- : member && generic?.implicitParams ? lowerer.lowerGenericFnValue(member, generic).type
2072
+ : member && lowerer.globalOf(member)?.type.kind === "dyn"
2073
+ ? DYN
2074
+ : member && generic?.implicitParams
2075
+ ? lowerer.lowerGenericFnValue(member, generic).type
1909
2076
  : dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode));
1910
2077
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1911
- if (symbol && fallback && (fallback.kind === "dyn" || fallback.kind === "func" || fallback.kind === "union") && lowerer.dynConvertible(fallback)) {
2078
+ if (symbol &&
2079
+ fallback &&
2080
+ (fallback.kind === "dyn" || fallback.kind === "func" || fallback.kind === "union") &&
2081
+ lowerer.dynConvertible(fallback)) {
1912
2082
  if (!lowerer.globalsBySymbol.has(symbol)) {
1913
2083
  const g = {
1914
- id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text,
1915
- type: DYN, mutable: isLet, source: bindingSource(nameNode),
2084
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
2085
+ name: nameNode.text,
2086
+ type: DYN,
2087
+ mutable: isLet,
2088
+ source: bindingSource(nameNode),
1916
2089
  ...(!isVarDeclared(decl) ? { tdz: true } : {}),
1917
2090
  };
1918
2091
  lowerer.globalsBySymbol.set(symbol, g);
@@ -1930,37 +2103,63 @@ export function collectGlobals(lowerer, sf, topStmts) {
1930
2103
  // and closures created in the init body capture it normally.
1931
2104
  // References from separately-declared functions cascade to
1932
2105
  // their own per-site runtime fences.
1933
- const factoryType = !isLet && isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
1934
- ts.isIdentifier(decl.name) && nameNode === decl.name && decl.initializer && ts.isNewExpression(decl.initializer)
1935
- ? objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined : undefined;
2106
+ const factoryType = !isLet &&
2107
+ isJsSourceFile(sf) &&
2108
+ !decl.type &&
2109
+ !hasJsTypeAnnotation(decl) &&
2110
+ ts.isIdentifier(decl.name) &&
2111
+ nameNode === decl.name &&
2112
+ decl.initializer &&
2113
+ ts.isNewExpression(decl.initializer)
2114
+ ? (objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined)
2115
+ : undefined;
1936
2116
  // `var p1 = import("./m")` at file scope: the global holds the
1937
2117
  // island promise/handle — the import expression's only
1938
2118
  // production — whatever the checker's namespace type mapped to
1939
2119
  // (lowerVarDecl's rule at module scope; the init body assigns
1940
2120
  // it).
1941
2121
  const handleT = ts.isIdentifier(decl.name) && nameNode === decl.name
1942
- ? (isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
1943
- (lowerer.dynamic ? importCallHandleType(decl.initializer) : staticImportNamespaceType(lowerer, decl.initializer)) ??
1944
- (lowerer.dynamic ?
1945
- // An unchecked-overload call result stores the handle,
1946
- // exactly the local rule (uncheckedOverloadHandleCall).
1947
- (uncheckedOverloadHandleCall(lowerer, decl.initializer) ? JSVAL : null) : null)
2122
+ ? ((isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
2123
+ (lowerer.dynamic
2124
+ ? importCallHandleType(decl.initializer)
2125
+ : staticImportNamespaceType(lowerer, decl.initializer)) ??
2126
+ (lowerer.dynamic
2127
+ ? // An unchecked-overload call result stores the handle,
2128
+ // exactly the local rule (uncheckedOverloadHandleCall).
2129
+ uncheckedOverloadHandleCall(lowerer, decl.initializer)
2130
+ ? JSVAL
2131
+ : null
2132
+ : null))
1948
2133
  : null;
1949
2134
  // JavaScript factory results with unmappable annotations still
1950
2135
  // need shared storage. Unannotated callable unions also use a
1951
2136
  // checked slot; mappable authored annotations keep their layout.
1952
2137
  const unannotatedCall = !decl.type && !hasJsTypeAnnotation(decl);
1953
- const callSignature = (isJsSourceFile(sf) || unannotatedCall) && decl.initializer && ts.isCallExpression(decl.initializer)
1954
- ? lowerer.checker.getResolvedSignature(decl.initializer) : undefined;
2138
+ const callSignature = (isJsSourceFile(sf) || unannotatedCall) &&
2139
+ decl.initializer &&
2140
+ ts.isCallExpression(decl.initializer)
2141
+ ? lowerer.checker.getResolvedSignature(decl.initializer)
2142
+ : undefined;
1955
2143
  const callDeclaration = callSignature && lowerer.checker.signatureDeclaration(callSignature);
1956
2144
  const callType = callDeclaration && isJsSourceFile(callDeclaration.getSourceFile())
1957
- ? lowerer.mapTypeOf(lowerer.typeOf(nameNode)) : null;
1958
- const inferredJsCall = callDeclaration && isJsSourceFile(callDeclaration.getSourceFile()) &&
1959
- (!callType || unannotatedCall && callType.kind === "union" && lowerer.unions.get(callType.unionId)?.arms.some((arm) => arm.kind === "func"));
1960
- if (!factoryType && !inferredJsCall && isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)))
2145
+ ? lowerer.mapTypeOf(lowerer.typeOf(nameNode))
2146
+ : null;
2147
+ const inferredJsCall = callDeclaration &&
2148
+ isJsSourceFile(callDeclaration.getSourceFile()) &&
2149
+ (!callType ||
2150
+ (unannotatedCall &&
2151
+ callType.kind === "union" &&
2152
+ lowerer.unions.get(callType.unionId)?.arms.some((arm) => arm.kind === "func")));
2153
+ if (!factoryType &&
2154
+ !inferredJsCall &&
2155
+ isJsSourceFile(sf) &&
2156
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)))
1961
2157
  continue;
1962
2158
  let type = handleT ?? factoryType ?? (inferredJsCall ? DYN : lowerer.irTypeOf(nameNode));
1963
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && decl.initializer &&
2159
+ if (isJsSourceFile(sf) &&
2160
+ !decl.type &&
2161
+ !hasJsTypeAnnotation(decl) &&
2162
+ decl.initializer &&
1964
2163
  (ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer)) &&
1965
2164
  !decl.initializer.typeParameters?.length) {
1966
2165
  type = lowerer.lambdaSignature(decl.initializer).funcType;
@@ -1968,8 +2167,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1968
2167
  // Namespace aliases of inferred helpers carry the helper's
1969
2168
  // settled callable, whose return can differ from checker inference.
1970
2169
  // Keep a shared checked slot before any consumer specializes it.
1971
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "func" &&
1972
- decl.initializer && ts.isPropertyAccessExpression(decl.initializer)) {
2170
+ if (isJsSourceFile(sf) &&
2171
+ !decl.type &&
2172
+ !hasJsTypeAnnotation(decl) &&
2173
+ type.kind === "func" &&
2174
+ decl.initializer &&
2175
+ ts.isPropertyAccessExpression(decl.initializer)) {
1973
2176
  const member = nsMemberIdentOf(lowerer, decl.initializer);
1974
2177
  if (member && lowerer.genericFnOf(member)?.implicitParams)
1975
2178
  type = DYN;
@@ -1979,24 +2182,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
1979
2182
  type = source.type;
1980
2183
  }
1981
2184
  }
1982
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
1983
- decl.initializer && ts.isCallExpression(decl.initializer) && type.kind === "union") {
2185
+ if (isJsSourceFile(sf) &&
2186
+ !decl.type &&
2187
+ !hasJsTypeAnnotation(decl) &&
2188
+ decl.initializer &&
2189
+ ts.isCallExpression(decl.initializer) &&
2190
+ type.kind === "union") {
1984
2191
  const arms = lowerer.unions.get(type.unionId)?.arms;
1985
- if (arms?.some((arm) => arm.kind === "record") && arms.every((arm) => isUnitType(arm) || arm.kind === "record"))
2192
+ if (arms?.some((arm) => arm.kind === "record") &&
2193
+ arms.every((arm) => isUnitType(arm) || arm.kind === "record"))
1986
2194
  type = DYN;
1987
2195
  }
1988
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && decl.initializer &&
1989
- ts.isNewExpression(decl.initializer) && lowerer.mapTypeOf(lowerer.typeOf(decl.initializer.expression))?.kind === "dyn" &&
1990
- !(ts.isIdentifier(decl.initializer.expression) && lowerer.isStdlibSymbol(lowerer.checker.getSymbolAtLocation(decl.initializer.expression))))
2196
+ if (isJsSourceFile(sf) &&
2197
+ !decl.type &&
2198
+ !hasJsTypeAnnotation(decl) &&
2199
+ decl.initializer &&
2200
+ ts.isNewExpression(decl.initializer) &&
2201
+ lowerer.mapTypeOf(lowerer.typeOf(decl.initializer.expression))?.kind === "dyn" &&
2202
+ !(ts.isIdentifier(decl.initializer.expression) &&
2203
+ lowerer.isStdlibSymbol(lowerer.checker.getSymbolAtLocation(decl.initializer.expression))))
1991
2204
  type = DYN;
1992
2205
  // Calls through checked function values retain their object
1993
2206
  // identity, including symbol keys absent from inferred records.
1994
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "record" &&
1995
- decl.initializer && ts.isCallExpression(decl.initializer) && lowerer.dynConvertible(type)) {
2207
+ if (isJsSourceFile(sf) &&
2208
+ !decl.type &&
2209
+ !hasJsTypeAnnotation(decl) &&
2210
+ type.kind === "record" &&
2211
+ decl.initializer &&
2212
+ ts.isCallExpression(decl.initializer) &&
2213
+ lowerer.dynConvertible(type)) {
1996
2214
  type = DYN;
1997
2215
  }
1998
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "record" &&
1999
- decl.initializer && ts.isCallExpression(decl.initializer) &&
2216
+ if (isJsSourceFile(sf) &&
2217
+ !decl.type &&
2218
+ !hasJsTypeAnnotation(decl) &&
2219
+ type.kind === "record" &&
2220
+ decl.initializer &&
2221
+ ts.isCallExpression(decl.initializer) &&
2000
2222
  ts.isPropertyAccessExpression(decl.initializer.expression) &&
2001
2223
  lowerer.stdlibGlobalMember(decl.initializer.expression, "Object") === "assign" &&
2002
2224
  decl.initializer.arguments.some((arg) => ts.isIdentifier(arg) && lowerer.globalOf(arg)?.type.kind === "dyn")) {
@@ -2005,24 +2227,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
2005
2227
  // Runtime-arity JavaScript callables can be returned by a
2006
2228
  // checked factory. Keep that callable boxed instead of asking
2007
2229
  // a fixed-signature adapter to reconstruct its hidden rest ABI.
2008
- if (!decl.type && !hasJsTypeAnnotation(decl) && type.kind === "func" && type.rest === true && type.restAbi === undefined)
2230
+ if (!decl.type &&
2231
+ !hasJsTypeAnnotation(decl) &&
2232
+ type.kind === "func" &&
2233
+ type.rest === true &&
2234
+ type.restAbi === undefined)
2009
2235
  type = DYN;
2010
- if (isJsSourceFile(sf) && isLet && !decl.type && !hasJsTypeAnnotation(decl) &&
2236
+ if (isJsSourceFile(sf) &&
2237
+ isLet &&
2238
+ !decl.type &&
2239
+ !hasJsTypeAnnotation(decl) &&
2011
2240
  (type.kind === "object" || jsBindingHasOpenWrites(lowerer, decl)))
2012
2241
  type = DYN;
2013
2242
  // JavaScript call results may retain a checked array supplied by
2014
2243
  // the caller. A typed global here would copy it on extraction.
2015
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "array" &&
2016
- decl.initializer && ts.isCallExpression(decl.initializer))
2244
+ if (isJsSourceFile(sf) &&
2245
+ !decl.type &&
2246
+ !hasJsTypeAnnotation(decl) &&
2247
+ type.kind === "array" &&
2248
+ decl.initializer &&
2249
+ ts.isCallExpression(decl.initializer))
2017
2250
  type = DYN;
2018
- if (!lowerer.dynamic && isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
2019
- decl.initializer && ts.isNewExpression(decl.initializer) && lowerer.isStdlibGlobal(decl.initializer.expression, "Array") &&
2251
+ if (!lowerer.dynamic &&
2252
+ isJsSourceFile(sf) &&
2253
+ !decl.type &&
2254
+ !hasJsTypeAnnotation(decl) &&
2255
+ decl.initializer &&
2256
+ ts.isNewExpression(decl.initializer) &&
2257
+ lowerer.isStdlibGlobal(decl.initializer.expression, "Array") &&
2020
2258
  (type.kind !== "array" || type.elem.kind === "dyn"))
2021
2259
  type = DYN;
2022
2260
  // Unannotated JavaScript aliases retain an existing native
2023
2261
  // checked object instead of copying it into an inferred record.
2024
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
2025
- decl.initializer && ts.isIdentifier(decl.initializer) &&
2262
+ if (isJsSourceFile(sf) &&
2263
+ !decl.type &&
2264
+ !hasJsTypeAnnotation(decl) &&
2265
+ decl.initializer &&
2266
+ ts.isIdentifier(decl.initializer) &&
2026
2267
  (type.kind === "record" || type.kind === "func")) {
2027
2268
  const source = lowerer.globalOf(decl.initializer);
2028
2269
  if (source?.type.kind === "dyn")
@@ -2030,10 +2271,15 @@ export function collectGlobals(lowerer, sf, topStmts) {
2030
2271
  }
2031
2272
  // JavaScript bind inference can leave an artificial tuple-rest
2032
2273
  // signature. Keep the returned callable's runtime arity intact.
2033
- if (isJsSourceFile(sf) && type.kind === "func" && decl.initializer &&
2034
- ts.isCallExpression(decl.initializer) && ts.isPropertyAccessExpression(decl.initializer.expression) &&
2035
- decl.initializer.expression.name.text === "bind" && lowerer.isStdlibMember(decl.initializer.expression) &&
2036
- decl.type === undefined && !hasJsTypeAnnotation(decl)) {
2274
+ if (isJsSourceFile(sf) &&
2275
+ type.kind === "func" &&
2276
+ decl.initializer &&
2277
+ ts.isCallExpression(decl.initializer) &&
2278
+ ts.isPropertyAccessExpression(decl.initializer.expression) &&
2279
+ decl.initializer.expression.name.text === "bind" &&
2280
+ lowerer.isStdlibMember(decl.initializer.expression) &&
2281
+ decl.type === undefined &&
2282
+ !hasJsTypeAnnotation(decl)) {
2037
2283
  type = DYN;
2038
2284
  }
2039
2285
  // An evolving-`any` array's DERIVED file-scope binding under
@@ -2046,18 +2292,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
2046
2292
  // element array (lowerVarDecl's adoption, the file-scope
2047
2293
  // face). Annotated declarations keep the validated-boundary
2048
2294
  // fence.
2049
- if (lowerer.dynamic && ts.isIdentifier(decl.name) && nameNode === decl.name &&
2050
- decl.type === undefined && decl.initializer !== undefined &&
2051
- type.kind === "array" && type.elem.kind !== "jsval" &&
2295
+ if (lowerer.dynamic &&
2296
+ ts.isIdentifier(decl.name) &&
2297
+ nameNode === decl.name &&
2298
+ decl.type === undefined &&
2299
+ decl.initializer !== undefined &&
2300
+ type.kind === "array" &&
2301
+ type.elem.kind !== "jsval" &&
2052
2302
  handleArrayPreservingCall(lowerer, decl.initializer)) {
2053
2303
  type = arrayOf(JSVAL);
2054
2304
  }
2055
- // `const r: Repo = new MemRepo()` over an all-generic-method
2056
- // interface: the binding keeps the initializer's CLASS
2057
- // representation (the record shape maps empty and the width
2058
- // copy would drop the class the generic-method calls
2059
- // monomorphize against) — see genericIfaceBindingKeepsClass.
2060
- if (type.kind === "record" && ts.isIdentifier(decl.name) && nameNode === decl.name &&
2305
+ // An exact class behind a generic interface keeps its native
2306
+ // representation so generic calls can specialize against its body.
2307
+ if ((type.kind === "record" || type.kind === "dyn") &&
2308
+ ts.isIdentifier(decl.name) &&
2309
+ nameNode === decl.name &&
2061
2310
  genericIfaceBindingKeepsClass(lowerer, decl, type)) {
2062
2311
  const initT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
2063
2312
  if (initT?.kind === "object")
@@ -2073,8 +2322,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
2073
2322
  if (lowerer.dynamic && !ts.isIdentifier(decl.name) && decl.initializer !== undefined) {
2074
2323
  const srcT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
2075
2324
  const island = srcT !== null &&
2076
- (srcT.kind === "jsval" || srcT.kind === "f64" || srcT.kind === "bool" ||
2077
- srcT.kind === "string" || isUnitType(srcT));
2325
+ (srcT.kind === "jsval" ||
2326
+ srcT.kind === "f64" ||
2327
+ srcT.kind === "bool" ||
2328
+ srcT.kind === "string" ||
2329
+ isUnitType(srcT));
2078
2330
  if (island && type.kind !== "f64" && type.kind !== "bool" && type.kind !== "string") {
2079
2331
  type = JSVAL;
2080
2332
  }
@@ -2096,7 +2348,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
2096
2348
  // adapter would re-copy at the assignment.
2097
2349
  if (isJsSourceFile(sf) &&
2098
2350
  type.kind === "func" &&
2099
- (type.ret.kind === "date" || type.ret.kind === "record" && lowerer.dynConvertible(type.ret)) &&
2351
+ (type.ret.kind === "date" ||
2352
+ (type.ret.kind === "record" && lowerer.dynConvertible(type.ret))) &&
2100
2353
  decl.initializer !== undefined &&
2101
2354
  (ts.isFunctionExpression(decl.initializer) || ts.isArrowFunction(decl.initializer)) &&
2102
2355
  decl.initializer.type === undefined &&
@@ -2115,13 +2368,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
2115
2368
  // Module vars hold real undefined until their declaration runs.
2116
2369
  // Unannotated JS function values need that state too: callers
2117
2370
  // before the initializer must see undefined and a TypeError.
2118
- if (isJsSourceFile(sf) && isVarDeclared(decl) && type.kind === "func" && lowerer.dynConvertible(type))
2371
+ if (isJsSourceFile(sf) &&
2372
+ isVarDeclared(decl) &&
2373
+ type.kind === "func" &&
2374
+ lowerer.dynConvertible(type))
2119
2375
  type = DYN;
2120
2376
  // Codec records keep that state in the ordinary optional union;
2121
2377
  // lexical codec declarations retain their separate TDZ guard.
2122
- const codec = type.kind === "record" && recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null;
2378
+ const codec = type.kind === "record" &&
2379
+ recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null;
2123
2380
  if (codec && isVarDeclared(decl)) {
2124
- type = { kind: "union", unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]) };
2381
+ type = {
2382
+ kind: "union",
2383
+ unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
2384
+ };
2125
2385
  }
2126
2386
  else if (codec && !decl.initializer) {
2127
2387
  lowerer.noLowering("uninitialized lexical codec bindings", decl, "initialize let or const TextEncoder/TextDecoder bindings at their declaration");
@@ -2141,7 +2401,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
2141
2401
  // A function pointer must not be dereferenced before a lexical
2142
2402
  // declaration assigns it. The shared pointer TDZ guard handles
2143
2403
  // these bindings like stored codec records.
2144
- ...(((codec || type.kind === "func") && !isVarDeclared(decl)) ? { tdz: true } : {}),
2404
+ ...((codec || type.kind === "func") && !isVarDeclared(decl)
2405
+ ? { tdz: true }
2406
+ : {}),
2145
2407
  };
2146
2408
  lowerer.globalsBySymbol.set(symbol, g);
2147
2409
  lowerer.globalsList.push(g);
@@ -2167,19 +2429,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
2167
2429
  }
2168
2430
  }
2169
2431
  /** True iff this initializer's VALUE is a jsval-element array from a
2170
- * module global already registered as one (the evolving-`any` binding
2171
- * under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
2172
- * array-method call chain over it (filter/slice/splice/concat — each
2173
- * answers the receiver's own array type). Registration runs in source
2174
- * order, so the root's global — declared above, TDZ-guaranteed — is
2175
- * already in the table. */
2432
+ * module global already registered as one (the evolving-`any` binding
2433
+ * under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
2434
+ * array-method call chain over it (filter/slice/splice/concat — each
2435
+ * answers the receiver's own array type). Registration runs in source
2436
+ * order, so the root's global — declared above, TDZ-guaranteed — is
2437
+ * already in the table. */
2176
2438
  function handleArrayPreservingCall(lowerer, e) {
2177
2439
  const PRESERVING = new Set(["filter", "slice", "splice", "concat"]);
2178
2440
  let cur = e;
2179
2441
  for (;;) {
2180
2442
  while (ts.isParenthesizedExpression(cur))
2181
2443
  cur = cur.expression;
2182
- if (ts.isCallExpression(cur) && ts.isPropertyAccessExpression(cur.expression) &&
2444
+ if (ts.isCallExpression(cur) &&
2445
+ ts.isPropertyAccessExpression(cur.expression) &&
2183
2446
  PRESERVING.has(cur.expression.name.text)) {
2184
2447
  cur = cur.expression.expression;
2185
2448
  continue;
@@ -2193,14 +2456,14 @@ function handleArrayPreservingCall(lowerer, e) {
2193
2456
  return g?.type.kind === "array" && g.type.elem.kind === "jsval";
2194
2457
  }
2195
2458
  /** Registers the entry-init note for a `var` module global: JS hoists
2196
- * module vars to `undefined` at module entry, so an undefined-armed slot
2197
- * must hold the interned undefined arm BEFORE the body runs (a function
2198
- * called above the declaration statement may read it — lowerFileInit
2199
- * emits the assigns right after the run-once guard). Checked-dynamic
2200
- * slots hold the dyn undefined the same way (a NULL dyn is a trap, not
2201
- * a value). Other types need nothing: tsc's flow analysis rejects their
2202
- * direct early reads, and closure reads share let's documented
2203
- * zero/NULL divergence window. */
2459
+ * module vars to `undefined` at module entry, so an undefined-armed slot
2460
+ * must hold the interned undefined arm BEFORE the body runs (a function
2461
+ * called above the declaration statement may read it — lowerFileInit
2462
+ * emits the assigns right after the run-once guard). Checked-dynamic
2463
+ * slots hold the dyn undefined the same way (a NULL dyn is a trap, not
2464
+ * a value). Other types need nothing: tsc's flow analysis rejects their
2465
+ * direct early reads, and closure reads share let's documented
2466
+ * zero/NULL divergence window. */
2204
2467
  function noteVarGlobalEntryInit(lowerer, sf, g) {
2205
2468
  // 'any' globals need the entry init exactly like undefined-armed
2206
2469
  // unions: tsc never guards `any` reads, so `var x: any;` is readable
@@ -2215,25 +2478,31 @@ function noteVarGlobalEntryInit(lowerer, sf, g) {
2215
2478
  lowerer.varGlobalEntryInits.set(sf, inits);
2216
2479
  }
2217
2480
  /** The nested half of module-scope `var` hoisting: a `var` inside a
2218
- * top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
2219
- * JS — other functions in the file read the same binding — so it must
2220
- * be a module global like its top-level siblings. Walks a top-level
2221
- * statement's insides for var-flagged declaration lists (statement and
2222
- * for/for-in/for-of initializer positions), never descending into
2223
- * function-likes, classes, or static blocks (each hoists to its own
2224
- * scope). Registration mirrors the main path's identifier story:
2225
- * JS-unmappable types register nothing (per-site fences own the
2226
- * references), everything else gets a mutable global. */
2481
+ * top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
2482
+ * JS — other functions in the file read the same binding — so it must
2483
+ * be a module global like its top-level siblings. Walks a top-level
2484
+ * statement's insides for var-flagged declaration lists (statement and
2485
+ * for/for-in/for-of initializer positions), never descending into
2486
+ * function-likes, classes, or static blocks (each hoists to its own
2487
+ * scope). Registration mirrors the main path's identifier story:
2488
+ * JS-unmappable types register nothing (per-site fences own the
2489
+ * references), everything else gets a mutable global. */
2227
2490
  function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
2228
2491
  const lists = [];
2229
2492
  // Iterative walk (walkPreorder): this sweep sees every non-var top-level
2230
2493
  // statement whole — the binderBinaryExpressionStress bare ~6500-term
2231
2494
  // chain sat within ~50 terms of overflowing the recursive form.
2232
2495
  ts.walkPreorder(stmt, (node) => {
2233
- if (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) ||
2234
- ts.isMethodDeclaration(node) || ts.isConstructorDeclaration(node) ||
2235
- ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node) ||
2236
- ts.isClassStaticBlockDeclaration(node) || ts.isClassDeclaration(node) || ts.isClassExpression(node) ||
2496
+ if (ts.isFunctionDeclaration(node) ||
2497
+ ts.isFunctionExpression(node) ||
2498
+ ts.isArrowFunction(node) ||
2499
+ ts.isMethodDeclaration(node) ||
2500
+ ts.isConstructorDeclaration(node) ||
2501
+ ts.isGetAccessorDeclaration(node) ||
2502
+ ts.isSetAccessorDeclaration(node) ||
2503
+ ts.isClassStaticBlockDeclaration(node) ||
2504
+ ts.isClassDeclaration(node) ||
2505
+ ts.isClassExpression(node) ||
2237
2506
  ts.isModuleDeclaration(node)) {
2238
2507
  return "skip";
2239
2508
  }
@@ -2263,13 +2532,23 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
2263
2532
  if (shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple)
2264
2533
  type = DYN;
2265
2534
  }
2266
- if (type.kind === "record" && recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null) {
2267
- type = { kind: "union", unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]) };
2535
+ if (type.kind === "record" &&
2536
+ recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null) {
2537
+ type = {
2538
+ kind: "union",
2539
+ unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
2540
+ };
2268
2541
  }
2269
2542
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
2270
2543
  if (!symbol || lowerer.globalsBySymbol.has(symbol))
2271
2544
  continue;
2272
- const g = { id: `%g.${tag}${nameNode.text}`, name: nameNode.text, type, mutable: true, source: bindingSource(nameNode) };
2545
+ const g = {
2546
+ id: `%g.${tag}${nameNode.text}`,
2547
+ name: nameNode.text,
2548
+ type,
2549
+ mutable: true,
2550
+ source: bindingSource(nameNode),
2551
+ };
2273
2552
  lowerer.globalsBySymbol.set(symbol, g);
2274
2553
  lowerer.globalsList.push(g);
2275
2554
  noteVarGlobalEntryInit(lowerer, sf, g);
@@ -2284,21 +2563,21 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
2284
2563
  }
2285
2564
  }
2286
2565
  /** The checker's symbol for a module's default export — the symbol a
2287
- * default import of this module aliases to (getAliasedSymbol), so keying
2288
- * the default's global by it makes every importer resolve to the same
2289
- * storage through the ordinary globalOf path. Null for modules without
2290
- * a default export (or non-module files). */
2566
+ * default import of this module aliases to (getAliasedSymbol), so keying
2567
+ * the default's global by it makes every importer resolve to the same
2568
+ * storage through the ordinary globalOf path. Null for modules without
2569
+ * a default export (or non-module files). */
2291
2570
  export function defaultExportSymbolOf(lowerer, sf) {
2292
2571
  const moduleSym = lowerer.checker.getSymbolAtLocation(sf);
2293
2572
  return moduleSym?.getExports().get(ts.InternalSymbolName.Default) ?? null;
2294
2573
  }
2295
2574
  /** The declaration symbol of a top-level function/class declaration,
2296
- * covering the one legal NAMELESS form: `export default function () {}` /
2297
- * `export default class {}`. A named declaration answers through its
2298
- * name node; the anonymous default IS the module's `default` export
2299
- * symbol (the binder declares it there), so collection, reachability,
2300
- * and body lowering all key that one identity — which is also what a
2301
- * default import's alias chain resolves to. */
2575
+ * covering the one legal NAMELESS form: `export default function () {}` /
2576
+ * `export default class {}`. A named declaration answers through its
2577
+ * name node; the anonymous default IS the module's `default` export
2578
+ * symbol (the binder declares it there), so collection, reachability,
2579
+ * and body lowering all key that one identity — which is also what a
2580
+ * default import's alias chain resolves to. */
2302
2581
  export function declSymbolOf(lowerer, decl) {
2303
2582
  if (decl.name)
2304
2583
  return lowerer.checker.getSymbolAtLocation(decl.name);
@@ -2310,18 +2589,18 @@ export function declSymbolOf(lowerer, decl) {
2310
2589
  return sym ?? undefined;
2311
2590
  }
2312
2591
  /** `export default <expr>` in a module's init body: the first (and only)
2313
- * assignment of the pre-registered `default` global — evaluated at the
2314
- * statement's source position, exactly where Node runs it (Node's
2315
- * expression defaults snapshot exactly once, here). ENTITY-NAME defaults
2316
- * of immutable targets are alias plumbing with no storage of their own:
2317
- * the statement lowers to nothing — importers' alias-resolved reads
2318
- * equal the snapshot. MUTABLE entity-name defaults registered snapshot
2319
- * storage in collection and assign it here like any expression default
2320
- * (the identifier read takes the let's value at this statement's
2321
- * position — Node's snapshot). A NON-alias default whose type had no
2322
- * registration (collection reported the blocker) re-lowers the
2323
- * expression so the expression's OWN diagnostic wins when it has one,
2324
- * then poisons. */
2592
+ * assignment of the pre-registered `default` global — evaluated at the
2593
+ * statement's source position, exactly where Node runs it (Node's
2594
+ * expression defaults snapshot exactly once, here). ENTITY-NAME defaults
2595
+ * of immutable targets are alias plumbing with no storage of their own:
2596
+ * the statement lowers to nothing — importers' alias-resolved reads
2597
+ * equal the snapshot. MUTABLE entity-name defaults registered snapshot
2598
+ * storage in collection and assign it here like any expression default
2599
+ * (the identifier read takes the let's value at this statement's
2600
+ * position — Node's snapshot). A NON-alias default whose type had no
2601
+ * registration (collection reported the blocker) re-lowers the
2602
+ * expression so the expression's OWN diagnostic wins when it has one,
2603
+ * then poisons. */
2325
2604
  export function lowerDefaultExport(lowerer, stmt) {
2326
2605
  const symbol = defaultExportSymbolOf(lowerer, stmt.getSourceFile());
2327
2606
  if (symbol && symbol.flags & ts.SymbolFlags.Alias && !lowerer.globalsBySymbol.has(symbol))
@@ -2335,9 +2614,11 @@ export function lowerDefaultExport(lowerer, stmt) {
2335
2614
  let inner = stmt.expression;
2336
2615
  while (ts.isParenthesizedExpression(inner))
2337
2616
  inner = inner.expression;
2338
- if (ts.isClassExpression(inner) && !isJsSourceFile(stmt.getSourceFile()) &&
2617
+ if (ts.isClassExpression(inner) &&
2618
+ !isJsSourceFile(stmt.getSourceFile()) &&
2339
2619
  inner.typeParameters === undefined &&
2340
- (decoratorNodesOf(inner).length > 0 || inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
2620
+ (decoratorNodesOf(inner).length > 0 ||
2621
+ inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
2341
2622
  guaranteedDecorationThrow(lowerer, inner) !== null) {
2342
2623
  return { kind: "exprStmt", expr: lowerer.lowerExpr(stmt.expression), loc: locOf(stmt) };
2343
2624
  }
@@ -2349,19 +2630,19 @@ export function lowerDefaultExport(lowerer, stmt) {
2349
2630
  return { kind: "assign", localId: g.id, value, loc: locOf(stmt) };
2350
2631
  }
2351
2632
  /** One file's top-level statements as its init function — RUN-ONCE like a
2352
- * Node module body: non-entry inits open with a guard flag test (already
2353
- * ran → return) and set the flag before anything else, so every caller —
2354
- * hoisted import headers, inline require statements, diamonds, cache-hit
2355
- * re-requires — gets Node's module-cache semantics from the same call.
2356
- * After the guard comes the file's HOISTED module-edge header: one
2357
- * guarded %init call per imported user module and the island loads for
2358
- * npm imports, in import order (Node evaluates every imported module
2359
- * before the importer's body — depth-first postorder falls out of the
2360
- * nesting). CommonJS requires are NOT in the header: Node runs them at
2361
- * their statements, so the statement lowering emits their %init calls
2362
- * inline in the body. JSON-import bindings (pure data) load next; then
2363
- * the body. Top-level var statements assign the pre-registered globals
2364
- * instead of declaring locals. */
2633
+ * Node module body: non-entry inits open with a guard flag test (already
2634
+ * ran → return) and set the flag before anything else, so every caller —
2635
+ * hoisted import headers, inline require statements, diamonds, cache-hit
2636
+ * re-requires — gets Node's module-cache semantics from the same call.
2637
+ * After the guard comes the file's HOISTED module-edge header: one
2638
+ * guarded %init call per imported user module and the island loads for
2639
+ * npm imports, in import order (Node evaluates every imported module
2640
+ * before the importer's body — depth-first postorder falls out of the
2641
+ * nesting). CommonJS requires are NOT in the header: Node runs them at
2642
+ * their statements, so the statement lowering emits their %init calls
2643
+ * inline in the body. JSON-import bindings (pure data) load next; then
2644
+ * the body. Top-level var statements assign the pre-registered globals
2645
+ * instead of declaring locals. */
2365
2646
  export function lowerFileInit(lowerer, sf, stmts, name) {
2366
2647
  const isAsync = lowerer.asyncInitFiles.has(sf);
2367
2648
  const ctx = newFnCtx(false, null, null, VOID);
@@ -2519,8 +2800,16 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
2519
2800
  // that evaluates them. MIXIN instantiations join by their CALL
2520
2801
  // SITE's position instead (below) — their inner class node may
2521
2802
  // even live in another file.
2522
- c.decl && ts.isClassDeclaration(c.decl) && !c.mixinInstance && c.decl.getSourceFile() === sf &&
2523
- (c.callableBase !== undefined || c.def.baseValueGlobal !== undefined || c.runtimeStatics !== undefined || c.staticFields.length > 0 || (c.staticBlocks?.length ?? 0) > 0 || c.classDecorators !== undefined))
2803
+ c.decl &&
2804
+ ts.isClassDeclaration(c.decl) &&
2805
+ !c.mixinInstance &&
2806
+ c.decl.getSourceFile() === sf &&
2807
+ (c.callableBase !== undefined ||
2808
+ c.def.baseValueGlobal !== undefined ||
2809
+ c.runtimeStatics !== undefined ||
2810
+ c.staticFields.length > 0 ||
2811
+ (c.staticBlocks?.length ?? 0) > 0 ||
2812
+ c.classDecorators !== undefined))
2524
2813
  .map((c) => ({ pos: c.decl.getStart(), info: c }));
2525
2814
  // Statics-bearing MIXIN instantiations whose call evaluates in THIS
2526
2815
  // file: their declaration-time code runs when the call does — the
@@ -2581,12 +2870,14 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
2581
2870
  loc: loc0,
2582
2871
  },
2583
2872
  ...(guardId !== undefined
2584
- ? [{
2873
+ ? [
2874
+ {
2585
2875
  kind: "assign",
2586
2876
  localId: guardId,
2587
2877
  value: { kind: "boolLit", value: false, type: BOOL, loc: loc0 },
2588
2878
  loc: loc0,
2589
- }]
2879
+ },
2880
+ ]
2590
2881
  : []),
2591
2882
  { kind: "rethrow", localId: catchLocal.id, loc: loc0 },
2592
2883
  ],
@@ -2615,15 +2906,15 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
2615
2906
  }
2616
2907
  }
2617
2908
  /** %main is just the entry's %init call: Node's whole module evaluation
2618
- * order lives in the init functions themselves — each file's hoisted
2619
- * import header runs its dependencies first (depth-first postorder by
2620
- * nesting), CommonJS require statements call dependency inits inline in
2621
- * their bodies, and the run-once guards turn every revisit (diamonds,
2622
- * re-imports, re-requires) into a cache hit. */
2909
+ * order lives in the init functions themselves — each file's hoisted
2910
+ * import header runs its dependencies first (depth-first postorder by
2911
+ * nesting), CommonJS require statements call dependency inits inline in
2912
+ * their bodies, and the run-once guards turn every revisit (diamonds,
2913
+ * re-imports, re-requires) into a cache hit. */
2623
2914
  export function buildMain(lowerer) {
2624
2915
  const loc = { file: lowerer.entry.fileName, start: 0, end: 0 };
2625
2916
  const body = [...cjsModuleRegistryPrelude(lowerer, loc)];
2626
- const roots = [lowerer.entry, ...lowerer.forkTargets];
2917
+ const roots = [lowerer.entry, ...lowerer.forkTargets, ...lowerer.workerTargets];
2627
2918
  const isAsync = roots.some((root) => lowerer.asyncInitFiles.has(root));
2628
2919
  const callRoot = (root) => {
2629
2920
  const init = lowerer.initNameOf.get(root);
@@ -2637,11 +2928,13 @@ export function buildMain(lowerer) {
2637
2928
  type: rootAsync ? { kind: "promise", inner: VOID } : VOID,
2638
2929
  loc,
2639
2930
  };
2640
- return [{
2931
+ return [
2932
+ {
2641
2933
  kind: "exprStmt",
2642
2934
  expr: rootAsync ? { kind: "awaitExpr", value: call, type: VOID, loc } : call,
2643
2935
  loc,
2644
- }];
2936
+ },
2937
+ ];
2645
2938
  };
2646
2939
  const locals = [];
2647
2940
  if (lowerer.forkTargets.length === 0) {
@@ -2665,7 +2958,8 @@ export function buildMain(lowerer) {
2665
2958
  const selector = () => ({ kind: "varRef", localId: targetId, type: F64, loc });
2666
2959
  let workerBranch = null;
2667
2960
  for (let id = lowerer.forkTargets.length - 1; id >= 0; id--) {
2668
- workerBranch = [{
2961
+ workerBranch = [
2962
+ {
2669
2963
  kind: "if",
2670
2964
  cond: {
2671
2965
  kind: "bin",
@@ -2678,7 +2972,8 @@ export function buildMain(lowerer) {
2678
2972
  then: callRoot(lowerer.forkTargets[id]),
2679
2973
  else_: workerBranch,
2680
2974
  loc,
2681
- }];
2975
+ },
2976
+ ];
2682
2977
  }
2683
2978
  body.push({
2684
2979
  kind: "if",
@@ -2695,6 +2990,35 @@ export function buildMain(lowerer) {
2695
2990
  loc,
2696
2991
  });
2697
2992
  }
2993
+ if (lowerer.workerTargets.length > 0) {
2994
+ const mainBody = body.splice(0);
2995
+ let workerBody = null;
2996
+ for (let id = lowerer.workerTargets.length - 1; id >= 0; id--) {
2997
+ workerBody = [
2998
+ {
2999
+ kind: "if",
3000
+ cond: {
3001
+ kind: "bin",
3002
+ op: "===",
3003
+ left: { kind: "libCall", fn: "worker.root", args: [], type: F64, loc },
3004
+ right: { kind: "numLit", value: id, type: F64, loc },
3005
+ type: BOOL,
3006
+ loc,
3007
+ },
3008
+ then: callRoot(lowerer.workerTargets[id]),
3009
+ else_: workerBody,
3010
+ loc,
3011
+ },
3012
+ ];
3013
+ }
3014
+ body.push({
3015
+ kind: "if",
3016
+ cond: { kind: "libCall", fn: "worker.isMainThread", args: [], type: BOOL, loc },
3017
+ then: mainBody,
3018
+ else_: [...cjsModuleRegistryPrelude(lowerer, loc), ...(workerBody ?? [])],
3019
+ loc,
3020
+ });
3021
+ }
2698
3022
  // Node's startup refusal (a resolution the graph carries that Node
2699
3023
  // rejects — preflight's Node-order resolution walk — or a module-LINK
2700
3024
  // SyntaxError from either named-import checker): the graph is refused
@@ -2710,7 +3034,9 @@ export function buildMain(lowerer) {
2710
3034
  value: {
2711
3035
  kind: "libCall",
2712
3036
  fn: "error.new",
2713
- args: [{ kind: "strLit", value: lowerer.startupCrash.message, type: STRING, loc: crashLoc }],
3037
+ args: [
3038
+ { kind: "strLit", value: lowerer.startupCrash.message, type: STRING, loc: crashLoc },
3039
+ ],
2714
3040
  type: { kind: "object", className: lowerer.startupCrash.className },
2715
3041
  loc: crashLoc,
2716
3042
  },