arkanalyzer 1.0.32 → 1.0.33
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 +1 -0
- package/lib/Config.d.ts +1 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +26 -18
- package/lib/Scene.d.ts +5 -5
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +21 -19
- package/lib/VFG/DVFG.d.ts.map +1 -1
- package/lib/VFG/builder/DVFGBuilder.d.ts +2 -2
- package/lib/VFG/builder/DVFGBuilder.d.ts.map +1 -1
- package/lib/VFG/builder/DVFGBuilder.js +15 -7
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +1 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +24 -8
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +3 -2
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +4 -3
- package/lib/callgraph/common/Statistics.d.ts +9 -7
- package/lib/callgraph/common/Statistics.d.ts.map +1 -1
- package/lib/callgraph/common/Statistics.js +18 -6
- package/lib/callgraph/model/CallGraph.d.ts +2 -0
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +14 -8
- 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 +9 -4
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Context.js +2 -2
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +4 -2
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PTAUtils.js +2 -3
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +27 -35
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +63 -46
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +12 -12
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.js +10 -6
- package/lib/core/base/Constant.js +2 -2
- package/lib/core/base/DefUseChain.d.ts.map +1 -1
- package/lib/core/base/DefUseChain.js +1 -1
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +3 -5
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +7 -2
- package/lib/core/base/Position.d.ts.map +1 -1
- package/lib/core/base/Position.js +1 -1
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +3 -1
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +1 -4
- package/lib/core/base/Trap.js +1 -1
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +2 -2
- package/lib/core/base/Value.d.ts +1 -1
- package/lib/core/base/Value.d.ts.map +1 -1
- package/lib/core/base/Value.js +1 -1
- package/lib/core/common/ArkError.js +1 -1
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +46 -36
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +295 -109
- package/lib/core/common/Builtin.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +10 -4
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +3 -12
- package/lib/core/common/ExprUseReplacer.js +1 -1
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +31 -20
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +5 -4
- package/lib/core/common/ModelUtils.d.ts +0 -1
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +36 -29
- package/lib/core/common/RefUseReplacer.js +1 -1
- package/lib/core/common/SdkUtils.d.ts +3 -0
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +29 -10
- package/lib/core/common/StmtDefReplacer.d.ts.map +1 -1
- package/lib/core/common/StmtDefReplacer.js +1 -1
- package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
- package/lib/core/common/StmtUseReplacer.js +1 -1
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +25 -17
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +1 -1
- package/lib/core/common/VisibleValue.d.ts.map +1 -1
- package/lib/core/common/VisibleValue.js +5 -5
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowProblem.js +1 -1
- package/lib/core/dataflow/DataflowResult.js +1 -1
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +5 -3
- package/lib/core/dataflow/Edge.d.ts.map +1 -1
- package/lib/core/dataflow/Edge.js +1 -1
- package/lib/core/dataflow/Fact.js +1 -1
- package/lib/core/dataflow/GenericDataFlow.js +5 -5
- package/lib/core/dataflow/ReachingDef.js +4 -4
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
- package/lib/core/dataflow/UndefinedVariable.js +17 -13
- package/lib/core/dataflow/Util.d.ts +4 -4
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +3 -5
- package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
- package/lib/core/graph/BaseExplicitGraph.js +1 -1
- package/lib/core/graph/BaseImplicitGraph.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +11 -7
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +10 -4
- package/lib/core/graph/DependsGraph.d.ts.map +1 -1
- package/lib/core/graph/DependsGraph.js +1 -1
- package/lib/core/graph/DominanceFinder.d.ts.map +1 -1
- package/lib/core/graph/DominanceFinder.js +4 -4
- package/lib/core/graph/DominanceTree.js +1 -1
- package/lib/core/graph/GraphTraits.js +1 -1
- package/lib/core/graph/Scc.js +2 -2
- package/lib/core/graph/ViewTree.js +1 -1
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +22 -13
- package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ConditionBuilder.js +21 -22
- package/lib/core/graph/builder/LoopBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/LoopBuilder.js +13 -10
- package/lib/core/graph/builder/SwitchBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/SwitchBuilder.js +7 -4
- package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/TrapBuilder.js +4 -3
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +18 -19
- package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
- package/lib/core/model/ArkBaseModel.js +8 -5
- package/lib/core/model/ArkBody.d.ts +1 -0
- package/lib/core/model/ArkBody.d.ts.map +1 -1
- package/lib/core/model/ArkBody.js +11 -1
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +3 -5
- package/lib/core/model/ArkExport.d.ts +4 -0
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +8 -1
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +2 -2
- package/lib/core/model/ArkFile.d.ts +1 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +21 -6
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +1 -1
- package/lib/core/model/ArkMetadata.d.ts.map +1 -1
- package/lib/core/model/ArkMetadata.js +1 -1
- package/lib/core/model/ArkMethod.d.ts +6 -5
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +27 -13
- package/lib/core/model/ArkNamespace.d.ts +1 -1
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +5 -6
- package/lib/core/model/ArkSignature.d.ts +4 -2
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +17 -17
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +15 -16
- package/lib/core/model/builder/ArkExportBuilder.d.ts +2 -1
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +17 -11
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +6 -7
- package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFileBuilder.js +22 -11
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkImportBuilder.js +13 -8
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +3 -3
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +7 -9
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkSignatureBuilder.js +1 -1
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/BodyBuilder.js +8 -5
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +15 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/save/ArkStream.d.ts.map +1 -1
- package/lib/save/ArkStream.js +1 -1
- package/lib/save/DotPrinter.d.ts.map +1 -1
- package/lib/save/DotPrinter.js +2 -4
- package/lib/save/GraphPrinter.d.ts.map +1 -1
- package/lib/save/GraphPrinter.js +2 -3
- package/lib/save/JsonPrinter.d.ts.map +1 -1
- package/lib/save/JsonPrinter.js +29 -29
- package/lib/save/Printer.js +1 -1
- package/lib/save/PrinterBuilder.d.ts.map +1 -1
- package/lib/save/PrinterBuilder.js +1 -1
- package/lib/save/ViewTreePrinter.d.ts.map +1 -1
- package/lib/save/ViewTreePrinter.js +3 -3
- package/lib/save/arkir/ArkIRClassPrinter.js +1 -1
- package/lib/save/arkir/ArkIRMethodPrinter.js +5 -5
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts.map +1 -1
- package/lib/save/arkir/ArkIRNamespacePrinter.js +2 -3
- package/lib/save/base/BasePrinter.js +2 -2
- package/lib/save/base/ExportPrinter.d.ts.map +1 -1
- package/lib/save/base/ExportPrinter.js +3 -6
- package/lib/save/base/ImportPrinter.d.ts.map +1 -1
- package/lib/save/base/ImportPrinter.js +2 -6
- package/lib/save/base/PrinterUtils.d.ts.map +1 -1
- package/lib/save/base/PrinterUtils.js +2 -4
- package/lib/save/serializeArkIR.d.ts.map +1 -1
- package/lib/save/serializeArkIR.js +2 -2
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +1 -3
- package/lib/save/source/SourceBody.d.ts.map +1 -1
- package/lib/save/source/SourceBody.js +1 -5
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +2 -3
- package/lib/save/source/SourceField.js +2 -2
- package/lib/save/source/SourceFilePrinter.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +5 -6
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +2 -3
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +9 -14
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +6 -10
- package/lib/transformer/FunctionTransformer.d.ts.map +1 -1
- package/lib/transformer/FunctionTransformer.js +1 -1
- package/lib/transformer/SceneTransformer.d.ts.map +1 -1
- package/lib/transformer/SceneTransformer.js +1 -1
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -1
- package/lib/transformer/StaticSingleAssignmentFormer.js +1 -1
- package/lib/transformer/Transformer.d.ts.map +1 -1
- package/lib/transformer/Transformer.js +2 -3
- package/lib/utils/AstTreeUtils.d.ts.map +1 -1
- package/lib/utils/AstTreeUtils.js +1 -1
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
- package/lib/utils/CfgStructualAnalysis.js +6 -18
- package/lib/utils/FileUtils.d.ts.map +1 -1
- package/lib/utils/FileUtils.js +7 -7
- package/lib/utils/SparseBitVector.d.ts.map +1 -1
- package/lib/utils/SparseBitVector.js +6 -5
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +9 -7
- package/lib/utils/crypto_utils.d.ts.map +1 -1
- package/lib/utils/crypto_utils.js +2 -2
- package/lib/utils/entryMethodUtils.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +18 -18
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/json5parser.d.ts.map +1 -1
- package/lib/utils/json5parser.js +1 -1
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/pathTransfer.d.ts +0 -1
- package/lib/utils/pathTransfer.d.ts.map +1 -1
- package/lib/utils/pathTransfer.js +2 -11
- package/package.json +2 -2
|
@@ -198,8 +198,7 @@ class ArkValueTransformer {
|
|
|
198
198
|
let { value, valueOriginalPositions, stmts } = this.tsNodeToValueAndStmts(node);
|
|
199
199
|
stmts.forEach(stmt => allStmts.push(stmt));
|
|
200
200
|
if (IRUtils_1.IRUtils.moreThanOneAddress(value)) {
|
|
201
|
-
({ value, valueOriginalPositions, stmts } =
|
|
202
|
-
this.arkIRTransformer.generateAssignStmtForValue(value, valueOriginalPositions));
|
|
201
|
+
({ value, valueOriginalPositions, stmts } = this.arkIRTransformer.generateAssignStmtForValue(value, valueOriginalPositions));
|
|
203
202
|
stmts.forEach(stmt => allStmts.push(stmt));
|
|
204
203
|
}
|
|
205
204
|
return { value, valueOriginalPositions, stmts: allStmts };
|
|
@@ -234,7 +233,11 @@ class ArkValueTransformer {
|
|
|
234
233
|
assignStmt.setOperandOriginalPositions([...resultLocalPosition, ...whenFalsePositions]);
|
|
235
234
|
stmts.push(assignStmt);
|
|
236
235
|
stmts.push(new ArkIRTransformer_1.DummyStmt(ArkIRTransformer_1.ArkIRTransformer.DUMMY_CONDITIONAL_OPERATOR_END_STMT + currConditionalOperatorIndex));
|
|
237
|
-
return {
|
|
236
|
+
return {
|
|
237
|
+
value: resultLocal,
|
|
238
|
+
valueOriginalPositions: resultLocalPosition,
|
|
239
|
+
stmts: stmts,
|
|
240
|
+
};
|
|
238
241
|
}
|
|
239
242
|
objectLiteralExpresionToValueAndStmts(objectLiteralExpression) {
|
|
240
243
|
const declaringArkClass = this.declaringMethod.getDeclaringArkClass();
|
|
@@ -263,7 +266,11 @@ class ArkValueTransformer {
|
|
|
263
266
|
const constructorInvokeStmt = new Stmt_1.ArkInvokeStmt(constructorInvokeExpr);
|
|
264
267
|
constructorInvokeStmt.setOperandOriginalPositions(constructorInvokeExprPositions);
|
|
265
268
|
stmts.push(constructorInvokeStmt);
|
|
266
|
-
return {
|
|
269
|
+
return {
|
|
270
|
+
value: newExprLocal,
|
|
271
|
+
valueOriginalPositions: newExprLocalPositions,
|
|
272
|
+
stmts: stmts,
|
|
273
|
+
};
|
|
267
274
|
}
|
|
268
275
|
generateSystemComponentStmt(componentName, args, argPositionsAllFlat, componentExpression, currStmts) {
|
|
269
276
|
const stmts = [...currStmts];
|
|
@@ -276,7 +283,11 @@ class ArkValueTransformer {
|
|
|
276
283
|
}
|
|
277
284
|
}
|
|
278
285
|
stmts.push(this.generateComponentPopStmts(componentName, componentExpressionPosition));
|
|
279
|
-
return {
|
|
286
|
+
return {
|
|
287
|
+
value: componentValue,
|
|
288
|
+
valueOriginalPositions: componentPositions,
|
|
289
|
+
stmts: stmts,
|
|
290
|
+
};
|
|
280
291
|
}
|
|
281
292
|
generateCustomViewStmt(componentName, args, argPositionsAllFlat, componentExpression, currStmts) {
|
|
282
293
|
const stmts = [...currStmts];
|
|
@@ -301,21 +312,29 @@ class ArkValueTransformer {
|
|
|
301
312
|
anonymous.pos = componentExpression.body.pos;
|
|
302
313
|
// @ts-expect-error: add end info for the created ArrowFunction
|
|
303
314
|
anonymous.end = componentExpression.body.end;
|
|
304
|
-
const { value: builderMethod, valueOriginalPositions: builderMethodPositions
|
|
315
|
+
const { value: builderMethod, valueOriginalPositions: builderMethodPositions } = this.callableNodeToValueAndStmts(anonymous);
|
|
305
316
|
createViewArgs.push(builderMethod);
|
|
306
317
|
createViewArgPositionsAll.push(builderMethodPositions);
|
|
307
318
|
}
|
|
308
319
|
const { value: componentValue, valueOriginalPositions: componentPositions, stmts: componentStmts, } = this.generateComponentCreationStmts(EtsConst_1.COMPONENT_CUSTOMVIEW, createViewArgs, componentExpressionPosition, createViewArgPositionsAll.flat());
|
|
309
320
|
componentStmts.forEach(stmt => stmts.push(stmt));
|
|
310
321
|
stmts.push(this.generateComponentPopStmts(EtsConst_1.COMPONENT_CUSTOMVIEW, componentExpressionPosition));
|
|
311
|
-
return {
|
|
322
|
+
return {
|
|
323
|
+
value: componentValue,
|
|
324
|
+
valueOriginalPositions: componentPositions,
|
|
325
|
+
stmts: stmts,
|
|
326
|
+
};
|
|
312
327
|
}
|
|
313
328
|
generateComponentCreationStmts(componentName, createArgs, componentExpressionPosition, createArgsPositionsAllFlat) {
|
|
314
329
|
const createMethodSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildMethodSignatureFromClassNameAndMethodName(componentName, EtsConst_1.COMPONENT_CREATE_FUNCTION);
|
|
315
330
|
const createInvokeExpr = new Expr_1.ArkStaticInvokeExpr(createMethodSignature, createArgs);
|
|
316
331
|
const createInvokeExprPositions = [componentExpressionPosition, ...createArgsPositionsAllFlat];
|
|
317
332
|
const { value: componentValue, valueOriginalPositions: componentPositions, stmts: componentStmts, } = this.arkIRTransformer.generateAssignStmtForValue(createInvokeExpr, createInvokeExprPositions);
|
|
318
|
-
return {
|
|
333
|
+
return {
|
|
334
|
+
value: componentValue,
|
|
335
|
+
valueOriginalPositions: componentPositions,
|
|
336
|
+
stmts: componentStmts,
|
|
337
|
+
};
|
|
319
338
|
}
|
|
320
339
|
generateComponentPopStmts(componentName, componentExpressionPosition) {
|
|
321
340
|
const popMethodSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildMethodSignatureFromClassNameAndMethodName(componentName, EtsConst_1.COMPONENT_POP_FUNCTION);
|
|
@@ -368,8 +387,11 @@ class ArkValueTransformer {
|
|
|
368
387
|
let placeholderPosition = [placeholderPositions[i]];
|
|
369
388
|
let placeholderStmts = [];
|
|
370
389
|
if (!(placeholderValue instanceof Local_1.Local)) {
|
|
371
|
-
({
|
|
372
|
-
|
|
390
|
+
({
|
|
391
|
+
value: placeholderValue,
|
|
392
|
+
valueOriginalPositions: placeholderPosition,
|
|
393
|
+
stmts: placeholderStmts,
|
|
394
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(placeholderValue, placeholderPosition));
|
|
373
395
|
}
|
|
374
396
|
placeholderStmts.forEach(stmt => newStmts.push(stmt));
|
|
375
397
|
const toStringExpr = new Expr_1.ArkInstanceInvokeExpr(placeholderValue, Builtin_1.Builtin.TO_STRING_METHOD_SIGNATURE, []);
|
|
@@ -379,7 +401,11 @@ class ArkValueTransformer {
|
|
|
379
401
|
placeholderStringLocalPositions.push(placeholderStringPositions[0]);
|
|
380
402
|
toStringStmts.forEach(stmt => newStmts.push(stmt));
|
|
381
403
|
}
|
|
382
|
-
return {
|
|
404
|
+
return {
|
|
405
|
+
placeholderStringLocals,
|
|
406
|
+
placeholderStringLocalPositions,
|
|
407
|
+
newStmts,
|
|
408
|
+
};
|
|
383
409
|
}
|
|
384
410
|
combineTemplateParts(stringTextValues, stringTextPositions, placeholderStringLocals, placeholderStringLocalPositions, currStmts) {
|
|
385
411
|
const templateParts = [];
|
|
@@ -402,17 +428,24 @@ class ArkValueTransformer {
|
|
|
402
428
|
for (let i = 1; i < templateParts.length; i++) {
|
|
403
429
|
const nextTemplatePartPosition = templatePartPositions[i];
|
|
404
430
|
const normalBinopExpr = new Expr_1.ArkNormalBinopExpr(currTemplateResult, templateParts[i], Expr_1.NormalBinaryOperator.Addition);
|
|
405
|
-
const normalBinopExprPositions = [
|
|
406
|
-
currTemplateResultPosition, nextTemplatePartPosition
|
|
431
|
+
const normalBinopExprPositions = [
|
|
432
|
+
Position_1.FullPosition.merge(currTemplateResultPosition, nextTemplatePartPosition),
|
|
433
|
+
currTemplateResultPosition,
|
|
434
|
+
nextTemplatePartPosition,
|
|
435
|
+
];
|
|
407
436
|
const { value: combinationValue, valueOriginalPositions: combinationValuePositions, stmts: combinationStmts, } = this.arkIRTransformer.generateAssignStmtForValue(normalBinopExpr, normalBinopExprPositions);
|
|
408
437
|
combinationStmts.forEach(stmt => finalStmts.push(stmt));
|
|
409
438
|
currTemplateResult = combinationValue;
|
|
410
439
|
currTemplateResultPosition = combinationValuePositions[0];
|
|
411
440
|
}
|
|
412
|
-
return {
|
|
441
|
+
return {
|
|
442
|
+
value: currTemplateResult,
|
|
443
|
+
valueOriginalPositions: [currTemplateResultPosition],
|
|
444
|
+
stmts: finalStmts,
|
|
445
|
+
};
|
|
413
446
|
}
|
|
414
447
|
taggedTemplateExpressionToValueAndStmts(taggedTemplateExpression) {
|
|
415
|
-
const { stmts, stringTextValues, placeholderValues, stringTextPositions, placeholderPositions
|
|
448
|
+
const { stmts, stringTextValues, placeholderValues, stringTextPositions, placeholderPositions } = this.collectTemplateValues(taggedTemplateExpression.template);
|
|
416
449
|
const stringTextBaseType = Type_1.StringType.getInstance();
|
|
417
450
|
const stringTextArrayLen = stringTextValues.length;
|
|
418
451
|
const stringTextArrayLenValue = ValueUtil_1.ValueUtil.getOrCreateNumberConst(stringTextArrayLen);
|
|
@@ -424,7 +457,8 @@ class ArkValueTransformer {
|
|
|
424
457
|
const placeholdersArrayLenPosition = Position_1.FullPosition.DEFAULT;
|
|
425
458
|
const { value: placeholdersLocal, valueOriginalPositions: placeholdersLocalPositions, stmts: placeholdersStmts, } = this.generateArrayExprAndStmts(placeholderBaseType, placeholdersArrayLenValue, placeholdersArrayLenPosition, placeholdersArrayLen, placeholderValues, placeholderPositions, templateObjectStmts, Position_1.FullPosition.DEFAULT, true);
|
|
426
459
|
const taggedFuncArgus = {
|
|
427
|
-
realGenericTypes: undefined,
|
|
460
|
+
realGenericTypes: undefined,
|
|
461
|
+
args: [templateObjectLocal, placeholdersLocal],
|
|
428
462
|
argPositions: [templateObjectLocalPositions[0], placeholdersLocalPositions[0]],
|
|
429
463
|
};
|
|
430
464
|
return this.generateInvokeValueAndStmts(taggedTemplateExpression.tag, taggedFuncArgus, placeholdersStmts, taggedTemplateExpression);
|
|
@@ -434,7 +468,8 @@ class ArkValueTransformer {
|
|
|
434
468
|
if (ts.isNoSubstitutionTemplateLiteral(templateLiteral)) {
|
|
435
469
|
const templateLiteralString = templateLiteral.getText(this.sourceFile);
|
|
436
470
|
return {
|
|
437
|
-
stmts: [],
|
|
471
|
+
stmts: [],
|
|
472
|
+
stringTextValues: [ValueUtil_1.ValueUtil.createStringConst(templateLiteralString)],
|
|
438
473
|
placeholderValues: [],
|
|
439
474
|
stringTextPositions: [Position_1.FullPosition.buildFromNode(templateLiteral, this.sourceFile)],
|
|
440
475
|
placeholderPositions: [],
|
|
@@ -446,11 +481,14 @@ class ArkValueTransformer {
|
|
|
446
481
|
const stringTextPositions = [Position_1.FullPosition.buildFromNode(head, this.sourceFile)];
|
|
447
482
|
const placeholderPositions = [];
|
|
448
483
|
for (const templateSpan of templateLiteral.templateSpans) {
|
|
449
|
-
let { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts
|
|
484
|
+
let { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts } = this.tsNodeToValueAndStmts(templateSpan.expression);
|
|
450
485
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
451
486
|
if (IRUtils_1.IRUtils.moreThanOneAddress(exprValue)) {
|
|
452
|
-
({
|
|
453
|
-
|
|
487
|
+
({
|
|
488
|
+
value: exprValue,
|
|
489
|
+
valueOriginalPositions: exprPositions,
|
|
490
|
+
stmts: exprStmts,
|
|
491
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(exprValue, exprPositions));
|
|
454
492
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
455
493
|
}
|
|
456
494
|
placeholderValues.push(exprValue);
|
|
@@ -458,7 +496,13 @@ class ArkValueTransformer {
|
|
|
458
496
|
stringTextPositions.push(Position_1.FullPosition.buildFromNode(templateSpan.literal, this.sourceFile));
|
|
459
497
|
stringTextValues.push(ValueUtil_1.ValueUtil.createStringConst(templateSpan.literal.rawText || ''));
|
|
460
498
|
}
|
|
461
|
-
return {
|
|
499
|
+
return {
|
|
500
|
+
stmts,
|
|
501
|
+
stringTextValues,
|
|
502
|
+
placeholderValues,
|
|
503
|
+
stringTextPositions,
|
|
504
|
+
placeholderPositions,
|
|
505
|
+
};
|
|
462
506
|
}
|
|
463
507
|
identifierToValueAndStmts(identifier, variableDefFlag = false) {
|
|
464
508
|
let identifierValue;
|
|
@@ -474,20 +518,30 @@ class ArkValueTransformer {
|
|
|
474
518
|
identifierValue = this.getOrCreateLocal(identifier.text);
|
|
475
519
|
}
|
|
476
520
|
}
|
|
477
|
-
return {
|
|
521
|
+
return {
|
|
522
|
+
value: identifierValue,
|
|
523
|
+
valueOriginalPositions: identifierPositions,
|
|
524
|
+
stmts: [],
|
|
525
|
+
};
|
|
478
526
|
}
|
|
479
527
|
propertyAccessExpressionToValue(propertyAccessExpression) {
|
|
480
528
|
const stmts = [];
|
|
481
|
-
let { value: baseValue, valueOriginalPositions: basePositions, stmts: baseStmts
|
|
529
|
+
let { value: baseValue, valueOriginalPositions: basePositions, stmts: baseStmts } = this.tsNodeToValueAndStmts(propertyAccessExpression.expression);
|
|
482
530
|
baseStmts.forEach(stmt => stmts.push(stmt));
|
|
483
531
|
if (IRUtils_1.IRUtils.moreThanOneAddress(baseValue)) {
|
|
484
|
-
({
|
|
485
|
-
|
|
532
|
+
({
|
|
533
|
+
value: baseValue,
|
|
534
|
+
valueOriginalPositions: basePositions,
|
|
535
|
+
stmts: baseStmts,
|
|
536
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(baseValue, basePositions));
|
|
486
537
|
baseStmts.forEach(stmt => stmts.push(stmt));
|
|
487
538
|
}
|
|
488
539
|
if (!(baseValue instanceof Local_1.Local)) {
|
|
489
|
-
({
|
|
490
|
-
|
|
540
|
+
({
|
|
541
|
+
value: baseValue,
|
|
542
|
+
valueOriginalPositions: basePositions,
|
|
543
|
+
stmts: baseStmts,
|
|
544
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(baseValue, basePositions));
|
|
491
545
|
baseStmts.forEach(stmt => stmts.push(stmt));
|
|
492
546
|
}
|
|
493
547
|
const fieldRefPositions = [Position_1.FullPosition.buildFromNode(propertyAccessExpression, this.sourceFile), ...basePositions];
|
|
@@ -496,7 +550,11 @@ class ArkValueTransformer {
|
|
|
496
550
|
this.locals.delete(baseValue.getName());
|
|
497
551
|
const fieldSignature = new ArkSignature_1.FieldSignature(propertyAccessExpression.name.getText(this.sourceFile), Builtin_1.Builtin.OBJECT_CLASS_SIGNATURE, Type_1.UnknownType.getInstance(), true);
|
|
498
552
|
const fieldRef = new Ref_1.ArkStaticFieldRef(fieldSignature);
|
|
499
|
-
return {
|
|
553
|
+
return {
|
|
554
|
+
value: fieldRef,
|
|
555
|
+
valueOriginalPositions: fieldRefPositions,
|
|
556
|
+
stmts: stmts,
|
|
557
|
+
};
|
|
500
558
|
}
|
|
501
559
|
let fieldSignature;
|
|
502
560
|
if (baseValue instanceof Local_1.Local && baseValue.getType() instanceof Type_1.ClassType) {
|
|
@@ -506,22 +564,32 @@ class ArkValueTransformer {
|
|
|
506
564
|
fieldSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildFieldSignatureFromFieldName(propertyAccessExpression.name.getText(this.sourceFile));
|
|
507
565
|
}
|
|
508
566
|
const fieldRef = new Ref_1.ArkInstanceFieldRef(baseValue, fieldSignature);
|
|
509
|
-
return {
|
|
567
|
+
return {
|
|
568
|
+
value: fieldRef,
|
|
569
|
+
valueOriginalPositions: fieldRefPositions,
|
|
570
|
+
stmts: stmts,
|
|
571
|
+
};
|
|
510
572
|
}
|
|
511
573
|
elementAccessExpressionToValueAndStmts(elementAccessExpression) {
|
|
512
574
|
const stmts = [];
|
|
513
575
|
let { value: baseValue, valueOriginalPositions: basePositions, stmts: baseStmts } = this.tsNodeToValueAndStmts(elementAccessExpression.expression);
|
|
514
576
|
baseStmts.forEach(stmt => stmts.push(stmt));
|
|
515
577
|
if (!(baseValue instanceof Local_1.Local)) {
|
|
516
|
-
({
|
|
517
|
-
|
|
578
|
+
({
|
|
579
|
+
value: baseValue,
|
|
580
|
+
valueOriginalPositions: basePositions,
|
|
581
|
+
stmts: baseStmts,
|
|
582
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(baseValue, basePositions));
|
|
518
583
|
baseStmts.forEach(stmt => stmts.push(stmt));
|
|
519
584
|
}
|
|
520
585
|
let { value: argumentValue, valueOriginalPositions: arguPositions, stmts: argumentStmts, } = this.tsNodeToValueAndStmts(elementAccessExpression.argumentExpression);
|
|
521
586
|
argumentStmts.forEach(stmt => stmts.push(stmt));
|
|
522
587
|
if (IRUtils_1.IRUtils.moreThanOneAddress(argumentValue)) {
|
|
523
|
-
({
|
|
524
|
-
|
|
588
|
+
({
|
|
589
|
+
value: argumentValue,
|
|
590
|
+
valueOriginalPositions: arguPositions,
|
|
591
|
+
stmts: argumentStmts,
|
|
592
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(argumentValue, arguPositions));
|
|
525
593
|
argumentStmts.forEach(stmt => stmts.push(stmt));
|
|
526
594
|
}
|
|
527
595
|
let elementAccessExpr;
|
|
@@ -534,9 +602,12 @@ class ArkValueTransformer {
|
|
|
534
602
|
elementAccessExpr = new Ref_1.ArkInstanceFieldRef(baseValue, fieldSignature);
|
|
535
603
|
}
|
|
536
604
|
// reserve positions for field name
|
|
537
|
-
const exprPositions = [Position_1.FullPosition.buildFromNode(elementAccessExpression, this.sourceFile), ...basePositions,
|
|
538
|
-
|
|
539
|
-
|
|
605
|
+
const exprPositions = [Position_1.FullPosition.buildFromNode(elementAccessExpression, this.sourceFile), ...basePositions, ...arguPositions];
|
|
606
|
+
return {
|
|
607
|
+
value: elementAccessExpr,
|
|
608
|
+
valueOriginalPositions: exprPositions,
|
|
609
|
+
stmts: stmts,
|
|
610
|
+
};
|
|
540
611
|
}
|
|
541
612
|
callExpressionToValueAndStmts(callExpression) {
|
|
542
613
|
const stmts = [];
|
|
@@ -545,7 +616,7 @@ class ArkValueTransformer {
|
|
|
545
616
|
}
|
|
546
617
|
generateInvokeValueAndStmts(functionNameNode, argus, currStmts, callExpression) {
|
|
547
618
|
const stmts = [...currStmts];
|
|
548
|
-
let { value: callerValue, valueOriginalPositions: callerPositions, stmts: callerStmts
|
|
619
|
+
let { value: callerValue, valueOriginalPositions: callerPositions, stmts: callerStmts } = this.tsNodeToValueAndStmts(functionNameNode);
|
|
549
620
|
callerStmts.forEach(stmt => stmts.push(stmt));
|
|
550
621
|
let invokeValue;
|
|
551
622
|
let invokeValuePositions = [Position_1.FullPosition.buildFromNode(callExpression, this.sourceFile)];
|
|
@@ -587,14 +658,21 @@ class ArkValueTransformer {
|
|
|
587
658
|
}
|
|
588
659
|
}
|
|
589
660
|
else {
|
|
590
|
-
({
|
|
591
|
-
|
|
661
|
+
({
|
|
662
|
+
value: callerValue,
|
|
663
|
+
valueOriginalPositions: callerPositions,
|
|
664
|
+
stmts: callerStmts,
|
|
665
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(callerValue, callerPositions));
|
|
592
666
|
callerStmts.forEach(stmt => stmts.push(stmt));
|
|
593
667
|
const methodSignature = ArkSignatureBuilder_1.ArkSignatureBuilder.buildMethodSignatureFromMethodName(callerValue.getName());
|
|
594
668
|
invokeValue = new Expr_1.ArkStaticInvokeExpr(methodSignature, args, realGenericTypes);
|
|
595
669
|
}
|
|
596
670
|
invokeValuePositions.push(...argPositions);
|
|
597
|
-
return {
|
|
671
|
+
return {
|
|
672
|
+
value: invokeValue,
|
|
673
|
+
valueOriginalPositions: invokeValuePositions,
|
|
674
|
+
stmts: stmts,
|
|
675
|
+
};
|
|
598
676
|
}
|
|
599
677
|
parseArgumentsOfCallExpression(currStmts, callExpression) {
|
|
600
678
|
let realGenericTypes;
|
|
@@ -612,7 +690,11 @@ class ArkValueTransformer {
|
|
|
612
690
|
}
|
|
613
691
|
}
|
|
614
692
|
const { args: args, argPositions: argPositions } = this.parseArguments(currStmts, callExpression.arguments, builderMethodIndexes);
|
|
615
|
-
return {
|
|
693
|
+
return {
|
|
694
|
+
realGenericTypes: realGenericTypes,
|
|
695
|
+
args: args,
|
|
696
|
+
argPositions: argPositions,
|
|
697
|
+
};
|
|
616
698
|
}
|
|
617
699
|
parseArguments(currStmts, argumentNodes, builderMethodIndexes) {
|
|
618
700
|
const args = [];
|
|
@@ -625,13 +707,16 @@ class ArkValueTransformer {
|
|
|
625
707
|
this.builderMethodContextFlag = true;
|
|
626
708
|
this.arkIRTransformer.setBuilderMethodContextFlag(true);
|
|
627
709
|
}
|
|
628
|
-
let { value: argValue, valueOriginalPositions: argPositionsSingle, stmts: argStmts
|
|
710
|
+
let { value: argValue, valueOriginalPositions: argPositionsSingle, stmts: argStmts } = this.tsNodeToValueAndStmts(argument);
|
|
629
711
|
this.builderMethodContextFlag = prevBuilderMethodContextFlag;
|
|
630
712
|
this.arkIRTransformer.setBuilderMethodContextFlag(prevBuilderMethodContextFlag);
|
|
631
713
|
argStmts.forEach(s => currStmts.push(s));
|
|
632
714
|
if (IRUtils_1.IRUtils.moreThanOneAddress(argValue)) {
|
|
633
|
-
({
|
|
634
|
-
|
|
715
|
+
({
|
|
716
|
+
value: argValue,
|
|
717
|
+
valueOriginalPositions: argPositionsSingle,
|
|
718
|
+
stmts: argStmts,
|
|
719
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(argValue, argPositionsSingle));
|
|
635
720
|
argStmts.forEach(s => currStmts.push(s));
|
|
636
721
|
}
|
|
637
722
|
args.push(argValue);
|
|
@@ -691,7 +776,11 @@ class ArkValueTransformer {
|
|
|
691
776
|
const invokeStmt = new Stmt_1.ArkInvokeStmt(instanceInvokeExpr);
|
|
692
777
|
invokeStmt.setOperandOriginalPositions(instanceInvokeExprPositions);
|
|
693
778
|
stmts.push(invokeStmt);
|
|
694
|
-
return {
|
|
779
|
+
return {
|
|
780
|
+
value: newLocal,
|
|
781
|
+
valueOriginalPositions: newLocalPositions,
|
|
782
|
+
stmts: stmts,
|
|
783
|
+
};
|
|
695
784
|
}
|
|
696
785
|
newArrayExpressionToValueAndStmts(newArrayExpression) {
|
|
697
786
|
let baseType = Type_1.UnknownType.getInstance();
|
|
@@ -707,9 +796,7 @@ class ArkValueTransformer {
|
|
|
707
796
|
let arrayLengthValue;
|
|
708
797
|
let arrayLength = -1;
|
|
709
798
|
let arrayLengthPosition = Position_1.FullPosition.DEFAULT;
|
|
710
|
-
if (
|
|
711
|
-
((argumentValues[0].getType() instanceof Type_1.NumberType) || argumentValues[0].getType() instanceof
|
|
712
|
-
Type_1.UnknownType)) {
|
|
799
|
+
if (argumentsLength === 1 && (argumentValues[0].getType() instanceof Type_1.NumberType || argumentValues[0].getType() instanceof Type_1.UnknownType)) {
|
|
713
800
|
arrayLengthValue = argumentValues[0];
|
|
714
801
|
arrayLengthPosition = argPositions[0];
|
|
715
802
|
}
|
|
@@ -718,7 +805,7 @@ class ArkValueTransformer {
|
|
|
718
805
|
arrayLength = argumentsLength;
|
|
719
806
|
}
|
|
720
807
|
if (baseType instanceof Type_1.UnknownType) {
|
|
721
|
-
if (
|
|
808
|
+
if (argumentsLength > 1 && !(argumentValues[0].getType() instanceof Type_1.UnknownType)) {
|
|
722
809
|
baseType = argumentValues[0].getType();
|
|
723
810
|
}
|
|
724
811
|
else {
|
|
@@ -735,11 +822,14 @@ class ArkValueTransformer {
|
|
|
735
822
|
const elementPositions = [];
|
|
736
823
|
const arrayLength = arrayLiteralExpression.elements.length;
|
|
737
824
|
for (const element of arrayLiteralExpression.elements) {
|
|
738
|
-
let { value: elementValue, valueOriginalPositions: elementPosition, stmts: elementStmts
|
|
825
|
+
let { value: elementValue, valueOriginalPositions: elementPosition, stmts: elementStmts } = this.tsNodeToValueAndStmts(element);
|
|
739
826
|
elementStmts.forEach(stmt => stmts.push(stmt));
|
|
740
827
|
if (IRUtils_1.IRUtils.moreThanOneAddress(elementValue)) {
|
|
741
|
-
({
|
|
742
|
-
|
|
828
|
+
({
|
|
829
|
+
value: elementValue,
|
|
830
|
+
valueOriginalPositions: elementPosition,
|
|
831
|
+
stmts: elementStmts,
|
|
832
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(elementValue, elementPosition));
|
|
743
833
|
elementStmts.forEach(stmt => stmts.push(stmt));
|
|
744
834
|
}
|
|
745
835
|
elementValues.push(elementValue);
|
|
@@ -770,15 +860,22 @@ class ArkValueTransformer {
|
|
|
770
860
|
assignStmt.setOperandOriginalPositions([...arrayRefPositions, initializerPositions[i]]);
|
|
771
861
|
stmts.push(assignStmt);
|
|
772
862
|
}
|
|
773
|
-
return {
|
|
863
|
+
return {
|
|
864
|
+
value: arrayLocal,
|
|
865
|
+
valueOriginalPositions: arrayLocalPositions,
|
|
866
|
+
stmts: stmts,
|
|
867
|
+
};
|
|
774
868
|
}
|
|
775
869
|
prefixUnaryExpressionToValueAndStmts(prefixUnaryExpression) {
|
|
776
870
|
const stmts = [];
|
|
777
|
-
let { value: operandValue, valueOriginalPositions: operandPositions, stmts: operandStmts
|
|
871
|
+
let { value: operandValue, valueOriginalPositions: operandPositions, stmts: operandStmts } = this.tsNodeToValueAndStmts(prefixUnaryExpression.operand);
|
|
778
872
|
operandStmts.forEach(stmt => stmts.push(stmt));
|
|
779
873
|
if (IRUtils_1.IRUtils.moreThanOneAddress(operandValue)) {
|
|
780
|
-
({
|
|
781
|
-
|
|
874
|
+
({
|
|
875
|
+
value: operandValue,
|
|
876
|
+
valueOriginalPositions: operandPositions,
|
|
877
|
+
stmts: operandStmts,
|
|
878
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(operandValue, operandPositions));
|
|
782
879
|
operandStmts.forEach(stmt => stmts.push(stmt));
|
|
783
880
|
}
|
|
784
881
|
const operatorToken = prefixUnaryExpression.operator;
|
|
@@ -790,10 +887,18 @@ class ArkValueTransformer {
|
|
|
790
887
|
const assignStmt = new Stmt_1.ArkAssignStmt(operandValue, binopExpr);
|
|
791
888
|
assignStmt.setOperandOriginalPositions([...operandPositions, ...exprPositions]);
|
|
792
889
|
stmts.push(assignStmt);
|
|
793
|
-
return {
|
|
890
|
+
return {
|
|
891
|
+
value: operandValue,
|
|
892
|
+
valueOriginalPositions: operandPositions,
|
|
893
|
+
stmts: stmts,
|
|
894
|
+
};
|
|
794
895
|
}
|
|
795
896
|
else if (operatorToken === ts.SyntaxKind.PlusToken) {
|
|
796
|
-
return {
|
|
897
|
+
return {
|
|
898
|
+
value: operandValue,
|
|
899
|
+
valueOriginalPositions: operandPositions,
|
|
900
|
+
stmts: stmts,
|
|
901
|
+
};
|
|
797
902
|
}
|
|
798
903
|
else {
|
|
799
904
|
let unopExpr;
|
|
@@ -806,16 +911,23 @@ class ArkValueTransformer {
|
|
|
806
911
|
unopExpr = ValueUtil_1.ValueUtil.getUndefinedConst();
|
|
807
912
|
exprPositions = [Position_1.FullPosition.DEFAULT];
|
|
808
913
|
}
|
|
809
|
-
return {
|
|
914
|
+
return {
|
|
915
|
+
value: unopExpr,
|
|
916
|
+
valueOriginalPositions: exprPositions,
|
|
917
|
+
stmts: stmts,
|
|
918
|
+
};
|
|
810
919
|
}
|
|
811
920
|
}
|
|
812
921
|
postfixUnaryExpressionToValueAndStmts(postfixUnaryExpression) {
|
|
813
922
|
const stmts = [];
|
|
814
|
-
let { value: operandValue, valueOriginalPositions: operandPositions, stmts: exprStmts
|
|
923
|
+
let { value: operandValue, valueOriginalPositions: operandPositions, stmts: exprStmts } = this.tsNodeToValueAndStmts(postfixUnaryExpression.operand);
|
|
815
924
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
816
925
|
if (IRUtils_1.IRUtils.moreThanOneAddress(operandValue)) {
|
|
817
|
-
({
|
|
818
|
-
|
|
926
|
+
({
|
|
927
|
+
value: operandValue,
|
|
928
|
+
valueOriginalPositions: operandPositions,
|
|
929
|
+
stmts: exprStmts,
|
|
930
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(operandValue, operandPositions));
|
|
819
931
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
820
932
|
}
|
|
821
933
|
let value;
|
|
@@ -834,45 +946,66 @@ class ArkValueTransformer {
|
|
|
834
946
|
value = ValueUtil_1.ValueUtil.getUndefinedConst();
|
|
835
947
|
exprPositions = [Position_1.FullPosition.DEFAULT];
|
|
836
948
|
}
|
|
837
|
-
return {
|
|
949
|
+
return {
|
|
950
|
+
value: value,
|
|
951
|
+
valueOriginalPositions: exprPositions,
|
|
952
|
+
stmts: stmts,
|
|
953
|
+
};
|
|
838
954
|
}
|
|
839
955
|
awaitExpressionToValueAndStmts(awaitExpression) {
|
|
840
956
|
const stmts = [];
|
|
841
|
-
let { value: promiseValue, valueOriginalPositions: promisePositions, stmts: promiseStmts
|
|
957
|
+
let { value: promiseValue, valueOriginalPositions: promisePositions, stmts: promiseStmts } = this.tsNodeToValueAndStmts(awaitExpression.expression);
|
|
842
958
|
promiseStmts.forEach(stmt => stmts.push(stmt));
|
|
843
959
|
if (IRUtils_1.IRUtils.moreThanOneAddress(promiseValue)) {
|
|
844
|
-
({
|
|
845
|
-
|
|
960
|
+
({
|
|
961
|
+
value: promiseValue,
|
|
962
|
+
valueOriginalPositions: promisePositions,
|
|
963
|
+
stmts: promiseStmts,
|
|
964
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(promiseValue, promisePositions));
|
|
846
965
|
promiseStmts.forEach(stmt => stmts.push(stmt));
|
|
847
966
|
}
|
|
848
967
|
const awaitExpr = new Expr_1.ArkAwaitExpr(promiseValue);
|
|
849
968
|
const awaitExprPositions = [Position_1.FullPosition.buildFromNode(awaitExpression, this.sourceFile), ...promisePositions];
|
|
850
|
-
return {
|
|
969
|
+
return {
|
|
970
|
+
value: awaitExpr,
|
|
971
|
+
valueOriginalPositions: awaitExprPositions,
|
|
972
|
+
stmts: stmts,
|
|
973
|
+
};
|
|
851
974
|
}
|
|
852
975
|
yieldExpressionToValueAndStmts(yieldExpression) {
|
|
853
976
|
let yieldValue = ValueUtil_1.ValueUtil.getUndefinedConst();
|
|
854
977
|
let yieldPositions = [Position_1.FullPosition.DEFAULT];
|
|
855
978
|
let stmts = [];
|
|
856
979
|
if (yieldExpression.expression) {
|
|
857
|
-
({ value: yieldValue, valueOriginalPositions: yieldPositions, stmts: stmts } =
|
|
858
|
-
this.tsNodeToValueAndStmts(yieldExpression.expression));
|
|
980
|
+
({ value: yieldValue, valueOriginalPositions: yieldPositions, stmts: stmts } = this.tsNodeToValueAndStmts(yieldExpression.expression));
|
|
859
981
|
}
|
|
860
982
|
const yieldExpr = new Expr_1.ArkYieldExpr(yieldValue);
|
|
861
983
|
const yieldExprPositions = [Position_1.FullPosition.buildFromNode(yieldExpression, this.sourceFile), ...yieldPositions];
|
|
862
|
-
return {
|
|
984
|
+
return {
|
|
985
|
+
value: yieldExpr,
|
|
986
|
+
valueOriginalPositions: yieldExprPositions,
|
|
987
|
+
stmts: stmts,
|
|
988
|
+
};
|
|
863
989
|
}
|
|
864
990
|
deleteExpressionToValueAndStmts(deleteExpression) {
|
|
865
991
|
const { value: exprValue, valueOriginalPositions: exprPositions, stmts: stmts } = this.tsNodeToValueAndStmts(deleteExpression.expression);
|
|
866
992
|
const deleteExpr = new Expr_1.ArkDeleteExpr(exprValue);
|
|
867
|
-
const deleteExprPositions = [Position_1.FullPosition.buildFromNode(deleteExpression, this.sourceFile),
|
|
868
|
-
|
|
869
|
-
|
|
993
|
+
const deleteExprPositions = [Position_1.FullPosition.buildFromNode(deleteExpression, this.sourceFile), ...exprPositions];
|
|
994
|
+
return {
|
|
995
|
+
value: deleteExpr,
|
|
996
|
+
valueOriginalPositions: deleteExprPositions,
|
|
997
|
+
stmts: stmts,
|
|
998
|
+
};
|
|
870
999
|
}
|
|
871
1000
|
voidExpressionToValueAndStmts(voidExpression) {
|
|
872
1001
|
const { value: exprValue, valueOriginalPositions: exprPositions, stmts: stmts } = this.tsNodeToValueAndStmts(voidExpression.expression);
|
|
873
1002
|
const { stmts: exprStmts } = this.arkIRTransformer.generateAssignStmtForValue(exprValue, exprPositions);
|
|
874
1003
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
875
|
-
return {
|
|
1004
|
+
return {
|
|
1005
|
+
value: ValueUtil_1.ValueUtil.getUndefinedConst(),
|
|
1006
|
+
valueOriginalPositions: [Position_1.FullPosition.DEFAULT],
|
|
1007
|
+
stmts: stmts,
|
|
1008
|
+
};
|
|
876
1009
|
}
|
|
877
1010
|
nonNullExpressionToValueAndStmts(nonNullExpression) {
|
|
878
1011
|
return this.tsNodeToValueAndStmts(nonNullExpression.expression);
|
|
@@ -881,29 +1014,44 @@ class ArkValueTransformer {
|
|
|
881
1014
|
return this.tsNodeToValueAndStmts(parenthesizedExpression.expression);
|
|
882
1015
|
}
|
|
883
1016
|
typeOfExpressionToValueAndStmts(typeOfExpression) {
|
|
884
|
-
const { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts
|
|
1017
|
+
const { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts } = this.tsNodeToValueAndStmts(typeOfExpression.expression);
|
|
885
1018
|
const typeOfExpr = new Expr_1.ArkTypeOfExpr(exprValue);
|
|
886
1019
|
const typeOfExprPositions = [Position_1.FullPosition.buildFromNode(typeOfExpression, this.sourceFile), ...exprPositions];
|
|
887
|
-
return {
|
|
1020
|
+
return {
|
|
1021
|
+
value: typeOfExpr,
|
|
1022
|
+
valueOriginalPositions: typeOfExprPositions,
|
|
1023
|
+
stmts: exprStmts,
|
|
1024
|
+
};
|
|
888
1025
|
}
|
|
889
1026
|
asExpressionToValueAndStmts(asExpression) {
|
|
890
1027
|
const stmts = [];
|
|
891
1028
|
let { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts } = this.tsNodeToValueAndStmts(asExpression.expression);
|
|
892
1029
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
893
1030
|
if (IRUtils_1.IRUtils.moreThanOneAddress(exprValue)) {
|
|
894
|
-
({
|
|
895
|
-
|
|
1031
|
+
({
|
|
1032
|
+
value: exprValue,
|
|
1033
|
+
valueOriginalPositions: exprPositions,
|
|
1034
|
+
stmts: exprStmts,
|
|
1035
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(exprValue, exprPositions));
|
|
896
1036
|
exprStmts.forEach(stmt => stmts.push(stmt));
|
|
897
1037
|
}
|
|
898
1038
|
const castExpr = new Expr_1.ArkCastExpr(exprValue, this.resolveTypeNode(asExpression.type));
|
|
899
1039
|
const castExprPositions = [Position_1.FullPosition.buildFromNode(asExpression, this.sourceFile), ...exprPositions];
|
|
900
|
-
return {
|
|
1040
|
+
return {
|
|
1041
|
+
value: castExpr,
|
|
1042
|
+
valueOriginalPositions: castExprPositions,
|
|
1043
|
+
stmts: stmts,
|
|
1044
|
+
};
|
|
901
1045
|
}
|
|
902
1046
|
typeAssertionToValueAndStmts(typeAssertion) {
|
|
903
|
-
const { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts
|
|
1047
|
+
const { value: exprValue, valueOriginalPositions: exprPositions, stmts: exprStmts } = this.tsNodeToValueAndStmts(typeAssertion.expression);
|
|
904
1048
|
const castExpr = new Expr_1.ArkCastExpr(exprValue, this.resolveTypeNode(typeAssertion.type));
|
|
905
1049
|
const castExprPositions = [Position_1.FullPosition.buildFromNode(typeAssertion, this.sourceFile), ...exprPositions];
|
|
906
|
-
return {
|
|
1050
|
+
return {
|
|
1051
|
+
value: castExpr,
|
|
1052
|
+
valueOriginalPositions: castExprPositions,
|
|
1053
|
+
stmts: exprStmts,
|
|
1054
|
+
};
|
|
907
1055
|
}
|
|
908
1056
|
variableDeclarationListToValueAndStmts(variableDeclarationList) {
|
|
909
1057
|
const stmts = [];
|
|
@@ -912,7 +1060,11 @@ class ArkValueTransformer {
|
|
|
912
1060
|
const { stmts: declaredStmts } = this.variableDeclarationToValueAndStmts(declaration, isConst);
|
|
913
1061
|
declaredStmts.forEach(s => stmts.push(s));
|
|
914
1062
|
}
|
|
915
|
-
return {
|
|
1063
|
+
return {
|
|
1064
|
+
value: ValueUtil_1.ValueUtil.getUndefinedConst(),
|
|
1065
|
+
valueOriginalPositions: [Position_1.FullPosition.DEFAULT],
|
|
1066
|
+
stmts: stmts,
|
|
1067
|
+
};
|
|
916
1068
|
}
|
|
917
1069
|
variableDeclarationToValueAndStmts(variableDeclaration, isConst, needRightOp = true) {
|
|
918
1070
|
const leftOpNode = variableDeclaration.name;
|
|
@@ -943,15 +1095,18 @@ class ArkValueTransformer {
|
|
|
943
1095
|
leftValue.setConstFlag(isConst);
|
|
944
1096
|
leftValue.setType(declarationType);
|
|
945
1097
|
}
|
|
946
|
-
if (leftValue.getType() instanceof Type_1.UnknownType &&
|
|
1098
|
+
if (leftValue.getType() instanceof Type_1.UnknownType &&
|
|
1099
|
+
!(rightValue.getType() instanceof Type_1.UnknownType) &&
|
|
947
1100
|
!(rightValue.getType() instanceof Type_1.UndefinedType)) {
|
|
948
1101
|
leftValue.setType(rightValue.getType());
|
|
949
1102
|
}
|
|
950
1103
|
}
|
|
951
1104
|
const assignStmt = new Stmt_1.ArkAssignStmt(leftValue, rightValue);
|
|
952
1105
|
assignStmt.setOperandOriginalPositions([...leftPositions, ...rightPositions]);
|
|
953
|
-
if (ts.isArrayBindingPattern(leftOpNode) ||
|
|
954
|
-
ts.
|
|
1106
|
+
if (ts.isArrayBindingPattern(leftOpNode) ||
|
|
1107
|
+
ts.isArrayLiteralExpression(leftOpNode) ||
|
|
1108
|
+
ts.isObjectBindingPattern(leftOpNode) ||
|
|
1109
|
+
ts.isObjectLiteralExpression(leftOpNode)) {
|
|
955
1110
|
rightStmts.forEach(stmt => stmts.push(stmt));
|
|
956
1111
|
stmts.push(assignStmt);
|
|
957
1112
|
leftStmts.forEach(stmt => stmts.push(stmt));
|
|
@@ -965,7 +1120,11 @@ class ArkValueTransformer {
|
|
|
965
1120
|
else {
|
|
966
1121
|
stmts = leftStmts;
|
|
967
1122
|
}
|
|
968
|
-
return {
|
|
1123
|
+
return {
|
|
1124
|
+
value: leftValue,
|
|
1125
|
+
valueOriginalPositions: leftPositions,
|
|
1126
|
+
stmts: stmts,
|
|
1127
|
+
};
|
|
969
1128
|
}
|
|
970
1129
|
assignmentRightOpToValueAndStmts(rightOpNode, leftValue) {
|
|
971
1130
|
let rightValue;
|
|
@@ -973,8 +1132,7 @@ class ArkValueTransformer {
|
|
|
973
1132
|
let tempRightStmts = [];
|
|
974
1133
|
const rightStmts = [];
|
|
975
1134
|
if (rightOpNode) {
|
|
976
|
-
({ value: rightValue, valueOriginalPositions: rightPositions, stmts: tempRightStmts } =
|
|
977
|
-
this.tsNodeToValueAndStmts(rightOpNode));
|
|
1135
|
+
({ value: rightValue, valueOriginalPositions: rightPositions, stmts: tempRightStmts } = this.tsNodeToValueAndStmts(rightOpNode));
|
|
978
1136
|
tempRightStmts.forEach(stmt => rightStmts.push(stmt));
|
|
979
1137
|
}
|
|
980
1138
|
else {
|
|
@@ -982,11 +1140,18 @@ class ArkValueTransformer {
|
|
|
982
1140
|
rightPositions = [Position_1.FullPosition.DEFAULT];
|
|
983
1141
|
}
|
|
984
1142
|
if (IRUtils_1.IRUtils.moreThanOneAddress(leftValue) && IRUtils_1.IRUtils.moreThanOneAddress(rightValue)) {
|
|
985
|
-
({
|
|
986
|
-
|
|
1143
|
+
({
|
|
1144
|
+
value: rightValue,
|
|
1145
|
+
valueOriginalPositions: rightPositions,
|
|
1146
|
+
stmts: tempRightStmts,
|
|
1147
|
+
} = this.arkIRTransformer.generateAssignStmtForValue(rightValue, rightPositions));
|
|
987
1148
|
tempRightStmts.forEach(stmt => rightStmts.push(stmt));
|
|
988
1149
|
}
|
|
989
|
-
return {
|
|
1150
|
+
return {
|
|
1151
|
+
value: rightValue,
|
|
1152
|
+
valueOriginalPositions: rightPositions,
|
|
1153
|
+
stmts: rightStmts,
|
|
1154
|
+
};
|
|
990
1155
|
}
|
|
991
1156
|
// In assignment patterns, the left operand will be an array literal expression
|
|
992
1157
|
arrayDestructuringToValueAndStmts(arrayDestructuring, isConst = false) {
|
|
@@ -1008,7 +1173,11 @@ class ArkValueTransformer {
|
|
|
1008
1173
|
stmts.push(assignStmt);
|
|
1009
1174
|
index++;
|
|
1010
1175
|
}
|
|
1011
|
-
return {
|
|
1176
|
+
return {
|
|
1177
|
+
value: arrayTempLocal,
|
|
1178
|
+
valueOriginalPositions: [leftOriginalPosition],
|
|
1179
|
+
stmts: stmts,
|
|
1180
|
+
};
|
|
1012
1181
|
}
|
|
1013
1182
|
// In assignment patterns, the left operand will be an object literal expression
|
|
1014
1183
|
objectDestructuringToValueAndStmts(objectDestructuring, isConst = false) {
|
|
@@ -1045,7 +1214,11 @@ class ArkValueTransformer {
|
|
|
1045
1214
|
assignStmt.setOperandOriginalPositions([targetLocalPosition, ...fieldRefPositions]);
|
|
1046
1215
|
stmts.push(assignStmt);
|
|
1047
1216
|
}
|
|
1048
|
-
return {
|
|
1217
|
+
return {
|
|
1218
|
+
value: objectTempLocal,
|
|
1219
|
+
valueOriginalPositions: [leftOriginalPosition],
|
|
1220
|
+
stmts: stmts,
|
|
1221
|
+
};
|
|
1049
1222
|
}
|
|
1050
1223
|
binaryExpressionToValueAndStmts(binaryExpression) {
|
|
1051
1224
|
const operatorToken = binaryExpression.operatorToken;
|
|
@@ -1060,16 +1233,20 @@ class ArkValueTransformer {
|
|
|
1060
1233
|
}
|
|
1061
1234
|
const stmts = [];
|
|
1062
1235
|
const binaryExpressionPosition = Position_1.FullPosition.buildFromNode(binaryExpression, this.sourceFile);
|
|
1063
|
-
const { value: opValue1, valueOriginalPositions: opPositions1, stmts: opStmts1
|
|
1236
|
+
const { value: opValue1, valueOriginalPositions: opPositions1, stmts: opStmts1 } = this.tsNodeToSingleAddressValueAndStmts(binaryExpression.left);
|
|
1064
1237
|
opStmts1.forEach(stmt => stmts.push(stmt));
|
|
1065
1238
|
if (operatorToken.kind === ts.SyntaxKind.InstanceOfKeyword) {
|
|
1066
1239
|
const instanceOfExpr = new Expr_1.ArkInstanceOfExpr(opValue1, new Type_1.UnclearReferenceType(binaryExpression.right.getText(this.sourceFile)));
|
|
1067
1240
|
const instanceOfExprPositions = [binaryExpressionPosition, ...opPositions1];
|
|
1068
1241
|
const { value: instanceofRes, valueOriginalPositions: instanceofPos, stmts: instanceofStmt, } = this.arkIRTransformer.generateAssignStmtForValue(instanceOfExpr, instanceOfExprPositions);
|
|
1069
1242
|
instanceofStmt.forEach(stmt => stmts.push(stmt));
|
|
1070
|
-
return {
|
|
1243
|
+
return {
|
|
1244
|
+
value: instanceofRes,
|
|
1245
|
+
valueOriginalPositions: instanceofPos,
|
|
1246
|
+
stmts: stmts,
|
|
1247
|
+
};
|
|
1071
1248
|
}
|
|
1072
|
-
const { value: opValue2, valueOriginalPositions: opPositions2, stmts: opStmts2
|
|
1249
|
+
const { value: opValue2, valueOriginalPositions: opPositions2, stmts: opStmts2 } = this.tsNodeToSingleAddressValueAndStmts(binaryExpression.right);
|
|
1073
1250
|
opStmts2.forEach(stmt => stmts.push(stmt));
|
|
1074
1251
|
let exprValue;
|
|
1075
1252
|
let exprValuePositions = [binaryExpressionPosition];
|
|
@@ -1092,13 +1269,17 @@ class ArkValueTransformer {
|
|
|
1092
1269
|
exprValuePositions.push(binaryExpressionPosition);
|
|
1093
1270
|
}
|
|
1094
1271
|
}
|
|
1095
|
-
return {
|
|
1272
|
+
return {
|
|
1273
|
+
value: exprValue,
|
|
1274
|
+
valueOriginalPositions: exprValuePositions,
|
|
1275
|
+
stmts: stmts,
|
|
1276
|
+
};
|
|
1096
1277
|
}
|
|
1097
1278
|
compoundAssignmentToValueAndStmts(binaryExpression) {
|
|
1098
1279
|
const stmts = [];
|
|
1099
|
-
let { value: leftValue, valueOriginalPositions: leftPositions, stmts: leftStmts
|
|
1280
|
+
let { value: leftValue, valueOriginalPositions: leftPositions, stmts: leftStmts } = this.tsNodeToValueAndStmts(binaryExpression.left);
|
|
1100
1281
|
leftStmts.forEach(stmt => stmts.push(stmt));
|
|
1101
|
-
let { value: rightValue, valueOriginalPositions: rightPositions, stmts: rightStmts
|
|
1282
|
+
let { value: rightValue, valueOriginalPositions: rightPositions, stmts: rightStmts } = this.tsNodeToValueAndStmts(binaryExpression.right);
|
|
1102
1283
|
rightStmts.forEach(stmt => stmts.push(stmt));
|
|
1103
1284
|
if (IRUtils_1.IRUtils.moreThanOneAddress(leftValue) && IRUtils_1.IRUtils.moreThanOneAddress(rightValue)) {
|
|
1104
1285
|
const { value: newRightValue, valueOriginalPositions: newRightPositions, stmts: rightStmts, } = this.arkIRTransformer.generateAssignStmtForValue(rightValue, rightPositions);
|
|
@@ -1122,7 +1303,11 @@ class ArkValueTransformer {
|
|
|
1122
1303
|
leftOpValue = ValueUtil_1.ValueUtil.getUndefinedConst();
|
|
1123
1304
|
leftOpPositions = [leftPositions[0]];
|
|
1124
1305
|
}
|
|
1125
|
-
return {
|
|
1306
|
+
return {
|
|
1307
|
+
value: leftOpValue,
|
|
1308
|
+
valueOriginalPositions: leftOpPositions,
|
|
1309
|
+
stmts: stmts,
|
|
1310
|
+
};
|
|
1126
1311
|
}
|
|
1127
1312
|
compoundAssignmentTokenToBinaryOperator(token) {
|
|
1128
1313
|
switch (token) {
|
|
@@ -1157,16 +1342,15 @@ class ArkValueTransformer {
|
|
|
1157
1342
|
case ts.SyntaxKind.BarBarEqualsToken:
|
|
1158
1343
|
return Expr_1.NormalBinaryOperator.LogicalOr;
|
|
1159
1344
|
default:
|
|
1160
|
-
;
|
|
1161
1345
|
}
|
|
1162
1346
|
return null;
|
|
1163
1347
|
}
|
|
1164
1348
|
conditionToValueAndStmts(condition) {
|
|
1165
1349
|
const stmts = [];
|
|
1166
|
-
let { value: conditionValue, valueOriginalPositions: conditionPositions, stmts: conditionStmts
|
|
1350
|
+
let { value: conditionValue, valueOriginalPositions: conditionPositions, stmts: conditionStmts } = this.tsNodeToValueAndStmts(condition);
|
|
1167
1351
|
conditionStmts.forEach(stmt => stmts.push(stmt));
|
|
1168
1352
|
let conditionExpr;
|
|
1169
|
-
if (
|
|
1353
|
+
if (conditionValue instanceof Expr_1.AbstractBinopExpr && this.isRelationalOperator(conditionValue.getOperator())) {
|
|
1170
1354
|
const operator = conditionValue.getOperator();
|
|
1171
1355
|
conditionExpr = new Expr_1.ArkConditionExpr(conditionValue.getOp1(), conditionValue.getOp2(), operator);
|
|
1172
1356
|
}
|
|
@@ -1182,7 +1366,11 @@ class ArkValueTransformer {
|
|
|
1182
1366
|
conditionExpr = new Expr_1.ArkConditionExpr(conditionValue, ValueUtil_1.ValueUtil.getOrCreateNumberConst(0), Expr_1.RelationalBinaryOperator.InEquality);
|
|
1183
1367
|
conditionPositions = [conditionPositions[0], ...conditionPositions, Position_1.FullPosition.DEFAULT];
|
|
1184
1368
|
}
|
|
1185
|
-
return {
|
|
1369
|
+
return {
|
|
1370
|
+
value: conditionExpr,
|
|
1371
|
+
valueOriginalPositions: conditionPositions,
|
|
1372
|
+
stmts: stmts,
|
|
1373
|
+
};
|
|
1186
1374
|
}
|
|
1187
1375
|
literalNodeToValueAndStmts(literalNode) {
|
|
1188
1376
|
const syntaxKind = literalNode.kind;
|
|
@@ -1244,14 +1432,14 @@ class ArkValueTransformer {
|
|
|
1244
1432
|
return tempLocal;
|
|
1245
1433
|
}
|
|
1246
1434
|
isRelationalOperator(operator) {
|
|
1247
|
-
return operator === Expr_1.RelationalBinaryOperator.LessThan ||
|
|
1435
|
+
return (operator === Expr_1.RelationalBinaryOperator.LessThan ||
|
|
1248
1436
|
operator === Expr_1.RelationalBinaryOperator.LessThanOrEqual ||
|
|
1249
1437
|
operator === Expr_1.RelationalBinaryOperator.GreaterThan ||
|
|
1250
1438
|
operator === Expr_1.RelationalBinaryOperator.GreaterThanOrEqual ||
|
|
1251
1439
|
operator === Expr_1.RelationalBinaryOperator.Equality ||
|
|
1252
1440
|
operator === Expr_1.RelationalBinaryOperator.InEquality ||
|
|
1253
1441
|
operator === Expr_1.RelationalBinaryOperator.StrictEquality ||
|
|
1254
|
-
operator === Expr_1.RelationalBinaryOperator.StrictInequality;
|
|
1442
|
+
operator === Expr_1.RelationalBinaryOperator.StrictInequality);
|
|
1255
1443
|
}
|
|
1256
1444
|
isLiteralNode(node) {
|
|
1257
1445
|
if (ts.isStringLiteral(node) ||
|
|
@@ -1391,7 +1579,6 @@ class ArkValueTransformer {
|
|
|
1391
1579
|
case ts.SyntaxKind.PrefixUnaryExpression:
|
|
1392
1580
|
return new Type_1.LiteralType(parseFloat(literal.getText(sourceFile)));
|
|
1393
1581
|
default:
|
|
1394
|
-
;
|
|
1395
1582
|
}
|
|
1396
1583
|
return new Type_1.LiteralType(literal.getText(sourceFile));
|
|
1397
1584
|
}
|
|
@@ -1415,8 +1602,7 @@ class ArkValueTransformer {
|
|
|
1415
1602
|
}
|
|
1416
1603
|
const unfoldTemplateTypeStrs = [];
|
|
1417
1604
|
for (const unfoldTemplateType of unfoldTemplateTypes) {
|
|
1418
|
-
unfoldTemplateTypeStrs.push(unfoldTemplateType instanceof Type_1.AliasType ? unfoldTemplateType.getOriginalType()
|
|
1419
|
-
.toString() : unfoldTemplateType.toString());
|
|
1605
|
+
unfoldTemplateTypeStrs.push(unfoldTemplateType instanceof Type_1.AliasType ? unfoldTemplateType.getOriginalType().toString() : unfoldTemplateType.toString());
|
|
1420
1606
|
}
|
|
1421
1607
|
const templateSpanString = templateSpan.literal.rawText || '';
|
|
1422
1608
|
for (const stringLiteral of stringLiterals) {
|