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,567 @@
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
+ 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 __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.CxxModelUtils = exports.setTs2CxxFuncMapOfClass = exports.shouldAddCxxHeaderImport = exports.findExportInfo = exports.getArkFile = void 0;
44
+ const ArkFile_1 = require("../../../core/model/ArkFile");
45
+ const ArkSignature_1 = require("../../../core/model/ArkSignature");
46
+ const ArkExport_1 = require("../../../core/model/ArkExport");
47
+ const logger_1 = __importStar(require("../../../utils/logger"));
48
+ const FileUtils_1 = require("../../../utils/FileUtils");
49
+ const path_1 = __importDefault(require("path"));
50
+ const ArkImport_1 = require("../../../core/model/ArkImport");
51
+ const ArkMethod_1 = require("../../../core/model/ArkMethod");
52
+ const ArkClass_1 = require("../../../core/model/ArkClass");
53
+ const Local_1 = require("../../../core/base/Local");
54
+ const Constant_1 = require("../../../core/base/Constant");
55
+ const Const_1 = require("../../../core/common/Const");
56
+ const Type_1 = require("../../../core/base/Type");
57
+ const ArkNamespace_1 = require("../../../core/model/ArkNamespace");
58
+ const ModelUtils_1 = require("../../../core/common/ModelUtils");
59
+ const TypeInference_1 = require("../../../core/common/TypeInference");
60
+ const Type_2 = require("../base/Type");
61
+ // Common C++standard library header files (excluding the .h suffix)
62
+ const CXX_STD_HEADERS = new Set([
63
+ 'iostream',
64
+ 'iomanip',
65
+ 'fstream',
66
+ 'sstream',
67
+ 'string',
68
+ 'vector',
69
+ 'map',
70
+ 'unordered_map',
71
+ 'set',
72
+ 'unordered_set',
73
+ 'queue',
74
+ 'stack',
75
+ 'list',
76
+ 'algorithm',
77
+ 'utility',
78
+ 'memory',
79
+ 'thread',
80
+ 'mutex',
81
+ 'condition_variable',
82
+ 'future',
83
+ 'atomic',
84
+ 'chrono',
85
+ 'functional',
86
+ 'stdexcept',
87
+ 'type_traits',
88
+ 'cassert',
89
+ 'cstdint',
90
+ 'cstdlib',
91
+ 'cstdio',
92
+ 'cstring',
93
+ 'cmath',
94
+ 'array',
95
+ 'bitset',
96
+ 'deque',
97
+ 'tuple',
98
+ 'numeric',
99
+ 'any',
100
+ 'optional',
101
+ 'variant',
102
+ 'filesystem',
103
+ 'span',
104
+ ]);
105
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelUtils');
106
+ /**
107
+ * find arkFile by from info
108
+ * #include "xx/xx.h"
109
+ * @param im importInfo or exportInfo
110
+ */
111
+ function getArkFile(im) {
112
+ let from = im.getFrom();
113
+ if (!from) {
114
+ return null;
115
+ }
116
+ if (!path_1.default.isAbsolute(from)) {
117
+ from = (0, FileUtils_1.getFileAbsPath)([im.getDeclaringArkFile().getFilePath()], from);
118
+ }
119
+ if (!from) {
120
+ return null;
121
+ }
122
+ const scene = im.getDeclaringArkFile().getScene();
123
+ return scene.getFile(new ArkSignature_1.FileSignature(scene.getProjectName(), path_1.default.relative(scene.getRealProjectDir(), from)));
124
+ }
125
+ exports.getArkFile = getArkFile;
126
+ /**
127
+ * #include "xx/xx.h" ==> Precompilation directly expands ==> Equivalent to importing all content of the file ==> Get exportInfo directly from header file
128
+ * find from info's export
129
+ * @param fromInfo importInfo or exportInfo
130
+ * @param fromFile The file where the imported object is located
131
+ */
132
+ function findExportInfo(fromInfo, fromFile) {
133
+ var _a, _b;
134
+ // scenario 1. processing using namespace xxx
135
+ if (fromInfo instanceof ArkImport_1.ImportInfo && fromInfo.getImportType() === 'NamespaceImport' && fromInfo.getFrom() === '') {
136
+ return processNamespaceImport(fromInfo);
137
+ }
138
+ // scenario 2. processing #include "xx.h"
139
+ let file = fromFile !== null && fromFile !== void 0 ? fromFile : getArkFile(fromInfo);
140
+ if (!file) {
141
+ logger.warn(`${fromInfo.getOriginName()} ${fromInfo.getFrom()} file not found: ${(_b = (_a = fromInfo.getDeclaringArkFile()) === null || _a === void 0 ? void 0 : _a.getFileSignature()) === null || _b === void 0 ? void 0 : _b.toString()}`);
142
+ return null;
143
+ }
144
+ if (fromInfo instanceof ArkImport_1.ImportInfo && fromInfo.getImportClauseName().startsWith('#include')) {
145
+ return processIncludeRef(fromInfo, file);
146
+ }
147
+ return processHeaderExportInfos(fromInfo, file);
148
+ }
149
+ exports.findExportInfo = findExportInfo;
150
+ function shouldAddCxxHeaderImport(element) {
151
+ if (!Object.prototype.hasOwnProperty.call(element, 'importClauseName')) {
152
+ return false;
153
+ }
154
+ return isValidCxxHeaderPath(element.getImportClauseName());
155
+ }
156
+ exports.shouldAddCxxHeaderImport = shouldAddCxxHeaderImport;
157
+ function processNamespaceImport(fromInfo) {
158
+ var _a, _b;
159
+ const declFile = fromInfo.getDeclaringArkFile();
160
+ const namespaceName = fromInfo.getImportClauseName();
161
+ // namespace is from current file or importInfo
162
+ let lazyExportInfo = (_a = declFile.getExportInfoBy(namespaceName)) !== null && _a !== void 0 ? _a : (_b = declFile.getImportInfoBy(namespaceName)) === null || _b === void 0 ? void 0 : _b.getExportInfo();
163
+ if (lazyExportInfo) {
164
+ let arkExport = lazyExportInfo.getArkExport() || null;
165
+ lazyExportInfo.setArkExport(arkExport);
166
+ if (!arkExport) {
167
+ return lazyExportInfo;
168
+ }
169
+ lazyExportInfo.setExportClauseType(ArkExport_1.ExportType.NAME_SPACE);
170
+ // If the namespace is imported in a header file, it is necessary to construct the exportInfo for the imported namespace.
171
+ if (isValidCxxHeaderPath(declFile.getFilePath())) {
172
+ const namespaceExportInfo = new ArkExport_1.ExportInfo.Builder()
173
+ .exportClauseType(ArkExport_1.ExportType.NAME_SPACE)
174
+ .exportClauseName(namespaceName)
175
+ .declaringArkFile(declFile)
176
+ .arkExport(arkExport)
177
+ .build();
178
+ declFile.addExportInfo(namespaceExportInfo);
179
+ }
180
+ return lazyExportInfo;
181
+ }
182
+ return null;
183
+ }
184
+ function isValidCxxHeaderPath(headerPath) {
185
+ if (!headerPath) {
186
+ return false;
187
+ }
188
+ const normalized = headerPath.replace(/\\/g, '/').toLowerCase();
189
+ // Check the sdk/default path
190
+ if (normalized.includes('sdk/default')) {
191
+ return false;
192
+ }
193
+ // Split the path and check the last file name
194
+ const parts = normalized.split('/');
195
+ let filename = parts.length > 0 ? parts[parts.length - 1] : '';
196
+ filename = filename.replace('"', '');
197
+ // Determine whether it is a standard library name or a standard library name+ h
198
+ if (CXX_STD_HEADERS.has(filename) || (filename.endsWith('.h') && CXX_STD_HEADERS.has(filename.replace(/\.h$/, '')))) {
199
+ return false;
200
+ }
201
+ return true;
202
+ }
203
+ /* Handling header file references for # include "xx/xx. h" */
204
+ function processIncludeRef(fromInfo, headerFile) {
205
+ var _a, _b;
206
+ // 1.Construct # include "xxx/xx" The exportInfo referenced by the header file is the DefaultClass of the header file
207
+ const includeExportInfo = new ArkExport_1.ExportInfo.Builder()
208
+ .exportClauseType(ArkExport_1.ExportType.CLASS)
209
+ .exportClauseName(`#include "${fromInfo.getFrom()}"`)
210
+ .declaringArkFile(headerFile)
211
+ .arkExport(headerFile.getDefaultClass())
212
+ .build();
213
+ // 2.Add the exportInfo of the header file to the importInfoMaps of the current file, and set lazyImportInfo
214
+ const declFile = fromInfo.getDeclaringArkFile();
215
+ let includeClauseName = fromInfo.getImportClauseName();
216
+ for (const exportInfo of headerFile.getExportInfos()) {
217
+ let headerRealIm = new ArkImport_1.ImportInfo();
218
+ // if there is "using namespace xxx" in declFile or the indirectly referenced file, we should keep the original import type
219
+ const curClauseName = exportInfo.getExportClauseName();
220
+ let importType;
221
+ if (((_a = declFile.getImportInfoBy(curClauseName)) === null || _a === void 0 ? void 0 : _a.getImportType()) === 'NamespaceImport' ||
222
+ ((_b = headerFile.getImportInfoBy(curClauseName)) === null || _b === void 0 ? void 0 : _b.getImportType()) === 'NamespaceImport') {
223
+ importType = 'NamespaceImport';
224
+ }
225
+ else {
226
+ importType = 'NamedImports';
227
+ }
228
+ headerRealIm.build(curClauseName, importType, headerFile.getFilePath(), exportInfo.getOriginTsPosition(), 0);
229
+ headerRealIm.setTsSourceCode(includeClauseName);
230
+ headerRealIm.setDeclaringArkFile(declFile);
231
+ if (shouldAddCxxHeaderImport(headerRealIm)) {
232
+ declFile.addImportInfo(headerRealIm);
233
+ }
234
+ headerRealIm.getLazyExportInfo(); // The findExportInfo function will be recursed
235
+ }
236
+ // 3.Add the importInfos of the header file to the importInfoMaps of the current file, and set lazyImportInfo
237
+ for (const im of headerFile.getImportInfos()) {
238
+ if (declFile.getImportInfoBy(im.getImportClauseName())) {
239
+ continue;
240
+ }
241
+ if (shouldAddCxxHeaderImport(im)) {
242
+ declFile.addImportInfo(im);
243
+ }
244
+ im.getLazyExportInfo();
245
+ }
246
+ return includeExportInfo;
247
+ }
248
+ /* Process the exportInfo of the header file (as the current file named importInfo) */
249
+ function processHeaderExportInfos(fromInfo, headerFile) {
250
+ const exportName = fromInfo.getOriginName();
251
+ let exportInfo = headerFile.getExportInfoBy(exportName);
252
+ if (!exportInfo) {
253
+ return null;
254
+ }
255
+ let arkExport = exportInfo.getArkExport() || null;
256
+ exportInfo.setArkExport(arkExport);
257
+ if (arkExport) {
258
+ exportInfo.setExportClauseType(arkExport.getExportType());
259
+ }
260
+ return exportInfo;
261
+ }
262
+ /**
263
+ * Record the mapping relationship between cpp functions and ts functions (when there are napi_property_descriptor and napi_define_class identifiers)
264
+ * @param elementValues Value of each actual parameter of the function describing the mapping relationship
265
+ * @param isDefineClass Whether it is a napi_define_class identifier
266
+ * @param declMethod The ArkMethod where the call is located
267
+ * @return None
268
+ */
269
+ function setTs2CxxFuncMapOfClass(elementValues, isDefineClass, declMethod) {
270
+ const curArkClass = declMethod.getDeclaringArkClass();
271
+ const dfltArkClass = declMethod.getDeclaringArkFile().getDefaultClass();
272
+ if (!(curArkClass && dfltArkClass)) {
273
+ return;
274
+ }
275
+ let funcElements;
276
+ let tsFuncNameIdx;
277
+ if (isDefineClass) {
278
+ // napi_define_class sets the constructor of the externally exposed class
279
+ funcElements = elementValues.length > 4 ? [elementValues[3]] : [];
280
+ tsFuncNameIdx = 1;
281
+ }
282
+ else {
283
+ // Fields set by functions in napi_property_descriptor
284
+ funcElements = elementValues.length > 5 ? elementValues.slice(2, 5) : [];
285
+ tsFuncNameIdx = 0;
286
+ }
287
+ const cxxFunc = findMatchingCxxMethod(funcElements, declMethod);
288
+ if (elementValues[tsFuncNameIdx] instanceof Constant_1.StringConstant) {
289
+ dfltArkClass.addTs2cxxFuncMapElement(elementValues[tsFuncNameIdx].getValue(), cxxFunc);
290
+ }
291
+ }
292
+ exports.setTs2CxxFuncMapOfClass = setTs2CxxFuncMapOfClass;
293
+ /**
294
+ * Find the actual cpp function corresponding to the function pointer in the mapping function
295
+ * @param funcElements Value array corresponding to function pointers
296
+ * @param declMethod The ArkMethod where the call is located
297
+ * @return Returns the found matching function array
298
+ */
299
+ function findMatchingCxxMethod(funcElements, declMethod) {
300
+ var _a;
301
+ const cxxFunc = [];
302
+ const currArkClass = declMethod.getDeclaringArkClass();
303
+ const classesToBeSearched = [];
304
+ classesToBeSearched.push(currArkClass, ...getIncludeDefaultClasses(declMethod));
305
+ const scene = currArkClass.getDeclaringArkFile().getScene();
306
+ for (const element of funcElements) {
307
+ if (!(element instanceof Local_1.Local)) {
308
+ continue;
309
+ }
310
+ let funcRef = element;
311
+ const mtdName = funcRef.getName();
312
+ // If it is local and in %num format => %num = A.b, it should actually be a member of a class
313
+ if (mtdName.startsWith(Const_1.TEMP_LOCAL_PREFIX)) {
314
+ const realType = funcRef.getType();
315
+ if (!(realType instanceof Type_1.FunctionType)) {
316
+ continue;
317
+ }
318
+ let matchMtd = scene.getMethod(realType.getMethodSignature());
319
+ if (matchMtd) {
320
+ matchMtd = getFuncImplement(matchMtd);
321
+ cxxFunc.push(matchMtd);
322
+ }
323
+ continue;
324
+ }
325
+ // If it is local and does not start with "%" => Member function of current class or global function
326
+ for (const cls of classesToBeSearched) {
327
+ let matchMtd = (_a = cls.getMethodWithName(mtdName)) !== null && _a !== void 0 ? _a : cls.getStaticMethodWithName(mtdName);
328
+ if (matchMtd) {
329
+ matchMtd = getFuncImplement(matchMtd);
330
+ cxxFunc.push(matchMtd);
331
+ }
332
+ }
333
+ }
334
+ return cxxFunc;
335
+ }
336
+ /**
337
+ * Get the defaultClass of the include header files of the file to which the current arkInstance belongs
338
+ * @param arkInstance Instance of ArkIR
339
+ * @return Returns all qualified defaultClasses obtained
340
+ */
341
+ function getIncludeDefaultClasses(arkInstance) {
342
+ const defaultClasses = [];
343
+ if (arkInstance instanceof ArkMethod_1.ArkMethod || arkInstance instanceof ArkClass_1.ArkClass) {
344
+ arkInstance = arkInstance.getDeclaringArkFile();
345
+ }
346
+ const includeFiles = [];
347
+ for (const info of arkInstance.getImportInfos()) {
348
+ const imFrom = info.getFrom();
349
+ if (!imFrom) {
350
+ continue;
351
+ }
352
+ includeFiles.push(imFrom);
353
+ }
354
+ if (includeFiles.length === 0) {
355
+ return defaultClasses;
356
+ }
357
+ const scene = arkInstance.getScene();
358
+ scene.getFiles().forEach(file => {
359
+ if (file.getLanguage() !== ArkFile_1.Language.CXX || !includeFiles.includes(file.getFilePath())) {
360
+ return;
361
+ }
362
+ defaultClasses.push(file.getDefaultClass());
363
+ });
364
+ return defaultClasses;
365
+ }
366
+ function getFuncImplement(mtd) {
367
+ if (mtd.isDefaultArkMethod() || mtd.getName() === Const_1.INSTANCE_INIT_METHOD_NAME || mtd.getName() === Const_1.STATIC_INIT_METHOD_NAME) {
368
+ return mtd;
369
+ }
370
+ const realImplSignature = mtd.getImplementationSignature();
371
+ if (!realImplSignature) {
372
+ return mtd;
373
+ }
374
+ const realImplMtd = mtd.getDeclaringArkFile().getScene().getMethod(realImplSignature);
375
+ if (!realImplMtd || !realImplMtd.getImplementationSignature()) {
376
+ return mtd;
377
+ }
378
+ return realImplMtd;
379
+ }
380
+ class CxxModelUtils {
381
+ static getArkExportInImportInfoWithName(name, arkFile, arkClass) {
382
+ var _a, _b, _c;
383
+ let arkExport = (_b = (_a = arkFile.getImportInfoBy(name)) === null || _a === void 0 ? void 0 : _a.getLazyExportInfo()) === null || _b === void 0 ? void 0 : _b.getArkExport();
384
+ if (arkExport) {
385
+ return arkExport;
386
+ }
387
+ let declNamespace;
388
+ if (arkClass) {
389
+ declNamespace = arkClass.getDeclaringArkNamespace();
390
+ }
391
+ // if using namespace or use type in same name namespace in file,we can call the method or class in the namespace without a prefix.
392
+ for (const im of arkFile.getImportInfos()) {
393
+ const imArkExport = (_c = im.getLazyExportInfo()) === null || _c === void 0 ? void 0 : _c.getArkExport();
394
+ if (!(imArkExport instanceof ArkNamespace_1.ArkNamespace)) {
395
+ continue;
396
+ }
397
+ const imNS = imArkExport;
398
+ // using namespace xxx
399
+ if (im.getImportType() === 'NamespaceImport') {
400
+ arkExport = CxxModelUtils.findPropertyInNamespace(name, imNS);
401
+ if (arkExport) {
402
+ return arkExport;
403
+ }
404
+ }
405
+ // infer type within the same namespace across different files
406
+ if ((declNamespace === null || declNamespace === void 0 ? void 0 : declNamespace.getName()) !== imNS.getName()) {
407
+ continue;
408
+ }
409
+ arkExport = CxxModelUtils.findPropertyInNamespace(name, imNS);
410
+ if (arkExport) {
411
+ return arkExport;
412
+ }
413
+ }
414
+ return null;
415
+ }
416
+ static findPropertyInClass(name, arkClass) {
417
+ var _a, _b, _c, _d, _e;
418
+ let property = (_d = (_c = (_b = (_a = arkClass.getMethodWithName(name)) !== null && _a !== void 0 ? _a : arkClass.getStaticMethodWithName(name)) !== null && _b !== void 0 ? _b : arkClass.getMethodWithName('Get-' + name)) !== null && _c !== void 0 ? _c : arkClass.getFieldWithName(name)) !== null && _d !== void 0 ? _d : arkClass.getStaticFieldWithName(name);
419
+ if (property) {
420
+ return property;
421
+ }
422
+ if (arkClass.isDefaultArkClass()) {
423
+ return (0, ModelUtils_1.findArkExport)(arkClass.getDeclaringArkFile().getExportInfoBy(name));
424
+ }
425
+ // In cases where a class's declaration and definition are separated, we may consider searching for the property at the class declaration.
426
+ const clsDeclareSignature = arkClass.getDeclareSignature();
427
+ let declClass;
428
+ if (clsDeclareSignature) {
429
+ declClass = (_e = arkClass.getDeclaringArkFile().getScene().getFile(clsDeclareSignature.getDeclaringFileSignature())) === null || _e === void 0 ? void 0 : _e.getClass(clsDeclareSignature);
430
+ }
431
+ const heritageClasses = arkClass.getAllHeritageClasses();
432
+ if (declClass) {
433
+ property = this.findPropertyInClass(name, declClass);
434
+ if (property) {
435
+ return property;
436
+ }
437
+ heritageClasses.push(...declClass.getAllHeritageClasses());
438
+ }
439
+ for (const heritage of heritageClasses) {
440
+ property = this.findPropertyInClass(name, heritage);
441
+ if (property) {
442
+ return property;
443
+ }
444
+ }
445
+ const objectClass = arkClass.getDeclaringArkFile().getScene().getSdkGlobal('Object');
446
+ if (objectClass instanceof ArkClass_1.ArkClass && arkClass !== objectClass) {
447
+ return this.findPropertyInClass(name, objectClass);
448
+ }
449
+ return null;
450
+ }
451
+ static getClassFromAnonymousNamespaceByName(className, declFile) {
452
+ const anonyNamespaces = declFile.getNamespaces().filter(ns => ns.getName().startsWith(Const_1.ANONYMOUS_NAMESPACE_PREFIX));
453
+ for (const anonyNamespace of anonyNamespaces) {
454
+ const matchedClass = anonyNamespace.getClassWithName(className);
455
+ if (matchedClass) {
456
+ return matchedClass;
457
+ }
458
+ }
459
+ return null;
460
+ }
461
+ static getStaticMethodWithName(methodName, thisClass) {
462
+ const thisNamespace = thisClass.getDeclaringArkNamespace();
463
+ if (thisNamespace) {
464
+ const defaultClass = thisNamespace.getClassWithName(Const_1.DEFAULT_ARK_CLASS_NAME);
465
+ if (defaultClass) {
466
+ const method = defaultClass.getMethodWithName(methodName);
467
+ if (method) {
468
+ return method;
469
+ }
470
+ }
471
+ }
472
+ return this.getStaticMethodInFileWithName(methodName, thisClass.getDeclaringArkFile());
473
+ }
474
+ static getStaticMethodInFileWithName(methodName, arkFile) {
475
+ const anonymousNamespaces = this.getAccessibleAnonNamespacesInFile(arkFile);
476
+ const allDefaultClasses = [];
477
+ allDefaultClasses.push(arkFile.getDefaultClass());
478
+ anonymousNamespaces.forEach(ns => {
479
+ allDefaultClasses.push(ns.getDefaultClass());
480
+ });
481
+ for (const defaultClass of allDefaultClasses) {
482
+ let method = defaultClass.getMethodWithName(methodName);
483
+ if (method) {
484
+ return method;
485
+ }
486
+ }
487
+ return null;
488
+ }
489
+ static getAccessibleAnonNamespacesInFile(file, namespace) {
490
+ const anonymousNamespaces = [];
491
+ const traversableNamespace = namespace ? namespace.getNamespaces() : file.getNamespaces();
492
+ for (const ns of traversableNamespace) {
493
+ if (ns.getName().startsWith(Const_1.ANONYMOUS_NAMESPACE_PREFIX)) {
494
+ anonymousNamespaces.push(ns);
495
+ anonymousNamespaces.push(...this.getAccessibleAnonNamespacesInFile(file, ns));
496
+ }
497
+ }
498
+ return anonymousNamespaces;
499
+ }
500
+ static findPropertyInNamespace(name, namespace) {
501
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
502
+ const allAccessibleNamespaces = [namespace];
503
+ allAccessibleNamespaces.push(...this.getAccessibleAnonNamespacesInFile(namespace.getDeclaringArkFile(), namespace));
504
+ for (const ns of allAccessibleNamespaces) {
505
+ const property = (_j = (_e = (_d = (_c = (_b = (_a = ns.getDefaultClass()) === null || _a === void 0 ? void 0 : _a.getMethodWithName(name)) !== null && _b !== void 0 ? _b : (0, ModelUtils_1.findArkExport)(ns.getExportInfoBy(name))) !== null && _c !== void 0 ? _c : ns.getClassWithName(name)) !== null && _d !== void 0 ? _d : ns.getNamespaceWithName(name)) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = ns.getDefaultClass()) === null || _f === void 0 ? void 0 : _f.getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name)) !== null && _j !== void 0 ? _j : (_o = (_m = (_l = (_k = ns.getDefaultClass()) === null || _k === void 0 ? void 0 : _k.getDefaultArkMethod()) === null || _l === void 0 ? void 0 : _l.getBody()) === null || _m === void 0 ? void 0 : _m.getLocals()) === null || _o === void 0 ? void 0 : _o.get(name);
506
+ if (property) {
507
+ return property;
508
+ }
509
+ }
510
+ return undefined;
511
+ }
512
+ static findSymbolInFileWithName(symbolName, arkClass, onlyType = false) {
513
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
514
+ // find symbol from enum value
515
+ if (arkClass.getCategory() === ArkClass_1.ClassCategory.ENUM) {
516
+ const field = arkClass.getStaticFieldWithName(symbolName);
517
+ if (field) {
518
+ return new Local_1.Local(symbolName, (_a = TypeInference_1.TypeInference.getEnumValueType(field)) !== null && _a !== void 0 ? _a : field.getType());
519
+ }
520
+ }
521
+ // look up symbol from inner to outer
522
+ let currNamespace = arkClass.getDeclaringArkNamespace();
523
+ let result;
524
+ while (currNamespace) {
525
+ result = this.findPropertyInNamespace(symbolName, currNamespace);
526
+ if (result) {
527
+ return result;
528
+ }
529
+ currNamespace = currNamespace.getDeclaringArkNamespace();
530
+ }
531
+ const file = arkClass.getDeclaringArkFile();
532
+ result =
533
+ (_e = (_b = file.getClassWithName(symbolName)) !== null && _b !== void 0 ? _b : (_d = (_c = file.getDefaultClass().getDefaultArkMethod()) === null || _c === void 0 ? void 0 : _c.getBody()) === null || _d === void 0 ? void 0 : _d.getAliasTypeByName(symbolName)) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = file.getDefaultClass()) === null || _f === void 0 ? void 0 : _f.getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getLocals().get(symbolName);
534
+ if (!result && !onlyType) {
535
+ result = (_j = file.getNamespaceWithName(symbolName)) !== null && _j !== void 0 ? _j : file.getDefaultClass().getMethodWithName(symbolName);
536
+ }
537
+ if (result) {
538
+ return result;
539
+ }
540
+ const allAnonyNamespaces = this.getAccessibleAnonNamespacesInFile(file);
541
+ for (const ns of allAnonyNamespaces) {
542
+ result = this.findPropertyInNamespace(symbolName, ns);
543
+ if (result) {
544
+ return result;
545
+ }
546
+ }
547
+ return null;
548
+ }
549
+ static isIOStreamObjectMatched(parameters, args, scene) {
550
+ // Compare the output object directly, i.e., the last param/arg
551
+ const lastParam = parameters.length > 0 ? parameters[parameters.length - 1] : null;
552
+ const lastArg = args.length > 0 ? args[args.length - 1] : null;
553
+ if (!lastParam || !lastArg) {
554
+ return false;
555
+ }
556
+ let lastParamType = lastParam.getType();
557
+ let lastArgType = lastArg.getType();
558
+ if (lastParamType instanceof Type_2.ReferenceType) {
559
+ lastParamType = lastParamType.getBaseType();
560
+ }
561
+ if (lastArgType instanceof Type_2.ReferenceType) {
562
+ lastArgType = lastArgType.getBaseType();
563
+ }
564
+ return ModelUtils_1.ModelUtils.matchType(lastParamType, lastArgType, lastArg, scene);
565
+ }
566
+ }
567
+ exports.CxxModelUtils = CxxModelUtils;