@abaplint/transpiler-cli 2.10.50 → 2.10.51

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 +102 -49
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -81453,34 +81453,35 @@ class AssignTranspiler {
81453
81453
  if (firstFirst?.get() instanceof abaplint.Expressions.Constant) {
81454
81454
  const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)?.toString();
81455
81455
  options.push(`dynamicSource: (() => {
81456
- try { return ${s}; } catch {}
81457
- try { return this.${s}; } catch {}
81458
- })()`);
81456
+ try { return ${s}; } catch {}
81457
+ try { return this.${s}; } catch {}
81458
+ })()`);
81459
81459
  }
81460
81460
  else if (firstFirst?.get() instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
81461
81461
  const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
81462
81462
  options.push(`dynamicSource: (() => {
81463
- const name = ${code}.toLowerCase().replace(/[~\\/]/g, "$").match(/[\\w\\$\\/]+/)[0];
81464
- try { return eval(name); } catch {}
81465
- try { return eval("this." + name); } catch {}
81466
- })()`);
81463
+ const name = ${code}.toLowerCase().replace(/[~\\/]/g, "$").match(/[\\w\\$\\/]+/)[0];
81464
+ try { return eval(name); } catch {}
81465
+ try { return eval("this." + name); } catch {}
81466
+ })()`);
81467
81467
  }
81468
81468
  }
81469
81469
  else if (first?.get() instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
81470
81470
  // const name = first.concatTokens().toLowerCase();
81471
81471
  const name = new expressions_1.SourceTranspiler().transpile(first, traversal).getCode();
81472
81472
  options.push(`dynamicSource: (() => {
81473
- try { return ${name}; } catch {}
81474
- try { return this.${name}; } catch {}
81475
- })()`);
81473
+ try { return ${name}; } catch {}
81474
+ try { return this.${name}; } catch {}
81475
+ })()`);
81476
81476
  }
81477
81477
  }
81478
81478
  if (concat.endsWith(" CASTING.") || concat.includes(" CASTING TYPE ")) {
81479
81479
  options.push("casting: true");
81480
81480
  }
81481
- return new chunk_1.Chunk().append("abap.statements.assign({", node, traversal)
81481
+ const ret = new chunk_1.Chunk().append("abap.statements.assign({", node, traversal)
81482
81482
  .appendString(options.join(", "))
81483
81483
  .append("});", node.getLastToken(), traversal);
81484
+ return ret;
81484
81485
  }
81485
81486
  }
81486
81487
  exports.AssignTranspiler = AssignTranspiler;
@@ -81764,8 +81765,8 @@ class CallFunctionTranspiler {
81764
81765
  else {
81765
81766
  const illegalFunc = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_FUNC'", node.getFirstToken(), true);
81766
81767
  const call = `abap.FunctionModules[${fmname}]`;
81767
- ret.appendString(`if (${call} === undefined && ${illegalFunc} === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; }\n`);
81768
- ret.appendString(`if (${call} === undefined) { throw new ${illegalFunc}(); }\n`);
81768
+ // eslint-disable-next-line max-len
81769
+ ret.appendString(`if (${call} === undefined) { if (${illegalFunc} === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; } else { throw new ${illegalFunc}();} }\n`);
81769
81770
  ret.appendString(`await ${call}(${param});`);
81770
81771
  }
81771
81772
  if (exceptions) {
@@ -85201,47 +85202,67 @@ class PerformTranspiler {
85201
85202
  return new chunk_1.Chunk(`throw new Error("PerformTranspiler FormName not found");`);
85202
85203
  }
85203
85204
  else if (node.concatTokens().toUpperCase().includes(" IN PROGRAM ")) {
85204
- return new chunk_1.Chunk(`throw new Error("PerformTranspiler IN PROGRAM, transpiler todo");`);
85205
- }
85206
- let def = undefined;
85207
- const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
85208
- for (const r of scope?.getData().references || []) {
85209
- if (r.referenceType === abaplint.ReferenceType.FormReference
85210
- && r.position.getStart().equals(formName.getFirstToken().getStart())
85211
- && r.resolved instanceof abaplint.Types.FormDefinition) {
85212
- def = r.resolved;
85205
+ // todo: throw exception if not found?
85206
+ const expression = node.findExpressionAfterToken("PROGRAM");
85207
+ let ref = "";
85208
+ if (expression?.get() instanceof abaplint.Expressions.Dynamic) {
85209
+ const name = expression.getChildren()[1].concatTokens() + ".get().trimEnd()";
85210
+ ref = `abap.Forms['PROG-' + ${name} + '-${formName.concatTokens().toUpperCase()}']`;
85213
85211
  }
85214
- }
85215
- // todo: pass by VALUE()
85216
- const params = [];
85217
- let index = 0;
85218
- for (const t of node.findDirectExpression(abaplint.Expressions.PerformTables)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
85219
- const name = def?.getTablesParameters()[index].getName().toLowerCase();
85220
- if (name === undefined) {
85221
- continue;
85212
+ else {
85213
+ const progName = expression?.concatTokens().toUpperCase();
85214
+ ref = `abap.Forms['PROG-${progName}-${formName.concatTokens().toUpperCase()}']`;
85222
85215
  }
85223
- params.push(`"${name}": ` + traversal.traverse(t).getCode());
85224
- index++;
85225
- }
85226
- index = 0;
85227
- for (const u of node.findDirectExpression(abaplint.Expressions.PerformUsing)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
85228
- const name = def?.getUsingParameters()[index].getName().toLowerCase();
85229
- if (name === undefined) {
85230
- continue;
85216
+ const params = [];
85217
+ // hacky hack
85218
+ for (const t of node.findDirectExpression(abaplint.Expressions.PerformChanging)?.findDirectExpressions(abaplint.Expressions.Target) || []) {
85219
+ const name = t.getFirstToken().getStr();
85220
+ params.push(`"${name}": ` + traversal.traverse(t).getCode());
85231
85221
  }
85232
- params.push(`"${name}": ` + traversal.traverse(u).getCode());
85233
- index++;
85222
+ return new chunk_1.Chunk("await " + ref + `({${params.join(",")}});`);
85234
85223
  }
85235
- index = 0;
85236
- for (const c of node.findDirectExpression(abaplint.Expressions.PerformChanging)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
85237
- const name = def?.getChangingParameters()[index].getName().toLowerCase();
85238
- if (name === undefined) {
85239
- continue;
85224
+ else {
85225
+ // todo: most of this needs rewriting?
85226
+ let def = undefined;
85227
+ const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
85228
+ for (const r of scope?.getData().references || []) {
85229
+ if (r.referenceType === abaplint.ReferenceType.FormReference
85230
+ && r.position.getStart().equals(formName.getFirstToken().getStart())
85231
+ && r.resolved instanceof abaplint.Types.FormDefinition) {
85232
+ def = r.resolved;
85233
+ }
85234
+ }
85235
+ // todo: pass by VALUE()
85236
+ const params = [];
85237
+ let index = 0;
85238
+ for (const t of node.findDirectExpression(abaplint.Expressions.PerformTables)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
85239
+ const name = def?.getTablesParameters()[index].getName().toLowerCase();
85240
+ if (name === undefined) {
85241
+ continue;
85242
+ }
85243
+ params.push(`"${name}": ` + traversal.traverse(t).getCode());
85244
+ index++;
85240
85245
  }
85241
- params.push(`"${name}": ` + traversal.traverse(c).getCode());
85242
- index++;
85246
+ index = 0;
85247
+ for (const u of node.findDirectExpression(abaplint.Expressions.PerformUsing)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
85248
+ const name = def?.getUsingParameters()[index].getName().toLowerCase();
85249
+ if (name === undefined) {
85250
+ continue;
85251
+ }
85252
+ params.push(`"${name}": ` + traversal.traverse(u).getCode());
85253
+ index++;
85254
+ }
85255
+ index = 0;
85256
+ for (const c of node.findDirectExpression(abaplint.Expressions.PerformChanging)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
85257
+ const name = def?.getChangingParameters()[index].getName().toLowerCase();
85258
+ if (name === undefined) {
85259
+ continue;
85260
+ }
85261
+ params.push(`"${name}": ` + traversal.traverse(c).getCode());
85262
+ index++;
85263
+ }
85264
+ return new chunk_1.Chunk("await " + formName.concatTokens() + `({${params.join(",")}});`);
85243
85265
  }
85244
- return new chunk_1.Chunk("await " + formName.concatTokens() + `({${params.join(",")}});`);
85245
85266
  }
85246
85267
  }
85247
85268
  exports.PerformTranspiler = PerformTranspiler;
@@ -87581,6 +87602,37 @@ exports.DoTranspiler = DoTranspiler;
87581
87602
 
87582
87603
  /***/ }),
87583
87604
 
87605
+ /***/ "./node_modules/@abaplint/transpiler/build/src/structures/form.js":
87606
+ /*!************************************************************************!*\
87607
+ !*** ./node_modules/@abaplint/transpiler/build/src/structures/form.js ***!
87608
+ \************************************************************************/
87609
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
87610
+
87611
+ "use strict";
87612
+
87613
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
87614
+ exports.FormTranspiler = void 0;
87615
+ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
87616
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
87617
+ class FormTranspiler {
87618
+ transpile(node, traversal) {
87619
+ const formName = node.findFirstStatement(abaplint.Statements.Form)
87620
+ ?.findDirectExpression(abaplint.Expressions.FormName)?.concatTokens()?.toUpperCase();
87621
+ const ret = new chunk_1.Chunk();
87622
+ for (const c of node.getChildren()) {
87623
+ ret.appendChunk(traversal.traverse(c));
87624
+ }
87625
+ if (formName && traversal.getCurrentObject().getType() === "PROG") {
87626
+ ret.appendString(`abap.Forms['PROG-${traversal.getCurrentObject().getName().toUpperCase()}-${formName}'] = ${formName?.toLowerCase()};`);
87627
+ }
87628
+ return ret;
87629
+ }
87630
+ }
87631
+ exports.FormTranspiler = FormTranspiler;
87632
+ //# sourceMappingURL=form.js.map
87633
+
87634
+ /***/ }),
87635
+
87584
87636
  /***/ "./node_modules/@abaplint/transpiler/build/src/structures/function_module.js":
87585
87637
  /*!***********************************************************************************!*\
87586
87638
  !*** ./node_modules/@abaplint/transpiler/build/src/structures/function_module.js ***!
@@ -87705,6 +87757,7 @@ __exportStar(__webpack_require__(/*! ./try */ "./node_modules/@abaplint/transpil
87705
87757
  __exportStar(__webpack_require__(/*! ./types */ "./node_modules/@abaplint/transpiler/build/src/structures/types.js"), exports);
87706
87758
  __exportStar(__webpack_require__(/*! ./when */ "./node_modules/@abaplint/transpiler/build/src/structures/when.js"), exports);
87707
87759
  __exportStar(__webpack_require__(/*! ./while */ "./node_modules/@abaplint/transpiler/build/src/structures/while.js"), exports);
87760
+ __exportStar(__webpack_require__(/*! ./form */ "./node_modules/@abaplint/transpiler/build/src/structures/form.js"), exports);
87708
87761
  //# sourceMappingURL=index.js.map
87709
87762
 
87710
87763
  /***/ }),
@@ -88255,7 +88308,7 @@ class TranspileTypes {
88255
88308
  asInclude[c.name.toLowerCase()] = true;
88256
88309
  }
88257
88310
  }
88258
- extra = "{" + list.join(", ") + "}";
88311
+ extra = "{\n" + list.join(",\n") + "}";
88259
88312
  if (type.getQualifiedName() !== undefined) {
88260
88313
  extra += ", \"" + type.getQualifiedName() + "\"";
88261
88314
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.10.50",
3
+ "version": "2.10.51",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -28,9 +28,9 @@
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
30
  "@abaplint/core": "^2.113.114",
31
- "@abaplint/transpiler": "^2.10.50",
31
+ "@abaplint/transpiler": "^2.10.51",
32
32
  "@types/glob": "^8.1.0",
33
- "@types/node": "^22.15.17",
33
+ "@types/node": "^22.15.18",
34
34
  "@types/progress": "^2.0.7",
35
35
  "glob": "=7.2.0",
36
36
  "progress": "^2.0.3",