@eagleoutice/flowr 2.13.14 → 2.13.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -23
- package/abstract-interpretation/data-frame/resolve-args.js +11 -12
- package/benchmark/summarizer/second-phase/graph.d.ts +23 -0
- package/benchmark/summarizer/second-phase/graph.js +47 -14
- package/cli/repl/commands/repl-cfg.js +2 -42
- package/cli/repl/commands/repl-clipboard.d.ts +7 -0
- package/cli/repl/commands/repl-clipboard.js +53 -0
- package/cli/repl/commands/repl-dataflow.js +5 -70
- package/cli/repl/commands/repl-normalize.js +3 -51
- package/control-flow/cfg-dead-code.js +5 -29
- package/control-flow/diff-cfg.js +2 -56
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +14 -0
- package/control-flow/useless-loop.js +4 -26
- package/core/steps/all/core/10-normalize.d.ts +8 -0
- package/core/steps/all/core/10-normalize.js +10 -8
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +5 -7
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -9
- package/data/r-base-packages.generated.d.ts +1 -0
- package/data/r-base-packages.generated.js +5 -3
- package/dataflow/environments/built-in-config.d.ts +9 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +4 -0
- package/dataflow/environments/built-in-props.js +3 -3
- package/dataflow/environments/built-in.d.ts +4 -2
- package/dataflow/environments/built-in.js +53 -3
- package/dataflow/environments/data-masking-functions.d.ts +3 -4
- package/dataflow/environments/data-masking-functions.js +7 -8
- package/dataflow/environments/default-builtin-config.d.ts +92 -12
- package/dataflow/environments/default-builtin-config.js +86 -43
- package/dataflow/environments/environment.d.ts +5 -0
- package/dataflow/environments/environment.js +17 -12
- package/dataflow/environments/identifier.d.ts +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +4 -7
- package/dataflow/eval/resolve/node-value.d.ts +51 -0
- package/dataflow/eval/resolve/node-value.js +71 -0
- package/dataflow/eval/resolve/resolve-argument.js +10 -7
- package/dataflow/eval/resolve/resolve-operators.js +1 -2
- package/dataflow/eval/values/general.d.ts +4 -0
- package/dataflow/eval/values/general.js +11 -0
- package/dataflow/eval/values/r-value.d.ts +15 -0
- package/dataflow/eval/values/r-value.js +27 -1
- package/dataflow/extractor.js +2 -0
- package/dataflow/fn/higher-order-function.js +2 -3
- package/dataflow/graph/diff-dataflow-graph.js +3 -55
- package/dataflow/graph/graph.d.ts +5 -0
- package/dataflow/graph/graph.js +27 -0
- package/dataflow/internal/linker.d.ts +23 -0
- package/dataflow/internal/linker.js +70 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +39 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +10 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +29 -53
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +19 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +69 -52
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +23 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +7 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +20 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +105 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
- package/dataflow/internal/process/functions/call/deferred.d.ts +41 -0
- package/dataflow/internal/process/functions/call/deferred.js +127 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -12
- package/dataflow/internal/process/functions/call/known-call-handling.js +35 -35
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/nse.d.ts +28 -0
- package/dataflow/internal/process/functions/call/nse.js +87 -0
- package/dataflow/internal/process/functions/call/quoted.d.ts +29 -0
- package/dataflow/internal/process/functions/call/quoted.js +188 -0
- package/documentation/doc-util/doc-types.js +15 -9
- package/linter/rules/deprecated-functions.js +9 -3
- package/linter/rules/seeded-randomness.js +2 -3
- package/linter/rules/undefined-symbol.js +10 -1
- package/package.json +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +6 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +17 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +3 -15
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +16 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +26 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +3 -15
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +4 -10
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +1 -1
- package/project/sigdb/reader.d.ts +9 -0
- package/project/sigdb/reader.js +30 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -12
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -37
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -23
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/query-function-filter.d.ts +21 -0
- package/queries/query-function-filter.js +48 -0
- package/r-bridge/data/data.d.ts +13 -3
- package/r-bridge/data/data.js +15 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +4 -0
- package/search/flowr-search-filters.d.ts +5 -1
- package/search/flowr-search-filters.js +31 -21
- package/search/search-executor/search-enrichers.d.ts +24 -4
- package/search/search-executor/search-enrichers.js +22 -9
- package/search/search-executor/search-transformer.js +1 -1
- package/util/diff-graph.d.ts +13 -0
- package/util/diff-graph.js +64 -1
- package/util/files.js +9 -8
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -1
- package/util/version.js +1 -1
|
@@ -12,9 +12,11 @@ const identifier_1 = require("./identifier");
|
|
|
12
12
|
const built_in_proc_name_1 = require("./built-in-proc-name");
|
|
13
13
|
const built_in_eval_name_1 = require("./built-in-eval-name");
|
|
14
14
|
const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
|
|
15
|
+
const nse_1 = require("../internal/process/functions/call/nse");
|
|
15
16
|
const data_masking_functions_1 = require("./data-masking-functions");
|
|
16
17
|
const built_in_props_1 = require("./built-in-props");
|
|
17
18
|
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
19
|
+
const r_base_packages_generated_1 = require("../../data/r-base-packages.generated");
|
|
18
20
|
/** Which stack environment an env-returning/-transforming builtin denotes (see {@link StackEnvBuiltins}). */
|
|
19
21
|
var StackEnvKind;
|
|
20
22
|
(function (StackEnvKind) {
|
|
@@ -36,6 +38,8 @@ exports.StackEnvBuiltins = {
|
|
|
36
38
|
'parent.env': StackEnvKind.Parent,
|
|
37
39
|
'parent.frame': StackEnvKind.CallerFrame,
|
|
38
40
|
'as.environment': StackEnvKind.Named,
|
|
41
|
+
/* `.env$x` reaches past the data mask */
|
|
42
|
+
'.env': StackEnvKind.Current,
|
|
39
43
|
'.GlobalEnv': StackEnvKind.Global,
|
|
40
44
|
'.BaseEnv': StackEnvKind.Base,
|
|
41
45
|
'.BaseNamespaceEnv': StackEnvKind.Base
|
|
@@ -200,35 +204,49 @@ exports.RGroupGenerics = {
|
|
|
200
204
|
* The `<-` forms are left out, one replacement definition covers many names.
|
|
201
205
|
* `npm run check:generic-labels` (part of `checkup`) compares this against a synced database.
|
|
202
206
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
'
|
|
209
|
-
'
|
|
210
|
-
'
|
|
211
|
-
'
|
|
212
|
-
'
|
|
213
|
-
]
|
|
207
|
+
/**
|
|
208
|
+
* The internal generics: they dispatch in C rather than through `UseMethod`, so no signature can state it and
|
|
209
|
+
* the list has to be written down. Everything that dispatches from R is generated, see {@link RBasePackageStore}.
|
|
210
|
+
*/
|
|
211
|
+
const InternalGenerics = [
|
|
212
|
+
'$', '[', '[[', '+', '-', '*', '/', '^', '%%', '%/%', '==', '!=', '<', '>', '<=', '>=', '&', '|', '!',
|
|
213
|
+
'c', 'length', 'dim', 'dimnames', 'names', 'max', 'min', 'range', 'sum', 'prod', 'abs', 'sqrt', 'exp',
|
|
214
|
+
'log', 'floor', 'ceiling', 'round', 'signif', 'trunc', 'cumsum', 'cumprod', 'cummax', 'cummin',
|
|
215
|
+
'as.character', 'as.integer', 'as.double', 'as.logical', 'as.complex', 'as.numeric', 'as.raw',
|
|
216
|
+
'is.na', 'is.nan', 'is.finite', 'is.infinite', 'is.matrix', 'is.numeric', 'cbind', 'rbind'
|
|
217
|
+
];
|
|
218
|
+
/** Every name R dispatches on: the generated closure generics plus the {@link InternalGenerics}. */
|
|
219
|
+
const RGenerics = new Set([...r_base_packages_generated_1.RBasePackageStore.generics, ...InternalGenerics]);
|
|
214
220
|
/** Label every {@link RGenerics} {@link CallProp.Generic}, splitting an entry that mixes them with names that do not dispatch (`&` does, `&&` does not). */
|
|
215
221
|
function markGenerics(definitions) {
|
|
216
|
-
|
|
222
|
+
const out = [];
|
|
223
|
+
for (const def of definitions) {
|
|
217
224
|
if (def.type !== 'function') {
|
|
218
|
-
|
|
225
|
+
out.push(def);
|
|
226
|
+
continue;
|
|
219
227
|
}
|
|
220
228
|
/* the attached base packages are the ones whose namespace layer a registered built-in hides, so their
|
|
221
229
|
* label is the only thing left stating the dispatch */
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
let generics = undefined;
|
|
231
|
+
let rest = undefined;
|
|
232
|
+
for (const name of def.names) {
|
|
233
|
+
if (RGenerics.has(identifier_1.Identifier.getName(name)) && r_base_packages_1.AttachedBasePackageSet.has(identifier_1.Identifier.getNamespace(name) ?? "base" /* PkgName.Base */)) {
|
|
234
|
+
(generics ??= []).push(name);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
(rest ??= []).push(name);
|
|
238
|
+
}
|
|
227
239
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
if (generics === undefined) {
|
|
241
|
+
out.push(def);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
out.push({ ...def, names: generics, config: { ...def.config, props: (def.config?.props ?? 0) | built_in_props_1.CallProp.Generic } });
|
|
245
|
+
if (rest !== undefined) {
|
|
246
|
+
out.push({ ...def, names: rest });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return out;
|
|
232
250
|
}
|
|
233
251
|
/**
|
|
234
252
|
* Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
|
|
@@ -287,7 +305,8 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
287
305
|
/* data-masking without a data argument, e.g. `aes(x, y)` */
|
|
288
306
|
{
|
|
289
307
|
type: 'function',
|
|
290
|
-
names: identifier_1.Identifier.fromAll("ggplot2" /* PkgName.GgPlot2 */, ['aes', '
|
|
308
|
+
names: [...identifier_1.Identifier.fromAll("ggplot2" /* PkgName.GgPlot2 */, ['aes', 'vars']), identifier_1.Identifier.from(['join_by', "dplyr" /* PkgName.Dplyr */]),
|
|
309
|
+
...identifier_1.Identifier.fromAll("tibble" /* PkgName.Tibble */, ['tibble', 'tribble'])],
|
|
291
310
|
processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
|
|
292
311
|
config: { markArgsAsMasked: known_call_handling_1.NseArguments.All },
|
|
293
312
|
assumePrimitive: false
|
|
@@ -536,8 +555,9 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
536
555
|
hasUnknownSideEffects: {
|
|
537
556
|
type: 'link-to-last-call',
|
|
538
557
|
ignoreIf: (source, graph) => {
|
|
558
|
+
const sourceVertex = graph.getVertex(source);
|
|
539
559
|
/* map with add = true appends to an existing plot */
|
|
540
|
-
return (exports.PlotFunctionsWithAddParam.has(identifier_1.Identifier.getName(
|
|
560
|
+
return (exports.PlotFunctionsWithAddParam.has(identifier_1.Identifier.getName(sourceVertex.name)) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, sourceVertex, {
|
|
541
561
|
index: -1,
|
|
542
562
|
name: 'add'
|
|
543
563
|
}, [type_1.RType.Logical])?.content === true);
|
|
@@ -564,7 +584,8 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
564
584
|
name: 'add'
|
|
565
585
|
}, [type_1.RType.Logical])?.content !== true);
|
|
566
586
|
},
|
|
567
|
-
cascadeIf: (
|
|
587
|
+
cascadeIf: (targetVertex, _, graph) => {
|
|
588
|
+
const target = targetVertex;
|
|
568
589
|
/* map with add = true appends to an existing plot */
|
|
569
590
|
return identifier_1.Identifier.getName(target.name) ? ((0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, target, {
|
|
570
591
|
index: 11,
|
|
@@ -641,8 +662,8 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
641
662
|
config: {
|
|
642
663
|
hasUnknownSideEffects: true,
|
|
643
664
|
forceArgs: [true],
|
|
644
|
-
/*
|
|
645
|
-
|
|
665
|
+
/* the routine usually comes from useDynLib, but it may be a variable holding a symbol */
|
|
666
|
+
markArgsAsMasked: known_call_handling_1.NseArguments.First,
|
|
646
667
|
treatAsFnCall: {
|
|
647
668
|
'.Call': ['.NAME'],
|
|
648
669
|
'.External': ['.NAME'],
|
|
@@ -654,9 +675,9 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
654
675
|
assumePrimitive: true
|
|
655
676
|
},
|
|
656
677
|
{ type: 'function', names: [identifier_1.Identifier.from(['eval', "base" /* PkgName.Base */])],
|
|
657
|
-
processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: false }, assumePrimitive: true },
|
|
678
|
+
processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: false, keepEnvironment: true }, assumePrimitive: true },
|
|
658
679
|
{ type: 'function', names: [identifier_1.Identifier.from(['evalText', "SoDA" /* PkgName.Soda */])],
|
|
659
|
-
processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: true }, assumePrimitive: true },
|
|
680
|
+
processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: true, keepEnvironment: true }, assumePrimitive: true },
|
|
660
681
|
{ type: 'function', names: [identifier_1.Identifier.from(['cat', "base" /* PkgName.Base */])],
|
|
661
682
|
processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes | built_in_props_1.CallProp.Prints, sig: [['...', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
|
|
662
683
|
{ type: 'function', names: [identifier_1.Identifier.from(['switch', "base" /* PkgName.Base */])],
|
|
@@ -672,7 +693,7 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
672
693
|
...identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['stop_bad_type', 'stop_bad_element_type', 'stop_bad_element_length'])
|
|
673
694
|
],
|
|
674
695
|
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
675
|
-
config: { useAsProcessor: built_in_proc_name_1.BuiltInProcName.Stop, cfg: 4 /* ExitPointType.Error */, forceArgs:
|
|
696
|
+
config: { useAsProcessor: built_in_proc_name_1.BuiltInProcName.Stop, cfg: 4 /* ExitPointType.Error */, forceArgs: 'all', props: built_in_props_1.CallProp.Throws },
|
|
676
697
|
assumePrimitive: false
|
|
677
698
|
},
|
|
678
699
|
{ type: 'function', names: [identifier_1.Identifier.from(['try', "base" /* PkgName.Base */])],
|
|
@@ -739,15 +760,18 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
739
760
|
processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { superAssignment: true, swapSourceAndTarget: true, canBeReplacement: true, props: built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.Invisible }, assumePrimitive: true },
|
|
740
761
|
{ type: 'function', names: [identifier_1.Identifier.from(['data', "utils" /* PkgName.Utils */]), identifier_1.Identifier.from(['getHdata', "Hmisc" /* PkgName.Hmisc */])],
|
|
741
762
|
processor: built_in_proc_name_1.BuiltInProcName.DefineArgument, config: { superAssignment: true }, assumePrimitive: false },
|
|
742
|
-
|
|
763
|
+
/* only `&&`/`||` short-circuit */
|
|
764
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['&&', "base" /* PkgName.Base */])],
|
|
743
765
|
processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: true, evalRhsWhen: true, props: built_in_props_1.CallProp.Pure }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
|
|
744
|
-
{ type: 'function', names: identifier_1.Identifier.
|
|
766
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['||', "base" /* PkgName.Base */])],
|
|
745
767
|
processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: true, evalRhsWhen: false, props: built_in_props_1.CallProp.Pure }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
|
|
768
|
+
{ type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['&', '|']),
|
|
769
|
+
processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: false, props: built_in_props_1.CallProp.Pure }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
|
|
746
770
|
{ type: 'function', names: ['|>'],
|
|
747
|
-
processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '_' }, assumePrimitive: true },
|
|
748
|
-
{ type: 'function', names: [identifier_1.Identifier.from(['%>%', "magrittr" /* PkgName.Magrittr */]), '%!>%'], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', rhsMightBeSymbol: true }, assumePrimitive: true },
|
|
749
|
-
{ type: 'function', names: [identifier_1.Identifier.from(['%<>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: true, rhsMightBeSymbol: true }, assumePrimitive: true },
|
|
750
|
-
{ type: 'function', names: [identifier_1.Identifier.from(['%T>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', returnLhs: true, rhsMightBeSymbol: true }, assumePrimitive: true },
|
|
771
|
+
processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '_', assignLhs: false, returnLhs: false }, assumePrimitive: true },
|
|
772
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['%>%', "magrittr" /* PkgName.Magrittr */]), '%!>%'], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: false, returnLhs: false, rhsMightBeSymbol: true }, assumePrimitive: true },
|
|
773
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['%<>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: true, returnLhs: false, rhsMightBeSymbol: true }, assumePrimitive: true },
|
|
774
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['%T>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: false, returnLhs: true, rhsMightBeSymbol: true }, assumePrimitive: true },
|
|
751
775
|
{ type: 'function', names: identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['map', 'map_lgl', 'map_int', 'map_dbl', 'map_chr']), processor: built_in_proc_name_1.BuiltInProcName.PurrrFormula, config: {
|
|
752
776
|
args: {
|
|
753
777
|
'.x': { index: 0, name: '.x' }
|
|
@@ -888,12 +912,29 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
888
912
|
} },
|
|
889
913
|
{ type: 'function', names: ['function', '\\'],
|
|
890
914
|
processor: built_in_proc_name_1.BuiltInProcName.FunctionDefinition, config: {}, assumePrimitive: true },
|
|
891
|
-
{ type: 'function', names: identifier_1.Identifier.
|
|
892
|
-
processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
|
|
915
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['quote', "base" /* PkgName.Base */])],
|
|
916
|
+
processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, keepEnvironment: true, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
|
|
917
|
+
/* `bquote` evaluates the operand of `.()` */
|
|
918
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['bquote', "base" /* PkgName.Base */])],
|
|
919
|
+
processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, unquote: nse_1.Unquote.Bquote, keepEnvironment: true, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
|
|
893
920
|
{ type: 'function', names: [identifier_1.Identifier.from(['substitute', "base" /* PkgName.Base */])],
|
|
894
|
-
processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, envArgIndex: 1, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
|
|
895
|
-
|
|
896
|
-
{ type: 'function', names:
|
|
921
|
+
processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, envArgIndex: 1, keepEnvironment: true, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
|
|
922
|
+
/* the rlang functions that capture unevaluated, the rest take a value */
|
|
923
|
+
{ type: 'function', names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['quo', 'quos', 'expr', 'exprs']), processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, unquote: nse_1.Unquote.Rlang, keepEnvironment: true, libFn: true, props: built_in_props_1.CallProp.Lang }, assumePrimitive: true },
|
|
924
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['exec', "rlang" /* PkgName.Rlang */])],
|
|
925
|
+
processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: '.fn', unquoteFunction: true, hasUnknownSideEffects: true, libFn: true, props: built_in_props_1.CallProp.MayPure, sig: [['.fn', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
926
|
+
{ type: 'function', names: identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['invoke', 'invoke_map']),
|
|
927
|
+
processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: '.f', unquoteFunction: true, hasUnknownSideEffects: true, libFn: true, props: built_in_props_1.CallProp.MayPure, sig: [['.f', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
928
|
+
/* the `{...}` of a template holds R code, evaluated where the call is; `cli_abort` stays with the other
|
|
929
|
+
* error exits, as terminating a branch matters more than interpolating its message */
|
|
930
|
+
{ type: 'function', names: [...identifier_1.Identifier.fromAll("glue" /* PkgName.Glue */, ['glue', 'glue_safe', 'glue_collapse']), identifier_1.Identifier.from(['str_glue', "stringr" /* PkgName.Stringr */])],
|
|
931
|
+
processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
932
|
+
{ type: 'function', names: identifier_1.Identifier.fromAll("cli" /* PkgName.Cli */, ['cli_text', 'cli_alert', 'cli_alert_info', 'cli_alert_success',
|
|
933
|
+
'cli_alert_warning', 'cli_alert_danger', 'cli_h1', 'cli_h2', 'cli_h3', 'cli_li', 'cli_bullets', 'cli_inform', 'cli_warn',
|
|
934
|
+
'format_inline', 'cli_verbatim']),
|
|
935
|
+
processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { markup: true, props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
936
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['str_interp', "stringr" /* PkgName.Stringr */])],
|
|
937
|
+
processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '${', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
897
938
|
{ type: 'function', names: [identifier_1.Identifier.from(['local', "base" /* PkgName.Base */])],
|
|
898
939
|
processor: built_in_proc_name_1.BuiltInProcName.Local, config: { args: { env: 'envir', expr: 'expr' } }, assumePrimitive: false },
|
|
899
940
|
{ type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['with', 'within']),
|
|
@@ -1071,8 +1112,10 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
1071
1112
|
processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse], ['envir', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
1072
1113
|
{
|
|
1073
1114
|
type: 'function',
|
|
1074
|
-
names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['enexpr', 'enexprs', 'inject', '
|
|
1075
|
-
'
|
|
1115
|
+
names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['enexpr', 'enexprs', 'inject', 'enquo', 'enquos', 'enquo0', 'enquos0',
|
|
1116
|
+
'ensym', 'ensyms', 'new_formula',
|
|
1117
|
+
'f_rhs', 'f_lhs', 'fn_body', 'fn_fmls', 'fn_fmls_names', 'call2', 'sym', 'syms', 'quo_name', 'as_name',
|
|
1118
|
+
'as_label', 'as_string']),
|
|
1076
1119
|
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
1077
1120
|
config: { forceArgs: 'all', libFn: true, props: built_in_props_1.CallProp.Lang },
|
|
1078
1121
|
assumePrimitive: false
|
|
@@ -102,6 +102,11 @@ export declare class Environment implements IEnvironment {
|
|
|
102
102
|
* Adds all writes of `other` to this environment (`other`'s operations *might* happen). Always recurses parents.
|
|
103
103
|
*/
|
|
104
104
|
append(other: Environment | undefined): Environment;
|
|
105
|
+
/**
|
|
106
|
+
* The environment a merge with `other` settles on without touching either memory, `undefined` if the
|
|
107
|
+
* memories have to be merged. Package blocks are always unioned, never overwritten or appended to.
|
|
108
|
+
*/
|
|
109
|
+
private mergeShortcut;
|
|
105
110
|
/**
|
|
106
111
|
* Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
|
|
107
112
|
*/
|
|
@@ -237,12 +237,9 @@ class Environment {
|
|
|
237
237
|
if (!other || this === other) {
|
|
238
238
|
return this;
|
|
239
239
|
}
|
|
240
|
-
|
|
241
|
-
if (
|
|
242
|
-
return
|
|
243
|
-
}
|
|
244
|
-
if (this.builtInEnv || this.n !== other.n) {
|
|
245
|
-
return this;
|
|
240
|
+
const shortcut = this.mergeShortcut(other);
|
|
241
|
+
if (shortcut !== undefined) {
|
|
242
|
+
return shortcut;
|
|
246
243
|
}
|
|
247
244
|
const map = new Map(this.memory);
|
|
248
245
|
for (const [key, values] of other.memory) {
|
|
@@ -291,12 +288,9 @@ class Environment {
|
|
|
291
288
|
if (!other || this === other) {
|
|
292
289
|
return this;
|
|
293
290
|
}
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
return
|
|
297
|
-
}
|
|
298
|
-
if (this.builtInEnv || this.n !== other.n) {
|
|
299
|
-
return this;
|
|
291
|
+
const shortcut = this.mergeShortcut(other);
|
|
292
|
+
if (shortcut !== undefined) {
|
|
293
|
+
return shortcut;
|
|
300
294
|
}
|
|
301
295
|
const map = new Map(this.memory);
|
|
302
296
|
for (const [key, value] of other.memory) {
|
|
@@ -309,12 +303,23 @@ class Environment {
|
|
|
309
303
|
}
|
|
310
304
|
}
|
|
311
305
|
const out = new Environment(this.parent.append(other.parent));
|
|
306
|
+
out.c = this.c;
|
|
312
307
|
out.n = this.n;
|
|
313
308
|
out.t = this.t;
|
|
314
309
|
out.globalEnv = this.globalEnv;
|
|
315
310
|
out.memory = map;
|
|
316
311
|
return out;
|
|
317
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* The environment a merge with `other` settles on without touching either memory, `undefined` if the
|
|
315
|
+
* memories have to be merged. Package blocks are always unioned, never overwritten or appended to.
|
|
316
|
+
*/
|
|
317
|
+
mergeShortcut(other) {
|
|
318
|
+
if (this.t !== undefined || other.t !== undefined) {
|
|
319
|
+
return this.mergePackageBlocks(other);
|
|
320
|
+
}
|
|
321
|
+
return this.builtInEnv || this.n !== other.n ? this : undefined;
|
|
322
|
+
}
|
|
318
323
|
/**
|
|
319
324
|
* Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
|
|
320
325
|
*/
|
|
@@ -192,6 +192,9 @@ export declare const enum PkgName {
|
|
|
192
192
|
Tcltk = "tcltk",
|
|
193
193
|
Testthat = "testthat",
|
|
194
194
|
TidyR = "tidyr",
|
|
195
|
+
Tibble = "tibble",
|
|
196
|
+
Glue = "glue",
|
|
197
|
+
Stringr = "stringr",
|
|
195
198
|
TinyPlot = "tinyplot",
|
|
196
199
|
TryCatchLog = "tryCatchLog",
|
|
197
200
|
Withr = "withr"
|
|
@@ -137,10 +137,8 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
|
|
|
137
137
|
blocked.add(node.info.id);
|
|
138
138
|
switch (node.type) {
|
|
139
139
|
case type_1.RType.Argument:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
// eslint-disable-next-line no-fallthrough
|
|
140
|
+
/* a missing argument (`f(x=)`) carries no value, and it is no symbol to resolve either */
|
|
141
|
+
return node.value ? resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve, ctx, blocked }) : r_value_1.Top;
|
|
144
142
|
case type_1.RType.Symbol:
|
|
145
143
|
if (full) {
|
|
146
144
|
if (environment) {
|
|
@@ -170,9 +168,8 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
|
|
|
170
168
|
}
|
|
171
169
|
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
172
170
|
function resolveIdToSingleString(id, info) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
return element?.type === 'string' && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
|
|
171
|
+
const element = (0, general_1.soleValue)((0, general_1.valueSetGuard)(resolveIdToValue(id, info)), 'string');
|
|
172
|
+
return element !== undefined && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
|
|
176
173
|
}
|
|
177
174
|
/** the values one element of a sequence may take: a vector contributes its elements, a set what its members do */
|
|
178
175
|
function iteratedElements(value) {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { ParentInformation, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import type { DataflowProcessorInformation } from '../../processor';
|
|
4
|
+
import type { DataflowGraph } from '../../graph/graph';
|
|
5
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
6
|
+
import type { ResolveInfo, ResolveResult } from './alias-tracking';
|
|
7
|
+
import { soleValue } from '../values/general';
|
|
8
|
+
import type { Value, ValueSet } from '../values/r-value';
|
|
9
|
+
/** The node to resolve, given either by id or directly. */
|
|
10
|
+
type Target = NodeId | RNodeWithParent | undefined;
|
|
11
|
+
declare function infoOf<OtherInfo>(this: void, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>): ResolveInfo;
|
|
12
|
+
/**
|
|
13
|
+
* The value(s) a node may hold, resolved against the state the current processor sees.
|
|
14
|
+
* Use {@link NodeValue.inGraph} to resolve against a finished {@link DataflowGraph} instead.
|
|
15
|
+
* Every entry point accepts overrides for the cases that deviate (e.g. another environment).
|
|
16
|
+
*
|
|
17
|
+
* This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
|
|
18
|
+
* constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
|
|
19
|
+
* Anything needing an abstract state lives in `src/abstract-interpretation/`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NodeValue: {
|
|
22
|
+
readonly name: "NodeValue";
|
|
23
|
+
/** The resolve info the processor's state stands for, for repeated resolutions. */
|
|
24
|
+
readonly infoOf: typeof infoOf;
|
|
25
|
+
/** The value(s) the node may hold. */
|
|
26
|
+
readonly of: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ResolveResult;
|
|
27
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
28
|
+
readonly setOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
|
|
29
|
+
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
30
|
+
readonly stringsOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string[] | undefined;
|
|
31
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
32
|
+
readonly singleStringOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string | undefined;
|
|
33
|
+
/** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */
|
|
34
|
+
readonly sole: typeof soleValue;
|
|
35
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
36
|
+
readonly soleOf: <OtherInfo, T extends Value["type"]>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, {
|
|
37
|
+
type: T;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
/** The same questions, asked of a finished dataflow graph instead of a running processor. */
|
|
40
|
+
readonly inGraph: {
|
|
41
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
42
|
+
readonly setOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
|
|
43
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
44
|
+
readonly singleStringOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => string | undefined;
|
|
45
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
46
|
+
readonly soleOf: <T extends Value["type"]>(this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, {
|
|
47
|
+
type: T;
|
|
48
|
+
}> | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeValue = void 0;
|
|
4
|
+
const alias_tracking_1 = require("./alias-tracking");
|
|
5
|
+
const general_1 = require("../values/general");
|
|
6
|
+
const string_constants_1 = require("../values/string/string-constants");
|
|
7
|
+
function infoOf(data, overrides) {
|
|
8
|
+
return {
|
|
9
|
+
environment: data.environment,
|
|
10
|
+
idMap: data.completeAst.idMap,
|
|
11
|
+
resolve: data.ctx.config.solver.variables,
|
|
12
|
+
ctx: data.ctx,
|
|
13
|
+
...overrides
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function graphInfoOf(graph, ctx, overrides) {
|
|
17
|
+
return { graph, resolve: ctx.config.solver.variables, ctx, ...overrides };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The value(s) a node may hold, resolved against the state the current processor sees.
|
|
21
|
+
* Use {@link NodeValue.inGraph} to resolve against a finished {@link DataflowGraph} instead.
|
|
22
|
+
* Every entry point accepts overrides for the cases that deviate (e.g. another environment).
|
|
23
|
+
*
|
|
24
|
+
* This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
|
|
25
|
+
* constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
|
|
26
|
+
* Anything needing an abstract state lives in `src/abstract-interpretation/`.
|
|
27
|
+
*/
|
|
28
|
+
exports.NodeValue = {
|
|
29
|
+
name: 'NodeValue',
|
|
30
|
+
/** The resolve info the processor's state stands for, for repeated resolutions. */
|
|
31
|
+
infoOf,
|
|
32
|
+
/** The value(s) the node may hold. */
|
|
33
|
+
of(id, data, overrides) {
|
|
34
|
+
return (0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides));
|
|
35
|
+
},
|
|
36
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
37
|
+
setOf(id, data, overrides) {
|
|
38
|
+
return (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides)));
|
|
39
|
+
},
|
|
40
|
+
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
41
|
+
stringsOf(id, data, overrides) {
|
|
42
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides)));
|
|
43
|
+
return resolved ? (0, string_constants_1.collectStrings)(resolved.elements) : undefined;
|
|
44
|
+
},
|
|
45
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
46
|
+
singleStringOf(id, data, overrides) {
|
|
47
|
+
return (0, alias_tracking_1.resolveIdToSingleString)(id, infoOf(data, overrides));
|
|
48
|
+
},
|
|
49
|
+
/** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */
|
|
50
|
+
sole: general_1.soleValue,
|
|
51
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
52
|
+
soleOf(id, data, type, overrides) {
|
|
53
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, infoOf(data, overrides))), type);
|
|
54
|
+
},
|
|
55
|
+
/** The same questions, asked of a finished dataflow graph instead of a running processor. */
|
|
56
|
+
inGraph: {
|
|
57
|
+
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
58
|
+
setOf(id, graph, ctx, overrides) {
|
|
59
|
+
return (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, graphInfoOf(graph, ctx, overrides)));
|
|
60
|
+
},
|
|
61
|
+
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
62
|
+
singleStringOf(id, graph, ctx, overrides) {
|
|
63
|
+
return (0, alias_tracking_1.resolveIdToSingleString)(id, graphInfoOf(graph, ctx, overrides));
|
|
64
|
+
},
|
|
65
|
+
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
66
|
+
soleOf(id, graph, ctx, type, overrides) {
|
|
67
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, graphInfoOf(graph, ctx, overrides))), type);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=node-value.js.map
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getArgumentStringValue = getArgumentStringValue;
|
|
4
4
|
const graph_1 = require("../../graph/graph");
|
|
5
|
+
const r_value_1 = require("../values/r-value");
|
|
5
6
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
6
7
|
const assert_1 = require("../../../util/assert");
|
|
7
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
8
9
|
const dependencies_query_format_1 = require("../../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
9
10
|
const general_1 = require("../values/general");
|
|
10
11
|
const alias_tracking_1 = require("./alias-tracking");
|
|
11
|
-
const
|
|
12
|
+
const r_value_2 = require("../values/r-value");
|
|
12
13
|
const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
|
|
13
14
|
const string_constants_1 = require("../values/string/string-constants");
|
|
14
15
|
/**
|
|
@@ -92,7 +93,7 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environm
|
|
|
92
93
|
if (resolved) {
|
|
93
94
|
const values = [];
|
|
94
95
|
for (const value of resolved.elements) {
|
|
95
|
-
const strings = (0,
|
|
96
|
+
const strings = (0, r_value_2.isValue)(value) ? stringsOfValue(value, full) : undefined;
|
|
96
97
|
if (strings === undefined) {
|
|
97
98
|
return undefined;
|
|
98
99
|
}
|
|
@@ -107,13 +108,15 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environm
|
|
|
107
108
|
*/
|
|
108
109
|
function stringsOfValue(value, full) {
|
|
109
110
|
switch (value.type) {
|
|
110
|
-
case 'string':
|
|
111
|
-
|
|
111
|
+
case 'string': {
|
|
112
|
+
const str = r_value_1.RValue.stringOf(value);
|
|
113
|
+
return str !== undefined ? [str] : undefined;
|
|
114
|
+
}
|
|
112
115
|
case 'logical':
|
|
113
|
-
return (0,
|
|
116
|
+
return (0, r_value_2.isValue)(value.value) ? [value.value.valueOf() ? convert_values_1.RTrue : convert_values_1.RFalse] : undefined;
|
|
114
117
|
case 'vector':
|
|
115
|
-
return (0,
|
|
116
|
-
? (0, string_constants_1.collectStrings)(value.elements, !full) ?? (value.elements.every(
|
|
118
|
+
return (0, r_value_2.isValue)(value.elements)
|
|
119
|
+
? (0, string_constants_1.collectStrings)(value.elements, !full) ?? (value.elements.every(r_value_2.isValue) ? [dependencies_query_format_1.Constant] : undefined)
|
|
117
120
|
: undefined;
|
|
118
121
|
case 'number':
|
|
119
122
|
case 'interval':
|
|
@@ -109,7 +109,6 @@ function resolveAsGroup(args) {
|
|
|
109
109
|
return r_value_2.Top;
|
|
110
110
|
}
|
|
111
111
|
/* unwrap the set again, as the caller of a handler wraps the returned value in one */
|
|
112
|
-
|
|
113
|
-
return values?.elements.length === 1 ? values.elements[0] : r_value_2.Top;
|
|
112
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(node.children[0], args))) ?? r_value_2.Top;
|
|
114
113
|
}
|
|
115
114
|
//# sourceMappingURL=resolve-operators.js.map
|
|
@@ -11,6 +11,10 @@ export declare function bottomTopGuard(...a: Lift<unknown>[]): typeof Top | type
|
|
|
11
11
|
* @returns value set if a is not top or bottom
|
|
12
12
|
*/
|
|
13
13
|
export declare function valueSetGuard(a: Lift<ValueSet<Value[]>>): ValueSet<Value[]> | undefined;
|
|
14
|
+
export declare function soleValue(this: void, set: ValueSet<Value[]> | undefined): Value | undefined;
|
|
15
|
+
export declare function soleValue<T extends Value['type']>(this: void, set: ValueSet<Value[]> | undefined, type: T): Extract<Value, {
|
|
16
|
+
type: T;
|
|
17
|
+
}> | undefined;
|
|
14
18
|
/**
|
|
15
19
|
* Constructs an Abstract Value from a normal TS value
|
|
16
20
|
* @param a - ts value
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bottomTopGuard = bottomTopGuard;
|
|
4
4
|
exports.valueSetGuard = valueSetGuard;
|
|
5
|
+
exports.soleValue = soleValue;
|
|
5
6
|
exports.valueFromTsValue = valueFromTsValue;
|
|
6
7
|
exports.valueFromRNodeConstant = valueFromRNodeConstant;
|
|
7
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -30,6 +31,16 @@ function bottomTopGuard(...a) {
|
|
|
30
31
|
function valueSetGuard(a) {
|
|
31
32
|
return ((0, r_value_1.isBottom)(a) || (0, r_value_1.isTop)(a)) ? undefined : a;
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind.
|
|
36
|
+
* @param set - the set to take the value from
|
|
37
|
+
* @param type - the kind the value has to have, any kind if unset
|
|
38
|
+
* @returns the sole value, `undefined` if the set holds another number of them or another kind
|
|
39
|
+
*/
|
|
40
|
+
function soleValue(set, type) {
|
|
41
|
+
const only = set?.elements.length === 1 ? set.elements[0] : undefined;
|
|
42
|
+
return only !== undefined && (type === undefined || only.type === type) ? only : undefined;
|
|
43
|
+
}
|
|
33
44
|
/**
|
|
34
45
|
* Constructs an Abstract Value from a normal TS value
|
|
35
46
|
* @param a - ts value
|
|
@@ -74,3 +74,18 @@ export declare function asValue<V extends Lift<unknown>>(value: V): Unlift<V>;
|
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
76
|
export declare function stringifyValue(value: Lift<Value>): string;
|
|
77
|
+
/**
|
|
78
|
+
* Reads the plain TS value a {@link Value} stands for, `undefined` whenever it stands for more than one, for
|
|
79
|
+
* none, or for another kind. Prefer these over reaching into a value's shape by hand.
|
|
80
|
+
*
|
|
81
|
+
* This is the constant-folding view: it answers "is this one known constant" and nothing else. It runs no
|
|
82
|
+
* fixpoint, knows no control flow, and widens nothing. For an abstract state that does, use the dedicated
|
|
83
|
+
* abstract interpretation in `src/abstract-interpretation/`.
|
|
84
|
+
*/
|
|
85
|
+
export declare const RValue: {
|
|
86
|
+
readonly name: "RValue";
|
|
87
|
+
/** The number the value stands for, collapsing an interval that admits a single one. */
|
|
88
|
+
readonly numberOf: (this: void, value: Value) => number | undefined;
|
|
89
|
+
/** The string the value stands for. */
|
|
90
|
+
readonly stringOf: (this: void, value: Value) => string | undefined;
|
|
91
|
+
};
|