@abaplint/runtime 2.3.19 → 2.3.20

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,23 +5,24 @@ export * from "./ceil";
5
5
  export * from "./concat_lines_of";
6
6
  export * from "./condense";
7
7
  export * from "./cos";
8
+ export * from "./count_any_of";
8
9
  export * from "./count";
9
10
  export * from "./escape";
10
11
  export * from "./find";
11
12
  export * from "./floor";
12
13
  export * from "./frac";
13
14
  export * from "./insert";
15
+ export * from "./ipow";
14
16
  export * from "./lines";
15
17
  export * from "./match";
16
18
  export * from "./matches";
17
- export * from "./ipow";
18
19
  export * from "./nmax";
19
- export * from "./count_any_of";
20
20
  export * from "./nmin";
21
21
  export * from "./repeat";
22
22
  export * from "./replace";
23
23
  export * from "./reverse";
24
24
  export * from "./round";
25
+ export * from "./segment";
25
26
  export * from "./shift_left";
26
27
  export * from "./sign";
27
28
  export * from "./sin";
@@ -22,23 +22,24 @@ __exportStar(require("./ceil"), exports);
22
22
  __exportStar(require("./concat_lines_of"), exports);
23
23
  __exportStar(require("./condense"), exports);
24
24
  __exportStar(require("./cos"), exports);
25
+ __exportStar(require("./count_any_of"), exports);
25
26
  __exportStar(require("./count"), exports);
26
27
  __exportStar(require("./escape"), exports);
27
28
  __exportStar(require("./find"), exports);
28
29
  __exportStar(require("./floor"), exports);
29
30
  __exportStar(require("./frac"), exports);
30
31
  __exportStar(require("./insert"), exports);
32
+ __exportStar(require("./ipow"), exports);
31
33
  __exportStar(require("./lines"), exports);
32
34
  __exportStar(require("./match"), exports);
33
35
  __exportStar(require("./matches"), exports);
34
- __exportStar(require("./ipow"), exports);
35
36
  __exportStar(require("./nmax"), exports);
36
- __exportStar(require("./count_any_of"), exports);
37
37
  __exportStar(require("./nmin"), exports);
38
38
  __exportStar(require("./repeat"), exports);
39
39
  __exportStar(require("./replace"), exports);
40
40
  __exportStar(require("./reverse"), exports);
41
41
  __exportStar(require("./round"), exports);
42
+ __exportStar(require("./segment"), exports);
42
43
  __exportStar(require("./shift_left"), exports);
43
44
  __exportStar(require("./sign"), exports);
44
45
  __exportStar(require("./sin"), exports);
@@ -0,0 +1,8 @@
1
+ import { String } from "../types";
2
+ import { ICharacter } from "../types/_character";
3
+ import { INumeric } from "../types/_numeric";
4
+ export declare function segment(input: {
5
+ val: ICharacter | string;
6
+ index: INumeric | number;
7
+ sep: ICharacter | string;
8
+ }): String;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.segment = void 0;
4
+ const throw_error_1 = require("../throw_error");
5
+ const types_1 = require("../types");
6
+ function segment(input) {
7
+ let val = input.val;
8
+ if (typeof val !== "string") {
9
+ val = val.get();
10
+ }
11
+ let sep = input.sep;
12
+ if (typeof sep !== "string") {
13
+ sep = sep.get();
14
+ }
15
+ let index = input.index;
16
+ if (typeof index !== "number") {
17
+ index = index.get();
18
+ }
19
+ if (index === 0 || sep.length === 0) {
20
+ (0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
21
+ }
22
+ const array = val.split(sep);
23
+ if (index < 0) {
24
+ array.reverse();
25
+ index = Math.abs(index);
26
+ }
27
+ if (index > array.length) {
28
+ (0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
29
+ }
30
+ return new types_1.String().set(array[index - 1]);
31
+ }
32
+ exports.segment = segment;
33
+ //# sourceMappingURL=segment.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.to_mixed = void 0;
4
4
  /* eslint-disable @typescript-eslint/ban-types */
5
+ const throw_error_1 = require("../throw_error");
5
6
  const types_1 = require("../types");
6
7
  function to_mixed(input) {
7
8
  let sep = input.sep;
@@ -12,11 +13,11 @@ function to_mixed(input) {
12
13
  sep = sep.get();
13
14
  }
14
15
  if (sep.length === 0) {
15
- throw "CX_SY_STRG_PAR_VAL";
16
+ (0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
16
17
  }
17
18
  const min = 1;
18
19
  if (min < 0) {
19
- throw "CX_SY_STRG_PAR_VAL";
20
+ (0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
20
21
  }
21
22
  let val = input.val;
22
23
  if (typeof val !== "string") {
@@ -10,7 +10,7 @@ export declare class OffsetLength {
10
10
  private readonly offset?;
11
11
  private readonly length?;
12
12
  private readonly isHex;
13
- constructor(obj: Character | Hex | XString | Structure, options: IOffsetLengthOptions);
13
+ constructor(obj: ICharacter | Character | Hex | XString | Structure, options: IOffsetLengthOptions);
14
14
  get(): string;
15
15
  set(value: ICharacter | string): void;
16
16
  }
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.divide = void 0;
4
+ const throw_error_1 = require("../throw_error");
4
5
  const types_1 = require("../types");
5
6
  const _parse_1 = require("./_parse");
6
7
  // todo, this will only work when the target value is an integer?
7
8
  function divide(left, right) {
8
9
  const r = (0, _parse_1.parse)(right);
9
10
  if (r === 0) {
10
- // @ts-ignore
11
- if (abap.Classes["CX_SY_ZERODIVIDE"] !== undefined) {
12
- // @ts-ignore
13
- throw new abap.Classes["CX_SY_ZERODIVIDE"]();
14
- }
15
- else {
16
- throw "Global class CX_SY_ZERODIVIDE not found";
17
- }
11
+ (0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
18
12
  }
19
13
  const val = (0, _parse_1.parse)(left) / r;
20
14
  return new types_1.Float().set(val);
@@ -2,16 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cast = void 0;
4
4
  const compare_1 = require("../compare");
5
- function throwError() {
6
- // @ts-ignore
7
- if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
8
- // @ts-ignore
9
- throw new abap.Classes["CX_SY_MOVE_CAST_ERROR"]();
10
- }
11
- else {
12
- throw "Global class CX_SY_MOVE_CAST_ERROR not found";
13
- }
14
- }
5
+ const throw_error_1 = require("../throw_error");
15
6
  // todo, field symbols as input?
16
7
  // todo, local classes?
17
8
  // check with javascript instanceof?
@@ -35,7 +26,7 @@ async function cast(target, source) {
35
26
  // using "instanceof" is probably wrong in some cases,
36
27
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
37
28
  if (source.get() instanceof targetClass === false) {
38
- throwError();
29
+ (0, throw_error_1.throwError)("CX_SY_MOVE_CAST_ERROR");
39
30
  }
40
31
  }
41
32
  else if (checkIntf === true && (targetClass === null || targetClass === void 0 ? void 0 : targetClass.INTERNAL_TYPE) === "INTF") {
@@ -62,7 +53,7 @@ async function cast(target, source) {
62
53
  }
63
54
  const isImplemented = list.some(i => i === targetName);
64
55
  if (isImplemented === false) {
65
- throwError();
56
+ (0, throw_error_1.throwError)("CX_SY_MOVE_CAST_ERROR");
66
57
  }
67
58
  }
68
59
  target.set(source);
@@ -2,23 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createData = void 0;
4
4
  const clone_1 = require("../clone");
5
+ const throw_error_1 = require("../throw_error");
5
6
  const types_1 = require("../types");
6
- function throwGlobalException(name) {
7
- // @ts-ignore
8
- if (abap.Classes[name] !== undefined) {
9
- // @ts-ignore
10
- throw new abap.Classes[name]();
11
- }
12
- else {
13
- throw `Global class ${name} not found`;
14
- }
15
- }
16
7
  function createData(target, options) {
17
8
  // console.dir(options);
18
9
  if ((options === null || options === void 0 ? void 0 : options.name) && (options === null || options === void 0 ? void 0 : options.table)) {
19
10
  // @ts-ignore
20
11
  if (abap.DDIC[options.name] === undefined) {
21
- throwGlobalException("CX_SY_CREATE_DATA_ERROR");
12
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
22
13
  }
23
14
  // @ts-ignore
24
15
  target.assign(new abap.types.Table(abap.DDIC[options.name].type));
@@ -26,7 +17,7 @@ function createData(target, options) {
26
17
  else if (options === null || options === void 0 ? void 0 : options.name) {
27
18
  // @ts-ignore
28
19
  if (abap.DDIC[options.name] === undefined) {
29
- throwGlobalException("CX_SY_CREATE_DATA_ERROR");
20
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
30
21
  }
31
22
  // @ts-ignore
32
23
  target.assign((0, clone_1.clone)(abap.DDIC[options.name].type));
@@ -1,7 +1,9 @@
1
1
  import { ICharacter } from "../types/_character";
2
+ import { INumeric } from "../types/_numeric";
2
3
  export declare type replaceInput = {
3
4
  target: ICharacter;
4
- sectionLength?: ICharacter;
5
+ sectionLength?: INumeric;
6
+ sectionOffset?: INumeric;
5
7
  regex?: ICharacter;
6
8
  all: boolean;
7
9
  with: ICharacter;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.replace = void 0;
4
+ const offset_length_1 = require("../offset_length");
4
5
  function escapeRegExp(text) {
5
6
  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
6
7
  }
@@ -26,6 +27,12 @@ function replace(input) {
26
27
  found = temp.match(input.regex.get()) !== null;
27
28
  search = new RegExp(input.regex.get(), ignoreCase + allOccurrences);
28
29
  }
30
+ else if (input.sectionLength && input.sectionOffset) {
31
+ new offset_length_1.OffsetLength(input.target, { length: input.sectionLength, offset: input.sectionOffset }).set(input.with);
32
+ // @ts-ignore
33
+ abap.builtin.sy.get().subrc.set(0);
34
+ return;
35
+ }
29
36
  else {
30
37
  throw "REPLACE, unexpected input";
31
38
  }
@@ -0,0 +1 @@
1
+ export declare function throwError(name: string): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwError = void 0;
4
+ function throwError(name) {
5
+ // @ts-ignore
6
+ if (abap.Classes[name] !== undefined) {
7
+ // @ts-ignore
8
+ throw new abap.Classes[name]();
9
+ }
10
+ else {
11
+ throw "Global class name not found";
12
+ }
13
+ }
14
+ exports.throwError = throwError;
15
+ //# sourceMappingURL=throw_error.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Character = void 0;
4
4
  const _parse_1 = require("../operators/_parse");
5
+ const throw_error_1 = require("../throw_error");
5
6
  // eslint-disable-next-line prefer-const
6
7
  let featureFixLength = true;
7
8
  class Character {
@@ -58,14 +59,7 @@ class Character {
58
59
  if ((input.offset && input.offset >= this.length)
59
60
  || (input.offset && input.offset < 0)
60
61
  || (input.length && input.length < 0)) {
61
- // @ts-ignore
62
- if (abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"] !== undefined) {
63
- // @ts-ignore
64
- throw new abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"]();
65
- }
66
- else {
67
- throw "Global class CX_SY_RANGE_OUT_OF_BOUNDS not found";
68
- }
62
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
69
63
  }
70
64
  let ret = this.value;
71
65
  if (input === null || input === void 0 ? void 0 : input.offset) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Integer = void 0;
4
+ const throw_error_1 = require("../throw_error");
4
5
  const float_1 = require("./float");
5
6
  const hex_1 = require("./hex");
6
7
  const xstring_1 = require("./xstring");
@@ -21,14 +22,7 @@ class Integer {
21
22
  }
22
23
  else if (typeof value === "string") {
23
24
  if (/^\s*-?\+?\d+\.?\d*$/i.test(value) === false) {
24
- // @ts-ignore
25
- if (abap.Classes["CX_SY_CONVERSION_NO_NUMBER"] !== undefined) {
26
- // @ts-ignore
27
- throw new abap.Classes["CX_SY_CONVERSION_NO_NUMBER"]();
28
- }
29
- else {
30
- throw "Global class CX_SY_CONVERSION_NO_NUMBER not found";
31
- }
25
+ (0, throw_error_1.throwError)("CX_SY_CONVERSION_NO_NUMBER");
32
26
  }
33
27
  this.value = parseInt(value, 10);
34
28
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.String = void 0;
4
4
  const _parse_1 = require("../operators/_parse");
5
+ const throw_error_1 = require("../throw_error");
5
6
  const character_1 = require("./character");
6
7
  const integer_1 = require("./integer");
7
8
  class String {
@@ -48,14 +49,7 @@ class String {
48
49
  if ((input.offset && input.offset > this.value.length)
49
50
  || (input.offset && input.offset < 0)
50
51
  || (input.length && input.length < 0)) {
51
- // @ts-ignore
52
- if (abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"] !== undefined) {
53
- // @ts-ignore
54
- throw new abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"]();
55
- }
56
- else {
57
- throw "Global class CX_SY_RANGE_OUT_OF_BOUNDS not found";
58
- }
52
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
59
53
  }
60
54
  let ret = this.value;
61
55
  if (input === null || input === void 0 ? void 0 : input.offset) {
@@ -6,6 +6,7 @@ const field_symbol_1 = require("./field_symbol");
6
6
  const table_1 = require("./table");
7
7
  const _parse_1 = require("../operators/_parse");
8
8
  const character_1 = require("./character");
9
+ const throw_error_1 = require("../throw_error");
9
10
  class Structure {
10
11
  constructor(fields, qualifiedName) {
11
12
  this.value = fields;
@@ -89,14 +90,7 @@ class Structure {
89
90
  if ((input.offset && input.offset >= val.length)
90
91
  || (input.offset && input.offset < 0)
91
92
  || (input.length && input.length < 0)) {
92
- // @ts-ignore
93
- if (abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"] !== undefined) {
94
- // @ts-ignore
95
- throw new abap.Classes["CX_SY_RANGE_OUT_OF_BOUNDS"]();
96
- }
97
- else {
98
- throw "Global class CX_SY_RANGE_OUT_OF_BOUNDS not found";
99
- }
93
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
100
94
  }
101
95
  let ret = val;
102
96
  if (input === null || input === void 0 ? void 0 : input.offset) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.3.19",
3
+ "version": "2.3.20",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",