Simplify new_stored_body
This commit is contained in:
parent
fbd23e05b6
commit
d6b77b287e
@ -436,7 +436,7 @@ impl<'a> Builder<'a> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
match inst {
|
match *inst {
|
||||||
Inst::Nop => {}
|
Inst::Nop => {}
|
||||||
Inst::Unreachable => {
|
Inst::Unreachable => {
|
||||||
stat.push(Statement::Unreachable);
|
stat.push(Statement::Unreachable);
|
||||||
@ -446,7 +446,7 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
let data = self.new_forward(list);
|
let data = self.new_forward(list);
|
||||||
|
|
||||||
self.push_block_result(*t);
|
self.push_block_result(t);
|
||||||
stat.push(Statement::Forward(data));
|
stat.push(Statement::Forward(data));
|
||||||
}
|
}
|
||||||
Inst::Loop(t) => {
|
Inst::Loop(t) => {
|
||||||
@ -454,7 +454,7 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
let data = self.new_backward(list);
|
let data = self.new_backward(list);
|
||||||
|
|
||||||
self.push_block_result(*t);
|
self.push_block_result(t);
|
||||||
stat.push(Statement::Backward(data));
|
stat.push(Statement::Backward(data));
|
||||||
}
|
}
|
||||||
Inst::If(t) => {
|
Inst::If(t) => {
|
||||||
@ -464,7 +464,7 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
let data = self.new_if(cond, list);
|
let data = self.new_if(cond, list);
|
||||||
|
|
||||||
self.push_block_result(*t);
|
self.push_block_result(t);
|
||||||
stat.push(Statement::If(data));
|
stat.push(Statement::If(data));
|
||||||
}
|
}
|
||||||
Inst::Else => {
|
Inst::Else => {
|
||||||
@ -481,17 +481,17 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Inst::Br(i) => {
|
Inst::Br(target) => {
|
||||||
self.data.gen_leak_pending(&mut stat);
|
self.data.gen_leak_pending(&mut stat);
|
||||||
stat.push(Statement::Br(Br { target: *i }));
|
stat.push(Statement::Br(Br { target }));
|
||||||
}
|
}
|
||||||
Inst::BrIf(i) => {
|
Inst::BrIf(target) => {
|
||||||
let cond = self.data.pop();
|
let cond = self.data.pop();
|
||||||
|
|
||||||
self.data.gen_leak_pending(&mut stat);
|
self.data.gen_leak_pending(&mut stat);
|
||||||
stat.push(Statement::BrIf(BrIf { cond, target: *i }));
|
stat.push(Statement::BrIf(BrIf { cond, target }));
|
||||||
}
|
}
|
||||||
Inst::BrTable(t) => {
|
Inst::BrTable(ref t) => {
|
||||||
let cond = self.data.pop();
|
let cond = self.data.pop();
|
||||||
|
|
||||||
self.data.gen_leak_pending(&mut stat);
|
self.data.gen_leak_pending(&mut stat);
|
||||||
@ -504,10 +504,10 @@ impl<'a> Builder<'a> {
|
|||||||
self.gen_return(&mut stat);
|
self.gen_return(&mut stat);
|
||||||
}
|
}
|
||||||
Inst::Call(i) => {
|
Inst::Call(i) => {
|
||||||
self.gen_call(*i, &mut stat);
|
self.gen_call(i, &mut stat);
|
||||||
}
|
}
|
||||||
Inst::CallIndirect(i, t) => {
|
Inst::CallIndirect(i, t) => {
|
||||||
self.gen_call_indirect(*i, *t, &mut stat);
|
self.gen_call_indirect(i, t, &mut stat);
|
||||||
}
|
}
|
||||||
Inst::Drop => {
|
Inst::Drop => {
|
||||||
self.data.pop();
|
self.data.pop();
|
||||||
@ -519,71 +519,71 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
self.data.push(Expression::Select(Select { cond, a, b }));
|
self.data.push(Expression::Select(Select { cond, a, b }));
|
||||||
}
|
}
|
||||||
Inst::GetLocal(i) => {
|
Inst::GetLocal(var) => {
|
||||||
self.data.push(Expression::GetLocal(GetLocal { var: *i }));
|
self.data.push(Expression::GetLocal(GetLocal { var }));
|
||||||
}
|
}
|
||||||
Inst::SetLocal(i) => {
|
Inst::SetLocal(var) => {
|
||||||
let value = self.data.pop();
|
let value = self.data.pop();
|
||||||
|
|
||||||
self.data.gen_leak_pending(&mut stat);
|
self.data.gen_leak_pending(&mut stat);
|
||||||
stat.push(Statement::SetLocal(SetLocal { var: *i, value }));
|
stat.push(Statement::SetLocal(SetLocal { var, value }));
|
||||||
}
|
}
|
||||||
Inst::TeeLocal(i) => {
|
Inst::TeeLocal(var) => {
|
||||||
self.data.gen_leak_pending(&mut stat);
|
self.data.gen_leak_pending(&mut stat);
|
||||||
|
|
||||||
let value = self.data.pop();
|
let value = self.data.pop();
|
||||||
|
|
||||||
self.data.push(value.clone_recall());
|
self.data.push(value.clone_recall());
|
||||||
stat.push(Statement::SetLocal(SetLocal { var: *i, value }));
|
stat.push(Statement::SetLocal(SetLocal { var, value }));
|
||||||
}
|
}
|
||||||
Inst::GetGlobal(i) => {
|
Inst::GetGlobal(var) => {
|
||||||
self.data.push(Expression::GetGlobal(GetGlobal { var: *i }));
|
self.data.push(Expression::GetGlobal(GetGlobal { var }));
|
||||||
}
|
}
|
||||||
Inst::SetGlobal(i) => {
|
Inst::SetGlobal(var) => {
|
||||||
let value = self.data.pop();
|
let value = self.data.pop();
|
||||||
|
|
||||||
stat.push(Statement::SetGlobal(SetGlobal { var: *i, 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(Load::I32, o),
|
||||||
Inst::I64Load(_, o) => self.data.push_load(Load::I64, *o),
|
Inst::I64Load(_, o) => self.data.push_load(Load::I64, o),
|
||||||
Inst::F32Load(_, o) => self.data.push_load(Load::F32, *o),
|
Inst::F32Load(_, o) => self.data.push_load(Load::F32, o),
|
||||||
Inst::F64Load(_, o) => self.data.push_load(Load::F64, *o),
|
Inst::F64Load(_, o) => self.data.push_load(Load::F64, o),
|
||||||
Inst::I32Load8S(_, o) => self.data.push_load(Load::I32_I8, *o),
|
Inst::I32Load8S(_, o) => self.data.push_load(Load::I32_I8, o),
|
||||||
Inst::I32Load8U(_, o) => self.data.push_load(Load::I32_U8, *o),
|
Inst::I32Load8U(_, o) => self.data.push_load(Load::I32_U8, o),
|
||||||
Inst::I32Load16S(_, o) => self.data.push_load(Load::I32_I16, *o),
|
Inst::I32Load16S(_, o) => self.data.push_load(Load::I32_I16, o),
|
||||||
Inst::I32Load16U(_, o) => self.data.push_load(Load::I32_U16, *o),
|
Inst::I32Load16U(_, o) => self.data.push_load(Load::I32_U16, o),
|
||||||
Inst::I64Load8S(_, o) => self.data.push_load(Load::I64_I8, *o),
|
Inst::I64Load8S(_, o) => self.data.push_load(Load::I64_I8, o),
|
||||||
Inst::I64Load8U(_, o) => self.data.push_load(Load::I64_U8, *o),
|
Inst::I64Load8U(_, o) => self.data.push_load(Load::I64_U8, o),
|
||||||
Inst::I64Load16S(_, o) => self.data.push_load(Load::I64_I16, *o),
|
Inst::I64Load16S(_, o) => self.data.push_load(Load::I64_I16, o),
|
||||||
Inst::I64Load16U(_, o) => self.data.push_load(Load::I64_U16, *o),
|
Inst::I64Load16U(_, o) => self.data.push_load(Load::I64_U16, o),
|
||||||
Inst::I64Load32S(_, o) => self.data.push_load(Load::I64_I32, *o),
|
Inst::I64Load32S(_, o) => self.data.push_load(Load::I64_I32, o),
|
||||||
Inst::I64Load32U(_, o) => self.data.push_load(Load::I64_U32, *o),
|
Inst::I64Load32U(_, o) => self.data.push_load(Load::I64_U32, o),
|
||||||
Inst::I32Store(_, o) => self.data.gen_store(Store::I32, *o, &mut stat),
|
Inst::I32Store(_, o) => self.data.gen_store(Store::I32, o, &mut stat),
|
||||||
Inst::I64Store(_, o) => self.data.gen_store(Store::I64, *o, &mut stat),
|
Inst::I64Store(_, o) => self.data.gen_store(Store::I64, o, &mut stat),
|
||||||
Inst::F32Store(_, o) => self.data.gen_store(Store::F32, *o, &mut stat),
|
Inst::F32Store(_, o) => self.data.gen_store(Store::F32, o, &mut stat),
|
||||||
Inst::F64Store(_, o) => self.data.gen_store(Store::F64, *o, &mut stat),
|
Inst::F64Store(_, o) => self.data.gen_store(Store::F64, o, &mut stat),
|
||||||
Inst::I32Store8(_, o) => self.data.gen_store(Store::I32_N8, *o, &mut stat),
|
Inst::I32Store8(_, o) => self.data.gen_store(Store::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(Store::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(Store::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(Store::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(Store::I64_N32, o, &mut stat),
|
||||||
Inst::CurrentMemory(i) => {
|
Inst::CurrentMemory(memory) => {
|
||||||
self.data
|
self.data
|
||||||
.push(Expression::MemorySize(MemorySize { memory: *i }));
|
.push(Expression::MemorySize(MemorySize { memory }));
|
||||||
}
|
}
|
||||||
Inst::GrowMemory(i) => {
|
Inst::GrowMemory(memory) => {
|
||||||
let value = Box::new(self.data.pop());
|
let value = Box::new(self.data.pop());
|
||||||
|
|
||||||
// `MemoryGrow` is an expression *but* it has side effects
|
// `MemoryGrow` is an expression *but* it has side effects
|
||||||
self.data
|
self.data
|
||||||
.push(Expression::MemoryGrow(MemoryGrow { memory: *i, value }));
|
.push(Expression::MemoryGrow(MemoryGrow { memory, value }));
|
||||||
|
|
||||||
self.data.gen_leak_pending(&mut stat);
|
self.data.gen_leak_pending(&mut stat);
|
||||||
}
|
}
|
||||||
Inst::I32Const(v) => self.data.push_constant(*v),
|
Inst::I32Const(v) => self.data.push_constant(v),
|
||||||
Inst::I64Const(v) => self.data.push_constant(*v),
|
Inst::I64Const(v) => self.data.push_constant(v),
|
||||||
Inst::F32Const(v) => self.data.push_constant(*v),
|
Inst::F32Const(v) => self.data.push_constant(v),
|
||||||
Inst::F64Const(v) => self.data.push_constant(*v),
|
Inst::F64Const(v) => self.data.push_constant(v),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user