migrate libsyntax/rustc to auto_serialize2
This commit is contained in:
parent
2a41abb9ef
commit
e1c517ca48
@ -1,33 +1,25 @@
|
||||
// The Rust abstract syntax tree.
|
||||
|
||||
use std::serialization2::{Serializable,
|
||||
Deserializable,
|
||||
Serializer,
|
||||
Deserializer};
|
||||
use codemap::{span, filename};
|
||||
use std::serialization::{Serializer,
|
||||
Deserializer,
|
||||
serialize_Option,
|
||||
deserialize_Option,
|
||||
serialize_uint,
|
||||
deserialize_uint,
|
||||
serialize_int,
|
||||
deserialize_int,
|
||||
serialize_i64,
|
||||
deserialize_i64,
|
||||
serialize_u64,
|
||||
deserialize_u64,
|
||||
serialize_str,
|
||||
deserialize_str,
|
||||
serialize_bool,
|
||||
deserialize_bool};
|
||||
use parse::token;
|
||||
|
||||
/* Note #1972 -- spans are serialized but not deserialized */
|
||||
fn serialize_span<S>(_s: S, _v: span) {
|
||||
impl span: Serializable {
|
||||
/* Note #1972 -- spans are serialized but not deserialized */
|
||||
fn serialize<S: Serializer>(&self, _s: &S) { }
|
||||
}
|
||||
|
||||
fn deserialize_span<D>(_d: D) -> span {
|
||||
ast_util::dummy_sp()
|
||||
impl span: Deserializable {
|
||||
static fn deserialize<D: Deserializer>(_d: &D) -> span {
|
||||
ast_util::dummy_sp()
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type spanned<T> = {node: T, span: span};
|
||||
|
||||
|
||||
@ -42,25 +34,30 @@ macro_rules! interner_key (
|
||||
// implemented.
|
||||
struct ident { repr: uint }
|
||||
|
||||
fn serialize_ident<S: Serializer>(s: S, i: ident) {
|
||||
let intr = match unsafe{
|
||||
task::local_data::local_data_get(interner_key!())
|
||||
} {
|
||||
None => fail ~"serialization: TLS interner not set up",
|
||||
Some(intr) => intr
|
||||
};
|
||||
impl ident: Serializable {
|
||||
fn serialize<S: Serializer>(&self, s: &S) {
|
||||
let intr = match unsafe {
|
||||
task::local_data::local_data_get(interner_key!())
|
||||
} {
|
||||
None => fail ~"serialization: TLS interner not set up",
|
||||
Some(intr) => intr
|
||||
};
|
||||
|
||||
s.emit_str(*(*intr).get(i));
|
||||
s.emit_owned_str(*(*intr).get(*self));
|
||||
}
|
||||
}
|
||||
fn deserialize_ident<D: Deserializer>(d: D) -> ident {
|
||||
let intr = match unsafe{
|
||||
task::local_data::local_data_get(interner_key!())
|
||||
} {
|
||||
None => fail ~"deserialization: TLS interner not set up",
|
||||
Some(intr) => intr
|
||||
};
|
||||
|
||||
(*intr).intern(@d.read_str())
|
||||
impl ident: Deserializable {
|
||||
static fn deserialize<D: Deserializer>(d: &D) -> ident {
|
||||
let intr = match unsafe {
|
||||
task::local_data::local_data_get(interner_key!())
|
||||
} {
|
||||
None => fail ~"deserialization: TLS interner not set up",
|
||||
Some(intr) => intr
|
||||
};
|
||||
|
||||
(*intr).intern(@d.read_owned_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl ident: cmp::Eq {
|
||||
@ -75,23 +72,22 @@ impl ident: to_bytes::IterBytes {
|
||||
}
|
||||
|
||||
// Functions may or may not have names.
|
||||
#[auto_serialize]
|
||||
type fn_ident = Option<ident>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type path = {span: span,
|
||||
global: bool,
|
||||
idents: ~[ident],
|
||||
rp: Option<@region>,
|
||||
types: ~[@ty]};
|
||||
|
||||
#[auto_serialize]
|
||||
type crate_num = int;
|
||||
|
||||
#[auto_serialize]
|
||||
type node_id = int;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type def_id = {crate: crate_num, node: node_id};
|
||||
|
||||
impl def_id : cmp::Eq {
|
||||
@ -104,7 +100,8 @@ impl def_id : cmp::Eq {
|
||||
const local_crate: crate_num = 0;
|
||||
const crate_node_id: node_id = 0;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum ty_param_bound {
|
||||
bound_copy,
|
||||
bound_send,
|
||||
@ -113,10 +110,12 @@ enum ty_param_bound {
|
||||
bound_trait(@ty),
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type ty_param = {ident: ident, id: node_id, bounds: @~[ty_param_bound]};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum def {
|
||||
def_fn(def_id, purity),
|
||||
def_static_method(def_id, purity),
|
||||
@ -293,33 +292,36 @@ enum crate_directive_ {
|
||||
|
||||
type crate_directive = spanned<crate_directive_>;
|
||||
|
||||
#[auto_serialize]
|
||||
type meta_item = spanned<meta_item_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum meta_item_ {
|
||||
meta_word(~str),
|
||||
meta_list(~str, ~[@meta_item]),
|
||||
meta_name_value(~str, lit),
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type blk = spanned<blk_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type blk_ = {view_items: ~[@view_item],
|
||||
stmts: ~[@stmt],
|
||||
expr: Option<@expr>,
|
||||
id: node_id,
|
||||
rules: blk_check_mode};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type pat = {id: node_id, node: pat_, span: span};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type field_pat = {ident: ident, pat: @pat};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum binding_mode {
|
||||
bind_by_value,
|
||||
bind_by_move,
|
||||
@ -375,7 +377,8 @@ impl binding_mode : cmp::Eq {
|
||||
pure fn ne(other: &binding_mode) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum pat_ {
|
||||
pat_wild,
|
||||
// A pat_ident may either be a new bound variable,
|
||||
@ -398,7 +401,8 @@ enum pat_ {
|
||||
pat_range(@expr, @expr),
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum mutability { m_mutbl, m_imm, m_const, }
|
||||
|
||||
impl mutability : to_bytes::IterBytes {
|
||||
@ -414,7 +418,8 @@ impl mutability : cmp::Eq {
|
||||
pure fn ne(other: &mutability) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum proto {
|
||||
proto_bare, // foreign fn
|
||||
proto_uniq, // fn~
|
||||
@ -429,7 +434,8 @@ impl proto : cmp::Eq {
|
||||
pure fn ne(other: &proto) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum vstore {
|
||||
// FIXME (#2112): Change uint to @expr (actually only constant exprs)
|
||||
vstore_fixed(Option<uint>), // [1,2,3,4]/_ or 4
|
||||
@ -438,7 +444,8 @@ enum vstore {
|
||||
vstore_slice(@region) // &[1,2,3,4](foo)?
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum expr_vstore {
|
||||
// FIXME (#2112): Change uint to @expr (actually only constant exprs)
|
||||
expr_vstore_fixed(Option<uint>), // [1,2,3,4]/_ or 4
|
||||
@ -454,7 +461,8 @@ pure fn is_blockish(p: ast::proto) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum binop {
|
||||
add,
|
||||
subtract,
|
||||
@ -483,7 +491,8 @@ impl binop : cmp::Eq {
|
||||
pure fn ne(other: &binop) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum unop {
|
||||
box(mutability),
|
||||
uniq(mutability),
|
||||
@ -534,7 +543,8 @@ impl unop : cmp::Eq {
|
||||
|
||||
// Generally, after typeck you can get the inferred value
|
||||
// using ty::resolved_T(...).
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum inferable<T> {
|
||||
expl(T),
|
||||
infer(node_id)
|
||||
@ -573,7 +583,8 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
|
||||
}
|
||||
|
||||
// "resolved" mode: the real modes.
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum rmode { by_ref, by_val, by_move, by_copy }
|
||||
|
||||
impl rmode : to_bytes::IterBytes {
|
||||
@ -591,13 +602,12 @@ impl rmode : cmp::Eq {
|
||||
}
|
||||
|
||||
// inferable mode.
|
||||
#[auto_serialize]
|
||||
type mode = inferable<rmode>;
|
||||
|
||||
#[auto_serialize]
|
||||
type stmt = spanned<stmt_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum stmt_ {
|
||||
stmt_decl(@decl, node_id),
|
||||
|
||||
@ -608,7 +618,8 @@ enum stmt_ {
|
||||
stmt_semi(@expr, node_id),
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum init_op { init_assign, init_move, }
|
||||
|
||||
impl init_op : cmp::Eq {
|
||||
@ -631,34 +642,37 @@ impl init_op : cmp::Eq {
|
||||
pure fn ne(other: &init_op) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type local_ = {is_mutbl: bool, ty: @ty, pat: @pat,
|
||||
init: Option<initializer>, id: node_id};
|
||||
|
||||
#[auto_serialize]
|
||||
type local = spanned<local_>;
|
||||
|
||||
#[auto_serialize]
|
||||
type decl = spanned<decl_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum decl_ { decl_local(~[@local]), decl_item(@item), }
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type arm = {pats: ~[@pat], guard: Option<@expr>, body: blk};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
|
||||
|
||||
#[auto_serialize]
|
||||
type field = spanned<field_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum blk_check_mode { default_blk, unsafe_blk, }
|
||||
|
||||
impl blk_check_mode : cmp::Eq {
|
||||
@ -673,18 +687,22 @@ impl blk_check_mode : cmp::Eq {
|
||||
pure fn ne(other: &blk_check_mode) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum log_level { error, debug, other }
|
||||
// 0 = error, 1 = debug, 2 = other
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum alt_mode { alt_check, alt_exhaustive, }
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum expr_ {
|
||||
expr_vstore(@expr, expr_vstore),
|
||||
expr_vec(~[@expr], mutability),
|
||||
@ -740,15 +758,17 @@ enum expr_ {
|
||||
expr_repeat(@expr /* element */, @expr /* count */, mutability)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type capture_item = @{
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type capture_item_ = {
|
||||
id: int,
|
||||
is_move: bool,
|
||||
name: ident, // Currently, can only capture a local var.
|
||||
span: span
|
||||
};
|
||||
|
||||
#[auto_serialize]
|
||||
type capture_item = @capture_item_;
|
||||
|
||||
type capture_clause = @~[capture_item];
|
||||
|
||||
//
|
||||
@ -767,7 +787,8 @@ type capture_clause = @~[capture_item];
|
||||
// else knows what to do with them, so you'll probably get a syntax
|
||||
// error.
|
||||
//
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
#[doc="For macro invocations; parsing is delegated to the macro"]
|
||||
enum token_tree {
|
||||
tt_tok(span, token::token),
|
||||
@ -829,10 +850,10 @@ enum token_tree {
|
||||
// If you understand that, you have closed to loop and understand the whole
|
||||
// macro system. Congratulations.
|
||||
//
|
||||
#[auto_serialize]
|
||||
type matcher = spanned<matcher_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum matcher_ {
|
||||
// match one token
|
||||
match_tok(token::token),
|
||||
@ -843,19 +864,18 @@ enum matcher_ {
|
||||
match_nonterminal(ident, ident, uint)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type mac = spanned<mac_>;
|
||||
|
||||
#[auto_serialize]
|
||||
type mac_arg = Option<@expr>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type mac_body_ = {span: span};
|
||||
|
||||
#[auto_serialize]
|
||||
type mac_body = Option<mac_body_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum mac_ {
|
||||
mac_invoc(@path, mac_arg, mac_body), // old macro-invocation
|
||||
mac_invoc_tt(@path,~[token_tree]), // new macro-invocation
|
||||
@ -866,10 +886,10 @@ enum mac_ {
|
||||
mac_var(uint)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type lit = spanned<lit_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum lit_ {
|
||||
lit_str(@~str),
|
||||
lit_int(i64, int_ty),
|
||||
@ -910,21 +930,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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type mt = {ty: @ty, mutbl: mutability};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type ty_field_ = {ident: ident, mt: mt};
|
||||
|
||||
#[auto_serialize]
|
||||
type ty_field = spanned<ty_field_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
// A trait method is either required (meaning it doesn't have an
|
||||
// implementation, just a signature) or provided (meaning it has a default
|
||||
// implementation).
|
||||
@ -933,7 +956,8 @@ enum trait_method {
|
||||
provided(@method),
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
|
||||
|
||||
impl int_ty : to_bytes::IterBytes {
|
||||
@ -962,7 +986,8 @@ impl int_ty : cmp::Eq {
|
||||
pure fn ne(other: &int_ty) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
|
||||
|
||||
impl uint_ty : to_bytes::IterBytes {
|
||||
@ -989,7 +1014,8 @@ impl uint_ty : cmp::Eq {
|
||||
pure fn ne(other: &uint_ty) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum float_ty { ty_f, ty_f32, ty_f64, }
|
||||
|
||||
impl float_ty : to_bytes::IterBytes {
|
||||
@ -1007,11 +1033,13 @@ impl float_ty : cmp::Eq {
|
||||
pure fn ne(other: &float_ty) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum prim_ty {
|
||||
ty_int(int_ty),
|
||||
ty_uint(uint_ty),
|
||||
@ -1058,10 +1086,12 @@ impl prim_ty : cmp::Eq {
|
||||
pure fn ne(other: &prim_ty) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type region = {id: node_id, node: region_};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum region_ {
|
||||
re_anon,
|
||||
re_static,
|
||||
@ -1069,7 +1099,8 @@ enum region_ {
|
||||
re_named(ident)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum ty_ {
|
||||
ty_nil,
|
||||
ty_bot, /* bottom type */
|
||||
@ -1108,16 +1139,19 @@ impl ty : to_bytes::IterBytes {
|
||||
}
|
||||
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type arg = {mode: mode, ty: @ty, ident: ident, id: node_id};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type fn_decl =
|
||||
{inputs: ~[arg],
|
||||
output: @ty,
|
||||
cf: ret_style};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum purity {
|
||||
pure_fn, // declared with "pure fn"
|
||||
unsafe_fn, // declared with "unsafe fn"
|
||||
@ -1138,7 +1172,8 @@ impl purity : cmp::Eq {
|
||||
pure fn ne(other: &purity) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum ret_style {
|
||||
noreturn, // functions with return type _|_ that always
|
||||
// raise an error or exit (i.e. never return to the caller)
|
||||
@ -1163,7 +1198,8 @@ impl ret_style : cmp::Eq {
|
||||
pure fn ne(other: &ret_style) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum self_ty_ {
|
||||
sty_static, // no self: static method
|
||||
sty_by_ref, // old by-reference self: ``
|
||||
@ -1217,20 +1253,22 @@ impl self_ty_ : cmp::Eq {
|
||||
pure fn ne(other: &self_ty_) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type self_ty = spanned<self_ty_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type _mod = {view_items: ~[@view_item], items: ~[@item]};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum foreign_abi {
|
||||
foreign_abi_rust_intrinsic,
|
||||
foreign_abi_cdecl,
|
||||
@ -1238,7 +1276,8 @@ enum foreign_abi {
|
||||
}
|
||||
|
||||
// Foreign mods can be named or anonymous
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum foreign_mod_sort { named, anonymous }
|
||||
|
||||
impl foreign_mod_sort : cmp::Eq {
|
||||
@ -1262,39 +1301,48 @@ impl foreign_abi : cmp::Eq {
|
||||
pure fn ne(other: &foreign_abi) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type foreign_mod =
|
||||
{sort: foreign_mod_sort,
|
||||
view_items: ~[@view_item],
|
||||
items: ~[@foreign_item]};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type variant_arg = {ty: @ty, id: node_id};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum variant_kind {
|
||||
tuple_variant_kind(~[variant_arg]),
|
||||
struct_variant_kind(@struct_def),
|
||||
enum_variant_kind(enum_def)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
enum enum_def = { variants: ~[variant], common: Option<@struct_def> };
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type enum_def_ = { variants: ~[variant], common: Option<@struct_def> };
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum enum_def = enum_def_;
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind,
|
||||
id: node_id, disr_expr: Option<@expr>, vis: visibility};
|
||||
|
||||
#[auto_serialize]
|
||||
type variant = spanned<variant_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type path_list_ident_ = {name: ident, id: node_id};
|
||||
|
||||
#[auto_serialize]
|
||||
type path_list_ident = spanned<path_list_ident_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum namespace { module_ns, type_value_ns }
|
||||
|
||||
impl namespace : cmp::Eq {
|
||||
@ -1304,10 +1352,10 @@ impl namespace : cmp::Eq {
|
||||
pure fn ne(other: &namespace) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type view_path = spanned<view_path_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum view_path_ {
|
||||
|
||||
// quux = foo::bar::baz
|
||||
@ -1324,11 +1372,13 @@ enum view_path_ {
|
||||
view_path_list(@path, ~[path_list_ident], node_id)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type view_item = {node: view_item_, attrs: ~[attribute],
|
||||
vis: visibility, span: span};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum view_item_ {
|
||||
view_item_use(ident, ~[@meta_item], node_id),
|
||||
view_item_import(~[@view_path]),
|
||||
@ -1336,13 +1386,13 @@ enum view_item_ {
|
||||
}
|
||||
|
||||
// Meta-data associated with an item
|
||||
#[auto_serialize]
|
||||
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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum attr_style { attr_outer, attr_inner, }
|
||||
|
||||
impl attr_style : cmp::Eq {
|
||||
@ -1353,7 +1403,8 @@ impl attr_style : cmp::Eq {
|
||||
}
|
||||
|
||||
// doc-comments are promoted to attributes that have is_sugared_doc = true
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
|
||||
|
||||
/*
|
||||
@ -1365,10 +1416,12 @@ 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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type trait_ref = {path: @path, ref_id: node_id, impl_id: node_id};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum visibility { public, private, inherited }
|
||||
|
||||
impl visibility : cmp::Eq {
|
||||
@ -1385,23 +1438,25 @@ impl visibility : cmp::Eq {
|
||||
pure fn ne(other: &visibility) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type struct_field_ = {
|
||||
kind: struct_field_kind,
|
||||
id: node_id,
|
||||
ty: @ty
|
||||
};
|
||||
|
||||
#[auto_serialize]
|
||||
type struct_field = spanned<struct_field_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum struct_field_kind {
|
||||
named_field(ident, class_mutability, visibility),
|
||||
unnamed_field // element of a tuple-like struct
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type struct_def = {
|
||||
traits: ~[@trait_ref], /* traits this struct implements */
|
||||
fields: ~[@struct_field], /* fields */
|
||||
@ -1417,12 +1472,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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type item = {ident: ident, attrs: ~[attribute],
|
||||
id: node_id, node: item_,
|
||||
vis: visibility, span: span};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum item_ {
|
||||
item_const(@ty, @expr),
|
||||
item_fn(fn_decl, purity, ~[ty_param], blk),
|
||||
@ -1439,7 +1496,8 @@ enum item_ {
|
||||
item_mac(mac),
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum class_mutability { class_mutable, class_immutable }
|
||||
|
||||
impl class_mutability : to_bytes::IterBytes {
|
||||
@ -1460,26 +1518,27 @@ impl class_mutability : cmp::Eq {
|
||||
pure fn ne(other: &class_mutability) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type class_ctor = spanned<class_ctor_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type class_ctor_ = {id: node_id,
|
||||
attrs: ~[attribute],
|
||||
self_id: node_id,
|
||||
dec: fn_decl,
|
||||
body: blk};
|
||||
|
||||
#[auto_serialize]
|
||||
type class_dtor = spanned<class_dtor_>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type class_dtor_ = {id: node_id,
|
||||
attrs: ~[attribute],
|
||||
self_id: node_id,
|
||||
body: blk};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type foreign_item =
|
||||
{ident: ident,
|
||||
attrs: ~[attribute],
|
||||
@ -1488,7 +1547,8 @@ type foreign_item =
|
||||
span: span,
|
||||
vis: visibility};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum foreign_item_ {
|
||||
foreign_item_fn(fn_decl, purity, ~[ty_param]),
|
||||
foreign_item_const(@ty)
|
||||
@ -1497,7 +1557,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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum inlined_item {
|
||||
ii_item(@item),
|
||||
ii_method(def_id /* impl id */, @method),
|
||||
|
@ -406,7 +406,8 @@ fn dtor_dec() -> fn_decl {
|
||||
// ______________________________________________________________________
|
||||
// Enumerating the IDs which appear in an AST
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type id_range = {min: node_id, max: node_id};
|
||||
|
||||
fn empty(range: id_range) -> bool {
|
||||
|
@ -54,7 +54,7 @@ enum syntax_extension {
|
||||
// macro_defining() is obsolete, remove when #old_macros go away.
|
||||
macro_defining(macro_definer),
|
||||
|
||||
// #[auto_serialize] and such. will probably survive death of #old_macros
|
||||
// #[auto_serialize2] and such. will probably survive death of #old_macros
|
||||
item_decorator(item_decorator),
|
||||
|
||||
// Token-tree expanders
|
||||
|
@ -124,7 +124,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_serialize2]. 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
|
||||
|
@ -1,18 +1,9 @@
|
||||
use util::interner;
|
||||
use util::interner::interner;
|
||||
use std::map::HashMap;
|
||||
use std::serialization::{Serializer,
|
||||
Deserializer,
|
||||
serialize_uint,
|
||||
deserialize_uint,
|
||||
serialize_i64,
|
||||
deserialize_i64,
|
||||
serialize_u64,
|
||||
deserialize_u64,
|
||||
serialize_bool,
|
||||
deserialize_bool};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum binop {
|
||||
PLUS,
|
||||
MINUS,
|
||||
@ -26,7 +17,8 @@ enum binop {
|
||||
SHR,
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum token {
|
||||
/* Expression-operator symbols. */
|
||||
EQ,
|
||||
@ -83,7 +75,8 @@ enum token {
|
||||
EOF,
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
/// For interpolation during macro expansion.
|
||||
enum nonterminal {
|
||||
nt_item(@ast::item),
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Searching for information from the cstore
|
||||
|
||||
use std::{ebml};
|
||||
use std::ebml2;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util;
|
||||
use syntax::ast_map;
|
||||
@ -136,7 +136,7 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
|
||||
def: ast::def_id) -> ty::ty_param_bounds_and_ty {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, class_id.crate);
|
||||
let all_items = ebml::get_doc(ebml::Doc(cdata.data), tag_items);
|
||||
let all_items = ebml2::get_doc(ebml2::Doc(cdata.data), tag_items);
|
||||
debug!("Looking up %?", class_id);
|
||||
let class_doc = expect(tcx.diag,
|
||||
decoder::maybe_find_item(class_id.node, all_items),
|
||||
|
@ -1,7 +1,8 @@
|
||||
// Decoding metadata from a single crate's metadata
|
||||
|
||||
use std::{ebml, map};
|
||||
use std::{ebml2, map};
|
||||
use std::map::HashMap;
|
||||
use std::serialization2::deserialize;
|
||||
use io::WriterUtil;
|
||||
use dvec::DVec;
|
||||
use syntax::{ast, ast_util};
|
||||
@ -63,25 +64,25 @@ export translate_def_id;
|
||||
// what crate that's in and give us a def_id that makes sense for the current
|
||||
// build.
|
||||
|
||||
fn lookup_hash(d: ebml::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
Option<ebml::Doc> {
|
||||
let index = ebml::get_doc(d, tag_index);
|
||||
let table = ebml::get_doc(index, tag_index_table);
|
||||
fn lookup_hash(d: ebml2::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
Option<ebml2::Doc> {
|
||||
let index = ebml2::get_doc(d, tag_index);
|
||||
let table = ebml2::get_doc(index, tag_index_table);
|
||||
let hash_pos = table.start + hash % 256u * 4u;
|
||||
let pos = io::u64_from_be_bytes(*d.data, hash_pos, 4u) as uint;
|
||||
let {tag:_, doc:bucket} = ebml::doc_at(d.data, pos);
|
||||
let tagged_doc = ebml2::doc_at(d.data, pos);
|
||||
|
||||
let belt = tag_index_buckets_bucket_elt;
|
||||
for ebml::tagged_docs(bucket, belt) |elt| {
|
||||
for ebml2::tagged_docs(tagged_doc.doc, belt) |elt| {
|
||||
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
|
||||
if eq_fn(vec::view(*elt.data, elt.start + 4u, elt.end)) {
|
||||
return Some(ebml::doc_at(d.data, pos).doc);
|
||||
return Some(ebml2::doc_at(d.data, pos).doc);
|
||||
}
|
||||
};
|
||||
None
|
||||
}
|
||||
|
||||
fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
fn maybe_find_item(item_id: int, items: ebml2::Doc) -> Option<ebml2::Doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||
return io::u64_from_be_bytes(vec::view(bytes, 0u, 4u), 0u, 4u) as int
|
||||
== item_id;
|
||||
@ -91,14 +92,14 @@ fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
item_id.hash() as uint)
|
||||
}
|
||||
|
||||
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
|
||||
fn find_item(item_id: int, items: ebml2::Doc) -> ebml2::Doc {
|
||||
return maybe_find_item(item_id, items).get();
|
||||
}
|
||||
|
||||
// Looks up an item in the given metadata and returns an ebml doc pointing
|
||||
// Looks up an item in the given metadata and returns an ebml2 doc pointing
|
||||
// to the item data.
|
||||
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
|
||||
let items = ebml::get_doc(ebml::Doc(data), tag_items);
|
||||
fn lookup_item(item_id: int, data: @~[u8]) -> ebml2::Doc {
|
||||
let items = ebml2::get_doc(ebml2::Doc(data), tag_items);
|
||||
match maybe_find_item(item_id, items) {
|
||||
None => fail(fmt!("lookup_item: id not found: %d", item_id)),
|
||||
Some(d) => d
|
||||
@ -136,9 +137,9 @@ impl Family : cmp::Eq {
|
||||
pure fn ne(other: &Family) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
fn item_family(item: ebml::Doc) -> Family {
|
||||
let fam = ebml::get_doc(item, tag_items_data_item_family);
|
||||
match ebml::doc_as_u8(fam) as char {
|
||||
fn item_family(item: ebml2::Doc) -> Family {
|
||||
let fam = ebml2::get_doc(item, tag_items_data_item_family);
|
||||
match ebml2::doc_as_u8(fam) as char {
|
||||
'c' => Const,
|
||||
'f' => Fn,
|
||||
'u' => UnsafeFn,
|
||||
@ -164,59 +165,59 @@ fn item_family(item: ebml::Doc) -> Family {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_symbol(item: ebml::Doc) -> ~str {
|
||||
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
||||
return str::from_bytes(ebml::doc_data(sym));
|
||||
fn item_symbol(item: ebml2::Doc) -> ~str {
|
||||
let sym = ebml2::get_doc(item, tag_items_data_item_symbol);
|
||||
return str::from_bytes(ebml2::doc_data(sym));
|
||||
}
|
||||
|
||||
fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
|
||||
for ebml::tagged_docs(d, tag_items_data_parent_item) |did| {
|
||||
return Some(ebml::with_doc_data(did, |d| parse_def_id(d)));
|
||||
fn item_parent_item(d: ebml2::Doc) -> Option<ast::def_id> {
|
||||
for ebml2::tagged_docs(d, tag_items_data_parent_item) |did| {
|
||||
return Some(ebml2::with_doc_data(did, |d| parse_def_id(d)));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id {
|
||||
let tagdoc = ebml::get_doc(d, tag_def_id);
|
||||
return translate_def_id(cdata, ebml::with_doc_data(tagdoc,
|
||||
fn item_def_id(d: ebml2::Doc, cdata: cmd) -> ast::def_id {
|
||||
let tagdoc = ebml2::get_doc(d, tag_def_id);
|
||||
return translate_def_id(cdata, ebml2::with_doc_data(tagdoc,
|
||||
|d| parse_def_id(d)));
|
||||
}
|
||||
|
||||
fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) {
|
||||
for ebml::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| {
|
||||
fn each_reexport(d: ebml2::Doc, f: fn(ebml2::Doc) -> bool) {
|
||||
for ebml2::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| {
|
||||
if !f(reexport_doc) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn field_mutability(d: ebml::Doc) -> ast::class_mutability {
|
||||
fn field_mutability(d: ebml2::Doc) -> ast::class_mutability {
|
||||
// Use maybe_get_doc in case it's a method
|
||||
option::map_default(
|
||||
&ebml::maybe_get_doc(d, tag_class_mut),
|
||||
&ebml2::maybe_get_doc(d, tag_class_mut),
|
||||
ast::class_immutable,
|
||||
|d| {
|
||||
match ebml::doc_as_u8(*d) as char {
|
||||
match ebml2::doc_as_u8(*d) as char {
|
||||
'm' => ast::class_mutable,
|
||||
_ => ast::class_immutable
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn variant_disr_val(d: ebml::Doc) -> Option<int> {
|
||||
do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
|
||||
int::parse_bytes(ebml::doc_data(val_doc), 10u)
|
||||
fn variant_disr_val(d: ebml2::Doc) -> Option<int> {
|
||||
do option::chain(ebml2::maybe_get_doc(d, tag_disr_val)) |val_doc| {
|
||||
int::parse_bytes(ebml2::doc_data(val_doc), 10u)
|
||||
}
|
||||
}
|
||||
|
||||
fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let tp = ebml::get_doc(doc, tag_items_data_item_type);
|
||||
fn doc_type(doc: ebml2::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let tp = ebml2::get_doc(doc, tag_items_data_item_type);
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx, |did| {
|
||||
translate_def_id(cdata, did)
|
||||
})
|
||||
}
|
||||
|
||||
fn item_type(item_id: ast::def_id, item: ebml::Doc,
|
||||
fn item_type(item_id: ast::def_id, item: ebml2::Doc,
|
||||
tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let t = doc_type(item, tcx, cdata);
|
||||
if family_names_type(item_family(item)) {
|
||||
@ -224,18 +225,18 @@ fn item_type(item_id: ast::def_id, item: ebml::Doc,
|
||||
} else { t }
|
||||
}
|
||||
|
||||
fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] {
|
||||
fn item_impl_traits(item: ebml2::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] {
|
||||
let mut results = ~[];
|
||||
for ebml::tagged_docs(item, tag_impl_trait) |ity| {
|
||||
for ebml2::tagged_docs(item, tag_impl_trait) |ity| {
|
||||
results.push(doc_type(ity, tcx, cdata));
|
||||
};
|
||||
results
|
||||
}
|
||||
|
||||
fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd)
|
||||
fn item_ty_param_bounds(item: ebml2::Doc, tcx: ty::ctxt, cdata: cmd)
|
||||
-> @~[ty::param_bounds] {
|
||||
let mut bounds = ~[];
|
||||
for ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) |p| {
|
||||
for ebml2::tagged_docs(item, tag_items_data_item_ty_param_bounds) |p| {
|
||||
let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, |did| {
|
||||
translate_def_id(cdata, did)
|
||||
});
|
||||
@ -244,43 +245,42 @@ fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd)
|
||||
@bounds
|
||||
}
|
||||
|
||||
fn item_ty_region_param(item: ebml::Doc) -> Option<ty::region_variance> {
|
||||
ebml::maybe_get_doc(item, tag_region_param).map(|doc| {
|
||||
let d = ebml::ebml_deserializer(*doc);
|
||||
ty::deserialize_region_variance(d)
|
||||
fn item_ty_region_param(item: ebml2::Doc) -> Option<ty::region_variance> {
|
||||
ebml2::maybe_get_doc(item, tag_region_param).map(|doc| {
|
||||
deserialize(&ebml2::Deserializer(*doc))
|
||||
})
|
||||
}
|
||||
|
||||
fn item_ty_param_count(item: ebml::Doc) -> uint {
|
||||
fn item_ty_param_count(item: ebml2::Doc) -> uint {
|
||||
let mut n = 0u;
|
||||
ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds,
|
||||
ebml2::tagged_docs(item, tag_items_data_item_ty_param_bounds,
|
||||
|_p| { n += 1u; true } );
|
||||
n
|
||||
}
|
||||
|
||||
fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
fn enum_variant_ids(item: ebml2::Doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
let mut ids: ~[ast::def_id] = ~[];
|
||||
let v = tag_items_data_item_variant;
|
||||
for ebml::tagged_docs(item, v) |p| {
|
||||
let ext = ebml::with_doc_data(p, |d| parse_def_id(d));
|
||||
for ebml2::tagged_docs(item, v) |p| {
|
||||
let ext = ebml2::with_doc_data(p, |d| parse_def_id(d));
|
||||
ids.push({crate: cdata.cnum, node: ext.node});
|
||||
};
|
||||
return ids;
|
||||
}
|
||||
|
||||
fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path {
|
||||
let path_doc = ebml::get_doc(item_doc, tag_path);
|
||||
fn item_path(intr: @ident_interner, item_doc: ebml2::Doc) -> ast_map::path {
|
||||
let path_doc = ebml2::get_doc(item_doc, tag_path);
|
||||
|
||||
let len_doc = ebml::get_doc(path_doc, tag_path_len);
|
||||
let len = ebml::doc_as_u32(len_doc) as uint;
|
||||
let len_doc = ebml2::get_doc(path_doc, tag_path_len);
|
||||
let len = ebml2::doc_as_u32(len_doc) as uint;
|
||||
|
||||
let mut result = vec::with_capacity(len);
|
||||
for ebml::docs(path_doc) |tag, elt_doc| {
|
||||
for ebml2::docs(path_doc) |tag, elt_doc| {
|
||||
if tag == tag_path_elt_mod {
|
||||
let str = ebml::doc_as_str(elt_doc);
|
||||
let str = ebml2::doc_as_str(elt_doc);
|
||||
result.push(ast_map::path_mod(intr.intern(@str)));
|
||||
} else if tag == tag_path_elt_name {
|
||||
let str = ebml::doc_as_str(elt_doc);
|
||||
let str = ebml2::doc_as_str(elt_doc);
|
||||
result.push(ast_map::path_name(intr.intern(@str)));
|
||||
} else {
|
||||
// ignore tag_path_len element
|
||||
@ -290,12 +290,12 @@ fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path {
|
||||
return result;
|
||||
}
|
||||
|
||||
fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident {
|
||||
let name = ebml::get_doc(item, tag_paths_data_name);
|
||||
intr.intern(@str::from_bytes(ebml::doc_data(name)))
|
||||
fn item_name(intr: @ident_interner, item: ebml2::Doc) -> ast::ident {
|
||||
let name = ebml2::get_doc(item, tag_paths_data_name);
|
||||
intr.intern(@str::from_bytes(ebml2::doc_data(name)))
|
||||
}
|
||||
|
||||
fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
fn item_to_def_like(item: ebml2::Doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
-> def_like {
|
||||
let fam = item_family(item);
|
||||
match fam {
|
||||
@ -367,10 +367,10 @@ fn get_impl_traits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::t] {
|
||||
|
||||
fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
name: ast::ident) -> ast::def_id {
|
||||
let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items);
|
||||
let items = ebml2::get_doc(ebml2::Doc(cdata.data), tag_items);
|
||||
let mut found = None;
|
||||
for ebml::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| {
|
||||
let m_did = ebml::with_doc_data(mid, |d| parse_def_id(d));
|
||||
for ebml2::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| {
|
||||
let m_did = ebml2::with_doc_data(mid, |d| parse_def_id(d));
|
||||
if item_name(intr, find_item(m_did.node, items)) == name {
|
||||
found = Some(translate_def_id(cdata, m_did));
|
||||
}
|
||||
@ -380,14 +380,14 @@ fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
|
||||
fn get_class_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
name: ast::ident) -> ast::def_id {
|
||||
let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items);
|
||||
let items = ebml2::get_doc(ebml2::Doc(cdata.data), tag_items);
|
||||
let mut found = None;
|
||||
let cls_items = match maybe_find_item(id, items) {
|
||||
Some(it) => it,
|
||||
None => fail (fmt!("get_class_method: class id not found \
|
||||
when looking up method %s", *intr.get(name)))
|
||||
};
|
||||
for ebml::tagged_docs(cls_items, tag_item_trait_method) |mid| {
|
||||
for ebml2::tagged_docs(cls_items, tag_item_trait_method) |mid| {
|
||||
let m_did = item_def_id(mid, cdata);
|
||||
if item_name(intr, mid) == name {
|
||||
found = Some(m_did);
|
||||
@ -401,16 +401,16 @@ fn get_class_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
}
|
||||
|
||||
fn class_dtor(cdata: cmd, id: ast::node_id) -> Option<ast::def_id> {
|
||||
let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items);
|
||||
let items = ebml2::get_doc(ebml2::Doc(cdata.data), tag_items);
|
||||
let mut found = None;
|
||||
let cls_items = match maybe_find_item(id, items) {
|
||||
Some(it) => it,
|
||||
None => fail (fmt!("class_dtor: class id not found \
|
||||
when looking up dtor for %d", id))
|
||||
};
|
||||
for ebml::tagged_docs(cls_items, tag_item_dtor) |doc| {
|
||||
let doc1 = ebml::get_doc(doc, tag_def_id);
|
||||
let did = ebml::with_doc_data(doc1, |d| parse_def_id(d));
|
||||
for ebml2::tagged_docs(cls_items, tag_item_dtor) |doc| {
|
||||
let doc1 = ebml2::get_doc(doc, tag_def_id);
|
||||
let did = ebml2::with_doc_data(doc1, |d| parse_def_id(d));
|
||||
found = Some(translate_def_id(cdata, did));
|
||||
};
|
||||
found
|
||||
@ -452,14 +452,14 @@ fn path_entry(path_string: ~str, def_like: def_like) -> path_entry {
|
||||
|
||||
/// Iterates over all the paths in the given crate.
|
||||
fn each_path(intr: @ident_interner, cdata: cmd, f: fn(path_entry) -> bool) {
|
||||
let root = ebml::Doc(cdata.data);
|
||||
let items = ebml::get_doc(root, tag_items);
|
||||
let items_data = ebml::get_doc(items, tag_items_data);
|
||||
let root = ebml2::Doc(cdata.data);
|
||||
let items = ebml2::get_doc(root, tag_items);
|
||||
let items_data = ebml2::get_doc(items, tag_items_data);
|
||||
|
||||
let mut broken = false;
|
||||
|
||||
// First, go through all the explicit items.
|
||||
for ebml::tagged_docs(items_data, tag_items_data_item) |item_doc| {
|
||||
for ebml2::tagged_docs(items_data, tag_items_data_item) |item_doc| {
|
||||
if !broken {
|
||||
let path = ast_map::path_to_str_with_sep(
|
||||
item_path(intr, item_doc), ~"::", intr);
|
||||
@ -482,16 +482,16 @@ fn each_path(intr: @ident_interner, cdata: cmd, f: fn(path_entry) -> bool) {
|
||||
for each_reexport(item_doc) |reexport_doc| {
|
||||
if !broken {
|
||||
let def_id_doc =
|
||||
ebml::get_doc(reexport_doc,
|
||||
ebml2::get_doc(reexport_doc,
|
||||
tag_items_data_item_reexport_def_id);
|
||||
let def_id =
|
||||
ebml::with_doc_data(def_id_doc, |d| parse_def_id(d));
|
||||
ebml2::with_doc_data(def_id_doc, |d| parse_def_id(d));
|
||||
let def_id = translate_def_id(cdata, def_id);
|
||||
|
||||
let reexport_name_doc =
|
||||
ebml::get_doc(reexport_doc,
|
||||
ebml2::get_doc(reexport_doc,
|
||||
tag_items_data_item_reexport_name);
|
||||
let reexport_name = ebml::doc_as_str(reexport_name_doc);
|
||||
let reexport_name = ebml2::doc_as_str(reexport_name_doc);
|
||||
|
||||
let reexport_path;
|
||||
if path == ~"" {
|
||||
@ -540,7 +540,7 @@ type decode_inlined_item = fn(
|
||||
cdata: cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
path: ast_map::path,
|
||||
par_doc: ebml::Doc) -> Option<ast::inlined_item>;
|
||||
par_doc: ebml2::Doc) -> Option<ast::inlined_item>;
|
||||
|
||||
fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
|
||||
id: ast::node_id,
|
||||
@ -571,7 +571,7 @@ fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
|
||||
fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
tcx: ty::ctxt) -> ~[ty::variant_info] {
|
||||
let data = cdata.data;
|
||||
let items = ebml::get_doc(ebml::Doc(data), tag_items);
|
||||
let items = ebml2::get_doc(ebml2::Doc(data), tag_items);
|
||||
let item = find_item(id, items);
|
||||
let mut infos: ~[ty::variant_info] = ~[];
|
||||
let variant_ids = enum_variant_ids(item, cdata);
|
||||
@ -609,7 +609,7 @@ type method_info = {
|
||||
|
||||
type _impl = {did: ast::def_id, ident: ast::ident, methods: ~[@method_info]};
|
||||
|
||||
fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
|
||||
fn get_self_ty(item: ebml2::Doc) -> ast::self_ty_ {
|
||||
fn get_mutability(ch: u8) -> ast::mutability {
|
||||
match ch as char {
|
||||
'i' => { ast::m_imm }
|
||||
@ -621,8 +621,8 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
|
||||
}
|
||||
}
|
||||
|
||||
let self_type_doc = ebml::get_doc(item, tag_item_trait_method_self_ty);
|
||||
let string = ebml::doc_as_str(self_type_doc);
|
||||
let self_type_doc = ebml2::get_doc(item, tag_item_trait_method_self_ty);
|
||||
let string = ebml2::doc_as_str(self_type_doc);
|
||||
|
||||
let self_ty_kind = string[0];
|
||||
match self_ty_kind as char {
|
||||
@ -638,11 +638,11 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc,
|
||||
fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml2::Doc,
|
||||
base_tps: uint) -> ~[@method_info] {
|
||||
let mut rslt = ~[];
|
||||
for ebml::tagged_docs(item, tag_item_impl_method) |doc| {
|
||||
let m_did = ebml::with_doc_data(doc, |d| parse_def_id(d));
|
||||
for ebml2::tagged_docs(item, tag_item_impl_method) |doc| {
|
||||
let m_did = ebml2::with_doc_data(doc, |d| parse_def_id(d));
|
||||
let mth_item = lookup_item(m_did.node, cdata.data);
|
||||
let self_ty = get_self_ty(mth_item);
|
||||
rslt.push(@{did: translate_def_id(cdata, m_did),
|
||||
@ -662,8 +662,8 @@ fn get_impls_for_mod(intr: @ident_interner, cdata: cmd,
|
||||
let data = cdata.data;
|
||||
let mod_item = lookup_item(m_id, data);
|
||||
let mut result = ~[];
|
||||
for ebml::tagged_docs(mod_item, tag_mod_impl) |doc| {
|
||||
let did = ebml::with_doc_data(doc, |d| parse_def_id(d));
|
||||
for ebml2::tagged_docs(mod_item, tag_mod_impl) |doc| {
|
||||
let did = ebml2::with_doc_data(doc, |d| parse_def_id(d));
|
||||
let local_did = translate_def_id(cdata, did);
|
||||
debug!("(get impls for mod) getting did %? for '%?'",
|
||||
local_did, name);
|
||||
@ -690,7 +690,7 @@ fn get_trait_methods(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
let data = cdata.data;
|
||||
let item = lookup_item(id, data);
|
||||
let mut result = ~[];
|
||||
for ebml::tagged_docs(item, tag_item_trait_method) |mth| {
|
||||
for ebml2::tagged_docs(item, tag_item_trait_method) |mth| {
|
||||
let bounds = item_ty_param_bounds(mth, tcx, cdata);
|
||||
let name = item_name(intr, mth);
|
||||
let ty = doc_type(mth, tcx, cdata);
|
||||
@ -722,7 +722,7 @@ fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd,
|
||||
}
|
||||
|
||||
let resulting_methods = @DVec();
|
||||
for ebml::tagged_docs(item, tag_item_trait_method) |method| {
|
||||
for ebml2::tagged_docs(item, tag_item_trait_method) |method| {
|
||||
resulting_methods.push(
|
||||
(item_name(intr, method), get_self_ty(method)));
|
||||
}
|
||||
@ -734,8 +734,8 @@ fn get_item_attrs(cdata: cmd,
|
||||
f: fn(~[@ast::meta_item])) {
|
||||
|
||||
let item = lookup_item(node_id, cdata.data);
|
||||
for ebml::tagged_docs(item, tag_attributes) |attributes| {
|
||||
for ebml::tagged_docs(attributes, tag_attribute) |attribute| {
|
||||
for ebml2::tagged_docs(item, tag_attributes) |attributes| {
|
||||
for ebml2::tagged_docs(attributes, tag_attribute) |attribute| {
|
||||
f(get_meta_items(attribute));
|
||||
}
|
||||
}
|
||||
@ -747,7 +747,7 @@ fn get_class_members(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
let data = cdata.data;
|
||||
let item = lookup_item(id, data);
|
||||
let mut result = ~[];
|
||||
for ebml::tagged_docs(item, tag_item_field) |an_item| {
|
||||
for ebml2::tagged_docs(item, tag_item_field) |an_item| {
|
||||
let f = item_family(an_item);
|
||||
if p(f) {
|
||||
let name = item_name(intr, an_item);
|
||||
@ -787,15 +787,15 @@ fn family_names_type(fam: Family) -> bool {
|
||||
match fam { Type | Mod | Trait => true, _ => false }
|
||||
}
|
||||
|
||||
fn read_path(d: ebml::Doc) -> {path: ~str, pos: uint} {
|
||||
let desc = ebml::doc_data(d);
|
||||
fn read_path(d: ebml2::Doc) -> {path: ~str, pos: uint} {
|
||||
let desc = ebml2::doc_data(d);
|
||||
let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint;
|
||||
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
||||
let path = str::from_bytes(pathbytes);
|
||||
return {path: path, pos: pos};
|
||||
}
|
||||
|
||||
fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str {
|
||||
fn describe_def(items: ebml2::Doc, id: ast::def_id) -> ~str {
|
||||
if id.crate != ast::local_crate { return ~"external"; }
|
||||
let it = match maybe_find_item(id.node, items) {
|
||||
Some(it) => it,
|
||||
@ -830,36 +830,36 @@ fn item_family_to_str(fam: Family) -> ~str {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] {
|
||||
fn get_meta_items(md: ebml2::Doc) -> ~[@ast::meta_item] {
|
||||
let mut items: ~[@ast::meta_item] = ~[];
|
||||
for ebml::tagged_docs(md, tag_meta_item_word) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let n = str::from_bytes(ebml::doc_data(nd));
|
||||
for ebml2::tagged_docs(md, tag_meta_item_word) |meta_item_doc| {
|
||||
let nd = ebml2::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let n = str::from_bytes(ebml2::doc_data(nd));
|
||||
items.push(attr::mk_word_item(n));
|
||||
};
|
||||
for ebml::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
|
||||
let n = str::from_bytes(ebml::doc_data(nd));
|
||||
let v = str::from_bytes(ebml::doc_data(vd));
|
||||
for ebml2::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| {
|
||||
let nd = ebml2::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let vd = ebml2::get_doc(meta_item_doc, tag_meta_item_value);
|
||||
let n = str::from_bytes(ebml2::doc_data(nd));
|
||||
let v = str::from_bytes(ebml2::doc_data(vd));
|
||||
// FIXME (#623): Should be able to decode meta_name_value variants,
|
||||
// but currently the encoder just drops them
|
||||
items.push(attr::mk_name_value_item_str(n, v));
|
||||
};
|
||||
for ebml::tagged_docs(md, tag_meta_item_list) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let n = str::from_bytes(ebml::doc_data(nd));
|
||||
for ebml2::tagged_docs(md, tag_meta_item_list) |meta_item_doc| {
|
||||
let nd = ebml2::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let n = str::from_bytes(ebml2::doc_data(nd));
|
||||
let subitems = get_meta_items(meta_item_doc);
|
||||
items.push(attr::mk_list_item(n, subitems));
|
||||
};
|
||||
return items;
|
||||
}
|
||||
|
||||
fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
|
||||
fn get_attributes(md: ebml2::Doc) -> ~[ast::attribute] {
|
||||
let mut attrs: ~[ast::attribute] = ~[];
|
||||
match ebml::maybe_get_doc(md, tag_attributes) {
|
||||
match ebml2::maybe_get_doc(md, tag_attributes) {
|
||||
option::Some(attrs_d) => {
|
||||
for ebml::tagged_docs(attrs_d, tag_attribute) |attr_doc| {
|
||||
for ebml2::tagged_docs(attrs_d, tag_attribute) |attr_doc| {
|
||||
let meta_items = get_meta_items(attr_doc);
|
||||
// Currently it's only possible to have a single meta item on
|
||||
// an attribute
|
||||
@ -877,13 +877,13 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
|
||||
}
|
||||
|
||||
fn list_meta_items(intr: @ident_interner,
|
||||
meta_items: ebml::Doc, out: io::Writer) {
|
||||
meta_items: ebml2::Doc, out: io::Writer) {
|
||||
for get_meta_items(meta_items).each |mi| {
|
||||
out.write_str(fmt!("%s\n", pprust::meta_item_to_str(*mi, intr)));
|
||||
}
|
||||
}
|
||||
|
||||
fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: ~str,
|
||||
fn list_crate_attributes(intr: @ident_interner, md: ebml2::Doc, hash: ~str,
|
||||
out: io::Writer) {
|
||||
out.write_str(fmt!("=Crate Attributes (%s)=\n", hash));
|
||||
|
||||
@ -895,7 +895,7 @@ fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: ~str,
|
||||
}
|
||||
|
||||
fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] {
|
||||
return get_attributes(ebml::Doc(data));
|
||||
return get_attributes(ebml2::Doc(data));
|
||||
}
|
||||
|
||||
type crate_dep = {cnum: ast::crate_num, name: ast::ident,
|
||||
@ -903,13 +903,13 @@ type crate_dep = {cnum: ast::crate_num, name: ast::ident,
|
||||
|
||||
fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] {
|
||||
let mut deps: ~[crate_dep] = ~[];
|
||||
let cratedoc = ebml::Doc(data);
|
||||
let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps);
|
||||
let cratedoc = ebml2::Doc(data);
|
||||
let depsdoc = ebml2::get_doc(cratedoc, tag_crate_deps);
|
||||
let mut crate_num = 1;
|
||||
fn docstr(doc: ebml::Doc, tag_: uint) -> ~str {
|
||||
str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_)))
|
||||
fn docstr(doc: ebml2::Doc, tag_: uint) -> ~str {
|
||||
str::from_bytes(ebml2::doc_data(ebml2::get_doc(doc, tag_)))
|
||||
}
|
||||
for ebml::tagged_docs(depsdoc, tag_crate_dep) |depdoc| {
|
||||
for ebml2::tagged_docs(depsdoc, tag_crate_dep) |depdoc| {
|
||||
deps.push({cnum: crate_num,
|
||||
name: intr.intern(@docstr(depdoc, tag_crate_dep_name)),
|
||||
vers: docstr(depdoc, tag_crate_dep_vers),
|
||||
@ -932,9 +932,9 @@ fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: io::Writer) {
|
||||
}
|
||||
|
||||
fn get_crate_hash(data: @~[u8]) -> ~str {
|
||||
let cratedoc = ebml::Doc(data);
|
||||
let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash);
|
||||
return str::from_bytes(ebml::doc_data(hashdoc));
|
||||
let cratedoc = ebml2::Doc(data);
|
||||
let hashdoc = ebml2::get_doc(cratedoc, tag_crate_hash);
|
||||
return str::from_bytes(ebml2::doc_data(hashdoc));
|
||||
}
|
||||
|
||||
fn get_crate_vers(data: @~[u8]) -> ~str {
|
||||
@ -988,7 +988,7 @@ fn get_crate_module_paths(intr: @ident_interner, cdata: cmd)
|
||||
fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8],
|
||||
out: io::Writer) {
|
||||
let hash = get_crate_hash(bytes);
|
||||
let md = ebml::Doc(bytes);
|
||||
let md = ebml2::Doc(bytes);
|
||||
list_crate_attributes(intr, md, hash, out);
|
||||
list_crate_deps(intr, bytes, out);
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use std::{ebml, map};
|
||||
use std::{ebml2, map};
|
||||
use std::map::HashMap;
|
||||
use io::WriterUtil;
|
||||
use ebml::Writer;
|
||||
use ebml2::Serializer;
|
||||
use syntax::ast::*;
|
||||
use syntax::print::pprust;
|
||||
use syntax::{ast_util, visit};
|
||||
@ -40,7 +40,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: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
path: ast_map::path,
|
||||
ii: ast::inlined_item);
|
||||
|
||||
@ -86,25 +86,25 @@ fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
|
||||
ecx.reachable.contains_key(id)
|
||||
}
|
||||
|
||||
fn encode_name(ecx: @encode_ctxt, ebml_w: ebml::Writer, name: ident) {
|
||||
fn encode_name(ecx: @encode_ctxt, ebml_w: ebml2::Serializer, name: ident) {
|
||||
ebml_w.wr_tagged_str(tag_paths_data_name, ecx.tcx.sess.str_of(name));
|
||||
}
|
||||
|
||||
fn encode_def_id(ebml_w: ebml::Writer, id: def_id) {
|
||||
fn encode_def_id(ebml_w: ebml2::Serializer, id: def_id) {
|
||||
ebml_w.wr_tagged_str(tag_def_id, def_to_str(id));
|
||||
}
|
||||
|
||||
fn encode_region_param(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_region_param(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
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) {
|
||||
ty::serialize_region_variance(ebml_w, *rp);
|
||||
(*rp).serialize(&ebml_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
|
||||
fn encode_mutability(ebml_w: ebml2::Serializer, mt: class_mutability) {
|
||||
do ebml_w.wr_tag(tag_class_mut) {
|
||||
let val = match mt {
|
||||
class_immutable => 'a',
|
||||
@ -116,7 +116,7 @@ fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
|
||||
|
||||
type entry<T> = {val: T, pos: uint};
|
||||
|
||||
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
|
||||
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml2::Serializer, path: &[ident],
|
||||
index: &mut ~[entry<~str>], name: ident) {
|
||||
let mut full_path = ~[];
|
||||
full_path.push_all(path);
|
||||
@ -127,7 +127,8 @@ fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
|
||||
pos: ebml_w.writer.tell()});
|
||||
}
|
||||
|
||||
fn encode_trait_ref(ebml_w: ebml::Writer, ecx: @encode_ctxt, t: @trait_ref) {
|
||||
fn encode_trait_ref(ebml_w: ebml2::Serializer, ecx: @encode_ctxt,
|
||||
t: @trait_ref) {
|
||||
ebml_w.start_tag(tag_impl_trait);
|
||||
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, t.ref_id));
|
||||
ebml_w.end_tag();
|
||||
@ -135,7 +136,7 @@ fn encode_trait_ref(ebml_w: ebml::Writer, ecx: @encode_ctxt, t: @trait_ref) {
|
||||
|
||||
|
||||
// Item info table encoding
|
||||
fn encode_family(ebml_w: ebml::Writer, c: char) {
|
||||
fn encode_family(ebml_w: ebml2::Serializer, c: char) {
|
||||
ebml_w.start_tag(tag_items_data_item_family);
|
||||
ebml_w.writer.write(&[c as u8]);
|
||||
ebml_w.end_tag();
|
||||
@ -143,7 +144,7 @@ fn encode_family(ebml_w: ebml::Writer, 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: ebml::Writer, ecx: @encode_ctxt,
|
||||
fn encode_ty_type_param_bounds(ebml_w: ebml2::Serializer, ecx: @encode_ctxt,
|
||||
params: @~[ty::param_bounds]) {
|
||||
let ty_str_ctxt = @{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
@ -157,7 +158,7 @@ fn encode_ty_type_param_bounds(ebml_w: ebml::Writer, ecx: @encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_type_param_bounds(ebml_w: ebml::Writer, ecx: @encode_ctxt,
|
||||
fn encode_type_param_bounds(ebml_w: ebml2::Serializer, ecx: @encode_ctxt,
|
||||
params: ~[ty_param]) {
|
||||
let ty_param_bounds =
|
||||
@params.map(|param| ecx.tcx.ty_param_bounds.get(param.id));
|
||||
@ -165,13 +166,13 @@ fn encode_type_param_bounds(ebml_w: ebml::Writer, ecx: @encode_ctxt,
|
||||
}
|
||||
|
||||
|
||||
fn encode_variant_id(ebml_w: ebml::Writer, vid: def_id) {
|
||||
fn encode_variant_id(ebml_w: ebml2::Serializer, vid: def_id) {
|
||||
ebml_w.start_tag(tag_items_data_item_variant);
|
||||
ebml_w.writer.write(str::to_bytes(def_to_str(vid)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn write_type(ecx: @encode_ctxt, ebml_w: ebml::Writer, typ: ty::t) {
|
||||
fn write_type(ecx: @encode_ctxt, ebml_w: ebml2::Serializer, typ: ty::t) {
|
||||
let ty_str_ctxt =
|
||||
@{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
@ -181,7 +182,8 @@ fn write_type(ecx: @encode_ctxt, ebml_w: ebml::Writer, typ: ty::t) {
|
||||
tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ);
|
||||
}
|
||||
|
||||
fn write_vstore(ecx: @encode_ctxt, ebml_w: ebml::Writer, vstore: ty::vstore) {
|
||||
fn write_vstore(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
vstore: ty::vstore) {
|
||||
let ty_str_ctxt =
|
||||
@{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
@ -191,13 +193,13 @@ fn write_vstore(ecx: @encode_ctxt, ebml_w: ebml::Writer, vstore: ty::vstore) {
|
||||
tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore);
|
||||
}
|
||||
|
||||
fn encode_type(ecx: @encode_ctxt, ebml_w: ebml::Writer, typ: ty::t) {
|
||||
fn encode_type(ecx: @encode_ctxt, ebml_w: ebml2::Serializer, typ: ty::t) {
|
||||
ebml_w.start_tag(tag_items_data_item_type);
|
||||
write_type(ecx, ebml_w, typ);
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::Writer, id: node_id) {
|
||||
fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml2::Serializer, id: node_id) {
|
||||
ebml_w.start_tag(tag_items_data_item_symbol);
|
||||
let sym = match ecx.item_symbols.find(id) {
|
||||
Some(x) => x,
|
||||
@ -210,25 +212,27 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::Writer, id: node_id) {
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_discriminant(ecx: @encode_ctxt, ebml_w: ebml::Writer, id: node_id) {
|
||||
fn encode_discriminant(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
id: node_id) {
|
||||
ebml_w.start_tag(tag_items_data_item_symbol);
|
||||
ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(id)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: ebml::Writer, disr_val: int) {
|
||||
fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
disr_val: int) {
|
||||
ebml_w.start_tag(tag_disr_val);
|
||||
ebml_w.writer.write(str::to_bytes(int::to_str(disr_val,10u)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_parent_item(ebml_w: ebml::Writer, id: def_id) {
|
||||
fn encode_parent_item(ebml_w: ebml2::Serializer, id: def_id) {
|
||||
ebml_w.start_tag(tag_items_data_parent_item);
|
||||
ebml_w.writer.write(str::to_bytes(def_to_str(id)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
id: node_id, variants: ~[variant],
|
||||
path: ast_map::path, index: @mut ~[entry<int>],
|
||||
ty_params: ~[ty_param]) {
|
||||
@ -265,9 +269,9 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: ast_map::path,
|
||||
name: ast_map::path_elt) {
|
||||
fn encode_path_elt(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_path(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
path: ast_map::path, name: ast_map::path_elt) {
|
||||
fn encode_path_elt(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
elt: ast_map::path_elt) {
|
||||
let (tag, name) = match elt {
|
||||
ast_map::path_mod(name) => (tag_path_elt_mod, name),
|
||||
@ -286,7 +290,7 @@ fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: ast_map::path,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::Writer, md: _mod,
|
||||
fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml2::Serializer, md: _mod,
|
||||
id: node_id, path: ast_map::path, name: ident) {
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(id));
|
||||
@ -344,7 +348,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::Writer, md: _mod,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_visibility(ebml_w: ebml::Writer, visibility: visibility) {
|
||||
fn encode_visibility(ebml_w: ebml2::Serializer, visibility: visibility) {
|
||||
encode_family(ebml_w, match visibility {
|
||||
public => 'g',
|
||||
private => 'j',
|
||||
@ -352,7 +356,7 @@ fn encode_visibility(ebml_w: ebml::Writer, visibility: visibility) {
|
||||
});
|
||||
}
|
||||
|
||||
fn encode_self_type(ebml_w: ebml::Writer, self_type: ast::self_ty_) {
|
||||
fn encode_self_type(ebml_w: ebml2::Serializer, self_type: ast::self_ty_) {
|
||||
ebml_w.start_tag(tag_item_trait_method_self_ty);
|
||||
|
||||
// Encode the base self type.
|
||||
@ -385,7 +389,7 @@ fn encode_self_type(ebml_w: ebml::Writer, self_type: ast::self_ty_) {
|
||||
}
|
||||
|
||||
/* Returns an index of items in this class */
|
||||
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
id: node_id, path: ast_map::path,
|
||||
class_tps: ~[ty_param],
|
||||
fields: ~[@struct_field],
|
||||
@ -441,7 +445,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
}
|
||||
|
||||
// This is for encoding info for ctors and dtors
|
||||
fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
id: node_id, ident: ident, path: ast_map::path,
|
||||
item: Option<inlined_item>, tps: ~[ty_param]) {
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
@ -466,7 +470,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
impl_path: ast_map::path, should_inline: bool,
|
||||
parent_id: node_id,
|
||||
m: @method, all_tps: ~[ty_param]) {
|
||||
@ -516,8 +520,9 @@ fn should_inline(attrs: ~[attribute]) -> bool {
|
||||
}
|
||||
|
||||
|
||||
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
index: @mut ~[entry<int>], path: ast_map::path) {
|
||||
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
item: @item, index: @mut ~[entry<int>],
|
||||
path: ast_map::path) {
|
||||
|
||||
let tcx = ecx.tcx;
|
||||
let must_write =
|
||||
@ -528,7 +533,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
};
|
||||
if !must_write && !reachable(ecx, item.id) { return; }
|
||||
|
||||
fn add_to_index_(item: @item, ebml_w: ebml::Writer,
|
||||
fn add_to_index_(item: @item, ebml_w: ebml2::Serializer,
|
||||
index: @mut ~[entry<int>]) {
|
||||
index.push({val: item.id, pos: ebml_w.writer.tell()});
|
||||
}
|
||||
@ -805,7 +810,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
nitem: @foreign_item,
|
||||
index: @mut ~[entry<int>],
|
||||
path: ast_map::path, abi: foreign_abi) {
|
||||
@ -838,7 +843,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
crate: @crate) -> ~[entry<int>] {
|
||||
let index = @mut ~[];
|
||||
ebml_w.start_tag(tag_items_data);
|
||||
@ -893,7 +898,7 @@ fn create_index<T: Copy Hash IterBytes>(index: ~[entry<T>]) ->
|
||||
return buckets_frozen;
|
||||
}
|
||||
|
||||
fn encode_index<T>(ebml_w: ebml::Writer, buckets: ~[@~[entry<T>]],
|
||||
fn encode_index<T>(ebml_w: ebml2::Serializer, buckets: ~[@~[entry<T>]],
|
||||
write_fn: fn(io::Writer, T)) {
|
||||
let writer = ebml_w.writer;
|
||||
ebml_w.start_tag(tag_index);
|
||||
@ -928,7 +933,7 @@ fn write_int(writer: io::Writer, &&n: int) {
|
||||
writer.write_be_u32(n as u32);
|
||||
}
|
||||
|
||||
fn encode_meta_item(ebml_w: ebml::Writer, mi: meta_item) {
|
||||
fn encode_meta_item(ebml_w: ebml2::Serializer, mi: meta_item) {
|
||||
match mi.node {
|
||||
meta_word(name) => {
|
||||
ebml_w.start_tag(tag_meta_item_word);
|
||||
@ -965,7 +970,7 @@ fn encode_meta_item(ebml_w: ebml::Writer, mi: meta_item) {
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_attributes(ebml_w: ebml::Writer, attrs: ~[attribute]) {
|
||||
fn encode_attributes(ebml_w: ebml2::Serializer, attrs: ~[attribute]) {
|
||||
ebml_w.start_tag(tag_attributes);
|
||||
for attrs.each |attr| {
|
||||
ebml_w.start_tag(tag_attribute);
|
||||
@ -1026,7 +1031,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
|
||||
return attrs;
|
||||
}
|
||||
|
||||
fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
cstore: cstore::cstore) {
|
||||
|
||||
fn get_ordered_deps(ecx: @encode_ctxt, cstore: cstore::cstore)
|
||||
@ -1072,7 +1077,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: ebml2::Serializer,
|
||||
dep: decoder::crate_dep) {
|
||||
ebml_w.start_tag(tag_crate_dep);
|
||||
ebml_w.start_tag(tag_crate_dep_name);
|
||||
@ -1087,7 +1092,7 @@ fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_hash(ebml_w: ebml::Writer, hash: ~str) {
|
||||
fn encode_hash(ebml_w: ebml2::Serializer, hash: ~str) {
|
||||
ebml_w.start_tag(tag_crate_hash);
|
||||
ebml_w.writer.write(str::to_bytes(hash));
|
||||
ebml_w.end_tag();
|
||||
@ -1125,7 +1130,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
|
||||
type_abbrevs: ty::new_ty_hash()
|
||||
});
|
||||
|
||||
let ebml_w = ebml::Writer(wr as io::Writer);
|
||||
let ebml_w = ebml2::Serializer(wr as io::Writer);
|
||||
|
||||
encode_hash(ebml_w, ecx.link_meta.extras_hash);
|
||||
|
||||
|
@ -7,23 +7,21 @@ use syntax::visit;
|
||||
use syntax::ast_map;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::span;
|
||||
use std::ebml;
|
||||
use std::ebml::Writer;
|
||||
use std::ebml::get_doc;
|
||||
use std::ebml2;
|
||||
use std::ebml2::Serializer;
|
||||
use std::ebml2::get_doc;
|
||||
use std::map::HashMap;
|
||||
use std::serialization::Serializer;
|
||||
use std::serialization::Deserializer;
|
||||
use std::serialization::SerializerHelpers;
|
||||
use std::serialization::DeserializerHelpers;
|
||||
use std::prettyprint::Serializer;
|
||||
use std::serialization2;
|
||||
use std::serialization2::{Serializable,
|
||||
SerializerHelpers,
|
||||
DeserializerHelpers,
|
||||
deserialize};
|
||||
use middle::{ty, typeck};
|
||||
use middle::typeck::{method_origin, method_map_entry,
|
||||
vtable_res,
|
||||
vtable_origin};
|
||||
use driver::session::session;
|
||||
use middle::freevars::{freevar_entry,
|
||||
serialize_freevar_entry,
|
||||
deserialize_freevar_entry};
|
||||
use middle::freevars::freevar_entry;
|
||||
use c = metadata::common;
|
||||
use e = metadata::encoder;
|
||||
use cstore = metadata::cstore;
|
||||
@ -76,7 +74,7 @@ trait tr {
|
||||
// Top-level methods.
|
||||
|
||||
fn encode_inlined_item(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
path: ast_map::path,
|
||||
ii: ast::inlined_item,
|
||||
maps: maps) {
|
||||
@ -87,7 +85,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) {
|
||||
ast_util::serialize_id_range(ebml_w, id_range);
|
||||
id_range.serialize(&ebml_w);
|
||||
encode_ast(ebml_w, simplify_ast(ii));
|
||||
encode_side_tables_for_ii(ecx, maps, ebml_w, ii);
|
||||
}
|
||||
@ -102,15 +100,15 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
maps: maps,
|
||||
path: ast_map::path,
|
||||
par_doc: ebml::Doc) -> Option<ast::inlined_item> {
|
||||
par_doc: ebml2::Doc) -> Option<ast::inlined_item> {
|
||||
let dcx = @{cdata: cdata, tcx: tcx, maps: maps};
|
||||
match par_doc.opt_child(c::tag_ast) {
|
||||
None => None,
|
||||
Some(ast_doc) => {
|
||||
debug!("> Decoding inlined fn: %s::?",
|
||||
ast_map::path_to_str(path, tcx.sess.parse_sess.interner));
|
||||
let ast_dsr = ebml::ebml_deserializer(ast_doc);
|
||||
let from_id_range = ast_util::deserialize_id_range(ast_dsr);
|
||||
let ast_dsr = &ebml2::Deserializer(ast_doc);
|
||||
let from_id_range = deserialize(ast_dsr);
|
||||
let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range);
|
||||
let xcx = extended_decode_ctxt_(@{dcx: dcx,
|
||||
from_id_range: from_id_range,
|
||||
@ -187,9 +185,9 @@ trait def_id_serializer_helpers {
|
||||
fn emit_def_id(did: ast::def_id);
|
||||
}
|
||||
|
||||
impl<S: Serializer> S: def_id_serializer_helpers {
|
||||
impl<S: serialization2::Serializer> S: def_id_serializer_helpers {
|
||||
fn emit_def_id(did: ast::def_id) {
|
||||
ast::serialize_def_id(self, did)
|
||||
did.serialize(&self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,10 +195,10 @@ trait def_id_deserializer_helpers {
|
||||
fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id;
|
||||
}
|
||||
|
||||
impl<D: Deserializer> D: def_id_deserializer_helpers {
|
||||
impl<D: serialization2::Deserializer> D: def_id_deserializer_helpers {
|
||||
|
||||
fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id {
|
||||
let did = ast::deserialize_def_id(self);
|
||||
let did: ast::def_id = deserialize(&self);
|
||||
did.tr(xcx)
|
||||
}
|
||||
}
|
||||
@ -220,9 +218,9 @@ impl<D: Deserializer> 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: ebml::Writer, item: ast::inlined_item) {
|
||||
fn encode_ast(ebml_w: ebml2::Serializer, item: ast::inlined_item) {
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) {
|
||||
ast::serialize_inlined_item(ebml_w, item)
|
||||
item.serialize(&ebml_w)
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,10 +278,10 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
}
|
||||
}
|
||||
|
||||
fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item {
|
||||
fn decode_ast(par_doc: ebml2::Doc) -> ast::inlined_item {
|
||||
let chi_doc = par_doc[c::tag_tree as uint];
|
||||
let d = ebml::ebml_deserializer(chi_doc);
|
||||
ast::deserialize_inlined_item(d)
|
||||
let d = &ebml2::Deserializer(chi_doc);
|
||||
deserialize(d)
|
||||
}
|
||||
|
||||
fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
||||
@ -334,13 +332,13 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
||||
// ______________________________________________________________________
|
||||
// Encoding and decoding of ast::def
|
||||
|
||||
fn encode_def(ebml_w: ebml::Writer, def: ast::def) {
|
||||
ast::serialize_def(ebml_w, def)
|
||||
fn encode_def(ebml_w: ebml2::Serializer, def: ast::def) {
|
||||
def.serialize(&ebml_w)
|
||||
}
|
||||
|
||||
fn decode_def(xcx: extended_decode_ctxt, doc: ebml::Doc) -> ast::def {
|
||||
let dsr = ebml::ebml_deserializer(doc);
|
||||
let def = ast::deserialize_def(dsr);
|
||||
fn decode_def(xcx: extended_decode_ctxt, doc: ebml2::Doc) -> ast::def {
|
||||
let dsr = &ebml2::Deserializer(doc);
|
||||
let def: ast::def = deserialize(dsr);
|
||||
def.tr(xcx)
|
||||
}
|
||||
|
||||
@ -425,17 +423,17 @@ impl ty::bound_region: tr {
|
||||
// ______________________________________________________________________
|
||||
// Encoding and decoding of freevar information
|
||||
|
||||
fn encode_freevar_entry(ebml_w: ebml::Writer, fv: freevar_entry) {
|
||||
serialize_freevar_entry(ebml_w, fv)
|
||||
fn encode_freevar_entry(ebml_w: ebml2::Serializer, fv: @freevar_entry) {
|
||||
(*fv).serialize(&ebml_w)
|
||||
}
|
||||
|
||||
trait ebml_deserializer_helper {
|
||||
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry;
|
||||
}
|
||||
|
||||
impl ebml::EbmlDeserializer: ebml_deserializer_helper {
|
||||
impl ebml2::Deserializer: ebml_deserializer_helper {
|
||||
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry {
|
||||
let fv = deserialize_freevar_entry(self);
|
||||
let fv: freevar_entry = deserialize(&self);
|
||||
fv.tr(xcx)
|
||||
}
|
||||
}
|
||||
@ -454,28 +452,29 @@ trait read_method_map_entry_helper {
|
||||
}
|
||||
|
||||
fn serialize_method_map_entry(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
mme: method_map_entry) {
|
||||
do ebml_w.emit_rec {
|
||||
do ebml_w.emit_rec_field(~"self_arg", 0u) {
|
||||
do ebml_w.emit_field(~"self_arg", 0u) {
|
||||
ebml_w.emit_arg(ecx, mme.self_arg);
|
||||
}
|
||||
do ebml_w.emit_rec_field(~"origin", 1u) {
|
||||
typeck::serialize_method_origin(ebml_w, mme.origin);
|
||||
do ebml_w.emit_field(~"origin", 1u) {
|
||||
mme.origin.serialize(&ebml_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ebml::EbmlDeserializer: read_method_map_entry_helper {
|
||||
impl ebml2::Deserializer: read_method_map_entry_helper {
|
||||
fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry {
|
||||
do self.read_rec {
|
||||
{self_arg:
|
||||
self.read_rec_field(~"self_arg", 0u, || {
|
||||
self.read_field(~"self_arg", 0u, || {
|
||||
self.read_arg(xcx)
|
||||
}),
|
||||
origin:
|
||||
self.read_rec_field(~"origin", 1u, || {
|
||||
typeck::deserialize_method_origin(self).tr(xcx)
|
||||
self.read_field(~"origin", 1u, || {
|
||||
let method_origin: method_origin = deserialize(&self);
|
||||
method_origin.tr(xcx)
|
||||
})}
|
||||
}
|
||||
}
|
||||
@ -504,19 +503,19 @@ impl method_origin: tr {
|
||||
// Encoding and decoding vtable_res
|
||||
|
||||
fn encode_vtable_res(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
dr: typeck::vtable_res) {
|
||||
// can't autogenerate this code because automatic serialization of
|
||||
// ty::t doesn't work, and there is no way (atm) to have
|
||||
// hand-written serialization 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)
|
||||
encode_vtable_origin(ecx, ebml_w, *vtable_origin)
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_vtable_origin(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
vtable_origin: typeck::vtable_origin) {
|
||||
do ebml_w.emit_enum(~"vtable_origin") {
|
||||
match vtable_origin {
|
||||
@ -563,7 +562,7 @@ trait vtable_deserialization_helpers {
|
||||
fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin;
|
||||
}
|
||||
|
||||
impl ebml::EbmlDeserializer: vtable_deserialization_helpers {
|
||||
impl ebml2::Deserializer: vtable_deserialization_helpers {
|
||||
fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res {
|
||||
@self.read_to_vec(|| self.read_vtable_origin(xcx) )
|
||||
}
|
||||
@ -640,7 +639,7 @@ trait ebml_writer_helpers {
|
||||
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty);
|
||||
}
|
||||
|
||||
impl ebml::Writer: ebml_writer_helpers {
|
||||
impl ebml2::Serializer: ebml_writer_helpers {
|
||||
fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) {
|
||||
do self.emit_opaque {
|
||||
e::write_type(ecx, self, ty)
|
||||
@ -661,7 +660,7 @@ impl ebml::Writer: ebml_writer_helpers {
|
||||
|
||||
fn emit_tys(ecx: @e::encode_ctxt, tys: ~[ty::t]) {
|
||||
do self.emit_from_vec(tys) |ty| {
|
||||
self.emit_ty(ecx, ty)
|
||||
self.emit_ty(ecx, *ty)
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,17 +672,15 @@ impl ebml::Writer: ebml_writer_helpers {
|
||||
|
||||
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) {
|
||||
do self.emit_rec {
|
||||
do self.emit_rec_field(~"bounds", 0u) {
|
||||
do self.emit_field(~"bounds", 0u) {
|
||||
do self.emit_from_vec(*tpbt.bounds) |bs| {
|
||||
self.emit_bounds(ecx, bs);
|
||||
self.emit_bounds(ecx, *bs);
|
||||
}
|
||||
}
|
||||
do self.emit_rec_field(~"region_param", 1u) {
|
||||
ty::serialize_opt_region_variance(
|
||||
self,
|
||||
tpbt.region_param);
|
||||
do self.emit_field(~"region_param", 1u) {
|
||||
tpbt.region_param.serialize(&self);
|
||||
}
|
||||
do self.emit_rec_field(~"ty", 2u) {
|
||||
do self.emit_field(~"ty", 2u) {
|
||||
self.emit_ty(ecx, tpbt.ty);
|
||||
}
|
||||
}
|
||||
@ -695,7 +692,7 @@ trait write_tag_and_id {
|
||||
fn id(id: ast::node_id);
|
||||
}
|
||||
|
||||
impl ebml::Writer: write_tag_and_id {
|
||||
impl ebml2::Serializer: write_tag_and_id {
|
||||
fn tag(tag_id: c::astencode_tag, f: fn()) {
|
||||
do self.wr_tag(tag_id as uint) { f() }
|
||||
}
|
||||
@ -707,7 +704,7 @@ impl ebml::Writer: write_tag_and_id {
|
||||
|
||||
fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
|
||||
maps: maps,
|
||||
ebml_w: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
ii: ast::inlined_item) {
|
||||
do ebml_w.wr_tag(c::tag_table as uint) {
|
||||
ast_util::visit_ids_for_inlined_item(
|
||||
@ -723,7 +720,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: ebml::Writer,
|
||||
ebml_w: ebml2::Serializer,
|
||||
id: ast::node_id) {
|
||||
let tcx = ecx.tcx;
|
||||
|
||||
@ -733,7 +730,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) {
|
||||
ast::serialize_def(ebml_w, *def)
|
||||
(*def).serialize(&ebml_w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -810,7 +807,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| {
|
||||
ebml_w.emit_int(id);
|
||||
id.serialize(&ebml_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -838,7 +835,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) {
|
||||
ty::serialize_AutoAdjustment(ebml_w, **adj)
|
||||
(**adj).serialize(&ebml_w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -852,13 +849,13 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
|
||||
trait doc_decoder_helpers {
|
||||
fn as_int() -> int;
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc>;
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml2::Doc>;
|
||||
}
|
||||
|
||||
impl ebml::Doc: doc_decoder_helpers {
|
||||
fn as_int() -> int { ebml::doc_as_u64(self) as int }
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc> {
|
||||
ebml::maybe_get_doc(self, tag as uint)
|
||||
impl ebml2::Doc: doc_decoder_helpers {
|
||||
fn as_int() -> int { ebml2::doc_as_u64(self) as int }
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml2::Doc> {
|
||||
ebml2::maybe_get_doc(self, tag as uint)
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,7 +868,7 @@ trait ebml_deserializer_decoder_helpers {
|
||||
-> ty::ty_param_bounds_and_ty;
|
||||
}
|
||||
|
||||
impl ebml::EbmlDeserializer: ebml_deserializer_decoder_helpers {
|
||||
impl ebml2::Deserializer: ebml_deserializer_decoder_helpers {
|
||||
|
||||
fn read_arg(xcx: extended_decode_ctxt) -> ty::arg {
|
||||
do self.read_opaque |doc| {
|
||||
@ -911,13 +908,13 @@ impl ebml::EbmlDeserializer: ebml_deserializer_decoder_helpers {
|
||||
{
|
||||
do self.read_rec {
|
||||
{
|
||||
bounds: self.read_rec_field(~"bounds", 0u, || {
|
||||
bounds: self.read_field(~"bounds", 0u, || {
|
||||
@self.read_to_vec(|| self.read_bounds(xcx) )
|
||||
}),
|
||||
region_param: self.read_rec_field(~"region_param", 1u, || {
|
||||
ty::deserialize_opt_region_variance(self)
|
||||
region_param: self.read_field(~"region_param", 1u, || {
|
||||
deserialize(&self)
|
||||
}),
|
||||
ty: self.read_rec_field(~"ty", 2u, || {
|
||||
ty: self.read_field(~"ty", 2u, || {
|
||||
self.read_ty(xcx)
|
||||
})
|
||||
}
|
||||
@ -926,10 +923,10 @@ impl ebml::EbmlDeserializer: ebml_deserializer_decoder_helpers {
|
||||
}
|
||||
|
||||
fn decode_side_tables(xcx: extended_decode_ctxt,
|
||||
ast_doc: ebml::Doc) {
|
||||
ast_doc: ebml2::Doc) {
|
||||
let dcx = xcx.dcx;
|
||||
let tbl_doc = ast_doc[c::tag_table as uint];
|
||||
for ebml::docs(tbl_doc) |tag, entry_doc| {
|
||||
for ebml2::docs(tbl_doc) |tag, entry_doc| {
|
||||
let id0 = entry_doc[c::tag_table_id as uint].as_int();
|
||||
let id = xcx.tr_id(id0);
|
||||
|
||||
@ -943,7 +940,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 = ebml::ebml_deserializer(val_doc);
|
||||
let val_dsr = &ebml2::Deserializer(val_doc);
|
||||
if tag == (c::tag_table_def as uint) {
|
||||
let def = decode_def(xcx, val_doc);
|
||||
dcx.tcx.def_map.insert(id, def);
|
||||
@ -979,7 +976,8 @@ 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::deserialize_AutoAdjustment(val_dsr).tr(xcx);
|
||||
let adj: @ty::AutoAdjustment = @deserialize(val_dsr);
|
||||
adj.tr(xcx);
|
||||
dcx.tcx.adjustments.insert(id, adj);
|
||||
} else {
|
||||
xcx.dcx.tcx.sess.bug(
|
||||
@ -995,17 +993,17 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
||||
// Testing of astencode_gen
|
||||
|
||||
#[cfg(test)]
|
||||
fn encode_item_ast(ebml_w: ebml::Writer, item: @ast::item) {
|
||||
fn encode_item_ast(ebml_w: ebml2::Serializer, item: @ast::item) {
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) {
|
||||
ast::serialize_item(ebml_w, *item);
|
||||
(*item).serialize(&ebml_w)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
|
||||
fn decode_item_ast(par_doc: ebml2::Doc) -> @ast::item {
|
||||
let chi_doc = par_doc[c::tag_tree as uint];
|
||||
let d = ebml::ebml_deserializer(chi_doc);
|
||||
@ast::deserialize_item(d)
|
||||
let d = &ebml2::Deserializer(chi_doc);
|
||||
@deserialize(d)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -1031,16 +1029,18 @@ 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 = ebml::Writer(wr);
|
||||
let ebml_w = ebml2::Serializer(wr);
|
||||
encode_item_ast(ebml_w, in_item);
|
||||
};
|
||||
let ebml_doc = ebml::Doc(@bytes);
|
||||
let ebml_doc = ebml2::Doc(@bytes);
|
||||
let out_item = decode_item_ast(ebml_doc);
|
||||
|
||||
let exp_str =
|
||||
io::with_str_writer(|w| ast::serialize_item(w, *in_item) );
|
||||
let out_str =
|
||||
io::with_str_writer(|w| ast::serialize_item(w, *out_item) );
|
||||
let exp_str = do io::with_str_writer |w| {
|
||||
in_item.serialize(&std::prettyprint2::Serializer(w))
|
||||
};
|
||||
let out_str = do io::with_str_writer |w| {
|
||||
out_item.serialize(&std::prettyprint2::Serializer(w))
|
||||
};
|
||||
|
||||
debug!("expected string: %s", exp_str);
|
||||
debug!("actual string : %s", out_str);
|
||||
|
@ -5,19 +5,19 @@ use syntax::print::pprust::path_to_str;
|
||||
use std::map::*;
|
||||
use option::*;
|
||||
use syntax::{ast, ast_util, visit};
|
||||
use syntax::ast::{serialize_span, deserialize_span};
|
||||
use syntax::codemap::span;
|
||||
|
||||
export annotate_freevars;
|
||||
export freevar_map;
|
||||
export freevar_info;
|
||||
export freevar_entry, serialize_freevar_entry, deserialize_freevar_entry;
|
||||
export freevar_entry;
|
||||
export get_freevars;
|
||||
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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type freevar_entry = {
|
||||
def: ast::def, //< The variable being accessed free.
|
||||
span: span //< First span where it is accessed (there can be multiple)
|
||||
|
@ -18,10 +18,6 @@ use middle::lint::{get_lint_level, allow};
|
||||
use syntax::ast::*;
|
||||
use syntax::print::pprust::*;
|
||||
use util::ppaux::{ty_to_str, proto_ty_to_str, tys_to_str};
|
||||
use std::serialization::{serialize_Option,
|
||||
deserialize_Option,
|
||||
serialize_uint,
|
||||
deserialize_uint};
|
||||
|
||||
export TyVid, IntVid, FnVid, RegionVid, vid;
|
||||
export br_hashmap;
|
||||
@ -173,7 +169,6 @@ export mach_sty;
|
||||
export ty_sort_str;
|
||||
export normalize_ty;
|
||||
export to_str;
|
||||
export borrow, serialize_borrow, deserialize_borrow;
|
||||
export bound_const;
|
||||
export terr_no_integral_type, terr_ty_param_size, terr_self_substs;
|
||||
export terr_in_field, terr_record_fields, terr_vstores_differ, terr_arg_count;
|
||||
@ -192,12 +187,10 @@ export is_blockish;
|
||||
export method_call_bounds;
|
||||
export hash_region;
|
||||
export region_variance, rv_covariant, rv_invariant, rv_contravariant;
|
||||
export serialize_region_variance, deserialize_region_variance;
|
||||
export opt_region_variance;
|
||||
export serialize_opt_region_variance, deserialize_opt_region_variance;
|
||||
export determine_inherited_purity;
|
||||
export provided_trait_methods;
|
||||
export AutoAdjustment, serialize_AutoAdjustment, deserialize_AutoAdjustment;
|
||||
export AutoAdjustment;
|
||||
export AutoRef, AutoRefKind, AutoSlice, AutoPtr;
|
||||
|
||||
// Data types
|
||||
@ -218,7 +211,8 @@ type method = {ident: ast::ident,
|
||||
|
||||
type mt = {ty: t, mutbl: ast::mutability};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum vstore {
|
||||
vstore_fixed(uint),
|
||||
vstore_uniq,
|
||||
@ -275,10 +269,10 @@ enum ast_ty_to_ty_cache_entry {
|
||||
atttce_resolved(t) /* resolved to a type, irrespective of region */
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
type opt_region_variance = Option<region_variance>;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
|
||||
|
||||
impl region_variance : cmp::Eq {
|
||||
@ -295,20 +289,23 @@ impl region_variance : cmp::Eq {
|
||||
pure fn ne(other: ®ion_variance) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type AutoAdjustment = {
|
||||
autoderefs: uint,
|
||||
autoref: Option<AutoRef>
|
||||
};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type AutoRef = {
|
||||
kind: AutoRefKind,
|
||||
region: region,
|
||||
mutbl: ast::mutability
|
||||
};
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum AutoRefKind {
|
||||
/// Convert from @[]/~[] to &[] (or str)
|
||||
AutoSlice,
|
||||
@ -512,7 +509,8 @@ impl param_ty : to_bytes::IterBytes {
|
||||
|
||||
|
||||
/// Representation of regions:
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum region {
|
||||
/// Bound regions are found (primarily) in function types. They indicate
|
||||
/// region parameters that have yet to be replaced with actual regions
|
||||
@ -540,7 +538,8 @@ enum region {
|
||||
re_var(RegionVid)
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum bound_region {
|
||||
/// The self region for classes, impls (&T in a type defn or &self/T)
|
||||
br_self,
|
||||
@ -670,7 +669,8 @@ enum param_bound {
|
||||
enum TyVid = uint;
|
||||
enum IntVid = uint;
|
||||
enum FnVid = uint;
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum RegionVid = uint;
|
||||
|
||||
enum InferTy {
|
||||
|
@ -56,7 +56,6 @@ use middle::ty::{vstore_uniq};
|
||||
use std::smallintmap;
|
||||
use std::map;
|
||||
use std::map::HashMap;
|
||||
use std::serialization::{serialize_uint, deserialize_uint};
|
||||
use syntax::print::pprust::*;
|
||||
use util::ppaux::{ty_to_str, tys_to_str, region_to_str,
|
||||
bound_region_to_str, vstore_to_str, expr_repr};
|
||||
@ -67,9 +66,8 @@ use list::{List, Nil, Cons};
|
||||
export check_crate;
|
||||
export infer;
|
||||
export method_map;
|
||||
export method_origin, serialize_method_origin, deserialize_method_origin;
|
||||
export method_map_entry, serialize_method_map_entry;
|
||||
export deserialize_method_map_entry;
|
||||
export method_origin;
|
||||
export method_map_entry;
|
||||
export vtable_map;
|
||||
export vtable_res;
|
||||
export vtable_origin;
|
||||
@ -77,7 +75,8 @@ export method_static, method_param, method_trait, method_self;
|
||||
export vtable_static, vtable_param, vtable_trait;
|
||||
export provided_methods_map;
|
||||
|
||||
#[auto_serialize]
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum method_origin {
|
||||
// fully statically resolved method
|
||||
method_static(ast::def_id),
|
||||
@ -94,7 +93,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_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type method_param = {
|
||||
// the trait containing the method to be invoked
|
||||
trait_id: ast::def_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user