@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,12 +1,13 @@
1
1
  import { instantiatedParameterTypes } from '../semantics/model/selected-signature.js';
2
2
  import { genericFunctionSetMembersOf, runtimeSymbolMemberIndexOf } from '../semantics/model/structural-types.js';
3
- import { carriableIndexesOf, dictionaryIndexOf, isDataOnlyObjectShape, recordAccessorsOf, recordFieldKeyOf } from './object-shape.js';
3
+ import { carriableIndexesOf, dictionaryIndexOf, isDataOnlyObjectShape, physicalIndexesOf, recordAccessorsOf, recordFieldKeyOf } from './object-shape.js';
4
4
  import { abiKey, passingOf, representationKey } from './model.js';
5
5
  import { createIntersectionFlattener, intersectPropertyRepresentations, intersectionMemberKindOf, isPrimitiveValueShape } from './intersection.js';
6
- import { widestSubsumingAbi } from './host-abi.js';
6
+ import { callbackOverloadJoinedAbi, widestSubsumingAbi } from './host-abi.js';
7
7
  import { primitiveCarrier, storedCarrier, unresolved } from './primitives.js';
8
8
  import { createUnionDeriver } from './union.js';
9
9
  import { deriveKeyedCollection } from './collections.js';
10
+ import { withStaticFieldAbsence } from './static-field-cells.js';
10
11
  import { defaultClassCopyPolicy, defaultDateDeclarationPolicy, defaultHostBindingPolicy, defaultHostNamespaceRootPolicy, defaultKeyedCollectionPolicy, defaultOwnershipPolicy, defaultPromiseDeclarationPolicy, defaultGeneratorDeclarationPolicy, defaultRegExpDeclarationPolicy, defaultStandardBufferPolicy, defaultStringObjectDeclarationPolicy, defaultErrorDeclarationPolicy, defaultFunctionDeclarationPolicy, defaultClassHeritagePolicy, defaultInterfaceImplementorPolicy, defaultTypedArrayElementPolicy, defaultValueRecordPolicy } from './policies.js';
11
12
  export { defaultClassCopyPolicy, defaultDateDeclarationPolicy, defaultHostBindingPolicy, defaultHostNamespaceRootPolicy, defaultKeyedCollectionPolicy, defaultOwnershipPolicy, defaultPromiseDeclarationPolicy, defaultGeneratorDeclarationPolicy, defaultRegExpDeclarationPolicy, defaultStandardBufferPolicy, defaultStringObjectDeclarationPolicy, defaultErrorDeclarationPolicy, defaultFunctionDeclarationPolicy, defaultClassHeritagePolicy, defaultInterfaceImplementorPolicy, defaultTypedArrayElementPolicy, defaultValueRecordPolicy };
12
13
  /**
@@ -85,7 +86,10 @@ export const selectedHostConstructFrameOf = (deriver, signature, received, resul
85
86
  return null;
86
87
  return { ...abi, result };
87
88
  };
88
- export const createRepresentationDeriver = (types, ownership = defaultOwnershipPolicy, binding = defaultHostBindingPolicy, elements = defaultTypedArrayElementPolicy, promise = defaultPromiseDeclarationPolicy, collections = defaultKeyedCollectionPolicy, buffers = defaultStandardBufferPolicy, namespaceRoots = defaultHostNamespaceRootPolicy, date = defaultDateDeclarationPolicy, generator = defaultGeneratorDeclarationPolicy, regexp = defaultRegExpDeclarationPolicy, stringObject = defaultStringObjectDeclarationPolicy, functionType = defaultFunctionDeclarationPolicy, heritage = defaultClassHeritagePolicy, valueRecords = defaultValueRecordPolicy, implementors = defaultInterfaceImplementorPolicy, errors = defaultErrorDeclarationPolicy, dynamicFallback = false, dynamicFallbackTypes = new Set(), dynamicCallableShapes = new Map(), dynamicWrittenTypes = new Set(), classCopies = defaultClassCopyPolicy) => {
89
+ export const createRepresentationDeriver = (types, ownership = defaultOwnershipPolicy, binding = defaultHostBindingPolicy, elements = defaultTypedArrayElementPolicy, promise = defaultPromiseDeclarationPolicy, collections = defaultKeyedCollectionPolicy, buffers = defaultStandardBufferPolicy, namespaceRoots = defaultHostNamespaceRootPolicy, date = defaultDateDeclarationPolicy, generator = defaultGeneratorDeclarationPolicy, regexp = defaultRegExpDeclarationPolicy, stringObject = defaultStringObjectDeclarationPolicy, functionType = defaultFunctionDeclarationPolicy, heritage = defaultClassHeritagePolicy, valueRecords = defaultValueRecordPolicy, implementors = defaultInterfaceImplementorPolicy, errors = defaultErrorDeclarationPolicy, dynamicFallback = false, dynamicFallbackTypes = new Set(), dynamicCallableShapes = new Map(), dynamicWrittenTypes = new Set(), classCopies = defaultClassCopyPolicy,
90
+ // The required members some object of a record type is created without
91
+ // (`unwritten-record-members.ts`), by the record's object shape.
92
+ unwrittenMembers = new Map()) => {
89
93
  const memo = new Map();
90
94
  // Every C++ spelling this deriver stamped on a Date's carrier, so `isDateCarrier` can read the fact back off a carrier.
91
95
  const dateNatives = new Set();
@@ -199,6 +203,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
199
203
  const outer = shapeOf(id);
200
204
  if (!outer)
201
205
  return null;
206
+ // A declared keyed collection is that collection whatever its body: the
207
+ // lib `Map` interface carries its members as an object body, and the
208
+ // declared branch below derives `keyed-collection` without looking at
209
+ // it. Reading the body first answered "an object, not a container" for
210
+ // `type Tree = Map<string, Tree>`, whose argument anchors on the `Map`
211
+ // itself, so the back edge never closed and the third level fell to a
212
+ // record of `Map`'s own members.
213
+ if (outer.kind === 'declared' && collections.forDeclaration(outer.declaration)) {
214
+ return { kind: 'keyed-collection', shape: outer, bodyId: id, ownershipShape: outer, ownershipId: id };
215
+ }
202
216
  const body = outer.kind === 'declared' && outer.body !== null ? shapeOf(outer.body) : null;
203
217
  const source = body ?? outer;
204
218
  const sourceId = body === null ? id : outer.body;
@@ -566,7 +580,11 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
566
580
  const parameterOwnership = ownership.forParameter(value);
567
581
  parameters.push({ value, ownership: parameterOwnership, passing: passingOf(value, parameterOwnership) });
568
582
  }
569
- const declaredReceiver = signature.thisParameter ? derive(signature.thisParameter) : null;
583
+ const declaredReceiver = signature.thisParameter
584
+ ? signature.implicitReceiver
585
+ ? exactClassInstanceOf(signature.thisParameter)
586
+ : derive(signature.thisParameter)
587
+ : null;
570
588
  return {
571
589
  parameters,
572
590
  restFrom,
@@ -704,6 +722,9 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
704
722
  const unionJoined = joinsByUnion ? unionJoinedAbi(signatures) : null;
705
723
  if (unionJoined)
706
724
  return unionJoined;
725
+ const callbackJoined = joinsByUnion ? callbackOverloadJoinedAbi(abis) : null;
726
+ if (callbackJoined)
727
+ return callbackJoined;
707
728
  return role === 'construct'
708
729
  ? `no primitive joining ${signatures.length} construct signatures into one calling convention: ${widened}`
709
730
  : `no primitive joining ${signatures.length} overload signatures into one calling convention: ${widened}`;
@@ -724,9 +745,21 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
724
745
  // An accessor-backed member has no storage, so it contributes no field. Both
725
746
  // halves read the same member list so the two can never disagree about which
726
747
  // members are laid out and which are called.
727
- const recordFieldsOf = (shape) => shape.members
728
- .filter((member) => member.accessor === null && runtimeSymbolMemberIndexOf(shape, member.key) === null)
729
- .map((member) => ({ key: recordFieldKeyOf(member.key), value: deriveStored(member.type), required: !member.optional }));
748
+ // A required member some object of this record is created without is laid
749
+ // out as an optional one: a presence bit that starts absent and a carrier
750
+ // that holds the `undefined` a read of it yields (`unwritten-record-members.ts`).
751
+ const isRecordFieldMember = (shape, member) => member.accessor === null && runtimeSymbolMemberIndexOf(shape, member.key) === null;
752
+ const recordFieldsOf = (shape, id = null) => {
753
+ const unwritten = id === null ? undefined : unwrittenMembers.get(id);
754
+ return shape.members
755
+ .filter((member) => isRecordFieldMember(shape, member))
756
+ .map((member) => {
757
+ const key = recordFieldKeyOf(member.key);
758
+ return !member.optional && unwritten?.has(key)
759
+ ? { key, value: withStaticFieldAbsence(deriveStored(member.type)), required: false }
760
+ : { key, value: deriveStored(member.type), required: !member.optional };
761
+ });
762
+ };
730
763
  /**
731
764
  * Derive and canonicalize the disjoint physical key domains of a record.
732
765
  * Number property keys alias their canonical string form in JavaScript, so a
@@ -786,7 +819,73 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
786
819
  }
787
820
  return fields;
788
821
  };
822
+ /**
823
+ * Whether a member's type is a callable and can be nothing else, read off
824
+ * shapes alone so a self-referential interface does not recurse.
825
+ *
826
+ * A union of a callable and a plain arm (`$where?: string | ((this: T) =>
827
+ * boolean)`) is not one: the member holds an `any` slot's value either way,
828
+ * and nothing about it needs a call convention until a program narrows it to
829
+ * the function. An intersection is callable exactly when one of its members
830
+ * is. `undefined`/`null` arms are absence, not a second kind of value.
831
+ */
832
+ const mustBeCallable = (type, depth = 0) => {
833
+ const shape = shapeOf(type);
834
+ if (shape === null || depth > 8)
835
+ return true;
836
+ if (shape.kind === 'signature' || shape.kind === 'class-constructor')
837
+ return true;
838
+ if (shape.kind === 'intersection')
839
+ return shape.members.some((member) => mustBeCallable(member, depth + 1));
840
+ if (shape.kind === 'union') {
841
+ const present = shape.members.filter((member) => {
842
+ const arm = shapeOf(member);
843
+ return !(arm?.kind === 'primitive' && (arm.primitive === 'undefined' || arm.primitive === 'null' || arm.primitive === 'void'));
844
+ });
845
+ return present.length > 0 && present.every((member) => mustBeCallable(member, depth + 1));
846
+ }
847
+ if (shape.kind === 'declared')
848
+ return shape.body !== null && shapeOf(shape.body)?.kind === 'signature';
849
+ return false;
850
+ };
851
+ /**
852
+ * `interface ErrorDescription extends Document { message?: string; ... }`:
853
+ * an open `{ [key: string]: any }` document that also names some OPTIONAL
854
+ * data keys is still exactly that open document. Every value it can hold,
855
+ * named or not, is one an `any` slot takes, and nothing it states can be
856
+ * missing, so a plain object, a class instance or an Error all satisfy it
857
+ * by identity -- which a sidecar record could not: mongodb's
858
+ * `MongoServerError(message: ErrorDescription)` keeps the object it was
859
+ * given (`this.errorResponse = message`). A read of a named key is the
860
+ * document's checked dynamic read into the key's own carrier. A required
861
+ * key, a symbol key, an accessor or a member that can only be a callable is
862
+ * layout the document cannot state, and keeps the record carrier. A member
863
+ * that MAY be a callable (mongodb's `$where?: string | ((this: T) =>
864
+ * boolean)`) does not: it is an `any` slot's value like any other key, and
865
+ * keeping the record for it made every `Filter<T>` literal a record the
866
+ * driver then had to view as the `Document` it forwards it as.
867
+ */
868
+ const isOpenDocumentShape = (shape) => {
869
+ if (shape.membersDropped || shape.members.length === 0)
870
+ return false;
871
+ const indexes = physicalIndexesOf(shape);
872
+ const [only] = indexes;
873
+ if (indexes.length !== 1 || only === undefined || only.key !== 'string')
874
+ return false;
875
+ const value = deriveStored(only.value);
876
+ if (value.kind !== 'dynamic' || value.reason !== 'declared-any-never-narrowed')
877
+ return false;
878
+ return shape.members.every((member) => member.optional && member.accessor === null && member.key.kind !== 'symbol' && !mustBeCallable(member.type));
879
+ };
880
+ const openDocumentOf = (shape, id) => ({
881
+ kind: 'dictionary',
882
+ key: 'string',
883
+ value: { kind: 'dynamic', reason: 'declared-any-never-narrowed' },
884
+ ownership: ownership.forShape(shape, id)
885
+ });
789
886
  const deriveObject = (id, shape) => {
887
+ if (isOpenDocumentShape(shape))
888
+ return openDocumentOf(shape, id);
790
889
  const dictionaryIndex = dictionaryIndexOf(shape);
791
890
  if (dictionaryIndex) {
792
891
  return {
@@ -796,7 +895,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
796
895
  ownership: ownership.forShape(shape, id)
797
896
  };
798
897
  }
799
- const fields = recordFieldsOf(shape);
898
+ const fields = recordFieldsOf(shape, id);
800
899
  const indexes = recordIndexesOf(shape);
801
900
  if (typeof indexes === 'string')
802
901
  return unresolved(indexes);
@@ -826,8 +925,9 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
826
925
  kind: 'record',
827
926
  shapeId: id,
828
927
  fields,
829
- accessors: recordAccessorsOf(shape, deriveStored),
830
- ownership: ownership.forShape(shape, id)
928
+ accessors: recordAccessorsOf(shape, deriveStored, (member) => isRecordFieldMember(shape, member)),
929
+ ownership: ownership.forShape(shape, id),
930
+ ...(shape.standIn ? { standIn: true } : {})
831
931
  };
832
932
  };
833
933
  /**
@@ -1225,6 +1325,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1225
1325
  version: stated.version,
1226
1326
  native: stated.native,
1227
1327
  bases: binding.basesOf(stated.native),
1328
+ viewsFrom: binding.viewsInto?.(stated.native) ?? new Map(),
1228
1329
  call: null,
1229
1330
  construct: null
1230
1331
  };
@@ -1621,7 +1722,8 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1621
1722
  // order decide the layout; a failed reduction still refuses by name.
1622
1723
  const reconciled = existing ? intersectPropertyRepresentations(existing.value, value) : value;
1623
1724
  if (existing && !reconciled) {
1624
- return unresolved(`no primitive for an intersection whose members disagree on the carrier of "${key}"`);
1725
+ return unresolved(`no primitive for an intersection whose members disagree on the carrier of "${key}" ` +
1726
+ `(${representationKey(existing.value)} vs ${representationKey(value)})`);
1625
1727
  }
1626
1728
  // Required in any arm is required overall: an intersection satisfies
1627
1729
  // every arm, so an optional field paired with a required one is present.
@@ -1673,10 +1775,11 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1673
1775
  if (shape.elements.length === 0) {
1674
1776
  return { kind: 'array-object', element: { kind: 'undefined' }, ownership: ownership.forShape(shape, id), extension: null };
1675
1777
  }
1676
- // A homogeneous closed tuple and T[] are views of the same JS array.
1677
- // Positional record storage would require a copying conversion at that
1678
- // boundary and break aliasing. Arity remains in the semantic tuple shape;
1679
- // it does not require a different physical carrier.
1778
+ // A homogeneous closed tuple and T[] are views of the same JS array BY
1779
+ // DEFAULT: positional record storage is a copying conversion at that
1780
+ // boundary, which breaks aliasing unless the proof below clears this id
1781
+ // of ever needing one. Arity remains in the semantic tuple shape; it does
1782
+ // not require a different physical carrier.
1680
1783
  const first = shape.elements[0];
1681
1784
  const fixedArity = first !== undefined && shape.elements.every((element) => !element.optional && !element.rest && !element.variadic);
1682
1785
  // Homogeneous by CARRIER, not by structural type id. `['a', 'b'] as const`
@@ -1698,7 +1801,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1698
1801
  const key = representationKey(carrier);
1699
1802
  return shape.elements.every((element) => representationKey(deriveStored(element.type)) === key) ? carrier : null;
1700
1803
  })();
1701
- if (uniformElement) {
1804
+ // The aliasing hazard above is a fact about how THIS id is used, not
1805
+ // about homogeneity itself -- `value-records.ts`'s `valueRecordTypesOf`
1806
+ // proves it the same way it proves an object record may be carried by
1807
+ // value: no write reaches an element, no identity test names the tuple,
1808
+ // and it never crosses a dynamic/boundary/protocol edge. A tuple this
1809
+ // proof clears falls through to the positional `record` below, the same
1810
+ // carrier a heterogeneous closed tuple already gets; one that is not
1811
+ // cleared (`names.forEach(...)`, still disqualified because `names` is
1812
+ // itself the invocation's receiver) keeps aliasing a real `T[]`.
1813
+ if (uniformElement && !valueRecords.forType(id)) {
1702
1814
  return { kind: 'array-object', element: uniformElement, ownership: ownership.forShape(shape, id), extension: null };
1703
1815
  }
1704
1816
  // A rest or variadic position has no fixed arity, so the tuple is not a
@@ -1746,7 +1858,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1746
1858
  // whose keys are its indices.
1747
1859
  fields.push({ key: String(position), value: deriveStored(element.type), required: !element.optional });
1748
1860
  }
1749
- return { kind: 'record', shapeId: id, fields, accessors: [], ownership: ownership.forShape(shape, id) };
1861
+ // `ownership.forShape` never answers `'owned'` for a tuple (it is scoped
1862
+ // to `shape.kind === 'object'`, `compiler.ts`) -- on purpose, so this
1863
+ // campaign's proof cannot silently flip every already-shipped
1864
+ // HETEROGENEOUS tuple-as-record from `shared-refcount`. `uniformElement`
1865
+ // is exactly the flag that says this id reached here only because the
1866
+ // proof above cleared it of the one hazard homogeneity used to force
1867
+ // `array-object` for; a heterogeneous tuple (`uniformElement === null`)
1868
+ // keeps its existing ownership untouched.
1869
+ const byValue = uniformElement !== null && valueRecords.forType(id);
1870
+ return { kind: 'record', shapeId: id, fields, accessors: [], ownership: byValue ? 'owned' : ownership.forShape(shape, id) };
1750
1871
  };
1751
1872
  /**
1752
1873
  * The carrier of a class's constructor object.
@@ -1849,6 +1970,148 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1849
1970
  return { declaration, representative: ordinal, family: [declaration] };
1850
1971
  };
1851
1972
  const physicalClassDeclarationOf = (shape) => physicalClassGroupOf(shape).declaration;
1973
+ /**
1974
+ * The physical class ONE copy of `root` is, by the same grouping
1975
+ * `physicalClassGroupOf` applies to a shape; the root while the class has
1976
+ * one layout, and the root too -- which then names no layout and fails
1977
+ * closed downstream -- for a copy no view recorded.
1978
+ */
1979
+ const physicalCopyDeclarationOf = (root, ordinal) => {
1980
+ const groups = classGroupsOf(root);
1981
+ if (groups === null || groups.size < 2)
1982
+ return root;
1983
+ const copy = classCopies.copiesOf(root).find((one) => one.ordinal === ordinal);
1984
+ const group = copy ? groups.get(copy.typeArguments.map((id) => classArgumentKeyOf(root, id)).join(',')) : undefined;
1985
+ return group === undefined ? root : `${root}@${group}`;
1986
+ };
1987
+ /** The instance shape of each of `root`'s physical copies, keyed by group ordinal -- the arms a family union cites. */
1988
+ const copyInstanceShapesOf = (root, groups) => {
1989
+ const found = new Map();
1990
+ for (const candidate of instanceShapesOf(root)) {
1991
+ const other = shapeOf(candidate);
1992
+ if (other?.kind !== 'class-instance' || other.body === null)
1993
+ continue;
1994
+ const group = groups.get(other.typeArguments.map((one) => classArgumentKeyOf(root, one)).join(','));
1995
+ if (group !== undefined && !found.has(group))
1996
+ found.set(group, candidate);
1997
+ }
1998
+ return found;
1999
+ };
2000
+ /**
2001
+ * A generic class spelled at its `any` filling, when its copies are
2002
+ * separate layouts, names ANY of them.
2003
+ *
2004
+ * mongodb's `AbstractCursor<TSchema>` stores `TSchema`, so each filling the
2005
+ * program constructs is its own struct -- the `any` one included
2006
+ * (`RunCommandCursor extends AbstractCursor`). The driver then hands every
2007
+ * copy's `this` to a slot typed bare `AbstractCursor`
2008
+ * (`new ReadableCursorStream(this)`, `Set<AbstractCursor>`,
2009
+ * `session.owner`). In JavaScript that is one object; natively it is one of
2010
+ * several structs, and neither a copy (loses identity and writes) nor one
2011
+ * shared struct (boxes a typed field) is sound. `any` is the unchecked
2012
+ * top, so the slot's honest carrier is the sum of the copies: identity is
2013
+ * kept, and each member access dispatches to the arm that is live.
2014
+ *
2015
+ * Only an `any` filling, never `unknown`: `unknown` is checked and
2016
+ * names no copy it could stand for. `null` for every other shape.
2017
+ */
2018
+ const anyCopyFamilyOf = (id, shape, self) => {
2019
+ if (shape.typeArguments.length === 0)
2020
+ return null;
2021
+ const filledWithAny = shape.typeArguments.map((argument) => {
2022
+ const filling = shapeOf(argument);
2023
+ return filling?.kind === 'primitive' && filling.primitive === 'any';
2024
+ });
2025
+ if (!filledWithAny.some(Boolean))
2026
+ return null;
2027
+ const groups = classGroupsOf(shape.declaration);
2028
+ if (groups === null || groups.size < 2)
2029
+ return null;
2030
+ // Every layout-relevant position `any`: a position folded away as
2031
+ // irrelevant carries the canonical placeholder, which is no statement.
2032
+ const argumentKeys = shape.typeArguments.map((one) => classArgumentKeyOf(shape.declaration, one));
2033
+ const own = groups.get(argumentKeys.join(','));
2034
+ const shapes = copyInstanceShapesOf(shape.declaration, groups);
2035
+ const ordinals = [...new Set(groups.values())].sort((left, right) => left - right);
2036
+ const arms = [];
2037
+ for (const ordinal of ordinals) {
2038
+ const member = ordinal === own ? id : shapes.get(ordinal);
2039
+ if (member === undefined)
2040
+ return null;
2041
+ const value = ordinal === own ? self : derive(member);
2042
+ if (value.kind !== 'class-ref')
2043
+ return null;
2044
+ arms.push({ tag: String(arms.length), value, semanticType: member, runtimeDiscriminator: { kind: 'carrier' } });
2045
+ }
2046
+ if (arms.length < 2)
2047
+ return null;
2048
+ const union = { kind: 'tagged-union', arms };
2049
+ copyFamilyUnions.add(union);
2050
+ return union;
2051
+ };
2052
+ /**
2053
+ * A class instance's carrier with the native object it extends, when it
2054
+ * extends one: the intrinsic `Error` layout (as an upcast; anything else
2055
+ * leaves the class without it rather than without a carrier -- the struct
2056
+ * link itself is `records.ts`'s decision), or a native collection or the
2057
+ * intrinsic promise, each the object's own storage and so has to resolve
2058
+ * for the class to have a carrier at all.
2059
+ */
2060
+ const withNativeBase = (shape, classRef) => {
2061
+ if (shape.nativeError) {
2062
+ const nativeBase = derive(shape.nativeError);
2063
+ if (nativeBase.kind !== 'native-record-ref' || nativeBase.native === null)
2064
+ return classRef;
2065
+ return {
2066
+ ...classRef,
2067
+ nativeBase,
2068
+ ...(heritage.overridesNativeError?.(shape.declaration) ? { nativeBaseOverridden: true } : {})
2069
+ };
2070
+ }
2071
+ if (shape.nativePromise) {
2072
+ const nativeBase = derive(shape.nativePromise);
2073
+ if (nativeBase.kind !== 'promise') {
2074
+ return unresolved(`class ${shape.declaration} extends the intrinsic Promise with no promise carrier: ${nativeBase.kind === 'unresolved' ? nativeBase.reason : nativeBase.kind}`);
2075
+ }
2076
+ return {
2077
+ ...classRef,
2078
+ nativeBase,
2079
+ ...(heritage.overridesNativeCollection?.(shape.declaration) ? { nativeBaseOverridden: true } : {})
2080
+ };
2081
+ }
2082
+ if (!shape.nativeCollection)
2083
+ return classRef;
2084
+ const nativeBase = derive(shape.nativeCollection);
2085
+ if (nativeBase.kind !== 'keyed-collection') {
2086
+ return unresolved(`class ${shape.declaration} extends a native collection with no carrier: ${nativeBase.kind === 'unresolved' ? nativeBase.reason : nativeBase.kind}`);
2087
+ }
2088
+ return {
2089
+ ...classRef,
2090
+ nativeBase,
2091
+ ...(heritage.overridesNativeCollection?.(shape.declaration) ? { nativeBaseOverridden: true } : {})
2092
+ };
2093
+ };
2094
+ const copyFamilyUnions = new WeakSet();
2095
+ const exactClassInstanceOf = (type) => {
2096
+ const derived = derive(type);
2097
+ if (derived.kind !== 'tagged-union' || !copyFamilyUnions.has(derived))
2098
+ return derived;
2099
+ return derived.arms.find((arm) => arm.semanticType === type)?.value ?? derived;
2100
+ };
2101
+ /**
2102
+ * The ancestors a class instance's carrier states: each generic ancestor
2103
+ * as the physical copy THIS copy derives from (`ClassHeritagePolicy.forCopy`),
2104
+ * which is what licenses the upcast of `Derived<{ a: string }>` into a
2105
+ * method `Base` declares once `Base`'s copies are separate structs.
2106
+ */
2107
+ const classInstanceAncestorsOf = (shape) => {
2108
+ const copies = classCopies.copiesOf(shape.declaration);
2109
+ const ordinal = physicalClassGroupOf(shape).representative ?? (copies.length === 1 ? (copies[0]?.ordinal ?? null) : null);
2110
+ const chain = heritage.forCopy?.(shape.declaration, ordinal) ?? null;
2111
+ if (chain === null)
2112
+ return heritage.forDeclaration(shape.declaration);
2113
+ return chain.map((ancestor) => ancestor.ordinal === null ? ancestor.declaration : physicalCopyDeclarationOf(ancestor.declaration, ancestor.ordinal));
2114
+ };
1852
2115
  const deriveClassConstructor = (shape) => {
1853
2116
  // An ambient `declare class`'s value IS a host handle, on the same
1854
2117
  // ground the `declared` case a few hundred lines below already stands on
@@ -1867,6 +2130,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1867
2130
  version: bound.version,
1868
2131
  native: bound.native,
1869
2132
  bases: binding.basesOf(bound.native),
2133
+ viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
1870
2134
  call: null,
1871
2135
  construct
1872
2136
  };
@@ -1892,9 +2156,12 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
1892
2156
  return unresolved(`class ${shape.declaration} has no interned construct signature`);
1893
2157
  if (signature.construct.length === 0)
1894
2158
  return unresolved(`class ${shape.declaration} has no interned construct signature`);
1895
- const abi = sharedAbiOf(signature.construct, 'construct');
1896
- if (typeof abi === 'string')
1897
- return unresolved(abi);
2159
+ const shared = sharedAbiOf(signature.construct, 'construct');
2160
+ if (typeof shared === 'string')
2161
+ return unresolved(shared);
2162
+ // A construction makes exactly this class, never "any copy" of it.
2163
+ const constructed = signature.construct[0]?.result;
2164
+ const abi = constructed === undefined ? shared : { ...shared, result: exactClassInstanceOf(constructed) };
1898
2165
  // A derived class the program stores into this constructor's slot is a
1899
2166
  // member too: naming only the base would let construction and static
1900
2167
  // reads resolve to the base while the cell holds the derived class.
@@ -2132,6 +2399,19 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2132
2399
  const derived = deriveStored(typeArgument);
2133
2400
  return derived.kind === 'dynamic' || derived.kind === 'unresolved' ? { kind: 'undefined' } : derived;
2134
2401
  };
2402
+ // `AsyncGenerator<T, TReturn, TNext>` shares the question -- which
2403
+ // of the three channels resolved to a native carrier -- but not the
2404
+ // carrier: its steps answer promises and its body suspends at every
2405
+ // `await`, which no synchronous cursor can do (model.ts's
2406
+ // `async-generator` arm).
2407
+ if (generator.isAsync?.(shape.declaration) === true) {
2408
+ return {
2409
+ kind: 'async-generator',
2410
+ element: deriveStored(yielded),
2411
+ completion: nativeOrUndefined(shape.typeArguments[1]),
2412
+ resume: nativeOrUndefined(shape.typeArguments[2])
2413
+ };
2414
+ }
2135
2415
  return {
2136
2416
  kind: 'iterator',
2137
2417
  element: deriveStored(yielded),
@@ -2141,8 +2421,26 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2141
2421
  };
2142
2422
  }
2143
2423
  const family = collections.forDeclaration(shape.declaration);
2144
- if (family)
2145
- return deriveKeyedCollection(family, shape, id, deriveStored, ownership);
2424
+ if (family) {
2425
+ // `type Tree = Map<string, Tree>` is ONE type, but it can reach the
2426
+ // table under a second id -- the collection census re-interns `new
2427
+ // Map()`'s `Map<string, Tree>` with no body -- whose argument is the
2428
+ // alias's own anchor. Same declaration, same arguments: it is that
2429
+ // anchor, and deriving it apart unrolls one level into a plain
2430
+ // `Map<string, Wrapper>` no conversion turns into the wrapper.
2431
+ const twin = shape.typeArguments.find((argument) => {
2432
+ if (argument === id)
2433
+ return false;
2434
+ const other = shapeOf(argument);
2435
+ return (other?.kind === 'declared' &&
2436
+ other.declaration === shape.declaration &&
2437
+ other.typeArguments.length === shape.typeArguments.length &&
2438
+ other.typeArguments.every((one, index) => one === shape.typeArguments[index]));
2439
+ });
2440
+ if (twin !== undefined)
2441
+ return derive(twin);
2442
+ return deriveKeyedCollection(family, shape, id, deriveStored, ownership, collections.isReadOnlyView?.(shape.declaration) === true);
2443
+ }
2146
2444
  // `Date`, checked here for the same two reasons `Promise<T>` and the
2147
2445
  // keyed collections are checked above it. Its ambient body survives
2148
2446
  // `declaredBodyOf`'s method stripping as an EMPTY object shape, so
@@ -2269,6 +2567,26 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2269
2567
  return sole !== undefined ? derive(sole) : deriveUnionShape({ kind: 'union', members: instances });
2270
2568
  }
2271
2569
  }
2570
+ // A program interface extending the intrinsic `Error` carries the
2571
+ // error itself, for the reason `Error & { code: string }` does in
2572
+ // `deriveIntersection`: nothing constructs an interface, so its values
2573
+ // are errors some `new Error(...)` built and the program re-typed --
2574
+ // node-compat's `new Error(m) as NodeArgumentError`, and
2575
+ // `(error as NodeArgumentError).code = ...` on an error it did not
2576
+ // build. A generated struct copying `Error`'s members could be
2577
+ // neither: it is a different object from the error written into it,
2578
+ // and it shares no base with `gea::runtime::Error`, so no pointer
2579
+ // upcast reaches an `Error` slot and a rebuild would drop identity,
2580
+ // `stack` and `cause`. The members the interface adds are properties
2581
+ // ON that error -- the native error's dynamic-property sidecar,
2582
+ // answered or refused by name at the access. After the implementors
2583
+ // above: a slot the program's own classes implement holds those
2584
+ // classes, not a bare error.
2585
+ if (shape.nativeError !== undefined) {
2586
+ const nativeError = derive(shape.nativeError);
2587
+ if (nativeError.kind === 'native-record-ref' && nativeError.native !== null)
2588
+ return nativeError;
2589
+ }
2272
2590
  // A bound declaration is a host handle, full stop: the protocol is its
2273
2591
  // complete definition, and neither an empty structural body (a JSX
2274
2592
  // `Element` interface with no members) nor a missing one changes that.
@@ -2321,6 +2639,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2321
2639
  version: bound.version,
2322
2640
  native: bound.native,
2323
2641
  bases: binding.basesOf(bound.native),
2642
+ viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
2324
2643
  call,
2325
2644
  construct
2326
2645
  };
@@ -2360,6 +2679,8 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2360
2679
  // identical layout question here, they just answer it at different
2361
2680
  // times.
2362
2681
  if (body?.kind === 'object') {
2682
+ if (isOpenDocumentShape(body))
2683
+ return openDocumentOf(shape, id);
2363
2684
  const dictionaryIndex = dictionaryIndexOf(body);
2364
2685
  if (dictionaryIndex) {
2365
2686
  return {
@@ -2444,6 +2765,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2444
2765
  version: bound.version,
2445
2766
  native: bound.native,
2446
2767
  bases: binding.basesOf(bound.native),
2768
+ viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
2447
2769
  call: null,
2448
2770
  construct: null
2449
2771
  };
@@ -2454,13 +2776,21 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2454
2776
  if (!shape.body) {
2455
2777
  return unresolved(`class ${shape.declaration} is declared without a body and has no installed host protocol`);
2456
2778
  }
2457
- return {
2779
+ const classRef = {
2458
2780
  kind: 'class-ref',
2459
2781
  declaration: physicalClassDeclarationOf(shape),
2460
2782
  shapeId: shape.body,
2461
2783
  ownership: ownership.forShape(shape, id),
2462
- ancestors: heritage.forDeclaration(shape.declaration)
2784
+ ancestors: classInstanceAncestorsOf(shape)
2463
2785
  };
2786
+ const own = withNativeBase(shape, classRef);
2787
+ if (own.kind !== 'class-ref')
2788
+ return own;
2789
+ // The copy's own arm is its complete carrier, native base included:
2790
+ // mongodb's `class CaseInsensitiveMap<Value = any> extends Map<string,
2791
+ // Value>` read at `any` is the family, and the `any` copy's own
2792
+ // constructor still initializes the Map it IS.
2793
+ return anyCopyFamilyOf(id, shape, own) ?? own;
2464
2794
  }
2465
2795
  case 'class-constructor':
2466
2796
  return deriveClassConstructor(shape);
@@ -2542,5 +2872,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
2542
2872
  return null;
2543
2873
  };
2544
2874
  const isDateCarrier = (representation) => representation.kind === 'native-record-ref' && representation.native !== null && dateNatives.has(representation.native);
2545
- return { derive, layoutOf, abiOf, deriveStored, isNeverType, isTupleShape, nativeCallableConventions, isDateCarrier, dynamicFallback };
2875
+ return {
2876
+ derive,
2877
+ exactClassInstanceOf,
2878
+ layoutOf,
2879
+ abiOf,
2880
+ deriveStored,
2881
+ isNeverType,
2882
+ isTupleShape,
2883
+ nativeCallableConventions,
2884
+ isDateCarrier,
2885
+ dynamicFallback
2886
+ };
2546
2887
  };
@@ -86,6 +86,10 @@ const shallowSignature = (representation) => {
86
86
  return representation.kind;
87
87
  case 'scalar':
88
88
  return `scalar(${representation.domain})`;
89
+ case 'constructor-identity':
90
+ return `constructor-identity(${representation.declaration})`;
91
+ case 'error-constructor':
92
+ return representation.kind;
89
93
  case 'class-ref':
90
94
  return `class-ref(${representation.declaration},${representation.shapeId},${representation.ownership})`;
91
95
  case 'native-handle':
@@ -120,6 +124,8 @@ const shallowSignature = (representation) => {
120
124
  return 'native-sequence';
121
125
  case 'iterator':
122
126
  return 'iterator';
127
+ case 'async-generator':
128
+ return 'async-generator';
123
129
  case 'promise':
124
130
  return 'promise';
125
131
  case 'keyed-collection':
@@ -162,6 +168,8 @@ const abiSignature = (abi) => `${abi.parameters.map((parameter) => parameter.own
162
168
  const children = (representation) => {
163
169
  switch (representation.kind) {
164
170
  case 'callable-identity':
171
+ case 'constructor-identity':
172
+ case 'error-constructor':
165
173
  case 'unresolved':
166
174
  case 'void':
167
175
  case 'string':
@@ -199,6 +207,12 @@ const children = (representation) => {
199
207
  case 'native-sequence':
200
208
  case 'iterator':
201
209
  return [['element', representation.element]];
210
+ case 'async-generator':
211
+ return [
212
+ ['element', representation.element],
213
+ ['completion', representation.completion],
214
+ ['resume', representation.resume]
215
+ ];
202
216
  case 'promise':
203
217
  return [['value', representation.value]];
204
218
  case 'keyed-collection':
@@ -63,6 +63,7 @@ export const forEachEmbeddedRepresentation = (root, visit) => {
63
63
  walk(value.element);
64
64
  return;
65
65
  case 'iterator':
66
+ case 'async-generator':
66
67
  walk(value.element);
67
68
  walk(value.resume);
68
69
  walk(value.completion);
@@ -30,3 +30,18 @@ import type { CallableAbi } from './model.js';
30
30
  * short and free of carrier keys so equal walls group together.
31
31
  */
32
32
  export declare const widestSubsumingAbi: (abis: readonly CallableAbi[]) => CallableAbi | string;
33
+ /**
34
+ * A PROGRAM overload set whose members differ by a trailing callback and a
35
+ * `void` result -- Node's callback-or-promise idiom, mongodb's
36
+ * `KerberosClient.step(challenge): Promise<string>` beside
37
+ * `step(challenge, callback): void` -- as one frame: the widest arity, each
38
+ * position joined exactly as `widestSubsumingAbi` joins it, and the valued
39
+ * overloads' one result made optional, since the callback form answers
40
+ * `undefined`.
41
+ *
42
+ * Only when every valued overload agrees on the result: two different
43
+ * values would need a union this layer cannot intern. The frame is marked
44
+ * `overloadJoined`, which is what licenses a call naming one overload to read
45
+ * it as that overload's convention (the result projected, checked).
46
+ */
47
+ export declare const callbackOverloadJoinedAbi: (abis: readonly CallableAbi[]) => CallableAbi | null;