Skip to content

Commit

Permalink
emit an empty module
Browse files Browse the repository at this point in the history
  • Loading branch information
dhconnelly committed Nov 18, 2023
1 parent 328b719 commit 157f442
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/emitter.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
use crate::wasm::*;
use std::io;
use std::io::Write;
use std::result;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {}
pub enum Error {
#[error("io: {0}")]
IOError(#[from] io::Error),
}

pub type Result<T> = result::Result<T, Error>;

pub fn emit<W: Write>(_w: W, _wasm: &[Wasm]) -> Result<()> {
// https://webassembly.github.io/spec/core/binary/modules.html#binary-module
const HEADER: &'static [u8] = &[0x00, 0x61, 0x73, 0x6d];
const VERSION: &'static [u8] = &[0x01, 0x00, 0x00, 0x00];

pub fn emit<W: Write>(mut w: W, _wasm: &[Wasm]) -> Result<()> {
w.write_all(HEADER)?;
w.write_all(VERSION)?;
Ok(())
}

0 comments on commit 157f442

Please sign in to comment.