@geastack/compiler 1.0.33 → 1.0.34
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/README.md +1 -1
- package/dist/cli-coverage.js +2 -4
- package/dist/cli-emit.js +1 -1
- package/dist/cli-module-graph.js +1 -1
- package/dist/cli.js +2 -1
- package/dist/compiler.js +14 -6
- package/dist/conversion/array-view.js +9 -0
- package/dist/conversion/build.js +15 -8
- package/dist/conversion/dictionary-view.js +2 -2
- package/dist/conversion/nodes.d.ts +7 -0
- package/dist/conversion/nodes.js +58 -11
- package/dist/identity/ids.d.ts +4 -0
- package/dist/identity/ids.js +4 -0
- package/dist/ir/build.d.ts +4 -3
- package/dist/ir/build.js +14 -5
- package/dist/ir/call-dispatch.js +67 -7
- package/dist/ir/call-entry.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +4 -0
- package/dist/ir/callable-class-flow.js +123 -1
- package/dist/ir/certify/parallel-region.js +698 -20
- package/dist/ir/certify.d.ts +3 -0
- package/dist/ir/certify.js +44 -9
- package/dist/ir/class-allocation-domain.js +2 -2
- package/dist/ir/class-construction-status.d.ts +10 -0
- package/dist/ir/class-construction-status.js +36 -0
- package/dist/ir/convert-carriers.d.ts +10 -1
- package/dist/ir/convert-carriers.js +18 -1
- package/dist/ir/dynamic-constructor-conversions.js +4 -2
- package/dist/ir/finite-iterator-close.d.ts +14 -0
- package/dist/ir/finite-iterator-close.js +50 -0
- package/dist/ir/host-template-conversions.js +9 -0
- package/dist/ir/lower-allocation.js +1 -1
- package/dist/ir/lower-flow.js +24 -3
- package/dist/ir/lower-operands.js +88 -7
- package/dist/ir/lower-protocol.js +1 -1
- package/dist/ir/lower.js +9 -4
- package/dist/ir/model.d.ts +39 -1
- package/dist/ir/native-accessor-definition.d.ts +3 -2
- package/dist/ir/native-accessor-definition.js +29 -10
- package/dist/ir/native-array-transport.js +2 -2
- package/dist/ir/native-field-view-domains.d.ts +23 -0
- package/dist/ir/native-field-view-domains.js +115 -9
- package/dist/ir/native-field-view-facts.d.ts +46 -2
- package/dist/ir/native-field-view-facts.js +159 -4
- package/dist/ir/native-iterable.d.ts +17 -0
- package/dist/ir/native-iterable.js +72 -0
- package/dist/ir/native-key-query.js +1 -1
- package/dist/ir/operation-conversions.js +15 -3
- package/dist/ir/program-conversions.js +2 -2
- package/dist/ir/publish-native-field-view-facts.js +9 -4
- package/dist/ir/pure-conversion-reuse.d.ts +58 -0
- package/dist/ir/pure-conversion-reuse.js +263 -0
- package/dist/ir/queries.js +1 -0
- package/dist/ir/reflection-demand.js +70 -18
- package/dist/ir/shake.js +2 -2
- package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
- package/dist/ir/unobserved-callable-inputs.js +111 -0
- package/dist/native-signatures.d.ts +1 -1
- package/dist/native-signatures.js +27 -2
- package/dist/plugins/gea/component-classes.d.ts +2 -1
- package/dist/plugins/gea/component-classes.js +3 -3
- package/dist/plugins/gea/contract.d.ts +26 -3
- package/dist/plugins/gea/contract.js +42 -43
- package/dist/plugins/gea/host.d.ts +9 -0
- package/dist/plugins/gea/host.js +25 -4
- package/dist/plugins/gea/plugin.js +12 -6
- package/dist/plugins/gea/producer.d.ts +2 -2
- package/dist/plugins/gea/producer.js +2 -2
- package/dist/plugins/load.js +18 -1
- package/dist/plugins/model.d.ts +5 -0
- package/dist/plugins/native-iterable-providers.d.ts +18 -0
- package/dist/plugins/native-iterable-providers.js +51 -0
- package/dist/project-preparation.d.ts +8 -0
- package/dist/project-preparation.js +49 -7
- package/dist/projection/bindings.d.ts +13 -0
- package/dist/projection/bindings.js +20 -1
- package/dist/projection/classes.d.ts +4 -2
- package/dist/projection/classes.js +12 -5
- package/dist/representation/collections.js +2 -0
- package/dist/representation/derive.js +1 -0
- package/dist/representation/model.d.ts +2 -0
- package/dist/representation/model.js +1 -0
- package/dist/representation/policies.d.ts +2 -0
- package/dist/representation/primitive-domain.d.ts +1 -1
- package/dist/representation/primitive-domain.js +1 -1
- package/dist/representation/unassigned-binding-cells.js +6 -1
- package/dist/representation/union.js +6 -6
- package/dist/semantics/frontend.d.ts +2 -0
- package/dist/semantics/frontend.js +34 -5
- package/dist/semantics/host-methods.js +4 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
- package/dist/semantics/jsx-runtime-provider.js +16 -0
- package/dist/semantics/model/native-iterable.d.ts +14 -0
- package/dist/semantics/model/native-iterable.js +7 -0
- package/dist/semantics/model/operands.d.ts +30 -0
- package/dist/semantics/model/operations.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.js +27 -4
- package/dist/semantics/module-resolution.js +13 -2
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
- package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
- package/dist/semantics/normalize/census.d.ts +3 -0
- package/dist/semantics/normalize/census.js +17 -12
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
- package/dist/semantics/normalize/flow/callable-reach.js +94 -3
- package/dist/semantics/normalize/flow/component-solver.js +144 -55
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
- package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
- package/dist/semantics/normalize/flow/source-value-session.js +596 -57
- package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
- package/dist/semantics/normalize/flow/value-flow.js +84 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
- package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
- package/dist/semantics/normalize/gating.js +5 -1
- package/dist/semantics/normalize/global-host-mutations.js +190 -13
- package/dist/semantics/normalize/identities.js +20 -1
- package/dist/semantics/normalize/local-bindings.js +2 -2
- package/dist/semantics/normalize/parameter-bindings.js +10 -1
- package/dist/semantics/normalize/producer-context.d.ts +5 -0
- package/dist/semantics/normalize/producers/binding-kind.js +2 -0
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
- package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
- package/dist/semantics/normalize/producers/computations.js +36 -5
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
- package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
- package/dist/semantics/normalize/producers/control.js +7 -1
- package/dist/semantics/normalize/producers/destructuring.js +8 -9
- package/dist/semantics/normalize/producers/invocations.js +55 -2
- package/dist/semantics/normalize/producers/properties.d.ts +13 -0
- package/dist/semantics/normalize/producers/properties.js +21 -3
- package/dist/semantics/normalize/producers/references.js +8 -4
- package/dist/semantics/normalize/reachability.d.ts +15 -3
- package/dist/semantics/normalize/reachability.js +128 -20
- package/dist/semantics/normalize/return-bindings.js +3 -3
- package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
- package/dist/semantics/normalize/source-native-iterable.js +74 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +9 -0
- package/dist/semantics/normalize/structural.js +11 -0
- package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
- package/dist/semantics/normalize/unshared-array-result.js +269 -0
- package/dist/semantics/package-sources.js +3 -2
- package/dist/semantics/program.d.ts +8 -0
- package/dist/semantics/program.js +55 -0
- package/dist/semantics/source-transform-exports.d.ts +8 -0
- package/dist/semantics/source-transform-exports.js +145 -0
- package/dist/semantics/source-transform-protocol.d.ts +22 -0
- package/dist/semantics/this-constructor-source-transform.js +19 -1
- package/dist/targets/cpp/class-layout.d.ts +2 -0
- package/dist/targets/cpp/class-layout.js +35 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
- package/dist/targets/cpp/conversions.js +6 -3
- package/dist/targets/cpp/emit-callable.js +73 -7
- package/dist/targets/cpp/emit-context.d.ts +23 -9
- package/dist/targets/cpp/emit-context.js +19 -8
- package/dist/targets/cpp/emit-equality.js +41 -1
- package/dist/targets/cpp/emit-exceptions.js +29 -11
- package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
- package/dist/targets/cpp/emit-iterator.js +33 -9
- package/dist/targets/cpp/emit-live-field-view.js +6 -1
- package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
- package/dist/targets/cpp/emit-narrowing.js +58 -18
- package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
- package/dist/targets/cpp/emit-native-field-view.js +84 -8
- package/dist/targets/cpp/emit-properties.d.ts +1 -0
- package/dist/targets/cpp/emit-properties.js +26 -7
- package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
- package/dist/targets/cpp/emit-record-view.js +14 -2
- package/dist/targets/cpp/emit-tostring.js +23 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +1 -1
- package/dist/targets/cpp/emit.js +99 -13
- package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
- package/dist/targets/cpp/host/emit-host-object.js +28 -2
- package/dist/targets/cpp/host/emit-host-properties.js +9 -1
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +8 -6
- package/dist/targets/cpp/host/host-members.js +2 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +16 -7
- package/dist/targets/cpp/translation-unit.js +30 -16
- package/package.json +8 -7
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_runtime.h +2399 -676
- package/dist/representation/any-null-record-members.d.ts +0 -41
- package/dist/representation/any-null-record-members.js +0 -115
- package/dist/semantics/any-null-member-declarations.d.ts +0 -32
- package/dist/semantics/any-null-member-declarations.js +0 -90
- package/dist/semantics/normalize/fresh-array-result.d.ts +0 -32
- package/dist/semantics/normalize/fresh-array-result.js +0 -125
package/dist/ir/certify.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NativeIterableCertificationInput } from './native-iterable.js';
|
|
1
2
|
import { type NativeCallableReadonlySet } from './native-callable-readonly-set.js';
|
|
2
3
|
import type { NativeCallableDataPlan } from '../representation/native-callable-data-storage.js';
|
|
3
4
|
import { type NativeCallablePrivateSlot } from './native-callable-own-property.js';
|
|
@@ -71,6 +72,8 @@ export interface CapabilityDemand {
|
|
|
71
72
|
readonly detail?: string;
|
|
72
73
|
}
|
|
73
74
|
export interface CertifyInput {
|
|
75
|
+
readonly nativeIterableAuthorities?: NativeIterableCertificationInput['nativeIterableAuthorities'];
|
|
76
|
+
readonly nativeIterableProviders?: NativeIterableCertificationInput['nativeIterableProviders'];
|
|
74
77
|
readonly programConversionRecipes?: readonly ProgramConversionRecipe[];
|
|
75
78
|
readonly representations?: readonly Representation[];
|
|
76
79
|
readonly hosts?: HostSpellings;
|
package/dist/ir/certify.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { finiteIteratorCloseRegionMatches } from './finite-iterator-close.js';
|
|
2
|
+
import { nativeIterableReceiptMatches } from './native-iterable.js';
|
|
3
|
+
import { classConstructionStatusMatches } from './class-construction-status.js';
|
|
1
4
|
import { nativeCallableReadonlySetsOf, nativeCallableReadonlySetMatches } from './native-callable-readonly-set.js';
|
|
2
5
|
import { lexicalReceiverOriginMatches } from './native-logical-receiver-body.js';
|
|
3
6
|
import { constantPropertyKeyTextOf } from './native-property-key-texts.js';
|
|
@@ -59,7 +62,7 @@ import { buildHostMethodAliasIndex } from './host-method-aliases.js';
|
|
|
59
62
|
import { callableOriginsOf } from '../semantics/callable-origins.js';
|
|
60
63
|
import { settledVirtualCallFramesOf } from './virtual-call-frames.js';
|
|
61
64
|
import { nonNormalReceiverProofMatches } from './non-normal-receiver.js';
|
|
62
|
-
import { nativeFieldViewLivePlansOf, nativeFieldViewTargetSetOf, nativeFieldViewDocumentTargetSetOf, nativeFieldViewOpenDocumentRead, nativeFieldViewOpenReadOf, nativeFieldViewCarrierNeedsReceipt, nativeFieldViewOperationNeedsReceipt, nativeFieldViewReadOf, nativeFieldViewWriteOf, nativeFieldViewReadSelectionOf, nativeFieldViewWriteSelectionOf, nativeFieldViewReceiptMatches } from './native-field-view-facts.js';
|
|
65
|
+
import { nativeFieldViewLivePlansOf, nativeFieldViewTargetSetOf, nativeFieldViewDocumentTargetSetOf, nativeFieldViewOpenDocumentRead, nativeFieldViewOpenReadOf, nativeFieldViewOpenWriteOf, nativeFieldViewCarrierNeedsReceipt, nativeFieldViewOperationNeedsReceipt, nativeFieldViewReadOf, nativeFieldViewWriteOf, nativeFieldViewReadSelectionOf, nativeFieldViewWriteSelectionOf, nativeFieldViewReceiptMatches } from './native-field-view-facts.js';
|
|
63
66
|
import { computedPropertyKeyTextsOf } from './typed-property-access.js';
|
|
64
67
|
import { nativeObjectDataSlotAuthorityOf, nativeObjectDataSlotMatches } from './native-object-data-slots.js';
|
|
65
68
|
import { nativeIteratorFieldReadOf, nativeIteratorFieldReadMatches } from './native-iterator-field-views.js';
|
|
@@ -703,6 +706,14 @@ const ownDemandsOf = (operation, ctx) => {
|
|
|
703
706
|
case 'get-iterator':
|
|
704
707
|
case 'iterator-next':
|
|
705
708
|
case 'iterator-close': {
|
|
709
|
+
if (operation.kind === 'get-iterator' && !nativeIterableReceiptMatches(operation, ctx.semanticOperationOf(operation.lineage), ctx))
|
|
710
|
+
return [
|
|
711
|
+
{
|
|
712
|
+
key: 'call-abi:native-iterable-source-proof',
|
|
713
|
+
verdict: 'missing',
|
|
714
|
+
detail: 'native iterator receipt lacks exact independent source, provider and typed cursor authority'
|
|
715
|
+
}
|
|
716
|
+
];
|
|
706
717
|
const sourceIgnores = (functionId) => {
|
|
707
718
|
const variants = [...ctx.bodies.values()].filter((body) => body.sourceOwner === functionId);
|
|
708
719
|
return variants.length > 0 && variants.every(nativeBodyIgnoresLogicalReceiver);
|
|
@@ -735,10 +746,22 @@ const ownDemandsOf = (operation, ctx) => {
|
|
|
735
746
|
: [])
|
|
736
747
|
];
|
|
737
748
|
}
|
|
738
|
-
case 'allocate-constructor':
|
|
749
|
+
case 'allocate-constructor': {
|
|
739
750
|
// Each captured slot crosses a body boundary in its own ownership; the
|
|
740
751
|
// capture path transports the ownerships the manifest lists and no other.
|
|
741
|
-
return
|
|
752
|
+
return [
|
|
753
|
+
...operation.captures.map((capture) => ({ key: `capture:${captureCapabilityOf(capture.representation)}` })),
|
|
754
|
+
...(!classConstructionStatusMatches(operation, ctx.semanticOperationOf(operation.lineage), ctx)
|
|
755
|
+
? [
|
|
756
|
+
{
|
|
757
|
+
key: 'call-abi:class-construction-status',
|
|
758
|
+
verdict: 'missing',
|
|
759
|
+
detail: 'class construct-entry status does not match its exact semantic allocation'
|
|
760
|
+
}
|
|
761
|
+
]
|
|
762
|
+
: [])
|
|
763
|
+
];
|
|
764
|
+
}
|
|
742
765
|
case 'binding-read':
|
|
743
766
|
return ctx.externalBindings.has(operation.declaration) ? [{ key: 'native-boundary:external-binding' }] : [];
|
|
744
767
|
case 'get': {
|
|
@@ -791,7 +814,9 @@ const ownDemandsOf = (operation, ctx) => {
|
|
|
791
814
|
// way: a demand is raised ONLY when the certificate has gone stale
|
|
792
815
|
// against the operation it rides on. A well-formed one asks for nothing
|
|
793
816
|
// new -- the emitter renders it as ordinary constant-key stores, whose
|
|
794
|
-
// storage the receiver's own `:set:` claims already cover
|
|
817
|
+
// storage the receiver's own `:set:` claims already cover and whose
|
|
818
|
+
// value-into-field conversions are the operation's own `field-write`
|
|
819
|
+
// recipes, published for every recipe key (`operation-conversions.ts`).
|
|
795
820
|
const recipe = operation.typedComputedWrite;
|
|
796
821
|
if (recipe === undefined)
|
|
797
822
|
return [];
|
|
@@ -1203,10 +1228,10 @@ const nativeFieldViewDemandsOf = (operation, ctx) => {
|
|
|
1203
1228
|
if (nativeObjectDataSlotMatches(ctx.nativeObjectDataSlots?.get(operation), operation.nativeObjectDataSlot))
|
|
1204
1229
|
return [];
|
|
1205
1230
|
const receipt = operation.kind === 'get' ? operation.nativeFieldViewRead : operation.nativeFieldViewWrite;
|
|
1206
|
-
const
|
|
1231
|
+
const key = constantKeyTextOf(operation, ctx);
|
|
1232
|
+
const required = nativeFieldViewOperationNeedsReceipt(operation, ctx.nativeFieldViewTargets ?? new Set(), ctx.authenticatedHosts, key, ctx.deriver);
|
|
1207
1233
|
if (!required && receipt === undefined)
|
|
1208
1234
|
return [];
|
|
1209
|
-
const key = constantKeyTextOf(operation, ctx);
|
|
1210
1235
|
const semantic = ctx.semanticOperationOf(operation.lineage);
|
|
1211
1236
|
if (required &&
|
|
1212
1237
|
receipt === undefined &&
|
|
@@ -1230,8 +1255,11 @@ const nativeFieldViewDemandsOf = (operation, ctx) => {
|
|
|
1230
1255
|
: key !== null
|
|
1231
1256
|
? nativeFieldViewWriteOf(operation, key, ctx.nativeFieldViews, ctx.conversions)
|
|
1232
1257
|
: authenticDomain
|
|
1233
|
-
? nativeFieldViewWriteSelectionOf(operation, keyDomain, ctx.nativeFieldViews, ctx.conversions)
|
|
1234
|
-
|
|
1258
|
+
? (nativeFieldViewWriteSelectionOf(operation, keyDomain, ctx.nativeFieldViews, ctx.conversions) ??
|
|
1259
|
+
nativeFieldViewOpenWriteOf(operation, ctx.nativeFieldViews, ctx.conversions, keyDomain))
|
|
1260
|
+
: copiedDomain === undefined
|
|
1261
|
+
? nativeFieldViewOpenWriteOf(operation, ctx.nativeFieldViews, ctx.conversions)
|
|
1262
|
+
: null
|
|
1235
1263
|
: null;
|
|
1236
1264
|
if (!nativeFieldViewReceiptMatches(expected, receipt))
|
|
1237
1265
|
return [
|
|
@@ -1681,9 +1709,16 @@ export const certifyIr = (input) => {
|
|
|
1681
1709
|
for (const demand of embeddedNativeBoundaryDemands(representation))
|
|
1682
1710
|
decide(owner, demand, ctx);
|
|
1683
1711
|
}
|
|
1684
|
-
for (const region of body.iteratorCloseRegions ?? [])
|
|
1712
|
+
for (const region of body.iteratorCloseRegions ?? []) {
|
|
1713
|
+
if (!finiteIteratorCloseRegionMatches(region, ctx.semanticOperationOf(region.lineage), ctx.definitionOf, ctx.semanticOperationOf))
|
|
1714
|
+
decide(owner, {
|
|
1715
|
+
key: 'call-abi:finite-iterator-close-state',
|
|
1716
|
+
verdict: 'missing',
|
|
1717
|
+
detail: 'finite iterator step completion lacks exact source close and iterator lineage authority'
|
|
1718
|
+
}, ctx);
|
|
1685
1719
|
for (const demand of nativeIteratorFieldDemandsOf(region.iterator, 'return', region.nativeMethodRead, ctx))
|
|
1686
1720
|
decide(owner, demand, ctx);
|
|
1721
|
+
}
|
|
1687
1722
|
for (const blockId of body.blockOrder) {
|
|
1688
1723
|
const block = body.blocks.get(blockId);
|
|
1689
1724
|
if (!block)
|
|
@@ -24,7 +24,7 @@ export const classAllocationDomainOf = (bodies, classes, placements, deriver, fl
|
|
|
24
24
|
// An unknown observer can recover every constructor along an instance's
|
|
25
25
|
// prototype chain, including a bodyless base declaration's constructor --
|
|
26
26
|
// but only from an instance that exists. A value it receives whose type is
|
|
27
|
-
// a class names that class's family, not an allocation of it:
|
|
27
|
+
// a class names that class's family, not an allocation of it: an HTTP framework's `Context`
|
|
28
28
|
// reaches an `executionCtx?: FetchEventLike` that nothing ever constructs,
|
|
29
29
|
// and treating the type as an instance made the abstract class allocatable
|
|
30
30
|
// and its bodyless `respondWith` an evaluated read. So a received class type
|
|
@@ -69,7 +69,7 @@ export const classAllocationDomainOf = (bodies, classes, placements, deriver, fl
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
// A class's own declared data field read as the `any` it is declared --
|
|
72
|
-
//
|
|
72
|
+
// an HTTP framework's `const { bodyCache } = this`, a `Partial<Body>` whose `json: any`
|
|
73
73
|
// makes the field dynamic -- is a load from the instance's slot. It hands
|
|
74
74
|
// no observer the instance: the Value it yields was exposed when stored.
|
|
75
75
|
let definitions = new Map();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClassLayout } from '../projection/classes.js';
|
|
2
|
+
import type { RepresentationDeriver } from '../representation/derive.js';
|
|
3
|
+
import type { DeclarationId } from '../identity/ids.js';
|
|
4
|
+
import type { SemanticOperation } from '../semantics/model/operations.js';
|
|
5
|
+
import type { AllocateConstructorOperation } from './model.js';
|
|
6
|
+
/** Lowering may omit a construct entry only on the exact semantic allocation that proved it unreachable. */
|
|
7
|
+
export declare const classConstructionStatusMatches: (operation: AllocateConstructorOperation, semantic: SemanticOperation | null, context?: {
|
|
8
|
+
readonly classes: ReadonlyMap<DeclarationId, ClassLayout>;
|
|
9
|
+
readonly deriver: Pick<RepresentationDeriver, "derive">;
|
|
10
|
+
}) => boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Lowering may omit a construct entry only on the exact semantic allocation that proved it unreachable. */
|
|
2
|
+
export const classConstructionStatusMatches = (operation, semantic, context) => {
|
|
3
|
+
// A static block has no ordinary receiver ABI. Its existing synthesized
|
|
4
|
+
// class value must consume the same projected construction status, and its
|
|
5
|
+
// semantic receiver carrier authenticates which class owns that status.
|
|
6
|
+
if (semantic?.family === 'reference' && semantic.form === 'this') {
|
|
7
|
+
const receiver = semantic.operands.find((operand) => operand.role === 'static-class-receiver' && operand.source.kind === 'receiver');
|
|
8
|
+
if (!receiver || !context)
|
|
9
|
+
return false;
|
|
10
|
+
const carrier = context.deriver.derive(receiver.type);
|
|
11
|
+
const result = operation.result.representation;
|
|
12
|
+
if (carrier.kind !== 'constructor-family' ||
|
|
13
|
+
carrier.members.length !== 1 ||
|
|
14
|
+
carrier.members[0] !== operation.declaration ||
|
|
15
|
+
result.kind !== 'constructor-family' ||
|
|
16
|
+
result.members[0] !== operation.declaration)
|
|
17
|
+
return false;
|
|
18
|
+
const layout = context.classes.get(operation.declaration);
|
|
19
|
+
return layout !== undefined && (operation.constructionDeferred === true) === (layout.constructionDeferred === true);
|
|
20
|
+
}
|
|
21
|
+
if (semantic?.family === 'allocation' && semantic.allocated === 'class-constructor-object') {
|
|
22
|
+
if (!context)
|
|
23
|
+
return false;
|
|
24
|
+
// Derivation already selects the physical generic copy. The semantic
|
|
25
|
+
// declaration spelling may name its unspecialized layout instead.
|
|
26
|
+
const carrier = context.deriver.derive(semantic.shape);
|
|
27
|
+
const result = operation.result.representation;
|
|
28
|
+
if (carrier.kind !== 'constructor-family' ||
|
|
29
|
+
carrier.members[0] !== operation.declaration ||
|
|
30
|
+
result.kind !== 'constructor-family' ||
|
|
31
|
+
result.members[0] !== operation.declaration)
|
|
32
|
+
return false;
|
|
33
|
+
return (operation.constructionDeferred === true) === (semantic.classConstructionDeferred === true);
|
|
34
|
+
}
|
|
35
|
+
return operation.constructionDeferred !== true;
|
|
36
|
+
};
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { Representation } from '../representation/model.js';
|
|
2
2
|
import type { ConvertOperation } from './model.js';
|
|
3
|
-
/**
|
|
3
|
+
/** The table pair an unshared-dictionary rebuild copies between: the source table and the slot's own table, or its optional's payload. */
|
|
4
|
+
export declare const unsharedDictionaryPairOf: (source: Representation, target: Representation) => {
|
|
5
|
+
readonly source: Extract<Representation, {
|
|
6
|
+
kind: "dictionary";
|
|
7
|
+
}>;
|
|
8
|
+
readonly target: Extract<Representation, {
|
|
9
|
+
kind: "dictionary";
|
|
10
|
+
}>;
|
|
11
|
+
} | null;
|
|
12
|
+
/** A fresh array or table rebuild cites its element (entry) conversion, including after await. */
|
|
4
13
|
export declare const convertCarriersOf: (operation: Pick<ConvertOperation, "source" | "result" | "rebuild">) => {
|
|
5
14
|
readonly source: Representation;
|
|
6
15
|
readonly target: Representation;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The table pair an unshared-dictionary rebuild copies between: the source table and the slot's own table, or its optional's payload. */
|
|
2
|
+
export const unsharedDictionaryPairOf = (source, target) => {
|
|
3
|
+
const table = target.kind === 'optional' ? target.payload : target;
|
|
4
|
+
if (source.kind !== 'dictionary' || table.kind !== 'dictionary')
|
|
5
|
+
return null;
|
|
6
|
+
if (source.key !== 'string' || table.key !== 'string')
|
|
7
|
+
return null;
|
|
8
|
+
if (source.ownership !== 'shared-refcount' || table.ownership !== 'shared-refcount')
|
|
9
|
+
return null;
|
|
10
|
+
if (source.recursive !== undefined || table.recursive !== undefined)
|
|
11
|
+
return null;
|
|
12
|
+
return { source, target: table };
|
|
13
|
+
};
|
|
14
|
+
/** A fresh array or table rebuild cites its element (entry) conversion, including after await. */
|
|
2
15
|
export const convertCarriersOf = (operation) => {
|
|
3
16
|
let source = operation.source.representation;
|
|
4
17
|
let target = operation.result.representation;
|
|
18
|
+
if (operation.rebuild === 'unshared-dictionary') {
|
|
19
|
+
const pair = unsharedDictionaryPairOf(source, target);
|
|
20
|
+
return pair === null ? null : { source: pair.source.value, target: pair.target.value };
|
|
21
|
+
}
|
|
5
22
|
if (operation.rebuild !== 'unshared-array')
|
|
6
23
|
return { source, target };
|
|
7
24
|
while (source.kind === 'promise' && target.kind === 'promise') {
|
|
@@ -42,9 +42,11 @@ export const dynamicConstructorConversionsOf = (receiver, result, classes) => {
|
|
|
42
42
|
conversions.push({ role: 'construct-argument', source: packed.value.element, target: parameter.value });
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
+
// A frame shorter than the candidate's convention omits this
|
|
46
|
+
// parameter: the candidate receives `undefined` there, exactly as an
|
|
47
|
+
// ordinary call's omitted argument does.
|
|
45
48
|
const source = target.parameters[position];
|
|
46
|
-
|
|
47
|
-
conversions.push({ role: 'construct-argument', source: source.value, target: parameter.value });
|
|
49
|
+
conversions.push({ role: 'construct-argument', source: source?.value ?? { kind: 'undefined' }, target: parameter.value });
|
|
48
50
|
});
|
|
49
51
|
conversions.push({ role: 'construct-result', source: instance, target: target.result });
|
|
50
52
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IrValueId, SemanticResultId } from '../identity/ids.js';
|
|
2
|
+
import type { SemanticOperation } from '../semantics/model/operations.js';
|
|
3
|
+
import type { IrIteratorCloseRegion, IrOperation } from './model.js';
|
|
4
|
+
/** Finite IteratorBindingInitialization marks its iterator record done when
|
|
5
|
+
* IteratorStepValue abruptly completes. Defaults/assignment run afterwards
|
|
6
|
+
* and retain ordinary close-on-throw. This obligation is independent of IR.
|
|
7
|
+
*
|
|
8
|
+
* A source that is already a native cursor (`const [a] = gen()`) has no
|
|
9
|
+
* GetIterator to lower: `lowerArrayPatternSource` registers the pattern's
|
|
10
|
+
* iterator-record as the source value itself, so that value is defined under
|
|
11
|
+
* the source's lineage. The record's own source step must then name exactly
|
|
12
|
+
* that value as its `base`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const finiteIteratorCloseRegionMatches: (region: IrIteratorCloseRegion, semantic: SemanticOperation | null, definitionOf: (value: IrValueId) => IrOperation | null, operationOfResult: (result: SemanticResultId) => SemanticOperation | null) => boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { resultOfIrOperation } from './queries.js';
|
|
2
|
+
/** Finite IteratorBindingInitialization marks its iterator record done when
|
|
3
|
+
* IteratorStepValue abruptly completes. Defaults/assignment run afterwards
|
|
4
|
+
* and retain ordinary close-on-throw. This obligation is independent of IR.
|
|
5
|
+
*
|
|
6
|
+
* A source that is already a native cursor (`const [a] = gen()`) has no
|
|
7
|
+
* GetIterator to lower: `lowerArrayPatternSource` registers the pattern's
|
|
8
|
+
* iterator-record as the source value itself, so that value is defined under
|
|
9
|
+
* the source's lineage. The record's own source step must then name exactly
|
|
10
|
+
* that value as its `base`.
|
|
11
|
+
*/
|
|
12
|
+
export const finiteIteratorCloseRegionMatches = (region, semantic, definitionOf, operationOfResult) => {
|
|
13
|
+
const finite = semantic?.family === 'destructuring' && semantic.form === 'array-pattern-close';
|
|
14
|
+
if (!finite)
|
|
15
|
+
return region.completeOnStepAbrupt !== true;
|
|
16
|
+
if (region.completeOnStepAbrupt !== true || !region.onlyIfOpen || region.bodyEntry !== null || region.dismissTargets.length !== 0)
|
|
17
|
+
return false;
|
|
18
|
+
if (semantic.id !== region.loop)
|
|
19
|
+
return false;
|
|
20
|
+
const source = semantic.operands.find((operand) => operand.role === 'iterator' && operand.ordinal === 0);
|
|
21
|
+
if (source?.source.kind !== 'result')
|
|
22
|
+
return false;
|
|
23
|
+
const record = source.source.result;
|
|
24
|
+
const definition = definitionOf(region.iterator.value);
|
|
25
|
+
if (!definition || resultOfIrOperation(definition)?.id !== region.iterator.value)
|
|
26
|
+
return false;
|
|
27
|
+
if (definition.lineage === record)
|
|
28
|
+
return true;
|
|
29
|
+
if (region.iterator.representation.kind !== 'iterator')
|
|
30
|
+
return false;
|
|
31
|
+
const step = operationOfResult(record);
|
|
32
|
+
if (step?.family !== 'destructuring' || step.form !== 'array-pattern')
|
|
33
|
+
return false;
|
|
34
|
+
const base = step.operands.find((operand) => operand.role === 'base');
|
|
35
|
+
if (base?.source.kind !== 'result')
|
|
36
|
+
return false;
|
|
37
|
+
// A defaulted parameter pattern (`function f([,] = it)`) reads its binding,
|
|
38
|
+
// whose value is exactly its initializer -- the defaulted value the phi joins.
|
|
39
|
+
let named = base.source.result;
|
|
40
|
+
for (let hops = 0; named !== definition.lineage; hops += 1) {
|
|
41
|
+
const binding = operationOfResult(named);
|
|
42
|
+
if (hops === 8 || binding?.family !== 'binding')
|
|
43
|
+
return false;
|
|
44
|
+
const initializer = binding.operands.find((operand) => operand.role === 'initializer');
|
|
45
|
+
if (initializer?.source.kind !== 'result')
|
|
46
|
+
return false;
|
|
47
|
+
named = initializer.source.result;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
@@ -88,6 +88,15 @@ export const hostTemplateConversionInputsOf = (operation, definitionOf, deriver,
|
|
|
88
88
|
if (callback?.kind === 'function-value-dispatch' && callback.abi.receiver === null && callback.abi.parameters[0])
|
|
89
89
|
add('prototype-callback', element, callback.abi.parameters[0].value);
|
|
90
90
|
}
|
|
91
|
+
// SortCompare hands the comparator two elements; the emitter converts
|
|
92
|
+
// each into its parameter's carrier (`sortText`), so both pairs are
|
|
93
|
+
// this call's own certified conversions.
|
|
94
|
+
if (member === 'sort') {
|
|
95
|
+
const comparator = operation.arguments[0]?.representation;
|
|
96
|
+
if (comparator?.kind === 'function-value-dispatch' && comparator.abi.receiver === null)
|
|
97
|
+
for (const parameter of comparator.abi.parameters.slice(0, 2))
|
|
98
|
+
add('prototype-callback', element, parameter.value);
|
|
99
|
+
}
|
|
91
100
|
if (result && ['find', 'findLast', 'at', 'pop', 'shift'].includes(member))
|
|
92
101
|
add('prototype-result', { kind: 'optional', payload: element, absence: 'undefined' }, result);
|
|
93
102
|
if (member === 'filter' && result?.kind === 'array-object')
|
|
@@ -317,7 +317,7 @@ export const lowerAllocation = (ctx, block, operation) => {
|
|
|
317
317
|
const constructed = representation.kind === 'constructor-family' && representation.members[0] !== undefined
|
|
318
318
|
? representation.members[0]
|
|
319
319
|
: shape.declaration;
|
|
320
|
-
registerResult(ctx, operation, ctx.builder.allocateConstructor(block, lineage, constructed, captures, representation, heritage));
|
|
320
|
+
registerResult(ctx, operation, ctx.builder.allocateConstructor(block, lineage, constructed, captures, representation, heritage, operation.classConstructionDeferred ? true : undefined));
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
323
|
case 'function-object': {
|
package/dist/ir/lower-flow.js
CHANGED
|
@@ -62,6 +62,12 @@ export const createFlowController = (deps) => {
|
|
|
62
62
|
// traceable to the semantic decision that required it.
|
|
63
63
|
builder.jump(arm, guard, join);
|
|
64
64
|
};
|
|
65
|
+
const requireLoopHeader = (loop) => {
|
|
66
|
+
const header = loopCache.get(loop)?.header;
|
|
67
|
+
if (header === undefined)
|
|
68
|
+
throw new IrLoweringBlockedError('a loop test branched before its loop header was opened');
|
|
69
|
+
return header;
|
|
70
|
+
};
|
|
65
71
|
const ensureGuardBlocks = (guard, predicate = membership.predicateOf(guard)) => {
|
|
66
72
|
const cached = guardCache.get(guard);
|
|
67
73
|
if (cached)
|
|
@@ -78,8 +84,13 @@ export const createFlowController = (deps) => {
|
|
|
78
84
|
const arms = membership.armsOf(guard);
|
|
79
85
|
// An arm nothing ever runs in would otherwise seal with no terminator: it
|
|
80
86
|
// is dead as far as this owner's operations go, so it heads straight to
|
|
81
|
-
// whichever join the live arm eventually creates
|
|
82
|
-
|
|
87
|
+
// whichever join the live arm eventually creates -- except a loop test's
|
|
88
|
+
// truthy arm, which is the body. An empty body is still an iteration: its
|
|
89
|
+
// end is the back edge, never the exit, or the loop runs its test once.
|
|
90
|
+
const loop = membership.loopOfGuard(guard);
|
|
91
|
+
if (!arms.hasTruthy && loop !== null)
|
|
92
|
+
builder.jump(armTrue, guard, requireLoopHeader(loop));
|
|
93
|
+
else if (!arms.hasTruthy)
|
|
83
94
|
sendArmToJoin(guard, info, armTrue, 'truthy');
|
|
84
95
|
if (!arms.hasFalsy)
|
|
85
96
|
sendArmToJoin(guard, info, armFalse, 'falsy');
|
|
@@ -343,8 +354,18 @@ export const createFlowController = (deps) => {
|
|
|
343
354
|
// when it failed, and its taken arm writes the back edge as that arm
|
|
344
355
|
// closes -- so leaving such a loop is nothing more than closing this
|
|
345
356
|
// frame.
|
|
346
|
-
|
|
357
|
+
//
|
|
358
|
+
// Unless no operation ever ran in either arm: an empty body
|
|
359
|
+
// (`while (!it.next().done) {}`) asks for no arm scope, so nothing built
|
|
360
|
+
// the test's branch, and the code after the loop was appended to the
|
|
361
|
+
// header after one evaluation of the test. The branch is built here
|
|
362
|
+
// instead, where the test finished, and control leaves through its exit.
|
|
363
|
+
const guard = membership.guardOfLoop(frame.loop);
|
|
364
|
+
if (guard !== null) {
|
|
365
|
+
if (!guardCache.has(guard) && !isTerminated())
|
|
366
|
+
leaveInto(ensureGuardBlocks(guard).joinBlock);
|
|
347
367
|
return;
|
|
368
|
+
}
|
|
348
369
|
// A loop with no test has neither. Without the back edge below, the body
|
|
349
370
|
// of `while (true)` ran exactly once and fell through to whatever came
|
|
350
371
|
// after it -- an ordinary construct compiled into something that is not
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { unsharedDictionaryPairOf } from './convert-carriers.js';
|
|
1
2
|
import { operationOfResult } from '../identity/ids.js';
|
|
2
3
|
import { exactArmIndexOf } from '../conversion/nodes.js';
|
|
3
4
|
import { conversionRequiresSourceGuard } from '../conversion/algebra.js';
|
|
5
|
+
import { recipeIsMaterializableWithoutPriorSourceGuard } from '../conversion/recipe-closure.js';
|
|
4
6
|
import { SIBLING_CLASS_ARGUMENT } from '../conversion/sibling-class.js';
|
|
5
7
|
import { nativeCallableSourceOf } from './native-callable-argument.js';
|
|
6
8
|
import { nativeObjectSampleEntryOf } from './native-object-sample.js';
|
|
@@ -113,7 +115,7 @@ export const resolveRequiredOperand = (ctx, block, lineage, operand) => {
|
|
|
113
115
|
`"${representationKey(representation)}" rather than one exact constructor-family`);
|
|
114
116
|
}
|
|
115
117
|
return {
|
|
116
|
-
value: ctx.builder.allocateConstructor(block, lineage, declaration, [], representation),
|
|
118
|
+
value: ctx.builder.allocateConstructor(block, lineage, declaration, [], representation, undefined, ctx.program.classes.get(declaration)?.constructionDeferred ? true : undefined),
|
|
117
119
|
representation
|
|
118
120
|
};
|
|
119
121
|
}
|
|
@@ -301,10 +303,12 @@ export const enter = (ctx, block, lineage, operation, operand, resolved) => {
|
|
|
301
303
|
nativeBaseViewEntry(ctx, block, lineage, operand, resolved, answer.representation) ??
|
|
302
304
|
unproven ??
|
|
303
305
|
assertedUnionEntry(ctx, block, lineage, operation, operand, resolved, answer.representation) ??
|
|
306
|
+
unsharedFreshTableEntry(ctx, block, lineage, operand, resolved, answer.representation) ??
|
|
304
307
|
convertTo(ctx, block, lineage, resolved, answer.representation) ??
|
|
305
308
|
familyMemberEntry(ctx, block, lineage, operation, operand, resolved, answer.representation) ??
|
|
306
309
|
assertedArmEntry(ctx, block, lineage, operand, resolved, answer.representation) ??
|
|
307
310
|
freshIntrinsicArrayEntry(ctx, block, lineage, operand, resolved, answer.representation) ??
|
|
311
|
+
unsharedOperandArrayEntry(ctx, block, lineage, operand, resolved, answer.representation) ??
|
|
308
312
|
assertedViewEntry(ctx, block, lineage, operand, resolved, answer.representation);
|
|
309
313
|
if (entered !== null)
|
|
310
314
|
return entered;
|
|
@@ -803,6 +807,31 @@ const assertedViewEntry = (ctx, block, lineage, operand, resolved, slot) => {
|
|
|
803
807
|
traceSpeculativeLoad(lineage, 'asserted-view', node, value);
|
|
804
808
|
return { value, representation: slot };
|
|
805
809
|
};
|
|
810
|
+
/**
|
|
811
|
+
* A fresh local table stored as its last use (`SemanticOperand.
|
|
812
|
+
* unsharedFreshTable`) into a slot of another entry carrier, where no
|
|
813
|
+
* ordinary conversion holds the pair: rebuilt once, entry by entry, at the
|
|
814
|
+
* slot's entry carrier (`ConvertOperation.rebuild`'s `unshared-dictionary`).
|
|
815
|
+
* Three's OutputPass stores its `{ [name: string]: string }` defines into
|
|
816
|
+
* `material.defines`, a table three reads and writes as `any` values; the
|
|
817
|
+
* read-only view the pair otherwise offers is refused because the slot IS
|
|
818
|
+
* written, and the local is never read again, so the copy is unobservable.
|
|
819
|
+
* An entry with no unguarded conversion keeps the store refused.
|
|
820
|
+
*/
|
|
821
|
+
const unsharedFreshTableEntry = (ctx, block, lineage, operand, resolved, slot) => {
|
|
822
|
+
if (operand.unsharedFreshTable !== true)
|
|
823
|
+
return null;
|
|
824
|
+
const pair = unsharedDictionaryPairOf(resolved.representation, slot);
|
|
825
|
+
if (pair === null)
|
|
826
|
+
return null;
|
|
827
|
+
const ordinary = ctx.program.conversions.nodeFor(resolved.representation, slot);
|
|
828
|
+
if (ordinary.capability.kind !== 'never' && !conversionRequiresSourceGuard(ordinary.capability, ctx.program.conversions.nodeById))
|
|
829
|
+
return null;
|
|
830
|
+
const entry = ctx.program.conversions.nodeFor(pair.source.value, pair.target.value);
|
|
831
|
+
if (!recipeIsMaterializableWithoutPriorSourceGuard(entry, ctx.program.conversions.nodeById))
|
|
832
|
+
return null;
|
|
833
|
+
return { value: ctx.builder.convert(block, lineage, entry.id, resolved, slot, 'unshared-dictionary'), representation: slot };
|
|
834
|
+
};
|
|
806
835
|
/**
|
|
807
836
|
* The array a native array's own `map`/`filter`/`slice`/... call just
|
|
808
837
|
* allocated (`InvocationOperation.freshIntrinsicArrayResult`), entering a
|
|
@@ -822,16 +851,68 @@ const freshIntrinsicArrayEntry = (ctx, block, lineage, operand, resolved, slot)
|
|
|
822
851
|
if (operand.source.kind !== 'result')
|
|
823
852
|
return null;
|
|
824
853
|
const producer = ctx.graph.operations.get(operationOfResult(operand.source.result));
|
|
825
|
-
if (producer?.family !== 'invocation'
|
|
826
|
-
return null;
|
|
827
|
-
const receiver = operandOf(producer, 'receiver', 0);
|
|
828
|
-
const held = receiver?.source.kind === 'result' ? ctx.plan.selected.get(receiver.source.result) : undefined;
|
|
829
|
-
if (held?.kind !== 'array-object' || held.extension !== null)
|
|
854
|
+
if (producer?.family !== 'invocation')
|
|
830
855
|
return null;
|
|
856
|
+
// `Array.from`/`Array.of` answer a fresh array off the intrinsic constructor
|
|
857
|
+
// itself, whose elements the program's own mapper produced: consumed here,
|
|
858
|
+
// so each element is moved into its conversion (`ConvertOperation.releasesSource`).
|
|
859
|
+
const factory = producer.freshIntrinsicArrayFactory === true;
|
|
860
|
+
if (!factory) {
|
|
861
|
+
if (producer.freshIntrinsicArrayResult !== true)
|
|
862
|
+
return null;
|
|
863
|
+
const receiver = operandOf(producer, 'receiver', 0);
|
|
864
|
+
const held = receiver?.source.kind === 'result' ? ctx.plan.selected.get(receiver.source.result) : undefined;
|
|
865
|
+
if (held?.kind !== 'array-object' || held.extension !== null)
|
|
866
|
+
return null;
|
|
867
|
+
}
|
|
831
868
|
const element = ctx.program.conversions.nodeFor(source.element, slot.element);
|
|
832
869
|
if (element.capability.kind === 'never')
|
|
833
870
|
return null;
|
|
834
|
-
return {
|
|
871
|
+
return {
|
|
872
|
+
value: ctx.builder.convert(block, lineage, element.id, resolved, slot, 'unshared-array', undefined, undefined, factory ? true : undefined),
|
|
873
|
+
representation: slot
|
|
874
|
+
};
|
|
875
|
+
};
|
|
876
|
+
/**
|
|
877
|
+
* An array local no other holder can observe past this consumer, entering a
|
|
878
|
+
* slot of another element carrier: rebuilt once at the slot's element. Either
|
|
879
|
+
* returned as its last use (`SemanticOperand.unsharedFreshArray`), when the
|
|
880
|
+
* local dies here and its elements are moved out, or handed to a formal that
|
|
881
|
+
* only reads it (`SemanticOperand.readOnlyArrayArgument`), when the caller's
|
|
882
|
+
* array is left intact. Asked only after the ordinary pair -- a live native
|
|
883
|
+
* array view, when one exists, keeps the array's identity and is always
|
|
884
|
+
* preferred.
|
|
885
|
+
*
|
|
886
|
+
* Unlike a fresh call result, the local's ELEMENTS may have other holders,
|
|
887
|
+
* so each element must cross by identity: a conversion that allocates would
|
|
888
|
+
* hand the consumer copies a write through another holder never reaches. And
|
|
889
|
+
* no element may be narrowed by a check the program never wrote, which a
|
|
890
|
+
* read through the original array would not have performed.
|
|
891
|
+
*/
|
|
892
|
+
const unsharedOperandArrayEntry = (ctx, block, lineage, operand, resolved, slot) => {
|
|
893
|
+
const consumed = operand.unsharedFreshArray === true;
|
|
894
|
+
if (!consumed && operand.readOnlyArrayArgument !== true)
|
|
895
|
+
return null;
|
|
896
|
+
const source = resolved.representation;
|
|
897
|
+
if (source.kind !== 'array-object' || slot.kind !== 'array-object')
|
|
898
|
+
return null;
|
|
899
|
+
if (source.ownership !== slot.ownership || source.extension !== null || slot.extension !== null)
|
|
900
|
+
return null;
|
|
901
|
+
const element = ctx.program.conversions.nodeFor(source.element, slot.element);
|
|
902
|
+
if (!elementCrossesByIdentity(element, ctx.program.conversions.nodeById))
|
|
903
|
+
return null;
|
|
904
|
+
return {
|
|
905
|
+
value: ctx.builder.convert(block, lineage, element.id, resolved, slot, 'unshared-array', undefined, undefined, consumed ? true : undefined),
|
|
906
|
+
representation: slot
|
|
907
|
+
};
|
|
908
|
+
};
|
|
909
|
+
const elementCrossesByIdentity = (element, resolve) => {
|
|
910
|
+
const capability = element.capability;
|
|
911
|
+
if (capability.kind === 'identity')
|
|
912
|
+
return true;
|
|
913
|
+
if (capability.kind !== 'atom' && capability.kind !== 'static')
|
|
914
|
+
return false;
|
|
915
|
+
return !capability.materializer.allocates && recipeIsMaterializableWithoutPriorSourceGuard(element, resolve);
|
|
835
916
|
};
|
|
836
917
|
/**
|
|
837
918
|
* A receiver read as the native collection its class extends, for a member
|
|
@@ -82,7 +82,7 @@ export const lowerProtocol = (ctx, block, operation) => {
|
|
|
82
82
|
// dynamic call needed" (see build.ts).
|
|
83
83
|
const method = resolveOptionalOperand(ctx, block, lineage, operandOf(operation, 'method'));
|
|
84
84
|
const representation = requireResultRepresentation(ctx, operation, 'iterator-record', 'a get-iterator step');
|
|
85
|
-
registerResult(ctx, operation, ctx.builder.getIterator(block, lineage, operation.protocol, target, method, representation));
|
|
85
|
+
registerResult(ctx, operation, ctx.builder.getIterator(block, lineage, operation.protocol, target, method, representation, operation.nativeIterable));
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
case 'next': {
|
package/dist/ir/lower.js
CHANGED
|
@@ -596,7 +596,7 @@ const lowerClassLifecycle = (ctx, block, operation) => {
|
|
|
596
596
|
lowerPrototypeReparenting(ctx, block, operation);
|
|
597
597
|
return;
|
|
598
598
|
}
|
|
599
|
-
if (operation.event !== 'define-field' || operation.placement !== 'static')
|
|
599
|
+
if (operation.event !== 'run-static-block' && (operation.event !== 'define-field' || operation.placement !== 'static'))
|
|
600
600
|
return;
|
|
601
601
|
const initializerOperand = operandOf(operation, 'initializer');
|
|
602
602
|
if (!initializerOperand || initializerOperand.source.kind !== 'result')
|
|
@@ -623,7 +623,11 @@ const lowerClassLifecycle = (ctx, block, operation) => {
|
|
|
623
623
|
source: { kind: 'result', result: constructorValue.id },
|
|
624
624
|
type: constructorAllocation.shape
|
|
625
625
|
});
|
|
626
|
+
if (operation.event === 'run-static-block' && abi.result.kind !== 'void')
|
|
627
|
+
throw new IrLoweringBlockedError('a static block must publish its actual void callable convention');
|
|
626
628
|
const result = ctx.builder.call(block, lineage, callee, receiver, [], abi.result);
|
|
629
|
+
if (operation.event === 'run-static-block')
|
|
630
|
+
return;
|
|
627
631
|
if (result === null) {
|
|
628
632
|
throw new IrLoweringBlockedError(`a static field initializer for ${operation.classDeclaration} produces no value to store`);
|
|
629
633
|
}
|
|
@@ -1086,9 +1090,10 @@ const iteratorCloseRegionsOf = (graph, membership, order, blockStarts, flow, ctx
|
|
|
1086
1090
|
blocks: blockOrder.slice(first, last + 1),
|
|
1087
1091
|
dismissTargets: [],
|
|
1088
1092
|
onlyIfOpen: true,
|
|
1089
|
-
//
|
|
1090
|
-
//
|
|
1091
|
-
//
|
|
1093
|
+
// Step/value failure completes the record; a later default/assignment
|
|
1094
|
+
// failure still closes its open iterator. Certification authenticates
|
|
1095
|
+
// this finite-pattern obligation independently against the source close.
|
|
1096
|
+
completeOnStepAbrupt: true,
|
|
1092
1097
|
bodyEntry: null
|
|
1093
1098
|
});
|
|
1094
1099
|
}
|