@eagleoutice/flowr 2.15.9 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -41
- package/abstract-interpretation/absint-inference.d.ts +2 -2
- package/abstract-interpretation/absint-inference.js +32 -79
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/benchmark/slicer.d.ts +0 -1
- package/benchmark/slicer.js +1 -2
- package/cli/repl/commands/repl-signature.js +12 -3
- package/config.d.ts +5 -1
- package/control-flow/cfg-properties.js +0 -22
- package/control-flow/happens-before.d.ts +7 -2
- package/control-flow/happens-before.js +55 -31
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/apply-kill.js +6 -2
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-props.d.ts +16 -1
- package/dataflow/environments/built-in-props.js +33 -20
- package/dataflow/environments/built-in.d.ts +8 -3
- package/dataflow/environments/built-in.js +52 -82
- package/dataflow/environments/default-builtin-config.d.ts +551 -21
- package/dataflow/environments/default-builtin-config.js +121 -45
- package/dataflow/environments/define.d.ts +3 -2
- package/dataflow/environments/define.js +4 -3
- package/dataflow/environments/deprecation-info.d.ts +45 -0
- package/dataflow/environments/deprecation-info.js +13 -0
- package/dataflow/environments/environment.d.ts +7 -5
- package/dataflow/environments/environment.js +55 -121
- package/dataflow/environments/identifier.d.ts +6 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +180 -58
- package/dataflow/fn/class-declaration.d.ts +8 -13
- package/dataflow/fn/class-declaration.js +95 -116
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +51 -41
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.d.ts +9 -1
- package/dataflow/fn/higher-order-function.js +27 -24
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +291 -123
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +13 -1
- package/dataflow/graph/graph.js +74 -66
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +31 -4
- package/dataflow/internal/control-flow.js +61 -39
- package/dataflow/internal/linker.d.ts +17 -8
- package/dataflow/internal/linker.js +286 -213
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- 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 +141 -146
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
- package/dataflow/internal/process/functions/call/common.d.ts +4 -4
- package/dataflow/internal/process/functions/call/common.js +49 -71
- package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
- package/dataflow/internal/process/functions/call/deferred.js +81 -63
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +257 -154
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +4 -3
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/data/faq/faqs.js +3 -3
- package/documentation/data/interface/doc-writing-code.js +1 -2
- package/documentation/data/server/doc-data-server-messages.js +7 -7
- package/documentation/doc-capabilities.js +80 -34
- package/documentation/doc-util/doc-query.d.ts +0 -3
- package/documentation/doc-util/doc-query.js +4 -3
- package/documentation/wiki-analyzer.js +1 -1
- package/documentation/wiki-cfg.js +5 -6
- package/documentation/wiki-core.js +8 -8
- package/documentation/wiki-dataflow-graph.js +10 -11
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linting-and-testing.js +3 -3
- package/documentation/wiki-overview.js +6 -6
- package/documentation/wiki-query.js +9 -101
- package/documentation/wiki-setup.js +23 -0
- package/documentation/wiki-signature-database.js +1 -1
- package/linter/linter-rules.d.ts +18 -9
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/deprecated-functions.d.ts +1 -45
- package/linter/rules/deprecated-functions.js +24 -33
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +114 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +128 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.d.ts +2 -0
- package/project/flowr-analyzer.js +28 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
- package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +4 -0
- package/project/sigdb/manifest.d.ts +2 -0
- package/project/sigdb/manifest.js +10 -1
- package/project/sigdb/reader.js +23 -61
- package/project/sigdb/sigdb-download.d.ts +29 -6
- package/project/sigdb/sigdb-download.js +212 -64
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
- package/queries/catalog/call-context-query/cascade-action.js +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/data/data.d.ts +21 -14
- package/r-bridge/data/data.js +28 -20
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell.js +6 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +115 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +2 -0
- package/util/files.js +3 -1
- package/util/mermaid/mermaid.js +6 -2
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -11,6 +11,7 @@ exports.processSourceCall = processSourceCall;
|
|
|
11
11
|
exports.sourceRequest = sourceRequest;
|
|
12
12
|
exports.standaloneSourceFile = standaloneSourceFile;
|
|
13
13
|
exports.mergeSourced = mergeSourced;
|
|
14
|
+
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
14
15
|
const processor_1 = require("../../../../../processor");
|
|
15
16
|
const append_1 = require("../../../../../environments/append");
|
|
16
17
|
const info_1 = require("../../../../../info");
|
|
@@ -27,7 +28,6 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
27
28
|
const path_1 = __importDefault(require("path"));
|
|
28
29
|
const files_1 = require("../../../../../../util/files");
|
|
29
30
|
const gas_1 = require("../../../../../../gas");
|
|
30
|
-
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
31
31
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
32
32
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
33
33
|
const edge_1 = require("../../../../../graph/edge");
|
|
@@ -43,12 +43,11 @@ function inferWdFromScript(option, referenceChain) {
|
|
|
43
43
|
case config_1.InferWorkingDirectory.MainScript:
|
|
44
44
|
return referenceChain[0] ? [platformDirname(referenceChain[0])] : [];
|
|
45
45
|
case config_1.InferWorkingDirectory.ActiveScript: {
|
|
46
|
-
const
|
|
47
|
-
return
|
|
46
|
+
const active = referenceChain.at(-1);
|
|
47
|
+
return active ? [platformDirname(active)] : [];
|
|
48
48
|
}
|
|
49
49
|
case config_1.InferWorkingDirectory.AnyScript:
|
|
50
|
-
return referenceChain.filter(assert_1.isNotUndefined).map(
|
|
51
|
-
case config_1.InferWorkingDirectory.No:
|
|
50
|
+
return referenceChain.filter(assert_1.isNotUndefined).map(platformDirname);
|
|
52
51
|
default:
|
|
53
52
|
return [];
|
|
54
53
|
}
|
|
@@ -75,7 +74,29 @@ function compileReplacements(replacements) {
|
|
|
75
74
|
return replacements.map(replacement => Object.entries(replacement).map(([key, value]) => [new RegExp(key, 'g'), value]));
|
|
76
75
|
}
|
|
77
76
|
function applyReplacements(path, replacements) {
|
|
78
|
-
return replacements.map(replacement =>
|
|
77
|
+
return replacements.map(replacement => {
|
|
78
|
+
let result = path;
|
|
79
|
+
for (const [pattern, value] of replacement) {
|
|
80
|
+
result = result.replaceAll(pattern, value);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function candidatePaths(seed, dropPaths) {
|
|
86
|
+
if (dropPaths !== config_1.DropPathsOption.Once && dropPaths !== config_1.DropPathsOption.All) {
|
|
87
|
+
return [seed];
|
|
88
|
+
}
|
|
89
|
+
const basename = platformBasename(seed);
|
|
90
|
+
const tryPaths = [seed, basename];
|
|
91
|
+
if (dropPaths === config_1.DropPathsOption.All) {
|
|
92
|
+
const dirs = platformDirname(seed).split(AnyPathSeparator);
|
|
93
|
+
if (dirs.length !== 1 || dirs[0] !== '.') {
|
|
94
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
95
|
+
tryPaths.push(path_1.default.join(...dirs.slice(i), basename));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return tryPaths;
|
|
79
100
|
}
|
|
80
101
|
/**
|
|
81
102
|
* Tries to find sourced by a source request and returns the first path that exists
|
|
@@ -86,48 +107,26 @@ function applyReplacements(path, replacements) {
|
|
|
86
107
|
function findSource(resolveSource, seed, data) {
|
|
87
108
|
const capitalization = resolveSource?.ignoreCapitalization ?? false;
|
|
88
109
|
const explorePaths = (resolveSource?.searchPath ?? []).concat(inferWdFromScript(resolveSource?.inferWorkingDirectory ?? config_1.InferWorkingDirectory.No, data.referenceChain));
|
|
89
|
-
let tryPaths =
|
|
90
|
-
switch (resolveSource?.dropPaths ?? config_1.DropPathsOption.No) {
|
|
91
|
-
case config_1.DropPathsOption.Once: {
|
|
92
|
-
const first = platformBasename(seed);
|
|
93
|
-
tryPaths.push(first);
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case config_1.DropPathsOption.All: {
|
|
97
|
-
const paths = platformDirname(seed).split(AnyPathSeparator);
|
|
98
|
-
const basename = platformBasename(seed);
|
|
99
|
-
tryPaths.push(basename);
|
|
100
|
-
if (paths.length === 1 && paths[0] === '.') {
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
for (let i = 0; i < paths.length; i++) {
|
|
104
|
-
tryPaths.push(path_1.default.join(...paths.slice(i), basename));
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case config_1.DropPathsOption.No:
|
|
109
|
-
default:
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
110
|
+
let tryPaths = candidatePaths(seed, resolveSource?.dropPaths);
|
|
112
111
|
if (resolveSource?.applyReplacements) {
|
|
113
112
|
const r = compileReplacements(resolveSource.applyReplacements);
|
|
114
113
|
tryPaths = tryPaths.flatMap(t => applyReplacements(t, r));
|
|
115
114
|
}
|
|
116
|
-
const found =
|
|
115
|
+
const found = new Set();
|
|
117
116
|
for (const explore of [undefined, ...explorePaths]) {
|
|
118
117
|
for (const tryPath of tryPaths) {
|
|
119
118
|
const effectivePath = explore ? path_1.default.join(explore, tryPath) : tryPath;
|
|
120
119
|
const context = data.ctx.files;
|
|
121
120
|
const get = context.exists(effectivePath, capitalization) ?? context.exists(returnPlatformPath(effectivePath), capitalization);
|
|
122
|
-
if (get
|
|
123
|
-
found.
|
|
121
|
+
if (get) {
|
|
122
|
+
found.add(returnPlatformPath(get));
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
if (log_1.log.settings.minLevel >= 3 /* LogLevel.Info */) {
|
|
128
|
-
log_1.log.info(`Found sourced file ${JSON.stringify(seed)} at ${JSON.stringify(found)}`);
|
|
127
|
+
log_1.log.info(`Found sourced file ${JSON.stringify(seed)} at ${JSON.stringify([...found])}`);
|
|
129
128
|
}
|
|
130
|
-
return found;
|
|
129
|
+
return [...found];
|
|
131
130
|
}
|
|
132
131
|
/**
|
|
133
132
|
* Processes a named function call (i.e., not an anonymous function)
|
|
@@ -140,60 +139,55 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
140
139
|
const information = config.includeFunctionCall ?
|
|
141
140
|
(0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Source }).information
|
|
142
141
|
: info_1.DataflowInformation.initialize(rootId, data);
|
|
142
|
+
const withAmbient = () => config.ambient === undefined ? information : (0, built_in_ambient_state_1.applyAmbientStateAccess)(information, args, rootId, data, config.ambient);
|
|
143
143
|
const sourceFileArgument = args[0];
|
|
144
144
|
if (!config.forceFollow && data.ctx.config.ignoreSourceCalls) {
|
|
145
145
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source call ${JSON.stringify(sourceFileArgument)} (disabled in config file)`);
|
|
146
146
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
147
|
-
return
|
|
147
|
+
return withAmbient();
|
|
148
148
|
}
|
|
149
149
|
let sourceFile;
|
|
150
150
|
if (sourceFileArgument !== r_function_call_1.EmptyArgument && r_string_1.RString.is(sourceFileArgument?.value)) {
|
|
151
151
|
sourceFile = [(0, retriever_1.removeRQuotes)(sourceFileArgument.lexeme)];
|
|
152
152
|
}
|
|
153
153
|
else if (sourceFileArgument !== r_function_call_1.EmptyArgument) {
|
|
154
|
-
|
|
155
|
-
sourceFile = resolved?.elements.map(r => r.type === 'string' && (0, r_value_1.isValue)(r.value) ? r.value.str : undefined).filter(assert_1.isNotUndefined);
|
|
154
|
+
sourceFile = node_value_1.NodeValue.knownStringsOf(sourceFileArgument.info.id, data);
|
|
156
155
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (findCount > limit) {
|
|
172
|
-
logger_1.dataflowLogger.warn(`Found cycle (>=${limit + 1}) in dataflow analysis for ${JSON.stringify(filepath)}: ${JSON.stringify(data.referenceChain)}, skipping further dataflow analysis`);
|
|
173
|
-
(0, unknown_side_effect_1.handleUnknownSideEffect)(result.graph, result.environment, rootId);
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
if (filepath.length > 1) {
|
|
177
|
-
data = { ...data, cds: [...origCds, { id: rootId, when: true, file: f }] };
|
|
178
|
-
}
|
|
179
|
-
result = sourceRequest(rootId, {
|
|
180
|
-
request: 'file',
|
|
181
|
-
content: f
|
|
182
|
-
}, data, result, maybe, (0, decorate_1.sourcedDeterministicCountingIdGenerator)((findCount > 0 ? findCount + '::' : '') + data.ctx.files.relativePath(f), name.location));
|
|
156
|
+
const path = sourceFile?.length === 1 ? (0, retriever_1.removeRQuotes)(sourceFile[0]) : undefined;
|
|
157
|
+
const filepath = path ? findSource(data.ctx.config.solver.resolveSource, path, data) : undefined;
|
|
158
|
+
if (filepath !== undefined && filepath.length > 0) {
|
|
159
|
+
let result = information;
|
|
160
|
+
const origCds = data.cds?.slice() ?? [];
|
|
161
|
+
const maybe = !data.ctx.config.solver.resolveSource?.assumeFilesExist || filepath.length > 1;
|
|
162
|
+
const limit = data.ctx.config.solver.resolveSource?.repeatedSourceLimit ?? 0;
|
|
163
|
+
for (const f of filepath) {
|
|
164
|
+
// check if the sourced file has already been dataflow analyzed, and if so, skip it
|
|
165
|
+
const findCount = data.referenceChain.filter(e => e === f).length;
|
|
166
|
+
if (findCount > limit) {
|
|
167
|
+
logger_1.dataflowLogger.warn(`Found cycle (>=${limit + 1}) in dataflow analysis for ${JSON.stringify(filepath)}: ${JSON.stringify(data.referenceChain)}, skipping further dataflow analysis`);
|
|
168
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(result.graph, result.environment, rootId);
|
|
169
|
+
continue;
|
|
183
170
|
}
|
|
184
|
-
|
|
171
|
+
if (filepath.length > 1) {
|
|
172
|
+
data = { ...data, cds: [...origCds, { id: rootId, when: true, file: f }] };
|
|
173
|
+
}
|
|
174
|
+
const idPrefix = (findCount > 0 ? findCount + '::' : '') + data.ctx.files.relativePath(f);
|
|
175
|
+
const getId = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(idPrefix, name.location);
|
|
176
|
+
result = sourceRequest(rootId, { request: 'file', content: f }, data, result, maybe, getId);
|
|
185
177
|
}
|
|
178
|
+
return result;
|
|
186
179
|
}
|
|
187
180
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Non-constant argument ${JSON.stringify(sourceFile)} for source is currently not supported, skipping`);
|
|
188
181
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
189
|
-
return
|
|
182
|
+
return withAmbient();
|
|
190
183
|
}
|
|
184
|
+
/** the files parsed for an inclusion, a requested file is not among them and its inclusions share its nodes */
|
|
185
|
+
const includedFiles = new WeakSet();
|
|
191
186
|
/**
|
|
192
187
|
* Processes a source request with the given dataflow processor information and existing dataflow information
|
|
193
188
|
* Otherwise, this can be an {@link RProjectFile} representing a standalone source file
|
|
194
189
|
*/
|
|
195
190
|
function sourceRequest(rootId, request, data, information, makeMaybe, getId, evaluatedByRoot = false) {
|
|
196
|
-
// parse, normalize, and dataflow the sourced file
|
|
197
191
|
let dataflow;
|
|
198
192
|
let fst;
|
|
199
193
|
let filePath;
|
|
@@ -204,22 +198,16 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
204
198
|
else {
|
|
205
199
|
const textRequest = data.ctx.files.resolveRequest(request);
|
|
206
200
|
if (textRequest === undefined && request.request === 'file') {
|
|
207
|
-
// if translation failed there is nothing we can do!!
|
|
208
201
|
logger_1.dataflowLogger.warn(`Failed to analyze sourced file ${JSON.stringify(request)}: file does not exist`);
|
|
209
202
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
210
203
|
return information;
|
|
211
204
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (ext !== '' && ext !== '.r') {
|
|
219
|
-
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source of non-R file ${JSON.stringify(textRequest.path)}`);
|
|
220
|
-
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
221
|
-
return information;
|
|
222
|
-
}
|
|
205
|
+
(0, assert_1.guard)(textRequest !== undefined, `Expected text request to be defined for sourced file ${JSON.stringify(request)}`);
|
|
206
|
+
const ext = textRequest.path ? /\.[^.]*$/.exec(textRequest.path)?.[0].toLowerCase() : undefined;
|
|
207
|
+
if (ext !== undefined && ext !== '.r') {
|
|
208
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source of non-R file ${JSON.stringify(textRequest.path)}`);
|
|
209
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
210
|
+
return information;
|
|
223
211
|
}
|
|
224
212
|
const gasLevel = data.ctx.gas.checkGas(gas_1.GasFeatureKey.Source);
|
|
225
213
|
if (gasLevel >= 2 /* GasLevel.Critical */) {
|
|
@@ -230,18 +218,24 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
230
218
|
else if (gasLevel >= 1 /* GasLevel.Problematic */) {
|
|
231
219
|
logger_1.dataflowLogger.warn(`Approaching resource limits for source of ${JSON.stringify(request)} (gas: problematic). See ${gas_1.GasWikiRef}`);
|
|
232
220
|
}
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
: (0, parser_1.normalize)({ files: [{ parsed, filePath: textRequest.path }] }, getId));
|
|
237
|
-
fst = normalized.ast.files[0];
|
|
238
|
-
// this can be improved, see issue #628
|
|
239
|
-
for (const [k, v] of normalized.idMap) {
|
|
240
|
-
data.completeAst.idMap.set(k, v);
|
|
221
|
+
const requested = textRequest.path === undefined || data.referenceChain.includes(textRequest.path) ? undefined : data.completeAst.ast.files.find(f => f.filePath === textRequest.path && !includedFiles.has(f));
|
|
222
|
+
if (requested) {
|
|
223
|
+
fst = requested;
|
|
241
224
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
225
|
+
else {
|
|
226
|
+
const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(textRequest.r, data.ctx);
|
|
227
|
+
const normalized = (typeof parsed !== 'string' ?
|
|
228
|
+
(0, parser_1.normalizeTreeSitter)({ files: [{ parsed, filePath: textRequest.path }] }, getId, data.ctx.config)
|
|
229
|
+
: (0, parser_1.normalize)({ files: [{ parsed, filePath: textRequest.path }] }, getId));
|
|
230
|
+
fst = normalized.ast.files[0];
|
|
231
|
+
includedFiles.add(fst);
|
|
232
|
+
// this can be improved, see issue #628
|
|
233
|
+
for (const [k, v] of normalized.idMap) {
|
|
234
|
+
data.completeAst.idMap.set(k, v);
|
|
235
|
+
}
|
|
236
|
+
if (!data.completeAst.ast.files.some(f => f.filePath === fst.filePath)) {
|
|
237
|
+
data.completeAst.ast.files.push(fst);
|
|
238
|
+
}
|
|
245
239
|
}
|
|
246
240
|
filePath = textRequest.path;
|
|
247
241
|
}
|
|
@@ -266,25 +260,22 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
266
260
|
dataflow.graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
267
261
|
}
|
|
268
262
|
}
|
|
269
|
-
else if (makeMaybe) {
|
|
270
|
-
if (dataflow.graph.hasVertex(dataflow.entryPoint)) {
|
|
271
|
-
dataflow.graph.addControlDependency(dataflow.entryPoint, rootId, true);
|
|
272
|
-
}
|
|
273
|
-
for (const out of dataflow.out) {
|
|
274
|
-
dataflow.graph.addControlDependency(out.nodeId, rootId, true);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
263
|
else {
|
|
264
|
+
const ids = dataflow.out.map(o => o.nodeId);
|
|
278
265
|
if (dataflow.graph.hasVertex(dataflow.entryPoint)) {
|
|
279
|
-
|
|
266
|
+
ids.unshift(dataflow.entryPoint);
|
|
280
267
|
}
|
|
281
|
-
for (const
|
|
282
|
-
|
|
268
|
+
for (const id of ids) {
|
|
269
|
+
if (makeMaybe) {
|
|
270
|
+
dataflow.graph.addControlDependency(id, rootId, true);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
dataflow.graph.addEdge(id, rootId, edge_1.EdgeType.Reads);
|
|
274
|
+
}
|
|
283
275
|
}
|
|
284
276
|
}
|
|
285
277
|
}
|
|
286
278
|
data.ctx.files.addConsideredFile(filePath ?? '<inline>');
|
|
287
|
-
// update our graph with the sourced file's information
|
|
288
279
|
const graph = information.graph.mergeWith(dataflow.graph);
|
|
289
280
|
control_flow_1.ControlFlow.continuesWith(graph, information, control_flow_1.ControlFlow.entryOf(dataflow));
|
|
290
281
|
return {
|
|
@@ -310,7 +301,7 @@ function standaloneSourceFile(idx, file, data, information) {
|
|
|
310
301
|
return sourceRequest('file-' + idx, file, {
|
|
311
302
|
...data,
|
|
312
303
|
environment: information.environment,
|
|
313
|
-
referenceChain: [
|
|
304
|
+
referenceChain: [file.filePath]
|
|
314
305
|
}, information, false);
|
|
315
306
|
}
|
|
316
307
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
-
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import type
|
|
3
|
+
import type { AstIdMap, ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import { 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
|
+
import { type DataflowGraph } from '../../../../../graph/graph';
|
|
8
|
+
import type { FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
7
9
|
/**
|
|
8
10
|
* Process a built-in try-catch or similar handler.
|
|
9
11
|
*/
|
|
@@ -15,3 +17,5 @@ export declare function processTryCatch<OtherInfo>(name: RSymbol<OtherInfo & Par
|
|
|
15
17
|
};
|
|
16
18
|
aborts?: boolean;
|
|
17
19
|
}): DataflowInformation;
|
|
20
|
+
/** Orders the raising calls in every body a block catching errors may run, once per definition and after linking bound all calls. */
|
|
21
|
+
export declare function orderRaisingBodies(graph: DataflowGraph, idMap: AstIdMap, ctx: FlowrAnalyzerContext): void;
|