@abaplint/transpiler 2.13.13 → 2.13.15
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.
|
@@ -15,8 +15,8 @@ class CorrespondingBodyTranspiler {
|
|
|
15
15
|
const type = new type_name_or_infer_1.TypeNameOrInfer().findType(typ, traversal);
|
|
16
16
|
let target = transpile_types_1.TranspileTypes.toType(type);
|
|
17
17
|
let source;
|
|
18
|
+
const isTableType = type instanceof core_1.BasicTypes.TableType;
|
|
18
19
|
const mapping = [];
|
|
19
|
-
const mappingRow = { componentName: undefined, componentChain: undefined };
|
|
20
20
|
for (const child of body.getChildren()) {
|
|
21
21
|
const c = child.get();
|
|
22
22
|
if (c instanceof core_1.Expressions.Source && child instanceof core_1.Nodes.ExpressionNode) {
|
|
@@ -27,6 +27,7 @@ class CorrespondingBodyTranspiler {
|
|
|
27
27
|
target = `abap.statements.moveCorresponding(${source.getCode()}, ${target})`;
|
|
28
28
|
}
|
|
29
29
|
else if (c instanceof core_1.Expressions.CorrespondingBodyMapping && child instanceof core_1.Nodes.ExpressionNode) {
|
|
30
|
+
let mappingRow = { componentName: undefined, componentChain: undefined };
|
|
30
31
|
for (const cc of child.getChildren()) {
|
|
31
32
|
if (cc.get() instanceof core_1.Expressions.ComponentName) {
|
|
32
33
|
mappingRow.componentName = cc;
|
|
@@ -34,6 +35,7 @@ class CorrespondingBodyTranspiler {
|
|
|
34
35
|
else if (cc.get() instanceof core_1.Expressions.ComponentChain) {
|
|
35
36
|
mappingRow.componentChain = cc;
|
|
36
37
|
mapping.push(mappingRow);
|
|
38
|
+
mappingRow = { componentName: undefined, componentChain: undefined };
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -43,13 +45,32 @@ class CorrespondingBodyTranspiler {
|
|
|
43
45
|
}
|
|
44
46
|
const ret = new chunk_1.Chunk();
|
|
45
47
|
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
48
|
+
const sourceId = unique_identifier_1.UniqueIdentifier.get();
|
|
46
49
|
ret.appendString("(await (async () => {\n");
|
|
47
50
|
ret.appendString(`const ${id} = ${target};\n`);
|
|
48
|
-
ret.appendString(`
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
ret.appendString(`const ${sourceId} = ${source.getCode()};\n`);
|
|
52
|
+
if (isTableType) {
|
|
53
|
+
const rowTargetType = transpile_types_1.TranspileTypes.toType(type.getRowType());
|
|
54
|
+
const sourceRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
55
|
+
const targetRowId = unique_identifier_1.UniqueIdentifier.get();
|
|
56
|
+
ret.appendString(`for (const ${sourceRowId} of ${sourceId}.array()) {\n`);
|
|
57
|
+
ret.appendString(`const ${targetRowId} = ${rowTargetType};\n`);
|
|
58
|
+
ret.appendString(`abap.statements.moveCorresponding(${sourceRowId}, ${targetRowId});\n`);
|
|
59
|
+
for (const map of mapping) {
|
|
60
|
+
const componentName = map.componentName.concatTokens().toLowerCase();
|
|
61
|
+
const chain = new component_chain_1.ComponentChainTranspiler().transpile(map.componentChain, traversal).getCode();
|
|
62
|
+
ret.appendString(`${targetRowId}.get().${componentName}.set(${sourceRowId}.get().${chain});\n`);
|
|
63
|
+
}
|
|
64
|
+
ret.appendString(`abap.statements.insertInternal({table: ${id}, data: ${targetRowId}});\n`);
|
|
65
|
+
ret.appendString("}\n");
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
ret.appendString(`abap.statements.moveCorresponding(${sourceId}, ${id});\n`);
|
|
69
|
+
for (const map of mapping) {
|
|
70
|
+
const componentName = map.componentName.concatTokens().toLowerCase();
|
|
71
|
+
const chain = new component_chain_1.ComponentChainTranspiler().transpile(map.componentChain, traversal).getCode();
|
|
72
|
+
ret.appendString(`${id}.get().${componentName}.set(${sourceId}.get().${chain});\n`);
|
|
73
|
+
}
|
|
53
74
|
}
|
|
54
75
|
ret.appendString("return " + id + ";\n");
|
|
55
76
|
ret.appendString("})())");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.15",
|
|
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.119.
|
|
32
|
+
"@abaplint/core": "^2.119.1",
|
|
33
33
|
"source-map": "^0.7.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|