Skip to content

Commit

Permalink
Fix the build
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Sep 20, 2024
1 parent a18aa75 commit d0ee331
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
28 changes: 0 additions & 28 deletions tests/src/tests/tests.instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,4 @@ namespace zasm::tests
}
}

TEST(InstructionTests, TestVisit)
{
auto ins = zasm::Instruction() //
.setMnemonic(x86::Mnemonic::Mov) //
.addOperand(x86::rax) //
.addOperand(x86::rdx); //

// Test if the conversion from base to upper works.
auto testVisit = [](InstructionBase& base) {
return base.visit([](auto&& real) {
//
real.setMnemonic(x86::Mnemonic::Sub);
return real.getOperandCount();
});
};

auto detail = ins.getDetail(MachineMode::AMD64);
detail->addOperand(x86::rdx);

auto opCount1 = testVisit(ins);
ASSERT_EQ(ins.getMnemonic(), x86::Mnemonic::Sub);
ASSERT_EQ(opCount1, 2);

auto opCount2 = testVisit(*detail);
ASSERT_EQ(detail->getMnemonic(), x86::Mnemonic::Sub);
ASSERT_EQ(opCount2, 3);
}

} // namespace zasm::tests
16 changes: 0 additions & 16 deletions zasm/include/zasm/base/instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ namespace zasm
return *this;
}

template<typename TPred> auto visit(TPred&& fn) const
{
if (_type == Type::Detail)
return fn(static_cast<const InstructionDetail&>(*this));
else
return fn(static_cast<const Instruction&>(*this));
}

template<typename TPred> auto visit(TPred&& fn)
{
if (_type == Type::Detail)
return fn(static_cast<InstructionDetail&>(*this));
else
return fn(static_cast<Instruction&>(*this));
}

/// <summary>
/// Casts this object to T. T must be a type that inherits InstructionBase and has kInstrType.
/// Casting to the wrong type is UB.
Expand Down

0 comments on commit d0ee331

Please sign in to comment.