Rename some AST parts to be less odd

This commit is contained in:
Rerumu 2022-04-26 05:03:54 -04:00
parent 12e2799914
commit 1fda67d6d3
9 changed files with 185 additions and 187 deletions

View File

@ -1,7 +1,7 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use wasm_ast::{ use wasm_ast::{
node::{AnyBinOp, AnyCmpOp, AnyLoad, AnyStore, AnyUnOp, Function}, node::{BinOp, CmpOp, Intermediate, LoadAt, StoreAt, UnOp},
visit::{Driver, Visitor}, visit::{Driver, Visitor},
}; };
@ -10,25 +10,25 @@ struct Visit {
} }
impl Visitor for Visit { impl Visitor for Visit {
fn visit_any_load(&mut self, v: &AnyLoad) { fn visit_load_at(&mut self, v: &LoadAt) {
let name = v.op.as_name(); let name = v.what.as_name();
self.result.insert(("load", name)); self.result.insert(("load", name));
} }
fn visit_any_store(&mut self, v: &AnyStore) { fn visit_store_at(&mut self, v: &StoreAt) {
let name = v.op.as_name(); let name = v.what.as_name();
self.result.insert(("store", name)); self.result.insert(("store", name));
} }
fn visit_any_unop(&mut self, v: &AnyUnOp) { fn visit_un_op(&mut self, v: &UnOp) {
let name = v.op.as_name(); let name = v.op.as_name();
self.result.insert(name); self.result.insert(name);
} }
fn visit_any_binop(&mut self, v: &AnyBinOp) { fn visit_bin_op(&mut self, v: &BinOp) {
if v.op.as_operator().is_some() { if v.op.as_operator().is_some() {
return; return;
} }
@ -38,7 +38,7 @@ impl Visitor for Visit {
self.result.insert(name); self.result.insert(name);
} }
fn visit_any_cmpop(&mut self, v: &AnyCmpOp) { fn visit_cmp_op(&mut self, v: &CmpOp) {
if v.op.as_operator().is_some() { if v.op.as_operator().is_some() {
return; return;
} }
@ -49,12 +49,12 @@ impl Visitor for Visit {
} }
} }
pub fn visit(func: &Function) -> BTreeSet<(&'static str, &'static str)> { pub fn visit(ir: &Intermediate) -> BTreeSet<(&'static str, &'static str)> {
let mut visit = Visit { let mut visit = Visit {
result: BTreeSet::new(), result: BTreeSet::new(),
}; };
func.accept(&mut visit); ir.accept(&mut visit);
visit.result visit.result
} }

View File

@ -1,7 +1,7 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use wasm_ast::{ use wasm_ast::{
node::{AnyLoad, AnyStore, Function, MemoryGrow, MemorySize}, node::{Intermediate, LoadAt, MemoryGrow, MemorySize, StoreAt},
visit::{Driver, Visitor}, visit::{Driver, Visitor},
}; };
@ -10,11 +10,11 @@ struct Visit {
} }
impl Visitor for Visit { impl Visitor for Visit {
fn visit_any_store(&mut self, _: &AnyStore) { fn visit_store_at(&mut self, _: &StoreAt) {
self.result.insert(0); self.result.insert(0);
} }
fn visit_any_load(&mut self, _: &AnyLoad) { fn visit_load_at(&mut self, _: &LoadAt) {
self.result.insert(0); self.result.insert(0);
} }
@ -27,12 +27,12 @@ impl Visitor for Visit {
} }
} }
pub fn visit(func: &Function) -> BTreeSet<usize> { pub fn visit(ir: &Intermediate) -> BTreeSet<usize> {
let mut visit = Visit { let mut visit = Visit {
result: BTreeSet::new(), result: BTreeSet::new(),
}; };
func.accept(&mut visit); ir.accept(&mut visit);
visit.result visit.result
} }

View File

@ -7,9 +7,9 @@ use parity_wasm::elements::{
use wasm_ast::{ use wasm_ast::{
builder::{Builder, TypeInfo}, builder::{Builder, TypeInfo},
node::{ node::{
AnyBinOp, AnyCmpOp, AnyLoad, AnyStore, AnyUnOp, Backward, Br, BrIf, BrTable, Call, Backward, BinOp, Br, BrIf, BrTable, Call, CallIndirect, CmpOp, Else, Expression, Forward,
CallIndirect, Else, Expression, Forward, Function, GetGlobal, GetLocal, If, Memorize, GetGlobal, GetLocal, If, Intermediate, LoadAt, Memorize, MemoryGrow, MemorySize, Recall,
MemoryGrow, MemorySize, Recall, Return, Select, SetGlobal, SetLocal, Statement, Value, Return, Select, SetGlobal, SetLocal, Statement, StoreAt, UnOp, Value,
}, },
writer::{Transpiler, Writer}, writer::{Transpiler, Writer},
}; };
@ -109,9 +109,9 @@ fn write_named_array(name: &str, len: usize, w: Writer) -> Result<()> {
write!(w, "local {name} = table_new({len}, {hash})") write!(w, "local {name} = table_new({len}, {hash})")
} }
fn write_parameter_list(func: &Function, w: Writer) -> Result<()> { fn write_parameter_list(ir: &Intermediate, w: Writer) -> Result<()> {
write!(w, "function(")?; write!(w, "function(")?;
write_ascending("param", 0..func.num_param, w)?; write_ascending("param", 0..ir.num_param, w)?;
write!(w, ")") write!(w, ")")
} }
@ -124,10 +124,10 @@ fn write_call_store(result: Range<usize>, w: Writer) -> Result<()> {
write!(w, " = ") write!(w, " = ")
} }
fn write_variable_list(func: &Function, w: Writer) -> Result<()> { fn write_variable_list(ir: &Intermediate, w: Writer) -> Result<()> {
let mut total = 0; let mut total = 0;
for data in &func.local_data { for data in &ir.local_data {
let range = total..total + usize::try_from(data.count()).unwrap(); let range = total..total + usize::try_from(data.count()).unwrap();
let typed = data.value_type(); let typed = data.value_type();
@ -139,9 +139,9 @@ fn write_variable_list(func: &Function, w: Writer) -> Result<()> {
write_separated(range, |_, w| write!(w, "ZERO_{typed} "), w)?; write_separated(range, |_, w| write!(w, "ZERO_{typed} "), w)?;
} }
if func.num_stack != 0 { if ir.num_stack != 0 {
write!(w, "local ")?; write!(w, "local ")?;
write_ascending("reg", 0..func.num_stack, w)?; write_ascending("reg", 0..ir.num_stack, w)?;
write!(w, " ")?; write!(w, " ")?;
} }
@ -252,9 +252,9 @@ impl Driver for GetGlobal {
} }
} }
impl Driver for AnyLoad { impl Driver for LoadAt {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write!(w, "load_{}(memory_at_0, ", self.op.as_name())?; write!(w, "load_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.visit(v, w)?; self.pointer.visit(v, w)?;
write!(w, "+ {})", self.offset) write!(w, "+ {})", self.offset)
} }
@ -285,7 +285,7 @@ impl Driver for Value {
} }
} }
impl Driver for AnyUnOp { impl Driver for UnOp {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
let (a, b) = self.op.as_name(); let (a, b) = self.op.as_name();
@ -309,7 +309,7 @@ fn write_bin_call(
write!(w, ")") write!(w, ")")
} }
impl Driver for AnyBinOp { impl Driver for BinOp {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
if let Some(op) = self.op.as_operator() { if let Some(op) = self.op.as_operator() {
write!(w, "(")?; write!(w, "(")?;
@ -323,7 +323,7 @@ impl Driver for AnyBinOp {
} }
} }
fn write_any_cmp(cmp: &AnyCmpOp, v: &mut Visitor, w: Writer) -> Result<()> { fn write_any_cmp(cmp: &CmpOp, v: &mut Visitor, w: Writer) -> Result<()> {
if let Some(op) = cmp.op.as_operator() { if let Some(op) = cmp.op.as_operator() {
cmp.lhs.visit(v, w)?; cmp.lhs.visit(v, w)?;
write!(w, "{op} ")?; write!(w, "{op} ")?;
@ -333,7 +333,7 @@ fn write_any_cmp(cmp: &AnyCmpOp, v: &mut Visitor, w: Writer) -> Result<()> {
} }
} }
impl Driver for AnyCmpOp { impl Driver for CmpOp {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write!(w, "(")?; write!(w, "(")?;
write_any_cmp(self, v, w)?; write_any_cmp(self, v, w)?;
@ -343,7 +343,7 @@ impl Driver for AnyCmpOp {
// Removes the boolean to integer conversion // Removes the boolean to integer conversion
fn write_as_condition(data: &Expression, v: &mut Visitor, w: Writer) -> Result<()> { fn write_as_condition(data: &Expression, v: &mut Visitor, w: Writer) -> Result<()> {
if let Expression::AnyCmpOp(o) = data { if let Expression::CmpOp(o) = data {
write_any_cmp(o, v, w) write_any_cmp(o, v, w)
} else { } else {
data.visit(v, w)?; data.visit(v, w)?;
@ -362,13 +362,13 @@ impl Driver for Expression {
Self::Select(e) => e.visit(v, w), Self::Select(e) => e.visit(v, w),
Self::GetLocal(e) => e.visit(v, w), Self::GetLocal(e) => e.visit(v, w),
Self::GetGlobal(e) => e.visit(v, w), Self::GetGlobal(e) => e.visit(v, w),
Self::AnyLoad(e) => e.visit(v, w), Self::LoadAt(e) => e.visit(v, w),
Self::MemorySize(e) => e.visit(v, w), Self::MemorySize(e) => e.visit(v, w),
Self::MemoryGrow(e) => e.visit(v, w), Self::MemoryGrow(e) => e.visit(v, w),
Self::Value(e) => e.visit(v, w), Self::Value(e) => e.visit(v, w),
Self::AnyUnOp(e) => e.visit(v, w), Self::UnOp(e) => e.visit(v, w),
Self::AnyBinOp(e) => e.visit(v, w), Self::BinOp(e) => e.visit(v, w),
Self::AnyCmpOp(e) => e.visit(v, w), Self::CmpOp(e) => e.visit(v, w),
} }
} }
} }
@ -544,9 +544,9 @@ impl Driver for SetGlobal {
} }
} }
impl Driver for AnyStore { impl Driver for StoreAt {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write!(w, "store_{}(memory_at_0, ", self.op.as_name())?; write!(w, "store_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.visit(v, w)?; self.pointer.visit(v, w)?;
write!(w, "+ {}, ", self.offset)?; write!(w, "+ {}, ", self.offset)?;
self.value.visit(v, w)?; self.value.visit(v, w)?;
@ -570,12 +570,12 @@ impl Driver for Statement {
Self::CallIndirect(s) => s.visit(v, w), Self::CallIndirect(s) => s.visit(v, w),
Self::SetLocal(s) => s.visit(v, w), Self::SetLocal(s) => s.visit(v, w),
Self::SetGlobal(s) => s.visit(v, w), Self::SetGlobal(s) => s.visit(v, w),
Self::AnyStore(s) => s.visit(v, w), Self::StoreAt(s) => s.visit(v, w),
} }
} }
} }
impl Driver for Function { impl Driver for Intermediate {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write_parameter_list(self, w)?; write_parameter_list(self, w)?;
@ -815,7 +815,7 @@ impl<'a> Generator<'a> {
write!(w, "}} end ") write!(w, "}} end ")
} }
fn gen_localize(func_list: &[Function], w: Writer) -> Result<()> { fn gen_localize(func_list: &[Intermediate], w: Writer) -> Result<()> {
let mut loc_set = BTreeSet::new(); let mut loc_set = BTreeSet::new();
for func in func_list { for func in func_list {
@ -829,7 +829,7 @@ impl<'a> Generator<'a> {
// FIXME: Make `pub` only for fuzzing. // FIXME: Make `pub` only for fuzzing.
#[must_use] #[must_use]
pub fn build_func_list(&self) -> Vec<Function> { pub fn build_func_list(&self) -> Vec<Intermediate> {
let list = self.wasm.code_section().unwrap().bodies(); let list = self.wasm.code_section().unwrap().bodies();
let iter = list.iter().enumerate(); let iter = list.iter().enumerate();
@ -842,7 +842,7 @@ impl<'a> Generator<'a> {
/// ///
/// # Panics /// # Panics
/// If the number of functions overflows 32 bits. /// If the number of functions overflows 32 bits.
pub fn gen_func_list(&self, func_list: &[Function], w: Writer) -> Result<()> { pub fn gen_func_list(&self, func_list: &[Intermediate], w: Writer) -> Result<()> {
let offset = self.type_info.len_ex().try_into().unwrap(); let offset = self.type_info.len_ex().try_into().unwrap();
func_list.iter().enumerate().try_for_each(|(i, v)| { func_list.iter().enumerate().try_for_each(|(i, v)| {

View File

@ -1,7 +1,7 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use wasm_ast::{ use wasm_ast::{
node::{AnyBinOp, AnyCmpOp, AnyLoad, AnyStore, AnyUnOp, Function}, node::{BinOp, CmpOp, Intermediate, LoadAt, StoreAt, UnOp},
visit::{Driver, Visitor}, visit::{Driver, Visitor},
}; };
@ -10,25 +10,25 @@ struct Visit {
} }
impl Visitor for Visit { impl Visitor for Visit {
fn visit_any_load(&mut self, v: &AnyLoad) { fn visit_load_at(&mut self, v: &LoadAt) {
let name = v.op.as_name(); let name = v.what.as_name();
self.result.insert(("load", name)); self.result.insert(("load", name));
} }
fn visit_any_store(&mut self, v: &AnyStore) { fn visit_store_at(&mut self, v: &StoreAt) {
let name = v.op.as_name(); let name = v.what.as_name();
self.result.insert(("store", name)); self.result.insert(("store", name));
} }
fn visit_any_unop(&mut self, v: &AnyUnOp) { fn visit_un_op(&mut self, v: &UnOp) {
let name = v.op.as_name(); let name = v.op.as_name();
self.result.insert(name); self.result.insert(name);
} }
fn visit_any_binop(&mut self, v: &AnyBinOp) { fn visit_bin_op(&mut self, v: &BinOp) {
if v.op.as_operator().is_some() { if v.op.as_operator().is_some() {
return; return;
} }
@ -38,7 +38,7 @@ impl Visitor for Visit {
self.result.insert(name); self.result.insert(name);
} }
fn visit_any_cmpop(&mut self, v: &AnyCmpOp) { fn visit_cmp_op(&mut self, v: &CmpOp) {
if v.op.as_operator().is_some() { if v.op.as_operator().is_some() {
return; return;
} }
@ -49,12 +49,12 @@ impl Visitor for Visit {
} }
} }
pub fn visit(func: &Function) -> BTreeSet<(&'static str, &'static str)> { pub fn visit(ir: &Intermediate) -> BTreeSet<(&'static str, &'static str)> {
let mut visit = Visit { let mut visit = Visit {
result: BTreeSet::new(), result: BTreeSet::new(),
}; };
func.accept(&mut visit); ir.accept(&mut visit);
visit.result visit.result
} }

View File

@ -1,7 +1,7 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use wasm_ast::{ use wasm_ast::{
node::{AnyLoad, AnyStore, Function, MemoryGrow, MemorySize}, node::{Intermediate, LoadAt, MemoryGrow, MemorySize, StoreAt},
visit::{Driver, Visitor}, visit::{Driver, Visitor},
}; };
@ -10,11 +10,11 @@ struct Visit {
} }
impl Visitor for Visit { impl Visitor for Visit {
fn visit_any_store(&mut self, _: &AnyStore) { fn visit_store_at(&mut self, _: &StoreAt) {
self.result.insert(0); self.result.insert(0);
} }
fn visit_any_load(&mut self, _: &AnyLoad) { fn visit_load_at(&mut self, _: &LoadAt) {
self.result.insert(0); self.result.insert(0);
} }
@ -27,12 +27,12 @@ impl Visitor for Visit {
} }
} }
pub fn visit(func: &Function) -> BTreeSet<usize> { pub fn visit(ir: &Intermediate) -> BTreeSet<usize> {
let mut visit = Visit { let mut visit = Visit {
result: BTreeSet::new(), result: BTreeSet::new(),
}; };
func.accept(&mut visit); ir.accept(&mut visit);
visit.result visit.result
} }

View File

@ -7,9 +7,9 @@ use parity_wasm::elements::{
use wasm_ast::{ use wasm_ast::{
builder::{Builder, TypeInfo}, builder::{Builder, TypeInfo},
node::{ node::{
AnyBinOp, AnyCmpOp, AnyLoad, AnyStore, AnyUnOp, Backward, Br, BrIf, BrTable, Call, Backward, BinOp, Br, BrIf, BrTable, Call, CallIndirect, CmpOp, Else, Expression, Forward,
CallIndirect, Else, Expression, Forward, Function, GetGlobal, GetLocal, If, Memorize, GetGlobal, GetLocal, If, Intermediate, LoadAt, Memorize, MemoryGrow, MemorySize, Recall,
MemoryGrow, MemorySize, Recall, Return, Select, SetGlobal, SetLocal, Statement, Value, Return, Select, SetGlobal, SetLocal, Statement, StoreAt, UnOp, Value,
}, },
writer::{Transpiler, Writer}, writer::{Transpiler, Writer},
}; };
@ -108,9 +108,9 @@ fn write_named_array(name: &str, len: usize, w: Writer) -> Result<()> {
write!(w, "local {name} = table.create({len})") write!(w, "local {name} = table.create({len})")
} }
fn write_parameter_list(func: &Function, w: Writer) -> Result<()> { fn write_parameter_list(ir: &Intermediate, w: Writer) -> Result<()> {
write!(w, "function(")?; write!(w, "function(")?;
write_ascending("param", 0..func.num_param, w)?; write_ascending("param", 0..ir.num_param, w)?;
write!(w, ")") write!(w, ")")
} }
@ -123,10 +123,10 @@ fn write_call_store(result: Range<usize>, w: Writer) -> Result<()> {
write!(w, " = ") write!(w, " = ")
} }
fn write_variable_list(func: &Function, w: Writer) -> Result<()> { fn write_variable_list(ir: &Intermediate, w: Writer) -> Result<()> {
let mut total = 0; let mut total = 0;
for data in &func.local_data { for data in &ir.local_data {
let range = total..total + usize::try_from(data.count()).unwrap(); let range = total..total + usize::try_from(data.count()).unwrap();
let typed = data.value_type(); let typed = data.value_type();
@ -138,9 +138,9 @@ fn write_variable_list(func: &Function, w: Writer) -> Result<()> {
write_separated(range, |_, w| write!(w, "ZERO_{typed} "), w)?; write_separated(range, |_, w| write!(w, "ZERO_{typed} "), w)?;
} }
if func.num_stack != 0 { if ir.num_stack != 0 {
write!(w, "local ")?; write!(w, "local ")?;
write_ascending("reg", 0..func.num_stack, w)?; write_ascending("reg", 0..ir.num_stack, w)?;
write!(w, " ")?; write!(w, " ")?;
} }
@ -256,9 +256,9 @@ impl Driver for GetGlobal {
} }
} }
impl Driver for AnyLoad { impl Driver for LoadAt {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write!(w, "load_{}(memory_at_0, ", self.op.as_name())?; write!(w, "load_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.visit(v, w)?; self.pointer.visit(v, w)?;
write!(w, "+ {})", self.offset) write!(w, "+ {})", self.offset)
} }
@ -289,7 +289,7 @@ impl Driver for Value {
} }
} }
impl Driver for AnyUnOp { impl Driver for UnOp {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
let (a, b) = self.op.as_name(); let (a, b) = self.op.as_name();
@ -299,7 +299,7 @@ impl Driver for AnyUnOp {
} }
} }
fn write_bin_op(bin_op: &AnyBinOp, v: &mut Visitor, w: Writer) -> Result<()> { fn write_bin_op(bin_op: &BinOp, v: &mut Visitor, w: Writer) -> Result<()> {
let op = bin_op.op.as_operator().unwrap(); let op = bin_op.op.as_operator().unwrap();
write!(w, "(")?; write!(w, "(")?;
@ -309,7 +309,7 @@ fn write_bin_op(bin_op: &AnyBinOp, v: &mut Visitor, w: Writer) -> Result<()> {
write!(w, ")") write!(w, ")")
} }
fn write_bin_op_call(bin_op: &AnyBinOp, v: &mut Visitor, w: Writer) -> Result<()> { fn write_bin_op_call(bin_op: &BinOp, v: &mut Visitor, w: Writer) -> Result<()> {
let (a, b) = bin_op.op.as_name(); let (a, b) = bin_op.op.as_name();
write!(w, "{a}_{b}(")?; write!(w, "{a}_{b}(")?;
@ -319,7 +319,7 @@ fn write_bin_op_call(bin_op: &AnyBinOp, v: &mut Visitor, w: Writer) -> Result<()
write!(w, ")") write!(w, ")")
} }
impl Driver for AnyBinOp { impl Driver for BinOp {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
if self.op.as_operator().is_some() { if self.op.as_operator().is_some() {
write_bin_op(self, v, w) write_bin_op(self, v, w)
@ -329,7 +329,7 @@ impl Driver for AnyBinOp {
} }
} }
impl Driver for AnyCmpOp { impl Driver for CmpOp {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
let (a, b) = self.op.as_name(); let (a, b) = self.op.as_name();
@ -352,13 +352,13 @@ impl Driver for Expression {
Self::Select(e) => e.visit(v, w), Self::Select(e) => e.visit(v, w),
Self::GetLocal(e) => e.visit(v, w), Self::GetLocal(e) => e.visit(v, w),
Self::GetGlobal(e) => e.visit(v, w), Self::GetGlobal(e) => e.visit(v, w),
Self::AnyLoad(e) => e.visit(v, w), Self::LoadAt(e) => e.visit(v, w),
Self::MemorySize(e) => e.visit(v, w), Self::MemorySize(e) => e.visit(v, w),
Self::MemoryGrow(e) => e.visit(v, w), Self::MemoryGrow(e) => e.visit(v, w),
Self::Value(e) => e.visit(v, w), Self::Value(e) => e.visit(v, w),
Self::AnyUnOp(e) => e.visit(v, w), Self::UnOp(e) => e.visit(v, w),
Self::AnyBinOp(e) => e.visit(v, w), Self::BinOp(e) => e.visit(v, w),
Self::AnyCmpOp(e) => e.visit(v, w), Self::CmpOp(e) => e.visit(v, w),
} }
} }
} }
@ -548,9 +548,9 @@ impl Driver for SetGlobal {
} }
} }
impl Driver for AnyStore { impl Driver for StoreAt {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write!(w, "store_{}(memory_at_0, ", self.op.as_name())?; write!(w, "store_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.visit(v, w)?; self.pointer.visit(v, w)?;
write!(w, "+ {}, ", self.offset)?; write!(w, "+ {}, ", self.offset)?;
self.value.visit(v, w)?; self.value.visit(v, w)?;
@ -574,12 +574,12 @@ impl Driver for Statement {
Statement::CallIndirect(s) => s.visit(v, w), Statement::CallIndirect(s) => s.visit(v, w),
Statement::SetLocal(s) => s.visit(v, w), Statement::SetLocal(s) => s.visit(v, w),
Statement::SetGlobal(s) => s.visit(v, w), Statement::SetGlobal(s) => s.visit(v, w),
Statement::AnyStore(s) => s.visit(v, w), Statement::StoreAt(s) => s.visit(v, w),
} }
} }
} }
impl Driver for Function { impl Driver for Intermediate {
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> { fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
write_parameter_list(self, w)?; write_parameter_list(self, w)?;
@ -817,7 +817,7 @@ impl<'a> Generator<'a> {
write!(w, "}} end ") write!(w, "}} end ")
} }
fn gen_localize(func_list: &[Function], w: Writer) -> Result<()> { fn gen_localize(func_list: &[Intermediate], w: Writer) -> Result<()> {
let mut loc_set = BTreeSet::new(); let mut loc_set = BTreeSet::new();
for func in func_list { for func in func_list {
@ -829,7 +829,7 @@ impl<'a> Generator<'a> {
.try_for_each(|(a, b)| write!(w, "local {a}_{b} = rt.{a}.{b} ")) .try_for_each(|(a, b)| write!(w, "local {a}_{b} = rt.{a}.{b} "))
} }
fn build_func_list(&self) -> Vec<Function> { fn build_func_list(&self) -> Vec<Intermediate> {
let list = self.wasm.code_section().unwrap().bodies(); let list = self.wasm.code_section().unwrap().bodies();
let iter = list.iter().enumerate(); let iter = list.iter().enumerate();
@ -837,7 +837,7 @@ impl<'a> Generator<'a> {
.collect() .collect()
} }
fn gen_func_list(&self, func_list: &[Function], w: Writer) -> Result<()> { fn gen_func_list(&self, func_list: &[Intermediate], w: Writer) -> Result<()> {
let offset = self.type_info.len_ex().try_into().unwrap(); let offset = self.type_info.len_ex().try_into().unwrap();
func_list.iter().enumerate().try_for_each(|(i, v)| { func_list.iter().enumerate().try_for_each(|(i, v)| {

View File

@ -4,10 +4,10 @@ use parity_wasm::elements::{
}; };
use crate::node::{ use crate::node::{
AnyBinOp, AnyCmpOp, AnyLoad, AnyStore, AnyUnOp, Backward, BinOp, Br, BrIf, BrTable, Call, Backward, BinOp, BinOpType, Br, BrIf, BrTable, Call, CallIndirect, CmpOp, CmpOpType, Else,
CallIndirect, CmpOp, Else, Expression, Forward, Function, GetGlobal, GetLocal, If, Load, Expression, Forward, GetGlobal, GetLocal, If, Intermediate, LoadAt, LoadType, Memorize,
Memorize, MemoryGrow, MemorySize, Recall, Return, Select, SetGlobal, SetLocal, Statement, MemoryGrow, MemorySize, Recall, Return, Select, SetGlobal, SetLocal, Statement, StoreAt,
Store, UnOp, Value, StoreType, UnOp, UnOpType, Value,
}; };
struct Arity { struct Arity {
@ -175,50 +175,48 @@ impl Stacked {
} }
} }
fn push_load(&mut self, op: Load, offset: u32) { fn push_load(&mut self, what: LoadType, offset: u32) {
let pointer = Box::new(self.pop()); let pointer = Box::new(self.pop());
self.stack.push(Expression::AnyLoad(AnyLoad { self.stack.push(Expression::LoadAt(LoadAt {
op, what,
offset, offset,
pointer, pointer,
})); }));
} }
fn gen_store(&mut self, op: Store, offset: u32, stat: &mut Vec<Statement>) { fn gen_store(&mut self, what: StoreType, offset: u32, stat: &mut Vec<Statement>) {
let value = self.pop(); let value = self.pop();
let pointer = self.pop(); let pointer = self.pop();
self.gen_leak_pending(stat); self.gen_leak_pending(stat);
stat.push(Statement::AnyStore(AnyStore { stat.push(Statement::StoreAt(StoreAt {
op, what,
offset, offset,
pointer, pointer,
value, value,
})); }));
} }
fn push_un_op(&mut self, op: UnOp) { fn push_un_op(&mut self, op: UnOpType) {
let rhs = Box::new(self.pop()); let rhs = Box::new(self.pop());
self.stack.push(Expression::AnyUnOp(AnyUnOp { op, rhs })); self.stack.push(Expression::UnOp(UnOp { op, rhs }));
} }
fn push_bin_op(&mut self, op: BinOp) { fn push_bin_op(&mut self, op: BinOpType) {
let rhs = Box::new(self.pop()); let rhs = Box::new(self.pop());
let lhs = Box::new(self.pop()); let lhs = Box::new(self.pop());
self.stack self.stack.push(Expression::BinOp(BinOp { op, lhs, rhs }));
.push(Expression::AnyBinOp(AnyBinOp { op, lhs, rhs }));
} }
fn push_cmp_op(&mut self, op: CmpOp) { fn push_cmp_op(&mut self, op: CmpOpType) {
let rhs = Box::new(self.pop()); let rhs = Box::new(self.pop());
let lhs = Box::new(self.pop()); let lhs = Box::new(self.pop());
self.stack self.stack.push(Expression::CmpOp(CmpOp { op, lhs, rhs }));
.push(Expression::AnyCmpOp(AnyCmpOp { op, lhs, rhs }));
} }
// Since Eqz is the only unary comparison it's cleaner to // Since Eqz is the only unary comparison it's cleaner to
@ -227,13 +225,13 @@ impl Stacked {
match inst { match inst {
Instruction::I32Eqz => { Instruction::I32Eqz => {
self.push_constant(0_i32); self.push_constant(0_i32);
self.push_cmp_op(CmpOp::Eq_I32); self.push_cmp_op(CmpOpType::Eq_I32);
true true
} }
Instruction::I64Eqz => { Instruction::I64Eqz => {
self.push_constant(0_i64); self.push_constant(0_i64);
self.push_cmp_op(CmpOp::Eq_I64); self.push_cmp_op(CmpOpType::Eq_I64);
true true
} }
@ -242,15 +240,15 @@ impl Stacked {
} }
fn try_operation(&mut self, inst: &Instruction) -> bool { fn try_operation(&mut self, inst: &Instruction) -> bool {
if let Ok(op) = UnOp::try_from(inst) { if let Ok(op) = UnOpType::try_from(inst) {
self.push_un_op(op); self.push_un_op(op);
true true
} else if let Ok(op) = BinOp::try_from(inst) { } else if let Ok(op) = BinOpType::try_from(inst) {
self.push_bin_op(op); self.push_bin_op(op);
true true
} else if let Ok(op) = CmpOp::try_from(inst) { } else if let Ok(op) = CmpOpType::try_from(inst) {
self.push_cmp_op(op); self.push_cmp_op(op);
true true
@ -291,7 +289,7 @@ impl<'a> Builder<'a> {
} }
#[must_use] #[must_use]
pub fn consume(mut self, index: usize, func: &'a FuncBody) -> Function { pub fn consume(mut self, index: usize, func: &'a FuncBody) -> Intermediate {
let arity = &self.type_info.arity_of(self.type_info.len_ex() + index); let arity = &self.type_info.arity_of(self.type_info.len_ex() + index);
self.num_result = arity.num_result; self.num_result = arity.num_result;
@ -299,7 +297,7 @@ impl<'a> Builder<'a> {
let code = self.new_forward(&mut func.code().elements()); let code = self.new_forward(&mut func.code().elements());
let num_stack = self.data.last_stack; let num_stack = self.data.last_stack;
Function { Intermediate {
local_data: func.locals().to_vec(), local_data: func.locals().to_vec(),
num_param: arity.num_param, num_param: arity.num_param,
num_stack, num_stack,
@ -533,29 +531,29 @@ impl<'a> Builder<'a> {
stat.push(Statement::SetGlobal(SetGlobal { var, value })); stat.push(Statement::SetGlobal(SetGlobal { var, value }));
} }
Inst::I32Load(_, o) => self.data.push_load(Load::I32, o), Inst::I32Load(_, o) => self.data.push_load(LoadType::I32, o),
Inst::I64Load(_, o) => self.data.push_load(Load::I64, o), Inst::I64Load(_, o) => self.data.push_load(LoadType::I64, o),
Inst::F32Load(_, o) => self.data.push_load(Load::F32, o), Inst::F32Load(_, o) => self.data.push_load(LoadType::F32, o),
Inst::F64Load(_, o) => self.data.push_load(Load::F64, o), Inst::F64Load(_, o) => self.data.push_load(LoadType::F64, o),
Inst::I32Load8S(_, o) => self.data.push_load(Load::I32_I8, o), Inst::I32Load8S(_, o) => self.data.push_load(LoadType::I32_I8, o),
Inst::I32Load8U(_, o) => self.data.push_load(Load::I32_U8, o), Inst::I32Load8U(_, o) => self.data.push_load(LoadType::I32_U8, o),
Inst::I32Load16S(_, o) => self.data.push_load(Load::I32_I16, o), Inst::I32Load16S(_, o) => self.data.push_load(LoadType::I32_I16, o),
Inst::I32Load16U(_, o) => self.data.push_load(Load::I32_U16, o), Inst::I32Load16U(_, o) => self.data.push_load(LoadType::I32_U16, o),
Inst::I64Load8S(_, o) => self.data.push_load(Load::I64_I8, o), Inst::I64Load8S(_, o) => self.data.push_load(LoadType::I64_I8, o),
Inst::I64Load8U(_, o) => self.data.push_load(Load::I64_U8, o), Inst::I64Load8U(_, o) => self.data.push_load(LoadType::I64_U8, o),
Inst::I64Load16S(_, o) => self.data.push_load(Load::I64_I16, o), Inst::I64Load16S(_, o) => self.data.push_load(LoadType::I64_I16, o),
Inst::I64Load16U(_, o) => self.data.push_load(Load::I64_U16, o), Inst::I64Load16U(_, o) => self.data.push_load(LoadType::I64_U16, o),
Inst::I64Load32S(_, o) => self.data.push_load(Load::I64_I32, o), Inst::I64Load32S(_, o) => self.data.push_load(LoadType::I64_I32, o),
Inst::I64Load32U(_, o) => self.data.push_load(Load::I64_U32, o), Inst::I64Load32U(_, o) => self.data.push_load(LoadType::I64_U32, o),
Inst::I32Store(_, o) => self.data.gen_store(Store::I32, o, &mut stat), Inst::I32Store(_, o) => self.data.gen_store(StoreType::I32, o, &mut stat),
Inst::I64Store(_, o) => self.data.gen_store(Store::I64, o, &mut stat), Inst::I64Store(_, o) => self.data.gen_store(StoreType::I64, o, &mut stat),
Inst::F32Store(_, o) => self.data.gen_store(Store::F32, o, &mut stat), Inst::F32Store(_, o) => self.data.gen_store(StoreType::F32, o, &mut stat),
Inst::F64Store(_, o) => self.data.gen_store(Store::F64, o, &mut stat), Inst::F64Store(_, o) => self.data.gen_store(StoreType::F64, o, &mut stat),
Inst::I32Store8(_, o) => self.data.gen_store(Store::I32_N8, o, &mut stat), Inst::I32Store8(_, o) => self.data.gen_store(StoreType::I32_N8, o, &mut stat),
Inst::I32Store16(_, o) => self.data.gen_store(Store::I32_N16, o, &mut stat), Inst::I32Store16(_, o) => self.data.gen_store(StoreType::I32_N16, o, &mut stat),
Inst::I64Store8(_, o) => self.data.gen_store(Store::I64_N8, o, &mut stat), Inst::I64Store8(_, o) => self.data.gen_store(StoreType::I64_N8, o, &mut stat),
Inst::I64Store16(_, o) => self.data.gen_store(Store::I64_N16, o, &mut stat), Inst::I64Store16(_, o) => self.data.gen_store(StoreType::I64_N16, o, &mut stat),
Inst::I64Store32(_, o) => self.data.gen_store(Store::I64_N32, o, &mut stat), Inst::I64Store32(_, o) => self.data.gen_store(StoreType::I64_N32, o, &mut stat),
Inst::CurrentMemory(memory) => { Inst::CurrentMemory(memory) => {
let memory = memory.try_into().unwrap(); let memory = memory.try_into().unwrap();

View File

@ -4,7 +4,7 @@ use parity_wasm::elements::{BrTableData, Instruction, Local, SignExtInstruction}
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum Load { pub enum LoadType {
I32, I32,
I64, I64,
F32, F32,
@ -21,7 +21,7 @@ pub enum Load {
I64_U32, I64_U32,
} }
impl Load { impl LoadType {
#[must_use] #[must_use]
pub fn as_name(self) -> &'static str { pub fn as_name(self) -> &'static str {
match self { match self {
@ -43,7 +43,7 @@ impl Load {
} }
} }
impl TryFrom<&Instruction> for Load { impl TryFrom<&Instruction> for LoadType {
type Error = (); type Error = ();
fn try_from(inst: &Instruction) -> Result<Self, Self::Error> { fn try_from(inst: &Instruction) -> Result<Self, Self::Error> {
@ -73,7 +73,7 @@ impl TryFrom<&Instruction> for Load {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum Store { pub enum StoreType {
I32, I32,
I64, I64,
F32, F32,
@ -85,7 +85,7 @@ pub enum Store {
I64_N32, I64_N32,
} }
impl Store { impl StoreType {
#[must_use] #[must_use]
pub fn as_name(self) -> &'static str { pub fn as_name(self) -> &'static str {
match self { match self {
@ -102,7 +102,7 @@ impl Store {
} }
} }
impl TryFrom<&Instruction> for Store { impl TryFrom<&Instruction> for StoreType {
type Error = (); type Error = ();
fn try_from(inst: &Instruction) -> Result<Self, Self::Error> { fn try_from(inst: &Instruction) -> Result<Self, Self::Error> {
@ -129,7 +129,7 @@ impl TryFrom<&Instruction> for Store {
// operation_result_parameter // operation_result_parameter
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum UnOp { pub enum UnOpType {
Clz_I32, Clz_I32,
Ctz_I32, Ctz_I32,
Popcnt_I32, Popcnt_I32,
@ -174,7 +174,7 @@ pub enum UnOp {
Reinterpret_F64_I64, Reinterpret_F64_I64,
} }
impl UnOp { impl UnOpType {
#[must_use] #[must_use]
pub fn as_name(self) -> (&'static str, &'static str) { pub fn as_name(self) -> (&'static str, &'static str) {
match self { match self {
@ -224,7 +224,7 @@ impl UnOp {
} }
} }
impl TryFrom<&Instruction> for UnOp { impl TryFrom<&Instruction> for UnOpType {
type Error = (); type Error = ();
fn try_from(inst: &Instruction) -> Result<Self, Self::Error> { fn try_from(inst: &Instruction) -> Result<Self, Self::Error> {
@ -285,7 +285,7 @@ impl TryFrom<&Instruction> for UnOp {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum BinOp { pub enum BinOpType {
Add_I32, Add_I32,
Sub_I32, Sub_I32,
Mul_I32, Mul_I32,
@ -325,7 +325,7 @@ pub enum BinOp {
Copysign_FN, Copysign_FN,
} }
impl BinOp { impl BinOpType {
#[must_use] #[must_use]
pub fn as_operator(self) -> Option<&'static str> { pub fn as_operator(self) -> Option<&'static str> {
let op = match self { let op = match self {
@ -384,7 +384,7 @@ impl BinOp {
} }
} }
impl TryFrom<&Instruction> for BinOp { impl TryFrom<&Instruction> for BinOpType {
type Error = (); type Error = ();
fn try_from(inst: &Instruction) -> Result<Self, Self::Error> { fn try_from(inst: &Instruction) -> Result<Self, Self::Error> {
@ -439,7 +439,7 @@ impl TryFrom<&Instruction> for BinOp {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum CmpOp { pub enum CmpOpType {
Eq_I32, Eq_I32,
Ne_I32, Ne_I32,
LtS_I32, LtS_I32,
@ -468,7 +468,7 @@ pub enum CmpOp {
Ge_FN, Ge_FN,
} }
impl CmpOp { impl CmpOpType {
#[must_use] #[must_use]
pub fn as_operator(self) -> Option<&'static str> { pub fn as_operator(self) -> Option<&'static str> {
let op = match self { let op = match self {
@ -517,7 +517,7 @@ impl CmpOp {
} }
} }
impl TryFrom<&Instruction> for CmpOp { impl TryFrom<&Instruction> for CmpOpType {
type Error = (); type Error = ();
fn try_from(inst: &Instruction) -> Result<Self, Self::Error> { fn try_from(inst: &Instruction) -> Result<Self, Self::Error> {
@ -578,8 +578,8 @@ pub struct GetGlobal {
pub var: usize, pub var: usize,
} }
pub struct AnyLoad { pub struct LoadAt {
pub op: Load, pub what: LoadType,
pub offset: u32, pub offset: u32,
pub pointer: Box<Expression>, pub pointer: Box<Expression>,
} }
@ -625,19 +625,19 @@ impl From<u64> for Value {
} }
} }
pub struct AnyUnOp { pub struct UnOp {
pub op: UnOp, pub op: UnOpType,
pub rhs: Box<Expression>, pub rhs: Box<Expression>,
} }
pub struct AnyBinOp { pub struct BinOp {
pub op: BinOp, pub op: BinOpType,
pub lhs: Box<Expression>, pub lhs: Box<Expression>,
pub rhs: Box<Expression>, pub rhs: Box<Expression>,
} }
pub struct AnyCmpOp { pub struct CmpOp {
pub op: CmpOp, pub op: CmpOpType,
pub lhs: Box<Expression>, pub lhs: Box<Expression>,
pub rhs: Box<Expression>, pub rhs: Box<Expression>,
} }
@ -647,13 +647,13 @@ pub enum Expression {
Select(Select), Select(Select),
GetLocal(GetLocal), GetLocal(GetLocal),
GetGlobal(GetGlobal), GetGlobal(GetGlobal),
AnyLoad(AnyLoad), LoadAt(LoadAt),
MemorySize(MemorySize), MemorySize(MemorySize),
MemoryGrow(MemoryGrow), MemoryGrow(MemoryGrow),
Value(Value), Value(Value),
AnyUnOp(AnyUnOp), UnOp(UnOp),
AnyBinOp(AnyBinOp), BinOp(BinOp),
AnyCmpOp(AnyCmpOp), CmpOp(CmpOp),
} }
impl Expression { impl Expression {
@ -738,8 +738,8 @@ pub struct SetGlobal {
pub value: Expression, pub value: Expression,
} }
pub struct AnyStore { pub struct StoreAt {
pub op: Store, pub what: StoreType,
pub offset: u32, pub offset: u32,
pub pointer: Expression, pub pointer: Expression,
pub value: Expression, pub value: Expression,
@ -759,10 +759,10 @@ pub enum Statement {
CallIndirect(CallIndirect), CallIndirect(CallIndirect),
SetLocal(SetLocal), SetLocal(SetLocal),
SetGlobal(SetGlobal), SetGlobal(SetGlobal),
AnyStore(AnyStore), StoreAt(StoreAt),
} }
pub struct Function { pub struct Intermediate {
pub local_data: Vec<Local>, pub local_data: Vec<Local>,
pub num_param: usize, pub num_param: usize,
pub num_stack: usize, pub num_stack: usize,

View File

@ -1,7 +1,7 @@
use crate::node::{ use crate::node::{
AnyBinOp, AnyCmpOp, AnyLoad, AnyStore, AnyUnOp, Backward, Br, BrIf, BrTable, Call, Backward, BinOp, Br, BrIf, BrTable, Call, CallIndirect, CmpOp, Else, Expression, Forward,
CallIndirect, Else, Expression, Forward, Function, GetGlobal, GetLocal, If, Memorize, GetGlobal, GetLocal, If, Intermediate, LoadAt, Memorize, MemoryGrow, MemorySize, Recall,
MemoryGrow, MemorySize, Recall, Return, Select, SetGlobal, SetLocal, Statement, Value, Return, Select, SetGlobal, SetLocal, Statement, StoreAt, UnOp, Value,
}; };
pub trait Visitor { pub trait Visitor {
@ -13,7 +13,7 @@ pub trait Visitor {
fn visit_get_global(&mut self, _: &GetGlobal) {} fn visit_get_global(&mut self, _: &GetGlobal) {}
fn visit_any_load(&mut self, _: &AnyLoad) {} fn visit_load_at(&mut self, _: &LoadAt) {}
fn visit_memory_size(&mut self, _: &MemorySize) {} fn visit_memory_size(&mut self, _: &MemorySize) {}
@ -21,11 +21,11 @@ pub trait Visitor {
fn visit_value(&mut self, _: &Value) {} fn visit_value(&mut self, _: &Value) {}
fn visit_any_unop(&mut self, _: &AnyUnOp) {} fn visit_un_op(&mut self, _: &UnOp) {}
fn visit_any_binop(&mut self, _: &AnyBinOp) {} fn visit_bin_op(&mut self, _: &BinOp) {}
fn visit_any_cmpop(&mut self, _: &AnyCmpOp) {} fn visit_cmp_op(&mut self, _: &CmpOp) {}
fn visit_expression(&mut self, _: &Expression) {} fn visit_expression(&mut self, _: &Expression) {}
@ -57,7 +57,7 @@ pub trait Visitor {
fn visit_set_global(&mut self, _: &SetGlobal) {} fn visit_set_global(&mut self, _: &SetGlobal) {}
fn visit_any_store(&mut self, _: &AnyStore) {} fn visit_store_at(&mut self, _: &StoreAt) {}
fn visit_statement(&mut self, _: &Statement) {} fn visit_statement(&mut self, _: &Statement) {}
} }
@ -94,11 +94,11 @@ impl<T: Visitor> Driver<T> for GetGlobal {
} }
} }
impl<T: Visitor> Driver<T> for AnyLoad { impl<T: Visitor> Driver<T> for LoadAt {
fn accept(&self, visitor: &mut T) { fn accept(&self, visitor: &mut T) {
self.pointer.accept(visitor); self.pointer.accept(visitor);
visitor.visit_any_load(self); visitor.visit_load_at(self);
} }
} }
@ -122,29 +122,29 @@ impl<T: Visitor> Driver<T> for Value {
} }
} }
impl<T: Visitor> Driver<T> for AnyUnOp { impl<T: Visitor> Driver<T> for UnOp {
fn accept(&self, visitor: &mut T) { fn accept(&self, visitor: &mut T) {
self.rhs.accept(visitor); self.rhs.accept(visitor);
visitor.visit_any_unop(self); visitor.visit_un_op(self);
} }
} }
impl<T: Visitor> Driver<T> for AnyBinOp { impl<T: Visitor> Driver<T> for BinOp {
fn accept(&self, visitor: &mut T) { fn accept(&self, visitor: &mut T) {
self.lhs.accept(visitor); self.lhs.accept(visitor);
self.rhs.accept(visitor); self.rhs.accept(visitor);
visitor.visit_any_binop(self); visitor.visit_bin_op(self);
} }
} }
impl<T: Visitor> Driver<T> for AnyCmpOp { impl<T: Visitor> Driver<T> for CmpOp {
fn accept(&self, visitor: &mut T) { fn accept(&self, visitor: &mut T) {
self.lhs.accept(visitor); self.lhs.accept(visitor);
self.rhs.accept(visitor); self.rhs.accept(visitor);
visitor.visit_any_cmpop(self); visitor.visit_cmp_op(self);
} }
} }
@ -155,13 +155,13 @@ impl<T: Visitor> Driver<T> for Expression {
Self::Select(v) => v.accept(visitor), Self::Select(v) => v.accept(visitor),
Self::GetLocal(v) => v.accept(visitor), Self::GetLocal(v) => v.accept(visitor),
Self::GetGlobal(v) => v.accept(visitor), Self::GetGlobal(v) => v.accept(visitor),
Self::AnyLoad(v) => v.accept(visitor), Self::LoadAt(v) => v.accept(visitor),
Self::MemorySize(v) => v.accept(visitor), Self::MemorySize(v) => v.accept(visitor),
Self::MemoryGrow(v) => v.accept(visitor), Self::MemoryGrow(v) => v.accept(visitor),
Self::Value(v) => v.accept(visitor), Self::Value(v) => v.accept(visitor),
Self::AnyUnOp(v) => v.accept(visitor), Self::UnOp(v) => v.accept(visitor),
Self::AnyBinOp(v) => v.accept(visitor), Self::BinOp(v) => v.accept(visitor),
Self::AnyCmpOp(v) => v.accept(visitor), Self::CmpOp(v) => v.accept(visitor),
} }
visitor.visit_expression(self); visitor.visit_expression(self);
@ -292,12 +292,12 @@ impl<T: Visitor> Driver<T> for SetGlobal {
} }
} }
impl<T: Visitor> Driver<T> for AnyStore { impl<T: Visitor> Driver<T> for StoreAt {
fn accept(&self, visitor: &mut T) { fn accept(&self, visitor: &mut T) {
self.pointer.accept(visitor); self.pointer.accept(visitor);
self.value.accept(visitor); self.value.accept(visitor);
visitor.visit_any_store(self); visitor.visit_store_at(self);
} }
} }
@ -317,12 +317,12 @@ impl<T: Visitor> Driver<T> for Statement {
Self::CallIndirect(v) => v.accept(visitor), Self::CallIndirect(v) => v.accept(visitor),
Self::SetLocal(v) => v.accept(visitor), Self::SetLocal(v) => v.accept(visitor),
Self::SetGlobal(v) => v.accept(visitor), Self::SetGlobal(v) => v.accept(visitor),
Self::AnyStore(v) => v.accept(visitor), Self::StoreAt(v) => v.accept(visitor),
} }
} }
} }
impl<T: Visitor> Driver<T> for Function { impl<T: Visitor> Driver<T> for Intermediate {
fn accept(&self, visitor: &mut T) { fn accept(&self, visitor: &mut T) {
self.code.accept(visitor); self.code.accept(visitor);
} }