@geastack/compiler 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-emit.js +11 -1
- package/dist/cli-package-source.d.ts +0 -4
- package/dist/cli-package-source.js +8 -112
- package/dist/cli-refusal-location.d.ts +6 -0
- package/dist/cli-refusal-location.js +5 -0
- package/dist/cli.js +2 -1
- package/dist/compiler.d.ts +4 -0
- package/dist/compiler.js +118 -28
- package/dist/conversion/algebra.d.ts +16 -1
- package/dist/conversion/algebra.js +2 -0
- package/dist/conversion/build.js +16 -6
- package/dist/conversion/constructor-identity-family.d.ts +49 -0
- package/dist/conversion/constructor-identity-family.js +67 -0
- package/dist/conversion/derive.js +39 -6
- package/dist/conversion/iterable-object-view.d.ts +44 -0
- package/dist/conversion/iterable-object-view.js +55 -0
- package/dist/conversion/iterator-object-view.d.ts +77 -0
- package/dist/conversion/iterator-object-view.js +112 -0
- package/dist/conversion/nodes.d.ts +93 -0
- package/dist/conversion/nodes.js +262 -5
- package/dist/conversion/operand-view.js +41 -0
- package/dist/conversion/protocol-iterator.d.ts +84 -0
- package/dist/conversion/protocol-iterator.js +88 -0
- package/dist/conversion/record-view.d.ts +152 -8
- package/dist/conversion/record-view.js +518 -37
- package/dist/conversion/registry.d.ts +32 -0
- package/dist/ir/borrowed-call-arguments.d.ts +22 -1
- package/dist/ir/borrowed-call-arguments.js +102 -1
- package/dist/ir/borrowed-callable-uses.d.ts +62 -0
- package/dist/ir/borrowed-callable-uses.js +135 -0
- package/dist/ir/boxed-bind-assumptions.d.ts +24 -0
- package/dist/ir/boxed-bind-assumptions.js +93 -0
- package/dist/ir/build.d.ts +18 -7
- package/dist/ir/build.js +71 -13
- package/dist/ir/call-dispatch.js +474 -10
- package/dist/ir/call-entry.d.ts +24 -1
- package/dist/ir/call-entry.js +106 -1
- package/dist/ir/callable-class-flow.js +15 -5
- package/dist/ir/callable-identity-demand.d.ts +20 -1
- package/dist/ir/callable-identity-demand.js +157 -18
- package/dist/ir/callable-member-candidates.d.ts +11 -1
- package/dist/ir/callable-member-candidates.js +82 -3
- package/dist/ir/callable-records.js +2 -2
- package/dist/ir/callable-site-escape.d.ts +4 -0
- package/dist/ir/callable-site-escape.js +228 -0
- package/dist/ir/captures.d.ts +10 -1
- package/dist/ir/captures.js +219 -4
- package/dist/ir/certify/carrier-keys.d.ts +58 -1
- package/dist/ir/certify/carrier-keys.js +158 -6
- package/dist/ir/certify/property-access-keys.d.ts +17 -0
- package/dist/ir/certify/property-access-keys.js +36 -0
- package/dist/ir/certify/property-access.js +49 -4
- package/dist/ir/certify/runtime-helper.d.ts +4 -0
- package/dist/ir/certify/runtime-helper.js +17 -5
- package/dist/ir/certify.js +132 -79
- package/dist/ir/class-static-fields.d.ts +11 -0
- package/dist/ir/class-static-fields.js +28 -0
- package/dist/ir/construct-entry.d.ts +2 -1
- package/dist/ir/construct-entry.js +3 -2
- package/dist/ir/construction-only-fields.d.ts +73 -0
- package/dist/ir/construction-only-fields.js +211 -0
- package/dist/ir/dominance.d.ts +14 -0
- package/dist/ir/dominance.js +18 -4
- package/dist/ir/emission-representations.js +4 -1
- package/dist/ir/exception-edges.d.ts +17 -0
- package/dist/ir/exception-edges.js +75 -0
- package/dist/ir/facts.d.ts +54 -3
- package/dist/ir/facts.js +182 -5
- package/dist/ir/generator-split.js +2 -2
- package/dist/ir/instance-reparenting.d.ts +83 -0
- package/dist/ir/instance-reparenting.js +167 -0
- package/dist/ir/integer-storage.d.ts +29 -0
- package/dist/ir/integer-storage.js +188 -79
- package/dist/ir/integers.d.ts +16 -0
- package/dist/ir/integers.js +327 -8
- package/dist/ir/integrity-restrictions.d.ts +42 -9
- package/dist/ir/integrity-restrictions.js +335 -42
- package/dist/ir/key-order-observation.d.ts +38 -0
- package/dist/ir/key-order-observation.js +173 -0
- package/dist/ir/literal-set-membership.d.ts +30 -0
- package/dist/ir/literal-set-membership.js +277 -0
- package/dist/ir/lower-allocation.js +68 -8
- package/dist/ir/lower-completion.d.ts +0 -9
- package/dist/ir/lower-completion.js +14 -5
- package/dist/ir/lower-destructuring.js +24 -2
- package/dist/ir/lower-exceptions.js +4 -4
- package/dist/ir/lower-flow.d.ts +21 -0
- package/dist/ir/lower-flow.js +37 -3
- package/dist/ir/lower-graph.d.ts +19 -1
- package/dist/ir/lower-graph.js +91 -67
- package/dist/ir/lower-invocation.d.ts +16 -0
- package/dist/ir/lower-invocation.js +182 -28
- package/dist/ir/lower-narrow.d.ts +0 -46
- package/dist/ir/lower-narrow.js +63 -1
- package/dist/ir/lower-operands.d.ts +52 -2
- package/dist/ir/lower-operands.js +491 -8
- package/dist/ir/lower-property.d.ts +2 -1
- package/dist/ir/lower-property.js +140 -31
- package/dist/ir/lower-protocol.js +16 -4
- package/dist/ir/lower-proxy.d.ts +65 -0
- package/dist/ir/lower-proxy.js +181 -0
- package/dist/ir/lower.js +112 -17
- package/dist/ir/model.d.ts +228 -18
- package/dist/ir/native-class-accessor.d.ts +9 -2
- package/dist/ir/native-class-accessor.js +12 -3
- package/dist/ir/native-class-construction.d.ts +1 -1
- package/dist/ir/native-class-construction.js +2 -1
- package/dist/ir/native-class-initialization.js +2 -2
- package/dist/ir/object-value-conversions.js +20 -5
- package/dist/ir/operation-index.d.ts +16 -0
- package/dist/ir/operation-index.js +17 -0
- package/dist/ir/pcm-loops.d.ts +11 -0
- package/dist/ir/pcm-loops.js +284 -0
- package/dist/ir/presence-proof.js +5 -0
- package/dist/ir/program-facts.d.ts +10 -20
- package/dist/ir/program-facts.js +80 -6
- package/dist/ir/proven-branches.d.ts +2 -2
- package/dist/ir/proven-branches.js +196 -3
- package/dist/ir/queries.js +35 -1
- package/dist/ir/reflection-demand.d.ts +9 -4
- package/dist/ir/reflection-demand.js +400 -28
- package/dist/ir/refusal.d.ts +1 -0
- package/dist/ir/refusal.js +2 -1
- package/dist/ir/shake.d.ts +94 -1
- package/dist/ir/shake.js +209 -12
- package/dist/ir/shared-empty-records.d.ts +12 -0
- package/dist/ir/shared-empty-records.js +301 -0
- package/dist/ir/spread-copy-elision.d.ts +59 -0
- package/dist/ir/spread-copy-elision.js +431 -0
- package/dist/ir/stable-cell-reads.d.ts +40 -0
- package/dist/ir/stable-cell-reads.js +123 -0
- package/dist/ir/static-callables.js +50 -0
- package/dist/ir/string-layout-reuse.d.ts +16 -1
- package/dist/ir/string-layout-reuse.js +66 -0
- package/dist/ir/transfer.d.ts +72 -3
- package/dist/ir/transfer.js +511 -19
- package/dist/ir/typed-property-access.d.ts +18 -2
- package/dist/ir/typed-property-access.js +109 -12
- package/dist/ir/verify.js +2 -1
- package/dist/plugins/apple/plugin.js +3 -2
- package/dist/plugins/gea/host.d.ts +7 -0
- package/dist/plugins/gea/host.js +30 -1
- package/dist/plugins/gea/lower.js +6 -1
- package/dist/plugins/gea/plugin.js +7 -4
- package/dist/plugins/gea/render-bridge.d.ts +4 -2
- package/dist/plugins/gea/render-bridge.js +23 -7
- package/dist/plugins/model.d.ts +2 -0
- package/dist/project-preparation.d.ts +5 -1
- package/dist/project-preparation.js +164 -7
- package/dist/projection/bindings.d.ts +5 -2
- package/dist/projection/bindings.js +40 -1
- package/dist/projection/callee.d.ts +16 -0
- package/dist/projection/callee.js +35 -6
- package/dist/projection/class-prototype.js +5 -1
- package/dist/projection/classes.d.ts +65 -2
- package/dist/projection/classes.js +159 -2
- package/dist/projection/dispatch.d.ts +69 -18
- package/dist/projection/dispatch.js +391 -19
- package/dist/projection/fields.d.ts +4 -3
- package/dist/projection/fields.js +89 -21
- package/dist/projection/instance-test.d.ts +12 -0
- package/dist/projection/instance-test.js +40 -10
- package/dist/projection/method-value-escapes.d.ts +43 -0
- package/dist/projection/method-value-escapes.js +113 -0
- package/dist/projection/slots.d.ts +34 -1
- package/dist/projection/slots.js +82 -5
- package/dist/representation/any-null-record-members.d.ts +41 -0
- package/dist/representation/any-null-record-members.js +115 -0
- package/dist/representation/collections.d.ts +3 -1
- package/dist/representation/collections.js +5 -2
- package/dist/representation/derive.d.ts +9 -1
- package/dist/representation/derive.js +366 -25
- package/dist/representation/difference.js +14 -0
- package/dist/representation/embedded-carriers.js +1 -0
- package/dist/representation/host-abi.d.ts +15 -0
- package/dist/representation/host-abi.js +28 -0
- package/dist/representation/host-templates.d.ts +1 -1
- package/dist/representation/host-templates.js +7 -3
- package/dist/representation/intersection.js +22 -0
- package/dist/representation/json-nullable.d.ts +18 -0
- package/dist/representation/json-nullable.js +22 -0
- package/dist/representation/model.d.ts +141 -0
- package/dist/representation/model.js +47 -3
- package/dist/representation/object-shape.d.ts +5 -1
- package/dist/representation/object-shape.js +5 -2
- package/dist/representation/policies.d.ts +66 -1
- package/dist/representation/proxy-carriers.d.ts +71 -0
- package/dist/representation/proxy-carriers.js +330 -0
- package/dist/representation/publish.d.ts +9 -1
- package/dist/representation/publish.js +186 -18
- package/dist/representation/record-fields.d.ts +5 -0
- package/dist/representation/record-fields.js +7 -1
- package/dist/representation/static-field-cells.d.ts +61 -0
- package/dist/representation/static-field-cells.js +80 -0
- package/dist/representation/unassigned-binding-cells.d.ts +32 -0
- package/dist/representation/unassigned-binding-cells.js +44 -0
- package/dist/representation/union.js +17 -1
- package/dist/representation/unwritten-record-members.d.ts +54 -0
- package/dist/representation/unwritten-record-members.js +167 -0
- package/dist/representation/value-records.js +153 -11
- package/dist/semantics/ambient.d.ts +102 -0
- package/dist/semantics/ambient.js +183 -0
- package/dist/semantics/any-null-member-declarations.d.ts +32 -0
- package/dist/semantics/any-null-member-declarations.js +90 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +14 -0
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.d.ts +51 -0
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +367 -0
- package/dist/semantics/call-invalidated-narrowing.d.ts +3 -0
- package/dist/semantics/call-invalidated-narrowing.js +715 -0
- package/dist/semantics/callable-origins.d.ts +39 -0
- package/dist/semantics/callable-origins.js +73 -2
- package/dist/semantics/class-alias.d.ts +21 -0
- package/dist/semantics/class-alias.js +45 -14
- package/dist/semantics/class-heritage.d.ts +64 -0
- package/dist/semantics/class-heritage.js +278 -2
- package/dist/semantics/commonjs-wrapper.d.ts +1 -1
- package/dist/semantics/commonjs-wrapper.js +24 -7
- package/dist/semantics/constructor-function-class-source-transform.d.ts +4 -0
- package/dist/semantics/constructor-function-class-source-transform.js +327 -0
- package/dist/semantics/constructor-slot-subclasses.js +163 -4
- package/dist/semantics/declaration-overlay-transform.js +197 -3
- package/dist/semantics/frontend.d.ts +31 -0
- package/dist/semantics/frontend.js +177 -19
- package/dist/semantics/host-methods.d.ts +27 -2
- package/dist/semantics/host-methods.js +57 -4
- package/dist/semantics/host-protocols.d.ts +19 -8
- package/dist/semantics/host-protocols.js +145 -31
- package/dist/semantics/interface-families.d.ts +51 -2
- package/dist/semantics/interface-families.js +609 -23
- package/dist/semantics/interface-implementors.d.ts +20 -0
- package/dist/semantics/interface-implementors.js +130 -6
- package/dist/semantics/known-caller-predicate-parameters.d.ts +2 -0
- package/dist/semantics/known-caller-predicate-parameters.js +161 -0
- package/dist/semantics/model/intrinsic-accessor-getters.d.ts +10 -0
- package/dist/semantics/model/intrinsic-accessor-getters.js +4 -0
- package/dist/semantics/model/operands.d.ts +10 -0
- package/dist/semantics/model/operations.d.ts +107 -0
- package/dist/semantics/model/selected-signature.d.ts +33 -0
- package/dist/semantics/model/structural-type-table.d.ts +15 -0
- package/dist/semantics/model/structural-type-table.js +19 -1
- package/dist/semantics/model/structural-types.d.ts +99 -0
- package/dist/semantics/model/structural-types.js +31 -2
- package/dist/semantics/normalize/absent-globals.d.ts +1 -1
- package/dist/semantics/normalize/absent-globals.js +3 -3
- package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +46 -0
- package/dist/semantics/normalize/bivariant-slot-parameter.js +357 -0
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +2 -0
- package/dist/semantics/normalize/callback-parameter-contracts.js +21 -0
- package/dist/semantics/normalize/census.d.ts +2 -1
- package/dist/semantics/normalize/census.js +25 -2
- package/dist/semantics/normalize/class-instance-record-statement.d.ts +37 -0
- package/dist/semantics/normalize/class-instance-record-statement.js +74 -0
- package/dist/semantics/normalize/collection-bindings.js +242 -5
- package/dist/semantics/normalize/commonjs-require.d.ts +26 -0
- package/dist/semantics/normalize/commonjs-require.js +355 -121
- package/dist/semantics/normalize/dead-event-emissions.d.ts +6 -0
- package/dist/semantics/normalize/dead-event-emissions.js +866 -0
- package/dist/semantics/normalize/dead-method-copies.d.ts +56 -0
- package/dist/semantics/normalize/dead-method-copies.js +239 -0
- package/dist/semantics/normalize/derived-expression-type.d.ts +149 -2
- package/dist/semantics/normalize/derived-expression-type.js +418 -14
- package/dist/semantics/normalize/field-bindings.js +139 -4
- package/dist/semantics/normalize/flow/callable-reach.js +162 -9
- package/dist/semantics/normalize/flow/member-call-forwarding.js +6 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.js +40 -2
- package/dist/semantics/normalize/flow/source-class-data.d.ts +7 -1
- package/dist/semantics/normalize/flow/source-class-data.js +28 -9
- package/dist/semantics/normalize/flow/source-value-session.js +32 -13
- package/dist/semantics/normalize/flow/targets.d.ts +32 -0
- package/dist/semantics/normalize/flow/targets.js +65 -6
- package/dist/semantics/normalize/flow/value-flow.d.ts +7 -0
- package/dist/semantics/normalize/flow/value-flow.js +30 -2
- package/dist/semantics/normalize/fresh-array-result.d.ts +32 -0
- package/dist/semantics/normalize/fresh-array-result.js +125 -0
- package/dist/semantics/normalize/gating.js +2 -0
- package/dist/semantics/normalize/global-host-mutations.d.ts +11 -1
- package/dist/semantics/normalize/global-host-mutations.js +691 -27
- package/dist/semantics/normalize/host-effect-contracts.d.ts +43 -1
- package/dist/semantics/normalize/host-effect-contracts.js +60 -3
- package/dist/semantics/normalize/identities.js +49 -3
- package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +59 -0
- package/dist/semantics/normalize/intrinsic-accessor-getter.js +129 -0
- package/dist/semantics/normalize/local-bindings.js +117 -21
- package/dist/semantics/normalize/merged-declaration.d.ts +41 -0
- package/dist/semantics/normalize/merged-declaration.js +81 -0
- package/dist/semantics/normalize/never-override-result.d.ts +21 -0
- package/dist/semantics/normalize/never-override-result.js +64 -0
- package/dist/semantics/normalize/null-blind-parameter.d.ts +21 -0
- package/dist/semantics/normalize/null-blind-parameter.js +77 -0
- package/dist/semantics/normalize/object-bag-bindings.js +10 -0
- package/dist/semantics/normalize/override-field-arms.d.ts +33 -0
- package/dist/semantics/normalize/override-field-arms.js +362 -0
- package/dist/semantics/normalize/parameter-bindings.d.ts +64 -1
- package/dist/semantics/normalize/parameter-bindings.js +801 -81
- package/dist/semantics/normalize/parameter-slot.d.ts +1 -0
- package/dist/semantics/normalize/parameter-slot.js +69 -0
- package/dist/semantics/normalize/physical-overload-result.d.ts +45 -0
- package/dist/semantics/normalize/physical-overload-result.js +132 -0
- package/dist/semantics/normalize/producer-context.d.ts +23 -0
- package/dist/semantics/normalize/producers/allocations.d.ts +13 -0
- package/dist/semantics/normalize/producers/allocations.js +8 -15
- package/dist/semantics/normalize/producers/binding-kind.d.ts +11 -0
- package/dist/semantics/normalize/producers/binding-kind.js +31 -0
- package/dist/semantics/normalize/producers/bindings.js +16 -1
- package/dist/semantics/normalize/producers/boundary.js +21 -1
- package/dist/semantics/normalize/producers/class-lifecycle.js +23 -14
- package/dist/semantics/normalize/producers/computations.js +8 -67
- package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
- package/dist/semantics/normalize/producers/control-loops.js +25 -1
- package/dist/semantics/normalize/producers/control.js +87 -60
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +5 -0
- package/dist/semantics/normalize/producers/enums.d.ts +10 -0
- package/dist/semantics/normalize/producers/enums.js +169 -0
- package/dist/semantics/normalize/producers/erasure.d.ts +10 -0
- package/dist/semantics/normalize/producers/erasure.js +23 -0
- package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +15 -0
- package/dist/semantics/normalize/producers/intrinsic-accessor-getter.js +33 -0
- package/dist/semantics/normalize/producers/invocations.js +255 -18
- package/dist/semantics/normalize/producers/iteration-yield.js +6 -1
- package/dist/semantics/normalize/producers/logical-merge-type.d.ts +36 -0
- package/dist/semantics/normalize/producers/logical-merge-type.js +163 -0
- package/dist/semantics/normalize/producers/properties.js +207 -18
- package/dist/semantics/normalize/producers/protocol.d.ts +4 -0
- package/dist/semantics/normalize/producers/protocol.js +147 -12
- package/dist/semantics/normalize/producers/references.js +50 -9
- package/dist/semantics/normalize/producers/shared.d.ts +120 -0
- package/dist/semantics/normalize/producers/shared.js +359 -10
- package/dist/semantics/normalize/producers/spread-arguments.js +85 -4
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -0
- package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
- package/dist/semantics/normalize/property-key-domain.js +6 -0
- package/dist/semantics/normalize/reachability.d.ts +7 -0
- package/dist/semantics/normalize/reachability.js +166 -9
- package/dist/semantics/normalize/record-home-arms.d.ts +25 -0
- package/dist/semantics/normalize/record-home-arms.js +87 -0
- package/dist/semantics/normalize/record-link-families.d.ts +74 -0
- package/dist/semantics/normalize/record-link-families.js +327 -0
- package/dist/semantics/normalize/record-stand-in-arms.d.ts +56 -0
- package/dist/semantics/normalize/record-stand-in-arms.js +484 -0
- package/dist/semantics/normalize/return-bindings.d.ts +6 -2
- package/dist/semantics/normalize/return-bindings.js +60 -7
- package/dist/semantics/normalize/script-global-redefinition.js +5 -0
- package/dist/semantics/normalize/shared-array-storage.d.ts +42 -0
- package/dist/semantics/normalize/shared-array-storage.js +373 -0
- package/dist/semantics/normalize/sloppy-absence.d.ts +41 -0
- package/dist/semantics/normalize/sloppy-absence.js +199 -0
- package/dist/semantics/normalize/specialization.d.ts +40 -0
- package/dist/semantics/normalize/specialization.js +770 -36
- package/dist/semantics/normalize/structural-array-element.js +196 -6
- package/dist/semantics/normalize/structural-array-read.js +12 -0
- package/dist/semantics/normalize/structural-creation-order.d.ts +15 -0
- package/dist/semantics/normalize/structural-creation-order.js +51 -48
- package/dist/semantics/normalize/structural-declarations.d.ts +16 -0
- package/dist/semantics/normalize/structural-declarations.js +43 -0
- package/dist/semantics/normalize/structural-generics.d.ts +13 -0
- package/dist/semantics/normalize/structural-generics.js +22 -0
- package/dist/semantics/normalize/structural-indexed-access.js +16 -0
- package/dist/semantics/normalize/structural-instantiated-member.js +68 -2
- package/dist/semantics/normalize/structural-joins.js +2 -0
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +30 -0
- package/dist/semantics/normalize/structural-layout-relevance.js +164 -0
- package/dist/semantics/normalize/structural-layout-type.js +270 -14
- package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
- package/dist/semantics/normalize/structural-leaves.js +17 -3
- package/dist/semantics/normalize/structural-mutable-method.js +5 -1
- package/dist/semantics/normalize/structural-parts.d.ts +18 -5
- package/dist/semantics/normalize/structural-parts.js +68 -19
- package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
- package/dist/semantics/normalize/structural-receiver.js +23 -1
- package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
- package/dist/semantics/normalize/structural-self-reference.js +23 -2
- package/dist/semantics/normalize/structural.d.ts +12 -1
- package/dist/semantics/normalize/structural.js +1420 -53
- package/dist/semantics/normalize/suppressed-write-arms.d.ts +47 -0
- package/dist/semantics/normalize/suppressed-write-arms.js +393 -0
- package/dist/semantics/normalize/unresolvable-names.d.ts +15 -2
- package/dist/semantics/normalize/unresolvable-names.js +30 -6
- package/dist/semantics/normalize/unshared-array-result.d.ts +32 -0
- package/dist/semantics/normalize/unshared-array-result.js +125 -0
- package/dist/semantics/package-sources.d.ts +1 -1
- package/dist/semantics/package-sources.js +120 -8
- package/dist/semantics/program.d.ts +20 -0
- package/dist/semantics/program.js +145 -14
- package/dist/semantics/stable-checker.d.ts +1 -1
- package/dist/semantics/stable-checker.js +7 -2
- package/dist/semantics/unchecked-guard-argument-copies.d.ts +67 -0
- package/dist/semantics/unchecked-guard-argument-copies.js +163 -0
- package/dist/semantics/unchecked-write-member-declarations.d.ts +46 -0
- package/dist/semantics/unchecked-write-member-declarations.js +331 -0
- package/dist/targets/cpp/balanced-units.d.ts +31 -0
- package/dist/targets/cpp/balanced-units.js +57 -0
- package/dist/targets/cpp/borrowed-arm-projections.d.ts +31 -0
- package/dist/targets/cpp/borrowed-arm-projections.js +106 -0
- package/dist/targets/cpp/borrowed-call-entry.d.ts +1 -1
- package/dist/targets/cpp/borrowed-call-entry.js +24 -20
- package/dist/targets/cpp/captures.js +314 -8
- package/dist/targets/cpp/char-code-buffers.d.ts +36 -0
- package/dist/targets/cpp/char-code-buffers.js +214 -0
- package/dist/targets/cpp/class-layout.d.ts +7 -1
- package/dist/targets/cpp/class-layout.js +42 -17
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +17 -2
- package/dist/targets/cpp/class-properties/computed-method-value.js +50 -4
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +31 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +174 -17
- package/dist/targets/cpp/class-ref-transport.d.ts +32 -0
- package/dist/targets/cpp/class-ref-transport.js +56 -1
- package/dist/targets/cpp/conversions.js +1827 -1502
- package/dist/targets/cpp/coroutine-bodies.d.ts +97 -0
- package/dist/targets/cpp/coroutine-bodies.js +187 -0
- package/dist/targets/cpp/document.js +11 -1
- package/dist/targets/cpp/emit-allocation.js +535 -21
- package/dist/targets/cpp/emit-arrays.d.ts +10 -0
- package/dist/targets/cpp/emit-arrays.js +147 -16
- package/dist/targets/cpp/emit-binding-reference.d.ts +26 -2
- package/dist/targets/cpp/emit-binding-reference.js +97 -5
- package/dist/targets/cpp/emit-bindings.d.ts +9 -1
- package/dist/targets/cpp/emit-bindings.js +108 -8
- package/dist/targets/cpp/emit-buffers.d.ts +2 -16
- package/dist/targets/cpp/emit-buffers.js +124 -25
- package/dist/targets/cpp/emit-callable.d.ts +35 -72
- package/dist/targets/cpp/emit-callable.js +647 -82
- package/dist/targets/cpp/emit-carrier-members.d.ts +13 -2
- package/dist/targets/cpp/emit-carrier-members.js +50 -9
- package/dist/targets/cpp/emit-constructor-identity-family.d.ts +20 -0
- package/dist/targets/cpp/emit-constructor-identity-family.js +45 -0
- package/dist/targets/cpp/emit-context.d.ts +329 -15
- package/dist/targets/cpp/emit-context.js +104 -13
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +44 -0
- package/dist/targets/cpp/emit-dynamic-properties.js +256 -37
- package/dist/targets/cpp/emit-equality.js +117 -2
- package/dist/targets/cpp/emit-error-constructor.d.ts +19 -0
- package/dist/targets/cpp/emit-error-constructor.js +73 -0
- package/dist/targets/cpp/emit-exceptions.d.ts +25 -3
- package/dist/targets/cpp/emit-exceptions.js +215 -26
- package/dist/targets/cpp/emit-in.js +52 -5
- package/dist/targets/cpp/emit-instanceof.js +59 -11
- package/dist/targets/cpp/emit-integers.d.ts +6 -0
- package/dist/targets/cpp/emit-integers.js +10 -0
- package/dist/targets/cpp/emit-iterable-object-view.d.ts +15 -0
- package/dist/targets/cpp/emit-iterable-object-view.js +51 -0
- package/dist/targets/cpp/emit-iterator-object-view.d.ts +15 -0
- package/dist/targets/cpp/emit-iterator-object-view.js +125 -0
- package/dist/targets/cpp/emit-iterator.d.ts +7 -10
- package/dist/targets/cpp/emit-iterator.js +361 -24
- package/dist/targets/cpp/emit-json.d.ts +7 -1
- package/dist/targets/cpp/emit-json.js +595 -55
- package/dist/targets/cpp/emit-jsx.d.ts +0 -37
- package/dist/targets/cpp/emit-jsx.js +70 -8
- package/dist/targets/cpp/emit-narrowing.d.ts +192 -28
- package/dist/targets/cpp/emit-narrowing.js +1595 -120
- package/dist/targets/cpp/emit-native-selection.js +8 -2
- package/dist/targets/cpp/emit-presence.js +13 -0
- package/dist/targets/cpp/emit-properties.d.ts +3 -1
- package/dist/targets/cpp/emit-properties.js +303 -54
- package/dist/targets/cpp/emit-protocol-iterator.d.ts +14 -0
- package/dist/targets/cpp/emit-protocol-iterator.js +203 -0
- package/dist/targets/cpp/emit-proxy.d.ts +17 -0
- package/dist/targets/cpp/emit-proxy.js +35 -0
- package/dist/targets/cpp/emit-record-view.d.ts +12 -1
- package/dist/targets/cpp/emit-record-view.js +429 -18
- package/dist/targets/cpp/emit-return.d.ts +38 -0
- package/dist/targets/cpp/emit-return.js +143 -21
- package/dist/targets/cpp/emit-scopes.d.ts +78 -0
- package/dist/targets/cpp/emit-scopes.js +196 -0
- package/dist/targets/cpp/emit-sum-widening.js +6 -3
- package/dist/targets/cpp/emit-tonumber.d.ts +40 -1
- package/dist/targets/cpp/emit-tonumber.js +75 -4
- package/dist/targets/cpp/emit-tostring.d.ts +28 -2
- package/dist/targets/cpp/emit-tostring.js +115 -12
- package/dist/targets/cpp/emit-typeof.js +2 -2
- package/dist/targets/cpp/emit-union-properties.d.ts +9 -0
- package/dist/targets/cpp/emit-union-properties.js +375 -46
- package/dist/targets/cpp/emit.d.ts +3 -1
- package/dist/targets/cpp/emit.js +725 -90
- package/dist/targets/cpp/evaluated-once.d.ts +51 -0
- package/dist/targets/cpp/evaluated-once.js +140 -0
- package/dist/targets/cpp/host/core-globals.d.ts +0 -21
- package/dist/targets/cpp/host/core-globals.js +10 -2
- package/dist/targets/cpp/host/emit-host-invoke.d.ts +0 -10
- package/dist/targets/cpp/host/emit-host-invoke.js +454 -36
- package/dist/targets/cpp/host/emit-host-object.js +733 -88
- package/dist/targets/cpp/host/emit-host-properties.js +26 -2
- package/dist/targets/cpp/host/emit-host-reflect.d.ts +1 -0
- package/dist/targets/cpp/host/emit-host-reflect.js +26 -7
- package/dist/targets/cpp/host/emit-host-value.d.ts +13 -0
- package/dist/targets/cpp/host/emit-host-value.js +47 -3
- package/dist/targets/cpp/host/host-members.d.ts +11 -0
- package/dist/targets/cpp/host/host-members.js +50 -4
- package/dist/targets/cpp/host/native-protocols.js +3 -0
- package/dist/targets/cpp/host/object-protocol.d.ts +8 -0
- package/dist/targets/cpp/host/object-protocol.js +55 -13
- package/dist/targets/cpp/key-order-tracking.d.ts +11 -0
- package/dist/targets/cpp/key-order-tracking.js +18 -0
- package/dist/targets/cpp/manifest/capabilities.js +107 -8
- package/dist/targets/cpp/manifest.js +14 -0
- package/dist/targets/cpp/native-collection-base.d.ts +27 -0
- package/dist/targets/cpp/native-collection-base.js +202 -0
- package/dist/targets/cpp/native-error-base.d.ts +14 -0
- package/dist/targets/cpp/native-error-base.js +19 -4
- package/dist/targets/cpp/native-promise-base.d.ts +23 -0
- package/dist/targets/cpp/native-promise-base.js +30 -0
- package/dist/targets/cpp/native-symbol-keys.js +1 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +258 -20
- package/dist/targets/cpp/prototype/emit-prototype-date.js +5 -4
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +9 -1
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +232 -26
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +1 -1
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +111 -13
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +33 -4
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +218 -10
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +8 -5
- package/dist/targets/cpp/prototype/emit-prototype-string.js +24 -7
- package/dist/targets/cpp/prototype/prototype-method-reads.js +18 -3
- package/dist/targets/cpp/reactive-dependencies.d.ts +2 -0
- package/dist/targets/cpp/reactive-dependencies.js +94 -3
- package/dist/targets/cpp/realm-storage.d.ts +5 -0
- package/dist/targets/cpp/realm-storage.js +12 -0
- package/dist/targets/cpp/records.d.ts +151 -1
- package/dist/targets/cpp/records.js +1321 -122
- package/dist/targets/cpp/recursive-containers.d.ts +4 -1
- package/dist/targets/cpp/recursive-containers.js +28 -9
- package/dist/targets/cpp/translation-unit.d.ts +10 -0
- package/dist/targets/cpp/translation-unit.js +686 -140
- package/dist/targets/cpp/types.d.ts +56 -6
- package/dist/targets/cpp/types.js +218 -12
- package/dist/targets/cpp/virtual-methods.d.ts +3 -3
- package/dist/targets/cpp/virtual-methods.js +174 -17
- package/package.json +6 -5
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +155 -25
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_pcm.h +116 -0
- package/src/targets/cpp/runtime/gea_runtime.h +18096 -4876
- package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +7 -45
- package/src/targets/cpp/runtime/gea_runtime_rtc.h +247 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { representationKey } from '../../representation/model.js';
|
|
2
|
-
import { structuralRecordViewPlan } from '../../conversion/record-view.js';
|
|
2
|
+
import { optionalMethodPayloadOf, restForwards, restPacks, structuralRecordViewPlan } from '../../conversion/record-view.js';
|
|
3
3
|
import { classFamilyOverridesOf, virtualDispatchKey } from '../../projection/dispatch.js';
|
|
4
4
|
import { cppVirtualMemberName } from './virtual-methods.js';
|
|
5
5
|
import { classMemberOf } from './class-layout.js';
|
|
6
|
+
import { classMethodOverrideOf, classPrototypeMethodMutableOf } from '../../projection/fields.js';
|
|
7
|
+
import { cppThunkEntryText, cppThunkName } from './emit-context.js';
|
|
6
8
|
import { alignedValueText, boxedAssertionText, chainConverts, convertedValueText, dynamicCarrierBoxText, recastedUnionFromHomes, recastUnionArmText } from './emit-narrowing.js';
|
|
7
9
|
import { ownedRecordMaterializationText } from './emit-owned-record.js';
|
|
8
|
-
import { cppRecordIndexAttributesNameFor,
|
|
9
|
-
import {
|
|
10
|
+
import { cppRecordIndexAttributesNameFor, cppRecordIndexSidecarNameFor, tailAwareFieldReadText, tailAwareFieldWriteText, tailFieldsOf } from './records.js';
|
|
11
|
+
import { evaluatedOnceText } from './evaluated-once.js';
|
|
12
|
+
import { cppAbiParameterType, cppBodyName, cppCallableDeclarationTagName, cppClassName, cppRecordFieldName, cppRecordFieldPresenceName, cppRecordStructName, cppResultTypeOf, cppStringLiteral, cppTypeOf, unitFunctionName } from './types.js';
|
|
10
13
|
/**
|
|
11
14
|
* The renderer of the census's `view:structural-record` recipe
|
|
12
15
|
* (`conversion/record-view.ts`): a record or class instance viewed as another
|
|
@@ -62,6 +65,46 @@ export const viewPlanFor = (layouts, source, target) => {
|
|
|
62
65
|
byTarget.set(target, plan);
|
|
63
66
|
return plan;
|
|
64
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* `viewPlanFor`, planned knowing which interface family members the site
|
|
70
|
+
* named (`nodes.ts`'s `familyMemberViewFor`). Cached per `members` object:
|
|
71
|
+
* the census remembers each node, so the registry's existence check and the
|
|
72
|
+
* printer's render of that node hand in the same one.
|
|
73
|
+
*/
|
|
74
|
+
const familyMemberViewPlans = new WeakMap();
|
|
75
|
+
export const familyMemberViewPlanFor = (layouts, source, target, members) => {
|
|
76
|
+
let byPair = familyMemberViewPlans.get(members);
|
|
77
|
+
if (byPair === undefined) {
|
|
78
|
+
byPair = new Map();
|
|
79
|
+
familyMemberViewPlans.set(members, byPair);
|
|
80
|
+
}
|
|
81
|
+
const key = `${representationKey(source)}->${representationKey(target)}`;
|
|
82
|
+
if (byPair.has(key))
|
|
83
|
+
return byPair.get(key) ?? null;
|
|
84
|
+
const plan = structuralRecordViewPlan(layouts, source, target, chainConverts, members);
|
|
85
|
+
byPair.set(key, plan);
|
|
86
|
+
return plan;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The structural plan of a pair when it homes EVERY arm of a source sum in
|
|
90
|
+
* the target sum (`recastUnionPlan`), optionally under matching optionals --
|
|
91
|
+
* the plan `emit-narrowing.ts`'s `recipeText` renders ahead of the chain
|
|
92
|
+
* for a `view:structural-record` node. Any other plan (a
|
|
93
|
+
* dispatch into one record, a single arm) is not a whole-sum recast.
|
|
94
|
+
*/
|
|
95
|
+
export const unionRecastPlanOf = (layouts, source, target) => {
|
|
96
|
+
const plan = viewPlanFor(layouts, source, target);
|
|
97
|
+
if (plan === null)
|
|
98
|
+
return null;
|
|
99
|
+
if (plan.kind === 'recast-union')
|
|
100
|
+
return plan;
|
|
101
|
+
return plan.kind === 'optional' && plan.sourceOptional && plan.payload.kind === 'recast-union' ? plan : null;
|
|
102
|
+
};
|
|
103
|
+
/** The render of a `familyMemberViewFor` node: its plan, spelled exactly as `structuralRecordViewText` spells the pair's own. */
|
|
104
|
+
export const familyMemberViewText = (ctx, source, target, members, text) => {
|
|
105
|
+
const plan = familyMemberViewPlanFor(ctx.layouts, source, target, members);
|
|
106
|
+
return plan === null ? null : recordViewText(ctx, plan, text);
|
|
107
|
+
};
|
|
65
108
|
const viewEnvironmentName = 'gea_view_env';
|
|
66
109
|
const viewSlotName = 'gea_view_slot';
|
|
67
110
|
const viewReceiverName = 'gea_view_this';
|
|
@@ -113,16 +156,90 @@ const boundClassMethodText = (ctx, source, member, key, text) => {
|
|
|
113
156
|
if (source.kind !== 'class-ref' || source.ownership !== 'shared-refcount')
|
|
114
157
|
return trace('source is not a shared-refcount class ref');
|
|
115
158
|
const abi = 'abi' in member ? member.abi : null;
|
|
116
|
-
if (abi === null || abi.receiver !== null
|
|
159
|
+
if (abi === null || abi.receiver !== null)
|
|
117
160
|
return trace('member declares no plain callable abi');
|
|
118
161
|
const site = classMemberOf(ctx.classes, source.declaration, key);
|
|
119
162
|
if (site === null || site.kind !== 'method' || site.method.callable === null)
|
|
120
163
|
return trace('class has no callable method of that name');
|
|
164
|
+
const own = site.method.representation;
|
|
165
|
+
if (!restForwards(abi, own !== undefined && 'abi' in own ? own.abi : null))
|
|
166
|
+
return trace("member's rest parameter is not the method's own packed rest");
|
|
121
167
|
if (ctx.captures.of(site.method.callable).kind !== 'none')
|
|
122
168
|
return trace('method captures, and the environment slot holds the receiver');
|
|
123
169
|
const receiverType = cppTypeOf(source);
|
|
124
170
|
const formals = abi.parameters.map((parameter, ordinal) => `${cppAbiParameterType(parameter)} ${viewArgumentName(ordinal)}`);
|
|
125
|
-
|
|
171
|
+
// A member frame wider than the method's own fixed frame -- a callback
|
|
172
|
+
// overload joined into the member (`host-abi.ts`'s
|
|
173
|
+
// `callbackOverloadJoinedAbi`) held by a class declaring only the promise
|
|
174
|
+
// form -- passes the method its own prefix: JavaScript binds no formal to an
|
|
175
|
+
// argument past the declared ones.
|
|
176
|
+
const ownFrame = own !== undefined && 'abi' in own ? own.abi : null;
|
|
177
|
+
const passed = ownFrame !== null && ownFrame.restFrom === null && abi.restFrom === null && ownFrame.parameters.length < abi.parameters.length
|
|
178
|
+
? ownFrame.parameters.length
|
|
179
|
+
: abi.parameters.length;
|
|
180
|
+
const actuals = abi.parameters.slice(0, passed).map((_, ordinal) => viewArgumentName(ordinal));
|
|
181
|
+
// The fixed prefix ahead of a rest position is the METHOD's own formal, which
|
|
182
|
+
// may be wider than the member's (`event: string | symbol` behind a
|
|
183
|
+
// `'stateChanged'` literal, or a stream-like interface's `emit(name: string,
|
|
184
|
+
// ...)` field bound to `EventEmitter.emit(name: EventName, ...)` once the
|
|
185
|
+
// concrete class declares no override of its own and the bind falls through
|
|
186
|
+
// to the ancestor). Shared by both shapes below: `restPacks`' fully-fixed
|
|
187
|
+
// member and `restForwards`' own already-packed member differ only in what
|
|
188
|
+
// happens AT the rest position, never in whether the prefix before it needs
|
|
189
|
+
// converting.
|
|
190
|
+
const widenFixedPrefix = (restFrom) => {
|
|
191
|
+
for (let ordinal = 0; ordinal < restFrom; ordinal++) {
|
|
192
|
+
const held = abi.parameters[ordinal]?.value;
|
|
193
|
+
const formal = ownFrame?.parameters[ordinal]?.value;
|
|
194
|
+
if (held === undefined || formal === undefined || cppTypeOf(held) === cppTypeOf(formal))
|
|
195
|
+
continue;
|
|
196
|
+
const converted = alignedValueText(ctx, 'emit-record-view.ts:widenFixedPrefix', held, formal, viewArgumentName(ordinal));
|
|
197
|
+
if (converted === null)
|
|
198
|
+
return `member argument ${ordinal} does not enter the method's formal`;
|
|
199
|
+
actuals[ordinal] = converted;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
};
|
|
203
|
+
// The method packs its rest where the member declares fixed parameters
|
|
204
|
+
// (`restPacks`): the member's arguments from the rest position on become
|
|
205
|
+
// the method's one Array, each entered into its element carrier.
|
|
206
|
+
if (ownFrame !== null && restPacks(abi, ownFrame)) {
|
|
207
|
+
const restFrom = ownFrame.restFrom;
|
|
208
|
+
const rest = ownFrame.parameters[restFrom]?.value;
|
|
209
|
+
if (rest === undefined || rest.kind !== 'array-object')
|
|
210
|
+
return trace("method's rest is not an Array");
|
|
211
|
+
const elementType = cppTypeOf(rest.element);
|
|
212
|
+
const elements = [];
|
|
213
|
+
for (const [offset, parameter] of abi.parameters.slice(restFrom).entries()) {
|
|
214
|
+
const formal = viewArgumentName(restFrom + offset);
|
|
215
|
+
const element = cppTypeOf(parameter.value) === elementType
|
|
216
|
+
? formal
|
|
217
|
+
: alignedValueText(ctx, 'emit-record-view.ts:restPack', parameter.value, rest.element, formal);
|
|
218
|
+
if (element === null)
|
|
219
|
+
return trace(`member argument ${restFrom + offset} does not enter the method's rest element`);
|
|
220
|
+
elements.push(element);
|
|
221
|
+
}
|
|
222
|
+
actuals.splice(restFrom, actuals.length - restFrom, `gea::arrayOf<${elementType}>({${elements.join(', ')}})`);
|
|
223
|
+
const refused = widenFixedPrefix(restFrom);
|
|
224
|
+
if (refused !== null)
|
|
225
|
+
return trace(refused);
|
|
226
|
+
}
|
|
227
|
+
else if (ownFrame !== null && ownFrame.restFrom !== null && abi.restFrom === ownFrame.restFrom) {
|
|
228
|
+
// `restForwards` proved the two rest slots agree on their ELEMENT carrier;
|
|
229
|
+
// it says nothing about the fixed positions ahead of it, which the member
|
|
230
|
+
// and the method may still name with different (but convertible) types.
|
|
231
|
+
const refused = widenFixedPrefix(ownFrame.restFrom);
|
|
232
|
+
if (refused !== null)
|
|
233
|
+
return trace(refused);
|
|
234
|
+
}
|
|
235
|
+
else if (ownFrame !== null && ownFrame.restFrom === null && abi.restFrom === null) {
|
|
236
|
+
// Fixed signatures need the same carrier conversion as the prefix of a
|
|
237
|
+
// rest signature. An interface can pass one record into a method whose
|
|
238
|
+
// complete caller census places that argument in a native union.
|
|
239
|
+
const refused = widenFixedPrefix(passed);
|
|
240
|
+
if (refused !== null)
|
|
241
|
+
return trace(refused);
|
|
242
|
+
}
|
|
126
243
|
const call = `${cppBodyName(site.method.callable)}(${[`*${viewReceiverName}`, ...actuals].join(', ')})`;
|
|
127
244
|
// A void-result member needs no conversion at all -- `call` is a statement,
|
|
128
245
|
// not an expression the lambda hands back -- so only a non-void result asks
|
|
@@ -165,6 +282,46 @@ const boundClassMethodText = (ctx, source, member, key, text) => {
|
|
|
165
282
|
const invoke = `+[](void* ${viewEnvironmentName}${formals.length > 0 ? ', ' : ''}${formals.join(', ')}) -> ${cppResultTypeOf(abi.result)} { ${body} }`;
|
|
166
283
|
return `${cppTypeOf(member)}(${invoke}, gea::packEnvironment<${receiverType}>(${text}))`;
|
|
167
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* A class METHOD as a member whose convention keeps the receiver a formal:
|
|
287
|
+
* the prototype's own function object, the value `instance.method` reads.
|
|
288
|
+
*
|
|
289
|
+
* mongodb's `createStdioLogger(process.stderr)` declares its parameter
|
|
290
|
+
* `{ write: NodeJS.WriteStream['write'] }` -- the method's TYPE, receiver
|
|
291
|
+
* included -- so the member is not a bound closure but the unbound method,
|
|
292
|
+
* and a call through the view supplies `this` from the view's origin. The
|
|
293
|
+
* value is minted through `gea::nativeClassMethodValue`, the same identity
|
|
294
|
+
* cache a plain `instance.method` read uses (`emit-class-properties.ts`), so
|
|
295
|
+
* `view.write === stream.write` holds.
|
|
296
|
+
*
|
|
297
|
+
* Refused where naming the resolved body is not the method the instance
|
|
298
|
+
* answers with: a subclass that overrides the key, an own-property shadow a
|
|
299
|
+
* class body stores, a prototype the program replaces, or a body with
|
|
300
|
+
* captures whose environment this expression cannot build.
|
|
301
|
+
*/
|
|
302
|
+
const classMethodValueViewText = (ctx, source, member, key, text) => {
|
|
303
|
+
if (source.kind !== 'class-ref')
|
|
304
|
+
return null;
|
|
305
|
+
const site = classMemberOf(ctx.classes, source.declaration, key);
|
|
306
|
+
if (site === null || site.kind !== 'method' || site.method.callable === null)
|
|
307
|
+
return null;
|
|
308
|
+
if (classFamilyOverridesOf(ctx.classes, source.declaration, key).length > 0)
|
|
309
|
+
return null;
|
|
310
|
+
if (classMethodOverrideOf(ctx.classes, source.declaration, key) !== null)
|
|
311
|
+
return null;
|
|
312
|
+
if (classPrototypeMethodMutableOf(ctx.classes, source.declaration, key))
|
|
313
|
+
return null;
|
|
314
|
+
if (ctx.captures.of(site.method.callable).kind !== 'none')
|
|
315
|
+
return null;
|
|
316
|
+
const own = site.method.representation;
|
|
317
|
+
if (own === undefined || own.kind !== 'function-value-dispatch')
|
|
318
|
+
return null;
|
|
319
|
+
const callable = site.method.callable;
|
|
320
|
+
const entry = ctx.functionFacts === undefined ? `&${cppThunkName(callable)}` : cppThunkEntryText({ functionFacts: ctx.functionFacts }, callable);
|
|
321
|
+
const value = `gea::nativeClassMethodValue<${cppClassName(site.owner)}, &${cppCallableDeclarationTagName(callable)}>` +
|
|
322
|
+
`(${text}->gea_method_state, ${cppTypeOf(own)}{${entry}, nullptr})`;
|
|
323
|
+
return alignedValueText(ctx, 'emit-record-view.ts:classMethodValueViewText', own, member, value);
|
|
324
|
+
};
|
|
168
325
|
/**
|
|
169
326
|
* A getter-backed member, read by CALLING the getter -- the same answer
|
|
170
327
|
* `emit-class-properties.ts` gives an ordinary `obj.member` read of an
|
|
@@ -211,7 +368,9 @@ const classAccessorReadText = (ctx, source, member, key, published, text) => {
|
|
|
211
368
|
*/
|
|
212
369
|
export const structuralRecordViewText = (ctx, source, target, text) => {
|
|
213
370
|
const plan = viewPlanFor(ctx.layouts, source, target);
|
|
214
|
-
|
|
371
|
+
// A view reads its source once per field; `evaluated-once.ts` keeps that
|
|
372
|
+
// one evaluation of the source when the source is an expression.
|
|
373
|
+
return evaluatedOnceText(text, (operand) => plan === null ? boxedAssertionText(source, target, operand) : recordViewText(ctx, plan, operand));
|
|
215
374
|
};
|
|
216
375
|
const recordViewText = (ctx, plan, text) => {
|
|
217
376
|
switch (plan.kind) {
|
|
@@ -229,6 +388,8 @@ const recordViewText = (ctx, plan, text) => {
|
|
|
229
388
|
if (built === null)
|
|
230
389
|
return null;
|
|
231
390
|
const optional = cppTypeOf(plan.target);
|
|
391
|
+
if (plan.sourceNullableReference)
|
|
392
|
+
return `(${text} ? ${optional}(${built}) : ${optional}())`;
|
|
232
393
|
if (!plan.sourceOptional)
|
|
233
394
|
return `${optional}(${built})`;
|
|
234
395
|
return `(${text}.has_value() ? ${optional}(${built}) : ${optional}())`;
|
|
@@ -297,47 +458,218 @@ const recordViewText = (ctx, plan, text) => {
|
|
|
297
458
|
result = `${text}.is<${index}>() ? ${homes[index]} : (${result})`;
|
|
298
459
|
return `(${result})`;
|
|
299
460
|
}
|
|
461
|
+
case 'iterator-result': {
|
|
462
|
+
const source = 'gea_iterator_result';
|
|
463
|
+
const targetType = cppTypeOf(plan.target);
|
|
464
|
+
const home = (planned) => {
|
|
465
|
+
const arm = plan.target.arms[planned.index];
|
|
466
|
+
if (arm === undefined)
|
|
467
|
+
return null;
|
|
468
|
+
const built = planned.payload === null
|
|
469
|
+
? alignedValueText(ctx, 'emit-record-view.ts:iterator-result', plan.source, arm.value, source)
|
|
470
|
+
: recordViewText(ctx, planned.payload, source);
|
|
471
|
+
return built === null ? null : `${targetType}::ofArm<${planned.index}>(${built})`;
|
|
472
|
+
};
|
|
473
|
+
const returned = home(plan.returnHome);
|
|
474
|
+
const yielded = home(plan.yieldHome);
|
|
475
|
+
if (returned === null || yielded === null)
|
|
476
|
+
return null;
|
|
477
|
+
// An `owned` record is a value, not a handle, exactly as `recordFieldsViewText` reads one.
|
|
478
|
+
const arrow = (plan.source.kind === 'record' || plan.source.kind === 'record-with-index') && plan.source.ownership !== 'shared-refcount'
|
|
479
|
+
? '.'
|
|
480
|
+
: '->';
|
|
481
|
+
return (`([&]() -> ${targetType} { const auto& ${source} = ${text}; ` +
|
|
482
|
+
`return ${source}${arrow}${cppRecordFieldName('done')} ? ${returned} : ${yielded}; }())`);
|
|
483
|
+
}
|
|
300
484
|
case 'fields':
|
|
301
485
|
return recordFieldsViewText(ctx, plan, text);
|
|
302
486
|
}
|
|
303
487
|
};
|
|
488
|
+
/** The cell holding a record view's one sidecar lookup; see `recordViewText`. */
|
|
489
|
+
const sidecarExpandoCell = 'gea_sidecar_expando';
|
|
490
|
+
/**
|
|
491
|
+
* A view built field by field depends on nothing at its site but the source it
|
|
492
|
+
* reads, so a unit defines it once over a formal and every site calls it
|
|
493
|
+
* (`unitFunctionName`). mongodb rebuilds its 131-field options record out of
|
|
494
|
+
* the same source carrier at dozens of call arguments; pasted, each copy was
|
|
495
|
+
* the whole field list.
|
|
496
|
+
*/
|
|
304
497
|
const recordFieldsViewText = (ctx, plan, text) => {
|
|
498
|
+
const formal = 'gea_view_source';
|
|
499
|
+
const body = recordFieldsViewTextAt(ctx, plan, formal);
|
|
500
|
+
if (body === null)
|
|
501
|
+
return null;
|
|
502
|
+
const named = unitFunctionName(`gea_view_${cppRecordStructName(plan.target.shapeId)}`, (name) => `${cppTypeOf(plan.target)} ${name}(const ${cppTypeOf(plan.source)}& ${formal})`, `return ${body};`);
|
|
503
|
+
return named === null ? recordFieldsViewTextAt(ctx, plan, text) : `${named}(${text})`;
|
|
504
|
+
};
|
|
505
|
+
const recordFieldsViewTextAt = (ctx, plan, text) => {
|
|
506
|
+
const sidecarCells = [];
|
|
507
|
+
const built = recordFieldsBuiltText(ctx, plan, text, sidecarCells);
|
|
508
|
+
if (built === null || sidecarCells.length === 0)
|
|
509
|
+
return built;
|
|
510
|
+
// The source's identity-keyed sidecar, looked up once for every added key
|
|
511
|
+
// the view reads from it (`gea::detail::nativeSidecarGet`); `null` when the
|
|
512
|
+
// record never grew one. `sidecarExpandoCell` marks the lookup; the cells
|
|
513
|
+
// follow it.
|
|
514
|
+
const cells = sidecarCells.map((cell) => cell === sidecarExpandoCell
|
|
515
|
+
? `const gea::Ref<gea::DynamicObject> ${cell} = gea::detail::expandoFor(gea::refCastToVoid(${text}), false);`
|
|
516
|
+
: `gea::Value ${cell};`);
|
|
517
|
+
if (!sidecarCells.includes(sidecarExpandoCell))
|
|
518
|
+
return `([&]() { ${cells.join(' ')} return ${built}; }())`;
|
|
519
|
+
// A record that never grew a sidecar -- the common case: a typed options
|
|
520
|
+
// record the program only ever wrote through its declared fields -- holds
|
|
521
|
+
// none of the added keys, so the view is built from the declared fields
|
|
522
|
+
// alone. Without this branch every added key was still a `PropertyKey`, a
|
|
523
|
+
// `nativeSidecarGet` and a `gea::Value` per view: mongodb's 134-field
|
|
524
|
+
// options record read 110 of them from an empty sidecar, twice per
|
|
525
|
+
// operation.
|
|
526
|
+
// Index-sidecar reads still number their cells from this list, so it
|
|
527
|
+
// starts past the expando cell and any cell only this build names is
|
|
528
|
+
// declared beside the others.
|
|
529
|
+
const absentCells = [sidecarExpandoCell];
|
|
530
|
+
const absent = recordFieldsBuiltText(ctx, plan, text, absentCells, true);
|
|
531
|
+
if (absent === null)
|
|
532
|
+
return null;
|
|
533
|
+
// The expando-free build reads no sidecar cell but an index one, so only
|
|
534
|
+
// those are declared ahead of the branch it returns from; the cells the
|
|
535
|
+
// full build alone names follow the branch. Declared before it, every one
|
|
536
|
+
// of them was constructed and destroyed on the path that never read it --
|
|
537
|
+
// 134 `gea::Value`s per view of mongodb's options family, twice an
|
|
538
|
+
// operation, for a sidecar the record did not have.
|
|
539
|
+
const shared = absentCells.filter((cell) => cell !== sidecarExpandoCell);
|
|
540
|
+
const before = cells.filter((cell) => cell.startsWith('const gea::Ref<gea::DynamicObject>') || shared.some((name) => cell === `gea::Value ${name};`));
|
|
541
|
+
const after = cells.filter((cell) => !before.includes(cell));
|
|
542
|
+
const extra = shared.filter((cell) => !sidecarCells.includes(cell)).map((cell) => `gea::Value ${cell};`);
|
|
543
|
+
// The full build is out of line and cold: it is most of the view's code
|
|
544
|
+
// (a lookup, a `PropertyKey` and a `gea::Value` per added key -- 110 of
|
|
545
|
+
// them for mongodb's options family, ~60 KB of machine code per view) and
|
|
546
|
+
// the rare case, and inlined beside the expando-free build it spread every
|
|
547
|
+
// view's hot path across the instruction cache.
|
|
548
|
+
return `([&]() { ${[...before, ...extra].join(' ')} if (!${sidecarExpandoCell}) return ${absent}; return ([&]() __attribute__((noinline, cold)) { ${after.join(' ')} return ${built}; }()); }())`;
|
|
549
|
+
};
|
|
550
|
+
const recordFieldsBuiltText = (ctx, plan, text, sidecarCells,
|
|
551
|
+
// The source has no expando sidecar (`recordFieldsViewTextAt`'s null
|
|
552
|
+
// branch): every key read from one is absent. Index-sidecar reads are
|
|
553
|
+
// unaffected; those are a field of the source, not its expando.
|
|
554
|
+
expandoAbsent = false) => {
|
|
305
555
|
const { source, target } = plan;
|
|
306
556
|
// An `owned` record is a value, not a handle: its members are reached with
|
|
307
557
|
// `.` where every refcounted carrier uses `->`.
|
|
308
558
|
const arrow = (source.kind === 'record' || source.kind === 'record-with-index') && source.ownership !== 'shared-refcount' ? '.' : '->';
|
|
309
559
|
const reads = [];
|
|
560
|
+
// Presence bits are ASSIGNED after the build, never initialized by
|
|
561
|
+
// position: `records.ts` lays out one bit per field, required ones
|
|
562
|
+
// included, unless the program-wide census made the required bits `static`
|
|
563
|
+
// -- so a positional list of the OPTIONAL bits lands each on a required one
|
|
564
|
+
// whenever that census says no (see `emit-narrowing.ts`'s
|
|
565
|
+
// `recastedRecordText`). Left alone a bit keeps its declared default.
|
|
310
566
|
const presences = [];
|
|
311
567
|
const structName = cppRecordStructName(target.shapeId);
|
|
568
|
+
// A source or target whose layout moved fields behind its `RecordTail`
|
|
569
|
+
// (records.ts's `tailFieldsOf`) is read through the tail's non-allocating
|
|
570
|
+
// spelling and, as a target, filled by name rather than by position.
|
|
571
|
+
const sourceFields = source.kind === 'record' || source.kind === 'record-with-index'
|
|
572
|
+
? source.fields
|
|
573
|
+
: source.kind === 'native-record-ref' && source.native === null
|
|
574
|
+
? ctx.layouts.forShape(source.shapeId)
|
|
575
|
+
: null;
|
|
576
|
+
const heldTextOf = (key) => sourceFields === null ? `${text}${arrow}${cppRecordFieldName(key)}` : tailAwareFieldReadText(sourceFields, key, `${text}${arrow}`);
|
|
577
|
+
const targetFields = target.kind === 'record' ? target.fields : ctx.layouts.forShape(target.shapeId);
|
|
578
|
+
const targetTailed = targetFields !== null && tailFieldsOf({ fields: targetFields }).size > 0;
|
|
579
|
+
let orderSensitive = false;
|
|
312
580
|
for (const { field, read } of plan.fields) {
|
|
581
|
+
// An optional method member is bound as its present payload, then held
|
|
582
|
+
// by the optional (`optionalMethodPayloadOf`).
|
|
583
|
+
const method = optionalMethodPayloadOf(field.value);
|
|
584
|
+
const present = (bound) => (method === field.value ? bound : `${cppTypeOf(field.value)}(${bound})`);
|
|
313
585
|
if (read.kind === 'bound-method') {
|
|
314
|
-
const bound = boundClassMethodText(ctx, source,
|
|
586
|
+
const bound = boundClassMethodText(ctx, source, method, field.key, text);
|
|
315
587
|
if (bound === null)
|
|
316
588
|
return null;
|
|
317
|
-
reads.push(bound);
|
|
589
|
+
reads.push(present(bound));
|
|
590
|
+
if (!field.required)
|
|
591
|
+
presences.push([field.key, 'true']);
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
if (read.kind === 'method-value') {
|
|
595
|
+
const value = classMethodValueViewText(ctx, source, method, field.key, text);
|
|
596
|
+
if (value === null)
|
|
597
|
+
return null;
|
|
598
|
+
reads.push(present(value));
|
|
318
599
|
if (!field.required)
|
|
319
|
-
presences.push('true');
|
|
600
|
+
presences.push([field.key, 'true']);
|
|
320
601
|
continue;
|
|
321
602
|
}
|
|
322
603
|
if (read.kind === 'class-accessor') {
|
|
323
604
|
const got = classAccessorReadText(ctx, source, field.value, field.key, read.value, text);
|
|
324
605
|
if (got === null)
|
|
325
606
|
return null;
|
|
607
|
+
orderSensitive = true;
|
|
326
608
|
reads.push(got);
|
|
327
609
|
if (!field.required)
|
|
328
|
-
presences.push('true');
|
|
610
|
+
presences.push([field.key, 'true']);
|
|
329
611
|
continue;
|
|
330
612
|
}
|
|
331
613
|
if (read.kind === 'absent') {
|
|
332
614
|
reads.push(`${cppTypeOf(field.value)}{}`);
|
|
333
615
|
if (!field.required)
|
|
334
|
-
presences.push('false');
|
|
616
|
+
presences.push([field.key, 'false']);
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
if (read.kind === 'sidecar') {
|
|
620
|
+
const fromIndex = read.from === 'index' && source.kind === 'record-with-index';
|
|
621
|
+
if (expandoAbsent && !fromIndex) {
|
|
622
|
+
reads.push(`${cppTypeOf(field.value)}{}`);
|
|
623
|
+
if (!field.required)
|
|
624
|
+
presences.push([field.key, 'false']);
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
// The key's value, or `undefined` when the sidecar lacks it: an absent
|
|
628
|
+
// key and an explicit `undefined` both read back as the optional's absence.
|
|
629
|
+
orderSensitive = true;
|
|
630
|
+
if (!fromIndex && !sidecarCells.includes(sidecarExpandoCell))
|
|
631
|
+
sidecarCells.unshift(sidecarExpandoCell);
|
|
632
|
+
const got = fromIndex
|
|
633
|
+
? `${text}${arrow}${cppRecordIndexSidecarNameFor(source.indexes[0], source.indexes)}.read(${cppStringLiteral(field.key)})`
|
|
634
|
+
: `gea::nativeSidecarGetText(${text}, ${sidecarExpandoCell}, ${cppStringLiteral(field.key)})`;
|
|
635
|
+
const fieldType = cppTypeOf(field.value);
|
|
636
|
+
const sidecarValue = { kind: 'dynamic', reason: 'declared-any-never-narrowed' };
|
|
637
|
+
const converted = alignedValueText(ctx, 'emit-record-view.ts:sidecar-field', sidecarValue, field.value, 'gea_sidecar');
|
|
638
|
+
if (converted === null)
|
|
639
|
+
return null;
|
|
640
|
+
const returned = `return gea_sidecar.tag() == gea::Value::Tag::Undefined ? ${fieldType}{} : ${fieldType}(${converted});`;
|
|
641
|
+
// The absent-or-converted read depends on the field's carrier alone, so
|
|
642
|
+
// it is one unit function per carrier, called with the sidecar's value.
|
|
643
|
+
const sidecarRead = unitFunctionName('gea_sidecar_field', (name) => `${fieldType} ${name}(const gea::Value& gea_sidecar)`, returned);
|
|
644
|
+
if (field.required) {
|
|
645
|
+
reads.push(sidecarRead === null
|
|
646
|
+
? `([&]() -> ${fieldType} { const gea::Value gea_sidecar = ${got}; ${returned} }())`
|
|
647
|
+
: `${sidecarRead}(${got})`);
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
// The presence flag answers from the SAME read as the value: a sidecar
|
|
651
|
+
// key is a `[[Get]]` that may run an accessor, and reading it again for
|
|
652
|
+
// the flag ran it twice. Braced initialization evaluates in order
|
|
653
|
+
// ([dcl.init.list]/4), so every value's read has landed in its cell
|
|
654
|
+
// before the first flag is initialized.
|
|
655
|
+
const cell = `gea_sidecar_read_${sidecarCells.length}`;
|
|
656
|
+
sidecarCells.push(cell);
|
|
657
|
+
reads.push(sidecarRead === null
|
|
658
|
+
? `([&]() -> ${fieldType} { ${cell} = ${got}; const gea::Value& gea_sidecar = ${cell}; ${returned} }())`
|
|
659
|
+
: `${sidecarRead}(${cell} = ${got})`);
|
|
660
|
+
presences.push([field.key, `(${cell}.tag() != gea::Value::Tag::Undefined)`]);
|
|
335
661
|
continue;
|
|
336
662
|
}
|
|
337
663
|
const held = read.held;
|
|
338
|
-
const
|
|
664
|
+
const heldText = heldTextOf(field.key);
|
|
665
|
+
const converted = read.kind === 'view' ? recordViewText(ctx, read.plan, heldText) : convertedValueText(held.value, field.value, heldText);
|
|
339
666
|
if (converted === null)
|
|
340
667
|
return null;
|
|
668
|
+
// A nested view is order-sensitive exactly when its own reads are: a
|
|
669
|
+
// getter body, a virtual accessor or a sidecar `[[Get]]` inside it.
|
|
670
|
+
if (read.kind === 'view' && ['gea_sidecar', 'gea_vget_', 'gea_body_fn_decl_'].some((mark) => converted.includes(mark))) {
|
|
671
|
+
orderSensitive = true;
|
|
672
|
+
}
|
|
341
673
|
// Inside braces [dcl.init.list]/7 forbids the narrowing every other
|
|
342
674
|
// position allows: a field the integer census holds in a `long long`
|
|
343
675
|
// (`{ kind, type }` with `kind: 1 | 2`) is a hard error written into a
|
|
@@ -356,7 +688,7 @@ const recordFieldsViewText = (ctx, plan, text) => {
|
|
|
356
688
|
? `static_cast<decltype(${structName}::${cppRecordFieldName(field.key)})>(${converted})`
|
|
357
689
|
: converted);
|
|
358
690
|
if (!field.required) {
|
|
359
|
-
presences.push(held.required ? 'true' : `${text}${arrow}${cppRecordFieldPresenceName(field.key)}`);
|
|
691
|
+
presences.push([field.key, held.required ? 'true' : `${text}${arrow}${cppRecordFieldPresenceName(field.key)}`]);
|
|
360
692
|
}
|
|
361
693
|
}
|
|
362
694
|
if (source.kind === 'record-with-index') {
|
|
@@ -365,13 +697,92 @@ const recordFieldsViewText = (ctx, plan, text) => {
|
|
|
365
697
|
reads.push(`${text}${arrow}${cppRecordIndexAttributesNameFor(sourceIndex, source.indexes)}`);
|
|
366
698
|
}
|
|
367
699
|
}
|
|
368
|
-
reads.
|
|
369
|
-
const
|
|
700
|
+
const built = `${structName}{${reads.join(', ')}}`;
|
|
701
|
+
const targetArrow = target.ownership === 'shared-refcount' ? '->' : '.';
|
|
702
|
+
const spills = presences
|
|
703
|
+
.filter(([, present]) => present !== 'false')
|
|
704
|
+
.map(([key, present]) => `gea_view${targetArrow}${cppRecordFieldPresenceName(key)} = ${present};`);
|
|
705
|
+
// A named source field the target does not declare lands in the target's
|
|
706
|
+
// string index (`RecordViewPlan.spilled`), after the struct is built.
|
|
707
|
+
for (const { held, index } of plan.spilled ?? []) {
|
|
708
|
+
const heldText = heldTextOf(held.key);
|
|
709
|
+
const converted = alignedValueText(ctx, 'emit-record-view.ts:index-spill', held.value, index.value, heldText);
|
|
710
|
+
if (converted === null)
|
|
711
|
+
return null;
|
|
712
|
+
const store = `gea_view${targetArrow}${cppRecordIndexSidecarNameFor(index, [index])}[${cppStringLiteral(held.key)}] = ${converted};`;
|
|
713
|
+
spills.push(held.required ? store : `if (${text}${arrow}${cppRecordFieldPresenceName(held.key)}) ${store}`);
|
|
714
|
+
}
|
|
715
|
+
const spilledInto = (value) => spills.length === 0 ? value : `([&]() { auto gea_view = ${value}; ${spills.join(' ')} return gea_view; }())`;
|
|
716
|
+
if (targetTailed) {
|
|
717
|
+
// Filled by name, present fields only: an absent one stored through the
|
|
718
|
+
// tail's write spelling would allocate the block for nothing. A presence
|
|
719
|
+
// that is a runtime test reads the value first, because a sidecar read
|
|
720
|
+
// is what sets the cell that test inspects.
|
|
721
|
+
const presenceOf = new Map(presences);
|
|
722
|
+
const stores = plan.fields.map(({ field }, index) => {
|
|
723
|
+
const member = `gea_view${targetArrow}${tailAwareFieldWriteText(targetFields, field.key)}`;
|
|
724
|
+
if (field.required)
|
|
725
|
+
return `${member} = ${reads[index]};`;
|
|
726
|
+
const present = presenceOf.get(field.key) ?? 'false';
|
|
727
|
+
if (present === 'false')
|
|
728
|
+
return '';
|
|
729
|
+
const flag = `gea_view${targetArrow}${cppRecordFieldPresenceName(field.key)} = true;`;
|
|
730
|
+
if (present === 'true')
|
|
731
|
+
return `${member} = ${reads[index]}; ${flag}`;
|
|
732
|
+
return `{ auto gea_field = ${reads[index]}; if (${present}) { ${member} = std::move(gea_field); ${flag} } }`;
|
|
733
|
+
});
|
|
734
|
+
if (source.kind === 'record-with-index') {
|
|
735
|
+
const targetIndexes = plan.indexes.map(({ target: targetIndex }) => targetIndex);
|
|
736
|
+
for (const { source: sourceIndex, target: targetIndex } of plan.indexes) {
|
|
737
|
+
const from = `${text}${arrow}`;
|
|
738
|
+
stores.push(`gea_view${targetArrow}${cppRecordIndexSidecarNameFor(targetIndex, targetIndexes)} = ${from}${cppRecordIndexSidecarNameFor(sourceIndex, source.indexes)};`, `gea_view${targetArrow}${cppRecordIndexAttributesNameFor(targetIndex, targetIndexes)} = ${from}${cppRecordIndexAttributesNameFor(sourceIndex, source.indexes)};`);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
const indexSpills = spills.slice(presences.filter(([, present]) => present !== 'false').length);
|
|
742
|
+
const declared = target.ownership === 'shared-refcount' ? `auto gea_view = gea::makeRef<${structName}>();` : `${structName} gea_view{};`;
|
|
743
|
+
const filled = `([&]() { ${declared} ${[...stores, ...indexSpills].filter((line) => line !== '').join(' ')} return gea_view; }())`;
|
|
744
|
+
if (target.ownership !== 'shared-refcount')
|
|
745
|
+
return filled;
|
|
746
|
+
return recordViewFinished(ctx, plan, text, arrow, filled);
|
|
747
|
+
}
|
|
748
|
+
const structure = spilledInto(built);
|
|
370
749
|
if (target.ownership !== 'shared-refcount')
|
|
371
750
|
return structure;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
751
|
+
// Built in the block itself (C++20 parenthesized aggregate initialization)
|
|
752
|
+
// rather than as a stack temporary the block is then move-constructed from
|
|
753
|
+
// and that is destroyed field by field afterwards: 2.4 KB of stack, a
|
|
754
|
+
// 134-field move and a 134-field destructor per view of mongodb's options
|
|
755
|
+
// family. A call's arguments are evaluated in no fixed order, though, so a
|
|
756
|
+
// build with an observable read -- an accessor, a sidecar `[[Get]]` -- keeps
|
|
757
|
+
// the braces, whose [dcl.init.list]/4 order is the property order.
|
|
758
|
+
const allocated = spilledInto(orderSensitive ? `gea::makeRef<${structName}>(${built})` : `gea::makeRef<${structName}>(${reads.join(', ')})`);
|
|
759
|
+
return recordViewFinished(ctx, plan, text, arrow, allocated);
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* What a built view still owes once its block is allocated: the open keys of
|
|
763
|
+
* an indexed source, or the class instance it was viewed from.
|
|
764
|
+
*/
|
|
765
|
+
const recordViewFinished = (ctx, plan, text, arrow, allocated) => {
|
|
766
|
+
const { source, target } = plan;
|
|
767
|
+
if (plan.expando && source.kind === 'record-with-index') {
|
|
768
|
+
// The keys the target names were read into its fields above; the rest of
|
|
769
|
+
// the open document, and any named field the target lacks, stay own
|
|
770
|
+
// properties of the view.
|
|
771
|
+
const named = target.kind === 'record' ? target.fields : (ctx.layouts.forShape(target.shapeId) ?? []);
|
|
772
|
+
const excluded = named.map((field) => cppStringLiteral(field.key)).join(', ');
|
|
773
|
+
const extras = [];
|
|
774
|
+
for (const held of plan.expandoSpilled ?? []) {
|
|
775
|
+
const heldText = tailAwareFieldReadText(source.fields, held.key, `${text}${arrow}`);
|
|
776
|
+
const boxed = alignedValueText(ctx, 'emit-record-view.ts:expando-spill', held.value, { kind: 'dynamic', reason: 'declared-any-never-narrowed' }, heldText);
|
|
777
|
+
if (boxed === null)
|
|
778
|
+
return null;
|
|
779
|
+
const store = `gea::nativeDynamicSet(gea_view, gea::PropertyKey::string(${cppStringLiteral(held.key)}), ${boxed});`;
|
|
780
|
+
extras.push(held.required ? store : `if (${text}${arrow}${cppRecordFieldPresenceName(held.key)}) ${store}`);
|
|
781
|
+
}
|
|
782
|
+
const sidecar = `${text}${arrow}${cppRecordIndexSidecarNameFor(source.indexes[0], source.indexes)}`;
|
|
783
|
+
return (`([&]() { auto gea_view = gea::record::assignDynamicPropertiesExcept(${allocated}, ${sidecar}, {${excluded}}); ` +
|
|
784
|
+
`${extras.join(' ')} return gea_view; }())`);
|
|
785
|
+
}
|
|
375
786
|
// A class instance's view remembers the instance, so `instanceof` and a
|
|
376
787
|
// narrowing back to the class still answer from it
|
|
377
788
|
// (`gea::record::viewOrigin`, `projection/instance-test.ts`).
|
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
import type { IrTerminatorOperation } from '../../ir/model.js';
|
|
2
|
+
import { type Representation } from '../../representation/model.js';
|
|
2
3
|
import type { EmitContext } from './emit-context.js';
|
|
4
|
+
/**
|
|
5
|
+
* What an async coroutine's `return` settles its promise WITH, as statements to
|
|
6
|
+
* run first plus the operand `co_return` takes.
|
|
7
|
+
*
|
|
8
|
+
* `co_return v` hands `v` to the promise's `return_value`, which resolves with a
|
|
9
|
+
* payload and ADOPTS a `gea::Promise` (ECMA-262 27.2.1.3.2: resolving with a
|
|
10
|
+
* thenable follows it). So the reconciliation is against the payload `V`, never
|
|
11
|
+
* against `Promise<V>` the way the plain-function rendering below has to build
|
|
12
|
+
* one -- except where the value already is a promise, whose adoption is exactly
|
|
13
|
+
* what the language asks for. `payload` is `null` for a promise that fulfills
|
|
14
|
+
* with nothing: `co_return;`.
|
|
15
|
+
*
|
|
16
|
+
* `adopts` marks a payload that is itself a promise, which a caller holding the
|
|
17
|
+
* value in a payload-typed slot (`emit-exceptions.ts`'s finally that suspends)
|
|
18
|
+
* cannot store.
|
|
19
|
+
*/
|
|
20
|
+
export interface CoroutineReturn {
|
|
21
|
+
readonly statements: readonly string[];
|
|
22
|
+
readonly payload: string | null;
|
|
23
|
+
readonly adopts: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const coroutineReturnOf: (ctx: EmitContext, terminator: Extract<IrTerminatorOperation, {
|
|
26
|
+
kind: "return";
|
|
27
|
+
}>) => CoroutineReturn;
|
|
28
|
+
/**
|
|
29
|
+
* What a generator body's `return` completes with: the value `co_return`
|
|
30
|
+
* takes (awaited first in an `async function*`), with the completion channel
|
|
31
|
+
* it fills, or `null` for a valueless `return`. Shared by `emitReturn` and by
|
|
32
|
+
* a suspending finally clause (`emit-exceptions.ts`), which parks the value
|
|
33
|
+
* while the clause runs.
|
|
34
|
+
*/
|
|
35
|
+
export declare const generatorCompletionOf: (ctx: EmitContext, terminator: Extract<IrTerminatorOperation, {
|
|
36
|
+
kind: "return";
|
|
37
|
+
}>) => {
|
|
38
|
+
readonly text: string;
|
|
39
|
+
readonly completion: Representation;
|
|
40
|
+
} | null;
|
|
3
41
|
export declare const emitReturn: (ctx: EmitContext, lines: string[], terminator: Extract<IrTerminatorOperation, {
|
|
4
42
|
kind: "return";
|
|
5
43
|
}>) => void;
|