arkanalyzer 1.0.35 → 1.0.37
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/Scene.js +5 -5
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +9 -6
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts +2 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +3 -3
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +1 -2
- package/lib/callgraph/common/Statistics.d.ts +1 -0
- package/lib/callgraph/common/Statistics.d.ts.map +1 -1
- package/lib/callgraph/common/Statistics.js +4 -1
- package/lib/callgraph/model/CallGraph.d.ts +4 -24
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +8 -37
- package/lib/callgraph/model/CallSite.d.ts +29 -0
- package/lib/callgraph/model/CallSite.d.ts.map +1 -0
- package/lib/callgraph/model/CallSite.js +42 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +1 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -1
- package/lib/callgraph/model/builder/CallGraphBuilder.js +15 -7
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +2 -2
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +11 -3
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +1 -2
- package/lib/core/base/Expr.d.ts +1 -0
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +30 -7
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +5 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +0 -10
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +1 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +3 -4
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +29 -1
- package/lib/core/common/TypeInference.d.ts +2 -1
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +8 -4
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +2 -1
- package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/TrapBuilder.js +20 -15
- package/lib/core/model/ArkImport.js +1 -1
- package/lib/core/model/ArkMethod.d.ts +2 -0
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +37 -28
- package/lib/core/model/builder/ArkClassBuilder.js +12 -3
- package/lib/core/model/builder/ArkFieldBuilder.js +2 -2
- package/lib/core/model/builder/ArkFileBuilder.js +2 -2
- package/lib/core/model/builder/ArkNamespaceBuilder.js +4 -4
- package/lib/save/JsonPrinter.d.ts.map +1 -1
- package/lib/save/JsonPrinter.js +50 -32
- package/package.json +2 -2
|
@@ -28,6 +28,7 @@ const EtsConst_1 = require("../common/EtsConst");
|
|
|
28
28
|
const Constant_1 = require("../base/Constant");
|
|
29
29
|
const Local_1 = require("../base/Local");
|
|
30
30
|
const TSConst_1 = require("../common/TSConst");
|
|
31
|
+
const TypeInference_1 = require("../common/TypeInference");
|
|
31
32
|
exports.arkMethodNodeKind = [
|
|
32
33
|
'MethodDeclaration',
|
|
33
34
|
'Constructor',
|
|
@@ -546,42 +547,37 @@ class ArkMethod extends ArkBaseModel_1.ArkBaseModel {
|
|
|
546
547
|
}
|
|
547
548
|
return args.length >= min && args.length <= max;
|
|
548
549
|
});
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
const isMatched = this.matchParam(parameters[i].getType(), args[i], scene);
|
|
557
|
-
if (!isMatched) {
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
550
|
+
return ((_c = (_b = signatures === null || signatures === void 0 ? void 0 : signatures.find(p => this.isMatched(p.getMethodSubSignature().getParameters(), args))) !== null && _b !== void 0 ? _b : signatures === null || signatures === void 0 ? void 0 : signatures[0]) !== null && _c !== void 0 ? _c : this.getSignature());
|
|
551
|
+
}
|
|
552
|
+
isMatched(parameters, args, isArrowFunc = false) {
|
|
553
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
554
|
+
if (!args[i]) {
|
|
555
|
+
return isArrowFunc ? true : parameters[i].isOptional();
|
|
560
556
|
}
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
const isMatched = this.matchParam(parameters[i].getType(), args[i]);
|
|
558
|
+
if (!isMatched) {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return true;
|
|
563
563
|
}
|
|
564
|
-
matchParam(paramType, arg
|
|
564
|
+
matchParam(paramType, arg) {
|
|
565
565
|
var _a, _b;
|
|
566
|
+
arg = ArkMethod.parseArg(arg);
|
|
566
567
|
const argType = arg.getType();
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
if (stmt instanceof Stmt_1.ArkAssignStmt && stmt.getRightOp() instanceof Constant_1.Constant) {
|
|
570
|
-
arg = stmt.getRightOp();
|
|
571
|
-
}
|
|
568
|
+
if (paramType instanceof Type_1.AliasType && !(argType instanceof Type_1.AliasType)) {
|
|
569
|
+
paramType = TypeInference_1.TypeInference.replaceAliasType(paramType);
|
|
572
570
|
}
|
|
573
571
|
if (paramType instanceof Type_1.UnionType) {
|
|
574
|
-
|
|
575
|
-
for (const e of paramType.getTypes()) {
|
|
576
|
-
if (argType.constructor === e.constructor) {
|
|
577
|
-
matched = true;
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return matched;
|
|
572
|
+
return !!paramType.getTypes().find(p => this.matchParam(p, arg));
|
|
582
573
|
}
|
|
583
574
|
else if (argType instanceof Type_1.FunctionType && paramType instanceof Type_1.FunctionType) {
|
|
584
|
-
|
|
575
|
+
if (argType.getMethodSignature().getParamLength() > paramType.getMethodSignature().getParamLength()) {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
const parameters = paramType.getMethodSignature().getMethodSubSignature().getParameters();
|
|
579
|
+
const args = argType.getMethodSignature().getMethodSubSignature().getParameters().filter(p => !p.getName().startsWith(Const_1.LEXICAL_ENV_NAME_PREFIX));
|
|
580
|
+
return this.isMatched(parameters, args, true);
|
|
585
581
|
}
|
|
586
582
|
else if (paramType instanceof Type_1.ClassType && paramType.getClassSignature().getClassName().includes(EtsConst_1.CALL_BACK)) {
|
|
587
583
|
return argType instanceof Type_1.FunctionType;
|
|
@@ -606,6 +602,19 @@ class ArkMethod extends ArkBaseModel_1.ArkBaseModel {
|
|
|
606
602
|
}
|
|
607
603
|
return argType.constructor === paramType.constructor;
|
|
608
604
|
}
|
|
605
|
+
static parseArg(arg) {
|
|
606
|
+
if (arg instanceof Local_1.Local) {
|
|
607
|
+
const stmt = arg.getDeclaringStmt();
|
|
608
|
+
const argType = arg.getType();
|
|
609
|
+
if (argType instanceof Type_1.EnumValueType && argType.getConstant()) {
|
|
610
|
+
arg = argType.getConstant();
|
|
611
|
+
}
|
|
612
|
+
else if (stmt instanceof Stmt_1.ArkAssignStmt && stmt.getRightOp() instanceof Constant_1.Constant) {
|
|
613
|
+
arg = stmt.getRightOp();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return arg;
|
|
617
|
+
}
|
|
609
618
|
getOuterMethod() {
|
|
610
619
|
return this.outerMethod;
|
|
611
620
|
}
|
|
@@ -316,7 +316,16 @@ function buildArkClassMembers(clsNode, cls, sourceFile) {
|
|
|
316
316
|
const instanceInitStmts = [];
|
|
317
317
|
let staticBlockId = 0;
|
|
318
318
|
clsNode.members.forEach(member => {
|
|
319
|
-
if (ohos_typescript_1.default.
|
|
319
|
+
if (ohos_typescript_1.default.isMethodDeclaration(member) ||
|
|
320
|
+
ohos_typescript_1.default.isConstructorDeclaration(member) ||
|
|
321
|
+
ohos_typescript_1.default.isMethodSignature(member) ||
|
|
322
|
+
ohos_typescript_1.default.isConstructSignatureDeclaration(member) ||
|
|
323
|
+
ohos_typescript_1.default.isAccessor(member) ||
|
|
324
|
+
ohos_typescript_1.default.isCallSignatureDeclaration(member)) {
|
|
325
|
+
// these node types have been handled at the beginning of this function by calling buildMethodsForClass
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
else if (ohos_typescript_1.default.isPropertyDeclaration(member) || ohos_typescript_1.default.isPropertySignature(member)) {
|
|
320
329
|
const arkField = (0, ArkFieldBuilder_1.buildProperty2ArkField)(member, sourceFile, cls);
|
|
321
330
|
if (ohos_typescript_1.default.isClassDeclaration(clsNode) || ohos_typescript_1.default.isClassExpression(clsNode) || ohos_typescript_1.default.isStructDeclaration(clsNode)) {
|
|
322
331
|
if (arkField.isStatic()) {
|
|
@@ -346,10 +355,10 @@ function buildArkClassMembers(clsNode, cls, sourceFile) {
|
|
|
346
355
|
staticInitStmts.push(new Stmt_1.ArkInvokeStmt(staticBlockInvokeExpr));
|
|
347
356
|
}
|
|
348
357
|
else if (ohos_typescript_1.default.isSemicolonClassElement(member)) {
|
|
349
|
-
logger.
|
|
358
|
+
logger.trace('Skip these members.');
|
|
350
359
|
}
|
|
351
360
|
else {
|
|
352
|
-
logger.warn(
|
|
361
|
+
logger.warn(`Please contact developers to support new member in class: ${cls.getSignature().toString()}, member: ${member.getText()}!`);
|
|
353
362
|
}
|
|
354
363
|
});
|
|
355
364
|
if (ohos_typescript_1.default.isClassDeclaration(clsNode) || ohos_typescript_1.default.isClassExpression(clsNode) || ohos_typescript_1.default.isStructDeclaration(clsNode)) {
|
|
@@ -66,7 +66,7 @@ function buildProperty2ArkField(member, sourceFile, cls) {
|
|
|
66
66
|
fieldName = (0, builderUtils_1.handlePropertyAccessExpression)(member.name.expression);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
logger.warn(
|
|
69
|
+
logger.warn(`Other property expression type found: ${member.name.expression.getText()}!`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
else if (member.name && (ohos_typescript_1.default.isIdentifier(member.name) || ohos_typescript_1.default.isLiteralExpression(member.name))) {
|
|
@@ -78,7 +78,7 @@ function buildProperty2ArkField(member, sourceFile, cls) {
|
|
|
78
78
|
field.addModifier(ArkBaseModel_1.ModifierType.PRIVATE);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
logger.warn(
|
|
81
|
+
logger.warn(`Other type of property name found: ${member.getText()}!`);
|
|
82
82
|
}
|
|
83
83
|
let fieldType = Type_1.UnknownType.getInstance();
|
|
84
84
|
if (ohos_typescript_1.default.isPropertyDeclaration(member) || ohos_typescript_1.default.isPropertySignature(member)) {
|
|
@@ -124,7 +124,7 @@ function buildArkFile(arkFile, astRoot) {
|
|
|
124
124
|
}
|
|
125
125
|
// TODO: Check
|
|
126
126
|
else if (ohos_typescript_1.default.isMethodDeclaration(child)) {
|
|
127
|
-
logger.
|
|
127
|
+
logger.trace('This is a MethodDeclaration in ArkFile.');
|
|
128
128
|
let mthd = new ArkMethod_1.ArkMethod();
|
|
129
129
|
(0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(child, arkFile.getDefaultClass(), mthd, astRoot);
|
|
130
130
|
if (mthd.isExported()) {
|
|
@@ -161,7 +161,7 @@ function buildArkFile(arkFile, astRoot) {
|
|
|
161
161
|
child.expression.text.trim() === Const_1.ARKTS_STATIC_MARK && arkFile.setLanguage(ArkFile_1.Language.ARKTS1_2);
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
|
-
logger.
|
|
164
|
+
logger.trace('Child joined default method of arkFile: ', ohos_typescript_1.default.SyntaxKind[child.kind]);
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
const mergedNameSpaces = (0, ArkNamespaceBuilder_1.mergeNameSpaces)(namespaces);
|
|
@@ -88,13 +88,13 @@ function buildArkNamespace(node, declaringInstance, ns, sourceFile) {
|
|
|
88
88
|
// NamespaceDeclaration extends ModuleDeclaration
|
|
89
89
|
//TODO: Check
|
|
90
90
|
else if (ohos_typescript_1.default.isModuleDeclaration(node.body)) {
|
|
91
|
-
logger.
|
|
91
|
+
logger.trace('This ModuleBody is an NamespaceDeclaration.');
|
|
92
92
|
let childNs = new ArkNamespace_1.ArkNamespace();
|
|
93
93
|
buildArkNamespace(node.body, ns, childNs, sourceFile);
|
|
94
94
|
ns.addNamespace(childNs);
|
|
95
95
|
}
|
|
96
96
|
else if (ohos_typescript_1.default.isIdentifier(node.body)) {
|
|
97
|
-
logger.warn('ModuleBody is Identifier
|
|
97
|
+
logger.warn('ModuleBody is Identifier');
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
100
|
logger.warn('JSDocNamespaceDeclaration found.');
|
|
@@ -128,7 +128,7 @@ function buildNamespaceMembers(node, namespace, sourceFile) {
|
|
|
128
128
|
}
|
|
129
129
|
// TODO: Check
|
|
130
130
|
else if (ohos_typescript_1.default.isMethodDeclaration(child)) {
|
|
131
|
-
logger.
|
|
131
|
+
logger.trace('This is a MethodDeclaration in ArkNamespace.');
|
|
132
132
|
let mthd = new ArkMethod_1.ArkMethod();
|
|
133
133
|
(0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(child, namespace.getDefaultClass(), mthd, sourceFile);
|
|
134
134
|
if (mthd.isExported()) {
|
|
@@ -152,7 +152,7 @@ function buildNamespaceMembers(node, namespace, sourceFile) {
|
|
|
152
152
|
(0, ArkExportBuilder_1.buildExportVariableStatement)(child, sourceFile, namespace.getDeclaringArkFile(), namespace).forEach(item => namespace.addExportInfo(item));
|
|
153
153
|
}
|
|
154
154
|
else {
|
|
155
|
-
logger.
|
|
155
|
+
logger.trace('Child joined default method of arkFile: ', ohos_typescript_1.default.SyntaxKind[child.kind]);
|
|
156
156
|
// join default method
|
|
157
157
|
}
|
|
158
158
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonPrinter.d.ts","sourceRoot":"","sources":["../../src/save/JsonPrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonPrinter.d.ts","sourceRoot":"","sources":["../../src/save/JsonPrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAsEhD,qBAAa,WAAY,SAAQ,OAAO;IACxB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAI7B,IAAI,IAAI,MAAM;IAKrB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,wBAAwB;IAOhC,OAAO,CAAC,aAAa;IA6HrB,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAuKtB,OAAO,CAAC,aAAa;CAuCxB"}
|
package/lib/save/JsonPrinter.js
CHANGED
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
17
|
exports.JsonPrinter = void 0;
|
|
21
18
|
const Printer_1 = require("./Printer");
|
|
@@ -26,7 +23,6 @@ const Constant_1 = require("../core/base/Constant");
|
|
|
26
23
|
const ArkSignature_1 = require("../core/model/ArkSignature");
|
|
27
24
|
const Ref_1 = require("../core/base/Ref");
|
|
28
25
|
const Local_1 = require("../core/base/Local");
|
|
29
|
-
const util_1 = __importDefault(require("util"));
|
|
30
26
|
class JsonPrinter extends Printer_1.Printer {
|
|
31
27
|
constructor(arkFile) {
|
|
32
28
|
super();
|
|
@@ -57,8 +53,9 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
57
53
|
return {
|
|
58
54
|
signature: this.serializeClassSignature(clazz.getSignature()),
|
|
59
55
|
modifiers: clazz.getModifiers(),
|
|
60
|
-
decorators: clazz.getDecorators().map(decorator => this.serializeDecorator(decorator)),
|
|
61
|
-
typeParameters: (_a = clazz.getGenericsTypes()) === null || _a === void 0 ? void 0 : _a.map(type => this.serializeType(type)),
|
|
56
|
+
decorators: clazz.getDecorators().map((decorator) => this.serializeDecorator(decorator)),
|
|
57
|
+
typeParameters: (_a = clazz.getGenericsTypes()) === null || _a === void 0 ? void 0 : _a.map((type) => this.serializeType(type)),
|
|
58
|
+
category: clazz.getCategory(),
|
|
62
59
|
superClassName: clazz.getSuperClassName(),
|
|
63
60
|
implementedInterfaceNames: clazz.getImplementedInterfaceNames(),
|
|
64
61
|
fields: clazz.getFields().map(field => this.serializeField(field)),
|
|
@@ -96,6 +93,7 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
96
93
|
name: parameter.getName(),
|
|
97
94
|
type: this.serializeType(parameter.getType()),
|
|
98
95
|
isOptional: parameter.isOptional(),
|
|
96
|
+
isRest: parameter.hasDotDotDotToken(),
|
|
99
97
|
};
|
|
100
98
|
}
|
|
101
99
|
serializeImportInfo(importInfo) {
|
|
@@ -161,6 +159,12 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
161
159
|
types: type.getTypes().map(type => this.serializeType(type)),
|
|
162
160
|
};
|
|
163
161
|
}
|
|
162
|
+
else if (type instanceof Type_1.IntersectionType) {
|
|
163
|
+
return {
|
|
164
|
+
_: 'IntersectionType',
|
|
165
|
+
types: type.getTypes().map((type) => this.serializeType(type)),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
164
168
|
else if (type instanceof Type_1.TupleType) {
|
|
165
169
|
return {
|
|
166
170
|
_: 'TupleType',
|
|
@@ -203,9 +207,6 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
203
207
|
literal: type.getLiteralName(),
|
|
204
208
|
};
|
|
205
209
|
}
|
|
206
|
-
else if (type instanceof Type_1.PrimitiveType) {
|
|
207
|
-
throw new Error('Unhandled PrimitiveType: ' + util_1.default.inspect(type, { showHidden: true, depth: null }));
|
|
208
|
-
}
|
|
209
210
|
else if (type instanceof Type_1.ClassType) {
|
|
210
211
|
return {
|
|
211
212
|
_: 'ClassType',
|
|
@@ -235,13 +236,13 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
235
236
|
};
|
|
236
237
|
}
|
|
237
238
|
else if (type instanceof Type_1.GenericType) {
|
|
238
|
-
let defaultType = type.getDefaultType();
|
|
239
239
|
let constraint = type.getConstraint();
|
|
240
|
+
let defaultType = type.getDefaultType();
|
|
240
241
|
return {
|
|
241
242
|
_: 'GenericType',
|
|
242
243
|
name: type.getName(),
|
|
243
|
-
defaultType: defaultType && this.serializeType(defaultType),
|
|
244
244
|
constraint: constraint && this.serializeType(constraint),
|
|
245
|
+
defaultType: defaultType && this.serializeType(defaultType),
|
|
245
246
|
};
|
|
246
247
|
}
|
|
247
248
|
else if (type instanceof Type_1.AliasType) {
|
|
@@ -265,11 +266,12 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
265
266
|
originType: type.getOriginType(),
|
|
266
267
|
};
|
|
267
268
|
}
|
|
268
|
-
else if (type instanceof Type_1.AnnotationType) {
|
|
269
|
-
throw new Error('Unhandled AnnotationType: ' + util_1.default.inspect(type, { showHidden: true, depth: null }));
|
|
270
|
-
}
|
|
271
269
|
else {
|
|
272
|
-
|
|
270
|
+
console.warn(`Unhandled Type: ${type.constructor.name} (${type.toString()})`);
|
|
271
|
+
return {
|
|
272
|
+
_: type.constructor.name,
|
|
273
|
+
text: type.toString(),
|
|
274
|
+
};
|
|
273
275
|
}
|
|
274
276
|
}
|
|
275
277
|
serializeFileSignature(file) {
|
|
@@ -457,9 +459,6 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
457
459
|
right: this.serializeValue(value.getOp2()),
|
|
458
460
|
};
|
|
459
461
|
}
|
|
460
|
-
else if (value instanceof Expr_1.AbstractBinopExpr) {
|
|
461
|
-
return new Error('Unhandled BinopExpr: ' + util_1.default.inspect(value, { showHidden: true, depth: null }));
|
|
462
|
-
}
|
|
463
462
|
else if (value instanceof Expr_1.ArkUnopExpr) {
|
|
464
463
|
return {
|
|
465
464
|
_: 'UnopExpr',
|
|
@@ -490,9 +489,6 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
490
489
|
args: value.getArgs().map(arg => this.serializeValue(arg)),
|
|
491
490
|
};
|
|
492
491
|
}
|
|
493
|
-
else if (value instanceof Expr_1.AbstractInvokeExpr) {
|
|
494
|
-
throw new Error('Unhandled CallExpr: ' + util_1.default.inspect(value, { showHidden: true, depth: null }));
|
|
495
|
-
}
|
|
496
492
|
else if (value instanceof Ref_1.ArkThisRef) {
|
|
497
493
|
return {
|
|
498
494
|
_: 'ThisRef',
|
|
@@ -514,6 +510,28 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
514
510
|
type: this.serializeType(value.getType()),
|
|
515
511
|
};
|
|
516
512
|
}
|
|
513
|
+
else if (value instanceof Ref_1.ArkCaughtExceptionRef) {
|
|
514
|
+
return {
|
|
515
|
+
_: 'CaughtExceptionRef',
|
|
516
|
+
type: this.serializeType(value.getType()),
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
else if (value instanceof Ref_1.GlobalRef) {
|
|
520
|
+
let ref = value.getRef();
|
|
521
|
+
return {
|
|
522
|
+
_: 'GlobalRef',
|
|
523
|
+
name: value.getName(),
|
|
524
|
+
ref: ref ? this.serializeValue(ref) : null,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
else if (value instanceof Ref_1.ClosureFieldRef) {
|
|
528
|
+
return {
|
|
529
|
+
_: 'ClosureFieldRef',
|
|
530
|
+
base: this.serializeLocal(value.getBase()),
|
|
531
|
+
fieldName: value.getFieldName(),
|
|
532
|
+
type: this.serializeType(value.getType()),
|
|
533
|
+
};
|
|
534
|
+
}
|
|
517
535
|
else if (value instanceof Ref_1.ArkInstanceFieldRef) {
|
|
518
536
|
return {
|
|
519
537
|
_: 'InstanceFieldRef',
|
|
@@ -527,17 +545,13 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
527
545
|
field: this.serializeFieldSignature(value.getFieldSignature()),
|
|
528
546
|
};
|
|
529
547
|
}
|
|
530
|
-
else if (value instanceof Ref_1.AbstractFieldRef) {
|
|
531
|
-
throw new Error('Unhandled FieldRef: ' + util_1.default.inspect(value, { showHidden: true, depth: null }));
|
|
532
|
-
}
|
|
533
|
-
else if (value instanceof Ref_1.AbstractRef) {
|
|
534
|
-
throw new Error('Unhandled Ref: ' + util_1.default.inspect(value, { showHidden: true, depth: null }));
|
|
535
|
-
}
|
|
536
|
-
else if (value instanceof Expr_1.AbstractExpr) {
|
|
537
|
-
throw new Error('Unhandled Expr: ' + util_1.default.inspect(value, { showHidden: true, depth: null }));
|
|
538
|
-
}
|
|
539
548
|
else {
|
|
540
|
-
|
|
549
|
+
console.warn(`Unhandled Value: ${value.constructor.name} (${value.toString()})`);
|
|
550
|
+
return {
|
|
551
|
+
_: value.constructor.name,
|
|
552
|
+
text: value.toString(),
|
|
553
|
+
type: this.serializeType(value.getType()),
|
|
554
|
+
};
|
|
541
555
|
}
|
|
542
556
|
}
|
|
543
557
|
serializeStmt(stmt) {
|
|
@@ -578,7 +592,11 @@ class JsonPrinter extends Printer_1.Printer {
|
|
|
578
592
|
};
|
|
579
593
|
}
|
|
580
594
|
else {
|
|
581
|
-
|
|
595
|
+
console.warn(`Unhandled Stmt: ${stmt.constructor.name} (${stmt.toString()})`);
|
|
596
|
+
return {
|
|
597
|
+
_: stmt.constructor.name,
|
|
598
|
+
text: stmt.toString(),
|
|
599
|
+
};
|
|
582
600
|
}
|
|
583
601
|
}
|
|
584
602
|
}
|