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
|
@@ -46,6 +46,7 @@ var InstanceInvokeExprInference_1;
|
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
47
|
exports.LocalInference = exports.ArkCastExprInference = exports.ArkInstanceOfExprInference = exports.ArkConditionExprInference = exports.ArkNormalBinOpExprInference = exports.ArkNewArrayExprInference = exports.ArkNewExprInference = exports.ArkPtrInvokeExprInference = exports.StaticInvokeExprInference = exports.InstanceInvokeExprInference = exports.StaticFieldRefInference = exports.FieldRefInference = exports.ClosureFieldRefInference = exports.ParameterRefInference = exports.ValueInference = exports.Bind = exports.valueCtors = exports.InferLanguage = void 0;
|
|
48
48
|
const Stmt_1 = require("../base/Stmt");
|
|
49
|
+
const SdkUtils_1 = require("../common/SdkUtils");
|
|
49
50
|
const Type_1 = require("../base/Type");
|
|
50
51
|
const TypeInference_1 = require("../common/TypeInference");
|
|
51
52
|
const IRInference_1 = require("../common/IRInference");
|
|
@@ -189,7 +190,9 @@ let ClosureFieldRefInference = class ClosureFieldRefInference extends ValueInfer
|
|
|
189
190
|
var _a;
|
|
190
191
|
const type = value.getBase().getType();
|
|
191
192
|
if (type instanceof Type_1.LexicalEnvType) {
|
|
192
|
-
let newType = (_a = type
|
|
193
|
+
let newType = (_a = type
|
|
194
|
+
.getClosures()
|
|
195
|
+
.find(c => c.getName() === value.getFieldName())) === null || _a === void 0 ? void 0 : _a.getType();
|
|
193
196
|
if (newType && !TypeInference_1.TypeInference.isUnclearType(newType)) {
|
|
194
197
|
value.setType(newType);
|
|
195
198
|
}
|
|
@@ -213,8 +216,9 @@ let FieldRefInference = class FieldRefInference extends ValueInference {
|
|
|
213
216
|
* @returns {boolean} True if pre-inference should be performed, false otherwise
|
|
214
217
|
*/
|
|
215
218
|
preInfer(value, stmt) {
|
|
216
|
-
return IRInference_1.IRInference.needInfer(value.getFieldSignature().getDeclaringSignature().getDeclaringFileSignature()) ||
|
|
217
|
-
TypeInference_1.TypeInference.isUnclearType(value.getType()) ||
|
|
219
|
+
return (IRInference_1.IRInference.needInfer(value.getFieldSignature().getDeclaringSignature().getDeclaringFileSignature()) ||
|
|
220
|
+
TypeInference_1.TypeInference.isUnclearType(value.getType()) ||
|
|
221
|
+
value.getFieldSignature().isStatic());
|
|
218
222
|
}
|
|
219
223
|
/**
|
|
220
224
|
* Performs inference on a field reference within the context of a statement
|
|
@@ -248,8 +252,7 @@ let StaticFieldRefInference = class StaticFieldRefInference extends ValueInferen
|
|
|
248
252
|
* @returns {boolean} True if pre-inference should be performed, false otherwise
|
|
249
253
|
*/
|
|
250
254
|
preInfer(value, stmt) {
|
|
251
|
-
return IRInference_1.IRInference.needInfer(value.getFieldSignature().getDeclaringSignature().getDeclaringFileSignature()) ||
|
|
252
|
-
TypeInference_1.TypeInference.isUnclearType(value.getType());
|
|
255
|
+
return (IRInference_1.IRInference.needInfer(value.getFieldSignature().getDeclaringSignature().getDeclaringFileSignature()) || TypeInference_1.TypeInference.isUnclearType(value.getType()));
|
|
253
256
|
}
|
|
254
257
|
/**
|
|
255
258
|
* Performs inference on a static field reference within the context of a statement
|
|
@@ -262,12 +265,14 @@ let StaticFieldRefInference = class StaticFieldRefInference extends ValueInferen
|
|
|
262
265
|
const baseSignature = value.getFieldSignature().getDeclaringSignature();
|
|
263
266
|
const baseName = baseSignature instanceof ArkSignature_1.ClassSignature ? baseSignature.getClassName() : baseSignature.getNamespaceName();
|
|
264
267
|
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
+
// Multi-candidate probing: same-name global entities are probed in order until the member resolves.
|
|
269
|
+
for (const baseType of TypeInference_1.TypeInference.inferBaseTypes(baseName, arkMethod.getDeclaringArkClass())) {
|
|
270
|
+
const result = IRInference_1.IRInference.inferInstanceMember(baseType, value, arkMethod, IRInference_1.IRInference.updateRefSignature);
|
|
271
|
+
if (result) {
|
|
272
|
+
return result === value ? undefined : result;
|
|
273
|
+
}
|
|
268
274
|
}
|
|
269
|
-
|
|
270
|
-
return !result || result === value ? undefined : result;
|
|
275
|
+
return undefined;
|
|
271
276
|
}
|
|
272
277
|
};
|
|
273
278
|
StaticFieldRefInference = __decorate([
|
|
@@ -286,8 +291,8 @@ let InstanceInvokeExprInference = InstanceInvokeExprInference_1 = class Instance
|
|
|
286
291
|
* @returns {boolean} True if pre-inference should be performed, false otherwise
|
|
287
292
|
*/
|
|
288
293
|
preInfer(value, stmt) {
|
|
289
|
-
return IRInference_1.IRInference.needInfer(value.getMethodSignature().getDeclaringClassSignature().getDeclaringFileSignature()) ||
|
|
290
|
-
TypeInference_1.TypeInference.isUnclearType(value.getType());
|
|
294
|
+
return (IRInference_1.IRInference.needInfer(value.getMethodSignature().getDeclaringClassSignature().getDeclaringFileSignature()) ||
|
|
295
|
+
TypeInference_1.TypeInference.isUnclearType(value.getType()));
|
|
291
296
|
}
|
|
292
297
|
/**
|
|
293
298
|
* Performs inference on an instance invocation expression within the context of a statement
|
|
@@ -300,24 +305,24 @@ let InstanceInvokeExprInference = InstanceInvokeExprInference_1 = class Instance
|
|
|
300
305
|
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
301
306
|
const baseType = TypeInference_1.TypeInference.inferRefinedValueType(value.getBase(), arkMethod.getDeclaringArkFile().getScene());
|
|
302
307
|
const result = IRInference_1.IRInference.inferInstanceMember(baseType, value, arkMethod, InstanceInvokeExprInference_1.inferInvokeExpr);
|
|
308
|
+
if (result === value) {
|
|
309
|
+
// isStatic 形态升级防御:签名已解析为 static 但 expr 停留 instance 形态的残余在此收敛——正常升级依赖 inferInvokeExpr 族返回替换 expr
|
|
310
|
+
// (invokeMatchedMethod 的 isStatic 分支),物化跟随/推导短路等场景可能就地 set 了 static 签名却未换形态(OperandOriginalPositions 实证)。
|
|
311
|
+
// base 为 super 时保持 instance(super.staticM() 的 postInfer base 替换语义优先,staticinvoke 丢弃 receiver 虽语义等价但保守排除)。
|
|
312
|
+
const sig = value.getMethodSignature();
|
|
313
|
+
if (sig.getMethodSubSignature().isStatic() && value.getBase().getName() !== TSConst_1.SUPER_NAME) {
|
|
314
|
+
return new Expr_1.ArkStaticInvokeExpr(sig, value.getArgs(), value.getRealGenericTypes(), value.getSpreadFlags());
|
|
315
|
+
}
|
|
316
|
+
}
|
|
303
317
|
return !result || result === value ? undefined : result;
|
|
304
318
|
}
|
|
305
319
|
/**
|
|
306
320
|
* Performs post-inference processing on invocation expressions
|
|
307
|
-
* Handles special case for super() calls by replacing the base with 'this' local
|
|
308
321
|
* @param {ArkInstanceInvokeExpr} value - The original invocation expression
|
|
309
322
|
* @param {Value} newValue - The new value after inference
|
|
310
|
-
* @param {Stmt} stmt - The statement containing the
|
|
323
|
+
* @param {Stmt} stmt - The statement containing the expression
|
|
311
324
|
*/
|
|
312
325
|
postInfer(value, newValue, stmt) {
|
|
313
|
-
var _a;
|
|
314
|
-
if (value instanceof Expr_1.ArkInstanceInvokeExpr && value.getBase().getName() === TSConst_1.SUPER_NAME) {
|
|
315
|
-
const thisLocal = (_a = stmt.getCfg().getDeclaringMethod().getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().get(TSConst_1.THIS_NAME);
|
|
316
|
-
if (thisLocal) {
|
|
317
|
-
value.setBase(thisLocal);
|
|
318
|
-
thisLocal.addUsedStmt(stmt);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
326
|
super.postInfer(value, newValue, stmt);
|
|
322
327
|
}
|
|
323
328
|
getMethodName(expr, arkMethod) {
|
|
@@ -327,7 +332,7 @@ let InstanceInvokeExprInference = InstanceInvokeExprInference_1 = class Instance
|
|
|
327
332
|
const methodName = expr.getMethodSignature().getMethodSubSignature().getMethodName();
|
|
328
333
|
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
329
334
|
if (baseType instanceof Type_1.ArrayType || baseType instanceof Type_1.TupleType) {
|
|
330
|
-
const arrayInterface =
|
|
335
|
+
const arrayInterface = SdkUtils_1.SdkUtils.getSdkGlobal(Builtin_1.Builtin.ARRAY);
|
|
331
336
|
const realTypes = baseType instanceof Type_1.ArrayType ? [baseType.getBaseType()] : undefined;
|
|
332
337
|
if (arrayInterface instanceof ArkClass_1.ArkClass) {
|
|
333
338
|
baseType = new Type_1.ClassType(arrayInterface.getSignature(), realTypes);
|
|
@@ -345,7 +350,8 @@ let InstanceInvokeExprInference = InstanceInvokeExprInference_1 = class Instance
|
|
|
345
350
|
else if (baseType instanceof Type_1.AnnotationNamespaceType) {
|
|
346
351
|
const namespace = scene.getNamespace(baseType.getNamespaceSignature());
|
|
347
352
|
if (namespace) {
|
|
348
|
-
|
|
353
|
+
// 多实体探测:跨文件同名 ns(Intl 系)的后续文件实体持有该文件声明的成员
|
|
354
|
+
const foundMethod = ModelUtils_1.ModelUtils.findPropertyInNamespaces(methodName, namespace);
|
|
349
355
|
if (foundMethod instanceof ArkMethod_1.ArkMethod) {
|
|
350
356
|
let signature = foundMethod.matchMethodSignature(expr.getArgs());
|
|
351
357
|
TypeInference_1.TypeInference.inferSignatureReturnType(signature, foundMethod);
|
|
@@ -391,12 +397,21 @@ let StaticInvokeExprInference = class StaticInvokeExprInference extends Instance
|
|
|
391
397
|
}
|
|
392
398
|
return undefined;
|
|
393
399
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
+
// Multi-candidate probing: same-name global entities are probed in order until the invoke resolves;
|
|
401
|
+
// the by-name fallback chain runs only when no candidate exists at all.
|
|
402
|
+
const baseTypes = this.getBaseTypes(expr, arkMethod);
|
|
403
|
+
if (baseTypes.length > 0) {
|
|
404
|
+
for (const baseType of baseTypes) {
|
|
405
|
+
const result = IRInference_1.IRInference.inferInstanceMember(baseType, expr, arkMethod, InstanceInvokeExprInference.inferInvokeExpr);
|
|
406
|
+
if (result) {
|
|
407
|
+
return result === expr ? undefined : result;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
return arkMethod.getDeclaringArkFile().getLanguage() === ArkFile_1.Language.CXX
|
|
413
|
+
? IRInference_2.IRInference.inferStaticInvokeExprByMethodName(methodName, arkMethod, expr)
|
|
414
|
+
: IRInference_1.IRInference.inferStaticInvokeExprByMethodName(methodName, arkMethod, expr);
|
|
400
415
|
}
|
|
401
416
|
getBaseType(expr, arkMethod) {
|
|
402
417
|
const className = expr.getMethodSignature().getDeclaringClassSignature().getClassName();
|
|
@@ -405,6 +420,14 @@ let StaticInvokeExprInference = class StaticInvokeExprInference extends Instance
|
|
|
405
420
|
}
|
|
406
421
|
return null;
|
|
407
422
|
}
|
|
423
|
+
/** Multi-candidate variant of {@link getBaseType} (same-name global entities expanded). */
|
|
424
|
+
getBaseTypes(expr, arkMethod) {
|
|
425
|
+
const className = expr.getMethodSignature().getDeclaringClassSignature().getClassName();
|
|
426
|
+
if (className && className !== Const_1.UNKNOWN_CLASS_NAME) {
|
|
427
|
+
return TypeInference_1.TypeInference.inferBaseTypes(className, arkMethod.getDeclaringArkClass());
|
|
428
|
+
}
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
408
431
|
};
|
|
409
432
|
StaticInvokeExprInference = __decorate([
|
|
410
433
|
Bind()
|
|
@@ -457,12 +480,20 @@ let ArkNewExprInference = class ArkNewExprInference extends ValueInference {
|
|
|
457
480
|
return IRInference_1.IRInference.needInfer(value.getClassType().getClassSignature().getDeclaringFileSignature());
|
|
458
481
|
}
|
|
459
482
|
infer(value, stmt) {
|
|
460
|
-
var _a;
|
|
483
|
+
var _a, _b, _c;
|
|
461
484
|
const className = value.getClassType().getClassSignature().getClassName();
|
|
462
485
|
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
463
|
-
let type =
|
|
486
|
+
let type = ModelUtils_1.ModelUtils.findDeclaredLocalType(className, arkMethod, 1);
|
|
487
|
+
if (TypeInference_1.TypeInference.isUnclearType(type)) {
|
|
488
|
+
// Deterministic local-class resolution along the method scope chain before
|
|
489
|
+
// the file-level fuzzy name search.
|
|
490
|
+
const localClass = ModelUtils_1.ModelUtils.findLocalClassInMethodChain(className, arkMethod);
|
|
491
|
+
if (localClass) {
|
|
492
|
+
type = new Type_1.ClassType(localClass.getSignature());
|
|
493
|
+
}
|
|
494
|
+
}
|
|
464
495
|
if (TypeInference_1.TypeInference.isUnclearType(type)) {
|
|
465
|
-
type = TypeInference_1.TypeInference.inferUnclearRefName(className, arkMethod.getDeclaringArkClass());
|
|
496
|
+
type = TypeInference_1.TypeInference.inferUnclearRefName(className, arkMethod.getDeclaringArkClass(), arkMethod);
|
|
466
497
|
}
|
|
467
498
|
if (type instanceof Type_1.AliasType) {
|
|
468
499
|
const originType = TypeInference_1.TypeInference.replaceAliasType(type);
|
|
@@ -473,10 +504,27 @@ let ArkNewExprInference = class ArkNewExprInference extends ValueInference {
|
|
|
473
504
|
type = originType;
|
|
474
505
|
}
|
|
475
506
|
}
|
|
476
|
-
if (type
|
|
477
|
-
|
|
478
|
-
|
|
507
|
+
if (!(type instanceof Type_1.ClassType)) {
|
|
508
|
+
return undefined;
|
|
509
|
+
}
|
|
510
|
+
// 构造器对象升级:type 解析为构造器持有类(ns 内 declare const 的 %AC 字面量类——如 Intl.NumberFormat,或顶层 Constructor interface)时,
|
|
511
|
+
// `new` 的实例类型 = construct-signature(或 call)返回类型——对齐 Expr.ArkNewExpr.inferType 的 constructorSignature 升级链。
|
|
512
|
+
// 顶层场景原靠后续赋值传播兜底(%0 初始 unclear 可覆盖);
|
|
513
|
+
// ns 内 %AC 场景类型构建期已明确,narrowing 哲学下传播不覆盖,必须在此显式升级。
|
|
514
|
+
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
515
|
+
let instanceType = type;
|
|
516
|
+
const typeClass = scene.getClass(type.getClassSignature());
|
|
517
|
+
if (typeClass) {
|
|
518
|
+
const ctorReturn = (_b = (_a = typeClass.getMethodWithName(Const_1.CONSTRUCT_SIGNATURE_NAME)) === null || _a === void 0 ? void 0 : _a.getReturnType()) !== null && _b !== void 0 ? _b : (_c = typeClass.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) === null || _c === void 0 ? void 0 : _c.getReturnType();
|
|
519
|
+
if (ctorReturn) {
|
|
520
|
+
const replaced = TypeInference_1.TypeInference.replaceAliasType(ctorReturn);
|
|
521
|
+
if (replaced instanceof Type_1.ClassType) {
|
|
522
|
+
instanceType = replaced;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
479
525
|
}
|
|
526
|
+
value.getClassType().setClassSignature(instanceType.getClassSignature());
|
|
527
|
+
TypeInference_1.TypeInference.inferRealGenericTypes(value.getClassType().getRealGenericTypes(), arkMethod.getDeclaringArkClass());
|
|
480
528
|
return undefined;
|
|
481
529
|
}
|
|
482
530
|
};
|
|
@@ -645,12 +693,14 @@ let LocalInference = class LocalInference extends ValueInference {
|
|
|
645
693
|
return 'Local';
|
|
646
694
|
}
|
|
647
695
|
preInfer(value) {
|
|
648
|
-
|
|
696
|
+
const type = value.getType();
|
|
697
|
+
return TypeInference_1.TypeInference.isUnclearType(type) || type instanceof Type_1.UndefinedType || type instanceof Type_1.NullType;
|
|
649
698
|
}
|
|
650
699
|
infer(value, stmt) {
|
|
651
|
-
var _a
|
|
700
|
+
var _a;
|
|
652
701
|
const name = value.getName();
|
|
653
|
-
const
|
|
702
|
+
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
703
|
+
const arkClass = arkMethod.getDeclaringArkClass();
|
|
654
704
|
// Special handling for 'this' reference - set to current class type
|
|
655
705
|
if (name === TSConst_1.THIS_NAME) {
|
|
656
706
|
value.setType(new Type_1.ClassType(arkClass.getSignature(), arkClass.getRealTypes()));
|
|
@@ -659,7 +709,7 @@ let LocalInference = class LocalInference extends ValueInference {
|
|
|
659
709
|
let newType;
|
|
660
710
|
// Skip temporary variables (those with name prefix) and look for declared locals
|
|
661
711
|
if (!name.startsWith(Const_1.NAME_PREFIX)) {
|
|
662
|
-
newType = (
|
|
712
|
+
newType = (_a = ModelUtils_1.ModelUtils.findDeclaredLocalType(name, arkMethod, 1)) !== null && _a !== void 0 ? _a : TypeInference_1.TypeInference.inferBaseType(name, arkClass);
|
|
663
713
|
}
|
|
664
714
|
if (newType) {
|
|
665
715
|
value.setType(newType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbcInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/abc/AbcInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGxF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"AbcInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/abc/AbcInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGxF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAQ,iBAAiB,EAAiB,2BAA2B,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAoB,qBAAqB,EAAE,mBAAmB,EAA8B,MAAM,gBAAgB,CAAC;AAI1H,OAAO,EAAsB,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AA6B5E,qBAAa,kBAAmB,SAAQ,eAAe;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAO3C,OAAO,CAAC,kCAAkC;CA8B7C;AA4ED,qBAAa,mBAAoB,SAAQ,gBAAgB;IAC9C,wBAAwB,IAAI,mBAAmB;IAI/C,oBAAoB,IAAI,eAAe;IAIvC,kBAAkB,IAAI,aAAa;CAK7C;AAED,qBACa,oBAAqB,SAAQ,iBAAiB;IAChD,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;IAgBzD,KAAK,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;CAmB1E;AAED,qBACa,8BAA+B,SAAQ,2BAA2B;IAC3E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAa;IAE5C;;;;;;OAMG;IACI,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;IASzE;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;CAkB5B;AAED,qBACa,wBAAyB,SAAQ,cAAc,CAAC,qBAAqB,CAAC;IAC/E,OAAO,CAAC,MAAM,CAAC,UAAU,CAA0B;IAE5C,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;IAI3D,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;CA4B5E"}
|
|
@@ -168,8 +168,8 @@ class AbcStmtInference extends ModelInference_1.StmtInference {
|
|
|
168
168
|
target.setType(srcType);
|
|
169
169
|
return target.getUsedStmts();
|
|
170
170
|
}
|
|
171
|
-
else if (target instanceof Ref_1.AbstractFieldRef &&
|
|
172
|
-
.getDeclaringFileSignature().getProjectName()) {
|
|
171
|
+
else if (target instanceof Ref_1.AbstractFieldRef &&
|
|
172
|
+
projectName === target.getFieldSignature().getDeclaringSignature().getDeclaringFileSignature().getProjectName()) {
|
|
173
173
|
target.getFieldSignature().setType(srcType);
|
|
174
174
|
}
|
|
175
175
|
else if (target instanceof Ref_1.ArkParameterRef) {
|
|
@@ -220,12 +220,12 @@ let AbcFieldRefInference = class AbcFieldRefInference extends ValueInference_1.F
|
|
|
220
220
|
if (signature instanceof ArkSignature_1.ClassSignature && signature.getDeclaringFileSignature().getProjectName() === scene.getProjectName()) {
|
|
221
221
|
const cls = scene.getClass(signature);
|
|
222
222
|
if (cls) {
|
|
223
|
-
const field = new ArkField_1.ArkField();
|
|
224
|
-
|
|
225
|
-
const fieldSignature = new ArkSignature_1.FieldSignature(value.getFieldSignature().getFieldName(), cls.getSignature(), Type_1.UnknownType.getInstance());
|
|
223
|
+
const field = new ArkField_1.ArkField(cls.getClassSigID());
|
|
224
|
+
const fieldSignature = new ArkSignature_1.FieldSignature(value.getFieldSignature().getFieldName(), cls.getClassSigID(), Type_1.UnknownType.getInstance());
|
|
226
225
|
field.setSignature(fieldSignature);
|
|
227
226
|
cls.addField(field);
|
|
228
|
-
|
|
227
|
+
// 终点确定,graduateToFormal 直达。
|
|
228
|
+
value.graduateToFormal(field.getFieldSigID());
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
}
|
|
@@ -260,7 +260,7 @@ let AbcInstanceInvokeExprInference = AbcInstanceInvokeExprInference_1 = class Ab
|
|
|
260
260
|
var _a, _b;
|
|
261
261
|
if (value.getBase().getName() === AbcInstanceInvokeExprInference_1.CONTEXT) {
|
|
262
262
|
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
263
|
-
const signature = (_a =
|
|
263
|
+
const signature = (_a = SdkUtils_1.SdkUtils.getSdkGlobal(AbcInstanceInvokeExprInference_1.CONTEXT)) === null || _a === void 0 ? void 0 : _a.getSignature();
|
|
264
264
|
if (signature instanceof ArkSignature_1.AliasTypeSignature) {
|
|
265
265
|
const cls = (_b = scene.getMethod(signature.getDeclaringMethodSignature())) === null || _b === void 0 ? void 0 : _b.getDeclaringArkClass();
|
|
266
266
|
if (cls) {
|
|
@@ -284,16 +284,29 @@ let AbcExceptionRefInference = AbcExceptionRefInference_1 = class AbcExceptionRe
|
|
|
284
284
|
return TypeInference_1.TypeInference.isUnclearType(value.getType());
|
|
285
285
|
}
|
|
286
286
|
infer(value, stmt) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
287
|
+
if (AbcExceptionRefInference_1.ERROR_TYPE) {
|
|
288
|
+
value.setType(AbcExceptionRefInference_1.ERROR_TYPE);
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
const scene = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile().getScene();
|
|
292
|
+
const errFile = scene.getSdkArkFiles().find(e => e.getName().endsWith(EtsConst_1.OHOS_BASE_FILE));
|
|
293
|
+
if (!errFile) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
// 签名直查:file 顶层 → 各 namespace(与 getClassWithName 的递归顺序一致),
|
|
297
|
+
// 免线性扫描与前缀模糊匹配
|
|
298
|
+
let err = null;
|
|
299
|
+
err = errFile.getClass(new ArkSignature_1.ClassSignature(EtsConst_1.BUSINESS_ERROR, errFile.getFileSigID()));
|
|
300
|
+
if (!err) {
|
|
301
|
+
for (const ns of errFile.getAllNamespacesUnderThisFile()) {
|
|
302
|
+
err = ns.getClass(new ArkSignature_1.ClassSignature(EtsConst_1.BUSINESS_ERROR, ns.getDeclaringFileID(), ns.getNamespaceSigID()));
|
|
303
|
+
if (err) {
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
294
306
|
}
|
|
295
307
|
}
|
|
296
|
-
|
|
308
|
+
if (err instanceof ArkClass_1.ArkClass) {
|
|
309
|
+
AbcExceptionRefInference_1.ERROR_TYPE = new Type_1.ClassType(err.getSignature(), err.getGenericsTypes());
|
|
297
310
|
value.setType(AbcExceptionRefInference_1.ERROR_TYPE);
|
|
298
311
|
}
|
|
299
312
|
return undefined;
|
|
@@ -10,7 +10,7 @@ import { Local } from '../../base/Local';
|
|
|
10
10
|
import { AliasTypeExpr, ArkInstanceInvokeExpr } from '../../base/Expr';
|
|
11
11
|
export declare class ArkTsStmtInference extends StmtInference {
|
|
12
12
|
constructor(valueInferences: ValueInference<Value>[]);
|
|
13
|
-
typeSpread(stmt: Stmt, method: ArkMethod):
|
|
13
|
+
typeSpread(stmt: Stmt, method: ArkMethod): Stmt[] | undefined;
|
|
14
14
|
transferRight2Left(leftOp: Value, rightType: Type, method: ArkMethod): Stmt[] | undefined;
|
|
15
15
|
static updateUnionType(target: Value, srcType: Type, method: ArkMethod): Stmt[] | undefined;
|
|
16
16
|
static updateGlobalRef(ref: Value | null, srcType: Type): Stmt[] | undefined;
|
|
@@ -32,10 +32,16 @@ export declare class ArkTSFieldRefInference extends FieldRefInference {
|
|
|
32
32
|
preInfer(value: ArkInstanceFieldRef, stmt: Stmt): boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Checks if a value represents an anonymous class 'this' field reference
|
|
35
|
-
* Identifies field references that access fields directly on 'this' in
|
|
35
|
+
* Identifies field references that access fields directly on 'this' in the AC's
|
|
36
|
+
* %instInit — the carrier of field-initializer expressions, where `this` lexically
|
|
37
|
+
* means the ENCLOSING this (rebound to the host class by inferThisLocal), so def-side
|
|
38
|
+
* member resolution against the AC would only degrade. The AC's own constructors keep
|
|
39
|
+
* the build-time this (ClassType(AC), see the this-semantic guards in
|
|
40
|
+
* ArkTSLocalInference.infer / IRInference.inferBase) and their def-side resolution
|
|
41
|
+
* must NOT be skipped — skipping it left build-time probe stubs permanently uncorrected.
|
|
36
42
|
* @param {Value} stmtDef - The value to check (typically a field reference)
|
|
37
43
|
* @param {ArkMethod} arkMethod - The method containing the value
|
|
38
|
-
* @returns {boolean} True if the value is an anonymous class 'this' field reference
|
|
44
|
+
* @returns {boolean} True if the value is an anonymous class %instInit 'this' field reference
|
|
39
45
|
*/
|
|
40
46
|
private isAnonClassThisRef;
|
|
41
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkTsInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/arkts/ArkTsInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKxG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"ArkTsInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/arkts/ArkTsInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKxG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAQ,iBAAiB,EAAiB,2BAA2B,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxI,OAAO,EAA0B,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAA2D,IAAI,EAAiB,MAAM,iBAAiB,CAAC;AAC/G,OAAO,EAAoB,mBAAmB,EAA8B,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKzC,OAAO,EAAsB,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAmD3F,qBAAa,kBAAmB,SAAQ,aAAa;gBACrC,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE;IAI7C,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,SAAS;IAU7D,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,SAAS;WAwBlF,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,SAAS;WAiBpF,eAAe,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS;CAatF;AAED,qBAAa,qBAAsB,SAAQ,gBAAgB;IAChD,wBAAwB,IAAI,mBAAmB;IAI/C,mBAAmB,IAAI,cAAc;IAIrC,oBAAoB,IAAI,eAAe;IAIvC,kBAAkB,IAAI,aAAa;CAK7C;AAED,qBAAa,sBAAuB,SAAQ,qBAAqB;CAAG;AAEpE,qBAAa,kBAAmB,SAAQ,gBAAgB;IAC7C,wBAAwB,IAAI,mBAAmB;IAI/C,oBAAoB,IAAI,eAAe;IAIvC,kBAAkB,IAAI,aAAa;CAI7C;AAED,qBACa,sBAAuB,SAAQ,iBAAiB;IAClD,QAAQ,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;IAOhE;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,kBAAkB;CAS7B;AAED,qBACa,gCAAiC,SAAQ,2BAA2B;IAC7E;;;;;;OAMG;IACI,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;IAUzE;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAS5B;AAED,qBACa,sBAAuB,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC9D,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAIvC,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;CAwCpE;AAED,qBACa,mBAAoB,SAAQ,cAAc;IAC5C,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAU/B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS;IA4CzD,OAAO,CAAC,YAAY;CASvB"}
|
|
@@ -52,7 +52,8 @@ class ArkTsClassInference extends ModelInference_1.ClassInference {
|
|
|
52
52
|
preInfer(arkClass) {
|
|
53
53
|
super.preInfer(arkClass);
|
|
54
54
|
TypeInference_1.TypeInference.inferGenericType(arkClass.getGenericsTypes(), arkClass);
|
|
55
|
-
arkClass
|
|
55
|
+
arkClass
|
|
56
|
+
.getFields()
|
|
56
57
|
.filter(p => TypeInference_1.TypeInference.isUnclearType(p.getType()))
|
|
57
58
|
.forEach(f => {
|
|
58
59
|
const newType = TypeInference_1.TypeInference.inferUnclearedType(f.getType(), arkClass);
|
|
@@ -73,10 +74,13 @@ class ArkTsMethodInference extends ModelInference_1.MethodInference {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
inferMethodSignature(ms, arkMethod) {
|
|
76
|
-
ms.getMethodSubSignature()
|
|
77
|
+
ms.getMethodSubSignature()
|
|
78
|
+
.getParameters()
|
|
79
|
+
.forEach(p => TypeInference_1.TypeInference.inferParameterType(p, arkMethod));
|
|
77
80
|
TypeInference_1.TypeInference.inferSignatureReturnType(ms, arkMethod);
|
|
78
81
|
}
|
|
79
82
|
}
|
|
83
|
+
const IS_GENERIC_OR_ANY = (t) => t instanceof Type_1.GenericType || t instanceof Type_1.AnyType;
|
|
80
84
|
class ArkTsStmtInference extends ModelInference_1.StmtInference {
|
|
81
85
|
constructor(valueInferences) {
|
|
82
86
|
super(valueInferences);
|
|
@@ -91,10 +95,20 @@ class ArkTsStmtInference extends ModelInference_1.StmtInference {
|
|
|
91
95
|
return super.typeSpread(stmt, method);
|
|
92
96
|
}
|
|
93
97
|
transferRight2Left(leftOp, rightType, method) {
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
// An unclear ClassType with fully-resolved real type args still carries information
|
|
99
|
+
// (e.g. IterableIterator<number> stubs) and should propagate to the left operand.
|
|
100
|
+
const realArgs = rightType instanceof Type_1.ClassType ? rightType.getRealGenericTypes() : undefined;
|
|
101
|
+
let isUnclearWithRealArgs = false;
|
|
102
|
+
for (let i = 0; realArgs !== undefined && i < realArgs.length; i++) {
|
|
103
|
+
if (!(realArgs[i] instanceof Type_1.GenericType)) {
|
|
104
|
+
isUnclearWithRealArgs = true;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const isPlaceholderRight = rightType instanceof Type_1.NullType || rightType instanceof Type_1.UndefinedType;
|
|
109
|
+
if ((!TypeInference_1.TypeInference.isUnclearType(rightType) && !isPlaceholderRight) || rightType instanceof Type_1.GenericType || isUnclearWithRealArgs) {
|
|
96
110
|
let leftType = leftOp.getType();
|
|
97
|
-
if (TypeInference_1.TypeInference.isTypeCanBeOverride(leftType) || TypeInference_1.TypeInference.isAnonType(leftType,
|
|
111
|
+
if (TypeInference_1.TypeInference.isTypeCanBeOverride(leftType) || TypeInference_1.TypeInference.isAnonType(leftType, method.getDeclaringArkFile().getProjectName())) {
|
|
98
112
|
leftType = rightType;
|
|
99
113
|
}
|
|
100
114
|
if (leftOp.getType() !== leftType) {
|
|
@@ -179,17 +193,23 @@ let ArkTSFieldRefInference = class ArkTSFieldRefInference extends ValueInference
|
|
|
179
193
|
}
|
|
180
194
|
/**
|
|
181
195
|
* Checks if a value represents an anonymous class 'this' field reference
|
|
182
|
-
* Identifies field references that access fields directly on 'this' in
|
|
196
|
+
* Identifies field references that access fields directly on 'this' in the AC's
|
|
197
|
+
* %instInit — the carrier of field-initializer expressions, where `this` lexically
|
|
198
|
+
* means the ENCLOSING this (rebound to the host class by inferThisLocal), so def-side
|
|
199
|
+
* member resolution against the AC would only degrade. The AC's own constructors keep
|
|
200
|
+
* the build-time this (ClassType(AC), see the this-semantic guards in
|
|
201
|
+
* ArkTSLocalInference.infer / IRInference.inferBase) and their def-side resolution
|
|
202
|
+
* must NOT be skipped — skipping it left build-time probe stubs permanently uncorrected.
|
|
183
203
|
* @param {Value} stmtDef - The value to check (typically a field reference)
|
|
184
204
|
* @param {ArkMethod} arkMethod - The method containing the value
|
|
185
|
-
* @returns {boolean} True if the value is an anonymous class 'this' field reference
|
|
205
|
+
* @returns {boolean} True if the value is an anonymous class %instInit 'this' field reference
|
|
186
206
|
*/
|
|
187
207
|
isAnonClassThisRef(stmtDef, arkMethod) {
|
|
188
|
-
return (arkMethod.getName() === Const_1.INSTANCE_INIT_METHOD_NAME
|
|
208
|
+
return (arkMethod.getName() === Const_1.INSTANCE_INIT_METHOD_NAME &&
|
|
189
209
|
stmtDef instanceof Ref_1.ArkInstanceFieldRef &&
|
|
190
210
|
stmtDef.getBase().getName() === TSConst_1.THIS_NAME &&
|
|
191
211
|
arkMethod.getDeclaringArkClass().isAnonymousClass() &&
|
|
192
|
-
stmtDef.getFieldName().indexOf('.') === -1;
|
|
212
|
+
stmtDef.getFieldName().indexOf('.') === -1);
|
|
193
213
|
}
|
|
194
214
|
};
|
|
195
215
|
ArkTSFieldRefInference = __decorate([
|
|
@@ -272,7 +292,7 @@ let AliasTypeExprInference = class AliasTypeExprInference extends ValueInference
|
|
|
272
292
|
}
|
|
273
293
|
if (type) {
|
|
274
294
|
const realGenericTypes = value.getRealGenericTypes();
|
|
275
|
-
if (TypeInference_1.TypeInference.checkType(type,
|
|
295
|
+
if (TypeInference_1.TypeInference.checkType(type, IS_GENERIC_OR_ANY) && realGenericTypes && realGenericTypes.length > 0) {
|
|
276
296
|
TypeInference_1.TypeInference.inferRealGenericTypes(realGenericTypes, arkMethod.getDeclaringArkClass());
|
|
277
297
|
type = TypeInference_1.TypeInference.replaceTypeWithReal(type, realGenericTypes);
|
|
278
298
|
}
|
|
@@ -294,8 +314,7 @@ let ArkTSLocalInference = class ArkTSLocalInference extends ValueInference_1.Loc
|
|
|
294
314
|
}
|
|
295
315
|
preInfer(value) {
|
|
296
316
|
const type = value.getType();
|
|
297
|
-
if (value.getName() === TSConst_1.THIS_NAME && type instanceof Type_1.ClassType &&
|
|
298
|
-
type.getClassSignature().getClassName().startsWith(Const_1.ANONYMOUS_CLASS_PREFIX)) {
|
|
317
|
+
if (value.getName() === TSConst_1.THIS_NAME && type instanceof Type_1.ClassType && type.getClassSignature().getClassName().startsWith(Const_1.ANONYMOUS_CLASS_PREFIX)) {
|
|
299
318
|
return true;
|
|
300
319
|
}
|
|
301
320
|
else if (type instanceof Type_1.FunctionType) {
|
|
@@ -310,15 +329,34 @@ let ArkTSLocalInference = class ArkTSLocalInference extends ValueInference_1.Loc
|
|
|
310
329
|
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
311
330
|
let newType;
|
|
312
331
|
if (name === TSConst_1.THIS_NAME) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
332
|
+
// this-semantic guard: only the AC's %instInit (the carrier of field-initializer
|
|
333
|
+
// expressions, where `this` lexically means the ENCLOSING this at the object
|
|
334
|
+
// literal / class expression site — the host class) gets rebound via
|
|
335
|
+
// inferThisLocal. The AC's own methods (constructor, named method properties)
|
|
336
|
+
// keep the build-time this (ClassType(AC)) — the instance itself. Rebinding
|
|
337
|
+
// them to the host class breaks every `this.<memberOfAC>` resolution downstream.
|
|
338
|
+
const hostMethod = stmt.getCfg().getDeclaringMethod();
|
|
339
|
+
if (hostMethod.getName() === Const_1.INSTANCE_INIT_METHOD_NAME && hostMethod.getDeclaringArkClass().isAnonymousClass()) {
|
|
340
|
+
newType = (_a = IRInference_1.IRInference.inferThisLocal(hostMethod)) === null || _a === void 0 ? void 0 : _a.getType();
|
|
341
|
+
if (newType) {
|
|
342
|
+
value.setType(newType);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
else if (name === TSConst_1.SUPER_NAME) {
|
|
348
|
+
const superType = TypeInference_1.TypeInference.inferBaseType(TSConst_1.SUPER_NAME, arkMethod.getDeclaringArkClass());
|
|
349
|
+
if (superType) {
|
|
350
|
+
value.setType(superType);
|
|
316
351
|
}
|
|
317
352
|
return undefined;
|
|
318
353
|
}
|
|
319
354
|
else if (type instanceof Type_1.FunctionType) {
|
|
320
355
|
const methodSignature = type.getMethodSignature();
|
|
321
|
-
methodSignature.getMethodSubSignature().getParameters()
|
|
356
|
+
const parameters = methodSignature.getMethodSubSignature().getParameters();
|
|
357
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
358
|
+
TypeInference_1.TypeInference.inferParameterType(parameters[i], arkMethod);
|
|
359
|
+
}
|
|
322
360
|
TypeInference_1.TypeInference.inferSignatureReturnType(methodSignature, arkMethod);
|
|
323
361
|
return undefined;
|
|
324
362
|
}
|