@abaplint/transpiler 2.3.37 → 2.3.39

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.
@@ -7,7 +7,7 @@ const expressions_1 = require("../expressions");
7
7
  const chunk_1 = require("../chunk");
8
8
  class AssignTranspiler {
9
9
  transpile(node, traversal) {
10
- var _a, _b, _c;
10
+ var _a;
11
11
  const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
12
12
  const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressions(abaplint.Expressions.Source).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode())) || [];
13
13
  const fs = new expressions_1.FieldSymbolTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.FSTarget), traversal).getCode();
@@ -17,7 +17,8 @@ class AssignTranspiler {
17
17
  options.push("component: " + sources.shift());
18
18
  }
19
19
  options.push("target: " + fs);
20
- if (sources.length !== 0) {
20
+ if (sources.length !== 0
21
+ && (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(abaplint.Expressions.Dynamic)) === undefined) {
21
22
  options.push("source: " + sources.pop());
22
23
  }
23
24
  else {
@@ -45,21 +46,30 @@ class AssignTranspiler {
45
46
  else if (c.concatTokens() === "=>" || c.concatTokens() === "->") {
46
47
  dynamicName += " + '" + c.concatTokens() + "'";
47
48
  }
49
+ else {
50
+ if (dynamicName !== "") {
51
+ dynamicName += " + ";
52
+ }
53
+ dynamicName += "'" + c.concatTokens() + "'";
54
+ }
48
55
  }
49
56
  options.push(`dynamicName: ` + dynamicName);
50
- // dynamicSource is the first part only
51
- let dynamic = (_b = assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _b === void 0 ? void 0 : _b.findFirstExpression(abaplint.Expressions.ConstantString);
52
- if (dynamic) {
53
- const s = dynamic.getFirstToken().getStr().toLowerCase().match(/\w+/);
54
- options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
55
- }
56
- else {
57
- dynamic = (_c = assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _c === void 0 ? void 0 : _c.findFirstExpression(abaplint.Expressions.FieldChain);
58
- if (dynamic) {
59
- const code = new expressions_1.FieldChainTranspiler(true).transpile(dynamic, traversal).getCode();
57
+ // dynamicSource is the first part of the dynamic part
58
+ const first = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getFirstChild();
59
+ if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Dynamic && first instanceof abaplint.Nodes.ExpressionNode) {
60
+ const firstFirst = first.getChildren()[1];
61
+ if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.Constant) {
62
+ const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/);
63
+ options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
64
+ }
65
+ else if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
66
+ const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
60
67
  options.push(`dynamicSource: (() => {try { return eval(${code}.toLowerCase().match(/\\w+/)[0]); } catch {}})()`);
61
68
  }
62
69
  }
70
+ else if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Source && first instanceof abaplint.Nodes.ExpressionNode) {
71
+ options.push(`dynamicSource: (() => {try { return ${first.concatTokens()}; } catch {}})()`);
72
+ }
63
73
  }
64
74
  if (concat.endsWith(" CASTING.") || concat.includes(" CASTING TYPE ")) {
65
75
  options.push("casting: true");
@@ -17,6 +17,11 @@ class InsertDatabaseTranspiler {
17
17
  const tvalues = traversal.traverse(from);
18
18
  options.push(`"values": ` + tvalues.getCode());
19
19
  }
20
+ const fromTable = node.findExpressionAfterToken("TABLE");
21
+ if (fromTable && fromTable.get() instanceof abaplint.Expressions.SQLSource) {
22
+ const tvalues = traversal.traverse(fromTable);
23
+ options.push(`"table": ` + tvalues.getCode());
24
+ }
20
25
  return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
21
26
  }
22
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.3.37",
3
+ "version": "2.3.39",
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.72",
31
+ "@abaplint/core": "^2.93.74",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {