@abaplint/transpiler 2.6.25 → 2.6.27

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.
@@ -21,6 +21,7 @@ class ClassImplementationTranspiler {
21
21
  const scope = traversal.findCurrentScopeByToken(token);
22
22
  return new chunk_1.Chunk().append(ret + ` {
23
23
  static INTERNAL_TYPE = 'CLAS';
24
+ static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
24
25
  static IMPLEMENTED_INTERFACES = [${this.findImplementedClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
25
26
  static ATTRIBUTES = {${traversal.buildAttributes(def)}};`, node, traversal);
26
27
  }
@@ -23,6 +23,8 @@ class ClassDefinitionTranspiler {
23
23
  return new chunk_1.Chunk(`
24
24
  class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
25
25
  static INTERNAL_TYPE = 'CLAS';
26
+ static IMPLEMENTED_INTERFACES = [];
27
+ static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
26
28
  static ATTRIBUTES = {};
27
29
  async constructor_() {
28
30
  this.me = new abap.types.ABAPObject();
@@ -17,15 +17,14 @@ class TranspileTypes {
17
17
  return pre + t.getName().toLowerCase() + " = " + code + ";\n";
18
18
  }
19
19
  toType(type) {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
21
21
  let resolved = "";
22
22
  let extra = "";
23
23
  if (type instanceof abaplint.BasicTypes.ObjectReferenceType
24
24
  || type instanceof abaplint.BasicTypes.GenericObjectReferenceType) {
25
25
  resolved = "ABAPObject";
26
- if (type.getQualifiedName() !== undefined) {
27
- extra = "{qualifiedName: \"" + ((_a = type.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()) + "\"}";
28
- }
26
+ extra = "{qualifiedName: " + JSON.stringify((_a = type.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()) +
27
+ ", RTTIName: " + JSON.stringify((_b = type.getRTTIName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()) + "}";
29
28
  }
30
29
  else if (type instanceof abaplint.BasicTypes.TableType) {
31
30
  resolved = "Table";
@@ -39,31 +38,31 @@ class TranspileTypes {
39
38
  else if (type instanceof abaplint.BasicTypes.IntegerType) {
40
39
  resolved = "Integer";
41
40
  if (type.getQualifiedName() !== undefined) {
42
- extra = "{qualifiedName: \"" + ((_b = type.getQualifiedName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()) + "\"}";
41
+ extra = "{qualifiedName: \"" + ((_c = type.getQualifiedName()) === null || _c === void 0 ? void 0 : _c.toUpperCase()) + "\"}";
43
42
  }
44
43
  }
45
44
  else if (type instanceof abaplint.BasicTypes.StringType) {
46
45
  resolved = "String";
47
46
  if (type.getQualifiedName() !== undefined) {
48
- extra = "{qualifiedName: \"" + ((_c = type.getQualifiedName()) === null || _c === void 0 ? void 0 : _c.toUpperCase()) + "\"}";
47
+ extra = "{qualifiedName: \"" + ((_d = type.getQualifiedName()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) + "\"}";
49
48
  }
50
49
  }
51
50
  else if (type instanceof abaplint.BasicTypes.UTCLongType) {
52
51
  resolved = "UTCLong";
53
52
  if (type.getQualifiedName() !== undefined) {
54
- extra = "{qualifiedName: \"" + ((_d = type.getQualifiedName()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) + "\"}";
53
+ extra = "{qualifiedName: \"" + ((_e = type.getQualifiedName()) === null || _e === void 0 ? void 0 : _e.toUpperCase()) + "\"}";
55
54
  }
56
55
  }
57
56
  else if (type instanceof abaplint.BasicTypes.DateType) {
58
57
  resolved = "Date";
59
58
  if (type.getQualifiedName() !== undefined) {
60
- extra = "{qualifiedName: \"" + ((_e = type.getQualifiedName()) === null || _e === void 0 ? void 0 : _e.toUpperCase()) + "\"}";
59
+ extra = "{qualifiedName: \"" + ((_f = type.getQualifiedName()) === null || _f === void 0 ? void 0 : _f.toUpperCase()) + "\"}";
61
60
  }
62
61
  }
63
62
  else if (type instanceof abaplint.BasicTypes.TimeType) {
64
63
  resolved = "Time";
65
64
  if (type.getQualifiedName() !== undefined) {
66
- extra = "{qualifiedName: \"" + ((_f = type.getQualifiedName()) === null || _f === void 0 ? void 0 : _f.toUpperCase()) + "\"}";
65
+ extra = "{qualifiedName: \"" + ((_g = type.getQualifiedName()) === null || _g === void 0 ? void 0 : _g.toUpperCase()) + "\"}";
67
66
  }
68
67
  }
69
68
  else if (type instanceof abaplint.BasicTypes.DataReference) {
@@ -134,7 +133,7 @@ class TranspileTypes {
134
133
  else if (type instanceof abaplint.BasicTypes.XStringType) {
135
134
  resolved = "XString";
136
135
  if (type.getQualifiedName() !== undefined) {
137
- extra = "{qualifiedName: \"" + ((_g = type.getQualifiedName()) === null || _g === void 0 ? void 0 : _g.toUpperCase()) + "\"}";
136
+ extra = "{qualifiedName: \"" + ((_h = type.getQualifiedName()) === null || _h === void 0 ? void 0 : _h.toUpperCase()) + "\"}";
138
137
  }
139
138
  }
140
139
  else if (type instanceof abaplint.BasicTypes.XSequenceType) {
@@ -150,13 +149,13 @@ class TranspileTypes {
150
149
  else if (type instanceof abaplint.BasicTypes.FloatType) {
151
150
  resolved = "Float";
152
151
  if (type.getQualifiedName() !== undefined) {
153
- extra = "{qualifiedName: \"" + ((_h = type.getQualifiedName()) === null || _h === void 0 ? void 0 : _h.toUpperCase()) + "\"}";
152
+ extra = "{qualifiedName: \"" + ((_j = type.getQualifiedName()) === null || _j === void 0 ? void 0 : _j.toUpperCase()) + "\"}";
154
153
  }
155
154
  }
156
155
  else if (type instanceof abaplint.BasicTypes.FloatingPointType) {
157
156
  resolved = "Float";
158
157
  if (type.getQualifiedName() !== undefined) {
159
- extra = "{qualifiedName: \"" + ((_j = type.getQualifiedName()) === null || _j === void 0 ? void 0 : _j.toUpperCase()) + "\"}";
158
+ extra = "{qualifiedName: \"" + ((_k = type.getQualifiedName()) === null || _k === void 0 ? void 0 : _k.toUpperCase()) + "\"}";
160
159
  }
161
160
  }
162
161
  else if (type instanceof abaplint.BasicTypes.DecFloat34Type) {
@@ -45,6 +45,7 @@ export declare class Traversal {
45
45
  registerClassOrInterface(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
46
46
  setValues(identifier: abaplint.TypedIdentifier, name: string): string;
47
47
  static setValues(identifier: abaplint.TypedIdentifier, name: string): string;
48
+ buildInternalName(name: string, def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
48
49
  lookupClassOrInterface(name: string | undefined, token: abaplint.Token | undefined, directGlobal?: boolean): string;
49
50
  private buildPrefix;
50
51
  protected traverseStructure(node: abaplint.Nodes.StructureNode): Chunk;
@@ -479,14 +479,8 @@ class Traversal {
479
479
  if (def === undefined) {
480
480
  return "";
481
481
  }
482
- const name = def.getName();
483
- if (def.isGlobal() === false) {
484
- const prefix = this.buildPrefix();
485
- return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
486
- }
487
- else {
488
- return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
489
- }
482
+ const name = this.buildInternalName(def.getName(), def);
483
+ return `abap.Classes['${name}'] = ${Traversal.escapeNamespace(def.getName().toLowerCase())};`;
490
484
  }
491
485
  setValues(identifier, name) {
492
486
  return Traversal.setValues(identifier, name);
@@ -511,8 +505,21 @@ class Traversal {
511
505
  }
512
506
  return ret;
513
507
  }
514
- lookupClassOrInterface(name, token, directGlobal = false) {
508
+ buildInternalName(name, def) {
515
509
  var _a, _b;
510
+ if (def) {
511
+ if (def.isGlobal() === false) {
512
+ const prefix = this.buildPrefix();
513
+ return `${prefix}-${(_a = def === null || def === void 0 ? void 0 : def.getName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()}`;
514
+ }
515
+ else {
516
+ return (_b = def === null || def === void 0 ? void 0 : def.getName()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
517
+ }
518
+ }
519
+ // assume global
520
+ return name.toUpperCase();
521
+ }
522
+ lookupClassOrInterface(name, token, directGlobal = false) {
516
523
  if (name === undefined || token === undefined) {
517
524
  return "abap.Classes['undefined']";
518
525
  }
@@ -520,24 +527,12 @@ class Traversal {
520
527
  return "abap.Classes[" + name + ".trimEnd()]";
521
528
  }
522
529
  const scope = this.findCurrentScopeByToken(token);
523
- // todo, add explicit type,
524
530
  let def = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(name);
525
531
  if (def === undefined) {
526
532
  def = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
527
533
  }
528
- if (def) {
529
- if (def.isGlobal() === false) {
530
- const prefix = this.buildPrefix();
531
- return `abap.Classes['${prefix}-${(_a = def === null || def === void 0 ? void 0 : def.getName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()}']`;
532
- }
533
- else {
534
- return `abap.Classes['${(_b = def === null || def === void 0 ? void 0 : def.getName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()}']`;
535
- }
536
- }
537
- else {
538
- // assume global
539
- return "abap.Classes['" + name.toUpperCase() + "']";
540
- }
534
+ const internalName = this.buildInternalName(name, def);
535
+ return "abap.Classes['" + internalName + "']";
541
536
  }
542
537
  buildPrefix() {
543
538
  return this.obj.getType() + "-" + this.obj.getName();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.6.25",
3
+ "version": "2.6.27",
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.97.15",
31
+ "@abaplint/core": "^2.97.16",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {