@abaplint/transpiler 2.5.33 → 2.5.35
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.
|
@@ -101,7 +101,20 @@ class ClassImplementationTranspiler {
|
|
|
101
101
|
}
|
|
102
102
|
// this is not correct, ABAP does not invocate the class constructor at require time,
|
|
103
103
|
// but this will probably work
|
|
104
|
-
if (
|
|
104
|
+
if (traversal.getCurrentObject().getType() === "CLAS") {
|
|
105
|
+
// gather call of all class constructors together for a global class, also local classes
|
|
106
|
+
// as they might use the global class
|
|
107
|
+
if (cdef.isGlobal() === true) {
|
|
108
|
+
for (const f of traversal.getCurrentObject().getABAPFiles()) {
|
|
109
|
+
for (const def of f.getInfo().listClassDefinitions()) {
|
|
110
|
+
if (def.methods.some(m => m.name.toLowerCase() === "class_constructor")) {
|
|
111
|
+
ret += "await " + traversal.lookupClassOrInterface(def.name, node.getFirstToken()) + ".class_constructor();\n";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (cdef.getMethodDefinitions().getByName("class_constructor")) {
|
|
105
118
|
ret += "await " + traversal_1.Traversal.escapeNamespace(node.getFirstToken().getStr().toLowerCase()) + ".class_constructor();\n";
|
|
106
119
|
}
|
|
107
120
|
return ret;
|
|
@@ -45,7 +45,7 @@ class FunctionModuleTranspiler {
|
|
|
45
45
|
const scope = traversal.findCurrentScopeByToken(node.getLastToken());
|
|
46
46
|
let ret = "";
|
|
47
47
|
for (const p of module.getParameters()) {
|
|
48
|
-
ret += `// ${p.direction} ${p.name} ${p.type}\n`;
|
|
48
|
+
ret += `// ${p.direction} ${p.name} ${p.type} ${p.optional}\n`;
|
|
49
49
|
let direction = p.direction;
|
|
50
50
|
if (direction === "importing") {
|
|
51
51
|
direction = "exporting";
|
|
@@ -59,15 +59,12 @@ class FunctionModuleTranspiler {
|
|
|
59
59
|
name += "_";
|
|
60
60
|
}
|
|
61
61
|
ret += `let ${name} = INPUT.${direction}?.${name};\n`;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
${name} = ${new transpile_types_1.TranspileTypes().toType(type)};
|
|
69
|
-
}\n`;
|
|
70
|
-
}
|
|
62
|
+
const type = (_c = scope === null || scope === void 0 ? void 0 : scope.findVariable(name)) === null || _c === void 0 ? void 0 : _c.getType();
|
|
63
|
+
if (type !== undefined && p.optional === true) {
|
|
64
|
+
// todo, set DEFAULT value
|
|
65
|
+
ret += `if (${name} === undefined) {
|
|
66
|
+
${name} = ${new transpile_types_1.TranspileTypes().toType(type)};
|
|
67
|
+
}\n`;
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
70
|
return ret;
|