@abaplint/transpiler 2.13.43 → 2.13.45

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,14 +7,12 @@ const type_name_or_infer_1 = require("./type_name_or_infer");
7
7
  const transpile_types_1 = require("../transpile_types");
8
8
  const cond_1 = require("./cond");
9
9
  const source_1 = require("./source");
10
+ const let_1 = require("./let");
10
11
  class CondBodyTranspiler {
11
12
  transpile(typ, body, traversal) {
12
13
  if (!(typ.get() instanceof core_1.Expressions.TypeNameOrInfer)) {
13
14
  throw new Error("CondBodyTranspiler, Expected TypeNameOrInfer");
14
15
  }
15
- else if (body.findDirectExpression(core_1.Expressions.Let)) {
16
- throw new Error("CondBodyTranspiler, Let not supported, todo");
17
- }
18
16
  const whenThen = [];
19
17
  const expressions = [];
20
18
  for (const c of body.getChildren()) {
@@ -23,7 +21,7 @@ class CondBodyTranspiler {
23
21
  break;
24
22
  }
25
23
  }
26
- else {
24
+ else if (!(c.get() instanceof core_1.Expressions.Let)) {
27
25
  expressions.push(c);
28
26
  }
29
27
  }
@@ -35,6 +33,10 @@ class CondBodyTranspiler {
35
33
  const ret = new chunk_1.Chunk();
36
34
  ret.appendString("(" + target + ".set(");
37
35
  ret.appendString("await (async () => {\n");
36
+ const llet = body.findDirectExpression(core_1.Expressions.Let);
37
+ if (llet) {
38
+ ret.appendString(new let_1.LetTranspiler().transpile(llet, traversal).getCode());
39
+ }
38
40
  for (const { when, then } of whenThen) {
39
41
  let condition = "";
40
42
  if (when.get() instanceof core_1.Expressions.Cond) {
@@ -94,7 +94,12 @@ class SourceTranspiler {
94
94
  ret = new chunk_1.Chunk().appendString("(").appendChunk(ret).appendString(").dereference()");
95
95
  }
96
96
  else if (c.get() instanceof core_1.Expressions.TextElement) {
97
- ret = new chunk_1.Chunk().appendString(`new abap.types.String().set("${c.concatTokens()}")`);
97
+ const key = c.findFirstExpression(core_1.Expressions.TextElementKey)?.concatTokens().toUpperCase();
98
+ const textSymbol = key === undefined
99
+ ? undefined
100
+ : traversal.getCurrentObject().getTextSymbols()[key]?.entry;
101
+ const value = textSymbol ?? c.concatTokens();
102
+ ret = new chunk_1.Chunk().appendString(`new abap.types.String().set(${JSON.stringify(value)})`);
98
103
  }
99
104
  else if (c.get() instanceof core_1.Expressions.TypeNameOrInfer) {
100
105
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.43",
3
+ "version": "2.13.45",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "author": "abaplint",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@abaplint/core": "^2.120.4",
32
+ "@abaplint/core": "^2.120.5",
33
33
  "source-map": "^0.7.6"
34
34
  },
35
35
  "devDependencies": {