@eagleoutice/flowr 2.9.10 → 2.9.12
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 +48 -50
- package/abstract-interpretation/absint-visitor.js +2 -1
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/normalized-ast-fold.d.ts +2 -2
- package/abstract-interpretation/normalized-ast-fold.js +4 -3
- package/benchmark/slicer.js +5 -5
- package/benchmark/summarizer/first-phase/process.js +4 -4
- package/cli/repl/commands/repl-normalize.js +2 -2
- package/cli/repl/core.js +2 -2
- package/config.js +1 -1
- package/control-flow/control-flow-graph.d.ts +1 -1
- package/control-flow/control-flow-graph.js +1 -2
- package/control-flow/extract-cfg.js +4 -3
- package/dataflow/cluster.js +12 -8
- package/dataflow/environments/built-in.d.ts +2 -15
- package/dataflow/environments/built-in.js +11 -31
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.js +2 -1
- package/dataflow/eval/resolve/resolve.js +4 -3
- package/dataflow/fn/exceptions-of-function.d.ts +1 -1
- package/dataflow/fn/exceptions-of-function.js +2 -1
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +4 -3
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +21 -21
- package/dataflow/graph/graph.d.ts +4 -4
- package/dataflow/graph/graph.js +27 -22
- package/dataflow/graph/quads.js +4 -7
- package/dataflow/internal/linker.d.ts +2 -2
- package/dataflow/internal/linker.js +15 -14
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +1 -1
- package/dataflow/internal/process/functions/call/common.js +43 -35
- package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/process-argument.js +3 -3
- package/dataflow/internal/process/functions/process-parameter.js +2 -2
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +2 -2
- package/documentation/doc-util/doc-types.js +1 -1
- package/documentation/wiki-cfg.js +3 -3
- package/documentation/wiki-dataflow-graph.js +86 -31
- package/documentation/wiki-engine.js +18 -0
- package/documentation/wiki-mk/doc-context.d.ts +52 -11
- package/documentation/wiki-mk/doc-context.js +20 -13
- package/documentation/wiki-normalized-ast.d.ts +1 -1
- package/documentation/wiki-normalized-ast.js +9 -6
- package/linter/linter-format.d.ts +10 -0
- package/linter/linter-format.js +15 -0
- package/linter/rules/absolute-path.js +3 -3
- package/linter/rules/file-path-validity.js +1 -1
- package/package.json +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +5 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -5
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +6 -5
- package/queries/catalog/dependencies-query/function-info/library-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +9 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
- package/queries/catalog/does-call-query/does-call-query-executor.js +3 -3
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/query-print.d.ts +1 -1
- package/queries/query-print.js +4 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +151 -4
- package/r-bridge/lang-4.x/ast/model/model.js +249 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +13 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +19 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +26 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +36 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +48 -13
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +21 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +8 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +11 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +23 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +32 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +19 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +26 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +12 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +20 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +26 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +12 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +8 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +11 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +17 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +22 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +22 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +45 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +57 -16
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +12 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +15 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +21 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +21 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +22 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +21 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +14 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +39 -2
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +52 -9
- package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +8 -7
- package/r-bridge/lang-4.x/ast/model/processing/visitor.js +6 -13
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +4 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +2 -2
- package/r-bridge/lang-4.x/convert-values.d.ts +14 -5
- package/r-bridge/lang-4.x/convert-values.js +76 -72
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -2
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/r-bridge/shell-executor.js +1 -1
- package/reconstruct/auto-select/magic-comments.js +4 -4
- package/reconstruct/reconstruct.js +2 -1
- package/search/search-executor/search-generators.js +2 -2
- package/slicing/criterion/filters/all-variables.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -1
- package/slicing/criterion/parse.js +5 -3
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/statistics/features/supported/assignments/assignments.js +2 -2
- package/statistics/features/supported/control-flow/control-flow.js +2 -2
- package/statistics/features/supported/data-access/data-access.js +4 -3
- package/statistics/features/supported/defined-functions/defined-functions.js +9 -8
- package/statistics/features/supported/expression-list/statistics-expression-list.js +2 -2
- package/statistics/features/supported/loops/loops.js +6 -5
- package/statistics/features/supported/used-functions/used-functions.js +2 -2
- package/statistics/features/supported/variables/variables.js +8 -8
- package/util/mermaid/ast.js +2 -2
- package/util/mermaid/cfg.js +3 -4
- package/util/mermaid/dfg.d.ts +9 -1
- package/util/mermaid/dfg.js +13 -9
- package/util/quads.js +14 -6
- package/util/range.d.ts +3 -0
- package/util/range.js +3 -0
- package/util/simple-df/dfg-ascii.js +1 -1
- package/util/version.js +1 -1
- package/r-bridge/lang-4.x/ast/model/collect.d.ts +0 -10
- package/r-bridge/lang-4.x/ast/model/collect.js +0 -25
|
@@ -235,7 +235,7 @@ function linkFunctionCallWithSingleTarget(graph, { subflow: fnSubflow, exitPoint
|
|
|
235
235
|
continue;
|
|
236
236
|
}
|
|
237
237
|
for (const { nodeId, type, value } of defs) {
|
|
238
|
-
if (!
|
|
238
|
+
if (!node_id_1.NodeId.isBuiltIn(nodeId)) {
|
|
239
239
|
graph.addEdge(ingoing.nodeId, nodeId, edge_1.EdgeType.DefinedByOnCall);
|
|
240
240
|
graph.addEdge(id, nodeId, edge_1.EdgeType.DefinesOnCall);
|
|
241
241
|
if (type === identifier_1.ReferenceType.Function && ingoing.type === identifier_1.ReferenceType.S7MethodPrefix && Array.isArray(value)) {
|
|
@@ -291,7 +291,7 @@ function linkFunctionCall(graph, id, info, idMap, thisGraph, calledFunctionDefin
|
|
|
291
291
|
}
|
|
292
292
|
const functionDefinitionReadIds = new Set();
|
|
293
293
|
for (const [t, e] of edges.entries()) {
|
|
294
|
-
if (!
|
|
294
|
+
if (!node_id_1.NodeId.isBuiltIn(t) && edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Argument) && edge_1.DfEdge.includesType(e, FCallLinkReadBits)) {
|
|
295
295
|
functionDefinitionReadIds.add(t);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -391,22 +391,22 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
391
391
|
while (potential.length !== 0) {
|
|
392
392
|
const cid = potential.pop();
|
|
393
393
|
visited.add(cid);
|
|
394
|
-
if (
|
|
394
|
+
if (node_id_1.NodeId.isBuiltIn(cid)) {
|
|
395
395
|
builtIns.add(cid);
|
|
396
396
|
continue;
|
|
397
397
|
}
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
398
|
+
const vertex = dataflowGraph.getVertex(cid);
|
|
399
|
+
if (vertex === undefined) {
|
|
400
400
|
continue;
|
|
401
401
|
}
|
|
402
|
-
const [vertex, edges] = currentInfo;
|
|
403
402
|
// Found a function definition
|
|
404
403
|
if (vertex.subflow !== undefined) {
|
|
405
404
|
result.add(vertex);
|
|
406
405
|
continue;
|
|
407
406
|
}
|
|
408
407
|
let hasReturnEdge = false;
|
|
409
|
-
|
|
408
|
+
const outgoing = dataflowGraph.outgoingEdges(cid) ?? [];
|
|
409
|
+
for (const [target, e] of outgoing) {
|
|
410
410
|
if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)) {
|
|
411
411
|
hasReturnEdge = true;
|
|
412
412
|
if (!visited.has(target)) {
|
|
@@ -417,7 +417,7 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
417
417
|
if (vertex.tag === vertex_1.VertexType.FunctionCall || hasReturnEdge || (vertex.tag === vertex_1.VertexType.VariableDefinition && vertex.par)) {
|
|
418
418
|
continue;
|
|
419
419
|
}
|
|
420
|
-
for (const [target, e] of
|
|
420
|
+
for (const [target, e] of outgoing) {
|
|
421
421
|
if (edge_1.DfEdge.includesType(e, LinkedFnFollowBits) && !visited.has(target)) {
|
|
422
422
|
potential.push(target);
|
|
423
423
|
}
|
|
@@ -438,7 +438,6 @@ function linkInputs(referencesToLinkAgainstEnvironment, environmentInformation,
|
|
|
438
438
|
for (const bodyInput of referencesToLinkAgainstEnvironment) {
|
|
439
439
|
const probableTarget = bodyInput.name ? (0, resolve_by_name_1.resolveByName)(bodyInput.name, environmentInformation, bodyInput.type) : undefined;
|
|
440
440
|
if (probableTarget === undefined) {
|
|
441
|
-
log_1.log.trace(`found no target for ${bodyInput.name ? identifier_1.Identifier.toString(bodyInput.name) : '<no-name>'}`);
|
|
442
441
|
if (maybeForRemaining) {
|
|
443
442
|
bodyInput.cds ??= [];
|
|
444
443
|
}
|
|
@@ -496,7 +495,9 @@ function linkCircularRedefinitionsWithinALoop(graph, openIns, outgoing) {
|
|
|
496
495
|
*/
|
|
497
496
|
function reapplyLoopExitPoints(exits, references, graph) {
|
|
498
497
|
// just apply the cds of all exit points not already present
|
|
499
|
-
const exitCds =
|
|
498
|
+
const exitCds = exits.flatMap(e => e.cds?.map(info_1.negateControlDependency))
|
|
499
|
+
.filter(assert_1.isNotUndefined)
|
|
500
|
+
.map(cd => ({ ...cd, byIteration: true }));
|
|
500
501
|
const seenRefs = new Set();
|
|
501
502
|
for (const ref of references) {
|
|
502
503
|
if (seenRefs.has(ref.nodeId)) {
|
|
@@ -508,12 +509,12 @@ function reapplyLoopExitPoints(exits, references, graph) {
|
|
|
508
509
|
let setVertex = false;
|
|
509
510
|
if (ref.cds) {
|
|
510
511
|
if (!ref.cds?.find(c => c.id === cId)) {
|
|
511
|
-
ref.cds.push(
|
|
512
|
+
ref.cds.push(cd);
|
|
512
513
|
setVertex = true;
|
|
513
514
|
}
|
|
514
515
|
}
|
|
515
516
|
else {
|
|
516
|
-
ref.cds = [
|
|
517
|
+
ref.cds = [cd];
|
|
517
518
|
setVertex = true;
|
|
518
519
|
}
|
|
519
520
|
if (setVertex) {
|
|
@@ -521,11 +522,11 @@ function reapplyLoopExitPoints(exits, references, graph) {
|
|
|
521
522
|
if (vertex) {
|
|
522
523
|
if (vertex.cds) {
|
|
523
524
|
if (!vertex.cds?.find(c => c.id === cId)) {
|
|
524
|
-
vertex.cds.push(
|
|
525
|
+
vertex.cds.push(cd);
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
else {
|
|
528
|
-
vertex.cds = [
|
|
529
|
+
vertex.cds = [cd];
|
|
529
530
|
}
|
|
530
531
|
}
|
|
531
532
|
}
|
|
@@ -2,6 +2,7 @@ import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model'
|
|
|
2
2
|
import type { AstIdMap, ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
3
|
import { EmptyArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
4
4
|
import type { RUnnamedArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
|
|
5
|
+
import { RArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
|
|
5
6
|
/**
|
|
6
7
|
* Converts a normalized node into an unnamed argument (wraps it with an argument node).
|
|
7
8
|
*/
|
|
@@ -9,4 +10,4 @@ export declare function toUnnamedArgument<OtherInfo>(node: RNode<OtherInfo & Par
|
|
|
9
10
|
/**
|
|
10
11
|
* Wraps the given nodes as unnamed arguments where necessary.
|
|
11
12
|
*/
|
|
12
|
-
export declare function wrapArgumentsUnnamed<OtherInfo>(nodes: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[], idMap: AstIdMap<OtherInfo>): ("<>" |
|
|
13
|
+
export declare function wrapArgumentsUnnamed<OtherInfo>(nodes: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[], idMap: AstIdMap<OtherInfo>): ("<>" | RArgument<OtherInfo & ParentInformation>)[];
|
|
@@ -4,6 +4,7 @@ exports.toUnnamedArgument = toUnnamedArgument;
|
|
|
4
4
|
exports.wrapArgumentsUnnamed = wrapArgumentsUnnamed;
|
|
5
5
|
const range_1 = require("../../../../../../util/range");
|
|
6
6
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
|
+
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
7
8
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
8
9
|
const graph_1 = require("../../../../../graph/graph");
|
|
9
10
|
/**
|
|
@@ -31,6 +32,6 @@ function toUnnamedArgument(node, idMap) {
|
|
|
31
32
|
* Wraps the given nodes as unnamed arguments where necessary.
|
|
32
33
|
*/
|
|
33
34
|
function wrapArgumentsUnnamed(nodes, idMap) {
|
|
34
|
-
return nodes.map(n => graph_1.FunctionArgument.isEmpty(n) ||
|
|
35
|
+
return nodes.map(n => graph_1.FunctionArgument.isEmpty(n) || r_argument_1.RArgument.is(n) ? n : toUnnamedArgument(n, idMap));
|
|
35
36
|
}
|
|
36
37
|
//# sourceMappingURL=make-argument.js.map
|
|
@@ -3,7 +3,7 @@ import type { DataflowInformation } from '../../../../../info';
|
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import { type RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
|
-
import
|
|
6
|
+
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import type { ForceArguments } from '../common';
|
|
8
8
|
/**
|
|
9
9
|
* Processes different types of access operations.
|
|
@@ -4,6 +4,7 @@ exports.processAccess = processAccess;
|
|
|
4
4
|
exports.symbolArgumentsToStrings = symbolArgumentsToStrings;
|
|
5
5
|
const known_call_handling_1 = require("../known-call-handling");
|
|
6
6
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
|
+
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
7
8
|
const logger_1 = require("../../../../../logger");
|
|
8
9
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
10
|
const edge_1 = require("../../../../../graph/edge");
|
|
@@ -94,7 +95,7 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
94
95
|
function processNumberBasedAccess(data, name, args, rootId, config, head) {
|
|
95
96
|
const existing = data.environment.current.memory.get(':=');
|
|
96
97
|
const outInfo = { definitionRootNodes: [] };
|
|
97
|
-
const tableAssignId =
|
|
98
|
+
const tableAssignId = node_id_1.NodeId.toBuiltIn(':=-table');
|
|
98
99
|
data.environment.current.memory.set(':=', [{
|
|
99
100
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
100
101
|
definedAt: tableAssignId,
|
|
@@ -15,6 +15,7 @@ const r_value_1 = require("../../../../../eval/values/r-value");
|
|
|
15
15
|
const log_1 = require("../../../../../../util/log");
|
|
16
16
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
17
17
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
18
|
+
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
18
19
|
/**
|
|
19
20
|
* Process an apply call like `vapply` or `mapply`.
|
|
20
21
|
*/
|
|
@@ -65,13 +66,10 @@ function processApply(name, args, rootId, data, config) {
|
|
|
65
66
|
let functionName = undefined;
|
|
66
67
|
let anonymous = false;
|
|
67
68
|
const val = arg.value;
|
|
68
|
-
if (unquoteFunction &&
|
|
69
|
+
if (unquoteFunction && r_string_1.RString.is(val)) {
|
|
69
70
|
functionId = val.info.id;
|
|
70
71
|
functionName = val.content.str;
|
|
71
|
-
information = {
|
|
72
|
-
...information,
|
|
73
|
-
in: [...information.in, { type: identifier_1.ReferenceType.Function, name: functionName, cds: data.cds, nodeId: functionId }]
|
|
74
|
-
};
|
|
72
|
+
information.in = [...information.in, { type: identifier_1.ReferenceType.Function, name: functionName, cds: data.cds, nodeId: functionId }];
|
|
75
73
|
}
|
|
76
74
|
else if (val.type === type_1.RType.Symbol) {
|
|
77
75
|
functionId = val.info.id;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { DataflowInformation } from '../../../../../info';
|
|
6
6
|
import { type DataflowProcessorInformation } from '../../../../../processor';
|
|
7
|
-
import
|
|
7
|
+
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
9
|
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
10
10
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
@@ -7,6 +7,7 @@ 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 node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
11
|
const graph_1 = require("../../../../../graph/graph");
|
|
11
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
12
13
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
@@ -20,13 +21,13 @@ const log_1 = require("../../../../../../util/log");
|
|
|
20
21
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
21
22
|
function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph) {
|
|
22
23
|
const readName = read.name && identifier_1.Identifier.isDotDotDotAccess(read.name) ? identifier_1.Identifier.dotdotdot() : read.name;
|
|
23
|
-
const readId = readName ? identifier_1.Identifier.getName(readName) : undefined;
|
|
24
24
|
const probableTarget = readName ? (0, resolve_by_name_1.resolveByName)(readName, environments, read.type) : undefined;
|
|
25
25
|
// record if at least one has not been defined
|
|
26
26
|
if (probableTarget === undefined || probableTarget.some(t => !listEnvironments.has(t.nodeId) || !(0, info_1.happensInEveryBranch)(t.cds))) {
|
|
27
|
+
const readId = readName ? identifier_1.Identifier.getName(readName) : undefined;
|
|
27
28
|
const has = remainingRead.get(readId);
|
|
28
29
|
if (has) {
|
|
29
|
-
if (!has
|
|
30
|
+
if (!has.some(h => h.nodeId === read.nodeId && h.name === read.name && h.cds === read.cds)) {
|
|
30
31
|
has.push(read);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -42,7 +43,7 @@ function linkReadNameToWriteIfPossible(read, environments, listEnvironments, rem
|
|
|
42
43
|
const rid = read.nodeId;
|
|
43
44
|
for (const target of probableTarget) {
|
|
44
45
|
const tid = target.nodeId;
|
|
45
|
-
if ((read.type === identifier_1.ReferenceType.Function || read.type === identifier_1.ReferenceType.BuiltInFunction)
|
|
46
|
+
if (node_id_1.NodeId.isBuiltIn(target.definedAt) && (read.type === identifier_1.ReferenceType.Function || read.type === identifier_1.ReferenceType.BuiltInFunction)) {
|
|
46
47
|
nextGraph.addEdge(rid, tid, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
@@ -66,7 +67,7 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
|
|
|
66
67
|
while (!current?.builtInEnv) {
|
|
67
68
|
for (const definitions of current.memory.values()) {
|
|
68
69
|
for (const def of definitions) {
|
|
69
|
-
if (!
|
|
70
|
+
if (!node_id_1.NodeId.isBuiltIn(def.definedAt)) {
|
|
70
71
|
hasUpdate = true;
|
|
71
72
|
nextGraph.addEdge(def.nodeId, functionCall, edge_1.EdgeType.SideEffectOnCall);
|
|
72
73
|
}
|
|
@@ -179,7 +180,7 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
179
180
|
argumentProcessResult: processedExpressions,
|
|
180
181
|
origin: built_in_1.BuiltInProcName.ExpressionList
|
|
181
182
|
});
|
|
182
|
-
nextGraph.addEdge(rootId,
|
|
183
|
+
nextGraph.addEdge(rootId, node_id_1.NodeId.toBuiltIn('{'), edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
|
|
183
184
|
// process all exit points as potential returns:
|
|
184
185
|
for (const exit of exitPoints) {
|
|
185
186
|
if (exit.type === 1 /* ExitPointType.Return */ || exit.type === 0 /* ExitPointType.Default */) {
|
|
@@ -3,7 +3,7 @@ import { type DataflowInformation } from '../../../../../info';
|
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
5
5
|
import { type RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
|
-
import
|
|
6
|
+
import { 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
9
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
@@ -11,6 +11,7 @@ const unpack_argument_1 = require("../argument/unpack-argument");
|
|
|
11
11
|
const assert_1 = require("../../../../../../util/assert");
|
|
12
12
|
const logger_1 = require("../../../../../logger");
|
|
13
13
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
14
|
+
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
14
15
|
const graph_1 = require("../../../../../graph/graph");
|
|
15
16
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
16
17
|
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
@@ -248,7 +249,7 @@ function updateNestedFunctionCalls(graph, outEnvironment) {
|
|
|
248
249
|
const collectedNextMethods = new Set();
|
|
249
250
|
const treatAsS3 = origin.includes(built_in_1.BuiltInProcName.S3Dispatch);
|
|
250
251
|
for (const target of targets) {
|
|
251
|
-
if (
|
|
252
|
+
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
252
253
|
graph.addEdge(id, target, edge_1.EdgeType.Calls);
|
|
253
254
|
continue;
|
|
254
255
|
}
|
|
@@ -289,7 +290,7 @@ function updateNestedFunctionCalls(graph, outEnvironment) {
|
|
|
289
290
|
const inId = ingoing.nodeId;
|
|
290
291
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Found ${resolved.length} references to open ref ${id} in closure of function definition ${id}`);
|
|
291
292
|
for (const { nodeId } of resolved) {
|
|
292
|
-
if (!
|
|
293
|
+
if (!node_id_1.NodeId.isBuiltIn(nodeId)) {
|
|
293
294
|
graph.addEdge(inId, nodeId, edge_1.EdgeType.DefinedByOnCall);
|
|
294
295
|
graph.addEdge(id, nodeId, edge_1.EdgeType.DefinesOnCall);
|
|
295
296
|
}
|
|
@@ -14,8 +14,8 @@ const general_1 = require("../../../../../eval/values/general");
|
|
|
14
14
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
15
15
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
16
16
|
const linker_1 = require("../../../../linker");
|
|
17
|
-
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
18
17
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
18
|
+
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
19
19
|
function getArguments(config, args) {
|
|
20
20
|
let condArg;
|
|
21
21
|
let thenArg;
|
|
@@ -28,9 +28,9 @@ function getArguments(config, args) {
|
|
|
28
28
|
'...': '...'
|
|
29
29
|
};
|
|
30
30
|
const argMaps = (0, linker_1.invertArgumentMap)((0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params));
|
|
31
|
-
condArg = (0, unpack_argument_1.unpackArg)(
|
|
32
|
-
thenArg = (0, unpack_argument_1.unpackArg)(
|
|
33
|
-
otherwiseArg = (0, unpack_argument_1.unpackArg)(
|
|
31
|
+
condArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('cond')?.[0]));
|
|
32
|
+
thenArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('yes')?.[0]));
|
|
33
|
+
otherwiseArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('no')?.[0]));
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
[condArg, thenArg, otherwiseArg] = args.map(e => (0, unpack_argument_1.unpackArg)(e));
|
|
@@ -7,10 +7,10 @@ const known_call_handling_1 = require("../known-call-handling");
|
|
|
7
7
|
const linker_1 = require("../../../../linker");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
9
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
10
|
-
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
11
10
|
const scoping_1 = require("../../../../../environments/scoping");
|
|
12
11
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
13
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
|
+
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
14
14
|
/**
|
|
15
15
|
* Processes a built-in 'local' function call.
|
|
16
16
|
*/
|
|
@@ -24,8 +24,8 @@ function processLocal(name, args, rootId, data, config) {
|
|
|
24
24
|
'...': '...'
|
|
25
25
|
};
|
|
26
26
|
const argMaps = (0, linker_1.invertArgumentMap)((0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params));
|
|
27
|
-
const env = (0, unpack_argument_1.unpackArg)(
|
|
28
|
-
const expr = (0, unpack_argument_1.unpackArg)(
|
|
27
|
+
const env = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('env')?.[0]));
|
|
28
|
+
const expr = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('expr')?.[0]));
|
|
29
29
|
if (!expr) {
|
|
30
30
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
31
31
|
}
|
|
@@ -4,7 +4,7 @@ import { type ForceArguments } from '../common';
|
|
|
4
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import { type RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
|
-
import
|
|
7
|
+
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
/**
|
|
9
9
|
* Process a replacement function call like `<-`, `[[<-`, `$<-`, etc.
|
|
10
10
|
* These are automatically created when doing assignments like `x[y] <- value` or in general `fun(x) <- value` will call `fun<- (x, value)`.
|
|
@@ -6,6 +6,7 @@ const known_call_handling_1 = require("../known-call-handling");
|
|
|
6
6
|
const log_1 = require("../../../../../../util/log");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
|
+
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
9
10
|
const logger_1 = require("../../../../../logger");
|
|
10
11
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
11
12
|
const edge_1 = require("../../../../../graph/edge");
|
|
@@ -110,7 +111,7 @@ args, rootId, data, config) {
|
|
|
110
111
|
fn.type = identifier_1.ReferenceType.S3MethodPrefix;
|
|
111
112
|
}
|
|
112
113
|
// link the built-in replacement op
|
|
113
|
-
res.graph.addEdge(rootId,
|
|
114
|
+
res.graph.addEdge(rootId, node_id_1.NodeId.toBuiltIn(identifier_1.Identifier.getName(name.content)), edge_1.EdgeType.Calls | edge_1.EdgeType.Reads);
|
|
114
115
|
return res;
|
|
115
116
|
}
|
|
116
117
|
//# sourceMappingURL=built-in-replacement.js.map
|
|
@@ -33,7 +33,7 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
33
33
|
params[config.args.fun] = 'fun';
|
|
34
34
|
params['...'] = '...';
|
|
35
35
|
const argMaps = (0, linker_1.invertArgumentMap)((0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params));
|
|
36
|
-
const genName = (0, unpack_argument_1.unpackArg)(
|
|
36
|
+
const genName = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('name')?.[0]));
|
|
37
37
|
if (!genName) {
|
|
38
38
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
39
39
|
}
|
|
@@ -51,10 +51,10 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
51
51
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
52
52
|
}
|
|
53
53
|
data = { ...data, currentS7name: accessedIdentifiers };
|
|
54
|
-
let funArg = (0, unpack_argument_1.unpackArg)(
|
|
54
|
+
let funArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('fun')?.[0]))?.info.id;
|
|
55
55
|
const effectiveArgs = args.slice();
|
|
56
56
|
if (!funArg) {
|
|
57
|
-
const dispatchArg = (0, unpack_argument_1.unpackArg)(
|
|
57
|
+
const dispatchArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('dispatchArg')?.[0]));
|
|
58
58
|
const newFun = makeS7DispatchFDef(name, [dispatchArg?.lexeme ?? undefined], rootId, args.length, data.completeAst.idMap);
|
|
59
59
|
// fake it 'function([dispatch_args],...) S7_dispatch()'
|
|
60
60
|
effectiveArgs.push(newFun[0]);
|
|
@@ -8,13 +8,13 @@ const logger_1 = require("../../../../../logger");
|
|
|
8
8
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
9
9
|
const linker_1 = require("../../../../linker");
|
|
10
10
|
const common_1 = require("../common");
|
|
11
|
-
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
12
11
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
13
12
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
14
13
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
15
14
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
16
15
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
17
16
|
const range_1 = require("../../../../../../util/range");
|
|
17
|
+
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
18
18
|
/**
|
|
19
19
|
* Process an S3 dispatch call like `UseMethod`.
|
|
20
20
|
*/
|
|
@@ -29,11 +29,11 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
29
29
|
'...': '...'
|
|
30
30
|
};
|
|
31
31
|
const argMaps = (0, linker_1.invertArgumentMap)((0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params));
|
|
32
|
-
const generic = (0, unpack_argument_1.unpackArg)(
|
|
32
|
+
const generic = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('generic')?.[0]));
|
|
33
33
|
if (!generic && !config.inferFromClosure) {
|
|
34
34
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
35
35
|
}
|
|
36
|
-
const obj = (0, unpack_argument_1.unpackArg)(
|
|
36
|
+
const obj = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('object')?.[0]));
|
|
37
37
|
const dfObj = obj ? (0, processor_1.processDataflowFor)(obj, data) : (0, info_1.initializeCleanDataflowInformation)(rootId, data);
|
|
38
38
|
if ((0, info_1.alwaysExits)(dfObj)) {
|
|
39
39
|
(0, common_1.patchFunctionCall)({
|
|
@@ -40,7 +40,7 @@ export declare function convertFnArguments<OtherInfo>(args: readonly (typeof Emp
|
|
|
40
40
|
* Transforms a function argument into a function argument reference for a function call vertex.
|
|
41
41
|
* Please be aware, that the ids here are those inferred from the AST, not from the dataflow graph!
|
|
42
42
|
*/
|
|
43
|
-
export declare function convertFnArgument<OtherInfo>(arg: typeof EmptyArgument | RNode<OtherInfo & ParentInformation>): FunctionArgument;
|
|
43
|
+
export declare function convertFnArgument<OtherInfo>(this: void, arg: typeof EmptyArgument | RNode<OtherInfo & ParentInformation>): FunctionArgument;
|
|
44
44
|
/**
|
|
45
45
|
* Processes all arguments for a function call, updating the given final graph and environment.
|
|
46
46
|
*/
|
|
@@ -6,6 +6,7 @@ exports.processAllArguments = processAllArguments;
|
|
|
6
6
|
exports.patchFunctionCall = patchFunctionCall;
|
|
7
7
|
const info_1 = require("../../../../info");
|
|
8
8
|
const processor_1 = require("../../../../processor");
|
|
9
|
+
const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
9
10
|
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
11
|
const identifier_1 = require("../../../../environments/identifier");
|
|
11
12
|
const overwrite_1 = require("../../../../environments/overwrite");
|
|
@@ -13,33 +14,34 @@ const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
|
|
|
13
14
|
const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
14
15
|
const vertex_1 = require("../../../../graph/vertex");
|
|
15
16
|
const edge_1 = require("../../../../graph/edge");
|
|
17
|
+
const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
18
|
function forceVertexArgumentValueReferences(rootId, value, graph, env) {
|
|
17
19
|
const valueVertex = graph.getVertex(value.entryPoint);
|
|
18
20
|
if (!valueVertex) {
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
// link read if it is function definition directly and reference the exit point
|
|
22
|
-
if (valueVertex.tag
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
26
|
-
}
|
|
24
|
+
if (valueVertex.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
25
|
+
for (const exit of valueVertex.exitPoints) {
|
|
26
|
+
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
}
|
|
29
|
+
else if (valueVertex.tag !== vertex_1.VertexType.Value) {
|
|
30
|
+
for (const exit of value.exitPoints) {
|
|
31
|
+
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
const containedSubflowIn = graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
|
|
35
|
-
.flatMap(([, info]) => info.subflow.in)
|
|
36
|
-
.toArray();
|
|
35
|
+
.flatMap(([, info]) => info.subflow.in);
|
|
37
36
|
// try to resolve them against the current environment
|
|
38
|
-
for (const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
for (const l of [value.in, containedSubflowIn]) {
|
|
38
|
+
for (const ref of l) {
|
|
39
|
+
if (ref.name) {
|
|
40
|
+
const refId = ref.nodeId;
|
|
41
|
+
const resolved = (0, resolve_by_name_1.resolveByName)(ref.name, env, ref.type) ?? [];
|
|
42
|
+
for (const resolve of resolved) {
|
|
43
|
+
graph.addEdge(refId, resolve.nodeId, edge_1.EdgeType.Reads);
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -51,7 +53,7 @@ function forceVertexArgumentValueReferences(rootId, value, graph, env) {
|
|
|
51
53
|
* @see convertFnArgument
|
|
52
54
|
*/
|
|
53
55
|
function convertFnArguments(args) {
|
|
54
|
-
return args.map(
|
|
56
|
+
return args.map(convertFnArgument);
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Transforms a function argument into a function argument reference for a function call vertex.
|
|
@@ -93,32 +95,38 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
93
95
|
continue;
|
|
94
96
|
}
|
|
95
97
|
const processed = (0, processor_1.processDataflowFor)(arg, { ...data, environment: argEnv });
|
|
96
|
-
if (
|
|
98
|
+
if (r_argument_1.RArgument.isWithValue(arg) && (forceArgs === 'all' || forceArgs[i]) && !model_1.RConstant.is(arg.value)) {
|
|
97
99
|
forceVertexArgumentValueReferences(functionRootId, processed, processed.graph, argEnv);
|
|
98
100
|
}
|
|
99
101
|
processedArguments.push(processed);
|
|
100
102
|
finalEnv = (0, overwrite_1.overwriteEnvironment)(finalEnv, processed.environment);
|
|
101
103
|
finalGraph.mergeWith(processed.graph);
|
|
102
104
|
// resolve reads within argument, we resolve before adding the `processed.environment` to avoid cyclic dependencies
|
|
103
|
-
for (const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
else {
|
|
111
|
-
/* maybe all targets are not definitely of the current scope and should be still kept */
|
|
112
|
-
let assumeItMayHaveAHigherTarget = true;
|
|
113
|
-
for (const resolved of tryToResolve) {
|
|
114
|
-
if ((0, info_1.happensInEveryBranch)(resolved.cds) && !(0, identifier_1.isReferenceType)(resolved.type, identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.BuiltInConstant)) {
|
|
115
|
-
assumeItMayHaveAHigherTarget = false;
|
|
116
|
-
}
|
|
117
|
-
finalGraph.addEdge(ingoing.nodeId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
118
|
-
}
|
|
119
|
-
if (assumeItMayHaveAHigherTarget) {
|
|
105
|
+
for (const l of [processed.in, processed.unknownReferences]) {
|
|
106
|
+
for (const ingoing of l) {
|
|
107
|
+
// check if it is called directly
|
|
108
|
+
const inId = ingoing.nodeId;
|
|
109
|
+
const refType = finalGraph.getVertex(inId)?.tag === vertex_1.VertexType.FunctionCall ? identifier_1.ReferenceType.Function : identifier_1.ReferenceType.Unknown;
|
|
110
|
+
const tryToResolve = ingoing.name ? (0, resolve_by_name_1.resolveByName)(ingoing.name, argEnv, refType) : undefined;
|
|
111
|
+
if (tryToResolve === undefined) {
|
|
120
112
|
remainingReadInArgs.push(ingoing);
|
|
121
113
|
}
|
|
114
|
+
else {
|
|
115
|
+
/* maybe all targets are not definitely of the current scope and should be still kept */
|
|
116
|
+
let assumeItMayHaveAHigherTarget = true;
|
|
117
|
+
for (const resolved of tryToResolve) {
|
|
118
|
+
if ((0, identifier_1.isReferenceType)(resolved.type, identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.BuiltInConstant)) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
else if ((0, info_1.happensInEveryBranch)(resolved.cds)) {
|
|
122
|
+
assumeItMayHaveAHigherTarget = false;
|
|
123
|
+
}
|
|
124
|
+
finalGraph.addEdge(inId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
125
|
+
}
|
|
126
|
+
if (assumeItMayHaveAHigherTarget) {
|
|
127
|
+
remainingReadInArgs.push(ingoing);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
132
|
argEnv = (0, overwrite_1.overwriteEnvironment)(argEnv, processed.environment);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DataflowProcessorInformation } from '../../../processor';
|
|
2
2
|
import { type DataflowInformation } from '../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import
|
|
4
|
+
import { RNode } from '../../../../r-bridge/lang-4.x/ast/model/model';
|
|
5
5
|
import type { IdentifierReference } from '../../../environments/identifier';
|
|
6
6
|
import { DataflowGraph } from '../../../graph/graph';
|
|
7
7
|
import type { RArgument } from '../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.linkReadsForArgument = linkReadsForArgument;
|
|
4
4
|
exports.processFunctionArgument = processFunctionArgument;
|
|
5
5
|
const processor_1 = require("../../../processor");
|
|
6
|
-
const
|
|
6
|
+
const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
|
|
7
7
|
const graph_1 = require("../../../graph/graph");
|
|
8
8
|
const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
9
|
const edge_1 = require("../../../graph/edge");
|
|
@@ -12,9 +12,9 @@ const vertex_1 = require("../../../graph/vertex");
|
|
|
12
12
|
* Links all reads that occur before the argument to the argument root node.
|
|
13
13
|
*/
|
|
14
14
|
function linkReadsForArgument(root, ingoingRefs, graph) {
|
|
15
|
-
const allIdsBeforeArguments = new Set((0, collect_1.collectAllIds)(root, n => n.type === type_1.RType.Argument && n.info.id !== root.info.id));
|
|
16
|
-
const ingoingBeforeArgs = ingoingRefs.filter(r => allIdsBeforeArguments.has(r.nodeId));
|
|
17
15
|
const rid = root.info.id;
|
|
16
|
+
const allIdsBeforeArguments = new Set(model_1.RNode.collectAllIdsWithStop(root, n => n.type === type_1.RType.Argument && n.info.id !== rid));
|
|
17
|
+
const ingoingBeforeArgs = ingoingRefs.filter(r => allIdsBeforeArguments.has(r.nodeId));
|
|
18
18
|
for (const ref of ingoingBeforeArgs) {
|
|
19
19
|
// link against the root reference currently I do not know how to deal with nested function calls otherwise
|
|
20
20
|
graph.addEdge(rid, ref.nodeId, edge_1.EdgeType.Reads);
|
|
@@ -5,8 +5,8 @@ const processor_1 = require("../../../processor");
|
|
|
5
5
|
const log_1 = require("../../../../util/log");
|
|
6
6
|
const identifier_1 = require("../../../environments/identifier");
|
|
7
7
|
const define_1 = require("../../../environments/define");
|
|
8
|
-
const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
8
|
const edge_1 = require("../../../graph/edge");
|
|
9
|
+
const r_function_definition_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
@@ -26,7 +26,7 @@ function processFunctionParameter(parameter, data) {
|
|
|
26
26
|
graph.setDefinitionOfVertex(writtenNode);
|
|
27
27
|
environment = (0, define_1.define)(writtenNode, false, environment);
|
|
28
28
|
if (defaultValue !== undefined) {
|
|
29
|
-
if (parameter.defaultValue
|
|
29
|
+
if (r_function_definition_1.RFunctionDefinition.is(parameter.defaultValue)) {
|
|
30
30
|
graph.addEdge(wid, parameter.defaultValue.info.id, edge_1.EdgeType.DefinedBy);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { DataflowGraph } from '../graph/graph';
|
|
3
3
|
import type { Identifier } from '../environments/identifier';
|
|
4
4
|
export declare const enum OriginType {
|