@abaplint/transpiler 2.11.30 → 2.11.32
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.
|
@@ -84,10 +84,12 @@ class CompareTranspiler {
|
|
|
84
84
|
}
|
|
85
85
|
const chain = node.findDirectExpression(core_1.Expressions.MethodCallChain);
|
|
86
86
|
if (chain) {
|
|
87
|
+
const negated = concat.startsWith("NOT ");
|
|
87
88
|
const name = chain.getFirstToken().getStr();
|
|
88
89
|
if (core_1.BuiltIn.isPredicate(name)) {
|
|
89
90
|
// todo, this is not completely correct if there is a method shadowing the name
|
|
90
|
-
|
|
91
|
+
const operator = negated ? 'ne' : 'eq';
|
|
92
|
+
return new chunk_1.Chunk().appendString(`abap.compare.${operator}(` + traversal.traverse(chain).getCode() + `, abap.builtin.abap_true)`);
|
|
91
93
|
}
|
|
92
94
|
else {
|
|
93
95
|
return new chunk_1.Chunk().appendString(pre + `abap.compare.initial(${traversal.traverse(chain).getCode()}) === false`);
|
|
@@ -7,33 +7,43 @@ const method_call_param_1 = require("./method_call_param");
|
|
|
7
7
|
const chunk_1 = require("../chunk");
|
|
8
8
|
class MethodCallTranspiler {
|
|
9
9
|
transpile(node, traversal) {
|
|
10
|
+
let post = "";
|
|
10
11
|
const nameToken = node.findDirectExpression(core_1.Expressions.MethodName)?.getFirstToken();
|
|
11
12
|
if (nameToken === undefined) {
|
|
12
13
|
throw new Error("MethodCallTranspiler, name not found");
|
|
13
14
|
}
|
|
15
|
+
const scope = traversal.findCurrentScopeByToken(nameToken);
|
|
16
|
+
const m = traversal.findMethodReference(nameToken, scope);
|
|
14
17
|
let name = nameToken.getStr().toLowerCase();
|
|
15
18
|
if (traversal.isBuiltinMethod(nameToken)) {
|
|
16
|
-
|
|
19
|
+
// todo: this is not correct, the method name might be shadowed
|
|
20
|
+
name = "abap.builtin." + name + "(";
|
|
21
|
+
if (name === "abap.builtin.line_exists(" || name === "abap.builtin.line_index(") {
|
|
22
|
+
name += "() => {";
|
|
23
|
+
post = "}";
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
// it might be aliased?
|
|
20
|
-
const m = traversal.findMethodReference(nameToken, scope);
|
|
21
|
-
if (m?.name && traversal.isBuiltinMethod(nameToken) === false) {
|
|
26
|
+
else if (m?.name) {
|
|
22
27
|
name = m.name.toLowerCase();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
name = traversal_1.Traversal.escapeNamespace(name.replace("~", "$"));
|
|
29
|
+
if (m?.def.getVisibility() === core_1.Visibility.Private
|
|
30
|
+
&& m.def.isStatic() === false) {
|
|
31
|
+
const id = scope?.getParent()?.getParent()?.getIdentifier();
|
|
32
|
+
if (id?.stype === core_1.ScopeType.ClassImplementation
|
|
33
|
+
&& m.def.getClassName().toUpperCase() === id.sname.toUpperCase()) {
|
|
34
|
+
name = "#" + name;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
name = `FRIENDS_ACCESS_INSTANCE["${name}"]`;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
40
|
+
name = name + "(";
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// todo: this should never happen?
|
|
44
|
+
name = traversal_1.Traversal.escapeNamespace(name.replace("~", "$"));
|
|
45
|
+
name = name + "(";
|
|
35
46
|
}
|
|
36
|
-
name = name + "(";
|
|
37
47
|
const step = node.findDirectExpression(core_1.Expressions.MethodCallParam);
|
|
38
48
|
if (step === undefined) {
|
|
39
49
|
throw new Error("MethodCallTranspiler, unexpected node");
|
|
@@ -41,7 +51,7 @@ class MethodCallTranspiler {
|
|
|
41
51
|
const ret = new chunk_1.Chunk();
|
|
42
52
|
ret.append(name, nameToken, traversal);
|
|
43
53
|
ret.appendChunk(new method_call_param_1.MethodCallParamTranspiler(m?.def).transpile(step, traversal));
|
|
44
|
-
ret.appendString(")");
|
|
54
|
+
ret.appendString(post + ")");
|
|
45
55
|
return ret;
|
|
46
56
|
}
|
|
47
57
|
}
|