@eagleoutice/flowr 2.17.7 → 2.17.8
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/abstract-interpretation/branch-paths.d.ts +10 -0
- package/abstract-interpretation/branch-paths.js +104 -10
- package/config.js +3 -1
- package/control-flow/control-flow-graph.js +18 -2
- package/data/r-base-guards.generated.js +2 -2
- package/dataflow/environments/ambient-effect.js +4 -1
- package/dataflow/environments/built-in-props.d.ts +8 -2
- package/dataflow/environments/built-in-props.js +16 -5
- package/dataflow/environments/default-builtin-config/base-functions.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +28 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +8 -4
- package/dataflow/environments/default-builtin-config/index.js +9 -5
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +25 -0
- package/dataflow/environments/guard-facts.d.ts +28 -1
- package/dataflow/environments/pkg-name.d.ts +2 -0
- package/dataflow/environments/query-fn-props.d.ts +19 -15
- package/dataflow/environments/query-fn-props.js +46 -36
- package/dataflow/environments/removal-marker.d.ts +1 -1
- package/dataflow/environments/removal-marker.js +18 -3
- package/dataflow/environments/reserved-names.d.ts +6 -0
- package/dataflow/environments/reserved-names.js +14 -0
- package/dataflow/environments/resolve-by-name.js +5 -10
- package/dataflow/eval/resolve/alias-tracking.js +23 -6
- package/dataflow/extractor.js +103 -28
- package/dataflow/fn/argument-roles.d.ts +3 -0
- package/dataflow/fn/argument-roles.js +5 -5
- package/dataflow/fn/exceptions-of-function.d.ts +7 -0
- package/dataflow/fn/exceptions-of-function.js +15 -2
- package/dataflow/fn/function-props.d.ts +1 -1
- package/dataflow/fn/function-props.js +40 -18
- package/dataflow/fn/function-semantics.d.ts +3 -1
- package/dataflow/fn/function-semantics.js +2 -0
- package/dataflow/fn/guards/built-in-guards.js +2 -1
- package/dataflow/fn/guards/condition-grouping.d.ts +11 -0
- package/dataflow/fn/guards/condition-grouping.js +50 -3
- package/dataflow/fn/guards/function-guards.d.ts +10 -0
- package/dataflow/fn/guards/function-guards.js +130 -14
- package/dataflow/fn/guards/guard-claims.d.ts +2 -0
- package/dataflow/fn/guards/guard-claims.js +42 -2
- package/dataflow/fn/guards/guard-knowledge.d.ts +7 -1
- package/dataflow/fn/guards/guard-knowledge.js +50 -4
- package/dataflow/fn/guards/guard-term.js +10 -1
- package/dataflow/fn/higher-order-function.d.ts +15 -1
- package/dataflow/fn/higher-order-function.js +54 -10
- package/dataflow/graph/call-graph.d.ts +5 -0
- package/dataflow/graph/call-graph.js +51 -15
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +4 -2
- package/dataflow/graph/graph.d.ts +21 -0
- package/dataflow/graph/graph.js +63 -2
- package/dataflow/internal/linker.d.ts +20 -0
- package/dataflow/internal/linker.js +190 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +20 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +12 -5
- package/dataflow/internal/process/functions/call/deferred.d.ts +7 -2
- package/dataflow/internal/process/functions/call/deferred.js +63 -28
- package/dataflow/internal/process/functions/call/quoted.js +33 -7
- package/documentation/data/dfg/doc-ambient.js +3 -1
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-query.js +9 -3
- package/package.json +5 -3
- package/project/context/flowr-analyzer-context.d.ts +7 -4
- package/project/context/flowr-analyzer-context.js +8 -3
- package/project/context/flowr-analyzer-files-context.js +1 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +2 -1
- package/project/context/flowr-analyzer-functions-context.js +9 -8
- package/project/flowr-analyzer.d.ts +7 -4
- package/project/flowr-analyzer.js +37 -8
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +22 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +34 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -1
- package/project/sigdb/build.js +41 -2
- package/project/sigdb/decode.d.ts +3 -1
- package/project/sigdb/decode.js +45 -1
- package/project/sigdb/decompress.d.ts +5 -0
- package/project/sigdb/decompress.js +17 -1
- package/project/sigdb/manifest.d.ts +2 -1
- package/project/sigdb/manifest.js +12 -5
- package/project/sigdb/native-routines.d.ts +82 -0
- package/project/sigdb/native-routines.js +178 -0
- package/project/sigdb/reader.d.ts +21 -3
- package/project/sigdb/reader.js +35 -3
- package/project/sigdb/schema.d.ts +107 -3
- package/project/sigdb/schema.js +8 -2
- package/project/sigdb/sigdb-download.js +1 -1
- package/project/sigdb/sigdb-version.d.ts +7 -1
- package/project/sigdb/sigdb-version.js +12 -9
- package/project/sigdb/spec-query.d.ts +9 -4
- package/project/sigdb/spec-query.js +71 -45
- package/queries/catalog/call-context-query/call-context-query-executor.js +76 -29
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -12
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +3 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +4 -2
- package/queries/catalog/signature-query/signature-query-executor.js +6 -2
- package/queries/catalog/signature-query/signature-query-format.d.ts +4 -0
- package/util/collections/bounded-map.d.ts +9 -0
- package/util/collections/bounded-map.js +22 -0
- package/util/collections/defaultmap.d.ts +5 -0
- package/util/collections/defaultmap.js +10 -0
- package/util/fixpoint.d.ts +6 -1
- package/util/fixpoint.js +45 -3
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/global-caches.d.ts +26 -0
- package/util/global-caches.js +43 -0
- package/util/monoid.js +2 -2
- package/util/quads.js +11 -3
- package/util/r-package-urls.d.ts +19 -0
- package/util/r-package-urls.js +41 -0
|
@@ -30,6 +30,9 @@ const df_helper_1 = require("../graph/df-helper");
|
|
|
30
30
|
const edge_1 = require("../graph/edge");
|
|
31
31
|
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
32
32
|
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
33
|
+
const bounded_map_1 = require("../../util/collections/bounded-map");
|
|
34
|
+
const global_caches_1 = require("../../util/global-caches");
|
|
35
|
+
const built_in_guards_1 = require("../fn/guards/built-in-guards");
|
|
33
36
|
/** What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR states nothing about it. */
|
|
34
37
|
function statedBuiltIn(definition, environment) {
|
|
35
38
|
const pkgFn = definition.type === identifier_1.ReferenceType.Function ? node_id_1.NodeId.toPkgFn(definition.nodeId) : undefined;
|
|
@@ -63,21 +66,24 @@ function statedFunctions(name, environment) {
|
|
|
63
66
|
return resolved === undefined ? undefined : withStatedBuiltIns(resolved, environment);
|
|
64
67
|
}
|
|
65
68
|
function ofDefinitions(definitions) {
|
|
66
|
-
let sig;
|
|
67
69
|
let stated = {};
|
|
68
70
|
let frame;
|
|
69
|
-
|
|
71
|
+
/* everything else a definition states, the first one stating a field answering it */
|
|
72
|
+
let rest = {};
|
|
70
73
|
for (const d of definitions ?? []) {
|
|
71
|
-
if (d.type !== identifier_1.ReferenceType.BuiltInFunction) {
|
|
74
|
+
if (d.type !== identifier_1.ReferenceType.BuiltInFunction || d.config === undefined) {
|
|
72
75
|
continue;
|
|
73
76
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
frame = info?.frame === undefined ? frame : (frame ?? 0) | info.frame;
|
|
77
|
+
const { props, tags, frame: own, ...others } = d.config;
|
|
78
|
+
rest = { ...definedOf(others), ...rest };
|
|
79
|
+
stated = function_semantics_1.FunctionSemantics.call.props.join(stated, { props, tags });
|
|
80
|
+
frame = own === undefined ? frame : (frame ?? 0) | own;
|
|
79
81
|
}
|
|
80
|
-
return
|
|
82
|
+
return Object.keys(rest).length === 0 && frame === undefined && !function_semantics_1.FunctionSemantics.call.props.hasAny(stated) ? undefined : { ...rest, ...stated, ...frame === undefined ? {} : { frame } };
|
|
83
|
+
}
|
|
84
|
+
/** The fields of `of` holding a value, so spreading it over another object keeps what that one states. */
|
|
85
|
+
function definedOf(of) {
|
|
86
|
+
return Object.fromEntries(Object.entries(of).filter(([, v]) => v !== undefined));
|
|
81
87
|
}
|
|
82
88
|
/** What flowR knows about the function `name`: what the built-in definitions state, filled up with what the signature database knows (see {@link fnInfoFromSignature}). */
|
|
83
89
|
function queryFnProps(name, { environment, builtIns, signatures, version }) {
|
|
@@ -94,7 +100,7 @@ function queryFnProps(name, { environment, builtIns, signatures, version }) {
|
|
|
94
100
|
}
|
|
95
101
|
const pkg = identifier_1.Identifier.getNamespace(name);
|
|
96
102
|
const known = signatures === undefined || pkg === undefined ? undefined : inferFnProps(signatures, pkg, identifier_1.Identifier.getName(name), version);
|
|
97
|
-
return known === undefined ? info : { sig: info?.sig ?? known.sig, ...built_in_props_1.CallProps.join(info, known)
|
|
103
|
+
return known === undefined ? info : { ...info, sig: info?.sig ?? known.sig, ...built_in_props_1.CallProps.join(info, known) };
|
|
98
104
|
}
|
|
99
105
|
/** How to ask what flowR states about a built-in, answering every name once. */
|
|
100
106
|
function builtInLookup(ctx) {
|
|
@@ -126,23 +132,27 @@ function quotedForWorker(id, graph, index) {
|
|
|
126
132
|
const quoting = df_helper_1.Dataflow.sourcesOf(graph, id, edge_1.EdgeType.NonStandardEvaluation);
|
|
127
133
|
return quoting.length > 0 && quoting.every(s => df_helper_1.Dataflow.targetsOf(graph, s, edge_1.EdgeType.Calls).some(t => node_id_1.NodeId.isBuiltIn(t) && ((index.propsOf(node_id_1.NodeId.fromBuiltIn(t)) ?? 0) & built_in_props_1.CallProp.Concurrent) !== 0));
|
|
128
134
|
}
|
|
129
|
-
/**
|
|
130
|
-
function
|
|
135
|
+
/**
|
|
136
|
+
* What the signature database implies for a package function: what its own entry states (see {@link fnInfoFromSignature}) plus the {@link PropagatedProps} of everything it calls, transitively,
|
|
137
|
+
* each callee as `builtIns` states it (flowR's default built-ins unless a configured lookup like {@link builtInLookup} is given).
|
|
138
|
+
*/
|
|
139
|
+
function inferFnProps(src, pkg, name, version, builtIns) {
|
|
131
140
|
const fn = src.functionByName(pkg, name, version);
|
|
132
|
-
return fn === undefined ? undefined : propsOfSignature(src, fn, pkg, version);
|
|
141
|
+
return fn === undefined ? undefined : propsOfSignature(src, fn, pkg, version, builtIns);
|
|
133
142
|
}
|
|
134
143
|
/** {@link inferFnProps} for an already decoded entry, so a lookup that found one does not repeat it. */
|
|
135
|
-
function propsOfSignature(src, fn, pkg, version) {
|
|
144
|
+
function propsOfSignature(src, fn, pkg, version, builtIns = name => BuiltInIndex.default().get(name)) {
|
|
136
145
|
const own = (0, built_in_props_1.fnInfoFromSignature)(fn);
|
|
137
|
-
const known = BuiltInIndex.default();
|
|
138
146
|
let props = own;
|
|
147
|
+
const carried = built_in_props_1.CallProps.hasAny(own, built_in_props_1.CallProp.Pure) ? built_in_props_1.PureCarriedProps : built_in_props_1.PropagatedProps;
|
|
139
148
|
for (const callee of src.transitiveCallees(pkg, fn.name, version) ?? fn.callees) {
|
|
140
|
-
|
|
149
|
+
/* the database names a callee `pkg::name`, the lookup asks for it split */
|
|
150
|
+
props = function_semantics_1.FunctionSemantics.call.props.join(props, function_semantics_1.FunctionSemantics.call.props.filter(builtIns(identifier_1.Identifier.parse(callee)), carried));
|
|
141
151
|
}
|
|
142
152
|
return { sig: own.sig, ...props };
|
|
143
153
|
}
|
|
144
154
|
/** The one place to ask what flowR knows about a function by name: one of its own built-ins, a package function the signature database carries, or both. */
|
|
145
|
-
function fnInfo(name, ctx, version) {
|
|
155
|
+
function fnInfo(name, ctx, { version, omit = [] } = {}) {
|
|
146
156
|
const db = (0, signature_db_1.signatureDbOf)(ctx.deps);
|
|
147
157
|
const { pkg, qualified, entry } = fnEntry(name, ctx, version);
|
|
148
158
|
/* an unqualified ask keeps its form, the built-in layer has a search path of its own */
|
|
@@ -157,19 +167,21 @@ function fnInfo(name, ctx, version) {
|
|
|
157
167
|
const sig = nonEmpty(stated?.sig) ?? nonEmpty(known?.sig);
|
|
158
168
|
/* the database keeps every formal, a `sig` only the ones flowR models, so it answers first, but an entry that records none must not hide the formals the built-in does state */
|
|
159
169
|
const parameters = nonEmpty(entry?.signature)?.map(p => p.name) ?? sig?.map(([param]) => param) ?? [];
|
|
160
|
-
|
|
170
|
+
const contract = entry?.guards ?? (0, built_in_guards_1.builtInGuards)(identifier_1.Identifier.getName(qualified), pkg);
|
|
171
|
+
const info = {
|
|
172
|
+
...stated,
|
|
161
173
|
name: qualified,
|
|
162
174
|
package: pkg,
|
|
163
175
|
version: assumed,
|
|
164
176
|
sig,
|
|
165
177
|
parameters,
|
|
166
178
|
...built_in_props_1.CallProps.join(stated, known),
|
|
167
|
-
frame: stated?.frame,
|
|
168
|
-
keepEnvironment: stated?.keepEnvironment,
|
|
169
179
|
builtIn: definition !== undefined || stated !== undefined,
|
|
170
180
|
foldable: definition?.evalHandler !== undefined,
|
|
171
|
-
entry
|
|
181
|
+
...entry === undefined ? {} : { entry },
|
|
182
|
+
...contract === undefined ? {} : { contract }
|
|
172
183
|
};
|
|
184
|
+
return omit.length === 0 ? info : Object.fromEntries(Object.entries(info).filter(([field]) => !omit.includes(field)));
|
|
173
185
|
}
|
|
174
186
|
/** The package {@link fnInfo} answers `name` for and the signature database entry it finds there, without the props of everything the entry calls, for a caller after the formals or the entry alone. */
|
|
175
187
|
function fnEntry(name, ctx, version) {
|
|
@@ -195,7 +207,7 @@ function packageExporting(name, ctx) {
|
|
|
195
207
|
const dependencies = ctx.deps.getDependencies().length;
|
|
196
208
|
let known = ExportingPerContext.get(ctx.deps);
|
|
197
209
|
if (known?.dependencies !== dependencies) {
|
|
198
|
-
known = { dependencies, owners: new
|
|
210
|
+
known = { dependencies, owners: new bounded_map_1.BoundedMap(MaxOwnersPerContext) };
|
|
199
211
|
ExportingPerContext.set(ctx.deps, known);
|
|
200
212
|
}
|
|
201
213
|
if (!known.owners.has(name)) {
|
|
@@ -204,7 +216,12 @@ function packageExporting(name, ctx) {
|
|
|
204
216
|
return known.owners.get(name);
|
|
205
217
|
}
|
|
206
218
|
/** what {@link packageExporting} answered per dependencies context, as long as it has the same number of dependencies */
|
|
207
|
-
|
|
219
|
+
let ExportingPerContext = new WeakMap();
|
|
220
|
+
/** bounds the names {@link ExportingPerContext} keeps per context, as they are the names the analyzed code uses */
|
|
221
|
+
const MaxOwnersPerContext = 65_536;
|
|
222
|
+
global_caches_1.GlobalCaches.register('exporting-per-context', global_caches_1.CacheScope.Analysis, () => undefined, () => {
|
|
223
|
+
ExportingPerContext = new WeakMap();
|
|
224
|
+
});
|
|
208
225
|
function exportingPackage(name, ctx) {
|
|
209
226
|
const db = (0, signature_db_1.signatureDbOf)(ctx.deps);
|
|
210
227
|
const src = db.sources();
|
|
@@ -232,9 +249,9 @@ function entryOfDefinition(definition) {
|
|
|
232
249
|
if (definition.type === 'constant') {
|
|
233
250
|
return [];
|
|
234
251
|
}
|
|
235
|
-
const info = definition.config;
|
|
252
|
+
const info = definedOf((0, ambient_effect_1.withImpliedAmbient)(definition.config) ?? {});
|
|
236
253
|
const foldable = definition.type === 'function' && definition.evalHandler !== undefined;
|
|
237
|
-
return builtInNames(definition).map(name => ({
|
|
254
|
+
return builtInNames(definition).map(name => ({ ...info, name, foldable, overrides: definition.overrides }));
|
|
238
255
|
}
|
|
239
256
|
function entriesOfMemory(builtIns) {
|
|
240
257
|
const out = [];
|
|
@@ -249,7 +266,7 @@ function entriesOfMemory(builtIns) {
|
|
|
249
266
|
const info = d.config;
|
|
250
267
|
const namespace = (d.name === undefined ? undefined : identifier_1.Identifier.getNamespace(d.name)) ?? pkg;
|
|
251
268
|
const name = namespace === undefined ? d.name ?? registered : identifier_1.Identifier.make(registered, namespace);
|
|
252
|
-
out.push({
|
|
269
|
+
out.push({ ...definedOf(info ?? {}), name, foldable: d.evalHandler !== undefined });
|
|
253
270
|
}
|
|
254
271
|
}
|
|
255
272
|
}
|
|
@@ -258,18 +275,11 @@ function entriesOfMemory(builtIns) {
|
|
|
258
275
|
let defaultIndex;
|
|
259
276
|
/** The one entry for a name several definitions state something about, the later definition winning wherever it states anything -- a definition that only adds a {@link FnSig} must not drop the props of the one before. */
|
|
260
277
|
function mergedEntry(known, next) {
|
|
261
|
-
return {
|
|
262
|
-
name: next.name,
|
|
263
|
-
props: next.props ?? known.props,
|
|
264
|
-
tags: next.tags ?? known.tags,
|
|
265
|
-
sig: next.sig ?? known.sig,
|
|
266
|
-
ambient: next.ambient ?? known.ambient,
|
|
267
|
-
foldable: next.foldable || known.foldable
|
|
268
|
-
};
|
|
278
|
+
return { ...known, ...plainEntry(next), foldable: next.foldable || known.foldable };
|
|
269
279
|
}
|
|
270
280
|
/** The entry alone, without what only the index build needs to know about it. */
|
|
271
|
-
function plainEntry({
|
|
272
|
-
return
|
|
281
|
+
function plainEntry({ overrides: _, ...entry }) {
|
|
282
|
+
return entry;
|
|
273
283
|
}
|
|
274
284
|
/** How early R's default search path reaches a name, deciding which package an unqualified ask answers with. */
|
|
275
285
|
function searchPathRank(name) {
|
|
@@ -5,5 +5,5 @@ export declare function removalMarkerOf(name: BrandedIdentifier): BrandedIdentif
|
|
|
5
5
|
export declare function removedNameOf(name: BrandedIdentifier): BrandedIdentifier;
|
|
6
6
|
/** Records that a {@link removalMarkerOf|marker} was written for `name`; see {@link anyRemovalMarker}. */
|
|
7
7
|
export declare function noteRemovalMarker(name: BrandedIdentifier): void;
|
|
8
|
-
/** Whether a removal marker
|
|
8
|
+
/** Whether a removal marker may have been written for `name`, so nothing else pays for looking one up. */
|
|
9
9
|
export declare function anyRemovalMarker(name: BrandedIdentifier): boolean;
|
|
@@ -4,6 +4,7 @@ exports.removalMarkerOf = removalMarkerOf;
|
|
|
4
4
|
exports.removedNameOf = removedNameOf;
|
|
5
5
|
exports.noteRemovalMarker = noteRemovalMarker;
|
|
6
6
|
exports.anyRemovalMarker = anyRemovalMarker;
|
|
7
|
+
const global_caches_1 = require("../../util/global-caches");
|
|
7
8
|
const removalMarkerPrefix = ' rm-removal:';
|
|
8
9
|
/** The reserved name recording that `name` was removed. */
|
|
9
10
|
function removalMarkerOf(name) {
|
|
@@ -14,12 +15,26 @@ function removedNameOf(name) {
|
|
|
14
15
|
return name.startsWith(removalMarkerPrefix) ? name.slice(removalMarkerPrefix.length) : name;
|
|
15
16
|
}
|
|
16
17
|
const removedNames = new Set();
|
|
18
|
+
/**
|
|
19
|
+
* Bounds {@link removedNames}. It may not forget a name while an environment holding its marker lives (in this or any
|
|
20
|
+
* other analyzer), so past the bound every name counts as possibly removed, which costs a lookup but is never wrong.
|
|
21
|
+
*/
|
|
22
|
+
const MaxRemovedNames = 65_536;
|
|
23
|
+
let saturated = false;
|
|
24
|
+
/* forgetting names is unsafe, so releasing them means giving up on the shortcut */
|
|
25
|
+
function saturate() {
|
|
26
|
+
saturated = true;
|
|
27
|
+
removedNames.clear();
|
|
28
|
+
}
|
|
29
|
+
global_caches_1.GlobalCaches.register('removed-names', global_caches_1.CacheScope.Process, () => removedNames.size, saturate, MaxRemovedNames);
|
|
17
30
|
/** Records that a {@link removalMarkerOf|marker} was written for `name`; see {@link anyRemovalMarker}. */
|
|
18
31
|
function noteRemovalMarker(name) {
|
|
19
|
-
removedNames.add(name)
|
|
32
|
+
if (!saturated && removedNames.add(name).size > MaxRemovedNames) {
|
|
33
|
+
saturate();
|
|
34
|
+
}
|
|
20
35
|
}
|
|
21
|
-
/** Whether a removal marker
|
|
36
|
+
/** Whether a removal marker may have been written for `name`, so nothing else pays for looking one up. */
|
|
22
37
|
function anyRemovalMarker(name) {
|
|
23
|
-
return removedNames.has(name);
|
|
38
|
+
return saturated || removedNames.has(name);
|
|
24
39
|
}
|
|
25
40
|
//# sourceMappingURL=removal-marker.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrandedIdentifier } from './identifier';
|
|
2
|
+
/**
|
|
3
|
+
* Whether flowR made the name up for its own bookkeeping, so that no R code binds it: an ambient state (`#option:digits`), the
|
|
4
|
+
* removal of a name (`rm(x)`), or an entry of the S4 class registry. A consumer listing what a package binds leaves these out.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isReservedName(name: BrandedIdentifier): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isReservedName = isReservedName;
|
|
4
|
+
const ambient_state_name_1 = require("./ambient-state-name");
|
|
5
|
+
const removal_marker_1 = require("./removal-marker");
|
|
6
|
+
const built_in_s_four_1 = require("../internal/process/functions/call/built-in/built-in-s-four");
|
|
7
|
+
/**
|
|
8
|
+
* Whether flowR made the name up for its own bookkeeping, so that no R code binds it: an ambient state (`#option:digits`), the
|
|
9
|
+
* removal of a name (`rm(x)`), or an entry of the S4 class registry. A consumer listing what a package binds leaves these out.
|
|
10
|
+
*/
|
|
11
|
+
function isReservedName(name) {
|
|
12
|
+
return ambient_state_name_1.AmbientStateName.is(name) || (0, removal_marker_1.removedNameOf)(name) !== name || (0, built_in_s_four_1.isS4ClassName)(name);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=reserved-names.js.map
|
|
@@ -6,6 +6,8 @@ exports.resolveByNameAnyType = resolveByNameAnyType;
|
|
|
6
6
|
exports.resolvesToBuiltIn = resolvesToBuiltIn;
|
|
7
7
|
exports.resolvesToBuiltInConstant = resolvesToBuiltInConstant;
|
|
8
8
|
const environment_1 = require("./environment");
|
|
9
|
+
const bounded_map_1 = require("../../util/collections/bounded-map");
|
|
10
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
9
11
|
const logic_1 = require("../../util/logic");
|
|
10
12
|
const identifier_1 = require("./identifier");
|
|
11
13
|
const info_1 = require("../info");
|
|
@@ -74,13 +76,10 @@ function resolveByName(id, environment, target) {
|
|
|
74
76
|
const found = resolveByTargetType(id, environment, target);
|
|
75
77
|
return found === undefined && target === identifier_1.ReferenceType.NonFunction ? ownDefinitions(id, environment) : found;
|
|
76
78
|
}
|
|
79
|
+
/** The memo of the walk below `env`, which may be the built-in environment or a shared base layer, so bounded by {@link TailCacheCap}. */
|
|
77
80
|
function tailCacheOf(env, target) {
|
|
78
81
|
env.tailCache ??= new Map();
|
|
79
|
-
|
|
80
|
-
if (memo === undefined) {
|
|
81
|
-
env.tailCache.set(target, memo = new Map());
|
|
82
|
-
}
|
|
83
|
-
return memo;
|
|
82
|
+
return (0, defaultmap_1.getOrSet)(env.tailCache, target, () => new bounded_map_1.BoundedMap(TailCacheCap));
|
|
84
83
|
}
|
|
85
84
|
/** {@link resolveByName} without its two special targets, i.e. the plain walk up the environments. */
|
|
86
85
|
function resolveByTargetType(id, environment, target) {
|
|
@@ -161,11 +160,7 @@ function resolveByTargetType(id, environment, target) {
|
|
|
161
160
|
? (builtIns === undefined || builtIns.length === 0 ? definitions : definitions.concat(builtIns))
|
|
162
161
|
: (builtIns === undefined || builtIns.length > 0 ? builtIns : undefined);
|
|
163
162
|
if (flattenAt !== undefined) {
|
|
164
|
-
|
|
165
|
-
if (memo.size >= TailCacheCap) {
|
|
166
|
-
memo.clear();
|
|
167
|
-
}
|
|
168
|
-
memo.set(name, result);
|
|
163
|
+
tailCacheOf(flattenAt, target).set(name, result);
|
|
169
164
|
}
|
|
170
165
|
return result;
|
|
171
166
|
}
|
|
@@ -509,19 +509,36 @@ class LoopRuns {
|
|
|
509
509
|
}
|
|
510
510
|
/** Whether a loop that surely runs at least once, standing before the read `from` in a block that holds it, surely redefines what `to`, made before the loop, defines, so the read no longer sees `to`. */
|
|
511
511
|
redefinedByLoop(from, to, edges) {
|
|
512
|
+
for (const { t, loop } of this.loopDefinitionsBefore(from, edges)) {
|
|
513
|
+
if (t !== to && !this.after(to, loop)
|
|
514
|
+
&& model_1.RNode.strictlyEnclosingFunction(to, this.idMap) === model_1.RNode.strictlyEnclosingFunction(loop, this.idMap)
|
|
515
|
+
&& !model_1.RNode.iterateParents(this.idMap.get(to), this.idMap).some(p => p.info.id === loop) && (this.runCount(loop) ?? 0) > 0) {
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
/** per read and its edges, the definitions {@link LoopRuns#redefinedByLoop} weighs, as only `to` differs between its questions */
|
|
522
|
+
loopDefinitions = new Map();
|
|
523
|
+
/** The definitions among the `edges` of the read `from` that a loop surely makes, standing before `from` in a block holding it. */
|
|
524
|
+
loopDefinitionsBefore(from, edges) {
|
|
525
|
+
const known = this.loopDefinitions.get(from);
|
|
526
|
+
if (known?.edges === edges) {
|
|
527
|
+
return known.found;
|
|
528
|
+
}
|
|
529
|
+
const found = [];
|
|
512
530
|
for (const [t, e] of edges) {
|
|
513
|
-
if (
|
|
531
|
+
if (!edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall) || this.graph.getVertex(t)?.cds?.some(cd => isCountedLoop(this.idMap.get(cd.id))) !== true
|
|
514
532
|
|| !vertex_1.DfgVertex.isVariableDefinition(this.graph.getVertex(t))) {
|
|
515
533
|
continue;
|
|
516
534
|
}
|
|
517
535
|
const loop = this.loopsAround(t, false)[0];
|
|
518
|
-
if (loop !== undefined && this.surelyIn(t, loop) && this.after(from, loop, true)
|
|
519
|
-
|
|
520
|
-
&& !model_1.RNode.iterateParents(this.idMap.get(to), this.idMap).some(p => p.info.id === loop) && (this.runCount(loop) ?? 0) > 0) {
|
|
521
|
-
return true;
|
|
536
|
+
if (loop !== undefined && this.surelyIn(t, loop) && this.after(from, loop, true)) {
|
|
537
|
+
found.push({ t, loop });
|
|
522
538
|
}
|
|
523
539
|
}
|
|
524
|
-
|
|
540
|
+
this.loopDefinitions.set(from, { edges, found });
|
|
541
|
+
return found;
|
|
525
542
|
}
|
|
526
543
|
/** Whether another definition among the `edges` of the read `from` in run `k` of the loop surely runs after `to` (made in run `toRun`, or before the loop if that is `undefined`) and before `from`, so the read no longer sees `to`. */
|
|
527
544
|
redefinedBetween(from, to, toRun, k, loop, edges) {
|
package/dataflow/extractor.js
CHANGED
|
@@ -47,6 +47,8 @@ const logger_1 = require("./logger");
|
|
|
47
47
|
const gas_1 = require("../gas");
|
|
48
48
|
const config_1 = require("../config");
|
|
49
49
|
const df_helper_1 = require("./graph/df-helper");
|
|
50
|
+
const fixpoint_1 = require("../util/fixpoint");
|
|
51
|
+
const monoid_1 = require("../util/monoid");
|
|
50
52
|
const built_in_ambient_state_1 = require("./internal/process/functions/call/built-in/built-in-ambient-state");
|
|
51
53
|
const ambient_state_name_1 = require("./environments/ambient-state-name");
|
|
52
54
|
const ambient_access_1 = require("./graph/ambient-access");
|
|
@@ -154,12 +156,16 @@ function callsUnseenBody(id, graph) {
|
|
|
154
156
|
if (!vertex_1.DfgVertex.isFunctionCall(call) || df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Calls).some(t => vertex_1.DfgVertex.isFunctionDefinition(graph.getVertex(t)))) {
|
|
155
157
|
return false;
|
|
156
158
|
}
|
|
159
|
+
if (call.origin === 'unnamed' || (Array.isArray(call.origin) && call.origin.every(o => o === 'function' || o === 'unnamed'))) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
/* resolving the name is the expensive part, so it comes last */
|
|
157
163
|
const ns = identifier_1.Identifier.getNamespace(df_helper_1.Dataflow.qualify(id, graph, false));
|
|
158
|
-
return
|
|
164
|
+
return ns !== undefined && !(0, r_base_packages_1.isBaseRPackage)(ns);
|
|
159
165
|
}
|
|
160
166
|
/** Whether the node creates or names an environment, as `new.env()`, `globalenv()` or `.GlobalEnv` do, or may return one, as a function whose body flowR does not see (`R6` objects are environments) */
|
|
161
|
-
function producesEnvironment(id, graph) {
|
|
162
|
-
return built_in_envir_utils_1.EnvironmentProducers.some(o => vertex_1.DfgVertex.hasOrigin(graph.getVertex(id), o)) || namesStackEnvironment(id, graph) ||
|
|
167
|
+
function producesEnvironment(id, graph, callsUnseen) {
|
|
168
|
+
return built_in_envir_utils_1.EnvironmentProducers.some(o => vertex_1.DfgVertex.hasOrigin(graph.getVertex(id), o)) || namesStackEnvironment(id, graph) || callsUnseen(id);
|
|
163
169
|
}
|
|
164
170
|
/** Whether the node names an environment of the search path or the call stack, as `globalenv()` or `.GlobalEnv` do, whose names no variable holds */
|
|
165
171
|
function namesStackEnvironment(id, graph) {
|
|
@@ -171,23 +177,27 @@ function namesStackEnvironment(id, graph) {
|
|
|
171
177
|
* The environments the value at `id` may be: the vertices creating them, followed through the parameters of the functions
|
|
172
178
|
* of the program to the arguments of their calls, and these calls, which hand the environment on.
|
|
173
179
|
*/
|
|
174
|
-
function environmentsAt(id, graph,
|
|
175
|
-
|
|
176
|
-
const
|
|
180
|
+
function environmentsAt(id, graph, boundTo, produces) {
|
|
181
|
+
/* sets, as many paths lead to the same producers and calls (each call of a function binds its parameter again), and every pair of them makes an edge */
|
|
182
|
+
const producers = new Set();
|
|
183
|
+
const via = new Set();
|
|
177
184
|
const seen = new Set();
|
|
185
|
+
/* many values lead to the same parameter, whose arguments are only worth one look */
|
|
186
|
+
const expanded = new Set();
|
|
178
187
|
const todo = [id];
|
|
179
188
|
for (let at = todo.pop(); at !== undefined; at = todo.pop()) {
|
|
180
189
|
if (seen.has(at)) {
|
|
181
190
|
continue;
|
|
182
191
|
}
|
|
183
192
|
seen.add(at);
|
|
184
|
-
for (const source of
|
|
185
|
-
if (
|
|
186
|
-
producers.
|
|
193
|
+
for (const source of produces(at) ? [at] : df_helper_1.Dataflow.valueSources(at, graph) ?? []) {
|
|
194
|
+
if (produces(source)) {
|
|
195
|
+
producers.add(source);
|
|
187
196
|
}
|
|
188
|
-
else if (
|
|
189
|
-
|
|
190
|
-
|
|
197
|
+
else if (!expanded.has(source)) {
|
|
198
|
+
expanded.add(source);
|
|
199
|
+
for (const { argument, calls } of boundTo(source) ?? []) {
|
|
200
|
+
calls.forEach(call => via.add(call));
|
|
191
201
|
todo.push(argument);
|
|
192
202
|
}
|
|
193
203
|
}
|
|
@@ -214,28 +224,52 @@ function linkEnvironmentsHandedToUnseenBodies(graph, environment) {
|
|
|
214
224
|
}
|
|
215
225
|
return holders.get(producer);
|
|
216
226
|
}
|
|
227
|
+
/* both are asked of the same vertices over and over (every value an argument may hold), and the edges added below change neither */
|
|
228
|
+
const callsUnseen = (0, defaultmap_1.memoize)((id) => callsUnseenBody(id, graph));
|
|
229
|
+
const produces = (0, defaultmap_1.memoize)((id) => producesEnvironment(id, graph, callsUnseen));
|
|
230
|
+
/* every value a parameter may hold leads to its arguments again, and their calls are picked out of all edges into them */
|
|
231
|
+
const boundTo = (0, defaultmap_1.memoize)((parameter) => parameters.has(parameter)
|
|
232
|
+
? df_helper_1.Dataflow.argumentsBoundTo(graph, parameter).map(argument => ({
|
|
233
|
+
argument,
|
|
234
|
+
calls: df_helper_1.Dataflow.sourcesOf(graph, argument, edge_1.EdgeType.Argument).filter(call => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(call)))
|
|
235
|
+
})).toArray()
|
|
236
|
+
: undefined);
|
|
237
|
+
/*
|
|
238
|
+
* an unknown side effect forgets every value the environment holds, so a writer only needs it once; the effects and edges
|
|
239
|
+
* are applied once every call is looked at, as any change to the graph drops what was resolved over it
|
|
240
|
+
*/
|
|
241
|
+
const written = new Set();
|
|
242
|
+
const reads = new graph_1.PendingEdges();
|
|
217
243
|
for (const [id, call] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
218
|
-
if (!
|
|
244
|
+
if (!callsUnseen(id)) {
|
|
219
245
|
continue;
|
|
220
246
|
}
|
|
221
247
|
for (const arg of call.args) {
|
|
222
248
|
const ref = graph_1.FunctionArgument.getReference(arg);
|
|
223
|
-
|
|
249
|
+
if (ref === undefined) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const { producers, via } = environmentsAt(ref, graph, boundTo, produces);
|
|
253
|
+
const writers = [id, ...via];
|
|
224
254
|
for (const producer of producers) {
|
|
225
255
|
if (namesStackEnvironment(producer, graph)) {
|
|
226
|
-
for (const writer of
|
|
227
|
-
|
|
256
|
+
for (const writer of writers) {
|
|
257
|
+
written.add(writer);
|
|
228
258
|
}
|
|
229
259
|
continue;
|
|
230
260
|
}
|
|
231
261
|
for (const holder of holdersOf(producer)) {
|
|
232
|
-
for (const writer of
|
|
233
|
-
|
|
262
|
+
for (const writer of writers) {
|
|
263
|
+
reads.add(holder, writer, edge_1.EdgeType.Reads);
|
|
234
264
|
}
|
|
235
265
|
}
|
|
236
266
|
}
|
|
237
267
|
}
|
|
238
268
|
}
|
|
269
|
+
for (const writer of written) {
|
|
270
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, writer);
|
|
271
|
+
}
|
|
272
|
+
reads.applyTo(graph);
|
|
239
273
|
}
|
|
240
274
|
function tracksAnyEnvironment(environment) {
|
|
241
275
|
return environment_1.REnvironment.frames(environment.current).some(e => e.memory.values().some(defs => defs.some(identifier_1.hasEnvState)));
|
|
@@ -464,9 +498,6 @@ function splitsResources(info) {
|
|
|
464
498
|
function resourceArgs(vertex, info, writes) {
|
|
465
499
|
return info?.sig === undefined ? [] : match_args_1.MatchArgs.findWithProps(vertex.args, built_in_props_1.FnSig.resources(info.sig, writes), built_in_props_1.ArgProp.Resource);
|
|
466
500
|
}
|
|
467
|
-
function definitionsReachedBy(node, graph) {
|
|
468
|
-
return df_helper_1.Dataflow.reachable(graph, node, { follow: edge_1.EdgeType.Reads, stopAt: id => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(id)) });
|
|
469
|
-
}
|
|
470
501
|
function fileCallNames(index) {
|
|
471
502
|
return new Set(index.with(built_in_props_1.SemanticCallTag.File).map(identifier_1.Identifier.getName));
|
|
472
503
|
}
|
|
@@ -512,16 +543,50 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
|
|
|
512
543
|
if (readers.length === 0 || writers.length === 0) {
|
|
513
544
|
return;
|
|
514
545
|
}
|
|
515
|
-
|
|
546
|
+
/* the variables a resource is made from, and what reads lead there: the walks from every resource share their vertices, so each vertex's reads are picked out of its edges once */
|
|
547
|
+
const readsOf = (0, defaultmap_1.memoize)((id) => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(id)) ? [] : df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads));
|
|
548
|
+
const reachedBy = (0, defaultmap_1.memoize)((id) => {
|
|
549
|
+
const reached = new Set();
|
|
550
|
+
const pending = [id];
|
|
551
|
+
for (let current = pending.pop(); current !== undefined; current = pending.pop()) {
|
|
552
|
+
if (reached.has(current)) {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
reached.add(current);
|
|
556
|
+
for (const next of readsOf(current)) {
|
|
557
|
+
pending.push(next);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return reached;
|
|
561
|
+
});
|
|
516
562
|
const where = { graph, idMap: graph.idMap, resolve: ctx.config.solver.variables, ctx, environment };
|
|
517
563
|
const pathOf = (0, defaultmap_1.memoize)((id) => resolve_helper_1.Resolve.toSingleString(id, where));
|
|
518
|
-
/*
|
|
519
|
-
|
|
520
|
-
|
|
564
|
+
/*
|
|
565
|
+
* every `tempfile()` call names a file of its own, so paths made from different ones differ; which ones a path is made from is
|
|
566
|
+
* its provenance, summarized once for all resources (see `Dataflow.provenance` for the edges it follows) rather than walked per resource
|
|
567
|
+
*/
|
|
568
|
+
const isTempFile = (0, defaultmap_1.memoize)((v) => {
|
|
521
569
|
const call = graph.getVertex(v);
|
|
522
570
|
return vertex_1.DfgVertex.isFunctionCall(call) && call.name !== undefined && identifier_1.Identifier.getName(call.name) === 'tempfile'
|
|
523
571
|
&& function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(v, { graph, environment }), [built_in_props_1.SemanticCallTag.TempFile]);
|
|
524
|
-
})
|
|
572
|
+
});
|
|
573
|
+
const tempFilesBehind = new fixpoint_1.ReachSummaries(current => {
|
|
574
|
+
const vertex = graph.get(current);
|
|
575
|
+
if (vertex === undefined) {
|
|
576
|
+
return [];
|
|
577
|
+
}
|
|
578
|
+
const next = [];
|
|
579
|
+
for (const [to, types] of vertex[1]) {
|
|
580
|
+
if (edge_1.DfEdge.includesType(types, df_helper_1.ProvenanceEdges)) {
|
|
581
|
+
next.push(to);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
for (const cd of vertex[0].cds ?? []) {
|
|
585
|
+
next.push(cd.id);
|
|
586
|
+
}
|
|
587
|
+
return next;
|
|
588
|
+
}, v => isTempFile(v) ? new Set([v]) : undefined, monoid_1.Monoid.set());
|
|
589
|
+
const tempFiles = (id) => tempFilesBehind.of(r_argument_1.RArgument.valueOf(graph.idMap?.get(id))?.info.id ?? id);
|
|
525
590
|
function sameResource(a, b) {
|
|
526
591
|
if (a === b) {
|
|
527
592
|
return true;
|
|
@@ -586,12 +651,19 @@ function fileWriteLevels(writer, graph, idMap, paths) {
|
|
|
586
651
|
if (first === undefined || affected.size === 0) {
|
|
587
652
|
return undefined;
|
|
588
653
|
}
|
|
654
|
+
/* per definition, the affected calls calling it, in the order of `affected`, worked out once rather than per level */
|
|
655
|
+
const callsOf = new Map();
|
|
656
|
+
for (const call of affected) {
|
|
657
|
+
for (const target of new Set(df_helper_1.Dataflow.targetsOf(graph, call, edge_1.EdgeType.Calls))) {
|
|
658
|
+
(0, defaultmap_1.getOrSet)(callsOf, target, () => []).push(call);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
589
661
|
const levels = [];
|
|
590
662
|
const covered = new Set();
|
|
591
663
|
const queue = [{ at: writer, definition: first, context: new Map() }];
|
|
592
664
|
for (let item = queue.shift(); item !== undefined; item = queue.shift()) {
|
|
593
665
|
const { at, definition, context } = item;
|
|
594
|
-
const calls =
|
|
666
|
+
const calls = callsOf.get(definition) ?? [];
|
|
595
667
|
if (calls.length === 0 || context.has(definition)) {
|
|
596
668
|
return undefined;
|
|
597
669
|
}
|
|
@@ -660,6 +732,8 @@ function linkReadsOfDivertedOutput(graph, environment) {
|
|
|
660
732
|
const printsOf = (0, defaultmap_1.memoize)((id) => function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(id, { graph, environment }), [built_in_props_1.SemanticCallTag.Prints]));
|
|
661
733
|
const printingCall = (writer) => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(writer)) && printsOf(writer);
|
|
662
734
|
const writersOf = (0, defaultmap_1.memoize)((target) => df_helper_1.Dataflow.sourcesOf(graph, target, edge_1.EdgeType.Reads).filter(printingCall));
|
|
735
|
+
/* added once every read is looked at: any change to the graph drops the call targets resolved over it */
|
|
736
|
+
const reads = new graph_1.PendingEdges();
|
|
663
737
|
for (const [id] of graph.verticesOfType(vertex_1.VertexType.Use)) {
|
|
664
738
|
for (const target of df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads)) {
|
|
665
739
|
const diverting = graph.getVertex(target);
|
|
@@ -668,11 +742,12 @@ function linkReadsOfDivertedOutput(graph, environment) {
|
|
|
668
742
|
}
|
|
669
743
|
for (const writer of writersOf(target)) {
|
|
670
744
|
if (writer !== id) {
|
|
671
|
-
|
|
745
|
+
reads.add(id, writer, edge_1.EdgeType.Reads);
|
|
672
746
|
}
|
|
673
747
|
}
|
|
674
748
|
}
|
|
675
749
|
}
|
|
750
|
+
reads.applyTo(graph);
|
|
676
751
|
}
|
|
677
752
|
function resolveLinkToSideEffects(graph, ctx) {
|
|
678
753
|
const gasLevel = ctx.gas.checkGas(gas_1.GasFeatureKey.SideEffectLinking);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* The `FunctionSemantics` facade wires these together, so a sibling here has to call the backing function directly; going through `FunctionSemantics` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
|
|
3
3
|
* @lintIgnore use-instead
|
|
4
4
|
*/
|
|
5
|
+
import type { SigNativeRoutineInfo } from '../../project/sigdb/schema';
|
|
5
6
|
import { type DataflowGraph } from '../graph/graph';
|
|
6
7
|
import { type ArgProps } from '../environments/built-in-props';
|
|
7
8
|
import { type BuiltInLookup } from './frame-reflection';
|
|
@@ -15,6 +16,8 @@ export declare const DefaultDepth = 6;
|
|
|
15
16
|
export interface ArgumentRolesOptions {
|
|
16
17
|
/** how to ask what a built-in states, so a configured or overwritten one answers */
|
|
17
18
|
readonly ctx?: ReadOnlyFlowrAnalyzerContext;
|
|
19
|
+
/** the native routines of the analyzed package, which flowR cannot read off its compiled code itself */
|
|
20
|
+
readonly natives?: readonly SigNativeRoutineInfo[];
|
|
18
21
|
/** how far a value is followed back through names and calls (default {@link DefaultDepth}) */
|
|
19
22
|
readonly maxDepth?: number;
|
|
20
23
|
}
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultDepth = void 0;
|
|
4
4
|
exports.argumentRolesOfFunctions = argumentRolesOfFunctions;
|
|
5
|
-
/**
|
|
6
|
-
* The `FunctionSemantics` facade wires these together, so a sibling here has to call the backing function directly; going through `FunctionSemantics` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
|
|
7
|
-
* @lintIgnore use-instead
|
|
8
|
-
*/
|
|
9
5
|
const graph_1 = require("../graph/graph");
|
|
10
6
|
const function_semantics_1 = require("./function-semantics");
|
|
11
7
|
const df_helper_1 = require("../graph/df-helper");
|
|
@@ -20,6 +16,7 @@ const identifier_1 = require("../environments/identifier");
|
|
|
20
16
|
const r_logical_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
|
|
21
17
|
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
22
18
|
const info_1 = require("../info");
|
|
19
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
23
20
|
/** How far a value is followed back: enough for `y <- x; y`, not a whole slice. */
|
|
24
21
|
exports.DefaultDepth = 6;
|
|
25
22
|
/**
|
|
@@ -38,7 +35,7 @@ function argumentRolesOfFunctions(ids, graph, options = {}) {
|
|
|
38
35
|
return all;
|
|
39
36
|
}
|
|
40
37
|
function roleStateOf(graph, { ctx, maxDepth = exports.DefaultDepth }) {
|
|
41
|
-
return { graph, info: (0, query_fn_props_1.builtInLookup)(ctx), maxDepth, args: new Map(), identities: new Map() };
|
|
38
|
+
return { graph, info: (0, query_fn_props_1.builtInLookup)(ctx), maxDepth, args: new Map(), identities: new Map(), sameValue: new Map() };
|
|
42
39
|
}
|
|
43
40
|
function rolesOf(id, state) {
|
|
44
41
|
const definition = state.graph.getVertex(id);
|
|
@@ -129,6 +126,9 @@ function intersect(sets) {
|
|
|
129
126
|
}
|
|
130
127
|
/** The nodes the value of `node` may be, split into the branches it picks one of and the steps it always takes. */
|
|
131
128
|
function sameValueAs(node, state) {
|
|
129
|
+
return (0, defaultmap_1.getOrSet)(state.sameValue, node, () => sameValueAsUncached(node, state));
|
|
130
|
+
}
|
|
131
|
+
function sameValueAsUncached(node, state) {
|
|
132
132
|
const graph = state.graph;
|
|
133
133
|
const vertex = graph.getVertex(node);
|
|
134
134
|
const returns = takesApart(vertex) ? [] : df_helper_1.Dataflow.targetsOf(graph, node, edge_1.EdgeType.Returns);
|
|
@@ -17,3 +17,10 @@ export interface FunctionExceptionsOptions {
|
|
|
17
17
|
* @useInstead {@link FunctionSemantics.exceptions}
|
|
18
18
|
*/
|
|
19
19
|
export declare function exceptionsOfFunction(this: void, id: NodeId, graph: CallGraph, { knownThrower }?: FunctionExceptionsOptions): ExceptionsByFunction;
|
|
20
|
+
/**
|
|
21
|
+
* {@link exceptionsOfFunction} for several definitions of one call graph at once: what a call raises is summarized once and
|
|
22
|
+
* shared by every definition reaching it, rather than walked again per definition. Answers for the `ids` and every
|
|
23
|
+
* definition the walk passed.
|
|
24
|
+
* @useInstead {@link FunctionSemantics.exceptionsOfAll}
|
|
25
|
+
*/
|
|
26
|
+
export declare function exceptionsOfFunctions(this: void, ids: Iterable<NodeId>, graph: CallGraph, { knownThrower }?: FunctionExceptionsOptions): ExceptionsByFunction;
|