revm_interpreter/interpreter/
loop_control.rsuse crate::interpreter_types::LoopControl as LoopControlTrait;
use crate::{Gas, InstructionResult, InterpreterAction};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LoopControl {
pub instruction_result: InstructionResult,
pub next_action: InterpreterAction,
pub gas: Gas,
}
impl LoopControl {
pub fn new(gas_limit: u64) -> Self {
Self {
instruction_result: InstructionResult::Continue,
next_action: InterpreterAction::None,
gas: Gas::new(gas_limit),
}
}
}
impl LoopControlTrait for LoopControl {
fn set_instruction_result(&mut self, result: InstructionResult) {
self.instruction_result = result;
}
fn set_next_action(&mut self, action: InterpreterAction, result: InstructionResult) {
self.next_action = action;
self.instruction_result = result;
}
fn gas(&mut self) -> &mut Gas {
&mut self.gas
}
fn instruction_result(&self) -> InstructionResult {
self.instruction_result
}
fn take_next_action(&mut self) -> InterpreterAction {
core::mem::take(&mut self.next_action)
}
}