@eagleoutice/flowr 2.17.0 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/config.d.ts +32 -0
- package/config.js +22 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/dataflow/environments/ambient-state-name.d.ts +4 -0
- package/dataflow/environments/ambient-state-name.js +4 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in-props.d.ts +18 -2
- package/dataflow/environments/built-in-props.js +26 -4
- package/dataflow/environments/built-in.d.ts +16 -6
- package/dataflow/environments/built-in.js +58 -7
- package/dataflow/environments/default-builtin-config.d.ts +1245 -159
- package/dataflow/environments/default-builtin-config.js +191 -38
- package/dataflow/environments/environment.d.ts +19 -2
- package/dataflow/environments/environment.js +90 -19
- package/dataflow/environments/identifier.d.ts +25 -1
- package/dataflow/environments/query-fn-props.js +4 -3
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/eval/resolve/node-value.d.ts +1 -1
- package/dataflow/eval/resolve/node-value.js +2 -2
- package/dataflow/eval/resolve/resolve-argument.js +1 -1
- package/dataflow/extractor.js +68 -17
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/graph/df-helper.d.ts +34 -1
- package/dataflow/graph/df-helper.js +60 -0
- package/dataflow/info.d.ts +2 -0
- package/dataflow/info.js +4 -0
- package/dataflow/internal/linker.js +21 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +144 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +8 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +43 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +67 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +134 -88
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +87 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +23 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +18 -15
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +8 -7
- package/documentation/wiki-dataflow-graph.js +20 -1
- package/linter/rules/network-functions.js +10 -2
- package/linter/rules/undefined-symbol.js +2 -2
- package/linter/rules/unused-import.js +11 -1
- package/package.json +1 -1
- package/project/attached-packages.d.ts +11 -6
- package/project/attached-packages.js +37 -9
- package/project/cache/flowr-analyzer-cache.d.ts +4 -0
- package/project/cache/flowr-analyzer-cache.js +11 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -0
- package/project/context/flowr-analyzer-dependencies-context.js +6 -0
- package/project/context/flowr-file.d.ts +2 -2
- package/project/context/flowr-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +39 -4
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +134 -30
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +7 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +14 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +18 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +43 -15
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +58 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +237 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +24 -18
- package/project/plugins/plugin-registry.d.ts +5 -4
- package/project/plugins/plugin-registry.js +6 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/decode.js +13 -3
- package/project/sigdb/memory-source.d.ts +6 -4
- package/project/sigdb/memory-source.js +6 -5
- package/project/sigdb/on-demand/fetch.d.ts +18 -0
- package/project/sigdb/on-demand/fetch.js +127 -0
- package/project/sigdb/on-demand/package-sources.d.ts +40 -0
- package/project/sigdb/on-demand/package-sources.js +263 -0
- package/project/sigdb/on-demand/recoverer.d.ts +40 -0
- package/project/sigdb/on-demand/recoverer.js +169 -0
- package/project/sigdb/on-demand/remote-sources.d.ts +72 -0
- package/project/sigdb/on-demand/remote-sources.js +132 -0
- package/project/sigdb/on-demand/tar.d.ts +19 -0
- package/project/sigdb/on-demand/tar.js +119 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +5 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +17 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +3 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +11 -1
- package/queries/catalog/signature-query/signature-query-executor.js +15 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -2
- package/r-bridge/data/data.d.ts +31 -2
- package/r-bridge/data/data.js +25 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/model.js +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +12 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +4 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +8 -0
- package/reconstruct/reconstruct.js +2 -5
- package/search/search-executor/search-enrichers.js +17 -2
- package/search/search-executor/search-generators.js +6 -2
- package/slicing/static/slice-call.d.ts +16 -0
- package/slicing/static/slice-call.js +42 -0
- package/slicing/static/static-slicer.js +6 -0
- package/taint-analysis/predefined/secret-analysis.js +7 -2
- package/taint-analysis/taint-mapping.d.ts +5 -2
- package/taint-analysis/taint-mapping.js +17 -6
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/r-version.js +4 -2
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ It offers a wide variety of features, for example:
|
|
|
38
38
|
|
|
39
39
|
```shell
|
|
40
40
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
41
|
-
flowR repl v2.
|
|
41
|
+
flowR repl v2.17.0, R grammar v14 (tree-sitter engine)
|
|
42
42
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ It offers a wide variety of features, for example:
|
|
|
46
46
|
<summary style='color:gray'>Output</summary>
|
|
47
47
|
|
|
48
48
|
```text
|
|
49
|
-
Query: linter (
|
|
49
|
+
Query: linter (21 ms)
|
|
50
50
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
51
51
|
╰ File Path Validity (file-path-validity):
|
|
52
52
|
╰ certain:
|
|
@@ -72,7 +72,7 @@ It offers a wide variety of features, for example:
|
|
|
72
72
|
╰ Namespace Access Validity (namespace-access): no findings
|
|
73
73
|
╰ Secret Exfiltration (secret-exfiltration): no findings
|
|
74
74
|
╰ Process State in Session (process-state-in-session): no findings
|
|
75
|
-
All queries together required ≈
|
|
75
|
+
All queries together required ≈21 ms (1ms accuracy, total 22 ms)
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
The linter will analyze the code and return any issues found.
|
|
@@ -86,7 +86,7 @@ It offers a wide variety of features, for example:
|
|
|
86
86
|
|
|
87
87
|
_Results (prettified and summarized):_
|
|
88
88
|
|
|
89
|
-
Query: **linter** (
|
|
89
|
+
Query: **linter** (23 ms)\
|
|
90
90
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
91
91
|
╰ **File Path Validity** (file-path-validity):\
|
|
92
92
|
╰ certain:\
|
|
@@ -205,7 +205,7 @@ It offers a wide variety of features, for example:
|
|
|
205
205
|
|
|
206
206
|
```shell
|
|
207
207
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
208
|
-
flowR repl v2.
|
|
208
|
+
flowR repl v2.17.0, R grammar v14 (tree-sitter engine)
|
|
209
209
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
210
210
|
```
|
|
211
211
|
|
|
@@ -218,7 +218,7 @@ It offers a wide variety of features, for example:
|
|
|
218
218
|
N <- 10
|
|
219
219
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
220
220
|
sum
|
|
221
|
-
All queries together required ≈
|
|
221
|
+
All queries together required ≈4 ms (1ms accuracy, total 4 ms)
|
|
222
222
|
```
|
|
223
223
|
|
|
224
224
|
</details>
|
|
@@ -226,7 +226,7 @@ It offers a wide variety of features, for example:
|
|
|
226
226
|
</details>
|
|
227
227
|
|
|
228
228
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
229
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
229
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">129.1 ms</span></i> (as of Nov 3, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
230
230
|
_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,
|
|
231
231
|
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).
|
|
232
232
|
( [▶ Explore in Browser](https://flowr-analysis.github.io/flowr/wiki/playground/#c=zDYSwRgTghhCeAUATADsWECUAoLBnAxlMAKYD6ALgPakC2UAHgAQA8AtIwGYCuAdvuSEo949DIyYB6RnXojsWaAHdGKlW0aIo5KADoO0GsXghEjALyMAjAC4AbABpGANyJdi5xvngBmRwA5HAHZHACZHAE5HABYMbHwSKB5VdQ4QYHJiCHglRxdgN0YAPkYQuISeABICImJTdWqSCmoZeHjiRIq8t3lcLho6OFJcbXJcFnZe-pgQXCM2xMdDRI8l4Qba2KxeLlnEJu1gNQm%2B7KhFTtdieUUIEAydfFwneEmB2CGR3EcAIleYWAeT2%2B2FQlHIrXKVUIJEQIMoIB4owh7UqJgwQA&p=13:1 "run this script in flowR's playground, no setup") )
|
|
@@ -257,7 +257,7 @@ It offers a wide variety of features, for example:
|
|
|
257
257
|
|
|
258
258
|
```shell
|
|
259
259
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
260
|
-
flowR repl v2.
|
|
260
|
+
flowR repl v2.17.0, R grammar v14 (tree-sitter engine)
|
|
261
261
|
R> :dataflow* test/testfiles/example.R
|
|
262
262
|
```
|
|
263
263
|
|
package/config.d.ts
CHANGED
|
@@ -199,6 +199,38 @@ export interface FlowrConfig {
|
|
|
199
199
|
readonly maxDepth?: number;
|
|
200
200
|
readonly packages?: string[];
|
|
201
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Recovering a package no signature database knows from its source, fetched when the analyzed code uses
|
|
204
|
+
* it: from CRAN, Bioconductor, or the GitHub repository the project installs it from. Opt-in, as it
|
|
205
|
+
* accesses the network. What it fetched is cached, so a later analysis can work offline.
|
|
206
|
+
*/
|
|
207
|
+
readonly onDemand?: {
|
|
208
|
+
readonly enabled: boolean;
|
|
209
|
+
/** where to look, in order (default `github`, `cran`, `bioconductor`), a plugin may add sources of its own */
|
|
210
|
+
readonly sources?: string[];
|
|
211
|
+
/** GitHub repositories (`owner/repo[/subdir][@ref]`) to fetch packages from, by package name */
|
|
212
|
+
readonly repositories?: Record<string, string>;
|
|
213
|
+
/** only recover packages whose name matches one of these regular expressions, empty means any */
|
|
214
|
+
readonly packages?: string[];
|
|
215
|
+
/** the CRAN `src/contrib/` to fetch from (default `https://cloud.r-project.org/src/contrib/`) */
|
|
216
|
+
readonly cranMirror?: string;
|
|
217
|
+
/** the Bioconductor host (default `https://bioconductor.org`) */
|
|
218
|
+
readonly bioconductorMirror?: string;
|
|
219
|
+
/** the Bioconductor release to fetch from (default `release`) */
|
|
220
|
+
readonly bioconductorRelease?: string;
|
|
221
|
+
/** whether to use the GitHub mirrors of CRAN and Bioconductor (`cran/<pkg>`, `bioc/<pkg>`, default true) */
|
|
222
|
+
readonly githubMirrors?: boolean;
|
|
223
|
+
/** the most packages to fetch for one analysis (default 25) */
|
|
224
|
+
readonly maxPackages?: number;
|
|
225
|
+
/** the most MiB a package archive may have (default 32), it may unpack to three times that */
|
|
226
|
+
readonly maxArchiveMb?: number;
|
|
227
|
+
/** only use what was fetched before, never the network (default false) */
|
|
228
|
+
readonly offline?: boolean;
|
|
229
|
+
/** how many hours to wait before asking again for a package no source had (default 24) */
|
|
230
|
+
readonly retryAfterHours?: number;
|
|
231
|
+
/** where to cache what was fetched (default the `on-demand` directory of the signature cache) */
|
|
232
|
+
readonly cacheDir?: string;
|
|
233
|
+
};
|
|
202
234
|
};
|
|
203
235
|
readonly versionManagement?: {
|
|
204
236
|
readonly linkedVersionGroups?: string[][];
|
package/config.js
CHANGED
|
@@ -137,10 +137,12 @@ exports.FlowrDefaultPlugins = [
|
|
|
137
137
|
'versions:description',
|
|
138
138
|
'versions:sigdb',
|
|
139
139
|
'versions:library',
|
|
140
|
+
'versions:on-demand',
|
|
140
141
|
'versions:namespace',
|
|
141
142
|
'versions:renv',
|
|
142
143
|
'versions:rv',
|
|
143
144
|
'versions:uvr',
|
|
145
|
+
'versions:rig',
|
|
144
146
|
'versions:packrat',
|
|
145
147
|
'versions:session-info',
|
|
146
148
|
'loading-order:description',
|
|
@@ -150,6 +152,8 @@ exports.FlowrDefaultPlugins = [
|
|
|
150
152
|
'meta:description',
|
|
151
153
|
'meta:rproject',
|
|
152
154
|
'meta:uvr',
|
|
155
|
+
'meta:rig',
|
|
156
|
+
'meta:rig-script',
|
|
153
157
|
'file-roles:vignette',
|
|
154
158
|
'file-roles:test',
|
|
155
159
|
'file-roles:inst',
|
|
@@ -173,6 +177,7 @@ exports.FlowrDefaultPlugins = [
|
|
|
173
177
|
'file:virtualenv',
|
|
174
178
|
'file:rproject',
|
|
175
179
|
'file:uvr',
|
|
180
|
+
'file:rig',
|
|
176
181
|
'file:rprofile',
|
|
177
182
|
];
|
|
178
183
|
/** deep-merge two config overwrites with `own` winning; objects merge, arrays/scalars replace (matching {@link specialize}'s array-as-leaf treatment) */
|
|
@@ -329,7 +334,7 @@ exports.FlowrConfig = {
|
|
|
329
334
|
variables: VariableResolve.Alias,
|
|
330
335
|
evalStrings: true,
|
|
331
336
|
trackEnvironments: true,
|
|
332
|
-
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, blobCacheBudgetMb: 16, assumedRVersion: 'auto', linkBaseR: false, linkDescriptionDependencies: false, linkBaseRCalls: false, linkPackageCalls: false, warmInBackground: false, additionalPaths: [], autoSync: false, versionSelection: VersionSelection.Newest, versionOverrides: {}, installedLibrary: { enabled: false, paths: [], useEnvironment: true, useProjectLibrary: true, maxDepth: 3, packages: [] } },
|
|
337
|
+
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, blobCacheBudgetMb: 16, assumedRVersion: 'auto', linkBaseR: false, linkDescriptionDependencies: false, linkBaseRCalls: false, linkPackageCalls: false, warmInBackground: false, additionalPaths: [], autoSync: false, versionSelection: VersionSelection.Newest, versionOverrides: {}, installedLibrary: { enabled: false, paths: [], useEnvironment: true, useProjectLibrary: true, maxDepth: 3, packages: [] }, onDemand: { enabled: false } },
|
|
333
338
|
versionManagement: { linkedVersionGroups: [] },
|
|
334
339
|
resolveSource: {
|
|
335
340
|
dropPaths: DropPathsOption.No,
|
|
@@ -461,7 +466,7 @@ exports.FlowrConfig = {
|
|
|
461
466
|
trackEnvironments: joi_1.default.boolean().optional().description('Track user-created environments (new.env, assign/get/local with envir=, dollar-assign, attach). When false, all envir-style calls fall through conservatively.'),
|
|
462
467
|
sigdb: joi_1.default.object({
|
|
463
468
|
enabled: joi_1.default.boolean().optional().description('Resolve library()/use() exports from a signature database (default true); when false no database is consulted.'),
|
|
464
|
-
loadProjectDependencies: joi_1.default.boolean().optional().description('Load the project\'s declared dependencies from its metadata files (DESCRIPTION Imports/Depends, rproject.toml, uvr.toml, renv.lock, rv.lock, uvr.lock) (default true); when false these files are not read for dependencies.'),
|
|
469
|
+
loadProjectDependencies: joi_1.default.boolean().optional().description('Load the project\'s declared dependencies from its metadata files (DESCRIPTION Imports/Depends, rproject.toml, uvr.toml, rig rproj.toml and script blocks, renv.lock, rv.lock, uvr.lock, rig lockfiles) (default true); when false these files are not read for dependencies.'),
|
|
465
470
|
eagerlyLoad: joi_1.default.boolean().optional().description('Parse the database up front rather than on the first package load (default false, ignored if disabled).'),
|
|
466
471
|
eagerlyLoadExports: joi_1.default.boolean().optional().description('Add a vertex for every export on load rather than on demand (default false); keeps the dataflow graph small.'),
|
|
467
472
|
assumedRVersion: joi_1.default.string().optional().description('R version assumed when resolving versioned (base-R) exports: a pin like "4.5" or "auto" to detect the installed R (default "auto").'),
|
|
@@ -481,6 +486,21 @@ exports.FlowrConfig = {
|
|
|
481
486
|
maxDepth: joi_1.default.number().optional().description('How far to descend into the nested layout of a project-local library (default 3).'),
|
|
482
487
|
packages: regexOption(joi_1.default.array().items(joi_1.default.string()).optional()).description('Only recover packages whose name matches one of these regular expressions; empty means any.')
|
|
483
488
|
}).optional().description('Recovering packages no signature database knows from the copy installed on this machine.'),
|
|
489
|
+
onDemand: joi_1.default.object({
|
|
490
|
+
enabled: securitySensitive(joi_1.default.boolean().required()).description('Fetch and recover the sources of packages no signature database knows when the analyzed code uses them (default false, accesses the network).'),
|
|
491
|
+
sources: joi_1.default.array().items(joi_1.default.string()).optional().description('Where to look, in order: github, cran, bioconductor, or a source a plugin adds (default ["github", "cran", "bioconductor"]).'),
|
|
492
|
+
repositories: securitySensitive(joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional()).description('GitHub repositories (owner/repo[/subdir][@ref]) to fetch packages from, by package name. The analyzed project may name more (DESCRIPTION Remotes, install_github calls).'),
|
|
493
|
+
packages: regexOption(joi_1.default.array().items(joi_1.default.string()).optional()).description('Only recover packages whose name matches one of these regular expressions, empty means any.'),
|
|
494
|
+
cranMirror: securitySensitive(joi_1.default.string().optional()).description('The CRAN src/contrib/ to fetch from, over https (default https://cloud.r-project.org/src/contrib/). It may be on the local network.'),
|
|
495
|
+
bioconductorMirror: securitySensitive(joi_1.default.string().optional()).description('The Bioconductor host, over https (default https://bioconductor.org). It may be on the local network.'),
|
|
496
|
+
bioconductorRelease: joi_1.default.string().pattern(/^(release|devel|\d+\.\d+)$/).optional().description('The Bioconductor release to fetch from: release, devel, or a number like 3.20 (default release).'),
|
|
497
|
+
githubMirrors: joi_1.default.boolean().optional().description('Use the GitHub mirrors of CRAN (cran/<pkg>) and Bioconductor (bioc/<pkg>) (default true).'),
|
|
498
|
+
maxPackages: joi_1.default.number().min(0).optional().description('The most packages to fetch for one analysis (default 25).'),
|
|
499
|
+
maxArchiveMb: joi_1.default.number().min(0).optional().description('The most MiB a package archive may have (default 32). It may unpack to three times that, at most 128 MiB.'),
|
|
500
|
+
offline: joi_1.default.boolean().optional().description('Only use what was fetched before, never the network (default false).'),
|
|
501
|
+
retryAfterHours: joi_1.default.number().min(0).optional().description('How many hours to wait before asking again for a package no source had (default 24).'),
|
|
502
|
+
cacheDir: securitySensitive(joi_1.default.string().optional()).description('Where to cache what was fetched (default the on-demand directory of the signature cache).')
|
|
503
|
+
}).optional().description('Recovering packages no signature database knows from their sources on CRAN, Bioconductor, or GitHub.'),
|
|
484
504
|
blobCacheBudgetMb: joi_1.default.number().min(0).optional().description('How many MiB of decoded package blobs every open bundle may hold together (default 16).'),
|
|
485
505
|
versionSelection: joi_1.default.string().valid(...Object.values(VersionSelection)).optional().description('When a project constrains a dependency, resolve to the newest (default), oldest, or system-installed version satisfying it; system needs R and falls back to newest. Base-R packages always resolve against the assumed R version.'),
|
|
486
506
|
versionOverrides: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional().description('Force an exact version for specific packages (name -> version), overriding both the project constraint and the versionSelection policy (default {}).')
|
|
@@ -249,6 +249,8 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
249
249
|
case built_in_proc_name_1.BuiltInProcName.StackEnv:
|
|
250
250
|
case built_in_proc_name_1.BuiltInProcName.With:
|
|
251
251
|
case built_in_proc_name_1.BuiltInProcName.Attach:
|
|
252
|
+
case built_in_proc_name_1.BuiltInProcName.Detach:
|
|
253
|
+
case built_in_proc_name_1.BuiltInProcName.Prefer:
|
|
252
254
|
case built_in_proc_name_1.BuiltInProcName.EnvContents:
|
|
253
255
|
case built_in_proc_name_1.BuiltInProcName.ListToEnv:
|
|
254
256
|
case built_in_proc_name_1.BuiltInProcName.Default:
|
|
@@ -42,6 +42,10 @@ export declare const AmbientStateName: {
|
|
|
42
42
|
readonly workingDirectory: "#wd";
|
|
43
43
|
/** whether console output is diverted into a file or connection, as `sink(file)` does and `sink()` undoes */
|
|
44
44
|
readonly sink: "#sink";
|
|
45
|
+
/** the project root `here::here()` builds its paths from, found from the working directory unless `here::i_am` names it */
|
|
46
|
+
readonly projectRoot: "#project-root";
|
|
47
|
+
/** where packages are installed and loaded from, which `.libPaths(new)` changes and every package load reads */
|
|
48
|
+
readonly libPaths: "#lib-paths";
|
|
45
49
|
/** the file creation mask `Sys.umask` sets */
|
|
46
50
|
readonly umask: "#umask";
|
|
47
51
|
/** the state of the random number generator, which `set.seed` sets and every draw advances */
|
|
@@ -57,6 +57,10 @@ exports.AmbientStateName = {
|
|
|
57
57
|
workingDirectory: '#wd',
|
|
58
58
|
/** whether console output is diverted into a file or connection, as `sink(file)` does and `sink()` undoes */
|
|
59
59
|
sink: '#sink',
|
|
60
|
+
/** the project root `here::here()` builds its paths from, found from the working directory unless `here::i_am` names it */
|
|
61
|
+
projectRoot: '#project-root',
|
|
62
|
+
/** where packages are installed and loaded from, which `.libPaths(new)` changes and every package load reads */
|
|
63
|
+
libPaths: '#lib-paths',
|
|
60
64
|
/** the file creation mask `Sys.umask` sets */
|
|
61
65
|
umask: '#umask',
|
|
62
66
|
/** the state of the random number generator, which `set.seed` sets and every draw advances */
|
|
@@ -98,6 +98,10 @@ export declare enum BuiltInProcName {
|
|
|
98
98
|
Try = "builtin:try",
|
|
99
99
|
/** for `attach` calls that inject environment contents into the search path, see {@link processAttach} */
|
|
100
100
|
Attach = "builtin:attach",
|
|
101
|
+
/** for `detach` and `unloadNamespace`, see {@link processDetach} */
|
|
102
|
+
Detach = "builtin:detach",
|
|
103
|
+
/** for `conflicted::conflict_prefer` and `conflicts_prefer`, see {@link processPrefer} */
|
|
104
|
+
Prefer = "builtin:prefer",
|
|
101
105
|
EnvContents = "builtin:env-contents",
|
|
102
106
|
ListToEnv = "builtin:list2env",
|
|
103
107
|
/** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
|
|
@@ -102,6 +102,10 @@ var BuiltInProcName;
|
|
|
102
102
|
BuiltInProcName["Try"] = "builtin:try";
|
|
103
103
|
/** for `attach` calls that inject environment contents into the search path, see {@link processAttach} */
|
|
104
104
|
BuiltInProcName["Attach"] = "builtin:attach";
|
|
105
|
+
/** for `detach` and `unloadNamespace`, see {@link processDetach} */
|
|
106
|
+
BuiltInProcName["Detach"] = "builtin:detach";
|
|
107
|
+
/** for `conflicted::conflict_prefer` and `conflicts_prefer`, see {@link processPrefer} */
|
|
108
|
+
BuiltInProcName["Prefer"] = "builtin:prefer";
|
|
105
109
|
BuiltInProcName["EnvContents"] = "builtin:env-contents";
|
|
106
110
|
BuiltInProcName["ListToEnv"] = "builtin:list2env";
|
|
107
111
|
/** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
|
|
@@ -21,9 +21,15 @@ export declare enum ArgProp {
|
|
|
21
21
|
Shape = 16,
|
|
22
22
|
/** selects a behavior instead of carrying data, like `na.rm` in `sum(x, na.rm = TRUE)` */
|
|
23
23
|
Flag = 32,
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* names the resource the call reads or writes, like `file` in `write.csv(x, file)`. A call that reads some
|
|
26
|
+
* files and writes others marks the ones it writes {@link ArgProp.Written} as well, see {@link FnSig.resources}.
|
|
27
|
+
*/
|
|
25
28
|
Resource = 64,
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* what it refers to may be modified, like `envir` in `assign(x, v, envir = e)`, or the file `to` names in
|
|
31
|
+
* `file.copy(from, to)`
|
|
32
|
+
*/
|
|
27
33
|
Written = 128,
|
|
28
34
|
/** quoted or evaluated in another frame, like `expr` in `quote(expr)` */
|
|
29
35
|
Nse = 256,
|
|
@@ -170,6 +176,8 @@ export declare enum SemanticCallTag {
|
|
|
170
176
|
AttachesPackage = "attaches-package",
|
|
171
177
|
/** answers whether a package is available, like `require`, `requireNamespace`, or `find.package` */
|
|
172
178
|
ChecksPackage = "checks-package",
|
|
179
|
+
/** takes a package off the search path, like `detach` or `unloadNamespace` */
|
|
180
|
+
DetachesPackage = "detaches-package",
|
|
173
181
|
/** registers a class, generic, method, or global name without computing anything else, like `setClass` or `utils::globalVariables` */
|
|
174
182
|
Declares = "declares",
|
|
175
183
|
/** reads which environment it runs in, like `environment()` or `parent.frame()`, so moving the call into another frame changes its result */
|
|
@@ -289,6 +297,12 @@ export declare const CallProps: {
|
|
|
289
297
|
* by their full name only.
|
|
290
298
|
*/
|
|
291
299
|
export type FnSig = [name: string, props: ArgProps][];
|
|
300
|
+
/**
|
|
301
|
+
* The signature with only the {@link ArgProp.Resource} arguments the call reads (`writes` false) or writes. Only
|
|
302
|
+
* a call that reads and writes marks the ones it writes {@link ArgProp.Written}, like `exdir` in
|
|
303
|
+
* `unzip(zipfile, exdir = "out")`. One that marks none does whatever it does to every resource argument.
|
|
304
|
+
*/
|
|
305
|
+
declare function resourcesOf(sig: FnSig, writes: boolean): FnSig;
|
|
292
306
|
/**
|
|
293
307
|
* Utility functions for {@link FnSig|function signatures}.
|
|
294
308
|
*/
|
|
@@ -309,6 +323,8 @@ export declare const FnSig: {
|
|
|
309
323
|
readonly every: FnSig;
|
|
310
324
|
/** A signature saying only that the call evaluates one argument; see {@link forcingOnly}. */
|
|
311
325
|
readonly only: typeof forcingOnly;
|
|
326
|
+
/** The signature keeping only the resources the call reads or writes, see {@link resourcesOf}. */
|
|
327
|
+
readonly resources: typeof resourcesOf;
|
|
312
328
|
};
|
|
313
329
|
/**
|
|
314
330
|
* Utility functions for {@link ArgProps|argument property bitfields}.
|
|
@@ -27,9 +27,15 @@ var ArgProp;
|
|
|
27
27
|
ArgProp[ArgProp["Shape"] = 16] = "Shape";
|
|
28
28
|
/** selects a behavior instead of carrying data, like `na.rm` in `sum(x, na.rm = TRUE)` */
|
|
29
29
|
ArgProp[ArgProp["Flag"] = 32] = "Flag";
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* names the resource the call reads or writes, like `file` in `write.csv(x, file)`. A call that reads some
|
|
32
|
+
* files and writes others marks the ones it writes {@link ArgProp.Written} as well, see {@link FnSig.resources}.
|
|
33
|
+
*/
|
|
31
34
|
ArgProp[ArgProp["Resource"] = 64] = "Resource";
|
|
32
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* what it refers to may be modified, like `envir` in `assign(x, v, envir = e)`, or the file `to` names in
|
|
37
|
+
* `file.copy(from, to)`
|
|
38
|
+
*/
|
|
33
39
|
ArgProp[ArgProp["Written"] = 128] = "Written";
|
|
34
40
|
/** quoted or evaluated in another frame, like `expr` in `quote(expr)` */
|
|
35
41
|
ArgProp[ArgProp["Nse"] = 256] = "Nse";
|
|
@@ -178,6 +184,8 @@ var SemanticCallTag;
|
|
|
178
184
|
SemanticCallTag["AttachesPackage"] = "attaches-package";
|
|
179
185
|
/** answers whether a package is available, like `require`, `requireNamespace`, or `find.package` */
|
|
180
186
|
SemanticCallTag["ChecksPackage"] = "checks-package";
|
|
187
|
+
/** takes a package off the search path, like `detach` or `unloadNamespace` */
|
|
188
|
+
SemanticCallTag["DetachesPackage"] = "detaches-package";
|
|
181
189
|
/** registers a class, generic, method, or global name without computing anything else, like `setClass` or `utils::globalVariables` */
|
|
182
190
|
SemanticCallTag["Declares"] = "declares";
|
|
183
191
|
/** reads which environment it runs in, like `environment()` or `parent.frame()`, so moving the call into another frame changes its result */
|
|
@@ -237,7 +245,7 @@ exports.PropagatedProps = getPropMask([
|
|
|
237
245
|
SemanticCallTag.Process, SemanticCallTag.User, SemanticCallTag.CommandLine, SemanticCallTag.Graphics,
|
|
238
246
|
SemanticCallTag.Database, SemanticCallTag.Reads, SemanticCallTag.Writes, SemanticCallTag.Prints,
|
|
239
247
|
SemanticCallTag.Eval, SemanticCallTag.Html, SemanticCallTag.JavaScript, SemanticCallTag.LoadsPackage, SemanticCallTag.AttachesPackage,
|
|
240
|
-
SemanticCallTag.ChecksPackage
|
|
248
|
+
SemanticCallTag.ChecksPackage, SemanticCallTag.DetachesPackage
|
|
241
249
|
]);
|
|
242
250
|
/** Checks whether a {@link PropSelector} is a bitfield of {@link CallProp}s */
|
|
243
251
|
function isCallProp(selector) {
|
|
@@ -377,6 +385,18 @@ exports.CallProps = {
|
|
|
377
385
|
* about a callee flowR cannot resolve.
|
|
378
386
|
*/
|
|
379
387
|
const ForcingEvery = [['...', ArgProp.Forced]];
|
|
388
|
+
/**
|
|
389
|
+
* The signature with only the {@link ArgProp.Resource} arguments the call reads (`writes` false) or writes. Only
|
|
390
|
+
* a call that reads and writes marks the ones it writes {@link ArgProp.Written}, like `exdir` in
|
|
391
|
+
* `unzip(zipfile, exdir = "out")`. One that marks none does whatever it does to every resource argument.
|
|
392
|
+
*/
|
|
393
|
+
function resourcesOf(sig, writes) {
|
|
394
|
+
const written = ArgProp.Resource | ArgProp.Written;
|
|
395
|
+
if (!sig.some(([, p]) => (p & written) === written)) {
|
|
396
|
+
return sig;
|
|
397
|
+
}
|
|
398
|
+
return sig.map(([n, p]) => (p & ArgProp.Resource) === 0 || ((p & ArgProp.Written) !== 0) === writes ? [n, p] : [n, p & ~ArgProp.Resource]);
|
|
399
|
+
}
|
|
380
400
|
/**
|
|
381
401
|
* Utility functions for {@link FnSig|function signatures}.
|
|
382
402
|
*/
|
|
@@ -396,7 +416,9 @@ exports.FnSig = {
|
|
|
396
416
|
/** A signature saying only that the call evaluates every argument; see {@link ForcingEvery}. */
|
|
397
417
|
every: ForcingEvery,
|
|
398
418
|
/** A signature saying only that the call evaluates one argument; see {@link forcingOnly}. */
|
|
399
|
-
only: forcingOnly
|
|
419
|
+
only: forcingOnly,
|
|
420
|
+
/** The signature keeping only the resources the call reads or writes, see {@link resourcesOf}. */
|
|
421
|
+
resources: resourcesOf
|
|
400
422
|
};
|
|
401
423
|
/** the {@link ArgProp} bits as words; integer keys iterate in ascending bit order */
|
|
402
424
|
const ArgPropWords = {
|
|
@@ -20,7 +20,7 @@ import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x
|
|
|
20
20
|
import type { PotentiallyEmptyRArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
21
21
|
import { RSymbol } from '../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
22
22
|
import { type BuiltIn, NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
23
|
-
import { processLibrary } from '../internal/process/functions/call/built-in/built-in-library';
|
|
23
|
+
import { processLibrary, processPrefer } from '../internal/process/functions/call/built-in/built-in-library';
|
|
24
24
|
import { processSourceCall } from '../internal/process/functions/call/built-in/built-in-source';
|
|
25
25
|
import { processApply } from '../internal/process/functions/call/built-in/built-in-apply';
|
|
26
26
|
import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
@@ -52,7 +52,7 @@ import { processClassRelation } from '../internal/process/functions/call/built-i
|
|
|
52
52
|
import { processS4Use } from '../internal/process/functions/call/built-in/built-in-s-four';
|
|
53
53
|
import { processStackEnv } from '../internal/process/functions/call/built-in/built-in-stack-env';
|
|
54
54
|
import { processEnvContents, processListToEnv } from '../internal/process/functions/call/built-in/built-in-env-contents';
|
|
55
|
-
import { processAttach } from '../internal/process/functions/call/built-in/built-in-attach';
|
|
55
|
+
import { processAttach, processDetach } from '../internal/process/functions/call/built-in/built-in-attach';
|
|
56
56
|
import { processWithEnv } from '../internal/process/functions/call/built-in/built-in-with';
|
|
57
57
|
import { processNamespaceAccess } from '../internal/process/functions/call/built-in/built-in-namespace-access';
|
|
58
58
|
import { processLoadCall } from '../internal/process/functions/call/built-in/built-in-load';
|
|
@@ -77,7 +77,12 @@ export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierRefere
|
|
|
77
77
|
definedAt: BuiltIn;
|
|
78
78
|
value: T;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
/** The global state a call reads or writes, applied for every processor (see {@link PlacesAmbientItself}). */
|
|
81
|
+
export interface AmbientConfig {
|
|
82
|
+
/** how the call reads or writes global state like the graphics parameters, the options, or files, see {@link AmbientStateAccess} */
|
|
83
|
+
readonly ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
84
|
+
}
|
|
85
|
+
export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo, AmbientConfig {
|
|
81
86
|
readonly cfg?: ExitPointType;
|
|
82
87
|
/** see {@link ProcessKnownFunctionCallInput#alternativeArgsFrom} */
|
|
83
88
|
readonly alternativeArgsFrom?: number;
|
|
@@ -90,8 +95,6 @@ export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo {
|
|
|
90
95
|
readonly hasUnknownSideEffects?: boolean | LinkTo<RegExp | string>;
|
|
91
96
|
/** without arguments, the result is the frame the call runs in, like `environment()`, so within a function it reads every binding of the frame */
|
|
92
97
|
readonly readsFrame?: boolean;
|
|
93
|
-
/** how the call reads or writes global state like the graphics parameters or the options, see {@link AmbientStateAccess} */
|
|
94
|
-
readonly ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
95
98
|
/** the call changes that state for a scope only, see {@link AmbientScope} */
|
|
96
99
|
readonly scope?: AmbientScope;
|
|
97
100
|
/** record mapping the actual function name called to the arguments that should be treated as function calls */
|
|
@@ -103,6 +106,11 @@ export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo {
|
|
|
103
106
|
* data instead of variables, while everything else in them is evaluated in the caller's frame as usual.
|
|
104
107
|
*/
|
|
105
108
|
readonly markArgsAsMasked?: NseArguments | readonly number[];
|
|
109
|
+
/**
|
|
110
|
+
* The formals whose arguments name variables the call reads by their string value, like `save("x", list = v)`:
|
|
111
|
+
* a string literal anywhere, any other value except in `...`, where a symbol is the variable itself.
|
|
112
|
+
*/
|
|
113
|
+
readonly namesIn?: readonly string[];
|
|
106
114
|
/**
|
|
107
115
|
* Name that should be used for the origin (useful when needing to differentiate between
|
|
108
116
|
* functions like 'return' that use the default builtin processor)
|
|
@@ -116,7 +124,7 @@ export interface BuiltInEvalHandlerArgs extends ResolveInfo {
|
|
|
116
124
|
}
|
|
117
125
|
export type BuiltInEvalHandler = (args: BuiltInEvalHandlerArgs) => Value;
|
|
118
126
|
declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, readAllArguments, cfg, alternativeArgsFrom, hasUnknownSideEffects, ambient, scope, treatAsFnCall, markArgsAsNSE: nse, markArgsAsMasked: masked, keepArgumentOut, sig, readsFrame }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
|
|
119
|
-
declare function defaultBuiltInProcessorReadallArgs<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, markArgsAsNSE: nse, markArgsAsMasked: masked, sig,
|
|
127
|
+
declare function defaultBuiltInProcessorReadallArgs<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, markArgsAsNSE: nse, markArgsAsMasked: masked, sig, namesIn }: Pick<DefaultBuiltInProcessorConfiguration, 'useAsProcessor' | 'markArgsAsNSE' | 'markArgsAsMasked' | 'sig' | 'ambient' | 'namesIn'>): DataflowInformation;
|
|
120
128
|
export declare const BuiltInProcessorMapper: {
|
|
121
129
|
readonly "builtin:acc": typeof processAccess;
|
|
122
130
|
readonly "builtin:app": typeof processApply;
|
|
@@ -156,6 +164,8 @@ export declare const BuiltInProcessorMapper: {
|
|
|
156
164
|
readonly "builtin:env-contents": typeof processEnvContents;
|
|
157
165
|
readonly "builtin:list2env": typeof processListToEnv;
|
|
158
166
|
readonly "builtin:attach": typeof processAttach;
|
|
167
|
+
readonly "builtin:detach": typeof processDetach;
|
|
168
|
+
readonly "builtin:prefer": typeof processPrefer;
|
|
159
169
|
readonly "builtin:nenv": typeof processNewEnv;
|
|
160
170
|
readonly "builtin:class-gen": typeof processClassGenerator;
|
|
161
171
|
readonly "builtin:class-relation": typeof processClassRelation;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuiltIns = exports.BuiltInEvalHandlerMapper = exports.BuiltInProcessorMapper = void 0;
|
|
4
|
+
const ambient_state_name_1 = require("./ambient-state-name");
|
|
4
5
|
const function_semantics_1 = require("../fn/function-semantics");
|
|
5
6
|
const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
|
|
6
7
|
const built_in_access_1 = require("../internal/process/functions/call/built-in/built-in-access");
|
|
@@ -47,6 +48,10 @@ const built_in_recall_1 = require("../internal/process/functions/call/built-in/b
|
|
|
47
48
|
const built_in_s_seven_new_generic_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-new-generic");
|
|
48
49
|
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
49
50
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
51
|
+
const common_1 = require("../internal/process/functions/call/common");
|
|
52
|
+
const node_value_1 = require("../eval/resolve/node-value");
|
|
53
|
+
const resolve_helper_1 = require("./resolve-helper");
|
|
54
|
+
const linker_1 = require("../internal/linker");
|
|
50
55
|
const built_in_proc_name_1 = require("./built-in-proc-name");
|
|
51
56
|
const built_in_purrr_formula_1 = require("../internal/process/functions/call/built-in/built-in-purrr-formula");
|
|
52
57
|
const built_in_new_env_1 = require("../internal/process/functions/call/built-in/built-in-new-env");
|
|
@@ -206,7 +211,7 @@ function dropQuotedReferences(res, processedArguments, nsePositions, lastEnv) {
|
|
|
206
211
|
res.environment = lastEnv;
|
|
207
212
|
}
|
|
208
213
|
}
|
|
209
|
-
function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, markArgsAsNSE: nse, markArgsAsMasked: masked, sig,
|
|
214
|
+
function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, markArgsAsNSE: nse, markArgsAsMasked: masked, sig, namesIn }) {
|
|
210
215
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
211
216
|
name, args, rootId, data, sig, origin: useAsProcessor, nonFunction: dataArgumentSymbols(args, sig), keepArgumentGraphs: nse !== undefined || masked !== undefined
|
|
212
217
|
});
|
|
@@ -214,21 +219,61 @@ function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsPro
|
|
|
214
219
|
const first = firstParameterArgument(args, sig === undefined ? undefined : function_semantics_1.FunctionSemantics.call.signature.layout(sig));
|
|
215
220
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, nse, { first });
|
|
216
221
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, masked, { kind: known_call_handling_1.NseKind.DataMasked, first });
|
|
217
|
-
|
|
222
|
+
if (namesIn !== undefined && sig !== undefined) {
|
|
223
|
+
readNamedVariables(information, args, rootId, data, sig, namesIn);
|
|
224
|
+
}
|
|
225
|
+
return information;
|
|
218
226
|
}
|
|
227
|
+
/** Links the call to the variables its {@link DefaultBuiltInProcessorConfiguration#namesIn} arguments name, an unknown name being an unknown side effect. */
|
|
228
|
+
function readNamedVariables(information, args, rootId, data, sig, namesIn) {
|
|
229
|
+
const bound = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), Object.fromEntries(sig.map(([n]) => [n, n])));
|
|
230
|
+
for (const formal of namesIn) {
|
|
231
|
+
for (const id of bound.get(formal) ?? []) {
|
|
232
|
+
const value = r_argument_1.RArgument.getValue(args, id);
|
|
233
|
+
const names = r_string_1.RString.is(value) ? [value.content.str] : formal === '...' || value === undefined ? [] : node_value_1.NodeValue.stringsOf(value.info.id, data);
|
|
234
|
+
if (names === undefined) {
|
|
235
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
236
|
+
}
|
|
237
|
+
for (const name of names ?? []) {
|
|
238
|
+
(0, linker_1.linkFieldReads)(information.graph, rootId, resolve_helper_1.Resolve.byName(name, data.environment), false);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** The processors that apply the configured {@link BuiltInFnInfo#ambient} access themselves, where it belongs among their steps; the others have it applied after them. */
|
|
244
|
+
const PlacesAmbientItself = new Set([built_in_proc_name_1.BuiltInProcName.Default, built_in_proc_name_1.BuiltInProcName.Source]);
|
|
219
245
|
/**
|
|
220
246
|
* A call that reads or writes the files its arguments name accesses the {@link AmbientStateName.files|files on disk} as well.
|
|
221
247
|
* Closing a device writes the file its opening already wrote, and only a device's file name may number its pages (`plot%03d.png`).
|
|
248
|
+
* A call reading some files and writing others (`unzip(zipfile, exdir = "out")`) does both, each with its own files.
|
|
222
249
|
*/
|
|
223
250
|
function withFileAccess(config) {
|
|
224
251
|
const { tags, ambient, sig } = (config ?? {});
|
|
225
|
-
|
|
252
|
+
if (!tags?.includes(built_in_props_1.SemanticCallTag.File)) {
|
|
253
|
+
return config;
|
|
254
|
+
}
|
|
255
|
+
const writes = tags.includes(built_in_props_1.SemanticCallTag.Writes);
|
|
256
|
+
const split = writes && tags.includes(built_in_props_1.SemanticCallTag.Reads) && sig !== undefined && built_in_props_1.FnSig.resources(sig, true) !== sig;
|
|
257
|
+
/* reading first, so the files read are the ones written before, not the call's own */
|
|
258
|
+
const types = [...split || !writes && tags.includes(built_in_props_1.SemanticCallTag.Reads) ? ["read-files" /* AmbientStateAccessType.ReadFiles */] : [], ...writes ? ["write-files" /* AmbientStateAccessType.WriteFiles */] : []];
|
|
226
259
|
const stated = [ambient ?? []].flat();
|
|
227
|
-
if (
|
|
260
|
+
if (types.length === 0 || stated.some(a => types.includes(a.type) || a.type === "close-device" /* AmbientStateAccessType.CloseDevice */)) {
|
|
228
261
|
return config;
|
|
229
262
|
}
|
|
230
263
|
const numbered = stated.some(a => a.type === "open-device" /* AmbientStateAccessType.OpenDevice */);
|
|
231
|
-
|
|
264
|
+
const glob = tags.includes(built_in_props_1.SemanticCallTag.Glob);
|
|
265
|
+
return { ...config, ambient: [...stated, ...types.map(type => ({
|
|
266
|
+
type, numbered, sig: glob || sig === undefined ? undefined : split ? built_in_props_1.FnSig.resources(sig, type === "write-files" /* AmbientStateAccessType.WriteFiles */) : sig
|
|
267
|
+
}))] };
|
|
268
|
+
}
|
|
269
|
+
/** A call starting a process hands it every environment variable, a call loading a package looks for it in the library paths. */
|
|
270
|
+
function withImplicitReads(config) {
|
|
271
|
+
const { tags, ambient } = (config ?? {});
|
|
272
|
+
const reads = [
|
|
273
|
+
...tags?.includes(built_in_props_1.SemanticCallTag.Process) ? [ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.Env)] : [],
|
|
274
|
+
...tags?.includes(built_in_props_1.SemanticCallTag.LoadsPackage) ? [ambient_state_name_1.AmbientStateName.libPaths] : []
|
|
275
|
+
];
|
|
276
|
+
return reads.length === 0 ? config : { ...config, ambient: [...[ambient ?? []].flat(), ...reads.map(state => ({ type: "read-state" /* AmbientStateAccessType.ReadState */, state }))] };
|
|
232
277
|
}
|
|
233
278
|
exports.BuiltInProcessorMapper = {
|
|
234
279
|
[built_in_proc_name_1.BuiltInProcName.Access]: built_in_access_1.processAccess,
|
|
@@ -269,6 +314,8 @@ exports.BuiltInProcessorMapper = {
|
|
|
269
314
|
[built_in_proc_name_1.BuiltInProcName.EnvContents]: built_in_env_contents_1.processEnvContents,
|
|
270
315
|
[built_in_proc_name_1.BuiltInProcName.ListToEnv]: built_in_env_contents_1.processListToEnv,
|
|
271
316
|
[built_in_proc_name_1.BuiltInProcName.Attach]: built_in_attach_1.processAttach,
|
|
317
|
+
[built_in_proc_name_1.BuiltInProcName.Detach]: built_in_attach_1.processDetach,
|
|
318
|
+
[built_in_proc_name_1.BuiltInProcName.Prefer]: built_in_library_1.processPrefer,
|
|
272
319
|
[built_in_proc_name_1.BuiltInProcName.NewEnv]: built_in_new_env_1.processNewEnv,
|
|
273
320
|
[built_in_proc_name_1.BuiltInProcName.ClassGenerator]: built_in_class_generator_1.processClassGenerator,
|
|
274
321
|
[built_in_proc_name_1.BuiltInProcName.ClassRelation]: built_in_class_relation_1.processClassRelation,
|
|
@@ -328,7 +375,11 @@ class BuiltIns {
|
|
|
328
375
|
(0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(exports.BuiltInProcessorMapper))}!`);
|
|
329
376
|
const mappedEval = evalHandler === undefined ? undefined : exports.BuiltInEvalHandlerMapper[evalHandler];
|
|
330
377
|
(0, assert_1.guard)(evalHandler === undefined || mappedEval !== undefined, () => `Eval handler ${evalHandler} is unknown! Please pass a valid one of ${JSON.stringify(Object.keys(exports.BuiltInEvalHandlerMapper))}!`);
|
|
331
|
-
config = withFileAccess(config);
|
|
378
|
+
config = withImplicitReads(withFileAccess(config));
|
|
379
|
+
const ambient = PlacesAmbientItself.has(processor) ? undefined : config?.ambient;
|
|
380
|
+
const process = ambient === undefined
|
|
381
|
+
? (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config)
|
|
382
|
+
: (name, args, rootId, data) => (0, built_in_ambient_state_1.applyAmbientStateAccess)(mappedProcessor(name, args, rootId, data, config), args, rootId, data, ambient);
|
|
332
383
|
for (const name of names) {
|
|
333
384
|
const n = identifier_1.Identifier.getName(name);
|
|
334
385
|
const id = node_id_1.NodeId.toBuiltIn(n);
|
|
@@ -336,7 +387,7 @@ class BuiltIns {
|
|
|
336
387
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
337
388
|
definedAt: id,
|
|
338
389
|
cds: undefined,
|
|
339
|
-
processor:
|
|
390
|
+
processor: process,
|
|
340
391
|
config,
|
|
341
392
|
evalHandler: mappedEval,
|
|
342
393
|
processorName: processor,
|