From f63299d1634b2e1f3b1433b585a48f00eba365b4 Mon Sep 17 00:00:00 2001 From: changjiaxing Date: Thu, 28 Jul 2022 21:13:09 +0800 Subject: [PATCH] Add tonumeric instruction issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I5JGB3?from=project-issue Signed-off-by: changjiaxing --- ts2panda/src/compiler.ts | 2 +- ts2panda/src/pandagen.ts | 5 +++++ ts2panda/tests/expression/cmpBinary.test.ts | 4 ++-- ts2panda/tests/expression/postfixOperations.test.ts | 6 +++--- ts2panda/tests/lexenv.test.ts | 4 ++-- ts2panda/tests/statements/for.test.ts | 6 +++--- ts2panda/tests/watch_expression/addWatch.test.ts | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ts2panda/src/compiler.ts b/ts2panda/src/compiler.ts index 59cd1d776e..fcc8536e36 100644 --- a/ts2panda/src/compiler.ts +++ b/ts2panda/src/compiler.ts @@ -1210,7 +1210,7 @@ export class Compiler { // lvalue var = acc +/- 1 lref.setValue(); // acc = operand_old - pandaGen.toNumber(expr, operandReg); + pandaGen.toNumeric(expr, operandReg); pandaGen.freeTemps(operandReg); } diff --git a/ts2panda/src/pandagen.ts b/ts2panda/src/pandagen.ts index 0db314b6bd..65834994a5 100644 --- a/ts2panda/src/pandagen.ts +++ b/ts2panda/src/pandagen.ts @@ -163,6 +163,7 @@ import { EcmaSub2dyn, EcmaSuspendgenerator, EcmaTonumber, + EcmaTonumeric, EcmaTypeofdyn, EcmaXor2dyn, Imm, @@ -1002,6 +1003,10 @@ export class PandaGen { this.add(node, new EcmaTonumber(arg)); } + toNumeric(node: ts.Node, arg: VReg) { + this.add(node, new EcmaTonumeric(arg)); + } + createGeneratorObj(node: ts.Node, funcObj: VReg) { this.add(node, new EcmaCreategeneratorobj(funcObj)); } diff --git a/ts2panda/tests/expression/cmpBinary.test.ts b/ts2panda/tests/expression/cmpBinary.test.ts index 55ad541245..9d9c6dd635 100644 --- a/ts2panda/tests/expression/cmpBinary.test.ts +++ b/ts2panda/tests/expression/cmpBinary.test.ts @@ -33,7 +33,7 @@ import { EcmaStlettoglobalrecord, EcmaStricteqdyn, EcmaStrictnoteqdyn, - EcmaTonumber, + EcmaTonumeric, EcmaTryldglobalbyname, EcmaTrystglobalbyname, EcmaXor2dyn, @@ -295,7 +295,7 @@ describe("CmpBinaryOperators", function () { new StaDyn(lhs), new EcmaIncdyn(lhs), new EcmaTrystglobalbyname('x'), - new EcmaTonumber(variable), + new EcmaTonumeric(variable), new StaDyn(rhs), new EcmaTryldglobalbyname('x'), new EcmaTrystglobalbyname('x'), diff --git a/ts2panda/tests/expression/postfixOperations.test.ts b/ts2panda/tests/expression/postfixOperations.test.ts index 355649dc9c..fdd7ad6d1c 100644 --- a/ts2panda/tests/expression/postfixOperations.test.ts +++ b/ts2panda/tests/expression/postfixOperations.test.ts @@ -22,7 +22,7 @@ import { EcmaIncdyn, EcmaReturnundefined, EcmaStlettoglobalrecord, - EcmaTonumber, + EcmaTonumeric, EcmaTryldglobalbyname, EcmaTrystglobalbyname, Imm, @@ -45,7 +45,7 @@ describe("PostfixOperationsTest", function () { new StaDyn(temp), new EcmaIncdyn(temp), new EcmaTrystglobalbyname('i'), - new EcmaTonumber(i), + new EcmaTonumeric(i), new EcmaReturnundefined() ]; expect(checkInstructions(insns, expected)).to.be.true; @@ -62,7 +62,7 @@ describe("PostfixOperationsTest", function () { new StaDyn(temp), new EcmaDecdyn(temp), new EcmaTrystglobalbyname('i'), - new EcmaTonumber(i), + new EcmaTonumeric(i), new EcmaReturnundefined() ]; expect(checkInstructions(insns, expected)).to.be.true; diff --git a/ts2panda/tests/lexenv.test.ts b/ts2panda/tests/lexenv.test.ts index c54daff6d0..a2180a6a15 100644 --- a/ts2panda/tests/lexenv.test.ts +++ b/ts2panda/tests/lexenv.test.ts @@ -32,7 +32,7 @@ import { EcmaStlexvardyn, EcmaThrowconstassignment, EcmaThrowundefinedifhole, - EcmaTonumber, + EcmaTonumeric, EcmaTrystglobalbyname, Imm, IRNode, @@ -520,7 +520,7 @@ describe("lexenv-compile-testcase in lexenv.test.ts", function () { new EcmaIncdyn(new VReg()), new StaDyn(new VReg()), ...MicroStoreLexVar(1, 0), - new EcmaTonumber(new VReg()), // this is redundant load varialbe + new EcmaTonumeric(new VReg()), // this is redundant load varialbe ...MicroLoadLexVar(1, 0), new StaDyn(new VReg), ...MicroLoadLexVar(1, 1), diff --git a/ts2panda/tests/statements/for.test.ts b/ts2panda/tests/statements/for.test.ts index de8617947f..47bfce8d47 100644 --- a/ts2panda/tests/statements/for.test.ts +++ b/ts2panda/tests/statements/for.test.ts @@ -21,7 +21,7 @@ import { EcmaIncdyn, EcmaLessdyn, EcmaReturnundefined, - EcmaTonumber, + EcmaTonumeric, Imm, Jeqz, Jmp, @@ -228,7 +228,7 @@ describe("LoopWithLabelTests", function () { new StaDyn(j), new EcmaIncdyn(j), new StaDyn(j), - new EcmaTonumber(j), + new EcmaTonumeric(j), // jump to the loop header new Jmp(labelPre1), labelPost1, @@ -299,7 +299,7 @@ describe("LoopWithLabelTests", function () { new StaDyn(j), new EcmaIncdyn(j), new StaDyn(j), - new EcmaTonumber(j), + new EcmaTonumeric(j), // jump to the loop header new Jmp(labelPre1), labelPost1, diff --git a/ts2panda/tests/watch_expression/addWatch.test.ts b/ts2panda/tests/watch_expression/addWatch.test.ts index 7eacad422c..53ccee3695 100644 --- a/ts2panda/tests/watch_expression/addWatch.test.ts +++ b/ts2panda/tests/watch_expression/addWatch.test.ts @@ -48,7 +48,7 @@ import { EcmaStricteqdyn, EcmaSuspendgenerator, EcmaThrowdyn, - EcmaTonumber, + EcmaTonumeric, EcmaTypeofdyn, FldaiDyn, Imm, @@ -661,7 +661,7 @@ describe("WatchExpressions", function () { new LdaStr('a'), new StaDyn(new VReg()), new EcmaCallargs2dyn(new VReg(), new VReg(), new VReg()), - new EcmaTonumber(new VReg()), + new EcmaTonumeric(new VReg()), new ReturnDyn() ]; -- Gitee