@abaplint/runtime 2.13.22 → 2.13.23
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.
|
@@ -4,6 +4,9 @@ exports.add = add;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const string_1 = require("../types/string");
|
|
6
6
|
const _parse_1 = require("./_parse");
|
|
7
|
+
function isIntegerCharacter(value) {
|
|
8
|
+
return value.get().trim().length > 0 && Number.isInteger(Number(value.get()));
|
|
9
|
+
}
|
|
7
10
|
function add(left, right) {
|
|
8
11
|
if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
|
|
9
12
|
return new types_1.Integer().set(left.get() + right.get());
|
|
@@ -18,12 +21,18 @@ function add(left, right) {
|
|
|
18
21
|
else if (typeof right === "number" && Number.isInteger(right) && left instanceof types_1.Integer) {
|
|
19
22
|
return new types_1.Integer().set(left.get() + right);
|
|
20
23
|
}
|
|
21
|
-
else if ((left instanceof string_1.String || left instanceof types_1.Character) &&
|
|
24
|
+
else if ((left instanceof string_1.String || left instanceof types_1.Character) && isIntegerCharacter(left) && right instanceof types_1.Integer) {
|
|
22
25
|
return new types_1.Integer().set(Number.parseInt(left.get(), 10) + right.get());
|
|
23
26
|
}
|
|
24
|
-
else if ((right instanceof string_1.String || right instanceof types_1.Character) &&
|
|
27
|
+
else if ((right instanceof string_1.String || right instanceof types_1.Character) && isIntegerCharacter(right) && left instanceof types_1.Integer) {
|
|
25
28
|
return new types_1.Integer().set(left.get() + Number.parseInt(right.get(), 10));
|
|
26
29
|
}
|
|
30
|
+
else if ((left instanceof string_1.String || left instanceof types_1.Character)
|
|
31
|
+
&& (right instanceof string_1.String || right instanceof types_1.Character)
|
|
32
|
+
&& isIntegerCharacter(left)
|
|
33
|
+
&& isIntegerCharacter(right)) {
|
|
34
|
+
return new types_1.Integer().set(Number.parseInt(left.get(), 10) + Number.parseInt(right.get(), 10));
|
|
35
|
+
}
|
|
27
36
|
else if (left instanceof types_1.Integer8) {
|
|
28
37
|
if (right instanceof types_1.Integer8) {
|
|
29
38
|
return new types_1.Integer8().set(left.get() + right.get());
|
|
@@ -86,6 +86,9 @@ class Structure {
|
|
|
86
86
|
throw new Error("Structure, input is a table");
|
|
87
87
|
}
|
|
88
88
|
else if (input instanceof Structure) {
|
|
89
|
+
if (input === this) {
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
89
92
|
const obj = input.get();
|
|
90
93
|
const keys1 = Object.keys(obj);
|
|
91
94
|
const keys2 = Object.keys(this.value);
|