@abaplint/runtime 2.1.17 → 2.1.18
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/statements/cast.js +26 -20
- package/package.json +1 -1
|
@@ -4,33 +4,39 @@ exports.cast = void 0;
|
|
|
4
4
|
const compare_1 = require("../compare");
|
|
5
5
|
// todo, field symbols as input?
|
|
6
6
|
// todo, local classes?
|
|
7
|
+
// check with javascript instanceof?
|
|
8
|
+
// handling interfaces?
|
|
7
9
|
async function cast(target, source) {
|
|
10
|
+
var _a;
|
|
8
11
|
if ((0, compare_1.initial)(source)) {
|
|
9
12
|
target.clear();
|
|
10
13
|
return;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
// eslint-disable-next-line prefer-const
|
|
16
|
+
let castEnabled = true;
|
|
17
|
+
if (castEnabled === true) {
|
|
18
|
+
const targetName = (_a = target.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
19
|
+
if ((targetName === null || targetName === void 0 ? void 0 : targetName.startsWith("IF_")) === false
|
|
20
|
+
&& (targetName === null || targetName === void 0 ? void 0 : targetName.startsWith("ZIF_")) === false) { // todo, interfaces are also classes but not inherited
|
|
21
|
+
// using "instanceof" is probably wrong in some cases,
|
|
22
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
if (abap.Classes[targetName] && source.get() instanceof abap.Classes[targetName] === false) {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
throw new abap.Classes["CX_SY_MOVE_CAST_ERROR"]();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw "Global class CX_SY_MOVE_CAST_ERROR not found";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
|
-
|
|
35
|
+
target.set(source);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
target.set(source);
|
|
28
39
|
}
|
|
29
|
-
*/
|
|
30
|
-
// throw cx_sy_move_cast_error if incompatible
|
|
31
|
-
// check with javascript instanceof?
|
|
32
|
-
// handling interfaces?
|
|
33
|
-
target.set(source);
|
|
34
40
|
}
|
|
35
41
|
exports.cast = cast;
|
|
36
42
|
//# sourceMappingURL=cast.js.map
|