Trait llvm::ExecutionEngine [] [src]

pub trait ExecutionEngine<'a>: 'a + Sized + DisposeRef where LLVMExecutionEngineRef: From<&'a Self> {
    type Options: Copy;
    fn new(module: &'a Module, options: Self::Options) -> Result<CSemiBox<'a, Self>, CBox<str>>;

    fn add_module(&'a self, module: &'a Module) { ... }
    fn remove_module(&'a self, module: &'a Module) -> &'a Module { ... }
    fn run_static_constructors(&'a self) { ... }
    fn run_static_destructors(&'a self) { ... }
    fn find_function(&'a self, name: &str) -> Option<&'a Function> { ... }
    fn run_function(&'a self, function: &'a Function, args: &[GenericValue<'a>]) -> GenericValue<'a> { ... }
    unsafe fn get_global<T>(&'a self, global: &'a Value) -> &'a T { ... }
    unsafe fn find_global<T>(&'a self, name: &str) -> Option<&'a T> { ... }
}

An abstract interface for implementation execution of LLVM modules.

This is designed to support both interpreter and just-in-time (JIT) compiler implementations.

Associated Types

type Options: Copy

The options given to the engine upon creation.

Required Methods

fn new(module: &'a Module, options: Self::Options) -> Result<CSemiBox<'a, Self>, CBox<str>>

Create a new execution engine with the given Module and optiions, or return a description of the error.

Provided Methods

fn add_module(&'a self, module: &'a Module)

Add a module to the list of modules to interpret or compile.

fn remove_module(&'a self, module: &'a Module) -> &'a Module

Remove a module from the list of modules to interpret or compile.

fn run_static_constructors(&'a self)

Execute all of the static constructors for this program.

fn run_static_destructors(&'a self)

Execute all of the static destructors for this program.

fn find_function(&'a self, name: &str) -> Option<&'a Function>

Attempt to find a function with the name given, or None if there wasn't a function with that name.

fn run_function(&'a self, function: &'a Function, args: &[GenericValue<'a>]) -> GenericValue<'a>

Run function with the arguments given as `GenericValues, then return the result as one.

Note that if this engine is a JitEngine, it only supports a small fraction of combinations for the arguments and return value, so be warned.

To convert the arguments to GenericValues, you should use the GenericValueCast::to_generic method. To convert the return value from a GenericValue, you should use the GenericValueCast::from_generic method.

unsafe fn get_global<T>(&'a self, global: &'a Value) -> &'a T

Returns a pointer to the global value given.

This is marked as unsafe because the type cannot be guranteed to be the same as the type of the global value at this point.

unsafe fn find_global<T>(&'a self, name: &str) -> Option<&'a T>

Returns a pointer to the global value with the name given.

This is marked as unsafe because the type cannot be guranteed to be the same as the type of the global value at this point.

Implementors