@scriptc/compiler 0.4.0 → 0.4.2

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 (866) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +617 -83
  2. package/dist/backend/cycle-analysis.d.ts +2 -1
  3. package/dist/backend/cycle-analysis.js +4 -4
  4. package/dist/backend/cycle-analysis.js.map +1 -1
  5. package/dist/backend/cycle-mutability.d.ts +2 -1
  6. package/dist/backend/cycle-mutability.js +2 -2
  7. package/dist/backend/cycle-mutability.js.map +1 -1
  8. package/dist/backend/executable-features.js +10 -0
  9. package/dist/backend/executable-features.js.map +1 -1
  10. package/dist/backend/immutability.d.ts +2 -1
  11. package/dist/backend/immutability.js +2 -2
  12. package/dist/backend/immutability.js.map +1 -1
  13. package/dist/backend/library-pack.js +7 -0
  14. package/dist/backend/library-pack.js.map +1 -1
  15. package/dist/backend/link-plan-core.d.ts +2 -0
  16. package/dist/backend/link-plan-core.js +2 -0
  17. package/dist/backend/link-plan-core.js.map +1 -1
  18. package/dist/backend/link-plan.d.ts +1 -0
  19. package/dist/backend/link-plan.js +1 -0
  20. package/dist/backend/link-plan.js.map +1 -1
  21. package/dist/backend/llvm/alloc.d.ts +7 -3
  22. package/dist/backend/llvm/alloc.js +7 -4
  23. package/dist/backend/llvm/alloc.js.map +1 -1
  24. package/dist/backend/llvm/array-search.js +4 -1
  25. package/dist/backend/llvm/array-search.js.map +1 -1
  26. package/dist/backend/llvm/bytes-loop-versions.d.ts +23 -2
  27. package/dist/backend/llvm/bytes-loop-versions.js +115 -19
  28. package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
  29. package/dist/backend/llvm/bytes-loop-versions.test.js +131 -0
  30. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  31. package/dist/backend/llvm/classes.d.ts +99 -2
  32. package/dist/backend/llvm/classes.js +436 -57
  33. package/dist/backend/llvm/classes.js.map +1 -1
  34. package/dist/backend/llvm/classes.test.js +235 -16
  35. package/dist/backend/llvm/classes.test.js.map +1 -1
  36. package/dist/backend/llvm/common.d.ts +21 -5
  37. package/dist/backend/llvm/common.js +50 -5
  38. package/dist/backend/llvm/common.js.map +1 -1
  39. package/dist/backend/llvm/constant-callbacks.js +8 -4
  40. package/dist/backend/llvm/constant-callbacks.js.map +1 -1
  41. package/dist/backend/llvm/constant-callbacks.test.js +4 -4
  42. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
  43. package/dist/backend/llvm/counted-loops.d.ts +4 -1
  44. package/dist/backend/llvm/counted-loops.js +62 -23
  45. package/dist/backend/llvm/counted-loops.js.map +1 -1
  46. package/dist/backend/llvm/dense-array-access.d.ts +3 -1
  47. package/dist/backend/llvm/dense-array-access.js +61 -38
  48. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  49. package/dist/backend/llvm/dense-array-access.test.js +4 -0
  50. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  51. package/dist/backend/llvm/dense-array-loops.d.ts +19 -16
  52. package/dist/backend/llvm/dense-array-loops.js +49 -13
  53. package/dist/backend/llvm/dense-array-loops.js.map +1 -1
  54. package/dist/backend/llvm/dense-array-loops.test.js +50 -14
  55. package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
  56. package/dist/backend/llvm/dyn.d.ts +34 -1
  57. package/dist/backend/llvm/dyn.js +393 -14
  58. package/dist/backend/llvm/dyn.js.map +1 -1
  59. package/dist/backend/llvm/emit-function.js +27 -8
  60. package/dist/backend/llvm/emit-function.js.map +1 -1
  61. package/dist/backend/llvm/emit-module.js +67 -39
  62. package/dist/backend/llvm/emit-module.js.map +1 -1
  63. package/dist/backend/llvm/emit-statements.d.ts +3 -25
  64. package/dist/backend/llvm/emit-statements.js +414 -37
  65. package/dist/backend/llvm/emit-statements.js.map +1 -1
  66. package/dist/backend/llvm/emitter.d.ts +159 -22
  67. package/dist/backend/llvm/emitter.js +573 -89
  68. package/dist/backend/llvm/emitter.js.map +1 -1
  69. package/dist/backend/llvm/expr-async.js +19 -0
  70. package/dist/backend/llvm/expr-async.js.map +1 -1
  71. package/dist/backend/llvm/expr-bytes.d.ts +5 -2
  72. package/dist/backend/llvm/expr-bytes.js +110 -40
  73. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  74. package/dist/backend/llvm/expr-calls.d.ts +1 -1
  75. package/dist/backend/llvm/expr-calls.js +51 -26
  76. package/dist/backend/llvm/expr-calls.js.map +1 -1
  77. package/dist/backend/llvm/expr-containers.js +27 -14
  78. package/dist/backend/llvm/expr-containers.js.map +1 -1
  79. package/dist/backend/llvm/expr-control.js +2 -3
  80. package/dist/backend/llvm/expr-control.js.map +1 -1
  81. package/dist/backend/llvm/expr-dynamic.js +95 -5
  82. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  83. package/dist/backend/llvm/expr-primitives.js +29 -11
  84. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  85. package/dist/backend/llvm/expr-primitives.test.js +55 -0
  86. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  87. package/dist/backend/llvm/expr-stream-bridges.js +48 -20
  88. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  89. package/dist/backend/llvm/expr-stream-callbacks.js +131 -35
  90. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  91. package/dist/backend/llvm/integer-clones.js +3 -3
  92. package/dist/backend/llvm/integer-clones.js.map +1 -1
  93. package/dist/backend/llvm/js-ic.d.ts +18 -0
  94. package/dist/backend/llvm/js-ic.js +712 -0
  95. package/dist/backend/llvm/js-ic.js.map +1 -0
  96. package/dist/backend/llvm/jsval.js +139 -11
  97. package/dist/backend/llvm/jsval.js.map +1 -1
  98. package/dist/backend/llvm/lib-dispatch.js +10 -0
  99. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  100. package/dist/backend/llvm/lib-filesystem.js +61 -0
  101. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  102. package/dist/backend/llvm/lib-http2.d.ts +4 -0
  103. package/dist/backend/llvm/lib-http2.js +20 -17
  104. package/dist/backend/llvm/lib-http2.js.map +1 -1
  105. package/dist/backend/llvm/lib-process.js +69 -17
  106. package/dist/backend/llvm/lib-process.js.map +1 -1
  107. package/dist/backend/llvm/lib-shared.js +75 -1
  108. package/dist/backend/llvm/lib-shared.js.map +1 -1
  109. package/dist/backend/llvm/lib-stream.js +65 -28
  110. package/dist/backend/llvm/lib-stream.js.map +1 -1
  111. package/dist/backend/llvm/lib-tls.js +23 -0
  112. package/dist/backend/llvm/lib-tls.js.map +1 -1
  113. package/dist/backend/llvm/local-array-reads.js +91 -61
  114. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  115. package/dist/backend/llvm/local-array-reads.test.js +14 -0
  116. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  117. package/dist/backend/llvm/map-number-lookup.d.ts +20 -4
  118. package/dist/backend/llvm/map-number-lookup.js +43 -7
  119. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  120. package/dist/backend/llvm/narrow-guards.js +64 -0
  121. package/dist/backend/llvm/narrow-guards.js.map +1 -1
  122. package/dist/backend/llvm/publish.d.ts +11 -1
  123. package/dist/backend/llvm/publish.js +80 -22
  124. package/dist/backend/llvm/publish.js.map +1 -1
  125. package/dist/backend/llvm/publish.test.js +3 -0
  126. package/dist/backend/llvm/publish.test.js.map +1 -1
  127. package/dist/backend/llvm/receivers.js +1 -1
  128. package/dist/backend/llvm/receivers.js.map +1 -1
  129. package/dist/backend/llvm/reference-writes.js +2 -0
  130. package/dist/backend/llvm/reference-writes.js.map +1 -1
  131. package/dist/backend/llvm/regex-matchers.js +161 -14
  132. package/dist/backend/llvm/regex-matchers.js.map +1 -1
  133. package/dist/backend/llvm/regex-matchers.test.js +18 -0
  134. package/dist/backend/llvm/regex-matchers.test.js.map +1 -1
  135. package/dist/backend/llvm/regions.js +2 -2
  136. package/dist/backend/llvm/regions.js.map +1 -1
  137. package/dist/backend/llvm/regions.test.js +7 -1
  138. package/dist/backend/llvm/regions.test.js.map +1 -1
  139. package/dist/backend/llvm/shapes.d.ts +17 -9
  140. package/dist/backend/llvm/shapes.js +21 -17
  141. package/dist/backend/llvm/shapes.js.map +1 -1
  142. package/dist/backend/llvm/speculative-integers.d.ts +20 -1
  143. package/dist/backend/llvm/speculative-integers.js +94 -6
  144. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  145. package/dist/backend/llvm/speculative-integers.test.js +55 -1
  146. package/dist/backend/llvm/speculative-integers.test.js.map +1 -1
  147. package/dist/backend/llvm/string-lifetimes.test.js +2 -1
  148. package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
  149. package/dist/backend/llvm/string-reads.d.ts +4 -1
  150. package/dist/backend/llvm/string-reads.js +88 -4
  151. package/dist/backend/llvm/string-reads.js.map +1 -1
  152. package/dist/backend/llvm/thread-slots.test.js +5 -4
  153. package/dist/backend/llvm/thread-slots.test.js.map +1 -1
  154. package/dist/backend/llvm/wasm-modules.d.ts +6 -5
  155. package/dist/backend/llvm/wasm-modules.js +32 -9
  156. package/dist/backend/llvm/wasm-modules.js.map +1 -1
  157. package/dist/backend/mangle.d.ts +8 -0
  158. package/dist/backend/mangle.js +12 -0
  159. package/dist/backend/mangle.js.map +1 -1
  160. package/dist/backend/native/contracts.d.ts +40 -2
  161. package/dist/backend/native/executable.js +40 -7
  162. package/dist/backend/native/executable.js.map +1 -1
  163. package/dist/backend/native/library.js +3 -1
  164. package/dist/backend/native/library.js.map +1 -1
  165. package/dist/backend/native-codegen.d.ts +17 -6
  166. package/dist/backend/native-codegen.js +55 -9
  167. package/dist/backend/native-codegen.js.map +1 -1
  168. package/dist/backend/native-codegen.test.js +18 -14
  169. package/dist/backend/native-codegen.test.js.map +1 -1
  170. package/dist/backend/native-link-info-core.d.ts +30 -2
  171. package/dist/backend/native-link-info-core.js.map +1 -1
  172. package/dist/backend/native-profile.d.ts +32 -0
  173. package/dist/backend/native-profile.js +39 -0
  174. package/dist/backend/native-profile.js.map +1 -0
  175. package/dist/backend/native-profile.test.d.ts +1 -0
  176. package/dist/backend/native-profile.test.js +58 -0
  177. package/dist/backend/native-profile.test.js.map +1 -0
  178. package/dist/backend/native-tools.d.ts +14 -0
  179. package/dist/backend/native-tools.js +13 -0
  180. package/dist/backend/native-tools.js.map +1 -1
  181. package/dist/backend/optimization.d.ts +2 -2
  182. package/dist/backend/runtime-abi.d.ts +2 -2
  183. package/dist/backend/runtime-abi.js +2 -2
  184. package/dist/backend/runtime-pack-core.d.ts +4 -0
  185. package/dist/backend/runtime-pack-core.js +4 -0
  186. package/dist/backend/runtime-pack-core.js.map +1 -1
  187. package/dist/backend/runtime-pack-targets.test.js +7 -1
  188. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  189. package/dist/backend/runtime-pack.d.ts +0 -21
  190. package/dist/backend/runtime-pack.js +0 -29
  191. package/dist/backend/runtime-pack.js.map +1 -1
  192. package/dist/backend/runtime-pack.test.js +12 -69
  193. package/dist/backend/runtime-pack.test.js.map +1 -1
  194. package/dist/backend/target-diagnostics.js +38 -1
  195. package/dist/backend/target-diagnostics.js.map +1 -1
  196. package/dist/backend/warm-cache.js +6 -0
  197. package/dist/backend/warm-cache.js.map +1 -1
  198. package/dist/cli/command.js +89 -7
  199. package/dist/cli/command.js.map +1 -1
  200. package/dist/cli/host.d.ts +3 -0
  201. package/dist/cli/output-options.d.ts +2 -0
  202. package/dist/cli/output-options.js +9 -0
  203. package/dist/cli/output-options.js.map +1 -1
  204. package/dist/cli/usage.d.ts +15 -1
  205. package/dist/cli/usage.js +30 -2
  206. package/dist/cli/usage.js.map +1 -1
  207. package/dist/compile-types.d.ts +9 -0
  208. package/dist/contracts/check.js +2 -3
  209. package/dist/contracts/check.js.map +1 -1
  210. package/dist/coverage/report.d.ts +7 -2
  211. package/dist/coverage/report.js +18 -0
  212. package/dist/coverage/report.js.map +1 -1
  213. package/dist/coverage/verdict-cache.d.ts +1 -0
  214. package/dist/coverage/verdict-cache.js +4 -0
  215. package/dist/coverage/verdict-cache.js.map +1 -1
  216. package/dist/coverage/verdict-semantic.js +4 -0
  217. package/dist/coverage/verdict-semantic.js.map +1 -1
  218. package/dist/diagnostics/diagnostic.js.map +1 -1
  219. package/dist/diagnostics/dynamic-tier.d.ts +40 -0
  220. package/dist/diagnostics/dynamic-tier.js +57 -0
  221. package/dist/diagnostics/dynamic-tier.js.map +1 -0
  222. package/dist/diagnostics/envelope.d.ts +2 -1
  223. package/dist/diagnostics/envelope.js +5 -2
  224. package/dist/diagnostics/envelope.js.map +1 -1
  225. package/dist/executable/executable-cache.d.ts +32 -0
  226. package/dist/executable/executable-cache.js +65 -7
  227. package/dist/executable/executable-cache.js.map +1 -1
  228. package/dist/executable/executable-cache.test.js +50 -3
  229. package/dist/executable/executable-cache.test.js.map +1 -1
  230. package/dist/executable/prepare.js +3 -1
  231. package/dist/executable/prepare.js.map +1 -1
  232. package/dist/frontend/analysis.js +1 -0
  233. package/dist/frontend/analysis.js.map +1 -1
  234. package/dist/frontend/arguments-usage.d.ts +8 -0
  235. package/dist/frontend/arguments-usage.js +98 -0
  236. package/dist/frontend/arguments-usage.js.map +1 -1
  237. package/dist/frontend/arguments-usage.test.d.ts +1 -0
  238. package/dist/frontend/arguments-usage.test.js +32 -0
  239. package/dist/frontend/arguments-usage.test.js.map +1 -0
  240. package/dist/frontend/builtin-package-aliases.d.ts +24 -0
  241. package/dist/frontend/builtin-package-aliases.js +133 -0
  242. package/dist/frontend/builtin-package-aliases.js.map +1 -0
  243. package/dist/frontend/builtin-package-aliases.test.d.ts +1 -0
  244. package/dist/frontend/builtin-package-aliases.test.js +48 -0
  245. package/dist/frontend/builtin-package-aliases.test.js.map +1 -0
  246. package/dist/frontend/dispose-hook.d.ts +2 -0
  247. package/dist/frontend/dispose-hook.js +14 -0
  248. package/dist/frontend/dispose-hook.js.map +1 -0
  249. package/dist/frontend/dts-paths.d.ts +4 -0
  250. package/dist/frontend/dts-paths.js +9 -1
  251. package/dist/frontend/dts-paths.js.map +1 -1
  252. package/dist/frontend/jsx-entities.d.ts +4 -0
  253. package/dist/frontend/jsx-entities.js +259 -0
  254. package/dist/frontend/jsx-entities.js.map +1 -0
  255. package/dist/frontend/jsx-source.d.ts +71 -0
  256. package/dist/frontend/jsx-source.js +781 -0
  257. package/dist/frontend/jsx-source.js.map +1 -0
  258. package/dist/frontend/jsx-source.test.d.ts +1 -0
  259. package/dist/frontend/jsx-source.test.js +200 -0
  260. package/dist/frontend/jsx-source.test.js.map +1 -0
  261. package/dist/frontend/literal-values.test.js +8 -9
  262. package/dist/frontend/literal-values.test.js.map +1 -1
  263. package/dist/frontend/lowering/array-indexed-mutation.js +2 -1
  264. package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
  265. package/dist/frontend/lowering/array-values.js +3 -2
  266. package/dist/frontend/lowering/array-values.js.map +1 -1
  267. package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
  268. package/dist/frontend/lowering/binding-analysis.js +2 -2
  269. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  270. package/dist/frontend/lowering/builtins/arguments.d.ts +3 -0
  271. package/dist/frontend/lowering/builtins/arguments.js +30 -15
  272. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  273. package/dist/frontend/lowering/builtins/atomics.js +10 -6
  274. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  275. package/dist/frontend/lowering/builtins/builtin-class-dyn.d.ts +8 -0
  276. package/dist/frontend/lowering/builtins/builtin-class-dyn.js +50 -1
  277. package/dist/frontend/lowering/builtins/builtin-class-dyn.js.map +1 -1
  278. package/dist/frontend/lowering/builtins/callable-aliases.js +3 -2
  279. package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
  280. package/dist/frontend/lowering/builtins/child-process-async.js +2 -1
  281. package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -1
  282. package/dist/frontend/lowering/builtins/child-process-sync.js +2 -1
  283. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  284. package/dist/frontend/lowering/builtins/crypto.d.ts +7 -2
  285. package/dist/frontend/lowering/builtins/crypto.js +63 -4
  286. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  287. package/dist/frontend/lowering/builtins/date-classes.d.ts +46 -0
  288. package/dist/frontend/lowering/builtins/date-classes.js +477 -0
  289. package/dist/frontend/lowering/builtins/date-classes.js.map +1 -0
  290. package/dist/frontend/lowering/builtins/dates.d.ts +11 -1
  291. package/dist/frontend/lowering/builtins/dates.js +55 -26
  292. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  293. package/dist/frontend/lowering/builtins/dh.d.ts +15 -0
  294. package/dist/frontend/lowering/builtins/dh.js +151 -0
  295. package/dist/frontend/lowering/builtins/dh.js.map +1 -0
  296. package/dist/frontend/lowering/builtins/disposable-stack.js +2 -1
  297. package/dist/frontend/lowering/builtins/disposable-stack.js.map +1 -1
  298. package/dist/frontend/lowering/builtins/ecdh.d.ts +21 -0
  299. package/dist/frontend/lowering/builtins/ecdh.js +208 -0
  300. package/dist/frontend/lowering/builtins/ecdh.js.map +1 -0
  301. package/dist/frontend/lowering/builtins/errors.d.ts +15 -0
  302. package/dist/frontend/lowering/builtins/errors.js +110 -0
  303. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  304. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -1
  305. package/dist/frontend/lowering/builtins/filesystem-calls.js +23 -17
  306. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  307. package/dist/frontend/lowering/builtins/filesystem.js +6 -4
  308. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  309. package/dist/frontend/lowering/builtins/fs-paths.d.ts +15 -0
  310. package/dist/frontend/lowering/builtins/fs-paths.js +209 -0
  311. package/dist/frontend/lowering/builtins/fs-paths.js.map +1 -0
  312. package/dist/frontend/lowering/builtins/hash-stream.d.ts +16 -4
  313. package/dist/frontend/lowering/builtins/hash-stream.js +86 -23
  314. package/dist/frontend/lowering/builtins/hash-stream.js.map +1 -1
  315. package/dist/frontend/lowering/builtins/json.js +54 -1
  316. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  317. package/dist/frontend/lowering/builtins/key-object.d.ts +2 -1
  318. package/dist/frontend/lowering/builtins/key-object.js +20 -7
  319. package/dist/frontend/lowering/builtins/key-object.js.map +1 -1
  320. package/dist/frontend/lowering/builtins/module-calls.js +11 -4
  321. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  322. package/dist/frontend/lowering/builtins/numbers.js +9 -5
  323. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  324. package/dist/frontend/lowering/builtins/operating-system.js +4 -3
  325. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  326. package/dist/frontend/lowering/builtins/performance.js +3 -2
  327. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  328. package/dist/frontend/lowering/builtins/process.d.ts +9 -0
  329. package/dist/frontend/lowering/builtins/process.js +47 -2
  330. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  331. package/dist/frontend/lowering/builtins/promises.js +3 -2
  332. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  333. package/dist/frontend/lowering/builtins/promisify-callback.d.ts +3 -0
  334. package/dist/frontend/lowering/builtins/promisify-callback.js +23 -4
  335. package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
  336. package/dist/frontend/lowering/builtins/readline.d.ts +2 -1
  337. package/dist/frontend/lowering/builtins/readline.js +23 -6
  338. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  339. package/dist/frontend/lowering/builtins/reflection.js +26 -0
  340. package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
  341. package/dist/frontend/lowering/builtins/strings.js +13 -5
  342. package/dist/frontend/lowering/builtins/strings.js.map +1 -1
  343. package/dist/frontend/lowering/builtins/text-codecs.js +2 -1
  344. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  345. package/dist/frontend/lowering/builtins/timers.js +6 -2
  346. package/dist/frontend/lowering/builtins/timers.js.map +1 -1
  347. package/dist/frontend/lowering/builtins/typed-array-members.d.ts +7 -0
  348. package/dist/frontend/lowering/builtins/typed-array-members.js +160 -0
  349. package/dist/frontend/lowering/builtins/typed-array-members.js.map +1 -0
  350. package/dist/frontend/lowering/builtins/url.js +4 -3
  351. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  352. package/dist/frontend/lowering/builtins/v8.js +2 -1
  353. package/dist/frontend/lowering/builtins/v8.js.map +1 -1
  354. package/dist/frontend/lowering/builtins/webcrypto.js +39 -20
  355. package/dist/frontend/lowering/builtins/webcrypto.js.map +1 -1
  356. package/dist/frontend/lowering/call-arguments.js +2 -1
  357. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  358. package/dist/frontend/lowering/call-signatures.d.ts +4 -0
  359. package/dist/frontend/lowering/call-signatures.js +137 -13
  360. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  361. package/dist/frontend/lowering/caught-value-dispatch.d.ts +18 -1
  362. package/dist/frontend/lowering/caught-value-dispatch.js +201 -32
  363. package/dist/frontend/lowering/caught-value-dispatch.js.map +1 -1
  364. package/dist/frontend/lowering/cjs-exports-object.js +34 -1
  365. package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
  366. package/dist/frontend/lowering/class-assertions.js +3 -2
  367. package/dist/frontend/lowering/class-assertions.js.map +1 -1
  368. package/dist/frontend/lowering/class-construction.d.ts +2 -1
  369. package/dist/frontend/lowering/class-construction.js +8 -13
  370. package/dist/frontend/lowering/class-construction.js.map +1 -1
  371. package/dist/frontend/lowering/class-descriptors.js +1 -1
  372. package/dist/frontend/lowering/class-descriptors.js.map +1 -1
  373. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +34 -0
  374. package/dist/frontend/lowering/class-dynamic-dispatch.js +577 -152
  375. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  376. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +77 -0
  377. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  378. package/dist/frontend/lowering/class-method-mutations.js +3 -0
  379. package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
  380. package/dist/frontend/lowering/class-method-values.js +1 -1
  381. package/dist/frontend/lowering/class-method-values.js.map +1 -1
  382. package/dist/frontend/lowering/class-protocols.d.ts +17 -0
  383. package/dist/frontend/lowering/class-protocols.js +117 -7
  384. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  385. package/dist/frontend/lowering/class-prototypes.d.ts +5 -0
  386. package/dist/frontend/lowering/class-prototypes.js +42 -4
  387. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  388. package/dist/frontend/lowering/class-to-primitive.d.ts +2 -2
  389. package/dist/frontend/lowering/class-to-primitive.js +31 -8
  390. package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
  391. package/dist/frontend/lowering/class-unions.js +2 -1
  392. package/dist/frontend/lowering/class-unions.js.map +1 -1
  393. package/dist/frontend/lowering/coercions/fresh-spread.d.ts +13 -0
  394. package/dist/frontend/lowering/coercions/fresh-spread.js +95 -0
  395. package/dist/frontend/lowering/coercions/fresh-spread.js.map +1 -0
  396. package/dist/frontend/lowering/coercions/function-adapters.js +105 -75
  397. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  398. package/dist/frontend/lowering/coercions/structural.js +8 -7
  399. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  400. package/dist/frontend/lowering/coercions/unions.js +8 -7
  401. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  402. package/dist/frontend/lowering/collection-ingestion.js +2 -1
  403. package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
  404. package/dist/frontend/lowering/containers/array-callbacks.d.ts +15 -0
  405. package/dist/frontend/lowering/containers/array-callbacks.js +36 -32
  406. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  407. package/dist/frontend/lowering/containers/array-concat.js +2 -1
  408. package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
  409. package/dist/frontend/lowering/containers/array-construction.js +32 -4
  410. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  411. package/dist/frontend/lowering/containers/array-methods.js +11 -5
  412. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  413. package/dist/frontend/lowering/containers/array-pipelines.js +2 -1
  414. package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
  415. package/dist/frontend/lowering/containers/bytes.d.ts +10 -1
  416. package/dist/frontend/lowering/containers/bytes.js +601 -24
  417. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  418. package/dist/frontend/lowering/containers/callback-arguments.js +52 -2
  419. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  420. package/dist/frontend/lowering/containers/collection-grouping.js +3 -2
  421. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  422. package/dist/frontend/lowering/containers/collection-methods.js +80 -10
  423. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  424. package/dist/frontend/lowering/containers/indexed-objects.js +8 -7
  425. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  426. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +32 -1
  427. package/dist/frontend/lowering/containers/iterator-helpers.js +6 -5
  428. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  429. package/dist/frontend/lowering/containers/string-and-regexp.js +85 -22
  430. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  431. package/dist/frontend/lowering/containers/string-replacement.js +2 -1
  432. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
  433. package/dist/frontend/lowering/cycle-initialization.d.ts +26 -10
  434. package/dist/frontend/lowering/cycle-initialization.js +177 -39
  435. package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
  436. package/dist/frontend/lowering/deferred-module-initializers.d.ts +18 -1
  437. package/dist/frontend/lowering/deferred-module-initializers.js +226 -115
  438. package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
  439. package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
  440. package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
  441. package/dist/frontend/lowering/dispatch-sites.d.ts +59 -0
  442. package/dist/frontend/lowering/dispatch-sites.js +204 -0
  443. package/dist/frontend/lowering/dispatch-sites.js.map +1 -0
  444. package/dist/frontend/lowering/dispatch-sites.test.d.ts +1 -0
  445. package/dist/frontend/lowering/dispatch-sites.test.js +59 -0
  446. package/dist/frontend/lowering/dispatch-sites.test.js.map +1 -0
  447. package/dist/frontend/lowering/dyn-streams.d.ts +3 -0
  448. package/dist/frontend/lowering/dyn-streams.js +1 -1
  449. package/dist/frontend/lowering/dyn-streams.js.map +1 -1
  450. package/dist/frontend/lowering/dynamic-tier.d.ts +25 -0
  451. package/dist/frontend/lowering/dynamic-tier.js +327 -0
  452. package/dist/frontend/lowering/dynamic-tier.js.map +1 -0
  453. package/dist/frontend/lowering/error-methods.js +4 -0
  454. package/dist/frontend/lowering/error-methods.js.map +1 -1
  455. package/dist/frontend/lowering/expressions/array-literals.js +48 -13
  456. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  457. package/dist/frontend/lowering/expressions/binary.js +124 -8
  458. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  459. package/dist/frontend/lowering/expressions/element-access.js +30 -7
  460. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  461. package/dist/frontend/lowering/expressions/identifiers.js +46 -7
  462. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  463. package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +14 -2
  464. package/dist/frontend/lowering/expressions/keyed-field-targets.js +91 -10
  465. package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
  466. package/dist/frontend/lowering/expressions/narrowing.js +52 -7
  467. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  468. package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -3
  469. package/dist/frontend/lowering/expressions/object-literals.js +75 -7
  470. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  471. package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
  472. package/dist/frontend/lowering/expressions/optional-chains.js +17 -8
  473. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  474. package/dist/frontend/lowering/expressions/property-access.d.ts +5 -4
  475. package/dist/frontend/lowering/expressions/property-access.js +351 -16
  476. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  477. package/dist/frontend/lowering/expressions/relational.js +112 -9
  478. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  479. package/dist/frontend/lowering/expressions/typeof.js +13 -0
  480. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  481. package/dist/frontend/lowering/expressions/updates.js +64 -10
  482. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  483. package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
  484. package/dist/frontend/lowering/generator-delegation.js +191 -1
  485. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  486. package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +6 -1
  487. package/dist/frontend/lowering/generator-dynamic-dispatch.js +20 -30
  488. package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
  489. package/dist/frontend/lowering/generic-functions.d.ts +46 -1
  490. package/dist/frontend/lowering/generic-functions.js +660 -73
  491. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  492. package/dist/frontend/lowering/handle-properties.d.ts +24 -0
  493. package/dist/frontend/lowering/handle-properties.js +281 -0
  494. package/dist/frontend/lowering/handle-properties.js.map +1 -0
  495. package/dist/frontend/lowering/intern-tables.js +2 -1
  496. package/dist/frontend/lowering/intern-tables.js.map +1 -1
  497. package/dist/frontend/lowering/iterable-spelling.d.ts +7 -0
  498. package/dist/frontend/lowering/iterable-spelling.js +38 -0
  499. package/dist/frontend/lowering/iterable-spelling.js.map +1 -0
  500. package/dist/frontend/lowering/iterator-adapters.js +9 -8
  501. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  502. package/dist/frontend/lowering/js-dynamic-objects.js +3 -2
  503. package/dist/frontend/lowering/js-dynamic-objects.js.map +1 -1
  504. package/dist/frontend/lowering/json-require.js +2 -1
  505. package/dist/frontend/lowering/json-require.js.map +1 -1
  506. package/dist/frontend/lowering/key-order-witness.d.ts +7 -2
  507. package/dist/frontend/lowering/key-order-witness.js +21 -4
  508. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  509. package/dist/frontend/lowering/key-order-witness.test.js +38 -2
  510. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  511. package/dist/frontend/lowering/lifetime-regions.js +2 -1
  512. package/dist/frontend/lowering/lifetime-regions.js.map +1 -1
  513. package/dist/frontend/lowering/lower-array-sort.d.ts +33 -15
  514. package/dist/frontend/lowering/lower-array-sort.js +117 -21
  515. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  516. package/dist/frontend/lowering/lower-array-sort.test.js +93 -14
  517. package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
  518. package/dist/frontend/lowering/lower-assert.js +6 -5
  519. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  520. package/dist/frontend/lowering/lower-async-iteration.js +3 -1
  521. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  522. package/dist/frontend/lowering/lower-builtin-values.js +1 -0
  523. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  524. package/dist/frontend/lowering/lower-calls.d.ts +4 -0
  525. package/dist/frontend/lowering/lower-calls.js +504 -97
  526. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  527. package/dist/frontend/lowering/lower-classes.d.ts +22 -0
  528. package/dist/frontend/lowering/lower-classes.js +339 -32
  529. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  530. package/dist/frontend/lowering/lower-dgram.js +65 -15
  531. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  532. package/dist/frontend/lowering/lower-event-emitter.d.ts +14 -0
  533. package/dist/frontend/lowering/lower-event-emitter.js +267 -20
  534. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  535. package/dist/frontend/lowering/lower-exprs.d.ts +19 -2
  536. package/dist/frontend/lowering/lower-exprs.js +148 -12
  537. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  538. package/dist/frontend/lowering/lower-functions.js +308 -72
  539. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  540. package/dist/frontend/lowering/lower-generators.js +10 -4
  541. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  542. package/dist/frontend/lowering/lower-inspect.js +578 -16
  543. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  544. package/dist/frontend/lowering/lower-mixins.js +2 -1
  545. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  546. package/dist/frontend/lowering/lower-mock.js +2 -1
  547. package/dist/frontend/lowering/lower-mock.js.map +1 -1
  548. package/dist/frontend/lowering/lower-modules.d.ts +11 -3
  549. package/dist/frontend/lowering/lower-modules.js +227 -72
  550. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  551. package/dist/frontend/lowering/lower-modules.test.js +2 -2
  552. package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
  553. package/dist/frontend/lowering/lower-namespaces.d.ts +2 -1
  554. package/dist/frontend/lowering/lower-namespaces.js +24 -3
  555. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  556. package/dist/frontend/lowering/lower-server.d.ts +10 -0
  557. package/dist/frontend/lowering/lower-server.js +263 -60
  558. package/dist/frontend/lowering/lower-server.js.map +1 -1
  559. package/dist/frontend/lowering/lower-stdlib.js +39 -18
  560. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  561. package/dist/frontend/lowering/lower-stmts.d.ts +7 -10
  562. package/dist/frontend/lowering/lower-stmts.js +584 -69
  563. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  564. package/dist/frontend/lowering/lower-stmts.test.js +1 -1
  565. package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
  566. package/dist/frontend/lowering/lower-stream.js +575 -165
  567. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  568. package/dist/frontend/lowering/lower-timers.js +21 -4
  569. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  570. package/dist/frontend/lowering/lowerer.d.ts +151 -30
  571. package/dist/frontend/lowering/lowerer.js +725 -84
  572. package/dist/frontend/lowering/lowerer.js.map +1 -1
  573. package/dist/frontend/lowering/lowerer.test.js +21 -9
  574. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  575. package/dist/frontend/lowering/narrowing-stability.js +5 -0
  576. package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
  577. package/dist/frontend/lowering/native-ffi.js +1 -1
  578. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  579. package/dist/frontend/lowering/object-enumeration-receiver.js +2 -1
  580. package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
  581. package/dist/frontend/lowering/pairs-snapshot.js +2 -1
  582. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  583. package/dist/frontend/lowering/private-brands.d.ts +9 -0
  584. package/dist/frontend/lowering/private-brands.js +66 -15
  585. package/dist/frontend/lowering/private-brands.js.map +1 -1
  586. package/dist/frontend/lowering/promise-executor-adapter.js +2 -1
  587. package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
  588. package/dist/frontend/lowering/rebindable-functions.d.ts +8 -0
  589. package/dist/frontend/lowering/rebindable-functions.js +54 -0
  590. package/dist/frontend/lowering/rebindable-functions.js.map +1 -0
  591. package/dist/frontend/lowering/require-initialization.js +2 -1
  592. package/dist/frontend/lowering/require-initialization.js.map +1 -1
  593. package/dist/frontend/lowering/runtime-optional-elements.d.ts +5 -0
  594. package/dist/frontend/lowering/runtime-optional-elements.js +17 -1
  595. package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -1
  596. package/dist/frontend/lowering/runtime-optional-records.d.ts +2 -0
  597. package/dist/frontend/lowering/runtime-optional-records.js +18 -5
  598. package/dist/frontend/lowering/runtime-optional-records.js.map +1 -1
  599. package/dist/frontend/lowering/site-dependencies.d.ts +35 -0
  600. package/dist/frontend/lowering/site-dependencies.js +84 -0
  601. package/dist/frontend/lowering/site-dependencies.js.map +1 -0
  602. package/dist/frontend/lowering/site-dependencies.test.d.ts +1 -0
  603. package/dist/frontend/lowering/site-dependencies.test.js +53 -0
  604. package/dist/frontend/lowering/site-dependencies.test.js.map +1 -0
  605. package/dist/frontend/lowering/stable-names.d.ts +11 -0
  606. package/dist/frontend/lowering/stable-names.js +35 -0
  607. package/dist/frontend/lowering/stable-names.js.map +1 -0
  608. package/dist/frontend/lowering/static-typeof.d.ts +26 -0
  609. package/dist/frontend/lowering/static-typeof.js +172 -0
  610. package/dist/frontend/lowering/static-typeof.js.map +1 -0
  611. package/dist/frontend/lowering/strict-equality.js +2 -1
  612. package/dist/frontend/lowering/strict-equality.js.map +1 -1
  613. package/dist/frontend/lowering/string-index-bounds.js +3 -2
  614. package/dist/frontend/lowering/string-index-bounds.js.map +1 -1
  615. package/dist/frontend/lowering/structural-positions.d.ts +32 -0
  616. package/dist/frontend/lowering/structural-positions.js +108 -0
  617. package/dist/frontend/lowering/structural-positions.js.map +1 -0
  618. package/dist/frontend/lowering/surfaces.js +72 -30
  619. package/dist/frontend/lowering/surfaces.js.map +1 -1
  620. package/dist/frontend/lowering/thenables.d.ts +16 -0
  621. package/dist/frontend/lowering/thenables.js +124 -0
  622. package/dist/frontend/lowering/thenables.js.map +1 -0
  623. package/dist/frontend/lowering/var-hoisting.js +37 -3
  624. package/dist/frontend/lowering/var-hoisting.js.map +1 -1
  625. package/dist/frontend/npm-static-builtin-aliases.d.ts +8 -0
  626. package/dist/frontend/npm-static-builtin-aliases.js +65 -0
  627. package/dist/frontend/npm-static-builtin-aliases.js.map +1 -0
  628. package/dist/frontend/npm-static-bundled-chunks.d.ts +8 -1
  629. package/dist/frontend/npm-static-bundled-chunks.js +173 -2
  630. package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
  631. package/dist/frontend/npm-static-bundled-chunks.test.js +112 -0
  632. package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
  633. package/dist/frontend/npm-static-bundled-esm.js +224 -4
  634. package/dist/frontend/npm-static-bundled-esm.js.map +1 -1
  635. package/dist/frontend/npm-static-bundled-esm.test.js +129 -0
  636. package/dist/frontend/npm-static-bundled-esm.test.js.map +1 -1
  637. package/dist/frontend/npm-static-enum-iife.d.ts +6 -0
  638. package/dist/frontend/npm-static-enum-iife.js +280 -0
  639. package/dist/frontend/npm-static-enum-iife.js.map +1 -0
  640. package/dist/frontend/npm-static-enum-iife.test.d.ts +1 -0
  641. package/dist/frontend/npm-static-enum-iife.test.js +116 -0
  642. package/dist/frontend/npm-static-enum-iife.test.js.map +1 -0
  643. package/dist/frontend/npm-static-tsc-helpers.d.ts +5 -0
  644. package/dist/frontend/npm-static-tsc-helpers.js +106 -0
  645. package/dist/frontend/npm-static-tsc-helpers.js.map +1 -0
  646. package/dist/frontend/npm-static-tsc-helpers.test.d.ts +1 -0
  647. package/dist/frontend/npm-static-tsc-helpers.test.js +58 -0
  648. package/dist/frontend/npm-static-tsc-helpers.test.js.map +1 -0
  649. package/dist/frontend/npm-static-type-exports-host.d.ts +8 -0
  650. package/dist/frontend/npm-static-type-exports-host.js +214 -0
  651. package/dist/frontend/npm-static-type-exports-host.js.map +1 -0
  652. package/dist/frontend/npm-static-type-exports-host.test.d.ts +1 -0
  653. package/dist/frontend/npm-static-type-exports-host.test.js +53 -0
  654. package/dist/frontend/npm-static-type-exports-host.test.js.map +1 -0
  655. package/dist/frontend/npm-static-type-exports.d.ts +52 -0
  656. package/dist/frontend/npm-static-type-exports.js +261 -0
  657. package/dist/frontend/npm-static-type-exports.js.map +1 -0
  658. package/dist/frontend/npm-static-type-exports.test.d.ts +1 -0
  659. package/dist/frontend/npm-static-type-exports.test.js +103 -0
  660. package/dist/frontend/npm-static-type-exports.test.js.map +1 -0
  661. package/dist/frontend/npm-static-umd.d.ts +6 -0
  662. package/dist/frontend/npm-static-umd.js +203 -0
  663. package/dist/frontend/npm-static-umd.js.map +1 -0
  664. package/dist/frontend/npm-static-umd.test.d.ts +1 -0
  665. package/dist/frontend/npm-static-umd.test.js +105 -0
  666. package/dist/frontend/npm-static-umd.test.js.map +1 -0
  667. package/dist/frontend/npm-static.d.ts +16 -0
  668. package/dist/frontend/npm-static.js +93 -3
  669. package/dist/frontend/npm-static.js.map +1 -1
  670. package/dist/frontend/npm.js +13 -0
  671. package/dist/frontend/npm.js.map +1 -1
  672. package/dist/frontend/package-shims.d.ts +47 -0
  673. package/dist/frontend/package-shims.js +300 -0
  674. package/dist/frontend/package-shims.js.map +1 -0
  675. package/dist/frontend/pipeline.js +67 -1
  676. package/dist/frontend/pipeline.js.map +1 -1
  677. package/dist/frontend/program.d.ts +21 -0
  678. package/dist/frontend/program.js +174 -14
  679. package/dist/frontend/program.js.map +1 -1
  680. package/dist/frontend/program.test.js +1 -1
  681. package/dist/frontend/program.test.js.map +1 -1
  682. package/dist/frontend/resolve.js +13 -0
  683. package/dist/frontend/resolve.js.map +1 -1
  684. package/dist/frontend/services.d.ts +12 -0
  685. package/dist/frontend/services.js +37 -0
  686. package/dist/frontend/services.js.map +1 -1
  687. package/dist/frontend/ts7/ast-node.d.ts +21 -7
  688. package/dist/frontend/ts7/ast-node.js +131 -29
  689. package/dist/frontend/ts7/ast-node.js.map +1 -1
  690. package/dist/frontend/ts7/ast-node.test.js +60 -0
  691. package/dist/frontend/ts7/ast-node.test.js.map +1 -1
  692. package/dist/frontend/ts7/ast-wire.d.ts +27 -2
  693. package/dist/frontend/ts7/ast-wire.js +124 -21
  694. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  695. package/dist/frontend/ts7/ast.d.ts +23 -2
  696. package/dist/frontend/ts7/ast.js +143 -2
  697. package/dist/frontend/ts7/ast.js.map +1 -1
  698. package/dist/frontend/ts7/checker.d.ts +13 -1
  699. package/dist/frontend/ts7/checker.js +75 -1
  700. package/dist/frontend/ts7/checker.js.map +1 -1
  701. package/dist/frontend/ts7/checker.test.js +9 -6
  702. package/dist/frontend/ts7/checker.test.js.map +1 -1
  703. package/dist/frontend/ts7/enums.d.ts +3 -3
  704. package/dist/frontend/ts7/enums.generated.d.ts +10 -0
  705. package/dist/frontend/ts7/enums.generated.js +21 -0
  706. package/dist/frontend/ts7/enums.generated.js.map +1 -1
  707. package/dist/frontend/ts7/enums.js +19 -0
  708. package/dist/frontend/ts7/enums.js.map +1 -1
  709. package/dist/frontend/ts7/program-host.d.ts +6 -5
  710. package/dist/frontend/ts7/program-host.js +12 -2
  711. package/dist/frontend/ts7/program-host.js.map +1 -1
  712. package/dist/frontend/ts7/semantic-checker.d.ts +10 -0
  713. package/dist/frontend/ts7/semantic-checker.js +25 -20
  714. package/dist/frontend/ts7/semantic-checker.js.map +1 -1
  715. package/dist/frontend/ts7/semantic-json.d.ts +13 -0
  716. package/dist/frontend/ts7/semantic-json.js +146 -0
  717. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  718. package/dist/frontend/ts7/semantic-json.test.js +57 -1
  719. package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
  720. package/dist/frontend/ts7/semantic-model.d.ts +18 -0
  721. package/dist/frontend/ts7/semantic-model.js +90 -16
  722. package/dist/frontend/ts7/semantic-model.js.map +1 -1
  723. package/dist/frontend/ts7/semantic-model.test.js +3 -2
  724. package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
  725. package/dist/frontend/ts7/session.d.ts +19 -4
  726. package/dist/frontend/ts7/session.js +1 -1
  727. package/dist/frontend/ts7/session.js.map +1 -1
  728. package/dist/frontend/tsc-codes.d.ts +1 -1
  729. package/dist/frontend/tsc-codes.js +7 -0
  730. package/dist/frontend/tsc-codes.js.map +1 -1
  731. package/dist/frontend/type-mapper.d.ts +38 -6
  732. package/dist/frontend/type-mapper.js +466 -47
  733. package/dist/frontend/type-mapper.js.map +1 -1
  734. package/dist/frontend/type-mapper.test.js +1 -1
  735. package/dist/frontend/type-mapper.test.js.map +1 -1
  736. package/dist/frontend-process-args.d.ts +4 -0
  737. package/dist/frontend-process-args.js +52 -0
  738. package/dist/frontend-process-args.js.map +1 -0
  739. package/dist/frontend-process-args.test.d.ts +1 -0
  740. package/dist/frontend-process-args.test.js +47 -0
  741. package/dist/frontend-process-args.test.js.map +1 -0
  742. package/dist/frontend-process.d.ts +1 -0
  743. package/dist/frontend-process.js +23 -0
  744. package/dist/frontend-process.js.map +1 -0
  745. package/dist/heap-collection.d.ts +16 -0
  746. package/dist/heap-collection.js +42 -0
  747. package/dist/heap-collection.js.map +1 -0
  748. package/dist/heap-collection.test.d.ts +1 -0
  749. package/dist/heap-collection.test.js +59 -0
  750. package/dist/heap-collection.test.js.map +1 -0
  751. package/dist/heap-pressure.d.ts +2 -0
  752. package/dist/heap-pressure.js +12 -0
  753. package/dist/heap-pressure.js.map +1 -0
  754. package/dist/index.d.ts +8 -0
  755. package/dist/index.js +453 -85
  756. package/dist/index.js.map +1 -1
  757. package/dist/ir/array-length-stability.d.ts +3 -2
  758. package/dist/ir/array-length-stability.js +22 -2
  759. package/dist/ir/array-length-stability.js.map +1 -1
  760. package/dist/ir/array-length-stability.test.js +47 -1
  761. package/dist/ir/array-length-stability.test.js.map +1 -1
  762. package/dist/ir/builtin-effects.js +41 -0
  763. package/dist/ir/builtin-effects.js.map +1 -1
  764. package/dist/ir/builtin-signatures.d.ts +5 -1
  765. package/dist/ir/builtin-signatures.js +187 -16
  766. package/dist/ir/builtin-signatures.js.map +1 -1
  767. package/dist/ir/final-fields.d.ts +2 -1
  768. package/dist/ir/final-fields.js +2 -2
  769. package/dist/ir/final-fields.js.map +1 -1
  770. package/dist/ir/function-references.test.js +2 -0
  771. package/dist/ir/function-references.test.js.map +1 -1
  772. package/dist/ir/int32-slots.d.ts +13 -5
  773. package/dist/ir/int32-slots.js +112 -115
  774. package/dist/ir/int32-slots.js.map +1 -1
  775. package/dist/ir/int32-slots.test.js +3 -1
  776. package/dist/ir/int32-slots.test.js.map +1 -1
  777. package/dist/ir/integer-loop-facts.d.ts +14 -4
  778. package/dist/ir/integer-loop-facts.js +172 -32
  779. package/dist/ir/integer-loop-facts.js.map +1 -1
  780. package/dist/ir/integer-loops.d.ts +49 -0
  781. package/dist/ir/integer-loops.js +193 -39
  782. package/dist/ir/integer-loops.js.map +1 -1
  783. package/dist/ir/integer-loops.test.js +201 -1
  784. package/dist/ir/integer-loops.test.js.map +1 -1
  785. package/dist/ir/integer-ranges.d.ts +10 -1
  786. package/dist/ir/integer-ranges.js +122 -25
  787. package/dist/ir/integer-ranges.js.map +1 -1
  788. package/dist/ir/integer-ranges.test.js +255 -1
  789. package/dist/ir/integer-ranges.test.js.map +1 -1
  790. package/dist/ir/ir.d.ts +17 -2
  791. package/dist/ir/ir.js +11 -1
  792. package/dist/ir/ir.js.map +1 -1
  793. package/dist/ir/js-ic.d.ts +52 -0
  794. package/dist/ir/js-ic.js +199 -0
  795. package/dist/ir/js-ic.js.map +1 -0
  796. package/dist/ir/js-ic.test.d.ts +1 -0
  797. package/dist/ir/js-ic.test.js +148 -0
  798. package/dist/ir/js-ic.test.js.map +1 -0
  799. package/dist/ir/jsval.js +38 -4
  800. package/dist/ir/jsval.js.map +1 -1
  801. package/dist/ir/runtime-features.d.ts +64 -5
  802. package/dist/ir/runtime-features.js +358 -101
  803. package/dist/ir/runtime-features.js.map +1 -1
  804. package/dist/ir/tiers.js +1 -0
  805. package/dist/ir/tiers.js.map +1 -1
  806. package/dist/ir/traverse.d.ts +2 -0
  807. package/dist/ir/traverse.js +124 -70
  808. package/dist/ir/traverse.js.map +1 -1
  809. package/dist/ir/validate.js +77 -24
  810. package/dist/ir/validate.js.map +1 -1
  811. package/dist/ir/validate.test.js +15 -2
  812. package/dist/ir/validate.test.js.map +1 -1
  813. package/dist/library/ir-policy.js +11 -0
  814. package/dist/library/ir-policy.js.map +1 -1
  815. package/dist/library/library-cache.d.ts +2 -0
  816. package/dist/library/library-cache.js.map +1 -1
  817. package/dist/library/prepare.js +2 -0
  818. package/dist/library/prepare.js.map +1 -1
  819. package/dist/native/cli.js +22 -0
  820. package/dist/native/cli.js.map +1 -1
  821. package/dist/native/compiler.js +33 -4
  822. package/dist/native/compiler.js.map +1 -1
  823. package/dist/native/executable-cache.js +3 -0
  824. package/dist/native/executable-cache.js.map +1 -1
  825. package/dist/native/prepare.js +8 -1
  826. package/dist/native/prepare.js.map +1 -1
  827. package/dist/native/sanitizer.test.js +10 -0
  828. package/dist/native/sanitizer.test.js.map +1 -1
  829. package/dist/startup-cache.d.ts +1 -0
  830. package/dist/startup-cache.js +1 -0
  831. package/dist/startup-cache.js.map +1 -1
  832. package/dist/text-parts.d.ts +7 -0
  833. package/dist/text-parts.js +44 -0
  834. package/dist/text-parts.js.map +1 -1
  835. package/dist/text-parts.test.d.ts +1 -0
  836. package/dist/text-parts.test.js +46 -0
  837. package/dist/text-parts.test.js.map +1 -0
  838. package/dist/timing.d.ts +9 -2
  839. package/dist/timing.js +7 -4
  840. package/dist/timing.js.map +1 -1
  841. package/dist/wasm/translate.d.ts +4 -0
  842. package/dist/wasm/translate.js +2 -2
  843. package/dist/wasm/translate.js.map +1 -1
  844. package/package.json +22 -21
  845. package/shims/fs-extra/core/api.ts +1192 -0
  846. package/shims/fs-extra/index.ts +9 -0
  847. package/shims/undici/core/agent.ts +163 -0
  848. package/shims/undici/core/api.ts +93 -0
  849. package/shims/undici/core/client.ts +1304 -0
  850. package/shims/undici/core/connector.ts +157 -0
  851. package/shims/undici/core/diagnostics-types.ts +68 -0
  852. package/shims/undici/core/diagnostics.ts +16 -0
  853. package/shims/undici/core/dispatcher.ts +574 -0
  854. package/shims/undici/core/errors-v5.ts +22 -0
  855. package/shims/undici/core/errors-v7.ts +25 -0
  856. package/shims/undici/core/errors.ts +255 -0
  857. package/shims/undici/core/fetch.ts +635 -0
  858. package/shims/undici/core/pool.ts +280 -0
  859. package/shims/undici/core/readable.ts +268 -0
  860. package/shims/undici/core/request.ts +313 -0
  861. package/shims/undici/core/timers.ts +80 -0
  862. package/shims/undici/core/types.ts +167 -0
  863. package/shims/undici/core/util.ts +67 -0
  864. package/shims/undici/v5.ts +119 -0
  865. package/shims/undici/v7.ts +119 -0
  866. package/surface-manifest.json +20 -52
@@ -1,8 +1,12 @@
1
- import { onlyForwarded } from "./typed-arguments.js";
1
+ import { relieveHeapPressure } from "../../heap-pressure.js";
2
+ import { keyedHelperName } from "./stable-names.js";
3
+ import { positionTag, StructuralPositions } from "./structural-positions.js";
4
+ import { onlyForwarded, stripTypeWrappers } from "./typed-arguments.js";
2
5
  import { needsGeneralNodeStreams, noteUntypedStreamFlow, stdioIntoGeneralStream, } from "./general-streams.js";
3
6
  import { extendAssertedRecordMembers } from "./assertion-members.js";
4
7
  import { jsDynamicDeclarations } from "./js-dynamic-objects.js";
5
- import { builtinClassValue, builtinMemberClassKind } from "./builtins/builtin-class-dyn.js";
8
+ import { isJsSourceFileName } from "../tsc-codes.js";
9
+ import { builtinClassKind, builtinClassValue, builtinMemberClassKind, } from "./builtins/builtin-class-dyn.js";
6
10
  import { lifetimeRegionType, lowerLifetimeRegionCall, lowerLifetimeRegionNew, } from "./lifetime-regions.js";
7
11
  import { internTableType, lowerInternTableCall, lowerInternTableNew } from "./intern-tables.js";
8
12
  import { lowerThreadSlotsCall, lowerThreadSlotsNew, threadSlotsType } from "./thread-slots.js";
@@ -13,10 +17,13 @@ import { checkRequireBindingAccesses, } from "./require-initialization.js";
13
17
  import { identityPreservingWidening } from "./coercions/identity.js";
14
18
  import { scanDivergences } from "./divergences.js";
15
19
  import { applyKeyOrderWitnesses, KeyOrderNotes } from "./key-order-witness.js";
20
+ import { exprFunctionReference } from "../../ir/function-references.js";
21
+ import { everyStmtList, observeRecordLiteralRebuilds } from "../../ir/traverse.js";
16
22
  import { checkedClassAssertion } from "./class-assertions.js";
17
23
  import { narrowStoredClassValue, narrowGenericClassValue } from "./class-unions.js";
18
- import { isOptionalProcessStreamProperty } from "./builtins/process.js";
24
+ import { isOptionalProcessStreamProperty, isOptionalProcessVersionsRead, } from "./builtins/process.js";
19
25
  import { isSettledIteratorValueRead } from "./lower-generators.js";
26
+ import { isRebindableFunctionSymbol } from "./rebindable-functions.js";
20
27
  import { concreteCollectionNarrow } from "./collection-narrowing.js";
21
28
  import { lowerWorkerMetadata } from "./builtins/workers.js";
22
29
  import { fenceStaticBlobMember, lowerBlobNew, lowerStaticBlobCall } from "./builtins/blob.js";
@@ -25,8 +32,10 @@ import { discoverWasmModules } from "../../wasm/discover.js";
25
32
  import { encodeBase64 } from "../../wasm/base64.js";
26
33
  import { resolveRequireRuntime } from "../runtime-resolve.js";
27
34
  import { lowerKeyObjectCall } from "./builtins/key-object.js";
35
+ import { isEcdhType, lowerEcdhCall } from "./builtins/ecdh.js";
36
+ import { isDiffieHellmanType, lowerDiffieHellmanCall } from "./builtins/dh.js";
28
37
  import { fenceWebCryptoMember, lowerWebCryptoCall } from "./builtins/webcrypto.js";
29
- import { hashStreamOf } from "./builtins/hash-stream.js";
38
+ import { valueStreamOf } from "./builtins/hash-stream.js";
30
39
  import { lowerNetAddressCall, lowerNetAddressNew } from "./builtins/net-address.js";
31
40
  import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
32
41
  import { iteratorSlotAdapter } from "./iterator-adapters.js";
@@ -46,6 +55,7 @@ import { ArrayElementStates } from "./runtime-optional-elements.js";
46
55
  import { indexReadInBounds } from "./runtime-optional-bounds.js";
47
56
  import { ArrayOwnership } from "./runtime-optional-ownership.js";
48
57
  import { RecordFlowClasses } from "./runtime-optional-records.js";
58
+ import { SiteDependencies } from "./site-dependencies.js";
49
59
  import { StringIndexBounds } from "./string-index-bounds.js";
50
60
  import { NanCodedReads } from "./nan-coded-reads.js";
51
61
  import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
@@ -58,10 +68,12 @@ import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optio
58
68
  import {} from "./class-protocol-dispatch.js";
59
69
  import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
60
70
  import { guardClassAttributeWrites } from "./class-attributes.js";
71
+ import { applyHandleProperties } from "./handle-properties.js";
61
72
  import { ClassProtocols } from "./class-protocols.js";
62
73
  import { earlyReadVarSymbols } from "./var-hoisting.js";
63
74
  import { recordTextCodecClass } from "../../ir/ir.js";
64
75
  import { assignLegacyTiers } from "../../ir/tiers.js";
76
+ import { dynamicTierWarning } from "./dynamic-tier.js";
65
77
  import { promoteJsvals } from "../../ir/jsval.js";
66
78
  import { analyzeTiers, dynamicStatementCount, } from "../tier-analysis.js";
67
79
  import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
@@ -83,10 +95,11 @@ export { newFnCtx } from "./function-context.js";
83
95
  * - Lexical scoping is resolved here: locals get function-unique ids
84
96
  * ("x.0", "x.1" for shadowing); the IR is scope-flat.
85
97
  */
86
- import { resolve } from "node:path";
98
+ import { dirname, relative, resolve } from "node:path";
87
99
  import { bindingSource } from "../binding-source.js";
88
100
  import { tsgoPath } from "../dts-paths.js";
89
101
  import * as ts from "../ts7/adapter.js";
102
+ import { isBundledShimForwarder } from "../package-shims.js";
90
103
  import { erasedTypeOnlyImport } from "../type-only-imports.js";
91
104
  import { literalValues } from "../literal-values.js";
92
105
  import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
@@ -142,7 +155,8 @@ import { lowerStringDecoderMethodCall, lowerTextCodecCall } from "./builtins/tex
142
155
  import { lowerReadlineMethodCall } from "./builtins/readline.js";
143
156
  import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, lowerAsyncLocalStorageMethodCall, lowerTracingChannelMethodCall, lowerTracingChannelProperty, } from "./builtins/async-context.js";
144
157
  import { lowerDisposableStackNew } from "./builtins/disposable-stack.js";
145
- import { lowerErrorCodeProperty } from "./builtins/errors.js";
158
+ import { lowerErrorCodeProperty, lowerErrorFunctionCall } from "./builtins/errors.js";
159
+ import { noteDateClassMethods } from "./builtins/date-classes.js";
146
160
  import { lowerProcessProperty, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerProcessStreamProperty, } from "./builtins/process.js";
147
161
  import { consoleCallMember, consoleMethodMember, isConsoleLog, } from "./builtins/console.js";
148
162
  import { lowerConsoleNew } from "./lower-console.js";
@@ -242,6 +256,33 @@ function directExternalTypeSpecifiersByFile(externalTypes) {
242
256
  }
243
257
  return out;
244
258
  }
259
+ /** Debugging aid: SCRIPTC_LOWER_SHUFFLE_SEED=<n> lowers each wave of
260
+ * reachable bodies in an order drawn from that seed instead of discovery
261
+ * order. Output assembly is ordered independently of it, so any IR
262
+ * difference between seeds is state one body's lowering leaves for another
263
+ * (scripts/lowering-order.mjs). */
264
+ function lowerShuffle() {
265
+ const raw = process.env["SCRIPTC_LOWER_SHUFFLE_SEED"];
266
+ if (raw === undefined || raw === "")
267
+ return null;
268
+ // mulberry32
269
+ let state = Number.parseInt(raw, 10) >>> 0;
270
+ const next = () => {
271
+ state = (state + 0x6d2b79f5) >>> 0;
272
+ let t = state;
273
+ t = Math.imul(t ^ (t >>> 15), t | 1);
274
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
275
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
276
+ };
277
+ return (wave) => {
278
+ for (let index = wave.length - 1; index > 0; index--) {
279
+ const other = Math.floor(next() * (index + 1));
280
+ const swap = wave[index];
281
+ wave[index] = wave[other];
282
+ wave[other] = swap;
283
+ }
284
+ };
285
+ }
245
286
  /** Build lowering runs as a reachability worklist over the ts.Program:
246
287
  *
247
288
  * 1. REACHABLE EMIT — a worklist computes the set of reachable bodies.
@@ -259,6 +300,10 @@ function directExternalTypeSpecifiersByFile(externalTypes) {
259
300
  * the bodies reachable emit did NOT mark (plus deferred collection
260
301
  * diagnostics nothing flushed), reported separately: whole-program analysis without
261
302
  * letting unreached code fail builds. */
303
+ /** The closure root of an emit-override specialization body. */
304
+ function emitSpecRoot(spec) {
305
+ return `%emit.${spec.info.def.name}.${spec.event}.${spec.ordinal}`;
306
+ }
262
307
  export function lowerToIr(program, entry, moduleOrder, options = {}) {
263
308
  const phaseTiming = process.env["SCRIPTC_TIMING"] === "1";
264
309
  const phaseStarted = performance.now();
@@ -297,11 +342,15 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
297
342
  cycleKeys.add(key);
298
343
  extraModuleCycleDiags.push(unsupportedDiag("SC1016", { file: entry.fileName, start: 0, end: 0 }, `circular imports (${cycle}; ${reason})`));
299
344
  };
345
+ // Inline require() calls closing a cycle inside the appended subgraphs
346
+ // join preflight's set (the same run-time refusal by name).
347
+ const inlineRequireCycleCalls = new Set(options.inlineRequireCycleCalls ?? []);
348
+ const graph = { edges: options.moduleEdges, inlineCycleCalls: inlineRequireCycleCalls };
300
349
  for (let pass = 0; pass < 32; pass++) {
301
350
  const before = moduleOrder.length;
302
- appendDynamicImportModules(program, moduleOrder, onExtraCycle);
303
- appendForkModules(program, moduleOrder, forkTargets, onExtraCycle);
304
- appendWorkerModules(program, moduleOrder, workerTargets, onExtraCycle);
351
+ appendDynamicImportModules(program, moduleOrder, onExtraCycle, graph);
352
+ appendForkModules(program, moduleOrder, forkTargets, onExtraCycle, graph);
353
+ appendWorkerModules(program, moduleOrder, workerTargets, onExtraCycle, graph);
305
354
  if (moduleOrder.length === before)
306
355
  break;
307
356
  if (pass === 31)
@@ -317,7 +366,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
317
366
  projectCheckJs: options.projectCheckJs ?? false,
318
367
  targetPlatform,
319
368
  startupCrash,
320
- inlineRequireCycleCalls: options.inlineRequireCycleCalls,
369
+ inlineRequireCycleCalls,
321
370
  ffiImports,
322
371
  libraryCallbacks,
323
372
  forkTargets,
@@ -340,7 +389,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
340
389
  projectCheckJs: options.projectCheckJs ?? false,
341
390
  targetPlatform,
342
391
  startupCrash,
343
- inlineRequireCycleCalls: options.inlineRequireCycleCalls,
392
+ inlineRequireCycleCalls,
344
393
  ffiImports,
345
394
  libraryCallbacks,
346
395
  forkTargets,
@@ -374,7 +423,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
374
423
  projectCheckJs: options.projectCheckJs ?? false,
375
424
  targetPlatform,
376
425
  startupCrash,
377
- inlineRequireCycleCalls: options.inlineRequireCycleCalls,
426
+ inlineRequireCycleCalls,
378
427
  ffiImports,
379
428
  libraryCallbacks,
380
429
  forkTargets,
@@ -420,7 +469,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
420
469
  reachable,
421
470
  targetPlatform,
422
471
  startupCrash,
423
- inlineRequireCycleCalls: options.inlineRequireCycleCalls,
472
+ inlineRequireCycleCalls,
424
473
  ffiImports,
425
474
  libraryCallbacks,
426
475
  forkTargets,
@@ -444,6 +493,14 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
444
493
  timing("divergence-scan", { found: divergences.length });
445
494
  if (divergences.length > 0)
446
495
  result = { ...result, divergences };
496
+ // The performance warning (SC6101): likely-hot functions of the program
497
+ // that compile to the dynamic tier because the source leaves them untyped.
498
+ if (result.module !== null && resultLowerer.dynamicFunctions.length > 0) {
499
+ const hotDynamic = dynamicTierWarning(resultLowerer, result.module, dirname(entry.fileName));
500
+ timing("dynamic-tier-scan", { found: hotDynamic === null ? 0 : 1 });
501
+ if (hotDynamic !== null)
502
+ result = { ...result, performance: [hotDynamic] };
503
+ }
447
504
  // Contract types (@scriptc/types): written annotations, checked against
448
505
  // the IR by the compile pipeline (contracts/check.ts).
449
506
  // Acyclic object types name the IR unit the program lowered them to; a
@@ -489,18 +546,28 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
489
546
  });
490
547
  // A program that uses the WebAssembly API carries every module the build
491
548
  // can see and translate (wasm/translate.ts); the rest fail at run time
492
- // with the CompileError for untranslated bytes.
549
+ // with a CompileError, which names the reason for the modules the build
550
+ // saw but does not translate.
493
551
  if (result.module !== null && resultLowerer.usesWebAssembly) {
494
552
  const bytesByHash = new Map();
495
553
  const reports = discoverModules((sha256, bytes) => bytesByHash.set(sha256, bytes));
496
554
  const wasmModules = [];
555
+ const wasmUntranslated = [];
497
556
  for (const report of reports) {
498
557
  const bytes = bytesByHash.get(report.sha256);
499
- if (report.status !== "valid" || bytes === undefined)
558
+ if (bytes === undefined)
500
559
  continue;
501
- wasmModules.push({ sha256: report.sha256, bytes: encodeBase64(bytes) });
560
+ if (report.status === "valid") {
561
+ wasmModules.push({ sha256: report.sha256, bytes: encodeBase64(bytes) });
562
+ continue;
563
+ }
564
+ const reason = report.status === "unsupported"
565
+ ? `it uses ${report.unsupported.join(", ")}, outside the translated WebAssembly feature set`
566
+ : `it is not a valid module: ${report.error ?? report.status}`;
567
+ wasmUntranslated.push({ sha256: report.sha256, size: bytes.length, reason });
502
568
  }
503
569
  result.module.wasmModules = wasmModules;
570
+ result.module.wasmUntranslated = wasmUntranslated;
504
571
  if (resultLowerer.usesWasmCustomSections)
505
572
  result.module.wasmCustomSections = true;
506
573
  timing("wasm-discovery", { modules: wasmModules.length });
@@ -515,7 +582,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
515
582
  reachable,
516
583
  remainder: true,
517
584
  alreadyFlushed: resultLowerer.flushedSymbols,
518
- inlineRequireCycleCalls: options.inlineRequireCycleCalls,
585
+ inlineRequireCycleCalls,
519
586
  targetPlatform,
520
587
  ffiImports,
521
588
  libraryCallbacks,
@@ -1052,6 +1119,10 @@ function monomorphizedImplicit(lowerer, fn) {
1052
1119
  return implicitLocalFnNodeOf(lowerer, binding) !== null;
1053
1120
  return true;
1054
1121
  }
1122
+ /** `fns` sorted by name; functions of one name keep their order. */
1123
+ function byName(fns) {
1124
+ return [...fns].sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
1125
+ }
1055
1126
  export class Lowerer {
1056
1127
  program;
1057
1128
  entry;
@@ -1082,6 +1153,9 @@ export class Lowerer {
1082
1153
  * pinned values resolve through genericFnOf exactly like top-level
1083
1154
  * generic function declarations (bindingGenericFnInfoOf). */
1084
1155
  bindingGenericFns = new Map();
1156
+ /** Identifiers by spelling, per file, for the generic bindings' use
1157
+ * ordering (runsAfterDeclaration). */
1158
+ bindingIdentifiers = new Map();
1085
1159
  /** Per-symbol result of the never-reassigned file scan
1086
1160
  * (bindingNeverReassigned — object-literal generic-method receivers). */
1087
1161
  neverReassignedCache = new Map();
@@ -1089,6 +1163,9 @@ export class Lowerer {
1089
1163
  * NaN, which lower to plain doubles (see nan-coded-reads.ts). Settled by
1090
1164
  * analyzeRuntimeOptionalArrayReads before any body lowers. */
1091
1165
  nanCodedReads = null;
1166
+ /** Whether any implementation source spells `versions`
1167
+ * (programMentionsVersions in builtins/process.ts). */
1168
+ mentionsProcessVersions = undefined;
1092
1169
  stringIndexBoundsCache = null;
1093
1170
  /** Proofs that a string element read names an existing code unit. The
1094
1171
  * indexed-read analysis and expression lowering share one instance, so a
@@ -1100,6 +1177,9 @@ export class Lowerer {
1100
1177
  /** Syntactic writes indexed once per JS scope. Symbol and RHS type
1101
1178
  * checks remain contextual to each binding probe. */
1102
1179
  jsBindingWritesByOwner = new Map();
1180
+ /** JavaScript function declarations their own module reassigns
1181
+ * (rebindable-functions.ts). */
1182
+ rebindableFunctions = new Set();
1103
1183
  /** TRAP bindings: declarations whose initializer provably throws before
1104
1184
  * producing a value (its chain roots at an ambient-undefined name —
1105
1185
  * ambientUndefVarRootOf). Module init unwinds at the declaration, so no
@@ -1227,6 +1307,35 @@ export class Lowerer {
1227
1307
  });
1228
1308
  this.genericClassInstances.splice(from, tail.length, ...tail);
1229
1309
  }
1310
+ /** The classes in table order. Generic instances are added as bodies
1311
+ * demand them, so they keep the slots they hold and fill them in the
1312
+ * order of their settled demand ranks. */
1313
+ classesInTableOrder() {
1314
+ const all = [...this.classes.values()];
1315
+ const slots = all.flatMap((info, index) => this.genericClassDemandPriority.has(info) ? [index] : []);
1316
+ const ranked = slots
1317
+ .map((index) => all[index])
1318
+ .sort((left, right) => {
1319
+ const a = this.genericClassDemandPriority.get(left).rank;
1320
+ const b = this.genericClassDemandPriority.get(right).rank;
1321
+ return a[0] - b[0] || a[1] - b[1];
1322
+ });
1323
+ slots.forEach((slot, index) => (all[slot] = ranked[index]));
1324
+ return all;
1325
+ }
1326
+ /** The globals in table order. A class's prototype data globals are
1327
+ * added when a body first reads that prototype, so they keep the slots
1328
+ * they hold and fill them in id order. */
1329
+ globalsInTableOrder() {
1330
+ const all = [...this.globalsList];
1331
+ const prototypeData = (global) => global.id.startsWith("%g.%prototype.data.");
1332
+ const slots = all.flatMap((global, index) => (prototypeData(global) ? [index] : []));
1333
+ const sorted = slots
1334
+ .map((index) => all[index])
1335
+ .sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0));
1336
+ slots.forEach((slot, index) => (all[slot] = sorted[index]));
1337
+ return all;
1338
+ }
1230
1339
  settleGenericDemandPriorities() {
1231
1340
  const functionQueue = [];
1232
1341
  const classQueue = [];
@@ -1308,6 +1417,12 @@ export class Lowerer {
1308
1417
  /** Instance types (by checker type id) of the local classes generic
1309
1418
  * factory calls return, and the per-instance class each names. */
1310
1419
  localClassInstanceTypes = new Map();
1420
+ /** A generic factory's instantiated result type → the class value of the
1421
+ * local class it returns (TypeMapperCtx.localClassValue). */
1422
+ localClassValueTypes = new Map();
1423
+ /** While a generic factory instance lowers: its declared result type → the
1424
+ * class value of the local class it returns. */
1425
+ instanceResultClass = null;
1311
1426
  /** The ts-level twin of typeParamBindings, non-null while a CALL-keyed
1312
1427
  * instance body lowers: type-parameter symbol → the bound CHECKER type,
1313
1428
  * consulted where the mapped IrType has already widened away information
@@ -1330,6 +1445,12 @@ export class Lowerer {
1330
1445
  * setEncoding call whose receiver is a socket or an untyped value.
1331
1446
  * Computed once on first use (null until then). */
1332
1447
  socketEncodingReachable = null;
1448
+ /** Whether some program source can define a thenable
1449
+ * (programMayDefineThenables). Null until first asked. */
1450
+ thenablesMayBeDefined = null;
1451
+ /** Lambdas lowered with checked-dynamic parameters (lambdaSignature):
1452
+ * callbacks whose arguments are wider than their contextual overload. */
1453
+ dynParamLambdas = new Set();
1333
1454
  /** Whether some server in this program may listen on a Unix socket: a
1334
1455
  * listen call whose first argument is a string. Computed once on first
1335
1456
  * use (null until then); address() answers the path only when true. */
@@ -1390,6 +1511,10 @@ export class Lowerer {
1390
1511
  /** Inline program-module require calls whose %init the enclosing member
1391
1512
  * read or member call is already sequencing (cjs-inline-require.ts). */
1392
1513
  inlineRequireInitDone = new Set();
1514
+ /** Whether lowered code writes properties onto children, and what the
1515
+ * program's JavaScript adds to them (handle-properties.ts). */
1516
+ writesOntoChildren = false;
1517
+ childAdditions = null;
1393
1518
  /** Bindings whose unchecked string arithmetic can produce either a number
1394
1519
  * (NaN for an absent read) or a string. Preserve that result union at bare
1395
1520
  * reads instead of applying the checker-bare string narrowing adapter. */
@@ -1832,6 +1957,19 @@ export class Lowerer {
1832
1957
  /** True while re-lowering a base function's 2nd+ instance: the same source
1833
1958
  * statements were already counted for the first instance. */
1834
1959
  suppressStats = false;
1960
+ /** Callback literals passed straight to an error-first zlib or crypto
1961
+ * function: only that function's callback adapter calls them
1962
+ * (lowerUndefinedResultBody). */
1963
+ errorFirstLiterals = new Set();
1964
+ /** Parameters read as `any` in the error-path copy of an error-first
1965
+ * callback. */
1966
+ anySymbols = new Set();
1967
+ /** Error parameters of an error-first callback with a known value in
1968
+ * the copy being lowered: true while it holds an Error, false while it
1969
+ * holds null (staticCondition folds conditions on them). */
1970
+ knownErrors = new Map();
1971
+ /** The number of error-path callback copies being lowered. */
1972
+ errorPathCopies = 0;
1835
1973
  /** Comparisons interned by operand representations and equality semantics. */
1836
1974
  equalityHelpers = new Map();
1837
1975
  /** Synthetic array-HOF loop functions (map/filter/forEach desugar),
@@ -1882,6 +2020,8 @@ export class Lowerer {
1882
2020
  /** Generated value helpers, keyed by operation and type. Callers own
1883
2021
  * their key prefixes; this includes more than structural conversions. */
1884
2022
  valueHelpers = new Map();
2023
+ /** Each name keyedHelperName made, with a second hash of its key. */
2024
+ keyedNameKeys = new Map();
1885
2025
  /** structuralNarrowing's assignable classes, keyed by static and
1886
2026
  * narrowed class name. */
1887
2027
  structuralClassPeers = new Map();
@@ -1996,13 +2136,16 @@ export class Lowerer {
1996
2136
  * `doneLocalId` is sticky: once next() observes the end, later source
1997
2137
  * changes do not revive the exhausted iterator, exactly like Node. */
1998
2138
  numericIterators = new Map();
1999
- chainCounter = 0;
2000
2139
  /** Keyed by program-wide qualified class name (what IR object types carry). */
2001
2140
  classes = new Map();
2002
2141
  classBySymbol = new Map();
2003
2142
  /** Named method slots observed before class collection need a callable
2004
2143
  * ABI and shared prototype descriptors instead of call-site specialization. */
2005
2144
  prototypeMethodAccesses = new Map();
2145
+ /** Whether the program reads `Error.prototype`, the checked-dynamic
2146
+ * object an ES5 constructor function can inherit from: only then can a
2147
+ * value that is not an Error instance be `instanceof Error`. */
2148
+ errorPrototypeValues = false;
2006
2149
  /** Well-known symbol methods (`sym:iterator`) the program may replace
2007
2150
  * through a symbol-keyed write: an instance or prototype property, or a
2008
2151
  * reflection call. */
@@ -2067,10 +2210,16 @@ export class Lowerer {
2067
2210
  /** Inline Promise.then parameters whose contextual type is a builtin
2068
2211
  * module namespace anonymous object. The settled native token is the
2069
2212
  * ABI truth even when the checker type has no stable module symbol. */
2070
- /** Receivers of a stream call on a Hash or Hmac (lowerHashStreamCall):
2071
- * for the duration of that call, the receiver lowers to the Transform of
2072
- * the value held in the named local. */
2073
- hashStreamReceivers = new Map();
2213
+ /** Receivers of a stream call on a Hash, Hmac, Cipheriv or Decipheriv
2214
+ * (lowerHashStreamCall): for the duration of that call, the receiver
2215
+ * lowers to the Transform of the value held in the named local. */
2216
+ valueStreamReceivers = new Map();
2217
+ /** fs call arguments evaluated ahead of a URL path's conversion
2218
+ * (builtins/fs-paths.ts): each lowers to the hidden local that holds its
2219
+ * value, which is null until the path's lowering has saved it. */
2220
+ stagedArguments = new Map();
2221
+ /** The staged arguments that follow each such URL path, in order. */
2222
+ stagedAfterPath = new Map();
2074
2223
  moduleNsParamOverrides = new Map();
2075
2224
  /** File → qualifier prefix: "" for the entry, "%mI." otherwise. */
2076
2225
  fileTag = new Map();
@@ -2185,6 +2334,10 @@ export class Lowerer {
2185
2334
  // top level, top = the innermost nested function currently lowering).
2186
2335
  fnStack = [];
2187
2336
  liftedFns = [];
2337
+ /** The first lifted function of each name (liftedFnNamed), for the
2338
+ * liftedFns indexed so far. liftedFns only grows. */
2339
+ liftedFnsByName = new Map();
2340
+ liftedFnsIndexed = 0;
2188
2341
  /** Runtime-provided classes used as values (defineClassValueConstruct),
2189
2342
  * by IR class name. */
2190
2343
  runtimeClassValues = new Map();
@@ -2192,7 +2345,49 @@ export class Lowerer {
2192
2345
  * dispatch revision needs no weak-key identity or process-global state. */
2193
2346
  errorMethodDispatchRevision = null;
2194
2347
  errorPropertyDispatchRevision = null;
2195
- lambdaCounter = 0;
2348
+ /** Structural source positions (structural-positions.ts) for names that
2349
+ * stay the same when unrelated code moves. */
2350
+ /** Files are named by their path relative to the entry's directory, so
2351
+ * names do not depend on where the program sits, and default library
2352
+ * files by their base name: two checkers install them in different
2353
+ * directories. */
2354
+ positions = new StructuralPositions((sf) => this.program.isSourceFileDefaultLibrary(sf)
2355
+ ? `lib:${sf.fileName.slice(sf.fileName.lastIndexOf("/") + 1)}`
2356
+ : relative(dirname(this.entry.fileName), sf.fileName));
2357
+ /** The outermost node whose token span is exactly `loc`, or null. */
2358
+ nodeAtLoc(loc) {
2359
+ const sf = this.program.getSourceFile(loc.file);
2360
+ return sf === undefined ? null : (ts.nodeAtSpan(sf, loc.start, loc.end) ?? null);
2361
+ }
2362
+ /** The lowering unit whose name scopes the closures it lifts. */
2363
+ closureRoot = "%pre";
2364
+ closureNameCounts = new Map();
2365
+ /** Runs `fn` with the closures it lifts named under `root`. */
2366
+ withClosureRoot(root, fn) {
2367
+ const previous = this.closureRoot;
2368
+ this.closureRoot = root;
2369
+ try {
2370
+ return fn();
2371
+ }
2372
+ finally {
2373
+ this.closureRoot = previous;
2374
+ }
2375
+ }
2376
+ /** The name of a closure (or wrapper) lifted for the source at `loc`:
2377
+ * `<prefix>.<hash>` of the current lowering unit, the location and
2378
+ * `suffix`, then `suffix`. A unit that lifts several functions for the same
2379
+ * location and suffix numbers them in the order it lifts them, so a
2380
+ * closure's name depends only on its unit, not on which units lowered
2381
+ * before it. */
2382
+ closureName(loc, suffix = "", prefix = "%fn") {
2383
+ const node = this.nodeAtLoc(loc);
2384
+ const where = node === null ? `${loc.file}:${loc.start}:${loc.end}` : this.positions.of(node);
2385
+ const key = `${prefix}|${this.closureRoot}|${where}|${suffix}`;
2386
+ const first = keyedHelperName(this, prefix, key);
2387
+ const seen = this.closureNameCounts.get(first) ?? 0;
2388
+ this.closureNameCounts.set(first, seen + 1);
2389
+ return (seen === 0 ? first : keyedHelperName(this, prefix, `${key}|${seen}`)) + suffix;
2390
+ }
2196
2391
  preparedClassFactories = new Map();
2197
2392
  preparingClassFactories = new Set();
2198
2393
  /** Statement lists currently mid-lowering, innermost last: the forward-
@@ -2244,6 +2439,10 @@ export class Lowerer {
2244
2439
  * can contain any retained descendant, but importing its declaration
2245
2440
  * alone does not make every descendant constructible. */
2246
2441
  constructedClasses = null;
2442
+ /** Classes added to some ClassInfo's subclasses (lower-classes.ts). With
2443
+ * the class and constructed-class counts, it tells caches over the class
2444
+ * graph when the graph changed. */
2445
+ subclassLinks = 0;
2247
2446
  /** Set while a subclass constructor's super() call notes its base
2248
2447
  * constructor edge: that edge does not instantiate the base exactly. */
2249
2448
  superConstructorEdge = false;
@@ -2257,6 +2456,136 @@ export class Lowerer {
2257
2456
  info.genericInstance !== undefined ||
2258
2457
  info.mixinInstance !== undefined);
2259
2458
  }
2459
+ /** How many classes classCanBeConstructed admits by name, or -1 while
2460
+ * it admits every class. The count only grows. */
2461
+ constructedClassCount() {
2462
+ return this.constructedClasses?.size ?? -1;
2463
+ }
2464
+ /** Helpers that every site asking for them shares (shareHelper). */
2465
+ sharedHelpers = new Set();
2466
+ sharedHelperNames = new Set();
2467
+ /** Marks a helper, or the lifted helpers of a name, as shared by every
2468
+ * site that asks for it. A shared helper is built for whichever site asks
2469
+ * first, so once lowering finishes its locations are replaced by one that
2470
+ * names no site. */
2471
+ shareHelper(helper) {
2472
+ if (typeof helper === "string")
2473
+ this.sharedHelperNames.add(helper);
2474
+ else
2475
+ this.sharedHelpers.add(helper);
2476
+ }
2477
+ /** Gives each shared helper (those marked by shareHelper, and those
2478
+ * interned by key in the helper tables) one location for all its nodes:
2479
+ * the earliest site in `functions` that uses it, by file and position, so
2480
+ * reports such as --explain-dynamic point at a use whatever order bodies
2481
+ * lowered in. A helper used only by other shared helpers takes their
2482
+ * location; one with no use takes the entry file's start. */
2483
+ settleSharedHelperLocations(functions) {
2484
+ const interned = new Set([...this.sharedHelperNames, ...this.classMethodValueHelpers]);
2485
+ for (const table of [
2486
+ this.equalityHelpers,
2487
+ this.arrHofHelpers,
2488
+ this.unionCallHelpers,
2489
+ this.valueHelpers,
2490
+ this.assertHelpers,
2491
+ this.inspectHelpers,
2492
+ this.iterDrainHelpers,
2493
+ this.mapHofHelpers,
2494
+ this.setHofHelpers,
2495
+ this.spHofHelpers,
2496
+ this.primitiveCtorFns,
2497
+ this.builtinCallableValueFns,
2498
+ this.regionRunHelpers,
2499
+ this.internTableHelpers,
2500
+ this.coercions.retags,
2501
+ this.coercions.narrows,
2502
+ ])
2503
+ for (const name of table.values())
2504
+ interned.add(name);
2505
+ for (const fn of [...this.liftedFns, ...this.implicitFns])
2506
+ if (interned.has(fn.name))
2507
+ this.sharedHelpers.add(fn);
2508
+ if (this.sharedHelpers.size === 0)
2509
+ return;
2510
+ const shared = new Map([...this.sharedHelpers].map((fn) => [fn.name, fn]));
2511
+ const earlier = (left, right) => left.file < right.file || (left.file === right.file && left.start < right.start);
2512
+ // The earliest use of each shared helper outside the shared helpers, and
2513
+ // which shared helpers each shared helper uses.
2514
+ const uses = new Map();
2515
+ const usedBy = new Map();
2516
+ for (const fn of functions) {
2517
+ const inShared = shared.has(fn.name) ? fn.name : undefined;
2518
+ everyStmtList(fn.body, {
2519
+ stmt: () => true,
2520
+ expr: (expr) => {
2521
+ const name = expr.kind === "call" ? expr.callee : exprFunctionReference(expr);
2522
+ if (name === undefined || name === inShared || !shared.has(name))
2523
+ return true;
2524
+ if (inShared !== undefined) {
2525
+ let users = usedBy.get(name);
2526
+ if (users === undefined)
2527
+ usedBy.set(name, (users = new Set()));
2528
+ users.add(inShared);
2529
+ }
2530
+ else {
2531
+ const current = uses.get(name);
2532
+ if (current === undefined || earlier(expr.loc, current))
2533
+ uses.set(name, expr.loc);
2534
+ }
2535
+ return true;
2536
+ },
2537
+ });
2538
+ }
2539
+ // Helpers reached only through other shared helpers take the earliest
2540
+ // location among those, to a fixed point.
2541
+ for (let changed = true; changed;) {
2542
+ changed = false;
2543
+ for (const [name, users] of usedBy) {
2544
+ for (const user of users) {
2545
+ const loc = uses.get(user);
2546
+ const current = uses.get(name);
2547
+ if (loc !== undefined && (current === undefined || earlier(loc, current))) {
2548
+ uses.set(name, loc);
2549
+ changed = true;
2550
+ }
2551
+ }
2552
+ }
2553
+ }
2554
+ const fallback = { file: this.entry.fileName, start: 0, end: 0 };
2555
+ for (const fn of this.sharedHelpers) {
2556
+ const use = uses.get(fn.name) ?? fallback;
2557
+ const loc = { file: use.file, start: use.start, end: use.end };
2558
+ const seen = new Set();
2559
+ const visit = (node) => {
2560
+ if (typeof node !== "object" || node === null || seen.has(node))
2561
+ return;
2562
+ seen.add(node);
2563
+ if (Array.isArray(node)) {
2564
+ for (const item of node)
2565
+ visit(item);
2566
+ return;
2567
+ }
2568
+ const record = node;
2569
+ for (const key of Object.keys(record)) {
2570
+ if (key === "loc")
2571
+ record[key] = loc;
2572
+ else if (key !== "type")
2573
+ visit(record[key]);
2574
+ }
2575
+ };
2576
+ visit(fn);
2577
+ }
2578
+ }
2579
+ /** The first lifted function named `name`, the one
2580
+ * `liftedFns.find((fn) => fn.name === name)` returns. */
2581
+ liftedFnNamed(name) {
2582
+ for (; this.liftedFnsIndexed < this.liftedFns.length; this.liftedFnsIndexed++) {
2583
+ const fn = this.liftedFns[this.liftedFnsIndexed];
2584
+ if (!this.liftedFnsByName.has(fn.name))
2585
+ this.liftedFnsByName.set(fn.name, fn);
2586
+ }
2587
+ return name === undefined ? undefined : this.liftedFnsByName.get(name);
2588
+ }
2260
2589
  /** Coverage remainder mode: the reachability gate inverts (see wantBody)
2261
2590
  * and no module is built. */
2262
2591
  remainder;
@@ -2410,6 +2739,7 @@ export class Lowerer {
2410
2739
  this.checker = program.getTypeChecker();
2411
2740
  this.typeCtx = {
2412
2741
  checker: this.checker,
2742
+ positionOf: (node) => this.positions.of(node),
2413
2743
  shapes: this.shapes,
2414
2744
  unions: this.unions,
2415
2745
  classNamer: this.classNamer,
@@ -2418,6 +2748,9 @@ export class Lowerer {
2418
2748
  isErasing: () => this.erasingDepth > 0,
2419
2749
  genericClassInstance: (decl, ref, mapArgument) => this.genericClassInstanceType(decl, ref, mapArgument),
2420
2750
  runtimeClassValue: (type) => runtimeClassValueOfType(this, type),
2751
+ localClassValue: (type) => this.instanceResultClass !== null && this.instanceResultClass.declared === type.id
2752
+ ? this.instanceResultClass.value
2753
+ : (this.localClassValueTypes.get(type.id) ?? null),
2421
2754
  mixinClassInstance: (decl) => this.mixinTypeContext && this.mixinTypeContext.classNode === decl
2422
2755
  ? { kind: "object", className: this.mixinTypeContext.className }
2423
2756
  : null,
@@ -2535,16 +2868,17 @@ export class Lowerer {
2535
2868
  /** Declared class fields may store a DYN value only when its static type
2536
2869
  * is `unknown` or `object` (also with `null` or `undefined`, or an array
2537
2870
  * of those), names checked protocol identity, is an owned runtime
2538
- * handle (a Worker or MessagePort, or a fetch Headers/Request/Response),
2539
- * or is a WeakMap/WeakSet (native weak collections live in
2540
- * checked-dynamic storage, as locals of those types do); `any` fields
2541
- * stay refused. */
2871
+ * handle (a Worker or MessagePort, a fetch Headers/Request/Response, or
2872
+ * a node:crypto ECDH, DiffieHellman or DiffieHellmanGroup), or is a
2873
+ * WeakMap/WeakSet (native weak collections live in checked-dynamic
2874
+ * storage, as locals of those types do); `any` fields stay refused. */
2542
2875
  classFieldStoresDyn(type) {
2543
2876
  return (this.opaqueValueType(type) ||
2544
2877
  this.classImplementedProtocol(type) ||
2545
2878
  isWorkerHandleType(type, this.typeCtx) ||
2546
2879
  isFetchHandleType(type, this.typeCtx) ||
2547
- this.weakCollectionType(type));
2880
+ this.weakCollectionType(type) ||
2881
+ this.stdlibHandleType(type, (part) => isEcdhType(this, part) || isDiffieHellmanType(this, part)));
2548
2882
  }
2549
2883
  /** A stdlib WeakMap or WeakSet, alone or with `null`/`undefined`. */
2550
2884
  weakCollectionType(type) {
@@ -2554,11 +2888,15 @@ export class Lowerer {
2554
2888
  (symbol !== undefined && ts.symbolName(symbol) === "WeakSet")) &&
2555
2889
  symbol.declarations.some((d) => ts.isInterfaceDeclaration(d) && this.isStdlibFile(ts.getSourceFileOfNode(d))));
2556
2890
  };
2891
+ return this.stdlibHandleType(type, weak);
2892
+ }
2893
+ /** A type `handle` accepts, alone or with `null`/`undefined`. */
2894
+ stdlibHandleType(type, handle) {
2557
2895
  if (!type.isUnionType())
2558
- return weak(type);
2896
+ return handle(type);
2559
2897
  const parts = ts.constituentTypes(type);
2560
- return (parts.some(weak) &&
2561
- parts.every((part) => (part.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0 || weak(part)));
2898
+ return (parts.some(handle) &&
2899
+ parts.every((part) => (part.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0 || handle(part)));
2562
2900
  }
2563
2901
  /** `unknown`, `object`, an array of those, or a union of those with
2564
2902
  * `null` and `undefined`: types whose values use checked-dynamic storage
@@ -2640,8 +2978,8 @@ export class Lowerer {
2640
2978
  }
2641
2979
  return false;
2642
2980
  })()
2643
- ? this.qualify(ts.getSourceFileOfNode(decl), `%cx${ts.tokenStartOfNode(decl)}.${decl.name?.text ?? ""}`)
2644
- : this.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(decl) + (decl.name ? decl.name.text : "%anon"));
2981
+ ? this.qualify(ts.getSourceFileOfNode(decl), `%cx${positionTag(this, decl)}.${decl.name?.text ?? ""}`)
2982
+ : this.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(this, decl) + (decl.name ? decl.name.text : "%anon"));
2645
2983
  for (let index = this.localClassInstantiations.length - 1; index >= 0; index--) {
2646
2984
  const entry = this.localClassInstantiations[index];
2647
2985
  for (let parent = decl.parent; parent && !ts.isSourceFile(parent); parent = parent.parent) {
@@ -3730,11 +4068,16 @@ export class Lowerer {
3730
4068
  // resolveValueSymbol also flushes deferred diagnostics and applies
3731
4069
  // merged-namespace fences, whose authority remains ordinary lowering.
3732
4070
  this.checker.prefetchSymbolRoots(sourceFiles, true);
4071
+ // The facts each fixed-point site reads, by the symbols, nodes and
4072
+ // element keys they belong to (created with the site list below).
4073
+ let siteDependencies = null;
3733
4074
  const symbolOf = (node) => {
3734
4075
  const s = this.checker.getSymbolAtLocation(node);
3735
4076
  if (!s)
3736
4077
  return null;
3737
- return s.flags & ts.SymbolFlags.Alias ? this.checker.getAliasedSymbol(s) : s;
4078
+ const symbol = s.flags & ts.SymbolFlags.Alias ? this.checker.getAliasedSymbol(s) : s;
4079
+ siteDependencies?.read(symbol);
4080
+ return symbol;
3738
4081
  };
3739
4082
  const signatureOf = (node) => {
3740
4083
  const symbol = symbolOf(node);
@@ -3902,8 +4245,11 @@ export class Lowerer {
3902
4245
  const callableSymbols = new Map();
3903
4246
  const callableSymbolOf = (node) => {
3904
4247
  const cached = callableSymbols.get(node);
3905
- if (cached !== undefined)
4248
+ if (cached !== undefined) {
4249
+ if (cached !== null)
4250
+ siteDependencies?.read(cached);
3906
4251
  return cached;
4252
+ }
3907
4253
  let symbol = symbolOf(ts.isPropertyAccessExpression(node) ? node.name : node);
3908
4254
  if (symbol === null || signatureBySymbol.has(symbol)) {
3909
4255
  callableSymbols.set(node, symbol);
@@ -4205,12 +4551,17 @@ export class Lowerer {
4205
4551
  return true;
4206
4552
  if (ts.isPropertyAccessExpression(e) && isOptionalProcessStreamProperty(this, e))
4207
4553
  return true;
4554
+ if (isOptionalProcessVersionsRead(this, e))
4555
+ return true;
4208
4556
  if (ts.isPropertyAccessExpression(e) && isSettledIteratorValueRead(this, e))
4209
4557
  return true;
4210
4558
  if (ts.isPropertyAccessExpression(e) && isOsConstantsSymbol(symbolOf(e.expression), this))
4211
4559
  return true;
4212
- if (ts.isCallExpression(e) && this.runtimeOptionalReduceTypes.has(e))
4213
- return true;
4560
+ if (ts.isCallExpression(e)) {
4561
+ siteDependencies?.read(e);
4562
+ if (this.runtimeOptionalReduceTypes.has(e))
4563
+ return true;
4564
+ }
4214
4565
  if (ts.isCallExpression(e) &&
4215
4566
  e.arguments.nodes.length === 0 &&
4216
4567
  ts.isPropertyAccessExpression(e.expression) &&
@@ -4501,22 +4852,38 @@ export class Lowerer {
4501
4852
  /** `const { a, b } = table` over an index-signature record: a name that
4502
4853
  * is not a declared field reads the index signature and can be
4503
4854
  * missing. */
4504
- const scanRecordPattern = (name, init) => {
4505
- const sourceType = this.mapTypeOf(this.typeOf(init));
4855
+ const scanRecordPattern = (name, init, sourceType = this.mapTypeOf(this.typeOf(init))) => {
4506
4856
  if (sourceType?.kind !== "record")
4507
4857
  return false;
4508
4858
  const shape = this.shapes.get(sourceType.shapeId);
4509
- const indexValue = shape?.indexValue;
4510
- if (!shape || shape.tuple || !indexValue || indexValue.kind === "dyn")
4859
+ if (!shape || shape.tuple)
4511
4860
  return false;
4861
+ const indexValue = shape.indexValue;
4512
4862
  let changed = false;
4513
4863
  for (const el of name.elements.nodes) {
4864
+ // A nested pattern reads its element the same way
4865
+ // (`const { limits: { [key]: limit } } = config`).
4866
+ if (!el.dotDotDotToken && el.name !== undefined && ts.isObjectBindingPattern(el.name)) {
4867
+ if (scanRecordPattern(el.name, init, this.mapTypeOf(this.typeOf(el.name))))
4868
+ changed = true;
4869
+ continue;
4870
+ }
4871
+ if (!indexValue || indexValue.kind === "dyn")
4872
+ continue;
4514
4873
  if (el.dotDotDotToken || el.initializer || !ts.isIdentifier(el.name))
4515
4874
  continue;
4516
4875
  const key = el.propertyName ?? el.name;
4517
- if (!ts.isIdentifier(key) && !ts.isStringLiteral(key) && !ts.isNumericLiteral(key))
4876
+ // A computed key that folds to one name reads like that name; a
4877
+ // runtime key reads the entry of a record with no declared fields
4878
+ // (runtimeKeyPatternRead), which can be missing too.
4879
+ const keyName = ts.isComputedPropertyName(key)
4880
+ ? this.foldedStringKeyOf(key.expression)
4881
+ : ts.isIdentifier(key) || ts.isStringLiteral(key) || ts.isNumericLiteral(key)
4882
+ ? key.text
4883
+ : undefined;
4884
+ if (keyName === undefined)
4518
4885
  continue;
4519
- if (shape.fields.some((field) => field.name === key.text))
4886
+ if (keyName === null ? shape.fields.length > 0 : shape.fields.some((f) => f.name === keyName))
4520
4887
  continue;
4521
4888
  const symbol = symbolOf(el.name);
4522
4889
  if (!symbol || optionalSymbols.has(symbol))
@@ -4699,6 +5066,7 @@ export class Lowerer {
4699
5066
  if (fnType?.kind === "func" && bodyReturnsOptional(fn)) {
4700
5067
  const widenedReturn = this.runtimeOptionalType(fnType.ret);
4701
5068
  provenance?.note("callback-return", fn, provenanceSite);
5069
+ siteDependencies?.read(fn);
4702
5070
  const previousReturn = this.runtimeOptionalFunctionReturnType(fn, fnType.ret);
4703
5071
  this.runtimeOptionalFunctionReturns.set(fn, widenedReturn);
4704
5072
  if (!typeEquals(previousReturn, widenedReturn))
@@ -4941,8 +5309,11 @@ export class Lowerer {
4941
5309
  const key = typeKey(arm.elem);
4942
5310
  if (arm.elem.kind === "union"
4943
5311
  ? this.armTag(arm.elem.unionId, UNDEFINED_T) >= 0
4944
- : isUnitType(arm.elem) || arm.elem.kind === "void")
5312
+ : isUnitType(arm.elem) || arm.elem.kind === "void") {
5313
+ if (!optionalElementKeys.has(key))
5314
+ siteDependencies?.changed(key);
4945
5315
  optionalElementKeys.add(key);
5316
+ }
4946
5317
  keys.push(key);
4947
5318
  }
4948
5319
  return keys;
@@ -5054,7 +5425,10 @@ export class Lowerer {
5054
5425
  return keys;
5055
5426
  };
5056
5427
  const elementStates = new ArrayElementStates({
5057
- elementAdmitsUndefined: (key) => optionalElementKeys.has(key),
5428
+ elementAdmitsUndefined: (key) => {
5429
+ siteDependencies?.read(key);
5430
+ return optionalElementKeys.has(key);
5431
+ },
5058
5432
  ownerOf: (node) => ownership.ownerOf(node),
5059
5433
  allocationOwner: (node) => ownership.allocationOwner(node),
5060
5434
  arrayKeys: arrayKeysOf,
@@ -5129,6 +5503,8 @@ export class Lowerer {
5129
5503
  note: provenance
5130
5504
  ? (fact, key, site) => provenance.note(`element-${fact}`, site, site, key)
5131
5505
  : null,
5506
+ read: (fact) => siteDependencies?.read(fact),
5507
+ changed: (fact) => siteDependencies?.changed(fact),
5132
5508
  });
5133
5509
  // Each pass revisits every array callback site; the last visit holds
5134
5510
  // the decision at the fixed point.
@@ -5143,6 +5519,7 @@ export class Lowerer {
5143
5519
  const nodes = [];
5144
5520
  ts.walkPreorder(sf, (node) => {
5145
5521
  if (ts.isVariableDeclaration(node) ||
5522
+ (ts.isParameter(node) && ts.isObjectBindingPattern(node.name)) ||
5146
5523
  ts.isBinaryExpression(node) ||
5147
5524
  ts.isCallExpression(node) ||
5148
5525
  ts.isNewExpression(node) ||
@@ -5164,6 +5541,12 @@ export class Lowerer {
5164
5541
  changed = true;
5165
5542
  if (ts.isForOfStatement(node))
5166
5543
  presentLoops.set(node, !elementStates.loopMayYieldUndefined(node));
5544
+ // A parameter pattern reads its argument like a declaration's
5545
+ // pattern reads its initializer.
5546
+ if (ts.isParameter(node) && ts.isObjectBindingPattern(node.name)) {
5547
+ if (scanRecordPattern(node.name, node, this.mapTypeOf(this.typeOf(node.name))))
5548
+ changed = true;
5549
+ }
5167
5550
  if (ts.isVariableDeclaration(node)) {
5168
5551
  if (node.initializer) {
5169
5552
  const result = optionalPrimitiveResultType(node.initializer);
@@ -5406,6 +5789,7 @@ export class Lowerer {
5406
5789
  if (promoteHofCallback(callback, [0, 1]))
5407
5790
  changed = true;
5408
5791
  const result = this.runtimeOptionalType(this.irTypeOf(node));
5792
+ siteDependencies?.read(node);
5409
5793
  const previous = this.runtimeOptionalReduceTypes.get(node);
5410
5794
  if (!previous || !typeEquals(previous, result)) {
5411
5795
  this.runtimeOptionalReduceTypes.set(node, result);
@@ -5463,6 +5847,7 @@ export class Lowerer {
5463
5847
  (this.typeOf(arg).flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Void)) === 0)
5464
5848
  continue;
5465
5849
  for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
5850
+ siteDependencies?.read(target);
5466
5851
  const shape = signatureBySymbol.get(target)?.params[i];
5467
5852
  if (!shape || shape.mode !== "required")
5468
5853
  continue;
@@ -5502,6 +5887,7 @@ export class Lowerer {
5502
5887
  if (!ts.isSpreadElement(arg) && shape && i !== restAt && fieldsOfValue(arg)) {
5503
5888
  const fields = fieldsOfValue(arg);
5504
5889
  for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
5890
+ siteDependencies?.read(target);
5505
5891
  const parameterShape = signatureBySymbol.get(target)?.params[i];
5506
5892
  const parameter = functionDeclBySymbol.get(target)?.parameters?.nodes[i];
5507
5893
  if (!parameterShape || parameterShape.type.kind !== "record")
@@ -5553,6 +5939,7 @@ export class Lowerer {
5553
5939
  // argument can make its elements undefined, not the pack.
5554
5940
  // Keep every virtual implementation on the same array ABI.
5555
5941
  for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
5942
+ siteDependencies?.read(target);
5556
5943
  const rest = signatureBySymbol.get(target)?.params[i];
5557
5944
  if (rest?.mode !== "rest" || rest.type.kind !== "array")
5558
5945
  continue;
@@ -5577,6 +5964,7 @@ export class Lowerer {
5577
5964
  // downstream calls and returns see the same optional value.
5578
5965
  const family = familyBySymbol.get(symbol);
5579
5966
  for (const target of family ?? [symbol]) {
5967
+ siteDependencies?.read(target);
5580
5968
  const parameterShape = signatureBySymbol.get(target)?.params[i];
5581
5969
  if (!parameterShape)
5582
5970
  continue;
@@ -5603,9 +5991,23 @@ export class Lowerer {
5603
5991
  });
5604
5992
  }
5605
5993
  };
5606
- for (const node of sitesOf(sf))
5607
- scan(node);
5608
- return changed;
5994
+ // A site whose facts are unchanged since its last visit would compute
5995
+ // that visit's result again, except in a full pass.
5996
+ const base = siteBase.get(sf);
5997
+ const dependencies = siteDependencies;
5998
+ const sites = sitesOf(sf);
5999
+ let fileChanged = false;
6000
+ for (let i = 0; i < sites.length; i++) {
6001
+ if (!fullPass && !dependencies.isStale(base + i))
6002
+ continue;
6003
+ changed = false;
6004
+ dependencies.begin(base + i);
6005
+ scan(sites[i]);
6006
+ dependencies.end(changed);
6007
+ if (changed)
6008
+ fileChanged = true;
6009
+ }
6010
+ return fileChanged;
5609
6011
  };
5610
6012
  const scanReturns = (symbol, decl) => {
5611
6013
  let changed = false;
@@ -5656,12 +6058,26 @@ export class Lowerer {
5656
6058
  optionalSymbols.add(symbol);
5657
6059
  this.earlyReadVars.add(symbol);
5658
6060
  }
5659
- let changed = true;
5660
- while (changed) {
6061
+ // Number the sites of every file. The first and the last pass visit
6062
+ // every site; the passes between visit only the sites whose facts
6063
+ // changed (SiteDependencies). When such a pass changes nothing, a full
6064
+ // pass confirms the fixed point, and the iteration resumes if it
6065
+ // changes a fact after all.
6066
+ const siteBase = new Map();
6067
+ let siteCount = 0;
6068
+ for (const sf of sourceFiles) {
6069
+ siteBase.set(sf, siteCount);
6070
+ siteCount += sitesOf(sf).length;
6071
+ }
6072
+ siteDependencies = new SiteDependencies(siteCount);
6073
+ let fullPass = true;
6074
+ for (let changed = true, first = true; changed || !fullPass; first = false) {
6075
+ fullPass = first || !changed;
5661
6076
  changed = false;
5662
6077
  for (const [symbol, field] of staticFieldsBySymbol) {
5663
6078
  if (!optionalSymbols.has(symbol) && mayBeOptional(field.initializer)) {
5664
6079
  optionalSymbols.add(symbol);
6080
+ siteDependencies.changed(symbol);
5665
6081
  provenance?.note("static-field", field.initializer.parent, field.initializer);
5666
6082
  changed = true;
5667
6083
  }
@@ -5669,15 +6085,19 @@ export class Lowerer {
5669
6085
  for (const sf of sourceFiles)
5670
6086
  if (scanFile(sf))
5671
6087
  changed = true;
5672
- for (const [symbol, decl] of functionDeclBySymbol)
5673
- if (scanReturns(symbol, decl))
5674
- changed = true;
6088
+ for (const [symbol, decl] of functionDeclBySymbol) {
6089
+ if (!scanReturns(symbol, decl))
6090
+ continue;
6091
+ siteDependencies.changed(symbol);
6092
+ changed = true;
6093
+ }
5675
6094
  const noteGenericReturn = (symbol, decl) => {
5676
6095
  if (optionalReturns.has(symbol) || isJsSourceFile(ts.getSourceFileOfNode(decl)))
5677
6096
  return;
5678
6097
  if (!returnsOf(decl).some(genericMayBeOptional))
5679
6098
  return;
5680
6099
  optionalReturns.add(symbol);
6100
+ siteDependencies.changed(symbol);
5681
6101
  this.runtimeOptionalGenericReturns.add(decl);
5682
6102
  provenance?.note("return", decl.name ?? decl, decl);
5683
6103
  changed = true;
@@ -5715,6 +6135,7 @@ export class Lowerer {
5715
6135
  : previous;
5716
6136
  if (!typeEquals(previous, next)) {
5717
6137
  this.runtimeOptionalFunctionReturns.set(fn, next);
6138
+ siteDependencies.changed(fn);
5718
6139
  provenance?.note("lambda-return", fn, fn.body);
5719
6140
  changed = true;
5720
6141
  }
@@ -5730,11 +6151,13 @@ export class Lowerer {
5730
6151
  if (symbol && next.kind === "union" && this.armTag(next.unionId, UNDEFINED_T) >= 0) {
5731
6152
  if (!optionalReturns.has(symbol)) {
5732
6153
  optionalReturns.add(symbol);
6154
+ siteDependencies.changed(symbol);
5733
6155
  changed = true;
5734
6156
  }
5735
6157
  }
5736
6158
  else if (symbol && !arithmeticReturns.has(symbol)) {
5737
6159
  arithmeticReturns.set(symbol, next);
6160
+ siteDependencies.changed(symbol);
5738
6161
  changed = true;
5739
6162
  }
5740
6163
  }
@@ -5753,6 +6176,7 @@ export class Lowerer {
5753
6176
  : this.runtimeOptionalType(previous);
5754
6177
  if (!typeEquals(previous, next)) {
5755
6178
  this.runtimeOptionalFunctionReturns.set(fn, next);
6179
+ siteDependencies.changed(fn);
5756
6180
  changed = true;
5757
6181
  }
5758
6182
  }
@@ -5767,6 +6191,7 @@ export class Lowerer {
5767
6191
  for (const symbol of optional ? family : []) {
5768
6192
  if (!optionalReturns.has(symbol)) {
5769
6193
  optionalReturns.add(symbol);
6194
+ siteDependencies.changed(symbol);
5770
6195
  provenance?.note("return", functionDeclBySymbol.get(symbol), undefined, "(override family)");
5771
6196
  changed = true;
5772
6197
  }
@@ -5783,10 +6208,14 @@ export class Lowerer {
5783
6208
  if (previous && typeEquals(previous, joined))
5784
6209
  continue;
5785
6210
  arithmeticReturns.set(symbol, joined);
6211
+ siteDependencies.changed(symbol);
5786
6212
  changed = true;
5787
6213
  }
5788
6214
  }
5789
6215
  }
6216
+ // The site facts serve only the fixed point; release them for the rest
6217
+ // of lowering.
6218
+ siteDependencies = null;
5790
6219
  // NaN-coded slots convert optional values on entry instead of holding
5791
6220
  // the union, so promotion never applies to them.
5792
6221
  for (const symbol of [...optionalSymbols])
@@ -6140,7 +6569,7 @@ export class Lowerer {
6140
6569
  for (const decl of fp.classDecls) {
6141
6570
  const info = this.classes.get(this.classNamer(decl));
6142
6571
  if (info)
6143
- functions.push(...this.lowerClassMembers(info));
6572
+ functions.push(...this.withClosureRoot(info.def.name, () => this.lowerClassMembers(info)));
6144
6573
  else if (this.countsSkips())
6145
6574
  this.countSkippedBody(decl);
6146
6575
  }
@@ -6153,7 +6582,8 @@ export class Lowerer {
6153
6582
  // are reachable by definition, already counted by reachable emit.
6154
6583
  if (!this.remainder) {
6155
6584
  for (const fp of parts) {
6156
- functions.push(this.lowerFileInit(fp.sf, fp.topStmts, this.initNameOf.get(fp.sf)));
6585
+ const initName = this.initNameOf.get(fp.sf);
6586
+ functions.push(this.withClosureRoot(initName, () => this.lowerFileInit(fp.sf, fp.topStmts, initName)));
6157
6587
  }
6158
6588
  functions.push(this.buildMain());
6159
6589
  }
@@ -6193,7 +6623,7 @@ export class Lowerer {
6193
6623
  // default): the diagnostic is recorded — the instance skips
6194
6624
  // like a signature-blocked function (lowerFunction's rule).
6195
6625
  try {
6196
- functions.push(this.lowerGenericInstance(info, inst));
6626
+ functions.push(this.withClosureRoot(inst.name, () => this.lowerGenericInstance(info, inst)));
6197
6627
  }
6198
6628
  catch (e) {
6199
6629
  if (!(e instanceof PoisonError))
@@ -6205,7 +6635,8 @@ export class Lowerer {
6205
6635
  // instances of its own; the joint fixpoint covers both).
6206
6636
  while (es < this.emitSpecQueue.length) {
6207
6637
  try {
6208
- const fn = lowerEmitOverrideSpec(this, this.emitSpecQueue[es++]);
6638
+ const spec = this.emitSpecQueue[es++];
6639
+ const fn = this.withClosureRoot(emitSpecRoot(spec), () => lowerEmitOverrideSpec(this, spec));
6209
6640
  if (fn)
6210
6641
  functions.push(fn);
6211
6642
  }
@@ -6223,6 +6654,7 @@ export class Lowerer {
6223
6654
  // Lambdas lifted while lowering any of the above (plus synthetic
6224
6655
  // array-HOF loop functions, which ride the same list), and the
6225
6656
  // implicit-any instances lowered eagerly at their first call sites.
6657
+ this.settleSharedHelperLocations([...functions, ...this.liftedFns, ...this.implicitFns]);
6226
6658
  functions.push(...this.liftedFns);
6227
6659
  functions.push(...this.implicitFns);
6228
6660
  functions.push(...runtimeClassConstructs(this, functions));
@@ -6256,6 +6688,7 @@ export class Lowerer {
6256
6688
  finalizePrivateBrands(this, functions);
6257
6689
  trackClassFieldCreation(this, functions);
6258
6690
  guardClassAttributeWrites(this, functions);
6691
+ applyHandleProperties(this, functions);
6259
6692
  // Globals typed by a class that never REGISTERED (a JS class whose
6260
6693
  // collection fenced — Symbol-keyed fields, an unsupported base): the
6261
6694
  // declaration statement and every use compiled to runtime fences, but
@@ -6353,7 +6786,7 @@ export class Lowerer {
6353
6786
  classes: artifacts.classes,
6354
6787
  records: artifacts.records,
6355
6788
  unions: artifacts.unions,
6356
- globals: this.globalsList,
6789
+ globals: this.globalsInTableOrder(),
6357
6790
  entry: ENTRY_NAME,
6358
6791
  ...(this.usesWorkers ? { workers: true } : {}),
6359
6792
  ...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
@@ -6482,6 +6915,10 @@ export class Lowerer {
6482
6915
  * body; both fire edges through the same hooks and are not units
6483
6916
  * themselves. */
6484
6917
  emitReachable(extraRoots) {
6918
+ // Frontend passes below rewrite function bodies through the IR mapper
6919
+ // (caught-value and class dispatch); key-order notes follow the record
6920
+ // literals they rebuild until the witness pass has read them.
6921
+ observeRecordLiteralRebuilds((from, to) => this.keyOrder.follow(from, to));
6485
6922
  this.deferredModuleInitializers = new DeferredModuleInitializers();
6486
6923
  const parts = this.splitFiles();
6487
6924
  this.narrowing.setFiles(parts.map((fp) => fp.sf));
@@ -6734,7 +7171,8 @@ export class Lowerer {
6734
7171
  rank: [4, instanceMetadataOrder++],
6735
7172
  };
6736
7173
  this.genericClassDemandPriority.set(info, ref);
6737
- instanceFunctions.push(...this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.lowerClassMembers(info))));
7174
+ instanceFunctions.push(...this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.withClosureRoot(info.def.name, () => this.lowerClassMembers(info)))));
7175
+ relieveHeapPressure();
6738
7176
  }
6739
7177
  }
6740
7178
  while (instLowered < this.instantiationQueue.length) {
@@ -6753,7 +7191,8 @@ export class Lowerer {
6753
7191
  // Body-level poisons skip the instance after retaining the
6754
7192
  // diagnostic and every edge fired before poisoning.
6755
7193
  try {
6756
- instanceFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.lowerGenericInstance(info, inst))));
7194
+ instanceFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.withClosureRoot(inst.name, () => this.lowerGenericInstance(info, inst)))));
7195
+ relieveHeapPressure();
6757
7196
  }
6758
7197
  catch (e) {
6759
7198
  if (!(e instanceof PoisonError))
@@ -6766,12 +7205,21 @@ export class Lowerer {
6766
7205
  // exactly like generic instances.
6767
7206
  while (specLowered < this.emitSpecQueue.length) {
6768
7207
  const waveEnd = this.emitSpecQueue.length;
7208
+ // A wave's specializations lower by class and event, not in the
7209
+ // order bodies asked for them.
7210
+ const wave = this.emitSpecQueue.slice(specLowered, waveEnd);
7211
+ const specKey = ({ info, event }) => `${info.def.name}\0${event}`;
7212
+ wave.sort((left, right) => specKey(left) < specKey(right) ? -1 : specKey(left) > specKey(right) ? 1 : 0);
7213
+ this.emitSpecQueue.splice(specLowered, wave.length, ...wave);
6769
7214
  this.checker.prefetchRoots(this.emitSpecQueue
6770
7215
  .slice(specLowered, waveEnd)
6771
7216
  .flatMap(({ info }) => info.emitOverride ? functionRoots(info.emitOverride.decl) : []));
6772
7217
  while (specLowered < waveEnd) {
6773
7218
  try {
6774
- const fn = this.shapes.withDeclaredOrderPriority([4, instanceMetadataOrder++], () => lowerEmitOverrideSpec(this, this.emitSpecQueue[specLowered++]));
7219
+ const fn = this.shapes.withDeclaredOrderPriority([4, instanceMetadataOrder++], () => {
7220
+ const spec = this.emitSpecQueue[specLowered++];
7221
+ return this.withClosureRoot(emitSpecRoot(spec), () => lowerEmitOverrideSpec(this, spec));
7222
+ });
6775
7223
  if (fn)
6776
7224
  instanceFunctions.push(fn);
6777
7225
  }
@@ -6798,7 +7246,7 @@ export class Lowerer {
6798
7246
  parts.forEach((fp, index) => {
6799
7247
  const priority = [2, index];
6800
7248
  const owner = demandOwner(priority);
6801
- initFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.lowerFileInit(fp.sf, fp.topStmts, this.initNameOf.get(fp.sf)))));
7249
+ initFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(this.initNameOf.get(fp.sf), () => this.lowerFileInit(fp.sf, fp.topStmts, this.initNameOf.get(fp.sf))))));
6802
7250
  });
6803
7251
  // LIBRARY mode's extra reachability roots (LowerOptions.libRoots): the
6804
7252
  // profile-mapped exports are called from outside the graph, so they
@@ -6806,9 +7254,11 @@ export class Lowerer {
6806
7254
  // (the export-map resolution reports them as SC4002 later).
6807
7255
  for (const root of extraRoots ?? [])
6808
7256
  this.onEdge?.(root);
7257
+ const shuffle = lowerShuffle();
6809
7258
  const drainUnits = () => {
6810
7259
  while (queue.length > 0) {
6811
7260
  const wave = queue.splice(0);
7261
+ shuffle?.(wave);
6812
7262
  this.checker.prefetchRoots(wave.flatMap((name) => units.get(name).roots));
6813
7263
  for (const name of wave) {
6814
7264
  // A body-level poison outside the per-statement catches (a fenced
@@ -6819,9 +7269,10 @@ export class Lowerer {
6819
7269
  const unit = units.get(name);
6820
7270
  const priority = metadataPriority.get(name) ?? [3, expressionMetadataOrder++];
6821
7271
  const owner = demandOwner(priority);
6822
- const fn = this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, unit.lower));
7272
+ const fn = this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(name, unit.lower)));
6823
7273
  if (fn)
6824
7274
  loweredUnits.set(name, fn);
7275
+ relieveHeapPressure();
6825
7276
  }
6826
7277
  catch (e) {
6827
7278
  if (!(e instanceof PoisonError))
@@ -6837,22 +7288,29 @@ export class Lowerer {
6837
7288
  // turn queue more instances. Continue to the joint fixpoint; the initial
6838
7289
  // queue above is the only portion whose discovery order differed from
6839
7290
  // historical emit order.
7291
+ noteDateClassMethods(this);
6840
7292
  const classDispatch = new ClassDynamicDispatch(extraRoots !== undefined);
7293
+ // Units in declaration order, so the passes below meet functions, and the
7294
+ // classes they collect, in an order that does not depend on lowering order.
7295
+ const unitsInOrder = () => [...loweredUnits]
7296
+ .sort(([left], [right]) => units.get(left).order - units.get(right).order)
7297
+ .map(([, fn]) => fn);
6841
7298
  for (;;) {
6842
7299
  drainInstances();
7300
+ const declared = unitsInOrder();
6843
7301
  const initializerChanged = this.deferredModuleInitializers.process(this, [
6844
- ...loweredUnits.values(),
7302
+ ...declared,
6845
7303
  ...initFunctions,
6846
7304
  ...instanceFunctions,
6847
- ...this.liftedFns,
6848
- ...this.implicitFns,
6849
- ]);
7305
+ ...byName(this.liftedFns),
7306
+ ...byName(this.implicitFns),
7307
+ ], (fn) => classDispatch.sites.forget(fn));
6850
7308
  const dispatchChanged = classDispatch.process(this, [
6851
- ...loweredUnits.values(),
7309
+ ...declared,
6852
7310
  ...initFunctions,
6853
7311
  ...instanceFunctions,
6854
- ...this.liftedFns,
6855
- ...this.implicitFns,
7312
+ ...byName(this.liftedFns),
7313
+ ...byName(this.implicitFns),
6856
7314
  ]);
6857
7315
  if (queue.length === 0 && !dispatchChanged && !initializerChanged)
6858
7316
  break;
@@ -6861,9 +7319,7 @@ export class Lowerer {
6861
7319
  this.restoreGenericClassInstanceOrder(clsInstLowered);
6862
7320
  }
6863
7321
  classDispatch.finalize(this);
6864
- const orderedUnits = [...loweredUnits]
6865
- .sort(([left], [right]) => units.get(left).order - units.get(right).order)
6866
- .map(([, fn]) => fn);
7322
+ const orderedUnits = unitsInOrder();
6867
7323
  this.settleGenericDemandPriorities();
6868
7324
  this.shapes.settleDeclaredOrderPriorities();
6869
7325
  for (const finalize of this.shapeOrderMetadataFinalizers)
@@ -6875,15 +7331,25 @@ export class Lowerer {
6875
7331
  ...this.liftedFns,
6876
7332
  ...this.implicitFns,
6877
7333
  ]);
7334
+ observeRecordLiteralRebuilds(null);
6878
7335
  for (const finalize of this.shapeOrderHelperFinalizers)
6879
7336
  finalize();
6880
- const functions = [
7337
+ this.settleSharedHelperLocations([
6881
7338
  ...orderedUnits,
6882
7339
  ...initFunctions,
6883
- this.buildMain(),
6884
7340
  ...instanceFunctions,
6885
7341
  ...this.liftedFns,
6886
7342
  ...this.implicitFns,
7343
+ ]);
7344
+ // Lifted and implicit functions are created in lowering order; they
7345
+ // are assembled by name.
7346
+ const functions = [
7347
+ ...orderedUnits,
7348
+ ...initFunctions,
7349
+ this.buildMain(),
7350
+ ...instanceFunctions,
7351
+ ...byName(this.liftedFns),
7352
+ ...byName(this.implicitFns),
6887
7353
  ];
6888
7354
  functions.push(...runtimeClassConstructs(this, functions));
6889
7355
  if (this.regexGroupResults)
@@ -7267,7 +7733,36 @@ export class Lowerer {
7267
7733
  fenceStaticReadableStreamMember(access, use) {
7268
7734
  return fenceStaticReadableStreamMember(this, access, use);
7269
7735
  }
7736
+ /** Whether `node` reads an anySymbols parameter, or a member, element or
7737
+ * call result of one: the error-path copy of a callback reads those as
7738
+ * `any`. */
7739
+ readsAnySymbol(node) {
7740
+ let base = node;
7741
+ for (;;) {
7742
+ if (ts.isPropertyAccessExpression(base) ||
7743
+ ts.isElementAccessExpression(base) ||
7744
+ ts.isNonNullExpression(base) ||
7745
+ ts.isParenthesizedExpression(base)) {
7746
+ base = base.expression;
7747
+ }
7748
+ else if (ts.isCallExpression(base) && ts.isPropertyAccessExpression(base.expression)) {
7749
+ base = base.expression.expression;
7750
+ }
7751
+ else {
7752
+ break;
7753
+ }
7754
+ }
7755
+ if (!ts.isIdentifier(base))
7756
+ return false;
7757
+ const parent = base.parent;
7758
+ const symbol = parent !== undefined && ts.isShorthandPropertyAssignment(parent) && parent.name === base
7759
+ ? this.checker.getShorthandAssignmentValueSymbol(parent)
7760
+ : this.checker.getSymbolAtLocation(base);
7761
+ return symbol !== undefined && this.anySymbols.has(symbol);
7762
+ }
7270
7763
  typeOf(node) {
7764
+ if (this.anySymbols.size > 0 && this.readsAnySymbol(node))
7765
+ return this.checker.getAnyType();
7271
7766
  if (ts.isPropertyAccessExpression(node) && isJsSourceFile(ts.getSourceFileOfNode(node))) {
7272
7767
  const receiver = node.expression.kind === ts.SyntaxKind.ThisKeyword && this.fnStack.length > 0
7273
7768
  ? this.resolveThis()?.type
@@ -7542,8 +8037,9 @@ export class Lowerer {
7542
8037
  /** The ts-level twin of typeParamResolver: the bound CHECKER type of a
7543
8038
  * type parameter in the current instantiation (typeParamTsBindings), for
7544
8039
  * the resolutions where mapType's widening already dropped what the body
7545
- * needs (indexed accesses over literal-bound keys). Inert outside
7546
- * call-keyed generic instantiation. */
8040
+ * needs (indexed accesses over literal-bound keys, conditional types
8041
+ * over literal arguments). Inert outside generic function and class
8042
+ * instantiation. */
7547
8043
  typeParamTsResolver = (t) => {
7548
8044
  if (!this.typeParamTsBindings || !(t.flags & ts.TypeFlags.TypeParameter))
7549
8045
  return null;
@@ -7861,7 +8357,32 @@ export class Lowerer {
7861
8357
  }
7862
8358
  // A runtime-provided class value has no checked-dynamic form that
7863
8359
  // inspects as Node's does (`[Function: EventEmitter] { ... }`).
8360
+ // JavaScript sources already read EventEmitter and the stream
8361
+ // classes as the runtime's untyped constructors (builtin-class-dyn.ts),
8362
+ // so one of those classes turning untyped there becomes the same
8363
+ // constructor. `require("events")` is the EventEmitter class itself,
8364
+ // so its module binding is too (`ReleaseEmitter = EventEmitter` over
8365
+ // `const EventEmitter = require("events")`).
8366
+ if (expr.type.kind === "moduleNs" &&
8367
+ expr.type.moduleId === "builtin:events" &&
8368
+ isJsSourceFileName(expr.loc.file)) {
8369
+ const value = builtinClassValue(0, expr.loc);
8370
+ if (expr.kind === "moduleNsRef")
8371
+ return value;
8372
+ return {
8373
+ kind: "seqExpr",
8374
+ stmts: [{ kind: "exprStmt", expr, loc: expr.loc }],
8375
+ result: value,
8376
+ type: DYN,
8377
+ loc: expr.loc,
8378
+ };
8379
+ }
7864
8380
  if (expr.type.kind === "classval" && this.classes.get(expr.type.className)?.def.runtime) {
8381
+ // Only the class itself: a slot of the class's type may hold a
8382
+ // program subclass, which this constructor would misidentify.
8383
+ const kind = builtinClassKind(expr.type.className);
8384
+ if (kind !== null && expr.kind === "classRef" && isJsSourceFileName(expr.loc.file))
8385
+ return builtinClassValue(kind, expr.loc);
7865
8386
  this.pushDiag(unsupportedDiag("SC1090", expr.loc, `a runtime-provided class value ('${expr.type.className.slice(1)}') as an untyped value`));
7866
8387
  throw new PoisonError();
7867
8388
  }
@@ -7925,6 +8446,16 @@ export class Lowerer {
7925
8446
  canAdaptDynFuncTo(expected, (id) => this.shapes.get(id), (id) => this.unions.get(id));
7926
8447
  const handleOk = DYN_HANDLE_KINDS.has(expected.kind);
7927
8448
  noteUntypedStreamFlow(this, expected);
8449
+ // `[EventEmitter]` in JavaScript builds an untyped array of the
8450
+ // untyped constructor, which a typed array of the class cannot
8451
+ // hold: no class check admits that constructor.
8452
+ if (expr.kind === "dynArrLit" &&
8453
+ expected.kind === "array" &&
8454
+ expected.elem.kind === "classval" &&
8455
+ expr.elems.some((elem) => elem.kind === "libCall" && elem.fn === "dyn.builtinClass")) {
8456
+ this.pushDiag(unsupportedDiag("SC1090", expr.loc, `holding runtime-provided class values ('${expected.elem.className.slice(1)}') in a typed array`));
8457
+ throw new PoisonError();
8458
+ }
7928
8459
  if (canDynCheckTo(expected, (id) => this.shapes.get(id), (id) => this.unions.get(id)) ||
7929
8460
  undefArmedOk ||
7930
8461
  bytesOk ||
@@ -8362,6 +8893,19 @@ export class Lowerer {
8362
8893
  * directly when the expression was already lowered. */
8363
8894
  coerceInto(node, expr, expected) {
8364
8895
  refuseInferredCallbackDrops(this, node, expr.type, expected);
8896
+ // An assertion's scalar check whose value goes straight back into a
8897
+ // checked-dynamic slot (`process.loadEnvFile({} as unknown as string)`)
8898
+ // keeps the original value: JavaScript erases assertions, so the check
8899
+ // could only add a TypeError Node does not throw, and the slot holds
8900
+ // the value either way.
8901
+ if (expected.kind === "dyn" && expr.kind === "dynCheck" && expr.value.type.kind === "dyn") {
8902
+ let source = node;
8903
+ while (ts.isParenthesizedExpression(source))
8904
+ source = source.expression;
8905
+ if ((ts.isAsExpression(source) || ts.isTypeAssertion(source)) &&
8906
+ (expr.type.kind === "string" || expr.type.kind === "f64" || expr.type.kind === "bool"))
8907
+ return expr.value;
8908
+ }
8365
8909
  // A union destination can accept the binding's tagged storage directly.
8366
8910
  // The checker's single-arm flow type can be stale after a callback writes
8367
8911
  // the binding. Extracting that arm and wrapping it again would discard the
@@ -8634,6 +9178,9 @@ export class Lowerer {
8634
9178
  // retain their own checked conversion and must not be erased here.
8635
9179
  while (ts.isParenthesizedExpression(node) || ts.isSatisfiesExpression(node))
8636
9180
  node = node.expression;
9181
+ const staged = this.stagedArgument(node);
9182
+ if (staged)
9183
+ return expected ? this.coerceInto(node, staged, expected) : staged;
8637
9184
  if (expected) {
8638
9185
  if (ts.isConditionalExpression(node))
8639
9186
  return lowerTernary(this, node, expected);
@@ -10208,6 +10755,10 @@ export class Lowerer {
10208
10755
  const ctx = this.ctx;
10209
10756
  if (!ctx.selfSymbol)
10210
10757
  return false;
10758
+ // A reassigned JavaScript declaration names its module global, which
10759
+ // may hold another function by the time the body runs.
10760
+ if (isRebindableFunctionSymbol(this, ctx.selfSymbol))
10761
+ return false;
10211
10762
  // The self binding can be shadowed by a scoped local of the same symbol?
10212
10763
  // No — a shadow is a different symbol; symbol identity is exact.
10213
10764
  return this.checker.getSymbolAtLocation(ident) === ctx.selfSymbol;
@@ -10358,10 +10909,23 @@ export class Lowerer {
10358
10909
  }
10359
10910
  /* ── expressions ──────────────────────────────────────────────────── */
10360
10911
  lowerExpr(expr) {
10361
- const hash = this.hashStreamReceivers.get(expr);
10362
- if (hash)
10363
- return hashStreamOf(varRef(hash.localId, hash.type, locOf(expr)));
10364
- return lowerExpr(this, expr);
10912
+ const streamValue = this.valueStreamReceivers.get(expr);
10913
+ if (streamValue)
10914
+ return valueStreamOf(varRef(streamValue.localId, streamValue.type, locOf(expr)));
10915
+ return this.stagedArgument(expr) ?? lowerExpr(this, expr);
10916
+ }
10917
+ /** The saved value of a staged fs argument (stagedArguments, keyed
10918
+ * without type-only wrappers), or null for every other expression. */
10919
+ stagedArgument(node) {
10920
+ if (this.stagedArguments.size === 0)
10921
+ return null;
10922
+ node = stripTypeWrappers(node);
10923
+ if (!this.stagedArguments.has(node))
10924
+ return null;
10925
+ const slot = this.stagedArguments.get(node);
10926
+ if (!slot)
10927
+ throw new InternalCompilerError("an fs argument lowered before the URL path it follows");
10928
+ return varRef(slot.localId, slot.type, locOf(node));
10365
10929
  }
10366
10930
  lowerIntrinsicProperty(expr) {
10367
10931
  // The builtin-spoke property extensions (Stats.mtimeMs,
@@ -10387,7 +10951,9 @@ export class Lowerer {
10387
10951
  }
10388
10952
  isNpmFile = (sf) => sf.isDeclarationFile &&
10389
10953
  (sf.fileName.includes("/node_modules/") || workspacePackageOfPath(sf.fileName) !== null) &&
10390
- !this.isStdlibFile(sf);
10954
+ !this.isStdlibFile(sf) &&
10955
+ // A bundled copy's forwarder to a package shim types compiled code.
10956
+ !isBundledShimForwarder(sf.fileName);
10391
10957
  npmPackageOf(type) {
10392
10958
  return npmPackageOf(this, type);
10393
10959
  }
@@ -10618,6 +11184,25 @@ export class Lowerer {
10618
11184
  return lower();
10619
11185
  return this.withExpressionOverride(node, this.checkedNarrowCall(helper, optional.value, optional.present, locOf(node)), lower);
10620
11186
  }
11187
+ /** withExpressionOverride for several nodes at once. */
11188
+ withExpressionOverrides(overrides, lower) {
11189
+ const previous = overrides.map((override) => this.chainRecvByNode.get(override.node));
11190
+ for (const override of overrides)
11191
+ this.chainRecvByNode.set(override.node, override.value);
11192
+ try {
11193
+ return lower();
11194
+ }
11195
+ finally {
11196
+ for (let i = overrides.length - 1; i >= 0; i--) {
11197
+ const node = overrides[i].node;
11198
+ const value = previous[i];
11199
+ if (value)
11200
+ this.chainRecvByNode.set(node, value);
11201
+ else
11202
+ this.chainRecvByNode.delete(node);
11203
+ }
11204
+ }
11205
+ }
10621
11206
  withExpressionOverride(node, value, lower) {
10622
11207
  const previous = this.chainRecvByNode.get(node);
10623
11208
  this.chainRecvByNode.set(node, value);
@@ -10639,7 +11224,8 @@ export class Lowerer {
10639
11224
  if (webAssembly !== null)
10640
11225
  return webAssembly;
10641
11226
  refuseWebAssemblyUse(this, expr.expression);
10642
- return (lowerLifetimeRegionCall(this, expr) ??
11227
+ return (lowerErrorFunctionCall(this, expr) ??
11228
+ lowerLifetimeRegionCall(this, expr) ??
10643
11229
  lowerInternTableCall(this, expr) ??
10644
11230
  lowerThreadSlotsCall(this, expr) ??
10645
11231
  lowerFfiCall(this, expr) ??
@@ -10654,6 +11240,8 @@ export class Lowerer {
10654
11240
  lowerStaticBlobCall(this, expr) ??
10655
11241
  lowerWebCryptoCall(this, expr) ??
10656
11242
  lowerKeyObjectCall(this, expr) ??
11243
+ lowerEcdhCall(this, expr) ??
11244
+ lowerDiffieHellmanCall(this, expr) ??
10657
11245
  lowerNetAddressCall(this, expr) ??
10658
11246
  lowerFetchElementMethodCall(this, expr) ??
10659
11247
  lowerDynamicImportCall(this, expr) ??
@@ -11161,6 +11749,10 @@ export class Lowerer {
11161
11749
  if (callable)
11162
11750
  return callable;
11163
11751
  }
11752
+ // node:crypto's webcrypto is the WebCrypto global's object.
11753
+ if (bi.module === "crypto" && bi.member === "webcrypto") {
11754
+ return { kind: "libCall", fn: "webcrypto.object", args: [], type: DYN, loc };
11755
+ }
11164
11756
  // node:stream/web's exports are the web stream globals themselves: in
11165
11757
  // JavaScript sources the same identity token as the global spelling
11166
11758
  // (`require("stream/web").ReadableStream === globalThis.ReadableStream`).
@@ -11204,6 +11796,8 @@ export class Lowerer {
11204
11796
  loc,
11205
11797
  };
11206
11798
  }
11799
+ if (bi.module === "fs" && (bi.member === "realpathSync" || bi.member === "realpathSync.native"))
11800
+ return fsRealpathValue(this, bi.member === "realpathSync.native", loc);
11207
11801
  const fn = builtinModuleFnOf(this, bi.module, bi.member);
11208
11802
  return fn ? this.lowerNativeCallableValue(fn, `${bi.module}.${bi.member}`, loc) : null;
11209
11803
  }
@@ -11228,7 +11822,7 @@ export class Lowerer {
11228
11822
  const key = `${fn.valueFn ?? fn.fn}:${typeKey(funcType)}:${adapterShape}`;
11229
11823
  let fnName = this.builtinCallableValueFns.get(key);
11230
11824
  if (!fnName) {
11231
- fnName = `%builtin.value.${fn.valueFn ?? fn.fn}.${this.builtinCallableValueFns.size}`;
11825
+ fnName = keyedHelperName(this, `%builtin.value.${fn.valueFn ?? fn.fn}`, key);
11232
11826
  this.builtinCallableValueFns.set(key, fnName);
11233
11827
  this.builtinCallableValueNames.set(fnName, display.slice(display.lastIndexOf(".") + 1));
11234
11828
  const params = funcType.params.map((type, index) => ({
@@ -11723,4 +12317,51 @@ function droppedMembers(lowerer, from, to, seen) {
11723
12317
  }
11724
12318
  return out;
11725
12319
  }
12320
+ /** fs.realpathSync and its .native as function values (fs.realpath stores
12321
+ * `var origRealpathSync = fs.realpathSync`): path and options pass through
12322
+ * unchecked to the runtime, which applies Node's argument handling. */
12323
+ function fsRealpathValue(lowerer, native, loc) {
12324
+ const name = native ? "%builtin.fs.realpathSync.native" : "%builtin.fs.realpathSync";
12325
+ if (!lowerer.builtinCallableValueFns.has(name)) {
12326
+ lowerer.builtinCallableValueFns.set(name, name);
12327
+ const params = ["path", "options"].map((id) => ({ localId: id, name: id, type: DYN }));
12328
+ lowerer.liftedFns.push({
12329
+ name,
12330
+ params,
12331
+ returnType: DYN,
12332
+ locals: params.map((p) => ({ id: p.localId, name: p.name, type: DYN, mutable: false })),
12333
+ loc,
12334
+ body: [
12335
+ {
12336
+ kind: "return",
12337
+ value: {
12338
+ kind: "libCall",
12339
+ fn: "fs.realpathValue",
12340
+ args: [
12341
+ { kind: "varRef", localId: "path", type: DYN, loc },
12342
+ { kind: "varRef", localId: "options", type: DYN, loc },
12343
+ { kind: "boolLit", value: native, type: BOOL, loc },
12344
+ ],
12345
+ type: DYN,
12346
+ loc,
12347
+ },
12348
+ loc,
12349
+ },
12350
+ ],
12351
+ });
12352
+ }
12353
+ return {
12354
+ kind: "dynFrom",
12355
+ value: {
12356
+ kind: "closure",
12357
+ fnName: name,
12358
+ captures: [],
12359
+ type: { kind: "func", params: [DYN, DYN], ret: DYN },
12360
+ loc,
12361
+ },
12362
+ fnName: native ? "native" : "realpathSync",
12363
+ type: DYN,
12364
+ loc,
12365
+ };
12366
+ }
11726
12367
  //# sourceMappingURL=lowerer.js.map