@abaplint/runtime 2.8.14 → 2.8.15

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.
@@ -18,6 +18,12 @@ function clone(obj) {
18
18
  // @ts-ignore
19
19
  return n;
20
20
  }
21
+ else if (obj instanceof types_1.HexUInt8) {
22
+ const n = new types_1.HexUInt8({ length: obj.getLength(), qualifiedName: obj.getQualifiedName() });
23
+ n.set(obj.get());
24
+ // @ts-ignore
25
+ return n;
26
+ }
21
27
  // @ts-ignore
22
28
  const copy = new obj.constructor();
23
29
  for (const attr in obj) {
@@ -1,17 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBit = void 0;
4
+ /* eslint-disable no-bitwise */
5
+ const types_1 = require("../types");
4
6
  function getBit(number, hex, output) {
5
- // todo: optimize for HexUInt8
6
- const charIndex = Math.floor((number.get() - 1) / 8);
7
+ const byteIndex = Math.floor((number.get() - 1) / 8);
7
8
  const bitIndex = (number.get() - 1) % 8;
8
- if (bitIndex < 0) {
9
- throw new Error("BIT_OFFSET_NOT_POSITIVE");
9
+ if (hex instanceof types_1.HexUInt8) {
10
+ let int = hex.getOffsetRaw(byteIndex);
11
+ int >>= (8 - bitIndex - 1);
12
+ int &= 1;
13
+ // @ts-ignore
14
+ output.set(int);
15
+ }
16
+ else {
17
+ if (bitIndex < 0) {
18
+ throw new Error("BIT_OFFSET_NOT_POSITIVE");
19
+ }
20
+ const h = hex.get().substr(byteIndex * 2, 2);
21
+ const parsed = parseInt(h, 16).toString(2);
22
+ const bits = parsed.padStart(8, "0");
23
+ output.set(bits.substr(bitIndex, 1));
10
24
  }
11
- const h = hex.get().substr(charIndex * 2, 2);
12
- const parsed = parseInt(h, 16).toString(2);
13
- const bits = parsed.padStart(8, "0");
14
- output.set(bits.substr(bitIndex, 1));
15
25
  }
16
26
  exports.getBit = getBit;
17
27
  //# sourceMappingURL=get_bit.js.map
@@ -1,42 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setBit = void 0;
4
+ /* eslint-disable no-bitwise */
5
+ const types_1 = require("../types");
4
6
  function setBit(number, hex, val) {
5
7
  if (number.get() <= 0) {
6
8
  throw new Error("BIT_OFFSET_NOT_POSITIVE");
7
9
  }
8
- // todo: optimize for HexUInt8
9
- const hexFull = hex.get();
10
- const fullByteLength = Math.ceil(hexFull.length / 2);
11
- const byteNum = Math.ceil(number.get() / 8);
12
- if (byteNum > fullByteLength) {
13
- return;
14
- }
15
- let pre = "";
16
- let byte = "";
17
- let post = "";
18
- if (hexFull.length > 2) {
19
- if (byteNum > 1) {
20
- pre = hexFull.substr(0, (byteNum - 1) * 2);
10
+ else if (hex instanceof types_1.HexUInt8) {
11
+ const byteIndex = Math.floor((number.get() - 1) / 8);
12
+ const bitIndex = (number.get() - 1) % 8;
13
+ let bits = hex.getOffsetRaw(byteIndex);
14
+ const bitMask = 1 << (8 - bitIndex - 1);
15
+ if (val?.get() === 0 || val?.get() === "0") {
16
+ bits &= ~bitMask;
21
17
  }
22
- byte = hexFull.substr((byteNum - 1) * 2, 2);
23
- if (fullByteLength > byteNum) {
24
- post = hexFull.substr(byteNum * 2, (fullByteLength - byteNum) * 2);
18
+ else {
19
+ bits |= bitMask;
25
20
  }
21
+ hex.setOffset(byteIndex, bits);
26
22
  }
27
23
  else {
28
- byte = hexFull;
29
- }
30
- let bits = parseInt(byte, 16);
31
- const bitMask = 1 << 8 - (number.get() - (byteNum - 1) * 8);
32
- if (val?.get() === 0 || val?.get() === "0") {
33
- bits = bits &= ~bitMask;
34
- }
35
- else {
36
- bits = bits |= bitMask;
24
+ const hexFull = hex.get();
25
+ const fullByteLength = Math.ceil(hexFull.length / 2);
26
+ const byteNum = Math.ceil(number.get() / 8);
27
+ if (byteNum > fullByteLength) {
28
+ return;
29
+ }
30
+ let pre = "";
31
+ let byte = "";
32
+ let post = "";
33
+ if (hexFull.length > 2) {
34
+ if (byteNum > 1) {
35
+ pre = hexFull.substr(0, (byteNum - 1) * 2);
36
+ }
37
+ byte = hexFull.substr((byteNum - 1) * 2, 2);
38
+ if (fullByteLength > byteNum) {
39
+ post = hexFull.substr(byteNum * 2, (fullByteLength - byteNum) * 2);
40
+ }
41
+ }
42
+ else {
43
+ byte = hexFull;
44
+ }
45
+ let bits = parseInt(byte, 16);
46
+ const bitMask = 1 << 8 - (number.get() - (byteNum - 1) * 8);
47
+ if (val?.get() === 0 || val?.get() === "0") {
48
+ bits &= ~bitMask;
49
+ }
50
+ else {
51
+ bits |= bitMask;
52
+ }
53
+ const reconstructed = pre + bits.toString(16).toUpperCase().padStart(2, "0") + post;
54
+ hex.set(reconstructed);
37
55
  }
38
- const reconstructed = pre + bits.toString(16).toUpperCase().padStart(2, "0") + post;
39
- hex.set(reconstructed);
40
56
  }
41
57
  exports.setBit = setBit;
42
58
  //# sourceMappingURL=set_bit.js.map
@@ -28,9 +28,12 @@ class Character {
28
28
  if (this.constant === true) {
29
29
  throw new Error("Changing constant");
30
30
  }
31
- if (typeof value === "string" || typeof value === "number") {
31
+ if (typeof value === "string") {
32
32
  this.value = value;
33
33
  }
34
+ else if (typeof value === "number") {
35
+ this.value = value + "";
36
+ }
34
37
  else if (value instanceof field_symbol_1.FieldSymbol) {
35
38
  if (value.getPointer() === undefined) {
36
39
  throw new Error("GETWA_NOT_ASSIGNED");
@@ -15,6 +15,7 @@ export declare class HexUInt8 implements ICharacter {
15
15
  });
16
16
  getQualifiedName(): string | undefined;
17
17
  setOffset(offset: number, value: number): void;
18
+ getOffsetRaw(offset: number): number;
18
19
  set(value: ICharacter | INumeric | string | number | Integer | Integer8 | Float | Hex | XString): HexUInt8;
19
20
  getLength(): number;
20
21
  clear(): void;
@@ -20,6 +20,10 @@ class HexUInt8 {
20
20
  // caller must validate offset
21
21
  this.value[offset] = value;
22
22
  }
23
+ getOffsetRaw(offset) {
24
+ // caller must validate offset
25
+ return this.value[offset];
26
+ }
23
27
  set(value) {
24
28
  let hexString = "";
25
29
  if (typeof value === "string") {
@@ -11,6 +11,7 @@ const insert_internal_1 = require("../statements/insert_internal");
11
11
  const sort_1 = require("../statements/sort");
12
12
  const character_1 = require("./character");
13
13
  const hex_1 = require("./hex");
14
+ const hex_uint8_1 = require("./hex_uint8");
14
15
  // const FEATURE_SHARED_TABLES = true;
15
16
  var TableAccessType;
16
17
  (function (TableAccessType) {
@@ -155,6 +156,9 @@ class HashedTable {
155
156
  else if (field instanceof hex_1.Hex && val instanceof hex_1.Hex && field.getLength() === val.getLength()) {
156
157
  val = val.get();
157
158
  }
159
+ else if (field instanceof hex_uint8_1.HexUInt8 && val instanceof hex_uint8_1.HexUInt8 && field.getLength() === val.getLength()) {
160
+ val = val.get();
161
+ }
158
162
  else {
159
163
  // convert
160
164
  const rowType = (0, clone_1.clone)(field);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.8.14",
3
+ "version": "2.8.15",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",