@geastack/compiler 1.0.19 → 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/prelude.js +5 -1
- 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 +594 -54
- 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 +48 -4
- 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 +18007 -4757
- package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +7 -45
- package/src/targets/cpp/runtime/gea_runtime_rtc.h +247 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync, realpathSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync, realpathSync, readdirSync, rmSync } from 'node:fs';
|
|
2
2
|
import { dirname, resolve, isAbsolute, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import { createPackageSourceHost } from './semantics/package-sources.js';
|
|
6
7
|
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
7
8
|
const disk = {
|
|
8
9
|
exists: existsSync,
|
|
@@ -10,7 +11,10 @@ const disk = {
|
|
|
10
11
|
write: (file, text) => {
|
|
11
12
|
writeFileSync(file, text);
|
|
12
13
|
},
|
|
13
|
-
realpath: realpathSync
|
|
14
|
+
realpath: realpathSync,
|
|
15
|
+
directories: (directory) => readdirSync(directory, { withFileTypes: true })
|
|
16
|
+
.filter((entry) => entry.isDirectory())
|
|
17
|
+
.map((entry) => entry.name)
|
|
14
18
|
};
|
|
15
19
|
const manifestAt = (root, files = disk) => object(JSON.parse(files.read(join(root, 'package.json'))));
|
|
16
20
|
/**
|
|
@@ -231,6 +235,160 @@ const checkout = (identity, destination) => {
|
|
|
231
235
|
if (run('git', ['rev-parse', 'HEAD'], destination) !== identity.commit)
|
|
232
236
|
throw new Error('Source checkout did not match the published commit');
|
|
233
237
|
};
|
|
238
|
+
const fetchPackage = (spec, destination) => {
|
|
239
|
+
mkdirSync(destination, { recursive: true });
|
|
240
|
+
const tarball = run('npm', ['pack', spec, '--silent', '--ignore-scripts', '--pack-destination', destination], destination)
|
|
241
|
+
.split('\n')
|
|
242
|
+
.pop();
|
|
243
|
+
if (!tarball)
|
|
244
|
+
throw new Error(`npm pack ${spec} produced no tarball`);
|
|
245
|
+
run('tar', ['-xzf', tarball, '--strip-components=1', '-C', destination], destination);
|
|
246
|
+
rmSync(join(destination, tarball));
|
|
247
|
+
};
|
|
248
|
+
/** Whether an installed package states its own declarations, so a DefinitelyTyped package adds nothing. */
|
|
249
|
+
const shipsDeclarations = (directory, manifest, files) => typeof manifest.types === 'string' ||
|
|
250
|
+
typeof manifest.typings === 'string' ||
|
|
251
|
+
/"types"\s*:/.test(JSON.stringify(manifest.exports ?? null)) ||
|
|
252
|
+
files.exists(join(directory, 'index.d.ts'));
|
|
253
|
+
/** The DefinitelyTyped package that describes `name`. */
|
|
254
|
+
const typesPackageOf = (name) => `@types/${name.startsWith('@') ? name.slice(1).replace('/', '__') : name}`;
|
|
255
|
+
/** The runtime package a DefinitelyTyped package describes. */
|
|
256
|
+
const describedPackageOf = (typesName) => {
|
|
257
|
+
const bare = typesName.slice('@types/'.length);
|
|
258
|
+
return bare.includes('__') ? `@${bare.replace('__', '/')}` : bare;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* The DefinitelyTyped declarations a source checkout compiles against.
|
|
262
|
+
*
|
|
263
|
+
* A package whose runtime dependency is untyped JavaScript names that
|
|
264
|
+
* dependency's `@types/*` package as a DEVELOPMENT dependency: its own build
|
|
265
|
+
* needs it, its published declarations do not. The installed tree therefore
|
|
266
|
+
* has the JavaScript and not its declarations -- `@mongodb-js/saslprep`
|
|
267
|
+
* imports `sparse-bitfield` and names `bitfield.BitFieldInstance`, which only
|
|
268
|
+
* `@types/sparse-bitfield` declares. Compiling the checkout without them turns
|
|
269
|
+
* every such name into a checker error.
|
|
270
|
+
*
|
|
271
|
+
* Only the `@types/*` counterpart of a runtime package that is installed and
|
|
272
|
+
* ships no declarations of its own is fetched, at the range the checkout
|
|
273
|
+
* states, and a fetched declaration package's own `@types/*` dependencies
|
|
274
|
+
* under the same rule (`@types/sparse-bitfield` imports `memory-pager`'s
|
|
275
|
+
* types). `@types/node` never qualifies: no installed package is named `node`.
|
|
276
|
+
*
|
|
277
|
+
* It goes into the `node_modules` holding the package it describes -- where
|
|
278
|
+
* `npm install -D` would have put it. That is where the declaration overlay
|
|
279
|
+
* pairs a JavaScript module with its DefinitelyTyped mirror
|
|
280
|
+
* (`declaration-overlay-transform.ts`), and where module resolution from both
|
|
281
|
+
* the checkout and the package finds it.
|
|
282
|
+
*/
|
|
283
|
+
const provideDevelopmentTypes = (packageRoot, origin, files, fetch) => {
|
|
284
|
+
const manifest = manifestAt(packageRoot, files);
|
|
285
|
+
const development = object(manifest.devDependencies);
|
|
286
|
+
const wanted = Object.keys({ ...object(manifest.dependencies), ...object(manifest.optionalDependencies) }).flatMap((name) => {
|
|
287
|
+
const range = development[typesPackageOf(name)];
|
|
288
|
+
return typeof range === 'string' ? [[typesPackageOf(name), range]] : [];
|
|
289
|
+
});
|
|
290
|
+
const seen = new Set();
|
|
291
|
+
while (wanted.length > 0) {
|
|
292
|
+
const [typesName, range] = wanted.shift();
|
|
293
|
+
if (seen.has(typesName))
|
|
294
|
+
continue;
|
|
295
|
+
seen.add(typesName);
|
|
296
|
+
const described = describedPackageOf(typesName);
|
|
297
|
+
const installed = installedPackage(described, origin, files);
|
|
298
|
+
if (!installed || !installed.endsWith(`/node_modules/${described}`))
|
|
299
|
+
continue;
|
|
300
|
+
if (shipsDeclarations(installed, manifestAt(installed, files), files))
|
|
301
|
+
continue;
|
|
302
|
+
let destination = installedPackage(typesName, installed, files);
|
|
303
|
+
if (!destination) {
|
|
304
|
+
destination = join(installed.slice(0, installed.length - described.length), typesName);
|
|
305
|
+
fetch(`${typesName}@${range}`, destination);
|
|
306
|
+
}
|
|
307
|
+
for (const [dependency, dependencyRange] of Object.entries(object(manifestAt(destination, files).dependencies)))
|
|
308
|
+
if (dependency.startsWith('@types/') && typeof dependencyRange === 'string')
|
|
309
|
+
wanted.push([dependency, dependencyRange]);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
/** Every runtime file the manifest publishes: `main`, `module`, and each non-type `exports` target. */
|
|
313
|
+
const runtimeOutputs = (manifest) => {
|
|
314
|
+
const outputs = [];
|
|
315
|
+
for (const field of ['main', 'module'])
|
|
316
|
+
if (typeof manifest[field] === 'string')
|
|
317
|
+
outputs.push(manifest[field]);
|
|
318
|
+
const visit = (value, condition) => {
|
|
319
|
+
if (typeof value === 'string') {
|
|
320
|
+
if (condition !== 'types' && !/\.d\.[cm]?ts$/.test(value))
|
|
321
|
+
outputs.push(value);
|
|
322
|
+
}
|
|
323
|
+
else if (Array.isArray(value))
|
|
324
|
+
value.forEach((entry) => visit(entry, condition));
|
|
325
|
+
else
|
|
326
|
+
for (const [key, entry] of Object.entries(object(value)))
|
|
327
|
+
visit(entry, key);
|
|
328
|
+
};
|
|
329
|
+
visit(manifest.exports);
|
|
330
|
+
return outputs;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Whether the installed package already proves which typed file one of its
|
|
334
|
+
* runtime outputs was built from, through the same metadata the resolver reads
|
|
335
|
+
* (a tsconfig outDir/rootDir pair, a `source` condition, a static Rollup
|
|
336
|
+
* input). Shipping a `src/` directory is not that proof: `bson` publishes
|
|
337
|
+
* `src/` beside a Rollup bundle but no build config, so nothing maps
|
|
338
|
+
* `lib/bson.node.mjs` back to `src/index.ts` and the compiled bundle was
|
|
339
|
+
* silently used instead -- the checkout carries the `rollup.config.mjs` that
|
|
340
|
+
* does.
|
|
341
|
+
*/
|
|
342
|
+
const installedSourceMapped = (directory, manifest, files) => {
|
|
343
|
+
const { sourceOf } = createPackageSourceHost({
|
|
344
|
+
fileExists: files.exists,
|
|
345
|
+
readFile: (file) => (files.exists(file) ? files.read(file) : undefined)
|
|
346
|
+
});
|
|
347
|
+
return runtimeOutputs(manifest).some((output) => {
|
|
348
|
+
const file = resolve(directory, output);
|
|
349
|
+
const source = sourceOf(file);
|
|
350
|
+
return source !== file && /\.(?:ts|tsx|mts|cts)$/.test(source) && !/\.d\.[cm]?ts$/.test(source);
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* The directory inside a checkout that IS the installed package: its manifest
|
|
355
|
+
* must name the installed package at the installed version. The repository's
|
|
356
|
+
* stated `directory` is authoritative when it names one. When it does not and
|
|
357
|
+
* the checkout root is some other package -- a monorepo whose published
|
|
358
|
+
* manifest omits `repository.directory`, as `@mongodb-js/saslprep` (in
|
|
359
|
+
* `mongodb-js/devtools-shared`) does -- the checkout at the exact published
|
|
360
|
+
* commit is searched for the one manifest with that name and version. Zero or
|
|
361
|
+
* several matches refuse, exactly as a mismatched root does.
|
|
362
|
+
*/
|
|
363
|
+
const checkoutPackageRoot = (destination, directory, manifest, files) => {
|
|
364
|
+
const matches = (root) => {
|
|
365
|
+
if (!files.exists(join(root, 'package.json')))
|
|
366
|
+
return false;
|
|
367
|
+
const found = manifestAt(root, files);
|
|
368
|
+
return found.name === manifest.name && found.version === manifest.version;
|
|
369
|
+
};
|
|
370
|
+
const stated = resolve(destination, directory);
|
|
371
|
+
if (matches(stated))
|
|
372
|
+
return stated;
|
|
373
|
+
if (directory === '.' && files.directories) {
|
|
374
|
+
const found = [];
|
|
375
|
+
const search = (root, depth) => {
|
|
376
|
+
for (const name of files.directories(root)) {
|
|
377
|
+
if (name === 'node_modules' || name.startsWith('.'))
|
|
378
|
+
continue;
|
|
379
|
+
const child = join(root, name);
|
|
380
|
+
if (matches(child))
|
|
381
|
+
found.push(child);
|
|
382
|
+
else if (depth < 3)
|
|
383
|
+
search(child, depth + 1);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
search(destination, 0);
|
|
387
|
+
if (found.length === 1)
|
|
388
|
+
return found[0];
|
|
389
|
+
}
|
|
390
|
+
throw new Error('Checkout package identity does not match the installed package');
|
|
391
|
+
};
|
|
234
392
|
/** Acquire missing typed sources at the installed version; plain JS remains usable. */
|
|
235
393
|
export const preparePackageSources = async (root, options = {}) => {
|
|
236
394
|
const files = options.files ?? disk;
|
|
@@ -265,7 +423,7 @@ export const preparePackageSources = async (root, options = {}) => {
|
|
|
265
423
|
const serialized = JSON.stringify({ main: manifest.main, exports: manifest.exports });
|
|
266
424
|
if (!/(?:dist|lib|build)\//.test(serialized) || !/\.d\.[cm]?ts|"types"|"typings"/.test(JSON.stringify(manifest)))
|
|
267
425
|
continue;
|
|
268
|
-
if (
|
|
426
|
+
if (installedSourceMapped(directory, manifest, files))
|
|
269
427
|
continue;
|
|
270
428
|
// Keyed by the published identity alone. A version is published once, so
|
|
271
429
|
// every installed copy of it -- hoisted, or nested under a dependency that
|
|
@@ -281,6 +439,7 @@ export const preparePackageSources = async (root, options = {}) => {
|
|
|
281
439
|
saved.version === manifest.version &&
|
|
282
440
|
typeof saved.root === 'string' &&
|
|
283
441
|
files.exists(join(saved.root, 'package.json'))) {
|
|
442
|
+
provideDevelopmentTypes(saved.root, directory, files, options.fetchPackage ?? fetchPackage);
|
|
284
443
|
sources.push({ root: saved.root, origin: directory });
|
|
285
444
|
continue;
|
|
286
445
|
}
|
|
@@ -299,10 +458,8 @@ export const preparePackageSources = async (root, options = {}) => {
|
|
|
299
458
|
const destination = join(cache, identity.commit);
|
|
300
459
|
log(`[geatsc] Fetching ${manifest.name}@${manifest.version} source (${identity.commit.slice(0, 12)})`);
|
|
301
460
|
(options.checkout ?? checkout)(identity, destination);
|
|
302
|
-
const packageRoot =
|
|
303
|
-
|
|
304
|
-
if (found.name !== manifest.name || found.version !== manifest.version)
|
|
305
|
-
throw new Error('Checkout package identity does not match the installed package');
|
|
461
|
+
const packageRoot = checkoutPackageRoot(destination, identity.directory, manifest, files);
|
|
462
|
+
provideDevelopmentTypes(packageRoot, directory, files, options.fetchPackage ?? fetchPackage);
|
|
306
463
|
files.write(record, `${JSON.stringify({ name: manifest.name, version: manifest.version, ...identity, root: packageRoot }, null, 2)}\n`);
|
|
307
464
|
sources.push({ root: packageRoot, origin: directory });
|
|
308
465
|
}
|
|
@@ -28,10 +28,13 @@ import type { SemanticGraph } from '../semantics/model/graph.js';
|
|
|
28
28
|
* and refuses by name (`bindingReference`, targets/cpp/emit-context.ts).
|
|
29
29
|
*/
|
|
30
30
|
export type BindingStorage =
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* A cell owned by one frame: a callable's, or a run-once region's for a
|
|
33
|
+
* block-scoped binding a closure captures (`regionFrameCells`).
|
|
34
|
+
*/
|
|
32
35
|
{
|
|
33
36
|
readonly kind: 'local';
|
|
34
|
-
readonly owner: FunctionId;
|
|
37
|
+
readonly owner: FunctionId | RegionId;
|
|
35
38
|
}
|
|
36
39
|
/** A cell owned by a region that runs once: a module body, an initializer, a static block. */
|
|
37
40
|
| {
|
|
@@ -223,6 +223,7 @@ export const projectBindingPlacements = (input) => {
|
|
|
223
223
|
return;
|
|
224
224
|
placements.set(declaration, { storage, representation });
|
|
225
225
|
};
|
|
226
|
+
const frameCells = regionFrameCells(input.graph);
|
|
226
227
|
for (const operation of input.graph.operations.values()) {
|
|
227
228
|
const introduces = (operation.family === 'binding' && (operation.action === 'initialize' || operation.action === 'declare')) ||
|
|
228
229
|
(operation.family === 'declaration-lifecycle' && (operation.event === 'module-link' || operation.event === 'initialize'));
|
|
@@ -241,7 +242,9 @@ export const projectBindingPlacements = (input) => {
|
|
|
241
242
|
})
|
|
242
243
|
: operation.caller.kind === 'function'
|
|
243
244
|
? { kind: 'local', owner: operation.caller.functionId }
|
|
244
|
-
:
|
|
245
|
+
: frameCells.has(operation.declaration)
|
|
246
|
+
? { kind: 'local', owner: operation.caller.regionId }
|
|
247
|
+
: { kind: 'region', owner: operation.caller.regionId };
|
|
245
248
|
record(operation.declaration, storage, representation);
|
|
246
249
|
}
|
|
247
250
|
// Second, and only where the graph introduced nothing: a cell the program
|
|
@@ -300,6 +303,42 @@ export const projectBindingPlacements = (input) => {
|
|
|
300
303
|
placeNamespaceAliases(input, placements);
|
|
301
304
|
return placements;
|
|
302
305
|
};
|
|
306
|
+
/**
|
|
307
|
+
* The block-scoped bindings of a run-once region that a closure captures.
|
|
308
|
+
*
|
|
309
|
+
* A module-level `let`/`const` inside a loop is a new binding every time its
|
|
310
|
+
* block is entered (ECMA-262 14.7.4.2 CreatePerIterationEnvironment for a
|
|
311
|
+
* `for` head, block evaluation for a body), so a closure made on each pass
|
|
312
|
+
* must hold its own. One file-scope cell cannot be that: every closure read
|
|
313
|
+
* the last value written. Such a binding is visible only to the region's own
|
|
314
|
+
* code and closures made inside its block, so it lives in the region body's
|
|
315
|
+
* frame and is captured like any function local. One no closure names keeps
|
|
316
|
+
* its file-scope cell -- a single cell is then unobservable.
|
|
317
|
+
*/
|
|
318
|
+
const regionFrameCells = (graph) => {
|
|
319
|
+
const candidates = new Map();
|
|
320
|
+
for (const operation of graph.operations.values()) {
|
|
321
|
+
if (operation.family !== 'binding' || !operation.blockScoped || operation.caller.kind === 'function')
|
|
322
|
+
continue;
|
|
323
|
+
if (operation.action !== 'initialize' && operation.action !== 'declare')
|
|
324
|
+
continue;
|
|
325
|
+
candidates.set(operation.declaration, operation.caller.regionId);
|
|
326
|
+
}
|
|
327
|
+
const captured = new Set();
|
|
328
|
+
if (candidates.size === 0)
|
|
329
|
+
return captured;
|
|
330
|
+
for (const operation of graph.operations.values()) {
|
|
331
|
+
const declaration = operation.family === 'binding' ? operation.declaration : operation.family === 'property' ? operation.resolvedBinding : undefined;
|
|
332
|
+
if (declaration === undefined)
|
|
333
|
+
continue;
|
|
334
|
+
const region = candidates.get(declaration);
|
|
335
|
+
if (region === undefined)
|
|
336
|
+
continue;
|
|
337
|
+
if (operation.caller.kind === 'function' || operation.caller.regionId !== region)
|
|
338
|
+
captured.add(declaration);
|
|
339
|
+
}
|
|
340
|
+
return captured;
|
|
341
|
+
};
|
|
303
342
|
/**
|
|
304
343
|
* Every read of a cell, by the declaration it reads, in `graph.operations` order.
|
|
305
344
|
*
|
|
@@ -5,6 +5,7 @@ import type { SealedRepresentationPlan } from '../representation/plan.js';
|
|
|
5
5
|
import { type HostMemberTable } from '../targets/cpp/host/host-members.js';
|
|
6
6
|
import type { BindingPlacement } from './bindings.js';
|
|
7
7
|
import type { ClassLayout } from './classes.js';
|
|
8
|
+
import { type UnboxedMethodAssumption } from './method-value-escapes.js';
|
|
8
9
|
import type { SemanticGraph } from '../semantics/model/graph.js';
|
|
9
10
|
import { type SemanticOperand } from '../semantics/model/operands.js';
|
|
10
11
|
import type { InvocationOperation } from '../semantics/model/operations.js';
|
|
@@ -91,6 +92,21 @@ export interface DeferredCallee {
|
|
|
91
92
|
* site's alone would be enough only if the call bypassed the box.
|
|
92
93
|
*/
|
|
93
94
|
readonly frame: 'native' | 'boxed';
|
|
95
|
+
/**
|
|
96
|
+
* Set on a `bind` lowered as the builtin although a write through a boxed
|
|
97
|
+
* target could, in principle, have shadowed it: valid only while the
|
|
98
|
+
* method's Function object is never boxed, which the lowered program alone
|
|
99
|
+
* can confirm (`ir/boxed-bind-assumptions.ts`). See `callableBindResolution`.
|
|
100
|
+
*/
|
|
101
|
+
readonly unboxedMethod?: UnboxedMethodAssumption;
|
|
102
|
+
/**
|
|
103
|
+
* Set on a `call`/`apply` lowered as the builtin although a write through a
|
|
104
|
+
* boxed target could, in principle, have shadowed it
|
|
105
|
+
* (`callableInvokeResolution`). The lowered call carries it as
|
|
106
|
+
* `CallOperation.builtinShadowGuard`, and the emitter checks the one
|
|
107
|
+
* Function object the call reaches at run time.
|
|
108
|
+
*/
|
|
109
|
+
readonly shadowGuard?: 'call' | 'apply';
|
|
94
110
|
/**
|
|
95
111
|
* The RECEIVER's own carrier -- the boxed frame's argument carrier, and the
|
|
96
112
|
* carrier the this-argument must keep its identity in. Carried here because
|
|
@@ -2,7 +2,8 @@ import { narrowedOperandView } from '../conversion/operand-view.js';
|
|
|
2
2
|
import { abiKey } from '../representation/model.js';
|
|
3
3
|
import { hostMemberOf } from '../targets/cpp/host/host-members.js';
|
|
4
4
|
import { classMemberOf, classMethodOverrideOf, classStaticMemberOf } from './fields.js';
|
|
5
|
-
import {
|
|
5
|
+
import { callableBindResolution, callableInvokeResolution, callableMutationFactsOf } from '../semantics/callable-origins.js';
|
|
6
|
+
import { unboxedMethodAssumptionOf } from './method-value-escapes.js';
|
|
6
7
|
import { operandOf, resultOf } from '../semantics/model/operands.js';
|
|
7
8
|
/**
|
|
8
9
|
* What a callee carrier says about the frame a call fills.
|
|
@@ -72,7 +73,7 @@ export const isClosedContiguousTupleRecord = (representation) => representation.
|
|
|
72
73
|
* the payload of an async function's promise, the completion of a generator's
|
|
73
74
|
* cursor, and otherwise the result itself.
|
|
74
75
|
*/
|
|
75
|
-
export const returnPayloadOf = (result) => result.kind === 'promise' ? result.value : result.kind === 'iterator' ? result.completion : result;
|
|
76
|
+
export const returnPayloadOf = (result) => result.kind === 'promise' ? result.value : result.kind === 'iterator' || result.kind === 'async-generator' ? result.completion : result;
|
|
76
77
|
/**
|
|
77
78
|
* The source function a method read as a VALUE names: `host.readFile` read
|
|
78
79
|
* off a class instance, or `Host.create` off its constructor, is the member
|
|
@@ -166,7 +167,27 @@ export const deferredCalleeOf = (input, operation) => {
|
|
|
166
167
|
const receiverProducer = receiverProducerId === undefined ? undefined : input.graph.operations.get(receiverProducerId);
|
|
167
168
|
const functionId = input.callableOrigins.get(receiver.source.result) ?? (receiverProducer ? methodValueOriginOfRead(input, receiverProducer) : null);
|
|
168
169
|
const facts = callableMutationFactsOf(input.graph, input.plan, input.callableOrigins);
|
|
169
|
-
|
|
170
|
+
const resolution = member === 'bind' ? callableBindResolution(facts, functionId) : callableInvokeResolution(facts, functionId, member);
|
|
171
|
+
// A boxed receiver IS a boxed Function object, so the assumption is already
|
|
172
|
+
// false for it; only a native carrier can have an object nothing boxed.
|
|
173
|
+
const unboxedMethod = member === 'bind' && resolution === 'builtin-unless-boxed' && representation.kind !== 'dynamic' && functionId !== null
|
|
174
|
+
? unboxedMethodAssumptionOf(input, functionId)
|
|
175
|
+
: null;
|
|
176
|
+
// `call` needs no census: the guard is a run-time read of the one Function
|
|
177
|
+
// object the call reaches, so it holds for a callable of unknown origin too
|
|
178
|
+
// -- only a boxed receiver, already a boxed Function object, is out, and it
|
|
179
|
+
// keeps the ordinary property read. `apply` is deliberately NOT taken here:
|
|
180
|
+
// its direct lowering range-copies the array into the callee's rest slot
|
|
181
|
+
// (`lowerDeferredFunctionApply`), where the `.apply` frame it would replace
|
|
182
|
+
// forwards the caller's array itself, and node-compat's `runListener` runs
|
|
183
|
+
// every listener through that one `fn.apply(this, args)` -- the copy is one
|
|
184
|
+
// allocation per listener call the driver never paid. The frame's aliasing
|
|
185
|
+
// is the older defect; the copy is not the fix for it without a callee-side
|
|
186
|
+
// proof that the rest array is neither written nor retained.
|
|
187
|
+
const shadowGuard = member === 'call' && resolution === 'builtin-unless-boxed' && representation.kind !== 'dynamic' ? member : null;
|
|
188
|
+
if (process.env.GEA_CALLABLE_FACTS_DEBUG)
|
|
189
|
+
console.error(`[deferred-callee] member=${member} functionId=${functionId} carrier=${representation.kind} resolution=${resolution}`);
|
|
190
|
+
if (resolution !== 'builtin' && unboxedMethod === null && shadowGuard === null)
|
|
170
191
|
return null;
|
|
171
192
|
// Read off the receiver's own carrier, which is what decides how the call
|
|
172
193
|
// renders -- see `DeferredCallee.frame`.
|
|
@@ -192,14 +213,18 @@ export const deferredCalleeOf = (input, operation) => {
|
|
|
192
213
|
? (input.abis.get(functionId) ?? null)
|
|
193
214
|
: null
|
|
194
215
|
: bindAbiOfCallableReceiver(representation);
|
|
195
|
-
return abi
|
|
216
|
+
return abi
|
|
217
|
+
? { member, receiver, abi, functionId, frame, receiverCarrier: representation, ...(unboxedMethod === null ? {} : { unboxedMethod }) }
|
|
218
|
+
: null;
|
|
196
219
|
}
|
|
197
220
|
if (functionId === null && representation.kind !== 'function-value-dispatch')
|
|
198
221
|
return null;
|
|
199
222
|
const abi = representation.kind === 'dynamic' && functionId !== null
|
|
200
223
|
? (input.abis.get(functionId) ?? null)
|
|
201
224
|
: callAbiOfCallableReceiver(representation);
|
|
202
|
-
return abi
|
|
225
|
+
return abi
|
|
226
|
+
? { member, receiver, abi, functionId, frame, receiverCarrier: representation, ...(shadowGuard === null ? {} : { shadowGuard }) }
|
|
227
|
+
: null;
|
|
203
228
|
};
|
|
204
229
|
/**
|
|
205
230
|
* `hasOwnProperty`/`propertyIsEnumerable` reached as instance methods off a
|
|
@@ -422,7 +447,11 @@ export const calleeRenderingOf = (input, operation) => {
|
|
|
422
447
|
: null;
|
|
423
448
|
if (held === null)
|
|
424
449
|
return 'template';
|
|
425
|
-
|
|
450
|
+
// A class extending `Promise` whose `then`/`catch`/`finally` is read off its
|
|
451
|
+
// native promise (`SemanticOperand.nativeBaseView`) is called as the
|
|
452
|
+
// promise's own member, exactly as a promise receiver is.
|
|
453
|
+
const nativeView = receiver.nativeBaseView === true ? input.deriver.derive(receiver.type) : null;
|
|
454
|
+
const view = nativeView?.kind === 'promise' ? nativeView : narrowedOperandView(held, receiver, input.deriver);
|
|
426
455
|
// A receiver with no storage (`undefined`/`null`, the carrier of a branch
|
|
427
456
|
// flow analysis proved dead) registers no template read at all, so the
|
|
428
457
|
// printer falls through to the callable path and the ABI's slots apply.
|
|
@@ -15,7 +15,11 @@ export const classPrototypeReadOf = (classes, receiver, key, value) => {
|
|
|
15
15
|
return null;
|
|
16
16
|
seen.add(declaration);
|
|
17
17
|
const ancestor = classes.get(declaration);
|
|
18
|
-
|
|
18
|
+
// A native collection base holds no field the prototype object could
|
|
19
|
+
// expose: its storage starts empty, exactly as every field of the
|
|
20
|
+
// prototype object starts absent. An Error base carries own fields
|
|
21
|
+
// (`message`, `stack`) the prototype would wrongly publish.
|
|
22
|
+
if (!ancestor || (ancestor.nativeBase !== null && ancestor.nativeBase.instance.kind !== 'keyed-collection'))
|
|
19
23
|
return null;
|
|
20
24
|
declaration = ancestor.base;
|
|
21
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DeclarationId, type FunctionId, type RegionId, type StructuralTypeId } from '../identity/ids.js';
|
|
2
2
|
import { type CallableAbi, type RecordField, type Representation } from '../representation/model.js';
|
|
3
3
|
import type { SealedRepresentationPlan } from '../representation/plan.js';
|
|
4
4
|
import type { RepresentationDeriver } from '../representation/derive.js';
|
|
@@ -54,6 +54,13 @@ export interface ClassFieldOwnership {
|
|
|
54
54
|
export interface ClassMethod {
|
|
55
55
|
readonly key: string;
|
|
56
56
|
readonly callable: FunctionId | null;
|
|
57
|
+
/**
|
|
58
|
+
* The census copy of a generic class whose evaluation installed this body
|
|
59
|
+
* (`decl|f0|36@2`), absent for a class that was never copied. A generic
|
|
60
|
+
* class's methods are one body per class copy, and a subclass overrides
|
|
61
|
+
* only the copy its own heritage names (`ClassLayout.baseCopies`).
|
|
62
|
+
*/
|
|
63
|
+
readonly publishedBy?: DeclarationId;
|
|
57
64
|
/** Convention of the installed method object, including its implicit receiver. */
|
|
58
65
|
readonly representation?: Representation;
|
|
59
66
|
/** Public mutable member frame, distinct from the original implementation's frame. */
|
|
@@ -116,11 +123,20 @@ export interface ClassLayout {
|
|
|
116
123
|
readonly prototypeBase?: true;
|
|
117
124
|
/** No evaluation can produce an instance of this class (`semantics/uninstantiable-classes.ts`). */
|
|
118
125
|
readonly uninstantiable?: true;
|
|
119
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* A built-in native class extended directly: the intrinsic Error family,
|
|
128
|
+
* whose instance is a native record, a standard keyed collection, whose
|
|
129
|
+
* instance is the runtime's own collection object, or the intrinsic
|
|
130
|
+
* `Promise`, whose instance is the runtime promise (`class-ref.nativeBase`).
|
|
131
|
+
*/
|
|
120
132
|
readonly nativeBase: {
|
|
121
133
|
readonly protocol: string;
|
|
122
134
|
readonly instance: Extract<Representation, {
|
|
123
135
|
readonly kind: 'native-record-ref';
|
|
136
|
+
} | {
|
|
137
|
+
readonly kind: 'keyed-collection';
|
|
138
|
+
} | {
|
|
139
|
+
readonly kind: 'promise';
|
|
124
140
|
}>;
|
|
125
141
|
} | null;
|
|
126
142
|
/** The convention `new` invokes, from the constructor object's own carrier. */
|
|
@@ -180,6 +196,15 @@ export interface ClassLayout {
|
|
|
180
196
|
* storage owner (`ir/class-static-fields.ts`'s `staticFieldOwnerOf`).
|
|
181
197
|
*/
|
|
182
198
|
readonly staticOwner?: DeclarationId;
|
|
199
|
+
/**
|
|
200
|
+
* For this class and each of its `copies`, the census copy its heritage
|
|
201
|
+
* names -- `Count extends Command<number>` names `Command@1`, whose own
|
|
202
|
+
* heritage names `Operation@1` -- where the base is a generic's copy.
|
|
203
|
+
* `base` is the physical class, which the copies of a class that does not
|
|
204
|
+
* split in layout all share, so it cannot say which copy of an inherited
|
|
205
|
+
* generic method an override replaces (`projection/dispatch.ts`).
|
|
206
|
+
*/
|
|
207
|
+
readonly baseCopies?: ReadonlyMap<DeclarationId, DeclarationId>;
|
|
183
208
|
}
|
|
184
209
|
/**
|
|
185
210
|
* The one class that owns the static storage behind these constructor-family
|
|
@@ -197,6 +222,30 @@ export declare const sharedStaticOwnerOf: (classes: ReadonlyMap<DeclarationId, C
|
|
|
197
222
|
* with no constructor-object carrier of its own was published.
|
|
198
223
|
*/
|
|
199
224
|
export declare const classLayoutOfCopy: (classes: ReadonlyMap<DeclarationId, ClassLayout>, copy: DeclarationId) => ClassLayout | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Whether a construct target naming `functionId` runs this layout's
|
|
227
|
+
* constructor.
|
|
228
|
+
*
|
|
229
|
+
* A `new` site's exact target is minted from the constructor DECLARATION, so
|
|
230
|
+
* it names the source function -- the root every copy is cut from -- while a
|
|
231
|
+
* generic class's layout names the copy body it kept. Every copy of one class
|
|
232
|
+
* that folds onto one struct keeps ONE body, so no per-copy spelling at the
|
|
233
|
+
* site could name it either: mongodb's `new FindCursor(...)` in
|
|
234
|
+
* `Collection.find` names `fn|decl|f166|167` against a layout whose seven
|
|
235
|
+
* copies kept `fn|decl|f166|167@6`, and exact equality read that as a
|
|
236
|
+
* contradictory implementation, left the construction open and pulled the
|
|
237
|
+
* whole cursor family into full reflection. A target that names a specific
|
|
238
|
+
* copy still has to name that copy.
|
|
239
|
+
*/
|
|
240
|
+
export declare const constructTargetNamesConstructorOf: (layout: ClassLayout, functionId: FunctionId) => boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Every layout whose constructor body is `constructor`, in the class map's own
|
|
243
|
+
* order. Emission asks this once per body and lowering once per construction,
|
|
244
|
+
* and each used to copy the whole class map into an array to filter it -- an
|
|
245
|
+
* O(classes) allocation per body over a program with tens of thousands of them.
|
|
246
|
+
* The size guard is the invalidation: a class map only grows while it is built.
|
|
247
|
+
*/
|
|
248
|
+
export declare const classLayoutsConstructedBy: (classes: ReadonlyMap<DeclarationId, ClassLayout>, constructor: FunctionId | RegionId | null) => readonly ClassLayout[];
|
|
200
249
|
/** Runtime class candidates exclude definitions retained solely for type layout. */
|
|
201
250
|
/** The class whose construction this class's construction runs first, which a prototype-only base is not. */
|
|
202
251
|
export declare const constructedBaseOf: (layout: Pick<ClassLayout, "base" | "prototypeBase">) => DeclarationId | null;
|
|
@@ -244,6 +293,8 @@ export interface ClassProjectionInput {
|
|
|
244
293
|
readonly deriver: RepresentationDeriver;
|
|
245
294
|
/** Classes no evaluation can instantiate (`semantics/uninstantiable-classes.ts`). */
|
|
246
295
|
readonly uninstantiable?: ReadonlySet<DeclarationId>;
|
|
296
|
+
/** Static fields whose storage is not their declared type alone (`RepresentationPublication.staticFieldCarriers`). */
|
|
297
|
+
readonly staticFieldCarriers?: ReadonlyMap<DeclarationId, Representation>;
|
|
247
298
|
}
|
|
248
299
|
/**
|
|
249
300
|
* Publish synthetic overlay ownership after specialization collapse.
|
|
@@ -281,3 +332,15 @@ export declare const projectClasses: (input: ClassProjectionInput) => ReadonlyMa
|
|
|
281
332
|
export declare const keyExcludesSymbols: (carrier: Representation) => boolean;
|
|
282
333
|
/** A write creates an own callable property without replacing its prototype declaration. */
|
|
283
334
|
export declare const publishClassMethodOverrides: (layouts: ReadonlyMap<DeclarationId, ClassLayout>, input: ClassProjectionInput) => ReadonlyMap<DeclarationId, ClassLayout>;
|
|
335
|
+
/**
|
|
336
|
+
* Whether an object literal can be laid out as this class without being its
|
|
337
|
+
* instance: TypeScript accepts `{ w: 0 }` where a `WriteConcern` is declared
|
|
338
|
+
* because a class type is structural, and mongodb writes exactly that. The
|
|
339
|
+
* literal takes the class's native layout but none of its behaviour, so the
|
|
340
|
+
* layout may be shared only where the class HAS no behaviour a read could
|
|
341
|
+
* reach -- no prototype method or accessor (the literal inherits neither), no
|
|
342
|
+
* field initializer (an instance's field starts from it, the literal's does
|
|
343
|
+
* not, and a lazily materialized arrow field would run it on first read), no
|
|
344
|
+
* native base, along the whole chain.
|
|
345
|
+
*/
|
|
346
|
+
export declare const isDataOnlyClass: (classes: ReadonlyMap<DeclarationId, ClassLayout>, declaration: DeclarationId) => boolean;
|