@@ -4,28 +4,35 @@ use crate::function_guid;
44use binaryninja:: binary_view:: BinaryViewExt ;
55use binaryninja:: function:: Function as BNFunction ;
66use binaryninja:: low_level_il:: function:: { FunctionMutability , LowLevelILFunction , NonSSA } ;
7+ use binaryninja:: rc:: Ref as BNRef ;
78use binaryninja:: symbol:: Symbol as BNSymbol ;
89use std:: collections:: HashSet ;
910use uuid:: Uuid ;
1011use warp:: signature:: constraint:: Constraint ;
1112use warp:: signature:: function:: FunctionGUID ;
1213
14+ /// Try to get the cached function GUID from the metadata.
15+ ///
16+ /// If not cached, we will use `lifted_il_accessor` to retrieve the lifted IL and create the GUID.
17+ ///
18+ /// `lifted_il_accessor` exists as it is to allow the retrieval of a cached GUID without incurring
19+ /// the cost of building the IL (if it no longer exists).
1320pub fn cached_function_guid < M : FunctionMutability > (
1421 function : & BNFunction ,
15- lifted_il : & LowLevelILFunction < M , NonSSA > ,
16- ) -> FunctionGUID {
22+ lifted_il_accessor : impl Fn ( ) -> Option < BNRef < LowLevelILFunction < M , NonSSA > > > ,
23+ ) -> Option < FunctionGUID > {
1724 let cached_guid = try_cached_function_guid ( function) ;
1825 if let Some ( cached_guid) = cached_guid {
19- return cached_guid;
26+ return Some ( cached_guid) ;
2027 }
2128
22- let function_guid = function_guid ( function, lifted_il ) ;
29+ let function_guid = function_guid ( function, lifted_il_accessor ( ) ? . as_ref ( ) ) ;
2330 function. store_metadata (
2431 "warp_function_guid" ,
2532 & function_guid. as_bytes ( ) . to_vec ( ) ,
2633 false ,
2734 ) ;
28- function_guid
35+ Some ( function_guid)
2936}
3037
3138pub fn try_cached_function_guid ( function : & BNFunction ) -> Option < FunctionGUID > {
0 commit comments