From 96c51a9b889bf3ff7e17ccec70def036b1bc7940 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 21 Dec 2016 17:50:13 -0800 Subject: [PATCH] Move some more unsafe code into block --- src/compilation.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compilation.rs b/src/compilation.rs index fc3c264..58f08f3 100644 --- a/src/compilation.rs +++ b/src/compilation.rs @@ -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);