File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -279,7 +279,8 @@ impl Processor {
279279 // casting to usize truncates the fractional part
280280 // so this is equivalent to `while self.state.accumulator >= 1.`
281281 for i in 0 ..( self . state . accumulator as usize ) {
282- if let InstructionResult :: Yield = self . step ( vm) {
282+ // SAFETY: self.state.enabled is always false if self.instructions is empty
283+ if let InstructionResult :: Yield = unsafe { self . step ( vm) } {
283284 self . state . accumulator -= ( i + 1 ) as f64 ;
284285 return ;
285286 }
@@ -289,8 +290,12 @@ impl Processor {
289290 self . state . accumulator = self . state . accumulator . fract ( ) ;
290291 }
291292
292- /// Do not call if the processor is disabled.
293- fn step ( & mut self , vm : & LogicVM ) -> InstructionResult {
293+ /// Executes a single instruction.
294+ ///
295+ /// # Safety
296+ ///
297+ /// Calling this method on a processor with no instructions is undefined behavior.
298+ pub unsafe fn step ( & mut self , vm : & LogicVM ) -> InstructionResult {
294299 let mut counter = self . state . counter ;
295300 if counter >= self . instructions . len ( ) {
296301 counter = 0 ;
You can’t perform that action at this time.
0 commit comments