@eagleoutice/flowr 2.17.1 → 2.17.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.
- package/README.md +9 -9
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/data/r-reexports.generated.d.ts +4 -0
- package/data/r-reexports.generated.js +43 -0
- package/dataflow/environments/ambient-state-name.d.ts +4 -0
- package/dataflow/environments/ambient-state-name.js +4 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in-props.d.ts +2 -0
- package/dataflow/environments/built-in-props.js +3 -1
- package/dataflow/environments/built-in.d.ts +16 -6
- package/dataflow/environments/built-in.js +45 -4
- package/dataflow/environments/default-builtin-config.d.ts +846 -21
- package/dataflow/environments/default-builtin-config.js +120 -26
- package/dataflow/environments/environment.d.ts +19 -2
- package/dataflow/environments/environment.js +90 -19
- package/dataflow/environments/identifier.d.ts +18 -0
- package/dataflow/environments/query-fn-props.js +4 -3
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/eval/resolve/node-value.d.ts +1 -1
- package/dataflow/eval/resolve/node-value.js +2 -2
- package/dataflow/eval/resolve/resolve-argument.js +1 -1
- package/dataflow/extractor.js +20 -4
- package/dataflow/graph/df-helper.d.ts +42 -1
- package/dataflow/graph/df-helper.js +83 -0
- package/dataflow/info.d.ts +2 -0
- package/dataflow/info.js +4 -0
- package/dataflow/internal/linker.js +21 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +144 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +8 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +43 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +67 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +138 -89
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +87 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +23 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +18 -15
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +8 -7
- package/documentation/wiki-dataflow-graph.js +25 -1
- package/linter/rules/undefined-symbol.js +2 -2
- package/package.json +1 -1
- package/project/attached-packages.d.ts +11 -6
- package/project/attached-packages.js +37 -9
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +5 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +13 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +25 -2
- package/project/sigdb/build.js +7 -6
- package/project/sigdb/decode.d.ts +2 -0
- package/project/sigdb/decode.js +9 -3
- package/project/sigdb/schema.d.ts +8 -3
- package/queries/catalog/signature-query/signature-query-executor.js +15 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -2
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/model.js +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +12 -1
- package/reconstruct/reconstruct.js +2 -5
- package/search/search-executor/search-enrichers.js +17 -2
- package/search/search-executor/search-generators.js +6 -2
- package/slicing/static/slice-call.d.ts +16 -0
- package/slicing/static/slice-call.js +42 -0
- package/slicing/static/static-slicer.js +6 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
|
@@ -27,7 +27,9 @@ export declare enum EnvType {
|
|
|
27
27
|
/** `requireNamespace("pkg")`: `pkg::fn` resolves, bare `fn` does not */
|
|
28
28
|
LoadedNamespace = "lns",
|
|
29
29
|
/** A package `solver.assumeAttachedPackages` states as attached; a `library()` in the analyzed code still attaches it in full over this. */
|
|
30
|
-
AssumedNamespace = "ans"
|
|
30
|
+
AssumedNamespace = "ans",
|
|
31
|
+
/** Data `attach(what)` put on the search path, a list, data frame, or environment */
|
|
32
|
+
Attached = "att"
|
|
31
33
|
}
|
|
32
34
|
interface Jsonified {
|
|
33
35
|
id: NodeId;
|
|
@@ -129,7 +131,11 @@ export declare class Environment implements IEnvironment {
|
|
|
129
131
|
* memories have to be merged. Package blocks are always unioned, never overwritten or appended to.
|
|
130
132
|
*/
|
|
131
133
|
private mergeShortcut;
|
|
132
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
|
|
136
|
+
* A package only one block has is only maybe attached if the blocks are alternatives (appended: two branches, a
|
|
137
|
+
* loop body that may not run), or under `applyCds` if only `other` has it (a call in a branch attaching it).
|
|
138
|
+
*/
|
|
133
139
|
private mergePackageBlocks;
|
|
134
140
|
remove(id: Identifier): this;
|
|
135
141
|
removeAll(names: readonly {
|
|
@@ -156,6 +162,13 @@ export declare const GlobalEnvEntryName = ".GlobalEnv";
|
|
|
156
162
|
* ({@link DefaultAttachPosition|2} by default); a position past the end attaches above the built-in env, mirroring R's clamping.
|
|
157
163
|
*/
|
|
158
164
|
declare function attachPackageAt(this: void, current: Environment, blockTop: Environment, blockBottom: Environment, pos?: number): Environment;
|
|
165
|
+
/** Removes the entry at the 1-based `search()` position `pos` (`detach`), with its imports layer; `current` itself if there is none. */
|
|
166
|
+
declare function detachPackageAt(this: void, current: Environment, pos?: number): Environment;
|
|
167
|
+
/**
|
|
168
|
+
* `target` with the packages `source` attached as well: the search path is global, so what code evaluated in
|
|
169
|
+
* another environment attaches (`local(library(x), envir = e)`) is attached for the caller, too.
|
|
170
|
+
*/
|
|
171
|
+
declare function adoptSearchPathOf(this: void, target: Environment, source: Environment): Environment;
|
|
159
172
|
/**
|
|
160
173
|
* The 1-based `search()` position of the entry called `name` (`.GlobalEnv`, `package:x`, or a bare package name), or
|
|
161
174
|
* `undefined` if absent; `package:base` resolves to the built-in env at the bottom if base R is not attached as its own layer.
|
|
@@ -182,6 +195,10 @@ export declare const REnvironment: {
|
|
|
182
195
|
readonly searchPath: typeof searchPathOf;
|
|
183
196
|
/** Attaches a package block at a `search()` position, below the global by default; see {@link attachPackageAt}. */
|
|
184
197
|
readonly attachAt: typeof attachPackageAt;
|
|
198
|
+
/** Removes the entry at a `search()` position, the topmost by default; see {@link detachPackageAt}. */
|
|
199
|
+
readonly detachAt: typeof detachPackageAt;
|
|
200
|
+
/** Takes over what another evaluation attached to the (global) search path; see {@link adoptSearchPathOf}. */
|
|
201
|
+
readonly adoptSearchPath: typeof adoptSearchPathOf;
|
|
185
202
|
/** The `search()` position of a named entry; see {@link searchPositionOf}. */
|
|
186
203
|
readonly searchPosition: typeof searchPositionOf;
|
|
187
204
|
/** The packages on the search path; see {@link attachedPackagesOf}. */
|
|
@@ -27,6 +27,8 @@ var EnvType;
|
|
|
27
27
|
EnvType["LoadedNamespace"] = "lns";
|
|
28
28
|
/** A package `solver.assumeAttachedPackages` states as attached; a `library()` in the analyzed code still attaches it in full over this. */
|
|
29
29
|
EnvType["AssumedNamespace"] = "ans";
|
|
30
|
+
/** Data `attach(what)` put on the search path, a list, data frame, or environment */
|
|
31
|
+
EnvType["Attached"] = "att";
|
|
30
32
|
})(EnvType || (exports.EnvType = EnvType = {}));
|
|
31
33
|
/** Use only if you do not know the object type; otherwise rely on {@link IEnvironment#builtInEnv}. */
|
|
32
34
|
function isDefaultBuiltInEnvironment(obj) {
|
|
@@ -288,7 +290,7 @@ class Environment {
|
|
|
288
290
|
if (!other || this === other) {
|
|
289
291
|
return this;
|
|
290
292
|
}
|
|
291
|
-
const shortcut = this.mergeShortcut(other);
|
|
293
|
+
const shortcut = this.mergeShortcut(other, append, applyCds);
|
|
292
294
|
if (shortcut !== undefined) {
|
|
293
295
|
return shortcut;
|
|
294
296
|
}
|
|
@@ -328,16 +330,21 @@ class Environment {
|
|
|
328
330
|
* The environment a merge with `other` settles on without touching either memory, `undefined` if the
|
|
329
331
|
* memories have to be merged. Package blocks are always unioned, never overwritten or appended to.
|
|
330
332
|
*/
|
|
331
|
-
mergeShortcut(other) {
|
|
333
|
+
mergeShortcut(other, append, applyCds) {
|
|
332
334
|
if (this.t !== undefined || other.t !== undefined) {
|
|
333
|
-
return this.mergePackageBlocks(other);
|
|
335
|
+
return this.mergePackageBlocks(other, append, applyCds);
|
|
334
336
|
}
|
|
335
337
|
return this.builtInEnv || this.n !== other.n ? this : undefined;
|
|
336
338
|
}
|
|
337
|
-
/**
|
|
338
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
|
|
341
|
+
* A package only one block has is only maybe attached if the blocks are alternatives (appended: two branches, a
|
|
342
|
+
* loop body that may not run), or under `applyCds` if only `other` has it (a call in a branch attaching it).
|
|
343
|
+
*/
|
|
344
|
+
mergePackageBlocks(other, append, applyCds) {
|
|
339
345
|
const [thisLayers, thisBase] = splitLibraryLayers(this);
|
|
340
346
|
const [otherLayers, otherBase] = splitLibraryLayers(other);
|
|
347
|
+
const oneSided = (layer, fromOther) => append ? maybeLayer(layer) : fromOther && applyCds !== undefined ? maybeLayer(layer, applyCds) : undefined;
|
|
341
348
|
/*
|
|
342
349
|
* One block is the other plus the packages attached since (blocks grow at the front), so their union is
|
|
343
350
|
* the longer one and it is already in R's order: the most recently attached package is searched first,
|
|
@@ -348,10 +355,12 @@ class Environment {
|
|
|
348
355
|
: layersEndWith(otherLayers, thisLayers) ? otherLayers : undefined;
|
|
349
356
|
if (keep !== undefined) {
|
|
350
357
|
const base = thisBase.append(otherBase);
|
|
351
|
-
|
|
358
|
+
const onlyInKeep = keep.length - (keep === thisLayers ? otherLayers : thisLayers).length;
|
|
359
|
+
const front = keep.slice(0, onlyInKeep).map(l => oneSided(l, keep === otherLayers));
|
|
360
|
+
if (front.every(l => l === undefined) && keep === thisLayers && base === thisBase) {
|
|
352
361
|
return this;
|
|
353
362
|
}
|
|
354
|
-
return relinkLayers(keep.map(l => l.clone(false)), base);
|
|
363
|
+
return relinkLayers(keep.map((l, i) => front[i] ?? l.clone(false)), base);
|
|
355
364
|
}
|
|
356
365
|
/*
|
|
357
366
|
* Neither block is recognizably an extension of the other, so union them. The longer attach history goes
|
|
@@ -360,6 +369,8 @@ class Environment {
|
|
|
360
369
|
* Keyed by type and then by name, rather than by a `t:n` string built for every layer of every merge.
|
|
361
370
|
*/
|
|
362
371
|
const order = [];
|
|
372
|
+
const inBoth = new Set();
|
|
373
|
+
const fromOther = new Set();
|
|
363
374
|
const merged = new defaultmap_1.DefaultMap(() => new Map());
|
|
364
375
|
for (const layers of thisLayers.length > otherLayers.length ? [thisLayers, otherLayers] : [otherLayers, thisLayers]) {
|
|
365
376
|
for (const layer of layers) {
|
|
@@ -369,8 +380,11 @@ class Environment {
|
|
|
369
380
|
const cloned = layer.clone(false);
|
|
370
381
|
byName.set(layer.n, cloned);
|
|
371
382
|
order.push(cloned);
|
|
383
|
+
if (layers === otherLayers) {
|
|
384
|
+
fromOther.add(cloned);
|
|
385
|
+
}
|
|
372
386
|
}
|
|
373
|
-
else if (!existing.sameMemoryAs(layer)) {
|
|
387
|
+
else if (inBoth.add(existing) && !existing.sameMemoryAs(layer)) {
|
|
374
388
|
for (const [name, value] of layer.memory) {
|
|
375
389
|
const old = existing.memory.get(name);
|
|
376
390
|
if (old !== value) {
|
|
@@ -380,7 +394,7 @@ class Environment {
|
|
|
380
394
|
}
|
|
381
395
|
}
|
|
382
396
|
}
|
|
383
|
-
return relinkLayers(order, thisBase.append(otherBase));
|
|
397
|
+
return relinkLayers(order.map(l => inBoth.has(l) ? l : oneSided(l, fromOther.has(l)) ?? l), thisBase.append(otherBase));
|
|
384
398
|
}
|
|
385
399
|
remove(id) {
|
|
386
400
|
if (this.builtInEnv) {
|
|
@@ -469,22 +483,62 @@ exports.GlobalEnvEntryName = '.GlobalEnv';
|
|
|
469
483
|
* ({@link DefaultAttachPosition|2} by default); a position past the end attaches above the built-in env, mirroring R's clamping.
|
|
470
484
|
*/
|
|
471
485
|
function attachPackageAt(current, blockTop, blockBottom, pos = exports.DefaultAttachPosition) {
|
|
472
|
-
const clonedCurrent = current
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
486
|
+
const [clonedCurrent, anchor] = cloneToPosition(current, pos);
|
|
487
|
+
blockBottom.parent = anchor.parent; // the built-in env, or the packages attached further down
|
|
488
|
+
anchor.parent = blockTop;
|
|
489
|
+
return clonedCurrent;
|
|
490
|
+
}
|
|
491
|
+
/** Removes the entry at the 1-based `search()` position `pos` (`detach`), with its imports layer; `current` itself if there is none. */
|
|
492
|
+
function detachPackageAt(current, pos = exports.DefaultAttachPosition) {
|
|
493
|
+
const [clonedCurrent, anchor] = cloneToPosition(current, pos);
|
|
494
|
+
const entry = anchor.parent;
|
|
495
|
+
if (entry.builtInEnv || entry.t === undefined) {
|
|
496
|
+
return current;
|
|
497
|
+
}
|
|
498
|
+
anchor.parent = entry.parent.t === EnvType.Imports && entry.parent.n === entry.n ? entry.parent.parent : entry.parent;
|
|
499
|
+
return clonedCurrent;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* A copy of the frames from `current` down to the frame right above the 1-based `search()` position `pos`, walking past
|
|
503
|
+
* the `pos - 2` entries below the global; an imports layer belongs to the entry above it and is never one itself.
|
|
504
|
+
*/
|
|
505
|
+
function cloneToPosition(current, pos) {
|
|
506
|
+
const [cloned, global] = cloneToGlobal(current);
|
|
507
|
+
let anchor = global;
|
|
479
508
|
for (let skip = pos - exports.DefaultAttachPosition; skip > 0 && !anchor.parent.builtInEnv; skip--) {
|
|
480
509
|
do {
|
|
481
510
|
anchor.parent = anchor.parent.clone(false);
|
|
482
511
|
anchor = anchor.parent;
|
|
483
512
|
} while (anchor.parent.t === EnvType.Imports);
|
|
484
513
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
514
|
+
return [cloned, anchor];
|
|
515
|
+
}
|
|
516
|
+
/** A copy of the frames from `current` down to the global environment, so the search path below it can be changed; returns the copy and its global frame. */
|
|
517
|
+
function cloneToGlobal(current) {
|
|
518
|
+
const cloned = current.clone(false);
|
|
519
|
+
let global = cloned;
|
|
520
|
+
while (!global.globalEnv && !global.parent.builtInEnv) {
|
|
521
|
+
global.parent = global.parent.clone(false);
|
|
522
|
+
global = global.parent;
|
|
523
|
+
}
|
|
524
|
+
return [cloned, global];
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* `target` with the packages `source` attached as well: the search path is global, so what code evaluated in
|
|
528
|
+
* another environment attaches (`local(library(x), envir = e)`) is attached for the caller, too.
|
|
529
|
+
*/
|
|
530
|
+
function adoptSearchPathOf(target, source) {
|
|
531
|
+
const into = findGlobalEnvironment(target), from = findGlobalEnvironment(source);
|
|
532
|
+
if (!into.globalEnv || !from.globalEnv || into.parent === from.parent) {
|
|
533
|
+
return target;
|
|
534
|
+
}
|
|
535
|
+
const block = into.parent.overwrite(from.parent);
|
|
536
|
+
if (block === into.parent) {
|
|
537
|
+
return target;
|
|
538
|
+
}
|
|
539
|
+
const [cloned, global] = cloneToGlobal(target);
|
|
540
|
+
global.parent = block;
|
|
541
|
+
return cloned;
|
|
488
542
|
}
|
|
489
543
|
/**
|
|
490
544
|
* The 1-based `search()` position of the entry called `name` (`.GlobalEnv`, `package:x`, or a bare package name), or
|
|
@@ -536,6 +590,10 @@ exports.REnvironment = {
|
|
|
536
590
|
searchPath: searchPathOf,
|
|
537
591
|
/** Attaches a package block at a `search()` position, below the global by default; see {@link attachPackageAt}. */
|
|
538
592
|
attachAt: attachPackageAt,
|
|
593
|
+
/** Removes the entry at a `search()` position, the topmost by default; see {@link detachPackageAt}. */
|
|
594
|
+
detachAt: detachPackageAt,
|
|
595
|
+
/** Takes over what another evaluation attached to the (global) search path; see {@link adoptSearchPathOf}. */
|
|
596
|
+
adoptSearchPath: adoptSearchPathOf,
|
|
539
597
|
/** The `search()` position of a named entry; see {@link searchPositionOf}. */
|
|
540
598
|
searchPosition: searchPositionOf,
|
|
541
599
|
/** The packages on the search path; see {@link attachedPackagesOf}. */
|
|
@@ -581,6 +639,19 @@ function relinkLayers(layers, base) {
|
|
|
581
639
|
}
|
|
582
640
|
return current;
|
|
583
641
|
}
|
|
642
|
+
/** A copy of the package layer whose bindings hold under `cds`, or, without, only maybe (the empty cds, no branch named). */
|
|
643
|
+
function maybeLayer(layer, cds) {
|
|
644
|
+
const out = layer.clone(false);
|
|
645
|
+
const memory = layer.memory;
|
|
646
|
+
const asMaybe = (defs) => defs.map(d => cds !== undefined
|
|
647
|
+
? { ...d, cds: cds.concat(d.cds ?? []) }
|
|
648
|
+
: (0, info_1.happensInEveryBranch)(d.cds) ? { ...d, cds: d.cds?.slice() ?? [] } : d);
|
|
649
|
+
const lazy = memory instanceof frame_memory_1.Frame ? memory.lazy() : undefined;
|
|
650
|
+
out.adoptMap(lazy === undefined
|
|
651
|
+
? new Map([...memory].map(([name, defs]) => [name, asMaybe(defs)]))
|
|
652
|
+
: new frame_memory_1.LazyBindings(new Set(lazy.keys()), name => asMaybe(lazy.get(name) ?? []), `maybe|${info_1.ControlDependency.key(cds)}|${lazy.origin}`));
|
|
653
|
+
return out;
|
|
654
|
+
}
|
|
584
655
|
/** Splits a package block (a contiguous run of attached-package layers, see {@link EnvType}) into its layers and the env below them. */
|
|
585
656
|
function splitLibraryLayers(env) {
|
|
586
657
|
const layers = [];
|
|
@@ -225,6 +225,7 @@ export declare const enum PkgName {
|
|
|
225
225
|
Audio = "audio",
|
|
226
226
|
Av = "av",
|
|
227
227
|
AwsS3 = "aws.s3",
|
|
228
|
+
BiocManager = "BiocManager",
|
|
228
229
|
Box = "box",
|
|
229
230
|
Brew = "brew",
|
|
230
231
|
Callr = "callr",
|
|
@@ -234,6 +235,8 @@ export declare const enum PkgName {
|
|
|
234
235
|
CohortBuilder = "cohortBuilder",
|
|
235
236
|
Corrplot = "corrplot",
|
|
236
237
|
Cowplot = "cowplot",
|
|
238
|
+
Config = "config",
|
|
239
|
+
Conflicted = "conflicted",
|
|
237
240
|
Curl = "curl",
|
|
238
241
|
DataTable = "data.table",
|
|
239
242
|
Dbi = "DBI",
|
|
@@ -245,7 +248,9 @@ export declare const enum PkgName {
|
|
|
245
248
|
DoParallel = "doParallel",
|
|
246
249
|
DoSnow = "doSNOW",
|
|
247
250
|
Downloader = "downloader",
|
|
251
|
+
Dotenv = "dotenv",
|
|
248
252
|
Dplyr = "dplyr",
|
|
253
|
+
EasyPackages = "easypackages",
|
|
249
254
|
EbImage = "EBImage",
|
|
250
255
|
Emmeans = "emmeans",
|
|
251
256
|
ExperimentHub = "ExperimentHub",
|
|
@@ -272,6 +277,7 @@ export declare const enum PkgName {
|
|
|
272
277
|
GoogleCloudStorageR = "googleCloudStorageR",
|
|
273
278
|
GoogleDrive = "googledrive",
|
|
274
279
|
Haven = "haven",
|
|
280
|
+
Groundhog = "groundhog",
|
|
275
281
|
Here = "here",
|
|
276
282
|
Hmisc = "Hmisc",
|
|
277
283
|
HtmlTools = "htmltools",
|
|
@@ -284,7 +290,9 @@ export declare const enum PkgName {
|
|
|
284
290
|
Janitor = "janitor",
|
|
285
291
|
Jpeg = "jpeg",
|
|
286
292
|
Jsonlite = "jsonlite",
|
|
293
|
+
Knitr = "knitr",
|
|
287
294
|
Lattice = "lattice",
|
|
295
|
+
Librarian = "librarian",
|
|
288
296
|
Lim = "LIM",
|
|
289
297
|
Lme4 = "lme4",
|
|
290
298
|
LmTest = "lmtest",
|
|
@@ -294,13 +302,17 @@ export declare const enum PkgName {
|
|
|
294
302
|
Mass = "MASS",
|
|
295
303
|
Meltr = "meltr",
|
|
296
304
|
Mirai = "mirai",
|
|
305
|
+
Mockery = "mockery",
|
|
297
306
|
Msgr = "msgr",
|
|
298
307
|
Multcomp = "multcomp",
|
|
308
|
+
Needs = "needs",
|
|
299
309
|
Ncdf4 = "ncdf4",
|
|
300
310
|
NorTest = "nortest",
|
|
301
311
|
OpenImageR = "OpenImageR",
|
|
302
312
|
OpenXlsx = "openxlsx",
|
|
303
313
|
Osfr = "osfr",
|
|
314
|
+
Pak = "pak",
|
|
315
|
+
Pacman = "pacman",
|
|
304
316
|
Parallelly = "parallelly",
|
|
305
317
|
Patchwork = "patchwork",
|
|
306
318
|
Piggyback = "piggyback",
|
|
@@ -311,6 +323,7 @@ export declare const enum PkgName {
|
|
|
311
323
|
Promises = "promises",
|
|
312
324
|
Purrr = "purrr",
|
|
313
325
|
Qs = "qs",
|
|
326
|
+
Quarto = "quarto",
|
|
314
327
|
R6 = "R6",
|
|
315
328
|
Ragg = "ragg",
|
|
316
329
|
Raster = "raster",
|
|
@@ -331,10 +344,14 @@ export declare const enum PkgName {
|
|
|
331
344
|
Rlang = "rlang",
|
|
332
345
|
Rmatlab = "R.matlab",
|
|
333
346
|
RmethodsS3 = "R.methodsS3",
|
|
347
|
+
Renv = "renv",
|
|
348
|
+
Reticulate = "reticulate",
|
|
349
|
+
Rmarkdown = "rmarkdown",
|
|
334
350
|
Rnetcdf = "RNetCDF",
|
|
335
351
|
Roo = "R.oo",
|
|
336
352
|
Rprintf = "rprintf",
|
|
337
353
|
RsConnect = "rsconnect",
|
|
354
|
+
Rsqlite = "RSQLite",
|
|
338
355
|
Rstatix = "rstatix",
|
|
339
356
|
RstudioApi = "rstudioapi",
|
|
340
357
|
Rutils = "R.utils",
|
|
@@ -360,6 +377,7 @@ export declare const enum PkgName {
|
|
|
360
377
|
SvDialogs = "svDialogs",
|
|
361
378
|
Svglite = "svglite",
|
|
362
379
|
Sys = "sys",
|
|
380
|
+
Targets = "targets",
|
|
363
381
|
Tcltk = "tcltk",
|
|
364
382
|
Terra = "terra",
|
|
365
383
|
Texreg = "texreg",
|
|
@@ -265,15 +265,16 @@ function entriesOfMemory(builtIns) {
|
|
|
265
265
|
/* the index says what flowR *knows*, not what is in scope, so the packages R does not attach on startup
|
|
266
266
|
belong in it as much as the always-on built-ins do -- being gated changes when a name resolves, not
|
|
267
267
|
whether flowR can answer for it */
|
|
268
|
-
|
|
268
|
+
/* an entry of a package R does not attach keeps the package it belongs to, `config::get` is no `get` */
|
|
269
|
+
for (const [pkg, memory] of [[undefined, builtIns.builtInMemory], ...builtIns.packageMemory.entries()]) {
|
|
269
270
|
for (const [registered, definitions] of memory) {
|
|
270
271
|
for (const d of definitions) {
|
|
271
272
|
if (d.type !== identifier_1.ReferenceType.BuiltInFunction) {
|
|
272
273
|
continue;
|
|
273
274
|
}
|
|
274
275
|
const info = d.config;
|
|
275
|
-
const
|
|
276
|
-
|
|
276
|
+
const namespace = (d.name === undefined ? undefined : identifier_1.Identifier.getNamespace(d.name)) ?? pkg;
|
|
277
|
+
const name = namespace === undefined ? d.name ?? registered : identifier_1.Identifier.make(registered, namespace);
|
|
277
278
|
out.push({ name, props: info?.props, tags: info?.tags, sig: info?.sig, foldable: d.evalHandler !== undefined });
|
|
278
279
|
}
|
|
279
280
|
}
|
|
@@ -148,10 +148,12 @@ function resolveByTargetType(id, environment, target) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
if (allOk) {
|
|
151
|
+
/* a definite definition ends the walk, the maybe ones above it still count */
|
|
152
|
+
const result = definitions ? definitions.concat(definition) : definition;
|
|
151
153
|
if (flattenAt !== undefined) {
|
|
152
|
-
tailCacheOf(flattenAt, target).set(name,
|
|
154
|
+
tailCacheOf(flattenAt, target).set(name, result);
|
|
153
155
|
}
|
|
154
|
-
return
|
|
156
|
+
return result;
|
|
155
157
|
}
|
|
156
158
|
const filtered = allWanted ? definition : definition.filter(wantedType);
|
|
157
159
|
if (filtered.length > 0) {
|
|
@@ -208,7 +210,7 @@ function resolveByNameAnyType(id, environment) {
|
|
|
208
210
|
definition = definition.filter(({ name }) => name === undefined || !identifier_1.Identifier.accessesInternal(name));
|
|
209
211
|
}
|
|
210
212
|
if (definition.every(inEveryBranch)) {
|
|
211
|
-
return remember(environment, id, definition);
|
|
213
|
+
return remember(environment, id, definitions ? definitions.concat(definition) : definition);
|
|
212
214
|
}
|
|
213
215
|
else if (definition.length > 0) {
|
|
214
216
|
definitions = definitions ? definitions.concat(definition) : definition;
|
|
@@ -30,7 +30,7 @@ export declare const NodeValue: {
|
|
|
30
30
|
readonly of: <OtherInfo>(this: void, id: Target, against: Against<OtherInfo>, overrides?: Partial<ResolveInfo>) => ResolveResult;
|
|
31
31
|
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
32
32
|
readonly setOf: <OtherInfo>(this: void, id: Target, against: Against<OtherInfo>, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
|
|
33
|
-
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
33
|
+
/** The strings the node may hold, those of a vector of strings (`c("a", "b")`) included, `undefined` if it does not resolve to strings. */
|
|
34
34
|
readonly stringsOf: <OtherInfo>(this: void, id: Target, against: Against<OtherInfo>, overrides?: Partial<ResolveInfo>) => string[] | undefined;
|
|
35
35
|
/** The strings the node may hold, dropping every value that is not one (in contrast to {@link NodeValue.stringsOf}, which gives up on them). */
|
|
36
36
|
readonly knownStringsOf: <OtherInfo>(this: void, id: Target, against: Against<OtherInfo>, overrides?: Partial<ResolveInfo>) => string[];
|
|
@@ -40,10 +40,10 @@ exports.NodeValue = {
|
|
|
40
40
|
setOf(id, against, overrides) {
|
|
41
41
|
return (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(against, overrides)));
|
|
42
42
|
},
|
|
43
|
-
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
43
|
+
/** The strings the node may hold, those of a vector of strings (`c("a", "b")`) included, `undefined` if it does not resolve to strings. */
|
|
44
44
|
stringsOf(id, against, overrides) {
|
|
45
45
|
const resolved = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(against, overrides)));
|
|
46
|
-
return resolved ? (0, string_constants_1.collectStrings)(resolved.elements) : undefined;
|
|
46
|
+
return resolved ? (0, string_constants_1.collectStrings)(resolved.elements.flatMap(v => v.type === 'vector' && (0, r_value_1.isValue)(v.elements) ? v.elements : [v])) : undefined;
|
|
47
47
|
},
|
|
48
48
|
/** The strings the node may hold, dropping every value that is not one (in contrast to {@link NodeValue.stringsOf}, which gives up on them). */
|
|
49
49
|
knownStringsOf(id, against, overrides) {
|
|
@@ -98,7 +98,7 @@ function argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx,
|
|
|
98
98
|
* already in `opening` is skipped: in `gzfile(d)` with `d` unknown, the provenance of `d` leads back to that very call.
|
|
99
99
|
*/
|
|
100
100
|
function openedResourceOf(variableResolve, graph, argument, ctx, opening) {
|
|
101
|
-
for (const id of df_helper_1.Dataflow.provenance(argument, graph, undefined, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall)) {
|
|
101
|
+
for (const id of df_helper_1.Dataflow.provenance(argument, graph, undefined, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Returns)) {
|
|
102
102
|
if (opening.has(id)) {
|
|
103
103
|
continue;
|
|
104
104
|
}
|
package/dataflow/extractor.js
CHANGED
|
@@ -281,7 +281,8 @@ function normalizedPath(p) {
|
|
|
281
281
|
*/
|
|
282
282
|
function sharesFile(a, b) {
|
|
283
283
|
const [x, y] = [normalizedPath(a), normalizedPath(b)];
|
|
284
|
-
|
|
284
|
+
/* a `setwd` in between makes two paths with the same file name the same file (`f.txt`, then `../f.txt` from `sub`) */
|
|
285
|
+
return x === y || holds(x, y) || holds(y, x) || path_1.default.posix.basename(x) === path_1.default.posix.basename(y);
|
|
285
286
|
}
|
|
286
287
|
function holds(directory, file) {
|
|
287
288
|
return directory === '.' ? !path_1.default.posix.isAbsolute(file) && file !== '..' && !file.startsWith('../') : file.startsWith(directory.endsWith('/') ? directory : `${directory}/`);
|
|
@@ -348,8 +349,22 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
|
|
|
348
349
|
const reachedBy = (0, defaultmap_1.memoize)((id) => definitionsReachedBy(id, graph));
|
|
349
350
|
const where = { graph, idMap: graph.idMap, resolve: ctx.config.solver.variables, ctx, environment };
|
|
350
351
|
const pathOf = (0, defaultmap_1.memoize)((id) => resolve_helper_1.Resolve.toSingleString(id, where));
|
|
352
|
+
/* every `tempfile()` call names a file of its own, so paths made from different ones differ */
|
|
353
|
+
const tempFiles = (0, defaultmap_1.memoize)((id) => new Set([...df_helper_1.Dataflow.provenance(r_argument_1.RArgument.valueOf(graph.idMap?.get(id))?.info.id ?? id, graph)]
|
|
354
|
+
.filter(v => {
|
|
355
|
+
const call = graph.getVertex(v);
|
|
356
|
+
return vertex_1.DfgVertex.isFunctionCall(call) && call.name !== undefined && identifier_1.Identifier.getName(call.name) === 'tempfile'
|
|
357
|
+
&& function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(v, { graph, environment }), [built_in_props_1.SemanticCallTag.TempFile]);
|
|
358
|
+
})));
|
|
351
359
|
const sameResource = (a, b) => {
|
|
352
|
-
if (a === b
|
|
360
|
+
if (a === b) {
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
const [ta, tb] = [tempFiles(a), tempFiles(b)];
|
|
364
|
+
if (ta.size > 0 && tb.size > 0 && ta.isDisjointFrom(tb)) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
else if (!reachedBy(b).isDisjointFrom(reachedBy(a))) {
|
|
353
368
|
return true;
|
|
354
369
|
}
|
|
355
370
|
/* a path we cannot resolve may name the other one */
|
|
@@ -463,7 +478,8 @@ function separateFileWritesPerCall(graph, environment, ctx) {
|
|
|
463
478
|
const body = graph.getVertex(definition).subflow.graph;
|
|
464
479
|
/* what holds the definition (`(function(p) ...)`) is no reader of what its body writes */
|
|
465
480
|
const holders = new Set([...model_1.RNode.iterateParents(idMap.get(at), idMap)].map(n => n.info.id));
|
|
466
|
-
|
|
481
|
+
/* a function reading the file reads it where it is called */
|
|
482
|
+
const readers = df_helper_1.Dataflow.sourcesOf(graph, at, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall).filter(r => !body.has(r) && !holders.has(r) && !calls.some(c => c.call === r));
|
|
467
483
|
for (const { call, paths } of calls) {
|
|
468
484
|
for (const reader of readers) {
|
|
469
485
|
const read = readPaths(reader);
|
|
@@ -616,7 +632,7 @@ function extractDataFlowGraph(parser, completeAst, ctx) {
|
|
|
616
632
|
(0, transitive_side_effects_1.reResolveOpenReferences)(df.graph, df.environment, [...df.in, ...df.unknownReferences], escapedNames);
|
|
617
633
|
}
|
|
618
634
|
// link on-demand-materialized package exports back to their `library()` loaders
|
|
619
|
-
(0, transitive_side_effects_1.linkMaterializedExportsToLoaders)(df.graph, df.environment);
|
|
635
|
+
(0, transitive_side_effects_1.linkMaterializedExportsToLoaders)(df.graph, df.environment, ctx);
|
|
620
636
|
const cleanEnvironment = ctx.env.makeCleanEnv();
|
|
621
637
|
(0, linker_1.separateClosureInstances)(df.graph, name => (0, query_fn_props_1.queryFnProps)(name, { environment: cleanEnvironment }));
|
|
622
638
|
function_semantics_1.FunctionSemantics.call.quoted.finalize(df.graph, df.environment, completeAst.idMap, () => new control_flow_graph_1.ControlFlowGraph(df.graph));
|
|
@@ -4,10 +4,12 @@ import { emptyGraph } from './dataflowgraph-builder';
|
|
|
4
4
|
import { getOriginInDfg } from '../origin/dfg-get-origin';
|
|
5
5
|
import { ambientWritesOfFunctions, computeCallGraphSummaries, propagateTransitiveSideEffects } from '../internal/process/functions/call/built-in/transitive-side-effects';
|
|
6
6
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
-
import type { REnvironmentInformation } from '../environments/environment';
|
|
8
7
|
import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexInfo } from './vertex';
|
|
9
8
|
import { Identifier } from '../environments/identifier';
|
|
10
9
|
import { DefaultMap } from '../../util/collections/defaultmap';
|
|
10
|
+
import type { FlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
11
|
+
import { type AttachSpec } from '../internal/process/functions/call/built-in/built-in-library';
|
|
12
|
+
import { type Environment, type REnvironmentInformation } from '../environments/environment';
|
|
11
13
|
/**
|
|
12
14
|
* This is the root helper object to work with the {@link DataflowGraph}.
|
|
13
15
|
*
|
|
@@ -18,6 +20,7 @@ import { DefaultMap } from '../../util/collections/defaultmap';
|
|
|
18
20
|
* - {@link Dataflow.calleesOf}/{@link Dataflow.calleeIdsOf}/{@link Dataflow.callTargetsOf}/{@link Dataflow.callsIn} - for what a call calls and what a definition calls,
|
|
19
21
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
20
22
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
23
|
+
* - {@link Dataflow.library} - for what `library(pkg)` attaches, loads, and puts on the search path, without analyzing any code,
|
|
21
24
|
*
|
|
22
25
|
* What it used to re-expose under a second name is imported directly instead: {@link DfEdge} for the edges,
|
|
23
26
|
* {@link CallGraph} for the call-graph view, {@link Resolve} for name and value resolution, and
|
|
@@ -204,6 +207,28 @@ export declare const Dataflow: {
|
|
|
204
207
|
* @see {@link Dataflow.provenance}
|
|
205
208
|
*/
|
|
206
209
|
readonly provenanceGraph: (this: void, id: NodeId, graph: DataflowGraph, consider?: ReadonlySet<NodeId>) => DataflowGraph;
|
|
210
|
+
/**
|
|
211
|
+
* What `library(pkg)` does, asked without analyzing any code.
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const ctx = analyzer.context();
|
|
215
|
+
* Dataflow.library.attaches(ctx, 'tidyverse'); // the search() entries it adds
|
|
216
|
+
* Dataflow.library.loads(ctx, 'tidyverse'); // every namespace it loads
|
|
217
|
+
* Dataflow.library.layers(ctx, 'tidyverse'); // the namespace and imports environments themselves
|
|
218
|
+
* Dataflow.library.reexports(ctx, 'dplyr'); // the exports it takes from others, `%>%` from magrittr included
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
readonly library: {
|
|
222
|
+
readonly name: "library";
|
|
223
|
+
/** The `search()` entries `library(pkg)` adds; see {@link libraryAttachesOf}. */
|
|
224
|
+
readonly attaches: typeof libraryAttachesOf;
|
|
225
|
+
/** The namespaces `library(pkg)` loads; see {@link libraryLoadsOf}. */
|
|
226
|
+
readonly loads: typeof libraryLoadsOf;
|
|
227
|
+
/** The environment layers `library(pkg)` adds to the search path; see {@link libraryLayersOf}. */
|
|
228
|
+
readonly layers: typeof libraryLayersOf;
|
|
229
|
+
/** The exports of `pkg` that re-export another package's function, with that package; see {@link libraryReexportsOf}. */
|
|
230
|
+
readonly reexports: typeof libraryReexportsOf;
|
|
231
|
+
};
|
|
207
232
|
readonly visualize: {
|
|
208
233
|
readonly mermaid: {
|
|
209
234
|
readonly name: "DataflowMermaid";
|
|
@@ -233,3 +258,19 @@ export declare const Dataflow: {
|
|
|
233
258
|
readonly reachable: <G extends DataflowGraph>(this: void, graph: G, seed: NodeId | Iterable<NodeId>, { follow, consider, cds, stopAt }?: import("./graph-helper").ReachOptions) => Set<NodeId>;
|
|
234
259
|
readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: DefaultMap<NodeId, Set<NodeId>>) => boolean;
|
|
235
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* The layers `library(pkg)` puts on an empty search path, innermost first, built by the {@link attachLibrary} the
|
|
263
|
+
* analysis uses: per attached package its namespace (exports) and imports layer, or for an unresolved one what flowR
|
|
264
|
+
* states about it or a bare {@link EnvType.LoadedNamespace}. `layer.n` is the package, `layer.t` the type, `layer.memory` the bindings.
|
|
265
|
+
*/
|
|
266
|
+
declare function libraryLayersOf(this: void, ctx: FlowrAnalyzerContext, pkg: string, spec?: AttachSpec): readonly Environment[];
|
|
267
|
+
/** The `search()` entries `library(pkg)` adds, in `search()` order: `pkg`, its `Depends` and a meta-package's core set, recursively. */
|
|
268
|
+
declare function libraryAttachesOf(this: void, ctx: FlowrAnalyzerContext, pkg: string, spec?: AttachSpec): readonly string[];
|
|
269
|
+
/**
|
|
270
|
+
* The exports of `pkg` it re-exports from another package, mapped to that package (`%>%` of dplyr to `magrittr`).
|
|
271
|
+
* The analysis keeps such an export as one of `pkg` (`dplyr::%>%`), so both stay apart; this tells where it comes from.
|
|
272
|
+
*/
|
|
273
|
+
declare function libraryReexportsOf(this: void, ctx: FlowrAnalyzerContext, pkg: string): ReadonlyMap<string, string>;
|
|
274
|
+
/** The namespaces `library(pkg)` loads, `pkg` first: the closure over {@link directLoadsOf} at the versions the analysis assumes. */
|
|
275
|
+
declare function libraryLoadsOf(this: void, ctx: FlowrAnalyzerContext, pkg: string): readonly string[];
|
|
276
|
+
export {};
|