@eagleoutice/flowr 2.17.10 → 2.17.11

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.
@@ -173,7 +173,7 @@ function statedRoles(definition, state) {
173
173
  function add(node, props) {
174
174
  /* forcing `if(c) a else b` evaluates only one of `a` and `b`, so neither is forced for certain */
175
175
  const always = (props & built_in_props_1.ArgProp.Forced) === 0 ? undefined : identityFrom(node, state, 0, new Set()).found;
176
- const written = writtenFormal(node, byName, state);
176
+ const written = writtenFormal(node, byName, state, true);
177
177
  for (const formal of aliasTargets(node, byName, state)) {
178
178
  const own = always === undefined || always.has(formal) || formal === written ? props : props & ~built_in_props_1.ArgProp.Forced;
179
179
  roles.set(formal, (roles.get(formal) ?? 0) | own);
@@ -234,10 +234,23 @@ function aliasTargets(node, byName, state) {
234
234
  }
235
235
  return found;
236
236
  }
237
- /** The formal parameter a symbol argument names. */
238
- function writtenFormal(node, byName, state) {
237
+ /**
238
+ * The formal parameter a symbol argument names, as long as the name still holds it: a symbol nothing links
239
+ * (`missing(a)`) is taken by its name, one that reads bindings is the formal only if it may read the formal
240
+ * or, with `only`, if it reads nothing else. So in `v <- h(v); v + 1` the `v` of `v + 1` is not the formal.
241
+ */
242
+ function writtenFormal(node, byName, state, only = false) {
239
243
  const name = r_symbol_1.RSymbol.is(state.graph.idMap?.get(node)) ? node_id_1.NodeId.recoverBareName(node, state.graph.idMap) : undefined;
240
- return name === undefined ? undefined : byName.get(name);
244
+ const formal = name === undefined ? undefined : byName.get(name);
245
+ if (formal === undefined) {
246
+ return undefined;
247
+ }
248
+ if (!vertex_1.DfgVertex.isUse(state.graph.getVertex(node))) {
249
+ /* the target of a replacement (`x[1] <- 2`) is the formal it changes a copy of */
250
+ return formal;
251
+ }
252
+ const read = df_helper_1.Dataflow.bindingsReadBy(node, state.graph);
253
+ return read.length === 0 || (only ? read.every(t => t === formal) : read.includes(formal)) ? formal : undefined;
241
254
  }
242
255
  /** The formals of `definition` by name, for {@link writtenFormal}. */
243
256
  function formalsByName(definition, state) {
@@ -287,8 +287,12 @@ function strictnessOfParameter(param, definition, state) {
287
287
  /* a `NextMethod` hands the parameter on unforced, the methods it reaches decide below */
288
288
  if (!vertex_1.DfgVertex.hasOrigin(state.graph.getVertex(read), built_in_proc_name_1.BuiltInProcName.S3DispatchNext)) {
289
289
  const { value, onlyUnder = [] } = forces(read, definition, state);
290
- reads.push(value);
291
- branches.push(...onlyUnder);
290
+ /* a read that may also be of a rebinding (`if(c) v <- h(v); v + 1`) forces the parameter only where it was not rebound */
291
+ const rebound = vertex_1.DfgVertex.isUse(state.graph.getVertex(read)) && df_helper_1.Dataflow.bindingsReadBy(read, state.graph).some(b => b !== param);
292
+ reads.push(rebound ? weaken(value) : value);
293
+ if (!rebound) {
294
+ branches.push(...onlyUnder);
295
+ }
292
296
  }
293
297
  }
294
298
  if (info_1.ControlDependency.happensInEveryBranch(branches)) {
@@ -56,6 +56,11 @@ export declare const Dataflow: {
56
56
  readonly callsIn: (this: void, definition: DataflowGraphVertexFunctionDefinition, graph: DataflowGraph) => Generator<[NodeId, DataflowGraphVertexFunctionCall]>;
57
57
  /** The value a plain assignment binds to the definition `def`, `undefined` for any other kind of definition (`class(x) <- `, `assign`, a parameter, ...). */
58
58
  readonly assignedValueOf: (this: void, def: NodeId, graph: DataflowGraph) => NodeId | undefined;
59
+ /**
60
+ * The bindings a read of a variable may take its value from, a replacement (`x[1] <- 2`) followed to the
61
+ * bindings it changed a copy of. Other vertices a read links to (the calls a `return` or an `if` may tie it to) are none of them.
62
+ */
63
+ readonly bindingsReadBy: (this: void, id: NodeId, graph: DataflowGraph) => NodeId[];
59
64
  /** The vertices the value at `id` originates from: an argument is followed to its value, a read to the definitions it reads, a definition to what it is defined by (other than the assignment making it) or, for a replacement (`e$f <- v`), to what the variable held before, and with `throughAccess` an access to what it accesses. */
60
65
  readonly valueSources: (this: void, id: NodeId, graph: DataflowGraph, opts?: {
61
66
  readonly throughAccess?: boolean;
@@ -148,6 +148,28 @@ exports.Dataflow = {
148
148
  const byAssignment = exports.Dataflow.targetsOf(graph, def, edge_1.EdgeType.DefinedBy).some(t => vertex_1.DfgVertex.hasOrigin(graph.getVertex(t), built_in_proc_name_1.BuiltInProcName.Assignment));
149
149
  return vertex_1.DfgVertex.isVariableDefinition(vertex) && byAssignment && vertex.source?.length === 1 ? vertex.source[0] : undefined;
150
150
  },
151
+ /**
152
+ * The bindings a read of a variable may take its value from, a replacement (`x[1] <- 2`) followed to the
153
+ * bindings it changed a copy of. Other vertices a read links to (the calls a `return` or an `if` may tie it to) are none of them.
154
+ */
155
+ bindingsReadBy(id, graph) {
156
+ const found = [];
157
+ const seen = new Set();
158
+ const todo = exports.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads);
159
+ for (let at = todo.pop(); at !== undefined; at = todo.pop()) {
160
+ if (seen.has(at) || !vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(at))) {
161
+ continue;
162
+ }
163
+ seen.add(at);
164
+ if (graph.idMap?.get(at)?.info.role === "acc" /* RoleInParent.Accessed */) {
165
+ todo.push(...exports.Dataflow.targetsOf(graph, at, edge_1.EdgeType.Reads));
166
+ }
167
+ else {
168
+ found.push(at);
169
+ }
170
+ }
171
+ return found;
172
+ },
151
173
  /** The vertices the value at `id` originates from: an argument is followed to its value, a read to the definitions it reads, a definition to what it is defined by (other than the assignment making it) or, for a replacement (`e$f <- v`), to what the variable held before, and with `throughAccess` an access to what it accesses. */
152
174
  valueSources(id, graph, opts) {
153
175
  const budget = opts?.budget ?? 256;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.17.10",
3
+ "version": "2.17.11",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -3,6 +3,6 @@
3
3
  * @module
4
4
  */
5
5
  import { SemVer } from 'semver';
6
- export declare const versionDate = "2026-11-22T14:31:31Z";
6
+ export declare const versionDate = "2026-11-22T17:14:43Z";
7
7
  /** Retrieves the current flowR version as a new {@link SemVer} object. */
8
8
  export declare function flowrVersion(): SemVer;
@@ -8,9 +8,9 @@ exports.flowrVersion = flowrVersion;
8
8
  */
9
9
  const semver_1 = require("semver");
10
10
  // this is automatically replaced with the current version by release-it
11
- const version = '2.17.10';
11
+ const version = '2.17.11';
12
12
  // this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
13
- exports.versionDate = '2026-11-22T14:31:31Z';
13
+ exports.versionDate = '2026-11-22T17:14:43Z';
14
14
  /** Retrieves the current flowR version as a new {@link SemVer} object. */
15
15
  function flowrVersion() {
16
16
  return new semver_1.SemVer(version);