@abaplint/transpiler 2.1.62 → 2.1.64
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
|
}
|
|
@@ -49,6 +49,9 @@ class CreateObjectTranspiler {
|
|
|
49
49
|
throw new Error("CreateObjectTranspiler, unable to lookup position");
|
|
50
50
|
}
|
|
51
51
|
const target = node.findDirectExpression(abaplint.Expressions.Target);
|
|
52
|
+
if (target === undefined) {
|
|
53
|
+
throw new Error(`CreateObjectTranspiler, target not found`);
|
|
54
|
+
}
|
|
52
55
|
const type = traversal.determineType(node, scope);
|
|
53
56
|
if (type === undefined) {
|
|
54
57
|
throw new Error(`CreateObjectTranspiler, target variable "${target === null || target === void 0 ? void 0 : target.concatTokens()}" not found in scope`);
|
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";
|
|
@@ -322,7 +315,7 @@ class Traversal {
|
|
|
322
315
|
return ret;
|
|
323
316
|
}
|
|
324
317
|
determineType(node, scope) {
|
|
325
|
-
var _a;
|
|
318
|
+
var _a, _b, _c;
|
|
326
319
|
if (scope === undefined) {
|
|
327
320
|
return undefined;
|
|
328
321
|
}
|
|
@@ -339,6 +332,21 @@ class Traversal {
|
|
|
339
332
|
&& context instanceof abaplint.BasicTypes.StructureType) {
|
|
340
333
|
context = context.getComponentByName(c.getFirstToken().getStr());
|
|
341
334
|
}
|
|
335
|
+
else if (c.get() instanceof abaplint.Expressions.AttributeName
|
|
336
|
+
&& context instanceof abaplint.BasicTypes.ObjectReferenceType) {
|
|
337
|
+
const id = context.getIdentifier();
|
|
338
|
+
if (id instanceof abaplint.Types.ClassDefinition || id instanceof abaplint.Types.InterfaceDefinition) {
|
|
339
|
+
const concat = c.concatTokens();
|
|
340
|
+
if (concat.includes("~")) {
|
|
341
|
+
const [iname, aname] = concat.split("~");
|
|
342
|
+
const intf = scope.findInterfaceDefinition(iname);
|
|
343
|
+
context = (_b = intf === null || intf === void 0 ? void 0 : intf.getAttributes().findByName(aname)) === null || _b === void 0 ? void 0 : _b.getType();
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
context = (_c = id.getAttributes().findByName(concat)) === null || _c === void 0 ? void 0 : _c.getType();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
342
350
|
}
|
|
343
351
|
return context;
|
|
344
352
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.64",
|
|
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.15",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|