File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
crates/wasmi/src/engine/translator/func2 Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,21 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
84
84
Ok ( ( ) )
85
85
}
86
86
87
- fn visit_loop ( & mut self , _block_ty : wasmparser:: BlockType ) -> Self :: Output {
88
- todo ! ( )
87
+ fn visit_loop ( & mut self , block_ty : wasmparser:: BlockType ) -> Self :: Output {
88
+ if !self . reachable {
89
+ self . stack . push_unreachable ( UnreachableControlFrame :: Loop ) ?;
90
+ return Ok ( ( ) ) ;
91
+ }
92
+ let block_ty = BlockType :: new ( block_ty, & self . module ) ;
93
+ let len_params = block_ty. len_params ( & self . engine ) ;
94
+ let continue_label = self . labels . new_label ( ) ;
95
+ let consume_fuel = self . stack . consume_fuel_instr ( ) ;
96
+ self . copy_branch_params ( usize:: from ( len_params) , consume_fuel) ?;
97
+ self . pin_label ( continue_label) ;
98
+ let consume_fuel = self . instrs . push_consume_fuel_instr ( ) ?;
99
+ self . stack
100
+ . push_loop ( block_ty, continue_label, consume_fuel) ?;
101
+ Ok ( ( ) )
89
102
}
90
103
91
104
fn visit_if ( & mut self , _block_ty : wasmparser:: BlockType ) -> Self :: Output {
You can’t perform that action at this time.
0 commit comments