Refactor naming and crates info (#8)

* Refactor naming and crates info

This commit:
* changes workspace crates to have a `wiggle_` prefix in names
* rename `memory` module of `wiggle-memory` crate to `runtime`
* fixes authors of all crates

* Rename wiggle memory crate to runtime
This commit is contained in:
Jakub Konka
2020-02-13 22:40:42 +01:00
committed by GitHub
parent 44584bccfc
commit 48a218b5c5
17 changed files with 77 additions and 79 deletions

View File

@@ -1,12 +1,12 @@
[package] [package]
name = "wiggle" name = "wiggle"
version = "0.1.0" version = "0.1.0"
authors = ["Jakub Konka <kubkonk@jakubkonka.com>"] authors = ["Pat Hickey <phickey@fastly.com>", "Jakub Konka <kubkonk@jakubkonka.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
generate = { path = "crates/generate" } wiggle-generate = { path = "crates/generate" }
memory = { path = "crates/memory" } wiggle-runtime = { path = "crates/runtime" }
[dev-dependencies] [dev-dependencies]
proptest = "0.9" proptest = "0.9"
@@ -14,6 +14,6 @@ proptest = "0.9"
[workspace] [workspace]
members = [ members = [
"crates/generate", "crates/generate",
"crates/memory" "crates/runtime"
] ]
exclude = ["crates/WASI"] exclude = ["crates/WASI"]

View File

@@ -1,14 +1,14 @@
[package] [package]
name = "generate" name = "wiggle-generate"
version = "0.1.0" version = "0.1.0"
authors = ["Jakub Konka <kubkon@jakubkonka.com>"] authors = ["Pat Hickey <phickey@fastly.com>", "Jakub Konka <kubkon@jakubkonka.com>"]
edition = "2018" edition = "2018"
[lib] [lib]
proc-macro = true proc-macro = true
[dependencies] [dependencies]
memory = { path = "../memory" } wiggle-runtime = { path = "../runtime" }
witx = { path = "../WASI/tools/witx" } witx = { path = "../WASI/tools/witx" }
quote = "1.0" quote = "1.0"
proc-macro2 = "1.0" proc-macro2 = "1.0"

View File

@@ -30,7 +30,7 @@ pub fn define_func(names: &Names, func: &witx::InterfaceFunc) -> TokenStream {
}); });
let abi_args = quote!( let abi_args = quote!(
ctx: &mut #ctx_type, memory: &mut ::memory::GuestMemory, ctx: &mut #ctx_type, memory: &mut wiggle_runtime::GuestMemory,
#(#params),* #(#params),*
); );
let abi_ret = if let Some(ret) = &coretype.ret { let abi_ret = if let Some(ret) = &coretype.ret {
@@ -62,8 +62,8 @@ pub fn define_func(names: &Names, func: &witx::InterfaceFunc) -> TokenStream {
}; };
let err_typename = names.type_ref(&tref, anon_lifetime()); let err_typename = names.type_ref(&tref, anon_lifetime());
quote! { quote! {
let e = ::memory::GuestError::InFunc { funcname: #funcname, location: #location, err: Box::new(e) }; let e = wiggle_runtime::GuestError::InFunc { funcname: #funcname, location: #location, err: Box::new(e) };
let err: #err_typename = ::memory::GuestErrorType::from_error(e, ctx); let err: #err_typename = wiggle_runtime::GuestErrorType::from_error(e, ctx);
return #abi_ret::from(err); return #abi_ret::from(err);
} }
} else { } else {
@@ -111,7 +111,7 @@ pub fn define_func(names: &Names, func: &witx::InterfaceFunc) -> TokenStream {
let success = if let Some(ref err_type) = err_type { let success = if let Some(ref err_type) = err_type {
let err_typename = names.type_ref(&err_type, anon_lifetime()); let err_typename = names.type_ref(&err_type, anon_lifetime());
quote! { quote! {
let success:#err_typename = ::memory::GuestErrorType::success(); let success:#err_typename = wiggle_runtime::GuestErrorType::success();
#abi_ret::from(success) #abi_ret::from(success)
} }
} else { } else {

View File

@@ -62,11 +62,11 @@ impl Names {
witx::Type::Builtin(builtin) => self.builtin_type(*builtin), witx::Type::Builtin(builtin) => self.builtin_type(*builtin),
witx::Type::Pointer(pointee) => { witx::Type::Pointer(pointee) => {
let pointee_type = self.type_ref(&pointee, lifetime.clone()); let pointee_type = self.type_ref(&pointee, lifetime.clone());
quote!(::memory::GuestPtrMut<#lifetime, #pointee_type>) quote!(wiggle_runtime::GuestPtrMut<#lifetime, #pointee_type>)
} }
witx::Type::ConstPointer(pointee) => { witx::Type::ConstPointer(pointee) => {
let pointee_type = self.type_ref(&pointee, lifetime.clone()); let pointee_type = self.type_ref(&pointee, lifetime.clone());
quote!(::memory::GuestPtr<#lifetime, #pointee_type>) quote!(wiggle_runtime::GuestPtr<#lifetime, #pointee_type>)
} }
_ => unimplemented!("anonymous type ref"), _ => unimplemented!("anonymous type ref"),
}, },

View File

@@ -21,11 +21,14 @@ pub fn define_datatype(names: &Names, namedtype: &witx::NamedType) -> TokenStrea
witx::Type::Union(_) => unimplemented!("union types"), witx::Type::Union(_) => unimplemented!("union types"),
witx::Type::Handle(_h) => unimplemented!("handle types"), witx::Type::Handle(_h) => unimplemented!("handle types"),
witx::Type::Builtin(b) => define_builtin(names, &namedtype.name, *b), witx::Type::Builtin(b) => define_builtin(names, &namedtype.name, *b),
witx::Type::Pointer(p) => { witx::Type::Pointer(p) => define_witx_pointer(
define_witx_pointer(names, &namedtype.name, quote!(::memory::GuestPtrMut), p) names,
} &namedtype.name,
quote!(wiggle_runtime::GuestPtrMut),
p,
),
witx::Type::ConstPointer(p) => { witx::Type::ConstPointer(p) => {
define_witx_pointer(names, &namedtype.name, quote!(::memory::GuestPtr), p) define_witx_pointer(names, &namedtype.name, quote!(wiggle_runtime::GuestPtr), p)
} }
witx::Type::Array { .. } => unimplemented!("array types"), witx::Type::Array { .. } => unimplemented!("array types"),
}, },
@@ -69,18 +72,18 @@ fn define_enum(names: &Names, name: &witx::Id, e: &witx::EnumDatatype) -> TokenS
} }
impl ::std::convert::TryFrom<#repr> for #ident { impl ::std::convert::TryFrom<#repr> for #ident {
type Error = ::memory::GuestError; type Error = wiggle_runtime::GuestError;
fn try_from(value: #repr) -> Result<#ident, ::memory::GuestError> { fn try_from(value: #repr) -> Result<#ident, wiggle_runtime::GuestError> {
match value as usize { match value as usize {
#(#tryfrom_repr_cases),*, #(#tryfrom_repr_cases),*,
_ => Err(::memory::GuestError::InvalidEnumValue(stringify!(#ident))), _ => Err(wiggle_runtime::GuestError::InvalidEnumValue(stringify!(#ident))),
} }
} }
} }
impl ::std::convert::TryFrom<#abi_repr> for #ident { impl ::std::convert::TryFrom<#abi_repr> for #ident {
type Error = ::memory::GuestError; type Error = wiggle_runtime::GuestError;
fn try_from(value: #abi_repr) -> Result<#ident, ::memory::GuestError> { fn try_from(value: #abi_repr) -> Result<#ident, wiggle_runtime::GuestError> {
#ident::try_from(value as #repr) #ident::try_from(value as #repr)
} }
} }
@@ -99,7 +102,7 @@ fn define_enum(names: &Names, name: &witx::Id, e: &witx::EnumDatatype) -> TokenS
} }
} }
impl ::memory::GuestType for #ident { impl wiggle_runtime::GuestType for #ident {
fn size() -> u32 { fn size() -> u32 {
::std::mem::size_of::<#repr>() as u32 ::std::mem::size_of::<#repr>() as u32
} }
@@ -109,7 +112,7 @@ fn define_enum(names: &Names, name: &witx::Id, e: &witx::EnumDatatype) -> TokenS
fn name() -> String { fn name() -> String {
stringify!(#ident).to_owned() stringify!(#ident).to_owned()
} }
fn validate<'a>(location: &::memory::GuestPtr<'a, #ident>) -> Result<(), ::memory::GuestError> { fn validate<'a>(location: &wiggle_runtime::GuestPtr<'a, #ident>) -> Result<(), wiggle_runtime::GuestError> {
use ::std::convert::TryFrom; use ::std::convert::TryFrom;
let raw: #repr = unsafe { (location.as_raw() as *const #repr).read() }; let raw: #repr = unsafe { (location.as_raw() as *const #repr).read() };
let _ = #ident::try_from(raw)?; let _ = #ident::try_from(raw)?;
@@ -117,15 +120,15 @@ fn define_enum(names: &Names, name: &witx::Id, e: &witx::EnumDatatype) -> TokenS
} }
} }
impl ::memory::GuestTypeCopy for #ident {} impl wiggle_runtime::GuestTypeCopy for #ident {}
impl ::memory::GuestTypeClone for #ident { impl wiggle_runtime::GuestTypeClone for #ident {
fn read_from_guest(location: &::memory::GuestPtr<#ident>) -> Result<#ident, ::memory::GuestError> { fn read_from_guest(location: &wiggle_runtime::GuestPtr<#ident>) -> Result<#ident, wiggle_runtime::GuestError> {
use ::std::convert::TryFrom; use ::std::convert::TryFrom;
let raw: #repr = unsafe { (location.as_raw() as *const #repr).read() }; let raw: #repr = unsafe { (location.as_raw() as *const #repr).read() };
let val = #ident::try_from(raw)?; let val = #ident::try_from(raw)?;
Ok(val) Ok(val)
} }
fn write_to_guest(&self, location: &::memory::GuestPtrMut<#ident>) { fn write_to_guest(&self, location: &wiggle_runtime::GuestPtrMut<#ident>) {
let val: #repr = #repr::from(*self); let val: #repr = #repr::from(*self);
unsafe { (location.as_raw() as *mut #repr).write(val) }; unsafe { (location.as_raw() as *mut #repr).write(val) };
} }
@@ -192,13 +195,13 @@ fn define_copy_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype)
quote! { quote! {
#type_::validate( #type_::validate(
&ptr.cast(#offset).map_err(|e| &ptr.cast(#offset).map_err(|e|
::memory::GuestError::InDataField{ wiggle_runtime::GuestError::InDataField{
typename: stringify!(#ident).to_owned(), typename: stringify!(#ident).to_owned(),
field: stringify!(#fieldname).to_owned(), field: stringify!(#fieldname).to_owned(),
err: Box::new(e), err: Box::new(e),
})? })?
).map_err(|e| ).map_err(|e|
::memory::GuestError::InDataField { wiggle_runtime::GuestError::InDataField {
typename: stringify!(#ident).to_owned(), typename: stringify!(#ident).to_owned(),
field: stringify!(#fieldname).to_owned(), field: stringify!(#fieldname).to_owned(),
err: Box::new(e), err: Box::new(e),
@@ -213,7 +216,7 @@ fn define_copy_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype)
#(#member_decls),* #(#member_decls),*
} }
impl ::memory::GuestType for #ident { impl wiggle_runtime::GuestType for #ident {
fn size() -> u32 { fn size() -> u32 {
#size #size
} }
@@ -223,12 +226,12 @@ fn define_copy_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype)
fn name() -> String { fn name() -> String {
stringify!(#ident).to_owned() stringify!(#ident).to_owned()
} }
fn validate(ptr: &::memory::GuestPtr<#ident>) -> Result<(), ::memory::GuestError> { fn validate(ptr: &wiggle_runtime::GuestPtr<#ident>) -> Result<(), wiggle_runtime::GuestError> {
#(#member_valids)* #(#member_valids)*
Ok(()) Ok(())
} }
} }
impl ::memory::GuestTypeCopy for #ident {} impl wiggle_runtime::GuestTypeCopy for #ident {}
} }
} }
@@ -246,11 +249,11 @@ fn define_ptr_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype) -
witx::Type::Builtin(builtin) => names.builtin_type(*builtin), witx::Type::Builtin(builtin) => names.builtin_type(*builtin),
witx::Type::Pointer(pointee) => { witx::Type::Pointer(pointee) => {
let pointee_type = names.type_ref(&pointee, quote!('a)); let pointee_type = names.type_ref(&pointee, quote!('a));
quote!(::memory::GuestPtrMut<'a, #pointee_type>) quote!(wiggle_runtime::GuestPtrMut<'a, #pointee_type>)
} }
witx::Type::ConstPointer(pointee) => { witx::Type::ConstPointer(pointee) => {
let pointee_type = names.type_ref(&pointee, quote!('a)); let pointee_type = names.type_ref(&pointee, quote!('a));
quote!(::memory::GuestPtr<'a, #pointee_type>) quote!(wiggle_runtime::GuestPtr<'a, #pointee_type>)
} }
_ => unimplemented!("other anonymous struct members"), _ => unimplemented!("other anonymous struct members"),
}, },
@@ -264,11 +267,11 @@ fn define_ptr_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype) -
witx::Type::Builtin(builtin) => names.builtin_type(*builtin), witx::Type::Builtin(builtin) => names.builtin_type(*builtin),
witx::Type::Pointer(pointee) => { witx::Type::Pointer(pointee) => {
let pointee_type = names.type_ref(&pointee, anon_lifetime()); let pointee_type = names.type_ref(&pointee, anon_lifetime());
quote!(::memory::GuestPtrMut::<#pointee_type>) quote!(wiggle_runtime::GuestPtrMut::<#pointee_type>)
} }
witx::Type::ConstPointer(pointee) => { witx::Type::ConstPointer(pointee) => {
let pointee_type = names.type_ref(&pointee, anon_lifetime()); let pointee_type = names.type_ref(&pointee, anon_lifetime());
quote!(::memory::GuestPtr::<#pointee_type>) quote!(wiggle_runtime::GuestPtr::<#pointee_type>)
} }
_ => unimplemented!("other anonymous struct members"), _ => unimplemented!("other anonymous struct members"),
}, },
@@ -278,13 +281,13 @@ fn define_ptr_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype) -
quote! { quote! {
#type_::validate( #type_::validate(
&ptr.cast(#offset).map_err(|e| &ptr.cast(#offset).map_err(|e|
::memory::GuestError::InDataField{ wiggle_runtime::GuestError::InDataField{
typename: stringify!(#ident).to_owned(), typename: stringify!(#ident).to_owned(),
field: stringify!(#fieldname).to_owned(), field: stringify!(#fieldname).to_owned(),
err: Box::new(e), err: Box::new(e),
})? })?
).map_err(|e| ).map_err(|e|
::memory::GuestError::InDataField { wiggle_runtime::GuestError::InDataField {
typename: stringify!(#ident).to_owned(), typename: stringify!(#ident).to_owned(),
field: stringify!(#fieldname).to_owned(), field: stringify!(#fieldname).to_owned(),
err: Box::new(e), err: Box::new(e),
@@ -312,13 +315,13 @@ fn define_ptr_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype) -
witx::Type::Pointer(pointee) => { witx::Type::Pointer(pointee) => {
let pointee_type = names.type_ref(&pointee, anon_lifetime()); let pointee_type = names.type_ref(&pointee, anon_lifetime());
quote! { quote! {
let #name = ::memory::GuestPtrMut::<#pointee_type>::read_from_guest(&location.cast(#offset)?)?; let #name = wiggle_runtime::GuestPtrMut::<#pointee_type>::read_from_guest(&location.cast(#offset)?)?;
} }
} }
witx::Type::ConstPointer(pointee) => { witx::Type::ConstPointer(pointee) => {
let pointee_type = names.type_ref(&pointee, anon_lifetime()); let pointee_type = names.type_ref(&pointee, anon_lifetime());
quote! { quote! {
let #name = ::memory::GuestPtr::<#pointee_type>::read_from_guest(&location.cast(#offset)?)?; let #name = wiggle_runtime::GuestPtr::<#pointee_type>::read_from_guest(&location.cast(#offset)?)?;
} }
} }
_ => unimplemented!("other anonymous struct members"), _ => unimplemented!("other anonymous struct members"),
@@ -338,7 +341,7 @@ fn define_ptr_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype) -
#(#member_decls),* #(#member_decls),*
} }
impl<'a> ::memory::GuestType for #ident<'a> { impl<'a> wiggle_runtime::GuestType for #ident<'a> {
fn size() -> u32 { fn size() -> u32 {
#size #size
} }
@@ -348,17 +351,17 @@ fn define_ptr_struct(names: &Names, name: &witx::Id, s: &witx::StructDatatype) -
fn name() -> String { fn name() -> String {
stringify!(#ident).to_owned() stringify!(#ident).to_owned()
} }
fn validate(ptr: &::memory::GuestPtr<#ident>) -> Result<(), ::memory::GuestError> { fn validate(ptr: &wiggle_runtime::GuestPtr<#ident>) -> Result<(), wiggle_runtime::GuestError> {
#(#member_valids)* #(#member_valids)*
Ok(()) Ok(())
} }
} }
impl<'a> ::memory::GuestTypePtr<'a> for #ident<'a> { impl<'a> wiggle_runtime::GuestTypePtr<'a> for #ident<'a> {
fn read_from_guest(location: &::memory::GuestPtr<'a, #ident<'a>>) -> Result<#ident<'a>, ::memory::GuestError> { fn read_from_guest(location: &wiggle_runtime::GuestPtr<'a, #ident<'a>>) -> Result<#ident<'a>, wiggle_runtime::GuestError> {
#(#member_reads)* #(#member_reads)*
Ok(#ident { #(#member_names),* }) Ok(#ident { #(#member_names),* })
} }
fn write_to_guest(&self, location: &::memory::GuestPtrMut<'a, Self>) { fn write_to_guest(&self, location: &wiggle_runtime::GuestPtrMut<'a, Self>) {
#(#member_writes)* #(#member_writes)*
} }
} }

View File

@@ -1,10 +0,0 @@
[package]
name = "memory"
version = "0.1.0"
authors = ["Pat Hickey <phickey@fastly.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
thiserror = "1"

View File

@@ -0,0 +1,8 @@
[package]
name = "wiggle-runtime"
version = "0.1.0"
authors = ["Pat Hickey <phickey@fastly.com>", "Jakub Konka <kubkon@jakubkonka.com>"]
edition = "2018"
[dependencies]
thiserror = "1"

View File

@@ -4,7 +4,7 @@ mod guest_type;
mod memory; mod memory;
mod region; mod region;
pub use self::memory::{GuestMemory, GuestPtr, GuestPtrMut, GuestRef, GuestRefMut};
pub use error::GuestError; pub use error::GuestError;
pub use guest_type::{GuestErrorType, GuestType, GuestTypeClone, GuestTypeCopy, GuestTypePtr}; pub use guest_type::{GuestErrorType, GuestType, GuestTypeClone, GuestTypeCopy, GuestTypePtr};
pub use memory::{GuestMemory, GuestPtr, GuestPtrMut, GuestRef, GuestRefMut};
pub use region::Region; pub use region::Region;

View File

@@ -1,13 +1,15 @@
use memory::GuestRef;
use proptest::prelude::*; use proptest::prelude::*;
use wiggle_runtime::{
GuestError, GuestErrorType, GuestMemory, GuestPtr, GuestPtrMut, GuestRef, GuestRefMut,
};
generate::from_witx!({ wiggle_generate::from_witx!({
witx: ["tests/test.witx"], witx: ["tests/test.witx"],
ctx: WasiCtx, ctx: WasiCtx,
}); });
pub struct WasiCtx { pub struct WasiCtx {
guest_errors: Vec<::memory::GuestError>, guest_errors: Vec<GuestError>,
} }
impl WasiCtx { impl WasiCtx {
@@ -27,14 +29,13 @@ impl foo::Foo for WasiCtx {
fn baz( fn baz(
&mut self, &mut self,
input1: types::Excuse, input1: types::Excuse,
input2_ptr: ::memory::GuestPtrMut<types::Excuse>, input2_ptr: GuestPtrMut<types::Excuse>,
input3_ptr: ::memory::GuestPtr<types::Excuse>, input3_ptr: GuestPtr<types::Excuse>,
input4_ptr_ptr: ::memory::GuestPtrMut<::memory::GuestPtr<types::Excuse>>, input4_ptr_ptr: GuestPtrMut<GuestPtr<types::Excuse>>,
) -> Result<(), types::Errno> { ) -> Result<(), types::Errno> {
println!("BAZ input1 {:?}", input1); println!("BAZ input1 {:?}", input1);
// Read enum value from mutable: // Read enum value from mutable:
let mut input2_ref: ::memory::GuestRefMut<types::Excuse> = let mut input2_ref: GuestRefMut<types::Excuse> = input2_ptr.as_ref_mut().map_err(|e| {
input2_ptr.as_ref_mut().map_err(|e| {
eprintln!("input2_ptr error: {}", e); eprintln!("input2_ptr error: {}", e);
types::Errno::InvalidArg types::Errno::InvalidArg
})?; })?;
@@ -53,7 +54,7 @@ impl foo::Foo for WasiCtx {
println!("wrote to input2_ref {:?}", input3); println!("wrote to input2_ref {:?}", input3);
// Read ptr value from mutable ptr: // Read ptr value from mutable ptr:
let input4_ptr: ::memory::GuestPtr<types::Excuse> = let input4_ptr: GuestPtr<types::Excuse> =
input4_ptr_ptr.read_ptr_from_guest().map_err(|e| { input4_ptr_ptr.read_ptr_from_guest().map_err(|e| {
eprintln!("input4_ptr_ptr error: {}", e); eprintln!("input4_ptr_ptr error: {}", e);
types::Errno::InvalidArg types::Errno::InvalidArg
@@ -96,12 +97,12 @@ impl foo::Foo for WasiCtx {
// it must implement GuestErrorType with type Context = WasiCtx. // it must implement GuestErrorType with type Context = WasiCtx.
// The context type should let you do logging or debugging or whatever you need // The context type should let you do logging or debugging or whatever you need
// with these errors. We just push them to vecs. // with these errors. We just push them to vecs.
impl ::memory::GuestErrorType for types::Errno { impl GuestErrorType for types::Errno {
type Context = WasiCtx; type Context = WasiCtx;
fn success() -> types::Errno { fn success() -> types::Errno {
types::Errno::Ok types::Errno::Ok
} }
fn from_error(e: ::memory::GuestError, ctx: &mut WasiCtx) -> types::Errno { fn from_error(e: GuestError, ctx: &mut WasiCtx) -> types::Errno {
eprintln!("GUEST ERROR: {:?}", e); eprintln!("GUEST ERROR: {:?}", e);
ctx.guest_errors.push(e); ctx.guest_errors.push(e);
types::Errno::InvalidArg types::Errno::InvalidArg
@@ -200,8 +201,7 @@ impl BatExercise {
pub fn test(&self) { pub fn test(&self) {
let mut ctx = WasiCtx::new(); let mut ctx = WasiCtx::new();
let mut host_memory = HostMemory::new(); let mut host_memory = HostMemory::new();
let mut guest_memory = let mut guest_memory = GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
memory::GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
let bat_err = foo::bat( let bat_err = foo::bat(
&mut ctx, &mut ctx,
@@ -300,8 +300,7 @@ impl BazExercise {
pub fn test(&self) { pub fn test(&self) {
let mut ctx = WasiCtx::new(); let mut ctx = WasiCtx::new();
let mut host_memory = HostMemory::new(); let mut host_memory = HostMemory::new();
let mut guest_memory = let mut guest_memory = GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
memory::GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
*guest_memory *guest_memory
.ptr_mut(self.input2_loc.ptr) .ptr_mut(self.input2_loc.ptr)
@@ -399,8 +398,7 @@ impl SumOfPairExercise {
pub fn test(&self) { pub fn test(&self) {
let mut ctx = WasiCtx::new(); let mut ctx = WasiCtx::new();
let mut host_memory = HostMemory::new(); let mut host_memory = HostMemory::new();
let mut guest_memory = let mut guest_memory = GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
memory::GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
*guest_memory *guest_memory
.ptr_mut(self.input_loc.ptr) .ptr_mut(self.input_loc.ptr)
@@ -492,8 +490,7 @@ impl SumPairPtrsExercise {
pub fn test(&self) { pub fn test(&self) {
let mut ctx = WasiCtx::new(); let mut ctx = WasiCtx::new();
let mut host_memory = HostMemory::new(); let mut host_memory = HostMemory::new();
let mut guest_memory = let mut guest_memory = GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
memory::GuestMemory::new(host_memory.as_mut_ptr(), host_memory.len() as u32);
*guest_memory *guest_memory
.ptr_mut(self.input_first_loc.ptr) .ptr_mut(self.input_first_loc.ptr)