Skip to content

Commit 81bb229

Browse files
committed
---
yaml --- r: 40353 b: refs/heads/dist-snap c: b22f941 h: refs/heads/master i: 40351: 1e00ec0 v: v3
1 parent a1268d6 commit 81bb229

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: 2ec09c4eb91b94bd68c95eaa8966d4801c3347bf
10+
refs/heads/dist-snap: b22f94148720e1ece7e16afe92f91d998ac9af34
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libsyntax/codemap.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ use std::serialization::{Serializable,
1010
Serializer,
1111
Deserializer};
1212

13+
pub type byte_pos = uint;
14+
pub type char_pos = uint;
15+
1316
pub struct span {
14-
lo: uint,
15-
hi: uint,
17+
lo: char_pos,
18+
hi: char_pos,
1619
expn_info: Option<@expn_info>
1720
}
1821

@@ -34,30 +37,30 @@ impl<D: Deserializer> span: Deserializable<D> {
3437
}
3538
}
3639

37-
pub enum expn_info {
38-
expanded_from({call_site: span,
39-
callie: {name: ~str, span: Option<span>}})
40+
pub struct file_pos {
41+
ch: char_pos, byte: byte_pos
4042
}
4143

42-
pub type filename = ~str;
43-
44-
pub type lookup_fn = pure fn(file_pos) -> uint;
45-
4644
pub struct loc {
4745
file: @filemap, line: uint, col: uint
4846
}
4947

50-
pub struct file_pos {
51-
ch: uint, byte: uint
52-
}
53-
5448
impl file_pos : cmp::Eq {
5549
pure fn eq(other: &file_pos) -> bool {
5650
self.ch == (*other).ch && self.byte == (*other).byte
5751
}
5852
pure fn ne(other: &file_pos) -> bool { !self.eq(other) }
5953
}
6054

55+
pub enum expn_info {
56+
expanded_from({call_site: span,
57+
callie: {name: ~str, span: Option<span>}})
58+
}
59+
60+
pub type filename = ~str;
61+
62+
pub type lookup_fn = pure fn(file_pos) -> uint;
63+
6164
pub struct file_lines {
6265
file: @filemap,
6366
lines: ~[uint]
@@ -90,13 +93,13 @@ pub impl filemap {
9093
}
9194

9295
static fn new(+filename: filename, src: @~str,
93-
start_pos_ch: uint, start_pos_byte: uint)
96+
start_pos_ch: char_pos, start_pos_byte: byte_pos)
9497
-> filemap {
9598
return filemap::new_w_substr(filename, fss_none, src,
9699
start_pos_ch, start_pos_byte);
97100
}
98101

99-
fn next_line(@self, chpos: uint, byte_pos: uint) {
102+
fn next_line(@self, chpos: char_pos, byte_pos: byte_pos) {
100103
self.lines.push(file_pos {ch: chpos, byte: byte_pos + self.start_pos.byte});
101104
}
102105

@@ -127,17 +130,17 @@ pub impl CodeMap {
127130
return fmt!("<%s:%u:%u>", pos.file.name, pos.line, pos.col);
128131
}
129132

130-
pub fn lookup_char_pos(@self, pos: uint) -> loc {
133+
pub fn lookup_char_pos(@self, pos: char_pos) -> loc {
131134
pure fn lookup(pos: file_pos) -> uint { return pos.ch; }
132135
return self.lookup_pos(pos, lookup);
133136
}
134137

135-
pub fn lookup_byte_pos(@self, pos: uint) -> loc {
138+
pub fn lookup_byte_pos(@self, pos: byte_pos) -> loc {
136139
pure fn lookup(pos: file_pos) -> uint { return pos.byte; }
137140
return self.lookup_pos(pos, lookup);
138141
}
139142

140-
pub fn lookup_char_pos_adj(@self, pos: uint)
143+
pub fn lookup_char_pos_adj(@self, pos: char_pos)
141144
-> {filename: ~str, line: uint, col: uint, file: Option<@filemap>}
142145
{
143146
let loc = self.lookup_char_pos(pos);
@@ -195,8 +198,8 @@ pub impl CodeMap {
195198
return @file_lines {file: lo.file, lines: lines};
196199
}
197200

198-
fn lookup_byte_offset(@self, chpos: uint)
199-
-> {fm: @filemap, pos: uint} {
201+
fn lookup_byte_offset(@self, chpos: char_pos)
202+
-> {fm: @filemap, pos: byte_pos} {
200203
pure fn lookup(pos: file_pos) -> uint { return pos.ch; }
201204
let {fm, line} = self.lookup_line(chpos, lookup);
202205
let line_offset = fm.lines[line].byte - fm.start_pos.byte;

0 commit comments

Comments
 (0)