syntax: de-mode and prepare for de-modeing rustc

This commit is contained in:
Alex Crichton
2013-04-17 12:15:08 -04:00
parent be9f4ef65f
commit 3c7aea3a6a
30 changed files with 363 additions and 364 deletions

View File

@@ -71,7 +71,7 @@ impl Sub<BytePos, BytePos> for BytePos {
}
impl to_bytes::IterBytes for BytePos {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f)
}
}
@@ -89,7 +89,7 @@ impl cmp::Ord for CharPos {
}
impl to_bytes::IterBytes for CharPos {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f)
}
}
@@ -141,20 +141,20 @@ impl<D:Decoder> Decodable<D> for span {
}
}
pub fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> spanned<T> {
respan(mk_sp(lo, hi), t)
}
pub fn respan<T>(sp: span, +t: T) -> spanned<T> {
pub fn respan<T>(sp: span, t: T) -> spanned<T> {
spanned {node: t, span: sp}
}
pub fn dummy_spanned<T>(+t: T) -> spanned<T> {
pub fn dummy_spanned<T>(t: T) -> spanned<T> {
respan(dummy_sp(), t)
}
/* assuming that we're not in macro expansion */
pub fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
pub fn mk_sp(lo: BytePos, hi: BytePos) -> span {
span {lo: lo, hi: hi, expn_info: None}
}
@@ -247,7 +247,7 @@ pub impl FileMap {
// UNCHECKED INVARIANT: these offsets must be added in the right
// order and must be in the right places; there is shared knowledge
// about what ends a line between this file and parse.rs
fn next_line(&self, +pos: BytePos) {
fn next_line(&self, pos: BytePos) {
// the new charpos must be > the last one (or it's the first one).
let lines = &mut *self.lines;
assert!((lines.len() == 0) || (lines[lines.len() - 1] < pos));
@@ -287,14 +287,14 @@ pub impl CodeMap {
}
/// Add a new FileMap to the CodeMap and return it
fn new_filemap(&self, +filename: FileName, src: @~str) -> @FileMap {
fn new_filemap(&self, filename: FileName, src: @~str) -> @FileMap {
return self.new_filemap_w_substr(filename, FssNone, src);
}
fn new_filemap_w_substr(
&self,
+filename: FileName,
+substr: FileSubstr,
filename: FileName,
substr: FileSubstr,
src: @~str
) -> @FileMap {
let files = &mut *self.files;
@@ -325,11 +325,11 @@ pub impl CodeMap {
}
/// Lookup source information about a BytePos
pub fn lookup_char_pos(&self, +pos: BytePos) -> Loc {
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
return self.lookup_pos(pos);
}
pub fn lookup_char_pos_adj(&self, +pos: BytePos) -> LocWithOpt
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt
{
let loc = self.lookup_char_pos(pos);
match (loc.file.substr) {
@@ -405,7 +405,7 @@ pub impl CodeMap {
priv impl CodeMap {
fn lookup_filemap_idx(&self, +pos: BytePos) -> uint {
fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
let files = &*self.files;
let len = files.len();
let mut a = 0u;
@@ -440,7 +440,7 @@ priv impl CodeMap {
return FileMapAndLine {fm: f, line: a};
}
fn lookup_pos(&self, +pos: BytePos) -> Loc {
fn lookup_pos(&self, pos: BytePos) -> Loc {
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
let line = a + 1u; // Line numbers start at 1
let chpos = self.bytepos_to_local_charpos(pos);
@@ -466,7 +466,7 @@ priv impl CodeMap {
lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint())
}
fn lookup_byte_offset(&self, +bpos: BytePos)
fn lookup_byte_offset(&self, bpos: BytePos)
-> FileMapAndBytePos {
let idx = self.lookup_filemap_idx(bpos);
let fm = self.files[idx];
@@ -476,7 +476,7 @@ priv impl CodeMap {
// Converts an absolute BytePos to a CharPos relative to the file it is
// located in
fn bytepos_to_local_charpos(&self, +bpos: BytePos) -> CharPos {
fn bytepos_to_local_charpos(&self, bpos: BytePos) -> CharPos {
debug!("codemap: converting %? to char pos", bpos);
let idx = self.lookup_filemap_idx(bpos);
let map = self.files[idx];