MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / simple_push_pop

Function simple_push_pop

pulley/src/interp.rs:1291–1315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1289
1290#[test]
1291fn simple_push_pop() {
1292 let mut state = MachineState::with_stack(16).unwrap();
1293 let pc = ExecutingPc::default();
1294 unsafe {
1295 let mut bytecode = [0; 10];
1296 let mut i = Interpreter {
1297 state: &mut state,
1298 // this isn't actually read so just manufacture a dummy one
1299 pc: UnsafeBytecodeStream::new(NonNull::new(bytecode.as_mut_ptr().offset(4)).unwrap()),
1300 executing_pc: pc.as_ref(),
1301 };
1302 assert!(i.push::<crate::Ret, _>(0_i32).is_continue());
1303 assert_eq!(i.pop::<i32>(), 0_i32);
1304 assert!(i.push::<crate::Ret, _>(1_i32).is_continue());
1305 assert!(i.push::<crate::Ret, _>(2_i32).is_continue());
1306 assert!(i.push::<crate::Ret, _>(3_i32).is_continue());
1307 assert!(i.push::<crate::Ret, _>(4_i32).is_continue());
1308 assert!(i.push::<crate::Ret, _>(5_i32).is_break());
1309 assert!(i.push::<crate::Ret, _>(6_i32).is_break());
1310 assert_eq!(i.pop::<i32>(), 4_i32);
1311 assert_eq!(i.pop::<i32>(), 3_i32);
1312 assert_eq!(i.pop::<i32>(), 2_i32);
1313 assert_eq!(i.pop::<i32>(), 1_i32);
1314 }
1315}
1316
1317macro_rules! br_if_imm {
1318 ($(

Callers

nothing calls this directly

Calls 5

newFunction · 0.50
unwrapMethod · 0.45
offsetMethod · 0.45
as_mut_ptrMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected