@geastack/compiler 1.0.27 → 1.0.29
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-coverage.js +2 -2
- package/dist/cli-emit.js +36 -12
- package/dist/compiler.d.ts +11 -9
- package/dist/compiler.js +264 -43
- package/dist/conversion/algebra.d.ts +84 -4
- package/dist/conversion/algebra.js +39 -0
- package/dist/conversion/array-view.d.ts +63 -0
- package/dist/conversion/array-view.js +186 -0
- package/dist/conversion/build.d.ts +8 -8
- package/dist/conversion/build.js +56 -50
- package/dist/conversion/certified-iterator-object-view.d.ts +13 -0
- package/dist/conversion/certified-iterator-object-view.js +31 -0
- package/dist/conversion/certified-iterator-protocols.d.ts +23 -0
- package/dist/conversion/certified-iterator-protocols.js +50 -0
- package/dist/conversion/checked-native-field-read.d.ts +7 -0
- package/dist/conversion/checked-native-field-read.js +36 -0
- package/dist/conversion/constructor-identity-family.d.ts +6 -6
- package/dist/conversion/constructor-identity-family.js +3 -3
- package/dist/conversion/derive.js +11 -8
- package/dist/conversion/dictionary-view.d.ts +114 -0
- package/dist/conversion/dictionary-view.js +275 -0
- package/dist/conversion/document-record-view.d.ts +89 -0
- package/dist/conversion/document-record-view.js +269 -0
- package/dist/conversion/dynamic-result-carriers.d.ts +6 -0
- package/dist/conversion/dynamic-result-carriers.js +43 -0
- package/dist/conversion/dynamic-wrapper.d.ts +52 -0
- package/dist/conversion/dynamic-wrapper.js +82 -0
- package/dist/conversion/impossible-field-read.d.ts +9 -0
- package/dist/conversion/impossible-field-read.js +28 -0
- package/dist/conversion/iterable-object-view.d.ts +1 -1
- package/dist/conversion/iterator-object-view.d.ts +2 -2
- package/dist/conversion/native-absence.d.ts +4 -0
- package/dist/conversion/native-absence.js +4 -0
- package/dist/conversion/native-buffer-method.d.ts +16 -0
- package/dist/conversion/native-buffer-method.js +37 -0
- package/dist/conversion/native-callable-adapter.d.ts +13 -0
- package/dist/conversion/native-callable-adapter.js +73 -0
- package/dist/conversion/native-descriptor-snapshot.d.ts +30 -0
- package/dist/conversion/native-descriptor-snapshot.js +75 -0
- package/dist/conversion/native-entry-writer.d.ts +21 -0
- package/dist/conversion/native-entry-writer.js +32 -0
- package/dist/conversion/native-field-view.d.ts +42 -0
- package/dist/conversion/native-field-view.js +145 -0
- package/dist/conversion/native-logical-receiver.d.ts +11 -0
- package/dist/conversion/native-logical-receiver.js +19 -0
- package/dist/conversion/native-method.d.ts +43 -0
- package/dist/conversion/native-method.js +56 -0
- package/dist/conversion/native-object-sample.d.ts +30 -0
- package/dist/conversion/native-object-sample.js +37 -0
- package/dist/conversion/native-payload-transport.d.ts +1 -1
- package/dist/conversion/native-payload-transport.js +1 -1
- package/dist/conversion/native-record-products.d.ts +15 -0
- package/dist/conversion/native-record-products.js +73 -0
- package/dist/conversion/native-selection.d.ts +18 -1
- package/dist/conversion/native-selection.js +117 -4
- package/dist/conversion/native-sum.d.ts +27 -0
- package/dist/conversion/native-sum.js +74 -9
- package/dist/conversion/native-view-origins.d.ts +12 -0
- package/dist/conversion/native-view-origins.js +97 -0
- package/dist/conversion/nodes.d.ts +75 -7
- package/dist/conversion/nodes.js +694 -19
- package/dist/conversion/number-storage.d.ts +8 -0
- package/dist/conversion/number-storage.js +8 -0
- package/dist/conversion/operand-view.js +10 -1
- package/dist/conversion/promise-adoption.d.ts +15 -0
- package/dist/conversion/promise-adoption.js +29 -0
- package/dist/conversion/protocol-iterator.d.ts +3 -3
- package/dist/conversion/recipe-closure.d.ts +14 -0
- package/dist/conversion/recipe-closure.js +135 -0
- package/dist/conversion/record-view.d.ts +51 -26
- package/dist/conversion/record-view.js +160 -97
- package/dist/conversion/registry.d.ts +18 -2
- package/dist/conversion/sibling-class.d.ts +4 -0
- package/dist/conversion/sibling-class.js +7 -0
- package/dist/conversion/structural-plan.d.ts +87 -0
- package/dist/conversion/structural-plan.js +480 -0
- package/dist/ir/absent-class-arm.d.ts +1 -1
- package/dist/ir/absent-class-arm.js +1 -1
- package/dist/ir/async-result-conventions.d.ts +15 -0
- package/dist/ir/async-result-conventions.js +140 -0
- package/dist/ir/borrowed-call-arguments.d.ts +3 -3
- package/dist/ir/borrowed-call-arguments.js +9 -9
- package/dist/ir/build.d.ts +20 -29
- package/dist/ir/build.js +116 -19
- package/dist/ir/call-dispatch.js +153 -40
- package/dist/ir/call-entry.d.ts +14 -3
- package/dist/ir/call-entry.js +63 -5
- package/dist/ir/callable-class-flow.d.ts +48 -3
- package/dist/ir/callable-class-flow.js +1509 -81
- package/dist/ir/callable-flow-candidates.d.ts +25 -0
- package/dist/ir/callable-flow-candidates.js +135 -0
- package/dist/ir/callable-identity-demand.d.ts +2 -2
- package/dist/ir/callable-identity-demand.js +33 -1
- package/dist/ir/callable-member-candidates.d.ts +1 -1
- package/dist/ir/callable-member-candidates.js +2 -2
- package/dist/ir/callable-records.js +1 -0
- package/dist/ir/callable-site-escape.js +3 -4
- package/dist/ir/captures.js +1 -1
- package/dist/ir/certificate.d.ts +1 -0
- package/dist/ir/certificate.js +2 -1
- package/dist/ir/certify/carrier-keys.d.ts +2 -2
- package/dist/ir/certify/carrier-keys.js +4 -4
- package/dist/ir/certify/has-property-key.d.ts +3 -3
- package/dist/ir/certify/has-property-key.js +3 -3
- package/dist/ir/certify/parallel-region.d.ts +26 -0
- package/dist/ir/certify/parallel-region.js +1331 -0
- package/dist/ir/certify/property-access-keys.d.ts +11 -11
- package/dist/ir/certify/property-access-keys.js +11 -11
- package/dist/ir/certify/property-access.js +7 -9
- package/dist/ir/certify.d.ts +66 -3
- package/dist/ir/certify.js +1197 -36
- package/dist/ir/class-allocation-domain.d.ts +9 -0
- package/dist/ir/class-allocation-domain.js +111 -0
- package/dist/ir/class-evaluation.d.ts +2 -3
- package/dist/ir/class-evaluation.js +2 -3
- package/dist/ir/class-static-fields.d.ts +12 -1
- package/dist/ir/class-static-fields.js +25 -0
- package/dist/ir/closed-normal-results.d.ts +18 -0
- package/dist/ir/closed-normal-results.js +208 -0
- package/dist/ir/construct-entry.js +1 -0
- package/dist/ir/construction-only-fields.d.ts +20 -1
- package/dist/ir/construction-only-fields.js +95 -9
- package/dist/ir/convert-carriers.d.ts +7 -0
- package/dist/ir/convert-carriers.js +12 -0
- package/dist/ir/coroutine-bodies.d.ts +74 -0
- package/dist/ir/coroutine-bodies.js +93 -0
- package/dist/ir/dead-logical-merge.d.ts +7 -0
- package/dist/ir/dead-logical-merge.js +84 -0
- package/dist/ir/dead-values.d.ts +7 -5
- package/dist/ir/dead-values.js +34 -5
- package/dist/ir/deferral.d.ts +3 -1
- package/dist/ir/deferral.js +19 -6
- package/dist/ir/dense-loops.d.ts +96 -7
- package/dist/ir/dense-loops.js +333 -17
- package/dist/ir/descriptor-own-protocol.d.ts +12 -0
- package/dist/ir/descriptor-own-protocol.js +35 -0
- package/dist/ir/dynamic-constructor-conversions.d.ts +17 -0
- package/dist/ir/dynamic-constructor-conversions.js +52 -0
- package/dist/ir/emission-representations.js +44 -2
- package/dist/ir/facts.d.ts +14 -2
- package/dist/ir/facts.js +23 -9
- package/dist/ir/fixed-data-definition-attributes.d.ts +10 -0
- package/dist/ir/fixed-data-definition-attributes.js +200 -0
- package/dist/ir/fixed-data-definition.d.ts +23 -5
- package/dist/ir/fixed-data-definition.js +80 -2
- package/dist/ir/function-reflection-demand.d.ts +11 -0
- package/dist/ir/function-reflection-demand.js +71 -0
- package/dist/ir/generic-call-entry.d.ts +18 -0
- package/dist/ir/generic-call-entry.js +94 -0
- package/dist/ir/hoist.d.ts +16 -3
- package/dist/ir/hoist.js +121 -8
- package/dist/ir/host-method-aliases.d.ts +15 -0
- package/dist/ir/host-method-aliases.js +61 -0
- package/dist/ir/host-namespace-reads.d.ts +24 -0
- package/dist/ir/host-namespace-reads.js +151 -0
- package/dist/ir/host-promise-conversions.d.ts +5 -0
- package/dist/ir/host-promise-conversions.js +61 -0
- package/dist/ir/host-template-conversions.d.ts +34 -0
- package/dist/ir/host-template-conversions.js +357 -0
- package/dist/ir/instance-reparenting.d.ts +3 -4
- package/dist/ir/instantiation.d.ts +1 -1
- package/dist/ir/instantiation.js +1 -1
- package/dist/ir/integer-storage.d.ts +19 -9
- package/dist/ir/integer-storage.js +158 -44
- package/dist/ir/integers.d.ts +34 -7
- package/dist/ir/integers.js +240 -7
- package/dist/ir/integrity-restrictions.d.ts +4 -4
- package/dist/ir/integrity-restrictions.js +7 -4
- package/dist/ir/internal-operation-conversions.d.ts +7 -0
- package/dist/ir/internal-operation-conversions.js +195 -0
- package/dist/ir/intrinsic-call-facts.d.ts +40 -0
- package/dist/ir/intrinsic-call-facts.js +176 -0
- package/dist/ir/key-order-observation.d.ts +1 -1
- package/dist/ir/lazy-splits.d.ts +20 -0
- package/dist/ir/lazy-splits.js +58 -0
- package/dist/ir/literal-set-membership.d.ts +2 -2
- package/dist/ir/literal-set-membership.js +2 -2
- package/dist/ir/logical-receivers.d.ts +15 -0
- package/dist/ir/logical-receivers.js +98 -0
- package/dist/ir/lower-allocation.js +16 -13
- package/dist/ir/lower-destructuring.js +7 -6
- package/dist/ir/lower-graph.d.ts +4 -4
- package/dist/ir/lower-graph.js +2 -2
- package/dist/ir/lower-invocation.d.ts +2 -2
- package/dist/ir/lower-invocation.js +99 -57
- package/dist/ir/lower-narrow.js +35 -13
- package/dist/ir/lower-operands.d.ts +40 -11
- package/dist/ir/lower-operands.js +206 -87
- package/dist/ir/lower-property.js +31 -8
- package/dist/ir/lower.js +9 -9
- package/dist/ir/merge-conversions.d.ts +18 -0
- package/dist/ir/merge-conversions.js +106 -0
- package/dist/ir/model.d.ts +138 -28
- package/dist/ir/native-accessor-definition.d.ts +104 -0
- package/dist/ir/native-accessor-definition.js +735 -0
- package/dist/ir/native-array-descriptor-snapshot.d.ts +45 -0
- package/dist/ir/native-array-descriptor-snapshot.js +380 -0
- package/dist/ir/native-array-insertion.d.ts +16 -0
- package/dist/ir/native-array-insertion.js +42 -0
- package/dist/ir/native-callable-argument.d.ts +38 -0
- package/dist/ir/native-callable-argument.js +128 -0
- package/dist/ir/native-callable-data-flow.d.ts +9 -0
- package/dist/ir/native-callable-data-flow.js +59 -0
- package/dist/ir/native-callable-data-owner.d.ts +45 -0
- package/dist/ir/native-callable-data-owner.js +755 -0
- package/dist/ir/native-callable-data-reads.d.ts +45 -0
- package/dist/ir/native-callable-data-reads.js +282 -0
- package/dist/ir/native-callable-data-slots.d.ts +78 -0
- package/dist/ir/native-callable-data-slots.js +403 -0
- package/dist/ir/native-callable-data-write.d.ts +58 -0
- package/dist/ir/native-callable-data-write.js +254 -0
- package/dist/ir/native-callable-integrity.d.ts +23 -0
- package/dist/ir/native-callable-integrity.js +77 -0
- package/dist/ir/native-callable-own-property.d.ts +42 -0
- package/dist/ir/native-callable-own-property.js +505 -0
- package/dist/ir/native-callable-prototype.d.ts +38 -0
- package/dist/ir/native-callable-prototype.js +307 -0
- package/dist/ir/native-callable-readonly-set.d.ts +25 -0
- package/dist/ir/native-callable-readonly-set.js +238 -0
- package/dist/ir/native-class-accessor.d.ts +3 -3
- package/dist/ir/native-class-accessor.js +3 -3
- package/dist/ir/native-class-construction.js +2 -2
- package/dist/ir/native-constructor-reads.d.ts +15 -0
- package/dist/ir/native-constructor-reads.js +156 -0
- package/dist/ir/native-constructor-static.d.ts +18 -0
- package/dist/ir/native-constructor-static.js +61 -0
- package/dist/ir/native-data-definition.d.ts +43 -0
- package/dist/ir/native-data-definition.js +222 -0
- package/dist/ir/native-document-array-entries.d.ts +15 -0
- package/dist/ir/native-document-array-entries.js +37 -0
- package/dist/ir/native-document-entries.d.ts +21 -0
- package/dist/ir/native-document-entries.js +74 -0
- package/dist/ir/native-entry-field-views.d.ts +18 -0
- package/dist/ir/native-entry-field-views.js +62 -0
- package/dist/ir/native-field-view-domains.d.ts +43 -0
- package/dist/ir/native-field-view-domains.js +300 -0
- package/dist/ir/native-field-view-facts.d.ts +97 -0
- package/dist/ir/native-field-view-facts.js +341 -0
- package/dist/ir/native-fixed-layout.js +1 -1
- package/dist/ir/native-host-construction.d.ts +4 -6
- package/dist/ir/native-host-construction.js +4 -6
- package/dist/ir/native-host-method-reads.d.ts +13 -0
- package/dist/ir/native-host-method-reads.js +53 -0
- package/dist/ir/native-iterator-field-views.d.ts +15 -0
- package/dist/ir/native-iterator-field-views.js +39 -0
- package/dist/ir/native-iterator-receivers.d.ts +8 -0
- package/dist/ir/native-iterator-receivers.js +59 -0
- package/dist/ir/native-logical-receiver-body.d.ts +8 -0
- package/dist/ir/native-logical-receiver-body.js +23 -0
- package/dist/ir/native-method-frames.d.ts +18 -0
- package/dist/ir/native-method-frames.js +127 -0
- package/dist/ir/native-method-read-source.d.ts +16 -0
- package/dist/ir/native-method-read-source.js +61 -0
- package/dist/ir/native-object-data-slots.d.ts +60 -0
- package/dist/ir/native-object-data-slots.js +493 -0
- package/dist/ir/native-object-sample.d.ts +32 -0
- package/dist/ir/native-object-sample.js +113 -0
- package/dist/ir/native-own-assignment.d.ts +123 -0
- package/dist/ir/native-own-assignment.js +529 -0
- package/dist/ir/native-property-coercibility.d.ts +3 -0
- package/dist/ir/native-property-coercibility.js +10 -0
- package/dist/ir/native-property-key-texts.d.ts +11 -0
- package/dist/ir/native-property-key-texts.js +41 -0
- package/dist/ir/native-property-presence-effects.d.ts +11 -0
- package/dist/ir/native-property-presence-effects.js +19 -0
- package/dist/ir/native-property-presence.d.ts +27 -0
- package/dist/ir/native-property-presence.js +275 -0
- package/dist/ir/native-prototype-calls.d.ts +19 -0
- package/dist/ir/native-prototype-calls.js +53 -0
- package/dist/ir/native-prototype-conversions.d.ts +5 -0
- package/dist/ir/native-prototype-conversions.js +46 -0
- package/dist/ir/native-prototype-presence-demand.d.ts +9 -0
- package/dist/ir/native-prototype-presence-demand.js +58 -0
- package/dist/ir/native-record-index.d.ts +1 -1
- package/dist/ir/native-union-method-targets.d.ts +8 -0
- package/dist/ir/native-union-method-targets.js +69 -0
- package/dist/ir/no-normal-call-completion.d.ts +15 -0
- package/dist/ir/no-normal-call-completion.js +184 -0
- package/dist/ir/non-normal-receiver.d.ts +39 -0
- package/dist/ir/non-normal-receiver.js +253 -0
- package/dist/ir/operation-conversions.d.ts +29 -0
- package/dist/ir/operation-conversions.js +484 -0
- package/dist/ir/operation-index.d.ts +1 -1
- package/dist/ir/presence-proof.d.ts +1 -1
- package/dist/ir/presence-proof.js +1 -0
- package/dist/ir/program-conversions.d.ts +48 -0
- package/dist/ir/program-conversions.js +221 -0
- package/dist/ir/program-facts.d.ts +4 -1
- package/dist/ir/program-facts.js +9 -7
- package/dist/ir/promise-reaction-conversions.d.ts +6 -0
- package/dist/ir/promise-reaction-conversions.js +92 -0
- package/dist/ir/property-read-conversions.d.ts +10 -0
- package/dist/ir/property-read-conversions.js +124 -0
- package/dist/ir/proven-branches.d.ts +2 -1
- package/dist/ir/proven-branches.js +97 -10
- package/dist/ir/publish-conversion-recipes.d.ts +27 -0
- package/dist/ir/publish-conversion-recipes.js +246 -0
- package/dist/ir/publish-native-field-view-facts.d.ts +17 -0
- package/dist/ir/publish-native-field-view-facts.js +119 -0
- package/dist/ir/queries.js +42 -4
- package/dist/ir/read-only-dictionary.d.ts +38 -0
- package/dist/ir/read-only-dictionary.js +281 -0
- package/dist/ir/reflection-demand.d.ts +2 -0
- package/dist/ir/reflection-demand.js +600 -44
- package/dist/ir/shake.d.ts +3 -0
- package/dist/ir/shake.js +24 -14
- package/dist/ir/shared-empty-records.js +1 -1
- package/dist/ir/short-circuit-threading.d.ts +23 -0
- package/dist/ir/short-circuit-threading.js +133 -0
- package/dist/ir/spread-conversions.d.ts +27 -0
- package/dist/ir/spread-conversions.js +134 -0
- package/dist/ir/spread-copy-elision.d.ts +2 -2
- package/dist/ir/spread-copy-elision.js +7 -4
- package/dist/ir/string-layout-reuse.d.ts +9 -8
- package/dist/ir/string-layout-reuse.js +8 -16
- package/dist/ir/string-length-reuse.d.ts +20 -4
- package/dist/ir/string-length-reuse.js +57 -13
- package/dist/ir/transfer.d.ts +5 -5
- package/dist/ir/transfer.js +53 -31
- package/dist/ir/typed-property-access.d.ts +2 -0
- package/dist/ir/typed-property-access.js +21 -8
- package/dist/ir/virtual-call-frames.d.ts +7 -0
- package/dist/ir/virtual-call-frames.js +8 -0
- package/dist/native-signatures.d.ts +45 -0
- package/dist/native-signatures.js +368 -0
- package/dist/plugins/gea/host.d.ts +6 -1
- package/dist/plugins/gea/host.js +30 -1
- package/dist/plugins/gea/lower.js +9 -3
- package/dist/plugins/gea/members.js +1 -1
- package/dist/plugins/gea/plugin.js +2 -1
- package/dist/plugins/gea/prelude.d.ts +1 -1
- package/dist/plugins/gea/prelude.js +1 -1
- package/dist/plugins/gea/reactive-slots.js +6 -6
- package/dist/plugins/gea/render-bridge.js +5 -6
- package/dist/plugins/gea/user-agent-styles.js +1 -1
- package/dist/plugins/installed.d.ts +2 -2
- package/dist/plugins/installed.js +2 -2
- package/dist/plugins/load.js +1 -1
- package/dist/plugins/model.d.ts +21 -36
- package/dist/plugins/webgl/host.d.ts +23 -23
- package/dist/plugins/webgl/host.js +25 -26
- package/dist/plugins/webgl/plugin.d.ts +16 -19
- package/dist/plugins/webgl/plugin.js +16 -23
- package/dist/project-preparation.js +12 -14
- package/dist/projection/abi.js +13 -10
- package/dist/projection/bindings.d.ts +8 -0
- package/dist/projection/bindings.js +36 -5
- package/dist/projection/callee.d.ts +17 -15
- package/dist/projection/callee.js +108 -81
- package/dist/projection/class-property-presence.d.ts +1 -1
- package/dist/projection/class-property-presence.js +1 -1
- package/dist/projection/classes.d.ts +2 -0
- package/dist/projection/classes.js +4 -1
- package/dist/projection/dispatch.d.ts +19 -3
- package/dist/projection/dispatch.js +39 -16
- package/dist/projection/fields.d.ts +14 -2
- package/dist/projection/fields.js +100 -38
- package/dist/projection/function-source.d.ts +5 -0
- package/dist/projection/function-source.js +15 -0
- package/dist/projection/immediate-callees.d.ts +12 -0
- package/dist/projection/immediate-callees.js +36 -0
- package/dist/projection/index-protocols.d.ts +12 -0
- package/dist/projection/index-protocols.js +39 -0
- package/dist/projection/instance-test.d.ts +8 -0
- package/dist/projection/instance-test.js +3 -1
- package/dist/projection/method-values.d.ts +7 -0
- package/dist/projection/method-values.js +29 -0
- package/dist/projection/native-accessor-access.d.ts +26 -0
- package/dist/projection/native-accessor-access.js +18 -0
- package/dist/projection/native-callable-data.d.ts +24 -0
- package/dist/projection/native-callable-data.js +101 -0
- package/dist/projection/native-expando.d.ts +3 -0
- package/dist/projection/native-expando.js +13 -0
- package/dist/projection/native-object-data.d.ts +47 -0
- package/dist/projection/native-object-data.js +203 -0
- package/dist/projection/native-prototype-methods.d.ts +22 -0
- package/dist/projection/native-prototype-methods.js +161 -0
- package/dist/projection/regexp-fields.d.ts +35 -0
- package/dist/projection/regexp-fields.js +80 -0
- package/dist/projection/slots.d.ts +5 -1
- package/dist/projection/slots.js +89 -10
- package/dist/representation/derive.d.ts +5 -7
- package/dist/representation/derive.js +78 -78
- package/dist/representation/difference.js +1 -1
- package/dist/representation/host-abi.d.ts +2 -2
- package/dist/representation/host-abi.js +4 -5
- package/dist/representation/host-templates.d.ts +6 -2
- package/dist/representation/host-templates.js +8 -2
- package/dist/representation/intersection.d.ts +3 -3
- package/dist/representation/intersection.js +3 -3
- package/dist/representation/merge.js +1 -1
- package/dist/representation/model.d.ts +27 -22
- package/dist/representation/model.js +35 -22
- package/dist/representation/native-callable-data-storage.d.ts +85 -0
- package/dist/representation/native-callable-data-storage.js +398 -0
- package/dist/representation/native-data-properties.d.ts +14 -0
- package/dist/representation/native-data-properties.js +52 -0
- package/dist/representation/native-logical-receiver.d.ts +36 -0
- package/dist/representation/native-logical-receiver.js +92 -0
- package/dist/representation/object-shape.d.ts +1 -1
- package/dist/representation/object-shape.js +1 -1
- package/dist/representation/optional.js +2 -2
- package/dist/representation/physical-carrier.d.ts +25 -0
- package/dist/representation/physical-carrier.js +153 -0
- package/dist/representation/policies.d.ts +16 -10
- package/dist/representation/policies.js +5 -1
- package/dist/representation/primitives.js +3 -0
- package/dist/representation/promise-resolution.d.ts +19 -0
- package/dist/representation/promise-resolution.js +50 -0
- package/dist/representation/prototype-domains.d.ts +43 -0
- package/dist/representation/prototype-domains.js +226 -0
- package/dist/representation/proxy-carriers.d.ts +3 -3
- package/dist/representation/proxy-carriers.js +2 -3
- package/dist/representation/publish.d.ts +4 -0
- package/dist/representation/publish.js +73 -42
- package/dist/representation/record-fields.d.ts +2 -2
- package/dist/representation/record-fields.js +2 -2
- package/dist/representation/static-field-cells.d.ts +1 -1
- package/dist/representation/structural-method-abi.d.ts +6 -0
- package/dist/representation/structural-method-abi.js +13 -0
- package/dist/representation/unassigned-binding-cells.d.ts +3 -3
- package/dist/representation/union.js +19 -4
- package/dist/representation/unwritten-record-members.d.ts +6 -6
- package/dist/representation/unwritten-record-members.js +1 -1
- package/dist/representation/value-records.js +77 -5
- package/dist/representation/verify.js +1 -1
- package/dist/representation/well-known-symbols.d.ts +3 -0
- package/dist/representation/well-known-symbols.js +11 -0
- package/dist/semantics/alias-this-field-declaration-transform.js +3 -3
- package/dist/semantics/ambient-type-realization-transform.d.ts +19 -20
- package/dist/semantics/ambient-type-realization-transform.js +20 -12
- package/dist/semantics/ambient.d.ts +13 -13
- package/dist/semantics/ambient.js +12 -12
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +5 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +110 -52
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.d.ts +4 -4
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +4 -4
- package/dist/semantics/call-invalidated-narrowing.js +2 -2
- package/dist/semantics/callable-origins.d.ts +49 -1
- package/dist/semantics/callable-origins.js +148 -32
- package/dist/semantics/callable-own-data-slots.d.ts +122 -0
- package/dist/semantics/callable-own-data-slots.js +421 -0
- package/dist/semantics/class-alias.d.ts +4 -4
- package/dist/semantics/class-alias.js +4 -4
- package/dist/semantics/class-heritage.d.ts +8 -7
- package/dist/semantics/class-heritage.js +8 -7
- package/dist/semantics/commonjs-wrapper.js +5 -2
- package/dist/semantics/constructor-function-class-source-transform.js +2 -3
- package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
- package/dist/semantics/constructor-slot-subclasses.js +5 -5
- package/dist/semantics/declaration-overlay-transform.d.ts +9 -12
- package/dist/semantics/declaration-overlay-transform.js +135 -142
- package/dist/semantics/declared-integers.d.ts +24 -0
- package/dist/semantics/declared-integers.js +34 -0
- package/dist/semantics/define-property-source-transform.js +21 -8
- package/dist/semantics/dynamic-fallback.d.ts +1 -1
- package/dist/semantics/dynamic-fallback.js +1 -1
- package/dist/semantics/frontend.d.ts +12 -16
- package/dist/semantics/frontend.js +187 -75
- package/dist/semantics/host-methods.d.ts +3 -3
- package/dist/semantics/host-methods.js +1 -1
- package/dist/semantics/host-protocols.d.ts +3 -3
- package/dist/semantics/host-protocols.js +26 -26
- package/dist/semantics/interface-families.d.ts +2 -2
- package/dist/semantics/interface-families.js +46 -47
- package/dist/semantics/interface-implementors.d.ts +12 -15
- package/dist/semantics/interface-implementors.js +12 -15
- package/dist/semantics/jsdoc-namepath-transform.js +7 -7
- package/dist/semantics/model/operands.d.ts +18 -3
- package/dist/semantics/model/operands.js +41 -0
- package/dist/semantics/model/operations.d.ts +82 -1
- package/dist/semantics/model/selected-signature.d.ts +24 -3
- package/dist/semantics/model/structural-type-table.js +24 -6
- package/dist/semantics/model/structural-types.d.ts +10 -8
- package/dist/semantics/model/structural-types.js +7 -5
- package/dist/semantics/module-resolution.js +3 -2
- package/dist/semantics/native-callable-readonly-set.d.ts +17 -0
- package/dist/semantics/native-callable-readonly-set.js +1 -0
- package/dist/semantics/native-function-signatures.d.ts +14 -0
- package/dist/semantics/native-function-signatures.js +96 -0
- package/dist/semantics/native-object-data-slots.d.ts +72 -0
- package/dist/semantics/native-object-data-slots.js +679 -0
- package/dist/semantics/native-own-assignment.d.ts +62 -0
- package/dist/semantics/native-own-assignment.js +1 -0
- package/dist/semantics/normalize/absent-globals.d.ts +8 -8
- package/dist/semantics/normalize/absent-globals.js +5 -5
- package/dist/semantics/normalize/arguments-objects.d.ts +3 -1
- package/dist/semantics/normalize/arguments-objects.js +1 -1
- package/dist/semantics/normalize/asserted-argument-arms.d.ts +7 -7
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -2
- package/dist/semantics/normalize/asserted-arm-absence.js +1 -2
- package/dist/semantics/normalize/binding-fixpoint.js +3 -3
- package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +2 -2
- package/dist/semantics/normalize/bivariant-slot-parameter.js +6 -6
- package/dist/semantics/normalize/callable-data-write.d.ts +46 -0
- package/dist/semantics/normalize/callable-data-write.js +182 -0
- package/dist/semantics/normalize/census.js +5 -5
- package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
- package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
- package/dist/semantics/normalize/collection-bindings.d.ts +11 -13
- package/dist/semantics/normalize/collection-bindings.js +60 -33
- package/dist/semantics/normalize/commonjs-module-record.d.ts +7 -4
- package/dist/semantics/normalize/commonjs-module-record.js +93 -4
- package/dist/semantics/normalize/contribution.js +4 -4
- package/dist/semantics/normalize/dead-method-copies.d.ts +5 -5
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +2 -2
- package/dist/semantics/normalize/dead-typeof-guards.js +6 -6
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +22 -13
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +85 -13
- package/dist/semantics/normalize/derived-expression-type.d.ts +129 -91
- package/dist/semantics/normalize/derived-expression-type.js +419 -192
- package/dist/semantics/normalize/field-bindings.d.ts +4 -4
- package/dist/semantics/normalize/field-bindings.js +334 -67
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +2 -2
- package/dist/semantics/normalize/flow/array-element-continuation.js +35 -18
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-array-origins.js +3 -3
- package/dist/semantics/normalize/flow/callable-completions.d.ts +2 -2
- package/dist/semantics/normalize/flow/callable-completions.js +2 -2
- package/dist/semantics/normalize/flow/callable-reach.d.ts +19 -6
- package/dist/semantics/normalize/flow/callable-reach.js +722 -289
- package/dist/semantics/normalize/flow/class-family-member-read.js +24 -29
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +2 -2
- package/dist/semantics/normalize/flow/collection-value-continuation.js +2 -2
- package/dist/semantics/normalize/flow/component-solver.d.ts +19 -16
- package/dist/semantics/normalize/flow/component-solver.js +138 -69
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +6 -7
- package/dist/semantics/normalize/flow/computed-key-set.js +20 -1
- package/dist/semantics/normalize/flow/export-importers.js +4 -4
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +3 -2
- package/dist/semantics/normalize/flow/host-text-sink.js +4 -3
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +3 -2
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +2 -2
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +3 -3
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +3 -2
- package/dist/semantics/normalize/flow/invocation-facts.js +3 -3
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +12 -6
- package/dist/semantics/normalize/flow/member-call-forwarding.js +94 -21
- package/dist/semantics/normalize/flow/model.d.ts +5 -5
- package/dist/semantics/normalize/flow/model.js +11 -11
- package/dist/semantics/normalize/flow/node-path-token.js +3 -3
- package/dist/semantics/normalize/flow/origin-authority.d.ts +3 -3
- package/dist/semantics/normalize/flow/owned-class-receivers.js +8 -7
- package/dist/semantics/normalize/flow/parameter-values.js +6 -6
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.js +56 -5
- package/dist/semantics/normalize/flow/proof-memo-settlement.d.ts +21 -0
- package/dist/semantics/normalize/flow/proof-memo-settlement.js +32 -0
- package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
- package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
- package/dist/semantics/normalize/flow/seeded-origins.d.ts +4 -4
- package/dist/semantics/normalize/flow/seeded-origins.js +4 -4
- package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +22 -0
- package/dist/semantics/normalize/flow/source-accessor-descriptor.js +210 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +33 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +238 -0
- package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +26 -0
- package/dist/semantics/normalize/flow/source-callable-readonly-set.js +337 -0
- package/dist/semantics/normalize/flow/source-class-data.d.ts +7 -7
- package/dist/semantics/normalize/flow/source-class-data.js +25 -26
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +2 -2
- package/dist/semantics/normalize/flow/source-class-static-data.js +2 -2
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +15 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +7 -0
- package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-descriptor-protocol.js +75 -0
- package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +8 -0
- package/dist/semantics/normalize/flow/source-executing-parameter-values.js +93 -0
- package/dist/semantics/normalize/flow/source-global-binding.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-global-binding.js +42 -0
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +27 -0
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +178 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +31 -11
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +7 -3
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +30 -2
- package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +7 -0
- package/dist/semantics/normalize/flow/source-native-class-alias.js +91 -0
- package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +10 -0
- package/dist/semantics/normalize/flow/source-normal-predecessor.js +90 -0
- package/dist/semantics/normalize/flow/source-property-key.d.ts +3 -0
- package/dist/semantics/normalize/flow/source-property-key.js +7 -0
- package/dist/semantics/normalize/flow/source-read-protocol.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-read-protocol.js +108 -0
- package/dist/semantics/normalize/flow/source-record-data.js +31 -30
- package/dist/semantics/normalize/flow/source-value-session.d.ts +106 -3
- package/dist/semantics/normalize/flow/source-value-session.js +1172 -218
- package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +16 -0
- package/dist/semantics/normalize/flow/standard-prototype-method-source.js +64 -0
- package/dist/semantics/normalize/flow/targets.d.ts +13 -14
- package/dist/semantics/normalize/flow/targets.js +20 -23
- package/dist/semantics/normalize/flow/value-flow.d.ts +2 -4
- package/dist/semantics/normalize/flow/value-flow.js +4 -13
- package/dist/semantics/normalize/flow/value-provenance.d.ts +23 -3
- package/dist/semantics/normalize/flow/value-provenance.js +44 -4
- package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +32 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +530 -0
- package/dist/semantics/normalize/fresh-indexed-storage.d.ts +43 -0
- package/dist/semantics/normalize/fresh-indexed-storage.js +88 -0
- package/dist/semantics/normalize/fresh-ordinary-object.d.ts +8 -0
- package/dist/semantics/normalize/fresh-ordinary-object.js +27 -0
- package/dist/semantics/normalize/gating.js +2 -2
- package/dist/semantics/normalize/global-host-mutations.js +770 -261
- package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
- package/dist/semantics/normalize/host-effect-contracts.js +1 -1
- package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +2 -2
- package/dist/semantics/normalize/host-mutation-computed-keys.js +8 -0
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +6 -11
- package/dist/semantics/normalize/host-mutation-key-reader.js +11 -28
- package/dist/semantics/normalize/host-mutation-keys.d.ts +11 -7
- package/dist/semantics/normalize/host-mutation-keys.js +26 -15
- package/dist/semantics/normalize/identities.js +20 -17
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +8 -3
- package/dist/semantics/normalize/implicit-arguments-tuple.js +21 -4
- package/dist/semantics/normalize/installed-global-properties.d.ts +17 -0
- package/dist/semantics/normalize/installed-global-properties.js +214 -0
- package/dist/semantics/normalize/instantiation.js +6 -6
- package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +6 -1
- package/dist/semantics/normalize/intrinsic-property-call.js +19 -0
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +7 -0
- package/dist/semantics/normalize/intrinsic-prototype.js +10 -0
- package/dist/semantics/normalize/intrinsic-return-identity.d.ts +5 -0
- package/dist/semantics/normalize/intrinsic-return-identity.js +29 -0
- package/dist/semantics/normalize/jsdoc-type-names.js +59 -63
- package/dist/semantics/normalize/keyof.js +3 -3
- package/dist/semantics/normalize/local-bindings.d.ts +4 -4
- package/dist/semantics/normalize/local-bindings.js +60 -61
- package/dist/semantics/normalize/logical-object-truthiness.d.ts +8 -0
- package/dist/semantics/normalize/logical-object-truthiness.js +20 -0
- package/dist/semantics/normalize/merged-declaration.d.ts +3 -3
- package/dist/semantics/normalize/merged-declaration.js +3 -3
- package/dist/semantics/normalize/never-override-result.d.ts +2 -3
- package/dist/semantics/normalize/never-override-result.js +2 -3
- package/dist/semantics/normalize/null-blind-parameter.d.ts +2 -2
- package/dist/semantics/normalize/null-blind-parameter.js +2 -2
- package/dist/semantics/normalize/object-bag-bindings.d.ts +19 -19
- package/dist/semantics/normalize/object-bag-bindings.js +334 -141
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +8 -8
- package/dist/semantics/normalize/omitted-stated-parameter.js +8 -9
- package/dist/semantics/normalize/override-field-arms.d.ts +3 -3
- package/dist/semantics/normalize/override-field-arms.js +15 -16
- package/dist/semantics/normalize/parameter-bindings.d.ts +13 -12
- package/dist/semantics/normalize/parameter-bindings.js +173 -139
- package/dist/semantics/normalize/parameter-slot.d.ts +9 -10
- package/dist/semantics/normalize/parameter-slot.js +16 -17
- package/dist/semantics/normalize/physical-overload-result.d.ts +8 -8
- package/dist/semantics/normalize/physical-overload-result.js +10 -10
- package/dist/semantics/normalize/producer-context.d.ts +27 -12
- package/dist/semantics/normalize/producers/allocations.js +5 -1
- package/dist/semantics/normalize/producers/bindings.js +8 -7
- package/dist/semantics/normalize/producers/class-lifecycle.js +52 -7
- package/dist/semantics/normalize/producers/computations.js +27 -3
- package/dist/semantics/normalize/producers/control.js +5 -5
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +4 -4
- package/dist/semantics/normalize/producers/destructuring.js +10 -5
- package/dist/semantics/normalize/producers/erasure.d.ts +9 -0
- package/dist/semantics/normalize/producers/erasure.js +22 -0
- package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
- package/dist/semantics/normalize/producers/invocations.js +200 -55
- package/dist/semantics/normalize/producers/logical-merge-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/logical-merge-type.js +12 -12
- package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +6 -0
- package/dist/semantics/normalize/producers/native-callable-readonly-set.js +24 -0
- package/dist/semantics/normalize/producers/native-own-assignment.d.ts +14 -0
- package/dist/semantics/normalize/producers/native-own-assignment.js +153 -0
- package/dist/semantics/normalize/producers/properties.js +153 -20
- package/dist/semantics/normalize/producers/protocol.js +4 -4
- package/dist/semantics/normalize/producers/references.js +21 -19
- package/dist/semantics/normalize/producers/shared.d.ts +1 -1
- package/dist/semantics/normalize/producers/shared.js +59 -58
- package/dist/semantics/normalize/producers/spread-arguments.js +7 -3
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +2 -2
- package/dist/semantics/normalize/producers/tuple-spread.js +5 -5
- package/dist/semantics/normalize/property-key-domain.d.ts +6 -6
- package/dist/semantics/normalize/property-key-domain.js +7 -7
- package/dist/semantics/normalize/reachability.d.ts +6 -7
- package/dist/semantics/normalize/reachability.js +60 -62
- package/dist/semantics/normalize/record-home-arms.js +2 -3
- package/dist/semantics/normalize/record-link-families.d.ts +1 -1
- package/dist/semantics/normalize/record-link-families.js +1 -1
- package/dist/semantics/normalize/record-stand-in-arms.d.ts +4 -5
- package/dist/semantics/normalize/return-bindings.d.ts +19 -9
- package/dist/semantics/normalize/return-bindings.js +49 -41
- package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
- package/dist/semantics/normalize/script-global-redefinition.js +1 -1
- package/dist/semantics/normalize/shared-array-storage.d.ts +4 -5
- package/dist/semantics/normalize/shared-array-storage.js +7 -8
- package/dist/semantics/normalize/sloppy-absence.d.ts +6 -3
- package/dist/semantics/normalize/sloppy-absence.js +7 -3
- package/dist/semantics/normalize/source-object-prototype-absence.d.ts +7 -0
- package/dist/semantics/normalize/source-object-prototype-absence.js +19 -0
- package/dist/semantics/normalize/specialization.d.ts +10 -10
- package/dist/semantics/normalize/specialization.js +107 -112
- package/dist/semantics/normalize/specialized-source-frames.d.ts +11 -0
- package/dist/semantics/normalize/specialized-source-frames.js +41 -0
- package/dist/semantics/normalize/structural-array-element.d.ts +5 -5
- package/dist/semantics/normalize/structural-array-element.js +40 -39
- package/dist/semantics/normalize/structural-array-read.js +3 -3
- package/dist/semantics/normalize/structural-callable.d.ts +15 -1
- package/dist/semantics/normalize/structural-callable.js +35 -3
- package/dist/semantics/normalize/structural-creation-order.d.ts +2 -2
- package/dist/semantics/normalize/structural-declarations.d.ts +22 -21
- package/dist/semantics/normalize/structural-declarations.js +42 -42
- package/dist/semantics/normalize/structural-declared-body.js +10 -11
- package/dist/semantics/normalize/structural-indexed-access.js +2 -2
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +9 -10
- package/dist/semantics/normalize/structural-instantiated-member.js +43 -30
- package/dist/semantics/normalize/structural-joins.d.ts +4 -16
- package/dist/semantics/normalize/structural-joins.js +5 -65
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +5 -5
- package/dist/semantics/normalize/structural-layout-relevance.js +22 -23
- package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-type.js +140 -107
- package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
- package/dist/semantics/normalize/structural-local-union.js +38 -12
- package/dist/semantics/normalize/structural-mutable-field.d.ts +9 -0
- package/dist/semantics/normalize/structural-mutable-field.js +152 -0
- package/dist/semantics/normalize/structural-parts.d.ts +6 -0
- package/dist/semantics/normalize/structural-parts.js +35 -32
- package/dist/semantics/normalize/structural-receiver.d.ts +3 -3
- package/dist/semantics/normalize/structural-receiver.js +12 -13
- package/dist/semantics/normalize/structural-self-reference.d.ts +12 -11
- package/dist/semantics/normalize/structural-self-reference.js +24 -25
- package/dist/semantics/normalize/structural.d.ts +13 -3
- package/dist/semantics/normalize/structural.js +400 -201
- package/dist/semantics/normalize/suppressed-write-arms.d.ts +10 -11
- package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +6 -6
- package/dist/semantics/normalize/symbol-keyed-this-slots.js +4 -4
- package/dist/semantics/normalize/unresolvable-names.d.ts +2 -3
- package/dist/semantics/normalize/unresolvable-names.js +2 -2
- package/dist/semantics/normalize/unshared-array-result.d.ts +4 -4
- package/dist/semantics/normalize/unshared-array-result.js +4 -4
- package/dist/semantics/package-sources.js +2 -3
- package/dist/semantics/program.d.ts +10 -13
- package/dist/semantics/program.js +80 -26
- package/dist/semantics/property-key.d.ts +9 -0
- package/dist/semantics/property-key.js +25 -0
- package/dist/semantics/prototype-object-class-source-transform.js +2 -2
- package/dist/semantics/prototype-reparenting.d.ts +1 -1
- package/dist/semantics/prototype-reparenting.js +1 -1
- package/dist/semantics/shared-declaration-files.d.ts +6 -1
- package/dist/semantics/shared-declaration-files.js +2 -2
- package/dist/semantics/source-transform-protocol.d.ts +26 -0
- package/dist/semantics/source-transform-protocol.js +1 -0
- package/dist/semantics/stable-checker.js +9 -13
- package/dist/semantics/subclass-member-overlay-transform.d.ts +2 -2
- package/dist/semantics/subclass-member-overlay-transform.js +89 -88
- package/dist/semantics/this-constructor-source-transform.js +2 -2
- package/dist/semantics/unchecked-guard-argument-copies.d.ts +3 -3
- package/dist/semantics/unchecked-write-member-declarations.d.ts +9 -11
- package/dist/semantics/unchecked-write-member-declarations.js +11 -13
- package/dist/semantics/uninstantiable-classes.d.ts +1 -1
- package/dist/semantics/uninstantiable-classes.js +1 -1
- package/dist/targets/cpp/balanced-units.d.ts +1 -1
- package/dist/targets/cpp/balanced-units.js +1 -1
- package/dist/targets/cpp/borrowed-arm-projections.d.ts +2 -3
- package/dist/targets/cpp/borrowed-arm-projections.js +2 -3
- package/dist/targets/cpp/borrowed-call-entry.js +3 -3
- package/dist/targets/cpp/captures.d.ts +2 -2
- package/dist/targets/cpp/captures.js +4 -4
- package/dist/targets/cpp/char-code-buffers.d.ts +1 -1
- package/dist/targets/cpp/char-code-buffers.js +4 -1
- package/dist/targets/cpp/class-layout.d.ts +7 -17
- package/dist/targets/cpp/class-layout.js +6 -13
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +1 -1
- package/dist/targets/cpp/class-properties/computed-method-value.js +5 -27
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +49 -59
- package/dist/targets/cpp/class-properties/emit-class-properties.js +68 -232
- package/dist/targets/cpp/class-properties/native-method-read.d.ts +5 -0
- package/dist/targets/cpp/class-properties/native-method-read.js +60 -0
- package/dist/targets/cpp/class-properties/native-prototype.d.ts +3 -1
- package/dist/targets/cpp/class-properties/native-prototype.js +5 -6
- package/dist/targets/cpp/class-ref-transport.d.ts +1 -11
- package/dist/targets/cpp/class-ref-transport.js +1 -9
- package/dist/targets/cpp/conversions.js +613 -252
- package/dist/targets/cpp/coroutine-bodies.d.ts +1 -97
- package/dist/targets/cpp/coroutine-bodies.js +1 -187
- package/dist/targets/cpp/document.js +1 -1
- package/dist/targets/cpp/emit-allocation.d.ts +0 -38
- package/dist/targets/cpp/emit-allocation.js +63 -88
- package/dist/targets/cpp/emit-array-view.d.ts +7 -0
- package/dist/targets/cpp/emit-array-view.js +47 -0
- package/dist/targets/cpp/emit-arrays.d.ts +9 -52
- package/dist/targets/cpp/emit-arrays.js +177 -113
- package/dist/targets/cpp/emit-binding-reference.d.ts +10 -0
- package/dist/targets/cpp/emit-binding-reference.js +19 -1
- package/dist/targets/cpp/emit-bindings.js +19 -24
- package/dist/targets/cpp/emit-buffers.d.ts +8 -4
- package/dist/targets/cpp/emit-buffers.js +88 -47
- package/dist/targets/cpp/emit-callable-view.d.ts +6 -0
- package/dist/targets/cpp/emit-callable-view.js +133 -0
- package/dist/targets/cpp/emit-callable.d.ts +11 -1
- package/dist/targets/cpp/emit-callable.js +225 -266
- package/dist/targets/cpp/emit-carrier-members.d.ts +2 -2
- package/dist/targets/cpp/emit-carrier-members.js +42 -35
- package/dist/targets/cpp/emit-certified-conversion.d.ts +7 -0
- package/dist/targets/cpp/emit-certified-conversion.js +27 -0
- package/dist/targets/cpp/emit-context.d.ts +123 -64
- package/dist/targets/cpp/emit-context.js +147 -44
- package/dist/targets/cpp/emit-descriptor-snapshot.d.ts +10 -0
- package/dist/targets/cpp/emit-descriptor-snapshot.js +60 -0
- package/dist/targets/cpp/emit-dictionary-view.d.ts +6 -0
- package/dist/targets/cpp/emit-dictionary-view.js +102 -0
- package/dist/targets/cpp/emit-document-record-view.d.ts +3 -0
- package/dist/targets/cpp/emit-document-record-view.js +104 -0
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +42 -17
- package/dist/targets/cpp/emit-dynamic-properties.js +118 -72
- package/dist/targets/cpp/emit-equality.d.ts +2 -1
- package/dist/targets/cpp/emit-equality.js +65 -45
- package/dist/targets/cpp/emit-exceptions.js +1 -1
- package/dist/targets/cpp/emit-in.js +22 -11
- package/dist/targets/cpp/emit-instanceof.js +15 -14
- package/dist/targets/cpp/emit-integers.d.ts +40 -3
- package/dist/targets/cpp/emit-integers.js +76 -5
- package/dist/targets/cpp/emit-iterable-object-view.d.ts +2 -0
- package/dist/targets/cpp/emit-iterable-object-view.js +15 -11
- package/dist/targets/cpp/emit-iterator-object-view.d.ts +2 -0
- package/dist/targets/cpp/emit-iterator-object-view.js +24 -16
- package/dist/targets/cpp/emit-iterator.d.ts +2 -0
- package/dist/targets/cpp/emit-iterator.js +115 -43
- package/dist/targets/cpp/emit-json.js +6 -6
- package/dist/targets/cpp/emit-jsx.js +2 -2
- package/dist/targets/cpp/emit-live-field-view.d.ts +26 -0
- package/dist/targets/cpp/emit-live-field-view.js +50 -0
- package/dist/targets/cpp/emit-narrowing.d.ts +60 -139
- package/dist/targets/cpp/emit-narrowing.js +694 -624
- package/dist/targets/cpp/emit-native-accessor-definition.d.ts +10 -0
- package/dist/targets/cpp/emit-native-accessor-definition.js +94 -0
- package/dist/targets/cpp/emit-native-callable-data.d.ts +23 -0
- package/dist/targets/cpp/emit-native-callable-data.js +117 -0
- package/dist/targets/cpp/emit-native-document-entry.d.ts +4 -0
- package/dist/targets/cpp/emit-native-document-entry.js +52 -0
- package/dist/targets/cpp/emit-native-field-view.d.ts +26 -0
- package/dist/targets/cpp/emit-native-field-view.js +217 -0
- package/dist/targets/cpp/emit-native-method.d.ts +16 -0
- package/dist/targets/cpp/emit-native-method.js +90 -0
- package/dist/targets/cpp/emit-native-object-data.d.ts +7 -0
- package/dist/targets/cpp/emit-native-object-data.js +66 -0
- package/dist/targets/cpp/emit-native-object-sample.d.ts +8 -0
- package/dist/targets/cpp/emit-native-object-sample.js +34 -0
- package/dist/targets/cpp/emit-native-own-assignment.d.ts +7 -0
- package/dist/targets/cpp/emit-native-own-assignment.js +119 -0
- package/dist/targets/cpp/emit-native-selection.d.ts +2 -2
- package/dist/targets/cpp/emit-native-selection.js +14 -5
- package/dist/targets/cpp/emit-number-storage.d.ts +2 -0
- package/dist/targets/cpp/emit-number-storage.js +1 -0
- package/dist/targets/cpp/emit-presence.d.ts +3 -4
- package/dist/targets/cpp/emit-presence.js +43 -21
- package/dist/targets/cpp/emit-properties.js +224 -111
- package/dist/targets/cpp/emit-protocol-iterator.d.ts +2 -0
- package/dist/targets/cpp/emit-protocol-iterator.js +45 -23
- package/dist/targets/cpp/emit-record-view.d.ts +5 -10
- package/dist/targets/cpp/emit-record-view.js +223 -269
- package/dist/targets/cpp/emit-return.js +33 -8
- package/dist/targets/cpp/emit-scopes.d.ts +2 -2
- package/dist/targets/cpp/emit-sum-widening.js +13 -5
- package/dist/targets/cpp/emit-tonumber.d.ts +1 -1
- package/dist/targets/cpp/emit-tonumber.js +3 -3
- package/dist/targets/cpp/emit-tostring.d.ts +20 -2
- package/dist/targets/cpp/emit-tostring.js +131 -28
- package/dist/targets/cpp/emit-typeof.d.ts +4 -0
- package/dist/targets/cpp/emit-typeof.js +29 -1
- package/dist/targets/cpp/emit-union-properties.d.ts +6 -23
- package/dist/targets/cpp/emit-union-properties.js +127 -235
- package/dist/targets/cpp/emit.d.ts +4 -1
- package/dist/targets/cpp/emit.js +336 -119
- package/dist/targets/cpp/error-types.d.ts +1 -3
- package/dist/targets/cpp/error-types.js +1 -2
- package/dist/targets/cpp/evaluated-once.d.ts +4 -4
- package/dist/targets/cpp/evaluated-once.js +5 -5
- package/dist/targets/cpp/function-source-reads.d.ts +2 -15
- package/dist/targets/cpp/function-source-reads.js +3 -38
- package/dist/targets/cpp/host/core-globals.d.ts +5 -0
- package/dist/targets/cpp/host/core-globals.js +10 -0
- package/dist/targets/cpp/host/emit-host-arity.js +1 -1
- package/dist/targets/cpp/host/emit-host-invoke.js +73 -23
- package/dist/targets/cpp/host/emit-host-object.d.ts +2 -1
- package/dist/targets/cpp/host/emit-host-object.js +328 -145
- package/dist/targets/cpp/host/emit-host-properties.js +4 -6
- package/dist/targets/cpp/host/emit-host-reflect.js +29 -5
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +2 -2
- package/dist/targets/cpp/host/host-members.d.ts +11 -0
- package/dist/targets/cpp/host/host-members.js +27 -5
- package/dist/targets/cpp/host/host-method-aliases.d.ts +1 -30
- package/dist/targets/cpp/host/host-method-aliases.js +1 -76
- package/dist/targets/cpp/host/native-protocols.js +1 -1
- package/dist/targets/cpp/host/object-protocol.d.ts +1 -1
- package/dist/targets/cpp/host/object-protocol.js +24 -24
- package/dist/targets/cpp/host-namespace-reads.d.ts +1 -83
- package/dist/targets/cpp/host-namespace-reads.js +1 -113
- package/dist/targets/cpp/manifest/capabilities.js +33 -33
- package/dist/targets/cpp/manifest.d.ts +5 -0
- package/dist/targets/cpp/manifest.js +38 -14
- package/dist/targets/cpp/native-collection-base.js +7 -6
- package/dist/targets/cpp/native-debug-source.d.ts +15 -0
- package/dist/targets/cpp/native-debug-source.js +21 -0
- package/dist/targets/cpp/native-error-base.d.ts +1 -1
- package/dist/targets/cpp/native-error-base.js +1 -1
- package/dist/targets/cpp/native-narrowing-transport.d.ts +2 -0
- package/dist/targets/cpp/native-narrowing-transport.js +25 -5
- package/dist/targets/cpp/native-view-targets.d.ts +3 -0
- package/dist/targets/cpp/native-view-targets.js +5 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +3 -33
- package/dist/targets/cpp/prototype/emit-prototype-array.js +40 -22
- package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +1 -58
- package/dist/targets/cpp/prototype/emit-prototype-date.js +14 -97
- package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +20 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +3 -27
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +60 -52
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +1 -41
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +4 -43
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +2 -13
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +10 -58
- package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +4 -25
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +16 -81
- package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +1 -1
- package/dist/targets/cpp/prototype/emit-prototype-string.js +17 -28
- package/dist/targets/cpp/prototype/prototype-method-reads.js +4 -80
- package/dist/targets/cpp/reactive-dependencies.d.ts +12 -6
- package/dist/targets/cpp/reactive-dependencies.js +62 -42
- package/dist/targets/cpp/reactive-origins.js +12 -0
- package/dist/targets/cpp/records.d.ts +133 -14
- package/dist/targets/cpp/records.js +345 -153
- package/dist/targets/cpp/regexp-types.d.ts +1 -26
- package/dist/targets/cpp/regexp-types.js +4 -29
- package/dist/targets/cpp/segment-scopes.d.ts +30 -0
- package/dist/targets/cpp/segment-scopes.js +294 -0
- package/dist/targets/cpp/translation-unit.d.ts +21 -2
- package/dist/targets/cpp/translation-unit.js +121 -276
- package/dist/targets/cpp/types.d.ts +8 -3
- package/dist/targets/cpp/types.js +30 -6
- package/dist/targets/cpp/virtual-callees.d.ts +18 -0
- package/dist/targets/cpp/virtual-callees.js +27 -0
- package/dist/targets/cpp/virtual-methods.d.ts +7 -7
- package/dist/targets/cpp/virtual-methods.js +213 -58
- package/package.json +8 -3
- package/src/targets/cpp/runtime/gea_dictionary_view.h +204 -0
- package/src/targets/cpp/runtime/gea_document_view.h +845 -0
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +66 -23
- package/src/targets/cpp/runtime/gea_eval.h +6 -6
- package/src/targets/cpp/runtime/gea_runtime.h +7550 -1166
- package/dist/targets/cpp/direct-call-receivers.d.ts +0 -37
- package/dist/targets/cpp/direct-call-receivers.js +0 -79
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import { isGlobalObjectAssign } from '../derived-expression-type.js';
|
|
2
3
|
import { isClassSpelledSourceClass } from './model.js';
|
|
3
4
|
import { dependencyFactSolver } from './component-solver.js';
|
|
4
|
-
import { classConstructorKeepsInstanceOf, exactSourceConstructionOf, sourceConstructorSelectionsOf } from './member-call-forwarding.js';
|
|
5
|
+
import { classConstructorKeepsInstanceOf, exactSourceConstructionOf, ordinarySourceClassInstanceTestOf, sourceConstructorSelectionsOf } from './member-call-forwarding.js';
|
|
5
6
|
import { sourceClassCallableMemberPlanOf, sourceClassDataMemberPlanOf, sourceClassKeyReadPlanOf } from './source-class-data.js';
|
|
6
7
|
import { sourceClassFamilyOf } from './owned-class-receivers.js';
|
|
7
|
-
import { isGlobalObjectAssign } from './value-flow.js';
|
|
8
8
|
import { intrinsicDataDefinitionTargetOf } from './intrinsic-data-definition.js';
|
|
9
9
|
import { callableCompletionSummaryOf, constructionYieldsCompletionOf } from './callable-completions.js';
|
|
10
10
|
import { sourceInvocationFrameLayoutOf } from './source-invocation-frame-layout.js';
|
|
11
|
-
import {
|
|
11
|
+
import { bindingReadMayPrecedeFirstWrite, sourceBindingValuesOf, sourceBindingWritesAreComplete } from './value-provenance.js';
|
|
12
12
|
import { collectionStoredValuesOf, collectionValueContinuationsOf } from './collection-value-continuation.js';
|
|
13
|
-
import { isTypePositionReference, runtimeParametersOf, unwrapNaming } from './targets.js';
|
|
13
|
+
import { isModuleExportedDeclaration, isTypePositionReference, runtimeParametersOf, unwrapNaming } from './targets.js';
|
|
14
14
|
import { outermostErasureOf, unwrapErasedExpression } from '../producers/erasure.js';
|
|
15
|
+
import { literalSourcePropertyKeyOf } from './source-property-key.js';
|
|
15
16
|
import { deferredIntrinsicProtocolLedgerOf } from '../deferred-intrinsic-protocols.js';
|
|
16
17
|
import { censusArgumentsObjects } from '../arguments-objects.js';
|
|
17
18
|
import { exportIsUnimported } from './targets.js';
|
|
18
19
|
import { inProgramImportReferencesOf } from './export-importers.js';
|
|
19
20
|
import { sourceConstructionFramesOf } from './source-construction-frames.js';
|
|
20
21
|
import { isSourceInstanceMethod } from './source-prototype-method-identity.js';
|
|
22
|
+
import { sourceGlobalCallableBindingIsClosed } from './source-global-binding.js';
|
|
23
|
+
import { isSourceCallableObject, sourceCallableObjectOf, sourceCallableReflectSetOf, sourceCallableDataWriteProtocolOf, sourceCallableOwnDataWriteOf, sourceCallableOwnDataMayBeWrittenOf } from './source-callable-own-data.js';
|
|
24
|
+
import { intrinsicJsonStringifyQueryOf, intrinsicOwnKeyQueryOf } from '../intrinsic-property-call.js';
|
|
25
|
+
import { sourceObjectPrototypeAbsenceOf } from '../source-object-prototype-absence.js';
|
|
26
|
+
import { sourceFreshOrdinaryObjectOf } from '../fresh-ordinary-object.js';
|
|
27
|
+
import { sourceIntrinsicMemberDataWriteOf, sourceIntrinsicMemberMayBeWrittenOf } from './source-intrinsic-member-data.js';
|
|
28
|
+
import { sourceCommonJsExportUsesOf, sourceCommonJsExportValueOf } from './source-commonjs-exports.js';
|
|
21
29
|
/**
|
|
22
30
|
* Walk two lists as one without building a third.
|
|
23
31
|
*
|
|
@@ -31,6 +39,7 @@ const refusalDebug = process.env['GEA_SESSION_REFUSALS'] !== undefined;
|
|
|
31
39
|
const VALUE_CARRYING_KINDS = new Set([
|
|
32
40
|
'value',
|
|
33
41
|
'slot',
|
|
42
|
+
'stored-slot',
|
|
34
43
|
'parameter',
|
|
35
44
|
'binding-element',
|
|
36
45
|
'super-targets',
|
|
@@ -47,12 +56,12 @@ const VALUE_ORIGIN = 'source-value-origin';
|
|
|
47
56
|
const noArrayKeys = process.env['GEA_NO_ARRAY_KEYS'] !== undefined;
|
|
48
57
|
/**
|
|
49
58
|
* The element slot of an array root: every position at once. A computed
|
|
50
|
-
* index names no single key (`this.
|
|
51
|
-
* with the loop counter as the index), so a store or read through one is
|
|
59
|
+
* index names no single key (`this.items[ i ]` in a constructor that fills
|
|
60
|
+
* an array field in a loop, with the loop counter as the index), so a store or read through one is
|
|
52
61
|
* filed under this key, and a literal-index slot and this one alias each
|
|
53
62
|
* other -- `slot(root, '0')` includes what `[ i ]` stored, and `[ i ]` reads
|
|
54
63
|
* what `[ 0 ]` stored. Before this the unbounded index published nothing and
|
|
55
|
-
* read nothing, and every
|
|
64
|
+
* read nothing, and every such array's elements were unresolvable.
|
|
56
65
|
*/
|
|
57
66
|
const ELEMENT_KEY = '[]';
|
|
58
67
|
const CANONICAL_INDEX = /^(?:0|[1-9][0-9]*)$/;
|
|
@@ -61,13 +70,10 @@ const isCanonicalIndex = (key) => CANONICAL_INDEX.test(key);
|
|
|
61
70
|
const keyReaches = (root, stored, key) => stored.includes(key) ||
|
|
62
71
|
(ts.isArrayLiteralExpression(root) &&
|
|
63
72
|
((key === ELEMENT_KEY && stored.some(isCanonicalIndex)) || (isCanonicalIndex(key) && stored.includes(ELEMENT_KEY))));
|
|
64
|
-
const
|
|
73
|
+
const isSpelledObjectRoot = (node) => ts.isNewExpression(node) || ts.isObjectLiteralExpression(node) || ts.isArrayLiteralExpression(node) || isSourceCallableObject(node);
|
|
65
74
|
const isBody = (node) => ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodDeclaration(node);
|
|
66
75
|
const accessKey = (access) => ts.isPropertyAccessExpression(access) ? access.name.text : literalKey(access.argumentExpression);
|
|
67
|
-
const literalKey =
|
|
68
|
-
const value = unwrapErasedExpression(node);
|
|
69
|
-
return ts.isStringLiteralLike(value) || ts.isNumericLiteral(value) ? value.text : null;
|
|
70
|
-
};
|
|
76
|
+
const literalKey = literalSourcePropertyKeyOf;
|
|
71
77
|
const declarationKey = (name) => ts.isComputedPropertyName(name) ? literalKey(name.expression) : ts.isPrivateIdentifier(name) ? null : name.text;
|
|
72
78
|
/**
|
|
73
79
|
* The slot a binding element reads out of the object being destructured.
|
|
@@ -88,15 +94,67 @@ const bindingElementKey = (element) => {
|
|
|
88
94
|
return ts.isIdentifier(element.name) ? element.name.text : null;
|
|
89
95
|
};
|
|
90
96
|
const sessions = new WeakMap();
|
|
97
|
+
/**
|
|
98
|
+
* The session handed out is a facade over the solver that does the work, so
|
|
99
|
+
* the solver can be released without finding every holder of the facade.
|
|
100
|
+
* Holders are many -- census closures capture it, and the binding fixpoint
|
|
101
|
+
* keeps every round's census reachable through its `upstream` chain
|
|
102
|
+
* (`parameter-bindings.ts`) -- so a finished round's ~1 GB solver used to stay
|
|
103
|
+
* alive for the rest of the compile.
|
|
104
|
+
*/
|
|
91
105
|
export const sourceValueSessionOf = (checker, flow) => {
|
|
92
106
|
const known = sessions.get(flow);
|
|
93
107
|
if (known)
|
|
94
|
-
return known;
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
return known.session;
|
|
109
|
+
// Built now, not on first question, so solver construction keeps its place in the compile.
|
|
110
|
+
let solver = createSession(checker, flow);
|
|
111
|
+
const live = () => {
|
|
112
|
+
if (solver !== null)
|
|
113
|
+
return solver;
|
|
114
|
+
return (solver = createSession(checker, flow));
|
|
115
|
+
};
|
|
116
|
+
const session = {
|
|
117
|
+
ownsInvocation: (call) => live().ownsInvocation(call),
|
|
118
|
+
invocationTargetsOf: (call) => live().invocationTargetsOf(call),
|
|
119
|
+
candidateOrdinaryOwnCallableOperandsOf: (call) => live().candidateOrdinaryOwnCallableOperandsOf(call),
|
|
120
|
+
ordinaryOwnCallableOperandsOf: (call) => live().ordinaryOwnCallableOperandsOf(call),
|
|
121
|
+
ordinaryOwnCallableSourceOf: (call) => live().ordinaryOwnCallableSourceOf(call),
|
|
122
|
+
valuesOf: (expression) => live().valuesOf(expression),
|
|
123
|
+
closedValuesOf: (expression) => live().closedValuesOf(expression),
|
|
124
|
+
memberValuesOf: (expression, key) => live().memberValuesOf(expression, key),
|
|
125
|
+
ownSlotOf: (expression, key) => live().ownSlotOf(expression, key),
|
|
126
|
+
ownAssignmentOf: (call, frames, describedKeysOf) => live().ownAssignmentOf(call, frames, describedKeysOf),
|
|
127
|
+
callerSitesOf: (body) => live().callerSitesOf(body),
|
|
128
|
+
parameterValuesOf: (parameter) => live().parameterValuesOf(parameter),
|
|
129
|
+
parameterSourceExpressionsOf: (parameter) => live().parameterSourceExpressionsOf(parameter),
|
|
130
|
+
explainParameter: (parameter) => live().explainParameter(parameter),
|
|
131
|
+
explainInvocation: (call) => live().explainInvocation(call),
|
|
132
|
+
explainValue: (expression) => live().explainValue(expression)
|
|
133
|
+
};
|
|
134
|
+
sessions.set(flow, {
|
|
135
|
+
session,
|
|
136
|
+
retire: () => {
|
|
137
|
+
solver = null;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
97
140
|
return session;
|
|
98
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Releases the solver behind `flow`'s session. A later question is still
|
|
144
|
+
* answered: by a fresh solver over the same flow, which reaches the same
|
|
145
|
+
* fixed point. The frontend retires a round's flow once the next round has
|
|
146
|
+
* replaced it, and the final round's once the frontend returns. On a
|
|
147
|
+
* large program no retired session is ever asked again; of the gate's programs
|
|
148
|
+
* one is (a later census falling through `upstream` to an earlier round,
|
|
149
|
+
* `indexed-absence-forwarded-cache`), and its rebuilt answer emits the same
|
|
150
|
+
* program.
|
|
151
|
+
*/
|
|
152
|
+
export const retireSourceValueSession = (flow) => {
|
|
153
|
+
sessions.get(flow)?.retire();
|
|
154
|
+
};
|
|
99
155
|
const createSession = (checker, flow) => {
|
|
156
|
+
const isFreshOrdinaryObject = (node) => sourceFreshOrdinaryObjectOf(checker, node);
|
|
157
|
+
const isObjectRoot = (node) => isSpelledObjectRoot(node) || isFreshOrdinaryObject(node);
|
|
100
158
|
// A closed native Map is only closed while `Map.prototype`'s `get`/`set`
|
|
101
159
|
// are the intrinsics: a finite root walk is not that proof
|
|
102
160
|
// (`native-collection-protocol.ts`), so only the deferred obligation -- an
|
|
@@ -106,6 +164,7 @@ const createSession = (checker, flow) => {
|
|
|
106
164
|
deferredIntrinsicProtocolLedgerOf(flow)?.requirePrototypeKeys(plan.intrinsic, plan.prototypeKeys, plan.location) === true;
|
|
107
165
|
const unary = new Map();
|
|
108
166
|
const slots = new Map();
|
|
167
|
+
const storedSlots = new Map();
|
|
109
168
|
const uses = new Map();
|
|
110
169
|
const publications = new Map();
|
|
111
170
|
const frameQueries = new Map();
|
|
@@ -120,8 +179,79 @@ const createSession = (checker, flow) => {
|
|
|
120
179
|
};
|
|
121
180
|
const undefinedValue = ts.factory.createVoidZero();
|
|
122
181
|
const arrayLengths = new Map();
|
|
182
|
+
const keyValues = new Map();
|
|
183
|
+
const keyValue = (root, key) => {
|
|
184
|
+
let keys = keyValues.get(root);
|
|
185
|
+
if (!keys)
|
|
186
|
+
keyValues.set(root, (keys = new Map()));
|
|
187
|
+
let literal = keys.get(key);
|
|
188
|
+
if (!literal)
|
|
189
|
+
keys.set(key, (literal = ts.factory.createStringLiteral(key)));
|
|
190
|
+
return literal;
|
|
191
|
+
};
|
|
123
192
|
const sites = new Map(flow.calls.map((site) => [site.call, site]));
|
|
193
|
+
const ownInvocationEntries = new Map();
|
|
194
|
+
const candidateOrdinaryOwnCallableOperandsOf = (call) => {
|
|
195
|
+
const callee = unwrapErasedExpression(call.expression);
|
|
196
|
+
if (!ts.isPropertyAccessExpression(callee) && !ts.isElementAccessExpression(callee))
|
|
197
|
+
return null;
|
|
198
|
+
const key = accessKey(callee);
|
|
199
|
+
const owner = sourceCallableObjectOf(checker, flow, callee.expression);
|
|
200
|
+
if (key === null || owner === null || !sourceCallableOwnDataMayBeWrittenOf(checker, flow, owner, key))
|
|
201
|
+
return null;
|
|
202
|
+
let entry = ownInvocationEntries.get(call);
|
|
203
|
+
if (!entry) {
|
|
204
|
+
entry = {
|
|
205
|
+
kind: 'call',
|
|
206
|
+
dispatch: { kind: 'member', lookup: callee.expression, key },
|
|
207
|
+
explicitThis: false,
|
|
208
|
+
callee,
|
|
209
|
+
receiver: callee.expression,
|
|
210
|
+
args: call.arguments
|
|
211
|
+
};
|
|
212
|
+
ownInvocationEntries.set(call, entry);
|
|
213
|
+
}
|
|
214
|
+
return entry;
|
|
215
|
+
};
|
|
216
|
+
const ownCallableReadOf = (expression, seen = new Set()) => {
|
|
217
|
+
const held = unwrapErasedExpression(expression);
|
|
218
|
+
if (seen.has(held))
|
|
219
|
+
return null;
|
|
220
|
+
if (ts.isPropertyAccessExpression(held) || ts.isElementAccessExpression(held)) {
|
|
221
|
+
const owner = sourceCallableObjectOf(checker, flow, held.expression);
|
|
222
|
+
const key = accessKey(held);
|
|
223
|
+
return owner !== null && key !== null && sourceCallableOwnDataMayBeWrittenOf(checker, flow, owner, key) ? held : null;
|
|
224
|
+
}
|
|
225
|
+
if (!ts.isIdentifier(held))
|
|
226
|
+
return null;
|
|
227
|
+
const declaration = flow.targetOf(held)?.declaration;
|
|
228
|
+
if (!declaration || !ts.isVariableDeclaration(declaration) || seen.has(declaration))
|
|
229
|
+
return null;
|
|
230
|
+
const incoming = sourceBindingValuesOf(checker, flow, declaration);
|
|
231
|
+
if (!incoming || incoming.length !== 1 || bindingReadMayPrecedeFirstWrite(declaration, held))
|
|
232
|
+
return null;
|
|
233
|
+
return ownCallableReadOf(incoming[0], new Set(seen).add(held).add(declaration));
|
|
234
|
+
};
|
|
124
235
|
const isNullish = (held) => held === undefinedValue || held.kind === ts.SyntaxKind.NullKeyword || ts.isVoidExpression(held);
|
|
236
|
+
const primitiveStoredValue = (held) => {
|
|
237
|
+
if (isNullish(held))
|
|
238
|
+
return true;
|
|
239
|
+
if (!ts.isExpression(held))
|
|
240
|
+
return false;
|
|
241
|
+
// JSON can invoke BigInt.prototype.toJSON; Object prototype absence alone cannot authenticate that hook.
|
|
242
|
+
const primitive = (type) => type.isUnion()
|
|
243
|
+
? type.types.every(primitive)
|
|
244
|
+
: (type.flags &
|
|
245
|
+
(ts.TypeFlags.StringLike |
|
|
246
|
+
ts.TypeFlags.NumberLike |
|
|
247
|
+
ts.TypeFlags.BooleanLike |
|
|
248
|
+
ts.TypeFlags.ESSymbolLike |
|
|
249
|
+
ts.TypeFlags.Null |
|
|
250
|
+
ts.TypeFlags.Undefined |
|
|
251
|
+
ts.TypeFlags.Void)) !==
|
|
252
|
+
0;
|
|
253
|
+
return primitive(checker.getTypeAtLocation(unwrapErasedExpression(held)));
|
|
254
|
+
};
|
|
125
255
|
const constructionFrames = sourceConstructionFramesOf(checker, flow);
|
|
126
256
|
// Destructuring is the other spelling of a slot read, so the enumeration of
|
|
127
257
|
// "everything that can read this key" has to hold both. A key no element
|
|
@@ -203,11 +333,11 @@ const createSession = (checker, flow) => {
|
|
|
203
333
|
*
|
|
204
334
|
* A read whose key the program does not spell -- `o[ k ]` -- can publish
|
|
205
335
|
* any key of any container its receiver reaches, so every publication had
|
|
206
|
-
* to test
|
|
336
|
+
* to test every unknown read in the program against its own container.
|
|
207
337
|
* That test does not depend on the key, and a container publishes many
|
|
208
|
-
* keys, so the same
|
|
209
|
-
* loop
|
|
210
|
-
* carries on
|
|
338
|
+
* keys, so the same whole-program scan was subscribed once PER KEY: this one
|
|
339
|
+
* loop was the largest single source of the millions of observe edges the
|
|
340
|
+
* solver carries on a large program. It is one node's fact, asked once per container.
|
|
211
341
|
*/
|
|
212
342
|
const unknownReadsOf = (container) => nodeQuery('unknown-reads', container);
|
|
213
343
|
const targets = (call) => nodeQuery('targets', call);
|
|
@@ -294,7 +424,7 @@ const createSession = (checker, flow) => {
|
|
|
294
424
|
const absentThroughChain = (owner, key, seen) => {
|
|
295
425
|
// The chain is syntax and a constructor proof, neither of which changes as
|
|
296
426
|
// the graph settles -- but it is asked once per (root, key) reaching an
|
|
297
|
-
// unspelled name, which on
|
|
427
|
+
// unspelled name, which on a deep class chain is a class-keeps-its-
|
|
298
428
|
// instance proof per access. Memoized on the pair it actually depends on.
|
|
299
429
|
let byKey = chainAbsences.get(owner);
|
|
300
430
|
if (!byKey)
|
|
@@ -341,8 +471,8 @@ const createSession = (checker, flow) => {
|
|
|
341
471
|
* A key an object provably does not have -- for an instance, anywhere on
|
|
342
472
|
* its chain; for a literal, among the keys it spells.
|
|
343
473
|
*
|
|
344
|
-
* `for ( const key in values ) this[ key ] = values[ key ]` --
|
|
345
|
-
* `setValues` -- stores to keys the class never declares. That is not an
|
|
474
|
+
* `for ( const key in values ) this[ key ] = values[ key ]` -- an
|
|
475
|
+
* options-applying `setValues` method -- stores to keys the class never declares. That is not an
|
|
346
476
|
* unmodelled descriptor: with the key absent from the chain the store
|
|
347
477
|
* creates a FRESH own data property, runs no accessor, and disturbs no slot
|
|
348
478
|
* the graph tracks. What it is NOT is a readable cell: `slot` keeps refusing
|
|
@@ -356,7 +486,7 @@ const createSession = (checker, flow) => {
|
|
|
356
486
|
* absence does not hold.
|
|
357
487
|
*/
|
|
358
488
|
const absentOwnKey = (root, key, at, descriptorOf, hasUnnamedWrite) => {
|
|
359
|
-
if (ts.isObjectLiteralExpression(root)) {
|
|
489
|
+
if (ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) {
|
|
360
490
|
// A literal that spells every key it has proves the absence of every
|
|
361
491
|
// key it does not. This is asked while walking the literal's OWN uses,
|
|
362
492
|
// so a store that added an unspelled key is a refusal in the same walk.
|
|
@@ -413,13 +543,14 @@ const createSession = (checker, flow) => {
|
|
|
413
543
|
* settles; which NAME it writes is syntax and never changes. Splitting the
|
|
414
544
|
* two lets a descriptor ask about one key without walking every write in
|
|
415
545
|
* the program -- the difference between a scan per key and a scan per
|
|
416
|
-
* (key, root) pair, which is what made
|
|
546
|
+
* (key, root) pair, which is what made a large class family unfinishable.
|
|
417
547
|
*/
|
|
418
548
|
const namedWrites = new Map();
|
|
419
549
|
const computedWrites = [];
|
|
420
550
|
const namedWriteReceivers = new Map();
|
|
421
551
|
/** The receiver queries of every computed write, for `hasUnnamedWrite`'s reverse lookup. */
|
|
422
552
|
const computedWriteReceiverQueries = new Set();
|
|
553
|
+
const computedWriteEdgesByReceiver = new Map();
|
|
423
554
|
const writeEdgeByAccess = new Map();
|
|
424
555
|
for (const write of flow.allWrites) {
|
|
425
556
|
const access = write.propertyAccess;
|
|
@@ -431,6 +562,9 @@ const createSession = (checker, flow) => {
|
|
|
431
562
|
if (key === null) {
|
|
432
563
|
computedWrites.push(write);
|
|
433
564
|
computedWriteReceiverQueries.add(edge.receiver);
|
|
565
|
+
const edges = computedWriteEdgesByReceiver.get(edge.receiver) ?? [];
|
|
566
|
+
edges.push(edge);
|
|
567
|
+
computedWriteEdgesByReceiver.set(edge.receiver, edges);
|
|
434
568
|
}
|
|
435
569
|
else {
|
|
436
570
|
let entries = namedWrites.get(key);
|
|
@@ -477,6 +611,15 @@ const createSession = (checker, flow) => {
|
|
|
477
611
|
keys.set(key, (query = { kind: 'slot', node: root, key }));
|
|
478
612
|
return query;
|
|
479
613
|
};
|
|
614
|
+
const storedSlot = (root, key) => {
|
|
615
|
+
let keys = storedSlots.get(root);
|
|
616
|
+
if (!keys)
|
|
617
|
+
storedSlots.set(root, (keys = new Map()));
|
|
618
|
+
let query = keys.get(key);
|
|
619
|
+
if (!query)
|
|
620
|
+
keys.set(key, (query = { kind: 'stored-slot', node: root, key }));
|
|
621
|
+
return query;
|
|
622
|
+
};
|
|
480
623
|
const use = (root, reference) => {
|
|
481
624
|
let refs = uses.get(root);
|
|
482
625
|
if (!refs)
|
|
@@ -545,10 +688,10 @@ const createSession = (checker, flow) => {
|
|
|
545
688
|
* for the all-data and all-method keys; this covers the mixed and the
|
|
546
689
|
* accessor families it refuses.
|
|
547
690
|
*
|
|
548
|
-
* `source.
|
|
549
|
-
* over `this.
|
|
550
|
-
* which made every value reaching
|
|
551
|
-
* `current.
|
|
691
|
+
* `source.attachment` in a `copy( source )` method: the key is a getter
|
|
692
|
+
* over `this._attachment`, and the read was an unmodelled descriptor --
|
|
693
|
+
* which made every value reaching that attachment opaque,
|
|
694
|
+
* `current.owner = this` in its setter included.
|
|
552
695
|
*/
|
|
553
696
|
const familyReadOf = (root, key) => {
|
|
554
697
|
const fact = construction(root);
|
|
@@ -577,8 +720,8 @@ const createSession = (checker, flow) => {
|
|
|
577
720
|
* Whether a plain store to `key` on this construction writes DATA on every
|
|
578
721
|
* class it can be -- an own data member, or a key the class lacks and so
|
|
579
722
|
* creates (with `Object.prototype` proven to hold no setter for it, which
|
|
580
|
-
* the key-read plan registers). `this.
|
|
581
|
-
*
|
|
723
|
+
* the key-read plan registers). `this.isSpecialTarget = true` in a
|
|
724
|
+
* subclass constructor, reached through a
|
|
582
725
|
* `new this.constructor()` whose alternatives include the base class that
|
|
583
726
|
* has no such member: the data-member plan refuses a key absent on any
|
|
584
727
|
* owner, and the store was an unmodelled descriptor.
|
|
@@ -618,9 +761,57 @@ const createSession = (checker, flow) => {
|
|
|
618
761
|
/**
|
|
619
762
|
* `Object.assign( target, ...sources )` on the intact intrinsic: the one
|
|
620
763
|
* bulk write this graph models. The call evaluates to its target, and each
|
|
621
|
-
* source's own slot values are copied into the target's slots --
|
|
622
|
-
*
|
|
764
|
+
* source's own slot values are copied into the target's slots -- a
|
|
765
|
+
* constructor that builds its `options` from defaults does exactly this.
|
|
623
766
|
*/
|
|
767
|
+
/** The rebinding `parameter = <right>` whose right side holds `read`, when
|
|
768
|
+
* that read cannot run again after it within the same cell: the read is in
|
|
769
|
+
* the parameter's own body (not a nested function) and no loop of that body
|
|
770
|
+
* encloses it. */
|
|
771
|
+
const rebindingAfterRead = (parameter, read) => {
|
|
772
|
+
const owner = parameter.parent;
|
|
773
|
+
if (ts.findAncestor(read.parent, ts.isFunctionLike) !== owner)
|
|
774
|
+
return null;
|
|
775
|
+
for (const write of flow.writesToDeclaration(parameter)) {
|
|
776
|
+
if (write.slot !== 'whole' || write.edge !== 'identifier-assignment' || !write.value)
|
|
777
|
+
continue;
|
|
778
|
+
if (write.value.getSourceFile() !== read.getSourceFile() || read.pos < write.value.pos || read.end > write.value.end)
|
|
779
|
+
continue;
|
|
780
|
+
return ts.findAncestor(read, (node) => node === owner || ts.isIterationStatement(node, false)) === owner ? write.site : null;
|
|
781
|
+
}
|
|
782
|
+
return null;
|
|
783
|
+
};
|
|
784
|
+
/** Whether `reference` runs only after a statement of its parameter's own
|
|
785
|
+
* body that every path executes first rebinds the parameter whole
|
|
786
|
+
* (`options = Object.assign( { ... }, options )` opening a
|
|
787
|
+
* constructor): the cell then holds what some write after entry stored,
|
|
788
|
+
* never the incoming argument as such. A reference in a nested callable is
|
|
789
|
+
* not ordered by statements -- a hoisted declaration can run before the
|
|
790
|
+
* rebinding. */
|
|
791
|
+
const readsAfterRebinding = (parameter, reference) => {
|
|
792
|
+
const owner = parameter.parent;
|
|
793
|
+
const body = 'body' in owner ? owner.body : undefined;
|
|
794
|
+
if (!body || !ts.isBlock(body) || ts.findAncestor(reference.parent, ts.isFunctionLike) !== owner)
|
|
795
|
+
return false;
|
|
796
|
+
const at = body.statements.findIndex((one) => one.pos <= reference.pos && reference.end <= one.end);
|
|
797
|
+
return (at >= 0 &&
|
|
798
|
+
flow
|
|
799
|
+
.writesToDeclaration(parameter)
|
|
800
|
+
.some((write) => write.slot === 'whole' &&
|
|
801
|
+
write.edge === 'identifier-assignment' &&
|
|
802
|
+
ts.isExpressionStatement(write.site.parent) &&
|
|
803
|
+
write.site.parent.parent === body &&
|
|
804
|
+
body.statements.indexOf(write.site.parent) < at));
|
|
805
|
+
};
|
|
806
|
+
const PARAMETER_ENTRY_EDGES = new Set([
|
|
807
|
+
'call-argument',
|
|
808
|
+
'super-argument',
|
|
809
|
+
'rest-argument',
|
|
810
|
+
'default-parameter'
|
|
811
|
+
]);
|
|
812
|
+
/** The writes that can replace a parameter's value after entry: everything
|
|
813
|
+
* but the arguments and the default it is bound from. */
|
|
814
|
+
const parameterRebindingsOf = (parameter) => flow.writesToDeclaration(parameter).filter((write) => !PARAMETER_ENTRY_EDGES.has(write.edge));
|
|
624
815
|
const bulkAssignOf = (call) => {
|
|
625
816
|
if (!isGlobalObjectAssign(checker, call))
|
|
626
817
|
return null;
|
|
@@ -634,9 +825,9 @@ const createSession = (checker, flow) => {
|
|
|
634
825
|
/**
|
|
635
826
|
* `Object.defineProperty( target, key, { value } )` on the intact intrinsic:
|
|
636
827
|
* a store of the descriptor's `value` into `key` of the target, running no
|
|
637
|
-
* code of the target's.
|
|
638
|
-
* way in their constructors
|
|
639
|
-
*
|
|
828
|
+
* code of the target's. JS classes that define a read-only `id` this
|
|
829
|
+
* way in their constructors had the target's use as the call's argument
|
|
830
|
+
* read as a call with no source target -- so every instance was opaque.
|
|
640
831
|
* `defineProperties` is lowered to this form by the source transform and is
|
|
641
832
|
* not modelled here.
|
|
642
833
|
*/
|
|
@@ -685,17 +876,23 @@ const createSession = (checker, flow) => {
|
|
|
685
876
|
return entries.length > 0 ? entries : null;
|
|
686
877
|
};
|
|
687
878
|
const descriptor = (root, key) => {
|
|
879
|
+
if (isFreshOrdinaryObject(root))
|
|
880
|
+
return false;
|
|
688
881
|
if (ts.isNewExpression(root))
|
|
689
882
|
return classMembers(root, key) !== null;
|
|
690
883
|
if (ts.isObjectLiteralExpression(root))
|
|
691
884
|
return ownEntries(root, key) !== null;
|
|
885
|
+
if (isSourceCallableObject(root))
|
|
886
|
+
return key === 'name' || key === 'length';
|
|
887
|
+
if (!ts.isArrayLiteralExpression(root))
|
|
888
|
+
return false;
|
|
692
889
|
if (key === 'length')
|
|
693
890
|
return true;
|
|
694
891
|
// An index the literal does not spell is still the array's own: it reads
|
|
695
892
|
// `undefined` until an index store fills it, and `case 'slot'` reads the
|
|
696
|
-
// stores through `keyReaches`.
|
|
697
|
-
// `this.
|
|
698
|
-
// `
|
|
893
|
+
// stores through `keyReaches`. A class that starts with
|
|
894
|
+
// `this.items = []`, fills it by index in the constructor, and has an
|
|
895
|
+
// `item` getter reading `this.items[ 0 ]` is the shape.
|
|
699
896
|
return (key === ELEMENT_KEY || isCanonicalIndex(key)) && !root.elements.some(ts.isSpreadElement);
|
|
700
897
|
};
|
|
701
898
|
const ownersOf = (root) => constructionFrames.receiverOwnersOf(root) ?? [];
|
|
@@ -717,7 +914,7 @@ const createSession = (checker, flow) => {
|
|
|
717
914
|
* however the graph solves. Three transfers -- a parameter's frame, a
|
|
718
915
|
* receiver's frame and a completion's use -- asked anyway, by observing
|
|
719
916
|
* `targets` of EVERY call in the program, per query. That forced the entire
|
|
720
|
-
* program's dispatch graph from each of them and was
|
|
917
|
+
* program's dispatch graph from each of them and was a large program's compile time:
|
|
721
918
|
* the fan-out, not any one answer. `callersOf` below is the fix for the
|
|
722
919
|
* fan-out; this function is unchanged and still returns the same
|
|
723
920
|
* whole-program list for an unnamed body -- only how many times that list
|
|
@@ -729,7 +926,7 @@ const createSession = (checker, flow) => {
|
|
|
729
926
|
* calls that were already impossible. A body whose own names cannot be
|
|
730
927
|
* enumerated falls back to the whole list rather than to a guess.
|
|
731
928
|
*
|
|
732
|
-
* That fallback fires for
|
|
929
|
+
* That fallback fires for every anonymous body handed straight to
|
|
733
930
|
* a host/intrinsic callee -- `[].map(x => ...)`, `setTimeout(() => ...)` --
|
|
734
931
|
* because `ValueWrite.naming` only spells "the parameter's name for a call
|
|
735
932
|
* argument" when the callee is a SOURCE function; a host callee's parameter
|
|
@@ -756,7 +953,8 @@ const createSession = (checker, flow) => {
|
|
|
756
953
|
// never names.
|
|
757
954
|
if (!ts.isCallExpression(site.call) && !ts.isNewExpression(site.call))
|
|
758
955
|
continue;
|
|
759
|
-
const
|
|
956
|
+
const own = ts.isCallExpression(site.call) ? candidateOrdinaryOwnCallableOperandsOf(site.call) : null;
|
|
957
|
+
const callee = site.operands ? unwrapErasedExpression(own?.callee ?? site.operands.callee) : null;
|
|
760
958
|
const name = callee
|
|
761
959
|
? ts.isIdentifier(callee)
|
|
762
960
|
? callee.text
|
|
@@ -785,6 +983,17 @@ const createSession = (checker, flow) => {
|
|
|
785
983
|
return known;
|
|
786
984
|
const names = new Set();
|
|
787
985
|
const declared = ts.getNameOfDeclaration(body);
|
|
986
|
+
// A value installed on a Function can be read through any immutable alias
|
|
987
|
+
// of that own member. Its declaration's spelling does not enumerate those
|
|
988
|
+
// callers, so keep the complete indexed call set for this bounded family.
|
|
989
|
+
if (flow.calls.some((site) => {
|
|
990
|
+
const installed = ts.isCallExpression(site.call) ? sourceCallableReflectSetOf(checker, site.call) : null;
|
|
991
|
+
return installed !== null && sourceCallableObjectOf(checker, flow, installed.value) === body;
|
|
992
|
+
}) ||
|
|
993
|
+
flow.allWrites.some((write) => write.propertyAccess !== null && write.value !== null && sourceCallableObjectOf(checker, flow, write.value) === body)) {
|
|
994
|
+
bodyNames.set(body, null);
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
788
997
|
if (declared) {
|
|
789
998
|
const key = ts.isIdentifier(declared) || ts.isStringLiteralLike(declared) ? declared.text : declarationKey(declared);
|
|
790
999
|
if (key === null) {
|
|
@@ -857,12 +1066,13 @@ const createSession = (checker, flow) => {
|
|
|
857
1066
|
* transfer: `for (const site of candidateCallersOf(owner)) if (...
|
|
858
1067
|
* observe(targets(site.call)).has(owner)) ...`. For a NAMED body
|
|
859
1068
|
* `candidateCallersOf` is already small and the repetition was cheap. For
|
|
860
|
-
*
|
|
861
|
-
*
|
|
1069
|
+
* an anonymous body handed to a host callee it is `flow.calls` -- every
|
|
1070
|
+
* call site in the program -- and every parameter of such a body, plus
|
|
862
1071
|
* its receiver, plus every one of its return statements, walked and
|
|
863
|
-
* `observe`d that entire list separately.
|
|
864
|
-
*
|
|
865
|
-
* all of it the same whole-program filter re-run for the
|
|
1072
|
+
* `observe`d that entire list separately. On a large program the
|
|
1073
|
+
* `parameter` states alone carried hundreds of thousands of observe edges
|
|
1074
|
+
* this way, almost all of it the same whole-program filter re-run for the
|
|
1075
|
+
* same owner.
|
|
866
1076
|
*
|
|
867
1077
|
* This is `unknownReadsOf`'s shape exactly: a whole-program list, tested
|
|
868
1078
|
* against one thing, wanted by many consumers of that one thing. Giving the
|
|
@@ -877,6 +1087,43 @@ const createSession = (checker, flow) => {
|
|
|
877
1087
|
// requirements that make its caller set complete, and a frame built from
|
|
878
1088
|
// the discovered calls alone would be complete over an open caller set.
|
|
879
1089
|
const callersOf = (owner) => nodeQuery('callers', owner);
|
|
1090
|
+
/** The writes a `for...of` binding receives from, out of every write the program makes; asked by each array literal's element publication on every re-evaluation. */
|
|
1091
|
+
let valueIterationWrites = null;
|
|
1092
|
+
/**
|
|
1093
|
+
* The part of `case 'callers'` that no fact can move: which candidate sites
|
|
1094
|
+
* are syntax-and-checker matches for `owner`. The transfer re-ran it on
|
|
1095
|
+
* every re-evaluation, asking the checker for each member receiver's type and
|
|
1096
|
+
* its assignability to the owner's class each time; on a large program that
|
|
1097
|
+
* was the session's heaviest transfer. Kept in site order, so the facts the
|
|
1098
|
+
* transfer adds keep their order.
|
|
1099
|
+
*/
|
|
1100
|
+
const callerCandidates = new Map();
|
|
1101
|
+
const callerCandidatesOf = (owner) => {
|
|
1102
|
+
const known = callerCandidates.get(owner);
|
|
1103
|
+
if (known !== undefined)
|
|
1104
|
+
return known;
|
|
1105
|
+
const ownerType = ownerInstanceTypeOf(owner);
|
|
1106
|
+
const answer = [];
|
|
1107
|
+
for (const site of candidateCallersOf(owner)) {
|
|
1108
|
+
// `new Factory( state )` on a plain function enters the
|
|
1109
|
+
// function's own argument frame exactly as a call would; the
|
|
1110
|
+
// construction domain names no class for it, so it is a caller.
|
|
1111
|
+
if (ts.isNewExpression(site.call)) {
|
|
1112
|
+
if (ts.isFunctionDeclaration(owner) && constructorFunctionCalleeOf(site.call) === owner)
|
|
1113
|
+
answer.push({ site, call: null });
|
|
1114
|
+
continue;
|
|
1115
|
+
}
|
|
1116
|
+
if (!ts.isCallExpression(site.call))
|
|
1117
|
+
continue;
|
|
1118
|
+
if (ownerType !== null && !site.explicitThis && site.operands.dispatch.kind === 'member' && site.operands.receiver !== null) {
|
|
1119
|
+
if (!statedTypeAdmits(checker.getTypeAtLocation(site.operands.receiver), ownerType))
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
answer.push({ site, call: site.call });
|
|
1123
|
+
}
|
|
1124
|
+
callerCandidates.set(owner, answer);
|
|
1125
|
+
return answer;
|
|
1126
|
+
};
|
|
880
1127
|
let constructionsByOwner = null;
|
|
881
1128
|
/**
|
|
882
1129
|
* Every site that constructs: a `new`, or a `super(...)` standing in for one.
|
|
@@ -954,8 +1201,9 @@ const createSession = (checker, flow) => {
|
|
|
954
1201
|
/**
|
|
955
1202
|
* The enumerated expression, when this key expression is a `for-in` head.
|
|
956
1203
|
*
|
|
957
|
-
* `for ( const key in values ) this[ key ] = values[ key ]` --
|
|
958
|
-
* `setValues
|
|
1204
|
+
* `for ( const key in values ) this[ key ] = values[ key ]` -- an
|
|
1205
|
+
* options-applying `setValues` method, typically a JS program's single
|
|
1206
|
+
* largest computed-store family. `key`
|
|
959
1207
|
* names no VALUE the graph can carry, so `value(key)` correctly answers
|
|
960
1208
|
* nothing and the access refuses on an unresolved key. What the graph CAN
|
|
961
1209
|
* answer is what `values` holds, and an object literal spells its own keys.
|
|
@@ -995,6 +1243,8 @@ const createSession = (checker, flow) => {
|
|
|
995
1243
|
* key set is not a smaller answer, it is a wrong one: it would leave a slot
|
|
996
1244
|
* the program actually stores into looking untouched. */
|
|
997
1245
|
const literalSpelledKeys = (root) => {
|
|
1246
|
+
if (isFreshOrdinaryObject(root))
|
|
1247
|
+
return [];
|
|
998
1248
|
if (!ts.isObjectLiteralExpression(root))
|
|
999
1249
|
return null;
|
|
1000
1250
|
const keys = [];
|
|
@@ -1027,8 +1277,8 @@ const createSession = (checker, flow) => {
|
|
|
1027
1277
|
const keys = new Set();
|
|
1028
1278
|
const roots = read(value(enumerated));
|
|
1029
1279
|
for (const root of roots) {
|
|
1030
|
-
// `for ( key in undefined )` binds nothing:
|
|
1031
|
-
// `setValues( parameters )` for a bare `new
|
|
1280
|
+
// `for ( key in undefined )` binds nothing: a base constructor runs
|
|
1281
|
+
// `setValues( parameters )` even for a bare `new Subclass()`.
|
|
1032
1282
|
if (isNullish(root))
|
|
1033
1283
|
continue;
|
|
1034
1284
|
const own = ownKeysOf(root);
|
|
@@ -1050,6 +1300,20 @@ const createSession = (checker, flow) => {
|
|
|
1050
1300
|
fail('unresolved-enumeration', enumerated);
|
|
1051
1301
|
return [...keys];
|
|
1052
1302
|
};
|
|
1303
|
+
// One object per (node, reason) for the whole session. The solver compares
|
|
1304
|
+
// a re-seal's causes by identity, and a fresh literal per evaluation made
|
|
1305
|
+
// every unchanged refusal look like a changed seal -- each one threw away
|
|
1306
|
+
// the component solve and re-expanded the whole sealed graph.
|
|
1307
|
+
const internedCauses = new Map();
|
|
1308
|
+
const causeOf = (reason, node) => {
|
|
1309
|
+
let byReason = internedCauses.get(node);
|
|
1310
|
+
if (byReason === undefined)
|
|
1311
|
+
internedCauses.set(node, (byReason = new Map()));
|
|
1312
|
+
let cause = byReason.get(reason);
|
|
1313
|
+
if (cause === undefined)
|
|
1314
|
+
byReason.set(reason, (cause = { reason, node }));
|
|
1315
|
+
return cause;
|
|
1316
|
+
};
|
|
1053
1317
|
const define = (query) => {
|
|
1054
1318
|
let finalCauses = [];
|
|
1055
1319
|
let finalGrounding = [];
|
|
@@ -1060,7 +1324,7 @@ const createSession = (checker, flow) => {
|
|
|
1060
1324
|
const causes = [];
|
|
1061
1325
|
const grounding = new Set();
|
|
1062
1326
|
const fail = (reason, node = query.node) => {
|
|
1063
|
-
causes.push(
|
|
1327
|
+
causes.push(causeOf(reason, node));
|
|
1064
1328
|
if (refusalDebug) {
|
|
1065
1329
|
const file = node.getSourceFile();
|
|
1066
1330
|
const { line } = file.getLineAndCharacterOfPosition(node.getStart(file));
|
|
@@ -1071,7 +1335,7 @@ const createSession = (checker, flow) => {
|
|
|
1071
1335
|
// No edge ledger of our own: the solver records every required edge, and
|
|
1072
1336
|
// `obligations` walks its copy. Keeping a second one cost a map lookup
|
|
1073
1337
|
// and a set insert on every edge read in the program -- the largest
|
|
1074
|
-
// single self-time entry in
|
|
1338
|
+
// single self-time entry in a large program's profile once the state lookup
|
|
1075
1339
|
// beside it was gone -- and a duplicate of the whole proof graph in a
|
|
1076
1340
|
// solve that was already running out of heap.
|
|
1077
1341
|
const read = required;
|
|
@@ -1086,23 +1350,24 @@ const createSession = (checker, flow) => {
|
|
|
1086
1350
|
/**
|
|
1087
1351
|
* A member call whose receiver holds nothing but `null`/`undefined`
|
|
1088
1352
|
* throws at the lookup: no target, no frame, no completion -- and no
|
|
1089
|
-
* refusal, since the throw is the program's own answer.
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1353
|
+
* refusal, since the throw is the program's own answer. A `copy( source )`
|
|
1354
|
+
* method running `source.attachment.clone()` under a guard this graph
|
|
1355
|
+
* does not read, where every value `attachment` holds is `null`, is the
|
|
1356
|
+
* shape.
|
|
1093
1357
|
*/
|
|
1094
1358
|
const lookupThrows = (call) => {
|
|
1095
1359
|
const site = sites.get(call);
|
|
1096
|
-
|
|
1360
|
+
const operands = candidateOrdinaryOwnCallableOperandsOf(call) ?? site?.operands;
|
|
1361
|
+
if (!operands || operands.explicitThis || operands.dispatch.kind !== 'member' || operands.receiver === null)
|
|
1097
1362
|
return false;
|
|
1098
|
-
const held = read(value(
|
|
1363
|
+
const held = read(value(operands.receiver));
|
|
1099
1364
|
return held.size > 0 && [...held].every(isNullish);
|
|
1100
1365
|
};
|
|
1101
1366
|
/**
|
|
1102
1367
|
* The keys a named write through a root adds to it.
|
|
1103
1368
|
*
|
|
1104
|
-
* `const values = {
|
|
1105
|
-
*
|
|
1369
|
+
* `const values = { mode: 1, flip: false }; values.wrap = w` --
|
|
1370
|
+
* an options literal extended after creation. The literal SPELLS two keys and the program
|
|
1106
1371
|
* gives it a third, so the spelling is not the key set. `case 'slot'`
|
|
1107
1372
|
* already reads those writes; without them in the descriptor the very
|
|
1108
1373
|
* slot they write was refused before it could be read -- the descriptor
|
|
@@ -1115,8 +1380,8 @@ const createSession = (checker, flow) => {
|
|
|
1115
1380
|
/**
|
|
1116
1381
|
* The keys a named write through a root adds to it.
|
|
1117
1382
|
*
|
|
1118
|
-
* `const values = {
|
|
1119
|
-
*
|
|
1383
|
+
* `const values = { mode: 1, flip: false }; values.wrap = w` --
|
|
1384
|
+
* an options literal extended after creation. The literal SPELLS two keys and the program
|
|
1120
1385
|
* gives it a third, so the spelling is not the key set. `case 'slot'`
|
|
1121
1386
|
* already reads those writes; without them in the descriptor the very
|
|
1122
1387
|
* slot they write was refused before it could be read -- the descriptor
|
|
@@ -1131,8 +1396,8 @@ const createSession = (checker, flow) => {
|
|
|
1131
1396
|
* measured and reverted: that query depends on every named write in the
|
|
1132
1397
|
* program, so a per-key descriptor question -- asked about most roots in
|
|
1133
1398
|
* the program, not just the enumerated ones -- pulled a whole-program
|
|
1134
|
-
* dependency set into each of them and put
|
|
1135
|
-
*
|
|
1399
|
+
* dependency set into each of them and put a large program into GC death
|
|
1400
|
+
* after minutes. A whole-program walk becomes a query only where the consumer
|
|
1136
1401
|
* genuinely wants the whole program, which here is enumeration alone.
|
|
1137
1402
|
*/
|
|
1138
1403
|
const writesTo = (root, edges) => edges.some((edge) => observe(edge.receiver).has(root));
|
|
@@ -1140,7 +1405,7 @@ const createSession = (checker, flow) => {
|
|
|
1140
1405
|
* A write under a key this graph cannot name leaves the key set unknown
|
|
1141
1406
|
* -- reported as unknown, never as a smaller set. Asked in reverse:
|
|
1142
1407
|
* which states hold this root, and is any of them a computed write's
|
|
1143
|
-
* receiver -- one lookup per root instead of observing all of the
|
|
1408
|
+
* receiver -- one lookup per root instead of observing all of the program's
|
|
1144
1409
|
* computed-write receivers per root per re-evaluation. `holdersOf`
|
|
1145
1410
|
* subscribes this node to the root's future holders exactly as the
|
|
1146
1411
|
* observe edges did, and the receivers are seeded below so each exists.
|
|
@@ -1155,8 +1420,9 @@ const createSession = (checker, flow) => {
|
|
|
1155
1420
|
let count = 0;
|
|
1156
1421
|
for (const holder of holdersOf(root)) {
|
|
1157
1422
|
count++;
|
|
1158
|
-
|
|
1159
|
-
|
|
1423
|
+
for (const write of computedWriteEdgesByReceiver.get(holder) ?? [])
|
|
1424
|
+
if (keysOf(write.access).length === 0)
|
|
1425
|
+
found = true;
|
|
1160
1426
|
}
|
|
1161
1427
|
for (const stamps of holderStampLists)
|
|
1162
1428
|
stamps.push([root, count]);
|
|
@@ -1251,20 +1517,21 @@ const createSession = (checker, flow) => {
|
|
|
1251
1517
|
}
|
|
1252
1518
|
if (!ts.isPropertyAccessExpression(stored) && !ts.isElementAccessExpression(stored))
|
|
1253
1519
|
continue;
|
|
1254
|
-
const written
|
|
1255
|
-
if (written !== null)
|
|
1520
|
+
for (const written of keysOf(stored))
|
|
1256
1521
|
keys.add(written);
|
|
1257
1522
|
}
|
|
1258
1523
|
return [...keys];
|
|
1259
1524
|
};
|
|
1260
1525
|
const descriptorOf = (root, key) => descriptor(root, key) ||
|
|
1261
|
-
(
|
|
1526
|
+
(isSourceCallableObject(root) && sourceCallableOwnDataWriteOf(checker, flow, root, key) !== null) ||
|
|
1527
|
+
((ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) && writesTo(root, namedWriteReceivers.get(key) ?? [])) ||
|
|
1528
|
+
((ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) &&
|
|
1529
|
+
[...holdersOf(root)].some((holder) => (computedWriteEdgesByReceiver.get(holder) ?? []).some((edge) => keysOf(edge.access).includes(key)))) ||
|
|
1262
1530
|
writesTo(root, definitionReceivers.get(key) ?? []);
|
|
1263
1531
|
/**
|
|
1264
1532
|
* Every element key of the arrays an access could be reaching.
|
|
1265
1533
|
*
|
|
1266
|
-
* `this.
|
|
1267
|
-
* field array. The index is a counter no value bounds, so asking what
|
|
1534
|
+
* `this.items[ i ]` -- every loop over a field array. The index is a counter no value bounds, so asking what
|
|
1268
1535
|
* `i` HOLDS correctly answers nothing; but the access still names some
|
|
1269
1536
|
* element, and an array literal spells all of them. Their union is a
|
|
1270
1537
|
* true superset where a single key is not available. `length` is not an
|
|
@@ -1314,8 +1581,50 @@ const createSession = (checker, flow) => {
|
|
|
1314
1581
|
const enumerated = enumerationHeadOf(access.argumentExpression);
|
|
1315
1582
|
if (enumerated !== null)
|
|
1316
1583
|
return enumeratedKeysOf(access, enumerated, read, fail, sealing, ownKeysOf);
|
|
1317
|
-
|
|
1318
|
-
|
|
1584
|
+
const keyReference = unwrapErasedExpression(access.argumentExpression);
|
|
1585
|
+
const keyDeclaration = ts.isIdentifier(keyReference) ? flow.targetOf(keyReference)?.declaration : undefined;
|
|
1586
|
+
if (keyDeclaration && ts.isVariableDeclaration(keyDeclaration)) {
|
|
1587
|
+
const writes = flow.writesToDeclaration(keyDeclaration).filter((write) => write.slot === 'whole');
|
|
1588
|
+
if (writes.length > 0 &&
|
|
1589
|
+
writes.every((write) => write.edge === 'iteration-binding' && write.iterationOrigin?.mode === 'values')) {
|
|
1590
|
+
const keys = new Set();
|
|
1591
|
+
let complete = true;
|
|
1592
|
+
for (const write of writes) {
|
|
1593
|
+
const source = write.iterationOrigin?.source;
|
|
1594
|
+
const call = source && unwrapErasedExpression(source);
|
|
1595
|
+
const query = call && ts.isCallExpression(call) ? intrinsicOwnKeyQueryOf(checker, call.expression) : null;
|
|
1596
|
+
if (!call ||
|
|
1597
|
+
!ts.isCallExpression(call) ||
|
|
1598
|
+
write.iterationOrigin?.asynchronous ||
|
|
1599
|
+
call.arguments.length !== 1 ||
|
|
1600
|
+
query?.owner !== 'Object' ||
|
|
1601
|
+
!['keys', 'getOwnPropertyNames'].includes(query.member) ||
|
|
1602
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.requireMember(query.owner, query.member, call) !== true) {
|
|
1603
|
+
complete = false;
|
|
1604
|
+
break;
|
|
1605
|
+
}
|
|
1606
|
+
const roots = read(value(call.arguments[0]));
|
|
1607
|
+
if (sealing && roots.size === 0)
|
|
1608
|
+
fail('unresolved-key-enumeration-owner', call);
|
|
1609
|
+
for (const root of roots) {
|
|
1610
|
+
if (!isObjectRoot(root)) {
|
|
1611
|
+
fail('unmodelled-key-enumeration-owner', call);
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
for (const key of read(nodeQuery('own-keys', root))) {
|
|
1615
|
+
if (ts.isStringLiteral(key))
|
|
1616
|
+
keys.add(key.text);
|
|
1617
|
+
else
|
|
1618
|
+
fail('unmodelled-own-key-value', call);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
if (complete)
|
|
1623
|
+
return [...keys];
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
// A counter names a POSITION, never a key: `this.items[ i ]` with
|
|
1627
|
+
// a `let i` loop counter. The checker calls it `number`, and
|
|
1319
1628
|
// asking what the counter holds only ever refused (`i++` is no value
|
|
1320
1629
|
// this graph states) and made the access opaque; the element slot is
|
|
1321
1630
|
// the answer, and it is a superset whatever the counter holds.
|
|
@@ -1325,7 +1634,9 @@ const createSession = (checker, flow) => {
|
|
|
1325
1634
|
if (elements !== null)
|
|
1326
1635
|
return elements;
|
|
1327
1636
|
const keys = new Set();
|
|
1328
|
-
const
|
|
1637
|
+
const keyQuery = value(access.argumentExpression);
|
|
1638
|
+
watched(keyQuery);
|
|
1639
|
+
const candidates = read(keyQuery);
|
|
1329
1640
|
for (const candidate of candidates) {
|
|
1330
1641
|
if (ts.isStringLiteralLike(candidate) || ts.isNumericLiteral(candidate))
|
|
1331
1642
|
keys.add(candidate.text);
|
|
@@ -1336,6 +1647,24 @@ const createSession = (checker, flow) => {
|
|
|
1336
1647
|
fail('unresolved-property-key', access);
|
|
1337
1648
|
return [...keys];
|
|
1338
1649
|
};
|
|
1650
|
+
const iterationValuesAt = (source) => {
|
|
1651
|
+
const elements = [];
|
|
1652
|
+
for (const root of read(value(source))) {
|
|
1653
|
+
if (!ts.isArrayLiteralExpression(root) ||
|
|
1654
|
+
root.elements.some((element) => ts.isSpreadElement(element) || ts.isOmittedExpression(element)) ||
|
|
1655
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.require('Array', source) !== true)
|
|
1656
|
+
return null;
|
|
1657
|
+
// This bounded lane transports the original literal's entries.
|
|
1658
|
+
// Mutating its contents/length needs the full indexed storage plan.
|
|
1659
|
+
for (const use of read(closure(root)))
|
|
1660
|
+
if ((ts.isPropertyAccessExpression(use) || ts.isElementAccessExpression(use)) && writeEdgeByAccess.has(use))
|
|
1661
|
+
return null;
|
|
1662
|
+
for (const element of root.elements)
|
|
1663
|
+
if (!ts.isSpreadElement(element) && !ts.isOmittedExpression(element))
|
|
1664
|
+
elements.push(element);
|
|
1665
|
+
}
|
|
1666
|
+
return elements;
|
|
1667
|
+
};
|
|
1339
1668
|
/**
|
|
1340
1669
|
* Mentions of an exported cell in the modules that import it, or null
|
|
1341
1670
|
* when the set of modules that can read it is not enumerable.
|
|
@@ -1351,15 +1680,13 @@ const createSession = (checker, flow) => {
|
|
|
1351
1680
|
* so a caller that widens the predicate must walk these too, or it has
|
|
1352
1681
|
* called a cell closed on the strength of uses it never looked at.
|
|
1353
1682
|
*/
|
|
1354
|
-
const importerMentions = (declaration) => (
|
|
1355
|
-
? []
|
|
1356
|
-
: inProgramImportReferencesOf(checker, flow, declaration);
|
|
1683
|
+
const importerMentions = (declaration) => !isModuleExportedDeclaration(checker, declaration, null) ? [] : inProgramImportReferencesOf(checker, flow, declaration);
|
|
1357
1684
|
/** The refusal a cell earns, or null when it is closed -- named, because
|
|
1358
1685
|
* "exposed" covered three different facts and each has its own fix. */
|
|
1359
1686
|
const bindingClosed = (declaration) => {
|
|
1360
|
-
if (!
|
|
1687
|
+
if (!sourceBindingWritesAreComplete(checker, flow, declaration))
|
|
1361
1688
|
return 'binding-writes-incomplete';
|
|
1362
|
-
if ((
|
|
1689
|
+
if (!isModuleExportedDeclaration(checker, declaration, null))
|
|
1363
1690
|
return null;
|
|
1364
1691
|
if (exportIsUnimported(checker, flow, declaration))
|
|
1365
1692
|
return null;
|
|
@@ -1369,6 +1696,13 @@ const createSession = (checker, flow) => {
|
|
|
1369
1696
|
for (const reference of flow.referencesToDeclaration(declaration)) {
|
|
1370
1697
|
if (reference === ts.getNameOfDeclaration(declaration) || isTypePositionReference(reference))
|
|
1371
1698
|
continue;
|
|
1699
|
+
// Past an unconditional rebinding the cell holds only what a write
|
|
1700
|
+
// after entry stored; a root none of those writes stores is no
|
|
1701
|
+
// longer reachable through it.
|
|
1702
|
+
if (ts.isParameter(declaration) &&
|
|
1703
|
+
readsAfterRebinding(declaration, reference) &&
|
|
1704
|
+
parameterRebindingsOf(declaration).every((write) => write.value !== null && !read(value(write.value)).has(root)))
|
|
1705
|
+
continue;
|
|
1372
1706
|
add(read(use(root, reference)));
|
|
1373
1707
|
}
|
|
1374
1708
|
for (const reference of importerMentions(declaration) ?? [])
|
|
@@ -1399,6 +1733,11 @@ const createSession = (checker, flow) => {
|
|
|
1399
1733
|
fail('rest-binding-element', element);
|
|
1400
1734
|
else if (key === null)
|
|
1401
1735
|
fail('computed-binding-element', element);
|
|
1736
|
+
else if (isSourceCallableObject(root) &&
|
|
1737
|
+
key !== 'name' &&
|
|
1738
|
+
key !== 'length' &&
|
|
1739
|
+
sourceCallableOwnDataWriteOf(checker, flow, root, key, element) === null)
|
|
1740
|
+
fail('unproven-callable-data-read', element);
|
|
1402
1741
|
else if (!descriptorOf(root, key))
|
|
1403
1742
|
fail('unmodelled-descriptor', element);
|
|
1404
1743
|
}
|
|
@@ -1428,8 +1767,8 @@ const createSession = (checker, flow) => {
|
|
|
1428
1767
|
* Every value a setter's parameter receives: the right-hand side of each
|
|
1429
1768
|
* store that runs the setter -- a store to its key on a construction of
|
|
1430
1769
|
* its class's family. A setter has no call sites, so `callersOf` names
|
|
1431
|
-
* nothing for it and the parameter was an unindexed frame:
|
|
1432
|
-
* `
|
|
1770
|
+
* nothing for it and the parameter was an unindexed frame: a class's
|
|
1771
|
+
* `set attachment( current )`. The family is by
|
|
1433
1772
|
* heritage; a descendant's own override is over-counted, which only
|
|
1434
1773
|
* widens the answer. A bulk `Object.assign` onto one of ours names no
|
|
1435
1774
|
* key to compare and refuses.
|
|
@@ -1477,9 +1816,9 @@ const createSession = (checker, flow) => {
|
|
|
1477
1816
|
* A value a getter returns is used wherever the getter is READ: every
|
|
1478
1817
|
* access spelling its key on one of its class family's constructions,
|
|
1479
1818
|
* from the instances outward like `setterStores`. A getter has no call
|
|
1480
|
-
* sites, so `callersOf` names nothing for it;
|
|
1481
|
-
* `get
|
|
1482
|
-
* at every `target.
|
|
1819
|
+
* sites, so `callersOf` names nothing for it; a class whose
|
|
1820
|
+
* `get item()` returns `this.items[ 0 ]` has the element used
|
|
1821
|
+
* at every `target.item` in the program. A descendant's override is
|
|
1483
1822
|
* over-counted, which only widens.
|
|
1484
1823
|
*/
|
|
1485
1824
|
const getterReturns = (root, getter) => {
|
|
@@ -1526,9 +1865,9 @@ const createSession = (checker, flow) => {
|
|
|
1526
1865
|
// constructions, and a construction's closure already lists every
|
|
1527
1866
|
// store through it (`case 'slot'` reads the same facts). Placing the
|
|
1528
1867
|
// receiver of every write naming the key instead read cells that
|
|
1529
|
-
// had nothing to do with this family --
|
|
1868
|
+
// had nothing to do with this family -- an event-dispatcher base's
|
|
1530
1869
|
// `listeners[ type ] = []` resolves `this._listeners` on every
|
|
1531
|
-
// dispatcher in the program,
|
|
1870
|
+
// dispatcher in the program, this family's included, and this family's
|
|
1532
1871
|
// computed stores hang on the very `setValues` parameter this
|
|
1533
1872
|
// question is part of establishing. Their opacity became this
|
|
1534
1873
|
// parameter's.
|
|
@@ -1554,11 +1893,11 @@ const createSession = (checker, flow) => {
|
|
|
1554
1893
|
/**
|
|
1555
1894
|
* Every read of an argument through the `arguments` object.
|
|
1556
1895
|
*
|
|
1557
|
-
*
|
|
1558
|
-
* several children at once
|
|
1896
|
+
* A scene-graph style `Node.add( object )` that walks its own `arguments`
|
|
1897
|
+
* to add several children at once receives a value at a
|
|
1559
1898
|
* PARAMETER and, on some index, at `arguments[ i ]` as well. Refusing
|
|
1560
|
-
* the whole frame for that gave up on the entire
|
|
1561
|
-
* every
|
|
1899
|
+
* the whole frame for that gave up on the entire node family --
|
|
1900
|
+
* every callback parameter reached through those nodes hung on this one
|
|
1562
1901
|
* refusal.
|
|
1563
1902
|
*
|
|
1564
1903
|
* The index is not resolved and does not need to be: one that names any
|
|
@@ -1645,9 +1984,12 @@ const createSession = (checker, flow) => {
|
|
|
1645
1984
|
fail('unindexed-use', reference);
|
|
1646
1985
|
return;
|
|
1647
1986
|
}
|
|
1648
|
-
const
|
|
1649
|
-
if (
|
|
1650
|
-
|
|
1987
|
+
const positioned = outermostErasureOf(reference);
|
|
1988
|
+
if (positioned !== reference) {
|
|
1989
|
+
if (ts.isExpression(positioned))
|
|
1990
|
+
add(read(use(root, positioned)));
|
|
1991
|
+
else
|
|
1992
|
+
fail('unindexed-use', positioned);
|
|
1651
1993
|
return;
|
|
1652
1994
|
}
|
|
1653
1995
|
if (ts.isVariableDeclaration(parent) || ts.isParameter(parent)) {
|
|
@@ -1673,6 +2015,15 @@ const createSession = (checker, flow) => {
|
|
|
1673
2015
|
if (parent.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
1674
2016
|
if (parent.left === reference)
|
|
1675
2017
|
return;
|
|
2018
|
+
const moduleUses = sourceCommonJsExportUsesOf(flow, parent);
|
|
2019
|
+
if (moduleUses !== null) {
|
|
2020
|
+
if (parent.right !== reference)
|
|
2021
|
+
fail('unmatched-commonjs-export', reference);
|
|
2022
|
+
else
|
|
2023
|
+
for (const alias of moduleUses)
|
|
2024
|
+
add(read(use(root, alias)));
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
1676
2027
|
const left = unwrapNaming(parent.left);
|
|
1677
2028
|
if (ts.isIdentifier(left)) {
|
|
1678
2029
|
const declaration = flow.targetOf(left)?.declaration;
|
|
@@ -1694,6 +2045,16 @@ const createSession = (checker, flow) => {
|
|
|
1694
2045
|
refs(root, declaration);
|
|
1695
2046
|
}
|
|
1696
2047
|
else if (ts.isPropertyAccessExpression(left) || ts.isElementAccessExpression(left)) {
|
|
2048
|
+
if (sourceIntrinsicMemberMayBeWrittenOf(checker, flow, left)) {
|
|
2049
|
+
const installed = sourceIntrinsicMemberDataWriteOf(checker, flow, left);
|
|
2050
|
+
if (installed === null || installed.site !== parent || sourceCallableObjectOf(checker, flow, reference) !== installed.body)
|
|
2051
|
+
fail('unproven-intrinsic-member-installation', left);
|
|
2052
|
+
else
|
|
2053
|
+
for (const access of installed.reads)
|
|
2054
|
+
add(read(use(root, access)));
|
|
2055
|
+
add(read(use(root, parent)));
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
1697
2058
|
const keys = keysOf(left);
|
|
1698
2059
|
const containers = read(value(left.expression));
|
|
1699
2060
|
if (sealing && containers.size === 0)
|
|
@@ -1701,8 +2062,8 @@ const createSession = (checker, flow) => {
|
|
|
1701
2062
|
for (const container of containers) {
|
|
1702
2063
|
// A store on `null`/`undefined` throws before it lands: an
|
|
1703
2064
|
// element slot read through a counter carries `undefined` for
|
|
1704
|
-
// the positions never written (`this.
|
|
1705
|
-
//
|
|
2065
|
+
// the positions never written (`this.items[ i ]` filled in a
|
|
2066
|
+
// loop), and that is no container.
|
|
1706
2067
|
if (container === undefinedValue || container.kind === ts.SyntaxKind.NullKeyword || ts.isVoidExpression(container))
|
|
1707
2068
|
continue;
|
|
1708
2069
|
if (!isObjectRoot(container)) {
|
|
@@ -1749,6 +2110,15 @@ const createSession = (checker, flow) => {
|
|
|
1749
2110
|
if (parent.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
1750
2111
|
parent.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsEqualsToken)
|
|
1751
2112
|
return;
|
|
2113
|
+
if (parent.operatorToken.kind === ts.SyntaxKind.InKeyword && parent.right === reference)
|
|
2114
|
+
return;
|
|
2115
|
+
// OrdinaryHasInstance only walks the left operand's prototype chain:
|
|
2116
|
+
// it reads no own key and runs no hook on it. A custom @@hasInstance
|
|
2117
|
+
// would receive it, which the ordinary-instance proof rules out.
|
|
2118
|
+
if (parent.operatorToken.kind === ts.SyntaxKind.InstanceOfKeyword &&
|
|
2119
|
+
parent.left === reference &&
|
|
2120
|
+
ordinarySourceClassInstanceTestOf(checker, flow, parent))
|
|
2121
|
+
return;
|
|
1752
2122
|
fail('coercing-value-use', parent);
|
|
1753
2123
|
return;
|
|
1754
2124
|
}
|
|
@@ -1765,6 +2135,19 @@ const createSession = (checker, flow) => {
|
|
|
1765
2135
|
add(read(publication(root, parent.parent, key)));
|
|
1766
2136
|
return;
|
|
1767
2137
|
}
|
|
2138
|
+
if (ts.isSpreadAssignment(parent) && parent.expression === reference && ts.isObjectLiteralExpression(root)) {
|
|
2139
|
+
// CopyDataProperties observes own data slots without retaining the
|
|
2140
|
+
// source owner. Copied identities continue through publication below;
|
|
2141
|
+
// the same complete key/storage queries still reject opaque readers.
|
|
2142
|
+
for (const key of read(nodeQuery('own-keys', root))) {
|
|
2143
|
+
if (!ts.isStringLiteral(key))
|
|
2144
|
+
fail('unmodelled-own-key-value', root);
|
|
2145
|
+
else
|
|
2146
|
+
read(storedSlot(root, key.text));
|
|
2147
|
+
}
|
|
2148
|
+
facts.add(reference);
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
1768
2151
|
if (ts.isShorthandPropertyAssignment(parent)) {
|
|
1769
2152
|
add(read(publication(root, parent.parent, parent.name.text)));
|
|
1770
2153
|
return;
|
|
@@ -1804,8 +2187,8 @@ const createSession = (checker, flow) => {
|
|
|
1804
2187
|
}
|
|
1805
2188
|
const keys = keysOf(parent);
|
|
1806
2189
|
// `new ( /** @type {new (...args: any[]) => this} */ ( this.constructor ) )()`
|
|
1807
|
-
// --
|
|
1808
|
-
// the read
|
|
2190
|
+
// -- a common JS spelling of the clone idiom wherever a library
|
|
2191
|
+
// JSDoc-casts the read --
|
|
1809
2192
|
// sits a ParenthesizedExpression between the access and the `new` that
|
|
1810
2193
|
// actually invokes it, purely to anchor the cast comment. Plain
|
|
1811
2194
|
// `parent.parent` lands on that paren, not the `new`, so the
|
|
@@ -1843,7 +2226,7 @@ const createSession = (checker, flow) => {
|
|
|
1843
2226
|
// where the program says so. Asking the write index instead -- "of
|
|
1844
2227
|
// every write in the program, which ones reach this root" -- is the
|
|
1845
2228
|
// same fact derived a second way, at O(all writes) per re-evaluation
|
|
1846
|
-
// instead of O(uses of the root); on
|
|
2229
|
+
// instead of O(uses of the root); on a large program that was the compile.
|
|
1847
2230
|
// `enumeratedKeysOf` already requires this closure, so the key set
|
|
1848
2231
|
// costs it no dependency it was not already holding.
|
|
1849
2232
|
if (stored || mutated)
|
|
@@ -1859,6 +2242,13 @@ const createSession = (checker, flow) => {
|
|
|
1859
2242
|
* receiver out says nothing about this store.
|
|
1860
2243
|
*/
|
|
1861
2244
|
const modelled = (held, key) => {
|
|
2245
|
+
if (isSourceCallableObject(held)) {
|
|
2246
|
+
if ((key === 'name' || key === 'length') && !stored && !mutated)
|
|
2247
|
+
return true;
|
|
2248
|
+
if (stored)
|
|
2249
|
+
return !mutated && sourceCallableDataWriteProtocolOf(checker, flow, key, parent);
|
|
2250
|
+
return !mutated && sourceCallableOwnDataWriteOf(checker, flow, held, key, parent) !== null;
|
|
2251
|
+
}
|
|
1862
2252
|
if (descriptorOf(held, key))
|
|
1863
2253
|
return true;
|
|
1864
2254
|
if (callee)
|
|
@@ -1909,6 +2299,68 @@ const createSession = (checker, flow) => {
|
|
|
1909
2299
|
fail('non-callable-use', reference);
|
|
1910
2300
|
return;
|
|
1911
2301
|
}
|
|
2302
|
+
if (ts.isCallExpression(parent)) {
|
|
2303
|
+
const query = intrinsicOwnKeyQueryOf(checker, parent.expression);
|
|
2304
|
+
if (query !== null &&
|
|
2305
|
+
parent.arguments.length === 1 &&
|
|
2306
|
+
parent.arguments[0] === reference &&
|
|
2307
|
+
['keys', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'ownKeys'].includes(query.member)) {
|
|
2308
|
+
if (deferredIntrinsicProtocolLedgerOf(flow)?.requireMember(query.owner, query.member, parent) !== true)
|
|
2309
|
+
fail('unproven-own-key-query', parent);
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
if (parent.arguments.length === 1 &&
|
|
2313
|
+
parent.arguments[0] === reference &&
|
|
2314
|
+
intrinsicJsonStringifyQueryOf(checker, unwrapErasedExpression(parent.expression))) {
|
|
2315
|
+
// This bounded observation has no replacer or coercing space
|
|
2316
|
+
// argument, and enters no toJSON/getter/recursive object frame.
|
|
2317
|
+
// Actual stored values and all future keys remain solver inputs.
|
|
2318
|
+
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
2319
|
+
const absence = sourceObjectPrototypeAbsenceOf(checker, ['toJSON'], parent);
|
|
2320
|
+
if (!isObjectRoot(root) ||
|
|
2321
|
+
(!ts.isObjectLiteralExpression(root) && !isFreshOrdinaryObject(root)) ||
|
|
2322
|
+
(ts.isObjectLiteralExpression(root) &&
|
|
2323
|
+
root.properties.some((one) => !ts.isPropertyAssignment(one) && !ts.isShorthandPropertyAssignment(one))) ||
|
|
2324
|
+
!ledger ||
|
|
2325
|
+
absence === null ||
|
|
2326
|
+
!ledger.requireMember('JSON', 'stringify', parent) ||
|
|
2327
|
+
!ledger.include([absence])) {
|
|
2328
|
+
fail('unproven-json-observation', parent);
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
for (const key of read(nodeQuery('own-keys', root))) {
|
|
2332
|
+
if (!ts.isStringLiteral(key) || key.text === 'toJSON') {
|
|
2333
|
+
fail('json-hook-observation', parent);
|
|
2334
|
+
continue;
|
|
2335
|
+
}
|
|
2336
|
+
const entries = read(storedSlot(root, key.text));
|
|
2337
|
+
if (sealing && entries.size === 0)
|
|
2338
|
+
fail('unresolved-json-slot', parent);
|
|
2339
|
+
if ([...entries].some((entry) => !primitiveStoredValue(entry)))
|
|
2340
|
+
fail('json-object-observation', parent);
|
|
2341
|
+
}
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2344
|
+
const installation = sourceCallableReflectSetOf(checker, parent);
|
|
2345
|
+
if (installation && (installation.target === reference || installation.value === reference)) {
|
|
2346
|
+
const owner = read(value(installation.target));
|
|
2347
|
+
if (sealing && owner.size === 0)
|
|
2348
|
+
fail('unresolved-callable-data-owner', parent);
|
|
2349
|
+
for (const held of owner) {
|
|
2350
|
+
if (!isSourceCallableObject(held) ||
|
|
2351
|
+
!sourceCallableDataWriteProtocolOf(checker, flow, installation.key, parent) ||
|
|
2352
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.requireMember('Reflect', 'set', parent) !== true) {
|
|
2353
|
+
fail('unproven-callable-data-write', parent);
|
|
2354
|
+
continue;
|
|
2355
|
+
}
|
|
2356
|
+
if (installation.target === reference)
|
|
2357
|
+
facts.add(parent);
|
|
2358
|
+
else
|
|
2359
|
+
add(read(publication(root, held, installation.key)));
|
|
2360
|
+
}
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
1912
2364
|
if (ts.isCallExpression(parent) && definitionPlans.has(parent)) {
|
|
1913
2365
|
const plan = definitionOf(parent);
|
|
1914
2366
|
if (plan === null)
|
|
@@ -1949,12 +2401,13 @@ const createSession = (checker, flow) => {
|
|
|
1949
2401
|
}
|
|
1950
2402
|
}
|
|
1951
2403
|
const site = sites.get(parent);
|
|
2404
|
+
const operands = ts.isCallExpression(parent) ? (candidateOrdinaryOwnCallableOperandsOf(parent) ?? site?.operands) : site?.operands;
|
|
1952
2405
|
// `f.call( receiver, ... )` writes the receiver in an ARGUMENT
|
|
1953
2406
|
// position of the syntax and reads it in the RECEIVER position of
|
|
1954
2407
|
// the frame. The operands already say which is which -- reading the
|
|
1955
2408
|
// syntax instead made every value handed to `.call` an argument no
|
|
1956
2409
|
// parameter had a slot for.
|
|
1957
|
-
if (site?.explicitThis &&
|
|
2410
|
+
if (site && operands?.explicitThis && operands.receiver === reference) {
|
|
1958
2411
|
forward(root, site, true, -1);
|
|
1959
2412
|
return;
|
|
1960
2413
|
}
|
|
@@ -1971,15 +2424,17 @@ const createSession = (checker, flow) => {
|
|
|
1971
2424
|
return;
|
|
1972
2425
|
}
|
|
1973
2426
|
}
|
|
1974
|
-
const position =
|
|
1975
|
-
if (!site || position < 0 ||
|
|
2427
|
+
const position = operands?.args.indexOf(reference) ?? -1;
|
|
2428
|
+
if (!site || position < 0 || operands?.args.some(ts.isSpreadElement))
|
|
1976
2429
|
fail('unmodelled-invocation-frame', parent);
|
|
1977
2430
|
else
|
|
1978
2431
|
forward(root, site, false, position);
|
|
1979
2432
|
return;
|
|
1980
2433
|
}
|
|
1981
|
-
if (ts.isReturnStatement(parent)) {
|
|
1982
|
-
|
|
2434
|
+
if (ts.isReturnStatement(parent) || (ts.isArrowFunction(parent) && parent.body === reference)) {
|
|
2435
|
+
// An expression-bodied arrow returns its body through the same
|
|
2436
|
+
// synchronous completion and complete caller inventory as `return`.
|
|
2437
|
+
const body = ts.isArrowFunction(parent) ? parent : ts.findAncestor(parent, ts.isFunctionLike);
|
|
1983
2438
|
if (body && ts.isGetAccessorDeclaration(body)) {
|
|
1984
2439
|
getterReturns(root, body);
|
|
1985
2440
|
return;
|
|
@@ -2001,6 +2456,11 @@ const createSession = (checker, flow) => {
|
|
|
2001
2456
|
// the key set could never be proven closed.
|
|
2002
2457
|
if (ts.isForInStatement(parent) && parent.expression === reference)
|
|
2003
2458
|
return;
|
|
2459
|
+
if (ts.isForOfStatement(parent) && parent.expression === reference && ts.isArrayLiteralExpression(root)) {
|
|
2460
|
+
if (parent.awaitModifier || deferredIntrinsicProtocolLedgerOf(flow)?.require('Array', parent) !== true)
|
|
2461
|
+
fail('unproven-array-iteration', parent);
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2004
2464
|
if (ts.isExpressionStatement(parent) ||
|
|
2005
2465
|
ts.isTypeOfExpression(parent) ||
|
|
2006
2466
|
ts.isVoidExpression(parent) ||
|
|
@@ -2009,13 +2469,76 @@ const createSession = (checker, flow) => {
|
|
|
2009
2469
|
return;
|
|
2010
2470
|
fail('opaque-value-use', reference);
|
|
2011
2471
|
};
|
|
2472
|
+
/** A parameter's values: every frame's argument and every rebinding of
|
|
2473
|
+
* the cell, less `excluded` -- a rebinding the read asking cannot see. */
|
|
2474
|
+
const parameterValues = (parameter, excluded) => {
|
|
2475
|
+
const owner = parameter.parent;
|
|
2476
|
+
if (ts.isSetAccessorDeclaration(owner)) {
|
|
2477
|
+
setterStores(owner);
|
|
2478
|
+
// The enumeration is exhaustive -- every store through every
|
|
2479
|
+
// instance -- so a setter nothing stores through has an EMPTY
|
|
2480
|
+
// parameter, witnessed here, not one pending some origin.
|
|
2481
|
+
seeded = true;
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
if (!isBody(owner) && !ts.isConstructorDeclaration(owner)) {
|
|
2485
|
+
fail('unindexed-parameter-frame');
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
// A binding pattern names no cell of its own, but the parameter DOES
|
|
2489
|
+
// hold the whole argument -- that value is what each binding element
|
|
2490
|
+
// then reads a slot of. Refusing here made the pattern's container
|
|
2491
|
+
// unknowable, so every receiver destructured out of a parameter was
|
|
2492
|
+
// opaque however completely the program built the object.
|
|
2493
|
+
if (parameter.dotDotDotToken) {
|
|
2494
|
+
fail('unmodelled-parameter-frame');
|
|
2495
|
+
return;
|
|
2496
|
+
}
|
|
2497
|
+
if (isBody(owner))
|
|
2498
|
+
read(closure(owner));
|
|
2499
|
+
for (const site of constructionSitesTargeting(owner))
|
|
2500
|
+
add(carry(frameQuery('frame-argument', site.call, owner, parameter)));
|
|
2501
|
+
for (const call of read(callersOf(owner)))
|
|
2502
|
+
if (ts.isCallExpression(call) || ts.isNewExpression(call))
|
|
2503
|
+
add(carry(frameQuery('frame-argument', call, owner, parameter)));
|
|
2504
|
+
for (const write of flow.writesToDeclaration(parameter)) {
|
|
2505
|
+
if (write.site === excluded)
|
|
2506
|
+
continue;
|
|
2507
|
+
if (write.edge === 'call-argument' || write.edge === 'super-argument' || write.edge === 'default-parameter')
|
|
2508
|
+
continue;
|
|
2509
|
+
// A member or element write goes THROUGH the cell into the object
|
|
2510
|
+
// it holds; it never rebinds the cell, so it is no evidence about
|
|
2511
|
+
// what this parameter's value set is. Whether the object can still
|
|
2512
|
+
// be described afterwards is that object's own closure to answer,
|
|
2513
|
+
// and refusing here answered it in the wrong place -- turning
|
|
2514
|
+
// `values[ k ] = 1` into "this parameter holds nothing".
|
|
2515
|
+
if (write.slot !== 'whole')
|
|
2516
|
+
continue;
|
|
2517
|
+
if (!['identifier-assignment', 'logical-assignment'].includes(write.edge) || !write.value) {
|
|
2518
|
+
fail('unmodelled-parameter-write', write.site);
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
add(carry(value(write.value)));
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2012
2524
|
seeded = false;
|
|
2013
2525
|
switch (query.kind) {
|
|
2014
2526
|
case 'value': {
|
|
2015
2527
|
const expression = query.node;
|
|
2528
|
+
const moduleExport = sourceCommonJsExportValueOf(flow, expression);
|
|
2529
|
+
if (moduleExport !== null) {
|
|
2530
|
+
add(carry(value(moduleExport)));
|
|
2531
|
+
break;
|
|
2532
|
+
}
|
|
2016
2533
|
if (isObjectRoot(expression)) {
|
|
2017
|
-
if (
|
|
2018
|
-
|
|
2534
|
+
if (isFreshOrdinaryObject(expression)) {
|
|
2535
|
+
if (deferredIntrinsicProtocolLedgerOf(flow)?.requireMember('Object', 'prototype', expression) !== true)
|
|
2536
|
+
fail('unproven-ordinary-object-allocation', expression);
|
|
2537
|
+
facts.add(expression);
|
|
2538
|
+
seeded = true;
|
|
2539
|
+
}
|
|
2540
|
+
else if (ts.isNewExpression(expression) && construction(expression) === null) {
|
|
2541
|
+
// `new State()` on a plain function that returns an object
|
|
2019
2542
|
// from every completion and never mentions `this` yields THAT
|
|
2020
2543
|
// completion, never the fresh allocation (`new` discards it):
|
|
2021
2544
|
// the value is the call's completion, solved through the same
|
|
@@ -2076,7 +2599,7 @@ const createSession = (checker, flow) => {
|
|
|
2076
2599
|
if (declaration && isBody(declaration) && flow.callableBodyIsIndexed(declaration)) {
|
|
2077
2600
|
facts.add(declaration);
|
|
2078
2601
|
seeded = true;
|
|
2079
|
-
if (
|
|
2602
|
+
if (!sourceGlobalCallableBindingIsClosed(checker, flow, declaration))
|
|
2080
2603
|
fail('global-object-callable', declaration);
|
|
2081
2604
|
for (const write of flow.writesToDeclaration(declaration)) {
|
|
2082
2605
|
if (write.slot !== 'whole' || write.edge === 'return' || write.edge === 'yield')
|
|
@@ -2088,15 +2611,30 @@ const createSession = (checker, flow) => {
|
|
|
2088
2611
|
}
|
|
2089
2612
|
}
|
|
2090
2613
|
else if (declaration && ts.isVariableDeclaration(declaration)) {
|
|
2091
|
-
const incoming =
|
|
2614
|
+
const incoming = sourceBindingValuesOf(checker, flow, declaration, iterationValuesAt);
|
|
2092
2615
|
if (incoming === null)
|
|
2093
2616
|
fail('unaccounted-binding-write', declaration);
|
|
2094
2617
|
else
|
|
2095
2618
|
for (const entry of incoming)
|
|
2096
2619
|
add(carry(value(entry)));
|
|
2620
|
+
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
2621
|
+
facts.add(undefinedValue);
|
|
2622
|
+
seeded = true;
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
else if (declaration && ts.isParameter(declaration)) {
|
|
2626
|
+
// `options = Object.assign({ ... }, options)`: the read in the
|
|
2627
|
+
// rebinding's own right side runs before the rebinding, and once
|
|
2628
|
+
// per cell -- outside a loop of the parameter's own body, and
|
|
2629
|
+
// not deferred into a nested function -- so it never sees the
|
|
2630
|
+
// value it is about to store. Joining it anyway made the copy's
|
|
2631
|
+
// source include its own target.
|
|
2632
|
+
const rebinding = rebindingAfterRead(declaration, expression);
|
|
2633
|
+
if (rebinding === null)
|
|
2634
|
+
add(carry(nodeQuery('parameter', declaration)));
|
|
2635
|
+
else
|
|
2636
|
+
parameterValues(declaration, rebinding);
|
|
2097
2637
|
}
|
|
2098
|
-
else if (declaration && ts.isParameter(declaration))
|
|
2099
|
-
add(carry(nodeQuery('parameter', declaration)));
|
|
2100
2638
|
else if (declaration && ts.isBindingElement(declaration))
|
|
2101
2639
|
add(carry(nodeQuery('binding-element', declaration)));
|
|
2102
2640
|
else if (expression.text === 'undefined' && (!declaration || declaration.getSourceFile().hasNoDefaultLib)) {
|
|
@@ -2114,6 +2652,16 @@ const createSession = (checker, flow) => {
|
|
|
2114
2652
|
add(carry(nodeQuery('receiver', owner)));
|
|
2115
2653
|
}
|
|
2116
2654
|
else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) {
|
|
2655
|
+
if (sourceIntrinsicMemberMayBeWrittenOf(checker, flow, expression)) {
|
|
2656
|
+
const installed = sourceIntrinsicMemberDataWriteOf(checker, flow, expression);
|
|
2657
|
+
if (installed === null)
|
|
2658
|
+
fail('unproven-intrinsic-member-read', expression);
|
|
2659
|
+
else {
|
|
2660
|
+
add(carry(value(installed.value)));
|
|
2661
|
+
read(closure(installed.body));
|
|
2662
|
+
}
|
|
2663
|
+
break;
|
|
2664
|
+
}
|
|
2117
2665
|
const keys = keysOf(expression);
|
|
2118
2666
|
const roots = read(value(expression.expression));
|
|
2119
2667
|
for (const root of roots) {
|
|
@@ -2127,8 +2675,15 @@ const createSession = (checker, flow) => {
|
|
|
2127
2675
|
continue;
|
|
2128
2676
|
}
|
|
2129
2677
|
if (isObjectRoot(root))
|
|
2130
|
-
for (const key of keys)
|
|
2131
|
-
|
|
2678
|
+
for (const key of keys) {
|
|
2679
|
+
if (isSourceCallableObject(root) &&
|
|
2680
|
+
key !== 'name' &&
|
|
2681
|
+
key !== 'length' &&
|
|
2682
|
+
sourceCallableOwnDataWriteOf(checker, flow, root, key, expression) === null)
|
|
2683
|
+
fail('unproven-callable-data-read', expression);
|
|
2684
|
+
else
|
|
2685
|
+
add(carry(slot(root, key)));
|
|
2686
|
+
}
|
|
2132
2687
|
else if (!isNullish(root))
|
|
2133
2688
|
fail('non-object-receiver');
|
|
2134
2689
|
}
|
|
@@ -2166,25 +2721,48 @@ const createSession = (checker, flow) => {
|
|
|
2166
2721
|
fail('unmodelled-value-origin');
|
|
2167
2722
|
break;
|
|
2168
2723
|
}
|
|
2169
|
-
case 'slot':
|
|
2724
|
+
case 'slot':
|
|
2725
|
+
case 'stored-slot': {
|
|
2170
2726
|
const root = query.node;
|
|
2171
2727
|
const key = query.key;
|
|
2172
|
-
const getterRead = ts.isNewExpression(root) && !descriptorOf(root, key) ? familyReadOf(root, key) : null;
|
|
2728
|
+
const getterRead = ts.isNewExpression(root) && !isFreshOrdinaryObject(root) && !descriptorOf(root, key) ? familyReadOf(root, key) : null;
|
|
2173
2729
|
if (!descriptorOf(root, key) && getterRead === null) {
|
|
2174
2730
|
// A literal that spells every key it has and holds no key this
|
|
2175
2731
|
// graph cannot name reads `undefined` for the ones it lacks:
|
|
2176
|
-
// `options.
|
|
2177
|
-
if (ts.isObjectLiteralExpression(root)
|
|
2732
|
+
// `options.attachment` on the `{}` a parameter defaults to.
|
|
2733
|
+
if ((ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) &&
|
|
2734
|
+
absentOwnKey(root, key, root, descriptorOf, hasUnnamedWrite)) {
|
|
2178
2735
|
read(closure(root));
|
|
2179
|
-
|
|
2180
|
-
|
|
2736
|
+
if (query.kind === 'slot') {
|
|
2737
|
+
facts.add(undefinedValue);
|
|
2738
|
+
seeded = true;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
else {
|
|
2742
|
+
fail('unmodelled-descriptor');
|
|
2181
2743
|
break;
|
|
2182
2744
|
}
|
|
2183
|
-
fail('unmodelled-descriptor');
|
|
2184
|
-
break;
|
|
2185
2745
|
}
|
|
2186
2746
|
read(closure(root));
|
|
2187
|
-
if (
|
|
2747
|
+
if (isSourceCallableObject(root)) {
|
|
2748
|
+
if (key === 'name' || key === 'length') {
|
|
2749
|
+
const parameters = runtimeParametersOf(root);
|
|
2750
|
+
const firstDefault = parameters.findIndex((parameter) => parameter.initializer !== undefined || parameter.dotDotDotToken !== undefined);
|
|
2751
|
+
const named = (ts.isArrowFunction(root) ? undefined : root.name) ?? (ts.isVariableDeclaration(root.parent) ? root.parent.name : undefined);
|
|
2752
|
+
facts.add(key === 'name'
|
|
2753
|
+
? ts.factory.createStringLiteral(named && ts.isIdentifier(named) ? named.text : '')
|
|
2754
|
+
: ts.factory.createNumericLiteral(firstDefault < 0 ? parameters.length : firstDefault));
|
|
2755
|
+
seeded = true;
|
|
2756
|
+
}
|
|
2757
|
+
else {
|
|
2758
|
+
const installed = sourceCallableOwnDataWriteOf(checker, flow, root, key);
|
|
2759
|
+
if (installed === null)
|
|
2760
|
+
fail('unproven-callable-data-slot', root);
|
|
2761
|
+
else
|
|
2762
|
+
add(carry(value(installed.value)));
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
else if (ts.isObjectLiteralExpression(root)) {
|
|
2188
2766
|
for (const entry of ownEntries(root, key) ?? []) {
|
|
2189
2767
|
if (ts.isPropertyAssignment(entry))
|
|
2190
2768
|
add(carry(value(entry.initializer)));
|
|
@@ -2222,7 +2800,7 @@ const createSession = (checker, flow) => {
|
|
|
2222
2800
|
}
|
|
2223
2801
|
}
|
|
2224
2802
|
}
|
|
2225
|
-
else {
|
|
2803
|
+
else if (ts.isNewExpression(root) && !isFreshOrdinaryObject(root)) {
|
|
2226
2804
|
for (const declaration of [...(classMembers(root, key) ?? []), ...(getterRead?.carriers ?? [])]) {
|
|
2227
2805
|
if (ts.isMethodDeclaration(declaration)) {
|
|
2228
2806
|
facts.add(declaration);
|
|
@@ -2267,17 +2845,24 @@ const createSession = (checker, flow) => {
|
|
|
2267
2845
|
// and the ones that spell no key at all. Walking every write in the
|
|
2268
2846
|
// program here cost O(all writes) per (root, key) -- fine while
|
|
2269
2847
|
// computed slots were rare, and quadratic the moment a `for-in` head
|
|
2270
|
-
// started naming a key set, which is what stopped
|
|
2271
|
-
//
|
|
2848
|
+
// started naming a key set, which is what stopped a large class
|
|
2849
|
+
// from finishing.
|
|
2272
2850
|
// The stores that go through this root are the root's own closure's
|
|
2273
2851
|
// facts -- `visitUse` publishes each one as it walks -- and this
|
|
2274
2852
|
// transfer already requires that closure above. Asking the write
|
|
2275
2853
|
// index instead meant subscribing to every write naming this key
|
|
2276
2854
|
// PLUS every computed write in the program, per slot, permanently:
|
|
2277
|
-
//
|
|
2278
|
-
//
|
|
2855
|
+
// hundreds of edges on each of a large program's tens of thousands of
|
|
2856
|
+
// slot states, and by far the largest contributor to its
|
|
2857
|
+
// multi-million-edge graph. Same answer, no
|
|
2279
2858
|
// dependency this node was not already holding.
|
|
2280
2859
|
for (const stored of read(closure(root))) {
|
|
2860
|
+
if (isSourceCallableObject(root) && ts.isCallExpression(stored)) {
|
|
2861
|
+
const installation = sourceCallableReflectSetOf(checker, stored);
|
|
2862
|
+
if (installation && installation.key === key && read(value(installation.target)).has(root))
|
|
2863
|
+
add(carry(value(installation.value)));
|
|
2864
|
+
continue;
|
|
2865
|
+
}
|
|
2281
2866
|
if (ts.isCallExpression(stored) && definitionPlans.has(stored)) {
|
|
2282
2867
|
const plan = definitionOf(stored);
|
|
2283
2868
|
if (plan === null || !plan.keys.includes(key) || !read(value(stored.arguments[0])).has(root))
|
|
@@ -2306,8 +2891,8 @@ const createSession = (checker, flow) => {
|
|
|
2306
2891
|
fail('bulk-assign-source-unmodelled', source);
|
|
2307
2892
|
else if (literalSpelledKeys(held) === null || hasUnnamedWrite(held))
|
|
2308
2893
|
fail('bulk-assign-source-keys-open', source);
|
|
2309
|
-
else if (
|
|
2310
|
-
add(carry(
|
|
2894
|
+
else if (ownKeysOf(held)?.includes(key))
|
|
2895
|
+
add(carry(storedSlot(held, key)));
|
|
2311
2896
|
}
|
|
2312
2897
|
continue;
|
|
2313
2898
|
}
|
|
@@ -2319,6 +2904,21 @@ const createSession = (checker, flow) => {
|
|
|
2319
2904
|
if (!keyReaches(root, keysOf(stored), key))
|
|
2320
2905
|
continue;
|
|
2321
2906
|
const write = edge.write;
|
|
2907
|
+
if (write.edge === 'delete' && (ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root))) {
|
|
2908
|
+
// Removing an own data descriptor contributes no stored payload.
|
|
2909
|
+
// A value read can also reach the prototype after that removal.
|
|
2910
|
+
if (query.kind === 'slot') {
|
|
2911
|
+
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
2912
|
+
const absence = sourceObjectPrototypeAbsenceOf(checker, [key], stored);
|
|
2913
|
+
if (!ledger || absence === null || !ledger.include([absence]))
|
|
2914
|
+
fail('unproven-deleted-slot-absence', stored);
|
|
2915
|
+
else {
|
|
2916
|
+
facts.add(undefinedValue);
|
|
2917
|
+
seeded = true;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
continue;
|
|
2921
|
+
}
|
|
2322
2922
|
if (write.value === null || !['property-assignment', 'index-assignment', 'class-field-initializer'].includes(write.edge)) {
|
|
2323
2923
|
fail('unmodelled-property-write', stored);
|
|
2324
2924
|
continue;
|
|
@@ -2381,7 +2981,8 @@ const createSession = (checker, flow) => {
|
|
|
2381
2981
|
fail('unmodelled-dispatch');
|
|
2382
2982
|
break;
|
|
2383
2983
|
}
|
|
2384
|
-
|
|
2984
|
+
const operands = candidateOrdinaryOwnCallableOperandsOf(query.node) ?? site.operands;
|
|
2985
|
+
for (const candidate of read(value(operands.callee))) {
|
|
2385
2986
|
if (isBody(candidate) && flow.callableBodyIsIndexed(candidate)) {
|
|
2386
2987
|
facts.add(candidate);
|
|
2387
2988
|
seeded = true;
|
|
@@ -2443,7 +3044,8 @@ const createSession = (checker, flow) => {
|
|
|
2443
3044
|
case 'frame-parameter':
|
|
2444
3045
|
case 'frame-value':
|
|
2445
3046
|
case 'frame-completion': {
|
|
2446
|
-
const
|
|
3047
|
+
const own = ts.isCallExpression(query.node) ? candidateOrdinaryOwnCallableOperandsOf(query.node) : null;
|
|
3048
|
+
const layout = sourceInvocationFrameLayoutOf(flow, query.node, query.body, own ?? undefined);
|
|
2447
3049
|
if (!layout) {
|
|
2448
3050
|
fail('unindexed-source-frame');
|
|
2449
3051
|
break;
|
|
@@ -2456,9 +3058,9 @@ const createSession = (checker, flow) => {
|
|
|
2456
3058
|
seeded = true;
|
|
2457
3059
|
}
|
|
2458
3060
|
else if (receiver.kind === 'expression') {
|
|
2459
|
-
const memberCall = !
|
|
3061
|
+
const memberCall = !layout.operands.explicitThis;
|
|
2460
3062
|
for (const candidate of carry(value(receiver.expression))) {
|
|
2461
|
-
// `source.
|
|
3063
|
+
// `source.attachment.clone()` with no attachment set:
|
|
2462
3064
|
// the member lookup on `null` throws and the frame never runs
|
|
2463
3065
|
// with that receiver. Only an explicit `f.call( null )` binds
|
|
2464
3066
|
// a nullish receiver.
|
|
@@ -2474,6 +3076,24 @@ const createSession = (checker, flow) => {
|
|
|
2474
3076
|
}
|
|
2475
3077
|
else if (receiver.kind === 'constructed')
|
|
2476
3078
|
add(carry(value(receiver.call)));
|
|
3079
|
+
else if (receiver.kind === 'lexical' && receiver.source !== 'arrow') {
|
|
3080
|
+
// `super.m()` and `super()` run with the calling frame's own
|
|
3081
|
+
// `this`; the class the layout names is only where the lookup
|
|
3082
|
+
// starts, and no receiver is owned by a class.
|
|
3083
|
+
const callee = ts.isCallExpression(query.node) ? unwrapErasedExpression(query.node.expression) : null;
|
|
3084
|
+
const keyword = callee === null
|
|
3085
|
+
? null
|
|
3086
|
+
: callee.kind === ts.SyntaxKind.SuperKeyword
|
|
3087
|
+
? callee
|
|
3088
|
+
: (ts.isPropertyAccessExpression(callee) || ts.isElementAccessExpression(callee)) &&
|
|
3089
|
+
callee.expression.kind === ts.SyntaxKind.SuperKeyword
|
|
3090
|
+
? callee.expression
|
|
3091
|
+
: null;
|
|
3092
|
+
if (keyword === null)
|
|
3093
|
+
fail('unresolved-super-home', query.node);
|
|
3094
|
+
else
|
|
3095
|
+
add(carry(value(keyword)));
|
|
3096
|
+
}
|
|
2477
3097
|
else if (receiver.kind === 'lexical' && receiver.owner) {
|
|
2478
3098
|
if (ts.isSourceFile(receiver.owner)) {
|
|
2479
3099
|
if (ts.isExternalModule(receiver.owner)) {
|
|
@@ -2558,12 +3178,16 @@ const createSession = (checker, flow) => {
|
|
|
2558
3178
|
else if (declaration &&
|
|
2559
3179
|
ts.isVariableDeclaration(declaration) &&
|
|
2560
3180
|
ts.findAncestor(declaration, ts.isFunctionLike) === query.body) {
|
|
2561
|
-
const incoming =
|
|
3181
|
+
const incoming = sourceBindingValuesOf(checker, flow, declaration, iterationValuesAt);
|
|
2562
3182
|
if (incoming === null)
|
|
2563
3183
|
fail('unaccounted-binding-write', declaration);
|
|
2564
3184
|
else
|
|
2565
3185
|
for (const entry of incoming)
|
|
2566
3186
|
add(carry(contextual(entry)));
|
|
3187
|
+
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3188
|
+
facts.add(undefinedValue);
|
|
3189
|
+
seeded = true;
|
|
3190
|
+
}
|
|
2567
3191
|
}
|
|
2568
3192
|
else if ((expression.kind === ts.SyntaxKind.ThisKeyword || expression.kind === ts.SyntaxKind.SuperKeyword) &&
|
|
2569
3193
|
(ts.isArrowFunction(query.body) || flow.receiverOwnerOf(expression) === query.body))
|
|
@@ -2576,8 +3200,15 @@ const createSession = (checker, flow) => {
|
|
|
2576
3200
|
const keys = keysOf(expression);
|
|
2577
3201
|
for (const root of read(contextual(expression.expression))) {
|
|
2578
3202
|
if (isObjectRoot(root))
|
|
2579
|
-
for (const key of keys)
|
|
2580
|
-
|
|
3203
|
+
for (const key of keys) {
|
|
3204
|
+
if (isSourceCallableObject(root) &&
|
|
3205
|
+
key !== 'name' &&
|
|
3206
|
+
key !== 'length' &&
|
|
3207
|
+
sourceCallableOwnDataWriteOf(checker, flow, root, key, expression) === null)
|
|
3208
|
+
fail('unproven-callable-data-read', expression);
|
|
3209
|
+
else
|
|
3210
|
+
add(carry(slot(root, key)));
|
|
3211
|
+
}
|
|
2581
3212
|
else if (root.kind !== ts.SyntaxKind.NullKeyword && !ts.isVoidExpression(root))
|
|
2582
3213
|
fail('non-object-receiver');
|
|
2583
3214
|
}
|
|
@@ -2596,53 +3227,7 @@ const createSession = (checker, flow) => {
|
|
|
2596
3227
|
break;
|
|
2597
3228
|
}
|
|
2598
3229
|
case 'parameter': {
|
|
2599
|
-
|
|
2600
|
-
const owner = parameter.parent;
|
|
2601
|
-
if (ts.isSetAccessorDeclaration(owner)) {
|
|
2602
|
-
setterStores(owner);
|
|
2603
|
-
// The enumeration is exhaustive -- every store through every
|
|
2604
|
-
// instance -- so a setter nothing stores through has an EMPTY
|
|
2605
|
-
// parameter, witnessed here, not one pending some origin.
|
|
2606
|
-
seeded = true;
|
|
2607
|
-
break;
|
|
2608
|
-
}
|
|
2609
|
-
if (!isBody(owner) && !ts.isConstructorDeclaration(owner)) {
|
|
2610
|
-
fail('unindexed-parameter-frame');
|
|
2611
|
-
break;
|
|
2612
|
-
}
|
|
2613
|
-
// A binding pattern names no cell of its own, but the parameter DOES
|
|
2614
|
-
// hold the whole argument -- that value is what each binding element
|
|
2615
|
-
// then reads a slot of. Refusing here made the pattern's container
|
|
2616
|
-
// unknowable, so every receiver destructured out of a parameter was
|
|
2617
|
-
// opaque however completely the program built the object.
|
|
2618
|
-
if (parameter.dotDotDotToken) {
|
|
2619
|
-
fail('unmodelled-parameter-frame');
|
|
2620
|
-
break;
|
|
2621
|
-
}
|
|
2622
|
-
if (isBody(owner))
|
|
2623
|
-
read(closure(owner));
|
|
2624
|
-
for (const site of constructionSitesTargeting(owner))
|
|
2625
|
-
add(carry(frameQuery('frame-argument', site.call, owner, parameter)));
|
|
2626
|
-
for (const call of read(callersOf(owner)))
|
|
2627
|
-
if (ts.isCallExpression(call) || ts.isNewExpression(call))
|
|
2628
|
-
add(carry(frameQuery('frame-argument', call, owner, parameter)));
|
|
2629
|
-
for (const write of flow.writesToDeclaration(parameter)) {
|
|
2630
|
-
if (write.edge === 'call-argument' || write.edge === 'super-argument' || write.edge === 'default-parameter')
|
|
2631
|
-
continue;
|
|
2632
|
-
// A member or element write goes THROUGH the cell into the object
|
|
2633
|
-
// it holds; it never rebinds the cell, so it is no evidence about
|
|
2634
|
-
// what this parameter's value set is. Whether the object can still
|
|
2635
|
-
// be described afterwards is that object's own closure to answer,
|
|
2636
|
-
// and refusing here answered it in the wrong place -- turning
|
|
2637
|
-
// `values[ k ] = 1` into "this parameter holds nothing".
|
|
2638
|
-
if (write.slot !== 'whole')
|
|
2639
|
-
continue;
|
|
2640
|
-
if (!['identifier-assignment', 'logical-assignment'].includes(write.edge) || !write.value) {
|
|
2641
|
-
fail('unmodelled-parameter-write', write.site);
|
|
2642
|
-
continue;
|
|
2643
|
-
}
|
|
2644
|
-
add(carry(value(write.value)));
|
|
2645
|
-
}
|
|
3230
|
+
parameterValues(query.node, null);
|
|
2646
3231
|
break;
|
|
2647
3232
|
}
|
|
2648
3233
|
case 'binding-element': {
|
|
@@ -2675,12 +3260,12 @@ const createSession = (checker, flow) => {
|
|
|
2675
3260
|
// and a literal's own stated property is never that by
|
|
2676
3261
|
// omission -- so when every root the container resolves to is
|
|
2677
3262
|
// such a literal, the default is dead code and the slot reads
|
|
2678
|
-
// below are the whole, sound answer.
|
|
2679
|
-
//
|
|
2680
|
-
//
|
|
3263
|
+
// below are the whole, sound answer. A host-options literal
|
|
3264
|
+
// like `new Renderer({ canvas, context, depth: true, ... })`
|
|
3265
|
+
// states every field its constructor destructures
|
|
2681
3266
|
// with a default, so refusing EVERY defaulted binding element
|
|
2682
|
-
// unconditionally made
|
|
2683
|
-
// the whole
|
|
3267
|
+
// unconditionally made the host context -- and everything
|
|
3268
|
+
// downstream of it, the whole host surface -- permanently unenumerable no
|
|
2684
3269
|
// matter what the program actually wrote at the call site.
|
|
2685
3270
|
const defaultIsLive = element.initializer !== undefined &&
|
|
2686
3271
|
(roots.size === 0 || [...roots].some((root) => !ts.isObjectLiteralExpression(root) || ownEntries(root, key) === null));
|
|
@@ -2688,7 +3273,12 @@ const createSession = (checker, flow) => {
|
|
|
2688
3273
|
fail('defaulted-binding-element', element);
|
|
2689
3274
|
else
|
|
2690
3275
|
for (const root of roots) {
|
|
2691
|
-
if (
|
|
3276
|
+
if (isSourceCallableObject(root) &&
|
|
3277
|
+
key !== 'name' &&
|
|
3278
|
+
key !== 'length' &&
|
|
3279
|
+
sourceCallableOwnDataWriteOf(checker, flow, root, key, element) === null)
|
|
3280
|
+
fail('unproven-callable-data-read', element);
|
|
3281
|
+
else if (isObjectRoot(root))
|
|
2692
3282
|
add(carry(slot(root, key)));
|
|
2693
3283
|
else
|
|
2694
3284
|
fail('non-object-destructured-container', element);
|
|
@@ -2737,9 +3327,9 @@ const createSession = (checker, flow) => {
|
|
|
2737
3327
|
// site spells. A spelled call whose targets are opaque is then
|
|
2738
3328
|
// either a call through one of those closures, which already
|
|
2739
3329
|
// refused, or a call on something that never holds this owner.
|
|
2740
|
-
// Requiring every candidate's targets instead made `
|
|
2741
|
-
// wait on `targetMatrix.copy( ... )`
|
|
2742
|
-
//
|
|
3330
|
+
// Requiring every candidate's targets instead made a class's `copy`
|
|
3331
|
+
// wait on `targetMatrix.copy( ... )` inside a module-level helper
|
|
3332
|
+
// literal, a matrix the graph never places.
|
|
2743
3333
|
const owner = query.node;
|
|
2744
3334
|
// A constructor is never CALLED: its frames are its construction
|
|
2745
3335
|
// sites, which `constructionSitesTargeting` names from the
|
|
@@ -2754,24 +3344,9 @@ const createSession = (checker, flow) => {
|
|
|
2754
3344
|
for (const instance of familyInstancesOf(owner.parent, 'member-family-open') ?? [])
|
|
2755
3345
|
read(closure(instance));
|
|
2756
3346
|
}
|
|
2757
|
-
const
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
// function's own argument frame exactly as a call would; the
|
|
2761
|
-
// construction domain names no class for it, so it is a caller.
|
|
2762
|
-
if (ts.isNewExpression(site.call)) {
|
|
2763
|
-
if (ts.isFunctionDeclaration(owner) && constructorFunctionCalleeOf(site.call) === owner)
|
|
2764
|
-
facts.add(site.call);
|
|
2765
|
-
continue;
|
|
2766
|
-
}
|
|
2767
|
-
if (!ts.isCallExpression(site.call))
|
|
2768
|
-
continue;
|
|
2769
|
-
if (ownerType !== null && !site.explicitThis && site.operands.dispatch.kind === 'member' && site.operands.receiver !== null) {
|
|
2770
|
-
if (!statedTypeAdmits(checker.getTypeAtLocation(site.operands.receiver), ownerType))
|
|
2771
|
-
continue;
|
|
2772
|
-
}
|
|
2773
|
-
if (observe(targets(site.call)).has(owner))
|
|
2774
|
-
facts.add(site.call);
|
|
3347
|
+
for (const candidate of callerCandidatesOf(owner)) {
|
|
3348
|
+
if (candidate.call === null || observe(targets(candidate.call)).has(owner))
|
|
3349
|
+
facts.add(candidate.site.call);
|
|
2775
3350
|
}
|
|
2776
3351
|
break;
|
|
2777
3352
|
}
|
|
@@ -2782,7 +3357,7 @@ const createSession = (checker, flow) => {
|
|
|
2782
3357
|
// factory imported by a source module is not an external escape.
|
|
2783
3358
|
if (importerMentions(root) === null)
|
|
2784
3359
|
fail('exported-callable');
|
|
2785
|
-
if (
|
|
3360
|
+
if (!sourceGlobalCallableBindingIsClosed(checker, flow, root))
|
|
2786
3361
|
fail('global-object-callable');
|
|
2787
3362
|
refs(root, root);
|
|
2788
3363
|
}
|
|
@@ -2801,7 +3376,7 @@ const createSession = (checker, flow) => {
|
|
|
2801
3376
|
add(read(use(root, root)));
|
|
2802
3377
|
else
|
|
2803
3378
|
fail('unmodelled-root');
|
|
2804
|
-
if (ts.isNewExpression(root)) {
|
|
3379
|
+
if (ts.isNewExpression(root) && !isFreshOrdinaryObject(root)) {
|
|
2805
3380
|
const owners = constructionFrames.receiverOwnersOf(root);
|
|
2806
3381
|
if (!owners) {
|
|
2807
3382
|
fail('opaque-construction');
|
|
@@ -2839,6 +3414,43 @@ const createSession = (checker, flow) => {
|
|
|
2839
3414
|
facts.add(entry.access);
|
|
2840
3415
|
break;
|
|
2841
3416
|
}
|
|
3417
|
+
case 'own-keys': {
|
|
3418
|
+
const root = query.node;
|
|
3419
|
+
const keys = ownKeysOf(root);
|
|
3420
|
+
if (keys === null) {
|
|
3421
|
+
fail('unspelled-own-key-domain', root);
|
|
3422
|
+
break;
|
|
3423
|
+
}
|
|
3424
|
+
const stored = read(closure(root));
|
|
3425
|
+
for (const key of keys)
|
|
3426
|
+
facts.add(keyValue(root, key));
|
|
3427
|
+
seeded = true;
|
|
3428
|
+
// Discovery subscriptions alone cannot authenticate a bulk source.
|
|
3429
|
+
// Require each contributing source's complete keys and closure in
|
|
3430
|
+
// the same solver graph, including keys that it acquired earlier.
|
|
3431
|
+
for (const write of stored) {
|
|
3432
|
+
if (!ts.isCallExpression(write))
|
|
3433
|
+
continue;
|
|
3434
|
+
const bulk = bulkAssignOf(write);
|
|
3435
|
+
if (bulk === null || !read(value(bulk.target)).has(root))
|
|
3436
|
+
continue;
|
|
3437
|
+
for (const source of bulk.sources)
|
|
3438
|
+
for (const held of read(value(source))) {
|
|
3439
|
+
if (isNullish(held))
|
|
3440
|
+
continue;
|
|
3441
|
+
if (!ts.isObjectLiteralExpression(held))
|
|
3442
|
+
fail('bulk-assign-source-unmodelled', source);
|
|
3443
|
+
else
|
|
3444
|
+
for (const key of read(nodeQuery('own-keys', held))) {
|
|
3445
|
+
if (ts.isStringLiteral(key))
|
|
3446
|
+
facts.add(keyValue(root, key.text));
|
|
3447
|
+
else
|
|
3448
|
+
fail('unmodelled-own-key-value', held);
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
break;
|
|
3453
|
+
}
|
|
2842
3454
|
case 'publication': {
|
|
2843
3455
|
read(closure(query.node));
|
|
2844
3456
|
// A container merged into another by `Object.assign` hands this
|
|
@@ -2854,6 +3466,9 @@ const createSession = (checker, flow) => {
|
|
|
2854
3466
|
add(read(publication(query.root, held, query.key)));
|
|
2855
3467
|
}
|
|
2856
3468
|
for (const stored of read(closure(query.node))) {
|
|
3469
|
+
const copied = ts.isExpression(stored) ? outermostErasureOf(stored).parent : undefined;
|
|
3470
|
+
if (copied && ts.isSpreadAssignment(copied) && read(value(copied.expression)).has(query.node))
|
|
3471
|
+
add(read(publication(query.root, copied.parent, query.key)));
|
|
2857
3472
|
if (!ts.isCallExpression(stored) || !definitionPlans.has(stored) || query.key !== 'value')
|
|
2858
3473
|
continue;
|
|
2859
3474
|
const plan = definitionOf(stored);
|
|
@@ -2900,6 +3515,21 @@ const createSession = (checker, flow) => {
|
|
|
2900
3515
|
else
|
|
2901
3516
|
refs(query.root, element);
|
|
2902
3517
|
}
|
|
3518
|
+
if (ts.isArrayLiteralExpression(query.node) && (query.key === ELEMENT_KEY || isCanonicalIndex(query.key)))
|
|
3519
|
+
for (const write of (valueIterationWrites ??= flow.allWrites.filter((write) => write.iterationOrigin?.mode === 'values'))) {
|
|
3520
|
+
const origin = write.iterationOrigin;
|
|
3521
|
+
if (!observe(value(origin.source)).has(query.node))
|
|
3522
|
+
continue;
|
|
3523
|
+
if (origin.asynchronous || deferredIntrinsicProtocolLedgerOf(flow)?.require('Array', origin.source) !== true) {
|
|
3524
|
+
fail('unproven-array-iteration', write.site);
|
|
3525
|
+
continue;
|
|
3526
|
+
}
|
|
3527
|
+
const declaration = write.target.declaration;
|
|
3528
|
+
if (declaration && ts.isVariableDeclaration(declaration) && ts.isIdentifier(declaration.name))
|
|
3529
|
+
refs(query.root, declaration);
|
|
3530
|
+
else
|
|
3531
|
+
fail('unmodelled-iteration-binding', write.site);
|
|
3532
|
+
}
|
|
2903
3533
|
break;
|
|
2904
3534
|
}
|
|
2905
3535
|
}
|
|
@@ -2985,7 +3615,7 @@ const createSession = (checker, flow) => {
|
|
|
2985
3615
|
};
|
|
2986
3616
|
// A literal's function-valued entry (`convert: function ( ... ) { ... }`)
|
|
2987
3617
|
// is the same slot as its shorthand method: one literal, one write, no
|
|
2988
|
-
// nominal family. Both spellings occur in
|
|
3618
|
+
// nominal family. Both spellings commonly occur in one literal.
|
|
2989
3619
|
const isObjectLiteralCallableEntry = (declaration) => ts.isObjectLiteralExpression(declaration.parent) &&
|
|
2990
3620
|
!declaration.getSourceFile().isDeclarationFile &&
|
|
2991
3621
|
(isSourceInstanceMethod(declaration) ||
|
|
@@ -3009,9 +3639,302 @@ const createSession = (checker, flow) => {
|
|
|
3009
3639
|
const found = admitted(targets(call));
|
|
3010
3640
|
return found !== null && found.every(isCallableValue) ? found : null;
|
|
3011
3641
|
};
|
|
3642
|
+
const ownSlotOf = (expression, key) => {
|
|
3643
|
+
const incoming = admitted(value(expression));
|
|
3644
|
+
if (incoming === null)
|
|
3645
|
+
return null;
|
|
3646
|
+
// This inventory names owners on the normal [[Get]]/[[Set]] path.
|
|
3647
|
+
// Nullish receiver alternatives throw at lookup, as the property-value
|
|
3648
|
+
// transfer above already models; they have no data slot to inventory.
|
|
3649
|
+
// Stored values remain untouched, including a real stored undefined.
|
|
3650
|
+
const roots = incoming.filter((root) => !isNullish(root));
|
|
3651
|
+
if (roots.length === 0)
|
|
3652
|
+
return null;
|
|
3653
|
+
if (roots.every((root) => ts.isObjectLiteralExpression(root) && literalSpelledKeys(root)?.includes(key)))
|
|
3654
|
+
return null;
|
|
3655
|
+
const slots = [];
|
|
3656
|
+
for (const root of roots) {
|
|
3657
|
+
if ((!ts.isObjectLiteralExpression(root) && !sourceFreshOrdinaryObjectOf(checker, root)) ||
|
|
3658
|
+
literalSpelledKeys(root) === null ||
|
|
3659
|
+
(ts.isObjectLiteralExpression(root) &&
|
|
3660
|
+
root.properties.some((property) => !ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property))))
|
|
3661
|
+
return null;
|
|
3662
|
+
const uses = admitted(closure(root));
|
|
3663
|
+
if (uses === null || uses.some((use) => ts.isCallExpression(use) && definitionPlans.has(use)))
|
|
3664
|
+
return null;
|
|
3665
|
+
const values = admitted(storedSlot(root, key));
|
|
3666
|
+
if (values === null)
|
|
3667
|
+
return null;
|
|
3668
|
+
const writes = [];
|
|
3669
|
+
for (const use of uses) {
|
|
3670
|
+
if ((!ts.isPropertyAccessExpression(use) && !ts.isElementAccessExpression(use)) || !writeEdgeByAccess.has(use))
|
|
3671
|
+
continue;
|
|
3672
|
+
const direct = accessKey(use);
|
|
3673
|
+
if (direct !== null) {
|
|
3674
|
+
if (direct === key)
|
|
3675
|
+
writes.push(use);
|
|
3676
|
+
continue;
|
|
3677
|
+
}
|
|
3678
|
+
if (!ts.isElementAccessExpression(use))
|
|
3679
|
+
return null;
|
|
3680
|
+
const names = admitted(value(use.argumentExpression));
|
|
3681
|
+
if (names === null || names.length === 0 || names.some((name) => !ts.isStringLiteralLike(name) && !ts.isNumericLiteral(name)))
|
|
3682
|
+
return null;
|
|
3683
|
+
if (names.some((name) => (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) && name.text === key))
|
|
3684
|
+
writes.push(use);
|
|
3685
|
+
}
|
|
3686
|
+
slots.push({ root, values, writes });
|
|
3687
|
+
}
|
|
3688
|
+
return { key, roots: slots };
|
|
3689
|
+
};
|
|
3690
|
+
const callerSitesOf = (body) => {
|
|
3691
|
+
const callers = admitted(callersOf(body));
|
|
3692
|
+
return callers !== null && callers.every((caller) => ts.isCallExpression(caller) || ts.isNewExpression(caller))
|
|
3693
|
+
? callers.filter((caller) => ts.isCallExpression(caller) || ts.isNewExpression(caller))
|
|
3694
|
+
: null;
|
|
3695
|
+
};
|
|
3696
|
+
const ordinaryOwnCallableOperandsOf = (call) => {
|
|
3697
|
+
const candidate = candidateOrdinaryOwnCallableOperandsOf(call);
|
|
3698
|
+
if (candidate === null)
|
|
3699
|
+
return null;
|
|
3700
|
+
const found = admitted(targets(call));
|
|
3701
|
+
return found !== null && found.length > 0 && found.every(isCallableValue) ? candidate : null;
|
|
3702
|
+
};
|
|
3703
|
+
const parameterSourceExpressionsOf = (parameter) => {
|
|
3704
|
+
const body = parameter.parent;
|
|
3705
|
+
if (!isBody(body) ||
|
|
3706
|
+
parameter.initializer !== undefined ||
|
|
3707
|
+
parameter.dotDotDotToken !== undefined ||
|
|
3708
|
+
!ts.isIdentifier(parameter.name) ||
|
|
3709
|
+
!runtimeParametersOf(body).includes(parameter) ||
|
|
3710
|
+
flow.writesToDeclaration(parameter).some((write) => write.slot === 'whole' && write.edge !== 'call-argument'))
|
|
3711
|
+
return null;
|
|
3712
|
+
const callers = callerSitesOf(body);
|
|
3713
|
+
if (callers === null)
|
|
3714
|
+
return null;
|
|
3715
|
+
const expressions = new Set();
|
|
3716
|
+
for (const call of callers) {
|
|
3717
|
+
if (!ts.isCallExpression(call) || !invocationTargetsOf(call)?.includes(body))
|
|
3718
|
+
return null;
|
|
3719
|
+
const candidate = candidateOrdinaryOwnCallableOperandsOf(call);
|
|
3720
|
+
const own = ordinaryOwnCallableOperandsOf(call);
|
|
3721
|
+
if (candidate !== own)
|
|
3722
|
+
return null;
|
|
3723
|
+
const frame = sourceInvocationFrameLayoutOf(flow, call, body, own ?? undefined);
|
|
3724
|
+
if (frame?.arguments.kind !== 'positional')
|
|
3725
|
+
return null;
|
|
3726
|
+
const slot = frame.arguments.slots.find((one) => one.parameter === parameter);
|
|
3727
|
+
if (slot?.kind !== 'single' || slot.actual === null || slot.defaultValue !== null)
|
|
3728
|
+
return null;
|
|
3729
|
+
expressions.add(slot.actual);
|
|
3730
|
+
}
|
|
3731
|
+
return [...expressions];
|
|
3732
|
+
};
|
|
3733
|
+
/** The copy no closed allocation family accounts for, described by its
|
|
3734
|
+
* operands' representations instead: no target root or slot domain is a
|
|
3735
|
+
* session fact (the IR proves the exact target allocation and its census
|
|
3736
|
+
* sizes any key it lacks), and every source's keys are the ones its
|
|
3737
|
+
* representation lays out (`describedKeysOf`). The session decides no key
|
|
3738
|
+
* set of its own; it publishes only the absence obligation over those
|
|
3739
|
+
* keys, since each may be absent from the target and [[Set]] then consults
|
|
3740
|
+
* the intact Object.prototype. */
|
|
3741
|
+
const describedOwnAssignmentOf = (call, bulk, describedKeysOf) => {
|
|
3742
|
+
if (bulk.sources.length === 0 || describedKeysOf === undefined)
|
|
3743
|
+
return null;
|
|
3744
|
+
const sources = [];
|
|
3745
|
+
const copied = new Set();
|
|
3746
|
+
for (const [index, expression] of bulk.sources.entries()) {
|
|
3747
|
+
const keys = describedKeysOf(expression);
|
|
3748
|
+
if (keys === null)
|
|
3749
|
+
return null;
|
|
3750
|
+
// The description copies the declared keys through the source's
|
|
3751
|
+
// carrier, so a literal the source is known to hold must have no other
|
|
3752
|
+
// key and no replaced descriptor, ever: its own complete key domain and
|
|
3753
|
+
// closure say so, and fail where it was published, coerced, written
|
|
3754
|
+
// under a computed key or redefined. That is the SOURCE's own proof; the
|
|
3755
|
+
// closed family additionally closes the TARGET, which a target read
|
|
3756
|
+
// through a whole program (a constructor's `options` bag) cannot. A
|
|
3757
|
+
// literal held in an `any` position was handed to dynamic code as a
|
|
3758
|
+
// Document, and a typed read of it is a live view over those entries.
|
|
3759
|
+
const declared = new Set(keys);
|
|
3760
|
+
for (const root of admitted(value(expression)) ?? []) {
|
|
3761
|
+
if (!ts.isObjectLiteralExpression(root))
|
|
3762
|
+
continue;
|
|
3763
|
+
const contextual = checker.getContextualType(root);
|
|
3764
|
+
if (contextual !== undefined && (contextual.flags & ts.TypeFlags.Any) !== 0)
|
|
3765
|
+
continue;
|
|
3766
|
+
const owned = admitted(nodeQuery('own-keys', root));
|
|
3767
|
+
if (owned === null || owned.some((key) => !ts.isStringLiteral(key) || !declared.has(key.text)))
|
|
3768
|
+
return null;
|
|
3769
|
+
const writes = admitted(nodeQuery('closure', root));
|
|
3770
|
+
if (writes === null || writes.some((write) => ts.isCallExpression(write) && definitionPlans.has(write)))
|
|
3771
|
+
return null;
|
|
3772
|
+
}
|
|
3773
|
+
for (const key of keys)
|
|
3774
|
+
copied.add(key);
|
|
3775
|
+
const type = checker.getTypeAtLocation(expression);
|
|
3776
|
+
const nullable = (type.isUnion() ? type.types : [type]).some((one) => (one.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.Void)) !== 0);
|
|
3777
|
+
sources.push({ ordinal: index + 1, expression, nullable, roots: [], described: { keys } });
|
|
3778
|
+
}
|
|
3779
|
+
// A key a fresh literal target spells is its own data property when the
|
|
3780
|
+
// copy runs (no source can reach the literal first), so [[Set]] never
|
|
3781
|
+
// consults the prototype for it.
|
|
3782
|
+
const fresh = unwrapErasedExpression(bulk.target);
|
|
3783
|
+
const spelled = ts.isObjectLiteralExpression(fresh) ? (literalSpelledKeys(fresh) ?? []) : [];
|
|
3784
|
+
const missing = [...copied].filter((key) => !spelled.includes(key));
|
|
3785
|
+
if (!prototypeLacksCopiedKeys(missing, call))
|
|
3786
|
+
return null;
|
|
3787
|
+
return { call, targets: [], targetSlots: [], sources };
|
|
3788
|
+
};
|
|
3789
|
+
/** A source slot writes through [[Set]], not CreateDataProperty. A key
|
|
3790
|
+
* absent from the fresh target must also lack an inherited interceptor;
|
|
3791
|
+
* initial declaration absence alone does not prove the final prototype. */
|
|
3792
|
+
const prototypeLacksCopiedKeys = (missing, call) => {
|
|
3793
|
+
if (missing.length === 0)
|
|
3794
|
+
return true;
|
|
3795
|
+
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
3796
|
+
const absence = sourceObjectPrototypeAbsenceOf(checker, missing, call);
|
|
3797
|
+
return ledger !== null && absence !== null && ledger.include([absence]);
|
|
3798
|
+
};
|
|
3799
|
+
// The closed literal family is the stronger fact and is preferred; where
|
|
3800
|
+
// the session cannot close it, the operands' representations describe it.
|
|
3801
|
+
const ownAssignmentOf = (call, frames, describedKeysOf) => {
|
|
3802
|
+
const bulk = bulkAssignOf(call);
|
|
3803
|
+
if (bulk === null)
|
|
3804
|
+
return null;
|
|
3805
|
+
const closed = closedOwnAssignmentOf(call, bulk, frames);
|
|
3806
|
+
return closed !== undefined ? closed : describedOwnAssignmentOf(call, bulk, describedKeysOf);
|
|
3807
|
+
};
|
|
3808
|
+
/** `undefined` where no closed family describes the copy; `null` where a
|
|
3809
|
+
* specialized body copy cannot cite its own frames, which no description
|
|
3810
|
+
* repairs. */
|
|
3811
|
+
const closedOwnAssignmentOf = (call, bulk, frames) => {
|
|
3812
|
+
if (frames !== undefined) {
|
|
3813
|
+
const callers = callerSitesOf(frames.body);
|
|
3814
|
+
if (ts.findAncestor(call, ts.isFunctionLike) !== frames.body ||
|
|
3815
|
+
callers === null ||
|
|
3816
|
+
frames.callers.length === 0 ||
|
|
3817
|
+
new Set(frames.callers).size !== frames.callers.length ||
|
|
3818
|
+
frames.callers.some((caller) => !callers.includes(caller)))
|
|
3819
|
+
return null;
|
|
3820
|
+
}
|
|
3821
|
+
const frameValuesOf = (expression) => {
|
|
3822
|
+
if (frames === undefined)
|
|
3823
|
+
return admitted(value(expression));
|
|
3824
|
+
const values = new Set();
|
|
3825
|
+
for (const caller of frames.callers) {
|
|
3826
|
+
const held = admitted(frameQuery('frame-value', caller, frames.body, unwrapErasedExpression(expression)));
|
|
3827
|
+
if (held === null)
|
|
3828
|
+
return null;
|
|
3829
|
+
for (const value of held)
|
|
3830
|
+
values.add(value);
|
|
3831
|
+
}
|
|
3832
|
+
return [...values];
|
|
3833
|
+
};
|
|
3834
|
+
const plainDataRoot = (held) => ts.isObjectLiteralExpression(held) &&
|
|
3835
|
+
literalSpelledKeys(held) !== null &&
|
|
3836
|
+
held.properties.every((property) => ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property) || ts.isMethodDeclaration(property));
|
|
3837
|
+
const targets = frameValuesOf(bulk.target);
|
|
3838
|
+
if (targets === null || targets.length === 0 || !targets.every(plainDataRoot))
|
|
3839
|
+
return undefined;
|
|
3840
|
+
for (const root of targets)
|
|
3841
|
+
if (admitted(closure(root)) === null)
|
|
3842
|
+
return undefined;
|
|
3843
|
+
const sources = [];
|
|
3844
|
+
const copied = new Set();
|
|
3845
|
+
for (const [index, expression] of bulk.sources.entries()) {
|
|
3846
|
+
const values = frameValuesOf(expression);
|
|
3847
|
+
if (values === null || values.length === 0)
|
|
3848
|
+
return undefined;
|
|
3849
|
+
const roots = [];
|
|
3850
|
+
for (const root of values) {
|
|
3851
|
+
if (isNullish(root))
|
|
3852
|
+
continue;
|
|
3853
|
+
if (!plainDataRoot(root))
|
|
3854
|
+
return undefined;
|
|
3855
|
+
const keys = admitted(nodeQuery('own-keys', root));
|
|
3856
|
+
if (keys === null || keys.some((key) => !ts.isStringLiteral(key)))
|
|
3857
|
+
return undefined;
|
|
3858
|
+
const closure = admitted(nodeQuery('closure', root));
|
|
3859
|
+
if (closure === null)
|
|
3860
|
+
return undefined;
|
|
3861
|
+
const descriptorChanged = closure.some((write) => ts.isCallExpression(write) && definitionPlans.has(write));
|
|
3862
|
+
const deleted = new Set();
|
|
3863
|
+
for (const write of closure) {
|
|
3864
|
+
if ((!ts.isPropertyAccessExpression(write) && !ts.isElementAccessExpression(write)) ||
|
|
3865
|
+
writeEdgeByAccess.get(write)?.write.edge !== 'delete')
|
|
3866
|
+
continue;
|
|
3867
|
+
const key = accessKey(write);
|
|
3868
|
+
if (key !== null)
|
|
3869
|
+
deleted.add(key);
|
|
3870
|
+
else if (ts.isElementAccessExpression(write)) {
|
|
3871
|
+
const keys = admitted(value(write.argumentExpression));
|
|
3872
|
+
if (keys === null || keys.length === 0 || keys.some((key) => !ts.isStringLiteralLike(key) && !ts.isNumericLiteral(key)))
|
|
3873
|
+
return undefined;
|
|
3874
|
+
for (const key of keys)
|
|
3875
|
+
if (ts.isStringLiteralLike(key) || ts.isNumericLiteral(key))
|
|
3876
|
+
deleted.add(key.text);
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
const slots = [];
|
|
3880
|
+
for (const name of keys) {
|
|
3881
|
+
if (!ts.isStringLiteral(name))
|
|
3882
|
+
return undefined;
|
|
3883
|
+
const values = admitted(storedSlot(root, name.text));
|
|
3884
|
+
if (values === null || values.length === 0)
|
|
3885
|
+
return undefined;
|
|
3886
|
+
copied.add(name.text);
|
|
3887
|
+
// The finite key domain includes potential later additions. Only
|
|
3888
|
+
// an initial enumerable own data field whose descriptor is never
|
|
3889
|
+
// changed is an unavoidable contributor to every normal copy.
|
|
3890
|
+
slots.push({
|
|
3891
|
+
key: name.text,
|
|
3892
|
+
values,
|
|
3893
|
+
copyPresent: !descriptorChanged && !deleted.has(name.text) && literalSpelledKeys(root).includes(name.text)
|
|
3894
|
+
});
|
|
3895
|
+
}
|
|
3896
|
+
roots.push({ root, slots });
|
|
3897
|
+
}
|
|
3898
|
+
sources.push({ ordinal: index + 1, expression, nullable: values.some(isNullish), roots });
|
|
3899
|
+
}
|
|
3900
|
+
const targetSlots = [];
|
|
3901
|
+
for (const root of targets) {
|
|
3902
|
+
const keys = admitted(nodeQuery('own-keys', root));
|
|
3903
|
+
if (keys === null)
|
|
3904
|
+
return undefined;
|
|
3905
|
+
const slots = [];
|
|
3906
|
+
for (const key of keys) {
|
|
3907
|
+
if (!ts.isStringLiteral(key))
|
|
3908
|
+
return undefined;
|
|
3909
|
+
const values = admitted(storedSlot(root, key.text));
|
|
3910
|
+
if (values === null || values.length === 0)
|
|
3911
|
+
return undefined;
|
|
3912
|
+
slots.push({ key: key.text, values });
|
|
3913
|
+
}
|
|
3914
|
+
targetSlots.push({ root, slots });
|
|
3915
|
+
}
|
|
3916
|
+
const missing = [...copied].filter((key) => targets.some((target) => !literalSpelledKeys(target).includes(key)));
|
|
3917
|
+
if (!prototypeLacksCopiedKeys(missing, call))
|
|
3918
|
+
return undefined;
|
|
3919
|
+
return { call, targets, targetSlots, sources };
|
|
3920
|
+
};
|
|
3012
3921
|
return {
|
|
3922
|
+
candidateOrdinaryOwnCallableOperandsOf,
|
|
3923
|
+
ordinaryOwnCallableOperandsOf,
|
|
3924
|
+
ordinaryOwnCallableSourceOf: (call) => {
|
|
3925
|
+
const candidate = candidateOrdinaryOwnCallableOperandsOf(call);
|
|
3926
|
+
const site = sites.get(call);
|
|
3927
|
+
if (candidate === null && (!site || site.operands.explicitThis || ownCallableReadOf(site.operands.callee) === null))
|
|
3928
|
+
return null;
|
|
3929
|
+
const found = admitted(targets(call));
|
|
3930
|
+
return found !== null && found.length === 1 && isSourceCallableObject(found[0]) ? found[0] : null;
|
|
3931
|
+
},
|
|
3013
3932
|
ownsInvocation: (call) => {
|
|
3933
|
+
if (candidateOrdinaryOwnCallableOperandsOf(call) !== null)
|
|
3934
|
+
return true;
|
|
3014
3935
|
const site = sites.get(call);
|
|
3936
|
+
if (site && !site.operands.explicitThis && ownCallableReadOf(site.operands.callee) !== null)
|
|
3937
|
+
return true;
|
|
3015
3938
|
// Wrapper integrity and lexical-super lookup are separate dispatch
|
|
3016
3939
|
// domains still owned by the existing invocation authority. Partition
|
|
3017
3940
|
// before solving; failure within the ordinary-member domain is final.
|
|
@@ -3020,6 +3943,8 @@ const createSession = (checker, flow) => {
|
|
|
3020
3943
|
const callee = site.operands.callee;
|
|
3021
3944
|
if (!callee || (!ts.isPropertyAccessExpression(callee) && !ts.isElementAccessExpression(callee)))
|
|
3022
3945
|
return false;
|
|
3946
|
+
if (sourceIntrinsicMemberMayBeWrittenOf(checker, flow, callee))
|
|
3947
|
+
return true;
|
|
3023
3948
|
const symbol = flow.targetOf(callee)?.nameSymbol ?? flow.targetOf(callee)?.symbol;
|
|
3024
3949
|
const declarations = symbol?.declarations;
|
|
3025
3950
|
if (!declarations?.length)
|
|
@@ -3036,7 +3961,7 @@ const createSession = (checker, flow) => {
|
|
|
3036
3961
|
// graph owns these now; narrowing the whole `isSourceInstanceMethod`
|
|
3037
3962
|
// widening back to the legacy resolver took literal-method-receiver
|
|
3038
3963
|
// from 2/3 to 1/3 -- the legacy authority never counted
|
|
3039
|
-
// `
|
|
3964
|
+
// `registry.define( ... )` on a literal returned by a factory.
|
|
3040
3965
|
if (declarations.every(isObjectLiteralCallableEntry))
|
|
3041
3966
|
return true;
|
|
3042
3967
|
// Ordinary CLASS methods stay with the legacy authority (§5's
|
|
@@ -3076,16 +4001,16 @@ const createSession = (checker, flow) => {
|
|
|
3076
4001
|
// bound only through sibling class-method calls loses its type.
|
|
3077
4002
|
// - `arguments-frame-member-closure.test.ts` (1/2 fail): a receiver
|
|
3078
4003
|
// forwarded through `arguments[ i ]` inside a recursive self-call
|
|
3079
|
-
// (
|
|
4004
|
+
// (a `Node.add` multi-child form) is not a shape the
|
|
3080
4005
|
// graph's `targets`/`value` queries resolve yet, so the whole
|
|
3081
4006
|
// family closure opens with
|
|
3082
4007
|
// `function-escapes:uncounted-member-reference`. This is the
|
|
3083
|
-
// single largest leaf-refusal shape measured on
|
|
3084
|
-
// (`measurements/leaf-refusals.log
|
|
4008
|
+
// single largest leaf-refusal shape measured on a large JS program
|
|
4009
|
+
// (`measurements/leaf-refusals.log`): a receiver
|
|
3085
4010
|
// forwarded through a call argument is not followed -- see §7
|
|
3086
4011
|
// item 0's `uncounted-member-reference` breakdown.
|
|
3087
|
-
// - `computed-key-set.test.ts` (1/10 fail,
|
|
3088
|
-
//
|
|
4012
|
+
// - `computed-key-set.test.ts` (1/10 fail, the reduced `setValues`
|
|
4013
|
+
// case): the refusal reason regresses from the precise
|
|
3089
4014
|
// `origin-computed-write` to the earlier, coarser
|
|
3090
4015
|
// `object-origin-open-parameter` -- the graph trips a less
|
|
3091
4016
|
// specific refusal before it reaches the computed-write site.
|
|
@@ -3100,7 +4025,36 @@ const createSession = (checker, flow) => {
|
|
|
3100
4025
|
},
|
|
3101
4026
|
invocationTargetsOf,
|
|
3102
4027
|
valuesOf: (expression) => admitted(value(expression)),
|
|
4028
|
+
closedValuesOf: (expression) => {
|
|
4029
|
+
const roots = admitted(value(expression));
|
|
4030
|
+
if (roots === null || roots.length === 0)
|
|
4031
|
+
return null;
|
|
4032
|
+
for (const root of roots)
|
|
4033
|
+
if (admitted(closure(root)) === null)
|
|
4034
|
+
return null;
|
|
4035
|
+
return roots;
|
|
4036
|
+
},
|
|
4037
|
+
callerSitesOf,
|
|
4038
|
+
ownAssignmentOf,
|
|
4039
|
+
ownSlotOf,
|
|
4040
|
+
memberValuesOf: (expression, key) => {
|
|
4041
|
+
const roots = admitted(value(expression));
|
|
4042
|
+
if (roots === null || roots.length === 0 || roots.some((root) => !isObjectRoot(root)))
|
|
4043
|
+
return null;
|
|
4044
|
+
const members = new Set();
|
|
4045
|
+
for (const root of roots) {
|
|
4046
|
+
if (!isObjectRoot(root))
|
|
4047
|
+
return null;
|
|
4048
|
+
const stored = admitted(slot(root, key));
|
|
4049
|
+
if (stored === null)
|
|
4050
|
+
return null;
|
|
4051
|
+
for (const member of stored)
|
|
4052
|
+
members.add(member);
|
|
4053
|
+
}
|
|
4054
|
+
return [...members];
|
|
4055
|
+
},
|
|
3103
4056
|
parameterValuesOf: (parameter) => admitted(nodeQuery('parameter', parameter)),
|
|
4057
|
+
parameterSourceExpressionsOf,
|
|
3104
4058
|
explainParameter: (parameter) => solve(nodeQuery('parameter', parameter)).explain(),
|
|
3105
4059
|
explainInvocation: (call) => solve(targets(call)).explain(),
|
|
3106
4060
|
explainValue: (expression) => solve(value(expression)).explain()
|