@abaplint/runtime 2.8.15 → 2.8.17
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.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.eq = void 0;
|
|
|
4
4
|
/* eslint-disable max-len */
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const _parse_1 = require("../operators/_parse");
|
|
7
|
+
const initial_1 = require("./initial");
|
|
7
8
|
function compareTables(left, right) {
|
|
8
9
|
const leftArray = left.array();
|
|
9
10
|
const rightArray = right.array();
|
|
@@ -106,10 +107,37 @@ function eq(left, right) {
|
|
|
106
107
|
return false;
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
else if (right instanceof types_1.Hex || right instanceof types_1.
|
|
110
|
-
if (left instanceof types_1.Hex || left instanceof types_1.
|
|
110
|
+
else if (right instanceof types_1.Hex || right instanceof types_1.XString || right instanceof types_1.HexUInt8) {
|
|
111
|
+
if (left instanceof types_1.Hex || left instanceof types_1.HexUInt8) {
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
if (right.getLength && right.getLength() !== left.getLength()) {
|
|
114
|
+
return (0, initial_1.initial)(left) && (0, initial_1.initial)(right);
|
|
115
|
+
}
|
|
116
|
+
return right.get() === left.get();
|
|
117
|
+
}
|
|
118
|
+
else if (left instanceof types_1.XString) {
|
|
111
119
|
return right.get() === left.get();
|
|
112
120
|
}
|
|
121
|
+
/*
|
|
122
|
+
} else if (right instanceof HexUInt8) {
|
|
123
|
+
if (left instanceof XString) {
|
|
124
|
+
return right.get() === left.get();
|
|
125
|
+
} else if (left instanceof HexUInt8) {
|
|
126
|
+
// https://stackoverflow.com/questions/21553528/how-to-test-for-equality-in-arraybuffer-dataview-and-typedarray
|
|
127
|
+
const llen = left.getLength();
|
|
128
|
+
if (llen === right.getLength()) {
|
|
129
|
+
// todo: this can be optimized by creating multi byte views?
|
|
130
|
+
// new DataView(this.value.buffer).setInt32(0, 0, true);
|
|
131
|
+
for (let i = 0; i < llen; i++) {
|
|
132
|
+
if (right.getOffsetRaw(i) !== left.getOffsetRaw(i)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
return initial(left) && initial(right);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
*/
|
|
113
141
|
}
|
|
114
142
|
else if (right instanceof types_1.ABAPObject) {
|
|
115
143
|
if (left instanceof types_1.ABAPObject) {
|
package/build/src/types/hex.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HexUInt8 = void 0;
|
|
4
|
+
/* eslint-disable no-bitwise */
|
|
4
5
|
const _parse_1 = require("../operators/_parse");
|
|
5
6
|
const float_1 = require("./float");
|
|
6
7
|
const xstring_1 = require("./xstring");
|
|
7
8
|
const throw_error_1 = require("../throw_error");
|
|
8
9
|
const integer8_1 = require("./integer8");
|
|
9
10
|
const REGEXP = /^(?![A-F0-9])/;
|
|
11
|
+
const LUT_HEX_4b = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
|
|
12
|
+
const LUT_HEX_8b = new Array(0x100);
|
|
13
|
+
for (let n = 0; n < 0x100; n++) {
|
|
14
|
+
LUT_HEX_8b[n] = `${LUT_HEX_4b[(n >>> 4) & 0xF]}${LUT_HEX_4b[n & 0xF]}`;
|
|
15
|
+
}
|
|
10
16
|
class HexUInt8 {
|
|
11
17
|
constructor(input) {
|
|
12
18
|
this.length = input?.length ? input?.length : 1;
|
|
@@ -65,6 +71,12 @@ class HexUInt8 {
|
|
|
65
71
|
hexString = hexString.padStart(this.length * 2, "0");
|
|
66
72
|
}
|
|
67
73
|
}
|
|
74
|
+
else if (value instanceof HexUInt8 || value instanceof xstring_1.XString) {
|
|
75
|
+
hexString = value.get();
|
|
76
|
+
if (hexString.length < this.length * 2) {
|
|
77
|
+
hexString = hexString.padEnd(this.length * 2, "0");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
68
80
|
else {
|
|
69
81
|
const v = value.get();
|
|
70
82
|
if (value instanceof float_1.Float) {
|
|
@@ -99,7 +111,13 @@ class HexUInt8 {
|
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
113
|
get() {
|
|
102
|
-
return Buffer.from(this.value).toString("hex").toUpperCase();
|
|
114
|
+
// return Buffer.from(this.value).toString("hex").toUpperCase();
|
|
115
|
+
let out = "";
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
117
|
+
for (let idx = 0; idx < this.value.length; idx++) {
|
|
118
|
+
out += LUT_HEX_8b[this.value[idx]];
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
103
121
|
}
|
|
104
122
|
getOffset(input) {
|
|
105
123
|
let offset = input?.offset;
|
|
@@ -143,8 +161,13 @@ class HexUInt8 {
|
|
|
143
161
|
console.dir(this.value.subarray(offset, length ? offset + length : undefined));
|
|
144
162
|
console.dir(Buffer.from(this.value.subarray(offset, length ? offset + length : undefined)));
|
|
145
163
|
*/
|
|
146
|
-
const str = Buffer.from(this.value.subarray(offset, length ? offset + length : undefined)).toString("hex")
|
|
147
|
-
|
|
164
|
+
// const str = Buffer.from(this.value.subarray(offset, length ? offset + length : undefined)).toString("hex").toUpperCase();
|
|
165
|
+
let str = "";
|
|
166
|
+
const until = length ? offset + length : this.value.length;
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
168
|
+
for (let idx = offset; idx < until; idx++) {
|
|
169
|
+
str += LUT_HEX_8b[this.value[idx]];
|
|
170
|
+
}
|
|
148
171
|
return new xstring_1.XString().set(str);
|
|
149
172
|
}
|
|
150
173
|
}
|