def clear_path(graph, reg, loc1, loc2):
 logger.debug('clear_path: reg(%s), loc1(%s), loc2(%s)', reg, loc1, loc2)
 node1 = graph.get_node_from_loc(loc1)
 node2 = graph.get_node_from_loc(loc2)
 if (node1 is node2):
  return clear_path_node(graph, reg, (loc1 + 1), loc2)
 if (not clear_path_node(graph, reg, (loc1 + 1), node1.ins_range[1])):
  return False
 path = build_path(graph, node1, node2)
 for node in path:
  locs = node.ins_range
  end_loc = (loc2 if (locs[0] <= loc2 <= locs[1]) else locs[1])
  if (not clear_path_node(graph, reg, locs[0], end_loc)):
   return False
 return True

def clear_path ( graph , reg , loc1 , loc2 ) : logger . debug ( 'clear_path: reg(%s), loc1(%s), loc2(%s)' , reg , loc1 , loc2 ) node1 = graph . get_node_from_loc ( loc1 ) node2 = graph . get_node_from_loc ( loc2 ) if ( node1 is node2 ) : return clear_path_node ( graph , reg , ( loc1 + 1 ) , loc2 ) if ( not clear_path_node ( graph , reg , ( loc1 + 1 ) , node1 . ins_range [ 1 ] ) ) : return False path = build_path ( graph , node1 , node2 ) for node in path : locs = node . ins_range end_loc = ( loc2 if ( locs [ 0 ] <= loc2 <= locs [ 1 ] ) else locs [ 1 ] ) if ( not clear_path_node ( graph , reg , locs [ 0 ] , end_loc ) ) : return False return True
check that the path from loc1 to loc2 is clear .