arkanalyzer 1.0.20 → 1.0.21
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 +70 -70
- package/lib/Config.js +198 -198
- package/lib/Scene.d.ts +316 -316
- package/lib/Scene.js +1316 -1316
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +28 -28
- package/lib/callgraph/algorithm/AbstractAnalysis.js +144 -144
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts +10 -10
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +69 -69
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +15 -15
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +146 -146
- package/lib/callgraph/common/Statistics.d.ts +57 -57
- package/lib/callgraph/common/Statistics.js +228 -228
- package/lib/callgraph/model/CallGraph.d.ts +96 -96
- package/lib/callgraph/model/CallGraph.js +354 -354
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +15 -15
- package/lib/callgraph/model/builder/CallGraphBuilder.js +106 -106
- package/lib/callgraph/pointerAnalysis/Context.d.ts +37 -37
- package/lib/callgraph/pointerAnalysis/Context.js +155 -155
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts +22 -22
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +104 -104
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +5 -5
- package/lib/callgraph/pointerAnalysis/PTAUtils.js +46 -46
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +261 -261
- package/lib/callgraph/pointerAnalysis/Pag.js +930 -930
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +157 -157
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +1399 -1399
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +72 -72
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +573 -573
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +15 -15
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +81 -81
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +80 -80
- package/lib/callgraph/pointerAnalysis/PtsDS.js +308 -308
- package/lib/core/base/Constant.d.ts +48 -48
- package/lib/core/base/Constant.js +103 -103
- package/lib/core/base/Decorator.d.ts +15 -15
- package/lib/core/base/Decorator.js +46 -46
- package/lib/core/base/DefUseChain.d.ts +8 -8
- package/lib/core/base/DefUseChain.js +25 -25
- package/lib/core/base/Expr.d.ts +340 -340
- package/lib/core/base/Expr.js +917 -917
- package/lib/core/base/Local.d.ts +104 -104
- package/lib/core/base/Local.js +176 -176
- package/lib/core/base/Position.d.ts +30 -30
- package/lib/core/base/Position.js +147 -147
- package/lib/core/base/Ref.d.ts +173 -173
- package/lib/core/base/Ref.js +374 -374
- package/lib/core/base/Stmt.d.ts +237 -237
- package/lib/core/base/Stmt.js +525 -525
- package/lib/core/base/Trap.d.ts +8 -8
- package/lib/core/base/Trap.js +30 -30
- package/lib/core/base/Type.d.ts +308 -308
- package/lib/core/base/Type.js +639 -639
- package/lib/core/base/TypeExpr.d.ts +71 -71
- package/lib/core/base/TypeExpr.js +155 -155
- package/lib/core/base/Value.d.ts +32 -32
- package/lib/core/base/Value.js +16 -16
- package/lib/core/common/ArkError.d.ts +14 -14
- package/lib/core/common/ArkError.js +28 -28
- package/lib/core/common/ArkIRTransformer.d.ts +67 -67
- package/lib/core/common/ArkIRTransformer.js +690 -690
- package/lib/core/common/ArkValueTransformer.d.ts +89 -89
- package/lib/core/common/ArkValueTransformer.js +1478 -1478
- package/lib/core/common/Builtin.d.ts +36 -36
- package/lib/core/common/Builtin.js +81 -81
- package/lib/core/common/Const.d.ts +21 -21
- package/lib/core/common/Const.js +43 -43
- package/lib/core/common/DummyMainCreater.d.ts +46 -46
- package/lib/core/common/DummyMainCreater.js +319 -319
- package/lib/core/common/EtsConst.d.ts +73 -73
- package/lib/core/common/EtsConst.js +1021 -1021
- package/lib/core/common/ExprUseReplacer.d.ts +21 -21
- package/lib/core/common/ExprUseReplacer.js +124 -124
- package/lib/core/common/IRInference.d.ts +36 -36
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +651 -648
- package/lib/core/common/IRUtils.d.ts +18 -18
- package/lib/core/common/IRUtils.js +141 -141
- package/lib/core/common/ModelUtils.d.ts +70 -70
- package/lib/core/common/ModelUtils.js +712 -712
- package/lib/core/common/RefUseReplacer.d.ts +13 -13
- package/lib/core/common/RefUseReplacer.js +52 -52
- package/lib/core/common/SdkUtils.d.ts +8 -8
- package/lib/core/common/SdkUtils.js +105 -105
- package/lib/core/common/StmtDefReplacer.d.ts +12 -12
- package/lib/core/common/StmtDefReplacer.js +41 -41
- package/lib/core/common/StmtUseReplacer.d.ts +16 -16
- package/lib/core/common/StmtUseReplacer.js +108 -108
- package/lib/core/common/TSConst.d.ts +18 -18
- package/lib/core/common/TSConst.js +36 -36
- package/lib/core/common/TypeInference.d.ts +102 -102
- package/lib/core/common/TypeInference.js +748 -748
- package/lib/core/common/ValueUtil.d.ts +12 -12
- package/lib/core/common/ValueUtil.js +54 -54
- package/lib/core/common/VisibleValue.d.ts +36 -36
- package/lib/core/common/VisibleValue.js +212 -212
- package/lib/core/dataflow/DataflowProblem.d.ts +20 -20
- package/lib/core/dataflow/DataflowProblem.js +20 -20
- package/lib/core/dataflow/DataflowResult.d.ts +7 -7
- package/lib/core/dataflow/DataflowResult.js +26 -26
- package/lib/core/dataflow/DataflowSolver.d.ts +43 -43
- package/lib/core/dataflow/DataflowSolver.js +307 -307
- package/lib/core/dataflow/Edge.d.ts +11 -11
- package/lib/core/dataflow/Edge.js +31 -31
- package/lib/core/dataflow/Fact.d.ts +6 -6
- package/lib/core/dataflow/Fact.js +24 -24
- package/lib/core/dataflow/GenericDataFlow.d.ts +142 -142
- package/lib/core/dataflow/GenericDataFlow.js +109 -109
- package/lib/core/dataflow/ReachingDef.d.ts +62 -62
- package/lib/core/dataflow/ReachingDef.js +168 -168
- package/lib/core/dataflow/UndefinedVariable.d.ts +45 -45
- package/lib/core/dataflow/UndefinedVariable.js +288 -288
- package/lib/core/dataflow/Util.d.ts +9 -9
- package/lib/core/dataflow/Util.js +64 -64
- package/lib/core/graph/BaseExplicitGraph.d.ts +58 -58
- package/lib/core/graph/BaseExplicitGraph.js +157 -157
- package/lib/core/graph/BaseImplicitGraph.d.ts +77 -77
- package/lib/core/graph/BaseImplicitGraph.js +78 -78
- package/lib/core/graph/BasicBlock.d.ts +104 -104
- package/lib/core/graph/BasicBlock.js +280 -280
- package/lib/core/graph/Cfg.d.ts +59 -59
- package/lib/core/graph/Cfg.js +282 -282
- package/lib/core/graph/DependsGraph.d.ts +35 -35
- package/lib/core/graph/DependsGraph.js +87 -87
- package/lib/core/graph/DominanceFinder.d.ts +15 -15
- package/lib/core/graph/DominanceFinder.js +121 -121
- package/lib/core/graph/DominanceTree.d.ts +12 -12
- package/lib/core/graph/DominanceTree.js +70 -70
- package/lib/core/graph/GraphTraits.d.ts +7 -7
- package/lib/core/graph/GraphTraits.js +16 -16
- package/lib/core/graph/Scc.d.ts +61 -61
- package/lib/core/graph/Scc.js +222 -222
- package/lib/core/graph/ViewTree.d.ts +114 -114
- package/lib/core/graph/ViewTree.js +16 -16
- package/lib/core/graph/builder/CfgBuilder.d.ts +176 -176
- package/lib/core/graph/builder/CfgBuilder.js +1139 -1139
- package/lib/core/graph/builder/ConditionBuilder.d.ts +15 -15
- package/lib/core/graph/builder/ConditionBuilder.js +252 -252
- package/lib/core/graph/builder/LoopBuilder.d.ts +20 -20
- package/lib/core/graph/builder/LoopBuilder.js +251 -251
- package/lib/core/graph/builder/SwitchBuilder.d.ts +11 -11
- package/lib/core/graph/builder/SwitchBuilder.js +152 -152
- package/lib/core/graph/builder/TrapBuilder.d.ts +16 -16
- package/lib/core/graph/builder/TrapBuilder.js +272 -272
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts +203 -203
- package/lib/core/graph/builder/ViewTreeBuilder.js +1055 -1055
- package/lib/core/model/ArkBaseModel.d.ts +59 -59
- package/lib/core/model/ArkBaseModel.js +274 -274
- package/lib/core/model/ArkBody.d.ts +24 -24
- package/lib/core/model/ArkBody.js +65 -65
- package/lib/core/model/ArkClass.d.ts +206 -206
- package/lib/core/model/ArkClass.js +439 -439
- package/lib/core/model/ArkExport.d.ts +72 -72
- package/lib/core/model/ArkExport.js +147 -147
- package/lib/core/model/ArkField.d.ts +62 -62
- package/lib/core/model/ArkField.js +113 -113
- package/lib/core/model/ArkFile.d.ts +131 -131
- package/lib/core/model/ArkFile.js +267 -267
- package/lib/core/model/ArkImport.d.ts +44 -44
- package/lib/core/model/ArkImport.js +108 -108
- package/lib/core/model/ArkMetadata.d.ts +31 -31
- package/lib/core/model/ArkMetadata.js +55 -55
- package/lib/core/model/ArkMethod.d.ts +261 -261
- package/lib/core/model/ArkMethod.js +592 -592
- package/lib/core/model/ArkNamespace.d.ts +66 -66
- package/lib/core/model/ArkNamespace.js +209 -209
- package/lib/core/model/ArkSignature.d.ts +162 -162
- package/lib/core/model/ArkSignature.js +379 -379
- package/lib/core/model/builder/ArkClassBuilder.d.ts +12 -12
- package/lib/core/model/builder/ArkClassBuilder.js +454 -454
- package/lib/core/model/builder/ArkExportBuilder.d.ts +24 -24
- package/lib/core/model/builder/ArkExportBuilder.js +210 -210
- package/lib/core/model/builder/ArkFieldBuilder.d.ts +8 -8
- package/lib/core/model/builder/ArkFieldBuilder.js +193 -193
- package/lib/core/model/builder/ArkFileBuilder.d.ts +9 -9
- package/lib/core/model/builder/ArkFileBuilder.js +165 -165
- package/lib/core/model/builder/ArkImportBuilder.d.ts +4 -4
- package/lib/core/model/builder/ArkImportBuilder.js +128 -128
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +63 -63
- package/lib/core/model/builder/ArkMethodBuilder.js +486 -486
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +5 -5
- package/lib/core/model/builder/ArkNamespaceBuilder.js +205 -205
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts +8 -8
- package/lib/core/model/builder/ArkSignatureBuilder.js +40 -40
- package/lib/core/model/builder/BodyBuilder.d.ts +55 -30
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/BodyBuilder.js +542 -371
- package/lib/core/model/builder/builderUtils.d.ts +18 -18
- package/lib/core/model/builder/builderUtils.js +558 -558
- package/lib/index.d.ts +82 -80
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +201 -196
- package/lib/save/ArkStream.d.ts +23 -23
- package/lib/save/ArkStream.js +83 -83
- package/lib/save/DotPrinter.d.ts +43 -43
- package/lib/save/DotPrinter.js +170 -170
- package/lib/save/GraphPrinter.d.ts +16 -16
- package/lib/save/GraphPrinter.js +134 -134
- package/lib/save/JsonPrinter.d.ts +30 -30
- package/lib/save/JsonPrinter.js +580 -580
- package/lib/save/Printer.d.ts +12 -12
- package/lib/save/Printer.js +27 -27
- package/lib/save/PrinterBuilder.d.ts +53 -53
- package/lib/save/PrinterBuilder.js +145 -145
- package/lib/save/ViewTreePrinter.d.ts +14 -14
- package/lib/save/ViewTreePrinter.js +123 -123
- package/lib/save/arkir/ArkIRClassPrinter.d.ts +13 -13
- package/lib/save/arkir/ArkIRClassPrinter.js +92 -92
- package/lib/save/arkir/ArkIRFieldPrinter.d.ts +11 -11
- package/lib/save/arkir/ArkIRFieldPrinter.js +64 -64
- package/lib/save/arkir/ArkIRFilePrinter.d.ts +12 -12
- package/lib/save/arkir/ArkIRFilePrinter.js +54 -54
- package/lib/save/arkir/ArkIRMethodPrinter.d.ts +16 -16
- package/lib/save/arkir/ArkIRMethodPrinter.js +159 -159
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts +11 -11
- package/lib/save/arkir/ArkIRNamespacePrinter.js +66 -66
- package/lib/save/base/BasePrinter.d.ts +23 -23
- package/lib/save/base/BasePrinter.js +70 -70
- package/lib/save/base/ExportPrinter.d.ts +8 -8
- package/lib/save/base/ExportPrinter.js +67 -67
- package/lib/save/base/ImportPrinter.d.ts +9 -9
- package/lib/save/base/ImportPrinter.js +92 -92
- package/lib/save/base/PrinterUtils.d.ts +24 -24
- package/lib/save/base/PrinterUtils.js +208 -208
- package/lib/save/serializeArkIR.d.ts +8 -8
- package/lib/save/serializeArkIR.js +294 -294
- package/lib/save/source/SourceBase.d.ts +22 -22
- package/lib/save/source/SourceBase.js +64 -64
- package/lib/save/source/SourceBody.d.ts +58 -58
- package/lib/save/source/SourceBody.js +296 -296
- package/lib/save/source/SourceClass.d.ts +25 -25
- package/lib/save/source/SourceClass.js +187 -187
- package/lib/save/source/SourceField.d.ts +13 -13
- package/lib/save/source/SourceField.js +73 -73
- package/lib/save/source/SourceFilePrinter.d.ts +12 -12
- package/lib/save/source/SourceFilePrinter.js +69 -69
- package/lib/save/source/SourceMethod.d.ts +22 -22
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +196 -193
- package/lib/save/source/SourceNamespace.d.ts +11 -11
- package/lib/save/source/SourceNamespace.js +83 -83
- package/lib/save/source/SourceStmt.d.ts +178 -178
- package/lib/save/source/SourceStmt.js +838 -838
- package/lib/save/source/SourceTransformer.d.ts +46 -46
- package/lib/save/source/SourceTransformer.js +446 -446
- package/lib/transformer/FunctionTransformer.d.ts +2 -2
- package/lib/transformer/FunctionTransformer.js +17 -17
- package/lib/transformer/SceneTransformer.d.ts +2 -2
- package/lib/transformer/SceneTransformer.js +17 -17
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts +12 -12
- package/lib/transformer/StaticSingleAssignmentFormer.js +259 -259
- package/lib/transformer/Transformer.d.ts +6 -6
- package/lib/transformer/Transformer.js +22 -22
- package/lib/utils/AstTreeUtils.d.ts +4 -4
- package/lib/utils/AstTreeUtils.js +26 -26
- package/lib/utils/CfgStructualAnalysis.d.ts +110 -110
- package/lib/utils/CfgStructualAnalysis.js +1277 -1277
- package/lib/utils/FileUtils.d.ts +18 -18
- package/lib/utils/FileUtils.js +135 -135
- package/lib/utils/SparseBitVector.d.ts +100 -100
- package/lib/utils/SparseBitVector.js +445 -445
- package/lib/utils/callGraphUtils.d.ts +30 -30
- package/lib/utils/callGraphUtils.js +205 -205
- package/lib/utils/crypto_utils.d.ts +5 -5
- package/lib/utils/crypto_utils.js +57 -57
- package/lib/utils/entryMethodUtils.d.ts +13 -13
- package/lib/utils/entryMethodUtils.js +110 -110
- package/lib/utils/getAllFiles.d.ts +9 -9
- package/lib/utils/getAllFiles.js +90 -90
- package/lib/utils/json5parser.d.ts +6 -6
- package/lib/utils/json5parser.js +146 -146
- package/lib/utils/logger.d.ts +18 -18
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/logger.js +97 -90
- package/lib/utils/pathTransfer.d.ts +1 -1
- package/lib/utils/pathTransfer.js +25 -25
- package/node_modules/json5/lib/cli.js +0 -0
- package/node_modules/ohos-typescript/bin/tsc +0 -0
- package/node_modules/ohos-typescript/bin/tsserver +0 -0
- package/package.json +3 -3
|
@@ -1,930 +1,930 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
var __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;
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.InterFuncPag = exports.FuncPag = exports.Pag = exports.PagGlobalThisNode = exports.PagFuncNode = exports.PagParamNode = exports.PagNewContainerExprNode = exports.PagNewExprNode = exports.PagArrayNode = exports.PagThisRefNode = exports.PagStaticFieldNode = exports.PagInstanceFieldNode = exports.PagLocalNode = exports.PagNode = exports.PagNodeKind = exports.ThisPagEdge = exports.WritePagEdge = exports.LoadPagEdge = exports.CopyPagEdge = exports.AddrPagEdge = exports.PagEdge = exports.StorageLinkEdgeType = exports.StorageType = exports.PagEdgeKind = void 0;
|
|
41
|
-
const BaseExplicitGraph_1 = require("../../core/graph/BaseExplicitGraph");
|
|
42
|
-
const Stmt_1 = require("../../core/base/Stmt");
|
|
43
|
-
const Expr_1 = require("../../core/base/Expr");
|
|
44
|
-
const Ref_1 = require("../../core/base/Ref");
|
|
45
|
-
const Local_1 = require("../../core/base/Local");
|
|
46
|
-
const GraphPrinter_1 = require("../../save/GraphPrinter");
|
|
47
|
-
const PrinterBuilder_1 = require("../../save/PrinterBuilder");
|
|
48
|
-
const Constant_1 = require("../../core/base/Constant");
|
|
49
|
-
const Type_1 = require("../../core/base/Type");
|
|
50
|
-
const ArkSignature_1 = require("../../core/model/ArkSignature");
|
|
51
|
-
const logger_1 = __importStar(require("../../utils/logger"));
|
|
52
|
-
const TSConst_1 = require("../../core/common/TSConst");
|
|
53
|
-
const ArkExport_1 = require("../../core/model/ArkExport");
|
|
54
|
-
const PTAUtils_1 = require("./PTAUtils");
|
|
55
|
-
const PointerAnalysisConfig_1 = require("./PointerAnalysisConfig");
|
|
56
|
-
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'PTA');
|
|
57
|
-
/*
|
|
58
|
-
* Implementation of pointer-to assignment graph for pointer analysis
|
|
59
|
-
*/
|
|
60
|
-
const DUMMY_PAG_NODE_ID = -1;
|
|
61
|
-
var PagEdgeKind;
|
|
62
|
-
(function (PagEdgeKind) {
|
|
63
|
-
PagEdgeKind[PagEdgeKind["Address"] = 0] = "Address";
|
|
64
|
-
PagEdgeKind[PagEdgeKind["Copy"] = 1] = "Copy";
|
|
65
|
-
PagEdgeKind[PagEdgeKind["Load"] = 2] = "Load";
|
|
66
|
-
PagEdgeKind[PagEdgeKind["Write"] = 3] = "Write";
|
|
67
|
-
PagEdgeKind[PagEdgeKind["This"] = 4] = "This";
|
|
68
|
-
PagEdgeKind[PagEdgeKind["Unknown"] = 5] = "Unknown";
|
|
69
|
-
PagEdgeKind[PagEdgeKind["InterProceduralCopy"] = 6] = "InterProceduralCopy";
|
|
70
|
-
})(PagEdgeKind = exports.PagEdgeKind || (exports.PagEdgeKind = {}));
|
|
71
|
-
;
|
|
72
|
-
var StorageType;
|
|
73
|
-
(function (StorageType) {
|
|
74
|
-
StorageType[StorageType["APP_STORAGE"] = 0] = "APP_STORAGE";
|
|
75
|
-
StorageType[StorageType["LOCAL_STORAGE"] = 1] = "LOCAL_STORAGE";
|
|
76
|
-
StorageType[StorageType["Undefined"] = 2] = "Undefined";
|
|
77
|
-
})(StorageType = exports.StorageType || (exports.StorageType = {}));
|
|
78
|
-
;
|
|
79
|
-
var StorageLinkEdgeType;
|
|
80
|
-
(function (StorageLinkEdgeType) {
|
|
81
|
-
StorageLinkEdgeType[StorageLinkEdgeType["Property2Local"] = 0] = "Property2Local";
|
|
82
|
-
StorageLinkEdgeType[StorageLinkEdgeType["Local2Property"] = 1] = "Local2Property";
|
|
83
|
-
StorageLinkEdgeType[StorageLinkEdgeType["TwoWay"] = 2] = "TwoWay";
|
|
84
|
-
})(StorageLinkEdgeType = exports.StorageLinkEdgeType || (exports.StorageLinkEdgeType = {}));
|
|
85
|
-
class PagEdge extends BaseExplicitGraph_1.BaseEdge {
|
|
86
|
-
constructor(n, d, k, s) {
|
|
87
|
-
super(n, d, k);
|
|
88
|
-
this.stmt = s;
|
|
89
|
-
}
|
|
90
|
-
;
|
|
91
|
-
getDotAttr() {
|
|
92
|
-
var _a;
|
|
93
|
-
switch (this.getKind()) {
|
|
94
|
-
case PagEdgeKind.Address:
|
|
95
|
-
return "color=green";
|
|
96
|
-
case PagEdgeKind.Copy:
|
|
97
|
-
if (((_a = this.stmt) === null || _a === void 0 ? void 0 : _a.getInvokeExpr()) !== undefined || this.stmt instanceof Stmt_1.ArkReturnStmt) {
|
|
98
|
-
return "color=black,style=dotted";
|
|
99
|
-
}
|
|
100
|
-
return "color=black";
|
|
101
|
-
case PagEdgeKind.Load:
|
|
102
|
-
return "color=red";
|
|
103
|
-
case PagEdgeKind.Write:
|
|
104
|
-
return "color=blue";
|
|
105
|
-
case PagEdgeKind.This:
|
|
106
|
-
return "color=orange";
|
|
107
|
-
case PagEdgeKind.InterProceduralCopy:
|
|
108
|
-
return "color=purple,style=dashed";
|
|
109
|
-
default:
|
|
110
|
-
return "color=black";
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.PagEdge = PagEdge;
|
|
115
|
-
class AddrPagEdge extends PagEdge {
|
|
116
|
-
constructor(n, d, s) {
|
|
117
|
-
super(n, d, PagEdgeKind.Address, s);
|
|
118
|
-
}
|
|
119
|
-
;
|
|
120
|
-
}
|
|
121
|
-
exports.AddrPagEdge = AddrPagEdge;
|
|
122
|
-
class CopyPagEdge extends PagEdge {
|
|
123
|
-
constructor(n, d, s) {
|
|
124
|
-
super(n, d, PagEdgeKind.Copy, s);
|
|
125
|
-
}
|
|
126
|
-
;
|
|
127
|
-
}
|
|
128
|
-
exports.CopyPagEdge = CopyPagEdge;
|
|
129
|
-
class LoadPagEdge extends PagEdge {
|
|
130
|
-
constructor(n, d, s) {
|
|
131
|
-
super(n, d, PagEdgeKind.Copy, s);
|
|
132
|
-
}
|
|
133
|
-
;
|
|
134
|
-
}
|
|
135
|
-
exports.LoadPagEdge = LoadPagEdge;
|
|
136
|
-
class WritePagEdge extends PagEdge {
|
|
137
|
-
constructor(n, d, s) {
|
|
138
|
-
super(n, d, PagEdgeKind.Write, s);
|
|
139
|
-
}
|
|
140
|
-
;
|
|
141
|
-
}
|
|
142
|
-
exports.WritePagEdge = WritePagEdge;
|
|
143
|
-
class ThisPagEdge extends PagEdge {
|
|
144
|
-
constructor(n, d, s) {
|
|
145
|
-
super(n, d, PagEdgeKind.This, s);
|
|
146
|
-
}
|
|
147
|
-
;
|
|
148
|
-
}
|
|
149
|
-
exports.ThisPagEdge = ThisPagEdge;
|
|
150
|
-
var PagNodeKind;
|
|
151
|
-
(function (PagNodeKind) {
|
|
152
|
-
PagNodeKind[PagNodeKind["HeapObj"] = 0] = "HeapObj";
|
|
153
|
-
PagNodeKind[PagNodeKind["LocalVar"] = 1] = "LocalVar";
|
|
154
|
-
PagNodeKind[PagNodeKind["RefVar"] = 2] = "RefVar";
|
|
155
|
-
PagNodeKind[PagNodeKind["Param"] = 3] = "Param";
|
|
156
|
-
PagNodeKind[PagNodeKind["ThisRef"] = 4] = "ThisRef";
|
|
157
|
-
PagNodeKind[PagNodeKind["Function"] = 5] = "Function";
|
|
158
|
-
PagNodeKind[PagNodeKind["GlobalThis"] = 6] = "GlobalThis";
|
|
159
|
-
PagNodeKind[PagNodeKind["ExportInfo"] = 7] = "ExportInfo";
|
|
160
|
-
})(PagNodeKind = exports.PagNodeKind || (exports.PagNodeKind = {}));
|
|
161
|
-
class PagNode extends BaseExplicitGraph_1.BaseNode {
|
|
162
|
-
constructor(id, cid = undefined, value, k, s) {
|
|
163
|
-
super(id, k);
|
|
164
|
-
this.cid = cid;
|
|
165
|
-
this.value = value;
|
|
166
|
-
this.stmt = s;
|
|
167
|
-
let ptaConfig = PointerAnalysisConfig_1.PointerAnalysisConfig.getInstance();
|
|
168
|
-
this.pointTo = new ptaConfig.ptsCollectionCtor();
|
|
169
|
-
}
|
|
170
|
-
getBasePt() {
|
|
171
|
-
return this.basePt;
|
|
172
|
-
}
|
|
173
|
-
setBasePt(pt) {
|
|
174
|
-
this.basePt = pt;
|
|
175
|
-
}
|
|
176
|
-
getCid() {
|
|
177
|
-
if (this.cid === undefined) {
|
|
178
|
-
throw new Error('cid is undefine');
|
|
179
|
-
}
|
|
180
|
-
return this.cid;
|
|
181
|
-
}
|
|
182
|
-
setCid(cid) {
|
|
183
|
-
this.cid = cid;
|
|
184
|
-
}
|
|
185
|
-
setStmt(s) {
|
|
186
|
-
this.stmt = s;
|
|
187
|
-
}
|
|
188
|
-
getStmt() {
|
|
189
|
-
return this.stmt;
|
|
190
|
-
}
|
|
191
|
-
hasOutgoingCopyEdge() {
|
|
192
|
-
return (this.copyOutEdges.size !== 0);
|
|
193
|
-
}
|
|
194
|
-
getOutgoingCopyEdges() {
|
|
195
|
-
return this.copyOutEdges;
|
|
196
|
-
}
|
|
197
|
-
getIncomingCopyEdges() {
|
|
198
|
-
return this.copyInEdges;
|
|
199
|
-
}
|
|
200
|
-
getOutgoingLoadEdges() {
|
|
201
|
-
return this.loadOutEdges;
|
|
202
|
-
}
|
|
203
|
-
getOutgoingWriteEdges() {
|
|
204
|
-
return this.writeOutEdges;
|
|
205
|
-
}
|
|
206
|
-
getIncomingWriteEdges() {
|
|
207
|
-
return this.writeInEdges;
|
|
208
|
-
}
|
|
209
|
-
getOutgoingThisEdges() {
|
|
210
|
-
return this.thisOutEdges;
|
|
211
|
-
}
|
|
212
|
-
getIncomingThisEdges() {
|
|
213
|
-
return this.thisInEdges;
|
|
214
|
-
}
|
|
215
|
-
addAddressInEdge(e) {
|
|
216
|
-
this.addressInEdges === undefined ? this.addressInEdges = new Set() : undefined;
|
|
217
|
-
this.addressInEdges.add(e);
|
|
218
|
-
this.addIncomingEdge(e);
|
|
219
|
-
}
|
|
220
|
-
addAddressOutEdge(e) {
|
|
221
|
-
this.addressOutEdges === undefined ? this.addressOutEdges = new Set() : undefined;
|
|
222
|
-
this.addressOutEdges.add(e);
|
|
223
|
-
this.addOutgoingEdge(e);
|
|
224
|
-
}
|
|
225
|
-
addCopyInEdge(e) {
|
|
226
|
-
this.copyInEdges === undefined ? this.copyInEdges = new Set() : undefined;
|
|
227
|
-
this.copyInEdges.add(e);
|
|
228
|
-
this.addIncomingEdge(e);
|
|
229
|
-
}
|
|
230
|
-
addCopyOutEdge(e) {
|
|
231
|
-
this.copyOutEdges === undefined ? this.copyOutEdges = new Set() : undefined;
|
|
232
|
-
this.copyOutEdges.add(e);
|
|
233
|
-
this.addOutgoingEdge(e);
|
|
234
|
-
}
|
|
235
|
-
addLoadInEdge(e) {
|
|
236
|
-
this.loadInEdges === undefined ? this.loadInEdges = new Set() : undefined;
|
|
237
|
-
this.loadInEdges.add(e);
|
|
238
|
-
this.addIncomingEdge(e);
|
|
239
|
-
}
|
|
240
|
-
addLoadOutEdge(e) {
|
|
241
|
-
this.loadOutEdges === undefined ? this.loadOutEdges = new Set() : undefined;
|
|
242
|
-
this.loadOutEdges.add(e);
|
|
243
|
-
this.addOutgoingEdge(e);
|
|
244
|
-
}
|
|
245
|
-
addWriteInEdge(e) {
|
|
246
|
-
var _a;
|
|
247
|
-
this.writeInEdges = (_a = this.writeInEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
248
|
-
this.writeInEdges.add(e);
|
|
249
|
-
this.addIncomingEdge(e);
|
|
250
|
-
}
|
|
251
|
-
addWriteOutEdge(e) {
|
|
252
|
-
var _a;
|
|
253
|
-
this.writeOutEdges = (_a = this.writeOutEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
254
|
-
this.writeOutEdges.add(e);
|
|
255
|
-
this.addOutgoingEdge(e);
|
|
256
|
-
}
|
|
257
|
-
addThisInEdge(e) {
|
|
258
|
-
var _a;
|
|
259
|
-
this.thisInEdges = (_a = this.thisInEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
260
|
-
this.thisInEdges.add(e);
|
|
261
|
-
this.addIncomingEdge(e);
|
|
262
|
-
}
|
|
263
|
-
addThisOutEdge(e) {
|
|
264
|
-
var _a;
|
|
265
|
-
this.thisOutEdges = (_a = this.thisOutEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
266
|
-
this.thisOutEdges.add(e);
|
|
267
|
-
this.addOutgoingEdge(e);
|
|
268
|
-
}
|
|
269
|
-
getValue() {
|
|
270
|
-
return this.value;
|
|
271
|
-
}
|
|
272
|
-
getPointTo() {
|
|
273
|
-
return this.pointTo;
|
|
274
|
-
}
|
|
275
|
-
addPointToElement(node) {
|
|
276
|
-
this.pointTo.insert(node);
|
|
277
|
-
}
|
|
278
|
-
setPointTo(pts) {
|
|
279
|
-
this.pointTo = pts;
|
|
280
|
-
}
|
|
281
|
-
getOutEdges() {
|
|
282
|
-
return {
|
|
283
|
-
AddressEdge: this.addressOutEdges,
|
|
284
|
-
CopyEdge: this.copyOutEdges,
|
|
285
|
-
LoadEdge: this.loadOutEdges,
|
|
286
|
-
WriteEdge: this.writeOutEdges
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
getClonedFrom() {
|
|
290
|
-
return this.clonedFrom;
|
|
291
|
-
}
|
|
292
|
-
setClonedFrom(id) {
|
|
293
|
-
this.clonedFrom = id;
|
|
294
|
-
}
|
|
295
|
-
getDotAttr() {
|
|
296
|
-
switch (this.getKind()) {
|
|
297
|
-
case PagNodeKind.HeapObj:
|
|
298
|
-
case PagNodeKind.Function:
|
|
299
|
-
case PagNodeKind.GlobalThis:
|
|
300
|
-
return 'shape=box3d';
|
|
301
|
-
case PagNodeKind.LocalVar:
|
|
302
|
-
return 'shape=box';
|
|
303
|
-
case PagNodeKind.RefVar:
|
|
304
|
-
return 'shape=component';
|
|
305
|
-
case PagNodeKind.Param:
|
|
306
|
-
return 'shape=box';
|
|
307
|
-
case PagNodeKind.ExportInfo:
|
|
308
|
-
return 'shape=tab,color=purple';
|
|
309
|
-
case PagNodeKind.ThisRef:
|
|
310
|
-
return 'shape=box,color=orange';
|
|
311
|
-
default:
|
|
312
|
-
return 'shape=box';
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
getDotLabel() {
|
|
316
|
-
var _a;
|
|
317
|
-
let label;
|
|
318
|
-
let param;
|
|
319
|
-
label = PagNodeKind[this.getKind()];
|
|
320
|
-
label = label + ` ID: ${this.getID()} Ctx: ${this.cid}`;
|
|
321
|
-
if (this.basePt) {
|
|
322
|
-
label = label + ` base:{${this.basePt}}`;
|
|
323
|
-
}
|
|
324
|
-
label = label + ` pts:{${Array.from(this.pointTo).join(',')}}`;
|
|
325
|
-
if (this.getKind() === PagNodeKind.Param) {
|
|
326
|
-
param = this.value;
|
|
327
|
-
label = label + `\nParam#${param.getIndex()} ${param.toString()}`;
|
|
328
|
-
}
|
|
329
|
-
if (this.getKind() === PagNodeKind.ThisRef) {
|
|
330
|
-
label = label + `\n${this.value.toString()}`;
|
|
331
|
-
}
|
|
332
|
-
if (this.stmt) {
|
|
333
|
-
label = label + `\n${this.stmt.toString()}`;
|
|
334
|
-
let method = (_a = this.stmt.getCfg()) === null || _a === void 0 ? void 0 : _a.getDeclaringMethod().getSubSignature().toString();
|
|
335
|
-
if (method) {
|
|
336
|
-
label = label + '\n' + method;
|
|
337
|
-
}
|
|
338
|
-
label = label + ' ln: ' + this.stmt.getOriginPositionInfo().getLineNo();
|
|
339
|
-
}
|
|
340
|
-
else if (this.value) {
|
|
341
|
-
label += `\n${this.value.toString()}`;
|
|
342
|
-
}
|
|
343
|
-
return label;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
exports.PagNode = PagNode;
|
|
347
|
-
class PagLocalNode extends PagNode {
|
|
348
|
-
constructor(id, cid = undefined, value, stmt) {
|
|
349
|
-
super(id, cid, value, PagNodeKind.LocalVar, stmt);
|
|
350
|
-
this.storageLinked = false;
|
|
351
|
-
this.sdkParam = false;
|
|
352
|
-
}
|
|
353
|
-
addRelatedDynCallSite(cs) {
|
|
354
|
-
var _a;
|
|
355
|
-
this.relatedDynamicCallSite = (_a = this.relatedDynamicCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
356
|
-
this.relatedDynamicCallSite.add(cs);
|
|
357
|
-
}
|
|
358
|
-
getRelatedDynCallSites() {
|
|
359
|
-
var _a;
|
|
360
|
-
return (_a = this.relatedDynamicCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
361
|
-
}
|
|
362
|
-
addRelatedUnknownCallSite(cs) {
|
|
363
|
-
var _a;
|
|
364
|
-
this.relatedUnknownCallSite = (_a = this.relatedUnknownCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
365
|
-
this.relatedUnknownCallSite.add(cs);
|
|
366
|
-
}
|
|
367
|
-
getRelatedUnknownCallSites() {
|
|
368
|
-
var _a;
|
|
369
|
-
return (_a = this.relatedUnknownCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
370
|
-
}
|
|
371
|
-
setStorageLink(storageType, propertyName) {
|
|
372
|
-
this.storageLinked = true;
|
|
373
|
-
this.storageType = storageType;
|
|
374
|
-
this.propertyName = propertyName;
|
|
375
|
-
}
|
|
376
|
-
getStorage() {
|
|
377
|
-
return {
|
|
378
|
-
StorageType: this.storageType,
|
|
379
|
-
PropertyName: this.propertyName
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
isStorageLinked() {
|
|
383
|
-
return this.storageLinked;
|
|
384
|
-
}
|
|
385
|
-
setSdkParam() {
|
|
386
|
-
this.sdkParam = true;
|
|
387
|
-
}
|
|
388
|
-
isSdkParam() {
|
|
389
|
-
return this.sdkParam;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
exports.PagLocalNode = PagLocalNode;
|
|
393
|
-
class PagInstanceFieldNode extends PagNode {
|
|
394
|
-
constructor(id, cid = undefined, instanceFieldRef, stmt) {
|
|
395
|
-
super(id, cid, instanceFieldRef, PagNodeKind.RefVar, stmt);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
exports.PagInstanceFieldNode = PagInstanceFieldNode;
|
|
399
|
-
class PagStaticFieldNode extends PagNode {
|
|
400
|
-
constructor(id, cid = undefined, staticFieldRef, stmt) {
|
|
401
|
-
super(id, cid, staticFieldRef, PagNodeKind.RefVar, stmt);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
exports.PagStaticFieldNode = PagStaticFieldNode;
|
|
405
|
-
class PagThisRefNode extends PagNode {
|
|
406
|
-
constructor(id, thisRef) {
|
|
407
|
-
super(id, DUMMY_PAG_NODE_ID, thisRef, PagNodeKind.ThisRef);
|
|
408
|
-
this.pointToNode = [];
|
|
409
|
-
}
|
|
410
|
-
getThisPTNode() {
|
|
411
|
-
return this.pointToNode;
|
|
412
|
-
}
|
|
413
|
-
addPTNode(ptNode) {
|
|
414
|
-
this.pointToNode.push(ptNode);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
exports.PagThisRefNode = PagThisRefNode;
|
|
418
|
-
class PagArrayNode extends PagNode {
|
|
419
|
-
constructor(id, cid = undefined, expr, stmt) {
|
|
420
|
-
super(id, cid, expr, PagNodeKind.LocalVar, stmt);
|
|
421
|
-
this.base = expr.getBase();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
exports.PagArrayNode = PagArrayNode;
|
|
425
|
-
/**
|
|
426
|
-
* below is heapObj like Node
|
|
427
|
-
*/
|
|
428
|
-
class PagNewExprNode extends PagNode {
|
|
429
|
-
constructor(id, cid = undefined, expr, stmt) {
|
|
430
|
-
super(id, cid, expr, PagNodeKind.HeapObj, stmt);
|
|
431
|
-
}
|
|
432
|
-
addFieldNode(fieldSignature, nodeID) {
|
|
433
|
-
if (!this.fieldNodes) {
|
|
434
|
-
this.fieldNodes = new Map();
|
|
435
|
-
}
|
|
436
|
-
if (this.fieldNodes.has(fieldSignature.getFieldSignature().toString())) {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
this.fieldNodes.set(fieldSignature.getFieldSignature().toString(), nodeID);
|
|
440
|
-
return true;
|
|
441
|
-
}
|
|
442
|
-
getFieldNode(fieldSignature) {
|
|
443
|
-
if (!this.fieldNodes) {
|
|
444
|
-
return undefined;
|
|
445
|
-
}
|
|
446
|
-
return this.fieldNodes.get(fieldSignature.getFieldSignature().toString());
|
|
447
|
-
}
|
|
448
|
-
getFieldNodes() {
|
|
449
|
-
if (!this.fieldNodes) {
|
|
450
|
-
return undefined;
|
|
451
|
-
}
|
|
452
|
-
return this.fieldNodes;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
exports.PagNewExprNode = PagNewExprNode;
|
|
456
|
-
class PagNewContainerExprNode extends PagNode {
|
|
457
|
-
constructor(id, cid = undefined, expr, stmt) {
|
|
458
|
-
super(id, cid, expr, PagNodeKind.HeapObj, stmt);
|
|
459
|
-
}
|
|
460
|
-
addElementNode(nodeID) {
|
|
461
|
-
if (!this.elementNode) {
|
|
462
|
-
this.elementNode = nodeID;
|
|
463
|
-
}
|
|
464
|
-
return true;
|
|
465
|
-
}
|
|
466
|
-
getElementNode() {
|
|
467
|
-
if (this.elementNode) {
|
|
468
|
-
return this.elementNode;
|
|
469
|
-
}
|
|
470
|
-
return undefined;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
exports.PagNewContainerExprNode = PagNewContainerExprNode;
|
|
474
|
-
class PagParamNode extends PagNode {
|
|
475
|
-
constructor(id, cid = undefined, r, stmt) {
|
|
476
|
-
super(id, cid, r, PagNodeKind.Param, stmt);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
exports.PagParamNode = PagParamNode;
|
|
480
|
-
class PagFuncNode extends PagNode {
|
|
481
|
-
// TODO: may add obj interface
|
|
482
|
-
constructor(id, cid = undefined, r, stmt, method) {
|
|
483
|
-
super(id, cid, r, PagNodeKind.Function, stmt);
|
|
484
|
-
if (method) {
|
|
485
|
-
this.methodSignature = method;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
setMethod(method) {
|
|
489
|
-
this.methodSignature = method;
|
|
490
|
-
}
|
|
491
|
-
getMethod() {
|
|
492
|
-
return this.methodSignature;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
exports.PagFuncNode = PagFuncNode;
|
|
496
|
-
/**
|
|
497
|
-
* almost same as PagNewExprNode, used only for globalThis and its field reference
|
|
498
|
-
*/
|
|
499
|
-
class PagGlobalThisNode extends PagNode {
|
|
500
|
-
constructor(id, cid = undefined, r, stmt) {
|
|
501
|
-
super(id, cid, r, PagNodeKind.GlobalThis, stmt);
|
|
502
|
-
this.fieldNodes = new Map();
|
|
503
|
-
}
|
|
504
|
-
addFieldNode(fieldSignature, nodeID) {
|
|
505
|
-
if (this.fieldNodes.has(fieldSignature.getFieldSignature().toString())) {
|
|
506
|
-
return false;
|
|
507
|
-
}
|
|
508
|
-
this.fieldNodes.set(fieldSignature.getFieldSignature().toString(), nodeID);
|
|
509
|
-
return true;
|
|
510
|
-
}
|
|
511
|
-
getFieldNode(fieldSignature) {
|
|
512
|
-
return this.fieldNodes.get(fieldSignature.getFieldSignature().toString());
|
|
513
|
-
}
|
|
514
|
-
getFieldNodes() {
|
|
515
|
-
return this.fieldNodes;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
exports.PagGlobalThisNode = PagGlobalThisNode;
|
|
519
|
-
class Pag extends BaseExplicitGraph_1.BaseExplicitGraph {
|
|
520
|
-
constructor() {
|
|
521
|
-
super(...arguments);
|
|
522
|
-
this.contextValueToIdMap = new Map();
|
|
523
|
-
// contextBaseToIdMap will only be used in instance field
|
|
524
|
-
// Value: instance field base value, NodeID: abstract nodes
|
|
525
|
-
this.contextBaseToIdMap = new Map();
|
|
526
|
-
// for reanalyze, will return new addr edges
|
|
527
|
-
this.stashAddrEdge = new Set();
|
|
528
|
-
this.addrEdge = new Set();
|
|
529
|
-
this.clonedNodeMap = new Map();
|
|
530
|
-
}
|
|
531
|
-
getCG() {
|
|
532
|
-
return this.cg;
|
|
533
|
-
}
|
|
534
|
-
/*
|
|
535
|
-
* Clone a PagNode with same cid/value/stmt,
|
|
536
|
-
* but different Node ID
|
|
537
|
-
*/
|
|
538
|
-
getOrClonePagNode(src, basePt) {
|
|
539
|
-
if (src.getBasePt() !== undefined) {
|
|
540
|
-
throw new Error('This is a cloned ref node, can not be cloned again');
|
|
541
|
-
}
|
|
542
|
-
let cloneSet = this.clonedNodeMap.get(src.getID());
|
|
543
|
-
if (!cloneSet) {
|
|
544
|
-
cloneSet = new Map();
|
|
545
|
-
this.clonedNodeMap.set(src.getID(), cloneSet);
|
|
546
|
-
}
|
|
547
|
-
else {
|
|
548
|
-
let nodeID = cloneSet.get(basePt);
|
|
549
|
-
if (nodeID) {
|
|
550
|
-
return this.getNode(nodeID);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
// Not found
|
|
554
|
-
let cloneNode = this.addPagNode(src.getCid(), src.getValue(), src.getStmt(), false);
|
|
555
|
-
cloneNode.setClonedFrom(src.getID());
|
|
556
|
-
cloneSet.set(basePt, cloneNode.getID());
|
|
557
|
-
return cloneNode;
|
|
558
|
-
}
|
|
559
|
-
getOrClonePagFieldNode(src, basePt) {
|
|
560
|
-
let baseNode = this.getNode(basePt);
|
|
561
|
-
if (baseNode instanceof PagNewExprNode || baseNode instanceof PagGlobalThisNode) {
|
|
562
|
-
// check if real field node has been created with basePT, using FieldSignature as key
|
|
563
|
-
let existedNode = baseNode.getFieldNode(src.getValue());
|
|
564
|
-
if (existedNode) {
|
|
565
|
-
return this.getNode(existedNode);
|
|
566
|
-
}
|
|
567
|
-
let fieldNode = this.getOrClonePagNode(src, basePt);
|
|
568
|
-
baseNode.addFieldNode(src.getValue(), fieldNode.getID());
|
|
569
|
-
fieldNode.setBasePt(basePt);
|
|
570
|
-
return fieldNode;
|
|
571
|
-
}
|
|
572
|
-
else {
|
|
573
|
-
logger.error(`Error clone field node ${src.getValue()}`);
|
|
574
|
-
return undefined;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
getOrClonePagContainerFieldNode(basePt, src, base) {
|
|
578
|
-
let baseNode = this.getNode(basePt);
|
|
579
|
-
if (baseNode instanceof PagNewContainerExprNode) {
|
|
580
|
-
// check if Array Ref real node has been created or not, if not: create a real Array Ref node
|
|
581
|
-
let existedNode = baseNode.getElementNode();
|
|
582
|
-
let fieldNode;
|
|
583
|
-
if (existedNode) {
|
|
584
|
-
return this.getNode(existedNode);
|
|
585
|
-
}
|
|
586
|
-
if (src) {
|
|
587
|
-
fieldNode = this.getOrClonePagNode(src, basePt);
|
|
588
|
-
}
|
|
589
|
-
else if (base) {
|
|
590
|
-
const containerFieldSignature = new ArkSignature_1.FieldSignature('field', new ArkSignature_1.ClassSignature('container', new ArkSignature_1.FileSignature('container', 'lib.es2015.collection.d.ts')), new Type_1.UnclearReferenceType(''));
|
|
591
|
-
fieldNode = this.getOrClonePagNode(
|
|
592
|
-
// TODO: cid check
|
|
593
|
-
this.addPagNode(0, new Ref_1.ArkInstanceFieldRef(base, containerFieldSignature)), basePt);
|
|
594
|
-
}
|
|
595
|
-
baseNode.addElementNode(fieldNode.getID());
|
|
596
|
-
fieldNode.setBasePt(basePt);
|
|
597
|
-
return fieldNode;
|
|
598
|
-
}
|
|
599
|
-
else if (baseNode instanceof PagNewExprNode) {
|
|
600
|
-
// In some cases, the value of a variable of array type may not be an explicit array object.
|
|
601
|
-
// For example, it could be a return value of a function (assuming that the call depth has
|
|
602
|
-
// exceeded the k-limit).
|
|
603
|
-
// In such situation, the `baseNode` will be a PagNewExprNode instead of a PagNewContainerExprNode,
|
|
604
|
-
// and a warning will be raised.
|
|
605
|
-
logger.warn(`[PTA]: Trying to clone an array from a PagNewExprNode instead of a PagNewContainerExprNode`);
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
throw new Error(`Error clone array field node ${baseNode.getValue()}`);
|
|
609
|
-
}
|
|
610
|
-
return undefined;
|
|
611
|
-
}
|
|
612
|
-
addPagNode(cid, value, stmt, refresh = true) {
|
|
613
|
-
let id = this.nodeNum;
|
|
614
|
-
let pagNode;
|
|
615
|
-
if (value instanceof Local_1.Local) {
|
|
616
|
-
pagNode = this.handleLocalNode(id, cid, value, stmt);
|
|
617
|
-
}
|
|
618
|
-
else if (value instanceof Ref_1.ArkInstanceFieldRef) {
|
|
619
|
-
pagNode = this.handleInstanceFieldNode(id, cid, value, stmt);
|
|
620
|
-
}
|
|
621
|
-
else if (value instanceof Ref_1.ArkStaticFieldRef) {
|
|
622
|
-
pagNode = this.handleStaticFieldNode(id, cid, value, stmt);
|
|
623
|
-
}
|
|
624
|
-
else if (value instanceof Ref_1.ArkArrayRef) {
|
|
625
|
-
pagNode = new PagArrayNode(id, cid, value, stmt);
|
|
626
|
-
}
|
|
627
|
-
else if (value instanceof Expr_1.ArkNewExpr) {
|
|
628
|
-
pagNode = this.handleNewExprNode(id, cid, value, stmt);
|
|
629
|
-
}
|
|
630
|
-
else if (value instanceof Expr_1.ArkNewArrayExpr) {
|
|
631
|
-
pagNode = new PagNewContainerExprNode(id, cid, value, stmt);
|
|
632
|
-
}
|
|
633
|
-
else if (value instanceof Ref_1.ArkParameterRef) {
|
|
634
|
-
pagNode = new PagParamNode(id, cid, value, stmt);
|
|
635
|
-
}
|
|
636
|
-
else if (value instanceof Ref_1.ArkThisRef) {
|
|
637
|
-
throw new Error('This Node needs to use addThisNode method');
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
throw new Error('unsupported Value type ' + value.getType().toString());
|
|
641
|
-
}
|
|
642
|
-
this.addNode(pagNode);
|
|
643
|
-
this.addContextOrExportInfoMap(refresh, cid, id, value, pagNode, stmt);
|
|
644
|
-
return pagNode;
|
|
645
|
-
}
|
|
646
|
-
handleLocalNode(id, cid, value, stmt) {
|
|
647
|
-
const valueType = value.getType();
|
|
648
|
-
if (valueType instanceof Type_1.FunctionType && value.getDeclaringStmt() === null) {
|
|
649
|
-
return new PagFuncNode(id, cid, value, stmt, valueType.getMethodSignature());
|
|
650
|
-
}
|
|
651
|
-
else if (value.getName() === TSConst_1.GLOBAL_THIS_NAME && value.getDeclaringStmt() == null) {
|
|
652
|
-
return new PagGlobalThisNode(id, -1, value);
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
return new PagLocalNode(id, cid, value, stmt);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
handleInstanceFieldNode(id, cid, value, stmt) {
|
|
659
|
-
return this.createFieldNode(id, cid, value, stmt);
|
|
660
|
-
}
|
|
661
|
-
handleStaticFieldNode(id, cid, value, stmt) {
|
|
662
|
-
return this.createFieldNode(id, cid, value, stmt);
|
|
663
|
-
}
|
|
664
|
-
createFieldNode(id, cid, value, stmt) {
|
|
665
|
-
if (value.getType() instanceof Type_1.FunctionType) {
|
|
666
|
-
return new PagFuncNode(id, cid, value, stmt, value.getType().getMethodSignature());
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
return value instanceof Ref_1.ArkStaticFieldRef ? new PagStaticFieldNode(id, cid, value, stmt) : new PagInstanceFieldNode(id, cid, value, stmt);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
handleNewExprNode(id, cid, value, stmt) {
|
|
673
|
-
const classSignature = value.getClassType().getClassSignature();
|
|
674
|
-
if ((0, PTAUtils_1.IsCollectionClass)(classSignature)) {
|
|
675
|
-
return new PagNewContainerExprNode(id, cid, value, stmt);
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
return new PagNewExprNode(id, cid, value, stmt);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
addContextOrExportInfoMap(refresh, cid, id, value, pagNode, stmt) {
|
|
682
|
-
if (!(value instanceof ArkExport_1.ExportInfo)) {
|
|
683
|
-
this.addContextMap(refresh, cid, id, value, stmt, pagNode);
|
|
684
|
-
}
|
|
685
|
-
else {
|
|
686
|
-
this.addExportInfoMap(id, value);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
addExportInfoMap(id, v) {
|
|
690
|
-
var _a;
|
|
691
|
-
this.ExportInfoToIdMap = (_a = this.ExportInfoToIdMap) !== null && _a !== void 0 ? _a : new Map();
|
|
692
|
-
this.ExportInfoToIdMap.set(v, id);
|
|
693
|
-
}
|
|
694
|
-
addContextMap(refresh, cid, id, value, stmt, pagNode) {
|
|
695
|
-
var _a;
|
|
696
|
-
if (!refresh) {
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
let ctx2NdMap = this.contextValueToIdMap.get(value);
|
|
700
|
-
if (!ctx2NdMap) {
|
|
701
|
-
ctx2NdMap = new Map();
|
|
702
|
-
this.contextValueToIdMap.set(value, ctx2NdMap);
|
|
703
|
-
}
|
|
704
|
-
ctx2NdMap.set(cid, id);
|
|
705
|
-
if (value instanceof Ref_1.ArkInstanceFieldRef || value instanceof Ref_1.ArkArrayRef) {
|
|
706
|
-
let base = value.getBase();
|
|
707
|
-
//TODO: remove below once this Local is not uniq in %instInit is fix
|
|
708
|
-
if (base instanceof Local_1.Local && base.getName() === 'this') {
|
|
709
|
-
(_a = stmt === null || stmt === void 0 ? void 0 : stmt.getCfg()) === null || _a === void 0 ? void 0 : _a.getStmts().forEach(s => {
|
|
710
|
-
if (s instanceof Stmt_1.ArkAssignStmt &&
|
|
711
|
-
(s.getLeftOp()) instanceof Local_1.Local &&
|
|
712
|
-
s.getLeftOp().getName() === 'this') {
|
|
713
|
-
base = s.getLeftOp();
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
let ctxMap = this.contextBaseToIdMap.get(base);
|
|
719
|
-
if (ctxMap === undefined) {
|
|
720
|
-
ctxMap = new Map();
|
|
721
|
-
ctxMap.set(cid, [pagNode.getID()]);
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
let nodes = ctxMap.get(cid);
|
|
725
|
-
if (nodes === undefined) {
|
|
726
|
-
nodes = [pagNode.getID()];
|
|
727
|
-
}
|
|
728
|
-
else {
|
|
729
|
-
nodes.push(pagNode.getID());
|
|
730
|
-
}
|
|
731
|
-
ctxMap.set(cid, nodes);
|
|
732
|
-
}
|
|
733
|
-
this.contextBaseToIdMap.set(base, ctxMap);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
/*
|
|
737
|
-
* This node has no context info
|
|
738
|
-
* but point to node info
|
|
739
|
-
*/
|
|
740
|
-
addPagThisRefNode(value) {
|
|
741
|
-
let id = this.nodeNum;
|
|
742
|
-
let pagNode = new PagThisRefNode(id, value);
|
|
743
|
-
this.addNode(pagNode);
|
|
744
|
-
return pagNode;
|
|
745
|
-
}
|
|
746
|
-
addPagThisLocalNode(ptNode, value) {
|
|
747
|
-
let id = this.nodeNum;
|
|
748
|
-
let pagNode = new PagLocalNode(id, ptNode, value);
|
|
749
|
-
this.addNode(pagNode);
|
|
750
|
-
return pagNode;
|
|
751
|
-
}
|
|
752
|
-
getOrNewThisRefNode(thisRefNodeID, value) {
|
|
753
|
-
if (thisRefNodeID !== -1) {
|
|
754
|
-
return this.getNode(thisRefNodeID);
|
|
755
|
-
}
|
|
756
|
-
let thisRefNode = this.addPagThisRefNode(value);
|
|
757
|
-
return thisRefNode;
|
|
758
|
-
}
|
|
759
|
-
getOrNewThisLocalNode(cid, ptNode, value, s) {
|
|
760
|
-
if (ptNode !== -1) {
|
|
761
|
-
return this.getNode(ptNode);
|
|
762
|
-
}
|
|
763
|
-
else {
|
|
764
|
-
return this.getOrNewNode(cid, value, s);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
hasExportNode(v) {
|
|
768
|
-
var _a;
|
|
769
|
-
this.ExportInfoToIdMap = (_a = this.ExportInfoToIdMap) !== null && _a !== void 0 ? _a : new Map();
|
|
770
|
-
return this.ExportInfoToIdMap.get(v);
|
|
771
|
-
}
|
|
772
|
-
hasCtxNode(cid, v) {
|
|
773
|
-
let ctx2nd = this.contextValueToIdMap.get(v);
|
|
774
|
-
if (!ctx2nd) {
|
|
775
|
-
return undefined;
|
|
776
|
-
}
|
|
777
|
-
let ndId = ctx2nd.get(cid);
|
|
778
|
-
if (!ndId) {
|
|
779
|
-
return undefined;
|
|
780
|
-
}
|
|
781
|
-
return ndId;
|
|
782
|
-
}
|
|
783
|
-
hasCtxRetNode(cid, v) {
|
|
784
|
-
let ctx2nd = this.contextValueToIdMap.get(v);
|
|
785
|
-
if (!ctx2nd) {
|
|
786
|
-
return undefined;
|
|
787
|
-
}
|
|
788
|
-
let ndId = ctx2nd.get(cid);
|
|
789
|
-
if (!ndId) {
|
|
790
|
-
return undefined;
|
|
791
|
-
}
|
|
792
|
-
return ndId;
|
|
793
|
-
}
|
|
794
|
-
getOrNewNode(cid, v, s) {
|
|
795
|
-
let nodeId;
|
|
796
|
-
// Value
|
|
797
|
-
if (!(v instanceof ArkExport_1.ExportInfo)) {
|
|
798
|
-
nodeId = this.hasCtxNode(cid, v);
|
|
799
|
-
}
|
|
800
|
-
else {
|
|
801
|
-
// ExportInfo
|
|
802
|
-
nodeId = this.hasExportNode(v);
|
|
803
|
-
}
|
|
804
|
-
if (nodeId !== undefined) {
|
|
805
|
-
return this.getNode(nodeId);
|
|
806
|
-
}
|
|
807
|
-
return this.addPagNode(cid, v, s);
|
|
808
|
-
}
|
|
809
|
-
getNodesByValue(v) {
|
|
810
|
-
return this.contextValueToIdMap.get(v);
|
|
811
|
-
}
|
|
812
|
-
getNodesByBaseValue(v) {
|
|
813
|
-
return this.contextBaseToIdMap.get(v);
|
|
814
|
-
}
|
|
815
|
-
addPagEdge(src, dst, kind, stmt) {
|
|
816
|
-
// TODO: check if the edge already existing
|
|
817
|
-
let edge = new PagEdge(src, dst, kind, stmt);
|
|
818
|
-
if (this.ifEdgeExisting(edge)) {
|
|
819
|
-
return false;
|
|
820
|
-
}
|
|
821
|
-
switch (kind) {
|
|
822
|
-
case PagEdgeKind.Copy:
|
|
823
|
-
case PagEdgeKind.InterProceduralCopy:
|
|
824
|
-
src.addCopyOutEdge(edge);
|
|
825
|
-
dst.addCopyInEdge(edge);
|
|
826
|
-
if (src instanceof PagFuncNode ||
|
|
827
|
-
src instanceof PagGlobalThisNode ||
|
|
828
|
-
src instanceof PagNewExprNode ||
|
|
829
|
-
src instanceof PagNewContainerExprNode) {
|
|
830
|
-
this.addrEdge.add(edge);
|
|
831
|
-
this.stashAddrEdge.add(edge);
|
|
832
|
-
}
|
|
833
|
-
break;
|
|
834
|
-
case PagEdgeKind.Address:
|
|
835
|
-
src.addAddressOutEdge(edge);
|
|
836
|
-
dst.addAddressInEdge(edge);
|
|
837
|
-
this.addrEdge.add(edge);
|
|
838
|
-
this.stashAddrEdge.add(edge);
|
|
839
|
-
break;
|
|
840
|
-
case PagEdgeKind.Write:
|
|
841
|
-
src.addWriteOutEdge(edge);
|
|
842
|
-
dst.addWriteInEdge(edge);
|
|
843
|
-
break;
|
|
844
|
-
case PagEdgeKind.Load:
|
|
845
|
-
src.addLoadOutEdge(edge);
|
|
846
|
-
dst.addLoadInEdge(edge);
|
|
847
|
-
break;
|
|
848
|
-
case PagEdgeKind.This:
|
|
849
|
-
src.addThisOutEdge(edge);
|
|
850
|
-
dst.addThisInEdge(edge);
|
|
851
|
-
break;
|
|
852
|
-
default:
|
|
853
|
-
;
|
|
854
|
-
}
|
|
855
|
-
return true;
|
|
856
|
-
}
|
|
857
|
-
getAddrEdges() {
|
|
858
|
-
return this.stashAddrEdge;
|
|
859
|
-
}
|
|
860
|
-
resetAddrEdges() {
|
|
861
|
-
this.stashAddrEdge.clear();
|
|
862
|
-
}
|
|
863
|
-
getGraphName() {
|
|
864
|
-
return 'PAG';
|
|
865
|
-
}
|
|
866
|
-
dump(name) {
|
|
867
|
-
let printer = new GraphPrinter_1.GraphPrinter(this);
|
|
868
|
-
PrinterBuilder_1.PrinterBuilder.dump(printer, name);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
exports.Pag = Pag;
|
|
872
|
-
class FuncPag {
|
|
873
|
-
getInternalEdges() {
|
|
874
|
-
return this.internalEdges;
|
|
875
|
-
}
|
|
876
|
-
addNormalCallSite(cs) {
|
|
877
|
-
var _a;
|
|
878
|
-
this.normalCallSites = (_a = this.normalCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
879
|
-
this.normalCallSites.add(cs);
|
|
880
|
-
}
|
|
881
|
-
getNormalCallSites() {
|
|
882
|
-
var _a;
|
|
883
|
-
this.normalCallSites = (_a = this.normalCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
884
|
-
return this.normalCallSites;
|
|
885
|
-
}
|
|
886
|
-
addDynamicCallSite(cs) {
|
|
887
|
-
var _a;
|
|
888
|
-
this.dynamicCallSites = (_a = this.dynamicCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
889
|
-
this.dynamicCallSites.add(cs);
|
|
890
|
-
}
|
|
891
|
-
getDynamicCallSites() {
|
|
892
|
-
var _a;
|
|
893
|
-
this.dynamicCallSites = (_a = this.dynamicCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
894
|
-
return this.dynamicCallSites;
|
|
895
|
-
}
|
|
896
|
-
addUnknownCallSite(cs) {
|
|
897
|
-
var _a;
|
|
898
|
-
this.unknownCallSites = (_a = this.unknownCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
899
|
-
this.unknownCallSites.add(cs);
|
|
900
|
-
}
|
|
901
|
-
getUnknownCallSites() {
|
|
902
|
-
var _a;
|
|
903
|
-
this.unknownCallSites = (_a = this.unknownCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
904
|
-
return this.unknownCallSites;
|
|
905
|
-
}
|
|
906
|
-
addInternalEdge(stmt, k) {
|
|
907
|
-
this.internalEdges === undefined ? this.internalEdges = new Set() : undefined;
|
|
908
|
-
let lhOp = stmt.getLeftOp();
|
|
909
|
-
let rhOp = stmt.getRightOp();
|
|
910
|
-
if (rhOp instanceof Constant_1.Constant) {
|
|
911
|
-
return false;
|
|
912
|
-
}
|
|
913
|
-
let iEdge = { src: rhOp, dst: lhOp, kind: k, stmt: stmt };
|
|
914
|
-
this.internalEdges.add(iEdge);
|
|
915
|
-
return true;
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
exports.FuncPag = FuncPag;
|
|
919
|
-
class InterFuncPag {
|
|
920
|
-
constructor() {
|
|
921
|
-
this.interFuncEdges = new Set();
|
|
922
|
-
}
|
|
923
|
-
getInterProceduralEdges() {
|
|
924
|
-
return this.interFuncEdges;
|
|
925
|
-
}
|
|
926
|
-
addToInterProceduralEdgeSet(e) {
|
|
927
|
-
this.interFuncEdges.add(e);
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
exports.InterFuncPag = InterFuncPag;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __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;
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.InterFuncPag = exports.FuncPag = exports.Pag = exports.PagGlobalThisNode = exports.PagFuncNode = exports.PagParamNode = exports.PagNewContainerExprNode = exports.PagNewExprNode = exports.PagArrayNode = exports.PagThisRefNode = exports.PagStaticFieldNode = exports.PagInstanceFieldNode = exports.PagLocalNode = exports.PagNode = exports.PagNodeKind = exports.ThisPagEdge = exports.WritePagEdge = exports.LoadPagEdge = exports.CopyPagEdge = exports.AddrPagEdge = exports.PagEdge = exports.StorageLinkEdgeType = exports.StorageType = exports.PagEdgeKind = void 0;
|
|
41
|
+
const BaseExplicitGraph_1 = require("../../core/graph/BaseExplicitGraph");
|
|
42
|
+
const Stmt_1 = require("../../core/base/Stmt");
|
|
43
|
+
const Expr_1 = require("../../core/base/Expr");
|
|
44
|
+
const Ref_1 = require("../../core/base/Ref");
|
|
45
|
+
const Local_1 = require("../../core/base/Local");
|
|
46
|
+
const GraphPrinter_1 = require("../../save/GraphPrinter");
|
|
47
|
+
const PrinterBuilder_1 = require("../../save/PrinterBuilder");
|
|
48
|
+
const Constant_1 = require("../../core/base/Constant");
|
|
49
|
+
const Type_1 = require("../../core/base/Type");
|
|
50
|
+
const ArkSignature_1 = require("../../core/model/ArkSignature");
|
|
51
|
+
const logger_1 = __importStar(require("../../utils/logger"));
|
|
52
|
+
const TSConst_1 = require("../../core/common/TSConst");
|
|
53
|
+
const ArkExport_1 = require("../../core/model/ArkExport");
|
|
54
|
+
const PTAUtils_1 = require("./PTAUtils");
|
|
55
|
+
const PointerAnalysisConfig_1 = require("./PointerAnalysisConfig");
|
|
56
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'PTA');
|
|
57
|
+
/*
|
|
58
|
+
* Implementation of pointer-to assignment graph for pointer analysis
|
|
59
|
+
*/
|
|
60
|
+
const DUMMY_PAG_NODE_ID = -1;
|
|
61
|
+
var PagEdgeKind;
|
|
62
|
+
(function (PagEdgeKind) {
|
|
63
|
+
PagEdgeKind[PagEdgeKind["Address"] = 0] = "Address";
|
|
64
|
+
PagEdgeKind[PagEdgeKind["Copy"] = 1] = "Copy";
|
|
65
|
+
PagEdgeKind[PagEdgeKind["Load"] = 2] = "Load";
|
|
66
|
+
PagEdgeKind[PagEdgeKind["Write"] = 3] = "Write";
|
|
67
|
+
PagEdgeKind[PagEdgeKind["This"] = 4] = "This";
|
|
68
|
+
PagEdgeKind[PagEdgeKind["Unknown"] = 5] = "Unknown";
|
|
69
|
+
PagEdgeKind[PagEdgeKind["InterProceduralCopy"] = 6] = "InterProceduralCopy";
|
|
70
|
+
})(PagEdgeKind = exports.PagEdgeKind || (exports.PagEdgeKind = {}));
|
|
71
|
+
;
|
|
72
|
+
var StorageType;
|
|
73
|
+
(function (StorageType) {
|
|
74
|
+
StorageType[StorageType["APP_STORAGE"] = 0] = "APP_STORAGE";
|
|
75
|
+
StorageType[StorageType["LOCAL_STORAGE"] = 1] = "LOCAL_STORAGE";
|
|
76
|
+
StorageType[StorageType["Undefined"] = 2] = "Undefined";
|
|
77
|
+
})(StorageType = exports.StorageType || (exports.StorageType = {}));
|
|
78
|
+
;
|
|
79
|
+
var StorageLinkEdgeType;
|
|
80
|
+
(function (StorageLinkEdgeType) {
|
|
81
|
+
StorageLinkEdgeType[StorageLinkEdgeType["Property2Local"] = 0] = "Property2Local";
|
|
82
|
+
StorageLinkEdgeType[StorageLinkEdgeType["Local2Property"] = 1] = "Local2Property";
|
|
83
|
+
StorageLinkEdgeType[StorageLinkEdgeType["TwoWay"] = 2] = "TwoWay";
|
|
84
|
+
})(StorageLinkEdgeType = exports.StorageLinkEdgeType || (exports.StorageLinkEdgeType = {}));
|
|
85
|
+
class PagEdge extends BaseExplicitGraph_1.BaseEdge {
|
|
86
|
+
constructor(n, d, k, s) {
|
|
87
|
+
super(n, d, k);
|
|
88
|
+
this.stmt = s;
|
|
89
|
+
}
|
|
90
|
+
;
|
|
91
|
+
getDotAttr() {
|
|
92
|
+
var _a;
|
|
93
|
+
switch (this.getKind()) {
|
|
94
|
+
case PagEdgeKind.Address:
|
|
95
|
+
return "color=green";
|
|
96
|
+
case PagEdgeKind.Copy:
|
|
97
|
+
if (((_a = this.stmt) === null || _a === void 0 ? void 0 : _a.getInvokeExpr()) !== undefined || this.stmt instanceof Stmt_1.ArkReturnStmt) {
|
|
98
|
+
return "color=black,style=dotted";
|
|
99
|
+
}
|
|
100
|
+
return "color=black";
|
|
101
|
+
case PagEdgeKind.Load:
|
|
102
|
+
return "color=red";
|
|
103
|
+
case PagEdgeKind.Write:
|
|
104
|
+
return "color=blue";
|
|
105
|
+
case PagEdgeKind.This:
|
|
106
|
+
return "color=orange";
|
|
107
|
+
case PagEdgeKind.InterProceduralCopy:
|
|
108
|
+
return "color=purple,style=dashed";
|
|
109
|
+
default:
|
|
110
|
+
return "color=black";
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.PagEdge = PagEdge;
|
|
115
|
+
class AddrPagEdge extends PagEdge {
|
|
116
|
+
constructor(n, d, s) {
|
|
117
|
+
super(n, d, PagEdgeKind.Address, s);
|
|
118
|
+
}
|
|
119
|
+
;
|
|
120
|
+
}
|
|
121
|
+
exports.AddrPagEdge = AddrPagEdge;
|
|
122
|
+
class CopyPagEdge extends PagEdge {
|
|
123
|
+
constructor(n, d, s) {
|
|
124
|
+
super(n, d, PagEdgeKind.Copy, s);
|
|
125
|
+
}
|
|
126
|
+
;
|
|
127
|
+
}
|
|
128
|
+
exports.CopyPagEdge = CopyPagEdge;
|
|
129
|
+
class LoadPagEdge extends PagEdge {
|
|
130
|
+
constructor(n, d, s) {
|
|
131
|
+
super(n, d, PagEdgeKind.Copy, s);
|
|
132
|
+
}
|
|
133
|
+
;
|
|
134
|
+
}
|
|
135
|
+
exports.LoadPagEdge = LoadPagEdge;
|
|
136
|
+
class WritePagEdge extends PagEdge {
|
|
137
|
+
constructor(n, d, s) {
|
|
138
|
+
super(n, d, PagEdgeKind.Write, s);
|
|
139
|
+
}
|
|
140
|
+
;
|
|
141
|
+
}
|
|
142
|
+
exports.WritePagEdge = WritePagEdge;
|
|
143
|
+
class ThisPagEdge extends PagEdge {
|
|
144
|
+
constructor(n, d, s) {
|
|
145
|
+
super(n, d, PagEdgeKind.This, s);
|
|
146
|
+
}
|
|
147
|
+
;
|
|
148
|
+
}
|
|
149
|
+
exports.ThisPagEdge = ThisPagEdge;
|
|
150
|
+
var PagNodeKind;
|
|
151
|
+
(function (PagNodeKind) {
|
|
152
|
+
PagNodeKind[PagNodeKind["HeapObj"] = 0] = "HeapObj";
|
|
153
|
+
PagNodeKind[PagNodeKind["LocalVar"] = 1] = "LocalVar";
|
|
154
|
+
PagNodeKind[PagNodeKind["RefVar"] = 2] = "RefVar";
|
|
155
|
+
PagNodeKind[PagNodeKind["Param"] = 3] = "Param";
|
|
156
|
+
PagNodeKind[PagNodeKind["ThisRef"] = 4] = "ThisRef";
|
|
157
|
+
PagNodeKind[PagNodeKind["Function"] = 5] = "Function";
|
|
158
|
+
PagNodeKind[PagNodeKind["GlobalThis"] = 6] = "GlobalThis";
|
|
159
|
+
PagNodeKind[PagNodeKind["ExportInfo"] = 7] = "ExportInfo";
|
|
160
|
+
})(PagNodeKind = exports.PagNodeKind || (exports.PagNodeKind = {}));
|
|
161
|
+
class PagNode extends BaseExplicitGraph_1.BaseNode {
|
|
162
|
+
constructor(id, cid = undefined, value, k, s) {
|
|
163
|
+
super(id, k);
|
|
164
|
+
this.cid = cid;
|
|
165
|
+
this.value = value;
|
|
166
|
+
this.stmt = s;
|
|
167
|
+
let ptaConfig = PointerAnalysisConfig_1.PointerAnalysisConfig.getInstance();
|
|
168
|
+
this.pointTo = new ptaConfig.ptsCollectionCtor();
|
|
169
|
+
}
|
|
170
|
+
getBasePt() {
|
|
171
|
+
return this.basePt;
|
|
172
|
+
}
|
|
173
|
+
setBasePt(pt) {
|
|
174
|
+
this.basePt = pt;
|
|
175
|
+
}
|
|
176
|
+
getCid() {
|
|
177
|
+
if (this.cid === undefined) {
|
|
178
|
+
throw new Error('cid is undefine');
|
|
179
|
+
}
|
|
180
|
+
return this.cid;
|
|
181
|
+
}
|
|
182
|
+
setCid(cid) {
|
|
183
|
+
this.cid = cid;
|
|
184
|
+
}
|
|
185
|
+
setStmt(s) {
|
|
186
|
+
this.stmt = s;
|
|
187
|
+
}
|
|
188
|
+
getStmt() {
|
|
189
|
+
return this.stmt;
|
|
190
|
+
}
|
|
191
|
+
hasOutgoingCopyEdge() {
|
|
192
|
+
return (this.copyOutEdges.size !== 0);
|
|
193
|
+
}
|
|
194
|
+
getOutgoingCopyEdges() {
|
|
195
|
+
return this.copyOutEdges;
|
|
196
|
+
}
|
|
197
|
+
getIncomingCopyEdges() {
|
|
198
|
+
return this.copyInEdges;
|
|
199
|
+
}
|
|
200
|
+
getOutgoingLoadEdges() {
|
|
201
|
+
return this.loadOutEdges;
|
|
202
|
+
}
|
|
203
|
+
getOutgoingWriteEdges() {
|
|
204
|
+
return this.writeOutEdges;
|
|
205
|
+
}
|
|
206
|
+
getIncomingWriteEdges() {
|
|
207
|
+
return this.writeInEdges;
|
|
208
|
+
}
|
|
209
|
+
getOutgoingThisEdges() {
|
|
210
|
+
return this.thisOutEdges;
|
|
211
|
+
}
|
|
212
|
+
getIncomingThisEdges() {
|
|
213
|
+
return this.thisInEdges;
|
|
214
|
+
}
|
|
215
|
+
addAddressInEdge(e) {
|
|
216
|
+
this.addressInEdges === undefined ? this.addressInEdges = new Set() : undefined;
|
|
217
|
+
this.addressInEdges.add(e);
|
|
218
|
+
this.addIncomingEdge(e);
|
|
219
|
+
}
|
|
220
|
+
addAddressOutEdge(e) {
|
|
221
|
+
this.addressOutEdges === undefined ? this.addressOutEdges = new Set() : undefined;
|
|
222
|
+
this.addressOutEdges.add(e);
|
|
223
|
+
this.addOutgoingEdge(e);
|
|
224
|
+
}
|
|
225
|
+
addCopyInEdge(e) {
|
|
226
|
+
this.copyInEdges === undefined ? this.copyInEdges = new Set() : undefined;
|
|
227
|
+
this.copyInEdges.add(e);
|
|
228
|
+
this.addIncomingEdge(e);
|
|
229
|
+
}
|
|
230
|
+
addCopyOutEdge(e) {
|
|
231
|
+
this.copyOutEdges === undefined ? this.copyOutEdges = new Set() : undefined;
|
|
232
|
+
this.copyOutEdges.add(e);
|
|
233
|
+
this.addOutgoingEdge(e);
|
|
234
|
+
}
|
|
235
|
+
addLoadInEdge(e) {
|
|
236
|
+
this.loadInEdges === undefined ? this.loadInEdges = new Set() : undefined;
|
|
237
|
+
this.loadInEdges.add(e);
|
|
238
|
+
this.addIncomingEdge(e);
|
|
239
|
+
}
|
|
240
|
+
addLoadOutEdge(e) {
|
|
241
|
+
this.loadOutEdges === undefined ? this.loadOutEdges = new Set() : undefined;
|
|
242
|
+
this.loadOutEdges.add(e);
|
|
243
|
+
this.addOutgoingEdge(e);
|
|
244
|
+
}
|
|
245
|
+
addWriteInEdge(e) {
|
|
246
|
+
var _a;
|
|
247
|
+
this.writeInEdges = (_a = this.writeInEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
248
|
+
this.writeInEdges.add(e);
|
|
249
|
+
this.addIncomingEdge(e);
|
|
250
|
+
}
|
|
251
|
+
addWriteOutEdge(e) {
|
|
252
|
+
var _a;
|
|
253
|
+
this.writeOutEdges = (_a = this.writeOutEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
254
|
+
this.writeOutEdges.add(e);
|
|
255
|
+
this.addOutgoingEdge(e);
|
|
256
|
+
}
|
|
257
|
+
addThisInEdge(e) {
|
|
258
|
+
var _a;
|
|
259
|
+
this.thisInEdges = (_a = this.thisInEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
260
|
+
this.thisInEdges.add(e);
|
|
261
|
+
this.addIncomingEdge(e);
|
|
262
|
+
}
|
|
263
|
+
addThisOutEdge(e) {
|
|
264
|
+
var _a;
|
|
265
|
+
this.thisOutEdges = (_a = this.thisOutEdges) !== null && _a !== void 0 ? _a : new Set();
|
|
266
|
+
this.thisOutEdges.add(e);
|
|
267
|
+
this.addOutgoingEdge(e);
|
|
268
|
+
}
|
|
269
|
+
getValue() {
|
|
270
|
+
return this.value;
|
|
271
|
+
}
|
|
272
|
+
getPointTo() {
|
|
273
|
+
return this.pointTo;
|
|
274
|
+
}
|
|
275
|
+
addPointToElement(node) {
|
|
276
|
+
this.pointTo.insert(node);
|
|
277
|
+
}
|
|
278
|
+
setPointTo(pts) {
|
|
279
|
+
this.pointTo = pts;
|
|
280
|
+
}
|
|
281
|
+
getOutEdges() {
|
|
282
|
+
return {
|
|
283
|
+
AddressEdge: this.addressOutEdges,
|
|
284
|
+
CopyEdge: this.copyOutEdges,
|
|
285
|
+
LoadEdge: this.loadOutEdges,
|
|
286
|
+
WriteEdge: this.writeOutEdges
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
getClonedFrom() {
|
|
290
|
+
return this.clonedFrom;
|
|
291
|
+
}
|
|
292
|
+
setClonedFrom(id) {
|
|
293
|
+
this.clonedFrom = id;
|
|
294
|
+
}
|
|
295
|
+
getDotAttr() {
|
|
296
|
+
switch (this.getKind()) {
|
|
297
|
+
case PagNodeKind.HeapObj:
|
|
298
|
+
case PagNodeKind.Function:
|
|
299
|
+
case PagNodeKind.GlobalThis:
|
|
300
|
+
return 'shape=box3d';
|
|
301
|
+
case PagNodeKind.LocalVar:
|
|
302
|
+
return 'shape=box';
|
|
303
|
+
case PagNodeKind.RefVar:
|
|
304
|
+
return 'shape=component';
|
|
305
|
+
case PagNodeKind.Param:
|
|
306
|
+
return 'shape=box';
|
|
307
|
+
case PagNodeKind.ExportInfo:
|
|
308
|
+
return 'shape=tab,color=purple';
|
|
309
|
+
case PagNodeKind.ThisRef:
|
|
310
|
+
return 'shape=box,color=orange';
|
|
311
|
+
default:
|
|
312
|
+
return 'shape=box';
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
getDotLabel() {
|
|
316
|
+
var _a;
|
|
317
|
+
let label;
|
|
318
|
+
let param;
|
|
319
|
+
label = PagNodeKind[this.getKind()];
|
|
320
|
+
label = label + ` ID: ${this.getID()} Ctx: ${this.cid}`;
|
|
321
|
+
if (this.basePt) {
|
|
322
|
+
label = label + ` base:{${this.basePt}}`;
|
|
323
|
+
}
|
|
324
|
+
label = label + ` pts:{${Array.from(this.pointTo).join(',')}}`;
|
|
325
|
+
if (this.getKind() === PagNodeKind.Param) {
|
|
326
|
+
param = this.value;
|
|
327
|
+
label = label + `\nParam#${param.getIndex()} ${param.toString()}`;
|
|
328
|
+
}
|
|
329
|
+
if (this.getKind() === PagNodeKind.ThisRef) {
|
|
330
|
+
label = label + `\n${this.value.toString()}`;
|
|
331
|
+
}
|
|
332
|
+
if (this.stmt) {
|
|
333
|
+
label = label + `\n${this.stmt.toString()}`;
|
|
334
|
+
let method = (_a = this.stmt.getCfg()) === null || _a === void 0 ? void 0 : _a.getDeclaringMethod().getSubSignature().toString();
|
|
335
|
+
if (method) {
|
|
336
|
+
label = label + '\n' + method;
|
|
337
|
+
}
|
|
338
|
+
label = label + ' ln: ' + this.stmt.getOriginPositionInfo().getLineNo();
|
|
339
|
+
}
|
|
340
|
+
else if (this.value) {
|
|
341
|
+
label += `\n${this.value.toString()}`;
|
|
342
|
+
}
|
|
343
|
+
return label;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
exports.PagNode = PagNode;
|
|
347
|
+
class PagLocalNode extends PagNode {
|
|
348
|
+
constructor(id, cid = undefined, value, stmt) {
|
|
349
|
+
super(id, cid, value, PagNodeKind.LocalVar, stmt);
|
|
350
|
+
this.storageLinked = false;
|
|
351
|
+
this.sdkParam = false;
|
|
352
|
+
}
|
|
353
|
+
addRelatedDynCallSite(cs) {
|
|
354
|
+
var _a;
|
|
355
|
+
this.relatedDynamicCallSite = (_a = this.relatedDynamicCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
356
|
+
this.relatedDynamicCallSite.add(cs);
|
|
357
|
+
}
|
|
358
|
+
getRelatedDynCallSites() {
|
|
359
|
+
var _a;
|
|
360
|
+
return (_a = this.relatedDynamicCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
361
|
+
}
|
|
362
|
+
addRelatedUnknownCallSite(cs) {
|
|
363
|
+
var _a;
|
|
364
|
+
this.relatedUnknownCallSite = (_a = this.relatedUnknownCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
365
|
+
this.relatedUnknownCallSite.add(cs);
|
|
366
|
+
}
|
|
367
|
+
getRelatedUnknownCallSites() {
|
|
368
|
+
var _a;
|
|
369
|
+
return (_a = this.relatedUnknownCallSite) !== null && _a !== void 0 ? _a : new Set();
|
|
370
|
+
}
|
|
371
|
+
setStorageLink(storageType, propertyName) {
|
|
372
|
+
this.storageLinked = true;
|
|
373
|
+
this.storageType = storageType;
|
|
374
|
+
this.propertyName = propertyName;
|
|
375
|
+
}
|
|
376
|
+
getStorage() {
|
|
377
|
+
return {
|
|
378
|
+
StorageType: this.storageType,
|
|
379
|
+
PropertyName: this.propertyName
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
isStorageLinked() {
|
|
383
|
+
return this.storageLinked;
|
|
384
|
+
}
|
|
385
|
+
setSdkParam() {
|
|
386
|
+
this.sdkParam = true;
|
|
387
|
+
}
|
|
388
|
+
isSdkParam() {
|
|
389
|
+
return this.sdkParam;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
exports.PagLocalNode = PagLocalNode;
|
|
393
|
+
class PagInstanceFieldNode extends PagNode {
|
|
394
|
+
constructor(id, cid = undefined, instanceFieldRef, stmt) {
|
|
395
|
+
super(id, cid, instanceFieldRef, PagNodeKind.RefVar, stmt);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
exports.PagInstanceFieldNode = PagInstanceFieldNode;
|
|
399
|
+
class PagStaticFieldNode extends PagNode {
|
|
400
|
+
constructor(id, cid = undefined, staticFieldRef, stmt) {
|
|
401
|
+
super(id, cid, staticFieldRef, PagNodeKind.RefVar, stmt);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.PagStaticFieldNode = PagStaticFieldNode;
|
|
405
|
+
class PagThisRefNode extends PagNode {
|
|
406
|
+
constructor(id, thisRef) {
|
|
407
|
+
super(id, DUMMY_PAG_NODE_ID, thisRef, PagNodeKind.ThisRef);
|
|
408
|
+
this.pointToNode = [];
|
|
409
|
+
}
|
|
410
|
+
getThisPTNode() {
|
|
411
|
+
return this.pointToNode;
|
|
412
|
+
}
|
|
413
|
+
addPTNode(ptNode) {
|
|
414
|
+
this.pointToNode.push(ptNode);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
exports.PagThisRefNode = PagThisRefNode;
|
|
418
|
+
class PagArrayNode extends PagNode {
|
|
419
|
+
constructor(id, cid = undefined, expr, stmt) {
|
|
420
|
+
super(id, cid, expr, PagNodeKind.LocalVar, stmt);
|
|
421
|
+
this.base = expr.getBase();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
exports.PagArrayNode = PagArrayNode;
|
|
425
|
+
/**
|
|
426
|
+
* below is heapObj like Node
|
|
427
|
+
*/
|
|
428
|
+
class PagNewExprNode extends PagNode {
|
|
429
|
+
constructor(id, cid = undefined, expr, stmt) {
|
|
430
|
+
super(id, cid, expr, PagNodeKind.HeapObj, stmt);
|
|
431
|
+
}
|
|
432
|
+
addFieldNode(fieldSignature, nodeID) {
|
|
433
|
+
if (!this.fieldNodes) {
|
|
434
|
+
this.fieldNodes = new Map();
|
|
435
|
+
}
|
|
436
|
+
if (this.fieldNodes.has(fieldSignature.getFieldSignature().toString())) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
this.fieldNodes.set(fieldSignature.getFieldSignature().toString(), nodeID);
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
getFieldNode(fieldSignature) {
|
|
443
|
+
if (!this.fieldNodes) {
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
return this.fieldNodes.get(fieldSignature.getFieldSignature().toString());
|
|
447
|
+
}
|
|
448
|
+
getFieldNodes() {
|
|
449
|
+
if (!this.fieldNodes) {
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
return this.fieldNodes;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
exports.PagNewExprNode = PagNewExprNode;
|
|
456
|
+
class PagNewContainerExprNode extends PagNode {
|
|
457
|
+
constructor(id, cid = undefined, expr, stmt) {
|
|
458
|
+
super(id, cid, expr, PagNodeKind.HeapObj, stmt);
|
|
459
|
+
}
|
|
460
|
+
addElementNode(nodeID) {
|
|
461
|
+
if (!this.elementNode) {
|
|
462
|
+
this.elementNode = nodeID;
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
getElementNode() {
|
|
467
|
+
if (this.elementNode) {
|
|
468
|
+
return this.elementNode;
|
|
469
|
+
}
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
exports.PagNewContainerExprNode = PagNewContainerExprNode;
|
|
474
|
+
class PagParamNode extends PagNode {
|
|
475
|
+
constructor(id, cid = undefined, r, stmt) {
|
|
476
|
+
super(id, cid, r, PagNodeKind.Param, stmt);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
exports.PagParamNode = PagParamNode;
|
|
480
|
+
class PagFuncNode extends PagNode {
|
|
481
|
+
// TODO: may add obj interface
|
|
482
|
+
constructor(id, cid = undefined, r, stmt, method) {
|
|
483
|
+
super(id, cid, r, PagNodeKind.Function, stmt);
|
|
484
|
+
if (method) {
|
|
485
|
+
this.methodSignature = method;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
setMethod(method) {
|
|
489
|
+
this.methodSignature = method;
|
|
490
|
+
}
|
|
491
|
+
getMethod() {
|
|
492
|
+
return this.methodSignature;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
exports.PagFuncNode = PagFuncNode;
|
|
496
|
+
/**
|
|
497
|
+
* almost same as PagNewExprNode, used only for globalThis and its field reference
|
|
498
|
+
*/
|
|
499
|
+
class PagGlobalThisNode extends PagNode {
|
|
500
|
+
constructor(id, cid = undefined, r, stmt) {
|
|
501
|
+
super(id, cid, r, PagNodeKind.GlobalThis, stmt);
|
|
502
|
+
this.fieldNodes = new Map();
|
|
503
|
+
}
|
|
504
|
+
addFieldNode(fieldSignature, nodeID) {
|
|
505
|
+
if (this.fieldNodes.has(fieldSignature.getFieldSignature().toString())) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
this.fieldNodes.set(fieldSignature.getFieldSignature().toString(), nodeID);
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
getFieldNode(fieldSignature) {
|
|
512
|
+
return this.fieldNodes.get(fieldSignature.getFieldSignature().toString());
|
|
513
|
+
}
|
|
514
|
+
getFieldNodes() {
|
|
515
|
+
return this.fieldNodes;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
exports.PagGlobalThisNode = PagGlobalThisNode;
|
|
519
|
+
class Pag extends BaseExplicitGraph_1.BaseExplicitGraph {
|
|
520
|
+
constructor() {
|
|
521
|
+
super(...arguments);
|
|
522
|
+
this.contextValueToIdMap = new Map();
|
|
523
|
+
// contextBaseToIdMap will only be used in instance field
|
|
524
|
+
// Value: instance field base value, NodeID: abstract nodes
|
|
525
|
+
this.contextBaseToIdMap = new Map();
|
|
526
|
+
// for reanalyze, will return new addr edges
|
|
527
|
+
this.stashAddrEdge = new Set();
|
|
528
|
+
this.addrEdge = new Set();
|
|
529
|
+
this.clonedNodeMap = new Map();
|
|
530
|
+
}
|
|
531
|
+
getCG() {
|
|
532
|
+
return this.cg;
|
|
533
|
+
}
|
|
534
|
+
/*
|
|
535
|
+
* Clone a PagNode with same cid/value/stmt,
|
|
536
|
+
* but different Node ID
|
|
537
|
+
*/
|
|
538
|
+
getOrClonePagNode(src, basePt) {
|
|
539
|
+
if (src.getBasePt() !== undefined) {
|
|
540
|
+
throw new Error('This is a cloned ref node, can not be cloned again');
|
|
541
|
+
}
|
|
542
|
+
let cloneSet = this.clonedNodeMap.get(src.getID());
|
|
543
|
+
if (!cloneSet) {
|
|
544
|
+
cloneSet = new Map();
|
|
545
|
+
this.clonedNodeMap.set(src.getID(), cloneSet);
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
let nodeID = cloneSet.get(basePt);
|
|
549
|
+
if (nodeID) {
|
|
550
|
+
return this.getNode(nodeID);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
// Not found
|
|
554
|
+
let cloneNode = this.addPagNode(src.getCid(), src.getValue(), src.getStmt(), false);
|
|
555
|
+
cloneNode.setClonedFrom(src.getID());
|
|
556
|
+
cloneSet.set(basePt, cloneNode.getID());
|
|
557
|
+
return cloneNode;
|
|
558
|
+
}
|
|
559
|
+
getOrClonePagFieldNode(src, basePt) {
|
|
560
|
+
let baseNode = this.getNode(basePt);
|
|
561
|
+
if (baseNode instanceof PagNewExprNode || baseNode instanceof PagGlobalThisNode) {
|
|
562
|
+
// check if real field node has been created with basePT, using FieldSignature as key
|
|
563
|
+
let existedNode = baseNode.getFieldNode(src.getValue());
|
|
564
|
+
if (existedNode) {
|
|
565
|
+
return this.getNode(existedNode);
|
|
566
|
+
}
|
|
567
|
+
let fieldNode = this.getOrClonePagNode(src, basePt);
|
|
568
|
+
baseNode.addFieldNode(src.getValue(), fieldNode.getID());
|
|
569
|
+
fieldNode.setBasePt(basePt);
|
|
570
|
+
return fieldNode;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
logger.error(`Error clone field node ${src.getValue()}`);
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
getOrClonePagContainerFieldNode(basePt, src, base) {
|
|
578
|
+
let baseNode = this.getNode(basePt);
|
|
579
|
+
if (baseNode instanceof PagNewContainerExprNode) {
|
|
580
|
+
// check if Array Ref real node has been created or not, if not: create a real Array Ref node
|
|
581
|
+
let existedNode = baseNode.getElementNode();
|
|
582
|
+
let fieldNode;
|
|
583
|
+
if (existedNode) {
|
|
584
|
+
return this.getNode(existedNode);
|
|
585
|
+
}
|
|
586
|
+
if (src) {
|
|
587
|
+
fieldNode = this.getOrClonePagNode(src, basePt);
|
|
588
|
+
}
|
|
589
|
+
else if (base) {
|
|
590
|
+
const containerFieldSignature = new ArkSignature_1.FieldSignature('field', new ArkSignature_1.ClassSignature('container', new ArkSignature_1.FileSignature('container', 'lib.es2015.collection.d.ts')), new Type_1.UnclearReferenceType(''));
|
|
591
|
+
fieldNode = this.getOrClonePagNode(
|
|
592
|
+
// TODO: cid check
|
|
593
|
+
this.addPagNode(0, new Ref_1.ArkInstanceFieldRef(base, containerFieldSignature)), basePt);
|
|
594
|
+
}
|
|
595
|
+
baseNode.addElementNode(fieldNode.getID());
|
|
596
|
+
fieldNode.setBasePt(basePt);
|
|
597
|
+
return fieldNode;
|
|
598
|
+
}
|
|
599
|
+
else if (baseNode instanceof PagNewExprNode) {
|
|
600
|
+
// In some cases, the value of a variable of array type may not be an explicit array object.
|
|
601
|
+
// For example, it could be a return value of a function (assuming that the call depth has
|
|
602
|
+
// exceeded the k-limit).
|
|
603
|
+
// In such situation, the `baseNode` will be a PagNewExprNode instead of a PagNewContainerExprNode,
|
|
604
|
+
// and a warning will be raised.
|
|
605
|
+
logger.warn(`[PTA]: Trying to clone an array from a PagNewExprNode instead of a PagNewContainerExprNode`);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
throw new Error(`Error clone array field node ${baseNode.getValue()}`);
|
|
609
|
+
}
|
|
610
|
+
return undefined;
|
|
611
|
+
}
|
|
612
|
+
addPagNode(cid, value, stmt, refresh = true) {
|
|
613
|
+
let id = this.nodeNum;
|
|
614
|
+
let pagNode;
|
|
615
|
+
if (value instanceof Local_1.Local) {
|
|
616
|
+
pagNode = this.handleLocalNode(id, cid, value, stmt);
|
|
617
|
+
}
|
|
618
|
+
else if (value instanceof Ref_1.ArkInstanceFieldRef) {
|
|
619
|
+
pagNode = this.handleInstanceFieldNode(id, cid, value, stmt);
|
|
620
|
+
}
|
|
621
|
+
else if (value instanceof Ref_1.ArkStaticFieldRef) {
|
|
622
|
+
pagNode = this.handleStaticFieldNode(id, cid, value, stmt);
|
|
623
|
+
}
|
|
624
|
+
else if (value instanceof Ref_1.ArkArrayRef) {
|
|
625
|
+
pagNode = new PagArrayNode(id, cid, value, stmt);
|
|
626
|
+
}
|
|
627
|
+
else if (value instanceof Expr_1.ArkNewExpr) {
|
|
628
|
+
pagNode = this.handleNewExprNode(id, cid, value, stmt);
|
|
629
|
+
}
|
|
630
|
+
else if (value instanceof Expr_1.ArkNewArrayExpr) {
|
|
631
|
+
pagNode = new PagNewContainerExprNode(id, cid, value, stmt);
|
|
632
|
+
}
|
|
633
|
+
else if (value instanceof Ref_1.ArkParameterRef) {
|
|
634
|
+
pagNode = new PagParamNode(id, cid, value, stmt);
|
|
635
|
+
}
|
|
636
|
+
else if (value instanceof Ref_1.ArkThisRef) {
|
|
637
|
+
throw new Error('This Node needs to use addThisNode method');
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
throw new Error('unsupported Value type ' + value.getType().toString());
|
|
641
|
+
}
|
|
642
|
+
this.addNode(pagNode);
|
|
643
|
+
this.addContextOrExportInfoMap(refresh, cid, id, value, pagNode, stmt);
|
|
644
|
+
return pagNode;
|
|
645
|
+
}
|
|
646
|
+
handleLocalNode(id, cid, value, stmt) {
|
|
647
|
+
const valueType = value.getType();
|
|
648
|
+
if (valueType instanceof Type_1.FunctionType && value.getDeclaringStmt() === null) {
|
|
649
|
+
return new PagFuncNode(id, cid, value, stmt, valueType.getMethodSignature());
|
|
650
|
+
}
|
|
651
|
+
else if (value.getName() === TSConst_1.GLOBAL_THIS_NAME && value.getDeclaringStmt() == null) {
|
|
652
|
+
return new PagGlobalThisNode(id, -1, value);
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
return new PagLocalNode(id, cid, value, stmt);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
handleInstanceFieldNode(id, cid, value, stmt) {
|
|
659
|
+
return this.createFieldNode(id, cid, value, stmt);
|
|
660
|
+
}
|
|
661
|
+
handleStaticFieldNode(id, cid, value, stmt) {
|
|
662
|
+
return this.createFieldNode(id, cid, value, stmt);
|
|
663
|
+
}
|
|
664
|
+
createFieldNode(id, cid, value, stmt) {
|
|
665
|
+
if (value.getType() instanceof Type_1.FunctionType) {
|
|
666
|
+
return new PagFuncNode(id, cid, value, stmt, value.getType().getMethodSignature());
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
return value instanceof Ref_1.ArkStaticFieldRef ? new PagStaticFieldNode(id, cid, value, stmt) : new PagInstanceFieldNode(id, cid, value, stmt);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
handleNewExprNode(id, cid, value, stmt) {
|
|
673
|
+
const classSignature = value.getClassType().getClassSignature();
|
|
674
|
+
if ((0, PTAUtils_1.IsCollectionClass)(classSignature)) {
|
|
675
|
+
return new PagNewContainerExprNode(id, cid, value, stmt);
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
return new PagNewExprNode(id, cid, value, stmt);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
addContextOrExportInfoMap(refresh, cid, id, value, pagNode, stmt) {
|
|
682
|
+
if (!(value instanceof ArkExport_1.ExportInfo)) {
|
|
683
|
+
this.addContextMap(refresh, cid, id, value, stmt, pagNode);
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
this.addExportInfoMap(id, value);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
addExportInfoMap(id, v) {
|
|
690
|
+
var _a;
|
|
691
|
+
this.ExportInfoToIdMap = (_a = this.ExportInfoToIdMap) !== null && _a !== void 0 ? _a : new Map();
|
|
692
|
+
this.ExportInfoToIdMap.set(v, id);
|
|
693
|
+
}
|
|
694
|
+
addContextMap(refresh, cid, id, value, stmt, pagNode) {
|
|
695
|
+
var _a;
|
|
696
|
+
if (!refresh) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
let ctx2NdMap = this.contextValueToIdMap.get(value);
|
|
700
|
+
if (!ctx2NdMap) {
|
|
701
|
+
ctx2NdMap = new Map();
|
|
702
|
+
this.contextValueToIdMap.set(value, ctx2NdMap);
|
|
703
|
+
}
|
|
704
|
+
ctx2NdMap.set(cid, id);
|
|
705
|
+
if (value instanceof Ref_1.ArkInstanceFieldRef || value instanceof Ref_1.ArkArrayRef) {
|
|
706
|
+
let base = value.getBase();
|
|
707
|
+
//TODO: remove below once this Local is not uniq in %instInit is fix
|
|
708
|
+
if (base instanceof Local_1.Local && base.getName() === 'this') {
|
|
709
|
+
(_a = stmt === null || stmt === void 0 ? void 0 : stmt.getCfg()) === null || _a === void 0 ? void 0 : _a.getStmts().forEach(s => {
|
|
710
|
+
if (s instanceof Stmt_1.ArkAssignStmt &&
|
|
711
|
+
(s.getLeftOp()) instanceof Local_1.Local &&
|
|
712
|
+
s.getLeftOp().getName() === 'this') {
|
|
713
|
+
base = s.getLeftOp();
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
let ctxMap = this.contextBaseToIdMap.get(base);
|
|
719
|
+
if (ctxMap === undefined) {
|
|
720
|
+
ctxMap = new Map();
|
|
721
|
+
ctxMap.set(cid, [pagNode.getID()]);
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
let nodes = ctxMap.get(cid);
|
|
725
|
+
if (nodes === undefined) {
|
|
726
|
+
nodes = [pagNode.getID()];
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
nodes.push(pagNode.getID());
|
|
730
|
+
}
|
|
731
|
+
ctxMap.set(cid, nodes);
|
|
732
|
+
}
|
|
733
|
+
this.contextBaseToIdMap.set(base, ctxMap);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/*
|
|
737
|
+
* This node has no context info
|
|
738
|
+
* but point to node info
|
|
739
|
+
*/
|
|
740
|
+
addPagThisRefNode(value) {
|
|
741
|
+
let id = this.nodeNum;
|
|
742
|
+
let pagNode = new PagThisRefNode(id, value);
|
|
743
|
+
this.addNode(pagNode);
|
|
744
|
+
return pagNode;
|
|
745
|
+
}
|
|
746
|
+
addPagThisLocalNode(ptNode, value) {
|
|
747
|
+
let id = this.nodeNum;
|
|
748
|
+
let pagNode = new PagLocalNode(id, ptNode, value);
|
|
749
|
+
this.addNode(pagNode);
|
|
750
|
+
return pagNode;
|
|
751
|
+
}
|
|
752
|
+
getOrNewThisRefNode(thisRefNodeID, value) {
|
|
753
|
+
if (thisRefNodeID !== -1) {
|
|
754
|
+
return this.getNode(thisRefNodeID);
|
|
755
|
+
}
|
|
756
|
+
let thisRefNode = this.addPagThisRefNode(value);
|
|
757
|
+
return thisRefNode;
|
|
758
|
+
}
|
|
759
|
+
getOrNewThisLocalNode(cid, ptNode, value, s) {
|
|
760
|
+
if (ptNode !== -1) {
|
|
761
|
+
return this.getNode(ptNode);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
return this.getOrNewNode(cid, value, s);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
hasExportNode(v) {
|
|
768
|
+
var _a;
|
|
769
|
+
this.ExportInfoToIdMap = (_a = this.ExportInfoToIdMap) !== null && _a !== void 0 ? _a : new Map();
|
|
770
|
+
return this.ExportInfoToIdMap.get(v);
|
|
771
|
+
}
|
|
772
|
+
hasCtxNode(cid, v) {
|
|
773
|
+
let ctx2nd = this.contextValueToIdMap.get(v);
|
|
774
|
+
if (!ctx2nd) {
|
|
775
|
+
return undefined;
|
|
776
|
+
}
|
|
777
|
+
let ndId = ctx2nd.get(cid);
|
|
778
|
+
if (!ndId) {
|
|
779
|
+
return undefined;
|
|
780
|
+
}
|
|
781
|
+
return ndId;
|
|
782
|
+
}
|
|
783
|
+
hasCtxRetNode(cid, v) {
|
|
784
|
+
let ctx2nd = this.contextValueToIdMap.get(v);
|
|
785
|
+
if (!ctx2nd) {
|
|
786
|
+
return undefined;
|
|
787
|
+
}
|
|
788
|
+
let ndId = ctx2nd.get(cid);
|
|
789
|
+
if (!ndId) {
|
|
790
|
+
return undefined;
|
|
791
|
+
}
|
|
792
|
+
return ndId;
|
|
793
|
+
}
|
|
794
|
+
getOrNewNode(cid, v, s) {
|
|
795
|
+
let nodeId;
|
|
796
|
+
// Value
|
|
797
|
+
if (!(v instanceof ArkExport_1.ExportInfo)) {
|
|
798
|
+
nodeId = this.hasCtxNode(cid, v);
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
// ExportInfo
|
|
802
|
+
nodeId = this.hasExportNode(v);
|
|
803
|
+
}
|
|
804
|
+
if (nodeId !== undefined) {
|
|
805
|
+
return this.getNode(nodeId);
|
|
806
|
+
}
|
|
807
|
+
return this.addPagNode(cid, v, s);
|
|
808
|
+
}
|
|
809
|
+
getNodesByValue(v) {
|
|
810
|
+
return this.contextValueToIdMap.get(v);
|
|
811
|
+
}
|
|
812
|
+
getNodesByBaseValue(v) {
|
|
813
|
+
return this.contextBaseToIdMap.get(v);
|
|
814
|
+
}
|
|
815
|
+
addPagEdge(src, dst, kind, stmt) {
|
|
816
|
+
// TODO: check if the edge already existing
|
|
817
|
+
let edge = new PagEdge(src, dst, kind, stmt);
|
|
818
|
+
if (this.ifEdgeExisting(edge)) {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
switch (kind) {
|
|
822
|
+
case PagEdgeKind.Copy:
|
|
823
|
+
case PagEdgeKind.InterProceduralCopy:
|
|
824
|
+
src.addCopyOutEdge(edge);
|
|
825
|
+
dst.addCopyInEdge(edge);
|
|
826
|
+
if (src instanceof PagFuncNode ||
|
|
827
|
+
src instanceof PagGlobalThisNode ||
|
|
828
|
+
src instanceof PagNewExprNode ||
|
|
829
|
+
src instanceof PagNewContainerExprNode) {
|
|
830
|
+
this.addrEdge.add(edge);
|
|
831
|
+
this.stashAddrEdge.add(edge);
|
|
832
|
+
}
|
|
833
|
+
break;
|
|
834
|
+
case PagEdgeKind.Address:
|
|
835
|
+
src.addAddressOutEdge(edge);
|
|
836
|
+
dst.addAddressInEdge(edge);
|
|
837
|
+
this.addrEdge.add(edge);
|
|
838
|
+
this.stashAddrEdge.add(edge);
|
|
839
|
+
break;
|
|
840
|
+
case PagEdgeKind.Write:
|
|
841
|
+
src.addWriteOutEdge(edge);
|
|
842
|
+
dst.addWriteInEdge(edge);
|
|
843
|
+
break;
|
|
844
|
+
case PagEdgeKind.Load:
|
|
845
|
+
src.addLoadOutEdge(edge);
|
|
846
|
+
dst.addLoadInEdge(edge);
|
|
847
|
+
break;
|
|
848
|
+
case PagEdgeKind.This:
|
|
849
|
+
src.addThisOutEdge(edge);
|
|
850
|
+
dst.addThisInEdge(edge);
|
|
851
|
+
break;
|
|
852
|
+
default:
|
|
853
|
+
;
|
|
854
|
+
}
|
|
855
|
+
return true;
|
|
856
|
+
}
|
|
857
|
+
getAddrEdges() {
|
|
858
|
+
return this.stashAddrEdge;
|
|
859
|
+
}
|
|
860
|
+
resetAddrEdges() {
|
|
861
|
+
this.stashAddrEdge.clear();
|
|
862
|
+
}
|
|
863
|
+
getGraphName() {
|
|
864
|
+
return 'PAG';
|
|
865
|
+
}
|
|
866
|
+
dump(name) {
|
|
867
|
+
let printer = new GraphPrinter_1.GraphPrinter(this);
|
|
868
|
+
PrinterBuilder_1.PrinterBuilder.dump(printer, name);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
exports.Pag = Pag;
|
|
872
|
+
class FuncPag {
|
|
873
|
+
getInternalEdges() {
|
|
874
|
+
return this.internalEdges;
|
|
875
|
+
}
|
|
876
|
+
addNormalCallSite(cs) {
|
|
877
|
+
var _a;
|
|
878
|
+
this.normalCallSites = (_a = this.normalCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
879
|
+
this.normalCallSites.add(cs);
|
|
880
|
+
}
|
|
881
|
+
getNormalCallSites() {
|
|
882
|
+
var _a;
|
|
883
|
+
this.normalCallSites = (_a = this.normalCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
884
|
+
return this.normalCallSites;
|
|
885
|
+
}
|
|
886
|
+
addDynamicCallSite(cs) {
|
|
887
|
+
var _a;
|
|
888
|
+
this.dynamicCallSites = (_a = this.dynamicCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
889
|
+
this.dynamicCallSites.add(cs);
|
|
890
|
+
}
|
|
891
|
+
getDynamicCallSites() {
|
|
892
|
+
var _a;
|
|
893
|
+
this.dynamicCallSites = (_a = this.dynamicCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
894
|
+
return this.dynamicCallSites;
|
|
895
|
+
}
|
|
896
|
+
addUnknownCallSite(cs) {
|
|
897
|
+
var _a;
|
|
898
|
+
this.unknownCallSites = (_a = this.unknownCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
899
|
+
this.unknownCallSites.add(cs);
|
|
900
|
+
}
|
|
901
|
+
getUnknownCallSites() {
|
|
902
|
+
var _a;
|
|
903
|
+
this.unknownCallSites = (_a = this.unknownCallSites) !== null && _a !== void 0 ? _a : new Set();
|
|
904
|
+
return this.unknownCallSites;
|
|
905
|
+
}
|
|
906
|
+
addInternalEdge(stmt, k) {
|
|
907
|
+
this.internalEdges === undefined ? this.internalEdges = new Set() : undefined;
|
|
908
|
+
let lhOp = stmt.getLeftOp();
|
|
909
|
+
let rhOp = stmt.getRightOp();
|
|
910
|
+
if (rhOp instanceof Constant_1.Constant) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
let iEdge = { src: rhOp, dst: lhOp, kind: k, stmt: stmt };
|
|
914
|
+
this.internalEdges.add(iEdge);
|
|
915
|
+
return true;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
exports.FuncPag = FuncPag;
|
|
919
|
+
class InterFuncPag {
|
|
920
|
+
constructor() {
|
|
921
|
+
this.interFuncEdges = new Set();
|
|
922
|
+
}
|
|
923
|
+
getInterProceduralEdges() {
|
|
924
|
+
return this.interFuncEdges;
|
|
925
|
+
}
|
|
926
|
+
addToInterProceduralEdgeSet(e) {
|
|
927
|
+
this.interFuncEdges.add(e);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
exports.InterFuncPag = InterFuncPag;
|