diff --git a/compiler/gen_wasm/src/backend.rs b/compiler/gen_wasm/src/backend.rs index 6f7dfcb884..0eebe41121 100644 --- a/compiler/gen_wasm/src/backend.rs +++ b/compiler/gen_wasm/src/backend.rs @@ -10,18 +10,12 @@ use roc_module::symbol::Symbol; use roc_mono::ir::{CallType, Expr, JoinPointId, Literal, Proc, Stmt}; use roc_mono::layout::{Builtin, Layout, UnionLayout}; +use crate::*; + // Don't allocate any constant data at address zero or near it. Would be valid, but bug-prone. // Follow Emscripten's example by using 1kB (4 bytes would probably do) const UNUSED_DATA_SECTION_BYTES: u32 = 1024; -const PTR_SIZE: u32 = 4; -const PTR_TYPE: ValueType = ValueType::I32; - -const ALIGN_1: u32 = 0; -const ALIGN_2: u32 = 1; -const ALIGN_4: u32 = 2; -const ALIGN_8: u32 = 3; - #[derive(Clone, Copy, Debug)] struct LocalId(u32); diff --git a/compiler/gen_wasm/src/lib.rs b/compiler/gen_wasm/src/lib.rs index e814a7a3b7..c807296304 100644 --- a/compiler/gen_wasm/src/lib.rs +++ b/compiler/gen_wasm/src/lib.rs @@ -3,7 +3,7 @@ pub mod from_wasm32_memory; use bumpalo::Bump; use parity_wasm::builder; -use parity_wasm::elements::Internal; +use parity_wasm::elements::{Internal, ValueType}; use roc_collections::all::{MutMap, MutSet}; use roc_module::symbol::{Interns, Symbol}; @@ -12,6 +12,16 @@ use roc_mono::layout::LayoutIds; use crate::backend::WasmBackend; +const PTR_SIZE: u32 = 4; +const PTR_TYPE: ValueType = ValueType::I32; + +pub const ALIGN_1: u32 = 0; +pub const ALIGN_2: u32 = 1; +pub const ALIGN_4: u32 = 2; +pub const ALIGN_8: u32 = 3; + +pub const STACK_POINTER_GLOBAL_ID: u32 = 0; + pub struct Env<'a> { pub arena: &'a Bump, // not really using this much, parity_wasm works with std::vec a lot pub interns: Interns,