@eagleoutice/flowr 2.13.2 → 2.13.4
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 +45 -43
- package/abstract-interpretation/absint-visitor.js +2 -2
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +1 -1
- package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
- package/abstract-interpretation/unsupported-functions.js +1 -1
- package/config.d.ts +8 -0
- package/config.js +9 -1
- package/control-flow/cfg-dead-code.js +72 -11
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/extract-cfg.js +85 -8
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- 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.d.ts +5 -1
- package/dataflow/environments/built-in.js +5 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.d.ts +59 -4
- package/dataflow/environments/default-builtin-config.js +23 -11
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/identifier.d.ts +1 -0
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +3 -1
- package/dataflow/eval/resolve/alias-tracking.js +8 -1
- package/dataflow/eval/resolve/resolve.d.ts +14 -0
- package/dataflow/eval/resolve/resolve.js +47 -0
- package/dataflow/fn/higher-order-function.js +3 -3
- package/dataflow/fn/recursive-function.js +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/vertex.d.ts +32 -25
- package/dataflow/graph/vertex.js +40 -36
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +28 -29
- 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 +41 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +45 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +14 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +80 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +63 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +63 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +29 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +35 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +55 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +24 -0
- package/dataflow/internal/process/functions/process-parameter.js +2 -1
- package/documentation/doc-readme.js +14 -12
- package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +4 -24
- package/documentation/wiki-query.js +47 -0
- package/documentation/wiki-signature-database.js +3 -2
- package/linter/rules/absolute-path.js +1 -1
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/no-leaked-credentials.js +1 -1
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +4 -5
- package/linter/rules/unused-definition.js +15 -10
- package/linter/rules/useless-loop.js +1 -1
- package/package.json +21 -9
- package/project/context/flowr-analyzer-context.d.ts +4 -4
- package/project/context/flowr-analyzer-context.js +3 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +11 -5
- package/project/context/flowr-analyzer-dependencies-context.js +8 -3
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/dependency-version-space.d.ts +118 -26
- package/project/dependency-version-space.js +343 -87
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
- 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 +4 -4
- package/project/plugins/package-version-plugins/package.d.ts +27 -10
- package/project/plugins/package-version-plugins/package.js +50 -25
- package/project/sigdb/reader.d.ts +26 -16
- package/project/sigdb/reader.js +52 -21
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +23 -24
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +53 -23
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +14 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +109 -20
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +45 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +22 -3
- package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
- package/queries/catalog/input-sources-query/input-types.js +64 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +76 -53
- package/queries/catalog/input-sources-query/simple-input-classifier.js +358 -101
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-executor.js +112 -39
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
- package/queries/catalog/signature-query/signature-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +8 -3
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/reconstruct/inline/source-inline-map.js +1 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- package/util/mermaid/dfg.js +1 -1
- package/util/objects.js +6 -4
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -0
- package/util/r-license.js +1 -4
- package/util/r-version.d.ts +12 -0
- package/util/r-version.js +16 -0
- package/util/range.d.ts +6 -2
- package/util/range.js +33 -15
- package/util/version.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REnvironment = exports.Environment = exports.EnvType = void 0;
|
|
3
|
+
exports.REnvironment = exports.GlobalEnvEntryName = exports.SearchPathPackagePrefix = exports.DefaultAttachPosition = exports.Environment = exports.EnvType = void 0;
|
|
4
4
|
exports.isDefaultBuiltInEnvironment = isDefaultBuiltInEnvironment;
|
|
5
5
|
exports.builtInEnvJsonReplacer = builtInEnvJsonReplacer;
|
|
6
6
|
/**
|
|
@@ -381,20 +381,71 @@ function findGlobalEnvironment(env) {
|
|
|
381
381
|
}
|
|
382
382
|
return current;
|
|
383
383
|
}
|
|
384
|
+
/** The `search()` position directly below the global environment; where R attaches by default. */
|
|
385
|
+
exports.DefaultAttachPosition = 2;
|
|
386
|
+
/** Prefix of a package's entry in R's `search()` list. */
|
|
387
|
+
exports.SearchPathPackagePrefix = 'package:';
|
|
388
|
+
/** Name of the global environment in R's `search()` list. */
|
|
389
|
+
exports.GlobalEnvEntryName = '.GlobalEnv';
|
|
384
390
|
/**
|
|
385
|
-
* Splices a package block (`blockTop`..`blockBottom`)
|
|
391
|
+
* Splices a package block (`blockTop`..`blockBottom`) into the search path at the 1-based `search()` position `pos`
|
|
392
|
+
* ({@link DefaultAttachPosition|2} being directly below the global environment, the default). A position past the end
|
|
393
|
+
* of the search path attaches directly above the built-in environment, mirroring R's clamping. Returns a fresh
|
|
394
|
+
* `current`, cloning only the path down to the insertion point.
|
|
386
395
|
*/
|
|
387
|
-
function
|
|
396
|
+
function attachPackageAt(current, blockTop, blockBottom, pos = exports.DefaultAttachPosition) {
|
|
388
397
|
const clonedCurrent = current.clone(false);
|
|
389
|
-
let
|
|
390
|
-
while (!
|
|
391
|
-
|
|
392
|
-
|
|
398
|
+
let anchor = clonedCurrent;
|
|
399
|
+
while (!anchor.globalEnv && !anchor.parent.builtInEnv) {
|
|
400
|
+
anchor.parent = anchor.parent.clone(false);
|
|
401
|
+
anchor = anchor.parent;
|
|
393
402
|
}
|
|
394
|
-
|
|
395
|
-
|
|
403
|
+
/* walk past the `pos - 2` search entries below the global; an imports layer belongs to the entry above it and is never one itself */
|
|
404
|
+
for (let skip = pos - exports.DefaultAttachPosition; skip > 0 && !anchor.parent.builtInEnv; skip--) {
|
|
405
|
+
do {
|
|
406
|
+
anchor.parent = anchor.parent.clone(false);
|
|
407
|
+
anchor = anchor.parent;
|
|
408
|
+
} while (anchor.parent.t === EnvType.Imports);
|
|
409
|
+
}
|
|
410
|
+
blockBottom.parent = anchor.parent; // the built-in env, or the packages attached further down
|
|
411
|
+
anchor.parent = blockTop;
|
|
396
412
|
return clonedCurrent;
|
|
397
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* The 1-based `search()` position of the entry called `name` (`.GlobalEnv`, `package:x`, or a bare package name),
|
|
416
|
+
* or `undefined` if no such entry is on the search path. `package:base` resolves to the built-in environment at the
|
|
417
|
+
* very bottom if base R is not attached as its own layer.
|
|
418
|
+
*/
|
|
419
|
+
function searchPositionOf(env, name) {
|
|
420
|
+
const target = name.startsWith(exports.SearchPathPackagePrefix) ? name.slice(exports.SearchPathPackagePrefix.length) : name;
|
|
421
|
+
if (target === exports.GlobalEnvEntryName) {
|
|
422
|
+
return 1;
|
|
423
|
+
}
|
|
424
|
+
let pos = 1;
|
|
425
|
+
for (let e = findGlobalEnvironment(env).parent; !e.builtInEnv; e = e.parent) {
|
|
426
|
+
if (e.t === EnvType.Imports) {
|
|
427
|
+
continue; // internal layer, not a search-path entry
|
|
428
|
+
}
|
|
429
|
+
pos++;
|
|
430
|
+
if (e.n === target) {
|
|
431
|
+
return pos;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return target === "base" /* PkgName.Base */ ? pos + 1 : undefined; // base is the built-in env when it is not attached as a layer
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* The packages attached below the global environment, i.e. those whose exports R resolves without a namespace.
|
|
438
|
+
* Base is always among them, as it backs the built-in environment even when it is no layer of its own.
|
|
439
|
+
*/
|
|
440
|
+
function attachedPackagesOf(env) {
|
|
441
|
+
const attached = new Set(["base" /* PkgName.Base */]);
|
|
442
|
+
for (let e = findGlobalEnvironment(env).parent; !e.builtInEnv; e = e.parent) {
|
|
443
|
+
if (e.t !== EnvType.Imports && e.n !== undefined) {
|
|
444
|
+
attached.add(e.n);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return attached;
|
|
448
|
+
}
|
|
398
449
|
/**
|
|
399
450
|
* Helpers for navigating and manipulating {@link REnvironmentInformation|environments} around the global environment and attached-package search path.
|
|
400
451
|
*/
|
|
@@ -402,8 +453,12 @@ exports.REnvironment = {
|
|
|
402
453
|
name: 'REnvironment',
|
|
403
454
|
/** Walks up to the global environment (`.GlobalEnv`); see {@link findGlobalEnvironment}. */
|
|
404
455
|
findGlobal: findGlobalEnvironment,
|
|
405
|
-
/** Attaches a package block below the global
|
|
406
|
-
|
|
456
|
+
/** Attaches a package block at a `search()` position, below the global by default; see {@link attachPackageAt}. */
|
|
457
|
+
attachAt: attachPackageAt,
|
|
458
|
+
/** The `search()` position of a named entry; see {@link searchPositionOf}. */
|
|
459
|
+
searchPosition: searchPositionOf,
|
|
460
|
+
/** The packages on the search path; see {@link attachedPackagesOf}. */
|
|
461
|
+
attachedPackages: attachedPackagesOf,
|
|
407
462
|
};
|
|
408
463
|
/** Splits a package block (a contiguous run of attached-package layers, see {@link EnvType}) into its layers and the env below them. */
|
|
409
464
|
function splitLibraryLayers(env) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { REnvironmentInformation } from './environment';
|
|
2
2
|
import type { ControlDependency } from '../info';
|
|
3
3
|
export declare function overwriteEnvironment(base: REnvironmentInformation, next: REnvironmentInformation | undefined, applyCds?: readonly ControlDependency[]): REnvironmentInformation;
|
|
4
4
|
export declare function overwriteEnvironment(base: REnvironmentInformation | undefined, next: REnvironmentInformation, applyCds?: readonly ControlDependency[]): REnvironmentInformation;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VariableResolve } from '../../../config';
|
|
2
2
|
import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
3
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
-
import {
|
|
4
|
+
import type { REnvironmentInformation } from '../../environments/environment';
|
|
5
5
|
import { Identifier } from '../../environments/identifier';
|
|
6
6
|
import type { DataflowGraph } from '../../graph/graph';
|
|
7
7
|
import { type Lift, type Value, type ValueSet } from '../values/r-value';
|
|
@@ -59,6 +59,8 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
|
|
|
59
59
|
* @param blocked - If set, the ids that should not be considered during resolution (=>top)
|
|
60
60
|
*/
|
|
61
61
|
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked }: ResolveInfo): ResolveResult;
|
|
62
|
+
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
63
|
+
export declare function resolveIdToSingleString(id: NodeId | RNodeWithParent | undefined, info: ResolveInfo): string | undefined;
|
|
62
64
|
/**
|
|
63
65
|
* Please use {@link resolveIdToValue}
|
|
64
66
|
*
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAliases = getAliases;
|
|
4
4
|
exports.resolveIdToValue = resolveIdToValue;
|
|
5
|
+
exports.resolveIdToSingleString = resolveIdToSingleString;
|
|
5
6
|
exports.trackAliasInEnvironments = trackAliasInEnvironments;
|
|
6
7
|
exports.trackAliasesInGraph = trackAliasesInGraph;
|
|
7
8
|
exports.resolveToConstants = resolveToConstants;
|
|
@@ -163,6 +164,12 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
|
|
|
163
164
|
return r_value_1.Top;
|
|
164
165
|
}
|
|
165
166
|
}
|
|
167
|
+
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
168
|
+
function resolveIdToSingleString(id, info) {
|
|
169
|
+
const resolved = (0, general_1.valueSetGuard)(resolveIdToValue(id, info));
|
|
170
|
+
const element = resolved?.elements.length === 1 ? resolved.elements[0] : undefined;
|
|
171
|
+
return element?.type === 'string' && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
|
|
172
|
+
}
|
|
166
173
|
/**
|
|
167
174
|
* Please use {@link resolveIdToValue}
|
|
168
175
|
*
|
|
@@ -325,7 +332,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
|
325
332
|
const values = new Set();
|
|
326
333
|
for (const id of resultIds) {
|
|
327
334
|
const vertex = graph.getVertex(id);
|
|
328
|
-
if (
|
|
335
|
+
if (vertex_1.ValueVertex.is(vertex) && vertex.value !== undefined) {
|
|
329
336
|
values.add(vertex.value);
|
|
330
337
|
continue;
|
|
331
338
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
|
+
import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
|
|
1
3
|
import type { BuiltInEvalHandlerArgs } from '../../environments/built-in';
|
|
2
4
|
import { type Lift, Top, type Value, type ValueNumber, type ValueVector } from '../values/r-value';
|
|
3
5
|
/**
|
|
@@ -45,3 +47,15 @@ export declare function resolveAsPlus({ node: operator, environment, resolve, ct
|
|
|
45
47
|
* @returns ValueNumber, ValueVector of ValueNumbers, or Top
|
|
46
48
|
*/
|
|
47
49
|
export declare function resolveAsMinus({ node: operator, environment, resolve, ctx, graph, idMap, blocked }: BuiltInEvalHandlerArgs): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves a `paste`/`paste0` call to a {@link Value} string when every non-`sep`/`collapse` argument
|
|
52
|
+
* resolves to a single string constant (e.g. `paste0("cfg_", k)` with `k` a known string). `sep` defaults to
|
|
53
|
+
* `""` for `paste0` and `" "` for `paste`, or the constant `sep=` argument when given; any unresolved part yields Top.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveAsPaste({ resolve, node, ctx, blocked, environment, graph, idMap }: BuiltInEvalHandlerArgs): Value;
|
|
56
|
+
/**
|
|
57
|
+
* Folds a named `paste`/`paste0` call to its concatenated string, resolving each non-`sep`/`collapse` argument via
|
|
58
|
+
* `resolveArg`; `sep` defaults to `""` (paste0) or `" "` (paste), overridden by a resolvable `sep=`. `undefined` if any
|
|
59
|
+
* part (or `sep`) does not resolve. Shared by the value solver ({@link resolveAsPaste}) and construction-time name resolution.
|
|
60
|
+
*/
|
|
61
|
+
export declare function foldPasteCall<Info>(node: RNamedFunctionCall<Info>, resolveArg: (arg: RNode<Info>) => string | undefined): string | undefined;
|
|
@@ -5,6 +5,8 @@ exports.resolveAsVector = resolveAsVector;
|
|
|
5
5
|
exports.resolveAsSeq = resolveAsSeq;
|
|
6
6
|
exports.resolveAsPlus = resolveAsPlus;
|
|
7
7
|
exports.resolveAsMinus = resolveAsMinus;
|
|
8
|
+
exports.resolveAsPaste = resolveAsPaste;
|
|
9
|
+
exports.foldPasteCall = foldPasteCall;
|
|
8
10
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
11
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
10
12
|
const r_value_1 = require("../../../util/r-value");
|
|
@@ -150,6 +152,51 @@ function resolveAsMinus({ node: operator, environment, resolve, ctx, graph, idMa
|
|
|
150
152
|
}
|
|
151
153
|
return r_value_2.Top;
|
|
152
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Resolves a `paste`/`paste0` call to a {@link Value} string when every non-`sep`/`collapse` argument
|
|
157
|
+
* resolves to a single string constant (e.g. `paste0("cfg_", k)` with `k` a known string). `sep` defaults to
|
|
158
|
+
* `""` for `paste0` and `" "` for `paste`, or the constant `sep=` argument when given; any unresolved part yields Top.
|
|
159
|
+
*/
|
|
160
|
+
function resolveAsPaste({ resolve, node, ctx, blocked, environment, graph, idMap }) {
|
|
161
|
+
if (node.type !== type_1.RType.FunctionCall || !node.named) {
|
|
162
|
+
return r_value_2.Top;
|
|
163
|
+
}
|
|
164
|
+
const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx, blocked };
|
|
165
|
+
const folded = foldPasteCall(node, arg => (0, alias_tracking_1.resolveIdToSingleString)(arg.info.id, resolveInfo));
|
|
166
|
+
return folded === undefined ? r_value_2.Top : (0, string_constants_1.stringFrom)(folded);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Folds a named `paste`/`paste0` call to its concatenated string, resolving each non-`sep`/`collapse` argument via
|
|
170
|
+
* `resolveArg`; `sep` defaults to `""` (paste0) or `" "` (paste), overridden by a resolvable `sep=`. `undefined` if any
|
|
171
|
+
* part (or `sep`) does not resolve. Shared by the value solver ({@link resolveAsPaste}) and construction-time name resolution.
|
|
172
|
+
*/
|
|
173
|
+
function foldPasteCall(node, resolveArg) {
|
|
174
|
+
let sep = identifier_1.Identifier.getName(node.functionName.content) === 'paste0' ? '' : ' ';
|
|
175
|
+
const parts = [];
|
|
176
|
+
for (const arg of node.arguments) {
|
|
177
|
+
if (arg === r_function_call_1.EmptyArgument || arg.value === undefined) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const argName = arg.name?.content;
|
|
181
|
+
if (argName === 'collapse') {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
else if (argName === 'sep') {
|
|
185
|
+
const s = resolveArg(arg.value);
|
|
186
|
+
if (s === undefined) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
sep = s;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const part = resolveArg(arg.value);
|
|
193
|
+
if (part === undefined) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
parts.push(part);
|
|
197
|
+
}
|
|
198
|
+
return parts.join(sep);
|
|
199
|
+
}
|
|
153
200
|
function createNumberSequence(start, end) {
|
|
154
201
|
const sequence = [];
|
|
155
202
|
const min = Math.min(start.num, end.num);
|
|
@@ -17,7 +17,7 @@ function isAnyReturnAFunction(def, graph) {
|
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
seen.add(current.id);
|
|
20
|
-
if (
|
|
20
|
+
if (vertex_1.FunctionDefinitionVertex.is(current)) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
const next = graph.outgoingEdges(current.id) ?? [];
|
|
@@ -39,7 +39,7 @@ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
41
|
const caller = graph.getVertex(callerId);
|
|
42
|
-
if (!caller || !
|
|
42
|
+
if (!caller || !vertex_1.FunctionCallVertex.is(caller)) {
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
45
|
for (const arg of caller.args) {
|
|
@@ -63,7 +63,7 @@ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
|
63
63
|
*/
|
|
64
64
|
function isFunctionHigherOrder(id, graph, ctx, invertedGraph) {
|
|
65
65
|
const vert = graph.getVertex(id);
|
|
66
|
-
if (!vert || !
|
|
66
|
+
if (!vert || !vertex_1.FunctionDefinitionVertex.is(vert)) {
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
// 1. check whether any of the exit types is a function
|
|
@@ -7,7 +7,7 @@ const vertex_1 = require("../graph/vertex");
|
|
|
7
7
|
*/
|
|
8
8
|
function isFunctionRecursive(id, graph) {
|
|
9
9
|
const vert = graph.getVertex(id);
|
|
10
|
-
if (!
|
|
10
|
+
if (!vertex_1.FunctionDefinitionVertex.is(vert)) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
const seen = new Set();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
3
|
import { type DataflowFunctionFlowInformation, DataflowGraph, FunctionArgument } from './graph';
|
|
4
|
-
import {
|
|
4
|
+
import type { IEnvironment, REnvironmentInformation } from '../environments/environment';
|
|
5
5
|
import { type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexArgument, type DataflowGraphVertexAstLink, type DataflowGraphVertexInfo, type DataflowGraphVertexUse, type FunctionOriginInformation } from './vertex';
|
|
6
6
|
import type { ControlDependency, ExitPoint } from '../info';
|
|
7
7
|
import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
@@ -69,7 +69,7 @@ exports.Dataflow = {
|
|
|
69
69
|
*/
|
|
70
70
|
qualify(id, graph, qualifyBaseR = true) {
|
|
71
71
|
const vertex = graph.getVertex(id);
|
|
72
|
-
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id),
|
|
72
|
+
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), vertex_1.FunctionCallVertex.is(vertex) ? vertex.name : undefined, qualifyBaseR);
|
|
73
73
|
},
|
|
74
74
|
/**
|
|
75
75
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
@@ -62,7 +62,7 @@ export interface DataflowGraphVertexAstLink {
|
|
|
62
62
|
*
|
|
63
63
|
* For built-in constants whose id is not in the {@link AstIdMap} (e.g. `T` resolving to `built-in:T`),
|
|
64
64
|
* the abstract {@link Value} is stored directly in the {@link DataflowGraphVertexValue#value|value} field.
|
|
65
|
-
* @see {@link
|
|
65
|
+
* @see {@link ValueVertex.is} - to check if a vertex is a value vertex
|
|
66
66
|
*/
|
|
67
67
|
export interface DataflowGraphVertexValue extends DataflowGraphVertexBase {
|
|
68
68
|
readonly tag: VertexType.Value;
|
|
@@ -72,7 +72,7 @@ export interface DataflowGraphVertexValue extends DataflowGraphVertexBase {
|
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Arguments required to construct a vertex which represents the usage of a variable in the {@link DataflowGraph|dataflow graph}.
|
|
75
|
-
* @see {@link
|
|
75
|
+
* @see {@link UseVertex.is} - to check if a vertex is a use vertex
|
|
76
76
|
*/
|
|
77
77
|
export interface DataflowGraphVertexUse extends DataflowGraphVertexBase {
|
|
78
78
|
readonly tag: VertexType.Use;
|
|
@@ -83,7 +83,7 @@ export interface DataflowGraphVertexUse extends DataflowGraphVertexBase {
|
|
|
83
83
|
* Arguments required to construct a vertex which represents the call to a function in the {@link DataflowGraph|dataflow graph}.
|
|
84
84
|
* This describes all kinds of function calls, including calls to built-ins and control-flow structures such as `if` or `for` (they are
|
|
85
85
|
* treated as function calls in R).
|
|
86
|
-
* @see {@link
|
|
86
|
+
* @see {@link FunctionCallVertex.is} - to check if a vertex is a function call vertex
|
|
87
87
|
*/
|
|
88
88
|
export interface DataflowGraphVertexFunctionCall extends DataflowGraphVertexBase {
|
|
89
89
|
readonly tag: VertexType.FunctionCall;
|
|
@@ -117,7 +117,7 @@ export interface DataflowGraphVertexFunctionCall extends DataflowGraphVertexBase
|
|
|
117
117
|
export type FunctionOriginInformation = BuiltInProcName;
|
|
118
118
|
/**
|
|
119
119
|
* Arguments required to construct a vertex which represents the definition of a variable in the {@link DataflowGraph|dataflow graph}.
|
|
120
|
-
* @see {@link
|
|
120
|
+
* @see {@link VariableDefinitionVertex.is} - to check if a vertex is a variable definition vertex
|
|
121
121
|
*/
|
|
122
122
|
export interface DataflowGraphVertexVariableDefinition extends DataflowGraphVertexBase {
|
|
123
123
|
readonly tag: VertexType.VariableDefinition;
|
|
@@ -130,7 +130,7 @@ export interface DataflowGraphVertexVariableDefinition extends DataflowGraphVert
|
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Arguments required to construct a vertex which represents the definition of a function in the {@link DataflowGraph|dataflow graph}.
|
|
133
|
-
* @see {@link
|
|
133
|
+
* @see {@link FunctionDefinitionVertex.is} - to check if a vertex is a function definition vertex
|
|
134
134
|
*/
|
|
135
135
|
export interface DataflowGraphVertexFunctionDefinition extends DataflowGraphVertexBase {
|
|
136
136
|
readonly tag: VertexType.FunctionDefinition;
|
|
@@ -176,24 +176,31 @@ export type DataflowGraphVertexInfo = Required<DataflowGraphVertexArgument>;
|
|
|
176
176
|
* A mapping of {@link NodeId}s to {@link DataflowGraphVertexInfo|vertices}.
|
|
177
177
|
*/
|
|
178
178
|
export type DataflowGraphVertices<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo> = Map<NodeId, Vertex>;
|
|
179
|
-
/**
|
|
180
|
-
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*/
|
|
190
|
-
export declare
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
179
|
+
/** Helpers for {@link DataflowGraphVertexValue} vertices. */
|
|
180
|
+
export declare const ValueVertex: {
|
|
181
|
+
/** Whether the given vertex is a value vertex. */
|
|
182
|
+
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexValue;
|
|
183
|
+
};
|
|
184
|
+
/** Helpers for {@link DataflowGraphVertexUse} vertices. */
|
|
185
|
+
export declare const UseVertex: {
|
|
186
|
+
/** Whether the given vertex is a use vertex. */
|
|
187
|
+
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexUse;
|
|
188
|
+
};
|
|
189
|
+
/** Helpers for {@link DataflowGraphVertexFunctionCall} vertices. */
|
|
190
|
+
export declare const FunctionCallVertex: {
|
|
191
|
+
/** Whether the given vertex is a function call vertex. */
|
|
192
|
+
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionCall;
|
|
193
|
+
/** Whether the given vertex is a function call carrying the given origin. */
|
|
194
|
+
hasOrigin(this: void, vertex: DataflowGraphVertexBase | undefined, origin: BuiltInProcName): boolean;
|
|
195
|
+
};
|
|
196
|
+
/** Helpers for {@link DataflowGraphVertexVariableDefinition} vertices. */
|
|
197
|
+
export declare const VariableDefinitionVertex: {
|
|
198
|
+
/** Whether the given vertex is a variable definition vertex. */
|
|
199
|
+
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexVariableDefinition;
|
|
200
|
+
};
|
|
201
|
+
/** Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices. */
|
|
202
|
+
export declare const FunctionDefinitionVertex: {
|
|
203
|
+
/** Whether the given vertex is a function definition vertex. */
|
|
204
|
+
is(this: void, vertex?: DataflowGraphVertexBase): vertex is DataflowGraphVertexFunctionDefinition;
|
|
205
|
+
};
|
|
199
206
|
export {};
|
package/dataflow/graph/vertex.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0;
|
|
4
|
-
exports.isValueVertex = isValueVertex;
|
|
5
|
-
exports.isUseVertex = isUseVertex;
|
|
6
|
-
exports.isFunctionCallVertex = isFunctionCallVertex;
|
|
7
|
-
exports.isVariableDefinitionVertex = isVariableDefinitionVertex;
|
|
8
|
-
exports.isFunctionDefinitionVertex = isFunctionDefinitionVertex;
|
|
3
|
+
exports.FunctionDefinitionVertex = exports.VariableDefinitionVertex = exports.FunctionCallVertex = exports.UseVertex = exports.ValueVertex = exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0;
|
|
9
4
|
var VertexType;
|
|
10
5
|
(function (VertexType) {
|
|
11
6
|
VertexType["Value"] = "value";
|
|
@@ -16,34 +11,43 @@ var VertexType;
|
|
|
16
11
|
})(VertexType || (exports.VertexType = VertexType = {}));
|
|
17
12
|
exports.ValidVertexTypes = new Set(Object.values(VertexType));
|
|
18
13
|
exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
14
|
+
/** Helpers for {@link DataflowGraphVertexValue} vertices. */
|
|
15
|
+
exports.ValueVertex = {
|
|
16
|
+
/** Whether the given vertex is a value vertex. */
|
|
17
|
+
is(vertex) {
|
|
18
|
+
return vertex?.tag === VertexType.Value;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** Helpers for {@link DataflowGraphVertexUse} vertices. */
|
|
22
|
+
exports.UseVertex = {
|
|
23
|
+
/** Whether the given vertex is a use vertex. */
|
|
24
|
+
is(vertex) {
|
|
25
|
+
return vertex?.tag === VertexType.Use;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** Helpers for {@link DataflowGraphVertexFunctionCall} vertices. */
|
|
29
|
+
exports.FunctionCallVertex = {
|
|
30
|
+
/** Whether the given vertex is a function call vertex. */
|
|
31
|
+
is(vertex) {
|
|
32
|
+
return vertex?.tag === VertexType.FunctionCall;
|
|
33
|
+
},
|
|
34
|
+
/** Whether the given vertex is a function call carrying the given origin. */
|
|
35
|
+
hasOrigin(vertex, origin) {
|
|
36
|
+
return exports.FunctionCallVertex.is(vertex) && vertex.origin.includes(origin);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/** Helpers for {@link DataflowGraphVertexVariableDefinition} vertices. */
|
|
40
|
+
exports.VariableDefinitionVertex = {
|
|
41
|
+
/** Whether the given vertex is a variable definition vertex. */
|
|
42
|
+
is(vertex) {
|
|
43
|
+
return vertex?.tag === VertexType.VariableDefinition;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/** Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices. */
|
|
47
|
+
exports.FunctionDefinitionVertex = {
|
|
48
|
+
/** Whether the given vertex is a function definition vertex. */
|
|
49
|
+
is(vertex) {
|
|
50
|
+
return vertex?.tag === VertexType.FunctionDefinition;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
49
53
|
//# sourceMappingURL=vertex.js.map
|
|
@@ -18,6 +18,7 @@ import type { ForceArguments } from '../common';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function processAccess<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
|
|
20
20
|
treatIndicesAsString: boolean;
|
|
21
|
+
resolveField?: boolean;
|
|
21
22
|
} & ForceArguments): DataflowInformation;
|
|
22
23
|
/**
|
|
23
24
|
* Converts symbol arguments to string arguments within the specified range.
|
|
@@ -60,18 +60,21 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
60
60
|
}
|
|
61
61
|
/* we include the read edges to the constant arguments as well so that they are included if necessary */
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
if (config.treatIndicesAsString && identifier_1.Identifier.getName(name.content) === '$'
|
|
63
|
+
if (config.resolveField
|
|
65
64
|
&& head !== r_function_call_1.EmptyArgument && head.value !== undefined
|
|
66
65
|
&& args.length >= 2 && args[1] !== r_function_call_1.EmptyArgument) {
|
|
67
|
-
const
|
|
66
|
+
const stackEnvState = (0, built_in_stack_env_1.resolveNodeToStackEnv)(head.value, data);
|
|
67
|
+
const envState = stackEnvState
|
|
68
68
|
?? (head.value.type === type_1.RType.Symbol ? (0, built_in_envir_utils_1.resolveSymbolToEnvir)(head.value.content, head.value.info.id, data)?.envDef.envState : undefined);
|
|
69
69
|
if (envState) {
|
|
70
70
|
const fieldNode = (0, unpack_argument_1.unpackArg)(args[1]);
|
|
71
|
-
const fieldName = fieldNode?.type === type_1.RType.String ? fieldNode.content.str : fieldNode?.lexeme;
|
|
71
|
+
const fieldName = fieldNode?.type === type_1.RType.String ? fieldNode.content.str : (config.treatIndicesAsString ? fieldNode?.lexeme : undefined);
|
|
72
72
|
const fieldDefs = fieldName ? envState.current.memory.get(fieldName) : undefined;
|
|
73
73
|
for (const fd of fieldDefs ?? []) {
|
|
74
74
|
info.graph.addEdge(name.info.id, fd.nodeId, edge_1.EdgeType.Reads);
|
|
75
|
+
if (stackEnvState === undefined && fd.type === identifier_1.ReferenceType.Function) {
|
|
76
|
+
info.graph.addEdge(name.info.id, fd.nodeId, edge_1.EdgeType.Returns);
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
}
|
|
@@ -5,6 +5,20 @@ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import type { MergeableRecord } from '../../../../../../util/objects';
|
|
8
|
+
import { type Identifier } from '../../../../../environments/identifier';
|
|
9
|
+
import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
10
|
+
/** the function reference extracted from an argument passed to a higher-order call */
|
|
11
|
+
export interface ResolvedFunctionArgument {
|
|
12
|
+
readonly functionId: NodeId;
|
|
13
|
+
readonly functionName: Identifier;
|
|
14
|
+
readonly anonymous: boolean;
|
|
15
|
+
readonly asString: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Resolve the function an argument stands for: a string literal, a symbol, or an inline definition; `undefined` if none. */
|
|
18
|
+
export declare function resolveFunctionArgument<OtherInfo>(val: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, opts: {
|
|
19
|
+
readonly unquoteFunction?: boolean;
|
|
20
|
+
readonly resolveValue?: boolean;
|
|
21
|
+
}): ResolvedFunctionArgument | undefined;
|
|
8
22
|
export interface BuiltInApplyConfiguration extends MergeableRecord {
|
|
9
23
|
/** the 0-based index of the argument which is the actual function passed, defaults to 1 */
|
|
10
24
|
readonly indexOfFunction?: number;
|