diff --git a/compiler/test_gen/src/helpers/from_wasm32_memory.rs b/compiler/test_gen/src/helpers/from_wasmer_memory.rs similarity index 76% rename from compiler/test_gen/src/helpers/from_wasm32_memory.rs rename to compiler/test_gen/src/helpers/from_wasmer_memory.rs index b4bd972813..99f368f87f 100644 --- a/compiler/test_gen/src/helpers/from_wasm32_memory.rs +++ b/compiler/test_gen/src/helpers/from_wasmer_memory.rs @@ -1,7 +1,7 @@ use roc_gen_wasm::wasm32_sized::Wasm32Sized; use roc_std::{RocDec, RocList, RocOrder, RocStr}; -pub trait FromWasm32Memory: Wasm32Sized { +pub trait FromWasmerMemory: Wasm32Sized { fn decode(memory: &wasmer::Memory, offset: u32) -> Self; } @@ -31,7 +31,7 @@ macro_rules! from_wasm_memory_primitive_decode { macro_rules! from_wasm_memory_primitive { ($($type_name:ident ,)+) => { $( - impl FromWasm32Memory for $type_name { + impl FromWasmerMemory for $type_name { from_wasm_memory_primitive_decode!($type_name); } )* @@ -42,13 +42,13 @@ from_wasm_memory_primitive!( u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, f32, f64, bool, RocDec, RocOrder, ); -impl FromWasm32Memory for () { +impl FromWasmerMemory for () { fn decode(_: &wasmer::Memory, _: u32) -> Self {} } -impl FromWasm32Memory for RocStr { +impl FromWasmerMemory for RocStr { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { - let bytes = ::decode(memory, offset); + let bytes = ::decode(memory, offset); let length = (bytes >> 32) as u32; let elements = bytes as u32; @@ -73,9 +73,9 @@ impl FromWasm32Memory for RocStr { } } -impl FromWasm32Memory for RocList { +impl FromWasmerMemory for RocList { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { - let bytes = ::decode(memory, offset); + let bytes = ::decode(memory, offset); let length = (bytes >> 32) as u32; let elements = bytes as u32; @@ -83,7 +83,7 @@ impl FromWasm32Memory for RocList { let mut items = Vec::with_capacity(length as usize); for i in 0..length { - let item = ::decode( + let item = ::decode( memory, elements + i * ::SIZE_OF_WASM as u32, ); @@ -94,11 +94,11 @@ impl FromWasm32Memory for RocList { } } -impl FromWasm32Memory for &'_ T { +impl FromWasmerMemory for &'_ T { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { - let elements = ::decode(memory, offset); + let elements = ::decode(memory, offset); - let actual = ::decode(memory, elements); + let actual = ::decode(memory, elements); let b = Box::new(actual); @@ -106,7 +106,7 @@ impl FromWasm32Memory for &'_ T { } } -impl FromWasm32Memory for [T; N] { +impl FromWasmerMemory for [T; N] { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { let ptr: wasmer::WasmPtr = wasmer::WasmPtr::new(offset); let width = ::SIZE_OF_WASM as u32 * N as u32; @@ -117,28 +117,28 @@ impl FromWasm32Memory for [T; N] { } } -impl FromWasm32Memory for usize { +impl FromWasmerMemory for usize { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { - ::decode(memory, offset) as usize + ::decode(memory, offset) as usize } } -impl FromWasm32Memory for (T, U) { +impl FromWasmerMemory for (T, U) { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { debug_assert!( T::ALIGN_OF_WASM >= U::ALIGN_OF_WASM, "this function does not handle alignment" ); - let t = ::decode(memory, offset); + let t = ::decode(memory, offset); - let u = ::decode(memory, offset + T::ACTUAL_WIDTH as u32); + let u = ::decode(memory, offset + T::ACTUAL_WIDTH as u32); (t, u) } } -impl FromWasm32Memory for (T, U, V) { +impl FromWasmerMemory for (T, U, V) { fn decode(memory: &wasmer::Memory, offset: u32) -> Self { debug_assert!( T::ALIGN_OF_WASM >= U::ALIGN_OF_WASM, @@ -150,11 +150,11 @@ impl FromWasm32Me "this function does not handle alignment" ); - let t = ::decode(memory, offset); + let t = ::decode(memory, offset); - let u = ::decode(memory, offset + T::ACTUAL_WIDTH as u32); + let u = ::decode(memory, offset + T::ACTUAL_WIDTH as u32); - let v = ::decode( + let v = ::decode( memory, offset + T::ACTUAL_WIDTH as u32 + U::ACTUAL_WIDTH as u32, ); diff --git a/compiler/test_gen/src/helpers/mod.rs b/compiler/test_gen/src/helpers/mod.rs index faf3c9afee..10e3c70e8b 100644 --- a/compiler/test_gen/src/helpers/mod.rs +++ b/compiler/test_gen/src/helpers/mod.rs @@ -2,7 +2,7 @@ extern crate bumpalo; #[cfg(feature = "gen-dev")] pub mod dev; -pub mod from_wasm32_memory; +pub mod from_wasmer_memory; #[cfg(feature = "gen-llvm")] pub mod llvm; #[cfg(feature = "gen-wasm")] diff --git a/compiler/test_gen/src/helpers/wasm.rs b/compiler/test_gen/src/helpers/wasm.rs index c18d83ddb6..f16bd5f819 100644 --- a/compiler/test_gen/src/helpers/wasm.rs +++ b/compiler/test_gen/src/helpers/wasm.rs @@ -6,7 +6,7 @@ use std::marker::PhantomData; use std::path::{Path, PathBuf}; use wasmer::{Memory, WasmPtr}; -use crate::helpers::from_wasm32_memory::FromWasm32Memory; +use crate::helpers::from_wasmer_memory::FromWasmerMemory; use roc_can::builtins::builtin_defs_map; use roc_collections::all::{MutMap, MutSet}; use roc_gen_wasm::wasm32_test_result::Wasm32TestResult; @@ -193,7 +193,7 @@ fn load_bytes_into_runtime(bytes: Vec) -> wasmer::Instance { #[allow(dead_code)] pub fn assert_wasm_evals_to_help(src: &str, phantom: PhantomData) -> Result where - T: FromWasm32Memory + Wasm32TestResult, + T: FromWasmerMemory + Wasm32TestResult, { let arena = bumpalo::Bump::new(); @@ -225,7 +225,7 @@ where // Manually provide address and size based on printf in wasm_test_platform.c crate::helpers::wasm::debug_memory_hex(memory, 0x11440, 24); } - let output = ::decode(memory, address as u32); + let output = ::decode(memory, address as u32); Ok(output) } @@ -239,7 +239,7 @@ pub fn assert_wasm_refcounts_help( num_refcounts: usize, ) -> Result, String> where - T: FromWasm32Memory + Wasm32TestResult, + T: FromWasmerMemory + Wasm32TestResult, { let arena = bumpalo::Bump::new();