@abaplint/transpiler 2.11.69 → 2.11.71
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.
|
@@ -6,7 +6,7 @@ const chunk_1 = require("../chunk");
|
|
|
6
6
|
class CompareTranspiler {
|
|
7
7
|
transpile(node, traversal) {
|
|
8
8
|
// todo, this is not correct
|
|
9
|
-
|
|
9
|
+
let concat = node.concatTokens().toUpperCase();
|
|
10
10
|
let pre = concat.startsWith("NOT ") ? "!" : "";
|
|
11
11
|
const sources = node.findDirectExpressionsMulti([core_1.Expressions.Source, core_1.Expressions.SourceFieldSymbolChain, core_1.Expressions.SourceFieldSymbol]);
|
|
12
12
|
if (sources.length === 1) {
|
|
@@ -36,7 +36,10 @@ class CompareTranspiler {
|
|
|
36
36
|
return new chunk_1.Chunk().appendString("abap.compare.assigned(").appendChunk(s0).appendString(")");
|
|
37
37
|
}
|
|
38
38
|
if (concat.endsWith(" IS SUPPLIED")) {
|
|
39
|
-
|
|
39
|
+
if (concat.startsWith("NOT ")) {
|
|
40
|
+
concat = concat.replace("NOT ", "");
|
|
41
|
+
}
|
|
42
|
+
return new chunk_1.Chunk().appendString(pre + "(INPUT && INPUT." + concat.replace(" IS SUPPLIED", "" + ")").toLowerCase());
|
|
40
43
|
}
|
|
41
44
|
else if (concat.endsWith(" IS NOT SUPPLIED")) {
|
|
42
45
|
return new chunk_1.Chunk().appendString(pre + "INPUT && INPUT." + concat.replace(" IS NOT SUPPLIED", "").toLowerCase() + " === undefined");
|
|
@@ -5,6 +5,8 @@ const core_1 = require("@abaplint/core");
|
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
6
|
const type_name_or_infer_1 = require("./type_name_or_infer");
|
|
7
7
|
const transpile_types_1 = require("../transpile_types");
|
|
8
|
+
const component_chain_1 = require("./component_chain");
|
|
9
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
8
10
|
class CorrespondingBodyTranspiler {
|
|
9
11
|
transpile(typ, body, traversal) {
|
|
10
12
|
if (!(typ.get() instanceof core_1.Expressions.TypeNameOrInfer)) {
|
|
@@ -13,6 +15,8 @@ class CorrespondingBodyTranspiler {
|
|
|
13
15
|
const type = new type_name_or_infer_1.TypeNameOrInfer().findType(typ, traversal);
|
|
14
16
|
let target = transpile_types_1.TranspileTypes.toType(type);
|
|
15
17
|
let source;
|
|
18
|
+
const mapping = [];
|
|
19
|
+
const mappingRow = { componentName: undefined, componentChain: undefined };
|
|
16
20
|
for (const child of body.getChildren()) {
|
|
17
21
|
const c = child.get();
|
|
18
22
|
if (c instanceof core_1.Expressions.Source && child instanceof core_1.Nodes.ExpressionNode) {
|
|
@@ -22,12 +26,33 @@ class CorrespondingBodyTranspiler {
|
|
|
22
26
|
source = traversal.traverse(child?.findDirectExpression(core_1.Expressions.Source));
|
|
23
27
|
target = `abap.statements.moveCorresponding(${source.getCode()}, ${target})`;
|
|
24
28
|
}
|
|
29
|
+
else if (c instanceof core_1.Expressions.CorrespondingBodyMapping && child instanceof core_1.Nodes.ExpressionNode) {
|
|
30
|
+
for (const cc of child.getChildren()) {
|
|
31
|
+
if (cc.get() instanceof core_1.Expressions.ComponentName) {
|
|
32
|
+
mappingRow.componentName = cc;
|
|
33
|
+
}
|
|
34
|
+
else if (cc.get() instanceof core_1.Expressions.ComponentChain) {
|
|
35
|
+
mappingRow.componentChain = cc;
|
|
36
|
+
mapping.push(mappingRow);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
25
40
|
else {
|
|
26
|
-
throw new Error("CorrespondingBodyTranspiler, todo, " + c.constructor.name);
|
|
41
|
+
throw new Error("CorrespondingBodyTranspiler, todo, " + c.constructor.name + ", " + body.concatTokens());
|
|
27
42
|
}
|
|
28
43
|
}
|
|
29
44
|
const ret = new chunk_1.Chunk();
|
|
30
|
-
|
|
45
|
+
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
46
|
+
ret.appendString("(await (async () => {\n");
|
|
47
|
+
ret.appendString(`const ${id} = ${target};\n`);
|
|
48
|
+
ret.appendString(`abap.statements.moveCorresponding(${source.getCode()}, ${id});\n`);
|
|
49
|
+
for (const map of mapping) {
|
|
50
|
+
const componentName = map.componentName.concatTokens().toLowerCase();
|
|
51
|
+
const chain = new component_chain_1.ComponentChainTranspiler().transpile(map.componentChain, traversal).getCode();
|
|
52
|
+
ret.appendString(`${id}.get().${componentName}.set(${source.getCode()}.get().${chain});\n`);
|
|
53
|
+
}
|
|
54
|
+
ret.appendString("return " + id + ";\n");
|
|
55
|
+
ret.appendString("})())");
|
|
31
56
|
return ret;
|
|
32
57
|
}
|
|
33
58
|
}
|
|
@@ -12,7 +12,7 @@ class FilterBodyTranspiler {
|
|
|
12
12
|
throw new Error("FilterBodyTranspiler, Expected TypeNameOrInfer");
|
|
13
13
|
}
|
|
14
14
|
else if (body.findDirectTokenByText("EXCEPT")) {
|
|
15
|
-
return new chunk_1.Chunk(`throw new Error("FilterBodyTranspiler EXCEPT in, not supported, transpiler")
|
|
15
|
+
return new chunk_1.Chunk(`(() => { throw new Error("FilterBodyTranspiler EXCEPT in, not supported, transpiler"); })()`);
|
|
16
16
|
}
|
|
17
17
|
const source = traversal.traverse(body.findDirectExpression(core_1.Expressions.Source)).getCode();
|
|
18
18
|
const type = new type_name_or_infer_1.TypeNameOrInfer().findType(typ, traversal);
|
package/build/src/validation.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.71",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"author": "abaplint",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@abaplint/core": "^2.113.
|
|
32
|
+
"@abaplint/core": "^2.113.195",
|
|
33
33
|
"source-map": "^0.7.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|