@abaplint/runtime 2.7.101 → 2.7.103
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/operators/div.js +10 -1
- package/build/src/operators/divide.d.ts +2 -2
- package/build/src/operators/divide.js +8 -2
- package/build/src/template_formatting.js +4 -1
- package/build/src/throw_error.d.ts +1 -1
- package/build/src/types/character.js +2 -0
- package/build/src/types/hex.js +18 -8
- package/build/src/types/numc.js +5 -1
- package/package.json +1 -1
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.div = void 0;
|
|
4
|
+
const throw_error_1 = require("../throw_error");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
const _parse_1 = require("./_parse");
|
|
6
7
|
function div(left, right) {
|
|
7
8
|
const l = (0, _parse_1.parse)(left);
|
|
8
9
|
const r = (0, _parse_1.parse)(right);
|
|
9
|
-
if (
|
|
10
|
+
if (r === 0) {
|
|
11
|
+
if (l === 0) {
|
|
12
|
+
return new types_1.Integer().set(0);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
(0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
10
19
|
return new types_1.Integer8().set(Math.floor(l / r));
|
|
11
20
|
}
|
|
12
21
|
else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Float } from "../types";
|
|
1
|
+
import { Float, Integer } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function divide(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float;
|
|
4
|
+
export declare function divide(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float | Integer;
|
|
@@ -7,10 +7,16 @@ const _parse_1 = require("./_parse");
|
|
|
7
7
|
// todo, this will only work when the target value is an integer?
|
|
8
8
|
function divide(left, right) {
|
|
9
9
|
const r = (0, _parse_1.parse)(right);
|
|
10
|
+
const l = (0, _parse_1.parse)(left);
|
|
10
11
|
if (r === 0) {
|
|
11
|
-
(0
|
|
12
|
+
if (l === 0) {
|
|
13
|
+
return new types_1.Integer().set(0);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
(0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
|
-
const val =
|
|
19
|
+
const val = l / r;
|
|
14
20
|
return new types_1.Float().set(val);
|
|
15
21
|
}
|
|
16
22
|
exports.divide = divide;
|
|
@@ -10,7 +10,10 @@ function templateFormatting(source, options) {
|
|
|
10
10
|
}
|
|
11
11
|
return templateFormatting(source.getPointer(), options);
|
|
12
12
|
}
|
|
13
|
-
else if (source instanceof types_1.Table
|
|
13
|
+
else if (source instanceof types_1.Table
|
|
14
|
+
|| source instanceof types_1.HashedTable
|
|
15
|
+
|| source instanceof types_1.ABAPObject
|
|
16
|
+
|| source instanceof types_1.Structure) {
|
|
14
17
|
throw new Error("STRG_ILLEGAL_DATA_TYPE");
|
|
15
18
|
}
|
|
16
19
|
else if (source instanceof types_1.Character) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function throwError(name: string):
|
|
1
|
+
export declare function throwError(name: string): never;
|
|
@@ -96,6 +96,8 @@ class Character {
|
|
|
96
96
|
length = (0, _parse_1.parse)(length);
|
|
97
97
|
}
|
|
98
98
|
if ((offset && offset >= this.length)
|
|
99
|
+
|| (length && length > this.length)
|
|
100
|
+
|| (offset && length && offset + length > this.length)
|
|
99
101
|
|| (offset && offset < 0)
|
|
100
102
|
|| (length && length < 0)) {
|
|
101
103
|
(0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
|
package/build/src/types/hex.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.Hex = void 0;
|
|
|
4
4
|
const _parse_1 = require("../operators/_parse");
|
|
5
5
|
const float_1 = require("./float");
|
|
6
6
|
const xstring_1 = require("./xstring");
|
|
7
|
+
const throw_error_1 = require("../throw_error");
|
|
7
8
|
class Hex {
|
|
8
9
|
constructor(input) {
|
|
9
10
|
this.length = (input === null || input === void 0 ? void 0 : input.length) ? input === null || input === void 0 ? void 0 : input.length : 1;
|
|
@@ -62,20 +63,29 @@ class Hex {
|
|
|
62
63
|
return this.value;
|
|
63
64
|
}
|
|
64
65
|
getOffset(input) {
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
let offset = input === null || input === void 0 ? void 0 : input.offset;
|
|
67
|
+
if (offset) {
|
|
68
|
+
offset = (0, _parse_1.parse)(offset);
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
let length = input === null || input === void 0 ? void 0 : input.length;
|
|
71
|
+
if (length) {
|
|
72
|
+
length = (0, _parse_1.parse)(length);
|
|
73
|
+
}
|
|
74
|
+
if ((offset && offset >= this.length)
|
|
75
|
+
|| (length && length > this.length)
|
|
76
|
+
|| (offset && length && offset + length > this.length)
|
|
77
|
+
|| (offset && offset < 0)
|
|
78
|
+
|| (length && length < 0)) {
|
|
79
|
+
(0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
|
|
70
80
|
}
|
|
71
81
|
let ret = this.value;
|
|
72
|
-
if (
|
|
82
|
+
if (offset) {
|
|
73
83
|
// @ts-ignore
|
|
74
|
-
ret = ret.substr(
|
|
84
|
+
ret = ret.substr(offset * 2);
|
|
75
85
|
}
|
|
76
|
-
if (
|
|
86
|
+
if (length !== undefined) {
|
|
77
87
|
// @ts-ignore
|
|
78
|
-
ret = ret.substr(0,
|
|
88
|
+
ret = ret.substr(0, length * 2);
|
|
79
89
|
}
|
|
80
90
|
const r = new xstring_1.XString();
|
|
81
91
|
r.set(ret);
|
package/build/src/types/numc.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Numc = void 0;
|
|
4
4
|
const _parse_1 = require("../operators/_parse");
|
|
5
5
|
const throw_error_1 = require("../throw_error");
|
|
6
|
+
const float_1 = require("./float");
|
|
6
7
|
class Numc {
|
|
7
8
|
constructor(input) {
|
|
8
9
|
this.length = (input === null || input === void 0 ? void 0 : input.length) ? input === null || input === void 0 ? void 0 : input.length : 1;
|
|
@@ -14,11 +15,14 @@ class Numc {
|
|
|
14
15
|
}
|
|
15
16
|
set(value, raw = false) {
|
|
16
17
|
if (typeof value === "number") {
|
|
17
|
-
this.value =
|
|
18
|
+
this.value = Math.trunc(value) + "";
|
|
18
19
|
}
|
|
19
20
|
else if (typeof value === "string") {
|
|
20
21
|
this.value = parseInt(value, 10) + "";
|
|
21
22
|
}
|
|
23
|
+
else if (value instanceof float_1.Float) {
|
|
24
|
+
this.value = Math.trunc(value.getRaw()) + "";
|
|
25
|
+
}
|
|
22
26
|
else {
|
|
23
27
|
this.set(value.get());
|
|
24
28
|
return;
|