@eagleoutice/flowr 2.11.1 → 2.12.1

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 (264) hide show
  1. package/README.md +187 -257
  2. package/abstract-interpretation/absint-visitor.d.ts +1 -0
  3. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
  4. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  5. package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
  6. package/benchmark/slicer.d.ts +1 -1
  7. package/benchmark/slicer.js +3 -1
  8. package/benchmark/summarizer/second-phase/graph.js +5 -0
  9. package/cli/common/options.d.ts +8 -0
  10. package/cli/common/options.js +2 -0
  11. package/cli/common/scripts-info.d.ts +8 -0
  12. package/cli/repl/commands/repl-commands.d.ts +1 -0
  13. package/cli/repl/commands/repl-commands.js +66 -15
  14. package/cli/repl/commands/repl-dataflow.js +48 -4
  15. package/cli/repl/commands/repl-main.d.ts +2 -0
  16. package/cli/repl/commands/repl-main.js +5 -0
  17. package/cli/repl/commands/repl-query.d.ts +4 -1
  18. package/cli/repl/commands/repl-query.js +72 -22
  19. package/cli/repl/commands/repl-signature.d.ts +7 -0
  20. package/cli/repl/commands/repl-signature.js +119 -0
  21. package/cli/repl/core.d.ts +8 -1
  22. package/cli/repl/core.js +46 -6
  23. package/cli/repl/ghost-hint.d.ts +37 -0
  24. package/cli/repl/ghost-hint.js +72 -0
  25. package/cli/repl/parser/slice-query-parser.d.ts +11 -1
  26. package/cli/repl/parser/slice-query-parser.js +45 -16
  27. package/cli/repl/print-version.d.ts +2 -4
  28. package/cli/repl/print-version.js +41 -23
  29. package/cli/repl/server/connection.js +19 -17
  30. package/cli/slicer-app.d.ts +2 -0
  31. package/cli/slicer-app.js +3 -3
  32. package/cli/wiki.d.ts +2 -2
  33. package/cli/wiki.js +2 -2
  34. package/config.d.ts +63 -2
  35. package/config.js +64 -8
  36. package/control-flow/cfg-dead-code.js +0 -1
  37. package/control-flow/control-flow-graph.js +6 -6
  38. package/control-flow/diff-cfg.js +2 -2
  39. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  40. package/core/print/slice-diff-ansi.js +8 -8
  41. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  42. package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
  43. package/core/steps/all/static-slicing/00-slice.js +1 -1
  44. package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
  45. package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
  46. package/core/steps/pipeline/default-pipelines.d.ts +20 -16
  47. package/data/r-base-packages.generated.d.ts +44 -0
  48. package/data/r-base-packages.generated.js +32 -0
  49. package/data/r-base-primitives.generated.d.ts +1 -0
  50. package/data/r-base-primitives.generated.js +15 -0
  51. package/data/sigdb/sigdb.remote.json +112 -0
  52. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  53. package/dataflow/environments/built-in-proc-name.js +4 -0
  54. package/dataflow/environments/built-in.d.ts +14 -4
  55. package/dataflow/environments/built-in.js +13 -2
  56. package/dataflow/environments/data-masking-functions.d.ts +12 -0
  57. package/dataflow/environments/data-masking-functions.js +46 -0
  58. package/dataflow/environments/default-builtin-config.d.ts +72 -19
  59. package/dataflow/environments/default-builtin-config.js +48 -14
  60. package/dataflow/environments/diff.js +1 -1
  61. package/dataflow/environments/environment.js +1 -2
  62. package/dataflow/environments/identifier.d.ts +11 -4
  63. package/dataflow/environments/identifier.js +28 -10
  64. package/dataflow/environments/resolve-by-name.js +16 -2
  65. package/dataflow/extractor.js +6 -3
  66. package/dataflow/graph/call-graph.d.ts +2 -2
  67. package/dataflow/graph/df-helper.d.ts +4 -4
  68. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  69. package/dataflow/graph/edge.d.ts +3 -3
  70. package/dataflow/graph/edge.js +3 -3
  71. package/dataflow/graph/graph-helper.d.ts +2 -2
  72. package/dataflow/internal/linker.js +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
  74. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
  77. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
  81. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
  86. package/dataflow/internal/process/functions/call/common.js +8 -1
  87. package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
  90. package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
  91. package/dataflow/internal/process/functions/process-argument.js +12 -1
  92. package/dataflow/internal/process/process-named-call.d.ts +18 -1
  93. package/dataflow/internal/process/process-named-call.js +94 -0
  94. package/dataflow/processor.d.ts +18 -0
  95. package/documentation/data/faq/faqs.js +5 -1
  96. package/documentation/doc-capabilities.js +1 -1
  97. package/documentation/doc-util/doc-cli-option.d.ts +10 -0
  98. package/documentation/doc-util/doc-cli-option.js +23 -0
  99. package/documentation/doc-util/doc-dfg.js +2 -1
  100. package/documentation/doc-util/doc-query.d.ts +9 -3
  101. package/documentation/doc-util/doc-query.js +9 -4
  102. package/documentation/wiki-dataflow-graph.js +8 -5
  103. package/documentation/wiki-interface.js +4 -2
  104. package/documentation/wiki-linter.js +1 -1
  105. package/documentation/wiki-linting-and-testing.js +4 -1
  106. package/documentation/wiki-mk/doc-context.d.ts +14 -0
  107. package/documentation/wiki-mk/doc-context.js +3 -0
  108. package/documentation/wiki-mk/doc-maker.js +3 -1
  109. package/documentation/wiki-query.js +36 -15
  110. package/documentation/wiki-setup.js +10 -7
  111. package/documentation/wiki-signature-database.d.ts +16 -0
  112. package/documentation/wiki-signature-database.js +293 -0
  113. package/linter/linter-format.d.ts +7 -0
  114. package/linter/linter-rules.d.ts +10 -9
  115. package/linter/rules/naming-convention.d.ts +1 -0
  116. package/linter/rules/naming-convention.js +2 -0
  117. package/linter/rules/no-leaked-credentials.js +1 -2
  118. package/linter/rules/roxygen-arguments.js +18 -5
  119. package/linter/rules/stop-with-call-arg.js +2 -2
  120. package/linter/rules/undefined-symbol-util.d.ts +36 -0
  121. package/linter/rules/undefined-symbol-util.js +149 -0
  122. package/linter/rules/undefined-symbol.d.ts +58 -17
  123. package/linter/rules/undefined-symbol.js +143 -33
  124. package/linter/rules/unused-definition.d.ts +8 -1
  125. package/linter/rules/unused-definition.js +126 -1
  126. package/package.json +22 -10
  127. package/project/context/abstract-flowr-analyzer-context.js +7 -1
  128. package/project/context/flowr-analyzer-context.d.ts +8 -0
  129. package/project/context/flowr-analyzer-context.js +10 -0
  130. package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
  131. package/project/context/flowr-analyzer-dependencies-context.js +51 -2
  132. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  133. package/project/context/flowr-analyzer-files-context.js +2 -1
  134. package/project/context/flowr-analyzer-functions-context.js +1 -1
  135. package/project/context/flowr-file.d.ts +5 -0
  136. package/project/context/flowr-file.js +5 -0
  137. package/project/flowr-analyzer-builder.js +12 -2
  138. package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
  139. package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
  140. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
  141. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
  142. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
  147. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
  148. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
  149. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
  150. package/project/plugins/package-version-plugins/package.d.ts +5 -3
  151. package/project/plugins/package-version-plugins/package.js +27 -25
  152. package/project/plugins/plugin-registry.d.ts +3 -2
  153. package/project/plugins/plugin-registry.js +4 -2
  154. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
  155. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
  156. package/project/sigdb/build.d.ts +131 -0
  157. package/project/sigdb/build.js +628 -0
  158. package/project/sigdb/codec.d.ts +51 -0
  159. package/project/sigdb/codec.js +122 -0
  160. package/project/sigdb/decode.d.ts +58 -0
  161. package/project/sigdb/decode.js +129 -0
  162. package/project/sigdb/decompress.d.ts +44 -0
  163. package/project/sigdb/decompress.js +176 -0
  164. package/project/sigdb/hash.d.ts +9 -0
  165. package/project/sigdb/hash.js +54 -0
  166. package/project/sigdb/index-format.d.ts +40 -0
  167. package/project/sigdb/index-format.js +28 -0
  168. package/project/sigdb/manifest.d.ts +68 -0
  169. package/project/sigdb/manifest.js +146 -0
  170. package/project/sigdb/reader.d.ts +250 -0
  171. package/project/sigdb/reader.js +692 -0
  172. package/project/sigdb/schema.d.ts +196 -0
  173. package/project/sigdb/schema.js +33 -0
  174. package/project/sigdb/sigdb-download.d.ts +65 -0
  175. package/project/sigdb/sigdb-download.js +237 -0
  176. package/project/sigdb/signature-match.d.ts +26 -0
  177. package/project/sigdb/signature-match.js +40 -0
  178. package/project/sigdb/version.d.ts +20 -0
  179. package/project/sigdb/version.js +55 -0
  180. package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
  181. package/queries/catalog/absint-query/absint-query-executor.js +63 -0
  182. package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
  183. package/queries/catalog/absint-query/absint-query-format.js +102 -0
  184. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
  185. package/queries/catalog/config-query/config-query-format.d.ts +3 -1
  186. package/queries/catalog/config-query/config-query-format.js +68 -9
  187. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
  188. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  189. package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
  190. package/queries/catalog/linter-query/linter-query-executor.js +6 -1
  191. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
  192. package/queries/catalog/linter-query/linter-query-format.js +40 -8
  193. package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
  194. package/queries/catalog/project-query/project-query-executor.js +96 -4
  195. package/queries/catalog/project-query/project-query-format.d.ts +44 -0
  196. package/queries/catalog/project-query/project-query-format.js +33 -2
  197. package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
  198. package/queries/catalog/signature-query/signature-query-executor.js +461 -0
  199. package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
  200. package/queries/catalog/signature-query/signature-query-format.js +76 -0
  201. package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
  202. package/queries/catalog/signature-query/signature-query-render.js +155 -0
  203. package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
  204. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
  205. package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
  206. package/queries/query-print.js +5 -0
  207. package/queries/query.d.ts +15 -5
  208. package/queries/query.js +7 -4
  209. package/r-bridge/init.js +5 -1
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
  212. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
  213. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
  214. package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
  215. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
  216. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
  217. package/r-bridge/parser.d.ts +2 -0
  218. package/r-bridge/retriever.js +4 -1
  219. package/r-bridge/roxygen2/documentation-provider.js +2 -1
  220. package/r-bridge/shell.d.ts +5 -0
  221. package/r-bridge/shell.js +17 -1
  222. package/reconstruct/inline/source-inline-map.d.ts +48 -0
  223. package/reconstruct/inline/source-inline-map.js +94 -0
  224. package/reconstruct/reconstruct.d.ts +19 -2
  225. package/reconstruct/reconstruct.js +79 -16
  226. package/search/search-executor/search-generators.js +5 -22
  227. package/search/search-executor/search-transformer.js +10 -6
  228. package/slicing/criterion/parse.d.ts +28 -4
  229. package/slicing/criterion/parse.js +133 -18
  230. package/slicing/static/slice-call.d.ts +24 -1
  231. package/slicing/static/slice-call.js +90 -0
  232. package/slicing/static/static-slicer.d.ts +7 -0
  233. package/slicing/static/static-slicer.js +38 -3
  234. package/util/collections/arrays.d.ts +4 -5
  235. package/util/collections/arrays.js +7 -18
  236. package/util/hash.d.ts +14 -0
  237. package/util/hash.js +31 -0
  238. package/util/mermaid/dfg.d.ts +7 -2
  239. package/util/mermaid/dfg.js +53 -13
  240. package/util/r-base-packages.d.ts +19 -0
  241. package/util/r-base-packages.js +72 -0
  242. package/util/r-license.js +2 -10
  243. package/util/r-version.d.ts +45 -15
  244. package/util/r-version.js +97 -36
  245. package/util/range.d.ts +15 -0
  246. package/util/range.js +39 -0
  247. package/util/schema.d.ts +10 -0
  248. package/util/schema.js +22 -0
  249. package/util/text/ansi.d.ts +3 -0
  250. package/util/text/ansi.js +10 -0
  251. package/util/text/args.js +1 -2
  252. package/util/version.js +28 -8
  253. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  254. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  255. package/documentation/wiki-package-database.d.ts +0 -9
  256. package/documentation/wiki-package-database.js +0 -63
  257. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
  258. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
  259. package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
  260. package/project/plugins/package-version-plugins/pkgdb.js +0 -370
  261. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
  262. package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
  263. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
  264. package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
@@ -1,370 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PkgDatabase = exports.PkgDbBuilder = exports.DefaultCranBase = exports.PkgDbSchema = exports.PkgDbMagic = void 0;
7
- exports.cranBlobUrl = cranBlobUrl;
8
- exports.validatePkgDb = validatePkgDb;
9
- exports.defaultPkgDbPath = defaultPkgDbPath;
10
- const fs_1 = __importDefault(require("fs"));
11
- const zlib_1 = __importDefault(require("zlib"));
12
- const path_1 = __importDefault(require("path"));
13
- /*
14
- * Reader/writer for the `flowr-pkgdb` database (schema 4) produced by crawlr's `dump`.
15
- * An export list mixes `strings`-pool indices (number) and inline single-use names.
16
- * latest: pkgs[name] = [version, exported]. all: shares a `lists` pool and stores
17
- * pkgs[name] = [latest, versions, nonCran?] with each version [ver, exported, internal?, deprecated?].
18
- * Optional `all` definition locations: a `files` pool + locs[pkg][id] = [fileIndex, line] (latest only).
19
- * CRAN urls are reconstructed on load. {@link PkgDbBuilder} writes, {@link PkgDatabase} reads - both in flowR.
20
- */
21
- exports.PkgDbMagic = 'flowr-pkgdb';
22
- exports.PkgDbSchema = 4;
23
- exports.DefaultCranBase = 'https://cran.r-project.org/src/contrib/';
24
- /** Reconstruct the CRAN source blob link; the newest non-archived version lives under `src/contrib`, every other under `Archive`. */
25
- function cranBlobUrl(cranBase, pkg, version, opts) {
26
- if (!opts.cran) {
27
- return undefined;
28
- }
29
- const base = cranBase.endsWith('/') ? cranBase : cranBase + '/';
30
- return version === opts.latest && !opts.archived
31
- ? `${base}${pkg}_${version}.tar.gz`
32
- : `${base}Archive/${pkg}/${pkg}_${version}.tar.gz`;
33
- }
34
- /** Validate the structural invariants of a decoded database, throwing a descriptive error on failure. */
35
- function validatePkgDb(o) {
36
- const fail = (msg) => {
37
- throw new Error(`invalid flowr-pkgdb database: ${msg}`);
38
- };
39
- if (typeof o !== 'object' || o === null) {
40
- fail('not an object');
41
- }
42
- const db = o;
43
- if (db.format !== exports.PkgDbMagic) {
44
- fail(`missing/invalid format (expected "${exports.PkgDbMagic}")`);
45
- }
46
- if (db.schema !== exports.PkgDbSchema) {
47
- fail(`unsupported schema version ${String(db.schema)} (expected ${exports.PkgDbSchema})`);
48
- }
49
- if (db.scope !== 'latest' && db.scope !== 'all') {
50
- fail(`invalid scope ${String(db.scope)}`);
51
- }
52
- if (!Array.isArray(db.strings)) {
53
- fail('missing strings pool');
54
- }
55
- if (typeof db.pkgs !== 'object' || db.pkgs === null) {
56
- fail('missing pkgs');
57
- }
58
- if (db.scope === 'all' && !Array.isArray(db.lists)) {
59
- fail('all-scope database is missing the lists pool');
60
- }
61
- if (typeof db.content !== 'object' || db.content === null || typeof db.content.version !== 'number') {
62
- fail('missing/invalid content header');
63
- }
64
- }
65
- /** portable gunzip (Node + browser + VS Code) via the Web Streams API */
66
- async function gunzip(bytes) {
67
- return new Response(new Blob([bytes]).stream().pipeThrough(new DecompressionStream('gzip'))).text();
68
- }
69
- function isGzip(bytes) {
70
- return bytes[0] === 0x1f && bytes[1] === 0x8b;
71
- }
72
- /** richest first: `all` carries every version, `latest`/`tiny` only the current one */
73
- const PkgDbScopeOrder = ['all', 'latest', 'tiny'];
74
- /** layouts a bundled database may sit in, relative to a search root */
75
- const PkgDbSubDirs = ['data/pkgdb', 'src/data/pkgdb', 'dist/src/data/pkgdb'];
76
- /** roots to search for a bundled database; extendable via `$FLOWR_PKGDB_DIR` (path-delimiter separated) */
77
- function pkgDbSearchRoots(extra) {
78
- const roots = [...(extra ?? [])];
79
- const env = typeof process !== 'undefined' ? process.env?.FLOWR_PKGDB_DIR : undefined;
80
- if (env) {
81
- roots.push(...env.split(path_1.default.delimiter).filter(Boolean));
82
- }
83
- if (typeof __dirname !== 'undefined') {
84
- roots.push(__dirname);
85
- }
86
- if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
87
- roots.push(process.cwd());
88
- }
89
- return roots;
90
- }
91
- /**
92
- * Location of a bundled database, found by walking up from several roots (this module,
93
- * `$FLOWR_PKGDB_DIR`, the working directory) across the dev (`src`) and build (`dist`) layouts. With
94
- * no `scope` it returns the richest available tier (brotli, then gzip, then plain json). Node only
95
- * (needs `fs`); pass `searchRoots` to override where it looks.
96
- */
97
- function defaultPkgDbPath(scope, searchRoots) {
98
- if (typeof fs_1.default?.existsSync !== 'function') {
99
- return undefined;
100
- }
101
- const scopes = scope ? [scope] : PkgDbScopeOrder;
102
- for (const root of pkgDbSearchRoots(searchRoots)) {
103
- for (let dir = root, i = 0; i < 10; i++) {
104
- for (const sub of PkgDbSubDirs) {
105
- for (const s of scopes) {
106
- for (const suffix of ['.br', '.gz', '']) {
107
- const candidate = path_1.default.join(dir, sub, `pkgdb-${s}.json${suffix}`);
108
- if (fs_1.default.existsSync(candidate)) {
109
- return candidate;
110
- }
111
- }
112
- }
113
- }
114
- const parent = path_1.default.dirname(dir);
115
- if (parent === dir) {
116
- break;
117
- }
118
- dir = parent;
119
- }
120
- }
121
- return undefined;
122
- }
123
- /** portable non-cryptographic 64-bit hash (cyrb53), hex, for update detection */
124
- function hash53(str) {
125
- let h1 = 0xdeadbeef, h2 = 0x41c6ce57;
126
- for (let i = 0; i < str.length; i++) {
127
- const ch = str.charCodeAt(i);
128
- h1 = Math.imul(h1 ^ ch, 2654435761);
129
- h2 = Math.imul(h2 ^ ch, 1597334677);
130
- }
131
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
132
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
133
- return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
134
- }
135
- /**
136
- * Serializes a {@link PkgDb}. Accumulate per-version exports with {@link addPackage}/{@link addVersion},
137
- * then {@link build} a scope. The multi-use string pool is computed per scope; the `latest` scope may
138
- * be pruned to the most-downloaded packages. This is the counterpart of {@link PkgDatabase} (the reader).
139
- */
140
- class PkgDbBuilder {
141
- raw = new Map();
142
- versionCount = 0;
143
- addPackage(name, opts) {
144
- const p = this.raw.get(name);
145
- if (p) {
146
- p.latest = opts.latest;
147
- p.archived = opts.archived ?? p.archived;
148
- p.downloads = opts.downloads ?? p.downloads;
149
- }
150
- else {
151
- this.raw.set(name, { latest: opts.latest, archived: opts.archived ?? false, downloads: opts.downloads ?? 0, versions: new Map() });
152
- }
153
- }
154
- addVersion(name, version, exports) {
155
- const p = this.raw.get(name) ?? { latest: version, archived: false, downloads: 0, versions: new Map() };
156
- if (!this.raw.has(name)) {
157
- this.raw.set(name, p);
158
- }
159
- p.versions.set(version, exports);
160
- this.versionCount++;
161
- }
162
- relevant(scope, prune) {
163
- if (scope === 'all') {
164
- const out = [];
165
- for (const [name, p] of this.raw) {
166
- for (const [version, ex] of p.versions) {
167
- out.push({ name, version, ex });
168
- }
169
- }
170
- return out;
171
- }
172
- let pkgs = [...this.raw].filter(([, p]) => p.downloads >= prune.minDownloads && p.versions.has(p.latest));
173
- if (prune.topN !== undefined && pkgs.length > prune.topN) {
174
- pkgs = pkgs.sort((a, b) => b[1].downloads - a[1].downloads).slice(0, prune.topN);
175
- }
176
- return pkgs.map(([name, p]) => ({ name, version: p.latest, ex: p.versions.get(p.latest) }));
177
- }
178
- buildPool(relevant, scope) {
179
- const freq = new Map();
180
- for (const { ex } of relevant) {
181
- const names = scope === 'all' ? [...ex.exported, ...ex.internal, ...ex.deprecated] : ex.exported;
182
- for (const name of names) {
183
- freq.set(name, (freq.get(name) ?? 0) + 1);
184
- }
185
- }
186
- const strings = [...freq.entries()].filter(([, c]) => c >= 2).sort((a, b) => b[1] - a[1]).map(([n]) => n);
187
- return { strings, index: new Map(strings.map((n, i) => [n, i])) };
188
- }
189
- build(scope, meta) {
190
- const relevant = this.relevant(scope, { minDownloads: meta.minDownloads ?? 0, topN: meta.topN });
191
- const { strings, index } = this.buildPool(relevant, scope);
192
- const encode = (names) => [...new Set(names)].sort().map(n => index.get(n) ?? n);
193
- const content = {
194
- version: meta.version, date: meta.date, hash: '', generated: meta.generated,
195
- packages: scope === 'latest' ? relevant.length : this.raw.size, versions: this.versionCount
196
- };
197
- const cranBase = meta.cranBase && meta.cranBase !== exports.DefaultCranBase ? meta.cranBase : undefined;
198
- const archived = [];
199
- let db;
200
- if (scope === 'latest') {
201
- const noncran = [];
202
- const pkgs = {};
203
- for (const { name, version, ex } of relevant) {
204
- pkgs[name] = [version, encode(ex.exported)];
205
- if (this.raw.get(name)?.archived) {
206
- archived.push(name);
207
- }
208
- if (!ex.cran) {
209
- noncran.push(name);
210
- }
211
- }
212
- db = { format: exports.PkgDbMagic, schema: exports.PkgDbSchema, scope, content, cranBase, strings, pkgs,
213
- ...(archived.length ? { archived } : {}), ...(noncran.length ? { noncran } : {}) };
214
- }
215
- else {
216
- const lists = [];
217
- const listIndex = new Map();
218
- const internList = (names) => {
219
- const enc = encode(names);
220
- const key = JSON.stringify(enc);
221
- let idx = listIndex.get(key);
222
- if (idx === undefined) {
223
- idx = lists.length;
224
- lists.push(enc);
225
- listIndex.set(key, idx);
226
- }
227
- return idx;
228
- };
229
- internList([]);
230
- const files = [];
231
- const fileIndex = new Map();
232
- const internFile = (f) => {
233
- let idx = fileIndex.get(f);
234
- if (idx === undefined) {
235
- idx = files.length;
236
- files.push(f);
237
- fileIndex.set(f, idx);
238
- }
239
- return idx;
240
- };
241
- const locs = {};
242
- const pkgs = {};
243
- for (const [name, p] of this.raw) {
244
- const versions = [];
245
- const nc = [];
246
- for (const [version, ex] of p.versions) {
247
- const e = internList(ex.exported), i = internList(ex.internal), d = internList(ex.deprecated);
248
- versions.push(d !== 0 ? [version, e, i, d] : i !== 0 ? [version, e, i] : [version, e]);
249
- if (!ex.cran) {
250
- nc.push(version);
251
- }
252
- }
253
- pkgs[name] = nc.length ? [p.latest, versions, nc] : [p.latest, versions];
254
- if (p.archived) {
255
- archived.push(name);
256
- }
257
- // optional: record the latest version's definition locations, if the source carried them
258
- const latestLoc = p.versions.get(p.latest)?.locations;
259
- if (latestLoc && latestLoc.size > 0) {
260
- const entry = {};
261
- for (const [id, [file, line]] of latestLoc) {
262
- entry[id] = [internFile(file), line];
263
- }
264
- locs[name] = entry;
265
- }
266
- }
267
- db = { format: exports.PkgDbMagic, schema: exports.PkgDbSchema, scope, content, cranBase, strings, lists, pkgs,
268
- ...(archived.length ? { archived } : {}),
269
- ...(files.length ? { files, locs } : {}) };
270
- }
271
- return { ...db, content: { ...content, hash: hash53(JSON.stringify(db)) } };
272
- }
273
- }
274
- exports.PkgDbBuilder = PkgDbBuilder;
275
- class PkgDatabase {
276
- db;
277
- archived;
278
- noncran;
279
- constructor(db) {
280
- this.db = db;
281
- this.archived = new Set(db.archived ?? []);
282
- this.noncran = new Set(db.noncran ?? []);
283
- }
284
- get content() {
285
- return this.db.content;
286
- }
287
- get scope() {
288
- return this.db.scope;
289
- }
290
- /** parse an already-loaded object (validates the schema, throwing a descriptive error on failure) */
291
- static fromObject(obj) {
292
- validatePkgDb(obj);
293
- return new PkgDatabase(obj);
294
- }
295
- /** portable async load from raw bytes (gzip auto-detected) */
296
- static async fromBytes(bytes) {
297
- const text = isGzip(bytes) ? await gunzip(bytes) : new TextDecoder().decode(bytes);
298
- return PkgDatabase.fromObject(JSON.parse(text));
299
- }
300
- /** portable async load from a URL (works in Node 18+, browser and VS Code) */
301
- static async fromUrl(url) {
302
- return PkgDatabase.fromBytes(new Uint8Array(await (await fetch(url)).arrayBuffer()));
303
- }
304
- /** synchronous load from a local file (Node only; brotli by `.br`, else gzip auto-detected, else plain) */
305
- static fromFileSync(file) {
306
- const raw = fs_1.default.readFileSync(file);
307
- const bytes = new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength);
308
- const text = file.endsWith('.br') ? zlib_1.default.brotliDecompressSync(raw).toString('utf8')
309
- : isGzip(bytes) ? zlib_1.default.gunzipSync(raw).toString('utf8')
310
- : raw.toString('utf8');
311
- return PkgDatabase.fromObject(JSON.parse(text));
312
- }
313
- has(pkg) {
314
- return this.db.pkgs[pkg] !== undefined;
315
- }
316
- decode(list) {
317
- return (list ?? []).map(x => typeof x === 'number' ? this.db.strings[x] : x);
318
- }
319
- result(pkg, version, latest, cran, exported, internal, deprecated, locations) {
320
- const cranBase = this.db.cranBase ?? exports.DefaultCranBase;
321
- return {
322
- version, exported, internal, deprecated, cran,
323
- cranUrl: cranBlobUrl(cranBase, pkg, version, { latest, archived: this.archived.has(pkg), cran }),
324
- ...(locations ? { locations } : {})
325
- };
326
- }
327
- /** definition locations of the latest version, if the (`all`-scope) database carries them */
328
- locations(pkg) {
329
- if (this.db.scope !== 'all' || !this.db.locs || !this.db.files) {
330
- return undefined;
331
- }
332
- const entry = this.db.locs[pkg];
333
- if (!entry) {
334
- return undefined;
335
- }
336
- const files = this.db.files;
337
- const map = new Map();
338
- for (const id in entry) {
339
- const [fileIdx, line] = entry[id];
340
- map.set(id, { file: files[fileIdx], line });
341
- }
342
- return map;
343
- }
344
- /** look up the identifiers of a package (defaulting to its latest version) */
345
- lookup(pkg, version) {
346
- if (this.db.scope === 'latest') {
347
- const entry = this.db.pkgs[pkg];
348
- if (!entry) {
349
- return undefined;
350
- }
351
- return this.result(pkg, entry[0], entry[0], !this.noncran.has(pkg), this.decode(entry[1]), [], []);
352
- }
353
- const entry = this.db.pkgs[pkg];
354
- if (!entry) {
355
- return undefined;
356
- }
357
- const [latest, versions, nc] = entry;
358
- const vt = (version ? versions.find(v => v[0] === version) : undefined)
359
- ?? versions.find(v => v[0] === latest) ?? versions[versions.length - 1];
360
- if (!vt) {
361
- return undefined;
362
- }
363
- const lists = this.db.lists;
364
- // locations are only stored for the latest version
365
- const locations = vt[0] === latest ? this.locations(pkg) : undefined;
366
- return this.result(pkg, vt[0], latest, !nc?.includes(vt[0]), this.decode(lists[vt[1]]), this.decode(lists[vt[2] ?? 0]), this.decode(lists[vt[3] ?? 0]), locations);
367
- }
368
- }
369
- exports.PkgDatabase = PkgDatabase;
370
- //# sourceMappingURL=pkgdb.js.map
@@ -1,6 +0,0 @@
1
- import type { BasicQueryData } from '../../base-query-format';
2
- import type { DfShapeQuery, DfShapeQueryResult } from './df-shape-query-format';
3
- /**
4
- * Executes the given data frame shape queries using the provided analyzer.
5
- */
6
- export declare function executeDfShapeQuery({ analyzer }: BasicQueryData, queries: readonly DfShapeQuery[]): Promise<DfShapeQueryResult>;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeDfShapeQuery = executeDfShapeQuery;
4
- const shape_inference_1 = require("../../../abstract-interpretation/data-frame/shape-inference");
5
- const cfg_kind_1 = require("../../../project/cfg-kind");
6
- const parse_1 = require("../../../slicing/criterion/parse");
7
- const log_1 = require("../../../util/log");
8
- /**
9
- * Executes the given data frame shape queries using the provided analyzer.
10
- */
11
- async function executeDfShapeQuery({ analyzer }, queries) {
12
- if (queries.length !== 1 && queries.some(query => query.criterion === undefined)) {
13
- log_1.log.warn('The dataframe shape query expects only up to one query without slicing criterion, but got', queries.length);
14
- queries = [{ type: 'df-shape' }];
15
- }
16
- const ast = await analyzer.normalize();
17
- const dfg = (await analyzer.dataflow()).graph;
18
- const cfg = await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
19
- const start = Date.now();
20
- const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg, normalizedAst: ast, ctx: analyzer.inspectContext() });
21
- inference.start();
22
- const domains = inference.getEndState();
23
- if (queries.length === 1 && queries[0].criterion === undefined) {
24
- return {
25
- '.meta': {
26
- timing: Date.now() - start
27
- },
28
- domains: domains
29
- };
30
- }
31
- const result = new Map();
32
- for (const query of queries) {
33
- if (query.criterion === undefined) {
34
- log_1.log.warn('Missing criterion in dataframe shape query');
35
- continue;
36
- }
37
- else if (result.has(query.criterion)) {
38
- log_1.log.warn('Duplicate criterion in dataframe shape query:', query.criterion);
39
- continue;
40
- }
41
- try {
42
- const nodeId = parse_1.SlicingCriterion.parse(query.criterion, ast.idMap);
43
- const node = ast.idMap.get(nodeId);
44
- const value = inference.getAbstractValue(node?.info.id);
45
- result.set(query.criterion, value);
46
- }
47
- catch (e) {
48
- console.error(e instanceof Error ? e.message : e);
49
- }
50
- }
51
- return {
52
- '.meta': {
53
- timing: Date.now() - start
54
- },
55
- domains: result
56
- };
57
- }
58
- //# sourceMappingURL=df-shape-query-executor.js.map
@@ -1,27 +0,0 @@
1
- import Joi from 'joi';
2
- import type { DataFrameDomain } from '../../../abstract-interpretation/data-frame/dataframe-domain';
3
- import type { StateAbstractDomain } from '../../../abstract-interpretation/domains/state-abstract-domain';
4
- import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
5
- import type { FlowrConfig } from '../../../config';
6
- import type { SlicingCriterion } from '../../../slicing/criterion/parse';
7
- import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
8
- import type { ParsedQueryLine } from '../../query';
9
- import { executeDfShapeQuery } from './df-shape-query-executor';
10
- /** Infer the shape of data frames using abstract interpretation. */
11
- export interface DfShapeQuery extends BaseQueryFormat {
12
- readonly type: 'df-shape';
13
- readonly criterion?: SlicingCriterion;
14
- }
15
- export interface DfShapeQueryResult extends BaseQueryResult {
16
- domains: StateAbstractDomain<DataFrameDomain> | Map<SlicingCriterion, DataFrameDomain | undefined>;
17
- }
18
- declare function dfShapeQueryLineParser(_output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'df-shape'>;
19
- export declare const DfShapeQueryDefinition: {
20
- readonly executor: typeof executeDfShapeQuery;
21
- readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
22
- readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
23
- readonly fromLine: typeof dfShapeQueryLineParser;
24
- readonly schema: Joi.ObjectSchema<any>;
25
- readonly flattenInvolvedNodes: () => never[];
26
- };
27
- export {};
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DfShapeQueryDefinition = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- const abstract_domain_1 = require("../../../abstract-interpretation/domains/abstract-domain");
9
- const lattice_1 = require("../../../abstract-interpretation/domains/lattice");
10
- const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
11
- const ansi_1 = require("../../../util/text/ansi");
12
- const time_1 = require("../../../util/text/time");
13
- const df_shape_query_executor_1 = require("./df-shape-query-executor");
14
- function dfShapeQueryLineParser(_output, line, _config) {
15
- const criterion = (0, slice_query_parser_1.sliceCriterionParser)(line[0]);
16
- return {
17
- query: {
18
- type: 'df-shape',
19
- criterion: criterion
20
- },
21
- rCode: criterion ? line[1] : line[0]
22
- };
23
- }
24
- exports.DfShapeQueryDefinition = {
25
- executor: df_shape_query_executor_1.executeDfShapeQuery,
26
- asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
27
- const out = queryResults;
28
- const domains = out.domains instanceof abstract_domain_1.AbstractDomain ? out.domains.value : out.domains;
29
- result.push(`Query: ${(0, ansi_1.bold)('df-shape', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
30
- if (domains === lattice_1.Bottom) {
31
- result.push(` ╰ state: ${lattice_1.BottomSymbol}`);
32
- return true;
33
- }
34
- result.push(...domains.entries().take(20).map(([key, domain]) => {
35
- return ` ╰ ${key}: ${domain?.toString()}`;
36
- }));
37
- if (domains.size > 20) {
38
- result.push(' ╰ ... (see JSON)');
39
- }
40
- return true;
41
- },
42
- jsonFormatter: (queryResults) => {
43
- const { domains, ...out } = queryResults;
44
- const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains;
45
- const json = state === lattice_1.Bottom ? state.description : Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null]));
46
- const result = { domains: json, ...out };
47
- return result;
48
- },
49
- fromLine: dfShapeQueryLineParser,
50
- schema: joi_1.default.object({
51
- type: joi_1.default.string().valid('df-shape').required().description('The type of the query.'),
52
- criterion: joi_1.default.string().optional().description('The slicing criterion of the node to get the dataframe shape for.')
53
- }).description('The df-shape query retrieves information on the shape of dataframes'),
54
- flattenInvolvedNodes: () => []
55
- };
56
- //# sourceMappingURL=df-shape-query-format.js.map