revm_interpreter/
interpreter_action.rs1mod call_inputs;
2mod call_outcome;
3mod create_inputs;
4mod create_outcome;
5mod eof_create_inputs;
6
7pub use call_inputs::{CallInput, CallInputs, CallScheme, CallValue};
8pub use call_outcome::CallOutcome;
9pub use create_inputs::CreateInputs;
10pub use create_outcome::CreateOutcome;
11pub use eof_create_inputs::{EOFCreateInputs, EOFCreateKind};
12use primitives::Bytes;
13
14use crate::{Gas, InstructionResult, InterpreterResult};
15use std::boxed::Box;
16
17#[derive(Clone, Debug, PartialEq, Eq)]
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19pub enum FrameInput {
20 Call(Box<CallInputs>),
23 Create(Box<CreateInputs>),
25 EOFCreate(Box<EOFCreateInputs>),
27}
28
29impl AsMut<Self> for FrameInput {
30 fn as_mut(&mut self) -> &mut Self {
31 self
32 }
33}
34
35#[derive(Clone, Debug, PartialEq, Eq)]
36#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
37pub enum InterpreterAction {
38 NewFrame(FrameInput),
40 Return(InterpreterResult),
42}
43
44impl InterpreterAction {
45 pub fn is_call(&self) -> bool {
47 matches!(self, InterpreterAction::NewFrame(FrameInput::Call(..)))
48 }
49
50 pub fn is_create(&self) -> bool {
52 matches!(self, InterpreterAction::NewFrame(FrameInput::Create(..)))
53 }
54
55 pub fn is_return(&self) -> bool {
57 matches!(self, InterpreterAction::Return { .. })
58 }
59
60 pub fn into_result_return(self) -> Option<InterpreterResult> {
64 match self {
65 InterpreterAction::Return(result) => Some(result),
66 _ => None,
67 }
68 }
69
70 pub fn instruction_result(&self) -> Option<InstructionResult> {
74 match self {
75 InterpreterAction::Return(result) => Some(result.result),
76 _ => None,
77 }
78 }
79
80 pub fn new_frame(frame_input: FrameInput) -> Self {
82 Self::NewFrame(frame_input)
83 }
84
85 pub fn new_halt(result: InstructionResult, gas: Gas) -> Self {
87 Self::Return(InterpreterResult::new(result, Bytes::new(), gas))
88 }
89
90 pub fn new_return(result: InstructionResult, output: Bytes, gas: Gas) -> Self {
92 Self::Return(InterpreterResult::new(result, output, gas))
93 }
94
95 pub fn new_stop() -> Self {
97 Self::Return(InterpreterResult::new(
98 InstructionResult::Stop,
99 Bytes::new(),
100 Gas::new(0),
101 ))
102 }
103}