@geastack/compiler 1.0.20 → 1.0.21

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 (534) hide show
  1. package/dist/cli-emit.js +11 -1
  2. package/dist/cli-package-source.d.ts +0 -4
  3. package/dist/cli-package-source.js +8 -112
  4. package/dist/cli-refusal-location.d.ts +6 -0
  5. package/dist/cli-refusal-location.js +5 -0
  6. package/dist/cli.js +2 -1
  7. package/dist/compiler.d.ts +4 -0
  8. package/dist/compiler.js +118 -28
  9. package/dist/conversion/algebra.d.ts +16 -1
  10. package/dist/conversion/algebra.js +2 -0
  11. package/dist/conversion/build.js +16 -6
  12. package/dist/conversion/constructor-identity-family.d.ts +49 -0
  13. package/dist/conversion/constructor-identity-family.js +67 -0
  14. package/dist/conversion/derive.js +39 -6
  15. package/dist/conversion/iterable-object-view.d.ts +44 -0
  16. package/dist/conversion/iterable-object-view.js +55 -0
  17. package/dist/conversion/iterator-object-view.d.ts +77 -0
  18. package/dist/conversion/iterator-object-view.js +112 -0
  19. package/dist/conversion/nodes.d.ts +93 -0
  20. package/dist/conversion/nodes.js +262 -5
  21. package/dist/conversion/operand-view.js +41 -0
  22. package/dist/conversion/protocol-iterator.d.ts +84 -0
  23. package/dist/conversion/protocol-iterator.js +88 -0
  24. package/dist/conversion/record-view.d.ts +152 -8
  25. package/dist/conversion/record-view.js +518 -37
  26. package/dist/conversion/registry.d.ts +32 -0
  27. package/dist/ir/borrowed-call-arguments.d.ts +22 -1
  28. package/dist/ir/borrowed-call-arguments.js +102 -1
  29. package/dist/ir/borrowed-callable-uses.d.ts +62 -0
  30. package/dist/ir/borrowed-callable-uses.js +135 -0
  31. package/dist/ir/boxed-bind-assumptions.d.ts +24 -0
  32. package/dist/ir/boxed-bind-assumptions.js +93 -0
  33. package/dist/ir/build.d.ts +18 -7
  34. package/dist/ir/build.js +71 -13
  35. package/dist/ir/call-dispatch.js +474 -10
  36. package/dist/ir/call-entry.d.ts +24 -1
  37. package/dist/ir/call-entry.js +106 -1
  38. package/dist/ir/callable-class-flow.js +15 -5
  39. package/dist/ir/callable-identity-demand.d.ts +20 -1
  40. package/dist/ir/callable-identity-demand.js +157 -18
  41. package/dist/ir/callable-member-candidates.d.ts +11 -1
  42. package/dist/ir/callable-member-candidates.js +82 -3
  43. package/dist/ir/callable-records.js +2 -2
  44. package/dist/ir/callable-site-escape.d.ts +4 -0
  45. package/dist/ir/callable-site-escape.js +228 -0
  46. package/dist/ir/captures.d.ts +10 -1
  47. package/dist/ir/captures.js +219 -4
  48. package/dist/ir/certify/carrier-keys.d.ts +58 -1
  49. package/dist/ir/certify/carrier-keys.js +158 -6
  50. package/dist/ir/certify/property-access-keys.d.ts +17 -0
  51. package/dist/ir/certify/property-access-keys.js +36 -0
  52. package/dist/ir/certify/property-access.js +49 -4
  53. package/dist/ir/certify/runtime-helper.d.ts +4 -0
  54. package/dist/ir/certify/runtime-helper.js +17 -5
  55. package/dist/ir/certify.js +132 -79
  56. package/dist/ir/class-static-fields.d.ts +11 -0
  57. package/dist/ir/class-static-fields.js +28 -0
  58. package/dist/ir/construct-entry.d.ts +2 -1
  59. package/dist/ir/construct-entry.js +3 -2
  60. package/dist/ir/construction-only-fields.d.ts +73 -0
  61. package/dist/ir/construction-only-fields.js +211 -0
  62. package/dist/ir/dominance.d.ts +14 -0
  63. package/dist/ir/dominance.js +18 -4
  64. package/dist/ir/emission-representations.js +4 -1
  65. package/dist/ir/exception-edges.d.ts +17 -0
  66. package/dist/ir/exception-edges.js +75 -0
  67. package/dist/ir/facts.d.ts +54 -3
  68. package/dist/ir/facts.js +182 -5
  69. package/dist/ir/generator-split.js +2 -2
  70. package/dist/ir/instance-reparenting.d.ts +83 -0
  71. package/dist/ir/instance-reparenting.js +167 -0
  72. package/dist/ir/integer-storage.d.ts +29 -0
  73. package/dist/ir/integer-storage.js +188 -79
  74. package/dist/ir/integers.d.ts +16 -0
  75. package/dist/ir/integers.js +327 -8
  76. package/dist/ir/integrity-restrictions.d.ts +42 -9
  77. package/dist/ir/integrity-restrictions.js +335 -42
  78. package/dist/ir/key-order-observation.d.ts +38 -0
  79. package/dist/ir/key-order-observation.js +173 -0
  80. package/dist/ir/literal-set-membership.d.ts +30 -0
  81. package/dist/ir/literal-set-membership.js +277 -0
  82. package/dist/ir/lower-allocation.js +68 -8
  83. package/dist/ir/lower-completion.d.ts +0 -9
  84. package/dist/ir/lower-completion.js +14 -5
  85. package/dist/ir/lower-destructuring.js +24 -2
  86. package/dist/ir/lower-exceptions.js +4 -4
  87. package/dist/ir/lower-flow.d.ts +21 -0
  88. package/dist/ir/lower-flow.js +37 -3
  89. package/dist/ir/lower-graph.d.ts +19 -1
  90. package/dist/ir/lower-graph.js +91 -67
  91. package/dist/ir/lower-invocation.d.ts +16 -0
  92. package/dist/ir/lower-invocation.js +182 -28
  93. package/dist/ir/lower-narrow.d.ts +0 -46
  94. package/dist/ir/lower-narrow.js +63 -1
  95. package/dist/ir/lower-operands.d.ts +52 -2
  96. package/dist/ir/lower-operands.js +491 -8
  97. package/dist/ir/lower-property.d.ts +2 -1
  98. package/dist/ir/lower-property.js +140 -31
  99. package/dist/ir/lower-protocol.js +16 -4
  100. package/dist/ir/lower-proxy.d.ts +65 -0
  101. package/dist/ir/lower-proxy.js +181 -0
  102. package/dist/ir/lower.js +112 -17
  103. package/dist/ir/model.d.ts +228 -18
  104. package/dist/ir/native-class-accessor.d.ts +9 -2
  105. package/dist/ir/native-class-accessor.js +12 -3
  106. package/dist/ir/native-class-construction.d.ts +1 -1
  107. package/dist/ir/native-class-construction.js +2 -1
  108. package/dist/ir/native-class-initialization.js +2 -2
  109. package/dist/ir/object-value-conversions.js +20 -5
  110. package/dist/ir/operation-index.d.ts +16 -0
  111. package/dist/ir/operation-index.js +17 -0
  112. package/dist/ir/pcm-loops.d.ts +11 -0
  113. package/dist/ir/pcm-loops.js +284 -0
  114. package/dist/ir/presence-proof.js +5 -0
  115. package/dist/ir/program-facts.d.ts +10 -20
  116. package/dist/ir/program-facts.js +80 -6
  117. package/dist/ir/proven-branches.d.ts +2 -2
  118. package/dist/ir/proven-branches.js +196 -3
  119. package/dist/ir/queries.js +35 -1
  120. package/dist/ir/reflection-demand.d.ts +9 -4
  121. package/dist/ir/reflection-demand.js +400 -28
  122. package/dist/ir/refusal.d.ts +1 -0
  123. package/dist/ir/refusal.js +2 -1
  124. package/dist/ir/shake.d.ts +94 -1
  125. package/dist/ir/shake.js +209 -12
  126. package/dist/ir/shared-empty-records.d.ts +12 -0
  127. package/dist/ir/shared-empty-records.js +301 -0
  128. package/dist/ir/spread-copy-elision.d.ts +59 -0
  129. package/dist/ir/spread-copy-elision.js +431 -0
  130. package/dist/ir/stable-cell-reads.d.ts +40 -0
  131. package/dist/ir/stable-cell-reads.js +123 -0
  132. package/dist/ir/static-callables.js +50 -0
  133. package/dist/ir/string-layout-reuse.d.ts +16 -1
  134. package/dist/ir/string-layout-reuse.js +66 -0
  135. package/dist/ir/transfer.d.ts +72 -3
  136. package/dist/ir/transfer.js +511 -19
  137. package/dist/ir/typed-property-access.d.ts +18 -2
  138. package/dist/ir/typed-property-access.js +109 -12
  139. package/dist/ir/verify.js +2 -1
  140. package/dist/plugins/apple/plugin.js +3 -2
  141. package/dist/plugins/gea/host.d.ts +7 -0
  142. package/dist/plugins/gea/host.js +30 -1
  143. package/dist/plugins/gea/lower.js +6 -1
  144. package/dist/plugins/gea/plugin.js +7 -4
  145. package/dist/plugins/gea/render-bridge.d.ts +4 -2
  146. package/dist/plugins/gea/render-bridge.js +23 -7
  147. package/dist/plugins/model.d.ts +2 -0
  148. package/dist/project-preparation.d.ts +5 -1
  149. package/dist/project-preparation.js +164 -7
  150. package/dist/projection/bindings.d.ts +5 -2
  151. package/dist/projection/bindings.js +40 -1
  152. package/dist/projection/callee.d.ts +16 -0
  153. package/dist/projection/callee.js +35 -6
  154. package/dist/projection/class-prototype.js +5 -1
  155. package/dist/projection/classes.d.ts +65 -2
  156. package/dist/projection/classes.js +159 -2
  157. package/dist/projection/dispatch.d.ts +69 -18
  158. package/dist/projection/dispatch.js +391 -19
  159. package/dist/projection/fields.d.ts +4 -3
  160. package/dist/projection/fields.js +89 -21
  161. package/dist/projection/instance-test.d.ts +12 -0
  162. package/dist/projection/instance-test.js +40 -10
  163. package/dist/projection/method-value-escapes.d.ts +43 -0
  164. package/dist/projection/method-value-escapes.js +113 -0
  165. package/dist/projection/slots.d.ts +34 -1
  166. package/dist/projection/slots.js +82 -5
  167. package/dist/representation/any-null-record-members.d.ts +41 -0
  168. package/dist/representation/any-null-record-members.js +115 -0
  169. package/dist/representation/collections.d.ts +3 -1
  170. package/dist/representation/collections.js +5 -2
  171. package/dist/representation/derive.d.ts +9 -1
  172. package/dist/representation/derive.js +366 -25
  173. package/dist/representation/difference.js +14 -0
  174. package/dist/representation/embedded-carriers.js +1 -0
  175. package/dist/representation/host-abi.d.ts +15 -0
  176. package/dist/representation/host-abi.js +28 -0
  177. package/dist/representation/host-templates.d.ts +1 -1
  178. package/dist/representation/host-templates.js +7 -3
  179. package/dist/representation/intersection.js +22 -0
  180. package/dist/representation/json-nullable.d.ts +18 -0
  181. package/dist/representation/json-nullable.js +22 -0
  182. package/dist/representation/model.d.ts +141 -0
  183. package/dist/representation/model.js +47 -3
  184. package/dist/representation/object-shape.d.ts +5 -1
  185. package/dist/representation/object-shape.js +5 -2
  186. package/dist/representation/policies.d.ts +66 -1
  187. package/dist/representation/proxy-carriers.d.ts +71 -0
  188. package/dist/representation/proxy-carriers.js +330 -0
  189. package/dist/representation/publish.d.ts +9 -1
  190. package/dist/representation/publish.js +186 -18
  191. package/dist/representation/record-fields.d.ts +5 -0
  192. package/dist/representation/record-fields.js +7 -1
  193. package/dist/representation/static-field-cells.d.ts +61 -0
  194. package/dist/representation/static-field-cells.js +80 -0
  195. package/dist/representation/unassigned-binding-cells.d.ts +32 -0
  196. package/dist/representation/unassigned-binding-cells.js +44 -0
  197. package/dist/representation/union.js +17 -1
  198. package/dist/representation/unwritten-record-members.d.ts +54 -0
  199. package/dist/representation/unwritten-record-members.js +167 -0
  200. package/dist/representation/value-records.js +153 -11
  201. package/dist/semantics/ambient.d.ts +102 -0
  202. package/dist/semantics/ambient.js +183 -0
  203. package/dist/semantics/any-null-member-declarations.d.ts +32 -0
  204. package/dist/semantics/any-null-member-declarations.js +90 -0
  205. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +14 -0
  206. package/dist/semantics/borrowed-method-receiver-copy-source-transform.d.ts +51 -0
  207. package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +367 -0
  208. package/dist/semantics/call-invalidated-narrowing.d.ts +3 -0
  209. package/dist/semantics/call-invalidated-narrowing.js +715 -0
  210. package/dist/semantics/callable-origins.d.ts +39 -0
  211. package/dist/semantics/callable-origins.js +73 -2
  212. package/dist/semantics/class-alias.d.ts +21 -0
  213. package/dist/semantics/class-alias.js +45 -14
  214. package/dist/semantics/class-heritage.d.ts +64 -0
  215. package/dist/semantics/class-heritage.js +278 -2
  216. package/dist/semantics/commonjs-wrapper.d.ts +1 -1
  217. package/dist/semantics/commonjs-wrapper.js +24 -7
  218. package/dist/semantics/constructor-function-class-source-transform.d.ts +4 -0
  219. package/dist/semantics/constructor-function-class-source-transform.js +327 -0
  220. package/dist/semantics/constructor-slot-subclasses.js +163 -4
  221. package/dist/semantics/declaration-overlay-transform.js +197 -3
  222. package/dist/semantics/frontend.d.ts +31 -0
  223. package/dist/semantics/frontend.js +177 -19
  224. package/dist/semantics/host-methods.d.ts +27 -2
  225. package/dist/semantics/host-methods.js +57 -4
  226. package/dist/semantics/host-protocols.d.ts +19 -8
  227. package/dist/semantics/host-protocols.js +145 -31
  228. package/dist/semantics/interface-families.d.ts +51 -2
  229. package/dist/semantics/interface-families.js +609 -23
  230. package/dist/semantics/interface-implementors.d.ts +20 -0
  231. package/dist/semantics/interface-implementors.js +130 -6
  232. package/dist/semantics/known-caller-predicate-parameters.d.ts +2 -0
  233. package/dist/semantics/known-caller-predicate-parameters.js +161 -0
  234. package/dist/semantics/model/intrinsic-accessor-getters.d.ts +10 -0
  235. package/dist/semantics/model/intrinsic-accessor-getters.js +4 -0
  236. package/dist/semantics/model/operands.d.ts +10 -0
  237. package/dist/semantics/model/operations.d.ts +107 -0
  238. package/dist/semantics/model/selected-signature.d.ts +33 -0
  239. package/dist/semantics/model/structural-type-table.d.ts +15 -0
  240. package/dist/semantics/model/structural-type-table.js +19 -1
  241. package/dist/semantics/model/structural-types.d.ts +99 -0
  242. package/dist/semantics/model/structural-types.js +31 -2
  243. package/dist/semantics/normalize/absent-globals.d.ts +1 -1
  244. package/dist/semantics/normalize/absent-globals.js +3 -3
  245. package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +46 -0
  246. package/dist/semantics/normalize/bivariant-slot-parameter.js +357 -0
  247. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +2 -0
  248. package/dist/semantics/normalize/callback-parameter-contracts.js +21 -0
  249. package/dist/semantics/normalize/census.d.ts +2 -1
  250. package/dist/semantics/normalize/census.js +25 -2
  251. package/dist/semantics/normalize/class-instance-record-statement.d.ts +37 -0
  252. package/dist/semantics/normalize/class-instance-record-statement.js +74 -0
  253. package/dist/semantics/normalize/collection-bindings.js +242 -5
  254. package/dist/semantics/normalize/commonjs-require.d.ts +26 -0
  255. package/dist/semantics/normalize/commonjs-require.js +355 -121
  256. package/dist/semantics/normalize/dead-event-emissions.d.ts +6 -0
  257. package/dist/semantics/normalize/dead-event-emissions.js +866 -0
  258. package/dist/semantics/normalize/dead-method-copies.d.ts +56 -0
  259. package/dist/semantics/normalize/dead-method-copies.js +239 -0
  260. package/dist/semantics/normalize/derived-expression-type.d.ts +149 -2
  261. package/dist/semantics/normalize/derived-expression-type.js +418 -14
  262. package/dist/semantics/normalize/field-bindings.js +139 -4
  263. package/dist/semantics/normalize/flow/callable-reach.js +162 -9
  264. package/dist/semantics/normalize/flow/member-call-forwarding.js +6 -0
  265. package/dist/semantics/normalize/flow/owned-class-receivers.js +40 -2
  266. package/dist/semantics/normalize/flow/source-class-data.d.ts +7 -1
  267. package/dist/semantics/normalize/flow/source-class-data.js +28 -9
  268. package/dist/semantics/normalize/flow/source-value-session.js +32 -13
  269. package/dist/semantics/normalize/flow/targets.d.ts +32 -0
  270. package/dist/semantics/normalize/flow/targets.js +65 -6
  271. package/dist/semantics/normalize/flow/value-flow.d.ts +7 -0
  272. package/dist/semantics/normalize/flow/value-flow.js +30 -2
  273. package/dist/semantics/normalize/fresh-array-result.d.ts +32 -0
  274. package/dist/semantics/normalize/fresh-array-result.js +125 -0
  275. package/dist/semantics/normalize/gating.js +2 -0
  276. package/dist/semantics/normalize/global-host-mutations.d.ts +11 -1
  277. package/dist/semantics/normalize/global-host-mutations.js +691 -27
  278. package/dist/semantics/normalize/host-effect-contracts.d.ts +43 -1
  279. package/dist/semantics/normalize/host-effect-contracts.js +60 -3
  280. package/dist/semantics/normalize/identities.js +49 -3
  281. package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +59 -0
  282. package/dist/semantics/normalize/intrinsic-accessor-getter.js +129 -0
  283. package/dist/semantics/normalize/local-bindings.js +117 -21
  284. package/dist/semantics/normalize/merged-declaration.d.ts +41 -0
  285. package/dist/semantics/normalize/merged-declaration.js +81 -0
  286. package/dist/semantics/normalize/never-override-result.d.ts +21 -0
  287. package/dist/semantics/normalize/never-override-result.js +64 -0
  288. package/dist/semantics/normalize/null-blind-parameter.d.ts +21 -0
  289. package/dist/semantics/normalize/null-blind-parameter.js +77 -0
  290. package/dist/semantics/normalize/object-bag-bindings.js +10 -0
  291. package/dist/semantics/normalize/override-field-arms.d.ts +33 -0
  292. package/dist/semantics/normalize/override-field-arms.js +362 -0
  293. package/dist/semantics/normalize/parameter-bindings.d.ts +64 -1
  294. package/dist/semantics/normalize/parameter-bindings.js +801 -81
  295. package/dist/semantics/normalize/parameter-slot.d.ts +1 -0
  296. package/dist/semantics/normalize/parameter-slot.js +69 -0
  297. package/dist/semantics/normalize/physical-overload-result.d.ts +45 -0
  298. package/dist/semantics/normalize/physical-overload-result.js +132 -0
  299. package/dist/semantics/normalize/producer-context.d.ts +23 -0
  300. package/dist/semantics/normalize/producers/allocations.d.ts +13 -0
  301. package/dist/semantics/normalize/producers/allocations.js +8 -15
  302. package/dist/semantics/normalize/producers/binding-kind.d.ts +11 -0
  303. package/dist/semantics/normalize/producers/binding-kind.js +31 -0
  304. package/dist/semantics/normalize/producers/bindings.js +16 -1
  305. package/dist/semantics/normalize/producers/boundary.js +21 -1
  306. package/dist/semantics/normalize/producers/class-lifecycle.js +23 -14
  307. package/dist/semantics/normalize/producers/computations.js +8 -67
  308. package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
  309. package/dist/semantics/normalize/producers/control-loops.js +25 -1
  310. package/dist/semantics/normalize/producers/control.js +87 -60
  311. package/dist/semantics/normalize/producers/declaration-lifecycle.js +5 -0
  312. package/dist/semantics/normalize/producers/enums.d.ts +10 -0
  313. package/dist/semantics/normalize/producers/enums.js +169 -0
  314. package/dist/semantics/normalize/producers/erasure.d.ts +10 -0
  315. package/dist/semantics/normalize/producers/erasure.js +23 -0
  316. package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +15 -0
  317. package/dist/semantics/normalize/producers/intrinsic-accessor-getter.js +33 -0
  318. package/dist/semantics/normalize/producers/invocations.js +255 -18
  319. package/dist/semantics/normalize/producers/iteration-yield.js +6 -1
  320. package/dist/semantics/normalize/producers/logical-merge-type.d.ts +36 -0
  321. package/dist/semantics/normalize/producers/logical-merge-type.js +163 -0
  322. package/dist/semantics/normalize/producers/properties.js +207 -18
  323. package/dist/semantics/normalize/producers/protocol.d.ts +4 -0
  324. package/dist/semantics/normalize/producers/protocol.js +147 -12
  325. package/dist/semantics/normalize/producers/references.js +50 -9
  326. package/dist/semantics/normalize/producers/shared.d.ts +120 -0
  327. package/dist/semantics/normalize/producers/shared.js +359 -10
  328. package/dist/semantics/normalize/producers/spread-arguments.js +85 -4
  329. package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -0
  330. package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
  331. package/dist/semantics/normalize/property-key-domain.js +6 -0
  332. package/dist/semantics/normalize/reachability.d.ts +7 -0
  333. package/dist/semantics/normalize/reachability.js +166 -9
  334. package/dist/semantics/normalize/record-home-arms.d.ts +25 -0
  335. package/dist/semantics/normalize/record-home-arms.js +87 -0
  336. package/dist/semantics/normalize/record-link-families.d.ts +74 -0
  337. package/dist/semantics/normalize/record-link-families.js +327 -0
  338. package/dist/semantics/normalize/record-stand-in-arms.d.ts +56 -0
  339. package/dist/semantics/normalize/record-stand-in-arms.js +484 -0
  340. package/dist/semantics/normalize/return-bindings.d.ts +6 -2
  341. package/dist/semantics/normalize/return-bindings.js +60 -7
  342. package/dist/semantics/normalize/script-global-redefinition.js +5 -0
  343. package/dist/semantics/normalize/shared-array-storage.d.ts +42 -0
  344. package/dist/semantics/normalize/shared-array-storage.js +373 -0
  345. package/dist/semantics/normalize/sloppy-absence.d.ts +41 -0
  346. package/dist/semantics/normalize/sloppy-absence.js +199 -0
  347. package/dist/semantics/normalize/specialization.d.ts +40 -0
  348. package/dist/semantics/normalize/specialization.js +770 -36
  349. package/dist/semantics/normalize/structural-array-element.js +196 -6
  350. package/dist/semantics/normalize/structural-array-read.js +12 -0
  351. package/dist/semantics/normalize/structural-creation-order.d.ts +15 -0
  352. package/dist/semantics/normalize/structural-creation-order.js +51 -48
  353. package/dist/semantics/normalize/structural-declarations.d.ts +16 -0
  354. package/dist/semantics/normalize/structural-declarations.js +43 -0
  355. package/dist/semantics/normalize/structural-generics.d.ts +13 -0
  356. package/dist/semantics/normalize/structural-generics.js +22 -0
  357. package/dist/semantics/normalize/structural-indexed-access.js +16 -0
  358. package/dist/semantics/normalize/structural-instantiated-member.js +68 -2
  359. package/dist/semantics/normalize/structural-joins.js +2 -0
  360. package/dist/semantics/normalize/structural-layout-relevance.d.ts +30 -0
  361. package/dist/semantics/normalize/structural-layout-relevance.js +164 -0
  362. package/dist/semantics/normalize/structural-layout-type.js +270 -14
  363. package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
  364. package/dist/semantics/normalize/structural-leaves.js +17 -3
  365. package/dist/semantics/normalize/structural-mutable-method.js +5 -1
  366. package/dist/semantics/normalize/structural-parts.d.ts +18 -5
  367. package/dist/semantics/normalize/structural-parts.js +68 -19
  368. package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
  369. package/dist/semantics/normalize/structural-receiver.js +23 -1
  370. package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
  371. package/dist/semantics/normalize/structural-self-reference.js +23 -2
  372. package/dist/semantics/normalize/structural.d.ts +12 -1
  373. package/dist/semantics/normalize/structural.js +1420 -53
  374. package/dist/semantics/normalize/suppressed-write-arms.d.ts +47 -0
  375. package/dist/semantics/normalize/suppressed-write-arms.js +393 -0
  376. package/dist/semantics/normalize/unresolvable-names.d.ts +15 -2
  377. package/dist/semantics/normalize/unresolvable-names.js +30 -6
  378. package/dist/semantics/normalize/unshared-array-result.d.ts +32 -0
  379. package/dist/semantics/normalize/unshared-array-result.js +125 -0
  380. package/dist/semantics/package-sources.d.ts +1 -1
  381. package/dist/semantics/package-sources.js +120 -8
  382. package/dist/semantics/program.d.ts +20 -0
  383. package/dist/semantics/program.js +145 -14
  384. package/dist/semantics/stable-checker.d.ts +1 -1
  385. package/dist/semantics/stable-checker.js +7 -2
  386. package/dist/semantics/unchecked-guard-argument-copies.d.ts +67 -0
  387. package/dist/semantics/unchecked-guard-argument-copies.js +163 -0
  388. package/dist/semantics/unchecked-write-member-declarations.d.ts +46 -0
  389. package/dist/semantics/unchecked-write-member-declarations.js +331 -0
  390. package/dist/targets/cpp/balanced-units.d.ts +31 -0
  391. package/dist/targets/cpp/balanced-units.js +57 -0
  392. package/dist/targets/cpp/borrowed-arm-projections.d.ts +31 -0
  393. package/dist/targets/cpp/borrowed-arm-projections.js +106 -0
  394. package/dist/targets/cpp/borrowed-call-entry.d.ts +1 -1
  395. package/dist/targets/cpp/borrowed-call-entry.js +24 -20
  396. package/dist/targets/cpp/captures.js +314 -8
  397. package/dist/targets/cpp/char-code-buffers.d.ts +36 -0
  398. package/dist/targets/cpp/char-code-buffers.js +214 -0
  399. package/dist/targets/cpp/class-layout.d.ts +7 -1
  400. package/dist/targets/cpp/class-layout.js +42 -17
  401. package/dist/targets/cpp/class-properties/computed-method-value.d.ts +17 -2
  402. package/dist/targets/cpp/class-properties/computed-method-value.js +50 -4
  403. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +31 -1
  404. package/dist/targets/cpp/class-properties/emit-class-properties.js +174 -17
  405. package/dist/targets/cpp/class-ref-transport.d.ts +32 -0
  406. package/dist/targets/cpp/class-ref-transport.js +56 -1
  407. package/dist/targets/cpp/conversions.js +1827 -1502
  408. package/dist/targets/cpp/coroutine-bodies.d.ts +97 -0
  409. package/dist/targets/cpp/coroutine-bodies.js +187 -0
  410. package/dist/targets/cpp/document.js +11 -1
  411. package/dist/targets/cpp/emit-allocation.js +535 -21
  412. package/dist/targets/cpp/emit-arrays.d.ts +10 -0
  413. package/dist/targets/cpp/emit-arrays.js +147 -16
  414. package/dist/targets/cpp/emit-binding-reference.d.ts +26 -2
  415. package/dist/targets/cpp/emit-binding-reference.js +97 -5
  416. package/dist/targets/cpp/emit-bindings.d.ts +9 -1
  417. package/dist/targets/cpp/emit-bindings.js +108 -8
  418. package/dist/targets/cpp/emit-buffers.d.ts +2 -16
  419. package/dist/targets/cpp/emit-buffers.js +124 -25
  420. package/dist/targets/cpp/emit-callable.d.ts +35 -72
  421. package/dist/targets/cpp/emit-callable.js +647 -82
  422. package/dist/targets/cpp/emit-carrier-members.d.ts +13 -2
  423. package/dist/targets/cpp/emit-carrier-members.js +50 -9
  424. package/dist/targets/cpp/emit-constructor-identity-family.d.ts +20 -0
  425. package/dist/targets/cpp/emit-constructor-identity-family.js +45 -0
  426. package/dist/targets/cpp/emit-context.d.ts +329 -15
  427. package/dist/targets/cpp/emit-context.js +104 -13
  428. package/dist/targets/cpp/emit-dynamic-properties.d.ts +44 -0
  429. package/dist/targets/cpp/emit-dynamic-properties.js +256 -37
  430. package/dist/targets/cpp/emit-equality.js +117 -2
  431. package/dist/targets/cpp/emit-error-constructor.d.ts +19 -0
  432. package/dist/targets/cpp/emit-error-constructor.js +73 -0
  433. package/dist/targets/cpp/emit-exceptions.d.ts +25 -3
  434. package/dist/targets/cpp/emit-exceptions.js +215 -26
  435. package/dist/targets/cpp/emit-in.js +52 -5
  436. package/dist/targets/cpp/emit-instanceof.js +59 -11
  437. package/dist/targets/cpp/emit-integers.d.ts +6 -0
  438. package/dist/targets/cpp/emit-integers.js +10 -0
  439. package/dist/targets/cpp/emit-iterable-object-view.d.ts +15 -0
  440. package/dist/targets/cpp/emit-iterable-object-view.js +51 -0
  441. package/dist/targets/cpp/emit-iterator-object-view.d.ts +15 -0
  442. package/dist/targets/cpp/emit-iterator-object-view.js +125 -0
  443. package/dist/targets/cpp/emit-iterator.d.ts +7 -10
  444. package/dist/targets/cpp/emit-iterator.js +361 -24
  445. package/dist/targets/cpp/emit-json.d.ts +7 -1
  446. package/dist/targets/cpp/emit-json.js +595 -55
  447. package/dist/targets/cpp/emit-jsx.d.ts +0 -37
  448. package/dist/targets/cpp/emit-jsx.js +70 -8
  449. package/dist/targets/cpp/emit-narrowing.d.ts +192 -28
  450. package/dist/targets/cpp/emit-narrowing.js +1595 -120
  451. package/dist/targets/cpp/emit-native-selection.js +8 -2
  452. package/dist/targets/cpp/emit-presence.js +13 -0
  453. package/dist/targets/cpp/emit-properties.d.ts +3 -1
  454. package/dist/targets/cpp/emit-properties.js +303 -54
  455. package/dist/targets/cpp/emit-protocol-iterator.d.ts +14 -0
  456. package/dist/targets/cpp/emit-protocol-iterator.js +203 -0
  457. package/dist/targets/cpp/emit-proxy.d.ts +17 -0
  458. package/dist/targets/cpp/emit-proxy.js +35 -0
  459. package/dist/targets/cpp/emit-record-view.d.ts +12 -1
  460. package/dist/targets/cpp/emit-record-view.js +429 -18
  461. package/dist/targets/cpp/emit-return.d.ts +38 -0
  462. package/dist/targets/cpp/emit-return.js +143 -21
  463. package/dist/targets/cpp/emit-scopes.d.ts +78 -0
  464. package/dist/targets/cpp/emit-scopes.js +196 -0
  465. package/dist/targets/cpp/emit-sum-widening.js +6 -3
  466. package/dist/targets/cpp/emit-tonumber.d.ts +40 -1
  467. package/dist/targets/cpp/emit-tonumber.js +75 -4
  468. package/dist/targets/cpp/emit-tostring.d.ts +28 -2
  469. package/dist/targets/cpp/emit-tostring.js +115 -12
  470. package/dist/targets/cpp/emit-typeof.js +2 -2
  471. package/dist/targets/cpp/emit-union-properties.d.ts +9 -0
  472. package/dist/targets/cpp/emit-union-properties.js +375 -46
  473. package/dist/targets/cpp/emit.d.ts +3 -1
  474. package/dist/targets/cpp/emit.js +725 -90
  475. package/dist/targets/cpp/evaluated-once.d.ts +51 -0
  476. package/dist/targets/cpp/evaluated-once.js +140 -0
  477. package/dist/targets/cpp/host/core-globals.d.ts +0 -21
  478. package/dist/targets/cpp/host/core-globals.js +10 -2
  479. package/dist/targets/cpp/host/emit-host-invoke.d.ts +0 -10
  480. package/dist/targets/cpp/host/emit-host-invoke.js +454 -36
  481. package/dist/targets/cpp/host/emit-host-object.js +733 -88
  482. package/dist/targets/cpp/host/emit-host-properties.js +26 -2
  483. package/dist/targets/cpp/host/emit-host-reflect.d.ts +1 -0
  484. package/dist/targets/cpp/host/emit-host-reflect.js +26 -7
  485. package/dist/targets/cpp/host/emit-host-value.d.ts +13 -0
  486. package/dist/targets/cpp/host/emit-host-value.js +47 -3
  487. package/dist/targets/cpp/host/host-members.d.ts +11 -0
  488. package/dist/targets/cpp/host/host-members.js +50 -4
  489. package/dist/targets/cpp/host/native-protocols.js +3 -0
  490. package/dist/targets/cpp/host/object-protocol.d.ts +8 -0
  491. package/dist/targets/cpp/host/object-protocol.js +55 -13
  492. package/dist/targets/cpp/key-order-tracking.d.ts +11 -0
  493. package/dist/targets/cpp/key-order-tracking.js +18 -0
  494. package/dist/targets/cpp/manifest/capabilities.js +107 -8
  495. package/dist/targets/cpp/manifest.js +14 -0
  496. package/dist/targets/cpp/native-collection-base.d.ts +27 -0
  497. package/dist/targets/cpp/native-collection-base.js +202 -0
  498. package/dist/targets/cpp/native-error-base.d.ts +14 -0
  499. package/dist/targets/cpp/native-error-base.js +19 -4
  500. package/dist/targets/cpp/native-promise-base.d.ts +23 -0
  501. package/dist/targets/cpp/native-promise-base.js +30 -0
  502. package/dist/targets/cpp/native-symbol-keys.js +1 -1
  503. package/dist/targets/cpp/prototype/emit-prototype-array.js +258 -20
  504. package/dist/targets/cpp/prototype/emit-prototype-date.js +5 -4
  505. package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +9 -1
  506. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +232 -26
  507. package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +1 -1
  508. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +111 -13
  509. package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +33 -4
  510. package/dist/targets/cpp/prototype/emit-prototype-promise.js +218 -10
  511. package/dist/targets/cpp/prototype/emit-prototype-regexp.js +8 -5
  512. package/dist/targets/cpp/prototype/emit-prototype-string.js +24 -7
  513. package/dist/targets/cpp/prototype/prototype-method-reads.js +18 -3
  514. package/dist/targets/cpp/reactive-dependencies.d.ts +2 -0
  515. package/dist/targets/cpp/reactive-dependencies.js +94 -3
  516. package/dist/targets/cpp/realm-storage.d.ts +5 -0
  517. package/dist/targets/cpp/realm-storage.js +12 -0
  518. package/dist/targets/cpp/records.d.ts +151 -1
  519. package/dist/targets/cpp/records.js +1321 -122
  520. package/dist/targets/cpp/recursive-containers.d.ts +4 -1
  521. package/dist/targets/cpp/recursive-containers.js +28 -9
  522. package/dist/targets/cpp/translation-unit.d.ts +10 -0
  523. package/dist/targets/cpp/translation-unit.js +686 -140
  524. package/dist/targets/cpp/types.d.ts +56 -6
  525. package/dist/targets/cpp/types.js +218 -12
  526. package/dist/targets/cpp/virtual-methods.d.ts +3 -3
  527. package/dist/targets/cpp/virtual-methods.js +174 -17
  528. package/package.json +6 -5
  529. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +155 -25
  530. package/src/targets/cpp/runtime/gea_eval.h +3 -0
  531. package/src/targets/cpp/runtime/gea_pcm.h +116 -0
  532. package/src/targets/cpp/runtime/gea_runtime.h +18096 -4876
  533. package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +7 -45
  534. package/src/targets/cpp/runtime/gea_runtime_rtc.h +247 -0
@@ -1,6 +1,7 @@
1
1
  import type { Representation } from '../representation/model.js';
2
2
  import type { ConversionNode, ConversionNodeId } from './algebra.js';
3
3
  import type { CoercionOperation, ConversionRuntimeRegistry } from './registry.js';
4
+ import type { FamilyMemberKeys } from './record-view.js';
4
5
  /**
5
6
  * The conversion census: ONE node per (source, target) pair, minted on
6
7
  * demand and remembered.
@@ -62,6 +63,72 @@ export interface ConversionCensus {
62
63
  * arm's parameters un-promoted.
63
64
  */
64
65
  readonly exactArmFor: (source: Representation, target: Representation) => ConversionNode | null;
66
+ /**
67
+ * An instance of a class extending a native collection, read AS that
68
+ * collection for one of the collection's own members
69
+ * (`SemanticOperand.nativeBaseView`): `super.get(k)`, or `lower.size` where
70
+ * no class in the family redeclares `size`. The same upcast the ordinary
71
+ * store renders, minted even for a family that redeclares OTHER members,
72
+ * which is exactly the case `nodeFor` must refuse. `null` for any other pair.
73
+ */
74
+ readonly nativeBaseViewFor: (source: Representation, target: Representation) => ConversionNode | null;
75
+ /**
76
+ * A census-built sum read as the one native collection the program asserts
77
+ * it is (`lower-operands.ts`'s `assertedCensusUnionReceiver`): every arm is
78
+ * that collection, a box, or an open Document that may view one, and EACH
79
+ * is converted -- the collection as it is, the box through its checked
80
+ * unbox, the Document through the object it views. `nodeFor`'s answer for
81
+ * the same pair selects the collection's arm by its tag, which misreads a
82
+ * boxed or viewed Map. `null` for any other pair.
83
+ */
84
+ readonly armViewFor: (source: Representation, target: Representation) => ConversionNode | null;
85
+ /**
86
+ * A tagged union the program's own `as T` asserts to ONE carrier that some
87
+ * arm cannot convert into. The assertion proves nothing about which arm is
88
+ * live (a flow narrowing would), so `nodeFor`'s selection -- an unchecked
89
+ * `get<k>()` of the arm that converts -- is wrong for the other arms: it
90
+ * aborted on a live `unknown[]` arm of `(cond ? items[0] : items) as S[]`.
91
+ * This node dispatches on the live arm instead: an arm that converts does,
92
+ * an `Array<any>` arm is rebuilt element-wise with each element checked, and
93
+ * an arm that cannot be the target is a `TypeError`. `null` for a source that
94
+ * is not a union or a target that is a union, a box or an optional (those
95
+ * have their own whole-union recipes).
96
+ */
97
+ readonly assertedUnionFor: (source: Representation, target: Representation, copyAllowed: boolean) => ConversionNode | null;
98
+ /**
99
+ * A record entering a slot whose record arm is an interface FAMILY's
100
+ * layout, viewed knowing which members of the family the site named
101
+ * (`record-view.ts`'s `FamilyMemberKeys`). `nodeFor`'s answer for the same
102
+ * pair is keyed by carriers alone and cannot tell a site that named a
103
+ * member lacking a layout field from one whose member declares it, so it
104
+ * must refuse a source that cannot fill that field; this node is asked
105
+ * only after it did, by a site that published the member it names. `null`
106
+ * where even the member's own keys leave no view.
107
+ */
108
+ readonly familyMemberViewFor: (source: Representation, target: Representation, members: FamilyMemberKeys) => ConversionNode | null;
109
+ /**
110
+ * A CAUGHT value -- a `catch (error)` binding typed `any` -- handed to a
111
+ * class-typed slot: the checked read of the class instance, which, when the
112
+ * thrown value is not one, rethrows that value rather than aborting.
113
+ * mongodb's `executeOperation` does `catch (error) { return
114
+ * operation.handleError(error) }` with `handleError(error: MongoError)`,
115
+ * whose every implementation rethrows what it does not recognize; in JS a
116
+ * non-MongoError reaches it and propagates as the operation's rejection.
117
+ * The slot cannot hold that value, so the handoff itself propagates it.
118
+ * `null` for any other pair.
119
+ */
120
+ readonly caughtHandoffFor: (source: Representation, target: Representation) => ConversionNode | null;
121
+ /**
122
+ * An `any` argument entering an OPTIONAL parameter (`x?: T`, no default)
123
+ * whose payload has no `null` state: a `null` the value holds reads as the
124
+ * parameter's absence. mongodb's `executeCommands` keeps `let thrownError =
125
+ * null` (typed `any`) and, on success, passes it to `mergeBatchResults(...,
126
+ * err?: AnyError, ...)`. The callee was checked against `T | undefined`, so
127
+ * the only null it can see is one an `any` smuggled past that check; it has
128
+ * no default initializer that could tell the two apart. `null` for any
129
+ * other pair.
130
+ */
131
+ readonly nullishOptionalFor: (source: Representation, target: Representation) => ConversionNode | null;
65
132
  /** The node a `convert` instruction names, from whichever table minted it; `null` for an id no census minted. */
66
133
  readonly nodeById: (id: ConversionNodeId) => ConversionNode | null;
67
134
  /** Every node minted through `nodeFor` that the eager graph did not already hold. */
@@ -75,6 +142,32 @@ export declare const conversionNodeIdOf: (source: Representation, target: Repres
75
142
  /** The carrier each abstract operation lands on. */
76
143
  export declare const coercionTargetOf: (operation: CoercionOperation) => Representation;
77
144
  export declare const createConversionNodes: (input: ConversionCensusInput) => ConversionCensus;
145
+ /** The materializer id every family-member view node carries; the printer dispatches its recipe on it. */
146
+ export declare const FAMILY_MEMBER_VIEW_MATERIALIZER = "view:family-member-record";
147
+ /** The materializer id every nullish-optional node carries; the printer dispatches its recipe on it. */
148
+ export declare const NULLISH_OPTIONAL_MATERIALIZER = "view:nullish-optional";
149
+ /** The materializer id every caught-handoff node carries; the printer dispatches its recipe on it. */
150
+ export declare const CAUGHT_HANDOFF_MATERIALIZER = "view:caught-handoff";
151
+ /** The materializer id every native-base view node carries; the printer dispatches its recipe on it. */
152
+ export declare const NATIVE_BASE_VIEW_MATERIALIZER = "gea::host::nativeBaseView";
153
+ /**
154
+ * Whether `target` is exactly the native collection `source`'s class extends
155
+ * (`class-ref.nativeBase`), by carrier key: the pair every native collection
156
+ * upcast -- a store or a view -- spans.
157
+ */
158
+ export declare const isNativeCollectionUpcast: (source: Representation, target: Representation) => boolean;
159
+ /**
160
+ * Whether `target` is exactly the intrinsic promise `source`'s class extends
161
+ * (`class-ref.nativeBase`): `timeout.then(...)` on `class Timeout extends
162
+ * Promise<never>` reads `then` off that promise, sharing its state.
163
+ */
164
+ export declare const isNativePromiseUpcast: (source: Representation, target: Representation) => boolean;
165
+ /** The materializer id every arm-view node carries; the printer dispatches its recipe on it. */
166
+ export declare const ARM_VIEW_MATERIALIZER = "gea::host::armView";
167
+ /** The materializer id every asserted-union node carries; the printer dispatches its recipe on it. */
168
+ export declare const ASSERTED_UNION_MATERIALIZER = "gea::host::assertedUnion";
169
+ /** The asserted-union node that may rebuild an `Array<any>` arm as a copy. */
170
+ export declare const ASSERTED_UNION_COPY_MATERIALIZER = "gea::host::assertedUnionCopy";
78
171
  /** The materializer id every exact-arm node carries; the printer dispatches its recipe on it. */
79
172
  export declare const EXACT_ARM_MATERIALIZER = "gea::host::exactArm";
80
173
  /**
@@ -1,7 +1,46 @@
1
- import { representationKey } from '../representation/model.js';
1
+ import { isOpenDocument, representationKey, standInRefuses } from '../representation/model.js';
2
2
  import { validateCapability } from './algebra.js';
3
3
  import { createConversionDerivationContext, deriveConversionCapability } from './derive.js';
4
4
  import { narrowingCapabilityFor } from './build.js';
5
+ /**
6
+ * Why a callable whose convention takes a receiver of class `X` cannot become
7
+ * one taking a receiver of class `Y` that does not extend `X`, or `null` for
8
+ * any other pair.
9
+ *
10
+ * `X.prototype.m.call(y, ...)` is the program shape: `mongodb-connection-
11
+ * string-url` borrows `CaseInsensitiveMap.prototype._normalizeKey` onto its
12
+ * `URLSearchParams` subclass. The body was compiled against `X`'s layout and
13
+ * dispatch -- its `this.keys()` is `Map`'s -- and no conversion of the function
14
+ * VALUE can retarget that; running it on a `Y` needs the body compiled again
15
+ * for `Y`, which this compiler does not do. The pair was already refused; this
16
+ * says why, rather than naming only the two carriers.
17
+ */
18
+ const foreignReceiverOf = (source, target) => {
19
+ // The receiver itself, handed to a method of the unrelated class: the
20
+ // lowered form of the same borrow when the callee is resolved directly.
21
+ if (source.kind === 'class-ref' && target.kind === 'class-ref') {
22
+ if (source.declaration === target.declaration || source.ancestors.includes(target.declaration))
23
+ return null;
24
+ if (target.ancestors.includes(source.declaration))
25
+ return null;
26
+ return (`an instance of class ${source.declaration} is used where class ${target.declaration} is declared, and neither extends the ` +
27
+ `other: a compiled instance has its own class's layout, so no conversion makes it one of the other (a borrowed method, ` +
28
+ `\`${target.declaration}.prototype.m.call(instance)\`, would need the body compiled again for the instance's class)`);
29
+ }
30
+ if (!('abi' in source) || !('abi' in target))
31
+ return null;
32
+ const from = source.abi.receiver;
33
+ const into = target.abi.receiver;
34
+ if (from?.kind !== 'class-ref' || into?.kind !== 'class-ref')
35
+ return null;
36
+ if (into.declaration === from.declaration || into.ancestors.includes(from.declaration))
37
+ return null;
38
+ if (from.ancestors.includes(into.declaration))
39
+ return null;
40
+ return (`a method compiled for receivers of class ${from.declaration} is called with a receiver of class ${into.declaration}, ` +
41
+ `which does not extend it (\`${from.declaration}.prototype.m.call(receiver)\`): the body is compiled against its own ` +
42
+ "class's layout and dispatch, and running it on another class would need a copy of the body compiled for that class");
43
+ };
5
44
  export const conversionNodeIdOf = (source, target) => `${representationKey(source)}->${representationKey(target)}`;
6
45
  /** The carrier each abstract operation lands on. */
7
46
  export const coercionTargetOf = (operation) => operation === 'ToNumber' ? { kind: 'scalar', domain: 'number' } : { kind: 'string' };
@@ -17,6 +56,8 @@ export const createConversionNodes = (input) => {
17
56
  }
18
57
  if (source.kind === 'void')
19
58
  return { kind: 'never', reason: `a void source has no value to convert into ${targetKey}` };
59
+ if (standInRefuses(source, target))
60
+ return { kind: 'never', reason: `${targetKey} is a stand-in record only its own shape moves into` };
20
61
  if (containsUnresolved(source) || containsUnresolved(target)) {
21
62
  return { kind: 'never', reason: `an unresolved carrier in ${sourceKey} -> ${targetKey} names no conversion` };
22
63
  }
@@ -45,7 +86,9 @@ export const createConversionNodes = (input) => {
45
86
  const recipe = input.registry.staticRecipe(source, target);
46
87
  if (recipe)
47
88
  return { kind: 'static', materializer: recipe };
48
- return { kind: 'never', reason: `no runtime conversion is installed from ${sourceKey} to ${targetKey}` };
89
+ const foreign = foreignReceiverOf(source, target);
90
+ const missing = `no runtime conversion is installed from ${sourceKey} to ${targetKey}`;
91
+ return { kind: 'never', reason: foreign === null ? missing : `${missing}: ${foreign}` };
49
92
  };
50
93
  const nodeFor = (source, target) => {
51
94
  const sourceKey = representationKey(source);
@@ -58,7 +101,10 @@ export const createConversionNodes = (input) => {
58
101
  if (remembered !== undefined)
59
102
  return remembered;
60
103
  const capability = capabilityOf(source, target, sourceKey, targetKey);
61
- validateCapability(capability, new Set([...input.nodes.keys(), ...minted.keys(), id]));
104
+ // A membership view, not a Set copied from both tables: the copy was made
105
+ // once per minted pair, quadratic in the census, and was the mongodb
106
+ // driver's single largest lowering cost (20 of 35 seconds).
107
+ validateCapability(capability, { has: (known) => known === id || input.nodes.has(known) || minted.has(known) });
62
108
  const node = { id, source, target, capability };
63
109
  minted.set(id, node);
64
110
  return node;
@@ -115,9 +161,216 @@ export const createConversionNodes = (input) => {
115
161
  exactArms.set(id, node);
116
162
  return node;
117
163
  };
118
- const nodeById = (id) => input.nodes.get(id) ?? minted.get(id) ?? coercions.get(id) ?? exactArms.get(id) ?? null;
119
- return { nodeFor, coercionFor, exactArmFor, nodeById, minted };
164
+ const nativeBaseViews = new Map();
165
+ const nativeBaseViewFor = (source, target) => {
166
+ if (!isNativeCollectionUpcast(source, target) && !isNativePromiseUpcast(source, target))
167
+ return null;
168
+ const id = `${representationKey(source)}->${representationKey(target)}#native-base-view`;
169
+ const remembered = nativeBaseViews.get(id);
170
+ if (remembered !== undefined)
171
+ return remembered;
172
+ const node = {
173
+ id,
174
+ source,
175
+ target,
176
+ capability: {
177
+ kind: 'static',
178
+ materializer: {
179
+ id: NATIVE_BASE_VIEW_MATERIALIZER,
180
+ domain: 'static:native-base-view',
181
+ allocates: false,
182
+ nativeFieldProtocol: 'unused',
183
+ nativePayloadTransport: 'preserved',
184
+ nativeClassReferenceIdentity: 'preserved',
185
+ callableIdentityTransport: 'preserved'
186
+ }
187
+ }
188
+ };
189
+ nativeBaseViews.set(id, node);
190
+ return node;
191
+ };
192
+ const armViews = new Map();
193
+ const armViewFor = (source, target) => {
194
+ if (!isArmViewPair(source, target))
195
+ return null;
196
+ const id = `${representationKey(source)}->${representationKey(target)}#arm-view`;
197
+ const remembered = armViews.get(id);
198
+ if (remembered !== undefined)
199
+ return remembered;
200
+ const node = {
201
+ id,
202
+ source,
203
+ target,
204
+ capability: { kind: 'static', materializer: { id: ARM_VIEW_MATERIALIZER, domain: 'static:arm-view', allocates: true } }
205
+ };
206
+ armViews.set(id, node);
207
+ return node;
208
+ };
209
+ const assertedUnions = new Map();
210
+ const assertedUnionFor = (source, target, copyAllowed) => {
211
+ if (source.kind !== 'tagged-union')
212
+ return null;
213
+ if (target.kind === 'tagged-union' || target.kind === 'dynamic' || target.kind === 'optional')
214
+ return null;
215
+ const id = `${representationKey(source)}->${representationKey(target)}#asserted-union${copyAllowed ? ':copy' : ''}`;
216
+ const remembered = assertedUnions.get(id);
217
+ if (remembered !== undefined)
218
+ return remembered;
219
+ const node = {
220
+ id,
221
+ source,
222
+ target,
223
+ capability: {
224
+ kind: 'static',
225
+ materializer: {
226
+ id: copyAllowed ? ASSERTED_UNION_COPY_MATERIALIZER : ASSERTED_UNION_MATERIALIZER,
227
+ domain: copyAllowed ? 'static:asserted-union-copy' : 'static:asserted-union',
228
+ allocates: copyAllowed
229
+ }
230
+ }
231
+ };
232
+ assertedUnions.set(id, node);
233
+ return node;
234
+ };
235
+ const familyMemberViews = new Map();
236
+ const familyMemberViewFor = (source, target, members) => {
237
+ const named = [...members.entries()]
238
+ .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
239
+ .map(([shape, keys]) => `${shape}:${[...keys].sort().join(',')}`)
240
+ .join(';');
241
+ const id = `${representationKey(source)}->${representationKey(target)}#family-members(${named})`;
242
+ const remembered = familyMemberViews.get(id);
243
+ if (remembered !== undefined)
244
+ return remembered;
245
+ const materializer = input.registry.familyMemberView?.(source, target, members) ?? null;
246
+ if (materializer === null)
247
+ return null;
248
+ const node = { id, source, target, capability: { kind: 'static', materializer }, familyMembers: members };
249
+ familyMemberViews.set(id, node);
250
+ return node;
251
+ };
252
+ const caughtHandoffs = new Map();
253
+ const caughtHandoffFor = (source, target) => {
254
+ if (source.kind !== 'dynamic' || target.kind !== 'class-ref')
255
+ return null;
256
+ const id = `${representationKey(source)}->${representationKey(target)}#caught-handoff`;
257
+ const remembered = caughtHandoffs.get(id);
258
+ if (remembered !== undefined)
259
+ return remembered;
260
+ const node = {
261
+ id,
262
+ source,
263
+ target,
264
+ capability: { kind: 'static', materializer: { id: CAUGHT_HANDOFF_MATERIALIZER, domain: 'static:caught-handoff', allocates: false } }
265
+ };
266
+ caughtHandoffs.set(id, node);
267
+ return node;
268
+ };
269
+ const nullishOptionals = new Map();
270
+ const nullishOptionalFor = (source, target) => {
271
+ if (source.kind !== 'dynamic' || target.kind !== 'optional' || target.absence !== 'undefined')
272
+ return null;
273
+ const id = `${representationKey(source)}->${representationKey(target)}#nullish-optional`;
274
+ const remembered = nullishOptionals.get(id);
275
+ if (remembered !== undefined)
276
+ return remembered;
277
+ const node = {
278
+ id,
279
+ source,
280
+ target,
281
+ capability: {
282
+ kind: 'static',
283
+ materializer: { id: NULLISH_OPTIONAL_MATERIALIZER, domain: 'static:nullish-optional', allocates: false }
284
+ }
285
+ };
286
+ nullishOptionals.set(id, node);
287
+ return node;
288
+ };
289
+ const nodeById = (id) => input.nodes.get(id) ??
290
+ minted.get(id) ??
291
+ coercions.get(id) ??
292
+ exactArms.get(id) ??
293
+ nativeBaseViews.get(id) ??
294
+ armViews.get(id) ??
295
+ assertedUnions.get(id) ??
296
+ familyMemberViews.get(id) ??
297
+ caughtHandoffs.get(id) ??
298
+ nullishOptionals.get(id) ??
299
+ null;
300
+ return {
301
+ nodeFor,
302
+ coercionFor,
303
+ exactArmFor,
304
+ nativeBaseViewFor,
305
+ armViewFor,
306
+ assertedUnionFor,
307
+ familyMemberViewFor,
308
+ caughtHandoffFor,
309
+ nullishOptionalFor,
310
+ nodeById,
311
+ minted
312
+ };
313
+ };
314
+ /** The materializer id every family-member view node carries; the printer dispatches its recipe on it. */
315
+ export const FAMILY_MEMBER_VIEW_MATERIALIZER = 'view:family-member-record';
316
+ /** The materializer id every nullish-optional node carries; the printer dispatches its recipe on it. */
317
+ export const NULLISH_OPTIONAL_MATERIALIZER = 'view:nullish-optional';
318
+ /** The materializer id every caught-handoff node carries; the printer dispatches its recipe on it. */
319
+ export const CAUGHT_HANDOFF_MATERIALIZER = 'view:caught-handoff';
320
+ /** The materializer id every native-base view node carries; the printer dispatches its recipe on it. */
321
+ export const NATIVE_BASE_VIEW_MATERIALIZER = 'gea::host::nativeBaseView';
322
+ /**
323
+ * Whether `target` is exactly the native collection `source`'s class extends
324
+ * (`class-ref.nativeBase`), by carrier key: the pair every native collection
325
+ * upcast -- a store or a view -- spans.
326
+ */
327
+ export const isNativeCollectionUpcast = (source, target) => source.kind === 'class-ref' &&
328
+ source.nativeBase !== undefined &&
329
+ target.kind === 'keyed-collection' &&
330
+ representationKey(source.nativeBase) === representationKey(target);
331
+ /**
332
+ * Whether `target` is exactly the intrinsic promise `source`'s class extends
333
+ * (`class-ref.nativeBase`): `timeout.then(...)` on `class Timeout extends
334
+ * Promise<never>` reads `then` off that promise, sharing its state.
335
+ */
336
+ export const isNativePromiseUpcast = (source, target) => source.kind === 'class-ref' &&
337
+ source.nativeBase?.kind === 'promise' &&
338
+ target.kind === 'promise' &&
339
+ representationKey(source.nativeBase) === representationKey(target);
340
+ /** The materializer id every arm-view node carries; the printer dispatches its recipe on it. */
341
+ export const ARM_VIEW_MATERIALIZER = 'gea::host::armView';
342
+ /**
343
+ * Whether `armViewFor` answers the pair: a sum some arm of which is a box or
344
+ * an open Document, every other arm the target itself (or a Map the target's
345
+ * all-dynamic view reads), read as a Map or an Array -- the collections a
346
+ * Document can view (`gea::dictionary::aliasOf`). `emit-narrowing.ts`'s
347
+ * `armViewText` renders exactly these arms.
348
+ */
349
+ const isArmViewPair = (source, target) => {
350
+ if (source.kind !== 'tagged-union')
351
+ return false;
352
+ const viewable = (target.kind === 'keyed-collection' && target.family === 'map') || target.kind === 'array-object';
353
+ if (!viewable || target.ownership !== 'shared-refcount')
354
+ return false;
355
+ const key = representationKey(target);
356
+ const indirect = (arm) => arm.value.kind === 'dynamic' || isOpenDocument(arm.value);
357
+ // Another Map carrier is the same object read through the all-dynamic Map
358
+ // view (`gea::detail::unboxDynamicMap`), when that is the target.
359
+ const mapView = (arm) => target.kind === 'keyed-collection' &&
360
+ target.key.kind === 'dynamic' &&
361
+ target.value?.kind === 'dynamic' &&
362
+ target.recursive === undefined &&
363
+ target.readOnlyView !== true &&
364
+ arm.value.kind === 'keyed-collection' &&
365
+ arm.value.family === 'map' &&
366
+ arm.value.recursive === undefined &&
367
+ arm.value.ownership === 'shared-refcount';
368
+ return source.arms.some(indirect) && source.arms.every((arm) => indirect(arm) || representationKey(arm.value) === key || mapView(arm));
120
369
  };
370
+ /** The materializer id every asserted-union node carries; the printer dispatches its recipe on it. */
371
+ export const ASSERTED_UNION_MATERIALIZER = 'gea::host::assertedUnion';
372
+ /** The asserted-union node that may rebuild an `Array<any>` arm as a copy. */
373
+ export const ASSERTED_UNION_COPY_MATERIALIZER = 'gea::host::assertedUnionCopy';
121
374
  /** The materializer id every exact-arm node carries; the printer dispatches its recipe on it. */
122
375
  export const EXACT_ARM_MATERIALIZER = 'gea::host::exactArm';
123
376
  /**
@@ -127,6 +380,10 @@ export const EXACT_ARM_MATERIALIZER = 'gea::host::exactArm';
127
380
  * exactly-one test still guards the answer rather than trusting that.
128
381
  */
129
382
  export const exactArmIndexOf = (source, target) => {
383
+ // A possibly-absent union projects the same way; absence fails the check
384
+ // like any other arm (`gea::host::exactArm`'s `Optional` overload).
385
+ if (source.kind === 'optional' && source.payload.kind === 'tagged-union')
386
+ return exactArmIndexOf(source.payload, target);
130
387
  if (source.kind !== 'tagged-union')
131
388
  return null;
132
389
  const targetKey = representationKey(target);
@@ -11,10 +11,51 @@ import { narrowingReachesTarget } from './build.js';
11
11
  * emits the same pair as an IR conversion.
12
12
  */
13
13
  export const narrowedOperandView = (source, operand, deriver) => {
14
+ // A box asserted to a type (`(value as string[]).join(',')` over an `any`)
15
+ // is read as that type: the checked unbox, then the native member. Read off
16
+ // the box, the member was looked up as a detached function value and
17
+ // called with no receiver.
18
+ if (source.kind === 'dynamic' && operand.asserted === true) {
19
+ const asserted = deriver.derive(operand.type);
20
+ return asserted.kind === 'unresolved' ? source : asserted;
21
+ }
14
22
  if (source.kind !== 'optional' && source.kind !== 'tagged-union')
15
23
  return source;
16
24
  const target = deriver.derive(operand.type);
17
25
  if (representationKey(source) === representationKey(target))
18
26
  return source;
27
+ if (source.kind === 'tagged-union' && source.arms.some(isProxyArm))
28
+ return narrowedKeepingProxies(source, target);
29
+ // The same sum behind an absence -- a module `let` with no initializer, read
30
+ // where it may still be unwritten (`representation/unassigned-binding-cells.ts`):
31
+ // mongodb's `'kModuleError' in zstd` over the proxy-carrying `ZStandard`. A
32
+ // use that states the arm ran on a present value (`in` throws on
33
+ // `undefined`, and so does a member read), so the view is the payload's own
34
+ // proxy-keeping selection -- the payload itself when the checker's arm is
35
+ // every ordinary arm it holds -- reached by the checked presence load.
36
+ if (source.kind === 'optional' && source.payload.kind === 'tagged-union' && source.payload.arms.some(isProxyArm)) {
37
+ const payload = source.payload;
38
+ const wanted = (target.kind === 'tagged-union' ? target.arms.map((arm) => arm.value) : [target]).map(representationKey);
39
+ const ordinary = new Set(payload.arms.filter((arm) => !isProxyArm(arm)).map((arm) => representationKey(arm.value)));
40
+ if (wanted.length > 0 && wanted.every((key) => ordinary.has(key)))
41
+ return narrowedKeepingProxies(payload, target);
42
+ }
19
43
  return narrowingReachesTarget(source, target) ? target : source;
20
44
  };
45
+ const isProxyArm = (arm) => arm.value.kind === 'proxy-object';
46
+ /**
47
+ * A proxy answers `in`, `typeof`-free structural checks and every other
48
+ * narrowing test through its own traps, so no narrowing the checker performed
49
+ * can rule it out: a narrowed view of a sum holding a proxy arm keeps that arm
50
+ * (under its own tag) beside the ordinary arms the narrowing selected. Loading
51
+ * the narrowed arm unchecked would read the wrong payload while the proxy is
52
+ * the one held.
53
+ */
54
+ const narrowedKeepingProxies = (source, target) => {
55
+ const ordinary = source.arms.filter((arm) => !isProxyArm(arm));
56
+ const wanted = new Set((target.kind === 'tagged-union' ? target.arms.map((arm) => arm.value) : [target]).map((value) => representationKey(value)));
57
+ const kept = ordinary.filter((arm) => wanted.has(representationKey(arm.value)));
58
+ if (kept.length === 0 || kept.length !== wanted.size || kept.length === ordinary.length)
59
+ return source;
60
+ return { kind: 'tagged-union', arms: [...kept, ...source.arms.filter(isProxyArm)] };
61
+ };
@@ -0,0 +1,84 @@
1
+ import type { CallableAbi, RecordField, Representation } from '../representation/model.js';
2
+ import type { RecordLayoutPolicy } from '../representation/policies.js';
3
+ import { type PairConvertible } from './record-view.js';
4
+ /**
5
+ * A program object that implements the iterator protocol by hand, read as the
6
+ * cursor carrier (`iterator`) its declared type names.
7
+ *
8
+ * mongodb's `onData` builds `{ next() {...}, return() {...}, throw(err)
9
+ * {...}, [Symbol.asyncIterator]() { return this } }` typed `AsyncGenerator<
10
+ * Buffer> & AsyncDisposable`: the intersection derives to a record, while
11
+ * `AsyncGenerator<Buffer>` alone -- `[Symbol.asyncIterator]`'s own result, and
12
+ * the field `Connection.dataEvents` it is stored into -- derives to the
13
+ * `async-generator` carrier. The two are one object, so the conversion is a
14
+ * VIEW: the carrier's steps call the same object's own members
15
+ * (`gea_runtime.h`'s `AsyncGenerator::ProtocolSteps`, or
16
+ * `Iterator::ProtocolSteps` for a synchronous iterator object), never a copy of
17
+ * what it held when converted.
18
+ *
19
+ * Only a shared-refcount object qualifies, because only a reference preserves
20
+ * that identity; a by-value record would be a snapshot. Each member the
21
+ * protocol calls must be a callable field whose parameters the call can omit,
22
+ * answering an `IteratorResult`. An async generator's step hands the member's
23
+ * promise straight back, mapped onto its step; a synchronous cursor's step
24
+ * cannot wait for one -- a blocking read inside a callback is the nested pump
25
+ * the runtime refuses -- so a synchronous target admits no promise-answering
26
+ * member. `next` must
27
+ * always be there; `return`/`throw` may be optional members, as
28
+ * `IterableIterator<T>` declares them.
29
+ */
30
+ export interface ProtocolIteratorMember {
31
+ readonly key: 'next' | 'return' | 'throw';
32
+ /**
33
+ * How the object says the member is there: always (`required`), or only
34
+ * when its presence bit is set (`flag`, an optional field) and, for an
35
+ * `optional(...)` value, when that holds a payload too. An optional member
36
+ * is asked at every step, never once at conversion: `IterableIterator<T>`'s
37
+ * `return?`/`throw?` may be installed after the cursor is made, and one that
38
+ * is absent when the step runs behaves exactly as a missing member.
39
+ */
40
+ readonly presence: {
41
+ readonly flag: boolean;
42
+ readonly payload: boolean;
43
+ };
44
+ readonly abi: CallableAbi;
45
+ /** The `IteratorResult` the member answers, after awaiting a promise result. */
46
+ readonly result: Representation;
47
+ readonly awaited: boolean;
48
+ }
49
+ export interface ProtocolIteratorPlan {
50
+ readonly source: Extract<Representation, {
51
+ kind: 'record' | 'native-record-ref';
52
+ }>;
53
+ /**
54
+ * The cursor the object is read as: the synchronous `iterator` (a
55
+ * `Generator`/`IterableIterator`-typed object), or an `async-generator`
56
+ * (mongodb's `onData`, typed `AsyncGenerator<Buffer>`), whose steps hand the
57
+ * member's promise back instead of reading it -- `gea::AsyncGenerator`'s
58
+ * `ProtocolSteps`.
59
+ */
60
+ readonly target: Extract<Representation, {
61
+ kind: 'iterator' | 'async-generator';
62
+ }>;
63
+ readonly next: ProtocolIteratorMember;
64
+ readonly finish: ProtocolIteratorMember | null;
65
+ readonly raise: ProtocolIteratorMember | null;
66
+ }
67
+ export interface IteratorResultRecord {
68
+ readonly record: Representation;
69
+ readonly value: RecordField;
70
+ readonly done: RecordField;
71
+ /** Whether a step can find this arm not done (a yielded value) and done (a completion). */
72
+ readonly yields: boolean;
73
+ readonly returns: boolean;
74
+ }
75
+ /**
76
+ * The `{ value, done }` records an `IteratorResult` can be: every arm of a
77
+ * union, or the one record. The library's union is told apart the way
78
+ * `record-view.ts`'s `iteratorResultHomes` tells it apart: the return arm
79
+ * REQUIRES `done` (`done: true`), the yield arm leaves it optional (`done?:
80
+ * false`), since boolean literals do not survive structural normalization. A
81
+ * shape with no such split can be either.
82
+ */
83
+ export declare const iteratorResultRecordsOf: (layouts: RecordLayoutPolicy, result: Representation) => readonly IteratorResultRecord[] | null;
84
+ export declare const protocolIteratorPlan: (layouts: RecordLayoutPolicy, source: Representation, target: Representation, convertible: PairConvertible) => ProtocolIteratorPlan | null;
@@ -0,0 +1,88 @@
1
+ import { thrownValueCarrier } from '../representation/model.js';
2
+ import { holdsAbsence } from './record-view.js';
3
+ /**
4
+ * The `{ value, done }` records an `IteratorResult` can be: every arm of a
5
+ * union, or the one record. The library's union is told apart the way
6
+ * `record-view.ts`'s `iteratorResultHomes` tells it apart: the return arm
7
+ * REQUIRES `done` (`done: true`), the yield arm leaves it optional (`done?:
8
+ * false`), since boolean literals do not survive structural normalization. A
9
+ * shape with no such split can be either.
10
+ */
11
+ export const iteratorResultRecordsOf = (layouts, result) => {
12
+ const arms = result.kind === 'tagged-union' ? result.arms.map((arm) => arm.value) : [result];
13
+ const found = [];
14
+ for (const arm of arms) {
15
+ const fields = arm.kind === 'record' ? arm.fields : arm.kind === 'native-record-ref' ? layouts.forShape(arm.shapeId) : null;
16
+ if (fields === null)
17
+ return null;
18
+ const value = fields.find((field) => field.key === 'value');
19
+ const done = fields.find((field) => field.key === 'done');
20
+ if (value === undefined || done === undefined)
21
+ return null;
22
+ found.push({ record: arm, value, done });
23
+ }
24
+ const split = found.some((arm) => arm.done.required) && found.some((arm) => !arm.done.required);
25
+ return found.map((arm) => ({ ...arm, yields: !split || !arm.done.required, returns: !split || arm.done.required }));
26
+ };
27
+ const omittable = (abi, from) => abi.parameters.every((parameter, position) => position < from ||
28
+ (abi.restFrom !== null && position >= abi.restFrom ? parameter.value.kind === 'array-object' : holdsAbsence(parameter.value)));
29
+ const memberOf = (layouts, fields, source, key, convertible) => {
30
+ const field = fields.find((candidate) => candidate.key === key);
31
+ if (field === undefined)
32
+ return 'absent';
33
+ const payload = field.value.kind === 'optional';
34
+ const value = field.value.kind === 'optional' ? field.value.payload : field.value;
35
+ // `next` is what makes the object an iterator at all.
36
+ if (key === 'next' && (payload || !field.required))
37
+ return null;
38
+ if (value.kind !== 'function-value-dispatch')
39
+ return null;
40
+ const abi = value.abi;
41
+ if (abi.receiver !== null && !convertible(source, abi.receiver))
42
+ return null;
43
+ // `throw(e)` hands the thrown value on as its first argument.
44
+ if (key === 'throw') {
45
+ const first = abi.parameters[0];
46
+ if (first === undefined || (abi.restFrom !== null && abi.restFrom === 0) || !convertible(thrownValueCarrier, first.value))
47
+ return null;
48
+ }
49
+ if (!omittable(abi, key === 'throw' ? 1 : 0))
50
+ return null;
51
+ const awaited = abi.result.kind === 'promise';
52
+ const result = abi.result.kind === 'promise' ? abi.result.value : abi.result;
53
+ if (iteratorResultRecordsOf(layouts, result) === null)
54
+ return null;
55
+ return { key, presence: { flag: !field.required, payload }, abi, result, awaited };
56
+ };
57
+ export const protocolIteratorPlan = (layouts, source, target, convertible) => {
58
+ if (target.kind !== 'iterator' && target.kind !== 'async-generator')
59
+ return null;
60
+ if ((source.kind !== 'record' && source.kind !== 'native-record-ref') || source.ownership !== 'shared-refcount')
61
+ return null;
62
+ const fields = source.kind === 'record' ? source.fields : layouts.forShape(source.shapeId);
63
+ if (fields === null)
64
+ return null;
65
+ const next = memberOf(layouts, fields, source, 'next', convertible);
66
+ if (next === null || next === 'absent')
67
+ return null;
68
+ const finish = memberOf(layouts, fields, source, 'return', convertible);
69
+ const raise = memberOf(layouts, fields, source, 'throw', convertible);
70
+ if (finish === null || raise === null)
71
+ return null;
72
+ if (target.kind === 'iterator' && [next, finish, raise].some((member) => member !== 'absent' && member.awaited))
73
+ return null;
74
+ // Every value a step can hand the cursor must reach its carrier: a yielded
75
+ // `value` the element, a done `value` the completion.
76
+ const completionValueless = target.completion.kind === 'void' || target.completion.kind === 'undefined';
77
+ for (const member of [next, raise === 'absent' ? null : raise]) {
78
+ if (member === null)
79
+ continue;
80
+ for (const arm of iteratorResultRecordsOf(layouts, member.result) ?? []) {
81
+ if (arm.yields && !convertible(arm.value.value, target.element))
82
+ return null;
83
+ if (arm.returns && !completionValueless && !convertible(arm.value.value, target.completion))
84
+ return null;
85
+ }
86
+ }
87
+ return { source, target, next, finish: finish === 'absent' ? null : finish, raise: raise === 'absent' ? null : raise };
88
+ };