if_diff/src/idfMatchAst.cxx
//============================================================================
// Return whether the given location overlaps the region of what follows
// given AST node.
//============================================================================
Return whether the given location overlaps the region of what follows
given AST node.
Return whether the given location overlaps the region of what follows given AST node .
static boolean overlaps_followers(locationStruct *comp, idfAst &ast)
{
  if (comp == NULL) {
    return false;
  }
  locationStruct next_comp;
  boolean got_next_comp = false;
  for (idfAst *p = &ast; p != NULL && !got_next_comp; p = p->getParent()) {
    for (idfAst *sib = p->getNextSib(); sib != NULL; sib = sib->getNextSib()) {
      if (got_next_comp = sib->getSubtreeLocation(next_comp)) {
      	break;
      }
    }
  }
  if (got_next_comp) {
    int order;
#if defined(IDF_DEBUG_TRY)
    genString next_str;
    idf_location_str(&next_comp, next_str);
    genString comp_str;
    idf_location_str(comp, comp_str);
    cout << "checking whether " << comp_str << " precedes " << next_str << ".";
#endif
    if (idf_location_precedes(comp, &next_comp, order) && order > 0) {
#if defined(IDF_DEBUG_TRY)
      cout << " fails to precede" << endl;
#endif
      return true;
    }
#if defined(IDF_DEBUG_TRY)
    cout << " precedes" << endl;
#endif
  }
  return false;
}
static boolean overlaps_followers ( locationStruct * comp , idfAst & ast ) { if ( comp == NULL ) { return false ; } locationStruct next_comp ; boolean got_next_comp = false ; for ( idfAst * p = & ast ; p != NULL && ! got_next_comp ; p = p -> getParent ( ) ) { for ( idfAst * sib = p -> getNextSib ( ) ; sib != NULL ; sib = sib -> getNextSib ( ) ) { if ( got_next_comp = sib -> getSubtreeLocation ( next_comp ) ) { break ; } } } if ( got_next_comp ) { int order ; #if defined ( IDF_DEBUG_TRY ) genString next_str ; idf_location_str ( & next_comp , next_str ) ; genString comp_str ; idf_location_str ( comp , comp_str ) ; cout << " " << comp_str << " " << next_str << " " ; #endif if ( idf_location_precedes ( comp , & next_comp , order ) && order > 0 ) { #if defined ( IDF_DEBUG_TRY ) cout << " " << endl ; #endif return true ; } #if defined ( IDF_DEBUG_TRY ) cout << " " << endl ; #endif } return false ; }
Return whether the given location overlaps the region of what follows
given AST node.
Return whether the given location overlaps the region of what follows given AST node .
// Find a later sibling or aunt/uncle.