1
Fork 0

syntax: Fix fallout of removing get()

This commit is contained in:
Alex Crichton 2014-03-20 15:05:37 -07:00
parent cd510b3382
commit f3682b5639
12 changed files with 159 additions and 209 deletions

View file

@ -40,7 +40,7 @@ impl PathElem {
impl fmt::Show for PathElem { impl fmt::Show for PathElem {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let slot = token::get_name(self.name()); let slot = token::get_name(self.name());
write!(f.buf, "{}", slot.get()) write!(f.buf, "{}", slot)
} }
} }
@ -190,8 +190,8 @@ pub struct Map {
impl Map { impl Map {
fn find_entry(&self, id: NodeId) -> Option<MapEntry> { fn find_entry(&self, id: NodeId) -> Option<MapEntry> {
let map = self.map.borrow(); let map = self.map.borrow();
if map.get().len() > id as uint { if map.len() > id as uint {
Some(*map.get().get(id as uint)) Some(*map.get(id as uint))
} else { } else {
None None
} }
@ -395,8 +395,7 @@ pub struct Ctx<'a, F> {
impl<'a, F> Ctx<'a, F> { impl<'a, F> Ctx<'a, F> {
fn insert(&self, id: NodeId, entry: MapEntry) { fn insert(&self, id: NodeId, entry: MapEntry) {
let mut map = self.map.map.borrow_mut(); (*self.map.map.borrow_mut()).grow_set(id as uint, &NotPresent, entry);
map.get().grow_set(id as uint, &NotPresent, entry);
} }
} }
@ -540,7 +539,7 @@ pub fn map_crate<F: FoldOps>(krate: Crate, fold_ops: F) -> (Crate, Map) {
let map = map.map.borrow(); let map = map.map.borrow();
// This only makes sense for ordered stores; note the // This only makes sense for ordered stores; note the
// enumerate to count the number of entries. // enumerate to count the number of entries.
let (entries_less_1, _) = map.get().iter().filter(|&x| { let (entries_less_1, _) = (*map).iter().filter(|&x| {
match *x { match *x {
NotPresent => false, NotPresent => false,
_ => true _ => true
@ -548,7 +547,7 @@ pub fn map_crate<F: FoldOps>(krate: Crate, fold_ops: F) -> (Crate, Map) {
}).enumerate().last().expect("AST map was empty after folding?"); }).enumerate().last().expect("AST map was empty after folding?");
let entries = entries_less_1 + 1; let entries = entries_less_1 + 1;
let vector_length = map.get().len(); let vector_length = (*map).len();
debug!("The AST map has {} entries with a maximum of {}: occupancy {:.1}%", debug!("The AST map has {} entries with a maximum of {}: occupancy {:.1}%",
entries, vector_length, (entries as f64 / vector_length as f64) * 100.); entries, vector_length, (entries as f64 / vector_length as f64) * 100.);
} }

View file

@ -228,15 +228,15 @@ impl FileMap {
pub fn next_line(&self, pos: BytePos) { pub fn next_line(&self, pos: BytePos) {
// the new charpos must be > the last one (or it's the first one). // the new charpos must be > the last one (or it's the first one).
let mut lines = self.lines.borrow_mut();; let mut lines = self.lines.borrow_mut();;
let line_len = lines.get().len(); let line_len = lines.len();
assert!(line_len == 0 || (*lines.get().get(line_len - 1) < pos)) assert!(line_len == 0 || (*lines.get(line_len - 1) < pos))
lines.get().push(pos); lines.push(pos);
} }
// get a line from the list of pre-computed line-beginnings // get a line from the list of pre-computed line-beginnings
pub fn get_line(&self, line: int) -> ~str { pub fn get_line(&self, line: int) -> ~str {
let mut lines = self.lines.borrow_mut(); let mut lines = self.lines.borrow_mut();
let begin: BytePos = *lines.get().get(line as uint) - self.start_pos; let begin: BytePos = *lines.get(line as uint) - self.start_pos;
let begin = begin.to_uint(); let begin = begin.to_uint();
let slice = self.src.slice_from(begin); let slice = self.src.slice_from(begin);
match slice.find('\n') { match slice.find('\n') {
@ -251,7 +251,7 @@ impl FileMap {
pos: pos, pos: pos,
bytes: bytes, bytes: bytes,
}; };
self.multibyte_chars.borrow_mut().get().push(mbc); self.multibyte_chars.borrow_mut().push(mbc);
} }
pub fn is_real_file(&self) -> bool { pub fn is_real_file(&self) -> bool {
@ -272,9 +272,9 @@ impl CodeMap {
pub fn new_filemap(&self, filename: FileName, src: ~str) -> Rc<FileMap> { pub fn new_filemap(&self, filename: FileName, src: ~str) -> Rc<FileMap> {
let mut files = self.files.borrow_mut(); let mut files = self.files.borrow_mut();
let start_pos = match files.get().last() { let start_pos = match files.last() {
None => 0, None => 0,
Some(last) => last.deref().start_pos.to_uint() + last.deref().src.len(), Some(last) => last.start_pos.to_uint() + last.src.len(),
}; };
// Remove utf-8 BOM if any. // Remove utf-8 BOM if any.
@ -302,14 +302,14 @@ impl CodeMap {
multibyte_chars: RefCell::new(Vec::new()), multibyte_chars: RefCell::new(Vec::new()),
}); });
files.get().push(filemap.clone()); files.push(filemap.clone());
filemap filemap
} }
pub fn mk_substr_filename(&self, sp: Span) -> ~str { pub fn mk_substr_filename(&self, sp: Span) -> ~str {
let pos = self.lookup_char_pos(sp.lo); let pos = self.lookup_char_pos(sp.lo);
format!("<{}:{}:{}>", pos.file.deref().name, pos.line, pos.col.to_uint() + 1) format!("<{}:{}:{}>", pos.file.name, pos.line, pos.col.to_uint() + 1)
} }
/// Lookup source information about a BytePos /// Lookup source information about a BytePos
@ -320,7 +320,7 @@ impl CodeMap {
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); let loc = self.lookup_char_pos(pos);
LocWithOpt { LocWithOpt {
filename: loc.file.deref().name.to_str(), filename: loc.file.name.to_str(),
line: loc.line, line: loc.line,
col: loc.col, col: loc.col,
file: Some(loc.file) file: Some(loc.file)
@ -328,7 +328,7 @@ impl CodeMap {
} }
pub fn span_to_str(&self, sp: Span) -> ~str { pub fn span_to_str(&self, sp: Span) -> ~str {
if self.files.borrow().get().len() == 0 && sp == DUMMY_SP { if self.files.borrow().len() == 0 && sp == DUMMY_SP {
return ~"no-location"; return ~"no-location";
} }
@ -339,7 +339,7 @@ impl CodeMap {
} }
pub fn span_to_filename(&self, sp: Span) -> FileName { pub fn span_to_filename(&self, sp: Span) -> FileName {
self.lookup_char_pos(sp.lo).file.deref().name.to_str() self.lookup_char_pos(sp.lo).file.name.to_str()
} }
pub fn span_to_lines(&self, sp: Span) -> FileLines { pub fn span_to_lines(&self, sp: Span) -> FileLines {
@ -360,16 +360,16 @@ impl CodeMap {
// it's testing isn't true for all spans in the AST, so to allow the // it's testing isn't true for all spans in the AST, so to allow the
// caller to not have to fail (and it can't catch it since the CodeMap // caller to not have to fail (and it can't catch it since the CodeMap
// isn't sendable), return None // isn't sendable), return None
if begin.fm.deref().start_pos != end.fm.deref().start_pos { if begin.fm.start_pos != end.fm.start_pos {
None None
} else { } else {
Some(begin.fm.deref().src.slice( begin.pos.to_uint(), end.pos.to_uint()).to_owned()) Some(begin.fm.src.slice( begin.pos.to_uint(), end.pos.to_uint()).to_owned())
} }
} }
pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> { pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> {
for fm in self.files.borrow().get().iter() { for fm in self.files.borrow().iter() {
if filename == fm.deref().name { if filename == fm.name {
return fm.clone(); return fm.clone();
} }
} }
@ -378,13 +378,13 @@ impl CodeMap {
fn lookup_filemap_idx(&self, pos: BytePos) -> uint { fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
let files = self.files.borrow(); let files = self.files.borrow();
let files = files.get(); let files = files;
let len = files.len(); let len = files.len();
let mut a = 0u; let mut a = 0u;
let mut b = len; let mut b = len;
while b - a > 1u { while b - a > 1u {
let m = (a + b) / 2u; let m = (a + b) / 2u;
if files.get(m).deref().start_pos > pos { if files.get(m).start_pos > pos {
b = m; b = m;
} else { } else {
a = m; a = m;
@ -394,8 +394,8 @@ impl CodeMap {
// filemap, but are not the filemaps we want (because they are length 0, they cannot // filemap, but are not the filemaps we want (because they are length 0, they cannot
// contain what we are looking for). So, rewind until we find a useful filemap. // contain what we are looking for). So, rewind until we find a useful filemap.
loop { loop {
let lines = files.get(a).deref().lines.borrow(); let lines = files.get(a).lines.borrow();
let lines = lines.get(); let lines = lines;
if lines.len() > 0 { if lines.len() > 0 {
break; break;
} }
@ -415,14 +415,14 @@ impl CodeMap {
let idx = self.lookup_filemap_idx(pos); let idx = self.lookup_filemap_idx(pos);
let files = self.files.borrow(); let files = self.files.borrow();
let f = files.get().get(idx).clone(); let f = files.get(idx).clone();
let mut a = 0u; let mut a = 0u;
{ {
let mut lines = f.deref().lines.borrow_mut(); let mut lines = f.lines.borrow_mut();
let mut b = lines.get().len(); let mut b = lines.len();
while b - a > 1u { while b - a > 1u {
let m = (a + b) / 2u; let m = (a + b) / 2u;
if *lines.get().get(m) > pos { b = m; } else { a = m; } if *lines.get(m) > pos { b = m; } else { a = m; }
} }
} }
FileMapAndLine {fm: f, line: a} FileMapAndLine {fm: f, line: a}
@ -432,7 +432,7 @@ impl CodeMap {
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos); let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
let line = a + 1u; // Line numbers start at 1 let line = a + 1u; // Line numbers start at 1
let chpos = self.bytepos_to_file_charpos(pos); let chpos = self.bytepos_to_file_charpos(pos);
let linebpos = *f.deref().lines.borrow().get().get(a); let linebpos = *f.lines.borrow().get(a);
let linechpos = self.bytepos_to_file_charpos(linebpos); let linechpos = self.bytepos_to_file_charpos(linebpos);
debug!("codemap: byte pos {:?} is on the line at byte pos {:?}", debug!("codemap: byte pos {:?} is on the line at byte pos {:?}",
pos, linebpos); pos, linebpos);
@ -449,8 +449,8 @@ impl CodeMap {
fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {
let idx = self.lookup_filemap_idx(bpos); let idx = self.lookup_filemap_idx(bpos);
let fm = self.files.borrow().get().get(idx).clone(); let fm = self.files.borrow().get(idx).clone();
let offset = bpos - fm.deref().start_pos; let offset = bpos - fm.start_pos;
FileMapAndBytePos {fm: fm, pos: offset} FileMapAndBytePos {fm: fm, pos: offset}
} }
@ -459,12 +459,12 @@ impl CodeMap {
debug!("codemap: converting {:?} to char pos", bpos); debug!("codemap: converting {:?} to char pos", bpos);
let idx = self.lookup_filemap_idx(bpos); let idx = self.lookup_filemap_idx(bpos);
let files = self.files.borrow(); let files = self.files.borrow();
let map = files.get().get(idx); let map = files.get(idx);
// The number of extra bytes due to multibyte chars in the FileMap // The number of extra bytes due to multibyte chars in the FileMap
let mut total_extra_bytes = 0; let mut total_extra_bytes = 0;
for mbc in map.deref().multibyte_chars.borrow().get().iter() { for mbc in map.multibyte_chars.borrow().iter() {
debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos); debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos);
if mbc.pos < bpos { if mbc.pos < bpos {
// every character is at least one byte, so we only // every character is at least one byte, so we only
@ -478,8 +478,8 @@ impl CodeMap {
} }
} }
assert!(map.deref().start_pos.to_uint() + total_extra_bytes <= bpos.to_uint()); assert!(map.start_pos.to_uint() + total_extra_bytes <= bpos.to_uint());
CharPos(bpos.to_uint() - map.deref().start_pos.to_uint() - total_extra_bytes) CharPos(bpos.to_uint() - map.start_pos.to_uint() - total_extra_bytes)
} }
} }

View file

@ -84,11 +84,11 @@ pub struct Handler {
impl Handler { impl Handler {
pub fn fatal(&self, msg: &str) -> ! { pub fn fatal(&self, msg: &str) -> ! {
self.emit.borrow_mut().get().emit(None, msg, Fatal); self.emit.borrow_mut().emit(None, msg, Fatal);
fail!(FatalError); fail!(FatalError);
} }
pub fn err(&self, msg: &str) { pub fn err(&self, msg: &str) {
self.emit.borrow_mut().get().emit(None, msg, Error); self.emit.borrow_mut().emit(None, msg, Error);
self.bump_err_count(); self.bump_err_count();
} }
pub fn bump_err_count(&self) { pub fn bump_err_count(&self) {
@ -113,13 +113,13 @@ impl Handler {
self.fatal(s); self.fatal(s);
} }
pub fn warn(&self, msg: &str) { pub fn warn(&self, msg: &str) {
self.emit.borrow_mut().get().emit(None, msg, Warning); self.emit.borrow_mut().emit(None, msg, Warning);
} }
pub fn note(&self, msg: &str) { pub fn note(&self, msg: &str) {
self.emit.borrow_mut().get().emit(None, msg, Note); self.emit.borrow_mut().emit(None, msg, Note);
} }
pub fn bug(&self, msg: &str) -> ! { pub fn bug(&self, msg: &str) -> ! {
self.emit.borrow_mut().get().emit(None, msg, Bug); self.emit.borrow_mut().emit(None, msg, Bug);
fail!(ExplicitBug); fail!(ExplicitBug);
} }
pub fn unimpl(&self, msg: &str) -> ! { pub fn unimpl(&self, msg: &str) -> ! {
@ -129,11 +129,11 @@ impl Handler {
cmsp: Option<(&codemap::CodeMap, Span)>, cmsp: Option<(&codemap::CodeMap, Span)>,
msg: &str, msg: &str,
lvl: Level) { lvl: Level) {
self.emit.borrow_mut().get().emit(cmsp, msg, lvl); self.emit.borrow_mut().emit(cmsp, msg, lvl);
} }
pub fn custom_emit(&self, cm: &codemap::CodeMap, pub fn custom_emit(&self, cm: &codemap::CodeMap,
sp: Span, msg: &str, lvl: Level) { sp: Span, msg: &str, lvl: Level) {
self.emit.borrow_mut().get().custom_emit(cm, sp, msg, lvl); self.emit.borrow_mut().custom_emit(cm, sp, msg, lvl);
} }
} }
@ -301,7 +301,7 @@ fn highlight_lines(err: &mut EmitterWriter,
sp: Span, sp: Span,
lvl: Level, lvl: Level,
lines: codemap::FileLines) -> io::IoResult<()> { lines: codemap::FileLines) -> io::IoResult<()> {
let fm = lines.file.deref(); let fm = &*lines.file;
let mut elided = false; let mut elided = false;
let mut display_lines = lines.lines.as_slice(); let mut display_lines = lines.lines.as_slice();
@ -374,7 +374,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter,
sp: Span, sp: Span,
lvl: Level, lvl: Level,
lines: codemap::FileLines) -> io::IoResult<()> { lines: codemap::FileLines) -> io::IoResult<()> {
let fm = lines.file.deref(); let fm = &*lines.file;
let lines = lines.lines.as_slice(); let lines = lines.lines.as_slice();
if lines.len() > MAX_LINES { if lines.len() > MAX_LINES {

View file

@ -628,7 +628,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
vec!( vec!(
self.expr_str(span, msg), self.expr_str(span, msg),
self.expr_str(span, self.expr_str(span,
token::intern_and_get_ident(loc.file.deref().name)), token::intern_and_get_ident(loc.file.name)),
self.expr_uint(span, loc.line))) self.expr_uint(span, loc.line)))
} }

View file

@ -63,11 +63,10 @@ pub fn new_mark(m: Mrk, tail: SyntaxContext) -> SyntaxContext {
// Extend a syntax context with a given mark and table // Extend a syntax context with a given mark and table
fn new_mark_internal(m: Mrk, tail: SyntaxContext, table: &SCTable) -> SyntaxContext { fn new_mark_internal(m: Mrk, tail: SyntaxContext, table: &SCTable) -> SyntaxContext {
let key = (tail, m); let key = (tail, m);
let mut mark_memo = table.mark_memo.borrow_mut();
let new_ctxt = |_: &(SyntaxContext, Mrk)| let new_ctxt = |_: &(SyntaxContext, Mrk)|
idx_push(table.table.borrow_mut().get(), Mark(m, tail)); idx_push(&mut *table.table.borrow_mut(), Mark(m, tail));
*mark_memo.get().find_or_insert_with(key, new_ctxt) *table.mark_memo.borrow_mut().find_or_insert_with(key, new_ctxt)
} }
/// Extend a syntax context with a given rename /// Extend a syntax context with a given rename
@ -82,11 +81,10 @@ fn new_rename_internal(id: Ident,
tail: SyntaxContext, tail: SyntaxContext,
table: &SCTable) -> SyntaxContext { table: &SCTable) -> SyntaxContext {
let key = (tail,id,to); let key = (tail,id,to);
let mut rename_memo = table.rename_memo.borrow_mut();
let new_ctxt = |_: &(SyntaxContext, Ident, Mrk)| let new_ctxt = |_: &(SyntaxContext, Ident, Mrk)|
idx_push(table.table.borrow_mut().get(), Rename(id, to, tail)); idx_push(&mut *table.table.borrow_mut(), Rename(id, to, tail));
*rename_memo.get().find_or_insert_with(key, new_ctxt) *table.rename_memo.borrow_mut().find_or_insert_with(key, new_ctxt)
} }
/// Fetch the SCTable from TLS, create one if it doesn't yet exist. /// Fetch the SCTable from TLS, create one if it doesn't yet exist.
@ -102,7 +100,7 @@ pub fn with_sctable<T>(op: |&SCTable| -> T) -> T {
} }
Some(ts) => ts.clone() Some(ts) => ts.clone()
}; };
op(table.deref()) op(&*table)
}) })
} }
@ -119,8 +117,7 @@ fn new_sctable_internal() -> SCTable {
/// Print out an SCTable for debugging /// Print out an SCTable for debugging
pub fn display_sctable(table: &SCTable) { pub fn display_sctable(table: &SCTable) {
error!("SC table:"); error!("SC table:");
let table = table.table.borrow(); for (idx,val) in table.table.borrow().iter().enumerate() {
for (idx,val) in table.get().iter().enumerate() {
error!("{:4u} : {:?}",idx,val); error!("{:4u} : {:?}",idx,val);
} }
} }
@ -128,9 +125,9 @@ pub fn display_sctable(table: &SCTable) {
/// Clear the tables from TLD to reclaim memory. /// Clear the tables from TLD to reclaim memory.
pub fn clear_tables() { pub fn clear_tables() {
with_sctable(|table| { with_sctable(|table| {
*table.table.borrow_mut().get() = Vec::new(); *table.table.borrow_mut() = Vec::new();
*table.mark_memo.borrow_mut().get() = HashMap::new(); *table.mark_memo.borrow_mut() = HashMap::new();
*table.rename_memo.borrow_mut().get() = HashMap::new(); *table.rename_memo.borrow_mut() = HashMap::new();
}); });
with_resolve_table_mut(|table| *table = HashMap::new()); with_resolve_table_mut(|table| *table = HashMap::new());
} }
@ -166,7 +163,7 @@ fn with_resolve_table_mut<T>(op: |&mut ResolveTable| -> T) -> T {
} }
Some(ts) => ts.clone() Some(ts) => ts.clone()
}; };
op(table.deref().borrow_mut().get()) op(&mut *table.borrow_mut())
}) })
} }
@ -183,7 +180,7 @@ fn resolve_internal(id: Ident,
} }
let resolved = { let resolved = {
let result = *table.table.borrow().get().get(id.ctxt as uint); let result = *table.table.borrow().get(id.ctxt as uint);
match result { match result {
EmptyCtxt => id.name, EmptyCtxt => id.name,
// ignore marks here: // ignore marks here:
@ -227,10 +224,7 @@ fn marksof_internal(ctxt: SyntaxContext,
let mut result = Vec::new(); let mut result = Vec::new();
let mut loopvar = ctxt; let mut loopvar = ctxt;
loop { loop {
let table_entry = { let table_entry = *table.table.borrow().get(loopvar as uint);
let table = table.table.borrow();
*table.get().get(loopvar as uint)
};
match table_entry { match table_entry {
EmptyCtxt => { EmptyCtxt => {
return result; return result;
@ -257,7 +251,7 @@ fn marksof_internal(ctxt: SyntaxContext,
/// FAILS when outside is not a mark. /// FAILS when outside is not a mark.
pub fn outer_mark(ctxt: SyntaxContext) -> Mrk { pub fn outer_mark(ctxt: SyntaxContext) -> Mrk {
with_sctable(|sctable| { with_sctable(|sctable| {
match *sctable.table.borrow().get().get(ctxt as uint) { match *sctable.table.borrow().get(ctxt as uint) {
Mark(mrk, _) => mrk, Mark(mrk, _) => mrk,
_ => fail!("can't retrieve outer mark when outside is not a mark") _ => fail!("can't retrieve outer mark when outside is not a mark")
} }
@ -327,7 +321,7 @@ mod tests {
let mut result = Vec::new(); let mut result = Vec::new();
loop { loop {
let table = table.table.borrow(); let table = table.table.borrow();
match *table.get().get(sc as uint) { match *table.get(sc as uint) {
EmptyCtxt => {return result;}, EmptyCtxt => {return result;},
Mark(mrk,tail) => { Mark(mrk,tail) => {
result.push(M(mrk)); result.push(M(mrk));
@ -351,9 +345,9 @@ mod tests {
assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4); assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4);
{ {
let table = t.table.borrow(); let table = t.table.borrow();
assert!(*table.get().get(2) == Mark(9,0)); assert!(*table.get(2) == Mark(9,0));
assert!(*table.get().get(3) == Rename(id(101,0),14,2)); assert!(*table.get(3) == Rename(id(101,0),14,2));
assert!(*table.get().get(4) == Mark(3,3)); assert!(*table.get(4) == Mark(3,3));
} }
assert_eq!(refold_test_sc(4,&t),test_sc); assert_eq!(refold_test_sc(4,&t),test_sc);
} }
@ -372,8 +366,8 @@ mod tests {
assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),3); assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),3);
{ {
let table = t.table.borrow(); let table = t.table.borrow();
assert!(*table.get().get(2) == Mark(7,0)); assert!(*table.get(2) == Mark(7,0));
assert!(*table.get().get(3) == Mark(3,2)); assert!(*table.get(3) == Mark(3,2));
} }
} }

View file

@ -57,7 +57,7 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
let topmost = topmost_expn_info(cx.backtrace().unwrap()); let topmost = topmost_expn_info(cx.backtrace().unwrap());
let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo);
let filename = token::intern_and_get_ident(loc.file.deref().name); let filename = token::intern_and_get_ident(loc.file.name);
base::MRExpr(cx.expr_str(topmost.call_site, filename)) base::MRExpr(cx.expr_str(topmost.call_site, filename))
} }

View file

@ -42,26 +42,23 @@ impl<'a> ParserAnyMacro<'a> {
/// allowed to be there. /// allowed to be there.
fn ensure_complete_parse(&self, allow_semi: bool) { fn ensure_complete_parse(&self, allow_semi: bool) {
let mut parser = self.parser.borrow_mut(); let mut parser = self.parser.borrow_mut();
if allow_semi && parser.get().token == SEMI { if allow_semi && parser.token == SEMI {
parser.get().bump() parser.bump()
} }
if parser.get().token != EOF { if parser.token != EOF {
let token_str = parser.get().this_token_to_str(); let token_str = parser.this_token_to_str();
let msg = format!("macro expansion ignores token `{}` and any \ let msg = format!("macro expansion ignores token `{}` and any \
following", following",
token_str); token_str);
let span = parser.get().span; let span = parser.span;
parser.get().span_err(span, msg); parser.span_err(span, msg);
} }
} }
} }
impl<'a> AnyMacro for ParserAnyMacro<'a> { impl<'a> AnyMacro for ParserAnyMacro<'a> {
fn make_expr(&self) -> @ast::Expr { fn make_expr(&self) -> @ast::Expr {
let ret = { let ret = self.parser.borrow_mut().parse_expr();
let mut parser = self.parser.borrow_mut();
parser.get().parse_expr()
};
self.ensure_complete_parse(true); self.ensure_complete_parse(true);
ret ret
} }
@ -69,8 +66,8 @@ impl<'a> AnyMacro for ParserAnyMacro<'a> {
let mut ret = SmallVector::zero(); let mut ret = SmallVector::zero();
loop { loop {
let mut parser = self.parser.borrow_mut(); let mut parser = self.parser.borrow_mut();
let attrs = parser.get().parse_outer_attributes(); let attrs = parser.parse_outer_attributes();
match parser.get().parse_item(attrs) { match parser.parse_item(attrs) {
Some(item) => ret.push(item), Some(item) => ret.push(item),
None => break None => break
} }
@ -79,11 +76,8 @@ impl<'a> AnyMacro for ParserAnyMacro<'a> {
ret ret
} }
fn make_stmt(&self) -> @ast::Stmt { fn make_stmt(&self) -> @ast::Stmt {
let ret = { let attrs = self.parser.borrow_mut().parse_outer_attributes();
let mut parser = self.parser.borrow_mut(); let ret = self.parser.borrow_mut().parse_stmt(attrs);
let attrs = parser.get().parse_outer_attributes();
parser.get().parse_stmt(attrs)
};
self.ensure_complete_parse(true); self.ensure_complete_parse(true);
ret ret
} }
@ -242,7 +236,7 @@ pub fn add_new_extension(cx: &mut ExtCtxt,
}; };
return MRDef(MacroDef { return MRDef(MacroDef {
name: token::get_ident(name).get().to_str(), name: token::get_ident(name).to_str(),
ext: NormalTT(exp, Some(sp)) ext: NormalTT(exp, Some(sp))
}); });
} }

View file

@ -109,15 +109,11 @@ fn lookup_cur_matched_by_matched(r: &TtReader, start: @NamedMatch)
MatchedSeq(ref ads, _) => *ads.get(*idx) MatchedSeq(ref ads, _) => *ads.get(*idx)
} }
} }
let repeat_idx = r.repeat_idx.borrow(); r.repeat_idx.borrow().iter().fold(start, red)
repeat_idx.get().iter().fold(start, red)
} }
fn lookup_cur_matched(r: &TtReader, name: Ident) -> @NamedMatch { fn lookup_cur_matched(r: &TtReader, name: Ident) -> @NamedMatch {
let matched_opt = { let matched_opt = r.interpolations.borrow().find_copy(&name);
let interpolations = r.interpolations.borrow();
interpolations.get().find_copy(&name)
};
match matched_opt { match matched_opt {
Some(s) => lookup_cur_matched_by_matched(r, s), Some(s) => lookup_cur_matched_by_matched(r, s),
None => { None => {
@ -178,19 +174,14 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan {
sp: r.cur_span.get(), sp: r.cur_span.get(),
}; };
loop { loop {
{ if r.stack.borrow().idx.get() < r.stack.borrow().forest.len() {
let mut stack = r.stack.borrow_mut();
if stack.get().idx.get() < stack.get().forest.len() {
break; break;
} }
}
/* done with this set; pop or repeat? */ /* done with this set; pop or repeat? */
if !r.stack.get().dotdotdoted || { if !r.stack.get().dotdotdoted || {
let repeat_idx = r.repeat_idx.borrow(); *r.repeat_idx.borrow().last().unwrap() ==
let repeat_len = r.repeat_len.borrow(); *r.repeat_len.borrow().last().unwrap() - 1
*repeat_idx.get().last().unwrap() ==
*repeat_len.get().last().unwrap() - 1
} { } {
match r.stack.get().up { match r.stack.get().up {
@ -200,12 +191,8 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan {
} }
Some(tt_f) => { Some(tt_f) => {
if r.stack.get().dotdotdoted { if r.stack.get().dotdotdoted {
{ r.repeat_idx.borrow_mut().pop().unwrap();
let mut repeat_idx = r.repeat_idx.borrow_mut(); r.repeat_len.borrow_mut().pop().unwrap();
let mut repeat_len = r.repeat_len.borrow_mut();
repeat_idx.get().pop().unwrap();
repeat_len.get().pop().unwrap();
}
} }
r.stack.set(tt_f); r.stack.set(tt_f);
@ -217,8 +204,8 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan {
r.stack.get().idx.set(0u); r.stack.get().idx.set(0u);
{ {
let mut repeat_idx = r.repeat_idx.borrow_mut(); let mut repeat_idx = r.repeat_idx.borrow_mut();
let last_repeat_idx = repeat_idx.get().len() - 1u; let last_repeat_idx = repeat_idx.len() - 1u;
*repeat_idx.get().get_mut(last_repeat_idx) += 1u; *repeat_idx.get_mut(last_repeat_idx) += 1u;
} }
match r.stack.get().sep.clone() { match r.stack.get().sep.clone() {
Some(tk) => { Some(tk) => {
@ -276,11 +263,8 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan {
r.stack.get().idx.set(r.stack.get().idx.get() + 1u); r.stack.get().idx.set(r.stack.get().idx.get() + 1u);
return tt_next_token(r); return tt_next_token(r);
} else { } else {
{ r.repeat_len.borrow_mut().push(len);
let mut repeat_idx = r.repeat_idx.borrow_mut(); r.repeat_idx.borrow_mut().push(0u);
let mut repeat_len = r.repeat_len.borrow_mut();
repeat_len.get().push(len);
repeat_idx.get().push(0u);
r.stack.set(@TtFrame { r.stack.set(@TtFrame {
forest: tts, forest: tts,
idx: Cell::new(0u), idx: Cell::new(0u),
@ -292,7 +276,6 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan {
} }
} }
} }
}
// FIXME #2887: think about span stuff here // FIXME #2887: think about span stuff here
TTNonterminal(sp, ident) => { TTNonterminal(sp, ident) => {
match *lookup_cur_matched(r, ident) { match *lookup_cur_matched(r, ident) {

View file

@ -78,8 +78,8 @@ pub fn new_low_level_string_reader<'a>(span_diagnostic: &'a SpanHandler,
let initial_char = '\n'; let initial_char = '\n';
let r = StringReader { let r = StringReader {
span_diagnostic: span_diagnostic, span_diagnostic: span_diagnostic,
pos: Cell::new(filemap.deref().start_pos), pos: Cell::new(filemap.start_pos),
last_pos: Cell::new(filemap.deref().start_pos), last_pos: Cell::new(filemap.start_pos),
col: Cell::new(CharPos(0)), col: Cell::new(CharPos(0)),
curr: Cell::new(Some(initial_char)), curr: Cell::new(Some(initial_char)),
filemap: filemap, filemap: filemap,
@ -111,12 +111,9 @@ impl<'a> Reader for StringReader<'a> {
fn is_eof(&self) -> bool { is_eof(self) } fn is_eof(&self) -> bool { is_eof(self) }
// return the next token. EFFECT: advances the string_reader. // return the next token. EFFECT: advances the string_reader.
fn next_token(&self) -> TokenAndSpan { fn next_token(&self) -> TokenAndSpan {
let ret_val = { let ret_val = TokenAndSpan {
let mut peek_tok = self.peek_tok.borrow_mut(); tok: replace(&mut *self.peek_tok.borrow_mut(), token::UNDERSCORE),
TokenAndSpan {
tok: replace(peek_tok.get(), token::UNDERSCORE),
sp: self.peek_span.get(), sp: self.peek_span.get(),
}
}; };
string_advance_token(self); string_advance_token(self);
ret_val ret_val
@ -137,8 +134,7 @@ impl<'a> Reader for StringReader<'a> {
impl<'a> Reader for TtReader<'a> { impl<'a> Reader for TtReader<'a> {
fn is_eof(&self) -> bool { fn is_eof(&self) -> bool {
let cur_tok = self.cur_tok.borrow(); *self.cur_tok.borrow() == token::EOF
*cur_tok.get() == token::EOF
} }
fn next_token(&self) -> TokenAndSpan { fn next_token(&self) -> TokenAndSpan {
let r = tt_next_token(self); let r = tt_next_token(self);
@ -191,7 +187,7 @@ fn fatal_span_verbose(rdr: &StringReader,
-> ! { -> ! {
let mut m = m; let mut m = m;
m.push_str(": "); m.push_str(": ");
let s = rdr.filemap.deref().src.slice( let s = rdr.filemap.src.slice(
byte_offset(rdr, from_pos).to_uint(), byte_offset(rdr, from_pos).to_uint(),
byte_offset(rdr, to_pos).to_uint()); byte_offset(rdr, to_pos).to_uint());
m.push_str(s); m.push_str(s);
@ -220,7 +216,7 @@ fn string_advance_token(r: &StringReader) {
} }
fn byte_offset(rdr: &StringReader, pos: BytePos) -> BytePos { fn byte_offset(rdr: &StringReader, pos: BytePos) -> BytePos {
(pos - rdr.filemap.deref().start_pos) (pos - rdr.filemap.start_pos)
} }
/// Calls `f` with a string slice of the source text spanning from `start` /// Calls `f` with a string slice of the source text spanning from `start`
@ -242,7 +238,7 @@ fn with_str_from_to<T>(
end: BytePos, end: BytePos,
f: |s: &str| -> T) f: |s: &str| -> T)
-> T { -> T {
f(rdr.filemap.deref().src.slice( f(rdr.filemap.src.slice(
byte_offset(rdr, start).to_uint(), byte_offset(rdr, start).to_uint(),
byte_offset(rdr, end).to_uint())) byte_offset(rdr, end).to_uint()))
} }
@ -252,21 +248,21 @@ fn with_str_from_to<T>(
pub fn bump(rdr: &StringReader) { pub fn bump(rdr: &StringReader) {
rdr.last_pos.set(rdr.pos.get()); rdr.last_pos.set(rdr.pos.get());
let current_byte_offset = byte_offset(rdr, rdr.pos.get()).to_uint(); let current_byte_offset = byte_offset(rdr, rdr.pos.get()).to_uint();
if current_byte_offset < rdr.filemap.deref().src.len() { if current_byte_offset < rdr.filemap.src.len() {
assert!(rdr.curr.get().is_some()); assert!(rdr.curr.get().is_some());
let last_char = rdr.curr.get().unwrap(); let last_char = rdr.curr.get().unwrap();
let next = rdr.filemap.deref().src.char_range_at(current_byte_offset); let next = rdr.filemap.src.char_range_at(current_byte_offset);
let byte_offset_diff = next.next - current_byte_offset; let byte_offset_diff = next.next - current_byte_offset;
rdr.pos.set(rdr.pos.get() + Pos::from_uint(byte_offset_diff)); rdr.pos.set(rdr.pos.get() + Pos::from_uint(byte_offset_diff));
rdr.curr.set(Some(next.ch)); rdr.curr.set(Some(next.ch));
rdr.col.set(rdr.col.get() + CharPos(1u)); rdr.col.set(rdr.col.get() + CharPos(1u));
if last_char == '\n' { if last_char == '\n' {
rdr.filemap.deref().next_line(rdr.last_pos.get()); rdr.filemap.next_line(rdr.last_pos.get());
rdr.col.set(CharPos(0u)); rdr.col.set(CharPos(0u));
} }
if byte_offset_diff > 1 { if byte_offset_diff > 1 {
rdr.filemap.deref().record_multibyte_char(rdr.last_pos.get(), byte_offset_diff); rdr.filemap.record_multibyte_char(rdr.last_pos.get(), byte_offset_diff);
} }
} else { } else {
rdr.curr.set(None); rdr.curr.set(None);
@ -279,8 +275,8 @@ pub fn is_eof(rdr: &StringReader) -> bool {
pub fn nextch(rdr: &StringReader) -> Option<char> { pub fn nextch(rdr: &StringReader) -> Option<char> {
let offset = byte_offset(rdr, rdr.pos.get()).to_uint(); let offset = byte_offset(rdr, rdr.pos.get()).to_uint();
if offset < rdr.filemap.deref().src.len() { if offset < rdr.filemap.src.len() {
Some(rdr.filemap.deref().src.char_at(offset)) Some(rdr.filemap.src.char_at(offset))
} else { } else {
None None
} }
@ -397,7 +393,7 @@ fn consume_any_line_comment(rdr: &StringReader)
// I guess this is the only way to figure out if // I guess this is the only way to figure out if
// we're at the beginning of the file... // we're at the beginning of the file...
let cmap = CodeMap::new(); let cmap = CodeMap::new();
cmap.files.borrow_mut().get().push(rdr.filemap.clone()); cmap.files.borrow_mut().push(rdr.filemap.clone());
let loc = cmap.lookup_char_pos_adj(rdr.last_pos.get()); let loc = cmap.lookup_char_pos_adj(rdr.last_pos.get());
if loc.line == 1u && loc.col == CharPos(0u) { if loc.line == 1u && loc.col == CharPos(0u) {
while !rdr.curr_is('\n') && !is_eof(rdr) { bump(rdr); } while !rdr.curr_is('\n') && !is_eof(rdr) { bump(rdr); }

View file

@ -4203,18 +4203,12 @@ impl<'a> Parser<'a> {
path: Path, path: Path,
outer_attrs: Vec<ast::Attribute> , outer_attrs: Vec<ast::Attribute> ,
id_sp: Span) -> (ast::Item_, Vec<ast::Attribute> ) { id_sp: Span) -> (ast::Item_, Vec<ast::Attribute> ) {
{ let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
let mut included_mod_stack = self.sess match included_mod_stack.iter().position(|p| *p == path) {
.included_mod_stack
.borrow_mut();
let maybe_i = included_mod_stack.get()
.iter()
.position(|p| *p == path);
match maybe_i {
Some(i) => { Some(i) => {
let mut err = ~"circular modules: "; let mut err = ~"circular modules: ";
let len = included_mod_stack.get().len(); let len = included_mod_stack.len();
for p in included_mod_stack.get().slice(i, len).iter() { for p in included_mod_stack.slice(i, len).iter() {
err.push_str(p.display().as_maybe_owned().as_slice()); err.push_str(p.display().as_maybe_owned().as_slice());
err.push_str(" -> "); err.push_str(" -> ");
} }
@ -4223,8 +4217,8 @@ impl<'a> Parser<'a> {
} }
None => () None => ()
} }
included_mod_stack.get().push(path.clone()); included_mod_stack.push(path.clone());
} drop(included_mod_stack);
let mut p0 = let mut p0 =
new_sub_parser_from_file(self.sess, new_sub_parser_from_file(self.sess,
@ -4235,12 +4229,7 @@ impl<'a> Parser<'a> {
let mod_attrs = vec::append(outer_attrs, inner.as_slice()); let mod_attrs = vec::append(outer_attrs, inner.as_slice());
let first_item_outer_attrs = next; let first_item_outer_attrs = next;
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs); let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
{ self.sess.included_mod_stack.borrow_mut().pop();
let mut included_mod_stack = self.sess
.included_mod_stack
.borrow_mut();
included_mod_stack.get().pop();
}
return (ast::ItemMod(m0), mod_attrs); return (ast::ItemMod(m0), mod_attrs);
} }

View file

@ -238,23 +238,23 @@ pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> ~str {
impl<'a> State<'a> { impl<'a> State<'a> {
pub fn ibox(&mut self, u: uint) -> IoResult<()> { pub fn ibox(&mut self, u: uint) -> IoResult<()> {
self.boxes.borrow_mut().get().push(pp::Inconsistent); self.boxes.borrow_mut().push(pp::Inconsistent);
pp::ibox(&mut self.s, u) pp::ibox(&mut self.s, u)
} }
pub fn end(&mut self) -> IoResult<()> { pub fn end(&mut self) -> IoResult<()> {
self.boxes.borrow_mut().get().pop().unwrap(); self.boxes.borrow_mut().pop().unwrap();
pp::end(&mut self.s) pp::end(&mut self.s)
} }
pub fn cbox(&mut self, u: uint) -> IoResult<()> { pub fn cbox(&mut self, u: uint) -> IoResult<()> {
self.boxes.borrow_mut().get().push(pp::Consistent); self.boxes.borrow_mut().push(pp::Consistent);
pp::cbox(&mut self.s, u) pp::cbox(&mut self.s, u)
} }
// "raw box" // "raw box"
pub fn rbox(&mut self, u: uint, b: pp::Breaks) -> IoResult<()> { pub fn rbox(&mut self, u: uint, b: pp::Breaks) -> IoResult<()> {
self.boxes.borrow_mut().get().push(b); self.boxes.borrow_mut().push(b);
pp::rbox(&mut self.s, u, b) pp::rbox(&mut self.s, u, b)
} }
@ -322,7 +322,7 @@ impl<'a> State<'a> {
} }
pub fn in_cbox(&mut self) -> bool { pub fn in_cbox(&mut self) -> bool {
match self.boxes.borrow().get().last() { match self.boxes.borrow().last() {
Some(&last_box) => last_box == pp::Consistent, Some(&last_box) => last_box == pp::Consistent,
None => false None => false
} }
@ -2186,7 +2186,7 @@ impl<'a> State<'a> {
ast::LitBinary(ref arr) => { ast::LitBinary(ref arr) => {
try!(self.ibox(indent_unit)); try!(self.ibox(indent_unit));
try!(word(&mut self.s, "[")); try!(word(&mut self.s, "["));
try!(self.commasep_cmnt(Inconsistent, arr.deref().as_slice(), try!(self.commasep_cmnt(Inconsistent, arr.as_slice(),
|s, u| word(&mut s.s, format!("{}", *u)), |s, u| word(&mut s.s, format!("{}", *u)),
|_| lit.span)); |_| lit.span));
try!(word(&mut self.s, "]")); try!(word(&mut self.s, "]"));

View file

@ -46,47 +46,47 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
pub fn intern(&self, val: T) -> Name { pub fn intern(&self, val: T) -> Name {
let mut map = self.map.borrow_mut(); let mut map = self.map.borrow_mut();
match map.get().find(&val) { match (*map).find(&val) {
Some(&idx) => return idx, Some(&idx) => return idx,
None => (), None => (),
} }
let mut vect = self.vect.borrow_mut(); let mut vect = self.vect.borrow_mut();
let new_idx = vect.get().len() as Name; let new_idx = (*vect).len() as Name;
map.get().insert(val.clone(), new_idx); (*map).insert(val.clone(), new_idx);
vect.get().push(val); (*vect).push(val);
new_idx new_idx
} }
pub fn gensym(&self, val: T) -> Name { pub fn gensym(&self, val: T) -> Name {
let mut vect = self.vect.borrow_mut(); let mut vect = self.vect.borrow_mut();
let new_idx = vect.get().len() as Name; let new_idx = (*vect).len() as Name;
// leave out of .map to avoid colliding // leave out of .map to avoid colliding
vect.get().push(val); (*vect).push(val);
new_idx new_idx
} }
pub fn get(&self, idx: Name) -> T { pub fn get(&self, idx: Name) -> T {
let vect = self.vect.borrow(); let vect = self.vect.borrow();
(*vect.get().get(idx as uint)).clone() (*(*vect).get(idx as uint)).clone()
} }
pub fn len(&self) -> uint { pub fn len(&self) -> uint {
let vect = self.vect.borrow(); let vect = self.vect.borrow();
vect.get().len() (*vect).len()
} }
pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> { pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
let map = self.map.borrow(); let map = self.map.borrow();
match map.get().find_equiv(val) { match (*map).find_equiv(val) {
Some(v) => Some(*v), Some(v) => Some(*v),
None => None, None => None,
} }
} }
pub fn clear(&self) { pub fn clear(&self) {
*self.map.borrow_mut().get() = HashMap::new(); *self.map.borrow_mut() = HashMap::new();
*self.vect.borrow_mut().get() = Vec::new(); *self.vect.borrow_mut() = Vec::new();
} }
} }
@ -110,13 +110,13 @@ impl TotalOrd for RcStr {
impl Str for RcStr { impl Str for RcStr {
#[inline] #[inline]
fn as_slice<'a>(&'a self) -> &'a str { fn as_slice<'a>(&'a self) -> &'a str {
let s: &'a str = *self.string.deref(); let s: &'a str = *self.string;
s s
} }
#[inline] #[inline]
fn into_owned(self) -> ~str { fn into_owned(self) -> ~str {
self.string.deref().to_owned() self.string.to_owned()
} }
} }
@ -159,24 +159,22 @@ impl StrInterner {
pub fn intern(&self, val: &str) -> Name { pub fn intern(&self, val: &str) -> Name {
let mut map = self.map.borrow_mut(); let mut map = self.map.borrow_mut();
match map.get().find_equiv(&val) { match map.find_equiv(&val) {
Some(&idx) => return idx, Some(&idx) => return idx,
None => (), None => (),
} }
let new_idx = self.len() as Name; let new_idx = self.len() as Name;
let val = RcStr::new(val); let val = RcStr::new(val);
map.get().insert(val.clone(), new_idx); map.insert(val.clone(), new_idx);
let mut vect = self.vect.borrow_mut(); self.vect.borrow_mut().push(val);
vect.get().push(val);
new_idx new_idx
} }
pub fn gensym(&self, val: &str) -> Name { pub fn gensym(&self, val: &str) -> Name {
let new_idx = self.len() as Name; let new_idx = self.len() as Name;
// leave out of .map to avoid colliding // leave out of .map to avoid colliding
let mut vect = self.vect.borrow_mut(); self.vect.borrow_mut().push(RcStr::new(val));
vect.get().push(RcStr::new(val));
new_idx new_idx
} }
@ -194,42 +192,39 @@ impl StrInterner {
let new_idx = self.len() as Name; let new_idx = self.len() as Name;
// leave out of map to avoid colliding // leave out of map to avoid colliding
let mut vect = self.vect.borrow_mut(); let mut vect = self.vect.borrow_mut();
let existing = (*vect.get().get(idx as uint)).clone(); let existing = (*vect.get(idx as uint)).clone();
vect.get().push(existing); vect.push(existing);
new_idx new_idx
} }
pub fn get(&self, idx: Name) -> RcStr { pub fn get(&self, idx: Name) -> RcStr {
let vect = self.vect.borrow(); (*self.vect.borrow().get(idx as uint)).clone()
(*vect.get().get(idx as uint)).clone()
} }
/// Returns this string with lifetime tied to the interner. Since /// Returns this string with lifetime tied to the interner. Since
/// strings may never be removed from the interner, this is safe. /// strings may never be removed from the interner, this is safe.
pub fn get_ref<'a>(&'a self, idx: Name) -> &'a str { pub fn get_ref<'a>(&'a self, idx: Name) -> &'a str {
let vect = self.vect.borrow(); let vect = self.vect.borrow();
let s: &str = vect.get().get(idx as uint).as_slice(); let s: &str = vect.get(idx as uint).as_slice();
unsafe { unsafe {
cast::transmute(s) cast::transmute(s)
} }
} }
pub fn len(&self) -> uint { pub fn len(&self) -> uint {
let vect = self.vect.borrow(); self.vect.borrow().len()
vect.get().len()
} }
pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> { pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
let map = self.map.borrow(); match (*self.map.borrow()).find_equiv(val) {
match map.get().find_equiv(val) {
Some(v) => Some(*v), Some(v) => Some(*v),
None => None, None => None,
} }
} }
pub fn clear(&self) { pub fn clear(&self) {
*self.map.borrow_mut().get() = HashMap::new(); *self.map.borrow_mut() = HashMap::new();
*self.vect.borrow_mut().get() = Vec::new(); *self.vect.borrow_mut() = Vec::new();
} }
} }