@eagleoutice/flowr 2.10.9 → 2.10.10
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 +103 -33
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/script.js +3 -2
- package/cli/flowr.js +47 -10
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +25 -0
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/statistics-core.js +2 -1
- package/cli/script-core/statistics-helper-core.js +2 -1
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +4 -1
- package/config.d.ts +9 -10
- package/config.js +25 -7
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/dataflow/environments/append.d.ts +2 -1
- package/dataflow/environments/append.js +2 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +122 -66
- package/dataflow/environments/default-builtin-config.js +324 -145
- package/dataflow/environments/environment.d.ts +2 -1
- package/dataflow/environments/environment.js +13 -9
- package/dataflow/environments/identifier.d.ts +55 -2
- package/dataflow/environments/identifier.js +14 -2
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.js +13 -7
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +12 -2
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +33 -0
- package/dataflow/graph/graph.js +1 -1
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +75 -57
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +119 -31
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +77 -76
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +19 -6
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +14 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +3 -3
- package/documentation/wiki-query.js +85 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +88 -86
- package/linter/linter-rules.js +7 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +6 -4
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +3 -2
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-files-context.d.ts +12 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +3 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +7 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- 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.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +600 -0
- package/search/search-executor/search-enrichers.js +23 -2
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/objects.d.ts +9 -0
- package/util/objects.js +54 -0
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +1 -1
|
@@ -44,7 +44,7 @@ const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
|
44
44
|
const range_1 = require("../util/range");
|
|
45
45
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
46
46
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
47
|
-
async function subExplanation(parser, { description, code, expectedSubgraph }) {
|
|
47
|
+
async function subExplanation(parser, ctx, { description, code, expectedSubgraph }) {
|
|
48
48
|
expectedSubgraph = await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
|
|
49
49
|
const marks = [];
|
|
50
50
|
for (const [id] of expectedSubgraph.vertices(true)) {
|
|
@@ -56,11 +56,11 @@ async function subExplanation(parser, { description, code, expectedSubgraph }) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return `
|
|
59
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set(marks) })}
|
|
59
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set(marks), ctx })}
|
|
60
60
|
|
|
61
61
|
${description}`;
|
|
62
62
|
}
|
|
63
|
-
async function printAllSubExplanations(parser, expls) {
|
|
63
|
+
async function printAllSubExplanations(parser, ctx, expls) {
|
|
64
64
|
let result = `
|
|
65
65
|
<details>
|
|
66
66
|
|
|
@@ -69,11 +69,11 @@ async function printAllSubExplanations(parser, expls) {
|
|
|
69
69
|
`;
|
|
70
70
|
for (const sub of expls) {
|
|
71
71
|
result += `#### ${sub.name}\n`;
|
|
72
|
-
result += await subExplanation(parser, sub) + '\n';
|
|
72
|
+
result += await subExplanation(parser, ctx, sub) + '\n';
|
|
73
73
|
}
|
|
74
74
|
return result + '\n\n</details>';
|
|
75
75
|
}
|
|
76
|
-
async function explanation({ name, type, description, code, expectedSubgraph }, parser, index, ...subExplanations) {
|
|
76
|
+
async function explanation({ name, type, description, code, expectedSubgraph }, parser, ctx, index, ...subExplanations) {
|
|
77
77
|
await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
|
|
78
78
|
return `
|
|
79
79
|
<a id='${name.toLowerCase().replaceAll(' ', '-')}'> </a>
|
|
@@ -82,9 +82,9 @@ async function explanation({ name, type, description, code, expectedSubgraph },
|
|
|
82
82
|
|
|
83
83
|
Type: \`${type}\` (this is the bit-flag value, e.g., when looking at the serialization)
|
|
84
84
|
|
|
85
|
-
${await subExplanation(parser, { name, description, code, expectedSubgraph })}
|
|
85
|
+
${await subExplanation(parser, ctx, { name, description, code, expectedSubgraph })}
|
|
86
86
|
|
|
87
|
-
${subExplanations.length > 0 ? await printAllSubExplanations(parser, subExplanations) : ''}
|
|
87
|
+
${subExplanations.length > 0 ? await printAllSubExplanations(parser, ctx, subExplanations) : ''}
|
|
88
88
|
`;
|
|
89
89
|
}
|
|
90
90
|
function edgeTypeToId(edgeType) {
|
|
@@ -109,7 +109,7 @@ ${(0, doc_structure_1.block)({
|
|
|
109
109
|
type: 'NOTE',
|
|
110
110
|
content: `
|
|
111
111
|
The value is not stored in the vertex itself, but in the normalized AST.
|
|
112
|
-
To access the value, you can use the \`id\` of the vertex to access the respective node in the
|
|
112
|
+
To access the value, you can use the \`id\` of the vertex to access the respective node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}
|
|
113
113
|
and ask for the value associated with it.
|
|
114
114
|
`
|
|
115
115
|
})}
|
|
@@ -117,8 +117,8 @@ and ask for the value associated with it.
|
|
|
117
117
|
Please be aware that such nodes may be the result from language semantics as well, and not just from constants directly in the source.
|
|
118
118
|
For example, an access operation like \`df$column\` will treat the column name as a constant value.
|
|
119
119
|
|
|
120
|
-
${(0, doc_structure_1.details)('Example: Semantics Create a Value', `In the following graph, the original type printed by mermaid is still \`RSymbol\` (from the
|
|
121
|
-
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'df$column', { mark: new Set([1]) }))}
|
|
120
|
+
${(0, doc_structure_1.details)('Example: Semantics Create a Value', `In the following graph, the original type printed by mermaid is still \`RSymbol\` (from the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}), however, the shape of the vertex signals to you that the symbol is in-fact treated as a constant! If you do not know what \`df$column\` even means, please refer to the [R topic](https://rdrr.io/r/base/Extract.html).\n` +
|
|
121
|
+
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'df$column', { mark: new Set([1]), ctx }))}
|
|
122
122
|
`,
|
|
123
123
|
code: '42',
|
|
124
124
|
expectedSubgraph: (0, dataflowgraph_builder_1.emptyGraph)().constant('0')
|
|
@@ -149,29 +149,29 @@ Most often, you will see the _use_ vertex whenever a variable is read.
|
|
|
149
149
|
However, similar to the [value vertex](#value-vertex), the _use_ vertex can also be the result of language semantics.
|
|
150
150
|
Consider a case, in which we refer to a variable with a string, as in \`get("x")\`.
|
|
151
151
|
|
|
152
|
-
${(0, doc_structure_1.details)('Example: Semantics Create a Symbol', `In the following graph, the original type printed by mermaid is still \`RString\` (from the
|
|
152
|
+
${(0, doc_structure_1.details)('Example: Semantics Create a Symbol', `In the following graph, the original type printed by mermaid is still \`RString\` (from the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}), however, the shape of the vertex signals to you that the symbol is in-fact treated as a variable use! ` +
|
|
153
153
|
'If you are unsure what `get` does, refer to the [documentation](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/get). ' +
|
|
154
154
|
'Please note, that the lexeme being printed as `"x"` may be misleading (after all it is recovered from the AST), the quotes are not part of the reference.\n' +
|
|
155
|
-
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'get("x")', { mark: new Set([1]) }))}
|
|
155
|
+
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'get("x")', { mark: new Set([1]), ctx }))}
|
|
156
156
|
|
|
157
157
|
But now to the interesting stuff: how do we actually know which values are read by the respective variable use?
|
|
158
158
|
This usually involves a [variable definition](#variable-definition-vertex) and a [reads edge](#reads-edge) linking the two.
|
|
159
159
|
|
|
160
160
|
${(0, doc_structure_1.details)('Example: Reads Edge Identifying a Single Definition', 'In the following graph, the `x` is read from the definition `x <- 1`.\n' +
|
|
161
|
-
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nprint(x)', { mark: new Set([3, '0->3']), codeOpen: true }))}
|
|
161
|
+
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nprint(x)', { mark: new Set([3, '0->3']), codeOpen: true, ctx }))}
|
|
162
162
|
|
|
163
163
|
In general, there may be many such edges, identifying every possible definition of the variable.
|
|
164
164
|
|
|
165
|
-
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (conditional)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nif(u) x <- 2\nprint(x)', { mark: new Set([10, '10->0', '10->4']), codeOpen: true }))}
|
|
166
|
-
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (loop)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nfor(i in v) x <- 2\nprint(x)', { mark: new Set([11, '11->0', '11->5']), codeOpen: true }))}
|
|
167
|
-
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (side-effect)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 2\nx <- 2\nif(u) f()\nprint(x)', { mark: new Set([16, '16->1', '16->7']), codeOpen: true }))}
|
|
165
|
+
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (conditional)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nif(u) x <- 2\nprint(x)', { mark: new Set([10, '10->0', '10->4']), codeOpen: true, ctx }))}
|
|
166
|
+
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (loop)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nfor(i in v) x <- 2\nprint(x)', { mark: new Set([11, '11->0', '11->5']), codeOpen: true, ctx }))}
|
|
167
|
+
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (side-effect)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 2\nx <- 2\nif(u) f()\nprint(x)', { mark: new Set([16, '16->1', '16->7']), codeOpen: true, ctx }))}
|
|
168
168
|
|
|
169
169
|
${(0, doc_structure_1.block)({
|
|
170
170
|
type: 'IMPORTANT',
|
|
171
171
|
content: `
|
|
172
172
|
If you want to obtain the locations where a variable is defined, or read, or re-defined, refrain from tracking these details manually in the dataflow graph
|
|
173
173
|
as there are some edge-cases that require special attention.
|
|
174
|
-
In general, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} (which is also available as ${ctx.linkO(df_helper_1.Dataflow, 'origin')}) function explained below in
|
|
174
|
+
In general, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} (which is also available as ${ctx.linkO(df_helper_1.Dataflow, 'origin')}) function explained below in ${ctx.linkPage('wiki/Dataflow Graph', 'working with the dataflow graph', 'dfg-working')} will help you to get the information you need.
|
|
175
175
|
`
|
|
176
176
|
})}
|
|
177
177
|
|
|
@@ -202,7 +202,7 @@ However, in general, flowR may use any fitting handler as an origin (see the ${c
|
|
|
202
202
|
|
|
203
203
|
${(0, doc_structure_1.details)('Example: Simple Function Call (unresolved)', await (async () => {
|
|
204
204
|
const code = 'foo(x,3,y=3,)';
|
|
205
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([8]), exposeResult: true });
|
|
205
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([8]), exposeResult: true, ctx });
|
|
206
206
|
const callInfo = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionCall && identifier_1.Identifier.getName(vertex.name) === 'foo');
|
|
207
207
|
(0, assert_1.guard)(callInfo !== undefined, () => `Could not find call vertex for ${code}`);
|
|
208
208
|
const [callId, callVert] = callInfo;
|
|
@@ -246,14 +246,14 @@ ${(0, doc_structure_1.block)({
|
|
|
246
246
|
content: `
|
|
247
247
|
But how do you know which definitions are actually called by the function?
|
|
248
248
|
|
|
249
|
-
So first of all, some frontends of _flowR_ (like the ${(0, doc_cli_option_1.getReplCommand)('slicer')} and ${(0, doc_cli_option_1.getReplCommand)('query')} with the
|
|
249
|
+
So first of all, some frontends of _flowR_ (like the ${(0, doc_cli_option_1.getReplCommand)('slicer')} and ${(0, doc_cli_option_1.getReplCommand)('query')} with the ${ctx.linkPage('wiki/Query API', 'Query API')}) already provide you with this information.
|
|
250
250
|
In general there are three scenarios you may be interested in:
|
|
251
251
|
|
|
252
252
|
${(0, doc_structure_1.details)('1) the function resolves only to builtin definitions (like <code><-</code>)', `
|
|
253
253
|
|
|
254
254
|
Let's have a look at a simple assignment:
|
|
255
255
|
|
|
256
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2')}
|
|
256
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2', { ctx })}
|
|
257
257
|
|
|
258
258
|
In this case, the call does not have a single ${linkEdgeName(edge_1.EdgeType.Calls)} edge, which in general means (i.e., if the analysis is done and you are not looking at an intermediate result) it is bound to anything
|
|
259
259
|
global beyond the scope of the given script. _flowR_ generally (theoretically at least) does not know if the call really refers to a built-in variable or function,
|
|
@@ -268,7 +268,7 @@ Let's have a look at a call to a function named \`foo\` which is defined in the
|
|
|
268
268
|
|
|
269
269
|
${await (async () => {
|
|
270
270
|
const code = 'foo <- function() 3\nfoo()';
|
|
271
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { exposeResult: true, mark: new Set([6, '6->0', '6->1', '6->3']) });
|
|
271
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { exposeResult: true, mark: new Set([6, '6->0', '6->1', '6->3']), ctx });
|
|
272
272
|
const numberOfEdges = [...info.dataflow.graph.edges()].flatMap(e => [...e[1].keys()]).length;
|
|
273
273
|
const callVertex = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionCall && identifier_1.Identifier.getName(vertex.name) === 'foo');
|
|
274
274
|
(0, assert_1.guard)(callVertex !== undefined, () => `Could not find call vertex for ${code}`);
|
|
@@ -283,7 +283,7 @@ While it seems to be somewhat redundant given the ${linkEdgeName(edge_1.EdgeType
|
|
|
283
283
|
you have to consider cases in which aliases are involved in the call resolution (e.g., with higher order functions).
|
|
284
284
|
|
|
285
285
|
${(0, doc_structure_1.details)('Example: Alias in Call Resolution', `In the following example, \`g\` ${linkEdgeName(edge_1.EdgeType.Reads)} the previous definition, but ${linkEdgeName(edge_1.EdgeType.Calls)} the function assigned to \`f\`.\n`
|
|
286
|
-
+ await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() 3\ng <- f\ng()', { mark: new Set(['9', '9->5', '9->3']) }))}
|
|
286
|
+
+ await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() 3\ng <- f\ng()', { mark: new Set(['9', '9->5', '9->3']), ctx }))}
|
|
287
287
|
|
|
288
288
|
Lastly, the ${linkEdgeName(edge_1.EdgeType.Returns)} edge links the call to the return vertices(s) of the function.
|
|
289
289
|
Please be aware, that these multiple exit points may be counter intuitive as they often appear with a nested call (usually a call to the built-in \`{\` function).
|
|
@@ -294,7 +294,7 @@ f <- function() {
|
|
|
294
294
|
if(v) return(2)
|
|
295
295
|
1
|
|
296
296
|
}
|
|
297
|
-
f()`.trim(), { mark: new Set([22, '22->18']) }) +
|
|
297
|
+
f()`.trim(), { mark: new Set([22, '22->18']), ctx }) +
|
|
298
298
|
`
|
|
299
299
|
In this case the call of \`f\` still only has one ${linkEdgeName(edge_1.EdgeType.Returns)} edge, although the function _looks_ as if it would have multiple exit points!
|
|
300
300
|
But you have to beware that \`{\` is a function call as well (see below) and it may be redefined, or at least affect the actual returns of the function.
|
|
@@ -315,7 +315,7 @@ Users may write… interesting pieces of code - for reasons we should not be int
|
|
|
315
315
|
Consider a case in which you have a built-in function (like the assignment operator \`<-\`) and a user that wants to redefine the meaning of the function call _sometimes_:
|
|
316
316
|
|
|
317
317
|
${await (async () => {
|
|
318
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2\nif(u) `<-` <- `*`\nx <- 3', { switchCodeAndGraph: true, mark: new Set([9, '9->0', '9->10']), exposeResult: true });
|
|
318
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2\nif(u) `<-` <- `*`\nx <- 3', { switchCodeAndGraph: true, mark: new Set([9, '9->0', '9->10']), exposeResult: true, ctx });
|
|
319
319
|
const interestingUseOfAssignment = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.id === 11);
|
|
320
320
|
(0, assert_1.guard)(interestingUseOfAssignment !== undefined, () => 'Could not find interesting assignment vertex for the code');
|
|
321
321
|
const [id, interestingVertex] = interestingUseOfAssignment;
|
|
@@ -350,18 +350,18 @@ Similarly, trying to resolve the name with ${ctx.link(resolve_by_name_1.resolveB
|
|
|
350
350
|
|
|
351
351
|
|
|
352
352
|
Similar to finding the definitions read by a variable use, please use the ${ctx.link(linker_1.getAllFunctionCallTargets)} function to find all possible definitions of a function call,
|
|
353
|
-
as explained in the
|
|
353
|
+
as explained in the ${ctx.linkPage('wiki/Dataflow Graph', 'working with the dataflow graph', 'dfg-working')} section.`
|
|
354
354
|
})}
|
|
355
355
|
|
|
356
356
|
Function calls are the most complicated mechanism in R as essentially everything is a function call.
|
|
357
357
|
Even **control structures** like \`if(p) a else b\` are desugared into function calls (e.g., as \`\` \`if\`(p, a, b) \`\`).
|
|
358
|
-
${(0, doc_structure_1.details)('Example: <code>if</code> as a Function Call', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'if(p) a else b'))}
|
|
358
|
+
${(0, doc_structure_1.details)('Example: <code>if</code> as a Function Call', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'if(p) a else b', { ctx }))}
|
|
359
359
|
|
|
360
360
|
Similarly, you should be aware of calls to **anonymous functions**, which may appear given directly (e.g. as \`(function() 1)()\`) or indirectly, with code
|
|
361
361
|
directly calling the return of another function call: \`foo()()\`.
|
|
362
|
-
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given directly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, '(function() 1)()', { mark: new Set([6, '6->4']) }))}
|
|
362
|
+
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given directly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, '(function() 1)()', { mark: new Set([6, '6->4']), ctx }))}
|
|
363
363
|
|
|
364
|
-
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given indirectly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'foo <- function() return(function() 3)\nfoo()()', { mark: new Set([12, '12->4']) }))}
|
|
364
|
+
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given indirectly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'foo <- function() return(function() 3)\nfoo()()', { mark: new Set([12, '12->4']), ctx }))}
|
|
365
365
|
|
|
366
366
|
${(0, doc_structure_1.block)({
|
|
367
367
|
type: 'NOTE',
|
|
@@ -372,7 +372,7 @@ But in short: the \`origin\` attribute of the ${ctx.link('DataflowGraphVertexFun
|
|
|
372
372
|
Please be aware that unnamed functions still have a \`name\` property to give it a unique identifier that can be used for debugging and reference.
|
|
373
373
|
This name _always_ starts with \`${unnamed_call_handling_1.UnnamedFunctionCallPrefix}\`.
|
|
374
374
|
|
|
375
|
-
To identify these calls please do not rely on the
|
|
375
|
+
To identify these calls please do not rely on the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}. An expression like \`1 + 1\` will be correctly
|
|
376
376
|
identified as a syntactical binary operation. Yet, from a dataflow/semantic perspective this is equivalent to \`\` \`+\`(1, 1) \`\` (which is a named function call and marked as such in the dataflow graph).
|
|
377
377
|
To know which function is called, please rely on the ${linkEdgeName(edge_1.EdgeType.Calls)} edge.
|
|
378
378
|
`
|
|
@@ -380,7 +380,7 @@ To know which function is called, please rely on the ${linkEdgeName(edge_1.EdgeT
|
|
|
380
380
|
|
|
381
381
|
Another interesting case is a function with **side effects**, most prominently with the super-assignment \`<<-\`.
|
|
382
382
|
In this case, you may encounter the ${linkEdgeName(edge_1.EdgeType.SideEffectOnCall)} as exemplified below.
|
|
383
|
-
${(0, doc_structure_1.details)('Example: Function Call with a Side-Effect', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 3\n f()', { mark: new Set([8, '1->8']) }))}
|
|
383
|
+
${(0, doc_structure_1.details)('Example: Function Call with a Side-Effect', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 3\n f()', { mark: new Set([8, '1->8']), ctx }))}
|
|
384
384
|
|
|
385
385
|
`,
|
|
386
386
|
code: 'foo()',
|
|
@@ -392,7 +392,7 @@ ${(0, doc_structure_1.details)('Example: Function Call with a Side-Effect', awai
|
|
|
392
392
|
description: `
|
|
393
393
|
Defined variables most commonly occur in the context of an assignment, for example, with the \`<-\` operator as shown above.
|
|
394
394
|
|
|
395
|
-
${(0, doc_structure_1.details)('Example: Super Definition (<code><<-</code>)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <<- 1', { mark: new Set([0]) }))}
|
|
395
|
+
${(0, doc_structure_1.details)('Example: Super Definition (<code><<-</code>)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <<- 1', { mark: new Set([0]), ctx }))}
|
|
396
396
|
|
|
397
397
|
The implementation is relatively sparse and similar to the other marker vertices:
|
|
398
398
|
|
|
@@ -401,18 +401,18 @@ Of only interest is \`par\`, which signals that the definitions is partial (e.g.
|
|
|
401
401
|
|
|
402
402
|
Of course, there are not just operators that define variables, but also functions, like \`assign\`.
|
|
403
403
|
|
|
404
|
-
${(0, doc_structure_1.details)('Example: Using <code>assign</code>', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'assign("x", 1)\nx', { mark: new Set([1]) })
|
|
404
|
+
${(0, doc_structure_1.details)('Example: Using <code>assign</code>', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'assign("x", 1)\nx', { mark: new Set([1]), ctx })
|
|
405
405
|
+ `\nThe example may be misleading as the visualization uses \`${node_id_1.recoverName.name}\` to print the lexeme of the variable. However, this actually defines the variable \`x\` (without the quotes) as you can see with the ${linkEdgeName(edge_1.EdgeType.Reads)} edge.`)}
|
|
406
406
|
|
|
407
407
|
Please be aware, that the name of the symbol defined may differ from what you read in the program as R allows the assignments to strings, escaped names, and more:
|
|
408
408
|
|
|
409
|
-
${(0, doc_structure_1.details)('Example: Assigning with an Escaped Name', await (0, doc_dfg_1.printDfGraphForCode)(parser, '`x` <- 1\nx', { mark: new Set([0]) }))}
|
|
410
|
-
${(0, doc_structure_1.details)('Example: Assigning with a String', await (0, doc_dfg_1.printDfGraphForCode)(parser, '"x" <- 1\nx', { mark: new Set([0]) }))}
|
|
409
|
+
${(0, doc_structure_1.details)('Example: Assigning with an Escaped Name', await (0, doc_dfg_1.printDfGraphForCode)(parser, '`x` <- 1\nx', { mark: new Set([0]), ctx }))}
|
|
410
|
+
${(0, doc_structure_1.details)('Example: Assigning with a String', await (0, doc_dfg_1.printDfGraphForCode)(parser, '"x" <- 1\nx', { mark: new Set([0]), ctx }))}
|
|
411
411
|
|
|
412
412
|
Definitions may be constrained by conditionals (_flowR_ takes care of calculating the dominating front for you).
|
|
413
413
|
|
|
414
414
|
${(0, doc_structure_1.details)('Conditional Assignments', await (async () => {
|
|
415
|
-
const constrainedDefinitions = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 0\nif(u) x <- 1 else x <- 2\nx', { exposeResult: true });
|
|
415
|
+
const constrainedDefinitions = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 0\nif(u) x <- 1 else x <- 2\nx', { exposeResult: true, ctx });
|
|
416
416
|
const [text, info] = constrainedDefinitions;
|
|
417
417
|
const finalEnvironment = (0, doc_env_1.printEnvironmentToMarkdown)(info.dataflow.environment.current);
|
|
418
418
|
return `
|
|
@@ -456,7 +456,7 @@ the actual dataflow graph is flat, and you can query all root vertices (i.e., th
|
|
|
456
456
|
vertices of function definitions or not (e.g., \`${new graph_1.DataflowGraph(undefined).vertices.name}\`)
|
|
457
457
|
|
|
458
458
|
${(0, doc_structure_1.details)('Example: Nested Function Definitions', await (async () => {
|
|
459
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() { g <- function() 3 }', { mark: new Set([9, 6]), exposeResult: true });
|
|
459
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() { g <- function() 3 }', { mark: new Set([9, 6]), exposeResult: true, ctx });
|
|
460
460
|
const definitions = info.dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
|
|
461
461
|
.map(([id, vertex]) => `| \`${id}\` | { \`${[...vertex.subflow.graph].join('`, `')}\` } |`)
|
|
462
462
|
.toArray();
|
|
@@ -474,12 +474,12 @@ ${definitions.join('\n')}
|
|
|
474
474
|
|
|
475
475
|
But now there is still an open question: how do you know which vertices are the parameters?
|
|
476
476
|
In short: there is no direct way to infer this from the dataflow graph (as parameters are handled as open references which are promises).
|
|
477
|
-
However, you can use the
|
|
477
|
+
However, you can use the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} to get the parameters used.
|
|
478
478
|
|
|
479
479
|
${(0, doc_structure_1.details)('Example: Parameters of a Function', await (async () => {
|
|
480
480
|
const code = 'f <- function(x, y = 3) x + y';
|
|
481
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([10, 1, 3]), exposeResult: true });
|
|
482
|
-
const ast = await (0, doc_normalized_ast_1.printNormalizedAstForCode)(parser, code, { prefix: 'flowchart LR\n', showCode: false });
|
|
481
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([10, 1, 3]), exposeResult: true, ctx });
|
|
482
|
+
const ast = await (0, doc_normalized_ast_1.printNormalizedAstForCode)(parser, code, { prefix: 'flowchart LR\n', showCode: false, ctx });
|
|
483
483
|
const functionDefinition = [...info.dataflow.graph.vertices(true)].find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionDefinition);
|
|
484
484
|
(0, assert_1.guard)(functionDefinition !== undefined, () => `Could not find function definition for ${code}`);
|
|
485
485
|
const [id] = functionDefinition;
|
|
@@ -489,7 +489,7 @@ Let's first consider the following dataflow graph (of \`${code}\`):
|
|
|
489
489
|
|
|
490
490
|
${text}
|
|
491
491
|
|
|
492
|
-
The function definition we are interested in has the id \`${id}\`. Looking at the
|
|
492
|
+
The function definition we are interested in has the id \`${id}\`. Looking at the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} of the code,
|
|
493
493
|
we can get the parameters simply be requesting the \`parameters\` property of the function definition (yielding the names: [${normalized.parameters.map(p => `\`${p.name.content}\``).join(', ')}]):
|
|
494
494
|
|
|
495
495
|
${ast}
|
|
@@ -500,7 +500,7 @@ ${ast}
|
|
|
500
500
|
|
|
501
501
|
Last but not least, please keep in mind that R offers another way of writing anonymous functions (using the backslash):
|
|
502
502
|
|
|
503
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(parser, '\\(x) x + 1', { switchCodeAndGraph: true })}
|
|
503
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, '\\(x) x + 1', { switchCodeAndGraph: true, ctx })}
|
|
504
504
|
|
|
505
505
|
Besides this being a theoretically "shorter" way of defining a function, this behaves similarly to the use of \`function\`.
|
|
506
506
|
|
|
@@ -514,7 +514,7 @@ Besides this being a theoretically "shorter" way of defining a function, this be
|
|
|
514
514
|
const get = vertexExplanations.get(vertex);
|
|
515
515
|
(0, assert_1.guard)(get !== undefined, () => `No explanation for vertex type ${vertex}`);
|
|
516
516
|
const [expl, subExplanations] = get;
|
|
517
|
-
results.push(await explanation(expl, parser, ++i, ...subExplanations));
|
|
517
|
+
results.push(await explanation(expl, parser, ctx, ++i, ...subExplanations));
|
|
518
518
|
}
|
|
519
519
|
return results.join('\n');
|
|
520
520
|
}
|
|
@@ -533,13 +533,13 @@ A ${linkEdgeName(edge_1.EdgeType.Reads)} edge is not a transitive closure and on
|
|
|
533
533
|
Our abstract domains resolving transitive ${linkEdgeName(edge_1.EdgeType.Reads)} edges (and for that matter, following ${linkEdgeName(edge_1.EdgeType.Returns)} as well)
|
|
534
534
|
are currently tailored to what we need in _flowR_. Hence, we offer a function like ${ctx.link(linker_1.getAllFunctionCallTargets)},
|
|
535
535
|
as well as ${ctx.link(resolve_by_name_1.resolvesToBuiltInConstant)} which do this for specific cases.
|
|
536
|
-
Refer to ${ctx.link(dfg_get_origin_1.getOriginInDfg)} for a more general solution, as explained in
|
|
536
|
+
Refer to ${ctx.link(dfg_get_origin_1.getOriginInDfg)} for a more general solution, as explained in ${ctx.linkPage('wiki/Dataflow Graph', 'working with the dataflow graph', 'dfg-working')}.
|
|
537
537
|
|
|
538
|
-
${(0, doc_structure_1.details)('Example: Multi-Level Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 3\ny <- x\nprint(y)', { mark: new Set(['9->7', '7->3', '4->0']) }))}
|
|
538
|
+
${(0, doc_structure_1.details)('Example: Multi-Level Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 3\ny <- x\nprint(y)', { mark: new Set(['9->7', '7->3', '4->0']), ctx }))}
|
|
539
539
|
|
|
540
540
|
Similarly, ${linkEdgeName(edge_1.EdgeType.Reads)} can be cyclic, for example in the context of loops:
|
|
541
541
|
|
|
542
|
-
${(0, doc_structure_1.details)('Example: Cyclic Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) x <- x + 1', { mark: new Set(['3->2']) }))}
|
|
542
|
+
${(0, doc_structure_1.details)('Example: Cyclic Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) x <- x + 1', { mark: new Set(['3->2']), ctx }))}
|
|
543
543
|
`
|
|
544
544
|
})}
|
|
545
545
|
|
|
@@ -567,7 +567,7 @@ Please refer to the explanation of the respective vertices for more information.
|
|
|
567
567
|
type: edge_1.EdgeType.DefinedBy,
|
|
568
568
|
description: `
|
|
569
569
|
The source vertex is usually a [\`variable definition\`](#variable-definition-vertex) linking the defined symbol to the entry point of the resulting side.
|
|
570
|
-
${(0, doc_structure_1.details)('In general, this does not have to be the right hand side of the operator.', await (0, doc_dfg_1.printDfGraphForCode)(parser, '3 -> x', { mark: new Set([0]) }))}
|
|
570
|
+
${(0, doc_structure_1.details)('In general, this does not have to be the right hand side of the operator.', await (0, doc_dfg_1.printDfGraphForCode)(parser, '3 -> x', { mark: new Set([0]), ctx }))}
|
|
571
571
|
|
|
572
572
|
However, nested definitions can carry it (in the nested case, \`x\` is defined by the return value of <code>\\\`<-\\\`(y, z)</code>). Additionally, we link the assignment function.
|
|
573
573
|
|
|
@@ -603,7 +603,7 @@ As you can see in the example, this happens for user-defined functions (like \`f
|
|
|
603
603
|
However, these edges are specific to scenarios in which flowR knows that a specific element is returned.
|
|
604
604
|
For contrast, compare this to a use of, for example, \`+\`:
|
|
605
605
|
|
|
606
|
-
${(0, doc_structure_1.details)('Example: No returns edge for +', await (0, doc_dfg_1.printDfGraphForCode)(parser, '1 + 1'))}
|
|
606
|
+
${(0, doc_structure_1.details)('Example: No returns edge for +', await (0, doc_dfg_1.printDfGraphForCode)(parser, '1 + 1', { ctx }))}
|
|
607
607
|
|
|
608
608
|
Here, we do not get a ${linkEdgeName(edge_1.EdgeType.Returns)} edge as this function call creates a new value based on its arguments.
|
|
609
609
|
In these scenarios you should rely on the \`args\` property of the ${ctx.link('DataflowGraphVertexFunctionCall')}
|
|
@@ -615,7 +615,8 @@ In general, the ${linkEdgeName(edge_1.EdgeType.Returns)} edge already does most
|
|
|
615
615
|
${(0, doc_structure_1.details)('Example: Tricky Returns', `We show the _simplified_ DFG for simplicity and highlight all ${linkEdgeName(edge_1.EdgeType.Returns)} edges involved in tracking the return of a call to \`f\` (as ${linkEdgeName(edge_1.EdgeType.Returns)} are never transitive and must hence be followed):\n` +
|
|
616
616
|
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() { if(u) { return(3); 2 } else 42 }\nf()', {
|
|
617
617
|
simplified: true,
|
|
618
|
-
mark: new Set(['19->15', '15->14', '14->12', '14->11', '11->9', '9->7'])
|
|
618
|
+
mark: new Set(['19->15', '15->14', '14->12', '14->11', '11->9', '9->7']),
|
|
619
|
+
ctx
|
|
619
620
|
})
|
|
620
621
|
+ '\n\n Note, that the `2` should be completely absent of the dataflow graph (recognized as dead code).')}
|
|
621
622
|
<br/>
|
|
@@ -625,7 +626,7 @@ ${(0, doc_structure_1.block)({
|
|
|
625
626
|
content: `You might find it an inconvenience that there is no ${linkEdgeName(edge_1.EdgeType.Returns)} edge for _every_ function call.
|
|
626
627
|
If there is particular function for which you think flowR should be able to detect the return, please open a [new issue](${doc_issue_1.NewIssueUrl}).
|
|
627
628
|
Yet the problem of flowR not tracking returns for functions that create new/transform existing values is a fundamental design decision — if this irritates you ~~you may be eligible for compensation~~, you may be interested in an
|
|
628
|
-
alternative with the
|
|
629
|
+
alternative with the ${ctx.linkPage('wiki/Control Flow Graph', 'Control Flow Graph', 'cfg-exit-points')} which not just tracks all possible execution orders of the program,
|
|
629
630
|
but also the exit points of _all_ function calls.
|
|
630
631
|
`
|
|
631
632
|
})}
|
|
@@ -638,7 +639,7 @@ f <- function() x
|
|
|
638
639
|
x <- 3
|
|
639
640
|
f()
|
|
640
641
|
`.trim();
|
|
641
|
-
const dfInfo = await (0, doc_dfg_1.printDfGraphForCode)(parser, lateBindingExample, { switchCodeAndGraph: true, codeOpen: true, mark: new Set([1, '1->5', '9->5']) });
|
|
642
|
+
const dfInfo = await (0, doc_dfg_1.printDfGraphForCode)(parser, lateBindingExample, { switchCodeAndGraph: true, codeOpen: true, mark: new Set([1, '1->5', '9->5']), ctx });
|
|
642
643
|
edgeExplanations.set(edge_1.EdgeType.DefinesOnCall, [{
|
|
643
644
|
name: 'DefinesOnCall Edge',
|
|
644
645
|
type: edge_1.EdgeType.DefinesOnCall,
|
|
@@ -705,8 +706,8 @@ Yet, you may choose to follow these references for other queries. For now, _flow
|
|
|
705
706
|
Besides the obvious quotation there are other cases in which _flowR_ may choose to create a ${linkEdgeName(edge_1.EdgeType.NonStandardEvaluation)} edge, there are
|
|
706
707
|
some that may appear to be counter-intuitive. For example, a for-loop body, as in the following example.
|
|
707
708
|
|
|
708
|
-
${(0, doc_structure_1.details)('Example: For-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) b', { mark: new Set([2, '4->2']) }))}
|
|
709
|
-
${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'while(TRUE) b', { mark: new Set([1, '3->1']) }))}
|
|
709
|
+
${(0, doc_structure_1.details)('Example: For-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) b', { mark: new Set([2, '4->2']), ctx }))}
|
|
710
|
+
${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'while(TRUE) b', { mark: new Set([1, '3->1']), ctx }))}
|
|
710
711
|
`
|
|
711
712
|
})}
|
|
712
713
|
`,
|
|
@@ -727,7 +728,7 @@ ${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.p
|
|
|
727
728
|
const get = edgeExplanations.get(edge);
|
|
728
729
|
(0, assert_1.guard)(get !== undefined, () => `No explanation for edge type ${edge}`);
|
|
729
730
|
const [expl, subExplanations] = get;
|
|
730
|
-
results.push(`<a id='${edgeTypeToId(edge)}'></a>` + await explanation(expl, parser, ++i, ...subExplanations));
|
|
731
|
+
results.push(`<a id='${edgeTypeToId(edge)}'></a>` + await explanation(expl, parser, ctx, ++i, ...subExplanations));
|
|
731
732
|
}
|
|
732
733
|
return results.join('\n');
|
|
733
734
|
}
|
|
@@ -774,7 +775,7 @@ Additionally, you may be interested in the [Unknown Side Effects](#unknown-side-
|
|
|
774
775
|
> There is also a simplified version available with ${ctx.replCmd('dataflowsimple*')} that does not show everything but is easier to read.
|
|
775
776
|
> For small graphs, you can also use ${ctx.replCmd('dataflowascii')} to print the graph as ASCII art.
|
|
776
777
|
>
|
|
777
|
-
> If you receive a dataflow graph in its serialized form (e.g., by talking to a
|
|
778
|
+
> If you receive a dataflow graph in its serialized form (e.g., by talking to a ${ctx.linkPage('wiki/Interface', '_flowR_ server')}), you can use ${ctx.linkM(graph_1.DataflowGraph, 'fromJson', { realNameWrapper: 'i', codeFont: true })} to recover the graph object.
|
|
778
779
|
>
|
|
779
780
|
> Also, check out the [${doc_files_1.FlowrGithubGroupName}/sample-analyzer-df-diff](${doc_files_1.FlowrGithubBaseRef}/sample-analyzer-df-diff) repository for a complete example project creating and comparing dataflow graphs.
|
|
780
781
|
|
|
@@ -783,7 +784,7 @@ ${(0, doc_code_1.codeBlock)('r', introExampleCode)}
|
|
|
783
784
|
|
|
784
785
|
With this code, the corresponding dataflow graph looks like this:
|
|
785
786
|
|
|
786
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, introExampleCode, { showCode: false })}
|
|
787
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, introExampleCode, { showCode: false, ctx })}
|
|
787
788
|
|
|
788
789
|
The above dataflow graph showcases the general gist. We define a dataflow graph as a directed graph G = (V, E),
|
|
789
790
|
differentiating between ${(0, doc_data_dfg_util_1.getAllVertices)().length} types of vertices V and
|
|
@@ -791,7 +792,7 @@ ${(0, doc_data_dfg_util_1.getAllEdges)().length} types of edges E allowing
|
|
|
791
792
|
Additionally, every node may have links to its [control dependencies](#control-dependencies) (which you may view as a ${(0, text_1.nth)((0, doc_data_dfg_util_1.getAllEdges)().length + 1)} edge type,
|
|
792
793
|
although they are explicitly no data dependency and relate to the ${ctx.linkPage('wiki/Control Flow Graph')}.
|
|
793
794
|
|
|
794
|
-
${(0, doc_structure_1.details)('Simplified Version of the graph', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'x <- 3\ny <- x + 1\ny', { simplified: true, showCode: false }))}
|
|
795
|
+
${(0, doc_structure_1.details)('Simplified Version of the graph', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'x <- 3\ny <- x + 1\ny', { simplified: true, showCode: false, ctx }))}
|
|
795
796
|
|
|
796
797
|
The following vertices types exist:
|
|
797
798
|
|
|
@@ -812,16 +813,16 @@ From an implementation perspective all of these types are represented by respect
|
|
|
812
813
|
The following sections present details on the different types of vertices and edges, including examples and explanations.
|
|
813
814
|
|
|
814
815
|
> [!NOTE]
|
|
815
|
-
> Every dataflow vertex holds an \`id\` which links it to the respective node in the
|
|
816
|
+
> Every dataflow vertex holds an \`id\` which links it to the respective node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}.
|
|
816
817
|
> So if you want more information about the respective vertex, you can usually access more information
|
|
817
818
|
> using the <code>${ctx.link(`${graph_1.DataflowGraph.name}`, { codeFont: false, realNameWrapper: 'i' })}::idMap</code> linked to the dataflow graph:
|
|
818
819
|
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts', 'const node = graph.idMap.get(id);'), '> ')}
|
|
819
820
|
> In case you just need the name (\`lexeme\`) of the respective vertex, ${ctx.link(node_id_1.recoverName)} can help you out:
|
|
820
821
|
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts', `const name = ${node_id_1.recoverName.name}(id, graph.idMap);`), '> ')}
|
|
821
822
|
>
|
|
822
|
-
> Please note, that not every node in the
|
|
823
|
+
> Please note, that not every node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} is represented in the dataflow graph.
|
|
823
824
|
> For example, if the node is unreachable in a way that can be detected during the analysis and flowR
|
|
824
|
-
> is configured to ignore dead code (there are more powerful dead code capabilities with the
|
|
825
|
+
> is configured to ignore dead code (there are more powerful dead code capabilities with the ${ctx.linkPage('wiki/Control Flow Graph', 'CFG')}). Likewise, empty argument wrappers do not have a corresponding
|
|
825
826
|
> dataflow graph vertex (as they are not relevant for the dataflow graph). It depends on the scenario what to do in such a case.
|
|
826
827
|
> For argument wrappers you can access the dataflow information for their value. For dead code, however, flowR currently contains
|
|
827
828
|
> some core heuristics that remove it which cannot be reversed easily. So please open [an issue](${doc_issue_1.NewIssueUrl}) if you encounter such a case and require the node to be present in the dataflow graph.
|
|
@@ -831,7 +832,7 @@ ${(0, doc_structure_1.section)('Reading the Visualizations', 2, 'reading-the-vis
|
|
|
831
832
|
Before we dive into the details of the different vertices and edges, let's briefly talk about how to read the visualizations.
|
|
832
833
|
For this, let's have a look at a very simple graph, created for the number \`42\`:
|
|
833
834
|
|
|
834
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, '42', { showCode: false })}
|
|
835
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, '42', { showCode: false, ctx })}
|
|
835
836
|
|
|
836
837
|
${(0, doc_structure_1.section)('Vertex Shape', 3, 'vtx-shape')}
|
|
837
838
|
|
|
@@ -867,7 +868,7 @@ In the second line, you will usually find the id (in the form of a ${ctx.link(no
|
|
|
867
868
|
alongside its [control dependencies](#control-dependencies) if it has any. This id links the vertex to the respective node in the ${ctx.linkPage('wiki/Normalized AST')} (and all other perspectives created by flowR).
|
|
868
869
|
To give you an example, have a look at the following graph:
|
|
869
870
|
|
|
870
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(u) a', { showCode: false, mark: new Set(['1']) })}
|
|
871
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(u) a', { showCode: false, mark: new Set(['1']), ctx })}
|
|
871
872
|
With the _may_ prefix you can see that \`a\` has a [control dependency](#control-dependencies)
|
|
872
873
|
on the \`if\`, which only triggers when the condition is \`true\` (as indicated by the \`+\` suffix).
|
|
873
874
|
|
|
@@ -904,21 +905,21 @@ and a boolean flag \`when\` to indicate if the control dependency is active when
|
|
|
904
905
|
|
|
905
906
|
As an example, consider the following dataflow graph:
|
|
906
907
|
|
|
907
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a else b')}
|
|
908
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a else b', { ctx })}
|
|
908
909
|
|
|
909
910
|
Whenever we visualize a graph, we represent the control dependencies as grayed out edges with a \`CD\` prefix, followed
|
|
910
911
|
by the \`when\` flag.
|
|
911
912
|
In the above example, both \`a\` and \`b\` depend on the \`if\`. Please note that they are _not_ linked to the result of
|
|
912
913
|
the condition itself as this is the more general linkage point (and harmonizes with other control structures, especially those which are user-defined).
|
|
913
914
|
|
|
914
|
-
${(0, doc_structure_1.details)('Example: Multiple Vertices (Assignment)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a <- 1'))}
|
|
915
|
-
${(0, doc_structure_1.details)('Example: Multiple Vertices (Arithmetic Expression)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) 3 + 2'))}
|
|
916
|
-
${(0, doc_structure_1.details)('Example: Nested Conditionals', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(x) { if(y) a else b } else c'))}
|
|
915
|
+
${(0, doc_structure_1.details)('Example: Multiple Vertices (Assignment)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a <- 1', { ctx }))}
|
|
916
|
+
${(0, doc_structure_1.details)('Example: Multiple Vertices (Arithmetic Expression)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) 3 + 2', { ctx }))}
|
|
917
|
+
${(0, doc_structure_1.details)('Example: Nested Conditionals', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(x) { if(y) a else b } else c', { ctx }))}
|
|
917
918
|
|
|
918
919
|
|
|
919
920
|
${(0, doc_structure_1.section)('Dataflow Information', 2, 'dataflow-information')}
|
|
920
921
|
|
|
921
|
-
Using _flowR's_ code interface (see the
|
|
922
|
+
Using _flowR's_ code interface (see the ${ctx.linkPage('wiki/Interface', 'Interface', 'creating-flowr-analyses')} wiki page for more), you can generate the dataflow information
|
|
922
923
|
for a given piece of R code (in this case \`x <- 1; x + 1\`) as follows:
|
|
923
924
|
|
|
924
925
|
${(0, doc_code_1.codeBlock)('ts', `
|
|
@@ -993,9 +994,9 @@ In case _flowR_ encounters a function call that it cannot handle, it marks the c
|
|
|
993
994
|
You can find these as part of the dataflow graph, specifically as \`unknownSideEffects\` (with a leading underscore if sesrialized as JSON).
|
|
994
995
|
In the following graph, _flowR_ realizes that it is unable to correctly handle the impacts of the \`load\` call and therefore marks it as such (marked in bright red):
|
|
995
996
|
|
|
996
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'load("file")\nprint(x + y)')}
|
|
997
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'load("file")\nprint(x + y)', { ctx })}
|
|
997
998
|
|
|
998
|
-
In general, as we cannot handle these correctly, we leave it up to other analyses (and
|
|
999
|
+
In general, as we cannot handle these correctly, we leave it up to other analyses (and ${ctx.linkPage('wiki/Query API', 'queries')}) to handle these cases
|
|
999
1000
|
as they see fit.
|
|
1000
1001
|
|
|
1001
1002
|
#### Linked Unknown Side Effects
|
|
@@ -1005,7 +1006,7 @@ Consider R's basic [\`graphics\`](https://www.rdocumentation.org/packages/graphi
|
|
|
1005
1006
|
implicitly draws on the current device and does not explicitly link a function like \`points\` to the last call opening a new graphic device. In such a scenario, we use a linked side effect to mark the relation:
|
|
1006
1007
|
|
|
1007
1008
|
${await (async () => {
|
|
1008
|
-
const [result, df] = await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'plot(data)\npoints(data2)', { exposeResult: true });
|
|
1009
|
+
const [result, df] = await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'plot(data)\npoints(data2)', { exposeResult: true, ctx });
|
|
1009
1010
|
return `
|
|
1010
1011
|
${result}
|
|
1011
1012
|
|
|
@@ -1033,7 +1034,7 @@ ${(0, doc_code_1.codeBlock)('r', 'f <- function() f()')}
|
|
|
1033
1034
|
|
|
1034
1035
|
The resulting call graph looks like this:
|
|
1035
1036
|
|
|
1036
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'f <- function() f()', { callGraph: true })}
|
|
1037
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'f <- function() f()', { callGraph: true, ctx })}
|
|
1037
1038
|
|
|
1038
1039
|
Please note, that, due to the over-approximative nature of call-graphs, the call-graph may label some function calls that are *not*
|
|
1039
1040
|
marked as such in the full dataflow graph (which may have more precise information).
|
|
@@ -1043,11 +1044,11 @@ ${(0, doc_code_1.codeBlock)('r', 'alias <- unknown\nalias(print)')}
|
|
|
1043
1044
|
|
|
1044
1045
|
The resulting call graph looks like this:
|
|
1045
1046
|
|
|
1046
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: true })}
|
|
1047
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: true, ctx })}
|
|
1047
1048
|
|
|
1048
1049
|
Here, \`unknown\` is a function call, while it is a symbol in the full dataflow graph (as we cannot resolve it):
|
|
1049
1050
|
|
|
1050
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: false })}
|
|
1051
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: false, ctx })}
|
|
1051
1052
|
|
|
1052
1053
|
|
|
1053
1054
|
${(0, doc_structure_1.section)('Working with the Dataflow Graph', 2, 'dfg-working')}
|
|
@@ -1075,13 +1076,13 @@ If you are interested in which features we support and which features are still
|
|
|
1075
1076
|
|
|
1076
1077
|
${(0, doc_structure_1.section)('Resolving Values', 3, 'dfg-resolving-values')}
|
|
1077
1078
|
|
|
1078
|
-
FlowR supports a
|
|
1079
|
-
These capabilities are exposed by the
|
|
1079
|
+
FlowR supports a ${ctx.linkPage('wiki/Interface', 'configurable', 'configuring-flowr')} level of value tracking—all with the goal of knowing the static value domain of a variable.
|
|
1080
|
+
These capabilities are exposed by the ${ctx.linkPage('wiki/Query API', 'resolve value Query', 'resolve-value-query')} and backed by two important functions:
|
|
1080
1081
|
|
|
1081
1082
|
${ctx.link(alias_tracking_1.resolveIdToValue)} provides an environment-sensitive (see ${ctx.link('REnvironmentInformation')})
|
|
1082
1083
|
value resolution depending on if the environment is provided.
|
|
1083
1084
|
The idea of ${ctx.link(alias_tracking_1.resolveIdToValue)} is to provide a compromise between precision and performance, to
|
|
1084
|
-
be used _during_ and _after_ the core analysis. After the dataflow analysis completes, there are much more expensive queries possible (such as the resolution of the data frame shape, see the
|
|
1085
|
+
be used _during_ and _after_ the core analysis. After the dataflow analysis completes, there are much more expensive queries possible (such as the resolution of the data frame shape, see the ${ctx.linkPage('wiki/Query API', 'Query API')}).
|
|
1085
1086
|
|
|
1086
1087
|
Additionally, to ${ctx.link(alias_tracking_1.resolveIdToValue)}, we offer the aforementioned ${ctx.link(identify_link_to_last_call_relation_1.getValueOfArgument)} to retrieve the value of an argument in a function call.
|
|
1087
1088
|
Be aware, that this function is currently not optimized for speed, so if you frequently require the values of multiple arguments of the same function call, you may want to open [an issue](${doc_issue_1.NewIssueUrl}) to request support for resolving
|
|
@@ -1093,7 +1094,7 @@ The [edges](#edges) of the dataflow graph use bitmasks to represent an edge with
|
|
|
1093
1094
|
difficult to check whether a given edge is a read edge.
|
|
1094
1095
|
Consider the following example:
|
|
1095
1096
|
|
|
1096
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'print(x)', { mark: new Set(['3->1']) })}
|
|
1097
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'print(x)', { mark: new Set(['3->1']), ctx })}
|
|
1097
1098
|
|
|
1098
1099
|
Retrieving the _types_ of the edge from the print call to its argument returns:
|
|
1099
1100
|
${await (async () => {
|
|
@@ -4,7 +4,6 @@ exports.WikiEngine = void 0;
|
|
|
4
4
|
const shell_1 = require("../r-bridge/shell");
|
|
5
5
|
const shell_executor_1 = require("../r-bridge/shell-executor");
|
|
6
6
|
const tree_sitter_executor_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor");
|
|
7
|
-
const doc_files_1 = require("./doc-util/doc-files");
|
|
8
7
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
9
8
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
10
9
|
/**
|
|
@@ -26,7 +25,7 @@ is synchronous, faster, and no longer needs an R installation, but requires the
|
|
|
26
25
|
To allow users of R to freely choose their backend between the R interpreter and the tree-sitter parser,
|
|
27
26
|
we provide the concept of engines.
|
|
28
27
|
|
|
29
|
-
Engines can be loaded with
|
|
28
|
+
Engines can be loaded with ${ctx.linkPage('wiki/Interface', "flowR's configuration file", 'configuring-flowr')}. Additionally, they
|
|
30
29
|
are exposed with some command line options (e.g., when using the docker image of flowR):
|
|
31
30
|
|
|
32
31
|
- ${ctx.cliOption('flowr', 'engine.r-shell.disabled', false)} to disable the ${ctx.link(shell_1.RShell)} engine
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { DocMakerArgs } from './wiki-mk/doc-maker';
|
|
1
2
|
import { DocMaker } from './wiki-mk/doc-maker';
|
|
2
3
|
/**
|
|
3
4
|
* https://github.com/flowr-analysis/flowr/wiki/FAQ
|
|
4
5
|
*/
|
|
5
6
|
export declare class WikiFaq extends DocMaker<'wiki/FAQ.md'> {
|
|
6
7
|
constructor();
|
|
7
|
-
text(): string;
|
|
8
|
+
text({ ctx }: DocMakerArgs): string;
|
|
8
9
|
}
|
|
@@ -10,10 +10,10 @@ class WikiFaq extends doc_maker_1.DocMaker {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super('wiki/FAQ.md', module.filename, 'frequently asked questions');
|
|
12
12
|
}
|
|
13
|
-
text() {
|
|
14
|
-
const faqs = (0, faqs_1.registerFaqs)();
|
|
15
|
-
return `
|
|
16
|
-
${faqs.toMarkdown()}
|
|
13
|
+
text({ ctx }) {
|
|
14
|
+
const faqs = (0, faqs_1.registerFaqs)(ctx);
|
|
15
|
+
return `
|
|
16
|
+
${faqs.toMarkdown()}
|
|
17
17
|
`.trim();
|
|
18
18
|
}
|
|
19
19
|
}
|