llama 0.1.0-beta

LLVM bindings
docs.rs failed to build llama-0.1.0-beta
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: llama-0.14.2

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);
}