@abaplint/runtime 2.13.46 → 2.13.48
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/abs.js +1 -1
- package/build/src/builtin/ceil.js +1 -1
- package/build/src/builtin/floor.js +1 -1
- package/build/src/builtin/frac.js +4 -2
- package/build/src/builtin/trunc.js +1 -1
- package/build/src/operators/add.js +3 -3
- package/build/src/operators/divide.js +11 -1
- package/build/src/operators/minus.js +2 -2
- package/build/src/operators/multiply.js +2 -2
- package/build/src/statements/modify_database.js +8 -2
- package/build/src/statements/select.js +20 -3
- package/build/src/types/data_reference.d.ts +1 -1
- package/build/src/types/decfloat34.d.ts +1 -1
- package/build/src/types/decfloat34.js +3 -0
- package/build/src/types/float.d.ts +7 -0
- package/build/src/types/float.js +18 -1
- package/build/src/types/integer.d.ts +7 -1
- package/build/src/types/integer.js +12 -1
- package/build/src/types/integer8.d.ts +2 -1
- package/build/src/types/integer8.js +2 -1
- package/build/src/types/packed.js +2 -1
- package/package.json +2 -2
package/build/src/builtin/abs.js
CHANGED
|
@@ -12,8 +12,10 @@ function frac(input) {
|
|
|
12
12
|
else if (typeof input.val === "string") {
|
|
13
13
|
num_in = parseFloat(input.val);
|
|
14
14
|
}
|
|
15
|
-
else if (input.val instanceof types_1.
|
|
16
|
-
|
|
15
|
+
else if (input.val instanceof types_1.Float) {
|
|
16
|
+
num_in = input.val.getCalculationValue();
|
|
17
|
+
}
|
|
18
|
+
else if (input.val instanceof types_1.DecFloat34) {
|
|
17
19
|
num_in = input.val.getRaw();
|
|
18
20
|
}
|
|
19
21
|
else {
|
|
@@ -22,16 +22,16 @@ function add(left, right) {
|
|
|
22
22
|
return new types_1.Integer().set(left.get() + right);
|
|
23
23
|
}
|
|
24
24
|
else if ((left instanceof string_1.String || left instanceof types_1.Character) && isIntegerCharacter(left) && right instanceof types_1.Integer) {
|
|
25
|
-
return new types_1.Integer().set(Number.parseInt(left.get(), 10) + right.get());
|
|
25
|
+
return new types_1.Integer().set(Number.parseInt(left.get(), 10) + right.get()).clearIntegerCalculationType();
|
|
26
26
|
}
|
|
27
27
|
else if ((right instanceof string_1.String || right instanceof types_1.Character) && isIntegerCharacter(right) && left instanceof types_1.Integer) {
|
|
28
|
-
return new types_1.Integer().set(left.get() + Number.parseInt(right.get(), 10));
|
|
28
|
+
return new types_1.Integer().set(left.get() + Number.parseInt(right.get(), 10)).clearIntegerCalculationType();
|
|
29
29
|
}
|
|
30
30
|
else if ((left instanceof string_1.String || left instanceof types_1.Character)
|
|
31
31
|
&& (right instanceof string_1.String || right instanceof types_1.Character)
|
|
32
32
|
&& isIntegerCharacter(left)
|
|
33
33
|
&& isIntegerCharacter(right)) {
|
|
34
|
-
return new types_1.Integer().set(Number.parseInt(left.get(), 10) + Number.parseInt(right.get(), 10));
|
|
34
|
+
return new types_1.Integer().set(Number.parseInt(left.get(), 10) + Number.parseInt(right.get(), 10)).clearIntegerCalculationType();
|
|
35
35
|
}
|
|
36
36
|
else if (left instanceof types_1.Integer8) {
|
|
37
37
|
if (right instanceof types_1.Integer8) {
|
|
@@ -30,6 +30,16 @@ function divide(left, right) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
const val = l / r;
|
|
33
|
-
|
|
33
|
+
const ret = new types_1.Float().set(val);
|
|
34
|
+
if (isIntegerOperand(left) && isIntegerOperand(right)) {
|
|
35
|
+
ret.setIntegerCalculationType();
|
|
36
|
+
}
|
|
37
|
+
return ret;
|
|
38
|
+
}
|
|
39
|
+
function isIntegerOperand(val) {
|
|
40
|
+
if (val instanceof types_1.Integer) {
|
|
41
|
+
return val.isIntegerCalculationType();
|
|
42
|
+
}
|
|
43
|
+
return val instanceof types_1.Integer8;
|
|
34
44
|
}
|
|
35
45
|
//# sourceMappingURL=divide.js.map
|
|
@@ -36,10 +36,10 @@ function minus(left, right) {
|
|
|
36
36
|
return new types_1.Integer().set(left.get() - right);
|
|
37
37
|
}
|
|
38
38
|
else if ((left instanceof string_1.String || left instanceof types_1.Character) && Number.isInteger(Number(left.get())) && right instanceof types_1.Integer) {
|
|
39
|
-
return new types_1.Integer().set(Number.parseInt(left.get(), 10) - right.get());
|
|
39
|
+
return new types_1.Integer().set(Number.parseInt(left.get(), 10) - right.get()).clearIntegerCalculationType();
|
|
40
40
|
}
|
|
41
41
|
else if ((right instanceof string_1.String || right instanceof types_1.Character) && Number.isInteger(Number(right)) && left instanceof types_1.Integer) {
|
|
42
|
-
return new types_1.Integer().set(left.get() - Number.parseInt(right.get(), 10));
|
|
42
|
+
return new types_1.Integer().set(left.get() - Number.parseInt(right.get(), 10)).clearIntegerCalculationType();
|
|
43
43
|
}
|
|
44
44
|
return new types_1.Float().set((0, _parse_1.parse)(left) - (0, _parse_1.parse)(right));
|
|
45
45
|
}
|
|
@@ -29,11 +29,11 @@ function multiply(left, right) {
|
|
|
29
29
|
}
|
|
30
30
|
else if ((left instanceof string_1.String || left instanceof types_1.Character) && Number.isInteger(Number(left.get())) && right instanceof types_1.Integer) {
|
|
31
31
|
const val = Number.parseInt(left.get(), 10) * right.get();
|
|
32
|
-
return new types_1.Integer().set(val);
|
|
32
|
+
return new types_1.Integer().set(val).clearIntegerCalculationType();
|
|
33
33
|
}
|
|
34
34
|
else if ((right instanceof string_1.String || right instanceof types_1.Character) && Number.isInteger(Number(right)) && left instanceof types_1.Integer) {
|
|
35
35
|
const val = left.get() * Number.parseInt(right.get(), 10);
|
|
36
|
-
return new types_1.Integer().set(val);
|
|
36
|
+
return new types_1.Integer().set(val).clearIntegerCalculationType();
|
|
37
37
|
}
|
|
38
38
|
return new types_1.Float().set((0, _parse_1.parse)(left) * (0, _parse_1.parse)(right));
|
|
39
39
|
}
|
|
@@ -12,12 +12,18 @@ async function modifyDatabase(table, options, context) {
|
|
|
12
12
|
options.values = options.values.getPointer();
|
|
13
13
|
}
|
|
14
14
|
if (options.table) {
|
|
15
|
+
let subrc = 0;
|
|
16
|
+
let dbcnt = 0;
|
|
15
17
|
for (const row of options.table.array()) {
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
+
const insertSubrc = await (0, insert_database_1.insertDatabase)(table, { values: row }, context);
|
|
19
|
+
if (insertSubrc !== 0) {
|
|
18
20
|
await (0, update_database_1.updateDatabase)(table, { from: row }, context);
|
|
19
21
|
}
|
|
22
|
+
subrc = Math.max(subrc, abap.builtin.sy.get().subrc.get());
|
|
23
|
+
dbcnt += abap.builtin.sy.get().dbcnt.get();
|
|
20
24
|
}
|
|
25
|
+
abap.builtin.sy.get().subrc.set(subrc);
|
|
26
|
+
abap.builtin.sy.get().dbcnt.set(dbcnt);
|
|
21
27
|
}
|
|
22
28
|
else if (options.values) {
|
|
23
29
|
const subrc = await (0, insert_database_1.insertDatabase)(table, { values: options.values }, context);
|
|
@@ -59,7 +59,12 @@ function rowsToTarget(target, rows) {
|
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
const columnName = Object.keys(row)[0];
|
|
62
|
-
|
|
62
|
+
if (row[columnName] === null) {
|
|
63
|
+
targetRow.clear();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
targetRow.set(row[columnName]);
|
|
67
|
+
}
|
|
63
68
|
}
|
|
64
69
|
abap.statements.insertInternal({ table: target, data: targetRow, noClone: true });
|
|
65
70
|
}
|
|
@@ -67,12 +72,24 @@ function rowsToTarget(target, rows) {
|
|
|
67
72
|
else if (Array.isArray(target)) {
|
|
68
73
|
for (let index = 0; index < target.length; index++) {
|
|
69
74
|
const element = target[index];
|
|
70
|
-
|
|
75
|
+
const value = rows[0][Object.keys(rows[0])[index]];
|
|
76
|
+
if (value === null) {
|
|
77
|
+
element.clear();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
element.set(value);
|
|
81
|
+
}
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
else if (target !== undefined) {
|
|
74
85
|
// its a simple type
|
|
75
|
-
|
|
86
|
+
const value = rows[0][Object.keys(rows[0])[0]];
|
|
87
|
+
if (value === null) {
|
|
88
|
+
target.clear();
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
target.set(value);
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
}
|
|
78
95
|
//# sourceMappingURL=select.js.map
|
|
@@ -23,7 +23,7 @@ export declare class DataReference {
|
|
|
23
23
|
get(): any;
|
|
24
24
|
array(): any;
|
|
25
25
|
getArrayLength(): any;
|
|
26
|
-
set(value: any): void | Table | Structure | ABAPObject | Float | Integer8 |
|
|
26
|
+
set(value: any): void | Table | Structure | ABAPObject | Float | Integer8 | DecFloat34 | this;
|
|
27
27
|
getOffset(input: {
|
|
28
28
|
offset?: number | INumeric | Hex;
|
|
29
29
|
length?: number | INumeric | Hex;
|
|
@@ -5,7 +5,7 @@ export declare class DecFloat34 {
|
|
|
5
5
|
private value;
|
|
6
6
|
constructor();
|
|
7
7
|
clone(): DecFloat34;
|
|
8
|
-
set(value: INumeric | ICharacter | Hex | string | number): this;
|
|
8
|
+
set(value: INumeric | ICharacter | Hex | string | number | DecFloat34): this;
|
|
9
9
|
clear(): void;
|
|
10
10
|
getRaw(): number;
|
|
11
11
|
get(): string;
|
|
@@ -3,11 +3,18 @@ import { ICharacter } from "./_character";
|
|
|
3
3
|
import { INumeric } from "./_numeric";
|
|
4
4
|
export declare class Float {
|
|
5
5
|
private value;
|
|
6
|
+
private integerCalculationType;
|
|
6
7
|
private readonly qualifiedName;
|
|
7
8
|
constructor(input?: {
|
|
8
9
|
qualifiedName?: string;
|
|
9
10
|
});
|
|
10
11
|
clone(): Float;
|
|
12
|
+
/** ABAP calculates in type i if all operands are integers, ie. "3 / 2" is 2. The exact value is
|
|
13
|
+
* kept here, so assigning to a float or packed target, which raises the calculation type, still
|
|
14
|
+
* gives the exact result. Consumers without a target type must use getCalculationValue() */
|
|
15
|
+
setIntegerCalculationType(): Float;
|
|
16
|
+
/** value as seen by the calculation type, ie. rounded if the calculation type is integer */
|
|
17
|
+
getCalculationValue(): number;
|
|
11
18
|
getQualifiedName(): string | undefined;
|
|
12
19
|
set(value: INumeric | ICharacter | Hex | string | number): this;
|
|
13
20
|
clear(): void;
|
package/build/src/types/float.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.Float = void 0;
|
|
|
4
4
|
const hex_1 = require("./hex");
|
|
5
5
|
const xstring_1 = require("./xstring");
|
|
6
6
|
const integer8_1 = require("./integer8");
|
|
7
|
+
const decfloat34_1 = require("./decfloat34");
|
|
7
8
|
/*
|
|
8
9
|
function getNumberParts(x: number) {
|
|
9
10
|
if(isNaN(x)) {
|
|
@@ -21,6 +22,7 @@ function getNumberParts(x: number) {
|
|
|
21
22
|
*/
|
|
22
23
|
class Float {
|
|
23
24
|
value;
|
|
25
|
+
integerCalculationType = false;
|
|
24
26
|
qualifiedName;
|
|
25
27
|
constructor(input) {
|
|
26
28
|
this.value = 0;
|
|
@@ -31,6 +33,21 @@ class Float {
|
|
|
31
33
|
n.value = this.value;
|
|
32
34
|
return n;
|
|
33
35
|
}
|
|
36
|
+
/** ABAP calculates in type i if all operands are integers, ie. "3 / 2" is 2. The exact value is
|
|
37
|
+
* kept here, so assigning to a float or packed target, which raises the calculation type, still
|
|
38
|
+
* gives the exact result. Consumers without a target type must use getCalculationValue() */
|
|
39
|
+
setIntegerCalculationType() {
|
|
40
|
+
this.integerCalculationType = true;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/** value as seen by the calculation type, ie. rounded if the calculation type is integer */
|
|
44
|
+
getCalculationValue() {
|
|
45
|
+
if (this.integerCalculationType === true) {
|
|
46
|
+
// ABAP rounds half away from zero
|
|
47
|
+
return this.value < 0 ? -Math.round(-this.value) : Math.round(this.value);
|
|
48
|
+
}
|
|
49
|
+
return this.value;
|
|
50
|
+
}
|
|
34
51
|
getQualifiedName() {
|
|
35
52
|
return this.qualifiedName;
|
|
36
53
|
}
|
|
@@ -47,7 +64,7 @@ class Float {
|
|
|
47
64
|
else if (value instanceof integer8_1.Integer8) {
|
|
48
65
|
this.value = Number(value.get());
|
|
49
66
|
}
|
|
50
|
-
else if (value instanceof Float) {
|
|
67
|
+
else if (value instanceof Float || value instanceof decfloat34_1.DecFloat34) {
|
|
51
68
|
this.value = value.getRaw();
|
|
52
69
|
}
|
|
53
70
|
else if (value instanceof hex_1.Hex || value instanceof xstring_1.XString) {
|
|
@@ -2,6 +2,7 @@ import { Float } from "./float";
|
|
|
2
2
|
import { Hex } from "./hex";
|
|
3
3
|
import { ICharacter } from "./_character";
|
|
4
4
|
import { INumeric } from "./_numeric";
|
|
5
|
+
import { DecFloat34 } from "./decfloat34";
|
|
5
6
|
export declare const DIGITS: RegExp;
|
|
6
7
|
export declare const MAX_INTEGER = 2147483647;
|
|
7
8
|
export declare const MIN_INTEGER = -2147483648;
|
|
@@ -9,14 +10,19 @@ export declare function toInteger(value: string, exception?: boolean): number;
|
|
|
9
10
|
export declare class Integer implements INumeric {
|
|
10
11
|
private value;
|
|
11
12
|
private constant;
|
|
13
|
+
private integerCalculationType;
|
|
12
14
|
private readonly qualifiedName;
|
|
13
15
|
constructor(input?: {
|
|
14
16
|
qualifiedName?: string;
|
|
15
17
|
});
|
|
18
|
+
/** ABAP determines the calculation type from the operand types, character-like operands raise it
|
|
19
|
+
* above type i even if the intermediate result is integer, ie. "'1.0' * 18 / 16" is not rounded */
|
|
20
|
+
clearIntegerCalculationType(): Integer;
|
|
21
|
+
isIntegerCalculationType(): boolean;
|
|
16
22
|
getQualifiedName(): string | undefined;
|
|
17
23
|
clone(): Integer;
|
|
18
24
|
setConstant(): this;
|
|
19
|
-
set(value: INumeric | ICharacter | Hex | string | number | Integer | Float): this;
|
|
25
|
+
set(value: INumeric | ICharacter | Hex | string | number | Integer | Float | DecFloat34): this;
|
|
20
26
|
clear(): void;
|
|
21
27
|
get(): number;
|
|
22
28
|
}
|
|
@@ -10,6 +10,7 @@ const integer8_1 = require("./integer8");
|
|
|
10
10
|
const hex_uint8_1 = require("./hex_uint8");
|
|
11
11
|
const character_1 = require("./character");
|
|
12
12
|
const string_1 = require("./string");
|
|
13
|
+
const decfloat34_1 = require("./decfloat34");
|
|
13
14
|
exports.DIGITS = new RegExp(/^\s*-?\+?\d+\.?\d* *$/i);
|
|
14
15
|
exports.MAX_INTEGER = 2147483647;
|
|
15
16
|
exports.MIN_INTEGER = -2147483648;
|
|
@@ -33,11 +34,21 @@ function toInteger(value, exception = true) {
|
|
|
33
34
|
class Integer {
|
|
34
35
|
value;
|
|
35
36
|
constant = false;
|
|
37
|
+
integerCalculationType = true;
|
|
36
38
|
qualifiedName;
|
|
37
39
|
constructor(input) {
|
|
38
40
|
this.value = 0;
|
|
39
41
|
this.qualifiedName = input?.qualifiedName;
|
|
40
42
|
}
|
|
43
|
+
/** ABAP determines the calculation type from the operand types, character-like operands raise it
|
|
44
|
+
* above type i even if the intermediate result is integer, ie. "'1.0' * 18 / 16" is not rounded */
|
|
45
|
+
clearIntegerCalculationType() {
|
|
46
|
+
this.integerCalculationType = false;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
isIntegerCalculationType() {
|
|
50
|
+
return this.integerCalculationType;
|
|
51
|
+
}
|
|
41
52
|
getQualifiedName() {
|
|
42
53
|
return this.qualifiedName;
|
|
43
54
|
}
|
|
@@ -70,7 +81,7 @@ class Integer {
|
|
|
70
81
|
else if (value instanceof integer8_1.Integer8) {
|
|
71
82
|
this.set(Number(value.get()));
|
|
72
83
|
}
|
|
73
|
-
else if (value instanceof float_1.Float) {
|
|
84
|
+
else if (value instanceof float_1.Float || value instanceof decfloat34_1.DecFloat34) {
|
|
74
85
|
this.set(Math.round(value.getRaw()));
|
|
75
86
|
}
|
|
76
87
|
else if (value instanceof hex_1.Hex || value instanceof xstring_1.XString || value instanceof hex_uint8_1.HexUInt8) {
|
|
@@ -3,6 +3,7 @@ import { Hex } from "./hex";
|
|
|
3
3
|
import { ICharacter } from "./_character";
|
|
4
4
|
import { INumeric } from "./_numeric";
|
|
5
5
|
import { Integer } from "./integer";
|
|
6
|
+
import { DecFloat34 } from "./decfloat34";
|
|
6
7
|
export declare class Integer8 {
|
|
7
8
|
private value;
|
|
8
9
|
private readonly qualifiedName;
|
|
@@ -11,7 +12,7 @@ export declare class Integer8 {
|
|
|
11
12
|
});
|
|
12
13
|
clone(): Integer8;
|
|
13
14
|
getQualifiedName(): string | undefined;
|
|
14
|
-
set(value: INumeric | ICharacter | Hex | string | number | bigint | Integer8 | Integer | Float): this;
|
|
15
|
+
set(value: INumeric | ICharacter | Hex | string | number | bigint | Integer8 | Integer | Float | DecFloat34): this;
|
|
15
16
|
clear(): void;
|
|
16
17
|
get(): bigint;
|
|
17
18
|
}
|
|
@@ -9,6 +9,7 @@ const integer_1 = require("./integer");
|
|
|
9
9
|
const get_bit_1 = require("../statements/get_bit");
|
|
10
10
|
const character_1 = require("./character");
|
|
11
11
|
const hex_uint8_1 = require("./hex_uint8");
|
|
12
|
+
const decfloat34_1 = require("./decfloat34");
|
|
12
13
|
const digits = new RegExp(/^\s*-?\+?\d+\.?\d* *$/i);
|
|
13
14
|
class Integer8 {
|
|
14
15
|
value;
|
|
@@ -45,7 +46,7 @@ class Integer8 {
|
|
|
45
46
|
}
|
|
46
47
|
this.value = BigInt(value);
|
|
47
48
|
}
|
|
48
|
-
else if (value instanceof float_1.Float) {
|
|
49
|
+
else if (value instanceof float_1.Float || value instanceof decfloat34_1.DecFloat34) {
|
|
49
50
|
this.set(Math.round(value.getRaw()));
|
|
50
51
|
}
|
|
51
52
|
else if (value instanceof hex_1.Hex || value instanceof xstring_1.XString || value instanceof hex_uint8_1.HexUInt8) {
|
|
@@ -4,6 +4,7 @@ exports.Packed = void 0;
|
|
|
4
4
|
const float_1 = require("./float");
|
|
5
5
|
const throw_error_1 = require("../throw_error");
|
|
6
6
|
const integer8_1 = require("./integer8");
|
|
7
|
+
const decfloat34_1 = require("./decfloat34");
|
|
7
8
|
const digits = new RegExp(/^\s*-?\+?\d*\.?\d*(?:E[+-]?\d+)? *$/i);
|
|
8
9
|
function pow10(exp) {
|
|
9
10
|
return 10n ** BigInt(exp);
|
|
@@ -110,7 +111,7 @@ class Packed {
|
|
|
110
111
|
else if (value instanceof integer8_1.Integer8) {
|
|
111
112
|
this.value = value.get() * pow10(this.decimals);
|
|
112
113
|
}
|
|
113
|
-
else if (value instanceof float_1.Float) {
|
|
114
|
+
else if (value instanceof float_1.Float || value instanceof decfloat34_1.DecFloat34) {
|
|
114
115
|
this.value = this.numberToScaled(value.getRaw());
|
|
115
116
|
}
|
|
116
117
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.48",
|
|
4
4
|
"description": "Transpiler - Runtime",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/chai": "^4.3.20",
|
|
33
33
|
"@types/mocha": "^10.0.10",
|
|
34
|
-
"@types/node": "^24.13.
|
|
34
|
+
"@types/node": "^24.13.3",
|
|
35
35
|
"chai": "^4.5.0",
|
|
36
36
|
"mocha": "^11.7.6",
|
|
37
37
|
"source-map-support": "^0.5.21",
|