@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.
- package/LICENSE +202 -0
- package/README.md +149 -0
- package/dist/cli-analyze.d.ts +1 -0
- package/dist/cli-analyze.js +61 -0
- package/dist/cli-coverage.d.ts +1 -0
- package/dist/cli-coverage.js +329 -0
- package/dist/cli-emit.d.ts +10 -0
- package/dist/cli-emit.js +398 -0
- package/dist/cli-module-graph.d.ts +18 -0
- package/dist/cli-module-graph.js +123 -0
- package/dist/cli-package-source.d.ts +5 -0
- package/dist/cli-package-source.js +116 -0
- package/dist/cli-project.d.ts +2 -0
- package/dist/cli-project.js +60 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +199 -0
- package/dist/compiler.d.ts +228 -0
- package/dist/compiler.js +1029 -0
- package/dist/conversion/algebra.d.ts +218 -0
- package/dist/conversion/algebra.js +155 -0
- package/dist/conversion/build.d.ts +67 -0
- package/dist/conversion/build.js +1378 -0
- package/dist/conversion/derive.d.ts +37 -0
- package/dist/conversion/derive.js +260 -0
- package/dist/conversion/graph-validation.d.ts +8 -0
- package/dist/conversion/graph-validation.js +97 -0
- package/dist/conversion/native-callable-adapter.d.ts +13 -0
- package/dist/conversion/native-callable-adapter.js +53 -0
- package/dist/conversion/native-class-reference.d.ts +12 -0
- package/dist/conversion/native-class-reference.js +39 -0
- package/dist/conversion/native-payload-transport.d.ts +25 -0
- package/dist/conversion/native-payload-transport.js +33 -0
- package/dist/conversion/native-selection.d.ts +49 -0
- package/dist/conversion/native-selection.js +135 -0
- package/dist/conversion/native-sum.d.ts +42 -0
- package/dist/conversion/native-sum.js +115 -0
- package/dist/conversion/nodes.d.ts +55 -0
- package/dist/conversion/nodes.js +91 -0
- package/dist/conversion/operand-view.d.ts +14 -0
- package/dist/conversion/operand-view.js +20 -0
- package/dist/conversion/record-view.d.ts +157 -0
- package/dist/conversion/record-view.js +273 -0
- package/dist/conversion/registry.d.ts +217 -0
- package/dist/conversion/registry.js +1 -0
- package/dist/diagnostics/model.d.ts +76 -0
- package/dist/diagnostics/model.js +60 -0
- package/dist/diagnostics/sweep.d.ts +31 -0
- package/dist/diagnostics/sweep.js +112 -0
- package/dist/identity/ids.d.ts +179 -0
- package/dist/identity/ids.js +212 -0
- package/dist/ir/absent-class-arm.d.ts +48 -0
- package/dist/ir/absent-class-arm.js +157 -0
- package/dist/ir/borrow-effects.d.ts +23 -0
- package/dist/ir/borrow-effects.js +151 -0
- package/dist/ir/borrowed-call-arguments.d.ts +40 -0
- package/dist/ir/borrowed-call-arguments.js +117 -0
- package/dist/ir/build.d.ts +168 -0
- package/dist/ir/build.js +459 -0
- package/dist/ir/call-dispatch.d.ts +38 -0
- package/dist/ir/call-dispatch.js +502 -0
- package/dist/ir/call-entry.d.ts +142 -0
- package/dist/ir/call-entry.js +386 -0
- package/dist/ir/callable-class-flow.d.ts +27 -0
- package/dist/ir/callable-class-flow.js +1386 -0
- package/dist/ir/callable-field-slots.d.ts +22 -0
- package/dist/ir/callable-field-slots.js +166 -0
- package/dist/ir/callable-identity-demand.d.ts +52 -0
- package/dist/ir/callable-identity-demand.js +460 -0
- package/dist/ir/callable-member-candidates.d.ts +9 -0
- package/dist/ir/callable-member-candidates.js +39 -0
- package/dist/ir/callable-records.d.ts +21 -0
- package/dist/ir/callable-records.js +411 -0
- package/dist/ir/captures.d.ts +26 -0
- package/dist/ir/captures.js +335 -0
- package/dist/ir/certificate.d.ts +45 -0
- package/dist/ir/certificate.js +47 -0
- package/dist/ir/certify/carrier-keys.d.ts +73 -0
- package/dist/ir/certify/carrier-keys.js +221 -0
- package/dist/ir/certify/function-source.d.ts +4 -0
- package/dist/ir/certify/function-source.js +28 -0
- package/dist/ir/certify/has-property-key.d.ts +88 -0
- package/dist/ir/certify/has-property-key.js +116 -0
- package/dist/ir/certify/instanceof-key.d.ts +24 -0
- package/dist/ir/certify/instanceof-key.js +35 -0
- package/dist/ir/certify/property-access-keys.d.ts +172 -0
- package/dist/ir/certify/property-access-keys.js +291 -0
- package/dist/ir/certify/property-access.d.ts +3 -0
- package/dist/ir/certify/property-access.js +597 -0
- package/dist/ir/certify/runtime-helper.d.ts +3 -0
- package/dist/ir/certify/runtime-helper.js +326 -0
- package/dist/ir/certify/typeof-operand.d.ts +14 -0
- package/dist/ir/certify/typeof-operand.js +16 -0
- package/dist/ir/certify.d.ts +123 -0
- package/dist/ir/certify.js +481 -0
- package/dist/ir/class-evaluation.d.ts +26 -0
- package/dist/ir/class-evaluation.js +50 -0
- package/dist/ir/class-static-fields.d.ts +60 -0
- package/dist/ir/class-static-fields.js +108 -0
- package/dist/ir/construct-entry.d.ts +26 -0
- package/dist/ir/construct-entry.js +117 -0
- package/dist/ir/dead-values.d.ts +90 -0
- package/dist/ir/dead-values.js +184 -0
- package/dist/ir/deferral.d.ts +99 -0
- package/dist/ir/deferral.js +409 -0
- package/dist/ir/dense-loops.d.ts +230 -0
- package/dist/ir/dense-loops.js +697 -0
- package/dist/ir/dominance.d.ts +82 -0
- package/dist/ir/dominance.js +268 -0
- package/dist/ir/emission-representations.d.ts +71 -0
- package/dist/ir/emission-representations.js +350 -0
- package/dist/ir/facts.d.ts +218 -0
- package/dist/ir/facts.js +181 -0
- package/dist/ir/fixed-data-definition.d.ts +19 -0
- package/dist/ir/fixed-data-definition.js +49 -0
- package/dist/ir/generator-split.d.ts +38 -0
- package/dist/ir/generator-split.js +329 -0
- package/dist/ir/hoist.d.ts +55 -0
- package/dist/ir/hoist.js +375 -0
- package/dist/ir/instantiation.d.ts +61 -0
- package/dist/ir/instantiation.js +137 -0
- package/dist/ir/integer-storage.d.ts +170 -0
- package/dist/ir/integer-storage.js +822 -0
- package/dist/ir/integers.d.ts +161 -0
- package/dist/ir/integers.js +539 -0
- package/dist/ir/integrity-restrictions.d.ts +50 -0
- package/dist/ir/integrity-restrictions.js +118 -0
- package/dist/ir/local-iterators.d.ts +4 -0
- package/dist/ir/local-iterators.js +27 -0
- package/dist/ir/lower-allocation.d.ts +4 -0
- package/dist/ir/lower-allocation.js +325 -0
- package/dist/ir/lower-completion.d.ts +15 -0
- package/dist/ir/lower-completion.js +25 -0
- package/dist/ir/lower-destructuring.d.ts +5 -0
- package/dist/ir/lower-destructuring.js +693 -0
- package/dist/ir/lower-element.d.ts +29 -0
- package/dist/ir/lower-element.js +111 -0
- package/dist/ir/lower-exceptions.d.ts +47 -0
- package/dist/ir/lower-exceptions.js +92 -0
- package/dist/ir/lower-flow.d.ts +137 -0
- package/dist/ir/lower-flow.js +600 -0
- package/dist/ir/lower-graph.d.ts +218 -0
- package/dist/ir/lower-graph.js +687 -0
- package/dist/ir/lower-invocation.d.ts +4 -0
- package/dist/ir/lower-invocation.js +514 -0
- package/dist/ir/lower-narrow.d.ts +53 -0
- package/dist/ir/lower-narrow.js +320 -0
- package/dist/ir/lower-operands.d.ts +272 -0
- package/dist/ir/lower-operands.js +461 -0
- package/dist/ir/lower-property.d.ts +21 -0
- package/dist/ir/lower-property.js +132 -0
- package/dist/ir/lower-protocol.d.ts +11 -0
- package/dist/ir/lower-protocol.js +118 -0
- package/dist/ir/lower-short-circuit.d.ts +41 -0
- package/dist/ir/lower-short-circuit.js +63 -0
- package/dist/ir/lower.d.ts +82 -0
- package/dist/ir/lower.js +1346 -0
- package/dist/ir/model.d.ts +1474 -0
- package/dist/ir/model.js +6 -0
- package/dist/ir/native-absent-property.d.ts +3 -0
- package/dist/ir/native-absent-property.js +13 -0
- package/dist/ir/native-array-transport.d.ts +7 -0
- package/dist/ir/native-array-transport.js +46 -0
- package/dist/ir/native-callable-bind.d.ts +9 -0
- package/dist/ir/native-callable-bind.js +30 -0
- package/dist/ir/native-carrier-predicate.d.ts +34 -0
- package/dist/ir/native-carrier-predicate.js +49 -0
- package/dist/ir/native-class-accessor.d.ts +18 -0
- package/dist/ir/native-class-accessor.js +52 -0
- package/dist/ir/native-class-construction.d.ts +16 -0
- package/dist/ir/native-class-construction.js +71 -0
- package/dist/ir/native-class-initialization.d.ts +15 -0
- package/dist/ir/native-class-initialization.js +56 -0
- package/dist/ir/native-class-origins.d.ts +13 -0
- package/dist/ir/native-class-origins.js +237 -0
- package/dist/ir/native-dictionary-transport.d.ts +6 -0
- package/dist/ir/native-dictionary-transport.js +37 -0
- package/dist/ir/native-enumeration.d.ts +14 -0
- package/dist/ir/native-enumeration.js +26 -0
- package/dist/ir/native-equality.d.ts +10 -0
- package/dist/ir/native-equality.js +18 -0
- package/dist/ir/native-field-owner.d.ts +37 -0
- package/dist/ir/native-field-owner.js +183 -0
- package/dist/ir/native-fixed-layout.d.ts +41 -0
- package/dist/ir/native-fixed-layout.js +232 -0
- package/dist/ir/native-host-construction.d.ts +53 -0
- package/dist/ir/native-host-construction.js +62 -0
- package/dist/ir/native-key-query.d.ts +4 -0
- package/dist/ir/native-key-query.js +38 -0
- package/dist/ir/native-merge-transport.d.ts +25 -0
- package/dist/ir/native-merge-transport.js +71 -0
- package/dist/ir/native-record-index-transport.d.ts +11 -0
- package/dist/ir/native-record-index-transport.js +34 -0
- package/dist/ir/native-record-index.d.ts +12 -0
- package/dist/ir/native-record-index.js +27 -0
- package/dist/ir/native-reflect-field.d.ts +5 -0
- package/dist/ir/native-reflect-field.js +33 -0
- package/dist/ir/native-sequence-transport.d.ts +7 -0
- package/dist/ir/native-sequence-transport.js +53 -0
- package/dist/ir/numeric-intrinsics.d.ts +13 -0
- package/dist/ir/numeric-intrinsics.js +57 -0
- package/dist/ir/object-value-conversions.d.ts +20 -0
- package/dist/ir/object-value-conversions.js +50 -0
- package/dist/ir/physical-class-reflection.d.ts +9 -0
- package/dist/ir/physical-class-reflection.js +57 -0
- package/dist/ir/presence-proof.d.ts +42 -0
- package/dist/ir/presence-proof.js +490 -0
- package/dist/ir/program-facts.d.ts +106 -0
- package/dist/ir/program-facts.js +319 -0
- package/dist/ir/proven-branches.d.ts +16 -0
- package/dist/ir/proven-branches.js +219 -0
- package/dist/ir/queries.d.ts +41 -0
- package/dist/ir/queries.js +213 -0
- package/dist/ir/reflection-demand.d.ts +64 -0
- package/dist/ir/reflection-demand.js +1394 -0
- package/dist/ir/refusal.d.ts +43 -0
- package/dist/ir/refusal.js +28 -0
- package/dist/ir/shake.d.ts +37 -0
- package/dist/ir/shake.js +1078 -0
- package/dist/ir/static-callables.d.ts +11 -0
- package/dist/ir/static-callables.js +163 -0
- package/dist/ir/string-layout-reuse.d.ts +13 -0
- package/dist/ir/string-layout-reuse.js +39 -0
- package/dist/ir/string-length-reuse.d.ts +8 -0
- package/dist/ir/string-length-reuse.js +47 -0
- package/dist/ir/transfer.d.ts +78 -0
- package/dist/ir/transfer.js +270 -0
- package/dist/ir/type-query-results.d.ts +25 -0
- package/dist/ir/type-query-results.js +96 -0
- package/dist/ir/typed-property-access.d.ts +100 -0
- package/dist/ir/typed-property-access.js +161 -0
- package/dist/ir/verify.d.ts +19 -0
- package/dist/ir/verify.js +355 -0
- package/dist/plugins/apple/constructors.d.ts +112 -0
- package/dist/plugins/apple/constructors.js +217 -0
- package/dist/plugins/apple/host.d.ts +181 -0
- package/dist/plugins/apple/host.js +262 -0
- package/dist/plugins/apple/jsx.d.ts +2 -0
- package/dist/plugins/apple/jsx.js +293 -0
- package/dist/plugins/apple/members.d.ts +16 -0
- package/dist/plugins/apple/members.js +190 -0
- package/dist/plugins/apple/plugin.d.ts +2 -0
- package/dist/plugins/apple/plugin.js +156 -0
- package/dist/plugins/gea/component-classes.d.ts +25 -0
- package/dist/plugins/gea/component-classes.js +162 -0
- package/dist/plugins/gea/component-inline.d.ts +13 -0
- package/dist/plugins/gea/component-inline.js +532 -0
- package/dist/plugins/gea/constructors.d.ts +23 -0
- package/dist/plugins/gea/constructors.js +100 -0
- package/dist/plugins/gea/contract.d.ts +150 -0
- package/dist/plugins/gea/contract.js +195 -0
- package/dist/plugins/gea/element-ref.d.ts +31 -0
- package/dist/plugins/gea/element-ref.js +45 -0
- package/dist/plugins/gea/host.d.ts +520 -0
- package/dist/plugins/gea/host.js +762 -0
- package/dist/plugins/gea/lower.d.ts +6 -0
- package/dist/plugins/gea/lower.js +195 -0
- package/dist/plugins/gea/members.d.ts +22 -0
- package/dist/plugins/gea/members.js +221 -0
- package/dist/plugins/gea/plugin.d.ts +22 -0
- package/dist/plugins/gea/plugin.js +307 -0
- package/dist/plugins/gea/prelude.d.ts +78 -0
- package/dist/plugins/gea/prelude.js +153 -0
- package/dist/plugins/gea/producer.d.ts +5 -0
- package/dist/plugins/gea/producer.js +52 -0
- package/dist/plugins/gea/reactive-slots.d.ts +49 -0
- package/dist/plugins/gea/reactive-slots.js +578 -0
- package/dist/plugins/gea/render-bridge.d.ts +6 -0
- package/dist/plugins/gea/render-bridge.js +281 -0
- package/dist/plugins/gea/slots.d.ts +15 -0
- package/dist/plugins/gea/slots.js +36 -0
- package/dist/plugins/gea/template-analysis.d.ts +151 -0
- package/dist/plugins/gea/template-analysis.js +346 -0
- package/dist/plugins/gea/user-agent-styles.d.ts +9 -0
- package/dist/plugins/gea/user-agent-styles.js +94 -0
- package/dist/plugins/installed.d.ts +19 -0
- package/dist/plugins/installed.js +21 -0
- package/dist/plugins/load.d.ts +7 -0
- package/dist/plugins/load.js +207 -0
- package/dist/plugins/model.d.ts +735 -0
- package/dist/plugins/model.js +47 -0
- package/dist/plugins/webgl/host.d.ts +77 -0
- package/dist/plugins/webgl/host.js +162 -0
- package/dist/plugins/webgl/plugin.d.ts +40 -0
- package/dist/plugins/webgl/plugin.js +99 -0
- package/dist/preflight/obligations.d.ts +206 -0
- package/dist/preflight/obligations.js +36 -0
- package/dist/preflight/report.d.ts +20 -0
- package/dist/preflight/report.js +61 -0
- package/dist/preflight/run.d.ts +39 -0
- package/dist/preflight/run.js +403 -0
- package/dist/project-preparation.d.ts +33 -0
- package/dist/project-preparation.js +314 -0
- package/dist/projection/abi.d.ts +82 -0
- package/dist/projection/abi.js +349 -0
- package/dist/projection/apply-arguments.d.ts +12 -0
- package/dist/projection/apply-arguments.js +20 -0
- package/dist/projection/bindings.d.ts +250 -0
- package/dist/projection/bindings.js +340 -0
- package/dist/projection/callee.d.ts +196 -0
- package/dist/projection/callee.js +444 -0
- package/dist/projection/class-property-presence.d.ts +28 -0
- package/dist/projection/class-property-presence.js +58 -0
- package/dist/projection/class-prototype.d.ts +5 -0
- package/dist/projection/class-prototype.js +23 -0
- package/dist/projection/class-storage.d.ts +26 -0
- package/dist/projection/class-storage.js +236 -0
- package/dist/projection/classes.d.ts +283 -0
- package/dist/projection/classes.js +944 -0
- package/dist/projection/coercions.d.ts +20 -0
- package/dist/projection/coercions.js +33 -0
- package/dist/projection/dispatch.d.ts +167 -0
- package/dist/projection/dispatch.js +379 -0
- package/dist/projection/fields.d.ts +123 -0
- package/dist/projection/fields.js +383 -0
- package/dist/projection/instance-test.d.ts +78 -0
- package/dist/projection/instance-test.js +156 -0
- package/dist/projection/slots.d.ts +146 -0
- package/dist/projection/slots.js +663 -0
- package/dist/projection/synthesized-abi.d.ts +61 -0
- package/dist/projection/synthesized-abi.js +94 -0
- package/dist/representation/array-index.d.ts +14 -0
- package/dist/representation/array-index.js +17 -0
- package/dist/representation/callable-object.d.ts +3 -0
- package/dist/representation/callable-object.js +6 -0
- package/dist/representation/collections.d.ts +84 -0
- package/dist/representation/collections.js +139 -0
- package/dist/representation/derive.d.ts +159 -0
- package/dist/representation/derive.js +2546 -0
- package/dist/representation/difference.d.ts +30 -0
- package/dist/representation/difference.js +240 -0
- package/dist/representation/field-descriptor-policy.d.ts +19 -0
- package/dist/representation/field-descriptor-policy.js +39 -0
- package/dist/representation/function-constructor.d.ts +13 -0
- package/dist/representation/function-constructor.js +9 -0
- package/dist/representation/host-abi.d.ts +32 -0
- package/dist/representation/host-abi.js +97 -0
- package/dist/representation/host-templates.d.ts +67 -0
- package/dist/representation/host-templates.js +94 -0
- package/dist/representation/intersection.d.ts +84 -0
- package/dist/representation/intersection.js +149 -0
- package/dist/representation/literal-destination.d.ts +43 -0
- package/dist/representation/literal-destination.js +133 -0
- package/dist/representation/merge.d.ts +18 -0
- package/dist/representation/merge.js +83 -0
- package/dist/representation/model.d.ts +1160 -0
- package/dist/representation/model.js +1019 -0
- package/dist/representation/numeric-index.d.ts +13 -0
- package/dist/representation/numeric-index.js +29 -0
- package/dist/representation/object-shape.d.ts +109 -0
- package/dist/representation/object-shape.js +123 -0
- package/dist/representation/optional.d.ts +12 -0
- package/dist/representation/optional.js +87 -0
- package/dist/representation/plan.d.ts +60 -0
- package/dist/representation/plan.js +78 -0
- package/dist/representation/policies.d.ts +589 -0
- package/dist/representation/policies.js +107 -0
- package/dist/representation/primitive-domain.d.ts +1 -0
- package/dist/representation/primitive-domain.js +1 -0
- package/dist/representation/primitives.d.ts +44 -0
- package/dist/representation/primitives.js +78 -0
- package/dist/representation/publish.d.ts +49 -0
- package/dist/representation/publish.js +648 -0
- package/dist/representation/record-fields.d.ts +96 -0
- package/dist/representation/record-fields.js +116 -0
- package/dist/representation/template-object.d.ts +11 -0
- package/dist/representation/template-object.js +26 -0
- package/dist/representation/union.d.ts +30 -0
- package/dist/representation/union.js +324 -0
- package/dist/representation/value-records.d.ts +3 -0
- package/dist/representation/value-records.js +307 -0
- package/dist/representation/verify.d.ts +17 -0
- package/dist/representation/verify.js +221 -0
- package/dist/semantics/alias-this-field-declaration-transform.d.ts +4 -0
- package/dist/semantics/alias-this-field-declaration-transform.js +207 -0
- package/dist/semantics/ambient-type-realization-transform.d.ts +62 -0
- package/dist/semantics/ambient-type-realization-transform.js +168 -0
- package/dist/semantics/ambient.d.ts +24 -0
- package/dist/semantics/ambient.js +119 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +4 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +341 -0
- package/dist/semantics/callable-origins.d.ts +46 -0
- package/dist/semantics/callable-origins.js +354 -0
- package/dist/semantics/class-alias.d.ts +7 -0
- package/dist/semantics/class-alias.js +37 -0
- package/dist/semantics/class-heritage.d.ts +34 -0
- package/dist/semantics/class-heritage.js +104 -0
- package/dist/semantics/commonjs-wrapper.d.ts +69 -0
- package/dist/semantics/commonjs-wrapper.js +231 -0
- package/dist/semantics/constructor-slot-subclasses.d.ts +28 -0
- package/dist/semantics/constructor-slot-subclasses.js +112 -0
- package/dist/semantics/declaration-overlay-transform.d.ts +35 -0
- package/dist/semantics/declaration-overlay-transform.js +2157 -0
- package/dist/semantics/define-property-source-transform.d.ts +4 -0
- package/dist/semantics/define-property-source-transform.js +437 -0
- package/dist/semantics/diagnostic-source-preparation.d.ts +24 -0
- package/dist/semantics/diagnostic-source-preparation.js +82 -0
- package/dist/semantics/documentation-ranges.d.ts +22 -0
- package/dist/semantics/documentation-ranges.js +36 -0
- package/dist/semantics/dynamic-fallback.d.ts +86 -0
- package/dist/semantics/dynamic-fallback.js +249 -0
- package/dist/semantics/frontend-timing.d.ts +6 -0
- package/dist/semantics/frontend-timing.js +35 -0
- package/dist/semantics/frontend.d.ts +504 -0
- package/dist/semantics/frontend.js +1157 -0
- package/dist/semantics/host-declaration-provenance.d.ts +11 -0
- package/dist/semantics/host-declaration-provenance.js +18 -0
- package/dist/semantics/host-methods.d.ts +24 -0
- package/dist/semantics/host-methods.js +74 -0
- package/dist/semantics/host-protocols.d.ts +429 -0
- package/dist/semantics/host-protocols.js +1501 -0
- package/dist/semantics/inherited-accessor.d.ts +7 -0
- package/dist/semantics/inherited-accessor.js +48 -0
- package/dist/semantics/interface-families.d.ts +70 -0
- package/dist/semantics/interface-families.js +180 -0
- package/dist/semantics/interface-implementors.d.ts +53 -0
- package/dist/semantics/interface-implementors.js +87 -0
- package/dist/semantics/jsdoc-namepath-transform.d.ts +4 -0
- package/dist/semantics/jsdoc-namepath-transform.js +85 -0
- package/dist/semantics/model/coverage.d.ts +68 -0
- package/dist/semantics/model/coverage.js +73 -0
- package/dist/semantics/model/edges.d.ts +103 -0
- package/dist/semantics/model/edges.js +20 -0
- package/dist/semantics/model/graph.d.ts +55 -0
- package/dist/semantics/model/graph.js +129 -0
- package/dist/semantics/model/operands.d.ts +159 -0
- package/dist/semantics/model/operands.js +26 -0
- package/dist/semantics/model/operations.d.ts +496 -0
- package/dist/semantics/model/operations.js +2 -0
- package/dist/semantics/model/primitive-domain.d.ts +26 -0
- package/dist/semantics/model/primitive-domain.js +38 -0
- package/dist/semantics/model/selected-signature.d.ts +261 -0
- package/dist/semantics/model/selected-signature.js +55 -0
- package/dist/semantics/model/structural-type-table.d.ts +93 -0
- package/dist/semantics/model/structural-type-table.js +237 -0
- package/dist/semantics/model/structural-types.d.ts +367 -0
- package/dist/semantics/model/structural-types.js +200 -0
- package/dist/semantics/module-resolution.d.ts +23 -0
- package/dist/semantics/module-resolution.js +227 -0
- package/dist/semantics/new-callee-class-tag-source-transform.d.ts +4 -0
- package/dist/semantics/new-callee-class-tag-source-transform.js +64 -0
- package/dist/semantics/node-project.d.ts +13 -0
- package/dist/semantics/node-project.js +107 -0
- package/dist/semantics/node-source-hooks.d.ts +1 -0
- package/dist/semantics/node-source-hooks.js +63 -0
- package/dist/semantics/normalize/absent-globals.d.ts +143 -0
- package/dist/semantics/normalize/absent-globals.js +191 -0
- package/dist/semantics/normalize/arguments-objects.d.ts +43 -0
- package/dist/semantics/normalize/arguments-objects.js +60 -0
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +28 -0
- package/dist/semantics/normalize/asserted-arm-absence.js +61 -0
- package/dist/semantics/normalize/assignment-patterns.d.ts +70 -0
- package/dist/semantics/normalize/assignment-patterns.js +147 -0
- package/dist/semantics/normalize/bag-absence.d.ts +8 -0
- package/dist/semantics/normalize/bag-absence.js +42 -0
- package/dist/semantics/normalize/binding-fixpoint.d.ts +36 -0
- package/dist/semantics/normalize/binding-fixpoint.js +140 -0
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +16 -0
- package/dist/semantics/normalize/callback-parameter-contracts.js +91 -0
- package/dist/semantics/normalize/cells/agreement.d.ts +46 -0
- package/dist/semantics/normalize/cells/agreement.js +34 -0
- package/dist/semantics/normalize/cells/candidates.d.ts +17 -0
- package/dist/semantics/normalize/cells/candidates.js +35 -0
- package/dist/semantics/normalize/cells/facts.d.ts +19 -0
- package/dist/semantics/normalize/cells/facts.js +90 -0
- package/dist/semantics/normalize/cells/index.d.ts +10 -0
- package/dist/semantics/normalize/cells/index.js +6 -0
- package/dist/semantics/normalize/cells/model.d.ts +98 -0
- package/dist/semantics/normalize/cells/model.js +2 -0
- package/dist/semantics/normalize/cells/policies/bag.d.ts +44 -0
- package/dist/semantics/normalize/cells/policies/bag.js +114 -0
- package/dist/semantics/normalize/cells/policies/collection.d.ts +42 -0
- package/dist/semantics/normalize/cells/policies/collection.js +218 -0
- package/dist/semantics/normalize/cells/policies/field.d.ts +28 -0
- package/dist/semantics/normalize/cells/policies/field.js +40 -0
- package/dist/semantics/normalize/cells/policies/index.d.ts +49 -0
- package/dist/semantics/normalize/cells/policies/index.js +58 -0
- package/dist/semantics/normalize/cells/policies/local.d.ts +18 -0
- package/dist/semantics/normalize/cells/policies/local.js +37 -0
- package/dist/semantics/normalize/cells/policies/parameter.d.ts +28 -0
- package/dist/semantics/normalize/cells/policies/parameter.js +39 -0
- package/dist/semantics/normalize/cells/policies/return.d.ts +26 -0
- package/dist/semantics/normalize/cells/policies/return.js +45 -0
- package/dist/semantics/normalize/cells/policies/shared.d.ts +33 -0
- package/dist/semantics/normalize/cells/policies/shared.js +45 -0
- package/dist/semantics/normalize/cells/policy.d.ts +72 -0
- package/dist/semantics/normalize/cells/policy.js +18 -0
- package/dist/semantics/normalize/cells/registry.d.ts +14 -0
- package/dist/semantics/normalize/cells/registry.js +17 -0
- package/dist/semantics/normalize/census-refusal.d.ts +62 -0
- package/dist/semantics/normalize/census-refusal.js +27 -0
- package/dist/semantics/normalize/census.d.ts +109 -0
- package/dist/semantics/normalize/census.js +667 -0
- package/dist/semantics/normalize/collection-bindings.d.ts +278 -0
- package/dist/semantics/normalize/collection-bindings.js +677 -0
- package/dist/semantics/normalize/commonjs-module-record.d.ts +21 -0
- package/dist/semantics/normalize/commonjs-module-record.js +289 -0
- package/dist/semantics/normalize/commonjs-require.d.ts +13 -0
- package/dist/semantics/normalize/commonjs-require.js +1527 -0
- package/dist/semantics/normalize/contribution.d.ts +63 -0
- package/dist/semantics/normalize/contribution.js +172 -0
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +64 -0
- package/dist/semantics/normalize/dead-typeof-guards.js +152 -0
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +57 -0
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +109 -0
- package/dist/semantics/normalize/derived-expression-type.d.ts +1070 -0
- package/dist/semantics/normalize/derived-expression-type.js +3463 -0
- package/dist/semantics/normalize/evaluation-order.d.ts +16 -0
- package/dist/semantics/normalize/evaluation-order.js +37 -0
- package/dist/semantics/normalize/field-bindings.d.ts +167 -0
- package/dist/semantics/normalize/field-bindings.js +1125 -0
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +27 -0
- package/dist/semantics/normalize/flow/array-element-continuation.js +1452 -0
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +42 -0
- package/dist/semantics/normalize/flow/callable-array-origins.js +318 -0
- package/dist/semantics/normalize/flow/callable-completions.d.ts +45 -0
- package/dist/semantics/normalize/flow/callable-completions.js +82 -0
- package/dist/semantics/normalize/flow/callable-reach.d.ts +237 -0
- package/dist/semantics/normalize/flow/callable-reach.js +7174 -0
- package/dist/semantics/normalize/flow/class-family-member-read.d.ts +16 -0
- package/dist/semantics/normalize/flow/class-family-member-read.js +992 -0
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +21 -0
- package/dist/semantics/normalize/flow/collection-value-continuation.js +192 -0
- package/dist/semantics/normalize/flow/component-solver.d.ts +199 -0
- package/dist/semantics/normalize/flow/component-solver.js +587 -0
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +84 -0
- package/dist/semantics/normalize/flow/computed-key-set.js +660 -0
- package/dist/semantics/normalize/flow/export-importers.d.ts +24 -0
- package/dist/semantics/normalize/flow/export-importers.js +269 -0
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +25 -0
- package/dist/semantics/normalize/flow/host-text-sink.js +87 -0
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +84 -0
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +180 -0
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +35 -0
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +140 -0
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +98 -0
- package/dist/semantics/normalize/flow/invocation-facts.js +257 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +122 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +835 -0
- package/dist/semantics/normalize/flow/model.d.ts +357 -0
- package/dist/semantics/normalize/flow/model.js +177 -0
- package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +24 -0
- package/dist/semantics/normalize/flow/native-collection-protocol.js +252 -0
- package/dist/semantics/normalize/flow/node-path-token.d.ts +3 -0
- package/dist/semantics/normalize/flow/node-path-token.js +53 -0
- package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +11 -0
- package/dist/semantics/normalize/flow/object-binding-continuation.js +42 -0
- package/dist/semantics/normalize/flow/origin-authority.d.ts +56 -0
- package/dist/semantics/normalize/flow/origin-authority.js +2 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +35 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.js +191 -0
- package/dist/semantics/normalize/flow/parameter-values.d.ts +27 -0
- package/dist/semantics/normalize/flow/parameter-values.js +251 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +66 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +162 -0
- package/dist/semantics/normalize/flow/record-alias-closure.d.ts +27 -0
- package/dist/semantics/normalize/flow/record-alias-closure.js +298 -0
- package/dist/semantics/normalize/flow/seeded-origins.d.ts +43 -0
- package/dist/semantics/normalize/flow/seeded-origins.js +54 -0
- package/dist/semantics/normalize/flow/source-class-data.d.ts +132 -0
- package/dist/semantics/normalize/flow/source-class-data.js +838 -0
- package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-class-instanceof.js +37 -0
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +16 -0
- package/dist/semantics/normalize/flow/source-class-static-data.js +47 -0
- package/dist/semantics/normalize/flow/source-construction-frames.d.ts +12 -0
- package/dist/semantics/normalize/flow/source-construction-frames.js +118 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +34 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +78 -0
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +95 -0
- package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +23 -0
- package/dist/semantics/normalize/flow/source-prototype-method-identity.js +81 -0
- package/dist/semantics/normalize/flow/source-record-data.d.ts +29 -0
- package/dist/semantics/normalize/flow/source-record-data.js +626 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +77 -0
- package/dist/semantics/normalize/flow/source-value-session.js +3089 -0
- package/dist/semantics/normalize/flow/targets.d.ts +118 -0
- package/dist/semantics/normalize/flow/targets.js +405 -0
- package/dist/semantics/normalize/flow/value-flow.d.ts +36 -0
- package/dist/semantics/normalize/flow/value-flow.js +823 -0
- package/dist/semantics/normalize/flow/value-provenance.d.ts +31 -0
- package/dist/semantics/normalize/flow/value-provenance.js +112 -0
- package/dist/semantics/normalize/gating.d.ts +51 -0
- package/dist/semantics/normalize/gating.js +560 -0
- package/dist/semantics/normalize/generic-function-choice.d.ts +31 -0
- package/dist/semantics/normalize/generic-function-choice.js +115 -0
- package/dist/semantics/normalize/global-host-mutations.d.ts +51 -0
- package/dist/semantics/normalize/global-host-mutations.js +5989 -0
- package/dist/semantics/normalize/host-effect-contracts.d.ts +77 -0
- package/dist/semantics/normalize/host-effect-contracts.js +143 -0
- package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +38 -0
- package/dist/semantics/normalize/host-mutation-computed-keys.js +26 -0
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +66 -0
- package/dist/semantics/normalize/host-mutation-key-reader.js +192 -0
- package/dist/semantics/normalize/host-mutation-keys.d.ts +114 -0
- package/dist/semantics/normalize/host-mutation-keys.js +183 -0
- package/dist/semantics/normalize/identities.d.ts +172 -0
- package/dist/semantics/normalize/identities.js +426 -0
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +97 -0
- package/dist/semantics/normalize/implicit-arguments-tuple.js +197 -0
- package/dist/semantics/normalize/implicit-arguments.d.ts +11 -0
- package/dist/semantics/normalize/implicit-arguments.js +39 -0
- package/dist/semantics/normalize/instantiation.d.ts +73 -0
- package/dist/semantics/normalize/instantiation.js +399 -0
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +18 -0
- package/dist/semantics/normalize/intrinsic-property-call.js +69 -0
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +41 -0
- package/dist/semantics/normalize/intrinsic-prototype.js +87 -0
- package/dist/semantics/normalize/intrinsic-static-member.d.ts +14 -0
- package/dist/semantics/normalize/intrinsic-static-member.js +23 -0
- package/dist/semantics/normalize/jsdoc-type-names.d.ts +32 -0
- package/dist/semantics/normalize/jsdoc-type-names.js +512 -0
- package/dist/semantics/normalize/keyof.d.ts +32 -0
- package/dist/semantics/normalize/keyof.js +110 -0
- package/dist/semantics/normalize/local-bindings.d.ts +176 -0
- package/dist/semantics/normalize/local-bindings.js +1826 -0
- package/dist/semantics/normalize/logical-result-type.d.ts +16 -0
- package/dist/semantics/normalize/logical-result-type.js +102 -0
- package/dist/semantics/normalize/namespace-paths.d.ts +57 -0
- package/dist/semantics/normalize/namespace-paths.js +108 -0
- package/dist/semantics/normalize/normalize.d.ts +57 -0
- package/dist/semantics/normalize/normalize.js +68 -0
- package/dist/semantics/normalize/object-bag-bindings.d.ts +305 -0
- package/dist/semantics/normalize/object-bag-bindings.js +1290 -0
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +53 -0
- package/dist/semantics/normalize/omitted-stated-parameter.js +59 -0
- package/dist/semantics/normalize/open-type-form.d.ts +10 -0
- package/dist/semantics/normalize/open-type-form.js +32 -0
- package/dist/semantics/normalize/parameter-bindings.d.ts +361 -0
- package/dist/semantics/normalize/parameter-bindings.js +3339 -0
- package/dist/semantics/normalize/parameter-slot.d.ts +264 -0
- package/dist/semantics/normalize/parameter-slot.js +491 -0
- package/dist/semantics/normalize/physical-overload-result.d.ts +77 -0
- package/dist/semantics/normalize/physical-overload-result.js +99 -0
- package/dist/semantics/normalize/primitive-property-absence.d.ts +12 -0
- package/dist/semantics/normalize/primitive-property-absence.js +60 -0
- package/dist/semantics/normalize/producer-context.d.ts +376 -0
- package/dist/semantics/normalize/producer-context.js +1 -0
- package/dist/semantics/normalize/producers/allocations.d.ts +3 -0
- package/dist/semantics/normalize/producers/allocations.js +863 -0
- package/dist/semantics/normalize/producers/binding-kind.d.ts +37 -0
- package/dist/semantics/normalize/producers/binding-kind.js +36 -0
- package/dist/semantics/normalize/producers/bindings.d.ts +85 -0
- package/dist/semantics/normalize/producers/bindings.js +710 -0
- package/dist/semantics/normalize/producers/boundary.d.ts +34 -0
- package/dist/semantics/normalize/producers/boundary.js +123 -0
- package/dist/semantics/normalize/producers/class-lifecycle.d.ts +3 -0
- package/dist/semantics/normalize/producers/class-lifecycle.js +902 -0
- package/dist/semantics/normalize/producers/computations.d.ts +3 -0
- package/dist/semantics/normalize/producers/computations.js +613 -0
- package/dist/semantics/normalize/producers/control-loops.d.ts +30 -0
- package/dist/semantics/normalize/producers/control-loops.js +91 -0
- package/dist/semantics/normalize/producers/control.d.ts +30 -0
- package/dist/semantics/normalize/producers/control.js +923 -0
- package/dist/semantics/normalize/producers/declaration-lifecycle.d.ts +3 -0
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +390 -0
- package/dist/semantics/normalize/producers/destructuring.d.ts +45 -0
- package/dist/semantics/normalize/producers/destructuring.js +1180 -0
- package/dist/semantics/normalize/producers/dynamic-language.d.ts +3 -0
- package/dist/semantics/normalize/producers/dynamic-language.js +70 -0
- package/dist/semantics/normalize/producers/erasure.d.ts +51 -0
- package/dist/semantics/normalize/producers/erasure.js +90 -0
- package/dist/semantics/normalize/producers/installed.d.ts +3 -0
- package/dist/semantics/normalize/producers/installed.js +55 -0
- package/dist/semantics/normalize/producers/invocations.d.ts +35 -0
- package/dist/semantics/normalize/producers/invocations.js +1796 -0
- package/dist/semantics/normalize/producers/iteration-yield.d.ts +59 -0
- package/dist/semantics/normalize/producers/iteration-yield.js +235 -0
- package/dist/semantics/normalize/producers/jsx.d.ts +3 -0
- package/dist/semantics/normalize/producers/jsx.js +360 -0
- package/dist/semantics/normalize/producers/mint.d.ts +39 -0
- package/dist/semantics/normalize/producers/mint.js +44 -0
- package/dist/semantics/normalize/producers/nullish.d.ts +16 -0
- package/dist/semantics/normalize/producers/nullish.js +27 -0
- package/dist/semantics/normalize/producers/object-assignment.d.ts +8 -0
- package/dist/semantics/normalize/producers/object-assignment.js +204 -0
- package/dist/semantics/normalize/producers/object-tag.d.ts +9 -0
- package/dist/semantics/normalize/producers/object-tag.js +119 -0
- package/dist/semantics/normalize/producers/optional-chain.d.ts +44 -0
- package/dist/semantics/normalize/producers/optional-chain.js +75 -0
- package/dist/semantics/normalize/producers/properties.d.ts +21 -0
- package/dist/semantics/normalize/producers/properties.js +1053 -0
- package/dist/semantics/normalize/producers/protocol.d.ts +67 -0
- package/dist/semantics/normalize/producers/protocol.js +695 -0
- package/dist/semantics/normalize/producers/references.d.ts +53 -0
- package/dist/semantics/normalize/producers/references.js +1027 -0
- package/dist/semantics/normalize/producers/shared.d.ts +561 -0
- package/dist/semantics/normalize/producers/shared.js +1683 -0
- package/dist/semantics/normalize/producers/spread-arguments.d.ts +72 -0
- package/dist/semantics/normalize/producers/spread-arguments.js +375 -0
- package/dist/semantics/normalize/producers/tagged-template.d.ts +5 -0
- package/dist/semantics/normalize/producers/tagged-template.js +307 -0
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +189 -0
- package/dist/semantics/normalize/producers/tuple-spread.js +279 -0
- package/dist/semantics/normalize/property-key-domain.d.ts +36 -0
- package/dist/semantics/normalize/property-key-domain.js +150 -0
- package/dist/semantics/normalize/reachability.d.ts +189 -0
- package/dist/semantics/normalize/reachability.js +1057 -0
- package/dist/semantics/normalize/reassigned-bindings.d.ts +13 -0
- package/dist/semantics/normalize/reassigned-bindings.js +41 -0
- package/dist/semantics/normalize/record-storage-families.d.ts +11 -0
- package/dist/semantics/normalize/record-storage-families.js +109 -0
- package/dist/semantics/normalize/return-bindings.d.ts +260 -0
- package/dist/semantics/normalize/return-bindings.js +1311 -0
- package/dist/semantics/normalize/return-paths.d.ts +2 -0
- package/dist/semantics/normalize/return-paths.js +28 -0
- package/dist/semantics/normalize/script-global-redefinition.d.ts +44 -0
- package/dist/semantics/normalize/script-global-redefinition.js +75 -0
- package/dist/semantics/normalize/specialization.d.ts +201 -0
- package/dist/semantics/normalize/specialization.js +1824 -0
- package/dist/semantics/normalize/structural-array-element.d.ts +176 -0
- package/dist/semantics/normalize/structural-array-element.js +700 -0
- package/dist/semantics/normalize/structural-array-read.d.ts +13 -0
- package/dist/semantics/normalize/structural-array-read.js +124 -0
- package/dist/semantics/normalize/structural-callable.d.ts +12 -0
- package/dist/semantics/normalize/structural-callable.js +82 -0
- package/dist/semantics/normalize/structural-creation-order.d.ts +32 -0
- package/dist/semantics/normalize/structural-creation-order.js +111 -0
- package/dist/semantics/normalize/structural-declarations.d.ts +395 -0
- package/dist/semantics/normalize/structural-declarations.js +968 -0
- package/dist/semantics/normalize/structural-declared-body.d.ts +25 -0
- package/dist/semantics/normalize/structural-declared-body.js +147 -0
- package/dist/semantics/normalize/structural-generics.d.ts +56 -0
- package/dist/semantics/normalize/structural-generics.js +120 -0
- package/dist/semantics/normalize/structural-indexed-access.d.ts +11 -0
- package/dist/semantics/normalize/structural-indexed-access.js +126 -0
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +64 -0
- package/dist/semantics/normalize/structural-instantiated-member.js +407 -0
- package/dist/semantics/normalize/structural-joins.d.ts +44 -0
- package/dist/semantics/normalize/structural-joins.js +143 -0
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +29 -0
- package/dist/semantics/normalize/structural-layout-relevance.js +391 -0
- package/dist/semantics/normalize/structural-layout-type.d.ts +11 -0
- package/dist/semantics/normalize/structural-layout-type.js +1468 -0
- package/dist/semantics/normalize/structural-leaves.d.ts +49 -0
- package/dist/semantics/normalize/structural-leaves.js +125 -0
- package/dist/semantics/normalize/structural-local-union.d.ts +13 -0
- package/dist/semantics/normalize/structural-local-union.js +133 -0
- package/dist/semantics/normalize/structural-members.d.ts +26 -0
- package/dist/semantics/normalize/structural-members.js +84 -0
- package/dist/semantics/normalize/structural-mutable-method.d.ts +15 -0
- package/dist/semantics/normalize/structural-mutable-method.js +109 -0
- package/dist/semantics/normalize/structural-parts.d.ts +131 -0
- package/dist/semantics/normalize/structural-parts.js +737 -0
- package/dist/semantics/normalize/structural-receiver.d.ts +66 -0
- package/dist/semantics/normalize/structural-receiver.js +551 -0
- package/dist/semantics/normalize/structural-rules.d.ts +112 -0
- package/dist/semantics/normalize/structural-rules.js +93 -0
- package/dist/semantics/normalize/structural-self-reference.d.ts +150 -0
- package/dist/semantics/normalize/structural-self-reference.js +494 -0
- package/dist/semantics/normalize/structural.d.ts +202 -0
- package/dist/semantics/normalize/structural.js +4218 -0
- package/dist/semantics/normalize/unreduced-type-form.d.ts +41 -0
- package/dist/semantics/normalize/unreduced-type-form.js +53 -0
- package/dist/semantics/normalize/unresolvable-names.d.ts +56 -0
- package/dist/semantics/normalize/unresolvable-names.js +140 -0
- package/dist/semantics/package-sources.d.ts +16 -0
- package/dist/semantics/package-sources.js +365 -0
- package/dist/semantics/program.d.ts +151 -0
- package/dist/semantics/program.js +667 -0
- package/dist/semantics/prototype-install-source-transform.d.ts +4 -0
- package/dist/semantics/prototype-install-source-transform.js +341 -0
- package/dist/semantics/prototype-object-class-source-transform.d.ts +4 -0
- package/dist/semantics/prototype-object-class-source-transform.js +525 -0
- package/dist/semantics/prototype-reparenting.d.ts +50 -0
- package/dist/semantics/prototype-reparenting.js +317 -0
- package/dist/semantics/stable-checker.d.ts +10 -0
- package/dist/semantics/stable-checker.js +148 -0
- package/dist/semantics/subclass-member-overlay-transform.d.ts +35 -0
- package/dist/semantics/subclass-member-overlay-transform.js +1418 -0
- package/dist/semantics/symbol-keyed-expando-source-transform.d.ts +4 -0
- package/dist/semantics/symbol-keyed-expando-source-transform.js +66 -0
- package/dist/semantics/this-constructor-source-transform.d.ts +4 -0
- package/dist/semantics/this-constructor-source-transform.js +122 -0
- package/dist/semantics/uninstantiable-classes.d.ts +22 -0
- package/dist/semantics/uninstantiable-classes.js +75 -0
- package/dist/targets/cpp/balanced-units.d.ts +3 -0
- package/dist/targets/cpp/balanced-units.js +58 -0
- package/dist/targets/cpp/borrowed-call-entry.d.ts +30 -0
- package/dist/targets/cpp/borrowed-call-entry.js +68 -0
- package/dist/targets/cpp/captures.d.ts +68 -0
- package/dist/targets/cpp/captures.js +269 -0
- package/dist/targets/cpp/class-layout.d.ts +313 -0
- package/dist/targets/cpp/class-layout.js +483 -0
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +25 -0
- package/dist/targets/cpp/class-properties/computed-method-value.js +22 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +216 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.js +917 -0
- package/dist/targets/cpp/class-properties/native-prototype.d.ts +11 -0
- package/dist/targets/cpp/class-properties/native-prototype.js +101 -0
- package/dist/targets/cpp/class-ref-transport.d.ts +12 -0
- package/dist/targets/cpp/class-ref-transport.js +32 -0
- package/dist/targets/cpp/conversions.d.ts +3 -0
- package/dist/targets/cpp/conversions.js +2027 -0
- package/dist/targets/cpp/deferral-safety.d.ts +82 -0
- package/dist/targets/cpp/deferral-safety.js +86 -0
- package/dist/targets/cpp/direct-call-receivers.d.ts +37 -0
- package/dist/targets/cpp/direct-call-receivers.js +79 -0
- package/dist/targets/cpp/document.d.ts +74 -0
- package/dist/targets/cpp/document.js +106 -0
- package/dist/targets/cpp/emit-allocation.d.ts +60 -0
- package/dist/targets/cpp/emit-allocation.js +573 -0
- package/dist/targets/cpp/emit-arrays.d.ts +119 -0
- package/dist/targets/cpp/emit-arrays.js +1047 -0
- package/dist/targets/cpp/emit-binding-reference.d.ts +17 -0
- package/dist/targets/cpp/emit-binding-reference.js +120 -0
- package/dist/targets/cpp/emit-bindings.d.ts +158 -0
- package/dist/targets/cpp/emit-bindings.js +769 -0
- package/dist/targets/cpp/emit-buffers.d.ts +156 -0
- package/dist/targets/cpp/emit-buffers.js +573 -0
- package/dist/targets/cpp/emit-callable.d.ts +230 -0
- package/dist/targets/cpp/emit-callable.js +2154 -0
- package/dist/targets/cpp/emit-carrier-members.d.ts +406 -0
- package/dist/targets/cpp/emit-carrier-members.js +1224 -0
- package/dist/targets/cpp/emit-coercion.d.ts +26 -0
- package/dist/targets/cpp/emit-coercion.js +39 -0
- package/dist/targets/cpp/emit-context.d.ts +1882 -0
- package/dist/targets/cpp/emit-context.js +904 -0
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +174 -0
- package/dist/targets/cpp/emit-dynamic-properties.js +1249 -0
- package/dist/targets/cpp/emit-equality.d.ts +39 -0
- package/dist/targets/cpp/emit-equality.js +472 -0
- package/dist/targets/cpp/emit-exceptions.d.ts +104 -0
- package/dist/targets/cpp/emit-exceptions.js +513 -0
- package/dist/targets/cpp/emit-field-owner.d.ts +4 -0
- package/dist/targets/cpp/emit-field-owner.js +27 -0
- package/dist/targets/cpp/emit-in.d.ts +31 -0
- package/dist/targets/cpp/emit-in.js +426 -0
- package/dist/targets/cpp/emit-instanceof.d.ts +19 -0
- package/dist/targets/cpp/emit-instanceof.js +601 -0
- package/dist/targets/cpp/emit-integers.d.ts +68 -0
- package/dist/targets/cpp/emit-integers.js +184 -0
- package/dist/targets/cpp/emit-iterator.d.ts +100 -0
- package/dist/targets/cpp/emit-iterator.js +1137 -0
- package/dist/targets/cpp/emit-json.d.ts +73 -0
- package/dist/targets/cpp/emit-json.js +823 -0
- package/dist/targets/cpp/emit-jsx.d.ts +74 -0
- package/dist/targets/cpp/emit-jsx.js +806 -0
- package/dist/targets/cpp/emit-mixed-binary.d.ts +51 -0
- package/dist/targets/cpp/emit-mixed-binary.js +60 -0
- package/dist/targets/cpp/emit-namespaces.d.ts +101 -0
- package/dist/targets/cpp/emit-namespaces.js +133 -0
- package/dist/targets/cpp/emit-narrowing.d.ts +738 -0
- package/dist/targets/cpp/emit-narrowing.js +3967 -0
- package/dist/targets/cpp/emit-native-equality.d.ts +3 -0
- package/dist/targets/cpp/emit-native-equality.js +14 -0
- package/dist/targets/cpp/emit-native-selection.d.ts +5 -0
- package/dist/targets/cpp/emit-native-selection.js +37 -0
- package/dist/targets/cpp/emit-object-tag.d.ts +4 -0
- package/dist/targets/cpp/emit-object-tag.js +108 -0
- package/dist/targets/cpp/emit-owned-record.d.ts +2 -0
- package/dist/targets/cpp/emit-owned-record.js +15 -0
- package/dist/targets/cpp/emit-presence.d.ts +78 -0
- package/dist/targets/cpp/emit-presence.js +376 -0
- package/dist/targets/cpp/emit-properties.d.ts +105 -0
- package/dist/targets/cpp/emit-properties.js +1640 -0
- package/dist/targets/cpp/emit-record-view.d.ts +20 -0
- package/dist/targets/cpp/emit-record-view.js +354 -0
- package/dist/targets/cpp/emit-return.d.ts +5 -0
- package/dist/targets/cpp/emit-return.js +237 -0
- package/dist/targets/cpp/emit-sum-widening.d.ts +10 -0
- package/dist/targets/cpp/emit-sum-widening.js +69 -0
- package/dist/targets/cpp/emit-tonumber.d.ts +38 -0
- package/dist/targets/cpp/emit-tonumber.js +177 -0
- package/dist/targets/cpp/emit-tostring.d.ts +92 -0
- package/dist/targets/cpp/emit-tostring.js +556 -0
- package/dist/targets/cpp/emit-typeof.d.ts +49 -0
- package/dist/targets/cpp/emit-typeof.js +317 -0
- package/dist/targets/cpp/emit-union-properties.d.ts +181 -0
- package/dist/targets/cpp/emit-union-properties.js +1281 -0
- package/dist/targets/cpp/emit.d.ts +45 -0
- package/dist/targets/cpp/emit.js +2225 -0
- package/dist/targets/cpp/error-types.d.ts +4 -0
- package/dist/targets/cpp/error-types.js +11 -0
- package/dist/targets/cpp/function-source-reads.d.ts +72 -0
- package/dist/targets/cpp/function-source-reads.js +148 -0
- package/dist/targets/cpp/host/atomics.d.ts +25 -0
- package/dist/targets/cpp/host/atomics.js +63 -0
- package/dist/targets/cpp/host/core-globals.d.ts +108 -0
- package/dist/targets/cpp/host/core-globals.js +158 -0
- package/dist/targets/cpp/host/dynamic-argument-members.d.ts +42 -0
- package/dist/targets/cpp/host/dynamic-argument-members.js +61 -0
- package/dist/targets/cpp/host/emit-host-arity.d.ts +139 -0
- package/dist/targets/cpp/host/emit-host-arity.js +232 -0
- package/dist/targets/cpp/host/emit-host-invoke.d.ts +91 -0
- package/dist/targets/cpp/host/emit-host-invoke.js +1105 -0
- package/dist/targets/cpp/host/emit-host-object.d.ts +55 -0
- package/dist/targets/cpp/host/emit-host-object.js +2206 -0
- package/dist/targets/cpp/host/emit-host-properties.d.ts +69 -0
- package/dist/targets/cpp/host/emit-host-properties.js +533 -0
- package/dist/targets/cpp/host/emit-host-reflect.d.ts +4 -0
- package/dist/targets/cpp/host/emit-host-reflect.js +180 -0
- package/dist/targets/cpp/host/emit-host-value.d.ts +120 -0
- package/dist/targets/cpp/host/emit-host-value.js +392 -0
- package/dist/targets/cpp/host/host-members.d.ts +505 -0
- package/dist/targets/cpp/host/host-members.js +819 -0
- package/dist/targets/cpp/host/host-method-aliases.d.ts +30 -0
- package/dist/targets/cpp/host/host-method-aliases.js +76 -0
- package/dist/targets/cpp/host/native-protocols.d.ts +47 -0
- package/dist/targets/cpp/host/native-protocols.js +183 -0
- package/dist/targets/cpp/host/object-protocol.d.ts +351 -0
- package/dist/targets/cpp/host/object-protocol.js +671 -0
- package/dist/targets/cpp/host-namespace-reads.d.ts +83 -0
- package/dist/targets/cpp/host-namespace-reads.js +113 -0
- package/dist/targets/cpp/manifest/capabilities.d.ts +39 -0
- package/dist/targets/cpp/manifest/capabilities.js +1484 -0
- package/dist/targets/cpp/manifest.d.ts +23 -0
- package/dist/targets/cpp/manifest.js +113 -0
- package/dist/targets/cpp/native-error-base.d.ts +38 -0
- package/dist/targets/cpp/native-error-base.js +74 -0
- package/dist/targets/cpp/native-narrowing-transport.d.ts +12 -0
- package/dist/targets/cpp/native-narrowing-transport.js +151 -0
- package/dist/targets/cpp/native-selection-helpers.d.ts +11 -0
- package/dist/targets/cpp/native-selection-helpers.js +46 -0
- package/dist/targets/cpp/native-symbol-keys.d.ts +8 -0
- package/dist/targets/cpp/native-symbol-keys.js +34 -0
- package/dist/targets/cpp/ownership.d.ts +43 -0
- package/dist/targets/cpp/ownership.js +38 -0
- package/dist/targets/cpp/owning-conversion-input.d.ts +14 -0
- package/dist/targets/cpp/owning-conversion-input.js +12 -0
- package/dist/targets/cpp/property-read-claims.d.ts +62 -0
- package/dist/targets/cpp/property-read-claims.js +23 -0
- package/dist/targets/cpp/property-store-claims.d.ts +62 -0
- package/dist/targets/cpp/property-store-claims.js +26 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +111 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.js +602 -0
- package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +133 -0
- package/dist/targets/cpp/prototype/emit-prototype-date.js +515 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +13 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.js +54 -0
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +34 -0
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +1003 -0
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +47 -0
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +250 -0
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +46 -0
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +143 -0
- package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +335 -0
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +853 -0
- package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +42 -0
- package/dist/targets/cpp/prototype/emit-prototype-string.js +252 -0
- package/dist/targets/cpp/prototype/prototype-method-reads.d.ts +25 -0
- package/dist/targets/cpp/prototype/prototype-method-reads.js +182 -0
- package/dist/targets/cpp/reactive-dependencies.d.ts +140 -0
- package/dist/targets/cpp/reactive-dependencies.js +432 -0
- package/dist/targets/cpp/reactive-origins.d.ts +44 -0
- package/dist/targets/cpp/reactive-origins.js +82 -0
- package/dist/targets/cpp/records.d.ts +277 -0
- package/dist/targets/cpp/records.js +2427 -0
- package/dist/targets/cpp/recursive-containers.d.ts +43 -0
- package/dist/targets/cpp/recursive-containers.js +144 -0
- package/dist/targets/cpp/regexp-types.d.ts +56 -0
- package/dist/targets/cpp/regexp-types.js +59 -0
- package/dist/targets/cpp/substrate.d.ts +125 -0
- package/dist/targets/cpp/substrate.js +12 -0
- package/dist/targets/cpp/translation-unit.d.ts +219 -0
- package/dist/targets/cpp/translation-unit.js +2063 -0
- package/dist/targets/cpp/types.d.ts +280 -0
- package/dist/targets/cpp/types.js +1135 -0
- package/dist/targets/cpp/virtual-methods.d.ts +95 -0
- package/dist/targets/cpp/virtual-methods.js +264 -0
- package/package.json +95 -0
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +824 -0
- package/src/targets/cpp/runtime/gea_eval.h +1376 -0
- package/src/targets/cpp/runtime/gea_native_class_prototype.h +44 -0
- package/src/targets/cpp/runtime/gea_runtime.h +29222 -0
- package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +55 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
import { representationKey } from '../../representation/model.js';
|
|
2
|
+
import { nativeEnumerationPlanOf } from '../../ir/native-enumeration.js';
|
|
3
|
+
import { createCppEmitBlockedError, defineValue, operandText, paddedArguments } from './emit-context.js';
|
|
4
|
+
import { receiverArgumentText } from './emit-callable.js';
|
|
5
|
+
import { memberAccessOperator } from './emit-carrier-members.js';
|
|
6
|
+
import { cppRecordFieldName, cppRecordFieldPresenceName, cppBodyName, cppStringLiteral, cppTypeOf, cppUndefinedIn, cppUndefinedValue } from './types.js';
|
|
7
|
+
import { alignedValueText } from './emit-narrowing.js';
|
|
8
|
+
import { dispatchedLeafExpression, unionPropertyLeaves } from './emit-union-properties.js';
|
|
9
|
+
import { recordAccessorsOfShape, recordFieldsOfShape } from './records.js';
|
|
10
|
+
import { renderTryRegion } from './emit-exceptions.js';
|
|
11
|
+
import { accessorEnvironmentArguments } from './emit-properties.js';
|
|
12
|
+
const isStaticEnumerationTarget = (target) => target.kind === 'record' || target.kind === 'record-with-index' || target.kind === 'class-ref' || target.kind === 'native-record-ref';
|
|
13
|
+
/**
|
|
14
|
+
* `for`-`in` over a statically shaped receiver, constructed from the snapshot
|
|
15
|
+
* a shared C++ helper (`gea::nativeDynamicKeys`) already knows how to build --
|
|
16
|
+
* see this file's own header comment for why this is a static question rather
|
|
17
|
+
* than a boxed walk.
|
|
18
|
+
*
|
|
19
|
+
* Returns `false` -- emitting nothing -- for a target this static path cannot
|
|
20
|
+
* spell, so its caller can fall through to the next candidate rather than this
|
|
21
|
+
* function committing to a throw the caller did not ask for.
|
|
22
|
+
*/
|
|
23
|
+
const emitStaticEnumerateIterator = (ctx, lines, operation, target) => {
|
|
24
|
+
if (!isStaticEnumerationTarget(target))
|
|
25
|
+
return false;
|
|
26
|
+
// A `native-record-ref` naming a HOST struct has no C++ definition this
|
|
27
|
+
// backend renders (`types.ts`'s own comment: "records.ts emits no struct for
|
|
28
|
+
// it"), so it never gets the `gea_ownFieldKeys`/`gea_readOwnField` dispatcher
|
|
29
|
+
// `nativeDynamicKeys` calls -- refused by name rather than reaching a method
|
|
30
|
+
// that does not exist on the host's own type.
|
|
31
|
+
if (target.kind === 'native-record-ref' && target.native !== null) {
|
|
32
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:enumerate:get-iterator:native-record-ref', 'enumerates a "native-record-ref" receiver naming a host-defined struct, which carries no compiler-rendered field ' +
|
|
33
|
+
'dispatcher for this walk to call');
|
|
34
|
+
}
|
|
35
|
+
// Every one of the four static kinds carries an `ownership` field; the
|
|
36
|
+
// dynamic-property sidecar this walk also visits needs the object's own
|
|
37
|
+
// shared identity to key on, exactly as `emit-dynamic-properties.ts`'s
|
|
38
|
+
// `nativeSidecarReceiver` requires for the identical reason -- a by-value
|
|
39
|
+
// struct has no stable address the sidecar table could be keyed on.
|
|
40
|
+
if (target.ownership !== 'shared-refcount') {
|
|
41
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:enumerate:get-iterator:${target.kind}`, `enumerates a "${target.kind}" receiver carried with ownership "${target.ownership}"; the dynamic-property sidecar this ` +
|
|
42
|
+
"walk also visits needs the object's own shared identity to key on, which a by-value struct does not have");
|
|
43
|
+
}
|
|
44
|
+
const receiver = operandText(ctx, operation.receiver);
|
|
45
|
+
const name = defineValue(ctx, operation.result);
|
|
46
|
+
lines.push(`${name} = gea::Iterator<std::string>(gea::nativeDynamicKeys(${receiver}), ` +
|
|
47
|
+
`std::function<bool(const std::string&)>([gea_receiver = ${receiver}](const std::string& gea_key) { ` +
|
|
48
|
+
'return gea::nativeDynamicHas(gea_receiver, gea::PropertyKey::string(gea_key)); }));');
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* `for`-`of` over a fixed-arity tuple, whose storage is a struct with one
|
|
53
|
+
* member per position (`gea_slot_0`, `gea_slot_1`, ...) rather than any
|
|
54
|
+
* container `gea::Iterator` has a constructor for. The cursor is built from a
|
|
55
|
+
* reader closure that returns the member at a given step -- a `switch` over
|
|
56
|
+
* the positions, which is the whole of the walk because the position count is
|
|
57
|
+
* a compile-time fact.
|
|
58
|
+
*
|
|
59
|
+
* This is a VALUES walk over the same `record` carrier `for`-`in` walks for
|
|
60
|
+
* its KEYS, which is why `emitGetIterator` dispatches on the operation's own
|
|
61
|
+
* `protocol` before reaching either: for a tuple of strings both cursors are
|
|
62
|
+
* `gea::Iterator<std::string>`, so neither carrier can tell them apart and
|
|
63
|
+
* picking the wrong one would compile cleanly and yield `"0", "1", "2"` where
|
|
64
|
+
* the program asked for its elements.
|
|
65
|
+
*
|
|
66
|
+
* Every field must be positional, required, and carried identically -- one
|
|
67
|
+
* cursor has one element type. `preflight/runtime-helper-key.ts`'s
|
|
68
|
+
* `isUniformTupleRecord` already keeps a heterogeneous tuple off the claimed
|
|
69
|
+
* `record(tuple-values)` key, so the checks here are fail-closed re-checks of
|
|
70
|
+
* that guarantee rather than a first opinion, the same posture every other
|
|
71
|
+
* source in this file takes.
|
|
72
|
+
*/
|
|
73
|
+
const emitStaticTupleIterator = (ctx, lines, operation, target, element) => {
|
|
74
|
+
if (target.kind !== 'record' || target.fields.length === 0)
|
|
75
|
+
return false;
|
|
76
|
+
const elementType = cppTypeOf(element);
|
|
77
|
+
const positional = target.fields.every((field, position) => field.key === String(position) && field.required);
|
|
78
|
+
if (!positional)
|
|
79
|
+
return false;
|
|
80
|
+
const uniform = target.fields.every((field) => cppTypeOf(field.value) === elementType);
|
|
81
|
+
if (!uniform) {
|
|
82
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:get-iterator:record(tuple-values)', `iterates a tuple whose positions do not share one carrier, so the single "${elementType}" element type its cursor would ` +
|
|
83
|
+
'have to publish is not the type of every position');
|
|
84
|
+
}
|
|
85
|
+
const accessor = memberAccessOperator(target.ownership);
|
|
86
|
+
const receiver = operandText(ctx, operation.receiver);
|
|
87
|
+
const name = defineValue(ctx, operation.result);
|
|
88
|
+
const cases = target.fields
|
|
89
|
+
.map((field, position) => `case ${position}: gea_out = gea_receiver${accessor}${cppRecordFieldName(field.key)}; return true;`)
|
|
90
|
+
.join(' ');
|
|
91
|
+
lines.push(`${name} = ${cppTypeOf(operation.result.representation)}(std::function<bool(std::size_t, ${elementType}&)>(` +
|
|
92
|
+
`[gea_receiver = ${receiver}](std::size_t gea_position, ${elementType}& gea_out) -> bool { ` +
|
|
93
|
+
`switch (gea_position) { ${cases} default: return false; } }));`);
|
|
94
|
+
return true;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A named layout is a record everywhere the iterator protocol asks about one.
|
|
98
|
+
*
|
|
99
|
+
* `interface Bag { [Symbol.iterator](): IterableIterator<T> }` derives a
|
|
100
|
+
* `native-record-ref` -- the nominal carrier that keeps a self-referential
|
|
101
|
+
* declaration finite -- while the very same shape written inline derives a
|
|
102
|
+
* structural `record`. Every step below reads a FIELD off the shape (`next`,
|
|
103
|
+
* `value`, `done`); which of the two carriers names it changes only where the
|
|
104
|
+
* field list is written down, never whether the field exists, so both go
|
|
105
|
+
* through the one layout authority `cppRecordDeclarations` builds the struct
|
|
106
|
+
* body from instead of each step forming its own opinion.
|
|
107
|
+
*
|
|
108
|
+
* A host-bound shape (`native !== null`) is deliberately excluded: the engine
|
|
109
|
+
* spells those members, not this compiler, so its own field list is not the
|
|
110
|
+
* struct being read -- the identical split `preflight/runtime-helper-key.ts`'s
|
|
111
|
+
* `enumerateGetIteratorCarrierKind` already makes for the enumerate protocol.
|
|
112
|
+
*/
|
|
113
|
+
const iteratorRecordFieldsOf = (ctx, representation) => {
|
|
114
|
+
if (representation.kind === 'record')
|
|
115
|
+
return representation.fields;
|
|
116
|
+
if (representation.kind !== 'native-record-ref' || representation.native !== null)
|
|
117
|
+
return null;
|
|
118
|
+
return recordFieldsOfShape(ctx.deriver, representation.shapeId);
|
|
119
|
+
};
|
|
120
|
+
const iteratorRecordAccessorsOf = (ctx, representation) => {
|
|
121
|
+
if (representation.kind === 'record')
|
|
122
|
+
return representation.accessors;
|
|
123
|
+
if (representation.kind !== 'native-record-ref' || representation.native !== null)
|
|
124
|
+
return null;
|
|
125
|
+
return recordAccessorsOfShape(ctx.deriver, representation.shapeId);
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* `for`-`in` over a `native-handle` receiver (`Math`, `Array.prototype`, ...).
|
|
129
|
+
*
|
|
130
|
+
* ECMA-262 declares every own property of a host intrinsic non-enumerable --
|
|
131
|
+
* 21.3.1's Math constants are `{writable: false, enumerable: false,
|
|
132
|
+
* configurable: false}`, and a builtin method is `{writable: true,
|
|
133
|
+
* enumerable: false, configurable: true}` (10.2.4 `SetFunctionLength`/
|
|
134
|
+
* `AddRestrictedFunctionProperties` and the per-clause "the length/name
|
|
135
|
+
* property" language throughout clause 21) -- so a `for`-`in` walk over one
|
|
136
|
+
* always visits zero keys, regardless of which intrinsic it is or how many
|
|
137
|
+
* members the checker's own lib types say it has. There is nothing to name at
|
|
138
|
+
* runtime here, unlike `emitStaticEnumerateIterator`'s struct walk: the empty
|
|
139
|
+
* vector plus an always-false presence predicate is the whole cursor, and the
|
|
140
|
+
* receiver text is never read at all (a `gea::NativeHandle<...>` carries no
|
|
141
|
+
* runtime value to key a table on regardless).
|
|
142
|
+
*/
|
|
143
|
+
const emitNativeHandleEnumerateIterator = (ctx, lines, operation) => {
|
|
144
|
+
const name = defineValue(ctx, operation.result);
|
|
145
|
+
lines.push(`${name} = gea::Iterator<std::string>(std::vector<std::string>{}, ` +
|
|
146
|
+
'std::function<bool(const std::string&)>([](const std::string&) { return false; }));');
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* `for`-`in` over a callable: the shared function-object table's own
|
|
150
|
+
* enumerable string keys. `name`/`length` are installed non-enumerable first
|
|
151
|
+
* so the walk sees exactly the expandos the program wrote, and a key deleted
|
|
152
|
+
* mid-walk is skipped the way the dynamic walk below skips one.
|
|
153
|
+
*/
|
|
154
|
+
const emitCallableEnumerateIterator = (ctx, lines, operation) => {
|
|
155
|
+
const receiver = operandText(ctx, operation.receiver);
|
|
156
|
+
const name = defineValue(ctx, operation.result);
|
|
157
|
+
lines.push(`${name} = gea::Iterator<std::string>(([&]() { const auto& __gea_callable = ${receiver}; ` +
|
|
158
|
+
'gea::installCallableOwnFacts(__gea_callable.functionObjectIdentity(), __gea_callable.name(), __gea_callable.length()); ' +
|
|
159
|
+
'std::vector<std::string> __gea_keys; for (const auto& __gea_key : __gea_callable.functionObjectIdentity()->properties->ownKeys()) { ' +
|
|
160
|
+
'if (__gea_key.isSymbol()) continue; const gea::PropertyDescriptor* __gea_own = __gea_callable.functionObjectIdentity()->properties->ownProperty(__gea_key); ' +
|
|
161
|
+
'if (__gea_own != nullptr && __gea_own->enumerable) __gea_keys.push_back(__gea_key.text()); } return __gea_keys; })(), ' +
|
|
162
|
+
`std::function<bool(const std::string&)>([gea_receiver = ${receiver}](const std::string& gea_key) { ` +
|
|
163
|
+
'return static_cast<bool>(gea_receiver.functionObjectIdentity()->properties->ownProperty(gea::PropertyKey::string(gea_key))); }));');
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* `for`-`in` over an ARRAY -- ECMA-262 14.7.5.9 over the array exotic object's
|
|
167
|
+
* own key space: its present indices as decimal strings, then whatever string
|
|
168
|
+
* keys an expando write put on the same object.
|
|
169
|
+
*
|
|
170
|
+
* It is reached by dispatching on the operation's own `protocol` BEFORE the
|
|
171
|
+
* shared collection path below, for the identical reason `for`-`of` over a
|
|
172
|
+
* tuple record is: an `array-object` is a `nativeSource` down there, and the
|
|
173
|
+
* cursor that path builds walks the array's ELEMENTS. For `number[]` both
|
|
174
|
+
* cursors compile, so picking the wrong one is not a compile error -- it is a
|
|
175
|
+
* program that yields `1, 2, 3` where the language yields `"0", "1", "2"`.
|
|
176
|
+
* hono's regexp router is the call site (`for (const i in
|
|
177
|
+
* indexReplacementMap)`, with its own comment saying it uses `in` precisely
|
|
178
|
+
* because the array is SPARSE), and a values walk would have visited the holes
|
|
179
|
+
* it is written to skip.
|
|
180
|
+
*
|
|
181
|
+
* The snapshot-plus-recheck shape is the one every other `for`-`in` source
|
|
182
|
+
* here uses, and `gea::arrayOwnEnumerableKeys` was already written for
|
|
183
|
+
* `Object.keys` of the same receiver -- so the two answers cannot disagree
|
|
184
|
+
* about what an array's own enumerable keys are.
|
|
185
|
+
*/
|
|
186
|
+
const emitArrayEnumerateIterator = (ctx, lines, operation) => {
|
|
187
|
+
const receiver = operandText(ctx, operation.receiver);
|
|
188
|
+
const name = defineValue(ctx, operation.result);
|
|
189
|
+
lines.push(`${name} = gea::Iterator<std::string>(gea::arrayOwnEnumerableKeys(${receiver}), ` +
|
|
190
|
+
`std::function<bool(const std::string&)>([gea_receiver = ${receiver}](const std::string& gea_key) { ` +
|
|
191
|
+
'return gea::arrayHasOwnEnumerableKey(gea_receiver, gea_key); }));');
|
|
192
|
+
};
|
|
193
|
+
/** `for`-`in` over a genuinely dynamic receiver -- see this file's own header comment. */
|
|
194
|
+
const emitDynamicEnumerateIterator = (ctx, lines, operation) => {
|
|
195
|
+
const receiver = operandText(ctx, operation.receiver);
|
|
196
|
+
const name = defineValue(ctx, operation.result);
|
|
197
|
+
lines.push(`${name} = gea::Iterator<std::string>((${receiver}).ownEnumerableStringKeys(), ` +
|
|
198
|
+
`std::function<bool(const std::string&)>([gea_receiver = ${receiver}](const std::string& gea_key) { ` +
|
|
199
|
+
'return gea_receiver.hasProperty(gea::PropertyKey::string(gea_key)); }));');
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* The general iterator protocol's `get-iterator` step: `receiver[Symbol.iterator]()`,
|
|
203
|
+
* called through the method value `get-method` already resolved -- a class
|
|
204
|
+
* instance's own hand-written `[Symbol.iterator]()`, or a plain object's.
|
|
205
|
+
*
|
|
206
|
+
* This is sound over exactly the two carriers `manifest/capabilities.ts`
|
|
207
|
+
* claims it for (`class-ref`, `record`), and NOT over every "record"-carried
|
|
208
|
+
* receiver: `preflight/runtime-helper-key.ts`'s `iteratorMethodCarrierKind`
|
|
209
|
+
* keeps a "record" with no discoverable `@@iterator` FIELD -- an open tuple
|
|
210
|
+
* spread through its inherited `Array.prototype[Symbol.iterator]`, carried as
|
|
211
|
+
* a positional "0"/"1"/... record with no such field at all -- off the
|
|
212
|
+
* claimed key, refused by name at preflight instead of reaching here. So
|
|
213
|
+
* every "record" receiver that DOES reach this function really does carry a
|
|
214
|
+
* callable `method` operand, and the checks below are fail-closed re-checks
|
|
215
|
+
* of that guarantee, not a first opinion -- the same posture this file's
|
|
216
|
+
* static/dynamic `for`-`in` sources already take.
|
|
217
|
+
*
|
|
218
|
+
* The call goes through the SAME dispatch check `emit-callable.ts`'s general
|
|
219
|
+
* call emission performs for an ordinary method reference: an overridden
|
|
220
|
+
* `[Symbol.iterator]` (`ctx.virtualCallees`) is called through the object, so
|
|
221
|
+
* a subclass's override runs rather than the base's; anything else calls
|
|
222
|
+
* through the `gea::CallableObject` carrier directly (`.call(receiver)`),
|
|
223
|
+
* exactly as `emit-properties.ts`'s `classMemberText` built it to be called.
|
|
224
|
+
*/
|
|
225
|
+
const emitDynamicGetIterator = (ctx, lines, operation) => {
|
|
226
|
+
const method = operation.method;
|
|
227
|
+
if (method === null) {
|
|
228
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:get-method:record', 'carries no "method" operand to call; the general iterator protocol has nothing else to advance the iteration with');
|
|
229
|
+
}
|
|
230
|
+
const representation = operation.result.representation;
|
|
231
|
+
// Almost always a "record" -- the synthetic `{ next }` shape ECMA-262 7.4.2
|
|
232
|
+
// `GetIterator` guarantees for a call this compiler cannot see the real
|
|
233
|
+
// return type of at the producer layer generically. "iterator" is the one
|
|
234
|
+
// other carrier this call can genuinely produce: `producers/protocol.ts`'s
|
|
235
|
+
// `generatorRecordTypeOf` publishes it instead, in place of the synthetic
|
|
236
|
+
// record, exactly when the resolved `[Symbol.iterator]` is written as a
|
|
237
|
+
// GENERATOR method (`*[Symbol.iterator]() { yield ... }`) and so really
|
|
238
|
+
// returns a `Generator<T>` -- which IS its own iterator (ECMA-262 27.5.1.2),
|
|
239
|
+
// so the call below needs no further unwrapping either way: assigning its
|
|
240
|
+
// result is the whole step, whether that result is the record or the cursor.
|
|
241
|
+
if (representation.kind !== 'iterator' && iteratorRecordFieldsOf(ctx, representation) === null) {
|
|
242
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:get-iterator:${representation.kind}`, `carries a "${representation.kind}" result over a dynamic "method" operand, but the general iterator protocol only ever ` +
|
|
243
|
+
'publishes a record result -- the `{ next }` record ECMA-262 7.4.2 `GetIterator` returns, structural or named -- or an ' +
|
|
244
|
+
'"iterator" result when the resolved method is itself a generator');
|
|
245
|
+
}
|
|
246
|
+
if (method.representation.kind !== 'function-value-dispatch') {
|
|
247
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:get-method:${method.representation.kind}`, `calls a "method" operand carried as "${method.representation.kind}", but the general iterator protocol only ever resolves ` +
|
|
248
|
+
'one through a "function-value-dispatch" carrier -- the class/record member read `preflight/runtime-helper-key.ts` gates on');
|
|
249
|
+
}
|
|
250
|
+
const receiverText = operandText(ctx, operation.receiver);
|
|
251
|
+
const name = defineValue(ctx, operation.result);
|
|
252
|
+
// An overridden `[Symbol.iterator]` goes through the object, exactly as an
|
|
253
|
+
// ordinary overridden method call does (`emit-callable.ts`): the value
|
|
254
|
+
// `classMemberText` built names the base's body, and only the object's own
|
|
255
|
+
// virtual member selects the override.
|
|
256
|
+
const dispatched = ctx.virtualCallees.get(method.value);
|
|
257
|
+
if (dispatched !== undefined) {
|
|
258
|
+
ctx.virtualCalleesUsed.add(method.value);
|
|
259
|
+
lines.push(`${name} = ${receiverText}->${dispatched.member}();`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
// `iteratorMethodCallText` is the one place that decides whether a receiver
|
|
263
|
+
// argument is supplied, and it decides it from the callable's own ABI --
|
|
264
|
+
// the same authority `next()` and an accessor-held `next` already read. A
|
|
265
|
+
// hand-written `.call(receiver)` here spelled a second answer, and it was
|
|
266
|
+
// the wrong one for every `[Symbol.iterator]` whose convention declares no
|
|
267
|
+
// receiver.
|
|
268
|
+
lines.push(`${name} = ${iteratorMethodCallText(ctx, operandText(ctx, method), method.representation.abi, operation.receiver, 'iterator get-iterator')};`);
|
|
269
|
+
};
|
|
270
|
+
export const emitGetIterator = (ctx, lines, operation) => {
|
|
271
|
+
// The general protocol: `receiver[Symbol.iterator]()`, called through the
|
|
272
|
+
// method value `get-method` already resolved -- see `emitDynamicGetIterator`
|
|
273
|
+
// for the whole of why this is sound. Checked first because its own result
|
|
274
|
+
// carrier ("record") is never the "iterator" cursor every branch below this
|
|
275
|
+
// point assumes.
|
|
276
|
+
if (operation.method) {
|
|
277
|
+
emitDynamicGetIterator(ctx, lines, operation);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const representation = operation.result.representation;
|
|
281
|
+
// A source explicitly declared `any`/`unknown` owns no static
|
|
282
|
+
// `[Symbol.iterator]` member to lower. Its record is a `Value`, and the
|
|
283
|
+
// runtime performs GetMethod, Call, and the iterable/result object checks
|
|
284
|
+
// against that one live value. This branch is intentionally before the
|
|
285
|
+
// native cursor assertion: the static cursor branch below is for a typed
|
|
286
|
+
// value and must never be widened into this dynamic path.
|
|
287
|
+
if (representation.kind === 'dynamic') {
|
|
288
|
+
if (operation.protocol !== 'iterator' || operation.receiver.representation.kind !== 'dynamic') {
|
|
289
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:get-iterator:dynamic', 'uses a dynamic iterator record outside the synchronous genuinely-dynamic source path');
|
|
290
|
+
}
|
|
291
|
+
const name = defineValue(ctx, operation.result);
|
|
292
|
+
lines.push(`${name} = gea::runtime::iterator::getIterator(${operandText(ctx, operation.receiver)});`);
|
|
293
|
+
const doneState = `v${ctx.nextValueOrdinal++}`;
|
|
294
|
+
ctx.declarations.push({ name: doneState, type: 'bool' });
|
|
295
|
+
lines.push(`${doneState} = false;`);
|
|
296
|
+
ctx.dynamicIteratorDoneStates.set(operation.result.id, doneState);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (representation.kind !== 'iterator') {
|
|
300
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:${operation.protocol}:get-iterator:${representation.kind}`, `carries a "${representation.kind}" result, but the only get-iterator step this backend lowers produces an "iterator" carrier`);
|
|
301
|
+
}
|
|
302
|
+
const carried = operation.receiver.representation;
|
|
303
|
+
if (operation.protocol === 'enumerate' && (carried.kind === 'optional' || carried.kind === 'tagged-union')) {
|
|
304
|
+
const plan = nativeEnumerationPlanOf(carried);
|
|
305
|
+
if (plan) {
|
|
306
|
+
const render = (step, receiver) => {
|
|
307
|
+
switch (step.kind) {
|
|
308
|
+
case 'empty':
|
|
309
|
+
return 'gea::Iterator<std::string>{}';
|
|
310
|
+
case 'fields':
|
|
311
|
+
return `gea::Iterator<std::string>(gea::nativeDynamicKeys(${receiver}), std::function<bool(const std::string&)>([gea_receiver = ${receiver}](const std::string& gea_key) { return gea::nativeDynamicHas(gea_receiver, gea::PropertyKey::string(gea_key)); }))`;
|
|
312
|
+
case 'optional':
|
|
313
|
+
return `((${receiver}).has_value() ? ${render(step.present, `(*(${receiver}))`)} : gea::Iterator<std::string>{})`;
|
|
314
|
+
case 'union': {
|
|
315
|
+
let result = render(step.arms[step.arms.length - 1], `(${receiver}).template get<${step.arms.length - 1}>()`);
|
|
316
|
+
for (let index = step.arms.length - 2; index >= 0; index--)
|
|
317
|
+
result = `((${receiver}).template is<${index}>() ? ${render(step.arms[index], `(${receiver}).template get<${index}>()`)} : ${result})`;
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
const name = defineValue(ctx, operation.result);
|
|
323
|
+
lines.push(`${name} = ([](const auto& gea_enumerated) -> gea::Iterator<std::string> { return ${render(plan, 'gea_enumerated')}; })(${operandText(ctx, operation.receiver)});`);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
// An ABSENT source iterates its PAYLOAD, behind a presence assertion.
|
|
328
|
+
//
|
|
329
|
+
// ECMA-262 7.4.2 `GetIterator` performs `GetMethod(obj, @@iterator)`, and
|
|
330
|
+
// `GetMethod` on `undefined`/`null` throws a `TypeError` -- so iterating an
|
|
331
|
+
// absent value is a RUNTIME refusal in the language itself, and the walk
|
|
332
|
+
// over a present payload is byte-for-byte the walk over a bare payload.
|
|
333
|
+
// That is why `producers/shared.ts`'s `presentIterationArm` routes such a
|
|
334
|
+
// source down this native fast path at all, and why the whole of the
|
|
335
|
+
// dispatch below reads the payload's carrier: the absence changes exactly
|
|
336
|
+
// one thing, whether the walk starts.
|
|
337
|
+
//
|
|
338
|
+
// `gea::detail::requireIterablePresent`, never a bare `*opt`: an
|
|
339
|
+
// `Optional<T>` always holds a constructed `T`, so dereferencing an absent
|
|
340
|
+
// one hands back a DEFAULT-constructed value and the loop would quietly
|
|
341
|
+
// walk an empty container -- a silently wrong answer where the language
|
|
342
|
+
// says throw.
|
|
343
|
+
//
|
|
344
|
+
// Preflight has already refused every payload this dispatch cannot spell:
|
|
345
|
+
// `runtime-helper-key.ts` reports an absent source under its own
|
|
346
|
+
// `optional(<payload kind>)` key rather than borrowing the payload's, so a
|
|
347
|
+
// shape the manifest does not claim never reaches here.
|
|
348
|
+
//
|
|
349
|
+
// The ASSERTION is scoped to the `iterator` protocol, and that scope is
|
|
350
|
+
// load-bearing rather than defensive: `for`-`in` over an absent value does
|
|
351
|
+
// NOT throw in JavaScript (ECMA-262 14.7.5.5 evaluates `undefined`/`null`
|
|
352
|
+
// to a BREAK completion and the loop runs zero times), so asserting
|
|
353
|
+
// presence for one would abort where the language quietly skips. An absent
|
|
354
|
+
// `for`-`in` source is instead an EMPTY cursor. A statically nullish source
|
|
355
|
+
// uses the default cursor below; a possibly-absent table uses
|
|
356
|
+
// `gea::detail::enumerateIfPresent` at the bottom of this function:
|
|
357
|
+
// the static-snapshot walks below read fields off the receiver itself, and
|
|
358
|
+
// preflight (`runtime-helper-key.ts`'s `enumerateGetIteratorCarrierKind`)
|
|
359
|
+
// keeps every non-table payload on an unclaimed `optional(<kind>)` key.
|
|
360
|
+
const absent = carried.kind === 'optional';
|
|
361
|
+
const target = absent ? carried.payload : carried;
|
|
362
|
+
if (operation.protocol === 'enumerate' && (carried.kind === 'undefined' || carried.kind === 'null')) {
|
|
363
|
+
// ForIn/OfHeadEvaluation skips nullish enumeration. Keep evaluation of
|
|
364
|
+
// the source even when a deferred call supplies this known-empty cursor.
|
|
365
|
+
const name = defineValue(ctx, operation.result);
|
|
366
|
+
lines.push(`${name} = (static_cast<void>(${operandText(ctx, operation.receiver)}), ${cppTypeOf(representation)}{});`);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const asserted = absent && operation.protocol !== 'enumerate';
|
|
370
|
+
const skipped = absent && operation.protocol === 'enumerate';
|
|
371
|
+
if (skipped && target.kind !== 'dictionary') {
|
|
372
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:enumerate:get-iterator:optional(${target.kind})`, `enumerates a possibly-absent "${target.kind}" source; only a table has a cursor an absent source can be the empty one of`);
|
|
373
|
+
}
|
|
374
|
+
// Three native sources, one cursor: an Array (ECMA-262 23.1.5), a `Set`
|
|
375
|
+
// (24.2.3.10) and a `string` (22.1.3.36). All three walk storage already in
|
|
376
|
+
// hand with no `@@iterator` lookup, and `gea::Iterator<E>` has a constructor
|
|
377
|
+
// for each -- see its own comment for why one cursor type rather than three.
|
|
378
|
+
// A `Map` is deliberately NOT here: its iterator yields a `[K, V]` pair with
|
|
379
|
+
// no cursor carrier to publish (`producers/shared.ts`'s
|
|
380
|
+
// `isNativeIterableSetType`), so it never reaches the fast path and refuses
|
|
381
|
+
// at preflight instead.
|
|
382
|
+
//
|
|
383
|
+
// A string is passed BY VALUE, not through a `shared_ptr`: that is what its
|
|
384
|
+
// carrier is (`std::string`), and the cursor's own string constructor takes
|
|
385
|
+
// it by value for the dangling reason its comment states. The ownership
|
|
386
|
+
// check below is therefore scoped to the two collection sources, which are
|
|
387
|
+
// the only ones that have an ownership at all.
|
|
388
|
+
// The payload kinds whose spelling below actually reads the source through
|
|
389
|
+
// `sourceText()`. A fixed-arity tuple is the one that does NOT: its
|
|
390
|
+
// positions are read straight off the receiver inside a lambda capture
|
|
391
|
+
// (`emitStaticTupleIterator`), so an absent tuple would capture the
|
|
392
|
+
// `Optional` itself and index a payload nobody proved present. Refused by
|
|
393
|
+
// name rather than unwrapped blind -- `runtime-helper-key.ts` reports it
|
|
394
|
+
// under the unclaimed `optional(record)` key, so preflight already stops it
|
|
395
|
+
// and this is the fail-closed backstop that keeps the two agreeing.
|
|
396
|
+
if (asserted && !['string', 'iterator', 'array-object', 'dictionary', 'keyed-collection'].includes(target.kind)) {
|
|
397
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:${operation.protocol}:get-iterator:optional(${target.kind})`, `targets a possibly-absent "${target.kind}" source; the presence assertion this backend spells sits in front of a cursor ` +
|
|
398
|
+
'constructor, and that payload is not read through one');
|
|
399
|
+
}
|
|
400
|
+
// Every spelling below reads the source through this, so the presence
|
|
401
|
+
// assertion is written once for whichever payload shape the dispatch lands
|
|
402
|
+
// on rather than once per branch.
|
|
403
|
+
const sourceText = () => asserted
|
|
404
|
+
? `gea::detail::requireIterablePresent(${operandText(ctx, operation.receiver)}, ${cppStringLiteral('a for-of over a possibly-absent source')})`
|
|
405
|
+
: operandText(ctx, operation.receiver);
|
|
406
|
+
if (target.kind === 'string') {
|
|
407
|
+
const cursorName = defineValue(ctx, operation.result);
|
|
408
|
+
lines.push(`${cursorName} = ${cppTypeOf(representation)}(${sourceText()});`);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
// A source that IS a cursor -- a `Generator<T, ...>`, carried as
|
|
412
|
+
// `iterator(T)` (`representation/derive.ts`) -- is its own iterator record:
|
|
413
|
+
// ECMA-262 27.5.1.2 `%GeneratorPrototype%[@@iterator]` returns `this`. So the
|
|
414
|
+
// step is an assignment, not a construction. The copy shares the coroutine
|
|
415
|
+
// frame (`gea::Iterator`'s `CoroutineState` is held by `shared_ptr`), which
|
|
416
|
+
// is what makes `g.next()` and a later `for (const x of g)` advance the one
|
|
417
|
+
// generator the language says they do.
|
|
418
|
+
if (target.kind === 'iterator') {
|
|
419
|
+
const aliasName = defineValue(ctx, operation.result);
|
|
420
|
+
lines.push(`${aliasName} = ${sourceText()};`);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
// A `Set` and a `Map` share this one spelling: `gea::Iterator<E>` has a
|
|
424
|
+
// constructor for each, and overload resolution picks by the collection's own
|
|
425
|
+
// C++ type. The two WEAK families never reach here -- they have no iteration
|
|
426
|
+
// at all (ECMA-262 24.3/24.4), `producers/shared.ts` mints a `get-method`
|
|
427
|
+
// step for them, and `protocol:iterator:get-method:keyed-collection` is
|
|
428
|
+
// claimed by no manifest.
|
|
429
|
+
//
|
|
430
|
+
// A `dictionary` joins them from the `enumerate` protocol -- `for`-`in` --
|
|
431
|
+
// and reaches the same spelling for the same reason: `gea::Iterator<E>` has
|
|
432
|
+
// a `Dictionary` constructor too, which walks the table's `propertyKeys()`.
|
|
433
|
+
// Nothing here distinguishes the two protocols, because nothing needs to:
|
|
434
|
+
// the operation's own receiver carrier already says which walk it is, and
|
|
435
|
+
// preflight has already refused every receiver neither claim covers.
|
|
436
|
+
//
|
|
437
|
+
// The two remaining `for`-`in` sources -- a statically shaped receiver and a
|
|
438
|
+
// genuinely dynamic one -- are checked before the collection group below
|
|
439
|
+
// rather than folded into it: neither is a `nativeSource` a bare
|
|
440
|
+
// `${cppTypeOf(representation)}(...)` construction can spell, each needs its
|
|
441
|
+
// own C++ helper call, and nothing here needs an explicit "is this really
|
|
442
|
+
// `for`-`in`" test to keep the two apart from a `for`-`of`/spread reaching
|
|
443
|
+
// this function -- see this file's own header comment for why the `iterator`
|
|
444
|
+
// result carrier these two branches require never gets published for the
|
|
445
|
+
// ONE protocol (`iterator`/`async-iterator`) that could target the same
|
|
446
|
+
// receiver kinds with a `method` operand still attached, and `operation.method`
|
|
447
|
+
// already refused that case above.
|
|
448
|
+
//
|
|
449
|
+
// The one thing the receiver's carrier CANNOT say is which of the two walks
|
|
450
|
+
// over a struct this is -- `for`-`in` yields its keys, `for`-`of` over a
|
|
451
|
+
// fixed-arity tuple yields its positions, and for a tuple of strings both
|
|
452
|
+
// cursors are `gea::Iterator<std::string>`. So the protocol the operation
|
|
453
|
+
// carries decides, and the two static struct walks are reached only through
|
|
454
|
+
// it; anything else is left to the collection group below, which refuses
|
|
455
|
+
// what it cannot spell.
|
|
456
|
+
if (operation.protocol === 'enumerate') {
|
|
457
|
+
if (emitStaticEnumerateIterator(ctx, lines, operation, target))
|
|
458
|
+
return;
|
|
459
|
+
if (target.kind === 'dynamic') {
|
|
460
|
+
emitDynamicEnumerateIterator(ctx, lines, operation);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (target.kind === 'native-handle') {
|
|
464
|
+
emitNativeHandleEnumerateIterator(ctx, lines, operation);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (target.kind === 'function-value-dispatch') {
|
|
468
|
+
emitCallableEnumerateIterator(ctx, lines, operation);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (target.kind === 'array-object' && target.ownership === 'shared-refcount') {
|
|
472
|
+
emitArrayEnumerateIterator(ctx, lines, operation);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (target.kind === 'dictionary' && target.key === 'symbol') {
|
|
476
|
+
// EnumerateObjectProperties visits string keys only. A symbol-keyed
|
|
477
|
+
// table therefore has a complete native cursor whose sequence is empty;
|
|
478
|
+
// it must not instantiate the string Dictionary cursor or stringify a
|
|
479
|
+
// symbol description into a property name.
|
|
480
|
+
const name = defineValue(ctx, operation.result);
|
|
481
|
+
lines.push(`${name} = gea::Iterator<std::string>(std::vector<std::string>{}, ` +
|
|
482
|
+
'std::function<bool(const std::string&)>([](const std::string&) { return false; }));');
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
else if (emitStaticTupleIterator(ctx, lines, operation, target, representation.element))
|
|
487
|
+
return;
|
|
488
|
+
const iterableCollection = target.kind === 'keyed-collection' && (target.family === 'set' || target.family === 'map');
|
|
489
|
+
const nativeSource = target.kind === 'array-object' || target.kind === 'dictionary' || iterableCollection;
|
|
490
|
+
if (!nativeSource) {
|
|
491
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:${operation.protocol}:get-iterator:${target.kind}`, `targets a "${target.kind}" receiver, but the native fast path only ever targets an "array-object", a "Set", a "Map", a "string" or a "dictionary"`);
|
|
492
|
+
}
|
|
493
|
+
if (target.ownership !== 'shared-refcount') {
|
|
494
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:${operation.protocol}:get-iterator:${target.kind}`, `targets a collection carried with ownership "${target.ownership}", but this emitter only spells the cursor constructor for "shared-refcount"`);
|
|
495
|
+
}
|
|
496
|
+
// Only a protocol-private SSA cursor may use a compact local layout. A
|
|
497
|
+
// returned, stored, merged or copied iterator retains the shared carrier.
|
|
498
|
+
const localType = ctx.localIterators.has(operation.result.id)
|
|
499
|
+
? target.kind === 'array-object'
|
|
500
|
+
? `gea::LocalArrayCursor<${cppTypeOf(representation.element)}>`
|
|
501
|
+
: target.kind === 'dictionary' && target.key === 'string'
|
|
502
|
+
? `gea::LocalDictionaryCursor<${cppTypeOf(target.value)}>`
|
|
503
|
+
: null
|
|
504
|
+
: null;
|
|
505
|
+
const type = localType ?? cppTypeOf(representation);
|
|
506
|
+
const name = defineValue(ctx, operation.result, type);
|
|
507
|
+
lines.push(skipped ? `${name} = gea::detail::enumerateIfPresent<${type}>(${sourceText()});` : `${name} = ${type}(${sourceText()});`);
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* The general iterator protocol's `next` step over a "record"-carried
|
|
511
|
+
* iterator-record: ECMA-262 7.4.3 `IteratorNext` is ONE call producing
|
|
512
|
+
* `{value, done}` together, unlike the native array cursor's `arrayNext()` +
|
|
513
|
+
* `.done()` pair (which answers the same two-op IR split for free, by
|
|
514
|
+
* stepping a stateful cursor and reading a flag back). A record's own `next`
|
|
515
|
+
* is a real, once-only call through a `gea::CallableObject`, so it is called
|
|
516
|
+
* exactly once here and its `{value, done}` result is cached in a fresh local
|
|
517
|
+
* for the paired `iterator-done` step (`emitIteratorDone` below) to read --
|
|
518
|
+
* `ctx.protocolNextResults`, keyed by the iterator-record value both steps
|
|
519
|
+
* name, so the cache always survives to when `iterator-done` runs (the same
|
|
520
|
+
* per-body evaluation order the array cursor's own split already relies on).
|
|
521
|
+
* Calling `next` a second time to answer `done` would both double the source
|
|
522
|
+
* iterator's side effect and skip every other element.
|
|
523
|
+
*
|
|
524
|
+
* The `next` FIELD's own shape is a fail-closed re-check of
|
|
525
|
+
* `iteratorMethodAndRecordTypes` (`producers/protocol.ts`), the one place
|
|
526
|
+
* that publishes it -- see `emitDynamicGetIterator`'s header for why every
|
|
527
|
+
* "record" reaching this step really does carry it.
|
|
528
|
+
*
|
|
529
|
+
* Invariant 5 audit (invariant 5: no write during render): `protocolNextResults`
|
|
530
|
+
* -- and, by the identical reasoning, `dynamicIteratorSteps` and
|
|
531
|
+
* `dynamicIteratorDoneStates` below -- is NAMING, not a fact, and correctly
|
|
532
|
+
* carries no `EmitBodyFacts`/`EmitContext` fact field. WHICH iterator values
|
|
533
|
+
* are dynamic or record-carried is answered entirely by `operation.iterator
|
|
534
|
+
* .representation`, an IR-settled carrier asked afresh at every use; nothing
|
|
535
|
+
* here decides that. What each map holds is the C++ NAME of a scratch local
|
|
536
|
+
* this render just minted (`v<ordinal>` off `ctx.nextValueOrdinal`, a counter
|
|
537
|
+
* tied to render's own traversal order, never a foreign table's `.size`) --
|
|
538
|
+
* a name that cannot exist before the call it names is printed, so it cannot
|
|
539
|
+
* be settled in a prepass. All three are correctly listed in
|
|
540
|
+
* `emit-context.ts`'s `renderMutableEmitContextFields`.
|
|
541
|
+
*/
|
|
542
|
+
/** Invoke a protocol method with the iterator as its real ECMAScript receiver. */
|
|
543
|
+
const iteratorMethodCallText = (ctx, callable, abi, iterator, what) => {
|
|
544
|
+
const supplied = abi.receiver === null ? [] : [receiverArgumentText(ctx, abi, iterator)];
|
|
545
|
+
return `${callable}.call(${paddedArguments(abi, supplied, what).join(', ')})`;
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* A getter is itself a receiver-bearing call and must use its projected ABI
|
|
549
|
+
* too -- and, when it captures, the environment the iterator object carries
|
|
550
|
+
* for it (`accessorEnvironmentArguments`), exactly as an ordinary member read
|
|
551
|
+
* of the same accessor does.
|
|
552
|
+
*/
|
|
553
|
+
const iteratorGetterText = (ctx, key, getter, iterator, what) => {
|
|
554
|
+
const abi = ctx.abiOfCallable(getter);
|
|
555
|
+
if (abi === null)
|
|
556
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:${what}`, `getter ${getter} publishes no callable ABI`);
|
|
557
|
+
const supplied = abi.receiver === null ? [] : [receiverArgumentText(ctx, abi, iterator)];
|
|
558
|
+
const environment = accessorEnvironmentArguments(ctx, iterator.representation, key, getter, 'getter', operandText(ctx, iterator));
|
|
559
|
+
return `${cppBodyName(getter)}(${[...environment, ...paddedArguments(abi, supplied, `${what} getter`)].join(', ')})`;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* `next()` whose result is the LIBRARY's own `IteratorResult<T>` union.
|
|
563
|
+
*
|
|
564
|
+
* One call, cached in a local of the union's type, and two reads dispatched
|
|
565
|
+
* over its arms -- the same leaf dispatch `emit-union-properties.ts` performs
|
|
566
|
+
* for any other member read of a tagged union. Every arm must be a record
|
|
567
|
+
* carrying both members, because that is what the protocol reads; an arm that
|
|
568
|
+
* is not is refused by name rather than defaulted.
|
|
569
|
+
*/
|
|
570
|
+
const emitUnionResultIteratorNext = (ctx, lines, operation, iteratorRecord, nextAbi, nextField, nextAccessor, result) => {
|
|
571
|
+
const receiverText = operandText(ctx, operation.iterator);
|
|
572
|
+
const receiverAccessor = memberAccessOperator(iteratorRecord.ownership);
|
|
573
|
+
const nextText = nextField
|
|
574
|
+
? `${receiverText}${receiverAccessor}${cppRecordFieldName('next')}`
|
|
575
|
+
: nextAccessor?.getter
|
|
576
|
+
? iteratorGetterText(ctx, nextAccessor.key, nextAccessor.getter, operation.iterator, 'iterator-next')
|
|
577
|
+
: null;
|
|
578
|
+
if (nextText === null)
|
|
579
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, 'cannot resolve the iterator next method');
|
|
580
|
+
const callText = iteratorMethodCallText(ctx, nextText, nextAbi, operation.iterator, 'iterator next()');
|
|
581
|
+
const tempName = `v${ctx.nextValueOrdinal}`;
|
|
582
|
+
ctx.nextValueOrdinal += 1;
|
|
583
|
+
ctx.declarations.push({ name: tempName, type: cppTypeOf(result) });
|
|
584
|
+
lines.push(`${tempName} = ${callText};`);
|
|
585
|
+
const name = defineValue(ctx, operation.result);
|
|
586
|
+
const leaves = unionPropertyLeaves(result, tempName);
|
|
587
|
+
const memberText = (key, target) => {
|
|
588
|
+
const texts = leaves.map((leaf) => {
|
|
589
|
+
const arm = leaf.representation;
|
|
590
|
+
if (arm.kind !== 'record' && arm.kind !== 'native-record-ref')
|
|
591
|
+
return null;
|
|
592
|
+
const field = iteratorRecordFieldsOf(ctx, arm)?.find((candidate) => candidate.key === key);
|
|
593
|
+
if (field === undefined)
|
|
594
|
+
return null;
|
|
595
|
+
return alignedValueText(ctx, 'emit-iterator.ts:671', field.value, target, `${leaf.text}${memberAccessOperator(arm.ownership)}${cppRecordFieldName(key)}`);
|
|
596
|
+
});
|
|
597
|
+
const dispatched = texts.every((text) => text !== null) ? dispatchedLeafExpression(leaves, texts) : null;
|
|
598
|
+
if (dispatched === null) {
|
|
599
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, `calls a "next()" whose result union has an arm with no readable "${key}" member of the published carrier`);
|
|
600
|
+
}
|
|
601
|
+
return dispatched;
|
|
602
|
+
};
|
|
603
|
+
ctx.protocolNextResults.set(operation.iterator.value, {
|
|
604
|
+
tempName,
|
|
605
|
+
accessor: '.',
|
|
606
|
+
valueName: name,
|
|
607
|
+
valueText: memberText('value', operation.result.representation),
|
|
608
|
+
doneText: memberText('done', { kind: 'scalar', domain: 'boolean' })
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
const emitDynamicIteratorNext = (ctx, lines, operation, iteratorRecord) => {
|
|
612
|
+
if (operation.value) {
|
|
613
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, 'carries a "value" argument; the general iterator protocol\'s next() call never consumes one (only a generator\'s .next(v) does, which is never carried as a "record")');
|
|
614
|
+
}
|
|
615
|
+
const iteratorFields = iteratorRecordFieldsOf(ctx, iteratorRecord);
|
|
616
|
+
const nextField = iteratorFields?.find((field) => field.key === 'next');
|
|
617
|
+
const nextAccessor = iteratorRecordAccessorsOf(ctx, iteratorRecord)?.find((accessor) => accessor.key === 'next');
|
|
618
|
+
const nextCallable = nextField?.value ?? (nextAccessor?.getter ? ctx.abiOfCallable(nextAccessor.getter)?.result : null);
|
|
619
|
+
if (!nextCallable || nextCallable.kind !== 'function-value-dispatch') {
|
|
620
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, `advances a "${iteratorRecord.kind}" iterator-record with no callable "next" field; the general iterator protocol has nothing else to call`);
|
|
621
|
+
}
|
|
622
|
+
const resultRepresentation = nextCallable.abi.result;
|
|
623
|
+
const resultFields = iteratorRecordFieldsOf(ctx, resultRepresentation);
|
|
624
|
+
const resultAccessors = iteratorRecordAccessorsOf(ctx, resultRepresentation);
|
|
625
|
+
// `IteratorResult<T>` IS a discriminated union in TypeScript's own library
|
|
626
|
+
// -- `IteratorYieldResult<T> | IteratorReturnResult<TReturn>` -- so a
|
|
627
|
+
// hand-written `next(): IteratorResult<number>` publishes a tagged union of
|
|
628
|
+
// two records, not one record. Both arms carry `value` and `done`; which
|
|
629
|
+
// arm is live is the tag, and the read dispatches on it exactly as any
|
|
630
|
+
// other union member read does.
|
|
631
|
+
if (resultRepresentation.kind === 'tagged-union') {
|
|
632
|
+
emitUnionResultIteratorNext(ctx, lines, operation, iteratorRecord, nextCallable.abi, nextField, nextAccessor, resultRepresentation);
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if ((resultFields === null && resultAccessors === null) ||
|
|
636
|
+
(resultRepresentation.kind !== 'record' && resultRepresentation.kind !== 'native-record-ref')) {
|
|
637
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${resultRepresentation.kind}`, `calls a "next()" whose own result is carried as "${resultRepresentation.kind}", but the general iterator protocol only ever ` +
|
|
638
|
+
'publishes a record result for it -- the `{ value, done }` pair ECMA-262 7.4.3 `IteratorNext` returns');
|
|
639
|
+
}
|
|
640
|
+
const hasMember = (key) => (resultFields?.some((field) => field.key === key) ?? false) || (resultAccessors?.some((accessor) => accessor.key === key) ?? false);
|
|
641
|
+
if (!hasMember('value') || !hasMember('done')) {
|
|
642
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${resultRepresentation.kind}`, 'calls a "next()" whose result record has no "value"/"done" field pair to read the iteration result out of');
|
|
643
|
+
}
|
|
644
|
+
const receiverText = operandText(ctx, operation.iterator);
|
|
645
|
+
const receiverAccessor = memberAccessOperator(iteratorRecord.ownership);
|
|
646
|
+
const nextText = nextField
|
|
647
|
+
? `${receiverText}${receiverAccessor}${cppRecordFieldName('next')}`
|
|
648
|
+
: nextAccessor?.getter
|
|
649
|
+
? iteratorGetterText(ctx, nextAccessor.key, nextAccessor.getter, operation.iterator, 'iterator-next')
|
|
650
|
+
: null;
|
|
651
|
+
if (nextText === null)
|
|
652
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRecord.kind}`, 'cannot resolve the iterator next method');
|
|
653
|
+
const callText = iteratorMethodCallText(ctx, nextText, nextCallable.abi, operation.iterator, 'iterator next()');
|
|
654
|
+
// A fresh local, hoisted exactly as `defineValue` hoists every other IR
|
|
655
|
+
// result -- this one just names no semantic result of its own, because
|
|
656
|
+
// `IteratorResult` as a whole is never published as one value (`next`'s own
|
|
657
|
+
// "value" role is the payload half; "done" is the sibling `iterator-done`
|
|
658
|
+
// step reads out of the SAME call, below).
|
|
659
|
+
const tempName = `v${ctx.nextValueOrdinal}`;
|
|
660
|
+
ctx.nextValueOrdinal += 1;
|
|
661
|
+
ctx.declarations.push({ name: tempName, type: cppTypeOf(resultRepresentation) });
|
|
662
|
+
lines.push(`${tempName} = ${callText};`);
|
|
663
|
+
const resultAccessor = memberAccessOperator(resultRepresentation.ownership);
|
|
664
|
+
const name = defineValue(ctx, operation.result);
|
|
665
|
+
const memberText = (key) => {
|
|
666
|
+
if (resultFields?.some((field) => field.key === key))
|
|
667
|
+
return `${tempName}${resultAccessor}${cppRecordFieldName(key)}`;
|
|
668
|
+
const accessor = resultAccessors?.find((candidate) => candidate.key === key);
|
|
669
|
+
if (!accessor?.getter) {
|
|
670
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${resultRepresentation.kind}`, `reads iterator result ${key} through an accessor with no getter body`);
|
|
671
|
+
}
|
|
672
|
+
const environment = accessorEnvironmentArguments(ctx, resultRepresentation, key, accessor.getter, 'getter', tempName);
|
|
673
|
+
return `${cppBodyName(accessor.getter)}(${[...environment, tempName].join(', ')})`;
|
|
674
|
+
};
|
|
675
|
+
ctx.protocolNextResults.set(operation.iterator.value, {
|
|
676
|
+
tempName,
|
|
677
|
+
accessor: resultAccessor,
|
|
678
|
+
valueName: name,
|
|
679
|
+
valueText: memberText('value'),
|
|
680
|
+
doneText: memberText('done')
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
export const emitIteratorNext = (ctx, lines, operation) => {
|
|
684
|
+
const iteratorRepresentation = operation.iterator.representation;
|
|
685
|
+
if (iteratorRepresentation.kind === 'dynamic') {
|
|
686
|
+
if (operation.value) {
|
|
687
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:next:dynamic', 'passes a value to a dynamic iterator step; ordinary iterator consumption calls next() with no arguments');
|
|
688
|
+
}
|
|
689
|
+
const stepName = `v${ctx.nextValueOrdinal}`;
|
|
690
|
+
ctx.nextValueOrdinal += 1;
|
|
691
|
+
ctx.declarations.push({ name: stepName, type: 'gea::runtime::iterator::Step' });
|
|
692
|
+
const doneState = ctx.dynamicIteratorDoneStates.get(operation.iterator.value);
|
|
693
|
+
if (!doneState) {
|
|
694
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:next:dynamic', 'advances a dynamic iterator with no exhaustion state from its get-iterator step');
|
|
695
|
+
}
|
|
696
|
+
lines.push(`${stepName} = ${doneState} ? gea::runtime::iterator::Step{} : ` +
|
|
697
|
+
`gea::runtime::iterator::step(${operandText(ctx, operation.iterator)});`);
|
|
698
|
+
lines.push(`${doneState} = ${stepName}.done;`);
|
|
699
|
+
ctx.dynamicIteratorSteps.set(operation.iterator.value, stepName);
|
|
700
|
+
const name = defineValue(ctx, operation.result);
|
|
701
|
+
const result = operation.result.representation;
|
|
702
|
+
if (result.kind === 'dynamic') {
|
|
703
|
+
lines.push(`${name} = ${stepName}.value;`);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
// A destructuring position can carry `E | undefined`: IteratorStep's
|
|
707
|
+
// exhausted answer is the language value `undefined`, not a default C++
|
|
708
|
+
// element. The same checked dynamic conversions that ordinary property
|
|
709
|
+
// reads use reconcile both outcomes. This deliberately has no raw cast:
|
|
710
|
+
// a typed pattern over a dynamic iterator is valid only where both its
|
|
711
|
+
// element and its exhausted value have installed conversions.
|
|
712
|
+
const absent = alignedValueText(ctx, 'emit-iterator.ts:815', { kind: 'undefined' }, result, cppUndefinedValue);
|
|
713
|
+
const present = alignedValueText(ctx, 'emit-iterator.ts:816', { kind: 'dynamic', reason: 'declared-any-never-narrowed' }, result, `${stepName}.value`);
|
|
714
|
+
if (absent === null || present === null) {
|
|
715
|
+
throw createCppEmitBlockedError(`conversion:dynamic->${representationKey(result)}`, `reads a dynamic iterator element into a "${representationKey(result)}" result, but no checked conversion handles both ` +
|
|
716
|
+
'the yielded value and IteratorStep exhaustion');
|
|
717
|
+
}
|
|
718
|
+
lines.push(`${name} = ${stepName}.done ? (${absent}) : (${present});`);
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (iteratorRepresentation.kind === 'record' || iteratorRepresentation.kind === 'native-record-ref') {
|
|
722
|
+
emitDynamicIteratorNext(ctx, lines, operation, iteratorRepresentation);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (iteratorRepresentation.kind !== 'iterator') {
|
|
726
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRepresentation.kind}`, `advances a "${iteratorRepresentation.kind}" iterator-record, but the only "next" step this backend lowers advances an "iterator" cursor`);
|
|
727
|
+
}
|
|
728
|
+
if (operation.value) {
|
|
729
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:next:iterator', 'carries a "value" argument; the array-native fast path never consumes one (the standard Array Iterator\'s own .next takes none)');
|
|
730
|
+
}
|
|
731
|
+
const name = defineValue(ctx, operation.result);
|
|
732
|
+
const element = iteratorRepresentation.element;
|
|
733
|
+
const result = operation.result.representation;
|
|
734
|
+
if (representationKey(result) === representationKey(element)) {
|
|
735
|
+
lines.push(`${name} = ${operandText(ctx, operation.iterator)}.arrayNext();`);
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
// An absence-capable read: the position may lie past the cursor's end, and
|
|
739
|
+
// `arrayNext()` on an exhausted cursor sets `done()` rather than throwing,
|
|
740
|
+
// so the result's own absence is what an exhausted step yields
|
|
741
|
+
// (`lower-destructuring.ts`'s `lowerArrayPatternIteratorRead`).
|
|
742
|
+
const absent = alignedValueText(ctx, 'emit-iterator.ts:854', { kind: 'undefined' }, result, cppUndefinedValue);
|
|
743
|
+
const present = alignedValueText(ctx, 'emit-iterator.ts:855', element, result, '__gea_next');
|
|
744
|
+
if (absent === null || present === null) {
|
|
745
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(element)}->${representationKey(result)}`, `reads an "${representationKey(element)}" cursor element into a "${representationKey(result)}" result, and no conversion is installed`);
|
|
746
|
+
}
|
|
747
|
+
const cursor = operandText(ctx, operation.iterator);
|
|
748
|
+
lines.push(`{ auto __gea_next = ${cursor}.arrayNext(); ${name} = ${cursor}.done() ? (${absent}) : (${present}); }`);
|
|
749
|
+
};
|
|
750
|
+
export const emitIteratorDone = (ctx, lines, operation) => {
|
|
751
|
+
const iteratorRepresentation = operation.iterator.representation;
|
|
752
|
+
if (iteratorRepresentation.kind === 'dynamic') {
|
|
753
|
+
const step = ctx.dynamicIteratorSteps.get(operation.iterator.value);
|
|
754
|
+
if (!step) {
|
|
755
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:next:dynamic', 'reads a dynamic iterator result before its paired next() step produced the shared value/done record');
|
|
756
|
+
}
|
|
757
|
+
const name = defineValue(ctx, operation.result);
|
|
758
|
+
lines.push(`${name} = ${step}.done;`);
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
if (iteratorRepresentation.kind === 'record' || iteratorRepresentation.kind === 'native-record-ref') {
|
|
762
|
+
// The paired `next` step (`emitDynamicIteratorNext`) always runs first --
|
|
763
|
+
// see its own header comment -- and always caches its call's result here
|
|
764
|
+
// before this step can be reached, so a miss means the two have somehow
|
|
765
|
+
// become decoupled rather than that this receiver is unsupported.
|
|
766
|
+
const cached = ctx.protocolNextResults.get(operation.iterator.value);
|
|
767
|
+
if (!cached) {
|
|
768
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRepresentation.kind}`, 'reads "done" off a "record" iterator-record before its paired "next" step cached a result to read it from');
|
|
769
|
+
}
|
|
770
|
+
const name = defineValue(ctx, operation.result);
|
|
771
|
+
lines.push(`${name} = ${cached.doneText};`);
|
|
772
|
+
lines.push(`if (!${name}) ${cached.valueName} = ${cached.valueText};`);
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
if (iteratorRepresentation.kind !== 'iterator') {
|
|
776
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:next:${iteratorRepresentation.kind}`, `reads "done" off a "${iteratorRepresentation.kind}" iterator-record, but the only shape this backend lowers is an "iterator" cursor`);
|
|
777
|
+
}
|
|
778
|
+
const name = defineValue(ctx, operation.result);
|
|
779
|
+
lines.push(`${name} = ${operandText(ctx, operation.iterator)}.done();`);
|
|
780
|
+
};
|
|
781
|
+
const staticallyObjectCloseResult = (representation) => {
|
|
782
|
+
if (representation.kind === 'record' || representation.kind === 'native-record-ref')
|
|
783
|
+
return true;
|
|
784
|
+
return representation.kind === 'tagged-union' && representation.arms.every((arm) => staticallyObjectCloseResult(arm.value));
|
|
785
|
+
};
|
|
786
|
+
/** Statements implementing IteratorClose for either an admitted dynamic value or a concrete typed iterator record. */
|
|
787
|
+
const iteratorCloseStatements = (ctx, iterator) => {
|
|
788
|
+
const representation = iterator.representation;
|
|
789
|
+
const receiver = operandText(ctx, iterator);
|
|
790
|
+
if (representation.kind === 'dynamic')
|
|
791
|
+
return [`gea::runtime::iterator::close(${receiver});`];
|
|
792
|
+
if (representation.kind === 'iterator') {
|
|
793
|
+
if (representation.source !== 'generator') {
|
|
794
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:close:iterator', 'cannot close a non-generator native sequence cursor');
|
|
795
|
+
}
|
|
796
|
+
const absent = representation.completion.kind === 'undefined' || representation.completion.kind === 'void'
|
|
797
|
+
? '{}'
|
|
798
|
+
: cppUndefinedIn(representation.completion);
|
|
799
|
+
if (absent === null) {
|
|
800
|
+
throw createCppEmitBlockedError(`conversion:undefined->${representationKey(representation.completion)}`, `calls generator return() without a value, but its completion channel "${representationKey(representation.completion)}" cannot carry undefined`);
|
|
801
|
+
}
|
|
802
|
+
return [`(void)(${receiver}.resumeReturn(${absent}));`];
|
|
803
|
+
}
|
|
804
|
+
if (representation.kind !== 'record' && representation.kind !== 'native-record-ref') {
|
|
805
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${representation.kind}`, `cannot close an iterator carried as "${representation.kind}"`);
|
|
806
|
+
}
|
|
807
|
+
const fields = iteratorRecordFieldsOf(ctx, representation);
|
|
808
|
+
const returnField = fields?.find((field) => field.key === 'return');
|
|
809
|
+
const returnAccessor = iteratorRecordAccessorsOf(ctx, representation)?.find((accessor) => accessor.key === 'return');
|
|
810
|
+
if (!returnField && !returnAccessor)
|
|
811
|
+
return [];
|
|
812
|
+
// `Iterator<T>`'s own `return?(...)` is an OPTIONAL method, so the field's
|
|
813
|
+
// carrier is `optional(function-value-dispatch)` for every hand-written
|
|
814
|
+
// iterator object that omits it. The payload is the convention to call; the
|
|
815
|
+
// optional is a second presence question, answered beside the field's own
|
|
816
|
+
// presence bit below rather than refused.
|
|
817
|
+
const declared = returnField?.value ?? (returnAccessor?.getter ? ctx.abiOfCallable(returnAccessor.getter)?.result : null);
|
|
818
|
+
const optionalReturn = declared?.kind === 'optional';
|
|
819
|
+
const callable = declared?.kind === 'optional' ? declared.payload : declared;
|
|
820
|
+
if (!callable || callable.kind !== 'function-value-dispatch') {
|
|
821
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${representation.kind}`, `reads a typed iterator return method carried as "${callable?.kind ?? 'absent'}", not a callable dispatch value`);
|
|
822
|
+
}
|
|
823
|
+
const access = memberAccessOperator(representation.ownership);
|
|
824
|
+
const method = returnField
|
|
825
|
+
? `${optionalReturn ? `(*${receiver}${access}${cppRecordFieldName('return')})` : `${receiver}${access}${cppRecordFieldName('return')}`}`
|
|
826
|
+
: returnAccessor?.getter
|
|
827
|
+
? iteratorGetterText(ctx, returnAccessor.key, returnAccessor.getter, iterator, 'iterator-close')
|
|
828
|
+
: null;
|
|
829
|
+
if (method === null)
|
|
830
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${representation.kind}`, 'cannot resolve the iterator return method');
|
|
831
|
+
const call = iteratorMethodCallText(ctx, method, callable.abi, iterator, 'iterator return()');
|
|
832
|
+
const result = callable.abi.result;
|
|
833
|
+
const invoke = result.kind === 'dynamic'
|
|
834
|
+
? `gea::runtime::iterator::validateCloseResult(${call});`
|
|
835
|
+
: staticallyObjectCloseResult(result)
|
|
836
|
+
? `(void)(${call});`
|
|
837
|
+
: `{ (void)(${call}); gea::runtime::iterator::throwNotIterable("iterator return method returned a non-object value"); }`;
|
|
838
|
+
if (!returnField)
|
|
839
|
+
return [invoke];
|
|
840
|
+
const guards = [
|
|
841
|
+
...(returnField.required ? [] : [`${receiver}${access}${cppRecordFieldPresenceName('return')}`]),
|
|
842
|
+
...(optionalReturn ? [`${receiver}${access}${cppRecordFieldName('return')}.has_value()`] : [])
|
|
843
|
+
];
|
|
844
|
+
if (guards.length === 0)
|
|
845
|
+
return [invoke];
|
|
846
|
+
return [`if (${guards.join(' && ')}) { ${invoke} }`];
|
|
847
|
+
};
|
|
848
|
+
const iteratorCloseWhileOpenStatements = (ctx, iterator, onlyIfOpen) => {
|
|
849
|
+
const close = iteratorCloseStatements(ctx, iterator);
|
|
850
|
+
if (!onlyIfOpen || close.length === 0)
|
|
851
|
+
return close;
|
|
852
|
+
const representation = iterator.representation;
|
|
853
|
+
const condition = representation.kind === 'dynamic'
|
|
854
|
+
? (() => {
|
|
855
|
+
const done = ctx.dynamicIteratorDoneStates.get(iterator.value);
|
|
856
|
+
if (!done)
|
|
857
|
+
throw createCppEmitBlockedError('runtime-helper:protocol:iterator:close:dynamic', 'conditionally closes a dynamic iterator with no exhaustion state');
|
|
858
|
+
return `!${done}`;
|
|
859
|
+
})()
|
|
860
|
+
: representation.kind === 'iterator'
|
|
861
|
+
? `!${operandText(ctx, iterator)}.done()`
|
|
862
|
+
: null;
|
|
863
|
+
if (condition === null) {
|
|
864
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${representation.kind}`, `conditionally closes a "${representation.kind}" iterator without a persistent exhaustion state`);
|
|
865
|
+
}
|
|
866
|
+
return [`if (${condition}) { ${close.join(' ')} }`];
|
|
867
|
+
};
|
|
868
|
+
/** Direct IteratorClose; a close failure propagates when no throw completion is already pending. */
|
|
869
|
+
export const emitIteratorClose = (ctx, lines, operation) => {
|
|
870
|
+
lines.push(...iteratorCloseWhileOpenStatements(ctx, operation.iterator, operation.onlyIfOpen));
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* Renders one general for-of iteration or finite destructuring sequence as a
|
|
874
|
+
* real C++ protected scope. The catch closes before rethrowing while
|
|
875
|
+
* preserving the original throw completion; the scope guard handles normal
|
|
876
|
+
* finite completion and return/break/goto, where a throwing `return()` does
|
|
877
|
+
* replace a pending non-throw completion. Loop continuation and exhaustion
|
|
878
|
+
* targets dismiss it; finite patterns instead keep it armed through the end
|
|
879
|
+
* and let the `onlyIfOpen` exhaustion test decide whether closure is needed.
|
|
880
|
+
*/
|
|
881
|
+
export const renderIteratorCloseRegion = (ctx, lines, body, region, rendering) => {
|
|
882
|
+
const guard = `__gea_iterator_close_${ctx.nextValueOrdinal++}`;
|
|
883
|
+
const selected = new Set(region.blocks);
|
|
884
|
+
const nestedConsumed = new Set();
|
|
885
|
+
const listed = body.blockOrder.filter((id) => selected.has(id) && id !== region.entry);
|
|
886
|
+
if (!selected.has(region.entry))
|
|
887
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${region.iterator.representation.kind}`, `does not include its declared body entry ${region.entry}`);
|
|
888
|
+
// C++ enters the protected region by fallthrough after this label, so the
|
|
889
|
+
// entry must render first even when block-order placed another reachable
|
|
890
|
+
// body arm earlier for a separate CFG reason.
|
|
891
|
+
const order = [region.entry, ...listed];
|
|
892
|
+
lines.push(`${rendering.labelOf(rendering.labels, region.entry)}:`);
|
|
893
|
+
lines.push('{');
|
|
894
|
+
const close = iteratorCloseWhileOpenStatements(ctx, region.iterator, region.onlyIfOpen);
|
|
895
|
+
lines.push(`gea::runtime::iterator::CompletionGuard ${guard}{[&]() { ${close.join(' ')} }};`);
|
|
896
|
+
// Which half of the region a throw came from. 14.7.5.7 closes for a throw
|
|
897
|
+
// out of the BODY and not for one out of the step -- see
|
|
898
|
+
// `IrIteratorCloseRegion.bodyEntry` -- and the two cannot be separate `try`
|
|
899
|
+
// blocks because the head test's branch jumps into the body. One flag, set
|
|
900
|
+
// where the body starts, lets the single handler tell them apart. It needs no
|
|
901
|
+
// reset on the back edge: the continuation edge jumps to the region's LABEL,
|
|
902
|
+
// which sits outside this scope, so coming round again re-enters the block
|
|
903
|
+
// and re-runs both the guard's construction and this initializer.
|
|
904
|
+
//
|
|
905
|
+
// The flag is emitted only when the body's entry is a block this loop will
|
|
906
|
+
// actually render. A finite pattern has no body, and a body entry consumed
|
|
907
|
+
// by a nested region is rendered by that region's own recursion, so neither
|
|
908
|
+
// gets the split and both keep closing exactly as before.
|
|
909
|
+
const splitEntry = region.bodyEntry !== null &&
|
|
910
|
+
region.bodyEntry !== region.entry &&
|
|
911
|
+
order.includes(region.bodyEntry) &&
|
|
912
|
+
!rendering.regionByTryEntry.has(region.bodyEntry) &&
|
|
913
|
+
!rendering.iteratorCloseRegionByEntry.has(region.bodyEntry)
|
|
914
|
+
? region.bodyEntry
|
|
915
|
+
: null;
|
|
916
|
+
const closingFlag = splitEntry === null ? null : `${guard}_in_body`;
|
|
917
|
+
if (closingFlag !== null)
|
|
918
|
+
lines.push(`bool ${closingFlag} = false;`);
|
|
919
|
+
lines.push('try {');
|
|
920
|
+
const scopedRendering = {
|
|
921
|
+
...rendering,
|
|
922
|
+
emitTerminator: (inner, targetLines, labels, isSingleBlock, terminator) => {
|
|
923
|
+
if (terminator.kind === 'jump' && region.dismissTargets.includes(terminator.target))
|
|
924
|
+
targetLines.push(`${guard}.dismiss();`);
|
|
925
|
+
if (terminator.kind === 'branch') {
|
|
926
|
+
if (region.dismissTargets.includes(terminator.whenTrue))
|
|
927
|
+
targetLines.push(`if (${operandText(inner, terminator.condition)}) ${guard}.dismiss();`);
|
|
928
|
+
if (region.dismissTargets.includes(terminator.whenFalse))
|
|
929
|
+
targetLines.push(`if (!${operandText(inner, terminator.condition)}) ${guard}.dismiss();`);
|
|
930
|
+
}
|
|
931
|
+
rendering.emitTerminator(inner, targetLines, labels, isSingleBlock, terminator);
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
for (const id of order) {
|
|
935
|
+
if (nestedConsumed.has(id))
|
|
936
|
+
continue;
|
|
937
|
+
const block = body.blocks.get(id);
|
|
938
|
+
if (!block)
|
|
939
|
+
throw createCppEmitBlockedError(`runtime-helper:protocol:iterator:close:${region.iterator.representation.kind}`, `names missing body block ${id}`);
|
|
940
|
+
const nested = id === region.entry ? undefined : rendering.regionByTryEntry.get(id);
|
|
941
|
+
const nestedIterator = id === region.entry ? undefined : rendering.iteratorCloseRegionByEntry.get(id);
|
|
942
|
+
if (nestedIterator) {
|
|
943
|
+
const consumed = renderIteratorCloseRegion(ctx, lines, body, nestedIterator, scopedRendering);
|
|
944
|
+
for (const consumedId of consumed)
|
|
945
|
+
nestedConsumed.add(consumedId);
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
if (nested) {
|
|
949
|
+
const consumed = renderTryRegion(ctx, lines, body, nested, scopedRendering);
|
|
950
|
+
for (const consumedId of consumed)
|
|
951
|
+
nestedConsumed.add(consumedId);
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
if (id !== region.entry)
|
|
955
|
+
lines.push(`${rendering.labelOf(rendering.labels, id)}:`);
|
|
956
|
+
if (closingFlag !== null && id === splitEntry)
|
|
957
|
+
lines.push(`${closingFlag} = true;`);
|
|
958
|
+
for (const operation of block.operations)
|
|
959
|
+
rendering.emitOperation(ctx, lines, operation);
|
|
960
|
+
for (const write of rendering.mergeWrites.get(id) ?? [])
|
|
961
|
+
lines.push(`${write.name} = ${operandText(ctx, write.value)};`);
|
|
962
|
+
scopedRendering.emitTerminator(ctx, lines, rendering.labels, rendering.isSingleBlock, block.terminator);
|
|
963
|
+
}
|
|
964
|
+
lines.push('} catch (const gea::Value&) {');
|
|
965
|
+
if (closingFlag === null)
|
|
966
|
+
lines.push(`try { ${guard}.close(); } catch (const gea::Value&) {}`);
|
|
967
|
+
else
|
|
968
|
+
lines.push(`if (${closingFlag}) { try { ${guard}.close(); } catch (const gea::Value&) {} } else { ${guard}.dismiss(); }`);
|
|
969
|
+
lines.push('throw;');
|
|
970
|
+
lines.push('}');
|
|
971
|
+
lines.push('}');
|
|
972
|
+
return order;
|
|
973
|
+
};
|
|
974
|
+
/**
|
|
975
|
+
* The `protocol:enumerate:get-iterator:*` rows this file renders, stated here
|
|
976
|
+
* rather than in `manifest.ts` so the claim and the rendering are one
|
|
977
|
+
* authority -- the same discipline `emit-in.ts`'s `hasPropertyHelperClaims`
|
|
978
|
+
* follows for `k in o`. `record`/`record-with-index`/`class-ref` are the
|
|
979
|
+
* compiler's own struct kinds; `native-record-ref` is claimed too, even
|
|
980
|
+
* though `emitStaticEnumerateIterator` refuses the one sub-shape of it
|
|
981
|
+
* (a host-named struct) that has no field dispatcher to call, because a
|
|
982
|
+
* refusal INSIDE an implemented capability is exactly what preflight's
|
|
983
|
+
* carrier-suffixed obligation keys cannot see coming (they key on the
|
|
984
|
+
* receiver's REPRESENTATION kind, not on the declaration behind it) -- the
|
|
985
|
+
* same posture `nativeSidecarReceiver`'s own ownership refusal takes in
|
|
986
|
+
* `emit-dynamic-properties.ts`. `dynamic` is the genuinely dynamic sibling:
|
|
987
|
+
* a real runtime walk, not a claim over a boxed guess.
|
|
988
|
+
*
|
|
989
|
+
* The native cursor override (`representation/publish.ts`'s
|
|
990
|
+
* `nativeCursorIteratorOf`) publishes `iterator(string)`, whose paired
|
|
991
|
+
* `next` is the shared `protocol:enumerate:next:iterator` row in the
|
|
992
|
+
* manifest. Enumeration never carries the general iterator protocol's
|
|
993
|
+
* synthetic `{ next }` record, so there is deliberately no
|
|
994
|
+
* `protocol:enumerate:next:record` claim here.
|
|
995
|
+
*
|
|
996
|
+
* `native-handle` (`Math`, `Array.prototype`, ...) is claimed for the reason
|
|
997
|
+
* `representation/publish.ts`'s own comment on the identical addition gives:
|
|
998
|
+
* ECMA-262 declares every own property of a host intrinsic non-enumerable, so
|
|
999
|
+
* `emitNativeHandleEnumerateIterator` below builds the cursor from an empty
|
|
1000
|
+
* key vector rather than reading any table -- there is no table to read.
|
|
1001
|
+
*/
|
|
1002
|
+
export const enumerateHelperClaims = [
|
|
1003
|
+
'protocol:enumerate:get-iterator:native-sum',
|
|
1004
|
+
'protocol:enumerate:get-iterator:undefined',
|
|
1005
|
+
'protocol:enumerate:get-iterator:null',
|
|
1006
|
+
'protocol:enumerate:get-iterator:record',
|
|
1007
|
+
'protocol:enumerate:get-iterator:record-with-index',
|
|
1008
|
+
'protocol:enumerate:get-iterator:class-ref',
|
|
1009
|
+
'protocol:enumerate:get-iterator:native-record-ref',
|
|
1010
|
+
'protocol:enumerate:get-iterator:dynamic',
|
|
1011
|
+
'protocol:enumerate:get-iterator:native-handle',
|
|
1012
|
+
'protocol:enumerate:get-iterator:function-value-dispatch',
|
|
1013
|
+
// `for`-`in` over an array -- `emitArrayEnumerateIterator` above. Claimed
|
|
1014
|
+
// only for the shared-refcount ownership that branch requires: an array's
|
|
1015
|
+
// expando half is keyed on the object's own identity, which a by-value
|
|
1016
|
+
// carrier does not have, and the branch falls through without it.
|
|
1017
|
+
'protocol:enumerate:get-iterator:array-object'
|
|
1018
|
+
];
|
|
1019
|
+
/**
|
|
1020
|
+
* The general `for`-`of`/`Symbol.iterator` protocol's own rows -- a class
|
|
1021
|
+
* instance or a plain object whose `[Symbol.iterator]()` is a real,
|
|
1022
|
+
* program-written method, stated here for the same one-authority reason
|
|
1023
|
+
* `enumerateHelperClaims` is, even though two of the five steps this claims
|
|
1024
|
+
* render through machinery this file does not own:
|
|
1025
|
+
*
|
|
1026
|
+
* - `get-method` lowers as an ordinary `[[Get]]` (`ir/lower-protocol.ts`'s
|
|
1027
|
+
* `get-method` case reuses `ctx.builder.get`, exactly as an object-pattern
|
|
1028
|
+
* property read does), rendered by `emit-properties.ts`'s own `emitGet` --
|
|
1029
|
+
* `classMemberText` for `class-ref`, the plain struct-field fallback for
|
|
1030
|
+
* `record`. The claim is stated here anyway, next to the producer
|
|
1031
|
+
* (`producers/protocol.ts`) that resolves WHICH member to read: an ordinary
|
|
1032
|
+
* source-level `obj.method` read carries no `runtime-helper` obligation at
|
|
1033
|
+
* all (`preflight/runtime-helper-key.ts`'s `runtimeHelperKey` has no case
|
|
1034
|
+
* for the property family), so this key exists only because THIS producer
|
|
1035
|
+
* mints a `protocol`-family step for it, and the file that mints the step
|
|
1036
|
+
* is the more honest place to answer for it than the file that happens to
|
|
1037
|
+
* render whatever `[[Get]]` shape any receiver resolves to.
|
|
1038
|
+
* - `get-iterator` and `next` are rendered by `emitDynamicGetIterator` and
|
|
1039
|
+
* `emitDynamicIteratorNext`/`emitIteratorDone` above.
|
|
1040
|
+
*
|
|
1041
|
+
* `class-ref` and `record` only -- never the bare `record` a program-defined
|
|
1042
|
+
* tuple also carries: `preflight/runtime-helper-key.ts`'s
|
|
1043
|
+
* `iteratorMethodCarrierKind` refines a "record" receiver with no
|
|
1044
|
+
* discoverable `@@iterator` FIELD (an open tuple, whose iterator is
|
|
1045
|
+
* `Array.prototype`'s own) to the deliberately unclaimed
|
|
1046
|
+
* `record(no-iterator-method)` sibling, so this claim never has to cover a
|
|
1047
|
+
* shape `emitDynamicGetIterator`'s struct-field read cannot find. The same
|
|
1048
|
+
* refinement applies to `get-method`, over the identical receiver operand.
|
|
1049
|
+
*
|
|
1050
|
+
* `next:record` is not scoped by receiver kind: `next`'s own carrier is the
|
|
1051
|
+
* iterator-record `get-iterator` published, which for BOTH `class-ref` and
|
|
1052
|
+
* `record` receivers is normally the identical synthetic
|
|
1053
|
+
* `{ next(): { value, done } }` shape `iteratorMethodAndRecordTypes`
|
|
1054
|
+
* (`producers/protocol.ts`) builds -- so one claim covers the step regardless
|
|
1055
|
+
* of which receiver produced it.
|
|
1056
|
+
*
|
|
1057
|
+
* `next:iterator` is that same step's other possible carrier: the resolved
|
|
1058
|
+
* `[Symbol.iterator]` was itself a GENERATOR method, so
|
|
1059
|
+
* `generatorRecordTypeOf` (`producers/protocol.ts`) published the real
|
|
1060
|
+
* `Generator<T>` structural type in place of the synthetic record, and
|
|
1061
|
+
* `representation/derive.ts`'s own `GeneratorDeclarationPolicy` carries that
|
|
1062
|
+
* as the native `gea::Iterator<T>` cursor -- `emitIteratorNext`/
|
|
1063
|
+
* `emitIteratorDone`'s existing "iterator" branches read it, unchanged.
|
|
1064
|
+
*/
|
|
1065
|
+
const generalIteratorHelperShapes = [
|
|
1066
|
+
'get-method:class-ref',
|
|
1067
|
+
'get-method:record',
|
|
1068
|
+
// A NAMED shape declaring `[Symbol.iterator]()` reaches the identical
|
|
1069
|
+
// struct-field read a structural record's does -- `emitDynamicGetIterator`
|
|
1070
|
+
// never looks at the receiver's kind, only at the resolved method operand --
|
|
1071
|
+
// and `runtime-helper-key.ts`'s `iteratorMethodCarrierKind` applies the same
|
|
1072
|
+
// fail-closed refinement to it, so a named shape WITHOUT the member is
|
|
1073
|
+
// refused by name rather than certified here.
|
|
1074
|
+
'get-method:native-record-ref',
|
|
1075
|
+
'get-iterator:class-ref',
|
|
1076
|
+
'get-iterator:record',
|
|
1077
|
+
'get-iterator:native-record-ref',
|
|
1078
|
+
'next:record',
|
|
1079
|
+
// Same step, named receiver: `emitIteratorNext` resolves a named layout
|
|
1080
|
+
// through the identical field read, so the claim follows the emitter rather
|
|
1081
|
+
// than stopping at the structural half of one carrier pair.
|
|
1082
|
+
'next:native-record-ref',
|
|
1083
|
+
'next:iterator'
|
|
1084
|
+
];
|
|
1085
|
+
/**
|
|
1086
|
+
* The dynamic-source rows are intentionally separate from the structural
|
|
1087
|
+
* method rows above. Only a source the program declared `any`/`unknown`
|
|
1088
|
+
* reaches these; `runtime::iterator` performs GetIterator/IteratorNext over
|
|
1089
|
+
* its `Value` without converting any statically typed iterable to a box.
|
|
1090
|
+
*/
|
|
1091
|
+
const dynamicValueIteratorHelperShapes = ['get-iterator:dynamic', 'next:dynamic', 'close:dynamic'];
|
|
1092
|
+
/**
|
|
1093
|
+
* The general protocol's claims, for BOTH iteration protocols over the same
|
|
1094
|
+
* six receiver shapes.
|
|
1095
|
+
*
|
|
1096
|
+
* `async-iterator` renders identically here, and the claim says so rather than
|
|
1097
|
+
* leaving the async rows silently unclaimed: `emitGetIterator` below branches
|
|
1098
|
+
* only on `enumerate`, and everything else -- the `[[Get]]` of the well-known
|
|
1099
|
+
* symbol, the call, the per-step `next()` -- is the same code. What makes that
|
|
1100
|
+
* correct rather than an over-claim is the runtime's own async model: `gea::
|
|
1101
|
+
* Promise<V>` is a settled-value box with no job queue, so an async
|
|
1102
|
+
* generator's `next()` hands back an already-settled result and the cursor
|
|
1103
|
+
* that walks it is the synchronous one (`producers/control.ts`'s yield comment
|
|
1104
|
+
* carries the argument in full, including what a port with a real job queue
|
|
1105
|
+
* would have to revisit).
|
|
1106
|
+
*
|
|
1107
|
+
* Derived from one list rather than written twice, so a shape added for one
|
|
1108
|
+
* protocol cannot be forgotten for the other.
|
|
1109
|
+
*/
|
|
1110
|
+
export const dynamicIteratorHelperClaims = [
|
|
1111
|
+
...generalIteratorHelperShapes.map((shape) => `protocol:iterator:${shape}`),
|
|
1112
|
+
...generalIteratorHelperShapes.map((shape) => `protocol:async-iterator:${shape}`),
|
|
1113
|
+
...dynamicValueIteratorHelperShapes.map((shape) => `protocol:iterator:${shape}`),
|
|
1114
|
+
'protocol:iterator:close:record',
|
|
1115
|
+
'protocol:iterator:close:native-record-ref',
|
|
1116
|
+
'protocol:iterator:close:iterator'
|
|
1117
|
+
];
|
|
1118
|
+
/**
|
|
1119
|
+
* `for`-`of` over a fixed-arity tuple, which is not a "dynamic" protocol row
|
|
1120
|
+
* at all despite sitting next to them: no `@@iterator` is fetched and no
|
|
1121
|
+
* method is called, because the position count is a compile-time fact and
|
|
1122
|
+
* `emitStaticTupleIterator` above unrolls it.
|
|
1123
|
+
*
|
|
1124
|
+
* `record(tuple-values)` is `preflight/runtime-helper-key.ts`'s refinement of
|
|
1125
|
+
* a positional "record" receiver whose positions all share one carrier -- the
|
|
1126
|
+
* sibling of the deliberately unclaimed `record(no-iterator-method)` a
|
|
1127
|
+
* heterogeneous tuple keeps, which refuses at preflight rather than reaching
|
|
1128
|
+
* an emitter with one `gea::Iterator<E>` to build and two different `E`s.
|
|
1129
|
+
*
|
|
1130
|
+
* There is no `get-method` row: the producer takes this source down the native
|
|
1131
|
+
* fast path (`producers/shared.ts`'s `hasNativeIterationCursor`), which mints
|
|
1132
|
+
* no `get-method` step to answer for. `next` needs no row either, for the
|
|
1133
|
+
* reason `enumerateHelperClaims` states about its own: the cursor this
|
|
1134
|
+
* publishes is an `iterator`, so its paired step resolves the already-claimed
|
|
1135
|
+
* `protocol:iterator:next:iterator`.
|
|
1136
|
+
*/
|
|
1137
|
+
export const staticTupleIteratorHelperClaims = ['protocol:iterator:get-iterator:record(tuple-values)'];
|