diff --git a/src/literal_number.cpp b/src/literal_number.cpp index f204dd3..2203150 100644 --- a/src/literal_number.cpp +++ b/src/literal_number.cpp @@ -9,7 +9,7 @@ namespace Sirit { -LiteralNumber::LiteralNumber(std::type_index type) : type(type) { +LiteralNumber::LiteralNumber(u64 raw, bool is_32) : raw{raw}, is_32{is_32} { operand_type = OperandType::Number; } @@ -30,7 +30,7 @@ u16 LiteralNumber::GetWordCount() const { bool LiteralNumber::operator==(const Operand& other) const { if (operand_type == other.GetType()) { const auto& o{static_cast(other)}; - return o.type == type && o.raw == raw; + return o.raw == raw && o.is_32 == is_32; } return false; } diff --git a/src/literal_number.h b/src/literal_number.h index a053057..a72718a 100644 --- a/src/literal_number.h +++ b/src/literal_number.h @@ -8,7 +8,6 @@ #include #include -#include #include "operand.h" #include "stream.h" @@ -16,7 +15,7 @@ namespace Sirit { class LiteralNumber : public Operand { public: - LiteralNumber(std::type_index type); + explicit LiteralNumber(u64 raw, bool is_32); ~LiteralNumber() override; void Fetch(Stream& stream) const override; @@ -28,16 +27,14 @@ public: static std::unique_ptr Create(T value) { static_assert(sizeof(T) == 4 || sizeof(T) == 8); - auto number = std::make_unique(std::type_index(typeid(T))); - number->is_32 = sizeof(T) == 4; - std::memcpy(&number->raw, &value, sizeof(T)); - return number; + u64 raw{}; + std::memcpy(&raw, &value, sizeof(T)); + return std::make_unique(raw, sizeof(T) == 4); } private: - std::type_index type; - bool is_32{}; u64 raw{}; + bool is_32{}; }; } // namespace Sirit