@eagleoutice/flowr 2.2.15 → 2.2.16
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 +210 -6
- package/benchmark/slicer.d.ts +3 -1
- package/benchmark/slicer.js +8 -5
- package/benchmark/summarizer/first-phase/process.d.ts +2 -1
- package/benchmark/summarizer/first-phase/process.js +2 -2
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +7 -8
- package/cli/common/options.js +2 -0
- package/cli/export-quads-app.js +2 -1
- package/cli/flowr.js +58 -57
- package/cli/repl/commands/repl-cfg.js +13 -13
- package/cli/repl/commands/repl-commands.js +2 -2
- package/cli/repl/commands/repl-dataflow.js +10 -10
- package/cli/repl/commands/repl-execute.d.ts +2 -3
- package/cli/repl/commands/repl-execute.js +4 -4
- package/cli/repl/commands/repl-lineage.js +4 -4
- package/cli/repl/commands/repl-main.d.ts +12 -1
- package/cli/repl/commands/repl-normalize.js +6 -6
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +9 -9
- package/cli/repl/commands/repl-version.js +1 -1
- package/cli/repl/core.d.ts +5 -2
- package/cli/repl/core.js +10 -8
- package/cli/repl/server/connection.d.ts +3 -1
- package/cli/repl/server/connection.js +7 -5
- package/cli/repl/server/server.d.ts +3 -2
- package/cli/repl/server/server.js +4 -2
- package/cli/script-core/statistics-core.d.ts +2 -1
- package/cli/script-core/statistics-core.js +2 -2
- package/cli/script-core/statistics-helper-core.d.ts +2 -1
- package/cli/script-core/statistics-helper-core.js +5 -4
- package/cli/slicer-app.js +4 -2
- package/cli/statistics-app.js +2 -1
- package/cli/statistics-helper-app.js +2 -1
- package/config.d.ts +12 -10
- package/config.js +26 -42
- package/control-flow/cfg-dead-code.js +45 -2
- package/control-flow/cfg-simplification.d.ts +2 -0
- package/control-flow/control-flow-graph.d.ts +1 -0
- package/control-flow/control-flow-graph.js +4 -0
- package/control-flow/dfg-cfg-guided-visitor.d.ts +5 -3
- package/control-flow/dfg-cfg-guided-visitor.js +15 -4
- package/control-flow/extract-cfg.d.ts +4 -2
- package/control-flow/extract-cfg.js +4 -3
- package/control-flow/semantic-cfg-guided-visitor.d.ts +19 -1
- package/control-flow/semantic-cfg-guided-visitor.js +23 -3
- package/core/pipeline-executor.d.ts +4 -1
- package/core/pipeline-executor.js +6 -5
- package/core/steps/all/core/10-normalize.d.ts +2 -0
- package/core/steps/all/core/10-normalize.js +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
- package/core/steps/all/core/20-dataflow.d.ts +2 -1
- package/core/steps/all/core/20-dataflow.js +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
- package/core/steps/all/static-slicing/00-slice.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +32 -31
- package/core/steps/pipeline/default-pipelines.js +8 -8
- package/core/steps/pipeline-step.d.ts +2 -1
- package/dataflow/environments/built-in-config.d.ts +3 -3
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +2 -2
- package/dataflow/environments/default-builtin-config.js +4 -2
- package/dataflow/environments/define.d.ts +2 -1
- package/dataflow/environments/define.js +4 -5
- package/dataflow/environments/remove.d.ts +6 -0
- package/dataflow/environments/remove.js +29 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +7 -2
- package/dataflow/eval/resolve/alias-tracking.js +9 -6
- package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
- package/dataflow/eval/resolve/resolve-argument.js +118 -0
- package/dataflow/eval/resolve/resolve.d.ts +18 -15
- package/dataflow/eval/resolve/resolve.js +20 -18
- package/dataflow/eval/values/string/string-constants.d.ts +1 -1
- package/dataflow/eval/values/string/string-constants.js +7 -2
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +11 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +10 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -15
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/common.js +1 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
- package/dataflow/processor.d.ts +5 -0
- package/documentation/doc-util/doc-cfg.js +4 -3
- package/documentation/doc-util/doc-code.d.ts +1 -1
- package/documentation/doc-util/doc-dfg.js +3 -2
- package/documentation/doc-util/doc-functions.d.ts +24 -0
- package/documentation/doc-util/doc-functions.js +65 -0
- package/documentation/doc-util/doc-normalized-ast.js +3 -2
- package/documentation/doc-util/doc-print.d.ts +5 -0
- package/documentation/doc-util/doc-print.js +36 -0
- package/documentation/doc-util/doc-query.js +3 -2
- package/documentation/doc-util/doc-repl.js +2 -1
- package/documentation/doc-util/doc-search.js +3 -2
- package/documentation/doc-util/doc-types.d.ts +28 -6
- package/documentation/doc-util/doc-types.js +89 -45
- package/documentation/print-cfg-wiki.js +6 -7
- package/documentation/print-core-wiki.js +5 -5
- package/documentation/print-dataflow-graph-wiki.js +10 -10
- package/documentation/print-engines-wiki.js +1 -2
- package/documentation/print-faq-wiki.js +8 -2
- package/documentation/print-interface-wiki.js +1 -2
- package/documentation/print-linter-issue.d.ts +1 -0
- package/documentation/print-linter-issue.js +71 -0
- package/documentation/print-linter-wiki.js +219 -34
- package/documentation/print-linting-and-testing-wiki.js +2 -4
- package/documentation/print-normalized-ast-wiki.js +3 -3
- package/documentation/print-query-wiki.js +1 -2
- package/documentation/print-readme.js +24 -1
- package/documentation/print-search-wiki.js +1 -2
- package/linter/linter-executor.d.ts +3 -1
- package/linter/linter-executor.js +3 -2
- package/linter/linter-format.d.ts +67 -7
- package/linter/linter-format.js +12 -1
- package/linter/linter-rules.d.ts +155 -16
- package/linter/linter-rules.js +12 -4
- package/linter/linter-tags.d.ts +80 -0
- package/linter/linter-tags.js +85 -0
- package/linter/rules/absolute-path.d.ts +71 -0
- package/linter/rules/absolute-path.js +177 -0
- package/linter/rules/deprecated-functions.d.ts +43 -0
- package/linter/rules/deprecated-functions.js +58 -0
- package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
- package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
- package/linter/rules/naming-convention.d.ts +71 -0
- package/linter/rules/naming-convention.js +164 -0
- package/linter/rules/seeded-randomness.d.ts +65 -0
- package/linter/rules/seeded-randomness.js +122 -0
- package/linter/rules/unused-definition.d.ts +41 -0
- package/linter/rules/unused-definition.js +105 -0
- package/package.json +4 -1
- package/queries/base-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.js +2 -3
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -116
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-format.js +16 -12
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
- package/queries/catalog/search-query/search-query-executor.js +2 -2
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/query.d.ts +15 -15
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
- package/r-bridge/lang-4.x/convert-values.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +7 -5
- package/r-bridge/shell.d.ts +3 -2
- package/r-bridge/shell.js +4 -5
- package/search/flowr-search-builder.d.ts +6 -2
- package/search/flowr-search-builder.js +7 -0
- package/search/flowr-search-filters.d.ts +32 -8
- package/search/flowr-search-filters.js +42 -15
- package/search/flowr-search.d.ts +4 -0
- package/search/search-executor/search-enrichers.d.ts +7 -3
- package/search/search-executor/search-enrichers.js +29 -20
- package/search/search-executor/search-generators.js +1 -1
- package/search/search-executor/search-transformer.d.ts +2 -0
- package/search/search-executor/search-transformer.js +10 -1
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +2 -3
- package/statistics/statistics.d.ts +3 -1
- package/statistics/statistics.js +5 -4
- package/util/containers.d.ts +12 -9
- package/util/containers.js +12 -9
- package/util/objects.d.ts +5 -4
- package/util/range.d.ts +5 -1
- package/util/range.js +11 -3
- package/util/text/strings.d.ts +6 -0
- package/util/text/strings.js +35 -0
- package/util/version.js +1 -1
- package/linter/rules/1-deprecated-functions.d.ts +0 -34
- package/linter/rules/1-deprecated-functions.js +0 -54
|
@@ -32,6 +32,7 @@ import type { REnvironmentInformation } from './environment';
|
|
|
32
32
|
import type { Value } from '../eval/values/r-value';
|
|
33
33
|
import { resolveAsVector } from '../eval/resolve/resolve';
|
|
34
34
|
import type { DataflowGraph } from '../graph/graph';
|
|
35
|
+
import type { VariableResolve } from '../../config';
|
|
35
36
|
export type BuiltIn = `built-in:${string}`;
|
|
36
37
|
export declare function builtInId(name: string): BuiltIn;
|
|
37
38
|
export declare function isBuiltIn(name: NodeId | string): name is BuiltIn;
|
|
@@ -48,6 +49,7 @@ export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierRefere
|
|
|
48
49
|
definedAt: BuiltIn;
|
|
49
50
|
value: T;
|
|
50
51
|
}
|
|
52
|
+
export type UseAsProcessors = 'builtin:default' | 'builtin:return' | 'builtin:stop';
|
|
51
53
|
export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
|
|
52
54
|
readonly returnsNthArgument?: number | 'last';
|
|
53
55
|
readonly cfg?: ExitPointType;
|
|
@@ -55,8 +57,12 @@ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
|
|
|
55
57
|
readonly hasUnknownSideEffects?: boolean | LinkTo<RegExp | string>;
|
|
56
58
|
/** record mapping the actual function name called to the arguments that should be treated as function calls */
|
|
57
59
|
readonly treatAsFnCall?: Record<string, readonly string[]>;
|
|
60
|
+
/** Name that should be used for the origin (useful when needing to differentiate between
|
|
61
|
+
* functions like 'return' that use the default builtin processor)
|
|
62
|
+
*/
|
|
63
|
+
readonly useAsProcessor?: UseAsProcessors;
|
|
58
64
|
}
|
|
59
|
-
export type BuiltInEvalHandler = (a: RNodeWithParent, env: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap) => Value;
|
|
65
|
+
export type BuiltInEvalHandler = (resolve: VariableResolve, a: RNodeWithParent, env: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap) => Value;
|
|
60
66
|
declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: DefaultBuiltInProcessorConfiguration): DataflowInformation;
|
|
61
67
|
export declare function registerBuiltInFunctions<Config extends object, Proc extends BuiltInIdentifierProcessorWithConfig<Config>>(both: boolean, names: readonly Identifier[], processor: Proc, config: Config): void;
|
|
62
68
|
export declare const BuiltInProcessorMapper: {
|
|
@@ -42,7 +42,7 @@ function isBuiltIn(name) {
|
|
|
42
42
|
return String(name).startsWith('built-in:');
|
|
43
43
|
}
|
|
44
44
|
function defaultBuiltInProcessor(name, args, rootId, data, config) {
|
|
45
|
-
const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'builtin:default' });
|
|
45
|
+
const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: config.useAsProcessor ?? 'builtin:default' });
|
|
46
46
|
if (config.returnsNthArgument !== undefined) {
|
|
47
47
|
const arg = config.returnsNthArgument === 'last' ? processedArguments[args.length - 1] : processedArguments[config.returnsNthArgument];
|
|
48
48
|
if (arg !== undefined) {
|
|
@@ -90,7 +90,7 @@ function defaultBuiltInProcessor(name, args, rootId, data, config) {
|
|
|
90
90
|
environment: data.environment,
|
|
91
91
|
onlyBuiltin: false,
|
|
92
92
|
cds: data.controlDependencies,
|
|
93
|
-
origin: ['builtin:default']
|
|
93
|
+
origin: [config.useAsProcessor ?? 'builtin:default']
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -102,7 +102,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
102
102
|
'~', '+', '-', '*', '/', '^', '!', '?', '**', '==', '!=', '>', '<', '>=', '<=', '%%', '%/%', '%*%', '%in%', ':',
|
|
103
103
|
'rep', 'seq', 'seq_len', 'seq_along', 'seq.int', 'gsub', 'which', 'class', 'dimnames', 'min', 'max',
|
|
104
104
|
'intersect', 'subset', 'match', 'sqrt', 'abs', 'round', 'floor', 'ceiling', 'signif', 'trunc', 'log', 'log10', 'log2', 'sum', 'mean',
|
|
105
|
-
'unique', 'paste', 'paste0', 'read.csv', '
|
|
105
|
+
'unique', 'paste', 'paste0', 'read.csv', 'is.null', 'numeric', 'as.character', 'as.integer', 'as.logical', 'as.numeric', 'as.matrix',
|
|
106
106
|
'rbind', 'nrow', 'ncol', 'tryCatch', 'expression', 'factor',
|
|
107
107
|
'missing', 'as.data.frame', 'data.frame', 'na.omit', 'rownames', 'names', 'order', 'length', 'any', 'dim', 'matrix', 'cbind', 'nchar',
|
|
108
108
|
'pdf', 'jpeg', 'png', 'windows', 'postscript', 'xfig', 'bitmap', 'pictex', 'cairo_pdf', 'svg', 'bmp', 'tiff', 'X11', 'quartz',
|
|
@@ -215,7 +215,9 @@ exports.DefaultBuiltinConfig = [
|
|
|
215
215
|
{ type: 'function', names: ['eval'], processor: 'builtin:eval', config: { includeFunctionCall: true }, assumePrimitive: true },
|
|
216
216
|
{ type: 'function', names: ['cat'], processor: 'builtin:default', config: { forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
|
|
217
217
|
{ type: 'function', names: ['switch'], processor: 'builtin:default', config: { forceArgs: [true] }, assumePrimitive: false },
|
|
218
|
-
{ type: 'function', names: ['return'], processor: 'builtin:default', config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return
|
|
218
|
+
{ type: 'function', names: ['return'], processor: 'builtin:default', config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return */, useAsProcessor: 'builtin:return' }, assumePrimitive: false },
|
|
219
|
+
{ type: 'function', names: ['stop'], processor: 'builtin:default', config: { useAsProcessor: 'builtin:stop' }, assumePrimitive: false },
|
|
220
|
+
{ type: 'function', names: ['stopifnot'], processor: 'builtin:default', config: { useAsProcessor: 'builtin:stopifnot' }, assumePrimitive: false },
|
|
219
221
|
{ type: 'function', names: ['break'], processor: 'builtin:default', config: { cfg: 2 /* ExitPointType.Break */ }, assumePrimitive: false },
|
|
220
222
|
{ type: 'function', names: ['next'], processor: 'builtin:default', config: { cfg: 3 /* ExitPointType.Next */ }, assumePrimitive: false },
|
|
221
223
|
{ type: 'function', names: ['{'], processor: 'builtin:expression-list', config: {}, assumePrimitive: true },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { REnvironmentInformation } from './environment';
|
|
2
2
|
import type { IdentifierDefinition, InGraphIdentifierDefinition } from './identifier';
|
|
3
|
+
import type { FlowrConfigOptions } from '../../config';
|
|
3
4
|
/**
|
|
4
5
|
* assumes: existing is not undefined, the overwrite has indices
|
|
5
6
|
*/
|
|
@@ -8,4 +9,4 @@ export declare function mergeDefinitions(existing: readonly IdentifierDefinition
|
|
|
8
9
|
* Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
|
|
9
10
|
* Does not modify the passed along `environments` in-place! It returns the new reference.
|
|
10
11
|
*/
|
|
11
|
-
export declare function define(definition: IdentifierDefinition, superAssign: boolean | undefined, environment: REnvironmentInformation): REnvironmentInformation;
|
|
12
|
+
export declare function define(definition: IdentifierDefinition, superAssign: boolean | undefined, environment: REnvironmentInformation, config: FlowrConfigOptions): REnvironmentInformation;
|
|
@@ -6,12 +6,11 @@ const assert_1 = require("../../util/assert");
|
|
|
6
6
|
const environment_1 = require("./environment");
|
|
7
7
|
const clone_1 = require("./clone");
|
|
8
8
|
const vertex_1 = require("../graph/vertex");
|
|
9
|
-
|
|
10
|
-
function defInEnv(newEnvironments, name, definition) {
|
|
9
|
+
function defInEnv(newEnvironments, name, definition, config) {
|
|
11
10
|
const existing = newEnvironments.memory.get(name);
|
|
12
11
|
// When there are defined indices, merge the definitions
|
|
13
12
|
const inGraphDefinition = definition;
|
|
14
|
-
if (
|
|
13
|
+
if (config.solver.pointerTracking &&
|
|
15
14
|
existing !== undefined &&
|
|
16
15
|
inGraphDefinition.controlDependencies === undefined) {
|
|
17
16
|
if (inGraphDefinition.indicesCollection !== undefined) {
|
|
@@ -122,7 +121,7 @@ function overwriteContainerIndices(existingIndices, overwriteIndex) {
|
|
|
122
121
|
* Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
|
|
123
122
|
* Does not modify the passed along `environments` in-place! It returns the new reference.
|
|
124
123
|
*/
|
|
125
|
-
function define(definition, superAssign, environment) {
|
|
124
|
+
function define(definition, superAssign, environment, config) {
|
|
126
125
|
const name = definition.name;
|
|
127
126
|
(0, assert_1.guard)(name !== undefined, () => `Name must be defined, but isn't for ${JSON.stringify(definition)}`);
|
|
128
127
|
let newEnvironment;
|
|
@@ -147,7 +146,7 @@ function define(definition, superAssign, environment) {
|
|
|
147
146
|
}
|
|
148
147
|
else {
|
|
149
148
|
newEnvironment = (0, clone_1.cloneEnvironmentInformation)(environment, false);
|
|
150
|
-
defInEnv(newEnvironment.current, name, definition);
|
|
149
|
+
defInEnv(newEnvironment.current, name, definition, config);
|
|
151
150
|
}
|
|
152
151
|
return newEnvironment;
|
|
153
152
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { REnvironmentInformation } from './environment';
|
|
2
2
|
import type { Identifier } from './identifier';
|
|
3
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
4
|
/**
|
|
4
5
|
* Removes all definitions of a given name from the environment.
|
|
5
6
|
*/
|
|
6
7
|
export declare function remove(name: Identifier, environment: REnvironmentInformation): REnvironmentInformation;
|
|
8
|
+
/** Creates a copy of the original environment but without the definitions of the given ids */
|
|
9
|
+
export declare function removeAll(definitions: readonly {
|
|
10
|
+
nodeId: NodeId;
|
|
11
|
+
name: Identifier | undefined;
|
|
12
|
+
}[], environment: REnvironmentInformation): REnvironmentInformation;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.remove = remove;
|
|
4
|
+
exports.removeAll = removeAll;
|
|
4
5
|
const environment_1 = require("./environment");
|
|
5
6
|
const info_1 = require("../info");
|
|
7
|
+
const clone_1 = require("./clone");
|
|
6
8
|
/**
|
|
7
9
|
* Removes all definitions of a given name from the environment.
|
|
8
10
|
*/
|
|
@@ -21,4 +23,31 @@ function remove(name, environment) {
|
|
|
21
23
|
// we never remove built ins
|
|
22
24
|
return environment;
|
|
23
25
|
}
|
|
26
|
+
/** Creates a copy of the original environment but without the definitions of the given ids */
|
|
27
|
+
function removeAll(definitions, environment) {
|
|
28
|
+
environment = (0, clone_1.cloneEnvironmentInformation)(environment, true);
|
|
29
|
+
let current = environment.current;
|
|
30
|
+
do {
|
|
31
|
+
for (const { nodeId, name } of definitions) {
|
|
32
|
+
if (name) {
|
|
33
|
+
current.memory.delete(name);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// remove all definitions for the node id
|
|
37
|
+
for (const [key, values] of current.memory) {
|
|
38
|
+
const res = values.filter(v => v.nodeId === nodeId);
|
|
39
|
+
if (res.length > 0) {
|
|
40
|
+
current.memory.set(key, values);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
current.memory.delete(key);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
current = current.parent;
|
|
49
|
+
} while (current.id !== environment_1.BuiltInEnvironment.id);
|
|
50
|
+
// we never remove built ins so we can stop one early
|
|
51
|
+
return environment;
|
|
52
|
+
}
|
|
24
53
|
//# sourceMappingURL=remove.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VariableResolve } from '../../../config';
|
|
1
2
|
import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
3
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
4
|
import type { REnvironmentInformation } from '../../environments/environment';
|
|
@@ -14,6 +15,8 @@ export interface ResolveInfo {
|
|
|
14
15
|
graph?: DataflowGraph;
|
|
15
16
|
/** Whether to track variables */
|
|
16
17
|
full?: boolean;
|
|
18
|
+
/** Variable resolve mode */
|
|
19
|
+
resolve: VariableResolve;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* Gets the definitions / aliases of a node
|
|
@@ -48,8 +51,9 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
|
|
|
48
51
|
* @param graph - The graph to resolve in
|
|
49
52
|
* @param idMap - The id map to resolve the node if given as an id
|
|
50
53
|
* @param full - Whether to track aliases on resolve
|
|
54
|
+
* @param resolve - Variable resolve mode
|
|
51
55
|
*/
|
|
52
|
-
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full }: ResolveInfo): ResolveResult;
|
|
56
|
+
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, resolve }: ResolveInfo): ResolveResult;
|
|
53
57
|
/**
|
|
54
58
|
* Please use {@link resolveIdToValue}
|
|
55
59
|
*
|
|
@@ -57,13 +61,14 @@ export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefine
|
|
|
57
61
|
* {@link getAliases} function) to resolve a node to a value.
|
|
58
62
|
*
|
|
59
63
|
*
|
|
64
|
+
* @param resolve - Variable resolve mode
|
|
60
65
|
* @param identifier - Identifier to resolve
|
|
61
66
|
* @param use - Environment to use
|
|
62
67
|
* @param graph - Dataflow graph
|
|
63
68
|
* @param idMap - id map of Dataflow graph
|
|
64
69
|
* @returns Value of Identifier or Top
|
|
65
70
|
*/
|
|
66
|
-
export declare function trackAliasInEnvironments(identifier: Identifier | undefined, use: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ResolveResult;
|
|
71
|
+
export declare function trackAliasInEnvironments(resolve: VariableResolve, identifier: Identifier | undefined, use: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ResolveResult;
|
|
67
72
|
/**
|
|
68
73
|
* Please use {@link resolveIdToValue}
|
|
69
74
|
*
|
|
@@ -115,8 +115,9 @@ function getAliases(sourceIds, dataflow, environment) {
|
|
|
115
115
|
* @param graph - The graph to resolve in
|
|
116
116
|
* @param idMap - The id map to resolve the node if given as an id
|
|
117
117
|
* @param full - Whether to track aliases on resolve
|
|
118
|
+
* @param resolve - Variable resolve mode
|
|
118
119
|
*/
|
|
119
|
-
function resolveIdToValue(id, { environment, graph, idMap, full = true }) {
|
|
120
|
+
function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve }) {
|
|
120
121
|
if (id === undefined) {
|
|
121
122
|
return r_value_1.Top;
|
|
122
123
|
}
|
|
@@ -129,16 +130,16 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true }) {
|
|
|
129
130
|
case type_1.RType.Argument:
|
|
130
131
|
case type_1.RType.Symbol:
|
|
131
132
|
if (environment) {
|
|
132
|
-
return full ? trackAliasInEnvironments(node.lexeme, environment, graph, idMap) : r_value_1.Top;
|
|
133
|
+
return full ? trackAliasInEnvironments(resolve, node.lexeme, environment, graph, idMap) : r_value_1.Top;
|
|
133
134
|
}
|
|
134
|
-
else if (graph &&
|
|
135
|
+
else if (graph && resolve === config_1.VariableResolve.Alias) {
|
|
135
136
|
return full ? trackAliasesInGraph(node.info.id, graph, idMap) : r_value_1.Top;
|
|
136
137
|
}
|
|
137
138
|
else {
|
|
138
139
|
return r_value_1.Top;
|
|
139
140
|
}
|
|
140
141
|
case type_1.RType.FunctionCall:
|
|
141
|
-
return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)(node, environment, graph, idMap));
|
|
142
|
+
return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)(resolve, node, environment, graph, idMap));
|
|
142
143
|
case type_1.RType.String:
|
|
143
144
|
case type_1.RType.Number:
|
|
144
145
|
case type_1.RType.Logical:
|
|
@@ -154,13 +155,14 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true }) {
|
|
|
154
155
|
* {@link getAliases} function) to resolve a node to a value.
|
|
155
156
|
*
|
|
156
157
|
*
|
|
158
|
+
* @param resolve - Variable resolve mode
|
|
157
159
|
* @param identifier - Identifier to resolve
|
|
158
160
|
* @param use - Environment to use
|
|
159
161
|
* @param graph - Dataflow graph
|
|
160
162
|
* @param idMap - id map of Dataflow graph
|
|
161
163
|
* @returns Value of Identifier or Top
|
|
162
164
|
*/
|
|
163
|
-
function trackAliasInEnvironments(identifier, use, graph, idMap) {
|
|
165
|
+
function trackAliasInEnvironments(resolve, identifier, use, graph, idMap) {
|
|
164
166
|
if (identifier === undefined) {
|
|
165
167
|
return r_value_1.Top;
|
|
166
168
|
}
|
|
@@ -184,7 +186,7 @@ function trackAliasInEnvironments(identifier, use, graph, idMap) {
|
|
|
184
186
|
for (const alias of def.value) {
|
|
185
187
|
const definitionOfAlias = idMap?.get(alias);
|
|
186
188
|
if (definitionOfAlias !== undefined) {
|
|
187
|
-
const value = (0, resolve_1.resolveNode)(definitionOfAlias, use, graph, idMap);
|
|
189
|
+
const value = (0, resolve_1.resolveNode)(resolve, definitionOfAlias, use, graph, idMap);
|
|
188
190
|
if ((0, r_value_1.isTop)(value)) {
|
|
189
191
|
return r_value_1.Top;
|
|
190
192
|
}
|
|
@@ -198,6 +200,7 @@ function trackAliasInEnvironments(identifier, use, graph, idMap) {
|
|
|
198
200
|
}
|
|
199
201
|
return (0, set_constants_1.setFrom)(...values);
|
|
200
202
|
}
|
|
203
|
+
/** given an unknown alias, we have to clear all values in the environments */
|
|
201
204
|
(0, unknown_side_effect_1.onUnknownSideEffect)((_graph, env, _id, target) => {
|
|
202
205
|
if (target) {
|
|
203
206
|
return;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataflowGraph } from '../../graph/graph';
|
|
2
|
+
import type { DataflowGraphVertexFunctionCall } from '../../graph/vertex';
|
|
3
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import type { VariableResolve } from '../../../config';
|
|
5
|
+
/**
|
|
6
|
+
* Get the values of all arguments matching the criteria.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined): Map<NodeId, Set<string | undefined>> | undefined;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getArgumentStringValue = getArgumentStringValue;
|
|
4
|
+
const graph_1 = require("../../graph/graph");
|
|
5
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
6
|
+
const assert_1 = require("../../../util/assert");
|
|
7
|
+
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
8
|
+
const dependencies_query_format_1 = require("../../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
9
|
+
const general_1 = require("../values/general");
|
|
10
|
+
const alias_tracking_1 = require("./alias-tracking");
|
|
11
|
+
const r_value_1 = require("../values/r-value");
|
|
12
|
+
const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
|
|
13
|
+
const string_constants_1 = require("../values/string/string-constants");
|
|
14
|
+
/**
|
|
15
|
+
* Get the values of all arguments matching the criteria.
|
|
16
|
+
*/
|
|
17
|
+
function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue) {
|
|
18
|
+
if (argumentName) {
|
|
19
|
+
const arg = vertex?.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && arg.name === argumentName);
|
|
20
|
+
if (arg >= 0) {
|
|
21
|
+
argumentIndex = arg;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!vertex || argumentIndex === undefined) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (argumentIndex === 'unnamed') {
|
|
28
|
+
// return all unnamed arguments
|
|
29
|
+
const references = vertex.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.getReferenceOfArgument).filter(assert_1.isNotUndefined);
|
|
30
|
+
const map = new Map();
|
|
31
|
+
for (const ref of references) {
|
|
32
|
+
let valueNode = graph.idMap?.get(ref);
|
|
33
|
+
if (valueNode?.type === type_1.RType.Argument) {
|
|
34
|
+
valueNode = valueNode.value;
|
|
35
|
+
}
|
|
36
|
+
if (valueNode) {
|
|
37
|
+
// this should be evaluated in the callee-context
|
|
38
|
+
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue) ?? [dependencies_query_format_1.Unknown];
|
|
39
|
+
map.set(ref, new Set(values));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return map;
|
|
43
|
+
}
|
|
44
|
+
if (argumentIndex < vertex.args.length) {
|
|
45
|
+
const arg = (0, graph_1.getReferenceOfArgument)(vertex.args[argumentIndex]);
|
|
46
|
+
if (!arg) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
let valueNode = graph.idMap?.get(arg);
|
|
50
|
+
if (valueNode?.type === type_1.RType.Argument) {
|
|
51
|
+
valueNode = valueNode.value;
|
|
52
|
+
}
|
|
53
|
+
if (valueNode) {
|
|
54
|
+
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue) ?? [dependencies_query_format_1.Unknown];
|
|
55
|
+
return new Map([[arg, new Set(values)]]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
function hasCharacterOnly(variableResolve, graph, vertex, idMap) {
|
|
61
|
+
if (!vertex.args || vertex.args.length === 0 || !idMap) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const treatAsChar = getArgumentStringValue(variableResolve, graph, vertex, 5, 'character.only', true);
|
|
65
|
+
if (!treatAsChar) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const hasTrue = [...treatAsChar.values()].some(set => set?.has('TRUE'));
|
|
69
|
+
const hasFalse = hasTrue ? [...treatAsChar.values()].some(set => set === undefined || set.has('FALSE')) : false;
|
|
70
|
+
if (hasTrue && hasFalse) {
|
|
71
|
+
return 'maybe';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return hasTrue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environment, idMap, resolveValue) {
|
|
78
|
+
let full = true;
|
|
79
|
+
if (!resolveValue) {
|
|
80
|
+
full = false;
|
|
81
|
+
}
|
|
82
|
+
if (resolveValue === 'library') {
|
|
83
|
+
const hasChar = hasCharacterOnly(variableResolve, graph, vertex, idMap);
|
|
84
|
+
if (hasChar === false) {
|
|
85
|
+
if (argument.type === type_1.RType.Symbol) {
|
|
86
|
+
return [argument.lexeme];
|
|
87
|
+
}
|
|
88
|
+
full = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(argument, { environment, graph, full, resolve: variableResolve }));
|
|
92
|
+
if (resolved) {
|
|
93
|
+
const values = [];
|
|
94
|
+
for (const value of resolved.elements) {
|
|
95
|
+
if (!(0, r_value_1.isValue)(value)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
else if (value.type === 'string' && (0, r_value_1.isValue)(value.value)) {
|
|
99
|
+
values.push(value.value.str);
|
|
100
|
+
}
|
|
101
|
+
else if (value.type === 'logical' && (0, r_value_1.isValue)(value.value)) {
|
|
102
|
+
values.push(value.value.valueOf() ? convert_values_1.RTrue : convert_values_1.RFalse);
|
|
103
|
+
}
|
|
104
|
+
else if (value.type === 'vector' && (0, r_value_1.isValue)(value.elements)) {
|
|
105
|
+
const elements = (0, string_constants_1.collectStrings)(value.elements, !full);
|
|
106
|
+
if (elements === undefined) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
values.push(...elements);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return values;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=resolve-argument.js.map
|
|
@@ -2,33 +2,36 @@ import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/m
|
|
|
2
2
|
import type { REnvironmentInformation } from '../../environments/environment';
|
|
3
3
|
import type { DataflowGraph } from '../../graph/graph';
|
|
4
4
|
import type { Value } from '../values/r-value';
|
|
5
|
+
import type { VariableResolve } from '../../../config';
|
|
5
6
|
/**
|
|
6
7
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
7
|
-
* you want to resolve the value of
|
|
8
|
+
* you want to resolve the value of an identifier / node
|
|
8
9
|
*
|
|
9
|
-
* This function converts an RNode to its Value, but also
|
|
10
|
+
* This function converts an RNode to its Value, but also recursively resolves
|
|
10
11
|
* aliases and vectors (in case of a vector).
|
|
11
12
|
*
|
|
12
|
-
* @param a
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
13
|
+
* @param a - Ast node to resolve
|
|
14
|
+
* @param resolve - Variable resolve mode
|
|
15
|
+
* @param env - Environment to use
|
|
16
|
+
* @param graph - Dataflow Graph to use
|
|
17
|
+
* @param map - Idmap of Dataflow Graph
|
|
16
18
|
* @returns resolved value or top/bottom
|
|
17
19
|
*/
|
|
18
|
-
export declare function resolveNode(a: RNodeWithParent, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
|
|
20
|
+
export declare function resolveNode(resolve: VariableResolve, a: RNodeWithParent, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
|
|
19
21
|
/**
|
|
20
22
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
21
|
-
* you want to resolve the value of
|
|
23
|
+
* you want to resolve the value of an identifier / node
|
|
22
24
|
*
|
|
23
|
-
* This function converts an
|
|
24
|
-
* It also
|
|
25
|
+
* This function converts an r-node to a Value Vector {@link vectorFrom}
|
|
26
|
+
* It also recursively resolves any symbols, values, function calls (only c), in
|
|
25
27
|
* order to construct the value of the vector to resolve by calling {@link resolveIdToValue}
|
|
26
28
|
* or {@link resolveNode}
|
|
27
29
|
*
|
|
28
|
-
* @param a
|
|
29
|
-
* @param env
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
30
|
+
* @param a - Node of the vector to resolve
|
|
31
|
+
* @param env - Environment to use
|
|
32
|
+
* @param resolve - Variable resolve mode
|
|
33
|
+
* @param graph - Dataflow graph
|
|
34
|
+
* @param map - Idmap of Dataflow Graph
|
|
32
35
|
* @returns ValueVector or Top
|
|
33
36
|
*/
|
|
34
|
-
export declare function resolveAsVector(a: RNodeWithParent, env: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
|
|
37
|
+
export declare function resolveAsVector(resolve: VariableResolve, a: RNodeWithParent, env: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
|
|
@@ -15,18 +15,19 @@ const vector_constants_1 = require("../values/vectors/vector-constants");
|
|
|
15
15
|
const alias_tracking_1 = require("./alias-tracking");
|
|
16
16
|
/**
|
|
17
17
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
18
|
-
* you want to resolve the value of
|
|
18
|
+
* you want to resolve the value of an identifier / node
|
|
19
19
|
*
|
|
20
|
-
* This function converts an RNode to its Value, but also
|
|
20
|
+
* This function converts an RNode to its Value, but also recursively resolves
|
|
21
21
|
* aliases and vectors (in case of a vector).
|
|
22
22
|
*
|
|
23
|
-
* @param a
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
23
|
+
* @param a - Ast node to resolve
|
|
24
|
+
* @param resolve - Variable resolve mode
|
|
25
|
+
* @param env - Environment to use
|
|
26
|
+
* @param graph - Dataflow Graph to use
|
|
27
|
+
* @param map - Idmap of Dataflow Graph
|
|
27
28
|
* @returns resolved value or top/bottom
|
|
28
29
|
*/
|
|
29
|
-
function resolveNode(a, env, graph, map) {
|
|
30
|
+
function resolveNode(resolve, a, env, graph, map) {
|
|
30
31
|
if (a.type === type_1.RType.String) {
|
|
31
32
|
return (0, string_constants_1.stringFrom)(a.content.str);
|
|
32
33
|
}
|
|
@@ -43,27 +44,28 @@ function resolveNode(a, env, graph, map) {
|
|
|
43
44
|
}
|
|
44
45
|
if (origin.proc in built_in_1.BuiltInEvalHandlerMapper) {
|
|
45
46
|
const handler = built_in_1.BuiltInEvalHandlerMapper[origin.proc];
|
|
46
|
-
return handler(a, env, graph, map);
|
|
47
|
+
return handler(resolve, a, env, graph, map);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
return r_value_1.Top;
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
53
|
-
* you want to resolve the value of
|
|
54
|
+
* you want to resolve the value of an identifier / node
|
|
54
55
|
*
|
|
55
|
-
* This function converts an
|
|
56
|
-
* It also
|
|
56
|
+
* This function converts an r-node to a Value Vector {@link vectorFrom}
|
|
57
|
+
* It also recursively resolves any symbols, values, function calls (only c), in
|
|
57
58
|
* order to construct the value of the vector to resolve by calling {@link resolveIdToValue}
|
|
58
59
|
* or {@link resolveNode}
|
|
59
60
|
*
|
|
60
|
-
* @param a
|
|
61
|
-
* @param env
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
61
|
+
* @param a - Node of the vector to resolve
|
|
62
|
+
* @param env - Environment to use
|
|
63
|
+
* @param resolve - Variable resolve mode
|
|
64
|
+
* @param graph - Dataflow graph
|
|
65
|
+
* @param map - Idmap of Dataflow Graph
|
|
64
66
|
* @returns ValueVector or Top
|
|
65
67
|
*/
|
|
66
|
-
function resolveAsVector(a, env, graph, map) {
|
|
68
|
+
function resolveAsVector(resolve, a, env, graph, map) {
|
|
67
69
|
(0, assert_1.guard)(a.type === type_1.RType.FunctionCall);
|
|
68
70
|
const values = [];
|
|
69
71
|
for (const arg of a.arguments) {
|
|
@@ -74,14 +76,14 @@ function resolveAsVector(a, env, graph, map) {
|
|
|
74
76
|
return r_value_1.Top;
|
|
75
77
|
}
|
|
76
78
|
if (arg.value.type === type_1.RType.Symbol) {
|
|
77
|
-
const value = (0, alias_tracking_1.resolveIdToValue)(arg.info.id, { environment: env, idMap: map, graph: graph, full: true });
|
|
79
|
+
const value = (0, alias_tracking_1.resolveIdToValue)(arg.info.id, { environment: env, idMap: map, graph: graph, full: true, resolve });
|
|
78
80
|
if ((0, r_value_1.isTop)(value)) {
|
|
79
81
|
return r_value_1.Top;
|
|
80
82
|
}
|
|
81
83
|
values.push(value);
|
|
82
84
|
}
|
|
83
85
|
else {
|
|
84
|
-
const val = resolveNode(arg.value, env, graph, map);
|
|
86
|
+
const val = resolveNode(resolve, arg.value, env, graph, map);
|
|
85
87
|
if ((0, r_value_1.isTop)(val)) {
|
|
86
88
|
return r_value_1.Top;
|
|
87
89
|
}
|
|
@@ -2,7 +2,7 @@ import type { RStringValue } from '../../../../r-bridge/lang-4.x/convert-values'
|
|
|
2
2
|
import type { Lift, Value, ValueString } from '../r-value';
|
|
3
3
|
export declare function stringFrom(str: RStringValue | string): ValueString;
|
|
4
4
|
export declare function liftString(str: Lift<RStringValue>): ValueString;
|
|
5
|
-
export declare function collectStrings(a: Value[]): string[] | undefined;
|
|
5
|
+
export declare function collectStrings(a: Value[], withQuotes?: boolean): string[] | undefined;
|
|
6
6
|
export declare const ValueEmptyString: ValueString<Lift<RStringValue>>;
|
|
7
7
|
export declare const ValueStringTop: ValueString<Lift<RStringValue>>;
|
|
8
8
|
export declare const ValueStringBot: ValueString<Lift<RStringValue>>;
|
|
@@ -21,7 +21,7 @@ function liftString(str) {
|
|
|
21
21
|
value: str
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function collectStrings(a) {
|
|
24
|
+
function collectStrings(a, withQuotes = false) {
|
|
25
25
|
if ((0, general_1.bottomTopGuard)(a)) {
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
@@ -30,7 +30,12 @@ function collectStrings(a) {
|
|
|
30
30
|
if (value.type !== 'string' || !(0, r_value_1.isValue)(value) || !(0, r_value_1.isValue)(value.value)) {
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
if (withQuotes) {
|
|
34
|
+
values.push(`${value.value.quotes}${value.value.str}${value.value.quotes}`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
values.push(value.value.str);
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
return values;
|
|
36
41
|
}
|
package/dataflow/extractor.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { DataflowProcessors } from './processor';
|
|
|
3
3
|
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { RParseRequests } from '../r-bridge/retriever';
|
|
5
5
|
import type { KnownParserType, Parser } from '../r-bridge/parser';
|
|
6
|
+
import type { FlowrConfigOptions } from '../config';
|
|
6
7
|
/**
|
|
7
8
|
* The best friend of {@link produceDataFlowGraph} and {@link processDataflowFor}.
|
|
8
9
|
* Maps every {@link RType} in the normalized AST to a processor.
|
|
@@ -14,4 +15,4 @@ export declare const processors: DataflowProcessors<ParentInformation>;
|
|
|
14
15
|
* (e.g., in the event of a `source` call).
|
|
15
16
|
* For the actual, canonical fold entry point, see {@link processDataflowFor}.
|
|
16
17
|
*/
|
|
17
|
-
export declare function produceDataFlowGraph<OtherInfo>(parser: Parser<KnownParserType>, request: RParseRequests, completeAst: NormalizedAst<OtherInfo & ParentInformation
|
|
18
|
+
export declare function produceDataFlowGraph<OtherInfo>(parser: Parser<KnownParserType>, request: RParseRequests, completeAst: NormalizedAst<OtherInfo & ParentInformation>, config: FlowrConfigOptions): DataflowInformation;
|
package/dataflow/extractor.js
CHANGED
|
@@ -80,7 +80,7 @@ function resolveLinkToSideEffects(ast, graph) {
|
|
|
80
80
|
* (e.g., in the event of a `source` call).
|
|
81
81
|
* For the actual, canonical fold entry point, see {@link processDataflowFor}.
|
|
82
82
|
*/
|
|
83
|
-
function produceDataFlowGraph(parser, request, completeAst) {
|
|
83
|
+
function produceDataFlowGraph(parser, request, completeAst, config) {
|
|
84
84
|
let firstRequest;
|
|
85
85
|
const multifile = Array.isArray(request);
|
|
86
86
|
if (multifile) {
|
|
@@ -97,6 +97,7 @@ function produceDataFlowGraph(parser, request, completeAst) {
|
|
|
97
97
|
currentRequest: firstRequest,
|
|
98
98
|
controlDependencies: undefined,
|
|
99
99
|
referenceChain: [firstRequest],
|
|
100
|
+
flowrConfig: config
|
|
100
101
|
};
|
|
101
102
|
let df = (0, processor_1.processDataflowFor)(completeAst.ast, dfData);
|
|
102
103
|
df.graph.sourced.unshift(firstRequest.request === 'file' ? firstRequest.content : '<inline>');
|