@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,1057 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Every statement of every file: the answer when nothing may be pruned.
|
|
4
|
+
*
|
|
5
|
+
* This is the fail-closed value, and it is what a compilation whose entry
|
|
6
|
+
* points could not be resolved gets. It is deliberately not the default of any
|
|
7
|
+
* parameter -- a census that silently walked the whole program because someone
|
|
8
|
+
* forgot to thread the reachability through would be the second authority this
|
|
9
|
+
* module exists to prevent.
|
|
10
|
+
*/
|
|
11
|
+
export const wholeProgram = {
|
|
12
|
+
statementsOf: (file) => file.statements,
|
|
13
|
+
memberIsPruned: () => false,
|
|
14
|
+
classIsLayoutOnly: () => false
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* `ts.forEachChild(file, visit)` restricted to what the program reaches.
|
|
18
|
+
*
|
|
19
|
+
* Every census in the parameter-binding family walks a file this way, and a
|
|
20
|
+
* walk that still visited a pruned statement counted references in code the
|
|
21
|
+
* program never runs: test262's propertyHelper ends with the inert, unreached
|
|
22
|
+
* `var verifyPrimordialProperty = verifyProperty`, and that one alias made
|
|
23
|
+
* the parameter census refuse `verifyProperty` as "escaping" -- so its `obj`
|
|
24
|
+
* never learned it is only ever called with `Math`, and every helper under it
|
|
25
|
+
* went dynamic. A declaration file has no statements the program evaluates,
|
|
26
|
+
* the same exclusion the walks made for themselves before.
|
|
27
|
+
*/
|
|
28
|
+
export const forEachReachableStatement = (reachable, file, visit) => {
|
|
29
|
+
if (file.isDeclarationFile)
|
|
30
|
+
return;
|
|
31
|
+
for (const statement of reachable.statementsOf(file))
|
|
32
|
+
visit(statement);
|
|
33
|
+
};
|
|
34
|
+
const liveStatementSets = new WeakMap();
|
|
35
|
+
/**
|
|
36
|
+
* Whether `node` is code the program runs: inside a top-level statement this
|
|
37
|
+
* program reaches, and under no member it pruned -- the boundary
|
|
38
|
+
* `forEachReachableStatement` draws for a walk, asked of one node a walk did
|
|
39
|
+
* not produce. A module the checker loaded but the program never evaluates
|
|
40
|
+
* (three's `ColorSpaceNode.js`, pulled in beside the node materials) answers
|
|
41
|
+
* false everywhere.
|
|
42
|
+
*/
|
|
43
|
+
export const nodeIsReachable = (reachable, node) => {
|
|
44
|
+
let current = node;
|
|
45
|
+
while (current.parent && !ts.isSourceFile(current.parent)) {
|
|
46
|
+
if (reachable.memberIsPruned(current))
|
|
47
|
+
return false;
|
|
48
|
+
current = current.parent;
|
|
49
|
+
}
|
|
50
|
+
const file = current.parent;
|
|
51
|
+
if (!file || !ts.isSourceFile(file) || file.isDeclarationFile)
|
|
52
|
+
return false;
|
|
53
|
+
let perFile = liveStatementSets.get(reachable);
|
|
54
|
+
if (!perFile)
|
|
55
|
+
liveStatementSets.set(reachable, (perFile = new Map()));
|
|
56
|
+
let statements = perFile.get(file);
|
|
57
|
+
if (!statements)
|
|
58
|
+
perFile.set(file, (statements = new Set(reachable.statementsOf(file))));
|
|
59
|
+
return statements.has(current);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Whether a computed member name is a key the class definition can compute
|
|
63
|
+
* without performing an action.
|
|
64
|
+
*
|
|
65
|
+
* One shape qualifies: a WELL-KNOWN SYMBOL -- `[Symbol.dispose]`,
|
|
66
|
+
* `[Symbol.asyncIterator]`. Two facts make it safe, and both are checked.
|
|
67
|
+
* Its type is `unique symbol`, which TypeScript mints only for a declared
|
|
68
|
+
* constant, so the key is a value and not a computation; and every declaration
|
|
69
|
+
* of the object it is read from is ambient, so the read is of the language's
|
|
70
|
+
* own intrinsic rather than of a user object where `get` could run code.
|
|
71
|
+
*
|
|
72
|
+
* Without this, `class X { [Symbol.dispose]() {} }` was kept in every program
|
|
73
|
+
* that so much as imported its module -- and node-compat's `events.ts` has two
|
|
74
|
+
* such classes, whose bodies need a deferred `Promise` this runtime does not
|
|
75
|
+
* have.
|
|
76
|
+
*/
|
|
77
|
+
const computedKeyIsInert = (checker, name) => {
|
|
78
|
+
// STATED, not HOLDS -- and deliberately left alone. This asks whether
|
|
79
|
+
// `name.expression` denotes a well-known ambient symbol (`Symbol.dispose`,
|
|
80
|
+
// `Symbol.asyncIterator`) via the checker's own `UniqueESSymbol` flag, to
|
|
81
|
+
// decide whether a class's computed-key EVALUATION can be pruned. No
|
|
82
|
+
// parameter/local/return/field census tracks a well-known-symbol reference
|
|
83
|
+
// (it is neither a parameter, an assignment target, nor a call result), so
|
|
84
|
+
// `censusedTypeAt` would fall through to this exact checker call every
|
|
85
|
+
// time -- but this file is a REACHABILITY/pruning decision, not a boxing
|
|
86
|
+
// one: a wrong answer here drops or keeps a statement, not a carrier
|
|
87
|
+
// (a mis-derived `never` here has miscompiled live code before). No boxing upside, real correctness downside -- left as a
|
|
88
|
+
// direct checker call.
|
|
89
|
+
if ((checker.getTypeAtLocation(name.expression).flags & ts.TypeFlags.UniqueESSymbol) === 0)
|
|
90
|
+
return false;
|
|
91
|
+
const root = ts.isPropertyAccessExpression(name.expression) ? name.expression.expression : name.expression;
|
|
92
|
+
const declarations = checker.getSymbolAtLocation(root)?.declarations ?? [];
|
|
93
|
+
return declarations.length > 0 && declarations.every((declaration) => declaration.getSourceFile().isDeclarationFile);
|
|
94
|
+
};
|
|
95
|
+
/** Whether a class's *definition* evaluates anything beyond binding its own name. */
|
|
96
|
+
const classDefinitionIsInert = (checker, node) => {
|
|
97
|
+
if (ts.canHaveDecorators(node) && (ts.getDecorators(node)?.length ?? 0) > 0)
|
|
98
|
+
return false;
|
|
99
|
+
// The one step `ClassDefinitionEvaluation` performs for a decorator-free
|
|
100
|
+
// class is its heritage read, and that step is not inert in THIS compiler
|
|
101
|
+
// even though it calls nothing: `projection/classes.ts` reads a class's
|
|
102
|
+
// `base` link off the class-lifecycle heritage event the census publishes
|
|
103
|
+
// for the definition, and `records.ts` spells `struct D : B` from that
|
|
104
|
+
// link alone -- while the struct itself is emitted whenever the class's
|
|
105
|
+
// shape is reachable, which a type position keeps it. Pruning an
|
|
106
|
+
// un-instantiated `class One extends Base` whose type still names a union
|
|
107
|
+
// arm emitted `struct One final {}` with no base, and the upcast
|
|
108
|
+
// `Ref<Base>(Ref<One>)` the union's recast renders stopped compiling.
|
|
109
|
+
if (node.heritageClauses?.some((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword))
|
|
110
|
+
return false;
|
|
111
|
+
return node.members.every((member) => {
|
|
112
|
+
if (ts.canHaveDecorators(member) && (ts.getDecorators(member)?.length ?? 0) > 0)
|
|
113
|
+
return false;
|
|
114
|
+
// A static block is a body that runs at definition time, and a computed key
|
|
115
|
+
// is an expression evaluated there -- for an instance field as much as a
|
|
116
|
+
// static one, because the key is captured when the class is defined.
|
|
117
|
+
if (ts.isClassStaticBlockDeclaration(member))
|
|
118
|
+
return false;
|
|
119
|
+
if (member.name && ts.isComputedPropertyName(member.name) && !computedKeyIsInert(checker, member.name))
|
|
120
|
+
return false;
|
|
121
|
+
if (!ts.isPropertyDeclaration(member))
|
|
122
|
+
return true;
|
|
123
|
+
const isStatic = member.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) ?? false;
|
|
124
|
+
return !isStatic || member.initializer === undefined;
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Whether this class member's body runs only when something NAMES it.
|
|
129
|
+
*
|
|
130
|
+
* A method or accessor, with no decorator and no computed name. Each exclusion
|
|
131
|
+
* is a way the member is reached other than by its own name: a decorator
|
|
132
|
+
* receives it at class-definition time, and a computed name is an expression
|
|
133
|
+
* evaluated there. A FIELD is excluded too -- by not being a method at all --
|
|
134
|
+
* because an instance initializer runs at construction and a static one at
|
|
135
|
+
* definition.
|
|
136
|
+
*
|
|
137
|
+
* Static and instance members are both deferrable, but they are opened by two
|
|
138
|
+
* different questions, because they are reached two different ways. `C.m`
|
|
139
|
+
* resolves to one declaration, so a static is opened by SYMBOL. An instance
|
|
140
|
+
* member is reached by dispatch through a receiver whose runtime class the
|
|
141
|
+
* walk does not know -- `base.close()` on a value that is really a subclass
|
|
142
|
+
* runs the subclass's `close` -- so an instance member is opened by KEY: any
|
|
143
|
+
* spelling of the name anywhere in live code opens every member that answers
|
|
144
|
+
* it, on every class. See `memberKeyOf`.
|
|
145
|
+
*/
|
|
146
|
+
const memberIsDeferrable = (member) => {
|
|
147
|
+
if (!ts.isMethodDeclaration(member) && !ts.isGetAccessorDeclaration(member) && !ts.isSetAccessorDeclaration(member))
|
|
148
|
+
return false;
|
|
149
|
+
// A CLASS member only. An object literal spells the same three node kinds --
|
|
150
|
+
// `{ m() {}, get v() {} }` really is a `MethodDeclaration` and an accessor --
|
|
151
|
+
// but its members are not dispatched-to definitions held on a prototype, they
|
|
152
|
+
// are the object's own installed properties: evaluating the literal creates
|
|
153
|
+
// each one, so nothing has to name a member for it to exist. Deferring one
|
|
154
|
+
// dropped the property from the object entirely (`object-members.ts`,
|
|
155
|
+
// `object-literal-accessors.ts`, both of which lost their certificate), which
|
|
156
|
+
// is the failure mode a static modifier used to rule out by accident.
|
|
157
|
+
if (!member.parent || !ts.isClassLike(member.parent))
|
|
158
|
+
return false;
|
|
159
|
+
if (ts.getDecorators(member)?.length)
|
|
160
|
+
return false;
|
|
161
|
+
return !ts.isComputedPropertyName(member.name);
|
|
162
|
+
};
|
|
163
|
+
const memberIsStatic = (member) => ts.canHaveModifiers(member) && (ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) ?? false);
|
|
164
|
+
/**
|
|
165
|
+
* The name an instance member is dispatched under, or `null` when it has none
|
|
166
|
+
* this walk can compare against a spelling.
|
|
167
|
+
*
|
|
168
|
+
* A computed name never reaches here (`memberIsDeferrable` refuses one), so the
|
|
169
|
+
* remaining forms are all written text. `null` is the fail-closed answer and
|
|
170
|
+
* keeps the member.
|
|
171
|
+
*/
|
|
172
|
+
const memberKeyOf = (member) => {
|
|
173
|
+
const name = member.name;
|
|
174
|
+
if (ts.isIdentifier(name) || ts.isPrivateIdentifier(name))
|
|
175
|
+
return name.text;
|
|
176
|
+
if (ts.isStringLiteral(name) || ts.isNumericLiteral(name))
|
|
177
|
+
return name.text;
|
|
178
|
+
return null;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Member names the language invokes on a value without the program spelling
|
|
182
|
+
* one, so no spelling can be required before keeping them.
|
|
183
|
+
*
|
|
184
|
+
* The same set `ir/shake.ts` keeps for the identical reason, and it has to stay
|
|
185
|
+
* the same set: that pass makes the same cut over the lowered IR, and a name
|
|
186
|
+
* only one of the two protects is a member this walk drops and that walk
|
|
187
|
+
* expected to still be there.
|
|
188
|
+
*/
|
|
189
|
+
const specificationInvokedKeys = new Set(['toString', 'valueOf', 'then', 'next', 'return', 'throw']);
|
|
190
|
+
/** Whether an object literal member installs itself without evaluating anything but its own definition. */
|
|
191
|
+
/** Whether a declaration is a name this module IMPORTED rather than one it declares itself. */
|
|
192
|
+
const isImportedBinding = (declaration) => ts.isImportSpecifier(declaration) ||
|
|
193
|
+
ts.isImportClause(declaration) ||
|
|
194
|
+
ts.isNamespaceImport(declaration) ||
|
|
195
|
+
ts.isImportEqualsDeclaration(declaration);
|
|
196
|
+
const objectMemberIsInert = (checker, member) => {
|
|
197
|
+
if (member.name && ts.isComputedPropertyName(member.name))
|
|
198
|
+
return false;
|
|
199
|
+
// A method or accessor is a function definition: its body does not run here,
|
|
200
|
+
// and its default parameter values run at call time, not at definition.
|
|
201
|
+
if (ts.isMethodDeclaration(member) || ts.isGetAccessorDeclaration(member) || ts.isSetAccessorDeclaration(member))
|
|
202
|
+
return true;
|
|
203
|
+
// `{ x }` reads the binding `x`, and the whitelist below refuses a bare
|
|
204
|
+
// identifier because the read can throw a `ReferenceError` from a temporal
|
|
205
|
+
// dead zone that TypeScript does not report ACROSS AN IMPORT CYCLE. That
|
|
206
|
+
// reason is specific, and so is its converse: a shorthand naming a binding
|
|
207
|
+
// declared in THIS file is a read TypeScript checks itself (TS2448), and a
|
|
208
|
+
// program it rejects is one this compiler never compiles. So the read is
|
|
209
|
+
// provably not an action, and the object literal it sits in can be dropped
|
|
210
|
+
// when nothing names it.
|
|
211
|
+
//
|
|
212
|
+
// What this buys: node-compat's `events.ts` ends with a CommonJS-style
|
|
213
|
+
// namespace listing every export by shorthand. Kept, it made `once` and the
|
|
214
|
+
// async-iterator machinery live in every program that imports the module at
|
|
215
|
+
// all -- and those need a deferred `Promise` this runtime deliberately does
|
|
216
|
+
// not have, so an app that never calls them could not compile.
|
|
217
|
+
if (ts.isShorthandPropertyAssignment(member)) {
|
|
218
|
+
const declarations = checker.getShorthandAssignmentValueSymbol(member)?.declarations ?? [];
|
|
219
|
+
if (declarations.length === 0)
|
|
220
|
+
return false;
|
|
221
|
+
return declarations.every((declaration) => declaration.getSourceFile() === member.getSourceFile() && !isImportedBinding(declaration));
|
|
222
|
+
}
|
|
223
|
+
// `{ ...rest }` copies own enumerable properties, which reads them -- and a
|
|
224
|
+
// read can be a getter.
|
|
225
|
+
if (!ts.isPropertyAssignment(member))
|
|
226
|
+
return false;
|
|
227
|
+
return initializerIsInert(checker, member.initializer);
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Whether evaluating this initializer is provably not an action.
|
|
231
|
+
*
|
|
232
|
+
* The whitelist is short on purpose. Every form outside it is kept, and the
|
|
233
|
+
* cost of keeping one is dead code in the census -- while the cost of
|
|
234
|
+
* admitting one wrongly is a module initialization step that silently stopped
|
|
235
|
+
* happening. A bare identifier is outside it for that reason and not because
|
|
236
|
+
* reading a binding does work: the read can throw a `ReferenceError` from a
|
|
237
|
+
* temporal dead zone, and while TypeScript reports that itself within one
|
|
238
|
+
* module (TS2448, which this compiler refuses the program for), it does not
|
|
239
|
+
* across an import cycle.
|
|
240
|
+
*/
|
|
241
|
+
const initializerIsInert = (checker, node) => {
|
|
242
|
+
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node))
|
|
243
|
+
return initializerIsInert(checker, node.expression);
|
|
244
|
+
if (ts.isNonNullExpression(node) || ts.isTypeAssertionExpression(node))
|
|
245
|
+
return initializerIsInert(checker, node.expression);
|
|
246
|
+
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node))
|
|
247
|
+
return true;
|
|
248
|
+
if (ts.isClassExpression(node))
|
|
249
|
+
return classDefinitionIsInert(checker, node);
|
|
250
|
+
if (ts.isObjectLiteralExpression(node))
|
|
251
|
+
return node.properties.every((member) => objectMemberIsInert(checker, member));
|
|
252
|
+
if (ts.isArrayLiteralExpression(node)) {
|
|
253
|
+
return node.elements.every((element) => ts.isOmittedExpression(element) || initializerIsInert(checker, element));
|
|
254
|
+
}
|
|
255
|
+
// A bare identifier naming a binding THIS FILE declares -- test262's
|
|
256
|
+
// propertyHelper ends with `var verifyPrimordialProperty = verifyProperty`.
|
|
257
|
+
// The one observable effect an identifier read can have is a
|
|
258
|
+
// temporal-dead-zone throw, and the shorthand case above already states why
|
|
259
|
+
// that is provably absent within one file: TypeScript reports it itself
|
|
260
|
+
// (TS2448) and refuses the program. A function declaration cannot even be in
|
|
261
|
+
// a dead zone. Kept live, that alias counted as `verifyProperty` ESCAPING to
|
|
262
|
+
// a value position (`parameter-bindings.ts`'s `escapeReason`), which refused
|
|
263
|
+
// every call-site type its parameters would otherwise have carried.
|
|
264
|
+
if (ts.isIdentifier(node)) {
|
|
265
|
+
const declarations = checker.getSymbolAtLocation(node)?.declarations ?? [];
|
|
266
|
+
if (declarations.length === 0)
|
|
267
|
+
return false;
|
|
268
|
+
return declarations.every((declaration) => declaration.getSourceFile() === node.getSourceFile() && !isImportedBinding(declaration));
|
|
269
|
+
}
|
|
270
|
+
// `C.prototype` where `C` is a class THIS FILE declares. ECMA-262 10.2.4
|
|
271
|
+
// makes `prototype` a non-writable, non-configurable DATA property of every
|
|
272
|
+
// class constructor, so the read this whitelist otherwise refuses -- because
|
|
273
|
+
// a property read can be a getter -- provably is not one here. The class
|
|
274
|
+
// has to be declared in this file for the same reason a shorthand's binding
|
|
275
|
+
// does: a temporal-dead-zone throw across an import cycle is the one
|
|
276
|
+
// observable effect an identifier read can have, and TypeScript reports the
|
|
277
|
+
// within-a-file case itself.
|
|
278
|
+
//
|
|
279
|
+
// `events.ts` exports `prototype = EventEmitter.prototype` as a CommonJS
|
|
280
|
+
// compatibility shim. This runtime models no prototype object at all, so
|
|
281
|
+
// emitting that read has no right answer -- and pruning a statement nothing
|
|
282
|
+
// reads is the answer that does not invent one.
|
|
283
|
+
if (ts.isPropertyAccessExpression(node) && node.name.text === 'prototype' && ts.isIdentifier(node.expression)) {
|
|
284
|
+
const declarations = checker.getSymbolAtLocation(node.expression)?.declarations ?? [];
|
|
285
|
+
return (declarations.length > 0 &&
|
|
286
|
+
declarations.every((declaration) => ts.isClassDeclaration(declaration) && declaration.getSourceFile() === node.getSourceFile()));
|
|
287
|
+
}
|
|
288
|
+
if (ts.isCallExpression(node))
|
|
289
|
+
return closureFactoryCallIsInert(checker, node);
|
|
290
|
+
// `-1` and `+1` are how a negative numeric constant is spelled; nothing else
|
|
291
|
+
// unary is admitted, because every other operand form can reach user code.
|
|
292
|
+
if (ts.isPrefixUnaryExpression(node)) {
|
|
293
|
+
const signed = node.operator === ts.SyntaxKind.MinusToken || node.operator === ts.SyntaxKind.PlusToken;
|
|
294
|
+
return signed && (ts.isNumericLiteral(node.operand) || ts.isBigIntLiteral(node.operand));
|
|
295
|
+
}
|
|
296
|
+
return (ts.isNumericLiteral(node) ||
|
|
297
|
+
ts.isBigIntLiteral(node) ||
|
|
298
|
+
ts.isStringLiteral(node) ||
|
|
299
|
+
ts.isNoSubstitutionTemplateLiteral(node) ||
|
|
300
|
+
ts.isRegularExpressionLiteral(node) ||
|
|
301
|
+
node.kind === ts.SyntaxKind.TrueKeyword ||
|
|
302
|
+
node.kind === ts.SyntaxKind.FalseKeyword ||
|
|
303
|
+
node.kind === ts.SyntaxKind.NullKeyword);
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* The body of a function whose call does nothing but create and return a
|
|
307
|
+
* closure: `return <function>` and nothing else, over plain parameters with no
|
|
308
|
+
* default. Calling it binds the parameters and allocates the closure; no
|
|
309
|
+
* expression runs, so the parameters are only ever READ later, by the closure,
|
|
310
|
+
* when something calls it.
|
|
311
|
+
*/
|
|
312
|
+
const returnsOnlyAClosure = (callee) => {
|
|
313
|
+
if (!ts.isFunctionDeclaration(callee) && !ts.isFunctionExpression(callee) && !ts.isArrowFunction(callee))
|
|
314
|
+
return false;
|
|
315
|
+
if (callee.asteriskToken || ts.getCombinedModifierFlags(callee) & ts.ModifierFlags.Async)
|
|
316
|
+
return false;
|
|
317
|
+
if (callee.parameters.some((parameter) => !ts.isIdentifier(parameter.name) || parameter.initializer !== undefined))
|
|
318
|
+
return false;
|
|
319
|
+
const body = callee.body;
|
|
320
|
+
if (!body)
|
|
321
|
+
return false;
|
|
322
|
+
let returned;
|
|
323
|
+
if (ts.isBlock(body)) {
|
|
324
|
+
const [only, ...rest] = body.statements;
|
|
325
|
+
if (!only || rest.length > 0 || !ts.isReturnStatement(only))
|
|
326
|
+
return false;
|
|
327
|
+
returned = only.expression;
|
|
328
|
+
}
|
|
329
|
+
else
|
|
330
|
+
returned = body;
|
|
331
|
+
while (returned &&
|
|
332
|
+
(ts.isParenthesizedExpression(returned) ||
|
|
333
|
+
ts.isAsExpression(returned) ||
|
|
334
|
+
ts.isSatisfiesExpression(returned) ||
|
|
335
|
+
ts.isNonNullExpression(returned) ||
|
|
336
|
+
ts.isTypeAssertionExpression(returned)))
|
|
337
|
+
returned = returned.expression;
|
|
338
|
+
return returned !== undefined && (ts.isArrowFunction(returned) || ts.isFunctionExpression(returned));
|
|
339
|
+
};
|
|
340
|
+
/** Every module `file` evaluates, transitively, itself excluded unless a cycle leads back to it. */
|
|
341
|
+
const transitiveModuleTargetsOf = (checker, file) => {
|
|
342
|
+
const seen = new Set();
|
|
343
|
+
const pending = [...moduleTargetsOf(checker, file)];
|
|
344
|
+
while (pending.length > 0) {
|
|
345
|
+
const next = pending.pop();
|
|
346
|
+
if (seen.has(next))
|
|
347
|
+
continue;
|
|
348
|
+
seen.add(next);
|
|
349
|
+
pending.push(...moduleTargetsOf(checker, next));
|
|
350
|
+
}
|
|
351
|
+
return seen;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* `export const upgradeWebSocket = defineWebSocketHelper(async (c, events) =>
|
|
355
|
+
* {...})` -- a call whose whole effect is a closure over inert arguments.
|
|
356
|
+
*
|
|
357
|
+
* `@hono/node-server` re-exports `upgradeWebSocket` from its package entry, so
|
|
358
|
+
* every app that imports `serve` evaluates `websocket.ts`, and a call is an
|
|
359
|
+
* action the statement rule keeps. But hono's `defineWebSocketHelper` only
|
|
360
|
+
* returns an arrow closing over `handler`; the handler runs when that arrow is
|
|
361
|
+
* called, and the arrow lives in `upgradeWebSocket` alone. So this is the
|
|
362
|
+
* `const X = () => ...` the whitelist already drops, reached through one call.
|
|
363
|
+
*
|
|
364
|
+
* The callee must be one declaration this program compiles, whose body
|
|
365
|
+
* `returnsOnlyAClosure` proves runs nothing, and its name must be readable
|
|
366
|
+
* without a temporal-dead-zone throw: declared in this file (TypeScript
|
|
367
|
+
* reports a same-file use before declaration, TS2448), or imported from a
|
|
368
|
+
* module that cannot import this one back and so has finished evaluating.
|
|
369
|
+
*/
|
|
370
|
+
const closureFactoryCallIsInert = (checker, node) => {
|
|
371
|
+
if (node.questionDotToken || !ts.isIdentifier(node.expression))
|
|
372
|
+
return false;
|
|
373
|
+
if (!node.arguments.every((argument) => !ts.isSpreadElement(argument) && initializerIsInert(checker, argument)))
|
|
374
|
+
return false;
|
|
375
|
+
const symbol = checker.getSymbolAtLocation(node.expression);
|
|
376
|
+
if (!symbol)
|
|
377
|
+
return false;
|
|
378
|
+
const imported = (symbol.flags & ts.SymbolFlags.Alias) !== 0;
|
|
379
|
+
const target = imported ? checker.getAliasedSymbol(symbol) : symbol;
|
|
380
|
+
const declarations = target.declarations ?? [];
|
|
381
|
+
if (declarations.length !== 1)
|
|
382
|
+
return false;
|
|
383
|
+
const declaration = declarations[0];
|
|
384
|
+
const file = declaration.getSourceFile();
|
|
385
|
+
if (file.isDeclarationFile)
|
|
386
|
+
return false;
|
|
387
|
+
let callee = declaration;
|
|
388
|
+
if (ts.isVariableDeclaration(declaration)) {
|
|
389
|
+
const list = declaration.parent;
|
|
390
|
+
if (!ts.isVariableDeclarationList(list) || (list.flags & ts.NodeFlags.Const) === 0)
|
|
391
|
+
return false;
|
|
392
|
+
callee = declaration.initializer;
|
|
393
|
+
while (callee && (ts.isParenthesizedExpression(callee) || ts.isAsExpression(callee) || ts.isSatisfiesExpression(callee)))
|
|
394
|
+
callee = callee.expression;
|
|
395
|
+
}
|
|
396
|
+
if (!callee || !ts.isFunctionLike(callee) || !returnsOnlyAClosure(callee))
|
|
397
|
+
return false;
|
|
398
|
+
const here = node.getSourceFile();
|
|
399
|
+
if (file === here)
|
|
400
|
+
return !imported;
|
|
401
|
+
return imported && ts.isExternalModule(file) && !transitiveModuleTargetsOf(checker, file).has(here);
|
|
402
|
+
};
|
|
403
|
+
/** Whether this top-level statement may be dropped when nothing reaches what it declares. */
|
|
404
|
+
const isPrunableDeclaration = (checker, statement) => {
|
|
405
|
+
// `export default x` in a module that is NOT an entry declares a name and
|
|
406
|
+
// runs nothing: the initializer is an identifier the module already
|
|
407
|
+
// evaluated, so opening the export is opening a NAME, and a name nothing
|
|
408
|
+
// imports is dead in a whole-program compile. Entries are exempt above --
|
|
409
|
+
// `openStatement` is called unconditionally for them -- which is what keeps
|
|
410
|
+
// a library's own default export a root when the library IS the program.
|
|
411
|
+
//
|
|
412
|
+
// Without this, node-compat's `events.ts` kept its whole CommonJS-style
|
|
413
|
+
// default namespace alive, and with it `once`, `on` and the async-iterator
|
|
414
|
+
// machinery, in an application that imports only `node:http` -- five
|
|
415
|
+
// capabilities demanded by code no call in the program can reach.
|
|
416
|
+
if (ts.isExportAssignment(statement))
|
|
417
|
+
return true;
|
|
418
|
+
if (ts.isFunctionDeclaration(statement)) {
|
|
419
|
+
return !(ts.canHaveDecorators(statement) && (ts.getDecorators(statement)?.length ?? 0) > 0);
|
|
420
|
+
}
|
|
421
|
+
if (ts.isClassDeclaration(statement))
|
|
422
|
+
return classDefinitionIsInert(checker, statement);
|
|
423
|
+
if (!ts.isVariableStatement(statement))
|
|
424
|
+
return false;
|
|
425
|
+
return statement.declarationList.declarations.every((declaration) => {
|
|
426
|
+
// A binding pattern reads properties off the initializer, and a read can be
|
|
427
|
+
// a getter or a throw on `null`; only a plain name binds without acting.
|
|
428
|
+
if (!ts.isIdentifier(declaration.name))
|
|
429
|
+
return false;
|
|
430
|
+
return declaration.initializer === undefined || initializerIsInert(checker, declaration.initializer);
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
/** The source files a module's own import and re-export declarations name. */
|
|
434
|
+
const moduleTargetsOf = (checker, file) => {
|
|
435
|
+
const targets = [];
|
|
436
|
+
const add = (specifier) => {
|
|
437
|
+
if (!specifier || !ts.isStringLiteralLike(specifier))
|
|
438
|
+
return;
|
|
439
|
+
// The checker's own module resolution, not this walk's: an unresolvable
|
|
440
|
+
// specifier is a checker error, and a program the checker rejects is one
|
|
441
|
+
// this compiler already refuses before anything here matters.
|
|
442
|
+
for (const declaration of checker.getSymbolAtLocation(specifier)?.declarations ?? []) {
|
|
443
|
+
if (ts.isSourceFile(declaration))
|
|
444
|
+
targets.push(declaration);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const visit = (node) => {
|
|
448
|
+
// `import type { Context } from 'hono'` is ERASED: it emits nothing, so the
|
|
449
|
+
// module it names never evaluates and nothing in it is reachable through
|
|
450
|
+
// this edge. Counting it made an app that wants one TYPE from a barrel
|
|
451
|
+
// pull in every module the barrel re-exports -- hono's `index.ts` reaches
|
|
452
|
+
// `RegExpRouter`, `TrieRouter` and `SmartRouter`, none of which
|
|
453
|
+
// `hono/tiny` uses, and their generic bodies accounted for 33 of the
|
|
454
|
+
// program's mandatory obligations. A module imported for a value ANYWHERE
|
|
455
|
+
// else is still reached by that edge; this drops only the edge that
|
|
456
|
+
// carries no evaluation.
|
|
457
|
+
if (ts.isImportDeclaration(node)) {
|
|
458
|
+
if (node.importClause?.isTypeOnly !== true)
|
|
459
|
+
add(node.moduleSpecifier);
|
|
460
|
+
}
|
|
461
|
+
else if (ts.isExportDeclaration(node)) {
|
|
462
|
+
if (!node.isTypeOnly)
|
|
463
|
+
add(node.moduleSpecifier);
|
|
464
|
+
}
|
|
465
|
+
else if (ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference))
|
|
466
|
+
add(node.moduleReference.expression);
|
|
467
|
+
// A dynamic `import()` is an edge whether or not the call ever runs: this
|
|
468
|
+
// over-approximates rather than tying module reachability to control flow.
|
|
469
|
+
else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword)
|
|
470
|
+
add(node.arguments[0]);
|
|
471
|
+
ts.forEachChild(node, visit);
|
|
472
|
+
};
|
|
473
|
+
ts.forEachChild(file, visit);
|
|
474
|
+
return targets;
|
|
475
|
+
};
|
|
476
|
+
/** Every declaration a name can mean, the target of an alias chain included. */
|
|
477
|
+
const declarationsOf = (checker, symbol) => {
|
|
478
|
+
const own = symbol.declarations ?? [];
|
|
479
|
+
if ((symbol.flags & ts.SymbolFlags.Alias) === 0)
|
|
480
|
+
return own;
|
|
481
|
+
// `getAliasedSymbol` resolves the whole chain, which is what a barrel needs:
|
|
482
|
+
// an app's `import { Display } from '@geastack/core'` passes through
|
|
483
|
+
// `runtime.ts`'s `export *` and `runtime-surface.ts`'s `export *` before it
|
|
484
|
+
// reaches the declaration in `runtime/host.ts`.
|
|
485
|
+
const target = checker.getAliasedSymbol(symbol);
|
|
486
|
+
return target === symbol ? own : [...own, ...(target.declarations ?? [])];
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* The order this program's modules evaluate in, as ECMA-262 defines it.
|
|
490
|
+
*
|
|
491
|
+
* A module body RUNS, once, when the module graph is evaluated -- and the
|
|
492
|
+
* order is not an implementation detail a target may pick: `InnerModuleEvaluation`
|
|
493
|
+
* (16.2.1.5.3) evaluates a module's requested modules, in the order the
|
|
494
|
+
* `[[RequestedModules]]` list names them, BEFORE the module's own body. So a
|
|
495
|
+
* module observes the state its imports established, and every import of a
|
|
496
|
+
* module after the first is a no-op. That is post-order over the import graph
|
|
497
|
+
* from the entry points, and a compiler that emitted the bodies in file order,
|
|
498
|
+
* or in whatever order a map happened to iterate, would produce a program
|
|
499
|
+
* whose module state is built in the wrong order -- constants read before the
|
|
500
|
+
* module that assigns them ran.
|
|
501
|
+
*
|
|
502
|
+
* A cycle terminates the same way the spec's does: a module already being
|
|
503
|
+
* evaluated is not re-entered, so its body runs once and the importer that
|
|
504
|
+
* closed the cycle observes it partially initialized. That is the language's
|
|
505
|
+
* answer, not an approximation of it.
|
|
506
|
+
*
|
|
507
|
+
* Files outside this compilation are skipped, exactly as `censusReachability`
|
|
508
|
+
* skips them: a `.d.ts` declares and evaluates nothing, and a file this
|
|
509
|
+
* compiler is not responsible for has no body to run.
|
|
510
|
+
*
|
|
511
|
+
* A SCRIPT is not in that graph at all and runs FIRST. A file with no
|
|
512
|
+
* top-level `import`/`export` is a Script, not a Module (16.1 vs 16.2): its
|
|
513
|
+
* top-level declarations go into the global scope, so no module can name it in
|
|
514
|
+
* `[[RequestedModules]]` and the post-order walk above can never reach it --
|
|
515
|
+
* yet every module can see what it declared. The only order consistent with
|
|
516
|
+
* that is all scripts before any module, which is also the order a host
|
|
517
|
+
* evaluates them in. node-compat's `runtime/node/globals.ts` is one: it
|
|
518
|
+
* declares `Request`/`Response`/`Headers`/`URL` into the global scope for
|
|
519
|
+
* library code that constructs them by name, and without this its class
|
|
520
|
+
* objects were left value-initialized -- hono's `new Request(...)` jumped
|
|
521
|
+
* through a null constructor thunk on the first served request.
|
|
522
|
+
*/
|
|
523
|
+
/**
|
|
524
|
+
* Whether a source file evaluates anything at all.
|
|
525
|
+
*
|
|
526
|
+
* `export {}` followed by `declare global { ... }` is the shape of an ambient
|
|
527
|
+
* module: it exists to put names into the checker's global scope and lowers
|
|
528
|
+
* no body, exactly like a `.d.ts` -- it only carries a `.ts` extension so the
|
|
529
|
+
* project can name it as a real root when a stated module set filters the
|
|
530
|
+
* staged project's file list down to declarations (node-compat's
|
|
531
|
+
* `standard-library.ts`, `node-globals.ts`). Scheduling such a file as a
|
|
532
|
+
* module body would ask the entry to call a function nothing defines, which
|
|
533
|
+
* the printer refuses rather than skips (`entryDefinitionOf`).
|
|
534
|
+
*
|
|
535
|
+
* Only statements with NO runtime meaning qualify: `declare`d declarations,
|
|
536
|
+
* interfaces, type aliases, type-only imports, and an export declaration that
|
|
537
|
+
* names nothing (`export {}`) or re-exports types only. Any other statement --
|
|
538
|
+
* a class, a `const`, a call, a real `export` -- and the file evaluates.
|
|
539
|
+
*/
|
|
540
|
+
const evaluatesNothing = (file) => file.statements.every((statement) => {
|
|
541
|
+
if (ts.isInterfaceDeclaration(statement) || ts.isTypeAliasDeclaration(statement))
|
|
542
|
+
return true;
|
|
543
|
+
if (ts.isImportDeclaration(statement))
|
|
544
|
+
return statement.importClause?.isTypeOnly === true;
|
|
545
|
+
if (ts.isExportDeclaration(statement)) {
|
|
546
|
+
if (statement.isTypeOnly)
|
|
547
|
+
return true;
|
|
548
|
+
if (statement.moduleSpecifier !== undefined)
|
|
549
|
+
return false;
|
|
550
|
+
return statement.exportClause !== undefined && ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.length === 0;
|
|
551
|
+
}
|
|
552
|
+
return ts.canHaveModifiers(statement) && (ts.getModifiers(statement) ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.DeclareKeyword);
|
|
553
|
+
});
|
|
554
|
+
export const moduleEvaluationOrder = (input) => {
|
|
555
|
+
const compiled = new Set(input.files);
|
|
556
|
+
const order = [];
|
|
557
|
+
const started = new Set();
|
|
558
|
+
const visit = (file) => {
|
|
559
|
+
if (!compiled.has(file) || started.has(file))
|
|
560
|
+
return;
|
|
561
|
+
started.add(file);
|
|
562
|
+
for (const target of moduleTargetsOf(input.checker, file))
|
|
563
|
+
visit(target);
|
|
564
|
+
if (evaluatesNothing(file))
|
|
565
|
+
return;
|
|
566
|
+
order.push(file);
|
|
567
|
+
};
|
|
568
|
+
for (const file of input.files)
|
|
569
|
+
if (!ts.isExternalModule(file) && !file.isDeclarationFile)
|
|
570
|
+
visit(file);
|
|
571
|
+
for (const entry of input.entries)
|
|
572
|
+
visit(entry);
|
|
573
|
+
return order;
|
|
574
|
+
};
|
|
575
|
+
export const censusReachability = (input) => {
|
|
576
|
+
if (input.entries.length === 0)
|
|
577
|
+
return wholeProgram;
|
|
578
|
+
const compiled = new Set(input.files);
|
|
579
|
+
const entries = new Set(input.entries);
|
|
580
|
+
const liveFiles = new Set();
|
|
581
|
+
const liveStatements = new Set();
|
|
582
|
+
// A receiver's static type requires layout, not evaluation of its module or
|
|
583
|
+
// constructor. A later value reference can promote the same class to runtime.
|
|
584
|
+
const layoutClasses = new Set();
|
|
585
|
+
// Every deferrable member the walk has SEEN, and the subset something has
|
|
586
|
+
// NAMED. A member in the first and not the second is dead: the class it
|
|
587
|
+
// belongs to is live, so the walk reached its declaration, and nothing in
|
|
588
|
+
// live code named it -- `C.m` for a static, the member's own key for an
|
|
589
|
+
// instance member.
|
|
590
|
+
const deferredMembers = new Set();
|
|
591
|
+
const liveMembers = new Set();
|
|
592
|
+
// Every member name live code has spelled, and the deferred INSTANCE members
|
|
593
|
+
// still waiting for one. Grown as the walk runs, never precomputed over the
|
|
594
|
+
// file set: a name spelled only inside a body nothing reaches is not a name
|
|
595
|
+
// this program spells, and precomputing would count it. That is the same
|
|
596
|
+
// fixpoint-from-below `ir/shake.ts` grows its own key set by, and it
|
|
597
|
+
// terminates for the same reason -- a key is only ever added.
|
|
598
|
+
const spelledKeys = new Set([...specificationInvokedKeys, ...(input.hostReachedMemberKeys ?? [])]);
|
|
599
|
+
const pendingByKey = new Map();
|
|
600
|
+
const fileQueue = [...input.entries];
|
|
601
|
+
const memberQueue = [];
|
|
602
|
+
const statementQueue = [];
|
|
603
|
+
const topLevel = new Map();
|
|
604
|
+
const topLevelOf = (file) => {
|
|
605
|
+
const known = topLevel.get(file);
|
|
606
|
+
if (known)
|
|
607
|
+
return known;
|
|
608
|
+
const built = new Set(file.statements);
|
|
609
|
+
topLevel.set(file, built);
|
|
610
|
+
return built;
|
|
611
|
+
};
|
|
612
|
+
const openStatement = (statement, layoutOnly = false) => {
|
|
613
|
+
if (liveStatements.has(statement)) {
|
|
614
|
+
if (!layoutOnly && ts.isClassDeclaration(statement) && layoutClasses.delete(statement))
|
|
615
|
+
statementQueue.push(statement);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (layoutOnly && ts.isClassDeclaration(statement))
|
|
619
|
+
layoutClasses.add(statement);
|
|
620
|
+
liveStatements.add(statement);
|
|
621
|
+
statementQueue.push(statement);
|
|
622
|
+
};
|
|
623
|
+
const openFile = (file) => {
|
|
624
|
+
if (!compiled.has(file) || liveFiles.has(file))
|
|
625
|
+
return;
|
|
626
|
+
liveFiles.add(file);
|
|
627
|
+
// An entry MODULE has no single call root -- a library's exports are its
|
|
628
|
+
// roots and an application's top level is its body -- so it is kept whole
|
|
629
|
+
// and only what it reaches is ever weighed. An entry SCRIPT (no top-level
|
|
630
|
+
// `import`/`export`, ECMA-262 16.1) exports nothing: its roots are exactly
|
|
631
|
+
// the statements that act, and a function declaration nothing in the
|
|
632
|
+
// program names is as dead there as in any other file. Keeping a script
|
|
633
|
+
// whole made every test262 case carry the obligations of the harness's
|
|
634
|
+
// deprecated, never-called helpers (`verifyEqualTo`, `verifyWritable`, ...
|
|
635
|
+
// in propertyHelper.js), whose unannotated parameters no call site ever
|
|
636
|
+
// types -- a refusal inside a body no program reaches denied thousands of
|
|
637
|
+
// cases their certificate.
|
|
638
|
+
const whole = entries.has(file) && ts.isExternalModule(file);
|
|
639
|
+
for (const statement of file.statements)
|
|
640
|
+
if (whole || !isPrunableDeclaration(input.checker, statement))
|
|
641
|
+
openStatement(statement);
|
|
642
|
+
for (const target of moduleTargetsOf(input.checker, file))
|
|
643
|
+
fileQueue.push(target);
|
|
644
|
+
};
|
|
645
|
+
const spellKey = (text) => {
|
|
646
|
+
if (spelledKeys.has(text))
|
|
647
|
+
return;
|
|
648
|
+
spelledKeys.add(text);
|
|
649
|
+
const waiting = pendingByKey.get(text);
|
|
650
|
+
if (!waiting)
|
|
651
|
+
return;
|
|
652
|
+
pendingByKey.delete(text);
|
|
653
|
+
for (const member of waiting)
|
|
654
|
+
openMember(member);
|
|
655
|
+
};
|
|
656
|
+
const markSymbol = (symbol) => {
|
|
657
|
+
if (!symbol)
|
|
658
|
+
return;
|
|
659
|
+
for (const declaration of declarationsOf(input.checker, symbol)) {
|
|
660
|
+
if (ts.isImportSpecifier(declaration) || ts.isImportClause(declaration) || ts.isNamespaceImport(declaration)) {
|
|
661
|
+
let imported = declaration.parent;
|
|
662
|
+
while (imported && !ts.isSourceFile(imported) && !ts.isImportDeclaration(imported))
|
|
663
|
+
imported = imported.parent;
|
|
664
|
+
if (imported && ts.isImportDeclaration(imported)) {
|
|
665
|
+
const module = input.checker.getSymbolAtLocation(imported.moduleSpecifier);
|
|
666
|
+
for (const target of module?.declarations ?? [])
|
|
667
|
+
if (ts.isSourceFile(target))
|
|
668
|
+
fileQueue.push(target);
|
|
669
|
+
}
|
|
670
|
+
// Reading an imported binding needs the imported module. The alias's
|
|
671
|
+
// declaration does not execute every statement in its containing file.
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
// A value's property symbol can be declared by an imported interface
|
|
675
|
+
// (`value.field`), even though this reference is in expression position.
|
|
676
|
+
// Such a declaration provides a layout, never module evaluation.
|
|
677
|
+
let owner = declaration;
|
|
678
|
+
while (owner && !ts.isSourceFile(owner) && !ts.isInterfaceDeclaration(owner) && !ts.isTypeAliasDeclaration(owner))
|
|
679
|
+
owner = owner.parent;
|
|
680
|
+
if (owner && (ts.isInterfaceDeclaration(owner) || ts.isTypeAliasDeclaration(owner)))
|
|
681
|
+
continue;
|
|
682
|
+
if (ts.isSourceFile(declaration)) {
|
|
683
|
+
fileQueue.push(declaration);
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
const file = declaration.getSourceFile();
|
|
687
|
+
if (!compiled.has(file))
|
|
688
|
+
continue;
|
|
689
|
+
let memberOwner = declaration.parent;
|
|
690
|
+
while (memberOwner && !ts.isSourceFile(memberOwner) && !ts.isClassDeclaration(memberOwner))
|
|
691
|
+
memberOwner = memberOwner.parent;
|
|
692
|
+
if (memberOwner && ts.isClassDeclaration(memberOwner) && !liveFiles.has(file)) {
|
|
693
|
+
openStatement(memberOwner, true);
|
|
694
|
+
if (memberIsDeferrable(declaration))
|
|
695
|
+
openMember(declaration);
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
// Naming something in a file this walk had not reached resurrects the
|
|
699
|
+
// file, so a missed import edge or a global script costs precision and
|
|
700
|
+
// never correctness.
|
|
701
|
+
if (!liveFiles.has(file))
|
|
702
|
+
fileQueue.push(file);
|
|
703
|
+
// Naming a deferrable static member is what makes its body live. The
|
|
704
|
+
// class's own statement is opened either way by the walk below, which is
|
|
705
|
+
// what keeps the LAYOUT of a class whose statics nothing calls intact.
|
|
706
|
+
if (memberIsDeferrable(declaration))
|
|
707
|
+
openMember(declaration);
|
|
708
|
+
let current = declaration;
|
|
709
|
+
while (current.parent && !ts.isSourceFile(current.parent))
|
|
710
|
+
current = current.parent;
|
|
711
|
+
if (current.parent && topLevelOf(file).has(current))
|
|
712
|
+
openStatement(current);
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
const markReference = (reference) => markSymbol(input.checker.getSymbolAtLocation(reference));
|
|
716
|
+
/**
|
|
717
|
+
* A member READ on a receiver typed as a class keeps that class's
|
|
718
|
+
* definition, and only that.
|
|
719
|
+
*
|
|
720
|
+
* Type nodes are erased (see `markReferences`), and an inert class
|
|
721
|
+
* definition -- no `extends`, no static body -- is prunable, so a class the
|
|
722
|
+
* program names only in annotations was dropped whole. Its struct was still
|
|
723
|
+
* emitted from the type table, which reads checker types independently of
|
|
724
|
+
* this walk; but the member LAYOUT the emitter consults comes from the
|
|
725
|
+
* class-lifecycle census over the statements this walk kept, so every read
|
|
726
|
+
* of a member on such an instance refused at emission as "no class
|
|
727
|
+
* evaluation published". Three's `Skeleton` is the shape: `SkinnedMesh`
|
|
728
|
+
* names it in `@param {Skeleton}` and reads `skeleton.boneTexture`, and
|
|
729
|
+
* nothing in an application without skinning ever constructs one.
|
|
730
|
+
*
|
|
731
|
+
* The trigger is the read, not the annotation. Opening every class a live
|
|
732
|
+
* annotation names was measured: three's JSDoc forms one connected graph,
|
|
733
|
+
* and following it from `Skeleton` opened the whole `Curve` hierarchy and
|
|
734
|
+
* more, each carrying walls in code no path executes. A read is what the
|
|
735
|
+
* emitter actually needs a layout for, and a read inside a member only
|
|
736
|
+
* counts once that member is live, so the closure stays bounded by what
|
|
737
|
+
* runs.
|
|
738
|
+
*
|
|
739
|
+
* Opening the class's own statement is not scheduling its module's effects.
|
|
740
|
+
* Layout-only declarations retain heritage and fields but do not run
|
|
741
|
+
* constructors, initializers, or unrelated same-named method bodies. A real
|
|
742
|
+
* value reference promotes the declaration and its module to normal runtime
|
|
743
|
+
* reachability. Otherwise a default-exported alternative in a JSDoc union
|
|
744
|
+
* can make a plain inherited-field read execute an entire unused subsystem.
|
|
745
|
+
*/
|
|
746
|
+
const openClassOfReceiver = (access) => {
|
|
747
|
+
const type = input.checker.getTypeAtLocation(access.expression);
|
|
748
|
+
const arms = type.isUnion() ? type.types : [type];
|
|
749
|
+
for (const arm of arms) {
|
|
750
|
+
if (((arm.symbol?.flags ?? 0) & ts.SymbolFlags.Class) === 0)
|
|
751
|
+
continue;
|
|
752
|
+
for (const declaration of arm.symbol?.declarations ?? []) {
|
|
753
|
+
if (!ts.isClassDeclaration(declaration))
|
|
754
|
+
continue;
|
|
755
|
+
const file = declaration.getSourceFile();
|
|
756
|
+
if (!compiled.has(file) || !topLevelOf(file).has(declaration) || liveStatements.has(declaration))
|
|
757
|
+
continue;
|
|
758
|
+
openStatement(declaration, !liveFiles.has(file));
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* Every class a TYPE names, opened for its LAYOUT alone.
|
|
764
|
+
*
|
|
765
|
+
* An annotation is erased, so it evaluates nothing and this walk rightly
|
|
766
|
+
* refuses to run its module or its constructor. But erasure is not the only
|
|
767
|
+
* thing that happens to it: the checker uses that same annotation to type a
|
|
768
|
+
* live cell, and `representation/derive.ts` turns the result into a
|
|
769
|
+
* `class-ref` carrier naming this declaration. So the class does have to be
|
|
770
|
+
* projected, and layout-only is exactly the promotion that says so -- the
|
|
771
|
+
* one `layoutClasses` already exists for, and the one a heritage clause on
|
|
772
|
+
* an already-layout-only class already takes.
|
|
773
|
+
*
|
|
774
|
+
* Without this the two authorities disagree, and the disagreement is not
|
|
775
|
+
* benign. A class the walk never opens publishes no class-lifecycle
|
|
776
|
+
* operation, so `projection/classes.ts` has no row for it; `records.ts` then
|
|
777
|
+
* renders its struct from the checker's FLATTENED shape with no base clause
|
|
778
|
+
* (`classBaseLinks` reads the same empty row), and `hasClosedFixedLayout`
|
|
779
|
+
* reports its storage unproven for want of a layout that was never missing
|
|
780
|
+
* -- so the object gets the unrestricted field protocol over a struct that
|
|
781
|
+
* repeats every inherited member. In the three.js app that is fourteen carriers, and
|
|
782
|
+
* three of them (`Bone`, `Node`, `InstancedBufferAttribute`, each named only
|
|
783
|
+
* inside a JSDoc annotation in a live file) were the program's three largest
|
|
784
|
+
* reflection consumers.
|
|
785
|
+
*
|
|
786
|
+
* Over-marking is the safe direction here for the reason this module's
|
|
787
|
+
* header already gives, and layout-only is the smallest promotion there is:
|
|
788
|
+
* no module evaluation, no constructor, no member body.
|
|
789
|
+
*/
|
|
790
|
+
const markTypeNamedClasses = (node) => {
|
|
791
|
+
const named = ts.isTypeReferenceNode(node) ? node.typeName : ts.isExpressionWithTypeArguments(node) ? node.expression : null;
|
|
792
|
+
if (named !== null) {
|
|
793
|
+
const symbol = input.checker.getSymbolAtLocation(named);
|
|
794
|
+
for (const declaration of symbol ? declarationsOf(input.checker, symbol) : []) {
|
|
795
|
+
if (!ts.isClassDeclaration(declaration))
|
|
796
|
+
continue;
|
|
797
|
+
const file = declaration.getSourceFile();
|
|
798
|
+
if (!compiled.has(file) || !topLevelOf(file).has(declaration) || liveStatements.has(declaration))
|
|
799
|
+
continue;
|
|
800
|
+
openStatement(declaration, !liveFiles.has(file));
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
ts.forEachChild(node, markTypeNamedClasses);
|
|
804
|
+
};
|
|
805
|
+
/**
|
|
806
|
+
* The same question for a JSDoc annotation, which `ts.forEachChild` does not
|
|
807
|
+
* reach: JSDoc hangs off a node's comment ranges rather than its child list,
|
|
808
|
+
* so a `@type`/`@param`/`@returns` type node is invisible to this walk while
|
|
809
|
+
* being fully visible to the checker. Three.js types its whole public
|
|
810
|
+
* surface this way, which is why every carrier in the state described above
|
|
811
|
+
* is a class whose only mention in live code is inside a JSDoc comment.
|
|
812
|
+
*/
|
|
813
|
+
const markJsDocNamedClasses = (node) => {
|
|
814
|
+
for (const tag of ts.getJSDocTags(node)) {
|
|
815
|
+
if (ts.isJSDocAugmentsTag(tag) || ts.isJSDocImplementsTag(tag)) {
|
|
816
|
+
markTypeNamedClasses(tag.class);
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
// Every tag whose payload is a type expression, narrowed by name because
|
|
820
|
+
// `typeExpression` is declared per tag rather than on `JSDocTag` itself.
|
|
821
|
+
const expression = ts.isJSDocTypeTag(tag) ||
|
|
822
|
+
ts.isJSDocParameterTag(tag) ||
|
|
823
|
+
ts.isJSDocReturnTag(tag) ||
|
|
824
|
+
ts.isJSDocPropertyTag(tag) ||
|
|
825
|
+
ts.isJSDocThisTag(tag) ||
|
|
826
|
+
ts.isJSDocEnumTag(tag) ||
|
|
827
|
+
ts.isJSDocSatisfiesTag(tag) ||
|
|
828
|
+
ts.isJSDocTypedefTag(tag)
|
|
829
|
+
? tag.typeExpression
|
|
830
|
+
: undefined;
|
|
831
|
+
if (expression !== undefined && ts.isJSDocTypeExpression(expression))
|
|
832
|
+
markTypeNamedClasses(expression.type);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
const markReferences = (node) => {
|
|
836
|
+
markJsDocNamedClasses(node);
|
|
837
|
+
if (ts.isClassDeclaration(node) && layoutClasses.has(node)) {
|
|
838
|
+
for (const heritage of node.heritageClauses ?? []) {
|
|
839
|
+
if (heritage.token !== ts.SyntaxKind.ExtendsKeyword)
|
|
840
|
+
continue;
|
|
841
|
+
for (const type of heritage.types) {
|
|
842
|
+
const symbol = input.checker.getSymbolAtLocation(type.expression);
|
|
843
|
+
const declarations = symbol ? declarationsOf(input.checker, symbol).filter(ts.isClassDeclaration) : [];
|
|
844
|
+
if (declarations.length === 0)
|
|
845
|
+
markReferences(type.expression);
|
|
846
|
+
else
|
|
847
|
+
for (const declaration of declarations) {
|
|
848
|
+
if (compiled.has(declaration.getSourceFile()))
|
|
849
|
+
openStatement(declaration, !liveFiles.has(declaration.getSourceFile()));
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
for (const member of node.members) {
|
|
854
|
+
if (ts.isConstructorDeclaration(member) || ts.isClassStaticBlockDeclaration(member))
|
|
855
|
+
continue;
|
|
856
|
+
if (ts.isPropertyDeclaration(member)) {
|
|
857
|
+
if (ts.isComputedPropertyName(member.name))
|
|
858
|
+
markReferences(member.name);
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
if (memberIsDeferrable(member) && !liveMembers.has(member)) {
|
|
862
|
+
// A type-only class is not a possible runtime override merely
|
|
863
|
+
// because unrelated live code spells the same method name. Direct
|
|
864
|
+
// member references still open its body through markSymbol. Runtime
|
|
865
|
+
// promotion revisits the class and enables ordinary key dispatch.
|
|
866
|
+
deferredMembers.add(member);
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
markReferences(member);
|
|
870
|
+
}
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node) || ts.isImportEqualsDeclaration(node))
|
|
874
|
+
return;
|
|
875
|
+
if (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node))
|
|
876
|
+
return;
|
|
877
|
+
if (ts.isTypeNode(node)) {
|
|
878
|
+
// `extends Base<T>` evaluates Base for a class; every other type node
|
|
879
|
+
// is erased. Following an annotation through an import-type alias must
|
|
880
|
+
// not schedule that module's top-level effects. Layout derivation still
|
|
881
|
+
// reads all checker types independently of this runtime reachability walk.
|
|
882
|
+
if (ts.isExpressionWithTypeArguments(node) &&
|
|
883
|
+
ts.isHeritageClause(node.parent) &&
|
|
884
|
+
node.parent.token === ts.SyntaxKind.ExtendsKeyword &&
|
|
885
|
+
(ts.isClassDeclaration(node.parent.parent) || ts.isClassExpression(node.parent.parent)))
|
|
886
|
+
markReferences(node.expression);
|
|
887
|
+
else
|
|
888
|
+
markTypeNamedClasses(node);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (ts.isPropertyAccessExpression(node))
|
|
892
|
+
openClassOfReceiver(node);
|
|
893
|
+
if (ts.isNewExpression(node)) {
|
|
894
|
+
for (const signature of input.checker.getTypeAtLocation(node.expression).getConstructSignatures()) {
|
|
895
|
+
const result = input.checker.getReturnTypeOfSignature(signature);
|
|
896
|
+
for (const arm of result.isUnion() ? result.types : [result]) {
|
|
897
|
+
if (((arm.symbol?.flags ?? 0) & ts.SymbolFlags.Class) !== 0)
|
|
898
|
+
markSymbol(arm.symbol);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
// `{ get }` NAMES `get`, and `getSymbolAtLocation` on that identifier
|
|
903
|
+
// answers the PROPERTY it declares, not the value it reads -- the one
|
|
904
|
+
// reference shape where the identifier's own symbol is the wrong end of
|
|
905
|
+
// the edge. Without this, a function nothing else in the program calls was
|
|
906
|
+
// pruned while a live module-scope object literal still read it, and
|
|
907
|
+
// emission refused the read as "a declaration this program never
|
|
908
|
+
// introduces": `http.ts`'s CommonJS-style default namespace naming its own
|
|
909
|
+
// `get`.
|
|
910
|
+
if (ts.isShorthandPropertyAssignment(node))
|
|
911
|
+
markSymbol(input.checker.getShorthandAssignmentValueSymbol(node));
|
|
912
|
+
// A runtime key on a class constructor can select any declared static
|
|
913
|
+
// member. There is no property-name symbol at `C[key]` for the walk to
|
|
914
|
+
// follow, so keep the constructor type's finite static surface live. The
|
|
915
|
+
// emitter later dispatches over this same set; pruning a method here would
|
|
916
|
+
// leave a valid key out of that dispatch and turn `C[String('m')]()` into
|
|
917
|
+
// an invocation of undefined. `getProperties()` includes inherited
|
|
918
|
+
// statics, while the class-symbol/construct-signature guard keeps ordinary
|
|
919
|
+
// object element accesses on the existing key-directed path.
|
|
920
|
+
if (ts.isElementAccessExpression(node)) {
|
|
921
|
+
const receiver = input.checker.getTypeAtLocation(node.expression);
|
|
922
|
+
const arms = receiver.isUnion() ? receiver.types : [receiver];
|
|
923
|
+
for (const arm of arms) {
|
|
924
|
+
if ((arm.symbol?.flags ?? 0) & ts.SymbolFlags.Class && arm.getConstructSignatures().length > 0) {
|
|
925
|
+
for (const property of arm.getProperties())
|
|
926
|
+
markSymbol(property);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
if (ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) {
|
|
931
|
+
markReference(node);
|
|
932
|
+
// EVERY identifier, not only one in member position, and measured that
|
|
933
|
+
// way: narrowing this to `o.close` / `const { close } = o` and letting a
|
|
934
|
+
// bare identifier spell nothing left the mongodb probe on the same 1635
|
|
935
|
+
// unmet obligations, so precision bought nothing there while
|
|
936
|
+
// over-marking costs only dead code left in. Under-marking is the one
|
|
937
|
+
// direction that could drop a live body, which is why the walk stays
|
|
938
|
+
// blunt about which names count -- exactly as this module's own header
|
|
939
|
+
// says it is blunt about references.
|
|
940
|
+
spellKey(node.text);
|
|
941
|
+
}
|
|
942
|
+
// `o['close']` is the same dispatch `o.close` is, wherever the string sits
|
|
943
|
+
// -- `Reflect.get(o, 'close')`, a key held in a `const`. A TEMPLATE with
|
|
944
|
+
// substitutions spells nothing, and neither does a computed key, which is
|
|
945
|
+
// sound here for the reason `ir/shake.ts`'s own `MemberReach` states: this
|
|
946
|
+
// backend can address a method or accessor only through a key spelled at
|
|
947
|
+
// compile time.
|
|
948
|
+
if (ts.isStringLiteralLike(node))
|
|
949
|
+
spellKey(node.text);
|
|
950
|
+
// A method's body is held back until something names it, exactly as a
|
|
951
|
+
// top-level function declaration's is. Its own name and its parameter list
|
|
952
|
+
// still walk -- the signature is part of the class's shape, and a
|
|
953
|
+
// parameter's default runs at call time -- so only the body waits.
|
|
954
|
+
if (memberIsDeferrable(node)) {
|
|
955
|
+
deferredMembers.add(node);
|
|
956
|
+
if (!memberIsStatic(node) && !liveMembers.has(node)) {
|
|
957
|
+
const key = memberKeyOf(node);
|
|
958
|
+
// Opened straight into `liveMembers` rather than through `openMember`:
|
|
959
|
+
// this node is being walked right now, and queueing it as well would
|
|
960
|
+
// walk the same body twice. A member with no readable key is kept.
|
|
961
|
+
if (key === null || spelledKeys.has(key))
|
|
962
|
+
liveMembers.add(node);
|
|
963
|
+
else
|
|
964
|
+
pendingByKey.set(key, [...(pendingByKey.get(key) ?? []), node]);
|
|
965
|
+
}
|
|
966
|
+
if (!liveMembers.has(node)) {
|
|
967
|
+
for (const parameter of node.parameters)
|
|
968
|
+
markReferences(parameter);
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
ts.forEachChild(node, markReferences);
|
|
973
|
+
};
|
|
974
|
+
const openMember = (member) => {
|
|
975
|
+
if (liveMembers.has(member))
|
|
976
|
+
return;
|
|
977
|
+
liveMembers.add(member);
|
|
978
|
+
// Walked now if the class was already opened, and by `markReferences` when
|
|
979
|
+
// it is -- either order reaches the body exactly once.
|
|
980
|
+
if (deferredMembers.has(member))
|
|
981
|
+
memberQueue.push(member);
|
|
982
|
+
};
|
|
983
|
+
while (fileQueue.length > 0 || statementQueue.length > 0 || memberQueue.length > 0) {
|
|
984
|
+
const file = fileQueue.pop();
|
|
985
|
+
if (file) {
|
|
986
|
+
openFile(file);
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
const member = memberQueue.pop();
|
|
990
|
+
if (member) {
|
|
991
|
+
ts.forEachChild(member, markReferences);
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
994
|
+
const statement = statementQueue.pop();
|
|
995
|
+
if (statement)
|
|
996
|
+
markReferences(statement);
|
|
997
|
+
}
|
|
998
|
+
// A layout-only class publishes no `bind-class-value` constructor object and
|
|
999
|
+
// therefore no binding for its own NAME (`producers/class-lifecycle.ts`), so
|
|
1000
|
+
// a program that reads that name as a value -- `v instanceof C`, `const K =
|
|
1001
|
+
// C` -- refuses at emission with nothing but a declaration id to go on. The
|
|
1002
|
+
// list is one line per class and is only ever wanted while tracking such a
|
|
1003
|
+
// refusal down, so it is an instrument like `GEA_SHAKE_DEBUG`, not a result.
|
|
1004
|
+
if (process.env['GEA_REACH_DEBUG'])
|
|
1005
|
+
for (const node of layoutClasses) {
|
|
1006
|
+
const file = node.getSourceFile();
|
|
1007
|
+
const { line } = file.getLineAndCharacterOfPosition(node.getStart(file));
|
|
1008
|
+
console.log(`[REACH] layout-only class ${node.name?.text ?? '<anonymous>'} ${file.fileName}:${line + 1}`);
|
|
1009
|
+
}
|
|
1010
|
+
// The same question per FILE, for the case the list above answers `no` to:
|
|
1011
|
+
// a class that is neither live nor layout-only was never opened at all, and
|
|
1012
|
+
// the difference between "opened for its layout" and "never reached" is the
|
|
1013
|
+
// difference between a class with a projected row and one the checker types
|
|
1014
|
+
// while no census ever saw it. Keyed by a file-name substring because the
|
|
1015
|
+
// answer is only ever wanted about one file.
|
|
1016
|
+
const fileWatch = process.env['GEA_REACH_WATCH'];
|
|
1017
|
+
if (fileWatch)
|
|
1018
|
+
for (const file of input.files) {
|
|
1019
|
+
if (!file.fileName.includes(fileWatch))
|
|
1020
|
+
continue;
|
|
1021
|
+
console.log(`[REACH] file ${file.fileName} live=${liveFiles.has(file)}`);
|
|
1022
|
+
for (const statement of file.statements) {
|
|
1023
|
+
if (!ts.isClassDeclaration(statement))
|
|
1024
|
+
continue;
|
|
1025
|
+
const { line } = file.getLineAndCharacterOfPosition(statement.getStart(file));
|
|
1026
|
+
const state = layoutClasses.has(statement) ? 'layout-only' : liveStatements.has(statement) ? 'live' : 'unreached';
|
|
1027
|
+
console.log(`[REACH] class ${statement.name?.text ?? '<anonymous>'}:${line + 1} ${state}`);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
const reached = new Map();
|
|
1031
|
+
return {
|
|
1032
|
+
classIsLayoutOnly: (node) => layoutClasses.has(node),
|
|
1033
|
+
memberIsPruned: (node) => {
|
|
1034
|
+
if (deferredMembers.has(node) && !liveMembers.has(node))
|
|
1035
|
+
return true;
|
|
1036
|
+
const parent = node.parent;
|
|
1037
|
+
if (!parent)
|
|
1038
|
+
return false;
|
|
1039
|
+
if (ts.isHeritageClause(node) && ts.isClassDeclaration(parent) && layoutClasses.has(parent))
|
|
1040
|
+
return true;
|
|
1041
|
+
if ((ts.isConstructorDeclaration(node) || ts.isClassStaticBlockDeclaration(node)) && ts.isClassDeclaration(parent))
|
|
1042
|
+
return layoutClasses.has(parent);
|
|
1043
|
+
return (ts.isPropertyDeclaration(parent) &&
|
|
1044
|
+
parent.initializer === node &&
|
|
1045
|
+
ts.isClassDeclaration(parent.parent) &&
|
|
1046
|
+
layoutClasses.has(parent.parent));
|
|
1047
|
+
},
|
|
1048
|
+
statementsOf: (file) => {
|
|
1049
|
+
const known = reached.get(file);
|
|
1050
|
+
if (known)
|
|
1051
|
+
return known;
|
|
1052
|
+
const built = file.statements.filter((statement) => liveStatements.has(statement));
|
|
1053
|
+
reached.set(file, built);
|
|
1054
|
+
return built;
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
};
|