arkanalyzer 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/config/arkanalyzer.json +8 -0
  2. package/docs/IR2ts-stmt.md +81 -0
  3. package/docs/IR2ts.md +82 -0
  4. package/lib/Config.d.ts +9 -1
  5. package/lib/Config.d.ts.map +1 -1
  6. package/lib/Config.js +24 -11
  7. package/lib/Scene.d.ts +49 -42
  8. package/lib/Scene.d.ts.map +1 -1
  9. package/lib/Scene.js +124 -93
  10. package/lib/callgraph/algorithm/AbstractAnalysis.js +1 -1
  11. package/lib/callgraph/common/Statistics.js +1 -1
  12. package/lib/callgraph/model/CallGraph.d.ts +3 -2
  13. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  14. package/lib/callgraph/model/CallGraph.js +16 -6
  15. package/lib/callgraph/model/builder/CallGraphBuilder.js +1 -1
  16. package/lib/callgraph/pointerAnalysis/Pag.d.ts +35 -8
  17. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  18. package/lib/callgraph/pointerAnalysis/Pag.js +93 -12
  19. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +32 -5
  20. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  21. package/lib/callgraph/pointerAnalysis/PagBuilder.js +378 -83
  22. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +3 -0
  23. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  24. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +71 -18
  25. package/lib/core/base/Constant.d.ts +25 -5
  26. package/lib/core/base/Constant.d.ts.map +1 -1
  27. package/lib/core/base/Constant.js +46 -8
  28. package/lib/core/base/Expr.d.ts +45 -40
  29. package/lib/core/base/Expr.d.ts.map +1 -1
  30. package/lib/core/base/Expr.js +239 -153
  31. package/lib/core/base/Local.d.ts +2 -2
  32. package/lib/core/base/Local.d.ts.map +1 -1
  33. package/lib/core/base/Local.js +2 -2
  34. package/lib/core/base/Ref.d.ts +38 -37
  35. package/lib/core/base/Ref.d.ts.map +1 -1
  36. package/lib/core/base/Ref.js +102 -70
  37. package/lib/core/base/Stmt.d.ts +4 -0
  38. package/lib/core/base/Stmt.d.ts.map +1 -1
  39. package/lib/core/base/Stmt.js +12 -1
  40. package/lib/core/base/Type.d.ts +4 -0
  41. package/lib/core/base/Type.d.ts.map +1 -1
  42. package/lib/core/base/Type.js +41 -17
  43. package/lib/core/common/ArkError.d.ts +15 -0
  44. package/lib/core/common/ArkError.d.ts.map +1 -0
  45. package/lib/core/common/ArkError.js +28 -0
  46. package/lib/core/common/ArkIRTransformer.d.ts +7 -3
  47. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  48. package/lib/core/common/ArkIRTransformer.js +46 -20
  49. package/lib/core/common/Builtin.js +1 -1
  50. package/lib/core/common/CfgBuilder.d.ts +12 -0
  51. package/lib/core/common/CfgBuilder.d.ts.map +1 -1
  52. package/lib/core/common/CfgBuilder.js +289 -61
  53. package/lib/core/common/Const.d.ts +15 -10
  54. package/lib/core/common/Const.d.ts.map +1 -1
  55. package/lib/core/common/Const.js +18 -11
  56. package/lib/core/common/DummyMainCreater.d.ts +2 -1
  57. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  58. package/lib/core/common/DummyMainCreater.js +28 -15
  59. package/lib/core/common/EtsConst.d.ts +1 -0
  60. package/lib/core/common/EtsConst.d.ts.map +1 -1
  61. package/lib/core/common/EtsConst.js +2 -1
  62. package/lib/core/common/IRUtils.d.ts +7 -0
  63. package/lib/core/common/IRUtils.d.ts.map +1 -1
  64. package/lib/core/common/IRUtils.js +34 -2
  65. package/lib/core/common/ModelUtils.d.ts +1 -0
  66. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  67. package/lib/core/common/ModelUtils.js +32 -32
  68. package/lib/core/common/TSConst.d.ts +10 -3
  69. package/lib/core/common/TSConst.d.ts.map +1 -1
  70. package/lib/core/common/TSConst.js +11 -4
  71. package/lib/core/common/TypeInference.d.ts +8 -2
  72. package/lib/core/common/TypeInference.d.ts.map +1 -1
  73. package/lib/core/common/TypeInference.js +218 -87
  74. package/lib/core/common/ValueUtil.d.ts +0 -4
  75. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  76. package/lib/core/common/ValueUtil.js +8 -25
  77. package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
  78. package/lib/core/dataflow/DataflowSolver.js +2 -4
  79. package/lib/core/dataflow/TiantAnalysis.js +2 -1
  80. package/lib/core/dataflow/Util.d.ts +1 -1
  81. package/lib/core/dataflow/Util.d.ts.map +1 -1
  82. package/lib/core/dataflow/Util.js +8 -7
  83. package/lib/core/graph/BasicBlock.d.ts +41 -0
  84. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  85. package/lib/core/graph/BasicBlock.js +132 -1
  86. package/lib/core/graph/Cfg.d.ts +30 -1
  87. package/lib/core/graph/Cfg.d.ts.map +1 -1
  88. package/lib/core/graph/Cfg.js +129 -6
  89. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  90. package/lib/core/graph/builder/ViewTreeBuilder.js +3 -2
  91. package/lib/core/model/ArkBaseModel.d.ts +8 -0
  92. package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
  93. package/lib/core/model/ArkBaseModel.js +56 -4
  94. package/lib/core/model/ArkClass.d.ts +36 -30
  95. package/lib/core/model/ArkClass.d.ts.map +1 -1
  96. package/lib/core/model/ArkClass.js +79 -40
  97. package/lib/core/model/ArkExport.d.ts +3 -0
  98. package/lib/core/model/ArkExport.d.ts.map +1 -1
  99. package/lib/core/model/ArkExport.js +11 -1
  100. package/lib/core/model/ArkField.d.ts +2 -0
  101. package/lib/core/model/ArkField.d.ts.map +1 -1
  102. package/lib/core/model/ArkField.js +4 -1
  103. package/lib/core/model/ArkFile.d.ts +4 -0
  104. package/lib/core/model/ArkFile.d.ts.map +1 -1
  105. package/lib/core/model/ArkFile.js +20 -0
  106. package/lib/core/model/ArkImport.d.ts +2 -0
  107. package/lib/core/model/ArkImport.d.ts.map +1 -1
  108. package/lib/core/model/ArkImport.js +3 -0
  109. package/lib/core/model/ArkMetadata.d.ts +20 -0
  110. package/lib/core/model/ArkMetadata.d.ts.map +1 -0
  111. package/lib/core/model/ArkMetadata.js +44 -0
  112. package/lib/core/model/ArkMethod.d.ts +156 -53
  113. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  114. package/lib/core/model/ArkMethod.js +309 -54
  115. package/lib/core/model/ArkNamespace.d.ts +4 -0
  116. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  117. package/lib/core/model/ArkNamespace.js +13 -0
  118. package/lib/core/model/ArkSignature.d.ts +11 -5
  119. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  120. package/lib/core/model/ArkSignature.js +38 -18
  121. package/lib/core/model/builder/ArkClassBuilder.d.ts +0 -1
  122. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  123. package/lib/core/model/builder/ArkClassBuilder.js +9 -34
  124. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
  125. package/lib/core/model/builder/ArkExportBuilder.js +6 -1
  126. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  127. package/lib/core/model/builder/ArkFieldBuilder.js +3 -0
  128. package/lib/core/model/builder/ArkFileBuilder.js +1 -1
  129. package/lib/core/model/builder/ArkImportBuilder.d.ts +2 -1
  130. package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
  131. package/lib/core/model/builder/ArkImportBuilder.js +12 -5
  132. package/lib/core/model/builder/ArkMethodBuilder.d.ts +2 -1
  133. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  134. package/lib/core/model/builder/ArkMethodBuilder.js +87 -47
  135. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  136. package/lib/core/model/builder/ArkNamespaceBuilder.js +2 -0
  137. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  138. package/lib/core/model/builder/builderUtils.js +25 -2
  139. package/lib/save/source/SourceClass.d.ts.map +1 -1
  140. package/lib/save/source/SourceClass.js +4 -0
  141. package/lib/save/source/SourceField.d.ts.map +1 -1
  142. package/lib/save/source/SourceField.js +4 -0
  143. package/lib/save/source/SourceMethod.d.ts.map +1 -1
  144. package/lib/save/source/SourceMethod.js +7 -0
  145. package/lib/save/source/SourceModule.d.ts.map +1 -1
  146. package/lib/save/source/SourceModule.js +14 -9
  147. package/lib/save/source/SourceNamespace.d.ts.map +1 -1
  148. package/lib/save/source/SourceNamespace.js +4 -0
  149. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  150. package/lib/save/source/SourceStmt.js +15 -3
  151. package/lib/save/source/SourceTransformer.d.ts +6 -0
  152. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  153. package/lib/save/source/SourceTransformer.js +72 -41
  154. package/lib/save/source/SourceUtils.d.ts.map +1 -1
  155. package/lib/save/source/SourceUtils.js +3 -2
  156. package/lib/transformer/StaticSingleAssignmentFormer.js +1 -1
  157. package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
  158. package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
  159. package/lib/utils/CfgStructualAnalysis.js +42 -8
  160. package/lib/utils/callGraphUtils.d.ts.map +1 -1
  161. package/lib/utils/callGraphUtils.js +7 -10
  162. package/lib/utils/crypto_utils.d.ts +6 -0
  163. package/lib/utils/crypto_utils.d.ts.map +1 -0
  164. package/lib/utils/crypto_utils.js +57 -0
  165. package/lib/utils/entryMethodUtils.js +23 -23
  166. package/lib/utils/getAllFiles.d.ts +1 -1
  167. package/lib/utils/getAllFiles.d.ts.map +1 -1
  168. package/lib/utils/getAllFiles.js +4 -5
  169. package/lib/utils/logger.js +2 -2
  170. package/package.json +3 -2
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.AnnotationTypeQueryType = exports.AnnotationNamespaceType = exports.AnnotationType = exports.AliasTypeDeclaration = exports.GenericType = exports.AliasType = exports.TupleType = exports.ArrayType = exports.ClassType = 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;
18
18
  const ArkSignature_1 = require("../model/ArkSignature");
19
19
  const ArkExport_1 = require("../model/ArkExport");
20
+ const ArkBaseModel_1 = require("../model/ArkBaseModel");
21
+ const TSConst_1 = require("../common/TSConst");
20
22
  /**
21
23
  * @category core/base/type
22
24
  */
@@ -35,7 +37,7 @@ class AnyType extends Type {
35
37
  super();
36
38
  }
37
39
  toString() {
38
- return 'any';
40
+ return TSConst_1.ANY_KEYWORD;
39
41
  }
40
42
  }
41
43
  exports.AnyType = AnyType;
@@ -52,7 +54,7 @@ class UnknownType extends Type {
52
54
  super();
53
55
  }
54
56
  toString() {
55
- return 'unknown';
57
+ return TSConst_1.UNKNOWN_KEYWORD;
56
58
  }
57
59
  }
58
60
  exports.UnknownType = UnknownType;
@@ -101,7 +103,7 @@ class PrimitiveType extends Type {
101
103
  exports.PrimitiveType = PrimitiveType;
102
104
  class BooleanType extends PrimitiveType {
103
105
  constructor() {
104
- super('boolean');
106
+ super(TSConst_1.BOOLEAN_KEYWORD);
105
107
  }
106
108
  static getInstance() {
107
109
  return this.INSTANCE;
@@ -111,7 +113,7 @@ exports.BooleanType = BooleanType;
111
113
  BooleanType.INSTANCE = new BooleanType();
112
114
  class NumberType extends PrimitiveType {
113
115
  constructor() {
114
- super('number');
116
+ super(TSConst_1.NUMBER_KEYWORD);
115
117
  }
116
118
  static getInstance() {
117
119
  return this.INSTANCE;
@@ -121,7 +123,7 @@ exports.NumberType = NumberType;
121
123
  NumberType.INSTANCE = new NumberType();
122
124
  class StringType extends PrimitiveType {
123
125
  constructor() {
124
- super('string');
126
+ super(TSConst_1.STRING_KEYWORD);
125
127
  }
126
128
  static getInstance() {
127
129
  return this.INSTANCE;
@@ -138,7 +140,7 @@ class NullType extends PrimitiveType {
138
140
  return this.INSTANCE;
139
141
  }
140
142
  constructor() {
141
- super('null');
143
+ super(TSConst_1.NULL_KEYWORD);
142
144
  }
143
145
  }
144
146
  exports.NullType = NullType;
@@ -152,7 +154,7 @@ class UndefinedType extends PrimitiveType {
152
154
  return this.INSTANCE;
153
155
  }
154
156
  constructor() {
155
- super('undefined');
157
+ super(TSConst_1.UNDEFINED_KEYWORD);
156
158
  }
157
159
  }
158
160
  exports.UndefinedType = UndefinedType;
@@ -196,11 +198,7 @@ class UnionType extends Type {
196
198
  this.currType = newType;
197
199
  }
198
200
  toString() {
199
- let typeStr = this.types.join('|');
200
- if (!(this.currType instanceof UnknownType) && this.currType !== this) {
201
- typeStr += '-' + this.currType;
202
- }
203
- return typeStr;
201
+ return this.types.join('|');
204
202
  }
205
203
  }
206
204
  exports.UnionType = UnionType;
@@ -216,7 +214,7 @@ class VoidType extends Type {
216
214
  super();
217
215
  }
218
216
  toString() {
219
- return 'void';
217
+ return TSConst_1.VOID_KEYWORD;
220
218
  }
221
219
  }
222
220
  exports.VoidType = VoidType;
@@ -229,7 +227,7 @@ class NeverType extends Type {
229
227
  super();
230
228
  }
231
229
  toString() {
232
- return 'never';
230
+ return TSConst_1.NEVER_KEYWORD;
233
231
  }
234
232
  }
235
233
  exports.NeverType = NeverType;
@@ -278,7 +276,13 @@ class ClassType extends Type {
278
276
  this.realGenericTypes = types;
279
277
  }
280
278
  toString() {
281
- return this.classSignature.toString();
279
+ var _a;
280
+ let temp = this.classSignature.toString();
281
+ let generic = (_a = this.realGenericTypes) === null || _a === void 0 ? void 0 : _a.join(',');
282
+ if (generic) {
283
+ temp += `<${generic}>`;
284
+ }
285
+ return temp;
282
286
  }
283
287
  }
284
288
  exports.ClassType = ClassType;
@@ -352,10 +356,30 @@ class AliasType extends Type {
352
356
  return ArkExport_1.ExportType.TYPE;
353
357
  }
354
358
  getModifiers() {
355
- return 0;
359
+ if (!this.modifiers) {
360
+ return 0;
361
+ }
362
+ return this.modifiers;
356
363
  }
357
364
  containsModifier(modifierType) {
358
- return false;
365
+ if (!this.modifiers) {
366
+ return false;
367
+ }
368
+ return (this.modifiers & modifierType) === modifierType;
369
+ }
370
+ setModifiers(modifiers) {
371
+ if (modifiers !== 0) {
372
+ this.modifiers = modifiers;
373
+ }
374
+ }
375
+ addModifier(modifier) {
376
+ this.modifiers = this.getModifiers() | modifier;
377
+ }
378
+ removeModifier(modifier) {
379
+ if (!this.modifiers) {
380
+ return;
381
+ }
382
+ this.modifiers &= ArkBaseModel_1.MODIFIER_TYPE_MASK ^ modifier;
359
383
  }
360
384
  getSignature() {
361
385
  return this.signature;
@@ -0,0 +1,15 @@
1
+ export declare enum ArkErrorCode {
2
+ OK = 0,
3
+ CLASS_INSTANCE_FIELD_UNDEFINDED = -1,
4
+ BB_MORE_THAN_ONE_BRANCH_RET_STMT = -2,
5
+ BB_BRANCH_RET_STMT_NOT_AT_END = -3,
6
+ CFG_NOT_FOUND_START_BLOCK = -4,
7
+ CFG_HAS_UNREACHABLE_BLOCK = -5,
8
+ METHOD_SIGNATURE_UNDEFINED = -6,
9
+ METHOD_SIGNATURE_LINE_UNMATCHED = -7
10
+ }
11
+ export interface ArkError {
12
+ errCode: ArkErrorCode;
13
+ errMsg?: string;
14
+ }
15
+ //# sourceMappingURL=ArkError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArkError.d.ts","sourceRoot":"","sources":["../../../src/core/common/ArkError.ts"],"names":[],"mappings":"AAeA,oBAAY,YAAY;IACpB,EAAE,IAAI;IACN,+BAA+B,KAAK;IACpC,gCAAgC,KAAK;IACrC,6BAA6B,KAAK;IAClC,yBAAyB,KAAK;IAC9B,yBAAyB,KAAK;IAC9B,0BAA0B,KAAK;IAC/B,+BAA+B,KAAK;CACvC;AAED,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 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.ArkErrorCode = void 0;
18
+ var ArkErrorCode;
19
+ (function (ArkErrorCode) {
20
+ ArkErrorCode[ArkErrorCode["OK"] = 0] = "OK";
21
+ ArkErrorCode[ArkErrorCode["CLASS_INSTANCE_FIELD_UNDEFINDED"] = -1] = "CLASS_INSTANCE_FIELD_UNDEFINDED";
22
+ ArkErrorCode[ArkErrorCode["BB_MORE_THAN_ONE_BRANCH_RET_STMT"] = -2] = "BB_MORE_THAN_ONE_BRANCH_RET_STMT";
23
+ ArkErrorCode[ArkErrorCode["BB_BRANCH_RET_STMT_NOT_AT_END"] = -3] = "BB_BRANCH_RET_STMT_NOT_AT_END";
24
+ ArkErrorCode[ArkErrorCode["CFG_NOT_FOUND_START_BLOCK"] = -4] = "CFG_NOT_FOUND_START_BLOCK";
25
+ ArkErrorCode[ArkErrorCode["CFG_HAS_UNREACHABLE_BLOCK"] = -5] = "CFG_HAS_UNREACHABLE_BLOCK";
26
+ ArkErrorCode[ArkErrorCode["METHOD_SIGNATURE_UNDEFINED"] = -6] = "METHOD_SIGNATURE_UNDEFINED";
27
+ ArkErrorCode[ArkErrorCode["METHOD_SIGNATURE_LINE_UNMATCHED"] = -7] = "METHOD_SIGNATURE_LINE_UNMATCHED";
28
+ })(ArkErrorCode = exports.ArkErrorCode || (exports.ArkErrorCode = {}));
@@ -6,7 +6,6 @@ import { Stmt } from '../base/Stmt';
6
6
  import { AliasType, AliasTypeDeclaration } from '../base/Type';
7
7
  import { ArkMethod } from '../model/ArkMethod';
8
8
  import { FullPosition } from '../base/Position';
9
- export declare const DUMMY_INITIALIZER_STMT = "dummyInitializerStmt";
10
9
  type ValueAndStmts = {
11
10
  value: Value;
12
11
  valueOriginalPositions: FullPosition[];
@@ -17,8 +16,12 @@ export declare class DummyStmt extends Stmt {
17
16
  toString(): string;
18
17
  }
19
18
  export declare class ArkIRTransformer {
20
- private readonly tempLocalPrefix;
21
- private tempLocalIndex;
19
+ static readonly DUMMY_LOOP_INITIALIZER_STMT = "LoopInitializer";
20
+ static readonly DUMMY_CONDITIONAL_OPERATOR_IF_TRUE_STMT = "ConditionalOperatorIfTrue";
21
+ static readonly DUMMY_CONDITIONAL_OPERATOR_IF_FALSE_STMT = "ConditionalOperatorIfFalse";
22
+ static readonly DUMMY_CONDITIONAL_OPERATOR_END_STMT = "ConditionalOperatorEnd";
23
+ private conditionalOperatorNo;
24
+ private tempLocalNo;
22
25
  private locals;
23
26
  private sourceFile;
24
27
  private declaringMethod;
@@ -33,6 +36,7 @@ export declare class ArkIRTransformer {
33
36
  getAliasTypeMap(): Map<string, [AliasType, AliasTypeDeclaration]>;
34
37
  prebuildStmts(): Stmt[];
35
38
  tsNodeToStmts(node: ts.Node): Stmt[];
39
+ private functionDeclarationToStmts;
36
40
  private returnStatementToStmts;
37
41
  private blockToStmts;
38
42
  private expressionStatementToStmts;
@@ -1 +1 @@
1
- {"version":3,"file":"ArkIRTransformer.d.ts","sourceRoot":"","sources":["../../../src/core/common/ArkIRTransformer.ts"],"names":[],"mappings":"AAeA,OAAO,EAkBH,cAAc,EAGd,aAAa,EAChB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,iBAAiB,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AAsC;IAW9C,OAAO,CAAC,kCAAkC;IAqF1C,OAAO,CAAC,+BAA+B;IA8EvC,OAAO,CAAC,yBAAyB;IAkCjC,OAAO,CAAC,iCAAiC;IA4CzC,OAAO,CAAC,uCAAuC;IAsC/C,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,0BAA0B;IA6ClC,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,iBAAiB;IAQlB,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,GAAG,aAAa;IAQtG,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,eAAe;IAkDvB,OAAO,CAAC,sBAAsB;IAoB9B,OAAO,CAAC,8BAA8B;IA2CtC,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,aAAa;IAed,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI;WAU7C,oBAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,aAAa,GAAG,IAAI;WAchE,qBAAqB,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,cAAc,GAAG,IAAI;CAqDnF"}
@@ -37,7 +37,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  return result;
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.ArkIRTransformer = exports.DummyStmt = exports.DUMMY_INITIALIZER_STMT = void 0;
40
+ exports.ArkIRTransformer = exports.DummyStmt = void 0;
41
41
  const Expr_1 = require("../base/Expr");
42
42
  const Ref_1 = require("../base/Ref");
43
43
  const ts = __importStar(require("ohos-typescript"));
@@ -59,8 +59,9 @@ const Position_1 = require("../base/Position");
59
59
  const ModelUtils_1 = require("./ModelUtils");
60
60
  const Builtin_1 = require("./Builtin");
61
61
  const TSConst_1 = require("./TSConst");
62
+ const builderUtils_1 = require("../model/builder/builderUtils");
63
+ const Const_1 = require("./Const");
62
64
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkIRTransformer');
63
- exports.DUMMY_INITIALIZER_STMT = 'dummyInitializerStmt';
64
65
  class DummyStmt extends Stmt_1.Stmt {
65
66
  constructor(text) {
66
67
  super();
@@ -73,8 +74,8 @@ class DummyStmt extends Stmt_1.Stmt {
73
74
  exports.DummyStmt = DummyStmt;
74
75
  class ArkIRTransformer {
75
76
  constructor(sourceFile, declaringMethod) {
76
- this.tempLocalPrefix = '$temp';
77
- this.tempLocalIndex = 0;
77
+ this.conditionalOperatorNo = 0;
78
+ this.tempLocalNo = 0;
78
79
  this.locals = new Map();
79
80
  this.inBuilderMethod = false;
80
81
  this.aliasTypeMap = new Map();
@@ -154,9 +155,24 @@ class ArkIRTransformer {
154
155
  else if (ts.isReturnStatement(node)) {
155
156
  stmts = this.returnStatementToStmts(node);
156
157
  }
158
+ else if (ts.isFunctionDeclaration(node)) {
159
+ stmts = this.functionDeclarationToStmts(node);
160
+ }
157
161
  this.mapStmtsToTsStmt(stmts, node);
162
+ if (stmts.length > 0) {
163
+ IRUtils_1.IRUtils.setLeadingComments(stmts[0], node, this.sourceFile, this.declaringMethod.getDeclaringArkFile().getScene().getOptions());
164
+ }
158
165
  return stmts;
159
166
  }
167
+ functionDeclarationToStmts(functionDeclarationNode) {
168
+ const declaringClass = this.declaringMethod.getDeclaringArkClass();
169
+ const arkMethod = new ArkMethod_1.ArkMethod();
170
+ if (this.builderMethodContextFlag) {
171
+ ModelUtils_1.ModelUtils.implicitArkUIBuilderMethods.add(arkMethod);
172
+ }
173
+ (0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(functionDeclarationNode, declaringClass, arkMethod, this.sourceFile, this.declaringMethod);
174
+ return [];
175
+ }
160
176
  returnStatementToStmts(returnStatement) {
161
177
  const stmts = [];
162
178
  if (returnStatement.expression) {
@@ -224,6 +240,8 @@ class ArkIRTransformer {
224
240
  const aliasName = typeAliasDeclaration.name.text;
225
241
  const originalType = this.resolveTypeNode(typeAliasDeclaration.type);
226
242
  const aliasType = new Type_1.AliasType(aliasName, originalType, new ArkSignature_1.LocalSignature(aliasName, this.declaringMethod.getSignature()));
243
+ const modifiers = typeAliasDeclaration.modifiers ? (0, builderUtils_1.buildModifiers)(typeAliasDeclaration) : 0;
244
+ aliasType.setModifiers(modifiers);
227
245
  const sourceCode = typeAliasDeclaration.getText(this.sourceFile);
228
246
  const aliasTypePosition = Position_1.LineColPosition.buildFromNode(typeAliasDeclaration, this.sourceFile);
229
247
  const aliasTypeDeclaration = new Type_1.AliasTypeDeclaration(sourceCode, aliasTypePosition);
@@ -259,7 +277,7 @@ class ArkIRTransformer {
259
277
  if (forStatement.initializer) {
260
278
  stmts.push(...this.tsNodeToValueAndStmts(forStatement.initializer).stmts);
261
279
  }
262
- const dummyInitializerStmt = new DummyStmt(exports.DUMMY_INITIALIZER_STMT);
280
+ const dummyInitializerStmt = new DummyStmt(ArkIRTransformer.DUMMY_LOOP_INITIALIZER_STMT);
263
281
  stmts.push(dummyInitializerStmt);
264
282
  if (forStatement.condition) {
265
283
  const { value: conditionValue, stmts: conditionStmts, } = this.conditionToValueAndStmts(forStatement.condition);
@@ -324,7 +342,7 @@ class ArkIRTransformer {
324
342
  const elements = variableDeclaration.name.elements;
325
343
  let index = 0;
326
344
  for (const element of elements) {
327
- const arrayRef = new Ref_1.ArkArrayRef(arrayItem, new Constant_1.Constant(index.toString(), Type_1.NumberType.getInstance()));
345
+ const arrayRef = new Ref_1.ArkArrayRef(arrayItem, ValueUtil_1.ValueUtil.getOrCreateNumberConst(index));
328
346
  const arrayRefPositions = [arrayItemPositions[0], ...arrayItemPositions, Position_1.FullPosition.DEFAULT];
329
347
  const item = new Local_1.Local(element.getText(this.sourceFile));
330
348
  const itemPosition = Position_1.FullPosition.buildFromNode(element, this.sourceFile);
@@ -369,7 +387,7 @@ class ArkIRTransformer {
369
387
  }
370
388
  whileStatementToStmts(whileStatement) {
371
389
  const stmts = [];
372
- const dummyInitializerStmt = new DummyStmt(exports.DUMMY_INITIALIZER_STMT);
390
+ const dummyInitializerStmt = new DummyStmt(ArkIRTransformer.DUMMY_LOOP_INITIALIZER_STMT);
373
391
  stmts.push(dummyInitializerStmt);
374
392
  const { value: conditionExpr, stmts: conditionStmts, } = this.conditionToValueAndStmts(whileStatement.expression);
375
393
  stmts.push(...conditionStmts);
@@ -551,23 +569,29 @@ class ArkIRTransformer {
551
569
  };
552
570
  }
553
571
  conditionalExpressionToValueAndStmts(conditionalExpression) {
554
- // TODO: separated by blocks
555
572
  const stmts = [];
573
+ const currConditionalOperatorIndex = this.conditionalOperatorNo++;
556
574
  const { value: conditionValue, valueOriginalPositions: conditionPositions, stmts: conditionStmts, } = this.conditionToValueAndStmts(conditionalExpression.condition);
557
575
  stmts.push(...conditionStmts);
558
576
  const ifStmt = new Stmt_1.ArkIfStmt(conditionValue);
559
577
  ifStmt.setOperandOriginalPositions(conditionPositions);
560
578
  stmts.push(ifStmt);
579
+ stmts.push(new DummyStmt(ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_IF_TRUE_STMT + currConditionalOperatorIndex));
561
580
  const { value: whenTrueValue, valueOriginalPositions: whenTruePositions, stmts: whenTrueStmts } = this.tsNodeToValueAndStmts(conditionalExpression.whenTrue);
562
581
  stmts.push(...whenTrueStmts);
563
- const { value: resultValue, valueOriginalPositions: resultPositions, stmts: tempStmts, } = this.generateAssignStmtForValue(whenTrueValue, whenTruePositions);
564
- stmts.push(...tempStmts);
582
+ const resultLocal = this.generateTempLocal();
583
+ const assignStmtWhenTrue = new Stmt_1.ArkAssignStmt(resultLocal, whenTrueValue);
584
+ const resultLocalPosition = [whenTruePositions[0]];
585
+ assignStmtWhenTrue.setOperandOriginalPositions([...resultLocalPosition, ...whenTruePositions]);
586
+ stmts.push(assignStmtWhenTrue);
587
+ stmts.push(new DummyStmt(ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_IF_FALSE_STMT + currConditionalOperatorIndex));
565
588
  const { value: whenFalseValue, valueOriginalPositions: whenFalsePositions, stmts: whenFalseStmts, } = this.tsNodeToValueAndStmts(conditionalExpression.whenFalse);
566
589
  stmts.push(...whenFalseStmts);
567
- const assignStmt = new Stmt_1.ArkAssignStmt(resultValue, whenFalseValue);
568
- assignStmt.setOperandOriginalPositions([...resultPositions, ...whenFalsePositions]);
590
+ const assignStmt = new Stmt_1.ArkAssignStmt(resultLocal, whenFalseValue);
591
+ assignStmt.setOperandOriginalPositions([...resultLocalPosition, ...whenFalsePositions]);
569
592
  stmts.push(assignStmt);
570
- return { value: resultValue, valueOriginalPositions: resultPositions, stmts: stmts };
593
+ stmts.push(new DummyStmt(ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_END_STMT + currConditionalOperatorIndex));
594
+ return { value: resultLocal, valueOriginalPositions: resultLocalPosition, stmts: stmts };
571
595
  }
572
596
  objectLiteralExpresionToValueAndStmts(objectLiteralExpression) {
573
597
  const declaringArkClass = this.declaringMethod.getDeclaringArkClass();
@@ -618,9 +642,9 @@ class ArkIRTransformer {
618
642
  const createViewArgPositionsAll = [newExprPositions];
619
643
  if (ts.isEtsComponentExpression(componentExpression) && componentExpression.body) {
620
644
  const anonymous = ts.factory.createArrowFunction([], [], [], undefined, undefined, componentExpression.body);
621
- // @ts-ignore
645
+ // @ts-expect-error: add pos info for the created ArrowFunction
622
646
  anonymous.pos = componentExpression.body.pos;
623
- // @ts-ignore
647
+ // @ts-expect-error: add end info for the created ArrowFunction
624
648
  anonymous.end = componentExpression.body.end;
625
649
  const { value: builderMethod, valueOriginalPositions: builderMethodPositions, } = this.callableNodeToValueAndStmts(anonymous);
626
650
  createViewArgs.push(builderMethod);
@@ -798,7 +822,6 @@ class ArkIRTransformer {
798
822
  if (callExpression.typeArguments) {
799
823
  realGenericTypes = [];
800
824
  callExpression.typeArguments.forEach(typeArgument => {
801
- // @ts-ignore
802
825
  realGenericTypes.push(this.resolveTypeNode(typeArgument));
803
826
  });
804
827
  }
@@ -894,7 +917,6 @@ class ArkIRTransformer {
894
917
  if (newExpression.typeArguments) {
895
918
  realGenericTypes = [];
896
919
  newExpression.typeArguments.forEach(typeArgument => {
897
- // @ts-ignore
898
920
  realGenericTypes.push(this.resolveTypeNode(typeArgument));
899
921
  });
900
922
  }
@@ -1172,7 +1194,7 @@ class ArkIRTransformer {
1172
1194
  const elements = leftOpNode.elements;
1173
1195
  let index = 0;
1174
1196
  for (const element of elements) {
1175
- const arrayRef = new Ref_1.ArkArrayRef(leftValue, new Constant_1.Constant(index.toString(), Type_1.NumberType.getInstance()));
1197
+ const arrayRef = new Ref_1.ArkArrayRef(leftValue, ValueUtil_1.ValueUtil.getOrCreateNumberConst(index));
1176
1198
  const arrayRefPositions = [leftPositions[0], ...leftPositions, Position_1.FullPosition.DEFAULT];
1177
1199
  const item = new Local_1.Local(element.getText(this.sourceFile));
1178
1200
  const itemPosition = Position_1.FullPosition.buildFromNode(element, this.sourceFile);
@@ -1432,8 +1454,8 @@ class ArkIRTransformer {
1432
1454
  return local;
1433
1455
  }
1434
1456
  generateTempLocal(localType = Type_1.UnknownType.getInstance()) {
1435
- const tempLocalName = this.tempLocalPrefix + this.tempLocalIndex;
1436
- this.tempLocalIndex++;
1457
+ const tempLocalName = Const_1.TEMP_LOCAL_PREFIX + this.tempLocalNo;
1458
+ this.tempLocalNo++;
1437
1459
  const tempLocal = new Local_1.Local(tempLocalName, localType);
1438
1460
  this.locals.set(tempLocalName, tempLocal);
1439
1461
  return tempLocal;
@@ -1691,3 +1713,7 @@ class ArkIRTransformer {
1691
1713
  }
1692
1714
  }
1693
1715
  exports.ArkIRTransformer = ArkIRTransformer;
1716
+ ArkIRTransformer.DUMMY_LOOP_INITIALIZER_STMT = 'LoopInitializer';
1717
+ ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_IF_TRUE_STMT = 'ConditionalOperatorIfTrue';
1718
+ ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_IF_FALSE_STMT = 'ConditionalOperatorIfFalse';
1719
+ ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_END_STMT = 'ConditionalOperatorEnd';
@@ -57,7 +57,7 @@ Builtin.BUILT_IN_CLASSES = _a.buildBuiltInClasses();
57
57
  // signature for built-in class
58
58
  Builtin.DUMMY_PROJECT_NAME = 'ES2015';
59
59
  Builtin.DUMMY_FILE_NAME = 'BuiltinClass';
60
- Builtin.BUILT_IN_CLASSES_FILE_SIGNATURE = _a.buildBuiltInClassesFileSignature();
60
+ Builtin.BUILT_IN_CLASSES_FILE_SIGNATURE = Builtin.buildBuiltInClassesFileSignature();
61
61
  Builtin.OBJECT_CLASS_SIGNATURE = _a.buildBuiltInClassSignature(_a.OBJECT);
62
62
  Builtin.ARRAY_CLASS_SIGNATURE = _a.buildBuiltInClassSignature(_a.ARRAY);
63
63
  Builtin.SET_CLASS_SIGNATURE = _a.buildBuiltInClassSignature(_a.SET);
@@ -123,7 +123,19 @@ export declare class CfgBuilder {
123
123
  locals: Set<Local>;
124
124
  aliasTypeMap: Map<string, [AliasType, AliasTypeDeclaration]>;
125
125
  };
126
+ private linkBasicBlocks;
127
+ private rebuildBlocksInConditionalOperator;
128
+ private traverseAndRebuildConditionalOperator;
129
+ private findConditionalOperator;
130
+ private adjustSuccessorOfConditionalOperator;
131
+ private removeUnnecessaryBlocksInConditionalOperator;
132
+ private replaceTempResultcursively;
133
+ private isNewDefLocal;
134
+ private rebuildBlocksInLoop;
135
+ private doesPrevBlockBuilderContainLoop;
126
136
  private insertBeforeConditionBlockBuilder;
137
+ private findIteratorIdx;
138
+ private adjustIncrementorStmts;
127
139
  }
128
140
  export {};
129
141
  //# sourceMappingURL=CfgBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CfgBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/common/CfgBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,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