@abaplint/transpiler 2.6.27 → 2.6.29
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.
|
@@ -75,7 +75,8 @@ class AssignTranspiler {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
else if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
|
|
78
|
-
const name = first.concatTokens().toLowerCase();
|
|
78
|
+
// const name = first.concatTokens().toLowerCase();
|
|
79
|
+
const name = new expressions_1.SourceTranspiler().transpile(first, traversal).getCode();
|
|
79
80
|
options.push(`dynamicSource: (() => {
|
|
80
81
|
try { return ${name}; } catch {}
|
|
81
82
|
try { return this.${name}; } catch {}
|
|
@@ -25,7 +25,7 @@ class MethodImplementationTranspiler {
|
|
|
25
25
|
if (methodName.toUpperCase() === "CONSTRUCTOR" && classDef) {
|
|
26
26
|
// note that all ABAP identifiers are lower cased, sometimes the kernel does magic, so it needs to know the method input name
|
|
27
27
|
unique = "INPUT";
|
|
28
|
-
after = traversal.buildConstructorContents(scope.getParent(), classDef);
|
|
28
|
+
// after = traversal.buildConstructorContents(scope.getParent(), classDef);
|
|
29
29
|
methodName = "constructor_";
|
|
30
30
|
}
|
|
31
31
|
const methodDef = this.findMethodParameters(scope);
|
|
@@ -10,10 +10,13 @@ class ClassImplementationTranspiler {
|
|
|
10
10
|
const ret = new chunk_1.Chunk();
|
|
11
11
|
for (const c of node.getChildren()) {
|
|
12
12
|
ret.appendChunk(traversal.traverse(c));
|
|
13
|
+
if (c.get() instanceof abaplint.Statements.ClassImplementation) {
|
|
14
|
+
ret.appendString(this.buildConstructor(node.getFirstStatement(), traversal));
|
|
15
|
+
}
|
|
13
16
|
if (c instanceof abaplint.Nodes.StatementNode
|
|
14
17
|
&& c.get() instanceof abaplint.Statements.ClassImplementation
|
|
15
18
|
&& this.hasConstructor(node) === false) {
|
|
16
|
-
ret.appendString(
|
|
19
|
+
ret.appendString("async constructor_(INPUT) {\nif (super.constructor_) { await super.constructor_(INPUT); }\nreturn this;\n}\n");
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
ret.appendString(this.buildStatic(node.findFirstExpression(abaplint.Expressions.ClassName), traversal));
|
|
@@ -127,6 +130,9 @@ class ClassImplementationTranspiler {
|
|
|
127
130
|
}
|
|
128
131
|
buildConstructor(node, traversal) {
|
|
129
132
|
var _a;
|
|
133
|
+
if (node === undefined) {
|
|
134
|
+
throw new Error("buildConstructor node undefined");
|
|
135
|
+
}
|
|
130
136
|
const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
|
|
131
137
|
const token = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
132
138
|
if (token === undefined) {
|
|
@@ -140,7 +146,8 @@ class ClassImplementationTranspiler {
|
|
|
140
146
|
if (ret === "") {
|
|
141
147
|
return ret;
|
|
142
148
|
}
|
|
143
|
-
|
|
149
|
+
// note: for CALL TRANSFORMATION, its nice that the values are initialized by the JS constructor,
|
|
150
|
+
return "constructor() {\n" + ret + "}\n";
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
153
|
exports.ClassImplementationTranspiler = ClassImplementationTranspiler;
|
package/build/src/traversal.js
CHANGED
|
@@ -319,10 +319,15 @@ class Traversal {
|
|
|
319
319
|
buildConstructorContents(scope, def) {
|
|
320
320
|
var _a, _b, _c;
|
|
321
321
|
let ret = "";
|
|
322
|
-
if (def.getSuperClass() !== undefined
|
|
323
|
-
|
|
324
|
-
ret += `await super.constructor_(INPUT);\n`;
|
|
322
|
+
if (def.getSuperClass() !== undefined || def.getName().toUpperCase() === "CX_ROOT") {
|
|
323
|
+
ret += "super();\n";
|
|
325
324
|
}
|
|
325
|
+
/*
|
|
326
|
+
if (def.getSuperClass() !== undefined
|
|
327
|
+
&& def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
|
|
328
|
+
ret += `await super.constructor_(INPUT);\n`;
|
|
329
|
+
}
|
|
330
|
+
*/
|
|
326
331
|
const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
|
|
327
332
|
ret += "this.me = new abap.types.ABAPObject();\n";
|
|
328
333
|
ret += "this.me.set(this);\n";
|