@abaplint/transpiler 1.7.21 → 1.7.22
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.
|
@@ -13,6 +13,9 @@ class CallTransformationParametersTranspiler {
|
|
|
13
13
|
const res = new chunk_1.Chunk().appendString("{");
|
|
14
14
|
for (const c of node.getChildren()) {
|
|
15
15
|
if (c.get() instanceof abaplint.Expressions.Field || c.get() instanceof abaplint.Expressions.Integer) {
|
|
16
|
+
if (res.getCode() !== "{") {
|
|
17
|
+
res.appendString(",");
|
|
18
|
+
}
|
|
16
19
|
res.appendString(c.concatTokens());
|
|
17
20
|
}
|
|
18
21
|
else if (c.get() instanceof abaplint.Expressions.Source) {
|
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MethodSourceTranspiler = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@abaplint/core");
|
|
5
|
+
const chunk_1 = require("../chunk");
|
|
5
6
|
class MethodSourceTranspiler {
|
|
6
7
|
transpile(node, traversal) {
|
|
7
|
-
const ret = new
|
|
8
|
+
const ret = new chunk_1.Chunk();
|
|
9
|
+
const children = node.getChildren();
|
|
10
|
+
for (let i = 0; i < children.length; i++) {
|
|
11
|
+
const child = children[i];
|
|
12
|
+
const nextChild = children[i + 1];
|
|
13
|
+
if (child.get() instanceof core_1.Expressions.ClassName) {
|
|
14
|
+
ret.appendString(traversal.lookupClassOrInterface(child.concatTokens(), child.getFirstToken()));
|
|
15
|
+
}
|
|
16
|
+
else if (child.get() instanceof core_1.Expressions.Dynamic && nextChild.concatTokens() === "=>") {
|
|
17
|
+
const second = child.getChildren()[1];
|
|
18
|
+
if (second.get() instanceof core_1.Expressions.FieldChain) {
|
|
19
|
+
ret.appendChunk(traversal.traverse(second));
|
|
20
|
+
}
|
|
21
|
+
else if (second.get() instanceof core_1.Expressions.Constant) {
|
|
22
|
+
const lookup = traversal.lookupClassOrInterface(second.getFirstToken().getStr(), child.getFirstToken(), true);
|
|
23
|
+
const lookupException = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_CLASS'", child.getFirstToken(), true);
|
|
24
|
+
// eslint-disable-next-line max-len
|
|
25
|
+
ret.appendString(`if (${lookup} === undefined && ${lookupException} === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_CLASS not found"; }\n`);
|
|
26
|
+
ret.appendString(`if (${lookup} === undefined) { throw new ${lookupException}(); }\n`);
|
|
27
|
+
ret.appendString(lookup);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
ret.appendString("MethodSourceTranspiler-Unexpected");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (child.get() instanceof core_1.Expressions.MethodName) {
|
|
34
|
+
const methodName = child.concatTokens().toLowerCase().replace("~", "$");
|
|
35
|
+
ret.append(methodName, child.getFirstToken().getStart(), traversal);
|
|
36
|
+
}
|
|
37
|
+
else if (child.concatTokens() === "=>") {
|
|
38
|
+
ret.append(".", child.getFirstToken().getStart(), traversal);
|
|
39
|
+
}
|
|
40
|
+
else if (child.concatTokens() === "->") {
|
|
41
|
+
if (ret.getCode() === "super") {
|
|
42
|
+
ret.append(".", child, traversal);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
ret.append(".get().", child, traversal);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (child.get() instanceof core_1.Expressions.FieldChain) {
|
|
49
|
+
ret.appendChunk(traversal.traverse(child));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
ret.appendString("MethodSourceTranspiler-" + child.get().constructor.name + "-todo");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
8
55
|
return ret;
|
|
9
56
|
}
|
|
10
57
|
}
|
|
@@ -14,6 +14,7 @@ class HandleTable {
|
|
|
14
14
|
const type = obj.parseType(reg);
|
|
15
15
|
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
16
|
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
17
|
+
"keyFields": ${JSON.stringify(obj.listKeys())},
|
|
17
18
|
};`);
|
|
18
19
|
const output = {
|
|
19
20
|
object: {
|
|
@@ -26,7 +26,7 @@ class CallTransformationTranspiler {
|
|
|
26
26
|
if (result && result.get() instanceof abaplint.Expressions.CallTransformationParameters) {
|
|
27
27
|
options.push("result: " + traversal.traverse(result).getCode());
|
|
28
28
|
}
|
|
29
|
-
const source = node.findExpressionAfterToken("
|
|
29
|
+
const source = node.findExpressionAfterToken("SOURCE");
|
|
30
30
|
if (source && source.get() instanceof abaplint.Expressions.CallTransformationParameters) {
|
|
31
31
|
options.push("source: " + traversal.traverse(source).getCode());
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.22",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abaplint/core": "^2.84.
|
|
30
|
+
"@abaplint/core": "^2.84.3",
|
|
31
31
|
"source-map": "^0.7.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/chai": "^4.3.0",
|
|
35
|
-
"@types/mocha": "^9.
|
|
35
|
+
"@types/mocha": "^9.1.0",
|
|
36
36
|
"chai": "^4.3.4",
|
|
37
37
|
"mocha": "^9.1.4",
|
|
38
38
|
"source-map-support": "^0.5.21",
|