[−][src]Struct wasm_bindgen_wasm_interpreter::Interpreter
A ready-to-go interpreter of a wasm module.
An interpreter currently represents effectively cached state. It is reused
between calls to interpret
and is precomputed from a Module
. It houses
state like the wasm stack, wasm memory, etc.
Methods
impl Interpreter
[src]
pub fn new(module: &Module) -> Result<Interpreter, Error>
[src]
Creates a new interpreter from a provided Module
, precomputing all
information necessary to interpret further.
Note that the module
passed in to this function must be the same as
the module
passed to interpret
below.
pub fn interpret_descriptor(
&mut self,
id: FunctionId,
module: &Module
) -> Option<&[u32]>
[src]
&mut self,
id: FunctionId,
module: &Module
) -> Option<&[u32]>
Interprets the execution of the descriptor function func
.
This function will execute func
in the module
provided. Note that
the module
provided here must be the same as the one passed to new
when this Interpreter
was constructed.
The func
must be a wasm-bindgen descriptor function meaning that it
doesn't do anything like use floats or i64. Instead all it should do is
call other functions, sometimes some stack pointer manipulation, and
then call the one imported __wbindgen_describe
function. Anything else
will cause this interpreter to panic.
When the descriptor has finished running the assembled descriptor list
is returned. The descriptor returned can then be re-parsed into an
actual Descriptor
in the cli-support crate.
Return value
Returns Some
if func
was found in the module
and None
if it was
not found in the module
.
pub fn interpret_closure_descriptor(
&mut self,
id: FunctionId,
module: &Module,
entry_removal_list: &mut HashSet<usize>
) -> Option<&[u32]>
[src]
&mut self,
id: FunctionId,
module: &Module,
entry_removal_list: &mut HashSet<usize>
) -> Option<&[u32]>
Interprets a "closure descriptor", figuring out the signature of the closure that was intended.
This function will take an id
which is known to internally
execute __wbindgen_describe_closure
and interpret it. The
wasm-bindgen
crate controls all callers of this internal import. It
will then take the index passed to __wbindgen_describe_closure
and
interpret it as a function pointer. This means it'll look up within the
element section (function table) which index it points to. Upon finding
the relevant entry it'll assume that function is a descriptor function,
and then it will execute the descriptor function.
The returned value is the return value of the descriptor function found.
The entry_removal_list
list is also then populated with an index of
the entry in the elements section (and then the index within that
section) of the function that needs to be snip'd out.
pub fn describe_closure_id(&self) -> Option<FunctionId>
[src]
Returns the function id of the __wbindgen_describe_closure
imported function.
pub fn function_table_id(&self) -> Option<TableId>
[src]
Returns the detected id of the function table.
Trait Implementations
impl Default for Interpreter
[src]
fn default() -> Interpreter
[src]
Auto Trait Implementations
impl Send for Interpreter
impl Sync for Interpreter
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,