mirror of
https://github.com/yuzu-emu/sirit.git
synced 2024-11-22 11:35:38 +01:00
operand: Move operand_type initialization to constructor
This commit is contained in:
parent
53d572ae7d
commit
4c2981eab5
@ -9,9 +9,8 @@
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
LiteralNumber::LiteralNumber(u64 raw, bool is_32) : raw{raw}, is_32{is_32} {
|
||||
operand_type = OperandType::Number;
|
||||
}
|
||||
LiteralNumber::LiteralNumber(u64 raw, bool is_32)
|
||||
: Operand{OperandType::Number}, raw{raw}, is_32{is_32} {}
|
||||
|
||||
LiteralNumber::~LiteralNumber() = default;
|
||||
|
||||
@ -28,7 +27,7 @@ u16 LiteralNumber::GetWordCount() const {
|
||||
}
|
||||
|
||||
bool LiteralNumber::operator==(const Operand& other) const {
|
||||
if (operand_type == other.GetType()) {
|
||||
if (GetType() == other.GetType()) {
|
||||
const auto& o{static_cast<const LiteralNumber&>(other)};
|
||||
return o.raw == raw && o.is_32 == is_32;
|
||||
}
|
||||
|
@ -10,9 +10,8 @@
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
LiteralString::LiteralString(std::string string) : string{std::move(string)} {
|
||||
operand_type = OperandType::String;
|
||||
}
|
||||
LiteralString::LiteralString(std::string string)
|
||||
: Operand{OperandType::String}, string{std::move(string)} {}
|
||||
|
||||
LiteralString::~LiteralString() = default;
|
||||
|
||||
@ -25,7 +24,7 @@ u16 LiteralString::GetWordCount() const {
|
||||
}
|
||||
|
||||
bool LiteralString::operator==(const Operand& other) const {
|
||||
if (operand_type == other.GetType()) {
|
||||
if (GetType() == other.GetType()) {
|
||||
return static_cast<const LiteralString&>(other).string == string;
|
||||
}
|
||||
return false;
|
||||
|
@ -16,9 +16,7 @@
|
||||
namespace Sirit {
|
||||
|
||||
Op::Op(spv::Op opcode, std::optional<u32> id, Id result_type)
|
||||
: opcode(opcode), result_type(result_type), id(id) {
|
||||
operand_type = OperandType::Op;
|
||||
}
|
||||
: Operand{OperandType::Op}, opcode(opcode), result_type(result_type), id(id) {}
|
||||
|
||||
Op::~Op() = default;
|
||||
|
||||
@ -32,7 +30,7 @@ u16 Op::GetWordCount() const {
|
||||
}
|
||||
|
||||
bool Op::operator==(const Operand& other) const {
|
||||
if (operand_type != other.GetType()) {
|
||||
if (GetType() != other.GetType()) {
|
||||
return false;
|
||||
}
|
||||
const auto& op = static_cast<const Op&>(other);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
Operand::Operand() = default;
|
||||
Operand::Operand(OperandType operand_type) : operand_type{operand_type} {}
|
||||
|
||||
Operand::~Operand() = default;
|
||||
|
||||
|
@ -14,7 +14,7 @@ enum class OperandType { Invalid, Op, Number, String };
|
||||
|
||||
class Operand {
|
||||
public:
|
||||
Operand();
|
||||
explicit Operand(OperandType operand_type);
|
||||
virtual ~Operand();
|
||||
|
||||
virtual void Fetch(Stream& stream) const;
|
||||
@ -25,7 +25,7 @@ public:
|
||||
|
||||
OperandType GetType() const;
|
||||
|
||||
protected:
|
||||
private:
|
||||
OperandType operand_type{};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user