Struct cranelift_wasm::DummyEnvironment
source · pub struct DummyEnvironment {
pub info: DummyModuleInfo,
pub trans: FuncTranslator,
pub func_bytecode_sizes: Vec<usize>,
pub module_name: Option<String>,
/* private fields */
}
Expand description
This ModuleEnvironment
implementation is a “naïve” one, doing essentially nothing and
emitting placeholders when forced to. Don’t try to execute code translated for this
environment, essentially here for translation debug purposes.
Fields§
§info: DummyModuleInfo
Module information.
trans: FuncTranslator
Function translation.
func_bytecode_sizes: Vec<usize>
Vector of wasm bytecode size for each function.
module_name: Option<String>
Name of the module from the wasm file.
Implementations§
source§impl DummyEnvironment
impl DummyEnvironment
sourcepub fn new(config: TargetFrontendConfig) -> Self
pub fn new(config: TargetFrontendConfig) -> Self
Creates a new DummyEnvironment
instance.
sourcepub fn func_env(&self) -> DummyFuncEnvironment<'_>
pub fn func_env(&self) -> DummyFuncEnvironment<'_>
Return a DummyFuncEnvironment
for translating functions within this
DummyEnvironment
.
sourcepub fn get_func_type(&self, func_index: FuncIndex) -> TypeIndex
pub fn get_func_type(&self, func_index: FuncIndex) -> TypeIndex
Get the type for the function at the given index.
sourcepub fn get_num_func_imports(&self) -> usize
pub fn get_num_func_imports(&self) -> usize
Return the number of imported functions within this DummyEnvironment
.
sourcepub fn get_func_name(&self, func_index: FuncIndex) -> Option<&str>
pub fn get_func_name(&self, func_index: FuncIndex) -> Option<&str>
Return the name of the function, if a name for the function with the corresponding index exists.
sourcepub fn test_expected_reachability(&mut self, reachability: Vec<(bool, bool)>)
pub fn test_expected_reachability(&mut self, reachability: Vec<(bool, bool)>)
Test reachability bits before and after every opcode during translation, as provided by the
FuncTranslationState
. This is generally used only for unit tests. This is applied to
every function in the module (so is likely only useful for test modules with one function).
Trait Implementations§
source§impl<'data> ModuleEnvironment<'data> for DummyEnvironment
impl<'data> ModuleEnvironment<'data> for DummyEnvironment
source§fn declare_type_func(&mut self, wasm: WasmFuncType) -> WasmResult<()>
fn declare_type_func(&mut self, wasm: WasmFuncType) -> WasmResult<()>
source§fn declare_func_import(
&mut self,
index: TypeIndex,
module: &'data str,
field: &'data str,
) -> WasmResult<()>
fn declare_func_import( &mut self, index: TypeIndex, module: &'data str, field: &'data str, ) -> WasmResult<()>
source§fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>
fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>
source§fn declare_global(
&mut self,
global: Global,
_init: GlobalInit,
) -> WasmResult<()>
fn declare_global( &mut self, global: Global, _init: GlobalInit, ) -> WasmResult<()>
source§fn declare_global_import(
&mut self,
global: Global,
module: &'data str,
field: &'data str,
) -> WasmResult<()>
fn declare_global_import( &mut self, global: Global, module: &'data str, field: &'data str, ) -> WasmResult<()>
source§fn declare_table(&mut self, table: Table) -> WasmResult<()>
fn declare_table(&mut self, table: Table) -> WasmResult<()>
source§fn declare_table_import(
&mut self,
table: Table,
module: &'data str,
field: &'data str,
) -> WasmResult<()>
fn declare_table_import( &mut self, table: Table, module: &'data str, field: &'data str, ) -> WasmResult<()>
source§fn declare_table_elements(
&mut self,
_table_index: TableIndex,
_base: Option<GlobalIndex>,
_offset: u32,
_elements: Box<[FuncIndex]>,
) -> WasmResult<()>
fn declare_table_elements( &mut self, _table_index: TableIndex, _base: Option<GlobalIndex>, _offset: u32, _elements: Box<[FuncIndex]>, ) -> WasmResult<()>
source§fn declare_passive_element(
&mut self,
_elem_index: ElemIndex,
_segments: Box<[FuncIndex]>,
) -> WasmResult<()>
fn declare_passive_element( &mut self, _elem_index: ElemIndex, _segments: Box<[FuncIndex]>, ) -> WasmResult<()>
source§fn declare_passive_data(
&mut self,
_elem_index: DataIndex,
_segments: &'data [u8],
) -> WasmResult<()>
fn declare_passive_data( &mut self, _elem_index: DataIndex, _segments: &'data [u8], ) -> WasmResult<()>
source§fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>
source§fn declare_memory_import(
&mut self,
memory: Memory,
module: &'data str,
field: &'data str,
) -> WasmResult<()>
fn declare_memory_import( &mut self, memory: Memory, module: &'data str, field: &'data str, ) -> WasmResult<()>
source§fn declare_data_initialization(
&mut self,
_memory_index: MemoryIndex,
_base: Option<GlobalIndex>,
_offset: u64,
_data: &'data [u8],
) -> WasmResult<()>
fn declare_data_initialization( &mut self, _memory_index: MemoryIndex, _base: Option<GlobalIndex>, _offset: u64, _data: &'data [u8], ) -> WasmResult<()>
source§fn declare_func_export(
&mut self,
func_index: FuncIndex,
name: &'data str,
) -> WasmResult<()>
fn declare_func_export( &mut self, func_index: FuncIndex, name: &'data str, ) -> WasmResult<()>
source§fn declare_table_export(
&mut self,
table_index: TableIndex,
name: &'data str,
) -> WasmResult<()>
fn declare_table_export( &mut self, table_index: TableIndex, name: &'data str, ) -> WasmResult<()>
source§fn declare_memory_export(
&mut self,
memory_index: MemoryIndex,
name: &'data str,
) -> WasmResult<()>
fn declare_memory_export( &mut self, memory_index: MemoryIndex, name: &'data str, ) -> WasmResult<()>
source§fn declare_global_export(
&mut self,
global_index: GlobalIndex,
name: &'data str,
) -> WasmResult<()>
fn declare_global_export( &mut self, global_index: GlobalIndex, name: &'data str, ) -> WasmResult<()>
source§fn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>
fn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>
source§fn define_function_body(
&mut self,
validator: FuncValidator<ValidatorResources>,
body: FunctionBody<'data>,
) -> WasmResult<()>
fn define_function_body( &mut self, validator: FuncValidator<ValidatorResources>, body: FunctionBody<'data>, ) -> WasmResult<()>
source§fn declare_module_name(&mut self, name: &'data str)
fn declare_module_name(&mut self, name: &'data str)
source§fn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str)
fn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str)
source§fn wasm_features(&self) -> WasmFeatures
fn wasm_features(&self) -> WasmFeatures
source§fn reserve_types(&mut self, _num: u32) -> WasmResult<()>
fn reserve_types(&mut self, _num: u32) -> WasmResult<()>
source§fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>
fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>
source§fn reserve_imports(&mut self, _num: u32) -> WasmResult<()>
fn reserve_imports(&mut self, _num: u32) -> WasmResult<()>
source§fn declare_tag_import(
&mut self,
tag: Tag,
module: &'data str,
field: &'data str,
) -> WasmResult<()>
fn declare_tag_import( &mut self, tag: Tag, module: &'data str, field: &'data str, ) -> WasmResult<()>
source§fn finish_imports(&mut self) -> WasmResult<()>
fn finish_imports(&mut self) -> WasmResult<()>
source§fn reserve_func_types(&mut self, _num: u32) -> WasmResult<()>
fn reserve_func_types(&mut self, _num: u32) -> WasmResult<()>
source§fn reserve_tables(&mut self, _num: u32) -> WasmResult<()>
fn reserve_tables(&mut self, _num: u32) -> WasmResult<()>
source§fn reserve_memories(&mut self, _num: u32) -> WasmResult<()>
fn reserve_memories(&mut self, _num: u32) -> WasmResult<()>
source§fn declare_tag(&mut self, tag: Tag) -> WasmResult<()>
fn declare_tag(&mut self, tag: Tag) -> WasmResult<()>
source§fn reserve_globals(&mut self, _num: u32) -> WasmResult<()>
fn reserve_globals(&mut self, _num: u32) -> WasmResult<()>
source§fn reserve_exports(&mut self, _num: u32) -> WasmResult<()>
fn reserve_exports(&mut self, _num: u32) -> WasmResult<()>
source§fn declare_tag_export(
&mut self,
tag_index: TagIndex,
name: &'data str,
) -> WasmResult<()>
fn declare_tag_export( &mut self, tag_index: TagIndex, name: &'data str, ) -> WasmResult<()>
source§fn finish_exports(&mut self) -> WasmResult<()>
fn finish_exports(&mut self) -> WasmResult<()>
source§fn reserve_table_elements(&mut self, _num: u32) -> WasmResult<()>
fn reserve_table_elements(&mut self, _num: u32) -> WasmResult<()>
source§fn declare_elements(&mut self, elements: Box<[FuncIndex]>) -> WasmResult<()>
fn declare_elements(&mut self, elements: Box<[FuncIndex]>) -> WasmResult<()>
source§fn reserve_passive_data(&mut self, count: u32) -> WasmResult<()>
fn reserve_passive_data(&mut self, count: u32) -> WasmResult<()>
source§fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64)
fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64)
source§fn reserve_data_initializers(&mut self, _num: u32) -> WasmResult<()>
fn reserve_data_initializers(&mut self, _num: u32) -> WasmResult<()>
source§fn declare_local_name(
&mut self,
_func_index: FuncIndex,
_local_index: u32,
_name: &'data str,
)
fn declare_local_name( &mut self, _func_index: FuncIndex, _local_index: u32, _name: &'data str, )
source§fn custom_section(
&mut self,
_name: &'data str,
_data: &'data [u8],
) -> WasmResult<()>
fn custom_section( &mut self, _name: &'data str, _data: &'data [u8], ) -> WasmResult<()>
source§impl TargetEnvironment for DummyEnvironment
impl TargetEnvironment for DummyEnvironment
source§fn target_config(&self) -> TargetFrontendConfig
fn target_config(&self) -> TargetFrontendConfig
source§fn heap_access_spectre_mitigation(&self) -> bool
fn heap_access_spectre_mitigation(&self) -> bool
source§fn pointer_type(&self) -> Type
fn pointer_type(&self) -> Type
source§fn pointer_bytes(&self) -> u8
fn pointer_bytes(&self) -> u8
source§fn reference_type(&self, ty: WasmHeapType) -> Type
fn reference_type(&self, ty: WasmHeapType) -> Type
source§impl TypeConvert for DummyEnvironment
impl TypeConvert for DummyEnvironment
source§fn lookup_heap_type(&self, _index: TypeIndex) -> WasmHeapType
fn lookup_heap_type(&self, _index: TypeIndex) -> WasmHeapType
source§fn convert_global_type(&self, ty: &GlobalType) -> Global
fn convert_global_type(&self, ty: &GlobalType) -> Global
source§fn convert_table_type(&self, ty: &TableType) -> Table
fn convert_table_type(&self, ty: &TableType) -> Table
source§fn convert_func_type(&self, ty: &FuncType) -> WasmFuncType
fn convert_func_type(&self, ty: &FuncType) -> WasmFuncType
source§fn convert_valtype(&self, ty: ValType) -> WasmType
fn convert_valtype(&self, ty: ValType) -> WasmType
source§fn convert_ref_type(&self, ty: RefType) -> WasmRefType
fn convert_ref_type(&self, ty: RefType) -> WasmRefType
source§fn convert_heap_type(&self, ty: HeapType) -> WasmHeapType
fn convert_heap_type(&self, ty: HeapType) -> WasmHeapType
Auto Trait Implementations§
impl Freeze for DummyEnvironment
impl RefUnwindSafe for DummyEnvironment
impl Send for DummyEnvironment
impl Sync for DummyEnvironment
impl Unpin for DummyEnvironment
impl UnwindSafe for DummyEnvironment
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more