@abaplint/runtime 2.10.79 → 2.10.80
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.
- package/build/src/expand_dynamic.js +44 -27
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.expandDynamic = expandDynamic;
|
|
|
4
4
|
const expand_in_1 = require("./expand_in");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
function expandDynamic(code, ev) {
|
|
7
|
+
// console.dir(code);
|
|
7
8
|
if (code === "") {
|
|
8
9
|
return "1 = 1";
|
|
9
10
|
}
|
|
@@ -12,45 +13,61 @@ function expandDynamic(code, ev) {
|
|
|
12
13
|
code = code.replace(/ EQ /g, " = ");
|
|
13
14
|
// todo more here, this is just one simple case,
|
|
14
15
|
let regex = /(\w+) IN <(\w+)>-(\w+)/;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
found
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
while (true) {
|
|
17
|
+
const match = code.match(regex);
|
|
18
|
+
if (match && match[1] && match[2] && match[3]) {
|
|
19
|
+
let name = "fs_" + match[2] + "_";
|
|
20
|
+
name = name.toLowerCase();
|
|
21
|
+
let found = ev(name);
|
|
22
|
+
if (found instanceof types_1.FieldSymbol) {
|
|
23
|
+
found = found.get()[match[3].toLowerCase()];
|
|
24
|
+
if (found === undefined) {
|
|
25
|
+
throw new Error(`expandDynamic: Field symbol ${name} does not have field ${match[2]}`);
|
|
26
|
+
}
|
|
27
|
+
code = code.replace(regex, (0, expand_in_1.expandIN)(match[1].toLowerCase(), found));
|
|
24
28
|
}
|
|
25
|
-
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
break;
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
// todo more here, this is just one simple case,
|
|
29
35
|
regex = / <(\w+)>-(\w+)/;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
found
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
while (true) {
|
|
37
|
+
const match = code.match(regex);
|
|
38
|
+
if (match && match[1] && match[2]) {
|
|
39
|
+
let name = "fs_" + match[1] + "_";
|
|
40
|
+
name = name.toLowerCase();
|
|
41
|
+
let found = ev(name);
|
|
42
|
+
if (found instanceof types_1.FieldSymbol) {
|
|
43
|
+
found = found.get()[match[2].toLowerCase()];
|
|
44
|
+
if (found === undefined) {
|
|
45
|
+
throw new Error(`expandDynamic: Field symbol ${name} does not have field ${match[2]}`);
|
|
46
|
+
}
|
|
47
|
+
code = code.replace(regex, " '" + found.get() + "'");
|
|
39
48
|
}
|
|
40
|
-
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
break;
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
// todo more here, this is just one simple case,
|
|
44
55
|
regex = / <(\w+)>/;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
while (true) {
|
|
57
|
+
const match = code.match(regex);
|
|
58
|
+
if (match && match[1]) {
|
|
59
|
+
let name = "fs_" + match[1] + "_";
|
|
60
|
+
name = name.toLowerCase();
|
|
61
|
+
const found = ev(name);
|
|
62
|
+
if (found instanceof types_1.FieldSymbol) {
|
|
63
|
+
code = code.replace(regex, " '" + found.get() + "'");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
break;
|
|
52
68
|
}
|
|
53
69
|
}
|
|
70
|
+
// console.dir(code);
|
|
54
71
|
return code;
|
|
55
72
|
}
|
|
56
73
|
}
|