arkanalyzer 1.0.86 → 1.0.88

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 (422) 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 +35 -1
  34. package/lib/Config.d.ts.map +1 -1
  35. package/lib/Config.js +91 -2
  36. package/lib/Scene.d.ts +25 -2
  37. package/lib/Scene.d.ts.map +1 -1
  38. package/lib/Scene.js +151 -44
  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 +53 -0
  61. package/lib/cli/commands/cg.d.ts.map +1 -0
  62. package/lib/cli/commands/cg.js +404 -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 +145 -23
  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 +4 -0
  94. package/lib/core/common/Const.d.ts.map +1 -1
  95. package/lib/core/common/Const.js +5 -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 +6 -2
  104. package/lib/core/common/IRUtils.d.ts.map +1 -1
  105. package/lib/core/common/IRUtils.js +3 -33
  106. package/lib/core/common/ModelUtils.d.ts +4 -7
  107. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  108. package/lib/core/common/ModelUtils.js +77 -110
  109. package/lib/core/common/SdkUtils.d.ts +1 -1
  110. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  111. package/lib/core/common/SdkUtils.js +14 -5
  112. package/lib/core/common/TypeInference.d.ts.map +1 -1
  113. package/lib/core/common/TypeInference.js +9 -3
  114. package/lib/core/graph/BaseExplicitGraph.d.ts +4 -4
  115. package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
  116. package/lib/core/graph/BaseExplicitGraph.js +15 -8
  117. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  118. package/lib/core/graph/Scc.d.ts.map +1 -1
  119. package/lib/core/graph/Scc.js +7 -2
  120. package/lib/core/graph/builder/CfgBuilder.d.ts +10 -7
  121. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  122. package/lib/core/graph/builder/CfgBuilder.js +12 -5
  123. package/lib/core/inference/Inference.d.ts.map +1 -1
  124. package/lib/core/inference/Inference.js +7 -0
  125. package/lib/core/inference/ModelInference.d.ts +1 -1
  126. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  127. package/lib/core/inference/ValueInference.d.ts +3 -2
  128. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  129. package/lib/core/inference/ValueInference.js +64 -12
  130. package/lib/core/inference/abc/AbcInference.d.ts +28 -2
  131. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  132. package/lib/core/inference/abc/AbcInference.js +105 -4
  133. package/lib/core/model/ArkBaseModel.d.ts +14 -1
  134. package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
  135. package/lib/core/model/ArkBaseModel.js +61 -2
  136. package/lib/core/model/ArkBody.d.ts.map +1 -1
  137. package/lib/core/model/ArkBody.js +1 -3
  138. package/lib/core/model/ArkClass.d.ts +25 -2
  139. package/lib/core/model/ArkClass.d.ts.map +1 -1
  140. package/lib/core/model/ArkClass.js +72 -30
  141. package/lib/core/model/ArkField.d.ts.map +1 -1
  142. package/lib/core/model/ArkField.js +3 -1
  143. package/lib/core/model/ArkFile.d.ts +4 -1
  144. package/lib/core/model/ArkFile.d.ts.map +1 -1
  145. package/lib/core/model/ArkFile.js +44 -3
  146. package/lib/core/model/ArkImport.d.ts.map +1 -1
  147. package/lib/core/model/ArkImport.js +9 -1
  148. package/lib/core/model/ArkMetadata.d.ts +32 -1
  149. package/lib/core/model/ArkMetadata.d.ts.map +1 -1
  150. package/lib/core/model/ArkMetadata.js +28 -2
  151. package/lib/core/model/ArkMethod.d.ts +5 -0
  152. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  153. package/lib/core/model/ArkMethod.js +33 -1
  154. package/lib/core/model/ArkNamespace.d.ts +2 -0
  155. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  156. package/lib/core/model/ArkNamespace.js +11 -0
  157. package/lib/core/model/ArkSignature.d.ts +3 -3
  158. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  159. package/lib/core/model/ArkSignature.js +14 -9
  160. package/lib/core/model/builder/ArkClassBuilder.d.ts +2 -0
  161. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  162. package/lib/core/model/builder/ArkClassBuilder.js +3 -3
  163. package/lib/core/model/builder/ArkMetadataBuilder.d.ts +21 -0
  164. package/lib/core/model/builder/ArkMetadataBuilder.d.ts.map +1 -0
  165. package/lib/core/model/builder/ArkMetadataBuilder.js +160 -0
  166. package/lib/core/model/builder/ArkMethodBuilder.d.ts +4 -1
  167. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  168. package/lib/core/model/builder/ArkMethodBuilder.js +50 -29
  169. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +1 -0
  170. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  171. package/lib/core/model/builder/ArkNamespaceBuilder.js +2 -1
  172. package/lib/core/model/builder/BodyBuilder.d.ts +4 -0
  173. package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
  174. package/lib/core/model/builder/builderUtils.d.ts +1 -0
  175. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  176. package/lib/core/model/builder/builderUtils.js +7 -3
  177. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts +296 -0
  178. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts.map +1 -0
  179. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.js +145 -0
  180. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiApi.d.ts +8 -0
  181. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiApi.d.ts.map +1 -0
  182. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiApi.js +90 -0
  183. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiRunner.d.ts +8 -0
  184. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiRunner.d.ts.map +1 -0
  185. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiRunner.js +183 -0
  186. package/lib/frontend/cppFrontend/ast/astParser.d.ts +25 -0
  187. package/lib/frontend/cppFrontend/ast/astParser.d.ts.map +1 -0
  188. package/lib/frontend/cppFrontend/ast/astParser.js +280 -0
  189. package/lib/frontend/cppFrontend/ast/astUtils.d.ts +18 -0
  190. package/lib/frontend/cppFrontend/ast/astUtils.d.ts.map +1 -0
  191. package/lib/frontend/cppFrontend/ast/astUtils.js +158 -0
  192. package/lib/frontend/cppFrontend/ast/const.d.ts +17 -0
  193. package/lib/frontend/cppFrontend/ast/const.d.ts.map +1 -0
  194. package/lib/frontend/cppFrontend/ast/const.js +58 -0
  195. package/lib/frontend/cppFrontend/ast/index.d.ts +5 -0
  196. package/lib/frontend/cppFrontend/ast/index.d.ts.map +1 -0
  197. package/lib/frontend/cppFrontend/ast/index.js +31 -0
  198. package/lib/frontend/cppFrontend/base/Constant.d.ts +9 -0
  199. package/lib/frontend/cppFrontend/base/Constant.d.ts.map +1 -0
  200. package/lib/frontend/cppFrontend/base/Constant.js +33 -0
  201. package/lib/frontend/cppFrontend/base/Expr.d.ts +174 -0
  202. package/lib/frontend/cppFrontend/base/Expr.d.ts.map +1 -0
  203. package/lib/frontend/cppFrontend/base/Expr.js +530 -0
  204. package/lib/frontend/cppFrontend/base/Ref.d.ts +25 -0
  205. package/lib/frontend/cppFrontend/base/Ref.d.ts.map +1 -0
  206. package/lib/frontend/cppFrontend/base/Ref.js +53 -0
  207. package/lib/frontend/cppFrontend/base/Trap.d.ts +8 -0
  208. package/lib/frontend/cppFrontend/base/Trap.d.ts.map +1 -0
  209. package/lib/frontend/cppFrontend/base/Trap.js +28 -0
  210. package/lib/frontend/cppFrontend/base/Type.d.ts +264 -0
  211. package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -0
  212. package/lib/frontend/cppFrontend/base/Type.js +600 -0
  213. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts +109 -0
  214. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -0
  215. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +925 -0
  216. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +477 -0
  217. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -0
  218. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +2746 -0
  219. package/lib/frontend/cppFrontend/common/Builtin.d.ts +57 -0
  220. package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -0
  221. package/lib/frontend/cppFrontend/common/Builtin.js +106 -0
  222. package/lib/frontend/cppFrontend/common/IRInference.d.ts +94 -0
  223. package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -0
  224. package/lib/frontend/cppFrontend/common/IRInference.js +1087 -0
  225. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +23 -0
  226. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -0
  227. package/lib/frontend/cppFrontend/common/IRUtils.js +168 -0
  228. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +44 -0
  229. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -0
  230. package/lib/frontend/cppFrontend/common/ModelUtils.js +567 -0
  231. package/lib/frontend/cppFrontend/common/TypeInference.d.ts +278 -0
  232. package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -0
  233. package/lib/frontend/cppFrontend/common/TypeInference.js +1354 -0
  234. package/lib/frontend/cppFrontend/common/ValueUtil.d.ts +16 -0
  235. package/lib/frontend/cppFrontend/common/ValueUtil.d.ts.map +1 -0
  236. package/lib/frontend/cppFrontend/common/ValueUtil.js +61 -0
  237. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts +182 -0
  238. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -0
  239. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +1435 -0
  240. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.d.ts +21 -0
  241. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.d.ts.map +1 -0
  242. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.js +303 -0
  243. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.d.ts +15 -0
  244. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.d.ts.map +1 -0
  245. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.js +161 -0
  246. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.d.ts +21 -0
  247. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.d.ts.map +1 -0
  248. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.js +261 -0
  249. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.d.ts +12 -0
  250. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.d.ts.map +1 -0
  251. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.js +155 -0
  252. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.d.ts +29 -0
  253. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.d.ts.map +1 -0
  254. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.js +302 -0
  255. package/lib/frontend/cppFrontend/inference/CxxInference.d.ts +10 -0
  256. package/lib/frontend/cppFrontend/inference/CxxInference.d.ts.map +1 -0
  257. package/lib/frontend/cppFrontend/inference/CxxInference.js +41 -0
  258. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +28 -0
  259. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -0
  260. package/lib/frontend/cppFrontend/inference/CxxModelInference.js +98 -0
  261. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts +20 -0
  262. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -0
  263. package/lib/frontend/cppFrontend/inference/CxxValueInference.js +128 -0
  264. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts +11 -0
  265. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -0
  266. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +413 -0
  267. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts +5 -0
  268. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -0
  269. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +61 -0
  270. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +17 -0
  271. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -0
  272. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +284 -0
  273. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts +6 -0
  274. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts.map +1 -0
  275. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.js +57 -0
  276. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts +14 -0
  277. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -0
  278. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +422 -0
  279. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +8 -0
  280. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
  281. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +194 -0
  282. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +59 -0
  283. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -0
  284. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +605 -0
  285. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts +46 -0
  286. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -0
  287. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +499 -0
  288. package/lib/frontend/cppFrontend/utils/cmakeUtils.d.ts +44 -0
  289. package/lib/frontend/cppFrontend/utils/cmakeUtils.d.ts.map +1 -0
  290. package/lib/frontend/cppFrontend/utils/cmakeUtils.js +240 -0
  291. package/lib/index.d.ts +2 -1
  292. package/lib/index.d.ts.map +1 -1
  293. package/lib/index.js +8 -1
  294. package/lib/node_modules/ohos-typescript/.ohos-typescript-version +1 -0
  295. package/{node_modules → lib/node_modules}/ohos-typescript/package.json +2 -1
  296. package/lib/save/CGJsonPrinter.d.ts +8 -0
  297. package/lib/save/CGJsonPrinter.d.ts.map +1 -0
  298. package/lib/save/CGJsonPrinter.js +41 -0
  299. package/lib/save/GraphPrinter.js +2 -2
  300. package/lib/save/json/JsonDto.d.ts +86 -2
  301. package/lib/save/json/JsonDto.d.ts.map +1 -1
  302. package/lib/save/json/JsonSerialization.d.ts +1 -1
  303. package/lib/save/json/JsonSerialization.d.ts.map +1 -1
  304. package/lib/save/json/JsonSerialization.js +235 -145
  305. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  306. package/lib/save/source/SourceStmt.js +3 -1
  307. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  308. package/lib/save/source/SourceTransformer.js +0 -3
  309. package/lib/utils/CxxSceneUtils.d.ts +11 -0
  310. package/lib/utils/CxxSceneUtils.d.ts.map +1 -0
  311. package/lib/utils/CxxSceneUtils.js +178 -0
  312. package/lib/utils/FileUtils.d.ts +8 -8
  313. package/lib/utils/FileUtils.d.ts.map +1 -1
  314. package/lib/utils/FileUtils.js +35 -45
  315. package/lib/utils/LRUCacheDecorator.d.ts +20 -0
  316. package/lib/utils/LRUCacheDecorator.d.ts.map +1 -0
  317. package/lib/utils/LRUCacheDecorator.js +89 -0
  318. package/lib/utils/ModuleUtils.d.ts +39 -0
  319. package/lib/utils/ModuleUtils.d.ts.map +1 -0
  320. package/lib/utils/ModuleUtils.js +261 -0
  321. package/package.json +13 -7
  322. /package/{node_modules → lib/node_modules}/ohos-typescript/LICENSE +0 -0
  323. /package/{node_modules → lib/node_modules}/ohos-typescript/README.OpenSource +0 -0
  324. /package/{node_modules → lib/node_modules}/ohos-typescript/README.md +0 -0
  325. /package/{node_modules → lib/node_modules}/ohos-typescript/SECURITY.md +0 -0
  326. /package/{node_modules → lib/node_modules}/ohos-typescript/ThirdPartyNoticeText.txt +0 -0
  327. /package/{node_modules → lib/node_modules}/ohos-typescript/bin/tsc +0 -0
  328. /package/{node_modules → lib/node_modules}/ohos-typescript/bin/tsserver +0 -0
  329. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/README.md +0 -0
  330. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/cancellationToken.js +0 -0
  331. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/cs/diagnosticMessages.generated.json +0 -0
  332. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/de/diagnosticMessages.generated.json +0 -0
  333. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/es/diagnosticMessages.generated.json +0 -0
  334. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/fr/diagnosticMessages.generated.json +0 -0
  335. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/it/diagnosticMessages.generated.json +0 -0
  336. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ja/diagnosticMessages.generated.json +0 -0
  337. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ko/diagnosticMessages.generated.json +0 -0
  338. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.d.ts +0 -0
  339. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.dom.d.ts +0 -0
  340. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.dom.iterable.d.ts +0 -0
  341. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.collection.d.ts +0 -0
  342. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.core.d.ts +0 -0
  343. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.d.ts +0 -0
  344. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.generator.d.ts +0 -0
  345. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.iterable.d.ts +0 -0
  346. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.promise.d.ts +0 -0
  347. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.proxy.d.ts +0 -0
  348. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.reflect.d.ts +0 -0
  349. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.symbol.d.ts +0 -0
  350. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -0
  351. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.array.include.d.ts +0 -0
  352. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.d.ts +0 -0
  353. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.full.d.ts +0 -0
  354. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.d.ts +0 -0
  355. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.full.d.ts +0 -0
  356. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.intl.d.ts +0 -0
  357. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.object.d.ts +0 -0
  358. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.sharedmemory.d.ts +0 -0
  359. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.string.d.ts +0 -0
  360. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.typedarrays.d.ts +0 -0
  361. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -0
  362. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.asynciterable.d.ts +0 -0
  363. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.d.ts +0 -0
  364. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.full.d.ts +0 -0
  365. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.intl.d.ts +0 -0
  366. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.promise.d.ts +0 -0
  367. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.regexp.d.ts +0 -0
  368. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.array.d.ts +0 -0
  369. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.d.ts +0 -0
  370. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.full.d.ts +0 -0
  371. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.intl.d.ts +0 -0
  372. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.object.d.ts +0 -0
  373. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.string.d.ts +0 -0
  374. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.symbol.d.ts +0 -0
  375. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.bigint.d.ts +0 -0
  376. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.d.ts +0 -0
  377. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.date.d.ts +0 -0
  378. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.full.d.ts +0 -0
  379. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.intl.d.ts +0 -0
  380. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.number.d.ts +0 -0
  381. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.promise.d.ts +0 -0
  382. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.sharedmemory.d.ts +0 -0
  383. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.string.d.ts +0 -0
  384. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -0
  385. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.d.ts +0 -0
  386. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.full.d.ts +0 -0
  387. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.intl.d.ts +0 -0
  388. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.promise.d.ts +0 -0
  389. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.string.d.ts +0 -0
  390. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.weakref.d.ts +0 -0
  391. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.array.d.ts +0 -0
  392. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.d.ts +0 -0
  393. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.error.d.ts +0 -0
  394. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.full.d.ts +0 -0
  395. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.intl.d.ts +0 -0
  396. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.object.d.ts +0 -0
  397. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.sharedmemory.d.ts +0 -0
  398. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.string.d.ts +0 -0
  399. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es5.d.ts +0 -0
  400. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es6.d.ts +0 -0
  401. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.d.ts +0 -0
  402. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.full.d.ts +0 -0
  403. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.intl.d.ts +0 -0
  404. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.scripthost.d.ts +0 -0
  405. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.d.ts +0 -0
  406. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.importscripts.d.ts +0 -0
  407. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.iterable.d.ts +0 -0
  408. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/pl/diagnosticMessages.generated.json +0 -0
  409. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/pt-br/diagnosticMessages.generated.json +0 -0
  410. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ru/diagnosticMessages.generated.json +0 -0
  411. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tr/diagnosticMessages.generated.json +0 -0
  412. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsc.js +0 -0
  413. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserver.js +0 -0
  414. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserverlibrary.d.ts +0 -0
  415. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserverlibrary.js +0 -0
  416. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typesMap.json +0 -0
  417. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typescript.d.ts +0 -0
  418. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typescript.js +0 -0
  419. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typingsInstaller.js +0 -0
  420. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/watchGuard.js +0 -0
  421. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -0
  422. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -0
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 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
+ 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.runAstJsonArgv = void 0;
41
+ const node_child_process_1 = require("node:child_process");
42
+ const fs = __importStar(require("node:fs"));
43
+ const path = __importStar(require("node:path"));
44
+ const logger_1 = __importStar(require("../../../../utils/logger"));
45
+ const astUtils_1 = require("../astUtils");
46
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'astJsonDumper');
47
+ let selectedRunArgv = null;
48
+ function startNewAstJsonWorker(addonAbsolutePath, onExit) {
49
+ var _a, _b;
50
+ const workerPath = path.join(__dirname, 'napiWorker.cjs');
51
+ const proc = (0, node_child_process_1.fork)(workerPath, [addonAbsolutePath], {
52
+ serialization: 'advanced',
53
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
54
+ });
55
+ (_a = proc.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (chunk) => {
56
+ const text = chunk.toString();
57
+ if (text.trim().length > 0) {
58
+ logger.info(`[Debug] astJsonDumper worker stdout:\n${text}`);
59
+ }
60
+ });
61
+ (_b = proc.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (chunk) => {
62
+ const text = chunk.toString();
63
+ if (text.trim().length > 0) {
64
+ logger.error(`[Debug] astJsonDumper worker stderr:\n${text}`);
65
+ }
66
+ });
67
+ proc.on('exit', (code, signal) => {
68
+ onExit(proc, code, signal);
69
+ });
70
+ return proc;
71
+ }
72
+ function awaitWorkerArgvReply(proc, workerStillCurrent, disposeOnSendFail, context, argv) {
73
+ const state = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2));
74
+ try {
75
+ proc.send({
76
+ type: 'run',
77
+ argv,
78
+ cwd: context.cwd,
79
+ envPath: context.env.PATH,
80
+ state: state.buffer,
81
+ });
82
+ }
83
+ catch (error) {
84
+ logger.error('[Debug] Failed to send astJsonDumper request to worker:', error);
85
+ disposeOnSendFail(proc);
86
+ return -1;
87
+ }
88
+ while (Atomics.load(state, 0) === 0) {
89
+ Atomics.wait(state, 0, 0, 1000);
90
+ if (!workerStillCurrent() || proc.exitCode !== null || proc.killed) {
91
+ logger.error('[Debug] astJsonDumper worker exited before replying.');
92
+ return -1;
93
+ }
94
+ }
95
+ return Atomics.load(state, 1);
96
+ }
97
+ function createPersistentWorkerRunner(addonAbsolutePath) {
98
+ let worker = null;
99
+ const disposeWorker = (proc) => {
100
+ if (worker === proc) {
101
+ worker = null;
102
+ }
103
+ if (proc.exitCode === null && !proc.killed) {
104
+ proc.kill();
105
+ }
106
+ };
107
+ const ensureWorker = () => {
108
+ if (worker && worker.exitCode === null && !worker.killed) {
109
+ return worker;
110
+ }
111
+ const proc = startNewAstJsonWorker(addonAbsolutePath, (exitedProc, code, signal) => {
112
+ if (worker === exitedProc) {
113
+ worker = null;
114
+ }
115
+ logger.warn(`[Debug] astJsonDumper worker exited (code=${code}, signal=${signal}).`);
116
+ });
117
+ worker = proc;
118
+ return proc;
119
+ };
120
+ return (context, ...argv) => {
121
+ const proc = ensureWorker();
122
+ return awaitWorkerArgvReply(proc, () => worker === proc, disposeWorker, context, argv);
123
+ };
124
+ }
125
+ function logSpawnSyncFailure(result) {
126
+ if (result.stdout) {
127
+ logger.error(`[Debug] child stdout:\n${result.stdout}`);
128
+ }
129
+ if (result.stderr) {
130
+ logger.error(`[Debug] child stderr:\n${result.stderr}`);
131
+ }
132
+ logger.error(`[Debug] astJsonDumper child exited with code ${result.status}`);
133
+ return -1;
134
+ }
135
+ function runArgvInSubprocess(context, ...argv) {
136
+ const addonPath = (0, astUtils_1.getAstJsonDumperNodePath)();
137
+ const childScript = 'const addon = require(process.argv[1]); ' +
138
+ 'const rc = addon.runArgv(process.argv.slice(2)); ' +
139
+ "process.exitCode = typeof rc === 'number' ? rc : 1;";
140
+ const quoted = ['-e', childScript, addonPath, ...argv]
141
+ .map((arg) => (arg.includes(' ') ? `"${arg}"` : arg))
142
+ .join(' ');
143
+ logger.info('================================================================');
144
+ logger.info(`[Debug] CWD: ${context.cwd}`);
145
+ logger.info(`[Debug] astJsonDumper.node: ${addonPath}`);
146
+ logger.info(`[Debug] CMD: "${process.execPath}" ${quoted}`);
147
+ logger.info('================================================================');
148
+ if (!fs.existsSync(addonPath)) {
149
+ logger.error(`[Debug] Missing addon: ${addonPath}`);
150
+ return -1;
151
+ }
152
+ const result = (0, node_child_process_1.spawnSync)(process.execPath, ['-e', childScript, addonPath, ...argv], {
153
+ stdio: ['inherit', 'pipe', 'pipe'],
154
+ encoding: 'utf-8',
155
+ env: context.env,
156
+ cwd: context.cwd,
157
+ });
158
+ if (result.status !== 0) {
159
+ return logSpawnSyncFailure(result);
160
+ }
161
+ return 0;
162
+ }
163
+ function shouldIsolateRuns() {
164
+ if (process.env.ARKANALYZER_AST_JSON_SUBPROCESS === '1') {
165
+ return true;
166
+ }
167
+ if (process.env.ARKANALYZER_AST_JSON_SUBPROCESS === '0') {
168
+ return false;
169
+ }
170
+ return process.env.VITEST === 'true';
171
+ }
172
+ function getRunArgv() {
173
+ if (!selectedRunArgv) {
174
+ selectedRunArgv = shouldIsolateRuns()
175
+ ? runArgvInSubprocess
176
+ : createPersistentWorkerRunner((0, astUtils_1.getAstJsonDumperNodePath)());
177
+ }
178
+ return selectedRunArgv;
179
+ }
180
+ function runAstJsonArgv(argv, context) {
181
+ return getRunArgv()(context, ...argv);
182
+ }
183
+ exports.runAstJsonArgv = runAstJsonArgv;
@@ -0,0 +1,25 @@
1
+ import { CxxAstNode, CxxAstNodeLite } from './ArkCxxAstNode';
2
+ export type GetParentFn = {
3
+ (isNeedInner: true): CxxAstNode;
4
+ (isNeedInner?: false): CxxAstNodeLite;
5
+ };
6
+ export declare class AstParser {
7
+ private static currentAccess;
8
+ private static deleteFileSync;
9
+ static parse(sourceFile: string, ccJsonPath: string | null, includeDirs: string[] | null, llvmPath: string, cppAstPath: string): CxxAstNode;
10
+ private static resolveProjectRoot;
11
+ private static getWorkingDir;
12
+ private static processAstFile;
13
+ private static createEmptyNode;
14
+ private static updateInner;
15
+ private static filter;
16
+ private static filterChildren;
17
+ private static makeGetParent;
18
+ private static fullInfo;
19
+ private static processAccess;
20
+ private static getCodeForExtractModifiers;
21
+ private static stripFucntionParams;
22
+ private static getAstOutputPath;
23
+ private static ensureOutputDir;
24
+ }
25
+ //# sourceMappingURL=astParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astParser.d.ts","sourceRoot":"","sources":["../../../../src/frontend/cppFrontend/ast/astParser.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAW,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMtE,MAAM,MAAM,WAAW,GAAG;IACtB,CAAC,WAAW,EAAE,IAAI,GAAG,UAAU,CAAC;IAChC,CAAC,WAAW,CAAC,EAAE,KAAK,GAAG,cAAc,CAAC;CACzC,CAAC;AAEF,qBAAa,SAAS;IAClB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAc;IAE1C,OAAO,CAAC,MAAM,CAAC,cAAc;WAQf,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU;IA4BlJ,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAoBjC,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B,OAAO,CAAC,MAAM,CAAC,cAAc;IAqB7B,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B,OAAO,CAAC,MAAM,CAAC,WAAW;IAY1B,OAAO,CAAC,MAAM,CAAC,MAAM;IAYrB,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B,OAAO,CAAC,MAAM,CAAC,QAAQ;IA8BvB,OAAO,CAAC,MAAM,CAAC,aAAa;IAgB5B,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAUzC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAyBlC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAQ/B,OAAO,CAAC,MAAM,CAAC,eAAe;CAKjC"}
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 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
+ 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
+ var __rest = (this && this.__rest) || function (s, e) {
40
+ var t = {};
41
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
42
+ t[p] = s[p];
43
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
44
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
45
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
46
+ t[p[i]] = s[p[i]];
47
+ }
48
+ return t;
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.AstParser = void 0;
52
+ const fs = __importStar(require("fs"));
53
+ const path = __importStar(require("path"));
54
+ const logger_1 = __importStar(require("../../../utils/logger"));
55
+ const ArkCxxAstNode_1 = require("./ArkCxxAstNode");
56
+ const napiApi_1 = require("./astJsonNapi/napiApi");
57
+ const astUtils_1 = require("./astUtils");
58
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'astParser');
59
+ class AstParser {
60
+ static deleteFileSync(filePath) {
61
+ try {
62
+ fs.unlinkSync(filePath);
63
+ }
64
+ catch (_a) {
65
+ logger.warn('delete file failed:', filePath);
66
+ }
67
+ }
68
+ static parse(sourceFile, ccJsonPath, includeDirs, llvmPath, cppAstPath) {
69
+ logger.info(`[Debug] Parsing File: ${sourceFile}`);
70
+ if (!fs.existsSync(sourceFile)) {
71
+ logger.warn('parse file is not exists');
72
+ return this.createEmptyNode();
73
+ }
74
+ const rawAstPath = this.getAstOutputPath(sourceFile, cppAstPath);
75
+ const astPath = path.resolve(rawAstPath);
76
+ this.ensureOutputDir(path.dirname(astPath));
77
+ const workingDir = this.getWorkingDir(ccJsonPath);
78
+ const finalIncludeDirs = includeDirs ? [...includeDirs] : [];
79
+ const projectRoot = this.resolveProjectRoot(sourceFile);
80
+ if (projectRoot && !finalIncludeDirs.includes(projectRoot)) {
81
+ finalIncludeDirs.push(projectRoot);
82
+ }
83
+ const status = (0, napiApi_1.dumpAstJson)({
84
+ sourceFile,
85
+ outputFile: astPath,
86
+ ccJsonPath: ccJsonPath !== null && ccJsonPath !== void 0 ? ccJsonPath : undefined,
87
+ includeDirs: finalIncludeDirs,
88
+ }, workingDir, llvmPath);
89
+ return this.processAstFile(astPath, sourceFile, status);
90
+ }
91
+ static resolveProjectRoot(sourceFile) {
92
+ try {
93
+ let currentDir = path.dirname(sourceFile);
94
+ for (let i = 0; i < 10; i++) {
95
+ if (path.dirname(currentDir) === currentDir) {
96
+ break;
97
+ }
98
+ if (path.basename(currentDir) === 'cpp' && path.basename(path.dirname(currentDir)) === 'main') {
99
+ const absRoot = path.resolve(currentDir);
100
+ logger.info(`[Debug] Found Source Root: ${absRoot}`);
101
+ return absRoot;
102
+ }
103
+ currentDir = path.dirname(currentDir);
104
+ }
105
+ }
106
+ catch (e) {
107
+ logger.error('[Debug] Error finding source root:', e);
108
+ }
109
+ return null;
110
+ }
111
+ static getWorkingDir(ccJsonPath) {
112
+ let workingDir = process.cwd();
113
+ if (ccJsonPath && fs.existsSync(ccJsonPath)) {
114
+ const stats = fs.statSync(ccJsonPath);
115
+ if (stats.isFile()) {
116
+ workingDir = path.dirname(ccJsonPath);
117
+ }
118
+ else {
119
+ workingDir = ccJsonPath;
120
+ }
121
+ }
122
+ return workingDir;
123
+ }
124
+ static processAstFile(astPath, sourceFile, status) {
125
+ try {
126
+ if (!fs.existsSync(astPath)) {
127
+ logger.error(`[Debug] AST file missing at: ${astPath}`);
128
+ return this.createEmptyNode();
129
+ }
130
+ const content = fs.readFileSync(astPath, 'utf-8');
131
+ if (!content || content.trim() === '') {
132
+ return this.createEmptyNode();
133
+ }
134
+ let tu = JSON.parse(content);
135
+ tu = this.filter(sourceFile, tu);
136
+ return tu;
137
+ }
138
+ catch (e) {
139
+ logger.error('Failed to parse AST json:', e);
140
+ return this.createEmptyNode();
141
+ }
142
+ finally {
143
+ this.deleteFileSync(astPath);
144
+ }
145
+ }
146
+ static createEmptyNode() {
147
+ return { kind: '', name: '', code: '', type: { qualType: '' }, inner: [] };
148
+ }
149
+ static updateInner(sourceFile, entry, newInner) {
150
+ if (entry.isImplicit) {
151
+ return;
152
+ }
153
+ const loc = entry.loc;
154
+ if (!loc) {
155
+ logger.warn('Node skipped due to missing "locFile", kind of node: ', entry.kind);
156
+ return;
157
+ }
158
+ newInner.push(entry);
159
+ }
160
+ static filter(sourceFile, translationUnit) {
161
+ const newInner = [];
162
+ for (const entry of translationUnit.inner) {
163
+ this.updateInner(sourceFile, entry, newInner);
164
+ }
165
+ translationUnit.inner = newInner;
166
+ translationUnit.fileName = sourceFile;
167
+ translationUnit.projectName = path.dirname(sourceFile);
168
+ this.fullInfo(translationUnit);
169
+ return translationUnit;
170
+ }
171
+ static filterChildren(cursor) {
172
+ if (!cursor.inner) {
173
+ return [];
174
+ }
175
+ return cursor.inner.filter((item) => !item.isImplicit);
176
+ }
177
+ static makeGetParent(cursor) {
178
+ function getParent(isNeedInner) {
179
+ if (isNeedInner) {
180
+ return Object.assign({}, cursor);
181
+ }
182
+ const { inner } = cursor, rest = __rest(cursor, ["inner"]);
183
+ return rest;
184
+ }
185
+ return getParent;
186
+ }
187
+ static fullInfo(cursor) {
188
+ if (!cursor.inner) {
189
+ cursor.inner = [];
190
+ }
191
+ cursor.inner = this.filterChildren(cursor);
192
+ if (cursor.name === undefined) {
193
+ cursor.name = '';
194
+ }
195
+ if (cursor.kind === 'LambdaExpr') {
196
+ this.processAccess(cursor);
197
+ }
198
+ if (cursor.kind === ArkCxxAstNode_1.astKind.CXXRecordDecl && cursor.tagUsed === 'class') {
199
+ this.currentAccess = 'private';
200
+ }
201
+ else if (cursor.kind === ArkCxxAstNode_1.astKind.CXXRecordDecl && cursor.tagUsed === 'struct') {
202
+ this.currentAccess = 'public';
203
+ }
204
+ else {
205
+ this.currentAccess = '';
206
+ }
207
+ for (const currentCursor of cursor.inner) {
208
+ Object.assign(currentCursor, { getParent: this.makeGetParent(cursor) });
209
+ if (cursor.kind === ArkCxxAstNode_1.astKind.CXXRecordDecl || cursor.kind === ArkCxxAstNode_1.astKind.CXXMethodDecl || cursor.kind === ArkCxxAstNode_1.astKind.FunctionDecl) {
210
+ this.processAccess(currentCursor);
211
+ }
212
+ this.fullInfo(currentCursor);
213
+ }
214
+ }
215
+ static processAccess(cursor) {
216
+ var _a, _b;
217
+ cursor.modifiers = [];
218
+ if (cursor.kind === 'AccessSpecDecl') {
219
+ this.currentAccess = (_b = (_a = cursor.access) !== null && _a !== void 0 ? _a : (0, astUtils_1.extractAllCppModifiers)(cursor.code)[0]) !== null && _b !== void 0 ? _b : '';
220
+ }
221
+ else {
222
+ const extractedCode = this.getCodeForExtractModifiers(cursor);
223
+ const codeModifier = (0, astUtils_1.extractAllCppModifiers)(extractedCode);
224
+ if (this.currentAccess !== '') {
225
+ cursor.modifiers.push(this.currentAccess);
226
+ }
227
+ if (codeModifier !== null) {
228
+ cursor.modifiers.push(...codeModifier);
229
+ }
230
+ }
231
+ }
232
+ static getCodeForExtractModifiers(cursor) {
233
+ const extractedCode = cursor.code;
234
+ if (!['CXXConstructorDecl', 'CXXDestructorDecl', 'CXXMethodDecl', 'FriendDecl', 'FunctionDecl', 'FunctionTemplateDecl'].includes(cursor.kind)) {
235
+ return extractedCode;
236
+ }
237
+ const bodyNode = cursor.inner.filter((inner) => inner.kind === 'CompoundStmt');
238
+ const bodyCode = bodyNode.length === 0 ? '' : bodyNode[0].code;
239
+ return this.stripFucntionParams(extractedCode.replace(bodyCode, ''));
240
+ }
241
+ static stripFucntionParams(code) {
242
+ let depth = 0;
243
+ let start = -1;
244
+ let end = -1;
245
+ for (let i = 0; i < code.length; i++) {
246
+ const ch = code[i];
247
+ if (ch === '(') {
248
+ if (depth === 0) {
249
+ start = i;
250
+ }
251
+ depth++;
252
+ }
253
+ else if (ch === ')') {
254
+ depth--;
255
+ if (depth === 0) {
256
+ end = i;
257
+ break;
258
+ }
259
+ }
260
+ }
261
+ if (start === -1 || end === -1) {
262
+ return code;
263
+ }
264
+ return code.slice(0, start).trimEnd() + ' ' + code.slice(end + 1).trimStart();
265
+ }
266
+ static getAstOutputPath(sourceFile, cppAstPath) {
267
+ const fileName = `${path.parse(path.basename(sourceFile)).name}_AST.json`;
268
+ if (cppAstPath !== '') {
269
+ return path.join(cppAstPath, fileName);
270
+ }
271
+ return path.join(astUtils_1.ClangPath.protectRoot, 'src', 'frontend', 'cppFrontend', 'ast', 'out', fileName);
272
+ }
273
+ static ensureOutputDir(dir) {
274
+ if (!fs.existsSync(dir)) {
275
+ fs.mkdirSync(dir, { recursive: true });
276
+ }
277
+ }
278
+ }
279
+ exports.AstParser = AstParser;
280
+ AstParser.currentAccess = '';
@@ -0,0 +1,18 @@
1
+ export declare function findProjectRoot(startDir?: string): string;
2
+ /**
3
+ * Resolved path to the astJsonDumper N-API addon ({@code astJsonDumper.node} under dumper/ or lib/ast/).
4
+ */
5
+ export declare function getAstJsonDumperNodePath(): string;
6
+ /** True when {@link getAstJsonDumperNodePath} exists on disk. */
7
+ export declare function isAstJsonDumperAvailable(): boolean;
8
+ /** Project-root anchor for C++ AST output paths (legacy name: historically held Clang binary paths). */
9
+ export declare class ClangPath {
10
+ static protectRoot: string;
11
+ }
12
+ export declare function extractAllCppModifiers(code: string): string[];
13
+ /**
14
+ * Find the absolute path of compile_commands.json starting from a file path.
15
+ * Strict logic: only traverses upward (ancestors) to find a ".cxx" directory.
16
+ */
17
+ export declare function findCompileCommands(filePath: string): string;
18
+ //# sourceMappingURL=astUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astUtils.d.ts","sourceRoot":"","sources":["../../../../src/frontend/cppFrontend/ast/astUtils.ts"],"names":[],"mappings":"AAqBA,wBAAgB,eAAe,CAAC,QAAQ,GAAE,MAAkB,GAAG,MAAM,CAYpE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAOjD;AAED,iEAAiE;AACjE,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED,wGAAwG;AACxG,qBAAa,SAAS;IAClB,OAAc,WAAW,SAA8B;CAC1D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB7D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA4B5D"}
@@ -0,0 +1,158 @@
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.findCompileCommands = exports.extractAllCppModifiers = exports.ClangPath = exports.isAstJsonDumperAvailable = exports.getAstJsonDumperNodePath = exports.findProjectRoot = void 0;
41
+ const fs = __importStar(require("fs"));
42
+ const path = __importStar(require("path"));
43
+ // Module level cache: Sub project root directory (including .cxx directory) -> compile_commands.json absolute path
44
+ const ccJsonCache = new Map();
45
+ function findProjectRoot(startDir = __dirname) {
46
+ let dir = path.resolve(startDir);
47
+ while (true) {
48
+ if (fs.existsSync(path.join(dir, 'package.json'))) {
49
+ return dir;
50
+ }
51
+ const parentDir = path.dirname(dir);
52
+ if (parentDir === dir) {
53
+ return dir;
54
+ }
55
+ dir = parentDir;
56
+ }
57
+ }
58
+ exports.findProjectRoot = findProjectRoot;
59
+ /**
60
+ * Resolved path to the astJsonDumper N-API addon ({@code astJsonDumper.node} under dumper/ or lib/ast/).
61
+ */
62
+ function getAstJsonDumperNodePath() {
63
+ const projectRoot = findProjectRoot(__dirname);
64
+ let nodeAddonPath = path.join(projectRoot, 'src', 'frontend', 'cppFrontend', 'ast', 'dumper', 'astJsonDumper.node');
65
+ if (!fs.existsSync(nodeAddonPath)) {
66
+ nodeAddonPath = path.join(projectRoot, 'lib', 'ast', 'astJsonDumper.node');
67
+ }
68
+ return nodeAddonPath;
69
+ }
70
+ exports.getAstJsonDumperNodePath = getAstJsonDumperNodePath;
71
+ /** True when {@link getAstJsonDumperNodePath} exists on disk. */
72
+ function isAstJsonDumperAvailable() {
73
+ return fs.existsSync(getAstJsonDumperNodePath());
74
+ }
75
+ exports.isAstJsonDumperAvailable = isAstJsonDumperAvailable;
76
+ /** Project-root anchor for C++ AST output paths (legacy name: historically held Clang binary paths). */
77
+ class ClangPath {
78
+ }
79
+ exports.ClangPath = ClangPath;
80
+ ClangPath.protectRoot = findProjectRoot(__dirname);
81
+ function extractAllCppModifiers(code) {
82
+ if (!code) {
83
+ return [];
84
+ }
85
+ const cppModifiers = [
86
+ 'static',
87
+ 'public',
88
+ 'private',
89
+ 'protected',
90
+ 'const',
91
+ 'virtual',
92
+ 'inline',
93
+ 'mutable',
94
+ 'explicit',
95
+ 'friend',
96
+ 'constexpr',
97
+ 'volatile'
98
+ ];
99
+ const pattern = new RegExp(`\\b(${cppModifiers.join('|')})\\b`, 'g');
100
+ const matches = code.match(pattern);
101
+ return matches ? matches : [];
102
+ }
103
+ exports.extractAllCppModifiers = extractAllCppModifiers;
104
+ /**
105
+ * Find the absolute path of compile_commands.json starting from a file path.
106
+ * Strict logic: only traverses upward (ancestors) to find a ".cxx" directory.
107
+ */
108
+ function findCompileCommands(filePath) {
109
+ for (const [projectRoot, jsonPath] of ccJsonCache) {
110
+ if (filePath === projectRoot || filePath.startsWith(projectRoot + path.sep)) {
111
+ return jsonPath;
112
+ }
113
+ }
114
+ let currentDir = path.dirname(filePath);
115
+ while (true) {
116
+ const cxxDir = path.join(currentDir, '.cxx');
117
+ if (fs.existsSync(cxxDir) && fs.statSync(cxxDir).isDirectory()) {
118
+ const result = searchCompileCommandsInDir(cxxDir);
119
+ if (result) {
120
+ ccJsonCache.set(currentDir, result);
121
+ return result;
122
+ }
123
+ return '';
124
+ }
125
+ const parent = path.dirname(currentDir);
126
+ if (parent === currentDir) {
127
+ break;
128
+ }
129
+ currentDir = parent;
130
+ }
131
+ return '';
132
+ }
133
+ exports.findCompileCommands = findCompileCommands;
134
+ /**
135
+ * Recursively search for compile_commands.json inside .cxx directory.
136
+ */
137
+ function searchCompileCommandsInDir(dir) {
138
+ let entries;
139
+ try {
140
+ entries = fs.readdirSync(dir, { withFileTypes: true });
141
+ }
142
+ catch (_a) {
143
+ return '';
144
+ }
145
+ for (const entry of entries) {
146
+ const fullPath = path.join(dir, entry.name);
147
+ if (entry.isFile() && entry.name === 'compile_commands.json') {
148
+ return dir;
149
+ }
150
+ if (entry.isDirectory()) {
151
+ const result = searchCompileCommandsInDir(fullPath);
152
+ if (result) {
153
+ return result;
154
+ }
155
+ }
156
+ }
157
+ return '';
158
+ }