@abaplint/transpiler-cli 2.10.35 → 2.10.36

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 +29 -8
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -80480,19 +80480,35 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
80480
80480
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
80481
80481
  const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
80482
80482
  const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
80483
+ const structures_1 = __webpack_require__(/*! ../structures */ "./node_modules/@abaplint/transpiler/build/src/structures/index.js");
80483
80484
  class HandleTypePool {
80484
80485
  runObject(obj, reg) {
80485
- const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti.getFirstChild()?.getFirstChild();
80486
+ const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti;
80487
+ const spaghettiNode = spaghetti.getFirstChild()?.getFirstChild();
80488
+ if (spaghettiNode === undefined) {
80489
+ throw new Error("HandleTypePool: no spaghetti found");
80490
+ }
80491
+ const abapFile = obj.getABAPFiles()[0];
80492
+ if (abapFile === undefined) {
80493
+ throw new Error("HandleTypePool: no ABAP file found");
80494
+ }
80486
80495
  const chunk = new chunk_1.Chunk();
80487
80496
  chunk.appendString(`const pool = {};\n`);
80488
- for (const v in spaghetti?.getData().vars) {
80489
- const abs = spaghetti.getData().vars[v];
80497
+ for (const v in spaghettiNode?.getData().vars) {
80498
+ const abs = spaghettiNode.getData().vars[v];
80490
80499
  const name = `pool['${v.toLowerCase()}']`;
80491
80500
  chunk.appendString(`${name} = ${new transpile_types_1.TranspileTypes().toType(abs.getType())};\n`);
80492
80501
  chunk.appendString(traversal_1.Traversal.setValues(abs, name));
80502
+ // yea, this is a mess
80503
+ for (const cons of abapFile.getStructure()?.findAllStructures(abaplint.Structures.Constants) || []) {
80504
+ const cName = cons.findFirstExpression(abaplint.Expressions.DefinitionName)?.getFirstToken().getStr().toLowerCase();
80505
+ if (cName === v.toLocaleLowerCase()) {
80506
+ chunk.appendString(structures_1.ConstantsTranspiler.handleValues(name, cons, new traversal_1.Traversal(spaghetti, abapFile, obj, reg)));
80507
+ }
80508
+ }
80493
80509
  }
80494
- for (const t in spaghetti?.getData().types) {
80495
- const abs = spaghetti.getData().types[t];
80510
+ for (const t in spaghettiNode?.getData().types) {
80511
+ const abs = spaghettiNode.getData().types[t];
80496
80512
  chunk.appendString(`pool['${t.toLowerCase()}'] = ${new transpile_types_1.TranspileTypes().toType(abs.getType())};\n`);
80497
80513
  }
80498
80514
  chunk.appendString(`abap.TypePools['${obj.getName()}'] = pool;`);
@@ -87203,6 +87219,11 @@ class ConstantsTranspiler {
87203
87219
  throw "ConstantsTranspilerName";
87204
87220
  }
87205
87221
  let ret = new statements_1.DataTranspiler().transpile(begin, traversal).getCode() + "\n";
87222
+ ret += ConstantsTranspiler.handleValues(name, node, traversal);
87223
+ return new chunk_1.Chunk(ret);
87224
+ }
87225
+ static handleValues(prefix, node, traversal) {
87226
+ let ret = "";
87206
87227
  // todo: CONSTANTS BEGIN inside CONSTANTS BEGIN
87207
87228
  for (const c of node.findDirectStatements(abaplint.Statements.Constant)) {
87208
87229
  const field = c.findDirectExpression(abaplint.Expressions.DefinitionName)?.getFirstToken().getStr();
@@ -87211,10 +87232,10 @@ class ConstantsTranspiler {
87211
87232
  }
87212
87233
  const value = c.findFirstExpression(abaplint.Expressions.Constant);
87213
87234
  if (value) {
87214
- ret += `${name}.get().${field}.set(${traversal.traverse(value).getCode()});\n`;
87235
+ ret += `${prefix}.get().${field}.set(${traversal.traverse(value).getCode()});\n`;
87215
87236
  }
87216
87237
  }
87217
- return new chunk_1.Chunk(ret);
87238
+ return ret;
87218
87239
  }
87219
87240
  }
87220
87241
  exports.ConstantsTranspiler = ConstantsTranspiler;
@@ -88912,7 +88933,7 @@ export async function initializeABAP() {\n`;
88912
88933
  ret += ` insert.push(\`${i}\`);\n`;
88913
88934
  }
88914
88935
  ret += `\n`;
88915
- if (extraSetup === undefined) {
88936
+ if (extraSetup === undefined || extraSetup === "") {
88916
88937
  ret += `// no setup logic specified in config\n`;
88917
88938
  }
88918
88939
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.10.35",
3
+ "version": "2.10.36",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
30
  "@abaplint/core": "^2.113.108",
31
- "@abaplint/transpiler": "^2.10.35",
31
+ "@abaplint/transpiler": "^2.10.36",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^22.13.17",
34
34
  "@types/progress": "^2.0.7",