@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,4 +1,4 @@
|
|
|
1
|
-
import { representationKey } from '../representation/model.js';
|
|
1
|
+
import { abiKey, representationKey } from '../representation/model.js';
|
|
2
2
|
import { classMemberOf } from './fields.js';
|
|
3
3
|
/** Exact allocation identities and the method each prototype lookup selects.
|
|
4
4
|
* Selection happens when the property is read, before a later call supplies
|
|
@@ -111,13 +111,41 @@ export const extendsClass = (classes, candidate, ancestor) => {
|
|
|
111
111
|
* upward: a layout names its base and never its derivations, so the derived
|
|
112
112
|
* side exists only as the set of classes whose own chain leads here.
|
|
113
113
|
*/
|
|
114
|
+
// Which classes declare a member at all, by key, in the class map's own
|
|
115
|
+
// iteration order. Every dispatch decision of every emitted body asks about one
|
|
116
|
+
// key, and the answer is nearly always "a handful of classes declare it" -- but
|
|
117
|
+
// the walk above visited the whole class map (and scanned each layout's member
|
|
118
|
+
// lists) to find them. The size guard is the invalidation: a class map only
|
|
119
|
+
// ever grows while it is being built.
|
|
120
|
+
const declarersByKey = new WeakMap();
|
|
121
|
+
const declarersOf = (classes, key) => {
|
|
122
|
+
let held = declarersByKey.get(classes);
|
|
123
|
+
if (!held || held.size !== classes.size) {
|
|
124
|
+
const byKey = new Map();
|
|
125
|
+
for (const [candidate, layout] of classes) {
|
|
126
|
+
const keys = new Set();
|
|
127
|
+
for (const entry of layout.accessors)
|
|
128
|
+
keys.add(entry.key);
|
|
129
|
+
for (const entry of layout.methods)
|
|
130
|
+
keys.add(entry.key);
|
|
131
|
+
for (const member of keys) {
|
|
132
|
+
const declarers = byKey.get(member);
|
|
133
|
+
if (declarers)
|
|
134
|
+
declarers.push(candidate);
|
|
135
|
+
else
|
|
136
|
+
byKey.set(member, [candidate]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
held = { size: classes.size, byKey };
|
|
140
|
+
declarersByKey.set(classes, held);
|
|
141
|
+
}
|
|
142
|
+
return held.byKey.get(key) ?? [];
|
|
143
|
+
};
|
|
114
144
|
export const classFamilyOverridesOf = (classes, declaration, key) => {
|
|
115
145
|
const overriding = [];
|
|
116
|
-
for (const
|
|
146
|
+
for (const candidate of declarersOf(classes, key)) {
|
|
117
147
|
if (candidate === declaration)
|
|
118
148
|
continue;
|
|
119
|
-
if (!layout.accessors.some((entry) => entry.key === key) && !layout.methods.some((entry) => entry.key === key))
|
|
120
|
-
continue;
|
|
121
149
|
if (extendsClass(classes, candidate, declaration))
|
|
122
150
|
overriding.push(candidate);
|
|
123
151
|
}
|
|
@@ -171,20 +199,279 @@ export const virtualMethodFamiliesOf = (classes) => {
|
|
|
171
199
|
record(declaration, accessor.key, 'set', accessor.setter);
|
|
172
200
|
}
|
|
173
201
|
}
|
|
202
|
+
// A data field a class below an accessor's root declares under the same
|
|
203
|
+
// key implements both halves of it for that class's instances.
|
|
204
|
+
const fieldImplementorsOf = (entry) => {
|
|
205
|
+
if (entry.role === 'call')
|
|
206
|
+
return [];
|
|
207
|
+
const found = [];
|
|
208
|
+
for (const [declaration, layout] of classes) {
|
|
209
|
+
if (declaration === entry.root || !extendsClass(classes, declaration, entry.root))
|
|
210
|
+
continue;
|
|
211
|
+
const field = layout.fields.find((candidate) => candidate.key === entry.key && !candidate.syntheticSubclassMemberOverlay);
|
|
212
|
+
if (field !== undefined)
|
|
213
|
+
found.push({ declaration, field });
|
|
214
|
+
}
|
|
215
|
+
return found.sort((left, right) => (left.declaration < right.declaration ? -1 : 1));
|
|
216
|
+
};
|
|
174
217
|
return [...byRoot.values()]
|
|
175
|
-
.
|
|
176
|
-
.filter((entry) => entry.
|
|
177
|
-
.
|
|
218
|
+
.map((entry) => ({ entry, fieldImplementors: fieldImplementorsOf(entry) }))
|
|
219
|
+
.filter(({ entry, fieldImplementors }) => fieldImplementors.length > 0 || entry.implementors.some((implementor) => implementor.declaration !== entry.root))
|
|
220
|
+
.filter(({ entry }) => entry.rootDeclares)
|
|
221
|
+
.map(({ entry, fieldImplementors }) => ({
|
|
178
222
|
key: entry.key,
|
|
179
223
|
role: entry.role,
|
|
180
224
|
root: entry.root,
|
|
181
225
|
abstractRoot: !entry.implementors.some((implementor) => implementor.declaration === entry.root),
|
|
182
|
-
implementors: [...entry.implementors].sort((left, right) => (left.declaration < right.declaration ? -1 : 1))
|
|
226
|
+
implementors: [...entry.implementors].sort((left, right) => (left.declaration < right.declaration ? -1 : 1)),
|
|
227
|
+
...(fieldImplementors.length > 0 ? { fieldImplementors } : {})
|
|
183
228
|
}))
|
|
184
229
|
.sort((left, right) => (`${left.root} ${left.key} ${left.role}` < `${right.root} ${right.key} ${right.role}` ? -1 : 1));
|
|
185
230
|
};
|
|
186
231
|
/** The key a call site looks up: the class it resolved the member ON, plus the member. Moved here from `targets/cpp/virtual-methods.ts` (which still re-exports it) so `ir/call-dispatch.ts` can ask the identical question without importing a target module. */
|
|
187
232
|
export const virtualDispatchKey = (owner, key, role = 'call') => `${owner} ${key} ${role}`;
|
|
233
|
+
/** The convention that tells one copy of a generic method from another: its ABI without the receiver, which is each class's own. */
|
|
234
|
+
export const virtualCopyKeyOf = (abi) => abiKey({ ...abi, receiver: null });
|
|
235
|
+
/** The key a call site reading one COPY of a generic method looks up, beside `virtualDispatchKey`. */
|
|
236
|
+
export const virtualCopyDispatchKey = (owner, key, copy) => `${owner} ${key} call ${copy}`;
|
|
237
|
+
/**
|
|
238
|
+
* The dispatch a method read resolves to: the family of the whole key, else
|
|
239
|
+
* the family of the ONE copy whose convention the read holds.
|
|
240
|
+
*
|
|
241
|
+
* A read's held convention is the checker's view of the call, which can widen
|
|
242
|
+
* the result past the body's -- `doc.get('cursor', 'object')?.get(...)`
|
|
243
|
+
* publishes the optional chain's `undefined` in it. So a copy is taken when its
|
|
244
|
+
* parameters are the read's exactly and its result's arms are the read's, less
|
|
245
|
+
* at most that `undefined`, and only when exactly one copy fits.
|
|
246
|
+
*/
|
|
247
|
+
export const virtualDispatchFor = (dispatched, owner, key, role, held, abiOfEntry) => {
|
|
248
|
+
const whole = dispatched.get(virtualDispatchKey(owner, key, role));
|
|
249
|
+
if (whole !== undefined)
|
|
250
|
+
return { entry: whole };
|
|
251
|
+
if (role !== 'call' || held === null)
|
|
252
|
+
return undefined;
|
|
253
|
+
const exactCopy = virtualCopyKeyOf(held);
|
|
254
|
+
const exact = dispatched.get(virtualCopyDispatchKey(owner, key, exactCopy));
|
|
255
|
+
if (exact !== undefined)
|
|
256
|
+
return { entry: exact, copy: exactCopy };
|
|
257
|
+
const prefix = virtualCopyDispatchKey(owner, key, '');
|
|
258
|
+
const fitting = [];
|
|
259
|
+
for (const [dispatchKey, entry] of dispatched) {
|
|
260
|
+
if (!dispatchKey.startsWith(prefix))
|
|
261
|
+
continue;
|
|
262
|
+
if (conventionFits(abiOfEntry(entry), held))
|
|
263
|
+
fitting.push({ entry, copy: dispatchKey.slice(prefix.length) });
|
|
264
|
+
}
|
|
265
|
+
return fitting.length === 1 ? fitting[0] : undefined;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* The one copy among a class's same-key methods whose convention a read holds
|
|
269
|
+
* -- the rule `virtualDispatchFor` applies to dispatch members, applied to the
|
|
270
|
+
* bodies themselves: an exact receiverless match, else the one copy whose
|
|
271
|
+
* parameters agree and whose result's values the read's result admits.
|
|
272
|
+
* `null` when no copy, or more than one, fits.
|
|
273
|
+
*/
|
|
274
|
+
export const methodCopyHeldBy = (copies, held, abiOf) => {
|
|
275
|
+
const wanted = virtualCopyKeyOf(held);
|
|
276
|
+
const conventions = copies.map((copy) => ({ copy, abi: copy.callable === null ? null : abiOf(copy.callable) }));
|
|
277
|
+
const exact = conventions.find(({ abi }) => abi !== null && virtualCopyKeyOf(abi) === wanted);
|
|
278
|
+
if (exact !== undefined)
|
|
279
|
+
return exact.copy;
|
|
280
|
+
const fitting = conventions.filter(({ abi }) => abi !== null && conventionFits(abi, held));
|
|
281
|
+
return fitting.length === 1 ? fitting[0].copy : null;
|
|
282
|
+
};
|
|
283
|
+
const conventionFits = (body, held) => body.restFrom === held.restFrom &&
|
|
284
|
+
body.parameters.length === held.parameters.length &&
|
|
285
|
+
body.parameters.every((parameter, index) => representationKey(parameter.value) === representationKey(held.parameters[index].value)) &&
|
|
286
|
+
resultArmsFit(body.result, held.result);
|
|
287
|
+
/** The values a result carrier can hold, as the carriers of its arms. */
|
|
288
|
+
const resultArmsOf = (value) => value.kind === 'tagged-union'
|
|
289
|
+
? value.arms.flatMap((arm) => resultArmsOf(arm.value))
|
|
290
|
+
: value.kind === 'optional'
|
|
291
|
+
? [...resultArmsOf(value.payload), { kind: value.absence }]
|
|
292
|
+
: [value];
|
|
293
|
+
// The read may add only the optional chain's `undefined`: any other extra arm
|
|
294
|
+
// could be a different copy's result, and a copy the verdict refused is not in
|
|
295
|
+
// the table to lose a tie against.
|
|
296
|
+
const resultArmsFit = (body, held) => {
|
|
297
|
+
const bodyArms = new Set(resultArmsOf(body).map(representationKey));
|
|
298
|
+
const heldArms = new Set(resultArmsOf(held).map(representationKey));
|
|
299
|
+
const undefinedArm = representationKey({ kind: 'undefined' });
|
|
300
|
+
return [...bodyArms].every((arm) => heldArms.has(arm)) && [...heldArms].every((arm) => bodyArms.has(arm) || arm === undefinedArm);
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* A generic method's family split into one family per copy.
|
|
304
|
+
*
|
|
305
|
+
* `specialization.ts` compiles `get<const T>(name, as: T): JSTypeOf[T]` once
|
|
306
|
+
* per instantiation, and every class in the family publishes its copies under
|
|
307
|
+
* the one key -- mongodb's `OnDemandDocument.get<T>` overridden by
|
|
308
|
+
* `MongoDBResponse.get<T>`, read at `'object'` and at `'timestamp'`. Treated as
|
|
309
|
+
* one family, the `timestamp` copy's `Timestamp | null` result had to convert
|
|
310
|
+
* into the `object` copy's slot, and the whole key was refused. Each copy is
|
|
311
|
+
* its own overridable member: the base's `T = 'object'` body is overridden by
|
|
312
|
+
* the subclass's `T = 'object'` body and by nothing else. So the copies are
|
|
313
|
+
* partitioned by their receiverless convention, and each partition is a
|
|
314
|
+
* family of its own with its own member; a class with two copies of one
|
|
315
|
+
* convention (two instantiations the types erase to the same ABI) contributes
|
|
316
|
+
* its first, as both run the same JavaScript.
|
|
317
|
+
*
|
|
318
|
+
* A family with at most one implementor per class is returned unchanged.
|
|
319
|
+
*/
|
|
320
|
+
const virtualCopyFamiliesOf = (classes, family, abiOf) => {
|
|
321
|
+
if (family.role !== 'call')
|
|
322
|
+
return [family];
|
|
323
|
+
const lineage = classCopyFamiliesOf(classes, family, abiOf);
|
|
324
|
+
if (lineage !== null)
|
|
325
|
+
return lineage;
|
|
326
|
+
const declarations = new Set(family.implementors.map((implementor) => implementor.declaration));
|
|
327
|
+
if (declarations.size === family.implementors.length)
|
|
328
|
+
return [family];
|
|
329
|
+
const partitions = new Map();
|
|
330
|
+
for (const implementor of family.implementors) {
|
|
331
|
+
const abi = abiOf(implementor.callable);
|
|
332
|
+
// A copy with no convention cannot be told apart; keeping the family whole
|
|
333
|
+
// lets the ordinary verdict name it.
|
|
334
|
+
if (abi === null)
|
|
335
|
+
return [family];
|
|
336
|
+
const copy = virtualCopyKeyOf(abi);
|
|
337
|
+
const members = partitions.get(copy) ?? [];
|
|
338
|
+
if (!members.some((member) => member.declaration === implementor.declaration))
|
|
339
|
+
members.push(implementor);
|
|
340
|
+
partitions.set(copy, members);
|
|
341
|
+
}
|
|
342
|
+
return [...partitions]
|
|
343
|
+
.sort(([left], [right]) => (left < right ? -1 : 1))
|
|
344
|
+
.map(([copy, implementors]) => {
|
|
345
|
+
const present = new Set(implementors.map((implementor) => implementor.declaration));
|
|
346
|
+
const absent = [...declarations].filter((declaration) => !present.has(declaration)).sort();
|
|
347
|
+
return { ...family, implementors, copy, ...(absent.length > 0 ? { copyAbsentFrom: absent } : {}) };
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* A family rooted at a GENERIC class split into one family per copy of the
|
|
352
|
+
* root's method that some implementor overrides, by heritage rather than by
|
|
353
|
+
* convention -- or `null` when the root is not a generic's copies, or some
|
|
354
|
+
* implementor's lineage cannot be followed, and `virtualCopyFamiliesOf`
|
|
355
|
+
* partitions by convention as before.
|
|
356
|
+
*
|
|
357
|
+
* `Operation<TResult>.handleOk` is one body per class copy, and `Count extends
|
|
358
|
+
* Command<number>` overrides the `number` copy only: it states `(reply) =>
|
|
359
|
+
* number`, and a `RunCursorCommand` under `RunCommand<Document>` states
|
|
360
|
+
* `(reply) => CursorReply` for the `Document` copy. Taken as one family, every
|
|
361
|
+
* override had to convert into ONE root convention -- a number into a document
|
|
362
|
+
* -- and the whole key was refused (mongodb's `AbstractOperation.handleOk`,
|
|
363
|
+
* `CommandOperation.buildCommandDocument`). An override's convention need not
|
|
364
|
+
* equal its copy's, only convert to it, which the verdict checks as for any
|
|
365
|
+
* family. A copy of the root whose body is dead (`dead-method-copies.ts`) is
|
|
366
|
+
* the family's bodyless root, exactly as an abstract one is; copies whose
|
|
367
|
+
* conventions coincide are one member, as in `virtualCopyFamiliesOf`.
|
|
368
|
+
*/
|
|
369
|
+
const classCopyFamiliesOf = (classes, family, abiOf) => {
|
|
370
|
+
const rootLayout = classes.get(family.root);
|
|
371
|
+
const rootCopies = new Set(rootLayout?.copies ?? []);
|
|
372
|
+
if (rootCopies.size < 2)
|
|
373
|
+
return null;
|
|
374
|
+
const methodOf = (declaration, callable) => classes.get(declaration)?.methods.find((method) => method.key === family.key && method.callable === callable);
|
|
375
|
+
const layoutHolding = (id) => classes.get(id) ?? [...classes.values()].find((layout) => layout.copies?.includes(id) === true);
|
|
376
|
+
// The root copy an implementor's body replaces: its own copy of the class,
|
|
377
|
+
// then each heritage link up to a copy of the root.
|
|
378
|
+
const rootCopyOf = (implementor) => {
|
|
379
|
+
const published = methodOf(implementor.declaration, implementor.callable)?.publishedBy;
|
|
380
|
+
if (implementor.declaration === family.root)
|
|
381
|
+
return published !== undefined && rootCopies.has(published) ? published : null;
|
|
382
|
+
let current = published ?? implementor.declaration;
|
|
383
|
+
for (let depth = 0; depth < 32; depth += 1) {
|
|
384
|
+
const layout = layoutHolding(current);
|
|
385
|
+
if (layout === undefined)
|
|
386
|
+
return null;
|
|
387
|
+
const next = layout.baseCopies?.get(current) ?? layout.base;
|
|
388
|
+
if (next === null)
|
|
389
|
+
return null;
|
|
390
|
+
if (rootCopies.has(next))
|
|
391
|
+
return next;
|
|
392
|
+
if (next === family.root)
|
|
393
|
+
return null;
|
|
394
|
+
current = next;
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
};
|
|
398
|
+
const byCopy = new Map();
|
|
399
|
+
for (const implementor of family.implementors) {
|
|
400
|
+
const copy = rootCopyOf(implementor);
|
|
401
|
+
if (copy === null)
|
|
402
|
+
return null;
|
|
403
|
+
const members = byCopy.get(copy) ?? [];
|
|
404
|
+
members.push(implementor);
|
|
405
|
+
byCopy.set(copy, members);
|
|
406
|
+
}
|
|
407
|
+
if (byCopy.size < 2)
|
|
408
|
+
return null;
|
|
409
|
+
// One member per convention: the root copy's own body states it, else the
|
|
410
|
+
// widest override (the rule `virtualDispatchVerdictOf` borrows by).
|
|
411
|
+
const byConvention = new Map();
|
|
412
|
+
const statedBy = new Map();
|
|
413
|
+
for (const implementors of byCopy.values()) {
|
|
414
|
+
const own = implementors.find((implementor) => implementor.declaration === family.root);
|
|
415
|
+
const stating = own ??
|
|
416
|
+
implementors.reduce((widest, implementor) => (abiOf(implementor.callable)?.parameters.length ?? -1) > (abiOf(widest.callable)?.parameters.length ?? -1) ? implementor : widest);
|
|
417
|
+
const abi = abiOf(stating.callable);
|
|
418
|
+
if (abi === null)
|
|
419
|
+
return null;
|
|
420
|
+
const convention = virtualCopyKeyOf(abi);
|
|
421
|
+
const members = byConvention.get(convention) ?? [];
|
|
422
|
+
for (const implementor of implementors)
|
|
423
|
+
if (!members.some((member) => member.declaration === implementor.declaration))
|
|
424
|
+
members.push(implementor);
|
|
425
|
+
byConvention.set(convention, members);
|
|
426
|
+
const previous = statedBy.get(convention);
|
|
427
|
+
statedBy.set(convention, { abi, borrowed: own === undefined && (previous?.borrowed ?? true) });
|
|
428
|
+
}
|
|
429
|
+
// A bodyless root copy whose every override leaves out trailing parameters
|
|
430
|
+
// (mongodb's `FindOperation.buildCommandDocument()` against the abstract
|
|
431
|
+
// `(connection, session?)`) borrowed a convention NO call site holds: a
|
|
432
|
+
// read's held convention is the checker's signature of the DECLARATION, so
|
|
433
|
+
// `this.buildCommandDocument(connection, session)` looks up the wider one --
|
|
434
|
+
// the sibling copy's, with the same result -- and dispatched every override
|
|
435
|
+
// of the narrow copy to that copy's abstract stub. Such a borrowed
|
|
436
|
+
// convention is folded into the one wider convention it is a parameter
|
|
437
|
+
// prefix of with the same result: the members of both copies are then one
|
|
438
|
+
// slot, and an override with fewer parameters ignores the rest, as the
|
|
439
|
+
// language does (the adapter passes only the formals it declares).
|
|
440
|
+
// `narrow` is a parameter prefix of `wide`, with the same rest and result.
|
|
441
|
+
const extendsConvention = (narrow, wide) => wide.restFrom === narrow.restFrom &&
|
|
442
|
+
wide.parameters.length > narrow.parameters.length &&
|
|
443
|
+
narrow.parameters.every((parameter, index) => representationKey(parameter.value) === representationKey(wide.parameters[index].value)) &&
|
|
444
|
+
representationKey(wide.result) === representationKey(narrow.result);
|
|
445
|
+
// Narrowest first, so a chain of borrowed prefixes folds into its widest
|
|
446
|
+
// end; the widest candidate is taken only when every other candidate is
|
|
447
|
+
// itself a prefix of it (one declaration, not two diverging ones).
|
|
448
|
+
const byWidth = [...statedBy].sort(([, left], [, right]) => left.abi.parameters.length - right.abi.parameters.length);
|
|
449
|
+
for (const [convention, stated] of byWidth) {
|
|
450
|
+
if (!stated.borrowed || !statedBy.has(convention))
|
|
451
|
+
continue;
|
|
452
|
+
const wider = [...statedBy].filter(([other, candidate]) => other !== convention && extendsConvention(stated.abi, candidate.abi));
|
|
453
|
+
if (wider.length === 0)
|
|
454
|
+
continue;
|
|
455
|
+
const widest = wider.reduce((best, entry) => (entry[1].abi.parameters.length > best[1].abi.parameters.length ? entry : best));
|
|
456
|
+
if (!wider.every((entry) => entry === widest || extendsConvention(entry[1].abi, widest[1].abi)))
|
|
457
|
+
continue;
|
|
458
|
+
const [target] = widest;
|
|
459
|
+
const members = byConvention.get(target);
|
|
460
|
+
for (const implementor of byConvention.get(convention) ?? [])
|
|
461
|
+
if (!members.some((member) => member.declaration === implementor.declaration))
|
|
462
|
+
members.push(implementor);
|
|
463
|
+
byConvention.delete(convention);
|
|
464
|
+
statedBy.delete(convention);
|
|
465
|
+
}
|
|
466
|
+
return [...byConvention]
|
|
467
|
+
.sort(([left], [right]) => (left < right ? -1 : 1))
|
|
468
|
+
.map(([copy, implementors]) => ({
|
|
469
|
+
...family,
|
|
470
|
+
implementors,
|
|
471
|
+
copy,
|
|
472
|
+
abstractRoot: !implementors.some((implementor) => implementor.declaration === family.root)
|
|
473
|
+
}));
|
|
474
|
+
};
|
|
188
475
|
/**
|
|
189
476
|
* Whether `source`'s class-ref carrier can reach `target`'s -- an upcast to
|
|
190
477
|
* an ancestor (or itself), or a runtime-checked downcast to a descendant
|
|
@@ -244,6 +531,33 @@ const virtualValueUsesNoFields = (classes, conversions, source, target) => {
|
|
|
244
531
|
((capability.kind === 'atom' || capability.kind === 'static' || capability.kind === 'class-family') &&
|
|
245
532
|
capability.materializer.nativeFieldProtocol === 'unused'));
|
|
246
533
|
};
|
|
534
|
+
/**
|
|
535
|
+
* The nearest class every implementor's `class-ref` result upcasts to, as that
|
|
536
|
+
* class's own instance carrier -- or `null` when some result is not a
|
|
537
|
+
* shared class-ref, or the results share no ancestor in the program.
|
|
538
|
+
*/
|
|
539
|
+
const joinedClassResultOf = (classes, implementors, abiOf) => {
|
|
540
|
+
const declarations = [];
|
|
541
|
+
for (const implementor of implementors) {
|
|
542
|
+
const result = abiOf(implementor.callable)?.result;
|
|
543
|
+
if (result === undefined || result.kind !== 'class-ref' || result.ownership !== 'shared-refcount')
|
|
544
|
+
return null;
|
|
545
|
+
declarations.push(result.declaration);
|
|
546
|
+
}
|
|
547
|
+
const [first, ...rest] = declarations;
|
|
548
|
+
if (first === undefined)
|
|
549
|
+
return null;
|
|
550
|
+
const walked = new Set();
|
|
551
|
+
for (let candidate = first; candidate !== null && !walked.has(candidate); candidate = classes.get(candidate)?.base ?? null) {
|
|
552
|
+
walked.add(candidate);
|
|
553
|
+
const joined = candidate;
|
|
554
|
+
if (!rest.every((declaration) => declaration === joined || extendsClass(classes, declaration, joined)))
|
|
555
|
+
continue;
|
|
556
|
+
const instance = classes.get(joined)?.instance ?? null;
|
|
557
|
+
return instance !== null && instance.kind === 'class-ref' && instance.ownership === 'shared-refcount' ? instance : null;
|
|
558
|
+
}
|
|
559
|
+
return null;
|
|
560
|
+
};
|
|
247
561
|
/**
|
|
248
562
|
* The dispatchability verdict for every override family: whether it can be
|
|
249
563
|
* dispatched through a C++ virtual member at all, and the exact convention
|
|
@@ -266,7 +580,7 @@ const virtualValueUsesNoFields = (classes, conversions, source, target) => {
|
|
|
266
580
|
export const virtualDispatchVerdictOf = (classes, abiOf, capturesNothing, conversions) => {
|
|
267
581
|
const families = [];
|
|
268
582
|
const refused = [];
|
|
269
|
-
for (const family of virtualMethodFamiliesOf(classes)) {
|
|
583
|
+
for (const family of virtualMethodFamiliesOf(classes).flatMap((whole) => virtualCopyFamiliesOf(classes, whole, abiOf))) {
|
|
270
584
|
const rootImplementor = family.implementors.find((implementor) => implementor.declaration === family.root);
|
|
271
585
|
// An ABSTRACT root has no body, and therefore no ABI of its own to state
|
|
272
586
|
// the slot's convention with. Every override is checked against the same
|
|
@@ -274,15 +588,43 @@ export const virtualDispatchVerdictOf = (classes, abiOf, capturesNothing, conver
|
|
|
274
588
|
// taking the first in the family's own deterministic order keeps the
|
|
275
589
|
// choice reproducible; the per-implementor loop below still proves every
|
|
276
590
|
// other implementor converts to it rather than assuming they agree.
|
|
277
|
-
|
|
591
|
+
//
|
|
592
|
+
// The WIDEST implementor, though: an override may leave out trailing
|
|
593
|
+
// parameters it does not read (mongodb's `AggregateOperation`
|
|
594
|
+
// `buildCommandDocument()` against the abstract `(connection, session?)`),
|
|
595
|
+
// and borrowing that one's empty list made every sibling that does read
|
|
596
|
+
// `connection` look like it was called without it. An implementor with
|
|
597
|
+
// fewer parameters simply ignores the rest, as the language does.
|
|
598
|
+
const borrowed = family.implementors
|
|
599
|
+
.map((implementor) => abiOf(implementor.callable))
|
|
600
|
+
.reduce((widest, abi) => (abi !== null && (widest === null || abi.parameters.length > widest.parameters.length) ? abi : widest), null) ?? null;
|
|
278
601
|
// The borrowed convention states the PARAMETERS and RESULT of the slot,
|
|
279
602
|
// never its receiver: an implementor's receiver is its own concrete class,
|
|
280
603
|
// and a call site converting `Ref<Rule>` to it downcast every element of
|
|
281
604
|
// `Rule[]` to whichever subclass happened to be borrowed. The slot's
|
|
282
605
|
// receiver is the root's.
|
|
283
606
|
const rootInstance = classes.get(family.root)?.instance ?? null;
|
|
284
|
-
|
|
607
|
+
// Nor its result, when that is a class the borrowed implementor narrowed to
|
|
608
|
+
// itself: `abstract addToOperationsList(...): this` (mongodb's bulk writers)
|
|
609
|
+
// and `abstract refreshed(): TimeoutContext` both come back from each
|
|
610
|
+
// override as the override's OWN class, so borrowing one sibling's result
|
|
611
|
+
// made every other sibling's "convert" to it a cast between unrelated
|
|
612
|
+
// classes, and the whole family was refused. The slot answers the classes'
|
|
613
|
+
// join -- every implementor's result upcasts to it.
|
|
614
|
+
const borrowedResult = borrowed === null ? null : joinedClassResultOf(classes, family.implementors, abiOf);
|
|
615
|
+
const inheritedAbi = borrowed === null || rootInstance === null
|
|
616
|
+
? null
|
|
617
|
+
: { ...borrowed, receiver: rootInstance, ...(borrowedResult ? { result: borrowedResult } : {}) };
|
|
285
618
|
const rootAbi = (rootImplementor ? abiOf(rootImplementor.callable) : null) ?? (family.abstractRoot ? inheritedAbi : null);
|
|
619
|
+
if (family.copyAbsentFrom !== undefined) {
|
|
620
|
+
refused.push({
|
|
621
|
+
key: family.key,
|
|
622
|
+
role: family.role,
|
|
623
|
+
owner: family.root,
|
|
624
|
+
reason: `the copy of this generic method at ${family.copy} has no body in ${family.copyAbsentFrom.join(', ')}, which redeclare it`
|
|
625
|
+
});
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
286
628
|
const capturing = family.implementors.filter((implementor) => !capturesNothing(implementor.callable));
|
|
287
629
|
if (rootAbi === null || capturing.length > 0) {
|
|
288
630
|
refused.push({
|
|
@@ -297,6 +639,13 @@ export const virtualDispatchVerdictOf = (classes, abiOf, capturesNothing, conver
|
|
|
297
639
|
}
|
|
298
640
|
let incompatible = null;
|
|
299
641
|
let nativeFieldProtocolUnused = true;
|
|
642
|
+
const protocolBoundaries = [];
|
|
643
|
+
const observeProtocol = (source, target) => {
|
|
644
|
+
if (virtualValueUsesNoFields(classes, conversions, source, target))
|
|
645
|
+
return;
|
|
646
|
+
nativeFieldProtocolUnused = false;
|
|
647
|
+
protocolBoundaries.push({ source, target });
|
|
648
|
+
};
|
|
300
649
|
for (const implementor of family.implementors) {
|
|
301
650
|
const actualAbi = abiOf(implementor.callable);
|
|
302
651
|
if (actualAbi === null) {
|
|
@@ -322,12 +671,12 @@ export const virtualDispatchVerdictOf = (classes, abiOf, capturesNothing, conver
|
|
|
322
671
|
incompatible = `implementation ${implementor.declaration}'s receiver cannot be converted to "${representationKey(actualAbi.receiver)}"`;
|
|
323
672
|
break;
|
|
324
673
|
}
|
|
325
|
-
|
|
674
|
+
observeProtocol(instance, actualAbi.receiver);
|
|
326
675
|
let parameterIncompatible = null;
|
|
327
676
|
for (const [position, parameter] of actualAbi.parameters.entries()) {
|
|
328
677
|
const source = rootAbi.parameters[position];
|
|
329
678
|
if (source !== undefined) {
|
|
330
|
-
|
|
679
|
+
observeProtocol(source.value, parameter.value);
|
|
331
680
|
if (!virtualValueConvertible(classes, conversions, source.value, parameter.value)) {
|
|
332
681
|
parameterIncompatible =
|
|
333
682
|
`implementation ${implementor.declaration}'s parameter ${position} expects "${representationKey(parameter.value)}", while the ` +
|
|
@@ -353,7 +702,25 @@ export const virtualDispatchVerdictOf = (classes, abiOf, capturesNothing, conver
|
|
|
353
702
|
`returns "${representationKey(rootAbi.result)}"`;
|
|
354
703
|
break;
|
|
355
704
|
}
|
|
356
|
-
|
|
705
|
+
observeProtocol(actualAbi.result, rootAbi.result);
|
|
706
|
+
}
|
|
707
|
+
for (const { declaration, field } of incompatible === null ? (family.fieldImplementors ?? []) : []) {
|
|
708
|
+
const stored = field.representation;
|
|
709
|
+
const written = rootAbi.parameters[0]?.value;
|
|
710
|
+
if (stored === null)
|
|
711
|
+
incompatible = `field implementation ${declaration}.${family.key} publishes no carrier`;
|
|
712
|
+
else if (family.role === 'get') {
|
|
713
|
+
if (!virtualValueConvertible(classes, conversions, stored, rootAbi.result))
|
|
714
|
+
incompatible = `field implementation ${declaration}.${family.key} holds "${representationKey(stored)}", while the family returns "${representationKey(rootAbi.result)}"`;
|
|
715
|
+
else
|
|
716
|
+
observeProtocol(stored, rootAbi.result);
|
|
717
|
+
}
|
|
718
|
+
else if (written === undefined || !virtualValueConvertible(classes, conversions, written, stored))
|
|
719
|
+
incompatible = `field implementation ${declaration}.${family.key} holds "${representationKey(stored)}", which the family's written value cannot convert to`;
|
|
720
|
+
else
|
|
721
|
+
observeProtocol(written, stored);
|
|
722
|
+
if (incompatible !== null)
|
|
723
|
+
break;
|
|
357
724
|
}
|
|
358
725
|
if (incompatible !== null) {
|
|
359
726
|
refused.push({
|
|
@@ -364,15 +731,20 @@ export const virtualDispatchVerdictOf = (classes, abiOf, capturesNothing, conver
|
|
|
364
731
|
});
|
|
365
732
|
continue;
|
|
366
733
|
}
|
|
367
|
-
families.push({
|
|
734
|
+
families.push({
|
|
735
|
+
family,
|
|
736
|
+
rootAbi,
|
|
737
|
+
...(nativeFieldProtocolUnused ? { nativeFieldProtocol: 'unused' } : { protocolBoundaries })
|
|
738
|
+
});
|
|
368
739
|
}
|
|
369
740
|
const dispatched = new Map();
|
|
370
741
|
for (const verdict of families) {
|
|
371
|
-
|
|
742
|
+
const { root, key, role, copy } = verdict.family;
|
|
743
|
+
const keyOf = (owner) => copy === undefined ? virtualDispatchKey(owner, key, role) : virtualCopyDispatchKey(owner, key, copy);
|
|
744
|
+
dispatched.set(keyOf(root), verdict);
|
|
372
745
|
for (const [declaration] of classes) {
|
|
373
|
-
if (extendsClass(classes, declaration,
|
|
374
|
-
dispatched.set(
|
|
375
|
-
}
|
|
746
|
+
if (extendsClass(classes, declaration, root))
|
|
747
|
+
dispatched.set(keyOf(declaration), verdict);
|
|
376
748
|
}
|
|
377
749
|
}
|
|
378
750
|
return { families, refused, dispatched };
|
|
@@ -28,7 +28,7 @@ export declare const recordIndexesOfShape: (deriver: RepresentationDeriver, shap
|
|
|
28
28
|
* printer's own context. Two constructions of this were two chances to
|
|
29
29
|
* answer "what does this shape hold" differently.
|
|
30
30
|
*/
|
|
31
|
-
export declare const recordLayoutPolicyOf: (deriver: RepresentationDeriver, classes: ReadonlyMap<DeclarationId, ClassLayout>) => RecordLayoutPolicy;
|
|
31
|
+
export declare const recordLayoutPolicyOf: (deriver: RepresentationDeriver, classes: ReadonlyMap<DeclarationId, ClassLayout>, wellKnownSymbols?: ReadonlyMap<DeclarationId, string>) => RecordLayoutPolicy;
|
|
32
32
|
/** A shape's own field list, or `null` when it carries no record layout. */
|
|
33
33
|
export declare const recordFieldsOfShape: (deriver: RepresentationDeriver, shapeId: string) => readonly RecordField[] | null;
|
|
34
34
|
/**
|
|
@@ -97,9 +97,10 @@ export type ClassMemberSite = {
|
|
|
97
97
|
* convert its callback into that body's parameter slot. The site knows which
|
|
98
98
|
* one it means -- its callee read carries that copy's own convention -- so it
|
|
99
99
|
* says so here, and a site with no opinion keeps getting the first exactly as
|
|
100
|
-
* before.
|
|
100
|
+
* before. The answer is a RANK: an exact convention outranks one the site's
|
|
101
|
+
* values merely convert into (`call-dispatch.ts`'s `methodCopyPreferenceOf`).
|
|
101
102
|
*/
|
|
102
|
-
export type ClassMethodPreference = (method: ClassMethod) =>
|
|
103
|
+
export type ClassMethodPreference = (method: ClassMethod) => number;
|
|
103
104
|
/** Which instance member a key names on a class, walking its bases; `null` when none declares it. */
|
|
104
105
|
export declare const classMemberOf: (classes: ReadonlyMap<DeclarationId, ClassLayout>, declaration: DeclarationId, key: string, prefer?: ClassMethodPreference) => ClassMemberSite | null;
|
|
105
106
|
/** The one physical slot shared by own shadows of an inherited method. */
|