Change spans to use byte offsets instead of char offsets

This commit is contained in:
Brian Anderson
2012-11-15 19:37:29 -08:00
parent 8cba337cce
commit 81d20156cd
12 changed files with 161 additions and 89 deletions

View File

@@ -1,7 +1,7 @@
use codemap::{span, CharPos};
use codemap::{span, BytePos};
use ast::*;
pure fn spanned<T>(+lo: CharPos, +hi: CharPos, +t: T) -> spanned<T> {
pure fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
respan(mk_sp(lo, hi), move t)
}
@@ -14,12 +14,12 @@ pure fn dummy_spanned<T>(+t: T) -> spanned<T> {
}
/* assuming that we're not in macro expansion */
pure fn mk_sp(+lo: CharPos, +hi: CharPos) -> span {
pure fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
span {lo: lo, hi: hi, expn_info: None}
}
// make this a const, once the compiler supports it
pure fn dummy_sp() -> span { return mk_sp(CharPos(0), CharPos(0)); }
pure fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); }