Reorder codemap decls

This commit is contained in:
Brian Anderson 2012-11-12 17:14:15 -08:00
parent 5b248a6ca8
commit 18a825bda0

View File

@ -39,8 +39,40 @@ export loc;
export get_filemap;
export new_codemap;
struct span {lo: uint, hi: uint, expn_info: expn_info}
impl span : cmp::Eq {
pure fn eq(other: &span) -> bool {
return self.lo == (*other).lo && self.hi == (*other).hi;
}
pure fn ne(other: &span) -> bool { !self.eq(other) }
}
impl<S: Serializer> span: Serializable<S> {
/* Note #1972 -- spans are serialized but not deserialized */
fn serialize(&self, _s: &S) { }
}
impl<D: Deserializer> span: Deserializable<D> {
static fn deserialize(_d: &D) -> span {
ast_util::dummy_sp()
}
}
enum expn_info_ {
expanded_from({call_site: span,
callie: {name: ~str, span: Option<span>}})
}
type expn_info = Option<@expn_info_>;
type filename = ~str;
type lookup_fn = pure fn(file_pos) -> uint;
struct loc {
file: @filemap, line: uint, col: uint
}
struct file_pos {
ch: uint, byte: uint
}
@ -90,10 +122,6 @@ struct CodeMap {
files: DVec<@filemap>
}
struct loc {
file: @filemap, line: uint, col: uint
}
fn new_codemap() -> CodeMap {
CodeMap {
files: DVec()
@ -110,8 +138,6 @@ fn next_line(file: @filemap, chpos: uint, byte_pos: uint) {
file.lines.push(file_pos {ch: chpos, byte: byte_pos + file.start_pos.byte});
}
type lookup_fn = pure fn(file_pos) -> uint;
fn lookup_line(map: @CodeMap, pos: uint, lookup: lookup_fn)
-> {fm: @filemap, line: uint}
{
@ -186,32 +212,6 @@ fn adjust_span(map: @CodeMap, sp: span) -> span {
}
}
enum expn_info_ {
expanded_from({call_site: span,
callie: {name: ~str, span: Option<span>}})
}
type expn_info = Option<@expn_info_>;
struct span {lo: uint, hi: uint, expn_info: expn_info}
impl span : cmp::Eq {
pure fn eq(other: &span) -> bool {
return self.lo == (*other).lo && self.hi == (*other).hi;
}
pure fn ne(other: &span) -> bool { !self.eq(other) }
}
impl<S: Serializer> span: Serializable<S> {
/* Note #1972 -- spans are serialized but not deserialized */
fn serialize(&self, _s: &S) { }
}
impl<D: Deserializer> span: Deserializable<D> {
static fn deserialize(_d: &D) -> span {
ast_util::dummy_sp()
}
}
fn span_to_str_no_adj(sp: span, cm: @CodeMap) -> ~str {
let lo = lookup_char_pos(cm, sp.lo);
let hi = lookup_char_pos(cm, sp.hi);