@abaplint/runtime 2.4.8 → 2.4.10

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.
@@ -5,6 +5,7 @@ const throw_error_1 = require("../throw_error");
5
5
  const float_1 = require("./float");
6
6
  const hex_1 = require("./hex");
7
7
  const xstring_1 = require("./xstring");
8
+ const digits = new RegExp(/^\s*-?\+?\d+\.?\d*$/i);
8
9
  class Integer {
9
10
  constructor(input) {
10
11
  this.value = 0;
@@ -17,11 +18,11 @@ class Integer {
17
18
  if (typeof value === "number") {
18
19
  this.value = Math.round(value);
19
20
  }
20
- else if (typeof value === "string" && value.trim().length === 0) {
21
- this.value = 0;
22
- }
23
21
  else if (typeof value === "string") {
24
- if (/^\s*-?\+?\d+\.?\d*$/i.test(value) === false) {
22
+ if (value.trim().length === 0) {
23
+ value = "0";
24
+ }
25
+ else if (digits.test(value) === false) {
25
26
  (0, throw_error_1.throwError)("CX_SY_CONVERSION_NO_NUMBER");
26
27
  }
27
28
  this.value = parseInt(value, 10);
@@ -34,6 +34,7 @@ export declare class Table {
34
34
  private readonly loops;
35
35
  private readonly options;
36
36
  private readonly qualifiedName;
37
+ private readonly isStructured;
37
38
  private secondaryIndexes;
38
39
  constructor(rowType: TableRowType, options?: ITableOptions, qualifiedName?: string);
39
40
  getKeyByName(name: string): ITableKey | undefined;
@@ -49,7 +50,7 @@ export declare class Table {
49
50
  getHeader(): TableRowType;
50
51
  insertIndex(item: TableRowType, index: number): TableRowType;
51
52
  deleteIndex(index: number): void;
52
- append(item: TableRowType, cloneRow?: boolean): FieldSymbol | DataReference | TableRowType;
53
+ append(item: TableRowType): FieldSymbol | DataReference | TableRowType;
53
54
  appendInitial(): TableRowType;
54
55
  sort(compareFn: (a: TableRowType, b: TableRowType) => number): void;
55
56
  private getValue;
@@ -4,6 +4,7 @@ exports.Table = exports.LoopIndex = exports.TableAccessType = void 0;
4
4
  const integer_1 = require("./integer");
5
5
  const string_1 = require("./string");
6
6
  const clone_1 = require("../clone");
7
+ const structure_1 = require("./structure");
7
8
  const field_symbol_1 = require("./field_symbol");
8
9
  const data_reference_1 = require("./data_reference");
9
10
  const insert_internal_1 = require("../statements/insert_internal");
@@ -29,6 +30,7 @@ class Table {
29
30
  this.loops = new Set();
30
31
  this.rowType = rowType;
31
32
  this.options = options;
33
+ this.isStructured = rowType instanceof structure_1.Structure;
32
34
  if ((options === null || options === void 0 ? void 0 : options.withHeader) === true) {
33
35
  this.header = (0, clone_1.clone)(this.rowType);
34
36
  }
@@ -114,7 +116,12 @@ class Table {
114
116
  insertIndex(item, index) {
115
117
  this.secondaryIndexes = {};
116
118
  const val = this.getValue(item);
117
- this.value.splice(index, 0, val);
119
+ if (index === 0) {
120
+ this.value.unshift(val);
121
+ }
122
+ else {
123
+ this.value.splice(index, 0, val);
124
+ }
118
125
  for (const l of this.loops.values()) {
119
126
  if (l.index <= index) {
120
127
  l.index++;
@@ -142,7 +149,7 @@ class Table {
142
149
  }
143
150
  }
144
151
  }
145
- append(item, cloneRow = true) {
152
+ append(item) {
146
153
  this.secondaryIndexes = {};
147
154
  if (item instanceof field_symbol_1.FieldSymbol) {
148
155
  const p = item.getPointer();
@@ -159,11 +166,9 @@ class Table {
159
166
  return ref;
160
167
  }
161
168
  else {
162
- const val = this.getValue(item, cloneRow);
163
- const p = (0, clone_1.clone)(this.rowType);
164
- p.set(val);
165
- this.value.push(p);
166
- return p;
169
+ const val = this.getValue(item);
170
+ this.value.push(val);
171
+ return val;
167
172
  }
168
173
  }
169
174
  appendInitial() {
@@ -178,7 +183,7 @@ class Table {
178
183
  this.value.sort(compareFn);
179
184
  }
180
185
  ///////////////////////////
181
- getValue(item, cloneRow = true) {
186
+ getValue(item) {
182
187
  // make sure to do conversion if needed
183
188
  if (typeof item === "number") {
184
189
  const tmp = (0, clone_1.clone)(this.getRowType());
@@ -189,15 +194,19 @@ class Table {
189
194
  const tmp = (0, clone_1.clone)(this.getRowType());
190
195
  tmp.set(new string_1.String().set(item));
191
196
  return tmp;
197
+ // @ts-ignore
198
+ // eslint-disable-next-line max-len
199
+ }
200
+ else if (this.isStructured === true && item.getQualifiedName && this.rowType.getQualifiedName && item.getQualifiedName() === this.rowType.getQualifiedName()) {
201
+ // types match, so no need to do conversions, just clone the item
202
+ const val = (0, clone_1.clone)(item);
203
+ return val;
192
204
  }
193
- else if (cloneRow === true) {
205
+ else {
194
206
  const tmp = (0, clone_1.clone)(this.getRowType());
195
207
  tmp.set(item);
196
208
  return tmp;
197
209
  }
198
- else {
199
- return item;
200
- }
201
210
  }
202
211
  }
203
212
  exports.Table = Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.4.8",
3
+ "version": "2.4.10",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -36,6 +36,6 @@
36
36
  "typescript": "^4.8.4"
37
37
  },
38
38
  "dependencies": {
39
- "temporal-polyfill": "^0.0.8"
39
+ "temporal-polyfill": "^0.1.0"
40
40
  }
41
41
  }