This commit is contained in:
Rairosu
2024-04-02 18:52:06 +02:00
parent e7c2b2bd2a
commit 2feb739d75
42 changed files with 4785 additions and 2675 deletions

View File

@@ -14,7 +14,7 @@ use crate::function::Function;
use crate::function::Location;
use crate::rc::{Array, Ref, RefCountable};
use super::{MediumLevelILBlock, MediumLevelILInstruction};
use super::{MediumLevelILBlock, MediumLevelILInstruction, MediumLevelILLiftedInstruction};
pub struct MediumLevelILFunction {
pub(crate) handle: *mut BNMediumLevelILFunction,
@@ -26,21 +26,21 @@ unsafe impl Sync for MediumLevelILFunction {}
impl Eq for MediumLevelILFunction {}
impl PartialEq for MediumLevelILFunction {
fn eq(&self, rhs: &Self) -> bool {
self.handle == rhs.handle
self.get_function().eq(&rhs.get_function())
}
}
impl Hash for MediumLevelILFunction {
fn hash<H: Hasher>(&self, state: &mut H) {
self.handle.hash(state);
self.get_function().hash(state)
}
}
impl MediumLevelILFunction {
pub(crate) unsafe fn from_raw(handle: *mut BNMediumLevelILFunction) -> Self {
pub(crate) unsafe fn ref_from_raw(handle: *mut BNMediumLevelILFunction) -> Ref<Self> {
debug_assert!(!handle.is_null());
Self { handle }
Self { handle }.to_owned()
}
pub fn instruction_at<L: Into<Location>>(&self, loc: L) -> Option<MediumLevelILInstruction> {
@@ -53,12 +53,16 @@ impl MediumLevelILFunction {
if expr_idx >= self.instruction_count() {
None
} else {
Some(MediumLevelILInstruction::new(self, expr_idx))
Some(MediumLevelILInstruction::new(self.to_owned(), expr_idx))
}
}
pub fn instruction_from_idx(&self, expr_idx: usize) -> MediumLevelILInstruction {
MediumLevelILInstruction::new(self, expr_idx)
MediumLevelILInstruction::new(self.to_owned(), expr_idx)
}
pub fn lifted_instruction_from_idx(&self, expr_idx: usize) -> MediumLevelILLiftedInstruction {
self.instruction_from_idx(expr_idx).lift()
}
pub fn instruction_count(&self) -> usize {