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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SignatureCanonicalizer = exports.signatureEquals = void 0;
|
|
18
|
+
const Canonicalizer_1 = require("../../utils/Canonicalizer");
|
|
19
|
+
/**
|
|
20
|
+
* Value-semantic identity comparison between two signatures:
|
|
21
|
+
* cached-hash fast reject + `equals()` final verdict.
|
|
22
|
+
*
|
|
23
|
+
* Execution rules: the hash comparison short-circuits only comparisons whose
|
|
24
|
+
* result is "unequal"; comparisons whose result is "equal" necessarily run
|
|
25
|
+
* `equals()` (the Canonicalizable contract "equals ⇒ same hash" guarantees the
|
|
26
|
+
* hashes match), where canonical instances short-circuit on the first line
|
|
27
|
+
* (`this === other`). This is the same hash-then-equals protocol the
|
|
28
|
+
* canonicalizer probe uses internally — running it once directly between the
|
|
29
|
+
* two objects, instead of twice (once per probe) plus an ID comparison, and
|
|
30
|
+
* without depending on registration state.
|
|
31
|
+
*
|
|
32
|
+
* Why not compare canonicalizer IDs ("same ID ⇒ equal")? IDs are a function
|
|
33
|
+
* of value × registration history, not of value alone: two unregistered
|
|
34
|
+
* signatures (e.g. temp stubs) both yield getExistingId() === -1 and would be
|
|
35
|
+
* wrongly judged equal; one registered + one unregistered would be wrongly
|
|
36
|
+
* judged unequal; and the getId() variant would blind-write unregistered
|
|
37
|
+
* values into the formal space (permanent holes, see the temp-space design).
|
|
38
|
+
*
|
|
39
|
+
* No string building, no string hashing.
|
|
40
|
+
*/
|
|
41
|
+
function signatureEquals(a, b) {
|
|
42
|
+
return a.getHashCode() === b.getHashCode() && a.equals(b);
|
|
43
|
+
}
|
|
44
|
+
exports.signatureEquals = signatureEquals;
|
|
45
|
+
/**
|
|
46
|
+
* A canonicalizer that deduplicates signatures by value semantics using hash + equals.
|
|
47
|
+
*
|
|
48
|
+
* Uses a three-layer hash-collision-handling architecture:
|
|
49
|
+
*
|
|
50
|
+
* 1. `sig.getHashCode()` returns a cached 32-bit hash (computed once at construction)
|
|
51
|
+
* 2. `Canonicalizer<S>` with `numberWithEquality` strategy uses TypedArray hash tables
|
|
52
|
+
* with open addressing + chaining for collision handling
|
|
53
|
+
* 3. `sig.equals()` does per-field comparison when hash collisions occur
|
|
54
|
+
*
|
|
55
|
+
* This eliminates the `list: string[]` storage of `toMapKey()` strings (~500 KB-1 MB
|
|
56
|
+
* for 10k-level signatures) and avoids repeated string concatenation in `toMapKey()`.
|
|
57
|
+
*
|
|
58
|
+
* IDs are dense integers starting from 0.
|
|
59
|
+
*
|
|
60
|
+
* @template S - The signature type, must implement {@link Canonicalizable}
|
|
61
|
+
*/
|
|
62
|
+
class SignatureCanonicalizer {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.canonicalizer = new Canonicalizer_1.Canonicalizer((s) => s.getHashCode(), (a, b) => a.equals(b));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the unique integer ID for a signature.
|
|
68
|
+
* If a signature with the same hash and `equals()` result has been seen before, returns the existing ID.
|
|
69
|
+
* Otherwise, assigns a new ID and records the signature as the canonical instance.
|
|
70
|
+
*
|
|
71
|
+
* @param sig - The signature to canonicalize
|
|
72
|
+
* @returns The integer ID (>= 0)
|
|
73
|
+
*/
|
|
74
|
+
getOrCreateId(sig) {
|
|
75
|
+
return this.canonicalizer.getId(sig);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get the integer ID of a signature if it already exists.
|
|
79
|
+
* Returns -1 if the signature has not been canonicalized.
|
|
80
|
+
* Does not create a new ID or modify internal state.
|
|
81
|
+
*
|
|
82
|
+
* @param sig - The signature to query
|
|
83
|
+
* @returns The integer ID (>= 0) if found, -1 otherwise
|
|
84
|
+
*/
|
|
85
|
+
getExistingId(sig) {
|
|
86
|
+
return this.canonicalizer.getExistingId(sig);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the canonical signature instance associated with an integer ID.
|
|
90
|
+
*
|
|
91
|
+
* @param id - The integer ID
|
|
92
|
+
* @returns The canonical signature instance, or `undefined` if the ID is out of bounds
|
|
93
|
+
*/
|
|
94
|
+
get(id) {
|
|
95
|
+
return this.canonicalizer.get(id);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the total number of unique signatures registered so far.
|
|
99
|
+
*/
|
|
100
|
+
size() {
|
|
101
|
+
return this.canonicalizer.size();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get hash table statistics (for debugging/profiling).
|
|
105
|
+
*/
|
|
106
|
+
getStats() {
|
|
107
|
+
return this.canonicalizer.getStats();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Clear all registered signatures and reset the canonicalizer.
|
|
111
|
+
*/
|
|
112
|
+
clear() {
|
|
113
|
+
this.canonicalizer.clear();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.SignatureCanonicalizer = SignatureCanonicalizer;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { FileSignature, ClassSignature, MethodSignature, NamespaceSignature, FieldSignature } from '../model/ArkSignature';
|
|
2
|
+
import { ArkFile } from '../model/ArkFile';
|
|
3
|
+
import { ArkClass } from '../model/ArkClass';
|
|
4
|
+
import { ArkMethod } from '../model/ArkMethod';
|
|
5
|
+
import { ArkNamespace } from '../model/ArkNamespace';
|
|
6
|
+
import { ArkField } from '../model/ArkField';
|
|
7
|
+
import { ArkExport } from '../model/ArkExport';
|
|
8
|
+
import { SignatureModelCanonicalizer } from './SignatureModelCanonicalizer';
|
|
9
|
+
import { TempSignatureCanonicalizer } from './TempSignatureCanonicalizer';
|
|
10
|
+
/**
|
|
11
|
+
* Global singleton registry that centralizes all signature canonicalizers and model storage.
|
|
12
|
+
*
|
|
13
|
+
* Any code can access canonicalizers via `SignatureCanonicalizerRegistry.getInstance()`
|
|
14
|
+
* or static shortcut methods, without needing a Scene reference.
|
|
15
|
+
*
|
|
16
|
+
* **Design constraint**: Assumes a single Scene instance at runtime.
|
|
17
|
+
* For multi-Scene support, change to per-Scene instances — a small modification.
|
|
18
|
+
*
|
|
19
|
+
* **Lifecycle**: `Scene.dispose()` / `Scene.clear()` should call `dispose()`.
|
|
20
|
+
* After dispose, `getInstance()` auto-rebuilds and re-initializes DEFAULT signatures.
|
|
21
|
+
*/
|
|
22
|
+
/** 单个 temp 索引表空间的统计快照(字段语义见 TempSignatureCanonicalizer.getStats)。 */
|
|
23
|
+
export interface TempSpaceStats {
|
|
24
|
+
/** 未迁移(非空 slot)的签名数——含 Builtin stub 池等常驻基线与推导中间垃圾。 */
|
|
25
|
+
liveCount: number;
|
|
26
|
+
/** 累计注册总量(= nextId,永不复用)。 */
|
|
27
|
+
totalRegistered: number;
|
|
28
|
+
/** 已迁移(retire 置空)总量。三数自洽:totalRegistered = liveCount + retiredCount。 */
|
|
29
|
+
retiredCount: number;
|
|
30
|
+
/** 有 formal 归宿记录的迁移数(≤ retiredCount)。 */
|
|
31
|
+
replacedCount: number;
|
|
32
|
+
}
|
|
33
|
+
export declare class SignatureCanonicalizerRegistry {
|
|
34
|
+
readonly fileSigCanonicalizer: SignatureModelCanonicalizer<FileSignature, ArkFile>;
|
|
35
|
+
readonly classSigCanonicalizer: SignatureModelCanonicalizer<ClassSignature, ArkClass>;
|
|
36
|
+
readonly namespaceSigCanonicalizer: SignatureModelCanonicalizer<NamespaceSignature, ArkNamespace>;
|
|
37
|
+
readonly fieldSigCanonicalizer: SignatureModelCanonicalizer<FieldSignature, ArkField>;
|
|
38
|
+
readonly methodSigCanonicalizer: SignatureModelCanonicalizer<MethodSignature, ArkMethod>;
|
|
39
|
+
readonly tempClassSigCanonicalizer: TempSignatureCanonicalizer<ClassSignature>;
|
|
40
|
+
readonly tempMethodSigCanonicalizer: TempSignatureCanonicalizer<MethodSignature>;
|
|
41
|
+
readonly tempFieldSigCanonicalizer: TempSignatureCanonicalizer<FieldSignature>;
|
|
42
|
+
/** Custom @Component name → ClassSignature (survives module unload for ViewTree stubs). */
|
|
43
|
+
customComponentMap: Map<string, ClassSignature>;
|
|
44
|
+
/**
|
|
45
|
+
* SDK 全局符号多值表(名字 → 实体列表,按登记序;列表 [0] 即单值视图首实体,
|
|
46
|
+
* 即旧单值 Map 的 first-win 语义)。实体种类:顶层 interface/class(ArkClass,
|
|
47
|
+
* 同名跨文件多实体)、全局函数(ArkMethod)、类型别名(AliasType)、namespace
|
|
48
|
+
*(ArkNamespace)、declare var 的 Local(var 侧探测锚点)。存对象引用不存 ID
|
|
49
|
+
*(Local 无 SigID;class/ns 双 ID 空间冲突;对象本就在各 canonicalizer models
|
|
50
|
+
* 中存活,此处仅名字索引)。写入方 SdkUtils.loadAPI 族;读取方 Scene
|
|
51
|
+
* getSdkGlobal 族(委托)。随 dispose() 清理;disposeModule 不清(模块卸载
|
|
52
|
+
* 后全局符号仍可解析,与旧 Scene 字段语义一致)。
|
|
53
|
+
*/
|
|
54
|
+
sdkGlobalMap: Map<string, ArkExport[]>;
|
|
55
|
+
/**
|
|
56
|
+
* fileSigCanonicalizer 的 ID 边界:[1, firstProjectFileSigID) 为 SDK 文件,
|
|
57
|
+
* [firstProjectFileSigID, size) 为 project 文件。ID 0 = DEFAULT,两侧均不属于。
|
|
58
|
+
* -1 = 边界未设置(尚未完成 SDK 构建阶段)。
|
|
59
|
+
*
|
|
60
|
+
* 语义前提:构建时序上全部 SDK(含 oh_modules 依赖包)先于 project 文件注册
|
|
61
|
+
* (见 ModuleBuilder.prepareSdks → buildBasicInfo → genArkFiles),因此边界单调。
|
|
62
|
+
*/
|
|
63
|
+
private firstProjectFileSigID;
|
|
64
|
+
/**
|
|
65
|
+
* 标记 project/SDK ID 边界。取当前 fileSigCanonicalizer.size():dense array 语义下,
|
|
66
|
+
* 下一个 intern 的 ID 恰为 size,即首个 project 文件将获得的 ID。重复调用以首次为准
|
|
67
|
+
* (幂等守卫,防止误调用覆盖已成立的边界)。
|
|
68
|
+
*/
|
|
69
|
+
markProjectFileBoundary(): void;
|
|
70
|
+
/** 获取 project/SDK ID 边界。-1 = 未设置。 */
|
|
71
|
+
getFirstProjectFileSigID(): number;
|
|
72
|
+
/** 仅凭 FileSigID 快速判断是否为 project 文件。边界未设置时恒返回 false。 */
|
|
73
|
+
isProjectFileID(id: number): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* 仅凭 FileSigID 快速判断是否为 SDK 文件。ID 0(DEFAULT)与边界未设置时恒返回 false。
|
|
76
|
+
*/
|
|
77
|
+
isSdkFileID(id: number): boolean;
|
|
78
|
+
private static instance;
|
|
79
|
+
private constructor();
|
|
80
|
+
/**
|
|
81
|
+
* Get the singleton instance. Auto-creates and initializes DEFAULT signatures on first call
|
|
82
|
+
* (or after `dispose()` was called).
|
|
83
|
+
*/
|
|
84
|
+
static getInstance(): SignatureCanonicalizerRegistry;
|
|
85
|
+
/**
|
|
86
|
+
* Dispose the singleton: clear all canonicalizers, models, and maps.
|
|
87
|
+
* Next `getInstance()` call will auto-rebuild.
|
|
88
|
+
*/
|
|
89
|
+
static dispose(): void;
|
|
90
|
+
/** 单个 temp 索引表空间的统计快照(字段语义见 TempSignatureCanonicalizer.getStats)。 */
|
|
91
|
+
getTempSpacesStats(): {
|
|
92
|
+
class: TempSpaceStats;
|
|
93
|
+
method: TempSpaceStats;
|
|
94
|
+
field: TempSpaceStats;
|
|
95
|
+
};
|
|
96
|
+
settleTempSpaces(): Promise<{
|
|
97
|
+
class: TempSpaceStats;
|
|
98
|
+
method: TempSpaceStats;
|
|
99
|
+
field: TempSpaceStats;
|
|
100
|
+
}>;
|
|
101
|
+
/** @internal Get the formal FileSigID for a FileSignature. */
|
|
102
|
+
getFileId(sig: FileSignature): number;
|
|
103
|
+
/** @internal Get the formal ClassSigID for a ClassSignature. */
|
|
104
|
+
getClassId(sig: ClassSignature): number;
|
|
105
|
+
/** @internal Get the formal MethodSigID for a MethodSignature. */
|
|
106
|
+
getMethodId(sig: MethodSignature): number;
|
|
107
|
+
/** @internal Get the formal NamespaceSigID for a NamespaceSignature. */
|
|
108
|
+
getNamespaceId(sig: NamespaceSignature): number;
|
|
109
|
+
/** @internal Get the formal FieldSigID for a FieldSignature. */
|
|
110
|
+
getFieldId(sig: FieldSignature): number;
|
|
111
|
+
/** @internal Get an ArkFile by its formal FileSigID. */
|
|
112
|
+
getFileById(id: number): ArkFile | undefined;
|
|
113
|
+
/** @internal Get an ArkFile by its formal FileSigID. Read-only: never interns the signature. */
|
|
114
|
+
getFileBySig(fileSig: FileSignature): ArkFile | undefined;
|
|
115
|
+
/** @internal Get an ArkClass by its formal ClassSigID. */
|
|
116
|
+
getClassById(id: number): ArkClass | undefined;
|
|
117
|
+
/** @internal Get an ArkClass by its formal ClassSigID. Read-only: never interns the signature. */
|
|
118
|
+
getClassBySig(classSig: ClassSignature): ArkClass | undefined;
|
|
119
|
+
/** @internal Get an ArkMethod by its formal MethodSigID. */
|
|
120
|
+
getMethodById(id: number): ArkMethod | undefined;
|
|
121
|
+
/** @internal Get an ArkMethod by its formal MethodSigID. Read-only: never interns the signature. */
|
|
122
|
+
getMethodBySig(methodSig: MethodSignature): ArkMethod | undefined;
|
|
123
|
+
/** @internal Get an ArkNamespace by its formal NamespaceSigID. */
|
|
124
|
+
getNamespaceById(id: number): ArkNamespace | undefined;
|
|
125
|
+
/** @internal Get an ArkNamespace by its formal NamespaceSigID. Read-only: never interns the signature. */
|
|
126
|
+
getNamespaceBySig(nsSig: NamespaceSignature): ArkNamespace | undefined;
|
|
127
|
+
/** @internal Get an ArkField by its formal FieldSigID. */
|
|
128
|
+
getFieldById(id: number): ArkField | undefined;
|
|
129
|
+
/** @internal Get an ArkField by its formal FieldSigID. Read-only: never interns the signature. */
|
|
130
|
+
getFieldBySig(fieldSig: FieldSignature): ArkField | undefined;
|
|
131
|
+
/** @internal Register an ArkFile into the file canonicalizer. Skips if fileSigID is 0 (DEFAULT). */
|
|
132
|
+
registerFile(file: ArkFile): void;
|
|
133
|
+
/** @internal Register an ArkClass into the class canonicalizer. Skips if classSigID is not positive (unset / DEFAULT). */
|
|
134
|
+
registerClass(cls: ArkClass): void;
|
|
135
|
+
/** @internal Register an ArkField into the field canonicalizer. Skips if fieldSigID is 0 (DEFAULT) or -1 (not set). */
|
|
136
|
+
registerField(field: ArkField): void;
|
|
137
|
+
/** @internal Register an ArkMethod into the method canonicalizer. Skips if methodSigID is undefined (declare-only) or not positive. */
|
|
138
|
+
registerMethod(method: ArkMethod): void;
|
|
139
|
+
/** @internal Register an ArkNamespace into the namespace canonicalizer. Skips if namespaceSigID is 0 (DEFAULT). */
|
|
140
|
+
registerNamespace(ns: ArkNamespace): void;
|
|
141
|
+
/**
|
|
142
|
+
* @internal Register a custom @Component into customComponentMap.
|
|
143
|
+
* Entries intentionally survive module unload so ViewTree can still resolve signatures.
|
|
144
|
+
*/
|
|
145
|
+
registerCustomComponent(cls: ArkClass): void;
|
|
146
|
+
/**
|
|
147
|
+
* @internal Remove a custom component entry from customComponentMap.
|
|
148
|
+
* Not called on module unload — the map must outlive IR.
|
|
149
|
+
*/
|
|
150
|
+
unregisterCustomComponent(cls: ArkClass): void;
|
|
151
|
+
/** @internal Remove an ArkFile from the file canonicalizer. Returns true if it existed. */
|
|
152
|
+
removeFile(file: ArkFile): boolean;
|
|
153
|
+
/** @internal Remove an ArkClass from the class canonicalizer and customComponentMap. Returns true if it existed. */
|
|
154
|
+
removeClass(arkClass: ArkClass): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* @internal Remove an ArkClass from the class canonicalizer without touching customComponentMap.
|
|
157
|
+
* Used by disposeModule where customComponentMap entries must survive module unload.
|
|
158
|
+
*/
|
|
159
|
+
removeClassModel(arkClass: ArkClass): boolean;
|
|
160
|
+
/** @internal Remove an ArkMethod from the method canonicalizer (impl + declare slots). Returns true if any existed. */
|
|
161
|
+
removeMethod(method: ArkMethod): boolean;
|
|
162
|
+
/** @internal Remove an ArkNamespace from the namespace canonicalizer. Returns true if it existed. */
|
|
163
|
+
removeNamespace(namespace: ArkNamespace): boolean;
|
|
164
|
+
/** @internal Remove an ArkField from the field canonicalizer. Returns true if it existed. */
|
|
165
|
+
removeField(field: ArkField): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Intern the 5 DEFAULT signatures to formal canonicalizers, each obtaining fixed ID 0.
|
|
168
|
+
* ID 0 does not correspond to any model (models[0] remains undefined).
|
|
169
|
+
*
|
|
170
|
+
* All value-object overloads resolve through `getInstance()`, but `instance` is assigned
|
|
171
|
+
* only after this constructor returns — hence every DEFAULT here is built via a
|
|
172
|
+
* SigID constructor overload with the already-interned file DEFAULT (ID 0).
|
|
173
|
+
*/
|
|
174
|
+
private internDefaults;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=SignatureCanonicalizerRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureCanonicalizerRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/common/SignatureCanonicalizerRegistry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SignatureCanonicalizerRegistry = void 0;
|
|
27
|
+
const ArkSignature_1 = require("../model/ArkSignature");
|
|
28
|
+
const Type_1 = require("../base/Type");
|
|
29
|
+
const Const_1 = require("./Const");
|
|
30
|
+
const SignatureModelCanonicalizer_1 = require("./SignatureModelCanonicalizer");
|
|
31
|
+
const TempSignatureCanonicalizer_1 = require("./TempSignatureCanonicalizer");
|
|
32
|
+
class SignatureCanonicalizerRegistry {
|
|
33
|
+
/**
|
|
34
|
+
* 标记 project/SDK ID 边界。取当前 fileSigCanonicalizer.size():dense array 语义下,
|
|
35
|
+
* 下一个 intern 的 ID 恰为 size,即首个 project 文件将获得的 ID。重复调用以首次为准
|
|
36
|
+
* (幂等守卫,防止误调用覆盖已成立的边界)。
|
|
37
|
+
*/
|
|
38
|
+
markProjectFileBoundary() {
|
|
39
|
+
if (this.firstProjectFileSigID !== -1) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.firstProjectFileSigID = this.fileSigCanonicalizer.size();
|
|
43
|
+
}
|
|
44
|
+
/** 获取 project/SDK ID 边界。-1 = 未设置。 */
|
|
45
|
+
getFirstProjectFileSigID() {
|
|
46
|
+
return this.firstProjectFileSigID;
|
|
47
|
+
}
|
|
48
|
+
/** 仅凭 FileSigID 快速判断是否为 project 文件。边界未设置时恒返回 false。 */
|
|
49
|
+
isProjectFileID(id) {
|
|
50
|
+
return this.firstProjectFileSigID !== -1 && id >= this.firstProjectFileSigID;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 仅凭 FileSigID 快速判断是否为 SDK 文件。ID 0(DEFAULT)与边界未设置时恒返回 false。
|
|
54
|
+
*/
|
|
55
|
+
isSdkFileID(id) {
|
|
56
|
+
return this.firstProjectFileSigID !== -1 && id > 0 && id < this.firstProjectFileSigID;
|
|
57
|
+
}
|
|
58
|
+
constructor() {
|
|
59
|
+
// --- Formal canonicalizers (value-semantic dedup + model storage) ---
|
|
60
|
+
this.fileSigCanonicalizer = new SignatureModelCanonicalizer_1.SignatureModelCanonicalizer();
|
|
61
|
+
this.classSigCanonicalizer = new SignatureModelCanonicalizer_1.SignatureModelCanonicalizer();
|
|
62
|
+
this.namespaceSigCanonicalizer = new SignatureModelCanonicalizer_1.SignatureModelCanonicalizer();
|
|
63
|
+
this.fieldSigCanonicalizer = new SignatureModelCanonicalizer_1.SignatureModelCanonicalizer();
|
|
64
|
+
this.methodSigCanonicalizer = new SignatureModelCanonicalizer_1.SignatureModelCanonicalizer();
|
|
65
|
+
// --- Temp canonicalizers (index-table semantics, see TempSignatureCanonicalizer) ---
|
|
66
|
+
// Note: no tempFile/tempNamespace spaces — both were permanently empty. FileSignature
|
|
67
|
+
// is the identity root (never temp-held), and no production path ever registered a
|
|
68
|
+
// namespace into the temp space (namespace-declaring FieldSignatures go through the
|
|
69
|
+
// SigID overloads; the unclear-ns value-constructor branch only marks SigID = -1).
|
|
70
|
+
this.tempClassSigCanonicalizer = new TempSignatureCanonicalizer_1.TempSignatureCanonicalizer();
|
|
71
|
+
this.tempMethodSigCanonicalizer = new TempSignatureCanonicalizer_1.TempSignatureCanonicalizer();
|
|
72
|
+
this.tempFieldSigCanonicalizer = new TempSignatureCanonicalizer_1.TempSignatureCanonicalizer();
|
|
73
|
+
// --- Maps that cannot be replaced by canonicalizer ---
|
|
74
|
+
/** Custom @Component name → ClassSignature (survives module unload for ViewTree stubs). */
|
|
75
|
+
this.customComponentMap = new Map();
|
|
76
|
+
/**
|
|
77
|
+
* SDK 全局符号多值表(名字 → 实体列表,按登记序;列表 [0] 即单值视图首实体,
|
|
78
|
+
* 即旧单值 Map 的 first-win 语义)。实体种类:顶层 interface/class(ArkClass,
|
|
79
|
+
* 同名跨文件多实体)、全局函数(ArkMethod)、类型别名(AliasType)、namespace
|
|
80
|
+
*(ArkNamespace)、declare var 的 Local(var 侧探测锚点)。存对象引用不存 ID
|
|
81
|
+
*(Local 无 SigID;class/ns 双 ID 空间冲突;对象本就在各 canonicalizer models
|
|
82
|
+
* 中存活,此处仅名字索引)。写入方 SdkUtils.loadAPI 族;读取方 Scene
|
|
83
|
+
* getSdkGlobal 族(委托)。随 dispose() 清理;disposeModule 不清(模块卸载
|
|
84
|
+
* 后全局符号仍可解析,与旧 Scene 字段语义一致)。
|
|
85
|
+
*/
|
|
86
|
+
this.sdkGlobalMap = new Map();
|
|
87
|
+
// --- Project/SDK file ID boundary ---
|
|
88
|
+
/**
|
|
89
|
+
* fileSigCanonicalizer 的 ID 边界:[1, firstProjectFileSigID) 为 SDK 文件,
|
|
90
|
+
* [firstProjectFileSigID, size) 为 project 文件。ID 0 = DEFAULT,两侧均不属于。
|
|
91
|
+
* -1 = 边界未设置(尚未完成 SDK 构建阶段)。
|
|
92
|
+
*
|
|
93
|
+
* 语义前提:构建时序上全部 SDK(含 oh_modules 依赖包)先于 project 文件注册
|
|
94
|
+
* (见 ModuleBuilder.prepareSdks → buildBasicInfo → genArkFiles),因此边界单调。
|
|
95
|
+
*/
|
|
96
|
+
this.firstProjectFileSigID = -1;
|
|
97
|
+
this.internDefaults();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the singleton instance. Auto-creates and initializes DEFAULT signatures on first call
|
|
101
|
+
* (or after `dispose()` was called).
|
|
102
|
+
*/
|
|
103
|
+
static getInstance() {
|
|
104
|
+
if (!SignatureCanonicalizerRegistry.instance) {
|
|
105
|
+
SignatureCanonicalizerRegistry.instance = new SignatureCanonicalizerRegistry();
|
|
106
|
+
}
|
|
107
|
+
return SignatureCanonicalizerRegistry.instance;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Dispose the singleton: clear all canonicalizers, models, and maps.
|
|
111
|
+
* Next `getInstance()` call will auto-rebuild.
|
|
112
|
+
*/
|
|
113
|
+
static dispose() {
|
|
114
|
+
if (SignatureCanonicalizerRegistry.instance) {
|
|
115
|
+
const reg = SignatureCanonicalizerRegistry.instance;
|
|
116
|
+
reg.fileSigCanonicalizer.clear();
|
|
117
|
+
reg.classSigCanonicalizer.clear();
|
|
118
|
+
reg.namespaceSigCanonicalizer.clear();
|
|
119
|
+
reg.fieldSigCanonicalizer.clear();
|
|
120
|
+
reg.methodSigCanonicalizer.clear();
|
|
121
|
+
reg.tempClassSigCanonicalizer.clear();
|
|
122
|
+
reg.tempMethodSigCanonicalizer.clear();
|
|
123
|
+
reg.tempFieldSigCanonicalizer.clear();
|
|
124
|
+
reg.customComponentMap.clear();
|
|
125
|
+
reg.sdkGlobalMap.clear();
|
|
126
|
+
SignatureCanonicalizerRegistry.instance = undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** 单个 temp 索引表空间的统计快照(字段语义见 TempSignatureCanonicalizer.getStats)。 */
|
|
130
|
+
getTempSpacesStats() {
|
|
131
|
+
return {
|
|
132
|
+
class: this.tempClassSigCanonicalizer.getStats(),
|
|
133
|
+
method: this.tempMethodSigCanonicalizer.getStats(),
|
|
134
|
+
field: this.tempFieldSigCanonicalizer.getStats(),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
settleTempSpaces() {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
return this.getTempSpacesStats();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// --- Static shortcut methods ---
|
|
143
|
+
/** @internal Get the formal FileSigID for a FileSignature. */
|
|
144
|
+
getFileId(sig) {
|
|
145
|
+
return this.fileSigCanonicalizer.getExistingId(sig);
|
|
146
|
+
}
|
|
147
|
+
/** @internal Get the formal ClassSigID for a ClassSignature. */
|
|
148
|
+
getClassId(sig) {
|
|
149
|
+
return this.classSigCanonicalizer.getExistingId(sig);
|
|
150
|
+
}
|
|
151
|
+
/** @internal Get the formal MethodSigID for a MethodSignature. */
|
|
152
|
+
getMethodId(sig) {
|
|
153
|
+
return this.methodSigCanonicalizer.getExistingId(sig);
|
|
154
|
+
}
|
|
155
|
+
/** @internal Get the formal NamespaceSigID for a NamespaceSignature. */
|
|
156
|
+
getNamespaceId(sig) {
|
|
157
|
+
return this.namespaceSigCanonicalizer.getExistingId(sig);
|
|
158
|
+
}
|
|
159
|
+
/** @internal Get the formal FieldSigID for a FieldSignature. */
|
|
160
|
+
getFieldId(sig) {
|
|
161
|
+
return this.fieldSigCanonicalizer.getExistingId(sig);
|
|
162
|
+
}
|
|
163
|
+
/** @internal Get an ArkFile by its formal FileSigID. */
|
|
164
|
+
getFileById(id) {
|
|
165
|
+
return this.fileSigCanonicalizer.getModel(id);
|
|
166
|
+
}
|
|
167
|
+
/** @internal Get an ArkFile by its formal FileSigID. Read-only: never interns the signature. */
|
|
168
|
+
getFileBySig(fileSig) {
|
|
169
|
+
const id = this.fileSigCanonicalizer.getExistingId(fileSig);
|
|
170
|
+
return id === -1 ? undefined : this.fileSigCanonicalizer.getModel(id);
|
|
171
|
+
}
|
|
172
|
+
/** @internal Get an ArkClass by its formal ClassSigID. */
|
|
173
|
+
getClassById(id) {
|
|
174
|
+
return this.classSigCanonicalizer.getModel(id);
|
|
175
|
+
}
|
|
176
|
+
/** @internal Get an ArkClass by its formal ClassSigID. Read-only: never interns the signature. */
|
|
177
|
+
getClassBySig(classSig) {
|
|
178
|
+
const id = this.classSigCanonicalizer.getExistingId(classSig);
|
|
179
|
+
return id === -1 ? undefined : this.classSigCanonicalizer.getModel(id);
|
|
180
|
+
}
|
|
181
|
+
/** @internal Get an ArkMethod by its formal MethodSigID. */
|
|
182
|
+
getMethodById(id) {
|
|
183
|
+
return this.methodSigCanonicalizer.getModel(id);
|
|
184
|
+
}
|
|
185
|
+
/** @internal Get an ArkMethod by its formal MethodSigID. Read-only: never interns the signature. */
|
|
186
|
+
getMethodBySig(methodSig) {
|
|
187
|
+
const id = this.methodSigCanonicalizer.getExistingId(methodSig);
|
|
188
|
+
return id === -1 ? undefined : this.methodSigCanonicalizer.getModel(id);
|
|
189
|
+
}
|
|
190
|
+
/** @internal Get an ArkNamespace by its formal NamespaceSigID. */
|
|
191
|
+
getNamespaceById(id) {
|
|
192
|
+
return this.namespaceSigCanonicalizer.getModel(id);
|
|
193
|
+
}
|
|
194
|
+
/** @internal Get an ArkNamespace by its formal NamespaceSigID. Read-only: never interns the signature. */
|
|
195
|
+
getNamespaceBySig(nsSig) {
|
|
196
|
+
const id = this.namespaceSigCanonicalizer.getExistingId(nsSig);
|
|
197
|
+
return id === -1 ? undefined : this.namespaceSigCanonicalizer.getModel(id);
|
|
198
|
+
}
|
|
199
|
+
/** @internal Get an ArkField by its formal FieldSigID. */
|
|
200
|
+
getFieldById(id) {
|
|
201
|
+
return this.fieldSigCanonicalizer.getModel(id);
|
|
202
|
+
}
|
|
203
|
+
/** @internal Get an ArkField by its formal FieldSigID. Read-only: never interns the signature. */
|
|
204
|
+
getFieldBySig(fieldSig) {
|
|
205
|
+
const id = this.fieldSigCanonicalizer.getExistingId(fieldSig);
|
|
206
|
+
return id === -1 ? undefined : this.fieldSigCanonicalizer.getModel(id);
|
|
207
|
+
}
|
|
208
|
+
/** @internal Register an ArkFile into the file canonicalizer. Skips if fileSigID is 0 (DEFAULT). */
|
|
209
|
+
registerFile(file) {
|
|
210
|
+
const id = file.getFileSigID();
|
|
211
|
+
if (id > 0) {
|
|
212
|
+
this.fileSigCanonicalizer.setModel(id, file);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** @internal Register an ArkClass into the class canonicalizer. Skips if classSigID is not positive (unset / DEFAULT). */
|
|
216
|
+
registerClass(cls) {
|
|
217
|
+
if (cls.getClassSigID() > 0) {
|
|
218
|
+
this.classSigCanonicalizer.setModel(cls.getClassSigID(), cls);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** @internal Register an ArkField into the field canonicalizer. Skips if fieldSigID is 0 (DEFAULT) or -1 (not set). */
|
|
222
|
+
registerField(field) {
|
|
223
|
+
const id = field.getFieldSigID();
|
|
224
|
+
if (id > 0) {
|
|
225
|
+
this.fieldSigCanonicalizer.setModel(id, field);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/** @internal Register an ArkMethod into the method canonicalizer. Skips if methodSigID is undefined (declare-only) or not positive. */
|
|
229
|
+
registerMethod(method) {
|
|
230
|
+
const id = method.getMethodSigID();
|
|
231
|
+
if (id !== undefined && id > 0) {
|
|
232
|
+
this.methodSigCanonicalizer.setModel(id, method);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** @internal Register an ArkNamespace into the namespace canonicalizer. Skips if namespaceSigID is 0 (DEFAULT). */
|
|
236
|
+
registerNamespace(ns) {
|
|
237
|
+
const id = ns.getNamespaceSigID();
|
|
238
|
+
if (id > 0) {
|
|
239
|
+
this.namespaceSigCanonicalizer.setModel(id, ns);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @internal Register a custom @Component into customComponentMap.
|
|
244
|
+
* Entries intentionally survive module unload so ViewTree can still resolve signatures.
|
|
245
|
+
*/
|
|
246
|
+
registerCustomComponent(cls) {
|
|
247
|
+
if (!cls.hasComponentDecorator()) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const name = cls.getName();
|
|
251
|
+
if (!name || name.startsWith('%')) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
this.customComponentMap.set(name, cls.getSignature());
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @internal Remove a custom component entry from customComponentMap.
|
|
258
|
+
* Not called on module unload — the map must outlive IR.
|
|
259
|
+
*/
|
|
260
|
+
unregisterCustomComponent(cls) {
|
|
261
|
+
const name = cls.getName();
|
|
262
|
+
if (!name || !cls.hasComponentDecorator()) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const existing = this.customComponentMap.get(name);
|
|
266
|
+
if (existing && this.classSigCanonicalizer.getExistingId(existing) === cls.getClassSigID()) {
|
|
267
|
+
this.customComponentMap.delete(name);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/** @internal Remove an ArkFile from the file canonicalizer. Returns true if it existed. */
|
|
271
|
+
removeFile(file) {
|
|
272
|
+
const id = file.getFileSigID();
|
|
273
|
+
const existed = this.fileSigCanonicalizer.getModel(id) !== undefined;
|
|
274
|
+
this.fileSigCanonicalizer.removeModel(id);
|
|
275
|
+
return existed;
|
|
276
|
+
}
|
|
277
|
+
/** @internal Remove an ArkClass from the class canonicalizer and customComponentMap. Returns true if it existed. */
|
|
278
|
+
removeClass(arkClass) {
|
|
279
|
+
this.unregisterCustomComponent(arkClass);
|
|
280
|
+
const id = arkClass.getClassSigID();
|
|
281
|
+
const existed = this.classSigCanonicalizer.getModel(id) !== undefined;
|
|
282
|
+
this.classSigCanonicalizer.removeModel(id);
|
|
283
|
+
return existed;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* @internal Remove an ArkClass from the class canonicalizer without touching customComponentMap.
|
|
287
|
+
* Used by disposeModule where customComponentMap entries must survive module unload.
|
|
288
|
+
*/
|
|
289
|
+
removeClassModel(arkClass) {
|
|
290
|
+
const id = arkClass.getClassSigID();
|
|
291
|
+
const existed = this.classSigCanonicalizer.getModel(id) !== undefined;
|
|
292
|
+
this.classSigCanonicalizer.removeModel(id);
|
|
293
|
+
return existed;
|
|
294
|
+
}
|
|
295
|
+
/** @internal Remove an ArkMethod from the method canonicalizer (impl + declare slots). Returns true if any existed. */
|
|
296
|
+
removeMethod(method) {
|
|
297
|
+
var _a;
|
|
298
|
+
let existed = false;
|
|
299
|
+
const implID = method.getMethodSigID();
|
|
300
|
+
if (implID !== undefined && implID > 0) {
|
|
301
|
+
existed = this.methodSigCanonicalizer.getModel(implID) !== undefined;
|
|
302
|
+
this.methodSigCanonicalizer.removeModel(implID);
|
|
303
|
+
}
|
|
304
|
+
for (const declareID of (_a = method.getDeclareSigIDs()) !== null && _a !== void 0 ? _a : []) {
|
|
305
|
+
if (declareID > 0 && this.methodSigCanonicalizer.getModel(declareID) !== undefined) {
|
|
306
|
+
existed = true;
|
|
307
|
+
this.methodSigCanonicalizer.removeModel(declareID);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return existed;
|
|
311
|
+
}
|
|
312
|
+
/** @internal Remove an ArkNamespace from the namespace canonicalizer. Returns true if it existed. */
|
|
313
|
+
removeNamespace(namespace) {
|
|
314
|
+
const id = namespace.getNamespaceSigID();
|
|
315
|
+
const existed = this.namespaceSigCanonicalizer.getModel(id) !== undefined;
|
|
316
|
+
this.namespaceSigCanonicalizer.removeModel(id);
|
|
317
|
+
return existed;
|
|
318
|
+
}
|
|
319
|
+
/** @internal Remove an ArkField from the field canonicalizer. Returns true if it existed. */
|
|
320
|
+
removeField(field) {
|
|
321
|
+
const id = field.getFieldSigID();
|
|
322
|
+
const existed = this.fieldSigCanonicalizer.getModel(id) !== undefined;
|
|
323
|
+
this.fieldSigCanonicalizer.removeModel(id);
|
|
324
|
+
return existed;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Intern the 5 DEFAULT signatures to formal canonicalizers, each obtaining fixed ID 0.
|
|
328
|
+
* ID 0 does not correspond to any model (models[0] remains undefined).
|
|
329
|
+
*
|
|
330
|
+
* All value-object overloads resolve through `getInstance()`, but `instance` is assigned
|
|
331
|
+
* only after this constructor returns — hence every DEFAULT here is built via a
|
|
332
|
+
* SigID constructor overload with the already-interned file DEFAULT (ID 0).
|
|
333
|
+
*/
|
|
334
|
+
internDefaults() {
|
|
335
|
+
const fileDefault = new ArkSignature_1.FileSignature(Const_1.UNKNOWN_PROJECT_NAME, Const_1.UNKNOWN_FILE_NAME);
|
|
336
|
+
this.fileSigCanonicalizer.getOrCreateId(fileDefault);
|
|
337
|
+
this.classSigCanonicalizer.getOrCreateId(new ArkSignature_1.ClassSignature(Const_1.UNKNOWN_CLASS_NAME, 0, undefined));
|
|
338
|
+
this.namespaceSigCanonicalizer.getOrCreateId(new ArkSignature_1.NamespaceSignature(Const_1.UNKNOWN_NAMESPACE_NAME, 0, undefined));
|
|
339
|
+
this.fieldSigCanonicalizer.getOrCreateId(new ArkSignature_1.FieldSignature(Const_1.UNKNOWN_FIELD_NAME, 0, Type_1.UnknownType.getInstance(), false));
|
|
340
|
+
this.methodSigCanonicalizer.getOrCreateId(new ArkSignature_1.MethodSignature(0, new ArkSignature_1.MethodSubSignature(Const_1.UNKNOWN_METHOD_NAME, [], Type_1.UnknownType.getInstance(), false)));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
exports.SignatureCanonicalizerRegistry = SignatureCanonicalizerRegistry;
|