@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,1003 @@
|
|
|
1
|
+
import { dictionaryKeyDomainOf, representationKey } from '../../../representation/model.js';
|
|
2
|
+
import { hasReferenceIdentity } from '../../../representation/collections.js';
|
|
3
|
+
import { thrownValueCarrier } from '../../../ir/lower-exceptions.js';
|
|
4
|
+
import { alignedValueText, callableObjectAbi } from '../emit-narrowing.js';
|
|
5
|
+
import { cppConstantLiteral, cppStringLiteral, cppTypeOf, cppUndefinedValue } from '../types.js';
|
|
6
|
+
import { createCppEmitBlockedError, operandText, prototypeMethodReceiverText } from '../emit-context.js';
|
|
7
|
+
import { arrayMethods } from './emit-prototype-array.js';
|
|
8
|
+
import { dateCallText } from './emit-prototype-date.js';
|
|
9
|
+
import { nativeErrorCallText } from './emit-prototype-error.js';
|
|
10
|
+
import { unionToStringCallText } from '../emit-union-properties.js';
|
|
11
|
+
import { iteratorCallText } from './emit-prototype-iterator.js';
|
|
12
|
+
import { stringMethods } from './emit-prototype-string.js';
|
|
13
|
+
import { regexpMethodCallText } from './emit-prototype-regexp.js';
|
|
14
|
+
import { dataViewCallText, typedArrayCallText, typedArrayElementSpelling } from '../emit-buffers.js';
|
|
15
|
+
import { keyedTableKeyText } from '../emit-carrier-members.js';
|
|
16
|
+
import { callableShapeCallText, dynamicObjectCallText, nativeHandleShapeCallText, objectShapeCallText } from '../host/object-protocol.js';
|
|
17
|
+
/**
|
|
18
|
+
* `String.prototype`/`Number.prototype`/`Array.prototype` calls that fuse a deferred `[[Get]]`
|
|
19
|
+
* (`emit-carrier-members.ts`'s `stringMemberText`/`arrayAccessText`) with the
|
|
20
|
+
* call that follows it into one C++ expression.
|
|
21
|
+
*
|
|
22
|
+
* This is the identical two-step shape `emit-host-invoke.ts`'s `hostCallText`
|
|
23
|
+
* already uses for a host method (`el.setAttribute(k, v)`) -- the access
|
|
24
|
+
* records which member was reached off which receiver and renders nothing;
|
|
25
|
+
* the call reads that record and renders the whole thing at once -- applied
|
|
26
|
+
* to a different receiver family for a different reason. A host member is
|
|
27
|
+
* deferred because the *host* states no spelling for the bare member, only
|
|
28
|
+
* for the call. A String/Array prototype member is deferred because ECMA-262
|
|
29
|
+
* gives the ambient `lib.es5.d.ts` interface method no `this` parameter at
|
|
30
|
+
* all (`stringMemberText`'s own comment), so there is no receiver-carrying
|
|
31
|
+
* calling convention this backend could build a first-class `CallableObject`
|
|
32
|
+
* from -- the receiver has to be fused in at the call site instead of routed
|
|
33
|
+
* through one.
|
|
34
|
+
*
|
|
35
|
+
* `ctx.prototypeMethodReads` is a map of its own, separate from
|
|
36
|
+
* `ctx.hostMemberReads`: the two mechanisms share a shape but not a table, so
|
|
37
|
+
* a String/Array method can never be mistaken for (or silently fall through
|
|
38
|
+
* to) a real `gea::host` protocol member, and `hostCallText`'s own
|
|
39
|
+
* fail-closed "no method template" guard stays exactly as strict as it was
|
|
40
|
+
* for every actual host member.
|
|
41
|
+
*
|
|
42
|
+
* Every member is refused by name at the `[[Get]]`, before this file is ever
|
|
43
|
+
* reached, unless its own family's table has a renderer for it. Each family
|
|
44
|
+
* exports that table's key set so `emit-carrier-members.ts` defers exactly the
|
|
45
|
+
* keys a renderer exists for -- one authority for "is this method
|
|
46
|
+
* implemented", not two lists that could drift apart.
|
|
47
|
+
*
|
|
48
|
+
* The two large families live in files of their own, because the table IS the
|
|
49
|
+
* content and `String.prototype` and `Array.prototype` each have enough of it
|
|
50
|
+
* to bury the dispatch below:
|
|
51
|
+
*
|
|
52
|
+
* - `emit-prototype-string.ts` -- `stringMethods` / `stringPrototypeMethods`
|
|
53
|
+
* / `stringMemberRefusals`
|
|
54
|
+
* - `emit-prototype-array.ts` -- `arrayMethods` / `arrayPrototypeMethods`
|
|
55
|
+
* / `arrayMemberRefusals`
|
|
56
|
+
*
|
|
57
|
+
* What stays here is `Number.prototype`, `Promise.prototype`, the four keyed
|
|
58
|
+
* collections, and the dispatch that routes a deferred read to its family.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* ECMA-262 21.1.3.3/21.1.3.2/21.1.3.5 `Number.prototype.toFixed` /
|
|
62
|
+
* `toExponential` / `toPrecision`.
|
|
63
|
+
*
|
|
64
|
+
* One argument, and `gea_runtime.h` already implements all three -- ported
|
|
65
|
+
* from v1's own `gea::runtime::numeric` family, digit clamping and the
|
|
66
|
+
* NaN/Infinity arms included -- so what is added here is only the fusion of
|
|
67
|
+
* the deferred `[[Get]]` with its call, exactly as `substring` is.
|
|
68
|
+
*
|
|
69
|
+
* The zero-argument forms are refused rather than defaulted. ECMA-262 gives
|
|
70
|
+
* `toFixed()` an implied `fractionDigits` of 0 and `toPrecision()` a
|
|
71
|
+
* ToString-of-the-number result that is a *different* operation, and an
|
|
72
|
+
* omitted trailing optional argument never reaches `operation.arguments` at
|
|
73
|
+
* all (`substringText`'s own note) -- so synthesizing a digit count here
|
|
74
|
+
* would render one of those two forms as the other for `toPrecision`, which
|
|
75
|
+
* is a wrong answer rather than a missing one.
|
|
76
|
+
*/
|
|
77
|
+
const numberFormatText = (member, clause) => (ctx, receiverText, args) => {
|
|
78
|
+
const digits = args[0];
|
|
79
|
+
if (args.length !== 1 || !digits) {
|
|
80
|
+
throw createCppEmitBlockedError(`host-invocation:Number.prototype.${member}`, `"Number.prototype.${member}" is spelled for its one digits argument (ECMA-262 ${clause}); this call passes ${args.length}` +
|
|
81
|
+
(args.length === 0 ? ', and the argument-less form is a different operation rather than this one with a default' : ''));
|
|
82
|
+
}
|
|
83
|
+
if (digits.representation.kind !== 'scalar' || digits.representation.domain !== 'number') {
|
|
84
|
+
throw createCppEmitBlockedError(`host-invocation:Number.prototype.${member}`, `"Number.prototype.${member}"'s digits argument carries a "${representationKey(digits.representation)}" carrier, not a number scalar`);
|
|
85
|
+
}
|
|
86
|
+
return `gea::host::detail::${member}(${receiverText}, ${operandText(ctx, digits)})`;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* `Number.prototype.toString` -- ECMA-262 21.1.3.6.
|
|
90
|
+
*
|
|
91
|
+
* The one number method here whose radix argument is genuinely optional, and
|
|
92
|
+
* the two forms are two different runtime functions rather than one with a
|
|
93
|
+
* default: 21.1.3.6 step 5 says a radix of 10 *is* `Number::toString(x)`, the
|
|
94
|
+
* same operation `ToString(number)` performs, and every other radix is the
|
|
95
|
+
* separate digit-layout the following steps describe.
|
|
96
|
+
*/
|
|
97
|
+
const numberToStringText = (ctx, receiverText, args) => {
|
|
98
|
+
if (args.length === 0)
|
|
99
|
+
return `gea::host::detail::toString(${receiverText})`;
|
|
100
|
+
const radix = args[0];
|
|
101
|
+
if (args.length !== 1 || !radix) {
|
|
102
|
+
throw createCppEmitBlockedError('host-invocation:Number.prototype.toString', `"Number.prototype.toString" takes at most one radix argument (ECMA-262 21.1.3.6); this call passes ${args.length}`);
|
|
103
|
+
}
|
|
104
|
+
if (radix.representation.kind === 'optional' &&
|
|
105
|
+
radix.representation.absence === 'undefined' &&
|
|
106
|
+
radix.representation.payload.kind === 'scalar' &&
|
|
107
|
+
radix.representation.payload.domain === 'number') {
|
|
108
|
+
const text = operandText(ctx, radix);
|
|
109
|
+
return `(${text}.has_value() ? gea::host::detail::toStringRadix(${receiverText}, *${text}) : gea::host::detail::toString(${receiverText}))`;
|
|
110
|
+
}
|
|
111
|
+
if (radix.representation.kind !== 'scalar' || radix.representation.domain !== 'number') {
|
|
112
|
+
throw createCppEmitBlockedError('host-invocation:Number.prototype.toString', `"Number.prototype.toString"'s radix argument carries a "${representationKey(radix.representation)}" carrier, not a number scalar`);
|
|
113
|
+
}
|
|
114
|
+
return `gea::host::detail::toStringRadix(${receiverText}, ${operandText(ctx, radix)})`;
|
|
115
|
+
};
|
|
116
|
+
/** `emit-carrier-members.ts`'s `scalarMemberText` defers exactly these keys off a number-domain `scalar` receiver. */
|
|
117
|
+
const numberMethods = new Map([
|
|
118
|
+
['toFixed', numberFormatText('toFixed', '21.1.3.3')],
|
|
119
|
+
['toExponential', numberFormatText('toExponential', '21.1.3.2')],
|
|
120
|
+
['toPrecision', numberFormatText('toPrecision', '21.1.3.5')],
|
|
121
|
+
['toString', numberToStringText],
|
|
122
|
+
[
|
|
123
|
+
'valueOf',
|
|
124
|
+
(_ctx, receiverText, args) => {
|
|
125
|
+
if (args.length !== 0) {
|
|
126
|
+
throw createCppEmitBlockedError('host-invocation:Number.prototype.valueOf', `"Number.prototype.valueOf" takes no arguments; this call passes ${args.length}`);
|
|
127
|
+
}
|
|
128
|
+
return receiverText;
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
]);
|
|
132
|
+
/** The locals `promiseReactionText`'s rendering binds, named out of every body-local namespace its text can be spliced into. */
|
|
133
|
+
const caughtSettledName = 'gea_catch_settled';
|
|
134
|
+
const caughtReasonName = 'gea_catch_reason';
|
|
135
|
+
const caughtValueName = 'gea_catch_value';
|
|
136
|
+
const catchResultName = 'gea_catch_result';
|
|
137
|
+
const catchHandlerName = 'gea_catch_handler';
|
|
138
|
+
const fulfilledHandlerName = 'gea_then_handler';
|
|
139
|
+
const fulfilledValueName = 'gea_then_value';
|
|
140
|
+
const settledResultName = 'gea_then_settled';
|
|
141
|
+
/**
|
|
142
|
+
* The fulfillment handler `gea::Promise<V>::then` is actually handed.
|
|
143
|
+
*
|
|
144
|
+
* `then` is a template: it invokes whatever it is given with the promise's OWN
|
|
145
|
+
* payload, `const V&`. The handler the program wrote declares the parameter
|
|
146
|
+
* the CHECKER gave it, which TypeScript only requires `V` to be assignable to
|
|
147
|
+
* -- and assignable is not the same as physically identical. A per-arm
|
|
148
|
+
* dispatch of a union of promises is where the two come apart at their widest:
|
|
149
|
+
* hono's `HonoRequest.#cachedBody` reads `bodyCache[anyCachedKey]`, whose
|
|
150
|
+
* carrier is a `TaggedUnion` of five `Promise`s, and calls `.then(body => ...)`
|
|
151
|
+
* on it with one handler declaring the UNION of the five payloads.
|
|
152
|
+
* `prototype-method-reads.ts`'s mixed-union claim rightly renders that as five
|
|
153
|
+
* arms, one per promise, and each arm then hands `then` a handler whose
|
|
154
|
+
* parameter is the whole union while its own payload is a single arm of it.
|
|
155
|
+
* The result was five `callSettledHandler` substitution failures inside the
|
|
156
|
+
* header and a `Promise<int>` (the degenerate `promise_result_t` of a failed
|
|
157
|
+
* deduction) where the program's own result carrier belonged.
|
|
158
|
+
*
|
|
159
|
+
* So the value is converted into the parameter the handler declared, by the
|
|
160
|
+
* same authority and with the same text `promiseReactionText`'s two-handler
|
|
161
|
+
* form already uses for it (`argumentText`). The adapter is a C++ lambda
|
|
162
|
+
* rather than another `CallableObject`, because `then` names no handler type
|
|
163
|
+
* to build one at and a lambda captures the handler exactly once.
|
|
164
|
+
*
|
|
165
|
+
* Handed straight back where nothing has to be converted -- a handler that
|
|
166
|
+
* declares no parameter at all (27.2.5.4 lets it: `p.then(() => reload())`,
|
|
167
|
+
* which `detail::callSettledHandler` already serves), a receiver whose carrier
|
|
168
|
+
* was not recorded, a `Promise<void>` whose fulfillment value is `undefined`
|
|
169
|
+
* rather than a payload, and the ordinary case where the two agree.
|
|
170
|
+
*/
|
|
171
|
+
const fulfilledHandlerText = (ctx, receiverCarrier, abi, handlerText) => {
|
|
172
|
+
if (receiverCarrier === undefined || abi === null)
|
|
173
|
+
return handlerText;
|
|
174
|
+
const payload = receiverCarrier.value;
|
|
175
|
+
if (payload.kind === 'void')
|
|
176
|
+
return handlerText;
|
|
177
|
+
const slot = abi.parameters[0];
|
|
178
|
+
if (slot === undefined || abi.parameters.length !== 1 || abi.receiver !== null || abi.restFrom !== null)
|
|
179
|
+
return handlerText;
|
|
180
|
+
if (representationKey(slot.value) === representationKey(payload))
|
|
181
|
+
return handlerText;
|
|
182
|
+
const converted = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:then-handler-value', payload, slot.value, fulfilledValueName);
|
|
183
|
+
if (converted === null) {
|
|
184
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(payload)}->${representationKey(slot.value)}`, `a "Promise.prototype.then" handler declares its fulfillment value as "${representationKey(slot.value)}" and no conversion is ` +
|
|
185
|
+
`installed from the "${representationKey(receiverCarrier)}" receiver's own payload`);
|
|
186
|
+
}
|
|
187
|
+
return (`[${fulfilledHandlerName} = ${handlerText}](const ${cppTypeOf(payload)}& ${fulfilledValueName}) ` +
|
|
188
|
+
`{ return ${fulfilledHandlerName}.call(${converted}); }`);
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* ECMA-262 27.2.5.4 `Promise.prototype.then`.
|
|
192
|
+
*
|
|
193
|
+
* `then(onFulfilled)` is the runtime's own member. `gea::Promise<V>::then`
|
|
194
|
+
* deduces the result from the handler, adopts a thenable it returns, and
|
|
195
|
+
* forwards a rejection it was given no handler for -- so nothing is needed
|
|
196
|
+
* here but the result reconciliation below. The callback's own carrier is not
|
|
197
|
+
* checked on that path either: `then` is a template that invokes whatever it
|
|
198
|
+
* is handed with the promise's own payload, so C++ rejects a callable that
|
|
199
|
+
* cannot take it, at the same call this renders.
|
|
200
|
+
*
|
|
201
|
+
* `then(onFulfilled, onRejected)` is NOT that call with one more argument, and
|
|
202
|
+
* it is not `then(f).catch(r)` either: 27.2.5.4 installs both reactions on the
|
|
203
|
+
* SAME promise, so `onRejected` observes the RECEIVER's rejection and never a
|
|
204
|
+
* throw from `onFulfilled` -- 27.2.5.4 step 5 hands both to
|
|
205
|
+
* `PerformPromiseThen` on one `[[PromiseReactions]]` list, where chaining
|
|
206
|
+
* would have given `onFulfilled`'s own abrupt completion somewhere to land.
|
|
207
|
+
* Rendering it as the chain would silently swallow that throw.
|
|
208
|
+
*
|
|
209
|
+
* It also inherits `catch`'s result problem -- the result fulfils with EITHER
|
|
210
|
+
* handler's value, and that union is the representation layer's answer rather
|
|
211
|
+
* than a deduction -- so the two share `promiseReactionText` below, which is
|
|
212
|
+
* where both the reason conversion and the result-carrier agreement live.
|
|
213
|
+
*/
|
|
214
|
+
const promiseThenText = (ctx, receiverText, args, result, receiverCarrier) => {
|
|
215
|
+
const onFulfilled = args[0];
|
|
216
|
+
if (args.length > 2 || !onFulfilled) {
|
|
217
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.then', `"Promise.prototype.then" takes a fulfillment handler and an optional rejection handler (ECMA-262 27.2.5.4); this call passes ${args.length}`);
|
|
218
|
+
}
|
|
219
|
+
const onRejected = args[1];
|
|
220
|
+
if (onRejected !== undefined) {
|
|
221
|
+
return promiseReactionText(ctx, 'then', receiverText, onFulfilled, onRejected, result, receiverCarrier);
|
|
222
|
+
}
|
|
223
|
+
const abi = callableObjectAbi(onFulfilled.representation);
|
|
224
|
+
const text = `${receiverText}.then(${fulfilledHandlerText(ctx, receiverCarrier, abi, operandText(ctx, onFulfilled))})`;
|
|
225
|
+
// `gea::Promise<V>::then` DEDUCES its result from the handler's own result --
|
|
226
|
+
// 27.2.5.4.1 adopts a thenable, so `U` and `Promise<U>` both land on
|
|
227
|
+
// `Promise<U>` -- while the emitter has ALREADY placed a cell for this call.
|
|
228
|
+
// Those are two authorities, and where they disagree the assignment is a bare
|
|
229
|
+
// `no viable overloaded '='`: a handler returning ONE ARM of a sum the cell
|
|
230
|
+
// carries whole is exactly that shape, and `gea::Promise` has no converting
|
|
231
|
+
// constructor from a promise over an arm. Reconciling it here routes the
|
|
232
|
+
// difference through the one conversion authority, which hands the text back
|
|
233
|
+
// untouched when the two already agree (the common case).
|
|
234
|
+
//
|
|
235
|
+
// A handler whose own result is a sum is left alone: the runtime's
|
|
236
|
+
// `promise_result` collapses `TaggedUnion<T, Promise<T>>` to `Promise<T>` and
|
|
237
|
+
// keeps a genuine union of fulfillment values whole, and re-deciding that
|
|
238
|
+
// here would be a THIRD authority free to disagree with both.
|
|
239
|
+
const handlerResult = abi === null ? null : abi.result;
|
|
240
|
+
if (result === null || handlerResult === null || handlerResult.kind === 'tagged-union')
|
|
241
|
+
return text;
|
|
242
|
+
const deduced = { kind: 'promise', value: handlerResult.kind === 'promise' ? handlerResult.value : handlerResult };
|
|
243
|
+
const aligned = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:then', deduced, result.representation, text);
|
|
244
|
+
if (aligned === null) {
|
|
245
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(deduced)}->${representationKey(result.representation)}`, `a "Promise.prototype.then" over a handler returning "${representationKey(handlerResult)}" settles "${representationKey(deduced)}", ` +
|
|
246
|
+
`and no conversion is installed into the cell this call publishes, "${representationKey(result.representation)}"`);
|
|
247
|
+
}
|
|
248
|
+
return aligned;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* ECMA-262 27.2.5.1 `Promise.prototype.catch(onRejected)` -- which step 3
|
|
252
|
+
* defines as `then(undefined, onRejected)` -- and 27.2.5.4's own two-handler
|
|
253
|
+
* form, which is the same machine with the fulfilled arm filled in. One
|
|
254
|
+
* renderer for both, because 27.2.5.1 IS 27.2.5.4 with one argument elided,
|
|
255
|
+
* and two renderers would be two places for the reason conversion and the
|
|
256
|
+
* result agreement to drift apart.
|
|
257
|
+
*
|
|
258
|
+
* Rendered HERE rather than as a `gea::Promise` member, and that is not a
|
|
259
|
+
* style choice. Two things a template member cannot do:
|
|
260
|
+
*
|
|
261
|
+
* - It cannot name the result carrier. `then`'s result is `Promise<U>` for a
|
|
262
|
+
* handler returning `U`, which the runtime deduces exactly; `catch`'s is
|
|
263
|
+
* `Promise<T | TResult>` -- a UNION of the receiver's payload and the
|
|
264
|
+
* handler's result, and the union's carrier is the representation layer's
|
|
265
|
+
* answer, not a deduction. A deduced one would be a second authority, free
|
|
266
|
+
* to disagree with the cell the emitter already placed.
|
|
267
|
+
* - It cannot convert into that carrier. Both arms may need one (the
|
|
268
|
+
* receiver's `T` and the handler's `TResult` into the union), and a
|
|
269
|
+
* conversion is `convertedValueText`'s to render -- boxing needs
|
|
270
|
+
* `dynamicTagFor`, which is emitter-side for the reason
|
|
271
|
+
* `resultAdapterOf` states.
|
|
272
|
+
*
|
|
273
|
+
* So the runtime supplies only what the language cannot express in the
|
|
274
|
+
* emitter: `rejected()`, and `rethrow()` to recover the thrown value. The
|
|
275
|
+
* rejection travels as an `exception_ptr` (see `gea::Promise`'s own comment),
|
|
276
|
+
* and rethrowing inside a handler is how its payload comes back typed -- every
|
|
277
|
+
* `throw` this backend emits carries `thrownValueCarrier`, so `catch (const
|
|
278
|
+
* gea::Value&)` catches all of them, which `emit-exceptions.ts` already checks
|
|
279
|
+
* for the source program's own `try`/`catch`.
|
|
280
|
+
*
|
|
281
|
+
* The three states are all rendered. Rejected: run the handler. Fulfilled: the
|
|
282
|
+
* value passes through unchanged (27.2.5.1 installs no fulfillment handler) or
|
|
283
|
+
* through 27.2.5.4's second-form handler. Unsettled: an unsettled result --
|
|
284
|
+
* there is no value to pass through and no rejection to handle, and reading
|
|
285
|
+
* `value()` there would convert a payload the program never produced.
|
|
286
|
+
*/
|
|
287
|
+
const promiseReactionText = (ctx, family, receiverText, onFulfilled, onRejected, result, receiverCarrier) => {
|
|
288
|
+
const label = family === 'catch' ? 'Promise.prototype.catch' : 'Promise.prototype.then';
|
|
289
|
+
const clause = family === 'catch' ? '27.2.5.1' : '27.2.5.4';
|
|
290
|
+
const published = result === null ? null : result.representation;
|
|
291
|
+
if (published !== null && published.kind !== 'promise') {
|
|
292
|
+
throw createCppEmitBlockedError(`host-invocation:${label}`, `a "${label}" result carries "${representationKey(published)}", not a promise; ${clause} returns one, ` +
|
|
293
|
+
'and a discarded result leaves the two arms no cell to agree on');
|
|
294
|
+
}
|
|
295
|
+
// A result NOBODY reads is not a reason to drop the reaction. `p.catch(h)`
|
|
296
|
+
// and `p.then(f, g)` as STATEMENTS are how @hono/node-server spells every
|
|
297
|
+
// stream teardown, and the handlers still have to run; what is absent is only
|
|
298
|
+
// a cell for the two arms to agree on. So the rendering publishes the one
|
|
299
|
+
// carrier that needs no agreement -- a `Promise<void>` -- and every arm
|
|
300
|
+
// settles it by running rather than by producing a value. The value the
|
|
301
|
+
// program discarded stays discarded; the rejection nothing handled is still
|
|
302
|
+
// held, which is the only part of 27.2.5.1's result still observable.
|
|
303
|
+
const discarded = published === null;
|
|
304
|
+
const carrier = published ?? { kind: 'promise', value: { kind: 'void' } };
|
|
305
|
+
if (receiverCarrier === undefined) {
|
|
306
|
+
throw createCppEmitBlockedError(`host-invocation:${label}`, `a "${label}" reached with no receiver carrier recorded has no fulfilled arm to render`);
|
|
307
|
+
}
|
|
308
|
+
const resultType = cppTypeOf(carrier);
|
|
309
|
+
const handlerAbi = (handler, role) => {
|
|
310
|
+
const abi = callableObjectAbi(handler.representation);
|
|
311
|
+
if (!abi || abi.receiver !== null || abi.restFrom !== null || abi.parameters.length > 1) {
|
|
312
|
+
throw createCppEmitBlockedError(`host-invocation:${label}`, `a "${label}" handler carried as "${representationKey(handler.representation)}" is not a plain 0- or 1-parameter ` +
|
|
313
|
+
`callable; ${clause} calls it with the ${role === 'rejection' ? 'rejection reason' : 'fulfillment value'} and nothing else -- ` +
|
|
314
|
+
'no receiver, no rest pack');
|
|
315
|
+
}
|
|
316
|
+
return abi;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* The argument a reaction handler is called with, converted from whatever
|
|
320
|
+
* the reaction itself has in hand into the parameter the handler declared --
|
|
321
|
+
* or nothing at all, because ECMA-262 passes a value the handler is free not
|
|
322
|
+
* to declare (`p.catch(() => fallback)` is ordinary JavaScript).
|
|
323
|
+
*/
|
|
324
|
+
const argumentText = (abi, source, text, site, note) => {
|
|
325
|
+
const slot = abi.parameters[0];
|
|
326
|
+
if (slot === undefined)
|
|
327
|
+
return '';
|
|
328
|
+
const converted = alignedValueText(ctx, site, source, slot.value, text);
|
|
329
|
+
if (converted === null) {
|
|
330
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(source)}->${representationKey(slot.value)}`, `a "${label}" handler declares its ${note} as "${representationKey(slot.value)}" and no conversion is installed from ` +
|
|
331
|
+
`"${representationKey(source)}"`);
|
|
332
|
+
}
|
|
333
|
+
return converted;
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Settle this call's result from one handler's own result.
|
|
337
|
+
*
|
|
338
|
+
* A handler that itself returns a promise: the result RESOLVES with the
|
|
339
|
+
* handler's result, and resolving with a thenable adopts its state
|
|
340
|
+
* (27.2.5.4.1) -- so the whole promise converts, rather than its payload
|
|
341
|
+
* being wrapped in a fresh one. `convertedValueText`'s promise-to-promise
|
|
342
|
+
* pair is that adoption, rejection and all.
|
|
343
|
+
*
|
|
344
|
+
* A handler that returns NOTHING settles the result by running, not by
|
|
345
|
+
* producing a value to adopt. `void` is not a carrier -- `cppResultTypeOf`
|
|
346
|
+
* elides the payload rather than standing an `Undefined` in for it, and the
|
|
347
|
+
* runtime's `Promise<void>` specialization matches that exactly: `resolve()`
|
|
348
|
+
* takes no argument.
|
|
349
|
+
*/
|
|
350
|
+
const settledText = (abi, handlerName, argument) => {
|
|
351
|
+
const handled = `${handlerName}.call(${argument})`;
|
|
352
|
+
if (discarded)
|
|
353
|
+
return `${handled}; ${catchResultName}.resolve();`;
|
|
354
|
+
if (abi.result.kind === 'void') {
|
|
355
|
+
if (carrier.value.kind === 'void')
|
|
356
|
+
return `${handled}; ${catchResultName}.resolve();`;
|
|
357
|
+
// A function that falls off its end produced `undefined` (ECMA-262
|
|
358
|
+
// 10.2.1.4: an implicit return completion carries it), and the result
|
|
359
|
+
// resolves WITH that. TypeScript writes exactly this as the `| void` arm
|
|
360
|
+
// of `Promise<T | void>` -- `p.catch((e) => { log(e) })` in
|
|
361
|
+
// @hono/node-server's listener -- so refusing here would refuse the
|
|
362
|
+
// program's own declared type. What has to exist is a rendering of
|
|
363
|
+
// absence in the result's payload; where the payload cannot hold one,
|
|
364
|
+
// the handler genuinely cannot settle it and that is still a refusal.
|
|
365
|
+
const absent = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:void-handler', { kind: 'undefined' }, carrier.value, cppUndefinedValue);
|
|
366
|
+
if (absent === null) {
|
|
367
|
+
throw createCppEmitBlockedError(`conversion:void->${representationKey(carrier.value)}`, `a "${label}" handler returns nothing while this call's result carries "${representationKey(carrier)}"; ${clause} ` +
|
|
368
|
+
"resolves the result WITH the handler's result, and this payload has no rendering of the `undefined` it produced");
|
|
369
|
+
}
|
|
370
|
+
return `${handled}; ${catchResultName}.resolve(${absent});`;
|
|
371
|
+
}
|
|
372
|
+
// A handler that MAY have produced a thenable. 27.2.5.4.1 is a per-VALUE
|
|
373
|
+
// test, not a per-type one -- a thenable is adopted and anything else,
|
|
374
|
+
// `undefined` included, resolves to itself -- so an `optional` over a
|
|
375
|
+
// promise settles the result one way when it is present and the other when
|
|
376
|
+
// it is not. @hono/node-server's `writeFromReadableStream` is the shape:
|
|
377
|
+
// its pump is `(result) => Promise<void> | undefined`, the next hop while
|
|
378
|
+
// the source has one and nothing once it is drained, handed straight to
|
|
379
|
+
// `read().then(pump, onError)`.
|
|
380
|
+
//
|
|
381
|
+
// Neither arm below can answer it, and the general one answered it WRONG
|
|
382
|
+
// rather than refusing: `alignedValueText` from an optional thenable into
|
|
383
|
+
// an `undefined` payload is the discard, which folds to the constant
|
|
384
|
+
// `gea::Undefined{}` and drops `handled` entirely -- the handler never ran,
|
|
385
|
+
// and with it the whole rest of the pump. Resolving instead of adopting
|
|
386
|
+
// would be the quieter version of the same loss: the returned promise's
|
|
387
|
+
// rejection is the only part of that chain still observable from here.
|
|
388
|
+
if (abi.result.kind === 'optional' && abi.result.payload.kind === 'promise') {
|
|
389
|
+
const adopted = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:optional-thenable', abi.result.payload, carrier, `(*${settledResultName})`);
|
|
390
|
+
const absent = carrier.value.kind === 'void'
|
|
391
|
+
? ''
|
|
392
|
+
: alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:optional-thenable-absent', { kind: 'undefined' }, carrier.value, cppUndefinedValue);
|
|
393
|
+
if (adopted === null || absent === null) {
|
|
394
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(abi.result)}->${representationKey(carrier)}`, `a "${label}" handler returns "${representationKey(abi.result)}" -- a thenable that may be absent -- and no conversion is ` +
|
|
395
|
+
`installed from ${adopted === null ? 'its payload' : 'the absence it stands for'} into this call's own result ` +
|
|
396
|
+
`"${representationKey(carrier)}"`);
|
|
397
|
+
}
|
|
398
|
+
return (`const auto ${settledResultName} = ${handled}; ` +
|
|
399
|
+
`if ((${settledResultName}).has_value()) ${catchResultName}.adopt(${adopted}); ` +
|
|
400
|
+
`else ${catchResultName}.resolve(${absent});`);
|
|
401
|
+
}
|
|
402
|
+
// The result declares NO payload while the handler produced one. A
|
|
403
|
+
// `Promise<void>` is settled by RUNNING, not by carrying a value: the
|
|
404
|
+
// runtime's `Promise<void>::resolve()` takes no argument, and
|
|
405
|
+
// `gea::Promise<void>(x)` is not a constructor -- the void conversion
|
|
406
|
+
// `alignedValueText` renders for the payload is the discard `(void)(x)`,
|
|
407
|
+
// which the `resultType(...)` wrapper below then tried to build a promise
|
|
408
|
+
// out of ("no matching conversion for functional-style cast from 'void'").
|
|
409
|
+
// @hono/node-server's stream pump is the shape: `reader.read().then(handler,
|
|
410
|
+
// onError)` whose handler returns a value nothing reads, published as a
|
|
411
|
+
// `Promise<void>` because the program's own type says so.
|
|
412
|
+
//
|
|
413
|
+
// A handler returning a PROMISE is excluded and takes the branch below:
|
|
414
|
+
// 27.2.5.4.1 ADOPTS it, so the result settles when that promise settles and
|
|
415
|
+
// rejects if it rejects -- dropping it here would resolve the result early
|
|
416
|
+
// and swallow the rejection.
|
|
417
|
+
if (carrier.value.kind === 'void' && abi.result.kind !== 'promise')
|
|
418
|
+
return `${handled}; ${catchResultName}.resolve();`;
|
|
419
|
+
const arm = abi.result.kind === 'promise'
|
|
420
|
+
? alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:269', abi.result, carrier, handled)
|
|
421
|
+
: ((payload) => (payload === null ? null : `${resultType}(${payload})`))(alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:271', abi.result, carrier.value, handled));
|
|
422
|
+
if (arm === null) {
|
|
423
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(abi.result)}->${representationKey(carrier)}`, `a "${label}" handler returns "${representationKey(abi.result)}" and no conversion is installed into this call's own ` +
|
|
424
|
+
`result "${representationKey(carrier)}"`);
|
|
425
|
+
}
|
|
426
|
+
return `${catchResultName}.adopt(${arm});`;
|
|
427
|
+
};
|
|
428
|
+
const rejectedAbi = handlerAbi(onRejected, 'rejection');
|
|
429
|
+
const rejectedBody = settledText(rejectedAbi, catchHandlerName, argumentText(rejectedAbi, thrownValueCarrier, caughtReasonName, 'prototype/emit-prototype-invoke.ts:253', 'reason'));
|
|
430
|
+
// A `Promise<void>` receiver has no value to hand a fulfilled arm, so
|
|
431
|
+
// `observe`'s fulfilled arm is niladic there (the specialization calls it
|
|
432
|
+
// with no argument) -- and a handler that declared a parameter anyway is
|
|
433
|
+
// handed the `undefined` 27.2.5.4 says the fulfillment value is.
|
|
434
|
+
const voidPayload = receiverCarrier.value.kind === 'void';
|
|
435
|
+
const fulfilledParameter = voidPayload ? '' : `const ${cppTypeOf(receiverCarrier.value)}& ${caughtValueName}`;
|
|
436
|
+
const fulfilledArm = (() => {
|
|
437
|
+
if (onFulfilled !== undefined) {
|
|
438
|
+
const abi = handlerAbi(onFulfilled, 'fulfillment');
|
|
439
|
+
const argument = voidPayload
|
|
440
|
+
? argumentText(abi, { kind: 'undefined' }, cppUndefinedValue, 'prototype/emit-prototype-invoke.ts:then-void-value', 'value')
|
|
441
|
+
: argumentText(abi, receiverCarrier.value, caughtValueName, 'prototype/emit-prototype-invoke.ts:then-value', 'value');
|
|
442
|
+
return (`[${catchResultName}, ${fulfilledHandlerName}](${fulfilledParameter}) mutable { ` +
|
|
443
|
+
`try { ${settledText(abi, fulfilledHandlerName, argument)} } ` +
|
|
444
|
+
`catch (...) { ${catchResultName}.reject(std::current_exception()); } }`);
|
|
445
|
+
}
|
|
446
|
+
// 27.2.5.1 installs no fulfillment handler, so the receiver's fulfillment
|
|
447
|
+
// value travels through unchanged -- unless nobody can read it, in which
|
|
448
|
+
// case the `Promise<void>` above settles by running and the value stops
|
|
449
|
+
// here rather than being converted into a carrier no cell asked for.
|
|
450
|
+
if (discarded) {
|
|
451
|
+
return voidPayload
|
|
452
|
+
? `[${catchResultName}]() mutable { ${catchResultName}.resolve(); }`
|
|
453
|
+
: `[${catchResultName}](const ${cppTypeOf(receiverCarrier.value)}&) mutable { ${catchResultName}.resolve(); }`;
|
|
454
|
+
}
|
|
455
|
+
if (voidPayload && carrier.value.kind !== 'void') {
|
|
456
|
+
throw createCppEmitBlockedError(`conversion:void->${representationKey(carrier.value)}`, `a "${label}" over a "${representationKey(receiverCarrier)}" receiver has no fulfillment value to pass through into ` +
|
|
457
|
+
`"${representationKey(carrier)}"; ${clause} installs no fulfillment handler, so the result can only fulfil with nothing`);
|
|
458
|
+
}
|
|
459
|
+
const passedThrough = voidPayload
|
|
460
|
+
? ''
|
|
461
|
+
: alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:280', receiverCarrier.value, carrier.value, caughtValueName);
|
|
462
|
+
if (passedThrough === null) {
|
|
463
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(receiverCarrier.value)}->${representationKey(carrier.value)}`, `a "${label}" over a "${representationKey(receiverCarrier)}" receiver cannot pass its fulfillment value through into ` +
|
|
464
|
+
`"${representationKey(carrier)}"; ${clause} installs no fulfillment handler, so the value has to travel unchanged`);
|
|
465
|
+
}
|
|
466
|
+
return voidPayload
|
|
467
|
+
? `[${catchResultName}]() mutable { ${catchResultName}.resolve(); }`
|
|
468
|
+
: `[${catchResultName}](${fulfilledParameter}) mutable { ${catchResultName}.resolve(${passedThrough}); }`;
|
|
469
|
+
})();
|
|
470
|
+
const fulfilledBinding = onFulfilled === undefined ? '' : `const auto ${fulfilledHandlerName} = ${operandText(ctx, onFulfilled)}; `;
|
|
471
|
+
return (`([&]() -> ${resultType} { const auto ${caughtSettledName} = ${receiverText}; ${resultType} ${catchResultName}; ` +
|
|
472
|
+
`const auto ${catchHandlerName} = ${operandText(ctx, onRejected)}; ` +
|
|
473
|
+
fulfilledBinding +
|
|
474
|
+
`${caughtSettledName}.observe(` +
|
|
475
|
+
`${fulfilledArm}, ` +
|
|
476
|
+
`[${catchResultName}, ${catchHandlerName}](const std::exception_ptr& gea_catch_rejection) mutable { ` +
|
|
477
|
+
`try { std::rethrow_exception(gea_catch_rejection); } ` +
|
|
478
|
+
`catch (const ${cppTypeOf(thrownValueCarrier)}& ${caughtReasonName}) { try { ${rejectedBody} } ` +
|
|
479
|
+
`catch (...) { ${catchResultName}.reject(std::current_exception()); } } }); return ${catchResultName}; }())`);
|
|
480
|
+
};
|
|
481
|
+
const promiseCatchText = (ctx, receiverText, args, result, receiverCarrier) => {
|
|
482
|
+
const onRejected = args[0];
|
|
483
|
+
if (args.length !== 1 || !onRejected) {
|
|
484
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.catch', `"Promise.prototype.catch" takes one rejection handler (27.2.5.1); this call passes ${args.length}`);
|
|
485
|
+
}
|
|
486
|
+
return promiseReactionText(ctx, 'catch', receiverText, undefined, onRejected, result, receiverCarrier);
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* ECMA-262 27.2.5.3 `Promise.prototype.finally(onFinally)`.
|
|
490
|
+
*
|
|
491
|
+
* Not `then(h, h)`, and not `catch(h)` either: the handler runs on BOTH
|
|
492
|
+
* settlements and changes neither of them. 27.2.5.3's `thenFinally` calls
|
|
493
|
+
* `onFinally` and then returns the original value; `catchFinally` calls it and
|
|
494
|
+
* then RETHROWS the original reason. So the result carries the receiver's
|
|
495
|
+
* settlement through unchanged -- which is why `lib.es5.d.ts` types it
|
|
496
|
+
* `Promise<T>` over the same `T`, with no arm for the handler's own result.
|
|
497
|
+
*
|
|
498
|
+
* The handler is called with NO arguments (27.2.5.3 step 4 builds a niladic
|
|
499
|
+
* `thenFinally`), and its result is dropped -- so the only thing it can
|
|
500
|
+
* contribute to the result is a throw, which 27.2.5.3 lets replace the
|
|
501
|
+
* settlement. The one exception is a THENABLE result: 27.2.5.3 step 5
|
|
502
|
+
* `promiseResolve`s it and waits for it before passing the value on, which
|
|
503
|
+
* this rendering does not do and therefore refuses by name rather than
|
|
504
|
+
* silently running the continuation early. `lib.es5.d.ts` types `onfinally`
|
|
505
|
+
* as `() => void`, so a program has to go out of its way to reach that.
|
|
506
|
+
*/
|
|
507
|
+
const finallyHandlerName = 'gea_finally_handler';
|
|
508
|
+
const promiseFinallyText = (ctx, receiverText, args, result, receiverCarrier) => {
|
|
509
|
+
const onFinally = args[0];
|
|
510
|
+
if (args.length !== 1 || !onFinally) {
|
|
511
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.finally', `"Promise.prototype.finally" takes one handler (ECMA-262 27.2.5.3); this call passes ${args.length}` +
|
|
512
|
+
(args.length === 0 ? ', and the handler-less form settles nothing this rendering could observe' : ''));
|
|
513
|
+
}
|
|
514
|
+
const published = result === null ? null : result.representation;
|
|
515
|
+
if (published !== null && published.kind !== 'promise') {
|
|
516
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.finally', `a "Promise.prototype.finally" result carries "${representationKey(published)}", not a promise; 27.2.5.3 returns one`);
|
|
517
|
+
}
|
|
518
|
+
if (receiverCarrier === undefined) {
|
|
519
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.finally', 'a "Promise.prototype.finally" reached with no receiver carrier recorded has no fulfilled arm to render');
|
|
520
|
+
}
|
|
521
|
+
const discarded = published === null;
|
|
522
|
+
const carrier = published ?? { kind: 'promise', value: { kind: 'void' } };
|
|
523
|
+
const abi = callableObjectAbi(onFinally.representation);
|
|
524
|
+
if (!abi || abi.receiver !== null || abi.restFrom !== null || abi.parameters.length !== 0) {
|
|
525
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.finally', `a "Promise.prototype.finally" handler carried as "${representationKey(onFinally.representation)}" is not a plain 0-parameter ` +
|
|
526
|
+
'callable; 27.2.5.3 calls it with no arguments at all -- no reason, no value, no receiver');
|
|
527
|
+
}
|
|
528
|
+
if (abi.result.kind === 'promise') {
|
|
529
|
+
throw createCppEmitBlockedError('host-invocation:Promise.prototype.finally', `a "Promise.prototype.finally" handler returns "${representationKey(abi.result)}"; 27.2.5.3 step 5 resolves that thenable and waits ` +
|
|
530
|
+
'for it before passing the settlement on, and running the continuation without that wait would be a different program');
|
|
531
|
+
}
|
|
532
|
+
const voidPayload = receiverCarrier.value.kind === 'void';
|
|
533
|
+
// The value travels through unchanged, exactly as it does across `catch`'s
|
|
534
|
+
// fulfilled arm -- unless nobody reads the result, in which case there is no
|
|
535
|
+
// carrier to travel into and the `Promise<void>` below settles by running.
|
|
536
|
+
const passThrough = (() => {
|
|
537
|
+
if (discarded || carrier.value.kind === 'void')
|
|
538
|
+
return '';
|
|
539
|
+
if (voidPayload)
|
|
540
|
+
return null;
|
|
541
|
+
return alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:finally', receiverCarrier.value, carrier.value, caughtValueName);
|
|
542
|
+
})();
|
|
543
|
+
if (passThrough === null) {
|
|
544
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(receiverCarrier.value)}->${representationKey(carrier.value)}`, `a "Promise.prototype.finally" over a "${representationKey(receiverCarrier)}" receiver cannot pass its fulfillment value through ` +
|
|
545
|
+
`into "${representationKey(carrier)}"; 27.2.5.3 changes the settlement in no way, so the value has to travel unchanged`);
|
|
546
|
+
}
|
|
547
|
+
const resultType = cppTypeOf(carrier);
|
|
548
|
+
const fulfilledParameter = voidPayload
|
|
549
|
+
? ''
|
|
550
|
+
: `const ${cppTypeOf(receiverCarrier.value)}&${passThrough === '' ? '' : ` ${caughtValueName}`}`;
|
|
551
|
+
return (`([&]() -> ${resultType} { const auto ${caughtSettledName} = ${receiverText}; ${resultType} ${catchResultName}; ` +
|
|
552
|
+
`const auto ${finallyHandlerName} = ${operandText(ctx, onFinally)}; ` +
|
|
553
|
+
`${caughtSettledName}.observe(` +
|
|
554
|
+
`[${catchResultName}, ${finallyHandlerName}](${fulfilledParameter}) mutable { ` +
|
|
555
|
+
`try { ${finallyHandlerName}.call(); ${catchResultName}.resolve(${passThrough}); } ` +
|
|
556
|
+
`catch (...) { ${catchResultName}.reject(std::current_exception()); } }, ` +
|
|
557
|
+
`[${catchResultName}, ${finallyHandlerName}](const std::exception_ptr& gea_finally_rejection) mutable { ` +
|
|
558
|
+
`try { ${finallyHandlerName}.call(); ${catchResultName}.reject(gea_finally_rejection); } ` +
|
|
559
|
+
`catch (...) { ${catchResultName}.reject(std::current_exception()); } }); return ${catchResultName}; }())`);
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* `p.toString()`.
|
|
563
|
+
*
|
|
564
|
+
* NOT a `Promise.prototype` member -- 27.2.5 defines no `toString` at all. It
|
|
565
|
+
* is `Object.prototype.toString`, which every object inherits, and 20.1.3.6
|
|
566
|
+
* step 15 reads the receiver's `@@toStringTag` for the answer: 27.2.5.5 makes
|
|
567
|
+
* that the literal "Promise". So the result is a class-independent constant
|
|
568
|
+
* with no call, exactly as it is for the same operation reached through
|
|
569
|
+
* `String(p)` and `` `${p}` `` (`emit-tostring.ts`'s own `promise` branch),
|
|
570
|
+
* which is why it renders the same string here.
|
|
571
|
+
*
|
|
572
|
+
* Refusing it read "toString is a Promise.prototype member this backend states
|
|
573
|
+
* no rendering for", which named the wrong prototype and sent the reader to
|
|
574
|
+
* implement a method that does not exist.
|
|
575
|
+
*/
|
|
576
|
+
const promiseToStringText = (_ctx, _receiverText, args) => {
|
|
577
|
+
if (args.length !== 0) {
|
|
578
|
+
throw createCppEmitBlockedError('host-invocation:Object.prototype.toString', `"Object.prototype.toString" takes no arguments (20.1.3.6); this call passes ${args.length}`);
|
|
579
|
+
}
|
|
580
|
+
return cppConstantLiteral('[object Promise]', 'string', { kind: 'string' });
|
|
581
|
+
};
|
|
582
|
+
const promiseMethods = new Map([
|
|
583
|
+
['then', promiseThenText],
|
|
584
|
+
['catch', promiseCatchText],
|
|
585
|
+
['finally', promiseFinallyText],
|
|
586
|
+
['toString', promiseToStringText]
|
|
587
|
+
]);
|
|
588
|
+
/** The keys `promiseMemberText` may defer -- one authority for "is this method implemented", as above. */
|
|
589
|
+
export const promisePrototypeMethods = new Set(promiseMethods.keys());
|
|
590
|
+
/**
|
|
591
|
+
* The keyed-collection prototype methods this backend renders, per family.
|
|
592
|
+
*
|
|
593
|
+
* Four sets rather than one, because the four interfaces genuinely differ:
|
|
594
|
+
* `Map.prototype` has `get`/`set` and no `add`, `Set.prototype` has `add` and
|
|
595
|
+
* neither, and ECMA-262 gives the two weak families no `clear` and no `size`
|
|
596
|
+
* at all (24.3/24.4) -- there is nothing to clear or count when entries may be
|
|
597
|
+
* collected. Merging them would let `weakSet.clear()` reach an emitter that
|
|
598
|
+
* has a spelling for it, which is exactly the over-claim that turns a preflight
|
|
599
|
+
* refusal into a clang error.
|
|
600
|
+
*
|
|
601
|
+
* Deliberately absent from every family, each still refused BY NAME at its
|
|
602
|
+
* access (`keyedCollectionMemberText`):
|
|
603
|
+
*
|
|
604
|
+
* - `forEach` -- a real ECMA-262 member (23.1.3.5 / 24.2.3.6). It takes a
|
|
605
|
+
* callback whose `this`-arg and three-parameter frame this backend has no
|
|
606
|
+
* convention for; `Array.prototype.map` is the one callback-taking method it
|
|
607
|
+
* does render, and its own renderer below is what that took.
|
|
608
|
+
* - `keys` / `values` -- each returns an iterator whose element carrier is not
|
|
609
|
+
* currently projected here. Map `entries` is implemented below because its
|
|
610
|
+
* result already carries the concrete pair type needed by `gea::Iterator`.
|
|
611
|
+
* - `getOrInsert` / `getOrInsertComputed` (ES2026), the ES2025
|
|
612
|
+
* `union`/`intersection`/`difference`/`isSubsetOf` family, and `Map.groupBy`
|
|
613
|
+
* / `Set.prototype.symmetricDifference` -- unbuilt, not refused on
|
|
614
|
+
* principle.
|
|
615
|
+
*/
|
|
616
|
+
const strongMapMethods = new Set(['get', 'set', 'has', 'delete', 'clear', 'entries', 'keys', 'values']);
|
|
617
|
+
const strongSetMethods = new Set(['add', 'has', 'delete', 'clear']);
|
|
618
|
+
const weakMapMethods = new Set(['get', 'set', 'has', 'delete']);
|
|
619
|
+
const weakSetMethods = new Set(['add', 'has', 'delete']);
|
|
620
|
+
export const keyedCollectionPrototypeMethods = (family) => family === 'map' ? strongMapMethods : family === 'set' ? strongSetMethods : family === 'weak-map' ? weakMapMethods : weakSetMethods;
|
|
621
|
+
/**
|
|
622
|
+
* The call text for one deferred keyed-collection method.
|
|
623
|
+
*
|
|
624
|
+
* The mutating pair (`set`/`add`) goes through a free function rather than a
|
|
625
|
+
* member call: ECMAScript returns the COLLECTION from both, so the call's
|
|
626
|
+
* result carrier is the collection's own, and a `void` member call would not
|
|
627
|
+
* typecheck against it (`gea::mapSet`/`gea::setAdd`, gea_runtime.h -- v1's
|
|
628
|
+
* `collection_internal::MapSet`/`SetAdd` split, spelled for this backend's
|
|
629
|
+
* `shared_ptr` carrier). Everything else is a plain member call, with `delete`
|
|
630
|
+
* renamed to `remove` in exactly this one place because `delete` is a C++
|
|
631
|
+
* keyword.
|
|
632
|
+
*
|
|
633
|
+
* The receiver's arrow-vs-dot is not decided here: `keyedCollectionMemberText`
|
|
634
|
+
* recorded the receiver text and this carrier is always `shared-refcount` by
|
|
635
|
+
* the time a method defers -- `emitKeyedCollectionConstruct` refuses any other
|
|
636
|
+
* ownership at construction, so a collection reaching a call site is a
|
|
637
|
+
* `shared_ptr`.
|
|
638
|
+
*/
|
|
639
|
+
const keyedCollectionCallText = (ctx, carrier, member, receiverText, args, result) => {
|
|
640
|
+
const family = carrier.family;
|
|
641
|
+
const expected = member === 'set' ? 2 : member === 'clear' || member === 'entries' || member === 'keys' || member === 'values' ? 0 : 1;
|
|
642
|
+
if (args.length !== expected) {
|
|
643
|
+
throw createCppEmitBlockedError(`host-invocation:${family}.prototype.${member}`, `"${family}.prototype.${member}" takes ${expected} argument(s); this call passes ${args.length}`);
|
|
644
|
+
}
|
|
645
|
+
// Every argument is converted into the SLOT it fills -- position 0 is a key
|
|
646
|
+
// and position 1 (`set` only) is the value -- rather than passed as the
|
|
647
|
+
// expression happened to carry it.
|
|
648
|
+
//
|
|
649
|
+
// Load-bearing for exactly one carrier, and it is the one the source itself
|
|
650
|
+
// declared dynamic: `Map<string, any>` is `gea::Map<std::string,
|
|
651
|
+
// gea::Value>`, so `bag.set('a', 1)` arrives with a `double` third argument
|
|
652
|
+
// against a `gea::Value` parameter and `gea::mapSet`'s own template
|
|
653
|
+
// deduction reports conflicting `V`. `convertedValueText` is the same
|
|
654
|
+
// authority every other store goes through, so the box it renders is the
|
|
655
|
+
// one `emit-narrowing.ts` would render anywhere else, not a second spelling
|
|
656
|
+
// of it. For a fully typed collection the source and target carriers are
|
|
657
|
+
// identical and it returns the text unchanged, so nothing native is
|
|
658
|
+
// disturbed.
|
|
659
|
+
const slotOf = (index) => (index === 1 && carrier.value ? carrier.value : carrier.key);
|
|
660
|
+
const argumentTexts = args.map((argument, index) => {
|
|
661
|
+
const slot = slotOf(index);
|
|
662
|
+
const text = operandText(ctx, argument);
|
|
663
|
+
if (index === 0 && (family === 'weak-map' || family === 'weak-set') && hasReferenceIdentity(argument.representation)) {
|
|
664
|
+
// A weak collection compares its key by object identity. Its generic K
|
|
665
|
+
// is only the checker's admissibility boundary; rebuilding a
|
|
666
|
+
// structurally compatible class instance as K would create a different
|
|
667
|
+
// object. Preserve the actual reference carrier and let WeakMap/WeakSet
|
|
668
|
+
// erase only its identity after the checker has admitted the call.
|
|
669
|
+
return text;
|
|
670
|
+
}
|
|
671
|
+
const converted = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:438', argument.representation, slot, text);
|
|
672
|
+
if (converted === null) {
|
|
673
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(argument.representation)}->${representationKey(slot)}`, `"${family}.prototype.${member}" argument ${index} carries "${representationKey(argument.representation)}", ` +
|
|
674
|
+
`and this backend states no conversion of it into the collection's own "${representationKey(slot)}"`);
|
|
675
|
+
}
|
|
676
|
+
return converted;
|
|
677
|
+
});
|
|
678
|
+
if (member === 'set') {
|
|
679
|
+
// `gea::mapSet` returns `Ref<Map<K, V>>`, which is the ordinary carrier
|
|
680
|
+
// but cannot be downcast to the identity-bearing recursive wrapper. The
|
|
681
|
+
// JavaScript result is the original receiver, so mutate that one wrapper
|
|
682
|
+
// and return the same `Ref<wrapper>` directly.
|
|
683
|
+
if (carrier.recursive) {
|
|
684
|
+
if (!result || representationKey(result.representation) !== representationKey(carrier)) {
|
|
685
|
+
throw createCppEmitBlockedError(`host-invocation:${family}.prototype.set`, `recursive ${family}.prototype.set publishes "${result ? representationKey(result.representation) : 'nothing'}", not its receiver carrier`);
|
|
686
|
+
}
|
|
687
|
+
return `([&]() -> ${cppTypeOf(result.representation)} { ${receiverText}->set(${argumentTexts.join(', ')}); return ${receiverText}; }())`;
|
|
688
|
+
}
|
|
689
|
+
const helper = family === 'weak-map' ? 'gea::weakMapSet' : 'gea::mapSet';
|
|
690
|
+
return `${helper}(${receiverText}, ${argumentTexts.join(', ')})`;
|
|
691
|
+
}
|
|
692
|
+
if (member === 'add') {
|
|
693
|
+
if (carrier.recursive) {
|
|
694
|
+
if (!result || representationKey(result.representation) !== representationKey(carrier)) {
|
|
695
|
+
throw createCppEmitBlockedError(`host-invocation:${family}.prototype.add`, `recursive ${family}.prototype.add publishes "${result ? representationKey(result.representation) : 'nothing'}", not its receiver carrier`);
|
|
696
|
+
}
|
|
697
|
+
return `([&]() -> ${cppTypeOf(result.representation)} { ${receiverText}->add(${argumentTexts[0]}); return ${receiverText}; }())`;
|
|
698
|
+
}
|
|
699
|
+
const helper = family === 'weak-set' ? 'gea::weakSetAdd' : 'gea::setAdd';
|
|
700
|
+
return `${helper}(${receiverText}, ${argumentTexts[0]})`;
|
|
701
|
+
}
|
|
702
|
+
if (member === 'entries') {
|
|
703
|
+
if (family !== 'map' || result?.representation.kind !== 'iterator') {
|
|
704
|
+
throw createCppEmitBlockedError(`host-invocation:${family}.prototype.entries`, `"${family}.prototype.entries" publishes "${result ? representationKey(result.representation) : 'nothing'}"; ` +
|
|
705
|
+
'Map entries require the iterator carrier that names their concrete pair element');
|
|
706
|
+
}
|
|
707
|
+
return `gea::Iterator<${cppTypeOf(result.representation.element)}>(${receiverText})`;
|
|
708
|
+
}
|
|
709
|
+
// `keys` and `values` -- ECMA-262 24.1.3.8 / 24.1.3.11 -- yield ONE HALF of
|
|
710
|
+
// each entry, so unlike `entries` there is no pair to mint: the element is
|
|
711
|
+
// the collection's own `K` or `V`, which the carrier already names. The
|
|
712
|
+
// runtime's generic cursor constructor takes the per-step read as a closure
|
|
713
|
+
// (the same one its Map-entry constructor is built on), so this re-reads the
|
|
714
|
+
// map's CURRENT entry list every step, exactly as `entries` does and as the
|
|
715
|
+
// specification requires -- a `delete` mid-iteration is observed live.
|
|
716
|
+
if (member === 'keys' || member === 'values') {
|
|
717
|
+
if (result?.representation.kind !== 'iterator') {
|
|
718
|
+
throw createCppEmitBlockedError(`host-invocation:${family}.prototype.${member}`, `"${family}.prototype.${member}" publishes "${result ? representationKey(result.representation) : 'nothing'}"; ` +
|
|
719
|
+
'a keyed collection cursor requires the iterator carrier that names its element');
|
|
720
|
+
}
|
|
721
|
+
const element = cppTypeOf(result.representation.element);
|
|
722
|
+
// A Set's `keys` IS its `values` (24.2.3.8): one storage, and the element
|
|
723
|
+
// is the collection's key either way.
|
|
724
|
+
if (family === 'set')
|
|
725
|
+
return `gea::Iterator<${element}>(${receiverText})`;
|
|
726
|
+
const half = member === 'keys' ? 'first' : 'second';
|
|
727
|
+
return (`gea::Iterator<${element}>([gea_collection = ${receiverText}](std::size_t gea_position, ${element}& gea_out) -> bool { ` +
|
|
728
|
+
`const auto& gea_entries = gea_collection->entries(); ` +
|
|
729
|
+
`if (gea_position >= gea_entries.size()) return false; ` +
|
|
730
|
+
`gea_out = gea_entries[gea_position].${half}; return true; })`);
|
|
731
|
+
}
|
|
732
|
+
// `delete` is a C++ keyword; `remove` is the member the runtime spells for
|
|
733
|
+
// ECMA-262's `delete`, and this is the single place the rename happens.
|
|
734
|
+
const spelling = member === 'delete' ? 'remove' : member;
|
|
735
|
+
const invocation = `${receiverText}->${spelling}(${argumentTexts.join(', ')})`;
|
|
736
|
+
if (member === 'get' && carrier.value && result && result.representation.kind !== 'void') {
|
|
737
|
+
// The runtime returns Optional<V> in the collection's storage order.
|
|
738
|
+
// The call site's union can have a different order or a narrowed payload.
|
|
739
|
+
const source = { kind: 'optional', payload: carrier.value, absence: 'undefined' };
|
|
740
|
+
const converted = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:collection-get', source, result.representation, invocation);
|
|
741
|
+
if (converted === null) {
|
|
742
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(source)}->${representationKey(result.representation)}`, `"${family}.prototype.get" has no conversion from its collection storage result to the published call result`);
|
|
743
|
+
}
|
|
744
|
+
return converted;
|
|
745
|
+
}
|
|
746
|
+
return invocation;
|
|
747
|
+
};
|
|
748
|
+
/** The keys `scalarMemberText` may defer off a number receiver -- one authority for "is this method implemented", as above. */
|
|
749
|
+
export const numberPrototypeMethods = new Set(numberMethods.keys());
|
|
750
|
+
/**
|
|
751
|
+
* `Object.prototype` methods reached through a `dictionary` receiver.
|
|
752
|
+
*
|
|
753
|
+
* A `{ [name: string]: V }` index signature covers every string key, so
|
|
754
|
+
* `headers.hasOwnProperty(k)` LOOKS like a table read of the key
|
|
755
|
+
* `"hasOwnProperty"`. It is not: the checker resolves that name against
|
|
756
|
+
* `Object.prototype` and publishes the method's own signature -- a
|
|
757
|
+
* `CallableObject<bool(PropertyKey)>` -- while the table would hand back a
|
|
758
|
+
* `V`. Emitting the read is how a certified program produced
|
|
759
|
+
* `CallableObject<...> = std::string`, so the access defers here instead and
|
|
760
|
+
* the whole thing renders at the call, the same shape every other prototype
|
|
761
|
+
* family uses.
|
|
762
|
+
*
|
|
763
|
+
* Only the members whose meaning survives the carrier are listed.
|
|
764
|
+
* `hasOwnProperty` is exactly `has` on the table -- the own half, no prototype
|
|
765
|
+
* chain, which is all a `std::map` has. `toString`/`valueOf`/`isPrototypeOf`
|
|
766
|
+
* ask about an object identity a `dictionary` does not carry, so they stay
|
|
767
|
+
* unclaimed and refuse at the read rather than compiling to something else.
|
|
768
|
+
*/
|
|
769
|
+
export const dictionaryPrototypeMethods = new Set(['hasOwnProperty']);
|
|
770
|
+
/**
|
|
771
|
+
* The call text for a deferred `Object.prototype` read off a dictionary.
|
|
772
|
+
*
|
|
773
|
+
* The argument is a `PropertyKey` in the ambient declaration and the table is
|
|
774
|
+
* keyed by one domain of it; `keyedTableKeyText` is the same reconciliation
|
|
775
|
+
* every other use of the table goes through, so a number-keyed table asks the
|
|
776
|
+
* key the identical question here that a subscript would.
|
|
777
|
+
*/
|
|
778
|
+
const dictionaryCallText = (ctx, member, receiverText, table, args) => {
|
|
779
|
+
if (member !== 'hasOwnProperty') {
|
|
780
|
+
throw createCppEmitBlockedError(`host-invocation:Object.prototype.${member}`, `"${member}" was recorded as a deferred Object.prototype read off a dictionary but this file renders no call for it`);
|
|
781
|
+
}
|
|
782
|
+
const key = args[0];
|
|
783
|
+
if (key === undefined) {
|
|
784
|
+
throw createCppEmitBlockedError('call-abi:hasOwnProperty', '"Object.prototype.hasOwnProperty" was called with no key');
|
|
785
|
+
}
|
|
786
|
+
return `${receiverText}${table.accessor}has(${keyedTableKeyText(ctx, key, dictionaryKeyDomainOf(table.key, key.representation))})`;
|
|
787
|
+
};
|
|
788
|
+
/**
|
|
789
|
+
* The call text for a deferred String/Array prototype-method read, or `null`
|
|
790
|
+
* when the callee is not one -- the ordinary invoke paths run unchanged.
|
|
791
|
+
*/
|
|
792
|
+
export const prototypeMethodCallText = (ctx, operation) => {
|
|
793
|
+
const read = ctx.prototypeMethodReads.get(operation.callee.value);
|
|
794
|
+
if (!read)
|
|
795
|
+
return null;
|
|
796
|
+
// Spelled here, not at the access that recorded the read: the record names
|
|
797
|
+
// the receiver's operand (`PrototypeMethodReceiver`) and this is the call
|
|
798
|
+
// that fuses with it.
|
|
799
|
+
return renderPrototypeMethodCall(ctx, read, prototypeMethodReceiverText(ctx, read.receiver), operation);
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
* One deferred read, spelled against one receiver TEXT.
|
|
803
|
+
*
|
|
804
|
+
* Split from the entry point above so a union arm can be rendered as itself:
|
|
805
|
+
* `mixed-union` below hands each arm its own recorded read and its own
|
|
806
|
+
* `get<N>()` spelling, and the arm then renders through exactly the same
|
|
807
|
+
* ladder a lone receiver of that carrier would -- rather than through a second
|
|
808
|
+
* copy of it, which is the shape this file exists to avoid.
|
|
809
|
+
*/
|
|
810
|
+
const renderPrototypeMethodCall = (ctx, read, receiverText, operation) => {
|
|
811
|
+
if (read.receiverKind === 'bigint') {
|
|
812
|
+
if (read.member === 'valueOf')
|
|
813
|
+
return receiverText;
|
|
814
|
+
const radix = operation.arguments[0];
|
|
815
|
+
return radix === undefined || radix.representation.kind === 'undefined'
|
|
816
|
+
? `(${receiverText}).toString()`
|
|
817
|
+
: `gea::host::BigIntConstructor::toStringRadix(${receiverText}, ${operandText(ctx, radix)})`;
|
|
818
|
+
}
|
|
819
|
+
if (read.receiverKind === 'string') {
|
|
820
|
+
const render = stringMethods.get(read.member);
|
|
821
|
+
if (!render) {
|
|
822
|
+
throw createCppEmitBlockedError(`host-invocation:String.prototype.${read.member}`, `"${read.member}" was recorded as a deferred String.prototype read but this file renders no call for it`);
|
|
823
|
+
}
|
|
824
|
+
return render(ctx, receiverText, operation.arguments, operation.result, ctx.stringMetadataNames.get(operation.callee.value));
|
|
825
|
+
}
|
|
826
|
+
if (read.receiverKind === 'number') {
|
|
827
|
+
const render = numberMethods.get(read.member);
|
|
828
|
+
if (!render) {
|
|
829
|
+
throw createCppEmitBlockedError(`host-invocation:Number.prototype.${read.member}`, `"${read.member}" was recorded as a deferred Number.prototype read but this file renders no call for it`);
|
|
830
|
+
}
|
|
831
|
+
return render(ctx, receiverText, operation.arguments);
|
|
832
|
+
}
|
|
833
|
+
if (read.receiverKind === 'promise') {
|
|
834
|
+
const render = promiseMethods.get(read.member);
|
|
835
|
+
if (!render) {
|
|
836
|
+
throw createCppEmitBlockedError(`host-invocation:Promise.prototype.${read.member}`, `"${read.member}" was recorded as a deferred Promise.prototype read but this file renders no call for it`);
|
|
837
|
+
}
|
|
838
|
+
return render(ctx, receiverText, operation.arguments, operation.result, read.promiseCarrier);
|
|
839
|
+
}
|
|
840
|
+
if (read.receiverKind === 'iterator') {
|
|
841
|
+
return iteratorCallText(ctx, read.member, receiverText, read.iteratorCarrier, operation);
|
|
842
|
+
}
|
|
843
|
+
if (read.receiverKind === 'date') {
|
|
844
|
+
// The whole table is `emit-prototype-date.ts`'s, the same way the String
|
|
845
|
+
// and Array families own theirs; this file only routes.
|
|
846
|
+
return dateCallText(ctx, read.member, receiverText, operation);
|
|
847
|
+
}
|
|
848
|
+
if (read.receiverKind === 'regexp') {
|
|
849
|
+
return regexpMethodCallText(ctx, read.member, receiverText, operation.arguments, operation.result);
|
|
850
|
+
}
|
|
851
|
+
if (read.receiverKind === 'dictionary') {
|
|
852
|
+
if (read.dictionaryTable === undefined) {
|
|
853
|
+
throw createCppEmitBlockedError(`host-invocation:Object.prototype.${read.member}`, `"${read.member}" was recorded as a deferred dictionary read with no table spelling`);
|
|
854
|
+
}
|
|
855
|
+
return dictionaryCallText(ctx, read.member, receiverText, read.dictionaryTable, operation.arguments);
|
|
856
|
+
}
|
|
857
|
+
if (read.receiverKind === 'object-shape') {
|
|
858
|
+
if (read.objectShapeFields === undefined || read.objectShapeAccessor === undefined) {
|
|
859
|
+
throw createCppEmitBlockedError(`host-invocation:object-shape.${read.member}`, `"${read.member}" was recorded as a deferred object-shape read with no field list`);
|
|
860
|
+
}
|
|
861
|
+
return objectShapeCallText(ctx, read.member, receiverText, read.objectShapeAccessor, read.objectShapeFields, operation.arguments);
|
|
862
|
+
}
|
|
863
|
+
if (read.receiverKind === 'native-handle-shape') {
|
|
864
|
+
if (read.intrinsicProtocol === undefined) {
|
|
865
|
+
throw createCppEmitBlockedError(`host-invocation:native-handle-shape.${read.member}`, `"${read.member}" was recorded as a deferred native-handle read with no protocol name`);
|
|
866
|
+
}
|
|
867
|
+
return nativeHandleShapeCallText(ctx, read.member, read.intrinsicProtocol, operation.arguments);
|
|
868
|
+
}
|
|
869
|
+
if (read.receiverKind === 'callable-shape') {
|
|
870
|
+
return callableShapeCallText(ctx, read.member, receiverText, operation.arguments);
|
|
871
|
+
}
|
|
872
|
+
if (read.receiverKind === 'dynamic-object') {
|
|
873
|
+
return dynamicObjectCallText(ctx, read.member, receiverText, operation.arguments);
|
|
874
|
+
}
|
|
875
|
+
// The ECMA-262 binary family, rendered in `emit-buffers.ts` -- see that
|
|
876
|
+
// file's header for why its members live together rather than with the
|
|
877
|
+
// indexed access each carrier also has.
|
|
878
|
+
if (read.receiverKind === 'data-view') {
|
|
879
|
+
return dataViewCallText(ctx, read.member, receiverText, operation.arguments);
|
|
880
|
+
}
|
|
881
|
+
if (read.receiverKind === 'union-to-string') {
|
|
882
|
+
if (read.receiver.kind !== 'operand') {
|
|
883
|
+
throw createCppEmitBlockedError('property-access:tagged-union:get:false', 'a union "toString" read was recorded without the union operand its dispatch is built from');
|
|
884
|
+
}
|
|
885
|
+
return unionToStringCallText(ctx, read.receiver.operand.representation, receiverText);
|
|
886
|
+
}
|
|
887
|
+
if (read.receiverKind === 'native-error') {
|
|
888
|
+
return nativeErrorCallText(read.member, receiverText);
|
|
889
|
+
}
|
|
890
|
+
if (read.receiverKind === 'typed-array') {
|
|
891
|
+
if (read.receiverElement === null) {
|
|
892
|
+
throw createCppEmitBlockedError(`host-invocation:TypedArray.prototype.${read.member}`, `"${read.member}" was recorded as a deferred %TypedArray%.prototype read with no element spelling`);
|
|
893
|
+
}
|
|
894
|
+
return typedArrayCallText(ctx, read.member, receiverText, read.receiverElement, operation.arguments);
|
|
895
|
+
}
|
|
896
|
+
if (read.receiverKind === 'typed-array-union') {
|
|
897
|
+
const carrier = read.typedArrayUnionCarrier;
|
|
898
|
+
if (!carrier || !carrier.arms.every((arm) => arm.value.kind === 'typed-array')) {
|
|
899
|
+
throw createCppEmitBlockedError(`host-invocation:TypedArray.prototype.${read.member}`, `"${read.member}" was recorded as a typed-array union read without a typed-array-only carrier`);
|
|
900
|
+
}
|
|
901
|
+
const branches = carrier.arms.map((arm, index) => {
|
|
902
|
+
if (arm.value.kind !== 'typed-array') {
|
|
903
|
+
throw createCppEmitBlockedError(`host-invocation:TypedArray.prototype.${read.member}`, `"${read.member}" reached a non-typed-array arm after typed-array-union admission`);
|
|
904
|
+
}
|
|
905
|
+
const receiver = `${receiverText}.get<${index}>()`;
|
|
906
|
+
const invocation = typedArrayCallText(ctx, read.member, receiver, typedArrayElementSpelling(arm.value), operation.arguments);
|
|
907
|
+
if (operation.result === null || operation.result.representation.kind === 'void')
|
|
908
|
+
return invocation;
|
|
909
|
+
const source = read.member === 'set' ? { kind: 'undefined' } : arm.value;
|
|
910
|
+
const converted = alignedValueText(ctx, 'prototype/emit-prototype-invoke.ts:682', source, operation.result.representation, invocation);
|
|
911
|
+
if (converted === null) {
|
|
912
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(source)}->${representationKey(operation.result.representation)}`, `a typed-array union arm's "${read.member}" result carries "${representationKey(source)}" while the call publishes ` +
|
|
913
|
+
`"${representationKey(operation.result.representation)}", and no installed conversion reconciles them`);
|
|
914
|
+
}
|
|
915
|
+
return converted;
|
|
916
|
+
});
|
|
917
|
+
return branches.reduceRight((rest, branch, index) => (index === branches.length - 1 ? branch : `${receiverText}.is<${index}>() ? ${branch} : (${rest})`), '');
|
|
918
|
+
}
|
|
919
|
+
if (read.receiverKind === 'mixed-union') {
|
|
920
|
+
const carrier = read.mixedUnionCarrier;
|
|
921
|
+
const arms = read.mixedUnionArms;
|
|
922
|
+
if (!carrier || !arms || arms.length !== carrier.arms.length) {
|
|
923
|
+
throw createCppEmitBlockedError(`host-invocation:union.${read.member}`, `"${read.member}" was recorded as a mixed-union call without a per-arm answer for every arm`);
|
|
924
|
+
}
|
|
925
|
+
const resultType = operation.result === null ? 'void' : cppTypeOf(operation.result.representation);
|
|
926
|
+
// A DISCARDED result and an absent arm together are the one combination
|
|
927
|
+
// whose branches cannot agree on a type by themselves. The absent arm's
|
|
928
|
+
// `throwAbsentUnionMember<void>` is `void` -- there is no result cell for
|
|
929
|
+
// it to be instantiated at -- while a live arm still evaluates to whatever
|
|
930
|
+
// its own method returns, and `Array.prototype.push` returns a number even
|
|
931
|
+
// when nobody reads it. C++'s conditional operator has no common type for
|
|
932
|
+
// `void` and `double`, so the whole statement was refused for a program
|
|
933
|
+
// that is perfectly well formed: hono's `_getQueryParam` writes
|
|
934
|
+
// `;(results[name] as string[]).push(value)` over a `string | string[]`,
|
|
935
|
+
// where the `as` names the arm the author means and the string arm is
|
|
936
|
+
// proved to have no `push`.
|
|
937
|
+
//
|
|
938
|
+
// Discarding both sides explicitly is what the statement already means --
|
|
939
|
+
// 13.3.6.1 throws on the absent arm and 23.1.3.20 returns a length nobody
|
|
940
|
+
// reads on the live one -- and it is applied only when an arm really is
|
|
941
|
+
// absent, so a union whose arms all answer keeps the text it had.
|
|
942
|
+
const discardedWithAbsentArm = operation.result === null && arms.some((armRead) => armRead === null);
|
|
943
|
+
const branches = arms.map((armRead, index) => {
|
|
944
|
+
const armCarrier = carrier.arms[index]?.value;
|
|
945
|
+
if (armRead === null) {
|
|
946
|
+
// The arm the claim proved holds no callable of this name. 6.2.5.5
|
|
947
|
+
// answers `undefined` for the read and 13.3.6.1 throws on the call --
|
|
948
|
+
// one step later, and only if this arm is the live one.
|
|
949
|
+
return (`gea::host::throwAbsentUnionMember<${resultType}>(${cppStringLiteral(read.member)}, ` +
|
|
950
|
+
`${cppStringLiteral(armCarrier ? representationKey(armCarrier) : 'arm')})`);
|
|
951
|
+
}
|
|
952
|
+
const text = renderPrototypeMethodCall(ctx, armRead, `${receiverText}.get<${index}>()`, operation);
|
|
953
|
+
if (typeof text !== 'string') {
|
|
954
|
+
throw createCppEmitBlockedError(`host-invocation:union.${read.member}`, `a mixed-union arm's "${read.member}" renders as a native scalar call, which has no per-arm spelling here`);
|
|
955
|
+
}
|
|
956
|
+
return discardedWithAbsentArm ? `(void)(${text})` : text;
|
|
957
|
+
});
|
|
958
|
+
return branches.reduceRight((rest, branch, index) => (index === branches.length - 1 ? branch : `${receiverText}.is<${index}>() ? ${branch} : (${rest})`), '');
|
|
959
|
+
}
|
|
960
|
+
if (read.receiverKind === 'array-buffer') {
|
|
961
|
+
// ECMA-262 25.1.5.3 `ArrayBuffer.prototype.slice`: a fresh block holding a
|
|
962
|
+
// COPY of the selected bytes, sharing nothing with the source. The
|
|
963
|
+
// relative-index fold is the runtime's own -- the same one every ranged
|
|
964
|
+
// method here uses -- and an omitted `end` is the buffer's own size, which
|
|
965
|
+
// only this call site can supply.
|
|
966
|
+
if (read.member !== 'slice') {
|
|
967
|
+
throw createCppEmitBlockedError(`host-invocation:ArrayBuffer.prototype.${read.member}`, `"${read.member}" was recorded as a deferred ArrayBuffer.prototype read but this file renders no call for it`);
|
|
968
|
+
}
|
|
969
|
+
const start = operation.arguments[0] === undefined ? '0.0' : operandText(ctx, operation.arguments[0]);
|
|
970
|
+
const end = operation.arguments[1] === undefined
|
|
971
|
+
? `static_cast<double>(${receiverText}->size())`
|
|
972
|
+
: operandText(ctx, operation.arguments[1]);
|
|
973
|
+
return `gea::detail::arrayBufferSlice(${receiverText}, ${start}, ${end})`;
|
|
974
|
+
}
|
|
975
|
+
if (read.receiverKind === 'keyed-collection') {
|
|
976
|
+
if (!read.collectionFamily) {
|
|
977
|
+
throw createCppEmitBlockedError(`host-invocation:KeyedCollection.prototype.${read.member}`, `"${read.member}" was recorded as a deferred keyed-collection read with no family, and the four families' spellings differ`);
|
|
978
|
+
}
|
|
979
|
+
if (!keyedCollectionPrototypeMethods(read.collectionFamily).has(read.member)) {
|
|
980
|
+
throw createCppEmitBlockedError(`host-invocation:${read.collectionFamily}.prototype.${read.member}`, `"${read.member}" was recorded as a deferred ${read.collectionFamily} read but this file renders no call for it`);
|
|
981
|
+
}
|
|
982
|
+
if (!read.collectionCarrier) {
|
|
983
|
+
throw createCppEmitBlockedError(`host-invocation:${read.collectionFamily}.prototype.${read.member}`, `"${read.member}" was recorded as a deferred keyed-collection read with no carrier, and its arguments cannot be converted into slots this call cannot see`);
|
|
984
|
+
}
|
|
985
|
+
return keyedCollectionCallText(ctx, read.collectionCarrier, read.member, receiverText, operation.arguments, operation.result);
|
|
986
|
+
}
|
|
987
|
+
const render = arrayMethods.get(read.member);
|
|
988
|
+
if (!render) {
|
|
989
|
+
throw createCppEmitBlockedError(`host-invocation:Array.prototype.${read.member}`, `"${read.member}" was recorded as a deferred Array.prototype read but this backend renders no call for it`);
|
|
990
|
+
}
|
|
991
|
+
// Every Array renderer needs the receiver's own ELEMENT carrier, not just
|
|
992
|
+
// its `representationKey`: `join` and the comparator-less `sort` ask whether
|
|
993
|
+
// the runtime can ToString it, `concat` asks whether the packed rest spreads
|
|
994
|
+
// or appends, and `find`/`at`/`pop`/`shift` compare it against the call's own
|
|
995
|
+
// optional result. `receiverElement` (a key string) answers only the last
|
|
996
|
+
// kind of question, so the carrier travels with the read -- the identical
|
|
997
|
+
// reason `collectionCarrier` does, stated at its own field.
|
|
998
|
+
if (!read.arrayCarrier) {
|
|
999
|
+
throw createCppEmitBlockedError(`host-invocation:Array.prototype.${read.member}`, `"${read.member}" was recorded as a deferred Array.prototype read with no receiver carrier, and its element carrier cannot be recovered at a call ` +
|
|
1000
|
+
'that no longer has the receiver');
|
|
1001
|
+
}
|
|
1002
|
+
return render(ctx, receiverText, read.arrayCarrier.element, operation.arguments, operation.result);
|
|
1003
|
+
};
|