Update LLVM FCG begin_body

This commit is contained in:
Brandon Fish
2019-05-03 00:14:25 -05:00
parent b016ec6b34
commit c5caf9b6db
4 changed files with 49 additions and 26 deletions

View File

@ -12,7 +12,9 @@ use smallvec::SmallVec;
use std::fmt::Debug;
use std::marker::PhantomData;
use wasmparser::{Operator, Type as WpType};
use std::fmt;
#[derive(Debug)]
pub enum Event<'a, 'b> {
Internal(InternalEvent),
Wasm(&'b Operator<'a>),
@ -26,6 +28,19 @@ pub enum InternalEvent {
GetInternal(u32),
}
impl fmt::Debug for InternalEvent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
InternalEvent::FunctionBegin(_) => write!(f, "FunctionBegin"),
InternalEvent::FunctionEnd => write!(f, "FunctionEnd"),
InternalEvent::Breakpoint(_) => write!(f, "Breakpoint"),
InternalEvent::SetInternal(_) => write!(f, "SetInternal"),
InternalEvent::GetInternal(_) => write!(f, "GetInternal"),
_ => panic!("unknown event")
}
}
}
pub struct BkptInfo {}
pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule, E: Debug> {
@ -246,7 +261,7 @@ pub trait FunctionCodeGenerator<E: Debug> {
fn feed_local(&mut self, ty: WpType, n: usize) -> Result<(), E>;
/// Called before the first call to `feed_opcode`.
fn begin_body(&mut self) -> Result<(), E>;
fn begin_body(&mut self, module_info: &ModuleInfo) -> Result<(), E>;
/// Called for each operator.
fn feed_event(&mut self, op: Event, module_info: &ModuleInfo) -> Result<(), E>;

View File

@ -244,7 +244,7 @@ pub fn read_module<
ParserState::CodeOperator(ref op) => {
if !body_begun {
body_begun = true;
fcg.begin_body()
fcg.begin_body(&info)
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
}
middlewares