pub fn step(&mut self) -> ExecResult<ProcessAction<'a>> {
        let mut result = ProcessAction::None;
        let mut do_step = true;
        match self.current_instruction() {
            Instruction::I32Const(val) => {
                self.stack_push(val);
            }
            Instruction::Call { function } => {
                if let Some(import) = self.wasm.get_import(function) {
                    result = ProcessAction::CallExtern {
                        function: import.name.name,
                        args: core::mem::take(&mut self.stack),
                    };
                } else {
                    unimplemented!("Calling local function");
                }
            }
            Instruction::LocalSet(idx) => {
                let ProgramCounter { locals, .. } = self.program_counter.last_mut().unwrap();
                locals[idx.0] = self.stack.pop().unwrap();
            }
            Instruction::LocalGet(idx) => {
                let ProgramCounter { locals, .. } = self.program_counter.last().unwrap();
                let val = locals[idx.0].clone();
                self.stack_push(val);
            }
            Instruction::Loop { bt, inner: _ } => {
                assert_eq!(bt, BlockType::Empty);
                self.program_counter.last_mut().unwrap().idx.push(0);
                do_step = false;
            }
            Instruction::Branch { mut index } => {
                let ProgramCounter { idx, func, .. } = self.program_counter.last_mut().unwrap();
                let code = self.wasm.get_code(*func);
                loop {
                    idx.pop();
                    if index.0 > 0 {
                        index.0 -= 1;
                    } else {
                        break;
                    }
                }
                match Self::find_instruction(&code.expr, idx).unwrap().clone() {
                    Instruction::Loop { bt, .. } => {
                        assert_eq!(bt, BlockType::Empty);
                        idx.push(0);
                        do_step = false;
                    }
                    x if x.get_child_instructions().is_none() => {}
                    x => unimplemented!("Loop handling on {:?}", x),
                }
            }
            x => unimplemented!("Unimplemented instruction: {:?}", x),
        }
        if do_step {
            *self
                .program_counter
                .last_mut()
                .unwrap()
                .idx
                .last_mut()
                .unwrap() += 1;
        }
        Ok(result)
    }
/// Execute a single step in the wasm runner. See [`ProcessAction`] for correct handling of the return value.
Execute a single step in the wasm runner. See [`ProcessAction`] for correct handling of the return value.
Execute a single step in the wasm runner . See [ ` ProcessAction ` ] for correct handling of the return value .
pub fn step(&mut self) -> ExecResult<ProcessAction<'a>> {
        let mut result = ProcessAction::None;
        let mut do_step = true;
        match self.current_instruction() {
            Instruction::I32Const(val) => {
                self.stack_push(val);
            }
            Instruction::Call { function } => {
                if let Some(import) = self.wasm.get_import(function) {
                    result = ProcessAction::CallExtern {
                        function: import.name.name,
                        args: core::mem::take(&mut self.stack),
                    };
                } else {
                    unimplemented!("Calling local function");
                }
            }
            Instruction::LocalSet(idx) => {
                let ProgramCounter { locals, .. } = self.program_counter.last_mut().unwrap();
                locals[idx.0] = self.stack.pop().unwrap();
            }
            Instruction::LocalGet(idx) => {
                let ProgramCounter { locals, .. } = self.program_counter.last().unwrap();
                let val = locals[idx.0].clone();
                self.stack_push(val);
            }
            Instruction::Loop { bt, inner: _ } => {
                assert_eq!(bt, BlockType::Empty);
                self.program_counter.last_mut().unwrap().idx.push(0);
                do_step = false;
            }
            Instruction::Branch { mut index } => {
                let ProgramCounter { idx, func, .. } = self.program_counter.last_mut().unwrap();
                let code = self.wasm.get_code(*func);
                loop {
                    idx.pop();
                    if index.0 > 0 {
                        index.0 -= 1;
                    } else {
                        break;
                    }
                }
                match Self::find_instruction(&code.expr, idx).unwrap().clone() {
                    Instruction::Loop { bt, .. } => {
                        assert_eq!(bt, BlockType::Empty);
                        idx.push(0);
                        do_step = false;
                    }
                    x if x.get_child_instructions().is_none() => {}
                    x => unimplemented!("Loop handling on {:?}", x),
                }
            }
            x => unimplemented!("Unimplemented instruction: {:?}", x),
        }
        if do_step {
            *self
                .program_counter
                .last_mut()
                .unwrap()
                .idx
                .last_mut()
                .unwrap() += 1;
        }
        Ok(result)
    }
pub fn step ( & mut self ) -> ExecResult < ProcessAction < ' a > > { let mut result = ProcessAction :: None ; let mut do_step = true ; match self . current_instruction ( ) { Instruction :: I32Const ( val ) => { self . stack_push ( val ) ; } Instruction :: Call { function } => { if let Some ( import ) = self . wasm . get_import ( function ) { result = ProcessAction :: CallExtern { function : import . name . name , args : core :: mem :: take ( & mut self . stack ) , } ; } else { unimplemented ! ( " " ) ; } } Instruction :: LocalSet ( idx ) => { let ProgramCounter { locals , .. } = self . program_counter . last_mut ( ) . unwrap ( ) ; locals [ idx . 0 ] = self . stack . pop ( ) . unwrap ( ) ; } Instruction :: LocalGet ( idx ) => { let ProgramCounter { locals , .. } = self . program_counter . last ( ) . unwrap ( ) ; let val = locals [ idx . 0 ] . clone ( ) ; self . stack_push ( val ) ; } Instruction :: Loop { bt , inner : _ } => { assert_eq ! ( bt BlockType Empty ) ; self . program_counter . last_mut ( ) . unwrap ( ) . idx . push ( 0 ) ; do_step = false ; } Instruction :: Branch { mut index } => { let ProgramCounter { idx , func , .. } = self . program_counter . last_mut ( ) . unwrap ( ) ; let code = self . wasm . get_code ( * func ) ; loop { idx . pop ( ) ; if index . 0 > 0 { index . 0 -= 1 ; } else { break ; } } match Self :: find_instruction ( & code . expr , idx ) . unwrap ( ) . clone ( ) { Instruction :: Loop { bt , .. } => { assert_eq ! ( bt BlockType Empty ) ; idx . push ( 0 ) ; do_step = false ; } x if x . get_child_instructions ( ) . is_none ( ) => { } x => unimplemented ! ( " " x ) , } } x => unimplemented ! ( " " x ) , } if do_step { * self . program_counter . last_mut ( ) . unwrap ( ) . idx . last_mut ( ) . unwrap ( ) += 1 ; } Ok ( result ) }
Execute a single step in the wasm runner.
Execute a single step in the wasm runner .
&mut self
&mut self