Esempio n. 1
0
        public virtual bool resolve_index_hunks(IndexHunk index, List <List <Hunk> > segment_list, List <LibUnit> lib_units)
        {
            var  units = index.units;
            var  no    = 0;
            bool found = false;

            foreach (var unit in units)
            {
                var unit_segments = new List <List <Hunk> >();
                var lib_unit      = new LibUnit
                {
                    segments   = unit_segments,
                    name       = unit.name,
                    unit_no    = no,
                    index_unit = unit,
                };
                lib_units.Add(lib_unit);
                no += 1;
                // try to find segment with start offset
                var hunk_offset = unit.hunk_begin_offset;
                found = false;
                foreach (var segment in segment_list)
                {
                    int  hunk_no = segment[0].hunk_no;
                    uint lib_off = segment[0].hunk_lib_offset / 4;
                    if (lib_off == hunk_offset)
                    {
                        // found segment
                        int num_segs = unit.hunk_infos.Count;
                        for (var i = 0; i < num_segs; ++i)
                        {
                            var info = unit.hunk_infos[i];
                            var seg  = segment_list[hunk_no + i];
                            unit_segments.Add(seg);
                            // renumber hunk
                            seg[0].hunk_no    = i;
                            seg[0].Name       = info.name;
                            seg[0].index_hunk = info;
                        }
                        found = true;
                    }
                }
                if (!found)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
 public virtual bool resolve_index_hunks(IndexHunk index, List<List<Hunk>> segment_list, List<LibUnit> lib_units)
 {
     var units = index.units;
     var no = 0;
     bool found = false;
     foreach (var unit in units)
     {
         var unit_segments = new List<List<Hunk>>();
         var lib_unit = new LibUnit
         {
             segments = unit_segments,
             name = unit.name,
             unit_no = no,
             index_unit = unit,
         };
         lib_units.Add(lib_unit);
         no += 1;
         // try to find segment with start offset
         var hunk_offset = unit.hunk_begin_offset;
         found = false;
         foreach (var segment in segment_list)
         {
             int hunk_no = segment[0].hunk_no;
             uint lib_off = segment[0].hunk_lib_offset / 4;
             if (lib_off == hunk_offset)
             {
                 // found segment
                 int num_segs = unit.hunk_infos.Count;
                 for (var i = 0; i < num_segs; ++i)
                 {
                     var info = unit.hunk_infos[i];
                     var seg = segment_list[hunk_no + i];
                     unit_segments.Add(seg);
                     // renumber hunk
                     seg[0].hunk_no = i;
                     seg[0].Name = info.name;
                     seg[0].index_hunk = info;
                 }
                 found = true;
             }
         }
         if (!found)
         {
             return false;
         }
     }
     return true;
 }