summaryrefslogtreecommitdiff
path: root/rust/src/mlil/function.rs
diff options
context:
space:
mode:
authorMichael Krasnitski <michael.krasnitski@gmail.com>2024-02-07 11:44:06 -0500
committerKyle Martin <krm504@nyu.edu>2024-03-18 17:46:37 -0400
commit5fcf6bc59ebc2110d053360d223e6570cdd2272c (patch)
treeed6eafd132cf53fd9e7105f541967324b4165db0 /rust/src/mlil/function.rs
parentbdd012af7941c7d17b97b3e69628a7bc7cc2411e (diff)
Refactor MLIL instructions
* Turn `MediumLevelILInstruction` into a struct with a `kind` field to indicate the instruction variant, and pull out the `function` and `address` fields from each variant to live in the top-level struct. * Make variant fields public, remove field getter methods and centralize lifting logic to happen all at once. Split tuple fields into individual named fields. * Move the `operands` method to `MediumLevelILLiftedInstruction`, and make it return an owned `Vec` of operands rather than a borrowed iterator.
Diffstat (limited to 'rust/src/mlil/function.rs')
-rw-r--r--rust/src/mlil/function.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/rust/src/mlil/function.rs b/rust/src/mlil/function.rs
index 8f5ed73d..16cc5102 100644
--- a/rust/src/mlil/function.rs
+++ b/rust/src/mlil/function.rs
@@ -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,
@@ -61,6 +61,10 @@ impl MediumLevelILFunction {
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 {
unsafe { BNGetMediumLevelILInstructionCount(self.handle) }
}