Move some more unsafe code into block

This commit is contained in:
greg 2016-12-21 17:50:13 -08:00
parent 8528c912bd
commit 96c51a9b88
1 changed files with 6 additions and 3 deletions

View File

@ -12,27 +12,30 @@ mod LLVMWrap {
use self::llvm_sys::prelude::*;
use self::llvm_sys::core;
use std::ptr;
pub fn ContextCreate() -> LLVMContextRef {
unsafe {
core::LLVMContextCreate()
}
}
pub fn ModuleCreateWithName(name: &str) -> LLVMModuleRef {
unsafe {
let n = name.as_ptr() as *const _;
core::LLVMModuleCreateWithName(n)
}
}
pub fn CreateBuilderInContext(context: LLVMContextRef) -> LLVMBuilderRef {
unsafe {
core::LLVMCreateBuilderInContext(context)
}
}
}
pub fn compile_ast(ast: AST) {
println!("Compiling!");
let context = LLVMWrap::ContextCreate();
let module = LLVMWrap::ModuleCreateWithName("schala");
let builder = LLVMWrap::CreateBuilderInContext(context);
unsafe {
let builder = core::LLVMCreateBuilderInContext(context);
let void = core::LLVMVoidTypeInContext(context);
let function_type = core::LLVMFunctionType(void, ptr::null_mut(), 0, 0);