@geastack/compiler 1.0.63 → 1.0.64
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 +14 -5
- package/dist/conversion/dictionary-view.js +13 -2
- package/dist/conversion/document-record-view.d.ts +0 -1
- package/dist/conversion/document-record-view.js +30 -3
- package/dist/conversion/impossible-field-read.d.ts +9 -0
- package/dist/conversion/impossible-field-read.js +26 -0
- package/dist/conversion/nodes.d.ts +12 -0
- package/dist/conversion/nodes.js +106 -2
- package/dist/conversion/record-view.js +21 -0
- package/dist/ir/build.d.ts +5 -2
- package/dist/ir/build.js +9 -2
- package/dist/ir/callable-class-flow.js +233 -13
- package/dist/ir/certify/parallel-region.js +1 -0
- package/dist/ir/certify.js +32 -2
- package/dist/ir/hoist.js +15 -1
- package/dist/ir/host-template-conversions.js +12 -0
- package/dist/ir/lower-invocation.js +42 -2
- package/dist/ir/lower-property.js +2 -2
- package/dist/ir/model.d.ts +18 -6
- package/dist/ir/native-callable-data-reads.js +15 -2
- package/dist/ir/native-field-view-domains.d.ts +8 -0
- package/dist/ir/native-field-view-domains.js +44 -3
- package/dist/ir/native-field-view-facts.d.ts +2 -2
- package/dist/ir/native-field-view-facts.js +57 -13
- package/dist/ir/native-own-assignment.js +20 -2
- package/dist/ir/program-conversions.js +38 -7
- package/dist/ir/property-read-conversions.js +14 -5
- package/dist/ir/publish-native-field-view-facts.js +1 -1
- package/dist/ir/queries.js +2 -0
- package/dist/ir/read-only-dictionary.js +138 -15
- package/dist/ir/reflection-demand.js +7 -1
- package/dist/ir/shake.js +26 -6
- package/dist/ir/typed-property-access.d.ts +20 -0
- package/dist/ir/typed-property-access.js +56 -0
- package/dist/projection/bindings.js +14 -19
- package/dist/projection/fields.js +7 -1
- package/dist/projection/native-object-data.d.ts +8 -1
- package/dist/projection/native-object-data.js +16 -4
- package/dist/representation/derive.js +67 -1
- package/dist/representation/proxy-carriers.js +17 -2
- package/dist/representation/publish.js +34 -0
- package/dist/semantics/callable-own-data-slots.js +71 -6
- package/dist/semantics/model/operations.d.ts +15 -4
- package/dist/semantics/native-own-assignment.d.ts +3 -0
- package/dist/semantics/normalize/collection-bindings.js +2 -2
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/array-element-continuation.js +32 -9
- package/dist/semantics/normalize/flow/callable-reach.d.ts +3 -5
- package/dist/semantics/normalize/flow/callable-reach.js +3 -5
- package/dist/semantics/normalize/flow/component-solver.d.ts +2 -0
- package/dist/semantics/normalize/flow/component-solver.js +32 -6
- package/dist/semantics/normalize/flow/computed-key-set.js +53 -1
- package/dist/semantics/normalize/flow/source-value-session.js +16 -14
- package/dist/semantics/normalize/producers/invocations.js +40 -1
- package/dist/semantics/normalize/producers/native-own-assignment.js +12 -4
- package/dist/semantics/normalize/reachability.js +18 -8
- package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -0
- package/dist/semantics/normalize/structural-mutable-field.js +170 -4
- package/dist/semantics/normalize/structural-parts.js +6 -1
- package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
- package/dist/semantics/normalize/structural-self-reference.js +9 -1
- package/dist/semantics/normalize/structural.js +10 -1
- package/dist/semantics/program.js +102 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +9 -0
- package/dist/targets/cpp/emit-allocation.js +22 -1
- package/dist/targets/cpp/emit-exceptions.js +6 -0
- package/dist/targets/cpp/emit-narrowing.js +24 -2
- package/dist/targets/cpp/emit-native-field-view.d.ts +1 -1
- package/dist/targets/cpp/emit-native-field-view.js +37 -5
- package/dist/targets/cpp/emit-native-own-assignment.js +5 -1
- package/dist/targets/cpp/emit-record-view.js +6 -1
- package/dist/targets/cpp/emit-tonumber.d.ts +22 -11
- package/dist/targets/cpp/emit-tonumber.js +86 -25
- package/dist/targets/cpp/emit.js +3 -0
- package/dist/targets/cpp/host/emit-host-invoke.js +6 -6
- package/dist/targets/cpp/prototype/emit-prototype-array.js +13 -1
- package/dist/targets/cpp/records.js +15 -7
- package/dist/targets/cpp/recursive-containers.js +5 -1
- package/dist/targets/cpp/translation-unit.js +17 -2
- package/package.json +4 -2
- package/src/targets/cpp/runtime/gea_runtime.h +212 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { recipeHasNormalResult, recipeIsMaterializableWithoutPriorSourceGuard, recipePreservesNativePayload } from '../conversion/recipe-closure.js';
|
|
2
2
|
import { nativePayloadTransportMatches } from '../conversion/native-payload-transport.js';
|
|
3
3
|
import { isNativeCallableCarrier } from '../representation/callable-object.js';
|
|
4
|
-
import { carriesUndefined, representationKey
|
|
4
|
+
import { carriesUndefined, representationKey } from '../representation/model.js';
|
|
5
5
|
import { operandOf } from '../semantics/model/operands.js';
|
|
6
6
|
import { allOperationsOf } from './model.js';
|
|
7
7
|
import { nativeCallableDataOwnerAuthorityOf } from './native-callable-data-owner.js';
|
|
@@ -27,7 +27,20 @@ export const nativeCallableTypedDataReadRequiresAuthority = (operation, key) =>
|
|
|
27
27
|
!declaredDynamicResult(operation.result.representation) &&
|
|
28
28
|
(key === null ||
|
|
29
29
|
(!['name', 'length', 'prototype'].includes(key) && !nonExpandoFunctionMemberNames.has(key) && !objectPrototypeMemberNames.has(key)));
|
|
30
|
-
|
|
30
|
+
/** Whether the value ITSELF may be a native Function: a write installs own
|
|
31
|
+
* data on its receiver, never on a Function held in one of the receiver's
|
|
32
|
+
* fields, so a connect-options record with a `lookup` callback field (whose
|
|
33
|
+
* `result[name] = options[name]` loop has a computed key) installs nothing a
|
|
34
|
+
* Function read could observe. */
|
|
35
|
+
const holdsNativeCallable = (value) => value.kind === 'optional'
|
|
36
|
+
? holdsNativeCallable(value.payload)
|
|
37
|
+
: value.kind === 'borrowed-ref'
|
|
38
|
+
? holdsNativeCallable(value.referent)
|
|
39
|
+
: value.kind === 'tagged-union'
|
|
40
|
+
? value.arms.some((arm) => holdsNativeCallable(arm.value))
|
|
41
|
+
: value.kind === 'proxy-object'
|
|
42
|
+
? holdsNativeCallable(value.target)
|
|
43
|
+
: isNativeCallableCarrier(value.kind) || value.kind === 'callable-identity';
|
|
31
44
|
const installedKeyCensuses = new WeakMap();
|
|
32
45
|
/** Every constant key some operation may install as own data on a native
|
|
33
46
|
* Function, or `unknown` when a write's key (or a bulk definition's key set)
|
|
@@ -26,6 +26,14 @@ export interface NativeFieldStorageDomain {
|
|
|
26
26
|
* `byteLength` are prototype accessors over the view's internal slots.
|
|
27
27
|
*/
|
|
28
28
|
readonly nativeData?: true;
|
|
29
|
+
/**
|
|
30
|
+
* A union's Array arm under an array-index key: the read is that Array's
|
|
31
|
+
* own element [[Get]] -- the element, or `undefined` for a hole or an index
|
|
32
|
+
* past its length -- so `read` is the element carrier made optional. A
|
|
33
|
+
* `Sort`-like union holding string arrays beside a Document-viewed tuple
|
|
34
|
+
* reads `t[1]` off each arm this way.
|
|
35
|
+
*/
|
|
36
|
+
readonly arrayElement?: true;
|
|
29
37
|
}
|
|
30
38
|
export interface NativeFieldViewDomains {
|
|
31
39
|
(receiver: Representation): ReadonlyMap<string, readonly NativeFieldStorageDomain[]> | null;
|
|
@@ -4,7 +4,12 @@ import { classMemberOf } from '../projection/fields.js';
|
|
|
4
4
|
import { extendsClass } from '../projection/dispatch.js';
|
|
5
5
|
import { abiOfCallee } from '../projection/callee.js';
|
|
6
6
|
import { nativeDataPropertyOf } from '../representation/native-data-properties.js';
|
|
7
|
+
import { objectPrototypeMemberNames } from '../representation/record-fields.js';
|
|
7
8
|
const binaryViewDataKeys = ['buffer', 'byteLength', 'byteOffset', 'length', 'BYTES_PER_ELEMENT'];
|
|
9
|
+
const noRoutes = new Map();
|
|
10
|
+
/** A canonical array index: the decimal spelling of an integer below 2^32 - 1. */
|
|
11
|
+
const declaredAnyEntryTable = (value) => value.kind === 'dictionary' && value.key === 'string' && value.ownership === 'shared-refcount' && value.value.kind === 'dynamic';
|
|
12
|
+
const isArrayIndexKey = (key) => /^(0|[1-9][0-9]*)$/.test(key) && Number(key) < 4294967295;
|
|
8
13
|
const isDocumentPlan = (plan) => plan.source.kind === 'dictionary' && plan.fields.every((field) => field.declaredAnyEntry === true);
|
|
9
14
|
/** The identity of one receiver's store of a forwarded key no source declares (`NativeCallableFlow.nativeFieldViewForwardedWrites`). */
|
|
10
15
|
export const nativeFieldViewForwardedWriteKey = (receiver, key) => JSON.stringify([receiver, key]);
|
|
@@ -218,10 +223,17 @@ sourcePlansOf = () => null) => {
|
|
|
218
223
|
// recursing with an `any` entry): its read is that Value's own [[Get]],
|
|
219
224
|
// converted by the same leaf as every other route. Nothing is boxed.
|
|
220
225
|
const dynamicArms = receiver.arms.filter((arm) => arm.value.kind === 'dynamic');
|
|
221
|
-
|
|
226
|
+
// A `Record<string, any>` arm answers a named key with its own entry,
|
|
227
|
+
// a Value (`undefined` on a miss), exactly as the ordinary per-arm
|
|
228
|
+
// dispatch reads it (`emit-union-properties.ts`); an `Object.prototype`
|
|
229
|
+
// member name is no entry read, so such a key gets no route.
|
|
230
|
+
const entryArms = receiver.arms.filter((arm) => declaredAnyEntryTable(arm.value));
|
|
231
|
+
const objectArms = receiver.arms.filter((arm) => arm.value.kind !== 'undefined' && arm.value.kind !== 'null' && arm.value.kind !== 'dynamic' && !declaredAnyEntryTable(arm.value));
|
|
222
232
|
if (!ordinaryArm && !objectArms.some((arm) => domainsOf(arm.value) !== null))
|
|
223
233
|
return null;
|
|
224
|
-
|
|
234
|
+
// An Array arm names no keys of its own here; its index reads are
|
|
235
|
+
// answered per key below, from the element.
|
|
236
|
+
const arms = objectArms.map((arm) => (arm.value.kind === 'array-object' ? noRoutes : domainsOf(arm.value, true, via)));
|
|
225
237
|
if (!arms.length || arms.some((arm) => arm === null))
|
|
226
238
|
return null;
|
|
227
239
|
// A per-arm union, not an intersection: a key only one arm stores (a
|
|
@@ -237,8 +249,18 @@ sourcePlansOf = () => null) => {
|
|
|
237
249
|
let complete = true;
|
|
238
250
|
for (const [index, arm] of arms.entries()) {
|
|
239
251
|
const held = arm.get(key);
|
|
252
|
+
const array = objectArms[index].value;
|
|
240
253
|
if (held !== undefined)
|
|
241
254
|
routes.push(...held);
|
|
255
|
+
else if (array.kind === 'array-object') {
|
|
256
|
+
if (array.extension !== null || !isArrayIndexKey(key)) {
|
|
257
|
+
complete = false;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
const read = { kind: 'optional', payload: array.element, absence: 'undefined' };
|
|
261
|
+
if (!routes.some((route) => route.arrayElement === true && representationKey(route.read) === representationKey(read)))
|
|
262
|
+
routes.push({ read, write: null, arrayElement: true });
|
|
263
|
+
}
|
|
242
264
|
else if (keyAbsentIn(objectArms[index].value, key, new Set())) {
|
|
243
265
|
if (!routes.some((route) => route.originalAbsent === true))
|
|
244
266
|
routes.push({ read: { kind: 'undefined' }, write: null, originalAbsent: true });
|
|
@@ -248,11 +270,19 @@ sourcePlansOf = () => null) => {
|
|
|
248
270
|
break;
|
|
249
271
|
}
|
|
250
272
|
}
|
|
251
|
-
if (!complete)
|
|
273
|
+
if (!complete || (entryArms.length > 0 && objectPrototypeMemberNames.has(key)))
|
|
252
274
|
continue;
|
|
253
275
|
for (const arm of dynamicArms)
|
|
254
276
|
if (!routes.some((route) => route.dynamicGet === true && representationKey(route.read) === representationKey(arm.value)))
|
|
255
277
|
routes.push({ read: arm.value, write: null, dynamicGet: true });
|
|
278
|
+
// The entry is a Value read by the same leaf as a `dynamic` arm's.
|
|
279
|
+
for (const arm of entryArms) {
|
|
280
|
+
if (arm.value.kind !== 'dictionary')
|
|
281
|
+
continue;
|
|
282
|
+
const entry = arm.value.value;
|
|
283
|
+
if (!routes.some((route) => route.dynamicGet === true && representationKey(route.read) === representationKey(entry)))
|
|
284
|
+
routes.push({ read: entry, write: null, dynamicGet: true });
|
|
285
|
+
}
|
|
256
286
|
common.set(key, routes);
|
|
257
287
|
}
|
|
258
288
|
cache.set(identity, common);
|
|
@@ -406,6 +436,17 @@ sourcePlansOf = () => null) => {
|
|
|
406
436
|
if ('shapeId' in plan.source)
|
|
407
437
|
for (const stored of expandoStoredOf(plan.source.shapeId, field.key))
|
|
408
438
|
add(field.key, { read: stored, write: null });
|
|
439
|
+
// A source that is itself a Document view (one of the views that
|
|
440
|
+
// can be this plan's very source) forwards the key on to its
|
|
441
|
+
// dictionary, which answers with its own entry, a declared `any`.
|
|
442
|
+
// Where the source's routes already read that entry -- a Document
|
|
443
|
+
// naming the key, whose route carries its checked read -- that route
|
|
444
|
+
// is the entry's one reader, and a second, unchecked one would make
|
|
445
|
+
// the two disagree on how the same Value converts.
|
|
446
|
+
if ('shapeId' in plan.source && !(inherited?.get(field.key) ?? []).some((route) => route.read.kind === 'dynamic'))
|
|
447
|
+
for (const source of installedFor(plan.source.shapeId, plan) ?? [])
|
|
448
|
+
if (isDocumentPlan(source) && source.source.kind === 'dictionary')
|
|
449
|
+
add(field.key, { read: source.source.value, write: null, declaredAnyEntry: true });
|
|
409
450
|
}
|
|
410
451
|
}
|
|
411
452
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConversionCensus } from '../conversion/nodes.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type ConversionNodeId } from '../conversion/algebra.js';
|
|
3
3
|
import type { IrValueId } from '../identity/ids.js';
|
|
4
4
|
import { type Representation } from '../representation/model.js';
|
|
5
5
|
import type { NativeCallableFlow } from './callable-class-flow.js';
|
|
@@ -111,7 +111,7 @@ export declare const nativeFieldViewOpenDocumentRead: (operation: GetOperation |
|
|
|
111
111
|
*/
|
|
112
112
|
export declare const nativeFieldViewOperationNeedsReceipt: (operation: GetOperation | SetOperation, targets: ReadonlySet<string>, hostNamespaces: HostNamespaceCensus | undefined,
|
|
113
113
|
/** The read's constant key, when it has one. */
|
|
114
|
-
key?: string | null, layoutOf?: Pick<RepresentationDeriver, "layoutOf"> | null) => boolean;
|
|
114
|
+
key?: string | null, layoutOf?: Pick<RepresentationDeriver, "layoutOf"> | null, flow?: Pick<FieldFlow, "nativeFieldStorageValues" | "nativeFieldViewOrigins"> | null) => boolean;
|
|
115
115
|
export declare const nativeFieldViewCarrierNeedsReceipt: (value: Representation, targets: ReadonlySet<string>) => boolean;
|
|
116
116
|
export declare const nativeFieldViewReadFor: (receiver: IrOperand, key: string, target: Representation, flow: FieldFlow, conversions: ConversionCensus, at?: GetOperation) => NativeFieldViewRead | null;
|
|
117
117
|
export declare const nativeFieldViewReadOf: (operation: GetOperation, key: string, flow: FieldFlow, conversions: ConversionCensus) => NativeFieldViewRead | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { recipeClosureOf, recipeIsMaterializableWithoutPriorSourceGuard } from '../conversion/recipe-closure.js';
|
|
2
|
+
import { isMaterializable } from '../conversion/algebra.js';
|
|
2
3
|
import { abiOfCallee } from '../projection/callee.js';
|
|
3
4
|
import { representationKey } from '../representation/model.js';
|
|
4
5
|
import { allOperationsOf } from './model.js';
|
|
@@ -113,10 +114,24 @@ const keyNamedByNoDescriptor = (receiver, key, flow) => flow
|
|
|
113
114
|
*/
|
|
114
115
|
export const nativeFieldViewOperationNeedsReceipt = (operation, targets, hostNamespaces,
|
|
115
116
|
/** The read's constant key, when it has one. */
|
|
116
|
-
key, layoutOf) => !(hostNamespaces?.reads.has(operation.receiver.value) || hostNamespaces?.values.has(operation.receiver.value)) &&
|
|
117
|
-
(operation.kind === 'get' &&
|
|
117
|
+
key, layoutOf, flow) => !(hostNamespaces?.reads.has(operation.receiver.value) || hostNamespaces?.values.has(operation.receiver.value)) &&
|
|
118
|
+
(operation.kind === 'get' &&
|
|
119
|
+
key !== null &&
|
|
120
|
+
key !== undefined &&
|
|
121
|
+
(operation.receiver.representation.kind === 'tagged-union' || plainAllocationsOnly(operation.receiver.value, key, flow))
|
|
118
122
|
? unionReadNeedsReceipt(operation.receiver.representation, key, targets, layoutOf)
|
|
119
123
|
: nativeFieldViewCarrierNeedsReceipt(operation.receiver.representation, targets));
|
|
124
|
+
/**
|
|
125
|
+
* A plain record receiver answers a key its layout lacks with the ordinary
|
|
126
|
+
* [[Get]] only where every allocation behind it is a known plain one: an
|
|
127
|
+
* installed live view forwards the key to native slots whose dynamic
|
|
128
|
+
* observation exists only through a receipt's adapter (`options = {}` handed an
|
|
129
|
+
* `Object.assign` result viewed as `{}`).
|
|
130
|
+
*/
|
|
131
|
+
const plainAllocationsOnly = (receiver, key, flow) => {
|
|
132
|
+
const slots = flow?.nativeFieldStorageValues.get(receiver);
|
|
133
|
+
return slots !== undefined && !slots.has(key) && flow?.nativeFieldViewOrigins?.has(receiver) !== true;
|
|
134
|
+
};
|
|
120
135
|
/**
|
|
121
136
|
* A constant-key read off a union is the per-arm dispatch of
|
|
122
137
|
* `emit-union-properties.ts`, and only an arm read through its own C++ member
|
|
@@ -127,6 +142,10 @@ key, layoutOf) => !(hostNamespaces?.reads.has(operation.receiver.value) || hostN
|
|
|
127
142
|
* node-compat's `Request` reads `init.body.type` after a call that may write
|
|
128
143
|
* `init.body`, so the read is off the whole `BodyInit` union, and its
|
|
129
144
|
* Document-viewed `ArrayBufferView` arm declares no `type`.
|
|
145
|
+
*
|
|
146
|
+
* A plain record receiver is that arm on its own: `options?.session` inside a
|
|
147
|
+
* generic `resolveOptions<T>` copy whose `T` is a literal record lacking
|
|
148
|
+
* `session` is the same ordinary [[Get]].
|
|
130
149
|
*/
|
|
131
150
|
const unionReadNeedsReceipt = (value, key, targets, layoutOf) => {
|
|
132
151
|
if (value.kind === 'optional')
|
|
@@ -170,7 +189,7 @@ const fieldSourcesOf = (flow, receiver, key, at) => {
|
|
|
170
189
|
return carried ?? (at === undefined ? null : (flow.nativeFieldViewAbsentRoutesOf?.(receiver, key) ?? null));
|
|
171
190
|
// Physical allocation slots are the whole answer where they exist; a union
|
|
172
191
|
// arm's certified absence speaks only for a receiver with none.
|
|
173
|
-
const domains = carried?.some((entry) => entry.originalAbsent === true || entry.dynamicGet === true || entry.nativeData === true)
|
|
192
|
+
const domains = carried?.some((entry) => entry.originalAbsent === true || entry.dynamicGet === true || entry.nativeData === true || entry.arrayElement === true)
|
|
174
193
|
? undefined
|
|
175
194
|
: carried;
|
|
176
195
|
const routes = physical.flatMap((read) => {
|
|
@@ -194,6 +213,10 @@ export const nativeFieldViewReadFor = (receiver, key, target, flow, conversions,
|
|
|
194
213
|
if (values.some((value) => value.originalAbsent === true) && at?.ordinaryObjectPrototypeKeyAbsent !== true)
|
|
195
214
|
return null;
|
|
196
215
|
const sources = new Map();
|
|
216
|
+
// Whether some route already merged under a source carried a checked read:
|
|
217
|
+
// the canonical-entry merge below must not depend on which of two routes
|
|
218
|
+
// over one Document entry happens to come first.
|
|
219
|
+
const checkedSources = new Set();
|
|
197
220
|
for (const { read: source, checkedRead, dynamicGet } of values) {
|
|
198
221
|
// A `dynamic` arm's Value reads through whichever exact leaf already
|
|
199
222
|
// converts that carrier (a Document entry's checked read): one source, one
|
|
@@ -220,12 +243,17 @@ export const nativeFieldViewReadFor = (receiver, key, target, flow, conversions,
|
|
|
220
243
|
// guard proved, a TypeError for any other -- never an unchecked `get<k>`.
|
|
221
244
|
const selected = recipeIsMaterializableWithoutPriorSourceGuard(unguarded, conversions.nodeById)
|
|
222
245
|
? unguarded
|
|
223
|
-
: (conversions.assertedUnionFor(source, target, false) ??
|
|
246
|
+
: (conversions.assertedUnionFor(source, target, false) ??
|
|
247
|
+
conversions.checkedClassFieldReadFor(source, target) ??
|
|
248
|
+
conversions.presentPayloadFor(source, target));
|
|
224
249
|
if (selected === null || !recipeIsMaterializableWithoutPriorSourceGuard(selected, conversions.nodeById))
|
|
225
250
|
return null;
|
|
226
251
|
const previous = sources.get(representationKey(source));
|
|
252
|
+
const checked = checkedRead !== undefined || checkedSources.has(representationKey(source));
|
|
253
|
+
if (checkedRead !== undefined)
|
|
254
|
+
checkedSources.add(representationKey(source));
|
|
227
255
|
if (previous !== undefined && previous.conversion !== selected.id) {
|
|
228
|
-
const canonical = documentEntryReadOf(source, target, previous.conversion, selected,
|
|
256
|
+
const canonical = documentEntryReadOf(source, target, previous.conversion, selected, checked, conversions);
|
|
229
257
|
if (canonical === null)
|
|
230
258
|
return null;
|
|
231
259
|
sources.set(representationKey(source), { source, conversion: canonical });
|
|
@@ -330,7 +358,7 @@ export const nativeFieldViewWriteOf = (operation, key, flow, conversions) => {
|
|
|
330
358
|
// an expando property, which no setter-less descriptor route performs.
|
|
331
359
|
if (!data &&
|
|
332
360
|
!accessor &&
|
|
333
|
-
descriptors?.some((entry) => entry.originalAbsent === true || entry.dynamicGet === true || entry.nativeData === true))
|
|
361
|
+
descriptors?.some((entry) => entry.originalAbsent === true || entry.dynamicGet === true || entry.nativeData === true || entry.arrayElement === true))
|
|
334
362
|
return null;
|
|
335
363
|
const targets = new Map();
|
|
336
364
|
// A forwarded key no source declares has no setter-less descriptor to
|
|
@@ -349,10 +377,10 @@ export const nativeFieldViewWriteOf = (operation, key, flow, conversions) => {
|
|
|
349
377
|
// A plain allocation of the receiver's own record keeps the key in its slot.
|
|
350
378
|
const own = ownRecordFieldOf(operation.receiver.representation, key);
|
|
351
379
|
if (own !== null) {
|
|
352
|
-
const
|
|
353
|
-
if (
|
|
380
|
+
const conversion = storeConversionOf(operation, key, own, conversions);
|
|
381
|
+
if (conversion === null)
|
|
354
382
|
return null;
|
|
355
|
-
targets.set(representationKey(own), { target: own, conversion
|
|
383
|
+
targets.set(representationKey(own), { target: own, conversion });
|
|
356
384
|
}
|
|
357
385
|
}
|
|
358
386
|
for (const target of data ?? accessor?.map((entry) => entry.write) ?? descriptors.map((entry) => entry.write)) {
|
|
@@ -365,13 +393,13 @@ export const nativeFieldViewWriteOf = (operation, key, flow, conversions) => {
|
|
|
365
393
|
if (!entries?.length || entries.some((entry) => entry.declaredAnyEntry !== true))
|
|
366
394
|
return null;
|
|
367
395
|
}
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
396
|
+
const conversion = storeConversionOf(operation, key, target, conversions);
|
|
397
|
+
if (conversion === null)
|
|
370
398
|
return null;
|
|
371
399
|
const previous = targets.get(representationKey(target));
|
|
372
|
-
if (previous !== undefined && previous.conversion !==
|
|
400
|
+
if (previous !== undefined && previous.conversion !== conversion)
|
|
373
401
|
return null;
|
|
374
|
-
targets.set(representationKey(target), { target, conversion
|
|
402
|
+
targets.set(representationKey(target), { target, conversion });
|
|
375
403
|
}
|
|
376
404
|
return {
|
|
377
405
|
receiver: operation.receiver.value,
|
|
@@ -383,6 +411,22 @@ export const nativeFieldViewWriteOf = (operation, key, flow, conversions) => {
|
|
|
383
411
|
...(open === undefined ? {} : { open, forwardedKeys: [key] })
|
|
384
412
|
};
|
|
385
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* A store's conversion into one key's slot. A correlated copy
|
|
416
|
+
* (`SetOperation.correlatedSourceFields`) holds, under `key`, only what the
|
|
417
|
+
* source's own field of that key holds; when that field converts into the slot
|
|
418
|
+
* without a check, so does every value the store can actually carry, and the
|
|
419
|
+
* check the union-wide carrier would otherwise need never fails.
|
|
420
|
+
*/
|
|
421
|
+
const storeConversionOf = (operation, key, target, conversions) => {
|
|
422
|
+
const node = conversions.nodeFor(operation.value.representation, target);
|
|
423
|
+
if (recipeIsMaterializableWithoutPriorSourceGuard(node, conversions.nodeById))
|
|
424
|
+
return node.id;
|
|
425
|
+
const source = operation.correlatedSourceFields?.find((field) => field.key === key)?.source;
|
|
426
|
+
if (source === undefined || !isMaterializable(node.capability))
|
|
427
|
+
return null;
|
|
428
|
+
return recipeIsMaterializableWithoutPriorSourceGuard(conversions.nodeFor(source, target), conversions.nodeById) ? node.id : null;
|
|
429
|
+
};
|
|
386
430
|
const ownRecordFieldOf = (receiver, key) => {
|
|
387
431
|
if (receiver.kind === 'optional' || receiver.kind === 'borrowed-ref')
|
|
388
432
|
return ownRecordFieldOf(receiver.kind === 'optional' ? receiver.payload : receiver.referent, key);
|
|
@@ -322,9 +322,20 @@ export const nativeOwnAssignmentRecipeOf = (operation, operations, input) => {
|
|
|
322
322
|
(operation.result && representationKey(operation.result.representation) !== representationKey(target.representation)))
|
|
323
323
|
return null;
|
|
324
324
|
const local = nativeOwnAssignmentRootOf(target.value, operations, input);
|
|
325
|
-
|
|
325
|
+
// A conditional source argument splits a described copy from its target
|
|
326
|
+
// too. The target argument must then be the exact native allocation, seen
|
|
327
|
+
// through its own initializing stores only; the body-wide producer check
|
|
328
|
+
// below authenticates it.
|
|
329
|
+
const splitRootOf = (id, depth) => {
|
|
330
|
+
const one = depth > 64 ? null : definitionOf(id);
|
|
331
|
+
if (one?.kind === 'allocate-record')
|
|
332
|
+
return sharedRecord(one.result.representation) ? one : null;
|
|
333
|
+
return one?.kind === 'set' || one?.kind === 'define-own-property' ? splitRootOf(one.receiver.value, depth + 1) : null;
|
|
334
|
+
};
|
|
335
|
+
const describedRoot = local ?? (describedFact ? splitRootOf(target.value, 0) : null);
|
|
336
|
+
if (describedFact && describedRoot === null)
|
|
326
337
|
return null;
|
|
327
|
-
const targetResult = describedFact ?
|
|
338
|
+
const targetResult = describedFact ? describedRoot.lineage : fact.targets[0];
|
|
328
339
|
const allocation = allocationOf(input.graph, targetResult);
|
|
329
340
|
const body = input.bodyOf?.(operation);
|
|
330
341
|
// A conditional source argument splits the call from its already evaluated
|
|
@@ -353,6 +364,13 @@ export const nativeOwnAssignmentRecipeOf = (operation, operations, input) => {
|
|
|
353
364
|
if (!receiver || !semanticSource || semanticSource.source !== source.source)
|
|
354
365
|
return null;
|
|
355
366
|
if (source.described !== undefined) {
|
|
367
|
+
// A declared-any table declaring no member holds only Values: every
|
|
368
|
+
// run-time key it enumerates is copied as its live entry.
|
|
369
|
+
const surfaces = surfacesOf(receiver.representation);
|
|
370
|
+
if (source.described.keys.length === 0 && surfaces.length > 0 && surfaces.every(declaredDynamicDictionary)) {
|
|
371
|
+
sources.push({ ordinal: source.ordinal, protocol: 'dictionary-entry', described: true, fields: [], receiver, roots: [] });
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
356
374
|
const described = describedSourceFieldsOf(receiver.representation, source.described.keys, layout, census.schemas.get(allocation.id), input);
|
|
357
375
|
if (described === null)
|
|
358
376
|
return null;
|
|
@@ -6,6 +6,7 @@ import { classMethodOverrideOf } from '../projection/fields.js';
|
|
|
6
6
|
import { representationKey, walkRepresentation } from '../representation/model.js';
|
|
7
7
|
import { dynamicRecordLoadNeedsPlan } from '../conversion/document-record-view.js';
|
|
8
8
|
import { recipeClosureOf } from '../conversion/recipe-closure.js';
|
|
9
|
+
import { nativeViewOriginsOf } from '../conversion/native-view-origins.js';
|
|
9
10
|
import { capturesNothing } from './captures.js';
|
|
10
11
|
import { asyncPromiseViewOf } from './coroutine-bodies.js';
|
|
11
12
|
import { allOperationsOf } from './model.js';
|
|
@@ -55,9 +56,10 @@ export const prototypeSetterValue = { kind: 'dynamic', reason: 'declared-any-nev
|
|
|
55
56
|
* A plan without one would refuse the whole program at certification; with no
|
|
56
57
|
* plan the one operation that reaches the slot keeps its named refusal.
|
|
57
58
|
*/
|
|
58
|
-
const dynamicLoadInstalled = (value, conversions) =>
|
|
59
|
+
const dynamicLoadInstalled = (value, conversions) => dynamicPairInstalled(prototypeSetterValue, value, conversions);
|
|
60
|
+
const dynamicPairInstalled = (source, value, conversions) => {
|
|
59
61
|
try {
|
|
60
|
-
const closure = recipeClosureOf([conversions.nodeFor(
|
|
62
|
+
const closure = recipeClosureOf([conversions.nodeFor(source, value)], conversions.nodeById);
|
|
61
63
|
return [...closure.values()].every((node) => node.capability.kind !== 'never');
|
|
62
64
|
}
|
|
63
65
|
catch {
|
|
@@ -99,10 +101,16 @@ export const programConversionInputsOf = (input) => {
|
|
|
99
101
|
// Function boxed into `any`, a prototype method a boxed instance answers
|
|
100
102
|
// with, and a callable own field a full-reflection receiver answers with.
|
|
101
103
|
const boxedFrames = [];
|
|
104
|
+
const convertedNodes = new Set();
|
|
102
105
|
for (const body of bodies) {
|
|
103
106
|
const operations = [...body.blocks.values()].flatMap((block) => allOperationsOf(block));
|
|
104
107
|
const definitions = new Map(operations.flatMap((operation) => (operation.kind === 'constant' ? [[operation.result.id, operation]] : [])));
|
|
105
108
|
for (const operation of operations) {
|
|
109
|
+
if (operation.kind === 'convert') {
|
|
110
|
+
const node = input.conversions.nodeById(operation.conversionUse);
|
|
111
|
+
if (node !== null)
|
|
112
|
+
convertedNodes.add(node);
|
|
113
|
+
}
|
|
106
114
|
if (operation.kind === 'convert' && operation.result.representation.kind === 'dynamic') {
|
|
107
115
|
const abi = abiOfCallee(operation.source.representation);
|
|
108
116
|
if (abi !== null)
|
|
@@ -125,6 +133,8 @@ export const programConversionInputsOf = (input) => {
|
|
|
125
133
|
const boundary = { role, owner, slot, source, target };
|
|
126
134
|
inputs.set(programConversionKey(boundary), boundary);
|
|
127
135
|
};
|
|
136
|
+
let origins = null;
|
|
137
|
+
const viewOrigins = () => (origins ??= [...nativeViewOriginsOf(convertedNodes, input.conversions.nodeById)].sort((left, right) => representationKey(left.source).localeCompare(representationKey(right.source))));
|
|
128
138
|
const layouts = recordShapeLayoutsOf(input.deriver, input.classes);
|
|
129
139
|
const retained = new Map();
|
|
130
140
|
for (const root of input.representations ?? [])
|
|
@@ -161,9 +171,16 @@ export const programConversionInputsOf = (input) => {
|
|
|
161
171
|
boxedFrames.push(callable);
|
|
162
172
|
if (demand.fieldOperations !== undefined && !operations?.has('write') && !operations?.has('define'))
|
|
163
173
|
continue;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
// Full reflection publishes every field to dynamic writers whether or
|
|
175
|
+
// not one ever names it, so a field the census cannot load into (an
|
|
176
|
+
// intersection-typed options record whose overloaded callable member
|
|
177
|
+
// no Document entry reads into) gets no plan, exactly as a boxed
|
|
178
|
+
// frame's record argument gets none: its dispatcher arm keeps the
|
|
179
|
+
// runtime refusal (`refuseUnaddressableField`) instead of a recipe
|
|
180
|
+
// with no conversion refusing the whole program.
|
|
181
|
+
if (dynamicRecordLoadNeedsPlan(field.value, layouts) || dynamicTableLoadNeedsPlan(field.value, layouts)
|
|
182
|
+
? dynamicLoadInstalled(field.value, input.conversions)
|
|
183
|
+
: dynamicCallableLoadInstalled(field.value, input.conversions))
|
|
167
184
|
add('dynamic-field-write', owner, field.key, prototypeSetterValue, field.value);
|
|
168
185
|
}
|
|
169
186
|
}
|
|
@@ -180,8 +197,22 @@ export const programConversionInputsOf = (input) => {
|
|
|
180
197
|
const owner = dynamicFieldConversionOwnerOf(record);
|
|
181
198
|
if (owner === null || inputs.has(programConversionKey({ role: 'dynamic-call-argument', owner, slot: '' })))
|
|
182
199
|
continue;
|
|
183
|
-
if (dynamicRecordLoadNeedsPlan(record, layouts)
|
|
184
|
-
|
|
200
|
+
if (!dynamicRecordLoadNeedsPlan(record, layouts) || !dynamicLoadInstalled(record, input.conversions))
|
|
201
|
+
continue;
|
|
202
|
+
add('dynamic-call-argument', owner, '', prototypeSetterValue, record);
|
|
203
|
+
// A live view boxes as its original object (`record::boxNativeView`),
|
|
204
|
+
// so a view of this record handed through the box arrives as the
|
|
205
|
+
// ORIGINAL's layout, which the exact-payload load refuses. Each
|
|
206
|
+
// origin the program views as this record is read back through that
|
|
207
|
+
// same certified view (`connectionType ?? Connection` constructed
|
|
208
|
+
// with a pool's merged options viewed as `ConnectionOptions`).
|
|
209
|
+
if (!('shapeId' in record))
|
|
210
|
+
continue;
|
|
211
|
+
for (const origin of viewOrigins())
|
|
212
|
+
if (origin.target.shapeId === record.shapeId &&
|
|
213
|
+
origin.source.kind !== 'dictionary' &&
|
|
214
|
+
dynamicPairInstalled(origin.source, record, input.conversions))
|
|
215
|
+
add('dynamic-call-argument', owner, `origin:${representationKey(origin.source)}`, origin.source, record);
|
|
185
216
|
}
|
|
186
217
|
for (const body of bodies) {
|
|
187
218
|
const view = asyncPromiseViewOf(body);
|
|
@@ -24,11 +24,20 @@ export const compatibilityFieldReadSourcesOf = (operation, deriver) => {
|
|
|
24
24
|
operation.key.representation.kind !== 'string')
|
|
25
25
|
return [];
|
|
26
26
|
const receiver = operation.receiver.representation;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const fields = receiver.kind === 'record' || receiver.kind === 'record-with-index'
|
|
28
|
+
? receiver.fields
|
|
29
|
+
: receiver.kind === 'class-ref' || (receiver.kind === 'native-record-ref' && receiver.native === null)
|
|
30
|
+
? (recordFieldsOfShape(deriver, receiver.shapeId) ?? [])
|
|
31
|
+
: [];
|
|
32
|
+
// A key whose domain the IR proved names only those fields: a class read by
|
|
33
|
+
// `command[key as keyof typeof MAP]` reaches its three numeric and Document
|
|
34
|
+
// members, never the `ns: string` beside them, which has no arm in the
|
|
35
|
+
// read's union. A key outside the domain is the route's unreachable tail.
|
|
36
|
+
const domain = operation.provenKeyTexts;
|
|
37
|
+
if (domain === undefined)
|
|
38
|
+
return fields;
|
|
39
|
+
const named = fields.filter((field) => domain.includes(field.key));
|
|
40
|
+
return named.length > 0 ? named : fields;
|
|
32
41
|
};
|
|
33
42
|
/** Property results produced by getter bodies and ordinary native property tables. */
|
|
34
43
|
export const propertyReadConversionInputsOf = (operation, keyText, deriver, classes, abis = new Map(), virtualAbis = new Map(), wellKnownSymbols = new Map()) => {
|
|
@@ -61,7 +61,7 @@ export const publishNativeFieldViewFacts = (input) => {
|
|
|
61
61
|
return nativeMethodRead === null ? ordinary : { ...ordinary, nativeMethodRead };
|
|
62
62
|
}
|
|
63
63
|
if ((operation.kind !== 'get' && operation.kind !== 'set') ||
|
|
64
|
-
!nativeFieldViewOperationNeedsReceipt(operation, targets, body.hostNamespaceCensus, keys.get(operation.key.value), input.deriver))
|
|
64
|
+
!nativeFieldViewOperationNeedsReceipt(operation, targets, body.hostNamespaceCensus, keys.get(operation.key.value), input.deriver, flow))
|
|
65
65
|
return output;
|
|
66
66
|
const key = keys.get(operation.key.value);
|
|
67
67
|
if (nativeFieldViewOpenDocumentRead(operation, key, targets, documents)) {
|
package/dist/ir/queries.js
CHANGED
|
@@ -177,6 +177,8 @@ export const operandsOfIrOperation = (operation) => {
|
|
|
177
177
|
case 'commonjs-require':
|
|
178
178
|
case 'commonjs-binding':
|
|
179
179
|
return [];
|
|
180
|
+
case 'module-namespace':
|
|
181
|
+
return [operation.fresh];
|
|
180
182
|
case 'commonjs-binding-set':
|
|
181
183
|
return [operation.value];
|
|
182
184
|
case 'super-initialize':
|