@geastack/compiler 1.0.15
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/LICENSE +202 -0
- package/README.md +149 -0
- package/dist/cli-analyze.d.ts +1 -0
- package/dist/cli-analyze.js +61 -0
- package/dist/cli-coverage.d.ts +1 -0
- package/dist/cli-coverage.js +329 -0
- package/dist/cli-emit.d.ts +10 -0
- package/dist/cli-emit.js +398 -0
- package/dist/cli-module-graph.d.ts +18 -0
- package/dist/cli-module-graph.js +123 -0
- package/dist/cli-package-source.d.ts +5 -0
- package/dist/cli-package-source.js +116 -0
- package/dist/cli-project.d.ts +2 -0
- package/dist/cli-project.js +60 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +199 -0
- package/dist/compiler.d.ts +228 -0
- package/dist/compiler.js +1029 -0
- package/dist/conversion/algebra.d.ts +218 -0
- package/dist/conversion/algebra.js +155 -0
- package/dist/conversion/build.d.ts +67 -0
- package/dist/conversion/build.js +1378 -0
- package/dist/conversion/derive.d.ts +37 -0
- package/dist/conversion/derive.js +260 -0
- package/dist/conversion/graph-validation.d.ts +8 -0
- package/dist/conversion/graph-validation.js +97 -0
- package/dist/conversion/native-callable-adapter.d.ts +13 -0
- package/dist/conversion/native-callable-adapter.js +53 -0
- package/dist/conversion/native-class-reference.d.ts +12 -0
- package/dist/conversion/native-class-reference.js +39 -0
- package/dist/conversion/native-payload-transport.d.ts +25 -0
- package/dist/conversion/native-payload-transport.js +33 -0
- package/dist/conversion/native-selection.d.ts +49 -0
- package/dist/conversion/native-selection.js +135 -0
- package/dist/conversion/native-sum.d.ts +42 -0
- package/dist/conversion/native-sum.js +115 -0
- package/dist/conversion/nodes.d.ts +55 -0
- package/dist/conversion/nodes.js +91 -0
- package/dist/conversion/operand-view.d.ts +14 -0
- package/dist/conversion/operand-view.js +20 -0
- package/dist/conversion/record-view.d.ts +157 -0
- package/dist/conversion/record-view.js +273 -0
- package/dist/conversion/registry.d.ts +217 -0
- package/dist/conversion/registry.js +1 -0
- package/dist/diagnostics/model.d.ts +76 -0
- package/dist/diagnostics/model.js +60 -0
- package/dist/diagnostics/sweep.d.ts +31 -0
- package/dist/diagnostics/sweep.js +112 -0
- package/dist/identity/ids.d.ts +179 -0
- package/dist/identity/ids.js +212 -0
- package/dist/ir/absent-class-arm.d.ts +48 -0
- package/dist/ir/absent-class-arm.js +157 -0
- package/dist/ir/borrow-effects.d.ts +23 -0
- package/dist/ir/borrow-effects.js +151 -0
- package/dist/ir/borrowed-call-arguments.d.ts +40 -0
- package/dist/ir/borrowed-call-arguments.js +117 -0
- package/dist/ir/build.d.ts +168 -0
- package/dist/ir/build.js +459 -0
- package/dist/ir/call-dispatch.d.ts +38 -0
- package/dist/ir/call-dispatch.js +502 -0
- package/dist/ir/call-entry.d.ts +142 -0
- package/dist/ir/call-entry.js +386 -0
- package/dist/ir/callable-class-flow.d.ts +27 -0
- package/dist/ir/callable-class-flow.js +1386 -0
- package/dist/ir/callable-field-slots.d.ts +22 -0
- package/dist/ir/callable-field-slots.js +166 -0
- package/dist/ir/callable-identity-demand.d.ts +52 -0
- package/dist/ir/callable-identity-demand.js +460 -0
- package/dist/ir/callable-member-candidates.d.ts +9 -0
- package/dist/ir/callable-member-candidates.js +39 -0
- package/dist/ir/callable-records.d.ts +21 -0
- package/dist/ir/callable-records.js +411 -0
- package/dist/ir/captures.d.ts +26 -0
- package/dist/ir/captures.js +335 -0
- package/dist/ir/certificate.d.ts +45 -0
- package/dist/ir/certificate.js +47 -0
- package/dist/ir/certify/carrier-keys.d.ts +73 -0
- package/dist/ir/certify/carrier-keys.js +221 -0
- package/dist/ir/certify/function-source.d.ts +4 -0
- package/dist/ir/certify/function-source.js +28 -0
- package/dist/ir/certify/has-property-key.d.ts +88 -0
- package/dist/ir/certify/has-property-key.js +116 -0
- package/dist/ir/certify/instanceof-key.d.ts +24 -0
- package/dist/ir/certify/instanceof-key.js +35 -0
- package/dist/ir/certify/property-access-keys.d.ts +172 -0
- package/dist/ir/certify/property-access-keys.js +291 -0
- package/dist/ir/certify/property-access.d.ts +3 -0
- package/dist/ir/certify/property-access.js +597 -0
- package/dist/ir/certify/runtime-helper.d.ts +3 -0
- package/dist/ir/certify/runtime-helper.js +326 -0
- package/dist/ir/certify/typeof-operand.d.ts +14 -0
- package/dist/ir/certify/typeof-operand.js +16 -0
- package/dist/ir/certify.d.ts +123 -0
- package/dist/ir/certify.js +481 -0
- package/dist/ir/class-evaluation.d.ts +26 -0
- package/dist/ir/class-evaluation.js +50 -0
- package/dist/ir/class-static-fields.d.ts +60 -0
- package/dist/ir/class-static-fields.js +108 -0
- package/dist/ir/construct-entry.d.ts +26 -0
- package/dist/ir/construct-entry.js +117 -0
- package/dist/ir/dead-values.d.ts +90 -0
- package/dist/ir/dead-values.js +184 -0
- package/dist/ir/deferral.d.ts +99 -0
- package/dist/ir/deferral.js +409 -0
- package/dist/ir/dense-loops.d.ts +230 -0
- package/dist/ir/dense-loops.js +697 -0
- package/dist/ir/dominance.d.ts +82 -0
- package/dist/ir/dominance.js +268 -0
- package/dist/ir/emission-representations.d.ts +71 -0
- package/dist/ir/emission-representations.js +350 -0
- package/dist/ir/facts.d.ts +218 -0
- package/dist/ir/facts.js +181 -0
- package/dist/ir/fixed-data-definition.d.ts +19 -0
- package/dist/ir/fixed-data-definition.js +49 -0
- package/dist/ir/generator-split.d.ts +38 -0
- package/dist/ir/generator-split.js +329 -0
- package/dist/ir/hoist.d.ts +55 -0
- package/dist/ir/hoist.js +375 -0
- package/dist/ir/instantiation.d.ts +61 -0
- package/dist/ir/instantiation.js +137 -0
- package/dist/ir/integer-storage.d.ts +170 -0
- package/dist/ir/integer-storage.js +822 -0
- package/dist/ir/integers.d.ts +161 -0
- package/dist/ir/integers.js +539 -0
- package/dist/ir/integrity-restrictions.d.ts +50 -0
- package/dist/ir/integrity-restrictions.js +118 -0
- package/dist/ir/local-iterators.d.ts +4 -0
- package/dist/ir/local-iterators.js +27 -0
- package/dist/ir/lower-allocation.d.ts +4 -0
- package/dist/ir/lower-allocation.js +325 -0
- package/dist/ir/lower-completion.d.ts +15 -0
- package/dist/ir/lower-completion.js +25 -0
- package/dist/ir/lower-destructuring.d.ts +5 -0
- package/dist/ir/lower-destructuring.js +693 -0
- package/dist/ir/lower-element.d.ts +29 -0
- package/dist/ir/lower-element.js +111 -0
- package/dist/ir/lower-exceptions.d.ts +47 -0
- package/dist/ir/lower-exceptions.js +92 -0
- package/dist/ir/lower-flow.d.ts +137 -0
- package/dist/ir/lower-flow.js +600 -0
- package/dist/ir/lower-graph.d.ts +218 -0
- package/dist/ir/lower-graph.js +687 -0
- package/dist/ir/lower-invocation.d.ts +4 -0
- package/dist/ir/lower-invocation.js +514 -0
- package/dist/ir/lower-narrow.d.ts +53 -0
- package/dist/ir/lower-narrow.js +320 -0
- package/dist/ir/lower-operands.d.ts +272 -0
- package/dist/ir/lower-operands.js +461 -0
- package/dist/ir/lower-property.d.ts +21 -0
- package/dist/ir/lower-property.js +132 -0
- package/dist/ir/lower-protocol.d.ts +11 -0
- package/dist/ir/lower-protocol.js +118 -0
- package/dist/ir/lower-short-circuit.d.ts +41 -0
- package/dist/ir/lower-short-circuit.js +63 -0
- package/dist/ir/lower.d.ts +82 -0
- package/dist/ir/lower.js +1346 -0
- package/dist/ir/model.d.ts +1474 -0
- package/dist/ir/model.js +6 -0
- package/dist/ir/native-absent-property.d.ts +3 -0
- package/dist/ir/native-absent-property.js +13 -0
- package/dist/ir/native-array-transport.d.ts +7 -0
- package/dist/ir/native-array-transport.js +46 -0
- package/dist/ir/native-callable-bind.d.ts +9 -0
- package/dist/ir/native-callable-bind.js +30 -0
- package/dist/ir/native-carrier-predicate.d.ts +34 -0
- package/dist/ir/native-carrier-predicate.js +49 -0
- package/dist/ir/native-class-accessor.d.ts +18 -0
- package/dist/ir/native-class-accessor.js +52 -0
- package/dist/ir/native-class-construction.d.ts +16 -0
- package/dist/ir/native-class-construction.js +71 -0
- package/dist/ir/native-class-initialization.d.ts +15 -0
- package/dist/ir/native-class-initialization.js +56 -0
- package/dist/ir/native-class-origins.d.ts +13 -0
- package/dist/ir/native-class-origins.js +237 -0
- package/dist/ir/native-dictionary-transport.d.ts +6 -0
- package/dist/ir/native-dictionary-transport.js +37 -0
- package/dist/ir/native-enumeration.d.ts +14 -0
- package/dist/ir/native-enumeration.js +26 -0
- package/dist/ir/native-equality.d.ts +10 -0
- package/dist/ir/native-equality.js +18 -0
- package/dist/ir/native-field-owner.d.ts +37 -0
- package/dist/ir/native-field-owner.js +183 -0
- package/dist/ir/native-fixed-layout.d.ts +41 -0
- package/dist/ir/native-fixed-layout.js +232 -0
- package/dist/ir/native-host-construction.d.ts +53 -0
- package/dist/ir/native-host-construction.js +62 -0
- package/dist/ir/native-key-query.d.ts +4 -0
- package/dist/ir/native-key-query.js +38 -0
- package/dist/ir/native-merge-transport.d.ts +25 -0
- package/dist/ir/native-merge-transport.js +71 -0
- package/dist/ir/native-record-index-transport.d.ts +11 -0
- package/dist/ir/native-record-index-transport.js +34 -0
- package/dist/ir/native-record-index.d.ts +12 -0
- package/dist/ir/native-record-index.js +27 -0
- package/dist/ir/native-reflect-field.d.ts +5 -0
- package/dist/ir/native-reflect-field.js +33 -0
- package/dist/ir/native-sequence-transport.d.ts +7 -0
- package/dist/ir/native-sequence-transport.js +53 -0
- package/dist/ir/numeric-intrinsics.d.ts +13 -0
- package/dist/ir/numeric-intrinsics.js +57 -0
- package/dist/ir/object-value-conversions.d.ts +20 -0
- package/dist/ir/object-value-conversions.js +50 -0
- package/dist/ir/physical-class-reflection.d.ts +9 -0
- package/dist/ir/physical-class-reflection.js +57 -0
- package/dist/ir/presence-proof.d.ts +42 -0
- package/dist/ir/presence-proof.js +490 -0
- package/dist/ir/program-facts.d.ts +106 -0
- package/dist/ir/program-facts.js +319 -0
- package/dist/ir/proven-branches.d.ts +16 -0
- package/dist/ir/proven-branches.js +219 -0
- package/dist/ir/queries.d.ts +41 -0
- package/dist/ir/queries.js +213 -0
- package/dist/ir/reflection-demand.d.ts +64 -0
- package/dist/ir/reflection-demand.js +1394 -0
- package/dist/ir/refusal.d.ts +43 -0
- package/dist/ir/refusal.js +28 -0
- package/dist/ir/shake.d.ts +37 -0
- package/dist/ir/shake.js +1078 -0
- package/dist/ir/static-callables.d.ts +11 -0
- package/dist/ir/static-callables.js +163 -0
- package/dist/ir/string-layout-reuse.d.ts +13 -0
- package/dist/ir/string-layout-reuse.js +39 -0
- package/dist/ir/string-length-reuse.d.ts +8 -0
- package/dist/ir/string-length-reuse.js +47 -0
- package/dist/ir/transfer.d.ts +78 -0
- package/dist/ir/transfer.js +270 -0
- package/dist/ir/type-query-results.d.ts +25 -0
- package/dist/ir/type-query-results.js +96 -0
- package/dist/ir/typed-property-access.d.ts +100 -0
- package/dist/ir/typed-property-access.js +161 -0
- package/dist/ir/verify.d.ts +19 -0
- package/dist/ir/verify.js +355 -0
- package/dist/plugins/apple/constructors.d.ts +112 -0
- package/dist/plugins/apple/constructors.js +217 -0
- package/dist/plugins/apple/host.d.ts +181 -0
- package/dist/plugins/apple/host.js +262 -0
- package/dist/plugins/apple/jsx.d.ts +2 -0
- package/dist/plugins/apple/jsx.js +293 -0
- package/dist/plugins/apple/members.d.ts +16 -0
- package/dist/plugins/apple/members.js +190 -0
- package/dist/plugins/apple/plugin.d.ts +2 -0
- package/dist/plugins/apple/plugin.js +156 -0
- package/dist/plugins/gea/component-classes.d.ts +25 -0
- package/dist/plugins/gea/component-classes.js +162 -0
- package/dist/plugins/gea/component-inline.d.ts +13 -0
- package/dist/plugins/gea/component-inline.js +532 -0
- package/dist/plugins/gea/constructors.d.ts +23 -0
- package/dist/plugins/gea/constructors.js +100 -0
- package/dist/plugins/gea/contract.d.ts +150 -0
- package/dist/plugins/gea/contract.js +195 -0
- package/dist/plugins/gea/element-ref.d.ts +31 -0
- package/dist/plugins/gea/element-ref.js +45 -0
- package/dist/plugins/gea/host.d.ts +520 -0
- package/dist/plugins/gea/host.js +762 -0
- package/dist/plugins/gea/lower.d.ts +6 -0
- package/dist/plugins/gea/lower.js +195 -0
- package/dist/plugins/gea/members.d.ts +22 -0
- package/dist/plugins/gea/members.js +221 -0
- package/dist/plugins/gea/plugin.d.ts +22 -0
- package/dist/plugins/gea/plugin.js +307 -0
- package/dist/plugins/gea/prelude.d.ts +78 -0
- package/dist/plugins/gea/prelude.js +153 -0
- package/dist/plugins/gea/producer.d.ts +5 -0
- package/dist/plugins/gea/producer.js +52 -0
- package/dist/plugins/gea/reactive-slots.d.ts +49 -0
- package/dist/plugins/gea/reactive-slots.js +578 -0
- package/dist/plugins/gea/render-bridge.d.ts +6 -0
- package/dist/plugins/gea/render-bridge.js +281 -0
- package/dist/plugins/gea/slots.d.ts +15 -0
- package/dist/plugins/gea/slots.js +36 -0
- package/dist/plugins/gea/template-analysis.d.ts +151 -0
- package/dist/plugins/gea/template-analysis.js +346 -0
- package/dist/plugins/gea/user-agent-styles.d.ts +9 -0
- package/dist/plugins/gea/user-agent-styles.js +94 -0
- package/dist/plugins/installed.d.ts +19 -0
- package/dist/plugins/installed.js +21 -0
- package/dist/plugins/load.d.ts +7 -0
- package/dist/plugins/load.js +207 -0
- package/dist/plugins/model.d.ts +735 -0
- package/dist/plugins/model.js +47 -0
- package/dist/plugins/webgl/host.d.ts +77 -0
- package/dist/plugins/webgl/host.js +162 -0
- package/dist/plugins/webgl/plugin.d.ts +40 -0
- package/dist/plugins/webgl/plugin.js +99 -0
- package/dist/preflight/obligations.d.ts +206 -0
- package/dist/preflight/obligations.js +36 -0
- package/dist/preflight/report.d.ts +20 -0
- package/dist/preflight/report.js +61 -0
- package/dist/preflight/run.d.ts +39 -0
- package/dist/preflight/run.js +403 -0
- package/dist/project-preparation.d.ts +33 -0
- package/dist/project-preparation.js +314 -0
- package/dist/projection/abi.d.ts +82 -0
- package/dist/projection/abi.js +349 -0
- package/dist/projection/apply-arguments.d.ts +12 -0
- package/dist/projection/apply-arguments.js +20 -0
- package/dist/projection/bindings.d.ts +250 -0
- package/dist/projection/bindings.js +340 -0
- package/dist/projection/callee.d.ts +196 -0
- package/dist/projection/callee.js +444 -0
- package/dist/projection/class-property-presence.d.ts +28 -0
- package/dist/projection/class-property-presence.js +58 -0
- package/dist/projection/class-prototype.d.ts +5 -0
- package/dist/projection/class-prototype.js +23 -0
- package/dist/projection/class-storage.d.ts +26 -0
- package/dist/projection/class-storage.js +236 -0
- package/dist/projection/classes.d.ts +283 -0
- package/dist/projection/classes.js +944 -0
- package/dist/projection/coercions.d.ts +20 -0
- package/dist/projection/coercions.js +33 -0
- package/dist/projection/dispatch.d.ts +167 -0
- package/dist/projection/dispatch.js +379 -0
- package/dist/projection/fields.d.ts +123 -0
- package/dist/projection/fields.js +383 -0
- package/dist/projection/instance-test.d.ts +78 -0
- package/dist/projection/instance-test.js +156 -0
- package/dist/projection/slots.d.ts +146 -0
- package/dist/projection/slots.js +663 -0
- package/dist/projection/synthesized-abi.d.ts +61 -0
- package/dist/projection/synthesized-abi.js +94 -0
- package/dist/representation/array-index.d.ts +14 -0
- package/dist/representation/array-index.js +17 -0
- package/dist/representation/callable-object.d.ts +3 -0
- package/dist/representation/callable-object.js +6 -0
- package/dist/representation/collections.d.ts +84 -0
- package/dist/representation/collections.js +139 -0
- package/dist/representation/derive.d.ts +159 -0
- package/dist/representation/derive.js +2546 -0
- package/dist/representation/difference.d.ts +30 -0
- package/dist/representation/difference.js +240 -0
- package/dist/representation/field-descriptor-policy.d.ts +19 -0
- package/dist/representation/field-descriptor-policy.js +39 -0
- package/dist/representation/function-constructor.d.ts +13 -0
- package/dist/representation/function-constructor.js +9 -0
- package/dist/representation/host-abi.d.ts +32 -0
- package/dist/representation/host-abi.js +97 -0
- package/dist/representation/host-templates.d.ts +67 -0
- package/dist/representation/host-templates.js +94 -0
- package/dist/representation/intersection.d.ts +84 -0
- package/dist/representation/intersection.js +149 -0
- package/dist/representation/literal-destination.d.ts +43 -0
- package/dist/representation/literal-destination.js +133 -0
- package/dist/representation/merge.d.ts +18 -0
- package/dist/representation/merge.js +83 -0
- package/dist/representation/model.d.ts +1160 -0
- package/dist/representation/model.js +1019 -0
- package/dist/representation/numeric-index.d.ts +13 -0
- package/dist/representation/numeric-index.js +29 -0
- package/dist/representation/object-shape.d.ts +109 -0
- package/dist/representation/object-shape.js +123 -0
- package/dist/representation/optional.d.ts +12 -0
- package/dist/representation/optional.js +87 -0
- package/dist/representation/plan.d.ts +60 -0
- package/dist/representation/plan.js +78 -0
- package/dist/representation/policies.d.ts +589 -0
- package/dist/representation/policies.js +107 -0
- package/dist/representation/primitive-domain.d.ts +1 -0
- package/dist/representation/primitive-domain.js +1 -0
- package/dist/representation/primitives.d.ts +44 -0
- package/dist/representation/primitives.js +78 -0
- package/dist/representation/publish.d.ts +49 -0
- package/dist/representation/publish.js +648 -0
- package/dist/representation/record-fields.d.ts +96 -0
- package/dist/representation/record-fields.js +116 -0
- package/dist/representation/template-object.d.ts +11 -0
- package/dist/representation/template-object.js +26 -0
- package/dist/representation/union.d.ts +30 -0
- package/dist/representation/union.js +324 -0
- package/dist/representation/value-records.d.ts +3 -0
- package/dist/representation/value-records.js +307 -0
- package/dist/representation/verify.d.ts +17 -0
- package/dist/representation/verify.js +221 -0
- package/dist/semantics/alias-this-field-declaration-transform.d.ts +4 -0
- package/dist/semantics/alias-this-field-declaration-transform.js +207 -0
- package/dist/semantics/ambient-type-realization-transform.d.ts +62 -0
- package/dist/semantics/ambient-type-realization-transform.js +168 -0
- package/dist/semantics/ambient.d.ts +24 -0
- package/dist/semantics/ambient.js +119 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +4 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +341 -0
- package/dist/semantics/callable-origins.d.ts +46 -0
- package/dist/semantics/callable-origins.js +354 -0
- package/dist/semantics/class-alias.d.ts +7 -0
- package/dist/semantics/class-alias.js +37 -0
- package/dist/semantics/class-heritage.d.ts +34 -0
- package/dist/semantics/class-heritage.js +104 -0
- package/dist/semantics/commonjs-wrapper.d.ts +69 -0
- package/dist/semantics/commonjs-wrapper.js +231 -0
- package/dist/semantics/constructor-slot-subclasses.d.ts +28 -0
- package/dist/semantics/constructor-slot-subclasses.js +112 -0
- package/dist/semantics/declaration-overlay-transform.d.ts +35 -0
- package/dist/semantics/declaration-overlay-transform.js +2157 -0
- package/dist/semantics/define-property-source-transform.d.ts +4 -0
- package/dist/semantics/define-property-source-transform.js +437 -0
- package/dist/semantics/diagnostic-source-preparation.d.ts +24 -0
- package/dist/semantics/diagnostic-source-preparation.js +82 -0
- package/dist/semantics/documentation-ranges.d.ts +22 -0
- package/dist/semantics/documentation-ranges.js +36 -0
- package/dist/semantics/dynamic-fallback.d.ts +86 -0
- package/dist/semantics/dynamic-fallback.js +249 -0
- package/dist/semantics/frontend-timing.d.ts +6 -0
- package/dist/semantics/frontend-timing.js +35 -0
- package/dist/semantics/frontend.d.ts +504 -0
- package/dist/semantics/frontend.js +1157 -0
- package/dist/semantics/host-declaration-provenance.d.ts +11 -0
- package/dist/semantics/host-declaration-provenance.js +18 -0
- package/dist/semantics/host-methods.d.ts +24 -0
- package/dist/semantics/host-methods.js +74 -0
- package/dist/semantics/host-protocols.d.ts +429 -0
- package/dist/semantics/host-protocols.js +1501 -0
- package/dist/semantics/inherited-accessor.d.ts +7 -0
- package/dist/semantics/inherited-accessor.js +48 -0
- package/dist/semantics/interface-families.d.ts +70 -0
- package/dist/semantics/interface-families.js +180 -0
- package/dist/semantics/interface-implementors.d.ts +53 -0
- package/dist/semantics/interface-implementors.js +87 -0
- package/dist/semantics/jsdoc-namepath-transform.d.ts +4 -0
- package/dist/semantics/jsdoc-namepath-transform.js +85 -0
- package/dist/semantics/model/coverage.d.ts +68 -0
- package/dist/semantics/model/coverage.js +73 -0
- package/dist/semantics/model/edges.d.ts +103 -0
- package/dist/semantics/model/edges.js +20 -0
- package/dist/semantics/model/graph.d.ts +55 -0
- package/dist/semantics/model/graph.js +129 -0
- package/dist/semantics/model/operands.d.ts +159 -0
- package/dist/semantics/model/operands.js +26 -0
- package/dist/semantics/model/operations.d.ts +496 -0
- package/dist/semantics/model/operations.js +2 -0
- package/dist/semantics/model/primitive-domain.d.ts +26 -0
- package/dist/semantics/model/primitive-domain.js +38 -0
- package/dist/semantics/model/selected-signature.d.ts +261 -0
- package/dist/semantics/model/selected-signature.js +55 -0
- package/dist/semantics/model/structural-type-table.d.ts +93 -0
- package/dist/semantics/model/structural-type-table.js +237 -0
- package/dist/semantics/model/structural-types.d.ts +367 -0
- package/dist/semantics/model/structural-types.js +200 -0
- package/dist/semantics/module-resolution.d.ts +23 -0
- package/dist/semantics/module-resolution.js +227 -0
- package/dist/semantics/new-callee-class-tag-source-transform.d.ts +4 -0
- package/dist/semantics/new-callee-class-tag-source-transform.js +64 -0
- package/dist/semantics/node-project.d.ts +13 -0
- package/dist/semantics/node-project.js +107 -0
- package/dist/semantics/node-source-hooks.d.ts +1 -0
- package/dist/semantics/node-source-hooks.js +63 -0
- package/dist/semantics/normalize/absent-globals.d.ts +143 -0
- package/dist/semantics/normalize/absent-globals.js +191 -0
- package/dist/semantics/normalize/arguments-objects.d.ts +43 -0
- package/dist/semantics/normalize/arguments-objects.js +60 -0
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +28 -0
- package/dist/semantics/normalize/asserted-arm-absence.js +61 -0
- package/dist/semantics/normalize/assignment-patterns.d.ts +70 -0
- package/dist/semantics/normalize/assignment-patterns.js +147 -0
- package/dist/semantics/normalize/bag-absence.d.ts +8 -0
- package/dist/semantics/normalize/bag-absence.js +42 -0
- package/dist/semantics/normalize/binding-fixpoint.d.ts +36 -0
- package/dist/semantics/normalize/binding-fixpoint.js +140 -0
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +16 -0
- package/dist/semantics/normalize/callback-parameter-contracts.js +91 -0
- package/dist/semantics/normalize/cells/agreement.d.ts +46 -0
- package/dist/semantics/normalize/cells/agreement.js +34 -0
- package/dist/semantics/normalize/cells/candidates.d.ts +17 -0
- package/dist/semantics/normalize/cells/candidates.js +35 -0
- package/dist/semantics/normalize/cells/facts.d.ts +19 -0
- package/dist/semantics/normalize/cells/facts.js +90 -0
- package/dist/semantics/normalize/cells/index.d.ts +10 -0
- package/dist/semantics/normalize/cells/index.js +6 -0
- package/dist/semantics/normalize/cells/model.d.ts +98 -0
- package/dist/semantics/normalize/cells/model.js +2 -0
- package/dist/semantics/normalize/cells/policies/bag.d.ts +44 -0
- package/dist/semantics/normalize/cells/policies/bag.js +114 -0
- package/dist/semantics/normalize/cells/policies/collection.d.ts +42 -0
- package/dist/semantics/normalize/cells/policies/collection.js +218 -0
- package/dist/semantics/normalize/cells/policies/field.d.ts +28 -0
- package/dist/semantics/normalize/cells/policies/field.js +40 -0
- package/dist/semantics/normalize/cells/policies/index.d.ts +49 -0
- package/dist/semantics/normalize/cells/policies/index.js +58 -0
- package/dist/semantics/normalize/cells/policies/local.d.ts +18 -0
- package/dist/semantics/normalize/cells/policies/local.js +37 -0
- package/dist/semantics/normalize/cells/policies/parameter.d.ts +28 -0
- package/dist/semantics/normalize/cells/policies/parameter.js +39 -0
- package/dist/semantics/normalize/cells/policies/return.d.ts +26 -0
- package/dist/semantics/normalize/cells/policies/return.js +45 -0
- package/dist/semantics/normalize/cells/policies/shared.d.ts +33 -0
- package/dist/semantics/normalize/cells/policies/shared.js +45 -0
- package/dist/semantics/normalize/cells/policy.d.ts +72 -0
- package/dist/semantics/normalize/cells/policy.js +18 -0
- package/dist/semantics/normalize/cells/registry.d.ts +14 -0
- package/dist/semantics/normalize/cells/registry.js +17 -0
- package/dist/semantics/normalize/census-refusal.d.ts +62 -0
- package/dist/semantics/normalize/census-refusal.js +27 -0
- package/dist/semantics/normalize/census.d.ts +109 -0
- package/dist/semantics/normalize/census.js +667 -0
- package/dist/semantics/normalize/collection-bindings.d.ts +278 -0
- package/dist/semantics/normalize/collection-bindings.js +677 -0
- package/dist/semantics/normalize/commonjs-module-record.d.ts +21 -0
- package/dist/semantics/normalize/commonjs-module-record.js +289 -0
- package/dist/semantics/normalize/commonjs-require.d.ts +13 -0
- package/dist/semantics/normalize/commonjs-require.js +1527 -0
- package/dist/semantics/normalize/contribution.d.ts +63 -0
- package/dist/semantics/normalize/contribution.js +172 -0
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +64 -0
- package/dist/semantics/normalize/dead-typeof-guards.js +152 -0
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +57 -0
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +109 -0
- package/dist/semantics/normalize/derived-expression-type.d.ts +1070 -0
- package/dist/semantics/normalize/derived-expression-type.js +3463 -0
- package/dist/semantics/normalize/evaluation-order.d.ts +16 -0
- package/dist/semantics/normalize/evaluation-order.js +37 -0
- package/dist/semantics/normalize/field-bindings.d.ts +167 -0
- package/dist/semantics/normalize/field-bindings.js +1125 -0
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +27 -0
- package/dist/semantics/normalize/flow/array-element-continuation.js +1452 -0
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +42 -0
- package/dist/semantics/normalize/flow/callable-array-origins.js +318 -0
- package/dist/semantics/normalize/flow/callable-completions.d.ts +45 -0
- package/dist/semantics/normalize/flow/callable-completions.js +82 -0
- package/dist/semantics/normalize/flow/callable-reach.d.ts +237 -0
- package/dist/semantics/normalize/flow/callable-reach.js +7174 -0
- package/dist/semantics/normalize/flow/class-family-member-read.d.ts +16 -0
- package/dist/semantics/normalize/flow/class-family-member-read.js +992 -0
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +21 -0
- package/dist/semantics/normalize/flow/collection-value-continuation.js +192 -0
- package/dist/semantics/normalize/flow/component-solver.d.ts +199 -0
- package/dist/semantics/normalize/flow/component-solver.js +587 -0
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +84 -0
- package/dist/semantics/normalize/flow/computed-key-set.js +660 -0
- package/dist/semantics/normalize/flow/export-importers.d.ts +24 -0
- package/dist/semantics/normalize/flow/export-importers.js +269 -0
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +25 -0
- package/dist/semantics/normalize/flow/host-text-sink.js +87 -0
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +84 -0
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +180 -0
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +35 -0
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +140 -0
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +98 -0
- package/dist/semantics/normalize/flow/invocation-facts.js +257 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +122 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +835 -0
- package/dist/semantics/normalize/flow/model.d.ts +357 -0
- package/dist/semantics/normalize/flow/model.js +177 -0
- package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +24 -0
- package/dist/semantics/normalize/flow/native-collection-protocol.js +252 -0
- package/dist/semantics/normalize/flow/node-path-token.d.ts +3 -0
- package/dist/semantics/normalize/flow/node-path-token.js +53 -0
- package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +11 -0
- package/dist/semantics/normalize/flow/object-binding-continuation.js +42 -0
- package/dist/semantics/normalize/flow/origin-authority.d.ts +56 -0
- package/dist/semantics/normalize/flow/origin-authority.js +2 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +35 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.js +191 -0
- package/dist/semantics/normalize/flow/parameter-values.d.ts +27 -0
- package/dist/semantics/normalize/flow/parameter-values.js +251 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +66 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +162 -0
- package/dist/semantics/normalize/flow/record-alias-closure.d.ts +27 -0
- package/dist/semantics/normalize/flow/record-alias-closure.js +298 -0
- package/dist/semantics/normalize/flow/seeded-origins.d.ts +43 -0
- package/dist/semantics/normalize/flow/seeded-origins.js +54 -0
- package/dist/semantics/normalize/flow/source-class-data.d.ts +132 -0
- package/dist/semantics/normalize/flow/source-class-data.js +838 -0
- package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-class-instanceof.js +37 -0
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +16 -0
- package/dist/semantics/normalize/flow/source-class-static-data.js +47 -0
- package/dist/semantics/normalize/flow/source-construction-frames.d.ts +12 -0
- package/dist/semantics/normalize/flow/source-construction-frames.js +118 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +34 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +78 -0
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +95 -0
- package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +23 -0
- package/dist/semantics/normalize/flow/source-prototype-method-identity.js +81 -0
- package/dist/semantics/normalize/flow/source-record-data.d.ts +29 -0
- package/dist/semantics/normalize/flow/source-record-data.js +626 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +77 -0
- package/dist/semantics/normalize/flow/source-value-session.js +3089 -0
- package/dist/semantics/normalize/flow/targets.d.ts +118 -0
- package/dist/semantics/normalize/flow/targets.js +405 -0
- package/dist/semantics/normalize/flow/value-flow.d.ts +36 -0
- package/dist/semantics/normalize/flow/value-flow.js +823 -0
- package/dist/semantics/normalize/flow/value-provenance.d.ts +31 -0
- package/dist/semantics/normalize/flow/value-provenance.js +112 -0
- package/dist/semantics/normalize/gating.d.ts +51 -0
- package/dist/semantics/normalize/gating.js +560 -0
- package/dist/semantics/normalize/generic-function-choice.d.ts +31 -0
- package/dist/semantics/normalize/generic-function-choice.js +115 -0
- package/dist/semantics/normalize/global-host-mutations.d.ts +51 -0
- package/dist/semantics/normalize/global-host-mutations.js +5989 -0
- package/dist/semantics/normalize/host-effect-contracts.d.ts +77 -0
- package/dist/semantics/normalize/host-effect-contracts.js +143 -0
- package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +38 -0
- package/dist/semantics/normalize/host-mutation-computed-keys.js +26 -0
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +66 -0
- package/dist/semantics/normalize/host-mutation-key-reader.js +192 -0
- package/dist/semantics/normalize/host-mutation-keys.d.ts +114 -0
- package/dist/semantics/normalize/host-mutation-keys.js +183 -0
- package/dist/semantics/normalize/identities.d.ts +172 -0
- package/dist/semantics/normalize/identities.js +426 -0
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +97 -0
- package/dist/semantics/normalize/implicit-arguments-tuple.js +197 -0
- package/dist/semantics/normalize/implicit-arguments.d.ts +11 -0
- package/dist/semantics/normalize/implicit-arguments.js +39 -0
- package/dist/semantics/normalize/instantiation.d.ts +73 -0
- package/dist/semantics/normalize/instantiation.js +399 -0
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +18 -0
- package/dist/semantics/normalize/intrinsic-property-call.js +69 -0
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +41 -0
- package/dist/semantics/normalize/intrinsic-prototype.js +87 -0
- package/dist/semantics/normalize/intrinsic-static-member.d.ts +14 -0
- package/dist/semantics/normalize/intrinsic-static-member.js +23 -0
- package/dist/semantics/normalize/jsdoc-type-names.d.ts +32 -0
- package/dist/semantics/normalize/jsdoc-type-names.js +512 -0
- package/dist/semantics/normalize/keyof.d.ts +32 -0
- package/dist/semantics/normalize/keyof.js +110 -0
- package/dist/semantics/normalize/local-bindings.d.ts +176 -0
- package/dist/semantics/normalize/local-bindings.js +1826 -0
- package/dist/semantics/normalize/logical-result-type.d.ts +16 -0
- package/dist/semantics/normalize/logical-result-type.js +102 -0
- package/dist/semantics/normalize/namespace-paths.d.ts +57 -0
- package/dist/semantics/normalize/namespace-paths.js +108 -0
- package/dist/semantics/normalize/normalize.d.ts +57 -0
- package/dist/semantics/normalize/normalize.js +68 -0
- package/dist/semantics/normalize/object-bag-bindings.d.ts +305 -0
- package/dist/semantics/normalize/object-bag-bindings.js +1290 -0
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +53 -0
- package/dist/semantics/normalize/omitted-stated-parameter.js +59 -0
- package/dist/semantics/normalize/open-type-form.d.ts +10 -0
- package/dist/semantics/normalize/open-type-form.js +32 -0
- package/dist/semantics/normalize/parameter-bindings.d.ts +361 -0
- package/dist/semantics/normalize/parameter-bindings.js +3339 -0
- package/dist/semantics/normalize/parameter-slot.d.ts +264 -0
- package/dist/semantics/normalize/parameter-slot.js +491 -0
- package/dist/semantics/normalize/physical-overload-result.d.ts +77 -0
- package/dist/semantics/normalize/physical-overload-result.js +99 -0
- package/dist/semantics/normalize/primitive-property-absence.d.ts +12 -0
- package/dist/semantics/normalize/primitive-property-absence.js +60 -0
- package/dist/semantics/normalize/producer-context.d.ts +376 -0
- package/dist/semantics/normalize/producer-context.js +1 -0
- package/dist/semantics/normalize/producers/allocations.d.ts +3 -0
- package/dist/semantics/normalize/producers/allocations.js +863 -0
- package/dist/semantics/normalize/producers/binding-kind.d.ts +37 -0
- package/dist/semantics/normalize/producers/binding-kind.js +36 -0
- package/dist/semantics/normalize/producers/bindings.d.ts +85 -0
- package/dist/semantics/normalize/producers/bindings.js +710 -0
- package/dist/semantics/normalize/producers/boundary.d.ts +34 -0
- package/dist/semantics/normalize/producers/boundary.js +123 -0
- package/dist/semantics/normalize/producers/class-lifecycle.d.ts +3 -0
- package/dist/semantics/normalize/producers/class-lifecycle.js +902 -0
- package/dist/semantics/normalize/producers/computations.d.ts +3 -0
- package/dist/semantics/normalize/producers/computations.js +613 -0
- package/dist/semantics/normalize/producers/control-loops.d.ts +30 -0
- package/dist/semantics/normalize/producers/control-loops.js +91 -0
- package/dist/semantics/normalize/producers/control.d.ts +30 -0
- package/dist/semantics/normalize/producers/control.js +923 -0
- package/dist/semantics/normalize/producers/declaration-lifecycle.d.ts +3 -0
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +390 -0
- package/dist/semantics/normalize/producers/destructuring.d.ts +45 -0
- package/dist/semantics/normalize/producers/destructuring.js +1180 -0
- package/dist/semantics/normalize/producers/dynamic-language.d.ts +3 -0
- package/dist/semantics/normalize/producers/dynamic-language.js +70 -0
- package/dist/semantics/normalize/producers/erasure.d.ts +51 -0
- package/dist/semantics/normalize/producers/erasure.js +90 -0
- package/dist/semantics/normalize/producers/installed.d.ts +3 -0
- package/dist/semantics/normalize/producers/installed.js +55 -0
- package/dist/semantics/normalize/producers/invocations.d.ts +35 -0
- package/dist/semantics/normalize/producers/invocations.js +1796 -0
- package/dist/semantics/normalize/producers/iteration-yield.d.ts +59 -0
- package/dist/semantics/normalize/producers/iteration-yield.js +235 -0
- package/dist/semantics/normalize/producers/jsx.d.ts +3 -0
- package/dist/semantics/normalize/producers/jsx.js +360 -0
- package/dist/semantics/normalize/producers/mint.d.ts +39 -0
- package/dist/semantics/normalize/producers/mint.js +44 -0
- package/dist/semantics/normalize/producers/nullish.d.ts +16 -0
- package/dist/semantics/normalize/producers/nullish.js +27 -0
- package/dist/semantics/normalize/producers/object-assignment.d.ts +8 -0
- package/dist/semantics/normalize/producers/object-assignment.js +204 -0
- package/dist/semantics/normalize/producers/object-tag.d.ts +9 -0
- package/dist/semantics/normalize/producers/object-tag.js +119 -0
- package/dist/semantics/normalize/producers/optional-chain.d.ts +44 -0
- package/dist/semantics/normalize/producers/optional-chain.js +75 -0
- package/dist/semantics/normalize/producers/properties.d.ts +21 -0
- package/dist/semantics/normalize/producers/properties.js +1053 -0
- package/dist/semantics/normalize/producers/protocol.d.ts +67 -0
- package/dist/semantics/normalize/producers/protocol.js +695 -0
- package/dist/semantics/normalize/producers/references.d.ts +53 -0
- package/dist/semantics/normalize/producers/references.js +1027 -0
- package/dist/semantics/normalize/producers/shared.d.ts +561 -0
- package/dist/semantics/normalize/producers/shared.js +1683 -0
- package/dist/semantics/normalize/producers/spread-arguments.d.ts +72 -0
- package/dist/semantics/normalize/producers/spread-arguments.js +375 -0
- package/dist/semantics/normalize/producers/tagged-template.d.ts +5 -0
- package/dist/semantics/normalize/producers/tagged-template.js +307 -0
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +189 -0
- package/dist/semantics/normalize/producers/tuple-spread.js +279 -0
- package/dist/semantics/normalize/property-key-domain.d.ts +36 -0
- package/dist/semantics/normalize/property-key-domain.js +150 -0
- package/dist/semantics/normalize/reachability.d.ts +189 -0
- package/dist/semantics/normalize/reachability.js +1057 -0
- package/dist/semantics/normalize/reassigned-bindings.d.ts +13 -0
- package/dist/semantics/normalize/reassigned-bindings.js +41 -0
- package/dist/semantics/normalize/record-storage-families.d.ts +11 -0
- package/dist/semantics/normalize/record-storage-families.js +109 -0
- package/dist/semantics/normalize/return-bindings.d.ts +260 -0
- package/dist/semantics/normalize/return-bindings.js +1311 -0
- package/dist/semantics/normalize/return-paths.d.ts +2 -0
- package/dist/semantics/normalize/return-paths.js +28 -0
- package/dist/semantics/normalize/script-global-redefinition.d.ts +44 -0
- package/dist/semantics/normalize/script-global-redefinition.js +75 -0
- package/dist/semantics/normalize/specialization.d.ts +201 -0
- package/dist/semantics/normalize/specialization.js +1824 -0
- package/dist/semantics/normalize/structural-array-element.d.ts +176 -0
- package/dist/semantics/normalize/structural-array-element.js +700 -0
- package/dist/semantics/normalize/structural-array-read.d.ts +13 -0
- package/dist/semantics/normalize/structural-array-read.js +124 -0
- package/dist/semantics/normalize/structural-callable.d.ts +12 -0
- package/dist/semantics/normalize/structural-callable.js +82 -0
- package/dist/semantics/normalize/structural-creation-order.d.ts +32 -0
- package/dist/semantics/normalize/structural-creation-order.js +111 -0
- package/dist/semantics/normalize/structural-declarations.d.ts +395 -0
- package/dist/semantics/normalize/structural-declarations.js +968 -0
- package/dist/semantics/normalize/structural-declared-body.d.ts +25 -0
- package/dist/semantics/normalize/structural-declared-body.js +147 -0
- package/dist/semantics/normalize/structural-generics.d.ts +56 -0
- package/dist/semantics/normalize/structural-generics.js +120 -0
- package/dist/semantics/normalize/structural-indexed-access.d.ts +11 -0
- package/dist/semantics/normalize/structural-indexed-access.js +126 -0
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +64 -0
- package/dist/semantics/normalize/structural-instantiated-member.js +407 -0
- package/dist/semantics/normalize/structural-joins.d.ts +44 -0
- package/dist/semantics/normalize/structural-joins.js +143 -0
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +29 -0
- package/dist/semantics/normalize/structural-layout-relevance.js +391 -0
- package/dist/semantics/normalize/structural-layout-type.d.ts +11 -0
- package/dist/semantics/normalize/structural-layout-type.js +1468 -0
- package/dist/semantics/normalize/structural-leaves.d.ts +49 -0
- package/dist/semantics/normalize/structural-leaves.js +125 -0
- package/dist/semantics/normalize/structural-local-union.d.ts +13 -0
- package/dist/semantics/normalize/structural-local-union.js +133 -0
- package/dist/semantics/normalize/structural-members.d.ts +26 -0
- package/dist/semantics/normalize/structural-members.js +84 -0
- package/dist/semantics/normalize/structural-mutable-method.d.ts +15 -0
- package/dist/semantics/normalize/structural-mutable-method.js +109 -0
- package/dist/semantics/normalize/structural-parts.d.ts +131 -0
- package/dist/semantics/normalize/structural-parts.js +737 -0
- package/dist/semantics/normalize/structural-receiver.d.ts +66 -0
- package/dist/semantics/normalize/structural-receiver.js +551 -0
- package/dist/semantics/normalize/structural-rules.d.ts +112 -0
- package/dist/semantics/normalize/structural-rules.js +93 -0
- package/dist/semantics/normalize/structural-self-reference.d.ts +150 -0
- package/dist/semantics/normalize/structural-self-reference.js +494 -0
- package/dist/semantics/normalize/structural.d.ts +202 -0
- package/dist/semantics/normalize/structural.js +4218 -0
- package/dist/semantics/normalize/unreduced-type-form.d.ts +41 -0
- package/dist/semantics/normalize/unreduced-type-form.js +53 -0
- package/dist/semantics/normalize/unresolvable-names.d.ts +56 -0
- package/dist/semantics/normalize/unresolvable-names.js +140 -0
- package/dist/semantics/package-sources.d.ts +16 -0
- package/dist/semantics/package-sources.js +365 -0
- package/dist/semantics/program.d.ts +151 -0
- package/dist/semantics/program.js +667 -0
- package/dist/semantics/prototype-install-source-transform.d.ts +4 -0
- package/dist/semantics/prototype-install-source-transform.js +341 -0
- package/dist/semantics/prototype-object-class-source-transform.d.ts +4 -0
- package/dist/semantics/prototype-object-class-source-transform.js +525 -0
- package/dist/semantics/prototype-reparenting.d.ts +50 -0
- package/dist/semantics/prototype-reparenting.js +317 -0
- package/dist/semantics/stable-checker.d.ts +10 -0
- package/dist/semantics/stable-checker.js +148 -0
- package/dist/semantics/subclass-member-overlay-transform.d.ts +35 -0
- package/dist/semantics/subclass-member-overlay-transform.js +1418 -0
- package/dist/semantics/symbol-keyed-expando-source-transform.d.ts +4 -0
- package/dist/semantics/symbol-keyed-expando-source-transform.js +66 -0
- package/dist/semantics/this-constructor-source-transform.d.ts +4 -0
- package/dist/semantics/this-constructor-source-transform.js +122 -0
- package/dist/semantics/uninstantiable-classes.d.ts +22 -0
- package/dist/semantics/uninstantiable-classes.js +75 -0
- package/dist/targets/cpp/balanced-units.d.ts +3 -0
- package/dist/targets/cpp/balanced-units.js +58 -0
- package/dist/targets/cpp/borrowed-call-entry.d.ts +30 -0
- package/dist/targets/cpp/borrowed-call-entry.js +68 -0
- package/dist/targets/cpp/captures.d.ts +68 -0
- package/dist/targets/cpp/captures.js +269 -0
- package/dist/targets/cpp/class-layout.d.ts +313 -0
- package/dist/targets/cpp/class-layout.js +483 -0
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +25 -0
- package/dist/targets/cpp/class-properties/computed-method-value.js +22 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +216 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.js +917 -0
- package/dist/targets/cpp/class-properties/native-prototype.d.ts +11 -0
- package/dist/targets/cpp/class-properties/native-prototype.js +101 -0
- package/dist/targets/cpp/class-ref-transport.d.ts +12 -0
- package/dist/targets/cpp/class-ref-transport.js +32 -0
- package/dist/targets/cpp/conversions.d.ts +3 -0
- package/dist/targets/cpp/conversions.js +2027 -0
- package/dist/targets/cpp/deferral-safety.d.ts +82 -0
- package/dist/targets/cpp/deferral-safety.js +86 -0
- package/dist/targets/cpp/direct-call-receivers.d.ts +37 -0
- package/dist/targets/cpp/direct-call-receivers.js +79 -0
- package/dist/targets/cpp/document.d.ts +74 -0
- package/dist/targets/cpp/document.js +106 -0
- package/dist/targets/cpp/emit-allocation.d.ts +60 -0
- package/dist/targets/cpp/emit-allocation.js +573 -0
- package/dist/targets/cpp/emit-arrays.d.ts +119 -0
- package/dist/targets/cpp/emit-arrays.js +1047 -0
- package/dist/targets/cpp/emit-binding-reference.d.ts +17 -0
- package/dist/targets/cpp/emit-binding-reference.js +120 -0
- package/dist/targets/cpp/emit-bindings.d.ts +158 -0
- package/dist/targets/cpp/emit-bindings.js +769 -0
- package/dist/targets/cpp/emit-buffers.d.ts +156 -0
- package/dist/targets/cpp/emit-buffers.js +573 -0
- package/dist/targets/cpp/emit-callable.d.ts +230 -0
- package/dist/targets/cpp/emit-callable.js +2154 -0
- package/dist/targets/cpp/emit-carrier-members.d.ts +406 -0
- package/dist/targets/cpp/emit-carrier-members.js +1224 -0
- package/dist/targets/cpp/emit-coercion.d.ts +26 -0
- package/dist/targets/cpp/emit-coercion.js +39 -0
- package/dist/targets/cpp/emit-context.d.ts +1882 -0
- package/dist/targets/cpp/emit-context.js +904 -0
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +174 -0
- package/dist/targets/cpp/emit-dynamic-properties.js +1249 -0
- package/dist/targets/cpp/emit-equality.d.ts +39 -0
- package/dist/targets/cpp/emit-equality.js +472 -0
- package/dist/targets/cpp/emit-exceptions.d.ts +104 -0
- package/dist/targets/cpp/emit-exceptions.js +513 -0
- package/dist/targets/cpp/emit-field-owner.d.ts +4 -0
- package/dist/targets/cpp/emit-field-owner.js +27 -0
- package/dist/targets/cpp/emit-in.d.ts +31 -0
- package/dist/targets/cpp/emit-in.js +426 -0
- package/dist/targets/cpp/emit-instanceof.d.ts +19 -0
- package/dist/targets/cpp/emit-instanceof.js +601 -0
- package/dist/targets/cpp/emit-integers.d.ts +68 -0
- package/dist/targets/cpp/emit-integers.js +184 -0
- package/dist/targets/cpp/emit-iterator.d.ts +100 -0
- package/dist/targets/cpp/emit-iterator.js +1137 -0
- package/dist/targets/cpp/emit-json.d.ts +73 -0
- package/dist/targets/cpp/emit-json.js +823 -0
- package/dist/targets/cpp/emit-jsx.d.ts +74 -0
- package/dist/targets/cpp/emit-jsx.js +806 -0
- package/dist/targets/cpp/emit-mixed-binary.d.ts +51 -0
- package/dist/targets/cpp/emit-mixed-binary.js +60 -0
- package/dist/targets/cpp/emit-namespaces.d.ts +101 -0
- package/dist/targets/cpp/emit-namespaces.js +133 -0
- package/dist/targets/cpp/emit-narrowing.d.ts +738 -0
- package/dist/targets/cpp/emit-narrowing.js +3967 -0
- package/dist/targets/cpp/emit-native-equality.d.ts +3 -0
- package/dist/targets/cpp/emit-native-equality.js +14 -0
- package/dist/targets/cpp/emit-native-selection.d.ts +5 -0
- package/dist/targets/cpp/emit-native-selection.js +37 -0
- package/dist/targets/cpp/emit-object-tag.d.ts +4 -0
- package/dist/targets/cpp/emit-object-tag.js +108 -0
- package/dist/targets/cpp/emit-owned-record.d.ts +2 -0
- package/dist/targets/cpp/emit-owned-record.js +15 -0
- package/dist/targets/cpp/emit-presence.d.ts +78 -0
- package/dist/targets/cpp/emit-presence.js +376 -0
- package/dist/targets/cpp/emit-properties.d.ts +105 -0
- package/dist/targets/cpp/emit-properties.js +1640 -0
- package/dist/targets/cpp/emit-record-view.d.ts +20 -0
- package/dist/targets/cpp/emit-record-view.js +354 -0
- package/dist/targets/cpp/emit-return.d.ts +5 -0
- package/dist/targets/cpp/emit-return.js +237 -0
- package/dist/targets/cpp/emit-sum-widening.d.ts +10 -0
- package/dist/targets/cpp/emit-sum-widening.js +69 -0
- package/dist/targets/cpp/emit-tonumber.d.ts +38 -0
- package/dist/targets/cpp/emit-tonumber.js +177 -0
- package/dist/targets/cpp/emit-tostring.d.ts +92 -0
- package/dist/targets/cpp/emit-tostring.js +556 -0
- package/dist/targets/cpp/emit-typeof.d.ts +49 -0
- package/dist/targets/cpp/emit-typeof.js +317 -0
- package/dist/targets/cpp/emit-union-properties.d.ts +181 -0
- package/dist/targets/cpp/emit-union-properties.js +1281 -0
- package/dist/targets/cpp/emit.d.ts +45 -0
- package/dist/targets/cpp/emit.js +2225 -0
- package/dist/targets/cpp/error-types.d.ts +4 -0
- package/dist/targets/cpp/error-types.js +11 -0
- package/dist/targets/cpp/function-source-reads.d.ts +72 -0
- package/dist/targets/cpp/function-source-reads.js +148 -0
- package/dist/targets/cpp/host/atomics.d.ts +25 -0
- package/dist/targets/cpp/host/atomics.js +63 -0
- package/dist/targets/cpp/host/core-globals.d.ts +108 -0
- package/dist/targets/cpp/host/core-globals.js +158 -0
- package/dist/targets/cpp/host/dynamic-argument-members.d.ts +42 -0
- package/dist/targets/cpp/host/dynamic-argument-members.js +61 -0
- package/dist/targets/cpp/host/emit-host-arity.d.ts +139 -0
- package/dist/targets/cpp/host/emit-host-arity.js +232 -0
- package/dist/targets/cpp/host/emit-host-invoke.d.ts +91 -0
- package/dist/targets/cpp/host/emit-host-invoke.js +1105 -0
- package/dist/targets/cpp/host/emit-host-object.d.ts +55 -0
- package/dist/targets/cpp/host/emit-host-object.js +2206 -0
- package/dist/targets/cpp/host/emit-host-properties.d.ts +69 -0
- package/dist/targets/cpp/host/emit-host-properties.js +533 -0
- package/dist/targets/cpp/host/emit-host-reflect.d.ts +4 -0
- package/dist/targets/cpp/host/emit-host-reflect.js +180 -0
- package/dist/targets/cpp/host/emit-host-value.d.ts +120 -0
- package/dist/targets/cpp/host/emit-host-value.js +392 -0
- package/dist/targets/cpp/host/host-members.d.ts +505 -0
- package/dist/targets/cpp/host/host-members.js +819 -0
- package/dist/targets/cpp/host/host-method-aliases.d.ts +30 -0
- package/dist/targets/cpp/host/host-method-aliases.js +76 -0
- package/dist/targets/cpp/host/native-protocols.d.ts +47 -0
- package/dist/targets/cpp/host/native-protocols.js +183 -0
- package/dist/targets/cpp/host/object-protocol.d.ts +351 -0
- package/dist/targets/cpp/host/object-protocol.js +671 -0
- package/dist/targets/cpp/host-namespace-reads.d.ts +83 -0
- package/dist/targets/cpp/host-namespace-reads.js +113 -0
- package/dist/targets/cpp/manifest/capabilities.d.ts +39 -0
- package/dist/targets/cpp/manifest/capabilities.js +1484 -0
- package/dist/targets/cpp/manifest.d.ts +23 -0
- package/dist/targets/cpp/manifest.js +113 -0
- package/dist/targets/cpp/native-error-base.d.ts +38 -0
- package/dist/targets/cpp/native-error-base.js +74 -0
- package/dist/targets/cpp/native-narrowing-transport.d.ts +12 -0
- package/dist/targets/cpp/native-narrowing-transport.js +151 -0
- package/dist/targets/cpp/native-selection-helpers.d.ts +11 -0
- package/dist/targets/cpp/native-selection-helpers.js +46 -0
- package/dist/targets/cpp/native-symbol-keys.d.ts +8 -0
- package/dist/targets/cpp/native-symbol-keys.js +34 -0
- package/dist/targets/cpp/ownership.d.ts +43 -0
- package/dist/targets/cpp/ownership.js +38 -0
- package/dist/targets/cpp/owning-conversion-input.d.ts +14 -0
- package/dist/targets/cpp/owning-conversion-input.js +12 -0
- package/dist/targets/cpp/property-read-claims.d.ts +62 -0
- package/dist/targets/cpp/property-read-claims.js +23 -0
- package/dist/targets/cpp/property-store-claims.d.ts +62 -0
- package/dist/targets/cpp/property-store-claims.js +26 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +111 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.js +602 -0
- package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +133 -0
- package/dist/targets/cpp/prototype/emit-prototype-date.js +515 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +13 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.js +54 -0
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +34 -0
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +1003 -0
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +47 -0
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +250 -0
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +46 -0
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +143 -0
- package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +335 -0
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +853 -0
- package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +42 -0
- package/dist/targets/cpp/prototype/emit-prototype-string.js +252 -0
- package/dist/targets/cpp/prototype/prototype-method-reads.d.ts +25 -0
- package/dist/targets/cpp/prototype/prototype-method-reads.js +182 -0
- package/dist/targets/cpp/reactive-dependencies.d.ts +140 -0
- package/dist/targets/cpp/reactive-dependencies.js +432 -0
- package/dist/targets/cpp/reactive-origins.d.ts +44 -0
- package/dist/targets/cpp/reactive-origins.js +82 -0
- package/dist/targets/cpp/records.d.ts +277 -0
- package/dist/targets/cpp/records.js +2427 -0
- package/dist/targets/cpp/recursive-containers.d.ts +43 -0
- package/dist/targets/cpp/recursive-containers.js +144 -0
- package/dist/targets/cpp/regexp-types.d.ts +56 -0
- package/dist/targets/cpp/regexp-types.js +59 -0
- package/dist/targets/cpp/substrate.d.ts +125 -0
- package/dist/targets/cpp/substrate.js +12 -0
- package/dist/targets/cpp/translation-unit.d.ts +219 -0
- package/dist/targets/cpp/translation-unit.js +2063 -0
- package/dist/targets/cpp/types.d.ts +280 -0
- package/dist/targets/cpp/types.js +1135 -0
- package/dist/targets/cpp/virtual-methods.d.ts +95 -0
- package/dist/targets/cpp/virtual-methods.js +264 -0
- package/package.json +95 -0
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +824 -0
- package/src/targets/cpp/runtime/gea_eval.h +1376 -0
- package/src/targets/cpp/runtime/gea_native_class_prototype.h +44 -0
- package/src/targets/cpp/runtime/gea_runtime.h +29222 -0
- package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +55 -0
|
@@ -0,0 +1,1180 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { isUnusableEvidence } from '../derived-expression-type.js';
|
|
3
|
+
import { arrayAssignmentSource, arrayAssignmentTargetOf, arrayAssignmentWriteTargetOf, isObjectAssignmentElement } from '../assignment-patterns.js';
|
|
4
|
+
import { contributeObjectAssignmentElement, contributeObjectAssignmentSource } from './object-assignment.js';
|
|
5
|
+
import { operationId, regionId, semanticResultId } from '../../../identity/ids.js';
|
|
6
|
+
import { normalCompletion, throwingCompletion } from '../../model/operands.js';
|
|
7
|
+
import { mintOperationId, mintResult, operand } from './mint.js';
|
|
8
|
+
import { asBlocked, hasNativeIterationCursor, isFixedArityTupleType, isGeneratorType, isStrictContext, resultEdge, unwrapErased, valueEdgesInto } from './shared.js';
|
|
9
|
+
import { citeExpressionResult } from './references.js';
|
|
10
|
+
import { memberTypeOf } from '../derived-expression-type.js';
|
|
11
|
+
import { bindingKindOf } from './binding-kind.js';
|
|
12
|
+
import { iteratorYieldStructuralType, iteratorYieldTypesOf } from './iteration-yield.js';
|
|
13
|
+
import { isDynamicIterationSource, mintIteratorSteps } from './protocol.js';
|
|
14
|
+
/**
|
|
15
|
+
* The result carrying the value a binding element finally receives.
|
|
16
|
+
*
|
|
17
|
+
* The binding family introduces the name, this family extracts the value, and
|
|
18
|
+
* neither may guess at the other's work -- so the two meet the way every other
|
|
19
|
+
* cross-family citation does: by recomputing the identity the other side
|
|
20
|
+
* independently mints. That recomputation is only sound because each element's
|
|
21
|
+
* operations are keyed on the *element's* own node, and because the ordinal is
|
|
22
|
+
* fixed by a property of the element rather than by its position in the walk: a
|
|
23
|
+
* defaulted element publishes its extraction first and its `default-value`
|
|
24
|
+
* second, and the second is the one the name is bound to.
|
|
25
|
+
*/
|
|
26
|
+
export const citeBoundElementValue = (element, identities) => ({
|
|
27
|
+
kind: 'result',
|
|
28
|
+
result: semanticResultId(operationId(identities.nodeIdOf(element), 'destructuring', element.initializer ? 1 : 0), 'value')
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* The EXTRACTION's result for a binding element -- always ordinal 0, whether or
|
|
32
|
+
* not the element is defaulted.
|
|
33
|
+
*
|
|
34
|
+
* `citeBoundElementValue` answers "what is the name bound to", which for a
|
|
35
|
+
* defaulted element is the `default-value` step. This answers "what did the
|
|
36
|
+
* pattern actually read out of the source", which is what that step tests for
|
|
37
|
+
* absence and what `gating.ts` names as the guard over the initializer. Two
|
|
38
|
+
* questions, two ordinals, recomputed the same way rather than looked up.
|
|
39
|
+
*/
|
|
40
|
+
export const citeExtractedElementValue = (element, identities) => semanticResultId(operationId(identities.nodeIdOf(element), 'destructuring', 0), 'value');
|
|
41
|
+
/**
|
|
42
|
+
* The type an object rest element and the binding it initializes must share.
|
|
43
|
+
*
|
|
44
|
+
* TypeScript narrows `Document` through a predicate such as `value is
|
|
45
|
+
* DBRefLike` and then types `{ known, ...rest }` as a closed `{}` when every
|
|
46
|
+
* named member of the predicate was excluded. That answer loses the index
|
|
47
|
+
* signature the runtime object still has: CopyDataProperties must retain all
|
|
48
|
+
* of the source's other keys. A binding read physically cites its declaration's
|
|
49
|
+
* published cell, so recover that storage type and preserve it when it is a
|
|
50
|
+
* members-free string dictionary. Both producer families call this function;
|
|
51
|
+
* otherwise the extraction would publish a dictionary and the introduced name
|
|
52
|
+
* would immediately demand a dictionary-to-empty-record conversion.
|
|
53
|
+
*/
|
|
54
|
+
export const boundElementType = (element, context) => {
|
|
55
|
+
const checkerType = context.types.typeAt(element);
|
|
56
|
+
if (!element.dotDotDotToken || !ts.isObjectBindingPattern(element.parent))
|
|
57
|
+
return checkerType;
|
|
58
|
+
const isOpenStringDictionary = (id, seen = new Set()) => {
|
|
59
|
+
if (seen.has(id))
|
|
60
|
+
return false;
|
|
61
|
+
seen.add(id);
|
|
62
|
+
const shape = context.table.get(id).shape;
|
|
63
|
+
if (shape.kind === 'declared' && shape.body)
|
|
64
|
+
return isOpenStringDictionary(shape.body, seen);
|
|
65
|
+
if (shape.kind === 'intersection' && shape.resolved)
|
|
66
|
+
return isOpenStringDictionary(shape.resolved, seen);
|
|
67
|
+
return shape.kind === 'object' && shape.members.length === 0 && shape.index.some((index) => index.key === 'string');
|
|
68
|
+
};
|
|
69
|
+
const pattern = element.parent;
|
|
70
|
+
const parent = pattern.parent;
|
|
71
|
+
let storageType = context.types.typeAt(pattern);
|
|
72
|
+
if (ts.isParameter(parent) && parent.name === pattern)
|
|
73
|
+
storageType = context.types.typeAt(parent);
|
|
74
|
+
else if (ts.isBindingElement(parent) && parent.name === pattern)
|
|
75
|
+
storageType = context.types.typeAt(parent);
|
|
76
|
+
else if (ts.isVariableDeclaration(parent) && parent.name === pattern && parent.initializer) {
|
|
77
|
+
const source = unwrapErased(parent.initializer);
|
|
78
|
+
if (ts.isIdentifier(source)) {
|
|
79
|
+
let symbol = context.checker.getSymbolAtLocation(source);
|
|
80
|
+
if (symbol && (symbol.flags & ts.SymbolFlags.Alias) !== 0)
|
|
81
|
+
symbol = context.checker.getAliasedSymbol(symbol);
|
|
82
|
+
const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
|
|
83
|
+
if (declaration)
|
|
84
|
+
storageType = context.types.typeAt(declaration);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return isOpenStringDictionary(storageType) ? storageType : checkerType;
|
|
88
|
+
};
|
|
89
|
+
export const createDestructuringProducer = (context) => {
|
|
90
|
+
const stringType = context.table.intern({ kind: 'primitive', primitive: 'string' });
|
|
91
|
+
/**
|
|
92
|
+
* A property key from a binding element, static or computed.
|
|
93
|
+
*
|
|
94
|
+
* A computed key's value comes from whichever family normalized the
|
|
95
|
+
* bracketed expression (`citeExpressionResult`); it is `blocked` only when
|
|
96
|
+
* that expression itself has no censused family, never merely for being
|
|
97
|
+
* computed. Everything downstream treats the key as an ordinary operand, so
|
|
98
|
+
* a computed key can still take its place among a rest element's excluded
|
|
99
|
+
* keys -- as a cited value instead of a constant, not as a reason to refuse.
|
|
100
|
+
*/
|
|
101
|
+
const keyResolutionOf = (element) => {
|
|
102
|
+
const name = element.propertyName ?? (ts.isIdentifier(element.name) ? element.name : undefined);
|
|
103
|
+
if (!name)
|
|
104
|
+
return { blocked: 'binding element has neither a property name nor an identifier target' };
|
|
105
|
+
if (ts.isIdentifier(name))
|
|
106
|
+
return { source: { kind: 'constant', text: name.text, literal: 'string' }, type: stringType };
|
|
107
|
+
// A numeric/string/bigint/no-substitution-template property name is still a
|
|
108
|
+
// statically known `ToPropertyKey` result -- reading its literal text here
|
|
109
|
+
// is reading the language-defined VALUE the key has, not source spelling
|
|
110
|
+
// used as identity.
|
|
111
|
+
if (ts.isStringLiteral(name) || ts.isNumericLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name) || ts.isBigIntLiteral(name)) {
|
|
112
|
+
return { source: { kind: 'constant', text: name.text, literal: 'string' }, type: stringType };
|
|
113
|
+
}
|
|
114
|
+
if (!ts.isComputedPropertyName(name)) {
|
|
115
|
+
return { blocked: 'private-identifier property name has no property-key value to bind against' };
|
|
116
|
+
}
|
|
117
|
+
const cited = citeExpressionResult(name.expression, context);
|
|
118
|
+
if (cited.kind === 'unmodelled')
|
|
119
|
+
return { blocked: cited.reason };
|
|
120
|
+
return { source: cited.source, type: context.types.typeAt(name.expression) };
|
|
121
|
+
};
|
|
122
|
+
const buildOperation = (id, caller, evaluationOrdinal, form, operands, resultType, completion, effects) => ({
|
|
123
|
+
id,
|
|
124
|
+
caller,
|
|
125
|
+
operands,
|
|
126
|
+
results: resultType ? [mintResult(id, 'value', resultType)] : [],
|
|
127
|
+
completion,
|
|
128
|
+
effects,
|
|
129
|
+
evaluationOrdinal,
|
|
130
|
+
family: 'destructuring',
|
|
131
|
+
form
|
|
132
|
+
});
|
|
133
|
+
const finitePatternNeedsClose = (type) => isDynamicIterationSource(context, type) || isGeneratorType(context, type) || !hasNativeIterationCursor(context, type);
|
|
134
|
+
/**
|
|
135
|
+
* This pattern's own source value, as an operand source -- either the
|
|
136
|
+
* result a sibling element of an *outer* pattern already publishes (the
|
|
137
|
+
* nested case, `{a: {b}}`/`[[x]]`/`[...[a,b]]`), or the initializer of the
|
|
138
|
+
* `const`/`let`/`var` declaration this pattern names directly (the
|
|
139
|
+
* top-level case), or the frame slot a formal parameter binds. A catch
|
|
140
|
+
* binding still has no source here: the value comes from a thrown
|
|
141
|
+
* exception rather than from any operation this producer can cite, so it
|
|
142
|
+
* is correctly `null` rather than guessed at.
|
|
143
|
+
*
|
|
144
|
+
* The nested case is answered by RECOMPUTING the sibling element's
|
|
145
|
+
* extraction identity (`citeBoundElementValue`, exported above for the
|
|
146
|
+
* *binding* family's own identical cross-family citation) rather than by
|
|
147
|
+
* looking one up in a table this producer populated itself. A lookup table
|
|
148
|
+
* keyed by the enclosing candidate's own contribute() call would need that
|
|
149
|
+
* candidate contributed *first* -- but `census.ts`'s own walk is
|
|
150
|
+
* documented and built the other way round ("Children first, then this
|
|
151
|
+
* node: the ordinal is an *evaluation* index, and an expression's operands
|
|
152
|
+
* evaluate before the expression does"), so a NESTED pattern's candidate is
|
|
153
|
+
* always contributed *before* the pattern enclosing it, and a table
|
|
154
|
+
* populated by the enclosing candidate is provably still empty every time
|
|
155
|
+
* this asks it. `citeExtractedElementValue`/`citeBoundElementValue`
|
|
156
|
+
* already avoid this exact trap for the *other* cross-family citation in
|
|
157
|
+
* this file by recomputing a deterministic identity instead of reading
|
|
158
|
+
* one back from a map an ordering assumption would have to hold for --
|
|
159
|
+
* this is that same fix, applied to the citation this producer makes of
|
|
160
|
+
* itself.
|
|
161
|
+
*/
|
|
162
|
+
const patternSourceOperand = (pattern) => {
|
|
163
|
+
const parent = pattern.parent;
|
|
164
|
+
if (ts.isBindingElement(parent) && parent.name === pattern) {
|
|
165
|
+
return {
|
|
166
|
+
source: citeBoundElementValue(parent, context.identities),
|
|
167
|
+
type: boundElementType(parent, context),
|
|
168
|
+
rawType: context.types.rawTypeAt(pattern),
|
|
169
|
+
at: pattern
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (ts.isVariableDeclaration(parent) && parent.name === pattern && parent.initializer) {
|
|
173
|
+
const cited = citeExpressionResult(parent.initializer, context);
|
|
174
|
+
return cited.kind === 'source'
|
|
175
|
+
? {
|
|
176
|
+
source: cited.source,
|
|
177
|
+
// The PATTERN's own published type, not the initializer's asked a
|
|
178
|
+
// second time. `citeExpressionResult` above cites the ERASED
|
|
179
|
+
// initializer's result (`as`/`!`/`satisfies` evaluate to nothing of
|
|
180
|
+
// their own), and `structural.ts`'s `binding-pattern-is-its-source`
|
|
181
|
+
// is the one place that decides which of the two an assertion
|
|
182
|
+
// leaves the pattern reading. Asking the initializer here made this
|
|
183
|
+
// the second authority on that, and the value cited and the type
|
|
184
|
+
// declared for it then described different values.
|
|
185
|
+
type: context.types.typeAt(pattern),
|
|
186
|
+
rawType: context.types.rawTypeAt(parent.initializer),
|
|
187
|
+
at: parent.initializer
|
|
188
|
+
}
|
|
189
|
+
: null;
|
|
190
|
+
}
|
|
191
|
+
// `function f({a, b})` holds the argument in the parameter's own cell while
|
|
192
|
+
// the pattern reads it, and the binding producer publishes exactly that
|
|
193
|
+
// cell's `initialize`. Citing it by predicted identity is the same
|
|
194
|
+
// agreement every other cross-family citation is built on.
|
|
195
|
+
if (ts.isParameter(parent) && parent.name === pattern) {
|
|
196
|
+
const id = operationId(context.identities.nodeIdOf(parent), 'binding', 0);
|
|
197
|
+
return {
|
|
198
|
+
source: { kind: 'result', result: semanticResultId(id, 'value') },
|
|
199
|
+
type: context.types.typeAt(parent),
|
|
200
|
+
rawType: context.types.rawTypeAt(parent),
|
|
201
|
+
at: parent
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// `for (const [k, v] of pairs)`: a loop variable that is a PATTERN has no
|
|
205
|
+
// `=` initializer any more than `for (const x of xs)` does -- ECMA-262
|
|
206
|
+
// assigns it from the loop's own `IteratorStep` at the head of every
|
|
207
|
+
// iteration -- so its source is that step's value, cited by the same fixed
|
|
208
|
+
// ordinal `producers/bindings.ts`'s `forOfLoopVariableNextResult` cites for
|
|
209
|
+
// the identifier case. `mintIteratorSteps` (protocol.ts) reserves `next` at
|
|
210
|
+
// ordinal 2 for exactly this: the citation is the same `SemanticResultId`
|
|
211
|
+
// whether the loop took the native-cursor path or the general protocol, and
|
|
212
|
+
// whether or not this compiler can lower either.
|
|
213
|
+
//
|
|
214
|
+
// Without this the pattern had no source operand at all, so every step of
|
|
215
|
+
// it keyed as "destructuring:array-pattern:absent" -- a key no manifest
|
|
216
|
+
// claims -- and `for (const [k, v] of ...)` was refused with a message
|
|
217
|
+
// about the pattern rather than about the loop it belongs to.
|
|
218
|
+
if (ts.isVariableDeclaration(parent) && parent.name === pattern && !parent.initializer) {
|
|
219
|
+
const list = parent.parent;
|
|
220
|
+
const loop = ts.isVariableDeclarationList(list) ? list.parent : null;
|
|
221
|
+
if (loop && (ts.isForOfStatement(loop) || ts.isForInStatement(loop)) && loop.initializer === list) {
|
|
222
|
+
const id = operationId(context.identities.nodeIdOf(loop), 'protocol', 2);
|
|
223
|
+
const iterable = context.types.typeAt(loop.expression);
|
|
224
|
+
const shape = context.table.get(iterable).shape;
|
|
225
|
+
const type = shape.kind === 'array' ? shape.element : context.types.typeAt(pattern);
|
|
226
|
+
return {
|
|
227
|
+
source: { kind: 'result', result: semanticResultId(id, 'value') },
|
|
228
|
+
type,
|
|
229
|
+
rawType: context.types.rawTypeAt(pattern),
|
|
230
|
+
at: pattern
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
};
|
|
236
|
+
/** The `base`/`iterator` operand for a step, wired only when a source value is known. */
|
|
237
|
+
const sourceOperand = (role, known, type) => {
|
|
238
|
+
if (!known)
|
|
239
|
+
return { operands: [], edge: () => null };
|
|
240
|
+
const source = 'source' in known ? known.source : known;
|
|
241
|
+
return {
|
|
242
|
+
operands: [operand(role, 0, source, type, { kind: 'provenance' })],
|
|
243
|
+
edge: (to) => (source.kind === 'result' ? { kind: 'value', result: source.result, to, role, ordinal: 0 } : null)
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* A default-value fallback, modelled as its own operation: the requirement
|
|
248
|
+
* that it fire only when the extracted value is exactly `undefined` (never
|
|
249
|
+
* `null`) has no matching `OperandEvaluation.conditional` `takenWhen` --
|
|
250
|
+
* that vocabulary only has `nullish`, which is wrong here -- so the
|
|
251
|
+
* distinction lives in this operation's own identity (`default-value`)
|
|
252
|
+
* rather than being expressed through the shared conditional-edge mechanism.
|
|
253
|
+
*/
|
|
254
|
+
const contributeDefault = (candidate, source, extracted, valueType, initializer, fallbackType) => {
|
|
255
|
+
const cited = citeExpressionResult(initializer, context);
|
|
256
|
+
if (cited.kind === 'unmodelled')
|
|
257
|
+
return { blocked: cited.reason };
|
|
258
|
+
const operands = [
|
|
259
|
+
operand('extracted', 0, { kind: 'result', result: extracted }, valueType, { kind: 'provenance' }),
|
|
260
|
+
operand('fallback', 0, cited.source, fallbackType)
|
|
261
|
+
];
|
|
262
|
+
const id = mintOperationId(context.ordinals, context.identities.nodeIdOf(source), 'destructuring');
|
|
263
|
+
const op = buildOperation(id, candidate.caller, candidate.evaluationOrdinal, 'default-value', operands, valueType, normalCompletion, {
|
|
264
|
+
readsMutableState: false,
|
|
265
|
+
writesMutableState: false,
|
|
266
|
+
allocates: false,
|
|
267
|
+
callsUserCode: cited.source.kind === 'result'
|
|
268
|
+
});
|
|
269
|
+
const edges = [{ kind: 'value', result: extracted, to: id, role: 'extracted', ordinal: 0 }];
|
|
270
|
+
const fallbackEdge = resultEdge(cited.source, id, 'fallback', 0);
|
|
271
|
+
if (fallbackEdge)
|
|
272
|
+
edges.push(fallbackEdge);
|
|
273
|
+
return { ...op, edges };
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* The type an object pattern READS OUT of its source for one element, which
|
|
277
|
+
* for a defaulted element is not the type the name ends up bound to.
|
|
278
|
+
*
|
|
279
|
+
* `const { width = 10 } = options` over `{ width?: number }` desugars to a
|
|
280
|
+
* `[[Get]]` yielding `number | undefined` followed by a test against
|
|
281
|
+
* `undefined`. `typeAt(element)` answers the SECOND of those -- `number` --
|
|
282
|
+
* because that is what the name is bound to once the default has run, and
|
|
283
|
+
* typing the extraction with it leaves the `default-value` step testing a
|
|
284
|
+
* carrier with no absent state at all. That is not a refusal: `is-defined`
|
|
285
|
+
* over such a carrier is honestly `true` (`emit-presence.ts`), so the default
|
|
286
|
+
* arm becomes dead code and the extraction dereferences an empty optional --
|
|
287
|
+
* a program that aborts where the language answers `10`.
|
|
288
|
+
*
|
|
289
|
+
* So the property's own type is asked of the checker, which is the same
|
|
290
|
+
* question the language answers to type the pattern. An index signature
|
|
291
|
+
* answers for a key no declared member matches (`Record<string, number>`); a
|
|
292
|
+
* computed key, or a base with neither, has no static answer, and the type
|
|
293
|
+
* stays what it was -- the lowering then refuses the step by name, because a
|
|
294
|
+
* guard it cannot test is the one thing it must not approximate.
|
|
295
|
+
*/
|
|
296
|
+
const extractedTypeOf = (element, pattern) => {
|
|
297
|
+
const bound = context.types.typeAt(element);
|
|
298
|
+
// The census's own read first, as `extractedArrayTypeOf` asks it: a
|
|
299
|
+
// numeric key over a plain array reads `T | undefined` whether or not a
|
|
300
|
+
// default follows, and the name's bound type has no arm for the absence.
|
|
301
|
+
const censused = context.types.patternReadTypeAt(element);
|
|
302
|
+
if (censused)
|
|
303
|
+
return context.types.typeOf(censused);
|
|
304
|
+
if (!element.initializer)
|
|
305
|
+
return bound;
|
|
306
|
+
const name = element.propertyName ?? element.name;
|
|
307
|
+
const key = ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name) ? name.text : null;
|
|
308
|
+
if (key === null)
|
|
309
|
+
return bound;
|
|
310
|
+
// HOLDS: the value this pattern destructures, read the census-aware way
|
|
311
|
+
// (`context.types.rawTypeAt`, the raw-`ts.Type` form of the same answer
|
|
312
|
+
// `context.types.typeAt(node)` already gives `baseType` above) rather
|
|
313
|
+
// than the checker directly, so an untyped source parameter/local the
|
|
314
|
+
// census resolved is not silently re-widened to `any` here.
|
|
315
|
+
const base = context.types.rawTypeAt(pattern);
|
|
316
|
+
// The shared member-read authority (`derived-expression-type.ts`), the
|
|
317
|
+
// same one every other property read in this compiler goes through --
|
|
318
|
+
// rather than a second, narrower copy of `getPropertyOfType` +
|
|
319
|
+
// `getTypeOfSymbolAtLocation` with no `isUnusableEvidence`/overload
|
|
320
|
+
// handling of its own.
|
|
321
|
+
const member = memberTypeOf(context.checker, base, key, element);
|
|
322
|
+
if (member)
|
|
323
|
+
return context.types.typeOf(member);
|
|
324
|
+
const index = context.checker.getIndexTypeOfType(context.checker.getNonNullableType(base), ts.IndexKind.String);
|
|
325
|
+
return index ? context.types.typeOf(index) : bound;
|
|
326
|
+
};
|
|
327
|
+
const contributeObjectPattern = (candidate, node) => {
|
|
328
|
+
const elements = node.elements;
|
|
329
|
+
const known = patternSourceOperand(node);
|
|
330
|
+
const baseType = known?.type ?? context.types.typeAt(node);
|
|
331
|
+
const operations = [];
|
|
332
|
+
const edges = [];
|
|
333
|
+
const excludedKeys = [];
|
|
334
|
+
let previousId = null;
|
|
335
|
+
const chain = (id) => {
|
|
336
|
+
if (previousId)
|
|
337
|
+
edges.push({ kind: 'evaluation', from: previousId, to: id });
|
|
338
|
+
previousId = id;
|
|
339
|
+
};
|
|
340
|
+
for (const element of elements) {
|
|
341
|
+
if (element.dotDotDotToken)
|
|
342
|
+
continue; // rest is always last; handled below
|
|
343
|
+
const key = keyResolutionOf(element);
|
|
344
|
+
if ('blocked' in key) {
|
|
345
|
+
// Withholding the whole pattern (rather than the one bad element) keeps
|
|
346
|
+
// a partially-published pattern from letting a consumer read some
|
|
347
|
+
// names but not others with no signal that the set is incomplete.
|
|
348
|
+
return asBlocked(candidate.id, 'destructuring', `object binding pattern key ${key.blocked}`, 'P1');
|
|
349
|
+
}
|
|
350
|
+
excludedKeys.push(operand('excluded-key', excludedKeys.length, key.source, key.type));
|
|
351
|
+
const { operands: baseOperands, edge: baseEdge } = sourceOperand('base', known, baseType);
|
|
352
|
+
const operands = [operand('key', 0, key.source, key.type), ...baseOperands];
|
|
353
|
+
const valueType = extractedTypeOf(element, node);
|
|
354
|
+
const getId = mintOperationId(context.ordinals, context.identities.nodeIdOf(element), 'destructuring');
|
|
355
|
+
const getOperation = buildOperation(getId, candidate.caller, candidate.evaluationOrdinal, 'object-pattern', operands, valueType,
|
|
356
|
+
// [[Get]] on the source can throw: object destructuring requires
|
|
357
|
+
// RequireObjectCoercible on its source, and a getter can itself throw.
|
|
358
|
+
throwingCompletion, { readsMutableState: true, writesMutableState: false, allocates: false, callsUserCode: true });
|
|
359
|
+
operations.push(getOperation);
|
|
360
|
+
const edge = baseEdge(getId);
|
|
361
|
+
if (edge)
|
|
362
|
+
edges.push(edge);
|
|
363
|
+
const keyEdge = resultEdge(key.source, getId, 'key', 0);
|
|
364
|
+
if (keyEdge)
|
|
365
|
+
edges.push(keyEdge);
|
|
366
|
+
chain(getId);
|
|
367
|
+
const extracted = getOperation.results[0]?.id;
|
|
368
|
+
if (element.initializer && extracted) {
|
|
369
|
+
// The step's own type is what the NAME is bound to, which is the
|
|
370
|
+
// extraction's type with the absence already resolved away -- two
|
|
371
|
+
// different types for two different operations, where before both read
|
|
372
|
+
// the bound one.
|
|
373
|
+
const defaultResult = contributeDefault(candidate, element, extracted, context.types.typeAt(element), element.initializer, context.types.typeAt(element.initializer));
|
|
374
|
+
if ('blocked' in defaultResult) {
|
|
375
|
+
return asBlocked(candidate.id, 'destructuring', `object binding pattern default ${defaultResult.blocked}`, null);
|
|
376
|
+
}
|
|
377
|
+
operations.push(defaultResult);
|
|
378
|
+
edges.push(...defaultResult.edges);
|
|
379
|
+
// The default expression is part of IteratorBindingInitialization,
|
|
380
|
+
// not a side branch that may float past the next element. Keeping it
|
|
381
|
+
// in the evaluation chain both preserves left-to-right pattern order
|
|
382
|
+
// and makes the finite IteratorClose region include a throwing
|
|
383
|
+
// initializer before any later step or the normal trailing close.
|
|
384
|
+
chain(defaultResult.id);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// An EMPTY pattern still runs RequireObjectCoercible on its source
|
|
388
|
+
// (ECMA-262 BindingInitialization of `{}`): `function f({} = null) {}`
|
|
389
|
+
// throws a TypeError from `f()`. Every property step above checks its
|
|
390
|
+
// own holder, so this step is minted only when there is no step to do it
|
|
391
|
+
// -- exactly the assignment side's `object-source` operation.
|
|
392
|
+
if (elements.length === 0) {
|
|
393
|
+
const { operands: baseOperands, edge: baseEdge } = sourceOperand('base', known, baseType);
|
|
394
|
+
const coercibleId = mintOperationId(context.ordinals, context.identities.nodeIdOf(node), 'destructuring');
|
|
395
|
+
const coercible = buildOperation(coercibleId, candidate.caller, candidate.evaluationOrdinal, 'object-source', baseOperands, baseType, throwingCompletion, { readsMutableState: false, writesMutableState: false, allocates: false, callsUserCode: false });
|
|
396
|
+
operations.push(coercible);
|
|
397
|
+
const edge = baseEdge(coercibleId);
|
|
398
|
+
if (edge)
|
|
399
|
+
edges.push(edge);
|
|
400
|
+
chain(coercibleId);
|
|
401
|
+
}
|
|
402
|
+
const restElement = elements.find((element) => element.dotDotDotToken);
|
|
403
|
+
if (restElement) {
|
|
404
|
+
const { operands: baseOperands, edge: baseEdge } = sourceOperand('base', known, baseType);
|
|
405
|
+
const valueType = boundElementType(restElement, context);
|
|
406
|
+
const restId = mintOperationId(context.ordinals, context.identities.nodeIdOf(restElement), 'destructuring');
|
|
407
|
+
const restOperation = buildOperation(restId, candidate.caller, candidate.evaluationOrdinal, 'rest-element', [...excludedKeys, ...baseOperands], valueType, normalCompletion,
|
|
408
|
+
// CopyDataProperties allocates a fresh object from the remaining own
|
|
409
|
+
// enumerable properties; it does not re-run any of the prior [[Get]]s.
|
|
410
|
+
{ readsMutableState: true, writesMutableState: false, allocates: true, callsUserCode: false });
|
|
411
|
+
operations.push(restOperation);
|
|
412
|
+
const edge = baseEdge(restId);
|
|
413
|
+
if (edge)
|
|
414
|
+
edges.push(edge);
|
|
415
|
+
// Each excluded-key operand may itself cite a computed-key expression's
|
|
416
|
+
// result (see keyResolutionOf); that citation needs the same ValueEdge
|
|
417
|
+
// treatment as any other cross-operation operand source.
|
|
418
|
+
for (const excludedKey of excludedKeys) {
|
|
419
|
+
const excludedEdge = resultEdge(excludedKey.source, restId, excludedKey.role, excludedKey.ordinal);
|
|
420
|
+
if (excludedEdge)
|
|
421
|
+
edges.push(excludedEdge);
|
|
422
|
+
}
|
|
423
|
+
chain(restId);
|
|
424
|
+
}
|
|
425
|
+
return { kind: 'operations', operations, edges };
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* The type an array pattern READS for one position -- the array-side twin
|
|
429
|
+
* of `extractedTypeOf`. A tuple source states its positions, so the step
|
|
430
|
+
* reads that position's own type (an unstated position past the tuple's
|
|
431
|
+
* end reads `undefined`). Any other array answers its element WITH
|
|
432
|
+
* `undefined`: the iterator may be exhausted before this position (ECMA-262
|
|
433
|
+
* IteratorBindingInitialization step "If iteratorRecord.[[done]] is true,
|
|
434
|
+
* let v be undefined"), and typing the read with the name's bound type
|
|
435
|
+
* would leave a `default-value` step testing a carrier with no absent state
|
|
436
|
+
* -- the exact abort-instead-of-default `extractedTypeOf` documents.
|
|
437
|
+
*/
|
|
438
|
+
/**
|
|
439
|
+
* The element carrier of the pattern's own PUBLISHED source, when that source
|
|
440
|
+
* is an array -- `null` whenever it is anything else.
|
|
441
|
+
*
|
|
442
|
+
* `structural.ts`'s `binding-pattern-is-its-source` is the authority on which
|
|
443
|
+
* expression an erasing assertion leaves a pattern reading, and the source
|
|
444
|
+
* operand (`patternSourceOperand`) takes its type from there. This asks that
|
|
445
|
+
* one published answer rather than re-deriving it from the raw checker type,
|
|
446
|
+
* so the element this step reads and the element `lower-destructuring.ts`
|
|
447
|
+
* indexes out of the same value are interned once, not twice.
|
|
448
|
+
*/
|
|
449
|
+
const arrayPatternSourceElementOf = (pattern) => {
|
|
450
|
+
const shape = context.table.get(context.types.typeAt(pattern)).shape;
|
|
451
|
+
return shape.kind === 'array' ? shape.element : null;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* What position `index` reads out of the pattern's own PUBLISHED source when
|
|
455
|
+
* that source is a UNION of fixed-arity tuples -- the union of what each arm
|
|
456
|
+
* states there, plus `undefined` when an arm is too short to reach it.
|
|
457
|
+
* `null` for every other source.
|
|
458
|
+
*
|
|
459
|
+
* The sibling of `arrayPatternSourceElementOf`, for the one source shape that
|
|
460
|
+
* has positions rather than a single element, and asking the same published
|
|
461
|
+
* answer for the same reason.
|
|
462
|
+
*
|
|
463
|
+
* The checker flattens such a union to its NUMBER-INDEX type -- `number |
|
|
464
|
+
* string | boolean` for `[number, string] | [number, boolean]` -- so the
|
|
465
|
+
* general branch below typed position 0 as that whole union plus `undefined`.
|
|
466
|
+
* The value is read the other way: `hasNativeIterationCursor`
|
|
467
|
+
* (producers/shared.ts) admits a union of fixed-arity tuples as closed-shape,
|
|
468
|
+
* so no iterator record stands between the pattern and the value, and
|
|
469
|
+
* `ir/lower-destructuring.ts`'s tuple-union path reads position `index` off
|
|
470
|
+
* whichever ARM is live and checks it against THIS step's carrier. It then
|
|
471
|
+
* refused the flattened answer by name -- "not every arm of this union
|
|
472
|
+
* answers this position with the same carrier" -- about arms that all answer
|
|
473
|
+
* it identically. hono's `HonoRequest.routePath` over `Result<T> = [[T,
|
|
474
|
+
* ParamIndexMap][], ParamStash] | [[T, Params][]]` is the measured case.
|
|
475
|
+
*
|
|
476
|
+
* `isFixedArityTupleType` because that is the predicate the source was
|
|
477
|
+
* admitted by: the two must agree, or this would state positions for a source
|
|
478
|
+
* the producer had already routed through the iterator protocol.
|
|
479
|
+
*/
|
|
480
|
+
const arrayPatternSourcePositionOf = (pattern, index) => {
|
|
481
|
+
const shape = context.table.get(context.types.typeAt(pattern)).shape;
|
|
482
|
+
if (shape.kind !== 'union' || shape.members.length === 0)
|
|
483
|
+
return null;
|
|
484
|
+
if (!shape.members.every((member) => isFixedArityTupleType(context, member)))
|
|
485
|
+
return null;
|
|
486
|
+
const members = [];
|
|
487
|
+
for (const member of shape.members) {
|
|
488
|
+
const arm = context.table.get(member).shape;
|
|
489
|
+
if (arm.kind !== 'tuple')
|
|
490
|
+
return null;
|
|
491
|
+
const position = arm.elements[index];
|
|
492
|
+
const type = position === undefined ? context.table.intern({ kind: 'primitive', primitive: 'undefined' }) : position.type;
|
|
493
|
+
if (!members.includes(type))
|
|
494
|
+
members.push(type);
|
|
495
|
+
}
|
|
496
|
+
const only = members.length === 1 ? members[0] : undefined;
|
|
497
|
+
return only ?? context.table.intern({ kind: 'union', members });
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* One position's read type, reconciled with the ARRAY the step physically
|
|
501
|
+
* indexes.
|
|
502
|
+
*
|
|
503
|
+
* Every answer below -- the census's, the raw type's tuple positions -- is a
|
|
504
|
+
* statement about what the program says is AT a position. When the pattern's
|
|
505
|
+
* published source is an array, `lower-destructuring.ts` reads the position
|
|
506
|
+
* out of that array and requires this step's carrier to be its element (or
|
|
507
|
+
* that plus the `undefined` a read past the end yields), because indexing an
|
|
508
|
+
* `array-object` cannot produce anything else. Two shapes reach that
|
|
509
|
+
* disagreement: a tuple ASSERTION over an array -- `const [createEvents,
|
|
510
|
+
* options] = args as [(c: Ctx) => Events, number?]`, hono's
|
|
511
|
+
* `defineWebSocketHelper` -- and a rest parameter whose checker tuple this
|
|
512
|
+
* compiler already collapsed to the one Array the language binds. Neither
|
|
513
|
+
* converts anything.
|
|
514
|
+
*
|
|
515
|
+
* The statement is not lost: `boundElementType` declares the NAME with it and
|
|
516
|
+
* the narrowing happens on the store, exactly as `arr[0] as F` already
|
|
517
|
+
* narrows an array read of a union.
|
|
518
|
+
*
|
|
519
|
+
* An answer that already CONTAINS the source's element -- it is that element,
|
|
520
|
+
* or a union carrying it beside the read's absence -- is left exactly alone,
|
|
521
|
+
* so every pattern that lowers today keeps the carrier it lowers with and
|
|
522
|
+
* only a genuine disagreement is re-homed.
|
|
523
|
+
*/
|
|
524
|
+
const reconciledWithSourceElement = (answer, pattern) => {
|
|
525
|
+
const sourceElement = arrayPatternSourceElementOf(pattern);
|
|
526
|
+
// Opt-in, because three authorities can publish this one read -- the
|
|
527
|
+
// pattern census, the raw type's tuple positions, and the source array's
|
|
528
|
+
// own element -- and the lowering's refusal names the carrier without
|
|
529
|
+
// naming which of them produced it.
|
|
530
|
+
if (process.env['GEA_DEBUG_PATTERN']) {
|
|
531
|
+
process.stderr.write(`[PATTERN] ${pattern.getText().slice(0, 60).replace(/\n/g, ' ')} answer=${answer} source=${sourceElement ?? 'none'}\n`);
|
|
532
|
+
}
|
|
533
|
+
if (sourceElement === null || answer === sourceElement)
|
|
534
|
+
return answer;
|
|
535
|
+
const shape = context.table.get(answer).shape;
|
|
536
|
+
if (shape.kind === 'union' && shape.members.includes(sourceElement))
|
|
537
|
+
return answer;
|
|
538
|
+
return context.table.intern({
|
|
539
|
+
kind: 'union',
|
|
540
|
+
members: [sourceElement, context.table.intern({ kind: 'primitive', primitive: 'undefined' })]
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
const extractedArrayTypeOf = (element, pattern) => {
|
|
544
|
+
const bound = context.types.typeAt(element);
|
|
545
|
+
// The census's own answer first: a parameter's pattern has no single raw
|
|
546
|
+
// source type when the census settled its callers as union arms.
|
|
547
|
+
const censused = context.types.patternReadTypeAt(element);
|
|
548
|
+
if (censused)
|
|
549
|
+
return reconciledWithSourceElement(context.types.typeOf(censused), pattern);
|
|
550
|
+
const base = context.checker.getNonNullableType(context.types.rawTypeAt(pattern));
|
|
551
|
+
// A position the source can never fill -- past a tuple's end, or any
|
|
552
|
+
// position of an array whose element is uninhabited (`[]` is `never[]`)
|
|
553
|
+
// -- reads `undefined`, spelled in the NAME's own carrier with the absence
|
|
554
|
+
// (`T | undefined`, not bare `undefined`) so the default that resolves it
|
|
555
|
+
// merges two arms of one carrier rather than converting nothing into `T`.
|
|
556
|
+
const absent = () => context.types.typeOf(context.checker.getNullableType(context.types.rawTypeAt(element), ts.TypeFlags.Undefined));
|
|
557
|
+
if (context.checker.isTupleType(base)) {
|
|
558
|
+
const stated = context.checker.getTypeArguments(base)[pattern.elements.indexOf(element)];
|
|
559
|
+
return reconciledWithSourceElement(stated === undefined ? absent() : context.types.typeOf(stated), pattern);
|
|
560
|
+
}
|
|
561
|
+
// Asked before the number-index fallback, which is what flattens a union of
|
|
562
|
+
// tuples into one element type; `arrayPatternSourcePositionOf` states why.
|
|
563
|
+
const position = arrayPatternSourcePositionOf(pattern, pattern.elements.indexOf(element));
|
|
564
|
+
if (position !== null)
|
|
565
|
+
return position;
|
|
566
|
+
const indexed = context.checker.getIndexTypeOfType(base, ts.IndexKind.Number);
|
|
567
|
+
if (!indexed) {
|
|
568
|
+
// A non-array iterable -- a generator, a Set, a Map -- reads what it
|
|
569
|
+
// yields, with the same `undefined` a plain array's position carries:
|
|
570
|
+
// the cursor may be exhausted before this position, and the name's
|
|
571
|
+
// bound type (bare `number` for `var [a, b] = g()`) has no arm for it.
|
|
572
|
+
const yielded = iteratorYieldStructuralType(context, base, pattern);
|
|
573
|
+
if (yielded === null)
|
|
574
|
+
return bound;
|
|
575
|
+
return context.table.intern({
|
|
576
|
+
kind: 'union',
|
|
577
|
+
members: [yielded, context.table.intern({ kind: 'primitive', primitive: 'undefined' })]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
if ((indexed.flags & ts.TypeFlags.Never) !== 0)
|
|
581
|
+
return absent();
|
|
582
|
+
if (isUnusableEvidence(indexed))
|
|
583
|
+
return bound;
|
|
584
|
+
return context.types.typeOf(context.checker.getNullableType(indexed, ts.TypeFlags.Undefined));
|
|
585
|
+
};
|
|
586
|
+
const contributeArrayPattern = (candidate, node) => {
|
|
587
|
+
const source = candidate.id;
|
|
588
|
+
const known = patternSourceOperand(node);
|
|
589
|
+
// The pattern node is contextually typed as an Array even when the value
|
|
590
|
+
// it consumes was declared `any`/`unknown`. Carry the source's own type
|
|
591
|
+
// beside its citation so the iterator-record remains the authorized
|
|
592
|
+
// dynamic carrier; using the pattern's requested view here would invent
|
|
593
|
+
// an ArrayObject projection before `Array.isArray` had proved anything.
|
|
594
|
+
const baseType = known?.type ?? context.types.typeAt(node);
|
|
595
|
+
const operations = [];
|
|
596
|
+
const edges = [];
|
|
597
|
+
let previousId = null;
|
|
598
|
+
const chain = (id) => {
|
|
599
|
+
if (previousId)
|
|
600
|
+
edges.push({ kind: 'evaluation', from: previousId, to: id });
|
|
601
|
+
previousId = id;
|
|
602
|
+
};
|
|
603
|
+
// GetIterator runs once, up front, regardless of how many elements follow
|
|
604
|
+
// (even `const [] = x` acquires and then closes an iterator), and publishes
|
|
605
|
+
// the iterator record every subsequent `next()` step consumes -- a step
|
|
606
|
+
// advances the SHARED iterator, never the original base value again.
|
|
607
|
+
let iteratorRecord = null;
|
|
608
|
+
let iteratorType = baseType;
|
|
609
|
+
const typedCustom = known !== null && !isDynamicIterationSource(context, baseType) && !hasNativeIterationCursor(context, baseType);
|
|
610
|
+
if (typedCustom) {
|
|
611
|
+
const steps = mintIteratorSteps(context, candidate, 'iterator', { source: known.source, type: baseType, iterated: known.at, rawIterated: known.rawType }, { includeGetMethod: true, includeClose: false, includeNext: false });
|
|
612
|
+
operations.push(...steps.operations);
|
|
613
|
+
edges.push(...steps.edges);
|
|
614
|
+
for (const step of steps.operations)
|
|
615
|
+
edges.push(...valueEdgesInto(step.id, step.operands));
|
|
616
|
+
iteratorRecord = steps.iteratorRecord;
|
|
617
|
+
iteratorType = steps.recordType;
|
|
618
|
+
previousId = steps.operations[steps.operations.length - 1]?.id ?? null;
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
const { operands, edge: baseEdge } = sourceOperand('base', known, baseType);
|
|
622
|
+
const id = mintOperationId(context.ordinals, source, 'destructuring');
|
|
623
|
+
const result = mintResult(id, 'iterator-record', baseType);
|
|
624
|
+
const getIterator = {
|
|
625
|
+
id,
|
|
626
|
+
caller: candidate.caller,
|
|
627
|
+
operands,
|
|
628
|
+
results: [result],
|
|
629
|
+
completion: throwingCompletion,
|
|
630
|
+
effects: { readsMutableState: true, writesMutableState: false, allocates: true, callsUserCode: true },
|
|
631
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
632
|
+
family: 'destructuring',
|
|
633
|
+
form: 'array-pattern'
|
|
634
|
+
};
|
|
635
|
+
operations.push(getIterator);
|
|
636
|
+
const edge = baseEdge(id);
|
|
637
|
+
if (edge)
|
|
638
|
+
edges.push(edge);
|
|
639
|
+
chain(id);
|
|
640
|
+
iteratorRecord = result.id;
|
|
641
|
+
}
|
|
642
|
+
for (const element of node.elements) {
|
|
643
|
+
const iteratorSource = iteratorRecord ? { kind: 'result', result: iteratorRecord } : null;
|
|
644
|
+
const { operands: iterOperands, edge: iterEdge } = sourceOperand('iterator', iteratorSource, iteratorType);
|
|
645
|
+
if (ts.isOmittedExpression(element)) {
|
|
646
|
+
// An elision still steps the iterator, discarding the value: no result
|
|
647
|
+
// is published because nothing is bound to the discarded position.
|
|
648
|
+
const id = mintOperationId(context.ordinals, source, 'destructuring');
|
|
649
|
+
const op = buildOperation(id, candidate.caller, candidate.evaluationOrdinal, 'array-pattern', iterOperands, null, throwingCompletion, {
|
|
650
|
+
readsMutableState: true,
|
|
651
|
+
writesMutableState: false,
|
|
652
|
+
allocates: false,
|
|
653
|
+
callsUserCode: true
|
|
654
|
+
});
|
|
655
|
+
operations.push(op);
|
|
656
|
+
const edge = iterEdge(id);
|
|
657
|
+
if (edge)
|
|
658
|
+
edges.push(edge);
|
|
659
|
+
chain(id);
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
if (element.dotDotDotToken) {
|
|
663
|
+
const valueType = context.types.typeAt(element);
|
|
664
|
+
const id = mintOperationId(context.ordinals, context.identities.nodeIdOf(element), 'destructuring');
|
|
665
|
+
const op = buildOperation(id, candidate.caller, candidate.evaluationOrdinal, 'rest-element', iterOperands, valueType, throwingCompletion, {
|
|
666
|
+
readsMutableState: true,
|
|
667
|
+
writesMutableState: false,
|
|
668
|
+
allocates: true,
|
|
669
|
+
callsUserCode: true
|
|
670
|
+
});
|
|
671
|
+
operations.push(op);
|
|
672
|
+
const edge = iterEdge(id);
|
|
673
|
+
if (edge)
|
|
674
|
+
edges.push(edge);
|
|
675
|
+
chain(id);
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
const valueType = extractedArrayTypeOf(element, node);
|
|
679
|
+
const stepId = mintOperationId(context.ordinals, context.identities.nodeIdOf(element), 'destructuring');
|
|
680
|
+
const stepOperation = buildOperation(stepId, candidate.caller, candidate.evaluationOrdinal, 'array-pattern', iterOperands, valueType, throwingCompletion, {
|
|
681
|
+
readsMutableState: true,
|
|
682
|
+
writesMutableState: false,
|
|
683
|
+
allocates: false,
|
|
684
|
+
callsUserCode: true
|
|
685
|
+
});
|
|
686
|
+
operations.push(stepOperation);
|
|
687
|
+
const edge = iterEdge(stepId);
|
|
688
|
+
if (edge)
|
|
689
|
+
edges.push(edge);
|
|
690
|
+
chain(stepId);
|
|
691
|
+
const extracted = stepOperation.results[0]?.id;
|
|
692
|
+
if (element.initializer && extracted) {
|
|
693
|
+
// Same split as the object pattern above: the step reads with the
|
|
694
|
+
// absence, the name is bound to the type the default resolves it to.
|
|
695
|
+
const defaultResult = contributeDefault(candidate, element, extracted, context.types.typeAt(element), element.initializer, context.types.typeAt(element.initializer));
|
|
696
|
+
if ('blocked' in defaultResult) {
|
|
697
|
+
return asBlocked(candidate.id, 'destructuring', `array binding pattern default ${defaultResult.blocked}`, null);
|
|
698
|
+
}
|
|
699
|
+
operations.push(defaultResult);
|
|
700
|
+
edges.push(...defaultResult.edges);
|
|
701
|
+
chain(defaultResult.id);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
// IteratorBindingInitialization closes a still-open iterator when a
|
|
705
|
+
// finite pattern stops before exhaustion. A rest element drains instead,
|
|
706
|
+
// so it has no trailing close. Dynamic sources and native generators are
|
|
707
|
+
// the two stateful iterator carriers this pattern currently acquires;
|
|
708
|
+
// typed arrays/tuples retain their positional fast paths.
|
|
709
|
+
if (iteratorRecord &&
|
|
710
|
+
finitePatternNeedsClose(baseType) &&
|
|
711
|
+
!node.elements.some((element) => ts.isBindingElement(element) && element.dotDotDotToken !== undefined)) {
|
|
712
|
+
const id = mintOperationId(context.ordinals, source, 'destructuring');
|
|
713
|
+
const close = {
|
|
714
|
+
id,
|
|
715
|
+
caller: candidate.caller,
|
|
716
|
+
operands: [operand('iterator', 0, { kind: 'result', result: iteratorRecord }, iteratorType, { kind: 'provenance' })],
|
|
717
|
+
results: [mintResult(id, 'completion', context.table.intern({ kind: 'primitive', primitive: 'void' }))],
|
|
718
|
+
completion: throwingCompletion,
|
|
719
|
+
effects: { readsMutableState: true, writesMutableState: false, allocates: false, callsUserCode: true },
|
|
720
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
721
|
+
family: 'destructuring',
|
|
722
|
+
form: 'array-pattern-close'
|
|
723
|
+
};
|
|
724
|
+
const predecessor = operations[operations.length - 1]?.id ?? null;
|
|
725
|
+
operations.push(close);
|
|
726
|
+
edges.push({ kind: 'value', result: iteratorRecord, to: id, role: 'iterator', ordinal: 0 });
|
|
727
|
+
if (predecessor)
|
|
728
|
+
edges.push({ kind: 'evaluation', from: predecessor, to: id });
|
|
729
|
+
previousId = id;
|
|
730
|
+
}
|
|
731
|
+
return { kind: 'operations', operations, edges };
|
|
732
|
+
};
|
|
733
|
+
const undefinedType = context.table.intern({ kind: 'primitive', primitive: 'undefined' });
|
|
734
|
+
/**
|
|
735
|
+
* Every member a union structural type holds, recursively flattened --
|
|
736
|
+
* `extractedArrayAssignmentTypeOf`'s own "array element, unioned with the
|
|
737
|
+
* absence a past-the-length read hands back" formula nests a SECOND union
|
|
738
|
+
* one level up from a nested pattern's own position (`row: (number |
|
|
739
|
+
* number[])[]`'s position 1 reads `union[union[number, number[]],
|
|
740
|
+
* undefined]`, not a flat three-armed one), and this is what lets the
|
|
741
|
+
* search below see through that nesting without caring how many levels
|
|
742
|
+
* deep it is.
|
|
743
|
+
*/
|
|
744
|
+
const flattenedUnionMembers = (id, seen = new Set()) => {
|
|
745
|
+
if (seen.has(id))
|
|
746
|
+
return [];
|
|
747
|
+
seen.add(id);
|
|
748
|
+
const shape = context.table.get(id).shape;
|
|
749
|
+
return shape.kind === 'union' ? shape.members.flatMap((member) => flattenedUnionMembers(member, seen)) : [id];
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* The one member of a union that is itself an 'array'/'tuple' shape --
|
|
753
|
+
* `number | number[]`, a plain array's own element type that is itself a
|
|
754
|
+
* union, where only the array arm supports a NESTED pattern's own
|
|
755
|
+
* positional read at all (`representation/model.ts`'s
|
|
756
|
+
* `soleArrayPatternCapableArm` is the identical question asked of the
|
|
757
|
+
* REPRESENTATION this becomes, once one exists; this is its structural
|
|
758
|
+
* twin, asked before one does, so `b`/`c` in `[a, [b, c]] = row` are typed
|
|
759
|
+
* `number` rather than falling through to whatever `bound` answers for a
|
|
760
|
+
* bare, unannotated `var`). `null` for zero such members, or for more than
|
|
761
|
+
* one -- `number[] | string[]` is a genuine ambiguity this compiler does
|
|
762
|
+
* not resolve, and returning `null` here is what keeps this function
|
|
763
|
+
* falling through to `bound` for it rather than guessing.
|
|
764
|
+
*/
|
|
765
|
+
const soleArrayPatternCapableMember = (id) => {
|
|
766
|
+
const capable = flattenedUnionMembers(id).filter((member) => {
|
|
767
|
+
const kind = context.table.get(member).shape.kind;
|
|
768
|
+
return kind === 'array' || kind === 'tuple';
|
|
769
|
+
});
|
|
770
|
+
return capable.length === 1 ? (capable[0] ?? null) : null;
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* The array-assignment twin of `extractedArrayTypeOf` -- the type a
|
|
774
|
+
* position reads BEFORE any default, for a target that is not a
|
|
775
|
+
* `BindingElement`. There is no parameter-census shortcut to try first
|
|
776
|
+
* (`patternReadTypeAt` binds only a formal parameter's own pattern), so
|
|
777
|
+
* this asks the STRUCTURAL shape of the source directly -- a stated tuple
|
|
778
|
+
* position, or an array element widened with the absence a position past
|
|
779
|
+
* the source's length reads -- rather than asking the checker about the
|
|
780
|
+
* PATTERN node's own raw type, the way `extractedArrayTypeOf` safely can
|
|
781
|
+
* for a binding pattern (whose `rawTypeAt` already recurses to its source
|
|
782
|
+
* via `mapper.typeAt`'s own binding-pattern branch). An `ArrayLiteralExpression`
|
|
783
|
+
* written as an assignment TARGET has no such branch: the checker's own
|
|
784
|
+
* answer for it is a contextually-typed TUPLE matching the target's own
|
|
785
|
+
* element types, not the source's -- exactly the `baseType` trap
|
|
786
|
+
* `arrayAssignmentSourceInfo` documents for the pattern's own iterator-record
|
|
787
|
+
* type, so this reads the same already-correct STRUCTURAL answer instead.
|
|
788
|
+
*
|
|
789
|
+
* A `union` base -- a NESTED pattern's own `baseType`, fed by the enclosing
|
|
790
|
+
* pattern's per-position read (`arrayAssignmentSourceInfo`'s nested branch)
|
|
791
|
+
* -- recurses into whichever one member of it is array/tuple-shaped, so a
|
|
792
|
+
* plain array's own union-typed element (`number | number[]`) is read the
|
|
793
|
+
* SAME way a bare array/tuple base already is, rather than falling through
|
|
794
|
+
* to the checker's `bound` (`any`, for an unannotated bare `var`).
|
|
795
|
+
*/
|
|
796
|
+
const extractedArrayAssignmentTypeOf = (target, position, baseType) => {
|
|
797
|
+
const bound = context.types.typeAt(target);
|
|
798
|
+
const shape = context.table.get(baseType).shape;
|
|
799
|
+
if (shape.kind === 'tuple') {
|
|
800
|
+
const stated = shape.elements[position];
|
|
801
|
+
return stated ? stated.type : context.table.intern({ kind: 'union', members: [bound, undefinedType] });
|
|
802
|
+
}
|
|
803
|
+
if (shape.kind === 'array') {
|
|
804
|
+
return context.table.intern({ kind: 'union', members: [shape.element, undefinedType] });
|
|
805
|
+
}
|
|
806
|
+
if (shape.kind === 'union') {
|
|
807
|
+
const capable = soleArrayPatternCapableMember(baseType);
|
|
808
|
+
if (capable !== null)
|
|
809
|
+
return extractedArrayAssignmentTypeOf(target, position, capable);
|
|
810
|
+
}
|
|
811
|
+
return bound;
|
|
812
|
+
};
|
|
813
|
+
/**
|
|
814
|
+
* The FINAL type an array-assignment target position is written with --
|
|
815
|
+
* post-default for a defaulted target, the SOURCE's own array type for a
|
|
816
|
+
* rest target, and the raw extraction type for a bare one. Shared by the
|
|
817
|
+
* pattern's own contribution (to type its default/rest operations) and the
|
|
818
|
+
* write contribution (to type the value it stores), so the two can never
|
|
819
|
+
* publish a store the extraction disagrees with.
|
|
820
|
+
*/
|
|
821
|
+
const arrayAssignmentBoundTypeOf = (target) => {
|
|
822
|
+
const info = arrayAssignmentSourceInfo(target.pattern);
|
|
823
|
+
const baseType = info?.type ?? context.types.typeAt(target.pattern);
|
|
824
|
+
if (ts.isBinaryExpression(target.keyNode))
|
|
825
|
+
return context.types.typeAt(target.keyNode.left);
|
|
826
|
+
if (ts.isSpreadElement(target.keyNode)) {
|
|
827
|
+
// A rest target over a plain array IS that array's own type -- the
|
|
828
|
+
// structural twin of `structural.ts`'s `arrayPatternRestTypeAt`, which
|
|
829
|
+
// covers only a BINDING pattern's rest element. Asking the checker
|
|
830
|
+
// about the target IDENTIFIER instead (`r` in `[a, ...r] = xs`) answers
|
|
831
|
+
// whatever `r`'s own declaration states, which for an unannotated `var`
|
|
832
|
+
// used only as an assignment target is `any` -- a second authority that
|
|
833
|
+
// disagreed with the rest OPERATION's own array-of-source-element
|
|
834
|
+
// carrier and left the write refusing to store what the read produced.
|
|
835
|
+
const shape = context.table.get(baseType).shape;
|
|
836
|
+
if (shape.kind === 'array')
|
|
837
|
+
return baseType;
|
|
838
|
+
return context.types.typeAt(target.keyNode.expression);
|
|
839
|
+
}
|
|
840
|
+
return extractedArrayAssignmentTypeOf(target.keyNode, target.position, baseType);
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* This array pattern's own source value AND type -- the assignment-side
|
|
844
|
+
* twin of `patternSourceOperand`. Three shapes: the top-level case
|
|
845
|
+
* (`[a,b] = rhs`), the nested case (`[a, [b]] = [1, [2]]`, recomputing the
|
|
846
|
+
* sibling position's extraction identity exactly as `patternSourceOperand`'s
|
|
847
|
+
* own nested case does for a binding pattern), and a loop-head pattern with
|
|
848
|
+
* no declaration keyword (`for ([a,b] of pairs)`), which reads the loop's
|
|
849
|
+
* own `next` result the identical fixed way `patternSourceOperand`'s for-of
|
|
850
|
+
* branch does.
|
|
851
|
+
*
|
|
852
|
+
* The TYPE travels with the source rather than coming from
|
|
853
|
+
* `context.types.typeAt(pattern)`, because that question has no good answer
|
|
854
|
+
* for an array literal in TARGET position: `mapper.typeAt`'s own early
|
|
855
|
+
* branch recurses a BINDING pattern's type to its source for exactly this
|
|
856
|
+
* reason, but has no such branch for an `ArrayLiteralExpression` written as
|
|
857
|
+
* an assignment target, so the checker's raw answer is whatever contextual
|
|
858
|
+
* TUPLE type it gave the literal -- which disagreed with the plain-array
|
|
859
|
+
* carrier the source itself resolves to and left the pattern's own
|
|
860
|
+
* `iterator-record` requiring a representation nothing could satisfy.
|
|
861
|
+
* `contributeObjectAssignmentSource` avoids the identical trap by typing
|
|
862
|
+
* its `object-source` operation from the cited source, never from the
|
|
863
|
+
* pattern node; this is that same fix for the array-shaped sibling.
|
|
864
|
+
*/
|
|
865
|
+
const arrayAssignmentSourceInfo = (pattern) => {
|
|
866
|
+
const topLevel = arrayAssignmentSource(pattern);
|
|
867
|
+
if (topLevel) {
|
|
868
|
+
const cited = citeExpressionResult(topLevel, context);
|
|
869
|
+
return cited.kind === 'source'
|
|
870
|
+
? {
|
|
871
|
+
source: cited.source,
|
|
872
|
+
type: context.types.typeAt(topLevel),
|
|
873
|
+
rawType: context.types.rawTypeAt(topLevel),
|
|
874
|
+
at: topLevel
|
|
875
|
+
}
|
|
876
|
+
: null;
|
|
877
|
+
}
|
|
878
|
+
const nested = arrayAssignmentTargetOf(pattern);
|
|
879
|
+
if (nested) {
|
|
880
|
+
const id = operationId(context.identities.nodeIdOf(nested.keyNode), 'destructuring', nested.defaulted ? 1 : 0);
|
|
881
|
+
const outer = arrayAssignmentSourceInfo(nested.pattern);
|
|
882
|
+
const outerRaw = outer ? context.checker.getNonNullableType(outer.rawType) : null;
|
|
883
|
+
const positional = outerRaw && context.checker.isTupleType(outerRaw)
|
|
884
|
+
? context.checker.getTypeArguments(outerRaw)[nested.position]
|
|
885
|
+
: outerRaw
|
|
886
|
+
? context.checker.getIndexTypeOfType(outerRaw, ts.IndexKind.Number)
|
|
887
|
+
: undefined;
|
|
888
|
+
const yielded = !positional && outer ? iteratorYieldTypesOf(context.checker, outerRaw, outer.at) : null;
|
|
889
|
+
return {
|
|
890
|
+
source: { kind: 'result', result: semanticResultId(id, 'value') },
|
|
891
|
+
type: arrayAssignmentBoundTypeOf(nested),
|
|
892
|
+
rawType: positional ?? (yielded?.length === 1 ? (yielded[0] ?? context.types.rawTypeAt(pattern)) : context.types.rawTypeAt(pattern)),
|
|
893
|
+
at: pattern
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
const parent = pattern.parent;
|
|
897
|
+
if (ts.isForOfStatement(parent) && parent.initializer === pattern) {
|
|
898
|
+
const id = operationId(context.identities.nodeIdOf(parent), 'protocol', 2);
|
|
899
|
+
// `context.types.typeAt(pattern)` asks the PATTERN's own type again --
|
|
900
|
+
// the exact trap `arrayAssignmentSourceInfo`'s other two branches exist
|
|
901
|
+
// to avoid (see the top-level `=` branch's own comment). A binding
|
|
902
|
+
// pattern's declaration node is real declaration syntax the checker
|
|
903
|
+
// types correctly on its own; an array LITERAL standing in the same
|
|
904
|
+
// loop-head position is not, so this asks the loop's own ITERABLE for
|
|
905
|
+
// its element type instead -- the one authority that actually states
|
|
906
|
+
// what each iteration hands the pattern.
|
|
907
|
+
const iterable = context.types.typeAt(parent.expression);
|
|
908
|
+
const shape = context.table.get(iterable).shape;
|
|
909
|
+
const type = shape.kind === 'array' ? shape.element : context.types.typeAt(pattern);
|
|
910
|
+
const iterableRaw = context.checker.getNonNullableType(context.types.rawTypeAt(parent.expression));
|
|
911
|
+
const yielded = iteratorYieldTypesOf(context.checker, iterableRaw, parent.expression);
|
|
912
|
+
return {
|
|
913
|
+
source: { kind: 'result', result: semanticResultId(id, 'value') },
|
|
914
|
+
type,
|
|
915
|
+
rawType: yielded?.length === 1 ? (yielded[0] ?? context.types.rawTypeAt(pattern)) : context.types.rawTypeAt(pattern),
|
|
916
|
+
at: pattern
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
};
|
|
921
|
+
/**
|
|
922
|
+
* An array ASSIGNMENT pattern's read side: `[a, b] = rhs`, `[a, ...r] = xs`,
|
|
923
|
+
* `[x = 3] = []`, `[a, [b]] = [1, [2]]`. The same GetIterator + per-position
|
|
924
|
+
* `array-pattern`/`rest-element`/`default-value` operations
|
|
925
|
+
* `contributeArrayPattern` publishes for a BINDING pattern, over elements
|
|
926
|
+
* that are ordinary expressions instead of `BindingElement`s -- there is no
|
|
927
|
+
* write here, unlike the binding case's own `initialize`: a simple target
|
|
928
|
+
* (identifier/property/element access) writes through its OWN candidate,
|
|
929
|
+
* `contributeArrayAssignmentWrite` below, the same split
|
|
930
|
+
* `citeBoundElementValue`/`contributeBindingElement` already keep between
|
|
931
|
+
* extraction and introduction. A nested pattern target needs no write here
|
|
932
|
+
* either -- it is itself a `destructuring` candidate, and
|
|
933
|
+
* `arrayAssignmentSourceInfo` above is what lets it cite this pattern's own
|
|
934
|
+
* per-position extraction instead of guessing at one.
|
|
935
|
+
*/
|
|
936
|
+
const contributeArrayAssignmentPattern = (candidate, node) => {
|
|
937
|
+
const source = candidate.id;
|
|
938
|
+
const info = arrayAssignmentSourceInfo(node);
|
|
939
|
+
const known = info?.source ?? null;
|
|
940
|
+
const baseType = info?.type ?? context.types.typeAt(node);
|
|
941
|
+
const operations = [];
|
|
942
|
+
const edges = [];
|
|
943
|
+
let previousId = null;
|
|
944
|
+
const chain = (id) => {
|
|
945
|
+
if (previousId)
|
|
946
|
+
edges.push({ kind: 'evaluation', from: previousId, to: id });
|
|
947
|
+
previousId = id;
|
|
948
|
+
};
|
|
949
|
+
let iteratorRecord = null;
|
|
950
|
+
let iteratorType = baseType;
|
|
951
|
+
const typedCustom = info !== null && !isDynamicIterationSource(context, baseType) && !hasNativeIterationCursor(context, baseType);
|
|
952
|
+
if (typedCustom) {
|
|
953
|
+
const steps = mintIteratorSteps(context, candidate, 'iterator', { source: info.source, type: baseType, iterated: info.at, rawIterated: info.rawType }, { includeGetMethod: true, includeClose: false, includeNext: false });
|
|
954
|
+
operations.push(...steps.operations);
|
|
955
|
+
edges.push(...steps.edges);
|
|
956
|
+
for (const step of steps.operations)
|
|
957
|
+
edges.push(...valueEdgesInto(step.id, step.operands));
|
|
958
|
+
iteratorRecord = steps.iteratorRecord;
|
|
959
|
+
iteratorType = steps.recordType;
|
|
960
|
+
previousId = steps.operations[steps.operations.length - 1]?.id ?? null;
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
const { operands, edge: baseEdge } = sourceOperand('base', known, baseType);
|
|
964
|
+
const id = mintOperationId(context.ordinals, source, 'destructuring');
|
|
965
|
+
const result = mintResult(id, 'iterator-record', baseType);
|
|
966
|
+
const getIterator = {
|
|
967
|
+
id,
|
|
968
|
+
caller: candidate.caller,
|
|
969
|
+
operands,
|
|
970
|
+
results: [result],
|
|
971
|
+
completion: throwingCompletion,
|
|
972
|
+
effects: { readsMutableState: true, writesMutableState: false, allocates: true, callsUserCode: true },
|
|
973
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
974
|
+
family: 'destructuring',
|
|
975
|
+
form: 'array-pattern'
|
|
976
|
+
};
|
|
977
|
+
operations.push(getIterator);
|
|
978
|
+
const edge = baseEdge(id);
|
|
979
|
+
if (edge)
|
|
980
|
+
edges.push(edge);
|
|
981
|
+
chain(id);
|
|
982
|
+
iteratorRecord = result.id;
|
|
983
|
+
}
|
|
984
|
+
for (const element of node.elements) {
|
|
985
|
+
const iteratorSource = iteratorRecord ? { kind: 'result', result: iteratorRecord } : null;
|
|
986
|
+
const { operands: iterOperands, edge: iterEdge } = sourceOperand('iterator', iteratorSource, iteratorType);
|
|
987
|
+
if (ts.isOmittedExpression(element)) {
|
|
988
|
+
const id = mintOperationId(context.ordinals, source, 'destructuring');
|
|
989
|
+
const op = buildOperation(id, candidate.caller, candidate.evaluationOrdinal, 'array-pattern', iterOperands, null, throwingCompletion, {
|
|
990
|
+
readsMutableState: true,
|
|
991
|
+
writesMutableState: false,
|
|
992
|
+
allocates: false,
|
|
993
|
+
callsUserCode: true
|
|
994
|
+
});
|
|
995
|
+
operations.push(op);
|
|
996
|
+
const edge = iterEdge(id);
|
|
997
|
+
if (edge)
|
|
998
|
+
edges.push(edge);
|
|
999
|
+
chain(id);
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
if (ts.isSpreadElement(element)) {
|
|
1003
|
+
const target = arrayAssignmentTargetOf(element);
|
|
1004
|
+
const valueType = target ? arrayAssignmentBoundTypeOf(target) : context.types.typeAt(element.expression);
|
|
1005
|
+
const id = mintOperationId(context.ordinals, context.identities.nodeIdOf(element), 'destructuring');
|
|
1006
|
+
const op = buildOperation(id, candidate.caller, candidate.evaluationOrdinal, 'rest-element', iterOperands, valueType, throwingCompletion, {
|
|
1007
|
+
readsMutableState: true,
|
|
1008
|
+
writesMutableState: false,
|
|
1009
|
+
allocates: true,
|
|
1010
|
+
callsUserCode: false
|
|
1011
|
+
});
|
|
1012
|
+
operations.push(op);
|
|
1013
|
+
const edge = iterEdge(id);
|
|
1014
|
+
if (edge)
|
|
1015
|
+
edges.push(edge);
|
|
1016
|
+
chain(id);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
const position = node.elements.indexOf(element);
|
|
1020
|
+
if (element.kind === ts.SyntaxKind.BinaryExpression &&
|
|
1021
|
+
element.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
1022
|
+
const assignment = element;
|
|
1023
|
+
const valueType = extractedArrayAssignmentTypeOf(assignment.left, position, baseType);
|
|
1024
|
+
const stepId = mintOperationId(context.ordinals, context.identities.nodeIdOf(element), 'destructuring');
|
|
1025
|
+
const stepOperation = buildOperation(stepId, candidate.caller, candidate.evaluationOrdinal, 'array-pattern', iterOperands, valueType, throwingCompletion, { readsMutableState: true, writesMutableState: false, allocates: false, callsUserCode: true });
|
|
1026
|
+
operations.push(stepOperation);
|
|
1027
|
+
const edge = iterEdge(stepId);
|
|
1028
|
+
if (edge)
|
|
1029
|
+
edges.push(edge);
|
|
1030
|
+
chain(stepId);
|
|
1031
|
+
const extracted = stepOperation.results[0]?.id;
|
|
1032
|
+
if (extracted) {
|
|
1033
|
+
const boundType = context.types.typeAt(assignment.left);
|
|
1034
|
+
const fallbackType = context.types.typeAt(assignment.right);
|
|
1035
|
+
const defaultResult = contributeDefault(candidate, element, extracted, boundType, assignment.right, fallbackType);
|
|
1036
|
+
if ('blocked' in defaultResult) {
|
|
1037
|
+
return asBlocked(candidate.id, 'destructuring', `array assignment pattern default ${defaultResult.blocked}`, null);
|
|
1038
|
+
}
|
|
1039
|
+
operations.push(defaultResult);
|
|
1040
|
+
edges.push(...defaultResult.edges);
|
|
1041
|
+
chain(defaultResult.id);
|
|
1042
|
+
}
|
|
1043
|
+
continue;
|
|
1044
|
+
}
|
|
1045
|
+
// A bare target: an identifier, a property/element access, or a nested
|
|
1046
|
+
// pattern. Assignment syntax has no BindingElement-like wrapper to key
|
|
1047
|
+
// the step on besides the target itself.
|
|
1048
|
+
const valueType = extractedArrayAssignmentTypeOf(element, position, baseType);
|
|
1049
|
+
const stepId = mintOperationId(context.ordinals, context.identities.nodeIdOf(element), 'destructuring');
|
|
1050
|
+
const stepOperation = buildOperation(stepId, candidate.caller, candidate.evaluationOrdinal, 'array-pattern', iterOperands, valueType, throwingCompletion, { readsMutableState: true, writesMutableState: false, allocates: false, callsUserCode: true });
|
|
1051
|
+
operations.push(stepOperation);
|
|
1052
|
+
const edge = iterEdge(stepId);
|
|
1053
|
+
if (edge)
|
|
1054
|
+
edges.push(edge);
|
|
1055
|
+
chain(stepId);
|
|
1056
|
+
}
|
|
1057
|
+
if (iteratorRecord && finitePatternNeedsClose(baseType) && !node.elements.some(ts.isSpreadElement)) {
|
|
1058
|
+
const id = mintOperationId(context.ordinals, source, 'destructuring');
|
|
1059
|
+
const close = {
|
|
1060
|
+
id,
|
|
1061
|
+
caller: candidate.caller,
|
|
1062
|
+
operands: [operand('iterator', 0, { kind: 'result', result: iteratorRecord }, iteratorType, { kind: 'provenance' })],
|
|
1063
|
+
results: [mintResult(id, 'completion', context.table.intern({ kind: 'primitive', primitive: 'void' }))],
|
|
1064
|
+
completion: throwingCompletion,
|
|
1065
|
+
effects: { readsMutableState: true, writesMutableState: false, allocates: false, callsUserCode: true },
|
|
1066
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
1067
|
+
family: 'destructuring',
|
|
1068
|
+
form: 'array-pattern-close'
|
|
1069
|
+
};
|
|
1070
|
+
const predecessor = operations[operations.length - 1]?.id ?? null;
|
|
1071
|
+
operations.push(close);
|
|
1072
|
+
edges.push({ kind: 'value', result: iteratorRecord, to: id, role: 'iterator', ordinal: 0 });
|
|
1073
|
+
if (predecessor)
|
|
1074
|
+
edges.push({ kind: 'evaluation', from: predecessor, to: id });
|
|
1075
|
+
previousId = id;
|
|
1076
|
+
}
|
|
1077
|
+
return { kind: 'operations', operations, edges };
|
|
1078
|
+
};
|
|
1079
|
+
/**
|
|
1080
|
+
* A simple array-assignment target's WRITE: an ordinary identifier
|
|
1081
|
+
* assignment or property/element store, citing the sibling
|
|
1082
|
+
* `contributeArrayAssignmentPattern` candidate's own per-position
|
|
1083
|
+
* extraction by recomputed identity -- never a lookup, for the same reason
|
|
1084
|
+
* `contributeBindingElement` cites `citeBoundElementValue` instead of one.
|
|
1085
|
+
*/
|
|
1086
|
+
const contributeArrayAssignmentWrite = (candidate, node) => {
|
|
1087
|
+
const refuse = (reason) => asBlocked(candidate.id, 'destructuring', reason, null);
|
|
1088
|
+
const target = arrayAssignmentWriteTargetOf(node);
|
|
1089
|
+
if (!target)
|
|
1090
|
+
return refuse('array assignment target has no enclosing array pattern');
|
|
1091
|
+
const boundType = arrayAssignmentBoundTypeOf(target);
|
|
1092
|
+
const value = {
|
|
1093
|
+
kind: 'result',
|
|
1094
|
+
result: semanticResultId(operationId(context.identities.nodeIdOf(target.keyNode), 'destructuring', target.defaulted ? 1 : 0), 'value')
|
|
1095
|
+
};
|
|
1096
|
+
let write;
|
|
1097
|
+
if (ts.isIdentifier(node)) {
|
|
1098
|
+
const symbol = context.checker.getSymbolAtLocation(node);
|
|
1099
|
+
const declaration = symbol ? context.identities.symbolDeclarationId(symbol) : null;
|
|
1100
|
+
const declarationNode = symbol ? context.identities.declarationOfSymbol(symbol) : null;
|
|
1101
|
+
if (!declaration || !declarationNode)
|
|
1102
|
+
return refuse('array assignment target has no declared binding cell');
|
|
1103
|
+
const id = mintOperationId(context.ordinals, candidate.id, 'binding');
|
|
1104
|
+
write = {
|
|
1105
|
+
id,
|
|
1106
|
+
family: 'binding',
|
|
1107
|
+
action: 'write',
|
|
1108
|
+
declaration,
|
|
1109
|
+
...bindingKindOf(declarationNode),
|
|
1110
|
+
...(context.commonJsBindings.has(declaration)
|
|
1111
|
+
? {
|
|
1112
|
+
commonJs: {
|
|
1113
|
+
global: context.commonJsBindings.get(declaration),
|
|
1114
|
+
owner: regionId(context.identities.nodeIdOf(node.getSourceFile()), 'module-body')
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
: {}),
|
|
1118
|
+
caller: candidate.caller,
|
|
1119
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
1120
|
+
operands: [operand('value', 0, value, boundType)],
|
|
1121
|
+
results: [mintResult(id, 'value', boundType)],
|
|
1122
|
+
completion: normalCompletion,
|
|
1123
|
+
effects: { readsMutableState: false, writesMutableState: true, allocates: false, callsUserCode: false }
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
// `arrayAssignmentWriteTargetOf` admits only identifier/property/element
|
|
1128
|
+
// targets, so a non-identifier target here is always one of the other two.
|
|
1129
|
+
const access = node;
|
|
1130
|
+
const receiver = citeExpressionResult(access.expression, context);
|
|
1131
|
+
if (receiver.kind === 'unmodelled')
|
|
1132
|
+
return refuse(receiver.reason);
|
|
1133
|
+
const targetKey = ts.isPropertyAccessExpression(access)
|
|
1134
|
+
? access.name.text
|
|
1135
|
+
: ts.isStringLiteralLike(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression)
|
|
1136
|
+
? access.argumentExpression.text
|
|
1137
|
+
: null;
|
|
1138
|
+
if (targetKey === null)
|
|
1139
|
+
return refuse('computed array assignment target keys are not yet modelled');
|
|
1140
|
+
const id = mintOperationId(context.ordinals, candidate.id, 'property');
|
|
1141
|
+
const receiverType = context.types.typeAt(access.expression);
|
|
1142
|
+
write = {
|
|
1143
|
+
id,
|
|
1144
|
+
family: 'property',
|
|
1145
|
+
internalMethod: 'set',
|
|
1146
|
+
strict: isStrictContext(access, context.buildIsStrict),
|
|
1147
|
+
keyIsComputed: false,
|
|
1148
|
+
descriptor: null,
|
|
1149
|
+
caller: candidate.caller,
|
|
1150
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
1151
|
+
operands: [
|
|
1152
|
+
operand('receiver', 0, receiver.source, receiverType, { kind: 'provenance' }),
|
|
1153
|
+
operand('key', 0, { kind: 'constant', text: targetKey, literal: 'string' }, stringType),
|
|
1154
|
+
operand('value', 0, value, boundType)
|
|
1155
|
+
],
|
|
1156
|
+
results: [mintResult(id, 'value', receiverType)],
|
|
1157
|
+
completion: throwingCompletion,
|
|
1158
|
+
effects: { readsMutableState: false, writesMutableState: true, allocates: false, callsUserCode: true }
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
return { kind: 'operations', operations: [write], edges: valueEdgesInto(write.id, write.operands) };
|
|
1162
|
+
};
|
|
1163
|
+
const contribute = (candidate) => {
|
|
1164
|
+
const { node } = candidate;
|
|
1165
|
+
if (ts.isObjectLiteralExpression(node))
|
|
1166
|
+
return contributeObjectAssignmentSource(context, candidate, node);
|
|
1167
|
+
if (isObjectAssignmentElement(node))
|
|
1168
|
+
return contributeObjectAssignmentElement(context, candidate, node);
|
|
1169
|
+
if (ts.isObjectBindingPattern(node))
|
|
1170
|
+
return contributeObjectPattern(candidate, node);
|
|
1171
|
+
if (ts.isArrayBindingPattern(node))
|
|
1172
|
+
return contributeArrayPattern(candidate, node);
|
|
1173
|
+
if (ts.isArrayLiteralExpression(node))
|
|
1174
|
+
return contributeArrayAssignmentPattern(candidate, node);
|
|
1175
|
+
if (arrayAssignmentWriteTargetOf(node))
|
|
1176
|
+
return contributeArrayAssignmentWrite(candidate, node);
|
|
1177
|
+
return asBlocked(candidate.id, 'destructuring', 'census produced a destructuring candidate of an unmodelled node kind', null);
|
|
1178
|
+
};
|
|
1179
|
+
return { family: 'destructuring', contribute };
|
|
1180
|
+
};
|