@eagleoutice/flowr 2.10.8 → 2.10.10

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 (260) hide show
  1. package/README.md +106 -36
  2. package/abstract-interpretation/absint-visitor.js +6 -3
  3. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
  4. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  5. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  6. package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
  7. package/abstract-interpretation/domains/interval-domain.js +1 -1
  8. package/abstract-interpretation/domains/lattice.d.ts +1 -1
  9. package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
  10. package/abstract-interpretation/domains/partial-product-domain.js +2 -2
  11. package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
  12. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  13. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
  14. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  15. package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
  16. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  17. package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
  18. package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
  19. package/abstract-interpretation/unsupported-functions.d.ts +3 -2
  20. package/abstract-interpretation/unsupported-functions.js +38 -28
  21. package/cli/benchmark-app.js +2 -1
  22. package/cli/common/script.js +3 -2
  23. package/cli/flowr.js +47 -10
  24. package/cli/repl/commands/repl-cfg.js +9 -9
  25. package/cli/repl/commands/repl-commands.js +5 -0
  26. package/cli/repl/commands/repl-dataflow.js +31 -24
  27. package/cli/repl/commands/repl-main.d.ts +6 -0
  28. package/cli/repl/commands/repl-normalize.js +15 -12
  29. package/cli/repl/commands/repl-parse.js +1 -1
  30. package/cli/repl/commands/repl-query.js +4 -5
  31. package/cli/repl/commands/repl-quit.js +2 -1
  32. package/cli/repl/core.d.ts +11 -0
  33. package/cli/repl/core.js +101 -3
  34. package/cli/repl/execute.js +3 -2
  35. package/cli/repl/parser/slice-query-parser.d.ts +16 -0
  36. package/cli/repl/parser/slice-query-parser.js +52 -0
  37. package/cli/repl/server/connection.d.ts +1 -0
  38. package/cli/repl/server/connection.js +25 -0
  39. package/cli/repl/server/messages/message-analysis.d.ts +10 -0
  40. package/cli/repl/server/messages/message-analysis.js +6 -2
  41. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  42. package/cli/script-core/statistics-core.js +2 -1
  43. package/cli/script-core/statistics-helper-core.js +2 -1
  44. package/cli/wiki.d.ts +2 -1
  45. package/cli/wiki.js +4 -1
  46. package/config.d.ts +9 -0
  47. package/config.js +23 -1
  48. package/control-flow/diff-cfg.d.ts +1 -1
  49. package/control-flow/diff-cfg.js +1 -1
  50. package/control-flow/extract-cfg.js +9 -3
  51. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  52. package/control-flow/simple-visitor.js +6 -5
  53. package/control-flow/useless-loop.js +2 -2
  54. package/core/print/dataflow-printer.d.ts +2 -2
  55. package/core/print/dataflow-printer.js +2 -2
  56. package/core/steps/all/static-slicing/00-slice.js +1 -1
  57. package/core/steps/pipeline/default-pipelines.d.ts +146 -146
  58. package/dataflow/environments/append.d.ts +2 -1
  59. package/dataflow/environments/append.js +2 -1
  60. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  61. package/dataflow/environments/built-in-proc-name.js +2 -0
  62. package/dataflow/environments/built-in.d.ts +2 -0
  63. package/dataflow/environments/built-in.js +2 -0
  64. package/dataflow/environments/default-builtin-config.d.ts +122 -66
  65. package/dataflow/environments/default-builtin-config.js +324 -145
  66. package/dataflow/environments/environment.d.ts +2 -1
  67. package/dataflow/environments/environment.js +13 -9
  68. package/dataflow/environments/identifier.d.ts +55 -2
  69. package/dataflow/environments/identifier.js +14 -2
  70. package/dataflow/environments/reference-to-maybe.d.ts +2 -0
  71. package/dataflow/environments/reference-to-maybe.js +56 -11
  72. package/dataflow/environments/resolve-by-name.js +13 -7
  73. package/dataflow/eval/values/general.js +4 -0
  74. package/dataflow/extractor.js +22 -3
  75. package/dataflow/graph/df-helper.d.ts +6 -0
  76. package/dataflow/graph/df-helper.js +33 -0
  77. package/dataflow/graph/graph.js +7 -3
  78. package/dataflow/info.d.ts +1 -1
  79. package/dataflow/info.js +3 -1
  80. package/dataflow/internal/linker.d.ts +5 -1
  81. package/dataflow/internal/linker.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
  83. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
  84. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
  87. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  88. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
  89. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -0
  91. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  92. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
  93. package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
  94. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  95. package/dataflow/origin/dfg-get-origin.js +1 -1
  96. package/dataflow/processor.d.ts +6 -0
  97. package/documentation/data/faq/faqs.d.ts +2 -1
  98. package/documentation/data/faq/faqs.js +75 -57
  99. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  100. package/documentation/data/server/doc-data-server-messages.js +15 -7
  101. package/documentation/doc-readme.js +15 -15
  102. package/documentation/doc-util/doc-cfg.d.ts +3 -1
  103. package/documentation/doc-util/doc-cfg.js +3 -3
  104. package/documentation/doc-util/doc-dfg.d.ts +3 -1
  105. package/documentation/doc-util/doc-dfg.js +3 -3
  106. package/documentation/doc-util/doc-files.d.ts +3 -1
  107. package/documentation/doc-util/doc-files.js +9 -6
  108. package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
  109. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  110. package/documentation/doc-util/doc-query.d.ts +2 -1
  111. package/documentation/doc-util/doc-query.js +2 -2
  112. package/documentation/doc-util/doc-repl.js +1 -0
  113. package/documentation/doc-util/doc-types.d.ts +6 -6
  114. package/documentation/doc-util/doc-types.js +11 -9
  115. package/documentation/issue-linting-rule.js +1 -2
  116. package/documentation/wiki-analyzer.js +9 -9
  117. package/documentation/wiki-cfg.js +40 -41
  118. package/documentation/wiki-core.js +119 -31
  119. package/documentation/wiki-create-linting-rules.d.ts +6 -0
  120. package/documentation/wiki-create-linting-rules.js +95 -0
  121. package/documentation/wiki-dataflow-graph.js +77 -76
  122. package/documentation/wiki-engine.js +1 -2
  123. package/documentation/wiki-faq.d.ts +2 -1
  124. package/documentation/wiki-faq.js +4 -4
  125. package/documentation/wiki-interface.js +19 -6
  126. package/documentation/wiki-linter.d.ts +1 -1
  127. package/documentation/wiki-linter.js +14 -6
  128. package/documentation/wiki-linting-and-testing.js +2 -2
  129. package/documentation/wiki-mk/doc-context.d.ts +3 -3
  130. package/documentation/wiki-mk/doc-maker.d.ts +2 -0
  131. package/documentation/wiki-mk/doc-maker.js +7 -1
  132. package/documentation/wiki-normalized-ast.js +5 -5
  133. package/documentation/wiki-onboarding.d.ts +2 -1
  134. package/documentation/wiki-onboarding.js +5 -5
  135. package/documentation/wiki-overview.js +3 -3
  136. package/documentation/wiki-query.js +85 -84
  137. package/documentation/wiki-search.js +4 -5
  138. package/documentation/wiki-setup.js +6 -7
  139. package/gas.d.ts +74 -0
  140. package/gas.js +18 -0
  141. package/linter/linter-executor.js +2 -8
  142. package/linter/linter-format.d.ts +4 -11
  143. package/linter/linter-rules.d.ts +88 -86
  144. package/linter/linter-rules.js +7 -1
  145. package/linter/rules/absolute-path.d.ts +2 -7
  146. package/linter/rules/absolute-path.js +6 -4
  147. package/linter/rules/dataframe-access-validation.d.ts +1 -6
  148. package/linter/rules/dataframe-access-validation.js +8 -6
  149. package/linter/rules/dead-code.d.ts +2 -11
  150. package/linter/rules/dead-code.js +16 -11
  151. package/linter/rules/deprecated-functions.d.ts +3 -3
  152. package/linter/rules/file-path-validity.d.ts +1 -6
  153. package/linter/rules/file-path-validity.js +5 -5
  154. package/linter/rules/function-finder-util.d.ts +7 -11
  155. package/linter/rules/function-finder-util.js +9 -6
  156. package/linter/rules/naming-convention.d.ts +2 -7
  157. package/linter/rules/naming-convention.js +3 -2
  158. package/linter/rules/network-functions.d.ts +2 -7
  159. package/linter/rules/network-functions.js +14 -12
  160. package/linter/rules/no-leaked-credentials.d.ts +36 -0
  161. package/linter/rules/no-leaked-credentials.js +75 -0
  162. package/linter/rules/problematic-inputs.d.ts +1 -8
  163. package/linter/rules/problematic-inputs.js +5 -4
  164. package/linter/rules/roxygen-arguments.d.ts +2 -7
  165. package/linter/rules/roxygen-arguments.js +13 -20
  166. package/linter/rules/seeded-randomness.d.ts +2 -7
  167. package/linter/rules/seeded-randomness.js +7 -4
  168. package/linter/rules/software-has-license.d.ts +31 -0
  169. package/linter/rules/software-has-license.js +46 -0
  170. package/linter/rules/software-has-tests.d.ts +38 -0
  171. package/linter/rules/software-has-tests.js +48 -0
  172. package/linter/rules/stop-with-call-arg.d.ts +2 -7
  173. package/linter/rules/stop-with-call-arg.js +3 -2
  174. package/linter/rules/unused-definition.d.ts +3 -8
  175. package/linter/rules/unused-definition.js +7 -5
  176. package/linter/rules/useless-loop.d.ts +2 -7
  177. package/linter/rules/useless-loop.js +5 -2
  178. package/package.json +3 -2
  179. package/project/context/flowr-analyzer-context.d.ts +13 -14
  180. package/project/context/flowr-analyzer-context.js +4 -0
  181. package/project/context/flowr-analyzer-files-context.d.ts +12 -0
  182. package/project/context/flowr-analyzer-files-context.js +12 -2
  183. package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
  184. package/project/context/flowr-analyzer-gas-context.js +101 -0
  185. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
  186. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
  187. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  188. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
  189. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
  190. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
  191. package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
  192. package/project/plugins/flowr-analyzer-plugin.js +14 -7
  193. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
  194. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
  195. package/project/plugins/plugin-registry.d.ts +2 -1
  196. package/project/plugins/plugin-registry.js +3 -1
  197. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
  198. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
  199. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
  200. package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
  201. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
  202. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  203. package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
  204. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  205. package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
  206. package/queries/catalog/dice-query/dice-query-executor.js +52 -0
  207. package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
  208. package/queries/catalog/dice-query/dice-query-format.js +102 -0
  209. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  210. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
  211. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
  212. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
  213. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
  214. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
  215. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
  216. package/queries/catalog/linter-query/linter-query-executor.js +7 -0
  217. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
  218. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  219. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  220. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  221. package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
  222. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  223. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
  224. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  225. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  226. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  227. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  228. package/queries/query.d.ts +18 -1
  229. package/queries/query.js +3 -1
  230. package/r-bridge/data/data.d.ts +5 -0
  231. package/r-bridge/data/data.js +6 -0
  232. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
  233. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
  234. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
  235. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  236. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
  237. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  238. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +63 -44
  239. package/r-bridge/parser.js +2 -9
  240. package/r-bridge/shell.d.ts +8 -1
  241. package/r-bridge/shell.js +26 -7
  242. package/search/flowr-search-builder.d.ts +2 -2
  243. package/search/flowr-search-builder.js +1 -1
  244. package/search/flowr-search-filters.d.ts +30 -9
  245. package/search/flowr-search-filters.js +26 -21
  246. package/search/search-executor/search-enrichers.d.ts +600 -0
  247. package/search/search-executor/search-enrichers.js +23 -2
  248. package/slicing/static/static-slicer.d.ts +39 -11
  249. package/slicing/static/static-slicer.js +44 -14
  250. package/util/collections/queue.d.ts +16 -0
  251. package/util/collections/queue.js +38 -0
  252. package/util/log.d.ts +1 -1
  253. package/util/log.js +1 -1
  254. package/util/mermaid/dfg.d.ts +2 -2
  255. package/util/mermaid/dfg.js +2 -2
  256. package/util/objects.d.ts +9 -0
  257. package/util/objects.js +57 -1
  258. package/util/proc.d.ts +6 -0
  259. package/util/proc.js +20 -0
  260. package/util/version.js +1 -1
package/cli/repl/core.js CHANGED
@@ -36,9 +36,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.watchProtocol = void 0;
39
40
  exports.replCompleter = replCompleter;
40
41
  exports.makeDefaultReplReadline = makeDefaultReplReadline;
41
42
  exports.handleString = handleString;
43
+ exports.toFileStatement = toFileStatement;
44
+ exports.extractWatchPath = extractWatchPath;
45
+ exports.stopWatching = stopWatching;
46
+ exports.startWatching = startWatching;
42
47
  exports.replProcessAnswer = replProcessAnswer;
43
48
  exports.repl = repl;
44
49
  exports.loadReplHistory = loadReplHistory;
@@ -62,6 +67,7 @@ const log_1 = require("../../util/log");
62
67
  const query_1 = require("../../queries/query");
63
68
  const strings_1 = require("../../util/text/strings");
64
69
  const instrument_dataflow_count_1 = require("../../dataflow/instrument/instrument-dataflow-count");
70
+ const proc_1 = require("../../util/proc");
65
71
  let _replCompleterKeywords = undefined;
66
72
  function replCompleterKeywords() {
67
73
  if (_replCompleterKeywords === undefined) {
@@ -98,8 +104,8 @@ function replCompleter(line, config) {
98
104
  completions = completions.concat(queryCompletions);
99
105
  }
100
106
  else {
101
- // autocomplete command arguments (specifically, autocomplete the file:// protocol)
102
107
  completions.push(retriever_1.fileProtocol);
108
+ completions.push(exports.watchProtocol);
103
109
  }
104
110
  return [completions.filter(a => a.startsWith(currentArg)), currentArg];
105
111
  }
@@ -145,7 +151,46 @@ function handleString(code) {
145
151
  remaining: []
146
152
  };
147
153
  }
148
- async function replProcessStatement(output, statement, analyzer, allowRSessionAccess) {
154
+ /** Path prefix that activates watch mode; use instead of {@link fileProtocol} to re-run on every file change. */
155
+ exports.watchProtocol = 'watch://';
156
+ /** Convert a statement containing {@link watchProtocol} into one using {@link fileProtocol} so it can be executed. */
157
+ function toFileStatement(statement) {
158
+ return statement.replaceAll(exports.watchProtocol, retriever_1.fileProtocol);
159
+ }
160
+ /** Return the watch path from the first `watch://<path>` token in `statement`, or `undefined` if none is present. */
161
+ function extractWatchPath(statement) {
162
+ return /watch:\/\/(\S+)/.exec(statement)?.[1];
163
+ }
164
+ let activeWatcher;
165
+ /** Stop the active watcher. Pass `notify = false` when silently switching to a new watch target. */
166
+ function stopWatching(output, notify = true) {
167
+ if (activeWatcher !== undefined) {
168
+ try {
169
+ activeWatcher.close();
170
+ }
171
+ catch { /* already closed */ }
172
+ activeWatcher = undefined;
173
+ if (notify) {
174
+ output.stdout('Watch mode stopped.');
175
+ }
176
+ }
177
+ }
178
+ /** `watchImpl` is injectable so tests can pass a fake `fs.watch`. */
179
+ function startWatching(watchPath, output, onFire, watchImpl = fs_1.default.watch) {
180
+ const faint = (s) => output.formatter.format(s, { style: 2 /* FontStyles.Faint */ });
181
+ const isDir = fs_1.default.existsSync(watchPath) && fs_1.default.statSync(watchPath).isDirectory();
182
+ let debounce;
183
+ const watcher = watchImpl(watchPath, { recursive: isDir }, () => {
184
+ clearTimeout(debounce);
185
+ debounce = setTimeout(() => {
186
+ output.stdout(faint(`\nChange detected in '${watchPath}', re-running...`));
187
+ onFire();
188
+ }, 50);
189
+ });
190
+ output.stdout(faint(`Watching ${isDir ? 'folder' : 'file'} '${watchPath}'. Press Ctrl+C or enter another command to stop.`));
191
+ return watcher;
192
+ }
193
+ async function executeStatement(output, statement, analyzer, allowRSessionAccess) {
149
194
  const time = Date.now();
150
195
  const heatMap = new Map();
151
196
  if (analyzer.inspectContext().config.repl.dfProcessorHeat) {
@@ -224,6 +269,31 @@ async function replProcessStatement(output, statement, analyzer, allowRSessionAc
224
269
  }
225
270
  }
226
271
  }
272
+ async function replProcessStatement(output, statement, analyzer, allowRSessionAccess) {
273
+ stopWatching(output, !statement.includes(exports.watchProtocol));
274
+ if (statement.includes(exports.watchProtocol)) {
275
+ const watchPath = extractWatchPath(statement);
276
+ const effective = toFileStatement(statement);
277
+ await executeStatement(output, effective, analyzer, allowRSessionAccess);
278
+ if (watchPath) {
279
+ try {
280
+ activeWatcher = startWatching(watchPath, output, () => {
281
+ void executeStatement(output, effective, analyzer, allowRSessionAccess);
282
+ });
283
+ activeWatcher.unref();
284
+ activeWatcher.on('error', (err) => {
285
+ output.stderr(`Watch error for '${watchPath}': ${err.message}`);
286
+ stopWatching(output, false);
287
+ });
288
+ }
289
+ catch (e) {
290
+ output.stderr(`Cannot watch '${watchPath}': ${e.message}`);
291
+ }
292
+ }
293
+ return;
294
+ }
295
+ await executeStatement(output, statement, analyzer, allowRSessionAccess);
296
+ }
227
297
  /**
228
298
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
229
299
  * @param analyzer - The flowR analyzer to use.
@@ -251,11 +321,39 @@ async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplRea
251
321
  if (historyFile) {
252
322
  rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
253
323
  }
324
+ let sigintCount = 0;
325
+ rl.on('SIGINT', () => {
326
+ process.stdout.write('\n');
327
+ if (activeWatcher !== undefined) {
328
+ stopWatching(output);
329
+ rl.setPrompt((0, prompt_1.prompt)());
330
+ sigintCount = 0;
331
+ }
332
+ else {
333
+ sigintCount++;
334
+ if (sigintCount >= 2) {
335
+ stopWatching(output, false);
336
+ (0, proc_1.exitSafe)(0);
337
+ }
338
+ else {
339
+ output.stdout('(Press Ctrl+C again or type :quit to exit)');
340
+ setTimeout(() => {
341
+ sigintCount = 0;
342
+ }, 2000).unref();
343
+ }
344
+ }
345
+ rl.prompt();
346
+ });
347
+ rl.on('close', () => {
348
+ stopWatching(output, false);
349
+ (0, proc_1.exitSafe)(0);
350
+ });
254
351
  // the incredible repl :D, we kill it with ':quit'
255
352
  // noinspection InfiniteLoopJS
256
353
  while (true) {
257
354
  await new Promise((resolve, reject) => {
258
- rl.question((0, prompt_1.prompt)(), answer => {
355
+ rl.question(activeWatcher !== undefined ? '' : (0, prompt_1.prompt)(), answer => {
356
+ sigintCount = 0;
259
357
  rl.pause();
260
358
  replProcessAnswer(analyzer, output, answer, allowRSessionAccess).then(() => {
261
359
  rl.resume();
@@ -9,6 +9,7 @@ const child_process_1 = __importDefault(require("child_process"));
9
9
  const readline_1 = __importDefault(require("readline"));
10
10
  const assert_1 = require("../../util/assert");
11
11
  const log_1 = require("../../util/log");
12
+ const proc_1 = require("../../util/proc");
12
13
  /**
13
14
  * Simply captures the output of the script executed by {@link waitOnScript}.
14
15
  * @param stdio - The standard io tuple provided by {@link waitOnScript}
@@ -54,14 +55,14 @@ async function waitOnScript(module, args, io, exitOnError = false) {
54
55
  if (code) {
55
56
  console.error(`Script ${module} exited with code ${String(code)} and signal ${JSON.stringify(signal)}`);
56
57
  if (exitOnError) {
57
- process.exit(code);
58
+ (0, proc_1.exitSafe)(code);
58
59
  }
59
60
  }
60
61
  });
61
62
  child.on('error', err => {
62
63
  console.error(`Script ${module} signaled error ${JSON.stringify(err)}`);
63
64
  if (exitOnError) {
64
- process.exit(1);
65
+ (0, proc_1.exitSafe)(1);
65
66
  }
66
67
  });
67
68
  await new Promise((resolve, reject) => child.on('exit', code => {
@@ -1,5 +1,7 @@
1
1
  import type { SlicingCriterion, SlicingCriteria } from '../../../slicing/criterion/parse';
2
2
  import { SliceDirection } from '../../../util/slice-direction';
3
+ import type { CommandCompletions } from '../core';
4
+ import type { FlowrConfig } from '../../../config';
3
5
  /**
4
6
  * Checks whether the given argument represents a slicing direction with an `f` suffix.
5
7
  */
@@ -12,3 +14,17 @@ export declare function sliceCriterionParser(argument: string | undefined): Slic
12
14
  * Parses multiple slicing criteria from the given argument.
13
15
  */
14
16
  export declare function sliceCriteriaParser(argument: string | undefined): SlicingCriteria | undefined;
17
+ /**
18
+ * Tab-completer for query arguments of the form `(line@var;line@var;...)`.
19
+ * Guides the user step by step: `(` then digits then `@` then variable then `)`.
20
+ */
21
+ export declare function criteriaQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
22
+ /**
23
+ * Parses a dice argument of the form `(from1;from2->to1;to2)`.
24
+ * Returns `{ from, to }` on success, or `undefined` if the argument is malformed.
25
+ * Each side is a semicolon-separated list of slicing criteria; a single criterion needs no semicolon.
26
+ */
27
+ export declare function diceCriteriaParser(argument: string | undefined): {
28
+ from: SlicingCriteria;
29
+ to: SlicingCriteria;
30
+ } | undefined;
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sliceDirectionParser = sliceDirectionParser;
4
4
  exports.sliceCriterionParser = sliceCriterionParser;
5
5
  exports.sliceCriteriaParser = sliceCriteriaParser;
6
+ exports.criteriaQueryCompleter = criteriaQueryCompleter;
7
+ exports.diceCriteriaParser = diceCriteriaParser;
6
8
  const slice_direction_1 = require("../../../util/slice-direction");
7
9
  /**
8
10
  * Checks whether the given argument represents a slicing direction with an `f` suffix.
@@ -31,4 +33,54 @@ function sliceCriteriaParser(argument) {
31
33
  return criteria;
32
34
  }
33
35
  }
36
+ /** Last partial criterion fragment after the most recent `;` or after `(`. */
37
+ function lastCriterionFragment(arg) {
38
+ return arg.slice(Math.max(arg.indexOf('(') + 1, arg.lastIndexOf(';') + 1));
39
+ }
40
+ /**
41
+ * Tab-completer for query arguments of the form `(line@var;line@var;...)`.
42
+ * Guides the user step by step: `(` then digits then `@` then variable then `)`.
43
+ */
44
+ function criteriaQueryCompleter(line, startingNewArg, _config) {
45
+ if (line.length === 0) {
46
+ return { completions: ['('] };
47
+ }
48
+ if (startingNewArg || line.length !== 1) {
49
+ return { completions: [] };
50
+ }
51
+ const arg = line[0];
52
+ if (arg.endsWith(')') || arg.endsWith(')f')) {
53
+ return { completions: [] };
54
+ }
55
+ const fragment = lastCriterionFragment(arg);
56
+ if (/^\d+$/.test(fragment)) {
57
+ return { completions: [`${arg}@`], argumentPart: arg };
58
+ }
59
+ if (/^\d+@\w+$/.test(fragment)) {
60
+ return { completions: [`${arg})`], argumentPart: arg };
61
+ }
62
+ return { completions: [] };
63
+ }
64
+ /**
65
+ * Parses a dice argument of the form `(from1;from2->to1;to2)`.
66
+ * Returns `{ from, to }` on success, or `undefined` if the argument is malformed.
67
+ * Each side is a semicolon-separated list of slicing criteria; a single criterion needs no semicolon.
68
+ */
69
+ function diceCriteriaParser(argument) {
70
+ if (!argument?.startsWith('(') || !argument.includes(')')) {
71
+ return undefined;
72
+ }
73
+ const endBracket = argument.indexOf(')');
74
+ const inner = argument.slice(1, endBracket);
75
+ const arrowIdx = inner.indexOf('->');
76
+ if (arrowIdx < 0) {
77
+ return undefined;
78
+ }
79
+ const from = inner.slice(0, arrowIdx).split(';').filter(s => s.length > 0);
80
+ const to = inner.slice(arrowIdx + 2).split(';').filter(s => s.length > 0);
81
+ if (from.length === 0 || to.length === 0) {
82
+ return undefined;
83
+ }
84
+ return { from, to };
85
+ }
34
86
  //# sourceMappingURL=slice-query-parser.js.map
@@ -23,6 +23,7 @@ export declare class FlowRServerConnection {
23
23
  private currentMessageBuffer;
24
24
  private handleData;
25
25
  private handleFileAnalysisRequest;
26
+ private invalidateTokens;
26
27
  private sendFileAnalysisResponse;
27
28
  private createAnalyzerForRequest;
28
29
  private handleSliceRequest;
@@ -135,6 +135,16 @@ class FlowRServerConnection {
135
135
  }
136
136
  const message = requestResult.message;
137
137
  this.logger.info(`[${this.name}] Received file analysis request for ${message.filename ?? 'unknown file'}${message.filetoken ? ' with token: ' + message.filetoken : ''}`);
138
+ if (message.content === undefined && message.filepath === undefined) {
139
+ (0, send_1.sendMessage)(this.socket, {
140
+ type: 'response-file-analysis',
141
+ format: 'json',
142
+ id: message.id,
143
+ results: {}
144
+ });
145
+ this.invalidateTokens(message.invalidateToken);
146
+ return;
147
+ }
138
148
  if (message.filetoken && this.fileMap.has(message.filetoken)) {
139
149
  this.logger.warn(`File token ${message.filetoken} already exists. Overwriting.`);
140
150
  // explicitly delete the previous store
@@ -156,6 +166,21 @@ class FlowRServerConnection {
156
166
  }
157
167
  // this is an interestingly named function that means "I am a callback that removes a file" - so this deletes the file
158
168
  tempFile.removeCallback();
169
+ this.invalidateTokens(message.invalidateToken);
170
+ }
171
+ invalidateTokens(invalidateToken) {
172
+ if (!invalidateToken) {
173
+ return;
174
+ }
175
+ const tokens = typeof invalidateToken === 'string' ? [invalidateToken] : invalidateToken;
176
+ for (const token of tokens) {
177
+ if (this.fileMap.delete(token)) {
178
+ this.logger.info(`[${this.name}] Invalidated file token ${token}`);
179
+ }
180
+ else {
181
+ this.logger.warn(`[${this.name}] Cannot invalidate unknown file token ${token}`);
182
+ }
183
+ }
159
184
  }
160
185
  async sendFileAnalysisResponse(analyzer, message) {
161
186
  let cfg = undefined;
@@ -34,6 +34,16 @@ export interface FileAnalysisRequestMessage extends IdMessageBase {
34
34
  cfg?: boolean;
35
35
  /** Controls the serialization of the `results` (and the {@link ControlFlowGraph} if the corresponding flag is set). If missing, we assume _json_. */
36
36
  format?: 'compact' | 'json' | 'n-quads';
37
+ /**
38
+ * One or more previously stored file tokens that the server should drop after it has answered this request.
39
+ * Use this to free the memory of analyses you no longer need.
40
+ *
41
+ * You may send a request that contains _only_ this field (without `content` or `filepath`) to drop tokens
42
+ * without performing a new analysis. In that case the server answers with an empty `results` object.
43
+ * As the tokens are dropped only after the response, you may also pass the request's own `filetoken` here to
44
+ * analyze a file once and have the server forget it immediately afterward.
45
+ */
46
+ invalidateToken?: string | readonly string[];
37
47
  }
38
48
  export declare const requestAnalysisMessage: MessageDefinition<FileAnalysisRequestMessage>;
39
49
  /**
@@ -15,8 +15,12 @@ exports.requestAnalysisMessage = {
15
15
  content: joi_1.default.string().optional().description('The content of the file or an R expression (either give this or the filepath).'),
16
16
  filepath: joi_1.default.alternatives(joi_1.default.string(), joi_1.default.array().items(joi_1.default.string())).optional().description('The path to the file(s) on the local machine (either give this or the content).'),
17
17
  cfg: joi_1.default.boolean().optional().description('If you want to extract the control flow information of the file.'),
18
- format: joi_1.default.string().valid('json', 'n-quads', 'compact').optional().description('The format of the results, if missing we assume json.')
19
- }).xor('content', 'filepath')
18
+ format: joi_1.default.string().valid('json', 'n-quads', 'compact').optional().description('The format of the results, if missing we assume json.'),
19
+ invalidateToken: joi_1.default.alternatives(joi_1.default.string(), joi_1.default.array().items(joi_1.default.string())).optional().description('One or more file tokens to drop from the server store after this request has been answered.')
20
+ }).when(joi_1.default.object({ invalidateToken: joi_1.default.exist() }).unknown(), {
21
+ then: joi_1.default.object().oxor('content', 'filepath'),
22
+ otherwise: joi_1.default.object().xor('content', 'filepath')
23
+ })
20
24
  };
21
25
  const jsonSchema = joi_1.default.object({
22
26
  type: joi_1.default.string().valid('response-file-analysis').required().description('The type of the message.'),
@@ -23,7 +23,7 @@ export interface SliceRequestMessage extends IdMessageBase {
23
23
  }
24
24
  export declare const requestSliceMessage: MessageDefinition<SliceRequestMessage>;
25
25
  /**
26
- * Similar to {@link FileAnalysisResponseMessage} this only contains the results of
26
+ * Similar to {@link FileAnalysisResponseMessageJson} this only contains the results of
27
27
  * the slice steps.
28
28
  */
29
29
  export interface SliceResponseMessage extends IdMessageBase {
@@ -16,6 +16,7 @@ const statistics_helper_core_1 = require("./statistics-helper-core");
16
16
  const command_line_args_1 = __importDefault(require("command-line-args"));
17
17
  const scripts_info_1 = require("../common/scripts-info");
18
18
  const ansi_1 = require("../../util/text/ansi");
19
+ const proc_1 = require("../../util/proc");
19
20
  const testRegex = /[^/]*\/test/i;
20
21
  const exampleRegex = /[^/]*\/example/i;
21
22
  function getPrefixForFile(file) {
@@ -63,7 +64,7 @@ async function collectFileArguments(options, verboseAdd, dumpJson, features) {
63
64
  async function flowrScriptGetStats(options, config) {
64
65
  if (options.input.length === 0) {
65
66
  console.error('No input files given. Nothing to do. See \'--help\' if this is an error.');
66
- process.exit(0);
67
+ return (0, proc_1.exitSafe)(0);
67
68
  }
68
69
  if (options['no-ansi']) {
69
70
  log_1.log.info('disabling ansi colors');
@@ -21,6 +21,7 @@ const time_1 = require("../../util/text/time");
21
21
  const tar_1 = require("tar");
22
22
  const ansi_1 = require("../../util/text/ansi");
23
23
  const config_1 = require("../../config");
24
+ const proc_1 = require("../../util/proc");
24
25
  const flowr_analyzer_context_1 = require("../../project/context/flowr-analyzer-context");
25
26
  function compressFolder(folder, target) {
26
27
  return (0, tar_1.create)({
@@ -50,7 +51,7 @@ async function getStatsForSingleFile(options, config) {
50
51
  target = (0, features_1.retrieveArchiveName)(options['output-dir']);
51
52
  if (fs_1.default.existsSync(target)) {
52
53
  console.log(`Archive ${target} exists. Skip.`);
53
- process.exit(0);
54
+ return (0, proc_1.exitSafe)(0);
54
55
  }
55
56
  }
56
57
  // assume correct
package/cli/wiki.d.ts CHANGED
@@ -9,7 +9,8 @@ import { WikiLinter } from '../documentation/wiki-linter';
9
9
  import { WikiSetup } from '../documentation/wiki-setup';
10
10
  import { WikiOverview } from '../documentation/wiki-overview';
11
11
  import { WikiAbsint } from '../documentation/wiki-absint';
12
- export declare const AllWikiDocuments: [WikiFaq, WikiSearch, WikiCfg, WikiQuery, WikiOnboarding, WikiAnalyzer, WikiEngine, WikiNormalizedAst, WikiCore, WikiSetup, WikiOverview, WikiInterface, WikiDataflowGraph, WikiLintingAndTesting, WikiLinter, WikiAbsint, IssueLintingRule, DocReadme, DocCapabilities];
12
+ import { WikiCreateLintingRules } from '../documentation/wiki-create-linting-rules';
13
+ export declare const AllWikiDocuments: [WikiFaq, WikiSearch, WikiCfg, WikiQuery, WikiOnboarding, WikiAnalyzer, WikiEngine, WikiNormalizedAst, WikiCore, WikiSetup, WikiOverview, WikiInterface, WikiDataflowGraph, WikiLintingAndTesting, WikiLinter, WikiAbsint, WikiCreateLintingRules, IssueLintingRule, DocReadme, DocCapabilities];
13
14
  export type ValidWikiDocumentTargets = ReturnType<typeof AllWikiDocuments[number]['getTarget']>;
14
15
  export type ValidWikiDocumentTargetsNoSuffix = ValidWikiDocumentTargets extends `${infer Name}.${string}` ? Name : never;
15
16
  /**
package/cli/wiki.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AllWikiDocuments = void 0;
7
7
  exports.makeAllWikis = makeAllWikis;
8
+ const proc_1 = require("../util/proc");
8
9
  const doc_context_1 = require("../documentation/wiki-mk/doc-context");
9
10
  const shell_1 = require("../r-bridge/shell");
10
11
  const tree_sitter_executor_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor");
@@ -26,6 +27,7 @@ const os_1 = __importDefault(require("os"));
26
27
  const wiki_setup_1 = require("../documentation/wiki-setup");
27
28
  const wiki_overview_1 = require("../documentation/wiki-overview");
28
29
  const wiki_absint_1 = require("../documentation/wiki-absint");
30
+ const wiki_create_linting_rules_1 = require("../documentation/wiki-create-linting-rules");
29
31
  exports.AllWikiDocuments = [
30
32
  new wiki_faq_1.WikiFaq(),
31
33
  new documentation_1.WikiSearch(),
@@ -43,6 +45,7 @@ exports.AllWikiDocuments = [
43
45
  new documentation_1.WikiLintingAndTesting(),
44
46
  new wiki_linter_1.WikiLinter(),
45
47
  new wiki_absint_1.WikiAbsint(),
48
+ new wiki_create_linting_rules_1.WikiCreateLintingRules(),
46
49
  new issue_linting_rule_1.IssueLintingRule(),
47
50
  new doc_readme_1.DocReadme(),
48
51
  new documentation_1.DocCapabilities()
@@ -159,7 +162,7 @@ if (require.main === module) {
159
162
  }
160
163
  void makeAllWikis(options.force, options.filter).catch(err => {
161
164
  console.error('Error while generating wikis:', err);
162
- process.exit(1);
165
+ (0, proc_1.exitSafe)(1);
163
166
  }).then(() => {
164
167
  if (options['keep-alive']) {
165
168
  console.log('Wiki generator running in keep-alive mode...');
package/config.d.ts CHANGED
@@ -7,6 +7,7 @@ import type { DataflowProcessors } from './dataflow/processor';
7
7
  import type { ParentInformation } from './r-bridge/lang-4.x/ast/model/processing/decorate';
8
8
  import type { FlowrAnalyzerContext } from './project/context/flowr-analyzer-context';
9
9
  import type { BuiltInFlowrPluginArgs, BuiltInFlowrPluginName } from './project/plugins/plugin-registry';
10
+ import { type FlowrGasConfig } from './gas';
10
11
  export declare enum VariableResolve {
11
12
  /** Don't resolve constants at all */
12
13
  Disabled = "disabled",
@@ -208,6 +209,14 @@ export interface FlowrConfig extends MergeableRecord {
208
209
  };
209
210
  };
210
211
  };
212
+ /**
213
+ * Resource-usage guard (gas) configuration.
214
+ * Gas checks are disabled by default (all feature factors are `0`).
215
+ * Set a `feature factor > 0` to enable checking for that feature.
216
+ * @see {@link FlowrGasConfig}
217
+ * @see {@link ReadOnlyFlowrAnalyzerGasContext}
218
+ */
219
+ readonly gas: FlowrGasConfig;
211
220
  }
212
221
  export type ValidFlowrConfigPaths = Paths<FlowrConfig, {
213
222
  depth: 9;
package/config.js CHANGED
@@ -11,6 +11,7 @@ const log_1 = require("./util/log");
11
11
  const files_1 = require("./util/files");
12
12
  const joi_1 = __importDefault(require("joi"));
13
13
  const object_path_1 = __importDefault(require("object-path"));
14
+ const gas_1 = require("./gas");
14
15
  var VariableResolve;
15
16
  (function (VariableResolve) {
16
17
  /** Don't resolve constants at all */
@@ -124,6 +125,13 @@ exports.FlowrConfig = {
124
125
  maxReadLines: 1e6
125
126
  }
126
127
  }
128
+ },
129
+ gas: {
130
+ thresholds: {
131
+ memory: { problematic: 0.7, critical: 0.9 },
132
+ timeMs: { problematic: 100_000, critical: 120_000 }
133
+ },
134
+ features: {}
127
135
  }
128
136
  };
129
137
  },
@@ -188,7 +196,21 @@ exports.FlowrConfig = {
188
196
  maxReadLines: joi_1.default.number().min(1).description('The maximum number of lines to read when extracting data frame shapes from loaded files, such as CSV files.')
189
197
  }).description('Configuration options for reading data frame shapes from loaded external data files, such as CSV files.')
190
198
  }).description('The configuration of the shape inference for data frames.')
191
- }).description('The configuration options for abstract interpretation.')
199
+ }).description('The configuration options for abstract interpretation.'),
200
+ gas: joi_1.default.object({
201
+ thresholds: joi_1.default.object({
202
+ memory: joi_1.default.object({
203
+ problematic: joi_1.default.number().min(0).max(1).optional().description('Heap fraction (0-1) above which Problematic is returned.'),
204
+ critical: joi_1.default.number().min(0).max(1).optional().description('Heap fraction (0-1) above which Critical is returned.')
205
+ }).optional().description('Heap-usage fraction thresholds (0-1).'),
206
+ timeMs: joi_1.default.object({
207
+ problematic: joi_1.default.number().min(0).optional().description('Elapsed ms above which Problematic is returned.'),
208
+ critical: joi_1.default.number().min(0).optional().description('Elapsed ms above which Critical is returned.')
209
+ }).optional().description('Elapsed analysis time thresholds in milliseconds.')
210
+ }).optional().description('Shared thresholds for all gas checks (scaled by per-feature factor).'),
211
+ features: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.number().min(0).optional()).optional().description('Per-feature sensitivity factors. 0 or absent disables gas checking for that feature. A factor of 2 makes the feature twice as sensitive. Recognised keys: `source`, `side-effect-linking`, `linter`.'),
212
+ heapProvider: joi_1.default.function().optional().description('Custom heap statistics source (programmatic configs only), overriding the built-in v8/performance.memory detection.')
213
+ }).optional().description(`Resource-usage guard (gas) configuration. All feature factors default to 0 (disabled). See ${gas_1.GasWikiRef}.`)
192
214
  }).description('The configuration file format for flowR.'),
193
215
  /**
194
216
  * Parses the given JSON string as a flowR config file, returning the resulting config object if the parsing and validation were successful, or `undefined` if there was an error.
@@ -4,6 +4,6 @@ import { type ControlFlowGraph } from './control-flow-graph';
4
4
  /**
5
5
  * Compare two control flow graphs and return a report on the differences.
6
6
  * If you simply want to check whether they equal, use {@link GraphDifferenceReport#isEqual|`<result>.isEqual()`}.
7
- * @see {@link diffOfDataflowGraphs} - for dataflow graphs
7
+ * @see {@link diffDataflowGraph} - for dataflow graphs
8
8
  */
9
9
  export declare function diffOfControlFlowGraphs(left: NamedGraph<ControlFlowGraph>, right: NamedGraph<ControlFlowGraph>, config?: Partial<GenericDiffConfiguration>): GraphDifferenceReport;
@@ -9,7 +9,7 @@ const arrays_1 = require("../util/collections/arrays");
9
9
  /**
10
10
  * Compare two control flow graphs and return a report on the differences.
11
11
  * If you simply want to check whether they equal, use {@link GraphDifferenceReport#isEqual|`<result>.isEqual()`}.
12
- * @see {@link diffOfDataflowGraphs} - for dataflow graphs
12
+ * @see {@link diffDataflowGraph} - for dataflow graphs
13
13
  */
14
14
  function diffOfControlFlowGraphs(left, right, config) {
15
15
  if (left.graph === right.graph) {
@@ -549,9 +549,15 @@ function cfgExprList(node, _grouping, expressions) {
549
549
  }
550
550
  }
551
551
  result.graph.mergeWith(expression.graph);
552
- result.breaks.push(...expression.breaks);
553
- result.nexts.push(...expression.nexts);
554
- result.returns.push(...expression.returns);
552
+ for (const b of expression.breaks) {
553
+ result.breaks.push(b);
554
+ }
555
+ for (const n of expression.nexts) {
556
+ result.nexts.push(n);
557
+ }
558
+ for (const r of expression.returns) {
559
+ result.returns.push(r);
560
+ }
555
561
  result.exitPoints = expression.exitPoints;
556
562
  }
557
563
  const exitId = control_flow_graph_1.CfgVertex.toExitId(nodeId);
@@ -253,6 +253,7 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
253
253
  return this.onRecallCall({ call });
254
254
  case built_in_proc_name_1.BuiltInProcName.PurrrFormula:
255
255
  return this.onPurrFormulaCall({ call });
256
+ case built_in_proc_name_1.BuiltInProcName.NamespaceAccess:
256
257
  case built_in_proc_name_1.BuiltInProcName.NewEnv:
257
258
  case built_in_proc_name_1.BuiltInProcName.With:
258
259
  case built_in_proc_name_1.BuiltInProcName.Attach:
@@ -4,6 +4,7 @@ exports.visitCfgInReverseOrder = visitCfgInReverseOrder;
4
4
  exports.visitCfgInOrder = visitCfgInOrder;
5
5
  exports.canReach = canReach;
6
6
  const control_flow_graph_1 = require("./control-flow-graph");
7
+ const queue_1 = require("../util/collections/queue");
7
8
  /**
8
9
  * Visit all nodes reachable from the start node in the control flow graph, traversing the dependencies but ignoring cycles.
9
10
  * @param graph - The control flow graph.
@@ -58,10 +59,10 @@ function visitCfgInOrder(graph, startNodes,
58
59
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type -- void is used to indicate that the return value is ignored/we never stop
59
60
  visitor) {
60
61
  const visited = new Set();
61
- const queue = startNodes.slice();
62
+ const queue = new queue_1.ArrayQueue(startNodes);
62
63
  const hasBb = graph.mayHaveBasicBlocks();
63
- while (queue.length > 0) {
64
- const current = queue.shift();
64
+ while (!queue.isEmpty()) {
65
+ const current = queue.dequeue();
65
66
  if (visited.has(current)) {
66
67
  continue;
67
68
  }
@@ -74,13 +75,13 @@ visitor) {
74
75
  if (control_flow_graph_1.CfgVertex.isBlock(get)) {
75
76
  const elems = control_flow_graph_1.CfgVertex.getBasicBlockElements(get);
76
77
  for (const e of elems.toReversed()) {
77
- queue.push(control_flow_graph_1.CfgVertex.getId(e));
78
+ queue.enqueue(control_flow_graph_1.CfgVertex.getId(e));
78
79
  }
79
80
  }
80
81
  }
81
82
  const outgoing = graph.ingoingEdges(current) ?? [];
82
83
  for (const [to] of outgoing) {
83
- queue.push(to);
84
+ queue.enqueue(to);
84
85
  }
85
86
  }
86
87
  return visited;
@@ -93,14 +93,14 @@ class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.Seman
93
93
  (0, assert_1.guard)(exits.size !== 0, "Can't find end of loop");
94
94
  const stack = [this.loopToCheck];
95
95
  while (stack.length > 0) {
96
- const current = stack.shift();
96
+ const current = stack.pop();
97
97
  if (!this.visitNode(current)) {
98
98
  continue;
99
99
  }
100
100
  if (!exits.has(current)) {
101
101
  const next = ingoing(current) ?? [];
102
102
  for (const [to] of next) {
103
- stack.unshift(to);
103
+ stack.push(to);
104
104
  }
105
105
  }
106
106
  this.onlyLoopyOnce ||= this.encounteredLoopBreaker && (0, info_1.happensInEveryBranch)(this.loopCds?.filter(c => !c.byIteration));
@@ -5,8 +5,8 @@ export declare function dataflowGraphToJson(df: DataflowInformation): string;
5
5
  /**
6
6
  * Transforms the dataflow graph into a quad serialization.
7
7
  * @see {@link df2quads}
8
- * @see {@link dataflowGraphToMermaidUrl}
9
- * @see {@link dataflowGraphToMermaid}
8
+ * @see {@link DataflowMermaid.url}
9
+ * @see {@link DataflowMermaid.convert}
10
10
  * @see {@link dataflowGraphToJson}
11
11
  */
12
12
  export declare function dataflowGraphToQuads(df: DataflowInformation, config: QuadSerializationConfiguration): string;
@@ -52,8 +52,8 @@ function dataflowGraphToJson(df) {
52
52
  /**
53
53
  * Transforms the dataflow graph into a quad serialization.
54
54
  * @see {@link df2quads}
55
- * @see {@link dataflowGraphToMermaidUrl}
56
- * @see {@link dataflowGraphToMermaid}
55
+ * @see {@link DataflowMermaid.url}
56
+ * @see {@link DataflowMermaid.convert}
57
57
  * @see {@link dataflowGraphToJson}
58
58
  */
59
59
  function dataflowGraphToQuads(df, config) {
@@ -9,7 +9,7 @@ function processor(results, input) {
9
9
  const direction = input.direction ?? slice_direction_1.SliceDirection.Backward;
10
10
  const threshold = input.threshold ?? input.context?.config.solver.slicer?.threshold;
11
11
  const n = results.normalize;
12
- return (0, static_slicer_1.staticSlice)(input.context, results.dataflow, n, parse_1.SlicingCriteria.convertAll(input.criterion, n.idMap), direction, threshold);
12
+ return (0, static_slicer_1.staticSlice)({ ctx: input.context, info: results.dataflow, ast: n, ids: parse_1.SlicingCriteria.convertAll(input.criterion, n.idMap), direction, threshold });
13
13
  }
14
14
  exports.STATIC_SLICE = {
15
15
  name: 'slice',