Improved function pointers

This commit is contained in:
Syrus Akbary 2018-10-22 18:36:51 +02:00
parent 7444837d09
commit a625382158

View File

@ -49,7 +49,7 @@ fn get_function_addr(
func_index: &FuncIndex, func_index: &FuncIndex,
import_functions: &Vec<*const u8>, import_functions: &Vec<*const u8>,
functions: &Vec<Vec<u8>>, functions: &Vec<Vec<u8>>,
) -> *const u8 { ) -> *const () {
let index = func_index.index(); let index = func_index.index();
let len = import_functions.len(); let len = import_functions.len();
let func_pointer = if index < len { let func_pointer = if index < len {
@ -57,7 +57,7 @@ fn get_function_addr(
} else { } else {
(&functions[func_index.index() - len]).as_ptr() (&functions[func_index.index() - len]).as_ptr()
}; };
func_pointer func_pointer as _
} }
// pub fn get_function_addr( // pub fn get_function_addr(
@ -468,7 +468,8 @@ impl Instance {
pub fn memories(&self) -> Arc<Vec<LinearMemory>> { pub fn memories(&self) -> Arc<Vec<LinearMemory>> {
self.memories.clone() self.memories.clone()
} }
pub fn get_function_pointer(&self, func_index: FuncIndex) -> *const u8 {
pub fn get_function_pointer(&self, func_index: FuncIndex) -> *const () {
get_function_addr(&func_index, &self.import_functions, &self.functions) get_function_addr(&func_index, &self.import_functions, &self.functions)
} }