@abaplint/transpiler-cli 2.5.19 → 2.5.20

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.
Files changed (2) hide show
  1. package/build/bundle.js +119 -10
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -12720,7 +12720,7 @@ class MethodDef {
12720
12720
  const link = (0, combi_1.seq)("LINK", expressions_1.MethodParamName);
12721
12721
  const full = (0, combi_1.seq)("FULL", expressions_1.MethodParamName);
12722
12722
  const modify = (0, combi_1.alt)((0, combi_1.seq)("FOR ACTION", expressions_1.TypeName, result), (0, combi_1.seq)("FOR CREATE", (0, combi_1.alt)(expressions_1.TypeName, expressions_1.EntityAssociation)), (0, combi_1.seq)("FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("FOR UPDATE", expressions_1.TypeName));
12723
- const behavior = (0, combi_1.altPrio)((0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, "FOR READ", (0, combi_1.alt)(expressions_1.TypeName, expressions_1.EntityAssociation), (0, combi_1.optPrio)(full), result, (0, combi_1.optPrio)(link)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName));
12723
+ const behavior = (0, combi_1.altPrio)((0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, "FOR READ", (0, combi_1.alt)(expressions_1.TypeName, expressions_1.EntityAssociation), (0, combi_1.optPrio)(full), result, (0, combi_1.optPrio)(link)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.alt)("BEHAVIOR", "LOCK"), "IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName));
12724
12724
  // todo, this is only from version something
12725
12725
  const amdp = (0, combi_1.seq)("AMDP OPTIONS CDS SESSION CLIENT CURRENT", (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising));
12726
12726
  const ret = (0, combi_1.seq)((0, combi_1.altPrio)("CLASS-METHODS", "METHODS"), expressions_1.MethodName, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), expressions_1.EventHandler), parameters, testing, (0, combi_1.seq)("FOR", (0, combi_1.alt)(tableFunction, ddl, behavior)), amdp, "NOT AT END OF MODE", (0, combi_1.optPrio)(expressions_1.Redefinition)));
@@ -46138,7 +46138,7 @@ class Registry {
46138
46138
  }
46139
46139
  static abaplintVersion() {
46140
46140
  // magic, see build script "version.sh"
46141
- return "2.95.31";
46141
+ return "2.95.32";
46142
46142
  }
46143
46143
  getDDICReferences() {
46144
46144
  return this.references;
@@ -73216,36 +73216,46 @@ const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./n
73216
73216
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
73217
73217
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
73218
73218
  class LoopTranspiler {
73219
+ constructor(options) {
73220
+ this.unique = "";
73221
+ this.injectFrom = undefined;
73222
+ this.skipInto = undefined;
73223
+ this.injectFrom = options === null || options === void 0 ? void 0 : options.injectFrom;
73224
+ this.skipInto = options === null || options === void 0 ? void 0 : options.skipInto;
73225
+ }
73226
+ getTarget() {
73227
+ return this.unique;
73228
+ }
73219
73229
  transpile(node, traversal) {
73220
73230
  var _a, _b, _c;
73221
73231
  if (!(node.get() instanceof abaplint.Statements.Loop)) {
73222
73232
  throw new Error("LoopTranspiler, unexpected node");
73223
73233
  }
73224
73234
  const source = traversal.traverse(node.findDirectExpression(abaplint.Expressions.SimpleSource2)).getCode();
73225
- const unique1 = unique_identifier_1.UniqueIdentifier.get();
73235
+ this.unique = unique_identifier_1.UniqueIdentifier.get();
73226
73236
  let target = "";
73227
73237
  const into = (_a = node.findDirectExpression(abaplint.Expressions.LoopTarget)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.Target);
73228
- if (into) {
73238
+ if (into && this.skipInto !== true) {
73229
73239
  const concat = node.concatTokens().toUpperCase();
73230
73240
  const t = traversal.traverse(into).getCode();
73231
73241
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
73232
73242
  const typ = traversal.determineType(node, scope);
73233
73243
  if (concat.includes(" REFERENCE INTO ")) {
73234
73244
  // target is assumed to be a data reference
73235
- target = t + ".assign(" + unique1 + ");";
73245
+ target = t + ".assign(" + this.unique + ");";
73236
73246
  }
73237
73247
  else if (typ instanceof abaplint.BasicTypes.DataReference) {
73238
73248
  // row type and target is assumed to be data references
73239
- target = t + ".assign(" + unique1 + ".getPointer());";
73249
+ target = t + ".assign(" + this.unique + ".getPointer());";
73240
73250
  }
73241
73251
  else {
73242
- target = t + ".set(" + unique1 + ");";
73252
+ target = t + ".set(" + this.unique + ");";
73243
73253
  }
73244
73254
  }
73245
- else {
73255
+ else if (this.skipInto !== true) {
73246
73256
  const assigning = (_b = node.findFirstExpression(abaplint.Expressions.FSTarget)) === null || _b === void 0 ? void 0 : _b.findFirstExpression(abaplint.Expressions.FieldSymbol);
73247
73257
  if (assigning) {
73248
- target = traversal.traverse(assigning).getCode() + ".assign(" + unique1 + ");";
73258
+ target = traversal.traverse(assigning).getCode() + ".assign(" + this.unique + ");";
73249
73259
  }
73250
73260
  }
73251
73261
  const extra = [];
@@ -73254,6 +73264,9 @@ class LoopTranspiler {
73254
73264
  const from = new expressions_1.SourceTranspiler().transpile(fromNode, traversal).getCode();
73255
73265
  extra.push("from: " + from);
73256
73266
  }
73267
+ else if (this.injectFrom) {
73268
+ extra.push("from: " + this.injectFrom);
73269
+ }
73257
73270
  const toNode = node.findExpressionAfterToken("TO");
73258
73271
  if (toNode) {
73259
73272
  const to = new expressions_1.SourceTranspiler().transpile(toNode, traversal).getCode();
@@ -73306,7 +73319,7 @@ class LoopTranspiler {
73306
73319
  if (extra.length > 0) {
73307
73320
  concat = ",{" + extra.join(",") + "}";
73308
73321
  }
73309
- return new chunk_1.Chunk(`for await (const ${unique1} of abap.statements.loop(${source}${concat})) {\n${target}`);
73322
+ return new chunk_1.Chunk(`for await (const ${this.unique} of abap.statements.loop(${source}${concat})) {\n${target}`);
73310
73323
  }
73311
73324
  }
73312
73325
  exports.LoopTranspiler = LoopTranspiler;
@@ -75530,6 +75543,64 @@ exports.WriteTranspiler = WriteTranspiler;
75530
75543
 
75531
75544
  /***/ }),
75532
75545
 
75546
+ /***/ "./node_modules/@abaplint/transpiler/build/src/structures/at.js":
75547
+ /*!**********************************************************************!*\
75548
+ !*** ./node_modules/@abaplint/transpiler/build/src/structures/at.js ***!
75549
+ \**********************************************************************/
75550
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
75551
+
75552
+ "use strict";
75553
+
75554
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
75555
+ exports.AtTranspiler = void 0;
75556
+ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
75557
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
75558
+ const statements_1 = __webpack_require__(/*! ../statements */ "./node_modules/@abaplint/transpiler/build/src/statements/index.js");
75559
+ const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
75560
+ class AtTranspiler {
75561
+ transpile(node, traversal, previous, loopTarget, tabix, loopStatement) {
75562
+ var _a, _b;
75563
+ const ret = new chunk_1.Chunk();
75564
+ const atStatement = node.findDirectStatement(abaplint.Statements.At);
75565
+ const concat = atStatement === null || atStatement === void 0 ? void 0 : atStatement.concatTokens().toUpperCase();
75566
+ const name = (_b = (_a = atStatement === null || atStatement === void 0 ? void 0 : atStatement.findDirectExpression(abaplint.Expressions.FieldSub)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
75567
+ let suffix = `.get().${name}`;
75568
+ if (name === "table_line") {
75569
+ suffix = "";
75570
+ }
75571
+ if (concat === null || concat === void 0 ? void 0 : concat.startsWith("AT NEW ")) {
75572
+ // eslint-disable-next-line max-len
75573
+ ret.appendString(`if (${previous} === undefined || abap.compare.eq(${previous}${suffix}, ${loopTarget}${suffix}) === false) {\n`);
75574
+ const body = node.findDirectStructure(abaplint.Structures.Body);
75575
+ if (body) {
75576
+ ret.appendChunk(traversal.traverse(body));
75577
+ }
75578
+ ret.appendString("}\n");
75579
+ }
75580
+ else if (concat === null || concat === void 0 ? void 0 : concat.startsWith("AT END OF ")) {
75581
+ const next = unique_identifier_1.UniqueIdentifier.get();
75582
+ ret.appendString(`let ${next} = undefined;\n`);
75583
+ const loop = new statements_1.LoopTranspiler({ injectFrom: tabix, skipInto: true });
75584
+ ret.appendChunk(loop.transpile(loopStatement, traversal));
75585
+ ret.appendString(`${next} = ${loop.getTarget()};\n`);
75586
+ ret.appendString(`break;\n`);
75587
+ ret.appendString(`}\n`);
75588
+ // eslint-disable-next-line max-len
75589
+ ret.appendString(`if (${next} === undefined || abap.compare.eq(${next}${suffix}, ${loopTarget}${suffix}) === false) {\n`);
75590
+ const body = node.findDirectStructure(abaplint.Structures.Body);
75591
+ if (body) {
75592
+ ret.appendChunk(traversal.traverse(body));
75593
+ }
75594
+ ret.appendString("}\n");
75595
+ }
75596
+ return ret;
75597
+ }
75598
+ }
75599
+ exports.AtTranspiler = AtTranspiler;
75600
+ //# sourceMappingURL=at.js.map
75601
+
75602
+ /***/ }),
75603
+
75533
75604
  /***/ "./node_modules/@abaplint/transpiler/build/src/structures/at_first.js":
75534
75605
  /*!****************************************************************************!*\
75535
75606
  !*** ./node_modules/@abaplint/transpiler/build/src/structures/at_first.js ***!
@@ -76201,12 +76272,26 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
76201
76272
  const at_first_1 = __webpack_require__(/*! ./at_first */ "./node_modules/@abaplint/transpiler/build/src/structures/at_first.js");
76202
76273
  const at_last_1 = __webpack_require__(/*! ./at_last */ "./node_modules/@abaplint/transpiler/build/src/structures/at_last.js");
76203
76274
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
76275
+ const statements_1 = __webpack_require__(/*! ../statements */ "./node_modules/@abaplint/transpiler/build/src/statements/index.js");
76276
+ const at_1 = __webpack_require__(/*! ./at */ "./node_modules/@abaplint/transpiler/build/src/structures/at.js");
76204
76277
  class LoopTranspiler {
76205
76278
  transpile(node, traversal) {
76279
+ var _a;
76206
76280
  const ret = new chunk_1.Chunk();
76207
76281
  let pre = "";
76208
76282
  let atFirst = undefined;
76209
76283
  let atLast = undefined;
76284
+ let loopStatement = undefined;
76285
+ let previous = "";
76286
+ let tabix = "";
76287
+ let loopTarget = "";
76288
+ let hasAt = false;
76289
+ for (const n of ((_a = node.findDirectStructure(abaplint.Structures.Body)) === null || _a === void 0 ? void 0 : _a.findDirectStructures(abaplint.Structures.Normal)) || []) {
76290
+ if (n.findDirectStructure(abaplint.Structures.At) !== undefined) {
76291
+ hasAt = true;
76292
+ break;
76293
+ }
76294
+ }
76210
76295
  for (const c of node.getChildren()) {
76211
76296
  if (c instanceof abaplint.Nodes.StructureNode && c.get() instanceof abaplint.Structures.Body) {
76212
76297
  for (const b of c.getChildren()) {
@@ -76223,12 +76308,36 @@ class LoopTranspiler {
76223
76308
  else if (n instanceof abaplint.Nodes.StructureNode && n.get() instanceof abaplint.Structures.AtLast) {
76224
76309
  atLast = new at_last_1.AtLastTranspiler().transpile(n, traversal);
76225
76310
  }
76311
+ else if (n instanceof abaplint.Nodes.StructureNode && n.get() instanceof abaplint.Structures.At) {
76312
+ ret.appendChunk(new at_1.AtTranspiler().transpile(n, traversal, previous, loopTarget, tabix, loopStatement));
76313
+ }
76226
76314
  else {
76227
76315
  ret.appendChunk(traversal.traverse(n));
76228
76316
  }
76229
76317
  }
76230
76318
  }
76231
76319
  }
76320
+ else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.Loop) {
76321
+ if (hasAt === true) {
76322
+ previous = unique_identifier_1.UniqueIdentifier.get();
76323
+ tabix = unique_identifier_1.UniqueIdentifier.get();
76324
+ ret.appendString(`let ${previous} = undefined;\n`);
76325
+ }
76326
+ const loop = new statements_1.LoopTranspiler();
76327
+ ret.appendChunk(loop.transpile(c, traversal));
76328
+ ret.appendString("\n");
76329
+ if (hasAt === true) {
76330
+ ret.appendString(tabix + " = new abap.types.Integer().set(abap.builtin.sy.get().tabix.get() + 1);\n");
76331
+ }
76332
+ loopTarget = loop.getTarget();
76333
+ loopStatement = c;
76334
+ }
76335
+ else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.EndLoop) {
76336
+ if (hasAt === true) {
76337
+ ret.appendString(`${previous} = ${loopTarget};\n`);
76338
+ }
76339
+ ret.appendChunk(traversal.traverse(c));
76340
+ }
76232
76341
  else {
76233
76342
  ret.appendChunk(traversal.traverse(c));
76234
76343
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.5.19",
3
+ "version": "2.5.20",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,11 +25,11 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.5.19",
28
+ "@abaplint/transpiler": "^2.5.20",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",
32
- "@abaplint/core": "^2.95.31",
32
+ "@abaplint/core": "^2.95.32",
33
33
  "progress": "^2.0.3",
34
34
  "webpack": "^5.75.0",
35
35
  "webpack-cli": "^5.0.1",