@abaplint/transpiler 2.11.55 → 2.11.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.
|
@@ -12,26 +12,30 @@ class MethodCallBodyTranspiler {
|
|
|
12
12
|
}
|
|
13
13
|
transpile(node, traversal) {
|
|
14
14
|
const ret = new chunk_1.Chunk();
|
|
15
|
-
let pt = false;
|
|
15
|
+
// let pt = false;
|
|
16
16
|
for (const c of node.getChildren()) {
|
|
17
17
|
if (c instanceof core_1.Nodes.TokenNode) {
|
|
18
|
+
/*
|
|
18
19
|
if (c.concatTokens().toUpperCase() === "PARAMETER") {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return ret;
|
|
20
|
+
// PARAMETER-TABLE
|
|
21
|
+
pt = true;
|
|
22
|
+
} else if(c.concatTokens().toUpperCase() === "EXCEPTION") {
|
|
23
|
+
// todo: handle EXCEPTION-TABLE, for now just produce valid javascript
|
|
24
|
+
return ret;
|
|
25
25
|
}
|
|
26
|
+
*/
|
|
26
27
|
}
|
|
27
28
|
else if (c.get() instanceof abaplint.Expressions.MethodCallParam) {
|
|
28
29
|
ret.appendChunk(new method_call_param_1.MethodCallParamTranspiler(this.m).transpile(c, traversal));
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
32
|
ret.appendChunk(traversal.traverse(c));
|
|
33
|
+
/*
|
|
32
34
|
if (pt === true) {
|
|
33
|
-
|
|
35
|
+
ret.appendString(".array().reduce((a, v) => ({ ...a, [v.get().name.get(
|
|
36
|
+
).toLowerCase().trimEnd()]: v.get().value.dereference()}), {})");
|
|
34
37
|
}
|
|
38
|
+
*/
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
return ret;
|
|
@@ -36,14 +36,25 @@ class CallTranspiler {
|
|
|
36
36
|
const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);
|
|
37
37
|
if (methodSource) {
|
|
38
38
|
let body = "";
|
|
39
|
+
let pre = "";
|
|
40
|
+
let post = "";
|
|
39
41
|
const nameToken = methodSource.getLastChild()?.getFirstToken();
|
|
40
42
|
const m = nameToken ? traversal.findMethodReference(nameToken, traversal.findCurrentScopeByToken(nameToken)) : undefined;
|
|
41
43
|
const methodCallBody = node.findDirectExpression(abaplint.Expressions.MethodCallBody);
|
|
42
44
|
if (methodCallBody) {
|
|
43
|
-
|
|
45
|
+
if (methodCallBody.findDirectTokenByText("EXCEPTION")) {
|
|
46
|
+
throw new Error("EXCEPTION-TABLE not supported, todo");
|
|
47
|
+
}
|
|
48
|
+
if (methodCallBody.findDirectTokenByText("PARAMETER")) {
|
|
49
|
+
const source = traversal.traverse(methodCallBody.findDirectExpression(abaplint.Expressions.Source)).getCode();
|
|
50
|
+
pre = 'await abap.parametersCall(';
|
|
51
|
+
body = ", " + source + ")";
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
body = new expressions_1.MethodCallBodyTranspiler(m?.def).transpile(methodCallBody, traversal).getCode();
|
|
55
|
+
body = "(" + body + ")";
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
|
-
let pre = "";
|
|
46
|
-
let post = "";
|
|
47
58
|
const receiving = node.findFirstExpression(abaplint.Expressions.MethodParameters)?.findExpressionAfterToken("RECEIVING");
|
|
48
59
|
if (receiving) {
|
|
49
60
|
const target = traversal.traverse(receiving.findDirectExpression(abaplint.Expressions.Target));
|
|
@@ -86,7 +97,10 @@ class CallTranspiler {
|
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
|
-
|
|
100
|
+
if (body === "") {
|
|
101
|
+
body = "()";
|
|
102
|
+
}
|
|
103
|
+
return new chunk_1.Chunk().appendString(ms).appendString(body + post + ";");
|
|
90
104
|
}
|
|
91
105
|
throw new Error("CallTranspiler, todo");
|
|
92
106
|
}
|
package/build/src/traversal.js
CHANGED
|
@@ -233,7 +233,7 @@ class Traversal {
|
|
|
233
233
|
for (const p of m.getParameters().getAll()) {
|
|
234
234
|
const type = transpile_types_1.TranspileTypes.toType(p.getType());
|
|
235
235
|
const optional = m.getParameters().getOptional().includes(p.getName()) ? "X" : " ";
|
|
236
|
-
parameters.push(`"${p.getName().toUpperCase()}": {"type": () => {return ${type};}, "is_optional": "${optional}"}`);
|
|
236
|
+
parameters.push(`"${p.getName().toUpperCase()}": {"type": () => {return ${type};}, "is_optional": "${optional}", "type_name": "${p.getType().constructor.name}"}`);
|
|
237
237
|
}
|
|
238
238
|
methods.push(`"${m.getName().toUpperCase()}": {"visibility": "${this.mapVisibility(m.getVisibility())}", "parameters": {${parameters.join(", ")}}}`);
|
|
239
239
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.57",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"author": "abaplint",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@abaplint/core": "^2.113.
|
|
32
|
+
"@abaplint/core": "^2.113.187",
|
|
33
33
|
"source-map": "^0.7.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|