Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f6ac24

Browse files
fix: import param order
Signed-off-by: Henry Gressmann <[email protected]>
1 parent 8adce67 commit 1f6ac24

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

crates/tinywasm/src/runtime/stack/value_stack.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use core::ops::Range;
22

3-
use crate::log;
43
use crate::{runtime::RawWasmValue, Error, Result};
54
use alloc::vec::Vec;
65
use tinywasm_types::{ValType, WasmValue};
@@ -85,14 +84,7 @@ impl ValueStack {
8584

8685
#[inline]
8786
pub(crate) fn pop_params(&mut self, types: &[ValType]) -> Result<Vec<WasmValue>> {
88-
log::info!("pop_params: types={:?}", types);
89-
log::info!("stack={:?}", self.stack);
90-
91-
let mut res = Vec::with_capacity(types.len());
92-
for ty in types.iter() {
93-
res.push(self.pop()?.attach_type(*ty));
94-
}
95-
87+
let res = self.pop_n_rev(types.len())?.iter().zip(types.iter()).map(|(v, ty)| v.attach_type(*ty)).collect();
9688
Ok(res)
9789
}
9890

examples/rust/src/hello.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#[link(wasm_import_module = "env")]
44
extern "C" {
5-
fn print_utf8(location: i32, len: i32);
5+
fn print_utf8(location: i64, len: i32);
66
}
77

88
const ARG: &[u8] = &[0u8; 100];
@@ -23,6 +23,6 @@ pub unsafe extern "C" fn hello(len: i32) {
2323
let res = format!("Hello, {}!", arg).as_bytes().to_vec();
2424

2525
let len = res.len() as i32;
26-
let ptr = res.leak().as_ptr() as i32;
26+
let ptr = res.leak().as_ptr() as i64;
2727
print_utf8(ptr, len);
2828
}

examples/wasm-rust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ fn hello() -> Result<()> {
5555
imports.define(
5656
"env",
5757
"print_utf8",
58-
Extern::typed_func(|mut ctx: FuncContext<'_>, args: (i32, i32)| {
58+
Extern::typed_func(|mut ctx: FuncContext<'_>, args: (i64, i32)| {
5959
let mem = ctx.memory("memory")?;
60-
let ptr = args.1 as usize;
61-
let len = args.0 as usize;
60+
let ptr = args.0 as usize;
61+
let len = args.1 as usize;
6262
let string = mem.load_string(ptr, len)?;
6363
println!("{}", string);
6464
Ok(())

0 commit comments

Comments
 (0)