Skip to main content

Interpreter

Trait Interpreter 

Source
pub trait Interpreter {
    type V: DomainValue;
    type M: DomainMemory<V = Self::V>;

    // Required methods
    fn ctx(&self) -> &Context<'_>;
    fn memory(&mut self) -> &mut Self::M;
    fn get_value(&mut self, id: ValueId) -> Result<Self::V, EmulatorErrorKind>;

    // Provided methods
    fn get_varnode_value(
        &mut self,
        id: VarnodeId,
    ) -> Result<Self::V, EmulatorErrorKind> { ... }
    fn set_varnode_value(
        &mut self,
        id: VarnodeId,
        value: Self::V,
    ) -> Result<(), EmulatorErrorKind> { ... }
    fn get_register_value(
        &mut self,
        reg_id: RegisterId,
    ) -> Result<Self::V, EmulatorErrorKind> { ... }
    fn set_register_value(
        &mut self,
        reg_id: RegisterId,
        value: Self::V,
    ) -> Result<(), EmulatorErrorKind> { ... }
    fn interpret_(
        &mut self,
        insn: &InstructionRef<'_, '_>,
        mnemonic: &Mnemonic,
    ) -> Result<Option<Self::V>, EmulatorErrorKind> { ... }
    fn interpret(
        &mut self,
        insn: InstructionRef<'_, '_>,
        mnemonic: &Mnemonic,
    ) -> Result<Option<Self::V>> { ... }
}

Required Associated Types§

Source

type V: DomainValue

Source

type M: DomainMemory<V = Self::V>

Required Methods§

Source

fn ctx(&self) -> &Context<'_>

Source

fn memory(&mut self) -> &mut Self::M

Source

fn get_value(&mut self, id: ValueId) -> Result<Self::V, EmulatorErrorKind>

Gets the value of the given value ID, if it exists in the context.

Provided Methods§

Source

fn get_varnode_value( &mut self, id: VarnodeId, ) -> Result<Self::V, EmulatorErrorKind>

Reads the value of a varnode from the emulated memory space.

Source

fn set_varnode_value( &mut self, id: VarnodeId, value: Self::V, ) -> Result<(), EmulatorErrorKind>

Writes a value to a varnode in the emulated memory space.

Source

fn get_register_value( &mut self, reg_id: RegisterId, ) -> Result<Self::V, EmulatorErrorKind>

Returns the value of the given register, if it exists in the context.

Source

fn set_register_value( &mut self, reg_id: RegisterId, value: Self::V, ) -> Result<(), EmulatorErrorKind>

Sets the value of the given register, if it exists in the context.

Source

fn interpret_( &mut self, insn: &InstructionRef<'_, '_>, mnemonic: &Mnemonic, ) -> Result<Option<Self::V>, EmulatorErrorKind>

Gets the value of the given instruction, if it has one. This is used for instructions that produce a value, such as copy, load, and binary operations.

Source

fn interpret( &mut self, insn: InstructionRef<'_, '_>, mnemonic: &Mnemonic, ) -> Result<Option<Self::V>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'ctx, M: EmulatorMemory> Interpreter for Emulator<'ctx, M>