Remove the old serializers (needs snapshot)

This commit is contained in:
Erick Tryzelaar 2012-10-07 16:33:20 -07:00
parent 91b7a9a529
commit eb626e7119
21 changed files with 2265 additions and 2956 deletions

View file

@ -1,9 +1,9 @@
// The Rust abstract syntax tree.
use std::serialization2::{Serializable,
Deserializable,
Serializer,
Deserializer};
use std::serialization::{Serializable,
Deserializable,
Serializer,
Deserializer};
use codemap::{span, filename};
use parse::token;
@ -18,6 +18,8 @@ impl span: Deserializable {
}
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type spanned<T> = {node: T, span: span};
@ -74,6 +76,8 @@ impl ident: to_bytes::IterBytes {
// Functions may or may not have names.
type fn_ident = Option<ident>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type path = {span: span,
@ -86,6 +90,8 @@ type crate_num = int;
type node_id = int;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type def_id = {crate: crate_num, node: node_id};
@ -100,6 +106,8 @@ impl def_id : cmp::Eq {
const local_crate: crate_num = 0;
const crate_node_id: node_id = 0;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum ty_param_bound {
@ -110,10 +118,14 @@ enum ty_param_bound {
bound_trait(@ty),
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type ty_param = {ident: ident, id: node_id, bounds: @~[ty_param_bound]};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum def {
@ -294,6 +306,8 @@ type crate_directive = spanned<crate_directive_>;
type meta_item = spanned<meta_item_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum meta_item_ {
@ -304,6 +318,8 @@ enum meta_item_ {
type blk = spanned<blk_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type blk_ = {view_items: ~[@view_item],
@ -312,14 +328,20 @@ type blk_ = {view_items: ~[@view_item],
id: node_id,
rules: blk_check_mode};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type pat = {id: node_id, node: pat_, span: span};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type field_pat = {ident: ident, pat: @pat};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum binding_mode {
@ -377,6 +399,8 @@ impl binding_mode : cmp::Eq {
pure fn ne(other: &binding_mode) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum pat_ {
@ -401,6 +425,8 @@ enum pat_ {
pat_range(@expr, @expr),
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum mutability { m_mutbl, m_imm, m_const, }
@ -418,6 +444,8 @@ impl mutability : cmp::Eq {
pure fn ne(other: &mutability) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum proto {
@ -434,6 +462,8 @@ impl proto : cmp::Eq {
pure fn ne(other: &proto) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum vstore {
@ -444,6 +474,8 @@ enum vstore {
vstore_slice(@region) // &[1,2,3,4](foo)?
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum expr_vstore {
@ -461,6 +493,8 @@ pure fn is_blockish(p: ast::proto) -> bool {
}
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum binop {
@ -491,6 +525,8 @@ impl binop : cmp::Eq {
pure fn ne(other: &binop) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum unop {
@ -543,6 +579,8 @@ impl unop : cmp::Eq {
// Generally, after typeck you can get the inferred value
// using ty::resolved_T(...).
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum inferable<T> {
@ -583,6 +621,8 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
}
// "resolved" mode: the real modes.
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum rmode { by_ref, by_val, by_move, by_copy }
@ -606,6 +646,8 @@ type mode = inferable<rmode>;
type stmt = spanned<stmt_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum stmt_ {
@ -618,6 +660,8 @@ enum stmt_ {
stmt_semi(@expr, node_id),
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum init_op { init_assign, init_move, }
@ -642,12 +686,16 @@ impl init_op : cmp::Eq {
pure fn ne(other: &init_op) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type initializer = {op: init_op, expr: @expr};
// FIXME (pending discussion of #1697, #2178...): local should really be
// a refinement on pat.
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type local_ = {is_mutbl: bool, ty: @ty, pat: @pat,
@ -657,20 +705,28 @@ type local = spanned<local_>;
type decl = spanned<decl_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum decl_ { decl_local(~[@local]), decl_item(@item), }
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type arm = {pats: ~[@pat], guard: Option<@expr>, body: blk};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
type field = spanned<field_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum blk_check_mode { default_blk, unsafe_blk, }
@ -687,20 +743,28 @@ impl blk_check_mode : cmp::Eq {
pure fn ne(other: &blk_check_mode) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
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
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum log_level { error, debug, other }
// 0 = error, 1 = debug, 2 = other
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum alt_mode { alt_check, alt_exhaustive, }
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum expr_ {
@ -758,6 +822,8 @@ enum expr_ {
expr_repeat(@expr /* element */, @expr /* count */, mutability)
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type capture_item_ = {
@ -787,6 +853,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_serialize2]
#[auto_deserialize2]
#[doc="For macro invocations; parsing is delegated to the macro"]
@ -852,6 +920,8 @@ enum token_tree {
//
type matcher = spanned<matcher_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum matcher_ {
@ -868,12 +938,16 @@ type mac = spanned<mac_>;
type mac_arg = Option<@expr>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type mac_body_ = {span: span};
type mac_body = Option<mac_body_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum mac_ {
@ -888,6 +962,8 @@ enum mac_ {
type lit = spanned<lit_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum lit_ {
@ -930,22 +1006,30 @@ 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_serialize2]
#[auto_deserialize2]
type mt = {ty: @ty, mutbl: mutability};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type ty_field_ = {ident: ident, mt: mt};
type ty_field = spanned<ty_field_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
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_serialize2]
#[auto_deserialize2]
// A trait method is either required (meaning it doesn't have an
@ -956,6 +1040,8 @@ enum trait_method {
provided(@method),
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
@ -986,6 +1072,8 @@ impl int_ty : cmp::Eq {
pure fn ne(other: &int_ty) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
@ -1014,6 +1102,8 @@ impl uint_ty : cmp::Eq {
pure fn ne(other: &uint_ty) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum float_ty { ty_f, ty_f32, ty_f64, }
@ -1033,11 +1123,15 @@ impl float_ty : cmp::Eq {
pure fn ne(other: &float_ty) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
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_serialize2]
#[auto_deserialize2]
enum prim_ty {
@ -1086,10 +1180,14 @@ impl prim_ty : cmp::Eq {
pure fn ne(other: &prim_ty) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type region = {id: node_id, node: region_};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum region_ {
@ -1099,6 +1197,8 @@ enum region_ {
re_named(ident)
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum ty_ {
@ -1139,10 +1239,14 @@ impl ty : to_bytes::IterBytes {
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type arg = {mode: mode, ty: @ty, ident: ident, id: node_id};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type fn_decl =
@ -1150,6 +1254,8 @@ type fn_decl =
output: @ty,
cf: ret_style};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum purity {
@ -1172,6 +1278,8 @@ impl purity : cmp::Eq {
pure fn ne(other: &purity) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum ret_style {
@ -1198,6 +1306,8 @@ impl ret_style : cmp::Eq {
pure fn ne(other: &ret_style) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum self_ty_ {
@ -1255,6 +1365,8 @@ impl self_ty_ : cmp::Eq {
type self_ty = spanned<self_ty_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type method = {ident: ident, attrs: ~[attribute],
@ -1263,10 +1375,14 @@ type method = {ident: ident, attrs: ~[attribute],
id: node_id, span: span, self_id: node_id,
vis: visibility};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type _mod = {view_items: ~[@view_item], items: ~[@item]};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum foreign_abi {
@ -1276,6 +1392,8 @@ enum foreign_abi {
}
// Foreign mods can be named or anonymous
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum foreign_mod_sort { named, anonymous }
@ -1301,6 +1419,8 @@ impl foreign_abi : cmp::Eq {
pure fn ne(other: &foreign_abi) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type foreign_mod =
@ -1308,10 +1428,14 @@ type foreign_mod =
view_items: ~[@view_item],
items: ~[@foreign_item]};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type variant_arg = {ty: @ty, id: node_id};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum variant_kind {
@ -1320,14 +1444,20 @@ enum variant_kind {
enum_variant_kind(enum_def)
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type enum_def_ = { variants: ~[variant], common: Option<@struct_def> };
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum enum_def = enum_def_;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind,
@ -1335,12 +1465,16 @@ type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind,
type variant = spanned<variant_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type path_list_ident_ = {name: ident, id: node_id};
type path_list_ident = spanned<path_list_ident_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum namespace { module_ns, type_value_ns }
@ -1354,6 +1488,8 @@ impl namespace : cmp::Eq {
type view_path = spanned<view_path_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum view_path_ {
@ -1372,11 +1508,15 @@ enum view_path_ {
view_path_list(@path, ~[path_list_ident], node_id)
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type view_item = {node: view_item_, attrs: ~[attribute],
vis: visibility, span: span};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum view_item_ {
@ -1391,6 +1531,8 @@ type attribute = spanned<attribute_>;
// 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_serialize2]
#[auto_deserialize2]
enum attr_style { attr_outer, attr_inner, }
@ -1403,6 +1545,8 @@ impl attr_style : cmp::Eq {
}
// doc-comments are promoted to attributes that have is_sugared_doc = true
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
@ -1416,10 +1560,14 @@ type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
conceptually, the impl_id stands in for the pair of (this class, this
trait)
*/
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type trait_ref = {path: @path, ref_id: node_id, impl_id: node_id};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum visibility { public, private, inherited }
@ -1438,6 +1586,8 @@ impl visibility : cmp::Eq {
pure fn ne(other: &visibility) -> bool { !self.eq(other) }
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type struct_field_ = {
@ -1448,6 +1598,8 @@ type struct_field_ = {
type struct_field = spanned<struct_field_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum struct_field_kind {
@ -1455,6 +1607,8 @@ enum struct_field_kind {
unnamed_field // element of a tuple-like struct
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type struct_def = {
@ -1472,12 +1626,16 @@ 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_serialize2]
#[auto_deserialize2]
type item = {ident: ident, attrs: ~[attribute],
id: node_id, node: item_,
vis: visibility, span: span};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum item_ {
@ -1496,6 +1654,8 @@ enum item_ {
item_mac(mac),
}
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum class_mutability { class_mutable, class_immutable }
@ -1520,6 +1680,8 @@ impl class_mutability : cmp::Eq {
type class_ctor = spanned<class_ctor_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type class_ctor_ = {id: node_id,
@ -1530,6 +1692,8 @@ type class_ctor_ = {id: node_id,
type class_dtor = spanned<class_dtor_>;
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type class_dtor_ = {id: node_id,
@ -1537,6 +1701,8 @@ type class_dtor_ = {id: node_id,
self_id: node_id,
body: blk};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
type foreign_item =
@ -1547,6 +1713,8 @@ type foreign_item =
span: span,
vis: visibility};
#[auto_serialize]
#[auto_deserialize]
#[auto_serialize2]
#[auto_deserialize2]
enum foreign_item_ {
@ -1557,6 +1725,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_serialize2]
#[auto_deserialize2]
enum inlined_item {