arkanalyzer 1.0.6 → 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 +29 -1
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +44 -11
- package/lib/Scene.d.ts +152 -9
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +233 -66
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +2 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +14 -7
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +2 -4
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +2 -3
- package/lib/callgraph/common/Statistics.js +1 -1
- package/lib/callgraph/model/BaseGraph.js +2 -2
- 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 +23 -14
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +2 -2
- package/lib/callgraph/model/builder/CallGraphBuilder.js +3 -3
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Context.js +0 -1
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +36 -9
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +130 -37
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +34 -5
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +479 -126
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +6 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +107 -45
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.js +0 -2
- package/lib/core/base/Constant.d.ts +37 -5
- package/lib/core/base/Constant.d.ts.map +1 -1
- package/lib/core/base/Constant.js +58 -8
- package/lib/core/base/Expr.d.ts +98 -13
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +295 -127
- package/lib/core/base/Local.d.ts +70 -5
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +77 -4
- package/lib/core/base/Ref.d.ts +79 -5
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +143 -38
- package/lib/core/base/Stmt.d.ts +126 -12
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +135 -28
- package/lib/core/base/Type.d.ts +11 -2
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +47 -42
- package/lib/core/base/Value.d.ts +24 -2
- package/lib/core/base/Value.d.ts.map +1 -1
- 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 +12 -5
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +90 -45
- package/lib/core/common/BodyBuilder.d.ts +2 -0
- package/lib/core/common/BodyBuilder.d.ts.map +1 -1
- package/lib/core/common/BodyBuilder.js +5 -2
- package/lib/core/common/Builtin.js +1 -1
- package/lib/core/common/CfgBuilder.d.ts +12 -7
- package/lib/core/common/CfgBuilder.d.ts.map +1 -1
- package/lib/core/common/CfgBuilder.js +336 -140
- 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 +5 -4
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +43 -28
- 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/ExprUseReplacer.js +8 -8
- 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 +39 -36
- package/lib/core/common/RefUseReplacer.js +3 -3
- package/lib/core/common/StmtUseReplacer.js +4 -4
- 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 +222 -90
- 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 +10 -27
- package/lib/core/common/VisibleValue.js +1 -1
- package/lib/core/dataflow/DataflowProblem.d.ts +1 -0
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowProblem.js +4 -4
- package/lib/core/dataflow/DataflowSolver.d.ts +20 -16
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +67 -78
- package/lib/core/dataflow/TiantAnalysis.d.ts +1 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -1
- package/lib/core/dataflow/TiantAnalysis.js +42 -28
- package/lib/core/dataflow/UndefinedVariable.d.ts +15 -1
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
- package/lib/core/dataflow/UndefinedVariable.js +122 -76
- package/lib/core/dataflow/Util.d.ts +5 -1
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +43 -22
- package/lib/core/graph/BasicBlock.d.ts +72 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +165 -3
- 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 +131 -11
- package/lib/core/graph/DominanceFinder.js +7 -7
- package/lib/core/graph/DominanceTree.js +4 -4
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +6 -5
- package/lib/core/model/ArkBaseModel.d.ts +59 -0
- package/lib/core/model/ArkBaseModel.d.ts.map +1 -0
- package/lib/core/model/ArkBaseModel.js +271 -0
- package/lib/core/model/ArkBody.d.ts +3 -9
- package/lib/core/model/ArkBody.d.ts.map +1 -1
- package/lib/core/model/ArkBody.js +3 -14
- package/lib/core/model/ArkClass.d.ts +107 -13
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +152 -54
- package/lib/core/model/ArkExport.d.ts +8 -7
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +16 -18
- package/lib/core/model/ArkField.d.ts +16 -13
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +18 -62
- package/lib/core/model/ArkFile.d.ts +42 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +58 -0
- package/lib/core/model/ArkImport.d.ts +9 -7
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +11 -12
- 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 +195 -17
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +363 -46
- package/lib/core/model/ArkNamespace.d.ts +6 -8
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +16 -20
- package/lib/core/model/ArkSignature.d.ts +41 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +76 -19
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +60 -49
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +12 -6
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +13 -9
- package/lib/core/model/builder/ArkFileBuilder.js +1 -3
- 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 +16 -13
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +3 -1
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +105 -45
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +4 -5
- package/lib/core/model/builder/builderUtils.d.ts +2 -1
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +63 -43
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/save/ArkStream.js +1 -1
- package/lib/save/DotPrinter.d.ts.map +1 -1
- package/lib/save/DotPrinter.js +1 -15
- package/lib/save/GraphPrinter.d.ts.map +1 -1
- package/lib/save/GraphPrinter.js +4 -2
- package/lib/save/JsonPrinter.js +5 -5
- package/lib/save/ViewTreePrinter.d.ts +16 -0
- package/lib/save/ViewTreePrinter.d.ts.map +1 -0
- package/lib/save/ViewTreePrinter.js +130 -0
- package/lib/save/source/SourceBase.d.ts +2 -2
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +6 -13
- package/lib/save/source/SourceBody.d.ts.map +1 -1
- package/lib/save/source/SourceBody.js +27 -14
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +12 -8
- package/lib/save/source/SourceField.d.ts.map +1 -1
- package/lib/save/source/SourceField.js +6 -2
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +10 -3
- package/lib/save/source/SourceModule.d.ts.map +1 -1
- package/lib/save/source/SourceModule.js +16 -10
- 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 +1 -1
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +37 -25
- 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 +82 -51
- package/lib/save/source/SourceUtils.d.ts.map +1 -1
- package/lib/save/source/SourceUtils.js +12 -11
- package/lib/transformer/StaticSingleAssignmentFormer.js +3 -3
- package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
- package/lib/utils/CfgStructualAnalysis.js +103 -72
- 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.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +27 -26
- 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
|
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.findArkExportInFile = exports.findExportInfo = exports.getArkFile = exports.ModelUtils = void 0;
|
|
43
|
+
exports.findArkExportInFile = exports.findArkExport = exports.findExportInfo = exports.getArkFile = exports.ModelUtils = void 0;
|
|
44
44
|
const Local_1 = require("../base/Local");
|
|
45
45
|
const ArkClass_1 = require("../model/ArkClass");
|
|
46
46
|
const ArkMethod_1 = require("../model/ArkMethod");
|
|
@@ -50,22 +50,23 @@ const ArkExport_1 = require("../model/ArkExport");
|
|
|
50
50
|
const logger_1 = __importStar(require("../../utils/logger"));
|
|
51
51
|
const FileUtils_1 = require("../../utils/FileUtils");
|
|
52
52
|
const path_1 = __importDefault(require("path"));
|
|
53
|
-
const pathTransfer_1 = require("../../utils/pathTransfer");
|
|
54
53
|
const TSConst_1 = require("./TSConst");
|
|
55
54
|
const ArkExportBuilder_1 = require("../model/builder/ArkExportBuilder");
|
|
56
55
|
const EtsConst_1 = require("./EtsConst");
|
|
57
56
|
const Type_1 = require("../base/Type");
|
|
57
|
+
const ArkMethodBuilder_1 = require("../model/builder/ArkMethodBuilder");
|
|
58
|
+
const Const_1 = require("./Const");
|
|
58
59
|
class ModelUtils {
|
|
59
60
|
static getMethodSignatureFromArkClass(arkClass, methodName) {
|
|
60
61
|
for (const arkMethod of arkClass.getMethods()) {
|
|
61
|
-
if (arkMethod.getName()
|
|
62
|
+
if (arkMethod.getName() === methodName) {
|
|
62
63
|
return arkMethod.getSignature();
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
68
|
static getClassWithNameInNamespaceRecursively(className, ns) {
|
|
68
|
-
if (className
|
|
69
|
+
if (className === '') {
|
|
69
70
|
return null;
|
|
70
71
|
}
|
|
71
72
|
let res = null;
|
|
@@ -111,7 +112,7 @@ class ModelUtils {
|
|
|
111
112
|
*/
|
|
112
113
|
static getClassWithName(className, thisClass) {
|
|
113
114
|
var _a;
|
|
114
|
-
if (thisClass.getName()
|
|
115
|
+
if (thisClass.getName() === className) {
|
|
115
116
|
return thisClass;
|
|
116
117
|
}
|
|
117
118
|
let classSearched = (_a = thisClass.getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getClassWithName(className);
|
|
@@ -143,7 +144,7 @@ class ModelUtils {
|
|
|
143
144
|
/** search method within the file that contain the given method */
|
|
144
145
|
static getMethodWithName(methodName, startFrom) {
|
|
145
146
|
if (!methodName.includes('.')) {
|
|
146
|
-
if (startFrom.getName()
|
|
147
|
+
if (startFrom.getName() === methodName) {
|
|
147
148
|
return startFrom;
|
|
148
149
|
}
|
|
149
150
|
const thisClass = startFrom.getDeclaringArkClass();
|
|
@@ -208,7 +209,7 @@ class ModelUtils {
|
|
|
208
209
|
static getStaticMethodWithName(methodName, thisClass) {
|
|
209
210
|
const thisNamespace = thisClass.getDeclaringArkNamespace();
|
|
210
211
|
if (thisNamespace) {
|
|
211
|
-
const defaultClass = thisNamespace.getClassWithName(
|
|
212
|
+
const defaultClass = thisNamespace.getClassWithName(Const_1.DEFAULT_ARK_CLASS_NAME);
|
|
212
213
|
if (defaultClass) {
|
|
213
214
|
const method = defaultClass.getMethodWithName(methodName);
|
|
214
215
|
if (method) {
|
|
@@ -219,7 +220,7 @@ class ModelUtils {
|
|
|
219
220
|
return this.getStaticMethodInFileWithName(methodName, thisClass.getDeclaringArkFile());
|
|
220
221
|
}
|
|
221
222
|
static getStaticMethodInFileWithName(methodName, arkFile) {
|
|
222
|
-
const defaultClass = arkFile.getClasses().find(cls => cls.getName()
|
|
223
|
+
const defaultClass = arkFile.getClasses().find(cls => cls.getName() === Const_1.DEFAULT_ARK_CLASS_NAME) || null;
|
|
223
224
|
if (defaultClass) {
|
|
224
225
|
let method = defaultClass.getMethodWithName(methodName);
|
|
225
226
|
if (method) {
|
|
@@ -274,9 +275,9 @@ class ModelUtils {
|
|
|
274
275
|
static isArkUIBuilderMethod(arkMethod) {
|
|
275
276
|
let isArkUIBuilderMethod = arkMethod.hasBuilderDecorator() || this.implicitArkUIBuilderMethods.has(arkMethod);
|
|
276
277
|
if (!isArkUIBuilderMethod &&
|
|
277
|
-
arkMethod.getName()
|
|
278
|
+
arkMethod.getName() === 'build' &&
|
|
278
279
|
arkMethod.getDeclaringArkClass().hasComponentDecorator() &&
|
|
279
|
-
!arkMethod.
|
|
280
|
+
!arkMethod.isStatic()) {
|
|
280
281
|
const fileName = arkMethod.getDeclaringArkClass().getDeclaringArkFile().getName();
|
|
281
282
|
if (fileName.endsWith('.ets')) {
|
|
282
283
|
isArkUIBuilderMethod = true;
|
|
@@ -327,14 +328,15 @@ class ModelUtils {
|
|
|
327
328
|
return (_j = (_e = (_d = (_c = (_b = (_a = namespace.getDefaultClass()) === null || _a === void 0 ? void 0 : _a.getMethodWithName(name)) !== null && _b !== void 0 ? _b : findArkExport(namespace.getExportInfoBy(name))) !== null && _c !== void 0 ? _c : namespace.getClassWithName(name)) !== null && _d !== void 0 ? _d : namespace.getNamespaceWithName(name)) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = namespace.getDefaultClass()) === null || _f === void 0 ? void 0 : _f.getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name)) !== null && _j !== void 0 ? _j : (_o = (_m = (_l = (_k = namespace.getDefaultClass()) === null || _k === void 0 ? void 0 : _k.getDefaultArkMethod()) === null || _l === void 0 ? void 0 : _l.getBody()) === null || _m === void 0 ? void 0 : _m.getLocals()) === null || _o === void 0 ? void 0 : _o.get(name);
|
|
328
329
|
}
|
|
329
330
|
static findPropertyInClass(name, arkClass) {
|
|
330
|
-
var _a, _b, _c
|
|
331
|
-
let
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
331
|
+
var _a, _b, _c;
|
|
332
|
+
let property;
|
|
333
|
+
let currentClass = arkClass;
|
|
334
|
+
do {
|
|
335
|
+
property = (_c = (_b = (_a = currentClass.getMethodWithName(name)) !== null && _a !== void 0 ? _a : currentClass.getStaticMethodWithName(name)) !== null && _b !== void 0 ? _b : currentClass.getFieldWithName(name)) !== null && _c !== void 0 ? _c : currentClass.getStaticFieldWithName(name);
|
|
336
|
+
currentClass = currentClass.getSuperClass();
|
|
337
|
+
} while (!property && currentClass);
|
|
338
|
+
if (property) {
|
|
339
|
+
return property;
|
|
338
340
|
}
|
|
339
341
|
if (arkClass.isDefaultArkClass()) {
|
|
340
342
|
return findArkExport(arkClass.getDeclaringArkFile().getExportInfoBy(name));
|
|
@@ -345,8 +347,10 @@ class ModelUtils {
|
|
|
345
347
|
var _a, _b;
|
|
346
348
|
if (file.getFilePath().includes(EtsConst_1.COMPONENT_PATH) || file.getFilePath().includes(EtsConst_1.API_INTERNAL)) {
|
|
347
349
|
this.getAllClassesInFile(file).forEach(cls => {
|
|
348
|
-
if (!cls.isAnonymousClass()) {
|
|
350
|
+
if (!cls.isAnonymousClass() && !cls.isDefaultArkClass()) {
|
|
349
351
|
globalMap.set(cls.getName(), cls);
|
|
352
|
+
}
|
|
353
|
+
if (cls.isDefaultArkClass()) {
|
|
350
354
|
cls.getMethods().forEach(mtd => {
|
|
351
355
|
if (!mtd.isDefaultArkMethod() && !mtd.isAnonymousMethod()) {
|
|
352
356
|
globalMap.set(mtd.getName(), mtd);
|
|
@@ -356,7 +360,7 @@ class ModelUtils {
|
|
|
356
360
|
});
|
|
357
361
|
(_b = (_a = file.getDefaultClass().getDefaultArkMethod()) === null || _a === void 0 ? void 0 : _a.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().forEach(local => {
|
|
358
362
|
const name = local.getName();
|
|
359
|
-
if (name !== TSConst_1.THIS_NAME && !name.startsWith(
|
|
363
|
+
if (name !== TSConst_1.THIS_NAME && !name.startsWith(Const_1.TEMP_LOCAL_PREFIX) && !name.endsWith(EtsConst_1.COMPONENT_INSTANCE)) {
|
|
360
364
|
const type = local.getType();
|
|
361
365
|
let arkExport;
|
|
362
366
|
if (type instanceof Type_1.UnclearReferenceType) {
|
|
@@ -371,14 +375,16 @@ class ModelUtils {
|
|
|
371
375
|
entry.setSignature(signature);
|
|
372
376
|
arkExport.getMethods().forEach(m => {
|
|
373
377
|
const ms = m.getSignature();
|
|
374
|
-
m.
|
|
378
|
+
m.setDeclareSignatures(new ArkSignature_1.MethodSignature(signature, ms.getMethodSubSignature()));
|
|
379
|
+
(0, ArkMethodBuilder_1.checkAndUpdateMethod)(m, entry);
|
|
375
380
|
entry.addMethod(m);
|
|
376
381
|
});
|
|
377
382
|
const attr = globalMap.get(name + EtsConst_1.COMPONENT_ATTRIBUTE);
|
|
378
383
|
if (attr instanceof ArkClass_1.ArkClass) {
|
|
379
384
|
attr.getMethods().forEach(m => {
|
|
380
385
|
const ms = m.getSignature();
|
|
381
|
-
m.
|
|
386
|
+
m.setDeclareSignatures(new ArkSignature_1.MethodSignature(signature, ms.getMethodSubSignature()));
|
|
387
|
+
(0, ArkMethodBuilder_1.checkAndUpdateMethod)(m, entry);
|
|
382
388
|
entry.addMethod(m);
|
|
383
389
|
});
|
|
384
390
|
}
|
|
@@ -392,8 +398,8 @@ class ModelUtils {
|
|
|
392
398
|
exports.ModelUtils = ModelUtils;
|
|
393
399
|
ModelUtils.implicitArkUIBuilderMethods = new Set();
|
|
394
400
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelUtils');
|
|
395
|
-
let moduleMap
|
|
396
|
-
const fileSuffixArray = ['.ets
|
|
401
|
+
let moduleMap;
|
|
402
|
+
const fileSuffixArray = ['.ets', '.ts', '.d.ets', '.d.ts'];
|
|
397
403
|
/**
|
|
398
404
|
* find arkFile by from info
|
|
399
405
|
* export xx from '../xx'
|
|
@@ -421,7 +427,7 @@ function getArkFile(im) {
|
|
|
421
427
|
//sdk path
|
|
422
428
|
const scene = im.getDeclaringArkFile().getScene();
|
|
423
429
|
for (const sdk of scene.getProjectSdkMap().values()) {
|
|
424
|
-
const arkFile = getArkFileFormMap(processSdkPath(sdk, from), scene
|
|
430
|
+
const arkFile = getArkFileFormMap(sdk.name, processSdkPath(sdk, from), scene);
|
|
425
431
|
if (arkFile) {
|
|
426
432
|
return arkFile;
|
|
427
433
|
}
|
|
@@ -487,6 +493,7 @@ function findArkExport(exportInfo) {
|
|
|
487
493
|
}
|
|
488
494
|
return arkExport || null;
|
|
489
495
|
}
|
|
496
|
+
exports.findArkExport = findArkExport;
|
|
490
497
|
function findArkExportInFile(name, declaringArkFile) {
|
|
491
498
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
492
499
|
let arkExport = (_f = (_c = (_b = (_a = declaringArkFile.getClassWithName(name)) !== null && _a !== void 0 ? _a : declaringArkFile.getDefaultClass().getMethodWithName(name)) !== null && _b !== void 0 ? _b : declaringArkFile.getNamespaceWithName(name)) !== null && _c !== void 0 ? _c : (_e = (_d = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _d === void 0 ? void 0 : _d.getBody()) === null || _e === void 0 ? void 0 : _e.getLocals().get(name)) !== null && _f !== void 0 ? _f : (_h = (_g = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name);
|
|
@@ -503,7 +510,6 @@ function findArkExportInFile(name, declaringArkFile) {
|
|
|
503
510
|
}
|
|
504
511
|
exports.findArkExportInFile = findArkExportInFile;
|
|
505
512
|
function processSdkPath(sdk, formPath) {
|
|
506
|
-
const sdkName = sdk.name;
|
|
507
513
|
let dir;
|
|
508
514
|
if (formPath.startsWith('@ohos.') || formPath.startsWith('@hms.') || formPath.startsWith('@system.')) {
|
|
509
515
|
dir = 'api';
|
|
@@ -519,9 +525,9 @@ function processSdkPath(sdk, formPath) {
|
|
|
519
525
|
if (FileUtils_1.FileUtils.isDirectory(originPath)) {
|
|
520
526
|
formPath = path_1.default.join(formPath, FileUtils_1.FileUtils.getIndexFileName(originPath));
|
|
521
527
|
}
|
|
522
|
-
return
|
|
528
|
+
return `${formPath}`;
|
|
523
529
|
}
|
|
524
|
-
return
|
|
530
|
+
return `${dir}/${formPath}`;
|
|
525
531
|
}
|
|
526
532
|
function getArkFileFromScene(im, originPath) {
|
|
527
533
|
if (FileUtils_1.FileUtils.isDirectory(originPath)) {
|
|
@@ -534,22 +540,19 @@ function getArkFileFromScene(im, originPath) {
|
|
|
534
540
|
return scene.getFile(fromSignature);
|
|
535
541
|
}
|
|
536
542
|
const projectName = im.getDeclaringArkFile().getProjectName();
|
|
537
|
-
|
|
538
|
-
if (projectName !== scene.getProjectName()) {
|
|
539
|
-
return getArkFileFormMap(filePath, scene.getSdkArkFilesMap());
|
|
540
|
-
}
|
|
541
|
-
return getArkFileFormMap(filePath, scene.getFilesMap());
|
|
543
|
+
return getArkFileFormMap(projectName, fileName, scene);
|
|
542
544
|
}
|
|
543
|
-
function getArkFileFormMap(filePath,
|
|
545
|
+
function getArkFileFormMap(projectName, filePath, scene) {
|
|
544
546
|
if (/\.e?ts$/.test(filePath)) {
|
|
545
|
-
return
|
|
547
|
+
return scene.getFile(new ArkSignature_1.FileSignature(projectName, filePath));
|
|
546
548
|
}
|
|
547
549
|
for (const suffix of fileSuffixArray) {
|
|
548
|
-
const arkFile =
|
|
550
|
+
const arkFile = scene.getFile(new ArkSignature_1.FileSignature(projectName, filePath + suffix));
|
|
549
551
|
if (arkFile) {
|
|
550
552
|
return arkFile;
|
|
551
553
|
}
|
|
552
554
|
}
|
|
555
|
+
return null;
|
|
553
556
|
}
|
|
554
557
|
function findExportInfoInfile(fromInfo, file) {
|
|
555
558
|
const exportName = fromInfo.isDefault() ? TSConst_1.DEFAULT : fromInfo.getOriginName();
|
|
@@ -34,15 +34,15 @@ class RefUseReplacer {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
caseFieldRef(ref) {
|
|
37
|
-
if (ref.getBase()
|
|
37
|
+
if (ref.getBase() === this.oldUse) {
|
|
38
38
|
ref.setBase(this.newUse);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
caseArrayRef(ref) {
|
|
42
|
-
if (ref.getBase()
|
|
42
|
+
if (ref.getBase() === this.oldUse) {
|
|
43
43
|
ref.setBase(this.newUse);
|
|
44
44
|
}
|
|
45
|
-
else if (ref.getIndex()
|
|
45
|
+
else if (ref.getIndex() === this.oldUse) {
|
|
46
46
|
ref.setIndex(this.newUse);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -46,16 +46,16 @@ class StmtUseReplacer {
|
|
|
46
46
|
}
|
|
47
47
|
caseAssignStmt(stmt) {
|
|
48
48
|
let rValue = stmt.getRightOp();
|
|
49
|
-
if (rValue
|
|
49
|
+
if (rValue === this.oldUse) {
|
|
50
50
|
stmt.setRightOp(this.newUse);
|
|
51
51
|
}
|
|
52
52
|
else if (rValue instanceof Local_1.Local) {
|
|
53
|
-
if (rValue
|
|
53
|
+
if (rValue === this.oldUse) {
|
|
54
54
|
stmt.setRightOp(this.newUse);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
else if (rValue instanceof Ref_1.AbstractRef) {
|
|
58
|
-
if (rValue
|
|
58
|
+
if (rValue === this.oldUse) {
|
|
59
59
|
stmt.setRightOp(this.newUse);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
@@ -64,7 +64,7 @@ class StmtUseReplacer {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
else if (rValue instanceof Expr_1.AbstractExpr) {
|
|
67
|
-
if (rValue
|
|
67
|
+
if (rValue === this.oldUse) {
|
|
68
68
|
stmt.setRightOp(this.newUse);
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
export declare const CONSTRUCTOR_NAME = "constructor";
|
|
2
2
|
export declare const SUPER_NAME = "super";
|
|
3
3
|
export declare const THIS_NAME = "this";
|
|
4
|
+
export declare const GLOBAL_THIS: string;
|
|
4
5
|
export declare const DEFAULT = "default";
|
|
5
6
|
export declare const ALL = "*";
|
|
6
7
|
export declare const IMPORT = "import";
|
|
7
8
|
export declare const DECLARE_KEYWORD = "DeclareKeyword";
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const NULL_KEYWORD = "null";
|
|
10
|
+
export declare const UNDEFINED_KEYWORD = "undefined";
|
|
11
|
+
export declare const ANY_KEYWORD = "any";
|
|
12
|
+
export declare const UNKNOWN_KEYWORD = "unknown";
|
|
13
|
+
export declare const BOOLEAN_KEYWORD = "boolean";
|
|
14
|
+
export declare const NUMBER_KEYWORD = "number";
|
|
15
|
+
export declare const STRING_KEYWORD = "string";
|
|
16
|
+
export declare const VOID_KEYWORD = "void";
|
|
17
|
+
export declare const NEVER_KEYWORD = "never";
|
|
11
18
|
//# sourceMappingURL=TSConst.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/TSConst.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"TSConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/TSConst.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,WAAW,EAAE,MAAqB,CAAA;AAE/C,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,eAAO,MAAM,GAAG,MAAM,CAAC;AAEvB,eAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,aAAa,UAAU,CAAC"}
|
|
@@ -14,15 +14,22 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.NEVER_KEYWORD = exports.VOID_KEYWORD = exports.STRING_KEYWORD = exports.NUMBER_KEYWORD = exports.BOOLEAN_KEYWORD = exports.UNKNOWN_KEYWORD = exports.ANY_KEYWORD = exports.UNDEFINED_KEYWORD = exports.NULL_KEYWORD = exports.DECLARE_KEYWORD = exports.IMPORT = exports.ALL = exports.DEFAULT = exports.GLOBAL_THIS = exports.THIS_NAME = exports.SUPER_NAME = exports.CONSTRUCTOR_NAME = void 0;
|
|
18
18
|
exports.CONSTRUCTOR_NAME = 'constructor';
|
|
19
19
|
exports.SUPER_NAME = 'super';
|
|
20
20
|
exports.THIS_NAME = 'this';
|
|
21
|
+
exports.GLOBAL_THIS = 'globalThis';
|
|
21
22
|
exports.DEFAULT = 'default';
|
|
22
23
|
exports.ALL = '*';
|
|
23
24
|
exports.IMPORT = 'import';
|
|
24
25
|
// ast const
|
|
25
26
|
exports.DECLARE_KEYWORD = 'DeclareKeyword';
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
27
|
+
exports.NULL_KEYWORD = 'null';
|
|
28
|
+
exports.UNDEFINED_KEYWORD = 'undefined';
|
|
29
|
+
exports.ANY_KEYWORD = 'any';
|
|
30
|
+
exports.UNKNOWN_KEYWORD = 'unknown';
|
|
31
|
+
exports.BOOLEAN_KEYWORD = 'boolean';
|
|
32
|
+
exports.NUMBER_KEYWORD = 'number';
|
|
33
|
+
exports.STRING_KEYWORD = 'string';
|
|
34
|
+
exports.VOID_KEYWORD = 'void';
|
|
35
|
+
exports.NEVER_KEYWORD = 'never';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Stmt } from '../base/Stmt';
|
|
2
|
-
import { GenericType, Type } from '../base/Type';
|
|
2
|
+
import { GenericType, Type, UnclearReferenceType } from '../base/Type';
|
|
3
3
|
import { ArkMethod } from '../model/ArkMethod';
|
|
4
4
|
import { ArkExport } from '../model/ArkExport';
|
|
5
5
|
import { ArkClass } from '../model/ArkClass';
|
|
6
6
|
import { ArkField } from '../model/ArkField';
|
|
7
7
|
import { Value } from '../base/Value';
|
|
8
|
+
import { ClassSignature } from '../model/ArkSignature';
|
|
8
9
|
export declare class TypeInference {
|
|
9
10
|
static inferTypeInArkField(arkField: ArkField): void;
|
|
10
11
|
static inferUnclearedType(leftOpType: Type, declaringArkClass: ArkClass, rightType?: Type): Type | null | undefined;
|
|
@@ -23,6 +24,7 @@ export declare class TypeInference {
|
|
|
23
24
|
* infer type for fieldRefs in stmt.
|
|
24
25
|
*/
|
|
25
26
|
private static resolveFieldRefsInStmt;
|
|
27
|
+
private static processRef;
|
|
26
28
|
static parseArkExport2Type(arkExport: ArkExport | undefined | null): Type | null;
|
|
27
29
|
/**
|
|
28
30
|
* infer and pass type for ArkAssignStmt right and left
|
|
@@ -33,12 +35,16 @@ export declare class TypeInference {
|
|
|
33
35
|
static isUnclearType(type: Type | null | undefined): boolean;
|
|
34
36
|
static inferSimpleTypeInStmt(stmt: Stmt): void;
|
|
35
37
|
static buildTypeFromStr(typeStr: string): Type;
|
|
36
|
-
static inferValueType(value: Value,
|
|
38
|
+
static inferValueType(value: Value, arkMethod: ArkMethod): Type | null;
|
|
37
39
|
static inferMethodReturnType(method: ArkMethod): void;
|
|
40
|
+
private static inferSignatureReturnType;
|
|
38
41
|
static inferGenericType(types: GenericType[] | undefined, arkClass: ArkClass): void;
|
|
42
|
+
static inferUnclearRefType(urType: UnclearReferenceType, arkClass: ArkClass): Type | null;
|
|
39
43
|
static inferUnclearReferenceType(refName: string, arkClass: ArkClass): Type | null;
|
|
40
44
|
static inferFieldType(baseType: Type, fieldName: string, declareClass: ArkClass): [any, Type] | null;
|
|
41
45
|
static inferBaseType(baseName: string, arkClass: ArkClass): Type | null;
|
|
42
46
|
static inferRealGenericTypes(realTypes: Type[] | undefined, arkClass: ArkClass): void;
|
|
47
|
+
static inferAnonymousClass(anon: ArkClass | null, declaredSignature: ClassSignature, set?: Set<string>): void;
|
|
48
|
+
private static assignAnonField;
|
|
43
49
|
}
|
|
44
50
|
//# sourceMappingURL=TypeInference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/TypeInference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/TypeInference.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAgC,IAAI,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAQH,WAAW,EAKX,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,cAAc,EAAuC,MAAM,uBAAuB,CAAC;AAQ5F,qBAAa,aAAa;WAER,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;WAqC7C,kBAAkB,CAAC,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,IAAI;WA6ClF,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAsC3D;;;OAGG;WACW,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAcjE;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAcjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAerC,OAAO,CAAC,MAAM,CAAC,UAAU;WAsBX,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;IAwBvF;;;;OAIG;WACW,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;WAuC1D,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS;WAgB3C,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;WAcvC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;WA2BvC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;WAU/D,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAgC5D,OAAO,CAAC,MAAM,CAAC,wBAAwB;WAkBzB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,QAAQ;WAmBrE,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;WAmBlF,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;WAoC3E,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI;WAgD7F,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;WAoBhE,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;WAe9E,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;CA8BjC"}
|