@abaplint/runtime 2.8.25 → 2.8.27

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,4 +1,4 @@
1
- import { ABAPObject, HashedTable, Structure, Table } from "../types";
1
+ import { ABAPObject, HashedTable, Integer8, Structure, Table } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
- export declare function gt(left: number | string | ICharacter | INumeric | ABAPObject | Structure | Table | HashedTable, right: number | string | ICharacter | INumeric | ABAPObject | Structure | Table | HashedTable): boolean;
4
+ export declare function gt(left: number | string | ICharacter | INumeric | ABAPObject | Structure | Table | HashedTable | Integer8, right: number | string | ICharacter | INumeric | ABAPObject | Structure | Table | HashedTable | Integer8): boolean;
@@ -5,6 +5,43 @@ const _parse_1 = require("../operators/_parse");
5
5
  const types_1 = require("../types");
6
6
  const integer_1 = require("../types/integer");
7
7
  function gt(left, right) {
8
+ if (right instanceof integer_1.Integer) {
9
+ if (left instanceof integer_1.Integer) {
10
+ return left.get() > right.get();
11
+ }
12
+ else if (left instanceof types_1.Float) {
13
+ return left.getRaw() > right.get();
14
+ }
15
+ else if (left instanceof types_1.Character) {
16
+ return (0, _parse_1.parse)(left) > right.get();
17
+ }
18
+ else if (left instanceof types_1.Integer8) {
19
+ const l = left.get();
20
+ const r = BigInt(right.get());
21
+ return l > r;
22
+ }
23
+ }
24
+ else if (right instanceof types_1.Float) {
25
+ if (left instanceof types_1.Float) {
26
+ return left.getRaw() > right.getRaw();
27
+ }
28
+ else if (left instanceof integer_1.Integer) {
29
+ return left.get() > right.getRaw();
30
+ }
31
+ else if (left instanceof types_1.Integer8) {
32
+ const l = left.get();
33
+ const r = BigInt(right.getRaw());
34
+ return l > r;
35
+ }
36
+ }
37
+ else if (right instanceof types_1.Integer8) {
38
+ if (left instanceof types_1.Table || left instanceof types_1.HashedTable) {
39
+ throw new Error("runtime_todo, gt TABLE");
40
+ }
41
+ const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
42
+ const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
43
+ return l > r;
44
+ }
8
45
  if (left instanceof types_1.FieldSymbol) {
9
46
  if (left.getPointer() === undefined) {
10
47
  throw new Error("GETWA_NOT_ASSIGNED");
@@ -20,12 +57,12 @@ function gt(left, right) {
20
57
  if (left instanceof types_1.Table || right instanceof types_1.Table || left instanceof types_1.HashedTable || right instanceof types_1.HashedTable) {
21
58
  throw new Error("runtime_todo, gt TABLE");
22
59
  }
23
- if (left instanceof types_1.Hex || right instanceof types_1.Hex || left instanceof types_1.HexUInt8 || right instanceof types_1.HexUInt8) {
60
+ else if (left instanceof types_1.Hex || right instanceof types_1.Hex || left instanceof types_1.HexUInt8 || right instanceof types_1.HexUInt8) {
24
61
  return gt_with_hex(left, right);
25
62
  }
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));
63
+ if (left instanceof types_1.Integer8) {
64
+ const l = left.get();
65
+ const r = BigInt((0, _parse_1.parse)(right));
29
66
  return l > r;
30
67
  }
31
68
  let l = undefined;
@@ -67,12 +104,13 @@ function gt(left, right) {
67
104
  if (l === undefined) {
68
105
  return true; // todo, not sure this is correct
69
106
  }
70
- if (r === undefined) {
107
+ else if (r === undefined) {
71
108
  return true; // todo, not sure this is correct
72
109
  }
73
110
  return l > r;
74
111
  }
75
112
  exports.gt = gt;
113
+ ///////////////////////////////////////////////////////////////////
76
114
  function gt_with_hex(left, right) {
77
115
  const left_hex = get_hex_from_parameter(left);
78
116
  const right_hex = get_hex_from_parameter(right);
@@ -131,45 +131,43 @@ class HashedTable {
131
131
  }
132
132
  buildHashFromSimple(data) {
133
133
  let hash = "";
134
- const ttyp = this.getRowType();
134
+ const tableRowType = this.getRowType();
135
135
  for (const k of this.options.primaryKey.keyFields) {
136
136
  let val = data[k.toLowerCase()];
137
- if (val instanceof structure_1.Structure) {
138
- val = val.getCharacter();
137
+ // convert to correct type, eg Chars have specific length, or rounding,
138
+ if (k === "TABLE_LINE") {
139
+ const row = (0, clone_1.clone)(tableRowType);
140
+ row.set(val.get());
141
+ val = row.get();
139
142
  }
140
- else {
141
- // convert to correct type, eg Chars have specific length, or rounding,
142
- if (k === "TABLE_LINE") {
143
- const rowType = (0, clone_1.clone)(ttyp);
144
- rowType.set(val.get());
145
- val = rowType.get();
143
+ else if (tableRowType instanceof structure_1.Structure) {
144
+ const field = tableRowType.get()[k.toLowerCase()];
145
+ // if types match, there is no need to clone
146
+ if (field instanceof string_1.String && val instanceof string_1.String) {
147
+ val = val.get();
148
+ }
149
+ else if (field instanceof character_1.Character && val instanceof character_1.Character && field.getLength() === val.getLength()) {
150
+ val = val.get();
151
+ }
152
+ else if (field instanceof hex_1.Hex && val instanceof hex_1.Hex && field.getLength() === val.getLength()) {
153
+ val = val.get();
154
+ }
155
+ else if (field instanceof hex_uint8_1.HexUInt8 && val instanceof hex_uint8_1.HexUInt8 && field.getLength() === val.getLength()) {
156
+ val = val.get();
146
157
  }
147
- else if (ttyp instanceof structure_1.Structure) {
148
- const field = ttyp.get()[k.toLowerCase()];
149
- // if types match, there is no need to clone
150
- if (field instanceof string_1.String && val instanceof string_1.String) {
151
- val = val.get();
152
- }
153
- else if (field instanceof character_1.Character && val instanceof character_1.Character && field.getLength() === val.getLength()) {
154
- val = val.get();
155
- }
156
- else if (field instanceof hex_1.Hex && val instanceof hex_1.Hex && field.getLength() === val.getLength()) {
157
- val = val.get();
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
- }
162
- else {
163
- // convert
164
- const rowType = (0, clone_1.clone)(field);
165
- rowType.set(val.get());
166
- val = rowType.get();
167
- }
158
+ else if (val instanceof structure_1.Structure) {
159
+ val = val.getCharacter();
168
160
  }
169
161
  else {
170
- throw new Error("HashedTable, buildHashFromSimple, unexpected type");
162
+ // convert
163
+ const row = (0, clone_1.clone)(field);
164
+ row.set(val.get());
165
+ val = row.get();
171
166
  }
172
167
  }
168
+ else {
169
+ throw new Error("HashedTable, buildHashFromSimple, unexpected type");
170
+ }
173
171
  hash += k + ":" + val + "|";
174
172
  }
175
173
  return hash;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.8.25",
3
+ "version": "2.8.27",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -37,6 +37,6 @@
37
37
  "typescript": "^5.4.5"
38
38
  },
39
39
  "dependencies": {
40
- "temporal-polyfill": "^0.2.4"
40
+ "temporal-polyfill": "^0.2.5"
41
41
  }
42
42
  }