From 2fcacc55d5466a7d17bdc0b3ce988772aa6d0653 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Thu, 21 Jan 2021 18:35:20 +0000 Subject: cargo fmt and all my changes --- rust/src/llil/function.rs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'rust/src/llil/function.rs') diff --git a/rust/src/llil/function.rs b/rust/src/llil/function.rs index ac50e72c..adc39f13 100644 --- a/rust/src/llil/function.rs +++ b/rust/src/llil/function.rs @@ -1,6 +1,20 @@ +// Copyright 2021 Vector 35 Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use binaryninjacore_sys::BNFreeLowLevelILFunction; use binaryninjacore_sys::BNLowLevelILFunction; use binaryninjacore_sys::BNNewLowLevelILFunctionReference; -use binaryninjacore_sys::BNFreeLowLevelILFunction; use std::borrow::Borrow; use std::marker::PhantomData; @@ -19,7 +33,6 @@ pub trait FunctionMutability: 'static {} impl FunctionMutability for Mutable {} impl FunctionMutability for Finalized {} - #[derive(Copy, Clone, Debug)] pub struct LiftedNonSSA; #[derive(Copy, Clone, Debug)] @@ -38,7 +51,6 @@ pub trait FunctionForm: 'static {} impl FunctionForm for SSA {} impl FunctionForm for NonSSA {} - pub struct Function { pub(crate) borrower: A::Handle, pub(crate) handle: *mut BNLowLevelILFunction, @@ -68,7 +80,7 @@ impl<'func, A, M, F> Function where A: 'func + Architecture, M: FunctionMutability, - F: FunctionForm + F: FunctionForm, { pub(crate) unsafe fn from_raw(borrower: A::Handle, handle: *mut BNLowLevelILFunction) -> Self { debug_assert!(!handle.is_null()); @@ -87,8 +99,8 @@ where } pub fn instruction_at>(&self, loc: L) -> Option> { - use binaryninjacore_sys::BNLowLevelILGetInstructionStart; use binaryninjacore_sys::BNGetLowLevelILInstructionCount; + use binaryninjacore_sys::BNLowLevelILGetInstructionStart; let loc: Location = loc.into(); let arch_handle = loc.arch.unwrap_or_else(|| *self.arch().as_ref()); @@ -112,7 +124,7 @@ where use binaryninjacore_sys::BNGetLowLevelILInstructionCount; if instr_idx >= BNGetLowLevelILInstructionCount(self.handle) { panic!("instruction index {} out of bounds", instr_idx); - } + } Instruction { function: self, @@ -127,7 +139,6 @@ where BNGetLowLevelILInstructionCount(self.handle) } } - } // LLIL basic blocks are not available until the function object @@ -136,7 +147,7 @@ where impl<'func, A, F> Function where A: 'func + Architecture, - F: FunctionForm + F: FunctionForm, { pub fn basic_blocks(&self) -> Array>> { use binaryninjacore_sys::BNGetLowLevelILBasicBlockList; @@ -155,7 +166,7 @@ impl<'func, A, M, F> ToOwned for Function where A: 'func + Architecture, M: FunctionMutability, - F: FunctionForm + F: FunctionForm, { type Owned = Ref; @@ -164,12 +175,11 @@ where } } - unsafe impl<'func, A, M, F> RefCountable for Function where A: 'func + Architecture, M: FunctionMutability, - F: FunctionForm + F: FunctionForm, { unsafe fn inc_ref(handle: &Self) -> Ref { Ref::new(Self { -- cgit v1.3.1