arkanalyzer 1.0.93 → 2.0.0-beta1

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 (326) hide show
  1. package/lib/Config.d.ts +7 -0
  2. package/lib/Config.d.ts.map +1 -1
  3. package/lib/Scene.d.ts +134 -170
  4. package/lib/Scene.d.ts.map +1 -1
  5. package/lib/Scene.js +412 -976
  6. package/lib/callgraph/algorithm/AbstractAnalysis.js +3 -2
  7. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
  8. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +2 -3
  9. package/lib/callgraph/model/CallGraph.js +1 -1
  10. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +1 -3
  11. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
  12. package/lib/callgraph/pointerAnalysis/PTAUtils.js +17 -7
  13. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  14. package/lib/callgraph/pointerAnalysis/Pag.js +4 -14
  15. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  16. package/lib/callgraph/pointerAnalysis/PagBuilder.js +2 -1
  17. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  18. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +1 -2
  19. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.d.ts.map +1 -1
  20. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +0 -1
  21. package/lib/cli/commands/cg.d.ts +1 -0
  22. package/lib/cli/commands/cg.d.ts.map +1 -1
  23. package/lib/cli/commands/cg.js +22 -18
  24. package/lib/cli/commands/ir.d.ts +1 -0
  25. package/lib/cli/commands/ir.d.ts.map +1 -1
  26. package/lib/cli/commands/ir.js +5 -2
  27. package/lib/core/base/Constant.d.ts +5 -5
  28. package/lib/core/base/Constant.d.ts.map +1 -1
  29. package/lib/core/base/Constant.js +12 -9
  30. package/lib/core/base/Expr.d.ts +36 -20
  31. package/lib/core/base/Expr.d.ts.map +1 -1
  32. package/lib/core/base/Expr.js +206 -94
  33. package/lib/core/base/Local.d.ts +10 -20
  34. package/lib/core/base/Local.d.ts.map +1 -1
  35. package/lib/core/base/Local.js +25 -28
  36. package/lib/core/base/Position.d.ts +6 -0
  37. package/lib/core/base/Position.d.ts.map +1 -1
  38. package/lib/core/base/Position.js +37 -11
  39. package/lib/core/base/Ref.d.ts +45 -33
  40. package/lib/core/base/Ref.d.ts.map +1 -1
  41. package/lib/core/base/Ref.js +225 -51
  42. package/lib/core/base/Stmt.d.ts +19 -9
  43. package/lib/core/base/Stmt.d.ts.map +1 -1
  44. package/lib/core/base/Stmt.js +135 -52
  45. package/lib/core/base/Type.d.ts +67 -4
  46. package/lib/core/base/Type.d.ts.map +1 -1
  47. package/lib/core/base/Type.js +391 -20
  48. package/lib/core/base/TypeExpr.d.ts +6 -4
  49. package/lib/core/base/TypeExpr.d.ts.map +1 -1
  50. package/lib/core/base/TypeExpr.js +34 -10
  51. package/lib/core/base/Value.d.ts +20 -2
  52. package/lib/core/base/Value.d.ts.map +1 -1
  53. package/lib/core/base/Value.js +12 -0
  54. package/lib/core/common/ArkIRTransformer.d.ts +18 -0
  55. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  56. package/lib/core/common/ArkIRTransformer.js +94 -75
  57. package/lib/core/common/ArkValueTransformer.d.ts +21 -3
  58. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  59. package/lib/core/common/ArkValueTransformer.js +458 -266
  60. package/lib/core/common/Builtin.d.ts +48 -24
  61. package/lib/core/common/Builtin.d.ts.map +1 -1
  62. package/lib/core/common/Builtin.js +90 -52
  63. package/lib/core/common/CanonicalizerValidator.d.ts +308 -0
  64. package/lib/core/common/CanonicalizerValidator.d.ts.map +1 -0
  65. package/lib/core/common/CanonicalizerValidator.js +888 -0
  66. package/lib/core/common/Const.d.ts +3 -3
  67. package/lib/core/common/Const.d.ts.map +1 -1
  68. package/lib/core/common/Const.js +3 -3
  69. package/lib/core/common/DummyMainCreater.d.ts +2 -21
  70. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  71. package/lib/core/common/DummyMainCreater.js +8 -105
  72. package/lib/core/common/IRInference.d.ts +55 -3
  73. package/lib/core/common/IRInference.d.ts.map +1 -1
  74. package/lib/core/common/IRInference.js +407 -126
  75. package/lib/core/common/IRUtils.d.ts +1 -0
  76. package/lib/core/common/IRUtils.d.ts.map +1 -1
  77. package/lib/core/common/IRUtils.js +44 -13
  78. package/lib/core/common/ModelUtils.d.ts +44 -20
  79. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  80. package/lib/core/common/ModelUtils.js +378 -208
  81. package/lib/core/common/SdkUtils.d.ts +35 -5
  82. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  83. package/lib/core/common/SdkUtils.js +203 -59
  84. package/lib/core/common/SignatureCanonicalizer.d.ts +95 -0
  85. package/lib/core/common/SignatureCanonicalizer.d.ts.map +1 -0
  86. package/lib/core/common/SignatureCanonicalizer.js +116 -0
  87. package/lib/core/common/SignatureCanonicalizerRegistry.d.ts +176 -0
  88. package/lib/core/common/SignatureCanonicalizerRegistry.d.ts.map +1 -0
  89. package/lib/core/common/SignatureCanonicalizerRegistry.js +343 -0
  90. package/lib/core/common/SignatureModelCanonicalizer.d.ts +69 -0
  91. package/lib/core/common/SignatureModelCanonicalizer.d.ts.map +1 -0
  92. package/lib/core/common/SignatureModelCanonicalizer.js +109 -0
  93. package/lib/core/common/StmtUseReplacer.d.ts +1 -0
  94. package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
  95. package/lib/core/common/StmtUseReplacer.js +9 -0
  96. package/lib/core/common/StringUtils.d.ts +12 -1
  97. package/lib/core/common/StringUtils.d.ts.map +1 -1
  98. package/lib/core/common/StringUtils.js +36 -17
  99. package/lib/core/common/TempSignatureCanonicalizer.d.ts +82 -0
  100. package/lib/core/common/TempSignatureCanonicalizer.d.ts.map +1 -0
  101. package/lib/core/common/TempSignatureCanonicalizer.js +177 -0
  102. package/lib/core/common/TypeInference.d.ts +24 -6
  103. package/lib/core/common/TypeInference.d.ts.map +1 -1
  104. package/lib/core/common/TypeInference.js +243 -117
  105. package/lib/core/common/ValueUtil.d.ts +2 -1
  106. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  107. package/lib/core/common/ValueUtil.js +4 -1
  108. package/lib/core/graph/Cfg.d.ts.map +1 -1
  109. package/lib/core/graph/Cfg.js +21 -6
  110. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  111. package/lib/core/graph/builder/CfgBuilder.js +46 -33
  112. package/lib/core/graph/builder/IfBuilder.d.ts.map +1 -1
  113. package/lib/core/graph/builder/IfBuilder.js +6 -2
  114. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  115. package/lib/core/graph/builder/ViewTreeBuilder.js +6 -2
  116. package/lib/core/inference/ModelInference.d.ts +24 -4
  117. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  118. package/lib/core/inference/ModelInference.js +273 -79
  119. package/lib/core/inference/ValueInference.d.ts +3 -2
  120. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  121. package/lib/core/inference/ValueInference.js +90 -40
  122. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  123. package/lib/core/inference/abc/AbcInference.js +28 -15
  124. package/lib/core/inference/arkts/ArkTsInference.d.ts +9 -3
  125. package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
  126. package/lib/core/inference/arkts/ArkTsInference.js +54 -16
  127. package/lib/core/model/ArkClass.d.ts +192 -18
  128. package/lib/core/model/ArkClass.d.ts.map +1 -1
  129. package/lib/core/model/ArkClass.js +852 -122
  130. package/lib/core/model/ArkExport.d.ts.map +1 -1
  131. package/lib/core/model/ArkExport.js +1 -2
  132. package/lib/core/model/ArkField.d.ts +34 -2
  133. package/lib/core/model/ArkField.d.ts.map +1 -1
  134. package/lib/core/model/ArkField.js +89 -14
  135. package/lib/core/model/ArkFile.d.ts +72 -12
  136. package/lib/core/model/ArkFile.d.ts.map +1 -1
  137. package/lib/core/model/ArkFile.js +275 -65
  138. package/lib/core/model/ArkImport.d.ts.map +1 -1
  139. package/lib/core/model/ArkImport.js +1 -2
  140. package/lib/core/model/ArkMethod.d.ts +101 -15
  141. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  142. package/lib/core/model/ArkMethod.js +252 -39
  143. package/lib/core/model/ArkModule.d.ts +1 -1
  144. package/lib/core/model/ArkModule.js +1 -1
  145. package/lib/core/model/ArkNamespace.d.ts +80 -10
  146. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  147. package/lib/core/model/ArkNamespace.js +309 -76
  148. package/lib/core/model/ArkSignature.d.ts +242 -18
  149. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  150. package/lib/core/model/ArkSignature.js +725 -95
  151. package/lib/core/model/builder/ArkClassBuilder.d.ts +6 -3
  152. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  153. package/lib/core/model/builder/ArkClassBuilder.js +119 -73
  154. package/lib/core/model/builder/ArkExportBuilder.d.ts +1 -1
  155. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
  156. package/lib/core/model/builder/ArkExportBuilder.js +1 -1
  157. package/lib/core/model/builder/ArkFieldBuilder.d.ts +0 -2
  158. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  159. package/lib/core/model/builder/ArkFieldBuilder.js +9 -43
  160. package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
  161. package/lib/core/model/builder/ArkFileBuilder.js +32 -33
  162. package/lib/core/model/builder/ArkMethodBuilder.d.ts +10 -3
  163. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  164. package/lib/core/model/builder/ArkMethodBuilder.js +40 -26
  165. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +3 -2
  166. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  167. package/lib/core/model/builder/ArkNamespaceBuilder.js +45 -77
  168. package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
  169. package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
  170. package/lib/core/model/builder/ArkSignatureBuilder.js +26 -3
  171. package/lib/core/model/builder/BodyBuilder.d.ts +1 -0
  172. package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
  173. package/lib/core/model/builder/BodyBuilder.js +37 -11
  174. package/lib/core/model/builder/builderUtils.d.ts +11 -1
  175. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  176. package/lib/core/model/builder/builderUtils.js +124 -90
  177. package/lib/frontend/FrontendBuilder.d.ts +10 -6
  178. package/lib/frontend/FrontendBuilder.d.ts.map +1 -1
  179. package/lib/frontend/FrontendBuilder.js +19 -45
  180. package/lib/frontend/ModuleScene.d.ts +43 -0
  181. package/lib/frontend/ModuleScene.d.ts.map +1 -0
  182. package/lib/frontend/ModuleScene.js +143 -0
  183. package/lib/frontend/SceneBuildStage.d.ts +15 -0
  184. package/lib/frontend/SceneBuildStage.d.ts.map +1 -0
  185. package/lib/frontend/SceneBuildStage.js +32 -0
  186. package/lib/frontend/SceneBuilder.d.ts +153 -0
  187. package/lib/frontend/SceneBuilder.d.ts.map +1 -0
  188. package/lib/frontend/SceneBuilder.js +859 -0
  189. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +0 -2
  190. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -1
  191. package/lib/frontend/arktsFrontend/ArktsFrontend.js +0 -18
  192. package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts +17 -0
  193. package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts.map +1 -0
  194. package/lib/frontend/arktsFrontend/FileBodyRemount.js +187 -0
  195. package/lib/frontend/common/ModuleBuilder.d.ts +4 -2
  196. package/lib/frontend/common/ModuleBuilder.d.ts.map +1 -1
  197. package/lib/frontend/common/ModuleBuilder.js +19 -9
  198. package/lib/frontend/cppFrontend/CppFrontend.d.ts +0 -6
  199. package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -1
  200. package/lib/frontend/cppFrontend/CppFrontend.js +0 -56
  201. package/lib/frontend/cppFrontend/base/Type.d.ts +7 -0
  202. package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -1
  203. package/lib/frontend/cppFrontend/base/Type.js +29 -0
  204. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
  205. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +56 -56
  206. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
  207. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
  208. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +124 -113
  209. package/lib/frontend/cppFrontend/common/Builtin.d.ts +29 -19
  210. package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -1
  211. package/lib/frontend/cppFrontend/common/Builtin.js +56 -35
  212. package/lib/frontend/cppFrontend/common/IRInference.d.ts +7 -2
  213. package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -1
  214. package/lib/frontend/cppFrontend/common/IRInference.js +61 -28
  215. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -0
  216. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
  217. package/lib/frontend/cppFrontend/common/IRUtils.js +22 -10
  218. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +19 -0
  219. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -1
  220. package/lib/frontend/cppFrontend/common/ModelUtils.js +84 -3
  221. package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -1
  222. package/lib/frontend/cppFrontend/common/TypeInference.js +44 -54
  223. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
  224. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +2 -1
  225. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +1 -1
  226. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -1
  227. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -1
  228. package/lib/frontend/cppFrontend/inference/CxxValueInference.js +41 -5
  229. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
  230. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +18 -28
  231. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  232. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +2 -3
  233. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +2 -2
  234. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
  235. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +31 -24
  236. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  237. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +10 -16
  238. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +0 -2
  239. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  240. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +19 -37
  241. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -0
  242. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
  243. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +30 -3
  244. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
  245. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +8 -4
  246. package/lib/index.d.ts +3 -0
  247. package/lib/index.d.ts.map +1 -1
  248. package/lib/index.js +10 -2
  249. package/lib/save/json/JsonSerialization.js +2 -2
  250. package/lib/save/source/SourceStmt.js +1 -1
  251. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  252. package/lib/save/source/SourceTransformer.js +0 -9
  253. package/lib/statistics/StageStatistics.d.ts +195 -0
  254. package/lib/statistics/StageStatistics.d.ts.map +1 -0
  255. package/lib/statistics/StageStatistics.js +346 -0
  256. package/lib/statistics/StageStatisticsReporter.d.ts +58 -0
  257. package/lib/statistics/StageStatisticsReporter.d.ts.map +1 -0
  258. package/lib/statistics/StageStatisticsReporter.js +255 -0
  259. package/lib/utils/Canonicalizer.d.ts +9 -2
  260. package/lib/utils/Canonicalizer.d.ts.map +1 -1
  261. package/lib/utils/Canonicalizer.js +19 -2
  262. package/lib/utils/CxxSceneUtils.d.ts +7 -0
  263. package/lib/utils/CxxSceneUtils.d.ts.map +1 -1
  264. package/lib/utils/CxxSceneUtils.js +10 -1
  265. package/lib/utils/FileUtils.d.ts +0 -1
  266. package/lib/utils/FileUtils.d.ts.map +1 -1
  267. package/lib/utils/FileUtils.js +1 -9
  268. package/lib/utils/HashUtils.d.ts +9 -0
  269. package/lib/utils/HashUtils.d.ts.map +1 -0
  270. package/lib/utils/HashUtils.js +65 -0
  271. package/lib/utils/ModuleUtils.d.ts.map +1 -1
  272. package/lib/utils/ModuleUtils.js +24 -5
  273. package/lib/utils/VisitedSegment.d.ts +23 -0
  274. package/lib/utils/VisitedSegment.d.ts.map +1 -0
  275. package/lib/utils/VisitedSegment.js +64 -0
  276. package/lib/utils/callGraphUtils.d.ts.map +1 -1
  277. package/lib/utils/callGraphUtils.js +7 -7
  278. package/lib/utils/getAllFiles.d.ts.map +1 -1
  279. package/lib/utils/getAllFiles.js +11 -8
  280. package/lib/utils/logger.d.ts +4 -0
  281. package/lib/utils/logger.d.ts.map +1 -1
  282. package/lib/utils/logger.js +16 -0
  283. package/lib/utils/parseArkSourceFile.d.ts +33 -0
  284. package/lib/utils/parseArkSourceFile.d.ts.map +1 -0
  285. package/lib/utils/parseArkSourceFile.js +131 -0
  286. package/package.json +1 -1
  287. package/lib/node_modules/ohos-typescript/README.OpenSource +0 -11
  288. package/lib/node_modules/ohos-typescript/README.md +0 -81
  289. package/lib/node_modules/ohos-typescript/SECURITY.md +0 -41
  290. package/lib/node_modules/ohos-typescript/ThirdPartyNoticeText.txt +0 -193
  291. package/lib/node_modules/ohos-typescript/bin/tsc +0 -2
  292. package/lib/node_modules/ohos-typescript/bin/tsserver +0 -2
  293. package/lib/node_modules/ohos-typescript/lib/README.md +0 -5
  294. package/lib/node_modules/ohos-typescript/lib/cancellationToken.js +0 -86
  295. package/lib/node_modules/ohos-typescript/lib/cs/diagnosticMessages.generated.json +0 -1880
  296. package/lib/node_modules/ohos-typescript/lib/de/diagnosticMessages.generated.json +0 -1880
  297. package/lib/node_modules/ohos-typescript/lib/es/diagnosticMessages.generated.json +0 -1880
  298. package/lib/node_modules/ohos-typescript/lib/fr/diagnosticMessages.generated.json +0 -1880
  299. package/lib/node_modules/ohos-typescript/lib/it/diagnosticMessages.generated.json +0 -1880
  300. package/lib/node_modules/ohos-typescript/lib/ja/diagnosticMessages.generated.json +0 -1880
  301. package/lib/node_modules/ohos-typescript/lib/ko/diagnosticMessages.generated.json +0 -1880
  302. package/lib/node_modules/ohos-typescript/lib/lib.dom.d.ts +0 -18505
  303. package/lib/node_modules/ohos-typescript/lib/lib.dom.iterable.d.ts +0 -341
  304. package/lib/node_modules/ohos-typescript/lib/lib.scripthost.d.ts +0 -327
  305. package/lib/node_modules/ohos-typescript/lib/lib.webworker.d.ts +0 -6192
  306. package/lib/node_modules/ohos-typescript/lib/lib.webworker.importscripts.d.ts +0 -26
  307. package/lib/node_modules/ohos-typescript/lib/lib.webworker.iterable.d.ts +0 -175
  308. package/lib/node_modules/ohos-typescript/lib/pl/diagnosticMessages.generated.json +0 -1880
  309. package/lib/node_modules/ohos-typescript/lib/pt-br/diagnosticMessages.generated.json +0 -1880
  310. package/lib/node_modules/ohos-typescript/lib/ru/diagnosticMessages.generated.json +0 -1880
  311. package/lib/node_modules/ohos-typescript/lib/tr/diagnosticMessages.generated.json +0 -1880
  312. package/lib/node_modules/ohos-typescript/lib/tsc.js +0 -114551
  313. package/lib/node_modules/ohos-typescript/lib/tsserver.js +0 -179691
  314. package/lib/node_modules/ohos-typescript/lib/tsserverlibrary.d.ts +0 -13648
  315. package/lib/node_modules/ohos-typescript/lib/tsserverlibrary.js +0 -178688
  316. package/lib/node_modules/ohos-typescript/lib/typesMap.json +0 -497
  317. package/lib/node_modules/ohos-typescript/lib/typingsInstaller.js +0 -39871
  318. package/lib/node_modules/ohos-typescript/lib/watchGuard.js +0 -49
  319. package/lib/node_modules/ohos-typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -1880
  320. package/lib/node_modules/ohos-typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -1880
  321. package/lib/utils/DependenciesSort.d.ts +0 -3
  322. package/lib/utils/DependenciesSort.d.ts.map +0 -1
  323. package/lib/utils/DependenciesSort.js +0 -72
  324. package/lib/utils/crypto_utils.d.ts +0 -6
  325. package/lib/utils/crypto_utils.d.ts.map +0 -1
  326. package/lib/utils/crypto_utils.js +0 -57
@@ -40,15 +40,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.ArkClass = exports.CLASS_CATEGORY_MASK = exports.CLASS_CATEGORY_SHIFT = exports.ClassCategory = void 0;
41
41
  const Type_1 = require("../base/Type");
42
42
  const ArkMethod_1 = require("./ArkMethod");
43
+ const ArkSignature_1 = require("./ArkSignature");
43
44
  const ArkExport_1 = require("./ArkExport");
44
45
  const TypeInference_1 = require("../common/TypeInference");
45
46
  const Const_1 = require("../common/Const");
46
47
  const Position_1 = require("../base/Position");
47
48
  const ArkBaseModel_1 = require("./ArkBaseModel");
48
49
  const ModelUtils_1 = require("../common/ModelUtils");
49
- const StringUtils_1 = require("../common/StringUtils");
50
+ const SignatureCanonicalizerRegistry_1 = require("../common/SignatureCanonicalizerRegistry");
50
51
  const logger_1 = __importStar(require("../../utils/logger"));
51
52
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkClass');
53
+ const forEachMethodSeenScratch = [];
54
+ let forEachMethodSeenTop = 0;
55
+ const forEachMethodOverflow = [];
56
+ let forEachMethodDepth = 0;
57
+ const SEEN_LINEAR_LIMIT = 32;
58
+ function markSeen(base, depth, method) {
59
+ const overflow = forEachMethodOverflow[depth];
60
+ if (overflow !== undefined) {
61
+ if (overflow.has(method)) {
62
+ return true;
63
+ }
64
+ overflow.add(method);
65
+ return false;
66
+ }
67
+ for (let i = base; i < forEachMethodSeenTop; i++) {
68
+ if (forEachMethodSeenScratch[i] === method) {
69
+ return true;
70
+ }
71
+ }
72
+ if (forEachMethodSeenTop - base >= SEEN_LINEAR_LIMIT) {
73
+ const promoted = new Set();
74
+ for (let i = base; i < forEachMethodSeenTop; i++) {
75
+ promoted.add(forEachMethodSeenScratch[i]);
76
+ }
77
+ promoted.add(method);
78
+ forEachMethodOverflow[depth] = promoted;
79
+ return false;
80
+ }
81
+ forEachMethodSeenScratch[forEachMethodSeenTop++] = method;
82
+ return false;
83
+ }
52
84
  var ClassCategory;
53
85
  (function (ClassCategory) {
54
86
  ClassCategory[ClassCategory["CLASS"] = 0] = "CLASS";
@@ -74,27 +106,38 @@ exports.CLASS_CATEGORY_MASK = 0x7 << exports.CLASS_CATEGORY_SHIFT;
74
106
  * @category core/model
75
107
  */
76
108
  class ArkClass extends ArkBaseModel_1.ArkBaseModel {
77
- constructor() {
109
+ /** @internal Get the Registry singleton. */
110
+ get registry() {
111
+ return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
112
+ }
113
+ constructor(declaringFileID, declaringNamespaceSigID, classSig) {
78
114
  super();
115
+ /** @internal Formal FileSigID for the declaring file. -1 = not yet interned. */
116
+ this.declaringFileID = -1;
117
+ /** @internal Formal ClassSigID of this class. -1 = not yet set. */
118
+ this.classSigID = -1;
79
119
  /**
80
120
  * The keys of the `heritageClasses` map represent the names of superclass and interfaces.
81
121
  * The superclass name is placed first; if it does not exist, an empty string `''` will occupy this position.
82
122
  * The values of the `heritageClasses` map will be replaced with `ArkClass` or `null` during type inference.
83
123
  */
84
124
  this.heritageClasses = new Map();
85
- this.defaultMethod = null;
86
- // name to model
87
- this.methods = new Map();
88
- this.fields = new Map();
89
- this.extendedClasses = new Map();
90
- this.staticMethods = new Map();
91
- this.staticFields = new Map();
92
- this.instanceInitMethod = new ArkMethod_1.ArkMethod();
93
- this.staticInitMethod = new ArkMethod_1.ArkMethod();
125
+ this.extendedClassCount = 0;
126
+ this.topFieldCount = 0;
127
+ this.topStaticFieldCount = 0;
94
128
  this.anonymousMethodNumber = 0;
95
129
  this.indexSignatureNumber = 0;
96
130
  // In order to record the mapping between arkTS and CPP functions
97
131
  this.ts2cxxFuncMap = new Map();
132
+ if (declaringFileID !== undefined) {
133
+ this.declaringFileID = declaringFileID;
134
+ }
135
+ if (declaringNamespaceSigID !== undefined) {
136
+ this.declaringNamespaceSigID = declaringNamespaceSigID;
137
+ }
138
+ if (classSig) {
139
+ this.setSignature(classSig);
140
+ }
98
141
  }
99
142
  /**
100
143
  * Returns the program language of the file where this class defined.
@@ -107,7 +150,7 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
107
150
  * @returns The name of this class.
108
151
  */
109
152
  getName() {
110
- return this.classSignature.getClassName();
153
+ return this.getSignature().getClassName();
111
154
  }
112
155
  /**
113
156
  * Returns the source text of the class extracted from the declaring ArkFile
@@ -118,7 +161,7 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
118
161
  if (this.sourceCode !== undefined) {
119
162
  return this.sourceCode;
120
163
  }
121
- const code = (0, StringUtils_1.extractSourceTextByFullPosition)(this.getDeclaringArkFile().getCode(), this.originFullPosition);
164
+ const code = this.getDeclaringArkFile().getSourceTextByFullPosition(this.originFullPosition);
122
165
  if (code !== undefined) {
123
166
  this.sourceCode = code;
124
167
  }
@@ -128,8 +171,7 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
128
171
  * @deprecated Source text is now stored on ArkFile only. This method has no effect.
129
172
  * @param _code - The source code (ignored).
130
173
  */
131
- setCode(_code) {
132
- }
174
+ setCode(_code) { }
133
175
  /**
134
176
  * Returns the full position (start/end line/col) of this class in the source file.
135
177
  * @returns The full position of this class in the source code, or undefined if this class
@@ -205,20 +247,43 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
205
247
  ```
206
248
  */
207
249
  getDeclaringArkFile() {
208
- return this.declaringArkFile;
250
+ if (this.declaringFileID !== -1) {
251
+ return this.registry.fileSigCanonicalizer.getModel(this.declaringFileID);
252
+ }
253
+ return undefined;
209
254
  }
255
+ /** @deprecated Use {@link constructor} instead. */
210
256
  setDeclaringArkFile(declaringArkFile) {
211
- this.declaringArkFile = declaringArkFile;
257
+ this.declaringFileID = declaringArkFile.getFileSigID();
258
+ }
259
+ /** @internal Get the formal FileSigID of the declaring file. Returns -1 if not interned. */
260
+ getDeclaringFileID() {
261
+ return this.declaringFileID;
212
262
  }
213
263
  /**
214
264
  * Returns the declaring namespace of this class, which may also be an **undefined**.
215
265
  * @returns The declaring namespace (may be **undefined**) of this class.
216
266
  */
217
267
  getDeclaringArkNamespace() {
218
- return this.declaringArkNamespace;
268
+ var _a;
269
+ if (this.declaringNamespaceSigID !== undefined) {
270
+ return (_a = this.registry.namespaceSigCanonicalizer.getModel(this.declaringNamespaceSigID)) !== null && _a !== void 0 ? _a : undefined;
271
+ }
272
+ return undefined;
219
273
  }
274
+ getDeclaringArkNamespaceID() {
275
+ if (this.declaringNamespaceSigID !== undefined) {
276
+ return this.declaringNamespaceSigID;
277
+ }
278
+ return undefined;
279
+ }
280
+ /**
281
+ * @deprecated Use the ID-injecting constructor
282
+ * {@link constructor(declaringFileID, declaringNamespaceSigID, classSig)} or
283
+ * {@link setDeclaringArkNamespaceID} instead.
284
+ */
220
285
  setDeclaringArkNamespace(declaringArkNamespace) {
221
- this.declaringArkNamespace = declaringArkNamespace;
286
+ this.declaringNamespaceSigID = declaringArkNamespace === null || declaringArkNamespace === void 0 ? void 0 : declaringArkNamespace.getNamespaceSigID();
222
287
  }
223
288
  isDefaultArkClass() {
224
289
  return this.getName() === Const_1.DEFAULT_ARK_CLASS_NAME;
@@ -236,10 +301,29 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
236
301
  * @returns The class signature.
237
302
  */
238
303
  getSignature() {
239
- return this.classSignature;
304
+ return this.registry.classSigCanonicalizer.get(this.classSigID);
240
305
  }
241
306
  setSignature(classSig) {
242
- this.classSignature = classSig;
307
+ const existing = this.registry.classSigCanonicalizer.getExistingId(classSig);
308
+ this.classSigID = existing >= 0 ? existing : this.registry.classSigCanonicalizer.getOrCreateId(classSig);
309
+ // 新值首建 → 注册;
310
+ // 驱逐态恢复(sig 值残留、model 已被 removeClass 删除)→ 补注册(否则 reload 时 getDeclaringArkClass 查不到 model,genDefaultArkMethod 链 NPE);
311
+ // 已有别的 model 持有该签名 → 不覆盖(防"后 setSignature 者顶替"写穿)。
312
+ if (existing < 0 || this.registry.classSigCanonicalizer.getModel(existing) === undefined) {
313
+ this.registry.registerClass(this);
314
+ }
315
+ }
316
+ /** @internal Get the formal ClassSigID of this class. */
317
+ getClassSigID() {
318
+ return this.classSigID;
319
+ }
320
+ /**
321
+ * Returns the unique ID of this model — the ClassSigID in the canonicalizer.
322
+ * The signature table and the model table share one dense ID space, so this ID
323
+ * resolves both the signature and the model.
324
+ */
325
+ getId() {
326
+ return this.classSigID;
243
327
  }
244
328
  getSuperClassName() {
245
329
  return this.heritageClasses.keys().next().value || '';
@@ -280,7 +364,7 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
280
364
  if (type) {
281
365
  type = TypeInference_1.TypeInference.replaceAliasType(type);
282
366
  }
283
- if (type instanceof Type_1.ClassType && (superClass = this.declaringArkFile.getScene().getClass(type.getClassSignature()))) {
367
+ if (type instanceof Type_1.ClassType && (superClass = this.getDeclaringArkFile().getScene().getClass(type.getClassSignature()))) {
284
368
  superClass.addExtendedClass(this);
285
369
  const realGenericTypes = type.getRealGenericTypes();
286
370
  if (realGenericTypes) {
@@ -313,11 +397,56 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
313
397
  });
314
398
  return result;
315
399
  }
400
+ /**
401
+ * Returns the direct subclasses (parent→child back-references) of this class.
402
+ * The returned Map is a rebuilt view keyed by class name; mutating it does not
403
+ * affect the internal storage.
404
+ */
316
405
  getExtendedClasses() {
317
- return this.extendedClasses;
406
+ const result = new Map();
407
+ const arr = this.extendedClassSigIDs;
408
+ if (!arr) {
409
+ return result;
410
+ }
411
+ const reg = this.registry;
412
+ for (let i = 0; i < this.extendedClassCount; i++) {
413
+ const cls = reg.classSigCanonicalizer.getModel(arr[i]);
414
+ if (cls) {
415
+ result.set(cls.getName(), cls);
416
+ }
417
+ }
418
+ return result;
419
+ }
420
+ /**
421
+ * @internal Returns the direct subclasses as an array, or **null** if this class
422
+ * has no extended classes. Preferred over {@link getExtendedClasses} in hot paths
423
+ * to avoid rebuilding a Map. Stale SigIDs (whose classes were removed) are skipped.
424
+ */
425
+ getExtendedClassList() {
426
+ const arr = this.extendedClassSigIDs;
427
+ if (!arr || this.extendedClassCount === 0) {
428
+ return null;
429
+ }
430
+ const result = [];
431
+ const reg = this.registry;
432
+ for (let i = 0; i < this.extendedClassCount; i++) {
433
+ const cls = reg.classSigCanonicalizer.getModel(arr[i]);
434
+ if (cls) {
435
+ result.push(cls);
436
+ }
437
+ }
438
+ return result;
318
439
  }
319
440
  addExtendedClass(extendedClass) {
320
- this.extendedClasses.set(extendedClass.getName(), extendedClass);
441
+ const id = extendedClass.getClassSigID();
442
+ if (id <= 0 || this.hasExtendedClassWithID(id)) {
443
+ return;
444
+ }
445
+ this.addExtendedClassSigID(id);
446
+ }
447
+ /** @internal Removes a direct subclass back-reference (by ClassSigID, swap-remove). */
448
+ removeExtendedClass(extendedClass) {
449
+ this.removeExtendedClassSigID(extendedClass.getClassSigID());
321
450
  }
322
451
  getImplementedInterfaceNames() {
323
452
  if (this.getCategory() === ClassCategory.INTERFACE) {
@@ -325,9 +454,11 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
325
454
  }
326
455
  return Array.from(this.heritageClasses.keys()).slice(1);
327
456
  }
457
+ /** @deprecated No callers remain in the codebase; no replacement. */
328
458
  hasImplementedInterface(interfaceName) {
329
459
  return this.heritageClasses.has(interfaceName) && this.getSuperClassName() !== interfaceName;
330
460
  }
461
+ /** @deprecated No callers remain in the codebase; no replacement. */
331
462
  getImplementedInterface(interfaceName) {
332
463
  const heritageClass = this.getHeritageClass(interfaceName);
333
464
  if (heritageClass && heritageClass.getCategory() === ClassCategory.INTERFACE) {
@@ -342,36 +473,74 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
342
473
  * @returns A field. If there is no field in this class, the return will be a **null**.
343
474
  */
344
475
  getField(fieldSignature) {
345
- const fieldName = fieldSignature.getFieldName();
346
- let fieldSearched = this.getFieldWithName(fieldName);
347
- if (!fieldSearched) {
348
- fieldSearched = this.getStaticFieldWithName(fieldName);
476
+ const id = this.registry.fieldSigCanonicalizer.getExistingId(fieldSignature);
477
+ if (id !== -1) {
478
+ const fld = this.registry.fieldSigCanonicalizer.getModel(id);
479
+ if (fld !== undefined && fld.getDeclaringClassID() === this.classSigID) {
480
+ return fld;
481
+ }
349
482
  }
350
- return fieldSearched;
483
+ return null;
351
484
  }
352
485
  getFieldWithName(fieldName) {
353
- return this.fields.get(fieldName) || null;
486
+ var _a;
487
+ const id = this.registry.fieldSigCanonicalizer.getExistingId(ArkSignature_1.FieldSignature.probe(fieldName, this.classSigID, Type_1.UnknownType.getInstance(), false));
488
+ if (id !== -1) {
489
+ return (_a = this.registry.fieldSigCanonicalizer.getModel(id)) !== null && _a !== void 0 ? _a : null;
490
+ }
491
+ return null;
354
492
  }
355
493
  getStaticFieldWithName(fieldName) {
356
- return this.staticFields.get(fieldName) || null;
494
+ var _a;
495
+ // 同 getFieldWithName,staticFlag = true。
496
+ const id = this.registry.fieldSigCanonicalizer.getExistingId(ArkSignature_1.FieldSignature.probe(fieldName, this.classSigID, Type_1.UnknownType.getInstance(), true));
497
+ if (id !== -1) {
498
+ return (_a = this.registry.fieldSigCanonicalizer.getModel(id)) !== null && _a !== void 0 ? _a : null;
499
+ }
500
+ return null;
357
501
  }
358
502
  /**
359
503
  * Returns an **array** of fields in the class.
360
504
  * @returns an **array** of fields in the class.
361
505
  */
362
506
  getFields() {
363
- const allFields = Array.from(this.staticFields.values());
364
- allFields.push(...this.fields.values());
365
- return allFields;
507
+ const result = [];
508
+ const sArr = this.topStaticFieldSigIDs;
509
+ if (sArr) {
510
+ const reg = this.registry;
511
+ for (let i = 0; i < this.topStaticFieldCount; i++) {
512
+ const fld = reg.fieldSigCanonicalizer.getModel(sArr[i]);
513
+ if (fld) {
514
+ result.push(fld);
515
+ }
516
+ }
517
+ }
518
+ const arr = this.topFieldSigIDs;
519
+ if (arr) {
520
+ const reg = this.registry;
521
+ for (let i = 0; i < this.topFieldCount; i++) {
522
+ const fld = reg.fieldSigCanonicalizer.getModel(arr[i]);
523
+ if (fld) {
524
+ result.push(fld);
525
+ }
526
+ }
527
+ }
528
+ return result;
366
529
  }
367
530
  addField(field) {
531
+ const id = field.getFieldSigID();
368
532
  if (field.isStatic()) {
369
- this.staticFields.set(field.getName(), field);
533
+ if (!this.hasTopStaticFieldWithID(id)) {
534
+ this.addTopStaticFieldSigID(id);
535
+ }
370
536
  }
371
537
  else {
372
- this.fields.set(field.getName(), field);
538
+ if (!this.hasTopFieldWithID(id)) {
539
+ this.addTopFieldSigID(id);
540
+ }
373
541
  }
374
542
  }
543
+ /** @deprecated No callers remain in the codebase; use {@link addField} per field instead. */
375
544
  addFields(fields) {
376
545
  fields.forEach(field => {
377
546
  this.addField(field);
@@ -406,27 +575,159 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
406
575
  ```
407
576
  */
408
577
  getMethods(generated) {
409
- const seen = new WeakSet();
578
+ var _a, _b, _c, _d;
579
+ const ids = new Set();
580
+ for (const entry of (_b = (_a = this.methodNameIndex) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : []) {
581
+ for (const id of entry) {
582
+ ids.add(id);
583
+ }
584
+ }
585
+ for (const entry of (_d = (_c = this.staticMethodNameIndex) === null || _c === void 0 ? void 0 : _c.values()) !== null && _d !== void 0 ? _d : []) {
586
+ for (const id of entry) {
587
+ ids.add(id);
588
+ }
589
+ }
590
+ const seen = new Set();
410
591
  const result = [];
411
- const addIfNeeded = (m) => {
412
- if (!seen.has(m) && (generated || !m.isGenerated())) {
592
+ for (const id of ids) {
593
+ const m = this.registry.methodSigCanonicalizer.getModel(id);
594
+ if (m !== undefined && (generated || !m.isGenerated()) && !seen.has(m)) {
413
595
  seen.add(m);
414
596
  result.push(m);
415
597
  }
416
- };
417
- for (const methods of this.methods.values()) {
418
- for (const m of methods) {
419
- addIfNeeded(m);
598
+ }
599
+ return result;
600
+ }
601
+ /**
602
+ * @internal Iterates the class methods in {@link getMethods} order without building the
603
+ * result array. Dedup uses a module-level scratch segment with base/top discipline instead
604
+ * of a per-call Set: each invocation appends its yielded methods above the current top and
605
+ * pops (nulling) its segment on exit, which keeps the walk reentrant - a callback may call
606
+ * forEachMethod again without disturbing the outer dedup - and allocation-free per call.
607
+ * Return false from the callback to stop early. Use getMethods when the caller needs the
608
+ * array itself (e.g. to sort it).
609
+ */
610
+ forEachMethod(callback, generated) {
611
+ const canonicalizer = this.registry.methodSigCanonicalizer;
612
+ const base = forEachMethodSeenTop;
613
+ const depth = forEachMethodDepth++;
614
+ try {
615
+ let earlyExit = false;
616
+ const index = this.methodNameIndex;
617
+ if (index !== undefined) {
618
+ for (const entry of index.values()) {
619
+ for (let i = 0; i < entry.length; i++) {
620
+ const m = canonicalizer.getModel(entry[i]);
621
+ if (m !== undefined && (generated || !m.isGenerated()) && !markSeen(base, depth, m)) {
622
+ if (!callback(m)) {
623
+ earlyExit = true;
624
+ break;
625
+ }
626
+ }
627
+ }
628
+ if (earlyExit) {
629
+ break;
630
+ }
631
+ }
632
+ }
633
+ const staticIndex = this.staticMethodNameIndex;
634
+ if (!earlyExit && staticIndex !== undefined) {
635
+ for (const entry of staticIndex.values()) {
636
+ for (let i = 0; i < entry.length; i++) {
637
+ const m = canonicalizer.getModel(entry[i]);
638
+ if (m !== undefined && (generated || !m.isGenerated()) && !markSeen(base, depth, m)) {
639
+ if (!callback(m)) {
640
+ earlyExit = true;
641
+ break;
642
+ }
643
+ }
644
+ }
645
+ if (earlyExit) {
646
+ break;
647
+ }
648
+ }
420
649
  }
421
650
  }
422
- for (const methods of this.staticMethods.values()) {
423
- for (const m of methods) {
424
- addIfNeeded(m);
651
+ finally {
652
+ forEachMethodDepth = depth;
653
+ if (forEachMethodOverflow[depth] !== undefined) {
654
+ forEachMethodOverflow[depth] = undefined;
425
655
  }
656
+ const nullMethod = null;
657
+ for (let i = base; i < forEachMethodSeenTop; i++) {
658
+ forEachMethodSeenScratch[i] = nullMethod;
659
+ }
660
+ forEachMethodSeenTop = base;
661
+ }
662
+ }
663
+ /**
664
+ * @internal Iterates the methods whose names mark them as nested inside `outerMethodName`
665
+ * (NAME_PREFIX ... NAME_DELIMITER + outerMethodName), in the same order and with the same
666
+ * dedup as an equivalent filtered {@link forEachMethod} walk, but scanning the name-index
667
+ * keys as strings and resolving models only for hits - no per-call Set and no O(class)
668
+ * model resolution, which mattered for large SDK classes walked once per outer method.
669
+ */
670
+ forEachNestedMethodOf(outerMethodName, callback) {
671
+ const suffix = Const_1.NAME_DELIMITER + outerMethodName;
672
+ const canonicalizer = this.registry.methodSigCanonicalizer;
673
+ const base = forEachMethodSeenTop;
674
+ const depth = forEachMethodDepth++;
675
+ try {
676
+ let stop = false;
677
+ for (let pass = 0; pass < 2 && !stop; pass++) {
678
+ const index = pass === 0 ? this.methodNameIndex : this.staticMethodNameIndex;
679
+ if (index === undefined) {
680
+ continue;
681
+ }
682
+ for (const name of index.keys()) {
683
+ if (!name.startsWith(Const_1.NAME_PREFIX) || !name.endsWith(suffix)) {
684
+ continue;
685
+ }
686
+ const ids = index.get(name);
687
+ for (let i = 0; i < ids.length; i++) {
688
+ const m = canonicalizer.getModel(ids[i]);
689
+ if (m !== undefined && !m.isGenerated() && !markSeen(base, depth, m)) {
690
+ if (!callback(m)) {
691
+ stop = true;
692
+ break;
693
+ }
694
+ }
695
+ }
696
+ if (stop) {
697
+ break;
698
+ }
699
+ }
700
+ }
701
+ }
702
+ finally {
703
+ forEachMethodDepth = depth;
704
+ if (forEachMethodOverflow[depth] !== undefined) {
705
+ forEachMethodOverflow[depth] = undefined;
706
+ }
707
+ const nullMethod = null;
708
+ for (let i = base; i < forEachMethodSeenTop; i++) {
709
+ forEachMethodSeenScratch[i] = nullMethod;
710
+ }
711
+ forEachMethodSeenTop = base;
426
712
  }
427
- return result;
428
713
  }
429
714
  getMethod(methodSignature) {
715
+ const canonicalizer = this.registry.methodSigCanonicalizer;
716
+ const id = canonicalizer.getExistingId(methodSignature);
717
+ if (id !== -1) {
718
+ const mtd = canonicalizer.getModel(id);
719
+ if (mtd !== undefined && mtd.getDeclaringClassID() === this.classSigID) {
720
+ return mtd;
721
+ }
722
+ }
723
+ // Fallback: class-local traversal with signature matching.
724
+ // 不能删除(结构性缺口承载者):
725
+ // ① declare[k>0] 无 model——addMethod 只注册 impl ?? declare[0],而
726
+ // matchMethodSignature 为可选参数/重载调用点选出的非首选声明签名
727
+ // (callgraph callee 解析主链路,PagBuilder/CallGraph/RTA 等)只能在此命中;
728
+ // → 全槽注册后 declare 槽已注册,此缺口关闭;
729
+ // ② 闭包 declare 重建签名(updateNestedMethodWithClosures 只 intern 不注册);
730
+ // ③ C++ 跨类借用(声明方法借实现侧签名,fast path 归属校验失败后在此命中)。
430
731
  const methodName = methodSignature.getMethodSubSignature().getMethodName();
431
732
  const methodsWithSameName = this.getAllMethodsWithName(methodName);
432
733
  if (methodsWithSameName.length === 0) {
@@ -462,65 +763,127 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
462
763
  return null;
463
764
  }
464
765
  getMethodWithName(methodName) {
465
- const sameNameMethods = this.methods.get(methodName);
466
- if (!sameNameMethods) {
766
+ var _a;
767
+ const ids = (_a = this.methodNameIndex) === null || _a === void 0 ? void 0 : _a.get(methodName);
768
+ if (ids === undefined || ids.length === 0) {
467
769
  return null;
468
770
  }
469
- if (sameNameMethods.length > 1) {
771
+ const reg = this.registry;
772
+ let first = null;
773
+ let resolved = 0;
774
+ for (let i = 0; i < ids.length; i++) {
775
+ const m = reg.methodSigCanonicalizer.getModel(ids[i]);
776
+ if (m) {
777
+ resolved++;
778
+ if (first === null) {
779
+ first = m;
780
+ }
781
+ else {
782
+ break;
783
+ }
784
+ }
785
+ }
786
+ if (resolved > 1) {
470
787
  logger.warn("There are multiple non-static methods with the same name, and the interface 'getMethodWithName' only returns one of them. " +
471
788
  "If you want to obtain all non-static methods with the same name, please use the interface 'getMethodsWithName'.");
472
789
  }
473
- return sameNameMethods[0];
790
+ return first;
474
791
  }
475
792
  getStaticMethodWithName(methodName) {
476
- const sameNameStaticMethods = this.staticMethods.get(methodName);
477
- if (!sameNameStaticMethods) {
793
+ var _a;
794
+ const ids = (_a = this.staticMethodNameIndex) === null || _a === void 0 ? void 0 : _a.get(methodName);
795
+ if (ids === undefined || ids.length === 0) {
478
796
  return null;
479
797
  }
480
- if (sameNameStaticMethods.length > 1) {
798
+ const reg = this.registry;
799
+ let first = null;
800
+ let resolved = 0;
801
+ for (let i = 0; i < ids.length; i++) {
802
+ const m = reg.methodSigCanonicalizer.getModel(ids[i]);
803
+ if (m) {
804
+ resolved++;
805
+ if (first === null) {
806
+ first = m;
807
+ }
808
+ else {
809
+ break;
810
+ }
811
+ }
812
+ }
813
+ if (resolved > 1) {
481
814
  logger.warn("There are multiple static methods with the same name, and the interface 'getStaticMethodWithName' only returns one of them. " +
482
815
  "If you want to obtain all static methods with the same name, please use the interface 'getStaticMethodsWithName'.");
483
816
  }
484
- return sameNameStaticMethods[0];
817
+ return first;
485
818
  }
486
819
  /**
487
820
  * add a method in class.
488
- * when a nested method with declare name, add both the declare origin name and signature name
489
- * %${declare name}$${outer method name} in class.
490
821
  */
491
- addMethod(method, originName) {
492
- const name = originName !== null && originName !== void 0 ? originName : method.getName();
493
- this.updateMethodMap(method, name);
494
- if (!originName && !method.isAnonymousMethod() && name.startsWith(Const_1.NAME_PREFIX)) {
495
- const index = name.indexOf(Const_1.NAME_DELIMITER);
496
- if (index > 1) {
497
- const originName = name.substring(1, index);
498
- this.addMethod(method, originName);
822
+ addMethod(method) {
823
+ var _a, _b;
824
+ const id = (_a = method.getMethodSigID()) !== null && _a !== void 0 ? _a : (_b = method.getDeclareSigIDs()) === null || _b === void 0 ? void 0 : _b[0];
825
+ if (id === undefined || id <= 0) {
826
+ logger.error(`Cannot add method (SigID=${method.getMethodSigID()}) to class (SigID=${this.getClassSigID()}): it has no interned signature.`);
827
+ return;
828
+ }
829
+ const canonicalizer = this.registry.methodSigCanonicalizer;
830
+ // The class index is authoritative: registering here (unconditionally) marks the final
831
+ // winner of any same-signature merge chain performed by builders.
832
+ canonicalizer.setModel(id, method);
833
+ const declareSigIDs = method.getDeclareSigIDs();
834
+ if (declareSigIDs !== null && declareSigIDs !== undefined) {
835
+ for (let i = 0; i < declareSigIDs.length; i++) {
836
+ const declareID = declareSigIDs[i];
837
+ if (declareID > 0 && declareID !== id) {
838
+ this.registerDeclareSlotWithArbitration(canonicalizer, declareID, method);
839
+ }
840
+ }
841
+ }
842
+ this.updateMethodIndex(method, id);
843
+ }
844
+ /**
845
+ * @internal Register a method as the model of one of its non-primary declare slots.
846
+ *
847
+ * Arbitration (single rule, no same-class sibling protection — addMethod is the
848
+ * terminal registration point where the merge winner must take over same-class
849
+ * declare slots; compare registerImplModelWithArbitration in ArkMethod for the
850
+ * construction-time rules):
851
+ * - a slot already held by a body-carrying method is never taken over by a
852
+ * body-less one (C++ decl/impl split added in reverse order).
853
+ */
854
+ registerDeclareSlotWithArbitration(canonicalizer, declareID, method) {
855
+ const existing = canonicalizer.getModel(declareID);
856
+ if (existing !== undefined && existing !== method) {
857
+ if (existing.getBody() !== undefined && method.getBody() === undefined) {
858
+ return;
499
859
  }
500
860
  }
861
+ canonicalizer.setModel(declareID, method);
501
862
  }
502
863
  /**
503
- * Update the new method to the corresponding Map.
864
+ * Update the new method in the corresponding SigID index.
504
865
  *
505
866
  * @param newMethod - the new method
506
- * @param methodName - name of new method
867
+ * @param sigID - the formal MethodSigID (or first declare SigID) indexing the method
507
868
  */
508
- updateMethodMap(newMethod, methodName) {
509
- const methodMap = newMethod.isStatic() ? this.staticMethods : this.methods;
510
- const methodsWithSameName = methodMap.get(methodName);
511
- if (!methodsWithSameName || !ModelUtils_1.ModelUtils.isLanguageOverloadSupport(this.getLanguage())) {
512
- methodMap.set(methodName, [newMethod]);
869
+ updateMethodIndex(newMethod, sigID) {
870
+ if (newMethod.isStatic()) {
871
+ if (!ModelUtils_1.ModelUtils.isLanguageOverloadSupport(this.getLanguage())) {
872
+ // Non-overload languages: same-name methods replace each other. set() on an
873
+ // existing key keeps its insertion position, so the first-occurrence order
874
+ // of getMethods is stable across same-name re-adds.
875
+ this.setStaticMethodNameEntry(newMethod.getName(), sigID);
876
+ }
877
+ else if (!this.replaceTopStaticMethodSigIDByMatch(newMethod)) {
878
+ this.appendStaticMethodNameEntry(newMethod.getName(), sigID);
879
+ }
513
880
  return;
514
881
  }
515
- const newMethodSignature = newMethod.getSignature();
516
- const matchIndex = methodsWithSameName.findIndex(
517
- // CXXTodo: After the subsequent abstraction of BodyBuilder, this conditions need to be refactored.
518
- preMtd => preMtd.getSignature().isMatch(newMethodSignature));
519
- if (matchIndex === -1) {
520
- methodsWithSameName.push(newMethod);
882
+ if (!ModelUtils_1.ModelUtils.isLanguageOverloadSupport(this.getLanguage())) {
883
+ this.setMethodNameEntry(newMethod.getName(), sigID);
521
884
  }
522
- else {
523
- methodsWithSameName[matchIndex] = newMethod;
885
+ else if (!this.replaceTopMethodSigIDByMatch(newMethod)) {
886
+ this.appendMethodNameEntry(newMethod.getName(), sigID);
524
887
  }
525
888
  }
526
889
  /**
@@ -531,7 +894,19 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
531
894
  */
532
895
  getMethodsWithName(methodName) {
533
896
  var _a;
534
- return (_a = this.methods.get(methodName)) !== null && _a !== void 0 ? _a : [];
897
+ const ids = (_a = this.methodNameIndex) === null || _a === void 0 ? void 0 : _a.get(methodName);
898
+ if (ids === undefined || ids.length === 0) {
899
+ return [];
900
+ }
901
+ const reg = this.registry;
902
+ const result = [];
903
+ for (let i = 0; i < ids.length; i++) {
904
+ const m = reg.methodSigCanonicalizer.getModel(ids[i]);
905
+ if (m) {
906
+ result.push(m);
907
+ }
908
+ }
909
+ return result;
535
910
  }
536
911
  /**
537
912
  * Get all static methods with the same name.
@@ -541,7 +916,19 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
541
916
  */
542
917
  getStaticMethodsWithName(methodName) {
543
918
  var _a;
544
- return (_a = this.staticMethods.get(methodName)) !== null && _a !== void 0 ? _a : [];
919
+ const ids = (_a = this.staticMethodNameIndex) === null || _a === void 0 ? void 0 : _a.get(methodName);
920
+ if (ids === undefined || ids.length === 0) {
921
+ return [];
922
+ }
923
+ const reg = this.registry;
924
+ const result = [];
925
+ for (let i = 0; i < ids.length; i++) {
926
+ const m = reg.methodSigCanonicalizer.getModel(ids[i]);
927
+ if (m) {
928
+ result.push(m);
929
+ }
930
+ }
931
+ return result;
545
932
  }
546
933
  /**
547
934
  * Get all non-static and static methods with the same name.
@@ -554,11 +941,15 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
554
941
  return [...new Set(allMethods)];
555
942
  }
556
943
  setDefaultArkMethod(defaultMethod) {
557
- this.defaultMethod = defaultMethod;
944
+ this.defaultMethodSigID = defaultMethod.getMethodSigID();
558
945
  this.addMethod(defaultMethod);
559
946
  }
560
947
  getDefaultArkMethod() {
561
- return this.defaultMethod;
948
+ var _a;
949
+ if (this.defaultMethodSigID === undefined) {
950
+ return null;
951
+ }
952
+ return (_a = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().methodSigCanonicalizer.getModel(this.defaultMethodSigID)) !== null && _a !== void 0 ? _a : null;
562
953
  }
563
954
  setViewTree(viewTree) {
564
955
  this.viewTree = viewTree;
@@ -603,54 +994,383 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
603
994
  return this.viewTree !== undefined;
604
995
  }
605
996
  getStaticFields(_classMap) {
606
- return Array.from(this.staticFields.values());
997
+ const arr = this.topStaticFieldSigIDs;
998
+ if (!arr) {
999
+ return [];
1000
+ }
1001
+ const reg = this.registry;
1002
+ const result = [];
1003
+ for (let i = 0; i < this.topStaticFieldCount; i++) {
1004
+ const fld = reg.fieldSigCanonicalizer.getModel(arr[i]);
1005
+ if (fld) {
1006
+ result.push(fld);
1007
+ }
1008
+ }
1009
+ return result;
607
1010
  }
1011
+ /** @deprecated No callers remain in the codebase; no replacement. */
608
1012
  getGlobalVariable(globalMap) {
609
- if (this.declaringArkNamespace) {
610
- return globalMap.get(this.declaringArkNamespace.getNamespaceSignature());
1013
+ const ns = this.getDeclaringArkNamespace();
1014
+ if (ns) {
1015
+ return globalMap.get(ns.getNamespaceSignature());
611
1016
  }
612
- return globalMap.get(this.declaringArkFile.getFileSignature());
1017
+ return globalMap.get(this.getDeclaringArkFile().getFileSignature());
613
1018
  }
614
1019
  getAnonymousMethodNumber() {
615
1020
  return this.anonymousMethodNumber++;
616
1021
  }
1022
+ /** @deprecated No callers remain in the codebase; no replacement. */
617
1023
  getIndexSignatureNumber() {
618
1024
  return this.indexSignatureNumber++;
619
1025
  }
620
1026
  getExportType() {
621
1027
  return ArkExport_1.ExportType.CLASS;
622
1028
  }
1029
+ /** @internal Returns the instance init method, or null if not set. */
1030
+ getInstanceInitMethodOrNull() {
1031
+ var _a;
1032
+ if (this.instanceInitMethodSigID === undefined) {
1033
+ return null;
1034
+ }
1035
+ return (_a = this.registry.methodSigCanonicalizer.getModel(this.instanceInitMethodSigID)) !== null && _a !== void 0 ? _a : null;
1036
+ }
1037
+ /** @internal Returns the static init method, or null if not set. */
1038
+ getStaticInitMethodOrNull() {
1039
+ var _a;
1040
+ if (this.staticInitMethodSigID === undefined) {
1041
+ return null;
1042
+ }
1043
+ return (_a = this.registry.methodSigCanonicalizer.getModel(this.staticInitMethodSigID)) !== null && _a !== void 0 ? _a : null;
1044
+ }
1045
+ /** @deprecated Use {@link getInstanceInitMethodOrNull} instead. */
623
1046
  getInstanceInitMethod() {
624
- return this.instanceInitMethod;
1047
+ var _a;
1048
+ return (_a = this.getInstanceInitMethodOrNull()) !== null && _a !== void 0 ? _a : new ArkMethod_1.ArkMethod();
625
1049
  }
1050
+ /** @deprecated Use {@link getStaticInitMethodOrNull} instead. */
626
1051
  getStaticInitMethod() {
627
- return this.staticInitMethod;
1052
+ var _a;
1053
+ return (_a = this.getStaticInitMethodOrNull()) !== null && _a !== void 0 ? _a : new ArkMethod_1.ArkMethod();
628
1054
  }
629
1055
  setInstanceInitMethod(arkMethod) {
630
- this.instanceInitMethod = arkMethod;
1056
+ this.instanceInitMethodSigID = arkMethod.getMethodSigID();
631
1057
  }
632
1058
  setStaticInitMethod(arkMethod) {
633
- this.staticInitMethod = arkMethod;
1059
+ this.staticInitMethodSigID = arkMethod.getMethodSigID();
1060
+ }
1061
+ // --- Instance/static method name index ---
1062
+ /** @internal Returns the instance method name index, or undefined if no instance methods exist. */
1063
+ getMethodNameIndex() {
1064
+ return this.methodNameIndex;
1065
+ }
1066
+ /** @internal Returns the static method name index, or undefined if no static methods exist. */
1067
+ getStaticMethodNameIndex() {
1068
+ return this.staticMethodNameIndex;
1069
+ }
1070
+ /** @internal Appends the SigID under the method name in the instance index. */
1071
+ appendMethodNameEntry(name, id) {
1072
+ var _a, _b;
1073
+ const ids = (_a = this.methodNameIndex) === null || _a === void 0 ? void 0 : _a.get(name);
1074
+ if (ids !== undefined) {
1075
+ ids.push(id);
1076
+ return;
1077
+ }
1078
+ ((_b = this.methodNameIndex) !== null && _b !== void 0 ? _b : (this.methodNameIndex = new Map())).set(name, [id]);
1079
+ }
1080
+ /** @internal Appends the SigID under the method name in the static index. */
1081
+ appendStaticMethodNameEntry(name, id) {
1082
+ var _a, _b;
1083
+ const ids = (_a = this.staticMethodNameIndex) === null || _a === void 0 ? void 0 : _a.get(name);
1084
+ if (ids !== undefined) {
1085
+ ids.push(id);
1086
+ return;
1087
+ }
1088
+ ((_b = this.staticMethodNameIndex) !== null && _b !== void 0 ? _b : (this.staticMethodNameIndex = new Map())).set(name, [id]);
1089
+ }
1090
+ /**
1091
+ * @internal Sets the instance method name entry to a single SigID. Overwrites any
1092
+ * previous same-name entry; set() on an existing key preserves its insertion position
1093
+ * (non-overload same-name replacement keeps the first-occurrence order).
1094
+ */
1095
+ setMethodNameEntry(name, id) {
1096
+ var _a;
1097
+ ((_a = this.methodNameIndex) !== null && _a !== void 0 ? _a : (this.methodNameIndex = new Map())).set(name, [id]);
1098
+ }
1099
+ /**
1100
+ * @internal Sets the static method name entry to a single SigID. See {@link setMethodNameEntry}.
1101
+ */
1102
+ setStaticMethodNameEntry(name, id) {
1103
+ var _a;
1104
+ ((_a = this.staticMethodNameIndex) !== null && _a !== void 0 ? _a : (this.staticMethodNameIndex = new Map())).set(name, [id]);
1105
+ }
1106
+ /**
1107
+ * @internal For overload-supported languages: replace the SigID of the same-signature
1108
+ * instance method in place. Returns true if replaced.
1109
+ */
1110
+ replaceTopMethodSigIDByMatch(newMethod) {
1111
+ var _a, _b;
1112
+ const index = this.methodNameIndex;
1113
+ if (!index) {
1114
+ return false;
1115
+ }
1116
+ const reg = this.registry;
1117
+ const newSig = newMethod.getSignature();
1118
+ const newID = (_a = newMethod.getMethodSigID()) !== null && _a !== void 0 ? _a : (_b = newMethod.getDeclareSigIDs()) === null || _b === void 0 ? void 0 : _b[0];
1119
+ if (newID === undefined) {
1120
+ return false;
1121
+ }
1122
+ for (const ids of index.values()) {
1123
+ for (let i = 0; i < ids.length; i++) {
1124
+ const m = reg.methodSigCanonicalizer.getModel(ids[i]);
1125
+ if (m && m.getSignature().isMatch(newSig)) {
1126
+ ids[i] = newID;
1127
+ return true;
1128
+ }
1129
+ }
1130
+ }
1131
+ return false;
1132
+ }
1133
+ /**
1134
+ * @internal For overload-supported languages: replace the SigID of the same-signature
1135
+ * static method in place. Returns true if replaced.
1136
+ */
1137
+ replaceTopStaticMethodSigIDByMatch(newMethod) {
1138
+ var _a, _b;
1139
+ const index = this.staticMethodNameIndex;
1140
+ if (!index) {
1141
+ return false;
1142
+ }
1143
+ const reg = this.registry;
1144
+ const newSig = newMethod.getSignature();
1145
+ const newID = (_a = newMethod.getMethodSigID()) !== null && _a !== void 0 ? _a : (_b = newMethod.getDeclareSigIDs()) === null || _b === void 0 ? void 0 : _b[0];
1146
+ if (newID === undefined) {
1147
+ return false;
1148
+ }
1149
+ for (const ids of index.values()) {
1150
+ for (let i = 0; i < ids.length; i++) {
1151
+ const m = reg.methodSigCanonicalizer.getModel(ids[i]);
1152
+ if (m && m.getSignature().isMatch(newSig)) {
1153
+ ids[i] = newID;
1154
+ return true;
1155
+ }
1156
+ }
1157
+ }
1158
+ return false;
1159
+ }
1160
+ /** @internal Removes the SigID of one instance method from the index (exact ID match). Returns true if it was held. */
1161
+ removeTopMethodSigID(id) {
1162
+ const index = this.methodNameIndex;
1163
+ if (!index) {
1164
+ return false;
1165
+ }
1166
+ for (const [name, ids] of index) {
1167
+ const i = ids.indexOf(id);
1168
+ if (i >= 0) {
1169
+ if (ids.length === 1) {
1170
+ index.delete(name);
1171
+ }
1172
+ else {
1173
+ ids.splice(i, 1);
1174
+ }
1175
+ return true;
1176
+ }
1177
+ }
1178
+ return false;
1179
+ }
1180
+ /** @internal Removes the SigID of one static method from the index (exact ID match). Returns true if it was held. */
1181
+ removeTopStaticMethodSigID(id) {
1182
+ const index = this.staticMethodNameIndex;
1183
+ if (!index) {
1184
+ return false;
1185
+ }
1186
+ for (const [name, ids] of index) {
1187
+ const i = ids.indexOf(id);
1188
+ if (i >= 0) {
1189
+ if (ids.length === 1) {
1190
+ index.delete(name);
1191
+ }
1192
+ else {
1193
+ ids.splice(i, 1);
1194
+ }
1195
+ return true;
1196
+ }
1197
+ }
1198
+ return false;
1199
+ }
1200
+ // --- Instance field SigID index ---
1201
+ /** @internal Checks whether a field with the given SigID is a direct instance field. */
1202
+ hasTopFieldWithID(id) {
1203
+ const arr = this.topFieldSigIDs;
1204
+ if (!arr) {
1205
+ return false;
1206
+ }
1207
+ const count = this.topFieldCount;
1208
+ for (let i = 0; i < count; i++) {
1209
+ if (arr[i] === id) {
1210
+ return true;
1211
+ }
1212
+ }
1213
+ return false;
1214
+ }
1215
+ /** @internal Ensures the instance field Int32Array has at least minCapacity slots. */
1216
+ ensureTopFieldCapacity(minCapacity) {
1217
+ if (!this.topFieldSigIDs) {
1218
+ this.topFieldSigIDs = new Int32Array(Math.max(minCapacity, 8));
1219
+ return;
1220
+ }
1221
+ if (this.topFieldSigIDs.length < minCapacity) {
1222
+ const newCapacity = Math.max(minCapacity, this.topFieldSigIDs.length * 2);
1223
+ const newArray = new Int32Array(newCapacity);
1224
+ newArray.set(this.topFieldSigIDs.subarray(0, this.topFieldCount));
1225
+ this.topFieldSigIDs = newArray;
1226
+ }
1227
+ }
1228
+ /** @internal Appends an instance field SigID to the index. */
1229
+ addTopFieldSigID(id) {
1230
+ this.ensureTopFieldCapacity(this.topFieldCount + 1);
1231
+ this.topFieldSigIDs[this.topFieldCount++] = id;
1232
+ }
1233
+ /** @internal Removes an instance field SigID from the index (swap-remove). */
1234
+ removeTopFieldSigID(id) {
1235
+ const arr = this.topFieldSigIDs;
1236
+ if (!arr) {
1237
+ return;
1238
+ }
1239
+ const count = this.topFieldCount;
1240
+ for (let i = 0; i < count; i++) {
1241
+ if (arr[i] === id) {
1242
+ arr[i] = arr[--this.topFieldCount];
1243
+ return;
1244
+ }
1245
+ }
1246
+ }
1247
+ // --- Static field SigID index ---
1248
+ /** @internal Checks whether a field with the given SigID is a direct static field. */
1249
+ hasTopStaticFieldWithID(id) {
1250
+ const arr = this.topStaticFieldSigIDs;
1251
+ if (!arr) {
1252
+ return false;
1253
+ }
1254
+ const count = this.topStaticFieldCount;
1255
+ for (let i = 0; i < count; i++) {
1256
+ if (arr[i] === id) {
1257
+ return true;
1258
+ }
1259
+ }
1260
+ return false;
1261
+ }
1262
+ /** @internal Ensures the static field Int32Array has at least minCapacity slots. */
1263
+ ensureTopStaticFieldCapacity(minCapacity) {
1264
+ if (!this.topStaticFieldSigIDs) {
1265
+ this.topStaticFieldSigIDs = new Int32Array(Math.max(minCapacity, 8));
1266
+ return;
1267
+ }
1268
+ if (this.topStaticFieldSigIDs.length < minCapacity) {
1269
+ const newCapacity = Math.max(minCapacity, this.topStaticFieldSigIDs.length * 2);
1270
+ const newArray = new Int32Array(newCapacity);
1271
+ newArray.set(this.topStaticFieldSigIDs.subarray(0, this.topStaticFieldCount));
1272
+ this.topStaticFieldSigIDs = newArray;
1273
+ }
1274
+ }
1275
+ /** @internal Appends a static field SigID to the index. */
1276
+ addTopStaticFieldSigID(id) {
1277
+ this.ensureTopStaticFieldCapacity(this.topStaticFieldCount + 1);
1278
+ this.topStaticFieldSigIDs[this.topStaticFieldCount++] = id;
1279
+ }
1280
+ /** @internal Removes a static field SigID from the index (swap-remove). */
1281
+ removeTopStaticFieldSigID(id) {
1282
+ const arr = this.topStaticFieldSigIDs;
1283
+ if (!arr) {
1284
+ return;
1285
+ }
1286
+ const count = this.topStaticFieldCount;
1287
+ for (let i = 0; i < count; i++) {
1288
+ if (arr[i] === id) {
1289
+ arr[i] = arr[--this.topStaticFieldCount];
1290
+ return;
1291
+ }
1292
+ }
1293
+ }
1294
+ // --- Extended class (subclass back-reference) SigID index ---
1295
+ /** @internal Checks whether a class with the given ClassSigID is a direct subclass. */
1296
+ hasExtendedClassWithID(id) {
1297
+ const arr = this.extendedClassSigIDs;
1298
+ if (!arr) {
1299
+ return false;
1300
+ }
1301
+ const count = this.extendedClassCount;
1302
+ for (let i = 0; i < count; i++) {
1303
+ if (arr[i] === id) {
1304
+ return true;
1305
+ }
1306
+ }
1307
+ return false;
1308
+ }
1309
+ /** @internal Ensures the extended class Int32Array has at least minCapacity slots. */
1310
+ ensureExtendedClassCapacity(minCapacity) {
1311
+ if (!this.extendedClassSigIDs) {
1312
+ this.extendedClassSigIDs = new Int32Array(Math.max(minCapacity, 8));
1313
+ return;
1314
+ }
1315
+ if (this.extendedClassSigIDs.length < minCapacity) {
1316
+ const newCapacity = Math.max(minCapacity, this.extendedClassSigIDs.length * 2);
1317
+ const newArray = new Int32Array(newCapacity);
1318
+ newArray.set(this.extendedClassSigIDs.subarray(0, this.extendedClassCount));
1319
+ this.extendedClassSigIDs = newArray;
1320
+ }
1321
+ }
1322
+ /** @internal Appends a subclass ClassSigID to the index. */
1323
+ addExtendedClassSigID(id) {
1324
+ this.ensureExtendedClassCapacity(this.extendedClassCount + 1);
1325
+ this.extendedClassSigIDs[this.extendedClassCount++] = id;
1326
+ }
1327
+ /** @internal Removes a subclass ClassSigID from the index (swap-remove). */
1328
+ removeExtendedClassSigID(id) {
1329
+ const arr = this.extendedClassSigIDs;
1330
+ if (!arr) {
1331
+ return;
1332
+ }
1333
+ const count = this.extendedClassCount;
1334
+ for (let i = 0; i < count; i++) {
1335
+ if (arr[i] === id) {
1336
+ arr[i] = arr[--this.extendedClassCount];
1337
+ return;
1338
+ }
1339
+ }
634
1340
  }
635
1341
  removeField(field) {
1342
+ const id = field.getFieldSigID();
636
1343
  if (field.isStatic()) {
637
- return this.staticFields.delete(field.getName());
1344
+ const rtn = this.hasTopStaticFieldWithID(id);
1345
+ if (rtn) {
1346
+ this.removeTopStaticFieldSigID(id);
1347
+ this.registry.removeField(field);
1348
+ }
1349
+ return rtn;
1350
+ }
1351
+ const rtn = this.hasTopFieldWithID(id);
1352
+ if (rtn) {
1353
+ this.removeTopFieldSigID(id);
1354
+ this.registry.removeField(field);
638
1355
  }
639
- return this.fields.delete(field.getName());
1356
+ return rtn;
640
1357
  }
641
1358
  removeMethod(method) {
1359
+ var _a, _b, _c;
1360
+ // Remove exactly this method (by its index SigID), not all same-name siblings.
1361
+ const id = (_c = (_a = method.getMethodSigID()) !== null && _a !== void 0 ? _a : (_b = method.getDeclareSigIDs()) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : -1;
642
1362
  let rtn = false;
643
1363
  if (method.isStatic()) {
644
- rtn = this.staticMethods.delete(method.getName());
1364
+ rtn = this.removeTopStaticMethodSigID(id);
645
1365
  }
646
1366
  else {
647
- rtn = this.methods.delete(method.getName());
1367
+ rtn = this.removeTopMethodSigID(id);
648
1368
  }
649
- rtn && (rtn = this.getDeclaringArkFile().getScene().removeMethod(method));
1369
+ rtn && (rtn = this.registry.removeMethod(method));
650
1370
  return rtn;
651
1371
  }
652
1372
  validate() {
653
- return this.validateFields(['declaringArkFile', 'classSignature']);
1373
+ return this.validateFields(['declaringFileID']);
654
1374
  }
655
1375
  addTs2cxxFuncMapElement(funcName, methods) {
656
1376
  this.ts2cxxFuncMap.set(funcName, methods);
@@ -665,41 +1385,51 @@ class ArkClass extends ArkBaseModel_1.ArkBaseModel {
665
1385
  this.classDeclareSignature = classSig;
666
1386
  }
667
1387
  clearAllReferences() {
668
- for (const methods of this.methods.values()) {
669
- for (const mtd of methods) {
670
- mtd.clearAllReferences();
1388
+ var _a, _b;
1389
+ const reg = this.registry;
1390
+ const index = this.methodNameIndex;
1391
+ if (index) {
1392
+ for (const ids of index.values()) {
1393
+ for (let i = 0; i < ids.length; i++) {
1394
+ (_a = reg.methodSigCanonicalizer.getModel(ids[i])) === null || _a === void 0 ? void 0 : _a.clearAllReferences();
1395
+ }
671
1396
  }
672
1397
  }
673
- for (const methods of this.staticMethods.values()) {
674
- for (const mtd of methods) {
675
- mtd.clearAllReferences();
1398
+ const staticIndex = this.staticMethodNameIndex;
1399
+ if (staticIndex) {
1400
+ for (const ids of staticIndex.values()) {
1401
+ for (let i = 0; i < ids.length; i++) {
1402
+ (_b = reg.methodSigCanonicalizer.getModel(ids[i])) === null || _b === void 0 ? void 0 : _b.clearAllReferences();
1403
+ }
676
1404
  }
677
1405
  }
678
- for (const fld of this.fields.values()) {
679
- fld.clearAllReferences();
680
- }
681
- for (const fld of this.staticFields.values()) {
1406
+ for (const fld of this.getFields()) {
682
1407
  fld.clearAllReferences();
683
1408
  }
684
- if (this.instanceInitMethod) {
685
- this.instanceInitMethod.clearAllReferences();
1409
+ const instanceInit = this.getInstanceInitMethodOrNull();
1410
+ if (instanceInit) {
1411
+ instanceInit.clearAllReferences();
686
1412
  }
687
- if (this.staticInitMethod) {
688
- this.staticInitMethod.clearAllReferences();
1413
+ const staticInit = this.getStaticInitMethodOrNull();
1414
+ if (staticInit) {
1415
+ staticInit.clearAllReferences();
689
1416
  }
690
- this.methods.clear();
691
- this.staticMethods.clear();
692
- this.fields.clear();
693
- this.staticFields.clear();
694
- this.extendedClasses.clear();
1417
+ this.methodNameIndex = undefined;
1418
+ this.staticMethodNameIndex = undefined;
1419
+ this.topFieldSigIDs = undefined;
1420
+ this.topFieldCount = 0;
1421
+ this.topStaticFieldSigIDs = undefined;
1422
+ this.topStaticFieldCount = 0;
1423
+ this.extendedClassSigIDs = undefined;
1424
+ this.extendedClassCount = 0;
695
1425
  this.heritageClasses.clear();
696
1426
  this.ts2cxxFuncMap.clear();
697
- this.defaultMethod = null;
698
- this.instanceInitMethod = undefined;
699
- this.staticInitMethod = undefined;
1427
+ this.defaultMethodSigID = undefined;
1428
+ this.instanceInitMethodSigID = undefined;
1429
+ this.staticInitMethodSigID = undefined;
700
1430
  this.viewTree = undefined;
701
- this.declaringArkFile = undefined;
702
- this.declaringArkNamespace = undefined;
1431
+ this.declaringFileID = -1;
1432
+ this.declaringNamespaceSigID = undefined;
703
1433
  }
704
1434
  }
705
1435
  exports.ArkClass = ArkClass;