@abaplint/runtime 2.0.36 → 2.0.39

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.
@@ -6,6 +6,9 @@ export interface IWriteOptions {
6
6
  newLine?: boolean;
7
7
  skipLine?: boolean;
8
8
  target?: ICharacter;
9
+ exponent?: ICharacter | INumeric;
10
+ noGrouping?: boolean;
11
+ noSign?: boolean;
9
12
  }
10
13
  export declare class WriteStatement {
11
14
  private readonly context;
@@ -7,6 +7,7 @@ class WriteStatement {
7
7
  this.context = context;
8
8
  }
9
9
  write(source, options) {
10
+ var _a;
10
11
  if ((options === null || options === void 0 ? void 0 : options.skipLine) === true) {
11
12
  this.context.console.add("\n");
12
13
  }
@@ -14,30 +15,39 @@ class WriteStatement {
14
15
  if ((options === null || options === void 0 ? void 0 : options.newLine) === true && this.context.console.get().length > 0) {
15
16
  this.context.console.add("\n");
16
17
  }
18
+ let result = "";
17
19
  if (typeof source === "string" || typeof source === "number") {
18
- if (options === null || options === void 0 ? void 0 : options.target) {
19
- options.target.set(source.toString());
20
- }
21
- else {
22
- this.context.console.add(source.toString());
23
- }
20
+ result = source.toString();
24
21
  }
25
- else {
26
- if (source instanceof types_1.Structure) {
27
- const obj = source.get();
28
- for (const f in obj) {
29
- // @ts-ignore
30
- abap.statements.write(obj[f]);
31
- }
22
+ else if (source instanceof types_1.Structure) {
23
+ const obj = source.get();
24
+ for (const f in obj) {
25
+ this.write(obj[f], Object.assign({}, options));
32
26
  }
33
- else {
34
- if (options === null || options === void 0 ? void 0 : options.target) {
35
- options.target.set(source.get().toString());
27
+ }
28
+ else if (source instanceof types_1.Float) {
29
+ if (((_a = options === null || options === void 0 ? void 0 : options.exponent) === null || _a === void 0 ? void 0 : _a.get()) === 0) {
30
+ const tens = source.getRaw().toFixed(0).length - 1;
31
+ if (options.noSign === true && source.getRaw() < 0) {
32
+ result = source.getRaw().toFixed(17 - tens).replace(".", ",");
33
+ result = result.replace("-", "");
36
34
  }
37
35
  else {
38
- this.context.console.add(source.get().toString());
36
+ result = source.getRaw().toFixed(16 - tens).replace(".", ",");
39
37
  }
40
38
  }
39
+ else {
40
+ result = source.get().toString();
41
+ }
42
+ }
43
+ else {
44
+ result = source.get().toString();
45
+ }
46
+ if (options === null || options === void 0 ? void 0 : options.target) {
47
+ options.target.set(result);
48
+ }
49
+ else {
50
+ this.context.console.add(result);
41
51
  }
42
52
  }
43
53
  }
@@ -105,7 +105,7 @@ class Table {
105
105
  const p = (0, clone_1.clone)(this.rowType);
106
106
  p.set(val);
107
107
  this.value.push(p);
108
- return val;
108
+ return p;
109
109
  }
110
110
  }
111
111
  appendInitial() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.0.36",
3
+ "version": "2.0.39",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",