use crate::ir::id::GlobalID;
use crate::ir::module::module_globals::Global;
use crate::ir::types::{InstrumentationMode, Location};
use crate::opcode::Instrumenter;
use wasmparser::Operator;
#[allow(dead_code)]
pub trait Iterator {
fn reset(&mut self);
fn next(&mut self) -> Option<&Operator<'_>>;
fn curr_loc(&self) -> (Location, bool);
fn curr_op(&self) -> Option<&Operator<'_>>;
}
pub trait IteratingInstrumenter<'a>: Instrumenter<'a> + Iterator {
fn set_instrument_mode(&mut self, mode: InstrumentationMode) {
self.set_instrument_mode_at(mode, self.curr_loc().0);
}
fn append_to_tag(&mut self, data: Vec<u8>) {
self.append_tag_at(data, self.curr_loc().0);
}
fn alternate(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::Alternate);
self
}
fn empty_alternate(&mut self) -> &mut Self {
self.empty_alternate_at(self.curr_loc().0);
self
}
fn before(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::Before);
self
}
fn after(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::After);
self
}
fn semantic_after(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::SemanticAfter);
self
}
fn block_entry(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::BlockEntry);
self
}
fn block_exit(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::BlockExit);
self
}
fn block_alt(&mut self) -> &mut Self {
self.set_instrument_mode(InstrumentationMode::BlockAlt);
self
}
fn empty_block_alt(&mut self) -> &mut Self {
self.empty_block_alt_at(self.curr_loc().0);
self
}
fn add_global(&mut self, global: Global) -> GlobalID;
}