@abaplint/runtime 2.3.21 → 2.3.23

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,5 +1,8 @@
1
1
  import { ICharacter } from "../types/_character";
2
- export declare function shift_left(input: {
2
+ import { INumeric } from "../types/_numeric";
3
+ export interface IShiftLeftInput {
3
4
  val: ICharacter | string;
4
- sub: ICharacter | string;
5
- }): ICharacter;
5
+ sub?: ICharacter | string;
6
+ places?: ICharacter | INumeric | string;
7
+ }
8
+ export declare function shift_left(input: IShiftLeftInput): ICharacter;
@@ -2,11 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shift_left = void 0;
4
4
  const string_1 = require("../types/string");
5
+ const throw_error_1 = require("../throw_error");
5
6
  function shift_left(input) {
6
7
  let val = typeof input.val === "string" ? input.val : input.val.get();
7
- const sub = typeof input.sub === "string" ? input.sub : input.sub.get();
8
- while (val.startsWith(sub)) {
9
- val = val.substr(sub.length);
8
+ if (input.sub) {
9
+ const sub = typeof input.sub === "string" ? input.sub : input.sub.get();
10
+ while (val.startsWith(sub)) {
11
+ val = val.substr(sub.length);
12
+ }
13
+ }
14
+ else if (input.places) {
15
+ let places = typeof input.places === "string" ? input.places : input.places.get();
16
+ if (typeof places === "string") {
17
+ places = parseInt(places, 10);
18
+ }
19
+ if (places > val.length) {
20
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
21
+ }
22
+ val = val.substring(places);
10
23
  }
11
24
  return new string_1.String().set(val);
12
25
  }
@@ -1,8 +1,8 @@
1
- import { DataReference, FieldSymbol, Structure } from "../types";
1
+ 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 IAssignInput {
5
- source?: INumeric | ICharacter | Structure | DataReference;
5
+ source?: INumeric | ICharacter | Table | Structure | DataReference;
6
6
  target: FieldSymbol;
7
7
  dynamicName?: string;
8
8
  dynamicSource?: ICharacter;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assign = void 0;
4
4
  const types_1 = require("../types");
5
5
  function assign(input) {
6
- // console.dir(input);
7
6
  if (input.dynamicName) {
8
7
  if (input.dynamicSource instanceof types_1.FieldSymbol) {
9
8
  input.dynamicSource = input.dynamicSource.getPointer();
@@ -58,7 +57,8 @@ function assign(input) {
58
57
  assign(input);
59
58
  return;
60
59
  }
61
- else if (!(input.source instanceof types_1.Structure)) {
60
+ else if (!(input.source instanceof types_1.Structure)
61
+ && !(input.source instanceof types_1.Table)) {
62
62
  // @ts-ignore
63
63
  abap.builtin.sy.get().subrc.set(4);
64
64
  return;
@@ -67,12 +67,23 @@ function assign(input) {
67
67
  if (typeof component !== "string") {
68
68
  component = component.get();
69
69
  }
70
+ if (input.source instanceof types_1.Table) {
71
+ input.source = input.source.getHeader();
72
+ }
73
+ if (input.source instanceof types_1.Table) {
74
+ throw "ASSIGN, nested table";
75
+ }
70
76
  let result = undefined;
71
77
  if (typeof component === "number") {
72
- const structure_as_object = input.source.get();
73
- const keys = Object.keys(structure_as_object);
74
- const component_name = keys[(component - 1)];
75
- result = structure_as_object[component_name];
78
+ if (component === 0) {
79
+ result = input.source;
80
+ }
81
+ else if (input.source instanceof types_1.Structure) {
82
+ const structure_as_object = input.source.get();
83
+ const keys = Object.keys(structure_as_object);
84
+ const component_name = keys[component - 1];
85
+ result = structure_as_object[component_name];
86
+ }
76
87
  }
77
88
  else {
78
89
  result = input.source.get()[component.toLowerCase()];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.3.21",
3
+ "version": "2.3.23",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",