fix(dev): 统一 IR/MIR 异常前缀
This commit is contained in:
@@ -3,13 +3,15 @@
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "utils/Log.h"
|
||||
|
||||
namespace mir {
|
||||
namespace {
|
||||
|
||||
const FrameSlot& GetFrameSlot(const MachineFunction& function,
|
||||
const Operand& operand) {
|
||||
if (operand.kind() != Operand::Kind::FrameIndex) {
|
||||
throw std::runtime_error("期望 FrameIndex 操作数");
|
||||
throw std::runtime_error(FormatError("mir", "期望 FrameIndex 操作数"));
|
||||
}
|
||||
return function.frame_slot(operand.frame_index());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include "utils/Log.h"
|
||||
|
||||
namespace mir {
|
||||
|
||||
MachineFunction::MachineFunction(std::string name)
|
||||
@@ -16,14 +18,14 @@ int MachineFunction::CreateFrameIndex(int size) {
|
||||
|
||||
FrameSlot& MachineFunction::frame_slot(int index) {
|
||||
if (index < 0 || index >= static_cast<int>(frame_slots_.size())) {
|
||||
throw std::runtime_error("非法 FrameIndex");
|
||||
throw std::runtime_error(FormatError("mir", "非法 FrameIndex"));
|
||||
}
|
||||
return frame_slots_[index];
|
||||
}
|
||||
|
||||
const FrameSlot& MachineFunction::frame_slot(int index) const {
|
||||
if (index < 0 || index >= static_cast<int>(frame_slots_.size())) {
|
||||
throw std::runtime_error("非法 FrameIndex");
|
||||
throw std::runtime_error(FormatError("mir", "非法 FrameIndex"));
|
||||
}
|
||||
return frame_slots_[index];
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "utils/Log.h"
|
||||
|
||||
namespace mir {
|
||||
|
||||
const char* PhysRegName(PhysReg reg) {
|
||||
@@ -19,7 +21,7 @@ const char* PhysRegName(PhysReg reg) {
|
||||
case PhysReg::SP:
|
||||
return "sp";
|
||||
}
|
||||
throw std::runtime_error("未知物理寄存器");
|
||||
throw std::runtime_error(FormatError("mir", "未知物理寄存器"));
|
||||
}
|
||||
|
||||
} // namespace mir
|
||||
|
||||
Reference in New Issue
Block a user