@eagleoutice/flowr 2.13.4 → 2.13.5

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.
Files changed (130) hide show
  1. package/README.md +31 -31
  2. package/cli/repl/core.js +10 -2
  3. package/config.d.ts +4 -1
  4. package/config.js +10 -1
  5. package/control-flow/cfg-dead-code.js +19 -4
  6. package/control-flow/extract-cfg.js +12 -4
  7. package/dataflow/environments/built-in-config.d.ts +6 -3
  8. package/dataflow/environments/built-in-eval-name.d.ts +20 -0
  9. package/dataflow/environments/built-in-eval-name.js +25 -0
  10. package/dataflow/environments/built-in-props.d.ts +175 -0
  11. package/dataflow/environments/built-in-props.js +207 -0
  12. package/dataflow/environments/built-in.d.ts +26 -22
  13. package/dataflow/environments/built-in.js +37 -10
  14. package/dataflow/environments/default-builtin-config.d.ts +1046 -93
  15. package/dataflow/environments/default-builtin-config.js +485 -213
  16. package/dataflow/environments/identifier.d.ts +24 -1
  17. package/dataflow/environments/identifier.js +24 -2
  18. package/dataflow/environments/query-fn-props.d.ts +102 -0
  19. package/dataflow/environments/query-fn-props.js +188 -0
  20. package/dataflow/eval/resolve/alias-tracking.js +4 -1
  21. package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
  22. package/dataflow/eval/resolve/match-arguments.js +77 -0
  23. package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
  24. package/dataflow/eval/resolve/resolve-numbers.js +163 -0
  25. package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
  26. package/dataflow/eval/resolve/resolve-operators.js +115 -0
  27. package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
  28. package/dataflow/eval/resolve/resolve-strings.js +116 -0
  29. package/dataflow/eval/resolve/resolve.d.ts +5 -37
  30. package/dataflow/eval/resolve/resolve.js +56 -134
  31. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +5 -4
  33. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  34. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
  35. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  36. package/documentation/data/faq/faqs.js +11 -0
  37. package/documentation/doc-util/doc-types.js +1 -1
  38. package/documentation/wiki-analyzer.js +75 -0
  39. package/documentation/wiki-core.js +65 -16
  40. package/documentation/wiki-interface.js +3 -0
  41. package/linter/linter-rules.d.ts +10 -11
  42. package/linter/rules/deprecated-functions.js +5 -3
  43. package/linter/rules/function-finder-util.d.ts +2 -2
  44. package/linter/rules/function-finder-util.js +10 -3
  45. package/linter/rules/network-functions.d.ts +25 -5
  46. package/linter/rules/network-functions.js +51 -11
  47. package/linter/rules/problematic-inputs.d.ts +1 -1
  48. package/linter/rules/problematic-inputs.js +7 -1
  49. package/linter/rules/seeded-randomness.d.ts +5 -8
  50. package/linter/rules/seeded-randomness.js +17 -9
  51. package/package.json +3 -2
  52. package/project/cache/flowr-analyzer-cache.d.ts +4 -3
  53. package/project/cache/flowr-analyzer-cache.js +32 -13
  54. package/project/cache/flowr-cache.d.ts +39 -12
  55. package/project/cache/flowr-cache.js +5 -3
  56. package/project/context/flowr-analyzer-context.d.ts +8 -1
  57. package/project/context/flowr-analyzer-context.js +11 -1
  58. package/project/context/flowr-analyzer-dependencies-context.d.ts +4 -2
  59. package/project/context/flowr-analyzer-dependencies-context.js +15 -1
  60. package/project/context/flowr-analyzer-files-context.d.ts +8 -4
  61. package/project/context/flowr-analyzer-files-context.js +20 -1
  62. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
  63. package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
  64. package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
  65. package/project/context/flowr-analyzer-meta-context.js +14 -0
  66. package/project/context/flowr-file.d.ts +25 -3
  67. package/project/context/flowr-file.js +24 -2
  68. package/project/dependency-version-space.d.ts +37 -0
  69. package/project/dependency-version-space.js +118 -26
  70. package/project/flowr-analyzer.d.ts +6 -0
  71. package/project/flowr-analyzer.js +6 -2
  72. package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
  73. package/project/incremental/incremental-parse/edit-computation.js +61 -0
  74. package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
  75. package/project/incremental/incremental-parse/incremental-parse.js +37 -0
  76. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
  77. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
  78. package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
  79. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
  80. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  81. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
  82. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
  83. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
  84. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
  85. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
  86. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +27 -0
  87. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
  89. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
  90. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
  91. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
  92. package/project/plugins/plugin-registry.d.ts +4 -4
  93. package/project/plugins/plugin-registry.js +7 -4
  94. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
  95. package/project/sigdb/reader.d.ts +7 -0
  96. package/project/sigdb/reader.js +12 -0
  97. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
  98. package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
  99. package/queries/catalog/dependencies-query/function-info/read-functions.js +13 -12
  100. package/queries/catalog/dependencies-query/function-info/write-functions.js +16 -23
  101. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
  102. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
  103. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
  104. package/queries/catalog/input-sources-query/input-source-functions.d.ts +8 -10
  105. package/queries/catalog/input-sources-query/input-source-functions.js +23 -388
  106. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
  107. package/queries/catalog/input-sources-query/input-sources-query-format.js +27 -10
  108. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
  109. package/queries/catalog/signature-query/signature-query-executor.js +79 -3
  110. package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
  111. package/queries/catalog/signature-query/signature-query-render.js +21 -3
  112. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
  113. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
  114. package/r-bridge/parser.d.ts +11 -1
  115. package/r-bridge/parser.js +7 -4
  116. package/r-bridge/shell-executor.d.ts +1 -0
  117. package/r-bridge/shell-executor.js +1 -0
  118. package/r-bridge/shell.d.ts +1 -0
  119. package/r-bridge/shell.js +1 -0
  120. package/search/flowr-search-filters.d.ts +1 -6
  121. package/search/flowr-search-filters.js +1 -8
  122. package/search/search-executor/search-enrichers.d.ts +2 -0
  123. package/search/search-executor/search-enrichers.js +29 -12
  124. package/util/version.js +1 -1
  125. package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
  126. package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
  127. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
  128. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
  129. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
  130. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PasteLikeCalls = exports.StringFns = void 0;
4
+ exports.foldStringCall = foldStringCall;
5
+ exports.resolveAsStringFn = resolveAsStringFn;
6
+ const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
7
+ const identifier_1 = require("../../environments/identifier");
8
+ const r_value_1 = require("../values/r-value");
9
+ const string_constants_1 = require("../values/string/string-constants");
10
+ const interval_constants_1 = require("../values/intervals/interval-constants");
11
+ const alias_tracking_1 = require("./alias-tracking");
12
+ const match_arguments_1 = require("./match-arguments");
13
+ /** everything after the last separator, with trailing separators dropped first (`a/b/` is `b`, `/` is the empty string) */
14
+ function basename(path) {
15
+ const trimmed = path.replace(/\/+$/, '');
16
+ return trimmed.slice(trimmed.lastIndexOf('/') + 1);
17
+ }
18
+ /** everything before the last separator, `.` if there is none and `/` if only the root remains */
19
+ function dirname(path) {
20
+ if (path === '') {
21
+ return '';
22
+ }
23
+ const trimmed = path.length > 1 ? path.replace(/(?<=.)\/+$/, '') : path;
24
+ const cut = trimmed.lastIndexOf('/');
25
+ if (cut < 0) {
26
+ return '.';
27
+ }
28
+ const head = trimmed.slice(0, cut).replace(/\/+$/, '');
29
+ return head === '' ? '/' : head;
30
+ }
31
+ /**
32
+ * Every string built-in the value solver folds, the joining ones included: `paste` is an entry like `toupper`
33
+ * is, and both are reached through {@link resolveAsStringFn}. Teaching flowR one more is a line here plus the
34
+ * matching `evalHandler` in the built-in configuration -- a test checks that the two agree.
35
+ *
36
+ * An entry with a `...` parameter joins what it collected, which is why its separator is just another
37
+ * parameter with a default. The rest take a fixed number of arguments under the names R documents.
38
+ */
39
+ exports.StringFns = {
40
+ /* the joining calls, which differ only in their separator and what the argument overriding it is called */
41
+ paste: { params: ['...', 'sep'], defaults: { sep: ' ' }, ignored: ['collapse'], fold: (parts, sep) => parts.join(sep) },
42
+ paste0: { params: ['...', 'sep'], defaults: { sep: '' }, ignored: ['collapse'], fold: (parts, sep) => parts.join(sep) },
43
+ 'file.path': { params: ['...', 'fsep'], defaults: { fsep: '/' }, fold: (parts, fsep) => parts.join(fsep) },
44
+ /* the path splits, which only ever treat `/` as a separator, so a Windows path keeps its non-`\` parts */
45
+ basename: { params: ['path'], fold: basename },
46
+ dirname: { params: ['path'], fold: dirname },
47
+ /* whole-string transformations */
48
+ toupper: { params: ['x'], fold: (s) => s.toUpperCase() },
49
+ tolower: { params: ['x'], fold: (s) => s.toLowerCase() },
50
+ trimws: { params: ['x'], fold: (s) => s.trim() },
51
+ /** R counts characters, so we count code points rather than UTF-16 units */
52
+ nchar: { params: ['x'], fold: (s) => [...s].length }
53
+ };
54
+ /** the entries that join what they are handed, the ones a name at construction time may be built from */
55
+ exports.PasteLikeCalls = new Set(Object.entries(exports.StringFns).filter(([, fn]) => fn.params.includes('...')).map(([name]) => name));
56
+ /**
57
+ * Folds a named {@link StringFns} call to its result, resolving each argument with `resolveArg`. `undefined`
58
+ * when the name is not one of them, an argument does not resolve, or the call does not match what the entry
59
+ * declares. Shared by the value solver ({@link resolveAsStringFn}) and construction-time name resolution.
60
+ */
61
+ function foldStringCall(node, resolveArg) {
62
+ const known = exports.StringFns[identifier_1.Identifier.getName(node.functionName.content)];
63
+ if (known === undefined) {
64
+ return undefined;
65
+ }
66
+ const matched = (0, match_arguments_1.matchCallArguments)(node, known.params, known.ignored);
67
+ if (matched === undefined) {
68
+ return undefined;
69
+ }
70
+ /* a fold that reads the characters cannot run on source text with an escape still in it (`\t` is two chars
71
+ * there); joining does not read them, so the entries collecting a `...` are exempt */
72
+ const literal = !known.params.includes('...');
73
+ const args = [];
74
+ for (const [at, slot] of matched.entries()) {
75
+ if (Array.isArray(slot)) {
76
+ const parts = slot.map(resolveArg);
77
+ if (parts.some(p => p === undefined)) {
78
+ return undefined;
79
+ }
80
+ args.push(parts);
81
+ continue;
82
+ }
83
+ if (slot === undefined) {
84
+ const fallback = known.defaults?.[known.params[at]];
85
+ if (fallback === undefined) {
86
+ break; // the parameters R gives a default are the trailing ones, so the fold sees a shorter prefix
87
+ }
88
+ args.push(fallback);
89
+ continue;
90
+ }
91
+ // the argument *was* given, so failing to resolve it means we do not know the result, defaults do not apply
92
+ const value = resolveArg(slot);
93
+ if (value === undefined || (literal && value.includes('\\'))) {
94
+ return undefined;
95
+ }
96
+ args.push(value);
97
+ }
98
+ return args.length > 0 ? known.fold(...args) : undefined;
99
+ }
100
+ /**
101
+ * Resolves any call of a {@link StringFns} entry to a {@link Value}, with its arguments in any order R accepts:
102
+ * a join like `paste0("cfg_", k)` when every part resolves to a single string constant, and a transformation
103
+ * like `basename(p)` when its argument does. Anything that does not resolve stays `Top`.
104
+ */
105
+ function resolveAsStringFn(args) {
106
+ const node = args.node;
107
+ if (node.type !== type_1.RType.FunctionCall || !node.named) {
108
+ return r_value_1.Top;
109
+ }
110
+ const folded = foldStringCall(node, arg => (0, alias_tracking_1.resolveIdToSingleString)(arg.info.id, args));
111
+ if (folded === undefined) {
112
+ return r_value_1.Top;
113
+ }
114
+ return typeof folded === 'number' ? (0, interval_constants_1.intervalFrom)(folded, folded) : (0, string_constants_1.stringFrom)(folded);
115
+ }
116
+ //# sourceMappingURL=resolve-strings.js.map
@@ -1,16 +1,14 @@
1
- import type { RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
2
- import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
3
1
  import type { BuiltInEvalHandlerArgs } from '../../environments/built-in';
4
2
  import { type Lift, Top, type Value, type ValueNumber, type ValueVector } from '../values/r-value';
5
3
  /**
6
4
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
7
5
  * you want to resolve the value of an identifier / node
8
6
  *
9
- * This function converts an RNode to its Value, but also recursively resolves
10
- * aliases and vectors (in case of node vector).
7
+ * This function converts an RNode to its Value, either directly for a constant or by handing the node
8
+ * to the {@link BuiltInEvalHandler} its built-in declares, which may resolve further nodes recursively.
11
9
  * @returns resolved value or top/bottom
12
10
  */
13
- export declare function resolveNode({ resolve, node, ctx, blocked, environment, graph, idMap }: BuiltInEvalHandlerArgs): Value;
11
+ export declare function resolveNode(args: BuiltInEvalHandlerArgs): Value;
14
12
  /**
15
13
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
16
14
  * you want to resolve the value of an identifier / node
@@ -19,7 +17,7 @@ export declare function resolveNode({ resolve, node, ctx, blocked, environment,
19
17
  * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
20
18
  * @returns ValueVector or Top
21
19
  */
22
- export declare function resolveAsVector({ resolve, environment, node, graph, idMap, ctx, blocked }: BuiltInEvalHandlerArgs): ValueVector | typeof Top;
20
+ export declare function resolveAsVector(args: BuiltInEvalHandlerArgs): ValueVector | typeof Top;
23
21
  /**
24
22
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
25
23
  * you want to resolve the value of an identifier / node
@@ -28,34 +26,4 @@ export declare function resolveAsVector({ resolve, environment, node, graph, idM
28
26
  * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
29
27
  * @returns ValueVector of ValueNumbers or Top
30
28
  */
31
- export declare function resolveAsSeq({ node: operator, environment, resolve, ctx, graph, idMap, blocked }: BuiltInEvalHandlerArgs): ValueVector<Lift<ValueNumber[]>> | typeof Top;
32
- /**
33
- * Helper function used by {@link resolveIdToValue}, please use that instead, if
34
- * you want to resolve the value of an identifier / node
35
- *
36
- * This function resolves a unary plus operator `+` to a {@link ValueNumber} or {@link ValueVector} of ValueNumbers
37
- * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
38
- * @returns ValueNumber, ValueVector of ValueNumbers, or Top
39
- */
40
- export declare function resolveAsPlus({ node: operator, environment, resolve, ctx, graph, idMap, blocked }: BuiltInEvalHandlerArgs): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
41
- /**
42
- * Helper function used by {@link resolveIdToValue}, please use that instead, if
43
- * you want to resolve the value of an identifier / node
44
- *
45
- * This function resolves a unary minus operator `-` to a {@link ValueNumber} or {@link ValueVector} of ValueNumbers
46
- * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
47
- * @returns ValueNumber, ValueVector of ValueNumbers, or Top
48
- */
49
- export declare function resolveAsMinus({ node: operator, environment, resolve, ctx, graph, idMap, blocked }: BuiltInEvalHandlerArgs): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
50
- /**
51
- * Resolves a `paste`/`paste0` call to a {@link Value} string when every non-`sep`/`collapse` argument
52
- * resolves to a single string constant (e.g. `paste0("cfg_", k)` with `k` a known string). `sep` defaults to
53
- * `""` for `paste0` and `" "` for `paste`, or the constant `sep=` argument when given; any unresolved part yields Top.
54
- */
55
- export declare function resolveAsPaste({ resolve, node, ctx, blocked, environment, graph, idMap }: BuiltInEvalHandlerArgs): Value;
56
- /**
57
- * Folds a named `paste`/`paste0` call to its concatenated string, resolving each non-`sep`/`collapse` argument via
58
- * `resolveArg`; `sep` defaults to `""` (paste0) or `" "` (paste), overridden by a resolvable `sep=`. `undefined` if any
59
- * part (or `sep`) does not resolve. Shared by the value solver ({@link resolveAsPaste}) and construction-time name resolution.
60
- */
61
- export declare function foldPasteCall<Info>(node: RNamedFunctionCall<Info>, resolveArg: (arg: RNode<Info>) => string | undefined): string | undefined;
29
+ export declare function resolveAsSeq(args: BuiltInEvalHandlerArgs): ValueVector<Lift<ValueNumber[]>> | typeof Top;
@@ -3,14 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveNode = resolveNode;
4
4
  exports.resolveAsVector = resolveAsVector;
5
5
  exports.resolveAsSeq = resolveAsSeq;
6
- exports.resolveAsPlus = resolveAsPlus;
7
- exports.resolveAsMinus = resolveAsMinus;
8
- exports.resolveAsPaste = resolveAsPaste;
9
- exports.foldPasteCall = foldPasteCall;
10
6
  const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
11
7
  const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
12
8
  const r_value_1 = require("../../../util/r-value");
13
- const built_in_1 = require("../../environments/built-in");
14
9
  const interval_constants_1 = require("../values/intervals/interval-constants");
15
10
  const logical_constants_1 = require("../values/logical/logical-constants");
16
11
  const r_value_2 = require("../values/r-value");
@@ -19,17 +14,59 @@ const vector_constants_1 = require("../values/vectors/vector-constants");
19
14
  const alias_tracking_1 = require("./alias-tracking");
20
15
  const scalar_constants_1 = require("../values/scalar/scalar-constants");
21
16
  const identifier_1 = require("../../environments/identifier");
22
- const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
17
+ const resolve_by_name_1 = require("../../environments/resolve-by-name");
23
18
  const df_helper_1 = require("../../graph/df-helper");
19
+ const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
20
+ /**
21
+ * The {@link BuiltInEvalHandler} the given name resolves to in the current environment, just like the
22
+ * {@link BuiltInIdentifierDefinition#processor} a call resolves to; `undefined` if the name is shadowed
23
+ * by a user definition or its built-in declares no handler.
24
+ */
25
+ function evalHandlerOf(name, environment, ctx) {
26
+ const defs = environment ?
27
+ (0, resolve_by_name_1.resolveByName)(name, environment, identifier_1.ReferenceType.BuiltInFunction)
28
+ : ctx.env.builtInEnvironment.memory.get(identifier_1.Identifier.getName(name));
29
+ const def = defs?.length === 1 ? defs[0] : undefined;
30
+ return def?.type === identifier_1.ReferenceType.BuiltInFunction ? def.evalHandler : undefined;
31
+ }
32
+ /** the node types that may fold through a built-in: calls, operators, and the `(`/`{` groupings */
33
+ const EvalNodeTypes = [type_1.RType.FunctionCall, type_1.RType.BinaryOp, type_1.RType.UnaryOp, type_1.RType.ExpressionList];
34
+ /**
35
+ * The name of the built-in the given node folds through, `undefined` if it is no call to one or if it may just
36
+ * as well resolve to something else (a user redefinition, a conditional one, ...), which must not be folded.
37
+ */
38
+ function evalNameOf({ node, graph }) {
39
+ if (graph === undefined || !EvalNodeTypes.includes(node.type)) {
40
+ return undefined;
41
+ }
42
+ let name;
43
+ for (const origin of df_helper_1.Dataflow.origin(graph, node.info.id) ?? []) {
44
+ if (origin.type === 2 /* OriginType.FunctionCallOrigin */ || origin.type === 1 /* OriginType.WriteVariableOrigin */) {
45
+ /* the call may go to a definition of the program instead, so we know too little to fold it */
46
+ return undefined;
47
+ }
48
+ else if (origin.type !== 3 /* OriginType.BuiltInFunctionOrigin */) {
49
+ continue;
50
+ }
51
+ /* an alias like `f <- c` keeps the built-in it stands for in `proc`, a direct call names itself */
52
+ const named = node_id_1.NodeId.isBuiltIn(origin.proc) ? node_id_1.NodeId.fromBuiltIn(origin.proc) : origin.fn.name;
53
+ if (name !== undefined && identifier_1.Identifier.getName(name) !== identifier_1.Identifier.getName(named)) {
54
+ return undefined;
55
+ }
56
+ name = named;
57
+ }
58
+ return name;
59
+ }
24
60
  /**
25
61
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
26
62
  * you want to resolve the value of an identifier / node
27
63
  *
28
- * This function converts an RNode to its Value, but also recursively resolves
29
- * aliases and vectors (in case of node vector).
64
+ * This function converts an RNode to its Value, either directly for a constant or by handing the node
65
+ * to the {@link BuiltInEvalHandler} its built-in declares, which may resolve further nodes recursively.
30
66
  * @returns resolved value or top/bottom
31
67
  */
32
- function resolveNode({ resolve, node, ctx, blocked, environment, graph, idMap }) {
68
+ function resolveNode(args) {
69
+ const { node, environment, ctx } = args;
33
70
  const nt = node.type;
34
71
  if (nt === type_1.RType.String) {
35
72
  return (0, string_constants_1.stringFrom)(node.content.str);
@@ -43,30 +80,9 @@ function resolveNode({ resolve, node, ctx, blocked, environment, graph, idMap })
43
80
  else if (nt === type_1.RType.FunctionDefinition) {
44
81
  return { type: 'function-definition' };
45
82
  }
46
- else if ((nt === type_1.RType.FunctionCall || nt === type_1.RType.BinaryOp || nt === type_1.RType.UnaryOp) && graph) {
47
- const origin = df_helper_1.Dataflow.origin(graph, node.info.id)?.[0];
48
- if (origin === undefined || origin.type !== 3 /* OriginType.BuiltInFunctionOrigin */) {
49
- return r_value_2.Top;
50
- }
51
- let builtInName;
52
- if (node_id_1.NodeId.isBuiltIn(origin.proc)) {
53
- builtInName = origin.proc;
54
- }
55
- else if (nt === type_1.RType.FunctionCall && node.named) {
56
- builtInName = node_id_1.NodeId.toBuiltIn(identifier_1.Identifier.getName(node.functionName.content));
57
- }
58
- else if (nt === type_1.RType.BinaryOp || nt === type_1.RType.UnaryOp) {
59
- builtInName = node_id_1.NodeId.toBuiltIn(node.operator);
60
- }
61
- else {
62
- return r_value_2.Top;
63
- }
64
- if (Object.hasOwn(built_in_1.BuiltInEvalHandlerMapper, builtInName)) {
65
- const handler = built_in_1.BuiltInEvalHandlerMapper[builtInName];
66
- return handler({ resolve, node, ctx, blocked, environment, graph, idMap });
67
- }
68
- }
69
- return r_value_2.Top;
83
+ const name = evalNameOf(args);
84
+ const handler = name === undefined ? undefined : evalHandlerOf(name, environment, ctx);
85
+ return handler?.(args) ?? r_value_2.Top;
70
86
  }
71
87
  /**
72
88
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
@@ -76,13 +92,12 @@ function resolveNode({ resolve, node, ctx, blocked, environment, graph, idMap })
76
92
  * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
77
93
  * @returns ValueVector or Top
78
94
  */
79
- function resolveAsVector({ resolve, environment, node, graph, idMap, ctx, blocked }) {
95
+ function resolveAsVector(args) {
96
+ const node = args.node;
80
97
  if (node.type !== type_1.RType.FunctionCall) {
81
98
  return r_value_2.Top;
82
99
  }
83
- const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx, blocked };
84
- const values = node.arguments.map(arg => arg !== r_function_call_1.EmptyArgument ? (0, alias_tracking_1.resolveIdToValue)(arg.value, resolveInfo) : r_value_2.Top);
85
- return (0, vector_constants_1.vectorFrom)((0, vector_constants_1.flattenVectorElements)(values));
100
+ return (0, vector_constants_1.vectorFrom)((0, vector_constants_1.flattenVectorElements)(node.arguments.map(arg => arg !== r_function_call_1.EmptyArgument ? (0, alias_tracking_1.resolveIdToValue)(arg.value, args) : r_value_2.Top)));
86
101
  }
87
102
  /**
88
103
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
@@ -92,111 +107,18 @@ function resolveAsVector({ resolve, environment, node, graph, idMap, ctx, blocke
92
107
  * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
93
108
  * @returns ValueVector of ValueNumbers or Top
94
109
  */
95
- function resolveAsSeq({ node: operator, environment, resolve, ctx, graph, idMap, blocked }) {
110
+ function resolveAsSeq(args) {
111
+ const operator = args.node;
96
112
  if (operator.type !== type_1.RType.BinaryOp) {
97
113
  return r_value_2.Top;
98
114
  }
99
- const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx, blocked };
100
- const leftArg = (0, alias_tracking_1.resolveIdToValue)(operator.lhs, resolveInfo);
101
- const rightArg = (0, alias_tracking_1.resolveIdToValue)(operator.rhs, resolveInfo);
102
- const leftValue = (0, r_value_1.unliftRValue)(leftArg);
103
- const rightValue = (0, r_value_1.unliftRValue)(rightArg);
115
+ const leftValue = (0, r_value_1.unliftRValue)((0, alias_tracking_1.resolveIdToValue)(operator.lhs, args));
116
+ const rightValue = (0, r_value_1.unliftRValue)((0, alias_tracking_1.resolveIdToValue)(operator.rhs, args));
104
117
  if ((0, r_value_1.isRNumberValue)(leftValue) && (0, r_value_1.isRNumberValue)(rightValue)) {
105
118
  return (0, vector_constants_1.vectorFrom)(createNumberSequence(leftValue, rightValue).map(scalar_constants_1.liftScalar));
106
119
  }
107
120
  return r_value_2.Top;
108
121
  }
109
- /**
110
- * Helper function used by {@link resolveIdToValue}, please use that instead, if
111
- * you want to resolve the value of an identifier / node
112
- *
113
- * This function resolves a unary plus operator `+` to a {@link ValueNumber} or {@link ValueVector} of ValueNumbers
114
- * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
115
- * @returns ValueNumber, ValueVector of ValueNumbers, or Top
116
- */
117
- function resolveAsPlus({ node: operator, environment, resolve, ctx, graph, idMap, blocked }) {
118
- if (operator.type !== type_1.RType.UnaryOp) {
119
- return r_value_2.Top;
120
- }
121
- const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx, blocked };
122
- const arg = (0, alias_tracking_1.resolveIdToValue)(operator.operand, resolveInfo);
123
- const argValue = (0, r_value_1.unliftRValue)(arg);
124
- if ((0, r_value_1.isRNumberValue)(argValue)) {
125
- return (0, scalar_constants_1.liftScalar)(argValue);
126
- }
127
- else if (Array.isArray(argValue) && argValue.every(r_value_1.isRNumberValue)) {
128
- return (0, vector_constants_1.vectorFrom)(argValue.map(scalar_constants_1.liftScalar));
129
- }
130
- return r_value_2.Top;
131
- }
132
- /**
133
- * Helper function used by {@link resolveIdToValue}, please use that instead, if
134
- * you want to resolve the value of an identifier / node
135
- *
136
- * This function resolves a unary minus operator `-` to a {@link ValueNumber} or {@link ValueVector} of ValueNumbers
137
- * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
138
- * @returns ValueNumber, ValueVector of ValueNumbers, or Top
139
- */
140
- function resolveAsMinus({ node: operator, environment, resolve, ctx, graph, idMap, blocked }) {
141
- if (operator.type !== type_1.RType.UnaryOp) {
142
- return r_value_2.Top;
143
- }
144
- const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx, blocked };
145
- const arg = (0, alias_tracking_1.resolveIdToValue)(operator.operand, resolveInfo);
146
- const argValue = (0, r_value_1.unliftRValue)(arg);
147
- if ((0, r_value_1.isRNumberValue)(argValue)) {
148
- return (0, scalar_constants_1.liftScalar)({ ...argValue, num: -argValue.num });
149
- }
150
- else if (Array.isArray(argValue) && argValue.every(r_value_1.isRNumberValue)) {
151
- return (0, vector_constants_1.vectorFrom)(argValue.map(element => (0, scalar_constants_1.liftScalar)({ ...element, num: -element.num })));
152
- }
153
- return r_value_2.Top;
154
- }
155
- /**
156
- * Resolves a `paste`/`paste0` call to a {@link Value} string when every non-`sep`/`collapse` argument
157
- * resolves to a single string constant (e.g. `paste0("cfg_", k)` with `k` a known string). `sep` defaults to
158
- * `""` for `paste0` and `" "` for `paste`, or the constant `sep=` argument when given; any unresolved part yields Top.
159
- */
160
- function resolveAsPaste({ resolve, node, ctx, blocked, environment, graph, idMap }) {
161
- if (node.type !== type_1.RType.FunctionCall || !node.named) {
162
- return r_value_2.Top;
163
- }
164
- const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx, blocked };
165
- const folded = foldPasteCall(node, arg => (0, alias_tracking_1.resolveIdToSingleString)(arg.info.id, resolveInfo));
166
- return folded === undefined ? r_value_2.Top : (0, string_constants_1.stringFrom)(folded);
167
- }
168
- /**
169
- * Folds a named `paste`/`paste0` call to its concatenated string, resolving each non-`sep`/`collapse` argument via
170
- * `resolveArg`; `sep` defaults to `""` (paste0) or `" "` (paste), overridden by a resolvable `sep=`. `undefined` if any
171
- * part (or `sep`) does not resolve. Shared by the value solver ({@link resolveAsPaste}) and construction-time name resolution.
172
- */
173
- function foldPasteCall(node, resolveArg) {
174
- let sep = identifier_1.Identifier.getName(node.functionName.content) === 'paste0' ? '' : ' ';
175
- const parts = [];
176
- for (const arg of node.arguments) {
177
- if (arg === r_function_call_1.EmptyArgument || arg.value === undefined) {
178
- continue;
179
- }
180
- const argName = arg.name?.content;
181
- if (argName === 'collapse') {
182
- continue;
183
- }
184
- else if (argName === 'sep') {
185
- const s = resolveArg(arg.value);
186
- if (s === undefined) {
187
- return undefined;
188
- }
189
- sep = s;
190
- continue;
191
- }
192
- const part = resolveArg(arg.value);
193
- if (part === undefined) {
194
- return undefined;
195
- }
196
- parts.push(part);
197
- }
198
- return parts.join(sep);
199
- }
200
122
  function createNumberSequence(start, end) {
201
123
  const sequence = [];
202
124
  const min = Math.min(start.num, end.num);
@@ -34,7 +34,7 @@ export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgu
34
34
  * instead of a hardcoded formal list, while staying correct -- and graph-invariant -- when no signature is available.
35
35
  */
36
36
  export declare function signatureParamNames<OtherInfo>(data: DataflowProcessorInformation<OtherInfo & ParentInformation>, id: Identifier, fallback: readonly string[]): readonly string[];
37
- /** The constant string a name-position node denotes at construction time (string literal, aliased variable, or `paste`/`paste0` of such); `undefined` if any part is dynamic or the paste builtin is user-shadowed. */
37
+ /** The constant string a name-position node denotes at construction time (string literal, aliased variable, or a paste-like join of such); `undefined` if any part is dynamic or the paste builtin is user-shadowed. */
38
38
  export declare function resolveConstantString<OtherInfo>(node: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): string | undefined;
39
39
  /** The `returnsEnvState` of the first reaching definition that carries one, else `undefined`. */
40
40
  export declare function findReturnsEnvState(defs: readonly IdentifierDefinition[] | undefined): REnvironmentInformation | undefined;
@@ -20,7 +20,7 @@ const environment_1 = require("../../../../../environments/environment");
20
20
  const prefix_1 = require("../../../../../../util/prefix");
21
21
  const built_in_stack_env_1 = require("./built-in-stack-env");
22
22
  const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
23
- const resolve_1 = require("../../../../../eval/resolve/resolve");
23
+ const resolve_strings_1 = require("../../../../../eval/resolve/resolve-strings");
24
24
  const general_1 = require("../../../../../eval/values/general");
25
25
  const logger_1 = require("../../../../../logger");
26
26
  /** A tracked env is a real stack environment (not a private custom env) when its current layer is the global or the built-in/base env. */
@@ -80,7 +80,7 @@ function signatureParamNames(data, id, fallback) {
80
80
  const names = sig ? (0, decode_1.signatureParameterNames)(sig) : [];
81
81
  return names.length > 0 ? names : fallback;
82
82
  }
83
- /** The constant string a name-position node denotes at construction time (string literal, aliased variable, or `paste`/`paste0` of such); `undefined` if any part is dynamic or the paste builtin is user-shadowed. */
83
+ /** The constant string a name-position node denotes at construction time (string literal, aliased variable, or a paste-like join of such); `undefined` if any part is dynamic or the paste builtin is user-shadowed. */
84
84
  function resolveConstantString(node, data) {
85
85
  const info = { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx, full: true };
86
86
  const unshadowed = new Map();
@@ -89,7 +89,7 @@ function resolveConstantString(node, data) {
89
89
  return (0, alias_tracking_1.resolveIdToSingleString)(n.info.id, info);
90
90
  }
91
91
  const fnName = identifier_1.Identifier.getName(n.functionName.content);
92
- if (fnName !== 'paste0' && fnName !== 'paste') {
92
+ if (!resolve_strings_1.PasteLikeCalls.has(fnName)) {
93
93
  return undefined;
94
94
  }
95
95
  let ok = unshadowed.get(fnName);
@@ -98,7 +98,8 @@ function resolveConstantString(node, data) {
98
98
  ok = defs === undefined || defs.every(d => (0, identifier_1.isReferenceType)(d.type, identifier_1.ReferenceType.BuiltInFunction));
99
99
  unshadowed.set(fnName, ok);
100
100
  }
101
- return ok ? (0, resolve_1.foldPasteCall)(n, fold) : undefined;
101
+ const folded = ok ? (0, resolve_strings_1.foldStringCall)(n, fold) : undefined;
102
+ return typeof folded === 'string' ? folded : undefined;
102
103
  };
103
104
  return fold(node);
104
105
  }
@@ -230,7 +230,7 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId) {
230
230
  else if (gasLevel >= 1 /* GasLevel.Problematic */) {
231
231
  logger_1.dataflowLogger.warn(`Approaching resource limits for source of ${JSON.stringify(request)} (gas: problematic). See ${gas_1.GasWikiRef}`);
232
232
  }
233
- const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(textRequest.r);
233
+ const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(textRequest.r, data.ctx);
234
234
  const normalized = (typeof parsed !== 'string' ?
235
235
  (0, parser_1.normalizeTreeSitter)({ files: [{ parsed, filePath: textRequest.path }] }, getId, data.ctx.config)
236
236
  : (0, parser_1.normalize)({ files: [{ parsed, filePath: textRequest.path }] }, getId));
@@ -60,8 +60,9 @@ export declare enum NseArguments {
60
60
  /**
61
61
  * Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
62
62
  * (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
63
+ * Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
63
64
  */
64
- export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments): void;
65
+ export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[]): void;
65
66
  /**
66
67
  * Marks the given arguments as being involved in R's non-standard evaluation.
67
68
  */
@@ -29,12 +29,13 @@ var NseArguments;
29
29
  /**
30
30
  * Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
31
31
  * (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
32
+ * Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
32
33
  */
33
34
  function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which) {
34
35
  const end = which === NseArguments.First ? 1 : processedArguments.length;
35
36
  for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
36
37
  const arg = processedArguments[i];
37
- if (arg === undefined) {
38
+ if (arg === undefined || (typeof which !== 'string' && !which.includes(i))) {
38
39
  continue;
39
40
  }
40
41
  graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
@@ -6,6 +6,9 @@ const doc_files_1 = require("../../doc-util/doc-files");
6
6
  const doc_code_1 = require("../../doc-util/doc-code");
7
7
  const recommended_configs_1 = require("./recommended-configs");
8
8
  const project_kind_1 = require("../../../project/context/project-kind");
9
+ const doc_cli_option_1 = require("../../doc-util/doc-cli-option");
10
+ const log_1 = require("../../../../test/functionality/_helper/log");
11
+ const log_2 = require("../../../util/log");
9
12
  /**
10
13
  *
11
14
  */
@@ -52,6 +55,14 @@ ${(0, doc_code_1.codeBlock)('shell', 'npm run flowR -- --help')}
52
55
  `)
53
56
  .addFaq('How to do *logging* in flowR?', `
54
57
  Check out the ${ctx.linkPage('wiki/Linting and Testing', 'Logging Section in the Linting and Testing wiki page', 'logging')} for more information on how to do logging in *flowR*.
58
+ `)
59
+ .addFaq('How to get flowR to *talk*?', `
60
+ When using flowR from the CLI, you can use the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'verbose')} option to get more information about what flowR is doing.
61
+ While coding, however, you can use the ${ctx.link(log_1.setMinLevelOfAllLogs)} function to set the minimum level of logs to be displayed (this works with the ${ctx.link(log_2.FlowrLogger)} abstraction).
62
+ In general, you can configure the levels of individual logs, such as the general \`log\` (obtained with ${ctx.link('getActiveLog')}) or the ${ctx.link('parseLog')}.
63
+ Please note that flowR makes no guarantees that log outputs are persistent across versions, and it is up to the implementors to provide sensible logging.
64
+ If you are an implementor and want to add logging, please make sure there are no larger runtime implications when logging is disabled.
65
+ Have a look at the ${ctx.link(log_2.expensiveTrace)} function for example, which uses a function to generate the log message only when the log level is reached.
55
66
  `)
56
67
  .addFaq('How to run *tests* with *verbose* logging?', `
57
68
  Use the dedicated npm script to run all tests with trace-level log output:
@@ -482,7 +482,7 @@ function implSnippet(node, program, showName = true, nesting = 0, open = false,
482
482
  text = ' ' + text;
483
483
  }
484
484
  if (showImplSnippet) {
485
- const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
485
+ const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName)).trim();
486
486
  text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
487
487
  }
488
488
  else {