@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,19 +1,19 @@
|
|
|
1
1
|
import { callableCompletionSummaryOf } from './flow/callable-completions.js';
|
|
2
2
|
import ts from 'typescript';
|
|
3
|
-
import { isAmbientDeclaration } from '../ambient.js';
|
|
3
|
+
import { globalSymbolBehindModuleAmbientConst, isAmbientDeclaration, moduleAmbientGlobalSatisfiesDeclaration } from '../ambient.js';
|
|
4
4
|
import { unwrapErasedExpression } from './producers/erasure.js';
|
|
5
5
|
import { scriptGlobalValueRedefinitionOf } from './script-global-redefinition.js';
|
|
6
|
-
import { sourceClassDataMemberPlanOf } from './flow/source-class-data.js';
|
|
6
|
+
import { reflectiveDefinitionMayInstallGetterOf, sourceClassDataMemberPlanOf } from './flow/source-class-data.js';
|
|
7
7
|
import { sourceRecordSlotValuesOf } from './flow/source-record-data.js';
|
|
8
8
|
import { isRealCallableDeclaration, runtimeParametersOf } from './flow/targets.js';
|
|
9
|
-
import { seededOriginSolver } from './flow/seeded-origins.js';
|
|
10
|
-
import { closedCallableAuthorityOf } from './flow/callable-reach.js';
|
|
9
|
+
import { isVacuousOrigin, seededOriginSolver } from './flow/seeded-origins.js';
|
|
10
|
+
import { closedCallableAuthorityOf, closedValueOriginAuthorityOf } from './flow/callable-reach.js';
|
|
11
11
|
import { sourceConstructorSelectionsOf, sourceConstructorReturnValuesOf } from './flow/member-call-forwarding.js';
|
|
12
12
|
import { wholeProgram } from './reachability.js';
|
|
13
13
|
import { createPropertyKeyDomains } from './property-key-domain.js';
|
|
14
14
|
import { HostMutationTaint, everyKey, keySetTouches, namedKey, numericKeys } from './host-mutation-keys.js';
|
|
15
15
|
import { attachDeferredIntrinsicProtocolLedger, createDeferredIntrinsicProtocolLedger, deferredIntrinsicProtocolLedgerOf, failedIntrinsicProtocolRequirements } from './deferred-intrinsic-protocols.js';
|
|
16
|
-
import { symbolIsStandardLibraryMutator, symbolStatesHostInert,
|
|
16
|
+
import { symbolIsStandardLibraryMutator, symbolStatesHostInert, symbolWritesNoIntrinsicProperty } from './host-effect-contracts.js';
|
|
17
17
|
import { createMutationKeyReader, hostAccessorNamesOf, isProgramDeclaredSymbolKey, keyOfName } from './host-mutation-key-reader.js';
|
|
18
18
|
const staticKeyOf = (node) => {
|
|
19
19
|
if (ts.isPropertyAccessExpression(node))
|
|
@@ -102,7 +102,16 @@ declarationFiles = [],
|
|
|
102
102
|
* census only ever narrows a write's key through this; `null` keeps the
|
|
103
103
|
* key unknown.
|
|
104
104
|
*/
|
|
105
|
-
computedKeysOf = () => null,
|
|
105
|
+
computedKeysOf = () => null,
|
|
106
|
+
/**
|
|
107
|
+
* The outcome kind when this call is a checker-authenticated static
|
|
108
|
+
* CommonJS `require` the invocation producer lowers to a `commonjs-require`
|
|
109
|
+
* module-record operation (`staticRequireOutcomeOf`), else `null`. Such a
|
|
110
|
+
* call runs only a compiled module body, or nothing at all when it throws
|
|
111
|
+
* `MODULE_NOT_FOUND` for a package absent from the build; see
|
|
112
|
+
* `unknownCalleeStampIsNarrowed` and the alias graph's call rule.
|
|
113
|
+
*/
|
|
114
|
+
staticCommonJsRequireOutcomeOf = () => null, trustSeed = initialCensusSeed) => {
|
|
106
115
|
const tainted = new HostMutationTaint();
|
|
107
116
|
// Every intrinsic member name this run trusted, and every key its visit
|
|
108
117
|
// wrote on a surface, a global binding or an intrinsic object: see
|
|
@@ -949,13 +958,20 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
949
958
|
};
|
|
950
959
|
});
|
|
951
960
|
const hasFreshLiteralIdentity = (expression) => freshLiteralOrigin(expression) === 'allocated';
|
|
952
|
-
|
|
961
|
+
/**
|
|
962
|
+
* `byType` admits the structural fallback: a receiver whose static type a
|
|
963
|
+
* native receiver type is assignable to, or from, may be that native object
|
|
964
|
+
* (or its intrinsic prototype, which the standard library types as an
|
|
965
|
+
* instance). Without it the answer is identity only -- the global object, a
|
|
966
|
+
* standard-library binding, or a local cell some write fills with one.
|
|
967
|
+
*/
|
|
968
|
+
const isIntrinsicSurface = (expression, seen = new Set(), byType = true) => {
|
|
953
969
|
const current = unwrapErasedExpression(expression);
|
|
954
970
|
if (hasFreshLiteralIdentity(current))
|
|
955
971
|
return false;
|
|
956
972
|
if (isProvenGlobalObject(current) ||
|
|
957
|
-
|
|
958
|
-
|
|
973
|
+
(byType &&
|
|
974
|
+
(nativeResult(checker.getTypeAtLocation(current), current) || mayBeAuthenticatedNativeSurface(checker.getTypeAtLocation(current))))) {
|
|
959
975
|
return true;
|
|
960
976
|
}
|
|
961
977
|
if (ts.isIdentifier(current)) {
|
|
@@ -970,12 +986,12 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
970
986
|
return flow
|
|
971
987
|
.writesToDeclaration(declaration)
|
|
972
988
|
.filter((write) => flowSiteIsReachable(write.site) && write.slot === 'whole' && write.value !== null)
|
|
973
|
-
.some((write) => isIntrinsicSurface(write.value, next));
|
|
989
|
+
.some((write) => isIntrinsicSurface(write.value, next, byType));
|
|
974
990
|
}
|
|
975
991
|
if (!ts.isPropertyAccessExpression(current) && !ts.isElementAccessExpression(current))
|
|
976
992
|
return false;
|
|
977
993
|
if (staticKeyOf(current) === 'prototype')
|
|
978
|
-
return isIntrinsicSurface(current.expression, seen);
|
|
994
|
+
return isIntrinsicSurface(current.expression, seen, byType);
|
|
979
995
|
const symbol = memberSymbolOf(current);
|
|
980
996
|
return isProvenGlobalObject(current.expression) && !!symbol && hasStandardLibraryDeclaration(symbol);
|
|
981
997
|
};
|
|
@@ -1035,11 +1051,44 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
1035
1051
|
for (const key of keys)
|
|
1036
1052
|
tainted.taintObject(id, key);
|
|
1037
1053
|
};
|
|
1038
|
-
|
|
1054
|
+
/**
|
|
1055
|
+
* A write of an unknown key through a receiver only the STRUCTURAL fallback
|
|
1056
|
+
* places on an intrinsic surface -- bson's `obj: Record<string, unknown> =
|
|
1057
|
+
* Object.create(null)`, the driver's `dest: Document` -- is decided after
|
|
1058
|
+
* the alias graph, not here. `Document`'s `[key: string]: any` accepts every
|
|
1059
|
+
* object type, so the type test says yes for every such receiver; only the
|
|
1060
|
+
* value's provenance can say no, and the provenance proof
|
|
1061
|
+
* (`isFreshProgramObject` below) needs the closed caller frames and source
|
|
1062
|
+
* invocation facts this pass runs before. Until then this run assumes the
|
|
1063
|
+
* write is harmless, and the census re-runs with every intrinsic distrusted
|
|
1064
|
+
* from the start if the proof does not close -- the same fixed point
|
|
1065
|
+
* `CensusSeed` already runs for every other assumption made here.
|
|
1066
|
+
*
|
|
1067
|
+
* A receiver that IS an intrinsic by identity (a standard global, the global
|
|
1068
|
+
* object, a cell holding one) is not deferred: nothing downstream could
|
|
1069
|
+
* clear it, and a re-run would only cost the time.
|
|
1070
|
+
*/
|
|
1071
|
+
const deferredSurfaceWrites = [];
|
|
1072
|
+
const invalidateForSurfaceWrite = (receiver, site) => {
|
|
1073
|
+
if (allIntrinsicTrustInvalidated)
|
|
1074
|
+
return;
|
|
1075
|
+
if (isIntrinsicSurface(receiver, new Set(), false))
|
|
1076
|
+
invalidateAllIntrinsicTrust(site);
|
|
1077
|
+
else
|
|
1078
|
+
deferredSurfaceWrites.push(receiver);
|
|
1079
|
+
};
|
|
1080
|
+
/**
|
|
1081
|
+
* `Object.defineProperty(o, kDecorated, ...)` with a program-declared unique
|
|
1082
|
+
* symbol: the same argument `isDefinitelyProgramSymbolElementKey` makes for
|
|
1083
|
+
* `o[sym] = v`. The key names no string member and is not `__proto__`, so
|
|
1084
|
+
* whatever `o` is, it replaces no intrinsic member a static call resolves to.
|
|
1085
|
+
*/
|
|
1086
|
+
const isProgramSymbolKeyExpression = (expression) => expression !== undefined && isProgramDeclaredSymbolKey(publishedTypeAt(unwrapErasedExpression(expression)));
|
|
1087
|
+
const markOverwrittenMember = (target, key, keyExpression) => {
|
|
1039
1088
|
markIntrinsicPrototypeKeys(target, key === null ? [everyKey] : [key === '__proto__' ? everyKey : namedKey(key)]);
|
|
1040
1089
|
if (key === null) {
|
|
1041
|
-
if (isIntrinsicSurface(target))
|
|
1042
|
-
|
|
1090
|
+
if (!isProgramSymbolKeyExpression(keyExpression) && isIntrinsicSurface(target))
|
|
1091
|
+
invalidateForSurfaceWrite(target, target);
|
|
1043
1092
|
return;
|
|
1044
1093
|
}
|
|
1045
1094
|
const symbol = actualSymbol(checker.getPropertyOfType(checker.getTypeAtLocation(target), key));
|
|
@@ -1089,7 +1138,7 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
1089
1138
|
// A prototype replacement can affect every method, regardless of its
|
|
1090
1139
|
// name. Other computed writes invalidate only the names they can reach.
|
|
1091
1140
|
if (domain === null || propertyKeyDomains.mayName(domain, '__proto__') || propertyKeyDomains.mayName(domain, 'prototype'))
|
|
1092
|
-
|
|
1141
|
+
invalidateForSurfaceWrite(node.expression, node);
|
|
1093
1142
|
else
|
|
1094
1143
|
computedIntrinsicKeys.add(domain);
|
|
1095
1144
|
}
|
|
@@ -1108,7 +1157,7 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
1108
1157
|
mutator === 'Reflect.set' ||
|
|
1109
1158
|
mutator === 'Reflect.deleteProperty') {
|
|
1110
1159
|
const key = node.arguments[1] ? staticKeyExpression(node.arguments[1]) : null;
|
|
1111
|
-
markOverwrittenMember(target, key);
|
|
1160
|
+
markOverwrittenMember(target, key, node.arguments[1]);
|
|
1112
1161
|
}
|
|
1113
1162
|
else if (mutator === 'Object.assign' || mutator === 'Object.defineProperties') {
|
|
1114
1163
|
const sources = mutator === 'Object.assign' ? node.arguments.slice(1) : node.arguments.slice(1, 2);
|
|
@@ -1223,6 +1272,60 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
1223
1272
|
const summary = callableCompletionSummaryOf(flow, declaration);
|
|
1224
1273
|
return summary === null ? [] : [...summary.values, ...summary.yields];
|
|
1225
1274
|
};
|
|
1275
|
+
/**
|
|
1276
|
+
* `new Proxy( target, handler )` with the standard `Proxy`, a handler that
|
|
1277
|
+
* is an object literal of program traps, and only the traps whose effect
|
|
1278
|
+
* this census can state: `set`/`has`/`deleteProperty` run program code
|
|
1279
|
+
* (censused where it is written) and hand back only a boolean, and `get`
|
|
1280
|
+
* hands back its own return values. Every other operation forwards to the
|
|
1281
|
+
* target. So the proxy is exactly its target plus the `get` trap's results
|
|
1282
|
+
* -- never the global object, never a host object -- which is what the alias
|
|
1283
|
+
* graph records (`AliasTerm` `proxy`). Anything else keeps the ordinary
|
|
1284
|
+
* `new` rule: a library constructor with no body is opaque.
|
|
1285
|
+
*
|
|
1286
|
+
* mongodb's optional-dependency stub (`makeErrorModule` in `deps.ts`) is
|
|
1287
|
+
* one: a proxy over `{ kModuleError }` whose `get` trap throws.
|
|
1288
|
+
*/
|
|
1289
|
+
const proxyConstructorSymbol = (() => {
|
|
1290
|
+
const anchor = files[0];
|
|
1291
|
+
const symbol = anchor ? checker.resolveName('Proxy', anchor, ts.SymbolFlags.Value, false) : undefined;
|
|
1292
|
+
return symbol && hasStandardLibraryDeclaration(symbol) ? symbol : null;
|
|
1293
|
+
})();
|
|
1294
|
+
const programProxyTraps = new Set(['get', 'set', 'has', 'deleteProperty']);
|
|
1295
|
+
const programProxyOf = (construct) => {
|
|
1296
|
+
const callee = unwrapErasedExpression(construct.expression);
|
|
1297
|
+
if (proxyConstructorSymbol === null || allIntrinsicTrustInvalidated || !ts.isIdentifier(callee))
|
|
1298
|
+
return null;
|
|
1299
|
+
if (actualSymbol(checker.getSymbolAtLocation(callee)) !== proxyConstructorSymbol ||
|
|
1300
|
+
intrinsicSymbolIsOverwritten(proxyConstructorSymbol))
|
|
1301
|
+
return null;
|
|
1302
|
+
const [target, handler] = construct.arguments ?? [];
|
|
1303
|
+
if (construct.arguments?.length !== 2 || !target || !handler || ts.isSpreadElement(target) || ts.isSpreadElement(handler))
|
|
1304
|
+
return null;
|
|
1305
|
+
const literal = unwrapErasedExpression(handler);
|
|
1306
|
+
if (!ts.isObjectLiteralExpression(literal))
|
|
1307
|
+
return null;
|
|
1308
|
+
const reads = [];
|
|
1309
|
+
for (const property of literal.properties) {
|
|
1310
|
+
const name = ts.isMethodDeclaration(property) || ts.isPropertyAssignment(property) ? staticPropertyName(property.name) : null;
|
|
1311
|
+
if (name === null || !programProxyTraps.has(name))
|
|
1312
|
+
return null;
|
|
1313
|
+
const initializer = ts.isPropertyAssignment(property) ? unwrapErasedExpression(property.initializer) : null;
|
|
1314
|
+
const trap = ts.isMethodDeclaration(property)
|
|
1315
|
+
? property
|
|
1316
|
+
: initializer !== null && (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer))
|
|
1317
|
+
? initializer
|
|
1318
|
+
: null;
|
|
1319
|
+
if (trap === null || trap.asteriskToken !== undefined)
|
|
1320
|
+
return null;
|
|
1321
|
+
const summary = callableCompletionSummaryOf(flow, trap);
|
|
1322
|
+
if (summary === null || summary.execution !== 'sync')
|
|
1323
|
+
return null;
|
|
1324
|
+
if (name === 'get')
|
|
1325
|
+
reads.push(...summary.values);
|
|
1326
|
+
}
|
|
1327
|
+
return { target, reads };
|
|
1328
|
+
};
|
|
1226
1329
|
const publishedTypeRepresentation = (type, location) => primitiveResult(type) ? 'primitive' : nativeResult(type, location) ? 'native' : representedObjectResult(type) ? 'object' : null;
|
|
1227
1330
|
// An object-shaped result type is evidence only at an authenticated call
|
|
1228
1331
|
// boundary. It is never value provenance by itself: an annotation or cast
|
|
@@ -1997,11 +2100,14 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
1997
2100
|
const facts = declaration === null ? undefined : mutatorAliases.get(declaration);
|
|
1998
2101
|
return facts !== undefined && (facts.size !== 1 || facts.has('UNKNOWN'));
|
|
1999
2102
|
};
|
|
2000
|
-
const invalidateIntrinsicMember = (target, key) => {
|
|
2103
|
+
const invalidateIntrinsicMember = (target, key, keyExpression) => {
|
|
2001
2104
|
if (!isIntrinsicSurface(target) && !standardGlobalValue(target))
|
|
2002
2105
|
return;
|
|
2003
2106
|
if (key === null) {
|
|
2004
|
-
|
|
2107
|
+
if (standardGlobalValue(target))
|
|
2108
|
+
invalidateAllIntrinsicTrust(target);
|
|
2109
|
+
else if (!isProgramSymbolKeyExpression(keyExpression))
|
|
2110
|
+
invalidateForSurfaceWrite(target, target);
|
|
2005
2111
|
return;
|
|
2006
2112
|
}
|
|
2007
2113
|
markOverwrittenMember(target, key);
|
|
@@ -2030,7 +2136,7 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
2030
2136
|
mutator === 'Reflect.defineProperty' ||
|
|
2031
2137
|
mutator === 'Reflect.set' ||
|
|
2032
2138
|
mutator === 'Reflect.deleteProperty') {
|
|
2033
|
-
invalidateIntrinsicMember(target, node.arguments[1] ? staticKeyExpression(node.arguments[1]) : null);
|
|
2139
|
+
invalidateIntrinsicMember(target, node.arguments[1] ? staticKeyExpression(node.arguments[1]) : null, node.arguments[1]);
|
|
2034
2140
|
}
|
|
2035
2141
|
else if (mutator === 'Object.assign') {
|
|
2036
2142
|
for (const source of node.arguments.slice(1))
|
|
@@ -3466,6 +3572,13 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
3466
3572
|
node.seeds.add(opaqueTerm);
|
|
3467
3573
|
return;
|
|
3468
3574
|
}
|
|
3575
|
+
// `require( 'optional-peer' )` of a package absent from the build never
|
|
3576
|
+
// completes normally: the backend throws `MODULE_NOT_FOUND` in its place
|
|
3577
|
+
// (`gea::commonjs::absentPackage`). It hands its binding no value at all,
|
|
3578
|
+
// so it contributes no origin -- the `catch` arm's value is the only one
|
|
3579
|
+
// mongodb's `getGcpMetadata()` can return.
|
|
3580
|
+
if (staticCommonJsRequireOutcomeOf(current) === 'absent-package')
|
|
3581
|
+
return;
|
|
3469
3582
|
const call = reachableCallOfNode.get(current);
|
|
3470
3583
|
const declaration = executableDeclarationOf(callDeclarationAt(current));
|
|
3471
3584
|
const body = declaration && ts.isFunctionLike(declaration) ? declaration.body : undefined;
|
|
@@ -3475,6 +3588,21 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
3475
3588
|
// carrier. The result is not an identity copy of the property lookup:
|
|
3476
3589
|
// receiver-sensitive calls were refused before this point unless the
|
|
3477
3590
|
// receiver itself had non-global provenance.
|
|
3591
|
+
//
|
|
3592
|
+
// When the call's callee set is CLOSED -- every frame the shared
|
|
3593
|
+
// invocation proof admits returns only values it names -- those values
|
|
3594
|
+
// are the result's whole origin, so the result carries theirs and
|
|
3595
|
+
// nothing else: no represented-but-unplaced marker a consumer would have
|
|
3596
|
+
// to read as "possibly anything" (`unknownCalleeStampIsNarrowed`'s
|
|
3597
|
+
// receiver rule is one).
|
|
3598
|
+
const frames = representation === 'object' && sourceFrameOwnedCalls.has(current) ? sourceInvocationFacts.get(current)?.frames : undefined;
|
|
3599
|
+
if (frames && frames.length > 0 && frames.every((frame) => frame.completions.kind === 'values')) {
|
|
3600
|
+
for (const frame of frames)
|
|
3601
|
+
if (frame.completions.kind === 'values')
|
|
3602
|
+
for (const value of frame.completions.values)
|
|
3603
|
+
link(valueNodeOf(value), node);
|
|
3604
|
+
return;
|
|
3605
|
+
}
|
|
3478
3606
|
node.seeds.add(representedNonGlobalTerm);
|
|
3479
3607
|
if (representation === 'object' && declaration && !declaration.getSourceFile().isDeclarationFile && body) {
|
|
3480
3608
|
for (const returned of observableCompletionValuesOf(declaration))
|
|
@@ -3502,6 +3630,12 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
3502
3630
|
return;
|
|
3503
3631
|
}
|
|
3504
3632
|
if (ts.isNewExpression(current)) {
|
|
3633
|
+
const proxy = programProxyOf(current);
|
|
3634
|
+
if (proxy !== null) {
|
|
3635
|
+
link(valueNodeOf(proxy.target), node);
|
|
3636
|
+
node.seeds.add({ kind: 'proxy', reads: proxy.reads.map(valueNodeOf) });
|
|
3637
|
+
return;
|
|
3638
|
+
}
|
|
3505
3639
|
const constructionReturns = sourceConstructionReturnsOf(current.expression);
|
|
3506
3640
|
for (const value of constructionReturns ?? [])
|
|
3507
3641
|
link(valueNodeOf(value), node);
|
|
@@ -4014,6 +4148,22 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
4014
4148
|
addTerm(target, globalTerm);
|
|
4015
4149
|
return;
|
|
4016
4150
|
}
|
|
4151
|
+
if (term.kind === 'proxy') {
|
|
4152
|
+
// Every key read runs the `get` trap when there is one, so any read
|
|
4153
|
+
// (and anything reachable from one) may be a trap result. Without the
|
|
4154
|
+
// trap a read forwards to the target, whose terms this proxy's node
|
|
4155
|
+
// already carries.
|
|
4156
|
+
for (const value of term.reads) {
|
|
4157
|
+
const source = componentOf.get(value);
|
|
4158
|
+
if (!source)
|
|
4159
|
+
throw new Error('global-host mutation proxy read was not condensed');
|
|
4160
|
+
if (selector.key === null)
|
|
4161
|
+
addSelector(source, null, target, childModeOf(selector.mode));
|
|
4162
|
+
else
|
|
4163
|
+
addFlow(source, target);
|
|
4164
|
+
}
|
|
4165
|
+
return;
|
|
4166
|
+
}
|
|
4017
4167
|
if (term.kind === 'source-containment') {
|
|
4018
4168
|
if (selector.key === null) {
|
|
4019
4169
|
for (const value of selector.mode === 'copied-reachable' ? term.ownValues : term.values) {
|
|
@@ -4759,7 +4909,7 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
4759
4909
|
addExpression(write.source);
|
|
4760
4910
|
continue;
|
|
4761
4911
|
}
|
|
4762
|
-
if (term.kind === 'rest') {
|
|
4912
|
+
if (term.kind === 'rest' || term.kind === 'proxy') {
|
|
4763
4913
|
unknown = true;
|
|
4764
4914
|
continue;
|
|
4765
4915
|
}
|
|
@@ -5165,7 +5315,31 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5165
5315
|
// the intrinsics its arguments reach", so the narrower contract answers it
|
|
5166
5316
|
// as completely as the full one. `authenticatedCalleeIdentity` still asks
|
|
5167
5317
|
// for `@gea-host-inert`, because retention and re-entry matter there.
|
|
5168
|
-
|
|
5318
|
+
// The typed-array-element contract answers it too: a store into a typed
|
|
5319
|
+
// array's element storage puts no key on any intrinsic
|
|
5320
|
+
// (`host-effect-contracts.ts`).
|
|
5321
|
+
if (symbolWritesNoIntrinsicProperty(symbol))
|
|
5322
|
+
return null;
|
|
5323
|
+
// A module-scoped `declare const atob: ...` is not a host native of its
|
|
5324
|
+
// own: no module binding exists at run time, and its linkage name is the
|
|
5325
|
+
// global's (`globalSymbolBehindModuleAmbientConst`). Binding placement
|
|
5326
|
+
// resolves that name through the installed host's tables BEFORE the
|
|
5327
|
+
// standard-library fallback, and the fallback is gated on the
|
|
5328
|
+
// standard-library declaration, so the local declaration reaches either
|
|
5329
|
+
// the very host binding the global declaration reaches, or none (an
|
|
5330
|
+
// unresolved external, which does not link). So the global's stated
|
|
5331
|
+
// contract is exactly the one that covers it. A global stating no
|
|
5332
|
+
// contract keeps the refusal: the local is then as unknown as the global.
|
|
5333
|
+
//
|
|
5334
|
+
// Only when the global SATISFIES the module's declaration -- the one
|
|
5335
|
+
// condition under which the declaration is blanked and the name really is
|
|
5336
|
+
// the global (`withoutModuleAmbientGlobalRedeclarations`). A module's
|
|
5337
|
+
// `declare const external: (value: unknown) => void` is unrelated to
|
|
5338
|
+
// lib.dom's `declare var external: External` that merely shares the
|
|
5339
|
+
// spelling; borrowing that global's contract made a callable no source
|
|
5340
|
+
// file defines look inert.
|
|
5341
|
+
const global = globalSymbolBehindModuleAmbientConst(checker, symbol);
|
|
5342
|
+
if (global !== null && moduleAmbientGlobalSatisfiesDeclaration(checker, symbol, global) && symbolWritesNoIntrinsicProperty(global))
|
|
5169
5343
|
return null;
|
|
5170
5344
|
const ambient = declarations.filter((declaration) => isAmbientDeclaration(declaration) || declaration.getSourceFile().isDeclarationFile);
|
|
5171
5345
|
if (ambient.length === 0 || ambient.length !== declarations.length)
|
|
@@ -5275,6 +5449,17 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5275
5449
|
return true;
|
|
5276
5450
|
if (ts.isExpressionWithTypeArguments(parent) && ts.isHeritageClause(parent.parent))
|
|
5277
5451
|
return true;
|
|
5452
|
+
// `encrypted.sort = sort`: a plain store to (or `delete` of) a member
|
|
5453
|
+
// never performs [[Get]] on it, so the library callable that member names
|
|
5454
|
+
// on the receiver's type is not read, let alone handed out. A compound or
|
|
5455
|
+
// logical assignment reads first, and stays a value position.
|
|
5456
|
+
if (ts.isPropertyAccessExpression(parent) && parent.name === node) {
|
|
5457
|
+
const outer = parent.parent;
|
|
5458
|
+
if (ts.isBinaryExpression(outer) && outer.left === parent && outer.operatorToken.kind === ts.SyntaxKind.EqualsToken)
|
|
5459
|
+
return true;
|
|
5460
|
+
if (ts.isDeleteExpression(outer) && outer.expression === parent)
|
|
5461
|
+
return true;
|
|
5462
|
+
}
|
|
5278
5463
|
return false;
|
|
5279
5464
|
};
|
|
5280
5465
|
/**
|
|
@@ -5291,10 +5476,13 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5291
5476
|
* `toString`/`subarray`, whose implementation is the native carrier -- is
|
|
5292
5477
|
* not, and keeps needing a stated contract.
|
|
5293
5478
|
*/
|
|
5294
|
-
const ambientCallableIsProgramSupplied = (symbol) => {
|
|
5479
|
+
const ambientCallableIsProgramSupplied = (symbol, seen = new Set()) => {
|
|
5295
5480
|
const declaration = symbol.declarations?.[0];
|
|
5296
5481
|
if (!declaration)
|
|
5297
5482
|
return false;
|
|
5483
|
+
const inherited = classChainMemberOfMergedSignature(symbol);
|
|
5484
|
+
if (inherited !== undefined)
|
|
5485
|
+
return inherited !== null && !seen.has(inherited) && ambientCallableIsProgramSupplied(inherited, new Set([...seen, symbol]));
|
|
5298
5486
|
const signatures = checker.getSignaturesOfType(checker.getTypeOfSymbolAtLocation(symbol, declaration), ts.SignatureKind.Call);
|
|
5299
5487
|
return (signatures.length > 0 &&
|
|
5300
5488
|
signatures.every((signature) => {
|
|
@@ -5304,6 +5492,41 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5304
5492
|
supplied.body !== undefined);
|
|
5305
5493
|
}));
|
|
5306
5494
|
};
|
|
5495
|
+
/**
|
|
5496
|
+
* mongodb's `export declare interface TypedEventEmitter<E> extends
|
|
5497
|
+
* EventEmitter { listeners(...): E[K][] }` merged into `export class
|
|
5498
|
+
* TypedEventEmitter<E> extends EventEmitter {}`. A method signature on an
|
|
5499
|
+
* interface puts no value anywhere: at run time `emitter.listeners` is
|
|
5500
|
+
* whatever the class's prototype chain holds -- the class's own member of
|
|
5501
|
+
* that name, else its base class's. So the signature is answered for by
|
|
5502
|
+
* that member, and a base whose method has a body in this program is
|
|
5503
|
+
* program code like any other.
|
|
5504
|
+
*
|
|
5505
|
+
* `undefined`: not such a signature, answer for the symbol itself. `null`:
|
|
5506
|
+
* it is one, and nothing on the chain names the member -- it is supplied
|
|
5507
|
+
* some other way, so it is not program code.
|
|
5508
|
+
*/
|
|
5509
|
+
const classChainMemberOfMergedSignature = (symbol) => {
|
|
5510
|
+
const declarations = symbol.declarations ?? [];
|
|
5511
|
+
if (declarations.length === 0 || !declarations.every((node) => ts.isMethodSignature(node) && ts.isInterfaceDeclaration(node.parent)))
|
|
5512
|
+
return undefined;
|
|
5513
|
+
const owners = new Set(declarations.map((node) => checker.getSymbolAtLocation(node.parent.name)));
|
|
5514
|
+
const [owner] = owners;
|
|
5515
|
+
if (owners.size !== 1 || !owner)
|
|
5516
|
+
return undefined;
|
|
5517
|
+
const classDeclarations = (owner.declarations ?? []).filter(ts.isClassDeclaration);
|
|
5518
|
+
const classDeclaration = classDeclarations[0];
|
|
5519
|
+
if (classDeclarations.length !== 1 || !classDeclaration || classDeclaration.getSourceFile().isDeclarationFile)
|
|
5520
|
+
return undefined;
|
|
5521
|
+
const name = symbol.getName();
|
|
5522
|
+
const own = classDeclaration.members.find((member) => member.name !== undefined && ts.isIdentifier(member.name) && member.name.text === name);
|
|
5523
|
+
if (own)
|
|
5524
|
+
return own.name ? (actualSymbol(checker.getSymbolAtLocation(own.name)) ?? null) : null;
|
|
5525
|
+
const base = classDeclaration.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0];
|
|
5526
|
+
if (!base)
|
|
5527
|
+
return null;
|
|
5528
|
+
return actualSymbol(checker.getTypeAtLocation(base).getProperty(name)) ?? null;
|
|
5529
|
+
};
|
|
5307
5530
|
const forwardingLibraryMember = (node, symbol) => FORWARDING_MEMBERS.has(node.text) && hasStandardLibraryDeclaration(symbol);
|
|
5308
5531
|
const returnHandsBackCallable = (declaration) => {
|
|
5309
5532
|
if (!ts.isFunctionLike(declaration))
|
|
@@ -5435,6 +5658,43 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5435
5658
|
return stampRefusal('eval-or-function-callee');
|
|
5436
5659
|
if (untaggedHostCallableEscapesAsValue())
|
|
5437
5660
|
return stampRefusal('host-callable-escapes-as-value');
|
|
5661
|
+
// A static CommonJS `require( 'x' )` is not a call of the ambient
|
|
5662
|
+
// `require` declaration at all. The producer lowers it to a
|
|
5663
|
+
// `commonjs-require` operation with NO operands -- the specifier is
|
|
5664
|
+
// resolved at compile time -- which the backend spells as a call of the
|
|
5665
|
+
// target module's own generated initializer. So nothing this call's
|
|
5666
|
+
// argument reaches is handed to any code (and a string literal carries no
|
|
5667
|
+
// object), and the only code it runs is a compiled module body, whose
|
|
5668
|
+
// writes this census reads in that module's own file, exactly as for any
|
|
5669
|
+
// other program body. What it returns is that module's exports record,
|
|
5670
|
+
// which the alias graph handles as the call's result, not here. A require
|
|
5671
|
+
// of a package absent from the build runs no code at all: it throws a
|
|
5672
|
+
// fresh `Error` carrying `code: 'MODULE_NOT_FOUND'` and nothing else. A require
|
|
5673
|
+
// the producer does NOT lower that way -- a possibly reassigned or
|
|
5674
|
+
// unauthenticated loader, a computed specifier, an unresolved one --
|
|
5675
|
+
// falls through and keeps the host-native refusal.
|
|
5676
|
+
if (staticCommonJsRequireOutcomeOf(call) !== null)
|
|
5677
|
+
return true;
|
|
5678
|
+
// A method read off a receiver that is no host object cannot BE an
|
|
5679
|
+
// untagged host native. The escape check above already proved no such
|
|
5680
|
+
// native is ever held as a value, so the only way to reach one is to read
|
|
5681
|
+
// it off a host object -- and every host object enters this graph opaque
|
|
5682
|
+
// (a bodiless call or construction, a declaration-file value, a class
|
|
5683
|
+
// chain that is not source-owned). A receiver whose provenance is only
|
|
5684
|
+
// program allocations reads program values or library members. mongodb's
|
|
5685
|
+
// `gcpMetadata.instance( ... )` is typed by the types-only `gcp-metadata`
|
|
5686
|
+
// declarations, but the value is `getGcpMetadata()`'s: the absent
|
|
5687
|
+
// package's `require` throws, and the `catch` hands back a program proxy.
|
|
5688
|
+
// Represented and intrinsic receivers keep the declaration's answer.
|
|
5689
|
+
const calleeRead = unwrapErasedExpression(call.expression);
|
|
5690
|
+
if (ts.isPropertyAccessExpression(calleeRead) || ts.isElementAccessExpression(calleeRead)) {
|
|
5691
|
+
const receiver = aliasFacts(calleeRead.expression);
|
|
5692
|
+
if (!receiver.opaque && !receiver.global && !receiver.represented && receiver.prototypes.size === 0)
|
|
5693
|
+
return true;
|
|
5694
|
+
if (process.env['GEA_DEBUG_GLOBAL_MUTATION'])
|
|
5695
|
+
debugSite(call, `callee receiver may be a host object: opaque=${receiver.opaque} global=${receiver.global} ` +
|
|
5696
|
+
`represented=${receiver.represented} intrinsics=${receiver.prototypes.size}`);
|
|
5697
|
+
}
|
|
5438
5698
|
// Kept only as a fast path over the whole-program predicate: a callee
|
|
5439
5699
|
// spelled as an untagged ambient bodiless declaration is a host native
|
|
5440
5700
|
// outright, with no cell in between. It must not be the gate -- see
|
|
@@ -5475,7 +5735,14 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5475
5735
|
// An untagged HOST native keeps `every`: its writes are in no source file,
|
|
5476
5736
|
// so `visitWrittenKeys` bounds nothing about it. That is the whole of the
|
|
5477
5737
|
// per-declaration contract's job.
|
|
5478
|
-
|
|
5738
|
+
if (library || supplied)
|
|
5739
|
+
return true;
|
|
5740
|
+
// The site, not only the per-name count: `require` alone is ten calls of
|
|
5741
|
+
// two different kinds (static module records and dynamic loads), and
|
|
5742
|
+
// only the site says which one is still refusing.
|
|
5743
|
+
if (process.env['GEA_DEBUG_GLOBAL_MUTATION'])
|
|
5744
|
+
debugSite(call, `refused callee-is-host-native ${row}`);
|
|
5745
|
+
return stampRefusal('callee-is-host-native');
|
|
5479
5746
|
};
|
|
5480
5747
|
/**
|
|
5481
5748
|
* Objects an unauthenticated call reached with a narrowed stamp, held until
|
|
@@ -5913,6 +6180,395 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5913
6180
|
}
|
|
5914
6181
|
ts.forEachChild(node, visit);
|
|
5915
6182
|
};
|
|
6183
|
+
/**
|
|
6184
|
+
* Can this receiver hold only ordinary objects THIS program allocated, or
|
|
6185
|
+
* no object at all? The proof a deferred surface write (see
|
|
6186
|
+
* `invalidateForSurfaceWrite`) needs.
|
|
6187
|
+
*
|
|
6188
|
+
* Soundness. An intrinsic object -- a constructor, a namespace, a
|
|
6189
|
+
* prototype, the global object -- and a native (host-carried) instance
|
|
6190
|
+
* enter a program only as values: a standard-library binding, a host call
|
|
6191
|
+
* result, a native allocation. None of those is a seed below, and every
|
|
6192
|
+
* other node must enumerate ALL of its values or refuse:
|
|
6193
|
+
*
|
|
6194
|
+
* - a literal, and `Object.create(p)`, allocate a fresh ordinary object;
|
|
6195
|
+
* `Object.assign(t, ...)` returns `t`. Both calls are trusted by name
|
|
6196
|
+
* through `intrinsicSymbolIsOverwritten`, so a program that replaces
|
|
6197
|
+
* either is re-run with that name distrusted.
|
|
6198
|
+
* - a local binding holds its complete reachable whole writes; `x += y`
|
|
6199
|
+
* always stores a primitive.
|
|
6200
|
+
* - a parameter holds its closed caller frame
|
|
6201
|
+
* (`enumeratedParameterValuesOf`, which fails closed for an escaping,
|
|
6202
|
+
* exported or `arguments`-reading callable, and whose intrinsic
|
|
6203
|
+
* requirements join the invocation ledger this census validates).
|
|
6204
|
+
* - a source call returns its closed frames' normal completions.
|
|
6205
|
+
* - a property read holds its slot's complete stored values
|
|
6206
|
+
* (`closedValueOriginAuthorityOf(...).fieldValuesOf`, the shared
|
|
6207
|
+
* closed-slot proof; its requirements join the same ledger).
|
|
6208
|
+
* - a primitive, `null`/`undefined`, or a never-reassigned identifier read
|
|
6209
|
+
* under its own `typeof x === '<primitive>'` guard is no object at all.
|
|
6210
|
+
*
|
|
6211
|
+
* A write through such a receiver creates or replaces an own property of a
|
|
6212
|
+
* program allocation. It cannot replace a member of any intrinsic, so no
|
|
6213
|
+
* static intrinsic callee selection depends on it. Everything else --
|
|
6214
|
+
* property reads, `this`, host results, casts from `any` -- refuses.
|
|
6215
|
+
*/
|
|
6216
|
+
const objectConstructorSymbol = (() => {
|
|
6217
|
+
const anchor = files[0];
|
|
6218
|
+
const symbol = anchor ? checker.resolveName('Object', anchor, ts.SymbolFlags.Value, false) : undefined;
|
|
6219
|
+
return symbol && hasStandardLibraryDeclaration(symbol) ? symbol : null;
|
|
6220
|
+
})();
|
|
6221
|
+
const trustedObjectStatic = (callee, member) => {
|
|
6222
|
+
const current = unwrapErasedExpression(callee);
|
|
6223
|
+
if (!objectConstructorSymbol || !ts.isPropertyAccessExpression(current))
|
|
6224
|
+
return false;
|
|
6225
|
+
if (actualSymbol(checker.getSymbolAtLocation(unwrapErasedExpression(current.expression))) !== objectConstructorSymbol)
|
|
6226
|
+
return false;
|
|
6227
|
+
const expected = actualSymbol(checker.getTypeOfSymbol(objectConstructorSymbol).getProperty(member));
|
|
6228
|
+
const symbol = actualSymbol(checker.getSymbolAtLocation(current.name));
|
|
6229
|
+
return !!symbol && symbol === expected && !allIntrinsicTrustInvalidated && !intrinsicSymbolIsOverwritten(symbol);
|
|
6230
|
+
};
|
|
6231
|
+
const neverReassigned = (declaration) => writesOf(declaration).every((write) => write.slot !== 'whole' ||
|
|
6232
|
+
write.edge === 'declaration-initializer' ||
|
|
6233
|
+
write.edge === 'call-argument' ||
|
|
6234
|
+
write.edge === 'super-argument' ||
|
|
6235
|
+
write.edge === 'default-parameter');
|
|
6236
|
+
/**
|
|
6237
|
+
* Can a get/set of `key` on an object whose prototype chain holds only this
|
|
6238
|
+
* program's class prototypes and `Object.prototype` run an accessor?
|
|
6239
|
+
*
|
|
6240
|
+
* Class prototypes carry the accessors their class bodies declare (a getter,
|
|
6241
|
+
* a setter or an `accessor` field, by any name that can equal `key`), and
|
|
6242
|
+
* whatever a decorator or a reflective definition puts there -- which the
|
|
6243
|
+
* caller rules out separately with the class family's inventory, and which
|
|
6244
|
+
* any decorator anywhere refuses here. `Object.prototype` carries a library
|
|
6245
|
+
* accessor (`hostAccessorNames`) or a key this census found written on it.
|
|
6246
|
+
* A computed accessor name refuses unless it is a symbol: a well-known one
|
|
6247
|
+
* or a program-declared unique one, neither of which is a string key.
|
|
6248
|
+
*/
|
|
6249
|
+
/**
|
|
6250
|
+
* The accessor names that can be on an object's prototype chain, as a
|
|
6251
|
+
* name set or `every`. `family` null: every accessor this program declares
|
|
6252
|
+
* anywhere. `family` a base class: only what can sit between an instance of
|
|
6253
|
+
* it and `Object.prototype` -- its own accessors and those of every class
|
|
6254
|
+
* that extends it, directly or through a chain -- plus every object-literal
|
|
6255
|
+
* accessor (a literal can be spliced into a chain reflectively, which the
|
|
6256
|
+
* class family's inventory, not this scan, is what refuses). A class whose
|
|
6257
|
+
* `extends` names no class declaration this scan can resolve might extend
|
|
6258
|
+
* the base, so it counts as family. A decorator anywhere can install
|
|
6259
|
+
* anything, so it is `every` for every family.
|
|
6260
|
+
*/
|
|
6261
|
+
const accessorNamesOnChain = new Map();
|
|
6262
|
+
const classFamilyOf = (base) => {
|
|
6263
|
+
const family = new Set([base]);
|
|
6264
|
+
const classes = nodes.filter((node) => ts.isClassDeclaration(node) || ts.isClassExpression(node));
|
|
6265
|
+
for (let grew = true; grew;) {
|
|
6266
|
+
grew = false;
|
|
6267
|
+
for (const candidate of classes) {
|
|
6268
|
+
if (family.has(candidate))
|
|
6269
|
+
continue;
|
|
6270
|
+
const heritage = candidate.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0];
|
|
6271
|
+
if (!heritage)
|
|
6272
|
+
continue;
|
|
6273
|
+
const symbol = actualSymbol(checker.getSymbolAtLocation(unwrapErasedExpression(heritage.expression)));
|
|
6274
|
+
// `extends Error`: a standard-library constructor nothing replaced is
|
|
6275
|
+
// that intrinsic, never a program class.
|
|
6276
|
+
if (symbol && hasStandardLibraryDeclaration(symbol) && !allIntrinsicTrustInvalidated && !intrinsicSymbolIsOverwritten(symbol))
|
|
6277
|
+
continue;
|
|
6278
|
+
const declaration = symbol?.valueDeclaration;
|
|
6279
|
+
const extended = declaration !== undefined && (ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration)) ? declaration : null;
|
|
6280
|
+
if (extended === null || family.has(extended)) {
|
|
6281
|
+
family.add(candidate);
|
|
6282
|
+
grew = true;
|
|
6283
|
+
}
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6286
|
+
return family;
|
|
6287
|
+
};
|
|
6288
|
+
const accessorNamesOnChainOf = (family) => {
|
|
6289
|
+
const known = accessorNamesOnChain.get(family);
|
|
6290
|
+
if (known !== undefined)
|
|
6291
|
+
return known;
|
|
6292
|
+
const members = family === null ? null : classFamilyOf(family);
|
|
6293
|
+
const names = new Set();
|
|
6294
|
+
let every = false;
|
|
6295
|
+
for (const node of nodes) {
|
|
6296
|
+
if (ts.isDecorator(node))
|
|
6297
|
+
every = true;
|
|
6298
|
+
const name = ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)
|
|
6299
|
+
? node.name
|
|
6300
|
+
: ts.isPropertyDeclaration(node) && node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AccessorKeyword)
|
|
6301
|
+
? node.name
|
|
6302
|
+
: null;
|
|
6303
|
+
if (!name || ts.isPrivateIdentifier(name))
|
|
6304
|
+
continue;
|
|
6305
|
+
if (members !== null && ts.isClassLike(node.parent) && !members.has(node.parent))
|
|
6306
|
+
continue;
|
|
6307
|
+
if (ts.isIdentifier(name) || ts.isStringLiteralLike(name) || ts.isNumericLiteral(name))
|
|
6308
|
+
names.add(name.text);
|
|
6309
|
+
else if (ts.isComputedPropertyName(name)) {
|
|
6310
|
+
const expression = unwrapErasedExpression(name.expression);
|
|
6311
|
+
const owner = ts.isPropertyAccessExpression(expression)
|
|
6312
|
+
? actualSymbol(checker.getSymbolAtLocation(unwrapErasedExpression(expression.expression)))
|
|
6313
|
+
: undefined;
|
|
6314
|
+
const wellKnown = owner != null &&
|
|
6315
|
+
hasStandardLibraryDeclaration(owner) &&
|
|
6316
|
+
(checker.getTypeAtLocation(expression).flags & ts.TypeFlags.UniqueESSymbol) !== 0;
|
|
6317
|
+
if (!wellKnown && !isProgramDeclaredSymbolKey(publishedTypeAt(expression)))
|
|
6318
|
+
every = true;
|
|
6319
|
+
}
|
|
6320
|
+
else
|
|
6321
|
+
every = true;
|
|
6322
|
+
}
|
|
6323
|
+
const answer = every ? 'every' : names;
|
|
6324
|
+
accessorNamesOnChain.set(family, answer);
|
|
6325
|
+
return answer;
|
|
6326
|
+
};
|
|
6327
|
+
/**
|
|
6328
|
+
* Can a get/set of `key` on an object whose prototype chain holds only this
|
|
6329
|
+
* program's class prototypes and `Object.prototype` run an accessor?
|
|
6330
|
+
*
|
|
6331
|
+
* Class prototypes carry the accessors their class bodies declare (a getter,
|
|
6332
|
+
* a setter or an `accessor` field, by any name that can equal `key`), and
|
|
6333
|
+
* whatever a decorator or a reflective definition puts there -- which the
|
|
6334
|
+
* caller rules out separately with the class family's inventory, and which
|
|
6335
|
+
* any decorator anywhere refuses here. `Object.prototype` carries a library
|
|
6336
|
+
* accessor (`hostAccessorNames`) or a key this census found written on it.
|
|
6337
|
+
* A computed accessor name refuses unless it is a symbol: a well-known one
|
|
6338
|
+
* or a program-declared unique one, neither of which is a string key.
|
|
6339
|
+
*
|
|
6340
|
+
* `family`, when given, is the base class the object was constructed by:
|
|
6341
|
+
* then only that class family's accessors are on the chain
|
|
6342
|
+
* (`accessorNamesOnChainOf`), not every class's in the program.
|
|
6343
|
+
*/
|
|
6344
|
+
const accessorMayRunFor = (key, family = null) => {
|
|
6345
|
+
const names = accessorNamesOnChainOf(family);
|
|
6346
|
+
if (names === 'every' || names.has(key) || hostAccessorNames.has(key))
|
|
6347
|
+
return true;
|
|
6348
|
+
// `flow.accessorNames` is the same program-wide scan, kept as the
|
|
6349
|
+
// unfamilied answer only: a family answer has already filtered it.
|
|
6350
|
+
if (family === null && flow.accessorNames.has(key))
|
|
6351
|
+
return true;
|
|
6352
|
+
const inherited = objectPrototypeKeysOf(tainted);
|
|
6353
|
+
return inherited.every || inherited.names.has(key) || (inherited.numeric && String(Number(key)) === key);
|
|
6354
|
+
};
|
|
6355
|
+
/**
|
|
6356
|
+
* Does this base-class constructor keep `this` to itself? Every mention of
|
|
6357
|
+
* `this` in its parameters, its body and the class's instance field
|
|
6358
|
+
* initializers is a get or set of a named member no accessor can intercept
|
|
6359
|
+
* (`accessorMayRunFor`), never a method call, a computed member, a private
|
|
6360
|
+
* member or the bare value. Then no code but these member stores and loads
|
|
6361
|
+
* ever holds the object while the constructor runs, and nothing can have
|
|
6362
|
+
* made one of its own properties an accessor. A parameter property is a
|
|
6363
|
+
* store of its own name.
|
|
6364
|
+
*/
|
|
6365
|
+
const constructorKeepsThisLocal = (constructor) => {
|
|
6366
|
+
for (const parameter of constructor.parameters)
|
|
6367
|
+
if (ts.canHaveModifiers(parameter) &&
|
|
6368
|
+
ts.getModifiers(parameter)?.length &&
|
|
6369
|
+
(!ts.isIdentifier(parameter.name) || accessorMayRunFor(parameter.name.text, constructor.parent)))
|
|
6370
|
+
return false;
|
|
6371
|
+
let local = true;
|
|
6372
|
+
const visit = (node) => {
|
|
6373
|
+
if (!local)
|
|
6374
|
+
return;
|
|
6375
|
+
if (node.kind === ts.SyntaxKind.ThisKeyword) {
|
|
6376
|
+
const access = node.parent;
|
|
6377
|
+
local =
|
|
6378
|
+
ts.isPropertyAccessExpression(access) &&
|
|
6379
|
+
access.expression === node &&
|
|
6380
|
+
ts.isIdentifier(access.name) &&
|
|
6381
|
+
!((ts.isCallExpression(access.parent) || ts.isNewExpression(access.parent)) && access.parent.expression === access) &&
|
|
6382
|
+
!ts.isTaggedTemplateExpression(access.parent) &&
|
|
6383
|
+
!accessorMayRunFor(access.name.text, constructor.parent);
|
|
6384
|
+
return;
|
|
6385
|
+
}
|
|
6386
|
+
if (ts.isFunctionLike(node) && !ts.isArrowFunction(node) && node !== constructor)
|
|
6387
|
+
return;
|
|
6388
|
+
if (ts.isClassLike(node))
|
|
6389
|
+
return;
|
|
6390
|
+
ts.forEachChild(node, visit);
|
|
6391
|
+
};
|
|
6392
|
+
ts.forEachChild(constructor, visit);
|
|
6393
|
+
for (const member of constructor.parent.members)
|
|
6394
|
+
if (ts.isPropertyDeclaration(member) && !ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword)) {
|
|
6395
|
+
if (!ts.isIdentifier(member.name) || accessorMayRunFor(member.name.text, constructor.parent))
|
|
6396
|
+
return false;
|
|
6397
|
+
if (member.initializer)
|
|
6398
|
+
visit(member.initializer);
|
|
6399
|
+
}
|
|
6400
|
+
return local;
|
|
6401
|
+
};
|
|
6402
|
+
/**
|
|
6403
|
+
* `this.commandObj = {}; this.commandObj[commandName] = true` in a base
|
|
6404
|
+
* class constructor: the receiver of the second statement is the value the
|
|
6405
|
+
* first one stored, whatever else the slot holds elsewhere.
|
|
6406
|
+
*
|
|
6407
|
+
* Control reaches a statement only from the normal completion of the one
|
|
6408
|
+
* before it in the same list, and the write's receiver is the first thing
|
|
6409
|
+
* its statement evaluates, so no code runs between the [[Set]] and this
|
|
6410
|
+
* [[Get]]. In a base class constructor `this` is an ordinary object made by
|
|
6411
|
+
* [[Construct]] (never a proxy or exotic object) whose prototype chain is
|
|
6412
|
+
* its class family's prototypes and `Object.prototype` -- the family
|
|
6413
|
+
* inventory (`sourceClassDataMemberPlanOf`) refuses any reference to one of
|
|
6414
|
+
* those constructors or prototypes it cannot explain, which is every way a
|
|
6415
|
+
* foreign `newTarget` could reach them, and `reflectiveDefinitionMayInstallGetterOf`
|
|
6416
|
+
* refuses a reflective definition or prototype swap of the key on any
|
|
6417
|
+
* target not proven a fresh program allocation (which is never a prototype
|
|
6418
|
+
* of anything this program constructs). Both statements sit directly in
|
|
6419
|
+
* the constructor body, not in a nested function that could run after the
|
|
6420
|
+
* object escaped and something defined an own accessor on it. Class
|
|
6421
|
+
* code is strict, so a [[Set]] that cannot store throws instead of
|
|
6422
|
+
* completing. The [[Get]] then returns the stored value unless an accessor
|
|
6423
|
+
* for that key is on the object or its chain: `constructorKeepsThisLocal`
|
|
6424
|
+
* rules out an own one, `accessorMayRunFor` an inherited one.
|
|
6425
|
+
*/
|
|
6426
|
+
const valueStoredJustBefore = (read) => {
|
|
6427
|
+
if (read.expression.kind !== ts.SyntaxKind.ThisKeyword || !ts.isIdentifier(read.name))
|
|
6428
|
+
return null;
|
|
6429
|
+
const access = read.parent;
|
|
6430
|
+
if (!(ts.isElementAccessExpression(access) || ts.isPropertyAccessExpression(access)) || access.expression !== read)
|
|
6431
|
+
return null;
|
|
6432
|
+
const operation = access.parent;
|
|
6433
|
+
const written = (ts.isBinaryExpression(operation) &&
|
|
6434
|
+
operation.left === access &&
|
|
6435
|
+
operation.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
6436
|
+
operation.operatorToken.kind <= ts.SyntaxKind.LastAssignment) ||
|
|
6437
|
+
(ts.isDeleteExpression(operation) && operation.expression === access);
|
|
6438
|
+
if (!written || !ts.isExpressionStatement(operation.parent))
|
|
6439
|
+
return null;
|
|
6440
|
+
const statement = operation.parent;
|
|
6441
|
+
const list = statement.parent;
|
|
6442
|
+
if (!ts.isBlock(list) && !ts.isCaseClause(list) && !ts.isDefaultClause(list))
|
|
6443
|
+
return null;
|
|
6444
|
+
const index = list.statements.indexOf(statement);
|
|
6445
|
+
const previous = index > 0 ? list.statements[index - 1] : undefined;
|
|
6446
|
+
if (!previous || !ts.isExpressionStatement(previous))
|
|
6447
|
+
return null;
|
|
6448
|
+
const store = previous.expression;
|
|
6449
|
+
if (!ts.isBinaryExpression(store) || store.operatorToken.kind !== ts.SyntaxKind.EqualsToken)
|
|
6450
|
+
return null;
|
|
6451
|
+
const target = store.left;
|
|
6452
|
+
if (!ts.isPropertyAccessExpression(target) ||
|
|
6453
|
+
target.expression.kind !== ts.SyntaxKind.ThisKeyword ||
|
|
6454
|
+
!ts.isIdentifier(target.name) ||
|
|
6455
|
+
target.name.text !== read.name.text)
|
|
6456
|
+
return null;
|
|
6457
|
+
const owner = ts.findAncestor(list, (node) => ts.isFunctionLike(node) || ts.isClassStaticBlockDeclaration(node));
|
|
6458
|
+
if (!owner || !ts.isConstructorDeclaration(owner))
|
|
6459
|
+
return null;
|
|
6460
|
+
if (owner.parent.heritageClauses?.some((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword))
|
|
6461
|
+
return null;
|
|
6462
|
+
const key = read.name.text;
|
|
6463
|
+
if (key === '__proto__' || accessorMayRunFor(key, owner.parent) || !constructorKeepsThisLocal(owner))
|
|
6464
|
+
return null;
|
|
6465
|
+
if (sourceClassDataMemberPlanOf(checker, flow, { kind: 'declared', receiver: checker.getTypeAtLocation(read.expression) }, key) === null)
|
|
6466
|
+
return null;
|
|
6467
|
+
if (reflectiveDefinitionMayInstallGetterOf(checker, flow, key, (target) => freshDefinitionTarget(target) !== 'refused'))
|
|
6468
|
+
return null;
|
|
6469
|
+
return store.right;
|
|
6470
|
+
};
|
|
6471
|
+
// Two solvers over one rule: the reflective-definition question
|
|
6472
|
+
// `valueStoredJustBefore` asks about definition targets must not re-enter
|
|
6473
|
+
// the solver that is asking it, so the one answering it proves targets
|
|
6474
|
+
// without store-then-read reasoning -- strictly fewer origins, still sound.
|
|
6475
|
+
const originRuleOf = (storedReads) => (key) => {
|
|
6476
|
+
const refused = { seed: false, admitted: false, dependencies: [] };
|
|
6477
|
+
const through = (dependencies) => ({ seed: false, admitted: true, dependencies });
|
|
6478
|
+
if (ts.isParameter(key)) {
|
|
6479
|
+
if (key.dotDotDotToken)
|
|
6480
|
+
return refused;
|
|
6481
|
+
const values = enumeratedParameterValuesOf(key);
|
|
6482
|
+
return values === null ? refused : through(values);
|
|
6483
|
+
}
|
|
6484
|
+
if (ts.isVariableDeclaration(key)) {
|
|
6485
|
+
const values = [];
|
|
6486
|
+
const writes = writesOf(key).filter((write) => write.slot === 'whole');
|
|
6487
|
+
if (writes.length === 0)
|
|
6488
|
+
return refused;
|
|
6489
|
+
for (const write of writes) {
|
|
6490
|
+
if (write.edge === 'compound-assignment')
|
|
6491
|
+
continue;
|
|
6492
|
+
if (write.value === null ||
|
|
6493
|
+
(write.edge !== 'declaration-initializer' && write.edge !== 'identifier-assignment' && write.edge !== 'logical-assignment'))
|
|
6494
|
+
return refused;
|
|
6495
|
+
values.push(write.value);
|
|
6496
|
+
}
|
|
6497
|
+
return through(values);
|
|
6498
|
+
}
|
|
6499
|
+
if (!ts.isExpression(key))
|
|
6500
|
+
return refused;
|
|
6501
|
+
const current = unwrapErasedExpression(key);
|
|
6502
|
+
if (ts.isObjectLiteralExpression(current) || ts.isArrayLiteralExpression(current))
|
|
6503
|
+
return { seed: true, admitted: true, dependencies: [] };
|
|
6504
|
+
if (isVacuousOrigin(flow, current) ||
|
|
6505
|
+
ts.isStringLiteralLike(current) ||
|
|
6506
|
+
ts.isTemplateExpression(current) ||
|
|
6507
|
+
ts.isNumericLiteral(current) ||
|
|
6508
|
+
ts.isBigIntLiteral(current) ||
|
|
6509
|
+
ts.isTypeOfExpression(current) ||
|
|
6510
|
+
current.kind === ts.SyntaxKind.TrueKeyword ||
|
|
6511
|
+
current.kind === ts.SyntaxKind.FalseKeyword)
|
|
6512
|
+
return through([]);
|
|
6513
|
+
if (ts.isConditionalExpression(current))
|
|
6514
|
+
return through([current.whenTrue, current.whenFalse]);
|
|
6515
|
+
if (ts.isBinaryExpression(current)) {
|
|
6516
|
+
const operator = current.operatorToken.kind;
|
|
6517
|
+
if (operator === ts.SyntaxKind.QuestionQuestionToken ||
|
|
6518
|
+
operator === ts.SyntaxKind.BarBarToken ||
|
|
6519
|
+
operator === ts.SyntaxKind.AmpersandAmpersandToken)
|
|
6520
|
+
return through([current.left, current.right]);
|
|
6521
|
+
if (operator === ts.SyntaxKind.CommaToken || operator === ts.SyntaxKind.EqualsToken)
|
|
6522
|
+
return through([current.right]);
|
|
6523
|
+
return refused;
|
|
6524
|
+
}
|
|
6525
|
+
if (ts.isCallExpression(current)) {
|
|
6526
|
+
if (trustedObjectStatic(current.expression, 'create'))
|
|
6527
|
+
return { seed: true, admitted: true, dependencies: [] };
|
|
6528
|
+
const target = current.arguments[0];
|
|
6529
|
+
if (trustedObjectStatic(current.expression, 'assign') && target && !ts.isSpreadElement(target))
|
|
6530
|
+
return through([target]);
|
|
6531
|
+
const fact = sourceFrameOwnedCalls.has(current) ? sourceInvocationFacts.get(current) : undefined;
|
|
6532
|
+
if (!fact || fact.frames.length === 0)
|
|
6533
|
+
return refused;
|
|
6534
|
+
const values = [];
|
|
6535
|
+
for (const frame of fact.frames) {
|
|
6536
|
+
if (frame.completions.kind !== 'values')
|
|
6537
|
+
return refused;
|
|
6538
|
+
values.push(...frame.completions.values);
|
|
6539
|
+
}
|
|
6540
|
+
return through(values);
|
|
6541
|
+
}
|
|
6542
|
+
if (ts.isIdentifier(current)) {
|
|
6543
|
+
const declaration = bindingOf(current);
|
|
6544
|
+
if (!declaration || (!ts.isParameter(declaration) && !ts.isVariableDeclaration(declaration)))
|
|
6545
|
+
return refused;
|
|
6546
|
+
if (isRuntimePrimitiveGuarded(current) && neverReassigned(declaration))
|
|
6547
|
+
return through([]);
|
|
6548
|
+
return through([declaration]);
|
|
6549
|
+
}
|
|
6550
|
+
const stored = storedReads && ts.isPropertyAccessExpression(current) ? valueStoredJustBefore(current) : null;
|
|
6551
|
+
if (stored)
|
|
6552
|
+
return through([stored]);
|
|
6553
|
+
if ((ts.isPropertyAccessExpression(current) || ts.isElementAccessExpression(current)) &&
|
|
6554
|
+
!trustSeed.rejectedCallableProofs.has(current)) {
|
|
6555
|
+
try {
|
|
6556
|
+
const proof = invocationLedger.capture(() => closedValueOriginAuthorityOf(checker, flow, current).fieldValuesOf(current));
|
|
6557
|
+
if (proof.value === null)
|
|
6558
|
+
return refused;
|
|
6559
|
+
invocationRequirements.set(current, proof.requirements);
|
|
6560
|
+
return through(proof.value);
|
|
6561
|
+
}
|
|
6562
|
+
catch {
|
|
6563
|
+
// The same live proof `enumeratedParameterValuesOf` guards: a slot
|
|
6564
|
+
// this file cannot evaluate is a slot it cannot close.
|
|
6565
|
+
return refused;
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6568
|
+
return refused;
|
|
6569
|
+
};
|
|
6570
|
+
const freshDefinitionTarget = seededOriginSolver(originRuleOf(false));
|
|
6571
|
+
const freshProgramObjectOrigin = seededOriginSolver(originRuleOf(true));
|
|
5916
6572
|
finishCensus();
|
|
5917
6573
|
for (const file of files) {
|
|
5918
6574
|
if (file.isDeclarationFile)
|
|
@@ -5926,6 +6582,13 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5926
6582
|
// every key Object.prototype may carry; and a key set's intrinsic
|
|
5927
6583
|
// assumptions hold against this very result. See `CensusSeed`.
|
|
5928
6584
|
if (!tainted.has('*')) {
|
|
6585
|
+
// Evaluated before the ledger checks below: the parameter proofs it asks
|
|
6586
|
+
// file their intrinsic requirements with `invocationRequirements`.
|
|
6587
|
+
const unprovenSurfaceWrite = allIntrinsicTrustInvalidated
|
|
6588
|
+
? undefined
|
|
6589
|
+
: deferredSurfaceWrites.find((receiver) => freshProgramObjectOrigin(receiver) === 'refused');
|
|
6590
|
+
if (unprovenSurfaceWrite && process.env['GEA_DEBUG_GLOBAL_MUTATION'])
|
|
6591
|
+
debugSite(unprovenSurfaceWrite, 'surface write receiver is not a fresh program object; invalidates all intrinsic trust');
|
|
5929
6592
|
const written = visitWrittenKeys.surfaceKeys;
|
|
5930
6593
|
const distrusted = [...trustedIntrinsicNames].filter((name) => !trustSeed.names.has(name) && keySetTouches(written, { names: [name] }));
|
|
5931
6594
|
const objectPrototypeKeys = inheritedObjectPrototypeKeys ? objectPrototypeKeysOf(tainted) : trustSeed.objectPrototypeKeys;
|
|
@@ -5944,13 +6607,14 @@ computedKeysOf = () => null, trustSeed = initialCensusSeed) => {
|
|
|
5944
6607
|
if (failedIntrinsicProtocolRequirements({ checker, identities, globalHostMutationTaint: tainted, isStandardLibraryDeclaration }, requirements).length > 0)
|
|
5945
6608
|
rejectedCallableProofs.add(call);
|
|
5946
6609
|
const invocationFailed = rejectedCallableProofs.size > trustSeed.rejectedCallableProofs.size;
|
|
5947
|
-
|
|
6610
|
+
const distrustAll = written.every || unprovenSurfaceWrite !== undefined;
|
|
6611
|
+
if (distrusted.length > 0 || (distrustAll && !trustSeed.all) || inheritedGrew || assumptionFailed || invocationFailed) {
|
|
5948
6612
|
if (process.env['GEA_DEBUG_GLOBAL_MUTATION'])
|
|
5949
|
-
process.stderr.write(`global host census re-run: distrusting ${
|
|
6613
|
+
process.stderr.write(`global host census re-run: distrusting ${distrustAll ? '<all>' : distrusted.join(', ') || '-'}` +
|
|
5950
6614
|
`${inheritedGrew ? '; Object.prototype keys grew' : ''}${assumptionFailed ? '; computed-key assumption failed' : ''}\n`);
|
|
5951
|
-
return censusGlobalHostMutations(checker, identities, files, names, hostBindings, flow, reachable, nativeReceiverDeclarations, nativeReceiverSymbols, nativeConstructorSymbols, publishedTypeAt, declarationFiles, computedKeysOf, {
|
|
6615
|
+
return censusGlobalHostMutations(checker, identities, files, names, hostBindings, flow, reachable, nativeReceiverDeclarations, nativeReceiverSymbols, nativeConstructorSymbols, publishedTypeAt, declarationFiles, computedKeysOf, staticCommonJsRequireOutcomeOf, {
|
|
5952
6616
|
names: new Set([...trustSeed.names, ...distrusted]),
|
|
5953
|
-
all: trustSeed.all ||
|
|
6617
|
+
all: trustSeed.all || distrustAll,
|
|
5954
6618
|
objectPrototypeKeys: {
|
|
5955
6619
|
names: new Set([...trustSeed.objectPrototypeKeys.names, ...objectPrototypeKeys.names]),
|
|
5956
6620
|
numeric: trustSeed.objectPrototypeKeys.numeric || objectPrototypeKeys.numeric,
|