fn bytepos_to_local_charpos(&self, bpos: BytePos) -> CharPos {
        debug!("codemap: converting {:?} to char pos", bpos);
        let idx = self.lookup_filemap_idx(bpos);
        let files = self.files.borrow();
        let map = files.get()[idx];

        // The number of extra bytes due to multibyte chars in the FileMap
        let mut total_extra_bytes = 0;

        let multibyte_chars = map.multibyte_chars.borrow();
        for mbc in multibyte_chars.get().iter() {
            debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos);
            if mbc.pos < bpos {
                total_extra_bytes += mbc.bytes;
                // We should never see a byte position in the middle of a
                // character
                assert!(bpos == mbc.pos
                    || bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes);
            } else {
                break;
            }
        }

        CharPos(bpos.to_uint() - total_extra_bytes)
    }
// Converts an absolute BytePos to a CharPos relative to the file it is
// located in
Converts an absolute BytePos to a CharPos relative to the file it is
located in
Converts an absolute BytePos to a CharPos relative to the file it is located in
fn bytepos_to_local_charpos(&self, bpos: BytePos) -> CharPos {
        debug!("codemap: converting {:?} to char pos", bpos);
        let idx = self.lookup_filemap_idx(bpos);
        let files = self.files.borrow();
        let map = files.get()[idx];
        // The number of extra bytes due to multibyte chars in the FileMap
        let mut total_extra_bytes = 0;
        let multibyte_chars = map.multibyte_chars.borrow();
        for mbc in multibyte_chars.get().iter() {
            debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos);
            if mbc.pos < bpos {
                total_extra_bytes += mbc.bytes;
                // We should never see a byte position in the middle of a
                // character
                assert!(bpos == mbc.pos
                    || bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes);
            } else {
                break;
            }
        }
        CharPos(bpos.to_uint() - total_extra_bytes)
    }
fn bytepos_to_local_charpos ( & self , bpos : BytePos ) -> CharPos { debug ! ( " " bpos ) ; let idx = self . lookup_filemap_idx ( bpos ) ; let files = self . files . borrow ( ) ; let map = files . get ( ) [ idx ] ; // The number of extra bytes due to multibyte chars in the FileMap let mut total_extra_bytes = 0 ; let multibyte_chars = map . multibyte_chars . borrow ( ) ; for mbc in multibyte_chars . get ( ) . iter ( ) { debug ! ( " " mbc bytes mbc pos ) ; if mbc . pos < bpos { total_extra_bytes += mbc . bytes ; // We should never see a byte position in the middle of a // character assert ! ( bpos mbc pos bpos to_uint ( ) mbc pos to_uint ( ) mbc bytes ) ; } else { break ; } } CharPos ( bpos . to_uint ( ) - total_extra_bytes ) }
Converts an absolute BytePos to a CharPos relative to the file it is
located in
Converts an absolute BytePos to a CharPos relative to the file it is located in
&self
bpos
BytePos
&self
bpos
BytePos