File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
crates/wasmi/src/engine/translator/func2 Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -109,8 +109,7 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
109
109
Ok ( ( ) )
110
110
}
111
111
112
- #[ allow( unused_variables) ] // TODO: remove
113
- fn visit_if ( & mut self , _block_ty : wasmparser:: BlockType ) -> Self :: Output {
112
+ fn visit_if ( & mut self , block_ty : wasmparser:: BlockType ) -> Self :: Output {
114
113
if !self . reachable {
115
114
self . stack . push_unreachable ( UnreachableControlFrame :: If ) ?;
116
115
return Ok ( ( ) ) ;
@@ -130,14 +129,18 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
130
129
let consume_fuel_instr = self . stack . consume_fuel_instr ( ) ;
131
130
( reachability, consume_fuel_instr)
132
131
}
133
- operand => {
134
- let condition = self . layout . operand_to_reg ( operand) ?;
132
+ _ => {
135
133
let else_label = self . labels . new_label ( ) ;
134
+ self . translate_br_eqz ( condition, else_label) ?;
136
135
let reachability = IfReachability :: Both { else_label } ;
137
- todo ! ( )
136
+ let consume_fuel_instr = self . instrs . push_consume_fuel_instr ( ) ?;
137
+ ( reachability, consume_fuel_instr)
138
138
}
139
139
} ;
140
- todo ! ( )
140
+ let block_ty = BlockType :: new ( block_ty, & self . module ) ;
141
+ self . stack
142
+ . push_if ( block_ty, end_label, reachability, consume_fuel_instr) ?;
143
+ Ok ( ( ) )
141
144
}
142
145
143
146
fn visit_else ( & mut self ) -> Self :: Output {
You can’t perform that action at this time.
0 commit comments