mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-14 14:45:40 +00:00
15 lines
393 B
Rust
15 lines
393 B
Rust
|
use crate::webassembly::Instance;
|
||
|
use std::mem;
|
||
|
|
||
|
#[repr(transparent)]
|
||
|
pub struct VarArgs {
|
||
|
pointer: u32, // assuming 32bit wasm
|
||
|
}
|
||
|
|
||
|
impl VarArgs {
|
||
|
pub fn get<T: Copy>(&mut self, instance: &mut Instance) -> T {
|
||
|
let ptr = instance.memory_offset_addr(0, self.pointer as usize);
|
||
|
self.pointer += mem::size_of::<T>() as u32;
|
||
|
unsafe { (ptr as *const T).read() }
|
||
|
}
|
||
|
}
|