@abaplint/transpiler 2.13.71 → 2.13.73

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.
@@ -135,6 +135,7 @@ export * from "./select";
135
135
  export * from "./selection_screen";
136
136
  export * from "./set_bit";
137
137
  export * from "./set_blank";
138
+ export * from "./set_cursor";
138
139
  export * from "./set_dataset";
139
140
  export * from "./set_extended_check";
140
141
  export * from "./set_handler";
@@ -151,6 +151,7 @@ __exportStar(require("./select"), exports);
151
151
  __exportStar(require("./selection_screen"), exports);
152
152
  __exportStar(require("./set_bit"), exports);
153
153
  __exportStar(require("./set_blank"), exports);
154
+ __exportStar(require("./set_cursor"), exports);
154
155
  __exportStar(require("./set_dataset"), exports);
155
156
  __exportStar(require("./set_extended_check"), exports);
156
157
  __exportStar(require("./set_handler"), exports);
@@ -6,9 +6,11 @@ export declare class LoopTranspiler implements IStatementTranspiler {
6
6
  private unique;
7
7
  private readonly injectFrom;
8
8
  private readonly skipInto;
9
+ private readonly atLast;
9
10
  constructor(options?: {
10
11
  injectFrom?: string;
11
12
  skipInto?: boolean;
13
+ atLast?: string;
12
14
  });
13
15
  getTarget(): string;
14
16
  private determineInto;
@@ -42,9 +42,11 @@ class LoopTranspiler {
42
42
  unique = "";
43
43
  injectFrom = undefined;
44
44
  skipInto = undefined;
45
+ atLast = undefined;
45
46
  constructor(options) {
46
47
  this.injectFrom = options?.injectFrom;
47
48
  this.skipInto = options?.skipInto;
49
+ this.atLast = options?.atLast;
48
50
  }
49
51
  getTarget() {
50
52
  return this.unique;
@@ -142,6 +144,9 @@ class LoopTranspiler {
142
144
  }
143
145
  extra.push(`dynamicWhere: {condition: ${code}, evaluate: (name) => {try { return eval(name);} catch {}}}`);
144
146
  }
147
+ if (this.atLast !== undefined) {
148
+ extra.push(`atLast: (last) => { ${this.atLast} = last; }`);
149
+ }
145
150
  const topEquals = {};
146
151
  for (const compare of whereNode?.findDirectExpressions(abaplint.Expressions.ComponentCompare) || []) {
147
152
  const op = compare.findDirectExpression(abaplint.Expressions.CompareOperator)?.concatTokens().toUpperCase();
@@ -0,0 +1,7 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { IStatementTranspiler } from "./_statement_transpiler";
3
+ import { Traversal } from "../traversal";
4
+ import { Chunk } from "../chunk";
5
+ export declare class SetCursorTranspiler implements IStatementTranspiler {
6
+ transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetCursorTranspiler = void 0;
4
+ const chunk_1 = require("../chunk");
5
+ class SetCursorTranspiler {
6
+ transpile(_node, _traversal) {
7
+ return new chunk_1.Chunk(`throw new Error("SET CURSOR, not supported, transpiler");`);
8
+ }
9
+ }
10
+ exports.SetCursorTranspiler = SetCursorTranspiler;
11
+ //# sourceMappingURL=set_cursor.js.map
@@ -41,12 +41,14 @@ const at_last_1 = require("./at_last");
41
41
  const unique_identifier_1 = require("../unique_identifier");
42
42
  const statements_1 = require("../statements");
43
43
  const at_1 = require("./at");
44
+ const inline_1 = require("../inline");
44
45
  class LoopTranspiler {
45
46
  transpile(node, traversal) {
46
47
  const ret = new chunk_1.Chunk();
47
48
  let pre = "";
48
49
  let atFirst = undefined;
49
50
  let atLast = undefined;
51
+ let atLastFlag = "";
50
52
  let loopStatement = undefined;
51
53
  let previous = "";
52
54
  let tabix = "";
@@ -58,6 +60,18 @@ class LoopTranspiler {
58
60
  break;
59
61
  }
60
62
  }
63
+ const hasAtLast = (node.findDirectStructure(abaplint.Structures.Body)
64
+ ?.findDirectStructures(abaplint.Structures.Normal) || [])
65
+ .some(n => n.findDirectStructure(abaplint.Structures.AtLast) !== undefined);
66
+ const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
67
+ if (scope?.getIdentifier().stype === abaplint.ScopeType.Program
68
+ || scope?.getIdentifier().stype === abaplint.ScopeType.SelectionEvent) {
69
+ ret.appendString(inline_1.InlineDeclarations.buildDeclarations(node, traversal));
70
+ }
71
+ if (hasAtLast) {
72
+ atLastFlag = unique_identifier_1.UniqueIdentifier.get();
73
+ ret.appendString(`let ${atLastFlag} = false;\n`);
74
+ }
61
75
  if (node.findDirectStatement(abaplint.Statements.Loop)?.findDirectTokenByText("GROUP") !== undefined) {
62
76
  return new chunk_1.Chunk(`throw new Error("transpiler todo, GROUP BY");`);
63
77
  }
@@ -76,6 +90,9 @@ class LoopTranspiler {
76
90
  }
77
91
  else if (n instanceof abaplint.Nodes.StructureNode && n.get() instanceof abaplint.Structures.AtLast) {
78
92
  atLast = new at_last_1.AtLastTranspiler().transpile(n, traversal);
93
+ ret.appendString(`if (${atLastFlag}) {\n`);
94
+ ret.appendChunk(atLast);
95
+ ret.appendString("}\n");
79
96
  }
80
97
  else if (n instanceof abaplint.Nodes.StructureNode && n.get() instanceof abaplint.Structures.At) {
81
98
  ret.appendChunk(new at_1.AtTranspiler().transpile(n, traversal, previous, loopTarget, tabix, loopStatement));
@@ -93,7 +110,7 @@ class LoopTranspiler {
93
110
  ret.appendString(`let ${previous} = undefined;\n`);
94
111
  ret.appendString(`let ${tabix} = undefined;\n`);
95
112
  }
96
- const loop = new statements_1.LoopTranspiler();
113
+ const loop = new statements_1.LoopTranspiler({ atLast: atLastFlag || undefined });
97
114
  // LoopStatementTranspiler maps its own head, so no ensureStartMapping needed here
98
115
  ret.appendChunk(loop.transpile(c, traversal));
99
116
  ret.appendString("\n");
@@ -118,11 +135,6 @@ class LoopTranspiler {
118
135
  atted.appendString(pre);
119
136
  }
120
137
  atted.appendChunk(ret);
121
- if (atLast) {
122
- atted.appendString("if (abap.builtin.sy.get().subrc.get() === 0) {\n");
123
- atted.appendChunk(atLast);
124
- atted.appendString("}\n");
125
- }
126
138
  return atted;
127
139
  }
128
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.71",
3
+ "version": "2.13.73",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",