@abaplint/runtime 2.8.7 → 2.8.9

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.
@@ -15,6 +15,10 @@ function parse(val) {
15
15
  return parseInt(val, 10);
16
16
  }
17
17
  }
18
+ else if (val instanceof types_1.Integer) {
19
+ // optimize, as this is the most common case
20
+ return val.get();
21
+ }
18
22
  else if (val instanceof types_1.Float) {
19
23
  return val.getRaw();
20
24
  }
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setBit = void 0;
4
4
  function setBit(number, hex, val) {
5
+ if (number.get() <= 0) {
6
+ throw new Error("BIT_OFFSET_NOT_POSITIVE");
7
+ }
5
8
  let hexFull = hex.get();
6
9
  if (hexFull === "") {
7
10
  hexFull = "00";
@@ -17,7 +17,7 @@ export declare class FieldSymbol {
17
17
  unassign(): void;
18
18
  isAssigned(): boolean;
19
19
  getPointer(): any;
20
- dereference(): INumeric | ICharacter | Float | import("./integer8").Integer8 | ABAPObject | Table | Structure | undefined;
20
+ dereference(): INumeric | ICharacter | Float | import("packages/runtime/src/types").Integer8 | ABAPObject | Table | Structure | undefined;
21
21
  clear(): void | Structure | undefined;
22
22
  get(): any;
23
23
  appendInitial(): import("./table").TableRowType | undefined;
@@ -94,6 +94,10 @@ class Hex {
94
94
  else {
95
95
  offset = (0, _parse_1.parse)(offset);
96
96
  }
97
+ if (offset * 2 > this.value.length
98
+ || offset < 0) {
99
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
100
+ }
97
101
  }
98
102
  let length = input?.length;
99
103
  if (length) {
@@ -103,24 +107,27 @@ class Hex {
103
107
  else {
104
108
  length = (0, _parse_1.parse)(length);
105
109
  }
110
+ if (length * 2 > this.value.length
111
+ || length < 0) {
112
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
113
+ }
114
+ }
115
+ // NOTE: this only copies the minimal length of the string,
116
+ if (offset !== undefined && length !== undefined) {
117
+ if (offset * 2 + length * 2 > this.value.length) {
118
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
119
+ }
120
+ return new xstring_1.XString().set(this.value.substr(offset * 2, length * 2));
106
121
  }
107
- if ((offset && offset * 2 > this.value.length)
108
- || (length && length * 2 > this.value.length)
109
- || (offset && length && offset * 2 + length * 2 > this.value.length)
110
- || (offset && offset < 0)
111
- || (length && length < 0)) {
112
- (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
122
+ else if (offset !== undefined) {
123
+ return new xstring_1.XString().set(this.value.substr(offset * 2));
113
124
  }
114
- let ret = this.value;
115
- if (offset) {
116
- ret = ret.substr(offset * 2);
125
+ else if (length !== undefined) {
126
+ return new xstring_1.XString().set(this.value.substr(0, length * 2));
117
127
  }
118
- if (length !== undefined) {
119
- ret = ret.substr(0, length * 2);
128
+ else {
129
+ throw new Error("hex: getOffset, unexpected");
120
130
  }
121
- const r = new xstring_1.XString();
122
- r.set(ret);
123
- return r;
124
131
  }
125
132
  }
126
133
  exports.Hex = Hex;
@@ -61,6 +61,10 @@ class XString {
61
61
  else {
62
62
  offset = (0, _parse_1.parse)(offset);
63
63
  }
64
+ if (offset * 2 > this.value.length
65
+ || offset < 0) {
66
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
67
+ }
64
68
  }
65
69
  let length = input?.length;
66
70
  if (length) {
@@ -70,26 +74,27 @@ class XString {
70
74
  else {
71
75
  length = (0, _parse_1.parse)(length);
72
76
  }
77
+ if (length * 2 > this.value.length
78
+ || length < 0) {
79
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
80
+ }
81
+ }
82
+ // NOTE: this only copies the minimal length of the string,
83
+ if (offset !== undefined && length !== undefined) {
84
+ if (offset * 2 + length * 2 > this.value.length) {
85
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
86
+ }
87
+ return new XString().set(this.value.substr(offset * 2, length * 2));
73
88
  }
74
- if ((offset && offset * 2 > this.value.length)
75
- || (length && length * 2 > this.value.length)
76
- || (offset && length && offset * 2 + length * 2 > this.value.length)
77
- || (offset && offset < 0)
78
- || (length && length < 0)) {
79
- (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
89
+ else if (offset !== undefined) {
90
+ return new XString().set(this.value.substr(offset * 2));
80
91
  }
81
- let ret = this.value;
82
- if (offset) {
83
- // @ts-ignore
84
- ret = ret.substr(offset * 2);
92
+ else if (length !== undefined) {
93
+ return new XString().set(this.value.substr(0, length * 2));
85
94
  }
86
- if (length !== undefined) {
87
- // @ts-ignore
88
- ret = ret.substr(0, length * 2);
95
+ else {
96
+ throw new Error("xstring: getOffset, unexpected");
89
97
  }
90
- const r = new XString();
91
- r.set(ret);
92
- return r;
93
98
  }
94
99
  }
95
100
  exports.XString = XString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.8.7",
3
+ "version": "2.8.9",
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.4.1",
35
35
  "mocha": "^10.3.0",
36
36
  "source-map-support": "^0.5.21",
37
- "typescript": "^5.3.3"
37
+ "typescript": "^5.4.2"
38
38
  },
39
39
  "dependencies": {
40
40
  "temporal-polyfill": "^0.2.3"