(&self, function: &BNFunction)
| 195 | } |
| 196 | |
| 197 | pub fn match_function(&self, function: &BNFunction) { |
| 198 | // Call this the first time you matched on the function. |
| 199 | let resolve_new_types = |matched: &Function| { |
| 200 | // We also want to resolve the types here. |
| 201 | if let TypeClass::Function(c) = matched.ty.class.as_ref() { |
| 202 | // Recursively go through the function type and resolve referrers |
| 203 | let view = function.view(); |
| 204 | let arch = function.arch(); |
| 205 | for out_member in &c.out_members { |
| 206 | self.add_type_to_view(&view, &arch, &out_member.ty); |
| 207 | } |
| 208 | for in_member in &c.in_members { |
| 209 | self.add_type_to_view(&view, &arch, &in_member.ty); |
| 210 | } |
| 211 | } |
| 212 | }; |
| 213 | |
| 214 | if let Some(matched_function) = cached_function_match(function, || { |
| 215 | // We have yet to match on this function. |
| 216 | let function_len = function.highest_address() - function.lowest_address(); |
| 217 | let is_function_trivial = { function_len < self.settings.trivial_function_len }; |
| 218 | let is_function_allowed = { |
| 219 | function_len > self.settings.minimum_function_len |
| 220 | && function_len < self.settings.maximum_function_len.unwrap_or(u64::MAX) |
| 221 | }; |
| 222 | let warp_func_guid = try_cached_function_guid(function)?; |
| 223 | match self.functions.get(&warp_func_guid) { |
| 224 | _ if !is_function_allowed => None, |
| 225 | Some(matched) if matched.len() == 1 && !is_function_trivial => { |
| 226 | resolve_new_types(&matched[0]); |
| 227 | Some(matched[0].to_owned()) |
| 228 | } |
| 229 | Some(matched) => { |
| 230 | let matched_on = self.match_function_from_constraints(function, &matched)?; |
| 231 | resolve_new_types(matched_on); |
| 232 | Some(matched_on.to_owned()) |
| 233 | } |
| 234 | None => None, |
| 235 | } |
| 236 | }) { |
| 237 | on_matched_function(function, &matched_function); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | pub fn match_function_from_constraints<'a>( |
| 242 | &self, |
no test coverage detected