@abaplint/transpiler 2.1.62 → 2.1.63
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.
|
@@ -7,10 +7,6 @@ const expressions_1 = require("../expressions");
|
|
|
7
7
|
class CallTranspiler {
|
|
8
8
|
transpile(node, traversal) {
|
|
9
9
|
var _a, _b, _c, _d;
|
|
10
|
-
if (node.concatTokens().toLowerCase().includes("super->constructor")) {
|
|
11
|
-
// todo, https://github.com/abaplint/transpiler/issues/133
|
|
12
|
-
return new chunk_1.Chunk("");
|
|
13
|
-
}
|
|
14
10
|
const chain = node.findDirectExpression(abaplint.Expressions.MethodCallChain);
|
|
15
11
|
if (chain) {
|
|
16
12
|
let pre = "";
|
|
@@ -49,9 +45,15 @@ if (e.classic) {
|
|
|
49
45
|
}
|
|
50
46
|
}`;
|
|
51
47
|
}
|
|
48
|
+
const chainChunk = traversal.traverse(chain);
|
|
49
|
+
let chainCode = chainChunk.getCode();
|
|
50
|
+
if (chainCode.startsWith("await super.constructor(")) {
|
|
51
|
+
// semantics of constructors in JS vs ABAP is different, so the "constructor_" has been introduced,
|
|
52
|
+
chainCode = chainCode.replace("await super.constructor(", "await super.constructor_(");
|
|
53
|
+
}
|
|
52
54
|
return new chunk_1.Chunk()
|
|
53
55
|
.appendString(pre)
|
|
54
|
-
.
|
|
56
|
+
.appendString(chainCode)
|
|
55
57
|
.append(post, node.getLastToken(), traversal);
|
|
56
58
|
}
|
|
57
59
|
const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);
|
|
@@ -69,8 +71,12 @@ if (e.classic) {
|
|
|
69
71
|
pre = target.getCode() + ".set(";
|
|
70
72
|
post = ")";
|
|
71
73
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
let ms = new expressions_1.MethodSourceTranspiler(pre).transpile(methodSource, traversal).getCode();
|
|
75
|
+
if (ms === "await super.get().constructor") {
|
|
76
|
+
// semantics of constructors in JS vs ABAP is different, so the "constructor_" has been introduced,
|
|
77
|
+
ms = "await super.constructor_";
|
|
78
|
+
}
|
|
79
|
+
return new chunk_1.Chunk().appendString(ms).appendString("(" + body + ")" + post + ";");
|
|
74
80
|
}
|
|
75
81
|
throw new Error("CallTranspiler, todo");
|
|
76
82
|
}
|
package/build/src/traversal.js
CHANGED
|
@@ -251,16 +251,9 @@ class Traversal {
|
|
|
251
251
|
return undefined;
|
|
252
252
|
}
|
|
253
253
|
buildConstructorContents(scope, def) {
|
|
254
|
-
/*
|
|
255
|
-
const vars = scope?.getData().vars;
|
|
256
|
-
if (vars === undefined || Object.keys(vars).length === 0) {
|
|
257
|
-
return "";
|
|
258
|
-
}
|
|
259
|
-
*/
|
|
260
254
|
let ret = "";
|
|
261
|
-
if (def.getSuperClass() !== undefined
|
|
262
|
-
|
|
263
|
-
// for now just pass the same input
|
|
255
|
+
if (def.getSuperClass() !== undefined
|
|
256
|
+
&& def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
|
|
264
257
|
ret += `await super.constructor_(INPUT);\n`;
|
|
265
258
|
}
|
|
266
259
|
ret += "this.me = new abap.types.ABAPObject();\n";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.63",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"author": "abaplint",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@abaplint/core": "^2.93.
|
|
31
|
+
"@abaplint/core": "^2.93.14",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|