@eagleoutice/flowr 2.13.10 → 2.13.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -40
- package/dataflow/environments/environment.js +56 -20
- package/dataflow/environments/resolve-by-name.js +16 -6
- package/dataflow/environments/resolve-helper.d.ts +43 -0
- package/dataflow/environments/resolve-helper.js +47 -0
- package/dataflow/graph/df-helper.d.ts +48 -1
- package/dataflow/graph/df-helper.js +63 -0
- package/dataflow/graph/graph.js +24 -13
- package/documentation/data/faq/faqs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +3 -2
- package/documentation/data/server/doc-data-server-messages.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +5 -0
- package/documentation/doc-util/doc-files.js +13 -3
- package/documentation/wiki-analyzer.js +10 -10
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +3 -3
- package/documentation/wiki-linting-and-testing.js +13 -13
- package/documentation/wiki-mk/doc-context.d.ts +1 -1
- package/documentation/wiki-mk/doc-context.js +9 -5
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-overview.js +2 -2
- package/documentation/wiki-query.js +1 -1
- package/documentation/wiki-setup.js +3 -3
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +12 -1
- package/linter/rules/syntactically-valid.js +88 -17
- package/package.json +7 -8
- package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
- package/project/context/flowr-analyzer-loading-order-context.js +23 -2
- package/project/sigdb/reader.d.ts +20 -0
- package/project/sigdb/reader.js +93 -10
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +3 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +6 -0
- package/queries/catalog/dependencies-query/link-devices.d.ts +7 -3
- package/queries/catalog/dependencies-query/link-devices.js +56 -10
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
- package/queries/catalog/slice-query-options.d.ts +11 -1
- package/queries/catalog/slice-query-options.js +8 -4
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +9 -0
- package/r-bridge/lang-4.x/ast/model/model.js +12 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/reconstruct/reconstruct.d.ts +9 -0
- package/reconstruct/reconstruct.js +1 -0
- package/search/flowr-search-filters.d.ts +8 -0
- package/search/flowr-search-filters.js +19 -7
- package/search/search-executor/search-generators.js +7 -2
- package/search/search-executor/search-transformer.js +4 -1
- package/slicing/static/slice-call.js +2 -2
- package/util/collections/bimap.d.ts +21 -1
- package/util/collections/bimap.js +43 -7
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ and [Docker](https://hub.docker.com/r/eagleoutice/flowr).
|
|
|
13
13
|
It offers a wide variety of features, for example:
|
|
14
14
|
|
|
15
15
|
* 📚 **dependency analysis**\
|
|
16
|
-
Given your analysis project, flowR offers a plethora of so-called [queries](https://github.com/flowr-analysis/flowr/wiki/
|
|
16
|
+
Given your analysis project, flowR offers a plethora of so-called [queries](https://github.com/flowr-analysis/flowr/wiki/Query-API) to get more information about your code.
|
|
17
17
|
An important query is the [dependencies query](https://github.com/flowr-analysis/flowr/wiki/%5BQuery%5D-Dependencies), which shows you the library your project needs,
|
|
18
18
|
the data files it reads, the scripts it sources, and the data it outputs.
|
|
19
19
|
Building on it, the [guess dependency versions query](https://github.com/flowr-analysis/flowr/wiki/%5BQuery%5D-Guess-Dependency-Versions) narrows down the version range each
|
|
@@ -32,18 +32,18 @@ It offers a wide variety of features, for example:
|
|
|
32
32
|
</details>
|
|
33
33
|
|
|
34
34
|
* 🐞 **code linting**\
|
|
35
|
-
Analyze your R scripts for common issues and potential bugs (see the [wiki page](https://github.com/flowr-analysis/flowr/wiki/
|
|
35
|
+
Analyze your R scripts for common issues and potential bugs (see the [wiki page](https://github.com/flowr-analysis/flowr/wiki/Linter) for more information on the currently supported linters).
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
<details><summary>Example: Linting code with flowR</summary>
|
|
39
39
|
|
|
40
|
-
To lint your code, you can use the [REPL](https://github.com/flowr-analysis/flowr/wiki/
|
|
40
|
+
To lint your code, you can use the [REPL](https://github.com/flowr-analysis/flowr/wiki/Interface#using-the-repl) or the [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr) (see [vscode-flowr#283](https://github.com/flowr-analysis/vscode-flowr/pull/283)).
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
45
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
46
|
-
flowR repl v2.13.
|
|
46
|
+
flowR repl v2.13.10, R grammar v14 (tree-sitter engine)
|
|
47
47
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -52,7 +52,7 @@ It offers a wide variety of features, for example:
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
```text
|
|
55
|
-
Query: linter (
|
|
55
|
+
Query: linter (10 ms)
|
|
56
56
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
57
57
|
╰ File Path Validity (file-path-validity):
|
|
58
58
|
╰ certain:
|
|
@@ -73,7 +73,7 @@ It offers a wide variety of features, for example:
|
|
|
73
73
|
╰ Roxygen Arguments (roxygen-arguments): no findings
|
|
74
74
|
╰ No Leaked Credentials (no-leaked-credentials): no findings
|
|
75
75
|
╰ Undefined Symbol (undefined-symbol): no findings
|
|
76
|
-
All queries together required ≈
|
|
76
|
+
All queries together required ≈10 ms (1ms accuracy, total 11 ms)
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
|
|
@@ -95,17 +95,17 @@ It offers a wide variety of features, for example:
|
|
|
95
95
|
|
|
96
96
|
_Results (prettified and summarized):_
|
|
97
97
|
|
|
98
|
-
Query: **linter** (
|
|
98
|
+
Query: **linter** (246 ms)\
|
|
99
99
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
100
100
|
╰ **File Path Validity** (file-path-validity):\
|
|
101
101
|
╰ certain:\
|
|
102
102
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
103
|
-
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
103
|
+
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 3, processTimeMs: 1\
|
|
104
104
|
╰ **Seeded Randomness** (seeded-randomness): _no findings_\
|
|
105
105
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
106
106
|
╰ certain:\
|
|
107
107
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
108
|
-
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
108
|
+
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 1\
|
|
109
109
|
╰ **Unused Definitions** (unused-definitions): _no findings_\
|
|
110
110
|
╰ **Network Functions** (network-functions): _no findings_\
|
|
111
111
|
╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
|
|
@@ -116,11 +116,11 @@ It offers a wide variety of features, for example:
|
|
|
116
116
|
╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
|
|
117
117
|
╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
|
|
118
118
|
╰ **Undefined Symbol** (undefined-symbol): _no findings_\
|
|
119
|
-
_All queries together required ≈
|
|
119
|
+
_All queries together required ≈246 ms (1ms accuracy, total 248 ms)_
|
|
120
120
|
|
|
121
121
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
122
122
|
|
|
123
|
-
The analysis required
|
|
123
|
+
The analysis required _248.0 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
124
124
|
|
|
125
125
|
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.
|
|
126
126
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -137,8 +137,8 @@ It offers a wide variety of features, for example:
|
|
|
137
137
|
".meta": {
|
|
138
138
|
"totalCalls": 0,
|
|
139
139
|
"totalFunctionDefinitions": 0,
|
|
140
|
-
"searchTimeMs":
|
|
141
|
-
"processTimeMs":
|
|
140
|
+
"searchTimeMs": 46,
|
|
141
|
+
"processTimeMs": 167
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
"file-path-validity": {
|
|
@@ -160,7 +160,7 @@ It offers a wide variety of features, for example:
|
|
|
160
160
|
"totalUnknown": 0,
|
|
161
161
|
"totalWritesBeforeAlways": 0,
|
|
162
162
|
"totalValid": 0,
|
|
163
|
-
"searchTimeMs":
|
|
163
|
+
"searchTimeMs": 3,
|
|
164
164
|
"processTimeMs": 1
|
|
165
165
|
}
|
|
166
166
|
},
|
|
@@ -172,7 +172,7 @@ It offers a wide variety of features, for example:
|
|
|
172
172
|
"callsWithAssignmentProducers": 0,
|
|
173
173
|
"callsWithNonConstantProducers": 0,
|
|
174
174
|
"callsWithOtherBranchProducers": 0,
|
|
175
|
-
"searchTimeMs":
|
|
175
|
+
"searchTimeMs": 1,
|
|
176
176
|
"processTimeMs": 0
|
|
177
177
|
}
|
|
178
178
|
},
|
|
@@ -192,7 +192,7 @@ It offers a wide variety of features, for example:
|
|
|
192
192
|
".meta": {
|
|
193
193
|
"totalConsidered": 1,
|
|
194
194
|
"totalUnknown": 0,
|
|
195
|
-
"searchTimeMs":
|
|
195
|
+
"searchTimeMs": 1,
|
|
196
196
|
"processTimeMs": 1
|
|
197
197
|
}
|
|
198
198
|
},
|
|
@@ -210,7 +210,7 @@ It offers a wide variety of features, for example:
|
|
|
210
210
|
"totalCalls": 0,
|
|
211
211
|
"totalFunctionDefinitions": 0,
|
|
212
212
|
"searchTimeMs": 0,
|
|
213
|
-
"processTimeMs":
|
|
213
|
+
"processTimeMs": 1
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
"dataframe-access-validation": {
|
|
@@ -220,13 +220,13 @@ It offers a wide variety of features, for example:
|
|
|
220
220
|
"numAccesses": 0,
|
|
221
221
|
"totalAccessed": 0,
|
|
222
222
|
"searchTimeMs": 0,
|
|
223
|
-
"processTimeMs":
|
|
223
|
+
"processTimeMs": 2
|
|
224
224
|
}
|
|
225
225
|
},
|
|
226
226
|
"dead-code": {
|
|
227
227
|
"results": [],
|
|
228
228
|
".meta": {
|
|
229
|
-
"searchTimeMs":
|
|
229
|
+
"searchTimeMs": 1,
|
|
230
230
|
"processTimeMs": 0
|
|
231
231
|
}
|
|
232
232
|
},
|
|
@@ -242,7 +242,7 @@ It offers a wide variety of features, for example:
|
|
|
242
242
|
"results": [],
|
|
243
243
|
".meta": {
|
|
244
244
|
"searchTimeMs": 0,
|
|
245
|
-
"processTimeMs":
|
|
245
|
+
"processTimeMs": 1
|
|
246
246
|
}
|
|
247
247
|
},
|
|
248
248
|
"stop-call": {
|
|
@@ -281,16 +281,16 @@ It offers a wide variety of features, for example:
|
|
|
281
281
|
"subscript": 0
|
|
282
282
|
},
|
|
283
283
|
"searchTimeMs": 0,
|
|
284
|
-
"processTimeMs":
|
|
284
|
+
"processTimeMs": 21
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
},
|
|
288
288
|
".meta": {
|
|
289
|
-
"timing":
|
|
289
|
+
"timing": 246
|
|
290
290
|
}
|
|
291
291
|
},
|
|
292
292
|
".meta": {
|
|
293
|
-
"timing":
|
|
293
|
+
"timing": 246
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
```
|
|
@@ -324,11 +324,11 @@ It offers a wide variety of features, for example:
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
The simplest way to retrieve slices is with flowR's [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr).
|
|
327
|
-
However, you can slice using the [REPL](https://github.com/flowr-analysis/flowr/wiki/
|
|
327
|
+
However, you can slice using the [REPL](https://github.com/flowr-analysis/flowr/wiki/Interface#using-the-repl) as well.
|
|
328
328
|
This can help you if you want to reuse specific parts of an existing analysis within another context or if you want to understand
|
|
329
329
|
what is happening in the code.
|
|
330
330
|
|
|
331
|
-
For this, let's have a look at the example file, located at [test/testfiles/example.R](https://github.com/flowr-analysis/flowr/tree/main
|
|
331
|
+
For this, let's have a look at the example file, located at [test/testfiles/example.R](https://github.com/flowr-analysis/flowr/tree/main/test/testfiles/example.R):
|
|
332
332
|
|
|
333
333
|
|
|
334
334
|
```r
|
|
@@ -354,7 +354,7 @@ It offers a wide variety of features, for example:
|
|
|
354
354
|
|
|
355
355
|
```shell
|
|
356
356
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
357
|
-
flowR repl v2.13.
|
|
357
|
+
flowR repl v2.13.10, R grammar v14 (tree-sitter engine)
|
|
358
358
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
359
359
|
```
|
|
360
360
|
|
|
@@ -368,7 +368,7 @@ It offers a wide variety of features, for example:
|
|
|
368
368
|
N <- 10
|
|
369
369
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
370
370
|
sum
|
|
371
|
-
All queries together required ≈
|
|
371
|
+
All queries together required ≈27 ms (1ms accuracy, total 27 ms)
|
|
372
372
|
```
|
|
373
373
|
|
|
374
374
|
|
|
@@ -383,16 +383,16 @@ It offers a wide variety of features, for example:
|
|
|
383
383
|
</details>
|
|
384
384
|
|
|
385
385
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
386
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
386
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">107.6 ms</span></i> (as of Aug 8, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
387
387
|
_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,
|
|
388
|
-
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/
|
|
388
|
+
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).
|
|
389
389
|
|
|
390
390
|
|
|
391
391
|
<details><summary>Example: Generating a dataflow graph with flowR</summary>
|
|
392
392
|
|
|
393
393
|
|
|
394
|
-
You can investigate flowR's analyses using the [REPL](https://github.com/flowr-analysis/flowr/wiki/
|
|
395
|
-
Commands like <span title="Description (Repl Command, starred version): Returns the URL to mermaid.live; Base Command: Get mermaid code for the dataflow graph (aliases: :d*, :df*)">`:dataflow*`</span> allow you to view a [dataflow graph](https://github.com/flowr-analysis/flowr/wiki/
|
|
394
|
+
You can investigate flowR's analyses using the [REPL](https://github.com/flowr-analysis/flowr/wiki/Interface#using-the-repl).
|
|
395
|
+
Commands like <span title="Description (Repl Command, starred version): Returns the URL to mermaid.live; Base Command: Get mermaid code for the dataflow graph (aliases: :d*, :df*)">`:dataflow*`</span> allow you to view a [dataflow graph](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for a given R script.
|
|
396
396
|
|
|
397
397
|
Let's have a look at the following example:
|
|
398
398
|
|
|
@@ -413,13 +413,13 @@ It offers a wide variety of features, for example:
|
|
|
413
413
|
```
|
|
414
414
|
|
|
415
415
|
|
|
416
|
-
To get the [dataflow graph](https://github.com/flowr-analysis/flowr/wiki/
|
|
416
|
+
To get the [dataflow graph](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for this script, you can use the following command:
|
|
417
417
|
|
|
418
418
|
|
|
419
419
|
|
|
420
420
|
```shell
|
|
421
421
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
422
|
-
flowR repl v2.13.
|
|
422
|
+
flowR repl v2.13.10, R grammar v14 (tree-sitter engine)
|
|
423
423
|
R> :dataflow* test/testfiles/example.R
|
|
424
424
|
```
|
|
425
425
|
|
|
@@ -692,7 +692,7 @@ It offers a wide variety of features, for example:
|
|
|
692
692
|
```
|
|
693
693
|
|
|
694
694
|
|
|
695
|
-
(The analysis required _2.
|
|
695
|
+
(The analysis required _2.6 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`).)
|
|
696
696
|
|
|
697
697
|
|
|
698
698
|
|
|
@@ -709,7 +709,7 @@ If you want to use flowR and the features it provides, feel free to check out th
|
|
|
709
709
|
- [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr)/[Positron](https://open-vsx.org/extension/code-inspect/vscode-flowr): provides access to flowR directly in VS Code and Positron (or [vscode.dev](https://vscode.dev/))
|
|
710
710
|
- [RStudio Addin](https://github.com/flowr-analysis/rstudio-addin-flowr): integrates flowR into [RStudio](https://posit.co/downloads/)
|
|
711
711
|
- [R package](https://github.com/flowr-analysis/flowr-r-adapter): use flowR in your R scripts
|
|
712
|
-
- [Docker image](https://hub.docker.com/r/eagleoutice/flowr): run flowR in a container, this also includes [flowR's server](https://github.com/flowr-analysis/flowr/wiki/
|
|
712
|
+
- [Docker image](https://hub.docker.com/r/eagleoutice/flowr): run flowR in a container, this also includes [flowR's server](https://github.com/flowr-analysis/flowr/wiki/Interface#communicating-with-the-server)
|
|
713
713
|
- [NPM package](https://www.npmjs.com/package/@eagleoutice/flowr): include flowR in your TypeScript and JavaScript projects
|
|
714
714
|
|
|
715
715
|
|
|
@@ -718,8 +718,8 @@ If you are already using flowR and want to give feedback, please consider fillin
|
|
|
718
718
|
|
|
719
719
|
## ⭐ Getting Started
|
|
720
720
|
|
|
721
|
-
To get started with _flowR_ and its features, please check out the [Overview](https://github.com/flowr-analysis/flowr/wiki/
|
|
722
|
-
The [Setup](https://github.com/flowr-analysis/flowr/wiki/
|
|
721
|
+
To get started with _flowR_ and its features, please check out the [Overview](https://github.com/flowr-analysis/flowr/wiki/Overview) wiki page.
|
|
722
|
+
The [Setup](https://github.com/flowr-analysis/flowr/wiki/Setup) wiki page explains how you can download and setup _flowR_ on your system.
|
|
723
723
|
With docker 🐳️, the following line should be enough (and drop you directly into the read-eval-print loop):
|
|
724
724
|
|
|
725
725
|
|
|
@@ -747,7 +747,7 @@ If you want to use the same commands:
|
|
|
747
747
|
## 📜 More Information
|
|
748
748
|
|
|
749
749
|
For more details on how to use _flowR_ please refer to the [wiki pages](https://github.com/flowr-analysis/flowr/wiki),
|
|
750
|
-
as well as the deployed [code documentation](https://flowr-analysis.github.io/flowr/
|
|
750
|
+
as well as the deployed [code documentation](https://flowr-analysis.github.io/flowr/doc/).
|
|
751
751
|
To cite flowR, please check out the publications below. To specifically refer to the source code,
|
|
752
752
|
please check out flowR's [Zenodo archive](https://zenodo.org/doi/10.5281/zenodo.13319290).
|
|
753
753
|
|
|
@@ -873,7 +873,7 @@ please check out the following publications (if you find that a paper is missing
|
|
|
873
873
|
|
|
874
874
|
## 🚀 Contributing
|
|
875
875
|
|
|
876
|
-
We welcome every contribution! Please check out the [developer onboarding](https://github.com/flowr-analysis/flowr/wiki/
|
|
876
|
+
We welcome every contribution! Please check out the [developer onboarding](https://github.com/flowr-analysis/flowr/wiki/Onboarding) section in the wiki for all the information you will need.
|
|
877
877
|
|
|
878
878
|
### Contributors
|
|
879
879
|
|
|
@@ -892,6 +892,6 @@ and received an unrestricted gift from [Posit](https://posit.co/), the open-sour
|
|
|
892
892
|
|
|
893
893
|
### Generation Notice
|
|
894
894
|
|
|
895
|
-
Please notice that this file was generated automatically using the file [src/documentation/doc-readme.ts](https://github.com/flowr-analysis/flowr/tree/main
|
|
895
|
+
Please notice that this file was generated automatically using the file [src/documentation/doc-readme.ts](https://github.com/flowr-analysis/flowr/tree/main/src/documentation/doc-readme.ts) as a source.\
|
|
896
896
|
If you want to make changes please edit the source file (the CI will take care of the rest).
|
|
897
897
|
In fact, many files in the [wiki](https://github.com/flowr-analysis/flowr/wiki) are generated, so make sure to check for the source file if you want to make changes.
|
|
@@ -169,9 +169,13 @@ class Environment {
|
|
|
169
169
|
// navigate to parent until either before built-in or matching namespace
|
|
170
170
|
const newEnvironment = this.clone(false);
|
|
171
171
|
let current = newEnvironment;
|
|
172
|
-
|
|
172
|
+
/* the match has to be re-checked after every step: a post-condition on `current.n` would end the loop on
|
|
173
|
+
* the very layer it was looking for, before the body could define anything in it */
|
|
174
|
+
for (;;) {
|
|
173
175
|
if (current.n === ns) {
|
|
174
|
-
|
|
176
|
+
/* every layer walked here is a fresh clone, and `apply` copies the shared memory on write,
|
|
177
|
+
* so this adds to the layer in place -- `define` would clone and the definition would be lost */
|
|
178
|
+
current.apply(identifier_1.Identifier.getName(definition.name), definition);
|
|
175
179
|
return newEnvironment;
|
|
176
180
|
}
|
|
177
181
|
else if (current.parent && !current.parent.builtInEnv) {
|
|
@@ -182,7 +186,7 @@ class Environment {
|
|
|
182
186
|
else {
|
|
183
187
|
break;
|
|
184
188
|
}
|
|
185
|
-
}
|
|
189
|
+
}
|
|
186
190
|
// we did not find the namespace, so we inject a new environment here
|
|
187
191
|
log_1.log.warn(`Defining ${identifier_1.Identifier.getName(definition.name)} in namespace ${ns}, which did not exist yet in the environment chain => create (r should fail or we miss attachment).`);
|
|
188
192
|
const env = new Environment(current.parent);
|
|
@@ -317,24 +321,41 @@ class Environment {
|
|
|
317
321
|
mergePackageBlocks(other) {
|
|
318
322
|
const [thisLayers, thisBase] = splitLibraryLayers(this);
|
|
319
323
|
const [otherLayers, otherBase] = splitLibraryLayers(other);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
+
/*
|
|
325
|
+
* One block is the other plus the packages attached since (blocks grow at the front), so their union is
|
|
326
|
+
* the longer one and it is already in R's order: the most recently attached package is searched first,
|
|
327
|
+
* `library(a); library(b)` resolves `b` before `a`. This is the overwhelmingly common case, since every
|
|
328
|
+
* statement after a `library` call merges two environments that still hold its layers.
|
|
329
|
+
*/
|
|
330
|
+
const keep = layersEndWith(thisLayers, otherLayers) ? thisLayers
|
|
331
|
+
: layersEndWith(otherLayers, thisLayers) ? otherLayers : undefined;
|
|
332
|
+
if (keep !== undefined) {
|
|
324
333
|
const base = thisBase.append(otherBase);
|
|
325
|
-
if (base === thisBase) {
|
|
334
|
+
if (keep === thisLayers && base === thisBase) {
|
|
326
335
|
return this;
|
|
327
336
|
}
|
|
328
|
-
return relinkLayers(
|
|
337
|
+
return relinkLayers(keep.map(l => l.clone(false)), base);
|
|
329
338
|
}
|
|
330
|
-
|
|
339
|
+
/*
|
|
340
|
+
* Neither block is recognizably an extension of the other, so union them. The longer attach history goes
|
|
341
|
+
* first so its order survives and the other block only contributes what it alone saw: R searches the most
|
|
342
|
+
* recently attached package first, and only the longer block still records that order.
|
|
343
|
+
* Keyed by type and then by name, rather than by a `t:n` string built for every layer of every merge.
|
|
344
|
+
*/
|
|
345
|
+
const order = [];
|
|
331
346
|
const merged = new Map();
|
|
332
|
-
for (const layers of [otherLayers, thisLayers]) {
|
|
347
|
+
for (const layers of thisLayers.length > otherLayers.length ? [thisLayers, otherLayers] : [otherLayers, thisLayers]) {
|
|
333
348
|
for (const layer of layers) {
|
|
334
|
-
|
|
335
|
-
|
|
349
|
+
let byName = merged.get(layer.t);
|
|
350
|
+
if (byName === undefined) {
|
|
351
|
+
byName = new Map();
|
|
352
|
+
merged.set(layer.t, byName);
|
|
353
|
+
}
|
|
354
|
+
const existing = byName.get(layer.n);
|
|
336
355
|
if (existing === undefined) {
|
|
337
|
-
|
|
356
|
+
const cloned = layer.clone(false);
|
|
357
|
+
byName.set(layer.n, cloned);
|
|
358
|
+
order.push(cloned);
|
|
338
359
|
}
|
|
339
360
|
else if (existing.memory !== layer.memory) {
|
|
340
361
|
for (const [name, value] of layer.memory) {
|
|
@@ -346,7 +367,7 @@ class Environment {
|
|
|
346
367
|
}
|
|
347
368
|
}
|
|
348
369
|
}
|
|
349
|
-
return relinkLayers(
|
|
370
|
+
return relinkLayers(order, thisBase.append(otherBase));
|
|
350
371
|
}
|
|
351
372
|
remove(id) {
|
|
352
373
|
if (this.builtInEnv) {
|
|
@@ -496,12 +517,27 @@ exports.REnvironment = {
|
|
|
496
517
|
attachedPackages: attachedPackagesOf,
|
|
497
518
|
};
|
|
498
519
|
/**
|
|
499
|
-
* Whether
|
|
500
|
-
*
|
|
501
|
-
*
|
|
520
|
+
* Whether the package block `layers` ends with `tail`, i.e. `tail` is `layers` without some of the attachments
|
|
521
|
+
* made since. A block grows at the front ({@link attachPackageAt} inserts at `search()` position 2), so this is
|
|
522
|
+
* the shape two branches take when one of them attached more packages than the other. Equal blocks qualify.
|
|
523
|
+
*
|
|
524
|
+
* Frames cloned from one another keep the same {@link Environment#memory} map until one of them is written to
|
|
525
|
+
* (see {@link Environment#clone}), so comparing the maps by identity recognizes untouched blocks without
|
|
526
|
+
* scanning them; blocks that only happen to hold equal definitions are treated as different, which merely costs
|
|
527
|
+
* the general union below.
|
|
502
528
|
*/
|
|
503
|
-
function
|
|
504
|
-
|
|
529
|
+
function layersEndWith(layers, tail) {
|
|
530
|
+
const offset = layers.length - tail.length;
|
|
531
|
+
if (offset < 0) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
for (let i = 0; i < tail.length; i++) {
|
|
535
|
+
const l = layers[offset + i], t = tail[i];
|
|
536
|
+
if (l !== t && (l.t !== t.t || l.n !== t.n || l.memory !== t.memory)) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return true;
|
|
505
541
|
}
|
|
506
542
|
/** Stacks `layers` (top first) on top of `base`, returning the new top of the chain. The layers must not be shared. */
|
|
507
543
|
function relinkLayers(layers, base) {
|
|
@@ -20,6 +20,8 @@ const VariableTargetTypes = identifier_1.ReferenceType.Variable | identifier_1.R
|
|
|
20
20
|
const ConstantTargetTypes = identifier_1.ReferenceType.Constant | identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.Unknown;
|
|
21
21
|
const BuiltInConstantTargetTypes = identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.Unknown;
|
|
22
22
|
const BuiltInFunctionTargetTypes = identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.Unknown;
|
|
23
|
+
const inEveryBranch = (d) => (0, info_1.happensInEveryBranch)(d.cds);
|
|
24
|
+
const notAParameter = (d) => d.type !== identifier_1.ReferenceType.Parameter;
|
|
23
25
|
const TargetTypePredicate = {
|
|
24
26
|
[identifier_1.ReferenceType.Unknown]: () => true,
|
|
25
27
|
[identifier_1.ReferenceType.Function]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
|
|
@@ -45,7 +47,10 @@ function resolveByName(id, environment, target) {
|
|
|
45
47
|
if (target === identifier_1.ReferenceType.Unknown) {
|
|
46
48
|
return resolveByNameAnyType(id, environment);
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
/* read piecewise, `Identifier.toArray` would allocate a tuple per resolution */
|
|
51
|
+
const name = identifier_1.Identifier.getName(id);
|
|
52
|
+
const ns = identifier_1.Identifier.getNamespace(id);
|
|
53
|
+
const internal = identifier_1.Identifier.accessesInternal(id);
|
|
49
54
|
let current = environment.current;
|
|
50
55
|
/* `current` can already be the built-in environment itself (e.g. `get(x, envir=baseenv())`);
|
|
51
56
|
* it has no parent to walk to, so resolve directly instead of entering the loop below. */
|
|
@@ -75,11 +80,14 @@ function resolveByName(id, environment, target) {
|
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
if (definition !== undefined && definition.length > 0) {
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
/* ask before filtering: the common case wants all of them and needs no copy */
|
|
84
|
+
const allWanted = definition.every(wantedType);
|
|
85
|
+
if (allWanted && (target !== identifier_1.ReferenceType.Function || definition.every(notAParameter)) && definition.every(inEveryBranch)) {
|
|
80
86
|
return definition;
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
/* never alias the environment's own array, it is appended to below */
|
|
89
|
+
const filtered = allWanted ? definition.slice() : definition.filter(wantedType);
|
|
90
|
+
if (filtered.length > 0) {
|
|
83
91
|
if (definitions) {
|
|
84
92
|
definitions.push(...filtered);
|
|
85
93
|
}
|
|
@@ -111,7 +119,9 @@ function resolveByNameAnyType(id, environment) {
|
|
|
111
119
|
return g;
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
|
-
const
|
|
122
|
+
const name = identifier_1.Identifier.getName(id);
|
|
123
|
+
const ns = identifier_1.Identifier.getNamespace(id);
|
|
124
|
+
const internal = identifier_1.Identifier.accessesInternal(id);
|
|
115
125
|
/* `current` can already be the built-in environment itself */
|
|
116
126
|
if (current.builtInEnv) {
|
|
117
127
|
const ret = current.memory.get(name);
|
|
@@ -132,7 +142,7 @@ function resolveByNameAnyType(id, environment) {
|
|
|
132
142
|
if (internal === false) {
|
|
133
143
|
definition = definition.filter(({ name }) => name === undefined || !identifier_1.Identifier.accessesInternal(name));
|
|
134
144
|
}
|
|
135
|
-
if (definition.every(
|
|
145
|
+
if (definition.every(inEveryBranch)) {
|
|
136
146
|
if (cacheable) {
|
|
137
147
|
environment.current.cache ??= new Map();
|
|
138
148
|
environment.current.cache.set(id, definition);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolveByName, resolveByNameAnyType, resolvesToBuiltInConstant } from './resolve-by-name';
|
|
2
|
+
import { resolveIdToValue, resolveIdToSingleString, resolveToConstants } from '../eval/resolve/alias-tracking';
|
|
3
|
+
import { resolveIdToArgName, resolveIdToArgStringVector, resolveIdToArgValue, resolveIdToArgValueSymbolName, resolveIdToArgVectorLength } from '../../abstract-interpretation/data-frame/resolve-args';
|
|
4
|
+
/**
|
|
5
|
+
* The helper object for resolution: from a name to the definitions it may refer to, and from a node to the
|
|
6
|
+
* value(s) it may hold. Reachable as {@link Dataflow.resolve} as well.
|
|
7
|
+
*
|
|
8
|
+
* Take the narrowest entry point that answers your question, they differ a lot in cost:
|
|
9
|
+
*
|
|
10
|
+
* - {@link Resolve.byName} walks the environment layers once and answers repeat questions from the layer's own
|
|
11
|
+
* lookup cache. Use it whenever the {@link ReferenceType} does not matter.
|
|
12
|
+
* - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
|
|
13
|
+
* Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
|
|
14
|
+
* - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Resolve: {
|
|
17
|
+
readonly name: "Resolve";
|
|
18
|
+
/** Every definition the identifier may refer to, whatever its type. */
|
|
19
|
+
readonly byName: typeof resolveByNameAnyType;
|
|
20
|
+
/** The definitions the identifier may refer to that fit the wanted {@link ReferenceType}. */
|
|
21
|
+
readonly byNameAndType: typeof resolveByName;
|
|
22
|
+
/** Whether the name always, never, or maybe refers to a built-in constant of the given value. */
|
|
23
|
+
readonly toBuiltIn: typeof resolvesToBuiltInConstant;
|
|
24
|
+
/** The constant values the name resolves to. */
|
|
25
|
+
readonly toConstants: typeof resolveToConstants;
|
|
26
|
+
/** The value(s) the node may hold, tracking aliases as the configuration allows. */
|
|
27
|
+
readonly toValue: typeof resolveIdToValue;
|
|
28
|
+
/** The single string the node resolves to, or `undefined` if it is not exactly one. */
|
|
29
|
+
readonly toSingleString: typeof resolveIdToSingleString;
|
|
30
|
+
/** The same, for the arguments of a call. */
|
|
31
|
+
readonly argument: {
|
|
32
|
+
/** The argument's name. */
|
|
33
|
+
readonly name: typeof resolveIdToArgName;
|
|
34
|
+
/** The argument's value. */
|
|
35
|
+
readonly value: typeof resolveIdToArgValue;
|
|
36
|
+
/** The argument's value as a vector of strings. */
|
|
37
|
+
readonly stringVector: typeof resolveIdToArgStringVector;
|
|
38
|
+
/** The argument's value as the name of the symbol it holds. */
|
|
39
|
+
readonly symbolName: typeof resolveIdToArgValueSymbolName;
|
|
40
|
+
/** The length of the vector the argument holds. */
|
|
41
|
+
readonly vectorLength: typeof resolveIdToArgVectorLength;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resolve = void 0;
|
|
4
|
+
const resolve_by_name_1 = require("./resolve-by-name");
|
|
5
|
+
const alias_tracking_1 = require("../eval/resolve/alias-tracking");
|
|
6
|
+
const resolve_args_1 = require("../../abstract-interpretation/data-frame/resolve-args");
|
|
7
|
+
/**
|
|
8
|
+
* The helper object for resolution: from a name to the definitions it may refer to, and from a node to the
|
|
9
|
+
* value(s) it may hold. Reachable as {@link Dataflow.resolve} as well.
|
|
10
|
+
*
|
|
11
|
+
* Take the narrowest entry point that answers your question, they differ a lot in cost:
|
|
12
|
+
*
|
|
13
|
+
* - {@link Resolve.byName} walks the environment layers once and answers repeat questions from the layer's own
|
|
14
|
+
* lookup cache. Use it whenever the {@link ReferenceType} does not matter.
|
|
15
|
+
* - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
|
|
16
|
+
* Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
|
|
17
|
+
* - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
|
|
18
|
+
*/
|
|
19
|
+
exports.Resolve = {
|
|
20
|
+
name: 'Resolve',
|
|
21
|
+
/** Every definition the identifier may refer to, whatever its type. */
|
|
22
|
+
byName: resolve_by_name_1.resolveByNameAnyType,
|
|
23
|
+
/** The definitions the identifier may refer to that fit the wanted {@link ReferenceType}. */
|
|
24
|
+
byNameAndType: resolve_by_name_1.resolveByName,
|
|
25
|
+
/** Whether the name always, never, or maybe refers to a built-in constant of the given value. */
|
|
26
|
+
toBuiltIn: resolve_by_name_1.resolvesToBuiltInConstant,
|
|
27
|
+
/** The constant values the name resolves to. */
|
|
28
|
+
toConstants: alias_tracking_1.resolveToConstants,
|
|
29
|
+
/** The value(s) the node may hold, tracking aliases as the configuration allows. */
|
|
30
|
+
toValue: alias_tracking_1.resolveIdToValue,
|
|
31
|
+
/** The single string the node resolves to, or `undefined` if it is not exactly one. */
|
|
32
|
+
toSingleString: alias_tracking_1.resolveIdToSingleString,
|
|
33
|
+
/** The same, for the arguments of a call. */
|
|
34
|
+
argument: {
|
|
35
|
+
/** The argument's name. */
|
|
36
|
+
name: resolve_args_1.resolveIdToArgName,
|
|
37
|
+
/** The argument's value. */
|
|
38
|
+
value: resolve_args_1.resolveIdToArgValue,
|
|
39
|
+
/** The argument's value as a vector of strings. */
|
|
40
|
+
stringVector: resolve_args_1.resolveIdToArgStringVector,
|
|
41
|
+
/** The argument's value as the name of the symbol it holds. */
|
|
42
|
+
symbolName: resolve_args_1.resolveIdToArgValueSymbolName,
|
|
43
|
+
/** The length of the vector the argument holds. */
|
|
44
|
+
vectorLength: resolve_args_1.resolveIdToArgVectorLength
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=resolve-helper.js.map
|