Permalink
Browse files

Switch from serialization to std::serialize. (snapshot)

  • Loading branch information...
1 parent ec93058 commit 8650c6f683cf43e9ced27e81945c20234d2bb61c @erickt erickt committed Dec 18, 2012
View
@@ -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
@@ -25,7 +25,7 @@ use reader = std::ebml::reader;
use std::ebml;
use std::map::HashMap;
use std::map;
-use std::serialization::deserialize;
+use std::serialize::decode;
use syntax::ast_map;
use syntax::attr;
use syntax::diagnostic::span_handler;
@@ -284,7 +284,7 @@ fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd)
fn item_ty_region_param(item: ebml::Doc) -> Option<ty::region_variance> {
reader::maybe_get_doc(item, tag_region_param).map(|doc| {
- deserialize(&reader::Deserializer(*doc))
+ decode(&reader::Decoder(*doc))
})
}
@@ -50,7 +50,7 @@ export encode_def_id;
type abbrev_map = map::HashMap<ty::t, tyencode::ty_abbrev>;
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<T> = {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,15 +152,15 @@ 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();
}
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,21 +174,21 @@ 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));
encode_ty_type_param_bounds(ebml_w, ecx, ty_param_bounds);
}
-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<int>],
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,15 +365,15 @@ 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',
inherited => 'N'
});
}
-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<int>]) -> ~[entry<int>] {
@@ -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<inlined_item>, 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<int>],
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<int>]) {
index.push({val: item.id, pos: ebml_w.writer.tell()});
}
@@ -807,7 +807,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<int>],
path: ast_map::path, abi: foreign_abi) {
@@ -840,7 +840,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<int>] {
let index = @mut ~[];
ebml_w.start_tag(tag_items_data);
@@ -895,7 +895,7 @@ fn create_index<T: Copy Hash IterBytes>(index: ~[entry<T>]) ->
return buckets_frozen;
}
-fn encode_index<T>(ebml_w: writer::Serializer, buckets: ~[@~[entry<T>]],
+fn encode_index<T>(ebml_w: writer::Encoder, buckets: ~[@~[entry<T>]],
write_fn: fn(io::Writer, T)) {
let writer = ebml_w.writer;
ebml_w.start_tag(tag_index);
@@ -930,7 +930,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);
@@ -967,7 +967,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);
@@ -1028,7 +1028,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)
@@ -1074,7 +1074,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);
@@ -1089,7 +1089,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();
@@ -1127,7 +1127,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);
Oops, something went wrong.

0 comments on commit 8650c6f

Please sign in to comment.