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,27 @@
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.Printer = void 0;
18
+ const ArkStream_1 = require("./ArkStream");
19
+ /**
20
+ * @category save
21
+ */
22
+ class Printer {
23
+ constructor(indent = '') {
24
+ this.printer = new ArkStream_1.ArkCodeBuffer(indent);
25
+ }
26
+ }
27
+ exports.Printer = Printer;
@@ -0,0 +1,38 @@
1
+ import { ArkFile } from '../core/model/ArkFile';
2
+ import { Printer } from './Printer';
3
+ /**
4
+ * @example
5
+ * // dump method IR to ts source
6
+ * let method: Method = xx;
7
+ * let srcPrinter = new SourceMethodPrinter(method);
8
+ * PrinterBuilder.dump(srcPrinter, 'output.ts');
9
+ *
10
+ * // dump method original ts source
11
+ * PrinterBuilder.dumpOriginal(srcPrinter, 'output.ts');
12
+ *
13
+ * // dump method cfg to dot
14
+ * let dotPrinter = new DotMethodPrinter(method);
15
+ * PrinterBuilder.dump(dotPrinter, 'output.dot');
16
+ *
17
+ * // dump method original dot
18
+ * PrinterBuilder.dumpOriginal(dotPrinter, 'output.dot');
19
+ *
20
+ * // dump project
21
+ * let printer = new PrinterBuilder('output');
22
+ * for (let f of scene.getFiles()) {
23
+ * printer.dumpToTs(f);
24
+ * }
25
+ *
26
+ * @category save
27
+ */
28
+ export declare class PrinterBuilder {
29
+ outputDir: string;
30
+ constructor(outputDir?: string);
31
+ static dump(source: Printer, output: string): void;
32
+ static dumpOriginal(source: Printer, output: string): void;
33
+ protected getOutputDir(arkFile: ArkFile): string;
34
+ dumpToDot(arkFile: ArkFile, output?: string | undefined): void;
35
+ dumpToTs(arkFile: ArkFile, output?: string | undefined): void;
36
+ dumpToJson(arkFile: ArkFile, output?: string | undefined): void;
37
+ }
38
+ //# sourceMappingURL=PrinterBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrinterBuilder.d.ts","sourceRoot":"","sources":["../../src/save/PrinterBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,cAAc;IACvB,SAAS,EAAE,MAAM,CAAC;gBACN,SAAS,GAAE,MAAW;WAIpB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;WAMpC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;IAM1D,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAQzC,SAAS,CACZ,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,MAAM,GAAG,SAAqB,GACvC,IAAI;IAcA,QAAQ,CACX,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,MAAM,GAAG,SAAqB,GACvC,IAAI;IAWA,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,MAAM,GAAG,SAAqB,GAAG,IAAI;CASpF"}
@@ -0,0 +1,102 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.PrinterBuilder = void 0;
21
+ const fs_1 = __importDefault(require("fs"));
22
+ const path_1 = require("path");
23
+ const ArkStream_1 = require("./ArkStream");
24
+ const DotPrinter_1 = require("./DotPrinter");
25
+ const SourceFilePrinter_1 = require("./source/SourceFilePrinter");
26
+ const JsonPrinter_1 = require("./JsonPrinter");
27
+ /**
28
+ * @example
29
+ * // dump method IR to ts source
30
+ * let method: Method = xx;
31
+ * let srcPrinter = new SourceMethodPrinter(method);
32
+ * PrinterBuilder.dump(srcPrinter, 'output.ts');
33
+ *
34
+ * // dump method original ts source
35
+ * PrinterBuilder.dumpOriginal(srcPrinter, 'output.ts');
36
+ *
37
+ * // dump method cfg to dot
38
+ * let dotPrinter = new DotMethodPrinter(method);
39
+ * PrinterBuilder.dump(dotPrinter, 'output.dot');
40
+ *
41
+ * // dump method original dot
42
+ * PrinterBuilder.dumpOriginal(dotPrinter, 'output.dot');
43
+ *
44
+ * // dump project
45
+ * let printer = new PrinterBuilder('output');
46
+ * for (let f of scene.getFiles()) {
47
+ * printer.dumpToTs(f);
48
+ * }
49
+ *
50
+ * @category save
51
+ */
52
+ class PrinterBuilder {
53
+ constructor(outputDir = '') {
54
+ this.outputDir = outputDir;
55
+ }
56
+ static dump(source, output) {
57
+ let streamOut = new ArkStream_1.ArkStream(fs_1.default.createWriteStream(output));
58
+ streamOut.write(source.dump());
59
+ streamOut.close();
60
+ }
61
+ static dumpOriginal(source, output) {
62
+ let streamOut = new ArkStream_1.ArkStream(fs_1.default.createWriteStream(output));
63
+ streamOut.write(source.dumpOriginal());
64
+ streamOut.close();
65
+ }
66
+ getOutputDir(arkFile) {
67
+ if (this.outputDir === '') {
68
+ return (0, path_1.join)(arkFile.getProjectDir(), '..', 'output');
69
+ }
70
+ else {
71
+ return (0, path_1.join)(this.outputDir);
72
+ }
73
+ }
74
+ dumpToDot(arkFile, output = undefined) {
75
+ let filename = output;
76
+ if (output === undefined) {
77
+ filename = (0, path_1.join)(this.getOutputDir(arkFile), arkFile.getName() + '.dot');
78
+ }
79
+ fs_1.default.mkdirSync((0, path_1.dirname)(filename), { recursive: true });
80
+ let printer = new DotPrinter_1.DotFilePrinter(arkFile);
81
+ PrinterBuilder.dump(printer, filename);
82
+ }
83
+ dumpToTs(arkFile, output = undefined) {
84
+ let filename = output;
85
+ if (filename === undefined) {
86
+ filename = (0, path_1.join)(this.getOutputDir(arkFile), arkFile.getName());
87
+ }
88
+ fs_1.default.mkdirSync((0, path_1.dirname)(filename), { recursive: true });
89
+ let printer = new SourceFilePrinter_1.SourceFilePrinter(arkFile);
90
+ PrinterBuilder.dump(printer, filename);
91
+ }
92
+ dumpToJson(arkFile, output = undefined) {
93
+ let filename = output;
94
+ if (filename === undefined) {
95
+ filename = (0, path_1.join)(this.getOutputDir(arkFile), arkFile.getName() + '.json');
96
+ }
97
+ fs_1.default.mkdirSync((0, path_1.dirname)(filename), { recursive: true });
98
+ let printer = new JsonPrinter_1.JsonPrinter(arkFile);
99
+ PrinterBuilder.dump(printer, filename);
100
+ }
101
+ }
102
+ exports.PrinterBuilder = PrinterBuilder;
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const program: Command;
3
+ //# sourceMappingURL=serializeArkIR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializeArkIR.d.ts","sourceRoot":"","sources":["../../src/save/serializeArkIR.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiHpC,eAAO,MAAM,OAAO,SAmCd,CAAC"}
@@ -0,0 +1,166 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.program = void 0;
21
+ const path_1 = __importDefault(require("path"));
22
+ const fs_1 = __importDefault(require("fs"));
23
+ const commander_1 = require("commander");
24
+ const PrinterBuilder_1 = require("./PrinterBuilder");
25
+ const Config_1 = require("../Config");
26
+ const Scene_1 = require("../Scene");
27
+ function serializeTsFile(input, output, verbose = false) {
28
+ if (verbose)
29
+ console.log(`Serializing TS file to JSON: '${input}' -> '${output}'`);
30
+ let filepath = path_1.default.resolve(input);
31
+ let projectDir = path_1.default.dirname(filepath);
32
+ if (verbose)
33
+ console.log("Building scene...");
34
+ let config = new Config_1.SceneConfig();
35
+ config.buildConfig("single-file", projectDir, []);
36
+ config.getProjectFiles().push(filepath);
37
+ let scene = new Scene_1.Scene();
38
+ scene.buildSceneFromProjectDir(config);
39
+ let files = scene.getFiles();
40
+ if (verbose) {
41
+ console.log(`Scene contains ${files.length} files:`);
42
+ for (let f of files) {
43
+ console.log(`- '${f.getName()}'`);
44
+ }
45
+ }
46
+ if (verbose)
47
+ console.log("Extracting single ArkFile...");
48
+ if (files.length === 0) {
49
+ console.error(`ERROR: No files found in the project directory '${projectDir}'.`);
50
+ process.exit(1);
51
+ }
52
+ if (files.length > 1) {
53
+ console.error(`ERROR: More than one file found in the project directory '${projectDir}'.`);
54
+ process.exit(1);
55
+ }
56
+ // Note: we explicitly push a single path to the project files (in config),
57
+ // so we expect there is only *one* ArkFile in the scene.
58
+ let arkFile = scene.getFiles()[0];
59
+ let outPath;
60
+ if (fs_1.default.existsSync(output) && fs_1.default.statSync(output).isDirectory()) {
61
+ outPath = path_1.default.join(output, arkFile.getName() + '.json');
62
+ }
63
+ else if (!fs_1.default.existsSync(output) && output.endsWith("/")) {
64
+ outPath = path_1.default.join(output, arkFile.getName() + '.json');
65
+ }
66
+ else {
67
+ outPath = output;
68
+ }
69
+ console.log(`Serializing ArkIR for '${arkFile.getName()}' to '${outPath}'...`);
70
+ let printer = new PrinterBuilder_1.PrinterBuilder();
71
+ printer.dumpToJson(arkFile, outPath);
72
+ if (verbose)
73
+ console.log("All done!");
74
+ }
75
+ function serializeMultipleTsFiles(inputDir, outDir, verbose = false) {
76
+ console.log(`Serializing multiple TS files to JSON: '${inputDir}' -> '${outDir}'`);
77
+ if (fs_1.default.existsSync(outDir) && !fs_1.default.statSync(outDir).isDirectory()) {
78
+ console.error(`ERROR: Output path must be a directory.`);
79
+ process.exit(1);
80
+ }
81
+ if (verbose)
82
+ console.log("Building scene...");
83
+ let config = new Config_1.SceneConfig();
84
+ config.buildFromProjectDir(inputDir);
85
+ let scene = new Scene_1.Scene();
86
+ scene.buildSceneFromProjectDir(config);
87
+ let files = scene.getFiles();
88
+ if (verbose) {
89
+ console.log(`Scene contains ${files.length} files:`);
90
+ for (let f of files) {
91
+ console.log(`- '${f.getName()}'`);
92
+ }
93
+ }
94
+ if (verbose)
95
+ console.log("Serializing...");
96
+ let printer = new PrinterBuilder_1.PrinterBuilder();
97
+ for (let f of files) {
98
+ let filepath = f.getName();
99
+ let outPath = path_1.default.join(outDir, filepath + '.json');
100
+ console.log(`Serializing ArkIR for '${filepath}' to '${outPath}'...`);
101
+ printer.dumpToJson(f, outPath);
102
+ }
103
+ if (verbose)
104
+ console.log("All done!");
105
+ }
106
+ function serializeTsProject(inputDir, outDir, verbose = false) {
107
+ console.log(`Serializing TS project to JSON: '${inputDir}' -> '${outDir}'`);
108
+ if (fs_1.default.existsSync(outDir) && !fs_1.default.statSync(outDir).isDirectory()) {
109
+ console.error(`ERROR: Output path must be a directory.`);
110
+ process.exit(1);
111
+ }
112
+ if (verbose)
113
+ console.log("Building scene...");
114
+ let config = new Config_1.SceneConfig();
115
+ config.buildFromProjectDir(inputDir);
116
+ let scene = new Scene_1.Scene();
117
+ scene.buildSceneFromProjectDir(config);
118
+ if (verbose)
119
+ console.log("Serializing...");
120
+ let printer = new PrinterBuilder_1.PrinterBuilder();
121
+ for (let f of scene.getFiles()) {
122
+ let filepath = f.getName();
123
+ let outPath = path_1.default.join(outDir, filepath + '.json');
124
+ console.log(`Serializing ArkIR for '${filepath}' to '${outPath}'...`);
125
+ printer.dumpToJson(f, outPath);
126
+ }
127
+ if (verbose)
128
+ console.log("All done!");
129
+ }
130
+ exports.program = new commander_1.Command()
131
+ .name('serializeArkIR')
132
+ .description('Serialize ArkIR for TypeScript files or projects to JSON')
133
+ .argument('<input>', 'Input file or directory')
134
+ .argument('<output>', 'Output file or directory')
135
+ .option('-m, --multi', 'Flag to indicate the input is a directory', false)
136
+ .option('-p, --project', 'Flag to indicate the input is a project directory', false)
137
+ .option('-v, --verbose', 'Verbose output', false)
138
+ .action((input, output, options) => {
139
+ // Check for invalid combinations of flags
140
+ if (options.multi && options.project) {
141
+ console.error(`ERROR: You cannot provide both the '-m' and '-p' flags.`);
142
+ process.exit(1);
143
+ }
144
+ // Ensure the input path exists
145
+ if (!fs_1.default.existsSync(input)) {
146
+ console.error(`ERROR: The input path '${input}' does not exist.`);
147
+ process.exit(1);
148
+ }
149
+ // Handle the case where the input is a directory
150
+ if (fs_1.default.statSync(input).isDirectory() && !(options.multi || options.project)) {
151
+ console.error(`ERROR: If the input is a directory, you must provide the '-p' or '-m' flag.`);
152
+ process.exit(1);
153
+ }
154
+ if (options.project) {
155
+ serializeTsProject(input, output, options.verbose);
156
+ }
157
+ else if (options.multi) {
158
+ serializeMultipleTsFiles(input, output, options.verbose);
159
+ }
160
+ else {
161
+ serializeTsFile(input, output, options.verbose);
162
+ }
163
+ });
164
+ if (require.main === module) {
165
+ exports.program.parse(process.argv);
166
+ }
@@ -0,0 +1,32 @@
1
+ import { Decorator } from '../../core/base/Decorator';
2
+ import { Printer } from '../Printer';
3
+ import { ArkFile } from '../../core/model/ArkFile';
4
+ import { ArkMethod } from '../../core/model/ArkMethod';
5
+ import { ClassSignature, MethodSignature } from '../../core/model/ArkSignature';
6
+ import { ArkClass } from '../../core/model/ArkClass';
7
+ import { ArkCodeBuffer } from '../ArkStream';
8
+ import { Local } from '../../core/base/Local';
9
+ import { TransformerContext } from './SourceTransformer';
10
+ import { ArkNamespace } from '../../core/model/ArkNamespace';
11
+ export interface Dump {
12
+ getLine(): number;
13
+ dump(): string;
14
+ }
15
+ export declare abstract class SourceBase extends Printer implements Dump, TransformerContext {
16
+ protected arkFile: ArkFile;
17
+ protected inBuilder: boolean;
18
+ constructor(arkFile: ArkFile, indent?: string);
19
+ getDeclaringArkNamespace(): ArkNamespace | undefined;
20
+ getArkFile(): ArkFile;
21
+ getMethod(signature: MethodSignature): ArkMethod | null;
22
+ getClass(signature: ClassSignature): ArkClass | null;
23
+ getPrinter(): ArkCodeBuffer;
24
+ transTemp2Code(temp: Local): string;
25
+ isInBuilderMethod(): boolean;
26
+ abstract getLine(): number;
27
+ protected printDecorator(modifiers: Set<string | Decorator>): void;
28
+ protected modifiersToString(modifiers: Set<string | Decorator>): string;
29
+ protected resolveKeywordType(keywordStr: string): string;
30
+ protected resolveMethodName(name: string): string;
31
+ }
32
+ //# sourceMappingURL=SourceBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceBase.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceBase.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,WAAW,IAAI;IACjB,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,IAAI,MAAM,CAAC;CAClB;AAED,8BAAsB,UAClB,SAAQ,OACR,YAAW,IAAI,EAAE,kBAAkB;IAEnC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,SAAS,EAAE,OAAO,CAAS;gBAElB,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW;IAKjD,wBAAwB,IAAI,YAAY,GAAG,SAAS;IAIpD,UAAU,IAAI,OAAO;IAIrB,SAAS,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI;IAIvD,QAAQ,CAAC,SAAS,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI;IAIpD,UAAU,IAAI,aAAa;IAI3B,cAAc,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM;IAInC,iBAAiB,IAAI,OAAO;aAInB,OAAO,IAAI,MAAM;IAEjC,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,IAAI;IAQlE,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM;IAWvE,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAmBxD,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAYpD"}
@@ -0,0 +1,93 @@
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.SourceBase = void 0;
18
+ const Decorator_1 = require("../../core/base/Decorator");
19
+ const Printer_1 = require("../Printer");
20
+ class SourceBase extends Printer_1.Printer {
21
+ constructor(arkFile, indent = '') {
22
+ super(indent);
23
+ this.inBuilder = false;
24
+ this.arkFile = arkFile;
25
+ }
26
+ getDeclaringArkNamespace() {
27
+ return undefined;
28
+ }
29
+ getArkFile() {
30
+ return this.arkFile;
31
+ }
32
+ getMethod(signature) {
33
+ return this.getArkFile().getScene().getMethod(signature);
34
+ }
35
+ getClass(signature) {
36
+ return this.getArkFile().getScene().getClass(signature);
37
+ }
38
+ getPrinter() {
39
+ return this.printer;
40
+ }
41
+ transTemp2Code(temp) {
42
+ return temp.getName();
43
+ }
44
+ isInBuilderMethod() {
45
+ return this.inBuilder;
46
+ }
47
+ printDecorator(modifiers) {
48
+ modifiers.forEach((value) => {
49
+ if (value instanceof Decorator_1.Decorator) {
50
+ this.printer.writeIndent().writeLine(`@${value.getContent()}`);
51
+ }
52
+ });
53
+ }
54
+ modifiersToString(modifiers) {
55
+ let modifiersStr = [];
56
+ modifiers.forEach((value) => {
57
+ if (!(value instanceof Decorator_1.Decorator)) {
58
+ modifiersStr.push(this.resolveKeywordType(value));
59
+ }
60
+ });
61
+ return modifiersStr.join(' ');
62
+ }
63
+ resolveKeywordType(keywordStr) {
64
+ // 'NumberKeyword | NullKeyword |
65
+ let types = [];
66
+ for (let keyword of keywordStr.split('|')) {
67
+ keyword = keyword.trim();
68
+ if (keyword.length == 0) {
69
+ continue;
70
+ }
71
+ if (keyword.endsWith('Keyword')) {
72
+ keyword = keyword
73
+ .substring(0, keyword.length - 'Keyword'.length)
74
+ .toLowerCase();
75
+ }
76
+ types.push(keyword);
77
+ }
78
+ return types.join(' | ');
79
+ }
80
+ resolveMethodName(name) {
81
+ if (name === '_Constructor') {
82
+ return 'constructor';
83
+ }
84
+ if (name.startsWith('Get-')) {
85
+ return name.replace('Get-', 'get ');
86
+ }
87
+ if (name.startsWith('Set-')) {
88
+ return name.replace('Set-', 'set ');
89
+ }
90
+ return name;
91
+ }
92
+ }
93
+ exports.SourceBase = SourceBase;
@@ -0,0 +1,60 @@
1
+ import { Local } from '../../core/base/Local';
2
+ import { Stmt } from '../../core/base/Stmt';
3
+ import { ArkMethod } from '../../core/model/ArkMethod';
4
+ import { ArkCodeBuffer } from '../ArkStream';
5
+ import { SourceStmt, StmtPrinterContext } from './SourceStmt';
6
+ import { ArkClass } from '../../core/model/ArkClass';
7
+ import { ArkFile } from '../../core/model/ArkFile';
8
+ import { ClassSignature, MethodSignature } from '../../core/model/ArkSignature';
9
+ import { ArkNamespace } from '../../core/model/ArkNamespace';
10
+ export declare class SourceBody implements StmtPrinterContext {
11
+ protected printer: ArkCodeBuffer;
12
+ private arkBody;
13
+ private stmts;
14
+ private method;
15
+ private cfgUtils;
16
+ private tempCodeMap;
17
+ private tempVisitor;
18
+ private skipStmts;
19
+ private stmtReader;
20
+ private definedLocals;
21
+ private inBuilder;
22
+ private lastStmt;
23
+ constructor(indent: string, method: ArkMethod, inBuilder: boolean);
24
+ setSkipStmt(stmt: Stmt): void;
25
+ isInBuilderMethod(): boolean;
26
+ isInDefaultMethod(): boolean;
27
+ getArkFile(): ArkFile;
28
+ getDeclaringArkNamespace(): ArkNamespace | undefined;
29
+ getMethod(signature: MethodSignature): ArkMethod | null;
30
+ getClass(signature: ClassSignature): ArkClass | null;
31
+ getLocals(): Map<string, Local>;
32
+ defineLocal(local: Local): void;
33
+ isLocalDefined(local: Local): boolean;
34
+ getStmtReader(): StmtReader;
35
+ setTempCode(temp: string, code: string): void;
36
+ transTemp2Code(temp: Local): string;
37
+ getTempCodeMap(): Map<string, string>;
38
+ hasTempVisit(temp: string): boolean;
39
+ setTempVisit(temp: string): void;
40
+ getPrinter(): ArkCodeBuffer;
41
+ dump(): string;
42
+ private buildSourceStmt;
43
+ private buildTypeAliasStmt;
44
+ private buildBasicBlock;
45
+ private printStmts;
46
+ getStmts(): SourceStmt[];
47
+ pushStmt(stmt: SourceStmt): void;
48
+ private getLastLine;
49
+ private sortStmt;
50
+ }
51
+ export declare class StmtReader {
52
+ private stmts;
53
+ private pos;
54
+ constructor(stmts: Stmt[]);
55
+ first(): Stmt;
56
+ hasNext(): boolean;
57
+ next(): Stmt;
58
+ rollback(): void;
59
+ }
60
+ //# sourceMappingURL=SourceBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceBody.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceBody.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAyD,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGnG,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EASH,UAAU,EAIV,kBAAkB,EACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAI7D,qBAAa,UAAW,YAAW,kBAAkB;IACjD,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC;IACjC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,QAAQ,CAAO;gBAEJ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO;IAcxE,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAI7B,iBAAiB,IAAI,OAAO;IAG5B,iBAAiB,IAAI,OAAO;IAGrB,UAAU,IAAI,OAAO;IAIrB,wBAAwB,IAAI,YAAY,GAAG,SAAS;IAIpD,SAAS,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI;IAQvD,QAAQ,CAAC,SAAS,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI;IAIpD,SAAS,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC;IAI/B,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAI/B,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAIrC,aAAa,IAAI,UAAU;IAI3B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI7C,cAAc,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM;IASnC,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIrC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAInC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIhC,UAAU,IAAI,aAAa;IAI3B,IAAI,IAAI,MAAM;IAKrB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,eAAe;IA2CvB,OAAO,CAAC,UAAU;IASX,QAAQ,IAAI,UAAU,EAAE;IAQxB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IASvC,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,QAAQ;CAqCnB;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,GAAG,CAAS;gBAER,KAAK,EAAE,IAAI,EAAE;IAKzB,KAAK,IAAI,IAAI;IAIb,OAAO,IAAI,OAAO;IAIlB,IAAI,IAAI,IAAI;IAUZ,QAAQ,IAAI,IAAI;CAOnB"}