@abaplint/runtime 2.5.63 → 2.5.64

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.
@@ -82,8 +82,8 @@ function describe(input) {
82
82
  }
83
83
  if (input.table) {
84
84
  // @ts-ignore
85
- abap.builtin.sy.get().tfill.set(input.table.array().length);
86
- (_a = input.lines) === null || _a === void 0 ? void 0 : _a.set(input.table.array().length);
85
+ abap.builtin.sy.get().tfill.set(input.table.getArrayLength());
86
+ (_a = input.lines) === null || _a === void 0 ? void 0 : _a.set(input.table.getArrayLength());
87
87
  }
88
88
  }
89
89
  exports.describe = describe;
@@ -96,7 +96,7 @@ function insertInternal(options) {
96
96
  }
97
97
  }
98
98
  else if (options.initial === true) {
99
- let index = options.table.array().length;
99
+ let index = options.table.getArrayLength();
100
100
  if (options.index) {
101
101
  index = options.index.get() - 1;
102
102
  }
@@ -122,7 +122,7 @@ function insertInternal(options) {
122
122
  }
123
123
  else if (data) {
124
124
  // todo, for now it just appends, this is not correct, but currently the table type is not known
125
- const val = options.table.insertIndex(data, options.table.array().length);
125
+ const val = options.table.insertIndex(data, options.table.getArrayLength());
126
126
  if (options.assigning) {
127
127
  options.assigning.assign(val);
128
128
  }
@@ -78,35 +78,35 @@ function loop(table, options) {
78
78
  else {
79
79
  array = table.array();
80
80
  }
81
- const loopIndex = table.startLoop(loopFrom);
81
+ const loopController = table.startLoop(loopFrom, loopTo, array);
82
82
  let entered = false;
83
83
  try {
84
84
  const isStructured = array[0] instanceof types_1.Structure;
85
- while (loopIndex.index < loopTo) {
86
- if (loopIndex.index > array.length) {
85
+ while (loopController.index < loopController.loopTo) {
86
+ if (loopController.index > array.length) {
87
87
  break;
88
88
  }
89
- const current = array[loopIndex.index];
89
+ const current = array[loopController.index];
90
90
  if (options === null || options === void 0 ? void 0 : options.where) {
91
91
  const row = isStructured ? current.get() : { table_line: current };
92
92
  if ((yield __await(options.where(row))) === false) {
93
- loopIndex.index++;
93
+ loopController.index++;
94
94
  continue;
95
95
  }
96
96
  }
97
97
  // @ts-ignore
98
- abap.builtin.sy.get().tabix.set(loopIndex.index + 1);
98
+ abap.builtin.sy.get().tabix.set(loopController.index + 1);
99
99
  entered = true;
100
100
  yield yield __await(current);
101
- loopIndex.index++;
101
+ loopController.index++;
102
102
  if ((options === null || options === void 0 ? void 0 : options.to) === undefined && (options === null || options === void 0 ? void 0 : options.usingKey) === undefined) {
103
103
  // extra rows might have been inserted inside the loop
104
- loopTo = array.length;
104
+ loopController.loopTo = array.length;
105
105
  }
106
106
  }
107
107
  }
108
108
  finally {
109
- table.unregisterLoop(loopIndex);
109
+ table.unregisterLoop(loopController);
110
110
  // @ts-ignore
111
111
  abap.builtin.sy.get().subrc.set(entered ? 0 : 4);
112
112
  }
@@ -51,6 +51,9 @@ function sort(input, options) {
51
51
  sort(pnt, options);
52
52
  return;
53
53
  }
54
+ if (input instanceof types_1.HashedTable) {
55
+ throw new Error("Sort hashed table, ugh?");
56
+ }
54
57
  if (options === null || options === void 0 ? void 0 : options.by) {
55
58
  if (options.by.length === 0) {
56
59
  throw "SortByLengthZero";
@@ -5,8 +5,6 @@ const _parse_1 = require("../operators/_parse");
5
5
  const throw_error_1 = require("../throw_error");
6
6
  const field_symbol_1 = require("./field_symbol");
7
7
  const structure_1 = require("./structure");
8
- // eslint-disable-next-line prefer-const
9
- let featureFixLength = true;
10
8
  class Character {
11
9
  constructor(length, extra) {
12
10
  this.constant = false;
@@ -48,7 +46,7 @@ class Character {
48
46
  if (this.value.length > this.length) {
49
47
  this.value = this.value.substr(0, this.length);
50
48
  }
51
- else if (featureFixLength && this.value.length < this.length) {
49
+ else if (this.value.length < this.length) {
52
50
  this.value.padEnd(this.length, " ");
53
51
  }
54
52
  return this;
@@ -69,12 +67,7 @@ class Character {
69
67
  return this.length;
70
68
  }
71
69
  clear() {
72
- if (featureFixLength) {
73
- this.value = " ".repeat(this.length);
74
- }
75
- else {
76
- this.value = "";
77
- }
70
+ this.value = " ".repeat(this.length);
78
71
  }
79
72
  get() {
80
73
  return this.value;
@@ -9,9 +9,11 @@ export declare enum TableAccessType {
9
9
  index = "INDEX",
10
10
  any = "ANY"
11
11
  }
12
- export declare class LoopIndex {
12
+ export declare class LoopController {
13
13
  index: number;
14
- constructor(start: number);
14
+ loopTo: number;
15
+ array: any[];
16
+ constructor(from: number, loopTo: number, array: any[]);
15
17
  }
16
18
  export type ITableKey = {
17
19
  name: string;
@@ -34,6 +36,7 @@ interface ITable {
34
36
  set(tab: Table | HashedTable | TableRowType): ITable;
35
37
  getHeader(): TableRowType;
36
38
  }
39
+ export declare let featureHashedTables: boolean;
37
40
  export declare class TableFactory {
38
41
  static construct(rowType: TableRowType, options?: ITableOptions, qualifiedName?: string): Table | HashedTable;
39
42
  }
@@ -62,9 +65,9 @@ export declare class HashedTable implements ITable {
62
65
  value: TableRowType | undefined;
63
66
  subrc: number;
64
67
  };
65
- array(): readonly any[];
66
- startLoop(start?: number): LoopIndex;
67
- unregisterLoop(loop: LoopIndex): void;
68
+ array(): any[];
69
+ startLoop(from: number, to: number, array: any[]): LoopController;
70
+ unregisterLoop(loop: LoopController): void;
68
71
  insertIndex(_item: TableRowType, _index: number): void;
69
72
  append(_item: TableRowType): void;
70
73
  getQualifiedName(): string | undefined;
@@ -90,10 +93,10 @@ export declare class Table implements ITable {
90
93
  getSecondaryIndex(name: string): TableRowType[];
91
94
  getQualifiedName(): string | undefined;
92
95
  getOptions(): ITableOptions;
93
- startLoop(start?: number): LoopIndex;
94
- unregisterLoop(loop: LoopIndex): void;
96
+ startLoop(from: number, to: number, array: any[]): LoopController;
97
+ unregisterLoop(loop: LoopController): void;
95
98
  getRowType(): TableRowType;
96
- array(): readonly any[];
99
+ array(): any[];
97
100
  clear(): void;
98
101
  set(tab: Table | TableRowType): this;
99
102
  getHeader(): TableRowType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Table = exports.HashedTable = exports.SortedTable = exports.TableFactory = exports.LoopIndex = exports.TableAccessType = void 0;
3
+ exports.Table = exports.HashedTable = exports.SortedTable = exports.TableFactory = exports.featureHashedTables = exports.LoopController = 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");
@@ -17,14 +17,16 @@ var TableAccessType;
17
17
  TableAccessType["index"] = "INDEX";
18
18
  TableAccessType["any"] = "ANY";
19
19
  })(TableAccessType = exports.TableAccessType || (exports.TableAccessType = {}));
20
- class LoopIndex {
21
- constructor(start) {
22
- this.index = start;
20
+ class LoopController {
21
+ constructor(from, loopTo, array) {
22
+ this.index = from;
23
+ this.loopTo = loopTo;
24
+ this.array = array;
23
25
  }
24
26
  }
25
- exports.LoopIndex = LoopIndex;
27
+ exports.LoopController = LoopController;
26
28
  // eslint-disable-next-line prefer-const
27
- let featureHashedTables = false;
29
+ exports.featureHashedTables = true;
28
30
  class TableFactory {
29
31
  static construct(rowType, options, qualifiedName) {
30
32
  var _a;
@@ -39,7 +41,7 @@ class TableFactory {
39
41
  withHeader: false,
40
42
  };
41
43
  }
42
- if (featureHashedTables === true && ((_a = options.primaryKey) === null || _a === void 0 ? void 0 : _a.type) === TableAccessType.hashed) {
44
+ if (exports.featureHashedTables === true && ((_a = options.primaryKey) === null || _a === void 0 ? void 0 : _a.type) === TableAccessType.hashed) {
43
45
  return new HashedTable(rowType, options, qualifiedName);
44
46
  }
45
47
  else {
@@ -136,15 +138,15 @@ class HashedTable {
136
138
  return this.value[hash];
137
139
  }
138
140
  insert(data) {
139
- if (this.loops.size !== 0) {
140
- throw new Error("Hash table insert inside LOOP");
141
- }
142
141
  const hash = this.buildHashFromData(data);
143
142
  if (this.value[hash] !== undefined) {
144
143
  return { value: undefined, subrc: 4 };
145
144
  }
146
145
  else {
147
146
  const val = this.getValue(data);
147
+ for (const loopController of this.loops.values()) {
148
+ loopController.array.push(val);
149
+ }
148
150
  this.value[hash] = val;
149
151
  return { value: val, subrc: 0 };
150
152
  }
@@ -157,8 +159,8 @@ class HashedTable {
157
159
  }
158
160
  return ret;
159
161
  }
160
- startLoop(start = 0) {
161
- const l = new LoopIndex(start);
162
+ startLoop(from, to, array) {
163
+ const l = new LoopController(from, to, array);
162
164
  this.loops.add(l);
163
165
  return l;
164
166
  }
@@ -268,8 +270,8 @@ class Table {
268
270
  getOptions() {
269
271
  return this.options;
270
272
  }
271
- startLoop(start = 0) {
272
- const l = new LoopIndex(start);
273
+ startLoop(from, to, array) {
274
+ const l = new LoopController(from, to, array);
273
275
  this.loops.add(l);
274
276
  return l;
275
277
  }
@@ -326,12 +328,15 @@ class Table {
326
328
  if (index === 0) {
327
329
  this.value.unshift(val);
328
330
  }
331
+ else if (index === this.value.length) {
332
+ this.value.push(val);
333
+ }
329
334
  else {
330
335
  this.value.splice(index, 0, val);
331
336
  }
332
- for (const l of this.loops.values()) {
333
- if (l.index <= index) {
334
- l.index++;
337
+ for (const loopController of this.loops.values()) {
338
+ if (index <= loopController.index) {
339
+ loopController.index++;
335
340
  }
336
341
  }
337
342
  return val;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.5.63",
3
+ "version": "2.5.64",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",