@eagleoutice/flowr 2.13.5 → 2.13.6
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 +24 -24
- package/dataflow/environments/built-in-props.d.ts +1 -1
- package/dataflow/environments/built-in-props.js +1 -1
- package/dataflow/environments/default-builtin-config.d.ts +22 -2
- package/dataflow/environments/default-builtin-config.js +64 -3
- package/dataflow/eval/resolve/alias-tracking.d.ts +6 -5
- package/dataflow/eval/resolve/alias-tracking.js +41 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -4
- package/documentation/wiki-core.js +34 -18
- package/linter/rules/seeded-randomness.js +1 -1
- package/linter/rules/unused-definition.js +29 -17
- package/package.json +2 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +4 -0
- package/project/context/flowr-analyzer-dependencies-context.js +28 -10
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ It offers a wide variety of features, for example:
|
|
|
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.5, R grammar v14 (tree-sitter engine)
|
|
47
47
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -52,12 +52,12 @@ It offers a wide variety of features, for example:
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
```text
|
|
55
|
-
Query: linter (
|
|
55
|
+
Query: linter (22 ms)
|
|
56
56
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
57
57
|
╰ File Path Validity (file-path-validity):
|
|
58
58
|
╰ certain:
|
|
59
59
|
╰ Path `/root/x.txt` at 1.1-23
|
|
60
|
-
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
60
|
+
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 1
|
|
61
61
|
╰ Seeded Randomness (seeded-randomness): no findings
|
|
62
62
|
╰ Absolute Paths (absolute-file-paths):
|
|
63
63
|
╰ 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 ≈22 ms (1ms accuracy, total 22 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** (19 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: 1, 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: 0\
|
|
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 ≈19 ms (1ms accuracy, total 21 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 _20.5 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": 3,
|
|
141
|
+
"processTimeMs": 5
|
|
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": 1,
|
|
164
164
|
"processTimeMs": 1
|
|
165
165
|
}
|
|
166
166
|
},
|
|
@@ -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": 0
|
|
197
197
|
}
|
|
198
198
|
},
|
|
@@ -209,7 +209,7 @@ It offers a wide variety of features, for example:
|
|
|
209
209
|
".meta": {
|
|
210
210
|
"totalCalls": 0,
|
|
211
211
|
"totalFunctionDefinitions": 0,
|
|
212
|
-
"searchTimeMs":
|
|
212
|
+
"searchTimeMs": 1,
|
|
213
213
|
"processTimeMs": 0
|
|
214
214
|
}
|
|
215
215
|
},
|
|
@@ -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": 1
|
|
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
|
},
|
|
@@ -241,7 +241,7 @@ It offers a wide variety of features, for example:
|
|
|
241
241
|
"problematic-inputs": {
|
|
242
242
|
"results": [],
|
|
243
243
|
".meta": {
|
|
244
|
-
"searchTimeMs":
|
|
244
|
+
"searchTimeMs": 0,
|
|
245
245
|
"processTimeMs": 0
|
|
246
246
|
}
|
|
247
247
|
},
|
|
@@ -286,11 +286,11 @@ It offers a wide variety of features, for example:
|
|
|
286
286
|
}
|
|
287
287
|
},
|
|
288
288
|
".meta": {
|
|
289
|
-
"timing":
|
|
289
|
+
"timing": 19
|
|
290
290
|
}
|
|
291
291
|
},
|
|
292
292
|
".meta": {
|
|
293
|
-
"timing":
|
|
293
|
+
"timing": 19
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
```
|
|
@@ -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.5, 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 ≈7 ms (1ms accuracy, total 8 ms)
|
|
372
372
|
```
|
|
373
373
|
|
|
374
374
|
|
|
@@ -383,7 +383,7 @@ 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!">105.1 ms</span></i> (as of Jul 29, 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
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
|
|
|
@@ -419,7 +419,7 @@ It offers a wide variety of features, for example:
|
|
|
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.5, 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 _3.
|
|
695
|
+
(The analysis required _3.5 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
|
|
|
@@ -47,7 +47,7 @@ export declare enum CallProp {
|
|
|
47
47
|
Throws = 4,
|
|
48
48
|
/** returns invisibly, so the result is not auto-printed */
|
|
49
49
|
Invisible = 8,
|
|
50
|
-
/** dispatches on the class of
|
|
50
|
+
/** dispatches on the class of an argument (S3, S4, or S7), a group generic like `+` on either operand */
|
|
51
51
|
Generic = 16,
|
|
52
52
|
/** a method that is reached by dispatch, like `print.foo` (see {@link SigDbInferable}) */
|
|
53
53
|
Method = 32,
|
|
@@ -55,7 +55,7 @@ var CallProp;
|
|
|
55
55
|
CallProp[CallProp["Throws"] = 4] = "Throws";
|
|
56
56
|
/** returns invisibly, so the result is not auto-printed */
|
|
57
57
|
CallProp[CallProp["Invisible"] = 8] = "Invisible";
|
|
58
|
-
/** dispatches on the class of
|
|
58
|
+
/** dispatches on the class of an argument (S3, S4, or S7), a group generic like `+` on either operand */
|
|
59
59
|
CallProp[CallProp["Generic"] = 16] = "Generic";
|
|
60
60
|
/** a method that is reached by dispatch, like `print.foo` (see {@link SigDbInferable}) */
|
|
61
61
|
CallProp[CallProp["Method"] = 32] = "Method";
|
|
@@ -43,9 +43,25 @@ export declare const PlotFunctionsWithAddParam: Set<string>;
|
|
|
43
43
|
export declare const GraphicsPlotAddons: string[];
|
|
44
44
|
export declare const GgPlotAddons: string[];
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
|
|
47
|
+
* `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
|
|
48
|
+
* `Ops` is what S3 calls the union of the three S4 groups it splits into.
|
|
49
|
+
*/
|
|
50
|
+
export declare const RGroupGenerics: {
|
|
51
|
+
readonly Arith: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%"];
|
|
52
|
+
readonly Compare: readonly ["==", "!=", "<", "<=", ">", ">="];
|
|
53
|
+
readonly Logic: readonly ["&", "|"];
|
|
54
|
+
readonly Ops: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%", "==", "!=", "<", "<=", ">", ">=", "&", "|", "!"];
|
|
55
|
+
readonly Math: readonly ["abs", "sign", "sqrt", "floor", "ceiling", "trunc", "exp", "expm1", "log", "log2", "log10", "log1p", "cos", "sin", "tan", "cosh", "sinh", "tanh", "acos", "asin", "atan", "acosh", "asinh", "atanh", "cumsum", "cumprod", "cummax", "cummin"];
|
|
56
|
+
readonly Math2: readonly ["round", "signif"];
|
|
57
|
+
readonly Summary: readonly ["any", "sum", "prod", "min", "max", "range"];
|
|
58
|
+
readonly Complex: readonly ["Re", "Im", "Mod", "Arg", "Conj"];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
|
|
62
|
+
* is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
|
|
47
63
|
*/
|
|
48
|
-
export declare const
|
|
64
|
+
export declare const WrittenBuiltinDefinitions: [{
|
|
49
65
|
readonly type: "constant";
|
|
50
66
|
readonly names: Identifier[];
|
|
51
67
|
readonly value: null;
|
|
@@ -2392,6 +2408,10 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
2392
2408
|
readonly props: CallProp.Scope;
|
|
2393
2409
|
};
|
|
2394
2410
|
}];
|
|
2411
|
+
/**
|
|
2412
|
+
* Contains the built-in definitions recognized by flowR
|
|
2413
|
+
*/
|
|
2414
|
+
export declare const DefaultBuiltinConfig: import("./built-in-config").BuiltInDefinition<BuiltInProcName.Access | BuiltInProcName.Apply | BuiltInProcName.Assignment | BuiltInProcName.AssignmentLike | BuiltInProcName.DefineArgument | BuiltInProcName.Default | BuiltInProcName.DefaultReadAllArgs | BuiltInProcName.Eval | BuiltInProcName.ExpressionList | BuiltInProcName.ForLoop | BuiltInProcName.FunctionDefinition | BuiltInProcName.Get | BuiltInProcName.IfThenElse | BuiltInProcName.Library | BuiltInProcName.List | BuiltInProcName.Load | BuiltInProcName.Local | BuiltInProcName.NamespaceAccess | BuiltInProcName.Pipe | BuiltInProcName.PurrrFormula | BuiltInProcName.Quote | BuiltInProcName.Recall | BuiltInProcName.RegisterHook | BuiltInProcName.RepeatLoop | BuiltInProcName.Replacement | BuiltInProcName.Rm | BuiltInProcName.S3Dispatch | BuiltInProcName.S7NewGeneric | BuiltInProcName.S7Dispatch | BuiltInProcName.S7MakeConstructor | BuiltInProcName.Source | BuiltInProcName.SpecialBinOp | BuiltInProcName.StackEnv | BuiltInProcName.StopIfNot | BuiltInProcName.Try | BuiltInProcName.Attach | BuiltInProcName.NewEnv | BuiltInProcName.ClassGenerator | BuiltInProcName.Vector | BuiltInProcName.WhileLoop | BuiltInProcName.With>[];
|
|
2395
2415
|
/**
|
|
2396
2416
|
* Expensive and naive lookup of the default processor for a built-in function name
|
|
2397
2417
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultBuiltinConfig = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
|
|
3
|
+
exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.RGroupGenerics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
|
|
4
4
|
exports.getDefaultProcessor = getDefaultProcessor;
|
|
5
5
|
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
6
6
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -13,6 +13,7 @@ const built_in_eval_name_1 = require("./built-in-eval-name");
|
|
|
13
13
|
const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
|
|
14
14
|
const data_masking_functions_1 = require("./data-masking-functions");
|
|
15
15
|
const built_in_props_1 = require("./built-in-props");
|
|
16
|
+
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
16
17
|
/** Which stack environment an env-returning/-transforming builtin denotes (see {@link StackEnvBuiltins}). */
|
|
17
18
|
var StackEnvKind;
|
|
18
19
|
(function (StackEnvKind) {
|
|
@@ -135,10 +136,66 @@ const LinkToLastPlot = {
|
|
|
135
136
|
type: 'link-to-last-call',
|
|
136
137
|
callName: toRegex(GraphicDeviceOpen.concat(exports.PlotCreate, PlotAddons, exports.GgPlotAddons, exports.TinyPlotAddons))
|
|
137
138
|
};
|
|
139
|
+
const Arith = ['+', '-', '*', '/', '^', '**', '%%', '%/%'];
|
|
140
|
+
const Compare = ['==', '!=', '<', '<=', '>', '>='];
|
|
141
|
+
const Logic = ['&', '|'];
|
|
138
142
|
/**
|
|
139
|
-
*
|
|
143
|
+
* R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
|
|
144
|
+
* `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
|
|
145
|
+
* `Ops` is what S3 calls the union of the three S4 groups it splits into.
|
|
146
|
+
*/
|
|
147
|
+
exports.RGroupGenerics = {
|
|
148
|
+
Arith, Compare, Logic,
|
|
149
|
+
Ops: [...Arith, ...Compare, ...Logic, '!'],
|
|
150
|
+
Math: ['abs', 'sign', 'sqrt', 'floor', 'ceiling', 'trunc', 'exp', 'expm1', 'log', 'log2', 'log10', 'log1p',
|
|
151
|
+
'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'acos', 'asin', 'atan', 'acosh', 'asinh', 'atanh',
|
|
152
|
+
'cumsum', 'cumprod', 'cummax', 'cummin'],
|
|
153
|
+
Math2: ['round', 'signif'],
|
|
154
|
+
Summary: ['any', 'sum', 'prod', 'min', 'max', 'range'],
|
|
155
|
+
Complex: ['Re', 'Im', 'Mod', 'Arg', 'Conj']
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Every R generic flowR states a built-in for: the {@link RGroupGenerics} members, the `.S3PrimitiveGenerics` and
|
|
159
|
+
* internal generics (which have no R body, so {@link fnInfoFromSignature} could never see them), and the
|
|
160
|
+
* `UseMethod` closures flowR models itself, as its own definition hides the one in the signature database.
|
|
161
|
+
* The `<-` forms are left out, one replacement definition covers many names.
|
|
162
|
+
* `npm run check:generic-labels` (part of `checkup`) compares this against a synced database.
|
|
140
163
|
*/
|
|
141
|
-
|
|
164
|
+
const RGenerics = new Set([
|
|
165
|
+
...Object.values(exports.RGroupGenerics).flat(), '%*%',
|
|
166
|
+
'c', 'length', 'dim', 'dimnames', 'names', 'rep', 'seq.int', '[', '[[', '$', '@',
|
|
167
|
+
'as.call', 'as.character', 'as.complex', 'as.double', 'as.environment', 'as.integer', 'as.logical',
|
|
168
|
+
'as.numeric', 'as.raw', 'is.na', 'is.nan', 'is.finite', 'is.infinite', 'is.matrix', 'is.numeric',
|
|
169
|
+
'aperm', 'as.array', 'as.data.frame', 'as.expression', 'as.list', 'as.matrix', 'cbind', 'rbind', 'diff',
|
|
170
|
+
'duplicated', 'format', 'head', 'tail', 'mean', 'median', 'na.omit', 'print', 'quantile', 'rev', 'seq',
|
|
171
|
+
'simulate', 'solve', 'sort', 'subset', 't', 'transform', 'unique', 'with', 'within',
|
|
172
|
+
'plot', 'lines', 'points', 'text', 'image', 'contour', 'persp', 'hist', 'barplot', 'boxplot', 'density',
|
|
173
|
+
'pairs', 'qqnorm', 'mosaicplot', 'spineplot', 'stripchart', 'sunflowerplot'
|
|
174
|
+
]);
|
|
175
|
+
/** Label every {@link RGenerics} {@link CallProp.Generic}, splitting an entry that mixes them with names that do not dispatch (`&` does, `&&` does not). */
|
|
176
|
+
function markGenerics(definitions) {
|
|
177
|
+
return definitions.flatMap((def) => {
|
|
178
|
+
if (def.type !== 'function') {
|
|
179
|
+
return [def];
|
|
180
|
+
}
|
|
181
|
+
/* the attached base packages are the ones whose namespace layer a registered built-in hides, so their
|
|
182
|
+
* label is the only thing left stating the dispatch */
|
|
183
|
+
const dispatches = (name) => RGenerics.has(identifier_1.Identifier.getName(name))
|
|
184
|
+
&& r_base_packages_1.AttachedBasePackages.includes(identifier_1.Identifier.getNamespace(name) ?? "base" /* PkgName.Base */);
|
|
185
|
+
const generics = def.names.filter(dispatches);
|
|
186
|
+
if (generics.length === 0) {
|
|
187
|
+
return [def];
|
|
188
|
+
}
|
|
189
|
+
const rest = def.names.filter(n => !dispatches(n));
|
|
190
|
+
const labeled = { ...def, names: generics, config: { ...def.config, props: (def.config?.props ?? 0) | built_in_props_1.CallProp.Generic } };
|
|
191
|
+
return rest.length === 0 ? [labeled] : [labeled, { ...def, names: rest }];
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
|
|
196
|
+
* is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
|
|
197
|
+
*/
|
|
198
|
+
exports.WrittenBuiltinDefinitions = [
|
|
142
199
|
{ type: 'constant', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['NULL', 'NA', 'NA_integer_', 'NA_real_', 'NA_complex_', 'NA_character_']), value: null, assumePrimitive: true },
|
|
143
200
|
{ type: 'constant', names: [identifier_1.Identifier.from(['NaN', "base" /* PkgName.Base */])], value: NaN, assumePrimitive: true },
|
|
144
201
|
{ type: 'constant', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['.GlobalEnv', '.BaseNamespaceEnv', '.BaseEnv']), value: null, assumePrimitive: true },
|
|
@@ -1057,6 +1114,10 @@ exports.DefaultBuiltinConfig = [
|
|
|
1057
1114
|
config: { readIndices: false, props: built_in_props_1.CallProp.Scope }
|
|
1058
1115
|
},
|
|
1059
1116
|
];
|
|
1117
|
+
/**
|
|
1118
|
+
* Contains the built-in definitions recognized by flowR
|
|
1119
|
+
*/
|
|
1120
|
+
exports.DefaultBuiltinConfig = markGenerics(exports.WrittenBuiltinDefinitions);
|
|
1060
1121
|
/**
|
|
1061
1122
|
* Expensive and naive lookup of the default processor for a built-in function name
|
|
1062
1123
|
*/
|
|
@@ -76,13 +76,14 @@ export declare function trackAliasInEnvironments(identifier: Identifier | undefi
|
|
|
76
76
|
* Please use {@link resolveIdToValue}
|
|
77
77
|
*
|
|
78
78
|
* Tries to resolve the value of a node by traversing the dataflow graph
|
|
79
|
-
* @param id
|
|
80
|
-
* @param ctx
|
|
81
|
-
* @param graph
|
|
82
|
-
* @param idMap
|
|
79
|
+
* @param id - node to resolve
|
|
80
|
+
* @param ctx - analysis context
|
|
81
|
+
* @param graph - dataflow graph
|
|
82
|
+
* @param idMap - idmap of dataflow graph
|
|
83
|
+
* @param blocked - the ids already being resolved, so a cyclic definition stops
|
|
83
84
|
* @returns Value of node or Top/Bottom
|
|
84
85
|
*/
|
|
85
|
-
export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap): ResolveResult;
|
|
86
|
+
export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap, blocked?: Set<NodeId>): ResolveResult;
|
|
86
87
|
/**
|
|
87
88
|
* Please use {@link resolveIdToValue}
|
|
88
89
|
*
|
|
@@ -146,7 +146,7 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
|
|
|
146
146
|
return trackAliasInEnvironments(identifier_1.Identifier.toString(node.content), environment, { idMap, resolve, ctx, graph, blocked });
|
|
147
147
|
}
|
|
148
148
|
else if (graph && resolve === config_1.VariableResolve.Alias) {
|
|
149
|
-
return trackAliasesInGraph(node.info.id, graph, ctx, idMap);
|
|
149
|
+
return trackAliasesInGraph(node.info.id, graph, ctx, idMap, blocked);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
return r_value_1.Top;
|
|
@@ -207,7 +207,15 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
|
|
|
207
207
|
for (const alias of def.value) {
|
|
208
208
|
const definitionOfAlias = idMap?.get(alias);
|
|
209
209
|
if (definitionOfAlias !== undefined) {
|
|
210
|
-
|
|
210
|
+
/* the environment attempt below marks what it visited as blocked, so the retry starts from a copy */
|
|
211
|
+
const beforeAttempt = blocked === undefined ? undefined : new Set(blocked);
|
|
212
|
+
let value = (0, resolve_1.resolveNode)({ resolve, node: definitionOfAlias, ctx, environment, graph, idMap, blocked });
|
|
213
|
+
if ((0, r_value_1.isTop)(value) && graph?.unknownSideEffects.size === 0) {
|
|
214
|
+
/* `x <- x + 1`: the environment holds only the definition we are resolving, so its own operand
|
|
215
|
+
* finds nothing there, while the graph still knows which definition that operand reads. Only
|
|
216
|
+
* when nothing unknown happened, as then the environment is right to give up */
|
|
217
|
+
value = (0, resolve_1.resolveNode)({ resolve, node: definitionOfAlias, ctx, graph, idMap, blocked: beforeAttempt });
|
|
218
|
+
}
|
|
211
219
|
if ((0, r_value_1.isTop)(value)) {
|
|
212
220
|
return r_value_1.Top;
|
|
213
221
|
}
|
|
@@ -258,17 +266,23 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
|
|
|
258
266
|
function isNestedInLoop(node, ast) {
|
|
259
267
|
return model_1.RNode.iterateParents(node, ast).some(model_1.RLoopConstructs.is);
|
|
260
268
|
}
|
|
269
|
+
/** whether the node is (or sits in) a parameter's default, which any call site may override */
|
|
270
|
+
function isParameterDefault(node, idMap) {
|
|
271
|
+
return node !== undefined && (node.info.role === "param-v" /* RoleInParent.ParameterDefaultValue */
|
|
272
|
+
|| model_1.RNode.iterateParents(node, idMap).some(p => p.info.role === "param-v" /* RoleInParent.ParameterDefaultValue */));
|
|
273
|
+
}
|
|
261
274
|
/**
|
|
262
275
|
* Please use {@link resolveIdToValue}
|
|
263
276
|
*
|
|
264
277
|
* Tries to resolve the value of a node by traversing the dataflow graph
|
|
265
|
-
* @param id
|
|
266
|
-
* @param ctx
|
|
267
|
-
* @param graph
|
|
268
|
-
* @param idMap
|
|
278
|
+
* @param id - node to resolve
|
|
279
|
+
* @param ctx - analysis context
|
|
280
|
+
* @param graph - dataflow graph
|
|
281
|
+
* @param idMap - idmap of dataflow graph
|
|
282
|
+
* @param blocked - the ids already being resolved, so a cyclic definition stops
|
|
269
283
|
* @returns Value of node or Top/Bottom
|
|
270
284
|
*/
|
|
271
|
-
function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
285
|
+
function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
|
|
272
286
|
if (!graph.get(id)) {
|
|
273
287
|
return r_value_1.Bottom;
|
|
274
288
|
}
|
|
@@ -280,6 +294,8 @@ function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
|
280
294
|
queue.add(id, clean, cleanFingerprint, false);
|
|
281
295
|
let forceTop = false;
|
|
282
296
|
const resultIds = [];
|
|
297
|
+
/* what a call the walk ended in folds to, see below */
|
|
298
|
+
const folded = [];
|
|
283
299
|
while (queue.nonEmpty()) {
|
|
284
300
|
const { id, baseEnvironment } = queue.next();
|
|
285
301
|
const vertex = graph.getVertex(id);
|
|
@@ -304,6 +320,11 @@ function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
|
304
320
|
break;
|
|
305
321
|
}
|
|
306
322
|
const t = vertex.tag;
|
|
323
|
+
/* a replacement (`df[1] <- v`) defines its target from just a part of it, so what it is defined by is not
|
|
324
|
+
* the value of the target */
|
|
325
|
+
if (t === vertex_1.VertexType.VariableDefinition && idMap.get(id)?.info.role === "acc" /* RoleInParent.Accessed */) {
|
|
326
|
+
return r_value_1.Top;
|
|
327
|
+
}
|
|
307
328
|
if (t === vertex_1.VertexType.Value || t === vertex_1.VertexType.FunctionDefinition) {
|
|
308
329
|
resultIds.push(id);
|
|
309
330
|
continue;
|
|
@@ -326,13 +347,22 @@ function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
|
326
347
|
}
|
|
327
348
|
}
|
|
328
349
|
if (isFn && !foundRetuns) {
|
|
329
|
-
|
|
350
|
+
/* a call that hands back none of its arguments has no `Returns` edge to follow, yet the value solver may
|
|
351
|
+
* well know what it produces (`p <- file.path("data", "x.csv")`), so we fold it instead of giving up */
|
|
352
|
+
const node = idMap.get(id);
|
|
353
|
+
const values = isParameterDefault(node, idMap) ? undefined
|
|
354
|
+
: (0, general_1.valueSetGuard)(resolveIdToValue(node, { graph, idMap, ctx, resolve: config_1.VariableResolve.Alias, blocked }));
|
|
355
|
+
if (values === undefined || values.elements.some(r_value_1.isTop)) {
|
|
356
|
+
return r_value_1.Top;
|
|
357
|
+
}
|
|
358
|
+
folded.push(...values.elements);
|
|
359
|
+
continue;
|
|
330
360
|
}
|
|
331
361
|
}
|
|
332
|
-
if (forceTop || resultIds.length === 0) {
|
|
362
|
+
if (forceTop || (resultIds.length === 0 && folded.length === 0)) {
|
|
333
363
|
return r_value_1.Top;
|
|
334
364
|
}
|
|
335
|
-
const values = new Set();
|
|
365
|
+
const values = new Set(folded);
|
|
336
366
|
for (const id of resultIds) {
|
|
337
367
|
const vertex = graph.getVertex(id);
|
|
338
368
|
if (vertex_1.ValueVertex.is(vertex) && vertex.value !== undefined) {
|
|
@@ -341,7 +371,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
|
341
371
|
}
|
|
342
372
|
const node = idMap.get(id);
|
|
343
373
|
if (node !== undefined) {
|
|
344
|
-
if (
|
|
374
|
+
if (isParameterDefault(node, idMap)) {
|
|
345
375
|
return r_value_1.Top;
|
|
346
376
|
}
|
|
347
377
|
values.add((0, general_1.valueFromRNodeConstant)(node));
|
|
@@ -155,15 +155,12 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
155
155
|
origin: built_in_proc_name_1.BuiltInProcName.Library
|
|
156
156
|
}).information;
|
|
157
157
|
for (const p of packetName) {
|
|
158
|
-
const dependency = data.ctx.deps.
|
|
158
|
+
const dependency = data.ctx.deps.loadDependency(p);
|
|
159
159
|
if (dependency) {
|
|
160
160
|
linkLibrary(dependency, info, rootId, data, spec);
|
|
161
161
|
}
|
|
162
162
|
else {
|
|
163
163
|
info.graph.markIdForUnknownSideEffects(rootId);
|
|
164
|
-
// no database resolves the package, but the load is syntactically known: record it so an explicit
|
|
165
|
-
// `p::fn` can still link back to this call. requireNamespace/loadNamespace are recorded too, since
|
|
166
|
-
// they equally make `p::fn` valid.
|
|
167
164
|
if (info.environment.level >= 0) {
|
|
168
165
|
info.environment = recordUnresolvedLibraryLoad(info.environment, p, rootId, spec.pos, data.cds);
|
|
169
166
|
}
|
|
@@ -110,11 +110,8 @@ function propNames(mask) {
|
|
|
110
110
|
return Object.entries(built_in_props_1.CallProp).filter(([, b]) => typeof b === 'number' && (b & mask) !== 0)
|
|
111
111
|
.map(([n]) => `\`${n}\``).join(', ');
|
|
112
112
|
}
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
* how many built-ins carry it, and which of them the signature database can state on its own.
|
|
116
|
-
*/
|
|
117
|
-
function builtInPropsTables(ctx) {
|
|
113
|
+
/** The "Labeling the Built-Ins" section of the Core page, with a table per enum taken from the configuration. */
|
|
114
|
+
function builtInLabelsSection(ctx) {
|
|
118
115
|
const index = query_fn_props_1.BuiltInIndex.default();
|
|
119
116
|
/* the doc comment of a bit is its explanation, flattened to fit a table cell; bits nothing carries are left out */
|
|
120
117
|
const table = (type, of) => [
|
|
@@ -130,7 +127,34 @@ function builtInPropsTables(ctx) {
|
|
|
130
127
|
return `| \`${name}\`${db} | ${of(bit)} | ${doc} |`;
|
|
131
128
|
})
|
|
132
129
|
].join('\n');
|
|
133
|
-
return
|
|
130
|
+
return `#### Labeling the Built-Ins
|
|
131
|
+
|
|
132
|
+
Besides the processor, an entry says what the function *is*, in two label vocabularies:
|
|
133
|
+
|
|
134
|
+
* ${ctx.link('CallProp')} labels the call as a whole (\`props\`): whether it is pure, whether it throws, whether it
|
|
135
|
+
touches the file system, whether it dispatches, and so on. \`print\` is \`Invisible | Generic | Prints\`; R's
|
|
136
|
+
primitive generics (\`+\`, \`sin\`, \`length\`, ...) are \`Pure | Generic\`, and as they have no R body, the store is
|
|
137
|
+
the only place that can say they dispatch.
|
|
138
|
+
* ${ctx.link('ArgProp')} labels each parameter (\`sig\`), in the order R declares them: which one carries the data,
|
|
139
|
+
which one only selects a behavior, which one names a file, which one is called as a function.
|
|
140
|
+
|
|
141
|
+
For several analyses the labels are all they know about a call: ${ctx.link(query_fn_props_1.BuiltInIndex.name)} turns them into the
|
|
142
|
+
questions callers ask over and over (\`with\`, \`without\`, \`params\`), which is how the
|
|
143
|
+
${ctx.linkPage('wiki/Query API', 'input-sources query')} knows which functions bring in data of their own, and how
|
|
144
|
+
${ctx.linkPage('wiki/Linter', 'linting rules')} like *seeded randomness* find every call drawing from the RNG without
|
|
145
|
+
naming a single one of them. Labeling a built-in therefore teaches all of them at once.
|
|
146
|
+
|
|
147
|
+
So \`lapply\` is pure on its own but runs what it is handed, and says which argument that is:
|
|
148
|
+
|
|
149
|
+
${(0, doc_code_1.codeBlock)('ts', `{ type: 'function', names: Identifier.fromAll(PkgName.Base, ['lapply', 'sapply', 'vapply']),
|
|
150
|
+
processor: BuiltInProcName.Apply,
|
|
151
|
+
config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true,
|
|
152
|
+
props: CallProp.MayPure, sig: [['X', ArgProp.Value], ['FUN', ArgProp.Callee]] } }`)}
|
|
153
|
+
|
|
154
|
+
The two tables below are generated from the configuration itself, so they always list every label that exists,
|
|
155
|
+
what it means, and how many built-ins carry it.
|
|
156
|
+
|
|
157
|
+
${(0, doc_structure_1.details)('What each call property means', `<sup>db</sup> marks the bits the ${ctx.linkPage('wiki/Signature Database', 'signature database')}
|
|
134
158
|
states for any package function on its own (${ctx.link(query_fn_props_1.inferFnProps.name)} reads them off an entry and carries what a
|
|
135
159
|
function calls over to the function calling it).
|
|
136
160
|
|
|
@@ -150,13 +174,6 @@ them, with \`...\` covering every position from where it appears. The count is h
|
|
|
150
174
|
parameter in that role.
|
|
151
175
|
|
|
152
176
|
${table('ArgProp', bit => new Set(index.params(bit).map(p => p.call)).size)}`)}
|
|
153
|
-
|
|
154
|
-
So \`lapply\` is pure on its own but runs what it is handed, and says which argument that is:
|
|
155
|
-
|
|
156
|
-
${(0, doc_code_1.codeBlock)('ts', `{ type: 'function', names: Identifier.fromAll(PkgName.Base, ['lapply', 'sapply', 'vapply']),
|
|
157
|
-
processor: BuiltInProcName.Apply,
|
|
158
|
-
config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true,
|
|
159
|
-
props: CallProp.MayPure, sig: [['X', ArgProp.Value], ['FUN', ArgProp.Callee]] } }`)}
|
|
160
177
|
`;
|
|
161
178
|
}
|
|
162
179
|
/**
|
|
@@ -200,6 +217,7 @@ See the ${ctx.linkPage('wiki/FAQ', 'FAQ')} (*How to get flowR to talk?*) for mor
|
|
|
200
217
|
* [Parsing](#parsing)
|
|
201
218
|
* [Normalization](#normalization)
|
|
202
219
|
* [Dataflow Graph Generation](#dataflow-graph-generation)
|
|
220
|
+
* [Labeling the Built-Ins](#labeling-the-built-ins)
|
|
203
221
|
* [Beyond the Dataflow Graph](#beyond-the-dataflow-graph)
|
|
204
222
|
* [Static Backward Slicing](#static-backward-slicing)
|
|
205
223
|
* [Gas (Resource Guard)](#gas-resource-guard)
|
|
@@ -482,12 +500,10 @@ by mapping function names to ${ctx.link('BuiltInProcessorMapper')} functions.
|
|
|
482
500
|
There you can find functions like ${ctx.link(built_in_access_1.processAccess)} which handles the (subset) access to a variable,
|
|
483
501
|
or ${ctx.link(built_in_for_loop_1.processForLoop)} which handles the primitive for loop construct (whenever it is not overwritten).
|
|
484
502
|
|
|
485
|
-
Besides the processor, an entry states what the function does with ${ctx.link('BuiltInFnInfo')}
|
|
486
|
-
|
|
487
|
-
with \`...\` covering every position from where it appears). Anything you add there is picked up by ${ctx.link(query_fn_props_1.BuiltInIndex.name)},
|
|
488
|
-
which is how the ${ctx.linkPage('wiki/Query API', 'input-sources query')} learns which functions bring in data of their own.
|
|
503
|
+
Besides the processor, an entry states what the function does with ${ctx.link('BuiltInFnInfo')} -- see
|
|
504
|
+
[Labeling the Built-Ins](#labeling-the-built-ins) below for the labels it may carry.
|
|
489
505
|
|
|
490
|
-
${
|
|
506
|
+
${builtInLabelsSection(ctx)}
|
|
491
507
|
|
|
492
508
|
Just as an example, we want to have a look at the ${ctx.link(built_in_repeat_loop_1.processRepeatLoop)} function, as it is one of the simplest built-in processors
|
|
493
509
|
we have:
|
|
@@ -158,7 +158,7 @@ exports.SEEDED_RANDOMNESS = {
|
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
160
|
function getDefaultAssignments() {
|
|
161
|
-
return default_builtin_config_1.DefaultBuiltinConfig.filter(b => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
|
|
161
|
+
return default_builtin_config_1.DefaultBuiltinConfig.filter((b) => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
|
|
162
162
|
}
|
|
163
163
|
function isConstantArgument(graph, call, argIndex, ctx) {
|
|
164
164
|
const args = call.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.FunctionArgument.getReference);
|
|
@@ -14,26 +14,37 @@ const flowr_namespace_file_1 = require("../../project/plugins/file-plugins/files
|
|
|
14
14
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
15
15
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
16
16
|
const retriever_1 = require("../../r-bridge/retriever");
|
|
17
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
18
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
19
|
+
const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
|
|
17
20
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
18
21
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
19
22
|
/**
|
|
20
23
|
* The dots parameter is a special parameter and must never be reported as an unused definition.
|
|
21
24
|
*/
|
|
22
25
|
const DotsParameter = '...';
|
|
26
|
+
/** the standard-library S3 generics flowR models no built-in for, so the store cannot state them */
|
|
27
|
+
const OtherKnownS3Generics = new Set([
|
|
28
|
+
'summary', 'coef', 'vcov', 'residuals', 'fitted', 'predict', 'as.vector', 'str', 'toString', 'all.equal',
|
|
29
|
+
'aggregate', 'update', 'anova', 'confint', 'logLik', 'AIC', 'BIC', 'deviance', 'df.residual',
|
|
30
|
+
'model.matrix', 'terms', 'weights', 'merge', 'split', 'window'
|
|
31
|
+
]);
|
|
32
|
+
let knownS3Generics;
|
|
23
33
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* without a
|
|
34
|
+
* Whether a definition named `name.class` may be an S3 method: `name` is a built-in flowR labels
|
|
35
|
+
* {@link CallProp.Generic} or one of {@link OtherKnownS3Generics}. Such a method is dispatched indirectly
|
|
36
|
+
* (`print(x)` on an object of that class), so it is used without a textual call.
|
|
27
37
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
function isKnownS3Generic(name) {
|
|
39
|
+
knownS3Generics ??= new Set([...OtherKnownS3Generics, ...Object.keys(default_builtin_config_1.RGroupGenerics),
|
|
40
|
+
...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.CallProp.Generic).map(g => identifier_1.Identifier.getName(g))]);
|
|
41
|
+
return knownS3Generics.has(name);
|
|
42
|
+
}
|
|
43
|
+
/** Whether `generic`, or any member of it when it is a group generic (`Ops.cls` dispatches on `+`), is called. */
|
|
44
|
+
function isDispatched(generic, called) {
|
|
45
|
+
const group = default_builtin_config_1.RGroupGenerics[generic];
|
|
46
|
+
return called.has(generic) || (group?.some(member => called.has(member)) ?? false);
|
|
47
|
+
}
|
|
37
48
|
/**
|
|
38
49
|
* R package lifecycle hooks called automatically by R's package machinery.
|
|
39
50
|
* These functions are invoked by the package system, so they are used even without textual callers.
|
|
@@ -104,8 +115,9 @@ function isConsideredUsed(lexeme, config, pkg, called) {
|
|
|
104
115
|
if (lexeme === undefined) {
|
|
105
116
|
return false;
|
|
106
117
|
}
|
|
107
|
-
// non-syntactic definition names (e.g. S3 methods like `"[.irts"`) carry their R quotes in the lexeme
|
|
108
|
-
const
|
|
118
|
+
// non-syntactic definition names (e.g. S3 methods like `"[.irts"`) carry their R quotes or backticks in the lexeme
|
|
119
|
+
const unquoted = (0, retriever_1.removeRQuotes)(lexeme);
|
|
120
|
+
const name = unquoted.length > 1 && unquoted.startsWith('`') && unquoted.endsWith('`') ? unquoted.slice(1, -1) : unquoted;
|
|
109
121
|
// the dots are a special parameter and must never be reported
|
|
110
122
|
if (name === DotsParameter) {
|
|
111
123
|
return true;
|
|
@@ -114,10 +126,10 @@ function isConsideredUsed(lexeme, config, pkg, called) {
|
|
|
114
126
|
if (PackageHookFunctions.has(name)) {
|
|
115
127
|
return true;
|
|
116
128
|
}
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
// every dot may be the one splitting method from class, as the generic may carry dots itself (`as.character.foo`)
|
|
130
|
+
for (let dot = name.indexOf('.'); dot > 0; dot = name.indexOf('.', dot + 1)) {
|
|
119
131
|
const generic = name.slice(0, dot);
|
|
120
|
-
if (
|
|
132
|
+
if (isKnownS3Generic(generic) || pkg.s3Generics.has(generic) || isDispatched(generic, called)) {
|
|
121
133
|
return true;
|
|
122
134
|
}
|
|
123
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.6",
|
|
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": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"build": "npm run gen:base-packages && tsc --project . && npm run build:copy-data",
|
|
31
31
|
"gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
|
|
32
32
|
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-sync.ts",
|
|
33
|
+
"check:generic-labels": "ts-node --transpile-only scripts/check-generic-labels.ts",
|
|
33
34
|
"gen:sigdb-remote": "ts-node --transpile-only scripts/sigdb-remote.ts",
|
|
34
35
|
"publish:sigdb": "ts-node scripts/publish-sigdb.ts",
|
|
35
36
|
"build:copy-data": "ts-node --transpile-only scripts/sigdb-copy.ts",
|
|
@@ -89,6 +89,8 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
89
89
|
readonly name = "flowr-analyzer-dependencies-context";
|
|
90
90
|
readonly functionsContext: FlowrAnalyzerFunctionsContext;
|
|
91
91
|
private dependencies;
|
|
92
|
+
/** what {@link getDependency} resolved for a package the project does not depend on, so a lookup never makes it one */
|
|
93
|
+
private resolvedOnly;
|
|
92
94
|
private staticsLoaded;
|
|
93
95
|
/** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
|
|
94
96
|
private lazyResolvers;
|
|
@@ -124,6 +126,8 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
124
126
|
addDeclaredDependency(pkg: Package): this;
|
|
125
127
|
addDependency(pkg: Package): this;
|
|
126
128
|
getDependency(name: string, version?: string | Range): Package | undefined;
|
|
129
|
+
/** Like {@link getDependency}, but for a package the code pulls in (`library(p)`): the result joins the project's {@link getDependencies|dependencies}. */
|
|
130
|
+
loadDependency(name: string): Package | undefined;
|
|
127
131
|
/** Resolve `name` constrained to `range` via the plugins (uncached); falls back to the cached dependency. */
|
|
128
132
|
private resolvePinnedDependency;
|
|
129
133
|
inferredRange(name: string): Range | undefined;
|
|
@@ -15,12 +15,15 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
15
15
|
name = 'flowr-analyzer-dependencies-context';
|
|
16
16
|
functionsContext;
|
|
17
17
|
dependencies = new Map();
|
|
18
|
+
/** what {@link getDependency} resolved for a package the project does not depend on, so a lookup never makes it one */
|
|
19
|
+
resolvedOnly = new Map();
|
|
18
20
|
staticsLoaded = false;
|
|
19
21
|
/** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
|
|
20
22
|
lazyResolvers = [];
|
|
21
23
|
resolvedMisses = new Set();
|
|
22
24
|
reset() {
|
|
23
25
|
this.dependencies = new Map();
|
|
26
|
+
this.resolvedOnly = new Map();
|
|
24
27
|
this.staticsLoaded = false;
|
|
25
28
|
this.lazyResolvers = [];
|
|
26
29
|
this.resolvedMisses = new Set();
|
|
@@ -142,13 +145,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
142
145
|
return this.addDependency(pkg);
|
|
143
146
|
}
|
|
144
147
|
addDependency(pkg) {
|
|
145
|
-
|
|
146
|
-
if (p) {
|
|
147
|
-
p.mergeInPlace(pkg);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
this.dependencies.set(pkg.name, pkg);
|
|
151
|
-
}
|
|
148
|
+
mergeIntoMap(this.dependencies, pkg);
|
|
152
149
|
return this;
|
|
153
150
|
}
|
|
154
151
|
getDependency(name, version) {
|
|
@@ -158,7 +155,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
158
155
|
if (version !== undefined) {
|
|
159
156
|
return this.resolvePinnedDependency(name, typeof version === 'string' ? r_version_1.RRange.parse('=' + version) : version);
|
|
160
157
|
}
|
|
161
|
-
const existing = this.dependencies.get(name);
|
|
158
|
+
const existing = this.dependencies.get(name) ?? this.resolvedOnly.get(name);
|
|
162
159
|
// a package already carrying exports is complete; a version-only one is still enriched below
|
|
163
160
|
if (existing?.namespaceInfo || (!existing && this.resolvedMisses.has(name))) {
|
|
164
161
|
return existing;
|
|
@@ -167,14 +164,26 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
167
164
|
for (const resolve of this.lazyResolvers) {
|
|
168
165
|
const resolved = resolve(name, existing);
|
|
169
166
|
if (resolved) {
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
// merges exports into any existing version info, of a dependency or of a mere lookup
|
|
168
|
+
const into = this.dependencies.has(name) ? this.dependencies : this.resolvedOnly;
|
|
169
|
+
mergeIntoMap(into, resolved);
|
|
170
|
+
return into.get(name);
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
this.resolvedMisses.add(name);
|
|
175
174
|
}
|
|
176
175
|
return existing;
|
|
177
176
|
}
|
|
177
|
+
/** Like {@link getDependency}, but for a package the code pulls in (`library(p)`): the result joins the project's {@link getDependencies|dependencies}. */
|
|
178
|
+
loadDependency(name) {
|
|
179
|
+
const found = this.getDependency(name);
|
|
180
|
+
const cached = this.resolvedOnly.get(name);
|
|
181
|
+
if (cached !== undefined) {
|
|
182
|
+
this.resolvedOnly.delete(name);
|
|
183
|
+
mergeIntoMap(this.dependencies, cached);
|
|
184
|
+
}
|
|
185
|
+
return this.dependencies.get(name) ?? found;
|
|
186
|
+
}
|
|
178
187
|
/** Resolve `name` constrained to `range` via the plugins (uncached); falls back to the cached dependency. */
|
|
179
188
|
resolvePinnedDependency(name, range) {
|
|
180
189
|
const pin = new package_1.Package({ name, versionConstraints: range ? [range] : [] });
|
|
@@ -203,4 +212,13 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
203
212
|
}
|
|
204
213
|
}
|
|
205
214
|
exports.FlowrAnalyzerDependenciesContext = FlowrAnalyzerDependenciesContext;
|
|
215
|
+
function mergeIntoMap(map, pkg) {
|
|
216
|
+
const existing = map.get(pkg.name);
|
|
217
|
+
if (existing) {
|
|
218
|
+
existing.mergeInPlace(pkg);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
map.set(pkg.name, pkg);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
206
224
|
//# sourceMappingURL=flowr-analyzer-dependencies-context.js.map
|
package/util/version.js
CHANGED
|
@@ -42,7 +42,7 @@ const assert_1 = require("./assert");
|
|
|
42
42
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
43
43
|
const doc_files_1 = require("../documentation/doc-util/doc-files");
|
|
44
44
|
// this is automatically replaced with the current version by release-it
|
|
45
|
-
const version = '2.13.
|
|
45
|
+
const version = '2.13.6';
|
|
46
46
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
47
47
|
const versionDate = '2026-07-15T07:13:44Z';
|
|
48
48
|
/**
|