@abaplint/runtime 2.7.149 → 2.7.151
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.
package/build/src/compare/eq.js
CHANGED
|
@@ -78,6 +78,16 @@ function eq(left, right) {
|
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
else if (right instanceof types_1.Hex) {
|
|
82
|
+
if (left instanceof types_1.Hex || left instanceof types_1.XString) {
|
|
83
|
+
return right.get() === left.get();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (right instanceof types_1.XString) {
|
|
87
|
+
if (left instanceof types_1.Hex || left instanceof types_1.XString) {
|
|
88
|
+
return right.get() === left.get();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
81
91
|
if (left instanceof types_1.Structure || right instanceof types_1.Structure) {
|
|
82
92
|
if (!(right instanceof types_1.Structure)) {
|
|
83
93
|
return eq(left.getCharacter(), right);
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initial = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
const REGEX_ZEROS = /^0+$/;
|
|
6
|
+
const REGEX_SPACES = /^ *$/;
|
|
5
7
|
function initial(val) {
|
|
6
8
|
// todo, refactor? add as method in each type instead?
|
|
7
9
|
if (val instanceof types_1.Table || val instanceof types_1.HashedTable) {
|
|
@@ -14,10 +16,10 @@ function initial(val) {
|
|
|
14
16
|
return val.get() === "00000000";
|
|
15
17
|
}
|
|
16
18
|
else if (val instanceof types_1.Numc) {
|
|
17
|
-
return val.get().match(
|
|
19
|
+
return val.get().match(REGEX_ZEROS) !== null;
|
|
18
20
|
}
|
|
19
21
|
else if (val instanceof types_1.Hex) {
|
|
20
|
-
return val.get().match(
|
|
22
|
+
return val.get().match(REGEX_ZEROS) !== null;
|
|
21
23
|
}
|
|
22
24
|
else if (val instanceof types_1.Time) {
|
|
23
25
|
return val.get() === "000000";
|
|
@@ -26,7 +28,7 @@ function initial(val) {
|
|
|
26
28
|
return val.getRaw() === 0;
|
|
27
29
|
}
|
|
28
30
|
else if (val instanceof types_1.Character) {
|
|
29
|
-
return val.get().match(
|
|
31
|
+
return val.get().match(REGEX_SPACES) !== null;
|
|
30
32
|
}
|
|
31
33
|
else if (val instanceof types_1.FieldSymbol && val.getPointer() === undefined) {
|
|
32
34
|
throw new Error("FS not assigned");
|
|
@@ -5,6 +5,41 @@ const binary_search_1 = require("../binary_search");
|
|
|
5
5
|
const compare_1 = require("../compare");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
/** startIndex = javascript index, return ABAP index */
|
|
8
|
+
function searchWithKeyEarlyExit(arr, withKey, startIndex = 0, usesTableLine, firstKeyName, firstValue) {
|
|
9
|
+
const isStructured = arr[0] instanceof types_1.Structure;
|
|
10
|
+
for (let index = startIndex; index < arr.length; index++) {
|
|
11
|
+
const a = arr[index];
|
|
12
|
+
let row = undefined;
|
|
13
|
+
if (usesTableLine === false && isStructured === true) {
|
|
14
|
+
row = a.get();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
row = isStructured ? Object.assign({ table_line: a }, a.get()) : { table_line: a };
|
|
18
|
+
}
|
|
19
|
+
if (withKey(row) === true) {
|
|
20
|
+
return {
|
|
21
|
+
found: a,
|
|
22
|
+
foundIndex: index + 1,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/*
|
|
26
|
+
console.dir(row);
|
|
27
|
+
console.dir(row[firstKeyName.toLowerCase()]);
|
|
28
|
+
console.dir(firstValue);
|
|
29
|
+
*/
|
|
30
|
+
if ((0, compare_1.gt)(row[firstKeyName.toLowerCase()], firstValue)) {
|
|
31
|
+
return {
|
|
32
|
+
found: undefined,
|
|
33
|
+
foundIndex: 0,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
found: undefined,
|
|
39
|
+
foundIndex: 0,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** startIndex = javascript index, return ABAP index */
|
|
8
43
|
function searchWithKey(arr, withKey, startIndex = 0, usesTableLine) {
|
|
9
44
|
const isStructured = arr[0] instanceof types_1.Structure;
|
|
10
45
|
for (let index = startIndex; index < arr.length; index++) {
|
|
@@ -121,8 +156,7 @@ function readTable(table, options) {
|
|
|
121
156
|
const startIndex = (0, binary_search_1.binarySearchFrom)(arr, 0, arr.length, firstKeyName.toLowerCase(), firstValue) - 1;
|
|
122
157
|
// console.dir("startindex: " + startIndex);
|
|
123
158
|
if (startIndex >= 0) {
|
|
124
|
-
|
|
125
|
-
const searchResult = searchWithKey(arr, options.withKey, startIndex, options.usesTableLine);
|
|
159
|
+
const searchResult = searchWithKeyEarlyExit(arr, options.withKey, startIndex, options.usesTableLine, firstKeyName, firstValue);
|
|
126
160
|
// console.dir(searchResult);
|
|
127
161
|
found = searchResult.found;
|
|
128
162
|
foundIndex = searchResult.foundIndex;
|
|
@@ -79,7 +79,7 @@ export declare class HashedTable implements ITable {
|
|
|
79
79
|
clear(): void;
|
|
80
80
|
set(tab: HashedTable | TableRowType): ITable;
|
|
81
81
|
getHeader(): TableRowType;
|
|
82
|
-
private
|
|
82
|
+
private cloneRow;
|
|
83
83
|
}
|
|
84
84
|
export declare class Table implements ITable {
|
|
85
85
|
private value;
|
|
@@ -109,6 +109,6 @@ export declare class Table implements ITable {
|
|
|
109
109
|
append(item: TableRowType): any;
|
|
110
110
|
appendInitial(): TableRowType;
|
|
111
111
|
sort(compareFn: (a: TableRowType, b: TableRowType) => number): void;
|
|
112
|
-
private
|
|
112
|
+
private cloneRow;
|
|
113
113
|
}
|
|
114
114
|
export {};
|
package/build/src/types/table.js
CHANGED
|
@@ -9,6 +9,7 @@ const field_symbol_1 = require("./field_symbol");
|
|
|
9
9
|
const data_reference_1 = require("./data_reference");
|
|
10
10
|
const insert_internal_1 = require("../statements/insert_internal");
|
|
11
11
|
const sort_1 = require("../statements/sort");
|
|
12
|
+
// const FEATURE_SHARED_TABLES = true;
|
|
12
13
|
var TableAccessType;
|
|
13
14
|
(function (TableAccessType) {
|
|
14
15
|
TableAccessType["standard"] = "STANDARD";
|
|
@@ -129,7 +130,7 @@ class HashedTable {
|
|
|
129
130
|
}
|
|
130
131
|
buildHashFromSimple(data) {
|
|
131
132
|
let hash = "";
|
|
132
|
-
const
|
|
133
|
+
const ttyp = this.getRowType();
|
|
133
134
|
for (const k of this.options.primaryKey.keyFields) {
|
|
134
135
|
let val = data[k.toLowerCase()];
|
|
135
136
|
if (val instanceof structure_1.Structure) {
|
|
@@ -138,12 +139,17 @@ class HashedTable {
|
|
|
138
139
|
else {
|
|
139
140
|
// convert to correct type, eg Chars have specific length, or rounding,
|
|
140
141
|
if (k === "TABLE_LINE") {
|
|
142
|
+
const rowType = (0, clone_1.clone)(ttyp);
|
|
143
|
+
rowType.set(val.get());
|
|
144
|
+
val = rowType.get();
|
|
145
|
+
}
|
|
146
|
+
else if (ttyp instanceof structure_1.Structure) {
|
|
147
|
+
const rowType = (0, clone_1.clone)(ttyp.get()[k.toLowerCase()]);
|
|
141
148
|
rowType.set(val.get());
|
|
142
149
|
val = rowType.get();
|
|
143
150
|
}
|
|
144
151
|
else {
|
|
145
|
-
|
|
146
|
-
val = rowType.get()[k.toLowerCase()].get();
|
|
152
|
+
throw new Error("HashedTable, buildHashFromSimple, unexpected type");
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
hash += k + ":" + val + "|";
|
|
@@ -159,7 +165,7 @@ class HashedTable {
|
|
|
159
165
|
return { value: undefined, subrc: 4 };
|
|
160
166
|
}
|
|
161
167
|
else {
|
|
162
|
-
const val = this.
|
|
168
|
+
const val = this.cloneRow(data);
|
|
163
169
|
for (const loopController of this.loops.values()) {
|
|
164
170
|
loopController.array.push(val);
|
|
165
171
|
}
|
|
@@ -230,7 +236,7 @@ class HashedTable {
|
|
|
230
236
|
return this.header;
|
|
231
237
|
}
|
|
232
238
|
///////////////////////////
|
|
233
|
-
|
|
239
|
+
cloneRow(item) {
|
|
234
240
|
// make sure to do conversion if needed
|
|
235
241
|
if (typeof item === "number") {
|
|
236
242
|
const tmp = (0, clone_1.clone)(this.getRowType());
|
|
@@ -355,7 +361,7 @@ class Table {
|
|
|
355
361
|
}
|
|
356
362
|
let val;
|
|
357
363
|
if (noClone === false) {
|
|
358
|
-
val = this.
|
|
364
|
+
val = this.cloneRow(item);
|
|
359
365
|
}
|
|
360
366
|
else {
|
|
361
367
|
val = item;
|
|
@@ -414,7 +420,7 @@ class Table {
|
|
|
414
420
|
return ref;
|
|
415
421
|
}
|
|
416
422
|
else {
|
|
417
|
-
const val = this.
|
|
423
|
+
const val = this.cloneRow(item);
|
|
418
424
|
this.value.push(val);
|
|
419
425
|
return val;
|
|
420
426
|
}
|
|
@@ -431,7 +437,7 @@ class Table {
|
|
|
431
437
|
this.value.sort(compareFn);
|
|
432
438
|
}
|
|
433
439
|
///////////////////////////
|
|
434
|
-
|
|
440
|
+
cloneRow(item) {
|
|
435
441
|
// make sure to do conversion if needed
|
|
436
442
|
if (typeof item === "number") {
|
|
437
443
|
const tmp = (0, clone_1.clone)(this.getRowType());
|