use core::fmt;
use capstone_sys::cs_evm;
pub use capstone_sys::evm_insn_group as EvmInsnGroup;
pub use capstone_sys::evm_insn as EvmInsn;
pub use crate::arch::arch_builder::evm::*;
use crate::arch::DetailsArchInsn;
pub struct EvmInsnDetail<'a>(pub(crate) &'a cs_evm);
impl<'a> EvmInsnDetail<'a> {
pub fn popped_items(&self) -> u8 {
self.0.pop
}
pub fn pushed_items(&self) -> u8 {
self.0.push
}
pub fn fee(&self) -> u32 {
self.0.fee as u32
}
}
impl_PartialEq_repr_fields!(EvmInsnDetail<'a> [ 'a ];
popped_items, pushed_items, fee
);
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct EvmOperand(());
#[derive(Clone)]
pub struct EvmOperandIterator(());
impl EvmOperandIterator {
fn new() -> EvmOperandIterator {
EvmOperandIterator(())
}
}
impl Iterator for EvmOperandIterator {
type Item = EvmOperand;
fn next(&mut self) -> Option<Self::Item> {
None
}
}
impl ExactSizeIterator for EvmOperandIterator {
fn len(&self) -> usize {
0
}
}
impl PartialEq for EvmOperandIterator {
fn eq(&self, _other: &EvmOperandIterator) -> bool {
false
}
}
impl fmt::Debug for EvmOperandIterator {
fn fmt(&self, fmt: &mut fmt::Formatter) -> ::core::fmt::Result {
fmt.debug_struct("EvmOperandIterator").finish()
}
}
impl<'a> fmt::Debug for EvmInsnDetail<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> ::core::fmt::Result {
fmt.debug_struct("EvmInsnDetail")
.field("cs_evm", &(self.0 as *const cs_evm))
.finish()
}
}
impl<'a> DetailsArchInsn for EvmInsnDetail<'a> {
type OperandIterator = EvmOperandIterator;
type Operand = EvmOperand;
fn operands(&self) -> EvmOperandIterator {
EvmOperandIterator::new()
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_evm_detail() {
let cs_evm = cs_evm {
pop: 1,
push: 2,
fee: 42,
};
let d = EvmInsnDetail(&cs_evm);
assert_eq!(d.popped_items(), 1);
assert_eq!(d.pushed_items(), 2);
assert_eq!(d.fee(), 42);
}
}