@abaplint/runtime 2.10.48 → 2.10.50

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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.strlen = strlen;
4
+ const integer_factory_1 = require("../integer_factory");
4
5
  const types_1 = require("../types");
5
6
  function strlen(input) {
6
7
  let str = "";
@@ -13,6 +14,11 @@ function strlen(input) {
13
14
  else {
14
15
  str = input.val.get();
15
16
  }
16
- return new types_1.Integer().set(str.length);
17
+ if (str.length <= 200) {
18
+ return integer_factory_1.IntegerFactory.get(str.length);
19
+ }
20
+ else {
21
+ return new types_1.Integer().set(str.length);
22
+ }
17
23
  }
18
24
  //# sourceMappingURL=strlen.js.map
@@ -0,0 +1,5 @@
1
+ import { Character } from "./types";
2
+ export declare class CharacterFactory {
3
+ private static readonly map;
4
+ static get(length: number, value: string): Character;
5
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CharacterFactory = void 0;
4
+ const types_1 = require("./types");
5
+ class CharacterFactory {
6
+ static get(length, value) {
7
+ if (CharacterFactory.map[value] === undefined) {
8
+ CharacterFactory.map[value] = new types_1.Character(length).set(value).setConstant();
9
+ }
10
+ return CharacterFactory.map[value];
11
+ }
12
+ }
13
+ exports.CharacterFactory = CharacterFactory;
14
+ CharacterFactory.map = {};
15
+ //# sourceMappingURL=character_factory.js.map
@@ -16,6 +16,7 @@ import { MemoryConsole } from "./console/memory_console";
16
16
  import { buildDbTableName } from "./prefix";
17
17
  import { IntegerFactory } from "./integer_factory";
18
18
  import { dynamicCallLookup } from "./dynamic_call_lookup";
19
+ import { CharacterFactory } from "./character_factory";
19
20
  export { RFC, types, DB, MemoryConsole };
20
21
  export type RuntimeDatabaseOptions = {
21
22
  schemaPrefix?: string;
@@ -66,8 +67,9 @@ export declare class ABAP {
66
67
  expandDynamic: typeof expandDynamic;
67
68
  buildDbTableName: typeof buildDbTableName;
68
69
  ClassicError: typeof ClassicError;
69
- IntegerFactory: typeof IntegerFactory;
70
70
  dynamicCallLookup: typeof dynamicCallLookup;
71
+ IntegerFactory: typeof IntegerFactory;
72
+ CharacterFactory: typeof CharacterFactory;
71
73
  readonly context: Context;
72
74
  readonly dbo: RuntimeDatabaseOptions;
73
75
  constructor(input?: RuntimeOptions);
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "MemoryConsole", { enumerable: true, get: functio
23
23
  const prefix_1 = require("./prefix");
24
24
  const integer_factory_1 = require("./integer_factory");
25
25
  const dynamic_call_lookup_1 = require("./dynamic_call_lookup");
26
+ const character_factory_1 = require("./character_factory");
26
27
  class ABAP {
27
28
  constructor(input) {
28
29
  // global objects
@@ -46,8 +47,9 @@ class ABAP {
46
47
  this.expandDynamic = expand_dynamic_1.expandDynamic;
47
48
  this.buildDbTableName = prefix_1.buildDbTableName;
48
49
  this.ClassicError = classic_error_1.ClassicError;
49
- this.IntegerFactory = integer_factory_1.IntegerFactory;
50
50
  this.dynamicCallLookup = dynamic_call_lookup_1.dynamicCallLookup;
51
+ this.IntegerFactory = integer_factory_1.IntegerFactory;
52
+ this.CharacterFactory = character_factory_1.CharacterFactory;
51
53
  this.context = new context_1.Context();
52
54
  this.console = input?.console ? input?.console : new standard_out_console_1.StandardOutConsole();
53
55
  this.context.console = this.console;
@@ -1,5 +1,5 @@
1
1
  import { Integer } from "./types";
2
2
  export declare class IntegerFactory {
3
3
  private static readonly map;
4
- static get(num: number): Integer;
4
+ static get(value: number): Integer;
5
5
  }
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IntegerFactory = void 0;
4
4
  const types_1 = require("./types");
5
5
  class IntegerFactory {
6
- static get(num) {
7
- if (IntegerFactory.map[num] === undefined) {
8
- IntegerFactory.map[num] = new types_1.Integer().set(num).setConstant();
6
+ static get(value) {
7
+ if (IntegerFactory.map[value] === undefined) {
8
+ IntegerFactory.map[value] = new types_1.Integer().set(value).setConstant();
9
9
  }
10
- return IntegerFactory.map[num];
10
+ return IntegerFactory.map[value];
11
11
  }
12
12
  }
13
13
  exports.IntegerFactory = IntegerFactory;
@@ -17,14 +17,14 @@ function minus(left, right) {
17
17
  }
18
18
  return minus(left, right.getPointer());
19
19
  }
20
- if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
20
+ if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
21
+ return new types_1.Integer().set(left.get() - right.get());
22
+ }
23
+ else if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
21
24
  const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left));
22
25
  const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right));
23
26
  return new types_1.Integer8().set(l - r);
24
27
  }
25
- else if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
26
- return new types_1.Integer().set(left.get() - right.get());
27
- }
28
28
  else if (typeof left === "number" && typeof right === "number"
29
29
  && Number.isInteger(left) && Number.isInteger(right)) {
30
30
  return new types_1.Integer().set(left - right);
@@ -1,14 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.condense = condense;
4
+ const ENDS_WITH_SPACE = / +$/;
5
+ const BEGINS_WITH_SPACE = /^ +/;
6
+ const ANY_SPACES = / */g;
7
+ const MULTIPLE_SPACES_REGEX = / {2,}/g;
4
8
  function condense(input, options) {
5
- let trimmed = input.get().replace(/ +$/, "");
6
- trimmed = trimmed.replace(/^ +/, "");
9
+ let trimmed = input.get().replace(ENDS_WITH_SPACE, "");
10
+ trimmed = trimmed.replace(BEGINS_WITH_SPACE, "");
7
11
  if (options.nogaps) {
8
- trimmed = trimmed.replace(/ */g, "");
12
+ trimmed = trimmed.replace(ANY_SPACES, "");
9
13
  }
10
14
  else {
11
- trimmed = trimmed.replace(/ {2,}/g, " ");
15
+ trimmed = trimmed.replace(MULTIPLE_SPACES_REGEX, " ");
12
16
  }
13
17
  input.set(trimmed);
14
18
  }
@@ -1,7 +1,6 @@
1
1
  import { append } from "./append";
2
2
  import { assert } from "./assert";
3
3
  import { assign } from "./assign";
4
- import { clear } from "./clear";
5
4
  import { commit } from "./commit";
6
5
  import { concatenate } from "./concatenate";
7
6
  import { condense } from "./condense";
@@ -56,7 +55,6 @@ export declare class Statements {
56
55
  assert: typeof assert;
57
56
  assign: typeof assign;
58
57
  cast: typeof cast;
59
- clear: typeof clear;
60
58
  collect: typeof collect;
61
59
  commit: typeof commit;
62
60
  concatenate: typeof concatenate;
@@ -4,7 +4,6 @@ exports.Statements = void 0;
4
4
  const append_1 = require("./append");
5
5
  const assert_1 = require("./assert");
6
6
  const assign_1 = require("./assign");
7
- const clear_1 = require("./clear");
8
7
  const commit_1 = require("./commit");
9
8
  const concatenate_1 = require("./concatenate");
10
9
  const condense_1 = require("./condense");
@@ -61,7 +60,6 @@ class Statements {
61
60
  this.assert = assert_1.assert;
62
61
  this.assign = assign_1.assign;
63
62
  this.cast = cast_1.cast;
64
- this.clear = clear_1.clear;
65
63
  this.collect = collect_1.collect;
66
64
  this.commit = commit_1.commit;
67
65
  this.concatenate = concatenate_1.concatenate;
@@ -73,7 +73,8 @@ function readTable(table, options) {
73
73
  if (table.getPointer() === undefined) {
74
74
  throw new Error("GETWA_NOT_ASSIGNED");
75
75
  }
76
- return readTable(table.getPointer(), options);
76
+ // return readTable(table.getPointer(), options);
77
+ table = table.getPointer();
77
78
  }
78
79
  // check if it is a primary index read specified with WITH KEY instead of WITH TABLE KEY
79
80
  if (options?.withTableKey === undefined
@@ -257,8 +258,8 @@ function readTable(table, options) {
257
258
  if (binarySubrc) {
258
259
  subrc = binarySubrc;
259
260
  }
260
- else if ((options?.binarySearch === true || options?.keyName !== undefined)
261
- && subrc === 4) {
261
+ else if (subrc === 4
262
+ && (options?.binarySearch === true || options?.keyName !== undefined)) {
262
263
  subrc = 8;
263
264
  }
264
265
  // @ts-ignore
@@ -8,6 +8,8 @@ const hex_1 = require("./hex");
8
8
  const xstring_1 = require("./xstring");
9
9
  const integer8_1 = require("./integer8");
10
10
  const hex_uint8_1 = require("./hex_uint8");
11
+ const character_1 = require("./character");
12
+ const string_1 = require("./string");
11
13
  exports.DIGITS = new RegExp(/^\s*-?\+?\d+\.?\d* *$/i);
12
14
  exports.MAX_INTEGER = 2147483647;
13
15
  exports.MIN_INTEGER = -2147483648;
@@ -54,8 +56,14 @@ class Integer {
54
56
  if (typeof value === "number") {
55
57
  this.value = Math.round(value);
56
58
  }
57
- else if (typeof value === "string") {
58
- this.value = toInteger(value);
59
+ else if (value instanceof Integer) {
60
+ this.set(value.get());
61
+ }
62
+ else if (value instanceof character_1.Character) {
63
+ this.value = toInteger(value.get());
64
+ }
65
+ else if (value instanceof string_1.String) {
66
+ this.value = toInteger(value.get());
59
67
  }
60
68
  else if (value instanceof integer8_1.Integer8) {
61
69
  this.set(Number(value.get()));
@@ -75,6 +83,9 @@ class Integer {
75
83
  }
76
84
  this.set(num);
77
85
  }
86
+ else if (typeof value === "string") {
87
+ this.value = toInteger(value);
88
+ }
78
89
  else {
79
90
  this.set(value.get());
80
91
  }
@@ -147,6 +147,7 @@ class HashedTable {
147
147
  buildHashFromSimple(data) {
148
148
  let hash = "";
149
149
  const tableRowType = this.getRowType();
150
+ const isStructured = tableRowType instanceof structure_1.Structure;
150
151
  for (const k of this.options.primaryKey.keyFields) {
151
152
  let val = data[k.toLowerCase()];
152
153
  // convert to correct type, eg Chars have specific length, or rounding,
@@ -155,7 +156,7 @@ class HashedTable {
155
156
  row.set(val.get());
156
157
  val = row.get();
157
158
  }
158
- else if (tableRowType instanceof structure_1.Structure) {
159
+ else if (isStructured === true) {
159
160
  const field = tableRowType.get()[k.toLowerCase()];
160
161
  // if types match, there is no need to clone
161
162
  if (field instanceof string_1.String && val instanceof string_1.String) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.10.48",
3
+ "version": "2.10.50",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "@types/chai": "^4.3.20",
33
33
  "@types/mocha": "^10.0.10",
34
34
  "chai": "^4.5.0",
35
- "mocha": "^11.1.0",
35
+ "mocha": "^11.2.2",
36
36
  "source-map-support": "^0.5.21",
37
37
  "typescript": "^5.8.3"
38
38
  },
@@ -1,4 +0,0 @@
1
- import { ICharacter } from "../types/_character";
2
- import { INumeric } from "../types/_numeric";
3
- import { Table } from "../types";
4
- export declare function clear(value: ICharacter | INumeric | Table): void;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clear = clear;
4
- function clear(value) {
5
- value.clear();
6
- }
7
- //# sourceMappingURL=clear.js.map