@eagleoutice/flowr 2.9.9 → 2.9.11
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 +57 -54
- package/abstract-interpretation/absint-visitor.d.ts +16 -14
- package/abstract-interpretation/absint-visitor.js +93 -47
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/shape-inference.d.ts +2 -5
- package/abstract-interpretation/data-frame/shape-inference.js +4 -5
- package/abstract-interpretation/domains/abstract-domain.d.ts +4 -4
- package/abstract-interpretation/domains/abstract-domain.js +8 -8
- package/abstract-interpretation/domains/mapped-abstract-domain.d.ts +12 -5
- package/abstract-interpretation/domains/mapped-abstract-domain.js +47 -23
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +30 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +130 -4
- 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/cfg-simplification.d.ts +1 -0
- package/control-flow/cfg-simplification.js +1 -0
- 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 +34 -15
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/dataflow/cluster.js +1 -1
- package/dataflow/environments/built-in.d.ts +6 -15
- package/dataflow/environments/built-in.js +25 -33
- package/dataflow/environments/default-builtin-config.d.ts +4 -8
- package/dataflow/environments/default-builtin-config.js +8 -5
- package/dataflow/environments/reference-to-maybe.d.ts +8 -0
- package/dataflow/environments/reference-to-maybe.js +46 -3
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
- package/dataflow/eval/resolve/alias-tracking.js +6 -6
- package/dataflow/eval/resolve/resolve.js +12 -10
- 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 +5 -5
- package/dataflow/graph/graph.js +36 -32
- package/dataflow/graph/unknown-side-effect.js +3 -1
- package/dataflow/info.d.ts +4 -0
- package/dataflow/info.js +2 -2
- package/dataflow/internal/linker.d.ts +4 -4
- package/dataflow/internal/linker.js +59 -33
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.js +3 -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-for-loop.js +15 -6
- 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-repeat-loop.js +2 -2
- 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 +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +22 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -19
- 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/call/known-call-handling.js +0 -2
- 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-absint.js +7 -8
- package/documentation/wiki-cfg.js +3 -3
- package/documentation/wiki-mk/doc-context.d.ts +8 -0
- package/documentation/wiki-mk/doc-context.js +4 -0
- 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/dead-code.js +1 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/seeded-randomness.js +1 -1
- package/linter/rules/unused-definition.js +1 -1
- package/package.json +7 -7
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +9 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +12 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- 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/df-shape-query/df-shape-query-format.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-format.js +3 -3
- 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/decorate.js +23 -17
- 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/role.d.ts +18 -17
- 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 +33 -15
- 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 +6 -5
- 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 +3 -3
- package/util/mermaid/cfg.js +3 -4
- package/util/mermaid/dfg.d.ts +1 -1
- package/util/mermaid/dfg.js +13 -12
- 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
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuiltIns = exports.BuiltInEvalHandlerMapper = exports.BuiltInProcessorMapper = exports.BuiltInProcName = void 0;
|
|
4
|
-
exports.builtInId = builtInId;
|
|
5
|
-
exports.isBuiltIn = isBuiltIn;
|
|
6
|
-
exports.dropBuiltInPrefix = dropBuiltInPrefix;
|
|
7
4
|
const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
|
|
8
5
|
const built_in_access_1 = require("../internal/process/functions/call/built-in/built-in-access");
|
|
9
6
|
const built_in_if_then_else_1 = require("../internal/process/functions/call/built-in/built-in-if-then-else");
|
|
@@ -21,6 +18,8 @@ const built_in_function_definition_1 = require("../internal/process/functions/ca
|
|
|
21
18
|
const built_in_expression_list_1 = require("../internal/process/functions/call/built-in/built-in-expression-list");
|
|
22
19
|
const built_in_get_1 = require("../internal/process/functions/call/built-in/built-in-get");
|
|
23
20
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
21
|
+
const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
22
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
24
23
|
const edge_1 = require("../graph/edge");
|
|
25
24
|
const built_in_library_1 = require("../internal/process/functions/call/built-in/built-in-library");
|
|
26
25
|
const built_in_source_1 = require("../internal/process/functions/call/built-in/built-in-source");
|
|
@@ -30,7 +29,6 @@ const built_in_vector_1 = require("../internal/process/functions/call/built-in/b
|
|
|
30
29
|
const built_in_rm_1 = require("../internal/process/functions/call/built-in/built-in-rm");
|
|
31
30
|
const built_in_eval_1 = require("../internal/process/functions/call/built-in/built-in-eval");
|
|
32
31
|
const vertex_1 = require("../graph/vertex");
|
|
33
|
-
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
34
32
|
const unknown_side_effect_1 = require("../graph/unknown-side-effect");
|
|
35
33
|
const resolve_1 = require("../eval/resolve/resolve");
|
|
36
34
|
const built_in_stop_if_not_1 = require("../internal/process/functions/call/built-in/built-in-stop-if-not");
|
|
@@ -41,30 +39,11 @@ const built_in_s_three_dispatch_1 = require("../internal/process/functions/call/
|
|
|
41
39
|
const built_in_recall_1 = require("../internal/process/functions/call/built-in/built-in-recall");
|
|
42
40
|
const built_in_s_seven_new_generic_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-new-generic");
|
|
43
41
|
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function builtInId(name) {
|
|
48
|
-
return `built-in:${name}`;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Checks whether the given name is a built-in identifier
|
|
52
|
-
*/
|
|
53
|
-
function isBuiltIn(name) {
|
|
54
|
-
return String(name).startsWith('built-in:');
|
|
55
|
-
}
|
|
56
|
-
const builtInPrefixLength = 'built-in:'.length;
|
|
57
|
-
/**
|
|
58
|
-
* Drops the `built-in:` prefix from the given built-in name
|
|
59
|
-
*/
|
|
60
|
-
function dropBuiltInPrefix(name) {
|
|
61
|
-
return name.slice(builtInPrefixLength);
|
|
62
|
-
}
|
|
63
|
-
function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument, useAsProcessor, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall }) {
|
|
64
|
-
const activeProcessor = useAsProcessor ?? BuiltInProcName.Default;
|
|
65
|
-
const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs, origin: activeProcessor });
|
|
42
|
+
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
43
|
+
function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument, useAsProcessor = BuiltInProcName.Default, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall }) {
|
|
44
|
+
const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs, origin: useAsProcessor });
|
|
66
45
|
if (returnsNthArgument !== undefined) {
|
|
67
|
-
const arg = returnsNthArgument === 'last' ? processedArguments
|
|
46
|
+
const arg = returnsNthArgument === 'last' ? processedArguments.at(-1) : processedArguments[returnsNthArgument];
|
|
68
47
|
if (arg !== undefined) {
|
|
69
48
|
res.graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.Returns);
|
|
70
49
|
}
|
|
@@ -91,11 +70,11 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
|
|
|
91
70
|
const rhs = arg.value;
|
|
92
71
|
let fnName;
|
|
93
72
|
let fnId;
|
|
94
|
-
if (
|
|
73
|
+
if (r_string_1.RString.is(rhs)) {
|
|
95
74
|
fnName = rhs.content.str;
|
|
96
75
|
fnId = rhs.info.id;
|
|
97
76
|
}
|
|
98
|
-
else if (
|
|
77
|
+
else if (r_symbol_1.RSymbol.is(rhs)) {
|
|
99
78
|
fnName = rhs.content;
|
|
100
79
|
fnId = rhs.info.id;
|
|
101
80
|
}
|
|
@@ -110,7 +89,7 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
|
|
|
110
89
|
environment: data.environment,
|
|
111
90
|
onlyBuiltin: false,
|
|
112
91
|
cds: data.cds,
|
|
113
|
-
origin: [
|
|
92
|
+
origin: [useAsProcessor]
|
|
114
93
|
});
|
|
115
94
|
}
|
|
116
95
|
}
|
|
@@ -120,6 +99,16 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
|
|
|
120
99
|
}
|
|
121
100
|
return res;
|
|
122
101
|
}
|
|
102
|
+
function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsProcessor = BuiltInProcName.Default, forceArgs }) {
|
|
103
|
+
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs, origin: useAsProcessor });
|
|
104
|
+
const g = information.graph;
|
|
105
|
+
for (const arg of processedArguments) {
|
|
106
|
+
if (arg) {
|
|
107
|
+
g.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.Reads);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return information;
|
|
111
|
+
}
|
|
123
112
|
/**
|
|
124
113
|
* This contains all names of built-in function handlers and origins
|
|
125
114
|
*/
|
|
@@ -137,6 +126,8 @@ var BuiltInProcName;
|
|
|
137
126
|
BuiltInProcName["Break"] = "builtin:break";
|
|
138
127
|
/** the default built-in processor, see {@link defaultBuiltInProcessor} */
|
|
139
128
|
BuiltInProcName["Default"] = "builtin:default";
|
|
129
|
+
/** Just a more performant variant of the default processor for built-ins that need to read all their arguments, see {@link defaultBuiltInProcessor}, this will still produce the origin `BuiltIn.Default` */
|
|
130
|
+
BuiltInProcName["DefaultReadAllArgs"] = "builtin:default-read-all-args";
|
|
140
131
|
/** for `eval` calls, see {@link processEvalCall} */
|
|
141
132
|
BuiltInProcName["Eval"] = "builtin:eval";
|
|
142
133
|
/** for expression lists, see {@link processExpressionList} */
|
|
@@ -208,6 +199,7 @@ exports.BuiltInProcessorMapper = {
|
|
|
208
199
|
[BuiltInProcName.Assignment]: built_in_assignment_1.processAssignment,
|
|
209
200
|
[BuiltInProcName.AssignmentLike]: built_in_assignment_1.processAssignmentLike,
|
|
210
201
|
[BuiltInProcName.Default]: defaultBuiltInProcessor,
|
|
202
|
+
[BuiltInProcName.DefaultReadAllArgs]: defaultBuiltInProcessorReadallArgs,
|
|
211
203
|
[BuiltInProcName.Eval]: built_in_eval_1.processEvalCall,
|
|
212
204
|
[BuiltInProcName.ExpressionList]: built_in_expression_list_1.processExpressionList,
|
|
213
205
|
[BuiltInProcName.ForLoop]: built_in_for_loop_1.processForLoop,
|
|
@@ -247,7 +239,7 @@ class BuiltIns {
|
|
|
247
239
|
registerBuiltInConstant({ names, value, assumePrimitive }) {
|
|
248
240
|
for (const name of names) {
|
|
249
241
|
const n = identifier_1.Identifier.getName(name);
|
|
250
|
-
const id =
|
|
242
|
+
const id = node_id_1.NodeId.toBuiltIn(n);
|
|
251
243
|
const d = [{
|
|
252
244
|
type: identifier_1.ReferenceType.BuiltInConstant,
|
|
253
245
|
definedAt: id,
|
|
@@ -268,7 +260,7 @@ class BuiltIns {
|
|
|
268
260
|
(0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(exports.BuiltInProcessorMapper))}!`);
|
|
269
261
|
for (const name of names) {
|
|
270
262
|
const n = identifier_1.Identifier.getName(name);
|
|
271
|
-
const id =
|
|
263
|
+
const id = node_id_1.NodeId.toBuiltIn(n);
|
|
272
264
|
const d = [{
|
|
273
265
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
274
266
|
definedAt: id,
|
|
@@ -291,7 +283,7 @@ class BuiltIns {
|
|
|
291
283
|
for (const assignment of names) {
|
|
292
284
|
for (const suffix of suffixes) {
|
|
293
285
|
const effectiveName = `${identifier_1.Identifier.getName(assignment)}${suffix}`;
|
|
294
|
-
const id =
|
|
286
|
+
const id = node_id_1.NodeId.toBuiltIn(effectiveName);
|
|
295
287
|
const d = [{
|
|
296
288
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
297
289
|
definedAt: id,
|
|
@@ -36,18 +36,14 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
36
36
|
}, {
|
|
37
37
|
readonly type: "function";
|
|
38
38
|
readonly names: ["~", "+", "-", "*", "/", "^", "!", "?", "**", "==", "!=", ">", "<", ">=", "<=", "%%", "%/%", "%*%", "%in%", ":", "rep", "seq", "seq_len", "seq_along", "seq.int", "gsub", "which", "class", "dimnames", "min", "max", "intersect", "subset", "match", "sqrt", "abs", "round", "floor", "ceiling", "signif", "trunc", "log", "log10", "log2", "sum", "mean", "unique", "paste", "paste0", "read.csv", "is.null", "numeric", "as.character", "as.integer", "as.logical", "as.numeric", "as.matrix", "rbind", "nrow", "ncol", "tryCatch", "expression", "factor", "missing", "as.data.frame", "data.frame", "na.omit", "rownames", "names", "order", "length", "any", "dim", "matrix", "cbind", "nchar", "pdf", "jpeg", "png", "windows", "postscript", "xfig", "bitmap", "pictex", "cairo_pdf", "svg", "bmp", "tiff", "X11", "quartz", "jitter"];
|
|
39
|
-
readonly processor: BuiltInProcName.
|
|
40
|
-
readonly config: {
|
|
41
|
-
readonly readAllArguments: true;
|
|
42
|
-
};
|
|
39
|
+
readonly processor: BuiltInProcName.DefaultReadAllArgs;
|
|
40
|
+
readonly config: {};
|
|
43
41
|
readonly assumePrimitive: true;
|
|
44
42
|
}, {
|
|
45
43
|
readonly type: "function";
|
|
46
44
|
readonly names: ["t", "aperm"];
|
|
47
|
-
readonly processor: BuiltInProcName.
|
|
48
|
-
readonly config: {
|
|
49
|
-
readonly readAllArguments: true;
|
|
50
|
-
};
|
|
45
|
+
readonly processor: BuiltInProcName.DefaultReadAllArgs;
|
|
46
|
+
readonly config: {};
|
|
51
47
|
readonly assumePrimitive: false;
|
|
52
48
|
}, {
|
|
53
49
|
readonly type: "function";
|
|
@@ -112,8 +112,8 @@ exports.DefaultBuiltinConfig = [
|
|
|
112
112
|
'pdf', 'jpeg', 'png', 'windows', 'postscript', 'xfig', 'bitmap', 'pictex', 'cairo_pdf', 'svg', 'bmp', 'tiff', 'X11', 'quartz',
|
|
113
113
|
'jitter'
|
|
114
114
|
],
|
|
115
|
-
processor: built_in_1.BuiltInProcName.
|
|
116
|
-
config: {
|
|
115
|
+
processor: built_in_1.BuiltInProcName.DefaultReadAllArgs,
|
|
116
|
+
config: {},
|
|
117
117
|
assumePrimitive: true
|
|
118
118
|
},
|
|
119
119
|
{
|
|
@@ -121,8 +121,8 @@ exports.DefaultBuiltinConfig = [
|
|
|
121
121
|
names: [
|
|
122
122
|
't', 'aperm' /* transpose function, permutation generation */
|
|
123
123
|
],
|
|
124
|
-
processor: built_in_1.BuiltInProcName.
|
|
125
|
-
config: {
|
|
124
|
+
processor: built_in_1.BuiltInProcName.DefaultReadAllArgs,
|
|
125
|
+
config: {},
|
|
126
126
|
assumePrimitive: false
|
|
127
127
|
},
|
|
128
128
|
{ type: 'function', names: ['rm'], processor: built_in_1.BuiltInProcName.Rm, config: {}, assumePrimitive: true },
|
|
@@ -371,6 +371,9 @@ function getDefaultProcessor(name) {
|
|
|
371
371
|
}
|
|
372
372
|
const fn = exports.DefaultBuiltinConfig.find(def => (def.names.includes(name) && def.type !== 'constant')
|
|
373
373
|
|| (def.type === 'replacement' && def.suffixes.flatMap(d => def.names.map(n => `${n}${d}`)).includes(name)));
|
|
374
|
-
|
|
374
|
+
if (fn?.type === 'replacement') {
|
|
375
|
+
return built_in_1.BuiltInProcName.Replacement;
|
|
376
|
+
}
|
|
377
|
+
return fn?.processor === built_in_1.BuiltInProcName.DefaultReadAllArgs ? built_in_1.BuiltInProcName.Default : fn?.processor;
|
|
375
378
|
}
|
|
376
379
|
//# sourceMappingURL=default-builtin-config.js.map
|
|
@@ -11,3 +11,11 @@ export declare function makeReferenceMaybe(ref: IdentifierReference, graph: Data
|
|
|
11
11
|
* @see {@link makeReferenceMaybe}
|
|
12
12
|
*/
|
|
13
13
|
export declare function makeAllMaybe(references: readonly IdentifierReference[] | undefined, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, applyCds?: ControlDependency[] | undefined): IdentifierReference[];
|
|
14
|
+
/**
|
|
15
|
+
* apply the given cds to all elements in the graph and also transform the given references similar to {@link makeAllMaybe}.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyCdsToAllInGraphButConstants(graph: DataflowGraph, references: readonly IdentifierReference[], cds: readonly ControlDependency[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* apply the given cds to all given references, but not to the graph. This is useful if we want to mark the references as maybe without marking all other nodes in the graph as maybe.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyCdToReferences(references: readonly IdentifierReference[], cds: readonly ControlDependency[]): void;
|
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeReferenceMaybe = makeReferenceMaybe;
|
|
4
4
|
exports.makeAllMaybe = makeAllMaybe;
|
|
5
|
+
exports.applyCdsToAllInGraphButConstants = applyCdsToAllInGraphButConstants;
|
|
6
|
+
exports.applyCdToReferences = applyCdToReferences;
|
|
5
7
|
const identifier_1 = require("./identifier");
|
|
6
8
|
const resolve_by_name_1 = require("./resolve-by-name");
|
|
9
|
+
const vertex_1 = require("../graph/vertex");
|
|
7
10
|
function appToCdsUnique(target, toAdd) {
|
|
8
11
|
if (toAdd) {
|
|
9
|
-
target.push(...toAdd.filter(c => !target.
|
|
12
|
+
target.push(...toAdd.filter(c => !target.some(tc => tc.id === c.id && tc.when === c.when)));
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
function concatCdsUnique(target, toAdd) {
|
|
13
16
|
if (toAdd) {
|
|
14
|
-
return target.concat(toAdd.filter(c => !target.
|
|
17
|
+
return target.concat(toAdd.filter(c => !target.some(tc => tc.id === c.id && tc.when === c.when)));
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
20
|
return target;
|
|
@@ -58,6 +61,46 @@ function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = u
|
|
|
58
61
|
* @see {@link makeReferenceMaybe}
|
|
59
62
|
*/
|
|
60
63
|
function makeAllMaybe(references, graph, environments, includeDefs, applyCds = undefined) {
|
|
61
|
-
|
|
64
|
+
if (references === undefined || references.length === 0) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
return references.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, applyCds));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* apply the given cds to all elements in the graph and also transform the given references similar to {@link makeAllMaybe}.
|
|
71
|
+
*/
|
|
72
|
+
function applyCdsToAllInGraphButConstants(graph, references, cds) {
|
|
73
|
+
for (const [, v] of graph.vertices(true)) {
|
|
74
|
+
if (v.tag === vertex_1.VertexType.Value) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (v.cds) {
|
|
78
|
+
appToCdsUnique(v.cds, cds);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
v.cds = Array.from(cds);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
for (const ref of references) {
|
|
85
|
+
if (ref.cds) {
|
|
86
|
+
appToCdsUnique(ref.cds, cds);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
ref.cds = Array.from(cds);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* apply the given cds to all given references, but not to the graph. This is useful if we want to mark the references as maybe without marking all other nodes in the graph as maybe.
|
|
95
|
+
*/
|
|
96
|
+
function applyCdToReferences(references, cds) {
|
|
97
|
+
for (const ref of references) {
|
|
98
|
+
if (ref.cds) {
|
|
99
|
+
appToCdsUnique(ref.cds, cds);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
ref.cds = Array.from(cds);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
62
105
|
}
|
|
63
106
|
//# sourceMappingURL=reference-to-maybe.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VariableResolve } from '../../../config';
|
|
2
2
|
import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
-
import {
|
|
3
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import { type REnvironmentInformation } from '../../environments/environment';
|
|
5
5
|
import { Identifier } from '../../environments/identifier';
|
|
6
6
|
import type { DataflowGraph } from '../../graph/graph';
|
|
@@ -58,7 +58,7 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
|
|
|
58
58
|
* @param ctx - Context used for clean environment
|
|
59
59
|
* @param blocked - If set, the ids that should not be considered during resolution (=>top)
|
|
60
60
|
*/
|
|
61
|
-
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full,
|
|
61
|
+
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked }: ResolveInfo): ResolveResult;
|
|
62
62
|
/**
|
|
63
63
|
* Please use {@link resolveIdToValue}
|
|
64
64
|
*
|
|
@@ -20,6 +20,7 @@ const general_1 = require("../values/general");
|
|
|
20
20
|
const r_value_1 = require("../values/r-value");
|
|
21
21
|
const set_constants_1 = require("../values/sets/set-constants");
|
|
22
22
|
const resolve_1 = require("./resolve");
|
|
23
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
23
24
|
const AliasHandler = {
|
|
24
25
|
[vertex_1.VertexType.Value]: (sourceId) => [sourceId],
|
|
25
26
|
[vertex_1.VertexType.Use]: getUseAlias,
|
|
@@ -119,8 +120,7 @@ function getAliases(sourceIds, dataflow, environment) {
|
|
|
119
120
|
* @param ctx - Context used for clean environment
|
|
120
121
|
* @param blocked - If set, the ids that should not be considered during resolution (=>top)
|
|
121
122
|
*/
|
|
122
|
-
function resolveIdToValue(id, { environment, graph, idMap, full = true,
|
|
123
|
-
const variableResolve = resolve ?? ctx.config.solver.variables;
|
|
123
|
+
function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, resolve = ctx.config.solver.variables, blocked }) {
|
|
124
124
|
blocked ??= new Set();
|
|
125
125
|
if (id === undefined) {
|
|
126
126
|
return r_value_1.Top;
|
|
@@ -134,13 +134,13 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve,
|
|
|
134
134
|
switch (node.type) {
|
|
135
135
|
case type_1.RType.Argument:
|
|
136
136
|
if (node.value) {
|
|
137
|
-
return resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve
|
|
137
|
+
return resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve, ctx, blocked });
|
|
138
138
|
}
|
|
139
139
|
// eslint-disable-next-line no-fallthrough
|
|
140
140
|
case type_1.RType.Symbol:
|
|
141
141
|
if (full) {
|
|
142
142
|
if (environment) {
|
|
143
|
-
return trackAliasInEnvironments(identifier_1.Identifier.toString(node.content), environment, { idMap, resolve
|
|
143
|
+
return trackAliasInEnvironments(identifier_1.Identifier.toString(node.content), environment, { idMap, resolve, ctx, graph, blocked });
|
|
144
144
|
}
|
|
145
145
|
else if (graph && resolve === config_1.VariableResolve.Alias) {
|
|
146
146
|
return trackAliasesInGraph(node.info.id, graph, ctx, idMap);
|
|
@@ -153,7 +153,7 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve,
|
|
|
153
153
|
case type_1.RType.BinaryOp:
|
|
154
154
|
case type_1.RType.UnaryOp:
|
|
155
155
|
return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)({
|
|
156
|
-
resolve
|
|
156
|
+
resolve, node, ctx, environment, graph, idMap, blocked
|
|
157
157
|
}));
|
|
158
158
|
case type_1.RType.String:
|
|
159
159
|
case type_1.RType.Number:
|
|
@@ -293,7 +293,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
|
293
293
|
if (target === undefined) {
|
|
294
294
|
continue;
|
|
295
295
|
}
|
|
296
|
-
if (
|
|
296
|
+
if (model_1.RLoopConstructs.is(target)) {
|
|
297
297
|
forceTop = true;
|
|
298
298
|
break;
|
|
299
299
|
}
|
|
@@ -18,6 +18,7 @@ const vector_constants_1 = require("../values/vectors/vector-constants");
|
|
|
18
18
|
const alias_tracking_1 = require("./alias-tracking");
|
|
19
19
|
const scalar_constants_1 = require("../values/scalar/scalar-constants");
|
|
20
20
|
const identifier_1 = require("../../environments/identifier");
|
|
21
|
+
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
21
22
|
/**
|
|
22
23
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
23
24
|
* you want to resolve the value of an identifier / node
|
|
@@ -27,32 +28,33 @@ const identifier_1 = require("../../environments/identifier");
|
|
|
27
28
|
* @returns resolved value or top/bottom
|
|
28
29
|
*/
|
|
29
30
|
function resolveNode({ resolve, node, ctx, blocked, environment, graph, idMap }) {
|
|
30
|
-
|
|
31
|
+
const nt = node.type;
|
|
32
|
+
if (nt === type_1.RType.String) {
|
|
31
33
|
return (0, string_constants_1.stringFrom)(node.content.str);
|
|
32
34
|
}
|
|
33
|
-
else if (
|
|
35
|
+
else if (nt === type_1.RType.Number) {
|
|
34
36
|
return (0, interval_constants_1.intervalFrom)(node.content.num, node.content.num);
|
|
35
37
|
}
|
|
36
|
-
else if (
|
|
38
|
+
else if (nt === type_1.RType.Logical) {
|
|
37
39
|
return node.content.valueOf() ? logical_constants_1.ValueLogicalTrue : logical_constants_1.ValueLogicalFalse;
|
|
38
40
|
}
|
|
39
|
-
else if (
|
|
41
|
+
else if (nt === type_1.RType.FunctionDefinition) {
|
|
40
42
|
return { type: 'function-definition' };
|
|
41
43
|
}
|
|
42
|
-
else if ((
|
|
44
|
+
else if ((nt === type_1.RType.FunctionCall || nt === type_1.RType.BinaryOp || nt === type_1.RType.UnaryOp) && graph) {
|
|
43
45
|
const origin = (0, dfg_get_origin_1.getOriginInDfg)(graph, node.info.id)?.[0];
|
|
44
46
|
if (origin === undefined || origin.type !== 3 /* OriginType.BuiltInFunctionOrigin */) {
|
|
45
47
|
return r_value_2.Top;
|
|
46
48
|
}
|
|
47
49
|
let builtInName;
|
|
48
|
-
if (
|
|
50
|
+
if (node_id_1.NodeId.isBuiltIn(origin.proc)) {
|
|
49
51
|
builtInName = origin.proc;
|
|
50
52
|
}
|
|
51
|
-
else if (
|
|
52
|
-
builtInName =
|
|
53
|
+
else if (nt === type_1.RType.FunctionCall && node.named) {
|
|
54
|
+
builtInName = node_id_1.NodeId.toBuiltIn(identifier_1.Identifier.getName(node.functionName.content));
|
|
53
55
|
}
|
|
54
|
-
else if (
|
|
55
|
-
builtInName =
|
|
56
|
+
else if (nt === type_1.RType.BinaryOp || nt === type_1.RType.UnaryOp) {
|
|
57
|
+
builtInName = node_id_1.NodeId.toBuiltIn(node.operator);
|
|
56
58
|
}
|
|
57
59
|
else {
|
|
58
60
|
return r_value_2.Top;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { CallGraph } from '../graph/call-graph';
|
|
3
3
|
import type { ControlDependency } from '../info';
|
|
4
4
|
export interface ExceptionPoint {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateExceptionsOfFunction = calculateExceptionsOfFunction;
|
|
4
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
4
5
|
const vertex_1 = require("../graph/vertex");
|
|
5
6
|
const built_in_1 = require("../environments/built-in");
|
|
6
7
|
const CatchHandlers = new Set([built_in_1.BuiltInProcName.Try]);
|
|
@@ -35,7 +36,7 @@ function calculateExceptionsOfFunction(id, graph, knownThrower = {}) {
|
|
|
35
36
|
if (!vtx) {
|
|
36
37
|
continue;
|
|
37
38
|
}
|
|
38
|
-
if (
|
|
39
|
+
if (node_id_1.NodeId.isBuiltIn(currentId)) {
|
|
39
40
|
continue;
|
|
40
41
|
}
|
|
41
42
|
if (vtx.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataflowGraph } from './graph';
|
|
2
2
|
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition } from './vertex';
|
|
3
|
-
import
|
|
3
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import { DefaultMap } from '../../util/collections/defaultmap';
|
|
5
5
|
/**
|
|
6
6
|
* A call graph is a dataflow graph where all vertices are function calls.
|
|
@@ -6,6 +6,7 @@ exports.dropTransitiveEdges = dropTransitiveEdges;
|
|
|
6
6
|
exports.computeCallGraph = computeCallGraph;
|
|
7
7
|
const graph_1 = require("./graph");
|
|
8
8
|
const vertex_1 = require("./vertex");
|
|
9
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
9
10
|
const linker_1 = require("../internal/linker");
|
|
10
11
|
const edge_1 = require("./edge");
|
|
11
12
|
const built_in_1 = require("../environments/built-in");
|
|
@@ -176,7 +177,7 @@ function processCall(vtx, from, graph, result, state) {
|
|
|
176
177
|
let addedTarget = false;
|
|
177
178
|
let addedBiTarget = false;
|
|
178
179
|
for (const tar of tars) {
|
|
179
|
-
if (
|
|
180
|
+
if (node_id_1.NodeId.isBuiltIn(tar)) {
|
|
180
181
|
result.addEdge(vid, tar, edge_1.EdgeType.Calls);
|
|
181
182
|
addedTarget = true;
|
|
182
183
|
addedBiTarget = true;
|
|
@@ -193,7 +194,7 @@ function processCall(vtx, from, graph, result, state) {
|
|
|
193
194
|
for (const origs of vtx.origin) {
|
|
194
195
|
if (origs.startsWith('builtin:')) {
|
|
195
196
|
addedTarget = true;
|
|
196
|
-
result.addEdge(vid,
|
|
197
|
+
result.addEdge(vid, node_id_1.NodeId.toBuiltIn(origs.substring('builtin:'.length)), edge_1.EdgeType.Calls);
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -237,7 +238,7 @@ function processUnknown(vtx, from, graph, result, state) {
|
|
|
237
238
|
return;
|
|
238
239
|
case vertex_1.VertexType.FunctionDefinition:
|
|
239
240
|
if (from) {
|
|
240
|
-
result.addEdge(from,
|
|
241
|
+
result.addEdge(from, node_id_1.NodeId.toBuiltIn('function'), edge_1.EdgeType.Calls);
|
|
241
242
|
}
|
|
242
243
|
return;
|
|
243
244
|
default:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
3
|
import { type DataflowFunctionFlowInformation, DataflowGraph, FunctionArgument } from './graph';
|
|
4
4
|
import { type IEnvironment, type REnvironmentInformation } from '../environments/environment';
|
|
@@ -48,21 +48,21 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
48
48
|
defineFunction(id, exitPoints, subflow, info, asRoot = true) {
|
|
49
49
|
return this.addVertexWithDefaultEnv({
|
|
50
50
|
tag: vertex_1.VertexType.FunctionDefinition,
|
|
51
|
-
id:
|
|
51
|
+
id: node_id_1.NodeId.normalize(id),
|
|
52
52
|
params: Object.fromEntries(info?.readParams ?? []),
|
|
53
53
|
subflow: {
|
|
54
54
|
...subflow,
|
|
55
|
-
entryPoint:
|
|
56
|
-
graph: new Set([...subflow.graph].map(node_id_1.
|
|
57
|
-
out: subflow.out.map(o => ({ ...o, nodeId:
|
|
58
|
-
in: subflow.in.map(o => ({ ...o, nodeId:
|
|
59
|
-
unknownReferences: subflow.unknownReferences.map(o => ({ ...o, nodeId:
|
|
55
|
+
entryPoint: node_id_1.NodeId.normalize(subflow.entryPoint),
|
|
56
|
+
graph: new Set([...subflow.graph].map(node_id_1.NodeId.normalize)),
|
|
57
|
+
out: subflow.out.map(o => ({ ...o, nodeId: node_id_1.NodeId.normalize(o.nodeId), cds: o.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })) })),
|
|
58
|
+
in: subflow.in.map(o => ({ ...o, nodeId: node_id_1.NodeId.normalize(o.nodeId), cds: o.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })) })),
|
|
59
|
+
unknownReferences: subflow.unknownReferences.map(o => ({ ...o, nodeId: node_id_1.NodeId.normalize(o.nodeId), cds: o.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })) })),
|
|
60
60
|
hooks: subflow.hooks ?? [],
|
|
61
61
|
},
|
|
62
62
|
mode: info?.mode,
|
|
63
|
-
exitPoints: exitPoints.map(e => typeof e === 'object' ? ({ ...e, nodeId:
|
|
64
|
-
({ nodeId:
|
|
65
|
-
cds: info?.cds?.map(c => ({ ...c, id:
|
|
63
|
+
exitPoints: exitPoints.map(e => typeof e === 'object' ? ({ ...e, nodeId: node_id_1.NodeId.normalize(e.nodeId), cds: e.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })) }) :
|
|
64
|
+
({ nodeId: node_id_1.NodeId.normalize(e), type: 0 /* ExitPointType.Default */, cds: undefined })),
|
|
65
|
+
cds: info?.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })),
|
|
66
66
|
environment: info?.environment,
|
|
67
67
|
}, asRoot);
|
|
68
68
|
}
|
|
@@ -76,14 +76,14 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
76
76
|
* (i.e., be a valid entry point), or is it nested (e.g., as part of a function definition)
|
|
77
77
|
*/
|
|
78
78
|
call(id, name, args, info, asRoot = true) {
|
|
79
|
-
const onlyBuiltInAuto = info?.reads?.length === 1 &&
|
|
79
|
+
const onlyBuiltInAuto = info?.reads?.length === 1 && node_id_1.NodeId.isBuiltIn(info?.reads[0]);
|
|
80
80
|
this.addVertexWithDefaultEnv({
|
|
81
81
|
tag: vertex_1.VertexType.FunctionCall,
|
|
82
|
-
id:
|
|
82
|
+
id: node_id_1.NodeId.normalize(id),
|
|
83
83
|
name,
|
|
84
|
-
args: args.map(a => a === r_function_call_1.EmptyArgument ? r_function_call_1.EmptyArgument : { ...a, nodeId:
|
|
84
|
+
args: args.map(a => a === r_function_call_1.EmptyArgument ? r_function_call_1.EmptyArgument : { ...a, nodeId: node_id_1.NodeId.normalize(a.nodeId), cds: undefined }),
|
|
85
85
|
environment: (info?.onlyBuiltIn || onlyBuiltInAuto) ? undefined : info?.environment ?? this.defaultEnvironment,
|
|
86
|
-
cds: info?.cds?.map(c => ({ ...c, id:
|
|
86
|
+
cds: info?.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })),
|
|
87
87
|
onlyBuiltin: info?.onlyBuiltIn ?? onlyBuiltInAuto ?? false,
|
|
88
88
|
origin: info?.origin ?? [(0, default_builtin_config_1.getDefaultProcessor)(name) ?? built_in_1.BuiltInProcName.Function],
|
|
89
89
|
link: info?.link
|
|
@@ -133,9 +133,9 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
133
133
|
defineVariable(id, name, info, asRoot = true) {
|
|
134
134
|
this.addVertexWithDefaultEnv({
|
|
135
135
|
tag: vertex_1.VertexType.VariableDefinition,
|
|
136
|
-
id:
|
|
136
|
+
id: node_id_1.NodeId.normalize(id),
|
|
137
137
|
name,
|
|
138
|
-
cds: info?.cds?.map(c => ({ ...c, id:
|
|
138
|
+
cds: info?.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })),
|
|
139
139
|
}, asRoot);
|
|
140
140
|
if (info?.definedBy) {
|
|
141
141
|
for (const def of info.definedBy) {
|
|
@@ -155,13 +155,13 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
155
155
|
use(id, name, info, asRoot = true) {
|
|
156
156
|
return this.addVertexWithDefaultEnv((0, objects_1.deepMergeObject)({
|
|
157
157
|
tag: vertex_1.VertexType.Use,
|
|
158
|
-
id:
|
|
158
|
+
id: node_id_1.NodeId.normalize(id),
|
|
159
159
|
name,
|
|
160
160
|
cds: undefined,
|
|
161
161
|
environment: undefined
|
|
162
162
|
}, {
|
|
163
163
|
...info,
|
|
164
|
-
cds: info?.cds?.map(c => ({ ...c, id:
|
|
164
|
+
cds: info?.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) }))
|
|
165
165
|
}), asRoot);
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -174,8 +174,8 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
174
174
|
constant(id, options, asRoot = true) {
|
|
175
175
|
return this.addVertexWithDefaultEnv({
|
|
176
176
|
tag: vertex_1.VertexType.Value,
|
|
177
|
-
id:
|
|
178
|
-
cds: options?.cds?.map(c => ({ ...c, id:
|
|
177
|
+
id: node_id_1.NodeId.normalize(id),
|
|
178
|
+
cds: options?.cds?.map(c => ({ ...c, id: node_id_1.NodeId.normalize(c.id) })),
|
|
179
179
|
environment: undefined
|
|
180
180
|
}, asRoot);
|
|
181
181
|
}
|
|
@@ -186,7 +186,7 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
186
186
|
}
|
|
187
187
|
return this;
|
|
188
188
|
}
|
|
189
|
-
return this.addEdge(
|
|
189
|
+
return this.addEdge(node_id_1.NodeId.normalize(from), node_id_1.NodeId.normalize(to), type);
|
|
190
190
|
}
|
|
191
191
|
async queryHelper(from, to, data, type) {
|
|
192
192
|
let fromId;
|
|
@@ -344,7 +344,7 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
344
344
|
* this is just an easier variant in case you working with a lot of functions this saves you a lot of `false` flags.
|
|
345
345
|
*/
|
|
346
346
|
overwriteRootIds(ids) {
|
|
347
|
-
this.rootVertices = new Set(ids.map(node_id_1.
|
|
347
|
+
this.rootVertices = new Set(ids.map(node_id_1.NodeId.normalize));
|
|
348
348
|
return this;
|
|
349
349
|
}
|
|
350
350
|
}
|
|
@@ -3,7 +3,7 @@ import type { DataflowInformation } from '../info';
|
|
|
3
3
|
import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall, type DataflowGraphVertexInfo } from './vertex';
|
|
4
4
|
import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { BrandedIdentifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
|
|
6
|
-
import {
|
|
6
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import { type REnvironmentInformation } from '../environments/environment';
|
|
8
8
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
9
|
import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
@@ -88,12 +88,12 @@ export declare const FunctionArgument: {
|
|
|
88
88
|
* ```
|
|
89
89
|
* @see {@link isNotEmpty}
|
|
90
90
|
*/
|
|
91
|
-
readonly isEmpty: (this: void, arg:
|
|
91
|
+
readonly isEmpty: (this: void, arg: unknown) => arg is typeof EmptyArgument;
|
|
92
92
|
/**
|
|
93
93
|
* Checks whether the given argument is not an empty argument.
|
|
94
|
-
* @see {@link isEmpty}
|
|
94
|
+
* @see {@link FunctionArgument.isEmpty}
|
|
95
95
|
*/
|
|
96
|
-
readonly isNotEmpty: (this: void, arg:
|
|
96
|
+
readonly isNotEmpty: <T>(this: void, arg: T) => arg is Exclude<T, typeof EmptyArgument>;
|
|
97
97
|
/**
|
|
98
98
|
* Returns the reference of a non-empty argument.
|
|
99
99
|
* @example
|
|
@@ -262,7 +262,7 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
262
262
|
*/
|
|
263
263
|
updateToFunctionCall(info: DataflowGraphVertexFunctionCall): void;
|
|
264
264
|
/** If you do not pass the `to` node, this will just mark the node as maybe */
|
|
265
|
-
addControlDependency(from: NodeId, to
|
|
265
|
+
addControlDependency(from: NodeId, to: NodeId, when?: boolean): this;
|
|
266
266
|
/** Marks the given node as having unknown side effects */
|
|
267
267
|
markIdForUnknownSideEffects(id: NodeId, target?: LinkTo<RegExp | string>): this;
|
|
268
268
|
/**
|