@@ -142,9 +142,9 @@ impl From<ExecutionResult> for sys::FizzyExecutionResult {
142142}
143143
144144impl Instance {
145- pub fn execute ( & mut self , func_idx : u32 , args : & [ Value ] ) -> ExecutionResult {
145+ pub unsafe fn unsafe_execute ( & mut self , func_idx : u32 , args : & [ Value ] ) -> ExecutionResult {
146146 ExecutionResult {
147- 0 : unsafe { sys:: fizzy_execute ( self . ptr . as_ptr ( ) , func_idx, args. as_ptr ( ) , 0 ) } ,
147+ 0 : sys:: fizzy_execute ( self . ptr . as_ptr ( ) , func_idx, args. as_ptr ( ) , 0 ) ,
148148 }
149149 }
150150}
@@ -194,28 +194,29 @@ mod tests {
194194 assert ! ( instance. is_ok( ) ) ;
195195 let mut instance = instance. unwrap ( ) ;
196196
197- let result = instance. execute ( 0 , & [ ] ) ;
197+ let result = unsafe { instance. unsafe_execute ( 0 , & [ ] ) } ;
198198 assert ! ( !result. trapped( ) ) ;
199199 assert ! ( !result. value( ) . is_some( ) ) ;
200200
201- let result = instance. execute ( 1 , & [ ] ) ;
201+ let result = unsafe { instance. unsafe_execute ( 1 , & [ ] ) } ;
202202 assert ! ( !result. trapped( ) ) ;
203203 assert ! ( result. value( ) . is_some( ) ) ;
204204 assert_eq ! ( result. value( ) . unwrap( ) . as_i32( ) , 42 ) ;
205205
206206 // Explicit type specification
207- let result = instance. execute ( 2 , & [ ( 42 as i32 ) . into ( ) , ( 2 as i32 ) . into ( ) ] ) ;
207+ let result =
208+ unsafe { instance. unsafe_execute ( 2 , & [ ( 42 as i32 ) . into ( ) , ( 2 as i32 ) . into ( ) ] ) } ;
208209 assert ! ( !result. trapped( ) ) ;
209210 assert ! ( result. value( ) . is_some( ) ) ;
210211 assert_eq ! ( result. value( ) . unwrap( ) . as_i32( ) , 21 ) ;
211212
212213 // Implicit i64 types (even though the code expects i32)
213- let result = instance. execute ( 2 , & [ 42 . into ( ) , 2 . into ( ) ] ) ;
214+ let result = unsafe { instance. unsafe_execute ( 2 , & [ 42 . into ( ) , 2 . into ( ) ] ) } ;
214215 assert ! ( !result. trapped( ) ) ;
215216 assert ! ( result. value( ) . is_some( ) ) ;
216217 assert_eq ! ( result. value( ) . unwrap( ) . as_i32( ) , 21 ) ;
217218
218- let result = instance. execute ( 3 , & [ ] ) ;
219+ let result = unsafe { instance. unsafe_execute ( 3 , & [ ] ) } ;
219220 assert ! ( result. trapped( ) ) ;
220221 assert ! ( !result. value( ) . is_some( ) ) ;
221222 }
0 commit comments