arkanalyzer 1.0.94 → 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.js +1 -1
- 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 +455 -265
- 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 +181 -53
- 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 +116 -71
- 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/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
|
@@ -13,17 +13,40 @@ export declare class ArkNamespace extends ArkBaseModel implements ArkExport {
|
|
|
13
13
|
private sourceCodes?;
|
|
14
14
|
/** The full positions of this namespace (can have multiple positions for merged namespaces). */
|
|
15
15
|
private originFullPositions;
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
16
|
+
/** @internal Formal FileSigID for the declaring file. -1 = not yet interned. */
|
|
17
|
+
private declaringFileID;
|
|
18
|
+
/** @internal Formal NamespaceSigID for the declaring namespace. undefined = top-level namespace (declaring is ArkFile). */
|
|
19
|
+
private declaringNamespaceSigID?;
|
|
20
|
+
/** @internal Formal NamespaceSigID of this namespace. -1 = not yet set. */
|
|
21
|
+
private namespaceSigID;
|
|
19
22
|
private exportInfos;
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
private
|
|
23
|
+
/** @internal Formal ClassSigID for the default class. -1 = not yet set. */
|
|
24
|
+
private defaultClassSigID;
|
|
25
|
+
/** @internal SigIDs of direct (top-level) child classes. undefined = no classes allocated yet. */
|
|
26
|
+
private topClassSigIDs?;
|
|
27
|
+
private topClassCount;
|
|
28
|
+
/** @internal SigIDs of direct (top-level) child namespaces. undefined = no namespaces allocated yet. */
|
|
29
|
+
private topNamespaceSigIDs?;
|
|
30
|
+
private topNamespaceCount;
|
|
31
|
+
/** @internal Get the Registry singleton. */
|
|
32
|
+
private get registry();
|
|
24
33
|
private anonymousClassNumber;
|
|
25
34
|
private anonymousNamespaceNumber;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Construct with declaring IDs and (optionally) the signature object instead.
|
|
37
|
+
*/
|
|
26
38
|
constructor();
|
|
39
|
+
/**
|
|
40
|
+
* Build directly from the declaring IDs and the (not yet registered) signature object.
|
|
41
|
+
* `setSignature` is the registration point: it interns the signature, assigns the
|
|
42
|
+
* NamespaceSigID, and registers this namespace as the model on first interning.
|
|
43
|
+
* @param declaringFileID - Formal FileSigID of the declaring file (top-level namespaces).
|
|
44
|
+
* @param declaringNamespaceSigID - Formal NamespaceSigID of the declaring (parent)
|
|
45
|
+
* namespace; omit for top-level namespaces.
|
|
46
|
+
* @param namespaceSignature - The signature object; not yet registered — registration
|
|
47
|
+
* happens inside via setSignature.
|
|
48
|
+
*/
|
|
49
|
+
constructor(declaringFileID: number, declaringNamespaceSigID?: number, namespaceSignature?: NamespaceSignature);
|
|
27
50
|
/**
|
|
28
51
|
* Returns the program language of the file where this namespace defined.
|
|
29
52
|
*/
|
|
@@ -32,7 +55,43 @@ export declare class ArkNamespace extends ArkBaseModel implements ArkExport {
|
|
|
32
55
|
getNamespace(namespaceSignature: NamespaceSignature): ArkNamespace | null;
|
|
33
56
|
getNamespaceWithName(namespaceName: string): ArkNamespace | null;
|
|
34
57
|
getNamespaces(): ArkNamespace[];
|
|
58
|
+
/** @internal Returns the SigIDs of direct child namespaces, or null if no namespaces exist. */
|
|
59
|
+
getTopNamespaceSigIDs(): Int32Array | null;
|
|
60
|
+
/** @internal Returns the number of direct child namespaces. */
|
|
61
|
+
getTopNamespaceCount(): number;
|
|
62
|
+
/** @internal Checks whether a namespace with the given SigID is a direct child of this namespace. */
|
|
63
|
+
hasTopNamespaceWithID(id: number): boolean;
|
|
64
|
+
/** @internal Returns the direct child namespace with the given SigID, or undefined. */
|
|
65
|
+
getTopNamespaceByID(id: number): ArkNamespace | undefined;
|
|
66
|
+
/** @internal Ensures the Int32Array has at least minCapacity slots. */
|
|
67
|
+
private ensureTopNamespaceCapacity;
|
|
68
|
+
/** @internal Appends a namespace SigID to the parallel index. */
|
|
69
|
+
private addTopNamespaceSigID;
|
|
70
|
+
/** @internal Removes a namespace SigID from the parallel index (swap-remove). */
|
|
71
|
+
private removeTopNamespaceSigID;
|
|
72
|
+
/** @internal Returns the SigIDs of direct child classes, or null if no classes exist. */
|
|
73
|
+
getTopClassSigIDs(): Int32Array | null;
|
|
74
|
+
/** @internal Returns the number of direct child classes. */
|
|
75
|
+
getTopClassCount(): number;
|
|
76
|
+
/** @internal Checks whether a class with the given SigID is a direct child of this namespace. */
|
|
77
|
+
hasTopClassWithID(id: number): boolean;
|
|
78
|
+
/** @internal Returns the direct child class with the given SigID, or undefined. */
|
|
79
|
+
getTopClassByID(id: number): ArkClass | undefined;
|
|
80
|
+
/** @internal Ensures the class Int32Array has at least minCapacity slots. */
|
|
81
|
+
private ensureTopClassCapacity;
|
|
82
|
+
/** @internal Appends a class SigID to the index. */
|
|
83
|
+
private addTopClassSigID;
|
|
84
|
+
/** @internal Removes a class SigID from the index (swap-remove). */
|
|
85
|
+
private removeTopClassSigID;
|
|
35
86
|
setSignature(namespaceSignature: NamespaceSignature): void;
|
|
87
|
+
/** @internal Get the formal NamespaceSigID of this namespace. */
|
|
88
|
+
getNamespaceSigID(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the unique ID of this model — the NamespaceSigID in the canonicalizer.
|
|
91
|
+
* The signature table and the model table share one dense ID space, so this ID
|
|
92
|
+
* resolves both the signature and the model.
|
|
93
|
+
*/
|
|
94
|
+
getId(): number;
|
|
36
95
|
getSignature(): NamespaceSignature;
|
|
37
96
|
getNamespaceSignature(): NamespaceSignature;
|
|
38
97
|
getName(): string;
|
|
@@ -101,15 +160,26 @@ export declare class ArkNamespace extends ArkBaseModel implements ArkExport {
|
|
|
101
160
|
*/
|
|
102
161
|
setOriginFullPositions(positions: FullPosition[]): void;
|
|
103
162
|
getDeclaringInstance(): ArkNamespace | ArkFile;
|
|
104
|
-
setDeclaringInstance(declaringInstance: ArkFile | ArkNamespace): void;
|
|
105
163
|
getDeclaringArkFile(): ArkFile;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use the ID-injecting constructor
|
|
166
|
+
* {@link constructor(declaringFileID, declaringNamespaceSigID, namespaceSignature)} or
|
|
167
|
+
* {@link setDeclaringFileID} instead.
|
|
168
|
+
*/
|
|
106
169
|
setDeclaringArkFile(declaringArkFile: ArkFile): void;
|
|
170
|
+
/** @internal Get the formal FileSigID of the declaring file. Returns -1 if not interned. */
|
|
171
|
+
getDeclaringFileID(): number;
|
|
107
172
|
getDeclaringArkNamespace(): ArkNamespace | null;
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated Use the ID-injecting constructor
|
|
175
|
+
* {@link constructor(declaringFileID, declaringNamespaceSigID, namespaceSignature)}
|
|
176
|
+
* instead — it covers both the parent SigID and the inherited file ID.
|
|
177
|
+
*/
|
|
108
178
|
setDeclaringArkNamespace(declaringArkNamespace: ArkNamespace): void;
|
|
109
179
|
getClass(classSignature: ClassSignature): ArkClass | null;
|
|
110
|
-
getClassWithName(
|
|
180
|
+
getClassWithName(className: string): ArkClass | null;
|
|
111
181
|
getClasses(): ArkClass[];
|
|
112
|
-
addArkClass(arkClass: ArkClass
|
|
182
|
+
addArkClass(arkClass: ArkClass): void;
|
|
113
183
|
getExportInfos(): ExportInfo[];
|
|
114
184
|
getExportInfoBy(name: string): ExportInfo | undefined;
|
|
115
185
|
addExportInfo(exportInfo: ExportInfo): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkNamespace.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkNamespace.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"ArkNamespace.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkNamespace.ts"],"names":[],"mappings":"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"}
|
|
@@ -20,22 +20,38 @@ const ArkSignature_1 = require("./ArkSignature");
|
|
|
20
20
|
const TSConst_1 = require("../common/TSConst");
|
|
21
21
|
const Position_1 = require("../base/Position");
|
|
22
22
|
const ArkBaseModel_1 = require("./ArkBaseModel");
|
|
23
|
-
const Const_1 = require("../common/Const");
|
|
24
23
|
const SdkUtils_1 = require("../common/SdkUtils");
|
|
25
|
-
const
|
|
24
|
+
const SignatureCanonicalizerRegistry_1 = require("../common/SignatureCanonicalizerRegistry");
|
|
26
25
|
/**
|
|
27
26
|
* @category core/model
|
|
28
27
|
*/
|
|
29
28
|
class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
30
|
-
|
|
29
|
+
/** @internal Get the Registry singleton. */
|
|
30
|
+
get registry() {
|
|
31
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
32
|
+
}
|
|
33
|
+
constructor(declaringFileID, declaringNamespaceSigID, namespaceSignature) {
|
|
31
34
|
super();
|
|
32
|
-
|
|
35
|
+
/** @internal Formal FileSigID for the declaring file. -1 = not yet interned. */
|
|
36
|
+
this.declaringFileID = -1;
|
|
37
|
+
/** @internal Formal NamespaceSigID of this namespace. -1 = not yet set. */
|
|
38
|
+
this.namespaceSigID = -1;
|
|
33
39
|
this.exportInfos = new Map();
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
40
|
+
/** @internal Formal ClassSigID for the default class. -1 = not yet set. */
|
|
41
|
+
this.defaultClassSigID = -1;
|
|
42
|
+
this.topClassCount = 0;
|
|
43
|
+
this.topNamespaceCount = 0;
|
|
37
44
|
this.anonymousClassNumber = 0;
|
|
38
45
|
this.anonymousNamespaceNumber = 0;
|
|
46
|
+
if (declaringFileID !== undefined) {
|
|
47
|
+
this.declaringFileID = declaringFileID;
|
|
48
|
+
}
|
|
49
|
+
if (declaringNamespaceSigID !== undefined) {
|
|
50
|
+
this.declaringNamespaceSigID = declaringNamespaceSigID;
|
|
51
|
+
}
|
|
52
|
+
if (namespaceSignature) {
|
|
53
|
+
this.setSignature(namespaceSignature);
|
|
54
|
+
}
|
|
39
55
|
}
|
|
40
56
|
/**
|
|
41
57
|
* Returns the program language of the file where this namespace defined.
|
|
@@ -44,36 +60,203 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
44
60
|
return this.getDeclaringArkFile().getLanguage();
|
|
45
61
|
}
|
|
46
62
|
addNamespace(namespace) {
|
|
47
|
-
const existing = this.
|
|
63
|
+
const existing = this.getNamespace(namespace.getSignature());
|
|
48
64
|
if (existing) {
|
|
49
65
|
// Merge content of namespaces with the same name
|
|
50
66
|
namespace.getClasses().forEach(cls => existing.addArkClass(cls));
|
|
51
67
|
namespace.getNamespaces().forEach(ns => existing.addNamespace(ns));
|
|
52
68
|
return;
|
|
53
69
|
}
|
|
54
|
-
this.
|
|
70
|
+
this.addTopNamespaceSigID(namespace.getNamespaceSigID());
|
|
55
71
|
}
|
|
56
72
|
getNamespace(namespaceSignature) {
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
var _a;
|
|
74
|
+
// O(1) 归属初筛:签名的 declaringNamespaceSigID 直比本 namespace 的 SigID。
|
|
75
|
+
const declaring = namespaceSignature.getDeclaringNamespaceSigID();
|
|
76
|
+
if (declaring !== undefined && declaring >= 0 && this.namespaceSigID >= 0 && declaring !== this.namespaceSigID) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const id = this.registry.namespaceSigCanonicalizer.getExistingId(namespaceSignature);
|
|
80
|
+
if (id !== -1 && this.hasTopNamespaceWithID(id)) {
|
|
81
|
+
return (_a = this.registry.namespaceSigCanonicalizer.getModel(id)) !== null && _a !== void 0 ? _a : null;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
59
84
|
}
|
|
60
85
|
getNamespaceWithName(namespaceName) {
|
|
61
|
-
|
|
86
|
+
// 精确匹配:拼本容器归属签名直查(复用 canonicalizer 值索引,O(1),对齐getClassWithName)。
|
|
87
|
+
if (this.namespaceSigID >= 0 && this.declaringFileID >= 0) {
|
|
88
|
+
return this.getNamespace(new ArkSignature_1.NamespaceSignature(namespaceName, this.declaringFileID, this.namespaceSigID));
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
62
91
|
}
|
|
63
92
|
getNamespaces() {
|
|
64
|
-
|
|
93
|
+
const arr = this.topNamespaceSigIDs;
|
|
94
|
+
if (!arr) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const reg = this.registry;
|
|
98
|
+
const result = [];
|
|
99
|
+
for (let i = 0; i < this.topNamespaceCount; i++) {
|
|
100
|
+
const ns = reg.namespaceSigCanonicalizer.getModel(arr[i]);
|
|
101
|
+
if (ns) {
|
|
102
|
+
result.push(ns);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
/** @internal Returns the SigIDs of direct child namespaces, or null if no namespaces exist. */
|
|
108
|
+
getTopNamespaceSigIDs() {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return (_b = (_a = this.topNamespaceSigIDs) === null || _a === void 0 ? void 0 : _a.subarray(0, this.topNamespaceCount)) !== null && _b !== void 0 ? _b : null;
|
|
111
|
+
}
|
|
112
|
+
/** @internal Returns the number of direct child namespaces. */
|
|
113
|
+
getTopNamespaceCount() {
|
|
114
|
+
return this.topNamespaceCount;
|
|
115
|
+
}
|
|
116
|
+
/** @internal Checks whether a namespace with the given SigID is a direct child of this namespace. */
|
|
117
|
+
hasTopNamespaceWithID(id) {
|
|
118
|
+
const arr = this.topNamespaceSigIDs;
|
|
119
|
+
if (!arr) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const count = this.topNamespaceCount;
|
|
123
|
+
for (let i = 0; i < count; i++) {
|
|
124
|
+
if (arr[i] === id) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
/** @internal Returns the direct child namespace with the given SigID, or undefined. */
|
|
131
|
+
getTopNamespaceByID(id) {
|
|
132
|
+
if (this.hasTopNamespaceWithID(id)) {
|
|
133
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().getNamespaceById(id);
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
/** @internal Ensures the Int32Array has at least minCapacity slots. */
|
|
138
|
+
ensureTopNamespaceCapacity(minCapacity) {
|
|
139
|
+
if (!this.topNamespaceSigIDs) {
|
|
140
|
+
this.topNamespaceSigIDs = new Int32Array(Math.max(minCapacity, 8));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (this.topNamespaceSigIDs.length < minCapacity) {
|
|
144
|
+
const newCapacity = Math.max(minCapacity, this.topNamespaceSigIDs.length * 2);
|
|
145
|
+
const newArray = new Int32Array(newCapacity);
|
|
146
|
+
newArray.set(this.topNamespaceSigIDs.subarray(0, this.topNamespaceCount));
|
|
147
|
+
this.topNamespaceSigIDs = newArray;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** @internal Appends a namespace SigID to the parallel index. */
|
|
151
|
+
addTopNamespaceSigID(id) {
|
|
152
|
+
this.ensureTopNamespaceCapacity(this.topNamespaceCount + 1);
|
|
153
|
+
this.topNamespaceSigIDs[this.topNamespaceCount++] = id;
|
|
154
|
+
}
|
|
155
|
+
/** @internal Removes a namespace SigID from the parallel index (swap-remove). */
|
|
156
|
+
removeTopNamespaceSigID(id) {
|
|
157
|
+
const arr = this.topNamespaceSigIDs;
|
|
158
|
+
if (!arr) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const count = this.topNamespaceCount;
|
|
162
|
+
for (let i = 0; i < count; i++) {
|
|
163
|
+
if (arr[i] === id) {
|
|
164
|
+
arr[i] = arr[--this.topNamespaceCount];
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** @internal Returns the SigIDs of direct child classes, or null if no classes exist. */
|
|
170
|
+
getTopClassSigIDs() {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
return (_b = (_a = this.topClassSigIDs) === null || _a === void 0 ? void 0 : _a.subarray(0, this.topClassCount)) !== null && _b !== void 0 ? _b : null;
|
|
173
|
+
}
|
|
174
|
+
/** @internal Returns the number of direct child classes. */
|
|
175
|
+
getTopClassCount() {
|
|
176
|
+
return this.topClassCount;
|
|
177
|
+
}
|
|
178
|
+
/** @internal Checks whether a class with the given SigID is a direct child of this namespace. */
|
|
179
|
+
hasTopClassWithID(id) {
|
|
180
|
+
const arr = this.topClassSigIDs;
|
|
181
|
+
if (!arr) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const count = this.topClassCount;
|
|
185
|
+
for (let i = 0; i < count; i++) {
|
|
186
|
+
if (arr[i] === id) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/** @internal Returns the direct child class with the given SigID, or undefined. */
|
|
193
|
+
getTopClassByID(id) {
|
|
194
|
+
if (this.hasTopClassWithID(id)) {
|
|
195
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().getClassById(id);
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
/** @internal Ensures the class Int32Array has at least minCapacity slots. */
|
|
200
|
+
ensureTopClassCapacity(minCapacity) {
|
|
201
|
+
if (!this.topClassSigIDs) {
|
|
202
|
+
this.topClassSigIDs = new Int32Array(Math.max(minCapacity, 8));
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (this.topClassSigIDs.length < minCapacity) {
|
|
206
|
+
const newCapacity = Math.max(minCapacity, this.topClassSigIDs.length * 2);
|
|
207
|
+
const newArray = new Int32Array(newCapacity);
|
|
208
|
+
newArray.set(this.topClassSigIDs.subarray(0, this.topClassCount));
|
|
209
|
+
this.topClassSigIDs = newArray;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** @internal Appends a class SigID to the index. */
|
|
213
|
+
addTopClassSigID(id) {
|
|
214
|
+
this.ensureTopClassCapacity(this.topClassCount + 1);
|
|
215
|
+
this.topClassSigIDs[this.topClassCount++] = id;
|
|
216
|
+
}
|
|
217
|
+
/** @internal Removes a class SigID from the index (swap-remove). */
|
|
218
|
+
removeTopClassSigID(id) {
|
|
219
|
+
const arr = this.topClassSigIDs;
|
|
220
|
+
if (!arr) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const count = this.topClassCount;
|
|
224
|
+
for (let i = 0; i < count; i++) {
|
|
225
|
+
if (arr[i] === id) {
|
|
226
|
+
arr[i] = arr[--this.topClassCount];
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
65
230
|
}
|
|
66
231
|
setSignature(namespaceSignature) {
|
|
67
|
-
|
|
232
|
+
// 三态处理(与 ArkClass.setSignature 对齐):
|
|
233
|
+
// 新值首建 → 注册;驱逐态恢复 → 补注册;已有别的 model 持有该签名 → 不覆盖。
|
|
234
|
+
const existing = this.registry.namespaceSigCanonicalizer.getExistingId(namespaceSignature);
|
|
235
|
+
this.namespaceSigID = existing >= 0 ? existing : this.registry.namespaceSigCanonicalizer.getOrCreateId(namespaceSignature);
|
|
236
|
+
if (existing < 0 || this.registry.namespaceSigCanonicalizer.getModel(existing) === undefined) {
|
|
237
|
+
this.registry.registerNamespace(this);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** @internal Get the formal NamespaceSigID of this namespace. */
|
|
241
|
+
getNamespaceSigID() {
|
|
242
|
+
return this.namespaceSigID;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Returns the unique ID of this model — the NamespaceSigID in the canonicalizer.
|
|
246
|
+
* The signature table and the model table share one dense ID space, so this ID
|
|
247
|
+
* resolves both the signature and the model.
|
|
248
|
+
*/
|
|
249
|
+
getId() {
|
|
250
|
+
return this.namespaceSigID;
|
|
68
251
|
}
|
|
69
252
|
getSignature() {
|
|
70
|
-
return this.
|
|
253
|
+
return this.registry.namespaceSigCanonicalizer.get(this.namespaceSigID);
|
|
71
254
|
}
|
|
72
255
|
getNamespaceSignature() {
|
|
73
|
-
return this.
|
|
256
|
+
return this.getSignature();
|
|
74
257
|
}
|
|
75
258
|
getName() {
|
|
76
|
-
return this.
|
|
259
|
+
return this.getSignature().getNamespaceName();
|
|
77
260
|
}
|
|
78
261
|
getCode() {
|
|
79
262
|
const codes = this.getCodes();
|
|
@@ -83,8 +266,7 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
83
266
|
* @deprecated Source text is now stored on ArkFile only. This method has no effect.
|
|
84
267
|
* @param _sourceCode - The source code (ignored).
|
|
85
268
|
*/
|
|
86
|
-
setCode(_sourceCode) {
|
|
87
|
-
}
|
|
269
|
+
setCode(_sourceCode) { }
|
|
88
270
|
/**
|
|
89
271
|
* Returns the source texts of this namespace extracted from the declaring ArkFile
|
|
90
272
|
* using the namespace's origin positions. Implements lazy loading with caching.
|
|
@@ -95,9 +277,9 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
95
277
|
if (this.sourceCodes !== undefined) {
|
|
96
278
|
return this.sourceCodes;
|
|
97
279
|
}
|
|
98
|
-
const
|
|
280
|
+
const file = this.getDeclaringArkFile();
|
|
99
281
|
const codes = this.originFullPositions
|
|
100
|
-
.map(position =>
|
|
282
|
+
.map(position => file.getSourceTextByFullPosition(position))
|
|
101
283
|
.filter((code) => code !== undefined);
|
|
102
284
|
this.sourceCodes = codes;
|
|
103
285
|
return codes;
|
|
@@ -106,14 +288,12 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
106
288
|
* @deprecated Source text is now stored on ArkFile only. This method has no effect.
|
|
107
289
|
* @param _sourceCodes - The source codes array (ignored).
|
|
108
290
|
*/
|
|
109
|
-
setCodes(_sourceCodes) {
|
|
110
|
-
}
|
|
291
|
+
setCodes(_sourceCodes) { }
|
|
111
292
|
/**
|
|
112
293
|
* @deprecated Source text is now stored on ArkFile only. This method has no effect.
|
|
113
294
|
* @param _sourceCode - The source code (ignored).
|
|
114
295
|
*/
|
|
115
|
-
addCode(_sourceCode) {
|
|
116
|
-
}
|
|
296
|
+
addCode(_sourceCode) { }
|
|
117
297
|
/**
|
|
118
298
|
* @deprecated Use getOriginFullPositions()[0]?.getFirstLine() instead.
|
|
119
299
|
* @returns The line number of the first namespace position.
|
|
@@ -193,48 +373,88 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
193
373
|
this.originFullPositions = [...positions];
|
|
194
374
|
}
|
|
195
375
|
getDeclaringInstance() {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
376
|
+
const ns = this.getDeclaringArkNamespace();
|
|
377
|
+
if (ns) {
|
|
378
|
+
return ns;
|
|
379
|
+
}
|
|
380
|
+
return this.getDeclaringArkFile();
|
|
200
381
|
}
|
|
201
382
|
getDeclaringArkFile() {
|
|
202
|
-
|
|
383
|
+
if (this.declaringFileID !== -1) {
|
|
384
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fileSigCanonicalizer.getModel(this.declaringFileID);
|
|
385
|
+
}
|
|
386
|
+
return undefined;
|
|
203
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* @deprecated Use the ID-injecting constructor
|
|
390
|
+
* {@link constructor(declaringFileID, declaringNamespaceSigID, namespaceSignature)} or
|
|
391
|
+
* {@link setDeclaringFileID} instead.
|
|
392
|
+
*/
|
|
204
393
|
setDeclaringArkFile(declaringArkFile) {
|
|
205
|
-
this.
|
|
394
|
+
this.declaringFileID = declaringArkFile.getFileSigID();
|
|
395
|
+
}
|
|
396
|
+
/** @internal Get the formal FileSigID of the declaring file. Returns -1 if not interned. */
|
|
397
|
+
getDeclaringFileID() {
|
|
398
|
+
return this.declaringFileID;
|
|
206
399
|
}
|
|
207
400
|
getDeclaringArkNamespace() {
|
|
208
|
-
|
|
401
|
+
var _a;
|
|
402
|
+
if (this.declaringNamespaceSigID !== undefined) {
|
|
403
|
+
return (_a = this.registry.namespaceSigCanonicalizer.getModel(this.declaringNamespaceSigID)) !== null && _a !== void 0 ? _a : null;
|
|
404
|
+
}
|
|
405
|
+
return null;
|
|
209
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* @deprecated Use the ID-injecting constructor
|
|
409
|
+
* {@link constructor(declaringFileID, declaringNamespaceSigID, namespaceSignature)}
|
|
410
|
+
* instead — it covers both the parent SigID and the inherited file ID.
|
|
411
|
+
*/
|
|
210
412
|
setDeclaringArkNamespace(declaringArkNamespace) {
|
|
211
|
-
this.
|
|
413
|
+
this.declaringNamespaceSigID = declaringArkNamespace.getNamespaceSigID();
|
|
414
|
+
this.declaringFileID = declaringArkNamespace.getDeclaringFileID();
|
|
212
415
|
}
|
|
213
416
|
getClass(classSignature) {
|
|
214
|
-
|
|
215
|
-
|
|
417
|
+
var _a;
|
|
418
|
+
// O(1) 归属初筛:签名的 declaringNamespaceSigID 直比本 namespace 的 SigID 顶层类签名该值为 undefined,直接 miss)。
|
|
419
|
+
// AliasClassSignature 的 hash/equals 继承父类三元组(originName + 双归属 SigID),与源签名值等价,getExistingId 直接命中,无需名字匹配。
|
|
420
|
+
if (classSignature.getDeclaringNamespaceSigID() !== this.namespaceSigID) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const id = this.registry.classSigCanonicalizer.getExistingId(classSignature);
|
|
424
|
+
if (id !== -1 && this.hasTopClassWithID(id)) {
|
|
425
|
+
return (_a = this.registry.classSigCanonicalizer.getModel(id)) !== null && _a !== void 0 ? _a : null;
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
216
428
|
}
|
|
217
|
-
getClassWithName(
|
|
218
|
-
|
|
429
|
+
getClassWithName(className) {
|
|
430
|
+
// 精确匹配:拼本容器归属签名直查(复用 canonicalizer 的值索引,O(1))
|
|
431
|
+
if (this.namespaceSigID >= 0 && this.declaringFileID >= 0) {
|
|
432
|
+
return this.getClass(ArkSignature_1.ClassSignature.probe(className, this.declaringFileID, this.namespaceSigID));
|
|
433
|
+
}
|
|
434
|
+
return null;
|
|
219
435
|
}
|
|
220
436
|
getClasses() {
|
|
221
|
-
|
|
437
|
+
const arr = this.topClassSigIDs;
|
|
438
|
+
if (!arr) {
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
const reg = this.registry;
|
|
442
|
+
const result = [];
|
|
443
|
+
for (let i = 0; i < this.topClassCount; i++) {
|
|
444
|
+
const cls = reg.classSigCanonicalizer.getModel(arr[i]);
|
|
445
|
+
if (cls) {
|
|
446
|
+
result.push(cls);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return result;
|
|
222
450
|
}
|
|
223
|
-
addArkClass(arkClass
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this.classes.set(name, arkClass);
|
|
451
|
+
addArkClass(arkClass) {
|
|
452
|
+
const existing = this.getTopClassByID(arkClass.getClassSigID());
|
|
453
|
+
if (existing) {
|
|
454
|
+
SdkUtils_1.SdkUtils.copyMembers(arkClass, existing);
|
|
228
455
|
}
|
|
229
456
|
else {
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
if (!originName && !arkClass.isAnonymousClass()) {
|
|
233
|
-
const index = name.indexOf(Const_1.NAME_DELIMITER);
|
|
234
|
-
if (index > 0) {
|
|
235
|
-
const originName = name.substring(0, index);
|
|
236
|
-
this.addArkClass(arkClass, originName);
|
|
237
|
-
}
|
|
457
|
+
this.addTopClassSigID(arkClass.getClassSigID());
|
|
238
458
|
}
|
|
239
459
|
}
|
|
240
460
|
getExportInfos() {
|
|
@@ -253,35 +473,39 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
253
473
|
this.exportInfos.set(exportInfo.getExportClauseName(), exportInfo);
|
|
254
474
|
}
|
|
255
475
|
getDefaultClass() {
|
|
256
|
-
|
|
476
|
+
if (this.defaultClassSigID !== -1) {
|
|
477
|
+
return this.registry.classSigCanonicalizer.getModel(this.defaultClassSigID);
|
|
478
|
+
}
|
|
479
|
+
return undefined;
|
|
257
480
|
}
|
|
258
481
|
setDefaultClass(defaultClass) {
|
|
259
|
-
this.
|
|
482
|
+
this.defaultClassSigID = defaultClass.getClassSigID();
|
|
260
483
|
}
|
|
261
484
|
getAllMethodsUnderThisNamespace() {
|
|
262
485
|
let methods = [];
|
|
263
|
-
this.
|
|
486
|
+
for (const cls of this.getClasses()) {
|
|
264
487
|
methods.push(...cls.getMethods());
|
|
265
|
-
}
|
|
266
|
-
this.
|
|
488
|
+
}
|
|
489
|
+
for (const ns of this.getNamespaces()) {
|
|
267
490
|
methods.push(...ns.getAllMethodsUnderThisNamespace());
|
|
268
|
-
}
|
|
491
|
+
}
|
|
269
492
|
return methods;
|
|
270
493
|
}
|
|
271
494
|
getAllClassesUnderThisNamespace() {
|
|
272
495
|
let classes = [];
|
|
273
|
-
classes.push(...this.
|
|
274
|
-
this.
|
|
496
|
+
classes.push(...this.getClasses());
|
|
497
|
+
for (const ns of this.getNamespaces()) {
|
|
275
498
|
classes.push(...ns.getAllClassesUnderThisNamespace());
|
|
276
|
-
}
|
|
499
|
+
}
|
|
277
500
|
return classes;
|
|
278
501
|
}
|
|
279
502
|
getAllNamespacesUnderThisNamespace() {
|
|
280
503
|
let namespaces = [];
|
|
281
|
-
|
|
282
|
-
|
|
504
|
+
const topNamespaces = this.getNamespaces();
|
|
505
|
+
namespaces.push(...topNamespaces);
|
|
506
|
+
for (const ns of topNamespaces) {
|
|
283
507
|
namespaces.push(...ns.getAllNamespacesUnderThisNamespace());
|
|
284
|
-
}
|
|
508
|
+
}
|
|
285
509
|
return namespaces;
|
|
286
510
|
}
|
|
287
511
|
getAnonymousClassNumber() {
|
|
@@ -294,35 +518,44 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
294
518
|
return ArkExport_1.ExportType.NAME_SPACE;
|
|
295
519
|
}
|
|
296
520
|
removeArkClass(arkClass) {
|
|
297
|
-
|
|
298
|
-
|
|
521
|
+
const id = arkClass.getClassSigID();
|
|
522
|
+
const rtn = this.hasTopClassWithID(id);
|
|
523
|
+
if (rtn) {
|
|
524
|
+
this.removeTopClassSigID(id);
|
|
525
|
+
this.registry.removeClass(arkClass);
|
|
526
|
+
}
|
|
299
527
|
return rtn;
|
|
300
528
|
}
|
|
301
529
|
removeNamespace(namespace) {
|
|
302
|
-
|
|
303
|
-
|
|
530
|
+
const id = namespace.getNamespaceSigID();
|
|
531
|
+
const rtn = this.hasTopNamespaceWithID(id);
|
|
532
|
+
if (rtn) {
|
|
533
|
+
this.removeTopNamespaceSigID(id);
|
|
534
|
+
this.registry.removeNamespace(namespace);
|
|
535
|
+
}
|
|
304
536
|
return rtn;
|
|
305
537
|
}
|
|
306
538
|
validate() {
|
|
307
|
-
return this.validateFields(['
|
|
539
|
+
return this.validateFields(['declaringFileID', 'namespaceSigID', 'defaultClassSigID']);
|
|
308
540
|
}
|
|
309
541
|
clearAllReferences() {
|
|
310
|
-
for (const cls of this.
|
|
542
|
+
for (const cls of this.getClasses()) {
|
|
311
543
|
cls.clearAllReferences();
|
|
312
544
|
}
|
|
313
|
-
for (const ns of this.
|
|
545
|
+
for (const ns of this.getNamespaces()) {
|
|
314
546
|
ns.clearAllReferences();
|
|
315
547
|
}
|
|
316
548
|
for (const exp of this.exportInfos.values()) {
|
|
317
549
|
exp.clearAllReferences();
|
|
318
550
|
}
|
|
319
|
-
this.
|
|
320
|
-
this.
|
|
551
|
+
this.topClassSigIDs = undefined;
|
|
552
|
+
this.topClassCount = 0;
|
|
553
|
+
this.topNamespaceSigIDs = undefined;
|
|
554
|
+
this.topNamespaceCount = 0;
|
|
321
555
|
this.exportInfos.clear();
|
|
322
|
-
this.
|
|
323
|
-
this.
|
|
324
|
-
this.
|
|
325
|
-
this.declaringInstance = undefined;
|
|
556
|
+
this.defaultClassSigID = -1;
|
|
557
|
+
this.declaringFileID = -1;
|
|
558
|
+
this.declaringNamespaceSigID = undefined;
|
|
326
559
|
}
|
|
327
560
|
}
|
|
328
561
|
exports.ArkNamespace = ArkNamespace;
|