diff options
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/low_level_il/expression.rs | 30 | ||||
| -rw-r--r-- | rust/src/low_level_il/instruction.rs | 29 |
2 files changed, 59 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, 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, |
