summaryrefslogtreecommitdiff
path: root/rust/src/low_level_il/instruction.rs
diff options
context:
space:
mode:
authorMark Rowe <mrowe@bdash.net.nz>2025-05-27 11:47:19 -0700
committerMason Reed <mason@vector35.com>2025-05-30 19:17:10 -0400
commit82a211d4312a7ce1dd3e3800b15648620c65f48b (patch)
tree9e2a156d0cf313d4f4ec508f26684422b286369a /rust/src/low_level_il/instruction.rs
parenta1b94836aaada389a88062541b1ca431fd9fc9ee (diff)
[Rust] Allow mapping between SSA and non-SSA forms of instructions / expressions
Diffstat (limited to 'rust/src/low_level_il/instruction.rs')
-rw-r--r--rust/src/low_level_il/instruction.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/rust/src/low_level_il/instruction.rs b/rust/src/low_level_il/instruction.rs
index df9d1839..ba8184e4 100644
--- a/rust/src/low_level_il/instruction.rs
+++ b/rust/src/low_level_il/instruction.rs
@@ -101,6 +101,35 @@ where
}
}
+impl<'func, M> LowLevelILInstruction<'func, M, NonSSA>
+where
+ M: FunctionMutability,
+{
+ pub fn ssa_form(
+ &self,
+ ssa: &'func LowLevelILFunction<M, SSA>,
+ ) -> LowLevelILInstruction<'func, M, SSA> {
+ use binaryninjacore_sys::BNGetLowLevelILSSAInstructionIndex;
+ let idx = unsafe { BNGetLowLevelILSSAInstructionIndex(self.function.handle, self.index.0) };
+ LowLevelILInstruction::new(ssa, LowLevelInstructionIndex(idx))
+ }
+}
+
+impl<'func, M> LowLevelILInstruction<'func, M, SSA>
+where
+ M: FunctionMutability,
+{
+ pub fn non_ssa_form(
+ &self,
+ non_ssa: &'func LowLevelILFunction<M, NonSSA>,
+ ) -> LowLevelILInstruction<'func, M, NonSSA> {
+ use binaryninjacore_sys::BNGetLowLevelILNonSSAInstructionIndex;
+ let idx =
+ unsafe { BNGetLowLevelILNonSSAInstructionIndex(self.function.handle, self.index.0) };
+ LowLevelILInstruction::new(non_ssa, LowLevelInstructionIndex(idx))
+ }
+}
+
impl<M, F> Debug for LowLevelILInstruction<'_, M, F>
where
M: FunctionMutability,