@abaplint/runtime 2.7.27 → 2.7.29

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.
@@ -1,5 +1,5 @@
1
- import { Integer } from "../types";
1
+ import { Hex, Integer, XString } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  export declare function xstrlen(input: {
4
- val: ICharacter | string;
4
+ val: ICharacter | string | Hex | XString;
5
5
  }): Integer;
@@ -1,14 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.bitnot = void 0;
4
- /*eslint no-bitwise: ["error", { "allow": ["~"] }] */
5
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_NOT
4
+ const builtin_1 = require("../builtin");
6
5
  const types_1 = require("../types");
6
+ // note: javascript bitwise negate doesnt work well for long hex values
7
7
  function bitnot(right) {
8
- const right16 = parseInt(right.get(), 16);
9
- const not = ~right16;
8
+ const len = (0, builtin_1.xstrlen)({ val: right }).get();
9
+ let not = "";
10
+ for (let i = 0; i < len; i++) {
11
+ const byte = right.getOffset({ offset: i, length: 1 });
12
+ let binary = parseInt(byte.get(), 16).toString(2).padStart(8, "0");
13
+ binary = binary.replace(/0/g, "2");
14
+ binary = binary.replace(/1/g, "0");
15
+ binary = binary.replace(/2/g, "1");
16
+ const hex = parseInt(binary, 2).toString(16).padStart(2, "0");
17
+ not += hex;
18
+ }
10
19
  const ret = new types_1.Hex({ length: right.get().length / 2 });
11
- ret.set(not);
20
+ ret.set(not.toUpperCase());
12
21
  return ret;
13
22
  }
14
23
  exports.bitnot = bitnot;
@@ -7,7 +7,7 @@ const xstring_1 = require("./xstring");
7
7
  class Hex {
8
8
  constructor(input) {
9
9
  this.length = (input === null || input === void 0 ? void 0 : input.length) ? input === null || input === void 0 ? void 0 : input.length : 1;
10
- this.value = "0".repeat(this.length * 2);
10
+ this.clear();
11
11
  }
12
12
  set(value) {
13
13
  if (typeof value === "string") {
@@ -52,7 +52,7 @@ class Hex {
52
52
  return this.length;
53
53
  }
54
54
  clear() {
55
- this.value = "";
55
+ this.value = "0".repeat(this.length * 2);
56
56
  }
57
57
  get() {
58
58
  return this.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.7.27",
3
+ "version": "2.7.29",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "chai": "^4.3.7",
35
35
  "mocha": "^10.2.0",
36
36
  "source-map-support": "^0.5.21",
37
- "typescript": "^5.1.3"
37
+ "typescript": "^5.1.6"
38
38
  },
39
39
  "dependencies": {
40
40
  "temporal-polyfill": "^0.1.1"