@abaplint/transpiler-cli 2.3.126 → 2.4.0

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 +73 -0
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -69286,6 +69286,55 @@ exports.HandleTableType = HandleTableType;
69286
69286
 
69287
69287
  /***/ }),
69288
69288
 
69289
+ /***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_type_pool.js":
69290
+ /*!**********************************************************************************!*\
69291
+ !*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_type_pool.js ***!
69292
+ \**********************************************************************************/
69293
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
69294
+
69295
+ "use strict";
69296
+
69297
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
69298
+ exports.HandleTypePool = void 0;
69299
+ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
69300
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
69301
+ const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
69302
+ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
69303
+ class HandleTypePool {
69304
+ runObject(obj, reg) {
69305
+ var _a;
69306
+ const spaghetti = (_a = new abaplint.SyntaxLogic(reg, obj).run().spaghetti.getFirstChild()) === null || _a === void 0 ? void 0 : _a.getFirstChild();
69307
+ const chunk = new chunk_1.Chunk();
69308
+ chunk.appendString(`const pool = {};\n`);
69309
+ for (const v in spaghetti === null || spaghetti === void 0 ? void 0 : spaghetti.getData().vars) {
69310
+ const abs = spaghetti.getData().vars[v];
69311
+ const name = `pool['${v.toLowerCase()}']`;
69312
+ chunk.appendString(`${name} = ${new transpile_types_1.TranspileTypes().toType(abs.getType())};\n`);
69313
+ chunk.appendString(traversal_1.Traversal.setValues(abs, name));
69314
+ }
69315
+ for (const t in spaghetti === null || spaghetti === void 0 ? void 0 : spaghetti.getData().types) {
69316
+ const abs = spaghetti.getData().types[t];
69317
+ chunk.appendString(`pool['${t.toLowerCase()}'] = ${new transpile_types_1.TranspileTypes().toType(abs.getType())};\n`);
69318
+ }
69319
+ chunk.appendString(`abap.TypePools['${obj.getName()}'] = pool;`);
69320
+ const output = {
69321
+ object: {
69322
+ name: obj.getName(),
69323
+ type: obj.getType(),
69324
+ },
69325
+ filename: obj.getName().toLowerCase() + "." + obj.getType().toLowerCase() + ".mjs",
69326
+ chunk: chunk,
69327
+ requires: [],
69328
+ exports: [],
69329
+ };
69330
+ return [output];
69331
+ }
69332
+ }
69333
+ exports.HandleTypePool = HandleTypePool;
69334
+ //# sourceMappingURL=handle_type_pool.js.map
69335
+
69336
+ /***/ }),
69337
+
69289
69338
  /***/ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_view.js":
69290
69339
  /*!*****************************************************************************!*\
69291
69340
  !*** ./node_modules/@abaplint/transpiler/build/src/handlers/handle_view.js ***!
@@ -69352,6 +69401,7 @@ const handle_data_element_1 = __webpack_require__(/*! ./handlers/handle_data_ele
69352
69401
  const handle_table_type_1 = __webpack_require__(/*! ./handlers/handle_table_type */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_table_type.js");
69353
69402
  const handle_view_1 = __webpack_require__(/*! ./handlers/handle_view */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_view.js");
69354
69403
  const handle_enqu_1 = __webpack_require__(/*! ./handlers/handle_enqu */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_enqu.js");
69404
+ const handle_type_pool_1 = __webpack_require__(/*! ./handlers/handle_type_pool */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_type_pool.js");
69355
69405
  class Transpiler {
69356
69406
  constructor(options) {
69357
69407
  this.options = options;
@@ -69397,6 +69447,9 @@ class Transpiler {
69397
69447
  if (obj instanceof abaplint.ABAPObject && !(obj instanceof abaplint.Objects.TypePool)) {
69398
69448
  output.objects.push(...new handle_abap_1.HandleABAP(this.options).runObject(obj, reg));
69399
69449
  }
69450
+ else if (obj instanceof abaplint.Objects.TypePool) {
69451
+ output.objects.push(...new handle_type_pool_1.HandleTypePool().runObject(obj, reg));
69452
+ }
69400
69453
  else if (obj instanceof abaplint.Objects.Table) {
69401
69454
  output.objects.push(...new handle_table_1.HandleTable().runObject(obj, reg));
69402
69455
  }
@@ -75963,6 +76016,10 @@ class Traversal {
75963
76016
  else if (this.isBuiltinVariable(t)) {
75964
76017
  name = "abap.builtin." + name;
75965
76018
  }
76019
+ else if (this.isTypePool(t)) {
76020
+ const tp = this.isTypePool(t);
76021
+ name = `abap.TypePools["${tp}"].` + name.toLowerCase();
76022
+ }
75966
76023
  return name;
75967
76024
  }
75968
76025
  isStaticClassAttribute(token) {
@@ -76038,6 +76095,18 @@ class Traversal {
76038
76095
  }
76039
76096
  return false;
76040
76097
  }
76098
+ isTypePool(token) {
76099
+ const ref = this.findReadOrWriteReference(token);
76100
+ if (ref === null || ref === void 0 ? void 0 : ref.getFilename().endsWith(".type.abap")) {
76101
+ const file = this.reg.getFileByName(ref.getFilename());
76102
+ if (file === undefined) {
76103
+ return undefined;
76104
+ }
76105
+ const obj = this.reg.findObjectForFile(file);
76106
+ return obj === null || obj === void 0 ? void 0 : obj.getName();
76107
+ }
76108
+ return undefined;
76109
+ }
76041
76110
  // returns the interface name if interfaced
76042
76111
  isInterfaceAttribute(token) {
76043
76112
  const ref = this.findReadOrWriteReference(token);
@@ -76234,6 +76303,9 @@ class Traversal {
76234
76303
  }
76235
76304
  }
76236
76305
  setValues(identifier, name) {
76306
+ return Traversal.setValues(identifier, name);
76307
+ }
76308
+ static setValues(identifier, name) {
76237
76309
  const val = identifier.getValue();
76238
76310
  let ret = "";
76239
76311
  if (typeof val === "string") {
@@ -76584,6 +76656,7 @@ run().then(() => {
76584
76656
  if (obj instanceof abaplint.Objects.Table
76585
76657
  || obj instanceof abaplint.Objects.DataElement
76586
76658
  || obj instanceof abaplint.Objects.LockObject
76659
+ || obj instanceof abaplint.Objects.TypePool
76587
76660
  || obj instanceof abaplint.Objects.TableType) {
76588
76661
  list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
76589
76662
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.3.126",
3
+ "version": "2.4.0",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,7 +25,7 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.3.126",
28
+ "@abaplint/transpiler": "^2.4.0",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",