@eagleoutice/flowr 1.4.1 → 1.5.0
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 +3 -3
- package/abstract-interpretation/processor.js +9 -3
- package/config.d.ts +16 -0
- package/config.js +75 -0
- package/core/input.d.ts +1 -1
- package/core/output.d.ts +1 -2
- package/core/print/parse-printer.d.ts +1 -2
- package/core/print/parse-printer.js +6 -4
- package/core/print/slice-diff-ansi.js +7 -7
- package/core/slicer.js +4 -8
- package/core/steps.d.ts +355 -31
- package/core/steps.js +7 -14
- package/dataflow/environments/environment.js +8 -0
- package/dataflow/environments/register.js +1 -0
- package/dataflow/extractor.d.ts +2 -2
- package/dataflow/extractor.js +10 -2
- package/dataflow/internal/process/functions/function-call.js +7 -1
- package/dataflow/internal/process/functions/source.d.ts +8 -0
- package/dataflow/internal/process/functions/source.js +81 -0
- package/dataflow/processor.d.ts +10 -1
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/package.json +75 -202
- package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/index.js +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
- package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
- package/r-bridge/lang-4.x/values.d.ts +0 -1
- package/r-bridge/lang-4.x/values.js +14 -6
- package/r-bridge/retriever.d.ts +25 -21
- package/r-bridge/retriever.js +73 -23
- package/r-bridge/shell-executor.d.ts +3 -17
- package/r-bridge/shell-executor.js +9 -78
- package/r-bridge/shell.d.ts +5 -27
- package/r-bridge/shell.js +31 -92
- package/{statistics/output → util}/ansi.js +1 -1
- package/util/args.d.ts +8 -4
- package/util/args.js +11 -4
- package/util/cfg/visitor.js +1 -1
- package/util/files.d.ts +6 -0
- package/util/files.js +11 -1
- package/util/log.js +3 -0
- package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
- package/util/summarizer.js +37 -0
- package/util/version.d.ts +2 -0
- package/util/version.js +10 -0
- package/benchmark/index.d.ts +0 -3
- package/benchmark/index.js +0 -20
- package/benchmark/slicer.d.ts +0 -101
- package/benchmark/slicer.js +0 -225
- package/benchmark/stats/index.d.ts +0 -10
- package/benchmark/stats/index.js +0 -27
- package/benchmark/stats/print.d.ts +0 -7
- package/benchmark/stats/print.js +0 -157
- package/benchmark/stats/stats.d.ts +0 -41
- package/benchmark/stats/stats.js +0 -6
- package/benchmark/stopwatch.d.ts +0 -35
- package/benchmark/stopwatch.js +0 -79
- package/cli/benchmark-app.d.ts +0 -9
- package/cli/benchmark-app.js +0 -52
- package/cli/benchmark-helper-app.d.ts +0 -7
- package/cli/benchmark-helper-app.js +0 -60
- package/cli/common/features.d.ts +0 -3
- package/cli/common/features.js +0 -30
- package/cli/common/index.d.ts +0 -2
- package/cli/common/index.js +0 -19
- package/cli/common/options.d.ts +0 -20
- package/cli/common/options.js +0 -82
- package/cli/common/script.d.ts +0 -21
- package/cli/common/script.js +0 -61
- package/cli/common/scripts-info.d.ts +0 -24
- package/cli/common/scripts-info.js +0 -69
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -46
- package/cli/repl/commands/cfg.d.ts +0 -3
- package/cli/repl/commands/cfg.js +0 -37
- package/cli/repl/commands/commands.d.ts +0 -11
- package/cli/repl/commands/commands.js +0 -103
- package/cli/repl/commands/dataflow.d.ts +0 -3
- package/cli/repl/commands/dataflow.js +0 -34
- package/cli/repl/commands/execute.d.ts +0 -4
- package/cli/repl/commands/execute.js +0 -27
- package/cli/repl/commands/index.d.ts +0 -2
- package/cli/repl/commands/index.js +0 -19
- package/cli/repl/commands/main.d.ts +0 -39
- package/cli/repl/commands/main.js +0 -14
- package/cli/repl/commands/normalize.d.ts +0 -3
- package/cli/repl/commands/normalize.js +0 -34
- package/cli/repl/commands/parse.d.ts +0 -2
- package/cli/repl/commands/parse.js +0 -109
- package/cli/repl/commands/quit.d.ts +0 -2
- package/cli/repl/commands/quit.js +0 -12
- package/cli/repl/commands/version.d.ts +0 -16
- package/cli/repl/commands/version.js +0 -33
- package/cli/repl/core.d.ts +0 -39
- package/cli/repl/core.js +0 -116
- package/cli/repl/execute.d.ts +0 -28
- package/cli/repl/execute.js +0 -79
- package/cli/repl/index.d.ts +0 -5
- package/cli/repl/index.js +0 -22
- package/cli/repl/prompt.d.ts +0 -2
- package/cli/repl/prompt.js +0 -9
- package/cli/repl/server/connection.d.ts +0 -21
- package/cli/repl/server/connection.js +0 -218
- package/cli/repl/server/messages/analysis.d.ts +0 -71
- package/cli/repl/server/messages/analysis.js +0 -21
- package/cli/repl/server/messages/error.d.ts +0 -11
- package/cli/repl/server/messages/error.js +0 -3
- package/cli/repl/server/messages/hello.d.ts +0 -20
- package/cli/repl/server/messages/hello.js +0 -3
- package/cli/repl/server/messages/index.d.ts +0 -1
- package/cli/repl/server/messages/index.js +0 -3
- package/cli/repl/server/messages/messages.d.ts +0 -35
- package/cli/repl/server/messages/messages.js +0 -40
- package/cli/repl/server/messages/repl.d.ts +0 -33
- package/cli/repl/server/messages/repl.js +0 -37
- package/cli/repl/server/messages/slice.d.ts +0 -25
- package/cli/repl/server/messages/slice.js +0 -37
- package/cli/repl/server/net.d.ts +0 -49
- package/cli/repl/server/net.js +0 -63
- package/cli/repl/server/send.d.ts +0 -4
- package/cli/repl/server/send.js +0 -18
- package/cli/repl/server/server.d.ts +0 -20
- package/cli/repl/server/server.js +0 -66
- package/cli/repl/server/validate.d.ts +0 -15
- package/cli/repl/server/validate.js +0 -34
- package/cli/slicer-app.d.ts +0 -11
- package/cli/slicer-app.js +0 -81
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -98
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -83
- package/cli/summarizer-app.d.ts +0 -18
- package/cli/summarizer-app.js +0 -67
- package/flowr.d.ts +0 -27
- package/flowr.js +0 -137
- package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
- package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
- package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
- package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
- package/statistics/features/common-syntax-probability.d.ts +0 -31
- package/statistics/features/common-syntax-probability.js +0 -156
- package/statistics/features/feature.d.ts +0 -175
- package/statistics/features/feature.js +0 -30
- package/statistics/features/index.d.ts +0 -1
- package/statistics/features/index.js +0 -18
- package/statistics/features/post-processing.d.ts +0 -12
- package/statistics/features/post-processing.js +0 -21
- package/statistics/features/supported/assignments/assignments.d.ts +0 -11
- package/statistics/features/supported/assignments/assignments.js +0 -53
- package/statistics/features/supported/assignments/index.d.ts +0 -1
- package/statistics/features/supported/assignments/index.js +0 -6
- package/statistics/features/supported/assignments/post-process.d.ts +0 -3
- package/statistics/features/supported/assignments/post-process.js +0 -125
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -133
- package/statistics/features/supported/comments/index.d.ts +0 -1
- package/statistics/features/supported/comments/index.js +0 -6
- package/statistics/features/supported/comments/post-process.d.ts +0 -3
- package/statistics/features/supported/comments/post-process.js +0 -50
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -67
- package/statistics/features/supported/control-flow/index.d.ts +0 -1
- package/statistics/features/supported/control-flow/index.js +0 -6
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
- package/statistics/features/supported/control-flow/post-process.js +0 -65
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -118
- package/statistics/features/supported/data-access/index.d.ts +0 -1
- package/statistics/features/supported/data-access/index.js +0 -6
- package/statistics/features/supported/data-access/post-process.d.ts +0 -3
- package/statistics/features/supported/data-access/post-process.js +0 -107
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
- package/statistics/features/supported/defined-functions/index.d.ts +0 -1
- package/statistics/features/supported/defined-functions/index.js +0 -6
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -177
- package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/expression-list.js +0 -36
- package/statistics/features/supported/expression-list/index.d.ts +0 -1
- package/statistics/features/supported/expression-list/index.js +0 -6
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
- package/statistics/features/supported/expression-list/post-process.js +0 -44
- package/statistics/features/supported/index.d.ts +0 -10
- package/statistics/features/supported/index.js +0 -27
- package/statistics/features/supported/loops/index.d.ts +0 -1
- package/statistics/features/supported/loops/index.js +0 -6
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -79
- package/statistics/features/supported/loops/post-process.d.ts +0 -3
- package/statistics/features/supported/loops/post-process.js +0 -72
- package/statistics/features/supported/used-functions/index.d.ts +0 -1
- package/statistics/features/supported/used-functions/index.js +0 -6
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -179
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -95
- package/statistics/features/supported/used-packages/index.d.ts +0 -1
- package/statistics/features/supported/used-packages/index.js +0 -6
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
- package/statistics/features/supported/used-packages/post-process.js +0 -121
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -130
- package/statistics/features/supported/values/index.d.ts +0 -1
- package/statistics/features/supported/values/index.js +0 -6
- package/statistics/features/supported/values/post-process.d.ts +0 -3
- package/statistics/features/supported/values/post-process.js +0 -72
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -101
- package/statistics/features/supported/variables/index.d.ts +0 -1
- package/statistics/features/supported/variables/index.js +0 -6
- package/statistics/features/supported/variables/post-process.d.ts +0 -9
- package/statistics/features/supported/variables/post-process.js +0 -122
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -70
- package/statistics/index.d.ts +0 -6
- package/statistics/index.js +0 -24
- package/statistics/meta-statistics.d.ts +0 -33
- package/statistics/meta-statistics.js +0 -17
- package/statistics/output/file-provider.d.ts +0 -37
- package/statistics/output/file-provider.js +0 -97
- package/statistics/output/index.d.ts +0 -4
- package/statistics/output/index.js +0 -21
- package/statistics/output/print-stats.d.ts +0 -17
- package/statistics/output/print-stats.js +0 -69
- package/statistics/output/statistics-file.d.ts +0 -37
- package/statistics/output/statistics-file.js +0 -69
- package/statistics/statistics.d.ts +0 -24
- package/statistics/statistics.js +0 -109
- package/util/summarizer/auto-detect.d.ts +0 -2
- package/util/summarizer/auto-detect.js +0 -32
- package/util/summarizer/benchmark/data.d.ts +0 -66
- package/util/summarizer/benchmark/data.js +0 -13
- package/util/summarizer/benchmark/first-phase/input.d.ts +0 -2
- package/util/summarizer/benchmark/first-phase/input.js +0 -59
- package/util/summarizer/benchmark/first-phase/process.d.ts +0 -10
- package/util/summarizer/benchmark/first-phase/process.js +0 -208
- package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
- package/util/summarizer/benchmark/second-phase/graph.js +0 -54
- package/util/summarizer/benchmark/second-phase/process.d.ts +0 -4
- package/util/summarizer/benchmark/second-phase/process.js +0 -89
- package/util/summarizer/benchmark/summarizer.d.ts +0 -35
- package/util/summarizer/benchmark/summarizer.js +0 -49
- package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
- package/util/summarizer/statistics/first-phase/process.js +0 -81
- package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
- package/util/summarizer/statistics/post-process/clusterer.js +0 -43
- package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
- package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
- package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
- package/util/summarizer/statistics/post-process/histogram.js +0 -128
- package/util/summarizer/statistics/post-process/index.d.ts +0 -4
- package/util/summarizer/statistics/post-process/index.js +0 -21
- package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
- package/util/summarizer/statistics/post-process/post-process-output.js +0 -104
- package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
- package/util/summarizer/statistics/second-phase/process.js +0 -117
- package/util/summarizer/statistics/summarizer.d.ts +0 -35
- package/util/summarizer/statistics/summarizer.js +0 -135
- package/util/summarizer/summarizer.js +0 -13
- /package/{statistics/output → util}/ansi.d.ts +0 -0
package/dataflow/extractor.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processBinaryOp = exports.produceDataFlowGraph = void 0;
|
|
4
|
+
const r_bridge_1 = require("../r-bridge");
|
|
4
5
|
const processor_1 = require("./processor");
|
|
5
6
|
const uninteresting_leaf_1 = require("./internal/process/uninteresting-leaf");
|
|
6
7
|
const symbol_1 = require("./internal/process/symbol");
|
|
@@ -44,8 +45,15 @@ const processors = {
|
|
|
44
45
|
["RArgument" /* RType.Argument */]: argument_1.processFunctionArgument,
|
|
45
46
|
["RExpressionList" /* RType.ExpressionList */]: expression_list_1.processExpressionList,
|
|
46
47
|
};
|
|
47
|
-
function produceDataFlowGraph(ast, initialScope = scopes_1.LocalScope) {
|
|
48
|
-
return (0, processor_1.processDataflowFor)(ast.ast, {
|
|
48
|
+
function produceDataFlowGraph(request, ast, initialScope = scopes_1.LocalScope) {
|
|
49
|
+
return (0, processor_1.processDataflowFor)(ast.ast, {
|
|
50
|
+
completeAst: ast,
|
|
51
|
+
activeScope: initialScope,
|
|
52
|
+
environments: (0, environments_1.initializeCleanEnvironments)(),
|
|
53
|
+
processors: processors,
|
|
54
|
+
currentRequest: request,
|
|
55
|
+
referenceChain: [(0, r_bridge_1.requestFingerprint)(request)]
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
exports.produceDataFlowGraph = produceDataFlowGraph;
|
|
51
59
|
function processBinaryOp(node, data) {
|
|
@@ -7,6 +7,7 @@ const assert_1 = require("../../../../util/assert");
|
|
|
7
7
|
const index_1 = require("../../../index");
|
|
8
8
|
const linker_1 = require("../../linker");
|
|
9
9
|
const scopes_1 = require("../../../environments/scopes");
|
|
10
|
+
const source_1 = require("./source");
|
|
10
11
|
exports.UnnamedFunctionCallPrefix = 'unnamed-function-call-';
|
|
11
12
|
function processFunctionCall(functionCall, data) {
|
|
12
13
|
const named = functionCall.flavor === 'named';
|
|
@@ -86,7 +87,7 @@ function processFunctionCall(functionCall, data) {
|
|
|
86
87
|
// push the called function to the ids:
|
|
87
88
|
inIds.push(...functionName.in, ...functionName.unknownReferences);
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
let info = {
|
|
90
91
|
unknownReferences: [],
|
|
91
92
|
in: inIds,
|
|
92
93
|
out: functionName.out, // we do not keep argument out as it has been linked by the function
|
|
@@ -94,6 +95,11 @@ function processFunctionCall(functionCall, data) {
|
|
|
94
95
|
environments: finalEnv,
|
|
95
96
|
scope: data.activeScope
|
|
96
97
|
};
|
|
98
|
+
// parse a source call and analyze the referenced code
|
|
99
|
+
if ((0, source_1.isSourceCall)(functionCallName, data.activeScope, finalEnv)) {
|
|
100
|
+
info = (0, source_1.processSourceCall)(functionCall, data, info);
|
|
101
|
+
}
|
|
102
|
+
return info;
|
|
97
103
|
}
|
|
98
104
|
exports.processFunctionCall = processFunctionCall;
|
|
99
105
|
//# sourceMappingURL=function-call.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IdGenerator, NoInfo, RParseRequest, RParseRequestProvider, ParentInformation, RFunctionCall } from '../../../../r-bridge';
|
|
2
|
+
import { type DataflowProcessorInformation } from '../../../processor';
|
|
3
|
+
import { type DataflowScopeName, type Identifier, type REnvironmentInformation } from '../../../environments';
|
|
4
|
+
import type { DataflowInformation } from '../../info';
|
|
5
|
+
export declare function setSourceProvider(provider: RParseRequestProvider): void;
|
|
6
|
+
export declare function isSourceCall(name: Identifier, scope: DataflowScopeName, environments: REnvironmentInformation): boolean;
|
|
7
|
+
export declare function processSourceCall<OtherInfo>(functionCall: RFunctionCall<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation): DataflowInformation;
|
|
8
|
+
export declare function sourceRequest<OtherInfo>(request: RParseRequest, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation, getId: IdGenerator<NoInfo>): DataflowInformation;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceRequest = exports.processSourceCall = exports.isSourceCall = exports.setSourceProvider = void 0;
|
|
4
|
+
const r_bridge_1 = require("../../../../r-bridge");
|
|
5
|
+
const shell_executor_1 = require("../../../../r-bridge/shell-executor");
|
|
6
|
+
const core_1 = require("../../../../core");
|
|
7
|
+
const processor_1 = require("../../../processor");
|
|
8
|
+
const environments_1 = require("../../../environments");
|
|
9
|
+
const index_1 = require("../../../index");
|
|
10
|
+
const config_1 = require("../../../../config");
|
|
11
|
+
let sourceProvider = (0, r_bridge_1.requestProviderFromFile)();
|
|
12
|
+
function setSourceProvider(provider) {
|
|
13
|
+
sourceProvider = provider;
|
|
14
|
+
}
|
|
15
|
+
exports.setSourceProvider = setSourceProvider;
|
|
16
|
+
function isSourceCall(name, scope, environments) {
|
|
17
|
+
const definitions = (0, environments_1.resolveByName)(name, scope, environments);
|
|
18
|
+
if (definitions === undefined) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
// fail if there are multiple definitions because then we must treat the complete import as a maybe because it might do something different
|
|
22
|
+
if (definitions.length !== 1) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const def = definitions[0];
|
|
26
|
+
return def.name == 'source' && def.kind == 'built-in-function';
|
|
27
|
+
}
|
|
28
|
+
exports.isSourceCall = isSourceCall;
|
|
29
|
+
function processSourceCall(functionCall, data, information) {
|
|
30
|
+
const sourceFile = functionCall.arguments[0];
|
|
31
|
+
if ((0, config_1.getConfig)().ignoreSourceCalls) {
|
|
32
|
+
index_1.dataflowLogger.info(`Skipping source call ${JSON.stringify(sourceFile)} (disabled in config file)`);
|
|
33
|
+
return information;
|
|
34
|
+
}
|
|
35
|
+
if (sourceFile?.value?.type == "RString" /* RType.String */) {
|
|
36
|
+
const path = (0, r_bridge_1.removeRQuotes)(sourceFile.lexeme);
|
|
37
|
+
const request = sourceProvider.createRequest(path);
|
|
38
|
+
// check if the sourced file has already been dataflow analyzed, and if so, skip it
|
|
39
|
+
if (data.referenceChain.includes((0, r_bridge_1.requestFingerprint)(request))) {
|
|
40
|
+
index_1.dataflowLogger.info(`Found loop in dataflow analysis for ${JSON.stringify(request)}: ${JSON.stringify(data.referenceChain)}, skipping further dataflow analysis`);
|
|
41
|
+
return information;
|
|
42
|
+
}
|
|
43
|
+
return sourceRequest(request, data, information, (0, r_bridge_1.sourcedDeterministicCountingIdGenerator)(path, functionCall.location));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
index_1.dataflowLogger.info(`Non-constant argument ${JSON.stringify(sourceFile)} for source is currently not supported, skipping`);
|
|
47
|
+
return information;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.processSourceCall = processSourceCall;
|
|
51
|
+
function sourceRequest(request, data, information, getId) {
|
|
52
|
+
const executor = new shell_executor_1.RShellExecutor();
|
|
53
|
+
// parse, normalize and dataflow the sourced file
|
|
54
|
+
let normalized;
|
|
55
|
+
let dataflow;
|
|
56
|
+
try {
|
|
57
|
+
const parsed = (0, core_1.executeSingleSubStep)('parse', request, executor);
|
|
58
|
+
normalized = (0, core_1.executeSingleSubStep)('normalize', parsed, undefined, getId);
|
|
59
|
+
dataflow = (0, processor_1.processDataflowFor)(normalized.ast, {
|
|
60
|
+
...data,
|
|
61
|
+
currentRequest: request,
|
|
62
|
+
environments: information.environments,
|
|
63
|
+
referenceChain: [...data.referenceChain, (0, r_bridge_1.requestFingerprint)(request)]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
index_1.dataflowLogger.warn(`Failed to analyze sourced file ${JSON.stringify(request)}, skipping: ${e.message}`);
|
|
68
|
+
return information;
|
|
69
|
+
}
|
|
70
|
+
// update our graph with the sourced file's information
|
|
71
|
+
const newInformation = { ...information };
|
|
72
|
+
newInformation.environments = (0, environments_1.overwriteEnvironments)(information.environments, dataflow.environments);
|
|
73
|
+
newInformation.graph.mergeWith(dataflow.graph);
|
|
74
|
+
// this can be improved, see issue #628
|
|
75
|
+
for (const [k, v] of normalized.idMap) {
|
|
76
|
+
data.completeAst.idMap.set(k, v);
|
|
77
|
+
}
|
|
78
|
+
return newInformation;
|
|
79
|
+
}
|
|
80
|
+
exports.sourceRequest = sourceRequest;
|
|
81
|
+
//# sourceMappingURL=source.js.map
|
package/dataflow/processor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Based on a two-way fold, this processor will automatically supply scope information
|
|
3
3
|
*/
|
|
4
|
-
import type { NormalizedAst, ParentInformation, RNode, RNodeWithParent } from '../r-bridge';
|
|
4
|
+
import type { NormalizedAst, ParentInformation, RNode, RNodeWithParent, RParseRequest } from '../r-bridge';
|
|
5
5
|
import type { DataflowInformation } from './internal/info';
|
|
6
6
|
import type { DataflowScopeName, REnvironmentInformation } from './environments';
|
|
7
7
|
export interface DataflowProcessorInformation<OtherInfo> {
|
|
@@ -22,6 +22,15 @@ export interface DataflowProcessorInformation<OtherInfo> {
|
|
|
22
22
|
* Other processors to be called by the given functions
|
|
23
23
|
*/
|
|
24
24
|
readonly processors: DataflowProcessors<OtherInfo>;
|
|
25
|
+
/**
|
|
26
|
+
* The {@link RParseRequest} that is currently being parsed
|
|
27
|
+
*/
|
|
28
|
+
readonly currentRequest: RParseRequest;
|
|
29
|
+
/**
|
|
30
|
+
* The chain of {@link RParseRequest} fingerprints ({@link requestFingerprint}) that lead to the {@link currentRequest}.
|
|
31
|
+
* The most recent (last) entry is expected to always be the {@link currentRequest}.
|
|
32
|
+
*/
|
|
33
|
+
readonly referenceChain: string[];
|
|
25
34
|
}
|
|
26
35
|
export type DataflowProcessor<OtherInfo, NodeType extends RNodeWithParent<OtherInfo>> = (node: NodeType, data: DataflowProcessorInformation<OtherInfo>) => DataflowInformation;
|
|
27
36
|
type NodeWithKey<OtherInfo, Node extends RNode<OtherInfo & ParentInformation>, TypeKey> = Node['type'] extends TypeKey ? Node : never;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -18,6 +18,4 @@ __exportStar(require("./core"), exports);
|
|
|
18
18
|
__exportStar(require("./slicing"), exports);
|
|
19
19
|
__exportStar(require("./dataflow"), exports);
|
|
20
20
|
__exportStar(require("./r-bridge"), exports);
|
|
21
|
-
__exportStar(require("./benchmark"), exports);
|
|
22
|
-
__exportStar(require("./statistics"), exports);
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -13,22 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
16
|
-
"main": "ts-node src/flowr.ts",
|
|
17
|
-
"stats": "ts-node src/cli/statistics-app.ts",
|
|
18
|
-
"stats-helper": "ts-node src/cli/statistics-helper-app.ts",
|
|
19
|
-
"slicer": "ts-node src/cli/slicer-app.ts",
|
|
20
16
|
"release": "release-it --ci",
|
|
21
|
-
"benchmark-helper": "ts-node src/cli/benchmark-helper-app.ts",
|
|
22
|
-
"benchmark": "ts-node src/cli/benchmark-app.ts",
|
|
23
|
-
"summarizer": "ts-node src/cli/summarizer-app.ts",
|
|
24
|
-
"export-quads": "ts-node src/cli/export-quads-app.ts",
|
|
25
17
|
"build": "tsc --project .",
|
|
26
18
|
"lint-local": "eslint src/ test/ --rule \"no-warning-comments: off\"",
|
|
27
19
|
"lint": "npm run license-compat -- --summary && eslint src/ test/",
|
|
28
20
|
"license-compat": "license-checker --onlyAllow 'MIT;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD'",
|
|
29
21
|
"doc": "typedoc",
|
|
30
|
-
"test": "nyc --no-clean mocha
|
|
31
|
-
"performance-test": "func() { cd test/performance/ && bash run-all-suites.sh $1 $2; cd ../../; }; func",
|
|
22
|
+
"test": "nyc --no-clean mocha",
|
|
23
|
+
"performance-test": "func() { cd test/performance/ && bash run-all-suites.sh $1 $2 $3; cd ../../; }; func",
|
|
32
24
|
"test-full": "npm run test -- --test-installation"
|
|
33
25
|
},
|
|
34
26
|
"keywords": [
|
|
@@ -41,6 +33,11 @@
|
|
|
41
33
|
],
|
|
42
34
|
"author": "Florian Sihler",
|
|
43
35
|
"license": "ISC",
|
|
36
|
+
"mocha": {
|
|
37
|
+
"require": "ts-node/register",
|
|
38
|
+
"timeout": 60000,
|
|
39
|
+
"spec": "test/**/*.spec.ts"
|
|
40
|
+
},
|
|
44
41
|
"nyc": {
|
|
45
42
|
"all": true,
|
|
46
43
|
"per-file": true,
|
|
@@ -58,6 +55,69 @@
|
|
|
58
55
|
"cobertura"
|
|
59
56
|
]
|
|
60
57
|
},
|
|
58
|
+
"eslintConfig": {
|
|
59
|
+
"settings": {
|
|
60
|
+
"import/resolver": {
|
|
61
|
+
"node": {
|
|
62
|
+
"extensions": [
|
|
63
|
+
".ts"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"extends": [
|
|
69
|
+
"@eagleoutice/eslint-config-flowr"
|
|
70
|
+
],
|
|
71
|
+
"rules": {
|
|
72
|
+
"import/no-restricted-paths": [
|
|
73
|
+
"error",
|
|
74
|
+
{
|
|
75
|
+
"zones": [
|
|
76
|
+
{
|
|
77
|
+
"target": "benchmark",
|
|
78
|
+
"from": [
|
|
79
|
+
"cli",
|
|
80
|
+
"src",
|
|
81
|
+
"statistics"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"target": "cli",
|
|
86
|
+
"from": [
|
|
87
|
+
"benchmark",
|
|
88
|
+
"src",
|
|
89
|
+
"statistics"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"target": "statistics",
|
|
94
|
+
"from": [
|
|
95
|
+
"benchmark",
|
|
96
|
+
"cli",
|
|
97
|
+
"src"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"target": "src",
|
|
102
|
+
"from": [
|
|
103
|
+
"benchmark",
|
|
104
|
+
"cli",
|
|
105
|
+
"statistics"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"target": "test",
|
|
110
|
+
"from": [
|
|
111
|
+
"benchmark",
|
|
112
|
+
"cli",
|
|
113
|
+
"statistics"
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
61
121
|
"typedocOptions": {
|
|
62
122
|
"includeVersion": true,
|
|
63
123
|
"plugin": [
|
|
@@ -109,195 +169,6 @@
|
|
|
109
169
|
},
|
|
110
170
|
"treatValidationWarningsAsErrors": false
|
|
111
171
|
},
|
|
112
|
-
"eslintConfig": {
|
|
113
|
-
"root": true,
|
|
114
|
-
"env": {
|
|
115
|
-
"browser": false,
|
|
116
|
-
"node": true,
|
|
117
|
-
"es2022": true
|
|
118
|
-
},
|
|
119
|
-
"extends": [
|
|
120
|
-
"eslint:recommended",
|
|
121
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
|
122
|
-
"plugin:@typescript-eslint/strict",
|
|
123
|
-
"plugin:@typescript-eslint/recommended"
|
|
124
|
-
],
|
|
125
|
-
"overrides": [],
|
|
126
|
-
"parserOptions": {
|
|
127
|
-
"ecmaVersion": "latest",
|
|
128
|
-
"sourceType": "module",
|
|
129
|
-
"project": "./tsconfig.json"
|
|
130
|
-
},
|
|
131
|
-
"parser": "@typescript-eslint/parser",
|
|
132
|
-
"plugins": [
|
|
133
|
-
"@typescript-eslint",
|
|
134
|
-
"eslint-plugin-tsdoc",
|
|
135
|
-
"check-file"
|
|
136
|
-
],
|
|
137
|
-
"rules": {
|
|
138
|
-
"indent": "off",
|
|
139
|
-
"@typescript-eslint/indent": [
|
|
140
|
-
"error",
|
|
141
|
-
"tab",
|
|
142
|
-
{
|
|
143
|
-
"FunctionDeclaration": {
|
|
144
|
-
"parameters": "first"
|
|
145
|
-
},
|
|
146
|
-
"ObjectExpression": 1,
|
|
147
|
-
"SwitchCase": 1
|
|
148
|
-
}
|
|
149
|
-
],
|
|
150
|
-
"quotes": [
|
|
151
|
-
"error",
|
|
152
|
-
"single",
|
|
153
|
-
{
|
|
154
|
-
"avoidEscape": true
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
"no-mixed-spaces-and-tabs": [
|
|
158
|
-
"error",
|
|
159
|
-
"smart-tabs"
|
|
160
|
-
],
|
|
161
|
-
"no-warning-comments": [
|
|
162
|
-
"error",
|
|
163
|
-
{
|
|
164
|
-
"terms": [
|
|
165
|
-
"todo",
|
|
166
|
-
"fixme",
|
|
167
|
-
"xxx"
|
|
168
|
-
],
|
|
169
|
-
"location": "anywhere"
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
|
-
"@typescript-eslint/non-nullable-type-assertion-style": "off",
|
|
173
|
-
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
174
|
-
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
175
|
-
"@typescript-eslint/consistent-type-assertions": [
|
|
176
|
-
"error",
|
|
177
|
-
{
|
|
178
|
-
"assertionStyle": "as"
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
"@typescript-eslint/key-spacing": [
|
|
182
|
-
"error",
|
|
183
|
-
{
|
|
184
|
-
"align": "value"
|
|
185
|
-
}
|
|
186
|
-
],
|
|
187
|
-
"semi": [
|
|
188
|
-
"error",
|
|
189
|
-
"never"
|
|
190
|
-
],
|
|
191
|
-
"space-before-function-paren": [
|
|
192
|
-
"error",
|
|
193
|
-
"never"
|
|
194
|
-
],
|
|
195
|
-
"keyword-spacing": "off",
|
|
196
|
-
"check-file/filename-naming-convention": [
|
|
197
|
-
"error",
|
|
198
|
-
{
|
|
199
|
-
"**/*.ts": "?([A-Z])+([a-z])*((-|.)?([A-Z])+([a-z]))"
|
|
200
|
-
}
|
|
201
|
-
],
|
|
202
|
-
"check-file/folder-match-with-fex": [
|
|
203
|
-
"error",
|
|
204
|
-
{
|
|
205
|
-
"*.spec.{js,jsx,ts,tsx}": "test/**"
|
|
206
|
-
}
|
|
207
|
-
],
|
|
208
|
-
"@typescript-eslint/keyword-spacing": [
|
|
209
|
-
"error",
|
|
210
|
-
{
|
|
211
|
-
"before": true,
|
|
212
|
-
"after": true,
|
|
213
|
-
"overrides": {
|
|
214
|
-
"if": {
|
|
215
|
-
"after": false
|
|
216
|
-
},
|
|
217
|
-
"for": {
|
|
218
|
-
"after": false
|
|
219
|
-
},
|
|
220
|
-
"while": {
|
|
221
|
-
"after": false
|
|
222
|
-
},
|
|
223
|
-
"do": {
|
|
224
|
-
"after": false
|
|
225
|
-
},
|
|
226
|
-
"catch": {
|
|
227
|
-
"after": false
|
|
228
|
-
},
|
|
229
|
-
"switch": {
|
|
230
|
-
"after": false
|
|
231
|
-
},
|
|
232
|
-
"default": {
|
|
233
|
-
"after": false
|
|
234
|
-
},
|
|
235
|
-
"throw": {
|
|
236
|
-
"after": false
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
],
|
|
241
|
-
"@typescript-eslint/space-before-function-paren": [
|
|
242
|
-
"error",
|
|
243
|
-
"never"
|
|
244
|
-
],
|
|
245
|
-
"@typescript-eslint/no-unused-vars": [
|
|
246
|
-
"error",
|
|
247
|
-
{
|
|
248
|
-
"argsIgnorePattern": "^_",
|
|
249
|
-
"destructuredArrayIgnorePattern": "^_",
|
|
250
|
-
"varsIgnorePattern": "^_"
|
|
251
|
-
}
|
|
252
|
-
],
|
|
253
|
-
"tsdoc/syntax": "error",
|
|
254
|
-
"@typescript-eslint/naming-convention": [
|
|
255
|
-
"error",
|
|
256
|
-
{
|
|
257
|
-
"selector": "variable",
|
|
258
|
-
"modifiers": [
|
|
259
|
-
"const",
|
|
260
|
-
"global",
|
|
261
|
-
"exported"
|
|
262
|
-
],
|
|
263
|
-
"format": [
|
|
264
|
-
"camelCase",
|
|
265
|
-
"PascalCase",
|
|
266
|
-
"UPPER_CASE"
|
|
267
|
-
],
|
|
268
|
-
"leadingUnderscore": "allow",
|
|
269
|
-
"trailingUnderscore": "allow"
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
"selector": "variable",
|
|
273
|
-
"modifiers": [
|
|
274
|
-
"const"
|
|
275
|
-
],
|
|
276
|
-
"format": [
|
|
277
|
-
"camelCase",
|
|
278
|
-
"PascalCase"
|
|
279
|
-
],
|
|
280
|
-
"leadingUnderscore": "allow",
|
|
281
|
-
"trailingUnderscore": "allow"
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"selector": "enumMember",
|
|
285
|
-
"format": [
|
|
286
|
-
"StrictPascalCase"
|
|
287
|
-
],
|
|
288
|
-
"leadingUnderscore": "forbid",
|
|
289
|
-
"trailingUnderscore": "forbid"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
"selector": "typeLike",
|
|
293
|
-
"format": [
|
|
294
|
-
"PascalCase"
|
|
295
|
-
]
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
"@typescript-eslint/consistent-type-imports": "error"
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
172
|
"release-it": {
|
|
302
173
|
"git": {
|
|
303
174
|
"commitMessage": "[skip ci] Release v${version}",
|
|
@@ -335,6 +206,10 @@
|
|
|
335
206
|
"devDependencies": {
|
|
336
207
|
"@commitlint/cli": "^18.4.3",
|
|
337
208
|
"@commitlint/config-angular": "^18.4.3",
|
|
209
|
+
"@eagleoutice/eslint-config-flowr": "^1.0.2",
|
|
210
|
+
"@stylistic/eslint-plugin": "^1.6.2",
|
|
211
|
+
"@stylistic/eslint-plugin-plus": "^1.6.2",
|
|
212
|
+
"@stylistic/eslint-plugin-ts": "^1.6.2",
|
|
338
213
|
"@types/chai": "^4.3.11",
|
|
339
214
|
"@types/chai-as-promised": "^7.1.8",
|
|
340
215
|
"@types/command-line-args": "^5.2.3",
|
|
@@ -344,7 +219,6 @@
|
|
|
344
219
|
"@types/n3": "^1.16.4",
|
|
345
220
|
"@types/object-hash": "^3.0.6",
|
|
346
221
|
"@types/tmp": "^0.2.6",
|
|
347
|
-
"@types/xml2js": "^0.4.14",
|
|
348
222
|
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
349
223
|
"chai": "^4.3.10",
|
|
350
224
|
"chai-as-promised": "^7.1.1",
|
|
@@ -386,7 +260,6 @@
|
|
|
386
260
|
"ts-essentials": "^9.4.1",
|
|
387
261
|
"tslog": "^4.9.2",
|
|
388
262
|
"ws": "^8.16.0",
|
|
389
|
-
"xml2js": "^0.6.2",
|
|
390
263
|
"xpath-ts2": "^1.4.2"
|
|
391
264
|
}
|
|
392
265
|
}
|
|
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.parseLog = void 0;
|
|
17
18
|
__exportStar(require("./model"), exports);
|
|
18
19
|
__exportStar(require("./parser/xml"), exports);
|
|
20
|
+
var parser_1 = require("./parser/json/parser");
|
|
21
|
+
Object.defineProperty(exports, "parseLog", { enumerable: true, get: function () { return parser_1.parseLog; } });
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
11
|
import type { NoInfo, RNode } from '../model';
|
|
12
|
+
import type { SourceRange } from '../../../../../util/range';
|
|
12
13
|
import { BiMap } from '../../../../../util/bimap';
|
|
13
14
|
import type { MergeableRecord } from '../../../../../util/objects';
|
|
14
15
|
import { RoleInParent } from './role';
|
|
@@ -27,6 +28,7 @@ export type IdGenerator<OtherInfo> = (data: RNode<OtherInfo>) => NodeId;
|
|
|
27
28
|
* The simplest id generator which just increments a number on each call.
|
|
28
29
|
*/
|
|
29
30
|
export declare function deterministicCountingIdGenerator(start?: number): () => NodeId;
|
|
31
|
+
export declare function sourcedDeterministicCountingIdGenerator(path: string, location: SourceRange, start?: number): () => NodeId;
|
|
30
32
|
/**
|
|
31
33
|
* Generates the location id, used by {@link deterministicLocationIdGenerator}.
|
|
32
34
|
*
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.decorateAst = exports.deterministicLocationIdGenerator = exports.nodeToLocationId = exports.deterministicCountingIdGenerator = void 0;
|
|
13
|
+
exports.decorateAst = exports.deterministicLocationIdGenerator = exports.nodeToLocationId = exports.sourcedDeterministicCountingIdGenerator = exports.deterministicCountingIdGenerator = void 0;
|
|
14
14
|
const assert_1 = require("../../../../../util/assert");
|
|
15
15
|
const bimap_1 = require("../../../../../util/bimap");
|
|
16
16
|
const fold_1 = require("./fold");
|
|
@@ -22,6 +22,11 @@ function deterministicCountingIdGenerator(start = 0) {
|
|
|
22
22
|
return () => `${id++}`;
|
|
23
23
|
}
|
|
24
24
|
exports.deterministicCountingIdGenerator = deterministicCountingIdGenerator;
|
|
25
|
+
function sourcedDeterministicCountingIdGenerator(path, location, start = 0) {
|
|
26
|
+
let id = start;
|
|
27
|
+
return () => `${path}-${loc2Id(location)}-${id++}`;
|
|
28
|
+
}
|
|
29
|
+
exports.sourcedDeterministicCountingIdGenerator = sourcedDeterministicCountingIdGenerator;
|
|
25
30
|
function loc2Id(loc) {
|
|
26
31
|
return `${loc.start.line}:${loc.start.column}-${loc.end.line}:${loc.end.column}`;
|
|
27
32
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const RootId = 0;
|
|
2
|
+
export interface Entry extends Record<string, unknown> {
|
|
3
|
+
line1: number;
|
|
4
|
+
col1: number;
|
|
5
|
+
line2: number;
|
|
6
|
+
col2: number;
|
|
7
|
+
id: number;
|
|
8
|
+
parent: number;
|
|
9
|
+
token: string;
|
|
10
|
+
terminal: boolean;
|
|
11
|
+
text: string;
|
|
12
|
+
children?: Entry[];
|
|
13
|
+
}
|
|
14
|
+
export declare function prepareParsedData(data: string): Map<number, Entry>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareParsedData = exports.RootId = void 0;
|
|
4
|
+
const retriever_1 = require("../../../../retriever");
|
|
5
|
+
const assert_1 = require("../../../../../util/assert");
|
|
6
|
+
exports.RootId = 0;
|
|
7
|
+
function prepareParsedData(data) {
|
|
8
|
+
const json = JSON.parse(data);
|
|
9
|
+
(0, assert_1.guard)(Array.isArray(json), () => `Expected ${data} to be an array but was not`);
|
|
10
|
+
const ret = new Map(json.map(([line1, col1, line2, col2, id, parent, token, terminal, text]) => {
|
|
11
|
+
return [id, { line1, col1, line2, col2, id, parent, token: (0, retriever_1.removeRQuotes)(token), terminal, text }];
|
|
12
|
+
}));
|
|
13
|
+
// iterate a second time to set parent-child relations (since they may be out of order in the csv)
|
|
14
|
+
for (const entry of ret.values()) {
|
|
15
|
+
if (entry.parent != exports.RootId) {
|
|
16
|
+
const parent = ret.get(entry.parent);
|
|
17
|
+
if (parent) {
|
|
18
|
+
parent.children ??= [];
|
|
19
|
+
parent.children.push(entry);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ret;
|
|
24
|
+
}
|
|
25
|
+
exports.prepareParsedData = prepareParsedData;
|
|
26
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeepPartial } from 'ts-essentials';
|
|
2
|
+
import type { XmlBasedJson, XmlParserHooks } from '../xml';
|
|
3
|
+
import type { IdGenerator, NoInfo, NormalizedAst } from '../../model';
|
|
4
|
+
import type { Entry } from './format';
|
|
5
|
+
export declare const parseLog: import("tslog").Logger<import("tslog").ILogObj>;
|
|
6
|
+
export declare function normalize(jsonString: string, hooks?: DeepPartial<XmlParserHooks>, getId?: IdGenerator<NoInfo>): NormalizedAst;
|
|
7
|
+
export declare function convertPreparedParsedData(valueMapping: Map<number, Entry>): XmlBasedJson;
|