arkanalyzer 1.0.81 → 1.0.83
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/callgraph/algorithm/AbstractAnalysis.d.ts +1 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +8 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +20 -16
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +5 -2
- package/lib/core/common/ArkValueTransformer.d.ts +1 -0
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +32 -4
- package/lib/core/common/Const.d.ts +12 -0
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +15 -2
- package/lib/core/common/DummyMainCreater.d.ts +32 -2
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +235 -97
- package/lib/core/common/EtsConst.d.ts +1 -0
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +3 -2
- package/lib/core/common/IRInference.d.ts +0 -7
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +11 -27
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +8 -15
- package/lib/core/graph/BasicBlock.d.ts +1 -1
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +4 -1
- package/lib/core/graph/builder/CfgBuilder.d.ts +1 -0
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +5 -1
- package/lib/core/graph/builder/ConditionBuilder.d.ts +1 -0
- package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ConditionBuilder.js +40 -24
- package/lib/core/inference/ModelInference.d.ts.map +1 -1
- package/lib/core/inference/ModelInference.js +31 -5
- package/lib/core/inference/ValueInference.d.ts +1 -36
- package/lib/core/inference/ValueInference.d.ts.map +1 -1
- package/lib/core/inference/ValueInference.js +1 -174
- package/lib/core/inference/abc/AbcInference.d.ts +7 -0
- package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
- package/lib/core/inference/abc/AbcInference.js +28 -2
- package/lib/core/inference/arkts/ArkTsInference.d.ts +43 -1
- package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
- package/lib/core/inference/arkts/ArkTsInference.js +189 -2
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +2 -5
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +6 -5
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/save/base/BasePrinter.d.ts.map +1 -1
- package/lib/save/base/BasePrinter.js +6 -5
- package/lib/save/source/SourceStmt.d.ts +2 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +51 -8
- package/lib/utils/IntMap.d.ts +48 -0
- package/lib/utils/IntMap.d.ts.map +1 -0
- package/lib/utils/IntMap.js +134 -0
- package/lib/utils/IntWorkList.d.ts +35 -0
- package/lib/utils/IntWorkList.d.ts.map +1 -0
- package/lib/utils/IntWorkList.js +97 -0
- package/lib/utils/PackedSparseMap.d.ts +26 -0
- package/lib/utils/PackedSparseMap.d.ts.map +1 -0
- package/lib/utils/PackedSparseMap.js +140 -0
- package/lib/utils/entryMethodUtils.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +20 -11
- package/lib/utils/logger.d.ts +1 -0
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/logger.js +1 -0
- package/package.json +2 -2
|
@@ -32,6 +32,11 @@ const ArkSignatureBuilder_1 = require("../model/builder/ArkSignatureBuilder");
|
|
|
32
32
|
const TSConst_1 = require("./TSConst");
|
|
33
33
|
const ArkMethodBuilder_1 = require("../model/builder/ArkMethodBuilder");
|
|
34
34
|
const ValueUtil_1 = require("./ValueUtil");
|
|
35
|
+
const Const_1 = require("./Const");
|
|
36
|
+
const Ref_1 = require("../base/Ref");
|
|
37
|
+
const EtsConst_1 = require("./EtsConst");
|
|
38
|
+
const COMPONENT_BASE_CLASSES = ['CustomComponent', 'ViewPU'];
|
|
39
|
+
const ABILITY_BASE_CLASSES = ['UIExtensionAbility', 'Ability', 'FormExtensionAbility', 'UIAbility', 'BackupExtensionAbility'];
|
|
35
40
|
/**
|
|
36
41
|
收集所有的onCreate,onStart等函数,构造一个虚拟函数,具体为:
|
|
37
42
|
%statInit()
|
|
@@ -57,96 +62,90 @@ return
|
|
|
57
62
|
*/
|
|
58
63
|
class DummyMainCreater {
|
|
59
64
|
constructor(scene) {
|
|
65
|
+
// entryMethods includes all UIAbility and Component lifecycle methods as well as all callback methods, but exclude the start and end methods
|
|
60
66
|
this.entryMethods = [];
|
|
67
|
+
this.entryClasses = [];
|
|
68
|
+
this.abilityCreateMethods = [];
|
|
69
|
+
this.abilityStageCreateMethods = [];
|
|
70
|
+
this.abilityStageDestroyMethods = [];
|
|
71
|
+
this.abilityDestroyMethods = [];
|
|
72
|
+
this.componentAppearMethods = [];
|
|
73
|
+
this.componentDisappearMethods = [];
|
|
74
|
+
this.componentDetachedMethods = [];
|
|
75
|
+
// every declaring class of method in entryMethods have its instance local which is used to be the base of instance invoke expr
|
|
61
76
|
this.classLocalMap = new Map();
|
|
62
77
|
this.dummyMain = new ArkMethod_1.ArkMethod();
|
|
63
78
|
this.tempLocalIndex = 0;
|
|
79
|
+
this.tempBlockIndex = 0;
|
|
64
80
|
this.scene = scene;
|
|
65
81
|
// Currently get entries from module.json5 can't visit all of abilities
|
|
66
|
-
// Todo: handle
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
82
|
+
// Todo: handle ability/component jump, then get entries from module.json5
|
|
83
|
+
this.getMethodsFromAllAbilities();
|
|
84
|
+
this.getEntryMethodsFromComponents();
|
|
85
|
+
this.getCallbackMethods();
|
|
70
86
|
}
|
|
71
87
|
setEntryMethods(methods) {
|
|
72
88
|
this.entryMethods = methods;
|
|
73
89
|
}
|
|
74
90
|
createDummyMain() {
|
|
75
91
|
var _a;
|
|
76
|
-
|
|
92
|
+
// step1: create dummy file
|
|
93
|
+
const dummyMainFile = new ArkFile_1.ArkFile(ArkFile_1.Language.ARKTS1_1);
|
|
77
94
|
dummyMainFile.setScene(this.scene);
|
|
78
|
-
const dummyMainFileSignature = new ArkSignature_1.FileSignature(this.scene.getProjectName(),
|
|
95
|
+
const dummyMainFileSignature = new ArkSignature_1.FileSignature(this.scene.getProjectName(), Const_1.DUMMY_FILE);
|
|
79
96
|
dummyMainFile.setFileSignature(dummyMainFileSignature);
|
|
80
97
|
this.scene.setFile(dummyMainFile);
|
|
98
|
+
// step2: create dummy class
|
|
81
99
|
const dummyMainClass = new ArkClass_1.ArkClass();
|
|
82
100
|
dummyMainClass.setDeclaringArkFile(dummyMainFile);
|
|
83
|
-
const dummyMainClassSignature = new ArkSignature_1.ClassSignature(
|
|
101
|
+
const dummyMainClassSignature = new ArkSignature_1.ClassSignature(Const_1.DUMMY_CLASS, dummyMainClass.getDeclaringArkFile().getFileSignature(), ((_a = dummyMainClass.getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getSignature()) || null);
|
|
84
102
|
dummyMainClass.setSignature(dummyMainClassSignature);
|
|
85
103
|
dummyMainFile.addArkClass(dummyMainClass);
|
|
86
|
-
|
|
104
|
+
// step3: create dummy method
|
|
87
105
|
this.dummyMain.setDeclaringArkClass(dummyMainClass);
|
|
88
|
-
const methodSubSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildMethodSubSignatureFromMethodName(
|
|
106
|
+
const methodSubSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildMethodSubSignatureFromMethodName(Const_1.DUMMY_METHOD);
|
|
89
107
|
const methodSignature = new ArkSignature_1.MethodSignature(this.dummyMain.getDeclaringArkClass().getSignature(), methodSubSignature);
|
|
90
108
|
this.dummyMain.setImplementationSignature(methodSignature);
|
|
91
109
|
this.dummyMain.setLineCol(0);
|
|
110
|
+
this.dummyMain.setIsGeneratedFlag(true);
|
|
92
111
|
(0, ArkMethodBuilder_1.checkAndUpdateMethod)(this.dummyMain, dummyMainClass);
|
|
93
112
|
dummyMainClass.addMethod(this.dummyMain);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
this.scene.addToMethodsMap(this.dummyMain);
|
|
114
|
+
// step4: create instance local for each class
|
|
115
|
+
for (const cls of this.entryClasses) {
|
|
116
|
+
if (cls.isDefaultArkClass()) {
|
|
98
117
|
continue;
|
|
99
118
|
}
|
|
100
|
-
|
|
101
|
-
let newLocal = null;
|
|
102
|
-
for (const local of this.classLocalMap.values()) {
|
|
103
|
-
if ((local === null || local === void 0 ? void 0 : local.getType()).getClassSignature() === declaringArkClass.getSignature()) {
|
|
104
|
-
newLocal = local;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
119
|
+
let newLocal = this.classLocalMap.get(cls);
|
|
108
120
|
if (!newLocal) {
|
|
109
|
-
newLocal = new Local_1.Local('%' + this.tempLocalIndex
|
|
110
|
-
this.
|
|
121
|
+
newLocal = new Local_1.Local('%' + this.tempLocalIndex++, new Type_1.ClassType(cls.getSignature()));
|
|
122
|
+
this.classLocalMap.set(cls, newLocal);
|
|
111
123
|
}
|
|
112
|
-
this.classLocalMap.set(method, newLocal);
|
|
113
|
-
}
|
|
114
|
-
for (const defaultMethod of defaultMethods) {
|
|
115
|
-
this.classLocalMap.set(defaultMethod, null);
|
|
116
124
|
}
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
125
|
+
// step5: create dummy method body
|
|
126
|
+
const localSet = new Set(this.classLocalMap.values());
|
|
127
|
+
const dummyCfg = new Cfg_1.Cfg();
|
|
128
|
+
this.dummyMain.setBody(new ArkBody_1.ArkBody(localSet, dummyCfg));
|
|
129
|
+
dummyCfg.setDeclaringMethod(this.dummyMain);
|
|
130
|
+
this.createDummyMainCfg();
|
|
120
131
|
this.addCfg2Stmt();
|
|
121
|
-
this.scene.addToMethodsMap(this.dummyMain);
|
|
122
132
|
}
|
|
123
|
-
addStaticInit(
|
|
124
|
-
let isStartingStmt = true;
|
|
133
|
+
addStaticInit(firstBlock) {
|
|
125
134
|
for (const method of this.scene.getStaticInitMethods()) {
|
|
126
135
|
const staticInvokeExpr = new Expr_1.ArkStaticInvokeExpr(method.getSignature(), []);
|
|
127
136
|
const invokeStmt = new Stmt_1.ArkInvokeStmt(staticInvokeExpr);
|
|
128
|
-
if (isStartingStmt) {
|
|
129
|
-
dummyCfg.setStartingStmt(invokeStmt);
|
|
130
|
-
isStartingStmt = false;
|
|
131
|
-
}
|
|
132
137
|
firstBlock.addStmt(invokeStmt);
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
addClassInit(firstBlock) {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
if (!local) {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
let clsType = local.getType();
|
|
142
|
-
let cls = this.scene.getClass(clsType.getClassSignature());
|
|
143
|
-
const assStmt = new Stmt_1.ArkAssignStmt(local, new Expr_1.ArkNewExpr(clsType));
|
|
141
|
+
for (const [cls, local] of this.classLocalMap) {
|
|
142
|
+
const assStmt = new Stmt_1.ArkAssignStmt(local, new Expr_1.ArkNewExpr(cls.getSignature().getType()));
|
|
144
143
|
firstBlock.addStmt(assStmt);
|
|
145
144
|
local.setDeclaringStmt(assStmt);
|
|
146
145
|
let consMtd = cls.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
|
|
147
146
|
if (consMtd) {
|
|
148
147
|
let ivkExpr = new Expr_1.ArkInstanceInvokeExpr(local, consMtd.getSignature(), []);
|
|
149
|
-
let ivkStmt = new Stmt_1.
|
|
148
|
+
let ivkStmt = new Stmt_1.ArkAssignStmt(local, ivkExpr);
|
|
150
149
|
firstBlock.addStmt(ivkStmt);
|
|
151
150
|
}
|
|
152
151
|
}
|
|
@@ -184,64 +183,84 @@ class DummyMainCreater {
|
|
|
184
183
|
count++;
|
|
185
184
|
const condition = new Expr_1.ArkConditionExpr(countLocal, new Constant_1.Constant(count.toString(), Type_1.NumberType.getInstance()), Expr_1.RelationalBinaryOperator.Equality);
|
|
186
185
|
const ifStmt = new Stmt_1.ArkIfStmt(condition);
|
|
187
|
-
const ifBlock = new BasicBlock_1.BasicBlock();
|
|
186
|
+
const ifBlock = new BasicBlock_1.BasicBlock(this.tempBlockIndex++);
|
|
188
187
|
ifBlock.addStmt(ifStmt);
|
|
189
188
|
dummyCfg.addBlock(ifBlock);
|
|
190
189
|
for (const block of lastBlocks) {
|
|
191
|
-
|
|
192
|
-
block.addSuccessorBlock(ifBlock);
|
|
193
|
-
}
|
|
194
|
-
const invokeBlock = new BasicBlock_1.BasicBlock();
|
|
195
|
-
const paramLocals = [];
|
|
196
|
-
this.addParamInit(method, paramLocals, invokeBlock);
|
|
197
|
-
const local = this.classLocalMap.get(method);
|
|
198
|
-
let invokeExpr;
|
|
199
|
-
if (local) {
|
|
200
|
-
invokeExpr = new Expr_1.ArkInstanceInvokeExpr(local, method.getSignature(), paramLocals);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
invokeExpr = new Expr_1.ArkStaticInvokeExpr(method.getSignature(), paramLocals);
|
|
190
|
+
this.linkBlocks(block, ifBlock);
|
|
204
191
|
}
|
|
205
|
-
const
|
|
206
|
-
|
|
192
|
+
const invokeBlock = new BasicBlock_1.BasicBlock(this.tempBlockIndex++);
|
|
193
|
+
this.addMethodsInvokeStmt(invokeBlock, [method]);
|
|
207
194
|
dummyCfg.addBlock(invokeBlock);
|
|
208
|
-
|
|
209
|
-
invokeBlock.addPredecessorBlock(ifBlock);
|
|
195
|
+
this.linkBlocks(ifBlock, invokeBlock);
|
|
210
196
|
lastBlocks = [ifBlock, invokeBlock];
|
|
211
197
|
}
|
|
212
198
|
for (const block of lastBlocks) {
|
|
213
|
-
|
|
214
|
-
whileBlock.addPredecessorBlock(block);
|
|
199
|
+
this.linkBlocks(block, whileBlock);
|
|
215
200
|
}
|
|
216
201
|
}
|
|
217
202
|
createDummyMainCfg() {
|
|
218
|
-
const dummyCfg =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
203
|
+
const dummyCfg = this.dummyMain.getCfg();
|
|
204
|
+
// step1: create the first block which includes:
|
|
205
|
+
// 1. all static invoke of static init methods
|
|
206
|
+
// 2. all class new expr
|
|
207
|
+
// 3. all instance invoke of instance init methods
|
|
208
|
+
// 4. all start lifecycle methods in sequence
|
|
209
|
+
const firstBlock = new BasicBlock_1.BasicBlock(this.tempBlockIndex++);
|
|
210
|
+
const dummyClassType = new Type_1.ClassType(this.dummyMain.getDeclaringArkClass().getSignature());
|
|
211
|
+
const startingStmt = new Stmt_1.ArkAssignStmt(new Local_1.Local(TSConst_1.THIS_NAME, dummyClassType), new Ref_1.ArkThisRef(dummyClassType));
|
|
212
|
+
firstBlock.addStmt(startingStmt);
|
|
213
|
+
dummyCfg.setStartingStmt(startingStmt);
|
|
214
|
+
this.addStaticInit(firstBlock);
|
|
222
215
|
this.addClassInit(firstBlock);
|
|
216
|
+
this.addMethodsInvokeStmt(firstBlock, this.abilityCreateMethods);
|
|
217
|
+
this.addMethodsInvokeStmt(firstBlock, this.abilityStageCreateMethods);
|
|
218
|
+
this.addMethodsInvokeStmt(firstBlock, this.componentAppearMethods);
|
|
223
219
|
const countLocal = new Local_1.Local('count', Type_1.NumberType.getInstance());
|
|
220
|
+
this.dummyMain.getBody().addLocal(countLocal.getName(), countLocal);
|
|
224
221
|
const zero = ValueUtil_1.ValueUtil.getOrCreateNumberConst(0);
|
|
225
222
|
const countAssignStmt = new Stmt_1.ArkAssignStmt(countLocal, zero);
|
|
226
|
-
const truE = ValueUtil_1.ValueUtil.getBooleanConstant(true);
|
|
227
|
-
const conditionTrue = new Expr_1.ArkConditionExpr(truE, zero, Expr_1.RelationalBinaryOperator.Equality);
|
|
228
|
-
const whileStmt = new Stmt_1.ArkIfStmt(conditionTrue);
|
|
229
223
|
firstBlock.addStmt(countAssignStmt);
|
|
230
224
|
dummyCfg.addBlock(firstBlock);
|
|
231
|
-
|
|
232
|
-
const whileBlock = new BasicBlock_1.BasicBlock();
|
|
225
|
+
// step2: create the while condition block
|
|
226
|
+
const whileBlock = new BasicBlock_1.BasicBlock(this.tempBlockIndex++);
|
|
227
|
+
const conditionTrue = new Expr_1.ArkConditionExpr(ValueUtil_1.ValueUtil.getBooleanConstant(true), ValueUtil_1.ValueUtil.getBooleanConstant(false), Expr_1.RelationalBinaryOperator.InEquality);
|
|
228
|
+
const whileStmt = new Stmt_1.ArkIfStmt(conditionTrue);
|
|
233
229
|
whileBlock.addStmt(whileStmt);
|
|
234
230
|
dummyCfg.addBlock(whileBlock);
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
this.linkBlocks(firstBlock, whileBlock);
|
|
232
|
+
// step3: create the following cfgs
|
|
237
233
|
this.addBranches(whileBlock, countLocal, dummyCfg);
|
|
234
|
+
// step4: create the last return block
|
|
235
|
+
const returnBlock = new BasicBlock_1.BasicBlock(this.tempBlockIndex++);
|
|
236
|
+
this.addMethodsInvokeStmt(returnBlock, this.componentDisappearMethods);
|
|
237
|
+
this.addMethodsInvokeStmt(returnBlock, this.abilityStageDestroyMethods);
|
|
238
|
+
this.addMethodsInvokeStmt(returnBlock, this.componentDetachedMethods);
|
|
239
|
+
this.addMethodsInvokeStmt(returnBlock, this.abilityDestroyMethods);
|
|
238
240
|
const returnStmt = new Stmt_1.ArkReturnVoidStmt();
|
|
239
|
-
const returnBlock = new BasicBlock_1.BasicBlock();
|
|
240
241
|
returnBlock.addStmt(returnStmt);
|
|
241
242
|
dummyCfg.addBlock(returnBlock);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
this.linkBlocks(whileBlock, returnBlock);
|
|
244
|
+
}
|
|
245
|
+
addMethodsInvokeStmt(block, methods) {
|
|
246
|
+
for (const method of methods) {
|
|
247
|
+
const paramLocals = [];
|
|
248
|
+
this.addParamInit(method, paramLocals, block);
|
|
249
|
+
const local = this.classLocalMap.get(method.getDeclaringArkClass());
|
|
250
|
+
let invokeExpr;
|
|
251
|
+
if (local) {
|
|
252
|
+
invokeExpr = new Expr_1.ArkInstanceInvokeExpr(local, method.getSignature(), paramLocals);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
invokeExpr = new Expr_1.ArkStaticInvokeExpr(method.getSignature(), paramLocals);
|
|
256
|
+
}
|
|
257
|
+
const invokeStmt = new Stmt_1.ArkInvokeStmt(invokeExpr);
|
|
258
|
+
block.addStmt(invokeStmt);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
linkBlocks(firstBlock, nextBlock) {
|
|
262
|
+
firstBlock.addSuccessorBlock(nextBlock);
|
|
263
|
+
nextBlock.addPredecessorBlock(firstBlock);
|
|
245
264
|
}
|
|
246
265
|
addCfg2Stmt() {
|
|
247
266
|
const cfg = this.dummyMain.getCfg();
|
|
@@ -258,26 +277,37 @@ class DummyMainCreater {
|
|
|
258
277
|
return this.dummyMain;
|
|
259
278
|
}
|
|
260
279
|
getEntryMethodsFromComponents() {
|
|
261
|
-
const COMPONENT_BASE_CLASSES = ['CustomComponent', 'ViewPU'];
|
|
262
|
-
let methods = [];
|
|
263
280
|
this.scene
|
|
264
281
|
.getClasses()
|
|
265
282
|
.filter(cls => {
|
|
266
283
|
if (COMPONENT_BASE_CLASSES.includes(cls.getSuperClassName())) {
|
|
267
284
|
return true;
|
|
268
285
|
}
|
|
269
|
-
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
return false;
|
|
286
|
+
return cls.hasDecorator(EtsConst_1.COMPONENT);
|
|
273
287
|
})
|
|
274
288
|
.forEach(cls => {
|
|
275
|
-
|
|
289
|
+
this.entryClasses.push(cls);
|
|
290
|
+
for (const mtd of cls.getMethods()) {
|
|
291
|
+
const name = mtd.getName();
|
|
292
|
+
if (name === Const_1.COMPONENT_START_METHOD) {
|
|
293
|
+
this.componentAppearMethods.push(mtd);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (name === Const_1.COMPONENT_DISAPPEAR_METHOD) {
|
|
297
|
+
this.componentDisappearMethods.push(mtd);
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (name === Const_1.COMPONENT_DETACHED_METHOD) {
|
|
301
|
+
this.componentDetachedMethods.push(mtd);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (entryMethodUtils_1.COMPONENT_LIFECYCLE_METHOD_NAME.includes(name)) {
|
|
305
|
+
this.entryMethods.push(mtd);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
276
308
|
});
|
|
277
|
-
return methods;
|
|
278
309
|
}
|
|
279
310
|
classInheritsAbility(arkClass) {
|
|
280
|
-
const ABILITY_BASE_CLASSES = ['UIExtensionAbility', 'Ability', 'FormExtensionAbility', 'UIAbility', 'BackupExtensionAbility'];
|
|
281
311
|
if (ABILITY_BASE_CLASSES.includes(arkClass.getSuperClassName())) {
|
|
282
312
|
return true;
|
|
283
313
|
}
|
|
@@ -291,17 +321,36 @@ class DummyMainCreater {
|
|
|
291
321
|
return false;
|
|
292
322
|
}
|
|
293
323
|
getMethodsFromAllAbilities() {
|
|
294
|
-
let methods = [];
|
|
295
324
|
this.scene
|
|
296
325
|
.getClasses()
|
|
297
326
|
.filter(cls => this.classInheritsAbility(cls))
|
|
298
327
|
.forEach(cls => {
|
|
299
|
-
|
|
328
|
+
this.entryClasses.push(cls);
|
|
329
|
+
for (const mtd of cls.getMethods()) {
|
|
330
|
+
const name = mtd.getName();
|
|
331
|
+
if (name === Const_1.ABILITY_CREATE_METHOD) {
|
|
332
|
+
this.abilityCreateMethods.push(mtd);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (name === Const_1.ABILITY_STAGE_CREATE_METHOD) {
|
|
336
|
+
this.abilityStageCreateMethods.push(mtd);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (name === Const_1.ABILITY_STAGE_DESTROY_METHOD) {
|
|
340
|
+
this.abilityStageDestroyMethods.push(mtd);
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (name === Const_1.ABILITY_DESTROY_METHOD) {
|
|
344
|
+
this.abilityDestroyMethods.push(mtd);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (entryMethodUtils_1.LIFECYCLE_METHOD_NAME.includes(name)) {
|
|
348
|
+
this.entryMethods.push(mtd);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
300
351
|
});
|
|
301
|
-
return methods;
|
|
302
352
|
}
|
|
303
353
|
getCallbackMethods() {
|
|
304
|
-
const callbackMethods = [];
|
|
305
354
|
this.scene.getMethods().forEach(method => {
|
|
306
355
|
if (!method.getCfg()) {
|
|
307
356
|
return;
|
|
@@ -311,12 +360,101 @@ class DummyMainCreater {
|
|
|
311
360
|
.getStmts()
|
|
312
361
|
.forEach(stmt => {
|
|
313
362
|
const cbMethod = (0, entryMethodUtils_1.getCallbackMethodFromStmt)(stmt, this.scene);
|
|
314
|
-
if (cbMethod && !
|
|
315
|
-
|
|
363
|
+
if (cbMethod && !this.entryMethods.includes(cbMethod)) {
|
|
364
|
+
this.entryMethods.push(cbMethod);
|
|
316
365
|
}
|
|
317
366
|
});
|
|
318
367
|
});
|
|
319
|
-
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Analysis the coverage of files, methods, stmts when starting from the dummy main method according to the given call graph.
|
|
371
|
+
* @param callGraph - the call graph create within ArkAnalyzer
|
|
372
|
+
* @param generated - whether to include the generated methods
|
|
373
|
+
*/
|
|
374
|
+
analysisCoverage(callGraph, generated = true) {
|
|
375
|
+
const analysis = new CoverageAnalysis(this.scene, this.dummyMain, callGraph, generated);
|
|
376
|
+
return analysis.calculateCoverage();
|
|
320
377
|
}
|
|
321
378
|
}
|
|
322
379
|
exports.DummyMainCreater = DummyMainCreater;
|
|
380
|
+
class CoverageAnalysis {
|
|
381
|
+
constructor(scene, entry, callGraph, generated = true) {
|
|
382
|
+
this.visitedFiles = new Set();
|
|
383
|
+
this.visitedMethods = new Set();
|
|
384
|
+
this.visitedStmts = new Set();
|
|
385
|
+
this.scene = scene;
|
|
386
|
+
this.callGraph = callGraph;
|
|
387
|
+
this.entry = entry;
|
|
388
|
+
this.totalFiles = new Set(scene.getFiles());
|
|
389
|
+
this.totalMethods = new Set();
|
|
390
|
+
this.totalFiles.forEach(file => {
|
|
391
|
+
file.getClasses().forEach(cls => {
|
|
392
|
+
cls.getMethods(generated).forEach(method => {
|
|
393
|
+
this.totalMethods.add(method);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
// if entry method is dummy main, then it is also generated, but still need to include it
|
|
398
|
+
this.totalMethods.add(entry);
|
|
399
|
+
this.totalStmts = new Set();
|
|
400
|
+
this.totalMethods.forEach(method => {
|
|
401
|
+
var _a;
|
|
402
|
+
(_a = method.getCfg()) === null || _a === void 0 ? void 0 : _a.getStmts().forEach(stmt => {
|
|
403
|
+
this.totalStmts.add(stmt);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
addVisitedFile(file) {
|
|
408
|
+
this.visitedFiles.add(file);
|
|
409
|
+
}
|
|
410
|
+
addVisitedMethod(method) {
|
|
411
|
+
this.visitedMethods.add(method);
|
|
412
|
+
}
|
|
413
|
+
addVisitedStmt(stmt) {
|
|
414
|
+
this.visitedStmts.add(stmt);
|
|
415
|
+
}
|
|
416
|
+
calculateCoverage() {
|
|
417
|
+
this.goThroughMethod(this.entry);
|
|
418
|
+
return {
|
|
419
|
+
filesCoverage: this.visitedFiles.size / this.totalFiles.size,
|
|
420
|
+
methodsCoverage: this.visitedMethods.size / this.totalMethods.size,
|
|
421
|
+
stmtsCoverage: this.visitedStmts.size / this.totalStmts.size,
|
|
422
|
+
totalFiles: this.totalFiles.size,
|
|
423
|
+
totalMethods: this.totalMethods.size,
|
|
424
|
+
totalStmts: this.totalStmts.size,
|
|
425
|
+
visitedFiles: this.visitedFiles.size,
|
|
426
|
+
visitedMethods: this.visitedMethods.size,
|
|
427
|
+
visitedStmts: this.visitedStmts.size,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Scan all invoke stmts of the given method, and go through all callee methods of this given method recursively.
|
|
432
|
+
* @param method
|
|
433
|
+
* @private
|
|
434
|
+
*/
|
|
435
|
+
goThroughMethod(method) {
|
|
436
|
+
var _a;
|
|
437
|
+
const file = method.getDeclaringArkFile();
|
|
438
|
+
if (!this.totalFiles.has(file) || !this.totalMethods.has(method) || this.visitedMethods.has(method)) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
this.addVisitedMethod(method);
|
|
442
|
+
this.addVisitedFile(file);
|
|
443
|
+
const stmts = (_a = method.getCfg()) === null || _a === void 0 ? void 0 : _a.getStmts();
|
|
444
|
+
if (!stmts) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
stmts.forEach(stmt => {
|
|
448
|
+
this.addVisitedStmt(stmt);
|
|
449
|
+
});
|
|
450
|
+
const node = this.callGraph.getCallGraphNodeByMethod(method.getSignature());
|
|
451
|
+
for (const outEdge of node.getOutgoingEdges()) {
|
|
452
|
+
const calleeSig = outEdge.getDstNode().getMethod();
|
|
453
|
+
const callee = this.scene.getMethod(calleeSig);
|
|
454
|
+
if (!callee) {
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
this.goThroughMethod(callee);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
@@ -72,4 +72,5 @@ export declare const CALL_BACK: string;
|
|
|
72
72
|
export declare const ON_OFF: Set<string>;
|
|
73
73
|
export declare const OH_PACKAGE_JSON5 = "oh-package.json5";
|
|
74
74
|
export declare const BUILD_PROFILE_JSON5 = "build-profile.json5";
|
|
75
|
+
export declare const COMPONENT: string;
|
|
75
76
|
//# sourceMappingURL=EtsConst.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EtsConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/EtsConst.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAy4BhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAkB,CAAC;AACpD,eAAO,MAAM,uBAAuB,EAAE,MAAsB,CAAC;AAE7D,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAAkG,CAAC;AAEpJ,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAqD/C,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAqE,CAAC;AAClH,eAAO,MAAM,eAAe,EAAE,MAAgB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,EAAE,MAAkB,CAAC;AACnD,eAAO,MAAM,uBAAuB,EAAE,MAAuB,CAAC;AAC9D,eAAO,MAAM,kBAAkB,EAAE,MAAmB,CAAC;AAErD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,EAAE,MAAc,CAAC;AACpD,eAAO,MAAM,o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.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
6
6
|
* You may obtain a copy of the License at
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BUILD_PROFILE_JSON5 = exports.OH_PACKAGE_JSON5 = exports.ON_OFF = exports.CALL_BACK = exports.COMPONENT_ATTRIBUTE = exports.COMPONENT_INSTANCE = exports.COMPONENT_COMMON = exports.SPECIAL_CONTAINER_COMPONENT = exports.COMPONENT_BUILD_FUNCTION = exports.COMPONENT_BRANCH_FUNCTION = exports.COMPONENT_IF_BRANCH = exports.COMPONENT_IF = exports.COMPONENT_REPEAT = exports.COMPONENT_CUSTOMVIEW = exports.COMPONENT_POP_FUNCTION = exports.COMPONENT_CREATE_FUNCTION = exports.isEtsContainerComponent = exports.isEtsSystemComponent = exports.isEtsAtomicComponent = exports.COMPONENT_BEHAVIOR = exports.BUILDER_PARAM_DECORATOR = exports.BUILDER_DECORATOR = exports.ENTRY_DECORATOR = exports.COMPONENT_DECORATOR = exports.BUILDIN_ATOMIC_COMPONENT = exports.BUILDIN_SYSTEM_COMPONENT = exports.COMPONENT_LAZY_FOR_EACH = exports.COMPONENT_FOR_EACH = exports.ETS_COMPILER_OPTIONS = void 0;
|
|
17
|
+
exports.COMPONENT = exports.BUILD_PROFILE_JSON5 = exports.OH_PACKAGE_JSON5 = exports.ON_OFF = exports.CALL_BACK = exports.COMPONENT_ATTRIBUTE = exports.COMPONENT_INSTANCE = exports.COMPONENT_COMMON = exports.SPECIAL_CONTAINER_COMPONENT = exports.COMPONENT_BUILD_FUNCTION = exports.COMPONENT_BRANCH_FUNCTION = exports.COMPONENT_IF_BRANCH = exports.COMPONENT_IF = exports.COMPONENT_REPEAT = exports.COMPONENT_CUSTOMVIEW = exports.COMPONENT_POP_FUNCTION = exports.COMPONENT_CREATE_FUNCTION = exports.isEtsContainerComponent = exports.isEtsSystemComponent = exports.isEtsAtomicComponent = exports.COMPONENT_BEHAVIOR = exports.BUILDER_PARAM_DECORATOR = exports.BUILDER_DECORATOR = exports.ENTRY_DECORATOR = exports.COMPONENT_DECORATOR = exports.BUILDIN_ATOMIC_COMPONENT = exports.BUILDIN_SYSTEM_COMPONENT = exports.COMPONENT_LAZY_FOR_EACH = exports.COMPONENT_FOR_EACH = exports.ETS_COMPILER_OPTIONS = void 0;
|
|
18
18
|
exports.ETS_COMPILER_OPTIONS = {
|
|
19
19
|
ets: {
|
|
20
20
|
emitDecorators: [
|
|
@@ -1011,3 +1011,4 @@ exports.CALL_BACK = 'Callback';
|
|
|
1011
1011
|
exports.ON_OFF = new Set(['on', 'off']);
|
|
1012
1012
|
exports.OH_PACKAGE_JSON5 = 'oh-package.json5';
|
|
1013
1013
|
exports.BUILD_PROFILE_JSON5 = 'build-profile.json5';
|
|
1014
|
+
exports.COMPONENT = 'Component';
|
|
@@ -17,13 +17,6 @@ export declare class IRInference {
|
|
|
17
17
|
static inferStaticInvokeExpr(expr: ArkStaticInvokeExpr, arkMethod: ArkMethod): AbstractInvokeExpr;
|
|
18
18
|
static inferStaticInvokeExprByMethodName(methodName: string, arkMethod: ArkMethod, expr: AbstractInvokeExpr): AbstractInvokeExpr;
|
|
19
19
|
static inferInstanceInvokeExpr(expr: ArkInstanceInvokeExpr, arkMethod: ArkMethod): AbstractInvokeExpr;
|
|
20
|
-
/**
|
|
21
|
-
* process arkUI function with Annotation @Extend @Styles @AnimatableExtend
|
|
22
|
-
* @param expr
|
|
23
|
-
* @param arkMethod
|
|
24
|
-
* @param methodName
|
|
25
|
-
*/
|
|
26
|
-
static processExtendFunc(expr: AbstractInvokeExpr, arkMethod: ArkMethod, methodName: string): AbstractInvokeExpr | null;
|
|
27
20
|
static inferFieldRef(ref: ArkInstanceFieldRef, arkMethod: ArkMethod): AbstractRef;
|
|
28
21
|
private static inferBase;
|
|
29
22
|
static inferThisLocal(arkMethod: ArkMethod): Local | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IRInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRInference.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAIH,SAAS,EAET,SAAS,EAET,YAAY,EAQZ,IAAI,EAKP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EAErB,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAGH,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EACH,gBAAgB,EAChB,WAAW,EAEX,mBAAmB,EACnB,eAAe,EAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"IRInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRInference.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAIH,SAAS,EAET,SAAS,EAET,YAAY,EAQZ,IAAI,EAKP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EAErB,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAGH,cAAc,EACd,cAAc,EACd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AyB,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,GAAG,cAAc,GAAG,IAAI;WAuB3G,kBAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,WAAW,GAAG,IAAI;IAuCjH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiChC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAgChC,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAoB5C,OAAO,CAAC,MAAM,CAAC,UAAU;WAeX,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,IAAI;IAoC/H,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B,OAAO,CAAC,MAAM,CAAC,eAAe;WAiChB,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,YAAY;WAiC3E,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WA2CnE,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WAcnE,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,GAAG,WAAW;CAsB3F"}
|
|
@@ -195,7 +195,7 @@ class IRInference {
|
|
|
195
195
|
return expr;
|
|
196
196
|
}
|
|
197
197
|
static inferInstanceInvokeExpr(expr, arkMethod) {
|
|
198
|
-
var _a, _b
|
|
198
|
+
var _a, _b;
|
|
199
199
|
const arkClass = arkMethod.getDeclaringArkClass();
|
|
200
200
|
TypeInference_1.TypeInference.inferRealGenericTypes(expr.getRealGenericTypes(), arkClass);
|
|
201
201
|
this.inferBase(expr, arkMethod);
|
|
@@ -218,7 +218,7 @@ class IRInference {
|
|
|
218
218
|
return expr;
|
|
219
219
|
}
|
|
220
220
|
expr.getArgs().forEach(arg => TypeInference_1.TypeInference.inferValueType(arg, arkMethod));
|
|
221
|
-
let result =
|
|
221
|
+
let result = this.inferInvokeExpr(expr, baseType, methodName, scene);
|
|
222
222
|
if (result) {
|
|
223
223
|
this.inferArgs(result, arkMethod);
|
|
224
224
|
return result;
|
|
@@ -226,30 +226,6 @@ class IRInference {
|
|
|
226
226
|
logger.warn('invoke ArkInstanceInvokeExpr MethodSignature type fail: ', expr.toString());
|
|
227
227
|
return expr;
|
|
228
228
|
}
|
|
229
|
-
/**
|
|
230
|
-
* process arkUI function with Annotation @Extend @Styles @AnimatableExtend
|
|
231
|
-
* @param expr
|
|
232
|
-
* @param arkMethod
|
|
233
|
-
* @param methodName
|
|
234
|
-
*/
|
|
235
|
-
static processExtendFunc(expr, arkMethod, methodName) {
|
|
236
|
-
var _a, _b;
|
|
237
|
-
const type = TypeInference_1.TypeInference.inferBaseType(methodName, arkMethod.getDeclaringArkClass());
|
|
238
|
-
if (type instanceof Type_1.FunctionType) {
|
|
239
|
-
const methodSignature = type.getMethodSignature();
|
|
240
|
-
// because of last stmt is ArkReturnVoidStmt, the ArkInvokeStmt at -2 before ArkReturnVoidStmt.
|
|
241
|
-
const stmts = (_b = (_a = arkMethod.getDeclaringArkFile().getScene().getMethod(methodSignature)) === null || _a === void 0 ? void 0 : _a.getCfg()) === null || _b === void 0 ? void 0 : _b.getStmts();
|
|
242
|
-
if (stmts) {
|
|
243
|
-
const endStmt = stmts[stmts.length - 2];
|
|
244
|
-
if (endStmt instanceof Stmt_1.ArkInvokeStmt) {
|
|
245
|
-
methodSignature.getMethodSubSignature().setReturnType(endStmt.getInvokeExpr().getType());
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
expr.setMethodSignature(methodSignature);
|
|
249
|
-
return expr;
|
|
250
|
-
}
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
229
|
static inferFieldRef(ref, arkMethod) {
|
|
254
230
|
this.inferBase(ref, arkMethod);
|
|
255
231
|
const baseType = TypeInference_1.TypeInference.replaceAliasType(ref.getBase().getType());
|
|
@@ -707,7 +683,10 @@ class IRInference {
|
|
|
707
683
|
baseType = new Type_1.ClassType(arrayClass.getSignature());
|
|
708
684
|
}
|
|
709
685
|
}
|
|
710
|
-
let { staticFlag, signature } = IRInference.genFieldSignature(fieldName, baseType, ref, arkMethod);
|
|
686
|
+
let { staticFlag, signature, value } = IRInference.genFieldSignature(fieldName, baseType, ref, arkMethod);
|
|
687
|
+
if (value) {
|
|
688
|
+
return value;
|
|
689
|
+
}
|
|
711
690
|
if (!signature) {
|
|
712
691
|
return null;
|
|
713
692
|
}
|
|
@@ -728,6 +707,11 @@ class IRInference {
|
|
|
728
707
|
let signature = null;
|
|
729
708
|
if (baseType instanceof Type_1.ClassType) {
|
|
730
709
|
const property = (_a = propertyAndType === null || propertyAndType === void 0 ? void 0 : propertyAndType[0]) !== null && _a !== void 0 ? _a : IRInference.findPropertyFormChildrenClass(fieldName, arkClass, baseType);
|
|
710
|
+
if (property instanceof ArkMethod_1.ArkMethod && property.getName().startsWith(Const_1.GETTER_PREFIX) && ref instanceof Ref_1.ArkInstanceFieldRef) {
|
|
711
|
+
const expr = property.isStatic() ? new Expr_1.ArkStaticInvokeExpr(property.getSignature(), [])
|
|
712
|
+
: new Expr_1.ArkInstanceInvokeExpr(ref.getBase(), property.getSignature(), []);
|
|
713
|
+
return { staticFlag: staticFlag, signature: signature, value: expr };
|
|
714
|
+
}
|
|
731
715
|
staticFlag = baseType.getClassSignature().getClassName() === Const_1.DEFAULT_ARK_CLASS_NAME ||
|
|
732
716
|
((property instanceof ArkField_1.ArkField || property instanceof ArkMethod_1.ArkMethod) && property.isStatic());
|
|
733
717
|
if (property instanceof ArkField_1.ArkField && property.getCategory() !== ArkField_1.FieldCategory.ENUM_MEMBER &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/ModelUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"ModelUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/ModelUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAEH,cAAc,EAId,eAAe,EAEf,SAAS,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAc,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,OAAO,EAGH,SAAS,EAIT,IAAI,EAIP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAYpC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAKrD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAKtC,qBAAa,UAAU;IACnB,OAAc,2BAA2B,EAAE,GAAG,CAAC,SAAS,CAAC,CAAa;WAMxD,OAAO,IAAI,IAAI;WAIf,8BAA8B,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;WAS9F,sCAAsC,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,GAAG,QAAQ,GAAG,IAAI;W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