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,24 +13,53 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var
|
|
17
|
-
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
18
38
|
};
|
|
19
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.genSignature4ImportClause = exports.fileSignatureCompare = exports.classSignatureCompare = exports.methodSubSignatureCompare = exports.methodSignatureCompare = exports.fieldSignatureCompare = exports.AliasTypeSignature = exports.LocalSignature = exports.MethodSignature = exports.MethodSubSignature = exports.FieldSignature = exports.AliasClassSignature = exports.ClassSignature = exports.NamespaceSignature = exports.FileSignature = void 0;
|
|
21
|
-
const path_1 = __importDefault(require("path"));
|
|
40
|
+
exports.genSignature4ImportClause = exports.fileSignatureCompare = exports.classSignatureCompare = exports.methodSubSignatureCompare = exports.methodSignatureCompare = exports.fieldSignatureCompare = exports.AliasTypeSignature = exports.LocalSignature = exports.MethodSignature = exports.MethodSubSignature = exports.FieldSignature = exports.internAliasMethodSignature = exports.AliasClassSignature = exports.ClassSignature = exports.NamespaceSignature = exports.FileSignature = void 0;
|
|
22
41
|
const pathTransfer_1 = require("../../utils/pathTransfer");
|
|
23
42
|
const Type_1 = require("../base/Type");
|
|
24
43
|
const Const_1 = require("../common/Const");
|
|
25
|
-
const
|
|
44
|
+
const SignatureCanonicalizerRegistry_1 = require("../common/SignatureCanonicalizerRegistry");
|
|
45
|
+
const SignatureCanonicalizer_1 = require("../common/SignatureCanonicalizer");
|
|
46
|
+
const HashUtils_1 = require("../../utils/HashUtils");
|
|
47
|
+
const logger_1 = __importStar(require("../../utils/logger"));
|
|
26
48
|
/**
|
|
27
49
|
* @category core/model
|
|
28
50
|
*/
|
|
29
51
|
class FileSignature {
|
|
52
|
+
/** The canonical DEFAULT signature (formal sigID 0 in the registry). */
|
|
53
|
+
static get DEFAULT() {
|
|
54
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fileSigCanonicalizer.get(0);
|
|
55
|
+
}
|
|
30
56
|
constructor(projectName, fileName) {
|
|
31
57
|
this.projectName = projectName;
|
|
32
58
|
this.fileName = (0, pathTransfer_1.transfer2UnixPath)(fileName);
|
|
33
|
-
|
|
59
|
+
let h = 0xdeadbeef;
|
|
60
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(this.projectName));
|
|
61
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(this.fileName));
|
|
62
|
+
this.hashCode = h >>> 0;
|
|
34
63
|
}
|
|
35
64
|
getProjectName() {
|
|
36
65
|
return this.projectName;
|
|
@@ -41,65 +70,245 @@ class FileSignature {
|
|
|
41
70
|
toString() {
|
|
42
71
|
return `@${this.projectName}/${this.fileName}: `;
|
|
43
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated No longer used internally since the ID refactor: identity comparison
|
|
75
|
+
* uses {@link signatureEquals} (hash + equals), indexing uses the canonicalizer.
|
|
76
|
+
* Kept for backward compatibility only — for identity checks use `equals()`
|
|
77
|
+
* (with `getHashCode()` fast reject), for debug output use `toString()`.
|
|
78
|
+
*
|
|
79
|
+
* Implementation note: identity projection (= toString, projectName + fileName are the complete identity fields) — collision-free.
|
|
80
|
+
*/
|
|
44
81
|
toMapKey() {
|
|
45
|
-
return
|
|
82
|
+
return this.toString();
|
|
83
|
+
}
|
|
84
|
+
getHashCode() {
|
|
85
|
+
return this.hashCode;
|
|
86
|
+
}
|
|
87
|
+
equals(other) {
|
|
88
|
+
if (this === other) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return this.projectName === other.projectName && this.fileName === other.fileName;
|
|
92
|
+
}
|
|
93
|
+
/** @internal FileSignature is never unclear (it is the identity root). */
|
|
94
|
+
isUnclear() {
|
|
95
|
+
return false;
|
|
46
96
|
}
|
|
47
97
|
}
|
|
48
98
|
exports.FileSignature = FileSignature;
|
|
49
|
-
FileSignature.DEFAULT = new FileSignature(Const_1.UNKNOWN_PROJECT_NAME, Const_1.UNKNOWN_FILE_NAME);
|
|
50
99
|
class NamespaceSignature {
|
|
51
|
-
|
|
100
|
+
/** The canonical DEFAULT signature (formal sigID 0 in the registry). */
|
|
101
|
+
static get DEFAULT() {
|
|
102
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().namespaceSigCanonicalizer.get(0);
|
|
103
|
+
}
|
|
104
|
+
constructor(namespaceName, declaringFileOrID, declaringNSOrID) {
|
|
105
|
+
function computeHashCode(fileId, namespaceName, declaringNSId) {
|
|
106
|
+
let h = 0xdeadbeef;
|
|
107
|
+
h = (0, HashUtils_1.hashCombineU32)(h, fileId);
|
|
108
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(namespaceName));
|
|
109
|
+
h = (0, HashUtils_1.hashCombineU32)(h, declaringNSId !== null && declaringNSId !== void 0 ? declaringNSId : 0);
|
|
110
|
+
return h >>> 0;
|
|
111
|
+
}
|
|
52
112
|
this.namespaceName = namespaceName;
|
|
53
|
-
|
|
54
|
-
|
|
113
|
+
if (typeof declaringFileOrID === 'number') {
|
|
114
|
+
this.declaringFileSigID = declaringFileOrID;
|
|
115
|
+
this.declaringNamespaceSigID = typeof declaringNSOrID === 'number' ? declaringNSOrID : undefined;
|
|
116
|
+
this.hashCode = computeHashCode(this.declaringFileSigID, this.namespaceName, this.declaringNamespaceSigID);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
120
|
+
let fileSigID;
|
|
121
|
+
let nsSigID;
|
|
122
|
+
// FileSignature 永不 unclear——身份根。
|
|
123
|
+
const fileExistingId = reg.fileSigCanonicalizer.getExistingId(declaringFileOrID);
|
|
124
|
+
if (fileExistingId !== -1) {
|
|
125
|
+
fileSigID = fileExistingId;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
NamespaceSignature.logger.error(`Clear FileSignature declaring not interned — defaulting to ID 0: ${declaringFileOrID.toString()}`);
|
|
129
|
+
fileSigID = 0;
|
|
130
|
+
}
|
|
131
|
+
// namespace 无 temp 空间。
|
|
132
|
+
if (declaringNSOrID instanceof NamespaceSignature) {
|
|
133
|
+
if (declaringNSOrID.isUnclear()) {
|
|
134
|
+
NamespaceSignature.logger.error(`Unclear NamespaceSignature — marking -1: ${declaringNSOrID.toString()}`);
|
|
135
|
+
nsSigID = -1;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const nsExistingId = reg.namespaceSigCanonicalizer.getExistingId(declaringNSOrID);
|
|
139
|
+
if (nsExistingId !== -1) {
|
|
140
|
+
nsSigID = nsExistingId;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
NamespaceSignature.logger.error(`Clear NamespaceSignature declaring not interned — marking -1: ${declaringNSOrID.toString()}`);
|
|
144
|
+
nsSigID = -1;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.declaringFileSigID = fileSigID;
|
|
149
|
+
this.declaringNamespaceSigID = nsSigID;
|
|
150
|
+
this.hashCode = computeHashCode(this.declaringFileSigID, this.namespaceName, this.declaringNamespaceSigID);
|
|
55
151
|
}
|
|
56
152
|
getNamespaceName() {
|
|
57
153
|
return this.namespaceName;
|
|
58
154
|
}
|
|
155
|
+
/** @internal Get the formal NamespaceSigID of this signature (interning it if needed). */
|
|
156
|
+
getNamespaceSigID() {
|
|
157
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().namespaceSigCanonicalizer.getExistingId(this);
|
|
158
|
+
}
|
|
59
159
|
getDeclaringFileSignature() {
|
|
60
|
-
|
|
160
|
+
const sig = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fileSigCanonicalizer.get(this.declaringFileSigID);
|
|
161
|
+
if (sig !== undefined) {
|
|
162
|
+
return sig;
|
|
163
|
+
}
|
|
164
|
+
// Stale SigID (registry disposed and rebuilt): degrade to DEFAULT instead of crashing.
|
|
165
|
+
NamespaceSignature.logger.error(`NamespaceSignature '${this.namespaceName}' has a stale declaring file SigID ${this.declaringFileSigID}; returning DEFAULT.`);
|
|
166
|
+
return FileSignature.DEFAULT;
|
|
167
|
+
}
|
|
168
|
+
/** @internal Get the formal FileSigID of the declaring file. (Renamed from
|
|
169
|
+
* getDeclaringFileSigId to align the casing with ClassSignature/getFileSigID.) */
|
|
170
|
+
getDeclaringFileSigID() {
|
|
171
|
+
return this.declaringFileSigID;
|
|
172
|
+
}
|
|
173
|
+
/** @internal Get the formal NamespaceSigID of the declaring namespace. undefined = top-level. */
|
|
174
|
+
getDeclaringNamespaceSigID() {
|
|
175
|
+
return this.declaringNamespaceSigID;
|
|
61
176
|
}
|
|
62
177
|
getDeclaringNamespaceSignature() {
|
|
63
|
-
|
|
178
|
+
if (this.declaringNamespaceSigID === undefined) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const sig = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().namespaceSigCanonicalizer.get(this.declaringNamespaceSigID);
|
|
182
|
+
if (sig !== undefined) {
|
|
183
|
+
return sig;
|
|
184
|
+
}
|
|
185
|
+
// Stale SigID (registry disposed and rebuilt): degrade to DEFAULT instead of crashing.
|
|
186
|
+
NamespaceSignature.logger.error(`NamespaceSignature '${this.namespaceName}' has a stale declaring namespace SigID ${this.declaringNamespaceSigID}; returning DEFAULT.`);
|
|
187
|
+
return NamespaceSignature.DEFAULT;
|
|
64
188
|
}
|
|
65
189
|
toString() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else {
|
|
70
|
-
return this.declaringFileSignature.toString() + this.namespaceName;
|
|
190
|
+
const declaringNS = this.getDeclaringNamespaceSignature();
|
|
191
|
+
if (declaringNS !== null) {
|
|
192
|
+
return declaringNS.toString() + '.' + this.namespaceName;
|
|
71
193
|
}
|
|
194
|
+
return this.getDeclaringFileSignature().toString() + this.namespaceName;
|
|
72
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* @deprecated No longer used internally since the ID refactor: identity comparison
|
|
198
|
+
* uses {@link signatureEquals} (hash + equals), indexing uses the canonicalizer.
|
|
199
|
+
* Kept for backward compatibility only — for identity checks use `equals()`
|
|
200
|
+
* (with `getHashCode()` fast reject), for debug output use `toString()`.
|
|
201
|
+
*/
|
|
73
202
|
toMapKey() {
|
|
74
|
-
|
|
75
|
-
|
|
203
|
+
const declaringNS = this.getDeclaringNamespaceSignature();
|
|
204
|
+
if (declaringNS !== null) {
|
|
205
|
+
return declaringNS.toMapKey() + '.' + this.namespaceName;
|
|
76
206
|
}
|
|
77
|
-
|
|
78
|
-
|
|
207
|
+
return this.getDeclaringFileSignature().toMapKey() + this.namespaceName;
|
|
208
|
+
}
|
|
209
|
+
getHashCode() {
|
|
210
|
+
return this.hashCode;
|
|
211
|
+
}
|
|
212
|
+
equals(other) {
|
|
213
|
+
if (this === other) {
|
|
214
|
+
return true;
|
|
79
215
|
}
|
|
216
|
+
if (this.namespaceName !== other.namespaceName) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (this.declaringFileSigID !== other.declaringFileSigID) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
return this.declaringNamespaceSigID === other.declaringNamespaceSigID;
|
|
223
|
+
}
|
|
224
|
+
/** Whether this signature's declaring file is unknown (FileSignature.DEFAULT). */
|
|
225
|
+
isUnclear() {
|
|
226
|
+
return this.declaringFileSigID === 0 && this.namespaceName !== Const_1.UNKNOWN_NAMESPACE_NAME;
|
|
80
227
|
}
|
|
81
228
|
}
|
|
82
229
|
exports.NamespaceSignature = NamespaceSignature;
|
|
83
|
-
NamespaceSignature.
|
|
230
|
+
NamespaceSignature.logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'NamespaceSignature');
|
|
84
231
|
class ClassSignature {
|
|
85
|
-
|
|
232
|
+
/** The canonical DEFAULT signature (formal sigID 0 in the registry). */
|
|
233
|
+
static get DEFAULT() {
|
|
234
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().classSigCanonicalizer.get(0);
|
|
235
|
+
}
|
|
236
|
+
constructor(className, declaringFileOrID, declaringNSOrID) {
|
|
86
237
|
this.className = className;
|
|
87
|
-
|
|
88
|
-
|
|
238
|
+
if (typeof declaringFileOrID === 'number') {
|
|
239
|
+
this.declaringFileSigID = declaringFileOrID;
|
|
240
|
+
this.declaringNamespaceSigID = typeof declaringNSOrID === 'number' ? declaringNSOrID : undefined;
|
|
241
|
+
this.recomputeHashCode();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
let fileSigID;
|
|
245
|
+
let nsSigID;
|
|
246
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
247
|
+
// FileSignature 永不 unclear——身份根。
|
|
248
|
+
const fileExistingId = reg.fileSigCanonicalizer.getExistingId(declaringFileOrID);
|
|
249
|
+
if (fileExistingId !== -1) {
|
|
250
|
+
fileSigID = fileExistingId;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
ClassSignature.logger.error(`Clear FileSignature declaring not interned — defaulting to ID 0: ${declaringFileOrID.toString()}`);
|
|
254
|
+
fileSigID = 0;
|
|
255
|
+
}
|
|
256
|
+
// namespace 无 temp 空间。
|
|
257
|
+
if (declaringNSOrID instanceof NamespaceSignature) {
|
|
258
|
+
if (declaringNSOrID.isUnclear()) {
|
|
259
|
+
nsSigID = -1;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const nsExistingId = reg.namespaceSigCanonicalizer.getExistingId(declaringNSOrID);
|
|
263
|
+
if (nsExistingId !== -1) {
|
|
264
|
+
nsSigID = nsExistingId;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
ClassSignature.logger.error(`Clear NamespaceSignature declaring not interned — marking -1: ${declaringNSOrID.toString()}`);
|
|
268
|
+
nsSigID = -1;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
this.declaringFileSigID = fileSigID;
|
|
273
|
+
this.declaringNamespaceSigID = nsSigID;
|
|
274
|
+
this.recomputeHashCode();
|
|
89
275
|
}
|
|
90
276
|
/**
|
|
91
277
|
* Returns the declaring file signature.
|
|
92
278
|
* @returns The declaring file signature.
|
|
93
279
|
*/
|
|
94
280
|
getDeclaringFileSignature() {
|
|
95
|
-
|
|
281
|
+
const sig = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fileSigCanonicalizer.get(this.declaringFileSigID);
|
|
282
|
+
if (sig !== undefined) {
|
|
283
|
+
return sig;
|
|
284
|
+
}
|
|
285
|
+
// Stale SigID (registry disposed and rebuilt): degrade to DEFAULT instead of crashing.
|
|
286
|
+
ClassSignature.logger.error(`ClassSignature '${this.className}' has a stale declaring file SigID ${this.declaringFileSigID}; returning DEFAULT.`);
|
|
287
|
+
return FileSignature.DEFAULT;
|
|
96
288
|
}
|
|
97
289
|
/**
|
|
98
290
|
* Get the declaring namespace's signature.
|
|
99
291
|
* @returns the declaring namespace's signature.
|
|
100
292
|
*/
|
|
101
293
|
getDeclaringNamespaceSignature() {
|
|
102
|
-
|
|
294
|
+
if (this.declaringNamespaceSigID === undefined) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
const sig = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().namespaceSigCanonicalizer.get(this.declaringNamespaceSigID);
|
|
298
|
+
if (sig !== undefined) {
|
|
299
|
+
return sig;
|
|
300
|
+
}
|
|
301
|
+
// Stale SigID (registry disposed and rebuilt): degrade to DEFAULT instead of crashing.
|
|
302
|
+
ClassSignature.logger.error(`ClassSignature '${this.className}' has a stale declaring namespace SigID ${this.declaringNamespaceSigID}; returning DEFAULT.`);
|
|
303
|
+
return NamespaceSignature.DEFAULT;
|
|
304
|
+
}
|
|
305
|
+
/** @internal Get the formal FileSigID of the declaring file. */
|
|
306
|
+
getDeclaringFileSigID() {
|
|
307
|
+
return this.declaringFileSigID;
|
|
308
|
+
}
|
|
309
|
+
/** @internal Get the formal NamespaceSigID of the declaring namespace. Returns undefined for top-level classes. */
|
|
310
|
+
getDeclaringNamespaceSigID() {
|
|
311
|
+
return this.declaringNamespaceSigID;
|
|
103
312
|
}
|
|
104
313
|
/**
|
|
105
314
|
* Get the **string** name of class from the the class signature. The default value is `""`.
|
|
@@ -108,6 +317,34 @@ class ClassSignature {
|
|
|
108
317
|
getClassName() {
|
|
109
318
|
return this.className;
|
|
110
319
|
}
|
|
320
|
+
/** @internal Recompute the cached hash from the current parts (constructor and probe). */
|
|
321
|
+
recomputeHashCode() {
|
|
322
|
+
var _a;
|
|
323
|
+
let h = 0xdeadbeef;
|
|
324
|
+
h = (0, HashUtils_1.hashCombineU32)(h, this.declaringFileSigID);
|
|
325
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(this.className));
|
|
326
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (_a = this.declaringNamespaceSigID) !== null && _a !== void 0 ? _a : 0);
|
|
327
|
+
this.hashCode = h >>> 0;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* @internal Shared mutable probe for existence-check lookups (getClassWithName and
|
|
331
|
+
* friends), which built a throwaway ClassSignature - object plus string hash - on every
|
|
332
|
+
* probe (~1.5GB per full build). Consume the result in a single expression: the next
|
|
333
|
+
* probe call rewrites the parts. Never store or intern the returned instance.
|
|
334
|
+
*/
|
|
335
|
+
static probe(className, declaringFileSigID, declaringNamespaceSigID) {
|
|
336
|
+
let p = ClassSignature.probeInstance;
|
|
337
|
+
if (p === undefined) {
|
|
338
|
+
p = new ClassSignature(className, declaringFileSigID, declaringNamespaceSigID);
|
|
339
|
+
ClassSignature.probeInstance = p;
|
|
340
|
+
return p;
|
|
341
|
+
}
|
|
342
|
+
p.className = className;
|
|
343
|
+
p.declaringFileSigID = declaringFileSigID;
|
|
344
|
+
p.declaringNamespaceSigID = declaringNamespaceSigID;
|
|
345
|
+
p.recomputeHashCode();
|
|
346
|
+
return p;
|
|
347
|
+
}
|
|
111
348
|
/**
|
|
112
349
|
*
|
|
113
350
|
* @returns The name of the declare class.
|
|
@@ -122,6 +359,11 @@ class ClassSignature {
|
|
|
122
359
|
}
|
|
123
360
|
return this.className;
|
|
124
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* @deprecated Mutating the class name breaks the cached hash (the signature would intern
|
|
364
|
+
* to a different SigID than a freshly built one with the new name). Build a new
|
|
365
|
+
* ClassSignature instead.
|
|
366
|
+
*/
|
|
125
367
|
setClassName(className) {
|
|
126
368
|
this.className = className;
|
|
127
369
|
}
|
|
@@ -129,31 +371,82 @@ class ClassSignature {
|
|
|
129
371
|
return new Type_1.ClassType(this);
|
|
130
372
|
}
|
|
131
373
|
toString() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
else {
|
|
136
|
-
return this.declaringFileSignature.toString() + this.className;
|
|
374
|
+
const declaringNS = this.getDeclaringNamespaceSignature();
|
|
375
|
+
if (declaringNS !== null) {
|
|
376
|
+
return declaringNS.toString() + '.' + this.getClassName();
|
|
137
377
|
}
|
|
378
|
+
return this.getDeclaringFileSignature().toString() + this.getClassName();
|
|
138
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* @deprecated No longer used internally since the ID refactor: identity comparison
|
|
382
|
+
* uses {@link signatureEquals} (hash + equals), indexing uses the canonicalizer.
|
|
383
|
+
* Kept for backward compatibility only — for identity checks use `equals()`
|
|
384
|
+
* (with `getHashCode()` fast reject), for debug output use `toString()`.
|
|
385
|
+
*/
|
|
139
386
|
toMapKey() {
|
|
140
|
-
|
|
141
|
-
|
|
387
|
+
const declaringNS = this.getDeclaringNamespaceSignature();
|
|
388
|
+
if (declaringNS !== null) {
|
|
389
|
+
return declaringNS.toMapKey() + '.' + this.getClassName();
|
|
142
390
|
}
|
|
143
|
-
|
|
144
|
-
|
|
391
|
+
return this.getDeclaringFileSignature().toMapKey() + this.getClassName();
|
|
392
|
+
}
|
|
393
|
+
getHashCode() {
|
|
394
|
+
return this.hashCode;
|
|
395
|
+
}
|
|
396
|
+
equals(other) {
|
|
397
|
+
if (this === other) {
|
|
398
|
+
return true;
|
|
145
399
|
}
|
|
400
|
+
// display 归一化:alias 与任何普通签名值不等——alias 的身份含 aliasName 维度(见 AliasClassSignature.equals)。对称性由子类 equals 对非
|
|
401
|
+
// alias 返回 false 共同保证。
|
|
402
|
+
if (other instanceof AliasClassSignature) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
if (this.className !== other.className) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (this.declaringFileSigID !== other.declaringFileSigID) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
return this.declaringNamespaceSigID === other.declaringNamespaceSigID;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* @internal Whether this signature's declaring file is unknown (FileSignature.DEFAULT).
|
|
415
|
+
* Direct field check (no registry lookup): unclear iff declaring file is DEFAULT (FileSigID 0)
|
|
416
|
+
* and this is not the DEFAULT placeholder itself (distinguished by the '%unk' name).
|
|
417
|
+
* This is a hot path in Method/FieldSignature constructor temp/formal branching.
|
|
418
|
+
*/
|
|
419
|
+
isUnclear() {
|
|
420
|
+
return this.declaringFileSigID === 0 && this.className !== Const_1.UNKNOWN_CLASS_NAME;
|
|
146
421
|
}
|
|
147
422
|
}
|
|
148
423
|
exports.ClassSignature = ClassSignature;
|
|
149
|
-
ClassSignature.
|
|
424
|
+
ClassSignature.logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ClassSignature');
|
|
150
425
|
/**
|
|
151
426
|
* `AliasClassSignature` is used to extend `ClassSignature`, preserving the actual name used during invocation.
|
|
152
427
|
*/
|
|
153
428
|
class AliasClassSignature extends ClassSignature {
|
|
154
429
|
constructor(aliasName, signature) {
|
|
155
|
-
|
|
430
|
+
var _a;
|
|
431
|
+
super(signature.getClassName(), signature.getDeclaringFileSigID(), signature.getDeclaringNamespaceSigID());
|
|
156
432
|
this.aliasName = aliasName;
|
|
433
|
+
let h = 0xdeadbeef;
|
|
434
|
+
h = (0, HashUtils_1.hashCombineU32)(h, this.getDeclaringFileSigID());
|
|
435
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(aliasName));
|
|
436
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (_a = this.getDeclaringNamespaceSigID()) !== null && _a !== void 0 ? _a : 0);
|
|
437
|
+
this.aliasHashCode = h >>> 0;
|
|
438
|
+
// formal 直存 + 双注册 origin model。前置:origin 必已在 formal(两个产生点
|
|
439
|
+
// ——组件 pop 构建、Interface 替换——的前提都是真实类已注册);origin model
|
|
440
|
+
// 缺失时 alias 条目暂无 model(Validator M3 将暴露该形态)。
|
|
441
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
442
|
+
const aliasID = reg.classSigCanonicalizer.getOrCreateId(this);
|
|
443
|
+
const originID = reg.classSigCanonicalizer.getExistingId(signature);
|
|
444
|
+
if (originID !== -1) {
|
|
445
|
+
const originModel = reg.classSigCanonicalizer.getModel(originID);
|
|
446
|
+
if (originModel !== undefined) {
|
|
447
|
+
reg.classSigCanonicalizer.setModel(aliasID, originModel);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
157
450
|
}
|
|
158
451
|
/**
|
|
159
452
|
* Returns the name used in the code.
|
|
@@ -167,20 +460,206 @@ class AliasClassSignature extends ClassSignature {
|
|
|
167
460
|
getOriginName() {
|
|
168
461
|
return super.getClassName();
|
|
169
462
|
}
|
|
463
|
+
/** alias 身份 hash(aliasName 替代 origin className 参与)。 */
|
|
464
|
+
getHashCode() {
|
|
465
|
+
return this.aliasHashCode;
|
|
466
|
+
}
|
|
467
|
+
/** 比较 aliasName + origin 维度;alias 与普通签名永不相等。 */
|
|
468
|
+
equals(other) {
|
|
469
|
+
if (this === other) {
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
if (!(other instanceof AliasClassSignature)) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
if (this.aliasName !== other.aliasName) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
if (this.getDeclaringFileSigID() !== other.getDeclaringFileSigID()) {
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
return this.getDeclaringNamespaceSigID() === other.getDeclaringNamespaceSigID();
|
|
482
|
+
}
|
|
170
483
|
}
|
|
171
484
|
exports.AliasClassSignature = AliasClassSignature;
|
|
485
|
+
/**
|
|
486
|
+
* @internal
|
|
487
|
+
* display 归一化:将 alias MethodSignature intern 进 methodSig formal 空间并双注册 origin 的 ArkMethod model(与 AliasClassSignature 构造器的 class 侧双注册
|
|
488
|
+
* 对称)。产生点(组件 pop 构建 / Interface 替换)在把签名交给 expr 之前调用——expr 的 route() formal 命中持 SigID,scene.getMethod 经 getModel 直命中
|
|
489
|
+
* 真实方法(callgraph/ViewTree findMethod 全链路无需 fallback)。
|
|
490
|
+
*/
|
|
491
|
+
function internAliasMethodSignature(aliasSignature, originSignature) {
|
|
492
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
493
|
+
const aliasID = reg.methodSigCanonicalizer.getOrCreateId(aliasSignature);
|
|
494
|
+
const originID = reg.methodSigCanonicalizer.getExistingId(originSignature);
|
|
495
|
+
if (originID === -1) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
const originModel = reg.methodSigCanonicalizer.getModel(originID);
|
|
499
|
+
if (originModel !== undefined) {
|
|
500
|
+
reg.methodSigCanonicalizer.setModel(aliasID, originModel);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
exports.internAliasMethodSignature = internAliasMethodSignature;
|
|
172
504
|
class FieldSignature {
|
|
173
|
-
|
|
505
|
+
/** The canonical DEFAULT signature (formal sigID 0 in the registry). */
|
|
506
|
+
static get DEFAULT() {
|
|
507
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fieldSigCanonicalizer.get(0);
|
|
508
|
+
}
|
|
509
|
+
constructor(fieldName, declaringOrID, type, staticFlag = false, namespaceDeclared, declaringClassTempSigID) {
|
|
174
510
|
this.fieldName = fieldName;
|
|
175
|
-
this.declaringSignature = declaringSignature;
|
|
176
511
|
this.type = type;
|
|
177
512
|
this.staticFlag = staticFlag;
|
|
513
|
+
if (typeof declaringOrID === 'number' && !namespaceDeclared) {
|
|
514
|
+
// Class-side SigID path: direct field assignment (formal or temp via optional param).
|
|
515
|
+
this.declaringClassSigID = declaringOrID;
|
|
516
|
+
this.declaringClassTempSigID = declaringClassTempSigID;
|
|
517
|
+
this.declaringNamespaceSigID = undefined;
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
this.setDeclaringFields(declaringOrID, namespaceDeclared !== null && namespaceDeclared !== void 0 ? namespaceDeclared : false);
|
|
521
|
+
}
|
|
522
|
+
this.recomputeHashCode();
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* @internal 解析 declaring 并写入三个 SigID 字段(构造器与 {@link applyFields}共用):
|
|
526
|
+
* 数字重载直存;
|
|
527
|
+
* 对象重载按 isUnclear 分流(unclear class → temp 登记;clear → formal 只读命中;unclear ns → 仅标记 -1)。
|
|
528
|
+
*/
|
|
529
|
+
setDeclaringFields(declaringOrID, namespaceDeclared = false) {
|
|
530
|
+
if (typeof declaringOrID === 'number') {
|
|
531
|
+
this.declaringClassSigID = undefined;
|
|
532
|
+
this.declaringClassTempSigID = undefined;
|
|
533
|
+
this.declaringNamespaceSigID = undefined;
|
|
534
|
+
if (namespaceDeclared) {
|
|
535
|
+
this.declaringNamespaceSigID = declaringOrID;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
this.declaringClassSigID = declaringOrID;
|
|
539
|
+
}
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
this.declaringClassSigID = undefined;
|
|
543
|
+
this.declaringClassTempSigID = undefined;
|
|
544
|
+
this.declaringNamespaceSigID = undefined;
|
|
545
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
546
|
+
if (declaringOrID instanceof ClassSignature) {
|
|
547
|
+
if (declaringOrID.isUnclear()) {
|
|
548
|
+
this.declaringClassSigID = -1;
|
|
549
|
+
this.declaringClassTempSigID = reg.tempClassSigCanonicalizer.register(declaringOrID);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
const existingId = reg.classSigCanonicalizer.getExistingId(declaringOrID);
|
|
553
|
+
if (existingId !== -1) {
|
|
554
|
+
this.declaringClassSigID = existingId;
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
FieldSignature.logger.error(`Clear ClassSignature declaring not interned — routing to temp: ${declaringOrID.toString()}`);
|
|
558
|
+
this.declaringClassSigID = -1;
|
|
559
|
+
this.declaringClassTempSigID = reg.tempClassSigCanonicalizer.register(declaringOrID);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
// namespace 无 temp 空间。
|
|
565
|
+
if (declaringOrID.isUnclear()) {
|
|
566
|
+
FieldSignature.logger.error(`Clear ClassSignature declaring not interned — routing to temp: ${declaringOrID.toString()}`);
|
|
567
|
+
this.declaringNamespaceSigID = -1;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
const existingNsId = reg.namespaceSigCanonicalizer.getExistingId(declaringOrID);
|
|
571
|
+
if (existingNsId !== -1) {
|
|
572
|
+
this.declaringNamespaceSigID = existingNsId;
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
FieldSignature.logger.error(`Clear NamespaceSignature declaring not interned — marking -1: ${declaringOrID.toString()}`);
|
|
576
|
+
this.declaringNamespaceSigID = -1;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* @internal Shared mutable probe for existence-check lookups (getFieldWithName and
|
|
583
|
+
* friends). Consume the result in a single expression; never store or intern it.
|
|
584
|
+
*/
|
|
585
|
+
static probe(fieldName, declaringClassSigID, type, staticFlag) {
|
|
586
|
+
let p = FieldSignature.probeInstance;
|
|
587
|
+
if (p === undefined) {
|
|
588
|
+
p = new FieldSignature(fieldName, declaringClassSigID, type, staticFlag);
|
|
589
|
+
FieldSignature.probeInstance = p;
|
|
590
|
+
return p;
|
|
591
|
+
}
|
|
592
|
+
p.applyFields(fieldName, declaringClassSigID, type, staticFlag, false);
|
|
593
|
+
return p;
|
|
594
|
+
}
|
|
595
|
+
/** @internal 按当前字段值重算 hash(applyFields 就地演进后调用,值与 hash 保持一致)。 */
|
|
596
|
+
recomputeHashCode() {
|
|
597
|
+
var _a, _b, _c;
|
|
598
|
+
let h = 0xdeadbeef;
|
|
599
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (_a = this.declaringClassSigID) !== null && _a !== void 0 ? _a : 0);
|
|
600
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (_b = this.declaringNamespaceSigID) !== null && _b !== void 0 ? _b : 0);
|
|
601
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (_c = this.declaringClassTempSigID) !== null && _c !== void 0 ? _c : 0);
|
|
602
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(this.fieldName));
|
|
603
|
+
h = (0, HashUtils_1.hashCombineU32)(h, this.staticFlag ? 1 : 0);
|
|
604
|
+
this.hashCode = h >>> 0;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* @internal 参数式就地演进原语——不经过中间实例 N,直接按参数赋值字段 + 解析 declaring + 重算 hash(编号不变)。供持有者更新入口的参数式路径
|
|
608
|
+
* (决策表"未毕业抄写"分支的零分配版)使用。
|
|
609
|
+
*/
|
|
610
|
+
applyFields(fieldName, declaringOrID, type, staticFlag, namespaceDeclared = false) {
|
|
611
|
+
this.fieldName = fieldName;
|
|
612
|
+
this.type = type;
|
|
613
|
+
this.staticFlag = staticFlag;
|
|
614
|
+
this.setDeclaringFields(declaringOrID, namespaceDeclared);
|
|
615
|
+
this.recomputeHashCode();
|
|
178
616
|
}
|
|
179
617
|
getDeclaringSignature() {
|
|
180
|
-
|
|
618
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
619
|
+
if (this.declaringClassSigID !== undefined && this.declaringClassSigID >= 0) {
|
|
620
|
+
const sig = reg.classSigCanonicalizer.get(this.declaringClassSigID);
|
|
621
|
+
if (sig !== undefined) {
|
|
622
|
+
return sig;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
else if (this.declaringNamespaceSigID !== undefined && this.declaringNamespaceSigID >= 0) {
|
|
626
|
+
const sig = reg.namespaceSigCanonicalizer.get(this.declaringNamespaceSigID);
|
|
627
|
+
if (sig !== undefined) {
|
|
628
|
+
return sig;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
else if (this.declaringClassTempSigID !== undefined) {
|
|
632
|
+
const sig = reg.tempClassSigCanonicalizer.get(this.declaringClassTempSigID);
|
|
633
|
+
if (sig !== undefined) {
|
|
634
|
+
return sig;
|
|
635
|
+
}
|
|
636
|
+
const formalId = reg.tempClassSigCanonicalizer.getReplacement(this.declaringClassTempSigID);
|
|
637
|
+
if (formalId !== -1) {
|
|
638
|
+
const formalSig = reg.classSigCanonicalizer.get(formalId);
|
|
639
|
+
if (formalSig !== undefined) {
|
|
640
|
+
return formalSig;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
// Stale SigID (registry disposed and rebuilt): degrade to DEFAULT instead of crashing.
|
|
645
|
+
FieldSignature.logger.error(`FieldSignature '${this.fieldName}' has a stale declaring SigID (class=${this.declaringClassSigID}, namespace=${this.declaringNamespaceSigID}, temp=${this.declaringClassTempSigID}); returning ClassSignature.DEFAULT.`);
|
|
646
|
+
return ClassSignature.DEFAULT;
|
|
647
|
+
}
|
|
648
|
+
/** @internal Get the formal ClassSigID of the declaring class. Returns -1 if unclear (temp-held), undefined if declared by namespace. */
|
|
649
|
+
getDeclaringClassSigID() {
|
|
650
|
+
return this.declaringClassSigID;
|
|
651
|
+
}
|
|
652
|
+
/** @internal Get the formal NamespaceSigID of the declaring namespace. Returns -1 if unclear (temp-held), undefined if declared by class. */
|
|
653
|
+
getDeclaringNamespaceSigID() {
|
|
654
|
+
return this.declaringNamespaceSigID;
|
|
655
|
+
}
|
|
656
|
+
/** @internal Get the temp ClassSigID of the unclear declaring class. Returns undefined if clear or declared by namespace. */
|
|
657
|
+
getDeclaringClassTempSigID() {
|
|
658
|
+
return this.declaringClassTempSigID;
|
|
181
659
|
}
|
|
182
660
|
getBaseName() {
|
|
183
|
-
|
|
661
|
+
const declaringSignature = this.getDeclaringSignature();
|
|
662
|
+
return declaringSignature instanceof ClassSignature ? declaringSignature.getClassName() : declaringSignature.getNamespaceName();
|
|
184
663
|
}
|
|
185
664
|
getFieldName() {
|
|
186
665
|
return this.fieldName;
|
|
@@ -206,8 +685,52 @@ class FieldSignature {
|
|
|
206
685
|
}
|
|
207
686
|
return this.getDeclaringSignature().toString() + '.' + tmpSig;
|
|
208
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
* @deprecated No longer used internally since the ID refactor: identity comparison
|
|
690
|
+
* uses {@link signatureEquals} (hash + equals), indexing uses the canonicalizer.
|
|
691
|
+
* Kept for backward compatibility only — for identity checks use `equals()`
|
|
692
|
+
* (with `getHashCode()` fast reject), for debug output use `toString()`.
|
|
693
|
+
*/
|
|
694
|
+
toMapKey() {
|
|
695
|
+
let tmpSig = this.fieldName;
|
|
696
|
+
if (this.isStatic()) {
|
|
697
|
+
tmpSig = '[static]' + tmpSig;
|
|
698
|
+
}
|
|
699
|
+
return this.getDeclaringSignature().toMapKey() + '.' + tmpSig;
|
|
700
|
+
}
|
|
701
|
+
getHashCode() {
|
|
702
|
+
return this.hashCode;
|
|
703
|
+
}
|
|
704
|
+
equals(other) {
|
|
705
|
+
if (this === other) {
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
if (this.fieldName !== other.fieldName) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
if (this.staticFlag !== other.staticFlag) {
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
return this.declaringClassSigID === other.declaringClassSigID &&
|
|
715
|
+
this.declaringNamespaceSigID === other.declaringNamespaceSigID &&
|
|
716
|
+
this.declaringClassTempSigID === other.declaringClassTempSigID;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* @internal Whether the declaring signature is unclear (temp-held, unresolved).
|
|
720
|
+
* Direct field check (no registry lookup, no declaring signature chain traversal):
|
|
721
|
+
* class-side unclear = declaringClassSigID is non-positive — -1 (temp-held) or 0
|
|
722
|
+
* (DEFAULT class as declaring, i.e. "method on an unknown class" — stub builders
|
|
723
|
+
* like ArkSignatureBuilder.buildMethodSignatureFromMethodName pass 0 directly);
|
|
724
|
+
* namespace-side unclear = declaringNamespaceSigID === -1.
|
|
725
|
+
* A positive formal declaring ID implies the declaring entity went through the
|
|
726
|
+
* formal path — no chain check needed.
|
|
727
|
+
*/
|
|
728
|
+
isUnclear() {
|
|
729
|
+
return this.declaringClassSigID === -1 || this.declaringClassSigID === 0 || this.declaringNamespaceSigID === -1;
|
|
730
|
+
}
|
|
209
731
|
}
|
|
210
732
|
exports.FieldSignature = FieldSignature;
|
|
733
|
+
FieldSignature.logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'FieldSignature');
|
|
211
734
|
class MethodSubSignature {
|
|
212
735
|
constructor(methodName, parameters, returnType, staticFlag = false) {
|
|
213
736
|
this.methodName = methodName;
|
|
@@ -221,6 +744,17 @@ class MethodSubSignature {
|
|
|
221
744
|
getParameters() {
|
|
222
745
|
return this.parameters;
|
|
223
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* @internal Replace the parameter list.
|
|
749
|
+
*
|
|
750
|
+
* Parameter NAMES are not part of the signature identity (hash/equals/toString only use
|
|
751
|
+
* parameter types), so distinct declarations/implementations of the same method share one
|
|
752
|
+
* canonical signature instance. The implementation side is the authority for body-local
|
|
753
|
+
* generation, so its parameter names are refreshed onto the canonical instance.
|
|
754
|
+
*/
|
|
755
|
+
setParameters(parameters) {
|
|
756
|
+
this.parameters = parameters;
|
|
757
|
+
}
|
|
224
758
|
getParameterTypes() {
|
|
225
759
|
const parameterTypes = [];
|
|
226
760
|
this.parameters.forEach(parameter => {
|
|
@@ -241,7 +775,9 @@ class MethodSubSignature {
|
|
|
241
775
|
let paraStr = '';
|
|
242
776
|
this.getParameterTypes().forEach(parameterType => {
|
|
243
777
|
const typeStr = parameterType
|
|
244
|
-
?
|
|
778
|
+
? visited
|
|
779
|
+
? parameterType.toStringWithVisited(visited)
|
|
780
|
+
: parameterType.toString()
|
|
245
781
|
: Type_1.UnknownType.getInstance().toString();
|
|
246
782
|
paraStr += typeStr + ', ';
|
|
247
783
|
});
|
|
@@ -254,13 +790,80 @@ class MethodSubSignature {
|
|
|
254
790
|
}
|
|
255
791
|
}
|
|
256
792
|
exports.MethodSubSignature = MethodSubSignature;
|
|
793
|
+
/**
|
|
794
|
+
* @internal Value-semantic equality between two MethodSubSignatures, semantically equivalent to `a.toString() === b.toString()` plus return-type equality,
|
|
795
|
+
* but short-circuits from cheap to expensive with NO string building in the common mismatch cases.
|
|
796
|
+
*/
|
|
797
|
+
function methodSubSignatureValueEquals(a, b) {
|
|
798
|
+
var _a, _b, _c, _d;
|
|
799
|
+
if (a === b) {
|
|
800
|
+
return true;
|
|
801
|
+
}
|
|
802
|
+
if (a.isStatic() !== b.isStatic()) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
if (a.getMethodName() !== b.getMethodName()) {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
const ap = a.getParameters();
|
|
809
|
+
const bp = b.getParameters();
|
|
810
|
+
if (ap.length !== bp.length) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
for (let i = 0; i < ap.length; i++) {
|
|
814
|
+
const at = (_a = ap[i]) === null || _a === void 0 ? void 0 : _a.getType();
|
|
815
|
+
const bt = (_b = bp[i]) === null || _b === void 0 ? void 0 : _b.getType();
|
|
816
|
+
if (at === bt) {
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
if (((_c = at === null || at === void 0 ? void 0 : at.toString()) !== null && _c !== void 0 ? _c : Type_1.UnknownType.getInstance().toString()) !== ((_d = bt === null || bt === void 0 ? void 0 : bt.toString()) !== null && _d !== void 0 ? _d : Type_1.UnknownType.getInstance().toString())) {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return a.getReturnType().toString() === b.getReturnType().toString();
|
|
824
|
+
}
|
|
257
825
|
/**
|
|
258
826
|
* @category core/model
|
|
259
827
|
*/
|
|
260
828
|
class MethodSignature {
|
|
261
|
-
|
|
262
|
-
|
|
829
|
+
/** The canonical DEFAULT signature (formal sigID 0 in the registry). */
|
|
830
|
+
static get DEFAULT() {
|
|
831
|
+
return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().methodSigCanonicalizer.get(0);
|
|
832
|
+
}
|
|
833
|
+
constructor(declaringClassOrID, methodSubSignature, declaringClassTempSigID) {
|
|
834
|
+
var _a;
|
|
263
835
|
this.methodSubSignature = methodSubSignature;
|
|
836
|
+
if (typeof declaringClassOrID === 'number') {
|
|
837
|
+
this.declaringClassSigID = declaringClassOrID;
|
|
838
|
+
this.declaringClassTempSigID = declaringClassTempSigID;
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
842
|
+
if (declaringClassOrID.isUnclear()) {
|
|
843
|
+
this.declaringClassSigID = -1;
|
|
844
|
+
this.declaringClassTempSigID = reg.tempClassSigCanonicalizer.register(declaringClassOrID);
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
const existingId = reg.classSigCanonicalizer.getExistingId(declaringClassOrID);
|
|
848
|
+
if (existingId !== -1) {
|
|
849
|
+
this.declaringClassSigID = existingId;
|
|
850
|
+
}
|
|
851
|
+
else {
|
|
852
|
+
MethodSignature.logger.error(`Clear ClassSignature declaring not interned — routing to temp: ${declaringClassOrID.toString()}`);
|
|
853
|
+
this.declaringClassSigID = -1;
|
|
854
|
+
this.declaringClassTempSigID = reg.tempClassSigCanonicalizer.register(declaringClassOrID);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
// Hash inputs are lifetime-stable identity fields ONLY: declaring SigIDs, method name, parameter count, static flag.
|
|
859
|
+
// Parameter TYPES and the return type are deliberately excluded — they are mutable in place during inference.
|
|
860
|
+
let h = 0xdeadbeef;
|
|
861
|
+
h = (0, HashUtils_1.hashCombineU32)(h, this.declaringClassSigID);
|
|
862
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (_a = this.declaringClassTempSigID) !== null && _a !== void 0 ? _a : 0);
|
|
863
|
+
h = (0, HashUtils_1.hashCombineU32)(h, (0, HashUtils_1.hashString32)(methodSubSignature.getMethodName()));
|
|
864
|
+
h = (0, HashUtils_1.hashCombineU32)(h, methodSubSignature.getParameters().length);
|
|
865
|
+
h = (0, HashUtils_1.hashCombineU32)(h, methodSubSignature.isStatic() ? 1 : 0);
|
|
866
|
+
this.hashCode = h >>> 0;
|
|
264
867
|
}
|
|
265
868
|
/**
|
|
266
869
|
* Return the declaring class signature.
|
|
@@ -271,17 +874,39 @@ class MethodSignature {
|
|
|
271
874
|
* A namespace signature can indicate its **string** name of namespace and its file signature.
|
|
272
875
|
* - Class Name: the **string** name of this class.
|
|
273
876
|
* @returns The declaring class signature.
|
|
274
|
-
* @example
|
|
275
|
-
* 1. get class signature from ArkMethod.
|
|
276
|
-
|
|
277
|
-
```typescript
|
|
278
|
-
let methodSignature = expr.getMethodSignature();
|
|
279
|
-
let name = methodSignature.getDeclaringClassSignature().getClassName();
|
|
280
|
-
```
|
|
281
|
-
*
|
|
282
877
|
*/
|
|
283
878
|
getDeclaringClassSignature() {
|
|
284
|
-
|
|
879
|
+
const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
|
|
880
|
+
if (this.declaringClassSigID >= 0) {
|
|
881
|
+
const sig = reg.classSigCanonicalizer.get(this.declaringClassSigID);
|
|
882
|
+
if (sig !== undefined) {
|
|
883
|
+
return sig;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
else if (this.declaringClassTempSigID !== undefined) {
|
|
887
|
+
const sig = reg.tempClassSigCanonicalizer.get(this.declaringClassTempSigID);
|
|
888
|
+
if (sig !== undefined) {
|
|
889
|
+
return sig;
|
|
890
|
+
}
|
|
891
|
+
const formalId = reg.tempClassSigCanonicalizer.getReplacement(this.declaringClassTempSigID);
|
|
892
|
+
if (formalId !== -1) {
|
|
893
|
+
const formalSig = reg.classSigCanonicalizer.get(formalId);
|
|
894
|
+
if (formalSig !== undefined) {
|
|
895
|
+
return formalSig;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
// Stale SigID (registry disposed and rebuilt): degrade to DEFAULT instead of crashing.
|
|
900
|
+
MethodSignature.logger.error(`MethodSignature '${this.methodSubSignature.getMethodName()}' has a stale declaring class SigID ${this.declaringClassSigID} (temp=${this.declaringClassTempSigID}); returning DEFAULT.`);
|
|
901
|
+
return ClassSignature.DEFAULT;
|
|
902
|
+
}
|
|
903
|
+
/** @internal Get the formal ClassSigID of the declaring class. Returns -1 if unclear (temp-held). */
|
|
904
|
+
getDeclaringClassSigID() {
|
|
905
|
+
return this.declaringClassSigID;
|
|
906
|
+
}
|
|
907
|
+
/** @internal Get the temp ClassSigID of the unclear declaring class. Returns undefined if clear. */
|
|
908
|
+
getDeclaringClassTempSigID() {
|
|
909
|
+
return this.declaringClassTempSigID;
|
|
285
910
|
}
|
|
286
911
|
/**
|
|
287
912
|
* Returns the sub-signature of this method signature.
|
|
@@ -296,20 +921,49 @@ class MethodSignature {
|
|
|
296
921
|
return this.methodSubSignature.getReturnType();
|
|
297
922
|
}
|
|
298
923
|
toString(ptrName, visited) {
|
|
299
|
-
return this.
|
|
300
|
-
this.methodSubSignature.toString(ptrName, visited);
|
|
924
|
+
return this.getDeclaringClassSignature().toString() + '.' + this.methodSubSignature.toString(ptrName, visited);
|
|
301
925
|
}
|
|
926
|
+
/**
|
|
927
|
+
* @deprecated No longer used internally since the ID refactor: identity comparison
|
|
928
|
+
* uses {@link signatureEquals} (hash + equals), indexing uses the canonicalizer.
|
|
929
|
+
* Kept for backward compatibility only — for identity checks use `equals()`
|
|
930
|
+
* (with `getHashCode()` fast reject), for debug output use `toString()`.
|
|
931
|
+
*/
|
|
302
932
|
toMapKey() {
|
|
303
|
-
return this.
|
|
933
|
+
return this.getDeclaringClassSignature().toMapKey() + '.' + this.methodSubSignature.toString();
|
|
934
|
+
}
|
|
935
|
+
getHashCode() {
|
|
936
|
+
return this.hashCode;
|
|
937
|
+
}
|
|
938
|
+
equals(other) {
|
|
939
|
+
if (this === other) {
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
if (this.declaringClassSigID !== other.declaringClassSigID) {
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
945
|
+
if (this.declaringClassTempSigID !== other.declaringClassTempSigID) {
|
|
946
|
+
return false;
|
|
947
|
+
}
|
|
948
|
+
return methodSubSignatureValueEquals(this.methodSubSignature, other.methodSubSignature);
|
|
949
|
+
}
|
|
950
|
+
isUnclear() {
|
|
951
|
+
return this.declaringClassSigID === -1 || this.declaringClassSigID === 0;
|
|
304
952
|
}
|
|
305
953
|
isMatch(signature) {
|
|
306
|
-
|
|
954
|
+
if (!(0, SignatureCanonicalizer_1.signatureEquals)(this.getDeclaringClassSignature(), signature.getDeclaringClassSignature())) {
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
// Sub-signature comparison shares the field-level path with equals (was: full
|
|
958
|
+
// MethodSignature.toString() building ×2 + returnType.toString() ×2 per call).
|
|
959
|
+
return methodSubSignatureValueEquals(this.methodSubSignature, signature.methodSubSignature);
|
|
307
960
|
}
|
|
308
961
|
getParamLength() {
|
|
309
962
|
return this.methodSubSignature.getParameters().filter(p => !p.getName().startsWith(Const_1.LEXICAL_ENV_NAME_PREFIX)).length;
|
|
310
963
|
}
|
|
311
964
|
}
|
|
312
965
|
exports.MethodSignature = MethodSignature;
|
|
966
|
+
MethodSignature.logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'MethodSignature');
|
|
313
967
|
class LocalSignature {
|
|
314
968
|
constructor(name, declaringMethodSignature) {
|
|
315
969
|
this.name = name;
|
|
@@ -342,57 +996,33 @@ class AliasTypeSignature {
|
|
|
342
996
|
}
|
|
343
997
|
}
|
|
344
998
|
exports.AliasTypeSignature = AliasTypeSignature;
|
|
345
|
-
|
|
999
|
+
/**
|
|
1000
|
+
* Legacy free-function comparators — kept for API compatibility (external callers may exist).
|
|
1001
|
+
* Behavior aligns with the corresponding signature classes' `equals()`:
|
|
1002
|
+
* - classSignatureCompare compares the declaring namespace (silently ignoring it misjudges same-name classes in different namespaces as equal);
|
|
1003
|
+
* - methodSubSignatureCompare compares parameter/return types by value (`===` reference comparison misjudges value-equal distinct Type instances as different).
|
|
1004
|
+
*/
|
|
346
1005
|
function fieldSignatureCompare(leftSig, rightSig) {
|
|
347
|
-
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
return false;
|
|
1006
|
+
return (0, SignatureCanonicalizer_1.signatureEquals)(leftSig.getDeclaringSignature(), rightSig.getDeclaringSignature()) && leftSig.getFieldName() === rightSig.getFieldName();
|
|
351
1007
|
}
|
|
352
1008
|
exports.fieldSignatureCompare = fieldSignatureCompare;
|
|
353
1009
|
function methodSignatureCompare(leftSig, rightSig) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
|
-
return false;
|
|
1010
|
+
return (0, SignatureCanonicalizer_1.signatureEquals)(leftSig.getDeclaringClassSignature(), rightSig.getDeclaringClassSignature()) &&
|
|
1011
|
+
methodSubSignatureValueEquals(leftSig.getMethodSubSignature(), rightSig.getMethodSubSignature());
|
|
359
1012
|
}
|
|
360
1013
|
exports.methodSignatureCompare = methodSignatureCompare;
|
|
361
1014
|
function methodSubSignatureCompare(leftSig, rightSig) {
|
|
362
|
-
|
|
363
|
-
arrayCompare(leftSig.getParameterTypes(), rightSig.getParameterTypes()) &&
|
|
364
|
-
leftSig.getReturnType() === rightSig.getReturnType() &&
|
|
365
|
-
leftSig.isStatic() === rightSig.isStatic()) {
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
return false;
|
|
1015
|
+
return methodSubSignatureValueEquals(leftSig, rightSig);
|
|
369
1016
|
}
|
|
370
1017
|
exports.methodSubSignatureCompare = methodSubSignatureCompare;
|
|
371
1018
|
function classSignatureCompare(leftSig, rightSig) {
|
|
372
|
-
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
return false;
|
|
1019
|
+
return (0, SignatureCanonicalizer_1.signatureEquals)(leftSig, rightSig);
|
|
376
1020
|
}
|
|
377
1021
|
exports.classSignatureCompare = classSignatureCompare;
|
|
378
1022
|
function fileSignatureCompare(leftSig, rightSig) {
|
|
379
|
-
|
|
380
|
-
return true;
|
|
381
|
-
}
|
|
382
|
-
return false;
|
|
1023
|
+
return leftSig.equals(rightSig);
|
|
383
1024
|
}
|
|
384
1025
|
exports.fileSignatureCompare = fileSignatureCompare;
|
|
385
|
-
function arrayCompare(leftArray, rightArray) {
|
|
386
|
-
if (leftArray.length !== rightArray.length) {
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
for (let i = 0; i < leftArray.length; i++) {
|
|
390
|
-
if (leftArray[i] !== rightArray[i]) {
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return true;
|
|
395
|
-
}
|
|
396
1026
|
function genSignature4ImportClause(arkFileName, importClauseName) {
|
|
397
1027
|
return `<${arkFileName}>.<${importClauseName}>`;
|
|
398
1028
|
}
|