diff options
| author | Mark Rowe <mrowe@bdash.net.nz> | 2025-05-27 12:34:30 -0700 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-05-30 19:17:10 -0400 |
| commit | bcec9c097cd913a06d2877d958cc53065476a82c (patch) | |
| tree | e8e11f937aaa79e1be59f1fd6843faf9fec398bd /rust/src/low_level_il/instruction.rs | |
| parent | 4e8060d23deec18f5b6985b918d7163f65c01e32 (diff) | |
[Rust] Add LowLevelILInstruction::basic_block / LowLevelILFunction::basic_block_containing_index
Diffstat (limited to 'rust/src/low_level_il/instruction.rs')
| -rw-r--r-- | rust/src/low_level_il/instruction.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/src/low_level_il/instruction.rs b/rust/src/low_level_il/instruction.rs index ba8184e4..652706ea 100644 --- a/rust/src/low_level_il/instruction.rs +++ b/rust/src/low_level_il/instruction.rs @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::basic_block::BasicBlock; +use crate::rc::Ref; + +use super::block::LowLevelILBlock; use super::operation; use super::operation::Operation; use super::VisitorAction; @@ -99,6 +103,12 @@ where pub fn into_raw(&self) -> BNLowLevelILInstruction { unsafe { BNGetLowLevelILByIndex(self.function.handle, self.expr_idx().0) } } + + /// Returns the [`BasicBlock`] containing the given [`LowLevelILInstruction`]. + pub fn basic_block(&self) -> Option<Ref<BasicBlock<LowLevelILBlock<'func, M, F>>>> { + // TODO: We might be able to .expect this if we guarantee that self.index is valid. + self.function.basic_block_containing_index(self.index) + } } impl<'func, M> LowLevelILInstruction<'func, M, NonSSA> |
