@eagleoutice/flowr 2.6.3 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
- package/abstract-interpretation/data-frame/absint-visitor.js +3 -3
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -7
- package/abstract-interpretation/data-frame/dataframe-domain.js +5 -11
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +3 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +3 -2
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +3 -1
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +3 -2
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +8 -8
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +3 -1
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +3 -2
- package/abstract-interpretation/data-frame/semantics.js +47 -42
- package/abstract-interpretation/data-frame/shape-inference.d.ts +1 -1
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -0
- package/abstract-interpretation/domains/abstract-domain.js +3 -2
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +2 -2
- package/abstract-interpretation/domains/interval-domain.js +3 -6
- package/abstract-interpretation/domains/lattice.d.ts +2 -0
- package/abstract-interpretation/domains/lattice.js +3 -1
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/positive-interval-domain.js +1 -1
- package/abstract-interpretation/domains/satisfiable-domain.d.ts +2 -2
- package/abstract-interpretation/domains/satisfiable-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +98 -0
- package/abstract-interpretation/domains/set-range-domain.js +400 -0
- package/abstract-interpretation/domains/set-upper-bound-domain.js +2 -2
- package/abstract-interpretation/domains/singleton-domain.js +2 -2
- package/benchmark/slicer.d.ts +2 -1
- package/benchmark/slicer.js +37 -15
- package/benchmark/stats/print.js +8 -5
- package/benchmark/stats/stats.d.ts +3 -2
- package/benchmark/summarizer/data.d.ts +11 -8
- package/benchmark/summarizer/first-phase/process.js +11 -8
- package/benchmark/summarizer/second-phase/process.js +24 -18
- package/control-flow/cfg-dead-code.js +3 -2
- package/control-flow/useless-loop.js +4 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +3 -0
- package/core/steps/all/static-slicing/00-slice.js +2 -1
- package/core/steps/pipeline/default-pipelines.d.ts +42 -42
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/append.d.ts +5 -0
- package/dataflow/environments/append.js +6 -20
- package/dataflow/environments/built-in.d.ts +2 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/clone.js +3 -27
- package/dataflow/environments/define.d.ts +7 -3
- package/dataflow/environments/define.js +9 -56
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.d.ts +48 -28
- package/dataflow/environments/environment.js +187 -62
- package/dataflow/environments/overwrite.js +2 -45
- package/dataflow/environments/reference-to-maybe.d.ts +13 -0
- package/dataflow/environments/reference-to-maybe.js +54 -0
- package/dataflow/environments/resolve-by-name.d.ts +6 -1
- package/dataflow/environments/resolve-by-name.js +56 -4
- package/dataflow/environments/scoping.d.ts +2 -2
- package/dataflow/environments/scoping.js +7 -7
- package/dataflow/eval/resolve/alias-tracking.d.ts +10 -4
- package/dataflow/eval/resolve/alias-tracking.js +15 -13
- package/dataflow/eval/resolve/resolve-argument.d.ts +2 -1
- package/dataflow/eval/resolve/resolve-argument.js +8 -8
- package/dataflow/eval/resolve/resolve.d.ts +13 -11
- package/dataflow/eval/resolve/resolve.js +16 -15
- package/dataflow/extractor.js +1 -7
- package/dataflow/fn/higher-order-function.d.ts +2 -1
- package/dataflow/fn/higher-order-function.js +4 -4
- package/dataflow/graph/dataflowgraph-builder.d.ts +9 -5
- package/dataflow/graph/dataflowgraph-builder.js +21 -11
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/graph.d.ts +10 -2
- package/dataflow/graph/graph.js +41 -12
- package/dataflow/graph/invert-dfg.d.ts +3 -2
- package/dataflow/graph/invert-dfg.js +3 -3
- package/dataflow/graph/resolve-graph.d.ts +2 -1
- package/dataflow/graph/resolve-graph.js +2 -2
- package/dataflow/graph/vertex.d.ts +3 -3
- package/dataflow/graph/vertex.js +3 -3
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.js +3 -7
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +7 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +12 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +9 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +9 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +8 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -5
- package/dataflow/internal/process/functions/call/common.js +2 -3
- package/dataflow/internal/process/functions/call/known-call-handling.js +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
- package/dataflow/internal/process/functions/process-argument.js +1 -1
- package/dataflow/internal/process/process-symbol.js +1 -1
- package/dataflow/internal/process/process-value.d.ts +1 -1
- package/dataflow/internal/process/process-value.js +7 -7
- package/dataflow/processor.d.ts +1 -5
- package/documentation/doc-util/doc-dfg.js +3 -2
- package/documentation/doc-util/doc-normalized-ast.js +3 -2
- package/documentation/doc-util/doc-types.d.ts +1 -1
- package/documentation/doc-util/doc-types.js +2 -2
- package/documentation/wiki-analyzer.js +14 -1
- package/documentation/wiki-dataflow-graph.js +4 -5
- package/documentation/wiki-faq.js +0 -1
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-mk/doc-maker.js +2 -1
- package/linter/linter-rules.d.ts +2 -2
- package/linter/rules/absolute-path.js +4 -4
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.js +1 -1
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/network-functions.js +1 -1
- package/linter/rules/seeded-randomness.d.ts +1 -1
- package/linter/rules/seeded-randomness.js +5 -5
- package/package.json +1 -2
- package/project/context/flowr-analyzer-context.d.ts +7 -0
- package/project/context/flowr-analyzer-context.js +3 -0
- package/project/context/flowr-analyzer-environment-context.d.ts +47 -0
- package/project/context/flowr-analyzer-environment-context.js +50 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -4
- package/queries/catalog/control-flow-query/control-flow-query-format.js +3 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -4
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +4 -4
- package/queries/catalog/df-shape-query/df-shape-query-format.js +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/slicing/static/slice-call.d.ts +3 -2
- package/slicing/static/slice-call.js +4 -4
- package/slicing/static/static-slicer.d.ts +3 -1
- package/slicing/static/static-slicer.js +6 -7
- package/statistics/features/supported/control-flow/control-flow.js +1 -1
- package/statistics/features/supported/used-functions/used-functions.js +1 -1
- package/statistics/features/supported/variables/variables.js +2 -1
- package/util/containers.js +1 -1
- package/util/mermaid/dfg.d.ts +1 -0
- package/util/mermaid/dfg.js +3 -3
- package/util/simple-df/dfg-view.d.ts +2 -1
- package/util/simple-df/dfg-view.js +2 -2
- package/util/version.js +1 -1
- package/dataflow/environments/remove.d.ts +0 -12
- package/dataflow/environments/remove.js +0 -52
|
@@ -207,8 +207,8 @@ function diffVertices(ctx) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
if (lInfo.tag ===
|
|
211
|
-
if (rInfo.tag !==
|
|
210
|
+
if (lInfo.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
211
|
+
if (rInfo.tag !== vertex_1.VertexType.FunctionDefinition) {
|
|
212
212
|
ctx.report.addComment(`Vertex ${id} differs in tags. ${ctx.leftname}: ${lInfo.tag} vs. ${ctx.rightname}: ${rInfo.tag}`, { tag: 'vertex', id });
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
@@ -4,6 +4,7 @@ import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall,
|
|
|
4
4
|
import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { Identifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
|
|
6
6
|
import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
import { type REnvironmentInformation } from '../environments/environment';
|
|
7
8
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
9
|
import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
9
10
|
/**
|
|
@@ -71,6 +72,7 @@ export interface DataflowGraphJson {
|
|
|
71
72
|
readonly rootVertices: NodeId[];
|
|
72
73
|
readonly vertexInformation: [NodeId, DataflowGraphVertexInfo][];
|
|
73
74
|
readonly edgeInformation: [NodeId, [NodeId, DataflowGraphEdge][]][];
|
|
75
|
+
readonly _unknownSideEffects: UnknownSideEffect[];
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
78
|
* An unknown side effect describes something that we cannot handle correctly (in all cases).
|
|
@@ -98,7 +100,6 @@ export type UnknownSideEffect = NodeId | {
|
|
|
98
100
|
* @see {@link emptyGraph|`emptyGraph`} - to create an empty graph (useful in tests)
|
|
99
101
|
*/
|
|
100
102
|
export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo, Edge extends DataflowGraphEdge = DataflowGraphEdge> {
|
|
101
|
-
private static DEFAULT_ENVIRONMENT;
|
|
102
103
|
private _idMap;
|
|
103
104
|
private readonly _unknownSideEffects;
|
|
104
105
|
constructor(idMap: AstIdMap | undefined);
|
|
@@ -108,6 +109,8 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
108
109
|
private vertexInformation;
|
|
109
110
|
/** All edges in the complete graph (including those nested in function definition) */
|
|
110
111
|
private edgeInformation;
|
|
112
|
+
private types;
|
|
113
|
+
toJSON(): DataflowGraphJson;
|
|
111
114
|
/**
|
|
112
115
|
* Get the {@link DataflowGraphVertexInfo} attached to a node as well as all outgoing edges.
|
|
113
116
|
* @param id - The id of the node to get
|
|
@@ -147,6 +150,10 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
147
150
|
* @see #edges
|
|
148
151
|
*/
|
|
149
152
|
vertices(includeDefinedFunctions: boolean): MapIterator<[NodeId, Vertex]>;
|
|
153
|
+
verticesOfType<T extends Vertex['tag']>(type: T): MapIterator<[NodeId, Vertex & {
|
|
154
|
+
tag: T;
|
|
155
|
+
}]>;
|
|
156
|
+
vertexIdsOfType<T extends Vertex['tag']>(type: T): NodeId[];
|
|
150
157
|
/**
|
|
151
158
|
* @returns the ids of all edges in the graph together with their edge information
|
|
152
159
|
* @see #vertices
|
|
@@ -166,13 +173,14 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
166
173
|
/**
|
|
167
174
|
* Adds a new vertex to the graph, for ease of use, some arguments are optional and filled automatically.
|
|
168
175
|
* @param vertex - The vertex to add
|
|
176
|
+
* @param fallbackEnv - A clean environment to use if no environment is given in the vertex
|
|
169
177
|
* @param asRoot - If false, this will only add the vertex but do not add it to the {@link rootIds|root vertices} of the graph.
|
|
170
178
|
* This is probably only of use, when you construct dataflow graphs for tests.
|
|
171
179
|
* @param overwrite - If true, this will overwrite the vertex if it already exists in the graph (based on the id).
|
|
172
180
|
* @see DataflowGraphVertexInfo
|
|
173
181
|
* @see DataflowGraphVertexArgument
|
|
174
182
|
*/
|
|
175
|
-
addVertex(vertex: DataflowGraphVertexArgument & Omit<Vertex, keyof DataflowGraphVertexArgument>, asRoot?: boolean, overwrite?: boolean): this;
|
|
183
|
+
addVertex(vertex: DataflowGraphVertexArgument & Omit<Vertex, keyof DataflowGraphVertexArgument>, fallbackEnv: REnvironmentInformation, asRoot?: boolean, overwrite?: boolean): this;
|
|
176
184
|
/** {@inheritDoc} */
|
|
177
185
|
addEdge(from: NodeId, to: NodeId, type: EdgeType | number): this;
|
|
178
186
|
/** {@inheritDoc} */
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -51,7 +51,6 @@ function getReferenceOfArgument(arg) {
|
|
|
51
51
|
* @see {@link emptyGraph|`emptyGraph`} - to create an empty graph (useful in tests)
|
|
52
52
|
*/
|
|
53
53
|
class DataflowGraph {
|
|
54
|
-
static DEFAULT_ENVIRONMENT = undefined;
|
|
55
54
|
_idMap;
|
|
56
55
|
/*
|
|
57
56
|
* Set of vertices which have sideEffects that we do not know anything about.
|
|
@@ -60,7 +59,6 @@ class DataflowGraph {
|
|
|
60
59
|
*/
|
|
61
60
|
_unknownSideEffects = new Set();
|
|
62
61
|
constructor(idMap) {
|
|
63
|
-
DataflowGraph.DEFAULT_ENVIRONMENT ??= (0, environment_1.initializeCleanEnvironments)();
|
|
64
62
|
this._idMap = idMap;
|
|
65
63
|
}
|
|
66
64
|
/** Contains the vertices of the root level graph (i.e., included those vertices from the complete graph, that are nested within function definitions) */
|
|
@@ -69,6 +67,15 @@ class DataflowGraph {
|
|
|
69
67
|
vertexInformation = new Map();
|
|
70
68
|
/** All edges in the complete graph (including those nested in function definition) */
|
|
71
69
|
edgeInformation = new Map();
|
|
70
|
+
types = new Map();
|
|
71
|
+
toJSON() {
|
|
72
|
+
return {
|
|
73
|
+
rootVertices: Array.from(this.rootVertices),
|
|
74
|
+
vertexInformation: Array.from(this.vertexInformation.entries()),
|
|
75
|
+
edgeInformation: Array.from(this.edgeInformation.entries()).map(([id, edges]) => [id, Array.from(edges.entries())]),
|
|
76
|
+
_unknownSideEffects: Array.from(this._unknownSideEffects)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
72
79
|
/**
|
|
73
80
|
* Get the {@link DataflowGraphVertexInfo} attached to a node as well as all outgoing edges.
|
|
74
81
|
* @param id - The id of the node to get
|
|
@@ -150,6 +157,15 @@ class DataflowGraph {
|
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
159
|
}
|
|
160
|
+
*verticesOfType(type) {
|
|
161
|
+
const ids = this.types.get(type) ?? [];
|
|
162
|
+
for (const id of ids) {
|
|
163
|
+
yield [id, this.vertexInformation.get(id)];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
vertexIdsOfType(type) {
|
|
167
|
+
return this.types.get(type) ?? [];
|
|
168
|
+
}
|
|
153
169
|
/**
|
|
154
170
|
* @returns the ids of all edges in the graph together with their edge information
|
|
155
171
|
* @see #vertices
|
|
@@ -177,24 +193,32 @@ class DataflowGraph {
|
|
|
177
193
|
/**
|
|
178
194
|
* Adds a new vertex to the graph, for ease of use, some arguments are optional and filled automatically.
|
|
179
195
|
* @param vertex - The vertex to add
|
|
196
|
+
* @param fallbackEnv - A clean environment to use if no environment is given in the vertex
|
|
180
197
|
* @param asRoot - If false, this will only add the vertex but do not add it to the {@link rootIds|root vertices} of the graph.
|
|
181
198
|
* This is probably only of use, when you construct dataflow graphs for tests.
|
|
182
199
|
* @param overwrite - If true, this will overwrite the vertex if it already exists in the graph (based on the id).
|
|
183
200
|
* @see DataflowGraphVertexInfo
|
|
184
201
|
* @see DataflowGraphVertexArgument
|
|
185
202
|
*/
|
|
186
|
-
addVertex(vertex, asRoot = true, overwrite = false) {
|
|
203
|
+
addVertex(vertex, fallbackEnv, asRoot = true, overwrite = false) {
|
|
187
204
|
const oldVertex = this.vertexInformation.get(vertex.id);
|
|
188
205
|
if (oldVertex !== undefined && !overwrite) {
|
|
189
206
|
return this;
|
|
190
207
|
}
|
|
191
|
-
const fallback = vertex.tag === vertex_1.VertexType.
|
|
208
|
+
const fallback = vertex.tag === vertex_1.VertexType.FunctionDefinition || (vertex.tag === vertex_1.VertexType.FunctionCall && !vertex.onlyBuiltin) ? fallbackEnv : undefined;
|
|
192
209
|
// keep a clone of the original environment
|
|
193
210
|
const environment = vertex.environment ? (0, clone_1.cloneEnvironmentInformation)(vertex.environment) : fallback;
|
|
194
211
|
this.vertexInformation.set(vertex.id, {
|
|
195
212
|
...vertex,
|
|
196
213
|
environment
|
|
197
214
|
});
|
|
215
|
+
const has = this.types.get(vertex.tag);
|
|
216
|
+
if (has) {
|
|
217
|
+
has.push(vertex.id);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.types.set(vertex.tag, [vertex.id]);
|
|
221
|
+
}
|
|
198
222
|
if (asRoot) {
|
|
199
223
|
this.rootVertices.add(vertex.id);
|
|
200
224
|
}
|
|
@@ -246,6 +270,10 @@ class DataflowGraph {
|
|
|
246
270
|
const currentInfo = this.vertexInformation.get(id);
|
|
247
271
|
this.vertexInformation.set(id, currentInfo === undefined ? info : mergeNodeInfos(currentInfo, info));
|
|
248
272
|
}
|
|
273
|
+
for (const [type, ids] of otherGraph.types) {
|
|
274
|
+
const existing = this.types.get(type);
|
|
275
|
+
this.types.set(type, existing ? existing.concat(ids) : ids.slice());
|
|
276
|
+
}
|
|
249
277
|
this.mergeEdges(otherGraph);
|
|
250
278
|
return this;
|
|
251
279
|
}
|
|
@@ -289,7 +317,10 @@ class DataflowGraph {
|
|
|
289
317
|
updateToFunctionCall(info) {
|
|
290
318
|
const vertex = this.getVertex(info.id, true);
|
|
291
319
|
(0, assert_1.guard)(vertex !== undefined && (vertex.tag === vertex_1.VertexType.Use || vertex.tag === vertex_1.VertexType.Value), () => `node must be a use or value node for ${JSON.stringify(info.id)} to update it to a function call but is ${vertex?.tag}`);
|
|
320
|
+
const previousTag = vertex.tag;
|
|
292
321
|
this.vertexInformation.set(info.id, { ...vertex, ...info, tag: vertex_1.VertexType.FunctionCall });
|
|
322
|
+
this.types.set(previousTag, (this.types.get(previousTag) ?? []).filter(id => id !== info.id));
|
|
323
|
+
this.types.set(vertex_1.VertexType.FunctionCall, (this.types.get(vertex_1.VertexType.FunctionCall) ?? []).concat([info.id]));
|
|
293
324
|
}
|
|
294
325
|
/** If you do not pass the `to` node, this will just mark the node as maybe */
|
|
295
326
|
addControlDependency(from, to, when) {
|
|
@@ -338,6 +369,9 @@ class DataflowGraph {
|
|
|
338
369
|
}
|
|
339
370
|
}
|
|
340
371
|
graph.edgeInformation = new Map(data.edgeInformation.map(([id, edges]) => [id, new Map(edges)]));
|
|
372
|
+
for (const unknown of data._unknownSideEffects) {
|
|
373
|
+
graph._unknownSideEffects.add(unknown);
|
|
374
|
+
}
|
|
341
375
|
return graph;
|
|
342
376
|
}
|
|
343
377
|
}
|
|
@@ -373,14 +407,9 @@ function envFromJson(json) {
|
|
|
373
407
|
for (const [key, value] of Object.entries(json.memory)) {
|
|
374
408
|
memory.set(key, value);
|
|
375
409
|
}
|
|
376
|
-
const obj =
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
memory
|
|
380
|
-
};
|
|
381
|
-
if (json.builtInEnv) {
|
|
382
|
-
obj.builtInEnv = true;
|
|
383
|
-
}
|
|
410
|
+
const obj = new environment_1.Environment(parent, json.builtInEnv);
|
|
411
|
+
obj.id = json.id;
|
|
412
|
+
obj.memory = memory;
|
|
384
413
|
return obj;
|
|
385
414
|
}
|
|
386
415
|
function renvFromJson(json) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataflowGraph } from './graph';
|
|
2
|
+
import type { REnvironmentInformation } from '../environments/environment';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Inverts the given dataflow graph by reversing all edges.
|
|
4
5
|
*/
|
|
5
|
-
export declare function invertDfg(graph: DataflowGraph): DataflowGraph;
|
|
6
|
+
export declare function invertDfg(graph: DataflowGraph, cleanEnv: REnvironmentInformation): DataflowGraph;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.invertDfg = invertDfg;
|
|
4
4
|
const graph_1 = require("./graph");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Inverts the given dataflow graph by reversing all edges.
|
|
7
7
|
*/
|
|
8
|
-
function invertDfg(graph) {
|
|
8
|
+
function invertDfg(graph, cleanEnv) {
|
|
9
9
|
const invertedGraph = new graph_1.DataflowGraph(graph.idMap);
|
|
10
10
|
for (const [, v] of graph.vertices(true)) {
|
|
11
|
-
invertedGraph.addVertex(v);
|
|
11
|
+
invertedGraph.addVertex(v, cleanEnv);
|
|
12
12
|
}
|
|
13
13
|
for (const [from, targets] of graph.edges()) {
|
|
14
14
|
for (const [to, { types }] of targets) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DataflowGraph } from './graph';
|
|
2
2
|
import { type AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
3
4
|
/**
|
|
4
5
|
* Resolves the dataflow graph ids from slicing criterion form to ids.
|
|
5
6
|
* This returns a **new** graph with the resolved ids.
|
|
6
7
|
*/
|
|
7
|
-
export declare function resolveDataflowGraph(graph: DataflowGraph, idMap?: AstIdMap): DataflowGraph;
|
|
8
|
+
export declare function resolveDataflowGraph(graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap): DataflowGraph;
|
|
@@ -9,7 +9,7 @@ const edge_1 = require("./edge");
|
|
|
9
9
|
* Resolves the dataflow graph ids from slicing criterion form to ids.
|
|
10
10
|
* This returns a **new** graph with the resolved ids.
|
|
11
11
|
*/
|
|
12
|
-
function resolveDataflowGraph(graph, idMap) {
|
|
12
|
+
function resolveDataflowGraph(graph, ctx, idMap) {
|
|
13
13
|
const resolveMap = idMap ?? graph.idMap;
|
|
14
14
|
(0, assert_1.guard)(resolveMap !== undefined, 'idMap must be provided to resolve the graph');
|
|
15
15
|
const cache = new Map();
|
|
@@ -36,7 +36,7 @@ function resolveDataflowGraph(graph, idMap) {
|
|
|
36
36
|
resultGraph.addVertex({
|
|
37
37
|
...vertex,
|
|
38
38
|
id: resolve(id)
|
|
39
|
-
}, roots.has(id));
|
|
39
|
+
}, ctx.env.makeCleanEnv(), roots.has(id));
|
|
40
40
|
}
|
|
41
41
|
/* recreate edges */
|
|
42
42
|
for (const [from, targets] of graph.edges()) {
|
|
@@ -7,9 +7,9 @@ import type { BuiltInMappingName } from '../environments/built-in';
|
|
|
7
7
|
export declare enum VertexType {
|
|
8
8
|
Value = "value",
|
|
9
9
|
Use = "use",
|
|
10
|
-
FunctionCall = "
|
|
11
|
-
VariableDefinition = "
|
|
12
|
-
FunctionDefinition = "
|
|
10
|
+
FunctionCall = "fcall",
|
|
11
|
+
VariableDefinition = "vdef",
|
|
12
|
+
FunctionDefinition = "fdef"
|
|
13
13
|
}
|
|
14
14
|
export declare const ValidVertexTypes: Set<string>;
|
|
15
15
|
export declare const ValidVertexTypeReverse: {
|
package/dataflow/graph/vertex.js
CHANGED
|
@@ -14,9 +14,9 @@ var VertexType;
|
|
|
14
14
|
(function (VertexType) {
|
|
15
15
|
VertexType["Value"] = "value";
|
|
16
16
|
VertexType["Use"] = "use";
|
|
17
|
-
VertexType["FunctionCall"] = "
|
|
18
|
-
VertexType["VariableDefinition"] = "
|
|
19
|
-
VertexType["FunctionDefinition"] = "
|
|
17
|
+
VertexType["FunctionCall"] = "fcall";
|
|
18
|
+
VertexType["VariableDefinition"] = "vdef";
|
|
19
|
+
VertexType["FunctionDefinition"] = "fdef";
|
|
20
20
|
})(VertexType || (exports.VertexType = VertexType = {}));
|
|
21
21
|
exports.ValidVertexTypes = new Set(Object.values(VertexType));
|
|
22
22
|
exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
|
package/dataflow/info.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export interface DataflowInformation extends DataflowCfgInformation {
|
|
|
102
102
|
* This is to be used as a "starting point" when processing leaf nodes during the dataflow extraction.
|
|
103
103
|
* @see {@link DataflowInformation}
|
|
104
104
|
*/
|
|
105
|
-
export declare function initializeCleanDataflowInformation<T>(entryPoint: NodeId, data: Pick<DataflowProcessorInformation<T>, 'environment' | '
|
|
105
|
+
export declare function initializeCleanDataflowInformation<T>(entryPoint: NodeId, data: Pick<DataflowProcessorInformation<T>, 'environment' | 'completeAst'>): DataflowInformation;
|
|
106
106
|
/**
|
|
107
107
|
* Checks whether the given control dependencies are exhaustive (i.e. if for every control dependency on a boolean,
|
|
108
108
|
* the list contains a dependency on the `true` and on the `false` case).
|
|
@@ -29,9 +29,7 @@ const prefix_1 = require("../../util/prefix");
|
|
|
29
29
|
*/
|
|
30
30
|
function findNonLocalReads(graph, ignore) {
|
|
31
31
|
const ignores = new Set(ignore.map(i => i.nodeId));
|
|
32
|
-
const ids = new Set(graph.
|
|
33
|
-
.filter(([_, info]) => info.tag === vertex_1.VertexType.Use || info.tag === vertex_1.VertexType.FunctionCall)
|
|
34
|
-
.map(([id, _]) => id));
|
|
32
|
+
const ids = new Set(graph.vertexIdsOfType(vertex_1.VertexType.Use).concat(graph.vertexIdsOfType(vertex_1.VertexType.FunctionCall)));
|
|
35
33
|
/* find all variable use ids which do not link to a given id */
|
|
36
34
|
const nonLocalReads = [];
|
|
37
35
|
for (const id of ids) {
|
|
@@ -202,10 +200,8 @@ function linkFunctionCall(graph, id, info, idMap, thisGraph, calledFunctionDefin
|
|
|
202
200
|
*/
|
|
203
201
|
function linkFunctionCalls(graph, idMap, thisGraph) {
|
|
204
202
|
const calledFunctionDefinitions = [];
|
|
205
|
-
for (const [id, info] of thisGraph.
|
|
206
|
-
|
|
207
|
-
linkFunctionCall(graph, id, info, idMap, thisGraph, calledFunctionDefinitions);
|
|
208
|
-
}
|
|
203
|
+
for (const [id, info] of thisGraph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
204
|
+
linkFunctionCall(graph, id, info, idMap, thisGraph, calledFunctionDefinitions);
|
|
209
205
|
}
|
|
210
206
|
return calledFunctionDefinitions;
|
|
211
207
|
}
|
|
@@ -2,5 +2,11 @@ import { type RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
2
2
|
import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve the value from an argument, if it is not empty.
|
|
5
|
+
* @see {@link unpackArg} - to specifically retrieve non-named arguments
|
|
5
6
|
*/
|
|
6
|
-
export declare function
|
|
7
|
+
export declare function unpackNonameArg<OtherInfo>(arg: RFunctionArgument<OtherInfo> | undefined): RNode<OtherInfo> | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve the value from a non-named argument, if it is not empty.
|
|
10
|
+
* @see {@link unpackNonameArg} - to specifically retrieve non-named arguments
|
|
11
|
+
*/
|
|
12
|
+
export declare function unpackArg<OtherInfo>(arg: RFunctionArgument<OtherInfo> | undefined): RNode<OtherInfo> | undefined;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.unpackNonameArg = unpackNonameArg;
|
|
4
|
+
exports.unpackArg = unpackArg;
|
|
4
5
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
6
|
/**
|
|
6
7
|
* Retrieve the value from an argument, if it is not empty.
|
|
8
|
+
* @see {@link unpackArg} - to specifically retrieve non-named arguments
|
|
7
9
|
*/
|
|
8
|
-
function
|
|
9
|
-
return arg ===
|
|
10
|
+
function unpackNonameArg(arg) {
|
|
11
|
+
return arg === r_function_call_1.EmptyArgument || arg?.name !== undefined ? undefined : arg?.value;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Retrieve the value from a non-named argument, if it is not empty.
|
|
15
|
+
* @see {@link unpackNonameArg} - to specifically retrieve non-named arguments
|
|
16
|
+
*/
|
|
17
|
+
function unpackArg(arg) {
|
|
18
|
+
return arg === r_function_call_1.EmptyArgument ? undefined : arg?.value;
|
|
10
19
|
}
|
|
11
20
|
//# sourceMappingURL=unpack-argument.js.map
|
|
@@ -7,12 +7,12 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
7
7
|
const logger_1 = require("../../../../../logger");
|
|
8
8
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
9
|
const edge_1 = require("../../../../../graph/edge");
|
|
10
|
-
const environment_1 = require("../../../../../environments/environment");
|
|
11
10
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
12
11
|
const built_in_assignment_1 = require("./built-in-assignment");
|
|
13
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
14
13
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
15
14
|
const containers_1 = require("../../../../../../util/containers");
|
|
15
|
+
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
16
16
|
function tableAssignmentProcessor(name, args, rootId, data, outInfo) {
|
|
17
17
|
outInfo.definitionRootNodes.push(rootId);
|
|
18
18
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'table:assign' }).information;
|
|
@@ -71,12 +71,12 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
71
71
|
* ```
|
|
72
72
|
* the read for a will use both accesses as potential definitions and not just the last one!
|
|
73
73
|
*/
|
|
74
|
-
unknownReferences: (0,
|
|
74
|
+
unknownReferences: (0, reference_to_maybe_1.makeAllMaybe)(info.unknownReferences, info.graph, info.environment, false),
|
|
75
75
|
entryPoint: rootId,
|
|
76
76
|
/** it is, to be precise, the accessed element we want to map to maybe */
|
|
77
77
|
in: head === r_function_call_1.EmptyArgument ? info.in : info.in.map(ref => {
|
|
78
78
|
if (ref.nodeId === head.value?.info.id) {
|
|
79
|
-
return (0,
|
|
79
|
+
return (0, reference_to_maybe_1.makeReferenceMaybe)(ref, info.graph, info.environment, false);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
return ref;
|
|
@@ -60,7 +60,7 @@ function processApply(name, args, rootId, data, config) {
|
|
|
60
60
|
else if (val.type === type_1.RType.Symbol) {
|
|
61
61
|
functionId = val.info.id;
|
|
62
62
|
if (resolveValue) {
|
|
63
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables }));
|
|
63
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx }));
|
|
64
64
|
if (resolved?.elements.length === 1 && resolved.elements[0].type === 'string') {
|
|
65
65
|
functionName = (0, r_value_1.isValue)(resolved.elements[0].value) ? resolved.elements[0].value.str : undefined;
|
|
66
66
|
}
|
|
@@ -105,7 +105,7 @@ function processApply(name, args, rootId, data, config) {
|
|
|
105
105
|
cds: data.controlDependencies,
|
|
106
106
|
args: allOtherArguments, // same reference
|
|
107
107
|
origin: ['function']
|
|
108
|
-
});
|
|
108
|
+
}, data.ctx.env.makeCleanEnv());
|
|
109
109
|
information.graph.addEdge(rootId, rootFnId, edge_1.EdgeType.Calls | edge_1.EdgeType.Reads);
|
|
110
110
|
information.graph.addEdge(rootId, functionId, edge_1.EdgeType.Calls | edge_1.EdgeType.Argument);
|
|
111
111
|
information = {
|
|
@@ -51,4 +51,6 @@ export interface AssignmentToSymbolParameters<OtherInfo> extends AssignmentConfi
|
|
|
51
51
|
export declare function markAsAssignment<OtherInfo>(information: {
|
|
52
52
|
environment: REnvironmentInformation;
|
|
53
53
|
graph: DataflowGraph;
|
|
54
|
-
}, nodeToDefine: InGraphIdentifierDefinition
|
|
54
|
+
}, nodeToDefine: InGraphIdentifierDefinition & {
|
|
55
|
+
name: string;
|
|
56
|
+
}, sourceIds: readonly NodeId[], rootIdOfAssignment: NodeId, data: DataflowProcessorInformation<OtherInfo>, assignmentConfig?: AssignmentConfiguration): void;
|
|
@@ -112,7 +112,7 @@ args, rootId, data, config) {
|
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
114
|
// try to resolve the variable first
|
|
115
|
-
const n = (0, alias_tracking_1.resolveIdToValue)(target.info.id, { environment: data.environment, resolve: data.ctx.config.solver.variables, idMap: data.completeAst.idMap, full: true });
|
|
115
|
+
const n = (0, alias_tracking_1.resolveIdToValue)(target.info.id, { environment: data.environment, resolve: data.ctx.config.solver.variables, idMap: data.completeAst.idMap, full: true, ctx: data.ctx });
|
|
116
116
|
if (n.type === 'set' && n.elements.length === 1 && n.elements[0].type === 'string') {
|
|
117
117
|
const val = n.elements[0].value;
|
|
118
118
|
if ((0, r_value_1.isValue)(val)) {
|
|
@@ -187,8 +187,8 @@ args, rootId, data, config) {
|
|
|
187
187
|
return info;
|
|
188
188
|
}
|
|
189
189
|
function extractSourceAndTarget(args) {
|
|
190
|
-
const source = (0, unpack_argument_1.
|
|
191
|
-
const target = (0, unpack_argument_1.
|
|
190
|
+
const source = (0, unpack_argument_1.unpackArg)(args[1]);
|
|
191
|
+
const target = (0, unpack_argument_1.unpackArg)(args[0]);
|
|
192
192
|
return { source, target };
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
@@ -38,7 +38,7 @@ function processEvalCall(name, args, rootId, data, config) {
|
|
|
38
38
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
39
39
|
return information;
|
|
40
40
|
}
|
|
41
|
-
const code = resolveEvalToCode(evalArgument.value, data.environment, data.completeAst.idMap, data.ctx
|
|
41
|
+
const code = resolveEvalToCode(evalArgument.value, data.environment, data.completeAst.idMap, data.ctx);
|
|
42
42
|
if (code) {
|
|
43
43
|
const idGenerator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(name.lexeme + '::' + rootId, name.location);
|
|
44
44
|
data = {
|
|
@@ -70,7 +70,7 @@ function processEvalCall(name, args, rootId, data, config) {
|
|
|
70
70
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
71
71
|
return information;
|
|
72
72
|
}
|
|
73
|
-
function resolveEvalToCode(evalArgument, env, idMap,
|
|
73
|
+
function resolveEvalToCode(evalArgument, env, idMap, ctx) {
|
|
74
74
|
const val = evalArgument;
|
|
75
75
|
if (val.type === type_1.RType.FunctionCall && val.named && val.functionName.content === 'parse') {
|
|
76
76
|
const arg = val.arguments.find(v => v !== r_function_call_1.EmptyArgument && v.name?.content === 'text');
|
|
@@ -82,13 +82,13 @@ function resolveEvalToCode(evalArgument, env, idMap, config) {
|
|
|
82
82
|
return [arg.value.content.str];
|
|
83
83
|
}
|
|
84
84
|
else if (arg.value?.type === type_1.RType.Symbol) {
|
|
85
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(arg.value.info.id, { environment: env, idMap: idMap, resolve: config.solver.variables }));
|
|
85
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(arg.value.info.id, { environment: env, idMap: idMap, resolve: ctx.config.solver.variables, ctx }));
|
|
86
86
|
if (resolved) {
|
|
87
87
|
return (0, string_constants_1.collectStrings)(resolved.elements);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
else if (arg.value?.type === type_1.RType.FunctionCall && arg.value.named && ['paste', 'paste0'].includes(arg.value.functionName.content)) {
|
|
91
|
-
return handlePaste(config, arg.value.arguments, env, idMap, arg.value.functionName.content === 'paste' ? [' '] : ['']);
|
|
91
|
+
return handlePaste(ctx.config, arg.value.arguments, env, idMap, arg.value.functionName.content === 'paste' ? [' '] : [''], ctx);
|
|
92
92
|
}
|
|
93
93
|
return undefined;
|
|
94
94
|
}
|
|
@@ -101,7 +101,7 @@ function resolveEvalToCode(evalArgument, env, idMap, config) {
|
|
|
101
101
|
return undefined;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function getAsString(config, val, env, idMap) {
|
|
104
|
+
function getAsString(config, val, env, idMap, ctx) {
|
|
105
105
|
if (!val) {
|
|
106
106
|
return undefined;
|
|
107
107
|
}
|
|
@@ -109,17 +109,17 @@ function getAsString(config, val, env, idMap) {
|
|
|
109
109
|
return [val.content.str];
|
|
110
110
|
}
|
|
111
111
|
else if (val.type === type_1.RType.Symbol) {
|
|
112
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: env, idMap: idMap, resolve: config.solver.variables }));
|
|
112
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: env, idMap: idMap, resolve: config.solver.variables, ctx }));
|
|
113
113
|
if (resolved) {
|
|
114
114
|
return (0, string_constants_1.collectStrings)(resolved.elements);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
return undefined;
|
|
118
118
|
}
|
|
119
|
-
function handlePaste(config, args, env, idMap, sepDefault) {
|
|
119
|
+
function handlePaste(config, args, env, idMap, sepDefault, ctx) {
|
|
120
120
|
const sepArg = args.find(v => v !== r_function_call_1.EmptyArgument && v.name?.content === 'sep');
|
|
121
121
|
if (sepArg) {
|
|
122
|
-
const res = sepArg !== r_function_call_1.EmptyArgument && sepArg.value ? getAsString(config, sepArg.value, env, idMap) : undefined;
|
|
122
|
+
const res = sepArg !== r_function_call_1.EmptyArgument && sepArg.value ? getAsString(config, sepArg.value, env, idMap, ctx) : undefined;
|
|
123
123
|
if (!res) {
|
|
124
124
|
// sep not resolvable clearly / unknown
|
|
125
125
|
return undefined;
|
|
@@ -128,7 +128,7 @@ function handlePaste(config, args, env, idMap, sepDefault) {
|
|
|
128
128
|
}
|
|
129
129
|
const allArgs = args
|
|
130
130
|
.filter(v => v !== r_function_call_1.EmptyArgument && v.name?.content !== 'sep' && v.value)
|
|
131
|
-
.map(v => getAsString(config, v.value, env, idMap));
|
|
131
|
+
.map(v => getAsString(config, v.value, env, idMap, ctx));
|
|
132
132
|
if (allArgs.some(assert_1.isUndefined)) {
|
|
133
133
|
return undefined;
|
|
134
134
|
}
|
|
@@ -7,7 +7,6 @@ const linker_1 = require("../../../../linker");
|
|
|
7
7
|
const assert_1 = require("../../../../../../util/assert");
|
|
8
8
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
9
9
|
const common_1 = require("../common");
|
|
10
|
-
const environment_1 = require("../../../../../environments/environment");
|
|
11
10
|
const graph_1 = require("../../../../../graph/graph");
|
|
12
11
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
12
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
@@ -18,7 +17,7 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
18
17
|
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
19
18
|
const logger_1 = require("../../../../../logger");
|
|
20
19
|
const log_1 = require("../../../../../../util/log");
|
|
21
|
-
const
|
|
20
|
+
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
22
21
|
const dotDotDotAccess = /^\.\.\d+$/;
|
|
23
22
|
function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph) {
|
|
24
23
|
const readName = read.name && dotDotDotAccess.test(read.name) ? '...' : read.name;
|
|
@@ -82,7 +81,10 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
|
|
|
82
81
|
// we update all definitions to be linked with the corresponding function call
|
|
83
82
|
// we, however, have to ignore expression-local writes!
|
|
84
83
|
if (localDefs.length > 0) {
|
|
85
|
-
environment =
|
|
84
|
+
environment = {
|
|
85
|
+
current: environment.current.removeAll(localDefs.filter(d => (0, assert_1.isNotUndefined)(d.name))),
|
|
86
|
+
level: environment.level
|
|
87
|
+
};
|
|
86
88
|
}
|
|
87
89
|
if (callDependencies === null) {
|
|
88
90
|
callDependencies = nextGraph.getVertex(functionCall, true)?.cds;
|
|
@@ -97,7 +99,7 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
|
|
|
97
99
|
*
|
|
98
100
|
*/
|
|
99
101
|
function processExpressionList(name, args, rootId, data) {
|
|
100
|
-
const expressions = args.map(
|
|
102
|
+
const expressions = args.map(unpack_argument_1.unpackNonameArg);
|
|
101
103
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `[expr list] with ${expressions.length} expressions`);
|
|
102
104
|
let { environment } = data;
|
|
103
105
|
// used to detect if a "write" happens within the same expression list
|
|
@@ -124,9 +126,9 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
124
126
|
// if the expression contained next or break anywhere before the next loop, the "overwrite" should be an "append", because we do not know if the rest is executed
|
|
125
127
|
// update the environments for the next iteration with the previous writes
|
|
126
128
|
if (exitPoints.length > 0) {
|
|
127
|
-
processed.out = (0,
|
|
128
|
-
processed.in = (0,
|
|
129
|
-
processed.unknownReferences = (0,
|
|
129
|
+
processed.out = (0, reference_to_maybe_1.makeAllMaybe)(processed.out, nextGraph, processed.environment, true);
|
|
130
|
+
processed.in = (0, reference_to_maybe_1.makeAllMaybe)(processed.in, nextGraph, processed.environment, false);
|
|
131
|
+
processed.unknownReferences = (0, reference_to_maybe_1.makeAllMaybe)(processed.unknownReferences, nextGraph, processed.environment, false);
|
|
130
132
|
}
|
|
131
133
|
(0, info_1.addNonDefaultExitPoints)(exitPoints, processed.exitPoints);
|
|
132
134
|
out = out.concat(processed.out);
|
|
@@ -12,9 +12,9 @@ const logger_1 = require("../../../../../logger");
|
|
|
12
12
|
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
13
13
|
const define_1 = require("../../../../../environments/define");
|
|
14
14
|
const append_1 = require("../../../../../environments/append");
|
|
15
|
-
const environment_1 = require("../../../../../environments/environment");
|
|
16
15
|
const edge_1 = require("../../../../../graph/edge");
|
|
17
16
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
17
|
+
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -23,7 +23,7 @@ function processForLoop(name, args, rootId, data) {
|
|
|
23
23
|
logger_1.dataflowLogger.warn(`For-Loop ${name.content} does not have three arguments, skipping`);
|
|
24
24
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
25
25
|
}
|
|
26
|
-
const [variableArg, vectorArg, bodyArg] = args.map(e => (0, unpack_argument_1.
|
|
26
|
+
const [variableArg, vectorArg, bodyArg] = args.map(e => (0, unpack_argument_1.unpackNonameArg)(e));
|
|
27
27
|
(0, assert_1.guard)(variableArg !== undefined && vectorArg !== undefined && bodyArg !== undefined, () => `For-Loop ${JSON.stringify(args)} has missing arguments! Bad!`);
|
|
28
28
|
const vector = (0, processor_1.processDataflowFor)(vectorArg, data);
|
|
29
29
|
if ((0, info_1.alwaysExits)(vector)) {
|
|
@@ -50,7 +50,7 @@ function processForLoop(name, args, rootId, data) {
|
|
|
50
50
|
nextGraph.addEdge(write.nodeId, vector.entryPoint, edge_1.EdgeType.DefinedBy);
|
|
51
51
|
nextGraph.setDefinitionOfVertex(write);
|
|
52
52
|
}
|
|
53
|
-
const outgoing = variable.out.concat(writtenVariable, (0,
|
|
53
|
+
const outgoing = variable.out.concat(writtenVariable, (0, reference_to_maybe_1.makeAllMaybe)(body.out, nextGraph, outEnvironment, true));
|
|
54
54
|
(0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out);
|
|
55
55
|
(0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences));
|
|
56
56
|
(0, common_1.patchFunctionCall)({
|
|
@@ -6,6 +6,7 @@ import { type RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import { DataflowGraph } from '../../../../../graph/graph';
|
|
8
8
|
import { type REnvironmentInformation } from '../../../../../environments/environment';
|
|
9
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
9
10
|
/**
|
|
10
11
|
* Process a function definition, i.e., `function(a, b) { ... }`
|
|
11
12
|
*/
|
|
@@ -13,7 +14,7 @@ export declare function processFunctionDefinition<OtherInfo>(name: RSymbol<Other
|
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
15
16
|
*/
|
|
16
|
-
export declare function retrieveActiveEnvironment(callerEnvironment: REnvironmentInformation | undefined, baseEnvironment: REnvironmentInformation): REnvironmentInformation;
|
|
17
|
+
export declare function retrieveActiveEnvironment(callerEnvironment: REnvironmentInformation | undefined, baseEnvironment: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
|
|
17
18
|
/**
|
|
18
19
|
* Update the closure links of all nested function definitions
|
|
19
20
|
* @param graph - dataflow graph to collect the function definitions from and to update the closure links for
|