@eagleoutice/flowr 2.14.2 → 2.14.3

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 (44) hide show
  1. package/README.md +30 -42
  2. package/abstract-interpretation/absint-visitor.d.ts +45 -4
  3. package/abstract-interpretation/absint-visitor.js +252 -53
  4. package/config.d.ts +15 -8
  5. package/config.js +4 -1
  6. package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -7
  7. package/control-flow/semantic-cfg-guided-visitor.js +23 -0
  8. package/dataflow/environments/default-builtin-config.d.ts +6 -0
  9. package/dataflow/environments/default-builtin-config.js +59 -5
  10. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  11. package/dataflow/eval/resolve/alias-tracking.js +1 -1
  12. package/dataflow/info.d.ts +1 -6
  13. package/dataflow/info.js +0 -17
  14. package/dataflow/internal/control-flow.d.ts +14 -2
  15. package/dataflow/internal/control-flow.js +24 -0
  16. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +10 -1
  17. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
  18. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +11 -10
  19. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -2
  20. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +1 -1
  21. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  22. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -0
  23. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -1
  24. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -2
  25. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  26. package/dataflow/internal/process/functions/call/known-call-handling.js +21 -17
  27. package/documentation/doc-readme.js +0 -12
  28. package/documentation/wiki-absint.js +7 -2
  29. package/documentation/wiki-interface.js +1 -0
  30. package/linter/rules/deprecated-functions.js +4 -2
  31. package/package.json +1 -1
  32. package/project/dependency-version-space.d.ts +1 -0
  33. package/project/dependency-version-space.js +1 -1
  34. package/project/flowr-analyzer-builder.d.ts +4 -4
  35. package/project/sigdb/reader.d.ts +6 -0
  36. package/project/sigdb/reader.js +2 -2
  37. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +7 -0
  38. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +7 -0
  39. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +5 -1
  40. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +0 -5
  41. package/search/search-executor/search-enrichers.d.ts +4 -0
  42. package/search/search-executor/search-enrichers.js +4 -4
  43. package/util/objects.d.ts +15 -4
  44. package/util/version.js +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.RGroupGenerics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
3
+ exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.RGroupGenerics = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
4
4
  exports.namespacePlotFunctions = namespacePlotFunctions;
5
5
  exports.statedSignatures = statedSignatures;
6
6
  exports.statedSignatureOf = statedSignatureOf;
@@ -175,6 +175,60 @@ const SigDataDots = [['.data', built_in_props_1.ArgProp.Value], ['...', built_in
175
175
  const SigShape = [['x', built_in_props_1.ArgProp.Shape]];
176
176
  const SigXTable = [['x', built_in_props_1.ArgProp.Value], ['table', built_in_props_1.ArgProp.Value]];
177
177
  const SigDots = [['...', built_in_props_1.ArgProp.Value]];
178
+ /**
179
+ * The manual page documenting a base R primitive, for the ones not documented under their own name.
180
+ *
181
+ * A primitive is written in C and has no R closure, so nothing extracts a signature, a source file or a help
182
+ * topic for it and the signature database holds no entry at all: `base::sin` is documented under `Trig`, and
183
+ * guessing `sin` only names a page that does not exist. flowR states these names itself, so it carries where
184
+ * they are documented as well. Written the way R documents them, one page and everything it covers.
185
+ */
186
+ const PrimitivesPerTopic = {
187
+ 'Arithmetic': ['%%', '%/%', '*', '+', '-', '/', '^'],
188
+ 'assignOps': ['<-', '<<-', '='],
189
+ 'call': ['as.call'],
190
+ 'CallExternal': ['.Call', '.External'],
191
+ 'character': ['as.character', 'is.character'],
192
+ 'Colon': [':'],
193
+ 'Comparison': ['!=', '<', '<=', '==', '>', '>='],
194
+ 'complex': ['Arg', 'Conj', 'Im', 'Mod', 'Re', 'as.complex'],
195
+ 'Control': ['break', 'for', 'if', 'next', 'repeat', 'while'],
196
+ 'crossprod': ['tcrossprod'],
197
+ 'cumsum': ['cummax', 'cummin', 'cumprod'],
198
+ 'double': ['as.double'],
199
+ 'environment': ['baseenv', 'emptyenv', 'globalenv'],
200
+ 'Extract': ['$', '[', '[['],
201
+ 'Extremes': ['max', 'min'],
202
+ 'Foreign': ['.C', '.Fortran'],
203
+ 'function': ['return'],
204
+ 'Hyperbolic': ['acosh', 'asinh', 'atanh', 'cosh', 'sinh', 'tanh'],
205
+ 'integer': ['as.integer'],
206
+ 'Internal': ['.Internal'],
207
+ 'is.finite': ['is.infinite', 'is.nan'],
208
+ 'list': ['is.list'],
209
+ 'Log': ['exp', 'expm1', 'log', 'log10', 'log1p', 'log2'],
210
+ 'Logic': ['!', '&', '&&', '|', '||'],
211
+ 'logical': ['as.logical', 'is.logical'],
212
+ 'MathFun': ['abs', 'sqrt'],
213
+ 'matmult': ['%*%'],
214
+ 'matrix': ['is.matrix'],
215
+ 'NA': ['is.na'],
216
+ 'nchar': ['nzchar'],
217
+ 'ns-dblcolon': ['::', ':::'],
218
+ 'NULL': ['is.null'],
219
+ 'numeric': ['as.numeric', 'is.numeric'],
220
+ 'Paren': ['(', '{'],
221
+ 'Primitive': ['.Primitive'],
222
+ 'raw': ['as.raw'],
223
+ 'Round': ['ceiling', 'floor', 'round', 'signif', 'trunc'],
224
+ 'seq': ['seq.int', 'seq_along', 'seq_len'],
225
+ 'slotOp': ['@'],
226
+ 'substitute': ['quote'],
227
+ 'tilde': ['~'],
228
+ 'Trig': ['acos', 'asin', 'atan', 'cos', 'sin', 'tan'],
229
+ };
230
+ /** {@link PrimitivesPerTopic} the way a lookup wants it: the topic documenting a name. */
231
+ exports.BasePrimitiveTopics = Object.fromEntries(Object.entries(PrimitivesPerTopic).flatMap(([topic, names]) => names.map(name => [name, topic])));
178
232
  /**
179
233
  * What flowR states about every function it carries a definition for, as `name -> signatures`. A name may be
180
234
  * defined for several packages (`filter` is dplyr's and cohortBuilder's), so all of them are here and the
@@ -284,10 +338,6 @@ function markGenerics(definitions) {
284
338
  }
285
339
  return out;
286
340
  }
287
- /**
288
- * Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
289
- * is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
290
- */
291
341
  /** what creating a plot does; restated by the deprecated plot creators, which do the same but should not be used */
292
342
  const PlotCreateConfig = {
293
343
  forceArgs: 'all',
@@ -305,6 +355,10 @@ const PlotCreateConfig = {
305
355
  },
306
356
  props: built_in_props_1.CallProp.Graphics
307
357
  };
358
+ /**
359
+ * Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
360
+ * is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
361
+ */
308
362
  exports.WrittenBuiltinDefinitions = [
309
363
  { type: 'constant', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['NULL', 'NA', 'NA_integer_', 'NA_real_', 'NA_complex_', 'NA_character_']), value: null, assumePrimitive: true },
310
364
  { type: 'constant', names: [identifier_1.Identifier.from(['NaN', "base" /* PkgName.Base */])], value: NaN, assumePrimitive: true },
@@ -60,8 +60,8 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
60
60
  * @useInstead {@link Resolve.toValue}
61
61
  */
62
62
  export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked }: ResolveInfo): ResolveResult;
63
- /** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
64
63
  /**
64
+ * Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant.
65
65
  * @useInstead {@link Resolve.toSingleString}
66
66
  */
67
67
  export declare function resolveIdToSingleString(id: NodeId | RNodeWithParent | undefined, info: ResolveInfo): string | undefined;
@@ -169,8 +169,8 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
169
169
  return r_value_1.Top;
170
170
  }
171
171
  }
172
- /** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
173
172
  /**
173
+ * Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant.
174
174
  * @useInstead {@link Resolve.toSingleString}
175
175
  */
176
176
  function resolveIdToSingleString(id, info) {
@@ -83,7 +83,7 @@ export declare function doesExitPointPropagateCalls(type: ExitPointType): boolea
83
83
  * This may be as innocent as the last expression or explicit with a `return`/`break`/`next`.
84
84
  * @see {@link ExitPointType} - for the different types of exit points
85
85
  * @see {@link addNonDefaultExitPoints} - to easily modify lists of exit points
86
- * @see {@link alwaysExits} - to check whether a list of control dependencies always triggers an exit
86
+ * @see {@link ControlFlow#alwaysExits|ControlFlow.alwaysExits()} - to check whether a subtree always jumps away
87
87
  * @see {@link filterOutLoopExitPoints} - to remove loop exit points from a list
88
88
  */
89
89
  export interface ExitPoint {
@@ -223,11 +223,6 @@ export declare function happensInEveryBranch(cds: readonly ControlDependency[] |
223
223
  * @see {@link happensInEveryBranch} - for the array-based version
224
224
  */
225
225
  export declare function happensInEveryBranchSet(cds: ReadonlySet<ControlDependency> | undefined): boolean;
226
- /**
227
- * Checks whether the given dataflow information always exits (i.e., if there is a non-default exit point in every branch).
228
- * @see {@link ExitPoint} - for the different types of exit points
229
- */
230
- export declare function alwaysExits(data: DataflowInformation): boolean;
231
226
  /**
232
227
  * Filters out exit points which end their cascade within a loop.
233
228
  */
package/dataflow/info.js CHANGED
@@ -9,7 +9,6 @@ exports.addNonDefaultExitPoints = addNonDefaultExitPoints;
9
9
  exports.overwriteExitPoints = overwriteExitPoints;
10
10
  exports.happensInEveryBranch = happensInEveryBranch;
11
11
  exports.happensInEveryBranchSet = happensInEveryBranchSet;
12
- exports.alwaysExits = alwaysExits;
13
12
  exports.filterOutLoopExitPoints = filterOutLoopExitPoints;
14
13
  exports.diffControlDependency = diffControlDependency;
15
14
  exports.diffControlDependencies = diffControlDependencies;
@@ -172,22 +171,6 @@ function coversSet(cds) {
172
171
  function happensInEveryBranchSet(cds) {
173
172
  return cds === undefined || (cds.size !== 0 && coversSet(cds));
174
173
  }
175
- /**
176
- * Checks whether the given dataflow information always exits (i.e., if there is a non-default exit point in every branch).
177
- * @see {@link ExitPoint} - for the different types of exit points
178
- */
179
- function alwaysExits(data) {
180
- let cds = [];
181
- for (const e of data.exitPoints) {
182
- if (e.type !== 0 /* ExitPointType.Default */) {
183
- if (e.cds === undefined) {
184
- return true;
185
- }
186
- cds = cds.concat(e.cds);
187
- }
188
- }
189
- return happensInEveryBranch(cds);
190
- }
191
174
  /**
192
175
  * Filters out exit points which end their cascade within a loop.
193
176
  */
@@ -1,7 +1,7 @@
1
1
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
2
  import type { DataflowGraph } from '../graph/graph';
3
- import type { ControlDependency, DataflowCfgInformation } from '../info';
4
- import { ExitPointType } from '../info';
3
+ import type { DataflowCfgInformation } from '../info';
4
+ import { ControlDependency, ExitPointType } from '../info';
5
5
  /**
6
6
  * Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
7
7
  * The {@link ControlFlowGraph} is a view on what is recorded here.
@@ -38,6 +38,17 @@ export declare const ControlFlow: {
38
38
  * @see {@link ControlFlow#isStatement|isStatement()} - for the other kind
39
39
  */
40
40
  readonly isExpression: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
41
+ /**
42
+ * Whether the subtree always jumps away instead of being left normally, i.e. whether a non-default exit
43
+ * point happens in every branch.
44
+ * @example
45
+ * ```r
46
+ * { break } # always exits
47
+ * { if(u) break } # only maybe
48
+ * ```
49
+ * @see {@link ControlFlow#canComplete|canComplete()} - for whether it can be left normally at all
50
+ */
51
+ readonly alwaysExits: (this: void, info: DataflowCfgInformation) => boolean;
41
52
  /**
42
53
  * Whether the subtree can be left normally instead of always jumping away.
43
54
  * @example
@@ -45,6 +56,7 @@ export declare const ControlFlow: {
45
56
  * { 1 } # can complete
46
57
  * { break } # cannot
47
58
  * ```
59
+ * @see {@link ControlFlow#alwaysExits|alwaysExits()} - for whether it always jumps away
48
60
  */
49
61
  readonly canComplete: (this: void, info: DataflowCfgInformation) => boolean;
50
62
  /**
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ControlFlow = void 0;
4
4
  const edge_1 = require("../graph/edge");
5
+ const info_1 = require("../info");
5
6
  const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
6
7
  /**
7
8
  * Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
@@ -50,6 +51,28 @@ exports.ControlFlow = {
50
51
  isExpression(graph, id) {
51
52
  return graph.idMap?.get(id) !== undefined && !exports.ControlFlow.isStatement(graph, id);
52
53
  },
54
+ /**
55
+ * Whether the subtree always jumps away instead of being left normally, i.e. whether a non-default exit
56
+ * point happens in every branch.
57
+ * @example
58
+ * ```r
59
+ * { break } # always exits
60
+ * { if(u) break } # only maybe
61
+ * ```
62
+ * @see {@link ControlFlow#canComplete|canComplete()} - for whether it can be left normally at all
63
+ */
64
+ alwaysExits(info) {
65
+ let cds = [];
66
+ for (const exit of info.exitPoints) {
67
+ if (exit.type !== 0 /* ExitPointType.Default */) {
68
+ if (exit.cds === undefined) {
69
+ return true;
70
+ }
71
+ cds = cds.concat(exit.cds);
72
+ }
73
+ }
74
+ return info_1.ControlDependency.happensInEveryBranch(cds);
75
+ },
53
76
  /**
54
77
  * Whether the subtree can be left normally instead of always jumping away.
55
78
  * @example
@@ -57,6 +80,7 @@ exports.ControlFlow = {
57
80
  * { 1 } # can complete
58
81
  * { break } # cannot
59
82
  * ```
83
+ * @see {@link ControlFlow#alwaysExits|alwaysExits()} - for whether it always jumps away
60
84
  */
61
85
  canComplete(info) {
62
86
  if (info.cfgExit !== undefined) {
@@ -263,7 +263,7 @@ function processExpressionList(name, args, rootId, data) {
263
263
  listEnvironments.add(ref.nodeId);
264
264
  }
265
265
  /** if at least built-one of the exit points encountered happens unconditionally, we exit here (dead code)! */
266
- if ((0, info_1.alwaysExits)(processed)) {
266
+ if (control_flow_1.ControlFlow.alwaysExits(processed)) {
267
267
  /* if there is an always-exit expression, there is no default return active anymore */
268
268
  defaultReturnExpr = undefined;
269
269
  break;
@@ -309,6 +309,15 @@ function processExpressionList(name, args, rootId, data) {
309
309
  /* an empty group completes on the spot, otherwise the last expression has to be able to reach the end */
310
310
  const reachesEnd = !!withGroup && (processedExpressions.length === 0 || exitPoints.some(e => e.type === 0 /* ExitPointType.Default */));
311
311
  const cfgEntry = control_flow_1.ControlFlow.inSequence(nextGraph, processedExpressions, reachesEnd ? rootId : undefined);
312
+ /*
313
+ * `{ break }` is entered and never left, so its `{` is reached and goes nowhere. Saying only the second
314
+ * half of that leaves the vertex beside the control flow, with nothing leading to it either.
315
+ */
316
+ if (withGroup && !reachesEnd) {
317
+ for (const exit of exitPoints) {
318
+ nextGraph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
319
+ }
320
+ }
312
321
  return {
313
322
  /* no active nodes remain, they are consumed within the remaining read collection */
314
323
  unknownReferences: [],
@@ -35,7 +35,7 @@ function processForLoop(name, args, rootId, data) {
35
35
  const origEnv = data.environment;
36
36
  (0, assert_1.guard)(variableArg !== undefined && vectorArg !== undefined && bodyArg !== undefined, () => `For-Loop ${JSON.stringify(args)} has missing arguments! Bad!`);
37
37
  const vector = (0, processor_1.processDataflowFor)(vectorArg, data);
38
- if ((0, info_1.alwaysExits)(vector)) {
38
+ if (control_flow_1.ControlFlow.alwaysExits(vector)) {
39
39
  logger_1.dataflowLogger.warn(`For-Loop ${rootId} forces exit in vector, skipping rest`);
40
40
  return vector;
41
41
  }
@@ -466,16 +466,6 @@ function prepareFunctionEnvironment(data, rootId) {
466
466
  }
467
467
  return { ...data, environment: env };
468
468
  }
469
- /**
470
- * Within something like `f <- function(a=b, m=3) { b <- 1; a; b <- 5; a + 1 }`
471
- * `a` will be defined by `b` and `b` will be a promise object bound by the first definition of b it can find.
472
- * This means that this function returns `2` due to the first `b <- 1` definition.
473
- * If the code is `f <- function(a=b, m=3) { if(m > 3) { b <- 1; }; a; b <- 5; a + 1 }`, we need a link to `b <- 1` and `b <- 6`
474
- * as `b` can be defined by either one of them.
475
- * <p>
476
- * <b>Currently we may be unable to narrow down every definition within the body as we have not implemented ways to track what covers the first definitions precisely</b>
477
- */
478
- /** Links a parameter default read to the body writes of the same name (may), returning whether any was linked. */
479
469
  /** Groups body writes by name, each list sorted by descending id (so the lowest id is last), for `linkParameterReadToBodyWrites`. */
480
470
  function groupBodyWrites(out) {
481
471
  const byName = new Map();
@@ -496,6 +486,17 @@ function groupBodyWrites(out) {
496
486
  }
497
487
  return byName;
498
488
  }
489
+ /**
490
+ * Within something like `f <- function(a=b, m=3) { b <- 1; a; b <- 5; a + 1 }`
491
+ * `a` will be defined by `b` and `b` will be a promise object bound by the first definition of b it can find.
492
+ * This means that this function returns `2` due to the first `b <- 1` definition.
493
+ * If the code is `f <- function(a=b, m=3) { if(m > 3) { b <- 1; }; a; b <- 5; a + 1 }`, we need a link to `b <- 1` and `b <- 6`
494
+ * as `b` can be defined by either one of them.
495
+ * <p>
496
+ * <b>Currently we may be unable to narrow down every definition within the body as we have not implemented ways to track what covers the first definitions precisely</b>
497
+ *
498
+ * Links a parameter default read to the body writes of the same name (may), returning whether any was linked.
499
+ */
499
500
  function linkParameterReadToBodyWrites(graph, read, writesByName) {
500
501
  const writingOuts = read.name === undefined ? undefined : writesByName.get(read.name);
501
502
  if (writingOuts === undefined) {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processIfThenElse = processIfThenElse;
4
4
  const match_args_1 = require("../../../../../graph/match-args");
5
5
  const processor_1 = require("../../../../../processor");
6
- const info_1 = require("../../../../../info");
7
6
  const known_call_handling_1 = require("../known-call-handling");
8
7
  const common_1 = require("../common");
9
8
  const unpack_argument_1 = require("../argument/unpack-argument");
@@ -54,7 +53,7 @@ function processIfThenElse(name, args, rootId, data, config) {
54
53
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
55
54
  }
56
55
  const cond = (0, processor_1.processDataflowFor)(condArg, data);
57
- if ((0, info_1.alwaysExits)(cond)) {
56
+ if (control_flow_1.ControlFlow.alwaysExits(cond)) {
58
57
  logger_1.dataflowLogger.warn(`If-then-else ${rootId} forces exit in condition, skipping rest`);
59
58
  return cond;
60
59
  }
@@ -35,7 +35,7 @@ function processLocal(name, args, rootId, data, config) {
35
35
  /* when envir resolves to a tracked environment, evaluate expr inside it */
36
36
  const envirResolution = env ? (0, built_in_envir_utils_1.resolveEnvirArg)(args, data, config.args.env) : undefined;
37
37
  const dfEnv = env ? (0, processor_1.processDataflowFor)(env, data) : info_1.DataflowInformation.initialize(rootId, data);
38
- if ((0, info_1.alwaysExits)(dfEnv)) {
38
+ if (control_flow_1.ControlFlow.alwaysExits(dfEnv)) {
39
39
  (0, common_1.patchFunctionCall)({
40
40
  nextGraph: dfEnv.graph,
41
41
  rootId,
@@ -1,5 +1,5 @@
1
1
  import type { DataflowProcessorInformation } from '../../../../../processor';
2
- import type { DataflowInformation } from '../../../../../info';
2
+ import { type DataflowInformation } from '../../../../../info';
3
3
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
5
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
@@ -45,6 +45,15 @@ function processQuote(name, args, rootId, data, config) {
45
45
  }
46
46
  const quotedProcessed = processedArguments[config.quoteArgumentsWithIndex];
47
47
  if (quotedProcessed) {
48
+ /*
49
+ * The expression is held on to rather than evaluated, so a `return` within it never runs and control
50
+ * arrives at the call. Every other jump the call catches already.
51
+ */
52
+ for (const exit of quotedProcessed.exitPoints) {
53
+ if (exit.type === 1 /* ExitPointType.Return */) {
54
+ information.graph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
55
+ }
56
+ }
48
57
  (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, [config.quoteArgumentsWithIndex], { evaluated });
49
58
  if (evaluated) {
50
59
  /* the argument was processed in a clean env, so the escaped reads need linking by hand */
@@ -35,7 +35,7 @@ function processS3Dispatch(name, args, rootId, data, config) {
35
35
  }
36
36
  const obj = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('object')?.[0]));
37
37
  const dfObj = obj ? (0, processor_1.processDataflowFor)(obj, data) : info_1.DataflowInformation.initialize(rootId, data);
38
- if ((0, info_1.alwaysExits)(dfObj)) {
38
+ if (control_flow_1.ControlFlow.alwaysExits(dfObj)) {
39
39
  (0, common_1.patchFunctionCall)({
40
40
  nextGraph: dfObj.graph,
41
41
  rootId,
@@ -106,9 +106,14 @@ function processTryCatch(name, args, rootId, data, config) {
106
106
  * raises is caught here as well, so it reaches the call rather than leaving it.
107
107
  */
108
108
  info.cfgExit = rootId;
109
- /* a `finally` runs whether the block completed or raised, so an error lands there before leaving the call */
109
+ /*
110
+ * An error the block raises lands on the handler when there is one, and the `finally` follows it, which the
111
+ * arguments being in sequence already says. Without either, the error simply arrives at the call.
112
+ */
113
+ const handler = res.processedArguments.find(arg => arg !== undefined && errorArg.has(arg.entryPoint));
110
114
  const cleanup = res.processedArguments.find(arg => arg !== undefined && finallyArg.has(arg.entryPoint));
111
- const caughtAt = cleanup === undefined ? rootId : control_flow_1.ControlFlow.entryOf(cleanup);
115
+ const caughtAt = handler !== undefined ? control_flow_1.ControlFlow.entryOf(handler)
116
+ : cleanup === undefined ? rootId : control_flow_1.ControlFlow.entryOf(cleanup);
112
117
  for (const arg of res.processedArguments) {
113
118
  if (arg === undefined || errorArg.has(arg.entryPoint) || finallyArg.has(arg.entryPoint)) {
114
119
  continue;
@@ -70,7 +70,7 @@ function processWhileLoop(name, args, rootId, data) {
70
70
  const conditionIsAlwaysTrue = values?.elements.every(d => d.type === 'logical' && d.value === true) ?? false;
71
71
  (0, assert_1.guard)(condition !== undefined && body !== undefined, () => `While-Loop ${identifier_1.Identifier.toString(name.content)} has no condition or body, impossible!`);
72
72
  const originalDependency = data.cds;
73
- if ((0, info_1.alwaysExits)(condition)) {
73
+ if (control_flow_1.ControlFlow.alwaysExits(condition)) {
74
74
  logger_1.dataflowLogger.warn(`While-Loop ${rootId} forces exit in condition, skipping rest`);
75
75
  information.graph.addEdge(nameId, condition.entryPoint, edge_1.EdgeType.Reads);
76
76
  return condition;
@@ -120,24 +120,24 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
120
120
  inIds.push(fnRef);
121
121
  // if force args is not none, we need to collect all non-default exit points from our arguments!
122
122
  let exitPoints = undefined;
123
- if (forceArgs === 'all') {
124
- const nonDefaults = processedArguments.flatMap(p => p ? p.exitPoints.filter(ep => ep.type !== 0 /* ExitPointType.Default */) : []);
125
- if (nonDefaults.length > 0) {
126
- exitPoints = nonDefaults;
127
- }
128
- }
129
- else if (forceArgs) {
130
- for (let i = 0; i < forceArgs.length; i++) {
131
- if (forceArgs[i]) {
132
- const p = processedArguments[i];
133
- if (p) {
134
- const nonDefaults = p.exitPoints.filter(ep => ep.type !== 0 /* ExitPointType.Default */);
135
- if (nonDefaults.length > 0) {
136
- exitPoints ??= [];
137
- exitPoints.push(...nonDefaults);
138
- }
123
+ /* a jump that only happens under a condition still lets the call complete, so its default exit has to stay */
124
+ let alwaysJumps = false;
125
+ if (forceArgs) {
126
+ for (let i = 0; i < processedArguments.length; i++) {
127
+ const p = processedArguments[i];
128
+ if (p === undefined || (forceArgs !== 'all' && !forceArgs[i])) {
129
+ continue;
130
+ }
131
+ const before = exitPoints?.length ?? 0;
132
+ for (const exit of p.exitPoints) {
133
+ if (exit.type !== 0 /* ExitPointType.Default */) {
134
+ (exitPoints ??= []).push(exit);
139
135
  }
140
136
  }
137
+ alwaysJumps ||= (exitPoints?.length ?? 0) > before && control_flow_1.ControlFlow.alwaysExits(p);
138
+ }
139
+ if (exitPoints !== undefined && !alwaysJumps) {
140
+ exitPoints.push({ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds });
141
141
  }
142
142
  }
143
143
  /* an alternative without a name is the default arm, which runs when nothing else matched */
@@ -151,7 +151,11 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
151
151
  */
152
152
  for (const argument of processedArguments) {
153
153
  for (const exit of argument?.exitPoints ?? []) {
154
- /* a `return` leaves the enclosing function whatever the call around it does with the argument */
154
+ /*
155
+ * A jump within an argument the call does not pass on resumes at the call. A `return` leaves the
156
+ * enclosing function wherever the argument runs at all, so only a call that never evaluates it
157
+ * may catch one (see `processQuote`).
158
+ */
155
159
  if (exit.type !== 0 /* ExitPointType.Default */ && exit.type !== 1 /* ExitPointType.Return */ && !exitPoints?.includes(exit)) {
156
160
  finalGraph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
157
161
  }
@@ -264,18 +264,6 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, (0, doc_files_1.getFileCo
264
264
 
265
265
  `), ' ')}
266
266
 
267
- Every ▶&nbsp;_Explore in Browser_ link above opens ${(0, doc_playground_1.linkToPlayground)('flowR\'s playground', { code: playgroundSample })},
268
- which runs the whole analysis locally in your browser, with no setup at all. Once it is open:
269
-
270
- | in the playground | what it does |
271
- | ----------------- | ------------ |
272
- | hover a name | what flowR knows about it: its value, its shape, its signature, and what the linter said |
273
- | ctrl-click a name | jump to where it is defined |
274
- | click a dependency | slice the script for it |
275
- | alt-click anything (or <kbd>alt</kbd>+<kbd>m</kbd>) | highlight it, so a link points at it; hold <kbd>shift</kbd> to highlight more than one |
276
- | _Copy link_ | hand the script, the highlights, and the layout to someone else as one url |
277
- | the _flowR repl_ drawer | every command the ${ctx.linkPage('wiki/Interface', 'repl', 'using-the-repl')} carries, over the script above |
278
-
279
267
  If you want to use flowR and the features it provides, feel free to check out the:
280
268
 
281
269
  - ${ctx.linkPage('flowr:vscode', 'Visual Studio Code')}/${ctx.linkPage('flowr:positron', 'Positron')}: provides access to flowR directly in VS Code and Positron (or [vscode.dev](https://vscode.dev/))
@@ -7,6 +7,7 @@ const bounded_set_domain_1 = require("../abstract-interpretation/domains/bounded
7
7
  const interval_domain_1 = require("../abstract-interpretation/domains/interval-domain");
8
8
  const lattice_1 = require("../abstract-interpretation/domains/lattice");
9
9
  const multi_value_state_domain_1 = require("../abstract-interpretation/domains/multi-value-state-domain");
10
+ const shape_inference_1 = require("../abstract-interpretation/data-frame/shape-inference");
10
11
  const state_abstract_domain_1 = require("../abstract-interpretation/domains/state-abstract-domain");
11
12
  const basic_cfg_guided_visitor_1 = require("../control-flow/basic-cfg-guided-visitor");
12
13
  const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
@@ -144,8 +145,12 @@ Joining the predecessors goes through ${ctx.link(`${absint_visitor_1.AbstractInt
144
145
  For \`if(u) 3 else 2\` the step onto \`3\` reports the condition \`u\` as the predecessor and the \`if\` as the branch, together with the outcome \`u\` had, so an analysis can pin the condition down on the way into a branch.
145
146
  The other direction is ${ctx.link(`${basic_cfg_guided_visitor_1.BasicCfgGuidedVisitor.name}::getDecidedConstructs`)}: standing on \`u\`, it names the \`if\` that \`u\` decides.
146
147
 
147
- Calls are not followed by default. Overriding ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}::shouldEnterCall`)} makes the visitor step into what a call dispatches to and continue with the state at the exit points of those functions, using ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}::enterCall`)}.
148
- A function that is already being interpreted is not entered again, so a recursive call stops at the second entry.
148
+ The analysis is interprocedural: it steps into what a call dispatches to and continues with the state at the exit points of those functions, using ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}::enterCall`)}.
149
+ This is what the ${ctx.linkConfig('abstractInterpretation.followCalls')} configuration switches off, and ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}::shouldEnterCall`)} is the hook to decide it per call.
150
+ Each call site hands its own arguments to the parameters of the function it enters, so what a function is worth depends on where it is called, and every definition a call may reach is entered with the state at the call, so what the call is worth is what either of them leaves behind.
151
+ A definition that calls itself is run until what it leaves behind and what its parameters are worth both stop moving: \`shrink(head(x, nrow(x) - 1))\` hands over fewer rows than it was given, so the parameters are as much part of the fixpoint as the result is, and both are widened once the rounds pass the threshold so that they must stop.
152
+ What a call is worth is only known when every way out of every definition it reaches is: a function that leaves a frame behind on one path and something else on another says nothing about its result, the same way \`if(u) df else 42\` does not.
153
+ This is how a ${ctx.link(shape_inference_1.DataFrameShapeInferenceVisitor)} shape flows through the functions a program defines.
149
154
 
150
155
  To implement a custom abstract interpretation analysis, we can just create a new class and extend the ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)}. The abstract interpretation visitor uses a \`StateDomain\` (e.g., a ${ctx.link(state_abstract_domain_1.StateAbstractDomain)}) to capture the current abstract state at each vertex in the control flow graph. We can then extend the callback functions of the ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)} to implement the abstract semantics of expressions, such as ${ctx.link(`${semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor.name}:::onNumberConstant`)}, ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}:::onFunctionCall`)} and ${ctx.link(`${semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor.name}:::onReplacementCall`)} (make sure to still call the respective super function). The abstract interpretation visitor provides the following functions to retrieve the currently inferred values:
151
156
 
@@ -293,6 +293,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
293
293
  },
294
294
  abstractInterpretation: {
295
295
  wideningThreshold: 4,
296
+ followCalls: true,
296
297
  dataFrame: {
297
298
  maxColNames: 20,
298
299
  readLoadedData: {
@@ -28,8 +28,10 @@ var DeprecationState;
28
28
  /** No longer works and is removed and replaced by another function {@link https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Defunct} */
29
29
  DeprecationState["Defunct"] = "defunct";
30
30
  })(DeprecationState || (exports.DeprecationState = DeprecationState = {}));
31
- /** `size` names the stroke width of every line-based geom until ggplot2 4.0.0 renamed it. */
32
- /** `size` gained `linewidth` beside it in ggplot2 3.4.0; 4.0.0 drops `size`. */
31
+ /**
32
+ * `size` names the stroke width of every line-based geom until ggplot2 4.0.0 renamed it: it gained
33
+ * `linewidth` beside it in 3.4.0, and 4.0.0 drops `size`.
34
+ */
33
35
  const GgplotLinewidth = {
34
36
  whenArgs: [{ argName: 'size', state: DeprecationState.Deprecated, replacedBy: 'linewidth', sinceVersion: r_version_1.RRange.parse('>= 3.4.0') }]
35
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.14.2",
3
+ "version": "2.14.3",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -121,6 +121,7 @@ export interface VersionAssignment {
121
121
  */
122
122
  readonly unverified?: readonly string[];
123
123
  }
124
+ /** default safety cap on how many assignments {@link explodeDependencyVersions} yields */
124
125
  export declare const DefaultExplodeLimit = 256;
125
126
  /** the date cutoff (end of the named day/month/year) for a `YYYY.MM.DD` spec, or `undefined` if malformed */
126
127
  export declare function dateCutoff(spec: string): Date | undefined;
@@ -43,13 +43,13 @@ const r_string_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-string");
43
43
  const arrays_1 = require("../util/collections/arrays");
44
44
  /** the pseudo-package standing for the analyzed project itself, never one of its own dependencies */
45
45
  exports.ProjectPackage = 'current';
46
- /** default safety cap on how many assignments {@link explodeDependencyVersions} yields */
47
46
  /** the dependency kinds a load has to satisfy, as `Suggests`/`Enhances` are not enforced when a package is attached */
48
47
  const LoadRelevantDeps = new Set([0 /* DepType.Depends */, 1 /* DepType.Imports */, 2 /* DepType.LinkingTo */]);
49
48
  /** The requirements `pkg@version` places on other packages that a load has to satisfy (see {@link LoadRelevantDeps}). */
50
49
  function loadRequirements(src, pkg, version) {
51
50
  return (src?.dependencies(pkg, version) ?? []).filter(d => LoadRelevantDeps.has(d.type));
52
51
  }
52
+ /** default safety cap on how many assignments {@link explodeDependencyVersions} yields */
53
53
  exports.DefaultExplodeLimit = 256;
54
54
  /** the date cutoff (end of the named day/month/year) for a `YYYY.MM.DD` spec, or `undefined` if malformed */
55
55
  function dateCutoff(spec) {
@@ -1,11 +1,11 @@
1
- import { type EngineConfig, FlowrConfig } from '../config';
2
- import type { DeepWritable, PathValue } from 'ts-essentials';
1
+ import { type EngineConfig, FlowrConfig, type ValidFlowrConfigPaths } from '../config';
2
+ import type { DeepWritable } from 'ts-essentials';
3
3
  import { FlowrAnalyzer } from './flowr-analyzer';
4
4
  import type { KnownParser } from '../r-bridge/parser';
5
5
  import type { FlowrAnalyzerPlugin } from './plugins/flowr-analyzer-plugin';
6
6
  import type { NormalizeRequiredInput } from '../core/steps/all/core/10-normalize';
7
7
  import type { BuiltInFlowrPluginName, PluginToRegister } from './plugins/plugin-registry';
8
- import type { AutocompletablePaths } from '../util/objects';
8
+ import type { ValueAtPath } from '../util/objects';
9
9
  /**
10
10
  * Builder for the {@link FlowrAnalyzer}, use it to configure all analysis aspects before creating the analyzer instance
11
11
  * with {@link FlowrAnalyzerBuilder#build|`.build()`} or {@link FlowrAnalyzerBuilder#buildSync|`.buildSync()`}.
@@ -62,7 +62,7 @@ export declare class FlowrAnalyzerBuilder {
62
62
  /**
63
63
  * Set a specific value in the configuration used by the resulting analyzer.
64
64
  */
65
- configure<K extends AutocompletablePaths<FlowrConfig>>(key: K, value: PathValue<FlowrConfig, K>): this;
65
+ configure<K extends ValidFlowrConfigPaths>(key: K, value: ValueAtPath<FlowrConfig, K>): this;
66
66
  /**
67
67
  * Set the parser instance used by the analyzer.
68
68
  * This is an alternative to {@link FlowrAnalyzerBuilder#setEngine} if you already have a parser instance.
@@ -170,6 +170,12 @@ export interface OpenSyncOptions {
170
170
  export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
171
171
  hash?: string;
172
172
  }
173
+ /**
174
+ * Fast, partial reader for a single bundle. `open()`/`openSync()` load the string dictionary + `.idx`
175
+ * once (a single ranged read of the dictionary section, no full parse), then every query seeks straight
176
+ * to one package blob on demand. `open()` additionally decompresses a `.br`/`.gz` source into a
177
+ * hash-keyed cache and reuses it on later startups. Implements {@link PackageSignatureSource}.
178
+ */
173
179
  export declare class SigDatabase implements PackageSignatureSource {
174
180
  private closed;
175
181
  /** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */