@abaplint/transpiler 2.10.32 → 2.10.34

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.
@@ -45,7 +45,7 @@ class MethodSourceTranspiler {
45
45
  }
46
46
  else if (child.get() instanceof core_1.Expressions.Dynamic) {
47
47
  const second = child.getChildren()[1];
48
- const lookupException = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_METHOD'", child.getFirstToken(), true);
48
+ // const lookupException = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_METHOD'", child.getFirstToken(), true);
49
49
  if (second.get() instanceof core_1.Expressions.FieldChain && second instanceof core_1.Nodes.ExpressionNode) {
50
50
  if (call.endsWith(".")) {
51
51
  call = call.substring(0, call.length - 1);
@@ -56,19 +56,22 @@ class MethodSourceTranspiler {
56
56
  call = `abap.dynamicCallLookup(${call}, ${traversal.traverse(second).getCode()})`;
57
57
  }
58
58
  else if (second.get() instanceof core_1.Expressions.Constant) {
59
- if (call === "") {
60
- call = "this.";
59
+ if (call.endsWith(".")) {
60
+ call = call.substring(0, call.length - 1);
61
61
  }
62
- else if (call.endsWith(".") === false) {
63
- call += ".";
62
+ if (call === "") {
63
+ call = "this";
64
64
  }
65
- call += second.getFirstToken().getStr().replace(/[\'\`]/g, "").toLowerCase().replace("~", "$").trimEnd();
65
+ const methodName = second.getFirstToken().getStr().replace(/[\'\`]/g, "").toLowerCase().replace("~", "$").trimEnd();
66
+ call = `abap.dynamicCallLookup(${call}, "${methodName}")`;
66
67
  }
67
68
  else {
68
69
  ret.appendString("MethodSourceTranspiler-Unexpected");
69
70
  }
71
+ /*
70
72
  ret.appendString(`if (${call} === undefined && ${lookupException} === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_METHOD not found"; }\n`);
71
73
  ret.appendString(`if (${call} === undefined) { throw new ${lookupException}(); }\n`);
74
+ */
72
75
  }
73
76
  else if (child.get() instanceof core_1.Expressions.MethodName
74
77
  || child.get() instanceof core_1.Expressions.AttributeName) {
@@ -23,7 +23,6 @@ static INTERNAL_TYPE = 'CLAS';
23
23
  static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
24
24
  static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
25
25
  static ATTRIBUTES = {${traversal.buildAttributes(def, scope).join(",\n")}};
26
- static FRIENDS_ACCESS_STATIC = {}; // todo
27
26
  static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};`, node, traversal);
28
27
  }
29
28
  findImplementedInterface(traversal, def, scope) {
@@ -25,7 +25,6 @@ class ${className?.toLowerCase()} {
25
25
  static IMPLEMENTED_INTERFACES = [];
26
26
  static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
27
27
  static ATTRIBUTES = {};
28
- static FRIENDS_ACCESS_STATIC = {};
29
28
  async constructor_() {
30
29
  this.me = new abap.types.ABAPObject();
31
30
  this.me.set(this);
@@ -224,16 +224,20 @@ async function run() {
224
224
  ret += ` meth.skip();\n`;
225
225
  continue;
226
226
  }
227
+ const callSpecial = (name) => {
228
+ let ret = "";
229
+ ret += ` if (test.${name}) await test.${name}();\n`;
230
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.${name}) await test.FRIENDS_ACCESS_INSTANCE.${name}();\n`;
231
+ ret += ` if (test.FRIENDS_ACCESS_INSTANCE.SUPER && test.FRIENDS_ACCESS_INSTANCE.SUPER.${name}) await test.FRIENDS_ACCESS_INSTANCE.SUPER.${name}();\n`;
232
+ return ret;
233
+ };
227
234
  ret += ` {\n const test = await (new ${lc}()).constructor_();\n`;
228
- // todo, some refactoring here,
229
- ret += ` if (test.setup) await test.setup();\n`;
230
- ret += ` if (test.FRIENDS_ACCESS_INSTANCE.setup) await test.FRIENDS_ACCESS_INSTANCE.setup();\n`;
231
- ret += ` if (test.FRIENDS_ACCESS_INSTANCE.SUPER && test.FRIENDS_ACCESS_INSTANCE.SUPER.setup) await test.FRIENDS_ACCESS_INSTANCE.SUPER.setup();\n`;
235
+ ret += callSpecial("setup");
232
236
  ret += ` console.log("${st.obj.getName()}: running ${lc}->${m}");\n`;
233
237
  ret += ` meth = locl.addMethod("${m}");\n`;
234
238
  ret += ` await test.FRIENDS_ACCESS_INSTANCE.${m}();\n`;
235
239
  ret += ` meth.pass();\n`;
236
- ret += ` if (test.teardown) await test.teardown();\n`;
240
+ ret += callSpecial("teardown");
237
241
  ret += ` }\n`;
238
242
  }
239
243
  ret += ` if (${lc}.class_teardown) await ${lc}.class_teardown();\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.10.32",
3
+ "version": "2.10.34",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",