@abaplint/runtime 2.13.30 → 2.13.31

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,12 +1,13 @@
1
1
  import { ICharacter } from "../types/_character";
2
2
  import { INumeric } from "../types/_numeric";
3
3
  import { String } from "../types/string";
4
+ import { FieldSymbol } from "../types";
4
5
  export interface IReplaceInput {
5
- val: string | ICharacter;
6
- sub?: string | ICharacter;
7
- with?: string | ICharacter;
8
- regex?: string | ICharacter;
9
- pcre?: string | ICharacter;
6
+ val: string | ICharacter | FieldSymbol;
7
+ sub?: string | ICharacter | FieldSymbol;
8
+ with?: string | ICharacter | FieldSymbol;
9
+ regex?: string | ICharacter | FieldSymbol;
10
+ pcre?: string | ICharacter | FieldSymbol;
10
11
  off?: INumeric;
11
12
  len?: INumeric;
12
13
  occ?: INumeric;
@@ -4,58 +4,71 @@ exports.replace = replace;
4
4
  const string_1 = require("../types/string");
5
5
  const abap_regex_1 = require("../abap_regex");
6
6
  const types_1 = require("../types");
7
+ function dereference(input) {
8
+ if (input instanceof types_1.FieldSymbol) {
9
+ const pointer = input.getPointer();
10
+ if (pointer === undefined) {
11
+ throw new Error("GETWA_NOT_ASSIGNED");
12
+ }
13
+ return pointer;
14
+ }
15
+ return input;
16
+ }
7
17
  function replace(input) {
18
+ const source = dereference(input.val);
19
+ const withSource = dereference(input.with);
20
+ const subSource = dereference(input.sub);
21
+ const regexInput = dereference(input.pcre || input.regex);
8
22
  let val = undefined;
9
- if (typeof input.val === "string") {
10
- val = input.val;
23
+ if (typeof source === "string") {
24
+ val = source;
11
25
  }
12
- else if (input.val instanceof types_1.Character) {
13
- val = input.val.getTrimEnd();
26
+ else if (source instanceof types_1.Character) {
27
+ val = source.getTrimEnd();
14
28
  }
15
29
  else {
16
- val = input.val.get();
30
+ val = source.get();
17
31
  }
18
32
  let wi = undefined;
19
- if (typeof input.with === "string") {
20
- wi = input.with;
33
+ if (typeof withSource === "string") {
34
+ wi = withSource;
21
35
  }
22
- else if (input.with instanceof types_1.Character) {
23
- wi = input.with.getTrimEnd();
36
+ else if (withSource instanceof types_1.Character) {
37
+ wi = withSource.getTrimEnd();
24
38
  }
25
- else if (input.with) {
26
- wi = input.with.get();
39
+ else if (withSource) {
40
+ wi = withSource.get();
27
41
  }
28
42
  let sub = undefined;
29
- if (typeof input.sub === "string") {
30
- sub = input.sub;
43
+ if (typeof subSource === "string") {
44
+ sub = subSource;
31
45
  }
32
- else if (input.sub instanceof types_1.Character) {
33
- sub = input.sub.getTrimEnd();
46
+ else if (subSource instanceof types_1.Character) {
47
+ sub = subSource.getTrimEnd();
34
48
  }
35
- else if (input.sub) {
36
- sub = input.sub.get();
49
+ else if (subSource) {
50
+ sub = subSource.get();
37
51
  }
38
52
  if (sub !== undefined) {
39
53
  sub = abap_regex_1.ABAPRegExp.escapeRegExp(sub);
40
54
  }
41
- const regexInput = input.pcre || input.regex;
42
55
  if (typeof regexInput === "string") {
43
56
  sub = new RegExp(abap_regex_1.ABAPRegExp.convert(regexInput), "g");
44
57
  }
45
58
  else if (regexInput) {
46
59
  sub = new RegExp(abap_regex_1.ABAPRegExp.convert(regexInput.get()), "g");
47
60
  }
48
- if (input.off && input.len && typeof input.val === "string") {
61
+ if (input.off && input.len && typeof source === "string") {
49
62
  const offset = input.off.get();
50
63
  const length = input.len.get();
51
64
  val = val.substring(0, offset) + wi + val.substring(offset + length);
52
65
  }
53
- else if (input.off && input.len && !(typeof input.val === "string")) {
66
+ else if (input.off && input.len && !(typeof source === "string")) {
54
67
  const offset = input.off.get();
55
68
  const length = input.len.get();
56
- val = input.val.getOffset({ offset: 0, length: offset }).get() +
69
+ val = source.getOffset({ offset: 0, length: offset }).get() +
57
70
  wi +
58
- input.val.getOffset({ offset: offset + length }).get();
71
+ source.getOffset({ offset: offset + length }).get();
59
72
  }
60
73
  else if (input.occ === undefined && sub && wi !== undefined) {
61
74
  if (typeof sub === "string") {
@@ -1,5 +1,5 @@
1
- import { Integer } from "../types";
1
+ import { FieldSymbol, Integer } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  export declare function strlen(input: {
4
- val: ICharacter | string;
4
+ val: ICharacter | FieldSymbol | string;
5
5
  }): Integer;
@@ -4,15 +4,26 @@ exports.strlen = strlen;
4
4
  const integer_factory_1 = require("../integer_factory");
5
5
  const types_1 = require("../types");
6
6
  function strlen(input) {
7
+ let source;
8
+ if (input.val instanceof types_1.FieldSymbol) {
9
+ const pointer = input.val.getPointer();
10
+ if (pointer === undefined) {
11
+ throw new Error("GETWA_NOT_ASSIGNED");
12
+ }
13
+ source = pointer;
14
+ }
15
+ else {
16
+ source = input.val;
17
+ }
7
18
  let str = "";
8
- if (typeof input.val === "string") {
9
- str = input.val;
19
+ if (typeof source === "string") {
20
+ str = source;
10
21
  }
11
- else if (input.val instanceof types_1.Character) {
12
- str = input.val.getTrimEnd();
22
+ else if (source instanceof types_1.Character) {
23
+ str = source.getTrimEnd();
13
24
  }
14
25
  else {
15
- str = input.val.get();
26
+ str = source.get();
16
27
  }
17
28
  if (str.length <= 200) {
18
29
  return integer_factory_1.IntegerFactory.get(str.length);
@@ -1,6 +1,7 @@
1
+ import { FieldSymbol } from "../types";
1
2
  import { ICharacter } from "../types/_character";
2
3
  interface ISubstringAfterInput {
3
- val: ICharacter | string;
4
+ val: ICharacter | FieldSymbol | string;
4
5
  sub?: ICharacter | string;
5
6
  regex?: ICharacter | string;
6
7
  pcre?: ICharacter | string;
@@ -5,9 +5,20 @@ const abap_regex_1 = require("../abap_regex");
5
5
  const types_1 = require("../types");
6
6
  const string_1 = require("../types/string");
7
7
  function substring_after(input) {
8
- let val = typeof input.val === "string" ? input.val : input.val.get();
9
- if (input.val instanceof types_1.Character) {
10
- val = input.val.getTrimEnd();
8
+ let source;
9
+ if (input.val instanceof types_1.FieldSymbol) {
10
+ const pointer = input.val.getPointer();
11
+ if (pointer === undefined) {
12
+ throw new Error("GETWA_NOT_ASSIGNED");
13
+ }
14
+ source = pointer;
15
+ }
16
+ else {
17
+ source = input.val;
18
+ }
19
+ let val = typeof source === "string" ? source : source.get();
20
+ if (source instanceof types_1.Character) {
21
+ val = source.getTrimEnd();
11
22
  }
12
23
  let reg = "";
13
24
  if (typeof input.regex === "string") {
@@ -1,6 +1,7 @@
1
+ import { FieldSymbol } from "../types";
1
2
  import { ICharacter } from "../types/_character";
2
3
  export declare function substring_before(input: {
3
- val: ICharacter | string;
4
+ val: ICharacter | FieldSymbol | string;
4
5
  sub?: ICharacter | string;
5
6
  regex?: ICharacter | string;
6
7
  }): ICharacter;
@@ -5,15 +5,26 @@ const abap_regex_1 = require("../abap_regex");
5
5
  const types_1 = require("../types");
6
6
  const string_1 = require("../types/string");
7
7
  function substring_before(input) {
8
+ let source;
9
+ if (input.val instanceof types_1.FieldSymbol) {
10
+ const pointer = input.val.getPointer();
11
+ if (pointer === undefined) {
12
+ throw new Error("GETWA_NOT_ASSIGNED");
13
+ }
14
+ source = pointer;
15
+ }
16
+ else {
17
+ source = input.val;
18
+ }
8
19
  let val = "";
9
- if (typeof input.val === "string") {
10
- val = input.val;
20
+ if (typeof source === "string") {
21
+ val = source;
11
22
  }
12
- else if (input.val instanceof types_1.Character) {
13
- val = input.val.getTrimEnd();
23
+ else if (source instanceof types_1.Character) {
24
+ val = source.getTrimEnd();
14
25
  }
15
26
  else {
16
- val = input.val.get();
27
+ val = source.get();
17
28
  }
18
29
  let reg = "";
19
30
  if (typeof input.regex === "string") {
@@ -1,4 +1,5 @@
1
+ import { FieldSymbol } from "../types";
1
2
  import { ICharacter } from "../types/_character";
2
3
  export declare function to_lower(input: {
3
- val: ICharacter | string;
4
+ val: ICharacter | FieldSymbol | string;
4
5
  }): ICharacter;
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.to_lower = to_lower;
4
4
  const types_1 = require("../types");
5
5
  function to_lower(input) {
6
- const val = typeof input.val === "string" ? input.val : input.val.get();
7
- if (input.val instanceof types_1.Character) {
8
- return new types_1.Character(input.val.getLength()).set(val.toLowerCase());
6
+ let source;
7
+ if (input.val instanceof types_1.FieldSymbol) {
8
+ const pointer = input.val.getPointer();
9
+ if (pointer === undefined) {
10
+ throw new Error("GETWA_NOT_ASSIGNED");
11
+ }
12
+ source = pointer;
13
+ }
14
+ else {
15
+ source = input.val;
16
+ }
17
+ const val = typeof source === "string" ? source : source.get();
18
+ if (source instanceof types_1.Character) {
19
+ return new types_1.Character(source.getLength()).set(val.toLowerCase());
9
20
  }
10
21
  else {
11
22
  return new types_1.String().set(val.toLowerCase());
@@ -1,4 +1,5 @@
1
+ import { FieldSymbol } from "../types";
1
2
  import { ICharacter } from "../types/_character";
2
3
  export declare function to_upper(input: {
3
- val: ICharacter | string;
4
+ val: ICharacter | FieldSymbol | string;
4
5
  }): ICharacter;
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.to_upper = to_upper;
4
4
  const types_1 = require("../types");
5
5
  function to_upper(input) {
6
- const val = typeof input.val === "string" ? input.val : input.val.get();
7
- if (input.val instanceof types_1.Character) {
8
- return new types_1.Character(input.val.getLength()).set(val.toUpperCase());
6
+ let source;
7
+ if (input.val instanceof types_1.FieldSymbol) {
8
+ const pointer = input.val.getPointer();
9
+ if (pointer === undefined) {
10
+ throw new Error("GETWA_NOT_ASSIGNED");
11
+ }
12
+ source = pointer;
13
+ }
14
+ else {
15
+ source = input.val;
16
+ }
17
+ const val = typeof source === "string" ? source : source.get();
18
+ if (source instanceof types_1.Character) {
19
+ return new types_1.Character(source.getLength()).set(val.toUpperCase());
9
20
  }
10
21
  else {
11
22
  return new types_1.String().set(val.toUpperCase());
@@ -1,6 +1,7 @@
1
+ import { FieldSymbol } from "../types";
1
2
  import { ICharacter } from "../types/_character";
2
3
  export declare function translate(input: {
3
4
  val: ICharacter | string;
4
5
  from: ICharacter | string;
5
- to: ICharacter | string;
6
+ to: ICharacter | FieldSymbol | string;
6
7
  }): ICharacter;
@@ -6,9 +6,20 @@ const string_1 = require("../types/string");
6
6
  function translate(input) {
7
7
  let val = typeof input.val === "string" ? input.val : input.val.get();
8
8
  const from = typeof input.from === "string" ? input.from : input.from.get();
9
- let to = typeof input.to === "string" ? input.to : input.to.get();
10
- if (input.to instanceof types_1.Character) {
11
- to = input.to.getTrimEnd();
9
+ let toSource;
10
+ if (input.to instanceof types_1.FieldSymbol) {
11
+ const pointer = input.to.getPointer();
12
+ if (pointer === undefined) {
13
+ throw new Error("GETWA_NOT_ASSIGNED");
14
+ }
15
+ toSource = pointer;
16
+ }
17
+ else {
18
+ toSource = input.to;
19
+ }
20
+ let to = typeof toSource === "string" ? toSource : toSource.get();
21
+ if (toSource instanceof types_1.Character) {
22
+ to = toSource.getTrimEnd();
12
23
  }
13
24
  const fromSplit = from.split("");
14
25
  const toSplit = to.split("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.30",
3
+ "version": "2.13.31",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",