File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub struct VM {
2121 pub ret : Value ,
2222 pub platform : Option < Box < dyn Platform > > ,
2323 pub global_scope : Scope ,
24+ pub halted : bool ,
2425 pub ( crate ) bfas_stack_start : Vec < i64 > ,
2526 pub ( crate ) bfas_stack_end : Vec < i64 > ,
2627}
@@ -38,6 +39,7 @@ impl VM {
3839 ret : Value :: Null ( ) ,
3940 platform : None ,
4041 global_scope : Scope :: new ( ) ,
42+ halted : false ,
4143 bfas_stack_start : Vec :: new ( ) ,
4244 bfas_stack_end : Vec :: new ( ) ,
4345 } ;
@@ -136,19 +138,19 @@ impl VM {
136138 }
137139
138140 pub fn step ( & mut self ) -> bool {
139- if ! self . error . is_empty ( ) {
141+ if self . halted {
140142 return false ;
141143 }
142144
143145 let module_index = self . pc . get_high ( ) as usize ;
144146 let opcode_index = self . pc . get_low ( ) ;
145147 if module_index >= self . modules . len ( ) {
146- return false ;
148+ self . halted = true ;
147149 }
148150
149151 let opcodes = core:: mem:: take ( & mut self . modules [ module_index] . opcodes ) ;
150152 if opcode_index >= opcodes. len ( ) as u32 {
151- return false ;
153+ self . halted = true ;
152154 }
153155
154156 let opcode = & opcodes[ opcode_index as usize ] ;
Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ impl VM {
378378 if !self . call_stack . is_empty ( ) {
379379 self . pc = self . call_stack . pop ( ) . unwrap ( ) ;
380380 } else {
381- self . pc . set_high ( u32 :: MAX ) ;
381+ self . halted = true ;
382382 }
383383 }
384384 }
You can’t perform that action at this time.
0 commit comments