arkanalyzer 1.0.17 → 1.0.19
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/pointerAnalysis/Pag.d.ts +3 -2
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +5 -3
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +4 -4
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +5 -4
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +2 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +11 -9
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +8 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +27 -3
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +30 -6
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.js +86 -5
- package/lib/core/base/Decorator.d.ts +1 -0
- package/lib/core/base/Decorator.d.ts.map +1 -1
- package/lib/core/base/Decorator.js +4 -1
- package/lib/core/base/Stmt.d.ts +3 -0
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +34 -0
- package/lib/core/base/Type.d.ts +45 -3
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +84 -4
- package/lib/core/base/TypeExpr.d.ts +72 -0
- package/lib/core/base/TypeExpr.d.ts.map +1 -0
- package/lib/core/base/TypeExpr.js +155 -0
- package/lib/core/common/ArkIRTransformer.d.ts +1 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +46 -23
- 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 +66 -16
- package/lib/core/common/IRInference.d.ts +5 -1
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +71 -0
- package/lib/core/common/ModelUtils.d.ts +3 -1
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +23 -1
- package/lib/core/common/TypeInference.d.ts +6 -0
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +82 -14
- package/lib/core/{common → graph/builder}/CfgBuilder.d.ts +34 -46
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/CfgBuilder.js +1139 -0
- package/lib/core/graph/builder/ConditionBuilder.d.ts +16 -0
- package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/ConditionBuilder.js +252 -0
- package/lib/core/graph/builder/LoopBuilder.d.ts +21 -0
- package/lib/core/graph/builder/LoopBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/LoopBuilder.js +251 -0
- package/lib/core/graph/builder/SwitchBuilder.d.ts +12 -0
- package/lib/core/graph/builder/SwitchBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/SwitchBuilder.js +152 -0
- package/lib/core/graph/builder/TrapBuilder.d.ts +17 -0
- package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/TrapBuilder.js +272 -0
- package/lib/core/model/ArkMethod.d.ts +1 -1
- package/lib/core/model/ArkMethod.js +1 -1
- package/lib/core/model/ArkSignature.d.ts +9 -1
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +17 -1
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +2 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +1 -1
- package/lib/core/{common → model/builder}/BodyBuilder.d.ts +5 -5
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -0
- package/lib/core/{common → model/builder}/BodyBuilder.js +12 -12
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +79 -5
- package/lib/save/JsonPrinter.d.ts +1 -1
- package/lib/save/JsonPrinter.d.ts.map +1 -1
- package/lib/save/JsonPrinter.js +2 -2
- package/lib/save/PrinterBuilder.d.ts +22 -0
- package/lib/save/PrinterBuilder.d.ts.map +1 -1
- package/lib/save/PrinterBuilder.js +54 -1
- package/lib/save/arkir/ArkIRClassPrinter.d.ts +14 -0
- package/lib/save/arkir/ArkIRClassPrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRClassPrinter.js +92 -0
- package/lib/save/arkir/ArkIRFieldPrinter.d.ts +12 -0
- package/lib/save/arkir/ArkIRFieldPrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRFieldPrinter.js +64 -0
- package/lib/save/arkir/ArkIRFilePrinter.d.ts +13 -0
- package/lib/save/arkir/ArkIRFilePrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRFilePrinter.js +54 -0
- package/lib/save/arkir/ArkIRMethodPrinter.d.ts +17 -0
- package/lib/save/arkir/ArkIRMethodPrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRMethodPrinter.js +159 -0
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts +12 -0
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRNamespacePrinter.js +66 -0
- package/lib/save/base/BasePrinter.d.ts +24 -0
- package/lib/save/base/BasePrinter.d.ts.map +1 -0
- package/lib/save/base/BasePrinter.js +70 -0
- package/lib/save/base/ExportPrinter.d.ts +9 -0
- package/lib/save/base/ExportPrinter.d.ts.map +1 -0
- package/lib/save/base/ExportPrinter.js +67 -0
- package/lib/save/base/ImportPrinter.d.ts +10 -0
- package/lib/save/base/ImportPrinter.d.ts.map +1 -0
- package/lib/save/base/ImportPrinter.js +92 -0
- package/lib/save/{source/SourceUtils.d.ts → base/PrinterUtils.d.ts} +2 -2
- package/lib/save/{source/SourceUtils.d.ts.map → base/PrinterUtils.d.ts.map} +1 -1
- package/lib/save/{source/SourceUtils.js → base/PrinterUtils.js} +10 -10
- package/lib/save/source/SourceBase.d.ts +2 -11
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +3 -25
- package/lib/save/source/SourceBody.js +3 -3
- package/lib/save/source/SourceClass.d.ts +2 -1
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +18 -17
- package/lib/save/source/SourceFilePrinter.d.ts +1 -1
- package/lib/save/source/SourceFilePrinter.d.ts.map +1 -1
- package/lib/save/source/SourceFilePrinter.js +9 -10
- package/lib/save/source/SourceMethod.d.ts +1 -1
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +37 -22
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +6 -6
- package/lib/save/source/SourceStmt.d.ts +1 -1
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +29 -42
- package/lib/save/source/SourceTransformer.d.ts +5 -1
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +107 -33
- package/lib/utils/SparseBitVector.d.ts +11 -2
- package/lib/utils/SparseBitVector.d.ts.map +1 -1
- package/lib/utils/SparseBitVector.js +70 -3
- package/package.json +1 -1
- package/lib/core/common/BodyBuilder.d.ts.map +0 -1
- package/lib/core/common/CfgBuilder.d.ts.map +0 -1
- package/lib/core/common/CfgBuilder.js +0 -1886
- package/lib/save/source/SourceModule.d.ts +0 -16
- package/lib/save/source/SourceModule.d.ts.map +0 -1
- package/lib/save/source/SourceModule.js +0 -125
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
4
|
* Licensed under the Apache License, Version 2.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
|
|
@@ -59,6 +59,7 @@ const builderUtils_1 = require("../model/builder/builderUtils");
|
|
|
59
59
|
const ArkValueTransformer_1 = require("./ArkValueTransformer");
|
|
60
60
|
const ArkImport_1 = require("../model/ArkImport");
|
|
61
61
|
const TypeInference_1 = require("./TypeInference");
|
|
62
|
+
const TypeExpr_1 = require("../base/TypeExpr");
|
|
62
63
|
class DummyStmt extends Stmt_1.Stmt {
|
|
63
64
|
constructor(text) {
|
|
64
65
|
super();
|
|
@@ -254,17 +255,40 @@ class ArkIRTransformer {
|
|
|
254
255
|
return true;
|
|
255
256
|
}
|
|
256
257
|
typeAliasDeclarationToStmts(typeAliasDeclaration) {
|
|
257
|
-
var _a;
|
|
258
258
|
const aliasName = typeAliasDeclaration.name.text;
|
|
259
259
|
const rightOp = typeAliasDeclaration.type;
|
|
260
260
|
let rightType = this.arkValueTransformer.resolveTypeNode(rightOp);
|
|
261
|
-
|
|
261
|
+
if (rightType instanceof TypeExpr_1.AbstractTypeExpr) {
|
|
262
|
+
rightType = rightType.getType();
|
|
263
|
+
}
|
|
264
|
+
const aliasType = new Type_1.AliasType(aliasName, rightType, new ArkSignature_1.AliasTypeSignature(aliasName, this.declaringMethod.getSignature()));
|
|
262
265
|
if (typeAliasDeclaration.typeParameters) {
|
|
263
266
|
const genericTypes = (0, builderUtils_1.buildTypeParameters)(typeAliasDeclaration.typeParameters, this.sourceFile, this.declaringMethod);
|
|
264
267
|
aliasType.setGenericTypes(genericTypes);
|
|
265
268
|
aliasType.setOriginalType((0, builderUtils_1.buildGenericType)(rightType, aliasType));
|
|
266
269
|
rightType = aliasType.getOriginalType();
|
|
267
270
|
}
|
|
271
|
+
let expr = this.generateAliasTypeExpr(rightOp, aliasType);
|
|
272
|
+
if ((ts.isTypeQueryNode(rightOp) || ts.isTypeReferenceNode(rightOp)) && rightOp.typeArguments) {
|
|
273
|
+
let realGenericTypes = [];
|
|
274
|
+
rightOp.typeArguments.forEach(typeArgument => {
|
|
275
|
+
realGenericTypes.push(this.arkValueTransformer.resolveTypeNode(typeArgument));
|
|
276
|
+
});
|
|
277
|
+
expr.setRealGenericTypes(realGenericTypes);
|
|
278
|
+
}
|
|
279
|
+
const modifiers = typeAliasDeclaration.modifiers ? (0, builderUtils_1.buildModifiers)(typeAliasDeclaration) : 0;
|
|
280
|
+
aliasType.setModifiers(modifiers);
|
|
281
|
+
const aliasTypeDefineStmt = new Stmt_1.ArkAliasTypeDefineStmt(aliasType, expr);
|
|
282
|
+
const leftPosition = Position_1.FullPosition.buildFromNode(typeAliasDeclaration.name, this.sourceFile);
|
|
283
|
+
const rightPosition = Position_1.FullPosition.buildFromNode(rightOp, this.sourceFile);
|
|
284
|
+
const operandOriginalPositions = [leftPosition, rightPosition];
|
|
285
|
+
aliasTypeDefineStmt.setOperandOriginalPositions(operandOriginalPositions);
|
|
286
|
+
this.getAliasTypeMap().set(aliasName, [aliasType, aliasTypeDefineStmt]);
|
|
287
|
+
return [aliasTypeDefineStmt];
|
|
288
|
+
}
|
|
289
|
+
generateAliasTypeExpr(rightOp, aliasType) {
|
|
290
|
+
var _a;
|
|
291
|
+
let rightType = aliasType.getOriginalType();
|
|
268
292
|
let expr;
|
|
269
293
|
if (ts.isImportTypeNode(rightOp)) {
|
|
270
294
|
expr = this.resolveImportTypeNode(rightOp);
|
|
@@ -285,10 +309,18 @@ class ArkIRTransformer {
|
|
|
285
309
|
expr = new Expr_1.AliasTypeExpr(originalLocal, true);
|
|
286
310
|
}
|
|
287
311
|
}
|
|
288
|
-
else if (ts.isTypeReferenceNode(rightOp)
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
312
|
+
else if (ts.isTypeReferenceNode(rightOp)) {
|
|
313
|
+
// For type A = B<number> stmt and B is also an alias type with the same scope of A,
|
|
314
|
+
// rightType here is AliasType with real generic type number.
|
|
315
|
+
// The originalObject in expr should be the object without real generic type, so try to find it in this scope.
|
|
316
|
+
if (rightType instanceof Type_1.AliasType) {
|
|
317
|
+
const existAliasType = this.getAliasTypeMap().get(rightType.getName());
|
|
318
|
+
if (existAliasType) {
|
|
319
|
+
expr = new Expr_1.AliasTypeExpr(existAliasType[0], false);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
expr = new Expr_1.AliasTypeExpr(rightType, false);
|
|
323
|
+
}
|
|
292
324
|
}
|
|
293
325
|
else {
|
|
294
326
|
expr = new Expr_1.AliasTypeExpr(rightType, false);
|
|
@@ -305,22 +337,7 @@ class ArkIRTransformer {
|
|
|
305
337
|
}
|
|
306
338
|
}
|
|
307
339
|
}
|
|
308
|
-
|
|
309
|
-
let realGenericTypes = [];
|
|
310
|
-
rightOp.typeArguments.forEach(typeArgument => {
|
|
311
|
-
realGenericTypes.push(this.arkValueTransformer.resolveTypeNode(typeArgument));
|
|
312
|
-
});
|
|
313
|
-
expr.setRealGenericTypes(realGenericTypes);
|
|
314
|
-
}
|
|
315
|
-
const modifiers = typeAliasDeclaration.modifiers ? (0, builderUtils_1.buildModifiers)(typeAliasDeclaration) : 0;
|
|
316
|
-
aliasType.setModifiers(modifiers);
|
|
317
|
-
const aliasTypeDefineStmt = new Stmt_1.ArkAliasTypeDefineStmt(aliasType, expr);
|
|
318
|
-
const leftPosition = Position_1.FullPosition.buildFromNode(typeAliasDeclaration.name, this.sourceFile);
|
|
319
|
-
const rightPosition = Position_1.FullPosition.buildFromNode(rightOp, this.sourceFile);
|
|
320
|
-
const operandOriginalPositions = [leftPosition, rightPosition];
|
|
321
|
-
aliasTypeDefineStmt.setOperandOriginalPositions(operandOriginalPositions);
|
|
322
|
-
this.getAliasTypeMap().set(aliasName, [aliasType, aliasTypeDefineStmt]);
|
|
323
|
-
return [aliasTypeDefineStmt];
|
|
340
|
+
return expr;
|
|
324
341
|
}
|
|
325
342
|
resolveImportTypeNode(importTypeNode) {
|
|
326
343
|
const importType = 'typeAliasDefine';
|
|
@@ -383,6 +400,12 @@ class ArkIRTransformer {
|
|
|
383
400
|
conditionStmts.forEach(stmt => stmts.push(stmt));
|
|
384
401
|
stmts.push(new Stmt_1.ArkIfStmt(conditionValue));
|
|
385
402
|
}
|
|
403
|
+
else {
|
|
404
|
+
// The omitted condition always evaluates to true.
|
|
405
|
+
const trueConstant = ValueUtil_1.ValueUtil.getBooleanConstant(true);
|
|
406
|
+
const conditionExpr = new Expr_1.ArkConditionExpr(trueConstant, trueConstant, Expr_1.RelationalBinaryOperator.Equality);
|
|
407
|
+
stmts.push(new Stmt_1.ArkIfStmt(conditionExpr));
|
|
408
|
+
}
|
|
386
409
|
if (forStatement.incrementor) {
|
|
387
410
|
this.tsNodeToValueAndStmts(forStatement.incrementor).stmts.forEach(stmt => stmts.push(stmt));
|
|
388
411
|
}
|
|
@@ -79,6 +79,7 @@ export declare class ArkValueTransformer {
|
|
|
79
79
|
private isLiteralNode;
|
|
80
80
|
resolveTypeNode(type: ts.TypeNode): Type;
|
|
81
81
|
private resolveTypeQueryNode;
|
|
82
|
+
private resolveTypeOperatorNode;
|
|
82
83
|
static resolveLiteralTypeNode(literalTypeNode: ts.LiteralTypeNode, sourceFile: ts.SourceFile): Type;
|
|
83
84
|
private resolveTemplateLiteralTypeNode;
|
|
84
85
|
private resolveTypeReferenceNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkValueTransformer.d.ts","sourceRoot":"","sources":["../../../src/core/common/ArkValueTransformer.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,sBAAsB,EAAiD,MA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AG,aAAa;IAU1G,kCAAkC,CAAC,mBAAmB,EAAE,EAAE,CAAC,mBAAmB,EAC3C,OAAO,EAAE,OAAO,EAAE,WAAW,GAAE,OAAc,GAAG,aAAa;IAQvG,OAAO,CAAC,yBAAyB;IAgDjC,OAAO,CAAC,gCAAgC;IAsBxC,OAAO,CAAC,iCAAiC;IAwBzC,OAAO,CAAC,kCAAkC;IAsC1C,OAAO,CAAC,+BAA+B;IAqDvC,OAAO,CAAC,iCAAiC;IA4CzC,OAAO,CAAC,uCAAuC;IAsCxC,wBAAwB,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,GAAG,aAAa;IA4BxE,OAAO,CAAC,0BAA0B;IA6ClC,OAAO,CAAC,gBAAgB;IAUjB,iBAAiB,CAAC,SAAS,GAAE,IAAgC,GAAG,KAAK;IAQ5E,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,aAAa;IAed,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,GAAG,IAAI;IA6D/C,OAAO,CAAC,oBAAoB;IA8B5B,OAAO,CAAC,uBAAuB;WAqBjB,sBAAsB,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI;IAoB1G,OAAO,CAAC,8BAA8B;IA6CtC,OAAO,CAAC,wBAAwB;IA8BhC,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,uBAAuB;WAOjB,4BAA4B,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,GAAG,OAAO;CAoB/E"}
|
|
@@ -61,6 +61,8 @@ const Constant_1 = require("../base/Constant");
|
|
|
61
61
|
const Const_1 = require("./Const");
|
|
62
62
|
const ArkIRTransformer_1 = require("./ArkIRTransformer");
|
|
63
63
|
const logger_1 = __importStar(require("../../utils/logger"));
|
|
64
|
+
const TypeInference_1 = require("./TypeInference");
|
|
65
|
+
const TypeExpr_1 = require("../base/TypeExpr");
|
|
64
66
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkValueTransformer');
|
|
65
67
|
class ArkValueTransformer {
|
|
66
68
|
constructor(arkIRTransformer, sourceFile, declaringMethod) {
|
|
@@ -1266,6 +1268,11 @@ class ArkValueTransformer {
|
|
|
1266
1268
|
type.types.forEach(t => mayTypes.push(this.resolveTypeNode(t)));
|
|
1267
1269
|
return new Type_1.UnionType(mayTypes);
|
|
1268
1270
|
}
|
|
1271
|
+
case ts.SyntaxKind.IntersectionType: {
|
|
1272
|
+
const intersectionTypes = [];
|
|
1273
|
+
type.types.forEach(t => intersectionTypes.push(this.resolveTypeNode(t)));
|
|
1274
|
+
return new Type_1.IntersectionType(intersectionTypes);
|
|
1275
|
+
}
|
|
1269
1276
|
case ts.SyntaxKind.TupleType: {
|
|
1270
1277
|
const types = [];
|
|
1271
1278
|
type.elements.forEach(element => {
|
|
@@ -1287,23 +1294,60 @@ class ArkValueTransformer {
|
|
|
1287
1294
|
return Type_1.UnknownType.getInstance();
|
|
1288
1295
|
case ts.SyntaxKind.TypeQuery:
|
|
1289
1296
|
return this.resolveTypeQueryNode(type);
|
|
1297
|
+
case ts.SyntaxKind.ParenthesizedType:
|
|
1298
|
+
return this.resolveTypeNode(type.type);
|
|
1299
|
+
case ts.SyntaxKind.TypeOperator:
|
|
1300
|
+
return this.resolveTypeOperatorNode(type);
|
|
1290
1301
|
default:
|
|
1291
1302
|
return Type_1.UnknownType.getInstance();
|
|
1292
1303
|
}
|
|
1293
1304
|
}
|
|
1294
1305
|
resolveTypeQueryNode(typeQueryNode) {
|
|
1295
|
-
|
|
1296
|
-
const local = this.locals.get(exprName);
|
|
1297
|
-
if (local !== undefined) {
|
|
1298
|
-
return local.getType();
|
|
1299
|
-
}
|
|
1306
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1300
1307
|
const genericTypes = [];
|
|
1301
1308
|
if (typeQueryNode.typeArguments) {
|
|
1302
1309
|
for (const typeArgument of typeQueryNode.typeArguments) {
|
|
1303
1310
|
genericTypes.push(this.resolveTypeNode(typeArgument));
|
|
1304
1311
|
}
|
|
1305
1312
|
}
|
|
1306
|
-
|
|
1313
|
+
const exprNameNode = typeQueryNode.exprName;
|
|
1314
|
+
let opValue;
|
|
1315
|
+
if (ts.isQualifiedName(exprNameNode)) {
|
|
1316
|
+
if (exprNameNode.left.getText(this.sourceFile) === TSConst_1.THIS_NAME) {
|
|
1317
|
+
const fieldName = exprNameNode.right.getText(this.sourceFile);
|
|
1318
|
+
const fieldSignature = (_b = (_a = this.declaringMethod.getDeclaringArkClass().getFieldWithName(fieldName)) === null || _a === void 0 ? void 0 : _a.getSignature()) !== null && _b !== void 0 ? _b : ArkSignatureBuilder_1.ArkSignatureBuilder.buildFieldSignatureFromFieldName(fieldName);
|
|
1319
|
+
const baseLocal = (_c = this.locals.get(TSConst_1.THIS_NAME)) !== null && _c !== void 0 ? _c : new Local_1.Local(TSConst_1.THIS_NAME, new Type_1.ClassType(this.declaringMethod.getDeclaringArkClass().getSignature(), genericTypes));
|
|
1320
|
+
opValue = new Ref_1.ArkInstanceFieldRef(baseLocal, fieldSignature);
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
const exprName = exprNameNode.getText(this.sourceFile);
|
|
1324
|
+
opValue = new Local_1.Local(exprName, Type_1.UnknownType.getInstance());
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
const exprName = exprNameNode.escapedText.toString();
|
|
1329
|
+
opValue = (_f = (_d = this.locals.get(exprName)) !== null && _d !== void 0 ? _d : (_e = this.globals) === null || _e === void 0 ? void 0 : _e.get(exprName)) !== null && _f !== void 0 ? _f : new Local_1.Local(exprName, Type_1.UnknownType.getInstance());
|
|
1330
|
+
}
|
|
1331
|
+
return new TypeExpr_1.TypeQueryExpr(opValue, genericTypes);
|
|
1332
|
+
}
|
|
1333
|
+
resolveTypeOperatorNode(typeOperatorNode) {
|
|
1334
|
+
let type = this.resolveTypeNode(typeOperatorNode.type);
|
|
1335
|
+
switch (typeOperatorNode.operator) {
|
|
1336
|
+
case ts.SyntaxKind.ReadonlyKeyword: {
|
|
1337
|
+
if (type instanceof Type_1.ArrayType || type instanceof Type_1.TupleType) {
|
|
1338
|
+
type.setReadonlyFlag(true);
|
|
1339
|
+
}
|
|
1340
|
+
return type;
|
|
1341
|
+
}
|
|
1342
|
+
case ts.SyntaxKind.KeyOfKeyword: {
|
|
1343
|
+
return new TypeExpr_1.KeyofTypeExpr(type);
|
|
1344
|
+
}
|
|
1345
|
+
case ts.SyntaxKind.UniqueKeyword: {
|
|
1346
|
+
return Type_1.UnknownType.getInstance();
|
|
1347
|
+
}
|
|
1348
|
+
default:
|
|
1349
|
+
return Type_1.UnknownType.getInstance();
|
|
1350
|
+
}
|
|
1307
1351
|
}
|
|
1308
1352
|
static resolveLiteralTypeNode(literalTypeNode, sourceFile) {
|
|
1309
1353
|
const literal = literalTypeNode.literal;
|
|
@@ -1366,24 +1410,30 @@ class ArkValueTransformer {
|
|
|
1366
1410
|
return templateTypes[0];
|
|
1367
1411
|
}
|
|
1368
1412
|
resolveTypeReferenceNode(typeReferenceNode) {
|
|
1369
|
-
const typeReferenceFullName = typeReferenceNode.getText(this.sourceFile);
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1413
|
+
const typeReferenceFullName = typeReferenceNode.typeName.getText(this.sourceFile);
|
|
1414
|
+
const aliasTypeAndStmt = this.aliasTypeMap.get(typeReferenceFullName);
|
|
1415
|
+
const genericTypes = [];
|
|
1416
|
+
if (typeReferenceNode.typeArguments) {
|
|
1417
|
+
for (const typeArgument of typeReferenceNode.typeArguments) {
|
|
1418
|
+
genericTypes.push(this.resolveTypeNode(typeArgument));
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
if (!aliasTypeAndStmt) {
|
|
1372
1422
|
const typeName = typeReferenceNode.typeName.getText(this.sourceFile);
|
|
1373
1423
|
const local = this.locals.get(typeName);
|
|
1374
1424
|
if (local !== undefined) {
|
|
1375
1425
|
return local.getType();
|
|
1376
1426
|
}
|
|
1377
|
-
const genericTypes = [];
|
|
1378
|
-
if (typeReferenceNode.typeArguments) {
|
|
1379
|
-
for (const typeArgument of typeReferenceNode.typeArguments) {
|
|
1380
|
-
genericTypes.push(this.resolveTypeNode(typeArgument));
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
1427
|
return new Type_1.UnclearReferenceType(typeName, genericTypes);
|
|
1384
1428
|
}
|
|
1385
1429
|
else {
|
|
1386
|
-
|
|
1430
|
+
if (genericTypes.length > 0) {
|
|
1431
|
+
const oldAlias = aliasTypeAndStmt[0];
|
|
1432
|
+
let alias = new Type_1.AliasType(oldAlias.getName(), TypeInference_1.TypeInference.replaceTypeWithReal(oldAlias.getOriginalType(), genericTypes), oldAlias.getSignature(), oldAlias.getGenericTypes());
|
|
1433
|
+
alias.setRealGenericTypes(genericTypes);
|
|
1434
|
+
return alias;
|
|
1435
|
+
}
|
|
1436
|
+
return aliasTypeAndStmt[0];
|
|
1387
1437
|
}
|
|
1388
1438
|
}
|
|
1389
1439
|
resolveTypeLiteralNode(typeLiteralNode) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ArkMethod } from '../model/ArkMethod';
|
|
2
2
|
import { ClassType, Type } from '../base/Type';
|
|
3
|
+
import { Local } from '../base/Local';
|
|
3
4
|
import { AbstractExpr, AbstractInvokeExpr, AliasTypeExpr, ArkInstanceInvokeExpr, ArkStaticInvokeExpr } from '../base/Expr';
|
|
4
5
|
import { Scene } from '../../Scene';
|
|
5
6
|
import { ArkClass } from '../model/ArkClass';
|
|
6
7
|
import { ClassSignature, MethodSignature } from '../model/ArkSignature';
|
|
7
8
|
import { AbstractRef, ArkInstanceFieldRef } from '../base/Ref';
|
|
8
9
|
import { ArkFile } from '../model/ArkFile';
|
|
10
|
+
import { KeyofTypeExpr, TypeQueryExpr } from '../base/TypeExpr';
|
|
9
11
|
export declare class IRInference {
|
|
10
12
|
private static inferExportInfos;
|
|
11
13
|
private static inferImportInfos;
|
|
@@ -24,10 +26,12 @@ export declare class IRInference {
|
|
|
24
26
|
private static getRealTypes;
|
|
25
27
|
static replaceMethodSignature(init: MethodSignature, declared: MethodSignature): MethodSignature;
|
|
26
28
|
private static processForEach;
|
|
27
|
-
|
|
29
|
+
static inferLocal(base: Local, arkMethod: ArkMethod): void;
|
|
28
30
|
private static generateNewFieldSignature;
|
|
29
31
|
static inferAnonymousClass(anon: ArkClass | null, declaredSignature: ClassSignature, set?: Set<string>): void;
|
|
30
32
|
private static assignAnonField;
|
|
31
33
|
static inferAliasTypeExpr(expr: AliasTypeExpr, arkMethod: ArkMethod): AbstractExpr;
|
|
34
|
+
static inferTypeQueryExpr(expr: TypeQueryExpr, arkMethod: ArkMethod): void;
|
|
35
|
+
static inferKeyofTypeExpr(expr: KeyofTypeExpr, arkMethod: ArkMethod): void;
|
|
32
36
|
}
|
|
33
37
|
//# sourceMappingURL=IRInference.d.ts.map
|
|
@@ -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,EAKH,SAAS,EAIT,IAAI,EAIP,MAAM,cAAc,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,EAKH,SAAS,EAIT,IAAI,EAIP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO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cvG,OAAO,CAAC,MAAM,CAAC,cAAc;WAmBf,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAsBjE,OAAO,CAAC,MAAM,CAAC,yBAAyB;WA4C1B,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,IAAI;IA+B/H,OAAO,CAAC,MAAM,CAAC,eAAe;WA+BhB,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;CAapF"}
|
|
@@ -56,6 +56,8 @@ const Ref_1 = require("../base/Ref");
|
|
|
56
56
|
const Constant_1 = require("../base/Constant");
|
|
57
57
|
const Const_1 = require("./Const");
|
|
58
58
|
const ValueUtil_1 = require("./ValueUtil");
|
|
59
|
+
const TypeExpr_1 = require("../base/TypeExpr");
|
|
60
|
+
const ArkBaseModel_1 = require("../model/ArkBaseModel");
|
|
59
61
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'IRInference');
|
|
60
62
|
class IRInference {
|
|
61
63
|
static inferExportInfos(file) {
|
|
@@ -555,12 +557,22 @@ class IRInference {
|
|
|
555
557
|
if (originalObject instanceof Local_1.Local) {
|
|
556
558
|
model = ModelUtils_1.ModelUtils.findArkModelByRefName(originalObject.getName(), arkMethod.getDeclaringArkClass());
|
|
557
559
|
}
|
|
560
|
+
else if (originalObject instanceof TypeExpr_1.AbstractTypeExpr) {
|
|
561
|
+
originalObject.inferType(arkMethod);
|
|
562
|
+
model = originalObject;
|
|
563
|
+
}
|
|
558
564
|
else if (originalObject instanceof Type_1.Type) {
|
|
559
565
|
const type = TypeInference_1.TypeInference.inferUnclearedType(originalObject, arkMethod.getDeclaringArkClass());
|
|
566
|
+
// If original Object is ClassType, AliasType or UnclearReferenceType with real generic types,
|
|
567
|
+
// the type after infer should be revert back to the object itself.
|
|
560
568
|
if (type instanceof Type_1.ClassType) {
|
|
561
569
|
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
562
570
|
model = ModelUtils_1.ModelUtils.findArkModelBySignature(type.getClassSignature(), scene);
|
|
563
571
|
}
|
|
572
|
+
else if (type instanceof Type_1.AliasType) {
|
|
573
|
+
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
574
|
+
model = ModelUtils_1.ModelUtils.findArkModelBySignature(type.getSignature(), scene);
|
|
575
|
+
}
|
|
564
576
|
else if (type) {
|
|
565
577
|
model = type;
|
|
566
578
|
}
|
|
@@ -573,5 +585,64 @@ class IRInference {
|
|
|
573
585
|
}
|
|
574
586
|
return expr;
|
|
575
587
|
}
|
|
588
|
+
static inferTypeQueryExpr(expr, arkMethod) {
|
|
589
|
+
var _a;
|
|
590
|
+
let gTypes = expr.getGenerateTypes();
|
|
591
|
+
if (gTypes) {
|
|
592
|
+
for (let i = 0; i < gTypes.length; i++) {
|
|
593
|
+
const newType = TypeInference_1.TypeInference.inferUnclearedType(gTypes[i], arkMethod.getDeclaringArkClass());
|
|
594
|
+
if (newType) {
|
|
595
|
+
gTypes[i] = newType;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const opValue = expr.getOpValue();
|
|
600
|
+
let opValueType;
|
|
601
|
+
if (opValue instanceof ArkBaseModel_1.ArkBaseModel) {
|
|
602
|
+
opValueType = (_a = ModelUtils_1.ModelUtils.parseArkBaseModel2Type(opValue)) !== null && _a !== void 0 ? _a : Type_1.UnknownType.getInstance();
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
opValueType = opValue.getType();
|
|
606
|
+
}
|
|
607
|
+
if (!TypeInference_1.TypeInference.isUnclearType(opValueType)) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
if (opValue instanceof Local_1.Local) {
|
|
611
|
+
const newOpValueType = TypeInference_1.TypeInference.inferUnclearRefName(opValue.getName(), arkMethod.getDeclaringArkClass());
|
|
612
|
+
const scene = arkMethod.getDeclaringArkFile().getScene();
|
|
613
|
+
if (newOpValueType instanceof Type_1.ClassType) {
|
|
614
|
+
const newOpValue = ModelUtils_1.ModelUtils.findArkModelBySignature(newOpValueType.getClassSignature(), scene);
|
|
615
|
+
if (newOpValue instanceof ArkBaseModel_1.ArkBaseModel) {
|
|
616
|
+
expr.setOpValue(newOpValue);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
else if (newOpValueType instanceof Type_1.FunctionType) {
|
|
620
|
+
const newOpValue = ModelUtils_1.ModelUtils.findArkModelBySignature(newOpValueType.getMethodSignature(), scene);
|
|
621
|
+
if (newOpValue instanceof ArkBaseModel_1.ArkBaseModel) {
|
|
622
|
+
expr.setOpValue(newOpValue);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
this.inferLocal(opValue, arkMethod);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
else if (opValue instanceof Ref_1.AbstractRef || opValue instanceof Expr_1.AbstractExpr) {
|
|
630
|
+
expr.setOpValue(opValue.inferType(arkMethod));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
static inferKeyofTypeExpr(expr, arkMethod) {
|
|
634
|
+
const opType = expr.getOpType();
|
|
635
|
+
if (TypeInference_1.TypeInference.isUnclearType(opType)) {
|
|
636
|
+
if (opType instanceof TypeExpr_1.TypeQueryExpr) {
|
|
637
|
+
this.inferTypeQueryExpr(opType, arkMethod);
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
const type = TypeInference_1.TypeInference.inferUnclearedType(opType, arkMethod.getDeclaringArkClass());
|
|
641
|
+
if (type) {
|
|
642
|
+
expr.setOpType(type);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
576
647
|
}
|
|
577
648
|
exports.IRInference = IRInference;
|
|
@@ -6,8 +6,9 @@ import { ArkNamespace } from '../model/ArkNamespace';
|
|
|
6
6
|
import { ClassSignature, MethodSignature, Signature } from '../model/ArkSignature';
|
|
7
7
|
import { ArkExport, ExportInfo, FromInfo } from '../model/ArkExport';
|
|
8
8
|
import { ArkField } from '../model/ArkField';
|
|
9
|
-
import { ClassType } from '../base/Type';
|
|
9
|
+
import { ClassType, Type } from '../base/Type';
|
|
10
10
|
import { Scene } from '../../Scene';
|
|
11
|
+
import { ArkBaseModel } from '../model/ArkBaseModel';
|
|
11
12
|
export declare class ModelUtils {
|
|
12
13
|
static implicitArkUIBuilderMethods: Set<ArkMethod>;
|
|
13
14
|
static getMethodSignatureFromArkClass(arkClass: ArkClass, methodName: string): MethodSignature | null;
|
|
@@ -46,6 +47,7 @@ export declare class ModelUtils {
|
|
|
46
47
|
static findArkModel(baseName: string, arkClass: ArkClass): ArkExport | ArkField | null;
|
|
47
48
|
static findArkModelByRefName(refName: string, arkClass: ArkClass): ArkExport | ArkField | null;
|
|
48
49
|
static findArkModelBySignature(signature: Signature, scene: Scene): ArkExport | ArkField | null;
|
|
50
|
+
static parseArkBaseModel2Type(arkBaseModel: ArkBaseModel): Type | null;
|
|
49
51
|
}
|
|
50
52
|
export declare const sdkImportMap: Map<string, ArkFile>;
|
|
51
53
|
/**
|
|
@@ -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,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,C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E,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CA6BnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI,CA4BpE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CA4BlF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAiB7F;AAiED,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,GAAG,IAAI,CAK9F"}
|
|
@@ -425,7 +425,7 @@ class ModelUtils {
|
|
|
425
425
|
return model;
|
|
426
426
|
}
|
|
427
427
|
static findArkModelBySignature(signature, scene) {
|
|
428
|
-
var _a, _b, _c, _d;
|
|
428
|
+
var _a, _b, _c, _d, _e, _f;
|
|
429
429
|
if (signature instanceof ArkSignature_1.ClassSignature) {
|
|
430
430
|
return scene.getClass(signature);
|
|
431
431
|
}
|
|
@@ -449,6 +449,28 @@ class ModelUtils {
|
|
|
449
449
|
const declare = scene.getMethod(signature.getDeclaringMethodSignature());
|
|
450
450
|
return (_d = (_b = (_a = declare === null || declare === void 0 ? void 0 : declare.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().get(signature.getName())) !== null && _b !== void 0 ? _b : (_c = declare === null || declare === void 0 ? void 0 : declare.getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeByName(signature.getName())) !== null && _d !== void 0 ? _d : null;
|
|
451
451
|
}
|
|
452
|
+
else if (signature instanceof ArkSignature_1.AliasTypeSignature) {
|
|
453
|
+
const declare = scene.getMethod(signature.getDeclaringMethodSignature());
|
|
454
|
+
return (_f = (_e = declare === null || declare === void 0 ? void 0 : declare.getBody()) === null || _e === void 0 ? void 0 : _e.getAliasTypeByName(signature.getName())) !== null && _f !== void 0 ? _f : null;
|
|
455
|
+
}
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
static parseArkBaseModel2Type(arkBaseModel) {
|
|
459
|
+
if (arkBaseModel instanceof ArkClass_1.ArkClass) {
|
|
460
|
+
return new Type_1.ClassType(arkBaseModel.getSignature(), arkBaseModel.getGenericsTypes());
|
|
461
|
+
}
|
|
462
|
+
else if (arkBaseModel instanceof ArkNamespace_1.ArkNamespace) {
|
|
463
|
+
return Type_1.AnnotationNamespaceType.getInstance(arkBaseModel.getSignature());
|
|
464
|
+
}
|
|
465
|
+
else if (arkBaseModel instanceof ArkMethod_1.ArkMethod) {
|
|
466
|
+
return new Type_1.FunctionType(arkBaseModel.getSignature());
|
|
467
|
+
}
|
|
468
|
+
else if (arkBaseModel instanceof ArkField_1.ArkField) {
|
|
469
|
+
if (arkBaseModel.getType() instanceof Type_1.UnknownType || arkBaseModel.getType() instanceof Type_1.UnclearReferenceType) {
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
return arkBaseModel.getType();
|
|
473
|
+
}
|
|
452
474
|
return null;
|
|
453
475
|
}
|
|
454
476
|
}
|
|
@@ -31,6 +31,10 @@ export declare class TypeInference {
|
|
|
31
31
|
* such as ArkInstanceInvokeExpr ArkStaticInvokeExpr ArkNewExpr
|
|
32
32
|
*/
|
|
33
33
|
private static resolveExprsInStmt;
|
|
34
|
+
/**
|
|
35
|
+
* infer value type for TypeExprs in stmt which specify the type such as TypeQueryExpr
|
|
36
|
+
*/
|
|
37
|
+
private static resolveTypeExprsInStmt;
|
|
34
38
|
/**
|
|
35
39
|
* infer type for fieldRefs in stmt.
|
|
36
40
|
*/
|
|
@@ -45,9 +49,11 @@ export declare class TypeInference {
|
|
|
45
49
|
static resolveArkAssignStmt(stmt: Stmt, arkMethod: ArkMethod): void;
|
|
46
50
|
private static setValueType;
|
|
47
51
|
static isUnclearType(type: Type | null | undefined): boolean;
|
|
52
|
+
private static hasUnclearReferenceType;
|
|
48
53
|
static inferSimpleTypeInStmt(stmt: Stmt): void;
|
|
49
54
|
static buildTypeFromStr(typeStr: string): Type;
|
|
50
55
|
static inferValueType(value: Value, arkMethod: ArkMethod): Type | null;
|
|
56
|
+
private static inferParameterType;
|
|
51
57
|
static inferSignatureReturnType(oldSignature: MethodSignature, arkMethod: ArkMethod): void;
|
|
52
58
|
static inferGenericType(types: GenericType[] | undefined, arkClass: ArkClass): void;
|
|
53
59
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/TypeInference.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAyC,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAOH,YAAY,EACZ,WAAW,
|
|
1
|
+
{"version":3,"file":"TypeInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/TypeInference.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAyC,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAOH,YAAY,EACZ,WAAW,EAMX,IAAI,EACJ,oBAAoB,EAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAMtC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAOpE,qBAAa,aAAa;WAER,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAuC3D;;;;;;;;;OASG;WACW,kBAAkB,CAAC,UAAU,EA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