@abaplint/transpiler 2.5.38 → 2.5.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.
Files changed (477) hide show
  1. package/build/src/chunk.d.ts +19 -19
  2. package/build/src/chunk.js +146 -146
  3. package/build/src/db/database_setup_result.d.ts +8 -8
  4. package/build/src/db/database_setup_result.js +2 -2
  5. package/build/src/db/index.d.ts +13 -13
  6. package/build/src/db/index.js +86 -86
  7. package/build/src/db/sqlite_database_schema.d.ts +9 -9
  8. package/build/src/db/sqlite_database_schema.js +120 -120
  9. package/build/src/expressions/_expression_transpiler.d.ts +6 -6
  10. package/build/src/expressions/_expression_transpiler.js +2 -2
  11. package/build/src/expressions/arith_operator.d.ts +7 -7
  12. package/build/src/expressions/arith_operator.js +37 -37
  13. package/build/src/expressions/attribute_chain.d.ts +7 -7
  14. package/build/src/expressions/attribute_chain.js +20 -20
  15. package/build/src/expressions/attribute_name.d.ts +7 -7
  16. package/build/src/expressions/attribute_name.js +10 -10
  17. package/build/src/expressions/call_transformation_options.d.ts +7 -7
  18. package/build/src/expressions/call_transformation_options.js +27 -27
  19. package/build/src/expressions/call_transformation_parameters.d.ts +7 -7
  20. package/build/src/expressions/call_transformation_parameters.js +36 -36
  21. package/build/src/expressions/compare.d.ts +7 -7
  22. package/build/src/expressions/compare.js +88 -88
  23. package/build/src/expressions/compare_operator.d.ts +7 -7
  24. package/build/src/expressions/compare_operator.js +54 -54
  25. package/build/src/expressions/component_chain.d.ts +7 -7
  26. package/build/src/expressions/component_chain.js +20 -20
  27. package/build/src/expressions/component_chain_simple.d.ts +7 -7
  28. package/build/src/expressions/component_chain_simple.js +28 -28
  29. package/build/src/expressions/component_compare.d.ts +7 -7
  30. package/build/src/expressions/component_compare.js +49 -49
  31. package/build/src/expressions/component_cond.d.ts +7 -7
  32. package/build/src/expressions/component_cond.js +33 -33
  33. package/build/src/expressions/component_cond_sub.d.ts +7 -7
  34. package/build/src/expressions/component_cond_sub.js +36 -36
  35. package/build/src/expressions/cond.d.ts +7 -7
  36. package/build/src/expressions/cond.js +26 -26
  37. package/build/src/expressions/cond_sub.d.ts +7 -7
  38. package/build/src/expressions/cond_sub.js +26 -26
  39. package/build/src/expressions/constant.d.ts +10 -10
  40. package/build/src/expressions/constant.js +86 -86
  41. package/build/src/expressions/database_table.d.ts +7 -7
  42. package/build/src/expressions/database_table.js +20 -20
  43. package/build/src/expressions/field_chain.d.ts +10 -10
  44. package/build/src/expressions/field_chain.js +92 -92
  45. package/build/src/expressions/field_length.d.ts +7 -7
  46. package/build/src/expressions/field_length.js +25 -25
  47. package/build/src/expressions/field_offset.d.ts +7 -7
  48. package/build/src/expressions/field_offset.js +25 -25
  49. package/build/src/expressions/field_symbol.d.ts +7 -7
  50. package/build/src/expressions/field_symbol.js +13 -13
  51. package/build/src/expressions/function_exporting.d.ts +7 -7
  52. package/build/src/expressions/function_exporting.js +28 -28
  53. package/build/src/expressions/function_parameters.d.ts +7 -7
  54. package/build/src/expressions/function_parameters.js +36 -36
  55. package/build/src/expressions/index.d.ts +50 -50
  56. package/build/src/expressions/index.js +66 -66
  57. package/build/src/expressions/message_number.d.ts +7 -7
  58. package/build/src/expressions/message_number.js +10 -10
  59. package/build/src/expressions/method_call.d.ts +7 -7
  60. package/build/src/expressions/method_call.js +37 -37
  61. package/build/src/expressions/method_call_body.d.ts +10 -10
  62. package/build/src/expressions/method_call_body.js +29 -29
  63. package/build/src/expressions/method_call_chain.d.ts +7 -7
  64. package/build/src/expressions/method_call_chain.js +66 -66
  65. package/build/src/expressions/method_call_param.d.ts +10 -10
  66. package/build/src/expressions/method_call_param.js +49 -49
  67. package/build/src/expressions/method_parameters.d.ts +7 -7
  68. package/build/src/expressions/method_parameters.js +34 -34
  69. package/build/src/expressions/method_source.d.ts +9 -9
  70. package/build/src/expressions/method_source.js +111 -111
  71. package/build/src/expressions/parameter_list_s.d.ts +7 -7
  72. package/build/src/expressions/parameter_list_s.js +17 -17
  73. package/build/src/expressions/parameter_list_t.d.ts +7 -7
  74. package/build/src/expressions/parameter_list_t.js +17 -17
  75. package/build/src/expressions/parameter_name.d.ts +7 -7
  76. package/build/src/expressions/parameter_name.js +12 -12
  77. package/build/src/expressions/parameter_s.d.ts +7 -7
  78. package/build/src/expressions/parameter_s.js +15 -15
  79. package/build/src/expressions/parameter_t.d.ts +7 -7
  80. package/build/src/expressions/parameter_t.js +15 -15
  81. package/build/src/expressions/simple_source1.d.ts +7 -7
  82. package/build/src/expressions/simple_source1.js +10 -10
  83. package/build/src/expressions/simple_source2.d.ts +7 -7
  84. package/build/src/expressions/simple_source2.js +10 -10
  85. package/build/src/expressions/simple_source3.d.ts +9 -9
  86. package/build/src/expressions/simple_source3.js +13 -13
  87. package/build/src/expressions/simple_source4.d.ts +7 -7
  88. package/build/src/expressions/simple_source4.js +10 -10
  89. package/build/src/expressions/source.d.ts +9 -9
  90. package/build/src/expressions/source.js +96 -96
  91. package/build/src/expressions/source_field.d.ts +7 -7
  92. package/build/src/expressions/source_field.js +14 -14
  93. package/build/src/expressions/source_field_symbol.d.ts +7 -7
  94. package/build/src/expressions/source_field_symbol.js +10 -10
  95. package/build/src/expressions/sql_cond.d.ts +11 -11
  96. package/build/src/expressions/sql_cond.js +128 -128
  97. package/build/src/expressions/sql_from.d.ts +7 -7
  98. package/build/src/expressions/sql_from.js +25 -25
  99. package/build/src/expressions/sql_join.d.ts +7 -7
  100. package/build/src/expressions/sql_join.js +24 -24
  101. package/build/src/expressions/sql_source.d.ts +7 -7
  102. package/build/src/expressions/sql_source.js +14 -14
  103. package/build/src/expressions/sql_source_simple.d.ts +7 -7
  104. package/build/src/expressions/sql_source_simple.js +14 -14
  105. package/build/src/expressions/sql_target.d.ts +7 -7
  106. package/build/src/expressions/sql_target.js +11 -11
  107. package/build/src/expressions/string_template.d.ts +7 -7
  108. package/build/src/expressions/string_template.js +39 -39
  109. package/build/src/expressions/string_template_source.d.ts +8 -8
  110. package/build/src/expressions/string_template_source.js +52 -52
  111. package/build/src/expressions/target.d.ts +7 -7
  112. package/build/src/expressions/target.js +83 -83
  113. package/build/src/handlers/handle_abap.d.ts +12 -12
  114. package/build/src/handlers/handle_abap.js +144 -144
  115. package/build/src/handlers/handle_data_element.d.ts +5 -5
  116. package/build/src/handlers/handle_data_element.js +35 -35
  117. package/build/src/handlers/handle_enqu.d.ts +5 -5
  118. package/build/src/handlers/handle_enqu.js +27 -27
  119. package/build/src/handlers/handle_smim.d.ts +5 -5
  120. package/build/src/handlers/handle_smim.js +42 -42
  121. package/build/src/handlers/handle_table.d.ts +5 -5
  122. package/build/src/handlers/handle_table.js +29 -29
  123. package/build/src/handlers/handle_table_type.d.ts +5 -5
  124. package/build/src/handlers/handle_table_type.js +28 -28
  125. package/build/src/handlers/handle_type_pool.d.ts +5 -5
  126. package/build/src/handlers/handle_type_pool.js +38 -38
  127. package/build/src/handlers/handle_view.d.ts +5 -5
  128. package/build/src/handlers/handle_view.js +30 -30
  129. package/build/src/handlers/handle_w3mi.d.ts +5 -5
  130. package/build/src/handlers/handle_w3mi.js +42 -42
  131. package/build/src/index.d.ts +11 -11
  132. package/build/src/index.js +95 -103
  133. package/build/src/keywords.d.ts +9 -9
  134. package/build/src/keywords.js +91 -91
  135. package/build/src/rearranger.d.ts +7 -7
  136. package/build/src/rearranger.js +109 -109
  137. package/build/src/requires.d.ts +7 -7
  138. package/build/src/requires.js +111 -111
  139. package/build/src/statements/_statement_transpiler.d.ts +6 -6
  140. package/build/src/statements/_statement_transpiler.js +2 -2
  141. package/build/src/statements/add.d.ts +7 -7
  142. package/build/src/statements/add.js +20 -20
  143. package/build/src/statements/append.d.ts +7 -7
  144. package/build/src/statements/append.js +70 -70
  145. package/build/src/statements/assert.d.ts +7 -7
  146. package/build/src/statements/assert.js +15 -15
  147. package/build/src/statements/assign.d.ts +7 -7
  148. package/build/src/statements/assign.js +82 -82
  149. package/build/src/statements/at.d.ts +7 -7
  150. package/build/src/statements/at.js +10 -10
  151. package/build/src/statements/authority_check.d.ts +7 -7
  152. package/build/src/statements/authority_check.js +14 -14
  153. package/build/src/statements/break.d.ts +7 -7
  154. package/build/src/statements/break.js +10 -10
  155. package/build/src/statements/break_id.d.ts +7 -7
  156. package/build/src/statements/break_id.js +11 -11
  157. package/build/src/statements/call.d.ts +7 -7
  158. package/build/src/statements/call.js +82 -82
  159. package/build/src/statements/call_function.d.ts +7 -7
  160. package/build/src/statements/call_function.js +40 -40
  161. package/build/src/statements/call_kernel.d.ts +7 -7
  162. package/build/src/statements/call_kernel.js +21 -21
  163. package/build/src/statements/call_screen.d.ts +7 -7
  164. package/build/src/statements/call_screen.js +10 -10
  165. package/build/src/statements/call_transaction.d.ts +7 -7
  166. package/build/src/statements/call_transaction.js +10 -10
  167. package/build/src/statements/call_transformation.d.ts +7 -7
  168. package/build/src/statements/call_transformation.js +37 -37
  169. package/build/src/statements/case.d.ts +7 -7
  170. package/build/src/statements/case.js +16 -16
  171. package/build/src/statements/check.d.ts +7 -7
  172. package/build/src/statements/check.js +24 -24
  173. package/build/src/statements/class_deferred.d.ts +7 -7
  174. package/build/src/statements/class_deferred.js +10 -10
  175. package/build/src/statements/class_definition_load.d.ts +7 -7
  176. package/build/src/statements/class_definition_load.js +11 -11
  177. package/build/src/statements/class_implementation.d.ts +9 -9
  178. package/build/src/statements/class_implementation.js +53 -53
  179. package/build/src/statements/class_local_friends.d.ts +7 -7
  180. package/build/src/statements/class_local_friends.js +10 -10
  181. package/build/src/statements/clear.d.ts +7 -7
  182. package/build/src/statements/clear.js +16 -16
  183. package/build/src/statements/close_dataset.d.ts +7 -7
  184. package/build/src/statements/close_dataset.js +10 -10
  185. package/build/src/statements/collect.d.ts +7 -7
  186. package/build/src/statements/collect.js +22 -22
  187. package/build/src/statements/commit.d.ts +7 -7
  188. package/build/src/statements/commit.js +10 -10
  189. package/build/src/statements/concatenate.d.ts +7 -7
  190. package/build/src/statements/concatenate.js +33 -33
  191. package/build/src/statements/condense.d.ts +7 -7
  192. package/build/src/statements/condense.js +17 -17
  193. package/build/src/statements/constant.d.ts +7 -7
  194. package/build/src/statements/constant.js +10 -10
  195. package/build/src/statements/continue.d.ts +7 -7
  196. package/build/src/statements/continue.js +10 -10
  197. package/build/src/statements/convert.d.ts +7 -7
  198. package/build/src/statements/convert.js +42 -42
  199. package/build/src/statements/create_data.d.ts +7 -7
  200. package/build/src/statements/create_data.js +70 -70
  201. package/build/src/statements/create_object.d.ts +8 -8
  202. package/build/src/statements/create_object.js +74 -74
  203. package/build/src/statements/data.d.ts +8 -8
  204. package/build/src/statements/data.js +53 -53
  205. package/build/src/statements/delete_database.d.ts +7 -7
  206. package/build/src/statements/delete_database.js +23 -23
  207. package/build/src/statements/delete_dataset.d.ts +7 -7
  208. package/build/src/statements/delete_dataset.js +10 -10
  209. package/build/src/statements/delete_internal.d.ts +7 -7
  210. package/build/src/statements/delete_internal.js +52 -52
  211. package/build/src/statements/delete_textpool.d.ts +7 -7
  212. package/build/src/statements/delete_textpool.js +10 -10
  213. package/build/src/statements/describe.d.ts +7 -7
  214. package/build/src/statements/describe.js +45 -45
  215. package/build/src/statements/do.d.ts +9 -9
  216. package/build/src/statements/do.js +26 -26
  217. package/build/src/statements/editor_call.d.ts +7 -7
  218. package/build/src/statements/editor_call.js +10 -10
  219. package/build/src/statements/else.d.ts +7 -7
  220. package/build/src/statements/else.js +10 -10
  221. package/build/src/statements/else_if.d.ts +7 -7
  222. package/build/src/statements/else_if.js +15 -15
  223. package/build/src/statements/end_at.d.ts +7 -7
  224. package/build/src/statements/end_at.js +10 -10
  225. package/build/src/statements/end_case.d.ts +7 -7
  226. package/build/src/statements/end_case.js +10 -10
  227. package/build/src/statements/end_class.d.ts +7 -7
  228. package/build/src/statements/end_class.js +13 -13
  229. package/build/src/statements/end_do.d.ts +9 -9
  230. package/build/src/statements/end_do.js +13 -13
  231. package/build/src/statements/end_enhancement_section.d.ts +7 -7
  232. package/build/src/statements/end_enhancement_section.js +11 -11
  233. package/build/src/statements/end_form.d.ts +7 -7
  234. package/build/src/statements/end_form.js +10 -10
  235. package/build/src/statements/end_if.d.ts +7 -7
  236. package/build/src/statements/end_if.js +10 -10
  237. package/build/src/statements/end_loop.d.ts +7 -7
  238. package/build/src/statements/end_loop.js +10 -10
  239. package/build/src/statements/end_method.d.ts +8 -8
  240. package/build/src/statements/end_method.js +57 -57
  241. package/build/src/statements/end_try.d.ts +7 -7
  242. package/build/src/statements/end_try.js +10 -10
  243. package/build/src/statements/end_while.d.ts +9 -9
  244. package/build/src/statements/end_while.js +13 -13
  245. package/build/src/statements/enhancement_section.d.ts +7 -7
  246. package/build/src/statements/enhancement_section.js +11 -11
  247. package/build/src/statements/exit.d.ts +7 -7
  248. package/build/src/statements/exit.js +16 -16
  249. package/build/src/statements/export.d.ts +7 -7
  250. package/build/src/statements/export.js +10 -10
  251. package/build/src/statements/field_symbol.d.ts +7 -7
  252. package/build/src/statements/field_symbol.js +32 -32
  253. package/build/src/statements/find.d.ts +7 -7
  254. package/build/src/statements/find.js +74 -74
  255. package/build/src/statements/form.d.ts +6 -6
  256. package/build/src/statements/form.js +14 -14
  257. package/build/src/statements/free.d.ts +7 -7
  258. package/build/src/statements/free.js +10 -10
  259. package/build/src/statements/free_memory.d.ts +7 -7
  260. package/build/src/statements/free_memory.js +10 -10
  261. package/build/src/statements/function_pool.d.ts +7 -7
  262. package/build/src/statements/function_pool.js +10 -10
  263. package/build/src/statements/get_bit.d.ts +7 -7
  264. package/build/src/statements/get_bit.js +18 -18
  265. package/build/src/statements/get_dataset.d.ts +7 -7
  266. package/build/src/statements/get_dataset.js +10 -10
  267. package/build/src/statements/get_locale.d.ts +7 -7
  268. package/build/src/statements/get_locale.js +12 -12
  269. package/build/src/statements/get_parameter.d.ts +7 -7
  270. package/build/src/statements/get_parameter.js +17 -17
  271. package/build/src/statements/get_reference.d.ts +7 -7
  272. package/build/src/statements/get_reference.js +29 -29
  273. package/build/src/statements/get_run_time.d.ts +7 -7
  274. package/build/src/statements/get_run_time.js +16 -16
  275. package/build/src/statements/get_time.d.ts +7 -7
  276. package/build/src/statements/get_time.js +22 -22
  277. package/build/src/statements/if.d.ts +7 -7
  278. package/build/src/statements/if.js +16 -16
  279. package/build/src/statements/import.d.ts +7 -7
  280. package/build/src/statements/import.js +10 -10
  281. package/build/src/statements/include.d.ts +7 -7
  282. package/build/src/statements/include.js +11 -11
  283. package/build/src/statements/index.d.ts +141 -141
  284. package/build/src/statements/index.js +157 -157
  285. package/build/src/statements/initialization.d.ts +7 -7
  286. package/build/src/statements/initialization.js +10 -10
  287. package/build/src/statements/insert_database.d.ts +7 -7
  288. package/build/src/statements/insert_database.js +28 -28
  289. package/build/src/statements/insert_internal.d.ts +7 -7
  290. package/build/src/statements/insert_internal.js +41 -41
  291. package/build/src/statements/insert_report.d.ts +7 -7
  292. package/build/src/statements/insert_report.js +10 -10
  293. package/build/src/statements/insert_textpool.d.ts +7 -7
  294. package/build/src/statements/insert_textpool.js +10 -10
  295. package/build/src/statements/leave.d.ts +7 -7
  296. package/build/src/statements/leave.js +10 -10
  297. package/build/src/statements/log_point.d.ts +7 -7
  298. package/build/src/statements/log_point.js +11 -11
  299. package/build/src/statements/loop.d.ts +15 -15
  300. package/build/src/statements/loop.js +115 -115
  301. package/build/src/statements/loop_at_screen.d.ts +7 -7
  302. package/build/src/statements/loop_at_screen.js +10 -10
  303. package/build/src/statements/macro_call.d.ts +7 -7
  304. package/build/src/statements/macro_call.js +10 -10
  305. package/build/src/statements/message.d.ts +7 -7
  306. package/build/src/statements/message.js +80 -80
  307. package/build/src/statements/method_implementation.d.ts +9 -9
  308. package/build/src/statements/method_implementation.js +182 -182
  309. package/build/src/statements/modify_database.d.ts +7 -7
  310. package/build/src/statements/modify_database.js +23 -23
  311. package/build/src/statements/modify_internal.d.ts +7 -7
  312. package/build/src/statements/modify_internal.js +31 -31
  313. package/build/src/statements/modify_screen.d.ts +7 -7
  314. package/build/src/statements/modify_screen.js +10 -10
  315. package/build/src/statements/move.d.ts +7 -7
  316. package/build/src/statements/move.js +35 -35
  317. package/build/src/statements/move_corresponding.d.ts +7 -7
  318. package/build/src/statements/move_corresponding.js +15 -15
  319. package/build/src/statements/open_dataset.d.ts +7 -7
  320. package/build/src/statements/open_dataset.js +10 -10
  321. package/build/src/statements/overlay.d.ts +7 -7
  322. package/build/src/statements/overlay.js +18 -18
  323. package/build/src/statements/parameter.d.ts +7 -7
  324. package/build/src/statements/parameter.js +10 -10
  325. package/build/src/statements/perform.d.ts +7 -7
  326. package/build/src/statements/perform.js +19 -19
  327. package/build/src/statements/raise.d.ts +7 -7
  328. package/build/src/statements/raise.js +30 -30
  329. package/build/src/statements/raise_event.d.ts +7 -7
  330. package/build/src/statements/raise_event.js +11 -11
  331. package/build/src/statements/read_dataset.d.ts +7 -7
  332. package/build/src/statements/read_dataset.js +10 -10
  333. package/build/src/statements/read_line.d.ts +7 -7
  334. package/build/src/statements/read_line.js +10 -10
  335. package/build/src/statements/read_report.d.ts +7 -7
  336. package/build/src/statements/read_report.js +25 -25
  337. package/build/src/statements/read_table.d.ts +7 -7
  338. package/build/src/statements/read_table.js +90 -90
  339. package/build/src/statements/read_textpool.d.ts +7 -7
  340. package/build/src/statements/read_textpool.js +10 -10
  341. package/build/src/statements/receive.d.ts +7 -7
  342. package/build/src/statements/receive.js +10 -10
  343. package/build/src/statements/refresh.d.ts +7 -7
  344. package/build/src/statements/refresh.js +16 -16
  345. package/build/src/statements/replace.d.ts +7 -7
  346. package/build/src/statements/replace.js +47 -47
  347. package/build/src/statements/report.d.ts +7 -7
  348. package/build/src/statements/report.js +10 -10
  349. package/build/src/statements/retry.d.ts +7 -7
  350. package/build/src/statements/retry.js +10 -10
  351. package/build/src/statements/return.d.ts +7 -7
  352. package/build/src/statements/return.js +29 -29
  353. package/build/src/statements/rollback.d.ts +7 -7
  354. package/build/src/statements/rollback.js +10 -10
  355. package/build/src/statements/scan.d.ts +7 -7
  356. package/build/src/statements/scan.js +31 -31
  357. package/build/src/statements/search.d.ts +7 -7
  358. package/build/src/statements/search.js +10 -10
  359. package/build/src/statements/select.d.ts +9 -9
  360. package/build/src/statements/select.js +122 -122
  361. package/build/src/statements/select_option.d.ts +7 -7
  362. package/build/src/statements/select_option.js +10 -10
  363. package/build/src/statements/selection_screen.d.ts +7 -7
  364. package/build/src/statements/selection_screen.js +10 -10
  365. package/build/src/statements/set_bit.d.ts +7 -7
  366. package/build/src/statements/set_bit.js +20 -20
  367. package/build/src/statements/set_dataset.d.ts +7 -7
  368. package/build/src/statements/set_dataset.js +10 -10
  369. package/build/src/statements/set_handler.d.ts +7 -7
  370. package/build/src/statements/set_handler.js +26 -26
  371. package/build/src/statements/set_language.d.ts +7 -7
  372. package/build/src/statements/set_language.js +10 -10
  373. package/build/src/statements/set_locale.d.ts +7 -7
  374. package/build/src/statements/set_locale.js +12 -12
  375. package/build/src/statements/set_parameter.d.ts +7 -7
  376. package/build/src/statements/set_parameter.js +10 -10
  377. package/build/src/statements/set_pf_status.d.ts +7 -7
  378. package/build/src/statements/set_pf_status.js +10 -10
  379. package/build/src/statements/set_screen.d.ts +7 -7
  380. package/build/src/statements/set_screen.js +10 -10
  381. package/build/src/statements/set_titlebar.d.ts +7 -7
  382. package/build/src/statements/set_titlebar.js +10 -10
  383. package/build/src/statements/shift.d.ts +7 -7
  384. package/build/src/statements/shift.js +42 -42
  385. package/build/src/statements/sort.d.ts +8 -8
  386. package/build/src/statements/sort.js +48 -48
  387. package/build/src/statements/sort_dataset.d.ts +7 -7
  388. package/build/src/statements/sort_dataset.js +10 -10
  389. package/build/src/statements/split.d.ts +7 -7
  390. package/build/src/statements/split.js +23 -23
  391. package/build/src/statements/start_of_selection.d.ts +6 -6
  392. package/build/src/statements/start_of_selection.js +10 -10
  393. package/build/src/statements/submit.d.ts +7 -7
  394. package/build/src/statements/submit.js +10 -10
  395. package/build/src/statements/subtract.d.ts +7 -7
  396. package/build/src/statements/subtract.js +20 -20
  397. package/build/src/statements/syntax_check.d.ts +7 -7
  398. package/build/src/statements/syntax_check.js +10 -10
  399. package/build/src/statements/tables.d.ts +7 -7
  400. package/build/src/statements/tables.js +30 -30
  401. package/build/src/statements/translate.d.ts +7 -7
  402. package/build/src/statements/translate.js +29 -29
  403. package/build/src/statements/truncate_dataset.d.ts +7 -7
  404. package/build/src/statements/truncate_dataset.js +10 -10
  405. package/build/src/statements/try.d.ts +7 -7
  406. package/build/src/statements/try.js +10 -10
  407. package/build/src/statements/type.d.ts +6 -6
  408. package/build/src/statements/type.js +10 -10
  409. package/build/src/statements/type_pools.d.ts +7 -7
  410. package/build/src/statements/type_pools.js +11 -11
  411. package/build/src/statements/unassign.d.ts +7 -7
  412. package/build/src/statements/unassign.js +13 -13
  413. package/build/src/statements/unpack.d.ts +7 -7
  414. package/build/src/statements/unpack.js +10 -10
  415. package/build/src/statements/update_database.d.ts +7 -7
  416. package/build/src/statements/update_database.js +29 -29
  417. package/build/src/statements/wait.d.ts +7 -7
  418. package/build/src/statements/wait.js +28 -28
  419. package/build/src/statements/when.d.ts +9 -9
  420. package/build/src/statements/when.js +23 -23
  421. package/build/src/statements/while.d.ts +9 -9
  422. package/build/src/statements/while.js +21 -21
  423. package/build/src/statements/write.d.ts +7 -7
  424. package/build/src/statements/write.js +56 -56
  425. package/build/src/structures/_structure_transpiler.d.ts +6 -6
  426. package/build/src/structures/_structure_transpiler.js +2 -2
  427. package/build/src/structures/at.d.ts +7 -7
  428. package/build/src/structures/at.js +47 -47
  429. package/build/src/structures/at_first.d.ts +7 -7
  430. package/build/src/structures/at_first.js +16 -16
  431. package/build/src/structures/at_last.d.ts +7 -7
  432. package/build/src/structures/at_last.js +16 -16
  433. package/build/src/structures/case.d.ts +7 -7
  434. package/build/src/structures/case.js +53 -53
  435. package/build/src/structures/class_definition.d.ts +7 -7
  436. package/build/src/structures/class_definition.js +27 -27
  437. package/build/src/structures/class_implementation.d.ts +14 -14
  438. package/build/src/structures/class_implementation.js +146 -146
  439. package/build/src/structures/constants.d.ts +7 -7
  440. package/build/src/structures/constants.js +33 -33
  441. package/build/src/structures/data.d.ts +7 -7
  442. package/build/src/structures/data.js +26 -26
  443. package/build/src/structures/define.d.ts +7 -7
  444. package/build/src/structures/define.js +11 -11
  445. package/build/src/structures/do.d.ts +7 -7
  446. package/build/src/structures/do.js +27 -27
  447. package/build/src/structures/function_module.d.ts +8 -8
  448. package/build/src/structures/function_module.js +71 -71
  449. package/build/src/structures/index.d.ts +17 -17
  450. package/build/src/structures/index.js +33 -33
  451. package/build/src/structures/interface.d.ts +9 -9
  452. package/build/src/structures/interface.js +74 -74
  453. package/build/src/structures/loop.d.ts +7 -7
  454. package/build/src/structures/loop.js +93 -93
  455. package/build/src/structures/select.d.ts +7 -7
  456. package/build/src/structures/select.js +34 -34
  457. package/build/src/structures/try.d.ts +8 -8
  458. package/build/src/structures/try.js +69 -69
  459. package/build/src/structures/types.d.ts +7 -7
  460. package/build/src/structures/types.js +10 -10
  461. package/build/src/structures/when.d.ts +7 -7
  462. package/build/src/structures/when.js +15 -15
  463. package/build/src/structures/while.d.ts +7 -7
  464. package/build/src/structures/while.js +27 -27
  465. package/build/src/transpile_types.d.ts +6 -6
  466. package/build/src/transpile_types.js +175 -175
  467. package/build/src/traversal.d.ts +52 -52
  468. package/build/src/traversal.js +549 -549
  469. package/build/src/types.d.ts +58 -58
  470. package/build/src/types.js +2 -2
  471. package/build/src/unique_identifier.d.ts +9 -9
  472. package/build/src/unique_identifier.js +27 -27
  473. package/build/src/unit_test.d.ts +15 -15
  474. package/build/src/unit_test.js +183 -183
  475. package/build/src/validation.d.ts +8 -8
  476. package/build/src/validation.js +116 -116
  477. package/package.json +2 -2
@@ -1,550 +1,550 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Traversal = void 0;
4
- const abaplint = require("@abaplint/core");
5
- const StatementTranspilers = require("./statements");
6
- const ExpressionTranspilers = require("./expressions");
7
- const StructureTranspilers = require("./structures");
8
- const transpile_types_1 = require("./transpile_types");
9
- const chunk_1 = require("./chunk");
10
- const expressions_1 = require("./expressions");
11
- class Traversal {
12
- constructor(spaghetti, file, obj, reg, options) {
13
- this.scopeCache = undefined;
14
- this.spaghetti = spaghetti;
15
- this.file = file;
16
- this.obj = obj;
17
- this.reg = reg;
18
- this.options = options;
19
- }
20
- static escapeNamespace(name) {
21
- return name === null || name === void 0 ? void 0 : name.replace(/\//g, "$");
22
- }
23
- getCurrentObject() {
24
- return this.obj;
25
- }
26
- traverse(node) {
27
- if (node instanceof abaplint.Nodes.StructureNode) {
28
- return this.traverseStructure(node);
29
- }
30
- else if (node instanceof abaplint.Nodes.StatementNode) {
31
- return this.traverseStatement(node);
32
- }
33
- else if (node instanceof abaplint.Nodes.ExpressionNode) {
34
- return this.traverseExpression(node);
35
- }
36
- else if (node === undefined) {
37
- throw new Error("Traverse, node undefined");
38
- }
39
- else {
40
- throw new Error("Traverse, unexpected node type");
41
- }
42
- }
43
- getFilename() {
44
- return this.file.getFilename();
45
- }
46
- getFile() {
47
- return this.file;
48
- }
49
- getSpaghetti() {
50
- return this.spaghetti;
51
- }
52
- /** finds a statement in the _current_ file given a position */
53
- findStatementInFile(pos) {
54
- for (const s of this.file.getStatements()) {
55
- if (pos.isBetween(s.getStart(), s.getEnd())) {
56
- return s;
57
- }
58
- }
59
- return undefined;
60
- }
61
- findCurrentScopeByToken(token) {
62
- const filename = this.file.getFilename();
63
- if (this.scopeCache
64
- && this.scopeCache.filename === filename
65
- && token.getEnd().isBetween(this.scopeCache.cov.start, this.scopeCache.cov.end)) {
66
- return this.scopeCache.node;
67
- }
68
- const node = this.spaghetti.lookupPosition(token.getStart(), filename);
69
- // note: cache only works for leafs, as parent nodes cover multiple leaves
70
- if (node && node.getChildren().length === 0) {
71
- this.scopeCache = {
72
- cov: node.calcCoverage(),
73
- filename: filename,
74
- node: node,
75
- };
76
- }
77
- else {
78
- this.scopeCache = undefined;
79
- }
80
- return node;
81
- }
82
- getInterfaceDefinition(token) {
83
- let scope = this.findCurrentScopeByToken(token);
84
- while (scope !== undefined) {
85
- if (scope.getIdentifier().stype === abaplint.ScopeType.Interface) {
86
- return scope.findInterfaceDefinition(scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname);
87
- }
88
- scope = scope.getParent();
89
- }
90
- return undefined;
91
- }
92
- getClassDefinition(token) {
93
- let scope = this.findCurrentScopeByToken(token);
94
- while (scope !== undefined) {
95
- if (scope.getIdentifier().stype === abaplint.ScopeType.ClassImplementation
96
- || scope.getIdentifier().stype === abaplint.ScopeType.ClassDefinition) {
97
- return scope.findClassDefinition(scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname);
98
- }
99
- scope = scope.getParent();
100
- }
101
- return undefined;
102
- }
103
- isClassAttribute(token) {
104
- const scope = this.findCurrentScopeByToken(token);
105
- if (scope === undefined) {
106
- throw new Error("isClassAttribute, unable to lookup position");
107
- }
108
- const name = token.getStr();
109
- if (name.toLowerCase() === "me") {
110
- return true;
111
- }
112
- const found = scope.findScopeForVariable(name);
113
- if (found && (found.stype === abaplint.ScopeType.MethodInstance
114
- || found.stype === abaplint.ScopeType.ClassImplementation)) {
115
- return true;
116
- }
117
- return false;
118
- }
119
- prefixAndName(t, filename) {
120
- let name = t.getStr().toLowerCase();
121
- if (filename && this.getCurrentObject().getABAPFileByName(filename) === undefined) {
122
- // the prefix is from a different object
123
- const file = this.reg.getFileByName(filename);
124
- if (file) {
125
- const found = this.reg.findObjectForFile(file);
126
- if (found) {
127
- if (found instanceof abaplint.Objects.Interface) {
128
- return Traversal.escapeNamespace(this.lookupClassOrInterface(found.getName(), t)) + "." + found.getName().toLowerCase() + "$" + name;
129
- }
130
- else {
131
- return Traversal.escapeNamespace(this.lookupClassOrInterface(found.getName(), t)) + "." + name;
132
- }
133
- }
134
- }
135
- }
136
- const className = this.isStaticClassAttribute(t);
137
- if (className) {
138
- name = Traversal.escapeNamespace(className) + "." + name;
139
- }
140
- else if (name === "super") {
141
- return name;
142
- }
143
- else if (this.isClassAttribute(t)) {
144
- name = "this." + Traversal.escapeNamespace(name);
145
- }
146
- else if (this.isBuiltinVariable(t)) {
147
- name = "abap.builtin." + name;
148
- }
149
- else if (this.isTypePool(t)) {
150
- const tp = this.isTypePool(t);
151
- name = `abap.TypePools["${tp}"].` + name.toLowerCase();
152
- }
153
- return name;
154
- }
155
- isStaticClassAttribute(token) {
156
- const scope = this.findCurrentScopeByToken(token);
157
- if (scope === undefined) {
158
- throw new Error(`isStaticClassAttribute, unable to lookup position, ${token.getStr()},${token.getRow()},${token.getCol()},` +
159
- this.file.getFilename());
160
- }
161
- const name = token.getStr();
162
- const found = scope.findScopeForVariable(name);
163
- const id = scope.findVariable(name);
164
- if (found && id
165
- && id.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */)
166
- && found.stype === abaplint.ScopeType.ClassImplementation) {
167
- // console.dir(found.sname);
168
- return found.sname.toLowerCase();
169
- }
170
- return undefined;
171
- }
172
- isBuiltinMethod(token) {
173
- const scope = this.findCurrentScopeByToken(token);
174
- if (scope === undefined) {
175
- return false;
176
- }
177
- for (const r of scope.getData().references) {
178
- if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
179
- && r.position.getStart().equals(token.getStart())) {
180
- return true;
181
- }
182
- }
183
- return false;
184
- }
185
- findMethodReference(token, scope) {
186
- var _a, _b;
187
- let candidate = undefined;
188
- if (scope === undefined) {
189
- return undefined;
190
- }
191
- for (const r of scope.getData().references) {
192
- if (r.referenceType === abaplint.ReferenceType.MethodReference
193
- && r.position.getStart().equals(token.getStart())
194
- && r.resolved instanceof abaplint.Types.MethodDefinition) {
195
- let name = r.resolved.getName();
196
- if (((_a = r.extra) === null || _a === void 0 ? void 0 : _a.ooName) && ((_b = r.extra) === null || _b === void 0 ? void 0 : _b.ooType) === "INTF") {
197
- name = r.extra.ooName + "$" + name;
198
- }
199
- candidate = { def: r.resolved, name };
200
- if (token.getStart() instanceof abaplint.VirtualPosition
201
- && name.toLowerCase().includes(token.getStr().toLowerCase()) === false) {
202
- // if its macros and they are nested everything can go wrong, so try looking for a better candidate
203
- continue;
204
- }
205
- return candidate;
206
- }
207
- else if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
208
- && r.position.getStart().equals(token.getStart())) {
209
- const def = r.resolved;
210
- const name = def.getName();
211
- return { def, name };
212
- }
213
- }
214
- return candidate;
215
- }
216
- isBuiltinVariable(token) {
217
- const scope = this.findCurrentScopeByToken(token);
218
- if (scope === undefined) {
219
- throw new Error("isBuiltin, unable to lookup position");
220
- }
221
- const name = token.getStr();
222
- const found = scope.findScopeForVariable(name);
223
- if (found && found.stype === abaplint.ScopeType.BuiltIn) {
224
- return true;
225
- }
226
- return false;
227
- }
228
- isTypePool(token) {
229
- const ref = this.findReadOrWriteReference(token);
230
- if (ref === null || ref === void 0 ? void 0 : ref.getFilename().endsWith(".type.abap")) {
231
- const file = this.reg.getFileByName(ref.getFilename());
232
- if (file === undefined) {
233
- return undefined;
234
- }
235
- const obj = this.reg.findObjectForFile(file);
236
- return obj === null || obj === void 0 ? void 0 : obj.getName();
237
- }
238
- return undefined;
239
- }
240
- // returns the interface name if interfaced
241
- isInterfaceAttribute(token) {
242
- const ref = this.findReadOrWriteReference(token);
243
- if (ref === undefined) {
244
- return undefined;
245
- }
246
- // local classes
247
- if (ref.getFilename() === this.getFilename()) {
248
- const scope = this.findCurrentScopeByToken(ref.getToken());
249
- if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Interface) {
250
- return scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname;
251
- }
252
- }
253
- // global classes
254
- const file = this.reg.getFileByName(ref.getFilename());
255
- if (file) {
256
- const obj = this.reg.findObjectForFile(file);
257
- if ((obj === null || obj === void 0 ? void 0 : obj.getType()) === "INTF") {
258
- return obj.getName().toLowerCase();
259
- }
260
- }
261
- return undefined;
262
- }
263
- findReadOrWriteReference(token) {
264
- const scope = this.findCurrentScopeByToken(token);
265
- if (scope === undefined) {
266
- return undefined;
267
- }
268
- for (const r of scope.getData().references) {
269
- if ((r.referenceType === abaplint.ReferenceType.DataReadReference
270
- || r.referenceType === abaplint.ReferenceType.DataWriteReference)
271
- && r.position.getStart().equals(token.getStart())) {
272
- return r.resolved;
273
- }
274
- }
275
- return undefined;
276
- }
277
- buildConstructorContents(scope, def) {
278
- let ret = "";
279
- if (def.getSuperClass() !== undefined
280
- && def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
281
- ret += `await super.constructor_(INPUT);\n`;
282
- }
283
- const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
284
- ret += "this.me = new abap.types.ABAPObject();\n";
285
- ret += "this.me.set(this);\n";
286
- for (const a of def.getAttributes().getAll()) {
287
- if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
288
- continue;
289
- }
290
- const name = "this." + Traversal.escapeNamespace(a.getName().toLowerCase());
291
- ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
292
- ret += this.setValues(a, name);
293
- }
294
- // attributes from directly implemented interfaces(not interfaces implemented in super classes)
295
- for (const i of def.getImplementing()) {
296
- ret += this.dataFromInterfaces(i.name, scope);
297
- }
298
- // handle aliases after initialization of carrier variables
299
- for (const a of def.getAliases().getAll()) {
300
- ret += "this." + a.getName().toLowerCase() + " = this." + Traversal.escapeNamespace(a.getComponent().replace("~", "$").toLowerCase()) + ";\n";
301
- }
302
- // constants can be accessed both statically and via reference
303
- for (const c of def.getAttributes().getConstants()) {
304
- ret += "this." + Traversal.escapeNamespace(c.getName().toLowerCase()) + " = " + cName + "." + Traversal.escapeNamespace(c.getName().toLowerCase()) + ";\n";
305
- }
306
- return ret;
307
- }
308
- findInterfaceDefinition(name, scope) {
309
- let intf = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
310
- if (intf === undefined) {
311
- const iglobal = this.reg.getObject("INTF", name);
312
- intf = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
313
- }
314
- return intf;
315
- }
316
- findTable(name) {
317
- const tabl = this.reg.getObject("TABL", name);
318
- return tabl;
319
- }
320
- findClassDefinition(name, scope) {
321
- if (name === undefined || scope === undefined) {
322
- return undefined;
323
- }
324
- let clas = scope.findClassDefinition(name);
325
- if (clas === undefined) {
326
- const iglobal = this.reg.getObject("CLAS", name);
327
- clas = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
328
- }
329
- return clas;
330
- }
331
- dataFromInterfaces(name, scope) {
332
- let ret = "";
333
- const intf = this.findInterfaceDefinition(name, scope);
334
- for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getConstants()) || []) {
335
- const fname = Traversal.escapeNamespace(a.getName().toLowerCase());
336
- const iname = Traversal.escapeNamespace(intf === null || intf === void 0 ? void 0 : intf.getName().toLowerCase());
337
- if ((intf === null || intf === void 0 ? void 0 : intf.isGlobal()) === true) {
338
- ret += "this." + iname + "$" + fname + " = abap.Classes['" + (intf === null || intf === void 0 ? void 0 : intf.getName().toUpperCase()) + "']." + iname + "$" + fname + ";\n";
339
- }
340
- else {
341
- ret += "this." + iname + "$" + fname + " = " + iname + "." + iname + "$" + fname + ";\n";
342
- }
343
- }
344
- for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getAll()) || []) {
345
- if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
346
- continue;
347
- }
348
- const n = Traversal.escapeNamespace(name.toLowerCase()) + "$" + a.getName().toLowerCase();
349
- // note: interface inheritenace and super inheritance might be strange,
350
- ret += "if (this." + n + " === undefined) this." + n + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
351
- }
352
- for (const i of (intf === null || intf === void 0 ? void 0 : intf.getImplementing()) || []) {
353
- ret += this.dataFromInterfaces(i.name, scope);
354
- }
355
- return ret;
356
- }
357
- determineType(node, scope) {
358
- var _a, _b, _c;
359
- if (scope === undefined) {
360
- return undefined;
361
- }
362
- const found = node.findDirectExpression(abaplint.Expressions.Target);
363
- if (found === undefined) {
364
- return undefined;
365
- }
366
- let context = undefined;
367
- for (const c of found.getChildren()) {
368
- if (context === undefined) {
369
- context = (_a = scope.findVariable(c.getFirstToken().getStr())) === null || _a === void 0 ? void 0 : _a.getType();
370
- }
371
- else if (c.get() instanceof abaplint.Expressions.ComponentName
372
- && context instanceof abaplint.BasicTypes.StructureType) {
373
- context = context.getComponentByName(c.getFirstToken().getStr());
374
- }
375
- else if (c.get() instanceof abaplint.Expressions.AttributeName
376
- && context instanceof abaplint.BasicTypes.ObjectReferenceType) {
377
- const id = context.getIdentifier();
378
- if (id instanceof abaplint.Types.ClassDefinition || id instanceof abaplint.Types.InterfaceDefinition) {
379
- const concat = c.concatTokens();
380
- if (concat.includes("~")) {
381
- const [iname, aname] = concat.split("~");
382
- const intf = this.findInterfaceDefinition(iname, scope);
383
- context = (_b = intf === null || intf === void 0 ? void 0 : intf.getAttributes().findByName(aname)) === null || _b === void 0 ? void 0 : _b.getType();
384
- }
385
- else {
386
- context = (_c = id.getAttributes().findByName(concat)) === null || _c === void 0 ? void 0 : _c.getType();
387
- }
388
- }
389
- }
390
- }
391
- return context;
392
- }
393
- isInsideLoop(node) {
394
- const stack = [];
395
- for (const statement of this.getFile().getStatements()) {
396
- const get = statement.get();
397
- if (get instanceof abaplint.Statements.Loop
398
- || get instanceof abaplint.Statements.While
399
- || get instanceof abaplint.Statements.SelectLoop
400
- || get instanceof abaplint.Statements.Do) {
401
- stack.push(statement);
402
- }
403
- else if (get instanceof abaplint.Statements.EndLoop
404
- || get instanceof abaplint.Statements.EndWhile
405
- || get instanceof abaplint.Statements.EndSelect
406
- || get instanceof abaplint.Statements.EndDo) {
407
- stack.pop();
408
- }
409
- if (statement === node) {
410
- break;
411
- }
412
- }
413
- return stack.length > 0;
414
- }
415
- isInsideDoOrWhile(node) {
416
- const stack = [];
417
- for (const statement of this.getFile().getStatements()) {
418
- const get = statement.get();
419
- if (get instanceof abaplint.Statements.While
420
- || get instanceof abaplint.Statements.Do) {
421
- stack.push(statement);
422
- }
423
- else if (get instanceof abaplint.Statements.EndWhile
424
- || get instanceof abaplint.Statements.EndDo) {
425
- stack.pop();
426
- }
427
- if (statement === node) {
428
- break;
429
- }
430
- }
431
- return stack.length > 0;
432
- }
433
- registerClassOrInterface(def) {
434
- if (def === undefined) {
435
- return "";
436
- }
437
- const name = def.getName();
438
- if (def.isGlobal() === false) {
439
- const prefix = this.buildPrefix(def);
440
- return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
441
- }
442
- else {
443
- return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
444
- }
445
- }
446
- setValues(identifier, name) {
447
- return Traversal.setValues(identifier, name);
448
- }
449
- static setValues(identifier, name) {
450
- const val = identifier.getValue();
451
- let ret = "";
452
- if (typeof val === "string") {
453
- const e = new expressions_1.ConstantTranspiler().escape(val);
454
- ret += name + ".set(" + e + ");\n";
455
- }
456
- else if (typeof val === "object") {
457
- const a = val;
458
- for (const v of Object.keys(val)) {
459
- let s = a[v];
460
- if (s === undefined) {
461
- continue;
462
- }
463
- s = new expressions_1.ConstantTranspiler().escape(s);
464
- ret += name + ".get()." + v + ".set(" + s + ");\n";
465
- }
466
- }
467
- return ret;
468
- }
469
- lookupClassOrInterface(name, token, directGlobal = false) {
470
- var _a, _b;
471
- if (name === undefined || token === undefined) {
472
- return "abap.Classes['undefined']";
473
- }
474
- if (directGlobal === true) {
475
- return "abap.Classes[" + name + "]";
476
- }
477
- const scope = this.findCurrentScopeByToken(token);
478
- // todo, add explicit type,
479
- let def = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(name);
480
- if (def === undefined) {
481
- def = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
482
- }
483
- if (def) {
484
- if (def.isGlobal() === false) {
485
- const prefix = this.buildPrefix(def);
486
- return `abap.Classes['${prefix}-${(_a = def === null || def === void 0 ? void 0 : def.getName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()}']`;
487
- }
488
- else {
489
- return `abap.Classes['${(_b = def === null || def === void 0 ? void 0 : def.getName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()}']`;
490
- }
491
- }
492
- else {
493
- // assume global
494
- return "abap.Classes['" + name.toUpperCase() + "']";
495
- }
496
- }
497
- buildPrefix(def) {
498
- const file = this.reg.getFileByName(def.getFilename());
499
- if (file === undefined) {
500
- return "NOT_FOUND";
501
- }
502
- const obj = this.reg.findObjectForFile(file);
503
- return (obj === null || obj === void 0 ? void 0 : obj.getType()) + "-" + (obj === null || obj === void 0 ? void 0 : obj.getName());
504
- }
505
- ////////////////////////////
506
- traverseStructure(node) {
507
- const list = StructureTranspilers;
508
- const ret = new chunk_1.Chunk();
509
- const search = node.get().constructor.name + "Transpiler";
510
- if (list[search]) {
511
- const transpiler = new list[search]();
512
- ret.appendChunk(transpiler.transpile(node, this));
513
- return ret;
514
- }
515
- for (const c of node.getChildren()) {
516
- if (c instanceof abaplint.Nodes.StructureNode) {
517
- ret.appendChunk(this.traverseStructure(c));
518
- }
519
- else if (c instanceof abaplint.Nodes.StatementNode) {
520
- ret.appendChunk(this.traverseStatement(c));
521
- }
522
- else {
523
- throw new Error("traverseStructure, unexpected child node type");
524
- }
525
- }
526
- return ret;
527
- }
528
- traverseStatement(node) {
529
- const list = StatementTranspilers;
530
- const search = node.get().constructor.name + "Transpiler";
531
- if (list[search]) {
532
- const transpiler = new list[search]();
533
- const chunk = transpiler.transpile(node, this);
534
- chunk.appendString("\n");
535
- return chunk;
536
- }
537
- throw new Error(`Statement ${node.get().constructor.name} not supported, ${node.concatTokens()}`);
538
- }
539
- traverseExpression(node) {
540
- const list = ExpressionTranspilers;
541
- const search = node.get().constructor.name + "Transpiler";
542
- if (list[search]) {
543
- const transpiler = new list[search]();
544
- return transpiler.transpile(node, this);
545
- }
546
- throw new Error(`Expression ${node.get().constructor.name} not supported, ${node.concatTokens()}`);
547
- }
548
- }
549
- exports.Traversal = Traversal;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Traversal = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ const StatementTranspilers = require("./statements");
6
+ const ExpressionTranspilers = require("./expressions");
7
+ const StructureTranspilers = require("./structures");
8
+ const transpile_types_1 = require("./transpile_types");
9
+ const chunk_1 = require("./chunk");
10
+ const expressions_1 = require("./expressions");
11
+ class Traversal {
12
+ constructor(spaghetti, file, obj, reg, options) {
13
+ this.scopeCache = undefined;
14
+ this.spaghetti = spaghetti;
15
+ this.file = file;
16
+ this.obj = obj;
17
+ this.reg = reg;
18
+ this.options = options;
19
+ }
20
+ static escapeNamespace(name) {
21
+ return name === null || name === void 0 ? void 0 : name.replace(/\//g, "$");
22
+ }
23
+ getCurrentObject() {
24
+ return this.obj;
25
+ }
26
+ traverse(node) {
27
+ if (node instanceof abaplint.Nodes.StructureNode) {
28
+ return this.traverseStructure(node);
29
+ }
30
+ else if (node instanceof abaplint.Nodes.StatementNode) {
31
+ return this.traverseStatement(node);
32
+ }
33
+ else if (node instanceof abaplint.Nodes.ExpressionNode) {
34
+ return this.traverseExpression(node);
35
+ }
36
+ else if (node === undefined) {
37
+ throw new Error("Traverse, node undefined");
38
+ }
39
+ else {
40
+ throw new Error("Traverse, unexpected node type");
41
+ }
42
+ }
43
+ getFilename() {
44
+ return this.file.getFilename();
45
+ }
46
+ getFile() {
47
+ return this.file;
48
+ }
49
+ getSpaghetti() {
50
+ return this.spaghetti;
51
+ }
52
+ /** finds a statement in the _current_ file given a position */
53
+ findStatementInFile(pos) {
54
+ for (const s of this.file.getStatements()) {
55
+ if (pos.isBetween(s.getStart(), s.getEnd())) {
56
+ return s;
57
+ }
58
+ }
59
+ return undefined;
60
+ }
61
+ findCurrentScopeByToken(token) {
62
+ const filename = this.file.getFilename();
63
+ if (this.scopeCache
64
+ && this.scopeCache.filename === filename
65
+ && token.getEnd().isBetween(this.scopeCache.cov.start, this.scopeCache.cov.end)) {
66
+ return this.scopeCache.node;
67
+ }
68
+ const node = this.spaghetti.lookupPosition(token.getStart(), filename);
69
+ // note: cache only works for leafs, as parent nodes cover multiple leaves
70
+ if (node && node.getChildren().length === 0) {
71
+ this.scopeCache = {
72
+ cov: node.calcCoverage(),
73
+ filename: filename,
74
+ node: node,
75
+ };
76
+ }
77
+ else {
78
+ this.scopeCache = undefined;
79
+ }
80
+ return node;
81
+ }
82
+ getInterfaceDefinition(token) {
83
+ let scope = this.findCurrentScopeByToken(token);
84
+ while (scope !== undefined) {
85
+ if (scope.getIdentifier().stype === abaplint.ScopeType.Interface) {
86
+ return scope.findInterfaceDefinition(scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname);
87
+ }
88
+ scope = scope.getParent();
89
+ }
90
+ return undefined;
91
+ }
92
+ getClassDefinition(token) {
93
+ let scope = this.findCurrentScopeByToken(token);
94
+ while (scope !== undefined) {
95
+ if (scope.getIdentifier().stype === abaplint.ScopeType.ClassImplementation
96
+ || scope.getIdentifier().stype === abaplint.ScopeType.ClassDefinition) {
97
+ return scope.findClassDefinition(scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname);
98
+ }
99
+ scope = scope.getParent();
100
+ }
101
+ return undefined;
102
+ }
103
+ isClassAttribute(token) {
104
+ const scope = this.findCurrentScopeByToken(token);
105
+ if (scope === undefined) {
106
+ throw new Error("isClassAttribute, unable to lookup position");
107
+ }
108
+ const name = token.getStr();
109
+ if (name.toLowerCase() === "me") {
110
+ return true;
111
+ }
112
+ const found = scope.findScopeForVariable(name);
113
+ if (found && (found.stype === abaplint.ScopeType.MethodInstance
114
+ || found.stype === abaplint.ScopeType.ClassImplementation)) {
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+ prefixAndName(t, filename) {
120
+ let name = t.getStr().toLowerCase();
121
+ if (filename && this.getCurrentObject().getABAPFileByName(filename) === undefined) {
122
+ // the prefix is from a different object
123
+ const file = this.reg.getFileByName(filename);
124
+ if (file) {
125
+ const found = this.reg.findObjectForFile(file);
126
+ if (found) {
127
+ if (found instanceof abaplint.Objects.Interface) {
128
+ return Traversal.escapeNamespace(this.lookupClassOrInterface(found.getName(), t)) + "." + found.getName().toLowerCase() + "$" + name;
129
+ }
130
+ else {
131
+ return Traversal.escapeNamespace(this.lookupClassOrInterface(found.getName(), t)) + "." + name;
132
+ }
133
+ }
134
+ }
135
+ }
136
+ const className = this.isStaticClassAttribute(t);
137
+ if (className) {
138
+ name = Traversal.escapeNamespace(className) + "." + name;
139
+ }
140
+ else if (name === "super") {
141
+ return name;
142
+ }
143
+ else if (this.isClassAttribute(t)) {
144
+ name = "this." + Traversal.escapeNamespace(name);
145
+ }
146
+ else if (this.isBuiltinVariable(t)) {
147
+ name = "abap.builtin." + name;
148
+ }
149
+ else if (this.isTypePool(t)) {
150
+ const tp = this.isTypePool(t);
151
+ name = `abap.TypePools["${tp}"].` + name.toLowerCase();
152
+ }
153
+ return name;
154
+ }
155
+ isStaticClassAttribute(token) {
156
+ const scope = this.findCurrentScopeByToken(token);
157
+ if (scope === undefined) {
158
+ throw new Error(`isStaticClassAttribute, unable to lookup position, ${token.getStr()},${token.getRow()},${token.getCol()},` +
159
+ this.file.getFilename());
160
+ }
161
+ const name = token.getStr();
162
+ const found = scope.findScopeForVariable(name);
163
+ const id = scope.findVariable(name);
164
+ if (found && id
165
+ && id.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */)
166
+ && found.stype === abaplint.ScopeType.ClassImplementation) {
167
+ // console.dir(found.sname);
168
+ return found.sname.toLowerCase();
169
+ }
170
+ return undefined;
171
+ }
172
+ isBuiltinMethod(token) {
173
+ const scope = this.findCurrentScopeByToken(token);
174
+ if (scope === undefined) {
175
+ return false;
176
+ }
177
+ for (const r of scope.getData().references) {
178
+ if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
179
+ && r.position.getStart().equals(token.getStart())) {
180
+ return true;
181
+ }
182
+ }
183
+ return false;
184
+ }
185
+ findMethodReference(token, scope) {
186
+ var _a, _b;
187
+ let candidate = undefined;
188
+ if (scope === undefined) {
189
+ return undefined;
190
+ }
191
+ for (const r of scope.getData().references) {
192
+ if (r.referenceType === abaplint.ReferenceType.MethodReference
193
+ && r.position.getStart().equals(token.getStart())
194
+ && r.resolved instanceof abaplint.Types.MethodDefinition) {
195
+ let name = r.resolved.getName();
196
+ if (((_a = r.extra) === null || _a === void 0 ? void 0 : _a.ooName) && ((_b = r.extra) === null || _b === void 0 ? void 0 : _b.ooType) === "INTF") {
197
+ name = r.extra.ooName + "$" + name;
198
+ }
199
+ candidate = { def: r.resolved, name };
200
+ if (token.getStart() instanceof abaplint.VirtualPosition
201
+ && name.toLowerCase().includes(token.getStr().toLowerCase()) === false) {
202
+ // if its macros and they are nested everything can go wrong, so try looking for a better candidate
203
+ continue;
204
+ }
205
+ return candidate;
206
+ }
207
+ else if (r.referenceType === abaplint.ReferenceType.BuiltinMethodReference
208
+ && r.position.getStart().equals(token.getStart())) {
209
+ const def = r.resolved;
210
+ const name = def.getName();
211
+ return { def, name };
212
+ }
213
+ }
214
+ return candidate;
215
+ }
216
+ isBuiltinVariable(token) {
217
+ const scope = this.findCurrentScopeByToken(token);
218
+ if (scope === undefined) {
219
+ throw new Error("isBuiltin, unable to lookup position");
220
+ }
221
+ const name = token.getStr();
222
+ const found = scope.findScopeForVariable(name);
223
+ if (found && found.stype === abaplint.ScopeType.BuiltIn) {
224
+ return true;
225
+ }
226
+ return false;
227
+ }
228
+ isTypePool(token) {
229
+ const ref = this.findReadOrWriteReference(token);
230
+ if (ref === null || ref === void 0 ? void 0 : ref.getFilename().endsWith(".type.abap")) {
231
+ const file = this.reg.getFileByName(ref.getFilename());
232
+ if (file === undefined) {
233
+ return undefined;
234
+ }
235
+ const obj = this.reg.findObjectForFile(file);
236
+ return obj === null || obj === void 0 ? void 0 : obj.getName();
237
+ }
238
+ return undefined;
239
+ }
240
+ // returns the interface name if interfaced
241
+ isInterfaceAttribute(token) {
242
+ const ref = this.findReadOrWriteReference(token);
243
+ if (ref === undefined) {
244
+ return undefined;
245
+ }
246
+ // local classes
247
+ if (ref.getFilename() === this.getFilename()) {
248
+ const scope = this.findCurrentScopeByToken(ref.getToken());
249
+ if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Interface) {
250
+ return scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname;
251
+ }
252
+ }
253
+ // global classes
254
+ const file = this.reg.getFileByName(ref.getFilename());
255
+ if (file) {
256
+ const obj = this.reg.findObjectForFile(file);
257
+ if ((obj === null || obj === void 0 ? void 0 : obj.getType()) === "INTF") {
258
+ return obj.getName().toLowerCase();
259
+ }
260
+ }
261
+ return undefined;
262
+ }
263
+ findReadOrWriteReference(token) {
264
+ const scope = this.findCurrentScopeByToken(token);
265
+ if (scope === undefined) {
266
+ return undefined;
267
+ }
268
+ for (const r of scope.getData().references) {
269
+ if ((r.referenceType === abaplint.ReferenceType.DataReadReference
270
+ || r.referenceType === abaplint.ReferenceType.DataWriteReference)
271
+ && r.position.getStart().equals(token.getStart())) {
272
+ return r.resolved;
273
+ }
274
+ }
275
+ return undefined;
276
+ }
277
+ buildConstructorContents(scope, def) {
278
+ let ret = "";
279
+ if (def.getSuperClass() !== undefined
280
+ && def.getMethodDefinitions().getByName("CONSTRUCTOR") === undefined) {
281
+ ret += `await super.constructor_(INPUT);\n`;
282
+ }
283
+ const cName = Traversal.escapeNamespace(def.getName().toLowerCase());
284
+ ret += "this.me = new abap.types.ABAPObject();\n";
285
+ ret += "this.me.set(this);\n";
286
+ for (const a of def.getAttributes().getAll()) {
287
+ if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
288
+ continue;
289
+ }
290
+ const name = "this." + Traversal.escapeNamespace(a.getName().toLowerCase());
291
+ ret += name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
292
+ ret += this.setValues(a, name);
293
+ }
294
+ // attributes from directly implemented interfaces(not interfaces implemented in super classes)
295
+ for (const i of def.getImplementing()) {
296
+ ret += this.dataFromInterfaces(i.name, scope);
297
+ }
298
+ // handle aliases after initialization of carrier variables
299
+ for (const a of def.getAliases().getAll()) {
300
+ ret += "this." + a.getName().toLowerCase() + " = this." + Traversal.escapeNamespace(a.getComponent().replace("~", "$").toLowerCase()) + ";\n";
301
+ }
302
+ // constants can be accessed both statically and via reference
303
+ for (const c of def.getAttributes().getConstants()) {
304
+ ret += "this." + Traversal.escapeNamespace(c.getName().toLowerCase()) + " = " + cName + "." + Traversal.escapeNamespace(c.getName().toLowerCase()) + ";\n";
305
+ }
306
+ return ret;
307
+ }
308
+ findInterfaceDefinition(name, scope) {
309
+ let intf = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
310
+ if (intf === undefined) {
311
+ const iglobal = this.reg.getObject("INTF", name);
312
+ intf = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
313
+ }
314
+ return intf;
315
+ }
316
+ findTable(name) {
317
+ const tabl = this.reg.getObject("TABL", name);
318
+ return tabl;
319
+ }
320
+ findClassDefinition(name, scope) {
321
+ if (name === undefined || scope === undefined) {
322
+ return undefined;
323
+ }
324
+ let clas = scope.findClassDefinition(name);
325
+ if (clas === undefined) {
326
+ const iglobal = this.reg.getObject("CLAS", name);
327
+ clas = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
328
+ }
329
+ return clas;
330
+ }
331
+ dataFromInterfaces(name, scope) {
332
+ let ret = "";
333
+ const intf = this.findInterfaceDefinition(name, scope);
334
+ for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getConstants()) || []) {
335
+ const fname = Traversal.escapeNamespace(a.getName().toLowerCase());
336
+ const iname = Traversal.escapeNamespace(intf === null || intf === void 0 ? void 0 : intf.getName().toLowerCase());
337
+ if ((intf === null || intf === void 0 ? void 0 : intf.isGlobal()) === true) {
338
+ ret += "this." + iname + "$" + fname + " = abap.Classes['" + (intf === null || intf === void 0 ? void 0 : intf.getName().toUpperCase()) + "']." + iname + "$" + fname + ";\n";
339
+ }
340
+ else {
341
+ ret += "this." + iname + "$" + fname + " = " + iname + "." + iname + "$" + fname + ";\n";
342
+ }
343
+ }
344
+ for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getAll()) || []) {
345
+ if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
346
+ continue;
347
+ }
348
+ const n = Traversal.escapeNamespace(name.toLowerCase()) + "$" + a.getName().toLowerCase();
349
+ // note: interface inheritenace and super inheritance might be strange,
350
+ ret += "if (this." + n + " === undefined) this." + n + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
351
+ }
352
+ for (const i of (intf === null || intf === void 0 ? void 0 : intf.getImplementing()) || []) {
353
+ ret += this.dataFromInterfaces(i.name, scope);
354
+ }
355
+ return ret;
356
+ }
357
+ determineType(node, scope) {
358
+ var _a, _b, _c;
359
+ if (scope === undefined) {
360
+ return undefined;
361
+ }
362
+ const found = node.findDirectExpression(abaplint.Expressions.Target);
363
+ if (found === undefined) {
364
+ return undefined;
365
+ }
366
+ let context = undefined;
367
+ for (const c of found.getChildren()) {
368
+ if (context === undefined) {
369
+ context = (_a = scope.findVariable(c.getFirstToken().getStr())) === null || _a === void 0 ? void 0 : _a.getType();
370
+ }
371
+ else if (c.get() instanceof abaplint.Expressions.ComponentName
372
+ && context instanceof abaplint.BasicTypes.StructureType) {
373
+ context = context.getComponentByName(c.getFirstToken().getStr());
374
+ }
375
+ else if (c.get() instanceof abaplint.Expressions.AttributeName
376
+ && context instanceof abaplint.BasicTypes.ObjectReferenceType) {
377
+ const id = context.getIdentifier();
378
+ if (id instanceof abaplint.Types.ClassDefinition || id instanceof abaplint.Types.InterfaceDefinition) {
379
+ const concat = c.concatTokens();
380
+ if (concat.includes("~")) {
381
+ const [iname, aname] = concat.split("~");
382
+ const intf = this.findInterfaceDefinition(iname, scope);
383
+ context = (_b = intf === null || intf === void 0 ? void 0 : intf.getAttributes().findByName(aname)) === null || _b === void 0 ? void 0 : _b.getType();
384
+ }
385
+ else {
386
+ context = (_c = id.getAttributes().findByName(concat)) === null || _c === void 0 ? void 0 : _c.getType();
387
+ }
388
+ }
389
+ }
390
+ }
391
+ return context;
392
+ }
393
+ isInsideLoop(node) {
394
+ const stack = [];
395
+ for (const statement of this.getFile().getStatements()) {
396
+ const get = statement.get();
397
+ if (get instanceof abaplint.Statements.Loop
398
+ || get instanceof abaplint.Statements.While
399
+ || get instanceof abaplint.Statements.SelectLoop
400
+ || get instanceof abaplint.Statements.Do) {
401
+ stack.push(statement);
402
+ }
403
+ else if (get instanceof abaplint.Statements.EndLoop
404
+ || get instanceof abaplint.Statements.EndWhile
405
+ || get instanceof abaplint.Statements.EndSelect
406
+ || get instanceof abaplint.Statements.EndDo) {
407
+ stack.pop();
408
+ }
409
+ if (statement === node) {
410
+ break;
411
+ }
412
+ }
413
+ return stack.length > 0;
414
+ }
415
+ isInsideDoOrWhile(node) {
416
+ const stack = [];
417
+ for (const statement of this.getFile().getStatements()) {
418
+ const get = statement.get();
419
+ if (get instanceof abaplint.Statements.While
420
+ || get instanceof abaplint.Statements.Do) {
421
+ stack.push(statement);
422
+ }
423
+ else if (get instanceof abaplint.Statements.EndWhile
424
+ || get instanceof abaplint.Statements.EndDo) {
425
+ stack.pop();
426
+ }
427
+ if (statement === node) {
428
+ break;
429
+ }
430
+ }
431
+ return stack.length > 0;
432
+ }
433
+ registerClassOrInterface(def) {
434
+ if (def === undefined) {
435
+ return "";
436
+ }
437
+ const name = def.getName();
438
+ if (def.isGlobal() === false) {
439
+ const prefix = this.buildPrefix(def);
440
+ return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
441
+ }
442
+ else {
443
+ return `abap.Classes['${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
444
+ }
445
+ }
446
+ setValues(identifier, name) {
447
+ return Traversal.setValues(identifier, name);
448
+ }
449
+ static setValues(identifier, name) {
450
+ const val = identifier.getValue();
451
+ let ret = "";
452
+ if (typeof val === "string") {
453
+ const e = new expressions_1.ConstantTranspiler().escape(val);
454
+ ret += name + ".set(" + e + ");\n";
455
+ }
456
+ else if (typeof val === "object") {
457
+ const a = val;
458
+ for (const v of Object.keys(val)) {
459
+ let s = a[v];
460
+ if (s === undefined) {
461
+ continue;
462
+ }
463
+ s = new expressions_1.ConstantTranspiler().escape(s);
464
+ ret += name + ".get()." + v + ".set(" + s + ");\n";
465
+ }
466
+ }
467
+ return ret;
468
+ }
469
+ lookupClassOrInterface(name, token, directGlobal = false) {
470
+ var _a, _b;
471
+ if (name === undefined || token === undefined) {
472
+ return "abap.Classes['undefined']";
473
+ }
474
+ if (directGlobal === true) {
475
+ return "abap.Classes[" + name + "]";
476
+ }
477
+ const scope = this.findCurrentScopeByToken(token);
478
+ // todo, add explicit type,
479
+ let def = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(name);
480
+ if (def === undefined) {
481
+ def = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
482
+ }
483
+ if (def) {
484
+ if (def.isGlobal() === false) {
485
+ const prefix = this.buildPrefix(def);
486
+ return `abap.Classes['${prefix}-${(_a = def === null || def === void 0 ? void 0 : def.getName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()}']`;
487
+ }
488
+ else {
489
+ return `abap.Classes['${(_b = def === null || def === void 0 ? void 0 : def.getName()) === null || _b === void 0 ? void 0 : _b.toUpperCase()}']`;
490
+ }
491
+ }
492
+ else {
493
+ // assume global
494
+ return "abap.Classes['" + name.toUpperCase() + "']";
495
+ }
496
+ }
497
+ buildPrefix(def) {
498
+ const file = this.reg.getFileByName(def.getFilename());
499
+ if (file === undefined) {
500
+ return "NOT_FOUND";
501
+ }
502
+ const obj = this.reg.findObjectForFile(file);
503
+ return (obj === null || obj === void 0 ? void 0 : obj.getType()) + "-" + (obj === null || obj === void 0 ? void 0 : obj.getName());
504
+ }
505
+ ////////////////////////////
506
+ traverseStructure(node) {
507
+ const list = StructureTranspilers;
508
+ const ret = new chunk_1.Chunk();
509
+ const search = node.get().constructor.name + "Transpiler";
510
+ if (list[search]) {
511
+ const transpiler = new list[search]();
512
+ ret.appendChunk(transpiler.transpile(node, this));
513
+ return ret;
514
+ }
515
+ for (const c of node.getChildren()) {
516
+ if (c instanceof abaplint.Nodes.StructureNode) {
517
+ ret.appendChunk(this.traverseStructure(c));
518
+ }
519
+ else if (c instanceof abaplint.Nodes.StatementNode) {
520
+ ret.appendChunk(this.traverseStatement(c));
521
+ }
522
+ else {
523
+ throw new Error("traverseStructure, unexpected child node type");
524
+ }
525
+ }
526
+ return ret;
527
+ }
528
+ traverseStatement(node) {
529
+ const list = StatementTranspilers;
530
+ const search = node.get().constructor.name + "Transpiler";
531
+ if (list[search]) {
532
+ const transpiler = new list[search]();
533
+ const chunk = transpiler.transpile(node, this);
534
+ chunk.appendString("\n");
535
+ return chunk;
536
+ }
537
+ throw new Error(`Statement ${node.get().constructor.name} not supported, ${node.concatTokens()}`);
538
+ }
539
+ traverseExpression(node) {
540
+ const list = ExpressionTranspilers;
541
+ const search = node.get().constructor.name + "Transpiler";
542
+ if (list[search]) {
543
+ const transpiler = new list[search]();
544
+ return transpiler.transpile(node, this);
545
+ }
546
+ throw new Error(`Expression ${node.get().constructor.name} not supported, ${node.concatTokens()}`);
547
+ }
548
+ }
549
+ exports.Traversal = Traversal;
550
550
  //# sourceMappingURL=traversal.js.map