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,69 @@
|
|
|
1
|
+
import { SignatureCanonicalizer, Canonicalizable } from './SignatureCanonicalizer';
|
|
2
|
+
/**
|
|
3
|
+
* A canonicalizer that stores both signature instances and model instances,
|
|
4
|
+
* unified by the same dense integer ID space.
|
|
5
|
+
*
|
|
6
|
+
* Extends {@link SignatureCanonicalizer} with a `models` array that maps
|
|
7
|
+
* ID → model object. This eliminates the need for a separate `Map<number, Model>`
|
|
8
|
+
* — the canonicalizer itself serves as both the signature registry and the model store.
|
|
9
|
+
*
|
|
10
|
+
* ID 0 is reserved for DEFAULT signatures and does not correspond to any model
|
|
11
|
+
* (`models[0]` remains `undefined`).
|
|
12
|
+
*
|
|
13
|
+
* @template S - The signature type, must implement {@link Canonicalizable}
|
|
14
|
+
* @template M - The model type associated with the signature
|
|
15
|
+
*/
|
|
16
|
+
export declare class SignatureModelCanonicalizer<S extends Canonicalizable, M> extends SignatureCanonicalizer<S> {
|
|
17
|
+
private models;
|
|
18
|
+
/**
|
|
19
|
+
* Register a model at the given ID.
|
|
20
|
+
*
|
|
21
|
+
* The ID must have been allocated by `getId(sig)` or `intern(sig)` first.
|
|
22
|
+
* Typically called right after `getId(sig)` returns a new or existing ID:
|
|
23
|
+
* ```
|
|
24
|
+
* const id = canonicalizer.getId(sig);
|
|
25
|
+
* canonicalizer.setModel(id, model);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param id - The integer ID (>= 0)
|
|
29
|
+
* @param model - The model to associate with this ID
|
|
30
|
+
*/
|
|
31
|
+
setModel(id: number, model: M): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the model associated with an integer ID.
|
|
34
|
+
*
|
|
35
|
+
* @param id - The integer ID
|
|
36
|
+
* @returns The model, or `undefined` if no model is registered at this ID
|
|
37
|
+
* (including ID 0 which is reserved for DEFAULT signatures)
|
|
38
|
+
*/
|
|
39
|
+
getModel(id: number): M | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Remove the model at the given ID.
|
|
42
|
+
*
|
|
43
|
+
* Sets `models[id]` to `undefined`. The ID itself is not recycled —
|
|
44
|
+
* the signature entry in the canonicalizer remains, but the model is no
|
|
45
|
+
* longer accessible via `getModel(id)`.
|
|
46
|
+
*
|
|
47
|
+
* @param id - The integer ID
|
|
48
|
+
*/
|
|
49
|
+
removeModel(id: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered models (excluding `undefined` entries).
|
|
52
|
+
*
|
|
53
|
+
* @returns An array of all models currently registered
|
|
54
|
+
*/
|
|
55
|
+
getModels(): M[];
|
|
56
|
+
/**
|
|
57
|
+
* Clear all registered models, keeping the signature table intact.
|
|
58
|
+
*
|
|
59
|
+
* Used when models need to be rebuilt (e.g., after type inference modifies
|
|
60
|
+
* method signatures) but the signature ID mappings should remain stable.
|
|
61
|
+
* Unlike {@link clear}, the signature canonicalizer entries are preserved.
|
|
62
|
+
*/
|
|
63
|
+
clearModels(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Clear all signatures, models, and reset the canonicalizer.
|
|
66
|
+
*/
|
|
67
|
+
clear(): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=SignatureModelCanonicalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureModelCanonicalizer.d.ts","sourceRoot":"","sources":["../../../src/core/common/SignatureModelCanonicalizer.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEnF;;;;;;;;;;;;;GAaG;AACH,qBAAa,2BAA2B,CAAC,CAAC,SAAS,eAAe,EAAE,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC,CAAC;IACpG,OAAO,CAAC,MAAM,CAAyB;IAEvC;;;;;;;;;;;;OAYG;IACI,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAI3C;;;;;;OAMG;IACI,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI1C;;;;;;;;OAQG;IACI,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIpC;;;;OAIG;IACI,SAAS,IAAI,CAAC,EAAE;IAWvB;;;;;;OAMG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,KAAK,IAAI,IAAI;CAIvB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
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.SignatureModelCanonicalizer = void 0;
|
|
18
|
+
const SignatureCanonicalizer_1 = require("./SignatureCanonicalizer");
|
|
19
|
+
/**
|
|
20
|
+
* A canonicalizer that stores both signature instances and model instances,
|
|
21
|
+
* unified by the same dense integer ID space.
|
|
22
|
+
*
|
|
23
|
+
* Extends {@link SignatureCanonicalizer} with a `models` array that maps
|
|
24
|
+
* ID → model object. This eliminates the need for a separate `Map<number, Model>`
|
|
25
|
+
* — the canonicalizer itself serves as both the signature registry and the model store.
|
|
26
|
+
*
|
|
27
|
+
* ID 0 is reserved for DEFAULT signatures and does not correspond to any model
|
|
28
|
+
* (`models[0]` remains `undefined`).
|
|
29
|
+
*
|
|
30
|
+
* @template S - The signature type, must implement {@link Canonicalizable}
|
|
31
|
+
* @template M - The model type associated with the signature
|
|
32
|
+
*/
|
|
33
|
+
class SignatureModelCanonicalizer extends SignatureCanonicalizer_1.SignatureCanonicalizer {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.models = [];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Register a model at the given ID.
|
|
40
|
+
*
|
|
41
|
+
* The ID must have been allocated by `getId(sig)` or `intern(sig)` first.
|
|
42
|
+
* Typically called right after `getId(sig)` returns a new or existing ID:
|
|
43
|
+
* ```
|
|
44
|
+
* const id = canonicalizer.getId(sig);
|
|
45
|
+
* canonicalizer.setModel(id, model);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param id - The integer ID (>= 0)
|
|
49
|
+
* @param model - The model to associate with this ID
|
|
50
|
+
*/
|
|
51
|
+
setModel(id, model) {
|
|
52
|
+
this.models[id] = model;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the model associated with an integer ID.
|
|
56
|
+
*
|
|
57
|
+
* @param id - The integer ID
|
|
58
|
+
* @returns The model, or `undefined` if no model is registered at this ID
|
|
59
|
+
* (including ID 0 which is reserved for DEFAULT signatures)
|
|
60
|
+
*/
|
|
61
|
+
getModel(id) {
|
|
62
|
+
return this.models[id];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Remove the model at the given ID.
|
|
66
|
+
*
|
|
67
|
+
* Sets `models[id]` to `undefined`. The ID itself is not recycled —
|
|
68
|
+
* the signature entry in the canonicalizer remains, but the model is no
|
|
69
|
+
* longer accessible via `getModel(id)`.
|
|
70
|
+
*
|
|
71
|
+
* @param id - The integer ID
|
|
72
|
+
*/
|
|
73
|
+
removeModel(id) {
|
|
74
|
+
this.models[id] = undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get all registered models (excluding `undefined` entries).
|
|
78
|
+
*
|
|
79
|
+
* @returns An array of all models currently registered
|
|
80
|
+
*/
|
|
81
|
+
getModels() {
|
|
82
|
+
const result = [];
|
|
83
|
+
for (let i = 0; i < this.models.length; i++) {
|
|
84
|
+
const m = this.models[i];
|
|
85
|
+
if (m !== undefined) {
|
|
86
|
+
result.push(m);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Clear all registered models, keeping the signature table intact.
|
|
93
|
+
*
|
|
94
|
+
* Used when models need to be rebuilt (e.g., after type inference modifies
|
|
95
|
+
* method signatures) but the signature ID mappings should remain stable.
|
|
96
|
+
* Unlike {@link clear}, the signature canonicalizer entries are preserved.
|
|
97
|
+
*/
|
|
98
|
+
clearModels() {
|
|
99
|
+
this.models = [];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Clear all signatures, models, and reset the canonicalizer.
|
|
103
|
+
*/
|
|
104
|
+
clear() {
|
|
105
|
+
super.clear();
|
|
106
|
+
this.models = [];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.SignatureModelCanonicalizer = SignatureModelCanonicalizer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StmtUseReplacer.d.ts","sourceRoot":"","sources":["../../../src/core/common/StmtUseReplacer.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAwE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"StmtUseReplacer.d.ts","sourceRoot":"","sources":["../../../src/core/common/StmtUseReplacer.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAwE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAMtC;;GAEG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAKjC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAejC,OAAO,CAAC,0BAA0B;IASlC,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,aAAa;CAMxB"}
|
|
@@ -30,6 +30,7 @@ class StmtUseReplacer {
|
|
|
30
30
|
this.newUse = newUse;
|
|
31
31
|
}
|
|
32
32
|
caseStmt(stmt) {
|
|
33
|
+
this.transferInvokeFullPosition();
|
|
33
34
|
if (stmt instanceof Stmt_1.ArkAssignStmt) {
|
|
34
35
|
this.caseAssignStmt(stmt);
|
|
35
36
|
}
|
|
@@ -46,6 +47,14 @@ class StmtUseReplacer {
|
|
|
46
47
|
this.caseThrowStmt(stmt);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
transferInvokeFullPosition() {
|
|
51
|
+
if (this.oldUse instanceof Expr_1.AbstractInvokeExpr && this.newUse instanceof Expr_1.AbstractInvokeExpr) {
|
|
52
|
+
const pos = this.oldUse.getInvokeFullPosition();
|
|
53
|
+
if (pos) {
|
|
54
|
+
this.newUse.setInvokeFullPosition(pos);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
49
58
|
caseAssignStmt(stmt) {
|
|
50
59
|
const lValue = stmt.getLeftOp();
|
|
51
60
|
if (lValue instanceof Ref_1.AbstractRef) {
|
|
@@ -2,17 +2,28 @@ import { FullPosition } from '../base/Position';
|
|
|
2
2
|
/**
|
|
3
3
|
* Deep copy a string to avoid sharing the original text reference from TypeScript AST nodes.
|
|
4
4
|
* This ensures that model objects do not implicitly depend on AST node lifecycles.
|
|
5
|
+
* Strings shorter than V8's kMinSlicedStringLength can never be sliced strings,
|
|
6
|
+
* so they cannot retain a larger parent and are returned as-is.
|
|
5
7
|
*/
|
|
6
8
|
export declare function cloneText(text: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Builds an array of absolute offsets of each line start in `sourceText`.
|
|
11
|
+
* Index 0 is always 0. Handles `\n` and `\r\n` the same way as position extraction.
|
|
12
|
+
* @param maxLineCount - When set, stop once this many line starts are collected
|
|
13
|
+
* (used by one-shot extract to avoid scanning the whole file).
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildLineStarts(sourceText: string, maxLineCount?: number): number[];
|
|
7
16
|
/**
|
|
8
17
|
* Extracts source text from the given source code using the specified full position.
|
|
9
18
|
* @param sourceText - The source code text, or undefined if not available.
|
|
10
19
|
* @param position - The full position (start/end line/col) specifying the range to extract.
|
|
20
|
+
* @param lineStarts - Optional precomputed line-start offsets (e.g. from {@link buildLineStarts}
|
|
21
|
+
* or `ArkFile.getLineStarts()`). When omitted, builds offsets only up to `endLine`.
|
|
11
22
|
* @returns The extracted source text, or undefined if:
|
|
12
23
|
* - sourceText is undefined or empty
|
|
13
24
|
* - position is undefined or FullPosition.DEFAULT
|
|
14
25
|
* - position has invalid line/col values (<=0)
|
|
15
26
|
* - position exceeds the source text boundaries
|
|
16
27
|
*/
|
|
17
|
-
export declare function extractSourceTextByFullPosition(sourceText: string | undefined, position: FullPosition | undefined): string | undefined;
|
|
28
|
+
export declare function extractSourceTextByFullPosition(sourceText: string | undefined, position: FullPosition | undefined, lineStarts?: readonly number[]): string | undefined;
|
|
18
29
|
//# sourceMappingURL=StringUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/StringUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"StringUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/StringUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAYnF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC3C,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,GAC/B,MAAM,GAAG,SAAS,CA6BpB"}
|
|
@@ -14,27 +14,56 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.extractSourceTextByFullPosition = exports.cloneText = void 0;
|
|
17
|
+
exports.extractSourceTextByFullPosition = exports.buildLineStarts = exports.cloneText = void 0;
|
|
18
18
|
const Position_1 = require("../base/Position");
|
|
19
|
+
const MIN_SLICED_STRING_LENGTH = 13;
|
|
19
20
|
/**
|
|
20
21
|
* Deep copy a string to avoid sharing the original text reference from TypeScript AST nodes.
|
|
21
22
|
* This ensures that model objects do not implicitly depend on AST node lifecycles.
|
|
23
|
+
* Strings shorter than V8's kMinSlicedStringLength can never be sliced strings,
|
|
24
|
+
* so they cannot retain a larger parent and are returned as-is.
|
|
22
25
|
*/
|
|
23
26
|
function cloneText(text) {
|
|
24
|
-
|
|
27
|
+
if (text.length < MIN_SLICED_STRING_LENGTH) {
|
|
28
|
+
return text;
|
|
29
|
+
}
|
|
30
|
+
return Buffer.from(text, 'utf8').toString('utf8');
|
|
25
31
|
}
|
|
26
32
|
exports.cloneText = cloneText;
|
|
33
|
+
/**
|
|
34
|
+
* Builds an array of absolute offsets of each line start in `sourceText`.
|
|
35
|
+
* Index 0 is always 0. Handles `\n` and `\r\n` the same way as position extraction.
|
|
36
|
+
* @param maxLineCount - When set, stop once this many line starts are collected
|
|
37
|
+
* (used by one-shot extract to avoid scanning the whole file).
|
|
38
|
+
*/
|
|
39
|
+
function buildLineStarts(sourceText, maxLineCount) {
|
|
40
|
+
const lineStarts = [0];
|
|
41
|
+
const len = sourceText.length;
|
|
42
|
+
for (let i = 0; i < len && (maxLineCount === undefined || lineStarts.length < maxLineCount); i++) {
|
|
43
|
+
if (sourceText[i] === '\n') {
|
|
44
|
+
lineStarts.push(i + 1);
|
|
45
|
+
}
|
|
46
|
+
else if (sourceText[i] === '\r' && i + 1 < len && sourceText[i + 1] === '\n') {
|
|
47
|
+
lineStarts.push(i + 2);
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return lineStarts;
|
|
52
|
+
}
|
|
53
|
+
exports.buildLineStarts = buildLineStarts;
|
|
27
54
|
/**
|
|
28
55
|
* Extracts source text from the given source code using the specified full position.
|
|
29
56
|
* @param sourceText - The source code text, or undefined if not available.
|
|
30
57
|
* @param position - The full position (start/end line/col) specifying the range to extract.
|
|
58
|
+
* @param lineStarts - Optional precomputed line-start offsets (e.g. from {@link buildLineStarts}
|
|
59
|
+
* or `ArkFile.getLineStarts()`). When omitted, builds offsets only up to `endLine`.
|
|
31
60
|
* @returns The extracted source text, or undefined if:
|
|
32
61
|
* - sourceText is undefined or empty
|
|
33
62
|
* - position is undefined or FullPosition.DEFAULT
|
|
34
63
|
* - position has invalid line/col values (<=0)
|
|
35
64
|
* - position exceeds the source text boundaries
|
|
36
65
|
*/
|
|
37
|
-
function extractSourceTextByFullPosition(sourceText, position) {
|
|
66
|
+
function extractSourceTextByFullPosition(sourceText, position, lineStarts) {
|
|
38
67
|
if (!sourceText || !position || position === Position_1.FullPosition.DEFAULT) {
|
|
39
68
|
return undefined;
|
|
40
69
|
}
|
|
@@ -46,23 +75,13 @@ function extractSourceTextByFullPosition(sourceText, position) {
|
|
|
46
75
|
return undefined;
|
|
47
76
|
}
|
|
48
77
|
const len = sourceText.length;
|
|
49
|
-
const
|
|
50
|
-
// Only iterate up to endLine to avoid traversing the entire file
|
|
51
|
-
for (let i = 0; i < len && lineStarts.length < endLine; i++) {
|
|
52
|
-
if (sourceText[i] === '\n') {
|
|
53
|
-
lineStarts.push(i + 1);
|
|
54
|
-
}
|
|
55
|
-
else if (sourceText[i] === '\r' && i + 1 < len && sourceText[i + 1] === '\n') {
|
|
56
|
-
lineStarts.push(i + 2);
|
|
57
|
-
i++;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
78
|
+
const starts = lineStarts !== null && lineStarts !== void 0 ? lineStarts : buildLineStarts(sourceText, endLine);
|
|
60
79
|
// Check if there are enough lines
|
|
61
|
-
if (startLine >
|
|
80
|
+
if (startLine > starts.length || endLine > starts.length) {
|
|
62
81
|
return undefined;
|
|
63
82
|
}
|
|
64
|
-
const startIdx =
|
|
65
|
-
const endIdx =
|
|
83
|
+
const startIdx = starts[startLine - 1] + startCol - 1;
|
|
84
|
+
const endIdx = starts[endLine - 1] + endCol - 1;
|
|
66
85
|
if (startIdx >= len || endIdx > len || startIdx >= endIdx) {
|
|
67
86
|
return undefined;
|
|
68
87
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 临时签名的索引表(组合 Canonicalizer.objectIdentity 策略)。
|
|
3
|
+
*
|
|
4
|
+
* 组合设计:注册/查ID/get/clear 委托 inner Canonicalizer(objectIdentity——Symbol 幂等
|
|
5
|
+
* + 稠密 ID + 数组存储);本类仅追加 temp 空间独有的 retire(迁移置空)与替换记录。
|
|
6
|
+
*
|
|
7
|
+
* retire 状态与归宿记录合并存储在单个三态槽表 {@link retireSlots}(4B/ID):
|
|
8
|
+
* 0 = live;-1 = 已迁移无归宿;>0 = 已迁移且值为 formal 归宿(formalId ≥ 1,
|
|
9
|
+
* 0 为 DEFAULT 不可作归宿)。读写判定共用一次数组读,两份状态由单写点保证同步。
|
|
10
|
+
*
|
|
11
|
+
* 生命周期(全保留):未 retire 的条目永不清——完整注册审计表。"推导中间垃圾"
|
|
12
|
+
* 钉活到 Registry.dispose——知情权衡(JS 无法感知强可达对象的持有者消亡)。
|
|
13
|
+
* 三数自洽:totalRegistered(inner.size)= liveCount + retiredCount。
|
|
14
|
+
*/
|
|
15
|
+
export declare class TempSignatureCanonicalizer<S extends object> {
|
|
16
|
+
/** objectIdentity 策略的注册/查ID/get/clear 核心(Symbol 幂等 + 稠密 ID + list 数组)。 */
|
|
17
|
+
private readonly inner;
|
|
18
|
+
/**
|
|
19
|
+
* 三态槽表(下标 = temp SigID):0 = live;-1 = 已迁移无归宿;>0 = 已迁移,
|
|
20
|
+
* 值为 formal 归宿。get/getReplacement 的判定共用此一次数组读。
|
|
21
|
+
*/
|
|
22
|
+
private retireSlots;
|
|
23
|
+
/** 注册签名对象:同一实例重复注册复用同一 ID;新实例分配新 ID。扩容保证槽表覆盖全部已分配 ID。 */
|
|
24
|
+
register(sig: S): number;
|
|
25
|
+
/**
|
|
26
|
+
* 按 ID 取签名对象。已迁移(三态槽非 0)返回 undefined——消费方应查
|
|
27
|
+
* {@link getReplacement} 获得 formal 归宿(三级查的 fallback)。
|
|
28
|
+
* register 的同步扩容保证已分配 ID 均在槽表界内;越界(未注册)与负 ID
|
|
29
|
+
* 经 inner.get 返回 undefined。
|
|
30
|
+
*/
|
|
31
|
+
get(id: number): S | undefined;
|
|
32
|
+
/** 查询签名对象的 tempSigID,不注册。未注册返回 -1。Symbol 在 retire 后不清(审计追溯保留)。 */
|
|
33
|
+
getExistingTempId(sig: S): number;
|
|
34
|
+
/**
|
|
35
|
+
* 迁移置空(幂等)。合法性以 inner.size() 为权威上界(register 分配保证 id <
|
|
36
|
+
* inner.size(),且 inner.size 只增不减)+ inner 槽有值才迁移。槽表覆盖全部已分配
|
|
37
|
+
* ID 的不变式由 register 维护(分配即扩容),此处三态读界内安全。
|
|
38
|
+
*/
|
|
39
|
+
retire(id: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* 迁移置空 + 记录 formal 归宿(幂等;重复调用以首次记录为准——槽为 -1 才写入,
|
|
42
|
+
* 已 >0 不覆盖)。live 时先经 {@link retire} 迁移;从未注册的 ID 不记录归宿
|
|
43
|
+
* (live 态写归宿会污染 get 判定)。
|
|
44
|
+
*/
|
|
45
|
+
retireWithReplacement(id: number, formalId: number): void;
|
|
46
|
+
/** 查询迁移记录的 formal 归宿。-1 = 无记录(未迁移 / 已迁移无归宿)。 */
|
|
47
|
+
getReplacement(id: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* 未迁移量(去洞活数)= totalRegistered() - retiredCount()。
|
|
50
|
+
* Named liveCount (not size) on purpose: the composed Canonicalizer.size() returns the
|
|
51
|
+
* dense extent (holes included) — same name, opposite semantics silently breaks any
|
|
52
|
+
* loop bound or capacity check that treats the two as interchangeable containers.
|
|
53
|
+
* 三数自洽:totalRegistered = liveCount + retired。
|
|
54
|
+
*/
|
|
55
|
+
liveCount(): number;
|
|
56
|
+
/** 累计注册总量 = inner.size()(含已置空)。 */
|
|
57
|
+
totalRegistered(): number;
|
|
58
|
+
/** 已迁移总量 = 三态槽表非零槽数。三数自洽:totalRegistered = liveCount + retired。 */
|
|
59
|
+
retired(): number;
|
|
60
|
+
/** 全区间审计视图:[0, totalRegistered) 的全部 ID(含已置空——可经 getReplacement 追溯归宿)。 */
|
|
61
|
+
registeredIds(): number[];
|
|
62
|
+
/** 未迁移(非空 slot)的 ID 集视图。 */
|
|
63
|
+
liveIds(): number[];
|
|
64
|
+
/** 索引表统计(同步即精确;计数为遍历槽表,仅 statistics 低频调用)。 */
|
|
65
|
+
getStats(): {
|
|
66
|
+
liveCount: number;
|
|
67
|
+
totalRegistered: number;
|
|
68
|
+
retiredCount: number;
|
|
69
|
+
replacedCount: number;
|
|
70
|
+
};
|
|
71
|
+
/** 清空:委托 inner.clear(Symbol 清理 + 换新 Symbol + 重置),追加本层状态重置。 */
|
|
72
|
+
clear(): void;
|
|
73
|
+
private retiredCount;
|
|
74
|
+
private replacedCount;
|
|
75
|
+
/**
|
|
76
|
+
* 扩容。唯一调用点是 register(分配即扩容)——维护"槽表覆盖全部已分配 ID"
|
|
77
|
+
* 的不变式,所有读点的三态判定由此界内安全。快速路径一次下标比较;慢路径按
|
|
78
|
+
* inner.size ×1.1 前瞻扩容(推导期约 5% 的注册增长被余量直接吸收,全程零再扩容)。
|
|
79
|
+
*/
|
|
80
|
+
private ensureCapacity;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=TempSignatureCanonicalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TempSignatureCanonicalizer.d.ts","sourceRoot":"","sources":["../../../src/core/common/TempSignatureCanonicalizer.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;GAaG;AACH,qBAAa,0BAA0B,CAAC,CAAC,SAAS,MAAM;IACpD,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;IAElE;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAwB;IAE3C,yDAAyD;IAClD,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM;IAM/B;;;;;OAKG;IACI,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAOrC,kEAAkE;IAC3D,iBAAiB,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM;IAIxC;;;;OAIG;IACI,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAU/B;;;;OAIG;IACI,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOhE,gDAAgD;IACzC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAIzC;;;;;;OAMG;IACI,SAAS,IAAI,MAAM;IAI1B,mCAAmC;IAC5B,eAAe,IAAI,MAAM;IAIhC,mEAAmE;IAC5D,OAAO,IAAI,MAAM;IAIxB,yEAAyE;IAClE,aAAa,IAAI,MAAM,EAAE;IAQhC,4BAA4B;IACrB,OAAO,IAAI,MAAM,EAAE;IAU1B,8CAA8C;IACvC,QAAQ,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE;IAS9G,8DAA8D;IACvD,KAAK,IAAI,IAAI;IAKpB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,aAAa;IAUrB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CASzB"}
|
|
@@ -0,0 +1,177 @@
|
|
|
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.TempSignatureCanonicalizer = void 0;
|
|
18
|
+
const Canonicalizer_1 = require("../../utils/Canonicalizer");
|
|
19
|
+
/**
|
|
20
|
+
* 临时签名的索引表(组合 Canonicalizer.objectIdentity 策略)。
|
|
21
|
+
*
|
|
22
|
+
* 组合设计:注册/查ID/get/clear 委托 inner Canonicalizer(objectIdentity——Symbol 幂等
|
|
23
|
+
* + 稠密 ID + 数组存储);本类仅追加 temp 空间独有的 retire(迁移置空)与替换记录。
|
|
24
|
+
*
|
|
25
|
+
* retire 状态与归宿记录合并存储在单个三态槽表 {@link retireSlots}(4B/ID):
|
|
26
|
+
* 0 = live;-1 = 已迁移无归宿;>0 = 已迁移且值为 formal 归宿(formalId ≥ 1,
|
|
27
|
+
* 0 为 DEFAULT 不可作归宿)。读写判定共用一次数组读,两份状态由单写点保证同步。
|
|
28
|
+
*
|
|
29
|
+
* 生命周期(全保留):未 retire 的条目永不清——完整注册审计表。"推导中间垃圾"
|
|
30
|
+
* 钉活到 Registry.dispose——知情权衡(JS 无法感知强可达对象的持有者消亡)。
|
|
31
|
+
* 三数自洽:totalRegistered(inner.size)= liveCount + retiredCount。
|
|
32
|
+
*/
|
|
33
|
+
class TempSignatureCanonicalizer {
|
|
34
|
+
constructor() {
|
|
35
|
+
/** objectIdentity 策略的注册/查ID/get/clear 核心(Symbol 幂等 + 稠密 ID + list 数组)。 */
|
|
36
|
+
this.inner = new Canonicalizer_1.Canonicalizer();
|
|
37
|
+
/**
|
|
38
|
+
* 三态槽表(下标 = temp SigID):0 = live;-1 = 已迁移无归宿;>0 = 已迁移,
|
|
39
|
+
* 值为 formal 归宿。get/getReplacement 的判定共用此一次数组读。
|
|
40
|
+
*/
|
|
41
|
+
this.retireSlots = new Int32Array(1024);
|
|
42
|
+
}
|
|
43
|
+
/** 注册签名对象:同一实例重复注册复用同一 ID;新实例分配新 ID。扩容保证槽表覆盖全部已分配 ID。 */
|
|
44
|
+
register(sig) {
|
|
45
|
+
const id = this.inner.getId(sig);
|
|
46
|
+
this.ensureCapacity(id);
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 按 ID 取签名对象。已迁移(三态槽非 0)返回 undefined——消费方应查
|
|
51
|
+
* {@link getReplacement} 获得 formal 归宿(三级查的 fallback)。
|
|
52
|
+
* register 的同步扩容保证已分配 ID 均在槽表界内;越界(未注册)与负 ID
|
|
53
|
+
* 经 inner.get 返回 undefined。
|
|
54
|
+
*/
|
|
55
|
+
get(id) {
|
|
56
|
+
if (this.retireSlots[id] !== 0) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return this.inner.get(id);
|
|
60
|
+
}
|
|
61
|
+
/** 查询签名对象的 tempSigID,不注册。未注册返回 -1。Symbol 在 retire 后不清(审计追溯保留)。 */
|
|
62
|
+
getExistingTempId(sig) {
|
|
63
|
+
return this.inner.getExistingId(sig);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 迁移置空(幂等)。合法性以 inner.size() 为权威上界(register 分配保证 id <
|
|
67
|
+
* inner.size(),且 inner.size 只增不减)+ inner 槽有值才迁移。槽表覆盖全部已分配
|
|
68
|
+
* ID 的不变式由 register 维护(分配即扩容),此处三态读界内安全。
|
|
69
|
+
*/
|
|
70
|
+
retire(id) {
|
|
71
|
+
if (id < 0 || id >= this.inner.size() || this.inner.get(id) === undefined) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (this.retireSlots[id] === 0) {
|
|
75
|
+
this.retireSlots[id] = -1;
|
|
76
|
+
this.inner.removeAt(id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 迁移置空 + 记录 formal 归宿(幂等;重复调用以首次记录为准——槽为 -1 才写入,
|
|
81
|
+
* 已 >0 不覆盖)。live 时先经 {@link retire} 迁移;从未注册的 ID 不记录归宿
|
|
82
|
+
* (live 态写归宿会污染 get 判定)。
|
|
83
|
+
*/
|
|
84
|
+
retireWithReplacement(id, formalId) {
|
|
85
|
+
this.retire(id);
|
|
86
|
+
if (this.retireSlots[id] === -1) {
|
|
87
|
+
this.retireSlots[id] = formalId;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** 查询迁移记录的 formal 归宿。-1 = 无记录(未迁移 / 已迁移无归宿)。 */
|
|
91
|
+
getReplacement(id) {
|
|
92
|
+
return this.retireSlots[id] > 0 ? this.retireSlots[id] : -1;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 未迁移量(去洞活数)= totalRegistered() - retiredCount()。
|
|
96
|
+
* Named liveCount (not size) on purpose: the composed Canonicalizer.size() returns the
|
|
97
|
+
* dense extent (holes included) — same name, opposite semantics silently breaks any
|
|
98
|
+
* loop bound or capacity check that treats the two as interchangeable containers.
|
|
99
|
+
* 三数自洽:totalRegistered = liveCount + retired。
|
|
100
|
+
*/
|
|
101
|
+
liveCount() {
|
|
102
|
+
return this.totalRegistered() - this.retiredCount();
|
|
103
|
+
}
|
|
104
|
+
/** 累计注册总量 = inner.size()(含已置空)。 */
|
|
105
|
+
totalRegistered() {
|
|
106
|
+
return this.inner.size();
|
|
107
|
+
}
|
|
108
|
+
/** 已迁移总量 = 三态槽表非零槽数。三数自洽:totalRegistered = liveCount + retired。 */
|
|
109
|
+
retired() {
|
|
110
|
+
return this.retiredCount();
|
|
111
|
+
}
|
|
112
|
+
/** 全区间审计视图:[0, totalRegistered) 的全部 ID(含已置空——可经 getReplacement 追溯归宿)。 */
|
|
113
|
+
registeredIds() {
|
|
114
|
+
const ids = [];
|
|
115
|
+
for (let i = 0; i < this.inner.size(); i++) {
|
|
116
|
+
ids.push(i);
|
|
117
|
+
}
|
|
118
|
+
return ids;
|
|
119
|
+
}
|
|
120
|
+
/** 未迁移(非空 slot)的 ID 集视图。 */
|
|
121
|
+
liveIds() {
|
|
122
|
+
const ids = [];
|
|
123
|
+
for (let i = 0; i < this.inner.size(); i++) {
|
|
124
|
+
if (this.retireSlots[i] === 0 && this.inner.get(i) !== undefined) {
|
|
125
|
+
ids.push(i);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return ids;
|
|
129
|
+
}
|
|
130
|
+
/** 索引表统计(同步即精确;计数为遍历槽表,仅 statistics 低频调用)。 */
|
|
131
|
+
getStats() {
|
|
132
|
+
return {
|
|
133
|
+
liveCount: this.liveCount(),
|
|
134
|
+
totalRegistered: this.totalRegistered(),
|
|
135
|
+
retiredCount: this.retiredCount(),
|
|
136
|
+
replacedCount: this.replacedCount(),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** 清空:委托 inner.clear(Symbol 清理 + 换新 Symbol + 重置),追加本层状态重置。 */
|
|
140
|
+
clear() {
|
|
141
|
+
this.inner.clear();
|
|
142
|
+
this.retireSlots = new Int32Array(1024);
|
|
143
|
+
}
|
|
144
|
+
retiredCount() {
|
|
145
|
+
let count = 0;
|
|
146
|
+
for (let i = 0; i < this.retireSlots.length; i++) {
|
|
147
|
+
if (this.retireSlots[i] !== 0) {
|
|
148
|
+
count++;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return count;
|
|
152
|
+
}
|
|
153
|
+
replacedCount() {
|
|
154
|
+
let count = 0;
|
|
155
|
+
for (let i = 0; i < this.retireSlots.length; i++) {
|
|
156
|
+
if (this.retireSlots[i] > 0) {
|
|
157
|
+
count++;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return count;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 扩容。唯一调用点是 register(分配即扩容)——维护"槽表覆盖全部已分配 ID"
|
|
164
|
+
* 的不变式,所有读点的三态判定由此界内安全。快速路径一次下标比较;慢路径按
|
|
165
|
+
* inner.size ×1.1 前瞻扩容(推导期约 5% 的注册增长被余量直接吸收,全程零再扩容)。
|
|
166
|
+
*/
|
|
167
|
+
ensureCapacity(requiredIdx) {
|
|
168
|
+
if (requiredIdx < this.retireSlots.length) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const newLength = Math.ceil(this.inner.size() * 1.1);
|
|
172
|
+
const next = new Int32Array(newLength);
|
|
173
|
+
next.set(this.retireSlots);
|
|
174
|
+
this.retireSlots = next;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.TempSignatureCanonicalizer = TempSignatureCanonicalizer;
|