// GlobalValue 占位实现: // - 具体的全局初始化器、打印和链接语义需要自行补全 #include "ir/IR.h" namespace ir { GlobalValue::GlobalValue(std::shared_ptr ty, std::string name) : User(std::move(ty), std::move(name)) {} GlobalVariable::GlobalVariable(std::shared_ptr 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& GlobalVariable::GetValueType() const { return value_type_; } ConstantValue* GlobalVariable::GetInitializer() const { return initializer_; } bool GlobalVariable::IsConst() const { return is_const_; } } // namespace ir