use crate::core::context::ContextRef;
use crate::core::values::ValueRef;
use crate::{CString, GetRef};
use llvm_sys::core::LLVMAppendBasicBlockInContext;
use llvm_sys::prelude::LLVMBasicBlockRef;
pub struct BasicBlockRef(LLVMBasicBlockRef);
impl GetRef for BasicBlockRef {
type RawRef = LLVMBasicBlockRef;
fn get_ref(&self) -> Self::RawRef {
self.0
}
}
impl BasicBlockRef {
#[must_use]
pub const fn get(&self) -> LLVMBasicBlockRef {
self.0
}
#[must_use]
pub fn append_in_context(context: &ContextRef, function: &ValueRef, name: &str) -> Self {
unsafe {
let c_name = CString::from(name);
Self(LLVMAppendBasicBlockInContext(
**context,
**function,
c_name.as_ptr(),
))
}
}
}