pub struct DataContext { /* private fields */ }
Expand description

This is to data objects what cranelift_codegen::Context is to functions.

Implementations§

source§

impl DataContext

source

pub fn new() -> Self

Allocate a new context.

source

pub fn clear(&mut self)

Clear all data structures in this context.

source

pub fn define_zeroinit(&mut self, size: usize)

Define a zero-initialized object with the given size.

source

pub fn define(&mut self, contents: Box<[u8]>)

Define an object initialized with the given contents.

TODO: Can we avoid a Box here?

source

pub fn set_segment_section(&mut self, seg: &str, sec: &str)

Override the segment/section for data, only supported on Object backend

source

pub fn set_align(&mut self, align: u64)

Set the alignment for data. The alignment must be a power of two.

source

pub fn import_function(&mut self, name: ModuleExtName) -> FuncRef

Declare an external function import.

Users of the Module API generally should call Module::declare_func_in_data instead, as it takes care of generating the appropriate ExternalName.

source

pub fn import_global_value(&mut self, name: ModuleExtName) -> GlobalValue

Declares a global value import.

TODO: Rename to import_data?

Users of the Module API generally should call Module::declare_data_in_data instead, as it takes care of generating the appropriate ExternalName.

source

pub fn write_function_addr(&mut self, offset: CodeOffset, func: FuncRef)

Write the address of func into the data at offset offset.

source

pub fn write_data_addr( &mut self, offset: CodeOffset, data: GlobalValue, addend: Addend )

Write the address of data into the data at offset offset.

source

pub fn description(&self) -> &DataDescription

Reference the initializer data.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.