@abaplint/transpiler 2.3.50 → 2.3.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.
@@ -4,7 +4,6 @@ exports.ClassImplementationTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  const traversal_1 = require("../traversal");
6
6
  const transpile_types_1 = require("../transpile_types");
7
- const expressions_1 = require("../expressions");
8
7
  const chunk_1 = require("../chunk");
9
8
  class ClassImplementationTranspiler {
10
9
  transpile(node, traversal) {
@@ -88,19 +87,7 @@ class ClassImplementationTranspiler {
88
87
  for (const attr of staticAttributes) {
89
88
  const name = traversal_1.Traversal.escapeClassName(clasName) + "." + attr.prefix + attr.identifier.getName().toLowerCase();
90
89
  ret += name + " = " + new transpile_types_1.TranspileTypes().toType(attr.identifier.getType()) + ";\n";
91
- const val = attr.identifier.getValue();
92
- if (typeof val === "string") {
93
- const e = new expressions_1.ConstantTranspiler().escape(val);
94
- ret += name + ".set(" + e + ");\n";
95
- }
96
- else if (typeof val === "object") {
97
- const a = val;
98
- for (const v of Object.keys(val)) {
99
- let s = a[v];
100
- s = new expressions_1.ConstantTranspiler().escape(s);
101
- ret += name + ".get()." + v + ".set(" + s + ");\n";
102
- }
103
- }
90
+ ret += traversal.setValues(attr.identifier, name);
104
91
  }
105
92
  for (const alias of cdef.getAliases().getAll()) {
106
93
  const isStatic = staticAttributes.some(s => s.prefix.replace("$", "~") + s.identifier.getName() === alias.getComponent());
@@ -67,21 +67,7 @@ class InterfaceTranspiler {
67
67
  ret += name + ".set(" + e + ");\n";
68
68
  continue;
69
69
  }
70
- const val = identifier.getValue();
71
- if (typeof val === "string") {
72
- const e = new expressions_1.ConstantTranspiler().escape(val);
73
- ret += name + ".set(" + e + ");\n";
74
- }
75
- else if (typeof val === "object") {
76
- const a = val;
77
- for (const v of Object.keys(val)) {
78
- const s = a[v];
79
- if (s === undefined) {
80
- continue;
81
- }
82
- ret += name + ".get()." + v + ".set(" + s + ");\n";
83
- }
84
- }
70
+ ret += traversal.setValues(identifier, name);
85
71
  }
86
72
  return ret;
87
73
  }
@@ -40,6 +40,7 @@ export declare class Traversal {
40
40
  isInsideLoop(node: abaplint.Nodes.StatementNode): boolean;
41
41
  isInsideDoOrWhile(node: abaplint.Nodes.StatementNode): boolean;
42
42
  registerClassOrInterface(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
43
+ setValues(identifier: abaplint.TypedIdentifier, name: string): string;
43
44
  lookupClassOrInterface(name: string | undefined, token: abaplint.Token | undefined, directGlobal?: boolean): string;
44
45
  private buildPrefix;
45
46
  protected traverseStructure(node: abaplint.Nodes.StructureNode): Chunk;
@@ -7,6 +7,7 @@ const ExpressionTranspilers = require("./expressions");
7
7
  const StructureTranspilers = require("./structures");
8
8
  const transpile_types_1 = require("./transpile_types");
9
9
  const chunk_1 = require("./chunk");
10
+ const expressions_1 = require("./expressions");
10
11
  class Traversal {
11
12
  constructor(spaghetti, file, obj, reg, runtimeTypeError = false) {
12
13
  this.scopeCache = undefined;
@@ -263,8 +264,9 @@ class Traversal {
263
264
  if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
264
265
  continue;
265
266
  }
266
- const name = a.getName().toLowerCase();
267
- ret += "this." + name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
267
+ const name = "this." + a.getName().toLowerCase();
268
+ ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
269
+ ret += this.setValues(a, name);
268
270
  }
269
271
  // attributes from directly implemented interfaces(not interfaces implemented in super classes)
270
272
  for (const i of def.getImplementing()) {
@@ -404,6 +406,25 @@ class Traversal {
404
406
  return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.escapeClassName(name.toLowerCase())};`;
405
407
  }
406
408
  }
409
+ setValues(identifier, name) {
410
+ const val = identifier.getValue();
411
+ let ret = "";
412
+ if (typeof val === "string") {
413
+ const e = new expressions_1.ConstantTranspiler().escape(val);
414
+ ret += name + ".set(" + e + ");\n";
415
+ }
416
+ else if (typeof val === "object") {
417
+ const a = val;
418
+ for (const v of Object.keys(val)) {
419
+ const s = a[v];
420
+ if (s === undefined) {
421
+ continue;
422
+ }
423
+ ret += name + ".get()." + v + ".set(" + s + ");\n";
424
+ }
425
+ }
426
+ return ret;
427
+ }
407
428
  lookupClassOrInterface(name, token, directGlobal = false) {
408
429
  var _a, _b;
409
430
  if (name === undefined || token === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.3.50",
3
+ "version": "2.3.51",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "author": "abaplint",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@abaplint/core": "^2.93.87",
31
+ "@abaplint/core": "^2.93.92",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {