use derive_more::Display;
use crate::{
instruction::InstructionMeta,
opcode::{Mnemonic, OpCode},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Keccak256;
impl InstructionMeta for Keccak256 {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::KECCAK256)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Create;
impl InstructionMeta for Create {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::CREATE)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Call;
impl InstructionMeta for Call {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::CALL)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct CallCode;
impl InstructionMeta for CallCode {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::CALLCODE)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Return;
impl InstructionMeta for Return {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::RETURN)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct DelegateCall;
impl InstructionMeta for DelegateCall {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::DELEGATECALL)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Create2;
impl InstructionMeta for Create2 {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::CREATE2)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct StaticCall;
impl InstructionMeta for StaticCall {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::STATICCALL)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Revert;
impl InstructionMeta for Revert {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::REVERT)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Invalid;
impl InstructionMeta for Invalid {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::INVALID)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct SelfDestruct;
impl InstructionMeta for SelfDestruct {
fn opcode(&self) -> OpCode {
OpCode::Known(Mnemonic::SELFDESTRUCT)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[display("{}", self.opcode())]
pub struct Unknown(
pub u8,
);
impl InstructionMeta for Unknown {
fn opcode(&self) -> OpCode {
OpCode::Unknown(self.0)
}
}