summaryrefslogtreecommitdiff
path: root/rust/src/llil/function.rs
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2021-01-21 18:35:20 +0000
committerKyleMiles <krm504@nyu.edu>2021-01-21 19:07:07 +0000
commit2fcacc55d5466a7d17bdc0b3ce988772aa6d0653 (patch)
tree9d0f2ba19117843575936f2b93e0b6a578a84dc8 /rust/src/llil/function.rs
parenta0da07c5c2860a5bd69921d38e438bbc1d43912f (diff)
cargo fmt and all my changes
Diffstat (limited to 'rust/src/llil/function.rs')
-rw-r--r--rust/src/llil/function.rs32
1 files changed, 21 insertions, 11 deletions
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<V: NonSSAVariant> FunctionForm for NonSSA<V> {}
-
pub struct Function<A: Architecture, M: FunctionMutability, F: FunctionForm> {
pub(crate) borrower: A::Handle,
pub(crate) handle: *mut BNLowLevelILFunction,
@@ -68,7 +80,7 @@ impl<'func, A, M, F> Function<A, M, F>
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<L: Into<Location>>(&self, loc: L) -> Option<Instruction<A, M, F>> {
- 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<A, Finalized, F>
where
A: 'func + Architecture,
- F: FunctionForm
+ F: FunctionForm,
{
pub fn basic_blocks(&self) -> Array<BasicBlock<LowLevelBlock<A, Finalized, F>>> {
use binaryninjacore_sys::BNGetLowLevelILBasicBlockList;
@@ -155,7 +166,7 @@ impl<'func, A, M, F> ToOwned for Function<A, M, F>
where
A: 'func + Architecture,
M: FunctionMutability,
- F: FunctionForm
+ F: FunctionForm,
{
type Owned = Ref<Self>;
@@ -164,12 +175,11 @@ where
}
}
-
unsafe impl<'func, A, M, F> RefCountable for Function<A, M, F>
where
A: 'func + Architecture,
M: FunctionMutability,
- F: FunctionForm
+ F: FunctionForm,
{
unsafe fn inc_ref(handle: &Self) -> Ref<Self> {
Ref::new(Self {