@abaplint/runtime 2.13.99 → 2.14.0
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/builtin/substring_after.js +1 -1
- package/build/src/builtin/substring_before.js +1 -1
- package/build/src/compare/instance_of.js +33 -1
- package/build/src/statements/assign.d.ts +1 -0
- package/build/src/statements/assign.js +3 -1
- package/build/src/statements/cast.js +8 -1
- package/build/src/types/field_symbol.d.ts +1 -0
- package/build/src/types/field_symbol.js +4 -0
- package/package.json +1 -1
|
@@ -39,7 +39,7 @@ function substring_after(input) {
|
|
|
39
39
|
else if (input?.sub) {
|
|
40
40
|
reg = abap_regex_1.ABAPRegExp.escapeRegExp(input.sub.get());
|
|
41
41
|
}
|
|
42
|
-
const r = new RegExp(reg + "(
|
|
42
|
+
const r = new RegExp(reg + "([\\s\\S]*)");
|
|
43
43
|
const res = val.match(r);
|
|
44
44
|
let ret = "";
|
|
45
45
|
if (res && res[1]) {
|
|
@@ -39,7 +39,7 @@ function substring_before(input) {
|
|
|
39
39
|
else if (input?.sub) {
|
|
40
40
|
reg = abap_regex_1.ABAPRegExp.escapeRegExp(input.sub.get());
|
|
41
41
|
}
|
|
42
|
-
const r = new RegExp("(
|
|
42
|
+
const r = new RegExp("([\\s\\S]*?)" + reg);
|
|
43
43
|
const res = val.match(r);
|
|
44
44
|
let ret = "";
|
|
45
45
|
if (res && res[1]) {
|
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.instance_of = instance_of;
|
|
4
4
|
function instance_of(val, cname) {
|
|
5
|
-
|
|
5
|
+
const obj = val.get();
|
|
6
|
+
if (obj === undefined) {
|
|
7
|
+
const name = val.getQualifiedName()?.toUpperCase();
|
|
8
|
+
if (name === undefined || name === "OBJECT") {
|
|
9
|
+
return cname === "OBJECT";
|
|
10
|
+
}
|
|
11
|
+
else if (cname === "OBJECT") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
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
|
+
// Local qualified names are short; RTTI carries the declaring program or class pool.
|
|
30
|
+
const scope = val.getRTTIName()?.toUpperCase().match(/^\\(PROGRAM|CLASS-POOL)=([^\\]+)/);
|
|
31
|
+
const prefix = scope ? (scope[1] === "PROGRAM" ? "PROG" : "CLAS") + "-" + scope[2] + "-" : "";
|
|
32
|
+
return matches(abap.Classes[prefix + name] || abap.Classes[name]);
|
|
33
|
+
}
|
|
34
|
+
else if (cname === "OBJECT") {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return obj instanceof cname;
|
|
6
38
|
}
|
|
7
39
|
//# sourceMappingURL=instance_of.js.map
|
|
@@ -4,7 +4,6 @@ exports.cast = cast;
|
|
|
4
4
|
const throw_error_1 = require("../throw_error");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
// todo, field symbols as input?
|
|
7
|
-
// todo, local classes?
|
|
8
7
|
// check with javascript instanceof?
|
|
9
8
|
// handling interfaces?
|
|
10
9
|
// todo: remove the "async"
|
|
@@ -34,6 +33,14 @@ async function cast(target, source) {
|
|
|
34
33
|
// todo, for unit testing,
|
|
35
34
|
targetClass = abap.Classes["PROG-ZFOOBAR-" + targetName];
|
|
36
35
|
}
|
|
36
|
+
if (targetClass === undefined && target instanceof types_1.ABAPObject) {
|
|
37
|
+
// local class, RTTI name "\CLASS-POOL=ZCL_FOO\CLASS=LCL_BAR" is registered as "CLAS-ZCL_FOO-LCL_BAR"
|
|
38
|
+
const match = /^\\(CLASS-POOL|PROGRAM)=([^\\]+)\\CLASS=(.+)$/.exec(target.getRTTIName()?.toUpperCase() || "");
|
|
39
|
+
if (match) {
|
|
40
|
+
const prefix = match[1] === "PROGRAM" ? "PROG" : "CLAS";
|
|
41
|
+
targetClass = abap.Classes[prefix + "-" + match[2] + "-" + match[3]];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
37
44
|
if (targetClass?.INTERNAL_TYPE === "CLAS") {
|
|
38
45
|
// using "instanceof" is probably wrong in some cases,
|
|
39
46
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FieldSymbol = void 0;
|
|
4
|
+
const abap_object_1 = require("./abap_object");
|
|
4
5
|
const table_1 = require("./table");
|
|
5
6
|
const string_1 = require("./string");
|
|
6
7
|
const hex_1 = require("./hex");
|
|
@@ -24,6 +25,9 @@ class FieldSymbol {
|
|
|
24
25
|
// @ts-ignore
|
|
25
26
|
return this.type.getQualifiedName();
|
|
26
27
|
}
|
|
28
|
+
getRTTIName() {
|
|
29
|
+
return this.type instanceof abap_object_1.ABAPObject ? this.type.getRTTIName() : undefined;
|
|
30
|
+
}
|
|
27
31
|
assign(pointer) {
|
|
28
32
|
this.pointer = pointer;
|
|
29
33
|
}
|