@eagleoutice/flowr 2.2.14 → 2.2.16
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 +210 -6
- package/benchmark/slicer.d.ts +3 -1
- package/benchmark/slicer.js +8 -5
- package/benchmark/summarizer/first-phase/process.d.ts +2 -1
- package/benchmark/summarizer/first-phase/process.js +2 -2
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +7 -8
- package/cli/common/options.js +2 -0
- package/cli/export-quads-app.js +2 -1
- package/cli/flowr.js +58 -57
- package/cli/repl/commands/repl-cfg.js +13 -13
- package/cli/repl/commands/repl-commands.js +3 -3
- package/cli/repl/commands/repl-dataflow.js +10 -10
- package/cli/repl/commands/repl-execute.d.ts +2 -3
- package/cli/repl/commands/repl-execute.js +5 -4
- package/cli/repl/commands/repl-lineage.js +4 -4
- package/cli/repl/commands/repl-main.d.ts +12 -1
- package/cli/repl/commands/repl-normalize.js +6 -6
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +9 -9
- package/cli/repl/commands/repl-version.js +1 -1
- package/cli/repl/core.d.ts +5 -2
- package/cli/repl/core.js +10 -8
- package/cli/repl/server/connection.d.ts +3 -1
- package/cli/repl/server/connection.js +7 -5
- package/cli/repl/server/server.d.ts +3 -2
- package/cli/repl/server/server.js +4 -2
- package/cli/script-core/statistics-core.d.ts +2 -1
- package/cli/script-core/statistics-core.js +2 -2
- package/cli/script-core/statistics-helper-core.d.ts +2 -1
- package/cli/script-core/statistics-helper-core.js +5 -4
- package/cli/slicer-app.js +4 -2
- package/cli/statistics-app.js +2 -1
- package/cli/statistics-helper-app.js +2 -1
- package/config.d.ts +12 -10
- package/config.js +27 -43
- package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
- package/control-flow/cfg-dead-code.d.ts +4 -0
- package/control-flow/cfg-dead-code.js +124 -0
- package/control-flow/cfg-simplification.d.ts +19 -6
- package/control-flow/cfg-simplification.js +23 -19
- package/control-flow/control-flow-graph.d.ts +3 -1
- package/control-flow/control-flow-graph.js +5 -0
- package/control-flow/dfg-cfg-guided-visitor.d.ts +9 -7
- package/control-flow/dfg-cfg-guided-visitor.js +16 -5
- package/control-flow/extract-cfg.d.ts +4 -2
- package/control-flow/extract-cfg.js +63 -59
- package/control-flow/semantic-cfg-guided-visitor.d.ts +36 -9
- package/control-flow/semantic-cfg-guided-visitor.js +73 -20
- package/control-flow/simple-visitor.d.ts +4 -0
- package/control-flow/simple-visitor.js +14 -0
- package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -2
- package/core/pipeline-executor.d.ts +4 -1
- package/core/pipeline-executor.js +6 -5
- package/core/steps/all/core/10-normalize.d.ts +2 -0
- package/core/steps/all/core/10-normalize.js +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
- package/core/steps/all/core/20-dataflow.d.ts +2 -1
- package/core/steps/all/core/20-dataflow.js +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
- package/core/steps/all/static-slicing/00-slice.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +32 -31
- package/core/steps/pipeline/default-pipelines.js +8 -8
- package/core/steps/pipeline-step.d.ts +2 -1
- package/dataflow/environments/built-in-config.d.ts +4 -3
- package/dataflow/environments/built-in.d.ts +16 -1
- package/dataflow/environments/built-in.js +11 -5
- package/dataflow/environments/default-builtin-config.js +5 -3
- package/dataflow/environments/define.d.ts +2 -1
- package/dataflow/environments/define.js +4 -5
- package/dataflow/environments/remove.d.ts +6 -0
- package/dataflow/environments/remove.js +29 -0
- package/dataflow/environments/resolve-by-name.d.ts +0 -36
- package/dataflow/environments/resolve-by-name.js +0 -240
- package/dataflow/eval/resolve/alias-tracking.d.ts +92 -0
- package/dataflow/eval/resolve/alias-tracking.js +352 -0
- package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
- package/dataflow/eval/resolve/resolve-argument.js +118 -0
- package/dataflow/eval/resolve/resolve.d.ts +37 -0
- package/dataflow/eval/resolve/resolve.js +95 -0
- package/dataflow/eval/values/general.d.ts +27 -0
- package/dataflow/eval/values/general.js +73 -0
- package/dataflow/eval/values/intervals/interval-constants.d.ts +4 -0
- package/dataflow/eval/values/intervals/interval-constants.js +27 -0
- package/dataflow/eval/values/logical/logical-constants.d.ts +7 -0
- package/dataflow/eval/values/logical/logical-constants.js +31 -0
- package/dataflow/eval/values/r-value.d.ts +58 -0
- package/dataflow/eval/values/r-value.js +90 -0
- package/dataflow/eval/values/scalar/scalar-consatnts.d.ts +15 -0
- package/dataflow/eval/values/scalar/scalar-consatnts.js +35 -0
- package/dataflow/eval/values/sets/set-constants.d.ts +7 -0
- package/dataflow/eval/values/sets/set-constants.js +34 -0
- package/dataflow/eval/values/string/string-constants.d.ts +8 -0
- package/dataflow/eval/values/string/string-constants.js +45 -0
- package/dataflow/eval/values/vectors/vector-constants.d.ts +14 -0
- package/dataflow/eval/values/vectors/vector-constants.js +35 -0
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/unknown-replacement.d.ts +11 -0
- package/dataflow/graph/unknown-replacement.js +12 -0
- package/dataflow/graph/unknown-side-effect.d.ts +7 -0
- package/dataflow/graph/unknown-side-effect.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -5
- 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 +15 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +20 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +26 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -0
- package/dataflow/internal/process/functions/call/common.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
- package/dataflow/processor.d.ts +5 -0
- package/documentation/doc-util/doc-cfg.js +4 -3
- package/documentation/doc-util/doc-code.d.ts +1 -1
- package/documentation/doc-util/doc-dfg.js +3 -2
- package/documentation/doc-util/doc-functions.d.ts +24 -0
- package/documentation/doc-util/doc-functions.js +65 -0
- package/documentation/doc-util/doc-normalized-ast.js +3 -2
- package/documentation/doc-util/doc-print.d.ts +5 -0
- package/documentation/doc-util/doc-print.js +36 -0
- package/documentation/doc-util/doc-query.d.ts +6 -3
- package/documentation/doc-util/doc-query.js +6 -3
- package/documentation/doc-util/doc-repl.js +2 -1
- package/documentation/doc-util/doc-search.js +3 -2
- package/documentation/doc-util/doc-types.d.ts +28 -6
- package/documentation/doc-util/doc-types.js +89 -45
- package/documentation/print-cfg-wiki.js +10 -11
- package/documentation/print-core-wiki.js +5 -5
- package/documentation/print-dataflow-graph-wiki.js +14 -13
- package/documentation/print-engines-wiki.js +2 -3
- package/documentation/print-faq-wiki.js +8 -2
- package/documentation/print-interface-wiki.js +1 -2
- package/documentation/print-linter-issue.d.ts +1 -0
- package/documentation/print-linter-issue.js +71 -0
- package/documentation/print-linter-wiki.js +219 -34
- package/documentation/print-linting-and-testing-wiki.js +2 -4
- package/documentation/print-normalized-ast-wiki.js +3 -3
- package/documentation/print-query-wiki.js +81 -2
- package/documentation/print-readme.js +24 -1
- package/documentation/print-search-wiki.js +1 -2
- package/linter/linter-executor.d.ts +3 -1
- package/linter/linter-executor.js +3 -2
- package/linter/linter-format.d.ts +67 -7
- package/linter/linter-format.js +12 -1
- package/linter/linter-rules.d.ts +155 -16
- package/linter/linter-rules.js +12 -4
- package/linter/linter-tags.d.ts +80 -0
- package/linter/linter-tags.js +85 -0
- package/linter/rules/absolute-path.d.ts +71 -0
- package/linter/rules/absolute-path.js +177 -0
- package/linter/rules/deprecated-functions.d.ts +43 -0
- package/linter/rules/deprecated-functions.js +58 -0
- package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
- package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
- package/linter/rules/naming-convention.d.ts +71 -0
- package/linter/rules/naming-convention.js +164 -0
- package/linter/rules/seeded-randomness.d.ts +65 -0
- package/linter/rules/seeded-randomness.js +122 -0
- package/linter/rules/unused-definition.d.ts +41 -0
- package/linter/rules/unused-definition.js +105 -0
- package/package.json +4 -1
- package/queries/base-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.js +2 -3
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +3 -0
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +20 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +81 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +34 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -115
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-format.js +17 -12
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -4
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -22
- package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
- package/queries/catalog/search-query/search-query-executor.js +2 -2
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/query.d.ts +75 -15
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
- package/r-bridge/lang-4.x/convert-values.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +18 -9
- package/r-bridge/shell.d.ts +3 -2
- package/r-bridge/shell.js +4 -5
- package/search/flowr-search-builder.d.ts +6 -2
- package/search/flowr-search-builder.js +7 -0
- package/search/flowr-search-filters.d.ts +32 -8
- package/search/flowr-search-filters.js +42 -15
- package/search/flowr-search.d.ts +4 -0
- package/search/search-executor/search-enrichers.d.ts +7 -3
- package/search/search-executor/search-enrichers.js +32 -20
- package/search/search-executor/search-generators.js +1 -1
- package/search/search-executor/search-transformer.d.ts +2 -0
- package/search/search-executor/search-transformer.js +10 -1
- package/slicing/criterion/parse.d.ts +8 -0
- package/slicing/criterion/parse.js +20 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +2 -3
- package/statistics/statistics.d.ts +3 -1
- package/statistics/statistics.js +5 -4
- package/util/containers.d.ts +12 -9
- package/util/containers.js +12 -9
- package/util/objects.d.ts +5 -4
- package/util/range.d.ts +5 -1
- package/util/range.js +11 -3
- package/util/text/strings.d.ts +6 -0
- package/util/text/strings.js +35 -0
- package/util/version.js +1 -1
- package/linter/rules/1-deprecated-functions.d.ts +0 -34
- package/linter/rules/1-deprecated-functions.js +0 -54
|
@@ -6,6 +6,7 @@ const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
|
|
|
6
6
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
7
7
|
const edge_1 = require("../dataflow/graph/edge");
|
|
8
8
|
const assert_1 = require("../util/assert");
|
|
9
|
+
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
10
|
/**
|
|
10
11
|
* This visitor extends on the {@link DataflowAwareCfgGuidedVisitor} by dispatching visitors for separate function calls as well,
|
|
11
12
|
* providing more information!
|
|
@@ -51,8 +52,15 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
51
52
|
case type_1.RType.Number: return this.onNumberConstant({ vertex: val, node: astNode });
|
|
52
53
|
case type_1.RType.Logical: return this.onLogicalConstant({ vertex: val, node: astNode });
|
|
53
54
|
case type_1.RType.Symbol:
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
if (astNode.lexeme === 'NULL') {
|
|
56
|
+
return this.onNullConstant({
|
|
57
|
+
vertex: val,
|
|
58
|
+
node: astNode
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return this.onSymbolConstant({ vertex: val, node: astNode });
|
|
63
|
+
}
|
|
56
64
|
}
|
|
57
65
|
(0, assert_1.guard)(false, `Unexpected value type ${astNode.type} for value ${astNode.lexeme}`);
|
|
58
66
|
}
|
|
@@ -90,7 +98,13 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
90
98
|
*/
|
|
91
99
|
visitFunctionDefinition(vertex) {
|
|
92
100
|
super.visitFunctionDefinition(vertex);
|
|
93
|
-
this.
|
|
101
|
+
const ast = this.getNormalizedAst(vertex.id);
|
|
102
|
+
if (ast?.type === type_1.RType.FunctionDefinition) {
|
|
103
|
+
this.onFunctionDefinition({ vertex, parameters: ast.parameters.map(p => p.info.id) });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.onFunctionDefinition({ vertex });
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
/**
|
|
96
110
|
* See {@link DataflowAwareCfgGuidedVisitor#visitFunctionCall} for the base implementation.
|
|
@@ -161,8 +175,26 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
161
175
|
return this.onSourceCall({ call });
|
|
162
176
|
case 'builtin:access':
|
|
163
177
|
return this.onAccessCall({ call });
|
|
164
|
-
case 'builtin:if-then-else':
|
|
165
|
-
|
|
178
|
+
case 'builtin:if-then-else': {
|
|
179
|
+
// recover dead arguments from ast
|
|
180
|
+
const ast = this.getNormalizedAst(call.id);
|
|
181
|
+
if (!ast || ast.type !== type_1.RType.IfThenElse) {
|
|
182
|
+
return this.onIfThenElseCall({
|
|
183
|
+
call,
|
|
184
|
+
condition: call.args[0] === r_function_call_1.EmptyArgument ? undefined : call.args[0].nodeId,
|
|
185
|
+
then: call.args[1] === r_function_call_1.EmptyArgument ? undefined : call.args[1].nodeId,
|
|
186
|
+
else: call.args[2] === r_function_call_1.EmptyArgument ? undefined : call.args[2].nodeId
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
return this.onIfThenElseCall({
|
|
191
|
+
call,
|
|
192
|
+
condition: ast.condition.info.id,
|
|
193
|
+
then: ast.then.info.id,
|
|
194
|
+
else: ast.otherwise?.info.id
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
166
198
|
case 'builtin:get':
|
|
167
199
|
return this.onGetCall({ call });
|
|
168
200
|
case 'builtin:rm':
|
|
@@ -173,11 +205,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
173
205
|
return this.onVectorCall({ call });
|
|
174
206
|
case 'table:assign':
|
|
175
207
|
case 'builtin:assignment': {
|
|
176
|
-
const outgoing = this.config.
|
|
208
|
+
const outgoing = this.config.dfg.outgoingEdges(call.id);
|
|
177
209
|
if (outgoing) {
|
|
178
210
|
const target = [...outgoing.entries()].filter(([, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.Returns));
|
|
179
211
|
if (target.length === 1) {
|
|
180
|
-
const targetOut = this.config.
|
|
212
|
+
const targetOut = this.config.dfg.outgoingEdges(target[0][0]);
|
|
181
213
|
if (targetOut) {
|
|
182
214
|
const source = [...targetOut.entries()].filter(([t, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.DefinedBy) && t !== call.id);
|
|
183
215
|
if (source.length === 1) {
|
|
@@ -189,9 +221,15 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
189
221
|
return this.onAssignmentCall({ call, target: undefined, source: undefined });
|
|
190
222
|
}
|
|
191
223
|
case 'builtin:special-bin-op':
|
|
192
|
-
|
|
224
|
+
if (call.args.length !== 2) {
|
|
225
|
+
return this.onSpecialBinaryOpCall({ call });
|
|
226
|
+
}
|
|
227
|
+
return this.onSpecialBinaryOpCall({ call, lhs: call.args[0], rhs: call.args[1] });
|
|
193
228
|
case 'builtin:pipe':
|
|
194
|
-
|
|
229
|
+
if (call.args.length !== 2) {
|
|
230
|
+
return this.onPipeCall({ call });
|
|
231
|
+
}
|
|
232
|
+
return this.onPipeCall({ call, lhs: call.args[0], rhs: call.args[1] });
|
|
195
233
|
case 'builtin:quote':
|
|
196
234
|
return this.onQuoteCall({ call });
|
|
197
235
|
case 'builtin:for-loop':
|
|
@@ -201,11 +239,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
201
239
|
case 'builtin:while-loop':
|
|
202
240
|
return this.onWhileLoopCall({ call, condition: call.args[0], body: call.args[1] });
|
|
203
241
|
case 'builtin:replacement': {
|
|
204
|
-
const outgoing = this.config.
|
|
242
|
+
const outgoing = this.config.dfg.outgoingEdges(call.id);
|
|
205
243
|
if (outgoing) {
|
|
206
244
|
const target = [...outgoing.entries()].filter(([, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.Returns));
|
|
207
245
|
if (target.length === 1) {
|
|
208
|
-
const targetOut = this.config.
|
|
246
|
+
const targetOut = this.config.dfg.outgoingEdges(target[0][0]);
|
|
209
247
|
if (targetOut) {
|
|
210
248
|
const source = [...targetOut.entries()].filter(([t, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.DefinedBy) && t !== call.id);
|
|
211
249
|
if (source.length === 1) {
|
|
@@ -223,15 +261,23 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
223
261
|
return this.onDefaultFunctionCall({ call });
|
|
224
262
|
}
|
|
225
263
|
}
|
|
226
|
-
|
|
227
|
-
|
|
264
|
+
/**
|
|
265
|
+
* This event is called for the root program node, i.e., the program that is being analyzed.
|
|
266
|
+
*
|
|
267
|
+
* @protected
|
|
268
|
+
*/
|
|
269
|
+
onProgram(_data) { }
|
|
228
270
|
/**
|
|
229
271
|
* A helper function to request the {@link getOriginInDfg|origins} of the given node.
|
|
230
272
|
*/
|
|
231
273
|
getOrigins(id) {
|
|
232
|
-
return (0, dfg_get_origin_1.getOriginInDfg)(this.config.
|
|
274
|
+
return (0, dfg_get_origin_1.getOriginInDfg)(this.config.dfg, id);
|
|
233
275
|
}
|
|
234
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* Called for every occurrence of a `NULL` in the program.
|
|
278
|
+
*
|
|
279
|
+
* For other symbols that are not referenced as a variable, see {@link SemanticCfgGuidedVisitor#onSymbolConstant|`onSymbolConstant`}.
|
|
280
|
+
*/
|
|
235
281
|
onNullConstant(_data) { }
|
|
236
282
|
/**
|
|
237
283
|
* Called for every constant string value in the program.
|
|
@@ -251,6 +297,15 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
251
297
|
* For example, `TRUE` in `if(TRUE) { ... }`.
|
|
252
298
|
*/
|
|
253
299
|
onLogicalConstant(_data) { }
|
|
300
|
+
/**
|
|
301
|
+
* Called for every constant symbol value in the program.
|
|
302
|
+
*
|
|
303
|
+
* For example, `foo` in `library(foo)` or `a` in `l$a`. This most likely happens as part of non-standard-evaluation, i.e., the symbol is not evaluated to a value,
|
|
304
|
+
* but used as a symbol in and of itself.
|
|
305
|
+
*
|
|
306
|
+
* Please note, that due to its special behaviors, `NULL` is handled in {@link SemanticCfgGuidedVisitor#onNullConstant|`onNullConstant`} and not here.
|
|
307
|
+
*/
|
|
308
|
+
onSymbolConstant(_data) { }
|
|
254
309
|
/**
|
|
255
310
|
* Called for every variable that is read within the program.
|
|
256
311
|
* You can use {@link getOrigins} to get the origins of the variable.
|
|
@@ -300,7 +355,7 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
300
355
|
*
|
|
301
356
|
* This explicitly will not trigger for scenarios in which the function has no name (i.e., if it is anonymous).
|
|
302
357
|
* For such cases, you may rely on the {@link SemanticCfgGuidedVisitor#onUnnamedCall|`onUnnamedCall`} event.
|
|
303
|
-
* The main reason for this separation is part of flowR's handling of these functions, as
|
|
358
|
+
* The main reason for this separation is part of flowR's handling of these functions, as anonymous calls cannot be resolved using the active environment.
|
|
304
359
|
*
|
|
305
360
|
* @protected
|
|
306
361
|
*/
|
|
@@ -351,15 +406,13 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
351
406
|
*
|
|
352
407
|
* @protected
|
|
353
408
|
*/
|
|
354
|
-
onAccessCall(_data) {
|
|
355
|
-
}
|
|
409
|
+
onAccessCall(_data) { }
|
|
356
410
|
/**
|
|
357
411
|
* This event triggers for every call to the `if` function, which is used to implement the `if-then-else` control flow.
|
|
358
412
|
*
|
|
359
413
|
* @protected
|
|
360
414
|
*/
|
|
361
|
-
onIfThenElseCall(_data) {
|
|
362
|
-
}
|
|
415
|
+
onIfThenElseCall(_data) { }
|
|
363
416
|
/**
|
|
364
417
|
* This event triggers for every call to the `get` function, which is used to access variables in the global environment.
|
|
365
418
|
*
|
|
@@ -23,3 +23,7 @@ export declare function visitCfgInReverseOrder(graph: ControlFlowGraph, startNod
|
|
|
23
23
|
* @see {@link visitCfgInReverseOrder} for a traversal in reversed order
|
|
24
24
|
*/
|
|
25
25
|
export declare function visitCfgInOrder(graph: ControlFlowGraph, startNodes: readonly NodeId[], visitor: (node: NodeId) => boolean | void): void;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a node can reach another node in the control flow graph.
|
|
28
|
+
*/
|
|
29
|
+
export declare function canReach(graph: ControlFlowGraph, from: NodeId[], to: NodeId): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.visitCfgInReverseOrder = visitCfgInReverseOrder;
|
|
4
4
|
exports.visitCfgInOrder = visitCfgInOrder;
|
|
5
|
+
exports.canReach = canReach;
|
|
5
6
|
const control_flow_graph_1 = require("./control-flow-graph");
|
|
6
7
|
/**
|
|
7
8
|
* Visit all nodes reachable from the start node in the control flow graph, traversing the dependencies but ignoring cycles.
|
|
@@ -77,4 +78,17 @@ visitor) {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Check if a node can reach another node in the control flow graph.
|
|
83
|
+
*/
|
|
84
|
+
function canReach(graph, from, to) {
|
|
85
|
+
let reached = false;
|
|
86
|
+
visitCfgInOrder(graph, from, node => {
|
|
87
|
+
if (node === to) {
|
|
88
|
+
reached = true;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return reached;
|
|
93
|
+
}
|
|
80
94
|
//# sourceMappingURL=simple-visitor.js.map
|
|
@@ -25,7 +25,7 @@ import type { RNext } from '../r-bridge/lang-4.x/ast/model/nodes/r-next';
|
|
|
25
25
|
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
26
26
|
import type { RSymbol } from '../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
27
27
|
import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
28
|
-
export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo,
|
|
28
|
+
export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>> extends BasicCfgGuidedVisitorConfiguration<ControlFlow> {
|
|
29
29
|
readonly normalizedAst: Ast;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -33,7 +33,7 @@ export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, Cfg ext
|
|
|
33
33
|
*
|
|
34
34
|
* Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
|
|
35
35
|
*/
|
|
36
|
-
export declare class SyntaxAwareCfgGuidedVisitor<OtherInfo = NoInfo,
|
|
36
|
+
export declare class SyntaxAwareCfgGuidedVisitor<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Config extends SyntaxCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast> = SyntaxCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast>> extends BasicCfgGuidedVisitor<ControlFlow, Config> {
|
|
37
37
|
/**
|
|
38
38
|
* Get the normalized AST node for the given id or fail if it does not exist.
|
|
39
39
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PipelineStepName } from './steps/pipeline-step';
|
|
2
2
|
import { PipelineStepStage } from './steps/pipeline-step';
|
|
3
3
|
import type { Pipeline, PipelineInput, PipelineOutput, PipelinePerRequestInput, PipelineStepOutputWithName } from './steps/pipeline/pipeline';
|
|
4
|
+
import type { FlowrConfigOptions } from '../config';
|
|
4
5
|
/**
|
|
5
6
|
* The pipeline executor allows to execute arbitrary {@link Pipeline|pipelines} in a step-by-step fashion.
|
|
6
7
|
* If you are not yet in the possession of a {@link Pipeline|pipeline}, you can use the {@link createPipeline} function
|
|
@@ -91,6 +92,7 @@ export declare class PipelineExecutor<P extends Pipeline> {
|
|
|
91
92
|
private output;
|
|
92
93
|
private currentExecutionStage;
|
|
93
94
|
private stepCounter;
|
|
95
|
+
private readonly flowrConfig;
|
|
94
96
|
/**
|
|
95
97
|
* Construct a new pipeline executor.
|
|
96
98
|
* The required additional input is specified by the {@link IPipelineStep#requiredInput|required input configuration} of each step in the `pipeline`.
|
|
@@ -99,8 +101,9 @@ export declare class PipelineExecutor<P extends Pipeline> {
|
|
|
99
101
|
*
|
|
100
102
|
* @param pipeline - The {@link Pipeline} to execute, probably created with {@link createPipeline}.
|
|
101
103
|
* @param input - External {@link PipelineInput|configuration and input} required to execute the given pipeline.
|
|
104
|
+
* @param flowrConfig - The flowr config containing the built-in definitions
|
|
102
105
|
*/
|
|
103
|
-
constructor(pipeline: P, input: PipelineInput<P
|
|
106
|
+
constructor(pipeline: P, input: PipelineInput<P>, flowrConfig: FlowrConfigOptions);
|
|
104
107
|
/**
|
|
105
108
|
* Retrieve the {@link Pipeline|pipeline} that is currently being.
|
|
106
109
|
*/
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PipelineExecutor = void 0;
|
|
4
4
|
const assert_1 = require("../util/assert");
|
|
5
|
-
const config_1 = require("../config");
|
|
6
5
|
const built_in_1 = require("../dataflow/environments/built-in");
|
|
7
6
|
const built_in_config_1 = require("../dataflow/environments/built-in-config");
|
|
8
7
|
/**
|
|
@@ -95,6 +94,7 @@ class PipelineExecutor {
|
|
|
95
94
|
output = {};
|
|
96
95
|
currentExecutionStage = 0 /* PipelineStepStage.OncePerFile */;
|
|
97
96
|
stepCounter = 0;
|
|
97
|
+
flowrConfig;
|
|
98
98
|
/**
|
|
99
99
|
* Construct a new pipeline executor.
|
|
100
100
|
* The required additional input is specified by the {@link IPipelineStep#requiredInput|required input configuration} of each step in the `pipeline`.
|
|
@@ -103,13 +103,14 @@ class PipelineExecutor {
|
|
|
103
103
|
*
|
|
104
104
|
* @param pipeline - The {@link Pipeline} to execute, probably created with {@link createPipeline}.
|
|
105
105
|
* @param input - External {@link PipelineInput|configuration and input} required to execute the given pipeline.
|
|
106
|
+
* @param flowrConfig - The flowr config containing the built-in definitions
|
|
106
107
|
*/
|
|
107
|
-
constructor(pipeline, input) {
|
|
108
|
+
constructor(pipeline, input, flowrConfig) {
|
|
108
109
|
this.pipeline = pipeline;
|
|
109
110
|
this.length = pipeline.order.length;
|
|
110
111
|
this.input = input;
|
|
111
|
-
|
|
112
|
-
const builtIns =
|
|
112
|
+
this.flowrConfig = flowrConfig;
|
|
113
|
+
const builtIns = flowrConfig.semantics.environment.overwriteBuiltIns;
|
|
113
114
|
if (!builtIns.loadDefaults) {
|
|
114
115
|
built_in_1.BuiltInMemory.clear();
|
|
115
116
|
built_in_1.EmptyBuiltInMemory.clear();
|
|
@@ -190,7 +191,7 @@ class PipelineExecutor {
|
|
|
190
191
|
if (expectedStepName !== undefined) {
|
|
191
192
|
(0, assert_1.guard)(step.name === expectedStepName, () => `Cannot execute next step, expected step ${JSON.stringify(expectedStepName)} but got ${step.name}.`);
|
|
192
193
|
}
|
|
193
|
-
return [step.name, step.processor(this.output, this.input)];
|
|
194
|
+
return [step.name, step.processor(this.output, this.input, this.flowrConfig)];
|
|
194
195
|
}
|
|
195
196
|
/**
|
|
196
197
|
* This only makes sense if you have already run a request and want to re-use the per-file results for a new one.
|
|
@@ -9,6 +9,8 @@ export interface NormalizeRequiredInput {
|
|
|
9
9
|
/** This id generator is only necessary if you want to retrieve a dataflow from the parsed R AST, it determines the id generator to use and by default uses the {@link deterministicCountingIdGenerator}*/
|
|
10
10
|
readonly getId?: IdGenerator<NoInfo>;
|
|
11
11
|
readonly request: RParseRequests;
|
|
12
|
+
/** assume the input stems from a file and use the given path as the file path for the AST */
|
|
13
|
+
readonly overwriteFilePath?: string;
|
|
12
14
|
}
|
|
13
15
|
export declare function getCurrentRequestFile(request: RParseRequests | undefined): string | undefined;
|
|
14
16
|
declare function processor(results: {
|
|
@@ -17,7 +17,7 @@ function getCurrentRequestFile(request) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function processor(results, input) {
|
|
20
|
-
return (0, parser_1.normalize)(results.parse, input.getId, getCurrentRequestFile(input.request));
|
|
20
|
+
return (0, parser_1.normalize)(results.parse, input.getId, input.overwriteFilePath ?? getCurrentRequestFile(input.request));
|
|
21
21
|
}
|
|
22
22
|
exports.NORMALIZE = {
|
|
23
23
|
name: 'normalize',
|
|
@@ -3,9 +3,10 @@ import { normalizedAstToJson, normalizedAstToQuads, printNormalizedAstToMermaid,
|
|
|
3
3
|
import { PipelineStepStage } from '../../pipeline-step';
|
|
4
4
|
import type { NormalizeRequiredInput } from './10-normalize';
|
|
5
5
|
import type { ParseStepOutputTS } from './01-parse-tree-sitter';
|
|
6
|
+
import type { FlowrConfigOptions } from '../../../../config';
|
|
6
7
|
declare function processor(results: {
|
|
7
8
|
'parse'?: ParseStepOutputTS;
|
|
8
|
-
}, input: Partial<NormalizeRequiredInput
|
|
9
|
+
}, input: Partial<NormalizeRequiredInput>, config: FlowrConfigOptions): import("../../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../../r-bridge/lang-4.x/ast/model/model").RNode<import("../../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
|
|
9
10
|
export declare const NORMALIZE_TREE_SITTER: {
|
|
10
11
|
readonly name: "normalize";
|
|
11
12
|
readonly humanReadableName: "normalize tree-sitter tree";
|
|
@@ -5,8 +5,8 @@ const print_1 = require("../../../print/print");
|
|
|
5
5
|
const normalize_printer_1 = require("../../../print/normalize-printer");
|
|
6
6
|
const parser_1 = require("../../../../r-bridge/lang-4.x/ast/parser/json/parser");
|
|
7
7
|
const _10_normalize_1 = require("./10-normalize");
|
|
8
|
-
function processor(results, input) {
|
|
9
|
-
return (0, parser_1.normalizeTreeSitter)(results['parse'], input.getId, (0, _10_normalize_1.getCurrentRequestFile)(input.request));
|
|
8
|
+
function processor(results, input, config) {
|
|
9
|
+
return (0, parser_1.normalizeTreeSitter)(results['parse'], input.getId, config, input.overwriteFilePath ?? (0, _10_normalize_1.getCurrentRequestFile)(input.request));
|
|
10
10
|
}
|
|
11
11
|
exports.NORMALIZE_TREE_SITTER = {
|
|
12
12
|
name: 'normalize',
|
|
@@ -4,12 +4,13 @@ import { dataflowGraphToJson, dataflowGraphToMermaid, dataflowGraphToMermaidUrl,
|
|
|
4
4
|
import type { NormalizedAst } from '../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
5
|
import type { RParseRequests } from '../../../../r-bridge/retriever';
|
|
6
6
|
import type { KnownParserType, Parser } from '../../../../r-bridge/parser';
|
|
7
|
+
import type { FlowrConfigOptions } from '../../../../config';
|
|
7
8
|
declare function processor(results: {
|
|
8
9
|
normalize?: NormalizedAst;
|
|
9
10
|
}, input: {
|
|
10
11
|
request?: RParseRequests;
|
|
11
12
|
parser?: Parser<KnownParserType>;
|
|
12
|
-
}): import("../../../../dataflow/info").DataflowInformation;
|
|
13
|
+
}, config: FlowrConfigOptions): import("../../../../dataflow/info").DataflowInformation;
|
|
13
14
|
export declare const STATIC_DATAFLOW: {
|
|
14
15
|
readonly humanReadableName: "dataflow";
|
|
15
16
|
readonly processor: typeof processor;
|
|
@@ -17,8 +17,8 @@ const staticDataflowCommon = {
|
|
|
17
17
|
},
|
|
18
18
|
dependencies: ['normalize'],
|
|
19
19
|
};
|
|
20
|
-
function processor(results, input) {
|
|
21
|
-
return (0, extractor_1.produceDataFlowGraph)(input.parser, input.request, results.normalize);
|
|
20
|
+
function processor(results, input, config) {
|
|
21
|
+
return (0, extractor_1.produceDataFlowGraph)(input.parser, input.request, results.normalize, config);
|
|
22
22
|
}
|
|
23
23
|
exports.STATIC_DATAFLOW = {
|
|
24
24
|
...staticDataflowCommon,
|
|
@@ -3,6 +3,7 @@ import { PipelineStepStage } from '../../pipeline-step';
|
|
|
3
3
|
import type { DataflowInformation } from '../../../../dataflow/info';
|
|
4
4
|
import type { SlicingCriteria } from '../../../../slicing/criterion/parse';
|
|
5
5
|
import type { NormalizedAst } from '../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
|
+
import type { FlowrConfigOptions } from '../../../../config';
|
|
6
7
|
export interface SliceRequiredInput {
|
|
7
8
|
/** The slicing criterion is only of interest if you actually want to slice the R code */
|
|
8
9
|
readonly criterion: SlicingCriteria;
|
|
@@ -12,7 +13,7 @@ export interface SliceRequiredInput {
|
|
|
12
13
|
declare function processor(results: {
|
|
13
14
|
dataflow?: DataflowInformation;
|
|
14
15
|
normalize?: NormalizedAst;
|
|
15
|
-
}, input: Partial<SliceRequiredInput
|
|
16
|
+
}, input: Partial<SliceRequiredInput>, config: FlowrConfigOptions): Readonly<import("../../../../slicing/static/slicer-types").SliceResult>;
|
|
16
17
|
export declare const STATIC_SLICE: {
|
|
17
18
|
readonly name: "slice";
|
|
18
19
|
readonly humanReadableName: "static slice";
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.STATIC_SLICE = void 0;
|
|
4
4
|
const print_1 = require("../../../print/print");
|
|
5
5
|
const static_slicer_1 = require("../../../../slicing/static/static-slicer");
|
|
6
|
-
function processor(results, input) {
|
|
7
|
-
return (0, static_slicer_1.staticSlicing)(results.dataflow.graph, results.normalize, input.criterion, input.threshold);
|
|
6
|
+
function processor(results, input, config) {
|
|
7
|
+
return (0, static_slicer_1.staticSlicing)(results.dataflow.graph, results.normalize, input.criterion, input.threshold ?? config.solver.slicer?.threshold);
|
|
8
8
|
}
|
|
9
9
|
exports.STATIC_SLICE = {
|
|
10
10
|
name: 'slice',
|