1use crate::{CodegenBackend, MirProgram};
4
5pub struct WasmBackend {
7 buf: Vec<u8>,
8}
9
10impl WasmBackend {
11 pub fn new() -> Self {
12 let buf = vec![
13 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, ];
16 Self { buf }
17 }
18}
19
20impl Default for WasmBackend {
21 fn default() -> Self {
22 Self::new()
23 }
24}
25
26impl CodegenBackend for WasmBackend {
27 fn emit(&mut self, _mir: &MirProgram, out: &std::path::Path) -> anyhow::Result<()> {
28 std::fs::write(out.with_extension("wasm"), &self.buf)?;
29 Ok(())
30 }
31}