@geastack/compiler 1.0.20 → 1.0.22
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 +120 -29
- package/dist/conversion/algebra.d.ts +16 -1
- package/dist/conversion/algebra.js +2 -0
- package/dist/conversion/build.d.ts +12 -0
- package/dist/conversion/build.js +31 -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.d.ts +3 -1
- package/dist/ir/callable-class-flow.js +42 -6
- 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/certificate.js +87 -16
- package/dist/ir/certify/carrier-keys.d.ts +58 -1
- package/dist/ir/certify/carrier-keys.js +160 -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 +189 -29
- 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 +198 -3
- package/dist/ir/queries.js +35 -1
- package/dist/ir/reflection-demand.d.ts +9 -4
- package/dist/ir/reflection-demand.js +410 -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 +184 -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 +36 -0
- package/dist/semantics/class-alias.js +64 -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 +212 -26
- 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 +372 -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 +35 -5
- package/dist/semantics/normalize/commonjs-require.js +464 -147
- 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/host-mutation-key-reader.js +35 -10
- package/dist/semantics/normalize/identities.js +64 -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 +26 -2
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
- package/dist/semantics/normalize/omitted-stated-parameter.js +34 -4
- 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 +827 -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 +1437 -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 +179 -26
- package/dist/semantics/shared-declaration-files.d.ts +44 -0
- package/dist/semantics/shared-declaration-files.js +42 -0
- package/dist/semantics/stable-checker.d.ts +1 -1
- package/dist/semantics/stable-checker.js +7 -2
- package/dist/semantics/subclass-member-overlay-transform.js +95 -53
- 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 +568 -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 +391 -49
- 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 +117 -9
- 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 +1328 -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 +14 -13
- 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 +18159 -4887
- 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,13 @@
|
|
|
1
1
|
import { instantiatedParameterTypes } from '../semantics/model/selected-signature.js';
|
|
2
2
|
import { genericFunctionSetMembersOf, runtimeSymbolMemberIndexOf } from '../semantics/model/structural-types.js';
|
|
3
|
-
import { carriableIndexesOf, dictionaryIndexOf, isDataOnlyObjectShape, recordAccessorsOf, recordFieldKeyOf } from './object-shape.js';
|
|
3
|
+
import { carriableIndexesOf, dictionaryIndexOf, isDataOnlyObjectShape, physicalIndexesOf, recordAccessorsOf, recordFieldKeyOf } from './object-shape.js';
|
|
4
4
|
import { abiKey, passingOf, representationKey } from './model.js';
|
|
5
5
|
import { createIntersectionFlattener, intersectPropertyRepresentations, intersectionMemberKindOf, isPrimitiveValueShape } from './intersection.js';
|
|
6
|
-
import { widestSubsumingAbi } from './host-abi.js';
|
|
6
|
+
import { callbackOverloadJoinedAbi, widestSubsumingAbi } from './host-abi.js';
|
|
7
7
|
import { primitiveCarrier, storedCarrier, unresolved } from './primitives.js';
|
|
8
8
|
import { createUnionDeriver } from './union.js';
|
|
9
9
|
import { deriveKeyedCollection } from './collections.js';
|
|
10
|
+
import { withStaticFieldAbsence } from './static-field-cells.js';
|
|
10
11
|
import { defaultClassCopyPolicy, defaultDateDeclarationPolicy, defaultHostBindingPolicy, defaultHostNamespaceRootPolicy, defaultKeyedCollectionPolicy, defaultOwnershipPolicy, defaultPromiseDeclarationPolicy, defaultGeneratorDeclarationPolicy, defaultRegExpDeclarationPolicy, defaultStandardBufferPolicy, defaultStringObjectDeclarationPolicy, defaultErrorDeclarationPolicy, defaultFunctionDeclarationPolicy, defaultClassHeritagePolicy, defaultInterfaceImplementorPolicy, defaultTypedArrayElementPolicy, defaultValueRecordPolicy } from './policies.js';
|
|
11
12
|
export { defaultClassCopyPolicy, defaultDateDeclarationPolicy, defaultHostBindingPolicy, defaultHostNamespaceRootPolicy, defaultKeyedCollectionPolicy, defaultOwnershipPolicy, defaultPromiseDeclarationPolicy, defaultGeneratorDeclarationPolicy, defaultRegExpDeclarationPolicy, defaultStandardBufferPolicy, defaultStringObjectDeclarationPolicy, defaultErrorDeclarationPolicy, defaultFunctionDeclarationPolicy, defaultClassHeritagePolicy, defaultInterfaceImplementorPolicy, defaultTypedArrayElementPolicy, defaultValueRecordPolicy };
|
|
12
13
|
/**
|
|
@@ -85,7 +86,10 @@ export const selectedHostConstructFrameOf = (deriver, signature, received, resul
|
|
|
85
86
|
return null;
|
|
86
87
|
return { ...abi, result };
|
|
87
88
|
};
|
|
88
|
-
export const createRepresentationDeriver = (types, ownership = defaultOwnershipPolicy, binding = defaultHostBindingPolicy, elements = defaultTypedArrayElementPolicy, promise = defaultPromiseDeclarationPolicy, collections = defaultKeyedCollectionPolicy, buffers = defaultStandardBufferPolicy, namespaceRoots = defaultHostNamespaceRootPolicy, date = defaultDateDeclarationPolicy, generator = defaultGeneratorDeclarationPolicy, regexp = defaultRegExpDeclarationPolicy, stringObject = defaultStringObjectDeclarationPolicy, functionType = defaultFunctionDeclarationPolicy, heritage = defaultClassHeritagePolicy, valueRecords = defaultValueRecordPolicy, implementors = defaultInterfaceImplementorPolicy, errors = defaultErrorDeclarationPolicy, dynamicFallback = false, dynamicFallbackTypes = new Set(), dynamicCallableShapes = new Map(), dynamicWrittenTypes = new Set(), classCopies = defaultClassCopyPolicy
|
|
89
|
+
export const createRepresentationDeriver = (types, ownership = defaultOwnershipPolicy, binding = defaultHostBindingPolicy, elements = defaultTypedArrayElementPolicy, promise = defaultPromiseDeclarationPolicy, collections = defaultKeyedCollectionPolicy, buffers = defaultStandardBufferPolicy, namespaceRoots = defaultHostNamespaceRootPolicy, date = defaultDateDeclarationPolicy, generator = defaultGeneratorDeclarationPolicy, regexp = defaultRegExpDeclarationPolicy, stringObject = defaultStringObjectDeclarationPolicy, functionType = defaultFunctionDeclarationPolicy, heritage = defaultClassHeritagePolicy, valueRecords = defaultValueRecordPolicy, implementors = defaultInterfaceImplementorPolicy, errors = defaultErrorDeclarationPolicy, dynamicFallback = false, dynamicFallbackTypes = new Set(), dynamicCallableShapes = new Map(), dynamicWrittenTypes = new Set(), classCopies = defaultClassCopyPolicy,
|
|
90
|
+
// The required members some object of a record type is created without
|
|
91
|
+
// (`unwritten-record-members.ts`), by the record's object shape.
|
|
92
|
+
unwrittenMembers = new Map()) => {
|
|
89
93
|
const memo = new Map();
|
|
90
94
|
// Every C++ spelling this deriver stamped on a Date's carrier, so `isDateCarrier` can read the fact back off a carrier.
|
|
91
95
|
const dateNatives = new Set();
|
|
@@ -199,6 +203,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
199
203
|
const outer = shapeOf(id);
|
|
200
204
|
if (!outer)
|
|
201
205
|
return null;
|
|
206
|
+
// A declared keyed collection is that collection whatever its body: the
|
|
207
|
+
// lib `Map` interface carries its members as an object body, and the
|
|
208
|
+
// declared branch below derives `keyed-collection` without looking at
|
|
209
|
+
// it. Reading the body first answered "an object, not a container" for
|
|
210
|
+
// `type Tree = Map<string, Tree>`, whose argument anchors on the `Map`
|
|
211
|
+
// itself, so the back edge never closed and the third level fell to a
|
|
212
|
+
// record of `Map`'s own members.
|
|
213
|
+
if (outer.kind === 'declared' && collections.forDeclaration(outer.declaration)) {
|
|
214
|
+
return { kind: 'keyed-collection', shape: outer, bodyId: id, ownershipShape: outer, ownershipId: id };
|
|
215
|
+
}
|
|
202
216
|
const body = outer.kind === 'declared' && outer.body !== null ? shapeOf(outer.body) : null;
|
|
203
217
|
const source = body ?? outer;
|
|
204
218
|
const sourceId = body === null ? id : outer.body;
|
|
@@ -566,7 +580,11 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
566
580
|
const parameterOwnership = ownership.forParameter(value);
|
|
567
581
|
parameters.push({ value, ownership: parameterOwnership, passing: passingOf(value, parameterOwnership) });
|
|
568
582
|
}
|
|
569
|
-
const declaredReceiver = signature.thisParameter
|
|
583
|
+
const declaredReceiver = signature.thisParameter
|
|
584
|
+
? signature.implicitReceiver
|
|
585
|
+
? exactClassInstanceOf(signature.thisParameter)
|
|
586
|
+
: derive(signature.thisParameter)
|
|
587
|
+
: null;
|
|
570
588
|
return {
|
|
571
589
|
parameters,
|
|
572
590
|
restFrom,
|
|
@@ -704,6 +722,9 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
704
722
|
const unionJoined = joinsByUnion ? unionJoinedAbi(signatures) : null;
|
|
705
723
|
if (unionJoined)
|
|
706
724
|
return unionJoined;
|
|
725
|
+
const callbackJoined = joinsByUnion ? callbackOverloadJoinedAbi(abis) : null;
|
|
726
|
+
if (callbackJoined)
|
|
727
|
+
return callbackJoined;
|
|
707
728
|
return role === 'construct'
|
|
708
729
|
? `no primitive joining ${signatures.length} construct signatures into one calling convention: ${widened}`
|
|
709
730
|
: `no primitive joining ${signatures.length} overload signatures into one calling convention: ${widened}`;
|
|
@@ -724,9 +745,21 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
724
745
|
// An accessor-backed member has no storage, so it contributes no field. Both
|
|
725
746
|
// halves read the same member list so the two can never disagree about which
|
|
726
747
|
// members are laid out and which are called.
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
748
|
+
// A required member some object of this record is created without is laid
|
|
749
|
+
// out as an optional one: a presence bit that starts absent and a carrier
|
|
750
|
+
// that holds the `undefined` a read of it yields (`unwritten-record-members.ts`).
|
|
751
|
+
const isRecordFieldMember = (shape, member) => member.accessor === null && runtimeSymbolMemberIndexOf(shape, member.key) === null;
|
|
752
|
+
const recordFieldsOf = (shape, id = null) => {
|
|
753
|
+
const unwritten = id === null ? undefined : unwrittenMembers.get(id);
|
|
754
|
+
return shape.members
|
|
755
|
+
.filter((member) => isRecordFieldMember(shape, member))
|
|
756
|
+
.map((member) => {
|
|
757
|
+
const key = recordFieldKeyOf(member.key);
|
|
758
|
+
return !member.optional && unwritten?.has(key)
|
|
759
|
+
? { key, value: withStaticFieldAbsence(deriveStored(member.type)), required: false }
|
|
760
|
+
: { key, value: deriveStored(member.type), required: !member.optional };
|
|
761
|
+
});
|
|
762
|
+
};
|
|
730
763
|
/**
|
|
731
764
|
* Derive and canonicalize the disjoint physical key domains of a record.
|
|
732
765
|
* Number property keys alias their canonical string form in JavaScript, so a
|
|
@@ -786,7 +819,73 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
786
819
|
}
|
|
787
820
|
return fields;
|
|
788
821
|
};
|
|
822
|
+
/**
|
|
823
|
+
* Whether a member's type is a callable and can be nothing else, read off
|
|
824
|
+
* shapes alone so a self-referential interface does not recurse.
|
|
825
|
+
*
|
|
826
|
+
* A union of a callable and a plain arm (`$where?: string | ((this: T) =>
|
|
827
|
+
* boolean)`) is not one: the member holds an `any` slot's value either way,
|
|
828
|
+
* and nothing about it needs a call convention until a program narrows it to
|
|
829
|
+
* the function. An intersection is callable exactly when one of its members
|
|
830
|
+
* is. `undefined`/`null` arms are absence, not a second kind of value.
|
|
831
|
+
*/
|
|
832
|
+
const mustBeCallable = (type, depth = 0) => {
|
|
833
|
+
const shape = shapeOf(type);
|
|
834
|
+
if (shape === null || depth > 8)
|
|
835
|
+
return true;
|
|
836
|
+
if (shape.kind === 'signature' || shape.kind === 'class-constructor')
|
|
837
|
+
return true;
|
|
838
|
+
if (shape.kind === 'intersection')
|
|
839
|
+
return shape.members.some((member) => mustBeCallable(member, depth + 1));
|
|
840
|
+
if (shape.kind === 'union') {
|
|
841
|
+
const present = shape.members.filter((member) => {
|
|
842
|
+
const arm = shapeOf(member);
|
|
843
|
+
return !(arm?.kind === 'primitive' && (arm.primitive === 'undefined' || arm.primitive === 'null' || arm.primitive === 'void'));
|
|
844
|
+
});
|
|
845
|
+
return present.length > 0 && present.every((member) => mustBeCallable(member, depth + 1));
|
|
846
|
+
}
|
|
847
|
+
if (shape.kind === 'declared')
|
|
848
|
+
return shape.body !== null && shapeOf(shape.body)?.kind === 'signature';
|
|
849
|
+
return false;
|
|
850
|
+
};
|
|
851
|
+
/**
|
|
852
|
+
* `interface ErrorDescription extends Document { message?: string; ... }`:
|
|
853
|
+
* an open `{ [key: string]: any }` document that also names some OPTIONAL
|
|
854
|
+
* data keys is still exactly that open document. Every value it can hold,
|
|
855
|
+
* named or not, is one an `any` slot takes, and nothing it states can be
|
|
856
|
+
* missing, so a plain object, a class instance or an Error all satisfy it
|
|
857
|
+
* by identity -- which a sidecar record could not: mongodb's
|
|
858
|
+
* `MongoServerError(message: ErrorDescription)` keeps the object it was
|
|
859
|
+
* given (`this.errorResponse = message`). A read of a named key is the
|
|
860
|
+
* document's checked dynamic read into the key's own carrier. A required
|
|
861
|
+
* key, a symbol key, an accessor or a member that can only be a callable is
|
|
862
|
+
* layout the document cannot state, and keeps the record carrier. A member
|
|
863
|
+
* that MAY be a callable (mongodb's `$where?: string | ((this: T) =>
|
|
864
|
+
* boolean)`) does not: it is an `any` slot's value like any other key, and
|
|
865
|
+
* keeping the record for it made every `Filter<T>` literal a record the
|
|
866
|
+
* driver then had to view as the `Document` it forwards it as.
|
|
867
|
+
*/
|
|
868
|
+
const isOpenDocumentShape = (shape) => {
|
|
869
|
+
if (shape.membersDropped || shape.members.length === 0)
|
|
870
|
+
return false;
|
|
871
|
+
const indexes = physicalIndexesOf(shape);
|
|
872
|
+
const [only] = indexes;
|
|
873
|
+
if (indexes.length !== 1 || only === undefined || only.key !== 'string')
|
|
874
|
+
return false;
|
|
875
|
+
const value = deriveStored(only.value);
|
|
876
|
+
if (value.kind !== 'dynamic' || value.reason !== 'declared-any-never-narrowed')
|
|
877
|
+
return false;
|
|
878
|
+
return shape.members.every((member) => member.optional && member.accessor === null && member.key.kind !== 'symbol' && !mustBeCallable(member.type));
|
|
879
|
+
};
|
|
880
|
+
const openDocumentOf = (shape, id) => ({
|
|
881
|
+
kind: 'dictionary',
|
|
882
|
+
key: 'string',
|
|
883
|
+
value: { kind: 'dynamic', reason: 'declared-any-never-narrowed' },
|
|
884
|
+
ownership: ownership.forShape(shape, id)
|
|
885
|
+
});
|
|
789
886
|
const deriveObject = (id, shape) => {
|
|
887
|
+
if (isOpenDocumentShape(shape))
|
|
888
|
+
return openDocumentOf(shape, id);
|
|
790
889
|
const dictionaryIndex = dictionaryIndexOf(shape);
|
|
791
890
|
if (dictionaryIndex) {
|
|
792
891
|
return {
|
|
@@ -796,7 +895,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
796
895
|
ownership: ownership.forShape(shape, id)
|
|
797
896
|
};
|
|
798
897
|
}
|
|
799
|
-
const fields = recordFieldsOf(shape);
|
|
898
|
+
const fields = recordFieldsOf(shape, id);
|
|
800
899
|
const indexes = recordIndexesOf(shape);
|
|
801
900
|
if (typeof indexes === 'string')
|
|
802
901
|
return unresolved(indexes);
|
|
@@ -826,8 +925,9 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
826
925
|
kind: 'record',
|
|
827
926
|
shapeId: id,
|
|
828
927
|
fields,
|
|
829
|
-
accessors: recordAccessorsOf(shape, deriveStored),
|
|
830
|
-
ownership: ownership.forShape(shape, id)
|
|
928
|
+
accessors: recordAccessorsOf(shape, deriveStored, (member) => isRecordFieldMember(shape, member)),
|
|
929
|
+
ownership: ownership.forShape(shape, id),
|
|
930
|
+
...(shape.standIn ? { standIn: true } : {})
|
|
831
931
|
};
|
|
832
932
|
};
|
|
833
933
|
/**
|
|
@@ -1225,6 +1325,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1225
1325
|
version: stated.version,
|
|
1226
1326
|
native: stated.native,
|
|
1227
1327
|
bases: binding.basesOf(stated.native),
|
|
1328
|
+
viewsFrom: binding.viewsInto?.(stated.native) ?? new Map(),
|
|
1228
1329
|
call: null,
|
|
1229
1330
|
construct: null
|
|
1230
1331
|
};
|
|
@@ -1621,7 +1722,8 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1621
1722
|
// order decide the layout; a failed reduction still refuses by name.
|
|
1622
1723
|
const reconciled = existing ? intersectPropertyRepresentations(existing.value, value) : value;
|
|
1623
1724
|
if (existing && !reconciled) {
|
|
1624
|
-
return unresolved(`no primitive for an intersection whose members disagree on the carrier of "${key}"`
|
|
1725
|
+
return unresolved(`no primitive for an intersection whose members disagree on the carrier of "${key}" ` +
|
|
1726
|
+
`(${representationKey(existing.value)} vs ${representationKey(value)})`);
|
|
1625
1727
|
}
|
|
1626
1728
|
// Required in any arm is required overall: an intersection satisfies
|
|
1627
1729
|
// every arm, so an optional field paired with a required one is present.
|
|
@@ -1673,10 +1775,11 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1673
1775
|
if (shape.elements.length === 0) {
|
|
1674
1776
|
return { kind: 'array-object', element: { kind: 'undefined' }, ownership: ownership.forShape(shape, id), extension: null };
|
|
1675
1777
|
}
|
|
1676
|
-
// A homogeneous closed tuple and T[] are views of the same JS array
|
|
1677
|
-
//
|
|
1678
|
-
// boundary
|
|
1679
|
-
//
|
|
1778
|
+
// A homogeneous closed tuple and T[] are views of the same JS array BY
|
|
1779
|
+
// DEFAULT: positional record storage is a copying conversion at that
|
|
1780
|
+
// boundary, which breaks aliasing unless the proof below clears this id
|
|
1781
|
+
// of ever needing one. Arity remains in the semantic tuple shape; it does
|
|
1782
|
+
// not require a different physical carrier.
|
|
1680
1783
|
const first = shape.elements[0];
|
|
1681
1784
|
const fixedArity = first !== undefined && shape.elements.every((element) => !element.optional && !element.rest && !element.variadic);
|
|
1682
1785
|
// Homogeneous by CARRIER, not by structural type id. `['a', 'b'] as const`
|
|
@@ -1698,7 +1801,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1698
1801
|
const key = representationKey(carrier);
|
|
1699
1802
|
return shape.elements.every((element) => representationKey(deriveStored(element.type)) === key) ? carrier : null;
|
|
1700
1803
|
})();
|
|
1701
|
-
|
|
1804
|
+
// The aliasing hazard above is a fact about how THIS id is used, not
|
|
1805
|
+
// about homogeneity itself -- `value-records.ts`'s `valueRecordTypesOf`
|
|
1806
|
+
// proves it the same way it proves an object record may be carried by
|
|
1807
|
+
// value: no write reaches an element, no identity test names the tuple,
|
|
1808
|
+
// and it never crosses a dynamic/boundary/protocol edge. A tuple this
|
|
1809
|
+
// proof clears falls through to the positional `record` below, the same
|
|
1810
|
+
// carrier a heterogeneous closed tuple already gets; one that is not
|
|
1811
|
+
// cleared (`names.forEach(...)`, still disqualified because `names` is
|
|
1812
|
+
// itself the invocation's receiver) keeps aliasing a real `T[]`.
|
|
1813
|
+
if (uniformElement && !valueRecords.forType(id)) {
|
|
1702
1814
|
return { kind: 'array-object', element: uniformElement, ownership: ownership.forShape(shape, id), extension: null };
|
|
1703
1815
|
}
|
|
1704
1816
|
// A rest or variadic position has no fixed arity, so the tuple is not a
|
|
@@ -1746,7 +1858,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1746
1858
|
// whose keys are its indices.
|
|
1747
1859
|
fields.push({ key: String(position), value: deriveStored(element.type), required: !element.optional });
|
|
1748
1860
|
}
|
|
1749
|
-
|
|
1861
|
+
// `ownership.forShape` never answers `'owned'` for a tuple (it is scoped
|
|
1862
|
+
// to `shape.kind === 'object'`, `compiler.ts`) -- on purpose, so this
|
|
1863
|
+
// campaign's proof cannot silently flip every already-shipped
|
|
1864
|
+
// HETEROGENEOUS tuple-as-record from `shared-refcount`. `uniformElement`
|
|
1865
|
+
// is exactly the flag that says this id reached here only because the
|
|
1866
|
+
// proof above cleared it of the one hazard homogeneity used to force
|
|
1867
|
+
// `array-object` for; a heterogeneous tuple (`uniformElement === null`)
|
|
1868
|
+
// keeps its existing ownership untouched.
|
|
1869
|
+
const byValue = uniformElement !== null && valueRecords.forType(id);
|
|
1870
|
+
return { kind: 'record', shapeId: id, fields, accessors: [], ownership: byValue ? 'owned' : ownership.forShape(shape, id) };
|
|
1750
1871
|
};
|
|
1751
1872
|
/**
|
|
1752
1873
|
* The carrier of a class's constructor object.
|
|
@@ -1849,6 +1970,148 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1849
1970
|
return { declaration, representative: ordinal, family: [declaration] };
|
|
1850
1971
|
};
|
|
1851
1972
|
const physicalClassDeclarationOf = (shape) => physicalClassGroupOf(shape).declaration;
|
|
1973
|
+
/**
|
|
1974
|
+
* The physical class ONE copy of `root` is, by the same grouping
|
|
1975
|
+
* `physicalClassGroupOf` applies to a shape; the root while the class has
|
|
1976
|
+
* one layout, and the root too -- which then names no layout and fails
|
|
1977
|
+
* closed downstream -- for a copy no view recorded.
|
|
1978
|
+
*/
|
|
1979
|
+
const physicalCopyDeclarationOf = (root, ordinal) => {
|
|
1980
|
+
const groups = classGroupsOf(root);
|
|
1981
|
+
if (groups === null || groups.size < 2)
|
|
1982
|
+
return root;
|
|
1983
|
+
const copy = classCopies.copiesOf(root).find((one) => one.ordinal === ordinal);
|
|
1984
|
+
const group = copy ? groups.get(copy.typeArguments.map((id) => classArgumentKeyOf(root, id)).join(',')) : undefined;
|
|
1985
|
+
return group === undefined ? root : `${root}@${group}`;
|
|
1986
|
+
};
|
|
1987
|
+
/** The instance shape of each of `root`'s physical copies, keyed by group ordinal -- the arms a family union cites. */
|
|
1988
|
+
const copyInstanceShapesOf = (root, groups) => {
|
|
1989
|
+
const found = new Map();
|
|
1990
|
+
for (const candidate of instanceShapesOf(root)) {
|
|
1991
|
+
const other = shapeOf(candidate);
|
|
1992
|
+
if (other?.kind !== 'class-instance' || other.body === null)
|
|
1993
|
+
continue;
|
|
1994
|
+
const group = groups.get(other.typeArguments.map((one) => classArgumentKeyOf(root, one)).join(','));
|
|
1995
|
+
if (group !== undefined && !found.has(group))
|
|
1996
|
+
found.set(group, candidate);
|
|
1997
|
+
}
|
|
1998
|
+
return found;
|
|
1999
|
+
};
|
|
2000
|
+
/**
|
|
2001
|
+
* A generic class spelled at its `any` filling, when its copies are
|
|
2002
|
+
* separate layouts, names ANY of them.
|
|
2003
|
+
*
|
|
2004
|
+
* mongodb's `AbstractCursor<TSchema>` stores `TSchema`, so each filling the
|
|
2005
|
+
* program constructs is its own struct -- the `any` one included
|
|
2006
|
+
* (`RunCommandCursor extends AbstractCursor`). The driver then hands every
|
|
2007
|
+
* copy's `this` to a slot typed bare `AbstractCursor`
|
|
2008
|
+
* (`new ReadableCursorStream(this)`, `Set<AbstractCursor>`,
|
|
2009
|
+
* `session.owner`). In JavaScript that is one object; natively it is one of
|
|
2010
|
+
* several structs, and neither a copy (loses identity and writes) nor one
|
|
2011
|
+
* shared struct (boxes a typed field) is sound. `any` is the unchecked
|
|
2012
|
+
* top, so the slot's honest carrier is the sum of the copies: identity is
|
|
2013
|
+
* kept, and each member access dispatches to the arm that is live.
|
|
2014
|
+
*
|
|
2015
|
+
* Only an `any` filling, never `unknown`: `unknown` is checked and
|
|
2016
|
+
* names no copy it could stand for. `null` for every other shape.
|
|
2017
|
+
*/
|
|
2018
|
+
const anyCopyFamilyOf = (id, shape, self) => {
|
|
2019
|
+
if (shape.typeArguments.length === 0)
|
|
2020
|
+
return null;
|
|
2021
|
+
const filledWithAny = shape.typeArguments.map((argument) => {
|
|
2022
|
+
const filling = shapeOf(argument);
|
|
2023
|
+
return filling?.kind === 'primitive' && filling.primitive === 'any';
|
|
2024
|
+
});
|
|
2025
|
+
if (!filledWithAny.some(Boolean))
|
|
2026
|
+
return null;
|
|
2027
|
+
const groups = classGroupsOf(shape.declaration);
|
|
2028
|
+
if (groups === null || groups.size < 2)
|
|
2029
|
+
return null;
|
|
2030
|
+
// Every layout-relevant position `any`: a position folded away as
|
|
2031
|
+
// irrelevant carries the canonical placeholder, which is no statement.
|
|
2032
|
+
const argumentKeys = shape.typeArguments.map((one) => classArgumentKeyOf(shape.declaration, one));
|
|
2033
|
+
const own = groups.get(argumentKeys.join(','));
|
|
2034
|
+
const shapes = copyInstanceShapesOf(shape.declaration, groups);
|
|
2035
|
+
const ordinals = [...new Set(groups.values())].sort((left, right) => left - right);
|
|
2036
|
+
const arms = [];
|
|
2037
|
+
for (const ordinal of ordinals) {
|
|
2038
|
+
const member = ordinal === own ? id : shapes.get(ordinal);
|
|
2039
|
+
if (member === undefined)
|
|
2040
|
+
return null;
|
|
2041
|
+
const value = ordinal === own ? self : derive(member);
|
|
2042
|
+
if (value.kind !== 'class-ref')
|
|
2043
|
+
return null;
|
|
2044
|
+
arms.push({ tag: String(arms.length), value, semanticType: member, runtimeDiscriminator: { kind: 'carrier' } });
|
|
2045
|
+
}
|
|
2046
|
+
if (arms.length < 2)
|
|
2047
|
+
return null;
|
|
2048
|
+
const union = { kind: 'tagged-union', arms };
|
|
2049
|
+
copyFamilyUnions.add(union);
|
|
2050
|
+
return union;
|
|
2051
|
+
};
|
|
2052
|
+
/**
|
|
2053
|
+
* A class instance's carrier with the native object it extends, when it
|
|
2054
|
+
* extends one: the intrinsic `Error` layout (as an upcast; anything else
|
|
2055
|
+
* leaves the class without it rather than without a carrier -- the struct
|
|
2056
|
+
* link itself is `records.ts`'s decision), or a native collection or the
|
|
2057
|
+
* intrinsic promise, each the object's own storage and so has to resolve
|
|
2058
|
+
* for the class to have a carrier at all.
|
|
2059
|
+
*/
|
|
2060
|
+
const withNativeBase = (shape, classRef) => {
|
|
2061
|
+
if (shape.nativeError) {
|
|
2062
|
+
const nativeBase = derive(shape.nativeError);
|
|
2063
|
+
if (nativeBase.kind !== 'native-record-ref' || nativeBase.native === null)
|
|
2064
|
+
return classRef;
|
|
2065
|
+
return {
|
|
2066
|
+
...classRef,
|
|
2067
|
+
nativeBase,
|
|
2068
|
+
...(heritage.overridesNativeError?.(shape.declaration) ? { nativeBaseOverridden: true } : {})
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
if (shape.nativePromise) {
|
|
2072
|
+
const nativeBase = derive(shape.nativePromise);
|
|
2073
|
+
if (nativeBase.kind !== 'promise') {
|
|
2074
|
+
return unresolved(`class ${shape.declaration} extends the intrinsic Promise with no promise carrier: ${nativeBase.kind === 'unresolved' ? nativeBase.reason : nativeBase.kind}`);
|
|
2075
|
+
}
|
|
2076
|
+
return {
|
|
2077
|
+
...classRef,
|
|
2078
|
+
nativeBase,
|
|
2079
|
+
...(heritage.overridesNativeCollection?.(shape.declaration) ? { nativeBaseOverridden: true } : {})
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
if (!shape.nativeCollection)
|
|
2083
|
+
return classRef;
|
|
2084
|
+
const nativeBase = derive(shape.nativeCollection);
|
|
2085
|
+
if (nativeBase.kind !== 'keyed-collection') {
|
|
2086
|
+
return unresolved(`class ${shape.declaration} extends a native collection with no carrier: ${nativeBase.kind === 'unresolved' ? nativeBase.reason : nativeBase.kind}`);
|
|
2087
|
+
}
|
|
2088
|
+
return {
|
|
2089
|
+
...classRef,
|
|
2090
|
+
nativeBase,
|
|
2091
|
+
...(heritage.overridesNativeCollection?.(shape.declaration) ? { nativeBaseOverridden: true } : {})
|
|
2092
|
+
};
|
|
2093
|
+
};
|
|
2094
|
+
const copyFamilyUnions = new WeakSet();
|
|
2095
|
+
const exactClassInstanceOf = (type) => {
|
|
2096
|
+
const derived = derive(type);
|
|
2097
|
+
if (derived.kind !== 'tagged-union' || !copyFamilyUnions.has(derived))
|
|
2098
|
+
return derived;
|
|
2099
|
+
return derived.arms.find((arm) => arm.semanticType === type)?.value ?? derived;
|
|
2100
|
+
};
|
|
2101
|
+
/**
|
|
2102
|
+
* The ancestors a class instance's carrier states: each generic ancestor
|
|
2103
|
+
* as the physical copy THIS copy derives from (`ClassHeritagePolicy.forCopy`),
|
|
2104
|
+
* which is what licenses the upcast of `Derived<{ a: string }>` into a
|
|
2105
|
+
* method `Base` declares once `Base`'s copies are separate structs.
|
|
2106
|
+
*/
|
|
2107
|
+
const classInstanceAncestorsOf = (shape) => {
|
|
2108
|
+
const copies = classCopies.copiesOf(shape.declaration);
|
|
2109
|
+
const ordinal = physicalClassGroupOf(shape).representative ?? (copies.length === 1 ? (copies[0]?.ordinal ?? null) : null);
|
|
2110
|
+
const chain = heritage.forCopy?.(shape.declaration, ordinal) ?? null;
|
|
2111
|
+
if (chain === null)
|
|
2112
|
+
return heritage.forDeclaration(shape.declaration);
|
|
2113
|
+
return chain.map((ancestor) => ancestor.ordinal === null ? ancestor.declaration : physicalCopyDeclarationOf(ancestor.declaration, ancestor.ordinal));
|
|
2114
|
+
};
|
|
1852
2115
|
const deriveClassConstructor = (shape) => {
|
|
1853
2116
|
// An ambient `declare class`'s value IS a host handle, on the same
|
|
1854
2117
|
// ground the `declared` case a few hundred lines below already stands on
|
|
@@ -1867,6 +2130,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1867
2130
|
version: bound.version,
|
|
1868
2131
|
native: bound.native,
|
|
1869
2132
|
bases: binding.basesOf(bound.native),
|
|
2133
|
+
viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
|
|
1870
2134
|
call: null,
|
|
1871
2135
|
construct
|
|
1872
2136
|
};
|
|
@@ -1892,9 +2156,12 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
1892
2156
|
return unresolved(`class ${shape.declaration} has no interned construct signature`);
|
|
1893
2157
|
if (signature.construct.length === 0)
|
|
1894
2158
|
return unresolved(`class ${shape.declaration} has no interned construct signature`);
|
|
1895
|
-
const
|
|
1896
|
-
if (typeof
|
|
1897
|
-
return unresolved(
|
|
2159
|
+
const shared = sharedAbiOf(signature.construct, 'construct');
|
|
2160
|
+
if (typeof shared === 'string')
|
|
2161
|
+
return unresolved(shared);
|
|
2162
|
+
// A construction makes exactly this class, never "any copy" of it.
|
|
2163
|
+
const constructed = signature.construct[0]?.result;
|
|
2164
|
+
const abi = constructed === undefined ? shared : { ...shared, result: exactClassInstanceOf(constructed) };
|
|
1898
2165
|
// A derived class the program stores into this constructor's slot is a
|
|
1899
2166
|
// member too: naming only the base would let construction and static
|
|
1900
2167
|
// reads resolve to the base while the cell holds the derived class.
|
|
@@ -2132,6 +2399,19 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2132
2399
|
const derived = deriveStored(typeArgument);
|
|
2133
2400
|
return derived.kind === 'dynamic' || derived.kind === 'unresolved' ? { kind: 'undefined' } : derived;
|
|
2134
2401
|
};
|
|
2402
|
+
// `AsyncGenerator<T, TReturn, TNext>` shares the question -- which
|
|
2403
|
+
// of the three channels resolved to a native carrier -- but not the
|
|
2404
|
+
// carrier: its steps answer promises and its body suspends at every
|
|
2405
|
+
// `await`, which no synchronous cursor can do (model.ts's
|
|
2406
|
+
// `async-generator` arm).
|
|
2407
|
+
if (generator.isAsync?.(shape.declaration) === true) {
|
|
2408
|
+
return {
|
|
2409
|
+
kind: 'async-generator',
|
|
2410
|
+
element: deriveStored(yielded),
|
|
2411
|
+
completion: nativeOrUndefined(shape.typeArguments[1]),
|
|
2412
|
+
resume: nativeOrUndefined(shape.typeArguments[2])
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2135
2415
|
return {
|
|
2136
2416
|
kind: 'iterator',
|
|
2137
2417
|
element: deriveStored(yielded),
|
|
@@ -2141,8 +2421,26 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2141
2421
|
};
|
|
2142
2422
|
}
|
|
2143
2423
|
const family = collections.forDeclaration(shape.declaration);
|
|
2144
|
-
if (family)
|
|
2145
|
-
|
|
2424
|
+
if (family) {
|
|
2425
|
+
// `type Tree = Map<string, Tree>` is ONE type, but it can reach the
|
|
2426
|
+
// table under a second id -- the collection census re-interns `new
|
|
2427
|
+
// Map()`'s `Map<string, Tree>` with no body -- whose argument is the
|
|
2428
|
+
// alias's own anchor. Same declaration, same arguments: it is that
|
|
2429
|
+
// anchor, and deriving it apart unrolls one level into a plain
|
|
2430
|
+
// `Map<string, Wrapper>` no conversion turns into the wrapper.
|
|
2431
|
+
const twin = shape.typeArguments.find((argument) => {
|
|
2432
|
+
if (argument === id)
|
|
2433
|
+
return false;
|
|
2434
|
+
const other = shapeOf(argument);
|
|
2435
|
+
return (other?.kind === 'declared' &&
|
|
2436
|
+
other.declaration === shape.declaration &&
|
|
2437
|
+
other.typeArguments.length === shape.typeArguments.length &&
|
|
2438
|
+
other.typeArguments.every((one, index) => one === shape.typeArguments[index]));
|
|
2439
|
+
});
|
|
2440
|
+
if (twin !== undefined)
|
|
2441
|
+
return derive(twin);
|
|
2442
|
+
return deriveKeyedCollection(family, shape, id, deriveStored, ownership, collections.isReadOnlyView?.(shape.declaration) === true);
|
|
2443
|
+
}
|
|
2146
2444
|
// `Date`, checked here for the same two reasons `Promise<T>` and the
|
|
2147
2445
|
// keyed collections are checked above it. Its ambient body survives
|
|
2148
2446
|
// `declaredBodyOf`'s method stripping as an EMPTY object shape, so
|
|
@@ -2269,6 +2567,26 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2269
2567
|
return sole !== undefined ? derive(sole) : deriveUnionShape({ kind: 'union', members: instances });
|
|
2270
2568
|
}
|
|
2271
2569
|
}
|
|
2570
|
+
// A program interface extending the intrinsic `Error` carries the
|
|
2571
|
+
// error itself, for the reason `Error & { code: string }` does in
|
|
2572
|
+
// `deriveIntersection`: nothing constructs an interface, so its values
|
|
2573
|
+
// are errors some `new Error(...)` built and the program re-typed --
|
|
2574
|
+
// node-compat's `new Error(m) as NodeArgumentError`, and
|
|
2575
|
+
// `(error as NodeArgumentError).code = ...` on an error it did not
|
|
2576
|
+
// build. A generated struct copying `Error`'s members could be
|
|
2577
|
+
// neither: it is a different object from the error written into it,
|
|
2578
|
+
// and it shares no base with `gea::runtime::Error`, so no pointer
|
|
2579
|
+
// upcast reaches an `Error` slot and a rebuild would drop identity,
|
|
2580
|
+
// `stack` and `cause`. The members the interface adds are properties
|
|
2581
|
+
// ON that error -- the native error's dynamic-property sidecar,
|
|
2582
|
+
// answered or refused by name at the access. After the implementors
|
|
2583
|
+
// above: a slot the program's own classes implement holds those
|
|
2584
|
+
// classes, not a bare error.
|
|
2585
|
+
if (shape.nativeError !== undefined) {
|
|
2586
|
+
const nativeError = derive(shape.nativeError);
|
|
2587
|
+
if (nativeError.kind === 'native-record-ref' && nativeError.native !== null)
|
|
2588
|
+
return nativeError;
|
|
2589
|
+
}
|
|
2272
2590
|
// A bound declaration is a host handle, full stop: the protocol is its
|
|
2273
2591
|
// complete definition, and neither an empty structural body (a JSX
|
|
2274
2592
|
// `Element` interface with no members) nor a missing one changes that.
|
|
@@ -2321,6 +2639,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2321
2639
|
version: bound.version,
|
|
2322
2640
|
native: bound.native,
|
|
2323
2641
|
bases: binding.basesOf(bound.native),
|
|
2642
|
+
viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
|
|
2324
2643
|
call,
|
|
2325
2644
|
construct
|
|
2326
2645
|
};
|
|
@@ -2360,6 +2679,8 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2360
2679
|
// identical layout question here, they just answer it at different
|
|
2361
2680
|
// times.
|
|
2362
2681
|
if (body?.kind === 'object') {
|
|
2682
|
+
if (isOpenDocumentShape(body))
|
|
2683
|
+
return openDocumentOf(shape, id);
|
|
2363
2684
|
const dictionaryIndex = dictionaryIndexOf(body);
|
|
2364
2685
|
if (dictionaryIndex) {
|
|
2365
2686
|
return {
|
|
@@ -2444,6 +2765,7 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2444
2765
|
version: bound.version,
|
|
2445
2766
|
native: bound.native,
|
|
2446
2767
|
bases: binding.basesOf(bound.native),
|
|
2768
|
+
viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
|
|
2447
2769
|
call: null,
|
|
2448
2770
|
construct: null
|
|
2449
2771
|
};
|
|
@@ -2454,13 +2776,21 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2454
2776
|
if (!shape.body) {
|
|
2455
2777
|
return unresolved(`class ${shape.declaration} is declared without a body and has no installed host protocol`);
|
|
2456
2778
|
}
|
|
2457
|
-
|
|
2779
|
+
const classRef = {
|
|
2458
2780
|
kind: 'class-ref',
|
|
2459
2781
|
declaration: physicalClassDeclarationOf(shape),
|
|
2460
2782
|
shapeId: shape.body,
|
|
2461
2783
|
ownership: ownership.forShape(shape, id),
|
|
2462
|
-
ancestors:
|
|
2784
|
+
ancestors: classInstanceAncestorsOf(shape)
|
|
2463
2785
|
};
|
|
2786
|
+
const own = withNativeBase(shape, classRef);
|
|
2787
|
+
if (own.kind !== 'class-ref')
|
|
2788
|
+
return own;
|
|
2789
|
+
// The copy's own arm is its complete carrier, native base included:
|
|
2790
|
+
// mongodb's `class CaseInsensitiveMap<Value = any> extends Map<string,
|
|
2791
|
+
// Value>` read at `any` is the family, and the `any` copy's own
|
|
2792
|
+
// constructor still initializes the Map it IS.
|
|
2793
|
+
return anyCopyFamilyOf(id, shape, own) ?? own;
|
|
2464
2794
|
}
|
|
2465
2795
|
case 'class-constructor':
|
|
2466
2796
|
return deriveClassConstructor(shape);
|
|
@@ -2542,5 +2872,16 @@ export const createRepresentationDeriver = (types, ownership = defaultOwnershipP
|
|
|
2542
2872
|
return null;
|
|
2543
2873
|
};
|
|
2544
2874
|
const isDateCarrier = (representation) => representation.kind === 'native-record-ref' && representation.native !== null && dateNatives.has(representation.native);
|
|
2545
|
-
return {
|
|
2875
|
+
return {
|
|
2876
|
+
derive,
|
|
2877
|
+
exactClassInstanceOf,
|
|
2878
|
+
layoutOf,
|
|
2879
|
+
abiOf,
|
|
2880
|
+
deriveStored,
|
|
2881
|
+
isNeverType,
|
|
2882
|
+
isTupleShape,
|
|
2883
|
+
nativeCallableConventions,
|
|
2884
|
+
isDateCarrier,
|
|
2885
|
+
dynamicFallback
|
|
2886
|
+
};
|
|
2546
2887
|
};
|
|
@@ -86,6 +86,10 @@ const shallowSignature = (representation) => {
|
|
|
86
86
|
return representation.kind;
|
|
87
87
|
case 'scalar':
|
|
88
88
|
return `scalar(${representation.domain})`;
|
|
89
|
+
case 'constructor-identity':
|
|
90
|
+
return `constructor-identity(${representation.declaration})`;
|
|
91
|
+
case 'error-constructor':
|
|
92
|
+
return representation.kind;
|
|
89
93
|
case 'class-ref':
|
|
90
94
|
return `class-ref(${representation.declaration},${representation.shapeId},${representation.ownership})`;
|
|
91
95
|
case 'native-handle':
|
|
@@ -120,6 +124,8 @@ const shallowSignature = (representation) => {
|
|
|
120
124
|
return 'native-sequence';
|
|
121
125
|
case 'iterator':
|
|
122
126
|
return 'iterator';
|
|
127
|
+
case 'async-generator':
|
|
128
|
+
return 'async-generator';
|
|
123
129
|
case 'promise':
|
|
124
130
|
return 'promise';
|
|
125
131
|
case 'keyed-collection':
|
|
@@ -162,6 +168,8 @@ const abiSignature = (abi) => `${abi.parameters.map((parameter) => parameter.own
|
|
|
162
168
|
const children = (representation) => {
|
|
163
169
|
switch (representation.kind) {
|
|
164
170
|
case 'callable-identity':
|
|
171
|
+
case 'constructor-identity':
|
|
172
|
+
case 'error-constructor':
|
|
165
173
|
case 'unresolved':
|
|
166
174
|
case 'void':
|
|
167
175
|
case 'string':
|
|
@@ -199,6 +207,12 @@ const children = (representation) => {
|
|
|
199
207
|
case 'native-sequence':
|
|
200
208
|
case 'iterator':
|
|
201
209
|
return [['element', representation.element]];
|
|
210
|
+
case 'async-generator':
|
|
211
|
+
return [
|
|
212
|
+
['element', representation.element],
|
|
213
|
+
['completion', representation.completion],
|
|
214
|
+
['resume', representation.resume]
|
|
215
|
+
];
|
|
202
216
|
case 'promise':
|
|
203
217
|
return [['value', representation.value]];
|
|
204
218
|
case 'keyed-collection':
|
|
@@ -30,3 +30,18 @@ import type { CallableAbi } from './model.js';
|
|
|
30
30
|
* short and free of carrier keys so equal walls group together.
|
|
31
31
|
*/
|
|
32
32
|
export declare const widestSubsumingAbi: (abis: readonly CallableAbi[]) => CallableAbi | string;
|
|
33
|
+
/**
|
|
34
|
+
* A PROGRAM overload set whose members differ by a trailing callback and a
|
|
35
|
+
* `void` result -- Node's callback-or-promise idiom, mongodb's
|
|
36
|
+
* `KerberosClient.step(challenge): Promise<string>` beside
|
|
37
|
+
* `step(challenge, callback): void` -- as one frame: the widest arity, each
|
|
38
|
+
* position joined exactly as `widestSubsumingAbi` joins it, and the valued
|
|
39
|
+
* overloads' one result made optional, since the callback form answers
|
|
40
|
+
* `undefined`.
|
|
41
|
+
*
|
|
42
|
+
* Only when every valued overload agrees on the result: two different
|
|
43
|
+
* values would need a union this layer cannot intern. The frame is marked
|
|
44
|
+
* `overloadJoined`, which is what licenses a call naming one overload to read
|
|
45
|
+
* it as that overload's convention (the result projected, checked).
|
|
46
|
+
*/
|
|
47
|
+
export declare const callbackOverloadJoinedAbi: (abis: readonly CallableAbi[]) => CallableAbi | null;
|