Struct cranelift_module::DataContext
source · [−]pub struct DataContext { /* private fields */ }
Expand description
This is to data objects what cranelift_codegen::Context is to functions.
Implementations
sourceimpl DataContext
impl DataContext
sourcepub fn define_zeroinit(&mut self, size: usize)
pub fn define_zeroinit(&mut self, size: usize)
Define a zero-initialized object with the given size.
sourcepub fn define(&mut self, contents: Box<[u8]>)
pub fn define(&mut self, contents: Box<[u8]>)
Define an object initialized with the given contents.
TODO: Can we avoid a Box here?
sourcepub fn set_segment_section(&mut self, seg: &str, sec: &str)
pub fn set_segment_section(&mut self, seg: &str, sec: &str)
Override the segment/section for data, only supported on Object backend
sourcepub fn set_align(&mut self, align: u64)
pub fn set_align(&mut self, align: u64)
Set the alignment for data. The alignment must be a power of two.
sourcepub fn import_function(&mut self, name: ExternalName) -> FuncRef
pub fn import_function(&mut self, name: ExternalName) -> 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
.
sourcepub fn import_global_value(&mut self, name: ExternalName) -> GlobalValue
pub fn import_global_value(&mut self, name: ExternalName) -> 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
.
sourcepub fn write_function_addr(&mut self, offset: CodeOffset, func: FuncRef)
pub fn write_function_addr(&mut self, offset: CodeOffset, func: FuncRef)
Write the address of func
into the data at offset offset
.
sourcepub fn write_data_addr(
&mut self,
offset: CodeOffset,
data: GlobalValue,
addend: Addend
)
pub fn write_data_addr(
&mut self,
offset: CodeOffset,
data: GlobalValue,
addend: Addend
)
Write the address of data
into the data at offset offset
.
sourcepub fn description(&self) -> &DataDescription
pub fn description(&self) -> &DataDescription
Reference the initializer data.
Auto Trait Implementations
impl RefUnwindSafe for DataContext
impl Send for DataContext
impl Sync for DataContext
impl Unpin for DataContext
impl UnwindSafe for DataContext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more