@geastack/compiler 1.0.15

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 (966) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +149 -0
  3. package/dist/cli-analyze.d.ts +1 -0
  4. package/dist/cli-analyze.js +61 -0
  5. package/dist/cli-coverage.d.ts +1 -0
  6. package/dist/cli-coverage.js +329 -0
  7. package/dist/cli-emit.d.ts +10 -0
  8. package/dist/cli-emit.js +398 -0
  9. package/dist/cli-module-graph.d.ts +18 -0
  10. package/dist/cli-module-graph.js +123 -0
  11. package/dist/cli-package-source.d.ts +5 -0
  12. package/dist/cli-package-source.js +116 -0
  13. package/dist/cli-project.d.ts +2 -0
  14. package/dist/cli-project.js +60 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +199 -0
  17. package/dist/compiler.d.ts +228 -0
  18. package/dist/compiler.js +1029 -0
  19. package/dist/conversion/algebra.d.ts +218 -0
  20. package/dist/conversion/algebra.js +155 -0
  21. package/dist/conversion/build.d.ts +67 -0
  22. package/dist/conversion/build.js +1378 -0
  23. package/dist/conversion/derive.d.ts +37 -0
  24. package/dist/conversion/derive.js +260 -0
  25. package/dist/conversion/graph-validation.d.ts +8 -0
  26. package/dist/conversion/graph-validation.js +97 -0
  27. package/dist/conversion/native-callable-adapter.d.ts +13 -0
  28. package/dist/conversion/native-callable-adapter.js +53 -0
  29. package/dist/conversion/native-class-reference.d.ts +12 -0
  30. package/dist/conversion/native-class-reference.js +39 -0
  31. package/dist/conversion/native-payload-transport.d.ts +25 -0
  32. package/dist/conversion/native-payload-transport.js +33 -0
  33. package/dist/conversion/native-selection.d.ts +49 -0
  34. package/dist/conversion/native-selection.js +135 -0
  35. package/dist/conversion/native-sum.d.ts +42 -0
  36. package/dist/conversion/native-sum.js +115 -0
  37. package/dist/conversion/nodes.d.ts +55 -0
  38. package/dist/conversion/nodes.js +91 -0
  39. package/dist/conversion/operand-view.d.ts +14 -0
  40. package/dist/conversion/operand-view.js +20 -0
  41. package/dist/conversion/record-view.d.ts +157 -0
  42. package/dist/conversion/record-view.js +273 -0
  43. package/dist/conversion/registry.d.ts +217 -0
  44. package/dist/conversion/registry.js +1 -0
  45. package/dist/diagnostics/model.d.ts +76 -0
  46. package/dist/diagnostics/model.js +60 -0
  47. package/dist/diagnostics/sweep.d.ts +31 -0
  48. package/dist/diagnostics/sweep.js +112 -0
  49. package/dist/identity/ids.d.ts +179 -0
  50. package/dist/identity/ids.js +212 -0
  51. package/dist/ir/absent-class-arm.d.ts +48 -0
  52. package/dist/ir/absent-class-arm.js +157 -0
  53. package/dist/ir/borrow-effects.d.ts +23 -0
  54. package/dist/ir/borrow-effects.js +151 -0
  55. package/dist/ir/borrowed-call-arguments.d.ts +40 -0
  56. package/dist/ir/borrowed-call-arguments.js +117 -0
  57. package/dist/ir/build.d.ts +168 -0
  58. package/dist/ir/build.js +459 -0
  59. package/dist/ir/call-dispatch.d.ts +38 -0
  60. package/dist/ir/call-dispatch.js +502 -0
  61. package/dist/ir/call-entry.d.ts +142 -0
  62. package/dist/ir/call-entry.js +386 -0
  63. package/dist/ir/callable-class-flow.d.ts +27 -0
  64. package/dist/ir/callable-class-flow.js +1386 -0
  65. package/dist/ir/callable-field-slots.d.ts +22 -0
  66. package/dist/ir/callable-field-slots.js +166 -0
  67. package/dist/ir/callable-identity-demand.d.ts +52 -0
  68. package/dist/ir/callable-identity-demand.js +460 -0
  69. package/dist/ir/callable-member-candidates.d.ts +9 -0
  70. package/dist/ir/callable-member-candidates.js +39 -0
  71. package/dist/ir/callable-records.d.ts +21 -0
  72. package/dist/ir/callable-records.js +411 -0
  73. package/dist/ir/captures.d.ts +26 -0
  74. package/dist/ir/captures.js +335 -0
  75. package/dist/ir/certificate.d.ts +45 -0
  76. package/dist/ir/certificate.js +47 -0
  77. package/dist/ir/certify/carrier-keys.d.ts +73 -0
  78. package/dist/ir/certify/carrier-keys.js +221 -0
  79. package/dist/ir/certify/function-source.d.ts +4 -0
  80. package/dist/ir/certify/function-source.js +28 -0
  81. package/dist/ir/certify/has-property-key.d.ts +88 -0
  82. package/dist/ir/certify/has-property-key.js +116 -0
  83. package/dist/ir/certify/instanceof-key.d.ts +24 -0
  84. package/dist/ir/certify/instanceof-key.js +35 -0
  85. package/dist/ir/certify/property-access-keys.d.ts +172 -0
  86. package/dist/ir/certify/property-access-keys.js +291 -0
  87. package/dist/ir/certify/property-access.d.ts +3 -0
  88. package/dist/ir/certify/property-access.js +597 -0
  89. package/dist/ir/certify/runtime-helper.d.ts +3 -0
  90. package/dist/ir/certify/runtime-helper.js +326 -0
  91. package/dist/ir/certify/typeof-operand.d.ts +14 -0
  92. package/dist/ir/certify/typeof-operand.js +16 -0
  93. package/dist/ir/certify.d.ts +123 -0
  94. package/dist/ir/certify.js +481 -0
  95. package/dist/ir/class-evaluation.d.ts +26 -0
  96. package/dist/ir/class-evaluation.js +50 -0
  97. package/dist/ir/class-static-fields.d.ts +60 -0
  98. package/dist/ir/class-static-fields.js +108 -0
  99. package/dist/ir/construct-entry.d.ts +26 -0
  100. package/dist/ir/construct-entry.js +117 -0
  101. package/dist/ir/dead-values.d.ts +90 -0
  102. package/dist/ir/dead-values.js +184 -0
  103. package/dist/ir/deferral.d.ts +99 -0
  104. package/dist/ir/deferral.js +409 -0
  105. package/dist/ir/dense-loops.d.ts +230 -0
  106. package/dist/ir/dense-loops.js +697 -0
  107. package/dist/ir/dominance.d.ts +82 -0
  108. package/dist/ir/dominance.js +268 -0
  109. package/dist/ir/emission-representations.d.ts +71 -0
  110. package/dist/ir/emission-representations.js +350 -0
  111. package/dist/ir/facts.d.ts +218 -0
  112. package/dist/ir/facts.js +181 -0
  113. package/dist/ir/fixed-data-definition.d.ts +19 -0
  114. package/dist/ir/fixed-data-definition.js +49 -0
  115. package/dist/ir/generator-split.d.ts +38 -0
  116. package/dist/ir/generator-split.js +329 -0
  117. package/dist/ir/hoist.d.ts +55 -0
  118. package/dist/ir/hoist.js +375 -0
  119. package/dist/ir/instantiation.d.ts +61 -0
  120. package/dist/ir/instantiation.js +137 -0
  121. package/dist/ir/integer-storage.d.ts +170 -0
  122. package/dist/ir/integer-storage.js +822 -0
  123. package/dist/ir/integers.d.ts +161 -0
  124. package/dist/ir/integers.js +539 -0
  125. package/dist/ir/integrity-restrictions.d.ts +50 -0
  126. package/dist/ir/integrity-restrictions.js +118 -0
  127. package/dist/ir/local-iterators.d.ts +4 -0
  128. package/dist/ir/local-iterators.js +27 -0
  129. package/dist/ir/lower-allocation.d.ts +4 -0
  130. package/dist/ir/lower-allocation.js +325 -0
  131. package/dist/ir/lower-completion.d.ts +15 -0
  132. package/dist/ir/lower-completion.js +25 -0
  133. package/dist/ir/lower-destructuring.d.ts +5 -0
  134. package/dist/ir/lower-destructuring.js +693 -0
  135. package/dist/ir/lower-element.d.ts +29 -0
  136. package/dist/ir/lower-element.js +111 -0
  137. package/dist/ir/lower-exceptions.d.ts +47 -0
  138. package/dist/ir/lower-exceptions.js +92 -0
  139. package/dist/ir/lower-flow.d.ts +137 -0
  140. package/dist/ir/lower-flow.js +600 -0
  141. package/dist/ir/lower-graph.d.ts +218 -0
  142. package/dist/ir/lower-graph.js +687 -0
  143. package/dist/ir/lower-invocation.d.ts +4 -0
  144. package/dist/ir/lower-invocation.js +514 -0
  145. package/dist/ir/lower-narrow.d.ts +53 -0
  146. package/dist/ir/lower-narrow.js +320 -0
  147. package/dist/ir/lower-operands.d.ts +272 -0
  148. package/dist/ir/lower-operands.js +461 -0
  149. package/dist/ir/lower-property.d.ts +21 -0
  150. package/dist/ir/lower-property.js +132 -0
  151. package/dist/ir/lower-protocol.d.ts +11 -0
  152. package/dist/ir/lower-protocol.js +118 -0
  153. package/dist/ir/lower-short-circuit.d.ts +41 -0
  154. package/dist/ir/lower-short-circuit.js +63 -0
  155. package/dist/ir/lower.d.ts +82 -0
  156. package/dist/ir/lower.js +1346 -0
  157. package/dist/ir/model.d.ts +1474 -0
  158. package/dist/ir/model.js +6 -0
  159. package/dist/ir/native-absent-property.d.ts +3 -0
  160. package/dist/ir/native-absent-property.js +13 -0
  161. package/dist/ir/native-array-transport.d.ts +7 -0
  162. package/dist/ir/native-array-transport.js +46 -0
  163. package/dist/ir/native-callable-bind.d.ts +9 -0
  164. package/dist/ir/native-callable-bind.js +30 -0
  165. package/dist/ir/native-carrier-predicate.d.ts +34 -0
  166. package/dist/ir/native-carrier-predicate.js +49 -0
  167. package/dist/ir/native-class-accessor.d.ts +18 -0
  168. package/dist/ir/native-class-accessor.js +52 -0
  169. package/dist/ir/native-class-construction.d.ts +16 -0
  170. package/dist/ir/native-class-construction.js +71 -0
  171. package/dist/ir/native-class-initialization.d.ts +15 -0
  172. package/dist/ir/native-class-initialization.js +56 -0
  173. package/dist/ir/native-class-origins.d.ts +13 -0
  174. package/dist/ir/native-class-origins.js +237 -0
  175. package/dist/ir/native-dictionary-transport.d.ts +6 -0
  176. package/dist/ir/native-dictionary-transport.js +37 -0
  177. package/dist/ir/native-enumeration.d.ts +14 -0
  178. package/dist/ir/native-enumeration.js +26 -0
  179. package/dist/ir/native-equality.d.ts +10 -0
  180. package/dist/ir/native-equality.js +18 -0
  181. package/dist/ir/native-field-owner.d.ts +37 -0
  182. package/dist/ir/native-field-owner.js +183 -0
  183. package/dist/ir/native-fixed-layout.d.ts +41 -0
  184. package/dist/ir/native-fixed-layout.js +232 -0
  185. package/dist/ir/native-host-construction.d.ts +53 -0
  186. package/dist/ir/native-host-construction.js +62 -0
  187. package/dist/ir/native-key-query.d.ts +4 -0
  188. package/dist/ir/native-key-query.js +38 -0
  189. package/dist/ir/native-merge-transport.d.ts +25 -0
  190. package/dist/ir/native-merge-transport.js +71 -0
  191. package/dist/ir/native-record-index-transport.d.ts +11 -0
  192. package/dist/ir/native-record-index-transport.js +34 -0
  193. package/dist/ir/native-record-index.d.ts +12 -0
  194. package/dist/ir/native-record-index.js +27 -0
  195. package/dist/ir/native-reflect-field.d.ts +5 -0
  196. package/dist/ir/native-reflect-field.js +33 -0
  197. package/dist/ir/native-sequence-transport.d.ts +7 -0
  198. package/dist/ir/native-sequence-transport.js +53 -0
  199. package/dist/ir/numeric-intrinsics.d.ts +13 -0
  200. package/dist/ir/numeric-intrinsics.js +57 -0
  201. package/dist/ir/object-value-conversions.d.ts +20 -0
  202. package/dist/ir/object-value-conversions.js +50 -0
  203. package/dist/ir/physical-class-reflection.d.ts +9 -0
  204. package/dist/ir/physical-class-reflection.js +57 -0
  205. package/dist/ir/presence-proof.d.ts +42 -0
  206. package/dist/ir/presence-proof.js +490 -0
  207. package/dist/ir/program-facts.d.ts +106 -0
  208. package/dist/ir/program-facts.js +319 -0
  209. package/dist/ir/proven-branches.d.ts +16 -0
  210. package/dist/ir/proven-branches.js +219 -0
  211. package/dist/ir/queries.d.ts +41 -0
  212. package/dist/ir/queries.js +213 -0
  213. package/dist/ir/reflection-demand.d.ts +64 -0
  214. package/dist/ir/reflection-demand.js +1394 -0
  215. package/dist/ir/refusal.d.ts +43 -0
  216. package/dist/ir/refusal.js +28 -0
  217. package/dist/ir/shake.d.ts +37 -0
  218. package/dist/ir/shake.js +1078 -0
  219. package/dist/ir/static-callables.d.ts +11 -0
  220. package/dist/ir/static-callables.js +163 -0
  221. package/dist/ir/string-layout-reuse.d.ts +13 -0
  222. package/dist/ir/string-layout-reuse.js +39 -0
  223. package/dist/ir/string-length-reuse.d.ts +8 -0
  224. package/dist/ir/string-length-reuse.js +47 -0
  225. package/dist/ir/transfer.d.ts +78 -0
  226. package/dist/ir/transfer.js +270 -0
  227. package/dist/ir/type-query-results.d.ts +25 -0
  228. package/dist/ir/type-query-results.js +96 -0
  229. package/dist/ir/typed-property-access.d.ts +100 -0
  230. package/dist/ir/typed-property-access.js +161 -0
  231. package/dist/ir/verify.d.ts +19 -0
  232. package/dist/ir/verify.js +355 -0
  233. package/dist/plugins/apple/constructors.d.ts +112 -0
  234. package/dist/plugins/apple/constructors.js +217 -0
  235. package/dist/plugins/apple/host.d.ts +181 -0
  236. package/dist/plugins/apple/host.js +262 -0
  237. package/dist/plugins/apple/jsx.d.ts +2 -0
  238. package/dist/plugins/apple/jsx.js +293 -0
  239. package/dist/plugins/apple/members.d.ts +16 -0
  240. package/dist/plugins/apple/members.js +190 -0
  241. package/dist/plugins/apple/plugin.d.ts +2 -0
  242. package/dist/plugins/apple/plugin.js +156 -0
  243. package/dist/plugins/gea/component-classes.d.ts +25 -0
  244. package/dist/plugins/gea/component-classes.js +162 -0
  245. package/dist/plugins/gea/component-inline.d.ts +13 -0
  246. package/dist/plugins/gea/component-inline.js +532 -0
  247. package/dist/plugins/gea/constructors.d.ts +23 -0
  248. package/dist/plugins/gea/constructors.js +100 -0
  249. package/dist/plugins/gea/contract.d.ts +150 -0
  250. package/dist/plugins/gea/contract.js +195 -0
  251. package/dist/plugins/gea/element-ref.d.ts +31 -0
  252. package/dist/plugins/gea/element-ref.js +45 -0
  253. package/dist/plugins/gea/host.d.ts +520 -0
  254. package/dist/plugins/gea/host.js +762 -0
  255. package/dist/plugins/gea/lower.d.ts +6 -0
  256. package/dist/plugins/gea/lower.js +195 -0
  257. package/dist/plugins/gea/members.d.ts +22 -0
  258. package/dist/plugins/gea/members.js +221 -0
  259. package/dist/plugins/gea/plugin.d.ts +22 -0
  260. package/dist/plugins/gea/plugin.js +307 -0
  261. package/dist/plugins/gea/prelude.d.ts +78 -0
  262. package/dist/plugins/gea/prelude.js +153 -0
  263. package/dist/plugins/gea/producer.d.ts +5 -0
  264. package/dist/plugins/gea/producer.js +52 -0
  265. package/dist/plugins/gea/reactive-slots.d.ts +49 -0
  266. package/dist/plugins/gea/reactive-slots.js +578 -0
  267. package/dist/plugins/gea/render-bridge.d.ts +6 -0
  268. package/dist/plugins/gea/render-bridge.js +281 -0
  269. package/dist/plugins/gea/slots.d.ts +15 -0
  270. package/dist/plugins/gea/slots.js +36 -0
  271. package/dist/plugins/gea/template-analysis.d.ts +151 -0
  272. package/dist/plugins/gea/template-analysis.js +346 -0
  273. package/dist/plugins/gea/user-agent-styles.d.ts +9 -0
  274. package/dist/plugins/gea/user-agent-styles.js +94 -0
  275. package/dist/plugins/installed.d.ts +19 -0
  276. package/dist/plugins/installed.js +21 -0
  277. package/dist/plugins/load.d.ts +7 -0
  278. package/dist/plugins/load.js +207 -0
  279. package/dist/plugins/model.d.ts +735 -0
  280. package/dist/plugins/model.js +47 -0
  281. package/dist/plugins/webgl/host.d.ts +77 -0
  282. package/dist/plugins/webgl/host.js +162 -0
  283. package/dist/plugins/webgl/plugin.d.ts +40 -0
  284. package/dist/plugins/webgl/plugin.js +99 -0
  285. package/dist/preflight/obligations.d.ts +206 -0
  286. package/dist/preflight/obligations.js +36 -0
  287. package/dist/preflight/report.d.ts +20 -0
  288. package/dist/preflight/report.js +61 -0
  289. package/dist/preflight/run.d.ts +39 -0
  290. package/dist/preflight/run.js +403 -0
  291. package/dist/project-preparation.d.ts +33 -0
  292. package/dist/project-preparation.js +314 -0
  293. package/dist/projection/abi.d.ts +82 -0
  294. package/dist/projection/abi.js +349 -0
  295. package/dist/projection/apply-arguments.d.ts +12 -0
  296. package/dist/projection/apply-arguments.js +20 -0
  297. package/dist/projection/bindings.d.ts +250 -0
  298. package/dist/projection/bindings.js +340 -0
  299. package/dist/projection/callee.d.ts +196 -0
  300. package/dist/projection/callee.js +444 -0
  301. package/dist/projection/class-property-presence.d.ts +28 -0
  302. package/dist/projection/class-property-presence.js +58 -0
  303. package/dist/projection/class-prototype.d.ts +5 -0
  304. package/dist/projection/class-prototype.js +23 -0
  305. package/dist/projection/class-storage.d.ts +26 -0
  306. package/dist/projection/class-storage.js +236 -0
  307. package/dist/projection/classes.d.ts +283 -0
  308. package/dist/projection/classes.js +944 -0
  309. package/dist/projection/coercions.d.ts +20 -0
  310. package/dist/projection/coercions.js +33 -0
  311. package/dist/projection/dispatch.d.ts +167 -0
  312. package/dist/projection/dispatch.js +379 -0
  313. package/dist/projection/fields.d.ts +123 -0
  314. package/dist/projection/fields.js +383 -0
  315. package/dist/projection/instance-test.d.ts +78 -0
  316. package/dist/projection/instance-test.js +156 -0
  317. package/dist/projection/slots.d.ts +146 -0
  318. package/dist/projection/slots.js +663 -0
  319. package/dist/projection/synthesized-abi.d.ts +61 -0
  320. package/dist/projection/synthesized-abi.js +94 -0
  321. package/dist/representation/array-index.d.ts +14 -0
  322. package/dist/representation/array-index.js +17 -0
  323. package/dist/representation/callable-object.d.ts +3 -0
  324. package/dist/representation/callable-object.js +6 -0
  325. package/dist/representation/collections.d.ts +84 -0
  326. package/dist/representation/collections.js +139 -0
  327. package/dist/representation/derive.d.ts +159 -0
  328. package/dist/representation/derive.js +2546 -0
  329. package/dist/representation/difference.d.ts +30 -0
  330. package/dist/representation/difference.js +240 -0
  331. package/dist/representation/field-descriptor-policy.d.ts +19 -0
  332. package/dist/representation/field-descriptor-policy.js +39 -0
  333. package/dist/representation/function-constructor.d.ts +13 -0
  334. package/dist/representation/function-constructor.js +9 -0
  335. package/dist/representation/host-abi.d.ts +32 -0
  336. package/dist/representation/host-abi.js +97 -0
  337. package/dist/representation/host-templates.d.ts +67 -0
  338. package/dist/representation/host-templates.js +94 -0
  339. package/dist/representation/intersection.d.ts +84 -0
  340. package/dist/representation/intersection.js +149 -0
  341. package/dist/representation/literal-destination.d.ts +43 -0
  342. package/dist/representation/literal-destination.js +133 -0
  343. package/dist/representation/merge.d.ts +18 -0
  344. package/dist/representation/merge.js +83 -0
  345. package/dist/representation/model.d.ts +1160 -0
  346. package/dist/representation/model.js +1019 -0
  347. package/dist/representation/numeric-index.d.ts +13 -0
  348. package/dist/representation/numeric-index.js +29 -0
  349. package/dist/representation/object-shape.d.ts +109 -0
  350. package/dist/representation/object-shape.js +123 -0
  351. package/dist/representation/optional.d.ts +12 -0
  352. package/dist/representation/optional.js +87 -0
  353. package/dist/representation/plan.d.ts +60 -0
  354. package/dist/representation/plan.js +78 -0
  355. package/dist/representation/policies.d.ts +589 -0
  356. package/dist/representation/policies.js +107 -0
  357. package/dist/representation/primitive-domain.d.ts +1 -0
  358. package/dist/representation/primitive-domain.js +1 -0
  359. package/dist/representation/primitives.d.ts +44 -0
  360. package/dist/representation/primitives.js +78 -0
  361. package/dist/representation/publish.d.ts +49 -0
  362. package/dist/representation/publish.js +648 -0
  363. package/dist/representation/record-fields.d.ts +96 -0
  364. package/dist/representation/record-fields.js +116 -0
  365. package/dist/representation/template-object.d.ts +11 -0
  366. package/dist/representation/template-object.js +26 -0
  367. package/dist/representation/union.d.ts +30 -0
  368. package/dist/representation/union.js +324 -0
  369. package/dist/representation/value-records.d.ts +3 -0
  370. package/dist/representation/value-records.js +307 -0
  371. package/dist/representation/verify.d.ts +17 -0
  372. package/dist/representation/verify.js +221 -0
  373. package/dist/semantics/alias-this-field-declaration-transform.d.ts +4 -0
  374. package/dist/semantics/alias-this-field-declaration-transform.js +207 -0
  375. package/dist/semantics/ambient-type-realization-transform.d.ts +62 -0
  376. package/dist/semantics/ambient-type-realization-transform.js +168 -0
  377. package/dist/semantics/ambient.d.ts +24 -0
  378. package/dist/semantics/ambient.js +119 -0
  379. package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +4 -0
  380. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +341 -0
  381. package/dist/semantics/callable-origins.d.ts +46 -0
  382. package/dist/semantics/callable-origins.js +354 -0
  383. package/dist/semantics/class-alias.d.ts +7 -0
  384. package/dist/semantics/class-alias.js +37 -0
  385. package/dist/semantics/class-heritage.d.ts +34 -0
  386. package/dist/semantics/class-heritage.js +104 -0
  387. package/dist/semantics/commonjs-wrapper.d.ts +69 -0
  388. package/dist/semantics/commonjs-wrapper.js +231 -0
  389. package/dist/semantics/constructor-slot-subclasses.d.ts +28 -0
  390. package/dist/semantics/constructor-slot-subclasses.js +112 -0
  391. package/dist/semantics/declaration-overlay-transform.d.ts +35 -0
  392. package/dist/semantics/declaration-overlay-transform.js +2157 -0
  393. package/dist/semantics/define-property-source-transform.d.ts +4 -0
  394. package/dist/semantics/define-property-source-transform.js +437 -0
  395. package/dist/semantics/diagnostic-source-preparation.d.ts +24 -0
  396. package/dist/semantics/diagnostic-source-preparation.js +82 -0
  397. package/dist/semantics/documentation-ranges.d.ts +22 -0
  398. package/dist/semantics/documentation-ranges.js +36 -0
  399. package/dist/semantics/dynamic-fallback.d.ts +86 -0
  400. package/dist/semantics/dynamic-fallback.js +249 -0
  401. package/dist/semantics/frontend-timing.d.ts +6 -0
  402. package/dist/semantics/frontend-timing.js +35 -0
  403. package/dist/semantics/frontend.d.ts +504 -0
  404. package/dist/semantics/frontend.js +1157 -0
  405. package/dist/semantics/host-declaration-provenance.d.ts +11 -0
  406. package/dist/semantics/host-declaration-provenance.js +18 -0
  407. package/dist/semantics/host-methods.d.ts +24 -0
  408. package/dist/semantics/host-methods.js +74 -0
  409. package/dist/semantics/host-protocols.d.ts +429 -0
  410. package/dist/semantics/host-protocols.js +1501 -0
  411. package/dist/semantics/inherited-accessor.d.ts +7 -0
  412. package/dist/semantics/inherited-accessor.js +48 -0
  413. package/dist/semantics/interface-families.d.ts +70 -0
  414. package/dist/semantics/interface-families.js +180 -0
  415. package/dist/semantics/interface-implementors.d.ts +53 -0
  416. package/dist/semantics/interface-implementors.js +87 -0
  417. package/dist/semantics/jsdoc-namepath-transform.d.ts +4 -0
  418. package/dist/semantics/jsdoc-namepath-transform.js +85 -0
  419. package/dist/semantics/model/coverage.d.ts +68 -0
  420. package/dist/semantics/model/coverage.js +73 -0
  421. package/dist/semantics/model/edges.d.ts +103 -0
  422. package/dist/semantics/model/edges.js +20 -0
  423. package/dist/semantics/model/graph.d.ts +55 -0
  424. package/dist/semantics/model/graph.js +129 -0
  425. package/dist/semantics/model/operands.d.ts +159 -0
  426. package/dist/semantics/model/operands.js +26 -0
  427. package/dist/semantics/model/operations.d.ts +496 -0
  428. package/dist/semantics/model/operations.js +2 -0
  429. package/dist/semantics/model/primitive-domain.d.ts +26 -0
  430. package/dist/semantics/model/primitive-domain.js +38 -0
  431. package/dist/semantics/model/selected-signature.d.ts +261 -0
  432. package/dist/semantics/model/selected-signature.js +55 -0
  433. package/dist/semantics/model/structural-type-table.d.ts +93 -0
  434. package/dist/semantics/model/structural-type-table.js +237 -0
  435. package/dist/semantics/model/structural-types.d.ts +367 -0
  436. package/dist/semantics/model/structural-types.js +200 -0
  437. package/dist/semantics/module-resolution.d.ts +23 -0
  438. package/dist/semantics/module-resolution.js +227 -0
  439. package/dist/semantics/new-callee-class-tag-source-transform.d.ts +4 -0
  440. package/dist/semantics/new-callee-class-tag-source-transform.js +64 -0
  441. package/dist/semantics/node-project.d.ts +13 -0
  442. package/dist/semantics/node-project.js +107 -0
  443. package/dist/semantics/node-source-hooks.d.ts +1 -0
  444. package/dist/semantics/node-source-hooks.js +63 -0
  445. package/dist/semantics/normalize/absent-globals.d.ts +143 -0
  446. package/dist/semantics/normalize/absent-globals.js +191 -0
  447. package/dist/semantics/normalize/arguments-objects.d.ts +43 -0
  448. package/dist/semantics/normalize/arguments-objects.js +60 -0
  449. package/dist/semantics/normalize/asserted-arm-absence.d.ts +28 -0
  450. package/dist/semantics/normalize/asserted-arm-absence.js +61 -0
  451. package/dist/semantics/normalize/assignment-patterns.d.ts +70 -0
  452. package/dist/semantics/normalize/assignment-patterns.js +147 -0
  453. package/dist/semantics/normalize/bag-absence.d.ts +8 -0
  454. package/dist/semantics/normalize/bag-absence.js +42 -0
  455. package/dist/semantics/normalize/binding-fixpoint.d.ts +36 -0
  456. package/dist/semantics/normalize/binding-fixpoint.js +140 -0
  457. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +16 -0
  458. package/dist/semantics/normalize/callback-parameter-contracts.js +91 -0
  459. package/dist/semantics/normalize/cells/agreement.d.ts +46 -0
  460. package/dist/semantics/normalize/cells/agreement.js +34 -0
  461. package/dist/semantics/normalize/cells/candidates.d.ts +17 -0
  462. package/dist/semantics/normalize/cells/candidates.js +35 -0
  463. package/dist/semantics/normalize/cells/facts.d.ts +19 -0
  464. package/dist/semantics/normalize/cells/facts.js +90 -0
  465. package/dist/semantics/normalize/cells/index.d.ts +10 -0
  466. package/dist/semantics/normalize/cells/index.js +6 -0
  467. package/dist/semantics/normalize/cells/model.d.ts +98 -0
  468. package/dist/semantics/normalize/cells/model.js +2 -0
  469. package/dist/semantics/normalize/cells/policies/bag.d.ts +44 -0
  470. package/dist/semantics/normalize/cells/policies/bag.js +114 -0
  471. package/dist/semantics/normalize/cells/policies/collection.d.ts +42 -0
  472. package/dist/semantics/normalize/cells/policies/collection.js +218 -0
  473. package/dist/semantics/normalize/cells/policies/field.d.ts +28 -0
  474. package/dist/semantics/normalize/cells/policies/field.js +40 -0
  475. package/dist/semantics/normalize/cells/policies/index.d.ts +49 -0
  476. package/dist/semantics/normalize/cells/policies/index.js +58 -0
  477. package/dist/semantics/normalize/cells/policies/local.d.ts +18 -0
  478. package/dist/semantics/normalize/cells/policies/local.js +37 -0
  479. package/dist/semantics/normalize/cells/policies/parameter.d.ts +28 -0
  480. package/dist/semantics/normalize/cells/policies/parameter.js +39 -0
  481. package/dist/semantics/normalize/cells/policies/return.d.ts +26 -0
  482. package/dist/semantics/normalize/cells/policies/return.js +45 -0
  483. package/dist/semantics/normalize/cells/policies/shared.d.ts +33 -0
  484. package/dist/semantics/normalize/cells/policies/shared.js +45 -0
  485. package/dist/semantics/normalize/cells/policy.d.ts +72 -0
  486. package/dist/semantics/normalize/cells/policy.js +18 -0
  487. package/dist/semantics/normalize/cells/registry.d.ts +14 -0
  488. package/dist/semantics/normalize/cells/registry.js +17 -0
  489. package/dist/semantics/normalize/census-refusal.d.ts +62 -0
  490. package/dist/semantics/normalize/census-refusal.js +27 -0
  491. package/dist/semantics/normalize/census.d.ts +109 -0
  492. package/dist/semantics/normalize/census.js +667 -0
  493. package/dist/semantics/normalize/collection-bindings.d.ts +278 -0
  494. package/dist/semantics/normalize/collection-bindings.js +677 -0
  495. package/dist/semantics/normalize/commonjs-module-record.d.ts +21 -0
  496. package/dist/semantics/normalize/commonjs-module-record.js +289 -0
  497. package/dist/semantics/normalize/commonjs-require.d.ts +13 -0
  498. package/dist/semantics/normalize/commonjs-require.js +1527 -0
  499. package/dist/semantics/normalize/contribution.d.ts +63 -0
  500. package/dist/semantics/normalize/contribution.js +172 -0
  501. package/dist/semantics/normalize/dead-typeof-guards.d.ts +64 -0
  502. package/dist/semantics/normalize/dead-typeof-guards.js +152 -0
  503. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +57 -0
  504. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +109 -0
  505. package/dist/semantics/normalize/derived-expression-type.d.ts +1070 -0
  506. package/dist/semantics/normalize/derived-expression-type.js +3463 -0
  507. package/dist/semantics/normalize/evaluation-order.d.ts +16 -0
  508. package/dist/semantics/normalize/evaluation-order.js +37 -0
  509. package/dist/semantics/normalize/field-bindings.d.ts +167 -0
  510. package/dist/semantics/normalize/field-bindings.js +1125 -0
  511. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +27 -0
  512. package/dist/semantics/normalize/flow/array-element-continuation.js +1452 -0
  513. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +42 -0
  514. package/dist/semantics/normalize/flow/callable-array-origins.js +318 -0
  515. package/dist/semantics/normalize/flow/callable-completions.d.ts +45 -0
  516. package/dist/semantics/normalize/flow/callable-completions.js +82 -0
  517. package/dist/semantics/normalize/flow/callable-reach.d.ts +237 -0
  518. package/dist/semantics/normalize/flow/callable-reach.js +7174 -0
  519. package/dist/semantics/normalize/flow/class-family-member-read.d.ts +16 -0
  520. package/dist/semantics/normalize/flow/class-family-member-read.js +992 -0
  521. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +21 -0
  522. package/dist/semantics/normalize/flow/collection-value-continuation.js +192 -0
  523. package/dist/semantics/normalize/flow/component-solver.d.ts +199 -0
  524. package/dist/semantics/normalize/flow/component-solver.js +587 -0
  525. package/dist/semantics/normalize/flow/computed-key-set.d.ts +84 -0
  526. package/dist/semantics/normalize/flow/computed-key-set.js +660 -0
  527. package/dist/semantics/normalize/flow/export-importers.d.ts +24 -0
  528. package/dist/semantics/normalize/flow/export-importers.js +269 -0
  529. package/dist/semantics/normalize/flow/host-text-sink.d.ts +25 -0
  530. package/dist/semantics/normalize/flow/host-text-sink.js +87 -0
  531. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +84 -0
  532. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +180 -0
  533. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +35 -0
  534. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +140 -0
  535. package/dist/semantics/normalize/flow/invocation-facts.d.ts +98 -0
  536. package/dist/semantics/normalize/flow/invocation-facts.js +257 -0
  537. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +122 -0
  538. package/dist/semantics/normalize/flow/member-call-forwarding.js +835 -0
  539. package/dist/semantics/normalize/flow/model.d.ts +357 -0
  540. package/dist/semantics/normalize/flow/model.js +177 -0
  541. package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +24 -0
  542. package/dist/semantics/normalize/flow/native-collection-protocol.js +252 -0
  543. package/dist/semantics/normalize/flow/node-path-token.d.ts +3 -0
  544. package/dist/semantics/normalize/flow/node-path-token.js +53 -0
  545. package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +11 -0
  546. package/dist/semantics/normalize/flow/object-binding-continuation.js +42 -0
  547. package/dist/semantics/normalize/flow/origin-authority.d.ts +56 -0
  548. package/dist/semantics/normalize/flow/origin-authority.js +2 -0
  549. package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +35 -0
  550. package/dist/semantics/normalize/flow/owned-class-receivers.js +191 -0
  551. package/dist/semantics/normalize/flow/parameter-values.d.ts +27 -0
  552. package/dist/semantics/normalize/flow/parameter-values.js +251 -0
  553. package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +66 -0
  554. package/dist/semantics/normalize/flow/proof-hypotheses.js +162 -0
  555. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +27 -0
  556. package/dist/semantics/normalize/flow/record-alias-closure.js +298 -0
  557. package/dist/semantics/normalize/flow/seeded-origins.d.ts +43 -0
  558. package/dist/semantics/normalize/flow/seeded-origins.js +54 -0
  559. package/dist/semantics/normalize/flow/source-class-data.d.ts +132 -0
  560. package/dist/semantics/normalize/flow/source-class-data.js +838 -0
  561. package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +13 -0
  562. package/dist/semantics/normalize/flow/source-class-instanceof.js +37 -0
  563. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +16 -0
  564. package/dist/semantics/normalize/flow/source-class-static-data.js +47 -0
  565. package/dist/semantics/normalize/flow/source-construction-frames.d.ts +12 -0
  566. package/dist/semantics/normalize/flow/source-construction-frames.js +118 -0
  567. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +34 -0
  568. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +78 -0
  569. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +37 -0
  570. package/dist/semantics/normalize/flow/source-invocation-receiver.js +95 -0
  571. package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +23 -0
  572. package/dist/semantics/normalize/flow/source-prototype-method-identity.js +81 -0
  573. package/dist/semantics/normalize/flow/source-record-data.d.ts +29 -0
  574. package/dist/semantics/normalize/flow/source-record-data.js +626 -0
  575. package/dist/semantics/normalize/flow/source-value-session.d.ts +77 -0
  576. package/dist/semantics/normalize/flow/source-value-session.js +3089 -0
  577. package/dist/semantics/normalize/flow/targets.d.ts +118 -0
  578. package/dist/semantics/normalize/flow/targets.js +405 -0
  579. package/dist/semantics/normalize/flow/value-flow.d.ts +36 -0
  580. package/dist/semantics/normalize/flow/value-flow.js +823 -0
  581. package/dist/semantics/normalize/flow/value-provenance.d.ts +31 -0
  582. package/dist/semantics/normalize/flow/value-provenance.js +112 -0
  583. package/dist/semantics/normalize/gating.d.ts +51 -0
  584. package/dist/semantics/normalize/gating.js +560 -0
  585. package/dist/semantics/normalize/generic-function-choice.d.ts +31 -0
  586. package/dist/semantics/normalize/generic-function-choice.js +115 -0
  587. package/dist/semantics/normalize/global-host-mutations.d.ts +51 -0
  588. package/dist/semantics/normalize/global-host-mutations.js +5989 -0
  589. package/dist/semantics/normalize/host-effect-contracts.d.ts +77 -0
  590. package/dist/semantics/normalize/host-effect-contracts.js +143 -0
  591. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +38 -0
  592. package/dist/semantics/normalize/host-mutation-computed-keys.js +26 -0
  593. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +66 -0
  594. package/dist/semantics/normalize/host-mutation-key-reader.js +192 -0
  595. package/dist/semantics/normalize/host-mutation-keys.d.ts +114 -0
  596. package/dist/semantics/normalize/host-mutation-keys.js +183 -0
  597. package/dist/semantics/normalize/identities.d.ts +172 -0
  598. package/dist/semantics/normalize/identities.js +426 -0
  599. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +97 -0
  600. package/dist/semantics/normalize/implicit-arguments-tuple.js +197 -0
  601. package/dist/semantics/normalize/implicit-arguments.d.ts +11 -0
  602. package/dist/semantics/normalize/implicit-arguments.js +39 -0
  603. package/dist/semantics/normalize/instantiation.d.ts +73 -0
  604. package/dist/semantics/normalize/instantiation.js +399 -0
  605. package/dist/semantics/normalize/intrinsic-property-call.d.ts +18 -0
  606. package/dist/semantics/normalize/intrinsic-property-call.js +69 -0
  607. package/dist/semantics/normalize/intrinsic-prototype.d.ts +41 -0
  608. package/dist/semantics/normalize/intrinsic-prototype.js +87 -0
  609. package/dist/semantics/normalize/intrinsic-static-member.d.ts +14 -0
  610. package/dist/semantics/normalize/intrinsic-static-member.js +23 -0
  611. package/dist/semantics/normalize/jsdoc-type-names.d.ts +32 -0
  612. package/dist/semantics/normalize/jsdoc-type-names.js +512 -0
  613. package/dist/semantics/normalize/keyof.d.ts +32 -0
  614. package/dist/semantics/normalize/keyof.js +110 -0
  615. package/dist/semantics/normalize/local-bindings.d.ts +176 -0
  616. package/dist/semantics/normalize/local-bindings.js +1826 -0
  617. package/dist/semantics/normalize/logical-result-type.d.ts +16 -0
  618. package/dist/semantics/normalize/logical-result-type.js +102 -0
  619. package/dist/semantics/normalize/namespace-paths.d.ts +57 -0
  620. package/dist/semantics/normalize/namespace-paths.js +108 -0
  621. package/dist/semantics/normalize/normalize.d.ts +57 -0
  622. package/dist/semantics/normalize/normalize.js +68 -0
  623. package/dist/semantics/normalize/object-bag-bindings.d.ts +305 -0
  624. package/dist/semantics/normalize/object-bag-bindings.js +1290 -0
  625. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +53 -0
  626. package/dist/semantics/normalize/omitted-stated-parameter.js +59 -0
  627. package/dist/semantics/normalize/open-type-form.d.ts +10 -0
  628. package/dist/semantics/normalize/open-type-form.js +32 -0
  629. package/dist/semantics/normalize/parameter-bindings.d.ts +361 -0
  630. package/dist/semantics/normalize/parameter-bindings.js +3339 -0
  631. package/dist/semantics/normalize/parameter-slot.d.ts +264 -0
  632. package/dist/semantics/normalize/parameter-slot.js +491 -0
  633. package/dist/semantics/normalize/physical-overload-result.d.ts +77 -0
  634. package/dist/semantics/normalize/physical-overload-result.js +99 -0
  635. package/dist/semantics/normalize/primitive-property-absence.d.ts +12 -0
  636. package/dist/semantics/normalize/primitive-property-absence.js +60 -0
  637. package/dist/semantics/normalize/producer-context.d.ts +376 -0
  638. package/dist/semantics/normalize/producer-context.js +1 -0
  639. package/dist/semantics/normalize/producers/allocations.d.ts +3 -0
  640. package/dist/semantics/normalize/producers/allocations.js +863 -0
  641. package/dist/semantics/normalize/producers/binding-kind.d.ts +37 -0
  642. package/dist/semantics/normalize/producers/binding-kind.js +36 -0
  643. package/dist/semantics/normalize/producers/bindings.d.ts +85 -0
  644. package/dist/semantics/normalize/producers/bindings.js +710 -0
  645. package/dist/semantics/normalize/producers/boundary.d.ts +34 -0
  646. package/dist/semantics/normalize/producers/boundary.js +123 -0
  647. package/dist/semantics/normalize/producers/class-lifecycle.d.ts +3 -0
  648. package/dist/semantics/normalize/producers/class-lifecycle.js +902 -0
  649. package/dist/semantics/normalize/producers/computations.d.ts +3 -0
  650. package/dist/semantics/normalize/producers/computations.js +613 -0
  651. package/dist/semantics/normalize/producers/control-loops.d.ts +30 -0
  652. package/dist/semantics/normalize/producers/control-loops.js +91 -0
  653. package/dist/semantics/normalize/producers/control.d.ts +30 -0
  654. package/dist/semantics/normalize/producers/control.js +923 -0
  655. package/dist/semantics/normalize/producers/declaration-lifecycle.d.ts +3 -0
  656. package/dist/semantics/normalize/producers/declaration-lifecycle.js +390 -0
  657. package/dist/semantics/normalize/producers/destructuring.d.ts +45 -0
  658. package/dist/semantics/normalize/producers/destructuring.js +1180 -0
  659. package/dist/semantics/normalize/producers/dynamic-language.d.ts +3 -0
  660. package/dist/semantics/normalize/producers/dynamic-language.js +70 -0
  661. package/dist/semantics/normalize/producers/erasure.d.ts +51 -0
  662. package/dist/semantics/normalize/producers/erasure.js +90 -0
  663. package/dist/semantics/normalize/producers/installed.d.ts +3 -0
  664. package/dist/semantics/normalize/producers/installed.js +55 -0
  665. package/dist/semantics/normalize/producers/invocations.d.ts +35 -0
  666. package/dist/semantics/normalize/producers/invocations.js +1796 -0
  667. package/dist/semantics/normalize/producers/iteration-yield.d.ts +59 -0
  668. package/dist/semantics/normalize/producers/iteration-yield.js +235 -0
  669. package/dist/semantics/normalize/producers/jsx.d.ts +3 -0
  670. package/dist/semantics/normalize/producers/jsx.js +360 -0
  671. package/dist/semantics/normalize/producers/mint.d.ts +39 -0
  672. package/dist/semantics/normalize/producers/mint.js +44 -0
  673. package/dist/semantics/normalize/producers/nullish.d.ts +16 -0
  674. package/dist/semantics/normalize/producers/nullish.js +27 -0
  675. package/dist/semantics/normalize/producers/object-assignment.d.ts +8 -0
  676. package/dist/semantics/normalize/producers/object-assignment.js +204 -0
  677. package/dist/semantics/normalize/producers/object-tag.d.ts +9 -0
  678. package/dist/semantics/normalize/producers/object-tag.js +119 -0
  679. package/dist/semantics/normalize/producers/optional-chain.d.ts +44 -0
  680. package/dist/semantics/normalize/producers/optional-chain.js +75 -0
  681. package/dist/semantics/normalize/producers/properties.d.ts +21 -0
  682. package/dist/semantics/normalize/producers/properties.js +1053 -0
  683. package/dist/semantics/normalize/producers/protocol.d.ts +67 -0
  684. package/dist/semantics/normalize/producers/protocol.js +695 -0
  685. package/dist/semantics/normalize/producers/references.d.ts +53 -0
  686. package/dist/semantics/normalize/producers/references.js +1027 -0
  687. package/dist/semantics/normalize/producers/shared.d.ts +561 -0
  688. package/dist/semantics/normalize/producers/shared.js +1683 -0
  689. package/dist/semantics/normalize/producers/spread-arguments.d.ts +72 -0
  690. package/dist/semantics/normalize/producers/spread-arguments.js +375 -0
  691. package/dist/semantics/normalize/producers/tagged-template.d.ts +5 -0
  692. package/dist/semantics/normalize/producers/tagged-template.js +307 -0
  693. package/dist/semantics/normalize/producers/tuple-spread.d.ts +189 -0
  694. package/dist/semantics/normalize/producers/tuple-spread.js +279 -0
  695. package/dist/semantics/normalize/property-key-domain.d.ts +36 -0
  696. package/dist/semantics/normalize/property-key-domain.js +150 -0
  697. package/dist/semantics/normalize/reachability.d.ts +189 -0
  698. package/dist/semantics/normalize/reachability.js +1057 -0
  699. package/dist/semantics/normalize/reassigned-bindings.d.ts +13 -0
  700. package/dist/semantics/normalize/reassigned-bindings.js +41 -0
  701. package/dist/semantics/normalize/record-storage-families.d.ts +11 -0
  702. package/dist/semantics/normalize/record-storage-families.js +109 -0
  703. package/dist/semantics/normalize/return-bindings.d.ts +260 -0
  704. package/dist/semantics/normalize/return-bindings.js +1311 -0
  705. package/dist/semantics/normalize/return-paths.d.ts +2 -0
  706. package/dist/semantics/normalize/return-paths.js +28 -0
  707. package/dist/semantics/normalize/script-global-redefinition.d.ts +44 -0
  708. package/dist/semantics/normalize/script-global-redefinition.js +75 -0
  709. package/dist/semantics/normalize/specialization.d.ts +201 -0
  710. package/dist/semantics/normalize/specialization.js +1824 -0
  711. package/dist/semantics/normalize/structural-array-element.d.ts +176 -0
  712. package/dist/semantics/normalize/structural-array-element.js +700 -0
  713. package/dist/semantics/normalize/structural-array-read.d.ts +13 -0
  714. package/dist/semantics/normalize/structural-array-read.js +124 -0
  715. package/dist/semantics/normalize/structural-callable.d.ts +12 -0
  716. package/dist/semantics/normalize/structural-callable.js +82 -0
  717. package/dist/semantics/normalize/structural-creation-order.d.ts +32 -0
  718. package/dist/semantics/normalize/structural-creation-order.js +111 -0
  719. package/dist/semantics/normalize/structural-declarations.d.ts +395 -0
  720. package/dist/semantics/normalize/structural-declarations.js +968 -0
  721. package/dist/semantics/normalize/structural-declared-body.d.ts +25 -0
  722. package/dist/semantics/normalize/structural-declared-body.js +147 -0
  723. package/dist/semantics/normalize/structural-generics.d.ts +56 -0
  724. package/dist/semantics/normalize/structural-generics.js +120 -0
  725. package/dist/semantics/normalize/structural-indexed-access.d.ts +11 -0
  726. package/dist/semantics/normalize/structural-indexed-access.js +126 -0
  727. package/dist/semantics/normalize/structural-instantiated-member.d.ts +64 -0
  728. package/dist/semantics/normalize/structural-instantiated-member.js +407 -0
  729. package/dist/semantics/normalize/structural-joins.d.ts +44 -0
  730. package/dist/semantics/normalize/structural-joins.js +143 -0
  731. package/dist/semantics/normalize/structural-layout-relevance.d.ts +29 -0
  732. package/dist/semantics/normalize/structural-layout-relevance.js +391 -0
  733. package/dist/semantics/normalize/structural-layout-type.d.ts +11 -0
  734. package/dist/semantics/normalize/structural-layout-type.js +1468 -0
  735. package/dist/semantics/normalize/structural-leaves.d.ts +49 -0
  736. package/dist/semantics/normalize/structural-leaves.js +125 -0
  737. package/dist/semantics/normalize/structural-local-union.d.ts +13 -0
  738. package/dist/semantics/normalize/structural-local-union.js +133 -0
  739. package/dist/semantics/normalize/structural-members.d.ts +26 -0
  740. package/dist/semantics/normalize/structural-members.js +84 -0
  741. package/dist/semantics/normalize/structural-mutable-method.d.ts +15 -0
  742. package/dist/semantics/normalize/structural-mutable-method.js +109 -0
  743. package/dist/semantics/normalize/structural-parts.d.ts +131 -0
  744. package/dist/semantics/normalize/structural-parts.js +737 -0
  745. package/dist/semantics/normalize/structural-receiver.d.ts +66 -0
  746. package/dist/semantics/normalize/structural-receiver.js +551 -0
  747. package/dist/semantics/normalize/structural-rules.d.ts +112 -0
  748. package/dist/semantics/normalize/structural-rules.js +93 -0
  749. package/dist/semantics/normalize/structural-self-reference.d.ts +150 -0
  750. package/dist/semantics/normalize/structural-self-reference.js +494 -0
  751. package/dist/semantics/normalize/structural.d.ts +202 -0
  752. package/dist/semantics/normalize/structural.js +4218 -0
  753. package/dist/semantics/normalize/unreduced-type-form.d.ts +41 -0
  754. package/dist/semantics/normalize/unreduced-type-form.js +53 -0
  755. package/dist/semantics/normalize/unresolvable-names.d.ts +56 -0
  756. package/dist/semantics/normalize/unresolvable-names.js +140 -0
  757. package/dist/semantics/package-sources.d.ts +16 -0
  758. package/dist/semantics/package-sources.js +365 -0
  759. package/dist/semantics/program.d.ts +151 -0
  760. package/dist/semantics/program.js +667 -0
  761. package/dist/semantics/prototype-install-source-transform.d.ts +4 -0
  762. package/dist/semantics/prototype-install-source-transform.js +341 -0
  763. package/dist/semantics/prototype-object-class-source-transform.d.ts +4 -0
  764. package/dist/semantics/prototype-object-class-source-transform.js +525 -0
  765. package/dist/semantics/prototype-reparenting.d.ts +50 -0
  766. package/dist/semantics/prototype-reparenting.js +317 -0
  767. package/dist/semantics/stable-checker.d.ts +10 -0
  768. package/dist/semantics/stable-checker.js +148 -0
  769. package/dist/semantics/subclass-member-overlay-transform.d.ts +35 -0
  770. package/dist/semantics/subclass-member-overlay-transform.js +1418 -0
  771. package/dist/semantics/symbol-keyed-expando-source-transform.d.ts +4 -0
  772. package/dist/semantics/symbol-keyed-expando-source-transform.js +66 -0
  773. package/dist/semantics/this-constructor-source-transform.d.ts +4 -0
  774. package/dist/semantics/this-constructor-source-transform.js +122 -0
  775. package/dist/semantics/uninstantiable-classes.d.ts +22 -0
  776. package/dist/semantics/uninstantiable-classes.js +75 -0
  777. package/dist/targets/cpp/balanced-units.d.ts +3 -0
  778. package/dist/targets/cpp/balanced-units.js +58 -0
  779. package/dist/targets/cpp/borrowed-call-entry.d.ts +30 -0
  780. package/dist/targets/cpp/borrowed-call-entry.js +68 -0
  781. package/dist/targets/cpp/captures.d.ts +68 -0
  782. package/dist/targets/cpp/captures.js +269 -0
  783. package/dist/targets/cpp/class-layout.d.ts +313 -0
  784. package/dist/targets/cpp/class-layout.js +483 -0
  785. package/dist/targets/cpp/class-properties/computed-method-value.d.ts +25 -0
  786. package/dist/targets/cpp/class-properties/computed-method-value.js +22 -0
  787. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +216 -0
  788. package/dist/targets/cpp/class-properties/emit-class-properties.js +917 -0
  789. package/dist/targets/cpp/class-properties/native-prototype.d.ts +11 -0
  790. package/dist/targets/cpp/class-properties/native-prototype.js +101 -0
  791. package/dist/targets/cpp/class-ref-transport.d.ts +12 -0
  792. package/dist/targets/cpp/class-ref-transport.js +32 -0
  793. package/dist/targets/cpp/conversions.d.ts +3 -0
  794. package/dist/targets/cpp/conversions.js +2027 -0
  795. package/dist/targets/cpp/deferral-safety.d.ts +82 -0
  796. package/dist/targets/cpp/deferral-safety.js +86 -0
  797. package/dist/targets/cpp/direct-call-receivers.d.ts +37 -0
  798. package/dist/targets/cpp/direct-call-receivers.js +79 -0
  799. package/dist/targets/cpp/document.d.ts +74 -0
  800. package/dist/targets/cpp/document.js +106 -0
  801. package/dist/targets/cpp/emit-allocation.d.ts +60 -0
  802. package/dist/targets/cpp/emit-allocation.js +573 -0
  803. package/dist/targets/cpp/emit-arrays.d.ts +119 -0
  804. package/dist/targets/cpp/emit-arrays.js +1047 -0
  805. package/dist/targets/cpp/emit-binding-reference.d.ts +17 -0
  806. package/dist/targets/cpp/emit-binding-reference.js +120 -0
  807. package/dist/targets/cpp/emit-bindings.d.ts +158 -0
  808. package/dist/targets/cpp/emit-bindings.js +769 -0
  809. package/dist/targets/cpp/emit-buffers.d.ts +156 -0
  810. package/dist/targets/cpp/emit-buffers.js +573 -0
  811. package/dist/targets/cpp/emit-callable.d.ts +230 -0
  812. package/dist/targets/cpp/emit-callable.js +2154 -0
  813. package/dist/targets/cpp/emit-carrier-members.d.ts +406 -0
  814. package/dist/targets/cpp/emit-carrier-members.js +1224 -0
  815. package/dist/targets/cpp/emit-coercion.d.ts +26 -0
  816. package/dist/targets/cpp/emit-coercion.js +39 -0
  817. package/dist/targets/cpp/emit-context.d.ts +1882 -0
  818. package/dist/targets/cpp/emit-context.js +904 -0
  819. package/dist/targets/cpp/emit-dynamic-properties.d.ts +174 -0
  820. package/dist/targets/cpp/emit-dynamic-properties.js +1249 -0
  821. package/dist/targets/cpp/emit-equality.d.ts +39 -0
  822. package/dist/targets/cpp/emit-equality.js +472 -0
  823. package/dist/targets/cpp/emit-exceptions.d.ts +104 -0
  824. package/dist/targets/cpp/emit-exceptions.js +513 -0
  825. package/dist/targets/cpp/emit-field-owner.d.ts +4 -0
  826. package/dist/targets/cpp/emit-field-owner.js +27 -0
  827. package/dist/targets/cpp/emit-in.d.ts +31 -0
  828. package/dist/targets/cpp/emit-in.js +426 -0
  829. package/dist/targets/cpp/emit-instanceof.d.ts +19 -0
  830. package/dist/targets/cpp/emit-instanceof.js +601 -0
  831. package/dist/targets/cpp/emit-integers.d.ts +68 -0
  832. package/dist/targets/cpp/emit-integers.js +184 -0
  833. package/dist/targets/cpp/emit-iterator.d.ts +100 -0
  834. package/dist/targets/cpp/emit-iterator.js +1137 -0
  835. package/dist/targets/cpp/emit-json.d.ts +73 -0
  836. package/dist/targets/cpp/emit-json.js +823 -0
  837. package/dist/targets/cpp/emit-jsx.d.ts +74 -0
  838. package/dist/targets/cpp/emit-jsx.js +806 -0
  839. package/dist/targets/cpp/emit-mixed-binary.d.ts +51 -0
  840. package/dist/targets/cpp/emit-mixed-binary.js +60 -0
  841. package/dist/targets/cpp/emit-namespaces.d.ts +101 -0
  842. package/dist/targets/cpp/emit-namespaces.js +133 -0
  843. package/dist/targets/cpp/emit-narrowing.d.ts +738 -0
  844. package/dist/targets/cpp/emit-narrowing.js +3967 -0
  845. package/dist/targets/cpp/emit-native-equality.d.ts +3 -0
  846. package/dist/targets/cpp/emit-native-equality.js +14 -0
  847. package/dist/targets/cpp/emit-native-selection.d.ts +5 -0
  848. package/dist/targets/cpp/emit-native-selection.js +37 -0
  849. package/dist/targets/cpp/emit-object-tag.d.ts +4 -0
  850. package/dist/targets/cpp/emit-object-tag.js +108 -0
  851. package/dist/targets/cpp/emit-owned-record.d.ts +2 -0
  852. package/dist/targets/cpp/emit-owned-record.js +15 -0
  853. package/dist/targets/cpp/emit-presence.d.ts +78 -0
  854. package/dist/targets/cpp/emit-presence.js +376 -0
  855. package/dist/targets/cpp/emit-properties.d.ts +105 -0
  856. package/dist/targets/cpp/emit-properties.js +1640 -0
  857. package/dist/targets/cpp/emit-record-view.d.ts +20 -0
  858. package/dist/targets/cpp/emit-record-view.js +354 -0
  859. package/dist/targets/cpp/emit-return.d.ts +5 -0
  860. package/dist/targets/cpp/emit-return.js +237 -0
  861. package/dist/targets/cpp/emit-sum-widening.d.ts +10 -0
  862. package/dist/targets/cpp/emit-sum-widening.js +69 -0
  863. package/dist/targets/cpp/emit-tonumber.d.ts +38 -0
  864. package/dist/targets/cpp/emit-tonumber.js +177 -0
  865. package/dist/targets/cpp/emit-tostring.d.ts +92 -0
  866. package/dist/targets/cpp/emit-tostring.js +556 -0
  867. package/dist/targets/cpp/emit-typeof.d.ts +49 -0
  868. package/dist/targets/cpp/emit-typeof.js +317 -0
  869. package/dist/targets/cpp/emit-union-properties.d.ts +181 -0
  870. package/dist/targets/cpp/emit-union-properties.js +1281 -0
  871. package/dist/targets/cpp/emit.d.ts +45 -0
  872. package/dist/targets/cpp/emit.js +2225 -0
  873. package/dist/targets/cpp/error-types.d.ts +4 -0
  874. package/dist/targets/cpp/error-types.js +11 -0
  875. package/dist/targets/cpp/function-source-reads.d.ts +72 -0
  876. package/dist/targets/cpp/function-source-reads.js +148 -0
  877. package/dist/targets/cpp/host/atomics.d.ts +25 -0
  878. package/dist/targets/cpp/host/atomics.js +63 -0
  879. package/dist/targets/cpp/host/core-globals.d.ts +108 -0
  880. package/dist/targets/cpp/host/core-globals.js +158 -0
  881. package/dist/targets/cpp/host/dynamic-argument-members.d.ts +42 -0
  882. package/dist/targets/cpp/host/dynamic-argument-members.js +61 -0
  883. package/dist/targets/cpp/host/emit-host-arity.d.ts +139 -0
  884. package/dist/targets/cpp/host/emit-host-arity.js +232 -0
  885. package/dist/targets/cpp/host/emit-host-invoke.d.ts +91 -0
  886. package/dist/targets/cpp/host/emit-host-invoke.js +1105 -0
  887. package/dist/targets/cpp/host/emit-host-object.d.ts +55 -0
  888. package/dist/targets/cpp/host/emit-host-object.js +2206 -0
  889. package/dist/targets/cpp/host/emit-host-properties.d.ts +69 -0
  890. package/dist/targets/cpp/host/emit-host-properties.js +533 -0
  891. package/dist/targets/cpp/host/emit-host-reflect.d.ts +4 -0
  892. package/dist/targets/cpp/host/emit-host-reflect.js +180 -0
  893. package/dist/targets/cpp/host/emit-host-value.d.ts +120 -0
  894. package/dist/targets/cpp/host/emit-host-value.js +392 -0
  895. package/dist/targets/cpp/host/host-members.d.ts +505 -0
  896. package/dist/targets/cpp/host/host-members.js +819 -0
  897. package/dist/targets/cpp/host/host-method-aliases.d.ts +30 -0
  898. package/dist/targets/cpp/host/host-method-aliases.js +76 -0
  899. package/dist/targets/cpp/host/native-protocols.d.ts +47 -0
  900. package/dist/targets/cpp/host/native-protocols.js +183 -0
  901. package/dist/targets/cpp/host/object-protocol.d.ts +351 -0
  902. package/dist/targets/cpp/host/object-protocol.js +671 -0
  903. package/dist/targets/cpp/host-namespace-reads.d.ts +83 -0
  904. package/dist/targets/cpp/host-namespace-reads.js +113 -0
  905. package/dist/targets/cpp/manifest/capabilities.d.ts +39 -0
  906. package/dist/targets/cpp/manifest/capabilities.js +1484 -0
  907. package/dist/targets/cpp/manifest.d.ts +23 -0
  908. package/dist/targets/cpp/manifest.js +113 -0
  909. package/dist/targets/cpp/native-error-base.d.ts +38 -0
  910. package/dist/targets/cpp/native-error-base.js +74 -0
  911. package/dist/targets/cpp/native-narrowing-transport.d.ts +12 -0
  912. package/dist/targets/cpp/native-narrowing-transport.js +151 -0
  913. package/dist/targets/cpp/native-selection-helpers.d.ts +11 -0
  914. package/dist/targets/cpp/native-selection-helpers.js +46 -0
  915. package/dist/targets/cpp/native-symbol-keys.d.ts +8 -0
  916. package/dist/targets/cpp/native-symbol-keys.js +34 -0
  917. package/dist/targets/cpp/ownership.d.ts +43 -0
  918. package/dist/targets/cpp/ownership.js +38 -0
  919. package/dist/targets/cpp/owning-conversion-input.d.ts +14 -0
  920. package/dist/targets/cpp/owning-conversion-input.js +12 -0
  921. package/dist/targets/cpp/property-read-claims.d.ts +62 -0
  922. package/dist/targets/cpp/property-read-claims.js +23 -0
  923. package/dist/targets/cpp/property-store-claims.d.ts +62 -0
  924. package/dist/targets/cpp/property-store-claims.js +26 -0
  925. package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +111 -0
  926. package/dist/targets/cpp/prototype/emit-prototype-array.js +602 -0
  927. package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +133 -0
  928. package/dist/targets/cpp/prototype/emit-prototype-date.js +515 -0
  929. package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +13 -0
  930. package/dist/targets/cpp/prototype/emit-prototype-error.js +54 -0
  931. package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +34 -0
  932. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +1003 -0
  933. package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +47 -0
  934. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +250 -0
  935. package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +46 -0
  936. package/dist/targets/cpp/prototype/emit-prototype-promise.js +143 -0
  937. package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +335 -0
  938. package/dist/targets/cpp/prototype/emit-prototype-regexp.js +853 -0
  939. package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +42 -0
  940. package/dist/targets/cpp/prototype/emit-prototype-string.js +252 -0
  941. package/dist/targets/cpp/prototype/prototype-method-reads.d.ts +25 -0
  942. package/dist/targets/cpp/prototype/prototype-method-reads.js +182 -0
  943. package/dist/targets/cpp/reactive-dependencies.d.ts +140 -0
  944. package/dist/targets/cpp/reactive-dependencies.js +432 -0
  945. package/dist/targets/cpp/reactive-origins.d.ts +44 -0
  946. package/dist/targets/cpp/reactive-origins.js +82 -0
  947. package/dist/targets/cpp/records.d.ts +277 -0
  948. package/dist/targets/cpp/records.js +2427 -0
  949. package/dist/targets/cpp/recursive-containers.d.ts +43 -0
  950. package/dist/targets/cpp/recursive-containers.js +144 -0
  951. package/dist/targets/cpp/regexp-types.d.ts +56 -0
  952. package/dist/targets/cpp/regexp-types.js +59 -0
  953. package/dist/targets/cpp/substrate.d.ts +125 -0
  954. package/dist/targets/cpp/substrate.js +12 -0
  955. package/dist/targets/cpp/translation-unit.d.ts +219 -0
  956. package/dist/targets/cpp/translation-unit.js +2063 -0
  957. package/dist/targets/cpp/types.d.ts +280 -0
  958. package/dist/targets/cpp/types.js +1135 -0
  959. package/dist/targets/cpp/virtual-methods.d.ts +95 -0
  960. package/dist/targets/cpp/virtual-methods.js +264 -0
  961. package/package.json +95 -0
  962. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +824 -0
  963. package/src/targets/cpp/runtime/gea_eval.h +1376 -0
  964. package/src/targets/cpp/runtime/gea_native_class_prototype.h +44 -0
  965. package/src/targets/cpp/runtime/gea_runtime.h +29222 -0
  966. package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +55 -0
@@ -0,0 +1,1135 @@
1
+ import { arrayExtensionKey, representationKey } from '../../representation/model.js';
2
+ import { symbolPropertyKeyDeclarationOf } from '../../semantics/model/structural-types.js';
3
+ /**
4
+ * Representation -> physical C++ type spelling. This is the one authoritative
5
+ * mapping: nothing downstream re-derives a carrier's C++ type from generated
6
+ * text, a name, or a second table. `cppTypeOf`'s switch has no `default` on
7
+ * purpose -- adding a `Representation` kind in `representation/model.ts`
8
+ * without adding a case here is a compile error, not a silently-wrong runtime
9
+ * fallback.
10
+ */
11
+ const cppIdentifierCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
12
+ /**
13
+ * Checker/semantic identities are opaque strings that may contain characters
14
+ * a C++ identifier cannot (the `|` `identity/ids.ts` uses as a field
15
+ * separator, for one). No RegExp is admitted under this directory, so
16
+ * sanitization walks the string one code point at a time instead of matching
17
+ * a pattern against it.
18
+ */
19
+ const cppDigits = '0123456789';
20
+ export const sanitizeForCppIdentifier = (raw) => {
21
+ let sanitized = '';
22
+ for (const character of raw) {
23
+ sanitized += cppIdentifierCharacters.includes(character) ? character : '_';
24
+ }
25
+ return sanitized;
26
+ };
27
+ /** The emitted file-scope variable name for a binding cell a run-once region owns. */
28
+ export const cppGlobalName = (declaration) => `gea_global_${sanitizeForCppIdentifier(declaration)}`;
29
+ /** The emitted struct name for a closed record shape (or a native record's own shape). The one authority other sections must also call. */
30
+ export const cppRecordStructName = (shapeId) => `gea_record_${sanitizeForCppIdentifier(shapeId)}`;
31
+ /**
32
+ * An injective identifier encoding for an opaque structural identity.
33
+ *
34
+ * `sanitizeForCppIdentifier` intentionally repairs ordinary display-derived
35
+ * names, but it is not injective (`a-b` and `a_b` both repair to `a_b`). A
36
+ * recursive wrapper's name IS its carrier identity, so every non-alphanumeric
37
+ * code point is escaped rather than repaired. Underscores are escaped too,
38
+ * making the `_x..._` escapes self-delimiting and collision-free.
39
+ */
40
+ const encodeStructuralIdentityForCpp = (identity) => {
41
+ let encoded = '';
42
+ for (const character of identity) {
43
+ if (cppIdentifierCharacters.includes(character) && character !== '_') {
44
+ encoded += character;
45
+ continue;
46
+ }
47
+ encoded += `_x${(character.codePointAt(0) ?? 0).toString(16)}_`;
48
+ }
49
+ return encoded;
50
+ };
51
+ /**
52
+ * The file-scope wrapper which closes one recursive native container equation.
53
+ *
54
+ * This is named from the sealed structural identity, never a source spelling:
55
+ * aliases can be anonymous or share a display name, while an interned id is
56
+ * the one fact derivation, verification, and every C++ use site agree names
57
+ * this one physical object type.
58
+ */
59
+ export const cppRecursiveContainerName = (type) => `gea_recursive_${encodeStructuralIdentityForCpp(type)}`;
60
+ /**
61
+ * The emitted struct name for the typed fields an array-extending interface
62
+ * adds (`array-object.extension`). Named by the FIELDS' own identity --
63
+ * `arrayExtensionKey`, the same text the carrier's key carries -- hashed
64
+ * (FNV-1a, 64-bit, stable across runs) because a field list is not a C++
65
+ * identifier; two interfaces declaring the same fields over the same
66
+ * carriers share one struct, exactly as they share one carrier.
67
+ */
68
+ export const cppArrayExtensionStructName = (extension) => {
69
+ const key = arrayExtensionKey(extension);
70
+ let hash = 0xcbf29ce484222325n;
71
+ for (let index = 0; index < key.length; index += 1) {
72
+ hash ^= BigInt(key.charCodeAt(index));
73
+ hash = (hash * 0x100000001b3n) & 0xffffffffffffffffn;
74
+ }
75
+ return `gea_arrayext_${hash.toString(16)}`;
76
+ };
77
+ /** The emitted variable name for one try statement's finally-clause scope guard, keyed by the region's own operation id so two in a function never collide. */
78
+ export const cppFinallyGuardName = (region) => `gea_finally_${sanitizeForCppIdentifier(region)}`;
79
+ /** The slot one try statement parks an in-flight exception in while its finally clause runs; keyed the same way, and for the same reason, as the guard beside it. */
80
+ export const cppFinallyPendingName = (region) => `gea_finally_pending_${sanitizeForCppIdentifier(region)}`;
81
+ /**
82
+ * Struct declarations for every `record` / `native-record-ref` carrier a
83
+ * program's selected representations require.
84
+ *
85
+ * `cppTypeOf` (types.ts) spells a record carrier as a bare identifier --
86
+ * `cppRecordStructName(shapeId)` -- because a use site only ever needs the
87
+ * name, never the body. Something still has to emit the body once per struct,
88
+ * and this is that something: the one place a `RecordField[]` actually
89
+ * becomes C++ member declarations.
90
+ */
91
+ const cppIdentifierStartCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_';
92
+ const cppIdentifierContinueCharacters = `${cppIdentifierStartCharacters}0123456789`;
93
+ /**
94
+ * No `RegExp` literal is admitted under `src/targets/cpp/` (architecture.mjs
95
+ * enforces it), so identifier shape is a character walk, exactly like
96
+ * `sanitizeForCppIdentifier` in types.ts. Unlike that helper, this one never
97
+ * repairs what it finds: a field key is a record's own shape, not a name this
98
+ * renderer is free to invent a substitute for.
99
+ */
100
+ const isCppIdentifierShaped = (candidate) => {
101
+ let sawCharacter = false;
102
+ let atStart = true;
103
+ for (const character of candidate) {
104
+ const allowed = atStart ? cppIdentifierStartCharacters.includes(character) : cppIdentifierContinueCharacters.includes(character);
105
+ if (!allowed)
106
+ return false;
107
+ sawCharacter = true;
108
+ atStart = false;
109
+ }
110
+ return sawCharacter;
111
+ };
112
+ /**
113
+ * A small, non-exhaustive set of C++ reserved words. Exhaustiveness is not the
114
+ * point -- a field key colliding with an obscure alternative-operator keyword
115
+ * (`bitand`, `compl`, ...) is vanishingly unlikely from TypeScript source, and
116
+ * the fail-closed behaviour below only needs to catch the common case: a field
117
+ * named `class`, `new`, `template`, and the like.
118
+ */
119
+ const cppReservedKeywords = new Set([
120
+ 'alignas',
121
+ 'alignof',
122
+ 'and',
123
+ 'and_eq',
124
+ 'asm',
125
+ 'auto',
126
+ 'bool',
127
+ 'bitand',
128
+ 'bitor',
129
+ 'break',
130
+ 'case',
131
+ 'catch',
132
+ 'char',
133
+ 'char8_t',
134
+ 'char16_t',
135
+ 'char32_t',
136
+ 'class',
137
+ 'concept',
138
+ 'const',
139
+ 'const_cast',
140
+ 'consteval',
141
+ 'constexpr',
142
+ 'constinit',
143
+ 'compl',
144
+ 'continue',
145
+ 'co_await',
146
+ 'co_return',
147
+ 'co_yield',
148
+ 'default',
149
+ 'delete',
150
+ 'decltype',
151
+ 'do',
152
+ 'double',
153
+ 'dynamic_cast',
154
+ 'else',
155
+ 'enum',
156
+ 'explicit',
157
+ 'export',
158
+ 'extern',
159
+ 'false',
160
+ 'float',
161
+ 'for',
162
+ 'friend',
163
+ 'goto',
164
+ 'if',
165
+ 'inline',
166
+ 'int',
167
+ 'long',
168
+ 'mutable',
169
+ 'namespace',
170
+ 'new',
171
+ 'noexcept',
172
+ 'not',
173
+ 'not_eq',
174
+ 'nullptr',
175
+ 'operator',
176
+ 'or',
177
+ 'or_eq',
178
+ 'private',
179
+ 'protected',
180
+ 'public',
181
+ 'register',
182
+ 'requires',
183
+ 'reinterpret_cast',
184
+ 'return',
185
+ 'short',
186
+ 'signed',
187
+ 'sizeof',
188
+ 'static',
189
+ 'static_assert',
190
+ 'static_cast',
191
+ 'struct',
192
+ 'switch',
193
+ 'template',
194
+ 'this',
195
+ 'thread_local',
196
+ 'throw',
197
+ 'true',
198
+ 'try',
199
+ 'typedef',
200
+ 'typeid',
201
+ 'typename',
202
+ 'union',
203
+ 'unsigned',
204
+ 'using',
205
+ 'virtual',
206
+ 'void',
207
+ 'volatile',
208
+ 'wchar_t',
209
+ 'while',
210
+ 'xor',
211
+ 'xor_eq'
212
+ ]);
213
+ /**
214
+ * The textual marker `derive.ts`'s `recordFieldKeyOf` publishes for a
215
+ * symbol-keyed record field: `sym(<declaration>)`, the identical convention
216
+ * `structuralShapeKey`'s `keyOfPropertyKey` (semantics/model/structural-types.ts)
217
+ * already uses to key a symbol member into a shape's own canonical identity.
218
+ * Reusing that exact text is deliberate, not cosmetic: it is the one string a
219
+ * symbol key is already known by throughout this compiler, so a second,
220
+ * independently-invented spelling here would be a second opinion about what
221
+ * names the same field.
222
+ *
223
+ * `derive.ts` is target-neutral and states only *which* member a field names;
224
+ * this module is the one place that name becomes a C++ member spelling --
225
+ * exactly the split a tuple's positional key (`String(position)`, recognized
226
+ * below by shape alone) already uses. Symbol keys need an explicit marker
227
+ * instead of a shape test because a declaration id's own text (`decl|...`) is
228
+ * not self-describing the way an all-digit position is.
229
+ */
230
+ /**
231
+ * The declaration id inside a `sym(<declaration>)` marker, or `null` when
232
+ * `key` is not shaped like one.
233
+ *
234
+ * A source-spelled property name that happens to match this exact shape is a
235
+ * theoretical collision this function cannot rule out by construction -- the
236
+ * same residual risk `cppReservedKeywords` and the `gea_` prefix reservation
237
+ * below already accept for the identical reason: catching the case that
238
+ * actually occurs is the bar, not exhaustive proof against a name no real
239
+ * program spells. Getting it wrong is not silent, either: two fields that
240
+ * collapsed to one marker would still need to disagree on `value`'s shape to
241
+ * go unnoticed, and disagreeing on the struct member itself is a duplicate
242
+ * C++ member declaration, which clang refuses.
243
+ */
244
+ const symbolFieldDeclarationOf = symbolPropertyKeyDeclarationOf;
245
+ /**
246
+ * The reserved member-name prefix a symbol-keyed field mangles into.
247
+ *
248
+ * Placing it inside the `gea_` namespace is what makes recognizing it safe:
249
+ * every key that still carries a plain `gea_` prefix by the time it reaches
250
+ * `cppRecordFieldName` is refused a few lines below, so no key this compiler
251
+ * did not mint itself can ever arrive already wearing this prefix.
252
+ */
253
+ const cppSymbolFieldNamePrefix = 'gea_sym_';
254
+ /**
255
+ * The reserved member-name prefix an escaped key mangles into, and the one
256
+ * character inside an escaped name that does not stand for itself.
257
+ *
258
+ * `gea_key_` is the third member of the `gea_` family, alongside `gea_slot_`
259
+ * (a tuple position) and `gea_sym_` (a symbol's declaration). Those three and
260
+ * `records.ts`'s `gea_dynamic` sidecar are pairwise separated by the character
261
+ * right after `gea_` -- `k`, `s`, `s`, `d`, with `slot`/`sym` parting one
262
+ * character later -- and none of them is reachable by a key that passes
263
+ * through unchanged, because a pass-through key inside the `gea_` prefix is
264
+ * escaped instead. The four families are disjoint by construction, not by
265
+ * hoping no program spells one of these names.
266
+ *
267
+ * `q` introduces an escape. A letter rather than `_` is deliberate: the prefix
268
+ * already ends in `_`, so an escape that began with one would put `__` -- a
269
+ * spelling C++ reserves to the implementation in every scope ([lex.name]/3) --
270
+ * at the head of every name minted from a key that does not start with a
271
+ * letter. `q` is the rarest letter in ordinary property names, so the readable
272
+ * half of a mangled name stays readable.
273
+ */
274
+ const cppEscapedFieldNamePrefix = 'gea_key_';
275
+ const cppEscapeIntroducer = 'q';
276
+ const cppHexDigits = '0123456789abcdef';
277
+ /**
278
+ * A code point as fixed-width lowercase hex.
279
+ *
280
+ * Fixed width is what makes an escape self-delimiting without a terminator:
281
+ * a reader always knows how many characters belong to it, so no character has
282
+ * to be reserved as a separator. Spelled by walking nibbles rather than
283
+ * through `toString(16)` for the same reason `sanitizeForCppIdentifier` walks
284
+ * characters -- one visible rule, and no library formatting to drift from.
285
+ */
286
+ const cppHexOfCodePoint = (value, width) => {
287
+ let text = '';
288
+ for (let shift = width - 1; shift >= 0; shift -= 1)
289
+ text += cppHexDigits[(value >> (shift * 4)) & 0xf] ?? '0';
290
+ return text;
291
+ };
292
+ /**
293
+ * An arbitrary property key as the tail of an escaped member name.
294
+ *
295
+ * `[A-Za-z0-9]` stands for itself; every other code point -- `_` and the
296
+ * introducer `q` included -- becomes `q` + a width tag + that many hex digits.
297
+ * Escaping `_` is not about whether C++ accepts it (it would): it is what
298
+ * holds the tail's alphabet to exactly `[A-Za-z0-9]` plus escapes, so no `__`
299
+ * can be minted here and the prefix's own trailing `_` cannot begin one
300
+ * either. Escaping `q` is what makes the result readable backwards -- `q`
301
+ * means "an escape follows" and nothing else, so `counterqz2dvalue` has
302
+ * exactly one reading.
303
+ *
304
+ * That single reading is the injectivity argument, and injectivity is the
305
+ * whole point: two distinct keys arriving at one struct member is a layout the
306
+ * program never described, and it compiles. Every produced tail is decoded by
307
+ * one deterministic left-to-right walk -- on `q`, take the tag and its fixed
308
+ * run of hex digits; otherwise take the character -- so this encoder has a
309
+ * left inverse, and a function with a left inverse cannot collapse two inputs.
310
+ * Repair-style sanitization has no such inverse, which is exactly why it is
311
+ * not what this does: `-` -> `_` would map `counter-value` and `counter_value`
312
+ * -- two different properties of the same object -- onto one member.
313
+ *
314
+ * The width tag is always the smallest that fits (`z` <= 0xff, `y` <= 0xffff,
315
+ * `x` for the astral range), which is what makes the encoding a function of
316
+ * the key alone and not of anything about how the key was reached; there is no
317
+ * counter and no visit order anywhere in it, so the same key spells the same
318
+ * member on every run. Iteration is `for...of`, so an astral character is one
319
+ * code point rather than two surrogate halves, and an unpaired surrogate is
320
+ * still a code point and still encodes -- a JS property key is an arbitrary
321
+ * UTF-16 sequence, and this map is required to be total over all of them.
322
+ */
323
+ const escapeForCppMemberName = (key) => {
324
+ let escaped = '';
325
+ for (const character of key) {
326
+ if (character !== cppEscapeIntroducer && character !== '_' && cppIdentifierContinueCharacters.includes(character)) {
327
+ escaped += character;
328
+ continue;
329
+ }
330
+ const code = character.codePointAt(0) ?? 0;
331
+ if (code <= 0xff)
332
+ escaped += `${cppEscapeIntroducer}z${cppHexOfCodePoint(code, 2)}`;
333
+ else if (code <= 0xffff)
334
+ escaped += `${cppEscapeIntroducer}y${cppHexOfCodePoint(code, 4)}`;
335
+ else
336
+ escaped += `${cppEscapeIntroducer}x${cppHexOfCodePoint(code, 6)}`;
337
+ }
338
+ return escaped;
339
+ };
340
+ /**
341
+ * The emitted member name for a record field. Total: a JS property key is an
342
+ * arbitrary string, a C++ struct member is an identifier, and this is the one
343
+ * mapping between them.
344
+ *
345
+ * A tuple's slots are record fields keyed by their position -- `"0"`, `"1"` --
346
+ * because a position really is the key, and there is no separate tuple carrier
347
+ * by design. C++ has no such member name, so a positional key is spelled with
348
+ * the reserved `gea_` prefix rather than being prefixed ad hoc: `"0"` and a
349
+ * source property literally named `_0` would otherwise collide, and two
350
+ * distinct fields sharing one member is a silently wrong layout.
351
+ *
352
+ * A symbol-keyed field is the identical situation with a different shape of
353
+ * key: `derive.ts` publishes it as `sym(<declaration>)` rather than digits,
354
+ * and this is the one place that becomes `gea_sym_<mangled declaration>` --
355
+ * an ordinary struct member, not a runtime lookup, because a symbol key is a
356
+ * compile-time constant identity. Naming it by declaration id rather than by
357
+ * the symbol's own printable description is what keeps `{[Symbol.iterator]:
358
+ * f}` and `{"Symbol(Symbol.iterator)": f}` -- two different objects -- from
359
+ * ever mangling to the same member: the declaration id is stable identity,
360
+ * the description is not even unique (`Symbol('x')` and a second, unrelated
361
+ * `Symbol('x')` print identically and are still different symbols).
362
+ *
363
+ * A key that is already a C++ identifier, is not a reserved word, and is not
364
+ * inside this compiler's own `gea_` prefix passes through byte-for-byte, which
365
+ * is nearly every key any program writes: a member is named after the property
366
+ * it carries, so that reading the emitted struct against the source type is
367
+ * possible at all.
368
+ *
369
+ * Everything else is escaped into `gea_key_` -- a CSS class name used as a key
370
+ * (`counter-value`), a C++ keyword (`class`, `template`), a key that starts
371
+ * with a digit without spelling a position (`0x`), a non-ASCII key, the empty
372
+ * key, and any key already wearing the `gea_` prefix. Each of those used to
373
+ * throw. Throwing broke the contract `cppRecordDeclarations` states in
374
+ * `records.ts` -- "A gap here is reported, never thrown ... an exception
375
+ * escaping from there takes down a compilation that has a perfectly good
376
+ * report to give" -- and it was not even a gap to report: `{'counter-value':
377
+ * 1}` is ordinary, correct TypeScript, so a total spelling is what this
378
+ * function owes its callers rather than something it may decline to provide.
379
+ * Refusing by name would have been the fail-closed answer to a genuine gap;
380
+ * there is no gap here, only a name that has to be minted, and
381
+ * `escapeForCppMemberName` above carries the argument that minting it cannot
382
+ * collapse two properties into one member.
383
+ */
384
+ /**
385
+ * Whether a record field key names a SYMBOL member rather than a string one.
386
+ *
387
+ * The two halves of a JavaScript object's key space are physically different
388
+ * at runtime -- `Object.keys` lists one and not the other -- and a dynamic
389
+ * `[[Get]]` arrives holding a `gea::Symbol` id minted while the program ran,
390
+ * which no compile-time declaration id can be compared against. So the field
391
+ * dispatcher `records.ts` renders has to know which of its fields it can match
392
+ * by text and which it cannot, and asking here rather than re-testing the
393
+ * `sym(...)` spelling in a second module keeps one authority over that marker.
394
+ */
395
+ export const cppRecordFieldKeyIsSymbol = (key) => symbolFieldDeclarationOf(key) !== null;
396
+ export const cppRecordFieldName = (key) => {
397
+ const symbolDeclaration = symbolFieldDeclarationOf(key);
398
+ if (symbolDeclaration !== null)
399
+ return `${cppSymbolFieldNamePrefix}${sanitizeForCppIdentifier(symbolDeclaration)}`;
400
+ // A key already inside the reserved prefix takes the escaped path instead of
401
+ // passing through: `gea_dynamic` is a legal property name *and* the sidecar
402
+ // member `records.ts` mints, and only one of the two may own that spelling.
403
+ if (key.length > 0 && !key.startsWith('gea_')) {
404
+ if (cppDigits.includes(key[0] ?? '')) {
405
+ let positional = true;
406
+ for (const character of key)
407
+ positional = positional && cppDigits.includes(character);
408
+ if (positional)
409
+ return `gea_slot_${key}`;
410
+ }
411
+ else if (isCppIdentifierShaped(key) && !cppReservedKeywords.has(key))
412
+ return key;
413
+ }
414
+ return `${cppEscapedFieldNamePrefix}${escapeForCppMemberName(key)}`;
415
+ };
416
+ /**
417
+ * The presence bit paired with an optional record field.
418
+ *
419
+ * `RecordField.required` distinguishes a missing property from a property
420
+ * whose value is `undefined`; the value carrier cannot always do that (and an
421
+ * `optional<undefined | T>` must not be asked to). Generated record structs
422
+ * therefore keep this independent bit. The `gea_` prefix is collision-free
423
+ * with source members because `cppRecordFieldName` escapes every source key
424
+ * beginning with that reserved prefix.
425
+ */
426
+ export const cppRecordFieldPresenceName = (key) => `gea_present_${cppRecordFieldName(key)}`;
427
+ /**
428
+ * The environment a record carries for one accessor half whose body captures.
429
+ *
430
+ * An accessor occupies no storage for its VALUE -- that is what makes it an
431
+ * accessor -- but a getter written inside a function closes over that
432
+ * function's locals, and the only thing that can carry those to it is the
433
+ * object the getter is reached through. So a capturing accessor does occupy
434
+ * storage: one type-erased `gea::PackedEnvironment`, exactly what a
435
+ * `CallableObject` holds for the same reason, populated where the literal is
436
+ * allocated and read back at every call.
437
+ */
438
+ export const cppRecordAccessorEnvironmentName = (key, half) => `gea_env_${half === 'getter' ? 'get' : 'set'}_${cppRecordFieldName(key)}`;
439
+ /** The descriptor-attribute cell paired with one fixed native field. */
440
+ export const cppRecordFieldAttributesName = (key) => `gea_attributes_${cppRecordFieldName(key)}`;
441
+ /**
442
+ * A constant's C++ spelling, decided by the carrier that holds it.
443
+ *
444
+ * `OperandSource.constant.text` is the language's own literal form, which is
445
+ * not always C++'s: a string's text is the *contents*, with no quotes and no
446
+ * escaping, so emitting it verbatim spells an identifier rather than a literal
447
+ * and the field key `x` becomes a reference to a variable named `x`. The
448
+ * carrier is what says which reading is meant, which is why this takes one
449
+ * rather than guessing from the text.
450
+ */
451
+ /**
452
+ * Whether a carrier has an empty value that behaves like absence: using it
453
+ * faults rather than answering. Every one of these is a pointer or a handle
454
+ * whose default state is "refers to nothing".
455
+ */
456
+ const carriesAbsence = (representation) => {
457
+ if (representation.kind === 'native-handle' || representation.kind === 'array-object' || representation.kind === 'optional')
458
+ return true;
459
+ if (representation.kind === 'record' ||
460
+ representation.kind === 'record-with-index' ||
461
+ representation.kind === 'native-record-ref' ||
462
+ representation.kind === 'typed-array' ||
463
+ representation.kind === 'array-buffer' ||
464
+ representation.kind === 'shared-array-buffer' ||
465
+ representation.kind === 'data-view') {
466
+ return representation.ownership === 'shared-refcount';
467
+ }
468
+ return representation.kind === 'class-ref' && representation.ownership === 'shared-refcount';
469
+ };
470
+ /**
471
+ * The one spelling of `undefined` as a value.
472
+ *
473
+ * Both the constant path (a literal `undefined` in source) and `void`'s result
474
+ * name the same value, so they name it through the same constant rather than
475
+ * each spelling the struct themselves -- two places writing the same C++ text
476
+ * is exactly how the two drift apart when the runtime's spelling changes.
477
+ */
478
+ export const cppUndefinedValue = 'gea::Undefined{}';
479
+ /**
480
+ * The value `undefined`, spelled into a carrier that can hold it -- `null` for
481
+ * one that cannot.
482
+ *
483
+ * Two sites ask this exact question and each used to answer it: an OMITTED
484
+ * argument (`emit-context.ts`, whose slot receives the `undefined` the language
485
+ * binds an unpassed parameter to, ECMA-262 10.2.11) and a `[[Get]]` of a key an
486
+ * object does not have (`emit-union-properties.ts`, 10.1.8 step 3). They are one
487
+ * question -- what is `undefined` in this carrier -- so they are one renderer.
488
+ *
489
+ * The four carriers that hold it, and no wider set: `undefined` itself; a
490
+ * `dynamic` box, which default-constructs to `Tag::Undefined`; an `optional`
491
+ * whose absence IS `undefined` (one spending its absence on `null` cannot);
492
+ * and a tagged union with an `undefined` ARM, named by index because a
493
+ * default-constructed union holds its FIRST arm, which need not be that one.
494
+ *
495
+ * Deliberately narrower than `carriesAbsence` below. That predicate answers
496
+ * "has an empty value that faults when used", which an empty `Ref<T>` does --
497
+ * but an empty `Ref` is a null pointer, not `undefined`, and handing one back
498
+ * for a property read would answer a program that compares the result to
499
+ * `undefined` with a crash instead of `true`.
500
+ */
501
+ export const cppUndefinedIn = (representation) => {
502
+ if (representation.kind === 'undefined')
503
+ return cppUndefinedValue;
504
+ if (representation.kind === 'dynamic')
505
+ return `${cppTypeOf(representation)}()`;
506
+ if (representation.kind === 'optional' && representation.absence === 'undefined')
507
+ return `${cppTypeOf(representation)}()`;
508
+ if (representation.kind === 'tagged-union') {
509
+ const index = representation.arms.findIndex((arm) => arm.value.kind === 'undefined');
510
+ if (index < 0)
511
+ return null;
512
+ const union = cppTypeOf(representation);
513
+ return `${union}::ofArm<${index}>(${union}::ArmType<${index}>{})`;
514
+ }
515
+ return null;
516
+ };
517
+ const carriesConstantLiteral = (representation, literal) => {
518
+ if (representation.kind === 'tagged-union')
519
+ return representation.arms.some((arm) => carriesConstantLiteral(arm.value, literal));
520
+ if (literal === 'undefined' || literal === 'null')
521
+ return representation.kind === literal;
522
+ if (literal === 'string')
523
+ return representation.kind === 'string';
524
+ if (literal === 'boolean')
525
+ return representation.kind === 'scalar' && representation.domain === 'boolean';
526
+ if (literal === 'bigint')
527
+ return representation.kind === 'scalar' && representation.domain === 'bigint';
528
+ return representation.kind === 'scalar' && representation.domain === 'number';
529
+ };
530
+ export const cppConstantLiteral = (text, literal, representation) => {
531
+ // A reference to one member of a generic function set IS its index -- the
532
+ // constant `ir/lower.ts` mints for a read of the member's own name.
533
+ if (representation.kind === 'generic-function-set')
534
+ return `static_cast<std::uint8_t>(${text})`;
535
+ // `null` and `undefined` are spelled by their carriers, not by their source
536
+ // text: the language writes `null` and C++ has no such name, so emitting the
537
+ // text verbatim spells a reference to an identifier that does not exist.
538
+ // Which of the two this is comes from the literal form and never from the
539
+ // text, because the string `'undefined'` -- the right operand of every
540
+ // `typeof x !== 'undefined'` guard -- spells itself the same way.
541
+ if (literal === 'undefined' || literal === 'null') {
542
+ if (representation.kind === 'null')
543
+ return 'nullptr';
544
+ if (representation.kind === 'undefined')
545
+ return cppUndefinedValue;
546
+ if (representation.kind === 'tagged-union') {
547
+ const index = representation.arms.findIndex((arm) => arm.value.kind === literal);
548
+ const arm = representation.arms[index];
549
+ if (arm)
550
+ return `${cppTypeOf(representation)}::ofArm<${index}>(${cppConstantLiteral(text, literal, arm.value)})`;
551
+ }
552
+ // A `dynamic` carrier is a `gea::Value`, and unlike every carrier
553
+ // `carriesAbsence` below recognizes, it is not merely absence-shaped --
554
+ // it is the JS value model itself, which already has a tag for exactly
555
+ // this. `Value()` default-constructs to `Tag::Undefined` (`gea_runtime.h`'s
556
+ // own comment: "a hoisted cell holds *some* value from the moment it
557
+ // exists"), the same spelling `emit-narrowing.ts`'s tagged-union widening
558
+ // already uses for its untaken-arm fallback -- reused here rather than
559
+ // restated, so the two can't drift. `null` has no default-construction
560
+ // shortcut, so it goes through `box` explicitly with the identical tag
561
+ // `emit-narrowing.ts`'s `dynamicTagFor` states for `{ kind: 'null' }`.
562
+ // Both are reachable the moment a value whose STATIC type is `any` --
563
+ // this constant's own carrier, chosen upstream because nothing narrowed
564
+ // it -- happens to hold the literal `null`/`undefined`: an unresolvable
565
+ // global read as `typeof`'s operand (ECMA-262 13.5.1.2) is exactly one
566
+ // such case, but neither this literal nor this carrier is specific to it.
567
+ if (representation.kind === 'dynamic') {
568
+ if (literal === 'undefined')
569
+ return 'gea::Value()';
570
+ return 'gea::Value::box(gea::Value::Tag::Null, static_cast<std::nullptr_t>(nullptr))';
571
+ }
572
+ // `undefined as unknown as T` -- TypeScript's own double assertion, which
573
+ // the framework uses to declare an ambient global that a target may not
574
+ // inject. The value really is absent; only its carrier is T's. An empty T
575
+ // is the faithful spelling wherever T *has* an empty value that faults on
576
+ // use, the same way reading a property of `undefined` faults. A carrier
577
+ // with no such value -- a `double`, where an empty one is `0` and would
578
+ // answer arithmetic instead of faulting -- is refused rather than zeroed.
579
+ if (!carriesAbsence(representation)) {
580
+ throw new Error(`the constant \`${literal}\` was asserted into a ${representationKey(representation)} carrier, which has no absent value that faults when used`);
581
+ }
582
+ return `${cppTypeOf(representation)}{}`;
583
+ }
584
+ // Contextual typing can publish a literal directly in its union carrier.
585
+ // The literal still occupies one specific arm, so construct that arm here
586
+ // instead of emitting the bare C++ scalar into a TaggedUnion declaration.
587
+ if (representation.kind === 'tagged-union') {
588
+ const index = representation.arms.findIndex((arm) => carriesConstantLiteral(arm.value, literal));
589
+ const arm = representation.arms[index];
590
+ if (arm)
591
+ return `${cppTypeOf(representation)}::ofArm<${index}>(${cppConstantLiteral(text, literal, arm.value)})`;
592
+ }
593
+ // A constant materialized DIRECTLY in a boxed carrier, which is what an
594
+ // operand whose declared type is `any` gets: `f(x: any = 1)`'s default is a
595
+ // `1` the merge holds in a `gea::Value`, and there is no conversion step to
596
+ // box it because the constant was never anything else first. Emitting the
597
+ // bare literal spelled `v0 = (1);` against a `gea::Value` cell -- no viable
598
+ // overloaded `=`, an uncompilable unit from a program that says nothing
599
+ // unusual.
600
+ //
601
+ // The tag comes from the LITERAL FORM, which is the only thing known about a
602
+ // constant here, and every form has one: this is the same tag table
603
+ // `emit-narrowing.ts`'s `dynamicTagFor` states for the conversion path,
604
+ // restricted to the four literal kinds that reach this line (`null` and
605
+ // `undefined` returned above).
606
+ //
607
+ // The value is force-cast to that same literal form's C++ type before it
608
+ // reaches `box`, for the identical reason `emit-narrowing.ts`'s
609
+ // `widenedStoreText` now does the same at its own dynamic-boxing site:
610
+ // `box`'s template argument otherwise deduces from `text`'s bare C++
611
+ // spelling, and a bare numeric literal like `1` is a C++ `int`, not the
612
+ // `double` the `Number` tag promises -- `box` then records `int` as the
613
+ // payload's static type, and a checked unboxer downstream, comparing that
614
+ // against the carrier's declared `double`, refuses; an unchecked one reads
615
+ // the wrong byte width back as garbage. `static_cast<double>(1)` converts
616
+ // before boxing, exactly like direct-initializing a `double`-typed
617
+ // parameter with `1` already does.
618
+ if (representation.kind === 'dynamic') {
619
+ const tag = literal === 'string' ? 'String' : literal === 'boolean' ? 'Boolean' : literal === 'bigint' ? 'BigInt' : 'Number';
620
+ const cppType = literal === 'string' ? 'std::string' : literal === 'boolean' ? 'bool' : literal === 'bigint' ? 'gea::BigInt' : 'double';
621
+ const rendered = literal === 'string' ? cppStringLiteral(text) : literal === 'bigint' ? `gea::BigInt::parse(${cppStringLiteral(text)})` : text;
622
+ return `gea::Value::box(gea::Value::Tag::${tag}, static_cast<${cppType}>(${rendered}))`;
623
+ }
624
+ if (literal === 'bigint')
625
+ return `gea::BigInt::parse(${cppStringLiteral(text)})`;
626
+ if (literal !== 'string')
627
+ return text;
628
+ return cppStringLiteral(text);
629
+ };
630
+ /**
631
+ * The escapes C++ spells with a letter, for the control characters that have one.
632
+ *
633
+ * Named rather than numeric because the emitted text is read by people: a
634
+ * `split("\n")` that emitted `split("\012")` would be correct and unreadable.
635
+ */
636
+ const cppNamedEscapes = new Map([
637
+ ['\n', '\\n'],
638
+ ['\r', '\\r'],
639
+ ['\t', '\\t'],
640
+ ['\v', '\\v'],
641
+ ['\f', '\\f'],
642
+ ['\b', '\\b'],
643
+ ['\u0007', '\\a']
644
+ ]);
645
+ /**
646
+ * A string as a C++ literal expression, retaining embedded zero bytes.
647
+ *
648
+ * A newline is NOT legal raw inside one, whatever this used to claim. C++ ends
649
+ * a narrow string literal at the physical line, so a `"\n"` written through
650
+ * verbatim emits an unterminated literal and the next line of the program is
651
+ * read as a continuation of it -- a compile error three lines from the string
652
+ * that caused it. The corpus hid this for as long as no program put a control
653
+ * character in a string; `body.split('\n')` in an ordinary editor app is all it
654
+ * takes.
655
+ *
656
+ * The remaining control characters get an OCTAL escape rather than a hex one.
657
+ * `\x` is greedy -- it consumes every hex digit that follows, so `\x01` before a
658
+ * literal `2` becomes the single character `\x012` -- while an octal escape is
659
+ * at most three digits, and three are always written. Everything else,
660
+ * including non-ASCII UTF-8, is legal as itself and stays exactly as the source
661
+ * wrote it.
662
+ */
663
+ const rawCppStringLiteral = (content) => {
664
+ let quoted = '"';
665
+ for (const character of content) {
666
+ if (character === '"' || character === '\\') {
667
+ quoted += `\\${character}`;
668
+ continue;
669
+ }
670
+ const named = cppNamedEscapes.get(character);
671
+ if (named !== undefined) {
672
+ quoted += named;
673
+ continue;
674
+ }
675
+ const code = character.codePointAt(0) ?? 0;
676
+ // for...of combines valid pairs, leaving only unpaired UTF-16 units here.
677
+ // A UTF-8 file writer replaces those units with U+FFFD. Spell their WTF-8
678
+ // bytes explicitly so the native string retains JavaScript's exact units.
679
+ if (code >= 0xd800 && code <= 0xdfff) {
680
+ for (const byte of [0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f)])
681
+ quoted += `\\${byte.toString(8).padStart(3, '0')}`;
682
+ continue;
683
+ }
684
+ quoted += code < 0x20 || code === 0x7f ? `\\${code.toString(8).padStart(3, '0')}` : character;
685
+ }
686
+ return `${quoted}"`;
687
+ };
688
+ /** A literal view retains embedded NUL bytes without allocating or borrowing a temporary string. */
689
+ export const cppStringViewLiteral = (content) => {
690
+ const literal = rawCppStringLiteral(content);
691
+ return `std::string_view{${literal}, sizeof(${literal}) - 1}`;
692
+ };
693
+ export const cppStringLiteral = (content) => {
694
+ const literal = rawCppStringLiteral(content);
695
+ // An implicit std::string(const char*) conversion stops at the first NUL.
696
+ // Let C++ measure the literal's encoded byte length so non-ASCII text is
697
+ // counted correctly without duplicating the runtime's UTF-8 encoding.
698
+ return content.includes('\u0000') ? `std::string(${literal}, sizeof(${literal}) - 1)` : literal;
699
+ };
700
+ /** The emitted class name for a nominal class declaration. */
701
+ export const cppClassName = (declaration) => `gea_class_${sanitizeForCppIdentifier(declaration)}`;
702
+ /** The emitted function that performs one class's `[[Construct]]`: allocate, run field initializers, run the constructor body. */
703
+ export const cppConstructName = (declaration) => `gea_construct_${sanitizeForCppIdentifier(declaration)}`;
704
+ /**
705
+ * The emitted function that runs one class's initialization against an object
706
+ * that already exists -- the half of `[[Construct]]` after the allocation.
707
+ *
708
+ * `super(...)` needs exactly that half and no other: the derived construction
709
+ * allocated the object, and the base must initialize *it* rather than allocate
710
+ * a second one of its own type. Only a class some other class extends gets one
711
+ * emitted, because only such a class is ever initialized through a receiver it
712
+ * did not allocate.
713
+ */
714
+ export const cppInitializeName = (declaration) => `gea_initialize_${sanitizeForCppIdentifier(declaration)}`;
715
+ /** The emitted function name for one executable body: a function, or a module/class-evaluation region. */
716
+ export const cppBodyName = (owner) => `gea_body_${sanitizeForCppIdentifier(owner)}`;
717
+ /**
718
+ * The SOURCE DECLARATION a monomorphic copy belongs to: the owner id minus its
719
+ * `@N` copy ordinal.
720
+ *
721
+ * A generic function compiled for two instantiations is two bodies and two
722
+ * thunks, and it is still ONE JavaScript function object. `@N` is a copy
723
+ * ordinal, not a site, so stripping it is the whole of "which declaration is
724
+ * this". Anything that is not a trailing run of digits after the last `@` is
725
+ * left alone -- an owner that never had a copy ordinal is its own declaration.
726
+ */
727
+ export const callableDeclarationOf = (owner) => {
728
+ const at = owner.lastIndexOf('@');
729
+ if (at < 0)
730
+ return owner;
731
+ const ordinal = owner.slice(at + 1);
732
+ const numeric = ordinal.length > 0 && [...ordinal].every((character) => character >= '0' && character <= '9');
733
+ return numeric ? owner.slice(0, at) : owner;
734
+ };
735
+ /**
736
+ * The one program-wide object whose ADDRESS identifies a source declaration.
737
+ *
738
+ * `gea::identifyCallable<&X>` tags a callable with
739
+ * `detail::CallableDeclarationTag<X>`, documented in the runtime as "one
740
+ * program-wide address per emitted source declaration". Instantiating it on the
741
+ * per-COPY thunk pointer gave every copy its own tag, which is what made
742
+ * `stateStack[i] !== State.done` true forever in
743
+ * `generic-state-function-array.ts`. This name is shared by every copy of one
744
+ * declaration, so the tag finally is what its own comment says.
745
+ */
746
+ export const cppCallableDeclarationTagName = (owner) => `gea_decl_tag_${sanitizeForCppIdentifier(callableDeclarationOf(owner))}`;
747
+ /** The one static module-record accessor for a resolved CommonJS module body. */
748
+ export const cppCommonJsModuleName = (owner) => `gea_commonjs_module_${sanitizeForCppIdentifier(owner)}`;
749
+ export const cppCommonJsRecordName = (owner) => `gea_commonjs_record_${sanitizeForCppIdentifier(owner)}`;
750
+ /** The tag type spelled inside `gea::NativeHandle<...>` for one versioned host protocol. */
751
+ const cppNativeHandleTag = (protocol, version) => `gea_native_protocol_${sanitizeForCppIdentifier(protocol)}_v${version}`;
752
+ // `ScalarDomain | TypedArrayElementDomain`: this is also the one authority a
753
+ // typed-array element's C++ type is spelled from (`cppTypeOf`'s `typed-array`
754
+ // case, below), rather than a second table that could disagree with this one
755
+ // on the six domain names the two types share.
756
+ export const cppScalarType = (domain) => {
757
+ switch (domain) {
758
+ case 'boolean':
759
+ return 'bool';
760
+ case 'number':
761
+ return 'double';
762
+ case 'bigint':
763
+ return 'gea::BigInt';
764
+ case 'int8':
765
+ return 'int8_t';
766
+ case 'uint8':
767
+ return 'uint8_t';
768
+ // A DISTINCT C++ type, not `uint8_t`, so `Uint8ClampedArray`'s write rule
769
+ // (ECMA-262 7.1.11 `ToUint8Clamp` -- clamp to [0, 255], round halves to
770
+ // EVEN) is selected by overload resolution rather than by a runtime kind
771
+ // flag. `gea::ClampedUint8` is one byte wide and standard-layout, so a
772
+ // view over it aliases the same bytes any other view does.
773
+ case 'uint8-clamped':
774
+ return 'gea::ClampedUint8';
775
+ case 'int16':
776
+ return 'int16_t';
777
+ case 'uint16':
778
+ return 'uint16_t';
779
+ case 'int32':
780
+ return 'int32_t';
781
+ case 'uint32':
782
+ return 'uint32_t';
783
+ case 'float32':
784
+ return 'float';
785
+ case 'float64':
786
+ return 'double';
787
+ }
788
+ };
789
+ /**
790
+ * Ownership is a property of the physical carrier, not of the value's shape:
791
+ * the same record shape is a bare struct when owned, a `shared_ptr` when
792
+ * refcounted, and a reference when borrowed. Wrapping happens once, here,
793
+ * rather than at each call site that spells a class-ref/record/dictionary type.
794
+ */
795
+ const cppOwnershipWrap = (ownership, inner) => {
796
+ switch (ownership) {
797
+ case 'owned':
798
+ return inner;
799
+ case 'shared-refcount':
800
+ return `gea::Ref<${inner}>`;
801
+ case 'borrowed':
802
+ return `${inner}&`;
803
+ }
804
+ };
805
+ /**
806
+ * A parameter's ownership replaces the carrier's own, it does not stack on top
807
+ * of it. The two state different facts -- how the value is stored versus how it
808
+ * is passed -- and applying both spells `std::shared_ptr<std::shared_ptr<T>>`
809
+ * for a shared record passed by shared reference: valid C++, and wrong.
810
+ *
811
+ * This is the one spelling of a formal, and the body's own declaration of the
812
+ * value it reads out of that formal must use it too. When the two were spelled
813
+ * separately -- the formal from the ABI's passing mode, the local from the
814
+ * carrier's storage -- they disagreed for every reference parameter.
815
+ */
816
+ export const cppAbiParameterType = (parameter) => {
817
+ // `ArrayBuffer`'s bytes have observable reference identity: every TypedArray
818
+ // view aliases that one block. A function-value signature can retain an
819
+ // `owned` passing-mode residue even after publication selects the standard
820
+ // buffer carrier as shared-refcounted; applying that stale mode here copies
821
+ // the vector while the parameter operation and every use hold `Ref` to the
822
+ // block. Keep the shared carrier in that one impossible pairing. Borrowed
823
+ // and already-shared conventions remain exactly as declared.
824
+ const aliasing = parameter.value.kind === 'array-buffer' ||
825
+ parameter.value.kind === 'shared-array-buffer' ||
826
+ // A `DataView` and a `TypedArray` are the same argument one step out: each
827
+ // is an object with observable reference identity over a block it does not
828
+ // own, so a by-value formal copies the view while its own operations and
829
+ // every other use hold `Ref` to it -- clang's `no viable overloaded '='`
830
+ // on `b0 = gea_arg_0`, from a `DataView` parameter in ordinary code.
831
+ parameter.value.kind === 'data-view' ||
832
+ parameter.value.kind === 'typed-array';
833
+ if (aliasing && parameter.value.ownership === 'shared-refcount' && parameter.ownership === 'owned') {
834
+ return cppTypeOf(parameter.value);
835
+ }
836
+ return cppTypeOf(parameter.value, parameter.ownership);
837
+ };
838
+ /**
839
+ * Whether a receiver's carrier is a refcounted handle.
840
+ *
841
+ * A body that takes one BY VALUE increments and decrements a count on every
842
+ * call, for an object the caller already holds for the whole call -- so the
843
+ * count buys nothing and sits on the hot path of every method. Measured on
844
+ * `bench/comparison/fixtures/method_calls.ts`: 31.9ms taking the receiver by
845
+ * value, 15.9ms taking it by reference, against 19.0ms for the hand-written
846
+ * baseline whose receiver is a stack object.
847
+ *
848
+ * The ABI is untouched -- a `CallableObject` still stores the by-value
849
+ * convention every caller agrees on -- so this is the BODY's spelling only, the
850
+ * same split `formalsOf`'s `narrowed` makes.
851
+ */
852
+ export const cppRefcountedReceiver = (representation) => 'ownership' in representation && representation.ownership === 'shared-refcount';
853
+ /**
854
+ * A result position, where `void` is a real spelling rather than an error.
855
+ *
856
+ * `cppTypeOf` refuses `void` because no *value* can be carried by it, and that
857
+ * refusal is correct everywhere a value is stored. A function's return type is
858
+ * the one position where "carries nothing" is expressible in C++, and routing
859
+ * it through `cppTypeOf` made every `void`-returning callable unspellable --
860
+ * which read as a missing physical type for the whole carrier.
861
+ */
862
+ export const cppResultTypeOf = (representation) => representation.kind === 'void' ? 'void' : cppTypeOf(representation);
863
+ /**
864
+ * A broad source `Function` still carries a Value because it has no static
865
+ * callable ABI, but inside a typed sum it is not that sum's dynamic remainder.
866
+ * Give that arm a distinct physical type so runtime union admission can retain
867
+ * its checker-published Function-tag discriminator after Representation facts
868
+ * are no longer available to the C++ adapter.
869
+ */
870
+ export const cppTaggedUnionArmType = (arm) => arm.runtimeDiscriminator.kind === 'callable-tag' ? 'gea::FunctionValue' : cppTypeOf(arm.value);
871
+ /**
872
+ * The calling convention as a C++ function-type spelling: result first, then
873
+ * the receiver (if any) as the first formal, then the declared parameters --
874
+ * mirroring `abiKey` in `representation/model.ts`, which keys this exact
875
+ * shape for plan-conflict detection. `function`/`function-family`/
876
+ * `constructor-family`/`function-value-family`/`function-value-dispatch` all
877
+ * carry one `CallableAbi` and therefore all resolve through this one helper.
878
+ */
879
+ export const cppAbiType = (abi) => {
880
+ const receiver = abi.receiver === null ? [] : [cppTypeOf(abi.receiver)];
881
+ const parameters = abi.parameters.map(cppAbiParameterType);
882
+ return `${cppResultTypeOf(abi.result)}(${[...receiver, ...parameters].join(', ')})`;
883
+ };
884
+ /**
885
+ * `ownership` overrides the carrier's own ownership for this one spelling. It is
886
+ * how a parameter position states its passing mode without a second table that
887
+ * could disagree with this one.
888
+ */
889
+ /**
890
+ * Every tagged union a translation unit spells, bound to one short name.
891
+ *
892
+ * A union's C++ spelling is its whole arm list, and the arm list of three's
893
+ * `NativeUniformValue | null | undefined` is 1.3KB. Spelled at every field,
894
+ * formal, local, cast and `ofArm<k>` site, unions were 12.9MB of the three.js app's
895
+ * 38.7MB unit -- 25,410 spellings of a few hundred distinct types. While a
896
+ * unit is being rendered (`beginUnionAliasing` .. `endUnionAliasing`,
897
+ * `translation-unit.ts`), `cppTypeOf` answers the alias instead and records
898
+ * the spelling; the unit then declares `using gea_union_N = <spelling>;`
899
+ * once, ahead of the first use. Aliases are assigned in first-spelling
900
+ * order, which is also dependency order: an inner union is spelled -- and
901
+ * so named -- while its outer union's arm list is being built.
902
+ *
903
+ * Spelling equality is preserved: two representations with one spelling get
904
+ * one alias, so every `cppTypeOf(a) === cppTypeOf(b)` test in the emitter
905
+ * answers exactly as it did on the spellings.
906
+ */
907
+ const unionAliasing = { active: false, aliases: new Map() };
908
+ export const beginUnionAliasing = () => {
909
+ unionAliasing.aliases.clear();
910
+ unionAliasing.active = true;
911
+ };
912
+ /** The aliases recorded since `beginUnionAliasing`, in declaration order, and the end of aliasing. */
913
+ export const endUnionAliasing = () => {
914
+ const recorded = [...unionAliasing.aliases].map(([spelling, name]) => ({ name, spelling }));
915
+ unionAliasing.aliases.clear();
916
+ unionAliasing.active = false;
917
+ return recorded;
918
+ };
919
+ export const cppTypeOf = (representation, ownership = null) => {
920
+ switch (representation.kind) {
921
+ case 'unresolved':
922
+ throw new Error(`unresolved representation (${representation.reason}) is lattice bottom and has no physical C++ type`);
923
+ case 'void':
924
+ throw new Error('void is not a value carrier and has no physical C++ type');
925
+ case 'scalar':
926
+ return cppScalarType(representation.domain);
927
+ case 'string':
928
+ return 'std::string';
929
+ case 'symbol':
930
+ return 'gea::Symbol';
931
+ case 'null':
932
+ return 'std::nullptr_t';
933
+ case 'undefined':
934
+ return 'gea::Undefined';
935
+ case 'class-ref':
936
+ return cppOwnershipWrap(ownership ?? representation.ownership, cppClassName(representation.declaration));
937
+ case 'native-handle':
938
+ // The host's own type, spelled verbatim, wherever the plugin installing
939
+ // the protocol stated one. Nothing is derived from `protocol` in that
940
+ // case -- deriving a spelling is how `cppNativeHandleTag` below came to
941
+ // name tags `gea_runtime.h` had never heard of. The tagged handle stays
942
+ // for a protocol with no stated carrier, which is the honest physical
943
+ // answer for a boundary this compiler has been told nothing about.
944
+ return representation.native ?? `gea::NativeHandle<${cppNativeHandleTag(representation.protocol, representation.version)}>`;
945
+ case 'record':
946
+ // The struct name is the whole spelling either way: the named fields and
947
+ // the dictionary sidecar for the index-signature half are both members of
948
+ // the one struct `cppRecordStructName` names, rendered by `records.ts`,
949
+ // never a second type a use site would have to spell differently.
950
+ case 'record-with-index':
951
+ return cppOwnershipWrap(ownership ?? representation.ownership, cppRecordStructName(representation.shapeId));
952
+ case 'proxy-object':
953
+ return `gea::ProxyObject<${cppTypeOf(representation.target)}, ${cppTypeOf(representation.handler)}>`;
954
+ case 'native-record-ref':
955
+ // A recursive container uses the same name-shaped indirection records
956
+ // use, but its definition is a generated wrapper over a runtime
957
+ // container rather than a record layout. `native` is only the private
958
+ // records-walker marker; the structural identity is the C++ authority.
959
+ if (representation.recursive)
960
+ return cppOwnershipWrap(ownership ?? representation.ownership, cppRecursiveContainerName(representation.recursive.type));
961
+ // The host's own struct name when one was stated, exactly as
962
+ // `native-handle` spells its carrier: the type is the engine's, and a
963
+ // `gea_record_*` name minted here would be a second, incompatible
964
+ // identity for the same value. The layout still derives -- what is
965
+ // suppressed is the DEFINITION (`records.ts`), never the check.
966
+ return cppOwnershipWrap(ownership ?? representation.ownership, representation.native ?? cppRecordStructName(representation.shapeId));
967
+ case 'borrowed-ref':
968
+ return `${cppTypeOf(representation.referent)}&`;
969
+ case 'array-object':
970
+ if (representation.recursive)
971
+ return cppOwnershipWrap(ownership ?? representation.ownership, cppRecursiveContainerName(representation.recursive.type));
972
+ return cppOwnershipWrap(ownership ?? representation.ownership, `gea::ArrayObject<${cppTypeOf(representation.element)}>`);
973
+ case 'dense-buffer':
974
+ return `std::vector<${cppTypeOf(representation.element)}>`;
975
+ case 'typed-array':
976
+ return cppOwnershipWrap(ownership ?? representation.ownership, `gea::TypedArray<${cppScalarType(representation.element)}>`);
977
+ // The SAME block `gea::TypedArray` stores its bytes behind -- `gea::
978
+ // ArrayBuffer` is an alias of `std::vector<std::uint8_t>` -- so
979
+ // `view.buffer` hands back the very block the view reads rather than a
980
+ // copy of it, and `new Uint8Array(buffer)` aliases rather than copies.
981
+ // That identity is the whole observable content of ECMA-262 25.1.
982
+ case 'array-buffer':
983
+ return cppOwnershipWrap(ownership ?? representation.ownership, 'gea::ArrayBuffer');
984
+ case 'shared-array-buffer':
985
+ return cppOwnershipWrap(ownership ?? representation.ownership, 'gea::SharedArrayBuffer');
986
+ case 'data-view':
987
+ return cppOwnershipWrap(ownership ?? representation.ownership, 'gea::DataView');
988
+ case 'native-sequence':
989
+ return `gea::NativeSequence<${cppTypeOf(representation.element)}>`;
990
+ case 'iterator': {
991
+ // `gea::Iterator<E, TReturn, TNext>` (`runtime/gea_runtime.h`) defaults
992
+ // both trailing parameters to `void`, which is what every non-generator
993
+ // cursor and every generator whose completion/resume never resolved to
994
+ // a native carrier (`representation/derive.ts`'s `nativeOrUndefined`)
995
+ // needs -- so the 2-argument spelling stays available for them, and
996
+ // only a carrier that genuinely stores a completion value and/or a
997
+ // resume value spells the wider form. `cppTypeOf` itself refuses to
998
+ // spell bare `void` (it is not a value type), so a valueless slot is
999
+ // spelled `void` HERE, literally, rather than routed through it.
1000
+ const isValueless = (carrier) => carrier.kind === 'void' || carrier.kind === 'undefined';
1001
+ const completionValueless = isValueless(representation.completion);
1002
+ const resumeValueless = isValueless(representation.resume);
1003
+ if (completionValueless && resumeValueless)
1004
+ return `gea::Iterator<${cppTypeOf(representation.element)}>`;
1005
+ const completionType = completionValueless ? 'void' : cppTypeOf(representation.completion);
1006
+ const resumeType = resumeValueless ? 'void' : cppTypeOf(representation.resume);
1007
+ return `gea::Iterator<${cppTypeOf(representation.element)}, ${completionType}, ${resumeType}>`;
1008
+ }
1009
+ case 'promise':
1010
+ // `cppTypeOf(representation.value)` would throw for `Promise<void>` --
1011
+ // `cppTypeOf` refuses to spell `void` on purpose, since `void` is not
1012
+ // a value type; only `cppResultTypeOf` (defined above in this same
1013
+ // file, and already calling back into `cppTypeOf` for every other
1014
+ // kind) knows the ABI-position special case where a bare `void` is the
1015
+ // right spelling. `gea::Promise<void>` is that ABI position for the
1016
+ // payload, so it is spelled through the same function.
1017
+ return `gea::Promise<${cppResultTypeOf(representation.value)}>`;
1018
+ case 'keyed-collection': {
1019
+ if (representation.recursive)
1020
+ return cppOwnershipWrap(ownership ?? representation.ownership, cppRecursiveContainerName(representation.recursive.type));
1021
+ // Four containers, not one parameterized by a flag: a Set has no value
1022
+ // slot at all, and a weak family's key equality is reference identity
1023
+ // rather than SameValueZero, so they are genuinely different storage
1024
+ // (the same reasoning `array-object`/`dense-buffer` and
1025
+ // `Dictionary`/`NumericDictionary`/`SymbolDictionary` already state above).
1026
+ const template = representation.family === 'map'
1027
+ ? 'gea::Map'
1028
+ : representation.family === 'set'
1029
+ ? 'gea::Set'
1030
+ : representation.family === 'weak-map'
1031
+ ? 'gea::WeakMap'
1032
+ : 'gea::WeakSet';
1033
+ const key = cppTypeOf(representation.key);
1034
+ const arguments_ = representation.value === null ? key : `${key}, ${cppTypeOf(representation.value)}`;
1035
+ return cppOwnershipWrap(ownership ?? representation.ownership, `${template}<${arguments_}>`);
1036
+ }
1037
+ case 'dictionary': {
1038
+ if (representation.recursive)
1039
+ return cppOwnershipWrap(ownership ?? representation.ownership, cppRecursiveContainerName(representation.recursive.type));
1040
+ // `key` names which runtime container this domain is stored in --
1041
+ // `gea::Dictionary` for strings, `gea::NumericDictionary` for numbers,
1042
+ // and `gea::SymbolDictionary` for symbol identity. A symbol description
1043
+ // is not an identity, so coercing one into a string table would conflate
1044
+ // keys the language keeps distinct.
1045
+ const container = representation.key === 'number'
1046
+ ? 'gea::NumericDictionary'
1047
+ : representation.key === 'symbol'
1048
+ ? 'gea::SymbolDictionary'
1049
+ : 'gea::Dictionary';
1050
+ return cppOwnershipWrap(ownership ?? representation.ownership, `${container}<${cppTypeOf(representation.value)}>`);
1051
+ }
1052
+ // The identity half every callable already carries -- `gea::CallableObject`
1053
+ // holds one of these beside its thunk -- so a callable converts into it by
1054
+ // reading a field rather than by fabricating anything. It has no calling
1055
+ // convention, which is the whole point: a call through it is refused.
1056
+ case 'callable-identity':
1057
+ return 'gea::Ref<gea::FunctionObjectIdentity>';
1058
+ case 'function-value-dispatch':
1059
+ // A signature that mentions itself has no finite expansion: the wrapper
1060
+ // name is the whole spelling, by value, exactly as the recursive
1061
+ // containers spell theirs through their own name.
1062
+ if (representation.recursive)
1063
+ return cppRecursiveContainerName(representation.recursive.type);
1064
+ return `gea::CallableObject<${cppAbiType(representation.abi)}>`;
1065
+ case 'function':
1066
+ case 'function-family':
1067
+ case 'function-value-family':
1068
+ return `gea::CallableObject<${cppAbiType(representation.abi)}>`;
1069
+ // The tag of a choice among generic source functions: an index into the
1070
+ // carrier's sorted `members`. See `generic-function-set` (model.ts).
1071
+ case 'generic-function-set':
1072
+ return 'std::uint8_t';
1073
+ case 'constructor-family':
1074
+ case 'constructor-value-dispatch':
1075
+ return `gea::ConstructorObject<${cppAbiType(representation.abi)}>`;
1076
+ case 'function-and-constructor':
1077
+ return `gea::CallableConstructorObject<${cppAbiType(representation.call)}, ${cppAbiType(representation.construct)}>`;
1078
+ case 'optional':
1079
+ return `gea::Optional<${cppTypeOf(representation.payload)}>`;
1080
+ case 'tagged-union': {
1081
+ const spelling = `gea::TaggedUnion<${representation.arms.map(cppTaggedUnionArmType).join(', ')}>`;
1082
+ if (!unionAliasing.active)
1083
+ return spelling;
1084
+ const existing = unionAliasing.aliases.get(spelling);
1085
+ if (existing !== undefined)
1086
+ return existing;
1087
+ const name = `gea_union_${unionAliasing.aliases.size}`;
1088
+ unionAliasing.aliases.set(spelling, name);
1089
+ return name;
1090
+ }
1091
+ case 'dynamic':
1092
+ // `gea::Value` (gea_runtime.h) is storage for a value whose type the
1093
+ // program never states: a tag and a type-erased holder, with copy, move
1094
+ // and destroy, and no dynamic operation whatsoever.
1095
+ //
1096
+ // Spelling it here says only that the carrier has a physical type, which
1097
+ // is what `manifest.ts`'s `isSpellable` asks -- it decides
1098
+ // `physicalTypes`/`verifierRecipes`/`emitterRecipes` by whether this
1099
+ // function throws. It says nothing about property access, calls or
1100
+ // arithmetic on a box: none of those are claimed anywhere in the
1101
+ // manifest, so a program that performs one is still refused by
1102
+ // preflight with the gap named. `ToBoolean` is now the one operation
1103
+ // that is claimed (`conversion:to-boolean:dynamic`, manifest.ts) --
1104
+ // holding a box and using one are still two different claims, and
1105
+ // `ToBoolean` is the only "using" claim made so far.
1106
+ return 'gea::Value';
1107
+ }
1108
+ };
1109
+ /**
1110
+ * The C++ carrier for a captured cell this backend shares by aliasing rather
1111
+ * than by copying (`emit-context.ts`'s `CaptureSlot.boxed`): a heap-allocated,
1112
+ * reference-counted box every frame that touches the declaration -- the frame
1113
+ * that owns it and every closure that captures it -- holds a copy of the same
1114
+ * pointer to, reading and writing through one dereference.
1115
+ *
1116
+ * `std::shared_ptr`, not a bespoke cell type: it is the same reference-counted
1117
+ * ownership `cppOwnershipWrap`'s `'shared-refcount'` arm already grants a
1118
+ * record, class instance, or array -- copying the pointer aliases the same
1119
+ * allocation, which is exactly the sharing a captured, mutated JavaScript
1120
+ * binding needs. This is a distinct spelling from that wrap on purpose: a
1121
+ * boxed cell's OWN representation can be a plain scalar (`aspectScale:
1122
+ * number`) that has no `ownership` field of its own to override, so this
1123
+ * wraps the whole physical type `cppTypeOf` already spells for it instead of
1124
+ * threading a second, representation-shaped ownership parameter through.
1125
+ */
1126
+ /**
1127
+ * The integer a narrowed `number` is held in.
1128
+ *
1129
+ * 64 bits rather than 32: the values this narrowing admits are bounded by 2^53
1130
+ * or grow with a loop's trip count, and both overflow an `int`. A `long long`
1131
+ * holds every integer a double can hold exactly, so the narrowed and the
1132
+ * unnarrowed form agree everywhere the census says they do.
1133
+ */
1134
+ export const cppNarrowedIntegerType = 'long long';
1135
+ export const cppBoxedType = (representation) => `gea::Ref<${cppTypeOf(representation)}>`;