diff --git a/src/librustc/README.txt b/src/librustc/README.txt index e0a4d7cbda1d9..e61714c0dd277 100644 --- a/src/librustc/README.txt +++ b/src/librustc/README.txt @@ -23,7 +23,7 @@ front/ - front-end: attributes, conditional compilation middle/ - middle-end: name resolution, typechecking, LLVM code generation back/ - back-end: linking and ABI -metadata/ - serializer and deserializer for data required by +metadata/ - encoder and decoder for data required by separate compilation driver/ - command-line processing, main() entrypoint util/ - ubiquitous types and helper functions diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 110b151a651ef..ca5ea3c3372c7 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -13,7 +13,7 @@ use std::ebml; use std::map; use std::map::HashMap; -use std::serialization::deserialize; +use std::serialize::decode; use reader = ebml::reader; use io::WriterUtil; use dvec::DVec; @@ -283,7 +283,7 @@ 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)) + decode(&reader::Decoder(*doc)) }) } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e2a4b8880c91a..23edc45a94b17 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -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::Encoder, path: ast_map::path, ii: ast::inlined_item); @@ -96,31 +96,31 @@ 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, it: @ast::item) { let opt_rp = ecx.tcx.region_paramd_items.find(it.id); for opt_rp.each |rp| { do ebml_w.wr_tag(tag_region_param) { - (*rp).serialize(&ebml_w); + (*rp).encode(&ebml_w); } } } -fn encode_mutability(ebml_w: writer::Serializer, mt: struct_mutability) { +fn encode_mutability(ebml_w: writer::Encoder, mt: struct_mutability) { do ebml_w.wr_tag(tag_struct_mut) { let val = match mt { struct_immutable => 'a', @@ -132,7 +132,7 @@ fn encode_mutability(ebml_w: writer::Serializer, mt: struct_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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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::Encoder, 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_struct(ecx: @encode_ctxt, ebml_w: writer::Serializer, +fn encode_info_for_struct(ecx: @encode_ctxt, ebml_w: writer::Encoder, path: ast_map::path, fields: ~[@struct_field], global_index: @mut~[entry]) -> ~[entry] { @@ -447,7 +447,7 @@ fn encode_info_for_struct(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::Encoder, id: node_id, ident: ident, path: ast_map::path, item: Option, tps: ~[ty_param]) { ebml_w.start_tag(tag_items_data_item); @@ -472,7 +472,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::Encoder, impl_path: ast_map::path, should_inline: bool, parent_id: node_id, m: @method, all_tps: ~[ty_param]) { @@ -527,7 +527,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::Encoder, item: @item, index: @mut ~[entry], path: ast_map::path) { @@ -540,7 +540,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::Encoder, index: @mut ~[entry]) { index.push({val: item.id, pos: ebml_w.writer.tell()}); } @@ -804,7 +804,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::Encoder, nitem: @foreign_item, index: @mut ~[entry], path: ast_map::path, abi: foreign_abi) { @@ -837,7 +837,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::Encoder, crate: @crate) -> ~[entry] { let index = @mut ~[]; ebml_w.start_tag(tag_items_data); @@ -892,7 +892,7 @@ fn create_index(index: ~[entry]) -> return buckets_frozen; } -fn encode_index(ebml_w: writer::Serializer, buckets: ~[@~[entry]], +fn encode_index(ebml_w: writer::Encoder, buckets: ~[@~[entry]], write_fn: fn(io::Writer, T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); @@ -927,7 +927,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::Encoder, mi: meta_item) { match mi.node { meta_word(ref name) => { ebml_w.start_tag(tag_meta_item_word); @@ -964,7 +964,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::Encoder, attrs: ~[attribute]) { ebml_w.start_tag(tag_attributes); for attrs.each |attr| { ebml_w.start_tag(tag_attribute); @@ -1025,7 +1025,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::Encoder, cstore: cstore::CStore) { fn get_ordered_deps(ecx: @encode_ctxt, cstore: cstore::CStore) @@ -1071,7 +1071,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::Encoder, dep: decoder::crate_dep) { ebml_w.start_tag(tag_crate_dep); ebml_w.start_tag(tag_crate_dep_name); @@ -1086,7 +1086,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::Encoder, hash: ~str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::to_bytes(hash)); ebml_w.end_tag(); @@ -1124,7 +1124,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::Encoder(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 ea018bd528e20..1d63c2dd1027a 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -21,13 +21,9 @@ use std::ebml; 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, - SerializerHelpers, - DeserializerHelpers, - deserialize}; +use std::serialize; +use std::serialize::{Encodable, EncoderHelpers, DecoderHelpers, decode}; use middle::{ty, typeck}; use middle::typeck::{method_origin, method_map_entry, vtable_res, @@ -90,7 +86,7 @@ trait tr_intern { // Top-level methods. fn encode_inlined_item(ecx: @e::encode_ctxt, - ebml_w: writer::Serializer, + ebml_w: writer::Encoder, path: ast_map::path, ii: ast::inlined_item, maps: maps) { @@ -101,7 +97,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt, let id_range = ast_util::compute_id_range_for_inlined_item(ii); do ebml_w.wr_tag(c::tag_ast as uint) { - id_range.serialize(&ebml_w); + id_range.encode(&ebml_w); encode_ast(ebml_w, simplify_ast(ii)); encode_side_tables_for_ii(ecx, maps, ebml_w, ii); } @@ -123,8 +119,8 @@ 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 from_id_range = deserialize(ast_dsr); + let ast_dsr = &reader::Decoder(ast_doc); + let from_id_range = decode(ast_dsr); let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); let xcx = extended_decode_ctxt_(@{dcx: dcx, from_id_range: from_id_range, @@ -200,24 +196,24 @@ impl span: tr { } } -trait def_id_serializer_helpers { +trait def_id_encoder_helpers { fn emit_def_id(did: ast::def_id); } -impl S: def_id_serializer_helpers { +impl S: def_id_encoder_helpers { fn emit_def_id(did: ast::def_id) { - did.serialize(&self) + did.encode(&self) } } -trait def_id_deserializer_helpers { +trait def_id_decoder_helpers { fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id; } -impl D: def_id_deserializer_helpers { +impl D: def_id_decoder_helpers { fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id { - let did: ast::def_id = deserialize(&self); + let did: ast::def_id = decode(&self); did.tr(xcx) } } @@ -237,9 +233,9 @@ 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::Encoder, item: ast::inlined_item) { do ebml_w.wr_tag(c::tag_tree as uint) { - item.serialize(&ebml_w) + item.encode(&ebml_w) } } @@ -293,8 +289,8 @@ 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); - deserialize(d) + let d = &reader::Decoder(chi_doc); + decode(d) } fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item) @@ -333,13 +329,13 @@ 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) { - def.serialize(&ebml_w) +fn encode_def(ebml_w: writer::Encoder, def: ast::def) { + def.encode(&ebml_w) } fn decode_def(xcx: extended_decode_ctxt, doc: ebml::Doc) -> ast::def { - let dsr = &reader::Deserializer(doc); - let def: ast::def = deserialize(dsr); + let dsr = &reader::Decoder(doc); + let def: ast::def = decode(dsr); def.tr(xcx) } @@ -426,17 +422,17 @@ impl ty::bound_region: tr { // ______________________________________________________________________ // Encoding and decoding of freevar information -fn encode_freevar_entry(ebml_w: writer::Serializer, fv: @freevar_entry) { - (*fv).serialize(&ebml_w) +fn encode_freevar_entry(ebml_w: writer::Encoder, fv: @freevar_entry) { + (*fv).encode(&ebml_w) } -trait ebml_deserializer_helper { +trait ebml_decoder_helper { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry; } -impl reader::Deserializer: ebml_deserializer_helper { +impl reader::Decoder: ebml_decoder_helper { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry { - let fv: freevar_entry = deserialize(&self); + let fv: freevar_entry = decode(&self); fv.tr(xcx) } } @@ -454,23 +450,23 @@ trait read_method_map_entry_helper { fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry; } -fn serialize_method_map_entry(ecx: @e::encode_ctxt, - ebml_w: writer::Serializer, +fn encode_method_map_entry(ecx: @e::encode_ctxt, + ebml_w: writer::Encoder, mme: method_map_entry) { do ebml_w.emit_rec { do ebml_w.emit_field(~"self_arg", 0u) { ebml_w.emit_arg(ecx, mme.self_arg); } do ebml_w.emit_field(~"explicit_self", 2u) { - mme.explicit_self.serialize(&ebml_w); + mme.explicit_self.encode(&ebml_w); } do ebml_w.emit_field(~"origin", 1u) { - mme.origin.serialize(&ebml_w); + mme.origin.encode(&ebml_w); } } } -impl reader::Deserializer: read_method_map_entry_helper { +impl reader::Decoder: read_method_map_entry_helper { fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry { do self.read_rec { {self_arg: @@ -479,12 +475,12 @@ impl reader::Deserializer: read_method_map_entry_helper { }), explicit_self: self.read_field(~"explicit_self", 2u, || { - let self_type: ast::self_ty_ = deserialize(&self); + let self_type: ast::self_ty_ = decode(&self); self_type }), origin: self.read_field(~"origin", 1u, || { - let method_origin: method_origin = deserialize(&self); + let method_origin: method_origin = decode(&self); method_origin.tr(xcx) })} } @@ -514,11 +510,11 @@ impl method_origin: tr { // Encoding and decoding vtable_res fn encode_vtable_res(ecx: @e::encode_ctxt, - ebml_w: writer::Serializer, + ebml_w: writer::Encoder, dr: typeck::vtable_res) { - // can't autogenerate this code because automatic serialization of + // can't autogenerate this code because automatic code of // ty::t doesn't work, and there is no way (atm) to have - // hand-written serialization routines combine with auto-generated + // hand-written encoding routines combine with auto-generated // ones. perhaps we should fix this. do ebml_w.emit_from_vec(*dr) |vtable_origin| { encode_vtable_origin(ecx, ebml_w, *vtable_origin) @@ -526,7 +522,7 @@ fn encode_vtable_res(ecx: @e::encode_ctxt, } fn encode_vtable_origin(ecx: @e::encode_ctxt, - ebml_w: writer::Serializer, + ebml_w: writer::Encoder, vtable_origin: typeck::vtable_origin) { do ebml_w.emit_enum(~"vtable_origin") { match vtable_origin { @@ -568,12 +564,12 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } -trait vtable_deserialization_helpers { +trait vtable_decoder_helpers { fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res; fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin; } -impl reader::Deserializer: vtable_deserialization_helpers { +impl reader::Decoder: vtable_decoder_helpers { fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res { @self.read_to_vec(|| self.read_vtable_origin(xcx) ) } @@ -650,7 +646,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::Encoder: ebml_writer_helpers { fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) { do self.emit_opaque { e::write_type(ecx, self, ty) @@ -689,7 +685,7 @@ impl writer::Serializer: ebml_writer_helpers { } } do self.emit_field(~"region_param", 1u) { - tpbt.region_param.serialize(&self); + tpbt.region_param.encode(&self); } do self.emit_field(~"ty", 2u) { self.emit_ty(ecx, tpbt.ty); @@ -703,7 +699,7 @@ trait write_tag_and_id { fn id(id: ast::node_id); } -impl writer::Serializer: write_tag_and_id { +impl writer::Encoder: write_tag_and_id { fn tag(tag_id: c::astencode_tag, f: fn()) { do self.wr_tag(tag_id as uint) { f() } } @@ -715,7 +711,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::Encoder, ii: ast::inlined_item) { do ebml_w.wr_tag(c::tag_table as uint) { ast_util::visit_ids_for_inlined_item( @@ -731,7 +727,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::Encoder, id: ast::node_id) { let tcx = ecx.tcx; @@ -741,7 +737,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, do ebml_w.tag(c::tag_table_def) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - (*def).serialize(&ebml_w) + (*def).encode(&ebml_w) } } } @@ -818,7 +814,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { do ebml_w.emit_from_vec((*m).get()) |id| { - id.serialize(&ebml_w); + id.encode(&ebml_w); } } } @@ -828,7 +824,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, do ebml_w.tag(c::tag_table_method_map) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - serialize_method_map_entry(ecx, ebml_w, *mme) + encode_method_map_entry(ecx, ebml_w, *mme) } } } @@ -846,7 +842,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, do ebml_w.tag(c::tag_table_adjustments) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - (**adj).serialize(&ebml_w) + (**adj).encode(&ebml_w) } } } @@ -861,7 +857,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, do ebml_w.tag(c::tag_table_value_mode) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - (*vm).serialize(&ebml_w) + (*vm).encode(&ebml_w) } } } @@ -879,7 +875,7 @@ impl ebml::Doc: doc_decoder_helpers { } } -trait ebml_deserializer_decoder_helpers { +trait ebml_decoder_decoder_helpers { fn read_arg(xcx: extended_decode_ctxt) -> ty::arg; fn read_ty(xcx: extended_decode_ctxt) -> ty::t; fn read_tys(xcx: extended_decode_ctxt) -> ~[ty::t]; @@ -888,7 +884,7 @@ trait ebml_deserializer_decoder_helpers { -> ty::ty_param_bounds_and_ty; } -impl reader::Deserializer: ebml_deserializer_decoder_helpers { +impl reader::Decoder: ebml_decoder_decoder_helpers { fn read_arg(xcx: extended_decode_ctxt) -> ty::arg { do self.read_opaque |doc| { @@ -932,7 +928,7 @@ impl reader::Deserializer: ebml_deserializer_decoder_helpers { @self.read_to_vec(|| self.read_bounds(xcx) ) }), region_param: self.read_field(~"region_param", 1u, || { - deserialize(&self) + decode(&self) }), ty: self.read_field(~"ty", 2u, || { self.read_ty(xcx) @@ -960,7 +956,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::Decoder(val_doc); if tag == (c::tag_table_def as uint) { let def = decode_def(xcx, val_doc); dcx.tcx.def_map.insert(id, def); @@ -996,11 +992,11 @@ fn decode_side_tables(xcx: extended_decode_ctxt, dcx.maps.vtable_map.insert(id, val_dsr.read_vtable_res(xcx)); } else if tag == (c::tag_table_adjustments as uint) { - let adj: @ty::AutoAdjustment = @deserialize(val_dsr); + let adj: @ty::AutoAdjustment = @decode(val_dsr); adj.tr(xcx); dcx.tcx.adjustments.insert(id, adj); } else if tag == (c::tag_table_value_mode as uint) { - let vm: ty::ValueMode = deserialize(val_dsr); + let vm: ty::ValueMode = decode(val_dsr); dcx.tcx.value_modes.insert(id, vm); } else { xcx.dcx.tcx.sess.bug( @@ -1016,17 +1012,17 @@ 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::Encoder, item: @ast::item) { do ebml_w.wr_tag(c::tag_tree as uint) { - (*item).serialize(&ebml_w) + (*item).encode(&ebml_w) } } #[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); - @deserialize(d) + let d = &reader::Decoder(chi_doc); + @decode(d) } #[cfg(test)] @@ -1052,17 +1048,17 @@ 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::Encoder(wr); encode_item_ast(ebml_w, in_item); }; let ebml_doc = reader::Doc(@bytes); let out_item = decode_item_ast(ebml_doc); let exp_str = do io::with_str_writer |w| { - in_item.serialize(&std::prettyprint::Serializer(w)) + in_item.encode(&std::prettyprint::Encoder(w)) }; let out_str = do io::with_str_writer |w| { - out_item.serialize(&std::prettyprint::Serializer(w)) + out_item.encode(&std::prettyprint::Encoder(w)) }; debug!("expected string: %s", exp_str); diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index cfebe7c06e9b1..38ec7dd5eb071 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -26,8 +26,8 @@ export has_freevars; // A vector of defs representing the free variables referred to in a function. // (The def_upvar will already have been stripped). -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type freevar_entry = { def: ast::def, //< The variable being accessed free. span: span //< First span where it is accessed (there can be multiple) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index d244021763782..19f2be9947f2c 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -106,7 +106,7 @@ export ty_estr, mk_estr, type_is_str; export ty_evec, mk_evec, type_is_vec; export ty_unboxed_vec, mk_unboxed_vec, mk_mut_unboxed_vec; export vstore, vstore_fixed, vstore_uniq, vstore_box, vstore_slice; -export serialize_vstore, deserialize_vstore; +export encode_vstore, decode_vstore; export ty_nil, mk_nil, type_is_nil; export ty_trait, mk_trait; export ty_param, mk_param, ty_params_to_tys; @@ -240,8 +240,8 @@ type method = {ident: ast::ident, type mt = {ty: t, mutbl: ast::mutability}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum vstore { vstore_fixed(uint), vstore_uniq, @@ -257,8 +257,8 @@ type field_ty = { }; /// How an lvalue is to be used. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] pub enum ValueMode { ReadValue, // Non-destructively read the value; do not copy or move. CopyValue, // Copy the value. @@ -309,8 +309,8 @@ enum ast_ty_to_ty_cache_entry { type opt_region_variance = Option; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum region_variance { rv_covariant, rv_invariant, rv_contravariant } impl region_variance : cmp::Eq { @@ -327,23 +327,23 @@ impl region_variance : cmp::Eq { pure fn ne(&self, other: ®ion_variance) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] pub type AutoAdjustment = { autoderefs: uint, autoref: Option }; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] pub type AutoRef = { kind: AutoRefKind, region: Region, mutbl: ast::mutability }; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum AutoRefKind { /// Convert from T to &T AutoPtr, @@ -571,8 +571,8 @@ impl param_ty : to_bytes::IterBytes { /// Representation of regions: -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum Region { /// Bound regions are found (primarily) in function types. They indicate /// region parameters that have yet to be replaced with actual regions @@ -600,8 +600,8 @@ enum Region { re_infer(InferRegion) } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum bound_region { /// The self region for structs, impls (&T in a type defn or &self/T) br_self, @@ -739,8 +739,8 @@ enum TyVid = uint; enum IntVid = uint; enum FloatVid = uint; enum FnVid = uint; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum RegionVid = uint; enum InferTy { @@ -759,8 +759,8 @@ impl InferTy : to_bytes::IterBytes { } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum InferRegion { ReVar(RegionVid), ReSkolemized(uint, bound_region) diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 6af374353ab74..a851c5a4bfac4 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -105,8 +105,8 @@ mod collect; mod coherence; mod deriving; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum method_origin { // fully statically resolved method method_static(ast::def_id), @@ -123,8 +123,8 @@ enum method_origin { // details for a method invoked with a receiver whose type is a type parameter // with a bounded trait. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type method_param = { // the trait containing the method to be invoked trait_id: ast::def_id, diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 1c6384f87d41f..0e1b6852e7e0b 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -9,7 +9,7 @@ // except according to those terms. #[forbid(deprecated_mode)]; -use serialization; +use serialize; // Simple Extensible Binary Markup Language (ebml) reader and writer on a // cursor model. See the specification here: @@ -38,7 +38,7 @@ struct TaggedDoc { doc: Doc, } -enum EbmlSerializerTag { +enum EbmlEncoderTag { EsUint, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8, EsBool, @@ -189,16 +189,16 @@ pub mod reader { pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } - pub struct Deserializer { + pub struct Decoder { priv mut parent: Doc, priv mut pos: uint, } - pub fn Deserializer(d: Doc) -> Deserializer { - Deserializer { mut parent: d, mut pos: d.start } + pub fn Decoder(d: Doc) -> Decoder { + Decoder { mut parent: d, mut pos: d.start } } - priv impl Deserializer { + priv impl Decoder { fn _check_label(lbl: &str) { if self.pos < self.parent.end { let TaggedDoc { tag: r_tag, doc: r_doc } = @@ -214,7 +214,7 @@ pub mod reader { } } - fn next_doc(exp_tag: EbmlSerializerTag) -> Doc { + fn next_doc(exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { fail ~"no more documents in current node!"; @@ -247,14 +247,14 @@ pub mod reader { move r } - fn _next_uint(exp_tag: EbmlSerializerTag) -> uint { + fn _next_uint(exp_tag: EbmlEncoderTag) -> uint { let r = doc_as_u32(self.next_doc(exp_tag)); debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); r as uint } } - impl Deserializer { + impl Decoder { fn read_opaque(&self, op: fn(Doc) -> R) -> R { do self.push_doc(self.next_doc(EsOpaque)) { op(copy self.parent) @@ -262,7 +262,7 @@ pub mod reader { } } - impl Deserializer: serialization::Deserializer { + impl Decoder: serialize::Decoder { fn read_nil(&self) -> () { () } fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) } @@ -387,7 +387,7 @@ pub mod reader { pub mod writer { // ebml writing - pub struct Serializer { + pub struct Encoder { writer: io::Writer, priv mut size_positions: ~[uint], } @@ -412,13 +412,13 @@ pub mod writer { fail fmt!("vint to write too big: %?", n); } - pub fn Serializer(w: io::Writer) -> Serializer { + pub fn Encoder(w: io::Writer) -> Encoder { let size_positions: ~[uint] = ~[]; - Serializer { writer: w, mut size_positions: size_positions } + Encoder { writer: w, mut size_positions: size_positions } } // FIXME (#2741): Provide a function to write the standard ebml header. - impl Serializer { + impl Encoder { fn start_tag(tag_id: uint) { debug!("Start tag %u", tag_id); @@ -516,13 +516,13 @@ pub mod writer { // FIXME (#2743): optionally perform "relaxations" on end_tag to more // efficiently encode sizes; this is a fixed point iteration - // Set to true to generate more debugging in EBML serialization. + // Set to true to generate more debugging in EBML code. // Totally lame approach. const debug: bool = false; - priv impl Serializer { + priv impl Encoder { // used internally to emit things like the vector length and so on - fn _emit_tagged_uint(t: EbmlSerializerTag, v: uint) { + fn _emit_tagged_uint(t: EbmlEncoderTag, v: uint) { assert v <= 0xFFFF_FFFF_u; self.wr_tagged_u32(t as uint, v as u32); } @@ -530,15 +530,15 @@ pub mod writer { fn _emit_label(label: &str) { // There are various strings that we have access to, such as // the name of a record field, which do not actually appear in - // the serialized EBML (normally). This is just for + // the encoded EBML (normally). This is just for // efficiency. When debugging, though, we can emit such - // labels and then they will be checked by deserializer to + // labels and then they will be checked by decoder to // try and check failures more quickly. if debug { self.wr_tagged_str(EsLabel as uint, label) } } } - impl Serializer { + impl Encoder { fn emit_opaque(&self, f: fn()) { do self.wr_tag(EsOpaque as uint) { f() @@ -546,7 +546,7 @@ pub mod writer { } } - impl Serializer: serialization::Serializer { + impl Encoder: serialize::Encoder { fn emit_nil(&self) {} fn emit_uint(&self, v: uint) { @@ -652,12 +652,12 @@ mod tests { fn test_v(v: Option) { debug!("v == %?", v); let bytes = do io::with_bytes_writer |wr| { - let ebml_w = writer::Serializer(wr); - v.serialize(&ebml_w) + let ebml_w = writer::Encoder(wr); + v.encode(&ebml_w) }; let ebml_doc = reader::Doc(@bytes); - let deser = reader::Deserializer(ebml_doc); - let v1 = serialization::deserialize(&deser); + let deser = reader::Decoder(ebml_doc); + let v1 = serialize::decode(&deser); debug!("v1 == %?", v1); assert v == v1; } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index eb96e074a8258..09b4ec1d7bc4f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -65,15 +65,15 @@ fn spaces(n: uint) -> ~str { return ss; } -pub struct Serializer { +pub struct Encoder { priv wr: io::Writer, } -pub fn Serializer(wr: io::Writer) -> Serializer { - Serializer { wr: wr } +pub fn Encoder(wr: io::Writer) -> Encoder { + Encoder { wr: wr } } -pub impl Serializer: serialization::Serializer { +pub impl Encoder: serialize::Encoder { fn emit_nil(&self) { self.wr.write_str("null") } fn emit_uint(&self, v: uint) { self.emit_float(v as float); } @@ -168,16 +168,16 @@ pub impl Serializer: serialization::Serializer { } } -pub struct PrettySerializer { +pub struct PrettyEncoder { priv wr: io::Writer, priv mut indent: uint, } -pub fn PrettySerializer(wr: io::Writer) -> PrettySerializer { - PrettySerializer { wr: wr, indent: 0 } +pub fn PrettyEncoder(wr: io::Writer) -> PrettyEncoder { + PrettyEncoder { wr: wr, indent: 0 } } -pub impl PrettySerializer: serialization::Serializer { +pub impl PrettyEncoder: serialize::Encoder { fn emit_nil(&self) { self.wr.write_str("null") } fn emit_uint(&self, v: uint) { self.emit_float(v as float); } @@ -283,21 +283,19 @@ pub impl PrettySerializer: serialization::Serializer { } } -pub impl< - S: serialization::Serializer -> Json: serialization::Serializable { - fn serialize(&self, s: &S) { +pub impl Json: serialize::Encodable { + fn encode(&self, s: &S) { match *self { - Number(v) => v.serialize(s), - String(ref v) => v.serialize(s), - Boolean(v) => v.serialize(s), - List(ref v) => v.serialize(s), + Number(v) => v.encode(s), + String(ref v) => v.encode(s), + Boolean(v) => v.encode(s), + List(ref v) => v.encode(s), Object(ref v) => { do s.emit_rec || { let mut idx = 0; for v.each |key, value| { do s.emit_field(*key, idx) { - value.serialize(s); + value.encode(s); } idx += 1; } @@ -308,23 +306,23 @@ pub impl< } } -/// Serializes a json value into a io::writer +/// Encodes a json value into a io::writer pub fn to_writer(wr: io::Writer, json: &Json) { - json.serialize(&Serializer(wr)) + json.encode(&Encoder(wr)) } -/// Serializes a json value into a string +/// Encodes a json value into a string pub pure fn to_str(json: &Json) -> ~str unsafe { // ugh, should be safe io::with_str_writer(|wr| to_writer(wr, json)) } -/// Serializes a json value into a io::writer +/// Encodes a json value into a io::writer pub fn to_pretty_writer(wr: io::Writer, json: &Json) { - json.serialize(&PrettySerializer(wr)) + json.encode(&PrettyEncoder(wr)) } -/// Serializes a json value into a string +/// Encodes a json value into a string pub fn to_pretty_str(json: &Json) -> ~str { io::with_str_writer(|wr| to_pretty_writer(wr, json)) } @@ -336,7 +334,7 @@ pub struct Parser { priv mut col: uint, } -/// Deserializes a json value from an io::reader +/// Decode a json value from an io::reader pub fn Parser(rdr: io::Reader) -> Parser { Parser { rdr: rdr, @@ -695,28 +693,28 @@ priv impl Parser { } } -/// Deserializes a json value from an io::reader +/// Decodes a json value from an io::reader pub fn from_reader(rdr: io::Reader) -> Result { Parser(rdr).parse() } -/// Deserializes a json value from a string +/// Decodes a json value from a string pub fn from_str(s: &str) -> Result { do io::with_str_reader(s) |rdr| { from_reader(rdr) } } -pub struct Deserializer { +pub struct Decoder { priv json: Json, priv mut stack: ~[&Json], } -pub fn Deserializer(json: Json) -> Deserializer { - Deserializer { json: move json, stack: ~[] } +pub fn Decoder(json: Json) -> Decoder { + Decoder { json: move json, stack: ~[] } } -priv impl Deserializer { +priv impl Decoder { fn peek(&self) -> &self/Json { if self.stack.len() == 0 { self.stack.push(&self.json); } vec::last(self.stack) @@ -728,7 +726,7 @@ priv impl Deserializer { } } -pub impl Deserializer: serialization::Deserializer { +pub impl Decoder: serialize::Decoder { fn read_nil(&self) -> () { debug!("read_nil"); match *self.pop() { diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index d282996754481..ef26a8cb19035 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -12,17 +12,17 @@ use io::Writer; use io::WriterUtil; -use serialization; +use serialize; -pub struct Serializer { +pub struct Encoder { wr: io::Writer, } -pub fn Serializer(wr: io::Writer) -> Serializer { - Serializer { wr: wr } +pub fn Encoder(wr: io::Writer) -> Encoder { + Encoder { wr: wr } } -pub impl Serializer: serialization::Serializer { +pub impl Encoder: serialize::Encoder { fn emit_nil(&self) { self.wr.write_str(~"()") } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 65916aa599274..af1186694bd19 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -108,7 +108,7 @@ pub mod serialize; pub mod serialization; // A curious inner-module that's not exported that contains the binding -// 'std' so that macro-expanded references to std::code and such +// 'std' so that macro-expanded references to std::serialize and such // can be resolved within libcore. #[doc(hidden)] // FIXME #3538 mod std { diff --git a/src/libstd/time.rs b/src/libstd/time.rs index c4a6e39c86bfe..e45fc8e0107a9 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -31,8 +31,8 @@ extern mod rustrt { } /// A record specifying a time value in seconds and nanoseconds. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] pub struct Timespec { sec: i64, nsec: i32 } impl Timespec { @@ -83,8 +83,8 @@ pub fn tzset() { rustrt::rust_tzset(); } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] pub struct Tm { tm_sec: i32, // seconds after the minute ~[0-60] tm_min: i32, // minutes after the hour ~[0-59] diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 2fd085fdb3343..f62dcfa014e57 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -15,9 +15,7 @@ use either::{Right,Left,Either}; use json; use sha1; -use serialization::{Serializer,Serializable, - Deserializer,Deserializable, - deserialize}; +use serialize::{Encoder, Encodable, Decoder, Decodable, decode}; /** * @@ -162,13 +160,13 @@ struct Work { res: Option>> } -fn digest - Deserializable>(t: &T) -> ~str { +fn digest + Decodable>(t: &T) -> ~str { let sha = sha1::sha1(); let s = do io::with_str_writer |wr| { // XXX: sha1 should be a writer itself, shouldn't // go via strings. - t.serialize(&json::Serializer(wr)); + t.encode(&json::Encoder(wr)); }; sha.input_str(s); sha.result_str() @@ -189,8 +187,8 @@ impl Context { } fn prep - Deserializable>( + Encodable + Decodable>( @self, fn_name:&str, blk: fn((@mut Prep))->Work) -> Work { @@ -214,8 +212,8 @@ impl Prep { } fn exec - Deserializable>( + Encodable + Decodable>( @mut self, blk: ~fn(&Exec) -> T) -> Work { let cached = self.ctxt.db.prepare(self.fn_name, &self.declared_inputs); @@ -229,7 +227,7 @@ impl Prep { // XXX: check deps for freshness, only return if fresh. let v : T = do io::with_str_reader(res) |rdr| { let j = result::unwrap(json::from_reader(rdr)); - deserialize(&json::Deserializer(move j)) + decode(&json::Decoder(move j)) }; return Work::new(self, move Left(move v)); } @@ -251,8 +249,8 @@ impl Prep { } impl - Deserializable> + Encodable + Decodable> Work { static fn new(p: @mut Prep, e: Either>) -> Work { move Work { prep: p, res: Some(move e) } @@ -261,8 +259,8 @@ impl - Deserializable>(w: Work) -> T { + Encodable + Decodable>(w: Work) -> T { let mut ww = move w; let mut s = None; @@ -279,7 +277,7 @@ fn unwrap = {node: T, span: span}; @@ -33,12 +30,12 @@ macro_rules! interner_key ( // implemented. struct ident { repr: uint } -impl ident: Serializable { - fn serialize(&self, s: &S) { +impl ident: Encodable { + fn encode(&self, s: &S) { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => fail ~"serialization: TLS interner not set up", + None => fail ~"encode: TLS interner not set up", Some(intr) => intr }; @@ -46,12 +43,12 @@ impl ident: Serializable { } } -impl ident: Deserializable { - static fn deserialize(d: &D) -> ident { +impl ident: Decodable { + static fn decode(d: &D) -> ident { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => fail ~"deserialization: TLS interner not set up", + None => fail ~"decode: TLS interner not set up", Some(intr) => intr }; @@ -73,8 +70,8 @@ impl ident: to_bytes::IterBytes { // Functions may or may not have names. type fn_ident = Option; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type path = {span: span, global: bool, idents: ~[ident], @@ -85,8 +82,8 @@ type crate_num = int; type node_id = int; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type def_id = {crate: crate_num, node: node_id}; impl def_id : cmp::Eq { @@ -99,20 +96,20 @@ impl def_id : cmp::Eq { const local_crate: crate_num = 0; const crate_node_id: node_id = 0; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] // The AST represents all type param bounds as types. // typeck::collect::compute_bounds matches these against // the "special" built-in traits (see middle::lang_items) and // detects Copy, Send, Owned, and Const. enum ty_param_bound = @Ty; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type ty_param = {ident: ident, id: node_id, bounds: @~[ty_param_bound]}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum def { def_fn(def_id, purity), def_static_method(/* method */ def_id, @@ -277,8 +274,8 @@ type crate_ = type meta_item = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum meta_item_ { meta_word(~str), meta_list(~str, ~[@meta_item]), @@ -287,24 +284,24 @@ enum meta_item_ { type blk = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type blk_ = {view_items: ~[@view_item], stmts: ~[@stmt], expr: Option<@expr>, id: node_id, rules: blk_check_mode}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type pat = {id: node_id, node: pat_, span: span}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type field_pat = {ident: ident, pat: @pat}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum binding_mode { bind_by_value, bind_by_move, @@ -360,8 +357,8 @@ impl binding_mode : cmp::Eq { pure fn ne(&self, other: &binding_mode) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum pat_ { pat_wild, // A pat_ident may either be a new bound variable, @@ -384,8 +381,8 @@ enum pat_ { pat_range(@expr, @expr), } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum mutability { m_mutbl, m_imm, m_const, } impl mutability : to_bytes::IterBytes { @@ -401,8 +398,8 @@ impl mutability : cmp::Eq { pure fn ne(&self, other: &mutability) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] pub enum Proto { ProtoBare, // bare functions (deprecated) ProtoUniq, // ~fn @@ -423,8 +420,8 @@ impl Proto : to_bytes::IterBytes { } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum vstore { // FIXME (#3469): Change uint to @expr (actually only constant exprs) vstore_fixed(Option), // [1,2,3,4] @@ -433,8 +430,8 @@ enum vstore { vstore_slice(@region) // &[1,2,3,4](foo)? } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum expr_vstore { // FIXME (#3469): Change uint to @expr (actually only constant exprs) expr_vstore_fixed(Option), // [1,2,3,4] @@ -452,8 +449,8 @@ pure fn is_blockish(p: ast::Proto) -> bool { } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum binop { add, subtract, @@ -482,8 +479,8 @@ impl binop : cmp::Eq { pure fn ne(&self, other: &binop) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum unop { box(mutability), uniq(mutability), @@ -534,8 +531,8 @@ impl unop : cmp::Eq { // Generally, after typeck you can get the inferred value // using ty::resolved_T(...). -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum inferable { expl(T), infer(node_id) @@ -574,8 +571,8 @@ impl inferable : cmp::Eq { } // "resolved" mode: the real modes. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum rmode { by_ref, by_val, by_move, by_copy } impl rmode : to_bytes::IterBytes { @@ -597,8 +594,8 @@ type mode = inferable; type stmt = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum stmt_ { stmt_decl(@decl, node_id), @@ -614,8 +611,8 @@ enum stmt_ { // FIXME (pending discussion of #1697, #2178...): local should really be // a refinement on pat. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type local_ = {is_mutbl: bool, ty: @Ty, pat: @pat, init: Option<@expr>, id: node_id}; @@ -623,22 +620,22 @@ type local = spanned; type decl = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum decl_ { decl_local(~[@local]), decl_item(@item), } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type arm = {pats: ~[@pat], guard: Option<@expr>, body: blk}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type field_ = {mutbl: mutability, ident: ident, expr: @expr}; type field = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum blk_check_mode { default_blk, unsafe_blk, } impl blk_check_mode : cmp::Eq { @@ -653,18 +650,18 @@ impl blk_check_mode : cmp::Eq { pure fn ne(&self, other: &blk_check_mode) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type expr = {id: node_id, callee_id: node_id, node: expr_, span: span}; // Extra node ID is only used for index, assign_op, unary, binary, method call -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum log_level { error, debug, log_other } // 0 = error, 1 = debug, 2 = log_other -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum expr_ { expr_vstore(@expr, expr_vstore), expr_vec(~[@expr], mutability), @@ -723,8 +720,8 @@ enum expr_ { expr_paren(@expr) } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type capture_item_ = { id: int, is_move: bool, @@ -752,8 +749,8 @@ type capture_clause = @~[capture_item]; // else knows what to do with them, so you'll probably get a syntax // error. // -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] #[doc="For macro invocations; parsing is delegated to the macro"] enum token_tree { tt_tok(span, token::Token), @@ -817,8 +814,8 @@ enum token_tree { // type matcher = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum matcher_ { // match one token match_tok(token::Token), @@ -833,14 +830,14 @@ type mac = spanned; type mac_arg = Option<@expr>; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type mac_body_ = {span: span}; type mac_body = Option; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum mac_ { mac_invoc(@path, mac_arg, mac_body), // old macro-invocation mac_invoc_tt(@path,~[token_tree]), // new macro-invocation @@ -853,8 +850,8 @@ enum mac_ { type lit = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum lit_ { lit_str(@~str), lit_int(i64, int_ty), @@ -898,24 +895,24 @@ impl ast::lit_: cmp::Eq { // NB: If you change this, you'll probably want to change the corresponding // type structure in middle/ty.rs as well. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type mt = {ty: @Ty, mutbl: mutability}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type ty_field_ = {ident: ident, mt: mt}; type ty_field = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type ty_method = {ident: ident, attrs: ~[attribute], purity: purity, decl: fn_decl, tps: ~[ty_param], self_ty: self_ty, id: node_id, span: span}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] // A trait method is either required (meaning it doesn't have an // implementation, just a signature) or provided (meaning it has a default // implementation). @@ -924,8 +921,8 @@ enum trait_method { provided(@method), } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, } impl int_ty : to_bytes::IterBytes { @@ -954,8 +951,8 @@ impl int_ty : cmp::Eq { pure fn ne(&self, other: &int_ty) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, } impl uint_ty : to_bytes::IterBytes { @@ -982,8 +979,8 @@ impl uint_ty : cmp::Eq { pure fn ne(&self, other: &uint_ty) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum float_ty { ty_f, ty_f32, ty_f64, } impl float_ty : to_bytes::IterBytes { @@ -1002,13 +999,13 @@ impl float_ty : cmp::Eq { pure fn ne(&self, other: &float_ty) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type Ty = {id: node_id, node: ty_, span: span}; // Not represented directly in the AST, referred to by name through a ty_path. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum prim_ty { ty_int(int_ty), ty_uint(uint_ty), @@ -1055,12 +1052,12 @@ impl prim_ty : cmp::Eq { pure fn ne(&self, other: &prim_ty) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type region = {id: node_id, node: region_}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum region_ { re_anon, re_static, @@ -1068,8 +1065,8 @@ enum region_ { re_named(ident) } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum Onceness { Once, Many @@ -1087,8 +1084,8 @@ impl Onceness : cmp::Eq { } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] struct TyFn { proto: Proto, region: Option<@region>, @@ -1098,8 +1095,8 @@ struct TyFn { decl: fn_decl } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum ty_ { ty_nil, ty_bot, /* bottom type */ @@ -1138,19 +1135,19 @@ impl Ty : to_bytes::IterBytes { } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type arg = {mode: mode, ty: @Ty, pat: @pat, id: node_id}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type fn_decl = {inputs: ~[arg], output: @Ty, cf: ret_style}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum purity { pure_fn, // declared with "pure fn" unsafe_fn, // declared with "unsafe fn" @@ -1171,8 +1168,8 @@ impl purity : cmp::Eq { pure fn ne(&self, other: &purity) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum ret_style { noreturn, // functions with return type _|_ that always // raise an error or exit (i.e. never return to the caller) @@ -1197,8 +1194,8 @@ impl ret_style : cmp::Eq { pure fn ne(&self, other: &ret_style) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum self_ty_ { sty_static, // no self: static method sty_by_ref, // old by-reference self: `` @@ -1254,20 +1251,20 @@ impl self_ty_ : cmp::Eq { type self_ty = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type method = {ident: ident, attrs: ~[attribute], tps: ~[ty_param], self_ty: self_ty, purity: purity, decl: fn_decl, body: blk, id: node_id, span: span, self_id: node_id, vis: visibility}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type _mod = {view_items: ~[@view_item], items: ~[@item]}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum foreign_abi { foreign_abi_rust_intrinsic, foreign_abi_cdecl, @@ -1275,8 +1272,8 @@ enum foreign_abi { } // Foreign mods can be named or anonymous -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum foreign_mod_sort { named, anonymous } impl foreign_mod_sort : cmp::Eq { @@ -1300,49 +1297,49 @@ impl foreign_abi : cmp::Eq { pure fn ne(&self, other: &foreign_abi) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type foreign_mod = {sort: foreign_mod_sort, abi: ident, view_items: ~[@view_item], items: ~[@foreign_item]}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type variant_arg = {ty: @Ty, id: node_id}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum variant_kind { tuple_variant_kind(~[variant_arg]), struct_variant_kind(@struct_def), enum_variant_kind(enum_def) } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type enum_def_ = { variants: ~[variant], common: Option<@struct_def> }; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum enum_def = enum_def_; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind, id: node_id, disr_expr: Option<@expr>, vis: visibility}; type variant = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type path_list_ident_ = {name: ident, id: node_id}; type path_list_ident = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum namespace { module_ns, type_value_ns } impl namespace : cmp::Eq { @@ -1354,8 +1351,8 @@ impl namespace : cmp::Eq { type view_path = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum view_path_ { // quux = foo::bar::baz @@ -1372,13 +1369,13 @@ enum view_path_ { view_path_list(@path, ~[path_list_ident], node_id) } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type view_item = {node: view_item_, attrs: ~[attribute], vis: visibility, span: span}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum view_item_ { view_item_use(ident, ~[@meta_item], node_id), view_item_import(~[@view_path]), @@ -1391,8 +1388,8 @@ type attribute = spanned; // Distinguishes between attributes that decorate items and attributes that // are contained as statements within items. These two cases need to be // distinguished for pretty-printing. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum attr_style { attr_outer, attr_inner, } impl attr_style : cmp::Eq { @@ -1403,8 +1400,8 @@ impl attr_style : cmp::Eq { } // doc-comments are promoted to attributes that have is_sugared_doc = true -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool}; /* @@ -1414,12 +1411,12 @@ type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool}; If this impl is an item_impl, the impl_id is redundant (it could be the same as the impl's node id). */ -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type trait_ref = {path: @path, ref_id: node_id}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum visibility { public, private, inherited } impl visibility : cmp::Eq { @@ -1436,8 +1433,8 @@ impl visibility : cmp::Eq { pure fn ne(&self, other: &visibility) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type struct_field_ = { kind: struct_field_kind, id: node_id, @@ -1446,8 +1443,8 @@ type struct_field_ = { type struct_field = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum struct_field_kind { named_field(ident, struct_mutability, visibility), unnamed_field // element of a tuple-like struct @@ -1480,8 +1477,8 @@ impl struct_field_kind : cmp::Eq { } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type struct_def = { fields: ~[@struct_field], /* fields */ /* (not including ctor or dtor) */ @@ -1496,14 +1493,14 @@ type struct_def = { FIXME (#3300): Should allow items to be anonymous. Right now we just use dummy names for anon items. */ -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type item = {ident: ident, attrs: ~[attribute], id: node_id, node: item_, vis: visibility, span: span}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum item_ { item_const(@Ty, @expr), item_fn(fn_decl, purity, ~[ty_param], blk), @@ -1520,8 +1517,8 @@ enum item_ { item_mac(mac), } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum struct_mutability { struct_mutable, struct_immutable } impl struct_mutability : to_bytes::IterBytes { @@ -1546,15 +1543,15 @@ impl struct_mutability : cmp::Eq { type struct_dtor = spanned; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type struct_dtor_ = {id: node_id, attrs: ~[attribute], self_id: node_id, body: blk}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type foreign_item = {ident: ident, attrs: ~[attribute], @@ -1563,8 +1560,8 @@ type foreign_item = span: span, vis: visibility}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum foreign_item_ { foreign_item_fn(fn_decl, purity, ~[ty_param]), foreign_item_const(@Ty) @@ -1573,8 +1570,8 @@ enum foreign_item_ { // The data we save and restore about an inlined item or method. This is not // part of the AST that we parse from a file, but it becomes part of the tree // that we trans. -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum inlined_item { ii_item(@item), ii_method(def_id /* impl id */, @method), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 3a8d399a45cdb..814d429f799ba 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -417,8 +417,8 @@ fn dtor_dec() -> fn_decl { // ______________________________________________________________________ // Enumerating the IDs which appear in an AST -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type id_range = {min: node_id, max: node_id}; fn empty(range: id_range) -> bool { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6481785e61af2..974455972f15e 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -22,10 +22,7 @@ source code snippets, etc. */ use dvec::DVec; -use std::serialization::{Serializable, - Deserializable, - Serializer, - Deserializer}; +use std::serialize::{Encodable, Decodable, Encoder, Decoder}; trait Pos { static pure fn from_uint(n: uint) -> self; @@ -131,13 +128,13 @@ impl span : cmp::Eq { pure fn ne(&self, other: &span) -> bool { !(*self).eq(other) } } -impl span: Serializable { - /* Note #1972 -- spans are serialized but not deserialized */ - fn serialize(&self, _s: &S) { } +impl span: Encodable { + /* Note #1972 -- spans are encoded but not decoded */ + fn encode(&self, _s: &S) { } } -impl span: Deserializable { - static fn deserialize(_d: &D) -> span { +impl span: Decodable { + static fn decode(_d: &D) -> span { ast_util::dummy_sp() } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e9d871752aae3..97b96446048f2 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -139,7 +139,7 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt, } // This is a secondary mechanism for invoking syntax extensions on items: -// "decorator" attributes, such as #[auto_serialize]. These are invoked by an +// "decorator" attributes, such as #[auto_encode]. These are invoked by an // attribute prefixing an item, and are interpreted by feeding the item // through the named attribute _as a syntax extension_ and splicing in the // resulting item vec into place in favour of the decorator. Note that diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a0aecd0375eba..01feaa8e69159 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -12,8 +12,8 @@ use util::interner; use util::interner::Interner; use std::map::HashMap; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum binop { PLUS, MINUS, @@ -27,8 +27,8 @@ enum binop { SHR, } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum Token { /* Expression-operator symbols. */ EQ, @@ -86,8 +86,8 @@ enum Token { EOF, } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] /// For interpolation during macro expansion. enum nonterminal { nt_item(@ast::item), @@ -353,7 +353,7 @@ impl ident_interner { } /* Key for thread-local data for sneaking interner information to the - * serializer/deserializer. It sounds like a hack because it is one. + * encoder/decoder. It sounds like a hack because it is one. * Bonus ultra-hack: functions as keys don't work across crates, * so we have to use a unique number. See taskgroup_key! in task.rs * for another case of this. */ diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto-encode.rs similarity index 87% rename from src/test/run-pass/auto_serialize.rs rename to src/test/run-pass/auto-encode.rs index fd9b30935cc9e..73bb5c2f4b873 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto-encode.rs @@ -20,16 +20,16 @@ use std::ebml; use EBReader = std::ebml::reader; use EBWriter = std::ebml::writer; use io::Writer; -use std::serialization::{Serializable, Deserializable, deserialize}; +use std::serialize::{Encodable, Decodable, decode}; use std::prettyprint; use std::time; -fn test_prettyprint>( +fn test_prettyprint>( a: &A, expected: &~str ) { let s = do io::with_str_writer |w| { - a.serialize(&prettyprint::Serializer(w)) + a.encode(&prettyprint::Encoder(w)) }; debug!("s == %?", s); assert s == *expected; @@ -37,20 +37,20 @@ fn test_prettyprint>( fn test_ebml - Deserializable + Encodable + Decodable >(a1: &A) { let bytes = do io::with_bytes_writer |wr| { - let ebml_w = &EBWriter::Serializer(wr); - a1.serialize(ebml_w) + let ebml_w = &EBWriter::Encoder(wr); + a1.encode(ebml_w) }; let d = EBReader::Doc(@move bytes); - let a2: A = deserialize(&EBReader::Deserializer(d)); + let a2: A = decode(&EBReader::Decoder(d)); assert *a1 == a2; } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum Expr { Val(uint), Plus(@Expr, @Expr), @@ -124,8 +124,8 @@ impl CLike : cmp::Eq { pure fn ne(&self, other: &CLike) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type Spanned = {lo: uint, hi: uint, node: T}; impl Spanned : cmp::Eq { @@ -137,27 +137,27 @@ impl Spanned : cmp::Eq { pure fn ne(&self, other: &Spanned) -> bool { !(*self).eq(other) } } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] type SomeRec = {v: ~[uint]}; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum AnEnum = SomeRec; -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] struct Point {x: uint, y: uint} -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum Quark { Top(T), Bottom(T) } -#[auto_serialize] -#[auto_deserialize] +#[auto_encode] +#[auto_decode] enum CLike { A, B, C } fn main() {