@abaplint/runtime 2.8.0 → 2.8.2
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/compare/eq.d.ts +2 -2
- package/build/src/compare/eq.js +10 -0
- package/build/src/compare/gt.js +6 -0
- package/build/src/compare/initial.d.ts +2 -2
- package/build/src/compare/initial.js +3 -0
- package/build/src/operators/add.d.ts +2 -2
- package/build/src/operators/add.js +11 -0
- package/build/src/operators/div.d.ts +1 -1
- package/build/src/operators/div.js +13 -3
- package/build/src/operators/divide.d.ts +2 -2
- package/build/src/operators/divide.js +13 -0
- package/build/src/operators/minus.d.ts +2 -2
- package/build/src/operators/minus.js +6 -1
- package/build/src/operators/mod.d.ts +1 -1
- package/build/src/operators/mod.js +6 -0
- package/build/src/operators/multiply.d.ts +2 -2
- package/build/src/operators/multiply.js +6 -1
- package/build/src/operators/power.d.ts +2 -2
- package/build/src/operators/power.js +5 -0
- package/build/src/statements/read_table.d.ts +2 -2
- package/build/src/statements/read_table.js +3 -0
- package/build/src/types/data_reference.d.ts +3 -2
- package/build/src/types/field_symbol.d.ts +1 -1
- package/build/src/types/float.js +4 -0
- package/build/src/types/hex.d.ts +4 -3
- package/build/src/types/hex.js +27 -2
- package/build/src/types/integer.js +4 -0
- package/build/src/types/integer8.d.ts +3 -3
- package/build/src/types/integer8.js +8 -4
- package/build/src/types/xstring.d.ts +3 -2
- package/build/src/types/xstring.js +13 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ABAPObject, FieldSymbol, Float, HashedTable, String, Hex, Structure, Table } from "../types";
|
|
1
|
+
import { ABAPObject, FieldSymbol, Float, HashedTable, String, Hex, Structure, Table, Integer8 } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function eq(left: number | string | ICharacter | INumeric | Float | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol, right: number | string | ICharacter | INumeric | Float | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol): boolean;
|
|
4
|
+
export declare function eq(left: number | string | ICharacter | Integer8 | INumeric | Float | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol, right: number | string | ICharacter | Integer8 | INumeric | Float | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol): boolean;
|
package/build/src/compare/eq.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.eq = void 0;
|
|
4
4
|
/* eslint-disable max-len */
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
+
const _parse_1 = require("../operators/_parse");
|
|
6
7
|
function compareTables(left, right) {
|
|
7
8
|
const leftArray = left.array();
|
|
8
9
|
const rightArray = right.array();
|
|
@@ -28,6 +29,15 @@ function eq(left, right) {
|
|
|
28
29
|
else if (left instanceof types_1.FieldSymbol) {
|
|
29
30
|
return eq(left.getPointer(), right);
|
|
30
31
|
}
|
|
32
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
33
|
+
if (left instanceof types_1.Table || left instanceof types_1.HashedTable || right instanceof types_1.Table || right instanceof types_1.HashedTable) {
|
|
34
|
+
// exception?
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
38
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
39
|
+
return l === r;
|
|
40
|
+
}
|
|
31
41
|
// for performance, do the typicaly/easy cases first
|
|
32
42
|
if (right instanceof types_1.Character) {
|
|
33
43
|
if (left instanceof types_1.Character) {
|
package/build/src/compare/gt.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gt = void 0;
|
|
4
|
+
const _parse_1 = require("../operators/_parse");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
const integer_1 = require("../types/integer");
|
|
6
7
|
function gt(left, right) {
|
|
@@ -22,6 +23,11 @@ function gt(left, right) {
|
|
|
22
23
|
if (left instanceof types_1.Hex || right instanceof types_1.Hex) {
|
|
23
24
|
return gt_with_hex(left, right);
|
|
24
25
|
}
|
|
26
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
27
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
28
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
29
|
+
return l > r;
|
|
30
|
+
}
|
|
25
31
|
let l = undefined;
|
|
26
32
|
if (typeof left === "number" || typeof left === "string") {
|
|
27
33
|
l = left;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ABAPObject, DataReference, FieldSymbol, Structure, Table } from "../types";
|
|
1
|
+
import { ABAPObject, DataReference, FieldSymbol, Integer8, Structure, Table } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function initial(val: ICharacter | INumeric | string | number | Structure | DataReference | FieldSymbol | Table | ABAPObject): boolean;
|
|
4
|
+
export declare function initial(val: ICharacter | INumeric | string | number | Integer8 | Structure | DataReference | FieldSymbol | Table | ABAPObject): boolean;
|
|
@@ -9,6 +9,9 @@ function initial(val) {
|
|
|
9
9
|
if (val instanceof types_1.Table || val instanceof types_1.HashedTable) {
|
|
10
10
|
return val.array().length === 0;
|
|
11
11
|
}
|
|
12
|
+
else if (val instanceof types_1.Integer8) {
|
|
13
|
+
return val.get() === 0n;
|
|
14
|
+
}
|
|
12
15
|
else if (val instanceof types_1.DataReference) {
|
|
13
16
|
return val.getPointer() === undefined;
|
|
14
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldSymbol, Float, Hex, Integer } from "../types";
|
|
1
|
+
import { FieldSymbol, Float, Hex, Integer, Integer8 } 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 | Float | Integer | Hex | FieldSymbol, right: INumeric | ICharacter | string | number | Float | Integer | Hex | FieldSymbol): Integer | Float;
|
|
4
|
+
export declare function add(left: INumeric | ICharacter | string | number | Float | Integer | Hex | FieldSymbol, right: INumeric | ICharacter | string | number | Float | Integer | Hex | FieldSymbol): Integer | Integer8 | Float;
|
|
@@ -24,6 +24,17 @@ function add(left, right) {
|
|
|
24
24
|
else if ((right instanceof string_1.String || right instanceof types_1.Character) && Number.isInteger(Number(right)) && left instanceof types_1.Integer) {
|
|
25
25
|
return new types_1.Integer().set(left.get() + Number.parseInt(right.get(), 10));
|
|
26
26
|
}
|
|
27
|
+
else if (left instanceof types_1.Integer8) {
|
|
28
|
+
if (right instanceof types_1.Integer8) {
|
|
29
|
+
return new types_1.Integer8().set(left.get() + right.get());
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return new types_1.Integer8().set(left.get() + BigInt((0, _parse_1.parse)(right)));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (right instanceof types_1.Integer8) {
|
|
36
|
+
return new types_1.Integer8().set(BigInt((0, _parse_1.parse)(left)) + right.get());
|
|
37
|
+
}
|
|
27
38
|
if (left instanceof types_1.FieldSymbol) {
|
|
28
39
|
if (left.getPointer() === undefined) {
|
|
29
40
|
throw new Error("GETWA_NOT_ASSIGNED");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Integer, Integer8 } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function div(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Integer | Integer8;
|
|
4
|
+
export declare function div(left: INumeric | ICharacter | Integer8 | string | number, right: INumeric | Integer8 | ICharacter | string | number): Integer | Integer8;
|
|
@@ -5,6 +5,19 @@ const throw_error_1 = require("../throw_error");
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const _parse_1 = require("./_parse");
|
|
7
7
|
function div(left, right) {
|
|
8
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
9
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
10
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
11
|
+
if (r === 0n) {
|
|
12
|
+
if (l === 0n) {
|
|
13
|
+
return new types_1.Integer8().set(0n);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
(0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return new types_1.Integer8().set(l / r);
|
|
20
|
+
}
|
|
8
21
|
const l = (0, _parse_1.parse)(left);
|
|
9
22
|
const r = (0, _parse_1.parse)(right);
|
|
10
23
|
if (r === 0) {
|
|
@@ -15,9 +28,6 @@ function div(left, right) {
|
|
|
15
28
|
(0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
|
|
16
29
|
}
|
|
17
30
|
}
|
|
18
|
-
else if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
19
|
-
return new types_1.Integer8().set(Math.floor(l / r));
|
|
20
|
-
}
|
|
21
31
|
else {
|
|
22
32
|
return new types_1.Integer().set(Math.floor(l / r));
|
|
23
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Float, Integer } from "../types";
|
|
1
|
+
import { Float, Integer, Integer8 } 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 | Integer8 | string | number, right: INumeric | ICharacter | Integer8 | string | number): Integer | Float | Integer8;
|
|
@@ -6,6 +6,19 @@ const types_1 = require("../types");
|
|
|
6
6
|
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
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
10
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
11
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
12
|
+
if (r === 0n) {
|
|
13
|
+
if (l === 0n) {
|
|
14
|
+
return new types_1.Integer8().set(0n);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
(0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return new types_1.Integer8().set(l / r);
|
|
21
|
+
}
|
|
9
22
|
const r = (0, _parse_1.parse)(right);
|
|
10
23
|
const l = (0, _parse_1.parse)(left);
|
|
11
24
|
if (r === 0) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldSymbol, Float, Integer } from "../types";
|
|
1
|
+
import { FieldSymbol, Float, Integer, Integer8 } 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 | Integer | Float | FieldSymbol, right: INumeric | ICharacter | string | number | Integer | Float | FieldSymbol): Integer | Float;
|
|
4
|
+
export declare function minus(left: INumeric | ICharacter | string | Integer8 | number | Integer | Float | FieldSymbol, right: INumeric | ICharacter | string | Integer8 | number | Integer | Float | FieldSymbol): Integer | Integer8 | Float;
|
|
@@ -17,7 +17,12 @@ function minus(left, right) {
|
|
|
17
17
|
}
|
|
18
18
|
return minus(left, right.getPointer());
|
|
19
19
|
}
|
|
20
|
-
if (left instanceof types_1.
|
|
20
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
21
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
22
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
23
|
+
return new types_1.Integer8().set(l - r);
|
|
24
|
+
}
|
|
25
|
+
else if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
|
|
21
26
|
return new types_1.Integer().set(left.get() - right.get());
|
|
22
27
|
}
|
|
23
28
|
else if (typeof left === "number" && typeof right === "number"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Integer, Integer8 } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function mod(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Integer | Integer8;
|
|
4
|
+
export declare function mod(left: INumeric | ICharacter | string | Integer8 | number, right: INumeric | Integer8 | ICharacter | string | number): Integer | Integer8;
|
|
@@ -4,6 +4,12 @@ exports.mod = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const _parse_1 = require("./_parse");
|
|
6
6
|
function mod(left, right) {
|
|
7
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
8
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
9
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
10
|
+
// todo, is this correct?
|
|
11
|
+
return new types_1.Integer8().set(l % r);
|
|
12
|
+
}
|
|
7
13
|
const l = (0, _parse_1.parse)(left);
|
|
8
14
|
const r = (0, _parse_1.parse)(right);
|
|
9
15
|
let val = ((l % r) + r) % r;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Float, Integer } from "../types";
|
|
1
|
+
import { Float, Integer, Integer8 } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function multiply(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float |
|
|
4
|
+
export declare function multiply(left: INumeric | ICharacter | string | Integer8 | number, right: INumeric | ICharacter | string | Integer8 | number): Integer | Float | Integer8;
|
|
@@ -5,7 +5,12 @@ const types_1 = require("../types");
|
|
|
5
5
|
const _parse_1 = require("./_parse");
|
|
6
6
|
const string_1 = require("../types/string");
|
|
7
7
|
function multiply(left, right) {
|
|
8
|
-
if (left instanceof types_1.
|
|
8
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
9
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
10
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
11
|
+
return new types_1.Integer8().set(l * r);
|
|
12
|
+
}
|
|
13
|
+
else if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
|
|
9
14
|
const val = left.get() * right.get();
|
|
10
15
|
return new types_1.Integer().set(val);
|
|
11
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Float } from "../types";
|
|
1
|
+
import { Float, Integer8 } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
export declare function power(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float;
|
|
4
|
+
export declare function power(left: INumeric | ICharacter | Integer8 | string | number, right: INumeric | ICharacter | Integer8 | string | number): Float | Integer8;
|
|
@@ -4,6 +4,11 @@ exports.power = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const _parse_1 = require("./_parse");
|
|
6
6
|
function power(left, right) {
|
|
7
|
+
if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
|
|
8
|
+
const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
|
|
9
|
+
const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
|
|
10
|
+
return new types_1.Integer8().set(l ** r);
|
|
11
|
+
}
|
|
7
12
|
return new types_1.Float().set(Math.pow((0, _parse_1.parse)(left), (0, _parse_1.parse)(right)));
|
|
8
13
|
}
|
|
9
14
|
exports.power = power;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DataReference, FieldSymbol, HashedTable, Structure, Table } from "../types";
|
|
1
|
+
import { DataReference, FieldSymbol, HashedTable, Integer8, Structure, Table } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
4
|
export interface IReadTableOptions {
|
|
5
|
-
index?: INumeric | FieldSymbol | number;
|
|
5
|
+
index?: INumeric | Integer8 | FieldSymbol | number;
|
|
6
6
|
into?: INumeric | ICharacter | Structure | Table | DataReference;
|
|
7
7
|
from?: INumeric | ICharacter | Structure | Table | DataReference;
|
|
8
8
|
referenceInto?: DataReference;
|
|
@@ -119,6 +119,9 @@ function readTable(table, options) {
|
|
|
119
119
|
if (index instanceof types_1.Float || index instanceof types_1.DecFloat34) {
|
|
120
120
|
index = index.getRaw();
|
|
121
121
|
}
|
|
122
|
+
else if (index instanceof types_1.Integer8) {
|
|
123
|
+
index = Number(index.get());
|
|
124
|
+
}
|
|
122
125
|
else {
|
|
123
126
|
index = index.get();
|
|
124
127
|
}
|
|
@@ -6,7 +6,8 @@ import { String } from "./string";
|
|
|
6
6
|
import { Structure } from "./structure";
|
|
7
7
|
import { Float } from "./float";
|
|
8
8
|
import { Hex } from "./hex";
|
|
9
|
-
|
|
9
|
+
import { Integer8 } from "./integer8";
|
|
10
|
+
type PointerType = INumeric | Table | ICharacter | ABAPObject | Integer8 | undefined | Structure | Float;
|
|
10
11
|
export declare class DataReference {
|
|
11
12
|
private pointer;
|
|
12
13
|
private readonly type;
|
|
@@ -20,7 +21,7 @@ export declare class DataReference {
|
|
|
20
21
|
get(): any;
|
|
21
22
|
array(): any;
|
|
22
23
|
getArrayLength(): any;
|
|
23
|
-
set(value: any): void | Float | ABAPObject | this | Table | Structure;
|
|
24
|
+
set(value: any): void | Float | Integer8 | ABAPObject | this | Table | Structure;
|
|
24
25
|
getOffset(input: {
|
|
25
26
|
offset?: number | INumeric | Hex;
|
|
26
27
|
length?: number | INumeric | Hex;
|
|
@@ -17,7 +17,7 @@ export declare class FieldSymbol {
|
|
|
17
17
|
unassign(): void;
|
|
18
18
|
isAssigned(): boolean;
|
|
19
19
|
getPointer(): any;
|
|
20
|
-
dereference(): INumeric | Float |
|
|
20
|
+
dereference(): INumeric | ICharacter | Float | import("./integer8").Integer8 | ABAPObject | Table | Structure | undefined;
|
|
21
21
|
clear(): void | Structure | undefined;
|
|
22
22
|
get(): any;
|
|
23
23
|
appendInitial(): import("./table").TableRowType | undefined;
|
package/build/src/types/float.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Float = void 0;
|
|
4
4
|
const hex_1 = require("./hex");
|
|
5
5
|
const xstring_1 = require("./xstring");
|
|
6
|
+
const integer8_1 = require("./integer8");
|
|
6
7
|
/*
|
|
7
8
|
function getNumberParts(x: number) {
|
|
8
9
|
if(isNaN(x)) {
|
|
@@ -36,6 +37,9 @@ class Float {
|
|
|
36
37
|
else if (typeof value === "string") {
|
|
37
38
|
this.value = parseFloat(value);
|
|
38
39
|
}
|
|
40
|
+
else if (value instanceof integer8_1.Integer8) {
|
|
41
|
+
this.value = Number(value.get());
|
|
42
|
+
}
|
|
39
43
|
else if (value instanceof Float) {
|
|
40
44
|
this.value = value.getRaw();
|
|
41
45
|
}
|
package/build/src/types/hex.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Integer } from "./integer";
|
|
|
3
3
|
import { XString } from "./xstring";
|
|
4
4
|
import { ICharacter } from "./_character";
|
|
5
5
|
import { INumeric } from "./_numeric";
|
|
6
|
+
import { Integer8 } from "./integer8";
|
|
6
7
|
export declare class Hex implements ICharacter {
|
|
7
8
|
private value;
|
|
8
9
|
private readonly length;
|
|
@@ -12,12 +13,12 @@ export declare class Hex implements ICharacter {
|
|
|
12
13
|
qualifiedName?: string;
|
|
13
14
|
});
|
|
14
15
|
getQualifiedName(): string | undefined;
|
|
15
|
-
set(value: ICharacter | INumeric | string | number | Integer | Float):
|
|
16
|
+
set(value: ICharacter | INumeric | string | number | Integer | Integer8 | Float): Hex;
|
|
16
17
|
getLength(): number;
|
|
17
18
|
clear(): void;
|
|
18
19
|
get(): string;
|
|
19
20
|
getOffset(input: {
|
|
20
|
-
offset?: number | INumeric | Hex;
|
|
21
|
-
length?: number | INumeric | Hex;
|
|
21
|
+
offset?: number | INumeric | Hex | Integer8;
|
|
22
|
+
length?: number | INumeric | Hex | Integer8;
|
|
22
23
|
}): XString;
|
|
23
24
|
}
|
package/build/src/types/hex.js
CHANGED
|
@@ -5,6 +5,7 @@ const _parse_1 = require("../operators/_parse");
|
|
|
5
5
|
const float_1 = require("./float");
|
|
6
6
|
const xstring_1 = require("./xstring");
|
|
7
7
|
const throw_error_1 = require("../throw_error");
|
|
8
|
+
const integer8_1 = require("./integer8");
|
|
8
9
|
class Hex {
|
|
9
10
|
constructor(input) {
|
|
10
11
|
this.length = input?.length ? input?.length : 1;
|
|
@@ -32,6 +33,20 @@ class Hex {
|
|
|
32
33
|
}
|
|
33
34
|
this.value = this.value.padStart(this.length * 2, "0");
|
|
34
35
|
}
|
|
36
|
+
else if (value instanceof integer8_1.Integer8) {
|
|
37
|
+
let hex = "";
|
|
38
|
+
if (value.get() < 0) {
|
|
39
|
+
hex = (value.get() + 0x10000000000000000n).toString(16).toUpperCase();
|
|
40
|
+
if (hex.length > this.length * 2) {
|
|
41
|
+
hex = hex.substring(hex.length - this.length * 2);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
hex = value.get().toString(16).toUpperCase();
|
|
46
|
+
hex = hex.padStart(this.length * 2, "0");
|
|
47
|
+
}
|
|
48
|
+
this.set(hex);
|
|
49
|
+
}
|
|
35
50
|
else {
|
|
36
51
|
let v = value.get();
|
|
37
52
|
if (value instanceof float_1.Float) {
|
|
@@ -69,11 +84,21 @@ class Hex {
|
|
|
69
84
|
getOffset(input) {
|
|
70
85
|
let offset = input?.offset;
|
|
71
86
|
if (offset) {
|
|
72
|
-
offset
|
|
87
|
+
if (offset instanceof integer8_1.Integer8) {
|
|
88
|
+
offset = Number(offset.get());
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
offset = (0, _parse_1.parse)(offset);
|
|
92
|
+
}
|
|
73
93
|
}
|
|
74
94
|
let length = input?.length;
|
|
75
95
|
if (length) {
|
|
76
|
-
length
|
|
96
|
+
if (length instanceof integer8_1.Integer8) {
|
|
97
|
+
length = Number(length.get());
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
length = (0, _parse_1.parse)(length);
|
|
101
|
+
}
|
|
77
102
|
}
|
|
78
103
|
if ((offset && offset * 2 > this.value.length)
|
|
79
104
|
|| (length && length * 2 > this.value.length)
|
|
@@ -5,6 +5,7 @@ const throw_error_1 = require("../throw_error");
|
|
|
5
5
|
const float_1 = require("./float");
|
|
6
6
|
const hex_1 = require("./hex");
|
|
7
7
|
const xstring_1 = require("./xstring");
|
|
8
|
+
const integer8_1 = require("./integer8");
|
|
8
9
|
exports.DIGITS = new RegExp(/^\s*-?\+?\d+\.?\d* *$/i);
|
|
9
10
|
exports.MAX_INTEGER = 2147483647;
|
|
10
11
|
exports.MIN_INTEGER = -2147483648;
|
|
@@ -49,6 +50,9 @@ class Integer {
|
|
|
49
50
|
else if (typeof value === "string") {
|
|
50
51
|
this.value = toInteger(value);
|
|
51
52
|
}
|
|
53
|
+
else if (value instanceof integer8_1.Integer8) {
|
|
54
|
+
this.set(Number(value.get()));
|
|
55
|
+
}
|
|
52
56
|
else if (value instanceof float_1.Float) {
|
|
53
57
|
this.set(Math.round(value.getRaw()));
|
|
54
58
|
}
|
|
@@ -3,14 +3,14 @@ import { Hex } from "./hex";
|
|
|
3
3
|
import { ICharacter } from "./_character";
|
|
4
4
|
import { INumeric } from "./_numeric";
|
|
5
5
|
import { Integer } from "./integer";
|
|
6
|
-
export declare class Integer8
|
|
6
|
+
export declare class Integer8 {
|
|
7
7
|
private value;
|
|
8
8
|
private readonly qualifiedName;
|
|
9
9
|
constructor(input?: {
|
|
10
10
|
qualifiedName?: string;
|
|
11
11
|
});
|
|
12
12
|
getQualifiedName(): string | undefined;
|
|
13
|
-
set(value: INumeric | ICharacter | Hex | string | number | Integer8 | Integer | Float): this;
|
|
13
|
+
set(value: INumeric | ICharacter | Hex | string | number | bigint | Integer8 | Integer | Float): this;
|
|
14
14
|
clear(): void;
|
|
15
|
-
get():
|
|
15
|
+
get(): bigint;
|
|
16
16
|
}
|
|
@@ -8,7 +8,7 @@ const xstring_1 = require("./xstring");
|
|
|
8
8
|
const digits = new RegExp(/^\s*-?\+?\d+\.?\d* *$/i);
|
|
9
9
|
class Integer8 {
|
|
10
10
|
constructor(input) {
|
|
11
|
-
this.value =
|
|
11
|
+
this.value = 0n;
|
|
12
12
|
this.qualifiedName = input?.qualifiedName;
|
|
13
13
|
}
|
|
14
14
|
getQualifiedName() {
|
|
@@ -16,7 +16,10 @@ class Integer8 {
|
|
|
16
16
|
}
|
|
17
17
|
set(value) {
|
|
18
18
|
if (typeof value === "number") {
|
|
19
|
-
this.value =
|
|
19
|
+
this.value = BigInt(value);
|
|
20
|
+
}
|
|
21
|
+
else if (typeof value === "bigint") {
|
|
22
|
+
this.value = value;
|
|
20
23
|
}
|
|
21
24
|
else if (typeof value === "string") {
|
|
22
25
|
if (value.endsWith("-")) {
|
|
@@ -28,12 +31,13 @@ class Integer8 {
|
|
|
28
31
|
else if (digits.test(value) === false) {
|
|
29
32
|
(0, throw_error_1.throwError)("CX_SY_CONVERSION_NO_NUMBER");
|
|
30
33
|
}
|
|
31
|
-
this.value =
|
|
34
|
+
this.value = BigInt(value);
|
|
32
35
|
}
|
|
33
36
|
else if (value instanceof float_1.Float) {
|
|
34
37
|
this.set(Math.round(value.getRaw()));
|
|
35
38
|
}
|
|
36
39
|
else if (value instanceof hex_1.Hex || value instanceof xstring_1.XString) {
|
|
40
|
+
// todo, can BigInt("0x" + value.get()); be used?
|
|
37
41
|
let num = parseInt(value.get(), 16);
|
|
38
42
|
// handle two complement,
|
|
39
43
|
if (value instanceof hex_1.Hex && value.getLength() >= 4) {
|
|
@@ -50,7 +54,7 @@ class Integer8 {
|
|
|
50
54
|
return this;
|
|
51
55
|
}
|
|
52
56
|
clear() {
|
|
53
|
-
this.value =
|
|
57
|
+
this.value = 0n;
|
|
54
58
|
}
|
|
55
59
|
get() {
|
|
56
60
|
return this.value;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Hex } from "./hex";
|
|
2
2
|
import { ICharacter } from "./_character";
|
|
3
3
|
import { INumeric } from "./_numeric";
|
|
4
|
+
import { Integer8 } from "./integer8";
|
|
4
5
|
export declare class XString implements ICharacter {
|
|
5
6
|
private value;
|
|
6
7
|
private readonly qualifiedName;
|
|
@@ -12,7 +13,7 @@ export declare class XString implements ICharacter {
|
|
|
12
13
|
clear(): void;
|
|
13
14
|
get(): string;
|
|
14
15
|
getOffset(input: {
|
|
15
|
-
offset?: number | INumeric | Hex;
|
|
16
|
-
length?: number | INumeric | Hex;
|
|
16
|
+
offset?: number | INumeric | Hex | Integer8;
|
|
17
|
+
length?: number | INumeric | Hex | Integer8;
|
|
17
18
|
}): XString;
|
|
18
19
|
}
|
|
@@ -5,6 +5,7 @@ const _parse_1 = require("../operators/_parse");
|
|
|
5
5
|
const float_1 = require("./float");
|
|
6
6
|
const character_1 = require("./character");
|
|
7
7
|
const throw_error_1 = require("../throw_error");
|
|
8
|
+
const integer8_1 = require("./integer8");
|
|
8
9
|
class XString {
|
|
9
10
|
constructor(input) {
|
|
10
11
|
this.value = "";
|
|
@@ -54,11 +55,21 @@ class XString {
|
|
|
54
55
|
getOffset(input) {
|
|
55
56
|
let offset = input?.offset;
|
|
56
57
|
if (offset) {
|
|
57
|
-
offset
|
|
58
|
+
if (offset instanceof integer8_1.Integer8) {
|
|
59
|
+
offset = Number(offset.get());
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
offset = (0, _parse_1.parse)(offset);
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
let length = input?.length;
|
|
60
66
|
if (length) {
|
|
61
|
-
length
|
|
67
|
+
if (length instanceof integer8_1.Integer8) {
|
|
68
|
+
length = Number(length.get());
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
length = (0, _parse_1.parse)(length);
|
|
72
|
+
}
|
|
62
73
|
}
|
|
63
74
|
if ((offset && offset * 2 > this.value.length)
|
|
64
75
|
|| (length && length * 2 > this.value.length)
|