arkanalyzer 1.0.6 → 1.0.8

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 (224) hide show
  1. package/config/arkanalyzer.json +8 -0
  2. package/docs/IR2ts-stmt.md +81 -0
  3. package/docs/IR2ts.md +82 -0
  4. package/lib/Config.d.ts +29 -1
  5. package/lib/Config.d.ts.map +1 -1
  6. package/lib/Config.js +44 -11
  7. package/lib/Scene.d.ts +152 -9
  8. package/lib/Scene.d.ts.map +1 -1
  9. package/lib/Scene.js +233 -66
  10. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +2 -1
  11. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
  12. package/lib/callgraph/algorithm/AbstractAnalysis.js +14 -7
  13. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
  14. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +2 -4
  15. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
  16. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +2 -3
  17. package/lib/callgraph/common/Statistics.js +1 -1
  18. package/lib/callgraph/model/BaseGraph.js +2 -2
  19. package/lib/callgraph/model/CallGraph.d.ts +3 -2
  20. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  21. package/lib/callgraph/model/CallGraph.js +23 -14
  22. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +2 -2
  23. package/lib/callgraph/model/builder/CallGraphBuilder.js +3 -3
  24. package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
  25. package/lib/callgraph/pointerAnalysis/Context.js +0 -1
  26. package/lib/callgraph/pointerAnalysis/Pag.d.ts +36 -9
  27. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  28. package/lib/callgraph/pointerAnalysis/Pag.js +130 -37
  29. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +34 -5
  30. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  31. package/lib/callgraph/pointerAnalysis/PagBuilder.js +479 -126
  32. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +6 -0
  33. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  34. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +107 -45
  35. package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
  36. package/lib/callgraph/pointerAnalysis/PtsDS.js +0 -2
  37. package/lib/core/base/Constant.d.ts +37 -5
  38. package/lib/core/base/Constant.d.ts.map +1 -1
  39. package/lib/core/base/Constant.js +58 -8
  40. package/lib/core/base/Expr.d.ts +98 -13
  41. package/lib/core/base/Expr.d.ts.map +1 -1
  42. package/lib/core/base/Expr.js +295 -127
  43. package/lib/core/base/Local.d.ts +70 -5
  44. package/lib/core/base/Local.d.ts.map +1 -1
  45. package/lib/core/base/Local.js +77 -4
  46. package/lib/core/base/Ref.d.ts +79 -5
  47. package/lib/core/base/Ref.d.ts.map +1 -1
  48. package/lib/core/base/Ref.js +143 -38
  49. package/lib/core/base/Stmt.d.ts +126 -12
  50. package/lib/core/base/Stmt.d.ts.map +1 -1
  51. package/lib/core/base/Stmt.js +135 -28
  52. package/lib/core/base/Type.d.ts +11 -2
  53. package/lib/core/base/Type.d.ts.map +1 -1
  54. package/lib/core/base/Type.js +47 -42
  55. package/lib/core/base/Value.d.ts +24 -2
  56. package/lib/core/base/Value.d.ts.map +1 -1
  57. package/lib/core/common/ArkError.d.ts +15 -0
  58. package/lib/core/common/ArkError.d.ts.map +1 -0
  59. package/lib/core/common/ArkError.js +28 -0
  60. package/lib/core/common/ArkIRTransformer.d.ts +12 -5
  61. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  62. package/lib/core/common/ArkIRTransformer.js +90 -45
  63. package/lib/core/common/BodyBuilder.d.ts +2 -0
  64. package/lib/core/common/BodyBuilder.d.ts.map +1 -1
  65. package/lib/core/common/BodyBuilder.js +5 -2
  66. package/lib/core/common/Builtin.js +1 -1
  67. package/lib/core/common/CfgBuilder.d.ts +12 -7
  68. package/lib/core/common/CfgBuilder.d.ts.map +1 -1
  69. package/lib/core/common/CfgBuilder.js +336 -140
  70. package/lib/core/common/Const.d.ts +15 -10
  71. package/lib/core/common/Const.d.ts.map +1 -1
  72. package/lib/core/common/Const.js +18 -11
  73. package/lib/core/common/DummyMainCreater.d.ts +5 -4
  74. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  75. package/lib/core/common/DummyMainCreater.js +43 -28
  76. package/lib/core/common/EtsConst.d.ts +1 -0
  77. package/lib/core/common/EtsConst.d.ts.map +1 -1
  78. package/lib/core/common/EtsConst.js +2 -1
  79. package/lib/core/common/ExprUseReplacer.js +8 -8
  80. package/lib/core/common/IRUtils.d.ts +7 -0
  81. package/lib/core/common/IRUtils.d.ts.map +1 -1
  82. package/lib/core/common/IRUtils.js +34 -2
  83. package/lib/core/common/ModelUtils.d.ts +1 -0
  84. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  85. package/lib/core/common/ModelUtils.js +39 -36
  86. package/lib/core/common/RefUseReplacer.js +3 -3
  87. package/lib/core/common/StmtUseReplacer.js +4 -4
  88. package/lib/core/common/TSConst.d.ts +10 -3
  89. package/lib/core/common/TSConst.d.ts.map +1 -1
  90. package/lib/core/common/TSConst.js +11 -4
  91. package/lib/core/common/TypeInference.d.ts +8 -2
  92. package/lib/core/common/TypeInference.d.ts.map +1 -1
  93. package/lib/core/common/TypeInference.js +222 -90
  94. package/lib/core/common/ValueUtil.d.ts +0 -4
  95. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  96. package/lib/core/common/ValueUtil.js +10 -27
  97. package/lib/core/common/VisibleValue.js +1 -1
  98. package/lib/core/dataflow/DataflowProblem.d.ts +1 -0
  99. package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
  100. package/lib/core/dataflow/DataflowProblem.js +4 -4
  101. package/lib/core/dataflow/DataflowSolver.d.ts +20 -16
  102. package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
  103. package/lib/core/dataflow/DataflowSolver.js +67 -78
  104. package/lib/core/dataflow/TiantAnalysis.d.ts +1 -0
  105. package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -1
  106. package/lib/core/dataflow/TiantAnalysis.js +42 -28
  107. package/lib/core/dataflow/UndefinedVariable.d.ts +15 -1
  108. package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
  109. package/lib/core/dataflow/UndefinedVariable.js +122 -76
  110. package/lib/core/dataflow/Util.d.ts +5 -1
  111. package/lib/core/dataflow/Util.d.ts.map +1 -1
  112. package/lib/core/dataflow/Util.js +43 -22
  113. package/lib/core/graph/BasicBlock.d.ts +72 -0
  114. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  115. package/lib/core/graph/BasicBlock.js +165 -3
  116. package/lib/core/graph/Cfg.d.ts +30 -1
  117. package/lib/core/graph/Cfg.d.ts.map +1 -1
  118. package/lib/core/graph/Cfg.js +131 -11
  119. package/lib/core/graph/DominanceFinder.js +7 -7
  120. package/lib/core/graph/DominanceTree.js +4 -4
  121. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  122. package/lib/core/graph/builder/ViewTreeBuilder.js +6 -5
  123. package/lib/core/model/ArkBaseModel.d.ts +59 -0
  124. package/lib/core/model/ArkBaseModel.d.ts.map +1 -0
  125. package/lib/core/model/ArkBaseModel.js +271 -0
  126. package/lib/core/model/ArkBody.d.ts +3 -9
  127. package/lib/core/model/ArkBody.d.ts.map +1 -1
  128. package/lib/core/model/ArkBody.js +3 -14
  129. package/lib/core/model/ArkClass.d.ts +107 -13
  130. package/lib/core/model/ArkClass.d.ts.map +1 -1
  131. package/lib/core/model/ArkClass.js +152 -54
  132. package/lib/core/model/ArkExport.d.ts +8 -7
  133. package/lib/core/model/ArkExport.d.ts.map +1 -1
  134. package/lib/core/model/ArkExport.js +16 -18
  135. package/lib/core/model/ArkField.d.ts +16 -13
  136. package/lib/core/model/ArkField.d.ts.map +1 -1
  137. package/lib/core/model/ArkField.js +18 -62
  138. package/lib/core/model/ArkFile.d.ts +42 -0
  139. package/lib/core/model/ArkFile.d.ts.map +1 -1
  140. package/lib/core/model/ArkFile.js +58 -0
  141. package/lib/core/model/ArkImport.d.ts +9 -7
  142. package/lib/core/model/ArkImport.d.ts.map +1 -1
  143. package/lib/core/model/ArkImport.js +11 -12
  144. package/lib/core/model/ArkMetadata.d.ts +20 -0
  145. package/lib/core/model/ArkMetadata.d.ts.map +1 -0
  146. package/lib/core/model/ArkMetadata.js +44 -0
  147. package/lib/core/model/ArkMethod.d.ts +195 -17
  148. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  149. package/lib/core/model/ArkMethod.js +363 -46
  150. package/lib/core/model/ArkNamespace.d.ts +6 -8
  151. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  152. package/lib/core/model/ArkNamespace.js +16 -20
  153. package/lib/core/model/ArkSignature.d.ts +41 -0
  154. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  155. package/lib/core/model/ArkSignature.js +76 -19
  156. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  157. package/lib/core/model/builder/ArkClassBuilder.js +60 -49
  158. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
  159. package/lib/core/model/builder/ArkExportBuilder.js +12 -6
  160. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  161. package/lib/core/model/builder/ArkFieldBuilder.js +13 -9
  162. package/lib/core/model/builder/ArkFileBuilder.js +1 -3
  163. package/lib/core/model/builder/ArkImportBuilder.d.ts +2 -1
  164. package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
  165. package/lib/core/model/builder/ArkImportBuilder.js +16 -13
  166. package/lib/core/model/builder/ArkMethodBuilder.d.ts +3 -1
  167. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  168. package/lib/core/model/builder/ArkMethodBuilder.js +105 -45
  169. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  170. package/lib/core/model/builder/ArkNamespaceBuilder.js +4 -5
  171. package/lib/core/model/builder/builderUtils.d.ts +2 -1
  172. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  173. package/lib/core/model/builder/builderUtils.js +63 -43
  174. package/lib/index.d.ts +2 -1
  175. package/lib/index.d.ts.map +1 -1
  176. package/lib/index.js +4 -3
  177. package/lib/save/ArkStream.js +1 -1
  178. package/lib/save/DotPrinter.d.ts.map +1 -1
  179. package/lib/save/DotPrinter.js +1 -15
  180. package/lib/save/GraphPrinter.d.ts.map +1 -1
  181. package/lib/save/GraphPrinter.js +4 -2
  182. package/lib/save/JsonPrinter.js +5 -5
  183. package/lib/save/ViewTreePrinter.d.ts +16 -0
  184. package/lib/save/ViewTreePrinter.d.ts.map +1 -0
  185. package/lib/save/ViewTreePrinter.js +130 -0
  186. package/lib/save/source/SourceBase.d.ts +2 -2
  187. package/lib/save/source/SourceBase.d.ts.map +1 -1
  188. package/lib/save/source/SourceBase.js +6 -13
  189. package/lib/save/source/SourceBody.d.ts.map +1 -1
  190. package/lib/save/source/SourceBody.js +27 -14
  191. package/lib/save/source/SourceClass.d.ts.map +1 -1
  192. package/lib/save/source/SourceClass.js +12 -8
  193. package/lib/save/source/SourceField.d.ts.map +1 -1
  194. package/lib/save/source/SourceField.js +6 -2
  195. package/lib/save/source/SourceMethod.d.ts.map +1 -1
  196. package/lib/save/source/SourceMethod.js +10 -3
  197. package/lib/save/source/SourceModule.d.ts.map +1 -1
  198. package/lib/save/source/SourceModule.js +16 -10
  199. package/lib/save/source/SourceNamespace.d.ts.map +1 -1
  200. package/lib/save/source/SourceNamespace.js +4 -0
  201. package/lib/save/source/SourceStmt.d.ts +1 -1
  202. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  203. package/lib/save/source/SourceStmt.js +37 -25
  204. package/lib/save/source/SourceTransformer.d.ts +6 -0
  205. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  206. package/lib/save/source/SourceTransformer.js +82 -51
  207. package/lib/save/source/SourceUtils.d.ts.map +1 -1
  208. package/lib/save/source/SourceUtils.js +12 -11
  209. package/lib/transformer/StaticSingleAssignmentFormer.js +3 -3
  210. package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
  211. package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
  212. package/lib/utils/CfgStructualAnalysis.js +103 -72
  213. package/lib/utils/callGraphUtils.d.ts.map +1 -1
  214. package/lib/utils/callGraphUtils.js +7 -10
  215. package/lib/utils/crypto_utils.d.ts +6 -0
  216. package/lib/utils/crypto_utils.d.ts.map +1 -0
  217. package/lib/utils/crypto_utils.js +57 -0
  218. package/lib/utils/entryMethodUtils.d.ts.map +1 -1
  219. package/lib/utils/entryMethodUtils.js +27 -26
  220. package/lib/utils/getAllFiles.d.ts +1 -1
  221. package/lib/utils/getAllFiles.d.ts.map +1 -1
  222. package/lib/utils/getAllFiles.js +4 -5
  223. package/lib/utils/logger.js +2 -2
  224. package/package.json +3 -2
@@ -28,7 +28,7 @@ var CodeBlockType;
28
28
  CodeBlockType[CodeBlockType["WHILE"] = 7] = "WHILE";
29
29
  CodeBlockType[CodeBlockType["FOR"] = 8] = "FOR";
30
30
  CodeBlockType[CodeBlockType["COMPOUND_END"] = 9] = "COMPOUND_END";
31
- })(CodeBlockType || (exports.CodeBlockType = CodeBlockType = {}));
31
+ })(CodeBlockType = exports.CodeBlockType || (exports.CodeBlockType = {}));
32
32
  class AbstractFlowGraph {
33
33
  constructor(cfg) {
34
34
  this.nodes = [];
@@ -83,7 +83,7 @@ class AbstractFlowGraph {
83
83
  let node = this.nodes[i];
84
84
  let nset = new Set();
85
85
  let rtype = this.identifyRegionType(node, nset);
86
- if (rtype != undefined) {
86
+ if (rtype !== undefined) {
87
87
  let p = this.reduce(rtype, nset);
88
88
  if (p) {
89
89
  if (nset.has(this.entry)) {
@@ -145,12 +145,15 @@ class AbstractFlowGraph {
145
145
  let dom = this.buildDominator();
146
146
  let loops = [];
147
147
  for (const header of this.nodes) {
148
- let innermost = undefined;
148
+ let innermost;
149
149
  let longest = 0;
150
150
  let backEdges = this.getBackEdges(dom, header);
151
- if (backEdges.size == 0) {
151
+ if (backEdges.size === 0) {
152
152
  continue;
153
153
  }
154
+ if (this.isSelfLoopNode(header)) {
155
+ loops.push(new Set([header]));
156
+ }
154
157
  for (const start of backEdges) {
155
158
  let loop = this.naturalLoop(start, header);
156
159
  if (!innermost || loop.size > longest) {
@@ -167,7 +170,7 @@ class AbstractFlowGraph {
167
170
  let domin = new Map();
168
171
  domin.set(this.entry, new Set([this.entry]));
169
172
  for (const node of this.nodes) {
170
- if (node != this.entry) {
173
+ if (node !== this.entry) {
171
174
  domin.set(node, new Set(this.nodes));
172
175
  }
173
176
  }
@@ -175,7 +178,7 @@ class AbstractFlowGraph {
175
178
  while (change) {
176
179
  change = false;
177
180
  for (const node of this.nodes) {
178
- if (node == this.entry) {
181
+ if (node === this.entry) {
179
182
  continue;
180
183
  }
181
184
  let t = new Set(domin.get(node));
@@ -218,10 +221,25 @@ class AbstractFlowGraph {
218
221
  }
219
222
  return loop;
220
223
  }
224
+ isSelfLoopNode(node) {
225
+ let inSucc = false;
226
+ let inPred = false;
227
+ for (const pred of node.getPred()) {
228
+ if (pred === node) {
229
+ inPred = true;
230
+ }
231
+ }
232
+ for (const succ of node.getSucc()) {
233
+ if (succ === node) {
234
+ inSucc = true;
235
+ }
236
+ }
237
+ return inSucc && inPred;
238
+ }
221
239
  isForLoopIncNode(node) {
222
240
  for (const loop of this.loopMap.values()) {
223
- if (loop.getType() == RegionType.FOR_LOOP_REGION) {
224
- if (node == loop.inc) {
241
+ if (loop.getType() === RegionType.FOR_LOOP_REGION) {
242
+ if (node === loop.inc) {
225
243
  return true;
226
244
  }
227
245
  }
@@ -236,12 +254,12 @@ class AbstractFlowGraph {
236
254
  }
237
255
  isIfRegion(node, nodeSet) {
238
256
  nodeSet.clear();
239
- if (node.getSucc().length != 2) {
257
+ if (node.getSucc().length !== 2) {
240
258
  return false;
241
259
  }
242
260
  let m = node.getSucc()[0];
243
261
  let n = node.getSucc()[1];
244
- if (m.getSucc().length == 1 && m.getSucc()[0] == n) {
262
+ if (m.getSucc().length === 1 && m.getSucc()[0] === n) {
245
263
  nodeSet.add(node).add(m);
246
264
  return true;
247
265
  }
@@ -249,7 +267,7 @@ class AbstractFlowGraph {
249
267
  }
250
268
  isIfExitRegion(node, nodeSet) {
251
269
  nodeSet.clear();
252
- if (node.getSucc().length != 2) {
270
+ if (node.getSucc().length !== 2) {
253
271
  return false;
254
272
  }
255
273
  let m = node.getSucc()[0];
@@ -261,17 +279,17 @@ class AbstractFlowGraph {
261
279
  }
262
280
  isIfElseRegion(node, nodeSet) {
263
281
  nodeSet.clear();
264
- if (node.getSucc().length != 2) {
282
+ if (node.getSucc().length !== 2) {
265
283
  return false;
266
284
  }
267
285
  let m = node.getSucc()[0];
268
286
  let n = node.getSucc()[1];
269
- if ((m.getSucc().length == 1 &&
270
- n.getSucc().length == 1 &&
271
- m.getPred().length == 1 &&
272
- n.getPred().length == 1 &&
273
- m.getSucc()[0] == n.getSucc()[0]) ||
274
- (m.getSucc().length == 0 && n.getSucc().length == 0)) {
287
+ if ((m.getSucc().length === 1 &&
288
+ n.getSucc().length === 1 &&
289
+ m.getPred().length === 1 &&
290
+ n.getPred().length === 1 &&
291
+ m.getSucc()[0] === n.getSucc()[0]) ||
292
+ (m.getSucc().length === 0 && n.getSucc().length === 0)) {
275
293
  nodeSet.add(node).add(m).add(n);
276
294
  return true;
277
295
  }
@@ -280,15 +298,15 @@ class AbstractFlowGraph {
280
298
  isBlockRegion(node, nodeSet) {
281
299
  let n = node;
282
300
  let p = true;
283
- let s = n.getSucc().length == 1;
301
+ let s = n.getSucc().length === 1;
284
302
  nodeSet.clear();
285
303
  let blocks = [];
286
304
  while (p && s && !nodeSet.has(n) && this.isValidInBlocks(n)) {
287
305
  nodeSet.add(n);
288
306
  blocks.push(n);
289
307
  n = n.getSucc()[0];
290
- p = n.getPred().length == 1;
291
- s = n.getSucc().length == 1;
308
+ p = n.getPred().length === 1;
309
+ s = n.getSucc().length === 1;
292
310
  }
293
311
  if (p && this.isValidInBlocks(n)) {
294
312
  if (!nodeSet.has(n)) {
@@ -297,7 +315,7 @@ class AbstractFlowGraph {
297
315
  nodeSet.add(n);
298
316
  }
299
317
  n = node;
300
- p = n.getPred().length == 1;
318
+ p = n.getPred().length === 1;
301
319
  s = true;
302
320
  while (p && s && this.isValidInBlocks(n)) {
303
321
  if (!nodeSet.has(n)) {
@@ -308,8 +326,8 @@ class AbstractFlowGraph {
308
326
  if (nodeSet.has(n)) {
309
327
  break;
310
328
  }
311
- p = n.getPred().length == 1;
312
- s = n.getSucc().length == 1;
329
+ p = n.getPred().length === 1;
330
+ s = n.getSucc().length === 1;
313
331
  }
314
332
  if (s && this.isValidInBlocks(n)) {
315
333
  if (!nodeSet.has(n)) {
@@ -333,7 +351,7 @@ class AbstractFlowGraph {
333
351
  nodeSet.add(node);
334
352
  return true;
335
353
  }
336
- if (m.getSucc().length == 1 && this.isExitLoop(m.getSucc()[0], this.structBlocks.get(loop))) {
354
+ if (m.getSucc().length === 1 && this.isExitLoop(m.getSucc()[0], this.structBlocks.get(loop))) {
337
355
  nodeSet.add(node).add(m);
338
356
  return true;
339
357
  }
@@ -347,7 +365,7 @@ class AbstractFlowGraph {
347
365
  nodeSet.add(node);
348
366
  return true;
349
367
  }
350
- if (m.getSucc().length == 1 &&
368
+ if (m.getSucc().length === 1 &&
351
369
  loop.control.has(m.getSucc()[0]) &&
352
370
  !loop.control.has(n) &&
353
371
  !this.isIfElseRegion(node, nodeSet)) {
@@ -359,7 +377,7 @@ class AbstractFlowGraph {
359
377
  isWhileRegion(node, nodeSet, loop) {
360
378
  nodeSet.clear();
361
379
  let m = node.getSucc()[0];
362
- if (loop.header == node && m.getSucc().length == 1 && m.getPred().length == 1 && m.getSucc()[0] == node) {
380
+ if (loop.header === node && m.getSucc().length === 1 && m.getPred().length === 1 && m.getSucc()[0] === node) {
363
381
  nodeSet.add(node).add(m);
364
382
  return true;
365
383
  }
@@ -367,12 +385,12 @@ class AbstractFlowGraph {
367
385
  }
368
386
  isForRegion(node, nodeSet, loop) {
369
387
  nodeSet.clear();
370
- if (loop.header == node && loop.getType() == RegionType.FOR_LOOP_REGION) {
388
+ if (loop.header === node && loop.getType() === RegionType.FOR_LOOP_REGION) {
371
389
  let forLoop = loop;
372
390
  let blocks = node.getSucc()[0];
373
- if (forLoop.inc.getPred().length == 1 &&
374
- forLoop.inc.getPred()[0] == blocks &&
375
- blocks.getSucc().length == 1) {
391
+ if (forLoop.inc.getPred().length === 1 &&
392
+ forLoop.inc.getPred()[0] === blocks &&
393
+ blocks.getSucc().length === 1) {
376
394
  nodeSet.add(node).add(forLoop.inc).add(blocks);
377
395
  return true;
378
396
  }
@@ -381,9 +399,9 @@ class AbstractFlowGraph {
381
399
  }
382
400
  isDoWhileRegion(node, nodeSet, loop) {
383
401
  nodeSet.clear();
384
- if (loop.back == node && loop.getType() == RegionType.DO_WHILE_LOOP_REGION) {
402
+ if (loop.back === node && loop.getType() === RegionType.DO_WHILE_LOOP_REGION) {
385
403
  let blocks = node.getPred()[0];
386
- if (blocks.getSucc().length == 1 && blocks.getSucc()[0] == node && node.getSucc()[0] == blocks) {
404
+ if (blocks.getSucc().length === 1 && blocks.getSucc()[0] === node && node.getSucc()[0] === blocks) {
387
405
  nodeSet.add(blocks).add(node);
388
406
  return true;
389
407
  }
@@ -401,9 +419,12 @@ class AbstractFlowGraph {
401
419
  }
402
420
  if (new Set(node.getPred()).has(node) && new Set(node.getSucc()).has(node)) {
403
421
  nodeSet.add(node);
422
+ if (inLoop) {
423
+ return region === null || region === void 0 ? void 0 : region.getType();
424
+ }
404
425
  return RegionType.SELF_LOOP_REGION;
405
426
  }
406
- if (node.getSucc().length != 2) {
427
+ if (node.getSucc().length !== 2) {
407
428
  return undefined;
408
429
  }
409
430
  if (inLoop) {
@@ -440,11 +461,15 @@ class AbstractFlowGraph {
440
461
  return undefined;
441
462
  }
442
463
  cyclicRegionType(nodeSet) {
443
- var _a, _b;
464
+ var _a, _b, _c;
444
465
  let nodes = Array.from(nodeSet);
445
466
  let header = nodes[0];
446
- if (nodeSet.size == 1) {
447
- return RegionType.SELF_LOOP_REGION;
467
+ if (nodeSet.size === 1) {
468
+ let tail = (_a = nodes[0].getBlock()) === null || _a === void 0 ? void 0 : _a.getTail();
469
+ if (tail instanceof Stmt_1.ArkIfStmt) {
470
+ return RegionType.DO_WHILE_LOOP_REGION;
471
+ }
472
+ return RegionType.WHILE_LOOP_REGION;
448
473
  }
449
474
  let back = nodes[1];
450
475
  // exit loop from back
@@ -458,10 +483,10 @@ class AbstractFlowGraph {
458
483
  }
459
484
  }
460
485
  // for
461
- if (back.getSucc().length == 1 && ((_b = (_a = back.getBlock()) === null || _a === void 0 ? void 0 : _a.getStmts()) === null || _b === void 0 ? void 0 : _b.length) == 1) {
486
+ if (back.getSucc().length === 1 && ((_c = (_b = back.getBlock()) === null || _b === void 0 ? void 0 : _b.getStmts()) === null || _c === void 0 ? void 0 : _c.length) === 1) {
462
487
  let isForLoop = true;
463
488
  for (const pred of header.getPred()) {
464
- if (nodeSet.has(pred) && pred != back) {
489
+ if (nodeSet.has(pred) && pred !== back) {
465
490
  isForLoop = false;
466
491
  }
467
492
  }
@@ -496,38 +521,38 @@ class AbstractFlowGraph {
496
521
  }
497
522
  createRegion(rtype, nodeSet) {
498
523
  let node;
499
- if (rtype == RegionType.BLOCK_REGION) {
524
+ if (rtype === RegionType.BLOCK_REGION) {
500
525
  node = new BlockRegion(nodeSet);
501
526
  }
502
- else if (rtype == RegionType.IF_ELSE_REGION) {
527
+ else if (rtype === RegionType.IF_ELSE_REGION) {
503
528
  node = new IfElseRegion(nodeSet);
504
529
  }
505
- else if (rtype == RegionType.IF_REGION) {
530
+ else if (rtype === RegionType.IF_REGION) {
506
531
  node = new IfRegion(nodeSet);
507
532
  }
508
- else if (rtype == RegionType.IF_THEN_EXIT_REGION) {
533
+ else if (rtype === RegionType.IF_THEN_EXIT_REGION) {
509
534
  node = new IfExitRegion(nodeSet);
510
535
  }
511
- else if (rtype == RegionType.IF_THEN_BREAK_REGION) {
536
+ else if (rtype === RegionType.IF_THEN_BREAK_REGION) {
512
537
  node = new IfBreakRegion(nodeSet);
513
538
  }
514
- else if (rtype == RegionType.IF_THEN_CONTINUE_REGION) {
539
+ else if (rtype === RegionType.IF_THEN_CONTINUE_REGION) {
515
540
  node = new IfContinueRegion(nodeSet);
516
541
  }
517
- else if (rtype == RegionType.SELF_LOOP_REGION) {
542
+ else if (rtype === RegionType.SELF_LOOP_REGION) {
518
543
  node = new SelfLoopRegion(nodeSet);
519
544
  }
520
- else if (rtype == RegionType.WHILE_LOOP_REGION) {
545
+ else if (rtype === RegionType.WHILE_LOOP_REGION) {
521
546
  let whileLoop = new WhileLoopRegion(nodeSet);
522
547
  this.loopMap.set(whileLoop.header, whileLoop);
523
548
  node = whileLoop;
524
549
  }
525
- else if (rtype == RegionType.FOR_LOOP_REGION) {
550
+ else if (rtype === RegionType.FOR_LOOP_REGION) {
526
551
  let forLoop = new ForLoopRegion(nodeSet);
527
552
  this.loopMap.set(forLoop.header, forLoop);
528
553
  node = forLoop;
529
554
  }
530
- else if (rtype == RegionType.DO_WHILE_LOOP_REGION) {
555
+ else if (rtype === RegionType.DO_WHILE_LOOP_REGION) {
531
556
  let doWhileLoop = new DoWhileLoopRegion(nodeSet);
532
557
  this.loopMap.set(doWhileLoop.header, doWhileLoop);
533
558
  node = doWhileLoop;
@@ -557,9 +582,6 @@ class AbstractFlowGraph {
557
582
  }
558
583
  setIntersect(a, b) {
559
584
  let r = new Set();
560
- if (b == undefined) {
561
- debugger;
562
- }
563
585
  for (const n of b) {
564
586
  if (a.has(n)) {
565
587
  r.add(n);
@@ -568,10 +590,10 @@ class AbstractFlowGraph {
568
590
  return r;
569
591
  }
570
592
  isSetEqual(a, b) {
571
- if (a.size != b.size) {
593
+ if (a.size !== b.size) {
572
594
  return false;
573
595
  }
574
- return this.setIntersect(a, b).size == a.size;
596
+ return this.setIntersect(a, b).size === a.size;
575
597
  }
576
598
  }
577
599
  exports.AbstractFlowGraph = AbstractFlowGraph;
@@ -620,7 +642,7 @@ class AbstractNode {
620
642
  }
621
643
  replaceSucc(src, dst) {
622
644
  for (let i = 0; i < this.succNodes.length; i++) {
623
- if (this.succNodes[i] == src) {
645
+ if (this.succNodes[i] === src) {
624
646
  this.succNodes[i] = dst;
625
647
  break;
626
648
  }
@@ -628,7 +650,7 @@ class AbstractNode {
628
650
  }
629
651
  removeSucc(src) {
630
652
  for (let i = 0; i < this.predNodes.length; i++) {
631
- if (this.succNodes[i] == src) {
653
+ if (this.succNodes[i] === src) {
632
654
  this.succNodes.splice(i, 1);
633
655
  break;
634
656
  }
@@ -642,7 +664,7 @@ class AbstractNode {
642
664
  }
643
665
  replacePred(src, dst) {
644
666
  for (let i = 0; i < this.predNodes.length; i++) {
645
- if (this.predNodes[i] == src) {
667
+ if (this.predNodes[i] === src) {
646
668
  this.predNodes[i] = dst;
647
669
  break;
648
670
  }
@@ -650,7 +672,7 @@ class AbstractNode {
650
672
  }
651
673
  removePred(src) {
652
674
  for (let i = 0; i < this.predNodes.length; i++) {
653
- if (this.predNodes[i] == src) {
675
+ if (this.predNodes[i] === src) {
654
676
  this.predNodes.splice(i, 1);
655
677
  break;
656
678
  }
@@ -718,7 +740,12 @@ class NaturalLoopRegion extends Region {
718
740
  super(nset, type);
719
741
  let nodes = Array.from(nset);
720
742
  this.header = nodes[0];
721
- this.back = nodes[1];
743
+ if (nset.size > 1) {
744
+ this.back = nodes[1];
745
+ }
746
+ else {
747
+ this.back = nodes[0];
748
+ }
722
749
  this.control = new Set([this.header]);
723
750
  }
724
751
  replace() {
@@ -736,7 +763,7 @@ class NaturalLoopRegion extends Region {
736
763
  }
737
764
  }
738
765
  }
739
- if (succNodes.size == 0) {
766
+ if (succNodes.size === 0) {
740
767
  return;
741
768
  }
742
769
  let pred = Array.from(succNodes)[0];
@@ -759,9 +786,9 @@ class NaturalLoopRegion extends Region {
759
786
  for (const node of this.nset) {
760
787
  for (const succ of node.getSucc()) {
761
788
  if (!this.nset.has(succ) &&
762
- succ != this.getExitNode() &&
763
- succ.getSucc().length == 1 &&
764
- succ.getSucc()[0] == this.getExitNode()) {
789
+ succ !== this.getExitNode() &&
790
+ succ.getSucc().length === 1 &&
791
+ succ.getSucc()[0] === this.getExitNode()) {
765
792
  this.nset.add(succ);
766
793
  }
767
794
  }
@@ -775,13 +802,13 @@ class SelfLoopRegion extends NaturalLoopRegion {
775
802
  }
776
803
  replace() {
777
804
  for (let pred of this.header.getPred()) {
778
- if (pred != this.header) {
805
+ if (pred !== this.header) {
779
806
  pred.replaceSucc(this.header, this);
780
807
  this.addPred(pred);
781
808
  }
782
809
  }
783
810
  for (let succ of this.header.getSucc()) {
784
- if (succ != this.header) {
811
+ if (succ !== this.header) {
785
812
  succ.replacePred(this.header, this);
786
813
  this.addSucc(succ);
787
814
  }
@@ -797,7 +824,9 @@ class WhileLoopRegion extends NaturalLoopRegion {
797
824
  }
798
825
  traversal(callback) {
799
826
  this.header.traversal(callback, CodeBlockType.WHILE);
800
- this.back.traversal(callback, CodeBlockType.NORMAL);
827
+ if (this.header !== this.back) {
828
+ this.back.traversal(callback, CodeBlockType.NORMAL);
829
+ }
801
830
  callback(undefined, CodeBlockType.COMPOUND_END);
802
831
  }
803
832
  getExitNode() {
@@ -812,7 +841,9 @@ class DoWhileLoopRegion extends NaturalLoopRegion {
812
841
  }
813
842
  traversal(callback) {
814
843
  callback(undefined, CodeBlockType.DO);
815
- this.header.traversal(callback, CodeBlockType.NORMAL);
844
+ if (this.header !== this.back) {
845
+ this.header.traversal(callback, CodeBlockType.NORMAL);
846
+ }
816
847
  this.back.traversal(callback, CodeBlockType.DO_WHILE);
817
848
  }
818
849
  getExitNode() {
@@ -828,7 +859,7 @@ class ForLoopRegion extends NaturalLoopRegion {
828
859
  traversal(callback) {
829
860
  this.header.traversal(callback, CodeBlockType.FOR);
830
861
  for (const node of this.nset) {
831
- if (node != this.header && node != this.inc) {
862
+ if (node !== this.header && node !== this.inc) {
832
863
  node.traversal(callback, CodeBlockType.NORMAL);
833
864
  }
834
865
  }
@@ -848,7 +879,7 @@ class IfRegion extends Region {
848
879
  replace() {
849
880
  this.replaceContitionPred();
850
881
  for (let succ of this.then.getSucc()) {
851
- if (succ != this.then) {
882
+ if (succ !== this.then) {
852
883
  succ.replacePred(this.then, this);
853
884
  succ.removePred(this.contition);
854
885
  this.addSucc(succ);
@@ -862,7 +893,7 @@ class IfRegion extends Region {
862
893
  }
863
894
  replaceContitionPred() {
864
895
  for (let pred of this.contition.getPred()) {
865
- if (pred != this.contition) {
896
+ if (pred !== this.contition) {
866
897
  pred.replaceSucc(this.contition, this);
867
898
  this.addPred(pred);
868
899
  }
@@ -932,13 +963,13 @@ class IfElseRegion extends Region {
932
963
  }
933
964
  replace() {
934
965
  for (let pred of this.contition.getPred()) {
935
- if (pred != this.contition) {
966
+ if (pred !== this.contition) {
936
967
  pred.replaceSucc(this.contition, this);
937
968
  this.addPred(pred);
938
969
  }
939
970
  }
940
971
  for (let succ of this.then.getSucc()) {
941
- if (succ != this.then) {
972
+ if (succ !== this.then) {
942
973
  succ.replacePred(this.then, this);
943
974
  succ.removePred(this.else);
944
975
  this.addSucc(succ);
@@ -1 +1 @@
1
- {"version":3,"file":"callGraphUtils.d.ts","sourceRoot":"","sources":["../../src/utils/callGraphUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAM7E,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,SAAS,CA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AG,IAAI;IAiBpD,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI;IAkBnD,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,EAAE;CAmClE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAOtG;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAY5D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,eAAe,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAsB1I;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/D"}
@@ -94,14 +94,12 @@ class SceneManager {
94
94
  let targetMethod = this._scene.getMethod(method);
95
95
  if (targetMethod == null) {
96
96
  // 支持SDK调用解析
97
- let sdkMap = this.scene.getSdkArkFilesMap();
98
- for (let file of sdkMap.values()) {
99
- if (file.getFileSignature().toString() == method.getDeclaringClassSignature().getDeclaringFileSignature().toString()) {
100
- const methods = ModelUtils_1.ModelUtils.getAllMethodsInFile(file);
101
- for (let methodUnderFile of methods) {
102
- if (method.toString() == methodUnderFile.getSignature().toString()) {
103
- return methodUnderFile;
104
- }
97
+ let file = this._scene.getFile(method.getDeclaringClassSignature().getDeclaringFileSignature());
98
+ if (file) {
99
+ const methods = ModelUtils_1.ModelUtils.getAllMethodsInFile(file);
100
+ for (let methodUnderFile of methods) {
101
+ if (method.toString() === methodUnderFile.getSignature().toString()) {
102
+ return methodUnderFile;
105
103
  }
106
104
  }
107
105
  }
@@ -113,8 +111,7 @@ class SceneManager {
113
111
  return null;
114
112
  let classInstance = this._scene.getClass(arkClass);
115
113
  if (classInstance == null) {
116
- let sdkOrTargetProjectFile = this._scene.getSdkArkFilesMap()
117
- .get(arkClass.getDeclaringFileSignature().toString());
114
+ let sdkOrTargetProjectFile = this._scene.getFile(arkClass.getDeclaringFileSignature());
118
115
  // TODO: support get sdk class, targetProject class waiting to be supported
119
116
  if (sdkOrTargetProjectFile != null) {
120
117
  for (let classUnderFile of ModelUtils_1.ModelUtils.getAllClassesInFile(sdkOrTargetProjectFile)) {
@@ -0,0 +1,6 @@
1
+ export declare class CryptoUtils {
2
+ static sha256(content: string): string;
3
+ static hash(content: string, algorithm: string): string;
4
+ static hashcode(content: string): number;
5
+ }
6
+ //# sourceMappingURL=crypto_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto_utils.d.ts","sourceRoot":"","sources":["../../src/utils/crypto_utils.ts"],"names":[],"mappings":"AAiBA,qBAAa,WAAW;WAEN,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;WAI/B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;WAIhD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAOlD"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.CryptoUtils = void 0;
41
+ const crypto = __importStar(require("crypto"));
42
+ class CryptoUtils {
43
+ static sha256(content) {
44
+ return this.hash(content, 'sha256');
45
+ }
46
+ static hash(content, algorithm) {
47
+ return crypto.createHash(algorithm).update(content).digest('base64url');
48
+ }
49
+ static hashcode(content) {
50
+ let h = 0;
51
+ for (let i = 0; i < content.length; i++) {
52
+ h = Math.imul(31, h) + content.charCodeAt(i) | 0;
53
+ }
54
+ return h;
55
+ }
56
+ }
57
+ exports.CryptoUtils = CryptoUtils;
@@ -1 +1 @@
1
- {"version":3,"file":"entryMethodUtils.d.ts","sourceRoot":"","sources":["../../src/utils/entryMethodUtils.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,eAAO,MAAM,qBA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