@geastack/compiler 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-emit.js +11 -1
- package/dist/cli-package-source.d.ts +0 -4
- package/dist/cli-package-source.js +8 -112
- package/dist/cli-refusal-location.d.ts +6 -0
- package/dist/cli-refusal-location.js +5 -0
- package/dist/cli.js +2 -1
- package/dist/compiler.d.ts +4 -0
- package/dist/compiler.js +118 -28
- package/dist/conversion/algebra.d.ts +16 -1
- package/dist/conversion/algebra.js +2 -0
- package/dist/conversion/build.js +16 -6
- package/dist/conversion/constructor-identity-family.d.ts +49 -0
- package/dist/conversion/constructor-identity-family.js +67 -0
- package/dist/conversion/derive.js +39 -6
- package/dist/conversion/iterable-object-view.d.ts +44 -0
- package/dist/conversion/iterable-object-view.js +55 -0
- package/dist/conversion/iterator-object-view.d.ts +77 -0
- package/dist/conversion/iterator-object-view.js +112 -0
- package/dist/conversion/nodes.d.ts +93 -0
- package/dist/conversion/nodes.js +262 -5
- package/dist/conversion/operand-view.js +41 -0
- package/dist/conversion/protocol-iterator.d.ts +84 -0
- package/dist/conversion/protocol-iterator.js +88 -0
- package/dist/conversion/record-view.d.ts +152 -8
- package/dist/conversion/record-view.js +518 -37
- package/dist/conversion/registry.d.ts +32 -0
- package/dist/ir/borrowed-call-arguments.d.ts +22 -1
- package/dist/ir/borrowed-call-arguments.js +102 -1
- package/dist/ir/borrowed-callable-uses.d.ts +62 -0
- package/dist/ir/borrowed-callable-uses.js +135 -0
- package/dist/ir/boxed-bind-assumptions.d.ts +24 -0
- package/dist/ir/boxed-bind-assumptions.js +93 -0
- package/dist/ir/build.d.ts +18 -7
- package/dist/ir/build.js +71 -13
- package/dist/ir/call-dispatch.js +474 -10
- package/dist/ir/call-entry.d.ts +24 -1
- package/dist/ir/call-entry.js +106 -1
- package/dist/ir/callable-class-flow.js +15 -5
- package/dist/ir/callable-identity-demand.d.ts +20 -1
- package/dist/ir/callable-identity-demand.js +157 -18
- package/dist/ir/callable-member-candidates.d.ts +11 -1
- package/dist/ir/callable-member-candidates.js +82 -3
- package/dist/ir/callable-records.js +2 -2
- package/dist/ir/callable-site-escape.d.ts +4 -0
- package/dist/ir/callable-site-escape.js +228 -0
- package/dist/ir/captures.d.ts +10 -1
- package/dist/ir/captures.js +219 -4
- package/dist/ir/certify/carrier-keys.d.ts +58 -1
- package/dist/ir/certify/carrier-keys.js +158 -6
- package/dist/ir/certify/property-access-keys.d.ts +17 -0
- package/dist/ir/certify/property-access-keys.js +36 -0
- package/dist/ir/certify/property-access.js +49 -4
- package/dist/ir/certify/runtime-helper.d.ts +4 -0
- package/dist/ir/certify/runtime-helper.js +17 -5
- package/dist/ir/certify.js +132 -79
- package/dist/ir/class-static-fields.d.ts +11 -0
- package/dist/ir/class-static-fields.js +28 -0
- package/dist/ir/construct-entry.d.ts +2 -1
- package/dist/ir/construct-entry.js +3 -2
- package/dist/ir/construction-only-fields.d.ts +73 -0
- package/dist/ir/construction-only-fields.js +211 -0
- package/dist/ir/dominance.d.ts +14 -0
- package/dist/ir/dominance.js +18 -4
- package/dist/ir/emission-representations.js +4 -1
- package/dist/ir/exception-edges.d.ts +17 -0
- package/dist/ir/exception-edges.js +75 -0
- package/dist/ir/facts.d.ts +54 -3
- package/dist/ir/facts.js +182 -5
- package/dist/ir/generator-split.js +2 -2
- package/dist/ir/instance-reparenting.d.ts +83 -0
- package/dist/ir/instance-reparenting.js +167 -0
- package/dist/ir/integer-storage.d.ts +29 -0
- package/dist/ir/integer-storage.js +188 -79
- package/dist/ir/integers.d.ts +16 -0
- package/dist/ir/integers.js +327 -8
- package/dist/ir/integrity-restrictions.d.ts +42 -9
- package/dist/ir/integrity-restrictions.js +335 -42
- package/dist/ir/key-order-observation.d.ts +38 -0
- package/dist/ir/key-order-observation.js +173 -0
- package/dist/ir/literal-set-membership.d.ts +30 -0
- package/dist/ir/literal-set-membership.js +277 -0
- package/dist/ir/lower-allocation.js +68 -8
- package/dist/ir/lower-completion.d.ts +0 -9
- package/dist/ir/lower-completion.js +14 -5
- package/dist/ir/lower-destructuring.js +24 -2
- package/dist/ir/lower-exceptions.js +4 -4
- package/dist/ir/lower-flow.d.ts +21 -0
- package/dist/ir/lower-flow.js +37 -3
- package/dist/ir/lower-graph.d.ts +19 -1
- package/dist/ir/lower-graph.js +91 -67
- package/dist/ir/lower-invocation.d.ts +16 -0
- package/dist/ir/lower-invocation.js +182 -28
- package/dist/ir/lower-narrow.d.ts +0 -46
- package/dist/ir/lower-narrow.js +63 -1
- package/dist/ir/lower-operands.d.ts +52 -2
- package/dist/ir/lower-operands.js +491 -8
- package/dist/ir/lower-property.d.ts +2 -1
- package/dist/ir/lower-property.js +140 -31
- package/dist/ir/lower-protocol.js +16 -4
- package/dist/ir/lower-proxy.d.ts +65 -0
- package/dist/ir/lower-proxy.js +181 -0
- package/dist/ir/lower.js +112 -17
- package/dist/ir/model.d.ts +228 -18
- package/dist/ir/native-class-accessor.d.ts +9 -2
- package/dist/ir/native-class-accessor.js +12 -3
- package/dist/ir/native-class-construction.d.ts +1 -1
- package/dist/ir/native-class-construction.js +2 -1
- package/dist/ir/native-class-initialization.js +2 -2
- package/dist/ir/object-value-conversions.js +20 -5
- package/dist/ir/operation-index.d.ts +16 -0
- package/dist/ir/operation-index.js +17 -0
- package/dist/ir/pcm-loops.d.ts +11 -0
- package/dist/ir/pcm-loops.js +284 -0
- package/dist/ir/presence-proof.js +5 -0
- package/dist/ir/program-facts.d.ts +10 -20
- package/dist/ir/program-facts.js +80 -6
- package/dist/ir/proven-branches.d.ts +2 -2
- package/dist/ir/proven-branches.js +196 -3
- package/dist/ir/queries.js +35 -1
- package/dist/ir/reflection-demand.d.ts +9 -4
- package/dist/ir/reflection-demand.js +400 -28
- package/dist/ir/refusal.d.ts +1 -0
- package/dist/ir/refusal.js +2 -1
- package/dist/ir/shake.d.ts +94 -1
- package/dist/ir/shake.js +209 -12
- package/dist/ir/shared-empty-records.d.ts +12 -0
- package/dist/ir/shared-empty-records.js +301 -0
- package/dist/ir/spread-copy-elision.d.ts +59 -0
- package/dist/ir/spread-copy-elision.js +431 -0
- package/dist/ir/stable-cell-reads.d.ts +40 -0
- package/dist/ir/stable-cell-reads.js +123 -0
- package/dist/ir/static-callables.js +50 -0
- package/dist/ir/string-layout-reuse.d.ts +16 -1
- package/dist/ir/string-layout-reuse.js +66 -0
- package/dist/ir/transfer.d.ts +72 -3
- package/dist/ir/transfer.js +511 -19
- package/dist/ir/typed-property-access.d.ts +18 -2
- package/dist/ir/typed-property-access.js +109 -12
- package/dist/ir/verify.js +2 -1
- package/dist/plugins/apple/plugin.js +3 -2
- package/dist/plugins/gea/host.d.ts +7 -0
- package/dist/plugins/gea/host.js +30 -1
- package/dist/plugins/gea/lower.js +6 -1
- package/dist/plugins/gea/plugin.js +7 -4
- package/dist/plugins/gea/prelude.js +5 -1
- package/dist/plugins/gea/render-bridge.d.ts +4 -2
- package/dist/plugins/gea/render-bridge.js +23 -7
- package/dist/plugins/model.d.ts +2 -0
- package/dist/project-preparation.d.ts +5 -1
- package/dist/project-preparation.js +164 -7
- package/dist/projection/bindings.d.ts +5 -2
- package/dist/projection/bindings.js +40 -1
- package/dist/projection/callee.d.ts +16 -0
- package/dist/projection/callee.js +35 -6
- package/dist/projection/class-prototype.js +5 -1
- package/dist/projection/classes.d.ts +65 -2
- package/dist/projection/classes.js +159 -2
- package/dist/projection/dispatch.d.ts +69 -18
- package/dist/projection/dispatch.js +391 -19
- package/dist/projection/fields.d.ts +4 -3
- package/dist/projection/fields.js +89 -21
- package/dist/projection/instance-test.d.ts +12 -0
- package/dist/projection/instance-test.js +40 -10
- package/dist/projection/method-value-escapes.d.ts +43 -0
- package/dist/projection/method-value-escapes.js +113 -0
- package/dist/projection/slots.d.ts +34 -1
- package/dist/projection/slots.js +82 -5
- package/dist/representation/any-null-record-members.d.ts +41 -0
- package/dist/representation/any-null-record-members.js +115 -0
- package/dist/representation/collections.d.ts +3 -1
- package/dist/representation/collections.js +5 -2
- package/dist/representation/derive.d.ts +9 -1
- package/dist/representation/derive.js +366 -25
- package/dist/representation/difference.js +14 -0
- package/dist/representation/embedded-carriers.js +1 -0
- package/dist/representation/host-abi.d.ts +15 -0
- package/dist/representation/host-abi.js +28 -0
- package/dist/representation/host-templates.d.ts +1 -1
- package/dist/representation/host-templates.js +7 -3
- package/dist/representation/intersection.js +22 -0
- package/dist/representation/json-nullable.d.ts +18 -0
- package/dist/representation/json-nullable.js +22 -0
- package/dist/representation/model.d.ts +141 -0
- package/dist/representation/model.js +47 -3
- package/dist/representation/object-shape.d.ts +5 -1
- package/dist/representation/object-shape.js +5 -2
- package/dist/representation/policies.d.ts +66 -1
- package/dist/representation/proxy-carriers.d.ts +71 -0
- package/dist/representation/proxy-carriers.js +330 -0
- package/dist/representation/publish.d.ts +9 -1
- package/dist/representation/publish.js +186 -18
- package/dist/representation/record-fields.d.ts +5 -0
- package/dist/representation/record-fields.js +7 -1
- package/dist/representation/static-field-cells.d.ts +61 -0
- package/dist/representation/static-field-cells.js +80 -0
- package/dist/representation/unassigned-binding-cells.d.ts +32 -0
- package/dist/representation/unassigned-binding-cells.js +44 -0
- package/dist/representation/union.js +17 -1
- package/dist/representation/unwritten-record-members.d.ts +54 -0
- package/dist/representation/unwritten-record-members.js +167 -0
- package/dist/representation/value-records.js +153 -11
- package/dist/semantics/ambient.d.ts +102 -0
- package/dist/semantics/ambient.js +183 -0
- package/dist/semantics/any-null-member-declarations.d.ts +32 -0
- package/dist/semantics/any-null-member-declarations.js +90 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +14 -0
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.d.ts +51 -0
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +367 -0
- package/dist/semantics/call-invalidated-narrowing.d.ts +3 -0
- package/dist/semantics/call-invalidated-narrowing.js +715 -0
- package/dist/semantics/callable-origins.d.ts +39 -0
- package/dist/semantics/callable-origins.js +73 -2
- package/dist/semantics/class-alias.d.ts +21 -0
- package/dist/semantics/class-alias.js +45 -14
- package/dist/semantics/class-heritage.d.ts +64 -0
- package/dist/semantics/class-heritage.js +278 -2
- package/dist/semantics/commonjs-wrapper.d.ts +1 -1
- package/dist/semantics/commonjs-wrapper.js +24 -7
- package/dist/semantics/constructor-function-class-source-transform.d.ts +4 -0
- package/dist/semantics/constructor-function-class-source-transform.js +327 -0
- package/dist/semantics/constructor-slot-subclasses.js +163 -4
- package/dist/semantics/declaration-overlay-transform.js +197 -3
- package/dist/semantics/frontend.d.ts +31 -0
- package/dist/semantics/frontend.js +177 -19
- package/dist/semantics/host-methods.d.ts +27 -2
- package/dist/semantics/host-methods.js +57 -4
- package/dist/semantics/host-protocols.d.ts +19 -8
- package/dist/semantics/host-protocols.js +145 -31
- package/dist/semantics/interface-families.d.ts +51 -2
- package/dist/semantics/interface-families.js +609 -23
- package/dist/semantics/interface-implementors.d.ts +20 -0
- package/dist/semantics/interface-implementors.js +130 -6
- package/dist/semantics/known-caller-predicate-parameters.d.ts +2 -0
- package/dist/semantics/known-caller-predicate-parameters.js +161 -0
- package/dist/semantics/model/intrinsic-accessor-getters.d.ts +10 -0
- package/dist/semantics/model/intrinsic-accessor-getters.js +4 -0
- package/dist/semantics/model/operands.d.ts +10 -0
- package/dist/semantics/model/operations.d.ts +107 -0
- package/dist/semantics/model/selected-signature.d.ts +33 -0
- package/dist/semantics/model/structural-type-table.d.ts +15 -0
- package/dist/semantics/model/structural-type-table.js +19 -1
- package/dist/semantics/model/structural-types.d.ts +99 -0
- package/dist/semantics/model/structural-types.js +31 -2
- package/dist/semantics/normalize/absent-globals.d.ts +1 -1
- package/dist/semantics/normalize/absent-globals.js +3 -3
- package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +46 -0
- package/dist/semantics/normalize/bivariant-slot-parameter.js +357 -0
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +2 -0
- package/dist/semantics/normalize/callback-parameter-contracts.js +21 -0
- package/dist/semantics/normalize/census.d.ts +2 -1
- package/dist/semantics/normalize/census.js +25 -2
- package/dist/semantics/normalize/class-instance-record-statement.d.ts +37 -0
- package/dist/semantics/normalize/class-instance-record-statement.js +74 -0
- package/dist/semantics/normalize/collection-bindings.js +242 -5
- package/dist/semantics/normalize/commonjs-require.d.ts +26 -0
- package/dist/semantics/normalize/commonjs-require.js +355 -121
- package/dist/semantics/normalize/dead-event-emissions.d.ts +6 -0
- package/dist/semantics/normalize/dead-event-emissions.js +866 -0
- package/dist/semantics/normalize/dead-method-copies.d.ts +56 -0
- package/dist/semantics/normalize/dead-method-copies.js +239 -0
- package/dist/semantics/normalize/derived-expression-type.d.ts +149 -2
- package/dist/semantics/normalize/derived-expression-type.js +418 -14
- package/dist/semantics/normalize/field-bindings.js +139 -4
- package/dist/semantics/normalize/flow/callable-reach.js +162 -9
- package/dist/semantics/normalize/flow/member-call-forwarding.js +6 -0
- package/dist/semantics/normalize/flow/owned-class-receivers.js +40 -2
- package/dist/semantics/normalize/flow/source-class-data.d.ts +7 -1
- package/dist/semantics/normalize/flow/source-class-data.js +28 -9
- package/dist/semantics/normalize/flow/source-value-session.js +32 -13
- package/dist/semantics/normalize/flow/targets.d.ts +32 -0
- package/dist/semantics/normalize/flow/targets.js +65 -6
- package/dist/semantics/normalize/flow/value-flow.d.ts +7 -0
- package/dist/semantics/normalize/flow/value-flow.js +30 -2
- package/dist/semantics/normalize/fresh-array-result.d.ts +32 -0
- package/dist/semantics/normalize/fresh-array-result.js +125 -0
- package/dist/semantics/normalize/gating.js +2 -0
- package/dist/semantics/normalize/global-host-mutations.d.ts +11 -1
- package/dist/semantics/normalize/global-host-mutations.js +691 -27
- package/dist/semantics/normalize/host-effect-contracts.d.ts +43 -1
- package/dist/semantics/normalize/host-effect-contracts.js +60 -3
- package/dist/semantics/normalize/identities.js +49 -3
- package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +59 -0
- package/dist/semantics/normalize/intrinsic-accessor-getter.js +129 -0
- package/dist/semantics/normalize/local-bindings.js +117 -21
- package/dist/semantics/normalize/merged-declaration.d.ts +41 -0
- package/dist/semantics/normalize/merged-declaration.js +81 -0
- package/dist/semantics/normalize/never-override-result.d.ts +21 -0
- package/dist/semantics/normalize/never-override-result.js +64 -0
- package/dist/semantics/normalize/null-blind-parameter.d.ts +21 -0
- package/dist/semantics/normalize/null-blind-parameter.js +77 -0
- package/dist/semantics/normalize/object-bag-bindings.js +10 -0
- package/dist/semantics/normalize/override-field-arms.d.ts +33 -0
- package/dist/semantics/normalize/override-field-arms.js +362 -0
- package/dist/semantics/normalize/parameter-bindings.d.ts +64 -1
- package/dist/semantics/normalize/parameter-bindings.js +801 -81
- package/dist/semantics/normalize/parameter-slot.d.ts +1 -0
- package/dist/semantics/normalize/parameter-slot.js +69 -0
- package/dist/semantics/normalize/physical-overload-result.d.ts +45 -0
- package/dist/semantics/normalize/physical-overload-result.js +132 -0
- package/dist/semantics/normalize/producer-context.d.ts +23 -0
- package/dist/semantics/normalize/producers/allocations.d.ts +13 -0
- package/dist/semantics/normalize/producers/allocations.js +8 -15
- package/dist/semantics/normalize/producers/binding-kind.d.ts +11 -0
- package/dist/semantics/normalize/producers/binding-kind.js +31 -0
- package/dist/semantics/normalize/producers/bindings.js +16 -1
- package/dist/semantics/normalize/producers/boundary.js +21 -1
- package/dist/semantics/normalize/producers/class-lifecycle.js +23 -14
- package/dist/semantics/normalize/producers/computations.js +8 -67
- package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
- package/dist/semantics/normalize/producers/control-loops.js +25 -1
- package/dist/semantics/normalize/producers/control.js +87 -60
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +5 -0
- package/dist/semantics/normalize/producers/enums.d.ts +10 -0
- package/dist/semantics/normalize/producers/enums.js +169 -0
- package/dist/semantics/normalize/producers/erasure.d.ts +10 -0
- package/dist/semantics/normalize/producers/erasure.js +23 -0
- package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +15 -0
- package/dist/semantics/normalize/producers/intrinsic-accessor-getter.js +33 -0
- package/dist/semantics/normalize/producers/invocations.js +255 -18
- package/dist/semantics/normalize/producers/iteration-yield.js +6 -1
- package/dist/semantics/normalize/producers/logical-merge-type.d.ts +36 -0
- package/dist/semantics/normalize/producers/logical-merge-type.js +163 -0
- package/dist/semantics/normalize/producers/properties.js +207 -18
- package/dist/semantics/normalize/producers/protocol.d.ts +4 -0
- package/dist/semantics/normalize/producers/protocol.js +147 -12
- package/dist/semantics/normalize/producers/references.js +50 -9
- package/dist/semantics/normalize/producers/shared.d.ts +120 -0
- package/dist/semantics/normalize/producers/shared.js +359 -10
- package/dist/semantics/normalize/producers/spread-arguments.js +85 -4
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -0
- package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
- package/dist/semantics/normalize/property-key-domain.js +6 -0
- package/dist/semantics/normalize/reachability.d.ts +7 -0
- package/dist/semantics/normalize/reachability.js +166 -9
- package/dist/semantics/normalize/record-home-arms.d.ts +25 -0
- package/dist/semantics/normalize/record-home-arms.js +87 -0
- package/dist/semantics/normalize/record-link-families.d.ts +74 -0
- package/dist/semantics/normalize/record-link-families.js +327 -0
- package/dist/semantics/normalize/record-stand-in-arms.d.ts +56 -0
- package/dist/semantics/normalize/record-stand-in-arms.js +484 -0
- package/dist/semantics/normalize/return-bindings.d.ts +6 -2
- package/dist/semantics/normalize/return-bindings.js +60 -7
- package/dist/semantics/normalize/script-global-redefinition.js +5 -0
- package/dist/semantics/normalize/shared-array-storage.d.ts +42 -0
- package/dist/semantics/normalize/shared-array-storage.js +373 -0
- package/dist/semantics/normalize/sloppy-absence.d.ts +41 -0
- package/dist/semantics/normalize/sloppy-absence.js +199 -0
- package/dist/semantics/normalize/specialization.d.ts +40 -0
- package/dist/semantics/normalize/specialization.js +770 -36
- package/dist/semantics/normalize/structural-array-element.js +196 -6
- package/dist/semantics/normalize/structural-array-read.js +12 -0
- package/dist/semantics/normalize/structural-creation-order.d.ts +15 -0
- package/dist/semantics/normalize/structural-creation-order.js +51 -48
- package/dist/semantics/normalize/structural-declarations.d.ts +16 -0
- package/dist/semantics/normalize/structural-declarations.js +43 -0
- package/dist/semantics/normalize/structural-generics.d.ts +13 -0
- package/dist/semantics/normalize/structural-generics.js +22 -0
- package/dist/semantics/normalize/structural-indexed-access.js +16 -0
- package/dist/semantics/normalize/structural-instantiated-member.js +68 -2
- package/dist/semantics/normalize/structural-joins.js +2 -0
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +30 -0
- package/dist/semantics/normalize/structural-layout-relevance.js +164 -0
- package/dist/semantics/normalize/structural-layout-type.js +270 -14
- package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
- package/dist/semantics/normalize/structural-leaves.js +17 -3
- package/dist/semantics/normalize/structural-mutable-method.js +5 -1
- package/dist/semantics/normalize/structural-parts.d.ts +18 -5
- package/dist/semantics/normalize/structural-parts.js +68 -19
- package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
- package/dist/semantics/normalize/structural-receiver.js +23 -1
- package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
- package/dist/semantics/normalize/structural-self-reference.js +23 -2
- package/dist/semantics/normalize/structural.d.ts +12 -1
- package/dist/semantics/normalize/structural.js +1420 -53
- package/dist/semantics/normalize/suppressed-write-arms.d.ts +47 -0
- package/dist/semantics/normalize/suppressed-write-arms.js +393 -0
- package/dist/semantics/normalize/unresolvable-names.d.ts +15 -2
- package/dist/semantics/normalize/unresolvable-names.js +30 -6
- package/dist/semantics/normalize/unshared-array-result.d.ts +32 -0
- package/dist/semantics/normalize/unshared-array-result.js +125 -0
- package/dist/semantics/package-sources.d.ts +1 -1
- package/dist/semantics/package-sources.js +120 -8
- package/dist/semantics/program.d.ts +20 -0
- package/dist/semantics/program.js +145 -14
- package/dist/semantics/stable-checker.d.ts +1 -1
- package/dist/semantics/stable-checker.js +7 -2
- package/dist/semantics/unchecked-guard-argument-copies.d.ts +67 -0
- package/dist/semantics/unchecked-guard-argument-copies.js +163 -0
- package/dist/semantics/unchecked-write-member-declarations.d.ts +46 -0
- package/dist/semantics/unchecked-write-member-declarations.js +331 -0
- package/dist/targets/cpp/balanced-units.d.ts +31 -0
- package/dist/targets/cpp/balanced-units.js +57 -0
- package/dist/targets/cpp/borrowed-arm-projections.d.ts +31 -0
- package/dist/targets/cpp/borrowed-arm-projections.js +106 -0
- package/dist/targets/cpp/borrowed-call-entry.d.ts +1 -1
- package/dist/targets/cpp/borrowed-call-entry.js +24 -20
- package/dist/targets/cpp/captures.js +314 -8
- package/dist/targets/cpp/char-code-buffers.d.ts +36 -0
- package/dist/targets/cpp/char-code-buffers.js +214 -0
- package/dist/targets/cpp/class-layout.d.ts +7 -1
- package/dist/targets/cpp/class-layout.js +42 -17
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +17 -2
- package/dist/targets/cpp/class-properties/computed-method-value.js +50 -4
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +31 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +174 -17
- package/dist/targets/cpp/class-ref-transport.d.ts +32 -0
- package/dist/targets/cpp/class-ref-transport.js +56 -1
- package/dist/targets/cpp/conversions.js +1827 -1502
- package/dist/targets/cpp/coroutine-bodies.d.ts +97 -0
- package/dist/targets/cpp/coroutine-bodies.js +187 -0
- package/dist/targets/cpp/document.js +11 -1
- package/dist/targets/cpp/emit-allocation.js +535 -21
- package/dist/targets/cpp/emit-arrays.d.ts +10 -0
- package/dist/targets/cpp/emit-arrays.js +147 -16
- package/dist/targets/cpp/emit-binding-reference.d.ts +26 -2
- package/dist/targets/cpp/emit-binding-reference.js +97 -5
- package/dist/targets/cpp/emit-bindings.d.ts +9 -1
- package/dist/targets/cpp/emit-bindings.js +108 -8
- package/dist/targets/cpp/emit-buffers.d.ts +2 -16
- package/dist/targets/cpp/emit-buffers.js +124 -25
- package/dist/targets/cpp/emit-callable.d.ts +35 -72
- package/dist/targets/cpp/emit-callable.js +647 -82
- package/dist/targets/cpp/emit-carrier-members.d.ts +13 -2
- package/dist/targets/cpp/emit-carrier-members.js +50 -9
- package/dist/targets/cpp/emit-constructor-identity-family.d.ts +20 -0
- package/dist/targets/cpp/emit-constructor-identity-family.js +45 -0
- package/dist/targets/cpp/emit-context.d.ts +329 -15
- package/dist/targets/cpp/emit-context.js +104 -13
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +44 -0
- package/dist/targets/cpp/emit-dynamic-properties.js +256 -37
- package/dist/targets/cpp/emit-equality.js +117 -2
- package/dist/targets/cpp/emit-error-constructor.d.ts +19 -0
- package/dist/targets/cpp/emit-error-constructor.js +73 -0
- package/dist/targets/cpp/emit-exceptions.d.ts +25 -3
- package/dist/targets/cpp/emit-exceptions.js +215 -26
- package/dist/targets/cpp/emit-in.js +52 -5
- package/dist/targets/cpp/emit-instanceof.js +59 -11
- package/dist/targets/cpp/emit-integers.d.ts +6 -0
- package/dist/targets/cpp/emit-integers.js +10 -0
- package/dist/targets/cpp/emit-iterable-object-view.d.ts +15 -0
- package/dist/targets/cpp/emit-iterable-object-view.js +51 -0
- package/dist/targets/cpp/emit-iterator-object-view.d.ts +15 -0
- package/dist/targets/cpp/emit-iterator-object-view.js +125 -0
- package/dist/targets/cpp/emit-iterator.d.ts +7 -10
- package/dist/targets/cpp/emit-iterator.js +361 -24
- package/dist/targets/cpp/emit-json.d.ts +7 -1
- package/dist/targets/cpp/emit-json.js +594 -54
- package/dist/targets/cpp/emit-jsx.d.ts +0 -37
- package/dist/targets/cpp/emit-jsx.js +70 -8
- package/dist/targets/cpp/emit-narrowing.d.ts +192 -28
- package/dist/targets/cpp/emit-narrowing.js +1595 -120
- package/dist/targets/cpp/emit-native-selection.js +8 -2
- package/dist/targets/cpp/emit-presence.js +13 -0
- package/dist/targets/cpp/emit-properties.d.ts +3 -1
- package/dist/targets/cpp/emit-properties.js +303 -54
- package/dist/targets/cpp/emit-protocol-iterator.d.ts +14 -0
- package/dist/targets/cpp/emit-protocol-iterator.js +203 -0
- package/dist/targets/cpp/emit-proxy.d.ts +17 -0
- package/dist/targets/cpp/emit-proxy.js +35 -0
- package/dist/targets/cpp/emit-record-view.d.ts +12 -1
- package/dist/targets/cpp/emit-record-view.js +429 -18
- package/dist/targets/cpp/emit-return.d.ts +38 -0
- package/dist/targets/cpp/emit-return.js +143 -21
- package/dist/targets/cpp/emit-scopes.d.ts +78 -0
- package/dist/targets/cpp/emit-scopes.js +196 -0
- package/dist/targets/cpp/emit-sum-widening.js +6 -3
- package/dist/targets/cpp/emit-tonumber.d.ts +40 -1
- package/dist/targets/cpp/emit-tonumber.js +75 -4
- package/dist/targets/cpp/emit-tostring.d.ts +28 -2
- package/dist/targets/cpp/emit-tostring.js +115 -12
- package/dist/targets/cpp/emit-typeof.js +2 -2
- package/dist/targets/cpp/emit-union-properties.d.ts +9 -0
- package/dist/targets/cpp/emit-union-properties.js +375 -46
- package/dist/targets/cpp/emit.d.ts +3 -1
- package/dist/targets/cpp/emit.js +725 -90
- package/dist/targets/cpp/evaluated-once.d.ts +51 -0
- package/dist/targets/cpp/evaluated-once.js +140 -0
- package/dist/targets/cpp/host/core-globals.d.ts +0 -21
- package/dist/targets/cpp/host/core-globals.js +10 -2
- package/dist/targets/cpp/host/emit-host-invoke.d.ts +0 -10
- package/dist/targets/cpp/host/emit-host-invoke.js +454 -36
- package/dist/targets/cpp/host/emit-host-object.js +733 -88
- package/dist/targets/cpp/host/emit-host-properties.js +26 -2
- package/dist/targets/cpp/host/emit-host-reflect.d.ts +1 -0
- package/dist/targets/cpp/host/emit-host-reflect.js +26 -7
- package/dist/targets/cpp/host/emit-host-value.d.ts +13 -0
- package/dist/targets/cpp/host/emit-host-value.js +48 -4
- package/dist/targets/cpp/host/host-members.d.ts +11 -0
- package/dist/targets/cpp/host/host-members.js +50 -4
- package/dist/targets/cpp/host/native-protocols.js +3 -0
- package/dist/targets/cpp/host/object-protocol.d.ts +8 -0
- package/dist/targets/cpp/host/object-protocol.js +55 -13
- package/dist/targets/cpp/key-order-tracking.d.ts +11 -0
- package/dist/targets/cpp/key-order-tracking.js +18 -0
- package/dist/targets/cpp/manifest/capabilities.js +107 -8
- package/dist/targets/cpp/manifest.js +14 -0
- package/dist/targets/cpp/native-collection-base.d.ts +27 -0
- package/dist/targets/cpp/native-collection-base.js +202 -0
- package/dist/targets/cpp/native-error-base.d.ts +14 -0
- package/dist/targets/cpp/native-error-base.js +19 -4
- package/dist/targets/cpp/native-promise-base.d.ts +23 -0
- package/dist/targets/cpp/native-promise-base.js +30 -0
- package/dist/targets/cpp/native-symbol-keys.js +1 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +258 -20
- package/dist/targets/cpp/prototype/emit-prototype-date.js +5 -4
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +9 -1
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +232 -26
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +1 -1
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +111 -13
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +33 -4
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +218 -10
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +8 -5
- package/dist/targets/cpp/prototype/emit-prototype-string.js +24 -7
- package/dist/targets/cpp/prototype/prototype-method-reads.js +18 -3
- package/dist/targets/cpp/reactive-dependencies.d.ts +2 -0
- package/dist/targets/cpp/reactive-dependencies.js +94 -3
- package/dist/targets/cpp/realm-storage.d.ts +5 -0
- package/dist/targets/cpp/realm-storage.js +12 -0
- package/dist/targets/cpp/records.d.ts +151 -1
- package/dist/targets/cpp/records.js +1321 -122
- package/dist/targets/cpp/recursive-containers.d.ts +4 -1
- package/dist/targets/cpp/recursive-containers.js +28 -9
- package/dist/targets/cpp/translation-unit.d.ts +10 -0
- package/dist/targets/cpp/translation-unit.js +686 -140
- package/dist/targets/cpp/types.d.ts +56 -6
- package/dist/targets/cpp/types.js +218 -12
- package/dist/targets/cpp/virtual-methods.d.ts +3 -3
- package/dist/targets/cpp/virtual-methods.js +174 -17
- package/package.json +6 -5
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +155 -25
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_pcm.h +116 -0
- package/src/targets/cpp/runtime/gea_runtime.h +18007 -4757
- package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +7 -45
- package/src/targets/cpp/runtime/gea_runtime_rtc.h +247 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { extendsClass, virtualDispatchKey, virtualMethodFamiliesOf } from '../../projection/dispatch.js';
|
|
2
2
|
export { extendsClass, virtualDispatchKey, virtualMethodFamiliesOf };
|
|
3
3
|
import { cppFormalName } from './emit-context.js';
|
|
4
|
-
import {
|
|
4
|
+
import { wellKnownSymbolEnumNameOf } from './records.js';
|
|
5
|
+
import { cppAbiParameterType, cppBodyName, cppCallableDeclarationTagName, cppClassName, cppRecordFieldKeyIsSymbol, cppRecordFieldName, cppResultTypeOf, cppStringLiteral, cppTypeOf, cppUndefinedIn } from './types.js';
|
|
5
6
|
import { alignedValueText, dynamicCarrierBoxText } from './emit-narrowing.js';
|
|
6
7
|
/**
|
|
7
8
|
* The C++ member one family dispatches through.
|
|
@@ -10,7 +11,21 @@ import { alignedValueText, dynamicCarrierBoxText } from './emit-narrowing.js';
|
|
|
10
11
|
* and a method whose names would otherwise collide inside one struct, and the
|
|
11
12
|
* field's spelling is already `cppRecordFieldName`'s.
|
|
12
13
|
*/
|
|
13
|
-
export const cppVirtualMemberName = (key, role = 'call') => `${role === 'set' ? 'gea_vset_' : role === 'get' ? 'gea_vget_' : 'gea_vcall_'}${cppRecordFieldName(key)}`;
|
|
14
|
+
export const cppVirtualMemberName = (key, role = 'call', copy) => `${role === 'set' ? 'gea_vset_' : role === 'get' ? 'gea_vget_' : 'gea_vcall_'}${cppRecordFieldName(key)}${copy === undefined ? '' : `_c${copyTagOf(copy)}`}`;
|
|
15
|
+
/**
|
|
16
|
+
* A short, stable spelling of a generic-method copy's convention for its
|
|
17
|
+
* member name (`projection/dispatch.ts`'s `virtualCopyFamiliesOf`): FNV-1a over
|
|
18
|
+
* the receiverless ABI key, so the family and every call site derive the same
|
|
19
|
+
* name from the convention alone.
|
|
20
|
+
*/
|
|
21
|
+
const copyTagOf = (copy) => {
|
|
22
|
+
let hash = 0x811c9dc5;
|
|
23
|
+
for (let index = 0; index < copy.length; index++) {
|
|
24
|
+
hash ^= copy.charCodeAt(index);
|
|
25
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
26
|
+
}
|
|
27
|
+
return hash.toString(16).padStart(8, '0');
|
|
28
|
+
};
|
|
14
29
|
/** The parameter list a family's member takes: the body's ABI minus the receiver, which becomes `this`. */
|
|
15
30
|
const memberFormalsOf = (abi) => abi.parameters.map((parameter, ordinal) => `${cppAbiParameterType(parameter)} ${cppFormalName(ordinal)}`);
|
|
16
31
|
/**
|
|
@@ -87,6 +102,9 @@ const virtualMethodAdapterOf = (site, classes, family, implementor, rootAbi, act
|
|
|
87
102
|
const result = virtualValueConversionText(site, classes, actualAbi.result, rootAbi.result, invocation) ?? drift('the result');
|
|
88
103
|
return { result };
|
|
89
104
|
};
|
|
105
|
+
const throwVirtualFieldDrift = (declaration, key) => {
|
|
106
|
+
throw new Error(`virtual field implementation ${declaration}.${key}: the dispatch verdict proved a conversion the emitter found none for`);
|
|
107
|
+
};
|
|
90
108
|
const throwVirtualAdapterDrift = (family, implementor, reason) => {
|
|
91
109
|
throw new Error(`virtual method adapter for ${implementor.declaration}.${family.key}: ${reason}`);
|
|
92
110
|
};
|
|
@@ -104,9 +122,10 @@ const throwVirtualAdapterDrift = (family, implementor, reason) => {
|
|
|
104
122
|
* capture index at render time the way `targets/cpp/captures.ts`'s
|
|
105
123
|
* `buildCaptureIndex` used to require.
|
|
106
124
|
*/
|
|
107
|
-
export const virtualMethodEmission = (site, classes, abiOf, verdict) => {
|
|
125
|
+
export const virtualMethodEmission = (site, classes, abiOf, verdict, reparentTargets = new Map()) => {
|
|
108
126
|
const membersByStruct = new Map();
|
|
109
127
|
const definitions = [];
|
|
128
|
+
const reparented = reparentedAllocationsOf(reparentTargets);
|
|
110
129
|
for (const { family, rootAbi } of verdict.families) {
|
|
111
130
|
const adapters = new Map();
|
|
112
131
|
for (const implementor of family.implementors) {
|
|
@@ -127,20 +146,39 @@ export const virtualMethodEmission = (site, classes, abiOf, verdict) => {
|
|
|
127
146
|
const failure = `std::fprintf(stderr, "gea: abstract method ${String(family.root)}.${family.key} has no implementation\\n"); std::abort();`;
|
|
128
147
|
membersByStruct.set(cppClassName(family.root), [
|
|
129
148
|
...(membersByStruct.get(cppClassName(family.root)) ?? []),
|
|
130
|
-
` virtual ${result} ${cppVirtualMemberName(family.key, family.role)}(${formals});`
|
|
149
|
+
` virtual ${result} ${cppVirtualMemberName(family.key, family.role, family.copy)}(${formals});`
|
|
131
150
|
]);
|
|
132
|
-
definitions.push(`${result} ${cppClassName(family.root)}::${cppVirtualMemberName(family.key, family.role)}(${formals}) { ${failure} }`);
|
|
151
|
+
definitions.push(`${result} ${cppClassName(family.root)}::${cppVirtualMemberName(family.key, family.role, family.copy)}(${formals}) { ${failure} }`);
|
|
133
152
|
}
|
|
134
153
|
for (const implementor of family.implementors) {
|
|
135
154
|
const structName = cppClassName(implementor.declaration);
|
|
136
155
|
const isRoot = implementor.declaration === family.root && !family.abstractRoot;
|
|
137
156
|
const members = membersByStruct.get(structName) ?? [];
|
|
138
|
-
members.push(` ${isRoot ? 'virtual ' : ''}${result} ${cppVirtualMemberName(family.key, family.role)}(${formals})${isRoot ? '' : ' override'};`);
|
|
157
|
+
members.push(` ${isRoot ? 'virtual ' : ''}${result} ${cppVirtualMemberName(family.key, family.role, family.copy)}(${formals})${isRoot ? '' : ' override'};`);
|
|
139
158
|
membersByStruct.set(structName, members);
|
|
140
159
|
const adapter = adapters.get(implementor.declaration);
|
|
141
160
|
if (adapter === undefined)
|
|
142
161
|
throw new Error(`virtual method adapter for ${implementor.declaration}.${family.key} was not retained`);
|
|
143
|
-
|
|
162
|
+
const prefix = reparentPrefixOf(classes, family, implementor.declaration, reparented, rootAbi.parameters.length);
|
|
163
|
+
definitions.push(`${result} ${structName}::${cppVirtualMemberName(family.key, family.role, family.copy)}(${formals}) { ${prefix}${result === 'void' ? '' : 'return '}${adapter.result}; }`);
|
|
164
|
+
}
|
|
165
|
+
// A derived class whose own data field implements the accessor: the
|
|
166
|
+
// override reads (or writes) that field, which is what the property is
|
|
167
|
+
// on such an instance (`VirtualMethodFamily.fieldImplementors`).
|
|
168
|
+
for (const { declaration, field } of family.fieldImplementors ?? []) {
|
|
169
|
+
const structName = cppClassName(declaration);
|
|
170
|
+
const stored = field.representation;
|
|
171
|
+
if (stored === null)
|
|
172
|
+
throw new Error(`virtual field implementation ${declaration}.${family.key} has no carrier`);
|
|
173
|
+
const member = cppVirtualMemberName(family.key, family.role, family.copy);
|
|
174
|
+
const slot = `this->${cppRecordFieldName(family.key)}`;
|
|
175
|
+
const written = rootAbi.parameters[0]?.value;
|
|
176
|
+
const body = family.role === 'get'
|
|
177
|
+
? `return ${virtualValueConversionText(site, classes, stored, rootAbi.result, slot) ?? throwVirtualFieldDrift(declaration, family.key)};`
|
|
178
|
+
: `${slot} = ${(written && virtualValueConversionText(site, classes, written, stored, cppFormalName(0))) ?? throwVirtualFieldDrift(declaration, family.key)};` +
|
|
179
|
+
(result === 'void' ? '' : ` return ${cppUndefinedIn(rootAbi.result) ?? throwVirtualFieldDrift(declaration, family.key)};`);
|
|
180
|
+
membersByStruct.set(structName, [...(membersByStruct.get(structName) ?? []), ` ${result} ${member}(${formals}) override;`]);
|
|
181
|
+
definitions.push(`${result} ${structName}::${member}(${formals}) { ${body} }`);
|
|
144
182
|
}
|
|
145
183
|
}
|
|
146
184
|
return {
|
|
@@ -150,6 +188,84 @@ export const virtualMethodEmission = (site, classes, abiOf, verdict) => {
|
|
|
150
188
|
dispatched: new Map([...verdict.dispatched].map(([key, entry]) => [key, entry.rootAbi]))
|
|
151
189
|
};
|
|
152
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Which classes an instance ALLOCATED as each class may be re-classed onto,
|
|
193
|
+
* closed over chains: an instance re-classed S -> M and then M -> M2 still
|
|
194
|
+
* carries S's vtable, so S's members must know M2 as well.
|
|
195
|
+
*/
|
|
196
|
+
const reparentedAllocationsOf = (targets) => {
|
|
197
|
+
const allocations = new Map();
|
|
198
|
+
for (const [target, sources] of targets)
|
|
199
|
+
allocations.set(target, new Set(sources));
|
|
200
|
+
let changed = true;
|
|
201
|
+
while (changed) {
|
|
202
|
+
changed = false;
|
|
203
|
+
for (const [target, sources] of allocations) {
|
|
204
|
+
for (const source of [...sources]) {
|
|
205
|
+
for (const inherited of allocations.get(source) ?? []) {
|
|
206
|
+
if (inherited === target || sources.has(inherited))
|
|
207
|
+
continue;
|
|
208
|
+
sources.add(inherited);
|
|
209
|
+
changed = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const byAllocation = new Map();
|
|
215
|
+
for (const [target, sources] of allocations) {
|
|
216
|
+
for (const source of sources)
|
|
217
|
+
byAllocation.set(source, (byAllocation.get(source) ?? new Set()).add(target));
|
|
218
|
+
}
|
|
219
|
+
return byAllocation;
|
|
220
|
+
};
|
|
221
|
+
/** The class whose body a `key` call on an exact `declaration` instance runs: the nearest along its chain that implements it. */
|
|
222
|
+
const implementorFor = (classes, family, declaration) => {
|
|
223
|
+
const implementors = new Set(family.implementors.map((implementor) => implementor.declaration));
|
|
224
|
+
const walked = new Set();
|
|
225
|
+
for (let current = declaration; current !== null && !walked.has(current); current = classes.get(current)?.base ?? null) {
|
|
226
|
+
walked.add(current);
|
|
227
|
+
if (implementors.has(current))
|
|
228
|
+
return current;
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* The re-class test a virtual member's definition runs first, when an
|
|
234
|
+
* instance whose vtable leads here may have been re-classed
|
|
235
|
+
* (`gea::reparentInstance`) onto a class that answers this key with a
|
|
236
|
+
* different body.
|
|
237
|
+
*
|
|
238
|
+
* A re-classed object keeps the vtable of the class it was allocated as --
|
|
239
|
+
* C++ gives no way to change it -- while its ref header now names the new
|
|
240
|
+
* class. So the definition every such vtable resolves to asks the header, and
|
|
241
|
+
* forwards to the new class's own definition by a QUALIFIED (non-virtual)
|
|
242
|
+
* call. The static downcast is sound only because the target adds no storage,
|
|
243
|
+
* which `ir/instance-reparenting.ts` proves and `gea::reparentInstance`
|
|
244
|
+
* re-asserts: the object is laid out exactly as the target is.
|
|
245
|
+
*
|
|
246
|
+
* Only definitions some allocated class's vtable reaches for a proven
|
|
247
|
+
* re-parent get a test; every other class pays nothing.
|
|
248
|
+
*/
|
|
249
|
+
const reparentPrefixOf = (classes, family, definer, reparented, arity) => {
|
|
250
|
+
const forwards = [];
|
|
251
|
+
const seenTargets = new Set();
|
|
252
|
+
const actuals = Array.from({ length: arity }, (_, ordinal) => `std::move(${cppFormalName(ordinal)})`).join(', ');
|
|
253
|
+
for (const [allocated, targets] of [...reparented].sort(([left], [right]) => (left < right ? -1 : 1))) {
|
|
254
|
+
if (implementorFor(classes, family, allocated) !== definer)
|
|
255
|
+
continue;
|
|
256
|
+
for (const target of [...targets].sort()) {
|
|
257
|
+
if (seenTargets.has(target))
|
|
258
|
+
continue;
|
|
259
|
+
const answering = implementorFor(classes, family, target);
|
|
260
|
+
if (answering === null || answering === definer)
|
|
261
|
+
continue;
|
|
262
|
+
seenTargets.add(target);
|
|
263
|
+
forwards.push(`if (gea::detail::refHeaderOf(static_cast<void*>(this))->operations == &gea::detail::RefOperationsFor<${cppClassName(target)}>::table) ` +
|
|
264
|
+
`return static_cast<${cppClassName(target)}*>(this)->${cppClassName(answering)}::${cppVirtualMemberName(family.key, family.role, family.copy)}(${actuals}); `);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return forwards.join('');
|
|
268
|
+
};
|
|
153
269
|
/**
|
|
154
270
|
* The runtime's `NativePrototypeTable` hooks for every class that declares a
|
|
155
271
|
* getter or method, so a boxed instance answers a dynamic read of either.
|
|
@@ -174,15 +290,24 @@ export const virtualMethodEmission = (site, classes, abiOf, verdict) => {
|
|
|
174
290
|
* dynamic carrier must not spell at all (`test/stored-listener-native-flow`,
|
|
175
291
|
* `native-method-overrides`' `emitted-lacks: gea::Value::box`).
|
|
176
292
|
*/
|
|
177
|
-
export const prototypeReadHooks = (classes, abiOf, capturesNothing, readDynamically) => {
|
|
178
|
-
// A method read yields
|
|
179
|
-
//
|
|
293
|
+
export const prototypeReadHooks = (classes, abiOf, capturesNothing, readDynamically, wellKnownSymbols = new Map()) => {
|
|
294
|
+
// A method read yields the ONE function object its class evaluation holds
|
|
295
|
+
// for that method (`gea::nativeClassMethodValue`), the object a native read
|
|
296
|
+
// of it yields too. A fresh object per read made `box.m === box.m` false and
|
|
297
|
+
// dropped every write through it: mongodb-shaped code that patches a
|
|
298
|
+
// method's `bind` through a boxed instance wrote onto a throwaway, and a
|
|
299
|
+
// native `this.m.bind(this)` guarded on that object's own `bind`
|
|
300
|
+
// (`emit-callable.ts`'s `guardedBindLines`) could not see the write.
|
|
180
301
|
const methods = (layout) => layout.methods.flatMap((method) => {
|
|
181
302
|
if (method.callable === null || !capturesNothing(method.callable))
|
|
182
303
|
return [];
|
|
183
304
|
const abi = abiOf(method.callable);
|
|
184
305
|
if (abi === null || abi.receiver === null)
|
|
185
306
|
return [];
|
|
307
|
+
const callable = method.callable;
|
|
308
|
+
const owner = [...classes.values()].find((candidate) => candidate.methods.some((entry) => entry.callable === callable && entry.key === method.key));
|
|
309
|
+
if (owner === undefined)
|
|
310
|
+
return [];
|
|
186
311
|
const value = { kind: 'function-value-dispatch', abi };
|
|
187
312
|
const receiver = abi.receiver;
|
|
188
313
|
const formals = [
|
|
@@ -191,7 +316,9 @@ export const prototypeReadHooks = (classes, abiOf, capturesNothing, readDynamica
|
|
|
191
316
|
];
|
|
192
317
|
const actuals = ['gea_receiver', ...abi.parameters.map((_, i) => cppFormalName(i))];
|
|
193
318
|
const thunk = `+[](void*, ${formals.join(', ')}) -> ${cppResultTypeOf(abi.result)} { return ${cppBodyName(method.callable)}(${actuals.join(', ')}); }`;
|
|
194
|
-
const
|
|
319
|
+
const identified = `gea::nativeClassMethodValue<${cppClassName(owner.declaration)}, &${cppCallableDeclarationTagName(callable)}>` +
|
|
320
|
+
`(this->gea_method_state, ${cppTypeOf(value)}{${thunk}, nullptr})`;
|
|
321
|
+
const boxed = dynamicCarrierBoxText(value, identified);
|
|
195
322
|
return boxed === null ? [] : [{ key: method.key, text: boxed }];
|
|
196
323
|
});
|
|
197
324
|
const readable = (layout) => [
|
|
@@ -241,17 +368,47 @@ export const prototypeReadHooks = (classes, abiOf, capturesNothing, readDynamica
|
|
|
241
368
|
` ${lead}gea::detail::NativePrototypeOps::SetResult gea_setPrototypeProperty(const gea::PropertyKey& gea_key, const gea::Value& gea_value, const gea::Value& gea_receiver)${tail};`
|
|
242
369
|
]);
|
|
243
370
|
const inherited = ancestor === null ? null : cppClassName(ancestor);
|
|
244
|
-
|
|
371
|
+
// A symbol-keyed member (`get [BSON_VERSION_SYMBOL]()` on bson's
|
|
372
|
+
// `BSONValue`) is laid out under its `sym(<declaration>)` marker, which no
|
|
373
|
+
// text key ever equals: it matches by the symbol's runtime id -- a
|
|
374
|
+
// well-known symbol's fixed one, or the id the program's own symbol cell
|
|
375
|
+
// registered (`gea::detail::registerDeclaredSymbol`), exactly as the
|
|
376
|
+
// record field dispatcher compares them (`records.ts`).
|
|
377
|
+
const texts = getters.filter((getter) => !cppRecordFieldKeyIsSymbol(getter.key));
|
|
378
|
+
const symbols = getters.filter((getter) => cppRecordFieldKeyIsSymbol(getter.key));
|
|
379
|
+
const symbolTest = (key) => {
|
|
380
|
+
const wellKnown = wellKnownSymbolEnumNameOf(wellKnownSymbols, key);
|
|
381
|
+
return wellKnown === null
|
|
382
|
+
? `gea_key.symbolId() == gea::detail::declaredSymbolId<${cppStringLiteral(key)}>()`
|
|
383
|
+
: `gea_key.symbolId() == static_cast<std::uint32_t>(gea::detail::WellKnownSymbol::${wellKnown})`;
|
|
384
|
+
};
|
|
385
|
+
const has = [
|
|
386
|
+
...(texts.length === 0
|
|
387
|
+
? []
|
|
388
|
+
: [`(!gea_key.isSymbol() && (${texts.map((getter) => `gea_key.text() == ${cppStringLiteral(getter.key)}`).join(' || ')}))`]),
|
|
389
|
+
...(symbols.length === 0 ? [] : [`(gea_key.isSymbol() && (${symbols.map((getter) => symbolTest(getter.key)).join(' || ')}))`])
|
|
390
|
+
];
|
|
245
391
|
definitions.push([
|
|
246
392
|
`bool ${struct}::gea_readPrototypeProperty(const gea::PropertyKey& gea_key, gea::Value& gea_out) const {`,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
393
|
+
...(texts.length === 0
|
|
394
|
+
? []
|
|
395
|
+
: [
|
|
396
|
+
' if (!gea_key.isSymbol()) {',
|
|
397
|
+
' const std::string& gea_name = gea_key.text();',
|
|
398
|
+
...texts.map((getter) => ` if (gea_name == ${cppStringLiteral(getter.key)}) { gea_out = ${getter.text}; return true; }`),
|
|
399
|
+
' }'
|
|
400
|
+
]),
|
|
401
|
+
...(symbols.length === 0
|
|
402
|
+
? []
|
|
403
|
+
: [
|
|
404
|
+
' if (gea_key.isSymbol()) {',
|
|
405
|
+
...symbols.map((getter) => ` if (${symbolTest(getter.key)}) { gea_out = ${getter.text}; return true; }`),
|
|
406
|
+
' }'
|
|
407
|
+
]),
|
|
251
408
|
` return ${inherited === null ? 'false' : `${inherited}::gea_readPrototypeProperty(gea_key, gea_out)`};`,
|
|
252
409
|
'}',
|
|
253
410
|
`bool ${struct}::gea_hasPrototypeProperty(const gea::PropertyKey& gea_key) const {`,
|
|
254
|
-
` if (
|
|
411
|
+
` if (${has.join(' || ')}) return true;`,
|
|
255
412
|
` return ${inherited === null ? 'false' : `${inherited}::gea_hasPrototypeProperty(gea_key)`};`,
|
|
256
413
|
'}',
|
|
257
414
|
// Setters stay on the static paths; a dynamic write falls through to the payload's own fields.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "The geastack TypeScript-to-C++ compiler: one semantic spine, no source-shaped authority, no boxing of statically typed values.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"test:compact-runtime": "node test/compact-runtime.mjs",
|
|
50
50
|
"test:stored-listener-native-flow": "node test/stored-listener-native-flow.mjs",
|
|
51
51
|
"test:native-typed-field-read": "node test/native-typed-field-read.mjs",
|
|
52
|
+
"test:native-tail-conversion-never-allocated": "node test/native-tail-conversion-never-allocated.mjs",
|
|
52
53
|
"test:native-method-overrides": "node test/native-method-overrides.mjs",
|
|
53
54
|
"architecture": "node scripts/architecture.mjs && node scripts/refusal-keys.mjs",
|
|
54
55
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
@@ -78,10 +79,10 @@
|
|
|
78
79
|
"fastify": "^5.0.0",
|
|
79
80
|
"find-my-way": "9.6.0",
|
|
80
81
|
"prettier": "^3.8.3",
|
|
81
|
-
"@geastack/core": "0.1.
|
|
82
|
-
"@geastack/host": "0.1.
|
|
83
|
-
"@geastack/engine": "0.1.
|
|
84
|
-
"@geastack/elements": "0.1.
|
|
82
|
+
"@geastack/core": "0.1.35",
|
|
83
|
+
"@geastack/host": "0.1.12",
|
|
84
|
+
"@geastack/engine": "0.1.11",
|
|
85
|
+
"@geastack/elements": "0.1.4",
|
|
85
86
|
"@geastack/geaos": "0.1.3",
|
|
86
87
|
"@geastack/apple": "0.2.8",
|
|
87
88
|
"@geastack/geatsc-plugin-gea": "0.1.6",
|
|
@@ -75,7 +75,8 @@ inline Value ordinaryToPrimitive(const Value& value, ToPrimitiveHint hint) {
|
|
|
75
75
|
return Value::box(Value::Tag::String, value.functionSourceText());
|
|
76
76
|
const bool present = value.hasProperty(key);
|
|
77
77
|
if (!present && isToString &&
|
|
78
|
-
(value.isDynamicObject() || value.isProxy() || value.isDynamicDictionaryPayload()
|
|
78
|
+
(value.isDynamicObject() || value.isProxy() || value.isDynamicDictionaryPayload() ||
|
|
79
|
+
(value.isNativeFieldPayload() && !value.isArrayPayload()))) {
|
|
79
80
|
const Value tag = value.getProperty(PropertyKey::symbol(wellKnownSymbol(detail::WellKnownSymbol::ToStringTag)));
|
|
80
81
|
const std::string tagText = tag.tag() == Value::Tag::String ? tag.as<std::string>() : std::string("Object");
|
|
81
82
|
return Value::box(Value::Tag::String, std::string("[object ") + tagText + "]");
|
|
@@ -145,6 +146,49 @@ inline std::string dynamicToString(const Value& input) {
|
|
|
145
146
|
return host::detail::toString(primitive);
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
/**
|
|
150
|
+
* ECMA-262 7.1.17 ToString of a string-keyed table (`{ [key: string]: T }`),
|
|
151
|
+
* read off the table itself rather than through a box of it.
|
|
152
|
+
*
|
|
153
|
+
* A table holds only string keys, so it has no `@@toPrimitive` of its own and
|
|
154
|
+
* ToPrimitive(hint string) is OrdinaryToPrimitive (7.1.1.1): `toString`, then
|
|
155
|
+
* `valueOf`, each called when it is callable and answering when it returns a
|
|
156
|
+
* primitive. A table has no prototype of its own -- it is an ordinary object
|
|
157
|
+
* over `Object.prototype` -- so a missing `toString` is
|
|
158
|
+
* `Object.prototype.toString`, whose tag walk (20.1.3.6) answers
|
|
159
|
+
* "[object Object]", and a missing `valueOf` returns the object and is passed.
|
|
160
|
+
*
|
|
161
|
+
* The receiver a stored function is called with is the table as a `Value`:
|
|
162
|
+
* the callee is itself an `any` function whose `this` is dynamic by ABI. A
|
|
163
|
+
* VIEW of another object (`gea::dictionary::aliasOf`) answers with that
|
|
164
|
+
* object's own ToString, `@@toPrimitive` and prototype chain included.
|
|
165
|
+
*
|
|
166
|
+
* A table whose values can hold no callable (`Record<string, number>`) finds
|
|
167
|
+
* no method to call: an own `toString` or `valueOf` key shadows the inherited
|
|
168
|
+
* method with a non-callable, and nothing then yields a primitive.
|
|
169
|
+
*/
|
|
170
|
+
template <typename V>
|
|
171
|
+
inline std::string dictionaryToString(const Ref<Dictionary<V>>& table) {
|
|
172
|
+
if constexpr (std::is_same_v<V, Value>) {
|
|
173
|
+
if (const auto* alias = table->alias()) return dynamicToString(alias->object);
|
|
174
|
+
for (const char* name : {"toString", "valueOf"}) {
|
|
175
|
+
if (!table->has(name)) {
|
|
176
|
+
if (name[0] == 't') return "[object Object]";
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const Value method = table->read(name);
|
|
180
|
+
if (method.tag() != Value::Tag::Function) continue;
|
|
181
|
+
const Value result = method.callWithReceiver(Value::box(Value::Tag::Object, table), {});
|
|
182
|
+
if (isObjectValue(result)) continue;
|
|
183
|
+
if (result.tag() == Value::Tag::Symbol) host::throwRuntimeError("TypeError", "Cannot convert a Symbol value to a string");
|
|
184
|
+
return host::detail::toString(result);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
if (!table->has("toString")) return "[object Object]";
|
|
188
|
+
}
|
|
189
|
+
host::throwRuntimeError("TypeError", "Cannot convert object to primitive value");
|
|
190
|
+
}
|
|
191
|
+
|
|
148
192
|
inline double dynamicToNumber(const Value& input) {
|
|
149
193
|
const Value value = dynamicToPrimitive(input, ToPrimitiveHint::Number);
|
|
150
194
|
switch (value.tag()) {
|
|
@@ -255,6 +299,59 @@ inline Value dynamicArrayPrototypeGet(const PropertyKey& key) {
|
|
|
255
299
|
return Value();
|
|
256
300
|
}
|
|
257
301
|
|
|
302
|
+
/**
|
|
303
|
+
* `String.prototype`'s methods read off a string the program declared `any`
|
|
304
|
+
* (`name.toLowerCase()` after `name = \`${name}\``). Each is the native
|
|
305
|
+
* string function the typed path already calls, reached through the boxed
|
|
306
|
+
* receiver; the receiver is converted with ToString, which for the string
|
|
307
|
+
* primitive these are read off is the string itself. A method not listed
|
|
308
|
+
* reads `undefined`, so calling it is the language's own TypeError rather
|
|
309
|
+
* than an answer this table invented.
|
|
310
|
+
*/
|
|
311
|
+
inline Value dynamicStringPrototypeGet(const PropertyKey& key) {
|
|
312
|
+
if (key.isSymbol()) return Value();
|
|
313
|
+
using Args = gea::Ref<ArrayObject<Value>>;
|
|
314
|
+
using Method = CallableObject<Value(Value, Args)>;
|
|
315
|
+
static const std::map<std::string, Value> methods = [] {
|
|
316
|
+
std::map<std::string, Value> result;
|
|
317
|
+
for (const char* name : {"toLowerCase", "toUpperCase", "toLocaleLowerCase", "toLocaleUpperCase", "trim", "trimStart", "trimEnd",
|
|
318
|
+
"toString", "valueOf", "includes", "startsWith", "endsWith", "indexOf", "slice", "charAt"}) {
|
|
319
|
+
auto callable = Method(+[](void* environment, Value receiver, Args args) -> Value {
|
|
320
|
+
alignas(void*) unsigned char slot[sizeof(void*)];
|
|
321
|
+
const std::string& method = *gea::unpackEnvironment<std::string>(environment, slot);
|
|
322
|
+
if (receiver.tag() == Value::Tag::Null || receiver.tag() == Value::Tag::Undefined)
|
|
323
|
+
host::throwRuntimeError("TypeError", "String.prototype method called on null or undefined");
|
|
324
|
+
const std::string text = dynamicToString(receiver);
|
|
325
|
+
const Value first = args->size() ? args->at(0) : Value();
|
|
326
|
+
const Value second = args->size() > 1 ? args->at(1) : Value();
|
|
327
|
+
const auto string = [](std::string value) { return Value::box(Value::Tag::String, std::move(value)); };
|
|
328
|
+
const auto position = [](const Value& value, double fallback) {
|
|
329
|
+
if (value.tag() == Value::Tag::Undefined) return fallback;
|
|
330
|
+
const double number = dynamicToNumber(value);
|
|
331
|
+
return std::isnan(number) ? 0.0 : std::trunc(number);
|
|
332
|
+
};
|
|
333
|
+
if (method == "toLowerCase" || method == "toLocaleLowerCase") return string(runtime::string::toLowerCase(text));
|
|
334
|
+
if (method == "toUpperCase" || method == "toLocaleUpperCase") return string(runtime::string::toUpperCase(text));
|
|
335
|
+
if (method == "trim") return string(runtime::string::trim(text));
|
|
336
|
+
if (method == "trimStart") return string(runtime::string::trimStart(text));
|
|
337
|
+
if (method == "trimEnd") return string(runtime::string::trimEnd(text));
|
|
338
|
+
if (method == "toString" || method == "valueOf") return string(text);
|
|
339
|
+
if (method == "slice") return string(runtime::string::slice(text, position(first, 0.0), position(second, std::numeric_limits<double>::infinity())));
|
|
340
|
+
if (method == "charAt") return string(runtime::string::charAt(text, position(first, 0.0)));
|
|
341
|
+
const std::string needle = dynamicToString(first);
|
|
342
|
+
if (method == "indexOf") return Value::box(Value::Tag::Number, runtime::string::indexOf(text, needle, position(second, 0.0)));
|
|
343
|
+
if (method == "includes") return Value::box(Value::Tag::Boolean, runtime::string::includes(text, needle, position(second, 0.0)));
|
|
344
|
+
if (method == "startsWith") return Value::box(Value::Tag::Boolean, runtime::string::startsWith(text, needle, position(second, 0.0)));
|
|
345
|
+
return Value::box(Value::Tag::Boolean, runtime::string::endsWith(text, needle, position(second, std::numeric_limits<double>::infinity())));
|
|
346
|
+
}, gea::packEnvironment<std::string>(std::string(name)));
|
|
347
|
+
result.emplace(name, Value::boxMethod<1>(callable));
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
}();
|
|
351
|
+
const auto found = methods.find(key.text());
|
|
352
|
+
return found == methods.end() ? Value() : found->second;
|
|
353
|
+
}
|
|
354
|
+
|
|
258
355
|
// The intrinsic is one ordinary native array with its own method properties.
|
|
259
356
|
// Identity sidecars already carry descriptors on arrays; a new representation
|
|
260
357
|
// or a boxed array would lose that existing native ownership for no reason.
|
|
@@ -356,8 +453,8 @@ inline void Value::freezeIntegrity() const {
|
|
|
356
453
|
return;
|
|
357
454
|
}
|
|
358
455
|
if (tag_ != Tag::Object) return;
|
|
359
|
-
if (metadata_->fields != nullptr) metadata_->fields->freezeIndex(
|
|
360
|
-
if (metadata_->elements != nullptr) metadata_->elements->freeze(
|
|
456
|
+
if (metadata_->fields != nullptr) metadata_->fields->freezeIndex(payload());
|
|
457
|
+
if (metadata_->elements != nullptr) metadata_->elements->freeze(payload());
|
|
361
458
|
detail::expandoFor(expandoAnchor(), true)->freezeIntegrity();
|
|
362
459
|
}
|
|
363
460
|
|
|
@@ -370,7 +467,7 @@ inline bool Value::hasFrozenIntegrity() const {
|
|
|
370
467
|
if (tag_ != Tag::Object) return true;
|
|
371
468
|
const auto expando = detail::expandoFor(expandoAnchor(), false);
|
|
372
469
|
if (!expando || !expando->hasFrozenIntegrity()) return false;
|
|
373
|
-
return metadata_->elements == nullptr || metadata_->elements->frozen(
|
|
470
|
+
return metadata_->elements == nullptr || metadata_->elements->frozen(payload());
|
|
374
471
|
}
|
|
375
472
|
|
|
376
473
|
inline bool Value::isExtensible() const {
|
|
@@ -384,8 +481,8 @@ inline bool Value::isExtensible() const {
|
|
|
384
481
|
return result;
|
|
385
482
|
}
|
|
386
483
|
if (dynamic_) return asDynamicObject()->extensible();
|
|
387
|
-
if (metadata_->fields != nullptr && !metadata_->fields->extensible(
|
|
388
|
-
if (metadata_->elements != nullptr && metadata_->elements->frozen(
|
|
484
|
+
if (metadata_->fields != nullptr && !metadata_->fields->extensible(payload())) return false;
|
|
485
|
+
if (metadata_->elements != nullptr && metadata_->elements->frozen(payload())) return false;
|
|
389
486
|
const auto expando = detail::expandoFor(expandoAnchor(), false);
|
|
390
487
|
return !expando || expando->extensible();
|
|
391
488
|
}
|
|
@@ -428,17 +525,28 @@ inline std::vector<PropertyKey> Value::ownPropertyKeys() const {
|
|
|
428
525
|
keys.push_back(PropertyKey::string("length"));
|
|
429
526
|
return keys;
|
|
430
527
|
}
|
|
431
|
-
|
|
528
|
+
// `Dictionary<Value>` has no `metadata_->fields`, so without this arm a boxed
|
|
529
|
+
// table reported no keys at all: `Object.keys` of a record read back out of a
|
|
530
|
+
// `Map<string, unknown>` came out empty while `ownDescriptor` still answered
|
|
531
|
+
// for every entry.
|
|
532
|
+
if (metadata_->payloadType == detail::payloadTypeTagFor<gea::Ref<gea::Dictionary<gea::Value>>>()) {
|
|
533
|
+
if (const gea::Value* gea_viewed = gea::dictionary::viewedObjectOf(*this)) return gea_viewed->ownPropertyKeys();
|
|
534
|
+
const gea::Ref<gea::Dictionary<gea::Value>>& dictionary = as<gea::Ref<gea::Dictionary<gea::Value>>>();
|
|
535
|
+
if (dictionary) for (const auto& key : dictionary->enumerableKeys()) keys.push_back(PropertyKey::string(key));
|
|
536
|
+
return detail::ordinaryOwnPropertyKeyOrder(std::move(keys));
|
|
537
|
+
}
|
|
538
|
+
if (metadata_->fields) metadata_->fields->ownKeys(payload(), keys);
|
|
432
539
|
if (metadata_->elements) {
|
|
433
|
-
for (std::size_t i = 0; i < metadata_->elements->length(
|
|
540
|
+
for (std::size_t i = 0; i < metadata_->elements->length(payload()); ++i) {
|
|
434
541
|
Value ignored;
|
|
435
|
-
if (metadata_->elements->element(
|
|
542
|
+
if (metadata_->elements->element(payload(), i, ignored)) keys.push_back(PropertyKey::string(std::to_string(i)));
|
|
436
543
|
}
|
|
437
544
|
keys.push_back(PropertyKey::string("length"));
|
|
438
545
|
}
|
|
439
|
-
const
|
|
546
|
+
const gea::Ref<void> anchor = expandoAnchor();
|
|
547
|
+
const auto expando = detail::expandoFor(anchor, false);
|
|
440
548
|
if (expando) for (const auto& key : expando->ownKeys()) keys.push_back(key);
|
|
441
|
-
return detail::
|
|
549
|
+
return detail::nativeOwnKeysInCreationOrder(anchor.get(), std::move(keys));
|
|
442
550
|
}
|
|
443
551
|
|
|
444
552
|
inline bool Value::defineProperty(const PropertyKey& key, const PropertyDescriptor& descriptor) const {
|
|
@@ -493,6 +601,7 @@ inline bool Value::defineProperty(const PropertyKey& key, const PropertyDescript
|
|
|
493
601
|
// through here) silently wrote a key nothing else ever reads: a direct
|
|
494
602
|
// `dictionary->read(key)` afterwards still saw the old table, unmodified.
|
|
495
603
|
if (metadata_->payloadType == detail::payloadTypeTagFor<gea::Ref<gea::Dictionary<gea::Value>>>()) {
|
|
604
|
+
if (const gea::Value* gea_viewed = gea::dictionary::viewedObjectOf(*this)) return gea_viewed->defineProperty(key, descriptor);
|
|
496
605
|
if (key.isSymbol() || descriptor.isAccessor()) return false;
|
|
497
606
|
const gea::Ref<gea::Dictionary<gea::Value>>& dictionary = as<gea::Ref<gea::Dictionary<gea::Value>>>();
|
|
498
607
|
if (!dictionary) return false;
|
|
@@ -507,11 +616,11 @@ inline bool Value::defineProperty(const PropertyKey& key, const PropertyDescript
|
|
|
507
616
|
// payload that states the whole own-field protocol installs this hook, so
|
|
508
617
|
// for every other native the next two branches are unchanged.
|
|
509
618
|
if (metadata_->fields != nullptr && metadata_->fields->matchesField != nullptr &&
|
|
510
|
-
metadata_->fields->matchesField(
|
|
511
|
-
return metadata_->fields->defineField(
|
|
619
|
+
metadata_->fields->matchesField(payload(), key)) {
|
|
620
|
+
return metadata_->fields->defineField(payload(), key, descriptor, isExtensible());
|
|
512
621
|
}
|
|
513
|
-
if (metadata_->fields != nullptr && metadata_->fields->matchesIndex(
|
|
514
|
-
return metadata_->fields->defineIndex(
|
|
622
|
+
if (metadata_->fields != nullptr && metadata_->fields->matchesIndex(payload(), key)) {
|
|
623
|
+
return metadata_->fields->defineIndex(payload(), key, descriptor, isExtensible());
|
|
515
624
|
}
|
|
516
625
|
PropertyDescriptor current;
|
|
517
626
|
if (ownDescriptor(key, current)) {
|
|
@@ -529,10 +638,14 @@ inline bool Value::defineProperty(const PropertyKey& key, const PropertyDescript
|
|
|
529
638
|
if (detail::arrayIndexOfKey(key, index)) {
|
|
530
639
|
if (!descriptor.hasValue || !descriptor.hasWritable || !descriptor.writable || !descriptor.hasEnumerable ||
|
|
531
640
|
!descriptor.enumerable || !descriptor.hasConfigurable || !descriptor.configurable) return false;
|
|
532
|
-
return metadata_->elements->setElement(
|
|
641
|
+
return metadata_->elements->setElement(payload(), index, descriptor.value);
|
|
533
642
|
}
|
|
534
643
|
}
|
|
535
|
-
|
|
644
|
+
const gea::Ref<void> anchor = expandoAnchor();
|
|
645
|
+
if (!detail::expandoFor(anchor, true)->defineOwnProperty(key, descriptor)) return false;
|
|
646
|
+
if (metadata_->fields)
|
|
647
|
+
detail::noteNativeOwnKeyCreated(anchor, key, [&](std::vector<PropertyKey>& keys) { metadata_->fields->ownKeys(payload(), keys); });
|
|
648
|
+
return true;
|
|
536
649
|
}
|
|
537
650
|
|
|
538
651
|
inline bool Value::ownDescriptor(const PropertyKey& key, PropertyDescriptor& out) const {
|
|
@@ -554,6 +667,7 @@ inline bool Value::ownDescriptor(const PropertyKey& key, PropertyDescriptor& out
|
|
|
554
667
|
// have or `Reflect.set`'s existence check (and `for`-`in`/`Object.keys`,
|
|
555
668
|
// which filter through `ownDescriptor`) never see what the table holds.
|
|
556
669
|
if (metadata_->payloadType == detail::payloadTypeTagFor<gea::Ref<gea::Dictionary<gea::Value>>>()) {
|
|
670
|
+
if (const gea::Value* gea_viewed = gea::dictionary::viewedObjectOf(*this)) return gea_viewed->ownDescriptor(key, out);
|
|
557
671
|
if (key.isSymbol()) return false;
|
|
558
672
|
const gea::Ref<gea::Dictionary<gea::Value>>& dictionary = as<gea::Ref<gea::Dictionary<gea::Value>>>();
|
|
559
673
|
if (!dictionary || !dictionary->has(key.text())) return false;
|
|
@@ -562,26 +676,26 @@ inline bool Value::ownDescriptor(const PropertyKey& key, PropertyDescriptor& out
|
|
|
562
676
|
}
|
|
563
677
|
if (tag_ == Tag::String && detail::stringOwnDescriptor(as<std::string>(), key, out)) return true;
|
|
564
678
|
if (metadata_->fields) {
|
|
565
|
-
if (metadata_->fields->ownDescriptor(
|
|
679
|
+
if (metadata_->fields->ownDescriptor(payload(), key, out)) {
|
|
566
680
|
const auto integrity = detail::expandoFor(expandoAnchor(), false);
|
|
567
681
|
if (integrity && integrity->nativeFieldsFrozen()) out.writable = false;
|
|
568
682
|
return true;
|
|
569
683
|
}
|
|
570
|
-
if (metadata_->fields->ownIndexDescriptor(
|
|
571
|
-
if (metadata_->fields->matchesIndex(
|
|
684
|
+
if (metadata_->fields->ownIndexDescriptor(payload(), key, out)) return true;
|
|
685
|
+
if (metadata_->fields->matchesIndex(payload(), key)) return false;
|
|
572
686
|
}
|
|
573
687
|
if (metadata_->elements) {
|
|
574
688
|
const auto integrity = detail::expandoFor(expandoAnchor(), false);
|
|
575
689
|
const bool frozen = integrity && integrity->hasFrozenIntegrity();
|
|
576
690
|
if (!key.isSymbol() && key.text() == "length") {
|
|
577
|
-
out = PropertyDescriptor::assignment(Value::box(Tag::Number, static_cast<double>(metadata_->elements->length(
|
|
691
|
+
out = PropertyDescriptor::assignment(Value::box(Tag::Number, static_cast<double>(metadata_->elements->length(payload()))));
|
|
578
692
|
out.enumerable = out.configurable = false;
|
|
579
693
|
out.writable = !frozen;
|
|
580
694
|
return true;
|
|
581
695
|
}
|
|
582
696
|
std::size_t index = 0;
|
|
583
697
|
Value found;
|
|
584
|
-
if (detail::arrayIndexOfKey(key, index) && metadata_->elements->element(
|
|
698
|
+
if (detail::arrayIndexOfKey(key, index) && metadata_->elements->element(payload(), index, found)) {
|
|
585
699
|
out = PropertyDescriptor::assignment(found);
|
|
586
700
|
if (frozen) out.writable = out.configurable = false;
|
|
587
701
|
return true;
|
|
@@ -668,7 +782,7 @@ inline bool Value::reflectSet(const PropertyKey& key, const Value& value, const
|
|
|
668
782
|
return parent.reflectSet(key, value, receiver);
|
|
669
783
|
}
|
|
670
784
|
if (!exists && metadata_->prototype != nullptr) {
|
|
671
|
-
const auto result = metadata_->prototype->set(
|
|
785
|
+
const auto result = metadata_->prototype->set(payload(), key, value, receiver);
|
|
672
786
|
if (result != detail::NativePrototypeOps::SetResult::Absent) {
|
|
673
787
|
return result == detail::NativePrototypeOps::SetResult::Accepted;
|
|
674
788
|
}
|
|
@@ -757,7 +871,14 @@ inline bool reflectDelete(const T& target, const K& key) {
|
|
|
757
871
|
}
|
|
758
872
|
|
|
759
873
|
inline std::string objectTagText(const char* tag) {
|
|
760
|
-
|
|
874
|
+
// One sized construction instead of `"[object " + tag + "]"`, which builds a
|
|
875
|
+
// temporary from the prefix and then appends twice (three strlen/copies).
|
|
876
|
+
constexpr std::size_t prefix = 8;
|
|
877
|
+
const std::size_t length = std::char_traits<char>::length(tag);
|
|
878
|
+
std::string text(prefix + length + 1, ']');
|
|
879
|
+
std::memcpy(text.data(), "[object ", prefix);
|
|
880
|
+
std::memcpy(text.data() + prefix, tag, length);
|
|
881
|
+
return text;
|
|
761
882
|
}
|
|
762
883
|
|
|
763
884
|
inline std::string objectTagWithOverride(const Value& tag, const char* builtinTag) {
|
|
@@ -830,6 +951,12 @@ inline std::string dynamicIntrinsicObjectTag(const Value& value, const char* bui
|
|
|
830
951
|
}
|
|
831
952
|
|
|
832
953
|
inline std::string objectTag(const Value& value, const char* = "Object", const char* = nullptr) {
|
|
954
|
+
// BSONPERF-objecttag-document: a plain open document (a `Dictionary<Value>` that views nothing) is no Array, Date, RegExp, Error, Map or
|
|
955
|
+
// ArrayBuffer, and its symbol-keyed read is always `undefined` (`getProperty` stores no symbols in it), so its tag is "Object".
|
|
956
|
+
// bson's isDate/isRegExp ask this of every nested document it serializes.
|
|
957
|
+
if (value.tag() == Value::Tag::Object && !value.isProxy() && !value.isDynamicObject() &&
|
|
958
|
+
value.payloadType() == detail::payloadTypeTagFor<gea::Ref<gea::Dictionary<Value>>>() && gea::dictionary::viewedObjectOf(value) == nullptr)
|
|
959
|
+
return objectTagText("Object");
|
|
833
960
|
const char* builtinTag = "Object";
|
|
834
961
|
switch (value.tag()) {
|
|
835
962
|
case Value::Tag::Undefined: return objectTagText("Undefined");
|
|
@@ -852,7 +979,10 @@ inline std::string objectTag(const Value& value, const char* = "Object", const c
|
|
|
852
979
|
else if (value.isMapPayload()) return dynamicIntrinsicObjectTag(value, "Object", "Map");
|
|
853
980
|
else if (host::instanceOfArrayBuffer(value)) return dynamicIntrinsicObjectTag(value, "Object", "ArrayBuffer");
|
|
854
981
|
}
|
|
855
|
-
|
|
982
|
+
// BSONPERF-tag-literal: the @@toStringTag read of a native record or class instance is a remembered miss like any literal-keyed read.
|
|
983
|
+
static const PropertyKey toStringTagKey = PropertyKey::symbol(wellKnownSymbol(detail::WellKnownSymbol::ToStringTag));
|
|
984
|
+
static detail::LiteralReadCache toStringTagCache;
|
|
985
|
+
return objectTagWithOverride(value.getLiteralProperty(toStringTagKey, toStringTagCache), builtinTag);
|
|
856
986
|
}
|
|
857
987
|
|
|
858
988
|
inline std::string objectTag(const FunctionValue& value, const char* builtinTag = "Function", const char* defaultTag = nullptr) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#pragma once
|
|
3
|
+
#ifndef GEA_EVAL_H_INCLUDED
|
|
4
|
+
#define GEA_EVAL_H_INCLUDED
|
|
3
5
|
#include <cctype>
|
|
4
6
|
#include <memory>
|
|
5
7
|
#include <unordered_map>
|
|
@@ -1374,3 +1376,4 @@ class Eval {
|
|
|
1374
1376
|
namespace gea {
|
|
1375
1377
|
inline Value dynamicFunctionPrototypeGet(const PropertyKey& key) { return eval_detail::functionPrototype(key); }
|
|
1376
1378
|
} // namespace gea
|
|
1379
|
+
#endif // GEA_EVAL_H_INCLUDED
|