2018-11-23 05:13:01 +00:00
|
|
|
use std::mem;
|
2019-01-23 07:27:13 +00:00
|
|
|
use wasmer_runtime_core::vm::Ctx;
|
2018-11-23 05:13:01 +00:00
|
|
|
|
|
|
|
#[repr(transparent)]
|
|
|
|
pub struct VarArgs {
|
2018-11-25 18:51:21 +00:00
|
|
|
pub pointer: u32, // assuming 32bit wasm
|
2018-11-23 05:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl VarArgs {
|
2019-01-23 07:27:13 +00:00
|
|
|
pub fn get<T: Sized>(&mut self, vmctx: &mut Ctx) -> T {
|
|
|
|
let ptr = vmctx.memory(0)[self.pointer as usize];
|
2018-11-23 05:13:01 +00:00
|
|
|
self.pointer += mem::size_of::<T>() as u32;
|
|
|
|
unsafe { (ptr as *const T).read() }
|
|
|
|
}
|
2018-11-27 04:29:26 +00:00
|
|
|
}
|