llama 0.1.0-beta.1

LLVM bindings
docs.rs failed to build llama-0.1.0-beta.1
Please check build logs and if you believe this is docs.rs' fault, report into this issue report.

llama provides easy-to-use LLVM bindings for Rust

Hello, world

use llama::*;

let ctx = Context::new();
let builder = ctx.builder();
let module = ctx.create_module("hello");

// Declare puts from libc
let puts = module.add_function("puts", &Type::i32().function(&[Type::i8().pointer()]));

// Declare a main function
let main_function = module.add_function(
"main",
&Type::i32().function(&[Type::i32(), Type::i8().pointer().pointer()]),
);

// Define the main function
builder.define_function(&ctx, &main_function, |builder, _| {
body!{
puts.call(values!("Hello, world!"));
Value::i32(0).ret();
}
});

assert!(module.verify().is_ok());
println!("{}", module);

let engine = module.create_execution_engine(0).unwrap();

// Get a pointer to the main function
let main = unsafe {
engine.get_function::<unsafe extern "C" fn(i32, *const *const i8) -> i32>("main")
};

// Call the main function
unsafe {
let x = main.unwrap();
assert!(x(0, std::ptr::null_mut()) == 0);
}