@eagleoutice/flowr 2.13.3 → 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 (176) hide show
  1. package/README.md +32 -32
  2. package/abstract-interpretation/absint-visitor.js +2 -2
  3. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
  4. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +1 -1
  5. package/abstract-interpretation/unsupported-functions.js +1 -1
  6. package/cli/repl/core.js +10 -2
  7. package/config.d.ts +4 -1
  8. package/config.js +10 -1
  9. package/control-flow/cfg-dead-code.js +91 -15
  10. package/control-flow/extract-cfg.js +93 -8
  11. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  12. package/dataflow/environments/built-in-config.d.ts +6 -3
  13. package/dataflow/environments/built-in-eval-name.d.ts +20 -0
  14. package/dataflow/environments/built-in-eval-name.js +25 -0
  15. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  16. package/dataflow/environments/built-in-proc-name.js +4 -0
  17. package/dataflow/environments/built-in-props.d.ts +175 -0
  18. package/dataflow/environments/built-in-props.js +207 -0
  19. package/dataflow/environments/built-in.d.ts +28 -20
  20. package/dataflow/environments/built-in.js +39 -8
  21. package/dataflow/environments/default-builtin-config.d.ts +1094 -86
  22. package/dataflow/environments/default-builtin-config.js +496 -212
  23. package/dataflow/environments/identifier.d.ts +25 -1
  24. package/dataflow/environments/identifier.js +24 -2
  25. package/dataflow/environments/query-fn-props.d.ts +102 -0
  26. package/dataflow/environments/query-fn-props.js +188 -0
  27. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -0
  28. package/dataflow/eval/resolve/alias-tracking.js +12 -2
  29. package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
  30. package/dataflow/eval/resolve/match-arguments.js +77 -0
  31. package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
  32. package/dataflow/eval/resolve/resolve-numbers.js +163 -0
  33. package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
  34. package/dataflow/eval/resolve/resolve-operators.js +115 -0
  35. package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
  36. package/dataflow/eval/resolve/resolve-strings.js +116 -0
  37. package/dataflow/eval/resolve/resolve.d.ts +5 -23
  38. package/dataflow/eval/resolve/resolve.js +56 -87
  39. package/dataflow/fn/higher-order-function.js +3 -3
  40. package/dataflow/fn/recursive-function.js +1 -1
  41. package/dataflow/graph/df-helper.js +1 -1
  42. package/dataflow/graph/vertex.d.ts +32 -25
  43. package/dataflow/graph/vertex.js +40 -36
  44. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
  45. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -4
  46. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +14 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +28 -29
  48. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +41 -48
  49. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +14 -0
  50. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +45 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -1
  52. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -0
  53. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +62 -2
  54. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +63 -16
  55. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +29 -9
  56. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +5 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +35 -0
  58. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
  59. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +2 -0
  61. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +46 -0
  62. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  63. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +3 -1
  64. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
  65. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  66. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +24 -0
  67. package/dataflow/internal/process/functions/process-parameter.js +2 -1
  68. package/documentation/data/faq/faqs.js +11 -0
  69. package/documentation/doc-util/doc-types.js +1 -1
  70. package/documentation/wiki-analyzer.js +75 -0
  71. package/documentation/wiki-core.js +65 -16
  72. package/documentation/wiki-interface.js +3 -0
  73. package/linter/linter-rules.d.ts +10 -11
  74. package/linter/rules/absolute-path.js +1 -1
  75. package/linter/rules/deprecated-functions.js +5 -3
  76. package/linter/rules/function-finder-util.d.ts +2 -2
  77. package/linter/rules/function-finder-util.js +11 -4
  78. package/linter/rules/network-functions.d.ts +25 -5
  79. package/linter/rules/network-functions.js +51 -11
  80. package/linter/rules/no-leaked-credentials.js +1 -1
  81. package/linter/rules/problematic-inputs.d.ts +1 -1
  82. package/linter/rules/problematic-inputs.js +7 -1
  83. package/linter/rules/seeded-randomness.d.ts +5 -8
  84. package/linter/rules/seeded-randomness.js +17 -9
  85. package/linter/rules/undefined-symbol.js +1 -1
  86. package/linter/rules/unused-definition.js +15 -10
  87. package/linter/rules/useless-loop.js +1 -1
  88. package/package.json +3 -2
  89. package/project/cache/flowr-analyzer-cache.d.ts +4 -3
  90. package/project/cache/flowr-analyzer-cache.js +32 -13
  91. package/project/cache/flowr-cache.d.ts +39 -12
  92. package/project/cache/flowr-cache.js +5 -3
  93. package/project/context/flowr-analyzer-context.d.ts +8 -1
  94. package/project/context/flowr-analyzer-context.js +11 -1
  95. package/project/context/flowr-analyzer-dependencies-context.d.ts +4 -2
  96. package/project/context/flowr-analyzer-dependencies-context.js +15 -1
  97. package/project/context/flowr-analyzer-files-context.d.ts +8 -4
  98. package/project/context/flowr-analyzer-files-context.js +20 -1
  99. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
  100. package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
  101. package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
  102. package/project/context/flowr-analyzer-meta-context.js +14 -0
  103. package/project/context/flowr-file.d.ts +25 -3
  104. package/project/context/flowr-file.js +24 -2
  105. package/project/dependency-version-space.d.ts +37 -0
  106. package/project/dependency-version-space.js +118 -26
  107. package/project/flowr-analyzer.d.ts +6 -0
  108. package/project/flowr-analyzer.js +6 -2
  109. package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
  110. package/project/incremental/incremental-parse/edit-computation.js +61 -0
  111. package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
  112. package/project/incremental/incremental-parse/incremental-parse.js +37 -0
  113. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
  114. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
  115. package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
  116. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
  117. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  118. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
  119. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
  120. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
  121. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
  122. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
  123. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +27 -0
  124. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
  125. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
  126. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
  127. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
  128. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
  129. package/project/plugins/plugin-registry.d.ts +4 -4
  130. package/project/plugins/plugin-registry.js +7 -4
  131. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
  132. package/project/sigdb/reader.d.ts +7 -0
  133. package/project/sigdb/reader.js +12 -0
  134. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  135. package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
  136. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
  137. package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
  138. package/queries/catalog/dependencies-query/function-info/read-functions.js +14 -13
  139. package/queries/catalog/dependencies-query/function-info/write-functions.js +28 -36
  140. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
  141. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
  142. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
  143. package/queries/catalog/input-sources-query/input-source-functions.d.ts +9 -10
  144. package/queries/catalog/input-sources-query/input-source-functions.js +23 -394
  145. package/queries/catalog/input-sources-query/input-sources-query-executor.js +11 -6
  146. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
  147. package/queries/catalog/input-sources-query/input-sources-query-format.js +28 -10
  148. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +14 -1
  149. package/queries/catalog/input-sources-query/simple-input-classifier.js +24 -0
  150. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
  151. package/queries/catalog/signature-query/signature-query-executor.js +79 -3
  152. package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
  153. package/queries/catalog/signature-query/signature-query-render.js +21 -3
  154. package/r-bridge/data/data.d.ts +2 -2
  155. package/r-bridge/data/data.js +2 -2
  156. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
  157. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
  158. package/r-bridge/parser.d.ts +11 -1
  159. package/r-bridge/parser.js +7 -4
  160. package/r-bridge/shell-executor.d.ts +1 -0
  161. package/r-bridge/shell-executor.js +1 -0
  162. package/r-bridge/shell.d.ts +1 -0
  163. package/r-bridge/shell.js +1 -0
  164. package/reconstruct/inline/source-inline-map.js +1 -1
  165. package/search/flowr-search-filters.d.ts +1 -6
  166. package/search/flowr-search-filters.js +1 -8
  167. package/search/search-executor/search-enrichers.d.ts +2 -0
  168. package/search/search-executor/search-enrichers.js +29 -12
  169. package/util/mermaid/dfg.js +1 -1
  170. package/util/version.js +1 -1
  171. package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
  172. package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
  173. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
  174. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
  175. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
  176. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropagatedProps = exports.FileInputProps = exports.SigDbInferable = exports.InputProps = exports.ExclusiveCallProps = exports.ImpureProps = exports.CallProp = exports.ArgProp = void 0;
4
+ exports.sigLayout = sigLayout;
5
+ exports.argProp = argProp;
6
+ exports.argsWith = argsWith;
7
+ exports.fnInfoFromSignature = fnInfoFromSignature;
8
+ /**
9
+ * What a single argument of a call is used for, as a bitmask.
10
+ * @see {@link BuiltInFnInfo#sig}
11
+ */
12
+ var ArgProp;
13
+ (function (ArgProp) {
14
+ /** the result is this argument, handed back unchanged, like `x` in `identity(x)`; this is what draws the `Returns` edge */
15
+ ArgProp[ArgProp["Alias"] = 1] = "Alias";
16
+ /** the result is computed from the argument's value, like `x` in `sum(x)` */
17
+ ArgProp[ArgProp["Value"] = 2] = "Value";
18
+ /** only the shape is used (length, dimensions, names, other attributes), like `x` in `nrow(x)` */
19
+ ArgProp[ArgProp["Shape"] = 4] = "Shape";
20
+ /** selects a behavior instead of carrying data, like `na.rm` in `sum(x, na.rm = TRUE)` */
21
+ ArgProp[ArgProp["Flag"] = 8] = "Flag";
22
+ /** names the resource the call reads or writes, like `file` in `write.csv(x, file)` */
23
+ ArgProp[ArgProp["Resource"] = 16] = "Resource";
24
+ /** what it refers to may be modified, like `envir` in `assign(x, v, envir = e)` */
25
+ ArgProp[ArgProp["Written"] = 32] = "Written";
26
+ /** evaluated whenever the call happens, even if the result goes unused, like `x` in `force(x)` */
27
+ ArgProp[ArgProp["Forced"] = 64] = "Forced";
28
+ /** quoted or evaluated in another frame, like `expr` in `quote(expr)` */
29
+ ArgProp[ArgProp["Nse"] = 128] = "Nse";
30
+ /** called as a function, like `FUN` in `lapply(x, FUN)` */
31
+ ArgProp[ArgProp["Callee"] = 256] = "Callee";
32
+ /** only whether it was supplied matters, as with `missing()` */
33
+ ArgProp[ArgProp["Presence"] = 512] = "Presence";
34
+ /**
35
+ * the result is one of this argument's values, like `choices` in `match.arg(arg, choices)`. The bounding
36
+ * argument of a {@link CallProp.Narrows} call; without one such a call yields a value of its own making.
37
+ */
38
+ ArgProp[ArgProp["Bounds"] = 1024] = "Bounds";
39
+ })(ArgProp || (exports.ArgProp = ArgProp = {}));
40
+ /**
41
+ * What the call as a whole does, as a bitmask. The resource bits ({@link CallProp.File} and its neighbors)
42
+ * say where the call gets its data from, which is what {@link InputProps} collects.
43
+ * @see {@link BuiltInFnInfo#props}
44
+ */
45
+ var CallProp;
46
+ (function (CallProp) {
47
+ /** computes a result and nothing else, the positive counterpart of `hasUnknownSideEffects` (excludes {@link ImpureProps}) */
48
+ CallProp[CallProp["Pure"] = 1] = "Pure";
49
+ /**
50
+ * pure on its own, but it runs code it is handed, so whatever that code does happens too.
51
+ * The parameter it runs is marked {@link ArgProp.Callee} or {@link ArgProp.Nse}, as with `lapply(x, f)`.
52
+ */
53
+ CallProp[CallProp["MayPure"] = 2] = "MayPure";
54
+ /** may signal an error, like `stop()` (see {@link SigDbInferable}) */
55
+ CallProp[CallProp["Throws"] = 4] = "Throws";
56
+ /** returns invisibly, so the result is not auto-printed */
57
+ CallProp[CallProp["Invisible"] = 8] = "Invisible";
58
+ /** dispatches on the class of its first argument (S3, S4, or S7) */
59
+ CallProp[CallProp["Generic"] = 16] = "Generic";
60
+ /** a method that is reached by dispatch, like `print.foo` (see {@link SigDbInferable}) */
61
+ CallProp[CallProp["Method"] = 32] = "Method";
62
+ /** binds, rebinds, or removes names outside of its own frame, like `assign` or `library` */
63
+ CallProp[CallProp["Scope"] = 64] = "Scope";
64
+ /** the result may differ between two identical calls for a reason neither `Random` nor `Ambient` covers (see {@link SigDbInferable}) */
65
+ CallProp[CallProp["NonDet"] = 128] = "NonDet";
66
+ /** draws from the random number generator, or sets its state (stated instead of `NonDet`) */
67
+ CallProp[CallProp["Random"] = 256] = "Random";
68
+ /** depends on ambient state like the clock, the locale, environment variables, or global options (stated instead of `NonDet`) */
69
+ CallProp[CallProp["Ambient"] = 512] = "Ambient";
70
+ /** touches the file system */
71
+ CallProp[CallProp["File"] = 1024] = "File";
72
+ /** produces a temporary path; on its own this touches no file system, so a call that also does states `File` too */
73
+ CallProp[CallProp["TempFile"] = 2048] = "TempFile";
74
+ /**
75
+ * always reaches the network, like `curl::curl_download`. Calls that only do so for some arguments, like
76
+ * `read.csv` of a URL, are left to the `network-functions` rule, which decides that per call site.
77
+ */
78
+ CallProp[CallProp["Network"] = 4096] = "Network";
79
+ /** runs a system command */
80
+ CallProp[CallProp["Process"] = 8192] = "Process";
81
+ /** calls native code through the foreign function interface, like `.Call` */
82
+ CallProp[CallProp["Ffi"] = 16384] = "Ffi";
83
+ /** produces a language object, like `quote` or `deparse` */
84
+ CallProp[CallProp["Lang"] = 32768] = "Lang";
85
+ /** asks the user, like `readline` or a file chooser */
86
+ CallProp[CallProp["User"] = 65536] = "User";
87
+ /** draws on a graphics device */
88
+ CallProp[CallProp["Graphics"] = 131072] = "Graphics";
89
+ /** talks to a database */
90
+ CallProp[CallProp["Database"] = 262144] = "Database";
91
+ /** reads the resource its `Resource` arguments name */
92
+ CallProp[CallProp["Reads"] = 524288] = "Reads";
93
+ /** writes the resource its `Resource` arguments name */
94
+ CallProp[CallProp["Writes"] = 1048576] = "Writes";
95
+ /** may emit to standard output, like `print` or a `cat` without a `file`, and follows a `sink` when one is active */
96
+ CallProp[CallProp["Prints"] = 2097152] = "Prints";
97
+ /**
98
+ * the result is bounded no matter what flows in: a count, an index, a logical, or one of the values of the
99
+ * argument marked {@link ArgProp.Bounds}. So nothing an argument carries reaches the result, which is what
100
+ * lets the input-sources query stop tracing at `length(x)` or `match.arg(arg, choices)`.
101
+ */
102
+ CallProp[CallProp["Narrows"] = 4194304] = "Narrows";
103
+ })(CallProp || (exports.CallProp = CallProp = {}));
104
+ /**
105
+ * The {@link CallProp} bits that state an effect beyond computing a result, so no {@link CallProp.Pure}
106
+ * definition may carry any of them.
107
+ */
108
+ exports.ImpureProps = CallProp.MayPure | CallProp.Scope | CallProp.NonDet | CallProp.Random | CallProp.Ambient
109
+ | CallProp.File | CallProp.TempFile | CallProp.Network | CallProp.Process | CallProp.Ffi | CallProp.Lang
110
+ | CallProp.User | CallProp.Graphics | CallProp.Database | CallProp.Reads | CallProp.Writes | CallProp.Prints;
111
+ /**
112
+ * Which {@link CallProp} bits rule each other out, as `[bit, everything stating it forbids]`. A definition
113
+ * that carries the left bit must carry none of the right ones; a test checks the {@link DefaultBuiltinConfig}
114
+ * (and any configured built-ins) against this. Every other pair of bits combines freely.
115
+ */
116
+ exports.ExclusiveCallProps = [
117
+ [CallProp.Pure, exports.ImpureProps],
118
+ [CallProp.NonDet, CallProp.Random | CallProp.Ambient],
119
+ [CallProp.Random, CallProp.Ambient]
120
+ ];
121
+ /**
122
+ * The {@link CallProp} bits of calls that bring in data of their own. A function that states its props and
123
+ * carries none of these derives its result from its arguments, which is what {@link BuiltInIndex#without}
124
+ * looks for.
125
+ */
126
+ exports.InputProps = CallProp.NonDet | CallProp.Random | CallProp.Ambient | CallProp.File
127
+ | CallProp.TempFile | CallProp.Network | CallProp.Process | CallProp.Ffi | CallProp.Lang | CallProp.User;
128
+ /**
129
+ * The {@link CallProp} bits the signature database states itself, so {@link fnInfoFromSignature} can read them
130
+ * off any package function without anyone writing them down.
131
+ */
132
+ exports.SigDbInferable = CallProp.Throws | CallProp.NonDet | CallProp.Method | CallProp.Generic;
133
+ /**
134
+ * The {@link CallProp} bits that say a call takes its data from a file, as {@link CallProp.File} alone also
135
+ * covers the calls that only write one.
136
+ */
137
+ exports.FileInputProps = CallProp.File | CallProp.Reads;
138
+ /**
139
+ * The {@link CallProp} bits that carry over from a callee to its caller: what the called function does, the
140
+ * calling one does too. Purity does not travel this way, which is why it is not in here.
141
+ */
142
+ exports.PropagatedProps = CallProp.Throws | CallProp.Scope | CallProp.NonDet | CallProp.Prints
143
+ | CallProp.Random | CallProp.Ambient | CallProp.File | CallProp.TempFile | CallProp.Network | CallProp.Process
144
+ | CallProp.Ffi | CallProp.Lang | CallProp.User | CallProp.Graphics | CallProp.Database | CallProp.Reads | CallProp.Writes;
145
+ const layouts = new WeakMap();
146
+ /**
147
+ * The positional view of a {@link FnSig}, computed on first use and cached per signature object,
148
+ * so declaring a signature costs nothing until a call actually needs it.
149
+ */
150
+ function sigLayout(sig) {
151
+ let layout = layouts.get(sig);
152
+ if (layout === undefined) {
153
+ const props = sig.map(p => p[1]);
154
+ layout = {
155
+ props,
156
+ rest: sig.findIndex(p => p[0] === '...'),
157
+ any: props.reduce((acc, p) => acc | p, 0),
158
+ alias: props.findIndex(p => (p & ArgProp.Alias) !== 0)
159
+ };
160
+ layouts.set(sig, layout);
161
+ }
162
+ return layout;
163
+ }
164
+ /** The {@link ArgProp} bits of the argument at `index`, with `...` covering every position from where it appears. */
165
+ function argProp({ props, rest }, index) {
166
+ return (rest >= 0 && index >= rest ? props[rest] : props[index]) ?? 0;
167
+ }
168
+ /** The positions of the first `count` arguments that carry any of `prop`. */
169
+ function argsWith(layout, count, prop) {
170
+ const found = [];
171
+ for (let i = 0; i < count; i++) {
172
+ if ((argProp(layout, i) & prop) !== 0) {
173
+ found.push(i);
174
+ }
175
+ }
176
+ return found;
177
+ }
178
+ /** the {@link DecodedFunction#props} names that have a {@link CallProp} counterpart, together {@link SigDbInferable} */
179
+ const SigDbProps = {
180
+ 'can-throw': CallProp.Throws,
181
+ 'non-deterministic': CallProp.NonDet,
182
+ 's3-method': CallProp.Method
183
+ };
184
+ /** the callees that make the calling function itself a generic ({@link CallProp.Generic}) */
185
+ const DispatchCallees = new Set(['UseMethod', 'standardGeneric', 'S7_dispatch']);
186
+ /**
187
+ * The part of a {@link BuiltInFnInfo} that the signature database already knows: the parameter names in order
188
+ * (`...` included) with the ones R always forces, plus the properties listed in {@link SigDbProps}. Everything
189
+ * else the database records (`higher-order`, `deprecated`, `recursive`, ...) has no counterpart here and is
190
+ * dropped, and anything it cannot see (purity, resources, what an argument is used for) stays unset.
191
+ */
192
+ function fnInfoFromSignature(fn) {
193
+ let props = 0;
194
+ for (const name of fn.props) {
195
+ props |= SigDbProps[name] ?? 0;
196
+ }
197
+ /* a function whose own body dispatches is the generic, which no property of the database states */
198
+ if (fn.callees.some(c => DispatchCallees.has(c))) {
199
+ props |= CallProp.Generic;
200
+ }
201
+ return {
202
+ sig: fn.signature.map(p => [p.name,
203
+ (p.forced ? ArgProp.Forced : 0) | (p.default === 'TRUE' || p.default === 'FALSE' ? ArgProp.Flag : 0)]),
204
+ props
205
+ };
206
+ }
207
+ //# sourceMappingURL=built-in-props.js.map
@@ -15,7 +15,7 @@ import { processQuote } from '../internal/process/functions/call/built-in/built-
15
15
  import { processFunctionDefinition } from '../internal/process/functions/call/built-in/built-in-function-definition';
16
16
  import { processExpressionList } from '../internal/process/functions/call/built-in/built-in-expression-list';
17
17
  import { processGet } from '../internal/process/functions/call/built-in/built-in-get';
18
- import type { AstIdMap, ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
18
+ import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
19
19
  import { type PotentiallyEmptyRArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
20
20
  import { RSymbol } from '../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
21
21
  import { type BuiltIn, NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
@@ -28,13 +28,14 @@ import { processList } from '../internal/process/functions/call/built-in/built-i
28
28
  import { processVector } from '../internal/process/functions/call/built-in/built-in-vector';
29
29
  import { processRm } from '../internal/process/functions/call/built-in/built-in-rm';
30
30
  import { processEvalCall } from '../internal/process/functions/call/built-in/built-in-eval';
31
- import type { REnvironmentInformation } from './environment';
32
31
  import type { Value } from '../eval/values/r-value';
33
- import { resolveAsMinus, resolveAsPlus, resolveAsSeq, resolveAsVector } from '../eval/resolve/resolve';
34
- import type { DataflowGraph } from '../graph/graph';
32
+ import type { ResolveInfo } from '../eval/resolve/alias-tracking';
33
+ import { resolveAsSeq, resolveAsVector } from '../eval/resolve/resolve';
34
+ import { resolveAsStringFn } from '../eval/resolve/resolve-strings';
35
+ import { resolveAsComparison, resolveAsGroup, resolveAsLogical } from '../eval/resolve/resolve-operators';
36
+ import { resolveAsNumeric } from '../eval/resolve/resolve-numbers';
35
37
  import type { VariableResolve } from '../../config';
36
38
  import type { BuiltInConstantDefinition, BuiltInDefinition, BuiltInFunctionDefinition, BuiltInReplacementDefinition } from './built-in-config';
37
- import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
38
39
  import { processStopIfNot } from '../internal/process/functions/call/built-in/built-in-stop-if-not';
39
40
  import { processTryCatch } from '../internal/process/functions/call/built-in/built-in-try-catch';
40
41
  import { processRegisterHook } from '../internal/process/functions/call/built-in/built-in-register-hook';
@@ -46,11 +47,13 @@ import { processS7Dispatch } from '../internal/process/functions/call/built-in/b
46
47
  import { BuiltInProcName } from './built-in-proc-name';
47
48
  import { processPurrrFormula } from '../internal/process/functions/call/built-in/built-in-purrr-formula';
48
49
  import { processNewEnv } from '../internal/process/functions/call/built-in/built-in-new-env';
50
+ import { processClassGenerator } from '../internal/process/functions/call/built-in/built-in-class-generator';
49
51
  import { processStackEnv } from '../internal/process/functions/call/built-in/built-in-stack-env';
50
52
  import { processAttach } from '../internal/process/functions/call/built-in/built-in-attach';
51
53
  import { processWithEnv } from '../internal/process/functions/call/built-in/built-in-with';
52
54
  import { processNamespaceAccess } from '../internal/process/functions/call/built-in/built-in-namespace-access';
53
55
  import { processLoadCall } from '../internal/process/functions/call/built-in/built-in-load';
56
+ import { type BuiltInFnInfo } from './built-in-props';
54
57
  export type BuiltInIdentifierProcessor = <OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>) => DataflowInformation;
55
58
  export type BuiltInIdentifierProcessorWithConfig<Config> = <OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: Config) => DataflowInformation;
56
59
  export interface BuiltInIdentifierDefinition extends IdentifierReference {
@@ -60,14 +63,15 @@ export interface BuiltInIdentifierDefinition extends IdentifierReference {
60
63
  config?: ConfigOfBuiltInMappingName<keyof typeof BuiltInProcessorMapper> & {
61
64
  libFn?: boolean;
62
65
  };
66
+ /** folds a call to this function to a constant, see {@link BuiltInEvalHandlerMapper} */
67
+ evalHandler?: BuiltInEvalHandler;
63
68
  }
64
69
  export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierReference {
65
70
  type: ReferenceType.BuiltInConstant;
66
71
  definedAt: BuiltIn;
67
72
  value: T;
68
73
  }
69
- export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
70
- readonly returnsNthArgument?: number | 'last';
74
+ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments, BuiltInFnInfo {
71
75
  readonly cfg?: ExitPointType;
72
76
  readonly readAllArguments?: boolean;
73
77
  /**
@@ -79,24 +83,20 @@ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
79
83
  /** record mapping the actual function name called to the arguments that should be treated as function calls */
80
84
  readonly treatAsFnCall?: Record<string, readonly string[]>;
81
85
  /** Mark the given arguments as {@link EdgeType.NonStandardEvaluation|non-standard-evaluated}, like `quote`. */
82
- readonly markArgsAsNSE?: NseArguments;
86
+ readonly markArgsAsNSE?: NseArguments | readonly number[];
83
87
  /**
84
88
  * Name that should be used for the origin (useful when needing to differentiate between
85
89
  * functions like 'return' that use the default builtin processor)
86
90
  */
87
91
  readonly useAsProcessor?: BuiltInProcName;
88
92
  }
89
- export interface BuiltInEvalHandlerArgs {
93
+ /** the {@link ResolveInfo} a handler continues to resolve with, plus the node it is asked to fold */
94
+ export interface BuiltInEvalHandlerArgs extends ResolveInfo {
90
95
  resolve: VariableResolve;
91
96
  node: RNodeWithParent;
92
- ctx: ReadOnlyFlowrAnalyzerContext;
93
- environment?: REnvironmentInformation;
94
- graph?: DataflowGraph;
95
- idMap?: AstIdMap;
96
- blocked?: Set<NodeId>;
97
97
  }
98
98
  export type BuiltInEvalHandler = (args: BuiltInEvalHandlerArgs) => Value;
99
- declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { returnsNthArgument, useAsProcessor, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall, markArgsAsNSE: nse, keepArgumentOut }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
99
+ declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall, markArgsAsNSE: nse, keepArgumentOut, sig }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
100
100
  declare function defaultBuiltInProcessorReadallArgs<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, forceArgs, markArgsAsNSE: nse }: Pick<DefaultBuiltInProcessorConfiguration, 'useAsProcessor' | 'forceArgs' | 'markArgsAsNSE'>): DataflowInformation;
101
101
  export declare const BuiltInProcessorMapper: {
102
102
  readonly "builtin:acc": typeof processAccess;
@@ -135,16 +135,24 @@ export declare const BuiltInProcessorMapper: {
135
135
  readonly "builtin:try": typeof processTryCatch;
136
136
  readonly "builtin:attach": typeof processAttach;
137
137
  readonly "builtin:nenv": typeof processNewEnv;
138
+ readonly "builtin:class-gen": typeof processClassGenerator;
138
139
  readonly "builtin:stack-env": typeof processStackEnv;
139
140
  readonly "builtin:with": typeof processWithEnv;
140
141
  readonly "builtin:vector": typeof processVector;
141
142
  readonly "builtin:wl": typeof processWhileLoop;
142
143
  };
144
+ /**
145
+ * The value-solver function behind every {@link BuiltInEvalName}, the counterpart of the {@link BuiltInProcessorMapper}.
146
+ * A built-in picks one of these by name with its serializable {@link BuiltInFunctionDefinition#evalHandler}.
147
+ */
143
148
  export declare const BuiltInEvalHandlerMapper: {
144
- readonly 'built-in:c': typeof resolveAsVector;
145
- readonly 'built-in::': typeof resolveAsSeq;
146
- readonly 'built-in:+': typeof resolveAsPlus;
147
- readonly 'built-in:-': typeof resolveAsMinus;
149
+ readonly "eval:vector": typeof resolveAsVector;
150
+ readonly "eval:seq": typeof resolveAsSeq;
151
+ readonly "eval:numeric": typeof resolveAsNumeric;
152
+ readonly "eval:cmp": typeof resolveAsComparison;
153
+ readonly "eval:logical": typeof resolveAsLogical;
154
+ readonly "eval:string-fn": typeof resolveAsStringFn;
155
+ readonly "eval:group": typeof resolveAsGroup;
148
156
  };
149
157
  export type ConfigOfBuiltInMappingName<N extends keyof typeof BuiltInProcessorMapper> = Parameters<typeof BuiltInProcessorMapper[N]>[4];
150
158
  export type BuiltInMemory = Map<BrandedIdentifier, IdentifierDefinition[]>;
@@ -156,7 +164,7 @@ export declare class BuiltIns {
156
164
  /**
157
165
  * Register a built-in function (like `print` or `c`) to the given {@link BuiltIns}
158
166
  */
159
- registerBuiltInFunctions<BuiltInProcessor extends keyof typeof BuiltInProcessorMapper>({ names, processor, config, assumePrimitive }: BuiltInFunctionDefinition<BuiltInProcessor>): void;
167
+ registerBuiltInFunctions<BuiltInProcessor extends keyof typeof BuiltInProcessorMapper>({ names, processor, config, assumePrimitive, evalHandler }: BuiltInFunctionDefinition<BuiltInProcessor>): void;
160
168
  /**
161
169
  * Registers all combinations of replacements
162
170
  */
@@ -31,6 +31,10 @@ const built_in_eval_1 = require("../internal/process/functions/call/built-in/bui
31
31
  const vertex_1 = require("../graph/vertex");
32
32
  const unknown_side_effect_1 = require("../graph/unknown-side-effect");
33
33
  const resolve_1 = require("../eval/resolve/resolve");
34
+ const resolve_strings_1 = require("../eval/resolve/resolve-strings");
35
+ const resolve_operators_1 = require("../eval/resolve/resolve-operators");
36
+ const resolve_numbers_1 = require("../eval/resolve/resolve-numbers");
37
+ const built_in_eval_name_1 = require("./built-in-eval-name");
34
38
  const built_in_stop_if_not_1 = require("../internal/process/functions/call/built-in/built-in-stop-if-not");
35
39
  const built_in_try_catch_1 = require("../internal/process/functions/call/built-in/built-in-try-catch");
36
40
  const built_in_register_hook_1 = require("../internal/process/functions/call/built-in/built-in-register-hook");
@@ -43,12 +47,20 @@ const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
43
47
  const built_in_proc_name_1 = require("./built-in-proc-name");
44
48
  const built_in_purrr_formula_1 = require("../internal/process/functions/call/built-in/built-in-purrr-formula");
45
49
  const built_in_new_env_1 = require("../internal/process/functions/call/built-in/built-in-new-env");
50
+ const built_in_class_generator_1 = require("../internal/process/functions/call/built-in/built-in-class-generator");
46
51
  const built_in_stack_env_1 = require("../internal/process/functions/call/built-in/built-in-stack-env");
47
52
  const built_in_attach_1 = require("../internal/process/functions/call/built-in/built-in-attach");
48
53
  const built_in_with_1 = require("../internal/process/functions/call/built-in/built-in-with");
49
54
  const built_in_namespace_access_1 = require("../internal/process/functions/call/built-in/built-in-namespace-access");
50
55
  const built_in_load_1 = require("../internal/process/functions/call/built-in/built-in-load");
51
- function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument, useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall, markArgsAsNSE: nse, keepArgumentOut }) {
56
+ const built_in_props_1 = require("./built-in-props");
57
+ function defaultBuiltInProcessor(name, args, rootId, data, { useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall, markArgsAsNSE: nse, keepArgumentOut, sig }) {
58
+ /* a signature states per argument what the individual options state for all of them at once */
59
+ const layout = sig !== undefined ? (0, built_in_props_1.sigLayout)(sig) : undefined;
60
+ if (layout !== undefined) {
61
+ forceArgs ??= (layout.any & built_in_props_1.ArgProp.Forced) !== 0 ? args.map((_, i) => ((0, built_in_props_1.argProp)(layout, i) & built_in_props_1.ArgProp.Forced) !== 0) : undefined;
62
+ nse ??= (layout.any & built_in_props_1.ArgProp.Nse) !== 0 ? (0, built_in_props_1.argsWith)(layout, args.length, built_in_props_1.ArgProp.Nse) : undefined;
63
+ }
52
64
  const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs, origin: useAsProcessor });
53
65
  if (nse !== undefined) {
54
66
  (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(res.graph, rootId, processedArguments, nse);
@@ -56,8 +68,8 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
56
68
  if (keepArgumentOut) {
57
69
  res.out = [...res.out, ...processedArguments.flatMap(arg => arg?.out ?? [])];
58
70
  }
59
- if (returnsNthArgument !== undefined) {
60
- const arg = returnsNthArgument === 'last' ? processedArguments.at(-1) : processedArguments[returnsNthArgument];
71
+ if (layout !== undefined && layout.alias >= 0) {
72
+ const arg = processedArguments[layout.alias];
61
73
  if (arg !== undefined) {
62
74
  res.graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.Returns);
63
75
  }
@@ -69,6 +81,14 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
69
81
  }
70
82
  }
71
83
  }
84
+ else if (layout !== undefined && (layout.any & (built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Shape)) !== 0) {
85
+ for (const i of (0, built_in_props_1.argsWith)(layout, processedArguments.length, built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Shape)) {
86
+ const arg = processedArguments[i];
87
+ if (arg) {
88
+ res.graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.Reads);
89
+ }
90
+ }
91
+ }
72
92
  if (hasUnknownSideEffects) {
73
93
  if (typeof hasUnknownSideEffects === 'boolean') {
74
94
  (0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId);
@@ -163,16 +183,24 @@ exports.BuiltInProcessorMapper = {
163
183
  [built_in_proc_name_1.BuiltInProcName.Try]: built_in_try_catch_1.processTryCatch,
164
184
  [built_in_proc_name_1.BuiltInProcName.Attach]: built_in_attach_1.processAttach,
165
185
  [built_in_proc_name_1.BuiltInProcName.NewEnv]: built_in_new_env_1.processNewEnv,
186
+ [built_in_proc_name_1.BuiltInProcName.ClassGenerator]: built_in_class_generator_1.processClassGenerator,
166
187
  [built_in_proc_name_1.BuiltInProcName.StackEnv]: built_in_stack_env_1.processStackEnv,
167
188
  [built_in_proc_name_1.BuiltInProcName.With]: built_in_with_1.processWithEnv,
168
189
  [built_in_proc_name_1.BuiltInProcName.Vector]: built_in_vector_1.processVector,
169
190
  [built_in_proc_name_1.BuiltInProcName.WhileLoop]: built_in_while_loop_1.processWhileLoop,
170
191
  };
192
+ /**
193
+ * The value-solver function behind every {@link BuiltInEvalName}, the counterpart of the {@link BuiltInProcessorMapper}.
194
+ * A built-in picks one of these by name with its serializable {@link BuiltInFunctionDefinition#evalHandler}.
195
+ */
171
196
  exports.BuiltInEvalHandlerMapper = {
172
- 'built-in:c': resolve_1.resolveAsVector,
173
- 'built-in::': resolve_1.resolveAsSeq,
174
- 'built-in:+': resolve_1.resolveAsPlus,
175
- 'built-in:-': resolve_1.resolveAsMinus
197
+ [built_in_eval_name_1.BuiltInEvalName.Vector]: resolve_1.resolveAsVector,
198
+ [built_in_eval_name_1.BuiltInEvalName.Seq]: resolve_1.resolveAsSeq,
199
+ [built_in_eval_name_1.BuiltInEvalName.Numeric]: resolve_numbers_1.resolveAsNumeric,
200
+ [built_in_eval_name_1.BuiltInEvalName.Comparison]: resolve_operators_1.resolveAsComparison,
201
+ [built_in_eval_name_1.BuiltInEvalName.Logical]: resolve_operators_1.resolveAsLogical,
202
+ [built_in_eval_name_1.BuiltInEvalName.StringFn]: resolve_strings_1.resolveAsStringFn,
203
+ [built_in_eval_name_1.BuiltInEvalName.Group]: resolve_operators_1.resolveAsGroup
176
204
  };
177
205
  class BuiltIns {
178
206
  /**
@@ -196,10 +224,12 @@ class BuiltIns {
196
224
  /**
197
225
  * Register a built-in function (like `print` or `c`) to the given {@link BuiltIns}
198
226
  */
199
- registerBuiltInFunctions({ names, processor, config, assumePrimitive }) {
227
+ registerBuiltInFunctions({ names, processor, config, assumePrimitive, evalHandler }) {
200
228
  (0, assert_1.guard)(processor !== undefined, () => `Processor for ${JSON.stringify(names)} is undefined, maybe you have an import loop? You may run 'npm run detect-circular-deps' - although by far not all are bad`);
201
229
  const mappedProcessor = exports.BuiltInProcessorMapper[processor];
202
230
  (0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(exports.BuiltInProcessorMapper))}!`);
231
+ const mappedEval = evalHandler === undefined ? undefined : exports.BuiltInEvalHandlerMapper[evalHandler];
232
+ (0, assert_1.guard)(evalHandler === undefined || mappedEval !== undefined, () => `Eval handler ${evalHandler} is unknown! Please pass a valid one of ${JSON.stringify(Object.keys(exports.BuiltInEvalHandlerMapper))}!`);
203
233
  for (const name of names) {
204
234
  const n = identifier_1.Identifier.getName(name);
205
235
  const id = node_id_1.NodeId.toBuiltIn(n);
@@ -210,6 +240,7 @@ class BuiltIns {
210
240
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument */
211
241
  processor: (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config),
212
242
  config,
243
+ evalHandler: mappedEval,
213
244
  name,
214
245
  nodeId: id
215
246
  }];