wasmer/src/apis/emscripten/varargs.rs

16 lines
399 B
Rust
Raw Normal View History

2018-11-23 05:13:01 +00:00
use crate::webassembly::Instance;
use std::mem;
#[repr(transparent)]
pub struct VarArgs {
pub pointer: u32, // assuming 32bit wasm
2018-11-23 05:13:01 +00:00
}
impl VarArgs {
pub fn get<T: Sized>(&mut self, instance: &mut Instance) -> T {
2018-11-23 05:13:01 +00:00
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() }
}
2018-11-27 04:29:26 +00:00
}