Refactor BrIf behavior

This commit is contained in:
Rerumu
2022-06-12 04:27:16 -04:00
parent 183db977f3
commit 32031c8c2c
5 changed files with 15 additions and 50 deletions
+1 -12
View File
@@ -5,7 +5,7 @@ use std::{
use parity_wasm::elements::ValueType;
use wasm_ast::node::{
Backward, Br, BrIf, BrTable, Call, CallIndirect, Forward, FuncData, If, SetGlobal, SetLocal,
Backward, Br, BrTable, Call, CallIndirect, Forward, FuncData, If, SetGlobal, SetLocal,
SetTemporary, Statement, StoreAt, Terminator,
};
@@ -152,16 +152,6 @@ impl Driver for If {
}
}
impl Driver for BrIf {
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
write!(w, "if ")?;
write_condition(&self.cond, mng, w)?;
write!(w, "then ")?;
write_br_at(self.target, mng, w)?;
write!(w, "end ")
}
}
fn write_call_store(result: Range<usize>, w: &mut dyn Write) -> Result<()> {
if result.is_empty() {
return Ok(());
@@ -236,7 +226,6 @@ impl Driver for Statement {
Self::Forward(s) => s.write(mng, w),
Self::Backward(s) => s.write(mng, w),
Self::If(s) => s.write(mng, w),
Self::BrIf(s) => s.write(mng, w),
Self::Call(s) => s.write(mng, w),
Self::CallIndirect(s) => s.write(mng, w),
Self::SetTemporary(s) => s.write(mng, w),