arkanalyzer 1.0.93 → 2.0.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Config.d.ts +7 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/Scene.d.ts +134 -170
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +412 -976
- package/lib/callgraph/algorithm/AbstractAnalysis.js +3 -2
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +2 -3
- package/lib/callgraph/model/CallGraph.js +1 -1
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +1 -3
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PTAUtils.js +17 -7
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +4 -14
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +2 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +1 -2
- package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +0 -1
- package/lib/cli/commands/cg.d.ts +1 -0
- package/lib/cli/commands/cg.d.ts.map +1 -1
- package/lib/cli/commands/cg.js +22 -18
- package/lib/cli/commands/ir.d.ts +1 -0
- package/lib/cli/commands/ir.d.ts.map +1 -1
- package/lib/cli/commands/ir.js +5 -2
- package/lib/core/base/Constant.d.ts +5 -5
- package/lib/core/base/Constant.d.ts.map +1 -1
- package/lib/core/base/Constant.js +12 -9
- package/lib/core/base/Expr.d.ts +36 -20
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +206 -94
- package/lib/core/base/Local.d.ts +10 -20
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +25 -28
- package/lib/core/base/Position.d.ts +6 -0
- package/lib/core/base/Position.d.ts.map +1 -1
- package/lib/core/base/Position.js +37 -11
- package/lib/core/base/Ref.d.ts +45 -33
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +225 -51
- package/lib/core/base/Stmt.d.ts +19 -9
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +135 -52
- package/lib/core/base/Type.d.ts +67 -4
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +391 -20
- package/lib/core/base/TypeExpr.d.ts +6 -4
- package/lib/core/base/TypeExpr.d.ts.map +1 -1
- package/lib/core/base/TypeExpr.js +34 -10
- package/lib/core/base/Value.d.ts +20 -2
- package/lib/core/base/Value.d.ts.map +1 -1
- package/lib/core/base/Value.js +12 -0
- package/lib/core/common/ArkIRTransformer.d.ts +18 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +94 -75
- package/lib/core/common/ArkValueTransformer.d.ts +21 -3
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +458 -266
- package/lib/core/common/Builtin.d.ts +48 -24
- package/lib/core/common/Builtin.d.ts.map +1 -1
- package/lib/core/common/Builtin.js +90 -52
- package/lib/core/common/CanonicalizerValidator.d.ts +308 -0
- package/lib/core/common/CanonicalizerValidator.d.ts.map +1 -0
- package/lib/core/common/CanonicalizerValidator.js +888 -0
- package/lib/core/common/Const.d.ts +3 -3
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +3 -3
- package/lib/core/common/DummyMainCreater.d.ts +2 -21
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +8 -105
- package/lib/core/common/IRInference.d.ts +55 -3
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +407 -126
- package/lib/core/common/IRUtils.d.ts +1 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +44 -13
- package/lib/core/common/ModelUtils.d.ts +44 -20
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +378 -208
- package/lib/core/common/SdkUtils.d.ts +35 -5
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +203 -59
- package/lib/core/common/SignatureCanonicalizer.d.ts +95 -0
- package/lib/core/common/SignatureCanonicalizer.d.ts.map +1 -0
- package/lib/core/common/SignatureCanonicalizer.js +116 -0
- package/lib/core/common/SignatureCanonicalizerRegistry.d.ts +176 -0
- package/lib/core/common/SignatureCanonicalizerRegistry.d.ts.map +1 -0
- package/lib/core/common/SignatureCanonicalizerRegistry.js +343 -0
- package/lib/core/common/SignatureModelCanonicalizer.d.ts +69 -0
- package/lib/core/common/SignatureModelCanonicalizer.d.ts.map +1 -0
- package/lib/core/common/SignatureModelCanonicalizer.js +109 -0
- package/lib/core/common/StmtUseReplacer.d.ts +1 -0
- package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
- package/lib/core/common/StmtUseReplacer.js +9 -0
- package/lib/core/common/StringUtils.d.ts +12 -1
- package/lib/core/common/StringUtils.d.ts.map +1 -1
- package/lib/core/common/StringUtils.js +36 -17
- package/lib/core/common/TempSignatureCanonicalizer.d.ts +82 -0
- package/lib/core/common/TempSignatureCanonicalizer.d.ts.map +1 -0
- package/lib/core/common/TempSignatureCanonicalizer.js +177 -0
- package/lib/core/common/TypeInference.d.ts +24 -6
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +243 -117
- package/lib/core/common/ValueUtil.d.ts +2 -1
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +4 -1
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +21 -6
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +46 -33
- package/lib/core/graph/builder/IfBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/IfBuilder.js +6 -2
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +6 -2
- package/lib/core/inference/ModelInference.d.ts +24 -4
- package/lib/core/inference/ModelInference.d.ts.map +1 -1
- package/lib/core/inference/ModelInference.js +273 -79
- package/lib/core/inference/ValueInference.d.ts +3 -2
- package/lib/core/inference/ValueInference.d.ts.map +1 -1
- package/lib/core/inference/ValueInference.js +90 -40
- package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
- package/lib/core/inference/abc/AbcInference.js +28 -15
- package/lib/core/inference/arkts/ArkTsInference.d.ts +9 -3
- package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
- package/lib/core/inference/arkts/ArkTsInference.js +54 -16
- package/lib/core/model/ArkClass.d.ts +192 -18
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +852 -122
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +1 -2
- package/lib/core/model/ArkField.d.ts +34 -2
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +89 -14
- package/lib/core/model/ArkFile.d.ts +72 -12
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +275 -65
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +1 -2
- package/lib/core/model/ArkMethod.d.ts +101 -15
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +252 -39
- package/lib/core/model/ArkModule.d.ts +1 -1
- package/lib/core/model/ArkModule.js +1 -1
- package/lib/core/model/ArkNamespace.d.ts +80 -10
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +309 -76
- package/lib/core/model/ArkSignature.d.ts +242 -18
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +725 -95
- package/lib/core/model/builder/ArkClassBuilder.d.ts +6 -3
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +119 -73
- package/lib/core/model/builder/ArkExportBuilder.d.ts +1 -1
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.d.ts +0 -2
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +9 -43
- package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFileBuilder.js +32 -33
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +10 -3
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +40 -26
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +3 -2
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +45 -77
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkSignatureBuilder.js +26 -3
- package/lib/core/model/builder/BodyBuilder.d.ts +1 -0
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/BodyBuilder.js +37 -11
- package/lib/core/model/builder/builderUtils.d.ts +11 -1
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +124 -90
- package/lib/frontend/FrontendBuilder.d.ts +10 -6
- package/lib/frontend/FrontendBuilder.d.ts.map +1 -1
- package/lib/frontend/FrontendBuilder.js +19 -45
- package/lib/frontend/ModuleScene.d.ts +43 -0
- package/lib/frontend/ModuleScene.d.ts.map +1 -0
- package/lib/frontend/ModuleScene.js +143 -0
- package/lib/frontend/SceneBuildStage.d.ts +15 -0
- package/lib/frontend/SceneBuildStage.d.ts.map +1 -0
- package/lib/frontend/SceneBuildStage.js +32 -0
- package/lib/frontend/SceneBuilder.d.ts +153 -0
- package/lib/frontend/SceneBuilder.d.ts.map +1 -0
- package/lib/frontend/SceneBuilder.js +859 -0
- package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +0 -2
- package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -1
- package/lib/frontend/arktsFrontend/ArktsFrontend.js +0 -18
- package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts +17 -0
- package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts.map +1 -0
- package/lib/frontend/arktsFrontend/FileBodyRemount.js +187 -0
- package/lib/frontend/common/ModuleBuilder.d.ts +4 -2
- package/lib/frontend/common/ModuleBuilder.d.ts.map +1 -1
- package/lib/frontend/common/ModuleBuilder.js +19 -9
- package/lib/frontend/cppFrontend/CppFrontend.d.ts +0 -6
- package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/CppFrontend.js +0 -56
- package/lib/frontend/cppFrontend/base/Type.d.ts +7 -0
- package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/base/Type.js +29 -0
- package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +56 -56
- package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
- package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +124 -113
- package/lib/frontend/cppFrontend/common/Builtin.d.ts +29 -19
- package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/Builtin.js +56 -35
- package/lib/frontend/cppFrontend/common/IRInference.d.ts +7 -2
- package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/IRInference.js +61 -28
- package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -0
- package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/IRUtils.js +22 -10
- package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +19 -0
- package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/ModelUtils.js +84 -3
- package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/common/TypeInference.js +44 -54
- package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +2 -1
- package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +1 -1
- package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/inference/CxxValueInference.js +41 -5
- package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +18 -28
- package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +2 -3
- package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +2 -2
- package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +31 -24
- package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +10 -16
- package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +0 -2
- package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +19 -37
- package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -0
- package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +30 -3
- package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/frontend/cppFrontend/model/builder/builderUtils.js +8 -4
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -2
- package/lib/save/json/JsonSerialization.js +2 -2
- package/lib/save/source/SourceStmt.js +1 -1
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +0 -9
- package/lib/statistics/StageStatistics.d.ts +195 -0
- package/lib/statistics/StageStatistics.d.ts.map +1 -0
- package/lib/statistics/StageStatistics.js +346 -0
- package/lib/statistics/StageStatisticsReporter.d.ts +58 -0
- package/lib/statistics/StageStatisticsReporter.d.ts.map +1 -0
- package/lib/statistics/StageStatisticsReporter.js +255 -0
- package/lib/utils/Canonicalizer.d.ts +9 -2
- package/lib/utils/Canonicalizer.d.ts.map +1 -1
- package/lib/utils/Canonicalizer.js +19 -2
- package/lib/utils/CxxSceneUtils.d.ts +7 -0
- package/lib/utils/CxxSceneUtils.d.ts.map +1 -1
- package/lib/utils/CxxSceneUtils.js +10 -1
- package/lib/utils/FileUtils.d.ts +0 -1
- package/lib/utils/FileUtils.d.ts.map +1 -1
- package/lib/utils/FileUtils.js +1 -9
- package/lib/utils/HashUtils.d.ts +9 -0
- package/lib/utils/HashUtils.d.ts.map +1 -0
- package/lib/utils/HashUtils.js +65 -0
- package/lib/utils/ModuleUtils.d.ts.map +1 -1
- package/lib/utils/ModuleUtils.js +24 -5
- package/lib/utils/VisitedSegment.d.ts +23 -0
- package/lib/utils/VisitedSegment.d.ts.map +1 -0
- package/lib/utils/VisitedSegment.js +64 -0
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +7 -7
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/getAllFiles.js +11 -8
- package/lib/utils/logger.d.ts +4 -0
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/logger.js +16 -0
- package/lib/utils/parseArkSourceFile.d.ts +33 -0
- package/lib/utils/parseArkSourceFile.d.ts.map +1 -0
- package/lib/utils/parseArkSourceFile.js +131 -0
- package/package.json +1 -1
- package/lib/node_modules/ohos-typescript/README.OpenSource +0 -11
- package/lib/node_modules/ohos-typescript/README.md +0 -81
- package/lib/node_modules/ohos-typescript/SECURITY.md +0 -41
- package/lib/node_modules/ohos-typescript/ThirdPartyNoticeText.txt +0 -193
- package/lib/node_modules/ohos-typescript/bin/tsc +0 -2
- package/lib/node_modules/ohos-typescript/bin/tsserver +0 -2
- package/lib/node_modules/ohos-typescript/lib/README.md +0 -5
- package/lib/node_modules/ohos-typescript/lib/cancellationToken.js +0 -86
- package/lib/node_modules/ohos-typescript/lib/cs/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/de/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/es/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/fr/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/it/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/ja/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/ko/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/lib.dom.d.ts +0 -18505
- package/lib/node_modules/ohos-typescript/lib/lib.dom.iterable.d.ts +0 -341
- package/lib/node_modules/ohos-typescript/lib/lib.scripthost.d.ts +0 -327
- package/lib/node_modules/ohos-typescript/lib/lib.webworker.d.ts +0 -6192
- package/lib/node_modules/ohos-typescript/lib/lib.webworker.importscripts.d.ts +0 -26
- package/lib/node_modules/ohos-typescript/lib/lib.webworker.iterable.d.ts +0 -175
- package/lib/node_modules/ohos-typescript/lib/pl/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/pt-br/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/ru/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/tr/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/tsc.js +0 -114551
- package/lib/node_modules/ohos-typescript/lib/tsserver.js +0 -179691
- package/lib/node_modules/ohos-typescript/lib/tsserverlibrary.d.ts +0 -13648
- package/lib/node_modules/ohos-typescript/lib/tsserverlibrary.js +0 -178688
- package/lib/node_modules/ohos-typescript/lib/typesMap.json +0 -497
- package/lib/node_modules/ohos-typescript/lib/typingsInstaller.js +0 -39871
- package/lib/node_modules/ohos-typescript/lib/watchGuard.js +0 -49
- package/lib/node_modules/ohos-typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -1880
- package/lib/node_modules/ohos-typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -1880
- package/lib/utils/DependenciesSort.d.ts +0 -3
- package/lib/utils/DependenciesSort.d.ts.map +0 -1
- package/lib/utils/DependenciesSort.js +0 -72
- package/lib/utils/crypto_utils.d.ts +0 -6
- package/lib/utils/crypto_utils.d.ts.map +0 -1
- package/lib/utils/crypto_utils.js +0 -57
|
@@ -55,6 +55,78 @@ const Const_1 = require("../common/Const");
|
|
|
55
55
|
const TypeExpr_1 = require("../base/TypeExpr");
|
|
56
56
|
const Expr_1 = require("../base/Expr");
|
|
57
57
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelInference');
|
|
58
|
+
class ArrayValueVisited {
|
|
59
|
+
constructor() {
|
|
60
|
+
this.items = [];
|
|
61
|
+
this.base = 0;
|
|
62
|
+
this.top = 0;
|
|
63
|
+
}
|
|
64
|
+
enter() {
|
|
65
|
+
const prev = this.base;
|
|
66
|
+
this.base = this.top;
|
|
67
|
+
return prev;
|
|
68
|
+
}
|
|
69
|
+
has(value) {
|
|
70
|
+
for (let i = this.base; i < this.top; i++) {
|
|
71
|
+
if (this.items[i] === value) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
add(value) {
|
|
78
|
+
this.items[this.top++] = value;
|
|
79
|
+
}
|
|
80
|
+
leave(prevBase) {
|
|
81
|
+
const nullValue = null;
|
|
82
|
+
for (let i = this.base; i < this.top; i++) {
|
|
83
|
+
this.items[i] = nullValue;
|
|
84
|
+
}
|
|
85
|
+
this.top = this.base;
|
|
86
|
+
this.base = prevBase;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const valueVisitedSeg = new ArrayValueVisited();
|
|
90
|
+
const GLOBAL_MERGE_SET_PRODUCT_LIMIT = 131072;
|
|
91
|
+
/**
|
|
92
|
+
* Snapshot-semantics merge of `incoming` into the global's used-stmt list: membership is
|
|
93
|
+
* checked against the entries present at call start (duplicates inside `incoming` are all
|
|
94
|
+
* appended, exactly like the former `new Set(global.getUsedStmts())` snapshot did).
|
|
95
|
+
*
|
|
96
|
+
* The linear scan is the only path in practice: a pointer compare is ~0.5ns versus ~50ns
|
|
97
|
+
* per Set hash operation, so scanning wins for any incoming count below ~50 regardless of
|
|
98
|
+
* the snapshot size - and incoming is one body's references to one global (typically 1-3).
|
|
99
|
+
* The Set fallback only guards the pathological product (a huge snapshot merged with a huge
|
|
100
|
+
* incoming list in one call), where the quadratic tail would reach milliseconds.
|
|
101
|
+
*/
|
|
102
|
+
function mergeGlobalUsedStmts(global, incoming) {
|
|
103
|
+
const snapshot = global.getUsedStmts();
|
|
104
|
+
const boundary = snapshot.length;
|
|
105
|
+
if (boundary * incoming.length > GLOBAL_MERGE_SET_PRODUCT_LIMIT) {
|
|
106
|
+
const set = new Set();
|
|
107
|
+
for (let i = 0; i < boundary; i++) {
|
|
108
|
+
set.add(snapshot[i]);
|
|
109
|
+
}
|
|
110
|
+
for (const stmt of incoming) {
|
|
111
|
+
if (!set.has(stmt)) {
|
|
112
|
+
global.addUsedStmt(stmt);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
for (const stmt of incoming) {
|
|
118
|
+
let found = false;
|
|
119
|
+
for (let i = 0; i < boundary; i++) {
|
|
120
|
+
if (snapshot[i] === stmt) {
|
|
121
|
+
found = true;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (!found) {
|
|
126
|
+
global.addUsedStmt(stmt);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
58
130
|
/**
|
|
59
131
|
* Abstract base class for performing inference on ArkModel instances
|
|
60
132
|
* Implements both Inference and InferenceFlow interfaces to provide
|
|
@@ -82,16 +154,14 @@ class ArkModelInference {
|
|
|
82
154
|
* Can be overridden by subclasses to add custom pre-processing logic
|
|
83
155
|
* @param model - The ArkModel instance being processed
|
|
84
156
|
*/
|
|
85
|
-
preInfer(model) {
|
|
86
|
-
}
|
|
157
|
+
preInfer(model) { }
|
|
87
158
|
/**
|
|
88
159
|
* Post-inference hook method for cleanup and finalization
|
|
89
160
|
* Can be overridden by subclasses to add custom post-processing logic
|
|
90
161
|
* @param model - The ArkModel instance that was processed
|
|
91
162
|
* @param result
|
|
92
163
|
*/
|
|
93
|
-
postInfer(model, result) {
|
|
94
|
-
}
|
|
164
|
+
postInfer(model, result) { }
|
|
95
165
|
}
|
|
96
166
|
class ImportInfoInference extends ArkModelInference {
|
|
97
167
|
constructor() {
|
|
@@ -106,10 +176,13 @@ class ImportInfoInference extends ArkModelInference {
|
|
|
106
176
|
var _a, _b;
|
|
107
177
|
const file = this.fromFile;
|
|
108
178
|
if (!file) {
|
|
109
|
-
|
|
179
|
+
if (logger_1.default.isWarnEnabled(logger)) {
|
|
180
|
+
const signature = (_b = (_a = fromInfo.getDeclaringArkFile()) === null || _a === void 0 ? void 0 : _a.getFileSignature()) === null || _b === void 0 ? void 0 : _b.toString();
|
|
181
|
+
logger.warn(`${fromInfo.getOriginName()} ${fromInfo.getFrom()} file not found: ${signature}`);
|
|
182
|
+
}
|
|
110
183
|
return null;
|
|
111
184
|
}
|
|
112
|
-
if (
|
|
185
|
+
if (file.getFileSigID() === fromInfo.getDeclaringArkFile().getFileSigID()) {
|
|
113
186
|
for (let exportInfo of file.getExportInfos()) {
|
|
114
187
|
if (exportInfo.getOriginName() === fromInfo.getOriginName()) {
|
|
115
188
|
exportInfo.setArkExport(file.getDefaultClass());
|
|
@@ -120,7 +193,9 @@ class ImportInfoInference extends ArkModelInference {
|
|
|
120
193
|
}
|
|
121
194
|
let exportInfo = (0, ModelUtils_1.findExportInfoInfile)(fromInfo, file) || null;
|
|
122
195
|
if (exportInfo === null) {
|
|
123
|
-
|
|
196
|
+
if (logger_1.default.isWarnEnabled(logger)) {
|
|
197
|
+
logger.warn('export info not found, ' + fromInfo.getFrom() + ' in file: ' + fromInfo.getDeclaringArkFile().getFileSignature().toString());
|
|
198
|
+
}
|
|
124
199
|
return null;
|
|
125
200
|
}
|
|
126
201
|
const arkExport = (0, ModelUtils_1.findArkExport)(exportInfo);
|
|
@@ -157,7 +232,8 @@ class FileInference extends ArkModelInference {
|
|
|
157
232
|
* @param {ArkFile} file
|
|
158
233
|
*/
|
|
159
234
|
preInfer(file) {
|
|
160
|
-
file.getImportInfos()
|
|
235
|
+
file.getImportInfos()
|
|
236
|
+
.filter(i => i.getExportInfo() === undefined)
|
|
161
237
|
.forEach(info => this.importInfoInference.doInfer(info));
|
|
162
238
|
}
|
|
163
239
|
/**
|
|
@@ -196,12 +272,31 @@ class ClassInference extends ArkModelInference {
|
|
|
196
272
|
* @param {ArkClass} arkClass
|
|
197
273
|
*/
|
|
198
274
|
infer(arkClass) {
|
|
199
|
-
arkClass.
|
|
275
|
+
arkClass.forEachMethod(method => {
|
|
200
276
|
this.methodInference.doInfer(method);
|
|
201
|
-
|
|
277
|
+
return true;
|
|
278
|
+
}, true);
|
|
202
279
|
}
|
|
203
280
|
}
|
|
204
281
|
exports.ClassInference = ClassInference;
|
|
282
|
+
/**
|
|
283
|
+
* Shared read-only empty for the no-change path: the worklist consumer indexes
|
|
284
|
+
* impactedStmts unconditionally, so the common unchanged statement skips a per-call branch.
|
|
285
|
+
* Never mutated, never retained.
|
|
286
|
+
*/
|
|
287
|
+
const NO_IMPACTED_STMTS = [];
|
|
288
|
+
/**
|
|
289
|
+
* Shared no-change result. postInfer must keep returning a truthy object even when nothing
|
|
290
|
+
* changed (a falsy result makes the worklist consumer skip the entry), so the common
|
|
291
|
+
* unchanged-stmt case returns this singleton instead of a fresh three-field literal per
|
|
292
|
+
* statement per round. Consumers only read replacedStmts/impactedStmts and never reach
|
|
293
|
+
* oldStmt on this path; the object is never mutated or retained.
|
|
294
|
+
*/
|
|
295
|
+
const EMPTY_INFER_STMT_RESULT = {
|
|
296
|
+
oldStmt: undefined,
|
|
297
|
+
replacedStmts: undefined,
|
|
298
|
+
impactedStmts: NO_IMPACTED_STMTS,
|
|
299
|
+
};
|
|
205
300
|
class MethodInference extends ArkModelInference {
|
|
206
301
|
constructor(stmtInference) {
|
|
207
302
|
super();
|
|
@@ -229,55 +324,73 @@ class MethodInference extends ArkModelInference {
|
|
|
229
324
|
* @returns {InferStmtResult[]} Array of modified or impacted statements during inference
|
|
230
325
|
*/
|
|
231
326
|
infer(method) {
|
|
232
|
-
var _a, _b;
|
|
233
327
|
const modifiedStmts = [];
|
|
234
|
-
// timeout
|
|
235
328
|
const startTime = Date.now();
|
|
236
329
|
// Check for cycle prevention
|
|
237
|
-
|
|
238
|
-
|
|
330
|
+
const visitedMethods = this.callBackVisited;
|
|
331
|
+
if (visitedMethods !== undefined) {
|
|
332
|
+
if (visitedMethods.has(method)) {
|
|
239
333
|
return modifiedStmts;
|
|
240
334
|
}
|
|
241
|
-
|
|
242
|
-
this.callBackVisited.add(method);
|
|
243
|
-
}
|
|
335
|
+
visitedMethods.add(method);
|
|
244
336
|
}
|
|
245
337
|
const body = method.getBody();
|
|
246
338
|
if (!body) {
|
|
247
339
|
return modifiedStmts;
|
|
248
340
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
value.setRef(global);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
const workList = new Set(body.getCfg().getStmts());
|
|
261
|
-
for (let stmt of workList) {
|
|
262
|
-
if (Date.now() - startTime > MethodInference.TIMEOUT_MS) {
|
|
341
|
+
this.resolveUsedGlobals(body, method);
|
|
342
|
+
const workList = body.getCfg().getStmts();
|
|
343
|
+
const tracked = workList.length > 64 ? new Set(workList) : undefined;
|
|
344
|
+
let nextIdx = 0;
|
|
345
|
+
while (nextIdx < workList.length) {
|
|
346
|
+
const stmt = workList[nextIdx++];
|
|
347
|
+
if ((nextIdx & 63) === 1 && Date.now() - startTime > MethodInference.TIMEOUT_MS) {
|
|
263
348
|
logger.error(`Inference timeout for method: ${method.getName()}`);
|
|
264
349
|
return modifiedStmts;
|
|
265
350
|
}
|
|
266
|
-
const
|
|
267
|
-
if (!
|
|
351
|
+
const inferResult = this.stmtInference.doInfer(stmt);
|
|
352
|
+
if (!inferResult) {
|
|
268
353
|
continue;
|
|
269
354
|
}
|
|
270
|
-
const inferResult = result;
|
|
271
|
-
// collect modified Stmts to update CFG
|
|
272
355
|
if (inferResult.replacedStmts) {
|
|
273
356
|
modifiedStmts.push(inferResult);
|
|
274
357
|
}
|
|
275
|
-
|
|
276
|
-
(
|
|
277
|
-
|
|
358
|
+
const impactedStmts = inferResult.impactedStmts;
|
|
359
|
+
for (let i = 0; i < impactedStmts.length; i++) {
|
|
360
|
+
const s = impactedStmts[i];
|
|
361
|
+
if (tracked !== undefined ? tracked.has(s) : workList.includes(s)) {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
tracked === null || tracked === void 0 ? void 0 : tracked.add(s);
|
|
365
|
+
workList.push(s);
|
|
366
|
+
}
|
|
367
|
+
tracked === null || tracked === void 0 ? void 0 : tracked.delete(stmt);
|
|
368
|
+
workList[nextIdx - 1] = null;
|
|
278
369
|
}
|
|
279
370
|
return modifiedStmts;
|
|
280
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Resolves the body's still-unresolved global references before statement inference: when a
|
|
374
|
+
* global name resolves to a local of an outer scope, that local takes over the global's
|
|
375
|
+
* used-statement list and becomes the global's target.
|
|
376
|
+
*/
|
|
377
|
+
resolveUsedGlobals(body, method) {
|
|
378
|
+
const usedGlobals = body.getUsedGlobals();
|
|
379
|
+
if (usedGlobals === undefined) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
for (const key of usedGlobals.keys()) {
|
|
383
|
+
const value = usedGlobals.get(key);
|
|
384
|
+
if (!(value instanceof Ref_1.GlobalRef) || value.getRef()) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const global = ModelUtils_1.ModelUtils.findGlobalRef(key, method);
|
|
388
|
+
if (global instanceof Local_1.Local) {
|
|
389
|
+
mergeGlobalUsedStmts(global, value.getUsedStmts());
|
|
390
|
+
value.setRef(global);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
281
394
|
/**
|
|
282
395
|
* Post-inference phase - updates CFG and infers return type
|
|
283
396
|
* @param {ArkMethod} method - The method that was analyzed
|
|
@@ -312,6 +425,9 @@ MethodInference.TIMEOUT_MS = 3000;
|
|
|
312
425
|
class StmtInference extends ArkModelInference {
|
|
313
426
|
constructor(valueInferences) {
|
|
314
427
|
super();
|
|
428
|
+
this.defAndUsesScratch = [null];
|
|
429
|
+
this.usesPool = [];
|
|
430
|
+
this.valueInferencesByCtor = new Map();
|
|
315
431
|
this.valueInferences = new Map();
|
|
316
432
|
valueInferences.forEach(v => this.valueInferences.set(v.getValueName(), v));
|
|
317
433
|
}
|
|
@@ -323,7 +439,14 @@ class StmtInference extends ArkModelInference {
|
|
|
323
439
|
infer(stmt) {
|
|
324
440
|
var _a;
|
|
325
441
|
const defType = (_a = stmt.getDef()) === null || _a === void 0 ? void 0 : _a.getType();
|
|
326
|
-
|
|
442
|
+
const values = this.defAndUsesScratch;
|
|
443
|
+
while (values.length > 1) {
|
|
444
|
+
values.pop();
|
|
445
|
+
}
|
|
446
|
+
stmt.getDefAndUses(values);
|
|
447
|
+
for (let i = 1; i < values.length; i++) {
|
|
448
|
+
this.inferValue(values[i], stmt);
|
|
449
|
+
}
|
|
327
450
|
return defType;
|
|
328
451
|
}
|
|
329
452
|
/**
|
|
@@ -335,8 +458,8 @@ class StmtInference extends ArkModelInference {
|
|
|
335
458
|
postInfer(stmt, defType) {
|
|
336
459
|
var _a, _b, _c, _d;
|
|
337
460
|
const method = stmt.getCfg().getDeclaringMethod();
|
|
338
|
-
let replacedStmts
|
|
339
|
-
let impactedStmts
|
|
461
|
+
let replacedStmts;
|
|
462
|
+
let impactedStmts;
|
|
340
463
|
if (stmt instanceof Stmt_1.ArkAssignStmt && stmt.getLeftOp() instanceof Expr_1.AbstractInvokeExpr) {
|
|
341
464
|
const invokeExpr = stmt.getLeftOp();
|
|
342
465
|
const cls = method.getDeclaringArkFile().getScene().getClass(invokeExpr.getMethodSignature().getDeclaringClassSignature());
|
|
@@ -357,20 +480,24 @@ class StmtInference extends ArkModelInference {
|
|
|
357
480
|
invokeStmt.setOriginFullPosition(stmt.getOriginFullPosition());
|
|
358
481
|
}
|
|
359
482
|
invokeStmt.metadata = stmt.metadata;
|
|
360
|
-
replacedStmts
|
|
483
|
+
replacedStmts = [invokeStmt];
|
|
361
484
|
}
|
|
362
485
|
else {
|
|
363
486
|
impactedStmts = this.typeSpread(stmt, method);
|
|
364
487
|
}
|
|
365
488
|
const finalDef = stmt.getDef();
|
|
366
|
-
if (defType !== (finalDef === null || finalDef === void 0 ? void 0 : finalDef.getType()) &&
|
|
489
|
+
if (defType !== (finalDef === null || finalDef === void 0 ? void 0 : finalDef.getType()) &&
|
|
490
|
+
finalDef instanceof Local_1.Local &&
|
|
367
491
|
(((_d = (_c = method.getBody()) === null || _c === void 0 ? void 0 : _c.getUsedGlobals()) === null || _d === void 0 ? void 0 : _d.get(finalDef.getName())) || !finalDef.getName().startsWith(Const_1.NAME_PREFIX))) {
|
|
368
|
-
|
|
492
|
+
impactedStmts = this.mergeImpactedStmts(impactedStmts, finalDef.getUsedStmts());
|
|
493
|
+
}
|
|
494
|
+
if (impactedStmts === undefined && replacedStmts === undefined) {
|
|
495
|
+
return EMPTY_INFER_STMT_RESULT;
|
|
369
496
|
}
|
|
370
497
|
return {
|
|
371
498
|
oldStmt: stmt,
|
|
372
|
-
impactedStmts: impactedStmts
|
|
373
|
-
replacedStmts: replacedStmts
|
|
499
|
+
impactedStmts: impactedStmts !== null && impactedStmts !== void 0 ? impactedStmts : NO_IMPACTED_STMTS,
|
|
500
|
+
replacedStmts: replacedStmts,
|
|
374
501
|
};
|
|
375
502
|
}
|
|
376
503
|
/**
|
|
@@ -379,31 +506,82 @@ class StmtInference extends ArkModelInference {
|
|
|
379
506
|
* @param {Stmt} stmt - The containing statement
|
|
380
507
|
* @param {Set<Value>} visited - Set of already visited values for cycle prevention
|
|
381
508
|
*/
|
|
382
|
-
inferValue(value, stmt, visited =
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
509
|
+
inferValue(value, stmt, visited, depth = 0) {
|
|
510
|
+
var _a;
|
|
511
|
+
if (visited !== undefined) {
|
|
512
|
+
if (visited.has(value)) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
387
515
|
visited.add(value);
|
|
388
516
|
}
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
if (
|
|
392
|
-
|
|
517
|
+
const ctor = value.constructor;
|
|
518
|
+
let valueInference = this.valueInferencesByCtor.get(ctor);
|
|
519
|
+
if (valueInference === undefined) {
|
|
520
|
+
valueInference = (_a = this.valueInferences.get(ctor.name)) !== null && _a !== void 0 ? _a : null;
|
|
521
|
+
this.valueInferencesByCtor.set(ctor, valueInference);
|
|
522
|
+
}
|
|
523
|
+
if (valueInference === null) {
|
|
524
|
+
if (logger_1.default.isDebugEnabled(logger)) {
|
|
525
|
+
logger.debug(ctor.name + ' valueInference not found');
|
|
526
|
+
}
|
|
393
527
|
return;
|
|
394
528
|
}
|
|
395
529
|
const type = value.getType();
|
|
396
|
-
|
|
397
|
-
|
|
530
|
+
const owned = visited === undefined;
|
|
531
|
+
let childVisited = visited;
|
|
532
|
+
let prevBase = 0;
|
|
533
|
+
if (owned) {
|
|
534
|
+
prevBase = valueVisitedSeg.enter();
|
|
535
|
+
childVisited = valueVisitedSeg;
|
|
536
|
+
}
|
|
537
|
+
try {
|
|
538
|
+
if (type instanceof TypeExpr_1.AbstractTypeExpr) {
|
|
539
|
+
this.inferSubValues(value, type.getUses(this.acquireUses(depth)), stmt, childVisited, depth);
|
|
540
|
+
}
|
|
541
|
+
this.inferSubValues(value, value.getUses(this.acquireUses(depth)), stmt, childVisited, depth);
|
|
542
|
+
}
|
|
543
|
+
finally {
|
|
544
|
+
if (owned) {
|
|
545
|
+
valueVisitedSeg.leave(prevBase);
|
|
546
|
+
}
|
|
398
547
|
}
|
|
399
|
-
value.getUses().forEach(sub => this.inferValue(sub, stmt, visited));
|
|
400
548
|
valueInference.doInfer(value, stmt);
|
|
401
549
|
}
|
|
550
|
+
inferSubValues(parent, subValues, stmt, visited, depth) {
|
|
551
|
+
const pooled = subValues === this.usesPool[depth];
|
|
552
|
+
if (subValues.length === 0 || (pooled && subValues.length === 1)) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
visited.add(parent);
|
|
556
|
+
const start = pooled ? 1 : 0;
|
|
557
|
+
for (let i = start; i < subValues.length; i++) {
|
|
558
|
+
this.inferValue(subValues[i], stmt, visited, depth + 1);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Per-depth pooled acc for the no-arg getUses default parameter: the default `acc = []`
|
|
563
|
+
* allocated (and push-grew) a fresh array on every inferValue visit. A plain shared
|
|
564
|
+
* scratch would be reset by nested inferValue calls while inferSubValues is still
|
|
565
|
+
* iterating it, so each recursion depth owns a slot. The slot keeps a sentinel at index 0
|
|
566
|
+
* and resets by pop (truncating to 0 would drop the V8 backing store); iteration skips
|
|
567
|
+
* the sentinel via the identity check in inferSubValues.
|
|
568
|
+
*/
|
|
569
|
+
acquireUses(depth) {
|
|
570
|
+
let arr = this.usesPool[depth];
|
|
571
|
+
if (arr === undefined) {
|
|
572
|
+
arr = [null];
|
|
573
|
+
this.usesPool[depth] = arr;
|
|
574
|
+
}
|
|
575
|
+
while (arr.length > 1) {
|
|
576
|
+
arr.pop();
|
|
577
|
+
}
|
|
578
|
+
return arr;
|
|
579
|
+
}
|
|
402
580
|
/**
|
|
403
581
|
* Propagates types through statements and handles special cases
|
|
404
582
|
* @param {Stmt} stmt - The statement to process
|
|
405
583
|
* @param {ArkMethod} method - The containing method
|
|
406
|
-
* @returns {
|
|
584
|
+
* @returns {Stmt[] | undefined} Statements impacted by type propagation, if any
|
|
407
585
|
*/
|
|
408
586
|
typeSpread(stmt, method) {
|
|
409
587
|
var _a;
|
|
@@ -413,17 +591,13 @@ class StmtInference extends ArkModelInference {
|
|
|
413
591
|
if (invokeExpr) {
|
|
414
592
|
impactedStmts = this.paramSpread(invokeExpr, method);
|
|
415
593
|
}
|
|
416
|
-
else {
|
|
417
|
-
impactedStmts = new Set();
|
|
418
|
-
}
|
|
419
594
|
if (stmt instanceof Stmt_1.ArkAssignStmt) {
|
|
420
|
-
this.transferTypeBidirectional(stmt, method, impactedStmts);
|
|
595
|
+
impactedStmts = this.transferTypeBidirectional(stmt, method, impactedStmts);
|
|
421
596
|
}
|
|
422
597
|
else if (stmt instanceof Stmt_1.ArkReturnStmt) {
|
|
423
598
|
// Handle return statements with async type resolution
|
|
424
599
|
let returnType = method.getSignature().getType();
|
|
425
|
-
if (method.containsModifier(ArkBaseModel_1.ModifierType.ASYNC) && returnType instanceof Type_1.ClassType &&
|
|
426
|
-
returnType.getClassSignature().getClassName() === TSConst_1.PROMISE) {
|
|
600
|
+
if (method.containsModifier(ArkBaseModel_1.ModifierType.ASYNC) && returnType instanceof Type_1.ClassType && returnType.getClassSignature().getClassName() === TSConst_1.PROMISE) {
|
|
427
601
|
const realGenericType = (_a = returnType.getRealGenericTypes()) === null || _a === void 0 ? void 0 : _a[0];
|
|
428
602
|
if (realGenericType) {
|
|
429
603
|
returnType = realGenericType;
|
|
@@ -433,21 +607,34 @@ class StmtInference extends ArkModelInference {
|
|
|
433
607
|
}
|
|
434
608
|
return impactedStmts;
|
|
435
609
|
}
|
|
610
|
+
mergeImpactedStmts(target, items) {
|
|
611
|
+
if (items === undefined || items.length === 0) {
|
|
612
|
+
return target;
|
|
613
|
+
}
|
|
614
|
+
if (target === undefined) {
|
|
615
|
+
target = [];
|
|
616
|
+
}
|
|
617
|
+
for (const item of items) {
|
|
618
|
+
if (!target.includes(item)) {
|
|
619
|
+
target.push(item);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return target;
|
|
623
|
+
}
|
|
436
624
|
/**
|
|
437
625
|
* Transfers types bidirectionally in assignment statements
|
|
438
626
|
* @param {ArkAssignStmt} stmt - The assignment statement
|
|
439
627
|
* @param {ArkMethod} method - The containing method
|
|
440
|
-
* @param {
|
|
628
|
+
* @param {Stmt[] | undefined} impactedStmts - Statements collected so far, if any
|
|
441
629
|
*/
|
|
442
630
|
transferTypeBidirectional(stmt, method, impactedStmts) {
|
|
443
|
-
var _a, _b;
|
|
444
631
|
const rightType = stmt.getRightOp().getType();
|
|
445
632
|
const leftOp = stmt.getLeftOp();
|
|
446
633
|
let leftType = leftOp.getType();
|
|
447
634
|
// Transfer type from left to right operand
|
|
448
|
-
|
|
635
|
+
impactedStmts = this.mergeImpactedStmts(impactedStmts, this.transferLeft2Right(stmt.getRightOp(), leftType, method));
|
|
449
636
|
// Transfer type from right to left operand
|
|
450
|
-
|
|
637
|
+
impactedStmts = this.mergeImpactedStmts(impactedStmts, this.transferRight2Left(leftOp, rightType, method));
|
|
451
638
|
// Handle global this references
|
|
452
639
|
if (leftOp instanceof Ref_1.ArkStaticFieldRef) {
|
|
453
640
|
const declaringSignature = leftOp.getFieldSignature().getDeclaringSignature();
|
|
@@ -455,11 +642,13 @@ class StmtInference extends ArkModelInference {
|
|
|
455
642
|
SdkUtils_1.SdkUtils.computeGlobalThis(leftOp, method);
|
|
456
643
|
}
|
|
457
644
|
}
|
|
645
|
+
return impactedStmts;
|
|
458
646
|
}
|
|
459
647
|
transferLeft2Right(rightOp, leftType, method) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
648
|
+
if (TypeInference_1.TypeInference.isUnclearType(leftType)) {
|
|
649
|
+
return undefined;
|
|
650
|
+
}
|
|
651
|
+
if (TypeInference_1.TypeInference.isAnonType(leftType, method.getDeclaringArkFile().getProjectName())) {
|
|
463
652
|
return undefined;
|
|
464
653
|
}
|
|
465
654
|
const rightType = rightOp.getType();
|
|
@@ -467,7 +656,7 @@ class StmtInference extends ArkModelInference {
|
|
|
467
656
|
return this.updateValueType(rightOp, leftType, method);
|
|
468
657
|
}
|
|
469
658
|
transferRight2Left(leftOp, rightType, method) {
|
|
470
|
-
if (TypeInference_1.TypeInference.isUnclearType(rightType)) {
|
|
659
|
+
if (TypeInference_1.TypeInference.isUnclearType(rightType) || rightType instanceof Type_1.UndefinedType || rightType instanceof Type_1.NullType) {
|
|
471
660
|
return undefined;
|
|
472
661
|
}
|
|
473
662
|
return this.updateValueType(leftOp, rightType, method);
|
|
@@ -481,7 +670,7 @@ class StmtInference extends ArkModelInference {
|
|
|
481
670
|
*/
|
|
482
671
|
updateValueType(target, srcType, method) {
|
|
483
672
|
const type = target.getType();
|
|
484
|
-
if (type !== srcType && TypeInference_1.TypeInference.isUnclearType(type)) {
|
|
673
|
+
if (type !== srcType && (TypeInference_1.TypeInference.isUnclearType(type) || type instanceof Type_1.UndefinedType || type instanceof Type_1.NullType)) {
|
|
485
674
|
if (target instanceof Local_1.Local) {
|
|
486
675
|
target.setType(srcType);
|
|
487
676
|
return target.getUsedStmts();
|
|
@@ -502,12 +691,17 @@ class StmtInference extends ArkModelInference {
|
|
|
502
691
|
* @returns {Set<Stmt>} Set of statements impacted by parameter type propagation
|
|
503
692
|
*/
|
|
504
693
|
paramSpread(invokeExpr, method) {
|
|
505
|
-
var _a;
|
|
506
694
|
const realTypes = [];
|
|
507
|
-
|
|
695
|
+
let result;
|
|
508
696
|
const len = invokeExpr.getArgs().length;
|
|
509
|
-
const
|
|
510
|
-
|
|
697
|
+
const declaredParameters = invokeExpr.getMethodSignature().getMethodSubSignature().getParameters();
|
|
698
|
+
let parameters = declaredParameters;
|
|
699
|
+
for (let i = 0; i < declaredParameters.length; i++) {
|
|
700
|
+
if (declaredParameters[i].getName().startsWith(Const_1.LEXICAL_ENV_NAME_PREFIX)) {
|
|
701
|
+
parameters = declaredParameters.filter(p => !p.getName().startsWith(Const_1.LEXICAL_ENV_NAME_PREFIX));
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
511
705
|
// Map arguments to parameters
|
|
512
706
|
for (let index = 0; index < len; index++) {
|
|
513
707
|
const arg = invokeExpr.getArg(index);
|
|
@@ -515,7 +709,7 @@ class StmtInference extends ArkModelInference {
|
|
|
515
709
|
break;
|
|
516
710
|
}
|
|
517
711
|
const paramType = parameters[index].getType();
|
|
518
|
-
|
|
712
|
+
result = this.mergeImpactedStmts(result, this.mapArgWithParam(arg, paramType, invokeExpr, method, realTypes));
|
|
519
713
|
}
|
|
520
714
|
// Set real generic types for the invocation
|
|
521
715
|
if (realTypes.length > 0 && !invokeExpr.getRealGenericTypes()) {
|
|
@@ -159,10 +159,9 @@ export declare class InstanceInvokeExprInference extends ValueInference<ArkInsta
|
|
|
159
159
|
infer(value: ArkInstanceInvokeExpr, stmt: Stmt): Value | undefined;
|
|
160
160
|
/**
|
|
161
161
|
* Performs post-inference processing on invocation expressions
|
|
162
|
-
* Handles special case for super() calls by replacing the base with 'this' local
|
|
163
162
|
* @param {ArkInstanceInvokeExpr} value - The original invocation expression
|
|
164
163
|
* @param {Value} newValue - The new value after inference
|
|
165
|
-
* @param {Stmt} stmt - The statement containing the
|
|
164
|
+
* @param {Stmt} stmt - The statement containing the expression
|
|
166
165
|
*/
|
|
167
166
|
postInfer(value: ArkInstanceInvokeExpr, newValue: Value, stmt: Stmt): void;
|
|
168
167
|
getMethodName(expr: AbstractInvokeExpr, arkMethod: ArkMethod): string;
|
|
@@ -172,6 +171,8 @@ export declare class StaticInvokeExprInference extends InstanceInvokeExprInferen
|
|
|
172
171
|
getValueName(): string;
|
|
173
172
|
infer(expr: ArkStaticInvokeExpr, stmt: Stmt): Value | undefined;
|
|
174
173
|
protected getBaseType(expr: ArkStaticInvokeExpr, arkMethod: ArkMethod): Type | null;
|
|
174
|
+
/** Multi-candidate variant of {@link getBaseType} (same-name global entities expanded). */
|
|
175
|
+
protected getBaseTypes(expr: ArkStaticInvokeExpr, arkMethod: ArkMethod): Type[];
|
|
175
176
|
}
|
|
176
177
|
export declare class ArkPtrInvokeExprInference extends StaticInvokeExprInference {
|
|
177
178
|
getValueName(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValueInference.d.ts","sourceRoot":"","sources":["../../../src/core/inference/ValueInference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ValueInference.d.ts","sourceRoot":"","sources":["../../../src/core/inference/ValueInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAiB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