arkanalyzer 1.0.5
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/LICENSE +201 -0
- package/README.en.md +88 -0
- package/README.md +98 -0
- package/docs/HowToCreatePR.md +55 -0
- package/docs/HowToHandleIssues.md +155 -0
- package/docs/quickstart.pdf +0 -0
- package/lib/Config.d.ts +26 -0
- package/lib/Config.d.ts.map +1 -0
- package/lib/Config.js +128 -0
- package/lib/Scene.d.ts +125 -0
- package/lib/Scene.d.ts.map +1 -0
- package/lib/Scene.js +762 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +28 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.js +137 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts +11 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +71 -0
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +16 -0
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -0
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +147 -0
- package/lib/callgraph/common/Statistics.d.ts +58 -0
- package/lib/callgraph/common/Statistics.d.ts.map +1 -0
- package/lib/callgraph/common/Statistics.js +203 -0
- package/lib/callgraph/model/BaseGraph.d.ts +62 -0
- package/lib/callgraph/model/BaseGraph.d.ts.map +1 -0
- package/lib/callgraph/model/BaseGraph.js +158 -0
- package/lib/callgraph/model/CallGraph.d.ts +94 -0
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -0
- package/lib/callgraph/model/CallGraph.js +339 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +16 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.js +106 -0
- package/lib/callgraph/pointerAnalysis/Context.d.ts +38 -0
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/Context.js +156 -0
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts +23 -0
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +104 -0
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +209 -0
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/Pag.js +774 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +88 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +821 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +64 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +502 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +9 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +57 -0
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +58 -0
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PtsDS.js +234 -0
- package/lib/core/base/Constant.d.ts +17 -0
- package/lib/core/base/Constant.d.ts.map +1 -0
- package/lib/core/base/Constant.js +53 -0
- package/lib/core/base/Decorator.d.ts +15 -0
- package/lib/core/base/Decorator.d.ts.map +1 -0
- package/lib/core/base/Decorator.js +43 -0
- package/lib/core/base/DefUseChain.d.ts +9 -0
- package/lib/core/base/DefUseChain.d.ts.map +1 -0
- package/lib/core/base/DefUseChain.js +25 -0
- package/lib/core/base/Expr.d.ts +219 -0
- package/lib/core/base/Expr.d.ts.map +1 -0
- package/lib/core/base/Expr.js +896 -0
- package/lib/core/base/Local.d.ts +40 -0
- package/lib/core/base/Local.d.ts.map +1 -0
- package/lib/core/base/Local.js +101 -0
- package/lib/core/base/Position.d.ts +39 -0
- package/lib/core/base/Position.d.ts.map +1 -0
- package/lib/core/base/Position.js +86 -0
- package/lib/core/base/Ref.d.ts +75 -0
- package/lib/core/base/Ref.d.ts.map +1 -0
- package/lib/core/base/Ref.js +286 -0
- package/lib/core/base/Stmt.d.ts +109 -0
- package/lib/core/base/Stmt.d.ts.map +1 -0
- package/lib/core/base/Stmt.js +374 -0
- package/lib/core/base/Type.d.ts +220 -0
- package/lib/core/base/Type.d.ts.map +1 -0
- package/lib/core/base/Type.js +477 -0
- package/lib/core/base/Value.d.ts +11 -0
- package/lib/core/base/Value.d.ts.map +1 -0
- package/lib/core/base/Value.js +16 -0
- package/lib/core/common/ArkIRTransformer.d.ts +101 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -0
- package/lib/core/common/ArkIRTransformer.js +1674 -0
- package/lib/core/common/BodyBuilder.d.ts +10 -0
- package/lib/core/common/BodyBuilder.d.ts.map +1 -0
- package/lib/core/common/BodyBuilder.js +34 -0
- package/lib/core/common/Builtin.d.ts +35 -0
- package/lib/core/common/Builtin.d.ts.map +1 -0
- package/lib/core/common/Builtin.js +78 -0
- package/lib/core/common/CfgBuilder.d.ts +136 -0
- package/lib/core/common/CfgBuilder.d.ts.map +1 -0
- package/lib/core/common/CfgBuilder.js +1241 -0
- package/lib/core/common/Const.d.ts +15 -0
- package/lib/core/common/Const.d.ts.map +1 -0
- package/lib/core/common/Const.js +34 -0
- package/lib/core/common/DummyMainCreater.d.ts +48 -0
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -0
- package/lib/core/common/DummyMainCreater.js +433 -0
- package/lib/core/common/EtsConst.d.ts +65 -0
- package/lib/core/common/EtsConst.d.ts.map +1 -0
- package/lib/core/common/EtsConst.js +918 -0
- package/lib/core/common/ExprUseReplacer.d.ts +18 -0
- package/lib/core/common/ExprUseReplacer.d.ts.map +1 -0
- package/lib/core/common/ExprUseReplacer.js +88 -0
- package/lib/core/common/IRUtils.d.ts +7 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -0
- package/lib/core/common/IRUtils.js +39 -0
- package/lib/core/common/ModelUtils.d.ts +61 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -0
- package/lib/core/common/ModelUtils.js +628 -0
- package/lib/core/common/RefUseReplacer.d.ts +14 -0
- package/lib/core/common/RefUseReplacer.d.ts.map +1 -0
- package/lib/core/common/RefUseReplacer.js +50 -0
- package/lib/core/common/StmtUseReplacer.d.ts +16 -0
- package/lib/core/common/StmtUseReplacer.d.ts.map +1 -0
- package/lib/core/common/StmtUseReplacer.js +88 -0
- package/lib/core/common/TSConst.d.ts +11 -0
- package/lib/core/common/TSConst.d.ts.map +1 -0
- package/lib/core/common/TSConst.js +28 -0
- package/lib/core/common/TypeInference.d.ts +44 -0
- package/lib/core/common/TypeInference.d.ts.map +1 -0
- package/lib/core/common/TypeInference.js +519 -0
- package/lib/core/common/ValueUtil.d.ts +17 -0
- package/lib/core/common/ValueUtil.d.ts.map +1 -0
- package/lib/core/common/ValueUtil.js +71 -0
- package/lib/core/common/VisibleValue.d.ts +37 -0
- package/lib/core/common/VisibleValue.d.ts.map +1 -0
- package/lib/core/common/VisibleValue.js +212 -0
- package/lib/core/dataflow/DataflowProblem.d.ts +21 -0
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -0
- package/lib/core/dataflow/DataflowProblem.js +33 -0
- package/lib/core/dataflow/DataflowResult.d.ts +8 -0
- package/lib/core/dataflow/DataflowResult.d.ts.map +1 -0
- package/lib/core/dataflow/DataflowResult.js +26 -0
- package/lib/core/dataflow/DataflowSolver.d.ts +40 -0
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -0
- package/lib/core/dataflow/DataflowSolver.js +318 -0
- package/lib/core/dataflow/Edge.d.ts +16 -0
- package/lib/core/dataflow/Edge.d.ts.map +1 -0
- package/lib/core/dataflow/Edge.js +40 -0
- package/lib/core/dataflow/Fact.d.ts +7 -0
- package/lib/core/dataflow/Fact.d.ts.map +1 -0
- package/lib/core/dataflow/Fact.js +24 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts +37 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -0
- package/lib/core/dataflow/TiantAnalysis.js +326 -0
- package/lib/core/dataflow/UndefinedVariable.d.ts +32 -0
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -0
- package/lib/core/dataflow/UndefinedVariable.js +235 -0
- package/lib/core/dataflow/Util.d.ts +8 -0
- package/lib/core/dataflow/Util.d.ts.map +1 -0
- package/lib/core/dataflow/Util.js +137 -0
- package/lib/core/graph/BasicBlock.d.ts +26 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -0
- package/lib/core/graph/BasicBlock.js +92 -0
- package/lib/core/graph/Cfg.d.ts +29 -0
- package/lib/core/graph/Cfg.d.ts.map +1 -0
- package/lib/core/graph/Cfg.js +154 -0
- package/lib/core/graph/DominanceFinder.d.ts +16 -0
- package/lib/core/graph/DominanceFinder.d.ts.map +1 -0
- package/lib/core/graph/DominanceFinder.js +121 -0
- package/lib/core/graph/DominanceTree.d.ts +13 -0
- package/lib/core/graph/DominanceTree.d.ts.map +1 -0
- package/lib/core/graph/DominanceTree.js +70 -0
- package/lib/core/graph/ViewTree.d.ts +115 -0
- package/lib/core/graph/ViewTree.d.ts.map +1 -0
- package/lib/core/graph/ViewTree.js +16 -0
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts +204 -0
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/ViewTreeBuilder.js +1046 -0
- package/lib/core/model/ArkBody.d.ts +22 -0
- package/lib/core/model/ArkBody.d.ts.map +1 -0
- package/lib/core/model/ArkBody.js +63 -0
- package/lib/core/model/ArkClass.d.ts +110 -0
- package/lib/core/model/ArkClass.d.ts.map +1 -0
- package/lib/core/model/ArkClass.js +315 -0
- package/lib/core/model/ArkExport.d.ts +70 -0
- package/lib/core/model/ArkExport.d.ts.map +1 -0
- package/lib/core/model/ArkExport.js +143 -0
- package/lib/core/model/ArkField.d.ts +60 -0
- package/lib/core/model/ArkField.d.ts.map +1 -0
- package/lib/core/model/ArkField.js +157 -0
- package/lib/core/model/ArkFile.d.ts +62 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -0
- package/lib/core/model/ArkFile.js +160 -0
- package/lib/core/model/ArkImport.d.ts +43 -0
- package/lib/core/model/ArkImport.d.ts.map +1 -0
- package/lib/core/model/ArkImport.js +109 -0
- package/lib/core/model/ArkMethod.d.ts +76 -0
- package/lib/core/model/ArkMethod.d.ts.map +1 -0
- package/lib/core/model/ArkMethod.js +235 -0
- package/lib/core/model/ArkNamespace.d.ts +65 -0
- package/lib/core/model/ArkNamespace.d.ts.map +1 -0
- package/lib/core/model/ArkNamespace.js +182 -0
- package/lib/core/model/ArkSignature.d.ts +98 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -0
- package/lib/core/model/ArkSignature.js +281 -0
- package/lib/core/model/builder/ArkClassBuilder.d.ts +13 -0
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkClassBuilder.js +422 -0
- package/lib/core/model/builder/ArkExportBuilder.d.ts +25 -0
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkExportBuilder.js +207 -0
- package/lib/core/model/builder/ArkFieldBuilder.d.ts +9 -0
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkFieldBuilder.js +189 -0
- package/lib/core/model/builder/ArkFileBuilder.d.ts +10 -0
- package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkFileBuilder.js +164 -0
- package/lib/core/model/builder/ArkImportBuilder.d.ts +4 -0
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkImportBuilder.js +125 -0
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +60 -0
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkMethodBuilder.js +419 -0
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +5 -0
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkNamespaceBuilder.js +171 -0
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkSignatureBuilder.js +40 -0
- package/lib/core/model/builder/builderUtils.d.ts +18 -0
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -0
- package/lib/core/model/builder/builderUtils.js +449 -0
- package/lib/index.d.ts +77 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +190 -0
- package/lib/save/ArkStream.d.ts +24 -0
- package/lib/save/ArkStream.d.ts.map +1 -0
- package/lib/save/ArkStream.js +83 -0
- package/lib/save/DotPrinter.d.ts +48 -0
- package/lib/save/DotPrinter.d.ts.map +1 -0
- package/lib/save/DotPrinter.js +229 -0
- package/lib/save/GraphPrinter.d.ts +17 -0
- package/lib/save/GraphPrinter.d.ts.map +1 -0
- package/lib/save/GraphPrinter.js +135 -0
- package/lib/save/JsonPrinter.d.ts +28 -0
- package/lib/save/JsonPrinter.d.ts.map +1 -0
- package/lib/save/JsonPrinter.js +511 -0
- package/lib/save/Printer.d.ts +17 -0
- package/lib/save/Printer.d.ts.map +1 -0
- package/lib/save/Printer.js +27 -0
- package/lib/save/PrinterBuilder.d.ts +38 -0
- package/lib/save/PrinterBuilder.d.ts.map +1 -0
- package/lib/save/PrinterBuilder.js +102 -0
- package/lib/save/serializeArkIR.d.ts +3 -0
- package/lib/save/serializeArkIR.d.ts.map +1 -0
- package/lib/save/serializeArkIR.js +166 -0
- package/lib/save/source/SourceBase.d.ts +32 -0
- package/lib/save/source/SourceBase.d.ts.map +1 -0
- package/lib/save/source/SourceBase.js +93 -0
- package/lib/save/source/SourceBody.d.ts +60 -0
- package/lib/save/source/SourceBody.d.ts.map +1 -0
- package/lib/save/source/SourceBody.js +292 -0
- package/lib/save/source/SourceClass.d.ts +27 -0
- package/lib/save/source/SourceClass.d.ts.map +1 -0
- package/lib/save/source/SourceClass.js +202 -0
- package/lib/save/source/SourceField.d.ts +15 -0
- package/lib/save/source/SourceField.d.ts.map +1 -0
- package/lib/save/source/SourceField.js +68 -0
- package/lib/save/source/SourceFilePrinter.d.ts +14 -0
- package/lib/save/source/SourceFilePrinter.d.ts.map +1 -0
- package/lib/save/source/SourceFilePrinter.js +73 -0
- package/lib/save/source/SourceMethod.d.ts +24 -0
- package/lib/save/source/SourceMethod.d.ts.map +1 -0
- package/lib/save/source/SourceMethod.js +170 -0
- package/lib/save/source/SourceModule.d.ts +18 -0
- package/lib/save/source/SourceModule.d.ts.map +1 -0
- package/lib/save/source/SourceModule.js +120 -0
- package/lib/save/source/SourceNamespace.d.ts +13 -0
- package/lib/save/source/SourceNamespace.d.ts.map +1 -0
- package/lib/save/source/SourceNamespace.js +80 -0
- package/lib/save/source/SourceStmt.d.ts +172 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -0
- package/lib/save/source/SourceStmt.js +757 -0
- package/lib/save/source/SourceTransformer.d.ts +37 -0
- package/lib/save/source/SourceTransformer.d.ts.map +1 -0
- package/lib/save/source/SourceTransformer.js +338 -0
- package/lib/save/source/SourceUtils.d.ts +25 -0
- package/lib/save/source/SourceUtils.d.ts.map +1 -0
- package/lib/save/source/SourceUtils.js +201 -0
- package/lib/transformer/FunctionTransformer.d.ts +3 -0
- package/lib/transformer/FunctionTransformer.d.ts.map +1 -0
- package/lib/transformer/FunctionTransformer.js +17 -0
- package/lib/transformer/SceneTransformer.d.ts +3 -0
- package/lib/transformer/SceneTransformer.d.ts.map +1 -0
- package/lib/transformer/SceneTransformer.js +17 -0
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts +13 -0
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -0
- package/lib/transformer/StaticSingleAssignmentFormer.js +259 -0
- package/lib/transformer/Transformer.d.ts +7 -0
- package/lib/transformer/Transformer.d.ts.map +1 -0
- package/lib/transformer/Transformer.js +22 -0
- package/lib/utils/CfgStructualAnalysis.d.ts +93 -0
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -0
- package/lib/utils/CfgStructualAnalysis.js +955 -0
- package/lib/utils/FileUtils.d.ts +18 -0
- package/lib/utils/FileUtils.d.ts.map +1 -0
- package/lib/utils/FileUtils.js +131 -0
- package/lib/utils/callGraphUtils.d.ts +31 -0
- package/lib/utils/callGraphUtils.d.ts.map +1 -0
- package/lib/utils/callGraphUtils.js +208 -0
- package/lib/utils/entryMethodUtils.d.ts +16 -0
- package/lib/utils/entryMethodUtils.d.ts.map +1 -0
- package/lib/utils/entryMethodUtils.js +139 -0
- package/lib/utils/getAllFiles.d.ts +10 -0
- package/lib/utils/getAllFiles.d.ts.map +1 -0
- package/lib/utils/getAllFiles.js +91 -0
- package/lib/utils/json5parser.d.ts +7 -0
- package/lib/utils/json5parser.d.ts.map +1 -0
- package/lib/utils/json5parser.js +146 -0
- package/lib/utils/logger.d.ts +19 -0
- package/lib/utils/logger.d.ts.map +1 -0
- package/lib/utils/logger.js +90 -0
- package/lib/utils/pathTransfer.d.ts +2 -0
- package/lib/utils/pathTransfer.d.ts.map +1 -0
- package/lib/utils/pathTransfer.js +25 -0
- package/package.json +29 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Scene } from '../../Scene';
|
|
2
|
+
import { AbstractInvokeExpr } from '../../core/base/Expr';
|
|
3
|
+
import { Stmt } from '../../core/base/Stmt';
|
|
4
|
+
import { ArkClass } from '../../core/model/ArkClass';
|
|
5
|
+
import { ArkMethod } from '../../core/model/ArkMethod';
|
|
6
|
+
import { MethodSignature } from '../../core/model/ArkSignature';
|
|
7
|
+
import { NodeID } from '../model/BaseGraph';
|
|
8
|
+
import { CallGraph, FuncID, CallSite } from '../model/CallGraph';
|
|
9
|
+
import { CallGraphBuilder } from '../model/builder/CallGraphBuilder';
|
|
10
|
+
export declare abstract class AbstractAnalysis {
|
|
11
|
+
protected scene: Scene;
|
|
12
|
+
protected cg: CallGraph;
|
|
13
|
+
protected cgBuilder: CallGraphBuilder;
|
|
14
|
+
protected workList: FuncID[];
|
|
15
|
+
protected processedMethod: Set<FuncID>;
|
|
16
|
+
constructor(s: Scene);
|
|
17
|
+
getScene(): Scene;
|
|
18
|
+
getCallGraph(): CallGraph;
|
|
19
|
+
protected abstract resolveCall(sourceMethod: NodeID, invokeStmt: Stmt): CallSite[];
|
|
20
|
+
protected abstract preProcessMethod(funcID: FuncID): CallSite[];
|
|
21
|
+
resolveInvokeExpr(invokeExpr: AbstractInvokeExpr): ArkMethod | undefined;
|
|
22
|
+
getClassHierarchy(arkClass: ArkClass): ArkClass[];
|
|
23
|
+
start(displayGeneratedMethod: Boolean): void;
|
|
24
|
+
protected init(): void;
|
|
25
|
+
protected processMethod(methodID: FuncID): CallSite[];
|
|
26
|
+
protected getParamAnonymousMethod(invokeExpr: AbstractInvokeExpr): MethodSignature[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=AbstractAnalysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractAnalysis.d.ts","sourceRoot":"","sources":["../../../src/callgraph/algorithm/AbstractAnalysis.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAiB,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIrE,8BAAsB,gBAAgB;IAClC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IACvB,SAAS,CAAC,EAAE,EAAG,SAAS,CAAC;IACzB,SAAS,CAAC,SAAS,EAAG,gBAAgB,CAAC;IACvC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAM;IAClC,SAAS,CAAC,eAAe,EAAG,GAAG,CAAC,MAAM,CAAC,CAAC;gBAE5B,CAAC,EAAE,KAAK;IAIb,QAAQ,IAAI,KAAK;IAIjB,YAAY,IAAI,SAAS;IAIhC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,GAAG,QAAQ,EAAE;IAClF,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE;IAExD,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,GAAG,SAAS;IAOxE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAiBjD,KAAK,CAAC,sBAAsB,EAAE,OAAO,GAAG,IAAI;IAiCnD,SAAS,CAAC,IAAI,IAAI,IAAI;IAOtB,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE;IAsBrD,SAAS,CAAC,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,GAAG,eAAe,EAAE;CAYvF"}
|
|
@@ -0,0 +1,137 @@
|
|
|
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.AbstractAnalysis = void 0;
|
|
41
|
+
const Type_1 = require("../../core/base/Type");
|
|
42
|
+
const logger_1 = __importStar(require("../../utils/logger"));
|
|
43
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'CG');
|
|
44
|
+
class AbstractAnalysis {
|
|
45
|
+
constructor(s) {
|
|
46
|
+
this.workList = [];
|
|
47
|
+
this.scene = s;
|
|
48
|
+
}
|
|
49
|
+
getScene() {
|
|
50
|
+
return this.scene;
|
|
51
|
+
}
|
|
52
|
+
getCallGraph() {
|
|
53
|
+
return this.cg;
|
|
54
|
+
}
|
|
55
|
+
resolveInvokeExpr(invokeExpr) {
|
|
56
|
+
const method = this.scene.getMethod(invokeExpr.getMethodSignature());
|
|
57
|
+
if (method != null) {
|
|
58
|
+
return method;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getClassHierarchy(arkClass) {
|
|
62
|
+
// TODO: remove abstract class
|
|
63
|
+
let classWorkList = [arkClass];
|
|
64
|
+
// TODO: check class with no super Class
|
|
65
|
+
// let classHierarchy: ArkClass[] = [arkClass.getSuperClass()]
|
|
66
|
+
let classHierarchy = [];
|
|
67
|
+
while (classWorkList.length > 0) {
|
|
68
|
+
// TODO: no dumplicated check, TS doesn't allow multi extend
|
|
69
|
+
let tempClass = classWorkList.shift();
|
|
70
|
+
classWorkList.push(...tempClass.getExtendedClasses().values());
|
|
71
|
+
classHierarchy.push(tempClass);
|
|
72
|
+
}
|
|
73
|
+
return classHierarchy;
|
|
74
|
+
}
|
|
75
|
+
start(displayGeneratedMethod) {
|
|
76
|
+
this.init();
|
|
77
|
+
while (this.workList.length != 0) {
|
|
78
|
+
const method = this.workList.shift();
|
|
79
|
+
const cgNode = this.cg.getNode(method);
|
|
80
|
+
if (this.processedMethod.has(method) || cgNode.getIsSdkMethod()) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// pre process for RTA only
|
|
84
|
+
this.preProcessMethod(method).forEach((cs) => {
|
|
85
|
+
this.workList.push(cs.calleeFuncID);
|
|
86
|
+
});
|
|
87
|
+
this.processMethod(method).forEach((cs) => {
|
|
88
|
+
var _a;
|
|
89
|
+
let me = this.cg.getArkMethodByFuncID(cs.calleeFuncID);
|
|
90
|
+
// check if need to display generated method
|
|
91
|
+
if (displayGeneratedMethod || (me === null || me === void 0 ? void 0 : me.isGenerated())) {
|
|
92
|
+
this.cg.addDynamicCallEdge(method, cs.calleeFuncID, cs.callStmt);
|
|
93
|
+
}
|
|
94
|
+
if (!this.processedMethod.has(cs.calleeFuncID)) {
|
|
95
|
+
this.workList.push(cs.calleeFuncID);
|
|
96
|
+
logger.info(`New workList item ${cs.calleeFuncID}: ${(_a = this.cg.getArkMethodByFuncID(cs.calleeFuncID)) === null || _a === void 0 ? void 0 : _a.getSignature().toString()}`);
|
|
97
|
+
this.processedMethod.add(cs.callerFuncID);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
init() {
|
|
103
|
+
this.processedMethod = new Set();
|
|
104
|
+
this.cg.getEntries().forEach((entryFunc) => {
|
|
105
|
+
this.workList.push(entryFunc);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
processMethod(methodID) {
|
|
109
|
+
let cgNode = this.cg.getNode(methodID);
|
|
110
|
+
let arkMethod = this.scene.getMethod(cgNode.getMethod(), true);
|
|
111
|
+
let calleeMethods = [];
|
|
112
|
+
if (!arkMethod) {
|
|
113
|
+
throw new Error("can not find method");
|
|
114
|
+
}
|
|
115
|
+
const cfg = arkMethod.getCfg();
|
|
116
|
+
if (!cfg) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
cfg.getStmts().forEach((stmt) => {
|
|
120
|
+
if (stmt.containsInvokeExpr()) {
|
|
121
|
+
calleeMethods.push(...this.resolveCall(cgNode.getID(), stmt));
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return calleeMethods;
|
|
125
|
+
}
|
|
126
|
+
getParamAnonymousMethod(invokeExpr) {
|
|
127
|
+
let paramMethod = [];
|
|
128
|
+
invokeExpr.getArgs().forEach((args) => {
|
|
129
|
+
let argsType = args.getType();
|
|
130
|
+
if (argsType instanceof Type_1.FunctionType) {
|
|
131
|
+
paramMethod.push(argsType.getMethodSignature());
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return paramMethod;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.AbstractAnalysis = AbstractAnalysis;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Scene } from '../../Scene';
|
|
2
|
+
import { Stmt } from '../../core/base/Stmt';
|
|
3
|
+
import { NodeID } from '../model/BaseGraph';
|
|
4
|
+
import { CallGraph, CallSite } from '../model/CallGraph';
|
|
5
|
+
import { AbstractAnalysis } from './AbstractAnalysis';
|
|
6
|
+
export declare class ClassHierarchyAnalysis extends AbstractAnalysis {
|
|
7
|
+
constructor(scene: Scene, cg: CallGraph);
|
|
8
|
+
resolveCall(callerMethod: NodeID, invokeStmt: Stmt): CallSite[];
|
|
9
|
+
protected preProcessMethod(): CallSite[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ClassHierarchyAnalysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassHierarchyAnalysis.d.ts","sourceRoot":"","sources":["../../../src/callgraph/algorithm/ClassHierarchyAnalysis.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,qBAAa,sBAAuB,SAAQ,gBAAgB;gBAE5C,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS;IAKhC,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,GAAG,QAAQ,EAAE;IAyDtE,SAAS,CAAC,gBAAgB,IAAI,QAAQ,EAAE;CAI3C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ClassHierarchyAnalysis = void 0;
|
|
18
|
+
const Expr_1 = require("../../core/base/Expr");
|
|
19
|
+
const CallGraph_1 = require("../model/CallGraph");
|
|
20
|
+
const AbstractAnalysis_1 = require("./AbstractAnalysis");
|
|
21
|
+
const TSConst_1 = require("../../core/common/TSConst");
|
|
22
|
+
class ClassHierarchyAnalysis extends AbstractAnalysis_1.AbstractAnalysis {
|
|
23
|
+
constructor(scene, cg) {
|
|
24
|
+
super(scene);
|
|
25
|
+
this.cg = cg;
|
|
26
|
+
}
|
|
27
|
+
resolveCall(callerMethod, invokeStmt) {
|
|
28
|
+
let invokeExpr = invokeStmt.getInvokeExpr();
|
|
29
|
+
let resolveResult = [];
|
|
30
|
+
if (!invokeExpr) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
// process anonymous method call
|
|
34
|
+
this.getParamAnonymousMethod(invokeExpr).forEach(method => {
|
|
35
|
+
resolveResult.push(new CallGraph_1.CallSite(invokeStmt, undefined, this.cg.getCallGraphNodeByMethod(method).getID(), callerMethod));
|
|
36
|
+
});
|
|
37
|
+
let calleeMethod = this.resolveInvokeExpr(invokeExpr);
|
|
38
|
+
if (!calleeMethod) {
|
|
39
|
+
return resolveResult;
|
|
40
|
+
}
|
|
41
|
+
if (invokeExpr instanceof Expr_1.ArkStaticInvokeExpr) {
|
|
42
|
+
// get specific method
|
|
43
|
+
// resolveResult.push(calleeMethod.getSignature())
|
|
44
|
+
resolveResult.push(new CallGraph_1.CallSite(invokeStmt, undefined, this.cg.getCallGraphNodeByMethod(calleeMethod.getSignature()).getID(), callerMethod));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
let declareClass = calleeMethod.getDeclaringArkClass();
|
|
48
|
+
// TODO: super class method should be placed at the end
|
|
49
|
+
this.getClassHierarchy(declareClass).forEach((arkClass) => {
|
|
50
|
+
if (arkClass.getModifiers().has(TSConst_1.ABSTRACT_KEYWORD)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let possibleCalleeMethod = arkClass.getMethodWithName(calleeMethod.getName());
|
|
54
|
+
if (possibleCalleeMethod && possibleCalleeMethod.isGenerated() &&
|
|
55
|
+
arkClass.getSignature().toString() !== declareClass.getSignature().toString()) {
|
|
56
|
+
// remove the generated method in extended classes
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (possibleCalleeMethod && !possibleCalleeMethod.getModifiers().has(TSConst_1.ABSTRACT_KEYWORD)) {
|
|
60
|
+
resolveResult.push(new CallGraph_1.CallSite(invokeStmt, undefined, this.cg.getCallGraphNodeByMethod(possibleCalleeMethod.getSignature()).getID(), callerMethod));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return resolveResult;
|
|
65
|
+
}
|
|
66
|
+
preProcessMethod() {
|
|
67
|
+
// do nothing
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ClassHierarchyAnalysis = ClassHierarchyAnalysis;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Scene } from '../../Scene';
|
|
2
|
+
import { Stmt } from '../../core/base/Stmt';
|
|
3
|
+
import { ClassSignature } from '../../core/model/ArkSignature';
|
|
4
|
+
import { NodeID } from '../model/BaseGraph';
|
|
5
|
+
import { CallGraph, CallSite, FuncID } from '../model/CallGraph';
|
|
6
|
+
import { AbstractAnalysis } from './AbstractAnalysis';
|
|
7
|
+
export declare class RapidTypeAnalysis extends AbstractAnalysis {
|
|
8
|
+
private instancedClasses;
|
|
9
|
+
private ignoredCalls;
|
|
10
|
+
constructor(scene: Scene, cg: CallGraph);
|
|
11
|
+
resolveCall(callerMethod: NodeID, invokeStmt: Stmt): CallSite[];
|
|
12
|
+
protected preProcessMethod(funcID: FuncID): CallSite[];
|
|
13
|
+
private collectInstancedClassesInMethod;
|
|
14
|
+
addIgnoredCalls(arkClass: ClassSignature, callerID: FuncID, calleeID: FuncID, invokeStmt: Stmt): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=RapidTypeAnalysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RapidTypeAnalysis.d.ts","sourceRoot":"","sources":["../../../src/callgraph/algorithm/RapidTypeAnalysis.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAOtD,qBAAa,iBAAkB,SAAQ,gBAAgB;IAEnD,OAAO,CAAC,gBAAgB,CAAkC;IAE1D,OAAO,CAAC,YAAY,CAA2F;gBAEnG,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS;IAKhC,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,GAAG,QAAQ,EAAE;IA4DtE,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE;IAqBtD,OAAO,CAAC,+BAA+B;IA4BhC,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI;CAKxG"}
|
|
@@ -0,0 +1,147 @@
|
|
|
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.RapidTypeAnalysis = void 0;
|
|
41
|
+
const Expr_1 = require("../../core/base/Expr");
|
|
42
|
+
const CallGraph_1 = require("../model/CallGraph");
|
|
43
|
+
const AbstractAnalysis_1 = require("./AbstractAnalysis");
|
|
44
|
+
const logger_1 = __importStar(require("../../utils/logger"));
|
|
45
|
+
const TSConst_1 = require("../../core/common/TSConst");
|
|
46
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'RTA');
|
|
47
|
+
class RapidTypeAnalysis extends AbstractAnalysis_1.AbstractAnalysis {
|
|
48
|
+
constructor(scene, cg) {
|
|
49
|
+
super(scene);
|
|
50
|
+
// TODO: signature duplicated check
|
|
51
|
+
this.instancedClasses = new Set();
|
|
52
|
+
// TODO: Set duplicated check
|
|
53
|
+
this.ignoredCalls = new Map();
|
|
54
|
+
this.cg = cg;
|
|
55
|
+
}
|
|
56
|
+
resolveCall(callerMethod, invokeStmt) {
|
|
57
|
+
let invokeExpr = invokeStmt.getInvokeExpr();
|
|
58
|
+
let resolveResult = [];
|
|
59
|
+
if (!invokeExpr) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
// process anonymous method call
|
|
63
|
+
this.getParamAnonymousMethod(invokeExpr).forEach(method => {
|
|
64
|
+
resolveResult.push(new CallGraph_1.CallSite(invokeStmt, undefined, this.cg.getCallGraphNodeByMethod(method).getID(), callerMethod));
|
|
65
|
+
});
|
|
66
|
+
let calleeMethod = this.resolveInvokeExpr(invokeExpr);
|
|
67
|
+
if (!calleeMethod) {
|
|
68
|
+
return resolveResult;
|
|
69
|
+
}
|
|
70
|
+
if (invokeExpr instanceof Expr_1.ArkStaticInvokeExpr) {
|
|
71
|
+
// get specific method
|
|
72
|
+
resolveResult.push(new CallGraph_1.CallSite(invokeStmt, undefined, this.cg.getCallGraphNodeByMethod(calleeMethod.getSignature()).getID(), callerMethod));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
let declareClass = calleeMethod.getDeclaringArkClass();
|
|
76
|
+
// TODO: super class method should be placed at the end
|
|
77
|
+
this.getClassHierarchy(declareClass).forEach((arkClass) => {
|
|
78
|
+
if (arkClass.getModifiers().has(TSConst_1.ABSTRACT_KEYWORD)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let possibleCalleeMethod = arkClass.getMethodWithName(calleeMethod.getName());
|
|
82
|
+
if (possibleCalleeMethod && possibleCalleeMethod.isGenerated() &&
|
|
83
|
+
arkClass.getSignature().toString() !== declareClass.getSignature().toString()) {
|
|
84
|
+
// remove the generated method in extended classes
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (possibleCalleeMethod && !possibleCalleeMethod.getModifiers().has(TSConst_1.ABSTRACT_KEYWORD)) {
|
|
88
|
+
if (!this.instancedClasses.has(arkClass.getSignature())) {
|
|
89
|
+
this.addIgnoredCalls(arkClass.getSignature(), callerMethod, this.cg.getCallGraphNodeByMethod(possibleCalleeMethod.getSignature()).getID(), invokeStmt);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
resolveResult.push(new CallGraph_1.CallSite(invokeStmt, undefined, this.cg.getCallGraphNodeByMethod(possibleCalleeMethod.getSignature()).getID(), callerMethod));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return resolveResult;
|
|
98
|
+
}
|
|
99
|
+
preProcessMethod(funcID) {
|
|
100
|
+
let newCallSites = [];
|
|
101
|
+
let instancedClasses = this.collectInstancedClassesInMethod(funcID);
|
|
102
|
+
let newlyInstancedClasses = new Set(Array.from(instancedClasses).filter(item => !this.instancedClasses.has(item)));
|
|
103
|
+
newlyInstancedClasses.forEach(sig => {
|
|
104
|
+
let ignoredCalls = this.ignoredCalls.get(sig);
|
|
105
|
+
if (ignoredCalls) {
|
|
106
|
+
ignoredCalls.forEach((call) => {
|
|
107
|
+
this.cg.addDynamicCallEdge(call.caller, call.callee, call.callStmt);
|
|
108
|
+
newCallSites.push(new CallGraph_1.CallSite(call.callStmt, undefined, call.callee, call.caller));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
this.instancedClasses.add(sig);
|
|
112
|
+
this.ignoredCalls.delete(sig);
|
|
113
|
+
});
|
|
114
|
+
return newCallSites;
|
|
115
|
+
}
|
|
116
|
+
collectInstancedClassesInMethod(funcID) {
|
|
117
|
+
let instancedClasses = new Set();
|
|
118
|
+
let arkMethod = this.cg.getArkMethodByFuncID(funcID);
|
|
119
|
+
if (!arkMethod) {
|
|
120
|
+
logger.error(`can not find arkMethod by funcID`);
|
|
121
|
+
return instancedClasses;
|
|
122
|
+
}
|
|
123
|
+
let cfg = arkMethod.getCfg();
|
|
124
|
+
if (!cfg) {
|
|
125
|
+
logger.error(`arkMethod ${arkMethod.getSignature().toString()} has no cfg`);
|
|
126
|
+
return instancedClasses;
|
|
127
|
+
}
|
|
128
|
+
for (let stmt of cfg.getStmts()) {
|
|
129
|
+
let stmtExpr = stmt.getExprs()[0];
|
|
130
|
+
if (stmtExpr instanceof Expr_1.ArkNewExpr) {
|
|
131
|
+
let classSig = stmtExpr.getType().getClassSignature();
|
|
132
|
+
if (classSig != null) {
|
|
133
|
+
// TODO: need to check if different stmt has single sig
|
|
134
|
+
instancedClasses.add(classSig);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return instancedClasses;
|
|
139
|
+
}
|
|
140
|
+
addIgnoredCalls(arkClass, callerID, calleeID, invokeStmt) {
|
|
141
|
+
var _a;
|
|
142
|
+
let classMap = (_a = this.ignoredCalls.get(arkClass)) !== null && _a !== void 0 ? _a : new Set();
|
|
143
|
+
classMap.add({ caller: callerID, callee: calleeID, callStmt: invokeStmt });
|
|
144
|
+
this.ignoredCalls.set(arkClass, classMap);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.RapidTypeAnalysis = RapidTypeAnalysis;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CallGraphNodeKind } from "../model/CallGraph";
|
|
2
|
+
import { PointerAnalysis } from "../pointerAnalysis/PointerAnalysis";
|
|
3
|
+
declare abstract class StatTraits {
|
|
4
|
+
getStat(): string;
|
|
5
|
+
printStat(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class PTAStat implements StatTraits {
|
|
8
|
+
pta: PointerAnalysis;
|
|
9
|
+
numProcessedAddr: number;
|
|
10
|
+
numProcessedCopy: number;
|
|
11
|
+
numProcessedLoad: number;
|
|
12
|
+
numProcessedWrite: number;
|
|
13
|
+
numProcessedThis: number;
|
|
14
|
+
numRealWrite: number;
|
|
15
|
+
numRealLoad: number;
|
|
16
|
+
numUnhandledFun: number;
|
|
17
|
+
numTotalValuesInHandedFun: number;
|
|
18
|
+
numTotalHandledValue: number;
|
|
19
|
+
numInferedUnknownValue: number;
|
|
20
|
+
numInferedDiffTypeValue: number;
|
|
21
|
+
totalValuesInVisitedFunc: number;
|
|
22
|
+
numNotInferedUnknownValue: number;
|
|
23
|
+
numUnhandledFunc: number;
|
|
24
|
+
iterTimes: number;
|
|
25
|
+
TotalTime: number;
|
|
26
|
+
startTime: number;
|
|
27
|
+
endTime: number;
|
|
28
|
+
startMemUsage: any;
|
|
29
|
+
endMemUsage: any;
|
|
30
|
+
rssUsed: number;
|
|
31
|
+
heapUsed: number;
|
|
32
|
+
constructor(pta: PointerAnalysis);
|
|
33
|
+
startStat(): void;
|
|
34
|
+
endStat(): void;
|
|
35
|
+
getNow(): number;
|
|
36
|
+
private getInferedStat;
|
|
37
|
+
private getUnhandledFuncStat;
|
|
38
|
+
getStat(): string;
|
|
39
|
+
printStat(): void;
|
|
40
|
+
}
|
|
41
|
+
export declare class PAGStat implements StatTraits {
|
|
42
|
+
numDynamicCall: number;
|
|
43
|
+
numTotalFunction: number;
|
|
44
|
+
numTotalNode: number;
|
|
45
|
+
getStat(): string;
|
|
46
|
+
printStat(): void;
|
|
47
|
+
}
|
|
48
|
+
export declare class CGStat extends StatTraits {
|
|
49
|
+
numTotalNode: number;
|
|
50
|
+
numReal: number;
|
|
51
|
+
numVirtual: number;
|
|
52
|
+
numIntrinsic: number;
|
|
53
|
+
numConstructor: number;
|
|
54
|
+
addNodeStat(kind: CallGraphNodeKind): void;
|
|
55
|
+
getStat(): string;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=Statistics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Statistics.d.ts","sourceRoot":"","sources":["../../../src/callgraph/common/Statistics.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,uBAAe,UAAU;IACd,OAAO,IAAI,MAAM;IAIjB,SAAS,IAAI,IAAI;CAG3B;AAED,qBAAa,OAAQ,YAAW,UAAU;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAK;IAC7B,gBAAgB,EAAE,MAAM,CAAK;IAC7B,gBAAgB,EAAE,MAAM,CAAK;IAC7B,iBAAiB,EAAE,MAAM,CAAK;IAC9B,gBAAgB,EAAE,MAAM,CAAK;IAC7B,YAAY,EAAE,MAAM,CAAK;IACzB,WAAW,EAAE,MAAM,CAAK;IAExB,eAAe,EAAE,MAAM,CAAK;IAC5B,yBAAyB,EAAE,MAAM,CAAK;IACtC,oBAAoB,EAAE,MAAM,CAAK;IAGjC,sBAAsB,EAAE,MAAM,CAAK;IAEnC,uBAAuB,EAAE,MAAM,CAAK;IAEpC,wBAAwB,EAAE,MAAM,CAAK;IAErC,yBAAyB,EAAE,MAAM,CAAK;IACtC,gBAAgB,EAAE,MAAM,CAAK;IAE7B,SAAS,EAAE,MAAM,CAAK;IACtB,SAAS,EAAE,MAAM,CAAK;IAEtB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IAEpB,aAAa,EAAE,GAAG,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC;IACjB,OAAO,EAAE,MAAM,CAAK;IACpB,QAAQ,EAAE,MAAM,CAAK;gBAET,GAAG,EAAE,eAAe;IAIzB,SAAS,IAAI,IAAI;IAKjB,OAAO,IAAI,IAAI;IAUf,MAAM,IAAI,MAAM;IAIvB,OAAO,CAAC,cAAc;IAkCtB,OAAO,CAAC,oBAAoB;IAerB,OAAO,IAAI,MAAM;IAsBjB,SAAS,IAAI,IAAI;CAG3B;AAED,qBAAa,OAAQ,YAAW,UAAU;IACtC,cAAc,EAAE,MAAM,CAAK;IAC3B,gBAAgB,EAAE,MAAM,CAAK;IAC7B,YAAY,EAAE,MAAM,CAAK;IAElB,OAAO,IAAI,MAAM;IASjB,SAAS,IAAI,IAAI;CAG3B;AAED,qBAAa,MAAO,SAAQ,UAAU;IAElC,YAAY,EAAE,MAAM,CAAK;IACzB,OAAO,EAAE,MAAM,CAAK;IACpB,UAAU,EAAE,MAAM,CAAK;IACvB,YAAY,EAAE,MAAM,CAAK;IACzB,cAAc,EAAE,MAAM,CAAK;IAEpB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAmB1C,OAAO,IAAI,MAAM;CAU3B"}
|