diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 65adbb9e09e..9f1cc419d15 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -243,7 +243,7 @@ fn check_variants_T( filename: &Path, thing_label: ~str, things: ~[T], - stringifier: fn@(@T, syntax::parse::token::ident_interner) -> ~str, + stringifier: fn@(@T, @syntax::parse::token::ident_interner) -> ~str, replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate, cx: context ) { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 75a2081bc14..24dc3660faf 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -38,6 +38,10 @@ macro_rules! interner_key ( (-3 as uint, 0u))) ) +// FIXME(#3534): Replace with the struct-based newtype when it's been +// implemented. +struct ident { repr: uint } + fn serialize_ident(s: S, i: ident) { let intr = match unsafe{ task::local_data::local_data_get(interner_key!()) @@ -59,7 +63,16 @@ fn deserialize_ident(d: D) -> ident { (*intr).intern(@d.read_str()) } -type ident = token::str_num; +impl ident: cmp::Eq { + pure fn eq(other: &ident) -> bool { self.repr == other.repr } + pure fn ne(other: &ident) -> bool { !self.eq(other) } +} + +impl ident: to_bytes::IterBytes { + pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + self.repr.iter_bytes(lsb0, f) + } +} // Functions may or may not have names. #[auto_serialize] diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 9a3e94b737f..09922ade073 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -34,7 +34,7 @@ impl path_elt : cmp::Eq { type path = ~[path_elt]; /* FIXMEs that say "bad" are as per #2543 */ -fn path_to_str_with_sep(p: path, sep: ~str, itr: ident_interner) -> ~str { +fn path_to_str_with_sep(p: path, sep: ~str, itr: @ident_interner) -> ~str { let strs = do vec::map(p) |e| { match *e { path_mod(s) => *itr.get(s), @@ -44,7 +44,7 @@ fn path_to_str_with_sep(p: path, sep: ~str, itr: ident_interner) -> ~str { str::connect(strs, sep) } -fn path_ident_to_str(p: path, i: ident, itr: ident_interner) -> ~str { +fn path_ident_to_str(p: path, i: ident, itr: @ident_interner) -> ~str { if vec::is_empty(p) { //FIXME /* FIXME (#2543) */ copy *i *itr.get(i) @@ -53,7 +53,7 @@ fn path_ident_to_str(p: path, i: ident, itr: ident_interner) -> ~str { } } -fn path_to_str(p: path, itr: ident_interner) -> ~str { +fn path_to_str(p: path, itr: @ident_interner) -> ~str { path_to_str_with_sep(p, ~"::", itr) } @@ -326,7 +326,7 @@ fn map_stmt(stmt: @stmt, cx: ctx, v: vt) { visit::visit_stmt(stmt, cx, v); } -fn node_id_to_str(map: map, id: node_id, itr: ident_interner) -> ~str { +fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { match map.find(id) { None => { fmt!("unknown node (id=%d)", id) diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index b0df0ea1c8d..98a471bd54c 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -23,7 +23,7 @@ pure fn dummy_sp() -> span { return mk_sp(0u, 0u); } -pure fn path_name_i(idents: ~[ident], intr: token::ident_interner) -> ~str { +pure fn path_name_i(idents: ~[ident], intr: @token::ident_interner) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") str::connect(idents.map(|i| *intr.get(*i)), ~"::") } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index c42811762e4..b208e4f8c6f 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -25,7 +25,7 @@ type tt_frame = @{ type tt_reader = @{ sp_diag: span_handler, - interner: ident_interner, + interner: @ident_interner, mut cur: tt_frame, /* for MBE-style macro transcription */ interpolations: std::map::HashMap, @@ -39,7 +39,7 @@ type tt_reader = @{ /** This can do Macro-By-Example transcription. On the other hand, if * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and * should) be none. */ -fn new_tt_reader(sp_diag: span_handler, itr: ident_interner, +fn new_tt_reader(sp_diag: span_handler, itr: @ident_interner, interp: Option>, src: ~[ast::token_tree]) -> tt_reader { diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 312c78085ac..751b3ce62b9 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -25,7 +25,7 @@ type parse_sess = @{ cm: codemap::codemap, mut next_id: node_id, span_diagnostic: span_handler, - interner: ident_interner, + interner: @ident_interner, // these two must be kept up to date mut chpos: uint, mut byte_pos: uint diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index c9b10c7b754..06fcc1cf958 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -13,7 +13,7 @@ trait reader { fn next_token() -> {tok: token::token, sp: span}; fn fatal(~str) -> !; fn span_diag() -> span_handler; - pure fn interner() -> token::ident_interner; + pure fn interner() -> @token::ident_interner; fn peek() -> {tok: token::token, sp: span}; fn dup() -> reader; } @@ -26,7 +26,7 @@ type string_reader = @{ mut curr: char, mut chpos: uint, filemap: codemap::filemap, - interner: token::ident_interner, + interner: @token::ident_interner, /* cached: */ mut peek_tok: token::token, mut peek_span: span @@ -34,7 +34,7 @@ type string_reader = @{ fn new_string_reader(span_diagnostic: span_handler, filemap: codemap::filemap, - itr: token::ident_interner) -> string_reader { + itr: @token::ident_interner) -> string_reader { let r = new_low_level_string_reader(span_diagnostic, filemap, itr); string_advance_token(r); /* fill in peek_* */ return r; @@ -43,7 +43,7 @@ fn new_string_reader(span_diagnostic: span_handler, /* For comments.rs, which hackily pokes into 'pos' and 'curr' */ fn new_low_level_string_reader(span_diagnostic: span_handler, filemap: codemap::filemap, - itr: token::ident_interner) + itr: @token::ident_interner) -> string_reader { let r = @{span_diagnostic: span_diagnostic, src: filemap.src, mut col: 0u, mut pos: 0u, mut curr: -1 as char, @@ -78,7 +78,7 @@ impl string_reader: reader { self.span_diagnostic.span_fatal(copy self.peek_span, m) } fn span_diag() -> span_handler { self.span_diagnostic } - pure fn interner() -> token::ident_interner { self.interner } + pure fn interner() -> @token::ident_interner { self.interner } fn peek() -> {tok: token::token, sp: span} { {tok: self.peek_tok, sp: self.peek_span} } @@ -100,7 +100,7 @@ impl tt_reader: reader { self.sp_diag.span_fatal(copy self.cur_span, m); } fn span_diag() -> span_handler { self.sp_diag } - pure fn interner() -> token::ident_interner { self.interner } + pure fn interner() -> @token::ident_interner { self.interner } fn peek() -> {tok: token::token, sp: span} { { tok: self.cur_tok, sp: self.cur_span } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bc232f1259e..9d970e23f68 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -237,7 +237,7 @@ struct parser { mut restriction: restriction, mut quote_depth: uint, // not (yet) related to the quasiquoter reader: reader, - interner: interner<@~str>, + interner: @token::ident_interner, keywords: HashMap<~str, ()>, strict_keywords: HashMap<~str, ()>, reserved_keywords: HashMap<~str, ()>, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 0f9041a2fcd..a328ff1bdf6 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -12,9 +12,6 @@ use std::serialization::{Serializer, serialize_bool, deserialize_bool}; -#[auto_serialize] -type str_num = uint; - #[auto_serialize] enum binop { PLUS, @@ -72,17 +69,17 @@ enum token { LIT_INT(i64, ast::int_ty), LIT_UINT(u64, ast::uint_ty), LIT_INT_UNSUFFIXED(i64), - LIT_FLOAT(str_num, ast::float_ty), - LIT_STR(str_num), + LIT_FLOAT(ast::ident, ast::float_ty), + LIT_STR(ast::ident), /* Name components */ - IDENT(str_num, bool), + IDENT(ast::ident, bool), UNDERSCORE, /* For interpolation */ INTERPOLATED(nonterminal), - DOC_COMMENT(str_num), + DOC_COMMENT(ast::ident), EOF, } @@ -95,7 +92,7 @@ enum nonterminal { nt_pat( @ast::pat), nt_expr(@ast::expr), nt_ty( @ast::ty), - nt_ident(str_num, bool), + nt_ident(ast::ident, bool), nt_path(@ast::path), nt_tt( @ast::token_tree), //needs @ed to break a circularity nt_matchers(~[ast::matcher]) @@ -116,7 +113,7 @@ fn binop_to_str(o: binop) -> ~str { } } -fn to_str(in: interner<@~str>, t: token) -> ~str { +fn to_str(in: @ident_interner, t: token) -> ~str { match t { EQ => ~"=", LT => ~"<", @@ -174,7 +171,7 @@ fn to_str(in: interner<@~str>, t: token) -> ~str { } body + ast_util::float_ty_to_str(t) } - LIT_STR(s) => { ~"\"" + str::escape_default( *in.get(s)) + ~"\"" } + LIT_STR(s) => { ~"\"" + str::escape_default(*in.get(s)) + ~"\"" } /* Name components */ IDENT(s, _) => *in.get(s), @@ -281,49 +278,66 @@ pure fn is_bar(t: token) -> bool { mod special_idents { #[legacy_exports]; use ast::ident; - const underscore : ident = 0u; - const anon : ident = 1u; - const dtor : ident = 2u; // 'drop', but that's reserved - const invalid : ident = 3u; // '' - const unary : ident = 4u; - const not_fn : ident = 5u; - const idx_fn : ident = 6u; - const unary_minus_fn : ident = 7u; - const clownshoes_extensions : ident = 8u; + const underscore : ident = ident { repr: 0u }; + const anon : ident = ident { repr: 1u }; + const dtor : ident = ident { repr: 2u }; // 'drop', but that's reserved + const invalid : ident = ident { repr: 3u }; // '' + const unary : ident = ident { repr: 4u }; + const not_fn : ident = ident { repr: 5u }; + const idx_fn : ident = ident { repr: 6u }; + const unary_minus_fn : ident = ident { repr: 7u }; + const clownshoes_extensions : ident = ident { repr: 8u }; - const self_ : ident = 9u; // 'self' + const self_ : ident = ident { repr: 9u }; // 'self' /* for matcher NTs */ - const item : ident = 10u; - const block : ident = 11u; - const stmt : ident = 12u; - const pat : ident = 13u; - const expr : ident = 14u; - const ty : ident = 15u; - const ident : ident = 16u; - const path : ident = 17u; - const tt : ident = 18u; - const matchers : ident = 19u; + const item : ident = ident { repr: 10u }; + const block : ident = ident { repr: 11u }; + const stmt : ident = ident { repr: 12u }; + const pat : ident = ident { repr: 13u }; + const expr : ident = ident { repr: 14u }; + const ty : ident = ident { repr: 15u }; + const ident : ident = ident { repr: 16u }; + const path : ident = ident { repr: 17u }; + const tt : ident = ident { repr: 18u }; + const matchers : ident = ident { repr: 19u }; - const str : ident = 20u; // for the type + const str : ident = ident { repr: 20u }; // for the type /* outside of libsyntax */ - const ty_visitor : ident = 21u; - const arg : ident = 22u; - const descrim : ident = 23u; - const clownshoe_abi : ident = 24u; - const clownshoe_stack_shim : ident = 25u; - const tydesc : ident = 26u; - const literally_dtor : ident = 27u; - const main : ident = 28u; - const opaque : ident = 29u; - const blk : ident = 30u; - const static : ident = 31u; - const intrinsic : ident = 32u; - const clownshoes_foreign_mod: ident = 33; + const ty_visitor : ident = ident { repr: 21u }; + const arg : ident = ident { repr: 22u }; + const descrim : ident = ident { repr: 23u }; + const clownshoe_abi : ident = ident { repr: 24u }; + const clownshoe_stack_shim : ident = ident { repr: 25u }; + const tydesc : ident = ident { repr: 26u }; + const literally_dtor : ident = ident { repr: 27u }; + const main : ident = ident { repr: 28u }; + const opaque : ident = ident { repr: 29u }; + const blk : ident = ident { repr: 30u }; + const static : ident = ident { repr: 31u }; + const intrinsic : ident = ident { repr: 32u }; + const clownshoes_foreign_mod: ident = ident { repr: 33 }; } -type ident_interner = util::interner::interner<@~str>; +struct ident_interner { + priv interner: util::interner::interner<@~str>, +} + +impl ident_interner { + fn intern(val: @~str) -> ast::ident { + ast::ident { repr: self.interner.intern(val) } + } + fn gensym(val: @~str) -> ast::ident { + ast::ident { repr: self.interner.gensym(val) } + } + pure fn get(idx: ast::ident) -> @~str { + self.interner.get(idx.repr) + } + fn len() -> uint { + self.interner.len() + } +} /** Key for thread-local data for sneaking interner information to the * serializer/deserializer. It sounds like a hack because it is one. @@ -335,7 +349,7 @@ macro_rules! interner_key ( (-3 as uint, 0u))) ) -fn mk_ident_interner() -> ident_interner { +fn mk_ident_interner() -> @ident_interner { /* the indices here must correspond to the numbers in special_idents */ let init_vec = ~[@~"_", @~"anon", @~"drop", @~"", @~"unary", @~"!", @~"[]", @~"unary-", @~"__extensions__", @~"self", @@ -346,7 +360,9 @@ fn mk_ident_interner() -> ident_interner { @~"dtor", @~"main", @~"", @~"blk", @~"static", @~"intrinsic", @~"__foreign_mod__"]; - let rv = interner::mk_prefill::<@~str>(init_vec); + let rv = @ident_interner { + interner: interner::mk_prefill::<@~str>(init_vec) + }; /* having multiple interners will just confuse the serializer */ unsafe { @@ -360,8 +376,8 @@ fn mk_ident_interner() -> ident_interner { /* for when we don't care about the contents; doesn't interact with TLD or serialization */ -fn mk_fake_ident_interner() -> ident_interner { - interner::mk::<@~str>() +fn mk_fake_ident_interner() -> @ident_interner { + @ident_interner { interner: interner::mk::<@~str>() } } /** diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3630ba8c5c6..00652346e10 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -25,7 +25,7 @@ fn no_ann() -> pp_ann { type ps = @{s: pp::printer, cm: Option, - intr: token::ident_interner, + intr: @token::ident_interner, comments: Option<~[comments::cmnt]>, literals: Option<~[comments::lit]>, mut cur_cmnt: uint, @@ -43,7 +43,7 @@ fn end(s: ps) { pp::end(s.s); } -fn rust_printer(writer: io::Writer, intr: ident_interner) -> ps { +fn rust_printer(writer: io::Writer, intr: @ident_interner) -> ps { return @{s: pp::mk_printer(writer, default_columns), cm: None::, intr: intr, @@ -63,7 +63,7 @@ const default_columns: uint = 78u; // Requires you to pass an input filename and reader so that // it can scan the input text for comments and literals to // copy forward. -fn print_crate(cm: codemap, intr: ident_interner, +fn print_crate(cm: codemap, intr: @ident_interner, span_diagnostic: diagnostic::span_handler, crate: @ast::crate, filename: ~str, in: io::Reader, out: io::Writer, ann: pp_ann, is_expanded: bool) { @@ -91,40 +91,40 @@ fn print_crate_(s: ps, &&crate: @ast::crate) { eof(s.s); } -fn ty_to_str(ty: @ast::ty, intr: ident_interner) -> ~str { +fn ty_to_str(ty: @ast::ty, intr: @ident_interner) -> ~str { to_str(ty, print_type, intr) } -fn pat_to_str(pat: @ast::pat, intr: ident_interner) -> ~str { +fn pat_to_str(pat: @ast::pat, intr: @ident_interner) -> ~str { to_str(pat, print_pat, intr) } -fn expr_to_str(e: @ast::expr, intr: ident_interner) -> ~str { +fn expr_to_str(e: @ast::expr, intr: @ident_interner) -> ~str { to_str(e, print_expr, intr) } -fn tt_to_str(tt: ast::token_tree, intr: ident_interner) -> ~str { +fn tt_to_str(tt: ast::token_tree, intr: @ident_interner) -> ~str { to_str(tt, print_tt, intr) } -fn stmt_to_str(s: ast::stmt, intr: ident_interner) -> ~str { +fn stmt_to_str(s: ast::stmt, intr: @ident_interner) -> ~str { to_str(s, print_stmt, intr) } -fn item_to_str(i: @ast::item, intr: ident_interner) -> ~str { +fn item_to_str(i: @ast::item, intr: @ident_interner) -> ~str { to_str(i, print_item, intr) } -fn typarams_to_str(tps: ~[ast::ty_param], intr: ident_interner) -> ~str { +fn typarams_to_str(tps: ~[ast::ty_param], intr: @ident_interner) -> ~str { to_str(tps, print_type_params, intr) } -fn path_to_str(&&p: @ast::path, intr: ident_interner) -> ~str { +fn path_to_str(&&p: @ast::path, intr: @ident_interner) -> ~str { to_str(p, |a,b| print_path(a, b, false), intr) } fn fun_to_str(decl: ast::fn_decl, name: ast::ident, - params: ~[ast::ty_param], intr: ident_interner) -> ~str { + params: ~[ast::ty_param], intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); print_fn(s, decl, None, name, params, None, ast::inherited); @@ -147,7 +147,7 @@ fn test_fun_to_str() { assert fun_to_str(decl, "a", ~[]) == "fn a()"; } -fn block_to_str(blk: ast::blk, intr: ident_interner) -> ~str { +fn block_to_str(blk: ast::blk, intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); // containing cbox, will be closed by print-block at } @@ -159,15 +159,15 @@ fn block_to_str(blk: ast::blk, intr: ident_interner) -> ~str { } } -fn meta_item_to_str(mi: @ast::meta_item, intr: ident_interner) -> ~str { +fn meta_item_to_str(mi: @ast::meta_item, intr: @ident_interner) -> ~str { to_str(mi, print_meta_item, intr) } -fn attribute_to_str(attr: ast::attribute, intr: ident_interner) -> ~str { +fn attribute_to_str(attr: ast::attribute, intr: @ident_interner) -> ~str { to_str(attr, print_attribute, intr) } -fn variant_to_str(var: ast::variant, intr: ident_interner) -> ~str { +fn variant_to_str(var: ast::variant, intr: @ident_interner) -> ~str { to_str(var, print_variant, intr) } @@ -2059,7 +2059,7 @@ fn print_string(s: ps, st: ~str) { word(s.s, ~"\""); } -fn to_str(t: T, f: fn@(ps, T), intr: ident_interner) -> ~str { +fn to_str(t: T, f: fn@(ps, T), intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); f(s, t); diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index fb3d749673c..c8f5871333f 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -607,7 +607,7 @@ fn mangle_internal_name_by_path(ccx: @crate_ctxt, path: path) -> ~str { } fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str { - return fmt!("%s_%u", flav, ccx.names(flav)); + return fmt!("%s_%u", flav, ccx.names(flav).repr); } // If the user wants an exe generated we need to invoke diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 335e1004078..c6c0ff2826a 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -243,7 +243,7 @@ impl session { fn ident_of(st: ~str) -> ast::ident { self.parse_sess.interner.intern(@st) } - fn intr() -> syntax::parse::token::ident_interner { + fn intr() -> @syntax::parse::token::ident_interner { self.parse_sess.interner } } diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 0cd0b64a061..0d19fe796e1 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -18,7 +18,7 @@ export read_crates; // libraries necessary for later resolving, typechecking, linking, etc. fn read_crates(diag: span_handler, crate: ast::crate, cstore: cstore::cstore, filesearch: filesearch, - os: loader::os, static: bool, intr: ident_interner) { + os: loader::os, static: bool, intr: @ident_interner) { let e = @{diag: diag, filesearch: filesearch, cstore: cstore, @@ -94,7 +94,7 @@ type env = @{diag: span_handler, static: bool, crate_cache: DVec, mut next_crate_num: ast::crate_num, - intr: ident_interner}; + intr: @ident_interner}; fn visit_view_item(e: env, i: @ast::view_item) { match i.node { diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index 7151702f25e..8a982eaf497 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -58,7 +58,7 @@ type cstore_private = mut used_crate_files: ~[Path], mut used_libraries: ~[~str], mut used_link_args: ~[~str], - intr: ident_interner}; + intr: @ident_interner}; // Map from node_id's of local use statements to crate numbers type use_crate_map = map::HashMap; @@ -68,7 +68,7 @@ pure fn p(cstore: cstore) -> cstore_private { match cstore { private(p) => p } } -fn mk_cstore(intr: ident_interner) -> cstore { +fn mk_cstore(intr: @ident_interner) -> cstore { let meta_cache = map::HashMap(); let crate_map = map::HashMap(); let mod_path_map = HashMap(); diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 928bba5205a..4a72867eb85 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -268,7 +268,7 @@ fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] { return ids; } -fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path { +fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path { let path_doc = ebml::get_doc(item_doc, tag_path); let len_doc = ebml::get_doc(path_doc, tag_path_len); @@ -290,7 +290,7 @@ fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path { return result; } -fn item_name(intr: ident_interner, item: ebml::Doc) -> ast::ident { +fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident { let name = ebml::get_doc(item, tag_paths_data_name); intr.intern(@str::from_bytes(ebml::doc_data(name))) } @@ -365,7 +365,7 @@ fn get_impl_traits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::t] { item_impl_traits(lookup_item(id, cdata.data), tcx, cdata) } -fn get_impl_method(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items); let mut found = None; @@ -378,7 +378,7 @@ fn get_impl_method(intr: ident_interner, cdata: cmd, id: ast::node_id, found.get() } -fn get_class_method(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_class_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items); let mut found = None; @@ -451,7 +451,7 @@ fn path_entry(path_string: ~str, def_like: def_like) -> path_entry { } /// Iterates over all the paths in the given crate. -fn each_path(intr: ident_interner, cdata: cmd, f: fn(path_entry) -> bool) { +fn each_path(intr: @ident_interner, cdata: cmd, f: fn(path_entry) -> bool) { let root = ebml::Doc(cdata.data); let items = ebml::get_doc(root, tag_items); let items_data = ebml::get_doc(items, tag_items_data); @@ -531,7 +531,7 @@ fn each_path(intr: ident_interner, cdata: cmd, f: fn(path_entry) -> bool) { } } -fn get_item_path(intr: ident_interner, cdata: cmd, id: ast::node_id) +fn get_item_path(intr: @ident_interner, cdata: cmd, id: ast::node_id) -> ast_map::path { item_path(intr, lookup_item(id, cdata.data)) } @@ -542,7 +542,7 @@ type decode_inlined_item = fn( path: ast_map::path, par_doc: ebml::Doc) -> Option; -fn maybe_get_item_ast(intr: ident_interner, cdata: cmd, tcx: ty::ctxt, +fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt, id: ast::node_id, decode_inlined_item: decode_inlined_item ) -> csearch::found_ast { @@ -568,7 +568,7 @@ fn maybe_get_item_ast(intr: ident_interner, cdata: cmd, tcx: ty::ctxt, } } -fn get_enum_variants(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::variant_info] { let data = cdata.data; let items = ebml::get_doc(ebml::Doc(data), tag_items); @@ -638,7 +638,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { } } -fn item_impl_methods(intr: ident_interner, cdata: cmd, item: ebml::Doc, +fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, base_tps: uint) -> ~[@method_info] { let mut rslt = ~[]; for ebml::tagged_docs(item, tag_item_impl_method) |doc| { @@ -654,7 +654,7 @@ fn item_impl_methods(intr: ident_interner, cdata: cmd, item: ebml::Doc, rslt } -fn get_impls_for_mod(intr: ident_interner, cdata: cmd, +fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, m_id: ast::node_id, name: Option, get_cdata: fn(ast::crate_num) -> cmd) -> @~[@_impl] { @@ -685,7 +685,7 @@ fn get_impls_for_mod(intr: ident_interner, cdata: cmd, } /* Works for both classes and traits */ -fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_trait_methods(intr: @ident_interner, cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> @~[ty::method] { let data = cdata.data; let item = lookup_item(id, data); @@ -712,7 +712,7 @@ fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id, // If the item in question is a trait, returns its set of methods and // their self types. Otherwise, returns none. This overlaps in an // annoying way with get_trait_methods. -fn get_method_names_if_trait(intr: ident_interner, cdata: cmd, +fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd, node_id: ast::node_id) -> Option<@DVec<(ast::ident, ast::self_ty_)>> { @@ -742,7 +742,7 @@ fn get_item_attrs(cdata: cmd, } // Helper function that gets either fields or methods -fn get_class_members(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_class_members(intr: @ident_interner, cdata: cmd, id: ast::node_id, p: fn(Family) -> bool) -> ~[ty::field_ty] { let data = cdata.data; let item = lookup_item(id, data); @@ -769,7 +769,7 @@ pure fn family_to_visibility(family: Family) -> ast::visibility { } } -fn get_class_fields(intr: ident_interner, cdata: cmd, id: ast::node_id) +fn get_class_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) -> ~[ty::field_ty] { get_class_members(intr, cdata, id, |f| f == PublicField || f == PrivateField || f == InheritedField) @@ -876,14 +876,14 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] { return attrs; } -fn list_meta_items(intr: ident_interner, +fn list_meta_items(intr: @ident_interner, meta_items: ebml::Doc, out: io::Writer) { for get_meta_items(meta_items).each |mi| { out.write_str(fmt!("%s\n", pprust::meta_item_to_str(*mi, intr))); } } -fn list_crate_attributes(intr: ident_interner, md: ebml::Doc, hash: ~str, +fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: ~str, out: io::Writer) { out.write_str(fmt!("=Crate Attributes (%s)=\n", hash)); @@ -901,7 +901,7 @@ fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { type crate_dep = {cnum: ast::crate_num, name: ast::ident, vers: ~str, hash: ~str}; -fn get_crate_deps(intr: ident_interner, data: @~[u8]) -> ~[crate_dep] { +fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] { let mut deps: ~[crate_dep] = ~[]; let cratedoc = ebml::Doc(data); let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps); @@ -919,7 +919,7 @@ fn get_crate_deps(intr: ident_interner, data: @~[u8]) -> ~[crate_dep] { return deps; } -fn list_crate_deps(intr: ident_interner, data: @~[u8], out: io::Writer) { +fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: io::Writer) { out.write_str(~"=External Dependencies=\n"); for get_crate_deps(intr, data).each |dep| { @@ -946,7 +946,7 @@ fn get_crate_vers(data: @~[u8]) -> ~str { }; } -fn iter_crate_items(intr: ident_interner, +fn iter_crate_items(intr: @ident_interner, cdata: cmd, proc: fn(~str, ast::def_id)) { for each_path(intr, cdata) |path_entry| { match path_entry.def_like { @@ -958,7 +958,7 @@ fn iter_crate_items(intr: ident_interner, } } -fn get_crate_module_paths(intr: ident_interner, cdata: cmd) +fn get_crate_module_paths(intr: @ident_interner, cdata: cmd) -> ~[(ast::def_id, ~str)] { fn mod_of_path(p: ~str) -> ~str { str::connect(vec::init(str::split_str(p, ~"::")), ~"::") @@ -985,7 +985,7 @@ fn get_crate_module_paths(intr: ident_interner, cdata: cmd) } } -fn list_crate_metadata(intr: ident_interner, bytes: @~[u8], +fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8], out: io::Writer) { let hash = get_crate_hash(bytes); let md = ebml::Doc(bytes); diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index e11793a36d0..b2c28fafd4c 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -35,7 +35,7 @@ type ctxt = { hash: ~str, os: os, static: bool, - intr: ident_interner + intr: @ident_interner }; fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { @@ -135,7 +135,7 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> ~str { } } -fn note_linkage_attrs(intr: ident_interner, diag: span_handler, +fn note_linkage_attrs(intr: @ident_interner, diag: span_handler, attrs: ~[ast::attribute]) { for attr::find_linkage_metas(attrs).each |mi| { diag.handler().note(fmt!("meta: %s", @@ -226,7 +226,7 @@ fn meta_section_name(os: os) -> ~str { } // A diagnostic function for dumping crate metadata to an output stream -fn list_file_metadata(intr: ident_interner, +fn list_file_metadata(intr: @ident_interner, os: os, path: &Path, out: io::Writer) { match get_metadata_section(os, path) { option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out), diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 07b5d3b4ce8..3e216c4eacc 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -652,14 +652,14 @@ struct PrimitiveTypeTable { } impl PrimitiveTypeTable { - fn intern(intr: ident_interner, string: @~str, + fn intern(intr: @ident_interner, string: @~str, primitive_type: prim_ty) { let atom = intr.intern(string); self.primitive_types.insert(atom, primitive_type); } } -fn PrimitiveTypeTable(intr: ident_interner) -> PrimitiveTypeTable { +fn PrimitiveTypeTable(intr: @ident_interner) -> PrimitiveTypeTable { let table = PrimitiveTypeTable { primitive_types: atom_hashmap() }; @@ -765,7 +765,7 @@ struct Resolver { lang_items: LanguageItems, crate: @crate, - intr: ident_interner, + intr: @ident_interner, graph_root: @NameBindings, diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index a1ca4287f0e..fc74e5e0e4d 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -25,9 +25,9 @@ use syntax::parse::token::ident_interner; use syntax::ast::ident; type namegen = fn@(~str) -> ident; -fn new_namegen(intr: ident_interner) -> namegen { +fn new_namegen(intr: @ident_interner) -> namegen { return fn@(prefix: ~str) -> ident { - return intr.gensym(@fmt!("%s_%u", prefix, intr.gensym(@prefix))) + return intr.gensym(@fmt!("%s_%u", prefix, intr.gensym(@prefix).repr)) }; } @@ -1024,7 +1024,7 @@ fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; let g = - str::as_c_str(fmt!("str%u", cx.names(~"str")), + str::as_c_str(fmt!("str%u", cx.names(~"str").repr), |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)); llvm::LLVMSetInitializer(g, sc); llvm::LLVMSetGlobalConstant(g, True); @@ -1086,7 +1086,8 @@ fn C_bytes_plus_null(bytes: ~[u8]) -> ValueRef unsafe { fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef { let llshape = C_bytes_plus_null(bytes); - let llglobal = str::as_c_str(fmt!("shape%u", ccx.names(~"shape")), |buf| { + let name = fmt!("shape%u", ccx.names(~"shape").repr); + let llglobal = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) }); llvm::LLVMSetInitializer(llglobal, llshape); diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 9944daefea4..26a83951c01 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -90,7 +90,7 @@ type debug_ctxt = { crate_file: ~str }; -fn mk_ctxt(crate: ~str, intr: ident_interner) -> debug_ctxt { +fn mk_ctxt(crate: ~str, intr: @ident_interner) -> debug_ctxt { {llmetadata: map::HashMap(), names: new_namegen(intr), crate_file: crate} diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index b8a13b712e5..448e699fc8d 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -21,7 +21,7 @@ fn to_str(id: ast::ident) -> ~str { return *(*intr.get()).get(id); } -fn interner() -> syntax::parse::token::ident_interner { +fn interner() -> @syntax::parse::token::ident_interner { return *(unsafe{ local_data_get(interner_key!()) }).get(); }