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.
- package/config/arkanalyzer.json +8 -0
- package/docs/IR2ts-stmt.md +81 -0
- package/docs/IR2ts.md +82 -0
- package/lib/Config.d.ts +29 -1
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +44 -11
- package/lib/Scene.d.ts +152 -9
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +233 -66
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +2 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +14 -7
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +2 -4
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +2 -3
- package/lib/callgraph/common/Statistics.js +1 -1
- package/lib/callgraph/model/BaseGraph.js +2 -2
- package/lib/callgraph/model/CallGraph.d.ts +3 -2
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +23 -14
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +2 -2
- package/lib/callgraph/model/builder/CallGraphBuilder.js +3 -3
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Context.js +0 -1
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +36 -9
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +130 -37
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +34 -5
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +479 -126
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +6 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +107 -45
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.js +0 -2
- package/lib/core/base/Constant.d.ts +37 -5
- package/lib/core/base/Constant.d.ts.map +1 -1
- package/lib/core/base/Constant.js +58 -8
- package/lib/core/base/Expr.d.ts +98 -13
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +295 -127
- package/lib/core/base/Local.d.ts +70 -5
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +77 -4
- package/lib/core/base/Ref.d.ts +79 -5
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +143 -38
- package/lib/core/base/Stmt.d.ts +126 -12
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +135 -28
- package/lib/core/base/Type.d.ts +11 -2
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +47 -42
- package/lib/core/base/Value.d.ts +24 -2
- package/lib/core/base/Value.d.ts.map +1 -1
- package/lib/core/common/ArkError.d.ts +15 -0
- package/lib/core/common/ArkError.d.ts.map +1 -0
- package/lib/core/common/ArkError.js +28 -0
- package/lib/core/common/ArkIRTransformer.d.ts +12 -5
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +90 -45
- package/lib/core/common/BodyBuilder.d.ts +2 -0
- package/lib/core/common/BodyBuilder.d.ts.map +1 -1
- package/lib/core/common/BodyBuilder.js +5 -2
- package/lib/core/common/Builtin.js +1 -1
- package/lib/core/common/CfgBuilder.d.ts +12 -7
- package/lib/core/common/CfgBuilder.d.ts.map +1 -1
- package/lib/core/common/CfgBuilder.js +336 -140
- package/lib/core/common/Const.d.ts +15 -10
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +18 -11
- package/lib/core/common/DummyMainCreater.d.ts +5 -4
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +43 -28
- package/lib/core/common/EtsConst.d.ts +1 -0
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +2 -1
- package/lib/core/common/ExprUseReplacer.js +8 -8
- package/lib/core/common/IRUtils.d.ts +7 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +34 -2
- package/lib/core/common/ModelUtils.d.ts +1 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +39 -36
- package/lib/core/common/RefUseReplacer.js +3 -3
- package/lib/core/common/StmtUseReplacer.js +4 -4
- package/lib/core/common/TSConst.d.ts +10 -3
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TSConst.js +11 -4
- package/lib/core/common/TypeInference.d.ts +8 -2
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +222 -90
- package/lib/core/common/ValueUtil.d.ts +0 -4
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +10 -27
- package/lib/core/common/VisibleValue.js +1 -1
- package/lib/core/dataflow/DataflowProblem.d.ts +1 -0
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowProblem.js +4 -4
- package/lib/core/dataflow/DataflowSolver.d.ts +20 -16
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +67 -78
- package/lib/core/dataflow/TiantAnalysis.d.ts +1 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -1
- package/lib/core/dataflow/TiantAnalysis.js +42 -28
- package/lib/core/dataflow/UndefinedVariable.d.ts +15 -1
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
- package/lib/core/dataflow/UndefinedVariable.js +122 -76
- package/lib/core/dataflow/Util.d.ts +5 -1
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +43 -22
- package/lib/core/graph/BasicBlock.d.ts +72 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +165 -3
- package/lib/core/graph/Cfg.d.ts +30 -1
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +131 -11
- package/lib/core/graph/DominanceFinder.js +7 -7
- package/lib/core/graph/DominanceTree.js +4 -4
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +6 -5
- package/lib/core/model/ArkBaseModel.d.ts +59 -0
- package/lib/core/model/ArkBaseModel.d.ts.map +1 -0
- package/lib/core/model/ArkBaseModel.js +271 -0
- package/lib/core/model/ArkBody.d.ts +3 -9
- package/lib/core/model/ArkBody.d.ts.map +1 -1
- package/lib/core/model/ArkBody.js +3 -14
- package/lib/core/model/ArkClass.d.ts +107 -13
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +152 -54
- package/lib/core/model/ArkExport.d.ts +8 -7
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +16 -18
- package/lib/core/model/ArkField.d.ts +16 -13
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +18 -62
- package/lib/core/model/ArkFile.d.ts +42 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +58 -0
- package/lib/core/model/ArkImport.d.ts +9 -7
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +11 -12
- package/lib/core/model/ArkMetadata.d.ts +20 -0
- package/lib/core/model/ArkMetadata.d.ts.map +1 -0
- package/lib/core/model/ArkMetadata.js +44 -0
- package/lib/core/model/ArkMethod.d.ts +195 -17
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +363 -46
- package/lib/core/model/ArkNamespace.d.ts +6 -8
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +16 -20
- package/lib/core/model/ArkSignature.d.ts +41 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +76 -19
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +60 -49
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +12 -6
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +13 -9
- package/lib/core/model/builder/ArkFileBuilder.js +1 -3
- package/lib/core/model/builder/ArkImportBuilder.d.ts +2 -1
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkImportBuilder.js +16 -13
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +3 -1
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +105 -45
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +4 -5
- package/lib/core/model/builder/builderUtils.d.ts +2 -1
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +63 -43
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/save/ArkStream.js +1 -1
- package/lib/save/DotPrinter.d.ts.map +1 -1
- package/lib/save/DotPrinter.js +1 -15
- package/lib/save/GraphPrinter.d.ts.map +1 -1
- package/lib/save/GraphPrinter.js +4 -2
- package/lib/save/JsonPrinter.js +5 -5
- package/lib/save/ViewTreePrinter.d.ts +16 -0
- package/lib/save/ViewTreePrinter.d.ts.map +1 -0
- package/lib/save/ViewTreePrinter.js +130 -0
- package/lib/save/source/SourceBase.d.ts +2 -2
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +6 -13
- package/lib/save/source/SourceBody.d.ts.map +1 -1
- package/lib/save/source/SourceBody.js +27 -14
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +12 -8
- package/lib/save/source/SourceField.d.ts.map +1 -1
- package/lib/save/source/SourceField.js +6 -2
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +10 -3
- package/lib/save/source/SourceModule.d.ts.map +1 -1
- package/lib/save/source/SourceModule.js +16 -10
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +4 -0
- package/lib/save/source/SourceStmt.d.ts +1 -1
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +37 -25
- package/lib/save/source/SourceTransformer.d.ts +6 -0
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +82 -51
- package/lib/save/source/SourceUtils.d.ts.map +1 -1
- package/lib/save/source/SourceUtils.js +12 -11
- package/lib/transformer/StaticSingleAssignmentFormer.js +3 -3
- package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
- package/lib/utils/CfgStructualAnalysis.js +103 -72
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +7 -10
- package/lib/utils/crypto_utils.d.ts +6 -0
- package/lib/utils/crypto_utils.d.ts.map +1 -0
- package/lib/utils/crypto_utils.js +57 -0
- package/lib/utils/entryMethodUtils.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +27 -26
- package/lib/utils/getAllFiles.d.ts +1 -1
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/getAllFiles.js +4 -5
- package/lib/utils/logger.js +2 -2
- 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
|
|
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
|
|
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
|
|
148
|
+
let innermost;
|
|
149
149
|
let longest = 0;
|
|
150
150
|
let backEdges = this.getBackEdges(dom, header);
|
|
151
|
-
if (backEdges.size
|
|
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
|
|
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
|
|
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()
|
|
224
|
-
if (node
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
270
|
-
n.getSucc().length
|
|
271
|
-
m.getPred().length
|
|
272
|
-
n.getPred().length
|
|
273
|
-
m.getSucc()[0]
|
|
274
|
-
(m.getSucc().length
|
|
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
|
|
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
|
|
291
|
-
s = n.getSucc().length
|
|
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
|
|
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
|
|
312
|
-
s = n.getSucc().length
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
374
|
-
forLoop.inc.getPred()[0]
|
|
375
|
-
blocks.getSucc().length
|
|
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
|
|
402
|
+
if (loop.back === node && loop.getType() === RegionType.DO_WHILE_LOOP_REGION) {
|
|
385
403
|
let blocks = node.getPred()[0];
|
|
386
|
-
if (blocks.getSucc().length
|
|
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
|
|
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
|
|
447
|
-
|
|
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
|
|
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
|
|
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
|
|
524
|
+
if (rtype === RegionType.BLOCK_REGION) {
|
|
500
525
|
node = new BlockRegion(nodeSet);
|
|
501
526
|
}
|
|
502
|
-
else if (rtype
|
|
527
|
+
else if (rtype === RegionType.IF_ELSE_REGION) {
|
|
503
528
|
node = new IfElseRegion(nodeSet);
|
|
504
529
|
}
|
|
505
|
-
else if (rtype
|
|
530
|
+
else if (rtype === RegionType.IF_REGION) {
|
|
506
531
|
node = new IfRegion(nodeSet);
|
|
507
532
|
}
|
|
508
|
-
else if (rtype
|
|
533
|
+
else if (rtype === RegionType.IF_THEN_EXIT_REGION) {
|
|
509
534
|
node = new IfExitRegion(nodeSet);
|
|
510
535
|
}
|
|
511
|
-
else if (rtype
|
|
536
|
+
else if (rtype === RegionType.IF_THEN_BREAK_REGION) {
|
|
512
537
|
node = new IfBreakRegion(nodeSet);
|
|
513
538
|
}
|
|
514
|
-
else if (rtype
|
|
539
|
+
else if (rtype === RegionType.IF_THEN_CONTINUE_REGION) {
|
|
515
540
|
node = new IfContinueRegion(nodeSet);
|
|
516
541
|
}
|
|
517
|
-
else if (rtype
|
|
542
|
+
else if (rtype === RegionType.SELF_LOOP_REGION) {
|
|
518
543
|
node = new SelfLoopRegion(nodeSet);
|
|
519
544
|
}
|
|
520
|
-
else if (rtype
|
|
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
|
|
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
|
|
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
|
|
593
|
+
if (a.size !== b.size) {
|
|
572
594
|
return false;
|
|
573
595
|
}
|
|
574
|
-
return this.setIntersect(a, b).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]
|
|
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]
|
|
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]
|
|
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]
|
|
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
|
-
|
|
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
|
|
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
|
|
763
|
-
succ.getSucc().length
|
|
764
|
-
succ.getSucc()[0]
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,CAAyB;IAC1C,OAAO,CAAC,cAAc,CAAyB;IAE/C,IAAI,QAAQ,IAAI,eAAe,EAAE,CAEhC;IAED,IAAI,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,EAEnC;IAED,IAAI,aAAa,IAAI,eAAe,EAAE,CAErC;IAED,IAAI,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,EAExC;IAEM,cAAc,CAAC,SAAS,EAAE,eAAe,GAAG,eAAe,GAAG,SAAS;IAIvE,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO;IAKxD,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAU/C,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAUpD,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAIpD,uBAAuB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;CAGnE;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAS;IAEvB,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,EAErB;IAEM,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI;
|
|
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,CAAyB;IAC1C,OAAO,CAAC,cAAc,CAAyB;IAE/C,IAAI,QAAQ,IAAI,eAAe,EAAE,CAEhC;IAED,IAAI,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,EAEnC;IAED,IAAI,aAAa,IAAI,eAAe,EAAE,CAErC;IAED,IAAI,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,EAExC;IAEM,cAAc,CAAC,SAAS,EAAE,eAAe,GAAG,eAAe,GAAG,SAAS;IAIvE,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO;IAKxD,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAU/C,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAUpD,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAIpD,uBAAuB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;CAGnE;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAS;IAEvB,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,EAErB;IAEM,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,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
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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.
|
|
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 @@
|
|
|
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,qBAAqB,EAAE,MAAM,
|
|
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,qBAAqB,EAAE,MAAM,EA2BvC,CAAC;AACJ,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAiBtC,CAAC;AAEJ,eAAO,MAAM,+BAA+B,EAAE,MAAM,EAkBnD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,EAAE,CAuBtG;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAcpF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAS5C"}
|