@abaplint/runtime 2.14.0 → 2.14.2
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/compare/instance_of.js +23 -17
- package/build/src/types/date.js +4 -0
- package/build/src/types/decfloat34.js +5 -0
- package/build/src/types/float.js +5 -0
- package/build/src/types/integer.js +5 -0
- package/build/src/types/integer8.js +5 -0
- package/build/src/types/packed.js +5 -0
- package/package.json +1 -1
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.instance_of = instance_of;
|
|
4
|
+
/** true when the class or interface is the target or a subtype of it:
|
|
5
|
+
* superclasses, implemented interfaces and interfaces they include */
|
|
6
|
+
function isSubtype(start, cname) {
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
const matches = (source) => {
|
|
9
|
+
if (source == null || seen.has(source)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
else if (source === cname) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
seen.add(source);
|
|
16
|
+
const internalName = source.INTERNAL_NAME || "";
|
|
17
|
+
const prefix = internalName.substring(0, internalName.lastIndexOf("-") + 1);
|
|
18
|
+
const interfaces = source.IMPLEMENTED_INTERFACES || [];
|
|
19
|
+
return interfaces.some(i => matches(abap.Classes[prefix + i] || abap.Classes[i]))
|
|
20
|
+
|| matches(Object.getPrototypeOf(source));
|
|
21
|
+
};
|
|
22
|
+
return matches(start);
|
|
23
|
+
}
|
|
4
24
|
function instance_of(val, cname) {
|
|
5
25
|
const obj = val.get();
|
|
6
26
|
if (obj === undefined) {
|
|
@@ -11,29 +31,15 @@ function instance_of(val, cname) {
|
|
|
11
31
|
else if (cname === "OBJECT") {
|
|
12
32
|
return true;
|
|
13
33
|
}
|
|
14
|
-
const seen = new Set();
|
|
15
|
-
const matches = (source) => {
|
|
16
|
-
if (source == null || seen.has(source)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
else if (source === cname) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
seen.add(source);
|
|
23
|
-
const internalName = source.INTERNAL_NAME || "";
|
|
24
|
-
const prefix = internalName.substring(0, internalName.lastIndexOf("-") + 1);
|
|
25
|
-
const interfaces = source.IMPLEMENTED_INTERFACES || [];
|
|
26
|
-
return interfaces.some(i => matches(abap.Classes[prefix + i] || abap.Classes[i]))
|
|
27
|
-
|| matches(Object.getPrototypeOf(source));
|
|
28
|
-
};
|
|
29
34
|
// Local qualified names are short; RTTI carries the declaring program or class pool.
|
|
30
35
|
const scope = val.getRTTIName()?.toUpperCase().match(/^\\(PROGRAM|CLASS-POOL)=([^\\]+)/);
|
|
31
36
|
const prefix = scope ? (scope[1] === "PROGRAM" ? "PROG" : "CLAS") + "-" + scope[2] + "-" : "";
|
|
32
|
-
return
|
|
37
|
+
return isSubtype(abap.Classes[prefix + name] || abap.Classes[name], cname);
|
|
33
38
|
}
|
|
34
39
|
else if (cname === "OBJECT") {
|
|
35
40
|
return true;
|
|
36
41
|
}
|
|
37
|
-
|
|
42
|
+
// an interface is not on the prototype chain of the classes implementing it
|
|
43
|
+
return obj instanceof cname || isSubtype(obj.constructor, cname);
|
|
38
44
|
}
|
|
39
45
|
//# sourceMappingURL=instance_of.js.map
|
package/build/src/types/date.js
CHANGED
|
@@ -59,6 +59,10 @@ class Date {
|
|
|
59
59
|
return this.value;
|
|
60
60
|
}
|
|
61
61
|
getNumeric() {
|
|
62
|
+
// the initial date and content that is not a date, eg. blanks, convert to 0
|
|
63
|
+
if (this.value === "00000000" || /^\d{8}$/.test(this.value) === false) {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
62
66
|
return (0, _date_helper_1.getNumberFromDate)(this.value);
|
|
63
67
|
}
|
|
64
68
|
getOffset(input) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DecFloat34 = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
|
+
const date_1 = require("./date");
|
|
5
6
|
const hex_1 = require("./hex");
|
|
6
7
|
const xstring_1 = require("./xstring");
|
|
7
8
|
class DecFloat34 {
|
|
@@ -30,6 +31,10 @@ class DecFloat34 {
|
|
|
30
31
|
else if (value instanceof DecFloat34) {
|
|
31
32
|
this.value = value.getRaw();
|
|
32
33
|
}
|
|
34
|
+
else if (value instanceof date_1.Date) {
|
|
35
|
+
// d is converted to the number of days since 01.01.0001, not the YYYYMMDD digits
|
|
36
|
+
this.value = value.getNumeric();
|
|
37
|
+
}
|
|
33
38
|
else if (value instanceof _1.Float) {
|
|
34
39
|
this.value = value.getRaw();
|
|
35
40
|
}
|
package/build/src/types/float.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Float = void 0;
|
|
4
4
|
const throw_error_1 = require("../throw_error");
|
|
5
|
+
const date_1 = require("./date");
|
|
5
6
|
const hex_1 = require("./hex");
|
|
6
7
|
const xstring_1 = require("./xstring");
|
|
7
8
|
const integer8_1 = require("./integer8");
|
|
@@ -77,6 +78,10 @@ class Float {
|
|
|
77
78
|
else if (value instanceof integer8_1.Integer8) {
|
|
78
79
|
this.value = Number(value.get());
|
|
79
80
|
}
|
|
81
|
+
else if (value instanceof date_1.Date) {
|
|
82
|
+
// d is converted to the number of days since 01.01.0001, not the YYYYMMDD digits
|
|
83
|
+
this.value = value.getNumeric();
|
|
84
|
+
}
|
|
80
85
|
else if (value instanceof Float || value instanceof decfloat34_1.DecFloat34) {
|
|
81
86
|
this.value = value.getRaw();
|
|
82
87
|
}
|
|
@@ -4,6 +4,7 @@ exports.Integer = exports.MIN_INTEGER = exports.MAX_INTEGER = exports.DIGITS = v
|
|
|
4
4
|
exports.toInteger = toInteger;
|
|
5
5
|
exports.roundHalfAwayFromZero = roundHalfAwayFromZero;
|
|
6
6
|
const throw_error_1 = require("../throw_error");
|
|
7
|
+
const date_1 = require("./date");
|
|
7
8
|
const float_1 = require("./float");
|
|
8
9
|
const hex_1 = require("./hex");
|
|
9
10
|
const xstring_1 = require("./xstring");
|
|
@@ -92,6 +93,10 @@ class Integer {
|
|
|
92
93
|
else if (value instanceof float_1.Float || value instanceof decfloat34_1.DecFloat34) {
|
|
93
94
|
this.set(roundHalfAwayFromZero(value.getRaw()));
|
|
94
95
|
}
|
|
96
|
+
else if (value instanceof date_1.Date) {
|
|
97
|
+
// d is converted to the number of days since 01.01.0001, not the YYYYMMDD digits
|
|
98
|
+
this.value = value.getNumeric();
|
|
99
|
+
}
|
|
95
100
|
else if (value instanceof hex_1.Hex || value instanceof xstring_1.XString || value instanceof hex_uint8_1.HexUInt8) {
|
|
96
101
|
// the last four bytes, 00 on the left, as a signed integer; an empty xstring is 0
|
|
97
102
|
const hex = value.get().slice(-8);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Integer8 = void 0;
|
|
4
4
|
const throw_error_1 = require("../throw_error");
|
|
5
|
+
const date_1 = require("./date");
|
|
5
6
|
const float_1 = require("./float");
|
|
6
7
|
const hex_1 = require("./hex");
|
|
7
8
|
const xstring_1 = require("./xstring");
|
|
@@ -46,6 +47,10 @@ class Integer8 {
|
|
|
46
47
|
}
|
|
47
48
|
this.value = BigInt(value);
|
|
48
49
|
}
|
|
50
|
+
else if (value instanceof date_1.Date) {
|
|
51
|
+
// d is converted to the number of days since 01.01.0001, not the YYYYMMDD digits
|
|
52
|
+
this.value = BigInt(value.getNumeric());
|
|
53
|
+
}
|
|
49
54
|
else if (value instanceof float_1.Float || value instanceof decfloat34_1.DecFloat34) {
|
|
50
55
|
this.set((0, integer_1.roundHalfAwayFromZero)(value.getRaw()));
|
|
51
56
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Packed = void 0;
|
|
4
4
|
const float_1 = require("./float");
|
|
5
|
+
const date_1 = require("./date");
|
|
5
6
|
const throw_error_1 = require("../throw_error");
|
|
6
7
|
const integer8_1 = require("./integer8");
|
|
7
8
|
const decfloat34_1 = require("./decfloat34");
|
|
@@ -111,6 +112,10 @@ class Packed {
|
|
|
111
112
|
else if (value instanceof integer8_1.Integer8) {
|
|
112
113
|
this.value = value.get() * pow10(this.decimals);
|
|
113
114
|
}
|
|
115
|
+
else if (value instanceof date_1.Date) {
|
|
116
|
+
// d is converted to the number of days since 01.01.0001, not the YYYYMMDD digits
|
|
117
|
+
this.value = BigInt(value.getNumeric()) * pow10(this.decimals);
|
|
118
|
+
}
|
|
114
119
|
else if (value instanceof float_1.Float || value instanceof decfloat34_1.DecFloat34) {
|
|
115
120
|
this.value = this.numberToScaled(value.getRaw());
|
|
116
121
|
}
|