wiggle: automate borrow checking, explicitly passing borrow checker throughout
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::GuestMemory;
|
||||
use wiggle::{BorrowChecker, GuestMemory};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -31,8 +31,9 @@ impl IntFloatExercise {
|
||||
pub fn test(&self) {
|
||||
let ctx = WasiCtx::new();
|
||||
let host_memory = HostMemory::new();
|
||||
let bc = BorrowChecker::new();
|
||||
|
||||
let e = atoms::int_float_args(&ctx, &host_memory, self.an_int as i32, self.an_float);
|
||||
let e = atoms::int_float_args(&ctx, &host_memory, &bc, self.an_int as i32, self.an_float);
|
||||
|
||||
assert_eq!(e, types::Errno::Ok.into(), "int_float_args error");
|
||||
}
|
||||
@@ -60,16 +61,18 @@ impl DoubleIntExercise {
|
||||
pub fn test(&self) {
|
||||
let ctx = WasiCtx::new();
|
||||
let host_memory = HostMemory::new();
|
||||
let bc = BorrowChecker::new();
|
||||
|
||||
let e = atoms::double_int_return_float(
|
||||
&ctx,
|
||||
&host_memory,
|
||||
&bc,
|
||||
self.input as i32,
|
||||
self.return_loc.ptr as i32,
|
||||
);
|
||||
|
||||
let return_val = host_memory
|
||||
.ptr::<types::AliasToFloat>(self.return_loc.ptr)
|
||||
.ptr::<types::AliasToFloat>(&bc, self.return_loc.ptr)
|
||||
.read()
|
||||
.expect("failed to read return");
|
||||
assert_eq!(e, types::Errno::Ok.into(), "errno");
|
||||
|
||||
Reference in New Issue
Block a user