From 506dc4b9d050a73d7615fc8365792b04c7eaa399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sun, 12 May 2024 17:30:20 +0300 Subject: [PATCH] Remove redundant namespace use --- src/tests/tests/tests.assembler.cpp | 2 +- src/tests/tests/tests.instruction.cpp | 4 +- src/tests/tests/tests.program.cpp | 96 ++++++++++++------------- src/tests/tests/tests.serialization.cpp | 18 ++--- 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/tests/tests/tests.assembler.cpp b/src/tests/tests/tests.assembler.cpp index a5cf532..29f60c1 100644 --- a/src/tests/tests/tests.assembler.cpp +++ b/src/tests/tests/tests.assembler.cpp @@ -32,7 +32,7 @@ namespace zasm::tests x86::Assembler assembler(program); - zasm::Label label01; + Label label01; ASSERT_EQ(label01.isValid(), false); ASSERT_EQ(assembler.bind(label01), ErrorCode::InvalidLabel); } diff --git a/src/tests/tests/tests.instruction.cpp b/src/tests/tests/tests.instruction.cpp index d056448..65a7553 100644 --- a/src/tests/tests/tests.instruction.cpp +++ b/src/tests/tests/tests.instruction.cpp @@ -43,7 +43,7 @@ namespace zasm::tests x86::Assembler assembler(program); - assembler.mov(x86::eax, zasm::Imm(2)); + assembler.mov(x86::eax, Imm(2)); auto* instrNode = assembler.getCursor(); @@ -51,7 +51,7 @@ namespace zasm::tests Instruction instr = assembler.getCursor()->get(); // Modify operand. - instr.setOperand(1, zasm::Imm(1)); + instr.setOperand(1, Imm(1)); // Emit modified ASSERT_EQ(assembler.emit(instr), ErrorCode::None); diff --git a/src/tests/tests/tests.program.cpp b/src/tests/tests/tests.program.cpp index f1bdc4c..3b0972f 100644 --- a/src/tests/tests/tests.program.cpp +++ b/src/tests/tests/tests.program.cpp @@ -68,7 +68,7 @@ namespace zasm::tests { ASSERT_NE(node, nullptr); - const auto& instr = node->get(); + const auto& instr = node->get(); const auto& imm = instr.getOperand<1, Imm>(); ASSERT_EQ(imm.value(), i); @@ -104,7 +104,7 @@ namespace zasm::tests { ASSERT_NE(node, nullptr); - const auto& instr = node->get(); + const auto& instr = node->get(); const auto& imm = instr.getOperand<1, Imm>(); ASSERT_EQ(imm.value(), i); @@ -170,7 +170,7 @@ namespace zasm::tests { ASSERT_NE(node, nullptr); - const auto& instr = node->get(); + const auto& instr = node->get(); const auto& imm = instr.getOperand<1, Imm>(); ASSERT_EQ(imm.value(), NumberOrder[i]); @@ -206,7 +206,7 @@ namespace zasm::tests { ASSERT_NE(node, nullptr); - const auto& instr = node->get(); + const auto& instr = node->get(); const auto& imm = instr.getOperand<1, Imm>(); ASSERT_EQ(imm.value(), NumberOrder[i]); @@ -223,22 +223,22 @@ namespace zasm::tests x86::Assembler assembler(program); - ASSERT_EQ(assembler.mov(x86::eax, x86::ebx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.xor_(x86::ebx, x86::edx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.add(x86::eax, Imm(1)), zasm::ErrorCode::None); - ASSERT_EQ(assembler.not_(x86::eax), zasm::ErrorCode::None); - ASSERT_EQ(assembler.xor_(x86::eax, Imm(1)), zasm::ErrorCode::None); + ASSERT_EQ(assembler.mov(x86::eax, x86::ebx), ErrorCode::None); + ASSERT_EQ(assembler.xor_(x86::ebx, x86::edx), ErrorCode::None); + ASSERT_EQ(assembler.add(x86::eax, Imm(1)), ErrorCode::None); + ASSERT_EQ(assembler.not_(x86::eax), ErrorCode::None); + ASSERT_EQ(assembler.xor_(x86::eax, Imm(1)), ErrorCode::None); auto labelFoo = assembler.createLabel("foo"); - ASSERT_EQ(labelFoo.getId(), zasm::Label::Id{ 0 }); + ASSERT_EQ(labelFoo.getId(), Label::Id{ 0 }); ASSERT_EQ(labelFoo.isValid(), true); - ASSERT_EQ(assembler.bind(labelFoo), zasm::ErrorCode::None); - ASSERT_EQ(assembler.mov(x86::dword_ptr(x86::rip, labelFoo), x86::eax), zasm::ErrorCode::None); + ASSERT_EQ(assembler.bind(labelFoo), ErrorCode::None); + ASSERT_EQ(assembler.mov(x86::dword_ptr(x86::rip, labelFoo), x86::eax), ErrorCode::None); ASSERT_EQ(program.size(), 7); Serializer serializer; - ASSERT_EQ(serializer.serialize(program, 0x400000), zasm::ErrorCode::None); + ASSERT_EQ(serializer.serialize(program, 0x400000), ErrorCode::None); const std::array expected = { 0x89, 0xd8, 0x31, 0xd3, 0x83, 0xc0, 0x01, 0xf7, 0xd0, 0x83, 0xf0, 0x01, 0x89, 0x05, 0xfa, 0xff, 0xff, 0xff, @@ -269,41 +269,41 @@ namespace zasm::tests { x86::Assembler assembler(program); - ASSERT_EQ(assembler.push(x86::rax), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::rcx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::rdx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::rbx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::rbp), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::rsi), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::rdi), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r8), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r9), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r10), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r11), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r12), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r13), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r14), zasm::ErrorCode::None); - ASSERT_EQ(assembler.push(x86::r15), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pushfq(), zasm::ErrorCode::None); - - ASSERT_EQ(assembler.popfq(), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r15), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r14), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r13), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r12), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r11), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r10), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r9), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::r8), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rdi), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rsi), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rbp), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rbx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rdx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rcx), zasm::ErrorCode::None); - ASSERT_EQ(assembler.pop(x86::rax), zasm::ErrorCode::None); - - ASSERT_EQ(serializer.serialize(program, address), zasm::ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rax), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rcx), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rdx), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rbx), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rbp), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rsi), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::rdi), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r8), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r9), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r10), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r11), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r12), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r13), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r14), ErrorCode::None); + ASSERT_EQ(assembler.push(x86::r15), ErrorCode::None); + ASSERT_EQ(assembler.pushfq(), ErrorCode::None); + + ASSERT_EQ(assembler.popfq(), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r15), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r14), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r13), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r12), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r11), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r10), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r9), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::r8), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rdi), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rsi), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rbp), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rbx), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rdx), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rcx), ErrorCode::None); + ASSERT_EQ(assembler.pop(x86::rax), ErrorCode::None); + + ASSERT_EQ(serializer.serialize(program, address), ErrorCode::None); address += 0x10; ASSERT_NE(serializer.getCodeSize(), 0); diff --git a/src/tests/tests/tests.serialization.cpp b/src/tests/tests/tests.serialization.cpp index d9495c4..73dfd38 100644 --- a/src/tests/tests/tests.serialization.cpp +++ b/src/tests/tests/tests.serialization.cpp @@ -1040,12 +1040,12 @@ namespace zasm::tests TEST(SerializationTests, SerializeDecodedSwapNodes) { - zasm::Program program(zasm::MachineMode::I386); - std::vector tails = {}; + Program program(MachineMode::I386); + std::vector tails = {}; { - zasm::x86::Assembler a(program); - zasm::Decoder decoder(zasm::MachineMode::I386); + x86::Assembler a(program); + Decoder decoder(MachineMode::I386); const std::array raw_data = { 0xB8, 0x00, 0x10, 0x40, 0x00, // mov eax, [blabla] @@ -1071,15 +1071,15 @@ namespace zasm::tests auto bind_node = program.bindLabel(label); program.moveBefore(tails[4], *bind_node); - tails[3]->getIf()->setOperand(0, label); + tails[3]->getIf()->setOperand(0, label); - zasm::x86::Assembler a(program); + x86::Assembler a(program); a.setCursor(tails[4]); - a.xor_(zasm::x86::eax, zasm::x86::eax); + a.xor_(x86::eax, x86::eax); - zasm::Serializer serializer{}; + Serializer serializer{}; auto r = serializer.serialize(program, 0x406000); - ASSERT_EQ(r, zasm::ErrorCode::None); + ASSERT_EQ(r, ErrorCode::None); const std::array expected = { 0xB8, 0x00, 0x10, 0x40, 0x00, 0x83, 0xF8, 0x00, 0x90, 0xEB, 0x00, 0xC3, 0x31, 0xC0 };