if_diff/src/idfMatchAst.cxx
//============================================================================
// Return whether the given location overlaps the region outside of the
// given AST node. Returns 1 if comp overlaps what precedes ast,
// 2 if comp overlaps what follows ast, and 3 if comp overlaps both.
//============================================================================
Return whether the given location overlaps the region outside of the
given AST node. Returns 1 if comp overlaps what precedes ast,
2 if comp overlaps what follows ast, and 3 if comp overlaps both.
Return whether the given location overlaps the region outside of the given AST node . Returns 1 if comp overlaps what precedes ast 2 if comp overlaps what follows ast and 3 if comp overlaps both .
static int overlaps_complement(locationStruct *comp, idfAst &ast)
{
  if (comp == NULL) {
    return 0;
  }
  boolean overlaps_prev = false;
  idfAst *p = &ast;
  locationStruct prev_comp;
  boolean got_prev_comp = false;
  while (p != NULL && !got_prev_comp) {
    for (idfAst *sib = p->getPrevSib(); sib != NULL; sib = sib->getPrevSib()) {
      if (got_prev_comp = sib->getSubtreeLocation(prev_comp)) {
      	break;
      }
    }
    p = p->getParent();
  }
  if (got_prev_comp) {
    int order;
#if defined(IDF_DEBUG_TRY)
    genString prev_str;
    idf_location_str(&prev_comp, prev_str);
    genString comp_str;
    idf_location_str(comp, comp_str);
    cout << "checking whether " << prev_str << " precedes " << comp_str << ".";
#endif
    if (idf_location_precedes(&prev_comp, comp, order) && order > 0) {
#if defined(IDF_DEBUG_TRY)
      cout << " fails to precede" << endl;
#endif
      overlaps_prev = true;
    }
#if defined(IDF_DEBUG_TRY)
    if (!overlaps_prev) {
      cout << " precedes" << endl;
    }
#endif
  }
  return (overlaps_prev ? 1 : 0) | (overlaps_followers(comp, ast) ? 2 : 0);
}
static int overlaps_complement ( locationStruct * comp , idfAst & ast ) { if ( comp == NULL ) { return 0 ; } boolean overlaps_prev = false ; idfAst * p = & ast ; locationStruct prev_comp ; boolean got_prev_comp = false ; while ( p != NULL && ! got_prev_comp ) { for ( idfAst * sib = p -> getPrevSib ( ) ; sib != NULL ; sib = sib -> getPrevSib ( ) ) { if ( got_prev_comp = sib -> getSubtreeLocation ( prev_comp ) ) { break ; } } p = p -> getParent ( ) ; } if ( got_prev_comp ) { int order ; #if defined ( IDF_DEBUG_TRY ) genString prev_str ; idf_location_str ( & prev_comp , prev_str ) ; genString comp_str ; idf_location_str ( comp , comp_str ) ; cout << " " << prev_str << " " << comp_str << " " ; #endif if ( idf_location_precedes ( & prev_comp , comp , order ) && order > 0 ) { #if defined ( IDF_DEBUG_TRY ) cout << " " << endl ; #endif overlaps_prev = true ; } #if defined ( IDF_DEBUG_TRY ) if ( ! overlaps_prev ) { cout << " " << endl ; } #endif } return ( overlaps_prev ? 1 : 0 ) | ( overlaps_followers ( comp , ast ) ? 2 : 0 ) ; }
Return whether the given location overlaps the region outside of the
given AST node.
Return whether the given location overlaps the region outside of the given AST node .
// Find a previous sibling or aunt/uncle.