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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stmt.d.ts","sourceRoot":"","sources":["../../../src/core/base/Stmt.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGrF,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"Stmt.d.ts","sourceRoot":"","sources":["../../../src/core/base/Stmt.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGrF,OAAO,EAAE,SAAS,EAA2D,MAAM,QAAQ,CAAC;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,8BAAsB,IAAI;IACtB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAChC,S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M;IAInC,QAAQ,IAAI,MAAM;IAKlB,OAAO,IAAI,KAAK,EAAE;CAM5B;AAED,qBAAa,aAAc,SAAQ,IAAI;IACnC,OAAO,CAAC,EAAE,CAAQ;gBAEN,EAAE,EAAE,KAAK;IAKd,yBAAyB,IAAI,MAAM;IAInC,KAAK,IAAI,KAAK;IAId,cAAc,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI;IAIxC,QAAQ,IAAI,MAAM;IAKlB,OAAO,IAAI,KAAK,EAAE;CAM5B;AAED,qBAAa,iBAAkB,SAAQ,IAAI;;IAKhC,yBAAyB,IAAI,MAAM;IAInC,QAAQ,IAAI,MAAM;CAI5B;AAED,qBAAa,YAAa,SAAQ,IAAI;IAClC,OAAO,CAAC,EAAE,CAAQ;gBAEN,EAAE,EAAE,KAAK;IAKd,KAAK,IAAI,KAAK;IAId,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIzB,QAAQ,IAAI,MAAM;IAKlB,OAAO,IAAI,KAAK,EAAE;CAM5B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAuB,SAAQ,IAAI;IAC5C,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa;IAMvD,YAAY,IAAI,SAAS;IAIzB,gBAAgB,IAAI,aAAa;IAIjC,YAAY,IAAI,MAAM;IAItB,QAAQ,IAAI,MAAM;IAWlB,QAAQ,IAAI,aAAa,EAAE;IAI3B,YAAY,IAAI,gBAAgB,EAAE;CAqB5C"}
|
package/lib/core/base/Stmt.js
CHANGED
|
@@ -22,7 +22,9 @@ const Position_1 = require("./Position");
|
|
|
22
22
|
const ArkMetadata_1 = require("../model/ArkMetadata");
|
|
23
23
|
const StmtDefReplacer_1 = require("../common/StmtDefReplacer");
|
|
24
24
|
const IRUtils_1 = require("../common/IRUtils");
|
|
25
|
+
const Type_1 = require("./Type");
|
|
25
26
|
const ArkBaseModel_1 = require("../model/ArkBaseModel");
|
|
27
|
+
const TypeExpr_1 = require("./TypeExpr");
|
|
26
28
|
/**
|
|
27
29
|
* @category core/base/stmt
|
|
28
30
|
*/
|
|
@@ -165,6 +167,16 @@ class Stmt {
|
|
|
165
167
|
}
|
|
166
168
|
return exprs;
|
|
167
169
|
}
|
|
170
|
+
getTypeExprs() {
|
|
171
|
+
let typeExprs = [];
|
|
172
|
+
for (const value of this.getDefAndUses()) {
|
|
173
|
+
const valueType = value.getType();
|
|
174
|
+
if (valueType instanceof TypeExpr_1.AbstractTypeExpr) {
|
|
175
|
+
typeExprs.push(valueType);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return typeExprs;
|
|
179
|
+
}
|
|
168
180
|
containsArrayRef() {
|
|
169
181
|
for (const use of this.getUses()) {
|
|
170
182
|
if (use instanceof Ref_1.ArkArrayRef) {
|
|
@@ -487,5 +499,27 @@ class ArkAliasTypeDefineStmt extends Stmt {
|
|
|
487
499
|
getExprs() {
|
|
488
500
|
return [this.getAliasTypeExpr()];
|
|
489
501
|
}
|
|
502
|
+
getTypeExprs() {
|
|
503
|
+
function getTypeExprsInType(originalObject) {
|
|
504
|
+
let typeExprs = [];
|
|
505
|
+
if (originalObject instanceof TypeExpr_1.AbstractTypeExpr) {
|
|
506
|
+
typeExprs.push(originalObject);
|
|
507
|
+
}
|
|
508
|
+
else if (originalObject instanceof Type_1.ArrayType) {
|
|
509
|
+
typeExprs.push(...getTypeExprsInType(originalObject.getBaseType()));
|
|
510
|
+
}
|
|
511
|
+
else if (originalObject instanceof Type_1.UnionType || originalObject instanceof Type_1.IntersectionType || originalObject instanceof Type_1.TupleType) {
|
|
512
|
+
for (const member of originalObject.getTypes()) {
|
|
513
|
+
typeExprs.push(...getTypeExprsInType(member));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return typeExprs;
|
|
517
|
+
}
|
|
518
|
+
const originalObject = this.getAliasTypeExpr().getOriginalObject();
|
|
519
|
+
if (originalObject instanceof Type_1.Type) {
|
|
520
|
+
return getTypeExprsInType(originalObject);
|
|
521
|
+
}
|
|
522
|
+
return [];
|
|
523
|
+
}
|
|
490
524
|
}
|
|
491
525
|
exports.ArkAliasTypeDefineStmt = ArkAliasTypeDefineStmt;
|
package/lib/core/base/Type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AliasTypeSignature, ClassSignature, MethodSignature, NamespaceSignature } from '../model/ArkSignature';
|
|
2
2
|
import { ArkExport, ExportType } from '../model/ArkExport';
|
|
3
3
|
import { ModifierType } from '../model/ArkBaseModel';
|
|
4
4
|
import { Local } from './Local';
|
|
@@ -110,6 +110,16 @@ export declare class UnionType extends Type {
|
|
|
110
110
|
getTypeString(): string;
|
|
111
111
|
flatType(): Type[];
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* intersection type
|
|
115
|
+
* @category core/base/type
|
|
116
|
+
*/
|
|
117
|
+
export declare class IntersectionType extends Type {
|
|
118
|
+
private types;
|
|
119
|
+
constructor(types: Type[]);
|
|
120
|
+
getTypes(): Type[];
|
|
121
|
+
getTypeString(): string;
|
|
122
|
+
}
|
|
113
123
|
/**
|
|
114
124
|
* types for function void return type
|
|
115
125
|
* @category core/base/type
|
|
@@ -162,9 +172,23 @@ export declare class ClassType extends Type {
|
|
|
162
172
|
setRealGenericTypes(types: Type[] | undefined): void;
|
|
163
173
|
getTypeString(): string;
|
|
164
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Array type
|
|
177
|
+
* @category core/base/type
|
|
178
|
+
* @extends Type
|
|
179
|
+
* @example
|
|
180
|
+
```typescript
|
|
181
|
+
// baseType is number, dimension is 1, readonlyFlag is true
|
|
182
|
+
let a: readonly number[] = [1, 2, 3];
|
|
183
|
+
|
|
184
|
+
// baseType is number, dimension is 1, readonlyFlag is undefined
|
|
185
|
+
let a: number[] = [1, 2, 3];
|
|
186
|
+
```
|
|
187
|
+
*/
|
|
165
188
|
export declare class ArrayType extends Type {
|
|
166
189
|
private baseType;
|
|
167
190
|
private dimension;
|
|
191
|
+
private readonlyFlag?;
|
|
168
192
|
constructor(baseType: Type, dimension: number);
|
|
169
193
|
/**
|
|
170
194
|
* Returns the base type of this array, such as `Any`, `Unknown`, `TypeParameter`, etc.
|
|
@@ -173,12 +197,30 @@ export declare class ArrayType extends Type {
|
|
|
173
197
|
getBaseType(): Type;
|
|
174
198
|
setBaseType(newType: Type): void;
|
|
175
199
|
getDimension(): number;
|
|
200
|
+
setReadonlyFlag(readonlyFlag: boolean): void;
|
|
201
|
+
getReadonlyFlag(): boolean | undefined;
|
|
176
202
|
getTypeString(): string;
|
|
177
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Tuple type
|
|
206
|
+
* @category core/base/type
|
|
207
|
+
* @extends Type
|
|
208
|
+
* @example
|
|
209
|
+
```typescript
|
|
210
|
+
// types are number and string, dimension is 1, readonlyFlag is true
|
|
211
|
+
let a: readonly number[] = [1, 2, 3];
|
|
212
|
+
|
|
213
|
+
// baseType is number, dimension is 1, readonlyFlag is undefined
|
|
214
|
+
let a: number[] = [1, 2, 3];
|
|
215
|
+
```
|
|
216
|
+
*/
|
|
178
217
|
export declare class TupleType extends Type {
|
|
179
218
|
private types;
|
|
219
|
+
private readonlyFlag?;
|
|
180
220
|
constructor(types: Type[]);
|
|
181
221
|
getTypes(): Type[];
|
|
222
|
+
setReadonlyFlag(readonlyFlag: boolean): void;
|
|
223
|
+
getReadonlyFlag(): boolean | undefined;
|
|
182
224
|
getTypeString(): string;
|
|
183
225
|
}
|
|
184
226
|
/**
|
|
@@ -206,7 +248,7 @@ export declare class AliasType extends Type implements ArkExport {
|
|
|
206
248
|
protected modifiers?: number;
|
|
207
249
|
private genericTypes?;
|
|
208
250
|
private realGenericTypes?;
|
|
209
|
-
constructor(name: string, originalType: Type, signature:
|
|
251
|
+
constructor(name: string, originalType: Type, signature: AliasTypeSignature, genericTypes?: GenericType[]);
|
|
210
252
|
getName(): string;
|
|
211
253
|
setOriginalType(type: Type): void;
|
|
212
254
|
getOriginalType(): Type;
|
|
@@ -217,7 +259,7 @@ export declare class AliasType extends Type implements ArkExport {
|
|
|
217
259
|
setModifiers(modifiers: number): void;
|
|
218
260
|
addModifier(modifier: ModifierType | number): void;
|
|
219
261
|
removeModifier(modifier: ModifierType): void;
|
|
220
|
-
getSignature():
|
|
262
|
+
getSignature(): AliasTypeSignature;
|
|
221
263
|
setGenericTypes(genericTypes: GenericType[]): void;
|
|
222
264
|
getGenericTypes(): GenericType[] | undefined;
|
|
223
265
|
setRealGenericTypes(realGenericTypes: Type[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Type.d.ts","sourceRoot":"","sources":["../../../src/core/base/Type.ts"],"names":[],"mappings":"AAeA,OAAO,
|
|
1
|
+
{"version":3,"file":"Type.d.ts","sourceRoot":"","sources":["../../../src/core/base/Type.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAsB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAYzE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;GAEG;AACH,8BAAsB,IAAI;IACtB,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,aAAa,IAAI,MAAM;CACnC;AAED;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,IAAI;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAiB;WAEnC,WAAW,IAAI,OAAO;IAIpC,OAAO;IAIA,aAAa,IAAI,MAAM;CAGjC;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,IAAI;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAqB;W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AK,EAAE;IAItB,UAAU,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI;IAIhC,aAAa,IAAI,MAAM;CAGjC"}
|
package/lib/core/base/Type.js
CHANGED
|
@@ -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
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.LexicalEnvType = exports.AnnotationTypeQueryType = exports.AnnotationNamespaceType = exports.AnnotationType = exports.GenericType = exports.AliasType = exports.TupleType = exports.ArrayType = exports.ClassType = exports.ClosureType = exports.FunctionType = exports.NeverType = exports.VoidType = exports.UnionType = exports.LiteralType = exports.UndefinedType = exports.NullType = exports.StringType = exports.NumberType = exports.BooleanType = exports.PrimitiveType = exports.UnclearReferenceType = exports.UnknownType = exports.AnyType = exports.Type = void 0;
|
|
17
|
+
exports.LexicalEnvType = exports.AnnotationTypeQueryType = exports.AnnotationNamespaceType = exports.AnnotationType = exports.GenericType = exports.AliasType = exports.TupleType = exports.ArrayType = exports.ClassType = exports.ClosureType = exports.FunctionType = exports.NeverType = exports.VoidType = exports.IntersectionType = exports.UnionType = exports.LiteralType = exports.UndefinedType = exports.NullType = exports.StringType = exports.NumberType = exports.BooleanType = exports.PrimitiveType = exports.UnclearReferenceType = exports.UnknownType = exports.AnyType = exports.Type = void 0;
|
|
18
18
|
const ArkSignature_1 = require("../model/ArkSignature");
|
|
19
19
|
const ArkExport_1 = require("../model/ArkExport");
|
|
20
20
|
const ArkBaseModel_1 = require("../model/ArkBaseModel");
|
|
@@ -201,8 +201,18 @@ class UnionType extends Type {
|
|
|
201
201
|
this.currType = newType;
|
|
202
202
|
}
|
|
203
203
|
getTypeString() {
|
|
204
|
-
|
|
204
|
+
let typesString = [];
|
|
205
|
+
this.getTypes().forEach((t) => {
|
|
206
|
+
if (t instanceof UnionType || t instanceof IntersectionType) {
|
|
207
|
+
typesString.push(`(${t.toString()})`);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
typesString.push(t.toString());
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return typesString.join('|');
|
|
205
214
|
}
|
|
215
|
+
// TODO: Need to remove this function because of IntersectionType has been added.
|
|
206
216
|
flatType() {
|
|
207
217
|
const result = [];
|
|
208
218
|
this.types.forEach(t => {
|
|
@@ -217,6 +227,32 @@ class UnionType extends Type {
|
|
|
217
227
|
}
|
|
218
228
|
}
|
|
219
229
|
exports.UnionType = UnionType;
|
|
230
|
+
/**
|
|
231
|
+
* intersection type
|
|
232
|
+
* @category core/base/type
|
|
233
|
+
*/
|
|
234
|
+
class IntersectionType extends Type {
|
|
235
|
+
constructor(types) {
|
|
236
|
+
super();
|
|
237
|
+
this.types = [...types];
|
|
238
|
+
}
|
|
239
|
+
getTypes() {
|
|
240
|
+
return this.types;
|
|
241
|
+
}
|
|
242
|
+
getTypeString() {
|
|
243
|
+
let typesString = [];
|
|
244
|
+
this.getTypes().forEach((t) => {
|
|
245
|
+
if (t instanceof UnionType || t instanceof IntersectionType) {
|
|
246
|
+
typesString.push(`(${t.toString()})`);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
typesString.push(t.toString());
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return typesString.join('&');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
exports.IntersectionType = IntersectionType;
|
|
220
256
|
/**
|
|
221
257
|
* types for function void return type
|
|
222
258
|
* @category core/base/type
|
|
@@ -318,6 +354,19 @@ class ClassType extends Type {
|
|
|
318
354
|
}
|
|
319
355
|
}
|
|
320
356
|
exports.ClassType = ClassType;
|
|
357
|
+
/**
|
|
358
|
+
* Array type
|
|
359
|
+
* @category core/base/type
|
|
360
|
+
* @extends Type
|
|
361
|
+
* @example
|
|
362
|
+
```typescript
|
|
363
|
+
// baseType is number, dimension is 1, readonlyFlag is true
|
|
364
|
+
let a: readonly number[] = [1, 2, 3];
|
|
365
|
+
|
|
366
|
+
// baseType is number, dimension is 1, readonlyFlag is undefined
|
|
367
|
+
let a: number[] = [1, 2, 3];
|
|
368
|
+
```
|
|
369
|
+
*/
|
|
321
370
|
class ArrayType extends Type {
|
|
322
371
|
constructor(baseType, dimension) {
|
|
323
372
|
super();
|
|
@@ -337,9 +386,18 @@ class ArrayType extends Type {
|
|
|
337
386
|
getDimension() {
|
|
338
387
|
return this.dimension;
|
|
339
388
|
}
|
|
389
|
+
setReadonlyFlag(readonlyFlag) {
|
|
390
|
+
this.readonlyFlag = readonlyFlag;
|
|
391
|
+
}
|
|
392
|
+
getReadonlyFlag() {
|
|
393
|
+
return this.readonlyFlag;
|
|
394
|
+
}
|
|
340
395
|
getTypeString() {
|
|
341
396
|
const strs = [];
|
|
342
|
-
if (this.
|
|
397
|
+
if (this.getReadonlyFlag()) {
|
|
398
|
+
strs.push('readonly ');
|
|
399
|
+
}
|
|
400
|
+
if (this.baseType instanceof UnionType || this.baseType instanceof IntersectionType) {
|
|
343
401
|
strs.push('(' + this.baseType.toString() + ')');
|
|
344
402
|
}
|
|
345
403
|
else if (this.baseType) {
|
|
@@ -352,6 +410,19 @@ class ArrayType extends Type {
|
|
|
352
410
|
}
|
|
353
411
|
}
|
|
354
412
|
exports.ArrayType = ArrayType;
|
|
413
|
+
/**
|
|
414
|
+
* Tuple type
|
|
415
|
+
* @category core/base/type
|
|
416
|
+
* @extends Type
|
|
417
|
+
* @example
|
|
418
|
+
```typescript
|
|
419
|
+
// types are number and string, dimension is 1, readonlyFlag is true
|
|
420
|
+
let a: readonly number[] = [1, 2, 3];
|
|
421
|
+
|
|
422
|
+
// baseType is number, dimension is 1, readonlyFlag is undefined
|
|
423
|
+
let a: number[] = [1, 2, 3];
|
|
424
|
+
```
|
|
425
|
+
*/
|
|
355
426
|
class TupleType extends Type {
|
|
356
427
|
constructor(types) {
|
|
357
428
|
super();
|
|
@@ -360,7 +431,16 @@ class TupleType extends Type {
|
|
|
360
431
|
getTypes() {
|
|
361
432
|
return this.types;
|
|
362
433
|
}
|
|
434
|
+
setReadonlyFlag(readonlyFlag) {
|
|
435
|
+
this.readonlyFlag = readonlyFlag;
|
|
436
|
+
}
|
|
437
|
+
getReadonlyFlag() {
|
|
438
|
+
return this.readonlyFlag;
|
|
439
|
+
}
|
|
363
440
|
getTypeString() {
|
|
441
|
+
if (this.getReadonlyFlag()) {
|
|
442
|
+
return 'readonly [' + this.types.join(', ') + ']';
|
|
443
|
+
}
|
|
364
444
|
return '[' + this.types.join(', ') + ']';
|
|
365
445
|
}
|
|
366
446
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Value } from './Value';
|
|
2
|
+
import { ArkMethod } from '../model/ArkMethod';
|
|
3
|
+
import { Type } from './Type';
|
|
4
|
+
import { ArkBaseModel } from '../model/ArkBaseModel';
|
|
5
|
+
/**
|
|
6
|
+
* abstract type expr represents the type operations of types or values.
|
|
7
|
+
* AbstractTypeExpr is different from AbstractExpr.
|
|
8
|
+
* @category core/base/typeExpr
|
|
9
|
+
* @extends Type
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* let a = number;
|
|
13
|
+
* type A = typeof a;
|
|
14
|
+
* let b: keyof typeof a;
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class AbstractTypeExpr extends Type {
|
|
18
|
+
abstract getUses(): Value[];
|
|
19
|
+
abstract getType(): Type;
|
|
20
|
+
inferType(arkMethod: ArkMethod): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* typeQuery type expr represents the get type of value with typeof.
|
|
24
|
+
* @category core/base/typeExpr
|
|
25
|
+
* @extends AbstractTypeExpr
|
|
26
|
+
* @example
|
|
27
|
+
```typescript
|
|
28
|
+
// opValue is a and type A is number
|
|
29
|
+
let a = number;
|
|
30
|
+
type A = typeof a;
|
|
31
|
+
```
|
|
32
|
+
*/
|
|
33
|
+
export declare class TypeQueryExpr extends AbstractTypeExpr {
|
|
34
|
+
private opValue;
|
|
35
|
+
private genericTypes?;
|
|
36
|
+
constructor(opValue: Value | ArkBaseModel, generateTypes?: Type[]);
|
|
37
|
+
setOpValue(opValue: Value | ArkBaseModel): void;
|
|
38
|
+
getOpValue(): Value | ArkBaseModel;
|
|
39
|
+
setGenerateTypes(types: Type[]): void;
|
|
40
|
+
getGenerateTypes(): Type[] | undefined;
|
|
41
|
+
addGenericType(gType: Type): void;
|
|
42
|
+
getUses(): Value[];
|
|
43
|
+
getType(): Type;
|
|
44
|
+
getTypeString(): string;
|
|
45
|
+
inferType(arkMethod: ArkMethod): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* keyof type expr represents the type operator with keyof.
|
|
49
|
+
* It should be an internal expr.
|
|
50
|
+
* the final type should be transferred to union type, unless it cannot find out all types within the union type.
|
|
51
|
+
* @category core/base/typeExpr
|
|
52
|
+
* @extends AbstractTypeExpr
|
|
53
|
+
* @example
|
|
54
|
+
```typescript
|
|
55
|
+
// opType is {a: 1, b: 2} and type of A is KeyofTypeExpr, which can be transferred to union type {'a', 'b'}
|
|
56
|
+
type A = keyof {a: 1, b: 2};
|
|
57
|
+
|
|
58
|
+
// opType is number and type of B is KeyofTypeExpr, which can be transferred to union type "toString" | "toFixed" | "toExponential" | ...
|
|
59
|
+
type B = keyof number;
|
|
60
|
+
```
|
|
61
|
+
*/
|
|
62
|
+
export declare class KeyofTypeExpr extends AbstractTypeExpr {
|
|
63
|
+
private opType;
|
|
64
|
+
constructor(opType: Type);
|
|
65
|
+
getOpType(): Type;
|
|
66
|
+
setOpType(opType: Type): void;
|
|
67
|
+
getUses(): Value[];
|
|
68
|
+
getType(): Type;
|
|
69
|
+
getTypeString(): string;
|
|
70
|
+
inferType(arkMethod: ArkMethod): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=TypeExpr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeExpr.d.ts","sourceRoot":"","sources":["../../../src/core/base/TypeExpr.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAoB,IAAI,EAA0B,MAAM,QAAQ,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD;;;;;;;;;;;GAWG;AACH,8BAAsB,gBAAiB,SAAQ,IAAI;IAC/C,QAAQ,CAAC,OAAO,IAAI,KAAK,EAAE;IAE3B,QAAQ,CAAC,OAAO,IAAI,IAAI;IAEjB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;CAG/C;AAED;;;;;;;;;;GAUG;AAEH,qBAAa,aAAc,SAAQ,gBAAgB;IAC/C,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,OAAO,EAAE,KAAK,GAAG,YAAY,EAAE,aAAa,CAAC,EAAE,IAAI,EAAE;IAM1D,UAAU,CAAC,OAAO,EAAE,KAAK,GAAG,YAAY,GAAG,IAAI;IAI/C,UAAU,IAAI,KAAK,GAAG,YAAY;IAIlC,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAIrC,gBAAgB,IAAI,IAAI,EAAE,GAAG,SAAS;IAItC,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI;IAOjC,OAAO,IAAI,KAAK,EAAE;IAWlB,OAAO,IAAI,IAAI;IAQf,aAAa,IAAI,MAAM;IAUvB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;CAG/C;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC/C,OAAO,CAAC,MAAM,CAAO;gBAET,MAAM,EAAE,IAAI;IAKjB,SAAS,IAAI,IAAI;IAIjB,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI;IAI7B,OAAO,IAAI,KAAK,EAAE;IAQlB,OAAO,IAAI,IAAI;IAIf,aAAa,IAAI,MAAM;IAOvB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;CAG/C"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.KeyofTypeExpr = exports.TypeQueryExpr = exports.AbstractTypeExpr = void 0;
|
|
18
|
+
const ArkMethod_1 = require("../model/ArkMethod");
|
|
19
|
+
const Type_1 = require("./Type");
|
|
20
|
+
const IRInference_1 = require("../common/IRInference");
|
|
21
|
+
const ArkBaseModel_1 = require("../model/ArkBaseModel");
|
|
22
|
+
const ModelUtils_1 = require("../common/ModelUtils");
|
|
23
|
+
const ArkClass_1 = require("../model/ArkClass");
|
|
24
|
+
/**
|
|
25
|
+
* abstract type expr represents the type operations of types or values.
|
|
26
|
+
* AbstractTypeExpr is different from AbstractExpr.
|
|
27
|
+
* @category core/base/typeExpr
|
|
28
|
+
* @extends Type
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* let a = number;
|
|
32
|
+
* type A = typeof a;
|
|
33
|
+
* let b: keyof typeof a;
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
class AbstractTypeExpr extends Type_1.Type {
|
|
37
|
+
inferType(arkMethod) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.AbstractTypeExpr = AbstractTypeExpr;
|
|
42
|
+
/**
|
|
43
|
+
* typeQuery type expr represents the get type of value with typeof.
|
|
44
|
+
* @category core/base/typeExpr
|
|
45
|
+
* @extends AbstractTypeExpr
|
|
46
|
+
* @example
|
|
47
|
+
```typescript
|
|
48
|
+
// opValue is a and type A is number
|
|
49
|
+
let a = number;
|
|
50
|
+
type A = typeof a;
|
|
51
|
+
```
|
|
52
|
+
*/
|
|
53
|
+
class TypeQueryExpr extends AbstractTypeExpr {
|
|
54
|
+
constructor(opValue, generateTypes) {
|
|
55
|
+
super();
|
|
56
|
+
this.opValue = opValue;
|
|
57
|
+
this.genericTypes = generateTypes;
|
|
58
|
+
}
|
|
59
|
+
setOpValue(opValue) {
|
|
60
|
+
this.opValue = opValue;
|
|
61
|
+
}
|
|
62
|
+
getOpValue() {
|
|
63
|
+
return this.opValue;
|
|
64
|
+
}
|
|
65
|
+
setGenerateTypes(types) {
|
|
66
|
+
this.genericTypes = types;
|
|
67
|
+
}
|
|
68
|
+
getGenerateTypes() {
|
|
69
|
+
return this.genericTypes;
|
|
70
|
+
}
|
|
71
|
+
addGenericType(gType) {
|
|
72
|
+
if (!this.genericTypes) {
|
|
73
|
+
this.genericTypes = [];
|
|
74
|
+
}
|
|
75
|
+
this.genericTypes.push(gType);
|
|
76
|
+
}
|
|
77
|
+
getUses() {
|
|
78
|
+
const opValue = this.getOpValue();
|
|
79
|
+
if (opValue instanceof ArkBaseModel_1.ArkBaseModel) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
let uses = [];
|
|
83
|
+
uses.push(opValue);
|
|
84
|
+
uses.push(...opValue.getUses());
|
|
85
|
+
return uses;
|
|
86
|
+
}
|
|
87
|
+
getType() {
|
|
88
|
+
var _a;
|
|
89
|
+
const opValue = this.getOpValue();
|
|
90
|
+
if (opValue instanceof ArkBaseModel_1.ArkBaseModel) {
|
|
91
|
+
return (_a = ModelUtils_1.ModelUtils.parseArkBaseModel2Type(opValue)) !== null && _a !== void 0 ? _a : Type_1.UnknownType.getInstance();
|
|
92
|
+
}
|
|
93
|
+
return opValue.getType();
|
|
94
|
+
}
|
|
95
|
+
getTypeString() {
|
|
96
|
+
const opValue = this.getOpValue();
|
|
97
|
+
const gTypes = this.getGenerateTypes();
|
|
98
|
+
const genericStr = gTypes && gTypes.length > 0 ? `<${gTypes.join(',')}>` : '';
|
|
99
|
+
if (opValue instanceof ArkClass_1.ArkClass || opValue instanceof ArkMethod_1.ArkMethod) {
|
|
100
|
+
return `typeof ${opValue.getSignature().toString()}${genericStr}`;
|
|
101
|
+
}
|
|
102
|
+
return `typeof ${opValue.toString()}${genericStr}`;
|
|
103
|
+
}
|
|
104
|
+
inferType(arkMethod) {
|
|
105
|
+
IRInference_1.IRInference.inferTypeQueryExpr(this, arkMethod);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.TypeQueryExpr = TypeQueryExpr;
|
|
109
|
+
/**
|
|
110
|
+
* keyof type expr represents the type operator with keyof.
|
|
111
|
+
* It should be an internal expr.
|
|
112
|
+
* the final type should be transferred to union type, unless it cannot find out all types within the union type.
|
|
113
|
+
* @category core/base/typeExpr
|
|
114
|
+
* @extends AbstractTypeExpr
|
|
115
|
+
* @example
|
|
116
|
+
```typescript
|
|
117
|
+
// opType is {a: 1, b: 2} and type of A is KeyofTypeExpr, which can be transferred to union type {'a', 'b'}
|
|
118
|
+
type A = keyof {a: 1, b: 2};
|
|
119
|
+
|
|
120
|
+
// opType is number and type of B is KeyofTypeExpr, which can be transferred to union type "toString" | "toFixed" | "toExponential" | ...
|
|
121
|
+
type B = keyof number;
|
|
122
|
+
```
|
|
123
|
+
*/
|
|
124
|
+
class KeyofTypeExpr extends AbstractTypeExpr {
|
|
125
|
+
constructor(opType) {
|
|
126
|
+
super();
|
|
127
|
+
this.opType = opType;
|
|
128
|
+
}
|
|
129
|
+
getOpType() {
|
|
130
|
+
return this.opType;
|
|
131
|
+
}
|
|
132
|
+
setOpType(opType) {
|
|
133
|
+
this.opType = opType;
|
|
134
|
+
}
|
|
135
|
+
getUses() {
|
|
136
|
+
let uses = [];
|
|
137
|
+
if (this.getOpType() instanceof TypeQueryExpr) {
|
|
138
|
+
uses.push(...this.getOpType().getUses());
|
|
139
|
+
}
|
|
140
|
+
return uses;
|
|
141
|
+
}
|
|
142
|
+
getType() {
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
getTypeString() {
|
|
146
|
+
if (this.getOpType() instanceof Type_1.UnionType || this.getOpType() instanceof Type_1.IntersectionType) {
|
|
147
|
+
return `keyof (${this.getOpType().toString()})`;
|
|
148
|
+
}
|
|
149
|
+
return `keyof ${this.getOpType().toString()}`;
|
|
150
|
+
}
|
|
151
|
+
inferType(arkMethod) {
|
|
152
|
+
IRInference_1.IRInference.inferKeyofTypeExpr(this, arkMethod);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.KeyofTypeExpr = KeyofTypeExpr;
|
|
@@ -43,6 +43,7 @@ export declare class ArkIRTransformer {
|
|
|
43
43
|
private addInvokeStmts;
|
|
44
44
|
private shouldGenerateExtraAssignStmt;
|
|
45
45
|
private typeAliasDeclarationToStmts;
|
|
46
|
+
private generateAliasTypeExpr;
|
|
46
47
|
private resolveImportTypeNode;
|
|
47
48
|
switchStatementToValueAndStmts(switchStatement: ts.SwitchStatement): ValueAndStmts[];
|
|
48
49
|
private forStatementToStmts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkIRTransformer.d.ts","sourceRoot":"","sources":["../../../src/core/common/ArkIRTransformer.ts"],"names":[],"mappings":"AAeA,OAAO,EAOH,cAAc,EAGd,aAAa,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA2E,SAAS,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACH,sBAAsB,EAOtB,IAAI,EACP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAmE,MAAM,cAAc,CAAC;AAW1G,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,OAAO,EAAE,YAAY,EAAmB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ArkIRTransformer.d.ts","sourceRoot":"","sources":["../../../src/core/common/ArkIRTransformer.ts"],"names":[],"mappings":"AAeA,OAAO,EAOH,cAAc,EAGd,aAAa,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA2E,SAAS,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACH,sBAAsB,EAOtB,IAAI,EACP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAmE,MAAM,cAAc,CAAC;AAW1G,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,OAAO,EAAE,YAAY,EAAmB,MAAM,kBAAkB,CAAC;AAUjE,MAAM,MAAM,aAAa,GAAG;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,sBAAsB,EAAE,YAAY,E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