From 82a211d4312a7ce1dd3e3800b15648620c65f48b Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Tue, 27 May 2025 11:47:19 -0700 Subject: [Rust] Allow mapping between SSA and non-SSA forms of instructions / expressions --- rust/src/low_level_il/expression.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'rust/src/low_level_il/expression.rs') 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 LowLevelILExpression<'_, M, SSA, R> +where + M: FunctionMutability, + R: ExpressionResultType, +{ + pub fn non_ssa_form<'func>( + &self, + non_ssa: &'func LowLevelILFunction, + ) -> 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 LowLevelILExpression<'_, M, NonSSA, R> +where + M: FunctionMutability, + R: ExpressionResultType, +{ + pub fn ssa_form<'func>( + &self, + ssa: &'func LowLevelILFunction, + ) -> 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, -- cgit v1.3.1