arkanalyzer 1.0.5

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 (322) hide show
  1. package/LICENSE +201 -0
  2. package/README.en.md +88 -0
  3. package/README.md +98 -0
  4. package/docs/HowToCreatePR.md +55 -0
  5. package/docs/HowToHandleIssues.md +155 -0
  6. package/docs/quickstart.pdf +0 -0
  7. package/lib/Config.d.ts +26 -0
  8. package/lib/Config.d.ts.map +1 -0
  9. package/lib/Config.js +128 -0
  10. package/lib/Scene.d.ts +125 -0
  11. package/lib/Scene.d.ts.map +1 -0
  12. package/lib/Scene.js +762 -0
  13. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +28 -0
  14. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -0
  15. package/lib/callgraph/algorithm/AbstractAnalysis.js +137 -0
  16. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts +11 -0
  17. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -0
  18. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +71 -0
  19. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +16 -0
  20. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -0
  21. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +147 -0
  22. package/lib/callgraph/common/Statistics.d.ts +58 -0
  23. package/lib/callgraph/common/Statistics.d.ts.map +1 -0
  24. package/lib/callgraph/common/Statistics.js +203 -0
  25. package/lib/callgraph/model/BaseGraph.d.ts +62 -0
  26. package/lib/callgraph/model/BaseGraph.d.ts.map +1 -0
  27. package/lib/callgraph/model/BaseGraph.js +158 -0
  28. package/lib/callgraph/model/CallGraph.d.ts +94 -0
  29. package/lib/callgraph/model/CallGraph.d.ts.map +1 -0
  30. package/lib/callgraph/model/CallGraph.js +339 -0
  31. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +16 -0
  32. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -0
  33. package/lib/callgraph/model/builder/CallGraphBuilder.js +106 -0
  34. package/lib/callgraph/pointerAnalysis/Context.d.ts +38 -0
  35. package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -0
  36. package/lib/callgraph/pointerAnalysis/Context.js +156 -0
  37. package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts +23 -0
  38. package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts.map +1 -0
  39. package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +104 -0
  40. package/lib/callgraph/pointerAnalysis/Pag.d.ts +209 -0
  41. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -0
  42. package/lib/callgraph/pointerAnalysis/Pag.js +774 -0
  43. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +88 -0
  44. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -0
  45. package/lib/callgraph/pointerAnalysis/PagBuilder.js +821 -0
  46. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +64 -0
  47. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -0
  48. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +502 -0
  49. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +9 -0
  50. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -0
  51. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +57 -0
  52. package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +58 -0
  53. package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -0
  54. package/lib/callgraph/pointerAnalysis/PtsDS.js +234 -0
  55. package/lib/core/base/Constant.d.ts +17 -0
  56. package/lib/core/base/Constant.d.ts.map +1 -0
  57. package/lib/core/base/Constant.js +53 -0
  58. package/lib/core/base/Decorator.d.ts +15 -0
  59. package/lib/core/base/Decorator.d.ts.map +1 -0
  60. package/lib/core/base/Decorator.js +43 -0
  61. package/lib/core/base/DefUseChain.d.ts +9 -0
  62. package/lib/core/base/DefUseChain.d.ts.map +1 -0
  63. package/lib/core/base/DefUseChain.js +25 -0
  64. package/lib/core/base/Expr.d.ts +219 -0
  65. package/lib/core/base/Expr.d.ts.map +1 -0
  66. package/lib/core/base/Expr.js +896 -0
  67. package/lib/core/base/Local.d.ts +40 -0
  68. package/lib/core/base/Local.d.ts.map +1 -0
  69. package/lib/core/base/Local.js +101 -0
  70. package/lib/core/base/Position.d.ts +39 -0
  71. package/lib/core/base/Position.d.ts.map +1 -0
  72. package/lib/core/base/Position.js +86 -0
  73. package/lib/core/base/Ref.d.ts +75 -0
  74. package/lib/core/base/Ref.d.ts.map +1 -0
  75. package/lib/core/base/Ref.js +286 -0
  76. package/lib/core/base/Stmt.d.ts +109 -0
  77. package/lib/core/base/Stmt.d.ts.map +1 -0
  78. package/lib/core/base/Stmt.js +374 -0
  79. package/lib/core/base/Type.d.ts +220 -0
  80. package/lib/core/base/Type.d.ts.map +1 -0
  81. package/lib/core/base/Type.js +477 -0
  82. package/lib/core/base/Value.d.ts +11 -0
  83. package/lib/core/base/Value.d.ts.map +1 -0
  84. package/lib/core/base/Value.js +16 -0
  85. package/lib/core/common/ArkIRTransformer.d.ts +101 -0
  86. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -0
  87. package/lib/core/common/ArkIRTransformer.js +1674 -0
  88. package/lib/core/common/BodyBuilder.d.ts +10 -0
  89. package/lib/core/common/BodyBuilder.d.ts.map +1 -0
  90. package/lib/core/common/BodyBuilder.js +34 -0
  91. package/lib/core/common/Builtin.d.ts +35 -0
  92. package/lib/core/common/Builtin.d.ts.map +1 -0
  93. package/lib/core/common/Builtin.js +78 -0
  94. package/lib/core/common/CfgBuilder.d.ts +136 -0
  95. package/lib/core/common/CfgBuilder.d.ts.map +1 -0
  96. package/lib/core/common/CfgBuilder.js +1241 -0
  97. package/lib/core/common/Const.d.ts +15 -0
  98. package/lib/core/common/Const.d.ts.map +1 -0
  99. package/lib/core/common/Const.js +34 -0
  100. package/lib/core/common/DummyMainCreater.d.ts +48 -0
  101. package/lib/core/common/DummyMainCreater.d.ts.map +1 -0
  102. package/lib/core/common/DummyMainCreater.js +433 -0
  103. package/lib/core/common/EtsConst.d.ts +65 -0
  104. package/lib/core/common/EtsConst.d.ts.map +1 -0
  105. package/lib/core/common/EtsConst.js +918 -0
  106. package/lib/core/common/ExprUseReplacer.d.ts +18 -0
  107. package/lib/core/common/ExprUseReplacer.d.ts.map +1 -0
  108. package/lib/core/common/ExprUseReplacer.js +88 -0
  109. package/lib/core/common/IRUtils.d.ts +7 -0
  110. package/lib/core/common/IRUtils.d.ts.map +1 -0
  111. package/lib/core/common/IRUtils.js +39 -0
  112. package/lib/core/common/ModelUtils.d.ts +61 -0
  113. package/lib/core/common/ModelUtils.d.ts.map +1 -0
  114. package/lib/core/common/ModelUtils.js +628 -0
  115. package/lib/core/common/RefUseReplacer.d.ts +14 -0
  116. package/lib/core/common/RefUseReplacer.d.ts.map +1 -0
  117. package/lib/core/common/RefUseReplacer.js +50 -0
  118. package/lib/core/common/StmtUseReplacer.d.ts +16 -0
  119. package/lib/core/common/StmtUseReplacer.d.ts.map +1 -0
  120. package/lib/core/common/StmtUseReplacer.js +88 -0
  121. package/lib/core/common/TSConst.d.ts +11 -0
  122. package/lib/core/common/TSConst.d.ts.map +1 -0
  123. package/lib/core/common/TSConst.js +28 -0
  124. package/lib/core/common/TypeInference.d.ts +44 -0
  125. package/lib/core/common/TypeInference.d.ts.map +1 -0
  126. package/lib/core/common/TypeInference.js +519 -0
  127. package/lib/core/common/ValueUtil.d.ts +17 -0
  128. package/lib/core/common/ValueUtil.d.ts.map +1 -0
  129. package/lib/core/common/ValueUtil.js +71 -0
  130. package/lib/core/common/VisibleValue.d.ts +37 -0
  131. package/lib/core/common/VisibleValue.d.ts.map +1 -0
  132. package/lib/core/common/VisibleValue.js +212 -0
  133. package/lib/core/dataflow/DataflowProblem.d.ts +21 -0
  134. package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -0
  135. package/lib/core/dataflow/DataflowProblem.js +33 -0
  136. package/lib/core/dataflow/DataflowResult.d.ts +8 -0
  137. package/lib/core/dataflow/DataflowResult.d.ts.map +1 -0
  138. package/lib/core/dataflow/DataflowResult.js +26 -0
  139. package/lib/core/dataflow/DataflowSolver.d.ts +40 -0
  140. package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -0
  141. package/lib/core/dataflow/DataflowSolver.js +318 -0
  142. package/lib/core/dataflow/Edge.d.ts +16 -0
  143. package/lib/core/dataflow/Edge.d.ts.map +1 -0
  144. package/lib/core/dataflow/Edge.js +40 -0
  145. package/lib/core/dataflow/Fact.d.ts +7 -0
  146. package/lib/core/dataflow/Fact.d.ts.map +1 -0
  147. package/lib/core/dataflow/Fact.js +24 -0
  148. package/lib/core/dataflow/TiantAnalysis.d.ts +37 -0
  149. package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -0
  150. package/lib/core/dataflow/TiantAnalysis.js +326 -0
  151. package/lib/core/dataflow/UndefinedVariable.d.ts +32 -0
  152. package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -0
  153. package/lib/core/dataflow/UndefinedVariable.js +235 -0
  154. package/lib/core/dataflow/Util.d.ts +8 -0
  155. package/lib/core/dataflow/Util.d.ts.map +1 -0
  156. package/lib/core/dataflow/Util.js +137 -0
  157. package/lib/core/graph/BasicBlock.d.ts +26 -0
  158. package/lib/core/graph/BasicBlock.d.ts.map +1 -0
  159. package/lib/core/graph/BasicBlock.js +92 -0
  160. package/lib/core/graph/Cfg.d.ts +29 -0
  161. package/lib/core/graph/Cfg.d.ts.map +1 -0
  162. package/lib/core/graph/Cfg.js +154 -0
  163. package/lib/core/graph/DominanceFinder.d.ts +16 -0
  164. package/lib/core/graph/DominanceFinder.d.ts.map +1 -0
  165. package/lib/core/graph/DominanceFinder.js +121 -0
  166. package/lib/core/graph/DominanceTree.d.ts +13 -0
  167. package/lib/core/graph/DominanceTree.d.ts.map +1 -0
  168. package/lib/core/graph/DominanceTree.js +70 -0
  169. package/lib/core/graph/ViewTree.d.ts +115 -0
  170. package/lib/core/graph/ViewTree.d.ts.map +1 -0
  171. package/lib/core/graph/ViewTree.js +16 -0
  172. package/lib/core/graph/builder/ViewTreeBuilder.d.ts +204 -0
  173. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -0
  174. package/lib/core/graph/builder/ViewTreeBuilder.js +1046 -0
  175. package/lib/core/model/ArkBody.d.ts +22 -0
  176. package/lib/core/model/ArkBody.d.ts.map +1 -0
  177. package/lib/core/model/ArkBody.js +63 -0
  178. package/lib/core/model/ArkClass.d.ts +110 -0
  179. package/lib/core/model/ArkClass.d.ts.map +1 -0
  180. package/lib/core/model/ArkClass.js +315 -0
  181. package/lib/core/model/ArkExport.d.ts +70 -0
  182. package/lib/core/model/ArkExport.d.ts.map +1 -0
  183. package/lib/core/model/ArkExport.js +143 -0
  184. package/lib/core/model/ArkField.d.ts +60 -0
  185. package/lib/core/model/ArkField.d.ts.map +1 -0
  186. package/lib/core/model/ArkField.js +157 -0
  187. package/lib/core/model/ArkFile.d.ts +62 -0
  188. package/lib/core/model/ArkFile.d.ts.map +1 -0
  189. package/lib/core/model/ArkFile.js +160 -0
  190. package/lib/core/model/ArkImport.d.ts +43 -0
  191. package/lib/core/model/ArkImport.d.ts.map +1 -0
  192. package/lib/core/model/ArkImport.js +109 -0
  193. package/lib/core/model/ArkMethod.d.ts +76 -0
  194. package/lib/core/model/ArkMethod.d.ts.map +1 -0
  195. package/lib/core/model/ArkMethod.js +235 -0
  196. package/lib/core/model/ArkNamespace.d.ts +65 -0
  197. package/lib/core/model/ArkNamespace.d.ts.map +1 -0
  198. package/lib/core/model/ArkNamespace.js +182 -0
  199. package/lib/core/model/ArkSignature.d.ts +98 -0
  200. package/lib/core/model/ArkSignature.d.ts.map +1 -0
  201. package/lib/core/model/ArkSignature.js +281 -0
  202. package/lib/core/model/builder/ArkClassBuilder.d.ts +13 -0
  203. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -0
  204. package/lib/core/model/builder/ArkClassBuilder.js +422 -0
  205. package/lib/core/model/builder/ArkExportBuilder.d.ts +25 -0
  206. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -0
  207. package/lib/core/model/builder/ArkExportBuilder.js +207 -0
  208. package/lib/core/model/builder/ArkFieldBuilder.d.ts +9 -0
  209. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -0
  210. package/lib/core/model/builder/ArkFieldBuilder.js +189 -0
  211. package/lib/core/model/builder/ArkFileBuilder.d.ts +10 -0
  212. package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -0
  213. package/lib/core/model/builder/ArkFileBuilder.js +164 -0
  214. package/lib/core/model/builder/ArkImportBuilder.d.ts +4 -0
  215. package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -0
  216. package/lib/core/model/builder/ArkImportBuilder.js +125 -0
  217. package/lib/core/model/builder/ArkMethodBuilder.d.ts +60 -0
  218. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -0
  219. package/lib/core/model/builder/ArkMethodBuilder.js +419 -0
  220. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +5 -0
  221. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
  222. package/lib/core/model/builder/ArkNamespaceBuilder.js +171 -0
  223. package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
  224. package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -0
  225. package/lib/core/model/builder/ArkSignatureBuilder.js +40 -0
  226. package/lib/core/model/builder/builderUtils.d.ts +18 -0
  227. package/lib/core/model/builder/builderUtils.d.ts.map +1 -0
  228. package/lib/core/model/builder/builderUtils.js +449 -0
  229. package/lib/index.d.ts +77 -0
  230. package/lib/index.d.ts.map +1 -0
  231. package/lib/index.js +190 -0
  232. package/lib/save/ArkStream.d.ts +24 -0
  233. package/lib/save/ArkStream.d.ts.map +1 -0
  234. package/lib/save/ArkStream.js +83 -0
  235. package/lib/save/DotPrinter.d.ts +48 -0
  236. package/lib/save/DotPrinter.d.ts.map +1 -0
  237. package/lib/save/DotPrinter.js +229 -0
  238. package/lib/save/GraphPrinter.d.ts +17 -0
  239. package/lib/save/GraphPrinter.d.ts.map +1 -0
  240. package/lib/save/GraphPrinter.js +135 -0
  241. package/lib/save/JsonPrinter.d.ts +28 -0
  242. package/lib/save/JsonPrinter.d.ts.map +1 -0
  243. package/lib/save/JsonPrinter.js +511 -0
  244. package/lib/save/Printer.d.ts +17 -0
  245. package/lib/save/Printer.d.ts.map +1 -0
  246. package/lib/save/Printer.js +27 -0
  247. package/lib/save/PrinterBuilder.d.ts +38 -0
  248. package/lib/save/PrinterBuilder.d.ts.map +1 -0
  249. package/lib/save/PrinterBuilder.js +102 -0
  250. package/lib/save/serializeArkIR.d.ts +3 -0
  251. package/lib/save/serializeArkIR.d.ts.map +1 -0
  252. package/lib/save/serializeArkIR.js +166 -0
  253. package/lib/save/source/SourceBase.d.ts +32 -0
  254. package/lib/save/source/SourceBase.d.ts.map +1 -0
  255. package/lib/save/source/SourceBase.js +93 -0
  256. package/lib/save/source/SourceBody.d.ts +60 -0
  257. package/lib/save/source/SourceBody.d.ts.map +1 -0
  258. package/lib/save/source/SourceBody.js +292 -0
  259. package/lib/save/source/SourceClass.d.ts +27 -0
  260. package/lib/save/source/SourceClass.d.ts.map +1 -0
  261. package/lib/save/source/SourceClass.js +202 -0
  262. package/lib/save/source/SourceField.d.ts +15 -0
  263. package/lib/save/source/SourceField.d.ts.map +1 -0
  264. package/lib/save/source/SourceField.js +68 -0
  265. package/lib/save/source/SourceFilePrinter.d.ts +14 -0
  266. package/lib/save/source/SourceFilePrinter.d.ts.map +1 -0
  267. package/lib/save/source/SourceFilePrinter.js +73 -0
  268. package/lib/save/source/SourceMethod.d.ts +24 -0
  269. package/lib/save/source/SourceMethod.d.ts.map +1 -0
  270. package/lib/save/source/SourceMethod.js +170 -0
  271. package/lib/save/source/SourceModule.d.ts +18 -0
  272. package/lib/save/source/SourceModule.d.ts.map +1 -0
  273. package/lib/save/source/SourceModule.js +120 -0
  274. package/lib/save/source/SourceNamespace.d.ts +13 -0
  275. package/lib/save/source/SourceNamespace.d.ts.map +1 -0
  276. package/lib/save/source/SourceNamespace.js +80 -0
  277. package/lib/save/source/SourceStmt.d.ts +172 -0
  278. package/lib/save/source/SourceStmt.d.ts.map +1 -0
  279. package/lib/save/source/SourceStmt.js +757 -0
  280. package/lib/save/source/SourceTransformer.d.ts +37 -0
  281. package/lib/save/source/SourceTransformer.d.ts.map +1 -0
  282. package/lib/save/source/SourceTransformer.js +338 -0
  283. package/lib/save/source/SourceUtils.d.ts +25 -0
  284. package/lib/save/source/SourceUtils.d.ts.map +1 -0
  285. package/lib/save/source/SourceUtils.js +201 -0
  286. package/lib/transformer/FunctionTransformer.d.ts +3 -0
  287. package/lib/transformer/FunctionTransformer.d.ts.map +1 -0
  288. package/lib/transformer/FunctionTransformer.js +17 -0
  289. package/lib/transformer/SceneTransformer.d.ts +3 -0
  290. package/lib/transformer/SceneTransformer.d.ts.map +1 -0
  291. package/lib/transformer/SceneTransformer.js +17 -0
  292. package/lib/transformer/StaticSingleAssignmentFormer.d.ts +13 -0
  293. package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -0
  294. package/lib/transformer/StaticSingleAssignmentFormer.js +259 -0
  295. package/lib/transformer/Transformer.d.ts +7 -0
  296. package/lib/transformer/Transformer.d.ts.map +1 -0
  297. package/lib/transformer/Transformer.js +22 -0
  298. package/lib/utils/CfgStructualAnalysis.d.ts +93 -0
  299. package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -0
  300. package/lib/utils/CfgStructualAnalysis.js +955 -0
  301. package/lib/utils/FileUtils.d.ts +18 -0
  302. package/lib/utils/FileUtils.d.ts.map +1 -0
  303. package/lib/utils/FileUtils.js +131 -0
  304. package/lib/utils/callGraphUtils.d.ts +31 -0
  305. package/lib/utils/callGraphUtils.d.ts.map +1 -0
  306. package/lib/utils/callGraphUtils.js +208 -0
  307. package/lib/utils/entryMethodUtils.d.ts +16 -0
  308. package/lib/utils/entryMethodUtils.d.ts.map +1 -0
  309. package/lib/utils/entryMethodUtils.js +139 -0
  310. package/lib/utils/getAllFiles.d.ts +10 -0
  311. package/lib/utils/getAllFiles.d.ts.map +1 -0
  312. package/lib/utils/getAllFiles.js +91 -0
  313. package/lib/utils/json5parser.d.ts +7 -0
  314. package/lib/utils/json5parser.d.ts.map +1 -0
  315. package/lib/utils/json5parser.js +146 -0
  316. package/lib/utils/logger.d.ts +19 -0
  317. package/lib/utils/logger.d.ts.map +1 -0
  318. package/lib/utils/logger.js +90 -0
  319. package/lib/utils/pathTransfer.d.ts +2 -0
  320. package/lib/utils/pathTransfer.d.ts.map +1 -0
  321. package/lib/utils/pathTransfer.js +25 -0
  322. package/package.json +29 -0
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SourceFilePrinter = void 0;
18
+ const Printer_1 = require("../Printer");
19
+ const SourceClass_1 = require("./SourceClass");
20
+ const SourceMethod_1 = require("./SourceMethod");
21
+ const SourceModule_1 = require("./SourceModule");
22
+ const SourceNamespace_1 = require("./SourceNamespace");
23
+ const SourceUtils_1 = require("./SourceUtils");
24
+ /**
25
+ * @category save
26
+ */
27
+ class SourceFilePrinter extends Printer_1.Printer {
28
+ constructor(arkFile) {
29
+ super();
30
+ this.items = [];
31
+ this.arkFile = arkFile;
32
+ }
33
+ dump() {
34
+ this.printer.clear();
35
+ // print imports
36
+ for (let info of this.arkFile.getImportInfos()) {
37
+ this.items.push(new SourceModule_1.SourceImportInfo(info));
38
+ }
39
+ // print namespace
40
+ for (let ns of this.arkFile.getNamespaces()) {
41
+ this.items.push(new SourceNamespace_1.SourceNamespace(ns));
42
+ }
43
+ // print class
44
+ for (let cls of this.arkFile.getClasses()) {
45
+ if (cls.isDefaultArkClass()) {
46
+ for (let method of cls.getMethods()) {
47
+ if (method.isDefaultArkMethod()) {
48
+ this.items.push(...new SourceMethod_1.SourceMethod(method, this.printer.getIndent()).dumpDefaultMethod());
49
+ }
50
+ else if (!SourceUtils_1.SourceUtils.isAnonymousMethod(method.getName())) {
51
+ this.items.push(new SourceMethod_1.SourceMethod(method));
52
+ }
53
+ }
54
+ }
55
+ else if (!SourceUtils_1.SourceUtils.isAnonymousClass(cls.getName())) {
56
+ this.items.push(new SourceClass_1.SourceClass(cls));
57
+ }
58
+ }
59
+ // print export
60
+ for (let info of this.arkFile.getExportInfos()) {
61
+ this.items.push(new SourceModule_1.SourceExportInfo(info));
62
+ }
63
+ this.items.sort((a, b) => a.getLine() - b.getLine());
64
+ this.items.forEach((v) => {
65
+ this.printer.write(v.dump());
66
+ });
67
+ return this.printer.toString();
68
+ }
69
+ dumpOriginal() {
70
+ return this.arkFile.getCode();
71
+ }
72
+ }
73
+ exports.SourceFilePrinter = SourceFilePrinter;
@@ -0,0 +1,24 @@
1
+ import { ArkMethod } from '../../core/model/ArkMethod';
2
+ import { SourceBase } from './SourceBase';
3
+ import { SourceStmt } from './SourceStmt';
4
+ import { ArkNamespace } from '../../core/model/ArkNamespace';
5
+ /**
6
+ * @category save
7
+ */
8
+ export declare class SourceMethod extends SourceBase {
9
+ private method;
10
+ private transformer;
11
+ constructor(method: ArkMethod, indent?: string);
12
+ getDeclaringArkNamespace(): ArkNamespace | undefined;
13
+ setInBuilder(inBuilder: boolean): void;
14
+ dump(): string;
15
+ dumpOriginal(): string;
16
+ getLine(): number;
17
+ dumpDefaultMethod(): SourceStmt[];
18
+ private printMethod;
19
+ private printBody;
20
+ protected methodProtoToString(method: ArkMethod): string;
21
+ toArrowFunctionTypeString(): string;
22
+ private initInBuilder;
23
+ }
24
+ //# sourceMappingURL=SourceMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceMethod.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceMethod.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D;;GAEG;AACH,qBAAa,YAAa,SAAQ,UAAU;IACxC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,WAAW,CAAoB;gBAEpB,MAAM,EAAE,SAAS,EAAE,MAAM,GAAE,MAAW;IAOlD,wBAAwB,IAAI,YAAY,GAAG,SAAS;IAIpD,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAItC,IAAI,IAAI,MAAM;IAUd,YAAY,IAAI,MAAM;IAItB,OAAO,IAAI,MAAM;IAoBjB,iBAAiB,IAAI,UAAU,EAAE;IAKxC,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,SAAS;IAKjB,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IA+CjD,yBAAyB,IAAI,MAAM;IAuB1C,OAAO,CAAC,aAAa;CAQxB"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SourceMethod = void 0;
18
+ const Type_1 = require("../../core/base/Type");
19
+ const ArkStream_1 = require("../ArkStream");
20
+ const SourceBase_1 = require("./SourceBase");
21
+ const SourceBody_1 = require("./SourceBody");
22
+ const SourceTransformer_1 = require("./SourceTransformer");
23
+ const SourceUtils_1 = require("./SourceUtils");
24
+ /**
25
+ * @category save
26
+ */
27
+ class SourceMethod extends SourceBase_1.SourceBase {
28
+ constructor(method, indent = '') {
29
+ super(method.getDeclaringArkFile(), indent);
30
+ this.method = method;
31
+ this.transformer = new SourceTransformer_1.SourceTransformer(this);
32
+ this.inBuilder = this.initInBuilder();
33
+ }
34
+ getDeclaringArkNamespace() {
35
+ return this.method.getDeclaringArkClass().getDeclaringArkNamespace();
36
+ }
37
+ setInBuilder(inBuilder) {
38
+ this.inBuilder = inBuilder;
39
+ }
40
+ dump() {
41
+ this.printer.clear();
42
+ if (!this.method.isDefaultArkMethod()) {
43
+ this.printMethod(this.method);
44
+ }
45
+ else {
46
+ this.printBody(this.method);
47
+ }
48
+ return this.printer.toString();
49
+ }
50
+ dumpOriginal() {
51
+ return this.method.getCode() + '\n';
52
+ }
53
+ getLine() {
54
+ let line = this.method.getLine();
55
+ if (line > 0) {
56
+ return line;
57
+ }
58
+ const stmts = [];
59
+ const cfg = this.method.getCfg();
60
+ if (cfg) {
61
+ stmts.push(...cfg.getStmts().reverse());
62
+ }
63
+ for (const stmt of stmts) {
64
+ if (stmt.getOriginPositionInfo().getLineNo() > 0) {
65
+ return stmt.getOriginPositionInfo().getLineNo();
66
+ }
67
+ }
68
+ return line;
69
+ }
70
+ dumpDefaultMethod() {
71
+ let srcBody = new SourceBody_1.SourceBody(this.printer.getIndent(), this.method, false);
72
+ return srcBody.getStmts();
73
+ }
74
+ printMethod(method) {
75
+ this.printDecorator(method.getModifiers());
76
+ this.printer.writeIndent().write(this.methodProtoToString(method));
77
+ // abstract function no body
78
+ if (!method.getBody()) {
79
+ this.printer.writeLine(';');
80
+ return;
81
+ }
82
+ this.printer.writeLine(' {');
83
+ this.printer.incIndent();
84
+ this.printBody(method);
85
+ this.printer.decIndent();
86
+ this.printer.writeIndent();
87
+ if (SourceUtils_1.SourceUtils.isAnonymousMethod(method.getName())) {
88
+ this.printer.write('}');
89
+ }
90
+ else {
91
+ this.printer.writeLine('}');
92
+ }
93
+ }
94
+ printBody(method) {
95
+ let srcBody = new SourceBody_1.SourceBody(this.printer.getIndent(), method, this.inBuilder);
96
+ this.printer.write(srcBody.dump());
97
+ }
98
+ methodProtoToString(method) {
99
+ var _a;
100
+ let code = new ArkStream_1.ArkCodeBuffer();
101
+ code.writeSpace(this.modifiersToString(method.getModifiers()));
102
+ if (!SourceUtils_1.SourceUtils.isAnonymousMethod(method.getName())) {
103
+ if ((_a = method.getDeclaringArkClass()) === null || _a === void 0 ? void 0 : _a.isDefaultArkClass()) {
104
+ code.writeSpace('function');
105
+ }
106
+ if (method.getAsteriskToken()) {
107
+ code.writeSpace('*');
108
+ }
109
+ code.write(this.resolveMethodName(method.getName()));
110
+ }
111
+ const genericTypes = method.getGenericTypes();
112
+ if (genericTypes && genericTypes.length > 0) {
113
+ let typeParameters = [];
114
+ genericTypes.forEach((genericType) => {
115
+ typeParameters.push(this.transformer.typeToString(genericType));
116
+ });
117
+ code.write(`<${this.transformer.typeArrayToString(genericTypes)}>`);
118
+ }
119
+ let parameters = [];
120
+ method.getParameters().forEach((parameter) => {
121
+ let str = parameter.getName();
122
+ if (parameter.hasDotDotDotToken()) {
123
+ str = `...${parameter.getName()}`;
124
+ }
125
+ if (parameter.isOptional()) {
126
+ str += '?';
127
+ }
128
+ if (parameter.getType()) {
129
+ str += ': ' + this.transformer.typeToString(parameter.getType());
130
+ }
131
+ parameters.push(str);
132
+ });
133
+ code.write(`(${parameters.join(', ')})`);
134
+ const returnType = method.getReturnType();
135
+ if (method.getName() !== 'constructor' && !(returnType instanceof Type_1.UnknownType)) {
136
+ code.write(`: ${this.transformer.typeToString(returnType)}`);
137
+ }
138
+ if (SourceUtils_1.SourceUtils.isAnonymousMethod(method.getName())) {
139
+ code.write(' =>');
140
+ }
141
+ return code.toString();
142
+ }
143
+ toArrowFunctionTypeString() {
144
+ let code = new ArkStream_1.ArkCodeBuffer();
145
+ let parameters = [];
146
+ this.method.getParameters().forEach((parameter) => {
147
+ let str = parameter.getName();
148
+ if (parameter.isOptional()) {
149
+ str += '?';
150
+ }
151
+ if (parameter.getType()) {
152
+ str += ': ' + this.transformer.typeToString(parameter.getType());
153
+ }
154
+ parameters.push(str);
155
+ });
156
+ code.write(`(${parameters.join(', ')}) => `);
157
+ const returnType = this.method.getReturnType();
158
+ if (!(returnType instanceof Type_1.UnknownType)) {
159
+ code.writeSpace(`${this.transformer.typeToString(returnType)}`);
160
+ }
161
+ return code.toString();
162
+ }
163
+ initInBuilder() {
164
+ return (this.method.hasBuilderDecorator() ||
165
+ ((this.method.getName() == 'build' || this.method.getName() == 'pageTransition') &&
166
+ !this.method.containsModifier('StaticKeyword') &&
167
+ this.method.getDeclaringArkClass().hasViewTree()));
168
+ }
169
+ }
170
+ exports.SourceMethod = SourceMethod;
@@ -0,0 +1,18 @@
1
+ import { ExportInfo } from '../../core/model/ArkExport';
2
+ import { ImportInfo } from '../../core/model/ArkImport';
3
+ import { SourceBase } from './SourceBase';
4
+ export declare class SourceExportInfo extends SourceBase {
5
+ info: ExportInfo;
6
+ constructor(info: ExportInfo, indent?: string);
7
+ getLine(): number;
8
+ dump(): string;
9
+ dumpOriginal(): string;
10
+ }
11
+ export declare class SourceImportInfo extends SourceBase {
12
+ info: ImportInfo;
13
+ constructor(info: ImportInfo, indent?: string);
14
+ getLine(): number;
15
+ dump(): string;
16
+ dumpOriginal(): string;
17
+ }
18
+ //# sourceMappingURL=SourceModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceModule.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceModule.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAc,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,gBAAiB,SAAQ,UAAU;IAC5C,IAAI,EAAE,UAAU,CAAC;gBAEE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,MAAW;IAKjD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;IA4Cd,YAAY,IAAI,MAAM;CAGhC;AAED,qBAAa,gBAAiB,SAAQ,UAAU;IAC5C,IAAI,EAAE,UAAU,CAAC;gBAEE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,MAAW;IAKjD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;IAuDd,YAAY,IAAI,MAAM;CAGhC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SourceImportInfo = exports.SourceExportInfo = void 0;
18
+ const ArkExport_1 = require("../../core/model/ArkExport");
19
+ const SourceBase_1 = require("./SourceBase");
20
+ class SourceExportInfo extends SourceBase_1.SourceBase {
21
+ constructor(info, indent = '') {
22
+ super(info.getDeclaringArkFile(), indent);
23
+ this.info = info;
24
+ }
25
+ getLine() {
26
+ return this.info.getOriginTsPosition().getLineNo();
27
+ }
28
+ dump() {
29
+ var _a;
30
+ this.printer.clear();
31
+ if (((_a = this.info.getArkExport()) === null || _a === void 0 ? void 0 : _a.getModifiers().has('ExportKeyword')) || this.info.getExportClauseType() == ArkExport_1.ExportType.LOCAL) {
32
+ return this.printer.toString();
33
+ }
34
+ if (this.info.getExportClauseName() === '*') {
35
+ // just like: export * as xx from './yy'
36
+ if (this.info.getNameBeforeAs() &&
37
+ this.info.getNameBeforeAs() != '*') {
38
+ this.printer
39
+ .writeIndent()
40
+ .write(`export ${this.info.getNameBeforeAs()} as ${this.info.getExportClauseName()}`);
41
+ }
42
+ else {
43
+ this.printer
44
+ .writeIndent()
45
+ .write(`export ${this.info.getExportClauseName()}`);
46
+ }
47
+ }
48
+ else {
49
+ // just like: export {xxx as x} from './yy'
50
+ if (this.info.getNameBeforeAs()) {
51
+ this.printer.write(`export {${this.info.getNameBeforeAs()} as ${this.info.getExportClauseName()}}`);
52
+ }
53
+ else {
54
+ this.printer.write(`export {${this.info.getExportClauseName()}}`);
55
+ }
56
+ }
57
+ if (this.info.getFrom()) {
58
+ this.printer.write(` from '${this.info.getFrom()}'`);
59
+ }
60
+ this.printer.writeLine(';');
61
+ return this.printer.toString();
62
+ }
63
+ dumpOriginal() {
64
+ return this.info.getTsSourceCode();
65
+ }
66
+ }
67
+ exports.SourceExportInfo = SourceExportInfo;
68
+ class SourceImportInfo extends SourceBase_1.SourceBase {
69
+ constructor(info, indent = '') {
70
+ super(info.getDeclaringArkFile(), indent);
71
+ this.info = info;
72
+ }
73
+ getLine() {
74
+ return this.info.getOriginTsPosition().getLineNo();
75
+ }
76
+ dump() {
77
+ if (this.info.getImportType() === 'Identifier') {
78
+ // sample: import fs from 'fs'
79
+ this.printer
80
+ .writeIndent()
81
+ .writeLine(`import ${this.info.getImportClauseName()} from '${this.info.getFrom()}';`);
82
+ }
83
+ else if (this.info.getImportType() === 'NamedImports') {
84
+ // sample: import {xxx} from './yyy'
85
+ if (this.info.getNameBeforeAs()) {
86
+ this.printer
87
+ .writeIndent()
88
+ .writeLine(`import {${this.info.getNameBeforeAs()} as ${this.info.getImportClauseName()}} from '${this.info.getFrom()}';`);
89
+ }
90
+ else {
91
+ this.printer
92
+ .writeIndent()
93
+ .writeLine(`import {${this.info.getImportClauseName()}} from '${this.info.getFrom()}';`);
94
+ }
95
+ }
96
+ else if (this.info.getImportType() === 'NamespaceImport') {
97
+ // sample: import * as ts from 'ohos-typescript'
98
+ this.printer
99
+ .writeIndent()
100
+ .writeLine(`import * as ${this.info.getImportClauseName()} from '${this.info.getFrom()}';`);
101
+ }
102
+ else if (this.info.getImportType() == 'EqualsImport') {
103
+ // sample: import mmmm = require('./xxx')
104
+ this.printer
105
+ .writeIndent()
106
+ .writeLine(`import ${this.info.getImportClauseName()} = require('${this.info.getFrom()}');`);
107
+ }
108
+ else {
109
+ // sample: import '../xxx'
110
+ this.printer
111
+ .writeIndent()
112
+ .writeLine(`import '${this.info.getFrom()}';`);
113
+ }
114
+ return this.printer.toString();
115
+ }
116
+ dumpOriginal() {
117
+ return this.info.getTsSourceCode();
118
+ }
119
+ }
120
+ exports.SourceImportInfo = SourceImportInfo;
@@ -0,0 +1,13 @@
1
+ import { ArkNamespace } from '../../core/model/ArkNamespace';
2
+ import { SourceBase } from './SourceBase';
3
+ /**
4
+ * @category save
5
+ */
6
+ export declare class SourceNamespace extends SourceBase {
7
+ ns: ArkNamespace;
8
+ constructor(ns: ArkNamespace, indent?: string);
9
+ getLine(): number;
10
+ dump(): string;
11
+ dumpOriginal(): string;
12
+ }
13
+ //# sourceMappingURL=SourceNamespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceNamespace.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceNamespace.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAQ,UAAU,EAAE,MAAM,cAAc,CAAC;AAMhD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC3C,EAAE,EAAE,YAAY,CAAC;gBAEE,EAAE,EAAE,YAAY,EAAE,MAAM,GAAE,MAAW;IAKjD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;IA2Dd,YAAY,IAAI,MAAM;CAGhC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SourceNamespace = void 0;
18
+ const SourceBase_1 = require("./SourceBase");
19
+ const SourceClass_1 = require("./SourceClass");
20
+ const SourceMethod_1 = require("./SourceMethod");
21
+ const SourceModule_1 = require("./SourceModule");
22
+ const SourceUtils_1 = require("./SourceUtils");
23
+ /**
24
+ * @category save
25
+ */
26
+ class SourceNamespace extends SourceBase_1.SourceBase {
27
+ constructor(ns, indent = '') {
28
+ super(ns.getDeclaringArkFile(), indent);
29
+ this.ns = ns;
30
+ }
31
+ getLine() {
32
+ return this.ns.getLine();
33
+ }
34
+ dump() {
35
+ this.printer
36
+ .writeIndent()
37
+ .writeSpace(this.modifiersToString(this.ns.getModifiers()))
38
+ .writeLine(`namespace ${this.ns.getName()} {`);
39
+ this.printer.incIndent();
40
+ let items = [];
41
+ // print class
42
+ for (let cls of this.ns.getClasses()) {
43
+ if (SourceUtils_1.SourceUtils.isAnonymousClass(cls.getName())) {
44
+ continue;
45
+ }
46
+ if (cls.isDefaultArkClass()) {
47
+ for (let method of cls.getMethods()) {
48
+ if (method.isDefaultArkMethod()) {
49
+ items.push(...new SourceMethod_1.SourceMethod(method, this.printer.getIndent()).dumpDefaultMethod());
50
+ }
51
+ else if (!SourceUtils_1.SourceUtils.isAnonymousMethod(method.getName())) {
52
+ items.push(new SourceMethod_1.SourceMethod(method, this.printer.getIndent()));
53
+ }
54
+ }
55
+ }
56
+ else {
57
+ items.push(new SourceClass_1.SourceClass(cls, this.printer.getIndent()));
58
+ }
59
+ }
60
+ // print namespace
61
+ for (let childNs of this.ns.getNamespaces()) {
62
+ items.push(new SourceNamespace(childNs, this.printer.getIndent()));
63
+ }
64
+ // print exportInfos
65
+ for (let exportInfo of this.ns.getExportInfos()) {
66
+ items.push(new SourceModule_1.SourceExportInfo(exportInfo, this.printer.getIndent()));
67
+ }
68
+ items.sort((a, b) => a.getLine() - b.getLine());
69
+ items.forEach((v) => {
70
+ this.printer.write(v.dump());
71
+ });
72
+ this.printer.decIndent();
73
+ this.printer.writeIndent().writeLine('}');
74
+ return this.printer.toString();
75
+ }
76
+ dumpOriginal() {
77
+ return this.ns.getCode();
78
+ }
79
+ }
80
+ exports.SourceNamespace = SourceNamespace;
@@ -0,0 +1,172 @@
1
+ import { ArkNewArrayExpr } from '../../core/base/Expr';
2
+ import { Local } from '../../core/base/Local';
3
+ import { ArkAssignStmt, ArkIfStmt, ArkInvokeStmt, ArkReturnStmt, ArkReturnVoidStmt, ArkSwitchStmt, ArkThrowStmt, Stmt } from '../../core/base/Stmt';
4
+ import { AliasType } from '../../core/base/Type';
5
+ import { Value } from '../../core/base/Value';
6
+ import { BasicBlock } from '../../core/graph/BasicBlock';
7
+ import { ArkCodeBuffer } from '../ArkStream';
8
+ import { Dump } from './SourceBase';
9
+ import { StmtReader } from './SourceBody';
10
+ import { SourceTransformer, TransformerContext } from './SourceTransformer';
11
+ export interface StmtPrinterContext extends TransformerContext {
12
+ getStmtReader(): StmtReader;
13
+ setTempCode(temp: string, code: string): void;
14
+ hasTempVisit(temp: string): boolean;
15
+ setTempVisit(temp: string): void;
16
+ setSkipStmt(stmt: Stmt): void;
17
+ getLocals(): Map<string, Local>;
18
+ defineLocal(local: Local): void;
19
+ isLocalDefined(local: Local): boolean;
20
+ isInDefaultMethod(): boolean;
21
+ }
22
+ export declare abstract class SourceStmt implements Dump {
23
+ original: Stmt;
24
+ context: StmtPrinterContext;
25
+ line: number;
26
+ text: string;
27
+ transformer: SourceTransformer;
28
+ constructor(context: StmtPrinterContext, original: Stmt);
29
+ getLine(): number;
30
+ setLine(line: number): void;
31
+ dump(): string;
32
+ protected beforeDump(): void;
33
+ protected afterDump(): void;
34
+ protected dumpTs(): string;
35
+ protected get printer(): ArkCodeBuffer;
36
+ toString(): string;
37
+ protected setText(text: string): void;
38
+ protected getIntent(): string;
39
+ abstract transfer2ts(): void;
40
+ protected isLocalTempValue(value: Value): boolean;
41
+ }
42
+ export declare class SourceAssignStmt extends SourceStmt {
43
+ private leftOp;
44
+ private rightOp;
45
+ private leftCode;
46
+ private rightCode;
47
+ private dumpType?;
48
+ private leftTypeCode;
49
+ constructor(context: StmtPrinterContext, original: ArkAssignStmt);
50
+ transfer2ts(): void;
51
+ protected beforeDump(): void;
52
+ protected afterDump(): void;
53
+ private getClassOriginType;
54
+ /**
55
+ * temp1 = new Person
56
+ * temp1.constructor(10)
57
+ */
58
+ private transferRightNewExpr;
59
+ /**
60
+ * $temp0 = newarray[4]
61
+ * $temp0[0] = 1
62
+ * $temp0[1] = 2
63
+ * $temp0[2] = 3
64
+ */
65
+ private transferRightNewArrayExpr;
66
+ private transferRightComponentCreate;
67
+ private transferRightComponentAttribute;
68
+ }
69
+ export declare class SourceInvokeStmt extends SourceStmt {
70
+ constructor(context: StmtPrinterContext, original: ArkInvokeStmt);
71
+ transfer2ts(): void;
72
+ protected beforeDump(): void;
73
+ protected afterDump(): void;
74
+ }
75
+ export declare class SourceIfStmt extends SourceStmt {
76
+ constructor(context: StmtPrinterContext, original: ArkIfStmt);
77
+ transfer2ts(): void;
78
+ protected afterDump(): void;
79
+ }
80
+ export declare class SourceWhileStmt extends SourceStmt {
81
+ block: BasicBlock;
82
+ constructor(context: StmtPrinterContext, original: ArkIfStmt, block: BasicBlock);
83
+ protected afterDump(): void;
84
+ /**
85
+ * $temp2 = $temp1.next()
86
+ * $temp3 = $temp2.done()
87
+ * if $temp3 == true
88
+ * $temp4 = $temp2.value
89
+ * $temp5 = <> cast
90
+ * @returns
91
+ */
92
+ private forOf2ts;
93
+ transfer2ts(): void;
94
+ protected valueToString(value: Value): string;
95
+ }
96
+ export declare class SourceForStmt extends SourceWhileStmt {
97
+ incBlock: BasicBlock;
98
+ constructor(context: StmtPrinterContext, original: ArkIfStmt, block: BasicBlock, incBlock: BasicBlock);
99
+ transfer2ts(): void;
100
+ }
101
+ export declare class SourceDoStmt extends SourceStmt {
102
+ constructor(context: StmtPrinterContext, stmt: Stmt);
103
+ transfer2ts(): void;
104
+ protected afterDump(): void;
105
+ }
106
+ export declare class SourceDoWhileStmt extends SourceWhileStmt {
107
+ constructor(context: StmtPrinterContext, stmt: ArkIfStmt, block: BasicBlock);
108
+ transfer2ts(): void;
109
+ protected beforeDump(): void;
110
+ protected afterDump(): void;
111
+ }
112
+ export declare class SourceElseStmt extends SourceStmt {
113
+ constructor(context: StmtPrinterContext, original: Stmt);
114
+ transfer2ts(): void;
115
+ protected beforeDump(): void;
116
+ protected afterDump(): void;
117
+ }
118
+ export declare class SourceContinueStmt extends SourceStmt {
119
+ constructor(context: StmtPrinterContext, original: Stmt);
120
+ transfer2ts(): void;
121
+ }
122
+ export declare class SourceBreakStmt extends SourceStmt {
123
+ constructor(context: StmtPrinterContext, original: Stmt);
124
+ transfer2ts(): void;
125
+ }
126
+ export declare class SourceReturnStmt extends SourceStmt {
127
+ constructor(context: StmtPrinterContext, original: ArkReturnStmt);
128
+ transfer2ts(): void;
129
+ }
130
+ export declare class SourceReturnVoidStmt extends SourceStmt {
131
+ constructor(context: StmtPrinterContext, original: ArkReturnVoidStmt);
132
+ transfer2ts(): void;
133
+ }
134
+ export declare class SourceSwitchStmt extends SourceStmt {
135
+ constructor(context: StmtPrinterContext, original: ArkSwitchStmt);
136
+ transfer2ts(): void;
137
+ protected afterDump(): void;
138
+ }
139
+ export declare class SourceCaseStmt extends SourceStmt {
140
+ caseIndex: number;
141
+ constructor(context: StmtPrinterContext, original: ArkSwitchStmt, index: number);
142
+ isDefault(): boolean;
143
+ transfer2ts(): void;
144
+ protected afterDump(): void;
145
+ }
146
+ export declare class SourceCompoundEndStmt extends SourceStmt {
147
+ constructor(context: StmtPrinterContext, stmt: Stmt, text: string);
148
+ transfer2ts(): void;
149
+ protected beforeDump(): void;
150
+ }
151
+ export declare class SourceCommonStmt extends SourceStmt {
152
+ constructor(context: StmtPrinterContext, stmt: Stmt);
153
+ transfer2ts(): void;
154
+ }
155
+ export declare class SourceThrowStmt extends SourceStmt {
156
+ constructor(context: StmtPrinterContext, original: ArkThrowStmt);
157
+ transfer2ts(): void;
158
+ }
159
+ export declare class SourceTypeAliasStmt extends SourceStmt {
160
+ aliasType: AliasType;
161
+ constructor(context: StmtPrinterContext, original: Stmt, aliasType: AliasType);
162
+ transfer2ts(): void;
163
+ }
164
+ export declare class SourceNewArrayExpr {
165
+ expr: ArkNewArrayExpr;
166
+ values: string[];
167
+ constructor(expr: ArkNewArrayExpr);
168
+ addInitValue(value: string): void;
169
+ toString(): string;
170
+ }
171
+ export declare function stmt2SourceStmt(context: StmtPrinterContext, stmt: Stmt): SourceStmt;
172
+ //# sourceMappingURL=SourceStmt.d.ts.map