refactor(ir): ir改为更标准的实现
This commit is contained in:
@@ -7,32 +7,11 @@ namespace ir {
|
||||
|
||||
Context::~Context() = default;
|
||||
|
||||
const std::shared_ptr<Type>& Context::Void() {
|
||||
if (!void_) {
|
||||
void_ = std::make_shared<Type>(Type::Kind::Void);
|
||||
}
|
||||
return void_;
|
||||
}
|
||||
|
||||
const std::shared_ptr<Type>& Context::Int32() {
|
||||
if (!int32_) {
|
||||
int32_ = std::make_shared<Type>(Type::Kind::Int32);
|
||||
}
|
||||
return int32_;
|
||||
}
|
||||
|
||||
const std::shared_ptr<Type>& Context::PtrInt32() {
|
||||
if (!ptr_i32_) {
|
||||
ptr_i32_ = std::make_shared<Type>(Type::Kind::PtrInt32);
|
||||
}
|
||||
return ptr_i32_;
|
||||
}
|
||||
|
||||
ConstantInt* Context::GetConstInt(int v) {
|
||||
auto it = const_ints_.find(v);
|
||||
if (it != const_ints_.end()) return it->second.get();
|
||||
auto inserted =
|
||||
const_ints_.emplace(v, std::make_unique<ConstantInt>(Int32(), v)).first;
|
||||
const_ints_.emplace(v, std::make_unique<ConstantInt>(Type::GetInt32Type(), v)).first;
|
||||
return inserted->second.get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user