@scriptc/compiler 0.2.6 → 0.2.8

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 (588) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +7 -18
  2. package/dist/backend/cycle-analysis.d.ts +21 -9
  3. package/dist/backend/cycle-analysis.js +139 -67
  4. package/dist/backend/cycle-analysis.js.map +1 -1
  5. package/dist/backend/cycle-analysis.test.js +283 -3
  6. package/dist/backend/cycle-analysis.test.js.map +1 -1
  7. package/dist/backend/cycle-mutability.d.ts +39 -0
  8. package/dist/backend/cycle-mutability.js +205 -0
  9. package/dist/backend/cycle-mutability.js.map +1 -0
  10. package/dist/backend/link-plan-core.d.ts +2 -1
  11. package/dist/backend/link-plan-core.js +15 -3
  12. package/dist/backend/link-plan-core.js.map +1 -1
  13. package/dist/backend/link-plan.d.ts +2 -1
  14. package/dist/backend/link-plan.js.map +1 -1
  15. package/dist/backend/llvm/alloc.d.ts +43 -0
  16. package/dist/backend/llvm/alloc.js +246 -0
  17. package/dist/backend/llvm/alloc.js.map +1 -0
  18. package/dist/backend/llvm/alloc.test.d.ts +1 -0
  19. package/dist/backend/llvm/alloc.test.js +102 -0
  20. package/dist/backend/llvm/alloc.test.js.map +1 -0
  21. package/dist/backend/llvm/blocks.d.ts +9 -0
  22. package/dist/backend/llvm/blocks.js +9 -0
  23. package/dist/backend/llvm/blocks.js.map +1 -1
  24. package/dist/backend/llvm/borrowed-receivers.d.ts +7 -0
  25. package/dist/backend/llvm/borrowed-receivers.js +39 -0
  26. package/dist/backend/llvm/borrowed-receivers.js.map +1 -1
  27. package/dist/backend/llvm/call-lifetimes.d.ts +18 -3
  28. package/dist/backend/llvm/call-lifetimes.js +54 -19
  29. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  30. package/dist/backend/llvm/call-lifetimes.test.js +178 -3
  31. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  32. package/dist/backend/llvm/checked-narrows.d.ts +24 -0
  33. package/dist/backend/llvm/checked-narrows.js +108 -0
  34. package/dist/backend/llvm/checked-narrows.js.map +1 -0
  35. package/dist/backend/llvm/checked-narrows.test.d.ts +1 -0
  36. package/dist/backend/llvm/checked-narrows.test.js +208 -0
  37. package/dist/backend/llvm/checked-narrows.test.js.map +1 -0
  38. package/dist/backend/llvm/classes.d.ts +16 -1
  39. package/dist/backend/llvm/classes.js +60 -49
  40. package/dist/backend/llvm/classes.js.map +1 -1
  41. package/dist/backend/llvm/classes.test.js +68 -6
  42. package/dist/backend/llvm/classes.test.js.map +1 -1
  43. package/dist/backend/llvm/common.d.ts +13 -0
  44. package/dist/backend/llvm/common.js +30 -0
  45. package/dist/backend/llvm/common.js.map +1 -1
  46. package/dist/backend/llvm/constant-callbacks.d.ts +19 -3
  47. package/dist/backend/llvm/constant-callbacks.js +289 -52
  48. package/dist/backend/llvm/constant-callbacks.js.map +1 -1
  49. package/dist/backend/llvm/constant-callbacks.test.js +140 -3
  50. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
  51. package/dist/backend/llvm/debug-info.d.ts +6 -2
  52. package/dist/backend/llvm/debug-info.js +11 -1
  53. package/dist/backend/llvm/debug-info.js.map +1 -1
  54. package/dist/backend/llvm/dense-array-access.d.ts +29 -0
  55. package/dist/backend/llvm/dense-array-access.js +335 -0
  56. package/dist/backend/llvm/dense-array-access.js.map +1 -0
  57. package/dist/backend/llvm/dense-array-access.test.d.ts +1 -0
  58. package/dist/backend/llvm/dense-array-access.test.js +238 -0
  59. package/dist/backend/llvm/dense-array-access.test.js.map +1 -0
  60. package/dist/backend/llvm/dyn.d.ts +38 -0
  61. package/dist/backend/llvm/dyn.js +213 -14
  62. package/dist/backend/llvm/dyn.js.map +1 -1
  63. package/dist/backend/llvm/emitter.d.ts +308 -15
  64. package/dist/backend/llvm/emitter.js +1788 -206
  65. package/dist/backend/llvm/emitter.js.map +1 -1
  66. package/dist/backend/llvm/emitter.test.js +89 -7
  67. package/dist/backend/llvm/emitter.test.js.map +1 -1
  68. package/dist/backend/llvm/expr-async.js +62 -8
  69. package/dist/backend/llvm/expr-async.js.map +1 -1
  70. package/dist/backend/llvm/expr-async.test.d.ts +1 -0
  71. package/dist/backend/llvm/expr-async.test.js +62 -0
  72. package/dist/backend/llvm/expr-async.test.js.map +1 -0
  73. package/dist/backend/llvm/expr-bytes.d.ts +1 -1
  74. package/dist/backend/llvm/expr-bytes.js +85 -8
  75. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  76. package/dist/backend/llvm/expr-callbacks.js +29 -21
  77. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  78. package/dist/backend/llvm/expr-calls.d.ts +5 -0
  79. package/dist/backend/llvm/expr-calls.js +118 -15
  80. package/dist/backend/llvm/expr-calls.js.map +1 -1
  81. package/dist/backend/llvm/expr-containers.d.ts +7 -1
  82. package/dist/backend/llvm/expr-containers.js +246 -32
  83. package/dist/backend/llvm/expr-containers.js.map +1 -1
  84. package/dist/backend/llvm/expr-control.js +113 -8
  85. package/dist/backend/llvm/expr-control.js.map +1 -1
  86. package/dist/backend/llvm/expr-dispatch.js +2 -0
  87. package/dist/backend/llvm/expr-dispatch.js.map +1 -1
  88. package/dist/backend/llvm/expr-dynamic.js +244 -44
  89. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  90. package/dist/backend/llvm/expr-island.js +3 -8
  91. package/dist/backend/llvm/expr-island.js.map +1 -1
  92. package/dist/backend/llvm/expr-primitives.d.ts +1 -1
  93. package/dist/backend/llvm/expr-primitives.js +93 -36
  94. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  95. package/dist/backend/llvm/expr-primitives.test.js +51 -3
  96. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  97. package/dist/backend/llvm/expr-records.js +31 -17
  98. package/dist/backend/llvm/expr-records.js.map +1 -1
  99. package/dist/backend/llvm/expr-stream-bridges.js +96 -29
  100. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  101. package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
  102. package/dist/backend/llvm/expr-stream-callbacks.js +6 -3
  103. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  104. package/dist/backend/llvm/integer-remainder.d.ts +11 -0
  105. package/dist/backend/llvm/integer-remainder.js +91 -0
  106. package/dist/backend/llvm/integer-remainder.js.map +1 -1
  107. package/dist/backend/llvm/layouts.d.ts +3 -1
  108. package/dist/backend/llvm/layouts.js +3 -2
  109. package/dist/backend/llvm/layouts.js.map +1 -1
  110. package/dist/backend/llvm/lazy-captures.d.ts +16 -0
  111. package/dist/backend/llvm/lazy-captures.js +96 -0
  112. package/dist/backend/llvm/lazy-captures.js.map +1 -0
  113. package/dist/backend/llvm/lazy-captures.test.d.ts +1 -0
  114. package/dist/backend/llvm/lazy-captures.test.js +78 -0
  115. package/dist/backend/llvm/lazy-captures.test.js.map +1 -0
  116. package/dist/backend/llvm/lib-abi.js +10 -0
  117. package/dist/backend/llvm/lib-abi.js.map +1 -1
  118. package/dist/backend/llvm/lib-filesystem.js +10 -15
  119. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  120. package/dist/backend/llvm/lib-process.js +8 -8
  121. package/dist/backend/llvm/lib-process.js.map +1 -1
  122. package/dist/backend/llvm/lib-shared.js +1 -0
  123. package/dist/backend/llvm/lib-shared.js.map +1 -1
  124. package/dist/backend/llvm/local-array-reads.d.ts +5 -1
  125. package/dist/backend/llvm/local-array-reads.js +147 -26
  126. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  127. package/dist/backend/llvm/local-array-reads.test.js +85 -4
  128. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  129. package/dist/backend/llvm/local-union-storage.d.ts +5 -1
  130. package/dist/backend/llvm/local-union-storage.js +54 -8
  131. package/dist/backend/llvm/local-union-storage.js.map +1 -1
  132. package/dist/backend/llvm/local-union-storage.test.js +94 -6
  133. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  134. package/dist/backend/llvm/map-number-lookup.d.ts +18 -0
  135. package/dist/backend/llvm/map-number-lookup.js +62 -0
  136. package/dist/backend/llvm/map-number-lookup.js.map +1 -0
  137. package/dist/backend/llvm/map-read-lifetimes.d.ts +6 -0
  138. package/dist/backend/llvm/map-read-lifetimes.js +24 -3
  139. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  140. package/dist/backend/llvm/map-read-lifetimes.test.js +39 -20
  141. package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
  142. package/dist/backend/llvm/nullable-fields.d.ts +28 -0
  143. package/dist/backend/llvm/nullable-fields.js +45 -0
  144. package/dist/backend/llvm/nullable-fields.js.map +1 -0
  145. package/dist/backend/llvm/nullable-fields.test.d.ts +1 -0
  146. package/dist/backend/llvm/nullable-fields.test.js +48 -0
  147. package/dist/backend/llvm/nullable-fields.test.js.map +1 -0
  148. package/dist/backend/llvm/nullable-unions.d.ts +68 -0
  149. package/dist/backend/llvm/nullable-unions.js +132 -0
  150. package/dist/backend/llvm/nullable-unions.js.map +1 -0
  151. package/dist/backend/llvm/publish.d.ts +58 -0
  152. package/dist/backend/llvm/publish.js +286 -0
  153. package/dist/backend/llvm/publish.js.map +1 -0
  154. package/dist/backend/llvm/rebound-parameters.d.ts +12 -0
  155. package/dist/backend/llvm/rebound-parameters.js +72 -0
  156. package/dist/backend/llvm/rebound-parameters.js.map +1 -0
  157. package/dist/backend/llvm/rebound-parameters.test.d.ts +1 -0
  158. package/dist/backend/llvm/rebound-parameters.test.js +67 -0
  159. package/dist/backend/llvm/rebound-parameters.test.js.map +1 -0
  160. package/dist/backend/llvm/reference-effects.d.ts +18 -2
  161. package/dist/backend/llvm/reference-effects.js +106 -16
  162. package/dist/backend/llvm/reference-effects.js.map +1 -1
  163. package/dist/backend/llvm/reference-effects.test.js +52 -1
  164. package/dist/backend/llvm/reference-effects.test.js.map +1 -1
  165. package/dist/backend/llvm/serialized-ir-emission.test.d.ts +1 -0
  166. package/dist/backend/llvm/serialized-ir-emission.test.js +52 -0
  167. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -0
  168. package/dist/backend/llvm/shapes.d.ts +104 -9
  169. package/dist/backend/llvm/shapes.js +356 -46
  170. package/dist/backend/llvm/shapes.js.map +1 -1
  171. package/dist/backend/llvm/shapes.test.js +139 -5
  172. package/dist/backend/llvm/shapes.test.js.map +1 -1
  173. package/dist/backend/llvm/stack-callbacks.js +2 -3
  174. package/dist/backend/llvm/stack-callbacks.js.map +1 -1
  175. package/dist/backend/llvm/stack-captures.d.ts +3 -1
  176. package/dist/backend/llvm/stack-captures.js +5 -3
  177. package/dist/backend/llvm/stack-captures.js.map +1 -1
  178. package/dist/backend/llvm/stack-unions.test.js +43 -3
  179. package/dist/backend/llvm/stack-unions.test.js.map +1 -1
  180. package/dist/backend/llvm/string-construction.d.ts +10 -0
  181. package/dist/backend/llvm/string-construction.js +42 -0
  182. package/dist/backend/llvm/string-construction.js.map +1 -1
  183. package/dist/backend/llvm/string-construction.test.js +1 -1
  184. package/dist/backend/llvm/string-key-hash.d.ts +15 -0
  185. package/dist/backend/llvm/string-key-hash.js +76 -0
  186. package/dist/backend/llvm/string-key-hash.js.map +1 -0
  187. package/dist/backend/llvm/string-key-hash.test.d.ts +1 -0
  188. package/dist/backend/llvm/string-key-hash.test.js +45 -0
  189. package/dist/backend/llvm/string-key-hash.test.js.map +1 -0
  190. package/dist/backend/llvm/string-lifetimes.test.js +65 -15
  191. package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
  192. package/dist/backend/llvm/string-reads.d.ts +7 -0
  193. package/dist/backend/llvm/string-reads.js +76 -0
  194. package/dist/backend/llvm/string-reads.js.map +1 -0
  195. package/dist/backend/llvm/switch-dispatch.js +1 -1
  196. package/dist/backend/llvm/switch-dispatch.js.map +1 -1
  197. package/dist/backend/llvm/switch-dispatch.test.js +3 -3
  198. package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
  199. package/dist/backend/llvm/test-boxed-unions.d.ts +5 -0
  200. package/dist/backend/llvm/test-boxed-unions.js +13 -0
  201. package/dist/backend/llvm/test-boxed-unions.js.map +1 -0
  202. package/dist/backend/llvm/union-repr.d.ts +15 -0
  203. package/dist/backend/llvm/union-repr.js +89 -0
  204. package/dist/backend/llvm/union-repr.js.map +1 -0
  205. package/dist/backend/llvm/virtual-borrows.d.ts +31 -0
  206. package/dist/backend/llvm/virtual-borrows.js +82 -0
  207. package/dist/backend/llvm/virtual-borrows.js.map +1 -0
  208. package/dist/backend/llvm/walk-borrows.d.ts +43 -0
  209. package/dist/backend/llvm/walk-borrows.js +150 -0
  210. package/dist/backend/llvm/walk-borrows.js.map +1 -0
  211. package/dist/backend/llvm/walk-borrows.test.d.ts +1 -0
  212. package/dist/backend/llvm/walk-borrows.test.js +119 -0
  213. package/dist/backend/llvm/walk-borrows.test.js.map +1 -0
  214. package/dist/backend/llvm/walkers.d.ts +5 -1
  215. package/dist/backend/llvm/walkers.js +24 -21
  216. package/dist/backend/llvm/walkers.js.map +1 -1
  217. package/dist/backend/may-throw.d.ts +29 -1
  218. package/dist/backend/may-throw.js +349 -3
  219. package/dist/backend/may-throw.js.map +1 -1
  220. package/dist/backend/may-throw.test.js +114 -2
  221. package/dist/backend/may-throw.test.js.map +1 -1
  222. package/dist/backend/native/cache-warm.d.ts +2 -1
  223. package/dist/backend/native/cache-warm.js.map +1 -1
  224. package/dist/backend/native/contracts.d.ts +3 -2
  225. package/dist/backend/native/contracts.js.map +1 -1
  226. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  227. package/dist/backend/native/runtime-inputs.js +2 -0
  228. package/dist/backend/native/runtime-inputs.js.map +1 -1
  229. package/dist/backend/native-codegen-core.d.ts +7 -4
  230. package/dist/backend/native-codegen-core.js +14 -9
  231. package/dist/backend/native-codegen-core.js.map +1 -1
  232. package/dist/backend/native-codegen.d.ts +9 -0
  233. package/dist/backend/native-codegen.js +53 -2
  234. package/dist/backend/native-codegen.js.map +1 -1
  235. package/dist/backend/native-codegen.test.js +64 -10
  236. package/dist/backend/native-codegen.test.js.map +1 -1
  237. package/dist/backend/native-link-info-core.d.ts +3 -2
  238. package/dist/backend/native-link-info-core.js.map +1 -1
  239. package/dist/backend/native-link-info.d.ts +2 -1
  240. package/dist/backend/native-link-info.js.map +1 -1
  241. package/dist/backend/native-link-info.test.js +2 -2
  242. package/dist/backend/native-link-info.test.js.map +1 -1
  243. package/dist/backend/native-tools.d.ts +5 -1
  244. package/dist/backend/native-tools.js +3 -1
  245. package/dist/backend/native-tools.js.map +1 -1
  246. package/dist/backend/optimization.d.ts +25 -0
  247. package/dist/backend/optimization.js +21 -0
  248. package/dist/backend/optimization.js.map +1 -0
  249. package/dist/backend/optimization.test.d.ts +1 -0
  250. package/dist/backend/optimization.test.js +24 -0
  251. package/dist/backend/optimization.test.js.map +1 -0
  252. package/dist/backend/publication.d.ts +28 -0
  253. package/dist/backend/publication.js +155 -0
  254. package/dist/backend/publication.js.map +1 -0
  255. package/dist/backend/publication.test.d.ts +1 -0
  256. package/dist/backend/publication.test.js +72 -0
  257. package/dist/backend/publication.test.js.map +1 -0
  258. package/dist/backend/runtime-abi.d.ts +2 -2
  259. package/dist/backend/runtime-abi.js +2 -2
  260. package/dist/backend/runtime-pack-core.d.ts +15 -4
  261. package/dist/backend/runtime-pack-core.js +23 -12
  262. package/dist/backend/runtime-pack-core.js.map +1 -1
  263. package/dist/backend/runtime-pack-native.d.ts +7 -3
  264. package/dist/backend/runtime-pack-native.js +0 -3
  265. package/dist/backend/runtime-pack-native.js.map +1 -1
  266. package/dist/backend/runtime-pack-targets.test.js +1 -1
  267. package/dist/backend/runtime-pack.d.ts +20 -2
  268. package/dist/backend/runtime-pack.js +23 -0
  269. package/dist/backend/runtime-pack.js.map +1 -1
  270. package/dist/backend/runtime-pack.test.js +115 -2
  271. package/dist/backend/runtime-pack.test.js.map +1 -1
  272. package/dist/backend/target-diagnostics.test.js +1 -1
  273. package/dist/backend/targets.d.ts +2 -1
  274. package/dist/backend/targets.js +1 -1
  275. package/dist/backend/targets.js.map +1 -1
  276. package/dist/cli/command.js +75 -11
  277. package/dist/cli/command.js.map +1 -1
  278. package/dist/cli/host.d.ts +2 -1
  279. package/dist/cli/usage.d.ts +4 -1
  280. package/dist/cli/usage.js +13 -3
  281. package/dist/cli/usage.js.map +1 -1
  282. package/dist/compile-types.d.ts +17 -5
  283. package/dist/coverage/report.d.ts +25 -2
  284. package/dist/coverage/report.js +161 -33
  285. package/dist/coverage/report.js.map +1 -1
  286. package/dist/coverage/verdict-cache.d.ts +63 -0
  287. package/dist/coverage/verdict-cache.js +193 -0
  288. package/dist/coverage/verdict-cache.js.map +1 -0
  289. package/dist/coverage/verdict-cache.test.d.ts +1 -0
  290. package/dist/coverage/verdict-cache.test.js +52 -0
  291. package/dist/coverage/verdict-cache.test.js.map +1 -0
  292. package/dist/coverage/verdict-semantic.d.ts +2 -0
  293. package/dist/coverage/verdict-semantic.js +24 -0
  294. package/dist/coverage/verdict-semantic.js.map +1 -0
  295. package/dist/coverage/verdict-startup.d.ts +15 -0
  296. package/dist/coverage/verdict-startup.js +66 -0
  297. package/dist/coverage/verdict-startup.js.map +1 -0
  298. package/dist/diagnostics/diagnostic.d.ts +29 -1
  299. package/dist/diagnostics/diagnostic.js +84 -12
  300. package/dist/diagnostics/diagnostic.js.map +1 -1
  301. package/dist/diagnostics/envelope.d.ts +130 -0
  302. package/dist/diagnostics/envelope.js +257 -0
  303. package/dist/diagnostics/envelope.js.map +1 -0
  304. package/dist/diagnostics/envelope.test.d.ts +1 -0
  305. package/dist/diagnostics/envelope.test.js +91 -0
  306. package/dist/diagnostics/envelope.test.js.map +1 -0
  307. package/dist/diagnostics/render.d.ts +3 -0
  308. package/dist/diagnostics/render.js +13 -2
  309. package/dist/diagnostics/render.js.map +1 -1
  310. package/dist/executable/executable-cache.d.ts +2 -2
  311. package/dist/executable/executable-cache.js +7 -4
  312. package/dist/executable/executable-cache.js.map +1 -1
  313. package/dist/executable/executable-cache.test.js +20 -0
  314. package/dist/executable/executable-cache.test.js.map +1 -1
  315. package/dist/executable/prepare.d.ts +4 -0
  316. package/dist/executable/prepare.js +7 -1
  317. package/dist/executable/prepare.js.map +1 -1
  318. package/dist/frontend/analysis.js +1 -0
  319. package/dist/frontend/analysis.js.map +1 -1
  320. package/dist/frontend/lowering/abstract-equality.js +5 -49
  321. package/dist/frontend/lowering/abstract-equality.js.map +1 -1
  322. package/dist/frontend/lowering/array-values.d.ts +30 -0
  323. package/dist/frontend/lowering/array-values.js +246 -1
  324. package/dist/frontend/lowering/array-values.js.map +1 -1
  325. package/dist/frontend/lowering/builtins/errors.js +17 -2
  326. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  327. package/dist/frontend/lowering/builtins/numbers.js +29 -1
  328. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  329. package/dist/frontend/lowering/builtins/process.d.ts +10 -17
  330. package/dist/frontend/lowering/builtins/process.js +66 -29
  331. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  332. package/dist/frontend/lowering/builtins/workers.js +4 -2
  333. package/dist/frontend/lowering/builtins/workers.js.map +1 -1
  334. package/dist/frontend/lowering/caught-value-dispatch.d.ts +11 -0
  335. package/dist/frontend/lowering/caught-value-dispatch.js +87 -0
  336. package/dist/frontend/lowering/caught-value-dispatch.js.map +1 -0
  337. package/dist/frontend/lowering/class-assertions.d.ts +12 -0
  338. package/dist/frontend/lowering/class-assertions.js +229 -5
  339. package/dist/frontend/lowering/class-assertions.js.map +1 -1
  340. package/dist/frontend/lowering/class-callbacks.d.ts +3 -3
  341. package/dist/frontend/lowering/class-callbacks.js +18 -5
  342. package/dist/frontend/lowering/class-callbacks.js.map +1 -1
  343. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +1 -0
  344. package/dist/frontend/lowering/class-dynamic-dispatch.js +12 -6
  345. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  346. package/dist/frontend/lowering/class-method-mutations.d.ts +5 -0
  347. package/dist/frontend/lowering/class-method-mutations.js +472 -0
  348. package/dist/frontend/lowering/class-method-mutations.js.map +1 -0
  349. package/dist/frontend/lowering/class-method-values.js +25 -5
  350. package/dist/frontend/lowering/class-method-values.js.map +1 -1
  351. package/dist/frontend/lowering/class-prototypes.js +8 -2
  352. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  353. package/dist/frontend/lowering/class-unions.d.ts +16 -0
  354. package/dist/frontend/lowering/class-unions.js +127 -0
  355. package/dist/frontend/lowering/class-unions.js.map +1 -0
  356. package/dist/frontend/lowering/coercions/builders.js +8 -1
  357. package/dist/frontend/lowering/coercions/builders.js.map +1 -1
  358. package/dist/frontend/lowering/coercions/function-adapters.js +2 -0
  359. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  360. package/dist/frontend/lowering/coercions/identity.d.ts +7 -0
  361. package/dist/frontend/lowering/coercions/identity.js +26 -0
  362. package/dist/frontend/lowering/coercions/identity.js.map +1 -0
  363. package/dist/frontend/lowering/coercions/state.d.ts +6 -0
  364. package/dist/frontend/lowering/coercions/state.js +2 -0
  365. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  366. package/dist/frontend/lowering/coercions/structural.js +9 -6
  367. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  368. package/dist/frontend/lowering/coercions/unions.d.ts +8 -0
  369. package/dist/frontend/lowering/coercions/unions.js +67 -2
  370. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  371. package/dist/frontend/lowering/collation-repertoire.d.ts +1 -0
  372. package/dist/frontend/lowering/collation-repertoire.js +19 -0
  373. package/dist/frontend/lowering/collation-repertoire.js.map +1 -0
  374. package/dist/frontend/lowering/collection-narrowing.d.ts +6 -0
  375. package/dist/frontend/lowering/collection-narrowing.js +31 -0
  376. package/dist/frontend/lowering/collection-narrowing.js.map +1 -0
  377. package/dist/frontend/lowering/construction-escapes.d.ts +38 -0
  378. package/dist/frontend/lowering/construction-escapes.js +146 -0
  379. package/dist/frontend/lowering/construction-escapes.js.map +1 -0
  380. package/dist/frontend/lowering/construction-escapes.test.d.ts +1 -0
  381. package/dist/frontend/lowering/construction-escapes.test.js +150 -0
  382. package/dist/frontend/lowering/construction-escapes.test.js.map +1 -0
  383. package/dist/frontend/lowering/containers/array-callback-call.d.ts +7 -0
  384. package/dist/frontend/lowering/containers/array-callback-call.js +52 -0
  385. package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -0
  386. package/dist/frontend/lowering/containers/array-callbacks.d.ts +1 -1
  387. package/dist/frontend/lowering/containers/array-callbacks.js +416 -65
  388. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  389. package/dist/frontend/lowering/containers/array-concat.d.ts +7 -0
  390. package/dist/frontend/lowering/containers/array-concat.js +130 -0
  391. package/dist/frontend/lowering/containers/array-concat.js.map +1 -0
  392. package/dist/frontend/lowering/containers/array-construction.d.ts +2 -0
  393. package/dist/frontend/lowering/containers/array-construction.js +110 -5
  394. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  395. package/dist/frontend/lowering/containers/array-methods.d.ts +1 -11
  396. package/dist/frontend/lowering/containers/array-methods.js +274 -144
  397. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  398. package/dist/frontend/lowering/containers/callback-arguments.js +43 -1
  399. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  400. package/dist/frontend/lowering/containers/collection-methods.js +10 -1
  401. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  402. package/dist/frontend/lowering/containers/indexed-objects.js +56 -70
  403. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  404. package/dist/frontend/lowering/containers/string-and-regexp.js +7 -63
  405. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  406. package/dist/frontend/lowering/cycle-initialization.d.ts +46 -0
  407. package/dist/frontend/lowering/cycle-initialization.js +303 -0
  408. package/dist/frontend/lowering/cycle-initialization.js.map +1 -0
  409. package/dist/frontend/lowering/divergences.d.ts +9 -0
  410. package/dist/frontend/lowering/divergences.js +630 -0
  411. package/dist/frontend/lowering/divergences.js.map +1 -0
  412. package/dist/frontend/lowering/expressions/evaluation-safety.js +4 -0
  413. package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
  414. package/dist/frontend/lowering/expressions/object-literals.js +178 -34
  415. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  416. package/dist/frontend/lowering/expressions/union-field-write.d.ts +4 -4
  417. package/dist/frontend/lowering/expressions/union-field-write.js +54 -44
  418. package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -1
  419. package/dist/frontend/lowering/iterator-adapters.d.ts +20 -0
  420. package/dist/frontend/lowering/iterator-adapters.js +605 -0
  421. package/dist/frontend/lowering/iterator-adapters.js.map +1 -0
  422. package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
  423. package/dist/frontend/lowering/lower-array-sort.js +44 -5
  424. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  425. package/dist/frontend/lowering/lower-array-sort.test.d.ts +1 -0
  426. package/dist/frontend/lowering/lower-array-sort.test.js +31 -0
  427. package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -0
  428. package/dist/frontend/lowering/lower-assert.js +7 -0
  429. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  430. package/dist/frontend/lowering/lower-builtin-values.js +1 -0
  431. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  432. package/dist/frontend/lowering/lower-calls.d.ts +8 -3
  433. package/dist/frontend/lowering/lower-calls.js +388 -278
  434. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  435. package/dist/frontend/lowering/lower-classes.d.ts +6 -0
  436. package/dist/frontend/lowering/lower-classes.js +117 -65
  437. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  438. package/dist/frontend/lowering/lower-exprs.d.ts +22 -2
  439. package/dist/frontend/lowering/lower-exprs.js +811 -254
  440. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  441. package/dist/frontend/lowering/lower-functions.js +32 -19
  442. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  443. package/dist/frontend/lowering/lower-generators.d.ts +19 -13
  444. package/dist/frontend/lowering/lower-generators.js +67 -44
  445. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  446. package/dist/frontend/lowering/lower-inspect.js +29 -4
  447. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  448. package/dist/frontend/lowering/lower-island.d.ts +1 -1
  449. package/dist/frontend/lowering/lower-island.js +24 -7
  450. package/dist/frontend/lowering/lower-island.js.map +1 -1
  451. package/dist/frontend/lowering/lower-modules.js +100 -3
  452. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  453. package/dist/frontend/lowering/lower-stmts.js +82 -64
  454. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  455. package/dist/frontend/lowering/lowerer.d.ts +115 -2
  456. package/dist/frontend/lowering/lowerer.js +1266 -88
  457. package/dist/frontend/lowering/lowerer.js.map +1 -1
  458. package/dist/frontend/lowering/native-ffi.js +3 -1
  459. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  460. package/dist/frontend/lowering/runtime-optional-bounds.d.ts +19 -0
  461. package/dist/frontend/lowering/runtime-optional-bounds.js +354 -0
  462. package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -0
  463. package/dist/frontend/lowering/runtime-optional-bounds.test.d.ts +1 -0
  464. package/dist/frontend/lowering/runtime-optional-bounds.test.js +66 -0
  465. package/dist/frontend/lowering/runtime-optional-bounds.test.js.map +1 -0
  466. package/dist/frontend/lowering/runtime-optional-elements.d.ts +117 -0
  467. package/dist/frontend/lowering/runtime-optional-elements.js +738 -0
  468. package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -0
  469. package/dist/frontend/lowering/runtime-optional-guards.d.ts +36 -0
  470. package/dist/frontend/lowering/runtime-optional-guards.js +375 -0
  471. package/dist/frontend/lowering/runtime-optional-guards.js.map +1 -0
  472. package/dist/frontend/lowering/runtime-optional-guards.test.d.ts +1 -0
  473. package/dist/frontend/lowering/runtime-optional-guards.test.js +92 -0
  474. package/dist/frontend/lowering/runtime-optional-guards.test.js.map +1 -0
  475. package/dist/frontend/lowering/runtime-optional-ownership.d.ts +63 -0
  476. package/dist/frontend/lowering/runtime-optional-ownership.js +382 -0
  477. package/dist/frontend/lowering/runtime-optional-ownership.js.map +1 -0
  478. package/dist/frontend/lowering/runtime-optional-provenance.d.ts +16 -0
  479. package/dist/frontend/lowering/runtime-optional-provenance.js +41 -0
  480. package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -0
  481. package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
  482. package/dist/frontend/lowering/strict-equality.d.ts +9 -0
  483. package/dist/frontend/lowering/strict-equality.js +116 -0
  484. package/dist/frontend/lowering/strict-equality.js.map +1 -0
  485. package/dist/frontend/lowering/string-index-bounds.d.ts +36 -0
  486. package/dist/frontend/lowering/string-index-bounds.js +537 -0
  487. package/dist/frontend/lowering/string-index-bounds.js.map +1 -0
  488. package/dist/frontend/lowering/string-index-bounds.test.d.ts +1 -0
  489. package/dist/frontend/lowering/string-index-bounds.test.js +223 -0
  490. package/dist/frontend/lowering/string-index-bounds.test.js.map +1 -0
  491. package/dist/frontend/lowering/surfaces.js +3 -0
  492. package/dist/frontend/lowering/surfaces.js.map +1 -1
  493. package/dist/frontend/lowering/union-comparison.d.ts +5 -0
  494. package/dist/frontend/lowering/union-comparison.js +47 -0
  495. package/dist/frontend/lowering/union-comparison.js.map +1 -0
  496. package/dist/frontend/lowering/union-narrow.d.ts +2 -0
  497. package/dist/frontend/lowering/union-narrow.js +10 -6
  498. package/dist/frontend/lowering/union-narrow.js.map +1 -1
  499. package/dist/frontend/program-analysis.d.ts +10 -0
  500. package/dist/frontend/program-analysis.js +7 -0
  501. package/dist/frontend/program-analysis.js.map +1 -1
  502. package/dist/frontend/program.d.ts +63 -2
  503. package/dist/frontend/program.js +1038 -61
  504. package/dist/frontend/program.js.map +1 -1
  505. package/dist/frontend/program.test.js +122 -6
  506. package/dist/frontend/program.test.js.map +1 -1
  507. package/dist/frontend/resolve.d.ts +6 -0
  508. package/dist/frontend/resolve.js +14 -0
  509. package/dist/frontend/resolve.js.map +1 -1
  510. package/dist/frontend/threads-import.d.ts +5 -0
  511. package/dist/frontend/threads-import.js +21 -0
  512. package/dist/frontend/threads-import.js.map +1 -0
  513. package/dist/frontend/type-mapper.d.ts +4 -1
  514. package/dist/frontend/type-mapper.js +161 -20
  515. package/dist/frontend/type-mapper.js.map +1 -1
  516. package/dist/frontend/type-mapper.test.js +15 -3
  517. package/dist/frontend/type-mapper.test.js.map +1 -1
  518. package/dist/frontend/worker-target.d.ts +4 -0
  519. package/dist/frontend/worker-target.js +8 -1
  520. package/dist/frontend/worker-target.js.map +1 -1
  521. package/dist/index.d.ts +6 -1
  522. package/dist/index.js +70 -16
  523. package/dist/index.js.map +1 -1
  524. package/dist/ir/analysis.d.ts +3 -1
  525. package/dist/ir/analysis.js +4 -0
  526. package/dist/ir/analysis.js.map +1 -1
  527. package/dist/ir/build.d.ts +5 -0
  528. package/dist/ir/build.js +7 -0
  529. package/dist/ir/build.js.map +1 -1
  530. package/dist/ir/builtin-signatures.d.ts +1 -1
  531. package/dist/ir/builtin-signatures.js +5 -3
  532. package/dist/ir/builtin-signatures.js.map +1 -1
  533. package/dist/ir/constant-tables.test.js +1 -1
  534. package/dist/ir/initializer-bindings.test.js +1 -1
  535. package/dist/ir/int32-slots.d.ts +72 -0
  536. package/dist/ir/int32-slots.js +837 -0
  537. package/dist/ir/int32-slots.js.map +1 -0
  538. package/dist/ir/int32-slots.test.d.ts +1 -0
  539. package/dist/ir/int32-slots.test.js +222 -0
  540. package/dist/ir/int32-slots.test.js.map +1 -0
  541. package/dist/ir/integer-ranges.d.ts +19 -3
  542. package/dist/ir/integer-ranges.js +168 -23
  543. package/dist/ir/integer-ranges.js.map +1 -1
  544. package/dist/ir/integer-ranges.test.js +74 -2
  545. package/dist/ir/integer-ranges.test.js.map +1 -1
  546. package/dist/ir/ir.d.ts +101 -20
  547. package/dist/ir/ir.js +20 -6
  548. package/dist/ir/ir.js.map +1 -1
  549. package/dist/ir/scalar-records.test.js +1 -1
  550. package/dist/ir/serialize.d.ts +1 -1
  551. package/dist/ir/serialize.js +3 -3
  552. package/dist/ir/serialize.js.map +1 -1
  553. package/dist/ir/traverse.js +8 -0
  554. package/dist/ir/traverse.js.map +1 -1
  555. package/dist/ir/validate.js +139 -22
  556. package/dist/ir/validate.js.map +1 -1
  557. package/dist/ir/validate.test.js +308 -8
  558. package/dist/ir/validate.test.js.map +1 -1
  559. package/dist/library/fence-eval.test.js +1 -1
  560. package/dist/library/int-infer.test.js +4 -4
  561. package/dist/library/library-cache.test.js +5 -5
  562. package/dist/library/library-profile.d.ts +2 -1
  563. package/dist/library/library-profile.js +4 -3
  564. package/dist/library/library-profile.js.map +1 -1
  565. package/dist/native/cache.d.ts +3 -0
  566. package/dist/native/cache.js +49 -1
  567. package/dist/native/cache.js.map +1 -1
  568. package/dist/native/cache.test.js +21 -1
  569. package/dist/native/cache.test.js.map +1 -1
  570. package/dist/native/cli.js +1 -1
  571. package/dist/native/cli.js.map +1 -1
  572. package/dist/native/compiler.d.ts +5 -0
  573. package/dist/native/compiler.js +51 -4
  574. package/dist/native/compiler.js.map +1 -1
  575. package/dist/native/compiler.test.js +2 -2
  576. package/dist/native/library.d.ts +2 -1
  577. package/dist/native/library.js.map +1 -1
  578. package/dist/native/prepare.d.ts +4 -0
  579. package/dist/native/prepare.js +28 -3
  580. package/dist/native/prepare.js.map +1 -1
  581. package/dist/native/sanitizer.d.ts +3 -2
  582. package/dist/native/sanitizer.js +3 -13
  583. package/dist/native/sanitizer.js.map +1 -1
  584. package/dist/startup-cache.d.ts +2 -0
  585. package/dist/startup-cache.js +2 -0
  586. package/dist/startup-cache.js.map +1 -1
  587. package/package.json +20 -20
  588. package/surface-manifest.json +8 -2
@@ -1,18 +1,24 @@
1
1
  import type { IrBytesElem, IrExpr, IrFfiImport, IrFunction, IrLocal, IrModule, IrRecordShape, IrStmt, IrType, IrUnionDef, SrcLoc } from "../../ir/ir.js";
2
2
  import { type SplitSpan } from "./split-loops.js";
3
3
  import { type IntegerRanges } from "../../ir/integer-ranges.js";
4
+ import { type Int32Slots } from "../../ir/int32-slots.js";
4
5
  import { type ConstantNumericTable } from "../../ir/constant-tables.js";
5
6
  import { type FfiCallbackAdapter } from "../ffi-callbacks.js";
6
7
  import { type CallLifetimes } from "./call-lifetimes.js";
7
8
  import { BlockBuilder } from "./blocks.js";
8
- import { type LocalArrayRead } from "./local-array-reads.js";
9
+ import { NullableRefFields, type NullableRefField } from "./nullable-fields.js";
10
+ import { OptionalArrayReads, type LocalArrayRead } from "./local-array-reads.js";
11
+ import { CheckedNarrows } from "./checked-narrows.js";
9
12
  import { type MapReadLifetimes } from "./map-read-lifetimes.js";
10
13
  import { ReferenceEffects } from "./reference-effects.js";
11
14
  import { StackCallbacks } from "./stack-callbacks.js";
15
+ import { AmbientReceiverReaders } from "./constant-callbacks.js";
12
16
  import { type StringSliceSnapshot } from "./string-slices.js";
17
+ import { type PublishedTypes } from "../publication.js";
13
18
  import { type LlClassMeta } from "./classes.js";
14
19
  import { LlDyn, type DynHost } from "./dyn.js";
15
20
  import { LlWalkers } from "./walkers.js";
21
+ import { NullableUnions } from "./nullable-unions.js";
16
22
  import { type MapKeyAccess } from "./shapes.js";
17
23
  import type { ExprOf, LibCallExpr, LlStreamTypedRefAdapter, LlValue } from "./expr-context.js";
18
24
  export { LlvmUnsupportedError } from "./unsupported.js";
@@ -31,6 +37,14 @@ export interface LlvmTargetOptions {
31
37
  /** Program objects carry a strong reference to the matching runtime ABI
32
38
  * marker so manual links against an incompatible runtime fail loudly. */
33
39
  runtimeAbiMarker?: boolean;
40
+ /** Emit live-object audit notes in emitted new/free helpers. Only the
41
+ * sanitized lane's SCR_RC_AUDIT runtime counts them; production plain
42
+ * builds pass false so release/dev objects carry no empty calls.
43
+ * Defaults to true for direct emission. */
44
+ objectAudit?: boolean;
45
+ /** Emit retain/release fast paths inline (the `speed` posture). Off, every
46
+ * retain and release is a runtime call. */
47
+ inlineRc?: boolean;
34
48
  }
35
49
  export declare function emitLlvmModule(mod: IrModule, options?: LlvmTargetOptions): string;
36
50
  /** Keep large translation units below the host's single-string limit. */
@@ -61,15 +75,23 @@ export declare class LlEmitter {
61
75
  readonly ffiExtendNarrowIntegers: boolean;
62
76
  readonly cycleColorOffset: number;
63
77
  readonly wasi: boolean;
78
+ /** ELF worker executables give thread-locals the executable TLS models. */
79
+ private readonly executableTls;
64
80
  private readonly emitLibraryIdentity;
65
81
  private readonly runtimeAbiMarker;
66
82
  /** Interned string literals: UTF-8 text → { symbol, byte length } —
67
83
  * first-use order, the runtime ABI’s determinism discipline. */
68
84
  private readonly literals;
85
+ /** Symbols of interned constant data, named by content (contentSymbol). */
86
+ private readonly contentSymbols;
69
87
  /** Interned unit-armed union instances: "unionId:tag" → symbol — one
70
88
  * immortal (rc == SIZE_MAX) static per (union, unit tag).
71
89
  * RC entry points and the collector skip immortals. */
72
90
  private readonly unitInstances;
91
+ /** unionId → symbol of the union's immortal ABSENT field-slot instance. */
92
+ private readonly absentInstances;
93
+ /** The nullable-union ABSENT sentinel was referenced (absentInstanceRef). */
94
+ private needsNullableAbsent;
73
95
  private readonly immortalValues;
74
96
  /** Regex literal templates: "<flags>/<pattern>" → { symbol, interned
75
97
  * source/flags literal refs } — one immortal ScrRegex template per distinct
@@ -110,18 +132,45 @@ export declare class LlEmitter {
110
132
  needsBadTag: boolean;
111
133
  needsBadKey: boolean;
112
134
  private needsRetainBox;
135
+ /** Inline RC fast-path helpers requested by call sites (shapes.ts); null
136
+ * when inline RC is off. */
137
+ private readonly rcHelpers;
113
138
  readonly fnByName: Map<string, IrFunction>;
139
+ /** Emitted LLVM text of every IR function body, by function name: the
140
+ * fiberless-async analysis scans it for suspension entry points. */
141
+ private readonly fnDefText;
114
142
  readonly referenceEffects: ReferenceEffects;
115
- private readonly optionalArrayReads;
143
+ readonly optionalArrayReads: OptionalArrayReads;
144
+ readonly checkedNarrows: CheckedNarrows;
116
145
  callArrayReads: Map<IrExpr, LocalArrayRead>;
117
146
  mapReadLifetimes: MapReadLifetimes;
118
147
  readonly callLifetimes: CallLifetimes;
119
148
  readonly constantCallbacks: Map<string, Map<string, string>>;
120
149
  currentConstantCallbacks: ReadonlyMap<string, string>;
121
150
  readonly stackCallbacks: StackCallbacks;
151
+ readonly receiverReaders: AmbientReceiverReaders;
122
152
  private readonly stackCaptures;
153
+ private readonly lazyCaptures;
154
+ /** Unchanged captured parameters of the current function: each maps to
155
+ * the slot caching its box, NULL until the first closure needs it. */
156
+ private readonly lazyCaptureBoxes;
157
+ private readonly lazyStackBoxes;
123
158
  private borrowedParameters;
159
+ /** Parameters proven projection-only: callers may pass stack boxes. */
160
+ private projectedParameters;
124
161
  private stableCallBindings;
162
+ /** Locals and rebound parameters holding borrowed pointers for their
163
+ * whole lifetime (walk-borrows.ts), per function and for the current one. */
164
+ private readonly walkBorrowsByFunction;
165
+ private walkBorrows;
166
+ /** Functions whose borrowing body returns its result without a reference
167
+ * (analyzeBorrowedReturns), and whether the current body is one. */
168
+ readonly borrowedReturns: Set<string>;
169
+ /** Rebound parameters that keep the borrowed convention with an owner
170
+ * slot (rebound-parameters.ts), per function, and the current owner slots. */
171
+ private readonly reboundByFunction;
172
+ private readonly reboundOwnerSlots;
173
+ private currentBorrowedReturn;
125
174
  /** Manifest-bound native imports, used by ffiCall emission. */
126
175
  readonly ffiByName: Map<string, IrFfiImport>;
127
176
  /** C-ABI callback trampolines and (for raw/no-userdata callbacks) their
@@ -140,6 +189,15 @@ export declare class LlEmitter {
140
189
  * checks are emitted only after calls that can actually raise. */
141
190
  readonly mayThrow: Set<string>;
142
191
  readonly indirectMayThrow: boolean;
192
+ /** Worker programs: the functions that poll for termination on entry
193
+ * (workerTerminationPolls); null outside worker programs. */
194
+ private readonly workerEntryPolls;
195
+ /** Functions that check the native stack guard on entry
196
+ * (stackCheckedFunctions); null where the runtime has no guard. */
197
+ private readonly stackChecks;
198
+ /** Static types whose values can be published (@scriptc/threads): their
199
+ * stores carry the frozen-object guard. Null without publish calls. */
200
+ readonly publishedTypes: PublishedTypes | null;
143
201
  /** Method names with at least one may-throw implementation — the
144
202
  * virtualCall pending check's key. */
145
203
  readonly mayThrowMethods: Set<string>;
@@ -160,6 +218,11 @@ export declare class LlEmitter {
160
218
  readonly liveDynUnionRefAdapters: Map<string, string>;
161
219
  readonly dynPromiseAdapters: Map<string, string>;
162
220
  readonly unionsById: Map<string, IrUnionDef>;
221
+ readonly nullableFields: NullableRefFields;
222
+ /** Unions whose values are nullable arm pointers (nullable-unions.ts). */
223
+ readonly nullableUnions: NullableUnions;
224
+ /** The union table without nullable unions: the stack-box analyses. */
225
+ readonly boxedUnionsById: Map<string, IrUnionDef>;
163
226
  readonly recordsById: Map<string, IrRecordShape>;
164
227
  readonly recordCloneShapes: Set<string>;
165
228
  readonly tracedShapes: Set<string>;
@@ -167,6 +230,8 @@ export declare class LlEmitter {
167
230
  /** The class graph (buildClassGraph): preorder numbering, hierarchy
168
231
  * membership, virtual slot lists. */
169
232
  readonly classMeta: Map<string, LlClassMeta>;
233
+ /** Which vtable slots borrow which parameters (virtual-borrows.ts). */
234
+ private virtualBorrows;
170
235
  /** Class objects (classes as first-class values): className → the
171
236
  * interned .name literal ref — registered during body emission, the
172
237
  * statics and construct thunks assemble around the bodies. */
@@ -206,6 +271,8 @@ export declare class LlEmitter {
206
271
  private storedSplits;
207
272
  private streamingSplitsEnabled;
208
273
  private readonly initializerBindings;
274
+ /** Whole-program int32 storage and parameter/result facts. */
275
+ readonly int32Slots: Int32Slots;
209
276
  private numericLocals;
210
277
  private captureIds;
211
278
  /** Active induction bindings retain their width independently of size_t. */
@@ -266,6 +333,11 @@ export declare class LlEmitter {
266
333
  logArgSlots: number;
267
334
  private readonly stackTraces;
268
335
  constructor(mod: IrModule, options: LlvmTargetOptions);
336
+ /** The borrowed parameters of a hierarchy's vtable slot (empty: owned). */
337
+ virtualSlotBorrowed(rootName: string, slotIndex: number): ReadonlySet<number>;
338
+ /** The vtable entry for one implementation (VirtualBorrows.entry). */
339
+ virtualEntry(implFn: string): string;
340
+ private implSlotBorrowed;
269
341
  abiOffset(native64: number, wasm32: number): number;
270
342
  llType(t: IrType): string;
271
343
  ffiCallbackAdapter(binding: string, id: string): FfiCallbackAdapter;
@@ -276,6 +348,7 @@ export declare class LlEmitter {
276
348
  private emitFfiCallbackDefs;
277
349
  emit(): string;
278
350
  emitParts(): string[];
351
+ private emitModuleParts;
279
352
  /** LIBRARY mode: the profile-declared external definitions — the
280
353
  * export-map wrappers plus init / sink-registration / reset / collect.
281
354
  * Plain `define` (not `define internal`) — the exact linkage distinction
@@ -288,6 +361,11 @@ export declare class LlEmitter {
288
361
  * abort of untraced shape allocation and the invalid-union-tag abort —
289
362
  * both print the runtime ABI’s exact message on fd 2 and abort. */
290
363
  private helperDefs;
364
+ /** The inline RC helpers every call site requested, emitted last so
365
+ * requests from main/library epilogues are included. Slow-path
366
+ * declarations a late request added after the extern block flushed land
367
+ * here too. */
368
+ private inlineRcTail;
291
369
  /** Env-signature wrappers + interned immortal closures for declared
292
370
  * functions used as values (the runtime ABI’s sc_w_/sc_fc_ pair): every
293
371
  * mention of `f` yields the same pointer, so `f === f` holds. */
@@ -296,6 +374,30 @@ export declare class LlEmitter {
296
374
  * and generators. Their promise/generator completion and spawn tails stay
297
375
  * with the callers below. */
298
376
  private emitArgPackAndTrampolinePrologue;
377
+ /** Settles `promise` from a clean async body result `%r` (moved in). */
378
+ private asyncFulfillLines;
379
+ /** Async functions whose calls can skip the fiber (scr_async_inline_*).
380
+ * A body qualifies only when nothing it runs can park its execution
381
+ * context: its emitted text, and the text of every module function it
382
+ * mentions (transitively), contains no suspension entry point. Such a
383
+ * body always completes before the call returns, which is exactly the
384
+ * behavior of a fiber that never suspends. Excluded conservatively:
385
+ * wasm32 (its coroutine lowering owns async bodies), programs embedding
386
+ * the dynamic engine, module-evaluation bodies (their promise caches),
387
+ * `dyn` results (resolution may adopt a thenable), and every program
388
+ * that uses node:test subtests — `t.test()` runs a subtest inline and
389
+ * awaits it on the CURRENT fiber even from synchronous code. Worker
390
+ * programs keep fibers too: their fiber epilogue owns context
391
+ * termination (a stopping worker rejects and observes the promise), which
392
+ * the fiberless wrapper does not reproduce. A missed suspension still
393
+ * cannot reorder silently: the runtime traps when a context parks while a
394
+ * fiberless body is on its stack. */
395
+ private fiberlessAsyncFunctions;
396
+ /** The spawn wrapper of a fiberless async function: runs the body on the
397
+ * caller's stack between scr_async_inline_enter/leave and settles the
398
+ * fresh promise from its outcome — the fiber trampoline's epilogue,
399
+ * without the fiber. */
400
+ private emitFiberlessAsyncSpawn;
299
401
  /** Per-async-function machinery — async.ts's scaffolding, .ll
300
402
  * flavored: an argument-pack struct type, a fiber trampoline (unpacks,
301
403
  * frees the pack, runs the ordinary compiled body, settles the
@@ -311,6 +413,12 @@ export declare class LlEmitter {
311
413
  * spawn wrapper that only ALLOCATES the suspended fiber, and the
312
414
  * never-started teardown that drops the packed (+1) arguments. */
313
415
  private emitGenScaffolding;
416
+ /** A symbol derived from the constant's text rather than its first-use
417
+ * index, so an edit that interns one more string leaves every other
418
+ * constant's symbol, and the code referencing it, unchanged. This lets
419
+ * native builds reuse the compiled partitions an edit does not touch. A
420
+ * collision retries with a counter, still in first-use order. */
421
+ private contentSymbol;
314
422
  internLiteral(text: string): string;
315
423
  /** Interned NUL-terminated C-string constant (the scr_jb_puts /
316
424
  * stringify-indent currency) — `@`-ref, first-use order. */
@@ -321,9 +429,29 @@ export declare class LlEmitter {
321
429
  * emission initializes undefined-admitting fields through it
322
430
  * (ClassHost). */
323
431
  unitInstanceRef(unionId: string, tag: number): string;
432
+ /** The immortal ABSENT state of an undefined-armed record field slot
433
+ * (IR fieldAbsent). */
434
+ absentInstanceRef(unionId: string): string;
435
+ /** i1: a union value loaded from a field slot is the ABSENT state — the
436
+ * undefined arm's tag with the absent payload marker. */
437
+ fieldAbsentTest(value: string, unionId: string): string;
438
+ /** fieldAbsentTest in another block builder (helper generators). A
439
+ * nullable union's ABSENT state is the module's immortal sentinel. */
440
+ fieldAbsentTestIn(B: BlockBuilder, value: string, unionId: string): string;
441
+ /** Loads a record field slot as a VALUE: an undefined-armed union slot
442
+ * holding the ABSENT state surfaces as the ordinary undefined arm, so
443
+ * absence never travels beyond its slot (a later `{ f: r.f }` is an
444
+ * explicit, present property). */
445
+ loadRecordField(ptr: string, t: IrType): string;
324
446
  declare(decl: string): void;
325
447
  needOom(): void;
326
448
  private currentFrame;
449
+ /** Whether a value is immortal: an interned constant, or a temp marked by
450
+ * markImmortal. */
451
+ private isImmortal;
452
+ /** Record that a temp holds an immortal value (a choice between interned
453
+ * literals): nothing owns it, and retains, releases and moves skip it. */
454
+ markImmortal(v: LlValue): LlValue;
327
455
  /** Registers an owned refcounted value on the current statement frame. */
328
456
  own(v: LlValue): LlValue;
329
457
  /** Registers a SLOT whose current contents the frame owns (conditional
@@ -353,13 +481,40 @@ export declare class LlEmitter {
353
481
  * function — and branch to the handler / return a dummy value (never
354
482
  * read: callers of a may-throw function test the pending flag before
355
483
  * using the result). Callers own the surrounding pending branch; a
356
- * `throw` unwinds unconditionally. */
484
+ * `throw` unwinds unconditionally. `passThrough` names a scalar call
485
+ * result of the function's own return type: with nothing to release, the
486
+ * unwind returns it as the dummy, so a call in tail position keeps a single
487
+ * return and stays eligible for tail-call and recursion elimination. */
357
488
  private emitUnwind;
489
+ /** Instructions (two-space indented) that set the i1 `dest` to "an
490
+ * exception is pending in the active context" — scr_exc_pending()'s
491
+ * meaning — for the helper and adapter bodies that test it outside
492
+ * emitPendingCheck. Executables read the runtime's exported active-cell
493
+ * pointer and compare its i32 kind (offset 0) against SCR_EXC_NONE inline,
494
+ * as emitPendingCheck does; the out-of-line call would be opaque to LLVM
495
+ * because the runtime links as prebuilt objects. Libraries and worker
496
+ * programs keep the runtime call, which is emitPendingCheck's path there
497
+ * too (workers also observe cross-thread termination in it). */
498
+ pendingTestLines(dest: string): string[];
358
499
  /** The emitter contract for exceptions: after EVERY call that can throw
359
500
  * (per the may-throw analysis), test the pending flag and unwind. The
360
501
  * call's result temp must join its frame BEFORE this runs so the unwind
361
- * releases the dummy (NULL for refcounted kinds) harmlessly. */
362
- emitPendingCheck(): void;
502
+ * releases the dummy (NULL for refcounted kinds) harmlessly. A scalar
503
+ * call result of the function's return type may be passed as the unwind's
504
+ * dummy value (see emitUnwind). */
505
+ emitPendingCheck(passThrough?: {
506
+ name: string;
507
+ type: IrType;
508
+ }): void;
509
+ /** After a runtime call that ALWAYS leaves an exception pending (the
510
+ * compiler-resolved Node throws): the pending test would always answer
511
+ * true, so unwind unconditionally. Emission continues in a block with no
512
+ * predecessors so the caller's remaining instructions stay well-formed;
513
+ * LLVM deletes it. */
514
+ emitAlwaysPendingUnwind(): void;
515
+ /** A recursive function's entry check: below the running stack's guard,
516
+ * throw Node's RangeError and unwind like any other pending exception. */
517
+ private emitStackCheck;
363
518
  private workerLoopBudget;
364
519
  private emitWorkerLoopCheck;
365
520
  /** Moves an already-evaluated value into the runtime's exception cell —
@@ -375,24 +530,34 @@ export declare class LlEmitter {
375
530
  /** Emit truthiness for one non-union kind. Union arms are known-present,
376
531
  * so object kinds become the constant true instead of a pointer test. */
377
532
  private truthyOf;
378
- /** Loads a union box's tag (i32). */
379
- unionTag(uName: string): string;
533
+ /** A union value's tag (i32): the box's tag word, or the NULL test of a
534
+ * nullable union's pointer. */
535
+ unionTag(uName: string, unionId: string): string;
536
+ /** Guard for helpers that build or read a union's `%ScrUnion` box
537
+ * directly (library-shaped unions with fixed arms): a nullable union
538
+ * reaching one is an emitter bug, never a silent miscompile. */
539
+ requireBoxedUnion(unionId: string): void;
380
540
  /** The BORROWED payload pointer of a ref arm (scr_union_peek inlined —
381
- * the runtime's is a static inline). */
382
- unionPeek(uName: string): string;
541
+ * the runtime's is a static inline); a nullable union is its payload. */
542
+ unionPeek(uName: string, unionId: string): string;
383
543
  /** Emits `switch` over a union's tag with one block per arm; each arm
384
544
  * body must TERMINATE its block (the callers branch to a join). The
385
545
  * default block is the runtime ABI’s invalid-tag abort. Shared field
386
546
  * reads can group equivalent storage prefixes and emit one representative. */
387
547
  unionTagSwitch(uName: string, def: IrUnionDef, arm: (armType: IrType, tag: number) => void, fieldGroups?: number[][]): void;
388
548
  /** The +1 extraction of a union's single narrowed arm (unionNarrow /
389
- * the nullish-family reads): scalars via the runtime getters, ref arms
549
+ * the nullish-family reads): scalars via inline payload loads, ref arms
390
550
  * a retained peek. */
391
- unionExtract(uName: string, arm: IrType): string;
551
+ unionExtract(uName: string, unionId: string, arm: IrType): string;
552
+ /** A scalar f64 arm's payload (scr_union_get_f64 inlined). Inline loads
553
+ * keep stack boxes free of escaping calls, so LLVM can scalarize them. */
554
+ unionGetF64(uName: string): string;
555
+ /** A bool arm's payload (scr_union_get_bool inlined: nonzero slot). */
556
+ unionGetBool(uName: string): string;
392
557
  /** Constructs a union box around an OWNED (+1, already moved) value —
393
558
  * the scr_union_new_* dispatch of unionWrap and the wrap-into-join
394
559
  * sites (shift). */
395
- unionNewOwned(tag: number, v: LlValue): string;
560
+ unionNewOwned(unionId: string, tag: number, v: LlValue): string;
396
561
  classMetaOf(className: string): LlClassMeta;
397
562
  /** The field-slot pointer of a class member: rc at 0, the vtable word at
398
563
  * 1 on hierarchy members, then the flattened field list. Runtime error
@@ -425,6 +590,12 @@ export declare class LlEmitter {
425
590
  loadField(ptr: string, t: IrType): string;
426
591
  /** Stores a record field (i1 zext to the i8 storage). */
427
592
  storeField(ptr: string, t: IrType, value: string): void;
593
+ /** Reads an int32-specialized class field: the i32 slot is the value,
594
+ * and its widening is the exact double every program observation sees. */
595
+ loadInt32Field(ptr: string, type: IrType): LlValue;
596
+ /** Stores a value the whole-program analysis proved to be an int32 (never
597
+ * -0, NaN or fractional) into an int32-specialized class field. */
598
+ storeInt32Field(ptr: string, value: LlValue, expr: IrExpr): void;
428
599
  /** A binding's storage: a module global, a plain local slot, or a boxed
429
600
  * local (the slot holds the capture BOX; access goes through it). */
430
601
  binding(id: string): {
@@ -436,9 +607,15 @@ export declare class LlEmitter {
436
607
  private emitDebugLocal;
437
608
  /** Loads a boxed binding's box pointer out of its slot. */
438
609
  loadBox(slot: string): string;
610
+ /** The payload slot of a capture box (ScrBox.slot, field 5). */
611
+ private boxSlot;
439
612
  boxGet(box: string, t: IrType): string;
440
613
  /** scr_box_set_* — the ref form takes ownership of the passed value. */
441
614
  boxSet(box: string, t: IrType, value: string): void;
615
+ /** The box a new environment captures for `localId` (borrowed). An
616
+ * unchanged parameter gets one box on first capture, holding its own
617
+ * reference to the value; the function scope releases the cached box. */
618
+ captureBox(localId: string): string;
442
619
  retainBox(box: string): string;
443
620
  /** The initializing write of a scalar TDZ box: mint the one-element
444
621
  * array cell holding the value and move it into the ARR-kind box
@@ -450,6 +627,8 @@ export declare class LlEmitter {
450
627
  * array cell; ref kinds read the box normally (+1). */
451
628
  private checkTdz;
452
629
  checkGlobalTdz(id: string): void;
630
+ /** Throws the TDZ ReferenceError for `name` unless the i1 `flag` is set. */
631
+ checkInitializedFlag(flag: string, name: string): void;
453
632
  private throwIfUninitialized;
454
633
  tdzBoxRead(box: string, t: IrType, name: string): string;
455
634
  /** Declaration stores initialize an empty TDZ box. Later stores check
@@ -476,6 +655,9 @@ export declare class LlEmitter {
476
655
  * borrowing body. Ownership of other parameters moves into that body;
477
656
  * borrowed parameters are released here on normal and exceptional exits.
478
657
  * The pending exception remains for the adapter's caller to handle. */
658
+ /** With `kept`, the virtual adapter of a borrowing slot instead: the
659
+ * slot's parameters stay borrowed, the body's other borrowed ones are
660
+ * released here. */
479
661
  private emitOwnedCallAdapter;
480
662
  /** A local stable binding keeps its value alive while later arguments
481
663
  * and the callee execute. A proven local union box cannot escape or be
@@ -535,6 +717,22 @@ export declare class LlEmitter {
535
717
  emitBranchInto(slot: string, expr: IrExpr, integerSlot?: string): boolean;
536
718
  emitLiteralExpr(e: ExprOf<"numLit" | "boolLit" | "strLit" | "moduleNsRef" | "unitLit" | "varRef">): LlValue;
537
719
  emitOperatorExpr(e: ExprOf<"bin" | "unary" | "incDec" | "fieldIncDec" | "assignExpr" | "seqExpr">): LlValue;
720
+ /** Saved operands can feed later call arguments. Transfer ownership of a
721
+ * sequence's locals to this expression's frame so they survive those
722
+ * reads and still die on the path that created them, including inside
723
+ * lazy branches. */
724
+ private emitSequence;
725
+ /** A statement-position expression whose value is dropped. When a
726
+ * sequence's result only reads an unchanged local (a derived
727
+ * constructor's `super()` evaluates to `this`), its statements still run
728
+ * in place, but the result is neither retained nor released. */
729
+ /** Whether a discarded value can be skipped entirely: a borrowable read
730
+ * with no effect of its own. canBorrowCallArgument also accepts checked
731
+ * projections (a ternary or narrow whose failing arm throws, and the
732
+ * throwing call itself) because a borrowed use still evaluates them;
733
+ * skipping those would drop the throw. */
734
+ private discardableRead;
735
+ private emitDiscarded;
538
736
  emitControlExpr(e: ExprOf<"dynDestrCheck" | "dynIterN" | "toBool" | "logical" | "ternary" | "optChain" | "chainRecv" | "orDefault" | "nullish">): LlValue;
539
737
  emitStringExpr(e: ExprOf<"strConcat" | "strEq" | "strCmp" | "toString" | "strIntrinsic" | "regexLit" | "templateStrings" | "regexIntrinsic">): LlValue;
540
738
  /**
@@ -544,11 +742,39 @@ export declare class LlEmitter {
544
742
  * value, making the snapshot unique unless a real observable alias exists.
545
743
  */
546
744
  emitStringSelfConcatAssign(localId: string, left: IrExpr, suffix: IrExpr, retainForYield: boolean): LlValue;
745
+ /** `local = local + suffix` when the suffix cannot read or write the
746
+ * local (an unboxed binding is only reachable through this function's own
747
+ * expressions): reading the binding after the suffix gives the value the
748
+ * left side had, so it moves into a consuming concat, and the result takes
749
+ * its place. Null when the general snapshot path is needed. */
750
+ private emitMovedSelfConcat;
547
751
  emitContainerExpr(e: ExprOf<"arrayLit" | "arrayNewLen" | "arrayGet" | "arrayHas" | "arrayState" | "arrIntrinsic" | "bytesNew" | "bytesIntrinsic" | "mapNew" | "mapIntrinsic" | "setIntrinsic" | "setNew">): LlValue;
548
752
  emitCallExpr(e: ExprOf<"call" | "ffiCall" | "closure" | "callValue" | "selfRef" | "new" | "classRef" | "newValue" | "instanceOfValue" | "promiseVoidWiden" | "upcast" | "downcast" | "instanceOf" | "virtualCall">): LlValue;
549
- emitRecordExpr(e: ExprOf<"fieldGet" | "recordGet" | "recordLit" | "recordClone" | "recordKeyGet" | "recordOvfKeys" | "recordOvfHas">): LlValue;
753
+ emitRecordExpr(e: ExprOf<"fieldGet" | "recordGet" | "recordLit" | "recordClone" | "recordKeyGet" | "recordOvfKeys" | "recordOvfHas" | "recordHas" | "fieldAbsent">): LlValue;
550
754
  emitDynamicExpr(e: ExprOf<"dynFrom" | "dynFromJsval" | "dynCall" | "dynInvoke" | "dynArrLit" | "dynObjLit" | "unionWrap" | "unionNarrow" | "unionDisc" | "unionKeyGet" | "unionIsTag" | "dynKeyGet" | "dynHasKey" | "dynScalarEq" | "dynTest" | "unionEq" | "unionFuncEq" | "caughtTest" | "caughtCheck" | "caughtNarrow" | "caughtToDyn">): LlValue;
551
755
  emitIntrinsicExpr(e: ExprOf<"intrinsic">): LlValue;
756
+ private publishWalkersCache;
757
+ /** Per-type publication walkers, created on the first publish. */
758
+ private get publishWalkers();
759
+ /** `publish(value)` (@scriptc/threads): makes the graph immortal and
760
+ * immutable (scr_publish with the static type's walker) and answers the
761
+ * same value. Throws (pending) when a dyn part is unpublishable. */
762
+ private emitPublish;
763
+ /** Branches on "`obj` is published" (rc == SIZE_MAX); leaves the builder
764
+ * in the cold block and answers the continuation label. */
765
+ private emitPublishedTest;
766
+ private publishedNamesSym;
767
+ /** The class-name table the hierarchy field guards index by preorder. */
768
+ private publishedClassNamesDefs;
769
+ /** The frozen-object guard of a class field or record field store:
770
+ * Node's "Cannot assign to read only property" TypeError when the target
771
+ * is published. `className` null means a record (`#<Object>`). */
772
+ emitPublishedFieldGuard(obj: string, className: string | null, field: string): void;
773
+ /** The frozen-array guard (scr_throw_published_array's ops): `index` and
774
+ * `count` are doubles (the written index, the argument count). */
775
+ emitPublishedArrayGuard(arr: string, arrType: IrType, op: number, index?: string, count?: string): void;
776
+ /** The published Map/Set guard: "Cannot modify a published Map/Set". */
777
+ emitPublishedCollectionGuard(m: string, t: IrType): void;
552
778
  emitSerializationExpr(e: ExprOf<"jsonStringify" | "dynCheck">): LlValue;
553
779
  emitAsyncExpr(e: ExprOf<"yieldExpr" | "genResume" | "awaitExpr" | "awaitUnionExpr" | "newPromise" | "promiseWithResolvers">): LlValue;
554
780
  emitJsInteropExpr(e: ExprOf<"jsMarshal" | "jsOp" | "jsExit" | "jsBridgePromise">): LlValue;
@@ -558,7 +784,74 @@ export declare class LlEmitter {
558
784
  * their ordinary statement-frame ownership. The caller must retain any
559
785
  * reference result before evaluating another expression. */
560
786
  emitReadReceiver(e: IrExpr): LlValue;
787
+ /** A private stack union source with an independently owned payload. */
788
+ canStackReceiver(e: IrExpr): boolean;
789
+ /** True for union sources that emitReadReceiver can produce as a private
790
+ * stack box with an independently owned payload (no heap union). */
791
+ isStackUnionSource(e: IrExpr): boolean;
792
+ /** The nullable-pointer representation behind a union-typed class field
793
+ * read, or null for every other expression. */
794
+ nullableFieldGet(e: IrExpr): NullableRefField | null;
795
+ /** A union operand consumed only by a projection (tag test, payload
796
+ * extraction, arm compare, truthiness). A nullable-pointer field read
797
+ * becomes a private stack box whose payload is borrowed from the field:
798
+ * the consumer must finish before any later expression can store to the
799
+ * field, and must never retain, release, or store the box. Every other
800
+ * operand takes the ordinary borrowed-receiver path. */
801
+ emitUnionProjection(e: IrExpr): LlValue;
802
+ /** A private stack box over a nullable-pointer field read whose payload
803
+ * is retained into the current frame: an independent owner, so the box
804
+ * may outlive later stores to the field (call arguments, local copies).
805
+ * The box itself must still never reach an RC entry point. */
806
+ emitOwnedNullableStack(e: IrExpr): {
807
+ box: string;
808
+ owner: LlValue;
809
+ };
810
+ /** A private stack box over a borrowed nullable pointer. */
811
+ stackNullableBox(p: string, nullable: NullableRefField): string;
812
+ /** The owned (+1) union value of a nullable-pointer slot: the unit arm's
813
+ * immortal instance, or a fresh heap box around a retained instance. */
814
+ nullableToOwnedUnion(p: string, nullable: NullableRefField): string;
815
+ /** The owned (+1) instance pointer (NULL for the unit arm) of a union
816
+ * box, which stays owned by its existing owner. */
817
+ unionToNullable(u: string, nullable: NullableRefField): string;
818
+ /** `obj.f = value` for a nullable-pointer field: the new instance pointer
819
+ * is produced without a union box where the value is a wrap, and as a
820
+ * retained payload of a borrowed box otherwise. Unlink-then-release like
821
+ * every field store. */
822
+ emitNullableFieldStore(obj: string, className: string, field: string, nullable: NullableRefField, value: IrExpr): void;
823
+ /** A union binding whose slot may hold a private stack box: stack locals
824
+ * and projection-only parameters (callers may pass stack boxes). Such a
825
+ * box must only be projected: never retained, released, or stored. */
826
+ isStackUnionLocal(localId: string): boolean;
561
827
  canBorrowReceiver(e: IrExpr): boolean;
828
+ /** A reference held as one plain pointer that emitReadReceiver can read
829
+ * without owning: class instances, records, arrays, strings and
830
+ * nullable-pointer unions. Tagged union boxes, closures and dynamic
831
+ * values keep ordinary ownership. */
832
+ plainReference(type: IrType): boolean;
833
+ /** Functions returning a walk of their borrowed parameters return it
834
+ * without a reference (+0) from their borrowing body; direct callers
835
+ * either consume it as a receiver/walk or retain it at once, and the owned
836
+ * adapter retains before releasing its parameters. Candidates preserve
837
+ * every heap edge (so the result stays reachable from the arguments),
838
+ * borrow every reference parameter and return plain pointers. The set
839
+ * grows to a fixpoint because a call to a borrowed-return function with
840
+ * walk arguments is itself a walk; walk facts are then recomputed with
841
+ * the final set, admitting only parameters whose convention borrows. */
842
+ private analyzeBorrowedReturns;
843
+ /** emitReadReceiver produces this node's pointer without acquiring a
844
+ * reference, given operands (and ternary arms) that do the same: plain
845
+ * class/record field reads, class casts, nullable-pointer narrows and
846
+ * wraps, and checked ternaries. Stack-boxed, map-read and boxed-field
847
+ * sources are owned. Depends only on module facts, not the current
848
+ * function. */
849
+ borrowsWithoutOwning(e: IrExpr): boolean;
850
+ /** A wrap into a nullable-pointer union is the payload pointer itself
851
+ * (the reference arm) or an immortal constant (a unit arm), so it can
852
+ * borrow exactly when its payload can. Void payloads run for effects and
853
+ * keep the ordinary path; tagged unions still construct a box. */
854
+ borrowableNullableWrap(e: IrExpr): "unit" | "ref" | null;
562
855
  materializeSplitLocal(localId: string): void;
563
856
  emitExpr(e: IrExpr): LlValue;
564
857
  emitJsMarshal(e: IrExpr & {
@@ -620,7 +913,7 @@ export declare class LlEmitter {
620
913
  }): string;
621
914
  streamCbThunkFor(kind: "r" | "w" | "f" | "d" | "t" | "l" | "e", cbT: IrType): string;
622
915
  resolveThunkFor(inner: IrType): string;
623
- tagInSet(uName: string, tags: number[]): string;
916
+ tagInSet(uName: string, unionId: string, tags: number[]): string;
624
917
  arrPush(arr: string, acc: "f64" | "bool" | "ref", value: string): string;
625
918
  emitArrayCopyLoop(dst: string, src: string, acc: "f64" | "bool" | "ref"): void;
626
919
  emitStrIntrinsic(e: IrExpr & {
@@ -647,7 +940,7 @@ export declare class LlEmitter {
647
940
  emitBytesIndex(receiver: string, index: LlValue, expr?: IrExpr, inBounds?: boolean): string;
648
941
  emitBytesData(receiver: string): string;
649
942
  emitBytesLength(elem: IrBytesElem, receiver: string, bytes: boolean): LlValue;
650
- emitBytesGet(elem: IrBytesElem, receiver: string, index: LlValue, expr?: IrExpr, inBounds?: boolean): LlValue;
943
+ emitBytesGet(elem: IrBytesElem, receiver: string, index: LlValue, expr?: IrExpr, inBounds?: boolean, invalidNaN?: boolean): LlValue;
651
944
  emitToUint32(value: string, expr?: IrExpr, uint32?: string): string;
652
945
  storeIntegerView(localId: string, value: LlValue, expr?: IrExpr): void;
653
946
  private emitBytesSet;