@eagleoutice/flowr 2.12.0 → 2.12.2
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 +19 -19
- package/abstract-interpretation/absint-visitor.d.ts +1 -0
- package/cli/flowr.js +9 -2
- package/cli/repl/commands/repl-signature.js +1 -2
- package/documentation/wiki-interface.js +1 -1
- package/documentation/wiki-query.js +17 -14
- package/package.json +4 -4
- package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
- package/queries/catalog/absint-query/absint-query-executor.js +63 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
- package/queries/catalog/absint-query/absint-query-format.js +102 -0
- package/queries/query.d.ts +6 -5
- package/queries/query.js +2 -2
- package/slicing/criterion/parse.d.ts +6 -0
- package/slicing/criterion/parse.js +8 -0
- package/util/version.d.ts +1 -1
- package/util/version.js +9 -8
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
- package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
|
|
|
24
24
|
|
|
25
25
|
```shell
|
|
26
26
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
27
|
-
flowR repl v2.
|
|
27
|
+
flowR repl v2.12.0, R grammar v14 (tree-sitter engine)
|
|
28
28
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -33,17 +33,17 @@ It offers a wide variety of features, for example:
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
```text
|
|
36
|
-
Query: linter (
|
|
36
|
+
Query: linter (4 ms)
|
|
37
37
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
38
38
|
╰ File Path Validity (file-path-validity):
|
|
39
39
|
╰ certain:
|
|
40
40
|
╰ Path `/root/x.txt` at 1.1-23
|
|
41
|
-
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
41
|
+
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 2, processTimeMs: 0
|
|
42
42
|
╰ Seeded Randomness (seeded-randomness): no findings
|
|
43
43
|
╰ Absolute Paths (absolute-file-paths):
|
|
44
44
|
╰ certain:
|
|
45
45
|
╰ Path `/root/x.txt` at 1.1-23
|
|
46
|
-
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
46
|
+
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0
|
|
47
47
|
╰ Unused Definitions (unused-definitions): no findings
|
|
48
48
|
╰ Network Functions (network-functions): no findings
|
|
49
49
|
╰ Dataframe Access Validation (dataframe-access-validation): no findings
|
|
@@ -62,7 +62,7 @@ It offers a wide variety of features, for example:
|
|
|
62
62
|
╰ Metadata: testFilesFound: 0, testCallsFound: 0, searchTimeMs: 0, processTimeMs: 0
|
|
63
63
|
╰ No Leaked Credentials (no-leaked-credentials): no findings
|
|
64
64
|
╰ Undefined Symbol (undefined-symbol): no findings
|
|
65
|
-
All queries together required ≈
|
|
65
|
+
All queries together required ≈4 ms (1ms accuracy, total 4 ms)
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
|
|
@@ -84,17 +84,17 @@ It offers a wide variety of features, for example:
|
|
|
84
84
|
|
|
85
85
|
_Results (prettified and summarized):_
|
|
86
86
|
|
|
87
|
-
Query: **linter** (
|
|
87
|
+
Query: **linter** (4 ms)\
|
|
88
88
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
89
89
|
╰ **File Path Validity** (file-path-validity):\
|
|
90
90
|
╰ certain:\
|
|
91
91
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
92
|
-
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
92
|
+
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 1\
|
|
93
93
|
╰ **Seeded Randomness** (seeded-randomness): _no findings_\
|
|
94
94
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
95
95
|
╰ certain:\
|
|
96
96
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
97
|
-
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs:
|
|
97
|
+
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0\
|
|
98
98
|
╰ **Unused Definitions** (unused-definitions): _no findings_\
|
|
99
99
|
╰ **Network Functions** (network-functions): _no findings_\
|
|
100
100
|
╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
|
|
@@ -113,11 +113,11 @@ It offers a wide variety of features, for example:
|
|
|
113
113
|
╰ _Metadata_: testFilesFound: 0, testCallsFound: 0, searchTimeMs: 0, processTimeMs: 0\
|
|
114
114
|
╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
|
|
115
115
|
╰ **Undefined Symbol** (undefined-symbol): _no findings_\
|
|
116
|
-
_All queries together required ≈
|
|
116
|
+
_All queries together required ≈4 ms (1ms accuracy, total 4 ms)_
|
|
117
117
|
|
|
118
118
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
119
119
|
|
|
120
|
-
The analysis required
|
|
120
|
+
The analysis required _4.4 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
121
121
|
|
|
122
122
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
123
123
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -157,7 +157,7 @@ It offers a wide variety of features, for example:
|
|
|
157
157
|
"totalUnknown": 0,
|
|
158
158
|
"totalWritesBeforeAlways": 0,
|
|
159
159
|
"totalValid": 0,
|
|
160
|
-
"searchTimeMs":
|
|
160
|
+
"searchTimeMs": 1,
|
|
161
161
|
"processTimeMs": 1
|
|
162
162
|
}
|
|
163
163
|
},
|
|
@@ -190,7 +190,7 @@ It offers a wide variety of features, for example:
|
|
|
190
190
|
"totalConsidered": 1,
|
|
191
191
|
"totalUnknown": 0,
|
|
192
192
|
"searchTimeMs": 0,
|
|
193
|
-
"processTimeMs":
|
|
193
|
+
"processTimeMs": 0
|
|
194
194
|
}
|
|
195
195
|
},
|
|
196
196
|
"unused-definitions": {
|
|
@@ -316,16 +316,16 @@ It offers a wide variety of features, for example:
|
|
|
316
316
|
"subscript": 0
|
|
317
317
|
},
|
|
318
318
|
"searchTimeMs": 0,
|
|
319
|
-
"processTimeMs":
|
|
319
|
+
"processTimeMs": 0
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
},
|
|
323
323
|
".meta": {
|
|
324
|
-
"timing":
|
|
324
|
+
"timing": 4
|
|
325
325
|
}
|
|
326
326
|
},
|
|
327
327
|
".meta": {
|
|
328
|
-
"timing":
|
|
328
|
+
"timing": 4
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
```
|
|
@@ -389,7 +389,7 @@ It offers a wide variety of features, for example:
|
|
|
389
389
|
|
|
390
390
|
```shell
|
|
391
391
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
392
|
-
flowR repl v2.
|
|
392
|
+
flowR repl v2.12.0, R grammar v14 (tree-sitter engine)
|
|
393
393
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
394
394
|
```
|
|
395
395
|
|
|
@@ -435,7 +435,7 @@ It offers a wide variety of features, for example:
|
|
|
435
435
|
</details>
|
|
436
436
|
|
|
437
437
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
438
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
438
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">105.5 ms</span></i> (as of Jul 15, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
439
439
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
440
440
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
|
|
441
441
|
|
|
@@ -471,7 +471,7 @@ It offers a wide variety of features, for example:
|
|
|
471
471
|
|
|
472
472
|
```shell
|
|
473
473
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
474
|
-
flowR repl v2.
|
|
474
|
+
flowR repl v2.12.0, R grammar v14 (tree-sitter engine)
|
|
475
475
|
R> :dataflow* test/testfiles/example.R
|
|
476
476
|
```
|
|
477
477
|
|
|
@@ -743,7 +743,7 @@ It offers a wide variety of features, for example:
|
|
|
743
743
|
```
|
|
744
744
|
|
|
745
745
|
|
|
746
|
-
(The analysis required
|
|
746
|
+
(The analysis required _1.7 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
|
|
747
747
|
|
|
748
748
|
|
|
749
749
|
|
|
@@ -7,6 +7,7 @@ import { type NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
|
7
7
|
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
8
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
9
9
|
import type { AnyStateDomain, ValueDomain } from './domains/state-domain-like';
|
|
10
|
+
export type DomainOfVisitor<AbsintVisitor extends AbstractInterpretationVisitor<AnyStateDomain>> = AbsintVisitor extends AbstractInterpretationVisitor<infer StateDomain> ? StateDomain : never;
|
|
10
11
|
export type AbsintVisitorConfiguration = Omit<SemanticCfgGuidedVisitorConfiguration<NoInfo, ControlFlowInformation, NormalizedAst>, 'defaultVisitingOrder' | 'defaultVisitingType'>;
|
|
11
12
|
/**
|
|
12
13
|
* A control flow graph visitor to perform abstract interpretation.
|
package/cli/flowr.js
CHANGED
|
@@ -162,8 +162,15 @@ async function mainRepl() {
|
|
|
162
162
|
const engines = await (0, engines_1.retrieveEngineInstances)(config);
|
|
163
163
|
const defaultEngine = engines.engines[engines.default];
|
|
164
164
|
if (options.version) {
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
const enginesList = Object.values(engines.engines);
|
|
166
|
+
if (enginesList.length > 0) {
|
|
167
|
+
await (0, version_1.printVersionInformation)(repl_main_1.standardReplOutput, enginesList[0]);
|
|
168
|
+
for (const engine of enginesList.slice(1)) {
|
|
169
|
+
console.log('');
|
|
170
|
+
await (0, version_1.printVersionInformation)(repl_main_1.standardReplOutput, engine, true);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const engine of enginesList) {
|
|
167
174
|
engine?.close();
|
|
168
175
|
}
|
|
169
176
|
return (0, proc_1.exitSafe)(0);
|
|
@@ -67,9 +67,8 @@ async function runDownload(output, analyzer, rest) {
|
|
|
67
67
|
if (manifest) {
|
|
68
68
|
await analyzer.context().deps.addDatabaseSource(manifest);
|
|
69
69
|
analyzer.reset();
|
|
70
|
-
output.stdout(`Mounted ${(0, ansi_1.bold)(manifest, f)}.`);
|
|
70
|
+
output.stdout(`Mounted ${(0, ansi_1.bold)(manifest, f)} (will be available on next startup from the cache).`);
|
|
71
71
|
}
|
|
72
|
-
output.stdout((0, ansi_1.italic)(`Add "${dir}" to solver.sigdb.additionalPaths to keep it mounted on every start.`, f));
|
|
73
72
|
}
|
|
74
73
|
catch (e) {
|
|
75
74
|
output.stderr(`Download failed: ${e.message}`);
|
|
@@ -195,7 +195,7 @@ As _flowR_ directly transforms this AST the output focuses on being human-readab
|
|
|
195
195
|
You can run any query supported by _flowR_ using the ${ctx.replCmd('query')} command.
|
|
196
196
|
For example, to obtain the shapes of all data frames in a given piece of code, you can run:
|
|
197
197
|
${await (0, doc_repl_1.documentReplSession)(parser, [{
|
|
198
|
-
command: ':query @df-shape "x <- data.frame(a = 1:10, b = 1:10)\\ny <- x$a"',
|
|
198
|
+
command: ':query @absint df-shape "x <- data.frame(a = 1:10, b = 1:10)\\ny <- x$a"',
|
|
199
199
|
description: 'Retrieve the shapes of all data frames in the given code.'
|
|
200
200
|
}], { openOutput: true })}
|
|
201
201
|
To run the linter on a file, you can use (in this example, we just issue the \`dead-code\` linter on a small piece of code):
|
|
@@ -28,7 +28,6 @@ const flowr_search_builder_1 = require("../search/flowr-search-builder");
|
|
|
28
28
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
29
29
|
const control_flow_query_executor_1 = require("../queries/catalog/control-flow-query/control-flow-query-executor");
|
|
30
30
|
const doc_cfg_1 = require("./doc-util/doc-cfg");
|
|
31
|
-
const df_shape_query_executor_1 = require("../queries/catalog/df-shape-query/df-shape-query-executor");
|
|
32
31
|
const doc_repl_1 = require("./doc-util/doc-repl");
|
|
33
32
|
const inspect_higher_order_query_executor_1 = require("../queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor");
|
|
34
33
|
const doc_escape_1 = require("./doc-util/doc-escape");
|
|
@@ -41,6 +40,7 @@ const inspect_exception_query_executor_1 = require("../queries/catalog/inspect-e
|
|
|
41
40
|
const slice_direction_1 = require("../util/slice-direction");
|
|
42
41
|
const provenance_query_executor_1 = require("../queries/catalog/provenance-query/provenance-query-executor");
|
|
43
42
|
const input_sources_query_executor_1 = require("../queries/catalog/input-sources-query/input-sources-query-executor");
|
|
43
|
+
const absint_query_executor_1 = require("../queries/catalog/absint-query/absint-query-executor");
|
|
44
44
|
(0, doc_query_1.registerQueryDocumentation)('call-context', {
|
|
45
45
|
name: 'Call-Context Query',
|
|
46
46
|
type: 'active',
|
|
@@ -462,26 +462,29 @@ enables quick statistics after each REPL command. Likewise, setting \`repl.dfPro
|
|
|
462
462
|
`;
|
|
463
463
|
}
|
|
464
464
|
});
|
|
465
|
-
(0, doc_query_1.registerQueryDocumentation)('
|
|
466
|
-
name: '
|
|
465
|
+
(0, doc_query_1.registerQueryDocumentation)('absint', {
|
|
466
|
+
name: 'Abstract Interpretation Query',
|
|
467
467
|
type: 'active',
|
|
468
|
-
shortDescription: 'Returns the
|
|
469
|
-
functionName:
|
|
470
|
-
functionFile: '../queries/catalog/
|
|
468
|
+
shortDescription: 'Returns the abstract values inferred for every expression or at specific locations.',
|
|
469
|
+
functionName: absint_query_executor_1.executeAbsintQuery.name,
|
|
470
|
+
functionFile: '../queries/catalog/absint-query/absint-query-format.ts',
|
|
471
471
|
buildExplanation: async (shell, ctx) => {
|
|
472
|
-
const
|
|
473
|
-
const
|
|
472
|
+
const criteria = ['1@df', '1@data.frame'];
|
|
473
|
+
const inference = 'df-shape';
|
|
474
|
+
const exampleCode = 'df <- data.frame(id = 1:3) |>\n filter(df, FALSE)';
|
|
474
475
|
return `
|
|
475
|
-
This query infers all shapes of dataframes within the code. For example, you can use:
|
|
476
|
+
This query infers all shapes of dataframes within the code using abstract interpretaion. For example, you can use:
|
|
476
477
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
477
|
-
type: '
|
|
478
|
+
type: 'absint',
|
|
479
|
+
inference: inference
|
|
478
480
|
}], { showCode: true, collapseQuery: true, ctx })}
|
|
479
481
|
|
|
480
|
-
The query also accepts
|
|
482
|
+
The query optionally also accepts slice criteria to narrow the results to specific nodes. For example:
|
|
481
483
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
482
|
-
type: '
|
|
483
|
-
|
|
484
|
-
|
|
484
|
+
type: 'absint',
|
|
485
|
+
inference: inference,
|
|
486
|
+
criteria: criteria
|
|
487
|
+
}], { showCode: true, collapseQuery: true, shorthand: (0, doc_query_1.sliceQueryShorthand)(criteria, (0, doc_escape_1.escapeNewline)(exampleCode)), ctx })}
|
|
485
488
|
`;
|
|
486
489
|
}
|
|
487
490
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.2",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
|
|
32
32
|
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-remote.ts",
|
|
33
33
|
"publish:sigdb": "ts-node scripts/publish-sigdb.ts",
|
|
34
|
-
"build:copy-data": "
|
|
34
|
+
"build:copy-data": "ts-node --transpile-only scripts/sigdb-copy.ts",
|
|
35
35
|
"build-dev": "npm run build && npm run build:copy-wasm",
|
|
36
36
|
"build:bundle-flowr": "npm run build && esbuild --bundle dist/src/cli/flowr.js --platform=node --tree-shaking=true --minify --external:clipboardy --target=node22 --outfile=dist/src/cli/flowr.min.js && npm run build:copy-wasm",
|
|
37
37
|
"build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
|
|
38
|
-
"lint-local": "npx eslint --version && npx eslint src/ test/ --rule \"no-warning-comments: off\"",
|
|
39
|
-
"lint": "npm run license-compat -- --summary && npx eslint --version && npx eslint src/ test/",
|
|
38
|
+
"lint-local": "npx eslint --version && npx eslint src/ test/ scripts/ --rule \"no-warning-comments: off\"",
|
|
39
|
+
"lint": "npm run license-compat -- --summary && npx eslint --version && npx eslint src/ test/ scripts/",
|
|
40
40
|
"license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MPL-2.0;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD'",
|
|
41
41
|
"doc": "typedoc",
|
|
42
42
|
"test": "vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
2
|
+
import { type AbsintQuery, type AbsintQueryResult, type AbsintQueryType } from './absint-query-format';
|
|
3
|
+
/**
|
|
4
|
+
* Executes the given abstract interpretation queries using the provided analyzer.
|
|
5
|
+
*/
|
|
6
|
+
export declare function executeAbsintQuery<AbsintType extends AbsintQueryType>({ analyzer }: BasicQueryData, queries: readonly AbsintQuery<AbsintType>[]): Promise<AbsintQueryResult<AbsintType>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeAbsintQuery = executeAbsintQuery;
|
|
4
|
+
const cfg_kind_1 = require("../../../project/cfg-kind");
|
|
5
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
6
|
+
const log_1 = require("../../../util/log");
|
|
7
|
+
const absint_query_format_1 = require("./absint-query-format");
|
|
8
|
+
/**
|
|
9
|
+
* Executes the given abstract interpretation queries using the provided analyzer.
|
|
10
|
+
*/
|
|
11
|
+
async function executeAbsintQuery({ analyzer }, queries) {
|
|
12
|
+
if (queries.length === 0 || queries.some(query => query.inference !== queries[0].inference)) {
|
|
13
|
+
throw new Error('The inference types of bundled abstract interpretation queries must be the same.');
|
|
14
|
+
}
|
|
15
|
+
if (queries.length > 1 && queries.some(query => query.criteria === undefined)) {
|
|
16
|
+
log_1.log.warn('The abstract interpretation query expects only up to one query without slicing criteria, but got', queries.length);
|
|
17
|
+
queries = [{ type: 'absint', inference: queries[0].inference }];
|
|
18
|
+
}
|
|
19
|
+
const inference = absint_query_format_1.AbsintQueryInferences[queries[0].inference];
|
|
20
|
+
const ast = await analyzer.normalize();
|
|
21
|
+
const dfg = (await analyzer.dataflow()).graph;
|
|
22
|
+
const cfg = await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
|
|
23
|
+
const start = Date.now();
|
|
24
|
+
const visitor = inference({ controlFlow: cfg, dfg, normalizedAst: ast, ctx: analyzer.inspectContext() });
|
|
25
|
+
visitor.start();
|
|
26
|
+
const endState = visitor.getEndState();
|
|
27
|
+
if (queries.length === 1 && queries[0].criteria === undefined) {
|
|
28
|
+
return {
|
|
29
|
+
'.meta': {
|
|
30
|
+
timing: Date.now() - start
|
|
31
|
+
},
|
|
32
|
+
result: endState
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const result = new Map();
|
|
36
|
+
for (const query of queries) {
|
|
37
|
+
if (query.criteria === undefined) {
|
|
38
|
+
log_1.log.warn('Missing criterion in abstract interpretation query');
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
for (const criterion of query.criteria) {
|
|
42
|
+
if (result.has(criterion)) {
|
|
43
|
+
log_1.log.warn('Duplicate criterion in abstract interpretation query:', query.criteria);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const nodeId = parse_1.SlicingCriterion.parse(criterion, ast.idMap);
|
|
48
|
+
const value = visitor.getAbstractValue(nodeId);
|
|
49
|
+
result.set(criterion, value);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.error(err instanceof Error ? err.message : err);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
'.meta': {
|
|
58
|
+
timing: Date.now() - start
|
|
59
|
+
},
|
|
60
|
+
result: result
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=absint-query-executor.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
import type { AbsintVisitorConfiguration, DomainOfVisitor } from '../../../abstract-interpretation/absint-visitor';
|
|
3
|
+
import { DataFrameShapeInferenceVisitor } from '../../../abstract-interpretation/data-frame/shape-inference';
|
|
4
|
+
import type { ValueDomain } from '../../../abstract-interpretation/domains/state-domain-like';
|
|
5
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
6
|
+
import type { CommandCompletions } from '../../../cli/repl/core';
|
|
7
|
+
import type { FlowrConfig } from '../../../config';
|
|
8
|
+
import { SlicingCriterion, type SlicingCriteria } from '../../../slicing/criterion/parse';
|
|
9
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
10
|
+
import type { ParsedQueryLine } from '../../query';
|
|
11
|
+
import { executeAbsintQuery } from './absint-query-executor';
|
|
12
|
+
export interface AbsintQuery<AbsintType extends AbsintQueryType = AbsintQueryType> extends BaseQueryFormat {
|
|
13
|
+
readonly type: 'absint';
|
|
14
|
+
readonly inference: AbsintType;
|
|
15
|
+
readonly criteria?: SlicingCriteria;
|
|
16
|
+
}
|
|
17
|
+
export interface AbsintQueryResult<AbsintType extends AbsintQueryType = AbsintQueryType> extends BaseQueryResult {
|
|
18
|
+
result: AbsintQueryStateDomain<AbsintType> | Map<SlicingCriterion, AbsintQueryDomain<AbsintType> | undefined>;
|
|
19
|
+
}
|
|
20
|
+
export declare const AbsintQueryInferences: {
|
|
21
|
+
'df-shape': (config: AbsintVisitorConfiguration) => DataFrameShapeInferenceVisitor;
|
|
22
|
+
};
|
|
23
|
+
export type AbsintQueryType = keyof typeof AbsintQueryInferences;
|
|
24
|
+
export type AbsintQueryStateDomain<AbsintType extends AbsintQueryType = AbsintQueryType> = DomainOfVisitor<ReturnType<typeof AbsintQueryInferences[AbsintType]>>;
|
|
25
|
+
export type AbsintQueryDomain<AbsintType extends AbsintQueryType = AbsintQueryType> = ValueDomain<AbsintQueryStateDomain<AbsintType>>;
|
|
26
|
+
declare function absintQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
|
|
27
|
+
declare function absintQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'absint'>;
|
|
28
|
+
export declare const AbsintQueryDefinition: {
|
|
29
|
+
readonly executor: typeof executeAbsintQuery;
|
|
30
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
31
|
+
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
32
|
+
readonly completer: typeof absintQueryCompleter;
|
|
33
|
+
readonly fromLine: typeof absintQueryLineParser;
|
|
34
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
35
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AbsintQueryDefinition = exports.AbsintQueryInferences = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const shape_inference_1 = require("../../../abstract-interpretation/data-frame/shape-inference");
|
|
9
|
+
const abstract_domain_1 = require("../../../abstract-interpretation/domains/abstract-domain");
|
|
10
|
+
const lattice_1 = require("../../../abstract-interpretation/domains/lattice");
|
|
11
|
+
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
12
|
+
const retriever_1 = require("../../../r-bridge/retriever");
|
|
13
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
14
|
+
const record_1 = require("../../../util/record");
|
|
15
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
16
|
+
const time_1 = require("../../../util/text/time");
|
|
17
|
+
const absint_query_executor_1 = require("./absint-query-executor");
|
|
18
|
+
exports.AbsintQueryInferences = {
|
|
19
|
+
'df-shape': config => new shape_inference_1.DataFrameShapeInferenceVisitor(config)
|
|
20
|
+
};
|
|
21
|
+
function absintQueryCompleter(line, startingNewArg, _config) {
|
|
22
|
+
if (line.length === 0 || (line.length === 1 && !startingNewArg)) {
|
|
23
|
+
return { completions: record_1.Record.keys(exports.AbsintQueryInferences).map(type => `${type} `) };
|
|
24
|
+
}
|
|
25
|
+
else if ((line.length === 1 && startingNewArg) || (line.length === 2 && line[1].length === 0)) {
|
|
26
|
+
return { completions: ['(', '""', retriever_1.fileProtocol] };
|
|
27
|
+
}
|
|
28
|
+
else if (line.length === 2 && !startingNewArg && line[1].startsWith('(') && !line[1].endsWith(')') && !line[1].endsWith(';')) {
|
|
29
|
+
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[1] + ')');
|
|
30
|
+
if (criteria !== undefined && criteria.length > 0 && criteria.every(parse_1.SlicingCriterion.isValid)) {
|
|
31
|
+
return { completions: [';', ') '], argumentPart: '' };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if ((line.length === 2 && startingNewArg) || (line.length === 3 && line[2].length === 0)) {
|
|
35
|
+
return { completions: ['""', retriever_1.fileProtocol] };
|
|
36
|
+
}
|
|
37
|
+
else if ((line.length === 2 && retriever_1.fileProtocol.startsWith(line[1])) || (line.length === 3 && retriever_1.fileProtocol.startsWith(line[2]))) {
|
|
38
|
+
return { completions: [retriever_1.fileProtocol] };
|
|
39
|
+
}
|
|
40
|
+
return { completions: [] };
|
|
41
|
+
}
|
|
42
|
+
function absintQueryLineParser(output, line, _config) {
|
|
43
|
+
const type = line[0].toLowerCase();
|
|
44
|
+
if (!Object.hasOwn(exports.AbsintQueryInferences, type)) {
|
|
45
|
+
output.stderr(output.formatter.format(`Invalid inference type "${type}", must be one of ${record_1.Record.keys(exports.AbsintQueryInferences).map(type => `"${type}"`).join(', ')}`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
|
|
46
|
+
return { query: [] };
|
|
47
|
+
}
|
|
48
|
+
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[1]);
|
|
49
|
+
if (criteria !== undefined && !criteria.every(parse_1.SlicingCriterion.isValid)) {
|
|
50
|
+
output.stderr(output.formatter.format(`Invalid slicing criteria "${line[1]}"`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
|
|
51
|
+
return { query: [] };
|
|
52
|
+
}
|
|
53
|
+
const code = criteria ? line[2] : line[1];
|
|
54
|
+
return {
|
|
55
|
+
query: {
|
|
56
|
+
type: 'absint',
|
|
57
|
+
inference: type,
|
|
58
|
+
criteria: criteria
|
|
59
|
+
},
|
|
60
|
+
rCode: code
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.AbsintQueryDefinition = {
|
|
64
|
+
executor: absint_query_executor_1.executeAbsintQuery,
|
|
65
|
+
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
66
|
+
const out = queryResults;
|
|
67
|
+
const domains = out.result instanceof abstract_domain_1.AbstractDomain ? out.result.value : out.result;
|
|
68
|
+
result.push(`Query: ${(0, ansi_1.bold)('absint', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
69
|
+
if (domains === lattice_1.Bottom) {
|
|
70
|
+
result.push(` ╰ state: ${lattice_1.BottomSymbol}`);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
else if (out.result instanceof abstract_domain_1.AbstractDomain && out.result.isTop()) {
|
|
74
|
+
result.push(` ╰ state: ${lattice_1.TopSymbol}`);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
result.push(...domains.entries().take(20).map(([key, domain]) => {
|
|
78
|
+
const criterion = parse_1.SlicingCriterion.isValid(key) ? key : parse_1.SlicingCriterion.fromId(key);
|
|
79
|
+
return ` ╰ ${criterion}: ${domain?.toString()}`;
|
|
80
|
+
}));
|
|
81
|
+
if (domains.size > 20) {
|
|
82
|
+
result.push(' ╰ ... (see JSON)');
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
},
|
|
86
|
+
jsonFormatter: (queryResults) => {
|
|
87
|
+
const { result: domains, ...out } = queryResults;
|
|
88
|
+
const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains;
|
|
89
|
+
const json = state === lattice_1.Bottom ? state.description : Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null]));
|
|
90
|
+
const result = { domains: json, ...out };
|
|
91
|
+
return result;
|
|
92
|
+
},
|
|
93
|
+
completer: absintQueryCompleter,
|
|
94
|
+
fromLine: absintQueryLineParser,
|
|
95
|
+
schema: joi_1.default.object({
|
|
96
|
+
type: joi_1.default.string().valid('absint').required().description('The type of the query.'),
|
|
97
|
+
inference: joi_1.default.string().valid(...record_1.Record.keys(exports.AbsintQueryInferences)).required().description('The type of abstract interpretation inference.'),
|
|
98
|
+
criteria: joi_1.default.array().items(joi_1.default.string()).optional().description('The slicing criteria of the nodes to get the inferred abstract values for.')
|
|
99
|
+
}).description('The abstract interpretation query retrieves inferred abstract values'),
|
|
100
|
+
flattenInvolvedNodes: () => []
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=absint-query-format.js.map
|
package/queries/query.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ import { type OriginQuery } from './catalog/origin-query/origin-query-format';
|
|
|
22
22
|
import { type LinterQuery } from './catalog/linter-query/linter-query-format';
|
|
23
23
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
24
24
|
import { type ControlFlowQuery } from './catalog/control-flow-query/control-flow-query-format';
|
|
25
|
-
import { type DfShapeQuery } from './catalog/df-shape-query/df-shape-query-format';
|
|
26
25
|
import type { AsyncOrSync } from 'ts-essentials';
|
|
27
26
|
import type { FlowrConfig } from '../config';
|
|
28
27
|
import { type InspectHigherOrderQuery } from './catalog/inspect-higher-order-query/inspect-higher-order-query-format';
|
|
@@ -38,10 +37,11 @@ import type { InputSourcesQuery } from './catalog/input-sources-query/input-sour
|
|
|
38
37
|
import type { ProvenanceQuery } from './catalog/provenance-query/provenance-query-format';
|
|
39
38
|
import type { LintingResultCertainty } from '../linter/linter-format';
|
|
40
39
|
import { type DiceQuery } from './catalog/dice-query/dice-query-format';
|
|
40
|
+
import { type AbsintQuery } from './catalog/absint-query/absint-query-format';
|
|
41
41
|
/**
|
|
42
42
|
* These are all queries that can be executed from within flowR
|
|
43
43
|
*/
|
|
44
|
-
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery |
|
|
44
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | DiceQuery;
|
|
45
45
|
export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
|
|
46
46
|
type: QueryType;
|
|
47
47
|
};
|
|
@@ -120,11 +120,12 @@ export declare const SupportedQueries: {
|
|
|
120
120
|
readonly schema: Joi.ObjectSchema<any>;
|
|
121
121
|
readonly flattenInvolvedNodes: () => never[];
|
|
122
122
|
};
|
|
123
|
-
readonly
|
|
124
|
-
readonly executor: typeof import("./catalog/
|
|
123
|
+
readonly absint: {
|
|
124
|
+
readonly executor: typeof import("./catalog/absint-query/absint-query-executor").executeAbsintQuery;
|
|
125
125
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
126
126
|
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
127
|
-
readonly
|
|
127
|
+
readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
|
|
128
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"absint">;
|
|
128
129
|
readonly schema: Joi.ObjectSchema<any>;
|
|
129
130
|
readonly flattenInvolvedNodes: () => never[];
|
|
130
131
|
};
|
package/queries/query.js
CHANGED
|
@@ -33,7 +33,6 @@ const signature_query_format_1 = require("./catalog/signature-query/signature-qu
|
|
|
33
33
|
const origin_query_format_1 = require("./catalog/origin-query/origin-query-format");
|
|
34
34
|
const linter_query_format_1 = require("./catalog/linter-query/linter-query-format");
|
|
35
35
|
const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
|
|
36
|
-
const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query-format");
|
|
37
36
|
const inspect_higher_order_query_format_1 = require("./catalog/inspect-higher-order-query/inspect-higher-order-query-format");
|
|
38
37
|
const log_1 = require("../util/log");
|
|
39
38
|
const files_query_format_1 = require("./catalog/files-query/files-query-format");
|
|
@@ -44,6 +43,7 @@ const inspect_exception_query_format_1 = require("./catalog/inspect-exceptions-q
|
|
|
44
43
|
const input_sources_query_format_1 = require("./catalog/input-sources-query/input-sources-query-format");
|
|
45
44
|
const provenance_query_format_1 = require("./catalog/provenance-query/provenance-query-format");
|
|
46
45
|
const dice_query_format_1 = require("./catalog/dice-query/dice-query-format");
|
|
46
|
+
const absint_query_format_1 = require("./catalog/absint-query/absint-query-format");
|
|
47
47
|
exports.SupportedQueries = {
|
|
48
48
|
'call-context': call_context_query_format_1.CallContextQueryDefinition,
|
|
49
49
|
'config': config_query_format_1.ConfigQueryDefinition,
|
|
@@ -52,7 +52,7 @@ exports.SupportedQueries = {
|
|
|
52
52
|
'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
|
|
53
53
|
'does-call': does_call_query_format_1.DoesCallQueryDefinition,
|
|
54
54
|
'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
|
|
55
|
-
'
|
|
55
|
+
'absint': absint_query_format_1.AbsintQueryDefinition,
|
|
56
56
|
'files': files_query_format_1.FilesQueryDefinition,
|
|
57
57
|
'id-map': id_map_query_format_1.IdMapQueryDefinition,
|
|
58
58
|
'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
|
|
@@ -13,6 +13,12 @@ export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${num
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const SlicingCriterion: {
|
|
15
15
|
readonly name: "SlicingCriterion";
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether a value has a valid slicing criterion syntax.
|
|
18
|
+
* This does not check whether the slicing criterion exists (represents a valid node ID).
|
|
19
|
+
* @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
|
|
20
|
+
*/
|
|
21
|
+
readonly isValid: (this: void, criterion: unknown) => criterion is SlicingCriterion;
|
|
16
22
|
/**
|
|
17
23
|
* Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
|
|
18
24
|
* @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
|
|
@@ -12,6 +12,14 @@ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
|
12
12
|
*/
|
|
13
13
|
exports.SlicingCriterion = {
|
|
14
14
|
name: 'SlicingCriterion',
|
|
15
|
+
/**
|
|
16
|
+
* Checks whether a value has a valid slicing criterion syntax.
|
|
17
|
+
* This does not check whether the slicing criterion exists (represents a valid node ID).
|
|
18
|
+
* @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
|
|
19
|
+
*/
|
|
20
|
+
isValid(criterion) {
|
|
21
|
+
return typeof criterion === 'string' && criterion.match(/^\d+:\d+|\d+@.+|\$.+$/) !== null;
|
|
22
|
+
},
|
|
15
23
|
/**
|
|
16
24
|
* Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
|
|
17
25
|
* @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
|
package/util/version.d.ts
CHANGED
|
@@ -24,5 +24,5 @@ export declare function retrieveVersionInformation(input: KnownParser | Readonly
|
|
|
24
24
|
/**
|
|
25
25
|
* Displays the version information to the given output.
|
|
26
26
|
*/
|
|
27
|
-
export declare function printVersionInformation(output: ReplOutput, input: KnownParser | ReadonlyFlowrAnalysisProvider): Promise<void>;
|
|
27
|
+
export declare function printVersionInformation(output: ReplOutput, input: KnownParser | ReadonlyFlowrAnalysisProvider, engineOnly?: boolean): Promise<void>;
|
|
28
28
|
export {};
|
package/util/version.js
CHANGED
|
@@ -7,7 +7,7 @@ const semver_1 = require("semver");
|
|
|
7
7
|
const assert_1 = require("./assert");
|
|
8
8
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
9
9
|
// this is automatically replaced with the current version by release-it
|
|
10
|
-
const version = '2.12.
|
|
10
|
+
const version = '2.12.2';
|
|
11
11
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
12
12
|
const versionDate = '2026-07-15T07:13:44Z';
|
|
13
13
|
/**
|
|
@@ -40,18 +40,18 @@ async function retrieveVersionInformation(input) {
|
|
|
40
40
|
/**
|
|
41
41
|
* Displays the version information to the given output.
|
|
42
42
|
*/
|
|
43
|
-
async function printVersionInformation(output, input) {
|
|
43
|
+
async function printVersionInformation(output, input, engineOnly = false) {
|
|
44
44
|
const { flowr, r, engine } = await retrieveVersionInformation(input);
|
|
45
45
|
const faint = (s) => output.formatter.format(s, { style: 2 /* FontStyles.Faint */ });
|
|
46
46
|
const rReason = r === 'none' ? ' (no R interpreter available)'
|
|
47
47
|
: r === 'unknown' ? (engine === 'tree-sitter' ? ' (not queried, using the tree-sitter engine)' : ' (could not be determined)')
|
|
48
48
|
: '';
|
|
49
49
|
const flowrValue = versionRegex.test(flowr) ? output.formatter.hyperlink(flowr, `https://github.com/flowr-analysis/flowr/releases/tag/v${flowr}`) : flowr;
|
|
50
|
-
const rows = [
|
|
51
|
-
|
|
52
|
-
['flowR', `${flowrValue} ${faint(`(${versionDate})`)}`]
|
|
53
|
-
|
|
54
|
-
];
|
|
50
|
+
const rows = [];
|
|
51
|
+
if (!engineOnly) {
|
|
52
|
+
rows.push(['flowR', `${flowrValue} ${faint(`(${versionDate})`)}`]);
|
|
53
|
+
}
|
|
54
|
+
rows.push(['engine', engine], ['R', `${r}${rReason}`, r === 'none' || r === 'unknown']);
|
|
55
55
|
if (typeof input !== 'function' && 'inspectContext' in input) {
|
|
56
56
|
// reads the current analyzer, so it reflects the databases in use (and adapts to config changes)
|
|
57
57
|
const ctx = input.inspectContext();
|
|
@@ -67,7 +67,8 @@ async function printVersionInformation(output, input) {
|
|
|
67
67
|
}
|
|
68
68
|
const width = Math.max(...rows.map(([label]) => label.length));
|
|
69
69
|
for (const [label, value, faded] of rows) {
|
|
70
|
-
const
|
|
70
|
+
const padding = ' '.repeat(width - label.length);
|
|
71
|
+
const line = `${label}:${padding} ${value}`;
|
|
71
72
|
output.stdout(faded ? faint(line) : line);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BasicQueryData } from '../../base-query-format';
|
|
2
|
-
import type { DfShapeQuery, DfShapeQueryResult } from './df-shape-query-format';
|
|
3
|
-
/**
|
|
4
|
-
* Executes the given data frame shape queries using the provided analyzer.
|
|
5
|
-
*/
|
|
6
|
-
export declare function executeDfShapeQuery({ analyzer }: BasicQueryData, queries: readonly DfShapeQuery[]): Promise<DfShapeQueryResult>;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeDfShapeQuery = executeDfShapeQuery;
|
|
4
|
-
const shape_inference_1 = require("../../../abstract-interpretation/data-frame/shape-inference");
|
|
5
|
-
const cfg_kind_1 = require("../../../project/cfg-kind");
|
|
6
|
-
const parse_1 = require("../../../slicing/criterion/parse");
|
|
7
|
-
const log_1 = require("../../../util/log");
|
|
8
|
-
/**
|
|
9
|
-
* Executes the given data frame shape queries using the provided analyzer.
|
|
10
|
-
*/
|
|
11
|
-
async function executeDfShapeQuery({ analyzer }, queries) {
|
|
12
|
-
if (queries.length !== 1 && queries.some(query => query.criterion === undefined)) {
|
|
13
|
-
log_1.log.warn('The dataframe shape query expects only up to one query without slicing criterion, but got', queries.length);
|
|
14
|
-
queries = [{ type: 'df-shape' }];
|
|
15
|
-
}
|
|
16
|
-
const ast = await analyzer.normalize();
|
|
17
|
-
const dfg = (await analyzer.dataflow()).graph;
|
|
18
|
-
const cfg = await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
|
|
19
|
-
const start = Date.now();
|
|
20
|
-
const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg, normalizedAst: ast, ctx: analyzer.inspectContext() });
|
|
21
|
-
inference.start();
|
|
22
|
-
const domains = inference.getEndState();
|
|
23
|
-
if (queries.length === 1 && queries[0].criterion === undefined) {
|
|
24
|
-
return {
|
|
25
|
-
'.meta': {
|
|
26
|
-
timing: Date.now() - start
|
|
27
|
-
},
|
|
28
|
-
domains: domains
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const result = new Map();
|
|
32
|
-
for (const query of queries) {
|
|
33
|
-
if (query.criterion === undefined) {
|
|
34
|
-
log_1.log.warn('Missing criterion in dataframe shape query');
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
else if (result.has(query.criterion)) {
|
|
38
|
-
log_1.log.warn('Duplicate criterion in dataframe shape query:', query.criterion);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const nodeId = parse_1.SlicingCriterion.parse(query.criterion, ast.idMap);
|
|
43
|
-
const node = ast.idMap.get(nodeId);
|
|
44
|
-
const value = inference.getAbstractValue(node?.info.id);
|
|
45
|
-
result.set(query.criterion, value);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
console.error(e instanceof Error ? e.message : e);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
'.meta': {
|
|
53
|
-
timing: Date.now() - start
|
|
54
|
-
},
|
|
55
|
-
domains: result
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=df-shape-query-executor.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import type { DataFrameDomain } from '../../../abstract-interpretation/data-frame/dataframe-domain';
|
|
3
|
-
import type { StateAbstractDomain } from '../../../abstract-interpretation/domains/state-abstract-domain';
|
|
4
|
-
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
5
|
-
import type { FlowrConfig } from '../../../config';
|
|
6
|
-
import type { SlicingCriterion } from '../../../slicing/criterion/parse';
|
|
7
|
-
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
8
|
-
import type { ParsedQueryLine } from '../../query';
|
|
9
|
-
import { executeDfShapeQuery } from './df-shape-query-executor';
|
|
10
|
-
/** Infer the shape of data frames using abstract interpretation. */
|
|
11
|
-
export interface DfShapeQuery extends BaseQueryFormat {
|
|
12
|
-
readonly type: 'df-shape';
|
|
13
|
-
readonly criterion?: SlicingCriterion;
|
|
14
|
-
}
|
|
15
|
-
export interface DfShapeQueryResult extends BaseQueryResult {
|
|
16
|
-
domains: StateAbstractDomain<DataFrameDomain> | Map<SlicingCriterion, DataFrameDomain | undefined>;
|
|
17
|
-
}
|
|
18
|
-
declare function dfShapeQueryLineParser(_output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'df-shape'>;
|
|
19
|
-
export declare const DfShapeQueryDefinition: {
|
|
20
|
-
readonly executor: typeof executeDfShapeQuery;
|
|
21
|
-
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
22
|
-
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
23
|
-
readonly fromLine: typeof dfShapeQueryLineParser;
|
|
24
|
-
readonly schema: Joi.ObjectSchema<any>;
|
|
25
|
-
readonly flattenInvolvedNodes: () => never[];
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DfShapeQueryDefinition = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const abstract_domain_1 = require("../../../abstract-interpretation/domains/abstract-domain");
|
|
9
|
-
const lattice_1 = require("../../../abstract-interpretation/domains/lattice");
|
|
10
|
-
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
11
|
-
const ansi_1 = require("../../../util/text/ansi");
|
|
12
|
-
const time_1 = require("../../../util/text/time");
|
|
13
|
-
const df_shape_query_executor_1 = require("./df-shape-query-executor");
|
|
14
|
-
function dfShapeQueryLineParser(_output, line, _config) {
|
|
15
|
-
const criterion = (0, slice_query_parser_1.sliceCriterionParser)(line[0]);
|
|
16
|
-
return {
|
|
17
|
-
query: {
|
|
18
|
-
type: 'df-shape',
|
|
19
|
-
criterion: criterion
|
|
20
|
-
},
|
|
21
|
-
rCode: criterion ? line[1] : line[0]
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.DfShapeQueryDefinition = {
|
|
25
|
-
executor: df_shape_query_executor_1.executeDfShapeQuery,
|
|
26
|
-
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
27
|
-
const out = queryResults;
|
|
28
|
-
const domains = out.domains instanceof abstract_domain_1.AbstractDomain ? out.domains.value : out.domains;
|
|
29
|
-
result.push(`Query: ${(0, ansi_1.bold)('df-shape', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
30
|
-
if (domains === lattice_1.Bottom) {
|
|
31
|
-
result.push(` ╰ state: ${lattice_1.BottomSymbol}`);
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
result.push(...domains.entries().take(20).map(([key, domain]) => {
|
|
35
|
-
return ` ╰ ${key}: ${domain?.toString()}`;
|
|
36
|
-
}));
|
|
37
|
-
if (domains.size > 20) {
|
|
38
|
-
result.push(' ╰ ... (see JSON)');
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
},
|
|
42
|
-
jsonFormatter: (queryResults) => {
|
|
43
|
-
const { domains, ...out } = queryResults;
|
|
44
|
-
const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains;
|
|
45
|
-
const json = state === lattice_1.Bottom ? state.description : Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null]));
|
|
46
|
-
const result = { domains: json, ...out };
|
|
47
|
-
return result;
|
|
48
|
-
},
|
|
49
|
-
fromLine: dfShapeQueryLineParser,
|
|
50
|
-
schema: joi_1.default.object({
|
|
51
|
-
type: joi_1.default.string().valid('df-shape').required().description('The type of the query.'),
|
|
52
|
-
criterion: joi_1.default.string().optional().description('The slicing criterion of the node to get the dataframe shape for.')
|
|
53
|
-
}).description('The df-shape query retrieves information on the shape of dataframes'),
|
|
54
|
-
flattenInvolvedNodes: () => []
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=df-shape-query-format.js.map
|