mirror of
https://git.suyu.dev/suyu/sirit.git
synced 2025-12-24 00:06:22 +01:00
Add Op* prefix to instructions that have to be emited
This commit is contained in:
parent
ba3a3a74d7
commit
a08aeec982
15 changed files with 149 additions and 144 deletions
36
src/literal_number.cpp
Normal file
36
src/literal_number.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* Lesser General Public License version 2.1 or any later version.
|
||||
*/
|
||||
|
||||
#include "literal_number.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
LiteralNumber::LiteralNumber(std::type_index type) : type(type) {
|
||||
operand_type = OperandType::Number;
|
||||
}
|
||||
|
||||
LiteralNumber::~LiteralNumber() = default;
|
||||
|
||||
void LiteralNumber::Fetch(Stream& stream) const {
|
||||
if (is_32) {
|
||||
stream.Write(static_cast<u32>(raw));
|
||||
} else {
|
||||
stream.Write(raw);
|
||||
}
|
||||
}
|
||||
|
||||
u16 LiteralNumber::GetWordCount() const { return is_32 ? 1 : 2; }
|
||||
|
||||
bool LiteralNumber::operator==(const Operand& other) const {
|
||||
if (operand_type == other.GetType()) {
|
||||
const auto& o{dynamic_cast<const LiteralNumber&>(other)};
|
||||
return o.type == type && o.raw == raw;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
||||
Loading…
Add table
Add a link
Reference in a new issue