@abaplint/transpiler 2.0.26 → 2.0.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.
@@ -12,7 +12,10 @@ class SourceTranspiler {
12
12
  transpile(node, traversal) {
13
13
  let ret = new chunk_1.Chunk();
14
14
  const post = new chunk_1.Chunk();
15
- for (const c of node.getChildren()) {
15
+ const children = node.getChildren();
16
+ for (let i = 0; i < children.length; i++) {
17
+ const c = children[i];
18
+ const last = i === children.length - 1;
16
19
  if (c instanceof core_1.Nodes.ExpressionNode) {
17
20
  if (c.get() instanceof core_1.Expressions.FieldChain) {
18
21
  ret.appendChunk(new _1.FieldChainTranspiler(this.addGet).transpile(c, traversal));
@@ -35,14 +38,12 @@ class SourceTranspiler {
35
38
  }
36
39
  else if (c.get() instanceof core_1.Expressions.MethodCallChain) {
37
40
  ret.appendChunk(traversal.traverse(c));
38
- if (this.addGet) {
39
- const code = ret.getCode();
40
- if (code.includes("await")) {
41
- ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).appendString(").get()");
42
- }
43
- else {
44
- ret.append(".get()", c, traversal);
45
- }
41
+ const code = ret.getCode();
42
+ if (code.includes("await")) {
43
+ ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).appendString(")");
44
+ }
45
+ if (this.addGet && last === true) {
46
+ ret.append(".get()", c, traversal);
46
47
  }
47
48
  }
48
49
  else if (c.get() instanceof core_1.Expressions.Source) {
@@ -57,6 +58,9 @@ class SourceTranspiler {
57
58
  else if (c.get() instanceof core_1.Expressions.ComponentChain) {
58
59
  ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).appendString(").get().");
59
60
  ret.appendChunk(new _1.ComponentChainTranspiler().transpile(c, traversal));
61
+ if (this.addGet && last === true) {
62
+ ret.append(".get()", c, traversal);
63
+ }
60
64
  }
61
65
  else if (c.get() instanceof core_1.Expressions.Dereference) {
62
66
  ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).appendString(").getPointer()");
@@ -82,6 +86,7 @@ class SourceTranspiler {
82
86
  }
83
87
  }
84
88
  ret.appendChunk(post);
89
+ // console.dir(ret.getCode());
85
90
  return ret;
86
91
  }
87
92
  }
@@ -15,7 +15,7 @@ class EndMethodTranspiler {
15
15
  const vars = scope.getData().vars;
16
16
  for (const n in vars) {
17
17
  const identifier = vars[n];
18
- if (identifier.getMeta().includes("returning" /* MethodReturning */)) {
18
+ if (identifier.getMeta().includes("returning" /* abaplint.IdentifierMeta.MethodReturning */)) {
19
19
  returning += "return " + n.toLowerCase() + ";\n";
20
20
  }
21
21
  }
@@ -31,14 +31,14 @@ class MethodImplementationTranspiler {
31
31
  for (const n in vars) {
32
32
  const identifier = vars[n];
33
33
  const varName = n.toLowerCase();
34
- if (identifier.getMeta().includes("importing" /* MethodImporting */)
35
- || identifier.getMeta().includes("changing" /* MethodChanging */)
36
- || identifier.getMeta().includes("exporting" /* MethodExporting */)) {
34
+ if (identifier.getMeta().includes("importing" /* abaplint.IdentifierMeta.MethodImporting */)
35
+ || identifier.getMeta().includes("changing" /* abaplint.IdentifierMeta.MethodChanging */)
36
+ || identifier.getMeta().includes("exporting" /* abaplint.IdentifierMeta.MethodExporting */)) {
37
37
  if (unique === "") {
38
38
  unique = "INPUT";
39
39
  }
40
40
  after = after + new transpile_types_1.TranspileTypes().declare(identifier) + "\n";
41
- if (identifier.getMeta().includes("importing" /* MethodImporting */) && identifier.getType().isGeneric() === false) {
41
+ if (identifier.getMeta().includes("importing" /* abaplint.IdentifierMeta.MethodImporting */) && identifier.getType().isGeneric() === false) {
42
42
  after += "if (" + unique + " && " + unique + "." + varName + ") {" + varName + ".set(" + unique + "." + varName + ");}\n";
43
43
  }
44
44
  else {
@@ -71,7 +71,7 @@ class MethodImplementationTranspiler {
71
71
  after += "if (" + unique + " === undefined || " + unique + "." + varName + " === undefined) {" + varName + " = " + val + ";}\n";
72
72
  }
73
73
  }
74
- else if (identifier.getMeta().includes("returning" /* MethodReturning */)) {
74
+ else if (identifier.getMeta().includes("returning" /* abaplint.IdentifierMeta.MethodReturning */)) {
75
75
  after = after + new transpile_types_1.TranspileTypes().declare(identifier) + "\n";
76
76
  }
77
77
  }
@@ -9,7 +9,7 @@ class ReturnTranspiler {
9
9
  const vars = scope === null || scope === void 0 ? void 0 : scope.getData().vars;
10
10
  for (const n in vars) {
11
11
  const identifier = vars[n];
12
- if (identifier.getMeta().includes("returning" /* MethodReturning */)) {
12
+ if (identifier.getMeta().includes("returning" /* abaplint.IdentifierMeta.MethodReturning */)) {
13
13
  extra = " " + n.toLowerCase();
14
14
  }
15
15
  }
@@ -36,8 +36,8 @@ class InterfaceTranspiler {
36
36
  let ret = "\n";
37
37
  for (const n in vars) {
38
38
  const identifier = vars[n];
39
- if (identifier.getMeta().includes("static" /* Static */) === false
40
- || identifier.getMeta().includes("read_only" /* ReadOnly */) === false) {
39
+ if (identifier.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === false
40
+ || identifier.getMeta().includes("read_only" /* abaplint.IdentifierMeta.ReadOnly */) === false) {
41
41
  continue;
42
42
  }
43
43
  const interfaceName = node.getFirstToken().getStr().toLowerCase();
@@ -154,7 +154,7 @@ class Traversal {
154
154
  const found = scope.findScopeForVariable(name);
155
155
  const id = scope.findVariable(name);
156
156
  if (found && id
157
- && id.getMeta().includes("static" /* Static */)
157
+ && id.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */)
158
158
  && found.stype === abaplint.ScopeType.ClassImplementation) {
159
159
  // console.dir(found.sname);
160
160
  return found.sname.toLowerCase();
@@ -261,7 +261,7 @@ class Traversal {
261
261
  ret += "this.me = new abap.types.ABAPObject();\n";
262
262
  ret += "this.me.set(this);\n";
263
263
  for (const a of def.getAttributes().getAll()) {
264
- if (a.getMeta().includes("static" /* Static */) === true) {
264
+ if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
265
265
  continue;
266
266
  }
267
267
  const name = a.getName().toLowerCase();
@@ -305,7 +305,7 @@ class Traversal {
305
305
  let ret = "";
306
306
  const intf = this.findInterfaceDefinition(name, scope);
307
307
  for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getAll()) || []) {
308
- if (a.getMeta().includes("static" /* Static */) === true) {
308
+ if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
309
309
  continue;
310
310
  }
311
311
  const n = name.toLowerCase() + "$" + a.getName().toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.0.26",
3
+ "version": "2.0.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.90.6",
31
+ "@abaplint/core": "^2.90.9",
32
32
  "source-map": "^0.7.3"
33
33
  },
34
34
  "devDependencies": {
@@ -37,6 +37,6 @@
37
37
  "chai": "^4.3.6",
38
38
  "mocha": "^10.0.0",
39
39
  "source-map-support": "^0.5.21",
40
- "typescript": "^4.6.4"
40
+ "typescript": "^4.7.2"
41
41
  }
42
42
  }