@eagleoutice/flowr 2.2.11 → 2.2.13
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 +82 -20
- package/benchmark/slicer.d.ts +49 -22
- package/benchmark/slicer.js +89 -29
- package/benchmark/stats/print.js +16 -10
- package/benchmark/stats/size-of.js +18 -1
- package/benchmark/stats/stats.d.ts +3 -0
- package/benchmark/summarizer/first-phase/input.js +1 -1
- package/benchmark/summarizer/first-phase/process.js +3 -3
- package/benchmark/summarizer/second-phase/process.js +9 -3
- package/benchmark/summarizer/summarizer.js +1 -1
- package/cli/benchmark-app.d.ts +5 -0
- package/cli/benchmark-app.js +49 -6
- package/cli/benchmark-helper-app.d.ts +4 -0
- package/cli/benchmark-helper-app.js +20 -4
- package/cli/common/options.js +15 -6
- package/cli/common/script.js +1 -1
- package/cli/flowr.js +1 -1
- package/cli/repl/commands/repl-cfg.d.ts +2 -0
- package/cli/repl/commands/repl-cfg.js +38 -24
- package/cli/repl/commands/repl-commands.js +6 -2
- package/cli/repl/commands/repl-dataflow.d.ts +2 -0
- package/cli/repl/commands/repl-dataflow.js +37 -3
- package/cli/repl/commands/repl-execute.js +1 -1
- package/cli/repl/commands/repl-main.d.ts +1 -1
- package/cli/repl/commands/repl-main.js +1 -1
- package/cli/repl/commands/repl-normalize.js +1 -1
- package/cli/repl/commands/repl-query.js +2 -2
- package/cli/repl/core.js +1 -1
- package/cli/repl/prompt.js +1 -1
- package/cli/repl/server/connection.js +4 -4
- package/cli/repl/server/messages/message-analysis.d.ts +1 -1
- package/cli/script-core/statistics-core.js +1 -1
- package/cli/script-core/statistics-helper-core.js +4 -4
- package/config.d.ts +60 -21
- package/config.js +24 -4
- package/control-flow/basic-cfg-guided-visitor.d.ts +39 -0
- package/control-flow/basic-cfg-guided-visitor.js +114 -0
- package/control-flow/cfg-properties.d.ts +26 -0
- package/control-flow/cfg-properties.js +100 -0
- package/control-flow/cfg-simplification.d.ts +18 -0
- package/control-flow/cfg-simplification.js +55 -0
- package/control-flow/cfg-to-basic-blocks.d.ts +5 -0
- package/control-flow/cfg-to-basic-blocks.js +81 -0
- package/control-flow/control-flow-graph.d.ts +247 -0
- package/control-flow/control-flow-graph.js +290 -0
- package/control-flow/dfg-cfg-guided-visitor.d.ts +32 -0
- package/control-flow/dfg-cfg-guided-visitor.js +71 -0
- package/control-flow/diff-cfg.d.ts +11 -0
- package/control-flow/diff-cfg.js +161 -0
- package/control-flow/extract-cfg.d.ts +30 -0
- package/control-flow/extract-cfg.js +475 -0
- package/control-flow/happens-before.d.ts +7 -0
- package/{util/cfg → control-flow}/happens-before.js +3 -3
- package/control-flow/semantic-cfg-guided-visitor.d.ts +452 -0
- package/control-flow/semantic-cfg-guided-visitor.js +492 -0
- package/control-flow/simple-visitor.d.ts +25 -0
- package/control-flow/simple-visitor.js +80 -0
- package/control-flow/syntax-cfg-guided-visitor.d.ts +128 -0
- package/control-flow/syntax-cfg-guided-visitor.js +166 -0
- package/core/print/print.d.ts +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/environments/built-in-config.d.ts +5 -2
- package/dataflow/environments/built-in-config.js +17 -8
- package/dataflow/environments/built-in.d.ts +16 -5
- package/dataflow/environments/built-in.js +55 -6
- package/dataflow/environments/clone.d.ts +5 -0
- package/dataflow/environments/clone.js +5 -0
- package/dataflow/environments/default-builtin-config.d.ts +2 -0
- package/dataflow/environments/default-builtin-config.js +164 -13
- package/dataflow/environments/define.d.ts +5 -1
- package/dataflow/environments/define.js +36 -10
- package/dataflow/environments/overwrite.js +4 -0
- package/dataflow/environments/remove.d.ts +6 -0
- package/dataflow/environments/remove.js +24 -0
- package/dataflow/environments/resolve-by-name.js +16 -5
- package/dataflow/extractor.js +2 -2
- package/dataflow/graph/dataflowgraph-builder.d.ts +79 -7
- package/dataflow/graph/dataflowgraph-builder.js +106 -8
- package/dataflow/graph/diff-dataflow-graph.d.ts +16 -0
- package/dataflow/graph/{diff.js → diff-dataflow-graph.js} +30 -56
- package/dataflow/graph/graph.d.ts +17 -4
- package/dataflow/graph/graph.js +51 -12
- package/dataflow/graph/vertex.d.ts +59 -4
- package/dataflow/graph/vertex.js +32 -0
- package/dataflow/internal/linker.d.ts +3 -2
- package/dataflow/internal/linker.js +36 -25
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +1 -1
- 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 +67 -54
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +108 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +54 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +10 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +140 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +15 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +51 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +100 -31
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +35 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +15 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +75 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +5 -2
- package/dataflow/internal/process/functions/call/common.js +9 -5
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +2 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +10 -6
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -0
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
- package/dataflow/internal/process/process-named-call.d.ts +4 -1
- package/dataflow/internal/process/process-named-call.js +8 -5
- package/dataflow/origin/dfg-get-origin.d.ts +82 -0
- package/dataflow/origin/dfg-get-origin.js +116 -0
- package/documentation/doc-util/doc-cfg.d.ts +20 -4
- package/documentation/doc-util/doc-cfg.js +41 -7
- package/documentation/doc-util/doc-cli-option.js +4 -2
- package/documentation/doc-util/doc-code.js +10 -2
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-escape.d.ts +7 -0
- package/documentation/doc-util/doc-escape.js +19 -0
- package/documentation/doc-util/doc-files.d.ts +1 -0
- package/documentation/doc-util/doc-files.js +2 -1
- package/documentation/doc-util/doc-normalized-ast.js +3 -3
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -1
- package/documentation/doc-util/doc-search.js +1 -1
- package/documentation/doc-util/doc-server-message.js +2 -2
- package/documentation/doc-util/doc-structure.d.ts +1 -0
- package/documentation/doc-util/doc-structure.js +5 -0
- package/documentation/doc-util/doc-types.d.ts +7 -1
- package/documentation/doc-util/doc-types.js +13 -2
- package/documentation/print-capabilities-markdown.js +28 -2
- package/documentation/print-cfg-wiki.d.ts +1 -0
- package/documentation/print-cfg-wiki.js +572 -0
- package/documentation/print-core-wiki.js +2 -2
- package/documentation/print-dataflow-graph-wiki.js +180 -25
- package/documentation/print-engines-wiki.js +1 -1
- package/documentation/print-faq-wiki.d.ts +1 -0
- package/documentation/print-faq-wiki.js +75 -0
- package/documentation/print-interface-wiki.js +2 -1
- package/documentation/print-linting-and-testing-wiki.js +52 -36
- package/documentation/print-normalized-ast-wiki.js +1 -1
- package/documentation/print-onboarding-wiki.d.ts +1 -0
- package/documentation/print-onboarding-wiki.js +42 -0
- package/documentation/print-query-wiki.js +23 -3
- package/documentation/print-readme.js +10 -3
- package/package.json +10 -6
- package/queries/catalog/call-context-query/call-context-query-executor.js +5 -5
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +24 -21
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +17 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -26
- package/queries/catalog/dependencies-query/dependencies-query-format.js +4 -147
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +24 -0
- package/queries/catalog/dependencies-query/function-info/function-info.js +10 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.js +18 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +101 -0
- package/queries/catalog/dependencies-query/function-info/source-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/source-functions.js +11 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +87 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +4 -4
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.js +2 -2
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +5 -0
- package/queries/catalog/origin-query/origin-query-executor.js +33 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +71 -0
- package/queries/catalog/origin-query/origin-query-format.js +27 -0
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.js +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -2
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/search-query/search-query-format.js +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.js +2 -2
- package/queries/query-print.d.ts +1 -1
- package/queries/query-print.js +4 -4
- package/queries/query.d.ts +61 -2
- package/queries/query.js +3 -1
- 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/nodes/r-number.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +5 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +5 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +3 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- 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.js +26 -8
- package/r-bridge/retriever.js +1 -1
- package/search/search-executor/search-generators.d.ts +1 -1
- package/search/search-executor/search-transformer.d.ts +1 -1
- package/slicing/criterion/collect-all.js +1 -1
- package/slicing/static/slice-call.js +13 -3
- package/statistics/features/supported/assignments/post-process.js +1 -1
- package/statistics/features/supported/defined-functions/post-process.js +2 -2
- package/statistics/features/supported/used-functions/post-process.js +1 -1
- package/statistics/features/supported/used-packages/post-process.js +2 -2
- package/statistics/features/supported/values/post-process.js +2 -2
- package/statistics/output/print-stats.js +2 -2
- package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
- package/statistics/summarizer/post-process/clusterer.js +1 -1
- package/statistics/summarizer/post-process/histogram.js +3 -3
- package/statistics/summarizer/post-process/post-process-output.js +3 -3
- package/statistics/summarizer/second-phase/process.js +2 -2
- package/statistics/summarizer/summarizer.js +2 -2
- package/util/assert.js +36 -1
- package/util/cfg/cfg.d.ts +0 -80
- package/util/cfg/cfg.js +0 -549
- package/util/{arrays.d.ts → collections/arrays.d.ts} +24 -1
- package/util/{arrays.js → collections/arrays.js} +44 -3
- package/util/collections/set.js +17 -0
- package/util/{list-access.d.ts → containers.d.ts} +24 -4
- package/util/{list-access.js → containers.js} +42 -12
- package/util/diff-graph.d.ts +47 -0
- package/util/diff-graph.js +61 -0
- package/util/diff.d.ts +6 -6
- package/util/diff.js +1 -1
- package/util/mermaid/ast.js +12 -1
- package/util/mermaid/cfg.d.ts +9 -2
- package/util/mermaid/cfg.js +65 -13
- package/util/mermaid/dfg.d.ts +2 -1
- package/util/mermaid/dfg.js +26 -10
- package/util/mermaid/mermaid.d.ts +2 -0
- package/util/mermaid/mermaid.js +6 -0
- package/util/parallel.d.ts +2 -1
- package/util/parallel.js +11 -2
- package/util/prefix.d.ts +13 -0
- package/util/prefix.js +34 -0
- package/util/quads.js +1 -1
- package/util/schema.d.ts +1 -1
- package/util/schema.js +1 -1
- package/util/summarizer.js +1 -1
- package/util/{text.js → text/text.js} +1 -1
- package/util/{time.js → text/time.js} +1 -1
- package/util/version.js +1 -1
- package/dataflow/graph/diff.d.ts +0 -36
- package/util/cfg/happens-before.d.ts +0 -7
- package/util/cfg/visitor.d.ts +0 -9
- package/util/cfg/visitor.js +0 -30
- package/util/set.js +0 -31
- /package/util/{bimap.d.ts → collections/bimap.d.ts} +0 -0
- /package/util/{bimap.js → collections/bimap.js} +0 -0
- /package/util/{defaultmap.d.ts → collections/defaultmap.d.ts} +0 -0
- /package/util/{defaultmap.js → collections/defaultmap.js} +0 -0
- /package/util/{set.d.ts → collections/set.d.ts} +0 -0
- /package/util/{ansi.d.ts → text/ansi.d.ts} +0 -0
- /package/util/{ansi.js → text/ansi.js} +0 -0
- /package/util/{args.d.ts → text/args.d.ts} +0 -0
- /package/util/{args.js → text/args.js} +0 -0
- /package/util/{strings.d.ts → text/strings.d.ts} +0 -0
- /package/util/{strings.js → text/strings.js} +0 -0
- /package/util/{text.d.ts → text/text.d.ts} +0 -0
- /package/util/{time.d.ts → text/time.d.ts} +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processEvalCall = processEvalCall;
|
|
4
|
+
const info_1 = require("../../../../../info");
|
|
5
|
+
const config_1 = require("../../../../../../config");
|
|
6
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
7
|
+
const retriever_1 = require("../../../../../../r-bridge/retriever");
|
|
8
|
+
const decorate_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate");
|
|
9
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
|
+
const logger_1 = require("../../../../../logger");
|
|
11
|
+
const log_1 = require("../../../../../../util/log");
|
|
12
|
+
const built_in_source_1 = require("./built-in-source");
|
|
13
|
+
const edge_1 = require("../../../../../graph/edge");
|
|
14
|
+
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
15
|
+
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
16
|
+
const append_1 = require("../../../../../environments/append");
|
|
17
|
+
const assert_1 = require("../../../../../../util/assert");
|
|
18
|
+
const arrays_1 = require("../../../../../../util/collections/arrays");
|
|
19
|
+
function processEvalCall(name, args, rootId, data, config) {
|
|
20
|
+
if (args.length !== 1 || args[0] === r_function_call_1.EmptyArgument || !args[0].value) {
|
|
21
|
+
logger_1.dataflowLogger.warn(`Expected exactly one argument for eval currently, but got ${args.length} instead, skipping`);
|
|
22
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
23
|
+
}
|
|
24
|
+
const information = config.includeFunctionCall ?
|
|
25
|
+
(0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: [true], origin: 'builtin:eval' }).information
|
|
26
|
+
: (0, info_1.initializeCleanDataflowInformation)(rootId, data);
|
|
27
|
+
const evalArgument = args[0];
|
|
28
|
+
if (config.includeFunctionCall) {
|
|
29
|
+
information.graph.addEdge(rootId, args[0].value.info.id, edge_1.EdgeType.Returns);
|
|
30
|
+
}
|
|
31
|
+
if (!(0, config_1.getConfig)().solver.evalStrings) {
|
|
32
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping eval call ${JSON.stringify(evalArgument)} (disabled in config file)`);
|
|
33
|
+
information.graph.markIdForUnknownSideEffects(rootId);
|
|
34
|
+
return information;
|
|
35
|
+
}
|
|
36
|
+
const code = resolveEvalToCode(evalArgument.value, data.environment, data.completeAst.idMap);
|
|
37
|
+
if (code) {
|
|
38
|
+
const idGenerator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(name.lexeme + '::' + rootId, name.location);
|
|
39
|
+
data = {
|
|
40
|
+
...data,
|
|
41
|
+
controlDependencies: [...(data.controlDependencies ?? []), { id: rootId, when: true }]
|
|
42
|
+
};
|
|
43
|
+
const originalInfo = { ...information };
|
|
44
|
+
const result = [];
|
|
45
|
+
for (const c of code) {
|
|
46
|
+
const codeRequest = (0, retriever_1.requestFromInput)(c);
|
|
47
|
+
const r = (0, built_in_source_1.sourceRequest)(rootId, codeRequest, data, originalInfo, idGenerator);
|
|
48
|
+
result.push(r);
|
|
49
|
+
// add a returns edge from the eval to the result
|
|
50
|
+
for (const e of r.exitPoints) {
|
|
51
|
+
information.graph.addEdge(rootId, e, edge_1.EdgeType.Returns);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
graph: result.reduce((acc, r) => acc.mergeWith(r.graph), information.graph),
|
|
56
|
+
environment: result.reduce((acc, r) => (0, append_1.appendEnvironment)(acc, r.environment), information.environment),
|
|
57
|
+
entryPoint: rootId,
|
|
58
|
+
out: [...information.out, ...result.flatMap(r => r.out)],
|
|
59
|
+
in: [...information.in, ...result.flatMap(r => r.in)],
|
|
60
|
+
unknownReferences: [...information.unknownReferences, ...result.flatMap(r => r.unknownReferences)],
|
|
61
|
+
exitPoints: [...information.exitPoints, ...result.flatMap(r => r.exitPoints)],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Non-constant argument ${JSON.stringify(args)} for eval is currently not supported, skipping`);
|
|
65
|
+
information.graph.markIdForUnknownSideEffects(rootId);
|
|
66
|
+
return information;
|
|
67
|
+
}
|
|
68
|
+
function resolveEvalToCode(evalArgument, env, idMap) {
|
|
69
|
+
const val = evalArgument;
|
|
70
|
+
if (val.type === type_1.RType.FunctionCall && val.named && val.functionName.content === 'parse') {
|
|
71
|
+
const arg = val.arguments.find(v => v !== r_function_call_1.EmptyArgument && v.name?.content === 'text');
|
|
72
|
+
const nArg = val.arguments.find(v => v !== r_function_call_1.EmptyArgument && v.name?.content === 'n');
|
|
73
|
+
if (nArg !== undefined || arg === undefined || arg === r_function_call_1.EmptyArgument) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (arg.value?.type === type_1.RType.String) {
|
|
77
|
+
return [arg.value.content.str];
|
|
78
|
+
}
|
|
79
|
+
else if (arg.value?.type === type_1.RType.Symbol) {
|
|
80
|
+
const resolve = (0, resolve_by_name_1.resolveValueOfVariable)(arg.value.content, env, idMap);
|
|
81
|
+
if (resolve?.every(r => typeof r === 'object' && r !== null && 'str' in r)) {
|
|
82
|
+
return resolve.map(r => r.str);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (arg.value?.type === type_1.RType.FunctionCall && arg.value.named && ['paste', 'paste0'].includes(arg.value.functionName.content)) {
|
|
86
|
+
return handlePaste(arg.value.arguments, env, idMap, arg.value.functionName.content === 'paste' ? [' '] : ['']);
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
else if (val.type === type_1.RType.Symbol) {
|
|
91
|
+
// const resolved = resolveValueOfVariable(val.content, env);
|
|
92
|
+
// see https://github.com/flowr-analysis/flowr/pull/1467
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function getAsString(val, env, idMap) {
|
|
100
|
+
if (!val) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
if (val.type === type_1.RType.String) {
|
|
104
|
+
return [val.content.str];
|
|
105
|
+
}
|
|
106
|
+
else if (val.type === type_1.RType.Symbol) {
|
|
107
|
+
const resolved = (0, resolve_by_name_1.resolveValueOfVariable)(val.content, env, idMap);
|
|
108
|
+
if (resolved?.every(r => typeof r === 'object' && r !== null && 'str' in r)) {
|
|
109
|
+
return resolved.map(r => r.str);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
function handlePaste(args, env, idMap, sepDefault) {
|
|
115
|
+
const sepArg = args.find(v => v !== r_function_call_1.EmptyArgument && v.name?.content === 'sep');
|
|
116
|
+
if (sepArg) {
|
|
117
|
+
const res = sepArg !== r_function_call_1.EmptyArgument && sepArg.value ? getAsString(sepArg.value, env, idMap) : undefined;
|
|
118
|
+
if (!res) {
|
|
119
|
+
// sep not resolvable clearly / unknown
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
sepDefault = res;
|
|
123
|
+
}
|
|
124
|
+
const allArgs = args
|
|
125
|
+
.filter(v => v !== r_function_call_1.EmptyArgument && v.name?.content !== 'sep' && v.value)
|
|
126
|
+
.map(v => getAsString(v.value, env, idMap));
|
|
127
|
+
if (allArgs.some(assert_1.isUndefined)) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
// return all cartesian products using the separator
|
|
131
|
+
const result = [];
|
|
132
|
+
const cartesianProducts = (0, arrays_1.cartesianProduct)(...allArgs);
|
|
133
|
+
for (const sep of sepDefault) {
|
|
134
|
+
for (const c of cartesianProducts) {
|
|
135
|
+
result.push(c.join(sep));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=built-in-eval.js.map
|
|
@@ -42,6 +42,9 @@ function linkReadNameToWriteIfPossible(read, environments, listEnvironments, rem
|
|
|
42
42
|
for (const target of probableTarget) {
|
|
43
43
|
// we can stick with maybe even if readId.attribute is always
|
|
44
44
|
nextGraph.addEdge(read, target, edge_1.EdgeType.Reads);
|
|
45
|
+
if ((read.type === identifier_1.ReferenceType.Function || read.type === identifier_1.ReferenceType.BuiltInFunction) && ((0, built_in_1.isBuiltIn)(target.definedAt))) {
|
|
46
|
+
nextGraph.addEdge(read, target, edge_1.EdgeType.Calls);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
function processNextExpression(currentElement, environment, listEnvironments, remainingRead, nextGraph) {
|
|
@@ -66,7 +69,7 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
|
|
|
66
69
|
while (current !== undefined && current.id !== environment_1.BuiltInEnvironment.id) {
|
|
67
70
|
for (const definitions of current.memory.values()) {
|
|
68
71
|
for (const def of definitions) {
|
|
69
|
-
if (
|
|
72
|
+
if (!(0, built_in_1.isBuiltIn)(def.definedAt)) {
|
|
70
73
|
hasUpdate = true;
|
|
71
74
|
nextGraph.addEdge(def.nodeId, functionCall, edge_1.EdgeType.SideEffectOnCall);
|
|
72
75
|
}
|
|
@@ -90,7 +93,7 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
90
93
|
const listEnvironments = new Set();
|
|
91
94
|
const remainingRead = new Map();
|
|
92
95
|
const nextGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
93
|
-
|
|
96
|
+
let out = [];
|
|
94
97
|
const exitPoints = [];
|
|
95
98
|
let expressionCounter = 0;
|
|
96
99
|
const processedExpressions = [];
|
|
@@ -115,7 +118,7 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
115
118
|
processed.unknownReferences = (0, environment_1.makeAllMaybe)(processed.unknownReferences, nextGraph, processed.environment, false);
|
|
116
119
|
}
|
|
117
120
|
(0, info_1.addNonDefaultExitPoints)(exitPoints, processed.exitPoints);
|
|
118
|
-
out.
|
|
121
|
+
out = out.concat(processed.out);
|
|
119
122
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `expression ${expressionCounter} of ${expressions.length} has ${processed.unknownReferences.length} unknown nodes`);
|
|
120
123
|
processNextExpression(processed, environment, listEnvironments, remainingRead, nextGraph);
|
|
121
124
|
environment = exitPoints.length > 0 ? (0, overwrite_1.overwriteEnvironment)(environment, processed.environment) : processed.environment;
|
|
@@ -150,8 +153,10 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
150
153
|
rootId,
|
|
151
154
|
name,
|
|
152
155
|
data,
|
|
153
|
-
argumentProcessResult: processedExpressions
|
|
156
|
+
argumentProcessResult: processedExpressions,
|
|
157
|
+
origin: 'builtin:expression-list'
|
|
154
158
|
});
|
|
159
|
+
nextGraph.addEdge(rootId, (0, built_in_1.builtInId)('{'), edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
|
|
155
160
|
// process all exit points as potential returns:
|
|
156
161
|
for (const exit of exitPoints) {
|
|
157
162
|
if (exit.type === 1 /* ExitPointType.Return */ || exit.type === 0 /* ExitPointType.Default */) {
|
|
@@ -18,7 +18,7 @@ const identifier_1 = require("../../../../../environments/identifier");
|
|
|
18
18
|
function processForLoop(name, args, rootId, data) {
|
|
19
19
|
if (args.length !== 3) {
|
|
20
20
|
logger_1.dataflowLogger.warn(`For-Loop ${name.content} does not have three arguments, skipping`);
|
|
21
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
21
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
22
22
|
}
|
|
23
23
|
const [variableArg, vectorArg, bodyArg] = args.map(e => (0, unpack_argument_1.unpackArgument)(e));
|
|
24
24
|
(0, assert_1.guard)(variableArg !== undefined && vectorArg !== undefined && bodyArg !== undefined, () => `For-Loop ${JSON.stringify(args)} has missing arguments! Bad!`);
|
|
@@ -55,7 +55,8 @@ function processForLoop(name, args, rootId, data) {
|
|
|
55
55
|
rootId,
|
|
56
56
|
name,
|
|
57
57
|
data: { ...data, controlDependencies: originalDependency },
|
|
58
|
-
argumentProcessResult: [variable, vector, body]
|
|
58
|
+
argumentProcessResult: [variable, vector, body],
|
|
59
|
+
origin: 'builtin:for-loop'
|
|
59
60
|
});
|
|
60
61
|
/* mark the last argument as nse */
|
|
61
62
|
nextGraph.addEdge(rootId, body.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
|
|
@@ -12,6 +12,7 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
12
12
|
const logger_1 = require("../../../../../logger");
|
|
13
13
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
14
14
|
const graph_1 = require("../../../../../graph/graph");
|
|
15
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
15
16
|
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
16
17
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
17
18
|
const scoping_1 = require("../../../../../environments/scoping");
|
|
@@ -19,10 +20,11 @@ const environment_1 = require("../../../../../environments/environment");
|
|
|
19
20
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
20
21
|
const edge_1 = require("../../../../../graph/edge");
|
|
21
22
|
const log_1 = require("../../../../../../util/log");
|
|
23
|
+
const built_in_1 = require("../../../../../environments/built-in");
|
|
22
24
|
function processFunctionDefinition(name, args, rootId, data) {
|
|
23
25
|
if (args.length < 1) {
|
|
24
26
|
logger_1.dataflowLogger.warn(`Function Definition ${name.content} does not have an argument, skipping`);
|
|
25
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
27
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
26
28
|
}
|
|
27
29
|
/* we remove the last argument, as it is the body */
|
|
28
30
|
const parameters = args.slice(0, -1);
|
|
@@ -140,8 +142,15 @@ function updateNestedFunctionClosures(graph, outEnvironment, fnId) {
|
|
|
140
142
|
continue;
|
|
141
143
|
}
|
|
142
144
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Found ${resolved.length} references to open ref ${id} in closure of function definition ${fnId}`);
|
|
145
|
+
let allBuiltIn = true;
|
|
143
146
|
for (const ref of resolved) {
|
|
144
147
|
graph.addEdge(ingoing, ref, edge_1.EdgeType.Reads);
|
|
148
|
+
if (!(0, identifier_1.isReferenceType)(ref.type, identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.BuiltInFunction)) {
|
|
149
|
+
allBuiltIn = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (allBuiltIn) {
|
|
153
|
+
remainingIn.push(ingoing);
|
|
145
154
|
}
|
|
146
155
|
}
|
|
147
156
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Keeping ${remainingIn.length} references to open ref ${id} in closure of function definition ${fnId}`);
|
|
@@ -191,8 +200,10 @@ function updateNestedFunctionCalls(graph, outEnvironment) {
|
|
|
191
200
|
}
|
|
192
201
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Found ${resolved.length} references to open ref ${id} in closure of function definition ${id}`);
|
|
193
202
|
for (const def of resolved) {
|
|
194
|
-
|
|
195
|
-
|
|
203
|
+
if (!(0, built_in_1.isBuiltIn)(def.nodeId)) {
|
|
204
|
+
graph.addEdge(ingoing, def, edge_1.EdgeType.DefinedByOnCall);
|
|
205
|
+
graph.addEdge(id, def, edge_1.EdgeType.DefinesOnCall);
|
|
206
|
+
}
|
|
196
207
|
}
|
|
197
208
|
}
|
|
198
209
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Keeping ${remainingIn.length} references to open ref ${id} in closure of function definition ${id}`);
|
|
@@ -209,7 +220,7 @@ function prepareFunctionEnvironment(data) {
|
|
|
209
220
|
}
|
|
210
221
|
/**
|
|
211
222
|
* Within something like `f <- function(a=b, m=3) { b <- 1; a; b <- 5; a + 1 }`
|
|
212
|
-
* `a` will be defined by `b` and `b`will be a promise object bound by the first definition of b it can find.
|
|
223
|
+
* `a` will be defined by `b` and `b` will be a promise object bound by the first definition of b it can find.
|
|
213
224
|
* This means that this function returns `2` due to the first `b <- 1` definition.
|
|
214
225
|
* If the code is `f <- function(a=b, m=3) { if(m > 3) { b <- 1; }; a; b <- 5; a + 1 }`, we need a link to `b <- 1` and `b <- 6`
|
|
215
226
|
* as `b` can be defined by either one of them.
|
|
@@ -11,12 +11,12 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
11
11
|
function processGet(name, args, rootId, data) {
|
|
12
12
|
if (args.length !== 1) {
|
|
13
13
|
logger_1.dataflowLogger.warn(`symbol access with ${name.content} has not 1 argument, skipping`);
|
|
14
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
14
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
15
15
|
}
|
|
16
16
|
const retrieve = (0, unpack_argument_1.unpackArgument)(args[0]);
|
|
17
17
|
if (retrieve === undefined || retrieve.type !== type_1.RType.String) {
|
|
18
18
|
logger_1.dataflowLogger.warn(`symbol access with ${name.content} has not 1 argument, skipping`);
|
|
19
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
19
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
20
20
|
}
|
|
21
21
|
const treatTargetAsSymbol = {
|
|
22
22
|
type: type_1.RType.Symbol,
|
|
@@ -30,7 +30,8 @@ function processGet(name, args, rootId, data) {
|
|
|
30
30
|
name,
|
|
31
31
|
args: (0, make_argument_1.wrapArgumentsUnnamed)([treatTargetAsSymbol], data.completeAst.idMap),
|
|
32
32
|
rootId,
|
|
33
|
-
data
|
|
33
|
+
data,
|
|
34
|
+
origin: 'builtin:get'
|
|
34
35
|
});
|
|
35
36
|
const firstArg = processedArguments[0];
|
|
36
37
|
if (firstArg) {
|
|
@@ -15,12 +15,12 @@ const environment_1 = require("../../../../../environments/environment");
|
|
|
15
15
|
function processIfThenElse(name, args, rootId, data) {
|
|
16
16
|
if (args.length !== 2 && args.length !== 3) {
|
|
17
17
|
logger_1.dataflowLogger.warn(`If-then-else ${name.content} has something different from 2 or 3 arguments, skipping`);
|
|
18
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
18
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
19
19
|
}
|
|
20
20
|
const [condArg, thenArg, otherwiseArg] = args.map(e => (0, unpack_argument_1.unpackArgument)(e));
|
|
21
21
|
if (condArg === undefined || thenArg === undefined) {
|
|
22
22
|
logger_1.dataflowLogger.warn(`If-then-else ${name.content} has empty condition or then case in ${JSON.stringify(args)}, skipping`);
|
|
23
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
23
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
24
24
|
}
|
|
25
25
|
const cond = (0, processor_1.processDataflowFor)(condArg, data);
|
|
26
26
|
if ((0, info_1.alwaysExits)(cond)) {
|
|
@@ -92,7 +92,8 @@ function processIfThenElse(name, args, rootId, data) {
|
|
|
92
92
|
rootId,
|
|
93
93
|
name,
|
|
94
94
|
data: { ...data, controlDependencies: originalDependency },
|
|
95
|
-
argumentProcessResult: [cond, then, otherwise]
|
|
95
|
+
argumentProcessResult: [cond, then, otherwise],
|
|
96
|
+
origin: 'builtin:if-then-else'
|
|
96
97
|
});
|
|
97
98
|
// as an if always evaluates its condition, we add a 'reads'-edge
|
|
98
99
|
nextGraph.addEdge(name.info.id, cond.entryPoint, edge_1.EdgeType.Reads);
|
|
@@ -10,12 +10,12 @@ function processLibrary(name, args, rootId, data) {
|
|
|
10
10
|
/* we do not really know what loading the library does and what side effects it causes, hence we mark it as an unknown side effect */
|
|
11
11
|
if (args.length !== 1) {
|
|
12
12
|
logger_1.dataflowLogger.warn(`Currently only one-arg library-likes are allows (for ${name.content}), skipping`);
|
|
13
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: true }).information;
|
|
13
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: true, origin: 'default' }).information;
|
|
14
14
|
}
|
|
15
15
|
const nameToLoad = (0, unpack_argument_1.unpackArgument)(args[0]);
|
|
16
16
|
if (nameToLoad === undefined || nameToLoad.type !== type_1.RType.Symbol) {
|
|
17
17
|
logger_1.dataflowLogger.warn('No library name provided, skipping');
|
|
18
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: true }).information;
|
|
18
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: true, origin: 'default' }).information;
|
|
19
19
|
}
|
|
20
20
|
// treat as a function call but convert the first argument to a string
|
|
21
21
|
const newArg = {
|
|
@@ -30,7 +30,8 @@ function processLibrary(name, args, rootId, data) {
|
|
|
30
30
|
};
|
|
31
31
|
return (0, known_call_handling_1.processKnownFunctionCall)({
|
|
32
32
|
name, args: (0, make_argument_1.wrapArgumentsUnnamed)([newArg], data.completeAst.idMap), rootId, data,
|
|
33
|
-
hasUnknownSideEffect: true
|
|
33
|
+
hasUnknownSideEffect: true,
|
|
34
|
+
origin: 'builtin:library'
|
|
34
35
|
}).information;
|
|
35
36
|
}
|
|
36
37
|
//# sourceMappingURL=built-in-library.js.map
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.processList = processList;
|
|
4
4
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
5
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
6
|
-
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
7
6
|
const known_call_handling_1 = require("../known-call-handling");
|
|
8
7
|
const config_1 = require("../../../../../../config");
|
|
8
|
+
const containers_1 = require("../../../../../../util/containers");
|
|
9
9
|
/**
|
|
10
10
|
* Process a list call.
|
|
11
11
|
*
|
|
@@ -15,36 +15,70 @@ const config_1 = require("../../../../../../config");
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
function processList(name, args, rootId, data) {
|
|
18
|
+
const fnCall = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'builtin:list' });
|
|
18
19
|
if (!(0, config_1.getConfig)().solver.pointerTracking) {
|
|
19
|
-
return
|
|
20
|
+
return fnCall.information;
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
+
const listArgs = [];
|
|
22
23
|
for (const arg of args) {
|
|
23
24
|
// Skip non named arguments
|
|
24
|
-
if (arg === r_function_call_1.EmptyArgument || arg.type !== type_1.RType.Argument || arg.
|
|
25
|
+
if (arg === r_function_call_1.EmptyArgument || arg.type !== type_1.RType.Argument || arg.value === undefined) {
|
|
25
26
|
continue;
|
|
26
27
|
}
|
|
27
|
-
let newIndex
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
let newIndex;
|
|
29
|
+
if (arg.name) {
|
|
30
|
+
// Named argument
|
|
31
|
+
newIndex = {
|
|
32
|
+
identifier: {
|
|
33
|
+
index: arg.info.index,
|
|
34
|
+
lexeme: arg.name.content
|
|
35
|
+
},
|
|
36
|
+
nodeId: arg.info.id,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Unnamed argument
|
|
41
|
+
newIndex = {
|
|
42
|
+
identifier: {
|
|
43
|
+
index: arg.info.index,
|
|
44
|
+
},
|
|
45
|
+
nodeId: arg.value.info.id,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Check whether argument value can be resolved
|
|
49
|
+
if (arg.value.type === type_1.RType.Symbol) {
|
|
50
|
+
const indicesCollection = (0, containers_1.resolveIndicesByName)(arg.value.lexeme, data.environment);
|
|
51
|
+
if (indicesCollection) {
|
|
36
52
|
newIndex = {
|
|
37
53
|
...newIndex,
|
|
38
|
-
subIndices:
|
|
54
|
+
subIndices: indicesCollection,
|
|
39
55
|
};
|
|
40
56
|
}
|
|
41
57
|
}
|
|
42
|
-
|
|
58
|
+
else {
|
|
59
|
+
// Check whether argument is nested container
|
|
60
|
+
const indicesCollection = fnCall.information.graph.getVertex(arg.value.info.id)?.indicesCollection;
|
|
61
|
+
if (indicesCollection) {
|
|
62
|
+
newIndex = {
|
|
63
|
+
...newIndex,
|
|
64
|
+
subIndices: indicesCollection,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
listArgs.push(newIndex);
|
|
69
|
+
}
|
|
70
|
+
if ((0, config_1.isOverPointerAnalysisThreshold)(listArgs.length)) {
|
|
71
|
+
return fnCall.information;
|
|
43
72
|
}
|
|
44
73
|
const indices = {
|
|
45
|
-
indices:
|
|
74
|
+
indices: listArgs,
|
|
46
75
|
isContainer: true,
|
|
47
76
|
};
|
|
48
|
-
|
|
77
|
+
// Add resolved indices to vertex
|
|
78
|
+
const vertex = fnCall.information.graph.getVertex(rootId);
|
|
79
|
+
if (vertex) {
|
|
80
|
+
vertex.indicesCollection = [indices];
|
|
81
|
+
}
|
|
82
|
+
return fnCall.information;
|
|
49
83
|
}
|
|
50
84
|
//# sourceMappingURL=built-in-list.js.map
|
|
@@ -10,7 +10,7 @@ const vertex_1 = require("../../../../../graph/vertex");
|
|
|
10
10
|
const edge_1 = require("../../../../../graph/edge");
|
|
11
11
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
12
12
|
function processPipe(name, args, rootId, data) {
|
|
13
|
-
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data });
|
|
13
|
+
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'builtin:pipe' });
|
|
14
14
|
if (args.length !== 2) {
|
|
15
15
|
logger_1.dataflowLogger.warn(`Pipe ${name.content} has something else than 2 arguments, skipping`);
|
|
16
16
|
return information;
|
|
@@ -4,16 +4,17 @@ exports.processQuote = processQuote;
|
|
|
4
4
|
const known_call_handling_1 = require("../known-call-handling");
|
|
5
5
|
const edge_1 = require("../../../../../graph/edge");
|
|
6
6
|
function processQuote(name, args, rootId, data, config) {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const startEnv = data.environment;
|
|
8
|
+
const { information, processedArguments, fnRef } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'builtin:quote' });
|
|
9
|
+
let inRefs = [fnRef];
|
|
10
|
+
let outRefs = [];
|
|
11
|
+
let unknownRefs = [];
|
|
11
12
|
for (let i = 0; i < args.length; i++) {
|
|
12
13
|
const processedArg = processedArguments[i];
|
|
13
14
|
if (processedArg && i !== config?.quoteArgumentsWithIndex) {
|
|
14
|
-
inRefs.
|
|
15
|
-
outRefs.
|
|
16
|
-
unknownRefs.
|
|
15
|
+
inRefs = inRefs.concat(processedArg.in);
|
|
16
|
+
outRefs = outRefs.concat(processedArg.out);
|
|
17
|
+
unknownRefs = unknownRefs.concat(processedArg.unknownReferences);
|
|
17
18
|
}
|
|
18
19
|
else if (processedArg) {
|
|
19
20
|
information.graph.addEdge(rootId, processedArg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
|
|
@@ -25,6 +26,7 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
25
26
|
}
|
|
26
27
|
return {
|
|
27
28
|
...information,
|
|
29
|
+
environment: startEnv,
|
|
28
30
|
in: inRefs,
|
|
29
31
|
out: outRefs,
|
|
30
32
|
unknownReferences: unknownRefs
|
|
@@ -11,7 +11,7 @@ const logger_1 = require("../../../../../logger");
|
|
|
11
11
|
function processRepeatLoop(name, args, rootId, data) {
|
|
12
12
|
if (args.length !== 1 || args[0] === r_function_call_1.EmptyArgument) {
|
|
13
13
|
logger_1.dataflowLogger.warn(`Repeat-Loop ${name.content} does not have 1 argument, skipping`);
|
|
14
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
14
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
15
15
|
}
|
|
16
16
|
const unpacked = (0, unpack_argument_1.unpackArgument)(args[0]);
|
|
17
17
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
@@ -25,7 +25,8 @@ function processRepeatLoop(name, args, rootId, data) {
|
|
|
25
25
|
}
|
|
26
26
|
return d;
|
|
27
27
|
},
|
|
28
|
-
markAsNSE: [0]
|
|
28
|
+
markAsNSE: [0],
|
|
29
|
+
origin: 'builtin:repeat-loop'
|
|
29
30
|
});
|
|
30
31
|
const body = processedArguments[0];
|
|
31
32
|
(0, assert_1.guard)(body !== undefined, () => `Repeat-Loop ${name.content} has no body, impossible!`);
|
|
@@ -5,9 +5,13 @@ 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 RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
7
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
|
+
import type { ContainerIndicesCollection } from '../../../../../graph/vertex';
|
|
8
9
|
export declare function processReplacementFunction<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>,
|
|
9
10
|
/** The last one has to be the value */
|
|
10
11
|
args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
|
|
11
12
|
makeMaybe?: boolean;
|
|
12
13
|
assignmentOperator?: '<-' | '<<-';
|
|
14
|
+
readIndices?: boolean;
|
|
15
|
+
activeIndices?: ContainerIndicesCollection;
|
|
16
|
+
assignRootId?: NodeId;
|
|
13
17
|
} & ForceArguments): DataflowInformation;
|