diff --git a/include/ChaiVM/utils/instr2Raw.hpp b/include/ChaiVM/utils/instr2Raw.hpp index 198a1da..80c97a2 100644 --- a/include/ChaiVM/utils/instr2Raw.hpp +++ b/include/ChaiVM/utils/instr2Raw.hpp @@ -17,8 +17,8 @@ chai::bytecode_t instr2Raw(interpreter::Operation op, chai::bytecode_t instr2Raw(interpreter::Operation op); -chai::bytecode_t inst2RawRI(interpreter::Operation op, - interpreter::RegisterId r1, - interpreter::Immidiate imm); +chai::bytecode_t instr2RawRI(interpreter::Operation op, + interpreter::RegisterId r1, + interpreter::Immidiate imm); } // namespace chai::utils diff --git a/include/frontend/assembler/assembler.hpp b/include/frontend/assembler/assembler.hpp index ad7b5e6..9c8f6cd 100644 --- a/include/frontend/assembler/assembler.hpp +++ b/include/frontend/assembler/assembler.hpp @@ -101,12 +101,16 @@ class Assembler final { chai::bytecode_t processI(chai::interpreter::Operation op) { lex_.nextLexem(); if (lex_.currentLexem()->type == AsmLex::INTEGER) { - auto val = static_cast(static_cast(lex_.currentLexem().get())->value); - auto imm = chaiFile_.addConst(std::make_unique(val)); + auto val = static_cast( + static_cast(lex_.currentLexem().get())->value); + auto imm = chaiFile_.addConst( + std::make_unique(val)); return chai::utils::instr2Raw(op, imm); } else if (lex_.currentLexem()->type == AsmLex::FLOAT) { - auto val = static_cast(lex_.currentLexem().get())->value; - auto imm = chaiFile_.addConst(std::make_unique(val)); + auto val = + static_cast(lex_.currentLexem().get())->value; + auto imm = chaiFile_.addConst( + std::make_unique(val)); return chai::utils::instr2Raw(op, imm); } else if (lex_.currentLexem()->type == AsmLex::STRING) { std::string str = @@ -124,12 +128,16 @@ class Assembler final { expectComma(); lex_.nextLexem(); if (lex_.currentLexem()->type == AsmLex::INTEGER) { - auto val = static_cast(static_cast(lex_.currentLexem().get())->value); - auto imm = chaiFile_.addConst(std::make_unique(val)); + auto val = static_cast( + static_cast(lex_.currentLexem().get())->value); + auto imm = chaiFile_.addConst( + std::make_unique(val)); return chai::utils::instr2RawRI(op, regId, imm); } else if (lex_.currentLexem()->type == AsmLex::FLOAT) { - auto val = static_cast(lex_.currentLexem().get())->value; - auto imm = chaiFile_.addConst(std::make_unique(val)); + auto val = + static_cast(lex_.currentLexem().get())->value; + auto imm = chaiFile_.addConst( + std::make_unique(val)); return chai::utils::instr2RawRI(op, regId, imm); } else if (lex_.currentLexem()->type == AsmLex::STRING) { std::string str = diff --git a/src/ChaiVM/utils/instr2Raw.cpp b/src/ChaiVM/utils/instr2Raw.cpp index f635224..473ebde 100644 --- a/src/ChaiVM/utils/instr2Raw.cpp +++ b/src/ChaiVM/utils/instr2Raw.cpp @@ -18,7 +18,7 @@ chai::bytecode_t instr2Raw(Operation op, Immidiate imm) { chai::bytecode_t instr2Raw(Operation op) { return (operation2opcode(op)); } -chai::bytecode_t inst2RawRI(Operation op, RegisterId r1, Immidiate imm) { +chai::bytecode_t instr2RawRI(Operation op, RegisterId r1, Immidiate imm) { return (operation2opcode(op)) | (static_cast(imm) << 16) | (r1 << 8); } diff --git a/test/ChaiVM/interpreter/executor-test-fixture.cpp b/test/ChaiVM/interpreter/executor-test-fixture.cpp index 173e380..5355c19 100644 --- a/test/ChaiVM/interpreter/executor-test-fixture.cpp +++ b/test/ChaiVM/interpreter/executor-test-fixture.cpp @@ -11,7 +11,7 @@ void ExecutorTest::loadRR(chai::interpreter::Operation op, void ExecutorTest::loadRI(chai::interpreter::Operation op, chai::interpreter::RegisterId reg1, chai::interpreter::Immidiate imm) { - chaiFile_.addInstr(chai::utils::inst2RawRI(op, reg1, imm)); + chaiFile_.addInstr(chai::utils::instr2RawRI(op, reg1, imm)); } int ExecutorTest::loadI(chai::interpreter::Operation op, diff --git a/test/ChaiVM/interpreter/executor_test.cpp b/test/ChaiVM/interpreter/executor_test.cpp index 3194986..4d5bbde 100644 --- a/test/ChaiVM/interpreter/executor_test.cpp +++ b/test/ChaiVM/interpreter/executor_test.cpp @@ -1,7 +1,6 @@ #include "executor-test-fixture.hpp" using chai::bytecode_t; -using chai::utils::inst2RawRI; using chai::utils::instr2Raw; using namespace chai::interpreter; using namespace chai::utils::fileformat; diff --git a/test/ChaiVM/interpreter/simple-programs-executor-test.cpp b/test/ChaiVM/interpreter/simple-programs-executor-test.cpp index 868deb4..9709c46 100644 --- a/test/ChaiVM/interpreter/simple-programs-executor-test.cpp +++ b/test/ChaiVM/interpreter/simple-programs-executor-test.cpp @@ -1,8 +1,8 @@ #include "executor-test-fixture.hpp" using chai::bytecode_t; -using chai::utils::inst2RawRI; using chai::utils::instr2Raw; +using chai::utils::instr2RawRI; using namespace chai::interpreter; using namespace chai::utils::fileformat; @@ -82,8 +82,8 @@ TEST_F(ExecutorTest, Factorial) { UINT16_MAX, "factorial", "(I)I", std::vector{ instr2Raw(Ldra, 7, 0), // val2 - inst2RawRI(If_icmpne, one, - static_cast(3 * sizeof(bytecode_t))), + instr2RawRI(If_icmpne, one, + static_cast(3 * sizeof(bytecode_t))), instr2Raw(Ldia, one), instr2Raw(Ret), instr2Raw(Star, 2, 0), instr2Raw(Subi, one), instr2Raw(Star, 7, 0), instr2Raw(Call, func_ref), instr2Raw(Mul, 2, 0),