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,15 @@
|
|
|
1
|
+
export declare const DEFAULT_ARK_CLASS_NAME = "_DEFAULT_ARK_CLASS";
|
|
2
|
+
export declare const DEFAULT_ARK_METHOD_NAME = "_DEFAULT_ARK_METHOD";
|
|
3
|
+
export declare const ANONYMOUS_CLASS_PREFIX = "AnonymousClass";
|
|
4
|
+
export declare const ANONYMOUS_CLASS_DELIMITER = "-";
|
|
5
|
+
export declare const INSTANCE_INIT_METHOD_NAME = "@instance_init";
|
|
6
|
+
export declare const STATIC_INIT_METHOD_NAME = "@static_init";
|
|
7
|
+
export declare const ANONYMOUS_METHOD_PREFIX = "AnonymousMethod-";
|
|
8
|
+
export declare const CALL_SIGNATURE_NAME = "create";
|
|
9
|
+
export declare const UNKNOWN_PROJECT_NAME = "_UnknownProjectName";
|
|
10
|
+
export declare const UNKNOWN_FILE_NAME = "_UnknownFileName";
|
|
11
|
+
export declare const UNKNOWN_NAMESPACE_NAME = "_UnknownNamespaceName";
|
|
12
|
+
export declare const UNKNOWN_CLASS_NAME = "";
|
|
13
|
+
export declare const UNKNOWN_FIELD_NAME = "";
|
|
14
|
+
export declare const UNKNOWN_METHOD_NAME = "";
|
|
15
|
+
//# sourceMappingURL=Const.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Const.d.ts","sourceRoot":"","sources":["../../../src/core/common/Const.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAC3D,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAC7D,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAG7C,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAC1D,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAC1D,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAG5C,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AAC1D,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AACpD,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,mBAAmB,KAAK,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.UNKNOWN_METHOD_NAME = exports.UNKNOWN_FIELD_NAME = exports.UNKNOWN_CLASS_NAME = exports.UNKNOWN_NAMESPACE_NAME = exports.UNKNOWN_FILE_NAME = exports.UNKNOWN_PROJECT_NAME = exports.CALL_SIGNATURE_NAME = exports.ANONYMOUS_METHOD_PREFIX = exports.STATIC_INIT_METHOD_NAME = exports.INSTANCE_INIT_METHOD_NAME = exports.ANONYMOUS_CLASS_DELIMITER = exports.ANONYMOUS_CLASS_PREFIX = exports.DEFAULT_ARK_METHOD_NAME = exports.DEFAULT_ARK_CLASS_NAME = void 0;
|
|
18
|
+
// ArkClass const
|
|
19
|
+
exports.DEFAULT_ARK_CLASS_NAME = '_DEFAULT_ARK_CLASS';
|
|
20
|
+
exports.DEFAULT_ARK_METHOD_NAME = '_DEFAULT_ARK_METHOD';
|
|
21
|
+
exports.ANONYMOUS_CLASS_PREFIX = 'AnonymousClass';
|
|
22
|
+
exports.ANONYMOUS_CLASS_DELIMITER = '-';
|
|
23
|
+
// ArkMethod const
|
|
24
|
+
exports.INSTANCE_INIT_METHOD_NAME = '@instance_init';
|
|
25
|
+
exports.STATIC_INIT_METHOD_NAME = '@static_init';
|
|
26
|
+
exports.ANONYMOUS_METHOD_PREFIX = 'AnonymousMethod-';
|
|
27
|
+
exports.CALL_SIGNATURE_NAME = 'create';
|
|
28
|
+
// ArkSignature const
|
|
29
|
+
exports.UNKNOWN_PROJECT_NAME = '_UnknownProjectName';
|
|
30
|
+
exports.UNKNOWN_FILE_NAME = '_UnknownFileName';
|
|
31
|
+
exports.UNKNOWN_NAMESPACE_NAME = '_UnknownNamespaceName';
|
|
32
|
+
exports.UNKNOWN_CLASS_NAME = ''; // temp for being compatible with existing type inference
|
|
33
|
+
exports.UNKNOWN_FIELD_NAME = ''; // temp for being compatible with existing type inference
|
|
34
|
+
exports.UNKNOWN_METHOD_NAME = ''; // temp for being compatible with existing type inference
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Scene } from '../../Scene';
|
|
2
|
+
import { ArkClass } from '../model/ArkClass';
|
|
3
|
+
import { ArkMethod } from '../model/ArkMethod';
|
|
4
|
+
/**
|
|
5
|
+
收集所有的onCreate,onStart等函数,构造一个虚拟函数,具体为:
|
|
6
|
+
@static_init()
|
|
7
|
+
...
|
|
8
|
+
count = 0
|
|
9
|
+
while (true) {
|
|
10
|
+
if (count == 1) {
|
|
11
|
+
temp1 = new ability
|
|
12
|
+
temp2 = new want
|
|
13
|
+
temp1.onCreate(temp2)
|
|
14
|
+
}
|
|
15
|
+
if (count == 2) {
|
|
16
|
+
onDestroy()
|
|
17
|
+
}
|
|
18
|
+
...
|
|
19
|
+
if (count == *) {
|
|
20
|
+
callbackMethod1()
|
|
21
|
+
}
|
|
22
|
+
...
|
|
23
|
+
}
|
|
24
|
+
return
|
|
25
|
+
如果是instanceInvoke还要先实例化对象,如果是其他文件的类或者方法还要添加import信息
|
|
26
|
+
*/
|
|
27
|
+
export declare class DummyMainCreater {
|
|
28
|
+
private entryMethods;
|
|
29
|
+
private classLocalMap;
|
|
30
|
+
private dummyMain;
|
|
31
|
+
private scene;
|
|
32
|
+
private tempLocalIndex;
|
|
33
|
+
private builtInClass;
|
|
34
|
+
constructor(scene: Scene);
|
|
35
|
+
private buildBuiltInClass;
|
|
36
|
+
setEntryMethods(methods: ArkMethod[]): void;
|
|
37
|
+
createDummyMain(): void;
|
|
38
|
+
private createDummyMainCfg;
|
|
39
|
+
private getArkClassFromParamType;
|
|
40
|
+
private addCfg2Stmt;
|
|
41
|
+
getDummyMain(): ArkMethod;
|
|
42
|
+
private getEntryMethodsFromComponents;
|
|
43
|
+
getMethodsFromAllAbilities(): ArkMethod[];
|
|
44
|
+
getEntryMethodsFromModuleJson5(): ArkMethod[];
|
|
45
|
+
getAbilitiesByParseModuleJson(modulePath: string): ArkClass[];
|
|
46
|
+
getCallbackMethods(): ArkMethod[];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=DummyMainCreater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DummyMainCreater.d.ts","sourceRoot":"","sources":["../../../src/core/common/DummyMainCreater.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAiBpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,aAAa,CAA2C;IAChE,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,YAAY,CAAkC;gBAE1C,KAAK,EAAE,KAAK;IAUxB,OAAO,CAAC,iBAAiB;IASlB,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI;IAI3C,eAAe,IAAI,IAAI;IA+C9B,OAAO,CAAC,kBAAkB;IA2H1B,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,WAAW;IAYZ,YAAY,IAAI,SAAS;IAIhC,OAAO,CAAC,6BAA6B;IAqB9B,0BAA0B,IAAI,SAAS,EAAE;IAWzC,8BAA8B,IAAI,SAAS,EAAE;IAoD7C,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,EAAE;IA2B7D,kBAAkB,IAAI,SAAS,EAAE;CAiB3C"}
|
|
@@ -0,0 +1,433 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.DummyMainCreater = void 0;
|
|
44
|
+
const fs_1 = __importDefault(require("fs"));
|
|
45
|
+
const path_1 = __importDefault(require("path"));
|
|
46
|
+
const entryMethodUtils_1 = require("../../utils/entryMethodUtils");
|
|
47
|
+
const Constant_1 = require("../base/Constant");
|
|
48
|
+
const Expr_1 = require("../base/Expr");
|
|
49
|
+
const Local_1 = require("../base/Local");
|
|
50
|
+
const Stmt_1 = require("../base/Stmt");
|
|
51
|
+
const Type_1 = require("../base/Type");
|
|
52
|
+
const BasicBlock_1 = require("../graph/BasicBlock");
|
|
53
|
+
const Cfg_1 = require("../graph/Cfg");
|
|
54
|
+
const ArkBody_1 = require("../model/ArkBody");
|
|
55
|
+
const ArkClass_1 = require("../model/ArkClass");
|
|
56
|
+
const ArkFile_1 = require("../model/ArkFile");
|
|
57
|
+
const ArkMethod_1 = require("../model/ArkMethod");
|
|
58
|
+
const ArkNamespace_1 = require("../model/ArkNamespace");
|
|
59
|
+
const ArkSignature_1 = require("../model/ArkSignature");
|
|
60
|
+
const ArkSignatureBuilder_1 = require("../model/builder/ArkSignatureBuilder");
|
|
61
|
+
const TSConst_1 = require("./TSConst");
|
|
62
|
+
const json5parser_1 = require("../../utils/json5parser");
|
|
63
|
+
const logger_1 = __importStar(require("../../utils/logger"));
|
|
64
|
+
const Decorator_1 = require("../base/Decorator");
|
|
65
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'Scene');
|
|
66
|
+
/**
|
|
67
|
+
收集所有的onCreate,onStart等函数,构造一个虚拟函数,具体为:
|
|
68
|
+
@static_init()
|
|
69
|
+
...
|
|
70
|
+
count = 0
|
|
71
|
+
while (true) {
|
|
72
|
+
if (count == 1) {
|
|
73
|
+
temp1 = new ability
|
|
74
|
+
temp2 = new want
|
|
75
|
+
temp1.onCreate(temp2)
|
|
76
|
+
}
|
|
77
|
+
if (count == 2) {
|
|
78
|
+
onDestroy()
|
|
79
|
+
}
|
|
80
|
+
...
|
|
81
|
+
if (count == *) {
|
|
82
|
+
callbackMethod1()
|
|
83
|
+
}
|
|
84
|
+
...
|
|
85
|
+
}
|
|
86
|
+
return
|
|
87
|
+
如果是instanceInvoke还要先实例化对象,如果是其他文件的类或者方法还要添加import信息
|
|
88
|
+
*/
|
|
89
|
+
class DummyMainCreater {
|
|
90
|
+
constructor(scene) {
|
|
91
|
+
this.entryMethods = [];
|
|
92
|
+
this.classLocalMap = new Map();
|
|
93
|
+
this.dummyMain = new ArkMethod_1.ArkMethod();
|
|
94
|
+
this.tempLocalIndex = 0;
|
|
95
|
+
this.builtInClass = new Map;
|
|
96
|
+
this.scene = scene;
|
|
97
|
+
// Currently get entries from module.json5 can't visit all of abilities
|
|
98
|
+
// Todo: handle ablity/component jump, then get entries from module.json5
|
|
99
|
+
this.entryMethods = this.getMethodsFromAllAbilities();
|
|
100
|
+
this.entryMethods.push(...this.getEntryMethodsFromComponents());
|
|
101
|
+
this.entryMethods.push(...this.getCallbackMethods());
|
|
102
|
+
this.buildBuiltInClass();
|
|
103
|
+
}
|
|
104
|
+
buildBuiltInClass() {
|
|
105
|
+
for (const sdkFile of this.scene.getSdkArkFilesMap().values()) {
|
|
106
|
+
if (sdkFile.getName() == 'api\\@ohos.app.ability.Want.d.ts') {
|
|
107
|
+
const arkClass = sdkFile.getClassWithName('Want');
|
|
108
|
+
this.builtInClass.set('Want', arkClass);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
setEntryMethods(methods) {
|
|
113
|
+
this.entryMethods = methods;
|
|
114
|
+
}
|
|
115
|
+
createDummyMain() {
|
|
116
|
+
var _a;
|
|
117
|
+
const dummyMainFile = new ArkFile_1.ArkFile();
|
|
118
|
+
dummyMainFile.setScene(this.scene);
|
|
119
|
+
const dummyMainFileSignature = new ArkSignature_1.FileSignature(this.scene.getProjectName(), '@dummyFile');
|
|
120
|
+
dummyMainFile.setFileSignature(dummyMainFileSignature);
|
|
121
|
+
this.scene.getFilesMap().set(dummyMainFile.getFileSignature().toString(), dummyMainFile);
|
|
122
|
+
const dummyMainClass = new ArkClass_1.ArkClass();
|
|
123
|
+
dummyMainClass.setDeclaringArkFile(dummyMainFile);
|
|
124
|
+
const dummyMainClassSignature = new ArkSignature_1.ClassSignature('@dummyClass', dummyMainClass.getDeclaringArkFile().getFileSignature(), ((_a = dummyMainClass.getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getSignature()) || null);
|
|
125
|
+
dummyMainClass.setSignature(dummyMainClassSignature);
|
|
126
|
+
dummyMainFile.addArkClass(dummyMainClass);
|
|
127
|
+
this.dummyMain = new ArkMethod_1.ArkMethod();
|
|
128
|
+
this.dummyMain.setDeclaringArkClass(dummyMainClass);
|
|
129
|
+
const methodSubSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildMethodSubSignatureFromMethodName('@dummyMain');
|
|
130
|
+
const methodSignature = new ArkSignature_1.MethodSignature(this.dummyMain.getDeclaringArkClass().getSignature(), methodSubSignature);
|
|
131
|
+
this.dummyMain.setSignature(methodSignature);
|
|
132
|
+
dummyMainClass.addMethod(this.dummyMain);
|
|
133
|
+
for (const method of this.entryMethods) {
|
|
134
|
+
if (method.getDeclaringArkClass().isDefaultArkClass()) {
|
|
135
|
+
this.classLocalMap.set(method, null);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const declaringArkClass = method.getDeclaringArkClass();
|
|
139
|
+
let newLocal = null;
|
|
140
|
+
for (const local of this.classLocalMap.values()) {
|
|
141
|
+
if ((local === null || local === void 0 ? void 0 : local.getType()).getClassSignature() == declaringArkClass.getSignature()) {
|
|
142
|
+
newLocal = local;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!newLocal) {
|
|
147
|
+
newLocal = new Local_1.Local('temp' + this.tempLocalIndex, new Type_1.ClassType(declaringArkClass.getSignature()));
|
|
148
|
+
this.tempLocalIndex++;
|
|
149
|
+
}
|
|
150
|
+
this.classLocalMap.set(method, newLocal);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const localSet = new Set(Array.from(this.classLocalMap.values()).filter((value) => value !== null));
|
|
154
|
+
const dummyBody = new ArkBody_1.ArkBody(localSet, new Cfg_1.Cfg(), this.createDummyMainCfg(), new Map(), new Map());
|
|
155
|
+
this.dummyMain.setBody(dummyBody);
|
|
156
|
+
this.addCfg2Stmt();
|
|
157
|
+
this.scene.addToMethodsMap(this.dummyMain);
|
|
158
|
+
}
|
|
159
|
+
createDummyMainCfg() {
|
|
160
|
+
var _a;
|
|
161
|
+
const dummyCfg = new Cfg_1.Cfg();
|
|
162
|
+
dummyCfg.setDeclaringMethod(this.dummyMain);
|
|
163
|
+
const firstBlock = new BasicBlock_1.BasicBlock();
|
|
164
|
+
dummyCfg.addBlock(firstBlock);
|
|
165
|
+
for (const method of this.scene.getStaticInitMethods()) {
|
|
166
|
+
const staticInvokeExpr = new Expr_1.ArkStaticInvokeExpr(method.getSignature(), []);
|
|
167
|
+
const invokeStmt = new Stmt_1.ArkInvokeStmt(staticInvokeExpr);
|
|
168
|
+
firstBlock.addStmt(invokeStmt);
|
|
169
|
+
}
|
|
170
|
+
const locals = Array.from(new Set(this.classLocalMap.values()));
|
|
171
|
+
for (const local of locals) {
|
|
172
|
+
if (!local) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
let clsType = local.getType();
|
|
176
|
+
let cls = this.scene.getClass(clsType.getClassSignature());
|
|
177
|
+
if (!cls) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const assStmt = new Stmt_1.ArkAssignStmt(local, new Expr_1.ArkNewExpr(clsType));
|
|
181
|
+
firstBlock.addStmt(assStmt);
|
|
182
|
+
let consMtd = cls.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
|
|
183
|
+
if (consMtd) {
|
|
184
|
+
let ivkExpr = new Expr_1.ArkInstanceInvokeExpr(local, consMtd.getSignature(), []);
|
|
185
|
+
let ivkStmt = new Stmt_1.ArkInvokeStmt(ivkExpr);
|
|
186
|
+
firstBlock.addStmt(ivkStmt);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const countLocal = new Local_1.Local('count', Type_1.NumberType.getInstance());
|
|
190
|
+
const zero = new Constant_1.Constant('0', Type_1.NumberType.getInstance());
|
|
191
|
+
const countAssignStmt = new Stmt_1.ArkAssignStmt(countLocal, zero);
|
|
192
|
+
const truE = new Constant_1.Constant('true', Type_1.BooleanType.getInstance());
|
|
193
|
+
const conditionTrue = new Expr_1.ArkConditionExpr(truE, zero, Expr_1.RelationalBinaryOperator.Equality);
|
|
194
|
+
const whileStmt = new Stmt_1.ArkIfStmt(conditionTrue);
|
|
195
|
+
firstBlock.addStmt(countAssignStmt);
|
|
196
|
+
const whileBlock = new BasicBlock_1.BasicBlock();
|
|
197
|
+
dummyCfg.addBlock(whileBlock);
|
|
198
|
+
whileBlock.addStmt(whileStmt);
|
|
199
|
+
firstBlock.addSuccessorBlock(whileBlock);
|
|
200
|
+
whileBlock.addPredecessorBlock(firstBlock);
|
|
201
|
+
let lastBlocks = [whileBlock];
|
|
202
|
+
let count = 0;
|
|
203
|
+
for (const method of this.entryMethods) {
|
|
204
|
+
count++;
|
|
205
|
+
const condition = new Expr_1.ArkConditionExpr(countLocal, new Constant_1.Constant(count.toString(), Type_1.NumberType.getInstance()), Expr_1.RelationalBinaryOperator.Equality);
|
|
206
|
+
const ifStmt = new Stmt_1.ArkIfStmt(condition);
|
|
207
|
+
const ifBlock = new BasicBlock_1.BasicBlock();
|
|
208
|
+
dummyCfg.addBlock(ifBlock);
|
|
209
|
+
ifBlock.addStmt(ifStmt);
|
|
210
|
+
for (const block of lastBlocks) {
|
|
211
|
+
ifBlock.addPredecessorBlock(block);
|
|
212
|
+
block.addSuccessorBlock(ifBlock);
|
|
213
|
+
}
|
|
214
|
+
const invokeBlock = new BasicBlock_1.BasicBlock();
|
|
215
|
+
const paramLocals = [];
|
|
216
|
+
let paramIdx = 0;
|
|
217
|
+
for (const param of method.getParameters()) {
|
|
218
|
+
let paramType = param.getType();
|
|
219
|
+
let checkMethod = method;
|
|
220
|
+
// In ArkIR from abc scenario, param type is undefined in some cases
|
|
221
|
+
// Then try to get it from super class(SDK)
|
|
222
|
+
// TODO - need handle method overload to get the correct method
|
|
223
|
+
if (!paramType) {
|
|
224
|
+
let superCls = method.getDeclaringArkClass().getSuperClass();
|
|
225
|
+
let methodInSuperCls = superCls === null || superCls === void 0 ? void 0 : superCls.getMethodWithName(method.getName());
|
|
226
|
+
if (methodInSuperCls) {
|
|
227
|
+
paramType = (_a = methodInSuperCls.getParameters().at(paramIdx)) === null || _a === void 0 ? void 0 : _a.getType();
|
|
228
|
+
checkMethod = methodInSuperCls;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const paramLocal = new Local_1.Local('temp' + this.tempLocalIndex++, paramType);
|
|
232
|
+
paramLocals.push(paramLocal);
|
|
233
|
+
if (paramType instanceof Type_1.ClassType) {
|
|
234
|
+
const assStmt = new Stmt_1.ArkAssignStmt(paramLocal, new Expr_1.ArkNewExpr(paramType));
|
|
235
|
+
invokeBlock.addStmt(assStmt);
|
|
236
|
+
}
|
|
237
|
+
else if (paramType instanceof Type_1.UnclearReferenceType) {
|
|
238
|
+
const arkClass = this.getArkClassFromParamType(paramType.getName(), checkMethod.getDeclaringArkFile());
|
|
239
|
+
if (arkClass) {
|
|
240
|
+
const classType = new Type_1.ClassType(arkClass.getSignature());
|
|
241
|
+
paramLocal.setType(classType);
|
|
242
|
+
const assStmt = new Stmt_1.ArkAssignStmt(paramLocal, new Expr_1.ArkNewExpr(classType));
|
|
243
|
+
invokeBlock.addStmt(assStmt);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
paramIdx++;
|
|
247
|
+
}
|
|
248
|
+
const local = this.classLocalMap.get(method);
|
|
249
|
+
let invokeExpr;
|
|
250
|
+
if (local) {
|
|
251
|
+
invokeExpr = new Expr_1.ArkInstanceInvokeExpr(local, method.getSignature(), paramLocals);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
invokeExpr = new Expr_1.ArkStaticInvokeExpr(method.getSignature(), paramLocals);
|
|
255
|
+
}
|
|
256
|
+
const invokeStmt = new Stmt_1.ArkInvokeStmt(invokeExpr);
|
|
257
|
+
dummyCfg.addBlock(invokeBlock);
|
|
258
|
+
invokeBlock.addStmt(invokeStmt);
|
|
259
|
+
ifBlock.addSuccessorBlock(invokeBlock);
|
|
260
|
+
invokeBlock.addPredecessorBlock(ifBlock);
|
|
261
|
+
lastBlocks = [ifBlock, invokeBlock];
|
|
262
|
+
}
|
|
263
|
+
for (const block of lastBlocks) {
|
|
264
|
+
block.addSuccessorBlock(whileBlock);
|
|
265
|
+
whileBlock.addPredecessorBlock(block);
|
|
266
|
+
}
|
|
267
|
+
const returnStmt = new Stmt_1.ArkReturnVoidStmt();
|
|
268
|
+
const returnBlock = new BasicBlock_1.BasicBlock();
|
|
269
|
+
dummyCfg.addBlock(returnBlock);
|
|
270
|
+
returnBlock.addStmt(returnStmt);
|
|
271
|
+
whileBlock.addSuccessorBlock(returnBlock);
|
|
272
|
+
returnBlock.addPredecessorBlock(whileBlock);
|
|
273
|
+
return dummyCfg;
|
|
274
|
+
}
|
|
275
|
+
getArkClassFromParamType(name, file) {
|
|
276
|
+
var _a, _b;
|
|
277
|
+
if (name.includes('.')) {
|
|
278
|
+
const nsName = name.split('.')[0];
|
|
279
|
+
const clsName = name.split('.')[1];
|
|
280
|
+
const importInfo = file.getImportInfoBy(nsName);
|
|
281
|
+
const arkExport = (_a = importInfo === null || importInfo === void 0 ? void 0 : importInfo.getLazyExportInfo()) === null || _a === void 0 ? void 0 : _a.getArkExport();
|
|
282
|
+
if (arkExport instanceof ArkNamespace_1.ArkNamespace) {
|
|
283
|
+
const arkClass = arkExport.getClassWithName(clsName);
|
|
284
|
+
if (arkClass) {
|
|
285
|
+
return arkClass;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
const importInfo = file.getImportInfoBy(name);
|
|
291
|
+
const arkExport = (_b = importInfo === null || importInfo === void 0 ? void 0 : importInfo.getLazyExportInfo()) === null || _b === void 0 ? void 0 : _b.getArkExport();
|
|
292
|
+
if (arkExport instanceof ArkClass_1.ArkClass) {
|
|
293
|
+
return arkExport;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
addCfg2Stmt() {
|
|
299
|
+
const cfg = this.dummyMain.getCfg();
|
|
300
|
+
if (!cfg) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
for (const block of cfg.getBlocks()) {
|
|
304
|
+
for (const stmt of block.getStmts()) {
|
|
305
|
+
stmt.setCfg(cfg);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
getDummyMain() {
|
|
310
|
+
return this.dummyMain;
|
|
311
|
+
}
|
|
312
|
+
getEntryMethodsFromComponents() {
|
|
313
|
+
const COMPONENT_BASE_CLASSES = ['CustomComponent', 'ViewPU'];
|
|
314
|
+
let methods = [];
|
|
315
|
+
this.scene.getClasses()
|
|
316
|
+
.filter(cls => {
|
|
317
|
+
if (COMPONENT_BASE_CLASSES.includes(cls.getSuperClassName())) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
for (let m of cls.getModifiers()) {
|
|
321
|
+
if (m instanceof Decorator_1.Decorator && m.getKind() === 'Component') {
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
})
|
|
327
|
+
.forEach(cls => {
|
|
328
|
+
methods.push(...cls.getMethods().filter(mtd => entryMethodUtils_1.COMPONENT_LIFECYCLE_METHOD_NAME.includes(mtd.getName())));
|
|
329
|
+
});
|
|
330
|
+
return methods;
|
|
331
|
+
}
|
|
332
|
+
getMethodsFromAllAbilities() {
|
|
333
|
+
const ABILITY_BASE_CLASSES = ['UIExtensionAbility', 'Ability', 'FormExtensionAbility'];
|
|
334
|
+
let methods = [];
|
|
335
|
+
this.scene.getClasses()
|
|
336
|
+
.filter(cls => ABILITY_BASE_CLASSES.includes(cls.getSuperClassName()))
|
|
337
|
+
.forEach(cls => {
|
|
338
|
+
methods.push(...cls.getMethods().filter(mtd => entryMethodUtils_1.LIFECYCLE_METHOD_NAME.includes(mtd.getName())));
|
|
339
|
+
});
|
|
340
|
+
return methods;
|
|
341
|
+
}
|
|
342
|
+
getEntryMethodsFromModuleJson5() {
|
|
343
|
+
const projectDir = this.scene.getRealProjectDir();
|
|
344
|
+
const buildProfile = path_1.default.join(projectDir, 'build-profile.json5');
|
|
345
|
+
if (!fs_1.default.existsSync(buildProfile)) {
|
|
346
|
+
logger.error(`${buildProfile} is not exists.`);
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
349
|
+
const abilities = [];
|
|
350
|
+
const buildProfileConfig = (0, json5parser_1.fetchDependenciesFromFile)(buildProfile);
|
|
351
|
+
let modules;
|
|
352
|
+
if (buildProfileConfig instanceof Object) {
|
|
353
|
+
Object.entries(buildProfileConfig).forEach(([k, v]) => {
|
|
354
|
+
if (k === 'modules' && Array.isArray(v)) {
|
|
355
|
+
modules = v;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (Array.isArray(modules)) {
|
|
361
|
+
for (const module of modules) {
|
|
362
|
+
const modulePath = path_1.default.join(projectDir, module.srcPath);
|
|
363
|
+
let moduleAbilities = this.getAbilitiesByParseModuleJson(modulePath);
|
|
364
|
+
abilities.push(...moduleAbilities);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const entryMethods = [];
|
|
368
|
+
for (const ability of abilities) {
|
|
369
|
+
const abilityEntryMethods = [];
|
|
370
|
+
let cls = ability;
|
|
371
|
+
for (const method of cls.getMethods()) {
|
|
372
|
+
for (const modifier of method.getModifiers()) {
|
|
373
|
+
if (modifier === 'private') {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
for (const mtd of abilityEntryMethods) {
|
|
378
|
+
if (mtd.getName() === method.getName()) {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (entryMethodUtils_1.LIFECYCLE_METHOD_NAME.includes(method.getName()) && !entryMethods.includes(method)) {
|
|
383
|
+
abilityEntryMethods.push(method);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
entryMethods.push(...abilityEntryMethods);
|
|
387
|
+
}
|
|
388
|
+
return entryMethods;
|
|
389
|
+
}
|
|
390
|
+
getAbilitiesByParseModuleJson(modulePath) {
|
|
391
|
+
const jsonPath = path_1.default.join(modulePath, '/src/main/module.json5');
|
|
392
|
+
let abilities = [];
|
|
393
|
+
const ABILITY_NAMES = ['abilities', 'extensionAbilities'];
|
|
394
|
+
try {
|
|
395
|
+
const config = (0, json5parser_1.fetchDependenciesFromFile)(jsonPath);
|
|
396
|
+
const configModule = config.module;
|
|
397
|
+
if (configModule instanceof Object) {
|
|
398
|
+
Object.entries(configModule).forEach(([k, v]) => {
|
|
399
|
+
if (ABILITY_NAMES.includes(k)) {
|
|
400
|
+
const moduleAbilities = (0, entryMethodUtils_1.getAbilities)(v, modulePath, this.scene);
|
|
401
|
+
for (const ability of moduleAbilities) {
|
|
402
|
+
if (!abilities.includes(ability)) {
|
|
403
|
+
abilities.push(ability);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
catch (err) {
|
|
411
|
+
logger.error(err);
|
|
412
|
+
}
|
|
413
|
+
return abilities;
|
|
414
|
+
}
|
|
415
|
+
getCallbackMethods() {
|
|
416
|
+
const callbackMethods = [];
|
|
417
|
+
this.scene.getMethods().forEach(method => {
|
|
418
|
+
if (!method.getCfg()) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
method.getCfg().getBlocks().forEach(block => {
|
|
422
|
+
block.getStmts().forEach(stmt => {
|
|
423
|
+
const cbMethod = (0, entryMethodUtils_1.getCallbackMethodFromStmt)(stmt, this.scene);
|
|
424
|
+
if (cbMethod && !callbackMethods.includes(cbMethod)) {
|
|
425
|
+
callbackMethods.push(cbMethod);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
return callbackMethods;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
exports.DummyMainCreater = DummyMainCreater;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare const ETS_COMPILER_OPTIONS: {
|
|
2
|
+
ets: {
|
|
3
|
+
emitDecorators: {
|
|
4
|
+
name: string;
|
|
5
|
+
emitParameters: boolean;
|
|
6
|
+
}[];
|
|
7
|
+
propertyDecorators: {
|
|
8
|
+
name: string;
|
|
9
|
+
needInitialization: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
render: {
|
|
12
|
+
method: string[];
|
|
13
|
+
decorator: string;
|
|
14
|
+
};
|
|
15
|
+
components: string[];
|
|
16
|
+
extend: {
|
|
17
|
+
decorator: string[];
|
|
18
|
+
components: {
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
instance: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
styles: {
|
|
25
|
+
decorator: string;
|
|
26
|
+
component: {
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
instance: string;
|
|
30
|
+
};
|
|
31
|
+
property: string;
|
|
32
|
+
};
|
|
33
|
+
concurrent: {
|
|
34
|
+
decorator: string;
|
|
35
|
+
};
|
|
36
|
+
customComponent: string;
|
|
37
|
+
libs: never[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const BUILDIN_SYSTEM_COMPONENT: Set<string>;
|
|
41
|
+
export declare const BUILDIN_ATOMIC_COMPONENT: Set<string>;
|
|
42
|
+
export declare const COMPONENT_DECORATOR: Set<string>;
|
|
43
|
+
export declare const ENTRY_DECORATOR: string;
|
|
44
|
+
export declare const BUILDER_DECORATOR: string;
|
|
45
|
+
export declare const BUILDER_PARAM_DECORATOR: string;
|
|
46
|
+
export declare function isEtsAtomicComponent(name: string): boolean;
|
|
47
|
+
export declare function isEtsSystemComponent(name: string): boolean;
|
|
48
|
+
export declare function isEtsContainerComponent(name: string): boolean;
|
|
49
|
+
export declare const COMPONENT_CREATE_FUNCTION: string;
|
|
50
|
+
export declare const COMPONENT_POP_FUNCTION: string;
|
|
51
|
+
export declare const COMPONENT_CUSTOMVIEW: string;
|
|
52
|
+
export declare const COMPONENT_REPEAT: string;
|
|
53
|
+
export declare const COMPONENT_FOR_EACH: string;
|
|
54
|
+
export declare const COMPONENT_LAZY_FOR_EACH: string;
|
|
55
|
+
export declare const COMPONENT_IF: string;
|
|
56
|
+
export declare const COMPONENT_IF_BRANCH: string;
|
|
57
|
+
export declare const COMPONENT_BRANCH_FUNCTION: string;
|
|
58
|
+
export declare const COMPONENT_BUILD_FUNCTION: string;
|
|
59
|
+
export declare const SPECIAL_CONTAINER_COMPONENT: Set<string>;
|
|
60
|
+
export declare const COMPONENT_PATH: string;
|
|
61
|
+
export declare const COMPONENT_COMMON: string;
|
|
62
|
+
export declare const COMPONENT_INSTANCE: string;
|
|
63
|
+
export declare const API_INTERNAL: string;
|
|
64
|
+
export declare const COMPONENT_ATTRIBUTE: string;
|
|
65
|
+
//# sourceMappingURL=EtsConst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EtsConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/EtsConst.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoyBhC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAAgD,CAAC;AAElG,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAqD/C,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAqE,CAAC;AAClH,eAAO,MAAM,eAAe,EAAE,MAAgB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,EAAE,MAAkB,CAAC;AACnD,eAAO,MAAM,uBAAuB,EAAE,MAAuB,CAAC;AAE9D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,EAAE,MAAc,CAAC;AACpD,eAAO,MAAM,oBAAoB,EAAE,MAAe,CAAC;AACnD,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AACjD,eAAO,MAAM,kBAAkB,EAAE,MAAkB,CAAC;AACpD,eAAO,MAAM,uBAAuB,EAAE,MAAsB,CAAC;AAE7D,eAAO,MAAM,YAAY,EAAE,MAAa,CAAC;AACzC,eAAO,MAAM,mBAAmB,EAAE,MAAmB,CAAC;AACtD,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,wBAAwB,EAAE,MAAgB,CAAC;AAExD,eAAO,MAAM,2BAA2B,EAAE,GAAG,CAAC,MAAM,CAKlD,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,MAA0C,CAAC;AACxE,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AACjD,eAAO,MAAM,kBAAkB,EAAE,MAAmB,CAAC;AACrD,eAAO,MAAM,YAAY,EAAE,MAA0C,CAAC;AAEtE,eAAO,MAAM,mBAAmB,EAAE,MAAoB,CAAC"}
|