summaryrefslogtreecommitdiff
path: root/rust/src/low_level_il/expression.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/expression.rs
parenta1b94836aaada389a88062541b1ca431fd9fc9ee (diff)
[Rust] Allow mapping between SSA and non-SSA forms of instructions / expressions
Diffstat (limited to 'rust/src/low_level_il/expression.rs')
-rw-r--r--rust/src/low_level_il/expression.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/rust/src/low_level_il/expression.rs b/rust/src/low_level_il/expression.rs
index 81c4e57d..ce9d5bba 100644
--- a/rust/src/low_level_il/expression.rs
+++ b/rust/src/low_level_il/expression.rs
@@ -120,6 +120,36 @@ where
}
}
+impl<M, R> LowLevelILExpression<'_, M, SSA, R>
+where
+ M: FunctionMutability,
+ R: ExpressionResultType,
+{
+ pub fn non_ssa_form<'func>(
+ &self,
+ non_ssa: &'func LowLevelILFunction<M, NonSSA>,
+ ) -> LowLevelILExpression<'func, M, NonSSA, R> {
+ use binaryninjacore_sys::BNGetLowLevelILNonSSAExprIndex;
+ let idx = unsafe { BNGetLowLevelILNonSSAExprIndex(self.function.handle, self.index.0) };
+ LowLevelILExpression::new(non_ssa, LowLevelExpressionIndex(idx))
+ }
+}
+
+impl<M, R> LowLevelILExpression<'_, M, NonSSA, R>
+where
+ M: FunctionMutability,
+ R: ExpressionResultType,
+{
+ pub fn ssa_form<'func>(
+ &self,
+ ssa: &'func LowLevelILFunction<M, SSA>,
+ ) -> LowLevelILExpression<'func, M, SSA, R> {
+ use binaryninjacore_sys::BNGetLowLevelILSSAExprIndex;
+ let idx = unsafe { BNGetLowLevelILSSAExprIndex(self.function.handle, self.index.0) };
+ LowLevelILExpression::new(ssa, LowLevelExpressionIndex(idx))
+ }
+}
+
impl<'func, M> ExpressionHandler<'func, M, SSA> for LowLevelILExpression<'func, M, SSA, ValueExpr>
where
M: FunctionMutability,