Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions rust/src/low_level_il/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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,
Expand Down
42 changes: 42 additions & 0 deletions rust/src/low_level_il/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,48 @@ 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> Clone for LowLevelILInstruction<'_, M, F>
where
M: FunctionMutability,
F: FunctionForm,
{
fn clone(&self) -> Self {
Self {
function: self.function,
index: self.index,
}
}
}

impl<M, F> Debug for LowLevelILInstruction<'_, M, F>
where
M: FunctionMutability,
Expand Down
Loading