@eagleoutice/flowr 2.4.0 → 2.4.1
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 +23 -23
- package/benchmark/stats/size-of.js +3 -3
- package/cli/repl/commands/repl-query.js +1 -1
- package/core/pipeline-executor.js +0 -8
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/dataflow/environments/append.js +1 -1
- package/dataflow/environments/built-in-config.d.ts +12 -4
- package/dataflow/environments/built-in-config.js +23 -82
- package/dataflow/environments/built-in.d.ts +38 -4
- package/dataflow/environments/built-in.js +106 -11
- package/dataflow/environments/clone.d.ts +3 -2
- package/dataflow/environments/clone.js +6 -5
- package/dataflow/environments/define.js +1 -2
- package/dataflow/environments/diff.js +1 -3
- package/dataflow/environments/environment.d.ts +18 -24
- package/dataflow/environments/environment.js +25 -37
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/environments/overwrite.js +1 -1
- package/dataflow/environments/remove.d.ts +2 -2
- package/dataflow/environments/remove.js +3 -4
- package/dataflow/environments/resolve-by-name.d.ts +3 -3
- package/dataflow/environments/resolve-by-name.js +4 -5
- package/dataflow/eval/resolve/alias-tracking.d.ts +12 -12
- package/dataflow/eval/resolve/alias-tracking.js +12 -12
- package/dataflow/eval/resolve/resolve.js +1 -1
- package/dataflow/extractor.js +6 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +3 -1
- package/dataflow/graph/graph.d.ts +2 -1
- package/dataflow/graph/graph.js +5 -1
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.js +9 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +1 -1
- package/dataflow/processor.d.ts +5 -1
- package/documentation/doc-util/doc-env.js +1 -2
- package/package.json +1 -1
- package/queries/base-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +7 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +18 -0
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +9 -5
- package/queries/catalog/dependencies-query/function-info/read-functions.js +4 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +5 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
- package/slicing/static/fingerprint.js +1 -2
- package/slicing/static/slice-call.d.ts +2 -1
- package/slicing/static/slice-call.js +3 -3
- package/slicing/static/static-slicer.d.ts +3 -4
- package/slicing/static/static-slicer.js +4 -4
- package/util/containers.d.ts +1 -0
- package/util/containers.js +1 -0
- package/util/json.js +1 -4
- package/util/mermaid/dfg.js +1 -2
- package/util/prefix.d.ts +1 -1
- package/util/version.js +1 -1
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 using flowR v2.
|
|
27
|
+
flowR repl using flowR v2.4.0, R v4.5.0 (r-shell engine)
|
|
28
28
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ It offers a wide variety of features, for example:
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
```text
|
|
36
|
-
Query: [;1mlinter[0m (
|
|
36
|
+
Query: [;1mlinter[0m (2 ms)
|
|
37
37
|
╰ **Deprecated Functions** (deprecated-functions):
|
|
38
38
|
╰ _Metadata_: <code>{"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
39
39
|
╰ **File Path Validity** (file-path-validity):
|
|
@@ -45,16 +45,16 @@ It offers a wide variety of features, for example:
|
|
|
45
45
|
╰ **Absolute Paths** (absolute-file-paths):
|
|
46
46
|
╰ certain:
|
|
47
47
|
╰ Path `/root/x.txt` at 1.1-23
|
|
48
|
-
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":
|
|
48
|
+
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
49
49
|
╰ **Unused Definitions** (unused-definitions):
|
|
50
50
|
╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
51
51
|
╰ **Naming Convention** (naming-convention):
|
|
52
|
-
╰ _Metadata_: <code>{"numMatches":0,"numBreak":0,"searchTimeMs":
|
|
52
|
+
╰ _Metadata_: <code>{"numMatches":0,"numBreak":0,"searchTimeMs":1,"processTimeMs":0}</code>
|
|
53
53
|
╰ **Dataframe Access Validation** (dataframe-access-validation):
|
|
54
54
|
╰ _Metadata_: <code>{"numOperations":0,"numAccesses":0,"totalAccessed":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
55
55
|
╰ **Dead Code** (dead-code):
|
|
56
|
-
╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":
|
|
57
|
-
[;3mAll queries together required ≈
|
|
56
|
+
╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
57
|
+
[;3mAll queries together required ≈2 ms (1ms accuracy, total 8 ms)[0m[0m
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
|
|
@@ -76,7 +76,7 @@ It offers a wide variety of features, for example:
|
|
|
76
76
|
|
|
77
77
|
_Results (prettified and summarized):_
|
|
78
78
|
|
|
79
|
-
Query: **linter** (
|
|
79
|
+
Query: **linter** (13 ms)\
|
|
80
80
|
╰ **Deprecated Functions** (deprecated-functions):\
|
|
81
81
|
╰ _Metadata_: <code>{"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":2,"processTimeMs":0}</code>\
|
|
82
82
|
╰ **File Path Validity** (file-path-validity):\
|
|
@@ -84,24 +84,24 @@ It offers a wide variety of features, for example:
|
|
|
84
84
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
85
85
|
╰ _Metadata_: <code>{"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":4,"processTimeMs":1}</code>\
|
|
86
86
|
╰ **Seeded Randomness** (seeded-randomness):\
|
|
87
|
-
╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":0,"processTimeMs":
|
|
87
|
+
╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":0,"processTimeMs":0}</code>\
|
|
88
88
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
89
89
|
╰ certain:\
|
|
90
90
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
91
|
-
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":1,"processTimeMs":
|
|
91
|
+
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":1,"processTimeMs":0}</code>\
|
|
92
92
|
╰ **Unused Definitions** (unused-definitions):\
|
|
93
|
-
╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":
|
|
93
|
+
╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":1,"processTimeMs":0}</code>\
|
|
94
94
|
╰ **Naming Convention** (naming-convention):\
|
|
95
95
|
╰ _Metadata_: <code>{"numMatches":0,"numBreak":0,"searchTimeMs":0,"processTimeMs":0}</code>\
|
|
96
96
|
╰ **Dataframe Access Validation** (dataframe-access-validation):\
|
|
97
97
|
╰ _Metadata_: <code>{"numOperations":0,"numAccesses":0,"totalAccessed":0,"searchTimeMs":0,"processTimeMs":2}</code>\
|
|
98
98
|
╰ **Dead Code** (dead-code):\
|
|
99
|
-
╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":
|
|
100
|
-
_All queries together required ≈
|
|
99
|
+
╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":1,"processTimeMs":0}</code>\
|
|
100
|
+
_All queries together required ≈13 ms (1ms accuracy, total 215 ms)_
|
|
101
101
|
|
|
102
102
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
103
103
|
|
|
104
|
-
The analysis required
|
|
104
|
+
The analysis required _214.5 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
105
105
|
|
|
106
106
|
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.
|
|
107
107
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -152,7 +152,7 @@ It offers a wide variety of features, for example:
|
|
|
152
152
|
"callsWithAssignmentProducers": 0,
|
|
153
153
|
"callsWithNonConstantProducers": 0,
|
|
154
154
|
"searchTimeMs": 0,
|
|
155
|
-
"processTimeMs":
|
|
155
|
+
"processTimeMs": 0
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
158
|
"absolute-file-paths": {
|
|
@@ -172,14 +172,14 @@ It offers a wide variety of features, for example:
|
|
|
172
172
|
"totalConsidered": 1,
|
|
173
173
|
"totalUnknown": 0,
|
|
174
174
|
"searchTimeMs": 1,
|
|
175
|
-
"processTimeMs":
|
|
175
|
+
"processTimeMs": 0
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
"unused-definitions": {
|
|
179
179
|
"results": [],
|
|
180
180
|
".meta": {
|
|
181
181
|
"totalConsidered": 0,
|
|
182
|
-
"searchTimeMs":
|
|
182
|
+
"searchTimeMs": 1,
|
|
183
183
|
"processTimeMs": 0
|
|
184
184
|
}
|
|
185
185
|
},
|
|
@@ -206,17 +206,17 @@ It offers a wide variety of features, for example:
|
|
|
206
206
|
"results": [],
|
|
207
207
|
".meta": {
|
|
208
208
|
"consideredNodes": 5,
|
|
209
|
-
"searchTimeMs":
|
|
209
|
+
"searchTimeMs": 1,
|
|
210
210
|
"processTimeMs": 0
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
".meta": {
|
|
215
|
-
"timing":
|
|
215
|
+
"timing": 13
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
".meta": {
|
|
219
|
-
"timing":
|
|
219
|
+
"timing": 13
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
```
|
|
@@ -283,7 +283,7 @@ It offers a wide variety of features, for example:
|
|
|
283
283
|
|
|
284
284
|
```shell
|
|
285
285
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
286
|
-
flowR repl using flowR v2.
|
|
286
|
+
flowR repl using flowR v2.4.0, R v4.5.0 (r-shell engine)
|
|
287
287
|
R> :slicer test/testfiles/example.R --criterion "11@sum"
|
|
288
288
|
```
|
|
289
289
|
|
|
@@ -330,7 +330,7 @@ It offers a wide variety of features, for example:
|
|
|
330
330
|
|
|
331
331
|
|
|
332
332
|
* 🚀 **fast data- and control-flow graphs**\
|
|
333
|
-
Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
333
|
+
Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">139.1 ms</span></i> (as of Aug 6, 2025),
|
|
334
334
|
_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,
|
|
335
335
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the dataflow graph.
|
|
336
336
|
|
|
@@ -366,7 +366,7 @@ It offers a wide variety of features, for example:
|
|
|
366
366
|
|
|
367
367
|
```shell
|
|
368
368
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
369
|
-
flowR repl using flowR v2.
|
|
369
|
+
flowR repl using flowR v2.4.0, R v4.5.0 (r-shell engine)
|
|
370
370
|
R> :dataflow* test/testfiles/example.R
|
|
371
371
|
```
|
|
372
372
|
|
|
@@ -667,7 +667,7 @@ It offers a wide variety of features, for example:
|
|
|
667
667
|
```
|
|
668
668
|
|
|
669
669
|
|
|
670
|
-
(The analysis required _13.
|
|
670
|
+
(The analysis required _13.9 ms_ (including parse and normalize, using the [r-shell](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
|
|
671
671
|
|
|
672
672
|
|
|
673
673
|
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getSizeOfDfGraph = getSizeOfDfGraph;
|
|
7
7
|
exports.safeSizeOf = safeSizeOf;
|
|
8
|
-
const environment_1 = require("../../dataflow/environments/environment");
|
|
9
8
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
9
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
11
10
|
const object_sizeof_1 = __importDefault(require("object-sizeof"));
|
|
@@ -15,12 +14,13 @@ function killBuiltInEnv(env) {
|
|
|
15
14
|
if (env === undefined) {
|
|
16
15
|
return undefined;
|
|
17
16
|
}
|
|
18
|
-
else if (env.
|
|
17
|
+
else if (env.builtInEnv) {
|
|
19
18
|
/* in this case, the reference would be shared for sure */
|
|
20
19
|
return {
|
|
21
20
|
id: env.id,
|
|
22
21
|
parent: killBuiltInEnv(env.parent),
|
|
23
|
-
memory: new Map()
|
|
22
|
+
memory: new Map(),
|
|
23
|
+
builtInEnv: true
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
const memory = new Map();
|
|
@@ -59,7 +59,7 @@ async function processQueryArgs(line, parser, output, config) {
|
|
|
59
59
|
}
|
|
60
60
|
const processed = await getDataflow(config, parser, args.join(' '));
|
|
61
61
|
return {
|
|
62
|
-
query: await Promise.resolve((0, query_1.executeQueries)({ dataflow: processed.dataflow, ast: processed.normalize, config
|
|
62
|
+
query: await Promise.resolve((0, query_1.executeQueries)({ dataflow: processed.dataflow, ast: processed.normalize, config }, parsedQuery)),
|
|
63
63
|
processed
|
|
64
64
|
};
|
|
65
65
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PipelineExecutor = void 0;
|
|
4
4
|
const assert_1 = require("../util/assert");
|
|
5
|
-
const built_in_1 = require("../dataflow/environments/built-in");
|
|
6
|
-
const built_in_config_1 = require("../dataflow/environments/built-in-config");
|
|
7
5
|
/**
|
|
8
6
|
* The pipeline executor allows to execute arbitrary {@link Pipeline|pipelines} in a step-by-step fashion.
|
|
9
7
|
* If you are not yet in the possession of a {@link Pipeline|pipeline}, you can use the {@link createPipeline} function
|
|
@@ -110,12 +108,6 @@ class PipelineExecutor {
|
|
|
110
108
|
this.length = pipeline.order.length;
|
|
111
109
|
this.input = input;
|
|
112
110
|
this.flowrConfig = flowrConfig;
|
|
113
|
-
const builtIns = flowrConfig.semantics.environment.overwriteBuiltIns;
|
|
114
|
-
if (!builtIns.loadDefaults) {
|
|
115
|
-
built_in_1.BuiltInMemory.clear();
|
|
116
|
-
built_in_1.EmptyBuiltInMemory.clear();
|
|
117
|
-
}
|
|
118
|
-
(0, built_in_config_1.registerBuiltInDefinitions)(builtIns.definitions);
|
|
119
111
|
}
|
|
120
112
|
/**
|
|
121
113
|
* Retrieve the {@link Pipeline|pipeline} that is currently being.
|
|
@@ -10,7 +10,7 @@ var SliceDirection;
|
|
|
10
10
|
})(SliceDirection || (exports.SliceDirection = SliceDirection = {}));
|
|
11
11
|
function processor(results, input, _config) {
|
|
12
12
|
const direction = input.direction ?? SliceDirection.Backward;
|
|
13
|
-
return (0, static_slicer_1.staticSlice)(results.dataflow
|
|
13
|
+
return (0, static_slicer_1.staticSlice)(results.dataflow, results.normalize, input.criterion, direction, input.threshold);
|
|
14
14
|
}
|
|
15
15
|
exports.STATIC_SLICE = {
|
|
16
16
|
name: 'slice',
|
|
@@ -25,7 +25,7 @@ function appendIEnvironmentWith(base, next) {
|
|
|
25
25
|
map.set(key, value);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const parent = base.parent
|
|
28
|
+
const parent = base.parent.builtInEnv ? base.parent : appendIEnvironmentWith(base.parent, next.parent);
|
|
29
29
|
const out = new environment_1.Environment(parent);
|
|
30
30
|
out.memory = map;
|
|
31
31
|
return out;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BuiltInMappingName, ConfigOfBuiltInMappingName } from './built-in';
|
|
2
|
+
import { BuiltIns } from './built-in';
|
|
2
3
|
import type { Identifier } from './identifier';
|
|
3
4
|
export interface BaseBuiltInDefinition {
|
|
4
5
|
/** The type of the built-in configuration */
|
|
@@ -45,7 +46,14 @@ export type BuiltInDefinition = BuiltInConstantDefinition<any> | BuiltInFunction
|
|
|
45
46
|
* @see DefaultBuiltinConfig
|
|
46
47
|
*/
|
|
47
48
|
export type BuiltInDefinitions = BuiltInDefinition[];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export declare function
|
|
49
|
+
/**
|
|
50
|
+
* Get the {@link BuiltIns#builtInMemory} and {@link BuiltIns#emptyBuiltInMemory} for the {@link DefaultBuiltinConfig}.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getDefaultBuiltInDefinitions(): BuiltIns;
|
|
53
|
+
/**
|
|
54
|
+
* Get the {@link BuiltIns#builtInMemory} and {@link BuiltIns#emptyBuiltInMemory} for the given list of built-in definitions.
|
|
55
|
+
*
|
|
56
|
+
* @param definitions - the list of built-in definitions
|
|
57
|
+
* @param loadDefaults - whether to first add the {@link DefaultBuiltinConfig} before the given {@link definitions}
|
|
58
|
+
*/
|
|
59
|
+
export declare function getBuiltInDefinitions(definitions: BuiltInDefinitions, loadDefaults: boolean | undefined): BuiltIns;
|
|
@@ -1,92 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.registerBuiltInDefinition = registerBuiltInDefinition;
|
|
6
|
-
exports.registerBuiltInDefinitions = registerBuiltInDefinitions;
|
|
3
|
+
exports.getDefaultBuiltInDefinitions = getDefaultBuiltInDefinitions;
|
|
4
|
+
exports.getBuiltInDefinitions = getBuiltInDefinitions;
|
|
7
5
|
const built_in_1 = require("./built-in");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
controlDependencies: undefined,
|
|
17
|
-
value,
|
|
18
|
-
name,
|
|
19
|
-
nodeId: id
|
|
20
|
-
}];
|
|
21
|
-
built_in_1.BuiltInMemory.set(name, d);
|
|
22
|
-
if (assumePrimitive) {
|
|
23
|
-
built_in_1.EmptyBuiltInMemory.set(name, d);
|
|
24
|
-
}
|
|
6
|
+
const default_builtin_config_1 = require("./default-builtin-config");
|
|
7
|
+
/**
|
|
8
|
+
* Get the {@link BuiltIns#builtInMemory} and {@link BuiltIns#emptyBuiltInMemory} for the {@link DefaultBuiltinConfig}.
|
|
9
|
+
*/
|
|
10
|
+
function getDefaultBuiltInDefinitions() {
|
|
11
|
+
const builtIns = new built_in_1.BuiltIns();
|
|
12
|
+
for (const definition of default_builtin_config_1.DefaultBuiltinConfig) {
|
|
13
|
+
builtIns.registerBuiltInDefinition(definition);
|
|
25
14
|
}
|
|
15
|
+
return builtIns;
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument */
|
|
38
|
-
processor: (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config),
|
|
39
|
-
config,
|
|
40
|
-
name,
|
|
41
|
-
nodeId: id
|
|
42
|
-
}];
|
|
43
|
-
built_in_1.BuiltInMemory.set(name, d);
|
|
44
|
-
if (assumePrimitive) {
|
|
45
|
-
built_in_1.EmptyBuiltInMemory.set(name, d);
|
|
46
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the {@link BuiltIns#builtInMemory} and {@link BuiltIns#emptyBuiltInMemory} for the given list of built-in definitions.
|
|
19
|
+
*
|
|
20
|
+
* @param definitions - the list of built-in definitions
|
|
21
|
+
* @param loadDefaults - whether to first add the {@link DefaultBuiltinConfig} before the given {@link definitions}
|
|
22
|
+
*/
|
|
23
|
+
function getBuiltInDefinitions(definitions, loadDefaults) {
|
|
24
|
+
let builtIns = new built_in_1.BuiltIns();
|
|
25
|
+
if (loadDefaults) {
|
|
26
|
+
builtIns = getDefaultBuiltInDefinitions();
|
|
47
27
|
}
|
|
48
|
-
}
|
|
49
|
-
/* registers all combinations of replacements */
|
|
50
|
-
function registerReplacementFunctions({ names, suffixes, assumePrimitive, config }) {
|
|
51
|
-
const replacer = built_in_1.BuiltInProcessorMapper['builtin:replacement'];
|
|
52
|
-
(0, assert_1.guard)(replacer !== undefined, () => 'Processor for builtin:replacement is undefined!');
|
|
53
|
-
for (const assignment of names) {
|
|
54
|
-
for (const suffix of suffixes) {
|
|
55
|
-
const effectiveName = `${assignment}${suffix}`;
|
|
56
|
-
const id = (0, built_in_1.builtInId)(effectiveName);
|
|
57
|
-
const d = [{
|
|
58
|
-
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
59
|
-
definedAt: id,
|
|
60
|
-
processor: (name, args, rootId, data) => replacer(name, args, rootId, data, { makeMaybe: true, assignmentOperator: suffix, readIndices: config.readIndices }),
|
|
61
|
-
config: {
|
|
62
|
-
...config,
|
|
63
|
-
assignmentOperator: suffix,
|
|
64
|
-
makeMaybe: true
|
|
65
|
-
},
|
|
66
|
-
name: effectiveName,
|
|
67
|
-
controlDependencies: undefined,
|
|
68
|
-
nodeId: id
|
|
69
|
-
}];
|
|
70
|
-
built_in_1.BuiltInMemory.set(effectiveName, d);
|
|
71
|
-
if (assumePrimitive) {
|
|
72
|
-
built_in_1.EmptyBuiltInMemory.set(effectiveName, d);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function registerBuiltInDefinition(definition) {
|
|
78
|
-
switch (definition.type) {
|
|
79
|
-
case 'constant':
|
|
80
|
-
return registerBuiltInConstant(definition);
|
|
81
|
-
case 'function':
|
|
82
|
-
return registerBuiltInFunctions(definition);
|
|
83
|
-
case 'replacement':
|
|
84
|
-
return registerReplacementFunctions(definition);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function registerBuiltInDefinitions(definitions) {
|
|
88
28
|
for (const definition of definitions) {
|
|
89
|
-
registerBuiltInDefinition(definition);
|
|
29
|
+
builtIns.registerBuiltInDefinition(definition);
|
|
90
30
|
}
|
|
31
|
+
return builtIns;
|
|
91
32
|
}
|
|
92
33
|
//# sourceMappingURL=built-in-config.js.map
|
|
@@ -30,9 +30,10 @@ import { processRm } from '../internal/process/functions/call/built-in/built-in-
|
|
|
30
30
|
import { processEvalCall } from '../internal/process/functions/call/built-in/built-in-eval';
|
|
31
31
|
import type { REnvironmentInformation } from './environment';
|
|
32
32
|
import type { Value } from '../eval/values/r-value';
|
|
33
|
-
import {
|
|
33
|
+
import { resolveAsMinus, resolveAsPlus, resolveAsSeq, resolveAsVector } from '../eval/resolve/resolve';
|
|
34
34
|
import type { DataflowGraph } from '../graph/graph';
|
|
35
35
|
import type { VariableResolve } from '../../config';
|
|
36
|
+
import type { BuiltInConstantDefinition, BuiltInDefinition, BuiltInFunctionDefinition, BuiltInReplacementDefinition } from './built-in-config';
|
|
36
37
|
export type BuiltIn = `built-in:${string}`;
|
|
37
38
|
export declare function builtInId(name: string): BuiltIn;
|
|
38
39
|
export declare function isBuiltIn(name: NodeId | string): name is BuiltIn;
|
|
@@ -64,7 +65,7 @@ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
|
|
|
64
65
|
}
|
|
65
66
|
export type BuiltInEvalHandler = (resolve: VariableResolve, a: RNodeWithParent, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap) => Value;
|
|
66
67
|
declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { returnsNthArgument, useAsProcessor, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
|
|
67
|
-
export declare function registerBuiltInFunctions<Config extends object, Proc extends BuiltInIdentifierProcessorWithConfig<Config>>(both: boolean, names: readonly Identifier[], processor: Proc, config: Config): void;
|
|
68
|
+
export declare function registerBuiltInFunctions<Config extends object, Proc extends BuiltInIdentifierProcessorWithConfig<Config>>(both: boolean, names: readonly Identifier[], processor: Proc, config: Config, builtIns: BuiltIns): void;
|
|
68
69
|
export declare const BuiltInProcessorMapper: {
|
|
69
70
|
readonly 'builtin:default': typeof defaultBuiltInProcessor;
|
|
70
71
|
readonly 'builtin:eval': typeof processEvalCall;
|
|
@@ -96,6 +97,39 @@ export declare const BuiltInEvalHandlerMapper: {
|
|
|
96
97
|
};
|
|
97
98
|
export type BuiltInMappingName = keyof typeof BuiltInProcessorMapper;
|
|
98
99
|
export type ConfigOfBuiltInMappingName<N extends BuiltInMappingName> = Parameters<typeof BuiltInProcessorMapper[N]>[4];
|
|
99
|
-
export
|
|
100
|
-
export declare
|
|
100
|
+
export type BuiltInMemory = Map<Identifier, IdentifierDefinition[]>;
|
|
101
|
+
export declare class BuiltIns {
|
|
102
|
+
/**
|
|
103
|
+
* Register a built-in constant (like `NULL` or `TRUE`) to the given {@link builtIns}
|
|
104
|
+
*/
|
|
105
|
+
registerBuiltInConstant<T>({ names, value, assumePrimitive }: BuiltInConstantDefinition<T>): void;
|
|
106
|
+
/**
|
|
107
|
+
* Register a built-in function (like `print` or `c`) to the given {@link builtIns}
|
|
108
|
+
*/
|
|
109
|
+
registerBuiltInFunctions<BuiltInProcessor extends BuiltInMappingName>({ names, processor, config, assumePrimitive }: BuiltInFunctionDefinition<BuiltInProcessor>): void;
|
|
110
|
+
/**
|
|
111
|
+
* Registers all combinations of replacements
|
|
112
|
+
*/
|
|
113
|
+
registerReplacementFunctions({ names, suffixes, assumePrimitive, config }: BuiltInReplacementDefinition): void;
|
|
114
|
+
/**
|
|
115
|
+
* Register a single {@link BuiltInDefinition} to the given memories in {@link builtIns}
|
|
116
|
+
*/
|
|
117
|
+
registerBuiltInDefinition(definition: BuiltInDefinition): void;
|
|
118
|
+
/**
|
|
119
|
+
* The built-in {@link REnvironmentInformation|environment} is the root of all environments.
|
|
120
|
+
*
|
|
121
|
+
* For its default content (when not overwritten by a flowR config),
|
|
122
|
+
* see the {@link DefaultBuiltinConfig}.
|
|
123
|
+
*/
|
|
124
|
+
builtInMemory: BuiltInMemory;
|
|
125
|
+
/**
|
|
126
|
+
* The twin of the {@link builtInMemory} but with less built ins defined for
|
|
127
|
+
* cases in which we want some commonly overwritten variables to remain open.
|
|
128
|
+
* If you do not know if you need the empty environment, you do not need the empty environment (right now).
|
|
129
|
+
*
|
|
130
|
+
* @see {@link builtInMemory}
|
|
131
|
+
*/
|
|
132
|
+
emptyBuiltInMemory: BuiltInMemory;
|
|
133
|
+
set(identifier: Identifier, definition: IdentifierDefinition[], includeInEmptyMemory: boolean | undefined): void;
|
|
134
|
+
}
|
|
101
135
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BuiltIns = exports.BuiltInEvalHandlerMapper = exports.BuiltInProcessorMapper = void 0;
|
|
4
4
|
exports.builtInId = builtInId;
|
|
5
5
|
exports.isBuiltIn = isBuiltIn;
|
|
6
6
|
exports.registerBuiltInFunctions = registerBuiltInFunctions;
|
|
@@ -25,8 +25,6 @@ const edge_1 = require("../graph/edge");
|
|
|
25
25
|
const built_in_library_1 = require("../internal/process/functions/call/built-in/built-in-library");
|
|
26
26
|
const built_in_source_1 = require("../internal/process/functions/call/built-in/built-in-source");
|
|
27
27
|
const built_in_apply_1 = require("../internal/process/functions/call/built-in/built-in-apply");
|
|
28
|
-
const built_in_config_1 = require("./built-in-config");
|
|
29
|
-
const default_builtin_config_1 = require("./default-builtin-config");
|
|
30
28
|
const built_in_list_1 = require("../internal/process/functions/call/built-in/built-in-list");
|
|
31
29
|
const built_in_vector_1 = require("../internal/process/functions/call/built-in/built-in-vector");
|
|
32
30
|
const built_in_rm_1 = require("../internal/process/functions/call/built-in/built-in-rm");
|
|
@@ -101,7 +99,7 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
|
|
|
101
99
|
}
|
|
102
100
|
return res;
|
|
103
101
|
}
|
|
104
|
-
function registerBuiltInFunctions(both, names, processor, config) {
|
|
102
|
+
function registerBuiltInFunctions(both, names, processor, config, builtIns) {
|
|
105
103
|
for (const name of names) {
|
|
106
104
|
(0, assert_1.guard)(processor !== undefined, `Processor for ${name} is undefined, maybe you have an import loop? You may run 'npm run detect-circular-deps' - although by far not all are bad`);
|
|
107
105
|
const id = builtInId(name);
|
|
@@ -114,10 +112,7 @@ function registerBuiltInFunctions(both, names, processor, config) {
|
|
|
114
112
|
name,
|
|
115
113
|
nodeId: id
|
|
116
114
|
}];
|
|
117
|
-
|
|
118
|
-
if (both) {
|
|
119
|
-
exports.EmptyBuiltInMemory.set(name, d);
|
|
120
|
-
}
|
|
115
|
+
builtIns.set(name, d, both);
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
exports.BuiltInProcessorMapper = {
|
|
@@ -149,7 +144,107 @@ exports.BuiltInEvalHandlerMapper = {
|
|
|
149
144
|
'built-in:+': resolve_1.resolveAsPlus,
|
|
150
145
|
'built-in:-': resolve_1.resolveAsMinus
|
|
151
146
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
(
|
|
147
|
+
class BuiltIns {
|
|
148
|
+
/**
|
|
149
|
+
* Register a built-in constant (like `NULL` or `TRUE`) to the given {@link builtIns}
|
|
150
|
+
*/
|
|
151
|
+
registerBuiltInConstant({ names, value, assumePrimitive }) {
|
|
152
|
+
for (const name of names) {
|
|
153
|
+
const id = builtInId(name);
|
|
154
|
+
const d = [{
|
|
155
|
+
type: identifier_1.ReferenceType.BuiltInConstant,
|
|
156
|
+
definedAt: id,
|
|
157
|
+
controlDependencies: undefined,
|
|
158
|
+
value,
|
|
159
|
+
name,
|
|
160
|
+
nodeId: id
|
|
161
|
+
}];
|
|
162
|
+
this.set(name, d, assumePrimitive);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Register a built-in function (like `print` or `c`) to the given {@link builtIns}
|
|
167
|
+
*/
|
|
168
|
+
registerBuiltInFunctions({ names, processor, config, assumePrimitive }) {
|
|
169
|
+
const mappedProcessor = exports.BuiltInProcessorMapper[processor];
|
|
170
|
+
(0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(exports.BuiltInProcessorMapper))}!`);
|
|
171
|
+
for (const name of names) {
|
|
172
|
+
(0, assert_1.guard)(processor !== undefined, `Processor for ${name} is undefined, maybe you have an import loop? You may run 'npm run detect-circular-deps' - although by far not all are bad`);
|
|
173
|
+
const id = builtInId(name);
|
|
174
|
+
const d = [{
|
|
175
|
+
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
176
|
+
definedAt: id,
|
|
177
|
+
controlDependencies: undefined,
|
|
178
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument */
|
|
179
|
+
processor: (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config),
|
|
180
|
+
config,
|
|
181
|
+
name,
|
|
182
|
+
nodeId: id
|
|
183
|
+
}];
|
|
184
|
+
this.set(name, d, assumePrimitive);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Registers all combinations of replacements
|
|
189
|
+
*/
|
|
190
|
+
registerReplacementFunctions({ names, suffixes, assumePrimitive, config }) {
|
|
191
|
+
const replacer = exports.BuiltInProcessorMapper['builtin:replacement'];
|
|
192
|
+
(0, assert_1.guard)(replacer !== undefined, () => 'Processor for builtin:replacement is undefined!');
|
|
193
|
+
for (const assignment of names) {
|
|
194
|
+
for (const suffix of suffixes) {
|
|
195
|
+
const effectiveName = `${assignment}${suffix}`;
|
|
196
|
+
const id = builtInId(effectiveName);
|
|
197
|
+
const d = [{
|
|
198
|
+
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
199
|
+
definedAt: id,
|
|
200
|
+
processor: (name, args, rootId, data) => replacer(name, args, rootId, data, { makeMaybe: true, assignmentOperator: suffix, readIndices: config.readIndices }),
|
|
201
|
+
config: {
|
|
202
|
+
...config,
|
|
203
|
+
assignmentOperator: suffix,
|
|
204
|
+
makeMaybe: true
|
|
205
|
+
},
|
|
206
|
+
name: effectiveName,
|
|
207
|
+
controlDependencies: undefined,
|
|
208
|
+
nodeId: id
|
|
209
|
+
}];
|
|
210
|
+
this.set(effectiveName, d, assumePrimitive);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Register a single {@link BuiltInDefinition} to the given memories in {@link builtIns}
|
|
216
|
+
*/
|
|
217
|
+
registerBuiltInDefinition(definition) {
|
|
218
|
+
switch (definition.type) {
|
|
219
|
+
case 'constant':
|
|
220
|
+
return this.registerBuiltInConstant(definition);
|
|
221
|
+
case 'function':
|
|
222
|
+
return this.registerBuiltInFunctions(definition);
|
|
223
|
+
case 'replacement':
|
|
224
|
+
return this.registerReplacementFunctions(definition);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The built-in {@link REnvironmentInformation|environment} is the root of all environments.
|
|
229
|
+
*
|
|
230
|
+
* For its default content (when not overwritten by a flowR config),
|
|
231
|
+
* see the {@link DefaultBuiltinConfig}.
|
|
232
|
+
*/
|
|
233
|
+
builtInMemory = new Map();
|
|
234
|
+
/**
|
|
235
|
+
* The twin of the {@link builtInMemory} but with less built ins defined for
|
|
236
|
+
* cases in which we want some commonly overwritten variables to remain open.
|
|
237
|
+
* If you do not know if you need the empty environment, you do not need the empty environment (right now).
|
|
238
|
+
*
|
|
239
|
+
* @see {@link builtInMemory}
|
|
240
|
+
*/
|
|
241
|
+
emptyBuiltInMemory = new Map();
|
|
242
|
+
set(identifier, definition, includeInEmptyMemory) {
|
|
243
|
+
this.builtInMemory.set(identifier, definition);
|
|
244
|
+
if (includeInEmptyMemory) {
|
|
245
|
+
this.emptyBuiltInMemory.set(identifier, definition);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
exports.BuiltIns = BuiltIns;
|
|
155
250
|
//# sourceMappingURL=built-in.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { REnvironmentInformation } from './environment';
|
|
2
2
|
/**
|
|
3
3
|
* Produce a clone of the given environment information.
|
|
4
|
-
* @param environment
|
|
5
|
-
* @param
|
|
4
|
+
* @param environment - The environment information to clone.
|
|
5
|
+
* @param builtInEnvironment - The built-in environment
|
|
6
|
+
* @param recurseParents - Whether to clone the parent environments as well.
|
|
6
7
|
*/
|
|
7
8
|
export declare function cloneEnvironmentInformation(environment: REnvironmentInformation, recurseParents?: boolean): REnvironmentInformation;
|
|
@@ -6,18 +6,19 @@ function cloneEnvironment(environment, recurseParents) {
|
|
|
6
6
|
if (environment === undefined) {
|
|
7
7
|
return undefined;
|
|
8
8
|
}
|
|
9
|
-
else if (environment.
|
|
10
|
-
return
|
|
9
|
+
else if (environment.builtInEnv) {
|
|
10
|
+
return environment; // do not clone the built-in environment
|
|
11
11
|
}
|
|
12
12
|
/* make sure the clone has the same id */
|
|
13
|
-
const clone = new environment_1.Environment(recurseParents ? cloneEnvironment(environment.parent, recurseParents) : environment.parent);
|
|
13
|
+
const clone = new environment_1.Environment(recurseParents ? cloneEnvironment(environment.parent, recurseParents) : environment.parent, environment.builtInEnv);
|
|
14
14
|
clone.memory = new Map(JSON.parse(JSON.stringify([...environment.memory])));
|
|
15
15
|
return clone;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Produce a clone of the given environment information.
|
|
19
|
-
* @param environment
|
|
20
|
-
* @param
|
|
19
|
+
* @param environment - The environment information to clone.
|
|
20
|
+
* @param builtInEnvironment - The built-in environment
|
|
21
|
+
* @param recurseParents - Whether to clone the parent environments as well.
|
|
21
22
|
*/
|
|
22
23
|
function cloneEnvironmentInformation(environment, recurseParents = true) {
|
|
23
24
|
return {
|