From f96a238da4de5d9bae7b9d57a8fb6359123f23de Mon Sep 17 00:00:00 2001 From: "Mr.UNIX" Date: Fri, 8 Mar 2024 10:23:23 +0100 Subject: [PATCH] refactor: remove unused StoreLocal instruction --- src/bytecode/instructions/StoreLocal.h | 27 ---------------------- tests/bytecode/compiler/to_string_test.cpp | 8 ------- 2 files changed, 35 deletions(-) delete mode 100644 src/bytecode/instructions/StoreLocal.h diff --git a/src/bytecode/instructions/StoreLocal.h b/src/bytecode/instructions/StoreLocal.h deleted file mode 100644 index 3bfa294..0000000 --- a/src/bytecode/instructions/StoreLocal.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "Instruction.h" -#include "bytecode/objects/Register.h" -#include - -namespace Bytecode { - class StoreLocal final : public Instruction { - size_t reg; - - public: - explicit StoreLocal(size_t reg) : reg(reg) { - type = InstructionType::StoreLocal; - } - - void execute(VM *vm) override { - vm->call_stack.setLocal(0, vm->program_stack.pop()); - } - [[nodiscard]] std::string toString() const override { - return "StoreLocal $r" + std::to_string(reg); - } - bool operator==(const Instruction &instruction) const override { - return instruction.type == type && - dynamic_cast(&instruction)->reg == reg; - } - }; -}// namespace Bytecode diff --git a/tests/bytecode/compiler/to_string_test.cpp b/tests/bytecode/compiler/to_string_test.cpp index 04a2ea2..2d6daae 100644 --- a/tests/bytecode/compiler/to_string_test.cpp +++ b/tests/bytecode/compiler/to_string_test.cpp @@ -6,7 +6,6 @@ #include "bytecode/instructions/LoadLiteral.h" #include "bytecode/instructions/LoadLocal.h" #include "bytecode/instructions/Multiply.h" -#include "bytecode/instructions/StoreLocal.h" #include "bytecode/instructions/Subtract.h" #include @@ -54,13 +53,6 @@ TEST(instruction_to_string, load_literal) { EXPECT_EQ(expected_result, actual_result); } -TEST(instruction_to_string, store) { - const auto instruction = StoreLocal(12); - const auto expected_result = "StoreLocal $r12"; - const auto actual_result = instruction.toString(); - EXPECT_EQ(expected_result, actual_result); -} - TEST(instruction_to_string, equals) { const auto instruction = Equals(); const auto expected_result = "Equals";