Skip to content

Commit a0f8ccf

Browse files
committed
Update function return types to use Vec<WasmValue> for better handling of multiple values
1 parent 7bd4999 commit a0f8ccf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Modules/Virtual_machine/src/Instance.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'module> Instance_type<'module> {
102102
&self,
103103
Name: &str,
104104
Parameters: &Vec<WasmValue>,
105-
) -> Result_type<WasmValue> {
105+
) -> Result_type<Vec<WasmValue>> {
106106
if Parameters.is_empty() {
107107
Ok(
108108
Function::find_export_func(self.Get_inner_reference(), Name)?
@@ -116,15 +116,15 @@ impl<'module> Instance_type<'module> {
116116
}
117117
}
118118

119-
pub fn Call_main(&self, Parameters: &Vec<WasmValue>) -> Result_type<WasmValue> {
119+
pub fn Call_main(&self, Parameters: &Vec<WasmValue>) -> Result_type<Vec<WasmValue>> {
120120
self.Call_export_function("_start", Parameters)
121121
}
122122

123123
pub fn Allocate<T>(&mut self, Size: usize) -> Result_type<*mut T> {
124124
let Result = self.Call_export_function("Allocate", &vec![WasmValue::I32(Size as i32)])?;
125125

126-
if let WasmValue::I32(Pointer) = Result {
127-
let Pointer = unsafe { self.Convert_to_native_pointer(Pointer as u32) };
126+
if let Some(WasmValue::I32(Pointer)) = Result.first() {
127+
let Pointer = unsafe { self.Convert_to_native_pointer(*Pointer as u32) };
128128

129129
Ok(Pointer)
130130
} else {

Modules/Virtual_machine/src/Manager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Manager_type {
109109
Standard_in: Unique_file_identifier_type,
110110
Standard_out: Unique_file_identifier_type,
111111
Standard_error: Unique_file_identifier_type,
112-
) -> Result_type<WasmValue> {
112+
) -> Result_type<Vec<WasmValue>> {
113113
let Module = Module_type::From_buffer(
114114
&self.Runtime,
115115
Buffer,

0 commit comments

Comments
 (0)