@geastack/compiler 1.0.26 → 1.0.29

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 (946) hide show
  1. package/dist/cli-coverage.js +2 -2
  2. package/dist/cli-emit.js +36 -12
  3. package/dist/compiler.d.ts +11 -9
  4. package/dist/compiler.js +264 -43
  5. package/dist/conversion/algebra.d.ts +84 -4
  6. package/dist/conversion/algebra.js +39 -0
  7. package/dist/conversion/array-view.d.ts +63 -0
  8. package/dist/conversion/array-view.js +186 -0
  9. package/dist/conversion/build.d.ts +8 -8
  10. package/dist/conversion/build.js +56 -50
  11. package/dist/conversion/certified-iterator-object-view.d.ts +13 -0
  12. package/dist/conversion/certified-iterator-object-view.js +31 -0
  13. package/dist/conversion/certified-iterator-protocols.d.ts +23 -0
  14. package/dist/conversion/certified-iterator-protocols.js +50 -0
  15. package/dist/conversion/checked-native-field-read.d.ts +7 -0
  16. package/dist/conversion/checked-native-field-read.js +36 -0
  17. package/dist/conversion/constructor-identity-family.d.ts +6 -6
  18. package/dist/conversion/constructor-identity-family.js +3 -3
  19. package/dist/conversion/derive.js +11 -8
  20. package/dist/conversion/dictionary-view.d.ts +114 -0
  21. package/dist/conversion/dictionary-view.js +275 -0
  22. package/dist/conversion/document-record-view.d.ts +89 -0
  23. package/dist/conversion/document-record-view.js +269 -0
  24. package/dist/conversion/dynamic-result-carriers.d.ts +6 -0
  25. package/dist/conversion/dynamic-result-carriers.js +43 -0
  26. package/dist/conversion/dynamic-wrapper.d.ts +52 -0
  27. package/dist/conversion/dynamic-wrapper.js +82 -0
  28. package/dist/conversion/impossible-field-read.d.ts +9 -0
  29. package/dist/conversion/impossible-field-read.js +28 -0
  30. package/dist/conversion/iterable-object-view.d.ts +1 -1
  31. package/dist/conversion/iterator-object-view.d.ts +2 -2
  32. package/dist/conversion/native-absence.d.ts +4 -0
  33. package/dist/conversion/native-absence.js +4 -0
  34. package/dist/conversion/native-buffer-method.d.ts +16 -0
  35. package/dist/conversion/native-buffer-method.js +37 -0
  36. package/dist/conversion/native-callable-adapter.d.ts +13 -0
  37. package/dist/conversion/native-callable-adapter.js +73 -0
  38. package/dist/conversion/native-descriptor-snapshot.d.ts +30 -0
  39. package/dist/conversion/native-descriptor-snapshot.js +75 -0
  40. package/dist/conversion/native-entry-writer.d.ts +21 -0
  41. package/dist/conversion/native-entry-writer.js +32 -0
  42. package/dist/conversion/native-field-view.d.ts +42 -0
  43. package/dist/conversion/native-field-view.js +145 -0
  44. package/dist/conversion/native-logical-receiver.d.ts +11 -0
  45. package/dist/conversion/native-logical-receiver.js +19 -0
  46. package/dist/conversion/native-method.d.ts +43 -0
  47. package/dist/conversion/native-method.js +56 -0
  48. package/dist/conversion/native-object-sample.d.ts +30 -0
  49. package/dist/conversion/native-object-sample.js +37 -0
  50. package/dist/conversion/native-payload-transport.d.ts +1 -1
  51. package/dist/conversion/native-payload-transport.js +1 -1
  52. package/dist/conversion/native-record-products.d.ts +15 -0
  53. package/dist/conversion/native-record-products.js +73 -0
  54. package/dist/conversion/native-selection.d.ts +18 -1
  55. package/dist/conversion/native-selection.js +117 -4
  56. package/dist/conversion/native-sum.d.ts +27 -0
  57. package/dist/conversion/native-sum.js +74 -9
  58. package/dist/conversion/native-view-origins.d.ts +12 -0
  59. package/dist/conversion/native-view-origins.js +97 -0
  60. package/dist/conversion/nodes.d.ts +75 -7
  61. package/dist/conversion/nodes.js +694 -19
  62. package/dist/conversion/number-storage.d.ts +8 -0
  63. package/dist/conversion/number-storage.js +8 -0
  64. package/dist/conversion/operand-view.js +10 -1
  65. package/dist/conversion/promise-adoption.d.ts +15 -0
  66. package/dist/conversion/promise-adoption.js +29 -0
  67. package/dist/conversion/protocol-iterator.d.ts +3 -3
  68. package/dist/conversion/recipe-closure.d.ts +14 -0
  69. package/dist/conversion/recipe-closure.js +135 -0
  70. package/dist/conversion/record-view.d.ts +51 -26
  71. package/dist/conversion/record-view.js +160 -97
  72. package/dist/conversion/registry.d.ts +18 -2
  73. package/dist/conversion/sibling-class.d.ts +4 -0
  74. package/dist/conversion/sibling-class.js +7 -0
  75. package/dist/conversion/structural-plan.d.ts +87 -0
  76. package/dist/conversion/structural-plan.js +480 -0
  77. package/dist/ir/absent-class-arm.d.ts +1 -1
  78. package/dist/ir/absent-class-arm.js +1 -1
  79. package/dist/ir/async-result-conventions.d.ts +15 -0
  80. package/dist/ir/async-result-conventions.js +140 -0
  81. package/dist/ir/borrowed-call-arguments.d.ts +3 -3
  82. package/dist/ir/borrowed-call-arguments.js +9 -9
  83. package/dist/ir/build.d.ts +20 -29
  84. package/dist/ir/build.js +116 -19
  85. package/dist/ir/call-dispatch.js +153 -40
  86. package/dist/ir/call-entry.d.ts +14 -3
  87. package/dist/ir/call-entry.js +63 -5
  88. package/dist/ir/callable-class-flow.d.ts +48 -3
  89. package/dist/ir/callable-class-flow.js +1509 -81
  90. package/dist/ir/callable-flow-candidates.d.ts +25 -0
  91. package/dist/ir/callable-flow-candidates.js +135 -0
  92. package/dist/ir/callable-identity-demand.d.ts +2 -2
  93. package/dist/ir/callable-identity-demand.js +33 -1
  94. package/dist/ir/callable-member-candidates.d.ts +1 -1
  95. package/dist/ir/callable-member-candidates.js +2 -2
  96. package/dist/ir/callable-records.js +1 -0
  97. package/dist/ir/callable-site-escape.js +3 -4
  98. package/dist/ir/captures.js +1 -1
  99. package/dist/ir/certificate.d.ts +1 -0
  100. package/dist/ir/certificate.js +2 -1
  101. package/dist/ir/certify/carrier-keys.d.ts +2 -2
  102. package/dist/ir/certify/carrier-keys.js +4 -4
  103. package/dist/ir/certify/has-property-key.d.ts +3 -3
  104. package/dist/ir/certify/has-property-key.js +3 -3
  105. package/dist/ir/certify/parallel-region.d.ts +26 -0
  106. package/dist/ir/certify/parallel-region.js +1331 -0
  107. package/dist/ir/certify/property-access-keys.d.ts +11 -11
  108. package/dist/ir/certify/property-access-keys.js +11 -11
  109. package/dist/ir/certify/property-access.js +7 -9
  110. package/dist/ir/certify.d.ts +66 -3
  111. package/dist/ir/certify.js +1197 -36
  112. package/dist/ir/class-allocation-domain.d.ts +9 -0
  113. package/dist/ir/class-allocation-domain.js +111 -0
  114. package/dist/ir/class-evaluation.d.ts +2 -3
  115. package/dist/ir/class-evaluation.js +2 -3
  116. package/dist/ir/class-static-fields.d.ts +12 -1
  117. package/dist/ir/class-static-fields.js +25 -0
  118. package/dist/ir/closed-normal-results.d.ts +18 -0
  119. package/dist/ir/closed-normal-results.js +208 -0
  120. package/dist/ir/construct-entry.js +1 -0
  121. package/dist/ir/construction-only-fields.d.ts +20 -1
  122. package/dist/ir/construction-only-fields.js +95 -9
  123. package/dist/ir/convert-carriers.d.ts +7 -0
  124. package/dist/ir/convert-carriers.js +12 -0
  125. package/dist/ir/coroutine-bodies.d.ts +74 -0
  126. package/dist/ir/coroutine-bodies.js +93 -0
  127. package/dist/ir/dead-logical-merge.d.ts +7 -0
  128. package/dist/ir/dead-logical-merge.js +84 -0
  129. package/dist/ir/dead-values.d.ts +7 -5
  130. package/dist/ir/dead-values.js +34 -5
  131. package/dist/ir/deferral.d.ts +3 -1
  132. package/dist/ir/deferral.js +19 -6
  133. package/dist/ir/dense-loops.d.ts +96 -7
  134. package/dist/ir/dense-loops.js +333 -17
  135. package/dist/ir/descriptor-own-protocol.d.ts +12 -0
  136. package/dist/ir/descriptor-own-protocol.js +35 -0
  137. package/dist/ir/dynamic-constructor-conversions.d.ts +17 -0
  138. package/dist/ir/dynamic-constructor-conversions.js +52 -0
  139. package/dist/ir/emission-representations.js +44 -2
  140. package/dist/ir/facts.d.ts +14 -2
  141. package/dist/ir/facts.js +23 -9
  142. package/dist/ir/fixed-data-definition-attributes.d.ts +10 -0
  143. package/dist/ir/fixed-data-definition-attributes.js +200 -0
  144. package/dist/ir/fixed-data-definition.d.ts +23 -5
  145. package/dist/ir/fixed-data-definition.js +80 -2
  146. package/dist/ir/function-reflection-demand.d.ts +11 -0
  147. package/dist/ir/function-reflection-demand.js +71 -0
  148. package/dist/ir/generic-call-entry.d.ts +18 -0
  149. package/dist/ir/generic-call-entry.js +94 -0
  150. package/dist/ir/hoist.d.ts +16 -3
  151. package/dist/ir/hoist.js +121 -8
  152. package/dist/ir/host-method-aliases.d.ts +15 -0
  153. package/dist/ir/host-method-aliases.js +61 -0
  154. package/dist/ir/host-namespace-reads.d.ts +24 -0
  155. package/dist/ir/host-namespace-reads.js +151 -0
  156. package/dist/ir/host-promise-conversions.d.ts +5 -0
  157. package/dist/ir/host-promise-conversions.js +61 -0
  158. package/dist/ir/host-template-conversions.d.ts +34 -0
  159. package/dist/ir/host-template-conversions.js +357 -0
  160. package/dist/ir/instance-reparenting.d.ts +3 -4
  161. package/dist/ir/instantiation.d.ts +1 -1
  162. package/dist/ir/instantiation.js +1 -1
  163. package/dist/ir/integer-storage.d.ts +19 -9
  164. package/dist/ir/integer-storage.js +158 -44
  165. package/dist/ir/integers.d.ts +34 -7
  166. package/dist/ir/integers.js +240 -7
  167. package/dist/ir/integrity-restrictions.d.ts +4 -4
  168. package/dist/ir/integrity-restrictions.js +7 -4
  169. package/dist/ir/internal-operation-conversions.d.ts +7 -0
  170. package/dist/ir/internal-operation-conversions.js +195 -0
  171. package/dist/ir/intrinsic-call-facts.d.ts +40 -0
  172. package/dist/ir/intrinsic-call-facts.js +176 -0
  173. package/dist/ir/key-order-observation.d.ts +1 -1
  174. package/dist/ir/lazy-splits.d.ts +20 -0
  175. package/dist/ir/lazy-splits.js +58 -0
  176. package/dist/ir/literal-set-membership.d.ts +2 -2
  177. package/dist/ir/literal-set-membership.js +2 -2
  178. package/dist/ir/logical-receivers.d.ts +15 -0
  179. package/dist/ir/logical-receivers.js +98 -0
  180. package/dist/ir/lower-allocation.js +16 -13
  181. package/dist/ir/lower-destructuring.js +7 -6
  182. package/dist/ir/lower-graph.d.ts +4 -4
  183. package/dist/ir/lower-graph.js +2 -2
  184. package/dist/ir/lower-invocation.d.ts +2 -2
  185. package/dist/ir/lower-invocation.js +99 -57
  186. package/dist/ir/lower-narrow.js +35 -13
  187. package/dist/ir/lower-operands.d.ts +40 -11
  188. package/dist/ir/lower-operands.js +206 -87
  189. package/dist/ir/lower-property.js +31 -8
  190. package/dist/ir/lower.js +9 -9
  191. package/dist/ir/merge-conversions.d.ts +18 -0
  192. package/dist/ir/merge-conversions.js +106 -0
  193. package/dist/ir/model.d.ts +138 -28
  194. package/dist/ir/native-accessor-definition.d.ts +104 -0
  195. package/dist/ir/native-accessor-definition.js +735 -0
  196. package/dist/ir/native-array-descriptor-snapshot.d.ts +45 -0
  197. package/dist/ir/native-array-descriptor-snapshot.js +380 -0
  198. package/dist/ir/native-array-insertion.d.ts +16 -0
  199. package/dist/ir/native-array-insertion.js +42 -0
  200. package/dist/ir/native-callable-argument.d.ts +38 -0
  201. package/dist/ir/native-callable-argument.js +128 -0
  202. package/dist/ir/native-callable-data-flow.d.ts +9 -0
  203. package/dist/ir/native-callable-data-flow.js +59 -0
  204. package/dist/ir/native-callable-data-owner.d.ts +45 -0
  205. package/dist/ir/native-callable-data-owner.js +755 -0
  206. package/dist/ir/native-callable-data-reads.d.ts +45 -0
  207. package/dist/ir/native-callable-data-reads.js +282 -0
  208. package/dist/ir/native-callable-data-slots.d.ts +78 -0
  209. package/dist/ir/native-callable-data-slots.js +403 -0
  210. package/dist/ir/native-callable-data-write.d.ts +58 -0
  211. package/dist/ir/native-callable-data-write.js +254 -0
  212. package/dist/ir/native-callable-integrity.d.ts +23 -0
  213. package/dist/ir/native-callable-integrity.js +77 -0
  214. package/dist/ir/native-callable-own-property.d.ts +42 -0
  215. package/dist/ir/native-callable-own-property.js +505 -0
  216. package/dist/ir/native-callable-prototype.d.ts +38 -0
  217. package/dist/ir/native-callable-prototype.js +307 -0
  218. package/dist/ir/native-callable-readonly-set.d.ts +25 -0
  219. package/dist/ir/native-callable-readonly-set.js +238 -0
  220. package/dist/ir/native-class-accessor.d.ts +3 -3
  221. package/dist/ir/native-class-accessor.js +3 -3
  222. package/dist/ir/native-class-construction.js +2 -2
  223. package/dist/ir/native-constructor-reads.d.ts +15 -0
  224. package/dist/ir/native-constructor-reads.js +156 -0
  225. package/dist/ir/native-constructor-static.d.ts +18 -0
  226. package/dist/ir/native-constructor-static.js +61 -0
  227. package/dist/ir/native-data-definition.d.ts +43 -0
  228. package/dist/ir/native-data-definition.js +222 -0
  229. package/dist/ir/native-document-array-entries.d.ts +15 -0
  230. package/dist/ir/native-document-array-entries.js +37 -0
  231. package/dist/ir/native-document-entries.d.ts +21 -0
  232. package/dist/ir/native-document-entries.js +74 -0
  233. package/dist/ir/native-entry-field-views.d.ts +18 -0
  234. package/dist/ir/native-entry-field-views.js +62 -0
  235. package/dist/ir/native-field-view-domains.d.ts +43 -0
  236. package/dist/ir/native-field-view-domains.js +300 -0
  237. package/dist/ir/native-field-view-facts.d.ts +97 -0
  238. package/dist/ir/native-field-view-facts.js +341 -0
  239. package/dist/ir/native-fixed-layout.js +1 -1
  240. package/dist/ir/native-host-construction.d.ts +4 -6
  241. package/dist/ir/native-host-construction.js +4 -6
  242. package/dist/ir/native-host-method-reads.d.ts +13 -0
  243. package/dist/ir/native-host-method-reads.js +53 -0
  244. package/dist/ir/native-iterator-field-views.d.ts +15 -0
  245. package/dist/ir/native-iterator-field-views.js +39 -0
  246. package/dist/ir/native-iterator-receivers.d.ts +8 -0
  247. package/dist/ir/native-iterator-receivers.js +59 -0
  248. package/dist/ir/native-logical-receiver-body.d.ts +8 -0
  249. package/dist/ir/native-logical-receiver-body.js +23 -0
  250. package/dist/ir/native-method-frames.d.ts +18 -0
  251. package/dist/ir/native-method-frames.js +127 -0
  252. package/dist/ir/native-method-read-source.d.ts +16 -0
  253. package/dist/ir/native-method-read-source.js +61 -0
  254. package/dist/ir/native-object-data-slots.d.ts +60 -0
  255. package/dist/ir/native-object-data-slots.js +493 -0
  256. package/dist/ir/native-object-sample.d.ts +32 -0
  257. package/dist/ir/native-object-sample.js +113 -0
  258. package/dist/ir/native-own-assignment.d.ts +123 -0
  259. package/dist/ir/native-own-assignment.js +529 -0
  260. package/dist/ir/native-property-coercibility.d.ts +3 -0
  261. package/dist/ir/native-property-coercibility.js +10 -0
  262. package/dist/ir/native-property-key-texts.d.ts +11 -0
  263. package/dist/ir/native-property-key-texts.js +41 -0
  264. package/dist/ir/native-property-presence-effects.d.ts +11 -0
  265. package/dist/ir/native-property-presence-effects.js +19 -0
  266. package/dist/ir/native-property-presence.d.ts +27 -0
  267. package/dist/ir/native-property-presence.js +275 -0
  268. package/dist/ir/native-prototype-calls.d.ts +19 -0
  269. package/dist/ir/native-prototype-calls.js +53 -0
  270. package/dist/ir/native-prototype-conversions.d.ts +5 -0
  271. package/dist/ir/native-prototype-conversions.js +46 -0
  272. package/dist/ir/native-prototype-presence-demand.d.ts +9 -0
  273. package/dist/ir/native-prototype-presence-demand.js +58 -0
  274. package/dist/ir/native-record-index.d.ts +1 -1
  275. package/dist/ir/native-union-method-targets.d.ts +8 -0
  276. package/dist/ir/native-union-method-targets.js +69 -0
  277. package/dist/ir/no-normal-call-completion.d.ts +15 -0
  278. package/dist/ir/no-normal-call-completion.js +184 -0
  279. package/dist/ir/non-normal-receiver.d.ts +39 -0
  280. package/dist/ir/non-normal-receiver.js +253 -0
  281. package/dist/ir/operation-conversions.d.ts +29 -0
  282. package/dist/ir/operation-conversions.js +484 -0
  283. package/dist/ir/operation-index.d.ts +1 -1
  284. package/dist/ir/presence-proof.d.ts +1 -1
  285. package/dist/ir/presence-proof.js +1 -0
  286. package/dist/ir/program-conversions.d.ts +48 -0
  287. package/dist/ir/program-conversions.js +221 -0
  288. package/dist/ir/program-facts.d.ts +4 -1
  289. package/dist/ir/program-facts.js +9 -7
  290. package/dist/ir/promise-reaction-conversions.d.ts +6 -0
  291. package/dist/ir/promise-reaction-conversions.js +92 -0
  292. package/dist/ir/property-read-conversions.d.ts +10 -0
  293. package/dist/ir/property-read-conversions.js +124 -0
  294. package/dist/ir/proven-branches.d.ts +2 -1
  295. package/dist/ir/proven-branches.js +97 -10
  296. package/dist/ir/publish-conversion-recipes.d.ts +27 -0
  297. package/dist/ir/publish-conversion-recipes.js +246 -0
  298. package/dist/ir/publish-native-field-view-facts.d.ts +17 -0
  299. package/dist/ir/publish-native-field-view-facts.js +119 -0
  300. package/dist/ir/queries.js +42 -4
  301. package/dist/ir/read-only-dictionary.d.ts +38 -0
  302. package/dist/ir/read-only-dictionary.js +281 -0
  303. package/dist/ir/reflection-demand.d.ts +2 -0
  304. package/dist/ir/reflection-demand.js +600 -44
  305. package/dist/ir/shake.d.ts +3 -0
  306. package/dist/ir/shake.js +24 -14
  307. package/dist/ir/shared-empty-records.js +1 -1
  308. package/dist/ir/short-circuit-threading.d.ts +23 -0
  309. package/dist/ir/short-circuit-threading.js +133 -0
  310. package/dist/ir/spread-conversions.d.ts +27 -0
  311. package/dist/ir/spread-conversions.js +134 -0
  312. package/dist/ir/spread-copy-elision.d.ts +2 -2
  313. package/dist/ir/spread-copy-elision.js +7 -4
  314. package/dist/ir/string-layout-reuse.d.ts +9 -8
  315. package/dist/ir/string-layout-reuse.js +8 -16
  316. package/dist/ir/string-length-reuse.d.ts +20 -4
  317. package/dist/ir/string-length-reuse.js +57 -13
  318. package/dist/ir/transfer.d.ts +5 -5
  319. package/dist/ir/transfer.js +53 -31
  320. package/dist/ir/typed-property-access.d.ts +2 -0
  321. package/dist/ir/typed-property-access.js +21 -8
  322. package/dist/ir/virtual-call-frames.d.ts +7 -0
  323. package/dist/ir/virtual-call-frames.js +8 -0
  324. package/dist/native-signatures.d.ts +45 -0
  325. package/dist/native-signatures.js +368 -0
  326. package/dist/plugins/gea/host.d.ts +6 -1
  327. package/dist/plugins/gea/host.js +30 -1
  328. package/dist/plugins/gea/lower.js +9 -3
  329. package/dist/plugins/gea/members.js +1 -1
  330. package/dist/plugins/gea/plugin.js +2 -1
  331. package/dist/plugins/gea/prelude.d.ts +1 -1
  332. package/dist/plugins/gea/prelude.js +1 -1
  333. package/dist/plugins/gea/reactive-slots.js +6 -6
  334. package/dist/plugins/gea/render-bridge.js +5 -6
  335. package/dist/plugins/gea/user-agent-styles.js +1 -1
  336. package/dist/plugins/installed.d.ts +2 -2
  337. package/dist/plugins/installed.js +2 -2
  338. package/dist/plugins/load.js +1 -1
  339. package/dist/plugins/model.d.ts +21 -36
  340. package/dist/plugins/webgl/host.d.ts +23 -23
  341. package/dist/plugins/webgl/host.js +25 -26
  342. package/dist/plugins/webgl/plugin.d.ts +16 -19
  343. package/dist/plugins/webgl/plugin.js +16 -23
  344. package/dist/project-preparation.js +12 -14
  345. package/dist/projection/abi.js +13 -10
  346. package/dist/projection/bindings.d.ts +8 -0
  347. package/dist/projection/bindings.js +36 -5
  348. package/dist/projection/callee.d.ts +17 -15
  349. package/dist/projection/callee.js +108 -81
  350. package/dist/projection/class-property-presence.d.ts +1 -1
  351. package/dist/projection/class-property-presence.js +1 -1
  352. package/dist/projection/classes.d.ts +2 -0
  353. package/dist/projection/classes.js +4 -1
  354. package/dist/projection/dispatch.d.ts +19 -3
  355. package/dist/projection/dispatch.js +39 -16
  356. package/dist/projection/fields.d.ts +14 -2
  357. package/dist/projection/fields.js +100 -38
  358. package/dist/projection/function-source.d.ts +5 -0
  359. package/dist/projection/function-source.js +15 -0
  360. package/dist/projection/immediate-callees.d.ts +12 -0
  361. package/dist/projection/immediate-callees.js +36 -0
  362. package/dist/projection/index-protocols.d.ts +12 -0
  363. package/dist/projection/index-protocols.js +39 -0
  364. package/dist/projection/instance-test.d.ts +8 -0
  365. package/dist/projection/instance-test.js +3 -1
  366. package/dist/projection/method-values.d.ts +7 -0
  367. package/dist/projection/method-values.js +29 -0
  368. package/dist/projection/native-accessor-access.d.ts +26 -0
  369. package/dist/projection/native-accessor-access.js +18 -0
  370. package/dist/projection/native-callable-data.d.ts +24 -0
  371. package/dist/projection/native-callable-data.js +101 -0
  372. package/dist/projection/native-expando.d.ts +3 -0
  373. package/dist/projection/native-expando.js +13 -0
  374. package/dist/projection/native-object-data.d.ts +47 -0
  375. package/dist/projection/native-object-data.js +203 -0
  376. package/dist/projection/native-prototype-methods.d.ts +22 -0
  377. package/dist/projection/native-prototype-methods.js +161 -0
  378. package/dist/projection/regexp-fields.d.ts +35 -0
  379. package/dist/projection/regexp-fields.js +80 -0
  380. package/dist/projection/slots.d.ts +5 -1
  381. package/dist/projection/slots.js +89 -10
  382. package/dist/representation/derive.d.ts +5 -7
  383. package/dist/representation/derive.js +78 -78
  384. package/dist/representation/difference.js +1 -1
  385. package/dist/representation/host-abi.d.ts +2 -2
  386. package/dist/representation/host-abi.js +4 -5
  387. package/dist/representation/host-templates.d.ts +6 -2
  388. package/dist/representation/host-templates.js +8 -2
  389. package/dist/representation/intersection.d.ts +3 -3
  390. package/dist/representation/intersection.js +3 -3
  391. package/dist/representation/merge.js +1 -1
  392. package/dist/representation/model.d.ts +27 -22
  393. package/dist/representation/model.js +35 -22
  394. package/dist/representation/native-callable-data-storage.d.ts +85 -0
  395. package/dist/representation/native-callable-data-storage.js +398 -0
  396. package/dist/representation/native-data-properties.d.ts +14 -0
  397. package/dist/representation/native-data-properties.js +52 -0
  398. package/dist/representation/native-logical-receiver.d.ts +36 -0
  399. package/dist/representation/native-logical-receiver.js +92 -0
  400. package/dist/representation/object-shape.d.ts +1 -1
  401. package/dist/representation/object-shape.js +1 -1
  402. package/dist/representation/optional.js +2 -2
  403. package/dist/representation/physical-carrier.d.ts +25 -0
  404. package/dist/representation/physical-carrier.js +153 -0
  405. package/dist/representation/policies.d.ts +16 -10
  406. package/dist/representation/policies.js +5 -1
  407. package/dist/representation/primitives.js +3 -0
  408. package/dist/representation/promise-resolution.d.ts +19 -0
  409. package/dist/representation/promise-resolution.js +50 -0
  410. package/dist/representation/prototype-domains.d.ts +43 -0
  411. package/dist/representation/prototype-domains.js +226 -0
  412. package/dist/representation/proxy-carriers.d.ts +3 -3
  413. package/dist/representation/proxy-carriers.js +2 -3
  414. package/dist/representation/publish.d.ts +4 -0
  415. package/dist/representation/publish.js +73 -42
  416. package/dist/representation/record-fields.d.ts +2 -2
  417. package/dist/representation/record-fields.js +2 -2
  418. package/dist/representation/static-field-cells.d.ts +1 -1
  419. package/dist/representation/structural-method-abi.d.ts +6 -0
  420. package/dist/representation/structural-method-abi.js +13 -0
  421. package/dist/representation/unassigned-binding-cells.d.ts +3 -3
  422. package/dist/representation/union.js +19 -4
  423. package/dist/representation/unwritten-record-members.d.ts +6 -6
  424. package/dist/representation/unwritten-record-members.js +1 -1
  425. package/dist/representation/value-records.js +77 -5
  426. package/dist/representation/verify.js +1 -1
  427. package/dist/representation/well-known-symbols.d.ts +3 -0
  428. package/dist/representation/well-known-symbols.js +11 -0
  429. package/dist/semantics/alias-this-field-declaration-transform.js +3 -3
  430. package/dist/semantics/ambient-type-realization-transform.d.ts +19 -20
  431. package/dist/semantics/ambient-type-realization-transform.js +20 -12
  432. package/dist/semantics/ambient.d.ts +13 -13
  433. package/dist/semantics/ambient.js +12 -12
  434. package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +5 -0
  435. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +110 -52
  436. package/dist/semantics/borrowed-method-receiver-copy-source-transform.d.ts +4 -4
  437. package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +4 -4
  438. package/dist/semantics/call-invalidated-narrowing.js +2 -2
  439. package/dist/semantics/callable-origins.d.ts +49 -1
  440. package/dist/semantics/callable-origins.js +148 -32
  441. package/dist/semantics/callable-own-data-slots.d.ts +122 -0
  442. package/dist/semantics/callable-own-data-slots.js +421 -0
  443. package/dist/semantics/class-alias.d.ts +4 -4
  444. package/dist/semantics/class-alias.js +4 -4
  445. package/dist/semantics/class-heritage.d.ts +8 -7
  446. package/dist/semantics/class-heritage.js +8 -7
  447. package/dist/semantics/commonjs-wrapper.js +5 -2
  448. package/dist/semantics/constructor-function-class-source-transform.js +2 -3
  449. package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
  450. package/dist/semantics/constructor-slot-subclasses.js +5 -5
  451. package/dist/semantics/declaration-overlay-transform.d.ts +9 -12
  452. package/dist/semantics/declaration-overlay-transform.js +138 -141
  453. package/dist/semantics/declared-integers.d.ts +24 -0
  454. package/dist/semantics/declared-integers.js +34 -0
  455. package/dist/semantics/define-property-source-transform.js +21 -8
  456. package/dist/semantics/dynamic-fallback.d.ts +1 -1
  457. package/dist/semantics/dynamic-fallback.js +1 -1
  458. package/dist/semantics/frontend.d.ts +12 -16
  459. package/dist/semantics/frontend.js +187 -75
  460. package/dist/semantics/host-methods.d.ts +3 -3
  461. package/dist/semantics/host-methods.js +1 -1
  462. package/dist/semantics/host-protocols.d.ts +3 -3
  463. package/dist/semantics/host-protocols.js +26 -26
  464. package/dist/semantics/interface-families.d.ts +2 -2
  465. package/dist/semantics/interface-families.js +46 -47
  466. package/dist/semantics/interface-implementors.d.ts +12 -15
  467. package/dist/semantics/interface-implementors.js +12 -15
  468. package/dist/semantics/jsdoc-namepath-transform.js +7 -7
  469. package/dist/semantics/model/operands.d.ts +18 -3
  470. package/dist/semantics/model/operands.js +41 -0
  471. package/dist/semantics/model/operations.d.ts +82 -1
  472. package/dist/semantics/model/selected-signature.d.ts +24 -3
  473. package/dist/semantics/model/structural-type-table.js +24 -6
  474. package/dist/semantics/model/structural-types.d.ts +10 -8
  475. package/dist/semantics/model/structural-types.js +7 -5
  476. package/dist/semantics/module-resolution.js +3 -2
  477. package/dist/semantics/native-callable-readonly-set.d.ts +17 -0
  478. package/dist/semantics/native-callable-readonly-set.js +1 -0
  479. package/dist/semantics/native-function-signatures.d.ts +14 -0
  480. package/dist/semantics/native-function-signatures.js +96 -0
  481. package/dist/semantics/native-object-data-slots.d.ts +72 -0
  482. package/dist/semantics/native-object-data-slots.js +679 -0
  483. package/dist/semantics/native-own-assignment.d.ts +62 -0
  484. package/dist/semantics/native-own-assignment.js +1 -0
  485. package/dist/semantics/normalize/absent-globals.d.ts +8 -8
  486. package/dist/semantics/normalize/absent-globals.js +5 -5
  487. package/dist/semantics/normalize/arguments-objects.d.ts +3 -1
  488. package/dist/semantics/normalize/arguments-objects.js +1 -1
  489. package/dist/semantics/normalize/asserted-argument-arms.d.ts +7 -7
  490. package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -2
  491. package/dist/semantics/normalize/asserted-arm-absence.js +1 -2
  492. package/dist/semantics/normalize/binding-fixpoint.js +3 -3
  493. package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +2 -2
  494. package/dist/semantics/normalize/bivariant-slot-parameter.js +6 -6
  495. package/dist/semantics/normalize/callable-data-write.d.ts +46 -0
  496. package/dist/semantics/normalize/callable-data-write.js +182 -0
  497. package/dist/semantics/normalize/census.js +5 -5
  498. package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
  499. package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
  500. package/dist/semantics/normalize/collection-bindings.d.ts +11 -13
  501. package/dist/semantics/normalize/collection-bindings.js +60 -33
  502. package/dist/semantics/normalize/commonjs-module-record.d.ts +7 -4
  503. package/dist/semantics/normalize/commonjs-module-record.js +93 -4
  504. package/dist/semantics/normalize/contribution.js +4 -4
  505. package/dist/semantics/normalize/dead-method-copies.d.ts +5 -5
  506. package/dist/semantics/normalize/dead-typeof-guards.d.ts +2 -2
  507. package/dist/semantics/normalize/dead-typeof-guards.js +6 -6
  508. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +22 -13
  509. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +85 -13
  510. package/dist/semantics/normalize/derived-expression-type.d.ts +129 -91
  511. package/dist/semantics/normalize/derived-expression-type.js +419 -192
  512. package/dist/semantics/normalize/field-bindings.d.ts +4 -4
  513. package/dist/semantics/normalize/field-bindings.js +334 -67
  514. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +2 -2
  515. package/dist/semantics/normalize/flow/array-element-continuation.js +35 -18
  516. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
  517. package/dist/semantics/normalize/flow/callable-array-origins.js +3 -3
  518. package/dist/semantics/normalize/flow/callable-completions.d.ts +2 -2
  519. package/dist/semantics/normalize/flow/callable-completions.js +2 -2
  520. package/dist/semantics/normalize/flow/callable-reach.d.ts +19 -6
  521. package/dist/semantics/normalize/flow/callable-reach.js +722 -289
  522. package/dist/semantics/normalize/flow/class-family-member-read.js +24 -29
  523. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +2 -2
  524. package/dist/semantics/normalize/flow/collection-value-continuation.js +2 -2
  525. package/dist/semantics/normalize/flow/component-solver.d.ts +19 -16
  526. package/dist/semantics/normalize/flow/component-solver.js +138 -69
  527. package/dist/semantics/normalize/flow/computed-key-set.d.ts +6 -7
  528. package/dist/semantics/normalize/flow/computed-key-set.js +20 -1
  529. package/dist/semantics/normalize/flow/export-importers.js +4 -4
  530. package/dist/semantics/normalize/flow/host-text-sink.d.ts +3 -2
  531. package/dist/semantics/normalize/flow/host-text-sink.js +4 -3
  532. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +3 -2
  533. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +2 -2
  534. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +3 -3
  535. package/dist/semantics/normalize/flow/invocation-facts.d.ts +3 -2
  536. package/dist/semantics/normalize/flow/invocation-facts.js +3 -3
  537. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +12 -6
  538. package/dist/semantics/normalize/flow/member-call-forwarding.js +94 -21
  539. package/dist/semantics/normalize/flow/model.d.ts +5 -5
  540. package/dist/semantics/normalize/flow/model.js +11 -11
  541. package/dist/semantics/normalize/flow/node-path-token.js +3 -3
  542. package/dist/semantics/normalize/flow/origin-authority.d.ts +3 -3
  543. package/dist/semantics/normalize/flow/owned-class-receivers.js +8 -7
  544. package/dist/semantics/normalize/flow/parameter-values.js +6 -6
  545. package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +30 -4
  546. package/dist/semantics/normalize/flow/proof-hypotheses.js +56 -5
  547. package/dist/semantics/normalize/flow/proof-memo-settlement.d.ts +21 -0
  548. package/dist/semantics/normalize/flow/proof-memo-settlement.js +32 -0
  549. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
  550. package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
  551. package/dist/semantics/normalize/flow/seeded-origins.d.ts +4 -4
  552. package/dist/semantics/normalize/flow/seeded-origins.js +4 -4
  553. package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +22 -0
  554. package/dist/semantics/normalize/flow/source-accessor-descriptor.js +210 -0
  555. package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +33 -0
  556. package/dist/semantics/normalize/flow/source-callable-own-data.js +238 -0
  557. package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +26 -0
  558. package/dist/semantics/normalize/flow/source-callable-readonly-set.js +337 -0
  559. package/dist/semantics/normalize/flow/source-class-data.d.ts +7 -7
  560. package/dist/semantics/normalize/flow/source-class-data.js +25 -26
  561. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +2 -2
  562. package/dist/semantics/normalize/flow/source-class-static-data.js +2 -2
  563. package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +15 -0
  564. package/dist/semantics/normalize/flow/source-commonjs-exports.js +7 -0
  565. package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +20 -0
  566. package/dist/semantics/normalize/flow/source-descriptor-protocol.js +75 -0
  567. package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +8 -0
  568. package/dist/semantics/normalize/flow/source-executing-parameter-values.js +93 -0
  569. package/dist/semantics/normalize/flow/source-global-binding.d.ts +13 -0
  570. package/dist/semantics/normalize/flow/source-global-binding.js +42 -0
  571. package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +27 -0
  572. package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +178 -0
  573. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
  574. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +31 -11
  575. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +7 -3
  576. package/dist/semantics/normalize/flow/source-invocation-receiver.js +30 -2
  577. package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +7 -0
  578. package/dist/semantics/normalize/flow/source-native-class-alias.js +91 -0
  579. package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +10 -0
  580. package/dist/semantics/normalize/flow/source-normal-predecessor.js +90 -0
  581. package/dist/semantics/normalize/flow/source-property-key.d.ts +3 -0
  582. package/dist/semantics/normalize/flow/source-property-key.js +7 -0
  583. package/dist/semantics/normalize/flow/source-read-protocol.d.ts +20 -0
  584. package/dist/semantics/normalize/flow/source-read-protocol.js +108 -0
  585. package/dist/semantics/normalize/flow/source-record-data.js +31 -30
  586. package/dist/semantics/normalize/flow/source-value-session.d.ts +106 -3
  587. package/dist/semantics/normalize/flow/source-value-session.js +1172 -218
  588. package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +16 -0
  589. package/dist/semantics/normalize/flow/standard-prototype-method-source.js +64 -0
  590. package/dist/semantics/normalize/flow/targets.d.ts +13 -14
  591. package/dist/semantics/normalize/flow/targets.js +20 -23
  592. package/dist/semantics/normalize/flow/value-flow.d.ts +2 -4
  593. package/dist/semantics/normalize/flow/value-flow.js +4 -13
  594. package/dist/semantics/normalize/flow/value-provenance.d.ts +23 -3
  595. package/dist/semantics/normalize/flow/value-provenance.js +44 -4
  596. package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +32 -0
  597. package/dist/semantics/normalize/fresh-dictionary-storage.js +530 -0
  598. package/dist/semantics/normalize/fresh-indexed-storage.d.ts +43 -0
  599. package/dist/semantics/normalize/fresh-indexed-storage.js +88 -0
  600. package/dist/semantics/normalize/fresh-ordinary-object.d.ts +8 -0
  601. package/dist/semantics/normalize/fresh-ordinary-object.js +27 -0
  602. package/dist/semantics/normalize/gating.js +2 -2
  603. package/dist/semantics/normalize/global-host-mutations.js +770 -261
  604. package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
  605. package/dist/semantics/normalize/host-effect-contracts.js +1 -1
  606. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +2 -2
  607. package/dist/semantics/normalize/host-mutation-computed-keys.js +8 -0
  608. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +6 -11
  609. package/dist/semantics/normalize/host-mutation-key-reader.js +11 -28
  610. package/dist/semantics/normalize/host-mutation-keys.d.ts +11 -7
  611. package/dist/semantics/normalize/host-mutation-keys.js +26 -15
  612. package/dist/semantics/normalize/identities.js +20 -17
  613. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +8 -3
  614. package/dist/semantics/normalize/implicit-arguments-tuple.js +21 -4
  615. package/dist/semantics/normalize/installed-global-properties.d.ts +17 -0
  616. package/dist/semantics/normalize/installed-global-properties.js +214 -0
  617. package/dist/semantics/normalize/instantiation.js +6 -6
  618. package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
  619. package/dist/semantics/normalize/intrinsic-property-call.d.ts +6 -1
  620. package/dist/semantics/normalize/intrinsic-property-call.js +19 -0
  621. package/dist/semantics/normalize/intrinsic-prototype.d.ts +7 -0
  622. package/dist/semantics/normalize/intrinsic-prototype.js +10 -0
  623. package/dist/semantics/normalize/intrinsic-return-identity.d.ts +5 -0
  624. package/dist/semantics/normalize/intrinsic-return-identity.js +29 -0
  625. package/dist/semantics/normalize/jsdoc-type-names.js +59 -63
  626. package/dist/semantics/normalize/keyof.js +3 -3
  627. package/dist/semantics/normalize/local-bindings.d.ts +4 -4
  628. package/dist/semantics/normalize/local-bindings.js +60 -61
  629. package/dist/semantics/normalize/logical-object-truthiness.d.ts +8 -0
  630. package/dist/semantics/normalize/logical-object-truthiness.js +20 -0
  631. package/dist/semantics/normalize/merged-declaration.d.ts +3 -3
  632. package/dist/semantics/normalize/merged-declaration.js +3 -3
  633. package/dist/semantics/normalize/never-override-result.d.ts +2 -3
  634. package/dist/semantics/normalize/never-override-result.js +2 -3
  635. package/dist/semantics/normalize/null-blind-parameter.d.ts +2 -2
  636. package/dist/semantics/normalize/null-blind-parameter.js +2 -2
  637. package/dist/semantics/normalize/object-bag-bindings.d.ts +19 -19
  638. package/dist/semantics/normalize/object-bag-bindings.js +334 -141
  639. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +8 -8
  640. package/dist/semantics/normalize/omitted-stated-parameter.js +8 -9
  641. package/dist/semantics/normalize/override-field-arms.d.ts +3 -3
  642. package/dist/semantics/normalize/override-field-arms.js +15 -16
  643. package/dist/semantics/normalize/parameter-bindings.d.ts +13 -12
  644. package/dist/semantics/normalize/parameter-bindings.js +173 -139
  645. package/dist/semantics/normalize/parameter-slot.d.ts +9 -10
  646. package/dist/semantics/normalize/parameter-slot.js +16 -17
  647. package/dist/semantics/normalize/physical-overload-result.d.ts +8 -8
  648. package/dist/semantics/normalize/physical-overload-result.js +10 -10
  649. package/dist/semantics/normalize/producer-context.d.ts +27 -12
  650. package/dist/semantics/normalize/producers/allocations.js +5 -1
  651. package/dist/semantics/normalize/producers/bindings.js +8 -7
  652. package/dist/semantics/normalize/producers/class-lifecycle.js +52 -7
  653. package/dist/semantics/normalize/producers/computations.js +27 -3
  654. package/dist/semantics/normalize/producers/control.js +5 -5
  655. package/dist/semantics/normalize/producers/declaration-lifecycle.js +4 -4
  656. package/dist/semantics/normalize/producers/destructuring.js +10 -5
  657. package/dist/semantics/normalize/producers/erasure.d.ts +9 -0
  658. package/dist/semantics/normalize/producers/erasure.js +22 -0
  659. package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
  660. package/dist/semantics/normalize/producers/invocations.js +200 -55
  661. package/dist/semantics/normalize/producers/logical-merge-type.d.ts +2 -2
  662. package/dist/semantics/normalize/producers/logical-merge-type.js +12 -12
  663. package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +6 -0
  664. package/dist/semantics/normalize/producers/native-callable-readonly-set.js +24 -0
  665. package/dist/semantics/normalize/producers/native-own-assignment.d.ts +14 -0
  666. package/dist/semantics/normalize/producers/native-own-assignment.js +153 -0
  667. package/dist/semantics/normalize/producers/properties.js +153 -20
  668. package/dist/semantics/normalize/producers/protocol.js +4 -4
  669. package/dist/semantics/normalize/producers/references.js +21 -19
  670. package/dist/semantics/normalize/producers/shared.d.ts +1 -1
  671. package/dist/semantics/normalize/producers/shared.js +59 -58
  672. package/dist/semantics/normalize/producers/spread-arguments.js +7 -3
  673. package/dist/semantics/normalize/producers/tuple-spread.d.ts +2 -2
  674. package/dist/semantics/normalize/producers/tuple-spread.js +5 -5
  675. package/dist/semantics/normalize/property-key-domain.d.ts +6 -6
  676. package/dist/semantics/normalize/property-key-domain.js +7 -7
  677. package/dist/semantics/normalize/reachability.d.ts +6 -7
  678. package/dist/semantics/normalize/reachability.js +60 -62
  679. package/dist/semantics/normalize/record-home-arms.js +2 -3
  680. package/dist/semantics/normalize/record-link-families.d.ts +1 -1
  681. package/dist/semantics/normalize/record-link-families.js +1 -1
  682. package/dist/semantics/normalize/record-stand-in-arms.d.ts +4 -5
  683. package/dist/semantics/normalize/return-bindings.d.ts +19 -9
  684. package/dist/semantics/normalize/return-bindings.js +49 -41
  685. package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
  686. package/dist/semantics/normalize/script-global-redefinition.js +1 -1
  687. package/dist/semantics/normalize/shared-array-storage.d.ts +4 -5
  688. package/dist/semantics/normalize/shared-array-storage.js +7 -8
  689. package/dist/semantics/normalize/sloppy-absence.d.ts +6 -3
  690. package/dist/semantics/normalize/sloppy-absence.js +7 -3
  691. package/dist/semantics/normalize/source-object-prototype-absence.d.ts +7 -0
  692. package/dist/semantics/normalize/source-object-prototype-absence.js +19 -0
  693. package/dist/semantics/normalize/specialization.d.ts +10 -10
  694. package/dist/semantics/normalize/specialization.js +107 -112
  695. package/dist/semantics/normalize/specialized-source-frames.d.ts +11 -0
  696. package/dist/semantics/normalize/specialized-source-frames.js +41 -0
  697. package/dist/semantics/normalize/structural-array-element.d.ts +5 -5
  698. package/dist/semantics/normalize/structural-array-element.js +40 -39
  699. package/dist/semantics/normalize/structural-array-read.js +3 -3
  700. package/dist/semantics/normalize/structural-callable.d.ts +15 -1
  701. package/dist/semantics/normalize/structural-callable.js +35 -3
  702. package/dist/semantics/normalize/structural-creation-order.d.ts +2 -2
  703. package/dist/semantics/normalize/structural-declarations.d.ts +22 -21
  704. package/dist/semantics/normalize/structural-declarations.js +42 -42
  705. package/dist/semantics/normalize/structural-declared-body.js +10 -11
  706. package/dist/semantics/normalize/structural-indexed-access.js +2 -2
  707. package/dist/semantics/normalize/structural-instantiated-member.d.ts +9 -10
  708. package/dist/semantics/normalize/structural-instantiated-member.js +43 -30
  709. package/dist/semantics/normalize/structural-joins.d.ts +4 -16
  710. package/dist/semantics/normalize/structural-joins.js +5 -65
  711. package/dist/semantics/normalize/structural-layout-relevance.d.ts +5 -5
  712. package/dist/semantics/normalize/structural-layout-relevance.js +22 -23
  713. package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
  714. package/dist/semantics/normalize/structural-layout-type.js +140 -107
  715. package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
  716. package/dist/semantics/normalize/structural-local-union.js +38 -12
  717. package/dist/semantics/normalize/structural-mutable-field.d.ts +9 -0
  718. package/dist/semantics/normalize/structural-mutable-field.js +152 -0
  719. package/dist/semantics/normalize/structural-parts.d.ts +6 -0
  720. package/dist/semantics/normalize/structural-parts.js +35 -32
  721. package/dist/semantics/normalize/structural-receiver.d.ts +3 -3
  722. package/dist/semantics/normalize/structural-receiver.js +12 -13
  723. package/dist/semantics/normalize/structural-self-reference.d.ts +12 -11
  724. package/dist/semantics/normalize/structural-self-reference.js +24 -25
  725. package/dist/semantics/normalize/structural.d.ts +13 -3
  726. package/dist/semantics/normalize/structural.js +400 -201
  727. package/dist/semantics/normalize/suppressed-write-arms.d.ts +10 -11
  728. package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +6 -6
  729. package/dist/semantics/normalize/symbol-keyed-this-slots.js +4 -4
  730. package/dist/semantics/normalize/unresolvable-names.d.ts +2 -3
  731. package/dist/semantics/normalize/unresolvable-names.js +2 -2
  732. package/dist/semantics/normalize/unshared-array-result.d.ts +4 -4
  733. package/dist/semantics/normalize/unshared-array-result.js +4 -4
  734. package/dist/semantics/package-sources.js +2 -3
  735. package/dist/semantics/program.d.ts +10 -13
  736. package/dist/semantics/program.js +80 -26
  737. package/dist/semantics/property-key.d.ts +9 -0
  738. package/dist/semantics/property-key.js +25 -0
  739. package/dist/semantics/prototype-object-class-source-transform.js +2 -2
  740. package/dist/semantics/prototype-reparenting.d.ts +1 -1
  741. package/dist/semantics/prototype-reparenting.js +1 -1
  742. package/dist/semantics/shared-declaration-files.d.ts +6 -1
  743. package/dist/semantics/shared-declaration-files.js +2 -2
  744. package/dist/semantics/source-transform-protocol.d.ts +26 -0
  745. package/dist/semantics/source-transform-protocol.js +1 -0
  746. package/dist/semantics/stable-checker.js +9 -13
  747. package/dist/semantics/subclass-member-overlay-transform.d.ts +2 -2
  748. package/dist/semantics/subclass-member-overlay-transform.js +89 -88
  749. package/dist/semantics/this-constructor-source-transform.js +2 -2
  750. package/dist/semantics/unchecked-guard-argument-copies.d.ts +3 -3
  751. package/dist/semantics/unchecked-write-member-declarations.d.ts +9 -11
  752. package/dist/semantics/unchecked-write-member-declarations.js +11 -13
  753. package/dist/semantics/uninstantiable-classes.d.ts +1 -1
  754. package/dist/semantics/uninstantiable-classes.js +1 -1
  755. package/dist/targets/cpp/balanced-units.d.ts +1 -1
  756. package/dist/targets/cpp/balanced-units.js +1 -1
  757. package/dist/targets/cpp/borrowed-arm-projections.d.ts +2 -3
  758. package/dist/targets/cpp/borrowed-arm-projections.js +2 -3
  759. package/dist/targets/cpp/borrowed-call-entry.js +3 -3
  760. package/dist/targets/cpp/captures.d.ts +2 -2
  761. package/dist/targets/cpp/captures.js +4 -4
  762. package/dist/targets/cpp/char-code-buffers.d.ts +1 -1
  763. package/dist/targets/cpp/char-code-buffers.js +4 -1
  764. package/dist/targets/cpp/class-layout.d.ts +7 -17
  765. package/dist/targets/cpp/class-layout.js +6 -13
  766. package/dist/targets/cpp/class-properties/computed-method-value.d.ts +1 -1
  767. package/dist/targets/cpp/class-properties/computed-method-value.js +5 -27
  768. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +49 -59
  769. package/dist/targets/cpp/class-properties/emit-class-properties.js +68 -232
  770. package/dist/targets/cpp/class-properties/native-method-read.d.ts +5 -0
  771. package/dist/targets/cpp/class-properties/native-method-read.js +60 -0
  772. package/dist/targets/cpp/class-properties/native-prototype.d.ts +3 -1
  773. package/dist/targets/cpp/class-properties/native-prototype.js +5 -6
  774. package/dist/targets/cpp/class-ref-transport.d.ts +1 -11
  775. package/dist/targets/cpp/class-ref-transport.js +1 -9
  776. package/dist/targets/cpp/conversions.js +613 -252
  777. package/dist/targets/cpp/coroutine-bodies.d.ts +1 -97
  778. package/dist/targets/cpp/coroutine-bodies.js +1 -187
  779. package/dist/targets/cpp/document.js +1 -1
  780. package/dist/targets/cpp/emit-allocation.d.ts +0 -38
  781. package/dist/targets/cpp/emit-allocation.js +63 -88
  782. package/dist/targets/cpp/emit-array-view.d.ts +7 -0
  783. package/dist/targets/cpp/emit-array-view.js +47 -0
  784. package/dist/targets/cpp/emit-arrays.d.ts +9 -52
  785. package/dist/targets/cpp/emit-arrays.js +177 -113
  786. package/dist/targets/cpp/emit-binding-reference.d.ts +10 -0
  787. package/dist/targets/cpp/emit-binding-reference.js +19 -1
  788. package/dist/targets/cpp/emit-bindings.js +19 -24
  789. package/dist/targets/cpp/emit-buffers.d.ts +8 -4
  790. package/dist/targets/cpp/emit-buffers.js +88 -47
  791. package/dist/targets/cpp/emit-callable-view.d.ts +6 -0
  792. package/dist/targets/cpp/emit-callable-view.js +133 -0
  793. package/dist/targets/cpp/emit-callable.d.ts +11 -1
  794. package/dist/targets/cpp/emit-callable.js +225 -266
  795. package/dist/targets/cpp/emit-carrier-members.d.ts +2 -2
  796. package/dist/targets/cpp/emit-carrier-members.js +42 -35
  797. package/dist/targets/cpp/emit-certified-conversion.d.ts +7 -0
  798. package/dist/targets/cpp/emit-certified-conversion.js +27 -0
  799. package/dist/targets/cpp/emit-context.d.ts +123 -64
  800. package/dist/targets/cpp/emit-context.js +147 -44
  801. package/dist/targets/cpp/emit-descriptor-snapshot.d.ts +10 -0
  802. package/dist/targets/cpp/emit-descriptor-snapshot.js +60 -0
  803. package/dist/targets/cpp/emit-dictionary-view.d.ts +6 -0
  804. package/dist/targets/cpp/emit-dictionary-view.js +102 -0
  805. package/dist/targets/cpp/emit-document-record-view.d.ts +3 -0
  806. package/dist/targets/cpp/emit-document-record-view.js +104 -0
  807. package/dist/targets/cpp/emit-dynamic-properties.d.ts +42 -17
  808. package/dist/targets/cpp/emit-dynamic-properties.js +118 -72
  809. package/dist/targets/cpp/emit-equality.d.ts +2 -1
  810. package/dist/targets/cpp/emit-equality.js +65 -45
  811. package/dist/targets/cpp/emit-exceptions.js +1 -1
  812. package/dist/targets/cpp/emit-in.js +22 -11
  813. package/dist/targets/cpp/emit-instanceof.js +15 -14
  814. package/dist/targets/cpp/emit-integers.d.ts +40 -3
  815. package/dist/targets/cpp/emit-integers.js +76 -5
  816. package/dist/targets/cpp/emit-iterable-object-view.d.ts +2 -0
  817. package/dist/targets/cpp/emit-iterable-object-view.js +15 -11
  818. package/dist/targets/cpp/emit-iterator-object-view.d.ts +2 -0
  819. package/dist/targets/cpp/emit-iterator-object-view.js +24 -16
  820. package/dist/targets/cpp/emit-iterator.d.ts +2 -0
  821. package/dist/targets/cpp/emit-iterator.js +115 -43
  822. package/dist/targets/cpp/emit-json.js +6 -6
  823. package/dist/targets/cpp/emit-jsx.js +2 -2
  824. package/dist/targets/cpp/emit-live-field-view.d.ts +26 -0
  825. package/dist/targets/cpp/emit-live-field-view.js +50 -0
  826. package/dist/targets/cpp/emit-narrowing.d.ts +60 -139
  827. package/dist/targets/cpp/emit-narrowing.js +694 -624
  828. package/dist/targets/cpp/emit-native-accessor-definition.d.ts +10 -0
  829. package/dist/targets/cpp/emit-native-accessor-definition.js +94 -0
  830. package/dist/targets/cpp/emit-native-callable-data.d.ts +23 -0
  831. package/dist/targets/cpp/emit-native-callable-data.js +117 -0
  832. package/dist/targets/cpp/emit-native-document-entry.d.ts +4 -0
  833. package/dist/targets/cpp/emit-native-document-entry.js +52 -0
  834. package/dist/targets/cpp/emit-native-field-view.d.ts +26 -0
  835. package/dist/targets/cpp/emit-native-field-view.js +217 -0
  836. package/dist/targets/cpp/emit-native-method.d.ts +16 -0
  837. package/dist/targets/cpp/emit-native-method.js +90 -0
  838. package/dist/targets/cpp/emit-native-object-data.d.ts +7 -0
  839. package/dist/targets/cpp/emit-native-object-data.js +66 -0
  840. package/dist/targets/cpp/emit-native-object-sample.d.ts +8 -0
  841. package/dist/targets/cpp/emit-native-object-sample.js +34 -0
  842. package/dist/targets/cpp/emit-native-own-assignment.d.ts +7 -0
  843. package/dist/targets/cpp/emit-native-own-assignment.js +119 -0
  844. package/dist/targets/cpp/emit-native-selection.d.ts +2 -2
  845. package/dist/targets/cpp/emit-native-selection.js +14 -5
  846. package/dist/targets/cpp/emit-number-storage.d.ts +2 -0
  847. package/dist/targets/cpp/emit-number-storage.js +1 -0
  848. package/dist/targets/cpp/emit-presence.d.ts +3 -4
  849. package/dist/targets/cpp/emit-presence.js +43 -21
  850. package/dist/targets/cpp/emit-properties.js +224 -111
  851. package/dist/targets/cpp/emit-protocol-iterator.d.ts +2 -0
  852. package/dist/targets/cpp/emit-protocol-iterator.js +45 -23
  853. package/dist/targets/cpp/emit-record-view.d.ts +5 -10
  854. package/dist/targets/cpp/emit-record-view.js +223 -269
  855. package/dist/targets/cpp/emit-return.js +33 -8
  856. package/dist/targets/cpp/emit-scopes.d.ts +2 -2
  857. package/dist/targets/cpp/emit-sum-widening.js +13 -5
  858. package/dist/targets/cpp/emit-tonumber.d.ts +1 -1
  859. package/dist/targets/cpp/emit-tonumber.js +3 -3
  860. package/dist/targets/cpp/emit-tostring.d.ts +20 -2
  861. package/dist/targets/cpp/emit-tostring.js +131 -28
  862. package/dist/targets/cpp/emit-typeof.d.ts +4 -0
  863. package/dist/targets/cpp/emit-typeof.js +29 -1
  864. package/dist/targets/cpp/emit-union-properties.d.ts +6 -23
  865. package/dist/targets/cpp/emit-union-properties.js +127 -235
  866. package/dist/targets/cpp/emit.d.ts +4 -1
  867. package/dist/targets/cpp/emit.js +336 -119
  868. package/dist/targets/cpp/error-types.d.ts +1 -3
  869. package/dist/targets/cpp/error-types.js +1 -2
  870. package/dist/targets/cpp/evaluated-once.d.ts +4 -4
  871. package/dist/targets/cpp/evaluated-once.js +5 -5
  872. package/dist/targets/cpp/function-source-reads.d.ts +2 -15
  873. package/dist/targets/cpp/function-source-reads.js +3 -38
  874. package/dist/targets/cpp/host/core-globals.d.ts +5 -0
  875. package/dist/targets/cpp/host/core-globals.js +10 -0
  876. package/dist/targets/cpp/host/emit-host-arity.js +1 -1
  877. package/dist/targets/cpp/host/emit-host-invoke.js +73 -23
  878. package/dist/targets/cpp/host/emit-host-object.d.ts +2 -1
  879. package/dist/targets/cpp/host/emit-host-object.js +328 -145
  880. package/dist/targets/cpp/host/emit-host-properties.js +4 -6
  881. package/dist/targets/cpp/host/emit-host-reflect.js +29 -5
  882. package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
  883. package/dist/targets/cpp/host/emit-host-value.js +2 -2
  884. package/dist/targets/cpp/host/host-members.d.ts +11 -0
  885. package/dist/targets/cpp/host/host-members.js +27 -5
  886. package/dist/targets/cpp/host/host-method-aliases.d.ts +1 -30
  887. package/dist/targets/cpp/host/host-method-aliases.js +1 -76
  888. package/dist/targets/cpp/host/native-protocols.js +1 -1
  889. package/dist/targets/cpp/host/object-protocol.d.ts +1 -1
  890. package/dist/targets/cpp/host/object-protocol.js +24 -24
  891. package/dist/targets/cpp/host-namespace-reads.d.ts +1 -83
  892. package/dist/targets/cpp/host-namespace-reads.js +1 -113
  893. package/dist/targets/cpp/manifest/capabilities.js +33 -33
  894. package/dist/targets/cpp/manifest.d.ts +5 -0
  895. package/dist/targets/cpp/manifest.js +38 -14
  896. package/dist/targets/cpp/native-collection-base.js +7 -6
  897. package/dist/targets/cpp/native-debug-source.d.ts +15 -0
  898. package/dist/targets/cpp/native-debug-source.js +21 -0
  899. package/dist/targets/cpp/native-error-base.d.ts +1 -1
  900. package/dist/targets/cpp/native-error-base.js +1 -1
  901. package/dist/targets/cpp/native-narrowing-transport.d.ts +2 -0
  902. package/dist/targets/cpp/native-narrowing-transport.js +25 -5
  903. package/dist/targets/cpp/native-view-targets.d.ts +3 -0
  904. package/dist/targets/cpp/native-view-targets.js +5 -0
  905. package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +3 -33
  906. package/dist/targets/cpp/prototype/emit-prototype-array.js +40 -22
  907. package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +1 -58
  908. package/dist/targets/cpp/prototype/emit-prototype-date.js +14 -97
  909. package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +20 -0
  910. package/dist/targets/cpp/prototype/emit-prototype-error.js +2 -2
  911. package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +3 -27
  912. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +60 -52
  913. package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +1 -41
  914. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +4 -43
  915. package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +2 -13
  916. package/dist/targets/cpp/prototype/emit-prototype-promise.js +10 -58
  917. package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +4 -25
  918. package/dist/targets/cpp/prototype/emit-prototype-regexp.js +16 -81
  919. package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +1 -1
  920. package/dist/targets/cpp/prototype/emit-prototype-string.js +17 -28
  921. package/dist/targets/cpp/prototype/prototype-method-reads.js +4 -80
  922. package/dist/targets/cpp/reactive-dependencies.d.ts +12 -6
  923. package/dist/targets/cpp/reactive-dependencies.js +62 -42
  924. package/dist/targets/cpp/reactive-origins.js +12 -0
  925. package/dist/targets/cpp/records.d.ts +133 -14
  926. package/dist/targets/cpp/records.js +345 -153
  927. package/dist/targets/cpp/regexp-types.d.ts +1 -26
  928. package/dist/targets/cpp/regexp-types.js +4 -29
  929. package/dist/targets/cpp/segment-scopes.d.ts +30 -0
  930. package/dist/targets/cpp/segment-scopes.js +294 -0
  931. package/dist/targets/cpp/translation-unit.d.ts +21 -2
  932. package/dist/targets/cpp/translation-unit.js +121 -276
  933. package/dist/targets/cpp/types.d.ts +8 -3
  934. package/dist/targets/cpp/types.js +30 -6
  935. package/dist/targets/cpp/virtual-callees.d.ts +18 -0
  936. package/dist/targets/cpp/virtual-callees.js +27 -0
  937. package/dist/targets/cpp/virtual-methods.d.ts +7 -7
  938. package/dist/targets/cpp/virtual-methods.js +213 -58
  939. package/package.json +8 -3
  940. package/src/targets/cpp/runtime/gea_dictionary_view.h +204 -0
  941. package/src/targets/cpp/runtime/gea_document_view.h +845 -0
  942. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +66 -23
  943. package/src/targets/cpp/runtime/gea_eval.h +6 -6
  944. package/src/targets/cpp/runtime/gea_runtime.h +7550 -1166
  945. package/dist/targets/cpp/direct-call-receivers.d.ts +0 -37
  946. package/dist/targets/cpp/direct-call-receivers.js +0 -79
@@ -32,7 +32,7 @@ const mirroredComparisons = new Map([
32
32
  * the integer that answers the same question moves the conversion to a pure
33
33
  * function of the bound alone, which leaves the loop by ordinary licm without
34
34
  * this emitter proving anything is invariant. Measured on
35
- * `bench/comparison/fixtures/modulo.ts`: 56.0ms with the conversion in the
35
+ * a modulo loop: 56.0ms with the conversion in the
36
36
  * loop, 37.4ms with the bound restated, against 36.7ms for the hand-written
37
37
  * baseline that takes its bound as `long long` to begin with.
38
38
  *
@@ -43,14 +43,27 @@ const mirroredComparisons = new Map([
43
43
  *
44
44
  * Sound because a narrowed value is one the integer census proved holds
45
45
  * |i| <= 2^53, far inside the sentinels the helpers clamp to.
46
+ *
47
+ * Not when the narrowed side is a literal: its double is a compile-time
48
+ * constant, so there is no conversion to move, and restating the double side
49
+ * instead puts a truncate, a convert back and a compare on the path of the
50
+ * value being tested. A method's `if (this.value >= C) this.value -= C` is
51
+ * loop-free, so its double field reads as invariant; inlined into its caller's
52
+ * loop, that chain sat on the field's own recurrence: a method-call counter loop
53
+ * measured 84 ms with the helper and 16 ms with the plain double compare.
46
54
  */
47
- export const integerBoundedComparison = (integerValues, invariant, operation, first, second, left, right) => {
55
+ export const integerBoundedComparison = (integerValues, invariant, isConstant, declaredWidths, operation, first, second, left, right) => {
48
56
  if (first.representation.kind !== 'scalar' || first.representation.domain !== 'number')
49
57
  return null;
50
58
  const leftNarrowed = integerValues.has(first.value);
51
59
  const rightNarrowed = integerValues.has(second.value);
52
60
  if (leftNarrowed === rightNarrowed)
53
61
  return null;
62
+ if (isConstant(leftNarrowed ? first : second))
63
+ return null;
64
+ // Explicit int64 values can exceed the helpers' bounded sentinels.
65
+ if (declaredWidths.get(leftNarrowed ? first.value : second.value) === 'int64')
66
+ return null;
54
67
  // The side that stays a double is the one being restated, so it is the one
55
68
  // that has to be free to restate.
56
69
  if (!invariant.has(leftNarrowed ? second.value : first.value))
@@ -61,6 +74,64 @@ export const integerBoundedComparison = (integerValues, invariant, operation, fi
61
74
  return null;
62
75
  return leftNarrowed ? `${left} ${operation.operator} ${helper}(${right})` : `${helper}(${left}) ${operation.operator} ${right}`;
63
76
  };
77
+ const constantComparisons = new Set(['==', '===', '!=', '!==', '<', '<=', '>', '>=']);
78
+ /**
79
+ * An integer compared against an integer-valued constant, asked of the integer.
80
+ *
81
+ * `while (value !== 1)` over an `int` read the integer, widened it to a double
82
+ * and compared doubles, once per turn of a hot inner loop. Against a
83
+ * constant `c` that is an integer below 2^53 in magnitude the integer compare
84
+ * is the same answer for EVERY integer, not only the safe ones: widening is
85
+ * monotone and `c` is exact, and an integer that widens to `c` must lie within
86
+ * half a unit of it -- below 2^53 a unit is at most one, so only `c` itself
87
+ * does. Equality is therefore as safe here as the relations, unlike against a
88
+ * double that is only known at run time (`integerBoundedComparison`).
89
+ *
90
+ * `integerText` answers an operand's integer spelling, or `null` when it is
91
+ * not one; `constantText` its constant literal, if it is a constant.
92
+ */
93
+ export const integerConstantComparison = (operation, first, second, integerText, constantText) => {
94
+ if (!constantComparisons.has(operation.operator))
95
+ return null;
96
+ const integral = (operand) => {
97
+ const text = constantText(operand);
98
+ if (text === undefined || operand.representation.kind !== 'scalar' || operand.representation.domain !== 'number')
99
+ return null;
100
+ const value = Number(text);
101
+ return Number.isInteger(value) && Math.abs(value) < 2 ** 53 ? `${value}LL` : null;
102
+ };
103
+ const operator = operation.operator === '===' ? '==' : operation.operator === '!==' ? '!=' : operation.operator;
104
+ const rightConstant = integral(second);
105
+ const leftInteger = rightConstant === null ? null : integerText(first);
106
+ if (rightConstant !== null && leftInteger !== null)
107
+ return `(${leftInteger}) ${operator} ${rightConstant}`;
108
+ const leftConstant = integral(first);
109
+ const rightInteger = leftConstant === null ? null : integerText(second);
110
+ if (leftConstant !== null && rightInteger !== null)
111
+ return `${leftConstant} ${operator} (${rightInteger})`;
112
+ return null;
113
+ };
114
+ /**
115
+ * Two `int`/`i32` values compared, asked of the integers.
116
+ *
117
+ * `divisor * divisor <= value` over `int`s widened `value` to a double to meet
118
+ * the product's Number type and compared doubles, a conversion and a float
119
+ * compare on every turn of a trial-division loop. A declared integer is
120
+ * the annotation's contract -- its arithmetic already wraps at the machine
121
+ * width rather than rounding -- so its comparisons are the integer ones too.
122
+ * `declaredText` answers an operand's integer spelling when it is a declared
123
+ * value or a widening of one, else `null`.
124
+ */
125
+ export const declaredIntegerComparison = (operation, first, second, declaredText) => {
126
+ if (!constantComparisons.has(operation.operator))
127
+ return null;
128
+ const left = declaredText(first);
129
+ const right = left === null ? null : declaredText(second);
130
+ if (left === null || right === null)
131
+ return null;
132
+ const operator = operation.operator === '===' ? '==' : operation.operator === '!==' ? '!=' : operation.operator;
133
+ return `(${left}) ${operator} (${right})`;
134
+ };
64
135
  /**
65
136
  * The largest dividend text this restates in place rather than handing to
66
137
  * `gea::integralRemainder`.
@@ -77,7 +148,7 @@ const restatableDividend = 80;
77
148
  *
78
149
  * The two spellings compute the same thing, and the difference between them is
79
150
  * entirely what clang can prove afterwards. Measured on
80
- * `bench/comparison/fixtures/factorial.ts` (10M iterations, best of five):
151
+ * an iterative factorial loop (10M iterations, best of five):
81
152
  *
82
153
  * gea::remainder (plain fmod) 87.9ms
83
154
  * gea::integralRemainder(expr, k) 83.2ms
@@ -148,7 +219,7 @@ export const roundingIntegerHelpers = new Map([
148
219
  * be zero and the integer answer is exact. The double form stays for the
149
220
  * general arm; this one is emitted beside it and used only inside the guard.
150
221
  *
151
- * Measured on `bench/comparison/fixtures/object_create.ts`, two subscripts of
222
+ * Measured on an object-creation loop, two subscripts of
152
223
  * this shape per iteration: 10.8ms converting through a `double`, 7.7ms not --
153
224
  * against 6.5ms for a literal `% 256`, so the round trip was three quarters of
154
225
  * what a constant length would have been worth.
@@ -162,7 +233,7 @@ export const denseRemainderCompanion = (ordinal, dividend, declarations, lines)
162
233
  // and `NaN` where it has none -- because the divisor here IS that length, so
163
234
  // a zero length is `x % 0`, which is NaN for every dividend there is. Naming
164
235
  // the general `gea::remainderBy` in that arm instead cost 12% of
165
- // `object_create`: the arm never runs, but a CALL in the loop body pins the
236
+ // an object-creation loop: the arm never runs, but a CALL in the loop body pins the
166
237
  // dividend and the receiver live across it, and clang stops sinking either.
167
238
  const zero = `${cppDenseLengthName(ordinal)} > 0`;
168
239
  return { index: name, value: `(${zero} ? static_cast<double>(${name}) : std::numeric_limits<double>::quiet_NaN())` };
@@ -1,6 +1,7 @@
1
1
  import type { Representation } from '../../representation/model.js';
2
2
  import type { RecordLayoutPolicy } from '../../representation/policies.js';
3
3
  import { type IterableObjectViewPlan } from '../../conversion/iterable-object-view.js';
4
+ import type { CertifiedIterableObjectViewPlan } from '../../conversion/certified-iterator-protocols.js';
4
5
  import { type ConversionSite } from './emit-narrowing.js';
5
6
  /** The materializer id `conversions.ts` installs a collection's iterable object view under, and `recipeText` renders. */
6
7
  export declare const ITERABLE_OBJECT_VIEW = "gea::Iterable::objectView";
@@ -13,3 +14,4 @@ export declare const iterableObjectViewPlanFor: (layouts: RecordLayoutPolicy, so
13
14
  * member declares.
14
15
  */
15
16
  export declare const iterableObjectViewText: (ctx: ConversionSite, source: Representation, target: Representation, text: string) => string | null;
17
+ export declare const certifiedIterableObjectViewText: (ctx: ConversionSite, certified: CertifiedIterableObjectViewPlan, text: string) => string | null;
@@ -1,5 +1,6 @@
1
1
  import { iterableObjectViewPlan } from '../../conversion/iterable-object-view.js';
2
- import { alignedValueText, chainConverts } from './emit-narrowing.js';
2
+ import { structuralConversionKey } from '../../conversion/structural-plan.js';
3
+ import { namedConversionText, chainConverts } from './emit-narrowing.js';
3
4
  import { viewPlanFor } from './emit-record-view.js';
4
5
  import { cppAbiParameterType, cppRecordFieldName, cppRecordFieldPresenceName, cppRecordStructName, cppResultTypeOf, cppTypeOf } from './types.js';
5
6
  /** The materializer id `conversions.ts` installs a collection's iterable object view under, and `recipeText` renders. */
@@ -14,13 +15,12 @@ export const iterableObjectViewPlanFor = (layouts, source, target) => iterableOb
14
15
  * member declares.
15
16
  */
16
17
  export const iterableObjectViewText = (ctx, source, target, text) => {
17
- if (target.kind === 'optional') {
18
- const present = iterableObjectViewText(ctx, source, target.payload, text);
19
- return present === null ? null : `${cppTypeOf(target)}(${present})`;
20
- }
21
- const plan = iterableObjectViewPlanFor(ctx.layouts, source, target);
22
- if (plan === null)
23
- return null;
18
+ const node = ctx.conversions.nodeById(structuralConversionKey(source, target));
19
+ const materializer = node?.capability.kind === 'atom' || node?.capability.kind === 'static' ? node.capability.materializer : null;
20
+ return materializer?.iterableObjectView === undefined ? null : certifiedIterableObjectViewText(ctx, materializer.iterableObjectView, text);
21
+ };
22
+ export const certifiedIterableObjectViewText = (ctx, certified, text) => {
23
+ const plan = certified.view;
24
24
  const sourceType = cppTypeOf(plan.source);
25
25
  const holderType = `gea::Ref<${sourceType}>`;
26
26
  const structName = cppRecordStructName(plan.target.shapeId);
@@ -34,7 +34,10 @@ export const iterableObjectViewText = (ctx, source, target, text) => {
34
34
  const resultType = cppResultTypeOf(abi.result);
35
35
  const cursorText = `${cppTypeOf(plan.cursor)}(**gea::unpackEnvironment<${holderType}>(gea_view_env, gea_view_slot))`;
36
36
  const object = abi.result.kind === 'optional' ? abi.result.payload : abi.result;
37
- const viewed = alignedValueText(ctx, 'emit-iterable-object-view.ts:cursor', plan.cursor, object, cursorText);
37
+ const cursor = certified.leaves.get(structuralConversionKey(plan.cursor, object));
38
+ if (cursor === undefined)
39
+ throw new Error('an iterable view has no certified cursor object recipe');
40
+ const viewed = namedConversionText(ctx, 'emit-iterable-object-view.ts:cursor', cursor, cursorText);
38
41
  if (viewed === null)
39
42
  return null;
40
43
  const answer = abi.result.kind === 'optional' ? `${cppTypeOf(abi.result)}(${viewed})` : viewed;
@@ -46,6 +49,7 @@ export const iterableObjectViewText = (ctx, source, target, text) => {
46
49
  const stores = [`gea_view->${cppRecordFieldName(field.key)} = ${callable};`];
47
50
  if (!field.required)
48
51
  stores.push(`gea_view->${cppRecordFieldPresenceName(field.key)} = true;`);
49
- return (`([&]() -> ${cppTypeOf(plan.target)} { ${holderType} gea_view_holder = gea::makeRef<${sourceType}>(${text}); ` +
50
- `auto gea_view = gea::makeRef<${structName}>(); ${stores.join(' ')} return gea_view; }())`);
52
+ const built = `([&]() -> ${cppTypeOf(plan.target)} { ${holderType} gea_view_holder = gea::makeRef<${sourceType}>(${text}); ` +
53
+ `auto gea_view = gea::makeRef<${structName}>(); ${stores.join(' ')} return gea_view; }())`;
54
+ return certified.target.kind === 'optional' ? `${cppTypeOf(certified.target)}(${built})` : built;
51
55
  };
@@ -1,5 +1,6 @@
1
1
  import type { Representation } from '../../representation/model.js';
2
2
  import type { RecordLayoutPolicy } from '../../representation/policies.js';
3
+ import type { CertifiedIteratorObjectViewPlan } from '../../conversion/certified-iterator-object-view.js';
3
4
  import { type IteratorObjectViewPlan } from '../../conversion/iterator-object-view.js';
4
5
  import { type ConversionSite } from './emit-narrowing.js';
5
6
  /** The materializer id `conversions.ts` installs a cursor's object view under, and `recipeText` renders. */
@@ -13,3 +14,4 @@ export declare const iteratorObjectViewPlanFor: (layouts: RecordLayoutPolicy, so
13
14
  * its own receiver.
14
15
  */
15
16
  export declare const iteratorObjectViewText: (ctx: ConversionSite, source: Representation, target: Representation, text: string) => string | null;
17
+ export declare const certifiedIteratorObjectViewText: (ctx: ConversionSite, certified: CertifiedIteratorObjectViewPlan, text: string) => string | null;
@@ -1,5 +1,6 @@
1
1
  import { iteratorObjectViewPlan } from '../../conversion/iterator-object-view.js';
2
- import { alignedValueText, chainConverts } from './emit-narrowing.js';
2
+ import { chainConverts, namedConversionText } from './emit-narrowing.js';
3
+ import { structuralConversionKey } from '../../conversion/structural-plan.js';
3
4
  import { viewPlanFor } from './emit-record-view.js';
4
5
  import { memberAccessOperator } from './emit-carrier-members.js';
5
6
  import { cppAbiParameterType, cppRecordFieldName, cppRecordFieldPresenceName, cppRecordStructName, cppResultTypeOf, cppTypeOf, cppUndefinedValue } from './types.js';
@@ -9,16 +10,23 @@ const planConverts = (layouts) => (source, target) => chainConverts(source, targ
9
10
  /** `conversion/iterator-object-view.ts`'s plan over the pairs this backend renders. */
10
11
  export const iteratorObjectViewPlanFor = (layouts, source, target) => iteratorObjectViewPlan(layouts, source, target, planConverts(layouts));
11
12
  const cursorName = 'gea_view_cursor';
13
+ const leafText = (ctx, plan, source, target, text) => {
14
+ const key = structuralConversionKey(source, target);
15
+ const node = plan.leaves.get(key);
16
+ if (node === undefined)
17
+ throw new Error(`iterator object view has no certified leaf for ${key}`);
18
+ return namedConversionText(ctx, 'emit-iterator-object-view.ts:certified-leaf', node, text);
19
+ };
12
20
  /** One `IteratorResult` arm built fresh, its `done` and `value` written from the step. */
13
- const resultArmText = (ctx, result, arm, done, value) => {
21
+ const resultArmText = (ctx, plan, result, arm, done, value) => {
14
22
  const record = arm.record.record;
15
23
  if (record.kind !== 'record' && record.kind !== 'native-record-ref')
16
24
  return null;
17
25
  if (record.ownership === 'borrowed')
18
26
  return null;
19
27
  const accessor = memberAccessOperator(record.ownership);
20
- const doneText = alignedValueText(ctx, 'emit-iterator-object-view.ts:done', { kind: 'scalar', domain: 'boolean' }, arm.record.done.value, done ? 'true' : 'false');
21
- const valueText = alignedValueText(ctx, 'emit-iterator-object-view.ts:value', value.source, arm.record.value.value, value.text);
28
+ const doneText = leafText(ctx, plan, { kind: 'scalar', domain: 'boolean' }, arm.record.done.value, done ? 'true' : 'false');
29
+ const valueText = leafText(ctx, plan, value.source, arm.record.value.value, value.text);
22
30
  if (doneText === null || valueText === null)
23
31
  return null;
24
32
  const store = (key, required, text) => `gea_result${accessor}${cppRecordFieldName(key)} = ${text}; ` +
@@ -35,13 +43,12 @@ const resultArmText = (ctx, result, arm, done, value) => {
35
43
  * its own receiver.
36
44
  */
37
45
  export const iteratorObjectViewText = (ctx, source, target, text) => {
38
- if (target.kind === 'optional') {
39
- const present = iteratorObjectViewText(ctx, source, target.payload, text);
40
- return present === null ? null : `${cppTypeOf(target)}(${present})`;
41
- }
42
- const plan = iteratorObjectViewPlanFor(ctx.layouts, source, target);
43
- if (plan === null)
44
- return null;
46
+ const node = ctx.conversions.nodeById(structuralConversionKey(source, target));
47
+ const materializer = node?.capability.kind === 'atom' || node?.capability.kind === 'static' ? node.capability.materializer : null;
48
+ return materializer?.iteratorObjectView === undefined ? null : certifiedIteratorObjectViewText(ctx, materializer.iteratorObjectView, text);
49
+ };
50
+ export const certifiedIteratorObjectViewText = (ctx, certified, text) => {
51
+ const plan = certified.view;
45
52
  const cursorType = cppTypeOf(plan.source);
46
53
  const holderType = `gea::Ref<${cursorType}>`;
47
54
  const structName = cppRecordStructName(plan.target.shapeId);
@@ -65,7 +72,7 @@ export const iteratorObjectViewText = (ctx, source, target, text) => {
65
72
  // through the environment block, which the collector traces
66
73
  // (`HeapEnvironmentBlock`'s `geaTraceRefs`).
67
74
  const held = abi.receiver !== null ? null : `*gea::unpackEnvironment<${recordType}>(gea_view_env, gea_view_slot)`;
68
- const self = alignedValueText(ctx, 'emit-iterator-object-view.ts:self', plan.target, abi.result, held ?? 'gea_view_this');
75
+ const self = leafText(ctx, certified, plan.target, abi.result, held ?? 'gea_view_this');
69
76
  if (self === null)
70
77
  return null;
71
78
  const ignored = abi.parameters.map((_, ordinal) => `(void)gea_view_arg_${ordinal}; `).join('');
@@ -82,8 +89,8 @@ export const iteratorObjectViewText = (ctx, source, target, text) => {
82
89
  ? { source: { kind: 'undefined' }, text: cppUndefinedValue }
83
90
  : { source: plan.source.completion, text: `${cursorName}.takeCompletionValue()` };
84
91
  const generator = plan.source.kind === 'async-generator';
85
- const returned = resultArmText(ctx, planned.settled, planned.returnArm, true, generator && !valueless ? { source: plan.source.completion, text: 'gea_step.completion' } : completion);
86
- const yielded = resultArmText(ctx, planned.settled, planned.yieldArm, false, {
92
+ const returned = resultArmText(ctx, certified, planned.settled, planned.returnArm, true, generator && !valueless ? { source: plan.source.completion, text: 'gea_step.completion' } : completion);
93
+ const yielded = resultArmText(ctx, certified, planned.settled, planned.yieldArm, false, {
87
94
  source: plan.source.element,
88
95
  text: generator ? 'gea_step.value' : 'gea_next'
89
96
  });
@@ -120,6 +127,7 @@ export const iteratorObjectViewText = (ctx, source, target, text) => {
120
127
  if (!field.required)
121
128
  stores.push(`gea_view->${cppRecordFieldPresenceName(field.key)} = true;`);
122
129
  }
123
- return (`([&]() -> ${cppTypeOf(plan.target)} { ${holderType} gea_view_holder = gea::makeRef<${cursorType}>(${text}); ` +
124
- `auto gea_view = gea::makeRef<${structName}>(); ${stores.join(' ')} return gea_view; }())`);
130
+ const built = `([&]() -> ${cppTypeOf(plan.target)} { ${holderType} gea_view_holder = gea::makeRef<${cursorType}>(${text}); ` +
131
+ `auto gea_view = gea::makeRef<${structName}>(); ${stores.join(' ')} return gea_view; }())`;
132
+ return certified.target.kind === 'optional' ? `${cppTypeOf(certified.target)}(${built})` : built;
125
133
  };
@@ -16,6 +16,8 @@ import { type RegionRendering } from './emit-exceptions.js';
16
16
  */
17
17
  export type IteratorCloseRegionRendering = RegionRendering;
18
18
  export declare const emitGetIterator: (ctx: EmitContext, lines: string[], operation: GetIteratorOperation) => void;
19
+ /** IteratorRecord captures next once; later mutations affect return but cannot replace this saved method. */
20
+ export declare const emitIteratorNextMethodCapture: (ctx: EmitContext, lines: string[], operation: GetIteratorOperation) => void;
19
21
  export declare const emitIteratorNext: (ctx: EmitContext, lines: string[], operation: IteratorNextOperation) => void;
20
22
  export declare const emitIteratorDone: (ctx: EmitContext, lines: string[], operation: IteratorDoneOperation) => void;
21
23
  /** Direct IteratorClose; a close failure propagates when no throw completion is already pending. */
@@ -2,6 +2,7 @@ import { representationKey } from '../../representation/model.js';
2
2
  import { nativeEnumerationPlanOf } from '../../ir/native-enumeration.js';
3
3
  import { createCppEmitBlockedError, defineValue, operandText, paddedArguments, suspendsInPlace } from './emit-context.js';
4
4
  import { receiverArgumentText } from './emit-callable.js';
5
+ import { nativeCallReceiverText } from './emit-native-method.js';
5
6
  import { memberAccessOperator } from './emit-carrier-members.js';
6
7
  import { cppRecordFieldName, cppRecordFieldPresenceName, cppBodyName, cppStringLiteral, cppTypeOf, cppUndefinedIn, cppUndefinedValue } from './types.js';
7
8
  import { alignedValueText } from './emit-narrowing.js';
@@ -10,14 +11,14 @@ import { recordAccessorsOfShape, recordFieldsOfShape } from './records.js';
10
11
  import { renderTryRegion } from './emit-exceptions.js';
11
12
  import { awaitTickText, awaitedText, coroutineAwaitStatements } from './prototype/emit-prototype-promise.js';
12
13
  import { accessorEnvironmentArguments } from './emit-properties.js';
14
+ import { nativeFieldViewReadForText } from './emit-native-field-view.js';
13
15
  /**
14
16
  * The settled value of a promise an async iteration step answered: a real
15
17
  * suspension (`co_await`) inside a coroutine frame, and the blocking read only
16
18
  * in a module body's top level -- the one frame `gea::detail::waitForPromise`
17
19
  * admits (`suspendsInPlace`). Every `for await` step in a function body is the
18
- * former: a nested pump there is the mongodb driver's deadlock, where a timer
19
- * fired inside `readMany`'s pump started a loop the pump beneath it never
20
- * returned from.
20
+ * former: a nested pump there deadlocks, where a timer fired inside one pump
21
+ * started a loop the pump beneath it never returned from.
21
22
  */
22
23
  const settledPromiseText = (ctx, promise) => suspendsInPlace(ctx) ? `(co_await ${promise})` : `(${promise}).awaited()`;
23
24
  const isStaticEnumerationTarget = (target) => target.kind === 'record' || target.kind === 'record-with-index' || target.kind === 'class-ref' || target.kind === 'native-record-ref';
@@ -184,10 +185,9 @@ const emitCallableEnumerateIterator = (ctx, lines, operation) => {
184
185
  * cursor that path builds walks the array's ELEMENTS. For `number[]` both
185
186
  * cursors compile, so picking the wrong one is not a compile error -- it is a
186
187
  * program that yields `1, 2, 3` where the language yields `"0", "1", "2"`.
187
- * hono's regexp router is the call site (`for (const i in
188
- * indexReplacementMap)`, with its own comment saying it uses `in` precisely
189
- * because the array is SPARSE), and a values walk would have visited the holes
190
- * it is written to skip.
188
+ * A router that walks a replacement table with `for (const i in map)`
189
+ * precisely because the array is SPARSE is the call site, and a values walk
190
+ * would have visited the holes it is written to skip.
191
191
  *
192
192
  * The snapshot-plus-recheck shape is the one every other `for`-`in` source
193
193
  * here uses, and `gea::arrayOwnEnumerableKeys` was already written for
@@ -281,9 +281,8 @@ const emitDynamicGetIterator = (ctx, lines, operation) => {
281
281
  lines.push(`${name} = ${iteratorMethodCallText(ctx, operandText(ctx, method), method.representation.abi, operation.receiver, 'iterator get-iterator')};`);
282
282
  };
283
283
  /**
284
- * `for`-`of` over a sum of Arrays -- mongodb's `seeds: string[] |
285
- * HostAddress[]` once the Topology constructor has normalized a lone seed --
286
- * or of Arrays and Sets (`isSuperset`'s rebound `string[] | Set<string>`).
284
+ * `for`-`of` over a sum of Arrays -- a `string[] | Address[]` field once a
285
+ * constructor has normalized a lone element into an array -- or of Arrays and Sets (`isSuperset`'s rebound `string[] | Set<string>`).
287
286
  *
288
287
  * Whichever arm is live is an ordinary Array, so its walk is ECMA-262
289
288
  * 23.1.5's index/length cursor over exactly that array, re-reading the length
@@ -305,7 +304,7 @@ const emitSequenceSumIterator = (ctx, lines, operation, source, element) => {
305
304
  const carrier = arm.value;
306
305
  const signature = `std::function<bool(std::size_t, ${elementType}&)>`;
307
306
  if (carrier.kind === 'array-object' && carrier.ownership === 'shared-refcount') {
308
- const read = `(gea_array->present(gea_position) ? gea_array->at(gea_position) : ${cppTypeOf(carrier.element)}{})`;
307
+ const read = `(gea_array->present(gea_position) ? gea_array->readElement(gea_position) : ${cppTypeOf(carrier.element)}{})`;
309
308
  return (`${cursorType}(${signature}([gea_array = gea_sum.template get<${index}>()]` +
310
309
  `(std::size_t gea_position, ${elementType}& gea_out) -> bool { ` +
311
310
  `if (!gea_array || gea_position >= gea_array->size()) return false; gea_out = ${widenedOf(index, carrier.element, read)}; return true; }))`);
@@ -327,6 +326,20 @@ const emitSequenceSumIterator = (ctx, lines, operation, source, element) => {
327
326
  const name = defineValue(ctx, operation.result);
328
327
  lines.push(`${name} = ([](const ${cppTypeOf(source)}& gea_sum) -> ${cursorType} { return ${chain}; })(${operandText(ctx, operation.receiver)});`);
329
328
  };
329
+ /**
330
+ * The cursor over a `split` whose array nothing else reads (`ir/lazy-splits.ts`).
331
+ * It reads the string as the loop runs, so it borrows only a private binding
332
+ * written once -- nothing in the loop can change it -- and takes its own copy
333
+ * of anything else.
334
+ */
335
+ const emitSplitCursor = (ctx, lines, operation, split) => {
336
+ const declaration = split.receiverDeclaration;
337
+ const borrowed = declaration !== null && ctx.stableBorrowActuals.has(split.receiver.value) && (ctx.bindingWriteCounts.get(declaration) ?? 0) === 1;
338
+ const type = 'gea::runtime::string::SplitCursor';
339
+ const name = defineValue(ctx, operation.result, type);
340
+ const receiver = operandText(ctx, split.receiver);
341
+ lines.push(`${name}.${borrowed ? 'borrow' : 'own'}(${receiver}, ${operandText(ctx, split.separator)});`);
342
+ };
330
343
  export const emitGetIterator = (ctx, lines, operation) => {
331
344
  // The general protocol: `receiver[Symbol.iterator]()`, called through the
332
345
  // method value `get-method` already resolved -- see `emitDynamicGetIterator`
@@ -337,6 +350,11 @@ export const emitGetIterator = (ctx, lines, operation) => {
337
350
  emitDynamicGetIterator(ctx, lines, operation);
338
351
  return;
339
352
  }
353
+ const split = ctx.lazySplits.get(operation.receiver.value);
354
+ if (split !== undefined) {
355
+ emitSplitCursor(ctx, lines, operation, split);
356
+ return;
357
+ }
340
358
  const representation = operation.result.representation;
341
359
  // A source explicitly declared `any`/`unknown` owns no static
342
360
  // `[Symbol.iterator]` member to lower. Its record is a `Value`, and the
@@ -622,7 +640,9 @@ export const emitGetIterator = (ctx, lines, operation) => {
622
640
  /** Invoke a protocol method with the iterator as its real ECMAScript receiver. */
623
641
  const iteratorMethodCallText = (ctx, callable, abi, iterator, what) => {
624
642
  const supplied = abi.receiver === null ? [] : [receiverArgumentText(ctx, abi, iterator)];
625
- return `${callable}.call(${paddedArguments(abi, supplied, what).join(', ')})`;
643
+ const argumentsText = paddedArguments(abi, supplied, what);
644
+ const logical = nativeCallReceiverText(iterator.representation, operandText(ctx, iterator));
645
+ return `${callable}.callWithReceiver(${logical}${argumentsText.length === 0 ? '' : `, ${argumentsText.join(', ')}`})`;
626
646
  };
627
647
  /**
628
648
  * A getter is itself a receiver-bearing call and must use its projected ABI
@@ -638,6 +658,55 @@ const iteratorGetterText = (ctx, key, getter, iterator, what) => {
638
658
  const environment = accessorEnvironmentArguments(ctx, iterator.representation, key, getter, 'getter', operandText(ctx, iterator));
639
659
  return `${cppBodyName(getter)}(${[...environment, ...paddedArguments(abi, supplied, `${what} getter`)].join(', ')})`;
640
660
  };
661
+ const iteratorPlainFieldRead = (ctx, iterator, carrier, key, receiverText) => {
662
+ const field = iteratorRecordFieldsOf(ctx, carrier)?.find((entry) => entry.key === key);
663
+ if (field) {
664
+ const access = memberAccessOperator(ownershipOfIteratorRecord(carrier));
665
+ const stored = `${receiverText}${access}${cppRecordFieldName(field.key)}`;
666
+ const absent = cppUndefinedIn(field.value);
667
+ return {
668
+ source: field.value,
669
+ text: field.required
670
+ ? stored
671
+ : absent === null
672
+ ? `([&]() -> ${cppTypeOf(field.value)} { if (!${receiverText}${access}${cppRecordFieldPresenceName(field.key)}) gea::host::throwRuntimeError("TypeError", "an absent protocol slot has no admitted undefined carrier"); return ${stored}; })()`
673
+ : `(${receiverText}${access}${cppRecordFieldPresenceName(field.key)} ? ${stored} : ${absent})`
674
+ };
675
+ }
676
+ const getter = iteratorRecordAccessorsOf(ctx, carrier)?.find((entry) => entry.key === key)?.getter;
677
+ const abi = getter ? ctx.abiOfCallable(getter) : null;
678
+ if (!getter || !abi)
679
+ return null;
680
+ const names = new Map(ctx.valueNames).set(iterator.value, receiverText);
681
+ const deferred = new Map(ctx.deferredTexts);
682
+ deferred.delete(iterator.value);
683
+ const pendingPacks = new Map(ctx.pendingPacks);
684
+ pendingPacks.delete(iterator.value);
685
+ return {
686
+ source: abi.result,
687
+ text: iteratorGetterText({ ...ctx, valueNames: names, deferredTexts: deferred, pendingPacks }, key, getter, { ...iterator, representation: carrier }, 'iterator native field')
688
+ };
689
+ };
690
+ /** Consume the certified internal Get; a live view never reads its inert public fields. */
691
+ const iteratorFieldReadText = (ctx, iterator, receipt) => nativeFieldViewReadForText(ctx, iterator, receipt.value, receipt.read, (carrier) => iteratorPlainFieldRead(ctx, iterator, carrier, receipt.read.key, 'gea_field_receiver'));
692
+ const ownershipOfIteratorRecord = (carrier) => ('ownership' in carrier ? carrier.ownership : 'owned');
693
+ /** IteratorRecord captures next once; later mutations affect return but cannot replace this saved method. */
694
+ export const emitIteratorNextMethodCapture = (ctx, lines, operation) => {
695
+ const carrier = operation.result.representation;
696
+ if (operation.protocol === 'enumerate' || (carrier.kind !== 'record' && carrier.kind !== 'native-record-ref'))
697
+ return;
698
+ const iterator = { value: operation.result.id, representation: carrier };
699
+ const plain = iteratorPlainFieldRead(ctx, iterator, carrier, 'next', operandText(ctx, iterator));
700
+ const receipt = operation.nativeNextMethodRead;
701
+ if (!receipt && !plain)
702
+ throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${carrier.kind}`, 'GetIterator cannot capture its next method');
703
+ const target = receipt?.value ?? plain.source;
704
+ const text = receipt ? iteratorFieldReadText(ctx, iterator, receipt) : plain.text;
705
+ const name = `v${ctx.nextValueOrdinal++}`;
706
+ ctx.declarations.push({ name, type: cppTypeOf(target) });
707
+ lines.push(`${name} = ${text};`);
708
+ ctx.protocolNextMethods.set(iterator.value, name);
709
+ };
641
710
  /**
642
711
  * `next()` whose result is the LIBRARY's own `IteratorResult<T>` union.
643
712
  *
@@ -647,14 +716,8 @@ const iteratorGetterText = (ctx, key, getter, iterator, what) => {
647
716
  * carrying both members, because that is what the protocol reads; an arm that
648
717
  * is not is refused by name rather than defaulted.
649
718
  */
650
- const emitUnionResultIteratorNext = (ctx, lines, operation, iteratorRecord, nextAbi, nextField, nextAccessor, result, awaits) => {
651
- const receiverText = operandText(ctx, operation.iterator);
652
- const receiverAccessor = memberAccessOperator(iteratorRecord.ownership);
653
- const nextText = nextField
654
- ? `${receiverText}${receiverAccessor}${cppRecordFieldName('next')}`
655
- : nextAccessor?.getter
656
- ? iteratorGetterText(ctx, nextAccessor.key, nextAccessor.getter, operation.iterator, 'iterator-next')
657
- : null;
719
+ const emitUnionResultIteratorNext = (ctx, lines, operation, iteratorRecord, nextAbi, result, awaits) => {
720
+ const nextText = ctx.protocolNextMethods.get(operation.iterator.value) ?? null;
658
721
  if (nextText === null)
659
722
  throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, 'cannot resolve the iterator next method');
660
723
  const called = iteratorMethodCallText(ctx, nextText, nextAbi, operation.iterator, 'iterator next()');
@@ -717,7 +780,7 @@ const emitDynamicIteratorNext = (ctx, lines, operation, iteratorRecord) => {
717
780
  // arm is live is the tag, and the read dispatches on it exactly as any
718
781
  // other union member read does.
719
782
  if (resultRepresentation.kind === 'tagged-union') {
720
- emitUnionResultIteratorNext(ctx, lines, operation, iteratorRecord, nextCallable.abi, nextField, nextAccessor, resultRepresentation, awaits);
783
+ emitUnionResultIteratorNext(ctx, lines, operation, iteratorRecord, nextCallable.abi, resultRepresentation, awaits);
721
784
  return;
722
785
  }
723
786
  if ((resultFields === null && resultAccessors === null) ||
@@ -729,13 +792,7 @@ const emitDynamicIteratorNext = (ctx, lines, operation, iteratorRecord) => {
729
792
  if (!hasMember('value') || !hasMember('done')) {
730
793
  throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${resultRepresentation.kind}`, 'calls a "next()" whose result record has no "value"/"done" field pair to read the iteration result out of');
731
794
  }
732
- const receiverText = operandText(ctx, operation.iterator);
733
- const receiverAccessor = memberAccessOperator(iteratorRecord.ownership);
734
- const nextText = nextField
735
- ? `${receiverText}${receiverAccessor}${cppRecordFieldName('next')}`
736
- : nextAccessor?.getter
737
- ? iteratorGetterText(ctx, nextAccessor.key, nextAccessor.getter, operation.iterator, 'iterator-next')
738
- : null;
795
+ const nextText = ctx.protocolNextMethods.get(operation.iterator.value) ?? null;
739
796
  if (nextText === null)
740
797
  throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, 'cannot resolve the iterator next method');
741
798
  const called = iteratorMethodCallText(ctx, nextText, nextCallable.abi, operation.iterator, 'iterator next()');
@@ -893,7 +950,13 @@ export const emitIteratorNext = (ctx, lines, operation) => {
893
950
  const element = iteratorRepresentation.element;
894
951
  const result = operation.result.representation;
895
952
  if (representationKey(result) === representationKey(element)) {
896
- lines.push(`${name} = ${operandText(ctx, operation.iterator)}.arrayNext();`);
953
+ // A string element is stored in place: `name = arrayNext()` copied it out
954
+ // and then moved it in, and libstdc++ moves an inline string with a
955
+ // `memcpy` call on its length.
956
+ if (element.kind === 'string')
957
+ lines.push(`gea::detail::nextInto(${operandText(ctx, operation.iterator)}, ${name});`);
958
+ else
959
+ lines.push(`${name} = ${operandText(ctx, operation.iterator)}.arrayNext();`);
897
960
  return;
898
961
  }
899
962
  // An absence-capable read: the position may lie past the cursor's end, and
@@ -947,7 +1010,7 @@ const staticallyObjectCloseResult = (representation) => {
947
1010
  return representation.kind === 'tagged-union' && representation.arms.every((arm) => staticallyObjectCloseResult(arm.value));
948
1011
  };
949
1012
  /** Statements implementing IteratorClose for either an admitted dynamic value or a concrete typed iterator record. */
950
- const iteratorCloseStatements = (ctx, iterator) => {
1013
+ const iteratorCloseStatements = (ctx, iterator, nativeMethodRead) => {
951
1014
  const representation = iterator.representation;
952
1015
  const receiver = operandText(ctx, iterator);
953
1016
  if (representation.kind === 'dynamic')
@@ -982,31 +1045,36 @@ const iteratorCloseStatements = (ctx, iterator) => {
982
1045
  const fields = iteratorRecordFieldsOf(ctx, representation);
983
1046
  const returnField = fields?.find((field) => field.key === 'return');
984
1047
  const returnAccessor = iteratorRecordAccessorsOf(ctx, representation)?.find((accessor) => accessor.key === 'return');
985
- if (!returnField && !returnAccessor)
1048
+ if (!returnField && !returnAccessor && !nativeMethodRead)
986
1049
  return [];
987
1050
  // `Iterator<T>`'s own `return?(...)` is an OPTIONAL method, so the field's
988
1051
  // carrier is `optional(function-value-dispatch)` for every hand-written
989
1052
  // iterator object that omits it. The payload is the convention to call; the
990
1053
  // optional is a second presence question, answered beside the field's own
991
1054
  // presence bit below rather than refused.
992
- const declared = returnField?.value ?? (returnAccessor?.getter ? ctx.abiOfCallable(returnAccessor.getter)?.result : null);
1055
+ const declared = nativeMethodRead?.value ?? returnField?.value ?? (returnAccessor?.getter ? ctx.abiOfCallable(returnAccessor.getter)?.result : null);
993
1056
  const optionalReturn = declared?.kind === 'optional';
994
1057
  const callable = declared?.kind === 'optional' ? declared.payload : declared;
995
1058
  if (!callable || callable.kind !== 'function-value-dispatch') {
996
1059
  throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${representation.kind}`, `reads a typed iterator return method carried as "${callable?.kind ?? 'absent'}", not a callable dispatch value`);
997
1060
  }
998
1061
  const access = memberAccessOperator(representation.ownership);
999
- const method = returnField
1000
- ? `${optionalReturn ? `(*${receiver}${access}${cppRecordFieldName('return')})` : `${receiver}${access}${cppRecordFieldName('return')}`}`
1001
- : returnAccessor?.getter
1002
- ? iteratorGetterText(ctx, returnAccessor.key, returnAccessor.getter, iterator, 'iterator-close')
1003
- : null;
1062
+ const method = nativeMethodRead
1063
+ ? optionalReturn
1064
+ ? '(*gea_return_method)'
1065
+ : 'gea_return_method'
1066
+ : returnField
1067
+ ? `${optionalReturn ? `(*${receiver}${access}${cppRecordFieldName('return')})` : `${receiver}${access}${cppRecordFieldName('return')}`}`
1068
+ : returnAccessor?.getter
1069
+ ? iteratorGetterText(ctx, returnAccessor.key, returnAccessor.getter, iterator, 'iterator-close')
1070
+ : null;
1004
1071
  if (method === null)
1005
1072
  throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${representation.kind}`, 'cannot resolve the iterator return method');
1006
1073
  const called = iteratorMethodCallText(ctx, method, callable.abi, iterator, 'iterator return()');
1007
1074
  // An async iterator's `return()` answers a promise of the record, and
1008
1075
  // AsyncIteratorClose awaits it (7.4.13 step 5) before checking the record:
1009
- // mongodb's `onData.return()` resolves only once its listeners are gone.
1076
+ // an event-stream iterator's `return()` resolves only once its listeners
1077
+ // are gone.
1010
1078
  // Only async iteration reaches a promise here, for the reason
1011
1079
  // `emitDynamicIteratorNext` gives about `next`.
1012
1080
  const awaitsClose = callable.abi.result.kind === 'promise';
@@ -1017,6 +1085,10 @@ const iteratorCloseStatements = (ctx, iterator) => {
1017
1085
  : staticallyObjectCloseResult(result)
1018
1086
  ? `(void)(${call});`
1019
1087
  : `{ (void)(${call}); gea::runtime::iterator::throwNotIterable("iterator return method returned a non-object value"); }`;
1088
+ if (nativeMethodRead) {
1089
+ const read = iteratorFieldReadText(ctx, iterator, nativeMethodRead);
1090
+ return [`{ const auto gea_return_method = ${read}; ${optionalReturn ? `if (gea_return_method.has_value()) { ${invoke} }` : invoke} }`];
1091
+ }
1020
1092
  if (!returnField)
1021
1093
  return [invoke];
1022
1094
  const guards = [
@@ -1027,8 +1099,8 @@ const iteratorCloseStatements = (ctx, iterator) => {
1027
1099
  return [invoke];
1028
1100
  return [`if (${guards.join(' && ')}) { ${invoke} }`];
1029
1101
  };
1030
- const iteratorCloseWhileOpenStatements = (ctx, iterator, onlyIfOpen) => {
1031
- const close = iteratorCloseStatements(ctx, iterator);
1102
+ const iteratorCloseWhileOpenStatements = (ctx, iterator, onlyIfOpen, nativeMethodRead) => {
1103
+ const close = iteratorCloseStatements(ctx, iterator, nativeMethodRead);
1032
1104
  if (!onlyIfOpen || close.length === 0)
1033
1105
  return close;
1034
1106
  const representation = iterator.representation;
@@ -1049,7 +1121,7 @@ const iteratorCloseWhileOpenStatements = (ctx, iterator, onlyIfOpen) => {
1049
1121
  };
1050
1122
  /** Direct IteratorClose; a close failure propagates when no throw completion is already pending. */
1051
1123
  export const emitIteratorClose = (ctx, lines, operation) => {
1052
- lines.push(...iteratorCloseWhileOpenStatements(ctx, operation.iterator, operation.onlyIfOpen));
1124
+ lines.push(...iteratorCloseWhileOpenStatements(ctx, operation.iterator, operation.onlyIfOpen, operation.nativeMethodRead));
1053
1125
  };
1054
1126
  /**
1055
1127
  * Whether this iterator's IteratorClose suspends in place: a `for await` in a
@@ -1107,7 +1179,7 @@ const renderSuspendingIteratorCloseRegion = (ctx, lines, body, region, rendering
1107
1179
  const nestedConsumed = new Set();
1108
1180
  const armed = `${guard}_armed`;
1109
1181
  const thrown = `${guard}_thrown`;
1110
- const close = iteratorCloseStatements(ctx, region.iterator).join(' ');
1182
+ const close = iteratorCloseStatements(ctx, region.iterator, region.nativeMethodRead).join(' ');
1111
1183
  const closeNow = `if (${armed}) { ${armed} = false; ${close} }`;
1112
1184
  const splitEntry = region.bodyEntry !== null &&
1113
1185
  region.bodyEntry !== region.entry &&
@@ -1231,7 +1303,7 @@ export const renderIteratorCloseRegion = (ctx, lines, body, region, rendering) =
1231
1303
  return renderSuspendingIteratorCloseRegion(ctx, lines, body, region, rendering, order, guard);
1232
1304
  lines.push(`${rendering.labelOf(rendering.labels, region.entry)}:`);
1233
1305
  lines.push('{');
1234
- const close = iteratorCloseWhileOpenStatements(ctx, region.iterator, region.onlyIfOpen);
1306
+ const close = iteratorCloseWhileOpenStatements(ctx, region.iterator, region.onlyIfOpen, region.nativeMethodRead);
1235
1307
  lines.push(`gea::runtime::iterator::CompletionGuard ${guard}{[&]() { ${close.join(' ')} }};`);
1236
1308
  // Which half of the region a throw came from. 14.7.5.7 closes for a throw
1237
1309
  // out of the BODY and not for one out of the step -- see