@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
|
@@ -30,6 +30,7 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
30
30
|
const assert_1 = require("../../../../../../util/assert");
|
|
31
31
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
32
32
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
33
|
+
const string_constants_1 = require("../../../../../eval/values/string/string-constants");
|
|
33
34
|
const package_1 = require("../../../../../../project/plugins/package-version-plugins/package");
|
|
34
35
|
const attached_packages_1 = require("../../../../../../project/attached-packages");
|
|
35
36
|
const flowr_namespace_file_1 = require("../../../../../../project/plugins/file-plugins/files/flowr-namespace-file");
|
|
@@ -53,9 +54,23 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
53
54
|
/* parse the import selection before the library flow rewrites `args` below */
|
|
54
55
|
const parsedSpec = config.fromImports ? parseFromSpec(args) : { namespaceOnly: config.namespaceOnly };
|
|
55
56
|
// 'pos' last, so the positional fallback keeps its previous order; `import::from` has no `pos`, its extra arguments name exports
|
|
56
|
-
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), { 'package': 'pkg', 'character.only': 'char', 'pos': 'pos' });
|
|
57
|
+
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), { 'package': 'pkg', 'character.only': 'char', 'pos': 'pos', 'include.only': 'only', 'exclude': 'except' });
|
|
57
58
|
const charId = (0, arrays_1.uniqueArray)(argMaps.get('char') ?? []);
|
|
58
|
-
|
|
59
|
+
/* `library(pkg, include.only = "f")` and `exclude = "f"` attach only part of the exports, as `import::from` does */
|
|
60
|
+
const namesIn = (key) => {
|
|
61
|
+
const value = r_argument_1.RArgument.getValue(args, argMaps.get(key)?.[0] ?? '');
|
|
62
|
+
/* usually a vector of names, `c("f", "g")` */
|
|
63
|
+
const elements = value === undefined ? undefined : node_value_1.NodeValue.setOf(value.info.id, data)?.elements.flatMap(v => v.type === 'vector' && (0, r_value_1.isValue)(v.elements) ? v.elements : [v]);
|
|
64
|
+
return elements === undefined ? undefined : (0, string_constants_1.collectStrings)(elements);
|
|
65
|
+
};
|
|
66
|
+
const only = config.fromImports ? undefined : namesIn('only');
|
|
67
|
+
const except = config.fromImports ? undefined : namesIn('except');
|
|
68
|
+
const spec = {
|
|
69
|
+
...parsedSpec,
|
|
70
|
+
pos: config.fromImports ? undefined : (0, built_in_envir_utils_1.resolveAttachPosition)(argMaps.get('pos')?.[0], data),
|
|
71
|
+
...(only !== undefined ? { include: new Map(only.map(n => [n, n])) } : {}),
|
|
72
|
+
...(except !== undefined ? { exclude: new Set(except), all: true } : {})
|
|
73
|
+
};
|
|
59
74
|
/* only a symbol or string literal names a package */
|
|
60
75
|
const namesToLoad = (0, arrays_1.uniqueArray)(argMaps.get('pkg') ?? [])
|
|
61
76
|
.map(v => r_argument_1.RArgument.getValue(args, v))
|
|
@@ -94,44 +109,23 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
94
109
|
isCharacterOnly = seenMaybe || seenTrue === seenFalse ? 'maybe' : seenTrue;
|
|
95
110
|
}
|
|
96
111
|
}
|
|
97
|
-
const packetName =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (values?.type === 'set' && values.elements.length !== 0) {
|
|
102
|
-
for (const elem of values.elements) {
|
|
103
|
-
const name = r_value_1.RValue.stringOf(elem);
|
|
104
|
-
if (name !== undefined) {
|
|
105
|
-
packetName.push(name);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
112
|
+
const packetName = isCharacterOnly ? namesToLoad.flatMap(nameToLoad => {
|
|
113
|
+
const values = node_value_1.NodeValue.setOf(nameToLoad.info.id, data);
|
|
114
|
+
return values?.type === 'set' ? values.elements.map(elem => r_value_1.RValue.stringOf(elem)).filter(assert_1.isNotUndefined) : [];
|
|
115
|
+
}) : [];
|
|
111
116
|
if (!isCharacterOnly || isCharacterOnly === 'maybe') {
|
|
112
117
|
// treat as a function call but convert the argument(s) to a string; a quoted literal carries its name in `content.str`, not `lexeme`
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
info: nameToLoad.info,
|
|
122
|
-
lexeme: nameToLoad.lexeme,
|
|
123
|
-
location: nameToLoad.location,
|
|
124
|
-
content: { quotes: 'none', str: identifier_1.Identifier.getName(nameToLoad.content) }
|
|
125
|
-
});
|
|
126
|
-
}
|
|
118
|
+
packetName.push(...namesToLoad.map(n => r_string_1.RString.is(n) ? n.content.str : n.lexeme).filter(assert_1.isNotUndefined));
|
|
119
|
+
const newArgs = namesToLoad.map((n) => r_string_1.RString.is(n) ? n : {
|
|
120
|
+
type: type_1.RType.String,
|
|
121
|
+
info: n.info,
|
|
122
|
+
lexeme: n.lexeme,
|
|
123
|
+
location: n.location,
|
|
124
|
+
content: { quotes: 'none', str: identifier_1.Identifier.getName(n.content) }
|
|
125
|
+
});
|
|
127
126
|
args = (0, make_argument_1.wrapArgumentsUnnamed)([...newArgs, ...args.slice(1)], data.completeAst.idMap);
|
|
128
127
|
}
|
|
129
|
-
const info = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
130
|
-
name,
|
|
131
|
-
args, rootId, data,
|
|
132
|
-
hasUnknownSideEffect: false,
|
|
133
|
-
origin: built_in_proc_name_1.BuiltInProcName.Library
|
|
134
|
-
}).information;
|
|
128
|
+
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: false, origin: built_in_proc_name_1.BuiltInProcName.Library }).information;
|
|
135
129
|
for (const p of packetName) {
|
|
136
130
|
const dependency = data.ctx.deps.loadDependency(p);
|
|
137
131
|
if (dependency) {
|
|
@@ -160,7 +154,7 @@ function symbolOrStringName(node) {
|
|
|
160
154
|
if (r_symbol_1.RSymbol.is(node)) {
|
|
161
155
|
return identifier_1.Identifier.getName(node.content);
|
|
162
156
|
}
|
|
163
|
-
if (r_string_1.RString.is(node)) {
|
|
157
|
+
else if (r_string_1.RString.is(node)) {
|
|
164
158
|
return node.content.str;
|
|
165
159
|
}
|
|
166
160
|
return undefined;
|
|
@@ -170,50 +164,40 @@ function stringLiterals(node) {
|
|
|
170
164
|
if (r_string_1.RString.is(node)) {
|
|
171
165
|
return [node.content.str];
|
|
172
166
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return [];
|
|
167
|
+
return r_function_call_1.RFunctionCall.isNamed(node) && identifier_1.Identifier.getName(node.functionName.content) === 'c'
|
|
168
|
+
? node.arguments.flatMap(a => a !== r_function_call_1.EmptyArgument && r_string_1.RString.is(a.value) ? [a.value.content.str] : [])
|
|
169
|
+
: [];
|
|
177
170
|
}
|
|
178
171
|
/** Parse `import::from(pkg, a, keep = filter, .all = TRUE, .except = c(...))` into which exports to attach. */
|
|
179
172
|
function parseFromSpec(args) {
|
|
180
173
|
const include = new Map();
|
|
181
174
|
const exclude = new Set();
|
|
182
175
|
let all = false;
|
|
183
|
-
for (
|
|
184
|
-
const arg = args[i];
|
|
176
|
+
for (const arg of args.slice(1)) {
|
|
185
177
|
if (r_argument_1.RArgument.isEmpty(arg) || arg.value === undefined) {
|
|
186
178
|
continue;
|
|
187
179
|
}
|
|
188
180
|
const argName = arg.name?.lexeme;
|
|
189
181
|
if (argName === '.all') {
|
|
190
182
|
all ||= r_logical_1.RLogical.isTrue(arg.value);
|
|
191
|
-
continue;
|
|
192
183
|
}
|
|
193
|
-
if (argName === '.except') {
|
|
194
|
-
|
|
195
|
-
exclude.add(s);
|
|
196
|
-
}
|
|
184
|
+
else if (argName === '.except') {
|
|
185
|
+
stringLiterals(arg.value).forEach(s => exclude.add(s));
|
|
197
186
|
all = true;
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
if (argName?.startsWith('.')) {
|
|
201
|
-
continue; // other control args (.into, .library, ...) do not affect which exports resolve
|
|
202
187
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
188
|
+
else if (!argName?.startsWith('.')) {
|
|
189
|
+
/* other control args (.into, .library, ...) do not affect which exports resolve */
|
|
190
|
+
const exported = symbolOrStringName(arg.value);
|
|
191
|
+
if (exported !== undefined) {
|
|
192
|
+
include.set(argName ?? exported, exported);
|
|
193
|
+
}
|
|
206
194
|
}
|
|
207
195
|
}
|
|
208
|
-
return {
|
|
209
|
-
include: include.size > 0 ? include : undefined,
|
|
210
|
-
exclude: exclude.size > 0 ? exclude : undefined,
|
|
211
|
-
all: all || exclude.size > 0
|
|
212
|
-
};
|
|
196
|
+
return { include: include.size > 0 ? include : undefined, exclude: exclude.size > 0 ? exclude : undefined, all };
|
|
213
197
|
}
|
|
214
198
|
/** Parse a `box::use` bracket argument (`pkg[a, b]` or `pkg[...]`) into a package and its attach spec; `undefined` if not a bracket. */
|
|
215
199
|
function parseBoxSpec(first) {
|
|
216
|
-
if (
|
|
200
|
+
if (!r_access_1.RAccess.isIndex(first)) {
|
|
217
201
|
return undefined;
|
|
218
202
|
}
|
|
219
203
|
const pack = symbolOrStringName(first.accessed);
|
|
@@ -223,16 +207,18 @@ function parseBoxSpec(first) {
|
|
|
223
207
|
const include = new Map();
|
|
224
208
|
let all = false;
|
|
225
209
|
for (const el of first.access) {
|
|
226
|
-
if (r_argument_1.RArgument.isEmpty(el)
|
|
210
|
+
if (r_argument_1.RArgument.isEmpty(el)) {
|
|
227
211
|
continue;
|
|
228
212
|
}
|
|
229
|
-
if (r_symbol_1.RSymbol.is(el.value) && identifier_1.Identifier.getName(el.value.content) === '...') {
|
|
230
|
-
|
|
231
|
-
|
|
213
|
+
else if (r_symbol_1.RSymbol.is(el.value) && identifier_1.Identifier.getName(el.value.content) === '...') {
|
|
214
|
+
/* use(pkg[...]) attaches every export */
|
|
215
|
+
all = true;
|
|
232
216
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
217
|
+
else {
|
|
218
|
+
const exported = symbolOrStringName(el.value);
|
|
219
|
+
if (exported !== undefined) {
|
|
220
|
+
include.set(el.name?.lexeme ?? exported, exported);
|
|
221
|
+
}
|
|
236
222
|
}
|
|
237
223
|
}
|
|
238
224
|
return { pack, spec: { include: include.size > 0 ? include : undefined, all } };
|
|
@@ -243,8 +229,7 @@ function parseBoxSpec(first) {
|
|
|
243
229
|
*/
|
|
244
230
|
function processUse(name, args, rootId, data) {
|
|
245
231
|
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: false, origin: built_in_proc_name_1.BuiltInProcName.Library }).information;
|
|
246
|
-
const
|
|
247
|
-
const parsed = parseUseSpec(name, first, args, data);
|
|
232
|
+
const parsed = parseUseSpec(name, r_argument_1.RArgument.valueOf(args[0]), args, data);
|
|
248
233
|
const dependency = parsed && data.ctx.deps.getDependency(parsed.pack);
|
|
249
234
|
if (parsed && dependency) {
|
|
250
235
|
linkLibrary(dependency, info, rootId, data, parsed.spec);
|
|
@@ -282,24 +267,22 @@ function attachExportVertex(graph, builtInId, environment, ctx, cds) {
|
|
|
282
267
|
tag: vertex_1.VertexType.FunctionDefinition,
|
|
283
268
|
id: builtInId,
|
|
284
269
|
environment, cds, params: {},
|
|
285
|
-
subflow: { graph: new Set(), unknownReferences: [], in: [], out: [], environment, entryPoint: builtInId, hooks: [] },
|
|
270
|
+
subflow: { graph: new Set(), unknownReferences: [], in: [], out: [], environment: ctx.env.makeCleanEnv(), entryPoint: builtInId, hooks: [] },
|
|
286
271
|
exitPoints: [],
|
|
287
272
|
}, ctx.env.cleanEnv);
|
|
288
273
|
}
|
|
289
274
|
/** Reserved marker binding recording an unresolved `library()`/`require()` load; the leading space cannot collide with a real export name. */
|
|
290
275
|
const libraryLoadMarker = ' library-load';
|
|
276
|
+
/** The {@link libraryLoadMarker} binding of loading `pack` at `loadedAt`, so `pack::fn` links back via {@link loadNodesForNamespace}. */
|
|
277
|
+
function loadMarkerOf(pack, loadedAt, cds) {
|
|
278
|
+
return { name: identifier_1.Identifier.make(libraryLoadMarker, pack), type: identifier_1.ReferenceType.Function, nodeId: loadedAt, definedAt: loadedAt, cds: cds?.slice() };
|
|
279
|
+
}
|
|
291
280
|
/**
|
|
292
281
|
* Record a syntactically known but database-unresolved package load: a bare {@link EnvType.LoadedNamespace} layer
|
|
293
282
|
* carrying only the reserved {@link libraryLoadMarker}, so an explicit `pack::fn` still links back via {@link loadNodesForNamespace}.
|
|
294
283
|
*/
|
|
295
284
|
function recordUnresolvedLibraryLoad(envInfo, pack, rootId, pos, cds) {
|
|
296
|
-
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define(
|
|
297
|
-
name: identifier_1.Identifier.make(libraryLoadMarker, pack),
|
|
298
|
-
type: identifier_1.ReferenceType.Function,
|
|
299
|
-
nodeId: rootId,
|
|
300
|
-
definedAt: rootId,
|
|
301
|
-
cds: cds?.slice()
|
|
302
|
-
});
|
|
285
|
+
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define(loadMarkerOf(pack, rootId, cds));
|
|
303
286
|
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, pos) };
|
|
304
287
|
}
|
|
305
288
|
/**
|
|
@@ -356,10 +339,7 @@ function selectExports(callables, spec) {
|
|
|
356
339
|
* and a script mentions a few dozen, so the definitions are only made for the ones something asks about.
|
|
357
340
|
*/
|
|
358
341
|
function lazyExports(pack, exports, ctx, definedAt) {
|
|
359
|
-
const byName = new Map();
|
|
360
|
-
for (const exp of exports) {
|
|
361
|
-
byName.set(identifier_1.Identifier.getName(identifier_1.Identifier.make(exp.as, pack)), exp);
|
|
362
|
-
}
|
|
342
|
+
const byName = new Map(exports.map(exp => [identifier_1.Identifier.getName(identifier_1.Identifier.make(exp.as, pack)), exp]));
|
|
363
343
|
return new frame_memory_1.LazyBindings(new Set(byName.keys()), name => [exportDefinition(pack, byName.get(name), ctx, definedAt)]);
|
|
364
344
|
}
|
|
365
345
|
/**
|
|
@@ -373,7 +353,9 @@ function exportDefinition(pack, exp, ctx, definedAt = node_id_1.NodeId.toBuiltIn
|
|
|
373
353
|
nodeId: node_id_1.NodeId.fromPkgFn(pack, exp.exported),
|
|
374
354
|
definedAt,
|
|
375
355
|
};
|
|
376
|
-
|
|
356
|
+
/* an export named like a primitive is a method registered for it (lubridate's `$`), the primitive still evaluates the call */
|
|
357
|
+
const exported = identifier_1.Identifier.make(exp.exported);
|
|
358
|
+
const stated = ctx.env.statedFor(pack)?.get(exported)?.[0] ?? ctx.env.emptyBuiltInEnvironment.memory.get(exported)?.[0];
|
|
377
359
|
if (stated === undefined) {
|
|
378
360
|
return identity;
|
|
379
361
|
}
|
|
@@ -493,11 +475,10 @@ function attachBaseRNamespaces(env, ctx) {
|
|
|
493
475
|
let builtinNames;
|
|
494
476
|
for (const pkg of basePackages) {
|
|
495
477
|
const dependency = ctx.deps.getDependency(pkg);
|
|
496
|
-
if (dependency?.namespaceInfo
|
|
497
|
-
|
|
478
|
+
if (dependency?.namespaceInfo !== undefined) {
|
|
479
|
+
builtinNames ??= new Set([...ctx.env.builtInEnvironment.memory.keys()].map(String));
|
|
480
|
+
built = attachDependencyToEnvironment(dependency, built, ctx, { exclude: builtinNames }, node_id_1.NodeId.toBuiltIn(pkg));
|
|
498
481
|
}
|
|
499
|
-
builtinNames ??= new Set([...ctx.env.builtInEnvironment.memory.keys()].map(String));
|
|
500
|
-
built = attachDependencyToEnvironment(dependency, built, ctx, { exclude: builtinNames }, node_id_1.NodeId.toBuiltIn(pkg));
|
|
501
482
|
}
|
|
502
483
|
if (built.current.parent !== env.current.parent) {
|
|
503
484
|
baseNamespaceLayerCache.set(key, built.current.parent);
|
|
@@ -514,12 +495,11 @@ function attachDeclaredDependencies(env, ctx) {
|
|
|
514
495
|
}
|
|
515
496
|
let built = env;
|
|
516
497
|
for (const declared of ctx.deps.getDependencies()) {
|
|
517
|
-
|
|
498
|
+
/* getDependency triggers lazy export resolution the raw declared record may still be missing */
|
|
518
499
|
const dependency = ctx.deps.getDependency(declared.name);
|
|
519
|
-
if (dependency?.namespaceInfo
|
|
520
|
-
|
|
500
|
+
if (dependency?.namespaceInfo !== undefined) {
|
|
501
|
+
built = attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(dependency.name));
|
|
521
502
|
}
|
|
522
|
-
built = attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(dependency.name));
|
|
523
503
|
}
|
|
524
504
|
return built;
|
|
525
505
|
}
|
|
@@ -544,14 +524,12 @@ function attachProjectImports(env, ctx) {
|
|
|
544
524
|
else {
|
|
545
525
|
names = funcs;
|
|
546
526
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
});
|
|
554
|
-
}
|
|
527
|
+
toDefine.push(...names.map((fn) => ({
|
|
528
|
+
name: identifier_1.Identifier.make(fn, layerNamespace),
|
|
529
|
+
type: identifier_1.ReferenceType.Function,
|
|
530
|
+
nodeId: node_id_1.NodeId.fromPkgFn(pkg, fn),
|
|
531
|
+
definedAt: node_id_1.NodeId.toBuiltIn(pkg)
|
|
532
|
+
})));
|
|
555
533
|
}
|
|
556
534
|
if (toDefine.length === 0) {
|
|
557
535
|
return env;
|
|
@@ -571,16 +549,11 @@ function attachStatedDefinitions(pack, envInfo, ctx, spec, as, loadedAt, cds) {
|
|
|
571
549
|
return envInfo;
|
|
572
550
|
}
|
|
573
551
|
/* keyed as the configuration states them: a replacement is bound under `f<-`, which its `name` does not say */
|
|
574
|
-
const memory = new Map(stated
|
|
552
|
+
const memory = new Map(spec.include === undefined && spec.exclude === undefined ? stated
|
|
553
|
+
: [...stated].filter(([key]) => (spec.all || spec.include === undefined || spec.include.has(key)) && !spec.exclude?.has(key)));
|
|
575
554
|
if (loadedAt !== undefined) {
|
|
576
555
|
/* the marker an unresolved load leaves behind, so a call links back to the `library()` that made it resolve */
|
|
577
|
-
memory.set(libraryLoadMarker, [
|
|
578
|
-
name: identifier_1.Identifier.make(libraryLoadMarker, pack),
|
|
579
|
-
type: identifier_1.ReferenceType.Function,
|
|
580
|
-
nodeId: loadedAt,
|
|
581
|
-
definedAt: loadedAt,
|
|
582
|
-
cds: cds?.slice()
|
|
583
|
-
}]);
|
|
556
|
+
memory.set(libraryLoadMarker, [loadMarkerOf(pack, loadedAt, cds)]);
|
|
584
557
|
}
|
|
585
558
|
const layer = new environment_1.Environment(envInfo.current)
|
|
586
559
|
.asLibrary(pack, as ?? (spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace));
|
|
@@ -606,11 +579,9 @@ function attachAssumedPackages(env, ctx) {
|
|
|
606
579
|
for (let i = assumed.length - 1; i >= 0; i--) {
|
|
607
580
|
const pkg = assumed[i];
|
|
608
581
|
const dependency = ctx.deps.getDependency(pkg);
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
built = attachStatedDefinitions(pkg, built, ctx, { pos: AssumedAttachPosition }, environment_1.EnvType.AssumedNamespace);
|
|
582
|
+
built = dependency?.namespaceInfo !== undefined
|
|
583
|
+
? attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(pkg))
|
|
584
|
+
: attachStatedDefinitions(pkg, built, ctx, { pos: AssumedAttachPosition }, environment_1.EnvType.AssumedNamespace);
|
|
614
585
|
}
|
|
615
586
|
return built;
|
|
616
587
|
}
|
|
@@ -642,23 +613,17 @@ function attachProject(env, ctx) {
|
|
|
642
613
|
return defineProjectSysdata(attachAssumedPackages(attachDeclaredDependencies(attachProjectImports(attachBaseRNamespaces(env, ctx), ctx), ctx), ctx), ctx);
|
|
643
614
|
}
|
|
644
615
|
function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
|
|
645
|
-
for (const
|
|
646
|
-
const importedDependency = ctx.deps.getDependency(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
const importedNs = importedDependency.namespaceInfo;
|
|
651
|
-
const funcToImport = importedNs === undefined ? undefined
|
|
652
|
-
: imp[1] === 'all' ? (0, flowr_namespace_file_1.getCallables)(importedNs) : (0, flowr_namespace_file_1.getCallables)(importedNs).filter(v => imp[1].includes(v));
|
|
653
|
-
if ((0, assert_1.isUndefined)(funcToImport)) {
|
|
654
|
-
continue;
|
|
655
|
-
}
|
|
656
|
-
if (alreadyImportedAll.has(importedDependency.name)) {
|
|
616
|
+
for (const [pkg, imported] of namespaceInfo.importedPackages) {
|
|
617
|
+
const importedDependency = ctx.deps.getDependency(pkg);
|
|
618
|
+
const importedNs = importedDependency?.namespaceInfo;
|
|
619
|
+
if (importedDependency === undefined || importedNs === undefined || alreadyImportedAll.has(importedDependency.name)) {
|
|
657
620
|
continue;
|
|
658
621
|
}
|
|
659
622
|
/* collect first and define in one go, as defining one by one copies the (growing) memory every time */
|
|
660
623
|
const toDefine = [];
|
|
661
624
|
const queued = new Set();
|
|
625
|
+
const callables = (0, flowr_namespace_file_1.getCallables)(importedNs);
|
|
626
|
+
const funcToImport = imported === 'all' ? callables : callables.filter(v => imported.includes(v));
|
|
662
627
|
for (const func of funcToImport) {
|
|
663
628
|
const identifier = package_1.Package.functionIdentifier(importedDependency.name, func);
|
|
664
629
|
if (importsEnv.memory.has(identifier) || queued.has(identifier)) {
|
|
@@ -675,12 +640,9 @@ function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
|
|
|
675
640
|
if (toDefine.length > 0) {
|
|
676
641
|
importsEnv = importsEnv.defineAll(toDefine);
|
|
677
642
|
}
|
|
678
|
-
if (
|
|
643
|
+
if (imported === 'all') {
|
|
679
644
|
alreadyImportedAll.add(importedDependency.name);
|
|
680
|
-
|
|
681
|
-
//if only importFrom() we don't have to recursively import
|
|
682
|
-
if (imp[1] === 'all' && importedDependency?.namespaceInfo) {
|
|
683
|
-
importsEnv = recImports(importsEnv, importedDependency.namespaceInfo, ctx, alreadyImportedAll);
|
|
645
|
+
importsEnv = recImports(importsEnv, importedNs, ctx, alreadyImportedAll);
|
|
684
646
|
}
|
|
685
647
|
}
|
|
686
648
|
return importsEnv;
|
|
@@ -12,7 +12,5 @@ export interface LocalFunctionConfiguration {
|
|
|
12
12
|
env: string;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Processes a built-in 'local' function call.
|
|
17
|
-
*/
|
|
15
|
+
/** Processes a built-in 'local' function call. */
|
|
18
16
|
export declare function processLocal<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: LocalFunctionConfiguration): DataflowInformation;
|
|
@@ -4,6 +4,7 @@ exports.processLocal = processLocal;
|
|
|
4
4
|
const function_semantics_1 = require("../../../../../fn/function-semantics");
|
|
5
5
|
const processor_1 = require("../../../../../processor");
|
|
6
6
|
const info_1 = require("../../../../../info");
|
|
7
|
+
const vertex_1 = require("../../../../../graph/vertex");
|
|
7
8
|
const edge_1 = require("../../../../../graph/edge");
|
|
8
9
|
const known_call_handling_1 = require("../known-call-handling");
|
|
9
10
|
const control_flow_1 = require("../../../../control-flow");
|
|
@@ -15,19 +16,16 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
15
16
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
16
17
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
17
18
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
18
|
-
/**
|
|
19
|
-
* Processes a built-in 'local' function call.
|
|
20
|
-
*/
|
|
19
|
+
/** Processes a built-in 'local' function call. */
|
|
21
20
|
function processLocal(name, args, rootId, data, config) {
|
|
22
21
|
if (args.length === 0) {
|
|
23
22
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
24
23
|
}
|
|
25
|
-
const
|
|
24
|
+
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
|
|
26
25
|
[config.args.expr]: 'expr',
|
|
27
26
|
[config.args.env]: 'env',
|
|
28
27
|
'...': '...'
|
|
29
|
-
};
|
|
30
|
-
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
|
|
28
|
+
});
|
|
31
29
|
const envArg = r_argument_1.RArgument.getWithId(args, argMaps.get('env')?.[0]);
|
|
32
30
|
const env = (0, unpack_argument_1.unpackArg)(envArg);
|
|
33
31
|
const expr = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('expr')?.[0]));
|
|
@@ -38,7 +36,7 @@ function processLocal(name, args, rootId, data, config) {
|
|
|
38
36
|
const envirRouting = envArg ? (0, built_in_envir_utils_1.resolveArgToEnvirOrAmbiguous)(envArg, data) : undefined;
|
|
39
37
|
const envirResolution = (0, built_in_envir_utils_1.envirOf)(envirRouting);
|
|
40
38
|
const dfEnv = env ? (0, processor_1.processDataflowFor)(env, data) : info_1.DataflowInformation.initialize(rootId, data);
|
|
41
|
-
if (control_flow_1.ControlFlow.alwaysExits(dfEnv)) {
|
|
39
|
+
if (control_flow_1.ControlFlow.alwaysExits(dfEnv, data.cds)) {
|
|
42
40
|
(0, common_1.patchFunctionCall)({
|
|
43
41
|
nextGraph: dfEnv.graph,
|
|
44
42
|
rootId,
|
|
@@ -64,17 +62,23 @@ function processLocal(name, args, rootId, data, config) {
|
|
|
64
62
|
const resultEnvironment = envirResolution ? data.environment : (0, scoping_1.popLocalEnvironment)(dfExpr.environment);
|
|
65
63
|
/* definitions of the local scope vanish with it, only what escaped it (e.g. via `<<-`) may bubble up */
|
|
66
64
|
const escaping = envirResolution ? dfExpr.out : dfExpr.out.filter(o => o.name !== undefined && resolve_helper_1.Resolve.byNameAndType(o.name, resultEnvironment, o.type)?.some(d => d.nodeId === o.nodeId));
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const graph = dfEnv.graph.mergeWith(dfExpr.graph);
|
|
66
|
+
graph.addEdge(rootId, expr.info.id, edge_1.EdgeType.Returns);
|
|
67
|
+
/* the body only runs because `local` runs it */
|
|
68
|
+
for (const [id, vertex] of dfExpr.graph.vertices(false)) {
|
|
69
|
+
if (!vertex_1.DfgVertex.isUse(vertex) && !vertex_1.DfgVertex.isValue(vertex)) {
|
|
70
|
+
graph.addEdge(id, rootId, edge_1.EdgeType.Reads);
|
|
71
|
+
}
|
|
69
72
|
}
|
|
73
|
+
const cfgEntry = control_flow_1.ControlFlow.inSequence(graph, env ? [dfEnv, dfExpr] : [dfExpr], rootId);
|
|
74
|
+
/* `return` only leaves the evaluation that local opens */
|
|
75
|
+
control_flow_1.ControlFlow.jumpsTo(graph, dfExpr, 1 /* ExitPointType.Return */, rootId);
|
|
70
76
|
const ingoing = dfEnv.in.concat(dfExpr.in, dfEnv.unknownReferences, dfExpr.unknownReferences);
|
|
71
77
|
ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
|
|
72
|
-
const graph = dfEnv.graph.mergeWith(dfExpr.graph);
|
|
73
|
-
const cfgEntry = control_flow_1.ControlFlow.inSequence(graph, env ? [dfEnv, dfExpr] : [dfExpr], rootId);
|
|
74
78
|
const baseResult = {
|
|
75
79
|
hooks: dfExpr.hooks.concat(dfEnv.hooks),
|
|
76
80
|
environment: resultEnvironment,
|
|
77
|
-
exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints),
|
|
81
|
+
exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints.filter(e => e.type !== 1 /* ExitPointType.Return */)),
|
|
78
82
|
graph,
|
|
79
83
|
entryPoint: rootId,
|
|
80
84
|
cfgEntry,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
-
import {
|
|
2
|
+
import type { FnSig } from '../../../../../environments/built-in-props';
|
|
3
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
3
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
5
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
6
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
@@ -10,9 +11,8 @@ interface QuoteConfig {
|
|
|
10
11
|
envArgIndex?: number;
|
|
11
12
|
/** which unquote escape the function supports, {@link Unquote.None} if unset */
|
|
12
13
|
unquote?: Unquote;
|
|
14
|
+
readonly sig?: FnSig;
|
|
13
15
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Process a call to `quote` or similar nse/substitution functions.
|
|
16
|
-
*/
|
|
16
|
+
/** Process a call to `quote` or similar nse/substitution functions. */
|
|
17
17
|
export declare function processQuote<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: QuoteConfig): DataflowInformation;
|
|
18
18
|
export {};
|
|
@@ -14,14 +14,12 @@ const nse_1 = require("../nse");
|
|
|
14
14
|
const linker_1 = require("../../../../linker");
|
|
15
15
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
16
|
const scoping_1 = require("../../../../../environments/scoping");
|
|
17
|
-
/**
|
|
18
|
-
* Process a call to `quote` or similar nse/substitution functions.
|
|
19
|
-
*/
|
|
17
|
+
/** Process a call to `quote` or similar nse/substitution functions. */
|
|
20
18
|
function processQuote(name, args, rootId, data, config) {
|
|
21
19
|
const startEnv = data.environment;
|
|
22
20
|
let lastEnv = startEnv;
|
|
23
21
|
const { information, processedArguments, fnRef } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
24
|
-
name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Quote,
|
|
22
|
+
name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Quote, sig: config.sig,
|
|
25
23
|
patchData(data, index) {
|
|
26
24
|
if (index === config.quoteArgumentsWithIndex) {
|
|
27
25
|
lastEnv = data.environment;
|
|
@@ -32,30 +30,12 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
});
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const unknownRefs = [];
|
|
33
|
+
const others = processedArguments.filter((p, i) => p !== undefined && i !== config.quoteArgumentsWithIndex);
|
|
34
|
+
const inRefs = [fnRef, ...others.flatMap(p => p.in)];
|
|
38
35
|
const quotedArg = args[config.quoteArgumentsWithIndex];
|
|
39
36
|
const evaluated = function_semantics_1.FunctionSemantics.call.nse.unquoted(r_argument_1.RArgument.isEmpty(quotedArg) ? undefined : quotedArg?.value, config.unquote ?? nse_1.Unquote.None);
|
|
40
|
-
for (let i = 0; i < args.length; i++) {
|
|
41
|
-
const processedArg = processedArguments[i];
|
|
42
|
-
if (processedArg && i !== config.quoteArgumentsWithIndex) {
|
|
43
|
-
inRefs.push(...processedArg.in);
|
|
44
|
-
outRefs.push(...processedArg.out);
|
|
45
|
-
unknownRefs.push(...processedArg.unknownReferences);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
37
|
const quotedProcessed = processedArguments[config.quoteArgumentsWithIndex];
|
|
49
38
|
if (quotedProcessed) {
|
|
50
|
-
/*
|
|
51
|
-
* The expression is held on to rather than evaluated, so a `return` within it never runs and control
|
|
52
|
-
* arrives at the call. Every other jump the call catches already.
|
|
53
|
-
*/
|
|
54
|
-
for (const exit of quotedProcessed.exitPoints) {
|
|
55
|
-
if (exit.type === 1 /* ExitPointType.Return */) {
|
|
56
|
-
information.graph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
39
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, [config.quoteArgumentsWithIndex], { evaluated });
|
|
60
40
|
if (evaluated) {
|
|
61
41
|
/* the argument was processed in a clean env, so the escaped reads need linking by hand */
|
|
@@ -63,19 +43,16 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
63
43
|
(0, linker_1.linkInputs)(escaped, lastEnv, inRefs, information.graph, false);
|
|
64
44
|
}
|
|
65
45
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (envProcessed && exprProcessed) {
|
|
70
|
-
applyEnvListReplacement(information, envProcessed, exprProcessed);
|
|
71
|
-
}
|
|
46
|
+
const envProcessed = config.envArgIndex === undefined ? undefined : processedArguments[config.envArgIndex];
|
|
47
|
+
if (envProcessed && quotedProcessed) {
|
|
48
|
+
applyEnvListReplacement(information, envProcessed, quotedProcessed);
|
|
72
49
|
}
|
|
73
50
|
return {
|
|
74
51
|
...information,
|
|
75
52
|
environment: startEnv,
|
|
76
53
|
in: inRefs,
|
|
77
|
-
out:
|
|
78
|
-
unknownReferences:
|
|
54
|
+
out: others.flatMap(p => p.out),
|
|
55
|
+
unknownReferences: others.flatMap(p => p.unknownReferences)
|
|
79
56
|
};
|
|
80
57
|
}
|
|
81
58
|
/** The uses within `expr`, by name, to match a `substitute` env list against. */
|
|
@@ -110,9 +87,6 @@ function applyEnvListReplacement(information, env, expr) {
|
|
|
110
87
|
return true;
|
|
111
88
|
}
|
|
112
89
|
useMap ??= usesByName(expr);
|
|
113
|
-
if (useMap.size === 0) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
90
|
for (const field of vtx.args.filter(graph_1.FunctionArgument.isNamed)) {
|
|
117
91
|
for (const useId of useMap.get(field.name) ?? []) {
|
|
118
92
|
information.graph.addEdge(useId, field.nodeId, edge_1.EdgeType.Reads);
|
|
@@ -13,6 +13,7 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
|
|
|
13
13
|
const control_flow_1 = require("../../../../control-flow");
|
|
14
14
|
const apply_kill_1 = require("../../../../../environments/apply-kill");
|
|
15
15
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
|
+
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
16
17
|
/**
|
|
17
18
|
* Process a built-in repeat loop function call like `repeat { ... }`.
|
|
18
19
|
* @param name - The name of the function being called.
|
|
@@ -46,6 +47,7 @@ function processRepeatLoop(name, args, rootId, data) {
|
|
|
46
47
|
const body = processedArguments[0];
|
|
47
48
|
(0, assert_1.guard)(body !== undefined, () => `Repeat-Loop ${identifier_1.Identifier.toString(name.content)} has no body, impossible!`);
|
|
48
49
|
(0, linker_1.linkCircularRedefinitionsWithinALoop)(information.graph, (0, linker_1.produceNameSharedIdMap)((0, linker_1.findNonLocalReads)(information.graph)), body.out, body.environment);
|
|
50
|
+
(0, built_in_ambient_state_1.linkAmbientStateWithinLoop)(information.graph, body.in.concat(body.unknownReferences), body);
|
|
49
51
|
(0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences), information.graph);
|
|
50
52
|
information.exitPoints = (0, info_1.filterOutLoopExitPoints)(information.exitPoints);
|
|
51
53
|
const graph = information.graph;
|
|
@@ -19,9 +19,10 @@ const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
|
19
19
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
20
20
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
21
21
|
const scoping_1 = require("../../../../../environments/scoping");
|
|
22
|
+
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
22
23
|
/** whether `value` is a call to the *built-in* `ls`/`objects` that lists (and thus clears) the whole scope */
|
|
23
24
|
function isBuiltInLsCall(value, data) {
|
|
24
|
-
if (!r_function_call_2.RFunctionCall.
|
|
25
|
+
if (!r_function_call_2.RFunctionCall.isNamed(value)) {
|
|
25
26
|
return false;
|
|
26
27
|
}
|
|
27
28
|
const [fn, ns] = identifier_1.Identifier.toArray(value.functionName.content);
|
|
@@ -29,7 +30,7 @@ function isBuiltInLsCall(value, data) {
|
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
31
32
|
// a `pattern`/`envir` argument restricts the listing, so only a plain listing clears everything
|
|
32
|
-
const listsEverything = value.arguments.every(a =>
|
|
33
|
+
const listsEverything = value.arguments.every(a => r_argument_1.RArgument.isNamed(a) && ['all.names', 'sorted'].includes(identifier_1.Identifier.getName(a.name.content)));
|
|
33
34
|
if (!listsEverything) {
|
|
34
35
|
return false;
|
|
35
36
|
}
|
|
@@ -208,6 +209,10 @@ function processRm(name, args, rootId, data) {
|
|
|
208
209
|
}
|
|
209
210
|
// apply to our own environment so threading reflects it, and emit the kills so a merging parent can re-apply
|
|
210
211
|
const kills = buildKills(targets, data.cds, rootId);
|
|
211
|
-
|
|
212
|
+
if (kills.length === 0) {
|
|
213
|
+
return res;
|
|
214
|
+
}
|
|
215
|
+
const names = targets.all || targets.unknown ? undefined : targets.names.map(n => n.name);
|
|
216
|
+
return { ...res, environment: (0, built_in_ambient_state_1.ambientWritesOfRelease)((0, apply_kill_1.applyKills)(res.environment, kills), names, rootId, data.cds), kill: kills };
|
|
212
217
|
}
|
|
213
218
|
//# sourceMappingURL=built-in-rm.js.map
|