@abaplint/core 2.80.5 → 2.80.6
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.
|
@@ -6,20 +6,6 @@ const Structures = require("../3_structures/structures");
|
|
|
6
6
|
const Statements = require("../2_statements/statements");
|
|
7
7
|
const Expressions = require("../2_statements/expressions");
|
|
8
8
|
const flow_graph_1 = require("./flow_graph");
|
|
9
|
-
// Levels: top, FORM, METHOD, FUNCTION-MODULE, (MODULE, AT, END-OF-*, GET, START-OF-SELECTION, TOP-OF-PAGE)
|
|
10
|
-
//
|
|
11
|
-
// Loop branching: LOOP, DO, WHILE,SELECT(loop), WITH, PROVIDE
|
|
12
|
-
//
|
|
13
|
-
// Branching: IF, CASE, CASE TYPE OF, TRY, ON, CATCH SYSTEM-EXCEPTIONS, AT
|
|
14
|
-
//
|
|
15
|
-
// Conditional exits: CHECK, ASSERT
|
|
16
|
-
//
|
|
17
|
-
// Exits: RETURN, EXIT, RAISE(not RESUMABLE), MESSAGE(type E and A?), CONTINUE, REJECT, RESUME, STOP
|
|
18
|
-
//
|
|
19
|
-
// Not handled? INCLUDE + malplaced macro calls
|
|
20
|
-
/////////////////////////////////////
|
|
21
|
-
// TODO: handling static exceptions(only static), refactor some logic from UncaughtException to common file
|
|
22
|
-
// TODO: RAISE
|
|
23
9
|
class StatementFlow {
|
|
24
10
|
constructor() {
|
|
25
11
|
this.counter = 0;
|
|
@@ -31,7 +17,7 @@ class StatementFlow {
|
|
|
31
17
|
for (const f of forms) {
|
|
32
18
|
const formName = "FORM " + ((_a = f.findFirstExpression(Expressions.FormName)) === null || _a === void 0 ? void 0 : _a.concatTokens());
|
|
33
19
|
this.counter = 1;
|
|
34
|
-
const graph = this.traverseBody(this.findBody(f), "end#1"
|
|
20
|
+
const graph = this.traverseBody(this.findBody(f), { procedureEnd: "end#1" });
|
|
35
21
|
graph.setLabel(formName);
|
|
36
22
|
ret.push(graph);
|
|
37
23
|
}
|
|
@@ -39,7 +25,7 @@ class StatementFlow {
|
|
|
39
25
|
for (const f of methods) {
|
|
40
26
|
const methodName = "METHOD " + ((_b = f.findFirstExpression(Expressions.MethodName)) === null || _b === void 0 ? void 0 : _b.concatTokens());
|
|
41
27
|
this.counter = 1;
|
|
42
|
-
const graph = this.traverseBody(this.findBody(f), "end#1"
|
|
28
|
+
const graph = this.traverseBody(this.findBody(f), { procedureEnd: "end#1" });
|
|
43
29
|
graph.setLabel(methodName);
|
|
44
30
|
ret.push(graph);
|
|
45
31
|
}
|
|
@@ -50,12 +36,27 @@ class StatementFlow {
|
|
|
50
36
|
return ((_a = f.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.getChildren()) || [];
|
|
51
37
|
}
|
|
52
38
|
buildName(statement) {
|
|
53
|
-
|
|
39
|
+
let token = undefined;
|
|
40
|
+
const colon = statement.getColon();
|
|
41
|
+
if (colon === undefined) {
|
|
42
|
+
token = statement.getFirstToken();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
for (const t of statement.getTokens()) {
|
|
46
|
+
if (t.getStart().isAfter(colon.getEnd())) {
|
|
47
|
+
token = t;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (token === undefined) {
|
|
53
|
+
return "tokenError";
|
|
54
|
+
}
|
|
54
55
|
return statement.get().constructor.name +
|
|
55
|
-
":" +
|
|
56
|
-
"," +
|
|
56
|
+
":" + token.getRow() +
|
|
57
|
+
"," + token.getCol();
|
|
57
58
|
}
|
|
58
|
-
traverseBody(children,
|
|
59
|
+
traverseBody(children, context) {
|
|
59
60
|
const graph = new flow_graph_1.FlowGraph(this.counter++);
|
|
60
61
|
if (children.length === 0) {
|
|
61
62
|
graph.addEdge(graph.getStart(), graph.getEnd());
|
|
@@ -70,37 +71,36 @@ class StatementFlow {
|
|
|
70
71
|
graph.addEdge(current, name);
|
|
71
72
|
current = name;
|
|
72
73
|
if (firstChild.get() instanceof Statements.Check) {
|
|
73
|
-
if (loopStart) {
|
|
74
|
-
graph.addEdge(name, loopStart);
|
|
74
|
+
if (context.loopStart) {
|
|
75
|
+
graph.addEdge(name, context.loopStart);
|
|
75
76
|
}
|
|
76
77
|
else {
|
|
77
|
-
graph.addEdge(name, procedureEnd);
|
|
78
|
+
graph.addEdge(name, context.procedureEnd);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
else if (firstChild.get() instanceof Statements.Assert) {
|
|
81
|
-
graph.addEdge(name, procedureEnd);
|
|
82
|
+
graph.addEdge(name, context.procedureEnd);
|
|
82
83
|
}
|
|
83
|
-
else if (firstChild.get() instanceof Statements.Continue && loopStart) {
|
|
84
|
-
graph.addEdge(name, loopStart);
|
|
84
|
+
else if (firstChild.get() instanceof Statements.Continue && context.loopStart) {
|
|
85
|
+
graph.addEdge(name, context.loopStart);
|
|
85
86
|
return graph;
|
|
86
87
|
}
|
|
87
88
|
else if (firstChild.get() instanceof Statements.Exit) {
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
graph.addEdge(name, loopStart);
|
|
89
|
+
if (context.loopEnd) {
|
|
90
|
+
graph.addEdge(name, context.loopEnd);
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
graph.addEdge(name, procedureEnd);
|
|
93
|
+
graph.addEdge(name, context.procedureEnd);
|
|
94
94
|
}
|
|
95
95
|
return graph;
|
|
96
96
|
}
|
|
97
97
|
else if (firstChild.get() instanceof Statements.Return) {
|
|
98
|
-
graph.addEdge(name, procedureEnd);
|
|
98
|
+
graph.addEdge(name, context.procedureEnd);
|
|
99
99
|
return graph;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
else if (firstChild instanceof nodes_1.StructureNode) {
|
|
103
|
-
const sub = this.traverseStructure(firstChild,
|
|
103
|
+
const sub = this.traverseStructure(firstChild, context);
|
|
104
104
|
current = graph.addGraph(current, sub);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ class StatementFlow {
|
|
|
108
108
|
graph.addEdge(current, graph.getEnd());
|
|
109
109
|
return graph;
|
|
110
110
|
}
|
|
111
|
-
traverseStructure(n,
|
|
111
|
+
traverseStructure(n, context) {
|
|
112
112
|
const graph = new flow_graph_1.FlowGraph(this.counter++);
|
|
113
113
|
if (n === undefined) {
|
|
114
114
|
return graph;
|
|
@@ -117,7 +117,7 @@ class StatementFlow {
|
|
|
117
117
|
const type = n.get();
|
|
118
118
|
if (type instanceof Structures.If) {
|
|
119
119
|
const ifName = this.buildName(n.findDirectStatement(Statements.If));
|
|
120
|
-
const sub = this.traverseBody(this.findBody(n),
|
|
120
|
+
const sub = this.traverseBody(this.findBody(n), context);
|
|
121
121
|
graph.addEdge(current, ifName);
|
|
122
122
|
graph.addGraph(ifName, sub);
|
|
123
123
|
graph.addEdge(sub.getEnd(), graph.getEnd());
|
|
@@ -128,7 +128,7 @@ class StatementFlow {
|
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
130
|
const elseIfName = this.buildName(elseifst);
|
|
131
|
-
const sub = this.traverseBody(this.findBody(e),
|
|
131
|
+
const sub = this.traverseBody(this.findBody(e), context);
|
|
132
132
|
graph.addEdge(current, elseIfName);
|
|
133
133
|
graph.addGraph(elseIfName, sub);
|
|
134
134
|
graph.addEdge(sub.getEnd(), graph.getEnd());
|
|
@@ -138,7 +138,7 @@ class StatementFlow {
|
|
|
138
138
|
const elsest = els === null || els === void 0 ? void 0 : els.findDirectStatement(Statements.Else);
|
|
139
139
|
if (els && elsest) {
|
|
140
140
|
const elseName = this.buildName(elsest);
|
|
141
|
-
const sub = this.traverseBody(this.findBody(els),
|
|
141
|
+
const sub = this.traverseBody(this.findBody(els), context);
|
|
142
142
|
graph.addEdge(current, elseName);
|
|
143
143
|
graph.addGraph(elseName, sub);
|
|
144
144
|
graph.addEdge(sub.getEnd(), graph.getEnd());
|
|
@@ -154,7 +154,7 @@ class StatementFlow {
|
|
|
154
154
|
|| type instanceof Structures.Select
|
|
155
155
|
|| type instanceof Structures.Do) {
|
|
156
156
|
const loopName = this.buildName(n.getFirstStatement());
|
|
157
|
-
const sub = this.traverseBody(this.findBody(n),
|
|
157
|
+
const sub = this.traverseBody(this.findBody(n), Object.assign(Object.assign({}, context), { loopStart: loopName, loopEnd: graph.getEnd() }));
|
|
158
158
|
graph.addEdge(current, loopName);
|
|
159
159
|
graph.addGraph(loopName, sub);
|
|
160
160
|
graph.addEdge(sub.getEnd(), loopName);
|
|
@@ -162,13 +162,13 @@ class StatementFlow {
|
|
|
162
162
|
}
|
|
163
163
|
else if (type instanceof Structures.Try) {
|
|
164
164
|
const tryName = this.buildName(n.getFirstStatement());
|
|
165
|
-
const body = this.traverseBody(this.findBody(n),
|
|
165
|
+
const body = this.traverseBody(this.findBody(n), context);
|
|
166
166
|
graph.addEdge(current, tryName);
|
|
167
167
|
graph.addGraph(tryName, body);
|
|
168
168
|
graph.addEdge(body.getEnd(), graph.getEnd());
|
|
169
169
|
for (const c of n.findDirectStructures(Structures.Catch)) {
|
|
170
170
|
const catchName = this.buildName(c.getFirstStatement());
|
|
171
|
-
const catchBody = this.traverseBody(this.findBody(c),
|
|
171
|
+
const catchBody = this.traverseBody(this.findBody(c), context);
|
|
172
172
|
// TODO: this does not take exceptions into account
|
|
173
173
|
graph.addEdge(body.getEnd(), catchName);
|
|
174
174
|
graph.addGraph(catchName, catchBody);
|
|
@@ -189,7 +189,7 @@ class StatementFlow {
|
|
|
189
189
|
othersFound = true;
|
|
190
190
|
}
|
|
191
191
|
const firstName = this.buildName(first);
|
|
192
|
-
const sub = this.traverseBody(this.findBody(w),
|
|
192
|
+
const sub = this.traverseBody(this.findBody(w), context);
|
|
193
193
|
graph.addEdge(caseName, firstName);
|
|
194
194
|
graph.addGraph(firstName, sub);
|
|
195
195
|
graph.addEdge(sub.getEnd(), graph.getEnd());
|
|
@@ -211,7 +211,7 @@ class StatementFlow {
|
|
|
211
211
|
othersFound = true;
|
|
212
212
|
}
|
|
213
213
|
const firstName = this.buildName(first);
|
|
214
|
-
const sub = this.traverseBody(this.findBody(w),
|
|
214
|
+
const sub = this.traverseBody(this.findBody(w), context);
|
|
215
215
|
graph.addEdge(caseName, firstName);
|
|
216
216
|
graph.addGraph(firstName, sub);
|
|
217
217
|
graph.addEdge(sub.getEnd(), graph.getEnd());
|
|
@@ -221,7 +221,7 @@ class StatementFlow {
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
else {
|
|
224
|
-
console.dir("todo, " + n.get().constructor.name);
|
|
224
|
+
console.dir("StatementFlow,todo, " + n.get().constructor.name);
|
|
225
225
|
}
|
|
226
226
|
return graph;
|
|
227
227
|
}
|
package/build/src/registry.js
CHANGED