From d2ad028a7c70866df375172a2377bdf966b25d9d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 6 Dec 2012 16:13:54 -0800 Subject: [PATCH] Rename std::ebml::Reader => std::ebml::reader, same for writer Closes #4076 --- src/librustc/metadata/csearch.rs | 4 +- src/librustc/metadata/decoder.rs | 198 ++++++++++++++-------------- src/librustc/metadata/encoder.rs | 82 ++++++------ src/librustc/middle/astencode.rs | 60 ++++----- src/libstd/ebml.rs | 10 +- src/test/run-pass/auto_serialize.rs | 4 +- 6 files changed, 179 insertions(+), 179 deletions(-) diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index cab42d838445f..913c63d0e3234 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -11,7 +11,7 @@ // Searching for information from the cstore use std::ebml; -use Reader = std::ebml::Reader; +use reader = std::ebml::reader; use syntax::ast; use syntax::ast_util; use syntax::ast_map; @@ -192,7 +192,7 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, def: ast::def_id) -> ty::ty_param_bounds_and_ty { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, class_id.crate); - let all_items = Reader::get_doc(Reader::Doc(cdata.data), tag_items); + let all_items = reader::get_doc(reader::Doc(cdata.data), tag_items); debug!("Looking up %?", class_id); let class_doc = expect(tcx.diag, decoder::maybe_find_item(class_id.node, all_items), diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index d1c71b95191be..8859c952471c5 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -14,7 +14,7 @@ use std::ebml; use std::map; use std::map::HashMap; use std::serialization::deserialize; -use Reader = ebml::Reader; +use reader = ebml::reader; use io::WriterUtil; use dvec::DVec; use syntax::{ast, ast_util}; @@ -84,17 +84,17 @@ export translate_def_id; fn lookup_hash(d: ebml::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) -> Option { - let index = Reader::get_doc(d, tag_index); - let table = Reader::get_doc(index, tag_index_table); + let index = reader::get_doc(d, tag_index); + let table = reader::get_doc(index, tag_index_table); let hash_pos = table.start + hash % 256u * 4u; let pos = io::u64_from_be_bytes(*d.data, hash_pos, 4u) as uint; - let tagged_doc = Reader::doc_at(d.data, pos); + let tagged_doc = reader::doc_at(d.data, pos); let belt = tag_index_buckets_bucket_elt; - for Reader::tagged_docs(tagged_doc.doc, belt) |elt| { + for reader::tagged_docs(tagged_doc.doc, belt) |elt| { let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint; if eq_fn(vec::view(*elt.data, elt.start + 4u, elt.end)) { - return Some(Reader::doc_at(d.data, pos).doc); + return Some(reader::doc_at(d.data, pos).doc); } }; None @@ -119,7 +119,7 @@ fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc { // Looks up an item in the given metadata and returns an ebml doc pointing // to the item data. fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { - let items = Reader::get_doc(Reader::Doc(data), tag_items); + let items = reader::get_doc(reader::Doc(data), tag_items); match maybe_find_item(item_id, items) { None => fail(fmt!("lookup_item: id not found: %d", item_id)), Some(d) => d @@ -157,8 +157,8 @@ impl Family : cmp::Eq { } fn item_family(item: ebml::Doc) -> Family { - let fam = Reader::get_doc(item, tag_items_data_item_family); - match Reader::doc_as_u8(fam) as char { + let fam = reader::get_doc(item, tag_items_data_item_family); + match reader::doc_as_u8(fam) as char { 'c' => Const, 'f' => Fn, 'u' => UnsafeFn, @@ -184,20 +184,20 @@ fn item_family(item: ebml::Doc) -> Family { } fn item_method_sort(item: ebml::Doc) -> char { - for Reader::tagged_docs(item, tag_item_trait_method_sort) |doc| { - return str::from_bytes(Reader::doc_data(doc))[0] as char; + for reader::tagged_docs(item, tag_item_trait_method_sort) |doc| { + return str::from_bytes(reader::doc_data(doc))[0] as char; } return 'r'; } fn item_symbol(item: ebml::Doc) -> ~str { - let sym = Reader::get_doc(item, tag_items_data_item_symbol); - return str::from_bytes(Reader::doc_data(sym)); + let sym = reader::get_doc(item, tag_items_data_item_symbol); + return str::from_bytes(reader::doc_data(sym)); } fn item_parent_item(d: ebml::Doc) -> Option { - for Reader::tagged_docs(d, tag_items_data_parent_item) |did| { - return Some(Reader::with_doc_data(did, |d| parse_def_id(d))); + for reader::tagged_docs(d, tag_items_data_parent_item) |did| { + return Some(reader::with_doc_data(did, |d| parse_def_id(d))); } None } @@ -215,13 +215,13 @@ fn item_reqd_and_translated_parent_item(cnum: ast::crate_num, } fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id { - let tagdoc = Reader::get_doc(d, tag_def_id); - return translate_def_id(cdata, Reader::with_doc_data(tagdoc, + let tagdoc = reader::get_doc(d, tag_def_id); + return translate_def_id(cdata, reader::with_doc_data(tagdoc, |d| parse_def_id(d))); } fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) { - for Reader::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| { + for reader::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| { if !f(reexport_doc) { return; } @@ -231,10 +231,10 @@ fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) { fn field_mutability(d: ebml::Doc) -> ast::class_mutability { // Use maybe_get_doc in case it's a method option::map_default( - &Reader::maybe_get_doc(d, tag_class_mut), + &reader::maybe_get_doc(d, tag_class_mut), ast::class_immutable, |d| { - match Reader::doc_as_u8(*d) as char { + match reader::doc_as_u8(*d) as char { 'm' => ast::class_mutable, _ => ast::class_immutable } @@ -242,13 +242,13 @@ fn field_mutability(d: ebml::Doc) -> ast::class_mutability { } fn variant_disr_val(d: ebml::Doc) -> Option { - do option::chain(Reader::maybe_get_doc(d, tag_disr_val)) |val_doc| { - int::parse_bytes(Reader::doc_data(val_doc), 10u) + do option::chain(reader::maybe_get_doc(d, tag_disr_val)) |val_doc| { + int::parse_bytes(reader::doc_data(val_doc), 10u) } } fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::t { - let tp = Reader::get_doc(doc, tag_items_data_item_type); + let tp = reader::get_doc(doc, tag_items_data_item_type); parse_ty_data(tp.data, cdata.cnum, tp.start, tcx, |did| { translate_def_id(cdata, did) }) @@ -264,7 +264,7 @@ fn item_type(item_id: ast::def_id, item: ebml::Doc, fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] { let mut results = ~[]; - for Reader::tagged_docs(item, tag_impl_trait) |ity| { + for reader::tagged_docs(item, tag_impl_trait) |ity| { results.push(doc_type(ity, tcx, cdata)); }; results @@ -273,7 +273,7 @@ fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] { fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> @~[ty::param_bounds] { let mut bounds = ~[]; - for Reader::tagged_docs(item, tag_items_data_item_ty_param_bounds) |p| { + for reader::tagged_docs(item, tag_items_data_item_ty_param_bounds) |p| { let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, |did| { translate_def_id(cdata, did) }); @@ -283,14 +283,14 @@ fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) } fn item_ty_region_param(item: ebml::Doc) -> Option { - Reader::maybe_get_doc(item, tag_region_param).map(|doc| { - deserialize(&Reader::Deserializer(*doc)) + reader::maybe_get_doc(item, tag_region_param).map(|doc| { + deserialize(&reader::Deserializer(*doc)) }) } fn item_ty_param_count(item: ebml::Doc) -> uint { let mut n = 0u; - Reader::tagged_docs(item, tag_items_data_item_ty_param_bounds, + reader::tagged_docs(item, tag_items_data_item_ty_param_bounds, |_p| { n += 1u; true } ); n } @@ -298,26 +298,26 @@ fn item_ty_param_count(item: ebml::Doc) -> uint { fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] { let mut ids: ~[ast::def_id] = ~[]; let v = tag_items_data_item_variant; - for Reader::tagged_docs(item, v) |p| { - let ext = Reader::with_doc_data(p, |d| parse_def_id(d)); + for reader::tagged_docs(item, v) |p| { + let ext = reader::with_doc_data(p, |d| parse_def_id(d)); ids.push({crate: cdata.cnum, node: ext.node}); }; return ids; } fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path { - let path_doc = Reader::get_doc(item_doc, tag_path); + let path_doc = reader::get_doc(item_doc, tag_path); - let len_doc = Reader::get_doc(path_doc, tag_path_len); - let len = Reader::doc_as_u32(len_doc) as uint; + let len_doc = reader::get_doc(path_doc, tag_path_len); + let len = reader::doc_as_u32(len_doc) as uint; let mut result = vec::with_capacity(len); - for Reader::docs(path_doc) |tag, elt_doc| { + for reader::docs(path_doc) |tag, elt_doc| { if tag == tag_path_elt_mod { - let str = Reader::doc_as_str(elt_doc); + let str = reader::doc_as_str(elt_doc); result.push(ast_map::path_mod(intr.intern(@str))); } else if tag == tag_path_elt_name { - let str = Reader::doc_as_str(elt_doc); + let str = reader::doc_as_str(elt_doc); result.push(ast_map::path_name(intr.intern(@str))); } else { // ignore tag_path_len element @@ -328,8 +328,8 @@ fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path { } fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident { - let name = Reader::get_doc(item, tag_paths_data_name); - intr.intern(@str::from_bytes(Reader::doc_data(name))) + let name = reader::get_doc(item, tag_paths_data_name); + intr.intern(@str::from_bytes(reader::doc_data(name))) } fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num) @@ -407,11 +407,11 @@ fn get_impl_traits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::t] { fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { - let items = Reader::get_doc(Reader::Doc(cdata.data), tag_items); + let items = reader::get_doc(reader::Doc(cdata.data), tag_items); let mut found = None; - for Reader::tagged_docs(find_item(id, items), tag_item_impl_method) + for reader::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| { - let m_did = Reader::with_doc_data(mid, |d| parse_def_id(d)); + let m_did = reader::with_doc_data(mid, |d| parse_def_id(d)); if item_name(intr, find_item(m_did.node, items)) == name { found = Some(translate_def_id(cdata, m_did)); } @@ -421,14 +421,14 @@ fn get_impl_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 = Reader::get_doc(Reader::Doc(cdata.data), tag_items); + let items = reader::get_doc(reader::Doc(cdata.data), tag_items); let mut found = None; let cls_items = match maybe_find_item(id, items) { Some(it) => it, None => fail (fmt!("get_class_method: class id not found \ when looking up method %s", *intr.get(name))) }; - for Reader::tagged_docs(cls_items, tag_item_trait_method) |mid| { + for reader::tagged_docs(cls_items, tag_item_trait_method) |mid| { let m_did = item_def_id(mid, cdata); if item_name(intr, mid) == name { found = Some(m_did); @@ -442,16 +442,16 @@ fn get_class_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, } fn class_dtor(cdata: cmd, id: ast::node_id) -> Option { - let items = Reader::get_doc(Reader::Doc(cdata.data), tag_items); + let items = reader::get_doc(reader::Doc(cdata.data), tag_items); let mut found = None; let cls_items = match maybe_find_item(id, items) { Some(it) => it, None => fail (fmt!("class_dtor: class id not found \ when looking up dtor for %d", id)) }; - for Reader::tagged_docs(cls_items, tag_item_dtor) |doc| { - let doc1 = Reader::get_doc(doc, tag_def_id); - let did = Reader::with_doc_data(doc1, |d| parse_def_id(d)); + for reader::tagged_docs(cls_items, tag_item_dtor) |doc| { + let doc1 = reader::get_doc(doc, tag_def_id); + let did = reader::with_doc_data(doc1, |d| parse_def_id(d)); found = Some(translate_def_id(cdata, did)); }; found @@ -495,14 +495,14 @@ fn path_entry(path_string: ~str, def_like: def_like) -> path_entry { fn each_path(intr: @ident_interner, cdata: cmd, get_crate_data: GetCrateDataCb, f: fn(path_entry) -> bool) { - let root = Reader::Doc(cdata.data); - let items = Reader::get_doc(root, tag_items); - let items_data = Reader::get_doc(items, tag_items_data); + let root = reader::Doc(cdata.data); + let items = reader::get_doc(root, tag_items); + let items_data = reader::get_doc(items, tag_items_data); let mut broken = false; // First, go through all the explicit items. - for Reader::tagged_docs(items_data, tag_items_data_item) |item_doc| { + for reader::tagged_docs(items_data, tag_items_data_item) |item_doc| { if !broken { let path = ast_map::path_to_str_with_sep( item_path(intr, item_doc), ~"::", intr); @@ -525,17 +525,17 @@ fn each_path(intr: @ident_interner, cdata: cmd, for each_reexport(item_doc) |reexport_doc| { if !broken { let def_id_doc = - Reader::get_doc(reexport_doc, + reader::get_doc(reexport_doc, tag_items_data_item_reexport_def_id); let def_id = - Reader::with_doc_data(def_id_doc, + reader::with_doc_data(def_id_doc, |d| parse_def_id(d)); let def_id = translate_def_id(cdata, def_id); let reexport_name_doc = - Reader::get_doc(reexport_doc, + reader::get_doc(reexport_doc, tag_items_data_item_reexport_name); - let reexport_name = Reader::doc_as_str(reexport_name_doc); + let reexport_name = reader::doc_as_str(reexport_name_doc); let reexport_path; if path == ~"" { @@ -549,8 +549,8 @@ fn each_path(intr: @ident_interner, cdata: cmd, items } else { let crate_data = get_crate_data(def_id.crate); - let root = Reader::Doc(crate_data.data); - Reader::get_doc(root, tag_items) + let root = reader::Doc(crate_data.data); + reader::get_doc(root, tag_items) }; // Get the item. @@ -624,7 +624,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, tcx: ty::ctxt) -> ~[ty::VariantInfo] { let data = cdata.data; - let items = Reader::get_doc(Reader::Doc(data), tag_items); + let items = reader::get_doc(reader::Doc(data), tag_items); let item = find_item(id, items); let mut infos: ~[ty::VariantInfo] = ~[]; let variant_ids = enum_variant_ids(item, cdata); @@ -676,8 +676,8 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { } } - let self_type_doc = Reader::get_doc(item, tag_item_trait_method_self_ty); - let string = Reader::doc_as_str(self_type_doc); + let self_type_doc = reader::get_doc(item, tag_item_trait_method_self_ty); + let string = reader::doc_as_str(self_type_doc); let self_ty_kind = string[0]; match self_ty_kind as char { @@ -696,8 +696,8 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, base_tps: uint) -> ~[@method_info] { let mut rslt = ~[]; - for Reader::tagged_docs(item, tag_item_impl_method) |doc| { - let m_did = Reader::with_doc_data(doc, |d| parse_def_id(d)); + for reader::tagged_docs(item, tag_item_impl_method) |doc| { + let m_did = reader::with_doc_data(doc, |d| parse_def_id(d)); let mth_item = lookup_item(m_did.node, cdata.data); let self_ty = get_self_ty(mth_item); rslt.push(@{did: translate_def_id(cdata, m_did), @@ -716,8 +716,8 @@ fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, let data = cdata.data; let mod_item = lookup_item(m_id, data); let mut result = ~[]; - for Reader::tagged_docs(mod_item, tag_mod_impl) |doc| { - let did = Reader::with_doc_data(doc, |d| parse_def_id(d)); + for reader::tagged_docs(mod_item, tag_mod_impl) |doc| { + let did = reader::with_doc_data(doc, |d| parse_def_id(d)); let local_did = translate_def_id(cdata, did); debug!("(get impls for mod) getting did %? for '%?'", local_did, name); @@ -744,7 +744,7 @@ fn get_trait_methods(intr: @ident_interner, cdata: cmd, id: ast::node_id, let data = cdata.data; let item = lookup_item(id, data); let mut result = ~[]; - for Reader::tagged_docs(item, tag_item_trait_method) |mth| { + for reader::tagged_docs(item, tag_item_trait_method) |mth| { let bounds = item_ty_param_bounds(mth, tcx, cdata); let name = item_name(intr, mth); let ty = doc_type(mth, tcx, cdata); @@ -770,7 +770,7 @@ fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd, let item = lookup_item(id, data); let mut result = ~[]; - for Reader::tagged_docs(item, tag_item_trait_method) |mth| { + for reader::tagged_docs(item, tag_item_trait_method) |mth| { if item_method_sort(mth) != 'p' { loop; } let did = item_def_id(mth, cdata); @@ -806,7 +806,7 @@ fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd, fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::t] { let results = dvec::DVec(); let item_doc = lookup_item(id, cdata.data); - for Reader::tagged_docs(item_doc, tag_impl_trait) |trait_doc| { + for reader::tagged_docs(item_doc, tag_impl_trait) |trait_doc| { results.push(doc_type(trait_doc, tcx, cdata)); } return dvec::unwrap(move results); @@ -825,7 +825,7 @@ fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd, } let resulting_methods = @DVec(); - for Reader::tagged_docs(item, tag_item_trait_method) |method| { + for reader::tagged_docs(item, tag_item_trait_method) |method| { resulting_methods.push( (item_name(intr, method), get_self_ty(method))); } @@ -840,8 +840,8 @@ fn get_type_name_if_impl(intr: @ident_interner, return None; } - for Reader::tagged_docs(item, tag_item_impl_type_basename) |doc| { - return Some(intr.intern(@str::from_bytes(Reader::doc_data(doc)))); + for reader::tagged_docs(item, tag_item_impl_type_basename) |doc| { + return Some(intr.intern(@str::from_bytes(reader::doc_data(doc)))); } return None; @@ -857,13 +857,13 @@ fn get_static_methods_if_impl(intr: @ident_interner, } // If this impl has a trait ref, don't consider it. - for Reader::tagged_docs(item, tag_impl_trait) |_doc| { + for reader::tagged_docs(item, tag_impl_trait) |_doc| { return None; } let impl_method_ids = DVec(); - for Reader::tagged_docs(item, tag_item_impl_method) |impl_method_doc| { - impl_method_ids.push(parse_def_id(Reader::doc_data(impl_method_doc))); + for reader::tagged_docs(item, tag_item_impl_method) |impl_method_doc| { + impl_method_ids.push(parse_def_id(reader::doc_data(impl_method_doc))); } let static_impl_methods = DVec(); @@ -898,8 +898,8 @@ fn get_item_attrs(cdata: cmd, f: fn(~[@ast::meta_item])) { let item = lookup_item(node_id, cdata.data); - for Reader::tagged_docs(item, tag_attributes) |attributes| { - for Reader::tagged_docs(attributes, tag_attribute) |attribute| { + for reader::tagged_docs(item, tag_attributes) |attributes| { + for reader::tagged_docs(attributes, tag_attribute) |attribute| { f(get_meta_items(attribute)); } } @@ -911,7 +911,7 @@ fn get_class_members(intr: @ident_interner, cdata: cmd, id: ast::node_id, let data = cdata.data; let item = lookup_item(id, data); let mut result = ~[]; - for Reader::tagged_docs(item, tag_item_field) |an_item| { + for reader::tagged_docs(item, tag_item_field) |an_item| { let f = item_family(an_item); if p(f) { let name = item_name(intr, an_item); @@ -952,7 +952,7 @@ fn family_names_type(fam: Family) -> bool { } fn read_path(d: ebml::Doc) -> {path: ~str, pos: uint} { - let desc = Reader::doc_data(d); + let desc = reader::doc_data(d); let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint; let pathbytes = vec::slice::(desc, 4u, vec::len::(desc)); let path = str::from_bytes(pathbytes); @@ -995,23 +995,23 @@ fn item_family_to_str(fam: Family) -> ~str { fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] { let mut items: ~[@ast::meta_item] = ~[]; - for Reader::tagged_docs(md, tag_meta_item_word) |meta_item_doc| { - let nd = Reader::get_doc(meta_item_doc, tag_meta_item_name); - let n = str::from_bytes(Reader::doc_data(nd)); + for reader::tagged_docs(md, tag_meta_item_word) |meta_item_doc| { + let nd = reader::get_doc(meta_item_doc, tag_meta_item_name); + let n = str::from_bytes(reader::doc_data(nd)); items.push(attr::mk_word_item(n)); }; - for Reader::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| { - let nd = Reader::get_doc(meta_item_doc, tag_meta_item_name); - let vd = Reader::get_doc(meta_item_doc, tag_meta_item_value); - let n = str::from_bytes(Reader::doc_data(nd)); - let v = str::from_bytes(Reader::doc_data(vd)); + for reader::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| { + let nd = reader::get_doc(meta_item_doc, tag_meta_item_name); + let vd = reader::get_doc(meta_item_doc, tag_meta_item_value); + let n = str::from_bytes(reader::doc_data(nd)); + let v = str::from_bytes(reader::doc_data(vd)); // FIXME (#623): Should be able to decode meta_name_value variants, // but currently the encoder just drops them items.push(attr::mk_name_value_item_str(n, v)); }; - for Reader::tagged_docs(md, tag_meta_item_list) |meta_item_doc| { - let nd = Reader::get_doc(meta_item_doc, tag_meta_item_name); - let n = str::from_bytes(Reader::doc_data(nd)); + for reader::tagged_docs(md, tag_meta_item_list) |meta_item_doc| { + let nd = reader::get_doc(meta_item_doc, tag_meta_item_name); + let n = str::from_bytes(reader::doc_data(nd)); let subitems = get_meta_items(meta_item_doc); items.push(attr::mk_list_item(n, subitems)); }; @@ -1020,9 +1020,9 @@ fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] { fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; - match Reader::maybe_get_doc(md, tag_attributes) { + match reader::maybe_get_doc(md, tag_attributes) { option::Some(attrs_d) => { - for Reader::tagged_docs(attrs_d, tag_attribute) |attr_doc| { + for reader::tagged_docs(attrs_d, tag_attribute) |attr_doc| { let meta_items = get_meta_items(attr_doc); // Currently it's only possible to have a single meta item on // an attribute @@ -1058,7 +1058,7 @@ fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: ~str, } fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { - return get_attributes(Reader::Doc(data)); + return get_attributes(reader::Doc(data)); } type crate_dep = {cnum: ast::crate_num, name: ast::ident, @@ -1066,13 +1066,13 @@ type crate_dep = {cnum: ast::crate_num, name: ast::ident, fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] { let mut deps: ~[crate_dep] = ~[]; - let cratedoc = Reader::Doc(data); - let depsdoc = Reader::get_doc(cratedoc, tag_crate_deps); + let cratedoc = reader::Doc(data); + let depsdoc = reader::get_doc(cratedoc, tag_crate_deps); let mut crate_num = 1; fn docstr(doc: ebml::Doc, tag_: uint) -> ~str { - str::from_bytes(Reader::doc_data(Reader::get_doc(doc, tag_))) + str::from_bytes(reader::doc_data(reader::get_doc(doc, tag_))) } - for Reader::tagged_docs(depsdoc, tag_crate_dep) |depdoc| { + for reader::tagged_docs(depsdoc, tag_crate_dep) |depdoc| { deps.push({cnum: crate_num, name: intr.intern(@docstr(depdoc, tag_crate_dep_name)), vers: docstr(depdoc, tag_crate_dep_vers), @@ -1095,9 +1095,9 @@ fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: io::Writer) { } fn get_crate_hash(data: @~[u8]) -> ~str { - let cratedoc = Reader::Doc(data); - let hashdoc = Reader::get_doc(cratedoc, tag_crate_hash); - return str::from_bytes(Reader::doc_data(hashdoc)); + let cratedoc = reader::Doc(data); + let hashdoc = reader::get_doc(cratedoc, tag_crate_hash); + return str::from_bytes(reader::doc_data(hashdoc)); } fn get_crate_vers(data: @~[u8]) -> ~str { @@ -1153,7 +1153,7 @@ fn get_crate_module_paths(intr: @ident_interner, cdata: cmd, fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8], out: io::Writer) { let hash = get_crate_hash(bytes); - let md = Reader::Doc(bytes); + let md = reader::Doc(bytes); list_crate_attributes(intr, md, hash, out); list_crate_deps(intr, bytes, out); } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 5d3bd0a8357d1..acfbcc947d6a8 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -15,7 +15,7 @@ use util::ppaux::ty_to_str; use std::{ebml, map}; use std::map::HashMap; use io::WriterUtil; -use Writer = ebml::Writer; +use writer = ebml::writer; use syntax::ast::*; use syntax::print::pprust; use syntax::{ast_util, visit}; @@ -50,7 +50,7 @@ export encode_def_id; type abbrev_map = map::HashMap; type encode_inlined_item = fn@(ecx: @encode_ctxt, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, path: ast_map::path, ii: ast::inlined_item); @@ -96,21 +96,21 @@ fn reachable(ecx: @encode_ctxt, id: node_id) -> bool { ecx.reachable.contains_key(id) } -fn encode_name(ecx: @encode_ctxt, ebml_w: Writer::Serializer, name: ident) { +fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Serializer, name: ident) { ebml_w.wr_tagged_str(tag_paths_data_name, ecx.tcx.sess.str_of(name)); } -fn encode_impl_type_basename(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_impl_type_basename(ecx: @encode_ctxt, ebml_w: writer::Serializer, name: ident) { ebml_w.wr_tagged_str(tag_item_impl_type_basename, ecx.tcx.sess.str_of(name)); } -fn encode_def_id(ebml_w: Writer::Serializer, id: def_id) { +fn encode_def_id(ebml_w: writer::Serializer, id: def_id) { ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); } -fn encode_region_param(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_region_param(ecx: @encode_ctxt, ebml_w: writer::Serializer, it: @ast::item) { let opt_rp = ecx.tcx.region_paramd_items.find(it.id); for opt_rp.each |rp| { @@ -120,7 +120,7 @@ fn encode_region_param(ecx: @encode_ctxt, ebml_w: Writer::Serializer, } } -fn encode_mutability(ebml_w: Writer::Serializer, mt: class_mutability) { +fn encode_mutability(ebml_w: writer::Serializer, mt: class_mutability) { do ebml_w.wr_tag(tag_class_mut) { let val = match mt { class_immutable => 'a', @@ -132,7 +132,7 @@ fn encode_mutability(ebml_w: Writer::Serializer, mt: class_mutability) { type entry = {val: T, pos: uint}; -fn add_to_index(ecx: @encode_ctxt, ebml_w: Writer::Serializer, path: &[ident], +fn add_to_index(ecx: @encode_ctxt, ebml_w: writer::Serializer, path: &[ident], index: &mut ~[entry<~str>], name: ident) { let mut full_path = ~[]; full_path.push_all(path); @@ -143,7 +143,7 @@ fn add_to_index(ecx: @encode_ctxt, ebml_w: Writer::Serializer, path: &[ident], pos: ebml_w.writer.tell()}); } -fn encode_trait_ref(ebml_w: Writer::Serializer, ecx: @encode_ctxt, +fn encode_trait_ref(ebml_w: writer::Serializer, ecx: @encode_ctxt, t: @trait_ref) { ebml_w.start_tag(tag_impl_trait); encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, t.ref_id)); @@ -152,7 +152,7 @@ fn encode_trait_ref(ebml_w: Writer::Serializer, ecx: @encode_ctxt, // Item info table encoding -fn encode_family(ebml_w: Writer::Serializer, c: char) { +fn encode_family(ebml_w: writer::Serializer, c: char) { ebml_w.start_tag(tag_items_data_item_family); ebml_w.writer.write(&[c as u8]); ebml_w.end_tag(); @@ -160,7 +160,7 @@ fn encode_family(ebml_w: Writer::Serializer, c: char) { fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) } -fn encode_ty_type_param_bounds(ebml_w: Writer::Serializer, ecx: @encode_ctxt, +fn encode_ty_type_param_bounds(ebml_w: writer::Serializer, ecx: @encode_ctxt, params: @~[ty::param_bounds]) { let ty_str_ctxt = @{diag: ecx.diag, ds: def_to_str, @@ -174,7 +174,7 @@ fn encode_ty_type_param_bounds(ebml_w: Writer::Serializer, ecx: @encode_ctxt, } } -fn encode_type_param_bounds(ebml_w: Writer::Serializer, ecx: @encode_ctxt, +fn encode_type_param_bounds(ebml_w: writer::Serializer, ecx: @encode_ctxt, params: ~[ty_param]) { let ty_param_bounds = @params.map(|param| ecx.tcx.ty_param_bounds.get(param.id)); @@ -182,13 +182,13 @@ fn encode_type_param_bounds(ebml_w: Writer::Serializer, ecx: @encode_ctxt, } -fn encode_variant_id(ebml_w: Writer::Serializer, vid: def_id) { +fn encode_variant_id(ebml_w: writer::Serializer, vid: def_id) { ebml_w.start_tag(tag_items_data_item_variant); ebml_w.writer.write(str::to_bytes(def_to_str(vid))); ebml_w.end_tag(); } -fn write_type(ecx: @encode_ctxt, ebml_w: Writer::Serializer, typ: ty::t) { +fn write_type(ecx: @encode_ctxt, ebml_w: writer::Serializer, typ: ty::t) { let ty_str_ctxt = @{diag: ecx.diag, ds: def_to_str, @@ -198,7 +198,7 @@ fn write_type(ecx: @encode_ctxt, ebml_w: Writer::Serializer, typ: ty::t) { tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); } -fn write_vstore(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn write_vstore(ecx: @encode_ctxt, ebml_w: writer::Serializer, vstore: ty::vstore) { let ty_str_ctxt = @{diag: ecx.diag, @@ -209,13 +209,13 @@ fn write_vstore(ecx: @encode_ctxt, ebml_w: Writer::Serializer, tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); } -fn encode_type(ecx: @encode_ctxt, ebml_w: Writer::Serializer, typ: ty::t) { +fn encode_type(ecx: @encode_ctxt, ebml_w: writer::Serializer, typ: ty::t) { ebml_w.start_tag(tag_items_data_item_type); write_type(ecx, ebml_w, typ); ebml_w.end_tag(); } -fn encode_symbol(ecx: @encode_ctxt, ebml_w: Writer::Serializer, id: node_id) { +fn encode_symbol(ecx: @encode_ctxt, ebml_w: writer::Serializer, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); let sym = match ecx.item_symbols.find(id) { Some(ref x) => (*x), @@ -228,27 +228,27 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: Writer::Serializer, id: node_id) { ebml_w.end_tag(); } -fn encode_discriminant(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_discriminant(ecx: @encode_ctxt, ebml_w: writer::Serializer, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(id))); ebml_w.end_tag(); } -fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: writer::Serializer, disr_val: int) { ebml_w.start_tag(tag_disr_val); ebml_w.writer.write(str::to_bytes(int::to_str(disr_val,10u))); ebml_w.end_tag(); } -fn encode_parent_item(ebml_w: Writer::Serializer, id: def_id) { +fn encode_parent_item(ebml_w: writer::Serializer, id: def_id) { ebml_w.start_tag(tag_items_data_parent_item); ebml_w.writer.write(str::to_bytes(def_to_str(id))); ebml_w.end_tag(); } -fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: writer::Serializer, id: node_id, variants: ~[variant], path: ast_map::path, index: @mut ~[entry], ty_params: ~[ty_param]) { @@ -285,9 +285,9 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: Writer::Serializer, } } -fn encode_path(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_path(ecx: @encode_ctxt, ebml_w: writer::Serializer, path: ast_map::path, name: ast_map::path_elt) { - fn encode_path_elt(ecx: @encode_ctxt, ebml_w: Writer::Serializer, + fn encode_path_elt(ecx: @encode_ctxt, ebml_w: writer::Serializer, elt: ast_map::path_elt) { let (tag, name) = match elt { ast_map::path_mod(name) => (tag_path_elt_mod, name), @@ -306,7 +306,7 @@ fn encode_path(ecx: @encode_ctxt, ebml_w: Writer::Serializer, } } -fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Serializer, md: _mod, id: node_id, path: ast_map::path, name: ident) { ebml_w.start_tag(tag_items_data_item); @@ -365,7 +365,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: Writer::Serializer, ebml_w.end_tag(); } -fn encode_visibility(ebml_w: Writer::Serializer, visibility: visibility) { +fn encode_visibility(ebml_w: writer::Serializer, visibility: visibility) { encode_family(ebml_w, match visibility { public => 'g', private => 'j', @@ -373,7 +373,7 @@ fn encode_visibility(ebml_w: Writer::Serializer, visibility: visibility) { }); } -fn encode_self_type(ebml_w: Writer::Serializer, self_type: ast::self_ty_) { +fn encode_self_type(ebml_w: writer::Serializer, self_type: ast::self_ty_) { ebml_w.start_tag(tag_item_trait_method_self_ty); // Encode the base self type. @@ -405,14 +405,14 @@ fn encode_self_type(ebml_w: Writer::Serializer, self_type: ast::self_ty_) { ebml_w.end_tag(); } -fn encode_method_sort(ebml_w: Writer::Serializer, sort: char) { +fn encode_method_sort(ebml_w: writer::Serializer, sort: char) { ebml_w.start_tag(tag_item_trait_method_sort); ebml_w.writer.write(&[ sort as u8 ]); ebml_w.end_tag(); } /* Returns an index of items in this class */ -fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: writer::Serializer, id: node_id, path: ast_map::path, class_tps: ~[ty_param], fields: ~[@struct_field], @@ -468,7 +468,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: Writer::Serializer, } // This is for encoding info for ctors and dtors -fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: writer::Serializer, id: node_id, ident: ident, path: ast_map::path, item: Option, tps: ~[ty_param]) { ebml_w.start_tag(tag_items_data_item); @@ -493,7 +493,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: Writer::Serializer, ebml_w.end_tag(); } -fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: writer::Serializer, impl_path: ast_map::path, should_inline: bool, parent_id: node_id, m: @method, all_tps: ~[ty_param]) { @@ -548,7 +548,7 @@ fn should_inline(attrs: ~[attribute]) -> bool { } -fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Serializer, item: @item, index: @mut ~[entry], path: ast_map::path) { @@ -561,7 +561,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer, }; if !must_write && !reachable(ecx, item.id) { return; } - fn add_to_index_(item: @item, ebml_w: Writer::Serializer, + fn add_to_index_(item: @item, ebml_w: writer::Serializer, index: @mut ~[entry]) { index.push({val: item.id, pos: ebml_w.writer.tell()}); } @@ -851,7 +851,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer, } } -fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: writer::Serializer, nitem: @foreign_item, index: @mut ~[entry], path: ast_map::path, abi: foreign_abi) { @@ -884,7 +884,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer, ebml_w.end_tag(); } -fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Serializer, crate: @crate) -> ~[entry] { let index = @mut ~[]; ebml_w.start_tag(tag_items_data); @@ -939,7 +939,7 @@ fn create_index(index: ~[entry]) -> return buckets_frozen; } -fn encode_index(ebml_w: Writer::Serializer, buckets: ~[@~[entry]], +fn encode_index(ebml_w: writer::Serializer, buckets: ~[@~[entry]], write_fn: fn(io::Writer, T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); @@ -974,7 +974,7 @@ fn write_int(writer: io::Writer, &&n: int) { writer.write_be_u32(n as u32); } -fn encode_meta_item(ebml_w: Writer::Serializer, mi: meta_item) { +fn encode_meta_item(ebml_w: writer::Serializer, mi: meta_item) { match mi.node { meta_word(ref name) => { ebml_w.start_tag(tag_meta_item_word); @@ -1011,7 +1011,7 @@ fn encode_meta_item(ebml_w: Writer::Serializer, mi: meta_item) { } } -fn encode_attributes(ebml_w: Writer::Serializer, attrs: ~[attribute]) { +fn encode_attributes(ebml_w: writer::Serializer, attrs: ~[attribute]) { ebml_w.start_tag(tag_attributes); for attrs.each |attr| { ebml_w.start_tag(tag_attribute); @@ -1072,7 +1072,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { return attrs; } -fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: writer::Serializer, cstore: cstore::CStore) { fn get_ordered_deps(ecx: @encode_ctxt, cstore: cstore::CStore) @@ -1118,7 +1118,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: Writer::Serializer, ebml_w.end_tag(); } -fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: Writer::Serializer, +fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: writer::Serializer, dep: decoder::crate_dep) { ebml_w.start_tag(tag_crate_dep); ebml_w.start_tag(tag_crate_dep_name); @@ -1133,7 +1133,7 @@ fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: Writer::Serializer, ebml_w.end_tag(); } -fn encode_hash(ebml_w: Writer::Serializer, hash: ~str) { +fn encode_hash(ebml_w: writer::Serializer, hash: ~str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::to_bytes(hash)); ebml_w.end_tag(); @@ -1171,7 +1171,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] { type_abbrevs: ty::new_ty_hash() }); - let ebml_w = Writer::Serializer(wr as io::Writer); + let ebml_w = writer::Serializer(wr as io::Writer); encode_hash(ebml_w, ecx.link_meta.extras_hash); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index e3b451219fc08..8c0bc8a298351 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -18,10 +18,10 @@ use syntax::ast_map; use syntax::ast_util; use syntax::codemap::span; use std::ebml; -use Writer = std::ebml::Writer; -use Reader = std::ebml::Reader; -use Reader::get_doc; -use Writer::Serializer; +use writer = std::ebml::writer; +use reader = std::ebml::reader; +use reader::get_doc; +use writer::Serializer; use std::map::HashMap; use std::serialization; use std::serialization::{Serializable, @@ -90,7 +90,7 @@ trait tr_intern { // Top-level methods. fn encode_inlined_item(ecx: @e::encode_ctxt, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, path: ast_map::path, ii: ast::inlined_item, maps: maps) { @@ -123,7 +123,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, Some(ast_doc) => { debug!("> Decoding inlined fn: %s::?", ast_map::path_to_str(path, tcx.sess.parse_sess.interner)); - let ast_dsr = &Reader::Deserializer(ast_doc); + let ast_dsr = &reader::Deserializer(ast_doc); let from_id_range = deserialize(ast_dsr); let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); let xcx = extended_decode_ctxt_(@{dcx: dcx, @@ -237,7 +237,7 @@ impl D: def_id_deserializer_helpers { // We also have to adjust the spans: for now we just insert a dummy span, // but eventually we should add entries to the local codemap as required. -fn encode_ast(ebml_w: Writer::Serializer, item: ast::inlined_item) { +fn encode_ast(ebml_w: writer::Serializer, item: ast::inlined_item) { do ebml_w.wr_tag(c::tag_tree as uint) { item.serialize(&ebml_w) } @@ -293,7 +293,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { let chi_doc = par_doc[c::tag_tree as uint]; - let d = &Reader::Deserializer(chi_doc); + let d = &reader::Deserializer(chi_doc); deserialize(d) } @@ -333,12 +333,12 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item) // ______________________________________________________________________ // Encoding and decoding of ast::def -fn encode_def(ebml_w: Writer::Serializer, def: ast::def) { +fn encode_def(ebml_w: writer::Serializer, def: ast::def) { def.serialize(&ebml_w) } fn decode_def(xcx: extended_decode_ctxt, doc: ebml::Doc) -> ast::def { - let dsr = &Reader::Deserializer(doc); + let dsr = &reader::Deserializer(doc); let def: ast::def = deserialize(dsr); def.tr(xcx) } @@ -426,7 +426,7 @@ impl ty::bound_region: tr { // ______________________________________________________________________ // Encoding and decoding of freevar information -fn encode_freevar_entry(ebml_w: Writer::Serializer, fv: @freevar_entry) { +fn encode_freevar_entry(ebml_w: writer::Serializer, fv: @freevar_entry) { (*fv).serialize(&ebml_w) } @@ -434,7 +434,7 @@ trait ebml_deserializer_helper { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry; } -impl Reader::Deserializer: ebml_deserializer_helper { +impl reader::Deserializer: ebml_deserializer_helper { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry { let fv: freevar_entry = deserialize(&self); fv.tr(xcx) @@ -455,7 +455,7 @@ trait read_method_map_entry_helper { } fn serialize_method_map_entry(ecx: @e::encode_ctxt, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, mme: method_map_entry) { do ebml_w.emit_rec { do ebml_w.emit_field(~"self_arg", 0u) { @@ -470,7 +470,7 @@ fn serialize_method_map_entry(ecx: @e::encode_ctxt, } } -impl Reader::Deserializer: read_method_map_entry_helper { +impl reader::Deserializer: read_method_map_entry_helper { fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry { do self.read_rec { {self_arg: @@ -514,7 +514,7 @@ impl method_origin: tr { // Encoding and decoding vtable_res fn encode_vtable_res(ecx: @e::encode_ctxt, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, dr: typeck::vtable_res) { // can't autogenerate this code because automatic serialization of // ty::t doesn't work, and there is no way (atm) to have @@ -526,7 +526,7 @@ fn encode_vtable_res(ecx: @e::encode_ctxt, } fn encode_vtable_origin(ecx: @e::encode_ctxt, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, vtable_origin: typeck::vtable_origin) { do ebml_w.emit_enum(~"vtable_origin") { match vtable_origin { @@ -573,7 +573,7 @@ trait vtable_deserialization_helpers { fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin; } -impl Reader::Deserializer: vtable_deserialization_helpers { +impl reader::Deserializer: vtable_deserialization_helpers { fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res { @self.read_to_vec(|| self.read_vtable_origin(xcx) ) } @@ -650,7 +650,7 @@ trait ebml_writer_helpers { fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty); } -impl Writer::Serializer: ebml_writer_helpers { +impl writer::Serializer: ebml_writer_helpers { fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) { do self.emit_opaque { e::write_type(ecx, self, ty) @@ -703,7 +703,7 @@ trait write_tag_and_id { fn id(id: ast::node_id); } -impl Writer::Serializer: write_tag_and_id { +impl writer::Serializer: write_tag_and_id { fn tag(tag_id: c::astencode_tag, f: fn()) { do self.wr_tag(tag_id as uint) { f() } } @@ -715,7 +715,7 @@ impl Writer::Serializer: write_tag_and_id { fn encode_side_tables_for_ii(ecx: @e::encode_ctxt, maps: maps, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, ii: ast::inlined_item) { do ebml_w.wr_tag(c::tag_table as uint) { ast_util::visit_ids_for_inlined_item( @@ -731,7 +731,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt, fn encode_side_tables_for_id(ecx: @e::encode_ctxt, maps: maps, - ebml_w: Writer::Serializer, + ebml_w: writer::Serializer, id: ast::node_id) { let tcx = ecx.tcx; @@ -873,9 +873,9 @@ trait doc_decoder_helpers { } impl ebml::Doc: doc_decoder_helpers { - fn as_int() -> int { Reader::doc_as_u64(self) as int } + fn as_int() -> int { reader::doc_as_u64(self) as int } fn opt_child(tag: c::astencode_tag) -> Option { - Reader::maybe_get_doc(self, tag as uint) + reader::maybe_get_doc(self, tag as uint) } } @@ -888,7 +888,7 @@ trait ebml_deserializer_decoder_helpers { -> ty::ty_param_bounds_and_ty; } -impl Reader::Deserializer: ebml_deserializer_decoder_helpers { +impl reader::Deserializer: ebml_deserializer_decoder_helpers { fn read_arg(xcx: extended_decode_ctxt) -> ty::arg { do self.read_opaque |doc| { @@ -946,7 +946,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt, ast_doc: ebml::Doc) { let dcx = xcx.dcx; let tbl_doc = ast_doc[c::tag_table as uint]; - for Reader::docs(tbl_doc) |tag, entry_doc| { + for reader::docs(tbl_doc) |tag, entry_doc| { let id0 = entry_doc[c::tag_table_id as uint].as_int(); let id = xcx.tr_id(id0); @@ -960,7 +960,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt, dcx.tcx.legacy_boxed_traits.insert(id, ()); } else { let val_doc = entry_doc[c::tag_table_val as uint]; - let val_dsr = &Reader::Deserializer(val_doc); + let val_dsr = &reader::Deserializer(val_doc); if tag == (c::tag_table_def as uint) { let def = decode_def(xcx, val_doc); dcx.tcx.def_map.insert(id, def); @@ -1016,7 +1016,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt, // Testing of astencode_gen #[cfg(test)] -fn encode_item_ast(ebml_w: Writer::Serializer, item: @ast::item) { +fn encode_item_ast(ebml_w: writer::Serializer, item: @ast::item) { do ebml_w.wr_tag(c::tag_tree as uint) { (*item).serialize(&ebml_w) } @@ -1025,7 +1025,7 @@ fn encode_item_ast(ebml_w: Writer::Serializer, item: @ast::item) { #[cfg(test)] fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item { let chi_doc = par_doc[c::tag_tree as uint]; - let d = &Reader::Deserializer(chi_doc); + let d = &reader::Deserializer(chi_doc); @deserialize(d) } @@ -1052,10 +1052,10 @@ fn mk_ctxt() -> fake_ext_ctxt { #[cfg(test)] fn roundtrip(in_item: @ast::item) { let bytes = do io::with_bytes_writer |wr| { - let ebml_w = Writer::Serializer(wr); + let ebml_w = writer::Serializer(wr); encode_item_ast(ebml_w, in_item); }; - let ebml_doc = Reader::Doc(@bytes); + let ebml_doc = reader::Doc(@bytes); let out_item = decode_item_ast(ebml_doc); let exp_str = do io::with_str_writer |w| { diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 3b65f91375523..164021783d198 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -53,7 +53,7 @@ enum EbmlSerializerTag { } // -------------------------------------- -pub mod Reader { +pub mod reader { // ebml reading @@ -395,7 +395,7 @@ pub mod Reader { } -pub mod Writer { +pub mod writer { // ebml writing struct Serializer { @@ -663,11 +663,11 @@ mod tests { fn test_v(v: Option) { debug!("v == %?", v); let bytes = do io::with_bytes_writer |wr| { - let ebml_w = Writer::Serializer(wr); + let ebml_w = writer::Serializer(wr); v.serialize(&ebml_w) }; - let ebml_doc = Reader::Doc(@bytes); - let deser = Reader::Deserializer(ebml_doc); + let ebml_doc = reader::Doc(@bytes); + let deser = reader::Deserializer(ebml_doc); let v1 = serialization::deserialize(&deser); debug!("v1 == %?", v1); assert v == v1; diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs index 1c81bb05bcc83..68312b0423f96 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto_serialize.rs @@ -7,8 +7,8 @@ extern mod std; use cmp::Eq; use std::ebml; -use EBReader = std::ebml::Reader; -use EBWriter = std::ebml::Writer; +use EBReader = std::ebml::reader; +use EBWriter = std::ebml::writer; use io::Writer; use std::serialization::{Serializable, Deserializable, deserialize}; use std::prettyprint;