@abaplint/runtime 2.0.2 → 2.0.3
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/insert.js +3 -2
- package/build/src/builtin/replace.js +8 -1
- package/build/src/builtin/substring.js +7 -2
- package/build/src/compare/initial.js +1 -0
- package/build/src/operators/_parse.d.ts +2 -1
- package/build/src/operators/add.d.ts +2 -2
- package/build/src/operators/minus.d.ts +1 -1
- package/build/src/statements/shift.js +10 -6
- package/build/src/types/_character.d.ts +4 -0
- package/build/src/types/character.js +19 -1
- package/build/src/types/hex.d.ts +3 -1
- package/build/src/types/integer.d.ts +2 -1
- package/build/src/types/numc.d.ts +4 -0
- package/build/src/types/numc.js +3 -0
- package/build/src/types/string.js +10 -0
- package/package.json +1 -1
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.insert = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function insert(input) {
|
|
6
|
-
let value = input.val.get();
|
|
7
6
|
let offset = 0;
|
|
8
7
|
if (input.off) {
|
|
9
8
|
offset = input.off.get();
|
|
10
9
|
}
|
|
11
|
-
value =
|
|
10
|
+
const value = input.val.getOffset({ offset: 0, length: offset }).get() +
|
|
11
|
+
input.sub.get() +
|
|
12
|
+
input.val.getOffset({ offset: offset }).get();
|
|
12
13
|
return new types_1.String().set(value);
|
|
13
14
|
}
|
|
14
15
|
exports.insert = insert;
|
|
@@ -34,11 +34,18 @@ function replace(input) {
|
|
|
34
34
|
else if (input.regex) {
|
|
35
35
|
sub = input.regex.get();
|
|
36
36
|
}
|
|
37
|
-
if (input.off && input.len) {
|
|
37
|
+
if (input.off && input.len && typeof input.val === "string") {
|
|
38
38
|
const offset = input.off.get();
|
|
39
39
|
const length = input.len.get();
|
|
40
40
|
val = val.substring(0, offset) + wi + val.substring(offset + length);
|
|
41
41
|
}
|
|
42
|
+
else if (input.off && input.len && !(typeof input.val === "string")) {
|
|
43
|
+
const offset = input.off.get();
|
|
44
|
+
const length = input.len.get();
|
|
45
|
+
val = input.val.getOffset({ offset: 0, length: offset }).get() +
|
|
46
|
+
wi +
|
|
47
|
+
input.val.getOffset({ offset: offset + length }).get();
|
|
48
|
+
}
|
|
42
49
|
else if (input.occ === undefined && sub && wi) {
|
|
43
50
|
val = val.replace(sub, wi);
|
|
44
51
|
}
|
|
@@ -4,13 +4,18 @@ exports.substring = void 0;
|
|
|
4
4
|
const string_1 = require("../types/string");
|
|
5
5
|
function substring(input) {
|
|
6
6
|
var _a, _b;
|
|
7
|
-
const val = typeof input.val === "string" ? input.val : input.val.get();
|
|
8
7
|
let off = (_a = input === null || input === void 0 ? void 0 : input.off) === null || _a === void 0 ? void 0 : _a.get();
|
|
9
8
|
if (off === undefined) {
|
|
10
9
|
off = 0;
|
|
11
10
|
}
|
|
12
11
|
const len = (_b = input === null || input === void 0 ? void 0 : input.len) === null || _b === void 0 ? void 0 : _b.get();
|
|
13
|
-
|
|
12
|
+
let sub = "";
|
|
13
|
+
if (typeof input.val === "string") {
|
|
14
|
+
sub = input.val.substr(off, len);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
sub = input.val.getOffset({ offset: off, length: len }).get();
|
|
18
|
+
}
|
|
14
19
|
return new string_1.String().set(sub);
|
|
15
20
|
}
|
|
16
21
|
exports.substring = substring;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initial = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function initial(val) {
|
|
6
|
+
// todo, refactor? add as method in each type instead?
|
|
6
7
|
if (val instanceof types_1.Table) {
|
|
7
8
|
return val.array().length === 0;
|
|
8
9
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Float, Integer } from "../types";
|
|
1
2
|
import { ICharacter } from "../types/_character";
|
|
2
3
|
import { INumeric } from "../types/_numeric";
|
|
3
|
-
export declare function parse(val: INumeric | ICharacter | string | number): number;
|
|
4
|
+
export declare function parse(val: INumeric | ICharacter | string | number | Float | Integer): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Float, Integer } from "../types";
|
|
1
|
+
import { Float, Hex, Integer } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function add(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float | Integer;
|
|
4
|
+
export declare function add(left: INumeric | ICharacter | string | number | Float | Integer | Hex, right: INumeric | ICharacter | string | number | Float | Integer | Hex): Float | Integer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Float, Integer } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function minus(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float | Integer;
|
|
4
|
+
export declare function minus(left: INumeric | ICharacter | string | number | Integer | Float, right: INumeric | ICharacter | string | number | Integer | Float): Float | Integer;
|
|
@@ -47,13 +47,11 @@ function shift_character_mode(target, options) {
|
|
|
47
47
|
value = value.substr(index);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
else if (options === null || options === void 0 ? void 0 : options.circular) {
|
|
51
|
+
value = value.substr(1) + value.substr(0, 1);
|
|
52
|
+
}
|
|
50
53
|
else {
|
|
51
|
-
|
|
52
|
-
value = value.substr(1) + value.substr(0, 1);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
value = value.substr(1);
|
|
56
|
-
}
|
|
54
|
+
value = value.substr(1);
|
|
57
55
|
}
|
|
58
56
|
target.set(value);
|
|
59
57
|
}
|
|
@@ -91,6 +89,12 @@ function shift_byte_mode(target, options) {
|
|
|
91
89
|
value = value.substr(index);
|
|
92
90
|
}
|
|
93
91
|
}
|
|
92
|
+
else if (options === null || options === void 0 ? void 0 : options.circular) {
|
|
93
|
+
value = value.substr(2) + value.substr(0, 2);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
value = value.substr(2);
|
|
97
|
+
}
|
|
94
98
|
target.set(value);
|
|
95
99
|
}
|
|
96
100
|
//# sourceMappingURL=shift.js.map
|
|
@@ -3,9 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Character = void 0;
|
|
4
4
|
class Character {
|
|
5
5
|
constructor(input) {
|
|
6
|
-
this.value = "";
|
|
7
6
|
this.length = (input === null || input === void 0 ? void 0 : input.length) ? input === null || input === void 0 ? void 0 : input.length : 1;
|
|
7
|
+
if (this.length <= 0) {
|
|
8
|
+
throw "Character, invalid length";
|
|
9
|
+
}
|
|
8
10
|
this.qualifiedName = input === null || input === void 0 ? void 0 : input.qualifiedName;
|
|
11
|
+
this.clear();
|
|
9
12
|
}
|
|
10
13
|
set(value) {
|
|
11
14
|
if (typeof value === "string" || typeof value === "number") {
|
|
@@ -16,6 +19,9 @@ class Character {
|
|
|
16
19
|
}
|
|
17
20
|
if (this.value.length > this.length) {
|
|
18
21
|
this.value = this.value.substr(0, this.length);
|
|
22
|
+
// todo, maintain consistent length
|
|
23
|
+
// } else if (this.value.length < this.length) {
|
|
24
|
+
// this.value.padEnd(this.length, " ");
|
|
19
25
|
}
|
|
20
26
|
return this;
|
|
21
27
|
}
|
|
@@ -26,12 +32,24 @@ class Character {
|
|
|
26
32
|
return this.length;
|
|
27
33
|
}
|
|
28
34
|
clear() {
|
|
35
|
+
// todo, maintain consistent length
|
|
36
|
+
// this.value = " ".repeat(this.length);
|
|
29
37
|
this.value = "";
|
|
30
38
|
}
|
|
31
39
|
get() {
|
|
32
40
|
return this.value;
|
|
33
41
|
}
|
|
34
42
|
getOffset(input) {
|
|
43
|
+
if (input.offset && input.offset >= this.length) {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
if (abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"] !== undefined) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
throw new abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"]();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw "Global class CX_SY_RANGE_OUT_OF_BOUNDS not found";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
35
53
|
let ret = this.value;
|
|
36
54
|
if (input === null || input === void 0 ? void 0 : input.offset) {
|
|
37
55
|
ret = ret.substr(input.offset);
|
package/build/src/types/hex.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Float } from "./float";
|
|
2
|
+
import { Integer } from "./integer";
|
|
1
3
|
import { XString } from "./xstring";
|
|
2
4
|
import { ICharacter } from "./_character";
|
|
3
5
|
import { INumeric } from "./_numeric";
|
|
@@ -7,7 +9,7 @@ export declare class Hex implements ICharacter {
|
|
|
7
9
|
constructor(input?: {
|
|
8
10
|
length?: number;
|
|
9
11
|
});
|
|
10
|
-
set(value: ICharacter | INumeric | string | number): void;
|
|
12
|
+
set(value: ICharacter | INumeric | string | number | Integer | Float): void;
|
|
11
13
|
getLength(): number;
|
|
12
14
|
clear(): void;
|
|
13
15
|
get(): string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Float } from "./float";
|
|
1
2
|
import { Hex } from "./hex";
|
|
2
3
|
import { ICharacter } from "./_character";
|
|
3
4
|
import { INumeric } from "./_numeric";
|
|
4
5
|
export declare class Integer implements INumeric {
|
|
5
6
|
private value;
|
|
6
7
|
constructor();
|
|
7
|
-
set(value: INumeric | ICharacter | Hex | string | number): this;
|
|
8
|
+
set(value: INumeric | ICharacter | Hex | string | number | Integer | Float): this;
|
|
8
9
|
clear(): void;
|
|
9
10
|
get(): number;
|
|
10
11
|
}
|
package/build/src/types/numc.js
CHANGED
|
@@ -34,6 +34,16 @@ class String {
|
|
|
34
34
|
return this.value;
|
|
35
35
|
}
|
|
36
36
|
getOffset(input) {
|
|
37
|
+
if (input.offset && input.offset > this.value.length) {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
if (abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"] !== undefined) {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
throw new abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"]();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw "Global class CX_SY_RANGE_OUT_OF_BOUNDS not found";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
37
47
|
let ret = this.value;
|
|
38
48
|
if (input === null || input === void 0 ? void 0 : input.offset) {
|
|
39
49
|
ret = ret.substr(input.offset);
|