@scriptc/compiler 0.3.2 → 0.3.4

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 (454) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +1202 -64
  2. package/dist/backend/cycle-analysis.js +6 -1
  3. package/dist/backend/cycle-analysis.js.map +1 -1
  4. package/dist/backend/cycle-mutability.d.ts +5 -0
  5. package/dist/backend/cycle-mutability.js +62 -3
  6. package/dist/backend/cycle-mutability.js.map +1 -1
  7. package/dist/backend/executable-features.js +1 -0
  8. package/dist/backend/executable-features.js.map +1 -1
  9. package/dist/backend/library-pack.js +1 -0
  10. package/dist/backend/library-pack.js.map +1 -1
  11. package/dist/backend/llvm/alloc.js +24 -10
  12. package/dist/backend/llvm/alloc.js.map +1 -1
  13. package/dist/backend/llvm/alloc.test.js +47 -1
  14. package/dist/backend/llvm/alloc.test.js.map +1 -1
  15. package/dist/backend/llvm/array-search.d.ts +8 -0
  16. package/dist/backend/llvm/array-search.js +52 -0
  17. package/dist/backend/llvm/array-search.js.map +1 -0
  18. package/dist/backend/llvm/array-search.test.d.ts +1 -0
  19. package/dist/backend/llvm/array-search.test.js +72 -0
  20. package/dist/backend/llvm/array-search.test.js.map +1 -0
  21. package/dist/backend/llvm/call-lifetimes.d.ts +12 -1
  22. package/dist/backend/llvm/call-lifetimes.js +41 -11
  23. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  24. package/dist/backend/llvm/call-lifetimes.test.js +85 -1
  25. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  26. package/dist/backend/llvm/classes.js +87 -36
  27. package/dist/backend/llvm/classes.js.map +1 -1
  28. package/dist/backend/llvm/common.d.ts +6 -1
  29. package/dist/backend/llvm/common.js +8 -1
  30. package/dist/backend/llvm/common.js.map +1 -1
  31. package/dist/backend/llvm/dense-array-access.d.ts +5 -0
  32. package/dist/backend/llvm/dense-array-access.js +3 -3
  33. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  34. package/dist/backend/llvm/dyn.d.ts +44 -1
  35. package/dist/backend/llvm/dyn.js +251 -36
  36. package/dist/backend/llvm/dyn.js.map +1 -1
  37. package/dist/backend/llvm/emitter.d.ts +77 -14
  38. package/dist/backend/llvm/emitter.js +461 -108
  39. package/dist/backend/llvm/emitter.js.map +1 -1
  40. package/dist/backend/llvm/emitter.test.js +26 -3
  41. package/dist/backend/llvm/emitter.test.js.map +1 -1
  42. package/dist/backend/llvm/expr-async.js +52 -1
  43. package/dist/backend/llvm/expr-async.js.map +1 -1
  44. package/dist/backend/llvm/expr-bytes.d.ts +9 -0
  45. package/dist/backend/llvm/expr-bytes.js +169 -63
  46. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  47. package/dist/backend/llvm/expr-callbacks.js +16 -2
  48. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  49. package/dist/backend/llvm/expr-calls.d.ts +3 -1
  50. package/dist/backend/llvm/expr-calls.js +57 -2
  51. package/dist/backend/llvm/expr-calls.js.map +1 -1
  52. package/dist/backend/llvm/expr-containers.js +57 -19
  53. package/dist/backend/llvm/expr-containers.js.map +1 -1
  54. package/dist/backend/llvm/expr-dynamic.js +19 -8
  55. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  56. package/dist/backend/llvm/expr-primitives.js +28 -30
  57. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  58. package/dist/backend/llvm/expr-records.js +8 -4
  59. package/dist/backend/llvm/expr-records.js.map +1 -1
  60. package/dist/backend/llvm/expr-stream-bridges.js +35 -32
  61. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  62. package/dist/backend/llvm/expr-stream-callbacks.d.ts +13 -2
  63. package/dist/backend/llvm/expr-stream-callbacks.js +80 -5
  64. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  65. package/dist/backend/llvm/inline-unions.d.ts +48 -0
  66. package/dist/backend/llvm/inline-unions.js +134 -0
  67. package/dist/backend/llvm/inline-unions.js.map +1 -0
  68. package/dist/backend/llvm/inline-unions.test.d.ts +1 -0
  69. package/dist/backend/llvm/inline-unions.test.js +124 -0
  70. package/dist/backend/llvm/inline-unions.test.js.map +1 -0
  71. package/dist/backend/llvm/integer-remainder.d.ts +28 -5
  72. package/dist/backend/llvm/integer-remainder.js +80 -9
  73. package/dist/backend/llvm/integer-remainder.js.map +1 -1
  74. package/dist/backend/llvm/intern-tables.test.d.ts +1 -0
  75. package/dist/backend/llvm/intern-tables.test.js +77 -0
  76. package/dist/backend/llvm/intern-tables.test.js.map +1 -0
  77. package/dist/backend/llvm/lib-datagram.js +10 -0
  78. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  79. package/dist/backend/llvm/lib-dispatch.js +255 -29
  80. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  81. package/dist/backend/llvm/lib-filesystem.js +176 -7
  82. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  83. package/dist/backend/llvm/lib-network.js +25 -6
  84. package/dist/backend/llvm/lib-network.js.map +1 -1
  85. package/dist/backend/llvm/lib-process.js +2 -2
  86. package/dist/backend/llvm/lib-process.js.map +1 -1
  87. package/dist/backend/llvm/lib-shared.d.ts +5 -0
  88. package/dist/backend/llvm/lib-shared.js +212 -1
  89. package/dist/backend/llvm/lib-shared.js.map +1 -1
  90. package/dist/backend/llvm/lib-stream.js +184 -0
  91. package/dist/backend/llvm/lib-stream.js.map +1 -1
  92. package/dist/backend/llvm/lib-test.js +9 -0
  93. package/dist/backend/llvm/lib-test.js.map +1 -1
  94. package/dist/backend/llvm/local-array-reads.js +7 -3
  95. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  96. package/dist/backend/llvm/local-array-reads.test.js +6 -3
  97. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  98. package/dist/backend/llvm/local-union-storage.d.ts +2 -0
  99. package/dist/backend/llvm/local-union-storage.js +5 -0
  100. package/dist/backend/llvm/local-union-storage.js.map +1 -1
  101. package/dist/backend/llvm/local-union-storage.test.js +1 -0
  102. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  103. package/dist/backend/llvm/loop-array-borrows.d.ts +8 -2
  104. package/dist/backend/llvm/loop-array-borrows.js +93 -13
  105. package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
  106. package/dist/backend/llvm/map-number-lookup.d.ts +24 -0
  107. package/dist/backend/llvm/map-number-lookup.js +88 -0
  108. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  109. package/dist/backend/llvm/map-number-lookup.test.d.ts +1 -0
  110. package/dist/backend/llvm/map-number-lookup.test.js +158 -0
  111. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -0
  112. package/dist/backend/llvm/map-read-lifetimes.d.ts +9 -0
  113. package/dist/backend/llvm/map-read-lifetimes.js +90 -1
  114. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  115. package/dist/backend/llvm/map-read-lifetimes.test.js +129 -1
  116. package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
  117. package/dist/backend/llvm/publish.d.ts +9 -0
  118. package/dist/backend/llvm/publish.js +25 -4
  119. package/dist/backend/llvm/publish.js.map +1 -1
  120. package/dist/backend/llvm/record-results.d.ts +8 -5
  121. package/dist/backend/llvm/record-results.js +20 -12
  122. package/dist/backend/llvm/record-results.js.map +1 -1
  123. package/dist/backend/llvm/reference-effects.js +13 -0
  124. package/dist/backend/llvm/reference-effects.js.map +1 -1
  125. package/dist/backend/llvm/reference-writes.js +19 -2
  126. package/dist/backend/llvm/reference-writes.js.map +1 -1
  127. package/dist/backend/llvm/regions.d.ts +5 -1
  128. package/dist/backend/llvm/regions.js +24 -10
  129. package/dist/backend/llvm/regions.js.map +1 -1
  130. package/dist/backend/llvm/serialized-ir-emission.test.js +2 -0
  131. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  132. package/dist/backend/llvm/shapes.d.ts +56 -10
  133. package/dist/backend/llvm/shapes.js +178 -39
  134. package/dist/backend/llvm/shapes.js.map +1 -1
  135. package/dist/backend/llvm/shapes.test.js +61 -3
  136. package/dist/backend/llvm/shapes.test.js.map +1 -1
  137. package/dist/backend/llvm/stack-objects.js +16 -4
  138. package/dist/backend/llvm/stack-objects.js.map +1 -1
  139. package/dist/backend/llvm/stack-objects.test.js +3 -0
  140. package/dist/backend/llvm/stack-objects.test.js.map +1 -1
  141. package/dist/backend/llvm/string-reads.js +2 -2
  142. package/dist/backend/llvm/string-reads.js.map +1 -1
  143. package/dist/backend/llvm/string-slices.js +2 -2
  144. package/dist/backend/llvm/string-slices.js.map +1 -1
  145. package/dist/backend/llvm/walkers.d.ts +11 -0
  146. package/dist/backend/llvm/walkers.js +106 -10
  147. package/dist/backend/llvm/walkers.js.map +1 -1
  148. package/dist/backend/may-throw.js +13 -4
  149. package/dist/backend/may-throw.js.map +1 -1
  150. package/dist/backend/native/contracts.d.ts +5 -2
  151. package/dist/backend/native/executable.js +27 -8
  152. package/dist/backend/native/executable.js.map +1 -1
  153. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  154. package/dist/backend/native/runtime-inputs.js +2 -0
  155. package/dist/backend/native/runtime-inputs.js.map +1 -1
  156. package/dist/backend/native-codegen-core.d.ts +4 -4
  157. package/dist/backend/native-codegen-core.js +4 -6
  158. package/dist/backend/native-codegen-core.js.map +1 -1
  159. package/dist/backend/native-codegen.test.js +7 -8
  160. package/dist/backend/native-codegen.test.js.map +1 -1
  161. package/dist/backend/native-link-info-core.d.ts +3 -0
  162. package/dist/backend/native-link-info-core.js.map +1 -1
  163. package/dist/backend/native-toolchain.test.js +1 -1
  164. package/dist/backend/native-toolchain.test.js.map +1 -1
  165. package/dist/backend/publication.js +3 -1
  166. package/dist/backend/publication.js.map +1 -1
  167. package/dist/backend/runtime-abi.d.ts +2 -2
  168. package/dist/backend/runtime-abi.js +2 -2
  169. package/dist/backend/runtime-pack-targets.test.js +2 -1
  170. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  171. package/dist/backend/runtime-pack.test.js +2 -1
  172. package/dist/backend/runtime-pack.test.js.map +1 -1
  173. package/dist/backend/target-diagnostics.js +11 -1
  174. package/dist/backend/target-diagnostics.js.map +1 -1
  175. package/dist/backend/target-diagnostics.test.js +4 -1
  176. package/dist/backend/target-diagnostics.test.js.map +1 -1
  177. package/dist/backend/warm-cache.js +1 -0
  178. package/dist/backend/warm-cache.js.map +1 -1
  179. package/dist/compat/fetch-profile.js +4 -4
  180. package/dist/compat/fetch-profile.js.map +1 -1
  181. package/dist/contracts/check.js +2 -0
  182. package/dist/contracts/check.js.map +1 -1
  183. package/dist/coverage/report.js +1 -1
  184. package/dist/coverage/report.js.map +1 -1
  185. package/dist/diagnostics/diagnostic.d.ts +6 -5
  186. package/dist/diagnostics/diagnostic.js +7 -6
  187. package/dist/diagnostics/diagnostic.js.map +1 -1
  188. package/dist/executable/executable-cache.d.ts +1 -0
  189. package/dist/executable/executable-cache.js +1 -0
  190. package/dist/executable/executable-cache.js.map +1 -1
  191. package/dist/executable/executable-cache.test.js +1 -0
  192. package/dist/executable/executable-cache.test.js.map +1 -1
  193. package/dist/frontend/builtin-modules.d.ts +1 -1
  194. package/dist/frontend/builtin-modules.js +1 -0
  195. package/dist/frontend/builtin-modules.js.map +1 -1
  196. package/dist/frontend/comptime-node.js +2 -2
  197. package/dist/frontend/comptime-node.js.map +1 -1
  198. package/dist/frontend/experimental-import.d.ts +5 -1
  199. package/dist/frontend/experimental-import.js +28 -3
  200. package/dist/frontend/experimental-import.js.map +1 -1
  201. package/dist/frontend/lowering/assert-instances.d.ts +38 -0
  202. package/dist/frontend/lowering/assert-instances.js +269 -0
  203. package/dist/frontend/lowering/assert-instances.js.map +1 -0
  204. package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
  205. package/dist/frontend/lowering/binding-analysis.js +1 -1
  206. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  207. package/dist/frontend/lowering/builtins/arguments.js +8 -4
  208. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  209. package/dist/frontend/lowering/builtins/blob.d.ts +20 -0
  210. package/dist/frontend/lowering/builtins/blob.js +167 -0
  211. package/dist/frontend/lowering/builtins/blob.js.map +1 -0
  212. package/dist/frontend/lowering/builtins/child-process-async.d.ts +2 -2
  213. package/dist/frontend/lowering/builtins/child-process-async.js +2 -2
  214. package/dist/frontend/lowering/builtins/child-process-methods.js +1 -1
  215. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  216. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -1
  217. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  218. package/dist/frontend/lowering/builtins/compression.d.ts +18 -0
  219. package/dist/frontend/lowering/builtins/compression.js +178 -4
  220. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  221. package/dist/frontend/lowering/builtins/constants.js +7 -2
  222. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  223. package/dist/frontend/lowering/builtins/crypto.d.ts +6 -0
  224. package/dist/frontend/lowering/builtins/crypto.js +526 -121
  225. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  226. package/dist/frontend/lowering/builtins/errors.js +23 -0
  227. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  228. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +10 -0
  229. package/dist/frontend/lowering/builtins/filesystem-calls.js +89 -1
  230. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  231. package/dist/frontend/lowering/builtins/filesystem.d.ts +16 -7
  232. package/dist/frontend/lowering/builtins/filesystem.js +97 -15
  233. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  234. package/dist/frontend/lowering/builtins/fs-glob.d.ts +23 -0
  235. package/dist/frontend/lowering/builtins/fs-glob.js +224 -0
  236. package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -0
  237. package/dist/frontend/lowering/builtins/key-object.d.ts +13 -0
  238. package/dist/frontend/lowering/builtins/key-object.js +56 -0
  239. package/dist/frontend/lowering/builtins/key-object.js.map +1 -0
  240. package/dist/frontend/lowering/builtins/module-calls.js +44 -11
  241. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  242. package/dist/frontend/lowering/builtins/performance.d.ts +25 -3
  243. package/dist/frontend/lowering/builtins/performance.js +340 -5
  244. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  245. package/dist/frontend/lowering/builtins/process.d.ts +2 -2
  246. package/dist/frontend/lowering/builtins/process.js +107 -14
  247. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  248. package/dist/frontend/lowering/builtins/properties.d.ts +0 -7
  249. package/dist/frontend/lowering/builtins/properties.js +39 -11
  250. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  251. package/dist/frontend/lowering/builtins/readline.d.ts +23 -8
  252. package/dist/frontend/lowering/builtins/readline.js +266 -90
  253. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  254. package/dist/frontend/lowering/builtins/timers.d.ts +3 -0
  255. package/dist/frontend/lowering/builtins/timers.js +109 -23
  256. package/dist/frontend/lowering/builtins/timers.js.map +1 -1
  257. package/dist/frontend/lowering/builtins/url.d.ts +8 -0
  258. package/dist/frontend/lowering/builtins/url.js +36 -0
  259. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  260. package/dist/frontend/lowering/call-arguments.js +1 -1
  261. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  262. package/dist/frontend/lowering/call-signatures.js +26 -2
  263. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  264. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +2 -0
  265. package/dist/frontend/lowering/class-dynamic-dispatch.js +171 -13
  266. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  267. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +1 -0
  268. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  269. package/dist/frontend/lowering/class-protocol-dispatch.d.ts +45 -0
  270. package/dist/frontend/lowering/class-protocol-dispatch.js +516 -0
  271. package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -0
  272. package/dist/frontend/lowering/coercions/structural-plans.js +2 -1
  273. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  274. package/dist/frontend/lowering/coercions/structural.js +3 -3
  275. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  276. package/dist/frontend/lowering/collation-repertoire.js +6 -5
  277. package/dist/frontend/lowering/collation-repertoire.js.map +1 -1
  278. package/dist/frontend/lowering/containers/array-callbacks.js +4 -7
  279. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  280. package/dist/frontend/lowering/containers/array-methods.d.ts +0 -7
  281. package/dist/frontend/lowering/containers/array-methods.js +43 -2
  282. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  283. package/dist/frontend/lowering/containers/bytes.js +38 -26
  284. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  285. package/dist/frontend/lowering/containers/for-of.d.ts +1 -1
  286. package/dist/frontend/lowering/containers/for-of.js +5 -1
  287. package/dist/frontend/lowering/containers/for-of.js.map +1 -1
  288. package/dist/frontend/lowering/containers/indexed-objects.js +1 -1
  289. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  290. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  291. package/dist/frontend/lowering/crypto-tables.js +77 -12
  292. package/dist/frontend/lowering/crypto-tables.js.map +1 -1
  293. package/dist/frontend/lowering/expressions/nullish-assignment.js +10 -0
  294. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  295. package/dist/frontend/lowering/expressions/object-literals.js +16 -12
  296. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  297. package/dist/frontend/lowering/generic-functions.d.ts +2 -2
  298. package/dist/frontend/lowering/generic-functions.js +2 -2
  299. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  300. package/dist/frontend/lowering/http2-constants.js +1 -1
  301. package/dist/frontend/lowering/intern-tables.d.ts +13 -0
  302. package/dist/frontend/lowering/intern-tables.js +536 -0
  303. package/dist/frontend/lowering/intern-tables.js.map +1 -0
  304. package/dist/frontend/lowering/lower-array-sort.d.ts +12 -1
  305. package/dist/frontend/lowering/lower-array-sort.js +561 -191
  306. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  307. package/dist/frontend/lowering/lower-array-sort.test.js +4 -2
  308. package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
  309. package/dist/frontend/lowering/lower-assert.js +702 -63
  310. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  311. package/dist/frontend/lowering/lower-async-iteration.d.ts +6 -3
  312. package/dist/frontend/lowering/lower-async-iteration.js +259 -4
  313. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  314. package/dist/frontend/lowering/lower-calls.js +118 -12
  315. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  316. package/dist/frontend/lowering/lower-classes.d.ts +11 -2
  317. package/dist/frontend/lowering/lower-classes.js +76 -9
  318. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  319. package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
  320. package/dist/frontend/lowering/lower-comptime.js +4 -4
  321. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  322. package/dist/frontend/lowering/lower-dgram.js +77 -52
  323. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  324. package/dist/frontend/lowering/lower-event-target.d.ts +63 -0
  325. package/dist/frontend/lowering/lower-event-target.js +362 -0
  326. package/dist/frontend/lowering/lower-event-target.js.map +1 -0
  327. package/dist/frontend/lowering/lower-expando.js +2 -2
  328. package/dist/frontend/lowering/lower-exprs.js +124 -22
  329. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  330. package/dist/frontend/lowering/lower-inspect.d.ts +6 -0
  331. package/dist/frontend/lowering/lower-inspect.js +240 -49
  332. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  333. package/dist/frontend/lowering/lower-mixins.js +1 -1
  334. package/dist/frontend/lowering/lower-mock.d.ts +11 -0
  335. package/dist/frontend/lowering/lower-mock.js +504 -0
  336. package/dist/frontend/lowering/lower-mock.js.map +1 -0
  337. package/dist/frontend/lowering/lower-modules.d.ts +1 -1
  338. package/dist/frontend/lowering/lower-modules.js +14 -3
  339. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  340. package/dist/frontend/lowering/lower-namespaces.d.ts +2 -2
  341. package/dist/frontend/lowering/lower-namespaces.js +2 -2
  342. package/dist/frontend/lowering/lower-server.d.ts +3 -0
  343. package/dist/frontend/lowering/lower-server.js +419 -44
  344. package/dist/frontend/lowering/lower-server.js.map +1 -1
  345. package/dist/frontend/lowering/lower-stdlib.d.ts +7 -1
  346. package/dist/frontend/lowering/lower-stdlib.js +10 -3
  347. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  348. package/dist/frontend/lowering/lower-stmts.d.ts +2 -2
  349. package/dist/frontend/lowering/lower-stmts.js +69 -14
  350. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  351. package/dist/frontend/lowering/lower-stream.d.ts +10 -6
  352. package/dist/frontend/lowering/lower-stream.js +1020 -49
  353. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  354. package/dist/frontend/lowering/lower-test.js +86 -8
  355. package/dist/frontend/lowering/lower-test.js.map +1 -1
  356. package/dist/frontend/lowering/lower-timers.js +1 -1
  357. package/dist/frontend/lowering/lowerer.d.ts +45 -5
  358. package/dist/frontend/lowering/lowerer.js +317 -48
  359. package/dist/frontend/lowering/lowerer.js.map +1 -1
  360. package/dist/frontend/lowering/native-ffi.js +2 -2
  361. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  362. package/dist/frontend/lowering/pairs-snapshot.d.ts +6 -0
  363. package/dist/frontend/lowering/pairs-snapshot.js +49 -0
  364. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  365. package/dist/frontend/lowering/runtime-optional-records.d.ts +115 -0
  366. package/dist/frontend/lowering/runtime-optional-records.js +715 -0
  367. package/dist/frontend/lowering/runtime-optional-records.js.map +1 -0
  368. package/dist/frontend/lowering/runtime-optional-records.test.d.ts +1 -0
  369. package/dist/frontend/lowering/runtime-optional-records.test.js +175 -0
  370. package/dist/frontend/lowering/runtime-optional-records.test.js.map +1 -0
  371. package/dist/frontend/lowering/surfaces.d.ts +11 -3
  372. package/dist/frontend/lowering/surfaces.js +334 -37
  373. package/dist/frontend/lowering/surfaces.js.map +1 -1
  374. package/dist/frontend/lowering/zlib-constants.d.ts +1 -0
  375. package/dist/frontend/lowering/zlib-constants.js +181 -0
  376. package/dist/frontend/lowering/zlib-constants.js.map +1 -0
  377. package/dist/frontend/mock-shapes.d.ts +10 -0
  378. package/dist/frontend/mock-shapes.js +76 -0
  379. package/dist/frontend/mock-shapes.js.map +1 -0
  380. package/dist/frontend/module-syntax.d.ts +1 -1
  381. package/dist/frontend/module-syntax.js +1 -1
  382. package/dist/frontend/npm-static-prune.js +1 -1
  383. package/dist/frontend/npm-static-prune.js.map +1 -1
  384. package/dist/frontend/npm-static-rewrite-syntax.js +4 -3
  385. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  386. package/dist/frontend/pipeline.js +6 -4
  387. package/dist/frontend/pipeline.js.map +1 -1
  388. package/dist/frontend/program.d.ts +3 -3
  389. package/dist/frontend/program.js +25 -18
  390. package/dist/frontend/program.js.map +1 -1
  391. package/dist/frontend/resolve.d.ts +4 -0
  392. package/dist/frontend/resolve.js +15 -1
  393. package/dist/frontend/resolve.js.map +1 -1
  394. package/dist/frontend/ts7/adapter.js +1 -1
  395. package/dist/frontend/ts7/ast-bytes.d.ts +1 -1
  396. package/dist/frontend/ts7/ast-bytes.js +1 -1
  397. package/dist/frontend/ts7/semantic-json.d.ts +1 -1
  398. package/dist/frontend/ts7/semantic-json.js +1 -1
  399. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  400. package/dist/frontend/ts7/world-check.js +1 -1
  401. package/dist/frontend/tsc-codes.js +3 -2
  402. package/dist/frontend/tsc-codes.js.map +1 -1
  403. package/dist/frontend/type-mapper.d.ts +21 -1
  404. package/dist/frontend/type-mapper.js +245 -27
  405. package/dist/frontend/type-mapper.js.map +1 -1
  406. package/dist/index.js +7 -5
  407. package/dist/index.js.map +1 -1
  408. package/dist/ir/analysis.d.ts +12 -6
  409. package/dist/ir/analysis.js +26 -10
  410. package/dist/ir/analysis.js.map +1 -1
  411. package/dist/ir/analysis.test.js +15 -3
  412. package/dist/ir/analysis.test.js.map +1 -1
  413. package/dist/ir/builtin-effects.js +115 -0
  414. package/dist/ir/builtin-effects.js.map +1 -1
  415. package/dist/ir/builtin-signatures.d.ts +1 -1
  416. package/dist/ir/builtin-signatures.js +438 -46
  417. package/dist/ir/builtin-signatures.js.map +1 -1
  418. package/dist/ir/int32-slots.js +1 -0
  419. package/dist/ir/int32-slots.js.map +1 -1
  420. package/dist/ir/ir.d.ts +84 -17
  421. package/dist/ir/ir.js +54 -1
  422. package/dist/ir/ir.js.map +1 -1
  423. package/dist/ir/runtime-features.d.ts +1 -0
  424. package/dist/ir/runtime-features.js +111 -7
  425. package/dist/ir/runtime-features.js.map +1 -1
  426. package/dist/ir/serialize.js +1 -1
  427. package/dist/ir/serialize.js.map +1 -1
  428. package/dist/ir/traverse.js +1 -0
  429. package/dist/ir/traverse.js.map +1 -1
  430. package/dist/ir/validate.js +295 -14
  431. package/dist/ir/validate.js.map +1 -1
  432. package/dist/ir/validate.test.js +60 -0
  433. package/dist/ir/validate.test.js.map +1 -1
  434. package/dist/library/fence-eval.d.ts +1 -1
  435. package/dist/library/fence-eval.js +5 -4
  436. package/dist/library/fence-eval.js.map +1 -1
  437. package/dist/library/ir-policy.js +11 -4
  438. package/dist/library/ir-policy.js.map +1 -1
  439. package/dist/library/library-profile.js +13 -13
  440. package/dist/library/library-profile.js.map +1 -1
  441. package/dist/library/prepare.js +1 -1
  442. package/dist/library/prepare.js.map +1 -1
  443. package/dist/library/sidecar.js +3 -3
  444. package/dist/library/sidecar.js.map +1 -1
  445. package/dist/native/cli.js +1 -0
  446. package/dist/native/cli.js.map +1 -1
  447. package/dist/native/compiler.js +1 -3
  448. package/dist/native/compiler.js.map +1 -1
  449. package/dist/native/prepare.js +4 -2
  450. package/dist/native/prepare.js.map +1 -1
  451. package/dist/native/sanitizer.test.js +1 -0
  452. package/dist/native/sanitizer.test.js.map +1 -1
  453. package/package.json +20 -20
  454. package/surface-manifest.json +1279 -221
@@ -0,0 +1,504 @@
1
+ /* node:test's mock functions (Node 24.22, lib/internal/test_runner/mock):
2
+ * mock.fn and t.mock.fn, and the fn.mock context's calls, callCount,
3
+ * mockImplementation, mockImplementationOnce, resetCalls and restore.
4
+ *
5
+ * mock.fn(original, implementation?) lowers to the hybrid record
6
+ * { %call: wrapper, mock: context } (mock-shapes.ts). The wrapper is a
7
+ * closure over the context, lifted once per context type: it takes the
8
+ * one-time implementation registered for this call index, or the current
9
+ * one, calls it, and appends { arguments, error, result, this } to the
10
+ * calls log before returning or rethrowing. The context's mutating
11
+ * methods are lifted helpers of the same type. */
12
+ import * as ts from "../ts7/adapter.js";
13
+ import { BOOL, CAUGHT, DYN, F64, UNDEFINED_T, VOID, typeKey, } from "../../ir/ir.js";
14
+ import { countedFor, dynUndefinedExpr, numLit, varRef } from "../../ir/build.js";
15
+ import { locOf } from "../program.js";
16
+ /** The context record's parts, or null when `type` is not a mock context
17
+ * (mock-shapes.ts). */
18
+ function mockContextFields(lowerer, type) {
19
+ if (type.kind !== "record")
20
+ return null;
21
+ const shape = lowerer.shapes.get(type.shapeId);
22
+ const field = (name) => shape?.fields.find((f) => f.name === name)?.type;
23
+ const impl = field("%impl");
24
+ const once = field("%once");
25
+ const calls = field("calls");
26
+ if (impl?.kind !== "func" ||
27
+ once?.kind !== "array" ||
28
+ calls?.kind !== "array" ||
29
+ field("%original") === undefined)
30
+ return null;
31
+ const call = calls.elem;
32
+ const callShape = call.kind === "record" ? lowerer.shapes.get(call.shapeId) : undefined;
33
+ const result = callShape?.fields.find((f) => f.name === "result")?.type;
34
+ const args = callShape?.fields.find((f) => f.name === "arguments")?.type;
35
+ if (!result || !args)
36
+ return null;
37
+ return { fn: impl, call, calls, once, onceEntry: once.elem, result, args };
38
+ }
39
+ export function isMockContextType(lowerer, type) {
40
+ return mockContextFields(lowerer, type) !== null;
41
+ }
42
+ const recordGet = (obj, field, type, loc) => ({
43
+ kind: "recordGet",
44
+ obj,
45
+ shapeId: obj.type.shapeId,
46
+ field,
47
+ type,
48
+ loc,
49
+ });
50
+ const recordSet = (obj, field, value, loc) => ({
51
+ kind: "recordSet",
52
+ obj,
53
+ shapeId: obj.type.shapeId,
54
+ field,
55
+ value,
56
+ loc,
57
+ });
58
+ const length = (arr, loc) => ({
59
+ kind: "arrIntrinsic",
60
+ method: "length",
61
+ receiver: arr,
62
+ args: [],
63
+ type: F64,
64
+ loc,
65
+ });
66
+ const local = (id, name, type, mutable = false) => ({
67
+ id,
68
+ name,
69
+ type,
70
+ mutable,
71
+ });
72
+ /** Lifts one function per (context type, role), cached on the lowerer. */
73
+ function liftOnce(lowerer, ctxType, role, build) {
74
+ const key = `mock.${role}:${ctxType.shapeId}`;
75
+ const existing = lowerer.assertHelpers.get(key);
76
+ if (existing)
77
+ return existing;
78
+ const name = `%mock.${role}.${lowerer.assertHelpers.size}`;
79
+ lowerer.assertHelpers.set(key, name);
80
+ build(name);
81
+ return name;
82
+ }
83
+ /** `%mock.wrap.N(ctx)`: the closure that records each call into ctx. */
84
+ function mockWrapperFactory(lowerer, ctxType, loc) {
85
+ return liftOnce(lowerer, ctxType, "wrap", (name) => {
86
+ const { fn, call, calls, once, onceEntry, result, args } = mockContextFields(lowerer, ctxType);
87
+ const impl = `${name}.impl`;
88
+ const ctx = () => varRef("ctx.0", ctxType, loc);
89
+ const params = fn.params.map((type, i) => ({ localId: `p${i}.0`, name: `p${i}`, type }));
90
+ const paramRefs = () => params.map((p) => varRef(p.localId, p.type, loc));
91
+ const argumentsValue = () => fn.rest
92
+ ? paramRefs()[0]
93
+ : {
94
+ kind: "recordLit",
95
+ fields: paramRefs().map((value, i) => ({ name: String(i), value })),
96
+ type: args,
97
+ loc,
98
+ };
99
+ const record = (resultValue, error) => ({
100
+ kind: "exprStmt",
101
+ expr: {
102
+ kind: "arrIntrinsic",
103
+ method: "push",
104
+ receiver: recordGet(ctx(), "calls", calls, loc),
105
+ args: [
106
+ {
107
+ kind: "recordLit",
108
+ fields: [
109
+ { name: "arguments", value: argumentsValue() },
110
+ { name: "error", value: error },
111
+ { name: "result", value: resultValue },
112
+ { name: "this", value: dynUndefinedExpr(loc) },
113
+ ],
114
+ type: call,
115
+ loc,
116
+ },
117
+ ],
118
+ type: F64,
119
+ loc,
120
+ },
121
+ loc,
122
+ });
123
+ const voidReturn = fn.ret.kind === "void" || fn.ret.kind === "undefinedT";
124
+ // The result slot: a checked-dynamic undefined for void functions, R
125
+ // when R already admits undefined, else the `R | undefined` union.
126
+ const asResult = (value) => {
127
+ if (result.kind === "dyn")
128
+ return dynUndefinedExpr(loc);
129
+ if (value !== null && result.kind === "union" && value.type.kind !== "union")
130
+ return {
131
+ kind: "unionWrap",
132
+ unionId: result.unionId,
133
+ tag: lowerer.armTag(result.unionId, value.type),
134
+ value,
135
+ type: result,
136
+ loc,
137
+ };
138
+ if (value !== null)
139
+ return value;
140
+ const unionId = result.unionId;
141
+ return {
142
+ kind: "unionWrap",
143
+ unionId,
144
+ tag: lowerer.armTag(unionId, UNDEFINED_T),
145
+ value: { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc },
146
+ type: result,
147
+ loc,
148
+ };
149
+ };
150
+ const invoke = {
151
+ kind: "callValue",
152
+ callee: varRef("f.0", fn, loc),
153
+ args: paramRefs(),
154
+ type: fn.ret,
155
+ loc,
156
+ };
157
+ const tryBody = voidReturn
158
+ ? [
159
+ { kind: "exprStmt", expr: invoke, loc },
160
+ record(asResult(null), dynUndefinedExpr(loc)),
161
+ { kind: "return", value: null, loc },
162
+ ]
163
+ : [
164
+ { kind: "varDecl", localId: "r.0", init: invoke, loc },
165
+ record(asResult(varRef("r.0", fn.ret, loc)), dynUndefinedExpr(loc)),
166
+ { kind: "return", value: varRef("r.0", fn.ret, loc), loc },
167
+ ];
168
+ const catchBody = [
169
+ record(asResult(null), {
170
+ kind: "caughtToDyn",
171
+ value: varRef("e.0", CAUGHT, loc),
172
+ type: DYN,
173
+ loc,
174
+ }),
175
+ { kind: "rethrow", localId: "e.0", loc },
176
+ ];
177
+ const onceArray = () => recordGet(ctx(), "%once", once, loc);
178
+ const entry = (j) => ({
179
+ kind: "arrayGet",
180
+ arr: onceArray(),
181
+ index: j,
182
+ type: onceEntry,
183
+ loc,
184
+ });
185
+ // The one-time implementation for this call index, used once.
186
+ const pickOnce = countedFor(loc, length(onceArray(), loc), (j) => [
187
+ {
188
+ kind: "if",
189
+ cond: {
190
+ kind: "bin",
191
+ op: "===",
192
+ left: recordGet(entry(j), "at", F64, loc),
193
+ right: varRef("n.0", F64, loc),
194
+ type: BOOL,
195
+ loc,
196
+ },
197
+ then: [
198
+ { kind: "assign", localId: "f.0", value: recordGet(entry(j), "fn", fn, loc), loc },
199
+ {
200
+ kind: "exprStmt",
201
+ expr: {
202
+ kind: "arrIntrinsic",
203
+ method: "splice",
204
+ receiver: onceArray(),
205
+ args: [j, numLit(1, loc)],
206
+ type: once,
207
+ loc,
208
+ },
209
+ loc,
210
+ },
211
+ ],
212
+ else_: null,
213
+ loc,
214
+ },
215
+ ]);
216
+ lowerer.liftedFns.push({
217
+ name: impl,
218
+ params,
219
+ returnType: fn.ret,
220
+ captures: [{ localId: "ctx.0", name: "ctx", type: ctxType }],
221
+ locals: [
222
+ ...params.map((p) => local(p.localId, p.name, p.type)),
223
+ { ...local("ctx.0", "ctx", ctxType), boxed: true },
224
+ local("n.0", "index", F64),
225
+ local("f.0", "implementation", fn, true),
226
+ local("i.0", "entry", F64, true),
227
+ ...(voidReturn ? [] : [local("r.0", "result", fn.ret)]),
228
+ local("e.0", "error", CAUGHT),
229
+ ],
230
+ body: [
231
+ {
232
+ kind: "varDecl",
233
+ localId: "n.0",
234
+ init: length(recordGet(ctx(), "calls", calls, loc), loc),
235
+ loc,
236
+ },
237
+ { kind: "varDecl", localId: "f.0", init: recordGet(ctx(), "%impl", fn, loc), loc },
238
+ pickOnce,
239
+ { kind: "tryCatch", tryBody, catchBody, catchLocalId: "e.0", finallyBody: null, loc },
240
+ ],
241
+ loc,
242
+ });
243
+ lowerer.liftedFns.push({
244
+ name,
245
+ params: [{ localId: "ctx.0", name: "ctx", type: ctxType }],
246
+ returnType: fn,
247
+ locals: [{ ...local("ctx.0", "ctx", ctxType), boxed: true }],
248
+ body: [
249
+ {
250
+ kind: "return",
251
+ value: { kind: "closure", fnName: impl, captures: ["ctx.0"], type: fn, loc },
252
+ loc,
253
+ },
254
+ ],
255
+ loc,
256
+ });
257
+ });
258
+ }
259
+ /** A VOID helper over the context: `%mock.<role>.N(ctx, ...extra)`. */
260
+ function mockHelper(lowerer, ctxType, role, extra, body, loc) {
261
+ return liftOnce(lowerer, ctxType, role, (name) => {
262
+ const ctx = () => varRef("ctx.0", ctxType, loc);
263
+ lowerer.liftedFns.push({
264
+ name,
265
+ params: [
266
+ { localId: "ctx.0", name: "ctx", type: ctxType },
267
+ ...extra.map((e) => ({ localId: e.id, name: e.name, type: e.type })),
268
+ ],
269
+ returnType: VOID,
270
+ locals: [
271
+ local("ctx.0", "ctx", ctxType),
272
+ ...extra.map((e) => local(e.id, e.name, e.type, true)),
273
+ local("i.0", "entry", F64, true),
274
+ ],
275
+ body: [...body(ctx, loc), { kind: "return", value: null, loc }],
276
+ loc,
277
+ });
278
+ });
279
+ }
280
+ /** mock.fn(original, implementation?) and t.mock.fn(...). */
281
+ export function lowerMockFn(lowerer, call, what) {
282
+ const loc = locOf(call);
283
+ const mockType = lowerer.mapTypeOf(lowerer.typeOf(call));
284
+ const shape = mockType?.kind === "record" ? lowerer.shapes.get(mockType.shapeId) : undefined;
285
+ const ctxType = shape?.fields.find((f) => f.name === "mock")?.type;
286
+ if (!mockType ||
287
+ !shape ||
288
+ shape.fields.length !== 2 ||
289
+ !shape.fields.some((f) => f.name === "%call") ||
290
+ !ctxType ||
291
+ !isMockContextType(lowerer, ctxType)) {
292
+ lowerer.noLowering(`${what} of this function type`, call, "mock functions lower for functions with fixed parameters, or a single rest array parameter");
293
+ }
294
+ const { fn, calls, once, result } = mockContextFields(lowerer, ctxType);
295
+ if (fn.ret.kind === "union" && typeKey(result) !== typeKey(fn.ret)) {
296
+ lowerer.noLowering(`${what} of a function returning '${lowerer.fmt(fn.ret)}'`, call, "a union return type needs an undefined arm here (the calls log records undefined for calls that throw)");
297
+ }
298
+ const args = call.arguments;
299
+ if (args.length === 0 || args.length > 2 || args.some(ts.isSpreadElement)) {
300
+ lowerer.noLowering(`${what} with ${args.length} arguments`, call, "the supported forms are mock.fn(original) and mock.fn(original, implementation); mock.fn() and mock options have no lowering");
301
+ }
302
+ const stmts = [];
303
+ const originalLocal = lowerer.declareHiddenLocal("%mockOriginal", fn);
304
+ stmts.push({
305
+ kind: "varDecl",
306
+ localId: originalLocal.id,
307
+ init: lowerer.lowerExprExpecting(args[0], fn),
308
+ loc,
309
+ });
310
+ const implementation = args.length === 2
311
+ ? lowerer.lowerExprExpecting(args[1], fn)
312
+ : varRef(originalLocal.id, fn, loc);
313
+ const ctxLocal = lowerer.declareHiddenLocal("%mockContext", ctxType);
314
+ stmts.push({
315
+ kind: "varDecl",
316
+ localId: ctxLocal.id,
317
+ init: {
318
+ kind: "recordLit",
319
+ fields: [
320
+ { name: "%impl", value: implementation },
321
+ { name: "%once", value: { kind: "arrayLit", elems: [], type: once, loc } },
322
+ { name: "%original", value: varRef(originalLocal.id, fn, loc) },
323
+ { name: "calls", value: { kind: "arrayLit", elems: [], type: calls, loc } },
324
+ ],
325
+ type: ctxType,
326
+ loc,
327
+ },
328
+ loc,
329
+ });
330
+ const factory = mockWrapperFactory(lowerer, ctxType, loc);
331
+ return {
332
+ kind: "seqExpr",
333
+ stmts,
334
+ result: {
335
+ kind: "recordLit",
336
+ fields: [
337
+ {
338
+ name: "%call",
339
+ value: {
340
+ kind: "call",
341
+ callee: factory,
342
+ args: [varRef(ctxLocal.id, ctxType, loc)],
343
+ type: fn,
344
+ loc,
345
+ },
346
+ },
347
+ { name: "mock", value: varRef(ctxLocal.id, ctxType, loc) },
348
+ ],
349
+ type: mockType,
350
+ loc,
351
+ },
352
+ type: mockType,
353
+ loc,
354
+ };
355
+ }
356
+ /** `fn.mock.calls`: a copy of the log, as Node's getter returns. Null for
357
+ * other reads. */
358
+ export function lowerMockContextProperty(lowerer, expr) {
359
+ if (expr.questionDotToken || expr.name.text !== "calls")
360
+ return null;
361
+ const receiverType = lowerer.mapTypeOf(lowerer.typeOf(expr.expression));
362
+ if (!receiverType || !isMockContextType(lowerer, receiverType))
363
+ return null;
364
+ const { calls } = mockContextFields(lowerer, receiverType);
365
+ const loc = locOf(expr);
366
+ return {
367
+ kind: "arrIntrinsic",
368
+ method: "slice",
369
+ receiver: recordGet(lowerer.lowerExpr(expr.expression), "calls", calls, loc),
370
+ args: [],
371
+ type: calls,
372
+ loc,
373
+ };
374
+ }
375
+ /** The fn.mock context's methods. Null for other receivers. */
376
+ export function lowerMockContextCall(lowerer, call, access) {
377
+ const ctxType = lowerer.mapTypeOf(lowerer.typeOf(access.expression));
378
+ if (!ctxType || !isMockContextType(lowerer, ctxType))
379
+ return null;
380
+ const { fn, calls, once, onceEntry } = mockContextFields(lowerer, ctxType);
381
+ const loc = locOf(call);
382
+ const member = access.name.text;
383
+ const args = call.arguments;
384
+ const arity = (min, max = min) => {
385
+ if (args.length < min || args.length > max || args.some(ts.isSpreadElement))
386
+ lowerer.noLowering(`MockFunctionContext.${member} with ${args.length} arguments`, call);
387
+ };
388
+ const helperCall = (helper, extra) => ({
389
+ kind: "call",
390
+ callee: helper,
391
+ args: [lowerer.lowerExpr(access.expression), ...extra],
392
+ type: VOID,
393
+ loc,
394
+ });
395
+ switch (member) {
396
+ case "callCount":
397
+ arity(0);
398
+ return length(recordGet(lowerer.lowerExpr(access.expression), "calls", calls, loc), loc);
399
+ case "mockImplementation": {
400
+ arity(1);
401
+ const helper = mockHelper(lowerer, ctxType, "setImplementation", [{ id: "f.0", name: "implementation", type: fn }], (ctx) => [recordSet(ctx(), "%impl", varRef("f.0", fn, loc), loc)], loc);
402
+ return helperCall(helper, [lowerer.lowerExprExpecting(args[0], fn)]);
403
+ }
404
+ case "mockImplementationOnce": {
405
+ arity(1, 2);
406
+ // onCall defaults to the next call: the log's length (NaN marks the
407
+ // default). A later registration for the same index replaces it, as
408
+ // Node's Map does.
409
+ const helper = mockHelper(lowerer, ctxType, "setImplementationOnce", [
410
+ { id: "f.0", name: "implementation", type: fn },
411
+ { id: "at.0", name: "onCall", type: F64 },
412
+ ], (ctx) => {
413
+ const at = () => varRef("at.0", F64, loc);
414
+ const onceArray = () => recordGet(ctx(), "%once", once, loc);
415
+ return [
416
+ {
417
+ kind: "if",
418
+ cond: { kind: "bin", op: "!==", left: at(), right: at(), type: BOOL, loc },
419
+ then: [
420
+ {
421
+ kind: "assign",
422
+ localId: "at.0",
423
+ value: length(recordGet(ctx(), "calls", calls, loc), loc),
424
+ loc,
425
+ },
426
+ ],
427
+ else_: null,
428
+ loc,
429
+ },
430
+ countedFor(loc, length(onceArray(), loc), (j) => [
431
+ {
432
+ kind: "if",
433
+ cond: {
434
+ kind: "bin",
435
+ op: "===",
436
+ left: recordGet({ kind: "arrayGet", arr: onceArray(), index: j, type: onceEntry, loc }, "at", F64, loc),
437
+ right: at(),
438
+ type: BOOL,
439
+ loc,
440
+ },
441
+ then: [
442
+ {
443
+ kind: "exprStmt",
444
+ expr: {
445
+ kind: "arrIntrinsic",
446
+ method: "splice",
447
+ receiver: onceArray(),
448
+ args: [j, numLit(1, loc)],
449
+ type: once,
450
+ loc,
451
+ },
452
+ loc,
453
+ },
454
+ ],
455
+ else_: null,
456
+ loc,
457
+ },
458
+ ]),
459
+ {
460
+ kind: "exprStmt",
461
+ expr: {
462
+ kind: "arrIntrinsic",
463
+ method: "push",
464
+ receiver: onceArray(),
465
+ args: [
466
+ {
467
+ kind: "recordLit",
468
+ fields: [
469
+ { name: "at", value: at() },
470
+ { name: "fn", value: varRef("f.0", fn, loc) },
471
+ ],
472
+ type: onceEntry,
473
+ loc,
474
+ },
475
+ ],
476
+ type: F64,
477
+ loc,
478
+ },
479
+ loc,
480
+ },
481
+ ];
482
+ }, loc);
483
+ return helperCall(helper, [
484
+ lowerer.lowerExprExpecting(args[0], fn),
485
+ args.length === 2 ? lowerer.lowerExprExpecting(args[1], F64) : numLit(NaN, loc),
486
+ ]);
487
+ }
488
+ case "resetCalls": {
489
+ arity(0);
490
+ const helper = mockHelper(lowerer, ctxType, "resetCalls", [], (ctx) => [
491
+ recordSet(ctx(), "calls", { kind: "arrayLit", elems: [], type: calls, loc }, loc),
492
+ ], loc);
493
+ return helperCall(helper, []);
494
+ }
495
+ case "restore": {
496
+ arity(0);
497
+ const helper = mockHelper(lowerer, ctxType, "restore", [], (ctx) => [recordSet(ctx(), "%impl", recordGet(ctx(), "%original", fn, loc), loc)], loc);
498
+ return helperCall(helper, []);
499
+ }
500
+ default:
501
+ return lowerer.noLowering(`MockFunctionContext.${member}`, call, "calls, callCount, mockImplementation, mockImplementationOnce, resetCalls and restore are the supported mock context members");
502
+ }
503
+ }
504
+ //# sourceMappingURL=lower-mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lower-mock.js","sourceRoot":"","sources":["../../../src/frontend/lowering/lower-mock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;kDAUkD;AAClD,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EACL,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,EACH,WAAW,EACX,IAAI,EACJ,OAAO,GAMR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAetC;uBACuB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AC,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC;aAClF,EACD,GAAG,CACJ,CAAC;YACF,OAAO,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,KAAK,SAAS,EAAE,CAAC;YACf,KAAK,CAAC,CAAC,CAAC,CAAC;YACT,MAAM,MAAM,GAAG,UAAU,CACvB,OAAO,EACP,OAAO,EACP,SAAS,EACT,EAAE,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,EACjF,GAAG,CACJ,CAAC;YACF,OAAO,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD;YACE,OAAO,OAAO,CAAC,UAAU,CACvB,uBAAuB,MAAM,EAAE,EAC/B,IAAI,EACJ,6HAA6H,CAC9H,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -24,7 +24,7 @@ export declare function splitFiles(lowerer: Lowerer): FileParts[];
24
24
  export declare function appendDynamicImportModules(program: ts.Program, order: ts.SourceFile[], onCycle: (cycle: string, reason: string) => void): void;
25
25
  /** Collect pass over the WHOLE program: signatures, class shapes, and
26
26
  * file-scope globals visible everywhere → hoisting, mutual recursion, and
27
- * cross-module references fall out for free. Runs in both passes —
27
+ * cross-module references resolve without extra handling. Runs in both passes —
28
28
  * signatures are cheap and calls resolve against them; only BODY lowering
29
29
  * is reachability-gated. */
30
30
  export declare function collectProgram(lowerer: Lowerer, parts: FileParts[]): void;
@@ -28,6 +28,7 @@ import { funcTypeFromParamShapes, registerOverloadedCallableAlias } from "./call
28
28
  import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl, } from "./lower-stmts.js";
29
29
  import { objectFactoryGlobalType } from "./object-factory-new.js";
30
30
  import { streamClassAliasDecl } from "./lower-stream.js";
31
+ import { isAssertClassNew } from "./assert-instances.js";
31
32
  import { stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf } from "./surfaces.js";
32
33
  import { isNativeBuiltinValueInitializer } from "./lower-builtin-values.js";
33
34
  import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf, } from "./lower-namespaces.js";
@@ -40,6 +41,7 @@ import { cjsModuleRef, cjsModuleRegistryPrelude } from "./lower-node-module.js";
40
41
  import { forkTargetPaths } from "../fork-target.js";
41
42
  import { workerTargetPaths } from "../worker-target.js";
42
43
  import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
44
+ import { handleEventReaderPrelude } from "./lower-event-target.js";
43
45
  /** Program modules selected by statically resolved child_process.fork()
44
46
  * calls join the compiled graph without becoming startup dependencies of
45
47
  * the parent entry. Their guarded init functions are selected by %main only
@@ -224,7 +226,7 @@ export function appendDynamicImportModules(program, order, onCycle) {
224
226
  }
225
227
  /** Collect pass over the WHOLE program: signatures, class shapes, and
226
228
  * file-scope globals visible everywhere → hoisting, mutual recursion, and
227
- * cross-module references fall out for free. Runs in both passes —
229
+ * cross-module references resolve without extra handling. Runs in both passes —
228
230
  * signatures are cheap and calls resolve against them; only BODY lowering
229
231
  * is reachability-gated. */
230
232
  export function collectProgram(lowerer, parts) {
@@ -435,7 +437,7 @@ export function collectNpmImports(lowerer, parts) {
435
437
  // A RELATIVE specifier resolving INTO node_modules (the e2e driver
436
438
  // shape: `import "../node_modules/vercel/dist/index.js"`) is
437
439
  // package code too. Attribute it to the package so unselected source
438
- // receives a diagnostic instead of silently dropping the import.
440
+ // receives a diagnostic instead of dropping the import.
439
441
  const relPkg = npm === null && isRelativeSpecifier(spec)
440
442
  ? packageNameOfPath(resolvePath(dirnamePath(fp.sf.fileName), spec))
441
443
  : null;
@@ -1630,6 +1632,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1630
1632
  // test).
1631
1633
  if (isConst && streamClassAliasDecl(lowerer, decl.name, decl.initializer))
1632
1634
  continue;
1635
+ // `new Assert(...)`: a static instance has no global storage, and any
1636
+ // other instance is refused where its declaration lowers.
1637
+ if (decl.initializer !== undefined &&
1638
+ ts.isNewExpression(stripTypeCasts(decl.initializer)) &&
1639
+ isAssertClassNew(lowerer, stripTypeCasts(decl.initializer)))
1640
+ continue;
1633
1641
  // `const process = globalThis.process` at file scope: a stdlib-
1634
1642
  // global snapshot — alias plumbing, no global storage (see
1635
1643
  // stdlibGlobalAliasDecl; the statement lowering skips it by the
@@ -2716,7 +2724,10 @@ function rememberEvaluationError(lowerer, guardId, body, loc) {
2716
2724
  * re-imports, re-requires) into a cache hit. */
2717
2725
  export function buildMain(lowerer) {
2718
2726
  const loc = { file: lowerer.entry.fileName, start: 0, end: 0 };
2719
- const body = [...cjsModuleRegistryPrelude(lowerer, loc)];
2727
+ const body = [
2728
+ ...cjsModuleRegistryPrelude(lowerer, loc),
2729
+ ...handleEventReaderPrelude(lowerer, loc),
2730
+ ];
2720
2731
  const roots = [lowerer.entry, ...lowerer.forkTargets, ...lowerer.workerTargets];
2721
2732
  const isAsync = roots.some((root) => lowerer.asyncInitFiles.has(root));
2722
2733
  const callRoot = (root) => {