use super::*;
use super::c_api::*;
pub fn create_module<S>(name: S) -> Module where S: AsRef<str> {
Module {
module: Some(
unsafe {
LLVMModuleCreateWithNameInContext(into_c(name).as_ptr(), context())
}
)
}
}
pub fn create_builder() -> Builder {
Builder {
builder: Some(
unsafe {
LLVMCreateBuilderInContext(context())
}
)
}
}
pub fn const_struct(elements: Vec<Value>, packed: bool) -> Value {
Value {
value: unsafe {
LLVMConstStructInContext(context(), val_vec(&elements).as_mut_ptr(), elements.len() as u32, packed as i32)
}
}
}
pub fn const_string<S>(string: S, null_terminated: bool) -> Value where S: AsRef<str> {
Value {
value: unsafe {
let string = string.as_ref();
LLVMConstStringInContext(context(), into_c(string).as_ptr(), string.len() as u32, null_terminated as i32)
}
}
}