arkanalyzer 1.0.7 → 1.0.8
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/config/arkanalyzer.json +8 -0
- package/docs/IR2ts-stmt.md +81 -0
- package/docs/IR2ts.md +82 -0
- package/lib/Config.d.ts +9 -1
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +24 -11
- package/lib/Scene.d.ts +49 -42
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +124 -93
- package/lib/callgraph/algorithm/AbstractAnalysis.js +1 -1
- package/lib/callgraph/common/Statistics.js +1 -1
- package/lib/callgraph/model/CallGraph.d.ts +3 -2
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +16 -6
- package/lib/callgraph/model/builder/CallGraphBuilder.js +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +35 -8
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +93 -12
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +32 -5
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +378 -83
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +3 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +71 -18
- package/lib/core/base/Constant.d.ts +25 -5
- package/lib/core/base/Constant.d.ts.map +1 -1
- package/lib/core/base/Constant.js +46 -8
- package/lib/core/base/Expr.d.ts +45 -40
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +239 -153
- package/lib/core/base/Local.d.ts +2 -2
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +2 -2
- package/lib/core/base/Ref.d.ts +38 -37
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +102 -70
- package/lib/core/base/Stmt.d.ts +4 -0
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +12 -1
- package/lib/core/base/Type.d.ts +4 -0
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +41 -17
- package/lib/core/common/ArkError.d.ts +15 -0
- package/lib/core/common/ArkError.d.ts.map +1 -0
- package/lib/core/common/ArkError.js +28 -0
- package/lib/core/common/ArkIRTransformer.d.ts +7 -3
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +46 -20
- package/lib/core/common/Builtin.js +1 -1
- package/lib/core/common/CfgBuilder.d.ts +12 -0
- package/lib/core/common/CfgBuilder.d.ts.map +1 -1
- package/lib/core/common/CfgBuilder.js +289 -61
- package/lib/core/common/Const.d.ts +15 -10
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +18 -11
- package/lib/core/common/DummyMainCreater.d.ts +2 -1
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +28 -15
- 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 +2 -1
- package/lib/core/common/IRUtils.d.ts +7 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +34 -2
- package/lib/core/common/ModelUtils.d.ts +1 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +32 -32
- package/lib/core/common/TSConst.d.ts +10 -3
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TSConst.js +11 -4
- package/lib/core/common/TypeInference.d.ts +8 -2
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +218 -87
- package/lib/core/common/ValueUtil.d.ts +0 -4
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +8 -25
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +2 -4
- package/lib/core/dataflow/TiantAnalysis.js +2 -1
- package/lib/core/dataflow/Util.d.ts +1 -1
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +8 -7
- package/lib/core/graph/BasicBlock.d.ts +41 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +132 -1
- package/lib/core/graph/Cfg.d.ts +30 -1
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +129 -6
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +3 -2
- package/lib/core/model/ArkBaseModel.d.ts +8 -0
- package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
- package/lib/core/model/ArkBaseModel.js +56 -4
- package/lib/core/model/ArkClass.d.ts +36 -30
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +79 -40
- package/lib/core/model/ArkExport.d.ts +3 -0
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +11 -1
- package/lib/core/model/ArkField.d.ts +2 -0
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +4 -1
- package/lib/core/model/ArkFile.d.ts +4 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +20 -0
- package/lib/core/model/ArkImport.d.ts +2 -0
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +3 -0
- package/lib/core/model/ArkMetadata.d.ts +20 -0
- package/lib/core/model/ArkMetadata.d.ts.map +1 -0
- package/lib/core/model/ArkMetadata.js +44 -0
- package/lib/core/model/ArkMethod.d.ts +156 -53
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +309 -54
- package/lib/core/model/ArkNamespace.d.ts +4 -0
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +13 -0
- package/lib/core/model/ArkSignature.d.ts +11 -5
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +38 -18
- package/lib/core/model/builder/ArkClassBuilder.d.ts +0 -1
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +9 -34
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +6 -1
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +3 -0
- package/lib/core/model/builder/ArkFileBuilder.js +1 -1
- package/lib/core/model/builder/ArkImportBuilder.d.ts +2 -1
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkImportBuilder.js +12 -5
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +2 -1
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +87 -47
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +2 -0
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +25 -2
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +4 -0
- package/lib/save/source/SourceField.d.ts.map +1 -1
- package/lib/save/source/SourceField.js +4 -0
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +7 -0
- package/lib/save/source/SourceModule.d.ts.map +1 -1
- package/lib/save/source/SourceModule.js +14 -9
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +4 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +15 -3
- package/lib/save/source/SourceTransformer.d.ts +6 -0
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +72 -41
- package/lib/save/source/SourceUtils.d.ts.map +1 -1
- package/lib/save/source/SourceUtils.js +3 -2
- package/lib/transformer/StaticSingleAssignmentFormer.js +1 -1
- package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
- package/lib/utils/CfgStructualAnalysis.js +42 -8
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +7 -10
- package/lib/utils/crypto_utils.d.ts +6 -0
- package/lib/utils/crypto_utils.d.ts.map +1 -0
- package/lib/utils/crypto_utils.js +57 -0
- package/lib/utils/entryMethodUtils.js +23 -23
- package/lib/utils/getAllFiles.d.ts +1 -1
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/getAllFiles.js +4 -5
- package/lib/utils/logger.js +2 -2
- package/package.json +3 -2
package/lib/core/base/Expr.js
CHANGED
|
@@ -54,12 +54,14 @@ const Constant_1 = require("./Constant");
|
|
|
54
54
|
const TSConst_1 = require("../common/TSConst");
|
|
55
55
|
const Builtin_1 = require("../common/Builtin");
|
|
56
56
|
const EtsConst_1 = require("../common/EtsConst");
|
|
57
|
+
const Const_1 = require("../common/Const");
|
|
58
|
+
const ArkField_1 = require("../model/ArkField");
|
|
57
59
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'Expr');
|
|
58
60
|
/**
|
|
59
61
|
* @category core/base/expr
|
|
60
62
|
*/
|
|
61
63
|
class AbstractExpr {
|
|
62
|
-
inferType(
|
|
64
|
+
inferType(arkMethod) {
|
|
63
65
|
return this;
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -78,12 +80,12 @@ class AbstractInvokeExpr extends AbstractExpr {
|
|
|
78
80
|
* @example
|
|
79
81
|
* 1. 3AC information composed of getMethodSignature ().
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
```typescript
|
|
84
|
+
let strs: string[] = [];
|
|
85
|
+
strs.push('staticinvoke <');
|
|
86
|
+
strs.push(this.getMethodSignature().toString());
|
|
87
|
+
strs.push('>(');
|
|
88
|
+
```
|
|
87
89
|
*/
|
|
88
90
|
getMethodSignature() {
|
|
89
91
|
return this.methodSignature;
|
|
@@ -105,21 +107,21 @@ class AbstractInvokeExpr extends AbstractExpr {
|
|
|
105
107
|
* @example
|
|
106
108
|
* 1. get args number.
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
```typescript
|
|
111
|
+
const argsNum = expr.getArgs().length;
|
|
112
|
+
if (argsNum < 5) {
|
|
113
|
+
... ...
|
|
114
|
+
}
|
|
115
|
+
```
|
|
114
116
|
|
|
115
|
-
|
|
117
|
+
2. iterate arg based on expression
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
```typescript
|
|
120
|
+
for (const arg of this.getArgs()) {
|
|
121
|
+
strs.push(arg.toString());
|
|
122
|
+
strs.push(', ');
|
|
123
|
+
}
|
|
124
|
+
```
|
|
123
125
|
*/
|
|
124
126
|
getArgs() {
|
|
125
127
|
return this.args;
|
|
@@ -127,13 +129,64 @@ class AbstractInvokeExpr extends AbstractExpr {
|
|
|
127
129
|
setArgs(newArgs) {
|
|
128
130
|
this.args = newArgs;
|
|
129
131
|
}
|
|
132
|
+
inferArgs(arkMethod) {
|
|
133
|
+
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
134
|
+
const parameters = this.methodSignature.getMethodSubSignature().getParameters();
|
|
135
|
+
let realTypes = [];
|
|
136
|
+
for (let index = 0; index < this.args.length; index++) {
|
|
137
|
+
const arg = this.args[index];
|
|
138
|
+
TypeInference_1.TypeInference.inferValueType(arg, arkMethod);
|
|
139
|
+
if (index >= parameters.length) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
const argType = arg.getType();
|
|
143
|
+
const paramType = parameters[index].getType();
|
|
144
|
+
if (paramType instanceof Type_1.UnionType) {
|
|
145
|
+
paramType.getTypes().forEach(t => this.inferArg(argType, t, scene));
|
|
146
|
+
}
|
|
147
|
+
else if (paramType instanceof Type_1.GenericType) {
|
|
148
|
+
realTypes.push(argType);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.inferArg(argType, paramType, scene);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (realTypes.length > 0) {
|
|
155
|
+
this.realGenericTypes = realTypes;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
inferArg(argType, paramType, scene) {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
if (argType instanceof Type_1.FunctionType) {
|
|
161
|
+
let params;
|
|
162
|
+
let realTypes;
|
|
163
|
+
if (paramType instanceof Type_1.ClassType) {
|
|
164
|
+
params = (_b = (_a = scene.getClass(paramType.getClassSignature())) === null || _a === void 0 ? void 0 : _a.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) === null || _b === void 0 ? void 0 : _b.getParameters();
|
|
165
|
+
realTypes = paramType.getRealGenericTypes();
|
|
166
|
+
}
|
|
167
|
+
else if (paramType instanceof Type_1.FunctionType) {
|
|
168
|
+
params = paramType.getMethodSignature().getMethodSubSignature().getParameters();
|
|
169
|
+
realTypes = this.realGenericTypes;
|
|
170
|
+
}
|
|
171
|
+
if (params) {
|
|
172
|
+
argType.getMethodSignature().getMethodSubSignature().getParameters().forEach((p, i) => {
|
|
173
|
+
var _a;
|
|
174
|
+
let type = (_a = params === null || params === void 0 ? void 0 : params[i]) === null || _a === void 0 ? void 0 : _a.getType();
|
|
175
|
+
if (type instanceof Type_1.GenericType && realTypes) {
|
|
176
|
+
type = realTypes === null || realTypes === void 0 ? void 0 : realTypes[type.getIndex()];
|
|
177
|
+
}
|
|
178
|
+
if (type) {
|
|
179
|
+
p.setType(type);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
130
185
|
getType() {
|
|
186
|
+
var _a;
|
|
131
187
|
let type = this.methodSignature.getType();
|
|
132
|
-
if (!this.realGenericTypes) {
|
|
133
|
-
return type;
|
|
134
|
-
}
|
|
135
188
|
if (type instanceof Type_1.GenericType) {
|
|
136
|
-
const realType = this.realGenericTypes[type.getIndex()];
|
|
189
|
+
const realType = (_a = this.realGenericTypes) === null || _a === void 0 ? void 0 : _a[type.getIndex()];
|
|
137
190
|
if (realType) {
|
|
138
191
|
type = realType;
|
|
139
192
|
}
|
|
@@ -155,6 +208,77 @@ class AbstractInvokeExpr extends AbstractExpr {
|
|
|
155
208
|
getRealGenericTypes() {
|
|
156
209
|
return this.realGenericTypes;
|
|
157
210
|
}
|
|
211
|
+
inferMethod(baseType, methodName, scene) {
|
|
212
|
+
if (baseType instanceof Type_1.ClassType) {
|
|
213
|
+
return this.processClassMethod(baseType, methodName, scene);
|
|
214
|
+
}
|
|
215
|
+
else if (baseType instanceof Type_1.AnnotationNamespaceType) {
|
|
216
|
+
const namespace = scene.getNamespace(baseType.getNamespaceSignature());
|
|
217
|
+
if (namespace) {
|
|
218
|
+
const foundMethod = ModelUtils_1.ModelUtils.findPropertyInNamespace(methodName, namespace);
|
|
219
|
+
if (foundMethod instanceof ArkMethod_1.ArkMethod) {
|
|
220
|
+
TypeInference_1.TypeInference.inferMethodReturnType(foundMethod);
|
|
221
|
+
let signature = foundMethod.matchMethodSignature(this.args);
|
|
222
|
+
this.setMethodSignature(signature);
|
|
223
|
+
return new ArkStaticInvokeExpr(signature, this.getArgs(), this.getRealGenericTypes());
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else if (baseType instanceof Type_1.ArrayType && methodName === Builtin_1.Builtin.ITERATOR_FUNCTION) {
|
|
228
|
+
const returnType = this.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
229
|
+
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature()
|
|
230
|
+
.getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
231
|
+
returnType.setRealGenericTypes([baseType.getBaseType()]);
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
processClassMethod(baseType, methodName, scene) {
|
|
238
|
+
let arkClass = scene.getClass(baseType.getClassSignature());
|
|
239
|
+
if (!arkClass) {
|
|
240
|
+
const globalClass = scene.getSdkGlobal(baseType.getClassSignature().getClassName());
|
|
241
|
+
if (globalClass instanceof ArkClass_1.ArkClass) {
|
|
242
|
+
arkClass = globalClass;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const method = arkClass ? ModelUtils_1.ModelUtils.findPropertyInClass(methodName, arkClass) : null;
|
|
246
|
+
if (method instanceof ArkMethod_1.ArkMethod) {
|
|
247
|
+
TypeInference_1.TypeInference.inferMethodReturnType(method);
|
|
248
|
+
const methodSignature = method.matchMethodSignature(this.args);
|
|
249
|
+
this.setMethodSignature(methodSignature);
|
|
250
|
+
this.realGenericTypes = method.getDeclaringArkClass() === arkClass ? baseType.getRealGenericTypes() :
|
|
251
|
+
arkClass === null || arkClass === void 0 ? void 0 : arkClass.getRealTypes();
|
|
252
|
+
if (method.isStatic()) {
|
|
253
|
+
return new ArkStaticInvokeExpr(methodSignature, this.getArgs(), this.getRealGenericTypes());
|
|
254
|
+
}
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
else if (method instanceof ArkField_1.ArkField) {
|
|
258
|
+
const type = method.getType();
|
|
259
|
+
if (type instanceof Type_1.FunctionType ||
|
|
260
|
+
(type instanceof Type_1.ClassType && type.getClassSignature().getClassName() === EtsConst_1.CALL_BACK)) {
|
|
261
|
+
const subSignature = new ArkSignature_1.MethodSubSignature(methodName, [], Type_1.VoidType);
|
|
262
|
+
this.setMethodSignature(new ArkSignature_1.MethodSignature(baseType.getClassSignature(), subSignature));
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else if (methodName === TSConst_1.CONSTRUCTOR_NAME) { //sdk隐式构造
|
|
267
|
+
const subSignature = new ArkSignature_1.MethodSubSignature(methodName, [], new Type_1.ClassType(baseType.getClassSignature()));
|
|
268
|
+
const signature = new ArkSignature_1.MethodSignature(baseType.getClassSignature(), subSignature);
|
|
269
|
+
this.setMethodSignature(signature);
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
else if (methodName === Builtin_1.Builtin.ITERATOR_NEXT) { //sdk隐式构造
|
|
273
|
+
const returnType = this.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
274
|
+
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature()
|
|
275
|
+
.getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
276
|
+
returnType.setRealGenericTypes(baseType.getRealGenericTypes());
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
158
282
|
getUses() {
|
|
159
283
|
let uses = [];
|
|
160
284
|
uses.push(...this.args);
|
|
@@ -213,8 +337,8 @@ class ArkInstanceInvokeExpr extends AbstractInvokeExpr {
|
|
|
213
337
|
strs.push(')');
|
|
214
338
|
return strs.join('');
|
|
215
339
|
}
|
|
216
|
-
inferType(
|
|
217
|
-
|
|
340
|
+
inferType(arkMethod) {
|
|
341
|
+
const arkClass = arkMethod.getDeclaringArkClass();
|
|
218
342
|
let baseType = this.base.getType();
|
|
219
343
|
if (this.base instanceof Local_1.Local && baseType instanceof Type_1.UnknownType) {
|
|
220
344
|
baseType = TypeInference_1.TypeInference.inferBaseType(this.base.getName(), arkClass);
|
|
@@ -224,7 +348,7 @@ class ArkInstanceInvokeExpr extends AbstractInvokeExpr {
|
|
|
224
348
|
}
|
|
225
349
|
const methodName = this.getMethodSignature().getMethodSubSignature().getMethodName();
|
|
226
350
|
if (!baseType) {
|
|
227
|
-
if (!this.tryInferFormGlobal(methodName,
|
|
351
|
+
if (!this.tryInferFormGlobal(methodName, arkMethod)) {
|
|
228
352
|
logger.warn('infer ArkInstanceInvokeExpr base type fail: ' + this.toString());
|
|
229
353
|
}
|
|
230
354
|
return this;
|
|
@@ -252,10 +376,11 @@ class ArkInstanceInvokeExpr extends AbstractInvokeExpr {
|
|
|
252
376
|
else {
|
|
253
377
|
result = this.inferMethod(baseType, methodName, scene);
|
|
254
378
|
}
|
|
255
|
-
if (!result && this.tryInferFormGlobal(methodName,
|
|
379
|
+
if (!result && this.tryInferFormGlobal(methodName, arkMethod)) {
|
|
256
380
|
result = this;
|
|
257
381
|
}
|
|
258
382
|
if (result) {
|
|
383
|
+
this.inferArgs(arkMethod);
|
|
259
384
|
return result;
|
|
260
385
|
}
|
|
261
386
|
logger.warn('invoke ArkInstanceInvokeExpr MethodSignature type fail: ', this.toString());
|
|
@@ -280,65 +405,18 @@ class ArkInstanceInvokeExpr extends AbstractInvokeExpr {
|
|
|
280
405
|
logger.warn(`arg of forEach must be callable`);
|
|
281
406
|
}
|
|
282
407
|
}
|
|
283
|
-
tryInferFormGlobal(methodName,
|
|
408
|
+
tryInferFormGlobal(methodName, arkMethod) {
|
|
409
|
+
let arkClass = arkMethod.getDeclaringArkClass();
|
|
284
410
|
if (arkClass.hasComponentDecorator() || arkClass.getCategory() === ArkClass_1.ClassCategory.OBJECT) {
|
|
285
411
|
const global = arkClass.getDeclaringArkFile().getScene().getSdkGlobal(methodName);
|
|
286
412
|
if (global instanceof ArkMethod_1.ArkMethod) {
|
|
287
|
-
|
|
288
|
-
this.setMethodSignature(
|
|
413
|
+
const methodSignature = global.matchMethodSignature(this.getArgs());
|
|
414
|
+
this.setMethodSignature(methodSignature);
|
|
289
415
|
return true;
|
|
290
416
|
}
|
|
291
417
|
}
|
|
292
418
|
return false;
|
|
293
419
|
}
|
|
294
|
-
inferMethod(baseType, methodName, scene) {
|
|
295
|
-
if (baseType instanceof Type_1.ClassType) {
|
|
296
|
-
const arkClass = scene.getClass(baseType.getClassSignature());
|
|
297
|
-
const method = arkClass ? ModelUtils_1.ModelUtils.findPropertyInClass(methodName, arkClass) : null;
|
|
298
|
-
if (method instanceof ArkMethod_1.ArkMethod) {
|
|
299
|
-
TypeInference_1.TypeInference.inferMethodReturnType(method);
|
|
300
|
-
this.setMethodSignature(method.getSignature());
|
|
301
|
-
if (method.isStatic()) {
|
|
302
|
-
return new ArkStaticInvokeExpr(method.getSignature(), this.getArgs(), this.getRealGenericTypes());
|
|
303
|
-
}
|
|
304
|
-
return this;
|
|
305
|
-
}
|
|
306
|
-
else if (methodName === TSConst_1.CONSTRUCTOR_NAME) { //sdk隐式构造
|
|
307
|
-
const subSignature = new ArkSignature_1.MethodSubSignature(methodName, [], new Type_1.ClassType(baseType.getClassSignature()));
|
|
308
|
-
const signature = new ArkSignature_1.MethodSignature(baseType.getClassSignature(), subSignature);
|
|
309
|
-
this.setMethodSignature(signature);
|
|
310
|
-
return this;
|
|
311
|
-
}
|
|
312
|
-
else if (methodName === Builtin_1.Builtin.ITERATOR_NEXT) { //sdk隐式构造
|
|
313
|
-
const returnType = this.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
314
|
-
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature()
|
|
315
|
-
.getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
316
|
-
returnType.setRealGenericTypes(baseType.getRealGenericTypes());
|
|
317
|
-
return this;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else if (baseType instanceof Type_1.AnnotationNamespaceType) {
|
|
322
|
-
const namespace = scene.getNamespace(baseType.getNamespaceSignature());
|
|
323
|
-
if (namespace) {
|
|
324
|
-
const foundMethod = ModelUtils_1.ModelUtils.findPropertyInNamespace(methodName, namespace);
|
|
325
|
-
if (foundMethod instanceof ArkMethod_1.ArkMethod) {
|
|
326
|
-
TypeInference_1.TypeInference.inferMethodReturnType(foundMethod);
|
|
327
|
-
this.setMethodSignature(foundMethod.getSignature());
|
|
328
|
-
return new ArkStaticInvokeExpr(foundMethod.getSignature(), this.getArgs(), this.getRealGenericTypes());
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
else if (baseType instanceof Type_1.ArrayType && methodName === Builtin_1.Builtin.ITERATOR_FUNCTION) {
|
|
333
|
-
const returnType = this.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
334
|
-
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature()
|
|
335
|
-
.getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
336
|
-
returnType.setRealGenericTypes([baseType.getBaseType()]);
|
|
337
|
-
return this;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
420
|
}
|
|
343
421
|
exports.ArkInstanceInvokeExpr = ArkInstanceInvokeExpr;
|
|
344
422
|
class ArkStaticInvokeExpr extends AbstractInvokeExpr {
|
|
@@ -360,63 +438,60 @@ class ArkStaticInvokeExpr extends AbstractInvokeExpr {
|
|
|
360
438
|
strs.push(')');
|
|
361
439
|
return strs.join('');
|
|
362
440
|
}
|
|
363
|
-
inferType(
|
|
441
|
+
inferType(arkMethod) {
|
|
364
442
|
var _a, _b;
|
|
365
|
-
|
|
443
|
+
const arkClass = arkMethod.getDeclaringArkClass();
|
|
366
444
|
const oldMethodSignature = this.getMethodSignature();
|
|
367
445
|
const oldMethodSubSignature = oldMethodSignature.getMethodSubSignature();
|
|
368
446
|
const methodName = oldMethodSubSignature.getMethodName();
|
|
447
|
+
if (methodName === TSConst_1.IMPORT && this.getArgs()[0] instanceof Constant_1.Constant) {
|
|
448
|
+
this.processDynamicImport(arkClass, methodName, oldMethodSignature);
|
|
449
|
+
return this;
|
|
450
|
+
}
|
|
451
|
+
const className = this.getMethodSignature().getDeclaringClassSignature().getClassName();
|
|
452
|
+
if (className && className !== Const_1.UNKNOWN_CLASS_NAME) {
|
|
453
|
+
const baseType = TypeInference_1.TypeInference.inferUnclearReferenceType(className, arkClass);
|
|
454
|
+
if (baseType) {
|
|
455
|
+
this.inferMethod(baseType, methodName, arkClass.getDeclaringArkFile().getScene());
|
|
456
|
+
this.inferArgs(arkMethod);
|
|
457
|
+
}
|
|
458
|
+
return this;
|
|
459
|
+
}
|
|
369
460
|
let method;
|
|
370
|
-
const arkExport = (_a = ModelUtils_1.ModelUtils.getStaticMethodWithName(methodName, arkClass)) !== null && _a !== void 0 ? _a : ModelUtils_1.ModelUtils.getArkExportInImportInfoWithName(methodName, arkClass.getDeclaringArkFile());
|
|
461
|
+
const arkExport = (_b = (_a = ModelUtils_1.ModelUtils.getStaticMethodWithName(methodName, arkClass)) !== null && _a !== void 0 ? _a : ModelUtils_1.ModelUtils.getArkExportInImportInfoWithName(methodName, arkClass.getDeclaringArkFile())) !== null && _b !== void 0 ? _b : arkClass.getDeclaringArkFile().getScene().getSdkGlobal(methodName);
|
|
371
462
|
if (arkExport instanceof ArkMethod_1.ArkMethod) {
|
|
372
463
|
method = arkExport;
|
|
373
464
|
}
|
|
374
465
|
else if (arkExport instanceof ArkClass_1.ArkClass) {
|
|
375
466
|
method = arkExport.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
|
|
376
467
|
}
|
|
377
|
-
if (!method) {
|
|
378
|
-
if (methodName === TSConst_1.IMPORT && this.getArgs()[0] instanceof Constant_1.Constant) {
|
|
379
|
-
const importInfo = new ArkImport_1.ImportInfo();
|
|
380
|
-
importInfo.setNameBeforeAs(TSConst_1.ALL);
|
|
381
|
-
importInfo.setImportClauseName(TSConst_1.ALL);
|
|
382
|
-
importInfo.setImportFrom(this.getArgs()[0].getValue());
|
|
383
|
-
importInfo.setDeclaringArkFile(arkClass.getDeclaringArkFile());
|
|
384
|
-
const type = TypeInference_1.TypeInference.parseArkExport2Type((_b = importInfo.getLazyExportInfo()) === null || _b === void 0 ? void 0 : _b.getArkExport());
|
|
385
|
-
if (type) {
|
|
386
|
-
const subSignature = new ArkSignature_1.MethodSubSignature(methodName, oldMethodSubSignature.getParameters(), type);
|
|
387
|
-
const signature = new ArkSignature_1.MethodSignature(oldMethodSignature.getDeclaringClassSignature(), subSignature);
|
|
388
|
-
this.setMethodSignature(signature);
|
|
389
|
-
}
|
|
390
|
-
return this;
|
|
391
|
-
}
|
|
392
|
-
if (arkClass.hasComponentDecorator() || arkClass.getCategory() === ArkClass_1.ClassCategory.OBJECT) {
|
|
393
|
-
let className;
|
|
394
|
-
if (EtsConst_1.COMPONENT_CREATE_FUNCTION === methodName || EtsConst_1.COMPONENT_POP_FUNCTION === methodName) {
|
|
395
|
-
className = this.getMethodSignature().getDeclaringClassSignature().getClassName();
|
|
396
|
-
}
|
|
397
|
-
const globalName = className !== null && className !== void 0 ? className : methodName;
|
|
398
|
-
const global = arkClass.getDeclaringArkFile().getScene().getSdkGlobal(globalName);
|
|
399
|
-
if (global instanceof ArkMethod_1.ArkMethod) {
|
|
400
|
-
method = global;
|
|
401
|
-
}
|
|
402
|
-
else if (global instanceof ArkClass_1.ArkClass) {
|
|
403
|
-
const callable = ModelUtils_1.ModelUtils.findPropertyInClass(methodName, global);
|
|
404
|
-
if (callable instanceof ArkMethod_1.ArkMethod) {
|
|
405
|
-
method = callable;
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
const signature = new ArkSignature_1.MethodSignature(global.getSignature(), oldMethodSubSignature);
|
|
409
|
-
this.setMethodSignature(signature);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
468
|
if (method) {
|
|
415
|
-
this.setMethodSignature(method.getSignature());
|
|
416
469
|
TypeInference_1.TypeInference.inferMethodReturnType(method);
|
|
470
|
+
let signature = method.matchMethodSignature(this.getArgs());
|
|
471
|
+
if (method.isAnonymousMethod()) {
|
|
472
|
+
const subSignature = signature.getMethodSubSignature();
|
|
473
|
+
const newSubSignature = new ArkSignature_1.MethodSubSignature(methodName, subSignature.getParameters(), subSignature.getReturnType(), subSignature.isStatic());
|
|
474
|
+
signature = new ArkSignature_1.MethodSignature(signature.getDeclaringClassSignature(), newSubSignature);
|
|
475
|
+
}
|
|
476
|
+
this.setMethodSignature(signature);
|
|
477
|
+
this.inferArgs(arkMethod);
|
|
417
478
|
}
|
|
418
479
|
return this;
|
|
419
480
|
}
|
|
481
|
+
processDynamicImport(arkClass, methodName, oldMethodSignature) {
|
|
482
|
+
var _a;
|
|
483
|
+
const importInfo = new ArkImport_1.ImportInfo();
|
|
484
|
+
importInfo.setNameBeforeAs(TSConst_1.ALL);
|
|
485
|
+
importInfo.setImportClauseName(TSConst_1.ALL);
|
|
486
|
+
importInfo.setImportFrom(this.getArgs()[0].getValue());
|
|
487
|
+
importInfo.setDeclaringArkFile(arkClass.getDeclaringArkFile());
|
|
488
|
+
const type = TypeInference_1.TypeInference.parseArkExport2Type((_a = importInfo.getLazyExportInfo()) === null || _a === void 0 ? void 0 : _a.getArkExport());
|
|
489
|
+
if (type) {
|
|
490
|
+
const subSignature = new ArkSignature_1.MethodSubSignature(methodName, oldMethodSignature.getMethodSubSignature().getParameters(), type);
|
|
491
|
+
const signature = new ArkSignature_1.MethodSignature(oldMethodSignature.getDeclaringClassSignature(), subSignature);
|
|
492
|
+
this.setMethodSignature(signature);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
420
495
|
}
|
|
421
496
|
exports.ArkStaticInvokeExpr = ArkStaticInvokeExpr;
|
|
422
497
|
class ArkPtrInvokeExpr extends AbstractInvokeExpr {
|
|
@@ -445,7 +520,7 @@ class ArkPtrInvokeExpr extends AbstractInvokeExpr {
|
|
|
445
520
|
strs.push(')');
|
|
446
521
|
return strs.join('');
|
|
447
522
|
}
|
|
448
|
-
inferType(
|
|
523
|
+
inferType(arkMethod) {
|
|
449
524
|
// TODO: handle type inference
|
|
450
525
|
return this;
|
|
451
526
|
}
|
|
@@ -468,12 +543,15 @@ class ArkNewExpr extends AbstractExpr {
|
|
|
468
543
|
toString() {
|
|
469
544
|
return 'new ' + this.classType;
|
|
470
545
|
}
|
|
471
|
-
inferType(
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
546
|
+
inferType(arkMethod) {
|
|
547
|
+
const classSignature = this.classType.getClassSignature();
|
|
548
|
+
if (classSignature.getDeclaringFileSignature().getFileName() === Const_1.UNKNOWN_FILE_NAME) {
|
|
549
|
+
const className = classSignature.getClassName();
|
|
550
|
+
const type = TypeInference_1.TypeInference.inferUnclearReferenceType(className, arkMethod.getDeclaringArkClass());
|
|
551
|
+
if (type && type instanceof Type_1.ClassType) {
|
|
552
|
+
let realGenericTypes = this.classType.getRealGenericTypes();
|
|
553
|
+
this.classType = realGenericTypes ? new Type_1.ClassType(type.getClassSignature(), realGenericTypes) : type;
|
|
554
|
+
}
|
|
477
555
|
}
|
|
478
556
|
return this;
|
|
479
557
|
}
|
|
@@ -504,8 +582,8 @@ class ArkNewArrayExpr extends AbstractExpr {
|
|
|
504
582
|
isFromLiteral() {
|
|
505
583
|
return this.fromLiteral;
|
|
506
584
|
}
|
|
507
|
-
inferType(
|
|
508
|
-
const type = TypeInference_1.TypeInference.inferUnclearedType(this.baseType,
|
|
585
|
+
inferType(arkMethod) {
|
|
586
|
+
const type = TypeInference_1.TypeInference.inferUnclearedType(this.baseType, arkMethod.getDeclaringArkClass());
|
|
509
587
|
if (type) {
|
|
510
588
|
this.baseType = type;
|
|
511
589
|
}
|
|
@@ -558,10 +636,18 @@ class ArkAwaitExpr extends AbstractExpr {
|
|
|
558
636
|
this.promise = newPromise;
|
|
559
637
|
}
|
|
560
638
|
getType() {
|
|
561
|
-
|
|
639
|
+
var _a, _b;
|
|
640
|
+
const type = this.promise.getType();
|
|
641
|
+
if (type instanceof Type_1.UnclearReferenceType) {
|
|
642
|
+
return type.getGenericTypes()[0];
|
|
643
|
+
}
|
|
644
|
+
else if (type instanceof Type_1.ClassType) {
|
|
645
|
+
return (_b = (_a = type.getRealGenericTypes()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : type;
|
|
646
|
+
}
|
|
647
|
+
return type;
|
|
562
648
|
}
|
|
563
|
-
inferType(
|
|
564
|
-
TypeInference_1.TypeInference.inferValueType(this.promise,
|
|
649
|
+
inferType(arkMethod) {
|
|
650
|
+
TypeInference_1.TypeInference.inferValueType(this.promise, arkMethod);
|
|
565
651
|
return this;
|
|
566
652
|
}
|
|
567
653
|
getUses() {
|
|
@@ -624,7 +710,7 @@ var NormalBinaryOperator;
|
|
|
624
710
|
// Logical
|
|
625
711
|
NormalBinaryOperator["LogicalAnd"] = "&&";
|
|
626
712
|
NormalBinaryOperator["LogicalOr"] = "||";
|
|
627
|
-
})(NormalBinaryOperator
|
|
713
|
+
})(NormalBinaryOperator = exports.NormalBinaryOperator || (exports.NormalBinaryOperator = {}));
|
|
628
714
|
var RelationalBinaryOperator;
|
|
629
715
|
(function (RelationalBinaryOperator) {
|
|
630
716
|
RelationalBinaryOperator["LessThan"] = "<";
|
|
@@ -635,7 +721,7 @@ var RelationalBinaryOperator;
|
|
|
635
721
|
RelationalBinaryOperator["InEquality"] = "!=";
|
|
636
722
|
RelationalBinaryOperator["StrictEquality"] = "===";
|
|
637
723
|
RelationalBinaryOperator["StrictInequality"] = "!==";
|
|
638
|
-
})(RelationalBinaryOperator
|
|
724
|
+
})(RelationalBinaryOperator = exports.RelationalBinaryOperator || (exports.RelationalBinaryOperator = {}));
|
|
639
725
|
// 二元运算表达式
|
|
640
726
|
class AbstractBinopExpr extends AbstractExpr {
|
|
641
727
|
constructor(op1, op2, operator) {
|
|
@@ -672,14 +758,14 @@ class AbstractBinopExpr extends AbstractExpr {
|
|
|
672
758
|
* one is the normal binary operator and the other is relational binary operator.
|
|
673
759
|
* @returns The binary operator from the statement.
|
|
674
760
|
* @example
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
761
|
+
```typescript
|
|
762
|
+
if (expr instanceof AbstractBinopExpr) {
|
|
763
|
+
let op1: Value = expr.getOp1();
|
|
764
|
+
let op2: Value = expr.getOp2();
|
|
765
|
+
let operator: string = expr.getOperator();
|
|
766
|
+
... ...
|
|
767
|
+
}
|
|
768
|
+
```
|
|
683
769
|
*/
|
|
684
770
|
getOperator() {
|
|
685
771
|
return this.operator;
|
|
@@ -701,9 +787,9 @@ class AbstractBinopExpr extends AbstractExpr {
|
|
|
701
787
|
toString() {
|
|
702
788
|
return this.op1 + ' ' + this.operator + ' ' + this.op2;
|
|
703
789
|
}
|
|
704
|
-
inferOpType(op,
|
|
790
|
+
inferOpType(op, arkMethod) {
|
|
705
791
|
if (op instanceof AbstractExpr || op instanceof Ref_1.AbstractRef) {
|
|
706
|
-
TypeInference_1.TypeInference.inferValueType(op,
|
|
792
|
+
TypeInference_1.TypeInference.inferValueType(op, arkMethod);
|
|
707
793
|
}
|
|
708
794
|
}
|
|
709
795
|
setType() {
|
|
@@ -769,9 +855,9 @@ class AbstractBinopExpr extends AbstractExpr {
|
|
|
769
855
|
}
|
|
770
856
|
this.type = type;
|
|
771
857
|
}
|
|
772
|
-
inferType(
|
|
773
|
-
this.inferOpType(this.op1,
|
|
774
|
-
this.inferOpType(this.op2,
|
|
858
|
+
inferType(arkMethod) {
|
|
859
|
+
this.inferOpType(this.op1, arkMethod);
|
|
860
|
+
this.inferOpType(this.op2, arkMethod);
|
|
775
861
|
this.setType();
|
|
776
862
|
return this;
|
|
777
863
|
}
|
|
@@ -781,8 +867,8 @@ class ArkConditionExpr extends AbstractBinopExpr {
|
|
|
781
867
|
constructor(op1, op2, operator) {
|
|
782
868
|
super(op1, op2, operator);
|
|
783
869
|
}
|
|
784
|
-
inferType(
|
|
785
|
-
this.inferOpType(this.op1,
|
|
870
|
+
inferType(arkMethod) {
|
|
871
|
+
this.inferOpType(this.op1, arkMethod);
|
|
786
872
|
const op1Type = this.op1.getType();
|
|
787
873
|
if (this.operator === RelationalBinaryOperator.InEquality && this.op2 === ValueUtil_1.ValueUtil.getOrCreateNumberConst(0)) {
|
|
788
874
|
if (op1Type instanceof Type_1.StringType) {
|
|
@@ -796,7 +882,7 @@ class ArkConditionExpr extends AbstractBinopExpr {
|
|
|
796
882
|
}
|
|
797
883
|
}
|
|
798
884
|
else {
|
|
799
|
-
this.inferOpType(this.getOp2(),
|
|
885
|
+
this.inferOpType(this.getOp2(), arkMethod);
|
|
800
886
|
}
|
|
801
887
|
this.type = Type_1.BooleanType.getInstance();
|
|
802
888
|
return this;
|
|
@@ -885,9 +971,9 @@ class ArkCastExpr extends AbstractExpr {
|
|
|
885
971
|
getType() {
|
|
886
972
|
return this.type;
|
|
887
973
|
}
|
|
888
|
-
inferType(
|
|
974
|
+
inferType(arkMethod) {
|
|
889
975
|
var _a;
|
|
890
|
-
const type = (_a = TypeInference_1.TypeInference.inferUnclearedType(this.type,
|
|
976
|
+
const type = (_a = TypeInference_1.TypeInference.inferUnclearedType(this.type, arkMethod.getDeclaringArkClass())) !== null && _a !== void 0 ? _a : this.op.getType();
|
|
891
977
|
if (!TypeInference_1.TypeInference.isUnclearType(type)) {
|
|
892
978
|
this.type = type;
|
|
893
979
|
}
|
|
@@ -944,7 +1030,7 @@ var UnaryOperator;
|
|
|
944
1030
|
UnaryOperator["Neg"] = "-";
|
|
945
1031
|
UnaryOperator["BitwiseNot"] = "~";
|
|
946
1032
|
UnaryOperator["LogicalNot"] = "!";
|
|
947
|
-
})(UnaryOperator
|
|
1033
|
+
})(UnaryOperator = exports.UnaryOperator || (exports.UnaryOperator = {}));
|
|
948
1034
|
// unary operation expression
|
|
949
1035
|
class ArkUnopExpr extends AbstractExpr {
|
|
950
1036
|
constructor(op, operator) {
|
package/lib/core/base/Local.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Stmt } from './Stmt';
|
|
2
2
|
import { Type } from './Type';
|
|
3
3
|
import { Value } from './Value';
|
|
4
|
-
import { ArkClass } from '../model/ArkClass';
|
|
5
4
|
import { ArkExport, ExportType } from '../model/ArkExport';
|
|
6
5
|
import { LocalSignature } from '../model/ArkSignature';
|
|
7
6
|
import { ModifierType } from '../model/ArkBaseModel';
|
|
7
|
+
import { ArkMethod } from '../model/ArkMethod';
|
|
8
8
|
/**
|
|
9
9
|
* @category core/base
|
|
10
10
|
*/
|
|
@@ -17,7 +17,7 @@ export declare class Local implements Value, ArkExport {
|
|
|
17
17
|
private signature?;
|
|
18
18
|
private constFlag?;
|
|
19
19
|
constructor(name: string, type?: Type);
|
|
20
|
-
inferType(
|
|
20
|
+
inferType(arkMethod: ArkMethod): Local;
|
|
21
21
|
/**
|
|
22
22
|
* Returns the name of local value.
|
|
23
23
|
* @returns The name of local value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Local.d.ts","sourceRoot":"","sources":["../../../src/core/base/Local.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAe,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Local.d.ts","sourceRoot":"","sources":["../../../src/core/base/Local.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAe,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAkB,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAGxF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,qBAAa,KAAM,YAAW,KAAK,EAAE,SAAS;IAC1C,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAO;IAEnB,OAAO,CAAC,aAAa,CAAe;IAEpC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,SAAS,CAAC,CAAU;gBAEhB,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAgC;IASzD,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK;IAU7C;;;;;;;;;;;;;;;;;OAiBG;IACI,OAAO,IAAI,MAAM;IAIjB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC;;;OAGG;IACI,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI;IAI5B,gBAAgB,IAAI,KAAK,GAAG,IAAI;IAIhC,gBAAgB,CAAC,aAAa,EAAE,KAAK,GAAG,IAAI;IAInD;;;;;;;;;;;;;;;;;OAiBG;IACI,gBAAgB,IAAI,IAAI,GAAG,IAAI;IAI/B,gBAAgB,CAAC,aAAa,EAAE,IAAI;IAI3C;;;OAGG;IACI,OAAO,IAAI,KAAK,EAAE;IAIlB,WAAW,CAAC,QAAQ,EAAE,IAAI;IAIjC;;;;;;OAMG;IACI,YAAY,IAAI,IAAI,EAAE;IAI7B;;;;;;;;;;;;OAYG;IACI,QAAQ,IAAI,MAAM;IAIlB,aAAa,IAAI,UAAU;IAG3B,YAAY,IAAI,MAAM;IAItB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO;IAOrD,YAAY,IAAI,cAAc;IAK9B,YAAY,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAI7C,YAAY,IAAI,OAAO;IAOvB,YAAY,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI;CAGnD"}
|
package/lib/core/base/Local.js
CHANGED
|
@@ -33,9 +33,9 @@ class Local {
|
|
|
33
33
|
this.declaringStmt = null;
|
|
34
34
|
this.usedStmts = [];
|
|
35
35
|
}
|
|
36
|
-
inferType(
|
|
36
|
+
inferType(arkMethod) {
|
|
37
37
|
if (TypeInference_1.TypeInference.isUnclearType(this.type)) {
|
|
38
|
-
const type = TypeInference_1.TypeInference.inferUnclearReferenceType(this.name,
|
|
38
|
+
const type = TypeInference_1.TypeInference.inferUnclearReferenceType(this.name, arkMethod.getDeclaringArkClass());
|
|
39
39
|
if (type) {
|
|
40
40
|
this.type = type;
|
|
41
41
|
}
|