This repository was archived by the owner on Oct 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-14
lines changed
crates/tinywasm/src/runtime/stack Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Original file line number Diff line number Diff line change 11use core:: ops:: Range ;
22
3- use crate :: log;
43use crate :: { runtime:: RawWasmValue , Error , Result } ;
54use alloc:: vec:: Vec ;
65use 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
Original file line number Diff line number Diff line change 22
33#[ link( wasm_import_module = "env" ) ]
44extern "C" {
5- fn print_utf8 ( location : i32 , len : i32 ) ;
5+ fn print_utf8 ( location : i64 , len : i32 ) ;
66}
77
88const 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}
Original file line number Diff line number Diff 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 ( ( ) )
You can’t perform that action at this time.
0 commit comments