@geastack/compiler 1.0.42 → 1.0.44
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.js +8 -2
- package/dist/conversion/nodes.js +5 -2
- package/dist/ir/callable-class-flow.js +48 -13
- package/dist/ir/certify.js +1 -1
- package/dist/ir/host-template-conversions.d.ts +2 -2
- package/dist/ir/host-template-conversions.js +73 -2
- package/dist/ir/lower-destructuring.js +22 -3
- package/dist/ir/lower-operands.js +30 -1
- package/dist/ir/native-field-view-facts.d.ts +8 -1
- package/dist/ir/native-field-view-facts.js +13 -3
- package/dist/ir/operation-conversions.js +1 -1
- package/dist/ir/program-conversions.d.ts +1 -1
- package/dist/ir/program-conversions.js +68 -1
- package/dist/ir/property-read-conversions.js +7 -1
- package/dist/ir/publish-native-field-view-facts.js +4 -0
- package/dist/ir/reflection-demand.js +29 -3
- package/dist/ir/shake.js +21 -0
- package/dist/projection/dispatch.d.ts +19 -1
- package/dist/projection/dispatch.js +34 -0
- package/dist/representation/value-records.js +182 -13
- package/dist/semantics/frontend.js +18 -14
- package/dist/semantics/normalize/collection-bindings.d.ts +7 -0
- package/dist/semantics/normalize/collection-bindings.js +35 -1
- package/dist/semantics/normalize/derived-expression-type.js +49 -0
- package/dist/semantics/normalize/field-bindings.js +6 -1
- package/dist/semantics/normalize/flow/component-solver.js +37 -2
- package/dist/semantics/normalize/flow/source-value-session.d.ts +12 -2
- package/dist/semantics/normalize/flow/source-value-session.js +861 -212
- package/dist/semantics/normalize/global-host-mutations.js +14 -6
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +11 -10
- package/dist/semantics/normalize/implicit-arguments-tuple.js +15 -3
- package/dist/semantics/normalize/local-bindings.js +23 -1
- package/dist/semantics/normalize/producers/references.js +26 -18
- package/dist/semantics/normalize/structural-array-element.d.ts +7 -0
- package/dist/semantics/normalize/structural-array-element.js +24 -1
- package/dist/semantics/normalize/structural-layout-type.js +5 -1
- package/dist/semantics/normalize/structural-mutable-method.js +88 -2
- package/dist/semantics/normalize/structural-parts.js +13 -8
- package/dist/semantics/normalize/structural.js +25 -1
- package/dist/targets/cpp/borrowed-call-entry.d.ts +41 -2
- package/dist/targets/cpp/borrowed-call-entry.js +91 -6
- package/dist/targets/cpp/class-properties/emit-class-properties.js +5 -1
- package/dist/targets/cpp/emit-callable.js +81 -39
- package/dist/targets/cpp/emit-native-field-view.d.ts +2 -0
- package/dist/targets/cpp/emit-native-field-view.js +1 -1
- package/dist/targets/cpp/emit-properties.js +114 -12
- package/dist/targets/cpp/host/emit-host-invoke.js +16 -2
- package/dist/targets/cpp/host/emit-host-object.js +69 -2
- package/dist/targets/cpp/host/host-members.js +4 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +42 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.js +31 -9
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +40 -17
- package/dist/targets/cpp/translation-unit.js +82 -24
- package/dist/targets/cpp/virtual-methods.js +9 -4
- package/package.json +1 -1
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +17 -1
- package/src/targets/cpp/runtime/gea_runtime.h +485 -64
|
@@ -147,6 +147,8 @@ const exactListOf = (set) => {
|
|
|
147
147
|
};
|
|
148
148
|
// Read once at load, not per value transfer: `process.env` is a native interceptor.
|
|
149
149
|
const noArrayKeys = process.env['GEA_NO_ARRAY_KEYS'] !== undefined;
|
|
150
|
+
// `GEA_JOINED_ONLY_OFF` re-runs every transfer in full (`joinedOnly`), so the claim stays checkable from one build.
|
|
151
|
+
const joinedOnlyEnabled = process.env['GEA_JOINED_ONLY_OFF'] === undefined;
|
|
150
152
|
/**
|
|
151
153
|
* The element slot of an array root: every position at once. A computed
|
|
152
154
|
* index names no single key (`this.items[ i ]` in a constructor that fills
|
|
@@ -157,6 +159,8 @@ const noArrayKeys = process.env['GEA_NO_ARRAY_KEYS'] !== undefined;
|
|
|
157
159
|
* read nothing, and every such array's elements were unresolvable.
|
|
158
160
|
*/
|
|
159
161
|
const ELEMENT_KEY = '[]';
|
|
162
|
+
/** Past this many facts a dependency's facts are added to a reader incrementally (`addedThrough`). */
|
|
163
|
+
const DELTA_MINIMUM = 8;
|
|
160
164
|
const CANONICAL_INDEX = /^(?:0|[1-9][0-9]*)$/;
|
|
161
165
|
const isCanonicalIndex = (key) => CANONICAL_INDEX.test(key);
|
|
162
166
|
/** Whether a store or read filed under `stored` can reach the slot `key` of `root`. */
|
|
@@ -304,7 +308,11 @@ const createSession = (checker, flow) => {
|
|
|
304
308
|
const slots = new Map();
|
|
305
309
|
const storedSlots = new Map();
|
|
306
310
|
const keyReadQueries = new Map();
|
|
311
|
+
const keyUseQueries = new Map();
|
|
307
312
|
const uses = new Map();
|
|
313
|
+
const rootUses = new Map();
|
|
314
|
+
const enumeratedSlotQueries = new Map();
|
|
315
|
+
const familySlotQueries = new Map();
|
|
308
316
|
const publications = new Map();
|
|
309
317
|
// Per call, the bodies and subjects it was asked about (see `frameQuery`).
|
|
310
318
|
const frameQueries = new Map();
|
|
@@ -347,6 +355,10 @@ const createSession = (checker, flow) => {
|
|
|
347
355
|
return null;
|
|
348
356
|
};
|
|
349
357
|
const arrayLengths = new Map();
|
|
358
|
+
// A callable's own `name` and `length`, one literal per (callable, key) for the same
|
|
359
|
+
// reason as `arrayLengths`: the solver compares facts by identity, so a literal minted
|
|
360
|
+
// per evaluation is a new fact every time and its slot never settles.
|
|
361
|
+
const callableOwnData = new Map();
|
|
350
362
|
const keyValues = new Map();
|
|
351
363
|
const keyValue = (root, key) => {
|
|
352
364
|
let keys = keyValues.get(root);
|
|
@@ -357,6 +369,29 @@ const createSession = (checker, flow) => {
|
|
|
357
369
|
keys.set(key, (literal = ts.factory.createStringLiteral(key)));
|
|
358
370
|
return literal;
|
|
359
371
|
};
|
|
372
|
+
// An `enumerated-keys` node's facts: one literal per key text, for the same
|
|
373
|
+
// identity reason as `keyValue`. They name keys and are no root's value.
|
|
374
|
+
const enumeratedKeyValues = new Map();
|
|
375
|
+
const enumeratedKeyValue = (key) => {
|
|
376
|
+
let literal = enumeratedKeyValues.get(key);
|
|
377
|
+
if (!literal)
|
|
378
|
+
enumeratedKeyValues.set(key, (literal = ts.factory.createStringLiteral(key)));
|
|
379
|
+
return literal;
|
|
380
|
+
};
|
|
381
|
+
// Each head's key list, rebuilt only when its node gained a key: facts only
|
|
382
|
+
// grow, so an unchanged size is an unchanged set, and the accesses that ask
|
|
383
|
+
// are many.
|
|
384
|
+
const enumeratedKeyLists = new Map();
|
|
385
|
+
const enumeratedKeyListOf = (query, held) => {
|
|
386
|
+
const known = enumeratedKeyLists.get(query);
|
|
387
|
+
if (known !== undefined && known.size === held.size)
|
|
388
|
+
return known.keys;
|
|
389
|
+
const keys = [];
|
|
390
|
+
for (const key of held)
|
|
391
|
+
keys.push(key.text);
|
|
392
|
+
enumeratedKeyLists.set(query, { size: held.size, keys });
|
|
393
|
+
return keys;
|
|
394
|
+
};
|
|
360
395
|
const sites = new Map(flow.calls.map((site) => [site.call, site]));
|
|
361
396
|
const ownInvocationEntries = new Map();
|
|
362
397
|
const candidateOrdinaryOwnCallableOperandsOf = (call) => {
|
|
@@ -517,6 +552,20 @@ const createSession = (checker, flow) => {
|
|
|
517
552
|
* solver carries on a large program. It is one node's fact, asked once per container.
|
|
518
553
|
*/
|
|
519
554
|
const unknownReadsOf = (container) => nodeQuery('unknown-reads', container);
|
|
555
|
+
/**
|
|
556
|
+
* The places in a container's closure that can copy a key's value into
|
|
557
|
+
* another container: an `Object.assign` call, an object spread, or a
|
|
558
|
+
* `defineProperty` call. The test is syntax alone and does not depend on
|
|
559
|
+
* the value or the key, yet every key's uses (`key-uses`, one per key of
|
|
560
|
+
* the container) ran it over the container's whole closure, twice, on every
|
|
561
|
+
* re-evaluation. Asked once per container, a key's uses walk only the
|
|
562
|
+
* candidates and apply the same value tests to them they applied to every
|
|
563
|
+
* closure entry before, so their reads, facts and ledger requirements are
|
|
564
|
+
* what they were.
|
|
565
|
+
*/
|
|
566
|
+
const copySitesOf = (container) => nodeQuery('copy-sites', container);
|
|
567
|
+
const isCopySite = (stored) => (ts.isCallExpression(stored) && (definitionPlans.has(stored) || isGlobalObjectAssign(checker, stored))) ||
|
|
568
|
+
(ts.isExpression(stored) && ts.isSpreadAssignment(outermostErasureOf(stored).parent));
|
|
520
569
|
/**
|
|
521
570
|
* The named reads of `key` (and of the keys that alias it on an array)
|
|
522
571
|
* whose receiver can hold THIS container.
|
|
@@ -531,6 +580,23 @@ const createSession = (checker, flow) => {
|
|
|
531
580
|
const keyReadsOf = (container, key) => {
|
|
532
581
|
return internIn(keyReadQueries, container, key, keyedQueryKey, () => new QueryState('key-reads', container, key, undefined));
|
|
533
582
|
};
|
|
583
|
+
/**
|
|
584
|
+
* Every reference a value stored under `key` of THIS container is used at
|
|
585
|
+
* next, whatever the value: the reads of the key (named and unspelled), the
|
|
586
|
+
* cells a destructuring of the container binds it to, the loop bindings
|
|
587
|
+
* iterating an array container, and the same for each container the key's
|
|
588
|
+
* value is copied into (`Object.assign`, a spread, a `defineProperty`
|
|
589
|
+
* descriptor's `value`).
|
|
590
|
+
*
|
|
591
|
+
* None of that depends on which value was stored, and a container's key
|
|
592
|
+
* receives many: every `publication` of a (value, container, key) used to
|
|
593
|
+
* re-derive it, scanning the container's whole closure twice per
|
|
594
|
+
* evaluation, so a class instance whose closure lists every store of its
|
|
595
|
+
* methods paid that scan once per value its slots were handed. Here it is
|
|
596
|
+
* one node per (container, key), and a publication only continues its own
|
|
597
|
+
* value at each reference this node names.
|
|
598
|
+
*/
|
|
599
|
+
const keyUsesOf = (container, key) => internIn(keyUseQueries, container, key, keyedQueryKey, () => new QueryState('key-uses', container, key, undefined));
|
|
534
600
|
const targets = (call) => nodeQuery('targets', call);
|
|
535
601
|
const superTargets = (call) => nodeQuery('super-targets', call);
|
|
536
602
|
/**
|
|
@@ -858,8 +924,143 @@ const createSession = (checker, flow) => {
|
|
|
858
924
|
};
|
|
859
925
|
const slot = (root, key) => internIn(slots, root, key, keyedQueryKey, () => new QueryState('slot', root, key, undefined));
|
|
860
926
|
const storedSlot = (root, key) => internIn(storedSlots, root, key, keyedQueryKey, () => new QueryState('stored-slot', root, key, undefined));
|
|
861
|
-
|
|
862
|
-
|
|
927
|
+
/**
|
|
928
|
+
* The value a use walk is keyed by: a class instance's family token, or the
|
|
929
|
+
* root itself.
|
|
930
|
+
*
|
|
931
|
+
* A walk of a `new` root through the program asks the root's identity in
|
|
932
|
+
* exactly two places -- whether a parameter rebinding stores it (`refs`)
|
|
933
|
+
* and whether a `defineProperty` gave it a key its classes do not declare
|
|
934
|
+
* (`descriptorOf`); everything else it asks is a fact of its construction,
|
|
935
|
+
* which names the same classes for every construction of them. So the
|
|
936
|
+
* walks of every `new Vector3( ... )` in a program were one walk repeated
|
|
937
|
+
* per construction site -- a node per (site, reference) through every
|
|
938
|
+
* method the vector reaches, and on a large program most of the solve.
|
|
939
|
+
*
|
|
940
|
+
* Constructions whose construction fact names the same classes share one
|
|
941
|
+
* token (the first of them met) and one walk. The two identity questions
|
|
942
|
+
* are not answered on the shared walk: it hands each back as a gate
|
|
943
|
+
* (`gateOf`), and each root's own `closure` answers it for that root
|
|
944
|
+
* (`resolveGates`), continuing the shared walk where the root continues.
|
|
945
|
+
* Every other root is its own token, walked exactly as before.
|
|
946
|
+
*/
|
|
947
|
+
const familyTokens = new Map();
|
|
948
|
+
const familyReps = new Set();
|
|
949
|
+
/**
|
|
950
|
+
* Every object literal shares one walk the same way. The walk asks a
|
|
951
|
+
* literal about itself only through the keys it reads or stores through it
|
|
952
|
+
* (whether the literal has the key, and what holds it there), its whole key
|
|
953
|
+
* set (a spread of it, a `JSON.stringify` of it), a destructuring of it,
|
|
954
|
+
* and whether a parameter rebinding stores it. Each of those is left to the
|
|
955
|
+
* literal as a gate; everything else the walk meets -- where the literal is
|
|
956
|
+
* passed, stored, returned and published -- is the same for every literal
|
|
957
|
+
* that reaches it. On a large three.js program the uniform and option
|
|
958
|
+
* literals handed to materials were each walked through the same seven
|
|
959
|
+
* thousand uses of the renderer.
|
|
960
|
+
*/
|
|
961
|
+
let literalToken = null;
|
|
962
|
+
const literalReps = new Set();
|
|
963
|
+
const tokens = new Map();
|
|
964
|
+
const classIds = new Map();
|
|
965
|
+
const classIdOf = (owner) => {
|
|
966
|
+
let id = classIds.get(owner);
|
|
967
|
+
if (id === undefined)
|
|
968
|
+
classIds.set(owner, (id = classIds.size));
|
|
969
|
+
return id;
|
|
970
|
+
};
|
|
971
|
+
const tokenOf = (root) => {
|
|
972
|
+
let token = tokens.get(root);
|
|
973
|
+
if (token !== undefined)
|
|
974
|
+
return token;
|
|
975
|
+
token = root;
|
|
976
|
+
if (ts.isNewExpression(root) && !isFreshOrdinaryObject(root)) {
|
|
977
|
+
const alternatives = construction(root)?.alternatives;
|
|
978
|
+
if (alternatives !== undefined && alternatives.length > 0) {
|
|
979
|
+
const signature = alternatives.map(classIdOf).join(',');
|
|
980
|
+
let representative = familyTokens.get(signature);
|
|
981
|
+
if (representative === undefined) {
|
|
982
|
+
familyTokens.set(signature, (representative = root));
|
|
983
|
+
familyReps.add(root);
|
|
984
|
+
}
|
|
985
|
+
token = representative;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
else if (ts.isObjectLiteralExpression(root)) {
|
|
989
|
+
if (literalToken === null)
|
|
990
|
+
literalReps.add((literalToken = root));
|
|
991
|
+
token = literalToken;
|
|
992
|
+
}
|
|
993
|
+
tokens.set(root, token);
|
|
994
|
+
return token;
|
|
995
|
+
};
|
|
996
|
+
const isFamilyMember = (root) => familyReps.has(tokenOf(root));
|
|
997
|
+
const isLiteralGroupMember = (root) => literalReps.has(tokenOf(root));
|
|
998
|
+
/**
|
|
999
|
+
* Every construction in the program a family token stands for, from the
|
|
1000
|
+
* call index: what `family-slot` joins. Built once, and only when a slot
|
|
1001
|
+
* summary is first asked for.
|
|
1002
|
+
*/
|
|
1003
|
+
let familyMembers = null;
|
|
1004
|
+
const NO_MEMBERS = new Set();
|
|
1005
|
+
const familyMembersOf = (token) => {
|
|
1006
|
+
if (familyMembers === null) {
|
|
1007
|
+
familyMembers = new Map();
|
|
1008
|
+
for (const site of flow.calls) {
|
|
1009
|
+
if (!ts.isNewExpression(site.call) || !isFamilyMember(site.call))
|
|
1010
|
+
continue;
|
|
1011
|
+
const token = tokenOf(site.call);
|
|
1012
|
+
let members = familyMembers.get(token);
|
|
1013
|
+
if (!members)
|
|
1014
|
+
familyMembers.set(token, (members = new Set()));
|
|
1015
|
+
members.add(site.call);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return familyMembers.get(token) ?? NO_MEMBERS;
|
|
1019
|
+
};
|
|
1020
|
+
/**
|
|
1021
|
+
* One key's slots across every construction of a family: a read through a
|
|
1022
|
+
* receiver that holds all of them -- `this.x` in a vector method, `v.x` of a
|
|
1023
|
+
* parameter every vector reaches -- joins this one node instead of every
|
|
1024
|
+
* construction's own slot. A large program's vectors and colors each hold
|
|
1025
|
+
* every value their setters were ever passed, so each such read was N slots
|
|
1026
|
+
* of hundreds of values, re-read as any of them grew. Like a row
|
|
1027
|
+
* (`enumeratedSlots`) it carries its slots' grounding and owes none.
|
|
1028
|
+
*/
|
|
1029
|
+
const familySlot = (token, key) => internIn(familySlotQueries, token, key, keyedQueryKey, () => new QueryState('family-slot', token, key, undefined));
|
|
1030
|
+
const gates = new Map();
|
|
1031
|
+
const rebindingGates = new Map();
|
|
1032
|
+
const rootGates = new Map();
|
|
1033
|
+
const gateOf = (reference, declaration) => {
|
|
1034
|
+
const held = declaration === null ? rootGates : rebindingGates;
|
|
1035
|
+
let marker = held.get(reference);
|
|
1036
|
+
if (marker === undefined) {
|
|
1037
|
+
held.set(reference, (marker = ts.factory.createOmittedExpression()));
|
|
1038
|
+
gates.set(marker, { reference, declaration });
|
|
1039
|
+
}
|
|
1040
|
+
return marker;
|
|
1041
|
+
};
|
|
1042
|
+
const use = (root, reference) => {
|
|
1043
|
+
const token = tokenOf(root);
|
|
1044
|
+
return internIn(uses, token, reference, (query) => query.node, () => new QueryState('use', reference, undefined, token));
|
|
1045
|
+
};
|
|
1046
|
+
/**
|
|
1047
|
+
* Every slot of `root` a for-in head over `enumerated` binds a key of: one
|
|
1048
|
+
* row of a read like `src[ u ]`, which reads each root it can reach under
|
|
1049
|
+
* every key the head enumerates.
|
|
1050
|
+
*
|
|
1051
|
+
* Read inline, such an access joined roots x keys slots and re-read all of
|
|
1052
|
+
* them whenever any one grew -- three's `cloneUniforms` reading every
|
|
1053
|
+
* uniform group under every uniform name, thousands of slots per
|
|
1054
|
+
* evaluation. As a row per root, a slot that grows re-reads its row, and
|
|
1055
|
+
* the access re-reads only its rows. The row is not value-carrying: it
|
|
1056
|
+
* carries its slots' grounding through to the access and owes none of its
|
|
1057
|
+
* own, so a row of a root with no key yet is no unwitnessed cycle member.
|
|
1058
|
+
*/
|
|
1059
|
+
const enumeratedSlots = (enumerated, root) => internIn(enumeratedSlotQueries, root, enumerated, (query) => query.node, () => new QueryState('enumerated-slots', enumerated, undefined, root));
|
|
1060
|
+
/** `reference` walked with the root itself: a family walk's root gate. */
|
|
1061
|
+
const rootUse = (root, reference) => internIn(rootUses, root, reference, (query) => query.node, () => new QueryState('root-use', reference, undefined, root));
|
|
1062
|
+
const publication = (stored, container, key) => {
|
|
1063
|
+
const root = tokenOf(stored);
|
|
863
1064
|
let containers = publications.get(root);
|
|
864
1065
|
if (!containers)
|
|
865
1066
|
publications.set(root, (containers = new Map()));
|
|
@@ -928,7 +1129,6 @@ const createSession = (checker, flow) => {
|
|
|
928
1129
|
(ts.isPrefixUnaryExpression(parent) && parent.operator === ts.SyntaxKind.ExclamationToken) ||
|
|
929
1130
|
(ts.isIfStatement(parent) && parent.expression === reference));
|
|
930
1131
|
};
|
|
931
|
-
const NO_VALUES = new Set();
|
|
932
1132
|
/**
|
|
933
1133
|
* `return this` in a body's own frame (not in a nested arrow, whose return
|
|
934
1134
|
* is the arrow's): the completion is the frame's receiver.
|
|
@@ -1266,7 +1466,9 @@ const createSession = (checker, flow) => {
|
|
|
1266
1466
|
* only as the name it is declared or stored under: `value` of a property
|
|
1267
1467
|
* access reads `slot(root, key)`, and a store into that slot is spelled with
|
|
1268
1468
|
* the same key, so a callee spelling some OTHER name cannot produce this body
|
|
1269
|
-
* however the graph solves
|
|
1469
|
+
* however the graph solves -- unless a cell got it from another cell (`const
|
|
1470
|
+
* g = f`, an argument, an element): the body's closure lists those calls
|
|
1471
|
+
* for `case 'callers'` (`visitUse`). Three transfers -- a parameter's frame, a
|
|
1270
1472
|
* receiver's frame and a completion's use -- asked anyway, by observing
|
|
1271
1473
|
* `targets` of EVERY call in the program, per query. That forced the entire
|
|
1272
1474
|
* program's dispatch graph from each of them and was a large program's compile time:
|
|
@@ -1297,6 +1499,17 @@ const createSession = (checker, flow) => {
|
|
|
1297
1499
|
*/
|
|
1298
1500
|
let calleeNames = null;
|
|
1299
1501
|
let unspelledCallees = [];
|
|
1502
|
+
const calleeNameOf = (site) => {
|
|
1503
|
+
const own = ts.isCallExpression(site.call) ? candidateOrdinaryOwnCallableOperandsOf(site.call) : null;
|
|
1504
|
+
const callee = site.operands ? unwrapErasedExpression(own?.callee ?? site.operands.callee) : null;
|
|
1505
|
+
return callee
|
|
1506
|
+
? ts.isIdentifier(callee)
|
|
1507
|
+
? callee.text
|
|
1508
|
+
: ts.isPropertyAccessExpression(callee) || ts.isElementAccessExpression(callee)
|
|
1509
|
+
? accessKey(callee)
|
|
1510
|
+
: null
|
|
1511
|
+
: null;
|
|
1512
|
+
};
|
|
1300
1513
|
const buildCalleeIndex = () => {
|
|
1301
1514
|
if (calleeNames !== null)
|
|
1302
1515
|
return calleeNames;
|
|
@@ -1308,15 +1521,7 @@ const createSession = (checker, flow) => {
|
|
|
1308
1521
|
// never names.
|
|
1309
1522
|
if (!ts.isCallExpression(site.call) && !ts.isNewExpression(site.call))
|
|
1310
1523
|
continue;
|
|
1311
|
-
const
|
|
1312
|
-
const callee = site.operands ? unwrapErasedExpression(own?.callee ?? site.operands.callee) : null;
|
|
1313
|
-
const name = callee
|
|
1314
|
-
? ts.isIdentifier(callee)
|
|
1315
|
-
? callee.text
|
|
1316
|
-
: ts.isPropertyAccessExpression(callee) || ts.isElementAccessExpression(callee)
|
|
1317
|
-
? accessKey(callee)
|
|
1318
|
-
: null
|
|
1319
|
-
: null;
|
|
1524
|
+
const name = calleeNameOf(site);
|
|
1320
1525
|
if (name === null)
|
|
1321
1526
|
unspelled.push(site);
|
|
1322
1527
|
else {
|
|
@@ -1679,12 +1884,15 @@ const createSession = (checker, flow) => {
|
|
|
1679
1884
|
* head walks keys no root spells. That obligation is deferred to the ledger,
|
|
1680
1885
|
* exactly as the legacy key-set authority defers it; with no ledger to carry
|
|
1681
1886
|
* it there is nothing to discharge it later, so the enumeration refuses.
|
|
1887
|
+
*
|
|
1888
|
+
* This is the transfer of the head's own `enumerated-keys` node, never run
|
|
1889
|
+
* inline by an access: every `values[ key ]` and `this[ key ]` in the loop
|
|
1890
|
+
* body is asked once per root that reaches it, so an inline walk of every
|
|
1891
|
+
* enumerated root -- every options literal passed to any constructor of a
|
|
1892
|
+
* family -- made the work roots x roots, and each walk paid for every root's
|
|
1893
|
+
* own-key and holder checks again.
|
|
1682
1894
|
*/
|
|
1683
|
-
const enumeratedKeysOf = (
|
|
1684
|
-
if (!deferredIntrinsicProtocolLedgerOf(flow)?.require('Object', access)) {
|
|
1685
|
-
fail('undeferrable-enumeration-protocol', access);
|
|
1686
|
-
return [];
|
|
1687
|
-
}
|
|
1895
|
+
const enumeratedKeysOf = (enumerated, read, fail, sealing, ownKeysOf) => {
|
|
1688
1896
|
const keys = new Set();
|
|
1689
1897
|
const roots = read(value(enumerated));
|
|
1690
1898
|
for (const root of roots) {
|
|
@@ -1709,7 +1917,7 @@ const createSession = (checker, flow) => {
|
|
|
1709
1917
|
}
|
|
1710
1918
|
if (sealing && roots.size === 0)
|
|
1711
1919
|
fail('unresolved-enumeration', enumerated);
|
|
1712
|
-
return
|
|
1920
|
+
return keys;
|
|
1713
1921
|
};
|
|
1714
1922
|
// One object per (node, reason) for the whole session. The solver compares
|
|
1715
1923
|
// a re-seal's causes by identity, and a fresh literal per evaluation made
|
|
@@ -1750,14 +1958,55 @@ const createSession = (checker, flow) => {
|
|
|
1750
1958
|
* one evaluation's own (`seeded`, and the causes and grounding a seal reads
|
|
1751
1959
|
* back through `outcome`) or a per-node cache kept in a map below.
|
|
1752
1960
|
*/
|
|
1961
|
+
const transferInputs = new Map();
|
|
1962
|
+
/** Counts transfers and seals: what `obligations` keeps is good until the next one. */
|
|
1963
|
+
const graphRevision = { value: 0 };
|
|
1753
1964
|
const definition = (() => {
|
|
1754
1965
|
// A node's map is allocated on its first answer: most nodes never ask an
|
|
1755
1966
|
// own-key question.
|
|
1756
1967
|
const ownKeysAnswersByQuery = new Map();
|
|
1757
|
-
|
|
1968
|
+
/**
|
|
1969
|
+
* Per node, how many of each dependency's facts its transfers have already
|
|
1970
|
+
* returned (`add`). Only dependencies past `DELTA_MINIMUM` are tracked: a
|
|
1971
|
+
* small one costs less to re-add than to look up.
|
|
1972
|
+
*/
|
|
1973
|
+
const addedThrough = new Map();
|
|
1974
|
+
const gateLogs = new Map();
|
|
1975
|
+
/**
|
|
1976
|
+
* Per reader, each family it has found every construction of among its
|
|
1977
|
+
* receivers (`true`), or how many receivers it held when it last did not
|
|
1978
|
+
* (a receiver set only grows, so a family once covered stays covered).
|
|
1979
|
+
*/
|
|
1980
|
+
const familyCoverage = new Map();
|
|
1981
|
+
const gateLogOf = (query) => {
|
|
1982
|
+
let log = gateLogs.get(query);
|
|
1983
|
+
if (log === undefined)
|
|
1984
|
+
gateLogs.set(query, (log = { list: [], seen: new Set() }));
|
|
1985
|
+
return log;
|
|
1986
|
+
};
|
|
1987
|
+
const evaluate = (query, required, observeFrom, holdersOfFrom, sealing, outcome) => {
|
|
1758
1988
|
let seeded = false;
|
|
1759
1989
|
let ownKeysAnswers = ownKeysAnswersByQuery.get(query) ?? null;
|
|
1760
1990
|
const facts = new Set();
|
|
1991
|
+
// A transfer's inputs, kept for `joinedOnly` (seals keep none).
|
|
1992
|
+
const inputs = outcome === null ? { tested: [], testedSizes: [], holders: [], joined: [], joinedSizes: [] } : null;
|
|
1993
|
+
const joinedHere = inputs === null ? null : new Set();
|
|
1994
|
+
const tested = (held) => {
|
|
1995
|
+
if (inputs !== null) {
|
|
1996
|
+
inputs.tested.push(held);
|
|
1997
|
+
inputs.testedSizes.push(held.size);
|
|
1998
|
+
}
|
|
1999
|
+
return held;
|
|
2000
|
+
};
|
|
2001
|
+
const observe = (dependency) => tested(observeFrom(dependency));
|
|
2002
|
+
const holdersOf = (fact) => {
|
|
2003
|
+
const found = holdersOfFrom(fact);
|
|
2004
|
+
if (inputs === null)
|
|
2005
|
+
return found;
|
|
2006
|
+
const list = Array.isArray(found) ? found : [...found];
|
|
2007
|
+
inputs.holders.push([fact, list.length]);
|
|
2008
|
+
return list;
|
|
2009
|
+
};
|
|
1761
2010
|
const causes = [];
|
|
1762
2011
|
const grounding = new Set();
|
|
1763
2012
|
const fail = (reason, node = query.node) => {
|
|
@@ -1775,16 +2024,114 @@ const createSession = (checker, flow) => {
|
|
|
1775
2024
|
// single self-time entry in a large program's profile once the state lookup
|
|
1776
2025
|
// beside it was gone -- and a duplicate of the whole proof graph in a
|
|
1777
2026
|
// solve that was already running out of heap.
|
|
1778
|
-
const read = required;
|
|
2027
|
+
const read = (dependency) => tested(required(dependency));
|
|
2028
|
+
/** A required edge whose facts this transfer does not look at: an input of its answer's completeness only. */
|
|
2029
|
+
const need = (dependency) => void required(dependency);
|
|
1779
2030
|
const carry = (dependency) => {
|
|
1780
2031
|
grounding.add(dependency);
|
|
1781
2032
|
return read(dependency);
|
|
1782
2033
|
};
|
|
1783
|
-
/**
|
|
1784
|
-
|
|
2034
|
+
/**
|
|
2035
|
+
* `add(read( dependency ))`: the dependency's facts become this node's and
|
|
2036
|
+
* nothing else is asked of them, so it is a joined input rather than a
|
|
2037
|
+
* tested one (`joinedOnly`).
|
|
2038
|
+
*/
|
|
2039
|
+
const join = (dependency) => {
|
|
2040
|
+
const held = required(dependency);
|
|
2041
|
+
if (joinedHere !== null && held instanceof FactState && !joinedHere.has(held)) {
|
|
2042
|
+
joinedHere.add(held);
|
|
2043
|
+
inputs.joined.push(held);
|
|
2044
|
+
inputs.joinedSizes.push(held.size);
|
|
2045
|
+
}
|
|
2046
|
+
add(held);
|
|
2047
|
+
};
|
|
2048
|
+
const joinCarried = (dependency) => {
|
|
2049
|
+
grounding.add(dependency);
|
|
2050
|
+
join(dependency);
|
|
2051
|
+
};
|
|
2052
|
+
/** `join(use(root, reference))`, without minting the node for a use that does nothing (`inertUse`). */
|
|
2053
|
+
const joinUse = (root, reference) => {
|
|
2054
|
+
if (!inertUse(reference))
|
|
2055
|
+
join(use(root, reference));
|
|
2056
|
+
};
|
|
2057
|
+
/**
|
|
2058
|
+
* The gates this node answers for its own root (`resolveGates`), when it
|
|
2059
|
+
* is the closure of a family member or reads a family walk for one: a
|
|
2060
|
+
* gate it adds is kept here instead of becoming a fact.
|
|
2061
|
+
*/
|
|
2062
|
+
let gating = null;
|
|
2063
|
+
/** This node walks a family token: identity questions become gates. */
|
|
2064
|
+
let familyWalk = false;
|
|
2065
|
+
/** This node walks an object literal group's token: a key the group does not spell, or its key set, becomes a gate. */
|
|
2066
|
+
let literalWalk = false;
|
|
2067
|
+
/** The reference a `use` node walks: a root gate re-walks it. */
|
|
2068
|
+
let walkedReference = null;
|
|
1785
2069
|
const add = (values) => {
|
|
1786
|
-
|
|
1787
|
-
|
|
2070
|
+
// A transfer only has to hand back what this node has not published
|
|
2071
|
+
// yet: the solver adds every fact a transfer returns to the node and
|
|
2072
|
+
// keeps it, and a dependency's facts only grow, in insertion order.
|
|
2073
|
+
// So a dependency read again is added from where this node's last
|
|
2074
|
+
// transfer stopped. Re-adding it whole made each re-evaluation of a
|
|
2075
|
+
// node joining many slots (`this.x` read across every instance of a
|
|
2076
|
+
// class, each slot holding every value its setters were passed) copy
|
|
2077
|
+
// and re-test every fact again -- ~95% of all facts added on a large
|
|
2078
|
+
// program. A seal still builds its full answer: it reads `facts`.
|
|
2079
|
+
const whole = outcome !== null || !(values instanceof FactState) || values.size <= DELTA_MINIMUM;
|
|
2080
|
+
if (whole && gating === null) {
|
|
2081
|
+
for (const held of values)
|
|
2082
|
+
facts.add(held);
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
let before = 0;
|
|
2086
|
+
if (!whole) {
|
|
2087
|
+
let through = addedThrough.get(query);
|
|
2088
|
+
if (through === undefined)
|
|
2089
|
+
addedThrough.set(query, (through = new Map()));
|
|
2090
|
+
before = through.get(values) ?? 0;
|
|
2091
|
+
const size = values.size;
|
|
2092
|
+
if (before === size)
|
|
2093
|
+
return;
|
|
2094
|
+
through.set(values, size);
|
|
2095
|
+
}
|
|
2096
|
+
let at = 0;
|
|
2097
|
+
if (gating === null) {
|
|
2098
|
+
for (const held of values)
|
|
2099
|
+
if (at++ >= before)
|
|
2100
|
+
facts.add(held);
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
for (const held of values) {
|
|
2104
|
+
if (at++ < before)
|
|
2105
|
+
continue;
|
|
2106
|
+
if (held.kind === ts.SyntaxKind.OmittedExpression && gates.has(held)) {
|
|
2107
|
+
if (!gating.seen.has(held)) {
|
|
2108
|
+
gating.seen.add(held);
|
|
2109
|
+
gating.list.push(held);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
else
|
|
2113
|
+
facts.add(held);
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
/**
|
|
2117
|
+
* Answers every gate the family walks read by this node have handed back,
|
|
2118
|
+
* for `root`: a rebinding gate continues the walk past the rebinding when
|
|
2119
|
+
* one of the parameter's rebindings stores `root` (the test `refs` makes
|
|
2120
|
+
* on a root's own walk), and a root gate re-walks its reference with
|
|
2121
|
+
* `root` itself. What either reads can hand back further gates, answered
|
|
2122
|
+
* in the same pass. The log outlives the evaluation, because `add` hands
|
|
2123
|
+
* back only what a dependency gained, while every gate is asked again:
|
|
2124
|
+
* its answer can change as the rebindings' values grow.
|
|
2125
|
+
*/
|
|
2126
|
+
const resolveGates = (root) => {
|
|
2127
|
+
const log = gating;
|
|
2128
|
+
for (let at = 0; at < log.list.length; at++) {
|
|
2129
|
+
const gate = gates.get(log.list[at]);
|
|
2130
|
+
if (gate.declaration === null)
|
|
2131
|
+
join(rootUse(root, gate.reference));
|
|
2132
|
+
else if (!parameterRebindingsOf(gate.declaration).every((write) => write.value !== null && !read(value(write.value)).has(root)))
|
|
2133
|
+
joinUse(root, gate.reference);
|
|
2134
|
+
}
|
|
1788
2135
|
};
|
|
1789
2136
|
/**
|
|
1790
2137
|
* A member call whose receiver holds nothing but `null`/`undefined`
|
|
@@ -1903,6 +2250,11 @@ const createSession = (checker, flow) => {
|
|
|
1903
2250
|
stamps.push(...kept.stamps);
|
|
1904
2251
|
for (const stamps of holderStampLists)
|
|
1905
2252
|
stamps.push(...kept.holderStamps);
|
|
2253
|
+
// Replayed without being read again, so the sets the answer was read
|
|
2254
|
+
// from are this transfer's inputs too (the holders are asked again in
|
|
2255
|
+
// `holdersUnchanged`).
|
|
2256
|
+
for (const [held] of kept.stamps)
|
|
2257
|
+
tested(held);
|
|
1906
2258
|
ownKeys.set(root, kept.keys);
|
|
1907
2259
|
return kept.keys;
|
|
1908
2260
|
}
|
|
@@ -1969,6 +2321,13 @@ const createSession = (checker, flow) => {
|
|
|
1969
2321
|
((ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) &&
|
|
1970
2322
|
[...holdersOf(root)].some((holder) => (computedWriteEdgesByReceiver.get(holder) ?? []).some((edge) => keysOf(edge.access).includes(key)))) ||
|
|
1971
2323
|
writesTo(root, definitionReceivers.get(key) ?? []);
|
|
2324
|
+
/**
|
|
2325
|
+
* Whether `descriptorOf` of a construction would ask which roots a
|
|
2326
|
+
* `defineProperty` targets -- the one part of it that is not a fact of
|
|
2327
|
+
* the construction's classes, and so the one a family walk cannot answer
|
|
2328
|
+
* for every member at once.
|
|
2329
|
+
*/
|
|
2330
|
+
const definitionDecides = (root, key) => isObjectRoot(root) && !descriptor(root, key) && (definitionReceivers.get(key)?.length ?? 0) > 0;
|
|
1972
2331
|
/**
|
|
1973
2332
|
* Every element key of the arrays an access could be reaching.
|
|
1974
2333
|
*
|
|
@@ -2020,8 +2379,14 @@ const createSession = (checker, flow) => {
|
|
|
2020
2379
|
if (!ts.isElementAccessExpression(access))
|
|
2021
2380
|
return [];
|
|
2022
2381
|
const enumerated = enumerationHeadOf(access.argumentExpression);
|
|
2023
|
-
if (enumerated !== null)
|
|
2024
|
-
|
|
2382
|
+
if (enumerated !== null) {
|
|
2383
|
+
if (!deferredIntrinsicProtocolLedgerOf(flow)?.require('Object', access)) {
|
|
2384
|
+
fail('undeferrable-enumeration-protocol', access);
|
|
2385
|
+
return [];
|
|
2386
|
+
}
|
|
2387
|
+
const head = nodeQuery('enumerated-keys', enumerated);
|
|
2388
|
+
return enumeratedKeyListOf(head, read(head));
|
|
2389
|
+
}
|
|
2025
2390
|
const keyReference = unwrapErasedExpression(access.argumentExpression);
|
|
2026
2391
|
const keyDeclaration = ts.isIdentifier(keyReference) ? flow.targetOf(keyReference)?.declaration : undefined;
|
|
2027
2392
|
if (keyDeclaration && ts.isVariableDeclaration(keyDeclaration)) {
|
|
@@ -2088,18 +2453,89 @@ const createSession = (checker, flow) => {
|
|
|
2088
2453
|
fail('unresolved-property-key', access);
|
|
2089
2454
|
return [...keys];
|
|
2090
2455
|
};
|
|
2456
|
+
/** The families whose slots this evaluation has read whole (`readSlotsOf`). */
|
|
2457
|
+
const familiesRead = new Set();
|
|
2458
|
+
/** The family whose every construction `receivers` holds, when `root` is one of them: its slots can be read whole. */
|
|
2459
|
+
const coveringFamilyOf = (root, receivers) => {
|
|
2460
|
+
if (!isFamilyMember(root))
|
|
2461
|
+
return null;
|
|
2462
|
+
const token = tokenOf(root);
|
|
2463
|
+
const members = familyMembersOf(token);
|
|
2464
|
+
if (!members.has(root))
|
|
2465
|
+
return null;
|
|
2466
|
+
let known = familyCoverage.get(query);
|
|
2467
|
+
const held = known?.get(token);
|
|
2468
|
+
if (held === true)
|
|
2469
|
+
return token;
|
|
2470
|
+
if (held === receivers.size)
|
|
2471
|
+
return null;
|
|
2472
|
+
let covered = members.size > 1;
|
|
2473
|
+
if (covered)
|
|
2474
|
+
for (const member of members)
|
|
2475
|
+
if (!receivers.has(member))
|
|
2476
|
+
covered = false;
|
|
2477
|
+
if (known === undefined)
|
|
2478
|
+
familyCoverage.set(query, (known = new Map()));
|
|
2479
|
+
known.set(token, covered ? true : receivers.size);
|
|
2480
|
+
return covered ? token : null;
|
|
2481
|
+
};
|
|
2482
|
+
/**
|
|
2483
|
+
* What `access` reads off `root`, one of `receivers`, under `keys` (its
|
|
2484
|
+
* `keysOf`): each slot; or, for a key bound by a for-in head, the
|
|
2485
|
+
* root's row of the head's keys (`enumeratedSlots`); or, when
|
|
2486
|
+
* `receivers` holds every construction of the root's family, the
|
|
2487
|
+
* family's slot (`familySlot`), once for all of them. A callable
|
|
2488
|
+
* object's own data is proven per read, so it is read key by key.
|
|
2489
|
+
*/
|
|
2490
|
+
const readSlotsOf = (root, receivers, keys, access) => {
|
|
2491
|
+
if (isSourceCallableObject(root)) {
|
|
2492
|
+
for (const key of keys) {
|
|
2493
|
+
if (key !== 'name' && key !== 'length' && sourceCallableOwnDataWriteOf(checker, flow, root, key, access) === null)
|
|
2494
|
+
fail('unproven-callable-data-read', access);
|
|
2495
|
+
else
|
|
2496
|
+
joinCarried(slot(root, key));
|
|
2497
|
+
}
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
const enumerated = keys.length > 0 && ts.isElementAccessExpression(access) && accessKey(access) === null
|
|
2501
|
+
? enumerationHeadOf(access.argumentExpression)
|
|
2502
|
+
: null;
|
|
2503
|
+
if (enumerated !== null) {
|
|
2504
|
+
joinCarried(enumeratedSlots(enumerated, root));
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
const family = coveringFamilyOf(root, receivers);
|
|
2508
|
+
if (family === null)
|
|
2509
|
+
for (const key of keys)
|
|
2510
|
+
joinCarried(slot(root, key));
|
|
2511
|
+
else if (!familiesRead.has(family)) {
|
|
2512
|
+
familiesRead.add(family);
|
|
2513
|
+
for (const key of keys)
|
|
2514
|
+
joinCarried(familySlot(family, key));
|
|
2515
|
+
}
|
|
2516
|
+
};
|
|
2517
|
+
// A root this lane cannot read refuses the binding, and the literal
|
|
2518
|
+
// roots' entries are still returned. The solver keeps every fact a
|
|
2519
|
+
// transfer ever published, so answering null once such a root arrived
|
|
2520
|
+
// kept whatever entries had been read before it, and how many depended
|
|
2521
|
+
// on the schedule (sakura 55269dd's `for (const m of mats)`, where
|
|
2522
|
+
// `mats` also holds `o.material` itself). `readers` observes the
|
|
2523
|
+
// refused cell without requiring it, so a missing entry there was a
|
|
2524
|
+
// missing reader.
|
|
2091
2525
|
const iterationValuesAt = (source) => {
|
|
2092
2526
|
const elements = [];
|
|
2093
2527
|
for (const root of read(value(source))) {
|
|
2094
2528
|
if (!ts.isArrayLiteralExpression(root) ||
|
|
2095
2529
|
root.elements.some((element) => ts.isSpreadElement(element) || ts.isOmittedExpression(element)) ||
|
|
2096
|
-
deferredIntrinsicProtocolLedgerOf(flow)?.require('Array', source) !== true)
|
|
2097
|
-
|
|
2530
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.require('Array', source) !== true) {
|
|
2531
|
+
fail('unmodelled-iteration-source', source);
|
|
2532
|
+
continue;
|
|
2533
|
+
}
|
|
2098
2534
|
// This bounded lane transports the original literal's entries.
|
|
2099
2535
|
// Mutating its contents/length needs the full indexed storage plan.
|
|
2100
2536
|
for (const use of read(closure(root)))
|
|
2101
2537
|
if ((ts.isPropertyAccessExpression(use) || ts.isElementAccessExpression(use)) && writeEdgeByAccess.has(use))
|
|
2102
|
-
|
|
2538
|
+
fail('unmodelled-iteration-source', use);
|
|
2103
2539
|
for (const element of root.elements)
|
|
2104
2540
|
if (!ts.isSpreadElement(element) && !ts.isOmittedExpression(element))
|
|
2105
2541
|
elements.push(element);
|
|
@@ -2133,21 +2569,36 @@ const createSession = (checker, flow) => {
|
|
|
2133
2569
|
return null;
|
|
2134
2570
|
return importerMentions(declaration) !== null ? null : 'export-importers-unenumerable';
|
|
2135
2571
|
};
|
|
2572
|
+
/** The references `refs` walks for a declaration no rebinding applies to: every read of the cell, and its importers' mentions. */
|
|
2573
|
+
const referencesOf = (declaration) => {
|
|
2574
|
+
const found = [];
|
|
2575
|
+
for (const reference of flow.referencesToDeclaration(declaration))
|
|
2576
|
+
if (reference !== ts.getNameOfDeclaration(declaration) && !isTypePositionReference(reference))
|
|
2577
|
+
found.push(reference);
|
|
2578
|
+
for (const reference of importerMentions(declaration) ?? [])
|
|
2579
|
+
found.push(reference);
|
|
2580
|
+
return found;
|
|
2581
|
+
};
|
|
2136
2582
|
const refs = (root, declaration) => {
|
|
2137
2583
|
for (const reference of flow.referencesToDeclaration(declaration)) {
|
|
2138
2584
|
if (reference === ts.getNameOfDeclaration(declaration) || isTypePositionReference(reference))
|
|
2139
2585
|
continue;
|
|
2140
2586
|
// Past an unconditional rebinding the cell holds only what a write
|
|
2141
2587
|
// after entry stored; a root none of those writes stores is no
|
|
2142
|
-
// longer reachable through it.
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2588
|
+
// longer reachable through it. Whether one stores it is a question
|
|
2589
|
+
// about the root, so a family walk leaves it to each root.
|
|
2590
|
+
if (ts.isParameter(declaration) && readsAfterRebinding(declaration, reference)) {
|
|
2591
|
+
if (familyWalk || literalWalk) {
|
|
2592
|
+
facts.add(gateOf(reference, declaration));
|
|
2593
|
+
continue;
|
|
2594
|
+
}
|
|
2595
|
+
if (parameterRebindingsOf(declaration).every((write) => write.value !== null && !read(value(write.value)).has(root)))
|
|
2596
|
+
continue;
|
|
2597
|
+
}
|
|
2598
|
+
joinUse(root, reference);
|
|
2148
2599
|
}
|
|
2149
2600
|
for (const reference of importerMentions(declaration) ?? [])
|
|
2150
|
-
|
|
2601
|
+
joinUse(root, reference);
|
|
2151
2602
|
};
|
|
2152
2603
|
/**
|
|
2153
2604
|
* A binding pattern taken apart over this value: every element reads one
|
|
@@ -2166,6 +2617,16 @@ const createSession = (checker, flow) => {
|
|
|
2166
2617
|
fail('non-object-destructured-container', pattern);
|
|
2167
2618
|
return;
|
|
2168
2619
|
}
|
|
2620
|
+
if ((familyWalk || literalWalk) &&
|
|
2621
|
+
pattern.elements.some((element) => {
|
|
2622
|
+
if (ts.isOmittedExpression(element) || element.dotDotDotToken)
|
|
2623
|
+
return false;
|
|
2624
|
+
const key = bindingElementKey(element);
|
|
2625
|
+
return key !== null && (literalWalk || definitionDecides(root, key));
|
|
2626
|
+
})) {
|
|
2627
|
+
facts.add(gateOf(walkedReference, null));
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2169
2630
|
for (const element of pattern.elements) {
|
|
2170
2631
|
if (ts.isOmittedExpression(element))
|
|
2171
2632
|
continue;
|
|
@@ -2201,7 +2662,7 @@ const createSession = (checker, flow) => {
|
|
|
2201
2662
|
return false;
|
|
2202
2663
|
for (const setter of bodies)
|
|
2203
2664
|
for (const reference of flow.receiverReferencesToDeclaration(setter))
|
|
2204
|
-
|
|
2665
|
+
joinUse(root, reference);
|
|
2205
2666
|
return true;
|
|
2206
2667
|
};
|
|
2207
2668
|
/**
|
|
@@ -2283,7 +2744,7 @@ const createSession = (checker, flow) => {
|
|
|
2283
2744
|
continue;
|
|
2284
2745
|
if (writeEdgeByAccess.has(fact) || !keysOf(fact).includes(key))
|
|
2285
2746
|
continue;
|
|
2286
|
-
|
|
2747
|
+
joinUse(root, fact);
|
|
2287
2748
|
}
|
|
2288
2749
|
};
|
|
2289
2750
|
const setterStores = (setter) => {
|
|
@@ -2328,7 +2789,7 @@ const createSession = (checker, flow) => {
|
|
|
2328
2789
|
if (write.value === null || !['property-assignment', 'index-assignment', 'logical-assignment'].includes(write.edge))
|
|
2329
2790
|
fail('unmodelled-setter-store', write.site);
|
|
2330
2791
|
else
|
|
2331
|
-
|
|
2792
|
+
joinCarried(value(write.value));
|
|
2332
2793
|
}
|
|
2333
2794
|
};
|
|
2334
2795
|
/**
|
|
@@ -2373,7 +2834,7 @@ const createSession = (checker, flow) => {
|
|
|
2373
2834
|
continue;
|
|
2374
2835
|
}
|
|
2375
2836
|
for (const mention of spread)
|
|
2376
|
-
|
|
2837
|
+
joinUse(root, mention);
|
|
2377
2838
|
const parameter = runtimeParametersOf(body)[position];
|
|
2378
2839
|
if (parameter?.dotDotDotToken)
|
|
2379
2840
|
fail('rest-frame', parameter);
|
|
@@ -2397,12 +2858,12 @@ const createSession = (checker, flow) => {
|
|
|
2397
2858
|
// says nothing about where `this` goes.
|
|
2398
2859
|
if (!ts.isArrowFunction(body)) {
|
|
2399
2860
|
for (const reference of flow.receiverReferencesToDeclaration(body))
|
|
2400
|
-
|
|
2861
|
+
joinUse(root, reference);
|
|
2401
2862
|
// `return this`: the call evaluates to its own receiver, so the
|
|
2402
2863
|
// root comes back out HERE, at the call it entered through --
|
|
2403
2864
|
// see `returnsOwnReceiver`.
|
|
2404
2865
|
if (returnsOwnReceiver(body) && callableCompletionSummaryOf(flow, body)?.execution === 'sync')
|
|
2405
|
-
|
|
2866
|
+
joinUse(root, site.call);
|
|
2406
2867
|
}
|
|
2407
2868
|
}
|
|
2408
2869
|
else {
|
|
@@ -2412,7 +2873,7 @@ const createSession = (checker, flow) => {
|
|
|
2412
2873
|
continue;
|
|
2413
2874
|
}
|
|
2414
2875
|
for (const mention of mentions)
|
|
2415
|
-
|
|
2876
|
+
joinUse(root, mention);
|
|
2416
2877
|
const parameter = runtimeParametersOf(body)[position];
|
|
2417
2878
|
if (parameter?.dotDotDotToken)
|
|
2418
2879
|
fail('rest-frame', parameter);
|
|
@@ -2434,7 +2895,7 @@ const createSession = (checker, flow) => {
|
|
|
2434
2895
|
const positioned = outermostErasureOf(reference);
|
|
2435
2896
|
if (positioned !== reference) {
|
|
2436
2897
|
if (ts.isExpression(positioned))
|
|
2437
|
-
|
|
2898
|
+
joinUse(root, positioned);
|
|
2438
2899
|
else
|
|
2439
2900
|
fail('unindexed-use', positioned);
|
|
2440
2901
|
return;
|
|
@@ -2468,7 +2929,7 @@ const createSession = (checker, flow) => {
|
|
|
2468
2929
|
fail('unmatched-commonjs-export', reference);
|
|
2469
2930
|
else
|
|
2470
2931
|
for (const alias of moduleUses)
|
|
2471
|
-
|
|
2932
|
+
joinUse(root, alias);
|
|
2472
2933
|
return;
|
|
2473
2934
|
}
|
|
2474
2935
|
const left = unwrapNaming(parent.left);
|
|
@@ -2498,8 +2959,8 @@ const createSession = (checker, flow) => {
|
|
|
2498
2959
|
fail('unproven-intrinsic-member-installation', left);
|
|
2499
2960
|
else
|
|
2500
2961
|
for (const access of installed.reads)
|
|
2501
|
-
|
|
2502
|
-
|
|
2962
|
+
joinUse(root, access);
|
|
2963
|
+
joinUse(root, parent);
|
|
2503
2964
|
return;
|
|
2504
2965
|
}
|
|
2505
2966
|
const keys = keysOf(left);
|
|
@@ -2519,13 +2980,13 @@ const createSession = (checker, flow) => {
|
|
|
2519
2980
|
}
|
|
2520
2981
|
for (const key of keys) {
|
|
2521
2982
|
if (descriptorOf(container, key)) {
|
|
2522
|
-
|
|
2983
|
+
join(publication(root, container, key));
|
|
2523
2984
|
continue;
|
|
2524
2985
|
}
|
|
2525
2986
|
// A store to an accessor key hands the value to the
|
|
2526
2987
|
// SETTER's parameter, never to a slot of the container.
|
|
2527
2988
|
if (ts.isNewExpression(container) && dataStoreOf(container, key)) {
|
|
2528
|
-
|
|
2989
|
+
join(publication(root, container, key));
|
|
2529
2990
|
continue;
|
|
2530
2991
|
}
|
|
2531
2992
|
const setters = ts.isNewExpression(container) ? settersOf(container, key) : null;
|
|
@@ -2544,14 +3005,14 @@ const createSession = (checker, flow) => {
|
|
|
2544
3005
|
}
|
|
2545
3006
|
else
|
|
2546
3007
|
fail('unmodelled-store', left);
|
|
2547
|
-
|
|
3008
|
+
joinUse(root, parent);
|
|
2548
3009
|
return;
|
|
2549
3010
|
}
|
|
2550
3011
|
if (parent.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken ||
|
|
2551
3012
|
parent.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
|
|
2552
3013
|
parent.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
|
|
2553
3014
|
parent.operatorToken.kind === ts.SyntaxKind.CommaToken) {
|
|
2554
|
-
|
|
3015
|
+
joinUse(root, parent);
|
|
2555
3016
|
return;
|
|
2556
3017
|
}
|
|
2557
3018
|
if (parent.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
@@ -2571,7 +3032,7 @@ const createSession = (checker, flow) => {
|
|
|
2571
3032
|
}
|
|
2572
3033
|
if (ts.isConditionalExpression(parent)) {
|
|
2573
3034
|
if (parent.condition !== reference)
|
|
2574
|
-
|
|
3035
|
+
joinUse(root, parent);
|
|
2575
3036
|
return;
|
|
2576
3037
|
}
|
|
2577
3038
|
if (ts.isPropertyAssignment(parent) && parent.initializer === reference) {
|
|
@@ -2579,10 +3040,14 @@ const createSession = (checker, flow) => {
|
|
|
2579
3040
|
if (key === null || key === '__proto__')
|
|
2580
3041
|
fail('computed-publication', parent);
|
|
2581
3042
|
else
|
|
2582
|
-
|
|
3043
|
+
join(publication(root, parent.parent, key));
|
|
2583
3044
|
return;
|
|
2584
3045
|
}
|
|
2585
3046
|
if (ts.isSpreadAssignment(parent) && parent.expression === reference && ts.isObjectLiteralExpression(root)) {
|
|
3047
|
+
if (literalWalk) {
|
|
3048
|
+
facts.add(gateOf(reference, null));
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
2586
3051
|
// CopyDataProperties observes own data slots without retaining the
|
|
2587
3052
|
// source owner. Copied identities continue through publication below;
|
|
2588
3053
|
// the same complete key/storage queries still reject opaque readers.
|
|
@@ -2590,13 +3055,13 @@ const createSession = (checker, flow) => {
|
|
|
2590
3055
|
if (!ts.isStringLiteral(key))
|
|
2591
3056
|
fail('unmodelled-own-key-value', root);
|
|
2592
3057
|
else
|
|
2593
|
-
|
|
3058
|
+
need(storedSlot(root, key.text));
|
|
2594
3059
|
}
|
|
2595
3060
|
facts.add(reference);
|
|
2596
3061
|
return;
|
|
2597
3062
|
}
|
|
2598
3063
|
if (ts.isShorthandPropertyAssignment(parent)) {
|
|
2599
|
-
|
|
3064
|
+
join(publication(root, parent.parent, parent.name.text));
|
|
2600
3065
|
return;
|
|
2601
3066
|
}
|
|
2602
3067
|
if (ts.isPropertyDeclaration(parent) && parent.initializer === reference) {
|
|
@@ -2606,14 +3071,14 @@ const createSession = (checker, flow) => {
|
|
|
2606
3071
|
return;
|
|
2607
3072
|
}
|
|
2608
3073
|
for (const construction of constructionsOf(parent))
|
|
2609
|
-
|
|
3074
|
+
join(publication(root, construction, key));
|
|
2610
3075
|
return;
|
|
2611
3076
|
}
|
|
2612
3077
|
if (ts.isArrayLiteralExpression(parent)) {
|
|
2613
3078
|
if (parent.elements.some(ts.isSpreadElement))
|
|
2614
3079
|
fail('spread-publication', parent);
|
|
2615
3080
|
else
|
|
2616
|
-
|
|
3081
|
+
join(publication(root, parent, String(parent.elements.indexOf(reference))));
|
|
2617
3082
|
return;
|
|
2618
3083
|
}
|
|
2619
3084
|
if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) {
|
|
@@ -2626,7 +3091,7 @@ const createSession = (checker, flow) => {
|
|
|
2626
3091
|
// sites as a key coercion, so `this.run()` had no callable slot at
|
|
2627
3092
|
// all -- the one place a member name is not a key being coerced.
|
|
2628
3093
|
if (ts.isPropertyAccessExpression(parent) && parent.name === reference) {
|
|
2629
|
-
|
|
3094
|
+
joinUse(root, parent);
|
|
2630
3095
|
return;
|
|
2631
3096
|
}
|
|
2632
3097
|
fail('coercing-property-key', reference);
|
|
@@ -2710,6 +3175,14 @@ const createSession = (checker, flow) => {
|
|
|
2710
3175
|
}
|
|
2711
3176
|
return absentOwnKey(held, key, parent, descriptorOf, hasUnnamedWrite);
|
|
2712
3177
|
};
|
|
3178
|
+
if (familyWalk && keys.some((key) => definitionDecides(root, key))) {
|
|
3179
|
+
facts.add(gateOf(reference, null));
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
3182
|
+
if (literalWalk) {
|
|
3183
|
+
facts.add(gateOf(reference, null));
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
2713
3186
|
// `instance.constructor` READS the class object off the prototype
|
|
2714
3187
|
// -- a value this graph does not carry, and one whose escape opens
|
|
2715
3188
|
// the family: `unknown( value.constructor )` can construct and
|
|
@@ -2739,11 +3212,20 @@ const createSession = (checker, flow) => {
|
|
|
2739
3212
|
if (ts.isCallExpression(parent) || ts.isNewExpression(parent)) {
|
|
2740
3213
|
if (parent.expression === reference) {
|
|
2741
3214
|
if (reference.kind === ts.SyntaxKind.SuperKeyword && ts.isCallExpression(parent) && ts.isNewExpression(root)) {
|
|
2742
|
-
|
|
3215
|
+
need(nodeQuery('construct-targets', parent));
|
|
2743
3216
|
return;
|
|
2744
3217
|
}
|
|
2745
3218
|
if (!isBody(root))
|
|
2746
3219
|
fail('non-callable-use', reference);
|
|
3220
|
+
else if (ts.isCallExpression(parent)) {
|
|
3221
|
+
// A call through a cell none of the body's names spells -- `const g =
|
|
3222
|
+
// f; g()`, a parameter, an element, a destructured binding -- is a
|
|
3223
|
+
// caller `candidateCallersOf` cannot list. Hand it to `case 'callers'`.
|
|
3224
|
+
const site = sites.get(parent);
|
|
3225
|
+
const name = site ? calleeNameOf(site) : null;
|
|
3226
|
+
if (!site || (name !== null && namesOf(root)?.includes(name) === false))
|
|
3227
|
+
facts.add(parent);
|
|
3228
|
+
}
|
|
2747
3229
|
return;
|
|
2748
3230
|
}
|
|
2749
3231
|
if (ts.isCallExpression(parent)) {
|
|
@@ -2759,6 +3241,10 @@ const createSession = (checker, flow) => {
|
|
|
2759
3241
|
if (parent.arguments.length === 1 &&
|
|
2760
3242
|
parent.arguments[0] === reference &&
|
|
2761
3243
|
intrinsicJsonStringifyQueryOf(checker, unwrapErasedExpression(parent.expression))) {
|
|
3244
|
+
if (literalWalk) {
|
|
3245
|
+
facts.add(gateOf(reference, null));
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
2762
3248
|
// This bounded observation has no replacer or coercing space
|
|
2763
3249
|
// argument, and enters no toJSON/getter/recursive object frame.
|
|
2764
3250
|
// Actual stored values and all future keys remain solver inputs.
|
|
@@ -2803,7 +3289,7 @@ const createSession = (checker, flow) => {
|
|
|
2803
3289
|
if (installation.target === reference)
|
|
2804
3290
|
facts.add(parent);
|
|
2805
3291
|
else
|
|
2806
|
-
|
|
3292
|
+
join(publication(root, held, installation.key));
|
|
2807
3293
|
}
|
|
2808
3294
|
return;
|
|
2809
3295
|
}
|
|
@@ -2818,7 +3304,7 @@ const createSession = (checker, flow) => {
|
|
|
2818
3304
|
// intrinsic returns it, whoever reads the call.
|
|
2819
3305
|
facts.add(parent);
|
|
2820
3306
|
if (plan.returnsTarget && !ts.isExpressionStatement(parent.parent))
|
|
2821
|
-
|
|
3307
|
+
joinUse(root, parent);
|
|
2822
3308
|
}
|
|
2823
3309
|
else if (parent.arguments[2] === reference) {
|
|
2824
3310
|
// The descriptor literal: its `value` is copied into the target
|
|
@@ -2841,7 +3327,7 @@ const createSession = (checker, flow) => {
|
|
|
2841
3327
|
// not a literal could run getters, which this does not enter.
|
|
2842
3328
|
facts.add(parent);
|
|
2843
3329
|
if (bulk.target === reference)
|
|
2844
|
-
|
|
3330
|
+
joinUse(root, parent);
|
|
2845
3331
|
else if (!ts.isObjectLiteralExpression(root))
|
|
2846
3332
|
fail('bulk-assign-source-unmodelled', reference);
|
|
2847
3333
|
return;
|
|
@@ -2867,7 +3353,7 @@ const createSession = (checker, flow) => {
|
|
|
2867
3353
|
const continuations = collectionValueContinuationsOf(checker, flow, parent, reference, nativeProtocolClosed);
|
|
2868
3354
|
if (continuations !== null) {
|
|
2869
3355
|
for (const continued of continuations)
|
|
2870
|
-
|
|
3356
|
+
joinUse(root, continued);
|
|
2871
3357
|
return;
|
|
2872
3358
|
}
|
|
2873
3359
|
}
|
|
@@ -2890,7 +3376,7 @@ const createSession = (checker, flow) => {
|
|
|
2890
3376
|
fail('deferred-completion', parent);
|
|
2891
3377
|
return;
|
|
2892
3378
|
}
|
|
2893
|
-
|
|
3379
|
+
need(closure(body));
|
|
2894
3380
|
// The body's own receiver, returned: it reaches only the calls it was
|
|
2895
3381
|
// the receiver of, and `forward` continues it at each of those. See
|
|
2896
3382
|
// `returnsOwnReceiver`.
|
|
@@ -2898,7 +3384,7 @@ const createSession = (checker, flow) => {
|
|
|
2898
3384
|
return;
|
|
2899
3385
|
for (const call of read(callersOf(body)))
|
|
2900
3386
|
if (ts.isCallExpression(call))
|
|
2901
|
-
|
|
3387
|
+
joinUse(root, call);
|
|
2902
3388
|
return;
|
|
2903
3389
|
}
|
|
2904
3390
|
// Enumerating an object reads its KEY SET and nothing else: no slot is
|
|
@@ -2947,12 +3433,12 @@ const createSession = (checker, flow) => {
|
|
|
2947
3433
|
return;
|
|
2948
3434
|
}
|
|
2949
3435
|
if (isBody(owner))
|
|
2950
|
-
|
|
3436
|
+
need(closure(owner));
|
|
2951
3437
|
for (const site of constructionSitesTargeting(owner))
|
|
2952
|
-
|
|
3438
|
+
joinCarried(frameQuery('frame-argument', site.call, owner, parameter));
|
|
2953
3439
|
for (const call of read(callersOf(owner)))
|
|
2954
3440
|
if (ts.isCallExpression(call) || ts.isNewExpression(call))
|
|
2955
|
-
|
|
3441
|
+
joinCarried(frameQuery('frame-argument', call, owner, parameter));
|
|
2956
3442
|
for (const write of flow.writesToDeclaration(parameter)) {
|
|
2957
3443
|
if (write.site === excluded)
|
|
2958
3444
|
continue;
|
|
@@ -2970,7 +3456,7 @@ const createSession = (checker, flow) => {
|
|
|
2970
3456
|
fail('unmodelled-parameter-write', write.site);
|
|
2971
3457
|
continue;
|
|
2972
3458
|
}
|
|
2973
|
-
|
|
3459
|
+
joinCarried(value(write.value));
|
|
2974
3460
|
}
|
|
2975
3461
|
};
|
|
2976
3462
|
seeded = false;
|
|
@@ -2979,7 +3465,7 @@ const createSession = (checker, flow) => {
|
|
|
2979
3465
|
const expression = query.node;
|
|
2980
3466
|
const moduleExport = sourceCommonJsExportValueOf(flow, expression);
|
|
2981
3467
|
if (moduleExport !== null) {
|
|
2982
|
-
|
|
3468
|
+
joinCarried(value(moduleExport));
|
|
2983
3469
|
break;
|
|
2984
3470
|
}
|
|
2985
3471
|
if (isObjectRoot(expression)) {
|
|
@@ -2997,7 +3483,7 @@ const createSession = (checker, flow) => {
|
|
|
2997
3483
|
// frame a call would be. Anything else under `new` that is not
|
|
2998
3484
|
// a source construction stays opaque.
|
|
2999
3485
|
if (constructorFunctionCalleeOf(expression) !== null)
|
|
3000
|
-
|
|
3486
|
+
joinCarried(nodeQuery('completion', expression));
|
|
3001
3487
|
else
|
|
3002
3488
|
fail('opaque-construction');
|
|
3003
3489
|
}
|
|
@@ -3057,7 +3543,7 @@ const createSession = (checker, flow) => {
|
|
|
3057
3543
|
if (write.slot !== 'whole' || write.edge === 'return' || write.edge === 'yield')
|
|
3058
3544
|
continue;
|
|
3059
3545
|
if (write.value && ['identifier-assignment', 'logical-assignment'].includes(write.edge))
|
|
3060
|
-
|
|
3546
|
+
joinCarried(value(write.value));
|
|
3061
3547
|
else
|
|
3062
3548
|
fail('unmodelled-callable-binding-write', write.site);
|
|
3063
3549
|
}
|
|
@@ -3068,7 +3554,7 @@ const createSession = (checker, flow) => {
|
|
|
3068
3554
|
fail('unaccounted-binding-write', declaration);
|
|
3069
3555
|
else
|
|
3070
3556
|
for (const entry of incoming)
|
|
3071
|
-
|
|
3557
|
+
joinCarried(value(entry));
|
|
3072
3558
|
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3073
3559
|
facts.add(undefinedValue);
|
|
3074
3560
|
seeded = true;
|
|
@@ -3083,12 +3569,12 @@ const createSession = (checker, flow) => {
|
|
|
3083
3569
|
// source include its own target.
|
|
3084
3570
|
const rebinding = rebindingAfterRead(declaration, expression);
|
|
3085
3571
|
if (rebinding === null)
|
|
3086
|
-
|
|
3572
|
+
joinCarried(nodeQuery('parameter', declaration));
|
|
3087
3573
|
else
|
|
3088
3574
|
parameterValues(declaration, rebinding);
|
|
3089
3575
|
}
|
|
3090
3576
|
else if (declaration && ts.isBindingElement(declaration))
|
|
3091
|
-
|
|
3577
|
+
joinCarried(nodeQuery('binding-element', declaration));
|
|
3092
3578
|
else if (expression.text === 'undefined' && (!declaration || declaration.getSourceFile().hasNoDefaultLib)) {
|
|
3093
3579
|
facts.add(undefinedValue);
|
|
3094
3580
|
seeded = true;
|
|
@@ -3101,7 +3587,7 @@ const createSession = (checker, flow) => {
|
|
|
3101
3587
|
if (!owner)
|
|
3102
3588
|
fail('unindexed-receiver');
|
|
3103
3589
|
else
|
|
3104
|
-
|
|
3590
|
+
joinCarried(nodeQuery('receiver', owner));
|
|
3105
3591
|
}
|
|
3106
3592
|
else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) {
|
|
3107
3593
|
if (sourceIntrinsicMemberMayBeWrittenOf(checker, flow, expression)) {
|
|
@@ -3109,8 +3595,8 @@ const createSession = (checker, flow) => {
|
|
|
3109
3595
|
if (installed === null)
|
|
3110
3596
|
fail('unproven-intrinsic-member-read', expression);
|
|
3111
3597
|
else {
|
|
3112
|
-
|
|
3113
|
-
|
|
3598
|
+
joinCarried(value(installed.value));
|
|
3599
|
+
need(closure(installed.body));
|
|
3114
3600
|
}
|
|
3115
3601
|
break;
|
|
3116
3602
|
}
|
|
@@ -3127,15 +3613,7 @@ const createSession = (checker, flow) => {
|
|
|
3127
3613
|
continue;
|
|
3128
3614
|
}
|
|
3129
3615
|
if (isObjectRoot(root))
|
|
3130
|
-
|
|
3131
|
-
if (isSourceCallableObject(root) &&
|
|
3132
|
-
key !== 'name' &&
|
|
3133
|
-
key !== 'length' &&
|
|
3134
|
-
sourceCallableOwnDataWriteOf(checker, flow, root, key, expression) === null)
|
|
3135
|
-
fail('unproven-callable-data-read', expression);
|
|
3136
|
-
else
|
|
3137
|
-
add(carry(slot(root, key)));
|
|
3138
|
-
}
|
|
3616
|
+
readSlotsOf(root, roots, keys, expression);
|
|
3139
3617
|
else if (!isNullish(root))
|
|
3140
3618
|
fail('non-object-receiver');
|
|
3141
3619
|
}
|
|
@@ -3146,18 +3624,18 @@ const createSession = (checker, flow) => {
|
|
|
3146
3624
|
seeded = true;
|
|
3147
3625
|
}
|
|
3148
3626
|
else if (ts.isCallExpression(expression))
|
|
3149
|
-
|
|
3627
|
+
joinCarried(nodeQuery('completion', expression));
|
|
3150
3628
|
else if (ts.isConditionalExpression(expression)) {
|
|
3151
|
-
|
|
3152
|
-
|
|
3629
|
+
joinCarried(value(expression.whenTrue));
|
|
3630
|
+
joinCarried(value(expression.whenFalse));
|
|
3153
3631
|
}
|
|
3154
3632
|
else if (ts.isBinaryExpression(expression) &&
|
|
3155
3633
|
[ts.SyntaxKind.EqualsToken, ts.SyntaxKind.CommaToken].includes(expression.operatorToken.kind))
|
|
3156
|
-
|
|
3634
|
+
joinCarried(value(expression.right));
|
|
3157
3635
|
else if (ts.isBinaryExpression(expression) &&
|
|
3158
3636
|
[ts.SyntaxKind.BarBarToken, ts.SyntaxKind.AmpersandAmpersandToken, ts.SyntaxKind.QuestionQuestionToken].includes(expression.operatorToken.kind)) {
|
|
3159
|
-
|
|
3160
|
-
|
|
3637
|
+
joinCarried(value(expression.left));
|
|
3638
|
+
joinCarried(value(expression.right));
|
|
3161
3639
|
}
|
|
3162
3640
|
else if (ts.isLiteralExpression(expression) ||
|
|
3163
3641
|
expression.kind === ts.SyntaxKind.NullKeyword ||
|
|
@@ -3178,8 +3656,8 @@ const createSession = (checker, flow) => {
|
|
|
3178
3656
|
fail('unproven-proxy-construction');
|
|
3179
3657
|
break;
|
|
3180
3658
|
}
|
|
3181
|
-
|
|
3182
|
-
|
|
3659
|
+
need(nodeQuery('proxy-target', query.node));
|
|
3660
|
+
need(nodeQuery('proxy-handler', query.node));
|
|
3183
3661
|
// This identity domain is deliberately separate from generic value
|
|
3184
3662
|
// roots: existing class-field consumers interpret NewExpression
|
|
3185
3663
|
// origins as physical data, which is not a Proxy get-trap proof.
|
|
@@ -3214,7 +3692,7 @@ const createSession = (checker, flow) => {
|
|
|
3214
3692
|
// `options.attachment` on the `{}` a parameter defaults to.
|
|
3215
3693
|
if ((ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) &&
|
|
3216
3694
|
absentOwnKey(root, key, root, descriptorOf, hasUnnamedWrite)) {
|
|
3217
|
-
|
|
3695
|
+
need(closure(root));
|
|
3218
3696
|
if (query.kind === 'slot') {
|
|
3219
3697
|
facts.add(undefinedValue);
|
|
3220
3698
|
seeded = true;
|
|
@@ -3225,15 +3703,22 @@ const createSession = (checker, flow) => {
|
|
|
3225
3703
|
break;
|
|
3226
3704
|
}
|
|
3227
3705
|
}
|
|
3228
|
-
|
|
3706
|
+
need(closure(root));
|
|
3229
3707
|
if (isSourceCallableObject(root)) {
|
|
3230
3708
|
if (key === 'name' || key === 'length') {
|
|
3231
3709
|
const parameters = runtimeParametersOf(root);
|
|
3232
3710
|
const firstDefault = parameters.findIndex((parameter) => parameter.initializer !== undefined || parameter.dotDotDotToken !== undefined);
|
|
3233
3711
|
const named = (ts.isArrowFunction(root) ? undefined : root.name) ?? (ts.isVariableDeclaration(root.parent) ? root.parent.name : undefined);
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3712
|
+
let ownData = callableOwnData.get(root);
|
|
3713
|
+
if (!ownData)
|
|
3714
|
+
callableOwnData.set(root, (ownData = new Map()));
|
|
3715
|
+
let literal = ownData.get(key);
|
|
3716
|
+
if (!literal)
|
|
3717
|
+
ownData.set(key, (literal =
|
|
3718
|
+
key === 'name'
|
|
3719
|
+
? ts.factory.createStringLiteral(named && ts.isIdentifier(named) ? named.text : '')
|
|
3720
|
+
: ts.factory.createNumericLiteral(firstDefault < 0 ? parameters.length : firstDefault)));
|
|
3721
|
+
facts.add(literal);
|
|
3237
3722
|
seeded = true;
|
|
3238
3723
|
}
|
|
3239
3724
|
else {
|
|
@@ -3241,15 +3726,15 @@ const createSession = (checker, flow) => {
|
|
|
3241
3726
|
if (installed === null)
|
|
3242
3727
|
fail('unproven-callable-data-slot', root);
|
|
3243
3728
|
else
|
|
3244
|
-
|
|
3729
|
+
joinCarried(value(installed.value));
|
|
3245
3730
|
}
|
|
3246
3731
|
}
|
|
3247
3732
|
else if (ts.isObjectLiteralExpression(root)) {
|
|
3248
3733
|
for (const entry of ownEntries(root, key) ?? []) {
|
|
3249
3734
|
if (ts.isPropertyAssignment(entry))
|
|
3250
|
-
|
|
3735
|
+
joinCarried(value(entry.initializer));
|
|
3251
3736
|
else if (ts.isShorthandPropertyAssignment(entry))
|
|
3252
|
-
|
|
3737
|
+
joinCarried(value(entry.name));
|
|
3253
3738
|
else if (ts.isMethodDeclaration(entry)) {
|
|
3254
3739
|
facts.add(entry);
|
|
3255
3740
|
seeded = true;
|
|
@@ -3261,7 +3746,7 @@ const createSession = (checker, flow) => {
|
|
|
3261
3746
|
// Every position at once; an index never written reads undefined.
|
|
3262
3747
|
for (const element of root.elements)
|
|
3263
3748
|
if (!ts.isOmittedExpression(element))
|
|
3264
|
-
|
|
3749
|
+
joinCarried(value(element));
|
|
3265
3750
|
facts.add(undefinedValue);
|
|
3266
3751
|
seeded = true;
|
|
3267
3752
|
}
|
|
@@ -3275,7 +3760,7 @@ const createSession = (checker, flow) => {
|
|
|
3275
3760
|
else {
|
|
3276
3761
|
const element = root.elements[Number(key)];
|
|
3277
3762
|
if (element !== undefined && !ts.isOmittedExpression(element))
|
|
3278
|
-
|
|
3763
|
+
joinCarried(value(element));
|
|
3279
3764
|
else {
|
|
3280
3765
|
facts.add(undefinedValue);
|
|
3281
3766
|
seeded = true;
|
|
@@ -3290,33 +3775,41 @@ const createSession = (checker, flow) => {
|
|
|
3290
3775
|
}
|
|
3291
3776
|
if (ts.isPropertyDeclaration(declaration)) {
|
|
3292
3777
|
if (declaration.initializer)
|
|
3293
|
-
|
|
3778
|
+
joinCarried(value(declaration.initializer));
|
|
3294
3779
|
else {
|
|
3295
3780
|
facts.add(undefinedValue);
|
|
3296
3781
|
seeded = true;
|
|
3297
3782
|
}
|
|
3298
3783
|
}
|
|
3299
3784
|
if (ts.isParameter(declaration))
|
|
3300
|
-
|
|
3785
|
+
joinCarried(nodeQuery('parameter', declaration));
|
|
3301
3786
|
}
|
|
3302
3787
|
if (getterRead !== null) {
|
|
3303
3788
|
// The getter runs with this construction as its receiver, and
|
|
3304
3789
|
// the read yields what the getter's completions yield.
|
|
3790
|
+
// The receiver's walk through the getter is a family walk for a
|
|
3791
|
+
// family member, whose gates are this root's to answer.
|
|
3792
|
+
if (getterRead.getters.length > 0 && isFamilyMember(root))
|
|
3793
|
+
gating = gateLogOf(query);
|
|
3305
3794
|
for (const getter of getterRead.getters) {
|
|
3306
3795
|
for (const reference of flow.receiverReferencesToDeclaration(getter))
|
|
3307
|
-
|
|
3796
|
+
joinUse(root, reference);
|
|
3308
3797
|
const summary = callableCompletionSummaryOf(flow, getter);
|
|
3309
3798
|
if (summary === null || summary.execution !== 'sync')
|
|
3310
3799
|
fail('unmodelled-getter-completion', getter);
|
|
3311
3800
|
else {
|
|
3312
3801
|
for (const completion of summary.values)
|
|
3313
|
-
|
|
3802
|
+
joinCarried(value(completion));
|
|
3314
3803
|
if (summary.mayCompleteUndefined) {
|
|
3315
3804
|
facts.add(undefinedValue);
|
|
3316
3805
|
seeded = true;
|
|
3317
3806
|
}
|
|
3318
3807
|
}
|
|
3319
3808
|
}
|
|
3809
|
+
if (gating !== null) {
|
|
3810
|
+
resolveGates(root);
|
|
3811
|
+
gating = null;
|
|
3812
|
+
}
|
|
3320
3813
|
if (getterRead.absent) {
|
|
3321
3814
|
facts.add(undefinedValue);
|
|
3322
3815
|
seeded = true;
|
|
@@ -3342,7 +3835,7 @@ const createSession = (checker, flow) => {
|
|
|
3342
3835
|
if (isSourceCallableObject(root) && ts.isCallExpression(stored)) {
|
|
3343
3836
|
const installation = sourceCallableReflectSetOf(checker, stored);
|
|
3344
3837
|
if (installation && installation.key === key && read(value(installation.target)).has(root))
|
|
3345
|
-
|
|
3838
|
+
joinCarried(value(installation.value));
|
|
3346
3839
|
continue;
|
|
3347
3840
|
}
|
|
3348
3841
|
if (ts.isCallExpression(stored) && definitionPlans.has(stored)) {
|
|
@@ -3354,7 +3847,7 @@ const createSession = (checker, flow) => {
|
|
|
3354
3847
|
seeded = true;
|
|
3355
3848
|
}
|
|
3356
3849
|
for (const defined of plan.values)
|
|
3357
|
-
|
|
3850
|
+
joinCarried(value(defined));
|
|
3358
3851
|
continue;
|
|
3359
3852
|
}
|
|
3360
3853
|
if (ts.isCallExpression(stored)) {
|
|
@@ -3374,7 +3867,7 @@ const createSession = (checker, flow) => {
|
|
|
3374
3867
|
else if (literalSpelledKeys(held) === null || hasUnnamedWrite(held))
|
|
3375
3868
|
fail('bulk-assign-source-keys-open', source);
|
|
3376
3869
|
else if (ownKeysOf(held)?.includes(key))
|
|
3377
|
-
|
|
3870
|
+
joinCarried(storedSlot(held, key));
|
|
3378
3871
|
}
|
|
3379
3872
|
continue;
|
|
3380
3873
|
}
|
|
@@ -3405,7 +3898,7 @@ const createSession = (checker, flow) => {
|
|
|
3405
3898
|
fail('unmodelled-property-write', stored);
|
|
3406
3899
|
continue;
|
|
3407
3900
|
}
|
|
3408
|
-
|
|
3901
|
+
joinCarried(value(write.value));
|
|
3409
3902
|
}
|
|
3410
3903
|
break;
|
|
3411
3904
|
}
|
|
@@ -3443,7 +3936,7 @@ const createSession = (checker, flow) => {
|
|
|
3443
3936
|
case 'targets': {
|
|
3444
3937
|
const site = sites.get(query.node);
|
|
3445
3938
|
if (site?.operands && !site.explicitThis && site.operands.dispatch.kind === 'lexical-super') {
|
|
3446
|
-
|
|
3939
|
+
joinCarried(superTargets(query.node));
|
|
3447
3940
|
break;
|
|
3448
3941
|
}
|
|
3449
3942
|
// `super()` selects a BASE CONSTRUCTOR, which is the construction
|
|
@@ -3451,7 +3944,7 @@ const createSession = (checker, flow) => {
|
|
|
3451
3944
|
// `new Base()` makes, reached from the subclass's heritage instead of
|
|
3452
3945
|
// from a spelled callee.
|
|
3453
3946
|
if (site?.operands && !site.explicitThis && site.operands.dispatch.kind === 'super-constructor') {
|
|
3454
|
-
|
|
3947
|
+
joinCarried(nodeQuery('construct-targets', query.node));
|
|
3455
3948
|
break;
|
|
3456
3949
|
}
|
|
3457
3950
|
// `.call`/`.apply` needs no separate resolver here: `operands.callee`
|
|
@@ -3480,7 +3973,7 @@ const createSession = (checker, flow) => {
|
|
|
3480
3973
|
if (ts.isCallExpression(query.node)) {
|
|
3481
3974
|
const bulk = bulkAssignOf(query.node);
|
|
3482
3975
|
if (bulk !== null) {
|
|
3483
|
-
|
|
3976
|
+
joinCarried(value(bulk.target));
|
|
3484
3977
|
break;
|
|
3485
3978
|
}
|
|
3486
3979
|
// `store.get( key )` on a native Map this program alone fills:
|
|
@@ -3500,7 +3993,7 @@ const createSession = (checker, flow) => {
|
|
|
3500
3993
|
const stored = collectionStoredValuesOf(checker, flow, query.node, nativeProtocolClosed);
|
|
3501
3994
|
if (stored !== null) {
|
|
3502
3995
|
for (const candidate of stored)
|
|
3503
|
-
|
|
3996
|
+
joinCarried(value(candidate));
|
|
3504
3997
|
facts.add(undefinedValue);
|
|
3505
3998
|
seeded = true;
|
|
3506
3999
|
break;
|
|
@@ -3512,7 +4005,7 @@ const createSession = (checker, flow) => {
|
|
|
3512
4005
|
flow.callableBodyIsIndexed(candidate) &&
|
|
3513
4006
|
candidate === constructorFunctionCalleeOf(query.node) &&
|
|
3514
4007
|
constructionYieldsCompletionOf(flow, candidate))
|
|
3515
|
-
|
|
4008
|
+
joinCarried(frameQuery('frame-completion', query.node, candidate));
|
|
3516
4009
|
else
|
|
3517
4010
|
fail('opaque-construction', candidate);
|
|
3518
4011
|
}
|
|
@@ -3522,7 +4015,7 @@ const createSession = (checker, flow) => {
|
|
|
3522
4015
|
if (!isBody(body))
|
|
3523
4016
|
fail('unindexed-body', body);
|
|
3524
4017
|
else
|
|
3525
|
-
|
|
4018
|
+
joinCarried(frameQuery('frame-completion', query.node, body));
|
|
3526
4019
|
}
|
|
3527
4020
|
if (ts.isCallExpression(query.node) && lookupThrows(query.node))
|
|
3528
4021
|
seeded = true;
|
|
@@ -3544,7 +4037,7 @@ const createSession = (checker, flow) => {
|
|
|
3544
4037
|
fail('incomplete-constructor-object-completion', query.body);
|
|
3545
4038
|
else
|
|
3546
4039
|
for (const returned of summary.values)
|
|
3547
|
-
|
|
4040
|
+
joinCarried(contextual(returned));
|
|
3548
4041
|
break;
|
|
3549
4042
|
}
|
|
3550
4043
|
const subject = query.subject;
|
|
@@ -3570,7 +4063,7 @@ const createSession = (checker, flow) => {
|
|
|
3570
4063
|
}
|
|
3571
4064
|
if (!slot.actual) {
|
|
3572
4065
|
if (slot.defaultValue)
|
|
3573
|
-
|
|
4066
|
+
joinCarried(contextual(slot.defaultValue));
|
|
3574
4067
|
else {
|
|
3575
4068
|
facts.add(undefinedValue);
|
|
3576
4069
|
seeded = true;
|
|
@@ -3579,7 +4072,7 @@ const createSession = (checker, flow) => {
|
|
|
3579
4072
|
else
|
|
3580
4073
|
for (const candidate of carry(value(slot.actual))) {
|
|
3581
4074
|
if (ts.isVoidExpression(candidate) && slot.defaultValue)
|
|
3582
|
-
|
|
4075
|
+
joinCarried(contextual(slot.defaultValue));
|
|
3583
4076
|
else
|
|
3584
4077
|
facts.add(candidate);
|
|
3585
4078
|
}
|
|
@@ -3592,14 +4085,14 @@ const createSession = (checker, flow) => {
|
|
|
3592
4085
|
const expression = unwrapErasedExpression(subject);
|
|
3593
4086
|
const declaration = ts.isIdentifier(expression) ? flow.targetOf(expression)?.declaration : null;
|
|
3594
4087
|
if (declaration && ts.isParameter(declaration) && declaration.parent === query.body)
|
|
3595
|
-
|
|
4088
|
+
joinCarried(frameQuery('constructor-parameter', query.node, query.body, declaration));
|
|
3596
4089
|
else if (declaration && ts.isVariableDeclaration(declaration) && ts.findAncestor(declaration, ts.isFunctionLike) === query.body) {
|
|
3597
4090
|
const incoming = sourceBindingValuesOf(checker, flow, declaration, iterationValuesAt);
|
|
3598
4091
|
if (incoming === null)
|
|
3599
4092
|
fail('unaccounted-constructor-binding', declaration);
|
|
3600
4093
|
else
|
|
3601
4094
|
for (const entry of incoming)
|
|
3602
|
-
|
|
4095
|
+
joinCarried(contextual(entry));
|
|
3603
4096
|
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3604
4097
|
facts.add(undefinedValue);
|
|
3605
4098
|
seeded = true;
|
|
@@ -3632,13 +4125,13 @@ const createSession = (checker, flow) => {
|
|
|
3632
4125
|
for (const condition of read(contextual(expression.condition))) {
|
|
3633
4126
|
const truth = conditionTruthOf(condition);
|
|
3634
4127
|
if (truth !== false)
|
|
3635
|
-
|
|
4128
|
+
joinCarried(contextual(expression.whenTrue));
|
|
3636
4129
|
if (truth !== true)
|
|
3637
|
-
|
|
4130
|
+
joinCarried(contextual(expression.whenFalse));
|
|
3638
4131
|
}
|
|
3639
4132
|
}
|
|
3640
4133
|
else
|
|
3641
|
-
|
|
4134
|
+
joinCarried(value(expression));
|
|
3642
4135
|
break;
|
|
3643
4136
|
}
|
|
3644
4137
|
case 'frame-receiver':
|
|
@@ -3677,7 +4170,7 @@ const createSession = (checker, flow) => {
|
|
|
3677
4170
|
}
|
|
3678
4171
|
}
|
|
3679
4172
|
else if (receiver.kind === 'constructed')
|
|
3680
|
-
|
|
4173
|
+
joinCarried(value(receiver.call));
|
|
3681
4174
|
else if (receiver.kind === 'lexical' && receiver.source !== 'arrow') {
|
|
3682
4175
|
// `super.m()` and `super()` run with the calling frame's own
|
|
3683
4176
|
// `this`; the class the layout names is only where the lookup
|
|
@@ -3694,7 +4187,7 @@ const createSession = (checker, flow) => {
|
|
|
3694
4187
|
if (keyword === null)
|
|
3695
4188
|
fail('unresolved-super-home', query.node);
|
|
3696
4189
|
else
|
|
3697
|
-
|
|
4190
|
+
joinCarried(value(keyword));
|
|
3698
4191
|
}
|
|
3699
4192
|
else if (receiver.kind === 'lexical' && receiver.owner) {
|
|
3700
4193
|
if (ts.isSourceFile(receiver.owner)) {
|
|
@@ -3706,7 +4199,7 @@ const createSession = (checker, flow) => {
|
|
|
3706
4199
|
fail('global-object-receiver-origin', receiver.owner);
|
|
3707
4200
|
}
|
|
3708
4201
|
else
|
|
3709
|
-
|
|
4202
|
+
joinCarried(nodeQuery('receiver', receiver.owner));
|
|
3710
4203
|
}
|
|
3711
4204
|
else
|
|
3712
4205
|
fail(receiver.kind === 'unsupported' ? receiver.reason : 'global-object-receiver-origin');
|
|
@@ -3718,7 +4211,7 @@ const createSession = (checker, flow) => {
|
|
|
3718
4211
|
break;
|
|
3719
4212
|
}
|
|
3720
4213
|
if (query.kind === 'frame-parameter') {
|
|
3721
|
-
|
|
4214
|
+
joinCarried(frameQuery('frame-argument', query.node, query.body, parameter));
|
|
3722
4215
|
for (const write of flow.writesToDeclaration(parameter)) {
|
|
3723
4216
|
if (write.edge === 'call-argument' || write.edge === 'super-argument' || write.edge === 'default-parameter')
|
|
3724
4217
|
continue;
|
|
@@ -3727,7 +4220,7 @@ const createSession = (checker, flow) => {
|
|
|
3727
4220
|
if (!['identifier-assignment', 'logical-assignment'].includes(write.edge) || !write.value)
|
|
3728
4221
|
fail('unmodelled-parameter-write', write.site);
|
|
3729
4222
|
else
|
|
3730
|
-
|
|
4223
|
+
joinCarried(contextual(write.value));
|
|
3731
4224
|
}
|
|
3732
4225
|
break;
|
|
3733
4226
|
}
|
|
@@ -3743,13 +4236,13 @@ const createSession = (checker, flow) => {
|
|
|
3743
4236
|
if (slot.actual) {
|
|
3744
4237
|
for (const candidate of carry(value(slot.actual))) {
|
|
3745
4238
|
if (ts.isVoidExpression(candidate) && slot.defaultValue)
|
|
3746
|
-
|
|
4239
|
+
joinCarried(contextual(slot.defaultValue));
|
|
3747
4240
|
else
|
|
3748
4241
|
facts.add(candidate);
|
|
3749
4242
|
}
|
|
3750
4243
|
}
|
|
3751
4244
|
else if (slot.defaultValue)
|
|
3752
|
-
|
|
4245
|
+
joinCarried(contextual(slot.defaultValue));
|
|
3753
4246
|
else {
|
|
3754
4247
|
facts.add(undefinedValue);
|
|
3755
4248
|
seeded = true;
|
|
@@ -3761,7 +4254,7 @@ const createSession = (checker, flow) => {
|
|
|
3761
4254
|
fail('deferred-completion', query.body);
|
|
3762
4255
|
else {
|
|
3763
4256
|
for (const expression of summary.values)
|
|
3764
|
-
|
|
4257
|
+
joinCarried(contextual(expression));
|
|
3765
4258
|
if (summary.mayCompleteUndefined || (ts.isCallExpression(query.node) && ts.isCallChain(query.node))) {
|
|
3766
4259
|
facts.add(undefinedValue);
|
|
3767
4260
|
seeded = true;
|
|
@@ -3776,7 +4269,7 @@ const createSession = (checker, flow) => {
|
|
|
3776
4269
|
}
|
|
3777
4270
|
const declaration = ts.isIdentifier(expression) ? flow.targetOf(expression)?.declaration : null;
|
|
3778
4271
|
if (declaration && ts.isParameter(declaration) && declaration.parent === query.body)
|
|
3779
|
-
|
|
4272
|
+
joinCarried(frameQuery('frame-parameter', query.node, query.body, declaration));
|
|
3780
4273
|
else if (declaration &&
|
|
3781
4274
|
ts.isVariableDeclaration(declaration) &&
|
|
3782
4275
|
ts.findAncestor(declaration, ts.isFunctionLike) === query.body) {
|
|
@@ -3785,7 +4278,7 @@ const createSession = (checker, flow) => {
|
|
|
3785
4278
|
fail('unaccounted-binding-write', declaration);
|
|
3786
4279
|
else
|
|
3787
4280
|
for (const entry of incoming)
|
|
3788
|
-
|
|
4281
|
+
joinCarried(contextual(entry));
|
|
3789
4282
|
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3790
4283
|
facts.add(undefinedValue);
|
|
3791
4284
|
seeded = true;
|
|
@@ -3793,38 +4286,31 @@ const createSession = (checker, flow) => {
|
|
|
3793
4286
|
}
|
|
3794
4287
|
else if ((expression.kind === ts.SyntaxKind.ThisKeyword || expression.kind === ts.SyntaxKind.SuperKeyword) &&
|
|
3795
4288
|
(ts.isArrowFunction(query.body) || flow.receiverOwnerOf(expression) === query.body))
|
|
3796
|
-
|
|
4289
|
+
joinCarried(frameQuery('frame-receiver', query.node, query.body));
|
|
3797
4290
|
else if (ts.isConditionalExpression(expression)) {
|
|
3798
|
-
|
|
3799
|
-
|
|
4291
|
+
joinCarried(contextual(expression.whenTrue));
|
|
4292
|
+
joinCarried(contextual(expression.whenFalse));
|
|
3800
4293
|
}
|
|
3801
4294
|
else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) {
|
|
3802
4295
|
const keys = keysOf(expression);
|
|
3803
|
-
|
|
4296
|
+
const receivers = read(contextual(expression.expression));
|
|
4297
|
+
for (const root of receivers) {
|
|
3804
4298
|
if (isObjectRoot(root))
|
|
3805
|
-
|
|
3806
|
-
if (isSourceCallableObject(root) &&
|
|
3807
|
-
key !== 'name' &&
|
|
3808
|
-
key !== 'length' &&
|
|
3809
|
-
sourceCallableOwnDataWriteOf(checker, flow, root, key, expression) === null)
|
|
3810
|
-
fail('unproven-callable-data-read', expression);
|
|
3811
|
-
else
|
|
3812
|
-
add(carry(slot(root, key)));
|
|
3813
|
-
}
|
|
4299
|
+
readSlotsOf(root, receivers, keys, expression);
|
|
3814
4300
|
else if (root.kind !== ts.SyntaxKind.NullKeyword && !ts.isVoidExpression(root))
|
|
3815
4301
|
fail('non-object-receiver');
|
|
3816
4302
|
}
|
|
3817
4303
|
}
|
|
3818
4304
|
else if (ts.isBinaryExpression(expression) &&
|
|
3819
4305
|
[ts.SyntaxKind.EqualsToken, ts.SyntaxKind.CommaToken].includes(expression.operatorToken.kind))
|
|
3820
|
-
|
|
4306
|
+
joinCarried(contextual(expression.right));
|
|
3821
4307
|
else if (ts.isBinaryExpression(expression) &&
|
|
3822
4308
|
[ts.SyntaxKind.BarBarToken, ts.SyntaxKind.AmpersandAmpersandToken, ts.SyntaxKind.QuestionQuestionToken].includes(expression.operatorToken.kind)) {
|
|
3823
|
-
|
|
3824
|
-
|
|
4309
|
+
joinCarried(contextual(expression.left));
|
|
4310
|
+
joinCarried(contextual(expression.right));
|
|
3825
4311
|
}
|
|
3826
4312
|
else
|
|
3827
|
-
|
|
4313
|
+
joinCarried(value(expression));
|
|
3828
4314
|
}
|
|
3829
4315
|
break;
|
|
3830
4316
|
}
|
|
@@ -3881,7 +4367,7 @@ const createSession = (checker, flow) => {
|
|
|
3881
4367
|
sourceCallableOwnDataWriteOf(checker, flow, root, key, element) === null)
|
|
3882
4368
|
fail('unproven-callable-data-read', element);
|
|
3883
4369
|
else if (isObjectRoot(root))
|
|
3884
|
-
|
|
4370
|
+
joinCarried(slot(root, key));
|
|
3885
4371
|
else
|
|
3886
4372
|
fail('non-object-destructured-container', element);
|
|
3887
4373
|
}
|
|
@@ -3900,15 +4386,15 @@ const createSession = (checker, flow) => {
|
|
|
3900
4386
|
ts.isGetAccessorDeclaration(owner) ||
|
|
3901
4387
|
ts.isSetAccessorDeclaration(owner)) {
|
|
3902
4388
|
for (const construction of constructionsOf(owner))
|
|
3903
|
-
|
|
4389
|
+
joinCarried(value(construction));
|
|
3904
4390
|
}
|
|
3905
4391
|
else if (isBody(owner)) {
|
|
3906
|
-
|
|
4392
|
+
need(closure(owner));
|
|
3907
4393
|
for (const construction of constructionsOf(owner))
|
|
3908
|
-
|
|
4394
|
+
joinCarried(value(construction));
|
|
3909
4395
|
for (const call of read(callersOf(owner)))
|
|
3910
4396
|
if (ts.isCallExpression(call))
|
|
3911
|
-
|
|
4397
|
+
joinCarried(frameQuery('frame-receiver', call, owner));
|
|
3912
4398
|
}
|
|
3913
4399
|
else
|
|
3914
4400
|
fail('unmodelled-receiver-owner');
|
|
@@ -3920,10 +4406,11 @@ const createSession = (checker, flow) => {
|
|
|
3920
4406
|
// is paid once per OWNER, not once per (owner, consumer) pair. See
|
|
3921
4407
|
// `callersOf`'s comment for the shape and the measured cost this
|
|
3922
4408
|
// replaces.
|
|
3923
|
-
// Discovery by name, soundness by CLOSURE. The spelled
|
|
3924
|
-
// resolve to this owner are its callers only while the owner
|
|
3925
|
-
// be reached from nowhere else: the body's own closure says where
|
|
3926
|
-
// the callable value goes
|
|
4409
|
+
// Discovery by name and by CLOSURE, soundness by CLOSURE. The spelled
|
|
4410
|
+
// calls that resolve to this owner are its callers only while the owner
|
|
4411
|
+
// can be reached from nowhere else: the body's own closure says where
|
|
4412
|
+
// the callable value goes -- including each call through an alias no
|
|
4413
|
+
// name of the owner spells, which it lists -- and for a class member each instance's
|
|
3927
4414
|
// closure says where the receivers go -- an instance handed to
|
|
3928
4415
|
// unknown code can be called through from there with arguments no
|
|
3929
4416
|
// site spells. A spelled call whose targets are opaque is then
|
|
@@ -3938,13 +4425,21 @@ const createSession = (checker, flow) => {
|
|
|
3938
4425
|
// construction domain, so it has no closure to read here.
|
|
3939
4426
|
if (ts.isConstructorDeclaration(owner))
|
|
3940
4427
|
break;
|
|
3941
|
-
|
|
4428
|
+
// `const g = f; g()` before this: `callers(f)` was a complete `[]`. Seeded
|
|
4429
|
+
// so `holdersOf` below finds the ones whose targets hold the owner; the
|
|
4430
|
+
// closure's other calls (a bulk assign or definition onto it) never do.
|
|
4431
|
+
const unnamed = [];
|
|
4432
|
+
for (const use of read(closure(owner)))
|
|
4433
|
+
if (ts.isCallExpression(use))
|
|
4434
|
+
unnamed.push(use);
|
|
4435
|
+
for (const call of unnamed)
|
|
4436
|
+
seed(targets(call));
|
|
3942
4437
|
if (ts.isClassElement(owner) && ts.isClassLike(owner.parent)) {
|
|
3943
4438
|
if ((ts.getCombinedModifierFlags(owner) & ts.ModifierFlags.Static) !== 0)
|
|
3944
4439
|
fail('static-member-callers-open', owner);
|
|
3945
4440
|
else
|
|
3946
4441
|
for (const instance of familyInstancesOf(owner.parent, 'member-family-open') ?? [])
|
|
3947
|
-
|
|
4442
|
+
need(closure(instance));
|
|
3948
4443
|
}
|
|
3949
4444
|
// Which candidates target this owner is asked the other way round:
|
|
3950
4445
|
// the `targets` states that hold the owner, from the reverse index,
|
|
@@ -3992,10 +4487,23 @@ const createSession = (checker, flow) => {
|
|
|
3992
4487
|
for (const position of matched)
|
|
3993
4488
|
facts.add(sites.sites[position].call);
|
|
3994
4489
|
}
|
|
4490
|
+
// The calls through an alias the closure listed: a caller once its
|
|
4491
|
+
// seeded `targets` holds the owner, as for a named candidate above.
|
|
4492
|
+
if (unnamed.length > 0) {
|
|
4493
|
+
const heldTargets = new Set();
|
|
4494
|
+
for (const holder of holders)
|
|
4495
|
+
if (holder.kind === 'targets')
|
|
4496
|
+
heldTargets.add(holder.node);
|
|
4497
|
+
for (const call of unnamed)
|
|
4498
|
+
if (heldTargets.has(call))
|
|
4499
|
+
facts.add(call);
|
|
4500
|
+
}
|
|
3995
4501
|
break;
|
|
3996
4502
|
}
|
|
3997
4503
|
case 'closure': {
|
|
3998
4504
|
const root = query.node;
|
|
4505
|
+
if (isFamilyMember(root) || isLiteralGroupMember(root))
|
|
4506
|
+
gating = gateLogOf(query);
|
|
3999
4507
|
if (ts.isFunctionDeclaration(root)) {
|
|
4000
4508
|
// `refs` follows the same import inventory as stored cells. A
|
|
4001
4509
|
// factory imported by a source module is not an external escape.
|
|
@@ -4011,38 +4519,45 @@ const createSession = (checker, flow) => {
|
|
|
4011
4519
|
if (key === null)
|
|
4012
4520
|
fail('computed-method');
|
|
4013
4521
|
else
|
|
4014
|
-
|
|
4522
|
+
join(publication(root, root.parent, key));
|
|
4015
4523
|
}
|
|
4016
4524
|
else
|
|
4017
4525
|
refs(root, root);
|
|
4018
4526
|
}
|
|
4019
4527
|
else if (ts.isExpression(root))
|
|
4020
|
-
|
|
4528
|
+
joinUse(root, root);
|
|
4021
4529
|
else
|
|
4022
4530
|
fail('unmodelled-root');
|
|
4023
4531
|
if (ts.isNewExpression(root) && !isFreshOrdinaryObject(root)) {
|
|
4024
4532
|
const owners = constructionFrames.receiverOwnersOf(root);
|
|
4025
|
-
if (!owners)
|
|
4533
|
+
if (!owners)
|
|
4026
4534
|
fail('opaque-construction');
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4535
|
+
else
|
|
4536
|
+
for (const owner of owners) {
|
|
4537
|
+
if (!isClassSpelledSourceClass(owner)) {
|
|
4538
|
+
for (const reference of flow.receiverReferencesToDeclaration(owner))
|
|
4539
|
+
joinUse(root, reference);
|
|
4540
|
+
continue;
|
|
4541
|
+
}
|
|
4542
|
+
for (const member of owner.members) {
|
|
4543
|
+
if (ts.isConstructorDeclaration(member) ||
|
|
4544
|
+
(ts.isPropertyDeclaration(member) && (ts.getCombinedModifierFlags(member) & ts.ModifierFlags.Static) === 0))
|
|
4545
|
+
for (const reference of flow.receiverReferencesToDeclaration(member))
|
|
4546
|
+
joinUse(root, reference);
|
|
4547
|
+
}
|
|
4040
4548
|
}
|
|
4041
|
-
}
|
|
4042
4549
|
}
|
|
4550
|
+
if (gating !== null)
|
|
4551
|
+
resolveGates(root);
|
|
4043
4552
|
break;
|
|
4044
4553
|
}
|
|
4045
4554
|
case 'use':
|
|
4555
|
+
familyWalk = familyReps.has(query.root);
|
|
4556
|
+
literalWalk = literalReps.has(query.root);
|
|
4557
|
+
walkedReference = query.node;
|
|
4558
|
+
visitUse(query.root, query.node);
|
|
4559
|
+
break;
|
|
4560
|
+
case 'root-use':
|
|
4046
4561
|
visitUse(query.root, query.node);
|
|
4047
4562
|
break;
|
|
4048
4563
|
case 'unknown-reads': {
|
|
@@ -4058,6 +4573,12 @@ const createSession = (checker, flow) => {
|
|
|
4058
4573
|
facts.add(entry.access);
|
|
4059
4574
|
break;
|
|
4060
4575
|
}
|
|
4576
|
+
case 'copy-sites': {
|
|
4577
|
+
for (const stored of read(closure(query.node)))
|
|
4578
|
+
if (isCopySite(stored))
|
|
4579
|
+
facts.add(stored);
|
|
4580
|
+
break;
|
|
4581
|
+
}
|
|
4061
4582
|
case 'key-reads': {
|
|
4062
4583
|
// `unknown-reads`' inversion for the reads that spell their key:
|
|
4063
4584
|
// the receivers holding this container, from the reverse index,
|
|
@@ -4088,6 +4609,24 @@ const createSession = (checker, flow) => {
|
|
|
4088
4609
|
facts.add(flow.propertyAccesses[position]);
|
|
4089
4610
|
break;
|
|
4090
4611
|
}
|
|
4612
|
+
case 'family-slot': {
|
|
4613
|
+
for (const member of familyMembersOf(query.node))
|
|
4614
|
+
joinCarried(slot(member, query.key));
|
|
4615
|
+
break;
|
|
4616
|
+
}
|
|
4617
|
+
case 'enumerated-slots': {
|
|
4618
|
+
const root = query.root;
|
|
4619
|
+
const head = nodeQuery('enumerated-keys', query.node);
|
|
4620
|
+
for (const key of enumeratedKeyListOf(head, read(head)))
|
|
4621
|
+
joinCarried(slot(root, key));
|
|
4622
|
+
break;
|
|
4623
|
+
}
|
|
4624
|
+
case 'enumerated-keys': {
|
|
4625
|
+
for (const key of enumeratedKeysOf(query.node, read, fail, sealing, ownKeysOf))
|
|
4626
|
+
facts.add(enumeratedKeyValue(key));
|
|
4627
|
+
seeded = true;
|
|
4628
|
+
break;
|
|
4629
|
+
}
|
|
4091
4630
|
case 'own-keys': {
|
|
4092
4631
|
const root = query.node;
|
|
4093
4632
|
const keys = ownKeysOf(root);
|
|
@@ -4126,65 +4665,76 @@ const createSession = (checker, flow) => {
|
|
|
4126
4665
|
break;
|
|
4127
4666
|
}
|
|
4128
4667
|
case 'publication': {
|
|
4129
|
-
|
|
4668
|
+
// The value continues at every reference the container's key is used
|
|
4669
|
+
// at (`keyUsesOf`), which is the same for every value it holds.
|
|
4670
|
+
for (const reference of read(keyUsesOf(query.node, query.key)))
|
|
4671
|
+
joinUse(query.root, reference);
|
|
4672
|
+
break;
|
|
4673
|
+
}
|
|
4674
|
+
case 'key-uses': {
|
|
4675
|
+
const container = query.node;
|
|
4676
|
+
const key = query.key;
|
|
4677
|
+
need(closure(container));
|
|
4678
|
+
const copySites = read(copySitesOf(container));
|
|
4130
4679
|
// A container merged into another by `Object.assign` hands this
|
|
4131
4680
|
// key's value to the target as well.
|
|
4132
|
-
for (const stored of
|
|
4681
|
+
for (const stored of copySites) {
|
|
4133
4682
|
if (!ts.isCallExpression(stored))
|
|
4134
4683
|
continue;
|
|
4135
4684
|
const bulk = bulkAssignOf(stored);
|
|
4136
|
-
if (bulk === null || !bulk.sources.some((source) => read(value(source)).has(
|
|
4685
|
+
if (bulk === null || !bulk.sources.some((source) => read(value(source)).has(container)))
|
|
4137
4686
|
continue;
|
|
4138
4687
|
for (const held of read(value(bulk.target)))
|
|
4139
4688
|
if (isObjectRoot(held))
|
|
4140
|
-
|
|
4689
|
+
join(keyUsesOf(held, key));
|
|
4141
4690
|
}
|
|
4142
|
-
for (const stored of
|
|
4691
|
+
for (const stored of copySites) {
|
|
4143
4692
|
const copied = ts.isExpression(stored) ? outermostErasureOf(stored).parent : undefined;
|
|
4144
|
-
if (copied && ts.isSpreadAssignment(copied) && read(value(copied.expression)).has(
|
|
4145
|
-
|
|
4146
|
-
if (!ts.isCallExpression(stored) || !definitionPlans.has(stored) ||
|
|
4693
|
+
if (copied && ts.isSpreadAssignment(copied) && read(value(copied.expression)).has(container))
|
|
4694
|
+
join(keyUsesOf(copied.parent, key));
|
|
4695
|
+
if (!ts.isCallExpression(stored) || !definitionPlans.has(stored) || key !== 'value')
|
|
4147
4696
|
continue;
|
|
4148
4697
|
const plan = definitionOf(stored);
|
|
4149
|
-
if (plan === null || !read(value(stored.arguments[2])).has(
|
|
4698
|
+
if (plan === null || !read(value(stored.arguments[2])).has(container))
|
|
4150
4699
|
continue;
|
|
4151
4700
|
for (const held of read(value(stored.arguments[0])))
|
|
4152
4701
|
if (isObjectRoot(held))
|
|
4153
|
-
for (const
|
|
4154
|
-
|
|
4702
|
+
for (const defined of plan.keys)
|
|
4703
|
+
join(keyUsesOf(held, defined));
|
|
4155
4704
|
}
|
|
4156
4705
|
// Discovery-only, as the per-read receiver test it replaces was.
|
|
4157
|
-
for (const access of observe(keyReadsOf(
|
|
4706
|
+
for (const access of observe(keyReadsOf(container, key))) {
|
|
4158
4707
|
if (!ts.isPropertyAccessExpression(access) && !ts.isElementAccessExpression(access))
|
|
4159
4708
|
continue;
|
|
4160
|
-
add(
|
|
4709
|
+
facts.add(access);
|
|
4161
4710
|
}
|
|
4162
4711
|
// Discovery-only, exactly as the receiver test it replaces was: a
|
|
4163
4712
|
// publication never required the unknown reads to have settled, it
|
|
4164
4713
|
// only had to see the ones that had.
|
|
4165
|
-
for (const access of observe(unknownReadsOf(
|
|
4714
|
+
for (const access of observe(unknownReadsOf(container))) {
|
|
4166
4715
|
if (!ts.isPropertyAccessExpression(access) && !ts.isElementAccessExpression(access))
|
|
4167
4716
|
continue;
|
|
4168
|
-
if (keyReaches(
|
|
4169
|
-
add(
|
|
4717
|
+
if (keyReaches(container, keysOf(access), key))
|
|
4718
|
+
facts.add(access);
|
|
4170
4719
|
}
|
|
4171
4720
|
// The value this key holds also reaches every cell a binding element
|
|
4172
4721
|
// of this container declares. Enumerating only `propertyAccesses`
|
|
4173
4722
|
// left `const { app } = p; sink(app)` out of the inventory, which is
|
|
4174
4723
|
// a hole in a closure proof, not a missing capability.
|
|
4175
|
-
for (const element of both(patternReadsByKey.get(
|
|
4176
|
-
const
|
|
4177
|
-
if (
|
|
4724
|
+
for (const element of both(patternReadsByKey.get(key), unknownPatternReads)) {
|
|
4725
|
+
const holder = bindingContainer(element);
|
|
4726
|
+
if (holder === null || !observe(holder).has(container))
|
|
4178
4727
|
continue;
|
|
4179
4728
|
if (element.dotDotDotToken || bindingElementKey(element) === null)
|
|
4180
4729
|
fail('unmodelled-container-read', element);
|
|
4181
4730
|
else
|
|
4182
|
-
|
|
4731
|
+
for (const reference of referencesOf(element))
|
|
4732
|
+
facts.add(reference);
|
|
4183
4733
|
}
|
|
4184
|
-
if (ts.isArrayLiteralExpression(
|
|
4734
|
+
if (ts.isArrayLiteralExpression(container) && (key === ELEMENT_KEY || isCanonicalIndex(key)))
|
|
4185
4735
|
for (const write of (valueIterationWrites ??= flow.allWrites.filter((write) => write.iterationOrigin?.mode === 'values'))) {
|
|
4186
4736
|
const origin = write.iterationOrigin;
|
|
4187
|
-
if (!observe(value(origin.source)).has(
|
|
4737
|
+
if (!observe(value(origin.source)).has(container))
|
|
4188
4738
|
continue;
|
|
4189
4739
|
if (origin.asynchronous || deferredIntrinsicProtocolLedgerOf(flow)?.require('Array', origin.source) !== true) {
|
|
4190
4740
|
fail('unproven-array-iteration', write.site);
|
|
@@ -4192,7 +4742,8 @@ const createSession = (checker, flow) => {
|
|
|
4192
4742
|
}
|
|
4193
4743
|
const declaration = write.target.declaration;
|
|
4194
4744
|
if (declaration && ts.isVariableDeclaration(declaration) && ts.isIdentifier(declaration.name))
|
|
4195
|
-
|
|
4745
|
+
for (const reference of referencesOf(declaration))
|
|
4746
|
+
facts.add(reference);
|
|
4196
4747
|
else
|
|
4197
4748
|
fail('unmodelled-iteration-binding', write.site);
|
|
4198
4749
|
}
|
|
@@ -4213,9 +4764,77 @@ const createSession = (checker, flow) => {
|
|
|
4213
4764
|
grounding.size === 0 ? NO_GROUNDING : grounding.size === 1 ? grounding.values().next().value : exactListOf(grounding);
|
|
4214
4765
|
outcome.seeded = seeded;
|
|
4215
4766
|
}
|
|
4767
|
+
// A node answering gates for its root keeps a gate log across its
|
|
4768
|
+
// evaluations and asks every gate again each time; it always runs in full.
|
|
4769
|
+
if (inputs !== null && !gateLogs.has(query))
|
|
4770
|
+
transferInputs.set(query, inputs);
|
|
4771
|
+
return facts;
|
|
4772
|
+
};
|
|
4773
|
+
/**
|
|
4774
|
+
* A transfer re-run only because something it joined grew: the joined
|
|
4775
|
+
* facts it has not handed back yet, without running it again.
|
|
4776
|
+
*
|
|
4777
|
+
* Most of a node's re-evaluations are of that kind -- a closure is woken
|
|
4778
|
+
* each time one of its uses gains a place, a publication each time one of
|
|
4779
|
+
* its key's uses does -- and a full re-run repeated all of the node's own
|
|
4780
|
+
* work to hand back only the joined facts' growth. A transfer is a
|
|
4781
|
+
* function of what it tests (its other reads, each a set that only grows,
|
|
4782
|
+
* so an unchanged size is the same set), the holders it asks for and the
|
|
4783
|
+
* program; a joined input it only adds whole. So while every tested set
|
|
4784
|
+
* and holder count is as the last full run left it, that run would do
|
|
4785
|
+
* everything the same and hand back, in the same order, exactly the joined
|
|
4786
|
+
* inputs' new facts. Seals and any change still run the transfer in full.
|
|
4787
|
+
*/
|
|
4788
|
+
const joinedOnly = (query, holdersOf) => {
|
|
4789
|
+
if (!joinedOnlyEnabled)
|
|
4790
|
+
return null;
|
|
4791
|
+
const inputs = transferInputs.get(query);
|
|
4792
|
+
if (inputs === undefined)
|
|
4793
|
+
return null;
|
|
4794
|
+
for (let index = 0; index < inputs.tested.length; index++)
|
|
4795
|
+
if (inputs.tested[index].size !== inputs.testedSizes[index])
|
|
4796
|
+
return null;
|
|
4797
|
+
for (const [fact, count] of inputs.holders) {
|
|
4798
|
+
let now = 0;
|
|
4799
|
+
for (const _holder of holdersOf(fact))
|
|
4800
|
+
now++;
|
|
4801
|
+
if (now !== count)
|
|
4802
|
+
return null;
|
|
4803
|
+
}
|
|
4804
|
+
const facts = new Set();
|
|
4805
|
+
let through = addedThrough.get(query);
|
|
4806
|
+
for (let index = 0; index < inputs.joined.length; index++) {
|
|
4807
|
+
const held = inputs.joined[index];
|
|
4808
|
+
const size = held.size;
|
|
4809
|
+
if (size === inputs.joinedSizes[index])
|
|
4810
|
+
continue;
|
|
4811
|
+
inputs.joinedSizes[index] = size;
|
|
4812
|
+
// `add`, for a transfer: past `DELTA_MINIMUM` from where the last one stopped.
|
|
4813
|
+
if (size <= DELTA_MINIMUM) {
|
|
4814
|
+
for (const value of held)
|
|
4815
|
+
facts.add(value);
|
|
4816
|
+
continue;
|
|
4817
|
+
}
|
|
4818
|
+
if (through === undefined)
|
|
4819
|
+
addedThrough.set(query, (through = new Map()));
|
|
4820
|
+
const before = through.get(held) ?? 0;
|
|
4821
|
+
let at = 0;
|
|
4822
|
+
for (const value of held)
|
|
4823
|
+
if (at++ >= before)
|
|
4824
|
+
facts.add(value);
|
|
4825
|
+
through.set(held, size);
|
|
4826
|
+
}
|
|
4216
4827
|
return facts;
|
|
4217
4828
|
};
|
|
4218
4829
|
const run = (query, read, observe, holdersOf, sealing, outcome) => {
|
|
4830
|
+
graphRevision.value++;
|
|
4831
|
+
// Before the ledger capture: a transfer that is not re-run raises no
|
|
4832
|
+
// obligation, and must keep the ones its last full run raised.
|
|
4833
|
+
if (outcome === null) {
|
|
4834
|
+
const joined = joinedOnly(query, holdersOf);
|
|
4835
|
+
if (joined !== null)
|
|
4836
|
+
return joined;
|
|
4837
|
+
}
|
|
4219
4838
|
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
4220
4839
|
if (!ledger)
|
|
4221
4840
|
return evaluate(query, read, observe, holdersOf, sealing, outcome);
|
|
@@ -4285,7 +4904,16 @@ const createSession = (checker, flow) => {
|
|
|
4285
4904
|
}
|
|
4286
4905
|
};
|
|
4287
4906
|
})();
|
|
4288
|
-
const { solve, requiredDependenciesOf, seed } = dependencyFactSolver(definition, 'grounding-domains', true);
|
|
4907
|
+
const { solve: solveGraph, requiredDependenciesOf, seed } = dependencyFactSolver(definition, 'grounding-domains', true);
|
|
4908
|
+
// A node's transfer inputs serve the re-runs of one solve; a later root wakes few nodes, and keeping them all would hold a second copy of every edge.
|
|
4909
|
+
const solve = (query) => {
|
|
4910
|
+
try {
|
|
4911
|
+
return solveGraph(query);
|
|
4912
|
+
}
|
|
4913
|
+
finally {
|
|
4914
|
+
transferInputs.clear();
|
|
4915
|
+
}
|
|
4916
|
+
};
|
|
4289
4917
|
// `case 'unknown-reads'` now asks `holdersOf` for the receivers that hold a
|
|
4290
4918
|
// container, instead of `observe`-ing all 968 of them itself -- but a
|
|
4291
4919
|
// reverse index only finds states that already EXIST and have already run.
|
|
@@ -4301,23 +4929,44 @@ const createSession = (checker, flow) => {
|
|
|
4301
4929
|
// `hasUnnamedWrite` asks the same reverse question of every computed write's receiver.
|
|
4302
4930
|
for (const receiver of computedWriteReceiverQueries)
|
|
4303
4931
|
seed(receiver);
|
|
4932
|
+
/**
|
|
4933
|
+
* Every obligation a root's answer rests on: a walk of its whole required
|
|
4934
|
+
* graph, which for a root in a large program's main component is half the
|
|
4935
|
+
* session. The same roots are asked again and again once the solver has
|
|
4936
|
+
* stopped growing (the structural censuses ask most of them), so an answer
|
|
4937
|
+
* is kept while no transfer or seal has run since (`graphRevision`): only
|
|
4938
|
+
* those change the required edges or a node's obligations.
|
|
4939
|
+
*/
|
|
4940
|
+
let obligationsRevision = -1;
|
|
4941
|
+
const obligationsByRoot = new Map();
|
|
4304
4942
|
const obligations = (root) => {
|
|
4943
|
+
if (obligationsRevision !== graphRevision.value) {
|
|
4944
|
+
obligationsByRoot.clear();
|
|
4945
|
+
obligationsRevision = graphRevision.value;
|
|
4946
|
+
}
|
|
4947
|
+
const known = obligationsByRoot.get(root);
|
|
4948
|
+
if (known !== undefined)
|
|
4949
|
+
return known;
|
|
4305
4950
|
const found = [];
|
|
4306
|
-
|
|
4951
|
+
// Marked when queued rather than when taken: a node is visited at its
|
|
4952
|
+
// first place in the queue either way, and the queue no longer holds an
|
|
4953
|
+
// entry per edge into it.
|
|
4954
|
+
const visited = new Set([root]);
|
|
4307
4955
|
const queue = [root];
|
|
4308
4956
|
for (let index = 0; index < queue.length; index++) {
|
|
4309
4957
|
const query = queue[index];
|
|
4310
|
-
if (visited.has(query))
|
|
4311
|
-
continue;
|
|
4312
|
-
visited.add(query);
|
|
4313
4958
|
const held = requirements.get(query);
|
|
4314
4959
|
if (Array.isArray(held))
|
|
4315
4960
|
found.push(...held);
|
|
4316
4961
|
else if (held !== undefined)
|
|
4317
4962
|
found.push(held);
|
|
4318
4963
|
for (const dependency of requiredDependenciesOf(query))
|
|
4319
|
-
|
|
4964
|
+
if (!visited.has(dependency)) {
|
|
4965
|
+
visited.add(dependency);
|
|
4966
|
+
queue.push(dependency);
|
|
4967
|
+
}
|
|
4320
4968
|
}
|
|
4969
|
+
obligationsByRoot.set(root, found);
|
|
4321
4970
|
return found;
|
|
4322
4971
|
};
|
|
4323
4972
|
// A literal's function-valued entry (`convert: function ( ... ) { ... }`)
|