@abaplint/transpiler 2.1.56 → 2.1.57
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,7 +6,7 @@ const chunk_1 = require("../chunk");
|
|
|
6
6
|
const expressions_1 = require("../expressions");
|
|
7
7
|
class CallTranspiler {
|
|
8
8
|
transpile(node, traversal) {
|
|
9
|
-
var _a, _b, _c;
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
10
|
if (node.concatTokens().toLowerCase().includes("super->constructor")) {
|
|
11
11
|
// todo, https://github.com/abaplint/transpiler/issues/133
|
|
12
12
|
return new chunk_1.Chunk("");
|
|
@@ -20,10 +20,39 @@ class CallTranspiler {
|
|
|
20
20
|
pre = traversal.traverse(receiving).getCode() + ".set(";
|
|
21
21
|
post = ")";
|
|
22
22
|
}
|
|
23
|
+
const exceptions = node.findFirstExpression(abaplint.Expressions.ParameterListExceptions);
|
|
24
|
+
if (exceptions) {
|
|
25
|
+
pre = "try {\n" + pre;
|
|
26
|
+
}
|
|
27
|
+
post += ";";
|
|
28
|
+
if (exceptions) {
|
|
29
|
+
post += `\nabap.builtin.sy.get().subrc.set(0);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (e.classic) {
|
|
32
|
+
switch (e.classic.toUpperCase()) {\n`;
|
|
33
|
+
for (const e of exceptions.findAllExpressions(abaplint.Expressions.ParameterException)) {
|
|
34
|
+
const name = e.getFirstToken().getStr().toUpperCase();
|
|
35
|
+
const value = (_c = e.findFirstExpression(abaplint.Expressions.SimpleName)) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase();
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (name === "OTHERS") {
|
|
40
|
+
post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\n`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
post += `case "${name}": abap.builtin.sy.get().subrc.set(${value}); break;\n`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
post += ` }
|
|
47
|
+
} else {
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}`;
|
|
51
|
+
}
|
|
23
52
|
return new chunk_1.Chunk()
|
|
24
53
|
.appendString(pre)
|
|
25
54
|
.appendChunk(traversal.traverse(chain))
|
|
26
|
-
.append(post
|
|
55
|
+
.append(post, node.getLastToken(), traversal);
|
|
27
56
|
}
|
|
28
57
|
const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);
|
|
29
58
|
if (methodSource) {
|
|
@@ -34,7 +63,7 @@ class CallTranspiler {
|
|
|
34
63
|
}
|
|
35
64
|
let pre = "";
|
|
36
65
|
let post = "";
|
|
37
|
-
const receiving = (
|
|
66
|
+
const receiving = (_d = node.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _d === void 0 ? void 0 : _d.findExpressionAfterToken("RECEIVING");
|
|
38
67
|
if (receiving) {
|
|
39
68
|
const target = traversal.traverse(receiving.findDirectExpression(abaplint.Expressions.Target));
|
|
40
69
|
pre = target.getCode() + ".set(";
|
|
@@ -13,7 +13,7 @@ class RaiseTranspiler {
|
|
|
13
13
|
const s = node.findFirstExpression(abaplint.Expressions.SimpleSource2);
|
|
14
14
|
if (s === undefined) {
|
|
15
15
|
const name = (_b = node.findFirstExpression(abaplint.Expressions.ExceptionName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toLowerCase();
|
|
16
|
-
return new chunk_1.Chunk().append(`throw new
|
|
16
|
+
return new chunk_1.Chunk().append(`throw new abap.ClassicError({classic: "${name}"});`, node, traversal);
|
|
17
17
|
}
|
|
18
18
|
const sCode = new expressions_1.SourceTranspiler(true).transpile(s, traversal).getCode();
|
|
19
19
|
return new chunk_1.Chunk().append(`throw ${sCode};`, node, traversal);
|