@eagleoutice/flowr 2.10.10 → 2.11.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 +37 -29
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +1 -1
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +2 -0
- package/cli/repl/server/connection.js +40 -31
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +2 -0
- package/config.d.ts +13 -0
- package/config.js +8 -0
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +1 -2
- package/dataflow/environments/append.js +3 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -0
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +63 -3
- package/dataflow/environments/default-builtin-config.js +40 -8
- package/dataflow/environments/environment.d.ts +49 -32
- package/dataflow/environments/environment.js +133 -18
- package/dataflow/environments/identifier.d.ts +10 -0
- package/dataflow/environments/identifier.js +23 -0
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +10 -2
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/extractor.js +23 -2
- package/dataflow/graph/df-helper.d.ts +8 -0
- package/dataflow/graph/df-helper.js +8 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +5 -1
- package/dataflow/info.d.ts +26 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
- package/documentation/data/faq/faqs.js +3 -0
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/wiki-core.js +2 -1
- package/documentation/wiki-dataflow-graph.js +35 -1
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +2 -0
- package/documentation/wiki-overview.js +1 -14
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +1 -0
- package/linter/linter-rules.d.ts +23 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.js +2 -1
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/package.json +3 -4
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +36 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +4 -1
- package/project/plugins/plugin-registry.js +7 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/linter-query/linter-query-executor.js +1 -0
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/search/search-executor/search-enrichers.d.ts +1 -1
- package/search/search-executor/search-enrichers.js +7 -4
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -104
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -86
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.definedFunctions = exports.AllDefinitionsFileBase = void 0;
|
|
4
|
-
const post_process_1 = require("./post-process");
|
|
5
|
-
const range_1 = require("../../../../util/range");
|
|
6
|
-
const assert_1 = require("../../../../util/assert");
|
|
7
|
-
const edge_1 = require("../../../../dataflow/graph/edge");
|
|
8
|
-
const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
|
-
const statistics_file_1 = require("../../../output/statistics-file");
|
|
10
|
-
const vertex_1 = require("../../../../dataflow/graph/vertex");
|
|
11
|
-
const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
12
|
-
const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
|
|
13
|
-
const initialFunctionDefinitionInfo = {
|
|
14
|
-
/** all, anonymous, assigned, non-assigned, ... */
|
|
15
|
-
total: 0,
|
|
16
|
-
/** how many are really using OP-Lambda? */
|
|
17
|
-
lambdasOnly: 0,
|
|
18
|
-
/** using `<<-`, `<-`, `=`, `->` `->>` */
|
|
19
|
-
assignedFunctions: 0,
|
|
20
|
-
nestedFunctions: 0,
|
|
21
|
-
/** functions that in some easily detectable way call themselves */
|
|
22
|
-
recursive: 0,
|
|
23
|
-
deepestNesting: 0
|
|
24
|
-
};
|
|
25
|
-
exports.AllDefinitionsFileBase = 'all-definitions';
|
|
26
|
-
function retrieveAllCallsites(input, node, recursiveCalls) {
|
|
27
|
-
const dfStart = input.dataflow.graph.outgoingEdges(node.info.id);
|
|
28
|
-
const callsites = [];
|
|
29
|
-
for (const [target, edge] of dfStart ?? []) {
|
|
30
|
-
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const loc = input.normalizedRAst.idMap.get(target)?.location;
|
|
34
|
-
if (loc) {
|
|
35
|
-
callsites.push(range_1.SourceRange.getStart(loc));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
for (const call of recursiveCalls) {
|
|
39
|
-
const loc = call.location;
|
|
40
|
-
if (loc) {
|
|
41
|
-
callsites.push(range_1.SourceRange.getStart(loc));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return callsites;
|
|
45
|
-
}
|
|
46
|
-
function visitDefinitions(info, input) {
|
|
47
|
-
const definitionStack = [];
|
|
48
|
-
const allDefinitions = [];
|
|
49
|
-
r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
|
|
50
|
-
if (node.type !== type_1.RType.FunctionDefinition) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const graph = input.dataflow.graph;
|
|
54
|
-
const dfNode = graph.get(node.info.id, true);
|
|
55
|
-
if (dfNode === undefined) {
|
|
56
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'no-dataflow-node-found', [node], input.filepath);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const [fnDefinition] = dfNode;
|
|
60
|
-
(0, assert_1.guard)(fnDefinition.tag === vertex_1.VertexType.FunctionDefinition, () => `Dataflow node is not a function definition (${JSON.stringify(fnDefinition)}))})`);
|
|
61
|
-
const returnTypes = fnDefinition.exitPoints.map(ep => graph.get(ep.nodeId, true)).filter(assert_1.isNotUndefined)
|
|
62
|
-
.map(([vertex]) => {
|
|
63
|
-
const l = graph.idMap?.get(vertex.id)?.location;
|
|
64
|
-
return {
|
|
65
|
-
location: l ? range_1.SourceRange.getStart(l) : range_1.SourcePosition.invalid()
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
if (definitionStack.length > 0) {
|
|
69
|
-
info.nestedFunctions++;
|
|
70
|
-
info.deepestNesting = Math.max(info.deepestNesting, definitionStack.length);
|
|
71
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'nested-definitions', [model_1.RNode.lexeme(node)], input.filepath);
|
|
72
|
-
}
|
|
73
|
-
// parameter names:
|
|
74
|
-
const parameterNames = node.parameters.map(model_1.RNode.lexeme);
|
|
75
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'usedParameterNames', parameterNames, input.filepath);
|
|
76
|
-
const isLambda = node.lexeme.startsWith('\\');
|
|
77
|
-
if (isLambda) {
|
|
78
|
-
info.lambdasOnly++;
|
|
79
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'allLambdas', [model_1.RNode.lexeme(node)], input.filepath);
|
|
80
|
-
}
|
|
81
|
-
definitionStack.push(node);
|
|
82
|
-
// we find definitions with silly defined-by edges
|
|
83
|
-
const assigned = new Set();
|
|
84
|
-
const edges = input.dataflow.graph.ingoingEdges(node.info.id);
|
|
85
|
-
if (edges !== undefined) {
|
|
86
|
-
for (const [targetId, edge] of edges) {
|
|
87
|
-
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy)) {
|
|
88
|
-
const target = input.normalizedRAst.idMap.get(targetId);
|
|
89
|
-
(0, assert_1.guard)(target !== undefined, 'Dataflow edge points to unknown node');
|
|
90
|
-
const name = model_1.RNode.lexeme(target);
|
|
91
|
-
if (name) {
|
|
92
|
-
assigned.add(name);
|
|
93
|
-
}
|
|
94
|
-
info.assignedFunctions++;
|
|
95
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'assignedFunctions', [name ?? '<unknown>'], input.filepath);
|
|
96
|
-
}
|
|
97
|
-
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
98
|
-
const target = input.normalizedRAst.idMap.get(targetId);
|
|
99
|
-
(0, assert_1.guard)(target !== undefined, 'Dataflow edge points to unknown node');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// track all calls with the same name that do not already have a bound calls edge, superfluous if recursive tracking is explicit
|
|
104
|
-
const recursiveCalls = [];
|
|
105
|
-
model_1.RNode.visitAst(node.body, n => {
|
|
106
|
-
if (n.type === type_1.RType.FunctionCall && n.named && assigned.has(n.functionName.lexeme)) {
|
|
107
|
-
recursiveCalls.push(n);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
// one recursive definition, but we record all
|
|
111
|
-
info.recursive += recursiveCalls.length > 0 ? 1 : 0;
|
|
112
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'recursive', recursiveCalls.map(n => model_1.RNode.lexeme(n) ?? 'unknown'), input.filepath);
|
|
113
|
-
const lexeme = node.info.fullLexeme;
|
|
114
|
-
const lexemeSplit = lexeme?.split('\n');
|
|
115
|
-
allDefinitions.push({
|
|
116
|
-
location: range_1.SourceRange.getStart(node.location),
|
|
117
|
-
callsites: retrieveAllCallsites(input, node, recursiveCalls),
|
|
118
|
-
numberOfParameters: node.parameters.length,
|
|
119
|
-
returns: returnTypes,
|
|
120
|
-
length: {
|
|
121
|
-
lines: lexemeSplit?.length ?? -1,
|
|
122
|
-
characters: lexeme?.length ?? -1,
|
|
123
|
-
nonWhitespaceCharacters: lexeme?.replaceAll(/\s/g, '').length ?? 0
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}, node => {
|
|
127
|
-
// drop again :D
|
|
128
|
-
if (node.type === type_1.RType.FunctionDefinition) {
|
|
129
|
-
definitionStack.pop();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
info.total += allDefinitions.length;
|
|
133
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, exports.AllDefinitionsFileBase, allDefinitions, input.filepath);
|
|
134
|
-
}
|
|
135
|
-
exports.definedFunctions = {
|
|
136
|
-
name: 'Defined Functions',
|
|
137
|
-
description: 'All functions defined within the document',
|
|
138
|
-
process(existing, input) {
|
|
139
|
-
visitDefinitions(existing, input);
|
|
140
|
-
return existing;
|
|
141
|
-
},
|
|
142
|
-
initialValue: initialFunctionDefinitionInfo,
|
|
143
|
-
postProcess: post_process_1.postProcess
|
|
144
|
-
};
|
|
145
|
-
//# sourceMappingURL=defined-functions.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FeatureStatisticsWithMeta } from '../../feature';
|
|
2
|
-
import type { StatisticsSummarizerConfiguration } from '../../../summarizer/summarizer';
|
|
3
|
-
/**
|
|
4
|
-
* Note: the summary does not contain a 0, for each function that `is _not_ called` by a file. Hence, the minimum can not be 0 (division for mean etc. will still be performed on total file count)
|
|
5
|
-
*/
|
|
6
|
-
export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.postProcess = postProcess;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const defined_functions_1 = require("./defined-functions");
|
|
10
|
-
const post_processing_1 = require("../../post-processing");
|
|
11
|
-
const summarizer_1 = require("../../../../util/summarizer");
|
|
12
|
-
const files_1 = require("../../../../util/files");
|
|
13
|
-
const time_1 = require("../../../../util/text/time");
|
|
14
|
-
const arrays_1 = require("../../../../util/collections/arrays");
|
|
15
|
-
function getFnDefCsv(idx, info) {
|
|
16
|
-
return `${JSON.stringify(idx)},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.total.flat()))}`
|
|
17
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.parameters.flat()))}`
|
|
18
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.length.lines.flat()))}`
|
|
19
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.length.chars.flat()))}`
|
|
20
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.length.nonWhitespaceChars.flat()))}`
|
|
21
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)([0]))}` /* this has to be changed once we have explicit returns again */
|
|
22
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)([0]))}`
|
|
23
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.returns.onlyExplicit.flat()))}`
|
|
24
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.returns.onlyImplicit.flat()))}`
|
|
25
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.exitPointsLinePercentageInDef.flat(2)))}`
|
|
26
|
-
+ `,${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(info.linePercentageInFile.flat()))}\n`;
|
|
27
|
-
}
|
|
28
|
-
function addToList(data, count, filepath, config) {
|
|
29
|
-
data.count.push(count);
|
|
30
|
-
if (count > 0) {
|
|
31
|
-
(0, post_processing_1.recordFilePath)(data, filepath, config);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function retrievePerFileDefinitionInformation(featureRoot, info, config, outputPath) {
|
|
35
|
-
/**
|
|
36
|
-
* maps fn-name (including namespace) to several definition information
|
|
37
|
-
* we use tuples to reduce the memory!
|
|
38
|
-
*/
|
|
39
|
-
const definitionsPerFile = [];
|
|
40
|
-
const mergedSuperDefinitions = emptyFunctionDefinitionSummary();
|
|
41
|
-
// we collect only `all-calls`
|
|
42
|
-
(0, files_1.readLineByLineSync)(path_1.default.join(featureRoot, `${defined_functions_1.AllDefinitionsFileBase}.txt`), (line, lineNumber) => processNextLine(definitionsPerFile, lineNumber, info, JSON.parse(String(line))));
|
|
43
|
-
console.log(` [${(0, time_1.date2string)(new Date())}] Defined functions process completed, start to write out function info`);
|
|
44
|
-
const fnOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-definitions.csv'));
|
|
45
|
-
const prefixes = ['total', 'params', 'length-lines', 'length-chars', 'length-non-ws-chars', 'return-explicit', 'return-implicit', 'return-only-explicit', 'return-only-implicit', 'exit-points-line-crac', 'def-line-frac'];
|
|
46
|
-
const others = prefixes.flatMap(summarizer_1.summarizedMeasurement2CsvHeader).join(',');
|
|
47
|
-
fnOutStream.write(`counter,${others}\n`);
|
|
48
|
-
for (const [idx, info] of definitionsPerFile.entries()) {
|
|
49
|
-
fnOutStream.write(getFnDefCsv(idx, info));
|
|
50
|
-
mergedSuperDefinitions.total.push(...info.total);
|
|
51
|
-
mergedSuperDefinitions.parameters.push(...info.parameters);
|
|
52
|
-
mergedSuperDefinitions.length.lines.push(...info.length.lines);
|
|
53
|
-
mergedSuperDefinitions.length.chars.push(...info.length.chars);
|
|
54
|
-
mergedSuperDefinitions.length.nonWhitespaceChars.push(...info.length.nonWhitespaceChars);
|
|
55
|
-
mergedSuperDefinitions.returns.onlyExplicit.push(...info.returns.onlyExplicit);
|
|
56
|
-
mergedSuperDefinitions.returns.onlyImplicit.push(...info.returns.onlyImplicit);
|
|
57
|
-
mergedSuperDefinitions.exitPointsLinePercentageInDef.push(...info.exitPointsLinePercentageInDef);
|
|
58
|
-
mergedSuperDefinitions.linePercentageInFile.push(...info.linePercentageInFile);
|
|
59
|
-
mergedSuperDefinitions.callsites.push(...info.callsites);
|
|
60
|
-
}
|
|
61
|
-
// now, write the ultimate summary at the end of the file
|
|
62
|
-
fnOutStream.write(getFnDefCsv('all', mergedSuperDefinitions));
|
|
63
|
-
fnOutStream.close();
|
|
64
|
-
}
|
|
65
|
-
function retrieveMetaInformation(info, config, outputPath) {
|
|
66
|
-
const data = {
|
|
67
|
-
total: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
68
|
-
lambdasOnly: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
69
|
-
assignedFunctions: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
70
|
-
nestedFunctions: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
71
|
-
recursive: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
72
|
-
deepestNesting: (0, post_processing_1.emptySummarizedWithProject)()
|
|
73
|
-
};
|
|
74
|
-
for (const [filepath, meta] of info.entries()) {
|
|
75
|
-
const us = meta.definedFunctions;
|
|
76
|
-
addToList(data.total, us.total, filepath, config);
|
|
77
|
-
addToList(data.lambdasOnly, us.lambdasOnly, filepath, config);
|
|
78
|
-
addToList(data.assignedFunctions, us.assignedFunctions, filepath, config);
|
|
79
|
-
addToList(data.nestedFunctions, us.nestedFunctions, filepath, config);
|
|
80
|
-
addToList(data.recursive, us.recursive, filepath, config);
|
|
81
|
-
addToList(data.deepestNesting, us.deepestNesting, filepath, config);
|
|
82
|
-
}
|
|
83
|
-
console.log(` [${(0, time_1.date2string)(new Date())}] Defined functions metadata reading completed, summarizing and writing to file`);
|
|
84
|
-
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-definitions-meta.csv'));
|
|
85
|
-
out.write(`kind,unique-projects,unique-files,${(0, summarizer_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
86
|
-
for (const [key, val] of Object.entries(data)) {
|
|
87
|
-
const data = val;
|
|
88
|
-
out.write(`${JSON.stringify(key)},${data.uniqueProjects.size},${data.uniqueFiles.size},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(data.count))}\n`);
|
|
89
|
-
}
|
|
90
|
-
out.close();
|
|
91
|
-
}
|
|
92
|
-
function retrieveAssignedFunctionNames(featureRoot, config, outputPath) {
|
|
93
|
-
const varNames = new Map();
|
|
94
|
-
(0, files_1.readLineByLineSync)(path_1.default.join(featureRoot, 'assignedFunctions.txt'), line => {
|
|
95
|
-
const parsed = JSON.parse(String(line));
|
|
96
|
-
const [hits, context] = parsed;
|
|
97
|
-
const countsForFile = (0, arrays_1.array2bag)(hits);
|
|
98
|
-
for (const [name, count] of countsForFile.entries()) {
|
|
99
|
-
let get = varNames.get(name);
|
|
100
|
-
if (!get) {
|
|
101
|
-
get = (0, post_processing_1.emptySummarizedWithProject)();
|
|
102
|
-
varNames.set(name, get);
|
|
103
|
-
}
|
|
104
|
-
addToList(get, count, context ?? '', config);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
const varNamesOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-definitions-var-names.csv'));
|
|
108
|
-
varNamesOut.write(`name,unique-projects,unique-files,${(0, summarizer_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
109
|
-
for (const [key, val] of varNames.entries()) {
|
|
110
|
-
varNamesOut.write(`${JSON.stringify(key)},${val.uniqueProjects.size},${val.uniqueFiles.size},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(val.count))}\n`);
|
|
111
|
-
}
|
|
112
|
-
varNamesOut.close();
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Note: the summary does not contain a 0, for each function that `is _not_ called` by a file. Hence, the minimum can not be 0 (division for mean etc. will still be performed on total file count)
|
|
116
|
-
*/
|
|
117
|
-
function postProcess(featureRoot, info, outputPath, config) {
|
|
118
|
-
// each number[][] contains a 'number[]' per file
|
|
119
|
-
retrievePerFileDefinitionInformation(featureRoot, info, config, outputPath);
|
|
120
|
-
console.log(` [${(0, time_1.date2string)(new Date())}] Defined functions reading completed, summarizing info...`);
|
|
121
|
-
retrieveMetaInformation(info, config, outputPath);
|
|
122
|
-
retrieveAssignedFunctionNames(featureRoot, config, outputPath);
|
|
123
|
-
}
|
|
124
|
-
function emptyFunctionDefinitionSummary() {
|
|
125
|
-
return {
|
|
126
|
-
total: [],
|
|
127
|
-
parameters: [],
|
|
128
|
-
length: {
|
|
129
|
-
lines: [],
|
|
130
|
-
chars: [],
|
|
131
|
-
nonWhitespaceChars: []
|
|
132
|
-
},
|
|
133
|
-
returns: {
|
|
134
|
-
explicit: [],
|
|
135
|
-
implicit: [],
|
|
136
|
-
onlyExplicit: [],
|
|
137
|
-
onlyImplicit: []
|
|
138
|
-
},
|
|
139
|
-
exitPointsLinePercentageInDef: [],
|
|
140
|
-
linePercentageInFile: [],
|
|
141
|
-
callsites: []
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function processNextLine(data, lineNumber, info, line) {
|
|
145
|
-
if (lineNumber % 2_500 === 0) {
|
|
146
|
-
console.log(` [${(0, time_1.date2string)(new Date())}] Defined functions processed ${lineNumber} lines`);
|
|
147
|
-
}
|
|
148
|
-
const [hits, context] = line;
|
|
149
|
-
const forFile = emptyFunctionDefinitionSummary();
|
|
150
|
-
for (const { location, length, returns, numberOfParameters, callsites } of hits) {
|
|
151
|
-
const stats = info.get(context ?? '')?.stats.lines[0].length;
|
|
152
|
-
// we retrieve the first component fo the path
|
|
153
|
-
forFile.total.push(1);
|
|
154
|
-
forFile.parameters.push(numberOfParameters);
|
|
155
|
-
forFile.length.lines.push(length.lines);
|
|
156
|
-
forFile.length.chars.push(length.characters);
|
|
157
|
-
forFile.length.nonWhitespaceChars.push(length.nonWhitespaceCharacters);
|
|
158
|
-
forFile.exitPointsLinePercentageInDef.push(returns.map(r => r.location[0]).map(l => l / length.lines));
|
|
159
|
-
forFile.callsites.push(callsites.length);
|
|
160
|
-
if (stats) {
|
|
161
|
-
forFile.linePercentageInFile.push(location[0] / stats);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// push all of that to main :D
|
|
165
|
-
forFile.total = [forFile.total.length];
|
|
166
|
-
data.push(forFile);
|
|
167
|
-
}
|
|
168
|
-
//# sourceMappingURL=post-process.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FeatureStatisticsWithMeta } from '../../feature';
|
|
2
|
-
import type { StatisticsSummarizerConfiguration } from '../../../summarizer/summarizer';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.postProcess = postProcess;
|
|
7
|
-
const post_processing_1 = require("../../post-processing");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const summarizer_1 = require("../../../../util/summarizer");
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
function postProcess(featureRoot, info, outputPath, config) {
|
|
15
|
-
const collected = {};
|
|
16
|
-
const deepestNestingOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'deepest-nesting-per-file.csv'));
|
|
17
|
-
deepestNestingOut.write('file,deepest-nesting\n');
|
|
18
|
-
for (const [filepath, data] of info.entries()) {
|
|
19
|
-
const value = data.expressionList;
|
|
20
|
-
for (const [key, val] of Object.entries(value)) {
|
|
21
|
-
let get = collected[key];
|
|
22
|
-
if (!get) {
|
|
23
|
-
get = (0, post_processing_1.emptySummarizedWithProject)();
|
|
24
|
-
collected[key] = get;
|
|
25
|
-
}
|
|
26
|
-
if (key === 'deepestNesting') {
|
|
27
|
-
deepestNestingOut.write(`${JSON.stringify(filepath)},${val}\n`);
|
|
28
|
-
}
|
|
29
|
-
get.count.push(val);
|
|
30
|
-
if (val > 0) {
|
|
31
|
-
(0, post_processing_1.recordFilePath)(get, filepath, config);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
deepestNestingOut.close();
|
|
36
|
-
const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'used-expression-lists.csv'));
|
|
37
|
-
variablesOutStream.write(`kind,unique-projects,unique-files,${(0, summarizer_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
38
|
-
for (const [key, val] of Object.entries(collected)) {
|
|
39
|
-
const data = val;
|
|
40
|
-
const sum = (0, summarizer_1.summarizeMeasurement)(data.count);
|
|
41
|
-
variablesOutStream.write(`${JSON.stringify(key)},${data.uniqueProjects.size},${data.uniqueFiles.size},${(0, summarizer_1.summarizedMeasurement2Csv)(sum)}\n`);
|
|
42
|
-
}
|
|
43
|
-
variablesOutStream.close();
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=post-process.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Writable } from 'ts-essentials';
|
|
2
|
-
import type { Feature } from '../../feature';
|
|
3
|
-
declare const initialExpressionListInfo: {
|
|
4
|
-
allExpressionLists: number;
|
|
5
|
-
deepestNesting: number;
|
|
6
|
-
};
|
|
7
|
-
export type ExpressionListInfo = Writable<typeof initialExpressionListInfo>;
|
|
8
|
-
export declare const expressionList: Feature<ExpressionListInfo>;
|
|
9
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expressionList = void 0;
|
|
4
|
-
const post_process_1 = require("./post-process");
|
|
5
|
-
const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
|
|
6
|
-
const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
7
|
-
const initialExpressionListInfo = {
|
|
8
|
-
allExpressionLists: 0,
|
|
9
|
-
deepestNesting: 0
|
|
10
|
-
};
|
|
11
|
-
function visitLists(info, input) {
|
|
12
|
-
let nest = -1; // we start with nesting 0
|
|
13
|
-
let total = 0;
|
|
14
|
-
r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
|
|
15
|
-
if (node.type === type_1.RType.ExpressionList) {
|
|
16
|
-
nest++;
|
|
17
|
-
total++;
|
|
18
|
-
info.deepestNesting = Math.max(info.deepestNesting, nest);
|
|
19
|
-
}
|
|
20
|
-
}, node => {
|
|
21
|
-
if (node.type === type_1.RType.ExpressionList) {
|
|
22
|
-
nest--;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
info.allExpressionLists += total;
|
|
26
|
-
}
|
|
27
|
-
exports.expressionList = {
|
|
28
|
-
name: 'Expression Lists',
|
|
29
|
-
description: 'Counts expression list nestings',
|
|
30
|
-
process(existing, input) {
|
|
31
|
-
visitLists(existing, input);
|
|
32
|
-
return existing;
|
|
33
|
-
},
|
|
34
|
-
initialValue: initialExpressionListInfo,
|
|
35
|
-
postProcess: post_process_1.postProcess
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=statistics-expression-list.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Feature } from '../../feature';
|
|
2
|
-
import type { Writable } from 'ts-essentials';
|
|
3
|
-
declare const initialLoopInfo: {
|
|
4
|
-
forLoops: import("../../common-syntax-probability").CommonSyntaxTypeCounts<bigint>;
|
|
5
|
-
forLoopVar: import("../../common-syntax-probability").CommonSyntaxTypeCounts<bigint>;
|
|
6
|
-
forBody: import("../../common-syntax-probability").CommonSyntaxTypeCounts<bigint>;
|
|
7
|
-
whileLoops: import("../../common-syntax-probability").CommonSyntaxTypeCounts<bigint>;
|
|
8
|
-
whileBody: import("../../common-syntax-probability").CommonSyntaxTypeCounts<bigint>;
|
|
9
|
-
repeatLoops: bigint;
|
|
10
|
-
repeatBody: import("../../common-syntax-probability").CommonSyntaxTypeCounts<bigint>;
|
|
11
|
-
breakStatements: number;
|
|
12
|
-
nextStatements: number;
|
|
13
|
-
/** apply, tapply, lapply, ...*/
|
|
14
|
-
implicitLoops: number;
|
|
15
|
-
nestedExplicitLoops: number;
|
|
16
|
-
deepestExplicitNesting: number;
|
|
17
|
-
};
|
|
18
|
-
export type LoopInfo = Writable<typeof initialLoopInfo>;
|
|
19
|
-
export declare const loops: Feature<LoopInfo>;
|
|
20
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loops = void 0;
|
|
4
|
-
const common_syntax_probability_1 = require("../../common-syntax-probability");
|
|
5
|
-
const post_process_1 = require("./post-process");
|
|
6
|
-
const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
|
|
7
|
-
const statistics_file_1 = require("../../../output/statistics-file");
|
|
8
|
-
const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
9
|
-
const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
|
|
10
|
-
const initialLoopInfo = {
|
|
11
|
-
forLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
|
|
12
|
-
forLoopVar: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
|
|
13
|
-
forBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
|
|
14
|
-
whileLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
|
|
15
|
-
whileBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
|
|
16
|
-
repeatLoops: 0n,
|
|
17
|
-
repeatBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
|
|
18
|
-
breakStatements: 0,
|
|
19
|
-
nextStatements: 0,
|
|
20
|
-
/** apply, tapply, lapply, ...*/
|
|
21
|
-
implicitLoops: 0,
|
|
22
|
-
nestedExplicitLoops: 0,
|
|
23
|
-
deepestExplicitNesting: 0
|
|
24
|
-
};
|
|
25
|
-
const isImplicitLoop = /[lsvmt]?apply/;
|
|
26
|
-
function visitLoops(info, input) {
|
|
27
|
-
// holds number of loops and their nesting depths
|
|
28
|
-
const loopStack = [];
|
|
29
|
-
r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
|
|
30
|
-
switch (node.type) {
|
|
31
|
-
case type_1.RType.Next:
|
|
32
|
-
info.nextStatements++;
|
|
33
|
-
return;
|
|
34
|
-
case type_1.RType.Break:
|
|
35
|
-
info.breakStatements++;
|
|
36
|
-
return;
|
|
37
|
-
case type_1.RType.FunctionCall:
|
|
38
|
-
if (node.named && isImplicitLoop.test(node.functionName.lexeme)) {
|
|
39
|
-
info.implicitLoops++;
|
|
40
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.loops.name, 'implicit-loop', [model_1.RNode.lexeme(node.functionName)], input.filepath);
|
|
41
|
-
}
|
|
42
|
-
return;
|
|
43
|
-
case type_1.RType.ForLoop:
|
|
44
|
-
(0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.forLoops, node.vector);
|
|
45
|
-
(0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.forLoopVar, node.variable);
|
|
46
|
-
(0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.forBody, ...node.body.children);
|
|
47
|
-
break;
|
|
48
|
-
case type_1.RType.WhileLoop:
|
|
49
|
-
(0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.whileLoops, node.condition);
|
|
50
|
-
(0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.whileBody, ...node.body.children);
|
|
51
|
-
break;
|
|
52
|
-
case type_1.RType.RepeatLoop:
|
|
53
|
-
info.repeatLoops++;
|
|
54
|
-
(0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.repeatBody, ...node.body.children);
|
|
55
|
-
break;
|
|
56
|
-
default: return;
|
|
57
|
-
}
|
|
58
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.loops.name, 'all-loops', [model_1.RNode.lexeme(node)], input.filepath);
|
|
59
|
-
if (loopStack.length > 0) {
|
|
60
|
-
info.nestedExplicitLoops++;
|
|
61
|
-
info.deepestExplicitNesting = Math.max(info.deepestExplicitNesting, loopStack.length);
|
|
62
|
-
}
|
|
63
|
-
loopStack.push(node);
|
|
64
|
-
}, node => {
|
|
65
|
-
// drop again :D
|
|
66
|
-
if (model_1.RLoopConstructs.is(node)) {
|
|
67
|
-
loopStack.pop();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
exports.loops = {
|
|
72
|
-
name: 'Loops',
|
|
73
|
-
description: 'All looping structures in the document',
|
|
74
|
-
process(existing, input) {
|
|
75
|
-
visitLoops(existing, input);
|
|
76
|
-
return existing;
|
|
77
|
-
},
|
|
78
|
-
initialValue: initialLoopInfo,
|
|
79
|
-
postProcess: post_process_1.postProcess
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=loops.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FeatureStatisticsWithMeta } from '../../feature';
|
|
2
|
-
import type { StatisticsSummarizerConfiguration } from '../../../summarizer/summarizer';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.postProcess = postProcess;
|
|
7
|
-
const post_processing_1 = require("../../post-processing");
|
|
8
|
-
const common_syntax_probability_1 = require("../../common-syntax-probability");
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const numbers_1 = require("../../../../util/numbers");
|
|
12
|
-
const summarizer_1 = require("../../../../util/summarizer");
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
function postProcess(featureRoot, info, outputPath, config) {
|
|
17
|
-
const collected = {
|
|
18
|
-
forLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
|
|
19
|
-
forLoopVar: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
|
|
20
|
-
forBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
|
|
21
|
-
whileLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
|
|
22
|
-
whileBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
|
|
23
|
-
repeatLoops: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
24
|
-
repeatBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
|
|
25
|
-
breakStatements: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
26
|
-
nextStatements: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
27
|
-
implicitLoops: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
28
|
-
nestedExplicitLoops: (0, post_processing_1.emptySummarizedWithProject)(),
|
|
29
|
-
deepestExplicitNesting: (0, post_processing_1.emptySummarizedWithProject)()
|
|
30
|
-
};
|
|
31
|
-
for (const [filepath, data] of info.entries()) {
|
|
32
|
-
const value = data.loops;
|
|
33
|
-
for (const [key, val] of Object.entries(value)) {
|
|
34
|
-
if (typeof val !== 'object') {
|
|
35
|
-
const get = collected[key];
|
|
36
|
-
get.count.push(typeof val === 'number' ? Number(val) : (0, numbers_1.bigint2number)(val));
|
|
37
|
-
if (val > 0) {
|
|
38
|
-
(0, post_processing_1.recordFilePath)(get, filepath, config);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
(0, common_syntax_probability_1.appendCommonSyntaxTypeCounter)(collected[key], val);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const metaOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loops-meta.csv'));
|
|
47
|
-
metaOut.write(`kind,unique-projects,unique-files,${(0, summarizer_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
48
|
-
for (const [key, val] of Object.entries(collected)) {
|
|
49
|
-
const data = val;
|
|
50
|
-
if ('uniqueProjects' in data) {
|
|
51
|
-
metaOut.write(`${JSON.stringify(key)},${data.uniqueProjects.size},${data.uniqueFiles.size},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(data.count))}\n`);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// new file for each :D
|
|
55
|
-
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, `loops-type-${key}.csv`));
|
|
56
|
-
// name is for fields like number etc to allow to group multiple entries
|
|
57
|
-
out.write(`kind,name,${(0, summarizer_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
58
|
-
for (const [name, vals] of Object.entries(data)) {
|
|
59
|
-
if (Array.isArray(vals)) {
|
|
60
|
-
out.write(`${JSON.stringify(name)},"",${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(vals.flat()))}\n`);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
for (const [keyName, keyValue] of Object.entries(vals)) {
|
|
64
|
-
out.write(`${JSON.stringify(name)},${JSON.stringify(keyName)},${(0, summarizer_1.summarizedMeasurement2Csv)((0, summarizer_1.summarizeMeasurement)(keyValue.flat()))}\n`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
out.close();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
metaOut.close();
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=post-process.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FeatureStatisticsWithMeta } from '../../feature';
|
|
2
|
-
import type { StatisticsSummarizerConfiguration } from '../../../summarizer/summarizer';
|
|
3
|
-
/**
|
|
4
|
-
* Note: the summary does not contain a 0 for each function that is _not_ called by a file. Hence, the minimum can not be 0 (division for mean etc. will still be performed on total file count)
|
|
5
|
-
*/
|
|
6
|
-
export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
|