32 lines
827 B
C++
32 lines
827 B
C++
// 当前仅支持 void、i32 和 i32*。
|
|
#include "ir/IR.h"
|
|
|
|
namespace ir {
|
|
|
|
Type::Type(Kind k) : kind_(k) {}
|
|
|
|
const std::shared_ptr<Type>& Type::GetVoidType() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::Void);
|
|
return type;
|
|
}
|
|
|
|
const std::shared_ptr<Type>& Type::GetInt32Type() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::Int32);
|
|
return type;
|
|
}
|
|
|
|
const std::shared_ptr<Type>& Type::GetPtrInt32Type() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::PtrInt32);
|
|
return type;
|
|
}
|
|
|
|
Type::Kind Type::GetKind() const { return kind_; }
|
|
|
|
bool Type::IsVoid() const { return kind_ == Kind::Void; }
|
|
|
|
bool Type::IsInt32() const { return kind_ == Kind::Int32; }
|
|
|
|
bool Type::IsPtrInt32() const { return kind_ == Kind::PtrInt32; }
|
|
|
|
} // namespace ir
|