@abaplint/runtime 2.5.15 → 2.5.17

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,4 +1,4 @@
1
- import { Float, Hex, Integer } from "../types";
1
+ import { FieldSymbol, Float, Hex, Integer } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
- export declare function add(left: INumeric | ICharacter | string | number | Float | Integer | Hex, right: INumeric | ICharacter | string | number | Float | Integer | Hex): Float | Integer;
4
+ export declare function add(left: INumeric | ICharacter | string | number | Float | Integer | Hex | FieldSymbol, right: INumeric | ICharacter | string | number | Float | Integer | Hex | FieldSymbol): Integer | Float;
@@ -5,6 +5,18 @@ const types_1 = require("../types");
5
5
  const string_1 = require("../types/string");
6
6
  const _parse_1 = require("./_parse");
7
7
  function add(left, right) {
8
+ if (left instanceof types_1.FieldSymbol) {
9
+ if (left.getPointer() === undefined) {
10
+ throw new Error("GETWA_NOT_ASSIGNED");
11
+ }
12
+ return add(left.getPointer(), right);
13
+ }
14
+ if (right instanceof types_1.FieldSymbol) {
15
+ if (right.getPointer() === undefined) {
16
+ throw new Error("GETWA_NOT_ASSIGNED");
17
+ }
18
+ return add(left, right.getPointer());
19
+ }
8
20
  if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
9
21
  return new types_1.Integer().set(left.get() + right.get());
10
22
  }
@@ -1,4 +1,4 @@
1
- import { Float, Integer } from "../types";
1
+ import { FieldSymbol, Float, Integer } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
- export declare function minus(left: INumeric | ICharacter | string | number | Integer | Float, right: INumeric | ICharacter | string | number | Integer | Float): Float | Integer;
4
+ export declare function minus(left: INumeric | ICharacter | string | number | Integer | Float | FieldSymbol, right: INumeric | ICharacter | string | number | Integer | Float | FieldSymbol): Integer | Float;
@@ -5,6 +5,18 @@ const types_1 = require("../types");
5
5
  const _parse_1 = require("./_parse");
6
6
  const string_1 = require("../types/string");
7
7
  function minus(left, right) {
8
+ if (left instanceof types_1.FieldSymbol) {
9
+ if (left.getPointer() === undefined) {
10
+ throw new Error("GETWA_NOT_ASSIGNED");
11
+ }
12
+ return minus(left.getPointer(), right);
13
+ }
14
+ if (right instanceof types_1.FieldSymbol) {
15
+ if (right.getPointer() === undefined) {
16
+ throw new Error("GETWA_NOT_ASSIGNED");
17
+ }
18
+ return minus(left, right.getPointer());
19
+ }
8
20
  if (left instanceof types_1.Integer && right instanceof types_1.Integer) {
9
21
  return new types_1.Integer().set(left.get() - right.get());
10
22
  }
@@ -24,7 +24,12 @@ async function cast(target, source) {
24
24
  targetName = (_a = target.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
25
25
  }
26
26
  // @ts-ignore
27
- const targetClass = abap.Classes[targetName];
27
+ let targetClass = abap.Classes[targetName];
28
+ if (targetClass === undefined) {
29
+ // todo, for unit testing,
30
+ // @ts-ignore
31
+ targetClass = abap.Classes["PROG-ZFOOBAR-" + targetName];
32
+ }
28
33
  if ((targetClass === null || targetClass === void 0 ? void 0 : targetClass.INTERNAL_TYPE) === "CLAS") {
29
34
  // using "instanceof" is probably wrong in some cases,
30
35
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
@@ -33,27 +38,7 @@ async function cast(target, source) {
33
38
  }
34
39
  }
35
40
  else if (checkIntf === true && (targetClass === null || targetClass === void 0 ? void 0 : targetClass.INTERNAL_TYPE) === "INTF") {
36
- const list = [...source.get().constructor.IMPLEMENTED_INTERFACES];
37
- // interfaces implemented in super classes
38
- let sup = source.get().super;
39
- while (sup !== undefined) {
40
- list.push(...sup.get().constructor.IMPLEMENTED_INTERFACES);
41
- sup = sup.get().super;
42
- }
43
- // interfaces implemented by interfaces
44
- const visit = new Set(list);
45
- while (visit.size > 0) {
46
- const intfName = visit.values().next().value;
47
- // @ts-ignore
48
- const intf = abap.Classes[intfName];
49
- for (const i of (intf === null || intf === void 0 ? void 0 : intf.IMPLEMENTED_INTERFACES) || []) {
50
- if (visit.has(i) === false) {
51
- visit.add(i);
52
- list.push(i);
53
- }
54
- }
55
- visit.delete(intfName);
56
- }
41
+ const list = source.get().constructor.IMPLEMENTED_INTERFACES;
57
42
  const isImplemented = list.some(i => i === targetName);
58
43
  if (isImplemented === false) {
59
44
  (0, throw_error_1.throwError)("CX_SY_MOVE_CAST_ERROR");
@@ -1,9 +1,12 @@
1
1
  import { Context } from "../context";
2
+ import { ABAPObject } from "../types";
2
3
  import { ICharacter } from "../types/_character";
3
4
  export interface IMessageOptions {
4
5
  id?: ICharacter | string;
5
6
  number?: ICharacter | string;
6
7
  type?: ICharacter | string;
8
+ displayLike?: ICharacter | string;
9
+ exception?: ABAPObject;
7
10
  with?: (ICharacter | string)[];
8
11
  into?: ICharacter;
9
12
  }
@@ -69,11 +69,21 @@ class MessageStatement {
69
69
  abap.builtin.sy.get().msgno.set(msgnr);
70
70
  // @ts-ignore
71
71
  abap.builtin.sy.get().msgty.set(msgty);
72
- const text = await findText(this.context, arbgb, msgnr, msgty);
73
- const replaced = replace(text, options.with);
72
+ let replaced = "";
73
+ if (options.exception) {
74
+ replaced = await options.exception.get().if_message$get_text();
75
+ }
76
+ else {
77
+ const text = await findText(this.context, arbgb, msgnr, msgty);
78
+ replaced = replace(text, options.with);
79
+ }
74
80
  if (options.into) {
75
81
  options.into.set(replaced);
76
82
  }
83
+ else {
84
+ // hmm, add option on how/if to write messages to console? or it should be the abap.console() ?
85
+ console.log(replaced);
86
+ }
77
87
  }
78
88
  }
79
89
  exports.MessageStatement = MessageStatement;
@@ -2,7 +2,7 @@ import { DataReference, FieldSymbol, Structure, Table } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
4
  export interface IReadTableOptions {
5
- index?: INumeric | number;
5
+ index?: INumeric | FieldSymbol | number;
6
6
  withKey?: (i: any) => boolean;
7
7
  into?: INumeric | ICharacter | Structure | Table | DataReference;
8
8
  from?: INumeric | ICharacter | Structure | Table | DataReference;
@@ -30,7 +30,18 @@ function readTable(table, options) {
30
30
  if (options === null || options === void 0 ? void 0 : options.index) {
31
31
  let index = options.index;
32
32
  if (typeof index !== "number") {
33
- index = index.get();
33
+ if (index instanceof types_1.FieldSymbol) {
34
+ if (index.getPointer() === undefined) {
35
+ throw new Error("GETWA_NOT_ASSIGNED");
36
+ }
37
+ index = index.getPointer();
38
+ }
39
+ if (index instanceof types_1.Float || index instanceof types_1.DecFloat34) {
40
+ index = index.getRaw();
41
+ }
42
+ else {
43
+ index = index.get();
44
+ }
34
45
  }
35
46
  found = arr[index - 1];
36
47
  if (found) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.5.15",
3
+ "version": "2.5.17",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",