mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Temporary setup to gradually migrate sections from parity_wasm to our own module_builder
Previously we just had our own code section. Now we also have export section, and a way of switching them over one by one, running tests in between.
This commit is contained in:
parent
4f464e485a
commit
edadd4ce13
6 changed files with 203 additions and 101 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::fmt::Debug;
|
||||
|
||||
use bumpalo::collections::vec::Vec;
|
||||
|
||||
/// Write an unsigned integer into the provided buffer in LEB-128 format, returning byte length
|
||||
|
@ -69,7 +71,7 @@ macro_rules! encode_padded_sleb128 {
|
|||
};
|
||||
}
|
||||
|
||||
pub trait SerialBuffer {
|
||||
pub trait SerialBuffer: Debug {
|
||||
fn append_u8(&mut self, b: u8);
|
||||
fn overwrite_u8(&mut self, index: usize, b: u8);
|
||||
fn append_slice(&mut self, b: &[u8]);
|
||||
|
@ -120,6 +122,11 @@ impl Serialize for u32 {
|
|||
}
|
||||
}
|
||||
|
||||
// Unit is used as a placeholder in parts of the Wasm spec we don't use yet
|
||||
impl Serialize for () {
|
||||
fn serialize<T: SerialBuffer>(&self, _buffer: &mut T) {}
|
||||
}
|
||||
|
||||
impl<S: Serialize> Serialize for [S] {
|
||||
fn serialize<T: SerialBuffer>(&self, buffer: &mut T) {
|
||||
buffer.encode_u32(self.len() as u32);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue