wasmer/lib/dynasm-backend/src/codegen.rs

21 lines
752 B
Rust
Raw Normal View History

2019-02-11 16:51:49 +00:00
use wasmparser::{Operator, Type as WpType};
pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator> {
fn next_function(&mut self) -> Result<&mut FCG, CodegenError>;
2019-02-13 16:53:06 +00:00
fn finalize(&mut self) -> Result<(), CodegenError>;
2019-02-11 16:51:49 +00:00
}
pub trait FunctionCodeGenerator {
2019-02-13 16:53:06 +00:00
fn feed_return(&mut self, ty: WpType) -> Result<(), CodegenError>;
2019-02-11 16:51:49 +00:00
fn feed_param(&mut self, ty: WpType) -> Result<(), CodegenError>;
fn feed_local(&mut self, ty: WpType, n: usize) -> Result<(), CodegenError>;
fn begin_body(&mut self) -> Result<(), CodegenError>;
2019-02-11 16:51:49 +00:00
fn feed_opcode(&mut self, op: Operator) -> Result<(), CodegenError>;
fn finalize(&mut self) -> Result<(), CodegenError>;
}
#[derive(Debug)]
pub struct CodegenError {
pub message: &'static str,
}