@abaplint/transpiler 2.7.164 → 2.8.0

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.
Files changed (72) hide show
  1. package/build/src/db/index.js +2 -3
  2. package/build/src/db/schema_generation/pg_database_schema.js +1 -1
  3. package/build/src/db/schema_generation/snowflake_database_schema.js +1 -1
  4. package/build/src/db/schema_generation/sqlite_database_schema.js +1 -1
  5. package/build/src/expressions/call_transformation_parameters.js +1 -2
  6. package/build/src/expressions/compare.js +2 -3
  7. package/build/src/expressions/component_compare.js +2 -2
  8. package/build/src/expressions/constant.js +6 -1
  9. package/build/src/expressions/method_call.js +3 -4
  10. package/build/src/expressions/method_call_param.js +2 -3
  11. package/build/src/expressions/method_source.js +1 -1
  12. package/build/src/expressions/parameter_s.js +2 -3
  13. package/build/src/expressions/parameter_t.js +2 -3
  14. package/build/src/expressions/sql_cond.js +2 -3
  15. package/build/src/expressions/sql_source.js +1 -1
  16. package/build/src/handlers/handle_abap.js +6 -9
  17. package/build/src/handlers/handle_data_element.js +1 -2
  18. package/build/src/handlers/handle_enqu.js +1 -2
  19. package/build/src/handlers/handle_msag.js +1 -2
  20. package/build/src/handlers/handle_oa2p.js +1 -2
  21. package/build/src/handlers/handle_smim.js +4 -5
  22. package/build/src/handlers/handle_table.js +1 -2
  23. package/build/src/handlers/handle_table_type.js +1 -2
  24. package/build/src/handlers/handle_type_pool.js +3 -4
  25. package/build/src/handlers/handle_view.js +1 -2
  26. package/build/src/handlers/handle_w3mi.js +4 -5
  27. package/build/src/index.js +7 -8
  28. package/build/src/requires.js +6 -7
  29. package/build/src/statements/assign.js +10 -11
  30. package/build/src/statements/call.js +5 -7
  31. package/build/src/statements/call_function.js +2 -3
  32. package/build/src/statements/call_transformation.js +1 -2
  33. package/build/src/statements/class_implementation.js +3 -4
  34. package/build/src/statements/concatenate.js +1 -2
  35. package/build/src/statements/convert.js +8 -8
  36. package/build/src/statements/create_data.js +3 -4
  37. package/build/src/statements/create_object.js +5 -7
  38. package/build/src/statements/data.js +1 -2
  39. package/build/src/statements/end_method.js +6 -7
  40. package/build/src/statements/field_symbol.js +1 -1
  41. package/build/src/statements/find.js +3 -4
  42. package/build/src/statements/form.js +4 -4
  43. package/build/src/statements/loop.js +7 -8
  44. package/build/src/statements/method_implementation.js +9 -11
  45. package/build/src/statements/move.js +1 -2
  46. package/build/src/statements/open_cursor.js +4 -4
  47. package/build/src/statements/perform.js +7 -8
  48. package/build/src/statements/raise.js +4 -5
  49. package/build/src/statements/read_table.js +3 -3
  50. package/build/src/statements/receive.js +1 -2
  51. package/build/src/statements/replace.js +1 -1
  52. package/build/src/statements/return.js +3 -3
  53. package/build/src/statements/select.js +1 -2
  54. package/build/src/statements/tables.js +1 -2
  55. package/build/src/statements/write.js +1 -2
  56. package/build/src/structures/at.js +7 -5
  57. package/build/src/structures/case.js +1 -2
  58. package/build/src/structures/case_type.js +2 -3
  59. package/build/src/structures/class_definition.js +2 -3
  60. package/build/src/structures/class_implementation.js +3 -5
  61. package/build/src/structures/constants.js +2 -3
  62. package/build/src/structures/data.js +2 -3
  63. package/build/src/structures/function_module.js +3 -5
  64. package/build/src/structures/interface.js +5 -6
  65. package/build/src/structures/loop.js +1 -2
  66. package/build/src/structures/select.js +2 -3
  67. package/build/src/structures/try.js +1 -1
  68. package/build/src/transpile_types.js +11 -12
  69. package/build/src/traversal.js +33 -38
  70. package/build/src/unit_test.js +2 -3
  71. package/build/src/validation.js +3 -4
  72. package/package.json +1 -1
@@ -5,8 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class ReceiveTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
9
- const fmchild = (_a = node.findDirectExpression(abaplint.Expressions.FunctionName)) === null || _a === void 0 ? void 0 : _a.getFirstChild();
8
+ const fmchild = node.findDirectExpression(abaplint.Expressions.FunctionName)?.getFirstChild();
10
9
  if (fmchild === undefined) {
11
10
  throw new Error("ReceiveTranspilerNameNotFound");
12
11
  }
@@ -33,7 +33,7 @@ class ReplaceTranspiler {
33
33
  extra.push("sectionOffset: " + new expressions_1.SourceTranspiler().transpile(offset, traversal).getCode());
34
34
  }
35
35
  const r = node.findDirectExpression(abaplint.Expressions.FindType);
36
- const type = r === null || r === void 0 ? void 0 : r.concatTokens().toUpperCase();
36
+ const type = r?.concatTokens().toUpperCase();
37
37
  if (type === "REGEX") {
38
38
  extra.push("regex: " + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());
39
39
  }
@@ -8,7 +8,7 @@ class ReturnTranspiler {
8
8
  transpile(node, traversal) {
9
9
  let extra = "";
10
10
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
11
- const vars = scope === null || scope === void 0 ? void 0 : scope.getData().vars;
11
+ const vars = scope?.getData().vars;
12
12
  for (const n in vars) {
13
13
  const identifier = vars[n];
14
14
  if (identifier.getMeta().includes("returning" /* abaplint.IdentifierMeta.MethodReturning */)) {
@@ -19,8 +19,8 @@ class ReturnTranspiler {
19
19
  if (traversal.isInsideDoOrWhile(node)) {
20
20
  pre = `abap.builtin.sy.get().index.set(${unique_identifier_1.UniqueIdentifier.getIndexBackup1()});\n`;
21
21
  }
22
- if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Method
23
- && (scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname.toLowerCase()) === "constructor") {
22
+ if (scope?.getIdentifier().stype === abaplint.ScopeType.Method
23
+ && scope?.getIdentifier().sname.toLowerCase() === "constructor") {
24
24
  extra = " this";
25
25
  }
26
26
  return new chunk_1.Chunk().append(pre + "return" + extra + ";", node, traversal);
@@ -12,7 +12,6 @@ function escapeRegExp(string) {
12
12
  // TODO: currently SELECT into are always handled as CORRESPONDING
13
13
  class SelectTranspiler {
14
14
  transpile(node, traversal, targetOverride) {
15
- var _a;
16
15
  let target = "undefined";
17
16
  if (targetOverride) {
18
17
  // SelectLoop structure uses override
@@ -89,7 +88,7 @@ class SelectTranspiler {
89
88
  if (node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) {
90
89
  const unique = unique_identifier_1.UniqueIdentifier.get();
91
90
  const unique2 = unique_identifier_1.UniqueIdentifier.get();
92
- const fn = (_a = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.SQLSource);
91
+ const fn = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)?.findDirectExpression(abaplint.Expressions.SQLSource);
93
92
  const faeTranspiled = new expressions_1.SQLSourceTranspiler().transpile(fn, traversal).getCode();
94
93
  select = select.replace(new RegExp(" " + escapeRegExp(faeTranspiled), "g"), " " + unique);
95
94
  select = select.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
@@ -6,8 +6,7 @@ const transpile_types_1 = require("../transpile_types");
6
6
  const chunk_1 = require("../chunk");
7
7
  class TablesTranspiler {
8
8
  transpile(node, traversal) {
9
- var _a;
10
- const token = (_a = node.findFirstExpression(abaplint.Expressions.Field)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
9
+ const token = node.findFirstExpression(abaplint.Expressions.Field)?.getFirstToken();
11
10
  if (token === undefined) {
12
11
  throw new Error("TablesTranspiler, token not found");
13
12
  }
@@ -5,10 +5,9 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class WriteTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
9
8
  const extra = [];
10
9
  let source;
11
- const newLine = ((_a = node.findFirstExpression(abaplint.Expressions.WriteOffsetLength)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText("/")) !== undefined;
10
+ const newLine = node.findFirstExpression(abaplint.Expressions.WriteOffsetLength)?.findDirectTokenByText("/") !== undefined;
12
11
  const concat = node.concatTokens().toUpperCase();
13
12
  const target = node.findDirectExpression(abaplint.Expressions.Target);
14
13
  if (target) {
@@ -7,16 +7,18 @@ const statements_1 = require("../statements");
7
7
  const unique_identifier_1 = require("../unique_identifier");
8
8
  class AtTranspiler {
9
9
  transpile(node, traversal, previous, loopTarget, tabix, loopStatement) {
10
- var _a, _b;
11
10
  const ret = new chunk_1.Chunk();
12
11
  const atStatement = node.findDirectStatement(abaplint.Statements.At);
13
- const concat = atStatement === null || atStatement === void 0 ? void 0 : atStatement.concatTokens().toUpperCase();
14
- const name = (_b = (_a = atStatement === null || atStatement === void 0 ? void 0 : atStatement.findDirectExpression(abaplint.Expressions.FieldSub)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
12
+ const concat = atStatement?.concatTokens().toUpperCase();
13
+ const name = atStatement
14
+ ?.findDirectExpression(abaplint.Expressions.FieldSub)
15
+ ?.concatTokens()
16
+ ?.toLowerCase();
15
17
  let suffix = `.get().${name}`;
16
18
  if (name === "table_line") {
17
19
  suffix = "";
18
20
  }
19
- if (concat === null || concat === void 0 ? void 0 : concat.startsWith("AT NEW ")) {
21
+ if (concat?.startsWith("AT NEW ")) {
20
22
  // eslint-disable-next-line max-len
21
23
  ret.appendString(`if (${previous} === undefined || abap.compare.eq(${previous}${suffix}, ${loopTarget}${suffix}) === false) {\n`);
22
24
  const body = node.findDirectStructure(abaplint.Structures.Body);
@@ -25,7 +27,7 @@ class AtTranspiler {
25
27
  }
26
28
  ret.appendString("}\n");
27
29
  }
28
- else if (concat === null || concat === void 0 ? void 0 : concat.startsWith("AT END OF ")) {
30
+ else if (concat?.startsWith("AT END OF ")) {
29
31
  const next = unique_identifier_1.UniqueIdentifier.get();
30
32
  ret.appendString(`let ${next} = undefined;\n`);
31
33
  const loop = new statements_1.LoopTranspiler({ injectFrom: tabix, skipInto: true });
@@ -7,9 +7,8 @@ const statements_1 = require("../statements");
7
7
  const chunk_1 = require("../chunk");
8
8
  class CaseTranspiler {
9
9
  transpile(node, traversal) {
10
- var _a;
11
10
  // does not use switch(), as it break;'s EXITs
12
- const s = (_a = node.findDirectStatement(abaplint.Statements.Case)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.Source);
11
+ const s = node.findDirectStatement(abaplint.Statements.Case)?.findDirectExpression(abaplint.Expressions.Source);
13
12
  if (s === undefined) {
14
13
  throw new Error("CASE, no Source found");
15
14
  }
@@ -6,9 +6,8 @@ const unique_identifier_1 = require("../unique_identifier");
6
6
  const chunk_1 = require("../chunk");
7
7
  class CaseTypeTranspiler {
8
8
  transpile(node, traversal) {
9
- var _a;
10
9
  // does not use switch(), as it break;'s EXITs
11
- const s = (_a = node.findDirectStatement(abaplint.Statements.CaseType)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.Source);
10
+ const s = node.findDirectStatement(abaplint.Statements.CaseType)?.findDirectExpression(abaplint.Expressions.Source);
12
11
  if (s === undefined) {
13
12
  throw new Error("CASE TYPE, no Source found");
14
13
  }
@@ -30,7 +29,7 @@ class CaseTypeTranspiler {
30
29
  ret.appendString("} else if (");
31
30
  }
32
31
  const cname = c.findDirectExpression(abaplint.Expressions.ClassName);
33
- const lookup = traversal.lookupClassOrInterface(cname === null || cname === void 0 ? void 0 : cname.concatTokens(), cname === null || cname === void 0 ? void 0 : cname.getFirstToken());
32
+ const lookup = traversal.lookupClassOrInterface(cname?.concatTokens(), cname?.getFirstToken());
34
33
  ret.appendString(u + ".get() instanceof " + lookup);
35
34
  ret.appendString(") {\n");
36
35
  ret.appendString(traversal.traverse(c.findDirectExpression(abaplint.Expressions.Target)).getCode() + ".set(" + u + ")\n");
@@ -5,8 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  class ClassDefinitionTranspiler {
7
7
  transpile(node, traversal) {
8
- var _a;
9
- const className = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
8
+ const className = node.findFirstExpression(abaplint.Expressions.ClassName)?.concatTokens().toUpperCase();
10
9
  let found = false;
11
10
  if (className !== undefined) {
12
11
  for (const a of traversal.getCurrentObject().getABAPFiles()) {
@@ -21,7 +20,7 @@ class ClassDefinitionTranspiler {
21
20
  else {
22
21
  // its an abstract class with only abstract methods
23
22
  return new chunk_1.Chunk(`
24
- class ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {
23
+ class ${className?.toLowerCase()} {
25
24
  static INTERNAL_TYPE = 'CLAS';
26
25
  static IMPLEMENTED_INTERFACES = [];
27
26
  static INTERNAL_NAME = 'ABSTRACT_CLASS_INTERNAL_NAME';
@@ -25,10 +25,9 @@ class ClassImplementationTranspiler {
25
25
  }
26
26
  ///////////////////////////////
27
27
  hasConstructor(node) {
28
- var _a;
29
28
  for (const m of node.findAllStatements(abaplint.Statements.MethodImplementation)) {
30
- const name = (_a = m.findFirstExpression(abaplint.Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
31
- if ((name === null || name === void 0 ? void 0 : name.toUpperCase()) === "CONSTRUCTOR") {
29
+ const name = m.findFirstExpression(abaplint.Expressions.MethodName)?.getFirstToken().getStr();
30
+ if (name?.toUpperCase() === "CONSTRUCTOR") {
32
31
  return true;
33
32
  }
34
33
  }
@@ -129,12 +128,11 @@ class ClassImplementationTranspiler {
129
128
  return ret;
130
129
  }
131
130
  buildConstructor(node, traversal) {
132
- var _a;
133
131
  if (node === undefined) {
134
132
  throw new Error("buildConstructor node undefined");
135
133
  }
136
134
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
137
- const token = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
135
+ const token = node.findFirstExpression(abaplint.Expressions.ClassName)?.getFirstToken();
138
136
  if (token === undefined) {
139
137
  throw "buildConstructorTokenNotFound";
140
138
  }
@@ -6,19 +6,18 @@ const statements_1 = require("../statements");
6
6
  const chunk_1 = require("../chunk");
7
7
  class ConstantsTranspiler {
8
8
  transpile(node, traversal) {
9
- var _a, _b;
10
9
  const begin = node.findDirectStatement(abaplint.Statements.ConstantBegin);
11
10
  if (begin === undefined) {
12
11
  throw "ConstantsTranspilerBegin";
13
12
  }
14
- const name = (_a = begin.findDirectExpression(abaplint.Expressions.DefinitionName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
13
+ const name = begin.findDirectExpression(abaplint.Expressions.DefinitionName)?.getFirstToken().getStr();
15
14
  if (name === undefined) {
16
15
  throw "ConstantsTranspilerName";
17
16
  }
18
17
  let ret = new statements_1.DataTranspiler().transpile(begin, traversal).getCode() + "\n";
19
18
  // todo: CONSTANTS BEGIN inside CONSTANTS BEGIN
20
19
  for (const c of node.findDirectStatements(abaplint.Statements.Constant)) {
21
- const field = (_b = c.findDirectExpression(abaplint.Expressions.DefinitionName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
20
+ const field = c.findDirectExpression(abaplint.Expressions.DefinitionName)?.getFirstToken().getStr();
22
21
  if (field === undefined) {
23
22
  continue;
24
23
  }
@@ -6,15 +6,14 @@ const statements_1 = require("../statements");
6
6
  const chunk_1 = require("../chunk");
7
7
  class DataTranspiler {
8
8
  transpile(node, traversal) {
9
- var _a, _b;
10
9
  const begin = node.findDirectStatement(abaplint.Statements.DataBegin);
11
10
  if (begin === undefined) {
12
11
  return new chunk_1.Chunk("");
13
12
  }
14
- const topName = (_a = begin.findDirectExpression(abaplint.Expressions.DefinitionName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toLowerCase();
13
+ const topName = begin.findDirectExpression(abaplint.Expressions.DefinitionName)?.concatTokens().toLowerCase();
15
14
  const chunk = new statements_1.DataTranspiler().transpile(begin, traversal);
16
15
  for (const d of node.findDirectStatements(abaplint.Statements.Data)) {
17
- const subName = (_b = d.findFirstExpression(abaplint.Expressions.DefinitionName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toLowerCase();
16
+ const subName = d.findFirstExpression(abaplint.Expressions.DefinitionName)?.concatTokens().toLowerCase();
18
17
  if (subName && topName) {
19
18
  chunk.appendString(statements_1.DataTranspiler.buildValue(d, topName + ".get()." + subName, traversal));
20
19
  }
@@ -8,12 +8,11 @@ const transpile_types_1 = require("../transpile_types");
8
8
  const unique_identifier_1 = require("../unique_identifier");
9
9
  class FunctionModuleTranspiler {
10
10
  transpile(node, traversal) {
11
- var _a;
12
11
  let r = "";
13
12
  let name = "";
14
13
  for (const c of node.getChildren()) {
15
14
  if (c.get() instanceof abaplint.Statements.FunctionModule && c instanceof abaplint.Nodes.StatementNode) {
16
- name = (_a = c.findDirectExpression(abaplint.Expressions.Field)) === null || _a === void 0 ? void 0 : _a.concatTokens().toLowerCase();
15
+ name = c.findDirectExpression(abaplint.Expressions.Field)?.concatTokens().toLowerCase();
17
16
  if (name === undefined) {
18
17
  name = "FunctionModuleTranspilerNameNotFound";
19
18
  }
@@ -33,7 +32,6 @@ class FunctionModuleTranspiler {
33
32
  }
34
33
  //////////////////////
35
34
  findSignature(traversal, name, node) {
36
- var _a, _b, _c;
37
35
  const group = traversal.getCurrentObject();
38
36
  if (group === undefined) {
39
37
  throw "FunctionModuleTranspilerGroupNotFound";
@@ -55,11 +53,11 @@ class FunctionModuleTranspiler {
55
53
  }
56
54
  // note: all directions are optional
57
55
  let name = p.name.toLowerCase();
58
- if ((_b = (_a = traversal.options) === null || _a === void 0 ? void 0 : _a.keywords) === null || _b === void 0 ? void 0 : _b.some(a => a === name)) {
56
+ if (traversal.options?.keywords?.some(a => a === name)) {
59
57
  name += "_";
60
58
  }
61
59
  ret += `let ${name} = INPUT.${direction}?.${name};\n`;
62
- const type = (_c = scope === null || scope === void 0 ? void 0 : scope.findVariable(name)) === null || _c === void 0 ? void 0 : _c.getType();
60
+ const type = scope?.findVariable(name)?.getType();
63
61
  if (type !== undefined && p.optional === true) {
64
62
  // todo, set DEFAULT value
65
63
  ret += `if (${name} === undefined) {
@@ -8,14 +8,13 @@ const expressions_1 = require("../expressions");
8
8
  const chunk_1 = require("../chunk");
9
9
  class InterfaceTranspiler {
10
10
  transpile(node, traversal) {
11
- var _a;
12
11
  let ret = "";
13
12
  let name;
14
13
  const def = traversal.getInterfaceDefinition(node.getFirstToken());
15
14
  for (const c of node.getChildren()) {
16
15
  if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.Interface) {
17
16
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
18
- name = (_a = c.findDirectExpression(abaplint.Expressions.InterfaceName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toLowerCase();
17
+ name = c.findDirectExpression(abaplint.Expressions.InterfaceName)?.getFirstToken().getStr().toLowerCase();
19
18
  name = traversal_1.Traversal.escapeNamespace(name);
20
19
  ret += `class ${name} {\n`;
21
20
  ret += `static INTERNAL_TYPE = 'INTF';\n`;
@@ -47,7 +46,7 @@ class InterfaceTranspiler {
47
46
  return "";
48
47
  }
49
48
  const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
50
- const vars = scope === null || scope === void 0 ? void 0 : scope.getData().vars;
49
+ const vars = scope?.getData().vars;
51
50
  if (vars === undefined || Object.keys(vars).length === 0) {
52
51
  return "";
53
52
  }
@@ -61,14 +60,14 @@ class InterfaceTranspiler {
61
60
  const interfaceName = traversal_1.Traversal.escapeNamespace(node.getFirstToken().getStr().toLowerCase());
62
61
  const name = interfaceName + "." + interfaceName + "$" + n.toLowerCase();
63
62
  ret += name + " = " + new transpile_types_1.TranspileTypes().toType(identifier.getType()) + ";\n";
64
- const alias = idef === null || idef === void 0 ? void 0 : idef.getAliases().getAll().find(a => a.getName().toUpperCase() === n.toUpperCase());
63
+ const alias = idef?.getAliases().getAll().find(a => a.getName().toUpperCase() === n.toUpperCase());
65
64
  if (alias) {
66
65
  // todo: this is an evil workaround, should be fixed in abaplint instead
67
66
  ret += interfaceName + "." + alias.getComponent().split("~")[0].toLowerCase() + "$" + n.toLowerCase() + " = " + name + ";\n";
68
67
  }
69
68
  const constantStatement = traversal.findStatementInFile(identifier.getStart());
70
- const valExpression = constantStatement === null || constantStatement === void 0 ? void 0 : constantStatement.findFirstExpression(abaplint.Expressions.Value);
71
- if ((valExpression === null || valExpression === void 0 ? void 0 : valExpression.getChildren()[1].get()) instanceof abaplint.Expressions.SimpleFieldChain) {
69
+ const valExpression = constantStatement?.findFirstExpression(abaplint.Expressions.Value);
70
+ if (valExpression?.getChildren()[1].get() instanceof abaplint.Expressions.SimpleFieldChain) {
72
71
  const s = new expressions_1.FieldChainTranspiler().transpile(valExpression.getChildren()[1], traversal, false).getCode();
73
72
  const e = expressions_1.ConstantTranspiler.escape(s);
74
73
  ret += name + ".set(" + e + ");\n";
@@ -10,7 +10,6 @@ const statements_1 = require("../statements");
10
10
  const at_1 = require("./at");
11
11
  class LoopTranspiler {
12
12
  transpile(node, traversal) {
13
- var _a;
14
13
  const ret = new chunk_1.Chunk();
15
14
  let pre = "";
16
15
  let atFirst = undefined;
@@ -20,7 +19,7 @@ class LoopTranspiler {
20
19
  let tabix = "";
21
20
  let loopTarget = "";
22
21
  let hasAt = false;
23
- for (const n of ((_a = node.findDirectStructure(abaplint.Structures.Body)) === null || _a === void 0 ? void 0 : _a.findDirectStructures(abaplint.Structures.Normal)) || []) {
22
+ for (const n of node.findDirectStructure(abaplint.Structures.Body)?.findDirectStructures(abaplint.Structures.Normal) || []) {
24
23
  if (n.findDirectStructure(abaplint.Structures.At) !== undefined) {
25
24
  hasAt = true;
26
25
  break;
@@ -9,14 +9,13 @@ const unique_identifier_1 = require("../unique_identifier");
9
9
  const expressions_1 = require("../expressions");
10
10
  class SelectTranspiler {
11
11
  transpile(node, traversal) {
12
- var _a, _b;
13
12
  const ret = new chunk_1.Chunk();
14
13
  const selectStatement = node.findFirstStatement(abaplint.Statements.SelectLoop);
15
14
  if (selectStatement === undefined) {
16
15
  throw "Structure, select loop not found";
17
16
  }
18
17
  const concat = selectStatement.concatTokens().toUpperCase();
19
- const from = (_a = selectStatement.findFirstExpression(abaplint.Expressions.SQLFromSource)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
18
+ const from = selectStatement.findFirstExpression(abaplint.Expressions.SQLFromSource)?.concatTokens().toUpperCase();
20
19
  const intoName = new expressions_1.SQLTargetTranspiler().transpile(selectStatement.findFirstExpression(abaplint.Expressions.SQLTarget), traversal).getCode();
21
20
  // note: this implementation SELECTs everything into memory, which might be bad, and sometimes not correct
22
21
  const targetName = unique_identifier_1.UniqueIdentifier.get();
@@ -24,7 +23,7 @@ class SelectTranspiler {
24
23
  ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${from}"].type);\n`);
25
24
  ret.appendChunk(new select_1.SelectTranspiler().transpile(selectStatement, traversal, targetName));
26
25
  // todo: optimize, it should do real streaming?
27
- const packageSize = (_b = node.findFirstExpression(abaplint.Expressions.SelectLoop)) === null || _b === void 0 ? void 0 : _b.findExpressionAfterToken("SIZE");
26
+ const packageSize = node.findFirstExpression(abaplint.Expressions.SelectLoop)?.findExpressionAfterToken("SIZE");
28
27
  if (packageSize) {
29
28
  const getSize = new expressions_1.SQLSourceTranspiler().transpile(packageSize, traversal).getCode() + ".get()";
30
29
  ret.appendString(`if (${targetName}.array().length > ${getSize}) {
@@ -48,7 +48,7 @@ class TryTranspiler {
48
48
  const catchNames = catchStatement.findDirectExpressions(abaplint.Expressions.ClassName).map(e => traversal.lookupClassOrInterface(e.concatTokens(), e.getFirstToken()));
49
49
  ret += first ? "" : " else ";
50
50
  first = false;
51
- ret += "if (" + (catchNames === null || catchNames === void 0 ? void 0 : catchNames.map(n => "(" + n + " && e instanceof " + n + ")").join(" || ")) + ") {\n";
51
+ ret += "if (" + catchNames?.map(n => "(" + n + " && e instanceof " + n + ")").join(" || ") + ") {\n";
52
52
  const intoNode = catchStatement.findExpressionAfterToken("INTO");
53
53
  if (intoNode) {
54
54
  ret += traversal.traverse(intoNode).getCode() + ".set(e);\n";
@@ -18,14 +18,13 @@ class TranspileTypes {
18
18
  return pre + t.getName().toLowerCase() + " = " + code + ";\n";
19
19
  }
20
20
  toType(type) {
21
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
22
21
  let resolved = "";
23
22
  let extra = "";
24
23
  if (type instanceof abaplint.BasicTypes.ObjectReferenceType
25
24
  || type instanceof abaplint.BasicTypes.GenericObjectReferenceType) {
26
25
  resolved = "ABAPObject";
27
- extra = "{qualifiedName: " + JSON.stringify((_a = type.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()) +
28
- ", RTTIName: " + JSON.stringify((_b = type.getRTTIName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()) + "}";
26
+ extra = "{qualifiedName: " + JSON.stringify(type.getQualifiedName()?.toUpperCase()) +
27
+ ", RTTIName: " + JSON.stringify(type.getRTTIName()?.toUpperCase()) + "}";
29
28
  }
30
29
  else if (type instanceof abaplint.BasicTypes.TableType) {
31
30
  resolved = "Table";
@@ -39,37 +38,37 @@ class TranspileTypes {
39
38
  else if (type instanceof abaplint.BasicTypes.IntegerType) {
40
39
  resolved = "Integer";
41
40
  if (type.getQualifiedName() !== undefined) {
42
- extra = "{qualifiedName: \"" + ((_c = type.getQualifiedName()) === null || _c === void 0 ? void 0 : _c.toUpperCase()) + "\"}";
41
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
43
42
  }
44
43
  }
45
44
  else if (type instanceof abaplint.BasicTypes.Integer8Type) {
46
45
  resolved = "Integer8";
47
46
  if (type.getQualifiedName() !== undefined) {
48
- extra = "{qualifiedName: \"" + ((_d = type.getQualifiedName()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) + "\"}";
47
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
49
48
  }
50
49
  }
51
50
  else if (type instanceof abaplint.BasicTypes.StringType) {
52
51
  resolved = "String";
53
52
  if (type.getQualifiedName() !== undefined) {
54
- extra = "{qualifiedName: \"" + ((_e = type.getQualifiedName()) === null || _e === void 0 ? void 0 : _e.toUpperCase()) + "\"}";
53
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
55
54
  }
56
55
  }
57
56
  else if (type instanceof abaplint.BasicTypes.UTCLongType) {
58
57
  resolved = "UTCLong";
59
58
  if (type.getQualifiedName() !== undefined) {
60
- extra = "{qualifiedName: \"" + ((_f = type.getQualifiedName()) === null || _f === void 0 ? void 0 : _f.toUpperCase()) + "\"}";
59
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
61
60
  }
62
61
  }
63
62
  else if (type instanceof abaplint.BasicTypes.DateType) {
64
63
  resolved = "Date";
65
64
  if (type.getQualifiedName() !== undefined) {
66
- extra = "{qualifiedName: \"" + ((_g = type.getQualifiedName()) === null || _g === void 0 ? void 0 : _g.toUpperCase()) + "\"}";
65
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
67
66
  }
68
67
  }
69
68
  else if (type instanceof abaplint.BasicTypes.TimeType) {
70
69
  resolved = "Time";
71
70
  if (type.getQualifiedName() !== undefined) {
72
- extra = "{qualifiedName: \"" + ((_h = type.getQualifiedName()) === null || _h === void 0 ? void 0 : _h.toUpperCase()) + "\"}";
71
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
73
72
  }
74
73
  }
75
74
  else if (type instanceof abaplint.BasicTypes.DataReference) {
@@ -154,7 +153,7 @@ class TranspileTypes {
154
153
  else if (type instanceof abaplint.BasicTypes.XStringType) {
155
154
  resolved = "XString";
156
155
  if (type.getQualifiedName() !== undefined) {
157
- extra = "{qualifiedName: \"" + ((_j = type.getQualifiedName()) === null || _j === void 0 ? void 0 : _j.toUpperCase()) + "\"}";
156
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
158
157
  }
159
158
  }
160
159
  else if (type instanceof abaplint.BasicTypes.XSequenceType
@@ -171,13 +170,13 @@ class TranspileTypes {
171
170
  else if (type instanceof abaplint.BasicTypes.FloatType) {
172
171
  resolved = "Float";
173
172
  if (type.getQualifiedName() !== undefined) {
174
- extra = "{qualifiedName: \"" + ((_k = type.getQualifiedName()) === null || _k === void 0 ? void 0 : _k.toUpperCase()) + "\"}";
173
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
175
174
  }
176
175
  }
177
176
  else if (type instanceof abaplint.BasicTypes.FloatingPointType) {
178
177
  resolved = "Float";
179
178
  if (type.getQualifiedName() !== undefined) {
180
- extra = "{qualifiedName: \"" + ((_l = type.getQualifiedName()) === null || _l === void 0 ? void 0 : _l.toUpperCase()) + "\"}";
179
+ extra = "{qualifiedName: \"" + type.getQualifiedName()?.toUpperCase() + "\"}";
181
180
  }
182
181
  }
183
182
  else if (type instanceof abaplint.BasicTypes.DecFloat34Type) {