Changeset 844 for proto/parabix2/src


Ignore:
Timestamp:
Dec 19, 2010, 6:26:34 AM (9 years ago)
Author:
cameron
Message:

Unify line/column reporting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/src/LineColTracker.h

    r843 r844  
    2727    inline void AdvanceBlock();
    2828    inline void StoreNewlines(BitBlock newline);
     29    void get_Line_and_Column(int pos_in_block, int & line, int & column);
    2930  private:
    3031    BitBlock BitParallelCounter[MAX_COUNTER_BITS];
     
    4243  blocks_after_last_newline_block = 0;
    4344  last_block_with_newline = simd_const_1(1);
    44   newline_counts = 1;
     45  newline_counts = 0;
    4546}
    4647
     
    6465    blocks_after_last_newline_block++;
    6566}
    66 
    67 int LineColTracker::getLineNumber(int mark_pos){
    68   int lines = 1;
    69   cur_newline = simd_andc(cur_newline, sisd_sfl(simd_const_1(1),sisd_from_int(mark_pos)));
    70  
    71   for(int i=MAX_COUNTER_BITS-1;i<=0;i++)
    72     lines = lines*2 +  bitblock_bit_count(BitParallelCounter[i]);
    73  
    74   if(bitblock_has_bit(cur_newline))
    75     return lines + bitblock_bit_count(cur_newline);
    76   else
    77     return lines;
    78 }
    7967#endif
    80 
    81 int LineColTracker::getColNumber(int mark_pos){
    82   cur_newline = simd_andc(cur_newline, sisd_sfl(simd_const_1(1),sisd_from_int(mark_pos)));
    83   if(bitblock_has_bit(cur_newline))
    84     return mark_pos - (BLOCK_SIZE-count_backward_zeroes(cur_newline))+1;
    85   else
    86     return BLOCK_SIZE*blocks_after_last_newline_block +
    87           count_backward_zeroes(last_block_with_newline) + mark_pos+1;
    88 }
    8968
    9069#ifdef BITBLOCK_BIT_COUNT
     
    9978    blocks_after_last_newline_block++;
    10079}
     80#endif
    10181
    102 int LineColTracker::getLineNumber(int mark_pos){
    103   cur_newline = simd_andc(cur_newline, sisd_sfl(simd_const_1(1),sisd_from_int(mark_pos)));
     82void LineColTracker::get_Line_and_Column(int pos_in_block, int & line, int & column) {
     83  cur_newline = simd_andc(cur_newline, sisd_sfl(simd_const_1(1),sisd_from_int(pos_in_block)));
     84  if(bitblock_has_bit(cur_newline))
     85    column = pos_in_block - (BLOCK_SIZE-count_backward_zeroes(cur_newline))+1;
     86  else
     87    column = BLOCK_SIZE*blocks_after_last_newline_block +
     88             count_backward_zeroes(last_block_with_newline) + pos_in_block+1;
     89
     90#ifndef BITBLOCK_BIT_COUNT
     91  int lines = 0;
     92  for(int i=MAX_COUNTER_BITS-1;i>=0;i--)
     93    lines = lines*2 + bitblock_bit_count(BitParallelCounter[i]);
     94  newline_counts = lines;
     95#endif
    10496 
    10597  if(bitblock_has_bit(cur_newline))
    106     return newline_counts + bitblock_bit_count(cur_newline);
     98    line = newline_counts + bitblock_bit_count(cur_newline) + 1;
    10799  else
    108     return newline_counts;
     100    line = newline_counts + 1;
     101
    109102}
    110 #endif
    111103
    112104
    113105
    114 
    115 
Note: See TracChangeset for help on using the changeset viewer.