This commit is contained in:
Brian Carroll 2021-11-03 11:31:12 +00:00
parent ad9b761fce
commit d87db20478
2 changed files with 7 additions and 6 deletions

View file

@ -395,7 +395,7 @@ impl<'a> CodeBuilder<'a> {
loop { loop {
let next_insert = insert_iter.next(); let next_insert = insert_iter.next();
let next_pos = next_insert.map(|i| i.at).unwrap_or(self.code.len()); let next_pos = next_insert.map(|i| i.at).unwrap_or_else(|| self.code.len());
// Relocation offset needs to be an index into the body of the code section, but // Relocation offset needs to be an index into the body of the code section, but
// at this point it is an index into self.code. Need to adjust for all previous functions // at this point it is an index into self.code. Need to adjust for all previous functions

View file

@ -951,15 +951,15 @@ impl<'a> WasmModule<'a> {
types: TypeSection::new(arena), types: TypeSection::new(arena),
import: ImportSection::new(arena), import: ImportSection::new(arena),
function: FunctionSection::new(arena), function: FunctionSection::new(arena),
table: (), table: (), // Unused in Roc (mainly for function pointers)
memory: MemorySection::new(1024 * 1024), memory: MemorySection::new(1024 * 1024),
global: GlobalSection::new(arena), global: GlobalSection::new(arena),
export: ExportSection::new(arena), export: ExportSection::new(arena),
start: (), start: (), // Entry function. In Roc this would be part of the platform.
element: (), element: (), // Unused in Roc (related to table section)
data_count: (), data_count: (), // TODO, related to data section
code: CodeSection::new(arena), code: CodeSection::new(arena),
data: (), data: (), // TODO: program constants (e.g. string literals)
linking: LinkingSection::new(arena), linking: LinkingSection::new(arena),
reloc_code: RelocationSection::new(arena, "reloc.CODE"), reloc_code: RelocationSection::new(arena, "reloc.CODE"),
reloc_data: RelocationSection::new(arena, "reloc.DATA"), reloc_data: RelocationSection::new(arena, "reloc.DATA"),
@ -972,6 +972,7 @@ impl<'a> WasmModule<'a> {
self.function.signature_indices.push(index); self.function.signature_indices.push(index);
} }
#[allow(clippy::unit_arg)]
pub fn serialize<T: SerialBuffer>(&mut self, buffer: &mut T) { pub fn serialize<T: SerialBuffer>(&mut self, buffer: &mut T) {
buffer.append_u8(0); buffer.append_u8(0);
buffer.append_slice("asm".as_bytes()); buffer.append_slice("asm".as_bytes());