@abaplint/runtime 2.13.89 → 2.13.91
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.
|
@@ -26,6 +26,10 @@ function parse(val) {
|
|
|
26
26
|
else if (val instanceof types_1.Float) {
|
|
27
27
|
return val.getRaw();
|
|
28
28
|
}
|
|
29
|
+
else if (val instanceof types_1.Character) {
|
|
30
|
+
// constants remember what they parse to, the value cannot change
|
|
31
|
+
return val.getNumeric();
|
|
32
|
+
}
|
|
29
33
|
else if (val instanceof xstring_1.XString) {
|
|
30
34
|
if (val.get() === "") {
|
|
31
35
|
return 0;
|
|
@@ -8,6 +8,10 @@ import { Integer } from "./integer";
|
|
|
8
8
|
export declare class Character implements ICharacter {
|
|
9
9
|
private value;
|
|
10
10
|
private constant;
|
|
11
|
+
/** the value as a number, filled by getNumeric() only when this is a constant.
|
|
12
|
+
* set() cannot invalidate it because set() throws on a constant; clear() can,
|
|
13
|
+
* and does, because it is not covered by that check. */
|
|
14
|
+
private numeric;
|
|
11
15
|
private readonly length;
|
|
12
16
|
private readonly extra;
|
|
13
17
|
constructor(length?: number, extra?: AbstractTypeData);
|
|
@@ -19,6 +23,11 @@ export declare class Character implements ICharacter {
|
|
|
19
23
|
getDDICName(): string | undefined;
|
|
20
24
|
getLength(): number;
|
|
21
25
|
clear(): void;
|
|
26
|
+
/** The value as a number. A constant cannot change, so it is parsed once and
|
|
27
|
+
* remembered: a character literal is how ABAP writes a non integer constant,
|
|
28
|
+
* ie. "lv_x = lv_y * '0.5'", and every arithmetic operation on one used to
|
|
29
|
+
* trim the string and parse it again. */
|
|
30
|
+
getNumeric(): number;
|
|
22
31
|
get(): string;
|
|
23
32
|
getTrimEnd(): string;
|
|
24
33
|
getOffset(input: {
|
|
@@ -11,6 +11,10 @@ const initialValues = {};
|
|
|
11
11
|
class Character {
|
|
12
12
|
value;
|
|
13
13
|
constant = false;
|
|
14
|
+
/** the value as a number, filled by getNumeric() only when this is a constant.
|
|
15
|
+
* set() cannot invalidate it because set() throws on a constant; clear() can,
|
|
16
|
+
* and does, because it is not covered by that check. */
|
|
17
|
+
numeric = undefined;
|
|
14
18
|
length;
|
|
15
19
|
extra;
|
|
16
20
|
constructor(length, extra) {
|
|
@@ -87,6 +91,21 @@ class Character {
|
|
|
87
91
|
initialValues[this.length] = " ".repeat(this.length);
|
|
88
92
|
}
|
|
89
93
|
this.value = initialValues[this.length];
|
|
94
|
+
this.numeric = undefined;
|
|
95
|
+
}
|
|
96
|
+
/** The value as a number. A constant cannot change, so it is parsed once and
|
|
97
|
+
* remembered: a character literal is how ABAP writes a non integer constant,
|
|
98
|
+
* ie. "lv_x = lv_y * '0.5'", and every arithmetic operation on one used to
|
|
99
|
+
* trim the string and parse it again. */
|
|
100
|
+
getNumeric() {
|
|
101
|
+
let numeric = this.numeric;
|
|
102
|
+
if (numeric === undefined) {
|
|
103
|
+
numeric = (0, _parse_1.parse)(this.value);
|
|
104
|
+
if (this.constant === true) {
|
|
105
|
+
this.numeric = numeric;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return numeric;
|
|
90
109
|
}
|
|
91
110
|
get() {
|
|
92
111
|
return this.value;
|