arkanalyzer 1.0.85 → 1.0.87

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 (400) hide show
  1. package/README.en.md +69 -65
  2. package/README.md +56 -70
  3. package/config/arkanalyzer.json +7 -2
  4. package/docs/cppFrontend/ArkAnalyzer-cpp_usage_guide.md +245 -0
  5. package/docs/cppFrontend/cpp_frontend_build_guide.md +126 -0
  6. package/docs/cppFrontend/cpp_frontend_user_guide.md +175 -0
  7. package/docs/cppFrontend/img.png +0 -0
  8. package/docs/cppFrontend/img_1.png +0 -0
  9. package/docs/cppFrontend/img_10.png +0 -0
  10. package/docs/cppFrontend/img_11.png +0 -0
  11. package/docs/cppFrontend/img_12.png +0 -0
  12. package/docs/cppFrontend/img_13.png +0 -0
  13. package/docs/cppFrontend/img_14.png +0 -0
  14. package/docs/cppFrontend/img_15.png +0 -0
  15. package/docs/cppFrontend/img_16.png +0 -0
  16. package/docs/cppFrontend/img_17.png +0 -0
  17. package/docs/cppFrontend/img_18.png +0 -0
  18. package/docs/cppFrontend/img_19.png +0 -0
  19. package/docs/cppFrontend/img_2.png +0 -0
  20. package/docs/cppFrontend/img_20.png +0 -0
  21. package/docs/cppFrontend/img_21.png +0 -0
  22. package/docs/cppFrontend/img_22.png +0 -0
  23. package/docs/cppFrontend/img_23.png +0 -0
  24. package/docs/cppFrontend/img_3.png +0 -0
  25. package/docs/cppFrontend/img_4.png +0 -0
  26. package/docs/cppFrontend/img_5.png +0 -0
  27. package/docs/cppFrontend/img_6.png +0 -0
  28. package/docs/cppFrontend/img_7.png +0 -0
  29. package/docs/cppFrontend/img_8.png +0 -0
  30. package/docs/cppFrontend/img_9.png +0 -0
  31. package/docs/sig_programanalysis.en.md +66 -0
  32. package/docs/sig_programanalysis.md +73 -0
  33. package/lib/Config.d.ts +32 -1
  34. package/lib/Config.d.ts.map +1 -1
  35. package/lib/Config.js +76 -2
  36. package/lib/Scene.d.ts +25 -2
  37. package/lib/Scene.d.ts.map +1 -1
  38. package/lib/Scene.js +148 -40
  39. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +4 -3
  40. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
  41. package/lib/callgraph/algorithm/AbstractAnalysis.js +17 -17
  42. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +6 -1
  43. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
  44. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +117 -14
  45. package/lib/callgraph/common/Statistics.d.ts +4 -2
  46. package/lib/callgraph/common/Statistics.d.ts.map +1 -1
  47. package/lib/callgraph/common/Statistics.js +14 -2
  48. package/lib/callgraph/model/CallGraph.d.ts +12 -8
  49. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  50. package/lib/callgraph/model/CallGraph.js +53 -29
  51. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +1 -0
  52. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -1
  53. package/lib/callgraph/model/builder/CallGraphBuilder.js +5 -1
  54. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  55. package/lib/callgraph/pointerAnalysis/Pag.js +3 -0
  56. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +4 -2
  57. package/lib/cli/cli.d.ts +3 -0
  58. package/lib/cli/cli.d.ts.map +1 -0
  59. package/lib/cli/cli.js +82 -0
  60. package/lib/cli/commands/cg.d.ts +32 -0
  61. package/lib/cli/commands/cg.d.ts.map +1 -0
  62. package/lib/cli/commands/cg.js +401 -0
  63. package/lib/cli/commands/index.d.ts +6 -0
  64. package/lib/cli/commands/index.d.ts.map +1 -0
  65. package/lib/cli/commands/index.js +64 -0
  66. package/lib/cli/commands/ir.d.ts +26 -0
  67. package/lib/cli/commands/ir.d.ts.map +1 -0
  68. package/lib/cli/commands/ir.js +94 -0
  69. package/lib/core/base/Constant.d.ts +1 -1
  70. package/lib/core/base/Constant.d.ts.map +1 -1
  71. package/lib/core/base/Constant.js +1 -1
  72. package/lib/core/base/Expr.d.ts +29 -5
  73. package/lib/core/base/Expr.d.ts.map +1 -1
  74. package/lib/core/base/Expr.js +144 -22
  75. package/lib/core/base/Position.d.ts +14 -0
  76. package/lib/core/base/Position.d.ts.map +1 -1
  77. package/lib/core/base/Position.js +27 -0
  78. package/lib/core/base/Ref.d.ts +1 -0
  79. package/lib/core/base/Ref.d.ts.map +1 -1
  80. package/lib/core/base/Ref.js +4 -1
  81. package/lib/core/base/Type.d.ts +64 -24
  82. package/lib/core/base/Type.d.ts.map +1 -1
  83. package/lib/core/base/Type.js +144 -49
  84. package/lib/core/common/ArkError.d.ts +26 -2
  85. package/lib/core/common/ArkError.d.ts.map +1 -1
  86. package/lib/core/common/ArkError.js +56 -2
  87. package/lib/core/common/ArkIRTransformer.d.ts +11 -10
  88. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  89. package/lib/core/common/ArkIRTransformer.js +1 -1
  90. package/lib/core/common/ArkValueTransformer.d.ts +14 -12
  91. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  92. package/lib/core/common/ArkValueTransformer.js +1 -5
  93. package/lib/core/common/Const.d.ts +3 -0
  94. package/lib/core/common/Const.d.ts.map +1 -1
  95. package/lib/core/common/Const.js +4 -1
  96. package/lib/core/common/DummyMainCreater.d.ts +23 -13
  97. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  98. package/lib/core/common/DummyMainCreater.js +66 -43
  99. package/lib/core/common/EtsConst.d.ts +11 -0
  100. package/lib/core/common/EtsConst.d.ts.map +1 -1
  101. package/lib/core/common/EtsConst.js +12 -1
  102. package/lib/core/common/IRInference.d.ts.map +1 -1
  103. package/lib/core/common/IRInference.js +5 -1
  104. package/lib/core/common/ModelUtils.d.ts +4 -7
  105. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  106. package/lib/core/common/ModelUtils.js +77 -110
  107. package/lib/core/common/SdkUtils.d.ts +1 -1
  108. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  109. package/lib/core/common/SdkUtils.js +14 -5
  110. package/lib/core/common/TypeInference.d.ts.map +1 -1
  111. package/lib/core/common/TypeInference.js +9 -3
  112. package/lib/core/graph/BaseExplicitGraph.d.ts +4 -4
  113. package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
  114. package/lib/core/graph/BaseExplicitGraph.js +15 -8
  115. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  116. package/lib/core/graph/Scc.d.ts.map +1 -1
  117. package/lib/core/graph/Scc.js +7 -2
  118. package/lib/core/graph/builder/CfgBuilder.d.ts +10 -7
  119. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  120. package/lib/core/graph/builder/CfgBuilder.js +12 -5
  121. package/lib/core/inference/Inference.d.ts.map +1 -1
  122. package/lib/core/inference/Inference.js +7 -0
  123. package/lib/core/inference/ModelInference.d.ts +1 -1
  124. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  125. package/lib/core/inference/ValueInference.d.ts +3 -2
  126. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  127. package/lib/core/inference/ValueInference.js +64 -12
  128. package/lib/core/inference/abc/AbcInference.d.ts +28 -2
  129. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  130. package/lib/core/inference/abc/AbcInference.js +105 -4
  131. package/lib/core/model/ArkBaseModel.d.ts +14 -1
  132. package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
  133. package/lib/core/model/ArkBaseModel.js +61 -2
  134. package/lib/core/model/ArkBody.d.ts.map +1 -1
  135. package/lib/core/model/ArkBody.js +1 -3
  136. package/lib/core/model/ArkClass.d.ts +22 -2
  137. package/lib/core/model/ArkClass.d.ts.map +1 -1
  138. package/lib/core/model/ArkClass.js +59 -28
  139. package/lib/core/model/ArkField.d.ts.map +1 -1
  140. package/lib/core/model/ArkField.js +3 -1
  141. package/lib/core/model/ArkFile.d.ts +4 -1
  142. package/lib/core/model/ArkFile.d.ts.map +1 -1
  143. package/lib/core/model/ArkFile.js +44 -3
  144. package/lib/core/model/ArkImport.d.ts.map +1 -1
  145. package/lib/core/model/ArkImport.js +9 -1
  146. package/lib/core/model/ArkMethod.d.ts +5 -0
  147. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  148. package/lib/core/model/ArkMethod.js +33 -1
  149. package/lib/core/model/ArkNamespace.d.ts +2 -0
  150. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  151. package/lib/core/model/ArkNamespace.js +11 -0
  152. package/lib/core/model/ArkSignature.d.ts +3 -3
  153. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  154. package/lib/core/model/ArkSignature.js +14 -9
  155. package/lib/core/model/builder/ArkClassBuilder.d.ts +2 -0
  156. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  157. package/lib/core/model/builder/ArkClassBuilder.js +3 -3
  158. package/lib/core/model/builder/ArkMethodBuilder.d.ts +4 -1
  159. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  160. package/lib/core/model/builder/ArkMethodBuilder.js +19 -6
  161. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +1 -0
  162. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  163. package/lib/core/model/builder/ArkNamespaceBuilder.js +2 -1
  164. package/lib/core/model/builder/BodyBuilder.d.ts +4 -0
  165. package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
  166. package/lib/core/model/builder/builderUtils.d.ts +1 -0
  167. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  168. package/lib/core/model/builder/builderUtils.js +7 -3
  169. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts +296 -0
  170. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts.map +1 -0
  171. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.js +145 -0
  172. package/lib/frontend/cppFrontend/ast/astUtils.d.ts +51 -0
  173. package/lib/frontend/cppFrontend/ast/astUtils.d.ts.map +1 -0
  174. package/lib/frontend/cppFrontend/ast/astUtils.js +470 -0
  175. package/lib/frontend/cppFrontend/ast/const.d.ts +30 -0
  176. package/lib/frontend/cppFrontend/ast/const.d.ts.map +1 -0
  177. package/lib/frontend/cppFrontend/ast/const.js +134 -0
  178. package/lib/frontend/cppFrontend/base/Constant.d.ts +9 -0
  179. package/lib/frontend/cppFrontend/base/Constant.d.ts.map +1 -0
  180. package/lib/frontend/cppFrontend/base/Constant.js +33 -0
  181. package/lib/frontend/cppFrontend/base/Expr.d.ts +174 -0
  182. package/lib/frontend/cppFrontend/base/Expr.d.ts.map +1 -0
  183. package/lib/frontend/cppFrontend/base/Expr.js +530 -0
  184. package/lib/frontend/cppFrontend/base/Ref.d.ts +25 -0
  185. package/lib/frontend/cppFrontend/base/Ref.d.ts.map +1 -0
  186. package/lib/frontend/cppFrontend/base/Ref.js +53 -0
  187. package/lib/frontend/cppFrontend/base/Trap.d.ts +8 -0
  188. package/lib/frontend/cppFrontend/base/Trap.d.ts.map +1 -0
  189. package/lib/frontend/cppFrontend/base/Trap.js +28 -0
  190. package/lib/frontend/cppFrontend/base/Type.d.ts +264 -0
  191. package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -0
  192. package/lib/frontend/cppFrontend/base/Type.js +600 -0
  193. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts +109 -0
  194. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -0
  195. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +925 -0
  196. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +477 -0
  197. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -0
  198. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +2746 -0
  199. package/lib/frontend/cppFrontend/common/Builtin.d.ts +57 -0
  200. package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -0
  201. package/lib/frontend/cppFrontend/common/Builtin.js +106 -0
  202. package/lib/frontend/cppFrontend/common/IRInference.d.ts +94 -0
  203. package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -0
  204. package/lib/frontend/cppFrontend/common/IRInference.js +1087 -0
  205. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +23 -0
  206. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -0
  207. package/lib/frontend/cppFrontend/common/IRUtils.js +168 -0
  208. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +44 -0
  209. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -0
  210. package/lib/frontend/cppFrontend/common/ModelUtils.js +567 -0
  211. package/lib/frontend/cppFrontend/common/TypeInference.d.ts +278 -0
  212. package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -0
  213. package/lib/frontend/cppFrontend/common/TypeInference.js +1354 -0
  214. package/lib/frontend/cppFrontend/common/ValueUtil.d.ts +16 -0
  215. package/lib/frontend/cppFrontend/common/ValueUtil.d.ts.map +1 -0
  216. package/lib/frontend/cppFrontend/common/ValueUtil.js +61 -0
  217. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts +182 -0
  218. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -0
  219. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +1435 -0
  220. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.d.ts +21 -0
  221. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.d.ts.map +1 -0
  222. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.js +303 -0
  223. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.d.ts +15 -0
  224. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.d.ts.map +1 -0
  225. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.js +161 -0
  226. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.d.ts +21 -0
  227. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.d.ts.map +1 -0
  228. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.js +261 -0
  229. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.d.ts +12 -0
  230. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.d.ts.map +1 -0
  231. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.js +155 -0
  232. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.d.ts +29 -0
  233. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.d.ts.map +1 -0
  234. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.js +302 -0
  235. package/lib/frontend/cppFrontend/inference/CxxInference.d.ts +10 -0
  236. package/lib/frontend/cppFrontend/inference/CxxInference.d.ts.map +1 -0
  237. package/lib/frontend/cppFrontend/inference/CxxInference.js +41 -0
  238. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +28 -0
  239. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -0
  240. package/lib/frontend/cppFrontend/inference/CxxModelInference.js +98 -0
  241. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts +20 -0
  242. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -0
  243. package/lib/frontend/cppFrontend/inference/CxxValueInference.js +128 -0
  244. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts +11 -0
  245. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -0
  246. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +413 -0
  247. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts +5 -0
  248. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -0
  249. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +61 -0
  250. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +17 -0
  251. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -0
  252. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +285 -0
  253. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts +6 -0
  254. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts.map +1 -0
  255. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.js +57 -0
  256. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts +14 -0
  257. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -0
  258. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +422 -0
  259. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +8 -0
  260. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
  261. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +194 -0
  262. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +59 -0
  263. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -0
  264. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +605 -0
  265. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts +46 -0
  266. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -0
  267. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +499 -0
  268. package/lib/frontend/cppFrontend/utils/cmakeUtils.d.ts +44 -0
  269. package/lib/frontend/cppFrontend/utils/cmakeUtils.d.ts.map +1 -0
  270. package/lib/frontend/cppFrontend/utils/cmakeUtils.js +240 -0
  271. package/lib/index.d.ts +1 -0
  272. package/lib/index.d.ts.map +1 -1
  273. package/lib/index.js +7 -1
  274. package/lib/node_modules/ohos-typescript/.ohos-typescript-version +1 -0
  275. package/{node_modules → lib/node_modules}/ohos-typescript/package.json +2 -1
  276. package/lib/save/CGJsonPrinter.d.ts +8 -0
  277. package/lib/save/CGJsonPrinter.d.ts.map +1 -0
  278. package/lib/save/CGJsonPrinter.js +41 -0
  279. package/lib/save/GraphPrinter.js +2 -2
  280. package/lib/save/json/JsonDto.d.ts +86 -2
  281. package/lib/save/json/JsonDto.d.ts.map +1 -1
  282. package/lib/save/json/JsonSerialization.d.ts +1 -1
  283. package/lib/save/json/JsonSerialization.d.ts.map +1 -1
  284. package/lib/save/json/JsonSerialization.js +235 -145
  285. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  286. package/lib/save/source/SourceTransformer.js +0 -3
  287. package/lib/utils/CxxSceneUtils.d.ts +11 -0
  288. package/lib/utils/CxxSceneUtils.d.ts.map +1 -0
  289. package/lib/utils/CxxSceneUtils.js +178 -0
  290. package/lib/utils/FileUtils.d.ts +7 -8
  291. package/lib/utils/FileUtils.d.ts.map +1 -1
  292. package/lib/utils/FileUtils.js +27 -45
  293. package/lib/utils/LRUCacheDecorator.d.ts +20 -0
  294. package/lib/utils/LRUCacheDecorator.d.ts.map +1 -0
  295. package/lib/utils/LRUCacheDecorator.js +89 -0
  296. package/lib/utils/ModuleUtils.d.ts +39 -0
  297. package/lib/utils/ModuleUtils.d.ts.map +1 -0
  298. package/lib/utils/ModuleUtils.js +261 -0
  299. package/package.json +15 -12
  300. /package/{node_modules → lib/node_modules}/ohos-typescript/LICENSE +0 -0
  301. /package/{node_modules → lib/node_modules}/ohos-typescript/README.OpenSource +0 -0
  302. /package/{node_modules → lib/node_modules}/ohos-typescript/README.md +0 -0
  303. /package/{node_modules → lib/node_modules}/ohos-typescript/SECURITY.md +0 -0
  304. /package/{node_modules → lib/node_modules}/ohos-typescript/ThirdPartyNoticeText.txt +0 -0
  305. /package/{node_modules → lib/node_modules}/ohos-typescript/bin/tsc +0 -0
  306. /package/{node_modules → lib/node_modules}/ohos-typescript/bin/tsserver +0 -0
  307. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/README.md +0 -0
  308. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/cancellationToken.js +0 -0
  309. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/cs/diagnosticMessages.generated.json +0 -0
  310. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/de/diagnosticMessages.generated.json +0 -0
  311. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/es/diagnosticMessages.generated.json +0 -0
  312. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/fr/diagnosticMessages.generated.json +0 -0
  313. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/it/diagnosticMessages.generated.json +0 -0
  314. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ja/diagnosticMessages.generated.json +0 -0
  315. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ko/diagnosticMessages.generated.json +0 -0
  316. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.d.ts +0 -0
  317. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.dom.d.ts +0 -0
  318. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.dom.iterable.d.ts +0 -0
  319. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.collection.d.ts +0 -0
  320. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.core.d.ts +0 -0
  321. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.d.ts +0 -0
  322. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.generator.d.ts +0 -0
  323. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.iterable.d.ts +0 -0
  324. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.promise.d.ts +0 -0
  325. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.proxy.d.ts +0 -0
  326. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.reflect.d.ts +0 -0
  327. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.symbol.d.ts +0 -0
  328. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -0
  329. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.array.include.d.ts +0 -0
  330. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.d.ts +0 -0
  331. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.full.d.ts +0 -0
  332. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.d.ts +0 -0
  333. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.full.d.ts +0 -0
  334. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.intl.d.ts +0 -0
  335. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.object.d.ts +0 -0
  336. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.sharedmemory.d.ts +0 -0
  337. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.string.d.ts +0 -0
  338. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.typedarrays.d.ts +0 -0
  339. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -0
  340. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.asynciterable.d.ts +0 -0
  341. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.d.ts +0 -0
  342. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.full.d.ts +0 -0
  343. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.intl.d.ts +0 -0
  344. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.promise.d.ts +0 -0
  345. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.regexp.d.ts +0 -0
  346. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.array.d.ts +0 -0
  347. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.d.ts +0 -0
  348. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.full.d.ts +0 -0
  349. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.intl.d.ts +0 -0
  350. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.object.d.ts +0 -0
  351. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.string.d.ts +0 -0
  352. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.symbol.d.ts +0 -0
  353. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.bigint.d.ts +0 -0
  354. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.d.ts +0 -0
  355. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.date.d.ts +0 -0
  356. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.full.d.ts +0 -0
  357. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.intl.d.ts +0 -0
  358. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.number.d.ts +0 -0
  359. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.promise.d.ts +0 -0
  360. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.sharedmemory.d.ts +0 -0
  361. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.string.d.ts +0 -0
  362. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -0
  363. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.d.ts +0 -0
  364. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.full.d.ts +0 -0
  365. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.intl.d.ts +0 -0
  366. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.promise.d.ts +0 -0
  367. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.string.d.ts +0 -0
  368. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.weakref.d.ts +0 -0
  369. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.array.d.ts +0 -0
  370. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.d.ts +0 -0
  371. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.error.d.ts +0 -0
  372. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.full.d.ts +0 -0
  373. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.intl.d.ts +0 -0
  374. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.object.d.ts +0 -0
  375. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.sharedmemory.d.ts +0 -0
  376. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.string.d.ts +0 -0
  377. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es5.d.ts +0 -0
  378. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es6.d.ts +0 -0
  379. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.d.ts +0 -0
  380. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.full.d.ts +0 -0
  381. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.intl.d.ts +0 -0
  382. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.scripthost.d.ts +0 -0
  383. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.d.ts +0 -0
  384. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.importscripts.d.ts +0 -0
  385. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.iterable.d.ts +0 -0
  386. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/pl/diagnosticMessages.generated.json +0 -0
  387. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/pt-br/diagnosticMessages.generated.json +0 -0
  388. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ru/diagnosticMessages.generated.json +0 -0
  389. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tr/diagnosticMessages.generated.json +0 -0
  390. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsc.js +0 -0
  391. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserver.js +0 -0
  392. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserverlibrary.d.ts +0 -0
  393. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserverlibrary.js +0 -0
  394. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typesMap.json +0 -0
  395. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typescript.d.ts +0 -0
  396. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typescript.js +0 -0
  397. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typingsInstaller.js +0 -0
  398. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/watchGuard.js +0 -0
  399. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -0
  400. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -0
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.CxxTrapBuilder = void 0;
41
+ const Trap_1 = require("../../base/Trap");
42
+ const logger_1 = __importStar(require("../../../../utils/logger"));
43
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'TrapBuilder');
44
+ /**
45
+ * Builder for traps from try...catch
46
+ */
47
+ class CxxTrapBuilder {
48
+ constructor(blockBuildersBeforeTry, blockBuilderToCfgBlock, basicBlockSet) {
49
+ this.blockBuildersBeforeTry = blockBuildersBeforeTry;
50
+ this.processedBlockBuildersBeforeTry = new Set();
51
+ this.basicBlockSet = basicBlockSet;
52
+ this.blockBuilderToCfgBlock = blockBuilderToCfgBlock;
53
+ }
54
+ buildTraps() {
55
+ const traps = [];
56
+ const blockBuildersBeforeTry = Array.from(this.blockBuildersBeforeTry);
57
+ for (const blockBuilderBeforeTry of blockBuildersBeforeTry) {
58
+ traps.push(...this.buildTrapGroup(blockBuilderBeforeTry).traps);
59
+ }
60
+ return traps;
61
+ }
62
+ buildTrapGroup(blockBuilderBeforeTry) {
63
+ if (this.shouldSkipProcessing(blockBuilderBeforeTry)) {
64
+ return { traps: [], headBlockBuilder: null };
65
+ }
66
+ const tryStmtBuilder = this.getTryStatementBuilder(blockBuilderBeforeTry);
67
+ if (!tryStmtBuilder) {
68
+ return { traps: [], headBlockBuilder: null };
69
+ }
70
+ const finallyBlockBuilder = this.getFinallyBlock(tryStmtBuilder);
71
+ if (!finallyBlockBuilder) {
72
+ return { traps: [], headBlockBuilder: null };
73
+ }
74
+ const headBlockBuilderWithinTry = this.prepareHeadBlock(blockBuilderBeforeTry);
75
+ const traps = [];
76
+ const tryResult = this.processTryBlock(headBlockBuilderWithinTry, finallyBlockBuilder);
77
+ traps.push(...tryResult.traps);
78
+ const updatedHeadBlock = tryResult.newStartBlockBuilder;
79
+ const catchResult = this.processCatchBlock(tryStmtBuilder);
80
+ traps.push(...catchResult.traps);
81
+ const blockBuilderAfterFinally = this.getAfterFinallyBlock(tryStmtBuilder);
82
+ if (!blockBuilderAfterFinally) {
83
+ return { traps: [], headBlockBuilder: null };
84
+ }
85
+ const singleTraps = this.buildSingleTraps(tryResult.bfsBlocks, tryResult.tailBlocks, catchResult.bfsBlocks, // It is a two-dimensional array here now.
86
+ catchResult.tailBlocks, // It is a two-dimensional array here now.
87
+ finallyBlockBuilder);
88
+ traps.push(...singleTraps);
89
+ return { traps, headBlockBuilder: updatedHeadBlock };
90
+ }
91
+ shouldSkipProcessing(blockBuilderBeforeTry) {
92
+ if (this.processedBlockBuildersBeforeTry.has(blockBuilderBeforeTry)) {
93
+ return true;
94
+ }
95
+ this.processedBlockBuildersBeforeTry.add(blockBuilderBeforeTry);
96
+ if (blockBuilderBeforeTry.nexts.length === 0) {
97
+ logger.error(`can't find try block.`);
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+ getTryStatementBuilder(blockBuilderBeforeTry) {
103
+ const stmtsCnt = blockBuilderBeforeTry.stmts.length;
104
+ return blockBuilderBeforeTry.stmts[stmtsCnt - 1];
105
+ }
106
+ getFinallyBlock(tryStmtBuilder) {
107
+ var _a;
108
+ const finallyBlockBuilder = (_a = tryStmtBuilder.finallyStatement) === null || _a === void 0 ? void 0 : _a.block;
109
+ if (!finallyBlockBuilder) {
110
+ logger.error(`can't find finally block or dummy finally block.`);
111
+ return null;
112
+ }
113
+ return finallyBlockBuilder;
114
+ }
115
+ prepareHeadBlock(blockBuilderBeforeTry) {
116
+ const headBlockBuilderWithinTry = blockBuilderBeforeTry.nexts[0];
117
+ this.removeEmptyBlockBeforeTry(blockBuilderBeforeTry);
118
+ return headBlockBuilderWithinTry;
119
+ }
120
+ processTryBlock(headBlockBuilderWithinTry, finallyBlockBuilder) {
121
+ const result = this.buildTrapsRecursively(headBlockBuilderWithinTry, finallyBlockBuilder);
122
+ const { bfsBlocks, tailBlocks } = this.getAllBlocksBFS(result.newStartBlockBuilder, finallyBlockBuilder);
123
+ return {
124
+ traps: result.traps,
125
+ newStartBlockBuilder: result.newStartBlockBuilder,
126
+ bfsBlocks,
127
+ tailBlocks
128
+ };
129
+ }
130
+ processCatchBlock(tryStmtBuilder) {
131
+ const allCatchBfsBlocks = [];
132
+ const allCatchTailBlocks = [];
133
+ const allTraps = [];
134
+ // 处理每个 catch 块
135
+ for (const catchStatement of tryStmtBuilder.catchStatement) {
136
+ const catchBlockBuilder = catchStatement === null || catchStatement === void 0 ? void 0 : catchStatement.block;
137
+ if (catchBlockBuilder) {
138
+ const result = this.buildTrapsRecursively(catchBlockBuilder);
139
+ const { bfsBlocks, tailBlocks } = this.getAllBlocksBFS(result.newStartBlockBuilder);
140
+ allCatchBfsBlocks.push(bfsBlocks);
141
+ allCatchTailBlocks.push(tailBlocks);
142
+ allTraps.push(...result.traps);
143
+ }
144
+ }
145
+ return {
146
+ traps: allTraps,
147
+ bfsBlocks: allCatchBfsBlocks,
148
+ tailBlocks: allCatchTailBlocks
149
+ };
150
+ }
151
+ getAfterFinallyBlock(tryStmtBuilder) {
152
+ var _a;
153
+ const blockBuilderAfterFinally = (_a = tryStmtBuilder.afterFinal) === null || _a === void 0 ? void 0 : _a.block;
154
+ if (!blockBuilderAfterFinally) {
155
+ logger.error(`can't find block after try...catch.`);
156
+ return null;
157
+ }
158
+ return blockBuilderAfterFinally;
159
+ }
160
+ buildSingleTraps(tryBfsBlocks, tryTailBlocks, catchBfsBlocks, catchTailBlocks, finallyBlockBuilder) {
161
+ return this.buildTrapsIfNoFinally(tryBfsBlocks, tryTailBlocks, catchBfsBlocks, catchTailBlocks, finallyBlockBuilder);
162
+ }
163
+ buildTrapsRecursively(startBlockBuilder, endBlockBuilder) {
164
+ const queue = [];
165
+ const visitedBlockBuilders = new Set();
166
+ queue.push(startBlockBuilder);
167
+ while (queue.length !== 0) {
168
+ const currBlockBuilder = queue.splice(0, 1)[0];
169
+ if (visitedBlockBuilders.has(currBlockBuilder)) {
170
+ continue;
171
+ }
172
+ visitedBlockBuilders.add(currBlockBuilder);
173
+ const childList = currBlockBuilder.nexts;
174
+ for (const child of childList) {
175
+ if (child !== endBlockBuilder) {
176
+ queue.push(child);
177
+ }
178
+ }
179
+ }
180
+ const allTraps = [];
181
+ for (const blockBuilder of visitedBlockBuilders) {
182
+ if (this.blockBuildersBeforeTry.has(blockBuilder)) {
183
+ const { traps, headBlockBuilder } = this.buildTrapGroup(blockBuilder);
184
+ allTraps.push(...traps);
185
+ if (blockBuilder === startBlockBuilder && this.shouldRemoveEmptyBlockBeforeTry(blockBuilder)) {
186
+ startBlockBuilder = headBlockBuilder;
187
+ }
188
+ }
189
+ }
190
+ return { traps: allTraps, newStartBlockBuilder: startBlockBuilder };
191
+ }
192
+ removeEmptyBlockBeforeTry(blockBuilderBeforeTry) {
193
+ if (!this.shouldRemoveEmptyBlockBeforeTry(blockBuilderBeforeTry)) {
194
+ return;
195
+ }
196
+ const headBlockBuilderWithinTry = blockBuilderBeforeTry.nexts[0];
197
+ const headBlockWithinTry = this.blockBuilderToCfgBlock.get(headBlockBuilderWithinTry);
198
+ headBlockWithinTry.getPredecessors().splice(0, 1);
199
+ const prevsOfBlockBuilderBeforeTry = blockBuilderBeforeTry.lasts;
200
+ for (const prevBlockBuilder of prevsOfBlockBuilderBeforeTry) {
201
+ const prevBlock = this.blockBuilderToCfgBlock.get(prevBlockBuilder);
202
+ for (let j = 0; j < prevBlockBuilder.nexts.length; j++) {
203
+ if (prevBlockBuilder.nexts[j] === blockBuilderBeforeTry) {
204
+ prevBlockBuilder.nexts[j] = headBlockBuilderWithinTry;
205
+ prevBlock.setSuccessorBlock(j, headBlockWithinTry);
206
+ break;
207
+ }
208
+ }
209
+ headBlockWithinTry.addPredecessorBlock(prevBlock);
210
+ }
211
+ headBlockBuilderWithinTry.lasts.splice(0, 1, ...prevsOfBlockBuilderBeforeTry);
212
+ this.basicBlockSet.delete(this.blockBuilderToCfgBlock.get(blockBuilderBeforeTry));
213
+ this.blockBuilderToCfgBlock.delete(blockBuilderBeforeTry);
214
+ }
215
+ shouldRemoveEmptyBlockBeforeTry(blockBuilderBeforeTry) {
216
+ const stmtsCnt = blockBuilderBeforeTry.stmts.length;
217
+ // This BlockBuilder contains only one redundant TryStatementBuilder, so the BlockBuilder can be deleted.
218
+ return stmtsCnt === 1;
219
+ }
220
+ buildTrapsIfNoFinally(tryBfsBlocks, tryTailBlocks, catchBfsBlocks, // Two-dimensional array, each subarray represents a catch block group
221
+ catchTailBlocks, finallyBlockBuilder) {
222
+ if (catchBfsBlocks.length === 0) {
223
+ logger.error(`catch block expected.`);
224
+ return [];
225
+ }
226
+ const blockBuilderAfterFinally = finallyBlockBuilder.nexts[0];
227
+ let blockAfterFinally = this.blockBuilderToCfgBlock.get(blockBuilderAfterFinally);
228
+ if (!this.blockBuilderToCfgBlock.has(finallyBlockBuilder)) {
229
+ logger.error(`can't find basicBlock corresponding to the blockBuilder.`);
230
+ return [];
231
+ }
232
+ const finallyBlock = this.blockBuilderToCfgBlock.get(finallyBlockBuilder);
233
+ let dummyFinallyIdxInPredecessors = -1;
234
+ for (let i = 0; i < blockAfterFinally.getPredecessors().length; i++) {
235
+ if (blockAfterFinally.getPredecessors()[i] === finallyBlock) {
236
+ dummyFinallyIdxInPredecessors = i;
237
+ break;
238
+ }
239
+ }
240
+ if (dummyFinallyIdxInPredecessors === -1) {
241
+ logger.error(`Dummy finally block isn't a predecessor of block after finally block.`);
242
+ return [];
243
+ }
244
+ blockAfterFinally.getPredecessors().splice(dummyFinallyIdxInPredecessors, 1);
245
+ for (const tryTailBlock of tryTailBlocks) {
246
+ const finallyIndex = tryTailBlock.getSuccessors().findIndex(succ => succ === finallyBlock);
247
+ tryTailBlock.setSuccessorBlock(finallyIndex, blockAfterFinally);
248
+ blockAfterFinally.addPredecessorBlock(tryTailBlock);
249
+ }
250
+ this.basicBlockSet.delete(finallyBlock);
251
+ // 连接所有catch块组到finally后的块
252
+ for (let i = 0; i < catchBfsBlocks.length; i++) {
253
+ const catchBfsBlockGroup = catchBfsBlocks[i];
254
+ const catchTailBlockGroup = catchTailBlocks[i];
255
+ for (const catchTailBlock of catchTailBlockGroup) {
256
+ catchTailBlock.addSuccessorBlock(blockAfterFinally);
257
+ blockAfterFinally.addPredecessorBlock(catchTailBlock);
258
+ }
259
+ // 建立try到每个catch块组的异常连接
260
+ for (const tryTailBlock of tryTailBlocks) {
261
+ tryTailBlock.addExceptionalSuccessorBlock(catchBfsBlockGroup[0]);
262
+ catchBfsBlockGroup[0].addExceptionalPredecessorBlock(tryTailBlock);
263
+ }
264
+ }
265
+ // 创建一个Trap,包含一个try块和多个catch块组
266
+ return [new Trap_1.CxxTrap(tryBfsBlocks, catchBfsBlocks)];
267
+ }
268
+ getAllBlocksBFS(startBlockBuilder, endBlockBuilder) {
269
+ const bfsBlocks = [];
270
+ const tailBlocks = [];
271
+ const startBlock = this.blockBuilderToCfgBlock.get(startBlockBuilder);
272
+ const endBlock = endBlockBuilder ? this.blockBuilderToCfgBlock.get(endBlockBuilder) : undefined;
273
+ const queue = [];
274
+ const visitedBlocks = new Set();
275
+ queue.push(startBlock);
276
+ while (queue.length !== 0) {
277
+ const currBlock = queue.splice(0, 1)[0];
278
+ if (visitedBlocks.has(currBlock)) {
279
+ continue;
280
+ }
281
+ visitedBlocks.add(currBlock);
282
+ bfsBlocks.push(currBlock);
283
+ const successors = currBlock.getSuccessors();
284
+ if (successors.length !== 0) {
285
+ for (const successor of successors) {
286
+ if (successor === endBlock) {
287
+ tailBlocks.push(currBlock);
288
+ }
289
+ else {
290
+ // A tail block's successor may be within the traversal range
291
+ queue.push(successor);
292
+ }
293
+ }
294
+ }
295
+ else {
296
+ tailBlocks.push(currBlock);
297
+ }
298
+ }
299
+ return { bfsBlocks, tailBlocks };
300
+ }
301
+ }
302
+ exports.CxxTrapBuilder = CxxTrapBuilder;
@@ -0,0 +1,10 @@
1
+ import { InferenceBuilder } from '../../../core/inference/InferenceBuilder';
2
+ import { ClassInference, FileInference, ImportInfoInference, MethodInference, StmtInference } from '../../../core/inference/ModelInference';
3
+ export declare class CxxInferenceBuilder extends InferenceBuilder {
4
+ buildFileInference(): FileInference;
5
+ buildImportInfoInference(): ImportInfoInference;
6
+ buildClassInference(): ClassInference;
7
+ buildMethodInference(): MethodInference;
8
+ buildStmtInference(): StmtInference;
9
+ }
10
+ //# sourceMappingURL=CxxInference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CxxInference.d.ts","sourceRoot":"","sources":["../../../../src/frontend/cppFrontend/inference/CxxInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAW5I,qBAAa,mBAAoB,SAAQ,gBAAgB;IAE9C,kBAAkB,IAAI,aAAa;IAInC,wBAAwB,IAAI,mBAAmB;IAI/C,mBAAmB,IAAI,cAAc;IAIrC,oBAAoB,IAAI,eAAe;IAIvC,kBAAkB,IAAI,aAAa;CAK7C"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024-2025 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.CxxInferenceBuilder = void 0;
18
+ const InferenceBuilder_1 = require("../../../core/inference/InferenceBuilder");
19
+ const ValueInference_1 = require("../../../core/inference/ValueInference");
20
+ const CxxValueInference_1 = require("./CxxValueInference");
21
+ const CxxModelInference_1 = require("./CxxModelInference");
22
+ class CxxInferenceBuilder extends InferenceBuilder_1.InferenceBuilder {
23
+ buildFileInference() {
24
+ return new CxxModelInference_1.CxxFileInference(this.buildImportInfoInference(), this.buildClassInference());
25
+ }
26
+ buildImportInfoInference() {
27
+ return new CxxModelInference_1.CxxImportInference();
28
+ }
29
+ buildClassInference() {
30
+ return new CxxModelInference_1.CxxClassInference(this.buildMethodInference());
31
+ }
32
+ buildMethodInference() {
33
+ return new CxxModelInference_1.CxxMethodInference(this.buildStmtInference());
34
+ }
35
+ buildStmtInference() {
36
+ const valueInferences = this.getValueInferences(ValueInference_1.InferLanguage.COMMON);
37
+ (0, CxxValueInference_1.getCxxValueInferences)().forEach(e => valueInferences.push(e));
38
+ return new CxxModelInference_1.CxxStmtInference(valueInferences);
39
+ }
40
+ }
41
+ exports.CxxInferenceBuilder = CxxInferenceBuilder;
@@ -0,0 +1,28 @@
1
+ import { ClassInference, FileInference, ImportInfoInference, MethodInference, StmtInference } from '../../../core/inference/ModelInference';
2
+ import { ArkFile } from '../../../core/model/ArkFile';
3
+ import { ImportInfo } from '../../../core/model/ArkImport';
4
+ import { ArkClass } from '../../../core/model/ArkClass';
5
+ import { ArkMethod } from '../../../core/model/ArkMethod';
6
+ import { ExportInfo } from '../../../core/model/ArkExport';
7
+ import { ValueInference } from '../../../core/inference/ValueInference';
8
+ import { Value } from '../../../core/base/Value';
9
+ import { Stmt } from '../../../core/base/Stmt';
10
+ export declare class CxxFileInference extends FileInference {
11
+ private preprocessedProjectName;
12
+ preInfer(file: ArkFile): void;
13
+ }
14
+ export declare class CxxImportInference extends ImportInfoInference {
15
+ preInfer(fromInfo: ImportInfo): void;
16
+ infer(fromInfo: ImportInfo): ExportInfo | null;
17
+ }
18
+ export declare class CxxClassInference extends ClassInference {
19
+ preInfer(arkClass: ArkClass): void;
20
+ }
21
+ export declare class CxxMethodInference extends MethodInference {
22
+ preInfer(arkMethod: ArkMethod): void;
23
+ }
24
+ export declare class CxxStmtInference extends StmtInference {
25
+ constructor(valueInferences: ValueInference<Value>[]);
26
+ typeSpread(stmt: Stmt, method: ArkMethod): Set<Stmt>;
27
+ }
28
+ //# sourceMappingURL=CxxModelInference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CxxModelInference.d.ts","sourceRoot":"","sources":["../../../../src/frontend/cppFrontend/inference/CxxModelInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5I,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAA0B,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEvE,qBAAa,gBAAiB,SAAQ,aAAa;IAC/C,OAAO,CAAC,uBAAuB,CAAc;IAEtC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;CASvC;AAED,qBAAa,kBAAmB,SAAQ,mBAAmB;IAChD,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;IAIpC,KAAK,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;CAGxD;AAED,qBAAa,iBAAkB,SAAQ,cAAc;IAC1C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAY5C;AAED,qBAAa,kBAAmB,SAAQ,eAAe;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;CAiB9C;AAED,qBAAa,gBAAiB,SAAQ,aAAa;gBACnC,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE;IAI7C,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC;CAS9D"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024-2025 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.CxxStmtInference = exports.CxxMethodInference = exports.CxxClassInference = exports.CxxImportInference = exports.CxxFileInference = void 0;
18
+ const ModelInference_1 = require("../../../core/inference/ModelInference");
19
+ const IRInference_1 = require("../common/IRInference");
20
+ const ModelUtils_1 = require("../common/ModelUtils");
21
+ const TypeInference_1 = require("../common/TypeInference");
22
+ const Stmt_1 = require("../../../core/base/Stmt");
23
+ class CxxFileInference extends ModelInference_1.FileInference {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.preprocessedProjectName = '';
27
+ }
28
+ preInfer(file) {
29
+ const scene = file.getScene();
30
+ if (this.preprocessedProjectName !== scene.getProjectName()) {
31
+ IRInference_1.IRInference.mapCxxDeclAndImpl(scene);
32
+ this.preprocessedProjectName = scene.getProjectName();
33
+ }
34
+ file.getImportInfos().filter(i => i.getExportInfo() === undefined)
35
+ .forEach(info => this.importInfoInference.doInfer(info));
36
+ }
37
+ }
38
+ exports.CxxFileInference = CxxFileInference;
39
+ class CxxImportInference extends ModelInference_1.ImportInfoInference {
40
+ preInfer(fromInfo) {
41
+ this.fromFile = (0, ModelUtils_1.getArkFile)(fromInfo) || null;
42
+ }
43
+ infer(fromInfo) {
44
+ return (0, ModelUtils_1.findExportInfo)(fromInfo, this.fromFile);
45
+ }
46
+ }
47
+ exports.CxxImportInference = CxxImportInference;
48
+ class CxxClassInference extends ModelInference_1.ClassInference {
49
+ preInfer(arkClass) {
50
+ super.preInfer(arkClass);
51
+ TypeInference_1.TypeInference.inferGenericType(arkClass.getGenericsTypes(), arkClass);
52
+ arkClass.getFields()
53
+ .filter(p => TypeInference_1.TypeInference.isUnclearType(p.getType()))
54
+ .forEach(f => {
55
+ const newType = TypeInference_1.TypeInference.inferUnclearedType(f.getType(), arkClass);
56
+ if (newType) {
57
+ f.getSignature().setType(newType);
58
+ }
59
+ });
60
+ }
61
+ }
62
+ exports.CxxClassInference = CxxClassInference;
63
+ class CxxMethodInference extends ModelInference_1.MethodInference {
64
+ preInfer(arkMethod) {
65
+ var _a;
66
+ TypeInference_1.TypeInference.inferGenericType(arkMethod.getGenericTypes(), arkMethod.getDeclaringArkClass());
67
+ const signatures = [];
68
+ (_a = arkMethod.getDeclareSignatures()) === null || _a === void 0 ? void 0 : _a.forEach(m => signatures.push(m));
69
+ const impl = arkMethod.getImplementationSignature();
70
+ if (impl) {
71
+ signatures.push(impl);
72
+ }
73
+ signatures.forEach(s => {
74
+ s.getMethodSubSignature()
75
+ .getParameters()
76
+ .forEach(p => {
77
+ TypeInference_1.TypeInference.inferParameterType(p, arkMethod);
78
+ });
79
+ TypeInference_1.TypeInference.inferSignatureReturnType(s, arkMethod);
80
+ });
81
+ }
82
+ }
83
+ exports.CxxMethodInference = CxxMethodInference;
84
+ class CxxStmtInference extends ModelInference_1.StmtInference {
85
+ constructor(valueInferences) {
86
+ super(valueInferences);
87
+ }
88
+ typeSpread(stmt, method) {
89
+ if (stmt instanceof Stmt_1.ArkAliasTypeDefineStmt && TypeInference_1.TypeInference.isUnclearType(stmt.getAliasType().getOriginalType())) {
90
+ const originalType = stmt.getAliasTypeExpr().getOriginalType();
91
+ if (originalType) {
92
+ stmt.getAliasType().setOriginalType(originalType);
93
+ }
94
+ }
95
+ return super.typeSpread(stmt, method);
96
+ }
97
+ }
98
+ exports.CxxStmtInference = CxxStmtInference;
@@ -0,0 +1,20 @@
1
+ import { ArkNewExpr, ArkInstanceInvokeExpr } from '../../../core/base/Expr';
2
+ import { ArkInstanceFieldRef } from '../../../core/base/Ref';
3
+ import { Stmt } from '../../../core/base/Stmt';
4
+ import { Value } from '../../../core/base/Value';
5
+ import { ValueInference, FieldRefInference, InstanceInvokeExprInference } from '../../../core/inference/ValueInference';
6
+ export declare class CxxFieldRefInference extends FieldRefInference {
7
+ getValueName(): string;
8
+ infer(value: ArkInstanceFieldRef, stmt: Stmt): Value | undefined;
9
+ }
10
+ export declare class CxxInstanceInvokeExprInference extends InstanceInvokeExprInference {
11
+ preInfer(value: ArkInstanceInvokeExpr, stmt?: Stmt): boolean;
12
+ infer(value: ArkInstanceInvokeExpr, stmt: Stmt): Value | undefined;
13
+ }
14
+ export declare class CxxArkNewExprInference extends ValueInference<ArkNewExpr> {
15
+ getValueName(): string;
16
+ preInfer(value: ArkNewExpr): boolean;
17
+ infer(value: ArkNewExpr, stmt: Stmt): Value | undefined;
18
+ }
19
+ export declare function getCxxValueInferences(): ValueInference<Value>[];
20
+ //# sourceMappingURL=CxxValueInference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CxxValueInference.d.ts","sourceRoot":"","sources":["../../../../src/frontend/cppFrontend/inference/CxxValueInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAuB,UAAU,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAqB,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAWxH,qBAAa,oBAAqB,SAAQ,iBAAiB;IAChD,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;CAY1E;AAED,qBAAa,8BAA+B,SAAQ,2BAA2B;IACpE,QAAQ,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO;IAO5D,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;CAwB5E;AAED,qBAAa,sBAAuB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAC3D,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAIpC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;CA4BjE;AAED,wBAAgB,qBAAqB,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAM/D"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024-2026 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.getCxxValueInferences = exports.CxxArkNewExprInference = exports.CxxInstanceInvokeExprInference = exports.CxxFieldRefInference = void 0;
18
+ const Expr_1 = require("../../../core/base/Expr");
19
+ const Ref_1 = require("../../../core/base/Ref");
20
+ const Type_1 = require("../../../core/base/Type");
21
+ const ValueInference_1 = require("../../../core/inference/ValueInference");
22
+ const ArkMethod_1 = require("../../../core/model/ArkMethod");
23
+ const IRInference_1 = require("../../../core/common/IRInference");
24
+ const ModelUtils_1 = require("../../../core/common/ModelUtils");
25
+ const TypeInference_1 = require("../../../core/common/TypeInference");
26
+ const Local_1 = require("../../../core/base/Local");
27
+ const TypeInference_2 = require("../common/TypeInference");
28
+ const IRInference_2 = require("../common/IRInference");
29
+ const ModelUtils_2 = require("../common/ModelUtils");
30
+ const Type_2 = require("../base/Type");
31
+ class CxxFieldRefInference extends ValueInference_1.FieldRefInference {
32
+ getValueName() {
33
+ return 'ArkCxxInstanceFieldRef';
34
+ }
35
+ infer(value, stmt) {
36
+ const baseType = TypeInference_2.TypeInference.replaceAliasType(value.getBase().getType());
37
+ const arkMethod = stmt.getCfg().getDeclaringMethod();
38
+ const newFieldSignature = IRInference_2.IRInference.generateNewFieldSignature(value, arkMethod.getDeclaringArkClass(), baseType);
39
+ if (newFieldSignature) {
40
+ value.setFieldSignature(newFieldSignature);
41
+ if (newFieldSignature.isStatic()) {
42
+ return new Ref_1.ArkStaticFieldRef(newFieldSignature);
43
+ }
44
+ }
45
+ return undefined;
46
+ }
47
+ }
48
+ exports.CxxFieldRefInference = CxxFieldRefInference;
49
+ class CxxInstanceInvokeExprInference extends ValueInference_1.InstanceInvokeExprInference {
50
+ preInfer(value, stmt) {
51
+ const needBySignature = value.getArgs().length !== value.getMethodSignature().getParamLength() ||
52
+ value.getMethodSignature().getMethodSubSignature().getParameterTypes().some(t => TypeInference_1.TypeInference.isUnclearType(t));
53
+ return needBySignature || super.preInfer(value, stmt);
54
+ }
55
+ infer(value, stmt) {
56
+ var _a;
57
+ const arkMethod = stmt.getCfg().getDeclaringMethod();
58
+ let baseType = value.getBase().getType();
59
+ if (baseType instanceof Type_2.PointerType || baseType instanceof Type_2.ReferenceType) {
60
+ baseType = baseType.getBaseType();
61
+ }
62
+ const methodName = this.getMethodName(value, arkMethod);
63
+ const result = (_a = ValueInference_1.InstanceInvokeExprInference.inferInvokeExpr(baseType, value, arkMethod)) !== null && _a !== void 0 ? _a : TypeInference_2.TypeInference.inferMethodFromImportNamespace(baseType, value, arkMethod, methodName);
64
+ if (!result && baseType instanceof Type_1.AnnotationNamespaceType) {
65
+ const namespace = arkMethod.getDeclaringArkFile().getScene().getNamespace(baseType.getNamespaceSignature());
66
+ if (namespace) {
67
+ const foundMethod = ModelUtils_2.CxxModelUtils.findPropertyInNamespace(methodName, namespace);
68
+ if (foundMethod instanceof ArkMethod_1.ArkMethod) {
69
+ const signature = foundMethod.matchMethodSignature(value.getArgs());
70
+ TypeInference_2.TypeInference.inferSignatureReturnType(signature, foundMethod);
71
+ value.setMethodSignature(signature);
72
+ return new Expr_1.ArkStaticInvokeExpr(signature, value.getArgs(), value.getRealGenericTypes());
73
+ }
74
+ }
75
+ }
76
+ return !result || result === value ? undefined : result;
77
+ }
78
+ }
79
+ exports.CxxInstanceInvokeExprInference = CxxInstanceInvokeExprInference;
80
+ class CxxArkNewExprInference extends ValueInference_1.ValueInference {
81
+ getValueName() {
82
+ return 'ArkNewExpr';
83
+ }
84
+ preInfer(value) {
85
+ return IRInference_1.IRInference.needInfer(value.getClassType().getClassSignature().getDeclaringFileSignature());
86
+ }
87
+ infer(value, stmt) {
88
+ var _a;
89
+ const className = value.getClassType().getClassSignature().getClassName();
90
+ const arkMethod = stmt.getCfg().getDeclaringMethod();
91
+ let type = (_a = ModelUtils_1.ModelUtils.findDeclaredLocal(new Local_1.Local(className), arkMethod, 1)) === null || _a === void 0 ? void 0 : _a.getType();
92
+ if (TypeInference_1.TypeInference.isUnclearType(type)) {
93
+ type = TypeInference_2.TypeInference.inferUnclearRefName(className, arkMethod.getDeclaringArkClass());
94
+ }
95
+ if (type instanceof Type_1.AliasType) {
96
+ const originType = TypeInference_1.TypeInference.replaceAliasType(type);
97
+ if (originType instanceof Type_1.FunctionType) {
98
+ type = originType.getMethodSignature().getMethodSubSignature().getReturnType();
99
+ }
100
+ else if (originType instanceof Type_2.PointerType) {
101
+ const baseType = originType.getBaseType();
102
+ if (baseType instanceof Type_1.FunctionType) {
103
+ type = baseType.getMethodSignature().getMethodSubSignature().getReturnType();
104
+ }
105
+ else {
106
+ type = originType;
107
+ }
108
+ }
109
+ else {
110
+ type = originType;
111
+ }
112
+ }
113
+ if (type && type instanceof Type_1.ClassType) {
114
+ value.getClassType().setClassSignature(type.getClassSignature());
115
+ TypeInference_1.TypeInference.inferRealGenericTypes(value.getClassType().getRealGenericTypes(), arkMethod.getDeclaringArkClass());
116
+ }
117
+ return undefined;
118
+ }
119
+ }
120
+ exports.CxxArkNewExprInference = CxxArkNewExprInference;
121
+ function getCxxValueInferences() {
122
+ return [
123
+ new CxxFieldRefInference(),
124
+ new CxxInstanceInvokeExprInference(),
125
+ new CxxArkNewExprInference(),
126
+ ];
127
+ }
128
+ exports.getCxxValueInferences = getCxxValueInferences;
@@ -0,0 +1,11 @@
1
+ import { ArkFile } from '../../../../core/model/ArkFile';
2
+ import { ArkMethod } from '../../../../core/model/ArkMethod';
3
+ import { ArkNamespace } from '../../../../core/model/ArkNamespace';
4
+ import { ArkClass } from '../../../../core/model/ArkClass';
5
+ import { CxxAstNode } from '../../ast/ArkCxxAstNode';
6
+ export declare function buildNormalArkClassFromArkMethod(clsNode: CxxAstNode, cls: ArkClass, sourceFile: CxxAstNode, declaring?: ArkMethod | ArkClass): void;
7
+ export declare function buildNormalArkClassFromArkFile(clsNode: CxxAstNode, arkFile: ArkFile, cls: ArkClass, sourceFile: CxxAstNode, declaring?: ArkMethod | ArkClass): void;
8
+ export declare function buildNormalArkClassFromArkNamespace(clsNode: CxxAstNode, arkNamespace: ArkNamespace, cls: ArkClass, sourceFile: CxxAstNode, declaring?: ArkMethod | ArkClass): void;
9
+ export declare function buildNormalArkClass(clsNode: CxxAstNode, cls: ArkClass, sourceFile: CxxAstNode, declaring?: ArkMethod | ArkClass): void;
10
+ export declare function buildDefaultArkClassFromArkFile(arkFile: ArkFile, defaultClass: ArkClass, astRoot: CxxAstNode): void;
11
+ //# sourceMappingURL=ArkClassBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArkClassBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/model/builder/ArkClassBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAwC,MAAM,iCAAiC,CAAC;AAUjG,OAAO,EAAE,UAAU,EAA8C,MAAM,yBAAyB,CAAC;AAcjG,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CAOnJ;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EACpD,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CAQ7G;AAED,wBAAgB,mCAAmC,CAC/C,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,UAAU,EACtB,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GACjC,IAAI,CASN;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CAwBtI;AA+PD,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAInH"}