Пример #1
0
/*--------------------------------------------------------------------
 * src_viewer::map_tree_node
 *
 * Return 0 if the source line cannot be found
 */
code_range src_viewer::map_tree_node( SuifObject* node, src_viewer* viewer ) {
  String file;
  int line = find_source_line( node, file).c_int();
  if ( line && // there is an input
       ( suif_utils::is_same_file( file, viewer->get_source_file_name() ) ) ) {
    return ( code_range(line, line) );
  }
  return ( code_range(0, 0) );
}
Пример #2
0
/*--------------------------------------------------------------------
 * output_viewer::map_tree_node
 *
 * This is a mapping function from a tree-node to the corresponding
 * line number on the output file
 */
code_range
output_viewer::map_tree_node(SuifObject* tn, output_viewer* viewer)
{

  /* find the src file and src line */
  String file;
  int line = find_source_line( tn, file ).c_int();
  if (line) {

    int possible_line = 0;

    ProcedureDefinition *proc = get_procedure_definition( tn );

    if (!proc) return code_range( INT_MAX, 0 );

    /* iterate through the procedures */
    for ( s_count_t _cnt=0; _cnt<viewer->proc_scopes->size(); _cnt++ ) {
      scope_node *scope = (*viewer->proc_scopes)[_cnt];

      if (scope->proc == proc) {
	
	/* this is the correct procedure */
	if (tn->isKindOf(ProcedureDefinition::get_class_name()) ) {
	  return code_range( scope->first_line, scope->last_line );
	}
	
        for ( s_count_t _cnt1=0; _cnt1 < scope->nodes.size(); _cnt1++ ) {
          output_node *node = scope->nodes[_cnt1];

	  if (node->src_line == line &&
	      !strcmp( node->src_file, file.c_str() ) ) {

	    if (!node->mapped) {
	      node->mapped = true;
	      return code_range(node->out_line, node->out_line);
	    } else {
	      possible_line = node->out_line;
	    }
	  }
	}
      }
    }

    if ( possible_line ) {
      return code_range( possible_line, possible_line );
    } else {
      return code_range( INT_MAX, 0 );
    }
  }
  return code_range( INT_MAX, 0 );
}