@eagleoutice/flowr 2.15.9 → 2.16.0
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 +47 -41
- package/abstract-interpretation/absint-inference.d.ts +2 -2
- package/abstract-interpretation/absint-inference.js +32 -79
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/benchmark/slicer.d.ts +0 -1
- package/benchmark/slicer.js +1 -2
- package/cli/repl/commands/repl-signature.js +12 -3
- package/config.d.ts +5 -1
- package/control-flow/cfg-properties.js +0 -22
- package/control-flow/happens-before.d.ts +7 -2
- package/control-flow/happens-before.js +55 -31
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/apply-kill.js +6 -2
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-props.d.ts +16 -1
- package/dataflow/environments/built-in-props.js +33 -20
- package/dataflow/environments/built-in.d.ts +8 -3
- package/dataflow/environments/built-in.js +52 -82
- package/dataflow/environments/default-builtin-config.d.ts +551 -21
- package/dataflow/environments/default-builtin-config.js +121 -45
- package/dataflow/environments/define.d.ts +3 -2
- package/dataflow/environments/define.js +4 -3
- package/dataflow/environments/deprecation-info.d.ts +45 -0
- package/dataflow/environments/deprecation-info.js +13 -0
- package/dataflow/environments/environment.d.ts +7 -5
- package/dataflow/environments/environment.js +55 -121
- package/dataflow/environments/identifier.d.ts +6 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +180 -58
- package/dataflow/fn/class-declaration.d.ts +8 -13
- package/dataflow/fn/class-declaration.js +95 -116
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +51 -41
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.d.ts +9 -1
- package/dataflow/fn/higher-order-function.js +27 -24
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +291 -123
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +13 -1
- package/dataflow/graph/graph.js +74 -66
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +31 -4
- package/dataflow/internal/control-flow.js +61 -39
- package/dataflow/internal/linker.d.ts +17 -8
- package/dataflow/internal/linker.js +286 -213
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
- 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 +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
- package/dataflow/internal/process/functions/call/common.d.ts +4 -4
- package/dataflow/internal/process/functions/call/common.js +49 -71
- package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
- package/dataflow/internal/process/functions/call/deferred.js +81 -63
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +257 -154
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +4 -3
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/data/faq/faqs.js +3 -3
- package/documentation/data/interface/doc-writing-code.js +1 -2
- package/documentation/data/server/doc-data-server-messages.js +7 -7
- package/documentation/doc-capabilities.js +80 -34
- package/documentation/doc-util/doc-query.d.ts +0 -3
- package/documentation/doc-util/doc-query.js +4 -3
- package/documentation/wiki-analyzer.js +1 -1
- package/documentation/wiki-cfg.js +5 -6
- package/documentation/wiki-core.js +8 -8
- package/documentation/wiki-dataflow-graph.js +10 -11
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linting-and-testing.js +3 -3
- package/documentation/wiki-overview.js +6 -6
- package/documentation/wiki-query.js +9 -101
- package/documentation/wiki-setup.js +23 -0
- package/documentation/wiki-signature-database.js +1 -1
- package/linter/linter-rules.d.ts +18 -9
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/deprecated-functions.d.ts +1 -45
- package/linter/rules/deprecated-functions.js +24 -33
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +114 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +128 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.d.ts +2 -0
- package/project/flowr-analyzer.js +28 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
- package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +4 -0
- package/project/sigdb/manifest.d.ts +2 -0
- package/project/sigdb/manifest.js +10 -1
- package/project/sigdb/reader.js +23 -61
- package/project/sigdb/sigdb-download.d.ts +29 -6
- package/project/sigdb/sigdb-download.js +212 -64
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
- package/queries/catalog/call-context-query/cascade-action.js +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/data/data.d.ts +21 -14
- package/r-bridge/data/data.js +28 -20
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell.js +6 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +115 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +2 -0
- package/util/files.js +3 -1
- package/util/mermaid/mermaid.js +6 -2
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
package/benchmark/slicer.d.ts
CHANGED
package/benchmark/slicer.js
CHANGED
|
@@ -57,7 +57,6 @@ class BenchmarkSlicer {
|
|
|
57
57
|
dataflow;
|
|
58
58
|
normalizedAst;
|
|
59
59
|
controlFlow;
|
|
60
|
-
callGraph;
|
|
61
60
|
totalStopwatch;
|
|
62
61
|
finished = false;
|
|
63
62
|
// Yes, this is unclean, but we know that we assign the executor during the initialization and this saves us from having to check for nullability every time
|
|
@@ -266,7 +265,7 @@ class BenchmarkSlicer {
|
|
|
266
265
|
this.guardActive();
|
|
267
266
|
const g = this.dataflow?.graph;
|
|
268
267
|
(0, assert_1.guard)(g !== undefined, 'dataflow should be defined for call graph extraction');
|
|
269
|
-
this.
|
|
268
|
+
this.measureSimpleStep('extract call graph', () => call_graph_1.CallGraph.compute(g));
|
|
270
269
|
}
|
|
271
270
|
/**
|
|
272
271
|
* Infer the shape of data frames using abstract interpretation with {@link inferDataFrameShapes}
|
|
@@ -74,12 +74,12 @@ async function runDownload(output, analyzer, rest) {
|
|
|
74
74
|
const f = output.formatter;
|
|
75
75
|
const sigdb = analyzer.flowrConfig.solver.sigdb;
|
|
76
76
|
try {
|
|
77
|
-
const { dir, manifest, files } = await (0, sigdb_download_1.downloadFullSigDb)({
|
|
77
|
+
const { tag, dir, manifest, files, downloaded, bytes, ms } = await (0, sigdb_download_1.downloadFullSigDb)({
|
|
78
78
|
version: rest.find(a => a.length > 0),
|
|
79
79
|
repo: sigdb.downloadRepo,
|
|
80
80
|
onProgress: msg => output.stdout((0, ansi_1.italic)(` ${msg}`, f))
|
|
81
81
|
});
|
|
82
|
-
output.stdout(`
|
|
82
|
+
output.stdout(`Signature database ${(0, ansi_1.bold)(tag, f)}: ${(0, ansi_1.bold)(String(files.length), f)} file(s) in ${(0, ansi_1.bold)(dir, f)}, ${downloaded.length} fetched now (${(bytes / 1e6).toFixed(1)} MB in ${(ms / 1000).toFixed(1)}s).`);
|
|
83
83
|
if (manifest) {
|
|
84
84
|
await analyzer.context().deps.addDatabaseSource(manifest);
|
|
85
85
|
analyzer.reset();
|
|
@@ -93,7 +93,16 @@ async function runDownload(output, analyzer, rest) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
96
|
-
|
|
96
|
+
if (e instanceof sigdb_download_1.SigDbDownloadError) {
|
|
97
|
+
output.stderr(`Download of ${e.tag} incomplete: ${e.completed} file(s) are in place, ${e.failed.length} failed:`);
|
|
98
|
+
for (const { name, reason } of e.failed) {
|
|
99
|
+
output.stderr(` ${name}: ${reason}`);
|
|
100
|
+
}
|
|
101
|
+
output.stderr((0, ansi_1.italic)('Run the command again to fetch only what is missing.', f));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
output.stderr(`Download failed: ${e.message}`);
|
|
105
|
+
}
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
108
|
/** every `:signature` subcommand keyed by name -- the single source driving both dispatch and completion */
|
package/config.d.ts
CHANGED
|
@@ -249,11 +249,15 @@ export interface FlowrConfig {
|
|
|
249
249
|
*/
|
|
250
250
|
readonly gas: FlowrGasConfig;
|
|
251
251
|
}
|
|
252
|
+
type PlainFlowrConfigPaths = AutocompletablePaths<Omit<FlowrConfig, 'specializeConfig'>>;
|
|
252
253
|
/**
|
|
253
254
|
* Every path into the configuration, which is what {@link FlowrConfig.setInConfig} and
|
|
254
255
|
* {@link FlowrAnalyzerBuilder#configure|configure()} take and what an editor completes.
|
|
256
|
+
*
|
|
257
|
+
* {@link FlowrConfig.specializeConfig} is spelled out one overwrite deep, not walked: it holds a partial
|
|
258
|
+
* configuration per {@link ProjectKind}, so walking it re-enters the whole configuration once per kind.
|
|
255
259
|
*/
|
|
256
|
-
export type ValidFlowrConfigPaths =
|
|
260
|
+
export type ValidFlowrConfigPaths = PlainFlowrConfigPaths | 'specializeConfig' | `specializeConfig.${ProjectKind}` | `specializeConfig.${ProjectKind}.${PlainFlowrConfigPaths | 'inherit'}`;
|
|
257
261
|
/** Whether library exports should be resolved from a signature database (`solver.sigdb.enabled`). */
|
|
258
262
|
export declare function isSigDbEnabled(config: FlowrConfig | undefined): boolean;
|
|
259
263
|
/**
|
|
@@ -70,28 +70,6 @@ function checkExitIsReachedByAll(cfg) {
|
|
|
70
70
|
function checkEntryReachesAll(cfg) {
|
|
71
71
|
return checkReachFrom('entry', cfg, cfg.entryPoints, simple_visitor_1.visitCfgInOrder);
|
|
72
72
|
}
|
|
73
|
-
function _checkFdIOCount(cfg, dir, type, limit) {
|
|
74
|
-
const counts = new Map();
|
|
75
|
-
for (const [from, targets] of cfg.graph.edges()) {
|
|
76
|
-
for (const [to, edge] of targets) {
|
|
77
|
-
const important = dir === 'in' ? to : from;
|
|
78
|
-
if (control_flow_graph_1.CfgEdge.isFlowDependency(edge)) {
|
|
79
|
-
counts.set(important, (counts.get(important) ?? 0) + 1);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const check = type === 'exact' ? (a) => a === limit : (a) => a <= limit;
|
|
84
|
-
for (const [node, count] of counts) {
|
|
85
|
-
if (type === 'exact' && (cfg.entryPoints.includes(node) || cfg.exitPoints.includes(node) || !cfg.graph.rootIds().has(node))) {
|
|
86
|
-
continue; // skip entry and exit points, they do not have to satisfy this
|
|
87
|
-
}
|
|
88
|
-
if (!check(count)) {
|
|
89
|
-
log_1.log.error(`Node ${node} has ${count} ${dir} edges, expected ${type} ${limit}`);
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
73
|
function checkNoDirectCycles(cfg, type) {
|
|
96
74
|
for (const [from, targets] of cfg.graph.edges()) {
|
|
97
75
|
for (const [to, edge] of targets) {
|
|
@@ -5,9 +5,14 @@ import { type ControlFlowGraph } from './control-flow-graph';
|
|
|
5
5
|
* Determines if node `a` happens before node `b` in the control flow graph.
|
|
6
6
|
*/
|
|
7
7
|
export declare function happensBefore(cfg: ControlFlowGraph, a: NodeId, b: NodeId): Ternary;
|
|
8
|
+
/** Whether one of the `candidates` always happens before `b`; one walk back from `b` settles all candidates at once. */
|
|
9
|
+
export declare function someAlwaysBefore(cfg: ControlFlowGraph, candidates: ReadonlySet<NodeId>, b: NodeId): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The `candidates` none of the others always happens before, i.e. those some path reaches without passing another.
|
|
12
|
+
* With `within` (a function's body) the walk stays among those nodes; a region that is one cycle keeps every candidate.
|
|
13
|
+
*/
|
|
14
|
+
export declare function firstOnSomePath(cfg: ControlFlowGraph, candidates: ReadonlySet<NodeId>, within?: ReadonlySet<NodeId>): ReadonlySet<NodeId>;
|
|
8
15
|
/** Every node reachable from one of `from`, the seeds included: `happensBefore(cfg, from_i, to)` is not {@link Ternary#Never} for some seed exactly when `to` is in here. */
|
|
9
16
|
export declare function reachableFrom(cfg: ControlFlowGraph, from: Iterable<NodeId>): ReadonlySet<NodeId>;
|
|
10
17
|
/** @see {@link reachableFrom} - the other direction */
|
|
11
18
|
export declare function reachableTo(cfg: ControlFlowGraph, to: Iterable<NodeId>): ReadonlySet<NodeId>;
|
|
12
|
-
/** Whether a node that may be evaluated before `to` satisfies `test`, stopping at the first that does; `to` itself is not tested. */
|
|
13
|
-
export declare function someReachableTo(cfg: ControlFlowGraph, to: NodeId, test: (id: NodeId) => boolean): boolean;
|
|
@@ -1,38 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.happensBefore = happensBefore;
|
|
4
|
+
exports.someAlwaysBefore = someAlwaysBefore;
|
|
5
|
+
exports.firstOnSomePath = firstOnSomePath;
|
|
4
6
|
exports.reachableFrom = reachableFrom;
|
|
5
7
|
exports.reachableTo = reachableTo;
|
|
6
|
-
exports.someReachableTo = someReachableTo;
|
|
7
8
|
const logic_1 = require("../util/logic");
|
|
8
9
|
const control_flow_graph_1 = require("./control-flow-graph");
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
function happensBefore(cfg, a, b) {
|
|
10
|
+
/** Walks back from `b`, handing each node the vertex its outermost open branch scope joins on, until `stop` says so. */
|
|
11
|
+
function walkBack(cfg, b, stop) {
|
|
13
12
|
const visited = new Set();
|
|
14
13
|
/* the first is the id we are currently at, the second one the vertex the current largest cd scope joins on */
|
|
15
14
|
const stack = [[b, undefined]];
|
|
16
15
|
while (stack.length > 0) {
|
|
17
16
|
const [current, cd] = stack.pop();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return cd ? logic_1.Ternary.Maybe : logic_1.Ternary.Always;
|
|
17
|
+
if (stop(current, cd)) {
|
|
18
|
+
return true;
|
|
21
19
|
}
|
|
22
20
|
else if (visited.has(current)) {
|
|
23
21
|
continue;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
useCd = undefined;
|
|
27
|
-
}
|
|
23
|
+
const useCd = cd && (current === cd || visited.has(cd)) ? undefined : cd;
|
|
28
24
|
visited.add(current);
|
|
29
25
|
for (const [id, t] of cfg.ingoingEdges(current) ?? []) {
|
|
30
26
|
/* the vertex that caused the branch is where its arms join again, so it closes the scope */
|
|
31
|
-
const joinsAt = control_flow_graph_1.CfgEdge.isControlDependency(t) ? control_flow_graph_1.CfgEdge.unpackCause(t) :
|
|
27
|
+
const joinsAt = control_flow_graph_1.CfgEdge.isControlDependency(t) ? control_flow_graph_1.CfgEdge.unpackCause(t) : undefined;
|
|
32
28
|
stack.push([id, useCd ?? joinsAt]);
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
|
-
return
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Determines if node `a` happens before node `b` in the control flow graph.
|
|
35
|
+
*/
|
|
36
|
+
function happensBefore(cfg, a, b) {
|
|
37
|
+
let result = logic_1.Ternary.Never;
|
|
38
|
+
walkBack(cfg, b, (current, cd) => {
|
|
39
|
+
if (current === a) {
|
|
40
|
+
result = cd ? logic_1.Ternary.Maybe : logic_1.Ternary.Always;
|
|
41
|
+
}
|
|
42
|
+
return current === a;
|
|
43
|
+
});
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/** Whether one of the `candidates` always happens before `b`; one walk back from `b` settles all candidates at once. */
|
|
47
|
+
function someAlwaysBefore(cfg, candidates, b) {
|
|
48
|
+
const met = new Set();
|
|
49
|
+
return walkBack(cfg, b, (current, cd) => {
|
|
50
|
+
if (current === b || !candidates.has(current) || met.has(current)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
met.add(current);
|
|
54
|
+
return !cd;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The `candidates` none of the others always happens before, i.e. those some path reaches without passing another.
|
|
59
|
+
* With `within` (a function's body) the walk stays among those nodes; a region that is one cycle keeps every candidate.
|
|
60
|
+
*/
|
|
61
|
+
function firstOnSomePath(cfg, candidates, within) {
|
|
62
|
+
const inside = (id) => within === undefined || within.has(id);
|
|
63
|
+
const predecessors = (id) => [...cfg.ingoingEdges(id)?.keys() ?? []].filter(inside);
|
|
64
|
+
const region = closure(candidates, predecessors);
|
|
65
|
+
const starts = [...region].filter(id => predecessors(id).length === 0);
|
|
66
|
+
if (starts.length === 0) {
|
|
67
|
+
return candidates;
|
|
68
|
+
}
|
|
69
|
+
const first = new Set();
|
|
70
|
+
closure(starts, id => {
|
|
71
|
+
if (candidates.has(id)) {
|
|
72
|
+
first.add(id);
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
return [...cfg.outgoingEdges(id)?.keys() ?? []].filter(next => region.has(next));
|
|
76
|
+
});
|
|
77
|
+
return first;
|
|
36
78
|
}
|
|
37
79
|
function closure(seeds, step) {
|
|
38
80
|
const seen = new Set(seeds);
|
|
@@ -55,22 +97,4 @@ function reachableFrom(cfg, from) {
|
|
|
55
97
|
function reachableTo(cfg, to) {
|
|
56
98
|
return closure(to, id => cfg.predecessors(id));
|
|
57
99
|
}
|
|
58
|
-
/** Whether a node that may be evaluated before `to` satisfies `test`, stopping at the first that does; `to` itself is not tested. */
|
|
59
|
-
function someReachableTo(cfg, to, test) {
|
|
60
|
-
const seen = new Set([to]);
|
|
61
|
-
const stack = [to];
|
|
62
|
-
while (stack.length > 0) {
|
|
63
|
-
for (const previous of cfg.predecessors(stack.pop())) {
|
|
64
|
-
if (seen.has(previous)) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
else if (test(previous)) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
seen.add(previous);
|
|
71
|
-
stack.push(previous);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
100
|
//# sourceMappingURL=happens-before.js.map
|
|
@@ -12,6 +12,6 @@ export declare const loopyFunctions: Set<BuiltInProcName>;
|
|
|
12
12
|
* @param controlflow - control flow graph
|
|
13
13
|
* @param ast - normalized ast
|
|
14
14
|
* @param ctx - current flowr analyzer context
|
|
15
|
-
* @returns true if the given loop only iterates once
|
|
15
|
+
* @returns true if the given loop only iterates once, `undefined` if we cannot tell
|
|
16
16
|
*/
|
|
17
17
|
export declare function onlyLoopsOnce(loop: NodeId, dataflow: DataflowGraph, controlflow: ControlFlowInformation, ast: NormalizedAst, ctx: ReadOnlyFlowrAnalyzerContext): boolean | undefined;
|
|
@@ -21,7 +21,7 @@ exports.loopyFunctions = new Set([built_in_proc_name_1.BuiltInProcName.ForLoop,
|
|
|
21
21
|
* @param controlflow - control flow graph
|
|
22
22
|
* @param ast - normalized ast
|
|
23
23
|
* @param ctx - current flowr analyzer context
|
|
24
|
-
* @returns true if the given loop only iterates once
|
|
24
|
+
* @returns true if the given loop only iterates once, `undefined` if we cannot tell
|
|
25
25
|
*/
|
|
26
26
|
function onlyLoopsOnce(loop, dataflow, controlflow, ast, ctx) {
|
|
27
27
|
const vertex = dataflow.getVertex(loop);
|
|
@@ -30,43 +30,43 @@ function onlyLoopsOnce(loop, dataflow, controlflow, ast, ctx) {
|
|
|
30
30
|
}
|
|
31
31
|
(0, assert_1.guard)(vertex_1.DfgVertex.isFunctionCall(vertex), 'invalid vertex type for onlyLoopsOnce');
|
|
32
32
|
(0, assert_1.guard)(vertex.origin !== 'unnamed' && exports.loopyFunctions.has(vertex.origin[0]), 'onlyLoopsOnce can only be called with loops');
|
|
33
|
-
|
|
33
|
+
/* a for loop over a vector of one element */
|
|
34
34
|
if (vertex.origin[0] === built_in_proc_name_1.BuiltInProcName.ForLoop) {
|
|
35
|
-
if (vertex.args.length < 2) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
35
|
const vectorOfLoop = vertex.args[1];
|
|
39
|
-
if (vectorOfLoop === r_function_call_1.EmptyArgument) {
|
|
36
|
+
if (vectorOfLoop === undefined || vectorOfLoop === r_function_call_1.EmptyArgument) {
|
|
40
37
|
return undefined;
|
|
41
38
|
}
|
|
42
39
|
const vector = node_value_1.NodeValue.soleOf(vectorOfLoop.nodeId, resolve_helper_1.Resolve.info(dataflow, ctx));
|
|
43
|
-
|
|
44
|
-
: vector.type === 'vector' ? (0, r_value_1.isValue)(vector.elements) && vector.elements.length === 1
|
|
45
|
-
: vector.type === 'interval' ? (0, r_value_1.isValue)(vector.start) && (0, r_value_1.isValue)(vector.end) && vector.startInclusive && vector.endInclusive
|
|
46
|
-
&& (0, r_value_1.isValue)(vector.start.value) && (0, r_value_1.isValue)(vector.end.value) && vector.start.value.num === vector.end.value.num
|
|
47
|
-
: vector.type === 'string' || vector.type === 'logical';
|
|
48
|
-
if (once) {
|
|
40
|
+
if (vector !== undefined && holdsOneElement(vector)) {
|
|
49
41
|
return true;
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
/* or a loop always left after the first iteration */
|
|
45
|
+
return new CfgSingleIterationLoopDetector(loop, {
|
|
54
46
|
controlFlow: controlflow,
|
|
55
47
|
normalizedAst: ast,
|
|
56
48
|
dfg: dataflow,
|
|
57
|
-
ctx
|
|
49
|
+
ctx,
|
|
58
50
|
defaultVisitingOrder: 'forward'
|
|
59
|
-
});
|
|
60
|
-
|
|
51
|
+
}).loopsOnlyOnce();
|
|
52
|
+
}
|
|
53
|
+
function holdsOneElement(value, element = false) {
|
|
54
|
+
if (!(0, r_value_1.isValue)(value)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return value.type === 'vector' ? (0, r_value_1.isValue)(value.elements) && value.elements.length === 1 && holdsOneElement(value.elements[0], true)
|
|
58
|
+
: value.type === 'interval' ? (0, r_value_1.isValue)(value.start) && (0, r_value_1.isValue)(value.end) && value.startInclusive && value.endInclusive
|
|
59
|
+
&& (0, r_value_1.isValue)(value.start.value) && (0, r_value_1.isValue)(value.end.value) && value.start.value.num === value.end.value.num
|
|
60
|
+
: (value.type === 'string' || value.type === 'logical' || (element && value.type === 'number')) && (0, r_value_1.isValue)(value.value);
|
|
61
61
|
}
|
|
62
62
|
class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
|
|
63
|
+
loopToCheck;
|
|
63
64
|
loopCds = undefined;
|
|
64
65
|
encounteredLoopBreaker = false;
|
|
65
66
|
onlyLoopyOnce = false;
|
|
66
|
-
loopToCheck
|
|
67
|
-
constructor(loop, config) {
|
|
67
|
+
constructor(loopToCheck, config) {
|
|
68
68
|
super(config);
|
|
69
|
-
this.loopToCheck =
|
|
69
|
+
this.loopToCheck = loopToCheck;
|
|
70
70
|
}
|
|
71
71
|
startVisitor(_) {
|
|
72
72
|
const g = this.config.controlFlow.graph;
|
|
@@ -92,38 +92,25 @@ class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.Seman
|
|
|
92
92
|
}
|
|
93
93
|
this.onlyLoopyOnce ||= this.encounteredLoopBreaker && (0, info_1.happensInEveryBranch)(this.loopCds?.filter(c => !c.byIteration));
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
const filtered = cds.filter(c => c.id !== this.loopToCheck);
|
|
95
|
+
breaks({ call }) {
|
|
96
|
+
this.encounteredLoopBreaker = true;
|
|
97
|
+
const filtered = call.cds?.filter(c => c.id !== this.loopToCheck) ?? [];
|
|
100
98
|
if (filtered.length > 0) {
|
|
101
|
-
|
|
102
|
-
this.loopCds = filtered;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
this.loopCds = this.loopCds.concat(filtered);
|
|
106
|
-
}
|
|
99
|
+
this.loopCds = (this.loopCds ?? []).concat(filtered);
|
|
107
100
|
}
|
|
108
101
|
}
|
|
109
102
|
onBreakCall(data) {
|
|
110
|
-
this.
|
|
111
|
-
this.app(data.call.cds);
|
|
103
|
+
this.breaks(data);
|
|
112
104
|
}
|
|
113
105
|
onReturnCall(data) {
|
|
114
|
-
this.
|
|
115
|
-
this.app(data.call.cds);
|
|
106
|
+
this.breaks(data);
|
|
116
107
|
}
|
|
117
108
|
onStopCall(data) {
|
|
118
|
-
this.
|
|
119
|
-
this.app(data.call.cds);
|
|
109
|
+
this.breaks(data);
|
|
120
110
|
}
|
|
121
111
|
onStopIfNotCall(data) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.encounteredLoopBreaker = true;
|
|
125
|
-
this.app(data.call.cds);
|
|
126
|
-
return;
|
|
112
|
+
if (this.getBoolArgValue(data) === false) {
|
|
113
|
+
this.breaks(data);
|
|
127
114
|
}
|
|
128
115
|
}
|
|
129
116
|
loopsOnlyOnce() {
|
|
@@ -64,6 +64,10 @@ function cancelRevivedKills(kills, writes) {
|
|
|
64
64
|
}
|
|
65
65
|
return remaining;
|
|
66
66
|
}
|
|
67
|
+
/** the options and graphics state flowR keeps as `#...` variables, which `rm(list = ls())` does not touch in R */
|
|
68
|
+
function isAmbientState(key) {
|
|
69
|
+
return key.startsWith('#');
|
|
70
|
+
}
|
|
67
71
|
function isBuiltInDef(d) {
|
|
68
72
|
return d.type === identifier_1.ReferenceType.BuiltInFunction || d.type === identifier_1.ReferenceType.BuiltInConstant;
|
|
69
73
|
}
|
|
@@ -88,7 +92,7 @@ function weakenAll(env, cds, except) {
|
|
|
88
92
|
return;
|
|
89
93
|
}
|
|
90
94
|
for (const [key, defs] of env.memory) {
|
|
91
|
-
if (except?.has(key)) {
|
|
95
|
+
if (except?.has(key) || isAmbientState(key)) {
|
|
92
96
|
continue;
|
|
93
97
|
}
|
|
94
98
|
if (defs.some(d => !isBuiltInDef(d))) {
|
|
@@ -103,7 +107,7 @@ function removeAllInFrame(env, except) {
|
|
|
103
107
|
return;
|
|
104
108
|
}
|
|
105
109
|
for (const [key, defs] of env.memory) {
|
|
106
|
-
if (except?.has(key) || defs.every(isBuiltInDef)) {
|
|
110
|
+
if (except?.has(key) || isAmbientState(key) || defs.every(isBuiltInDef)) {
|
|
107
111
|
continue;
|
|
108
112
|
}
|
|
109
113
|
const kept = defs.filter(isBuiltInDef);
|
|
@@ -3,6 +3,7 @@ import type { BuiltInEvalName } from './built-in-eval-name';
|
|
|
3
3
|
import { BuiltIns } from './built-in';
|
|
4
4
|
import type { Identifier } from './identifier';
|
|
5
5
|
import type { BuiltInFnInfo } from './built-in-props';
|
|
6
|
+
import type { DeprecatedFunctionInformation } from './deprecation-info';
|
|
6
7
|
export interface BaseBuiltInDefinition {
|
|
7
8
|
/** The type of the built-in configuration */
|
|
8
9
|
readonly type: string;
|
|
@@ -33,6 +34,7 @@ export interface BuiltInFunctionDefinition<BuiltInProcessor extends keyof typeof
|
|
|
33
34
|
readonly processor: BuiltInProcessor;
|
|
34
35
|
readonly config?: ConfigOfProcessor<BuiltInProcessor> & BuiltInFnInfo & {
|
|
35
36
|
libFn?: boolean;
|
|
37
|
+
deprInfo?: DeprecatedFunctionInformation;
|
|
36
38
|
};
|
|
37
39
|
/** the value solver to use when folding a call to this function to a constant, see {@link BuiltInEvalHandlerMapper} */
|
|
38
40
|
readonly evalHandler?: BuiltInEvalName;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DecodedFunction } from '../../project/sigdb/decode';
|
|
2
|
+
import { Ternary } from '../../util/logic';
|
|
2
3
|
/**
|
|
3
4
|
* What a single argument of a call is used for, as a bitmask ({@link ArgProp.Forced}/{@link ArgProp.NoDefault}
|
|
4
5
|
* lead, being the two bits the signature database can also state).
|
|
@@ -149,7 +150,13 @@ export declare enum SemanticCallTag {
|
|
|
149
150
|
/** produces raw HTML or JavaScript, such as `shiny::HTML` */
|
|
150
151
|
Html = "html",
|
|
151
152
|
/** produces raw JavaScript code, such as `shinyjs::runjs` */
|
|
152
|
-
JavaScript = "javascript"
|
|
153
|
+
JavaScript = "javascript",
|
|
154
|
+
/** loads a package's namespace (running its `.onLoad`), like `library` or `loadNamespace` */
|
|
155
|
+
LoadsPackage = "loads-package",
|
|
156
|
+
/** puts a package's exports on the search path, so their bare names resolve, like `library` or `attachNamespace` */
|
|
157
|
+
AttachesPackage = "attaches-package",
|
|
158
|
+
/** answers whether a package is available, like `require`, `requireNamespace`, or `find.package` */
|
|
159
|
+
ChecksPackage = "checks-package"
|
|
153
160
|
}
|
|
154
161
|
/** a bitfield of {@link ArgProp} */
|
|
155
162
|
export type ArgProps = number;
|
|
@@ -269,6 +276,8 @@ export declare const FnSig: {
|
|
|
269
276
|
readonly posWith: typeof argsWith;
|
|
270
277
|
/** Which of the first `count` arguments a call evaluates; see {@link forcedArgs}. */
|
|
271
278
|
readonly forced: typeof forcedArgs;
|
|
279
|
+
/** How surely a call evaluates each of the first `count` arguments; see {@link argForcing}. */
|
|
280
|
+
readonly forcing: typeof argForcing;
|
|
272
281
|
/** A signature saying only that the call evaluates every argument; see {@link ForcingEvery}. */
|
|
273
282
|
readonly every: FnSig;
|
|
274
283
|
/** A signature saying only that the call evaluates one argument; see {@link forcingOnly}. */
|
|
@@ -314,6 +323,7 @@ export interface SigLayout {
|
|
|
314
323
|
/** the position of the {@link ArgProp.Alias} argument, handed back as the result, `-1` if there is none */
|
|
315
324
|
readonly alias: number;
|
|
316
325
|
forced?: (readonly boolean[])[];
|
|
326
|
+
forcing?: (readonly Ternary[])[];
|
|
317
327
|
}
|
|
318
328
|
/**
|
|
319
329
|
* The positional view of a {@link FnSig}, computed on first use and cached per signature object,
|
|
@@ -332,6 +342,11 @@ declare function forcingOnly(this: void, index: number, name: string): FnSig;
|
|
|
332
342
|
* A signature is the one place that says so, which is why nothing else may state it alongside.
|
|
333
343
|
*/
|
|
334
344
|
declare function forcedArgs(this: void, sig: FnSig | undefined, count: number): readonly boolean[] | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* How surely a call evaluates each of the first `count` arguments: {@link ArgProp.Forced} always,
|
|
347
|
+
* {@link ArgProp.Nse} and {@link ArgProp.Presence} never, anything else maybe; `undefined` without a signature.
|
|
348
|
+
*/
|
|
349
|
+
declare function argForcing(this: void, sig: FnSig | undefined, count: number): readonly Ternary[] | undefined;
|
|
335
350
|
/** The positions of the first `count` arguments that carry any of `prop`. */
|
|
336
351
|
declare function argsWith(this: void, layout: SigLayout, count: number, prop: ArgProps): number[];
|
|
337
352
|
/** the callees that make the calling function itself a generic ({@link CallProp.Generic}) */
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DispatchCallees = exports.ArgProps = exports.FnSig = exports.CallProps = exports.PropagatedProps = exports.FileInputProps = exports.SigDbInferable = exports.InputProps = exports.ExclusiveCallProps = exports.ImpureProps = exports.ProvenanceProps = exports.SemanticCallTag = exports.CallProp = exports.ArgProp = void 0;
|
|
4
4
|
exports.fnInfoFromSignature = fnInfoFromSignature;
|
|
5
5
|
const record_1 = require("../../util/record");
|
|
6
|
+
const logic_1 = require("../../util/logic");
|
|
6
7
|
/**
|
|
7
8
|
* What a single argument of a call is used for, as a bitmask ({@link ArgProp.Forced}/{@link ArgProp.NoDefault}
|
|
8
9
|
* lead, being the two bits the signature database can also state).
|
|
@@ -157,6 +158,12 @@ var SemanticCallTag;
|
|
|
157
158
|
SemanticCallTag["Html"] = "html";
|
|
158
159
|
/** produces raw JavaScript code, such as `shinyjs::runjs` */
|
|
159
160
|
SemanticCallTag["JavaScript"] = "javascript";
|
|
161
|
+
/** loads a package's namespace (running its `.onLoad`), like `library` or `loadNamespace` */
|
|
162
|
+
SemanticCallTag["LoadsPackage"] = "loads-package";
|
|
163
|
+
/** puts a package's exports on the search path, so their bare names resolve, like `library` or `attachNamespace` */
|
|
164
|
+
SemanticCallTag["AttachesPackage"] = "attaches-package";
|
|
165
|
+
/** answers whether a package is available, like `require`, `requireNamespace`, or `find.package` */
|
|
166
|
+
SemanticCallTag["ChecksPackage"] = "checks-package";
|
|
160
167
|
})(SemanticCallTag || (exports.SemanticCallTag = SemanticCallTag = {}));
|
|
161
168
|
/**
|
|
162
169
|
* The properties that say where a definition comes from rather than what it does. A bare
|
|
@@ -211,7 +218,8 @@ exports.PropagatedProps = getPropMask([
|
|
|
211
218
|
SemanticCallTag.Random, SemanticCallTag.File, SemanticCallTag.TempFile, SemanticCallTag.Network,
|
|
212
219
|
SemanticCallTag.Process, SemanticCallTag.User, SemanticCallTag.CommandLine, SemanticCallTag.Graphics,
|
|
213
220
|
SemanticCallTag.Database, SemanticCallTag.Reads, SemanticCallTag.Writes, SemanticCallTag.Prints,
|
|
214
|
-
SemanticCallTag.Eval, SemanticCallTag.Html, SemanticCallTag.JavaScript
|
|
221
|
+
SemanticCallTag.Eval, SemanticCallTag.Html, SemanticCallTag.JavaScript, SemanticCallTag.LoadsPackage, SemanticCallTag.AttachesPackage,
|
|
222
|
+
SemanticCallTag.ChecksPackage
|
|
215
223
|
]);
|
|
216
224
|
/** Checks whether a {@link PropSelector} is a bitfield of {@link CallProp}s */
|
|
217
225
|
function isCallProp(selector) {
|
|
@@ -304,16 +312,11 @@ exports.CallProps = {
|
|
|
304
312
|
},
|
|
305
313
|
/** Gets the string labels for stated properties {@link CallPropLabels}. */
|
|
306
314
|
labels(stated) {
|
|
307
|
-
|
|
308
|
-
return [];
|
|
309
|
-
}
|
|
310
|
-
const callProps = record_1.Record.keys(CallPropLabels).filter(prop => ((stated?.props ?? 0) & prop) !== 0).map(prop => CallPropLabels[prop]);
|
|
311
|
-
const semanticProps = stated.tags ?? [];
|
|
312
|
-
return [...callProps, ...semanticProps];
|
|
315
|
+
return [...exports.CallProps.words(stated?.props), ...stated?.tags ?? []];
|
|
313
316
|
},
|
|
314
317
|
/** The {@link CallPropLabels} words for a bare {@link CallProps} bitfield, as inferred functions carry one. */
|
|
315
318
|
words(props) {
|
|
316
|
-
return
|
|
319
|
+
return wordsOf(CallPropEntries, props);
|
|
317
320
|
},
|
|
318
321
|
/** The {@link PropMask} the given {@link CallProp}/{@link SemanticCallTag} member names stand for, unknown ones ignored. */
|
|
319
322
|
mask(names) {
|
|
@@ -348,6 +351,8 @@ exports.FnSig = {
|
|
|
348
351
|
posWith: argsWith,
|
|
349
352
|
/** Which of the first `count` arguments a call evaluates; see {@link forcedArgs}. */
|
|
350
353
|
forced: forcedArgs,
|
|
354
|
+
/** How surely a call evaluates each of the first `count` arguments; see {@link argForcing}. */
|
|
355
|
+
forcing: argForcing,
|
|
351
356
|
/** A signature saying only that the call evaluates every argument; see {@link ForcingEvery}. */
|
|
352
357
|
every: ForcingEvery,
|
|
353
358
|
/** A signature saying only that the call evaluates one argument; see {@link forcingOnly}. */
|
|
@@ -408,6 +413,7 @@ function bitEntries(byBit) {
|
|
|
408
413
|
return Object.entries(byBit).map(([bit, word]) => [Number(bit), word]);
|
|
409
414
|
}
|
|
410
415
|
const ArgPropEntries = bitEntries(ArgPropNames);
|
|
416
|
+
const CallPropEntries = bitEntries(CallPropLabels);
|
|
411
417
|
/**
|
|
412
418
|
* Utility functions for {@link ArgProps|argument property bitfields}.
|
|
413
419
|
*/
|
|
@@ -456,25 +462,32 @@ function forcingOnly(index, name) {
|
|
|
456
462
|
* A signature is the one place that says so, which is why nothing else may state it alongside.
|
|
457
463
|
*/
|
|
458
464
|
function forcedArgs(sig, count) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
const layout = sigLayout(sig);
|
|
463
|
-
if ((layout.any & ArgProp.Forced) === 0) {
|
|
465
|
+
const layout = sig === undefined ? undefined : sigLayout(sig);
|
|
466
|
+
if (layout === undefined || (layout.any & ArgProp.Forced) === 0) {
|
|
464
467
|
return undefined;
|
|
465
468
|
}
|
|
466
469
|
const cache = layout.forced ??= [];
|
|
467
470
|
return cache[count] ??= Array.from({ length: count }, (_, i) => (argProp(layout, i) & ArgProp.Forced) !== 0);
|
|
468
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* How surely a call evaluates each of the first `count` arguments: {@link ArgProp.Forced} always,
|
|
474
|
+
* {@link ArgProp.Nse} and {@link ArgProp.Presence} never, anything else maybe; `undefined` without a signature.
|
|
475
|
+
*/
|
|
476
|
+
function argForcing(sig, count) {
|
|
477
|
+
if (sig === undefined) {
|
|
478
|
+
return undefined;
|
|
479
|
+
}
|
|
480
|
+
const layout = sigLayout(sig);
|
|
481
|
+
const cache = layout.forcing ??= [];
|
|
482
|
+
return cache[count] ??= Array.from({ length: count }, (_, i) => {
|
|
483
|
+
const props = argProp(layout, i);
|
|
484
|
+
return (props & ArgProp.Forced) !== 0 ? logic_1.Ternary.Always
|
|
485
|
+
: (props & (ArgProp.Nse | ArgProp.Presence)) !== 0 ? logic_1.Ternary.Never : logic_1.Ternary.Maybe;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
469
488
|
/** The positions of the first `count` arguments that carry any of `prop`. */
|
|
470
489
|
function argsWith(layout, count, prop) {
|
|
471
|
-
|
|
472
|
-
for (let i = 0; i < count; i++) {
|
|
473
|
-
if ((exports.FnSig.propAt(layout, i) & prop) !== 0) {
|
|
474
|
-
found.push(i);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return found;
|
|
490
|
+
return Array.from({ length: count }, (_, i) => i).filter(i => (argProp(layout, i) & prop) !== 0);
|
|
478
491
|
}
|
|
479
492
|
/** the {@link DecodedFunction#props} names that have a {@link CallProp} counterpart, together {@link SigDbInferable} */
|
|
480
493
|
const SigDbProps = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../processor';
|
|
2
2
|
import type { DataflowInformation } from '../info';
|
|
3
3
|
import { ExitPointType } from '../info';
|
|
4
|
-
import { NseArguments } from '../internal/process/functions/call/known-call-handling';
|
|
4
|
+
import { type NseArguments } from '../internal/process/functions/call/known-call-handling';
|
|
5
5
|
import { processAccess } from '../internal/process/functions/call/built-in/built-in-access';
|
|
6
6
|
import { processIfThenElse } from '../internal/process/functions/call/built-in/built-in-if-then-else';
|
|
7
7
|
import { processAssignment, processAssignmentLike, processDefineArgument } from '../internal/process/functions/call/built-in/built-in-assignment';
|
|
@@ -28,6 +28,7 @@ import { processList } from '../internal/process/functions/call/built-in/built-i
|
|
|
28
28
|
import { processVector } from '../internal/process/functions/call/built-in/built-in-vector';
|
|
29
29
|
import { processRm } from '../internal/process/functions/call/built-in/built-in-rm';
|
|
30
30
|
import { processEvalCall } from '../internal/process/functions/call/built-in/built-in-eval';
|
|
31
|
+
import { type AmbientScope, type AmbientStateAccess } from '../internal/process/functions/call/built-in/built-in-ambient-state';
|
|
31
32
|
import type { Value } from '../eval/values/r-value';
|
|
32
33
|
import type { ResolveInfo } from '../eval/resolve/alias-tracking';
|
|
33
34
|
import { resolveAsSeq, resolveAsVector } from '../eval/resolve/resolve';
|
|
@@ -85,6 +86,10 @@ export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo {
|
|
|
85
86
|
*/
|
|
86
87
|
readonly keepArgumentOut?: boolean;
|
|
87
88
|
readonly hasUnknownSideEffects?: boolean | LinkTo<RegExp | string>;
|
|
89
|
+
/** how the call reads or writes global state like the graphics parameters or the options, see {@link AmbientStateAccess} */
|
|
90
|
+
readonly ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
91
|
+
/** the call changes that state for a scope only, see {@link AmbientScope} */
|
|
92
|
+
readonly scope?: AmbientScope;
|
|
88
93
|
/** record mapping the actual function name called to the arguments that should be treated as function calls */
|
|
89
94
|
readonly treatAsFnCall?: Record<string, readonly string[]>;
|
|
90
95
|
/** Mark the given arguments as {@link EdgeType.NonStandardEvaluation|non-standard-evaluated}, like `quote`. */
|
|
@@ -106,8 +111,8 @@ export interface BuiltInEvalHandlerArgs extends ResolveInfo {
|
|
|
106
111
|
node: RNodeWithParent;
|
|
107
112
|
}
|
|
108
113
|
export type BuiltInEvalHandler = (args: BuiltInEvalHandlerArgs) => Value;
|
|
109
|
-
declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, readAllArguments, cfg, alternativeArgsFrom, hasUnknownSideEffects, treatAsFnCall, markArgsAsNSE: nse, markArgsAsMasked: masked, keepArgumentOut, sig }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
|
|
110
|
-
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 }: Pick<DefaultBuiltInProcessorConfiguration, 'useAsProcessor' | 'markArgsAsNSE' | 'markArgsAsMasked' | 'sig'>): DataflowInformation;
|
|
114
|
+
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 }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
|
|
115
|
+
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, ambient }: Pick<DefaultBuiltInProcessorConfiguration, 'useAsProcessor' | 'markArgsAsNSE' | 'markArgsAsMasked' | 'sig' | 'ambient'>): DataflowInformation;
|
|
111
116
|
export declare const BuiltInProcessorMapper: {
|
|
112
117
|
readonly "builtin:acc": typeof processAccess;
|
|
113
118
|
readonly "builtin:app": typeof processApply;
|