forked from NUDT-compiler/nudt-compiler-cpp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
978 B
31 lines
978 B
// GlobalValue 占位实现:
|
|
// - 具体的全局初始化器、打印和链接语义需要自行补全
|
|
|
|
#include "ir/IR.h"
|
|
|
|
namespace ir {
|
|
|
|
GlobalValue::GlobalValue(std::shared_ptr<Type> ty, std::string name)
|
|
: User(std::move(ty), std::move(name)) {}
|
|
|
|
GlobalVariable::GlobalVariable(std::shared_ptr<Type> value_ty, std::string name,
|
|
ConstantValue* init, bool is_const)
|
|
: GlobalValue(Type::GetPointerType(value_ty), std::move(name)),
|
|
value_type_(std::move(value_ty)),
|
|
initializer_(init),
|
|
is_const_(is_const) {
|
|
if (!value_type_) {
|
|
throw std::runtime_error("GlobalVariable 缺少 value type");
|
|
}
|
|
}
|
|
|
|
const std::shared_ptr<Type>& GlobalVariable::GetValueType() const {
|
|
return value_type_;
|
|
}
|
|
|
|
ConstantValue* GlobalVariable::GetInitializer() const { return initializer_; }
|
|
|
|
bool GlobalVariable::IsConst() const { return is_const_; }
|
|
|
|
} // namespace ir
|