@@ -228,15 +228,15 @@ impl FileMap {
228
228
pub fn next_line ( & self , pos : BytePos ) {
229
229
// the new charpos must be > the last one (or it's the first one).
230
230
let mut lines = self . lines . borrow_mut ( ) ; ;
231
- let line_len = lines. get ( ) . len ( ) ;
232
- assert ! ( line_len == 0 || ( * lines. get( ) . get ( line_len - 1 ) < pos) )
233
- lines. get ( ) . push ( pos) ;
231
+ let line_len = lines. len ( ) ;
232
+ assert ! ( line_len == 0 || ( * lines. get( line_len - 1 ) < pos) )
233
+ lines. push ( pos) ;
234
234
}
235
235
236
236
// get a line from the list of pre-computed line-beginnings
237
237
pub fn get_line ( & self , line : int ) -> ~str {
238
238
let mut lines = self . lines . borrow_mut ( ) ;
239
- let begin: BytePos = * lines. get ( ) . get ( line as uint ) - self . start_pos ;
239
+ let begin: BytePos = * lines. get ( line as uint ) - self . start_pos ;
240
240
let begin = begin. to_uint ( ) ;
241
241
let slice = self . src . slice_from ( begin) ;
242
242
match slice. find ( '\n' ) {
@@ -251,7 +251,7 @@ impl FileMap {
251
251
pos : pos,
252
252
bytes : bytes,
253
253
} ;
254
- self . multibyte_chars . borrow_mut ( ) . get ( ) . push ( mbc) ;
254
+ self . multibyte_chars . borrow_mut ( ) . push ( mbc) ;
255
255
}
256
256
257
257
pub fn is_real_file ( & self ) -> bool {
@@ -272,9 +272,9 @@ impl CodeMap {
272
272
273
273
pub fn new_filemap ( & self , filename : FileName , src : ~str ) -> Rc < FileMap > {
274
274
let mut files = self . files . borrow_mut ( ) ;
275
- let start_pos = match files. get ( ) . last ( ) {
275
+ let start_pos = match files. last ( ) {
276
276
None => 0 ,
277
- Some ( last) => last. deref ( ) . start_pos . to_uint ( ) + last. deref ( ) . src . len ( ) ,
277
+ Some ( last) => last. start_pos . to_uint ( ) + last. src . len ( ) ,
278
278
} ;
279
279
280
280
// Remove utf-8 BOM if any.
@@ -302,14 +302,14 @@ impl CodeMap {
302
302
multibyte_chars : RefCell :: new ( Vec :: new ( ) ) ,
303
303
} ) ;
304
304
305
- files. get ( ) . push ( filemap. clone ( ) ) ;
305
+ files. push ( filemap. clone ( ) ) ;
306
306
307
307
filemap
308
308
}
309
309
310
310
pub fn mk_substr_filename ( & self , sp : Span ) -> ~str {
311
311
let pos = self . lookup_char_pos ( sp. lo ) ;
312
- format ! ( "<{}:{}:{}>" , pos. file. deref ( ) . name, pos. line, pos. col. to_uint( ) + 1 )
312
+ format ! ( "<{}:{}:{}>" , pos. file. name, pos. line, pos. col. to_uint( ) + 1 )
313
313
}
314
314
315
315
/// Lookup source information about a BytePos
@@ -320,15 +320,15 @@ impl CodeMap {
320
320
pub fn lookup_char_pos_adj ( & self , pos : BytePos ) -> LocWithOpt {
321
321
let loc = self . lookup_char_pos ( pos) ;
322
322
LocWithOpt {
323
- filename : loc. file . deref ( ) . name . to_str ( ) ,
323
+ filename : loc. file . name . to_str ( ) ,
324
324
line : loc. line ,
325
325
col : loc. col ,
326
326
file : Some ( loc. file )
327
327
}
328
328
}
329
329
330
330
pub fn span_to_str ( & self , sp : Span ) -> ~str {
331
- if self . files . borrow ( ) . get ( ) . len ( ) == 0 && sp == DUMMY_SP {
331
+ if self . files . borrow ( ) . len ( ) == 0 && sp == DUMMY_SP {
332
332
return ~"no-location";
333
333
}
334
334
@@ -339,7 +339,7 @@ impl CodeMap {
339
339
}
340
340
341
341
pub fn span_to_filename ( & self , sp : Span ) -> FileName {
342
- self . lookup_char_pos ( sp. lo ) . file . deref ( ) . name . to_str ( )
342
+ self . lookup_char_pos ( sp. lo ) . file . name . to_str ( )
343
343
}
344
344
345
345
pub fn span_to_lines ( & self , sp : Span ) -> FileLines {
@@ -360,16 +360,16 @@ impl CodeMap {
360
360
// it's testing isn't true for all spans in the AST, so to allow the
361
361
// caller to not have to fail (and it can't catch it since the CodeMap
362
362
// isn't sendable), return None
363
- if begin. fm . deref ( ) . start_pos != end. fm . deref ( ) . start_pos {
363
+ if begin. fm . start_pos != end. fm . start_pos {
364
364
None
365
365
} else {
366
- Some ( begin. fm . deref ( ) . src . slice ( begin. pos . to_uint ( ) , end. pos . to_uint ( ) ) . to_owned ( ) )
366
+ Some ( begin. fm . src . slice ( begin. pos . to_uint ( ) , end. pos . to_uint ( ) ) . to_owned ( ) )
367
367
}
368
368
}
369
369
370
370
pub fn get_filemap ( & self , filename : & str ) -> Rc < FileMap > {
371
- for fm in self . files . borrow ( ) . get ( ) . iter ( ) {
372
- if filename == fm. deref ( ) . name {
371
+ for fm in self . files . borrow ( ) . iter ( ) {
372
+ if filename == fm. name {
373
373
return fm. clone ( ) ;
374
374
}
375
375
}
@@ -378,13 +378,13 @@ impl CodeMap {
378
378
379
379
fn lookup_filemap_idx ( & self , pos : BytePos ) -> uint {
380
380
let files = self . files . borrow ( ) ;
381
- let files = files. get ( ) ;
381
+ let files = files;
382
382
let len = files. len ( ) ;
383
383
let mut a = 0 u;
384
384
let mut b = len;
385
385
while b - a > 1 u {
386
386
let m = ( a + b) / 2 u;
387
- if files. get ( m) . deref ( ) . start_pos > pos {
387
+ if files. get ( m) . start_pos > pos {
388
388
b = m;
389
389
} else {
390
390
a = m;
@@ -394,8 +394,8 @@ impl CodeMap {
394
394
// filemap, but are not the filemaps we want (because they are length 0, they cannot
395
395
// contain what we are looking for). So, rewind until we find a useful filemap.
396
396
loop {
397
- let lines = files. get ( a) . deref ( ) . lines . borrow ( ) ;
398
- let lines = lines. get ( ) ;
397
+ let lines = files. get ( a) . lines . borrow ( ) ;
398
+ let lines = lines;
399
399
if lines. len ( ) > 0 {
400
400
break ;
401
401
}
@@ -415,14 +415,14 @@ impl CodeMap {
415
415
let idx = self . lookup_filemap_idx ( pos) ;
416
416
417
417
let files = self . files . borrow ( ) ;
418
- let f = files. get ( ) . get ( idx) . clone ( ) ;
418
+ let f = files. get ( idx) . clone ( ) ;
419
419
let mut a = 0 u;
420
420
{
421
- let mut lines = f. deref ( ) . lines . borrow_mut ( ) ;
422
- let mut b = lines. get ( ) . len ( ) ;
421
+ let mut lines = f. lines . borrow_mut ( ) ;
422
+ let mut b = lines. len ( ) ;
423
423
while b - a > 1 u {
424
424
let m = ( a + b) / 2 u;
425
- if * lines. get ( ) . get ( m) > pos { b = m; } else { a = m; }
425
+ if * lines. get ( m) > pos { b = m; } else { a = m; }
426
426
}
427
427
}
428
428
FileMapAndLine { fm : f, line : a}
@@ -432,7 +432,7 @@ impl CodeMap {
432
432
let FileMapAndLine { fm : f, line : a} = self . lookup_line ( pos) ;
433
433
let line = a + 1 u; // Line numbers start at 1
434
434
let chpos = self . bytepos_to_file_charpos ( pos) ;
435
- let linebpos = * f. deref ( ) . lines . borrow ( ) . get ( ) . get ( a) ;
435
+ let linebpos = * f. lines . borrow ( ) . get ( a) ;
436
436
let linechpos = self . bytepos_to_file_charpos ( linebpos) ;
437
437
debug ! ( "codemap: byte pos {:?} is on the line at byte pos {:?}" ,
438
438
pos, linebpos) ;
@@ -449,8 +449,8 @@ impl CodeMap {
449
449
450
450
fn lookup_byte_offset ( & self , bpos : BytePos ) -> FileMapAndBytePos {
451
451
let idx = self . lookup_filemap_idx ( bpos) ;
452
- let fm = self . files . borrow ( ) . get ( ) . get ( idx) . clone ( ) ;
453
- let offset = bpos - fm. deref ( ) . start_pos ;
452
+ let fm = self . files . borrow ( ) . get ( idx) . clone ( ) ;
453
+ let offset = bpos - fm. start_pos ;
454
454
FileMapAndBytePos { fm : fm, pos : offset}
455
455
}
456
456
@@ -459,12 +459,12 @@ impl CodeMap {
459
459
debug ! ( "codemap: converting {:?} to char pos" , bpos) ;
460
460
let idx = self . lookup_filemap_idx ( bpos) ;
461
461
let files = self . files . borrow ( ) ;
462
- let map = files. get ( ) . get ( idx) ;
462
+ let map = files. get ( idx) ;
463
463
464
464
// The number of extra bytes due to multibyte chars in the FileMap
465
465
let mut total_extra_bytes = 0 ;
466
466
467
- for mbc in map. deref ( ) . multibyte_chars . borrow ( ) . get ( ) . iter ( ) {
467
+ for mbc in map. multibyte_chars . borrow ( ) . iter ( ) {
468
468
debug ! ( "codemap: {:?}-byte char at {:?}" , mbc. bytes, mbc. pos) ;
469
469
if mbc. pos < bpos {
470
470
// every character is at least one byte, so we only
@@ -478,8 +478,8 @@ impl CodeMap {
478
478
}
479
479
}
480
480
481
- assert ! ( map. deref ( ) . start_pos. to_uint( ) + total_extra_bytes <= bpos. to_uint( ) ) ;
482
- CharPos ( bpos. to_uint ( ) - map. deref ( ) . start_pos . to_uint ( ) - total_extra_bytes)
481
+ assert ! ( map. start_pos. to_uint( ) + total_extra_bytes <= bpos. to_uint( ) ) ;
482
+ CharPos ( bpos. to_uint ( ) - map. start_pos . to_uint ( ) - total_extra_bytes)
483
483
}
484
484
}
485
485
0 commit comments