@abaplint/transpiler 2.1.34 → 2.1.37
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.
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssignTranspiler = void 0;
|
|
4
|
+
/* eslint-disable max-len */
|
|
4
5
|
const abaplint = require("@abaplint/core");
|
|
5
6
|
const expressions_1 = require("../expressions");
|
|
6
7
|
const chunk_1 = require("../chunk");
|
|
7
8
|
class AssignTranspiler {
|
|
8
9
|
transpile(node, traversal) {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
const
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
|
|
12
|
+
const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressions(abaplint.Expressions.Source).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode())) || [];
|
|
11
13
|
const fs = new expressions_1.FieldSymbolTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.FSTarget), traversal).getCode();
|
|
12
14
|
const options = [];
|
|
13
15
|
const concat = node.concatTokens().toUpperCase();
|
|
@@ -19,17 +21,42 @@ class AssignTranspiler {
|
|
|
19
21
|
options.push("source: " + sources.pop());
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
22
|
-
let
|
|
24
|
+
let dynamicName = "";
|
|
25
|
+
for (const c of (assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren()) || []) {
|
|
26
|
+
if (c instanceof abaplint.Nodes.ExpressionNode
|
|
27
|
+
&& c.get() instanceof abaplint.Expressions.Dynamic
|
|
28
|
+
&& c.findFirstExpression(abaplint.Expressions.ConstantString)) {
|
|
29
|
+
if (dynamicName !== "") {
|
|
30
|
+
dynamicName += " + ";
|
|
31
|
+
}
|
|
32
|
+
dynamicName += (_a = c.findFirstExpression(abaplint.Expressions.ConstantString)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
|
|
33
|
+
}
|
|
34
|
+
else if (c instanceof abaplint.Nodes.ExpressionNode
|
|
35
|
+
&& c.get() instanceof abaplint.Expressions.Dynamic
|
|
36
|
+
&& c.findDirectExpression(abaplint.Expressions.FieldChain)) {
|
|
37
|
+
if (dynamicName !== "") {
|
|
38
|
+
dynamicName += " + ";
|
|
39
|
+
}
|
|
40
|
+
dynamicName += new expressions_1.FieldChainTranspiler(true).transpile(c.findDirectExpression(abaplint.Expressions.FieldChain), traversal).getCode();
|
|
41
|
+
}
|
|
42
|
+
else if (c.concatTokens() === "(" || c.concatTokens() === ")") {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
else if (c.concatTokens() === "=>" || c.concatTokens() === "->") {
|
|
46
|
+
dynamicName += " + '" + c.concatTokens() + "'";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
options.push(`dynamicName: ` + dynamicName);
|
|
50
|
+
// dynamicSource is the first part only
|
|
51
|
+
let dynamic = (_b = assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _b === void 0 ? void 0 : _b.findFirstExpression(abaplint.Expressions.ConstantString);
|
|
23
52
|
if (dynamic) {
|
|
24
|
-
options.push(`dynamicText: ` + dynamic.getFirstToken().getStr());
|
|
25
53
|
const s = dynamic.getFirstToken().getStr().toLowerCase().match(/\w+/);
|
|
26
54
|
options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
|
|
27
55
|
}
|
|
28
56
|
else {
|
|
29
|
-
dynamic = (
|
|
57
|
+
dynamic = (_c = assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _c === void 0 ? void 0 : _c.findFirstExpression(abaplint.Expressions.FieldChain);
|
|
30
58
|
if (dynamic) {
|
|
31
59
|
const code = new expressions_1.FieldChainTranspiler(true).transpile(dynamic, traversal).getCode();
|
|
32
|
-
options.push(`dynamicText: ` + code);
|
|
33
60
|
options.push(`dynamicSource: (() => {try { return eval(${code}.toLowerCase().match(/\\w+/)[0]); } catch {}})()`);
|
|
34
61
|
}
|
|
35
62
|
}
|
|
@@ -8,7 +8,7 @@ class TranspileTypes {
|
|
|
8
8
|
return "let " + t.getName().toLowerCase() + " = " + this.toType(type) + ";";
|
|
9
9
|
}
|
|
10
10
|
toType(type) {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
12
12
|
let resolved = "";
|
|
13
13
|
let extra = "";
|
|
14
14
|
if (type instanceof abaplint.BasicTypes.ObjectReferenceType
|
|
@@ -96,9 +96,15 @@ class TranspileTypes {
|
|
|
96
96
|
}
|
|
97
97
|
else if (type instanceof abaplint.BasicTypes.NumericType) {
|
|
98
98
|
resolved = "Numc";
|
|
99
|
-
if (type.getLength() !== 1) {
|
|
99
|
+
if (type.getQualifiedName() && type.getLength() !== 1) {
|
|
100
|
+
extra = "{length: " + type.getLength() + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
|
|
101
|
+
}
|
|
102
|
+
else if (type.getLength() !== 1) {
|
|
100
103
|
extra = "{length: " + type.getLength() + "}";
|
|
101
104
|
}
|
|
105
|
+
else if (type.getQualifiedName()) {
|
|
106
|
+
extra = "{qualifiedName: \"" + type.getQualifiedName() + "\"}";
|
|
107
|
+
}
|
|
102
108
|
}
|
|
103
109
|
else if (type instanceof abaplint.BasicTypes.PackedType) {
|
|
104
110
|
resolved = "Packed";
|
|
@@ -131,9 +137,15 @@ class TranspileTypes {
|
|
|
131
137
|
}
|
|
132
138
|
else if (type instanceof abaplint.BasicTypes.FloatType) {
|
|
133
139
|
resolved = "Float";
|
|
140
|
+
if (type.getQualifiedName() !== undefined) {
|
|
141
|
+
extra = "{qualifiedName: \"" + ((_h = type.getQualifiedName()) === null || _h === void 0 ? void 0 : _h.toUpperCase()) + "\"}";
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
144
|
else if (type instanceof abaplint.BasicTypes.FloatingPointType) {
|
|
136
145
|
resolved = "Float";
|
|
146
|
+
if (type.getQualifiedName() !== undefined) {
|
|
147
|
+
extra = "{qualifiedName: \"" + ((_j = type.getQualifiedName()) === null || _j === void 0 ? void 0 : _j.toUpperCase()) + "\"}";
|
|
148
|
+
}
|
|
137
149
|
}
|
|
138
150
|
else if (type instanceof abaplint.BasicTypes.DecFloat34Type) {
|
|
139
151
|
resolved = "DecFloat34";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.37",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"author": "abaplint",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@abaplint/core": "^2.91.
|
|
31
|
+
"@abaplint/core": "^2.91.31",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|