Attempt to match new functions by searching for swallowed functions (islands). Return Value: True iff matched at least one function
(self)
| 261 | self._engine.recordRoundMatchAttempt(src_index, bin_ctx.ea, score_boost, score + score_boost, REASON_AGENT) |
| 262 | |
| 263 | def attemptMatchSwallows(self): |
| 264 | """Attempt to match new functions by searching for swallowed functions (islands). |
| 265 | |
| 266 | Return Value: |
| 267 | True iff matched at least one function |
| 268 | """ |
| 269 | # can't match anything if already matched them all (or was disabled) |
| 270 | if not self.active(): |
| 271 | return False |
| 272 | # scan the src gaps this time |
| 273 | src_index = self._src_index_start |
| 274 | first_matched = False |
| 275 | while src_index <= self._src_index_end: |
| 276 | # skip if matched |
| 277 | if src_index in self._engine.function_matches: |
| 278 | src_index += 1 |
| 279 | first_matched = True |
| 280 | continue |
| 281 | if not first_matched: |
| 282 | src_index += 1 |
| 283 | continue |
| 284 | gap_index_start = src_index |
| 285 | gap_index_end = None |
| 286 | # now search for the gap's end |
| 287 | src_index += 1 |
| 288 | while src_index <= self._src_index_end: |
| 289 | if src_index in self._engine.function_matches: |
| 290 | gap_index_end = src_index |
| 291 | break |
| 292 | src_index += 1 |
| 293 | # the gap did not end |
| 294 | if gap_index_end is None: |
| 295 | return False |
| 296 | # find the bin size |
| 297 | gap_bin_start = self._engine.function_matches[gap_index_start - 1] |
| 298 | gap_bin_end = self._engine.function_matches[gap_index_end] |
| 299 | # try to search for a swallow |
| 300 | if self.attemptMatchSwallow(gap_index_start, gap_index_end - 1, gap_bin_start, gap_bin_end): |
| 301 | return True |
| 302 | # Return the result |
| 303 | return False |
| 304 | |
| 305 | def attemptMatchSwallow(self, src_index_start, src_index_end, lower_bound, upper_bound): |
| 306 | """Attempt to match new functions by searching for swallowed functions (islands) in a given range. |
no test coverage detected