@eagleoutice/flowr 2.15.0 → 2.15.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.
package/README.md CHANGED
@@ -47,7 +47,7 @@ It offers a wide variety of features, for example:
47
47
 
48
48
  ```shell
49
49
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
50
- flowR repl v2.14.4, R grammar v14 (tree-sitter engine)
50
+ flowR repl v2.15.0, R grammar v14 (tree-sitter engine)
51
51
  R> :query @linter "read.csv(\"/root/x.txt\")"
52
52
  ```
53
53
 
@@ -56,7 +56,7 @@ It offers a wide variety of features, for example:
56
56
 
57
57
 
58
58
  ```text
59
- Query: linter (6 ms)
59
+ Query: linter (7 ms)
60
60
  ╰ Deprecated Functions (deprecated-functions): no findings
61
61
  ╰ File Path Validity (file-path-validity): no findings
62
62
  ╰ Seeded Randomness (seeded-randomness): no findings
@@ -96,7 +96,7 @@ It offers a wide variety of features, for example:
96
96
 
97
97
  _Results (prettified and summarized):_
98
98
 
99
- Query: **linter** (10 ms)\
99
+ Query: **linter** (9 ms)\
100
100
     ╰ **Deprecated Functions** (deprecated-functions): _no findings_\
101
101
     ╰ **File Path Validity** (file-path-validity):\
102
102
         ╰ certain:\
@@ -106,7 +106,7 @@ It offers a wide variety of features, for example:
106
106
     ╰ **Absolute Paths** (absolute-file-paths):\
107
107
         ╰ certain:\
108
108
             ╰ Path `/root/x.txt` at 1.1-23\
109
-        ╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0\
109
+        ╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0\
110
110
     ╰ **Unused Definitions** (unused-definitions): _no findings_\
111
111
     ╰ **Network Functions** (network-functions): _no findings_\
112
112
     ╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
@@ -124,7 +124,7 @@ It offers a wide variety of features, for example:
124
124
 
125
125
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
126
126
 
127
- The analysis required _9.9 ms_ (including parsing and normalization and the query) within the generation environment.
127
+ The analysis required _10.3 ms_ (including parsing and normalization and the query) within the generation environment.
128
128
 
129
129
  In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
130
130
  Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
@@ -141,7 +141,7 @@ It offers a wide variety of features, for example:
141
141
  ".meta": {
142
142
  "builtin": 0,
143
143
  "sigdb": 0,
144
- "searchTimeMs": 1,
144
+ "searchTimeMs": 0,
145
145
  "processTimeMs": 1
146
146
  }
147
147
  },
@@ -196,7 +196,7 @@ It offers a wide variety of features, for example:
196
196
  ".meta": {
197
197
  "totalConsidered": 1,
198
198
  "totalUnknown": 0,
199
- "searchTimeMs": 1,
199
+ "searchTimeMs": 0,
200
200
  "processTimeMs": 0
201
201
  }
202
202
  },
@@ -213,8 +213,8 @@ It offers a wide variety of features, for example:
213
213
  ".meta": {
214
214
  "totalCalls": 0,
215
215
  "totalFunctionDefinitions": 0,
216
- "searchTimeMs": 1,
217
- "processTimeMs": 0
216
+ "searchTimeMs": 0,
217
+ "processTimeMs": 1
218
218
  }
219
219
  },
220
220
  "dataframe-access-validation": {
@@ -319,7 +319,7 @@ It offers a wide variety of features, for example:
319
319
  }
320
320
  },
321
321
  ".meta": {
322
- "timing": 10
322
+ "timing": 9
323
323
  }
324
324
  },
325
325
  ".meta": {
@@ -389,7 +389,7 @@ It offers a wide variety of features, for example:
389
389
 
390
390
  ```shell
391
391
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
392
- flowR repl v2.14.4, R grammar v14 (tree-sitter engine)
392
+ flowR repl v2.15.0, R grammar v14 (tree-sitter engine)
393
393
  R> :query @static-slice (11@sum) file://test/testfiles/example.R
394
394
  ```
395
395
 
@@ -418,7 +418,7 @@ It offers a wide variety of features, for example:
418
418
  </details>
419
419
 
420
420
  * 🚀 **fast call-graph, data-, and control-flow graphs**\
421
- Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">109.6 ms</span></i> (as of Aug 23, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
421
+ Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">108.9 ms</span></i> (as of Aug 25, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
422
422
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
423
423
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph#perspectives-cg).
424
424
  (&nbsp;[▶&nbsp;Explore in Browser](https://flowr-analysis.github.io/flowr/wiki/playground/#c=zDYSwRgTghhCeAUATADsWECUAoLBnAxlMAKYD6ALgPakC2UAHgAQA8AtIwGYCuAdvuSEo949DIyYB6RnXojsWaAHdGKlW0aIo5KADoO0GsXghEjALyMAjAC4AbABpGANyJdi5xvngBmRwA5HAHZHACZHAE5HABYMbHwSKB5VdQ4QYHJiCHglRxdgN0YAPkYQuISeABICImJTdWqSCmoZeHjiRIq8t3lcLho6OFJcbXJcFnZe-pgQXCM2xMdDRI8l4Qba2KxeLlnEJu1gNQm%2B7KhFTtdieUUIEAydfFwneEmB2CGR3EcAIleYWAeT2%2B2FQlHIrXKVUIJEQIMoIB4owh7UqJgwQA&p=13:1 "run this script in flowR's playground, no setup")&nbsp;)
@@ -456,7 +456,7 @@ It offers a wide variety of features, for example:
456
456
 
457
457
  ```shell
458
458
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
459
- flowR repl v2.14.4, R grammar v14 (tree-sitter engine)
459
+ flowR repl v2.15.0, R grammar v14 (tree-sitter engine)
460
460
  R> :dataflow* test/testfiles/example.R
461
461
  ```
462
462
 
@@ -765,7 +765,7 @@ It offers a wide variety of features, for example:
765
765
  ```
766
766
 
767
767
 
768
- (The analysis required _1.8 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
768
+ (The analysis required _3.0 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
769
769
 
770
770
 
771
771
 
@@ -603,7 +603,7 @@ function mapDataFrameCreate(args, params, ctx, info) {
603
603
  const argNames = args.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
604
604
  const argLengths = args.map(arg => resolve_helper_1.Resolve.argument.vectorLength(arg, info));
605
605
  const allVectors = argLengths.every(assert_1.isNotUndefined);
606
- const rows = allVectors ? Math.max(...argLengths, 0) : undefined;
606
+ const rows = allVectors ? argLengths.reduce((max, length) => Math.max(max, length), 0) : undefined;
607
607
  let colnames = argNames;
608
608
  // over-approximate the column names if arguments are present but cannot be resolved to values
609
609
  if (!allVectors || typeof checkNames !== 'boolean' || typeof noDupNames !== 'boolean') {
@@ -1017,9 +1017,10 @@ function mapDataFrameMutate(args, params, ctx, info) {
1017
1017
  .filter(arg => !(0, arguments_1.isRNull)(arg))
1018
1018
  .map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
1019
1019
  // only column names that are not created by mutation are preconditions on the operand
1020
+ const mutatedColSet = new Set(mutatedCols);
1020
1021
  const accessedNames = mutateArgs
1021
1022
  .flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph))
1022
- .filter(arg => !mutatedCols?.includes(arg));
1023
+ .filter(arg => !mutatedColSet.has(arg));
1023
1024
  deletedCols = (0, arguments_1.filterValidNames)(deletedCols, params.checkNames, params.noDupNames, undefined, true);
1024
1025
  mutatedCols = (0, arguments_1.filterValidNames)(mutatedCols, params.checkNames, params.noDupNames, undefined, true);
1025
1026
  if (accessedNames.length > 0) {
@@ -1229,6 +1230,14 @@ function mapDataFrameNamedColumnAccess(access, ctx, info) {
1229
1230
  columns: colname ? [colname] : undefined
1230
1231
  }];
1231
1232
  }
1233
+ /** the largest absolute index of a list, which can hold more entries than a spread could pass as arguments */
1234
+ function maxAbs(indices) {
1235
+ let max = -Infinity;
1236
+ for (const index of indices) {
1237
+ max = Math.max(max, Math.abs(index));
1238
+ }
1239
+ return max;
1240
+ }
1232
1241
  /**
1233
1242
  * Maps an index-based access of the rows and columns of a data frame, such as `df[1, ]` or `df[["id"]]`, to abstract data frame operations.
1234
1243
  */
@@ -1291,7 +1300,7 @@ function mapDataFrameIndexColRowAccess(access, ctx, info) {
1291
1300
  const colSubset = columns === undefined || columns.every(col => isColName(col) || col >= 0);
1292
1301
  const rowZero = rows?.length === 1 && rows[0] === 0;
1293
1302
  const colZero = columns?.length === 1 && columns[0] === 0;
1294
- const duplicateCols = columns?.some((col, index, list) => list.indexOf(col) !== index);
1303
+ const duplicateCols = columns !== undefined && new Set(columns).size !== columns.length;
1295
1304
  let operand = dataFrame;
1296
1305
  if (rowArg !== undefined && r_argument_1.RArgument.isNotEmpty(rowArg)) {
1297
1306
  if (rowSubset) {
@@ -1307,7 +1316,7 @@ function mapDataFrameIndexColRowAccess(access, ctx, info) {
1307
1316
  operand: operand?.info.id,
1308
1317
  rows: rowZero ? 0 : rows?.filter(index => index !== 0).length,
1309
1318
  /* R drops nothing for an index beyond the extent, so the semantics has to know how far they reach */
1310
- maxIndex: rows !== undefined ? Math.max(...rows.map(Math.abs)) : undefined
1319
+ maxIndex: rows !== undefined ? maxAbs(rows) : undefined
1311
1320
  });
1312
1321
  }
1313
1322
  operand = undefined;
@@ -1326,7 +1335,7 @@ function mapDataFrameIndexColRowAccess(access, ctx, info) {
1326
1335
  operation: 'removeCols',
1327
1336
  operand: operand?.info.id,
1328
1337
  colnames: columns?.map(toColName),
1329
- maxIndex: columns?.every(isIndex) ? Math.max(...columns.map(Math.abs)) : undefined
1338
+ maxIndex: columns?.every(isIndex) ? maxAbs(columns) : undefined
1330
1339
  });
1331
1340
  }
1332
1341
  // eslint-disable-next-line no-useless-assignment -- ends the chain
@@ -247,7 +247,7 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
247
247
  if (values.size === 0) {
248
248
  return r_value_1.Top;
249
249
  }
250
- return (0, set_constants_1.setFrom)(...values);
250
+ return (0, set_constants_1.setOf)([...values]);
251
251
  }
252
252
  /** given an unknown alias, we have to clear all values in the environments */
253
253
  (0, unknown_side_effect_1.onUnknownSideEffect)((_graph, env, _id, target) => {
@@ -345,7 +345,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
345
345
  const sequence = iteratedSequence(id, graph, idMap);
346
346
  if (sequence !== undefined) {
347
347
  const value = resolveIdToValue(sequence.info.id, { graph, idMap, ctx, blocked });
348
- return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setFrom)(...iteratedElements(value));
348
+ return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setOf)(iteratedElements(value));
349
349
  }
350
350
  const queue = new visiting_queue_1.VisitingQueue(10);
351
351
  const clean = ctx.env.makeCleanEnv();
@@ -442,7 +442,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
442
442
  values.add((0, general_1.valueFromRNodeConstant)(node));
443
443
  }
444
444
  }
445
- return values.size === 0 ? r_value_1.Top : (0, set_constants_1.setFrom)(...values);
445
+ return values.size === 0 ? r_value_1.Top : (0, set_constants_1.setOf)([...values]);
446
446
  }
447
447
  /**
448
448
  * Please use {@link resolveIdToValue}
@@ -466,6 +466,6 @@ function resolveToConstants(name, environment) {
466
466
  const d = def.value;
467
467
  values.add(d === undefined ? r_value_1.Top : (0, general_1.valueFromTsValue)(d));
468
468
  });
469
- return (0, set_constants_1.setFrom)(...values);
469
+ return (0, set_constants_1.setOf)([...values]);
470
470
  }
471
471
  //# sourceMappingURL=alias-tracking.js.map
@@ -108,14 +108,24 @@ function resolveAsSeq(args) {
108
108
  }
109
109
  return r_value_2.Top;
110
110
  }
111
+ /**
112
+ * How many elements of a sequence are worth naming one by one. `1:148066` is a loop bound rather than a set of
113
+ * indices anything asks about, and holding one object per element costs more than the precision is worth, so
114
+ * a longer sequence resolves to {@link Top} instead.
115
+ */
116
+ const MaxSequenceLength = 4096;
111
117
  /**
112
118
  * The elements `from:to` runs over, counting down whenever `to` is the smaller one, and stopping before it
113
- * would pass `to` (`1:3.5` ends at `3`). `undefined` for a bound that names no position to count from or to.
119
+ * would pass `to` (`1:3.5` ends at `3`). `undefined` for a bound that names no position to count from or to,
120
+ * and for a sequence longer than {@link MaxSequenceLength}.
114
121
  */
115
122
  function createNumberSequence(start, end) {
116
123
  if (!Number.isFinite(start.num) || !Number.isFinite(end.num)) {
117
124
  return undefined;
118
125
  }
126
+ else if (Math.floor(Math.abs(end.num - start.num)) + 1 > MaxSequenceLength) {
127
+ return undefined;
128
+ }
119
129
  const step = start.num <= end.num ? 1 : -1;
120
130
  const sequence = [];
121
131
  for (let i = start.num; step > 0 ? i <= end.num : i >= end.num; i += step) {
@@ -5,6 +5,8 @@ import type { RNumberValue } from '../../../r-bridge/lang-4.x/convert-values';
5
5
  * Takes n potentially lifted ops and returns `Top` or `Bottom` if any is `Top` or `Bottom`.
6
6
  */
7
7
  export declare function bottomTopGuard(...a: Lift<unknown>[]): typeof Top | typeof Bottom | undefined;
8
+ /** {@link bottomTopGuard} for a list that is already one, which a spread of many elements could not pass on */
9
+ export declare function bottomTopGuardOf(a: readonly Lift<unknown>[]): typeof Top | typeof Bottom | undefined;
8
10
  /**
9
11
  * Returns a value set, if a is not bottom or top, otherwise undefined.
10
12
  * Useful when working with values returned by {@link Resolve.toValue}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.bottomTopGuard = bottomTopGuard;
4
+ exports.bottomTopGuardOf = bottomTopGuardOf;
4
5
  exports.valueSetGuard = valueSetGuard;
5
6
  exports.soleValue = soleValue;
6
7
  exports.valueFromTsValue = valueFromTsValue;
@@ -20,6 +21,10 @@ const scalar_constants_1 = require("./scalar/scalar-constants");
20
21
  * Takes n potentially lifted ops and returns `Top` or `Bottom` if any is `Top` or `Bottom`.
21
22
  */
22
23
  function bottomTopGuard(...a) {
24
+ return bottomTopGuardOf(a);
25
+ }
26
+ /** {@link bottomTopGuard} for a list that is already one, which a spread of many elements could not pass on */
27
+ function bottomTopGuardOf(a) {
23
28
  if (a.some(r_value_1.isBottom)) {
24
29
  return r_value_1.Bottom;
25
30
  }
@@ -4,6 +4,11 @@ import { type Lift, type Value, type ValueSet, Top } from '../r-value';
4
4
  * @see {@link isSet} - to check whether a value is a set
5
5
  */
6
6
  export declare function setFrom<V extends Value[]>(...elements: V): Lift<ValueSet<Value[]>>;
7
+ /**
8
+ * {@link setFrom} for elements that are already a list, which a set of many of them could not be spread into.
9
+ * @see {@link isSet} - to check whether a value is a set
10
+ */
11
+ export declare function setOf(elements: readonly Value[]): Lift<ValueSet<Value[]>>;
7
12
  /**
8
13
  * Checks, whether the given value is a set.
9
14
  * @see {@link setFrom} - to create sets
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValueSetBottom = exports.ValueSetTop = exports.ValueEmptySet = void 0;
4
4
  exports.setFrom = setFrom;
5
+ exports.setOf = setOf;
5
6
  exports.isSet = isSet;
6
7
  const general_1 = require("../general");
7
8
  const r_value_1 = require("../r-value");
@@ -15,10 +16,17 @@ function flattenSetElements(s) {
15
16
  * @see {@link isSet} - to check whether a value is a set
16
17
  */
17
18
  function setFrom(...elements) {
19
+ return setOf(elements);
20
+ }
21
+ /**
22
+ * {@link setFrom} for elements that are already a list, which a set of many of them could not be spread into.
23
+ * @see {@link isSet} - to check whether a value is a set
24
+ */
25
+ function setOf(elements) {
18
26
  const vals = elements.flatMap(e => {
19
27
  return e.type === 'set' ? flattenSetElements(e.elements) : e;
20
28
  });
21
- return (0, general_1.bottomTopGuard)(...vals) ?? {
29
+ return (0, general_1.bottomTopGuardOf)(vals) ?? {
22
30
  type: 'set',
23
31
  elements: vals
24
32
  };
@@ -93,8 +93,9 @@ function processStringTemplate(name, args, rootId, data, config) {
93
93
  continue;
94
94
  }
95
95
  const template = arg.value;
96
+ /* one generator for the whole template so its interpolations do not collide on the same ids */
97
+ const generator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(`${name.lexeme}::${template.info.id}`, template.location);
96
98
  for (const code of interpolationsOf(template.content.str, open, close, config.markup)) {
97
- const generator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(`${name.lexeme}::${template.info.id}`, template.location);
98
99
  const result = (0, built_in_source_1.sourceRequest)(rootId, (0, retriever_1.requestFromInput)(code), data, information, false, generator, true);
99
100
  /* the template stands where the call does, so what it leaves open resolves against the bindings here */
100
101
  (0, linker_1.linkInputs)([...result.in, ...result.unknownReferences], data.environment, [], result.graph, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -403,6 +403,25 @@ function optimizeStringOrder(strings, blobs) {
403
403
  for (const idx of Object.values(blob.sources ?? {})) {
404
404
  bump(idx);
405
405
  }
406
+ /* a class names itself, its superclasses, its slots and their types, all of them dictionary indices */
407
+ for (const c of blob.classes ?? []) {
408
+ bump(c[0]);
409
+ for (const superIdx of c[3]) {
410
+ bump(superIdx);
411
+ }
412
+ for (const slot of c[4]) {
413
+ if (typeof slot === 'number') {
414
+ bump(slot);
415
+ }
416
+ else {
417
+ bump(slot[0]);
418
+ bump(slot[1]);
419
+ }
420
+ }
421
+ if (c.length === 6) {
422
+ bump(c[5]);
423
+ }
424
+ }
406
425
  }
407
426
  const order = Array.from({ length: n }, (_, i) => i).sort((a, b) => counts[b] - counts[a] || a - b);
408
427
  const remap = new Int32Array(n);
@@ -454,6 +473,25 @@ function optimizeStringOrder(strings, blobs) {
454
473
  for (const [version, idx] of Object.entries(blob.sources ?? {})) {
455
474
  blob.sources[version] = remap[idx];
456
475
  }
476
+ for (const c of blob.classes ?? []) {
477
+ c[0] = remap[c[0]];
478
+ for (let i = 0; i < c[3].length; i++) {
479
+ c[3][i] = remap[c[3][i]];
480
+ }
481
+ for (let i = 0; i < c[4].length; i++) {
482
+ const slot = c[4][i];
483
+ if (typeof slot === 'number') {
484
+ c[4][i] = remap[slot];
485
+ }
486
+ else {
487
+ slot[0] = remap[slot[0]];
488
+ slot[1] = remap[slot[1]];
489
+ }
490
+ }
491
+ if (c.length === 6) {
492
+ c[5] = remap[c[5]];
493
+ }
494
+ }
457
495
  }
458
496
  return order.map(oldI => strings[oldI]);
459
497
  }
@@ -201,6 +201,13 @@ export declare class SigDatabase implements PackageSignatureSource {
201
201
  private blobMeta;
202
202
  lookup(pkg: string, version?: string): LibraryExports | undefined;
203
203
  packagesExporting(name: string): readonly string[];
204
+ /**
205
+ * Whether the newest version of `pkg` exports the name with dictionary id `id`. The same answer
206
+ * {@link lookup}'s `exported` gives, off the function records themselves: asking a package at a time is what
207
+ * {@link packagesExporting} does, and deriving a whole export view per package to read one name out of it is not
208
+ * worth the five arrays and the map it builds.
209
+ */
210
+ private exportsNameId;
204
211
  classOwner(className: string, version?: string): string | undefined;
205
212
  /** resolve a package version to its blob and the function-record indices of that version (the shared prologue of {@link functions}/{@link functionByName}) */
206
213
  private versionFns;
@@ -36,6 +36,48 @@ function applyDictLine(json, strings) {
36
36
  strings[start + k] = batch[k];
37
37
  }
38
38
  }
39
+ /**
40
+ * Dictionary ids grouped by first character and length, shared per dictionary rather than per reader (the shards of one
41
+ * database read the same array). One `Int32Array` per group, ascending, so a lookup answers what `indexOf` would while
42
+ * comparing a few hundred strings rather than the 1.4 million a scan of the whole dictionary walks.
43
+ */
44
+ const dictionaryBuckets = new WeakMap();
45
+ /** the group `name` belongs to; the empty string has none of its own, which is what `0` stands for */
46
+ function bucketKeyOf(name) {
47
+ return name.length === 0 ? 0 : (name.charCodeAt(0) << 8) | Math.min(name.length, 255);
48
+ }
49
+ /** the id `strings.indexOf(name)` would give, through {@link dictionaryBuckets}; `-1` when the dictionary lacks it */
50
+ function dictionaryIdOf(strings, name) {
51
+ let buckets = dictionaryBuckets.get(strings);
52
+ if (buckets === undefined) {
53
+ const sizes = new Map();
54
+ for (const entry of strings) {
55
+ const key = bucketKeyOf(entry);
56
+ sizes.set(key, (sizes.get(key) ?? 0) + 1);
57
+ }
58
+ buckets = new Map();
59
+ const filled = new Map();
60
+ for (const [key, size] of sizes) {
61
+ buckets.set(key, new Int32Array(size));
62
+ filled.set(key, 0);
63
+ }
64
+ for (let i = 0; i < strings.length; i++) {
65
+ const key = bucketKeyOf(strings[i]);
66
+ const at = filled.get(key);
67
+ buckets.get(key)[at] = i;
68
+ filled.set(key, at + 1);
69
+ }
70
+ dictionaryBuckets.set(strings, buckets);
71
+ }
72
+ const bucket = buckets.get(bucketKeyOf(name));
73
+ /* ascending, so the first match is the one a scan from the front would have found */
74
+ for (const id of bucket ?? []) {
75
+ if (strings[id] === name) {
76
+ return id;
77
+ }
78
+ }
79
+ return -1;
80
+ }
39
81
  function readDictSection(buf, strings) {
40
82
  let off = 0;
41
83
  while (off < buf.length) {
@@ -374,7 +416,7 @@ class SigDatabase {
374
416
  nameId(name) {
375
417
  let id = this.nameIds.get(name);
376
418
  if (id === undefined) {
377
- this.nameIds.set(name, id = this.strings.indexOf(name));
419
+ this.nameIds.set(name, id = dictionaryIdOf(this.strings, name));
378
420
  }
379
421
  return id;
380
422
  }
@@ -463,17 +505,37 @@ class SigDatabase {
463
505
  return bm && (0, decode_1.deriveLibraryExports)(this.strings, bm.blob, bm.meta, pkg, version, this.cranBase);
464
506
  }
465
507
  packagesExporting(name) {
466
- if (this.nameId(name) < 0) {
508
+ const id = this.nameId(name);
509
+ if (id < 0) {
467
510
  return [];
468
511
  }
469
512
  const found = [];
470
513
  for (const pkg in this.index.pkgs) {
471
- if (this.mayOffer(pkg, name) && this.lookup(pkg)?.exported.includes(name)) {
514
+ if (this.mayOffer(pkg, name) && this.exportsNameId(pkg, id)) {
472
515
  found.push(pkg);
473
516
  }
474
517
  }
475
518
  return found.sort((a, b) => this.downloads(b) - this.downloads(a) || a.localeCompare(b));
476
519
  }
520
+ /**
521
+ * Whether the newest version of `pkg` exports the name with dictionary id `id`. The same answer
522
+ * {@link lookup}'s `exported` gives, off the function records themselves: asking a package at a time is what
523
+ * {@link packagesExporting} does, and deriving a whole export view per package to read one name out of it is not
524
+ * worth the five arrays and the map it builds.
525
+ */
526
+ exportsNameId(pkg, id) {
527
+ const r = this.versionFns(pkg);
528
+ if (r === undefined) {
529
+ return false;
530
+ }
531
+ for (const i of r.idxs) {
532
+ const fn = r.blob.fns[i];
533
+ if (fn[0] === id && (fn[3] & 1 /* FnProp.Exported */) !== 0) {
534
+ return true;
535
+ }
536
+ }
537
+ return false;
538
+ }
477
539
  classOwner(className, version) {
478
540
  if (version !== undefined) {
479
541
  return classOwnerAtVersion(this, className, version);
@@ -1024,6 +1086,14 @@ async function verifyShardedDatabase(manifestFile, opts = {}) {
1024
1086
  break;
1025
1087
  }
1026
1088
  }
1089
+ /* a class names itself, its superclasses and its slots out of the same dictionary the rest reads from */
1090
+ for (const c of set.classes(pkg) ?? []) {
1091
+ const strings = [c.name, ...c.supers, ...c.slots.flatMap(slot => [slot.name, slot.type]), c.package];
1092
+ if (strings.some(entry => entry !== undefined && typeof entry !== 'string')) {
1093
+ errors.push(`spot-check: '${pkg}' class decoded with a non-string name/super/slot (dictionary index out of range?)`);
1094
+ break;
1095
+ }
1096
+ }
1027
1097
  spotChecked++;
1028
1098
  }
1029
1099
  // 5. required packages (e.g. base R) are present
package/util/version.js CHANGED
@@ -42,9 +42,9 @@ const assert_1 = require("./assert");
42
42
  const sigdb_download_1 = require("../project/sigdb/sigdb-download");
43
43
  const doc_files_1 = require("../documentation/doc-util/doc-files");
44
44
  // this is automatically replaced with the current version by release-it
45
- const version = '2.15.0';
45
+ const version = '2.15.1';
46
46
  // this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
47
- const versionDate = '2026-08-25T16:11:35Z';
47
+ const versionDate = '2026-08-25T18:47:31Z';
48
48
  /**
49
49
  * Retrieves the current flowR version as a new {@link SemVer} object.
50
50
  */