mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Use more deriving(IterBytes) in libsyntax.
This commit is contained in:
parent
5784c0912f
commit
75b80bad63
@ -17,17 +17,14 @@ use parse::token::{interner_get, str_to_ident};
|
|||||||
|
|
||||||
use std::hashmap::HashMap;
|
use std::hashmap::HashMap;
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
use std::to_bytes::IterBytes;
|
|
||||||
use std::to_bytes;
|
|
||||||
use std::to_str::ToStr;
|
use std::to_str::ToStr;
|
||||||
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
|
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
||||||
|
|
||||||
// an identifier contains a Name (index into the interner
|
// an identifier contains a Name (index into the interner
|
||||||
// table) and a SyntaxContext to track renaming and
|
// table) and a SyntaxContext to track renaming and
|
||||||
// macro expansion per Flatt et al., "Macros
|
// macro expansion per Flatt et al., "Macros
|
||||||
// That Work Together"
|
// That Work Together"
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq,IterBytes)]
|
||||||
pub struct ident { name: Name, ctxt: SyntaxContext }
|
pub struct ident { name: Name, ctxt: SyntaxContext }
|
||||||
|
|
||||||
/// Construct an identifier with the given name and an empty context:
|
/// Construct an identifier with the given name and an empty context:
|
||||||
@ -57,7 +54,7 @@ pub struct SCTable {
|
|||||||
pub static empty_ctxt : uint = 0;
|
pub static empty_ctxt : uint = 0;
|
||||||
pub static illegal_ctxt : uint = 1;
|
pub static illegal_ctxt : uint = 1;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum SyntaxContext_ {
|
pub enum SyntaxContext_ {
|
||||||
EmptyCtxt,
|
EmptyCtxt,
|
||||||
Mark (Mrk,SyntaxContext),
|
Mark (Mrk,SyntaxContext),
|
||||||
@ -86,42 +83,28 @@ impl<S:Encoder> Encodable<S> for ident {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving(IterBytes)]
|
||||||
impl<D:Decoder> Decodable<D> for ident {
|
impl<D:Decoder> Decodable<D> for ident {
|
||||||
fn decode(d: &mut D) -> ident {
|
fn decode(d: &mut D) -> ident {
|
||||||
str_to_ident(d.read_str())
|
str_to_ident(d.read_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ident {
|
|
||||||
#[inline]
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.name.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Functions may or may not have names.
|
// Functions may or may not have names.
|
||||||
pub type fn_ident = Option<ident>;
|
pub type fn_ident = Option<ident>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct Lifetime {
|
pub struct Lifetime {
|
||||||
id: node_id,
|
id: node_id,
|
||||||
span: span,
|
span: span,
|
||||||
ident: ident
|
ident: ident
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for Lifetime {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.id.iter_bytes(lsb0, f) &&
|
|
||||||
self.span.iter_bytes(lsb0, f) &&
|
|
||||||
self.ident.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// a "Path" is essentially Rust's notion of a name;
|
// a "Path" is essentially Rust's notion of a name;
|
||||||
// for instance: core::cmp::Eq . It's represented
|
// for instance: core::cmp::Eq . It's represented
|
||||||
// as a sequence of identifiers, along with a bunch
|
// as a sequence of identifiers, along with a bunch
|
||||||
// of supporting information.
|
// of supporting information.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct Path {
|
pub struct Path {
|
||||||
span: span,
|
span: span,
|
||||||
global: bool,
|
global: bool,
|
||||||
@ -134,7 +117,7 @@ pub type crate_num = int;
|
|||||||
|
|
||||||
pub type node_id = int;
|
pub type node_id = int;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct def_id {
|
pub struct def_id {
|
||||||
crate: crate_num,
|
crate: crate_num,
|
||||||
node: node_id,
|
node: node_id,
|
||||||
@ -143,7 +126,7 @@ pub struct def_id {
|
|||||||
pub static local_crate: crate_num = 0;
|
pub static local_crate: crate_num = 0;
|
||||||
pub static crate_node_id: node_id = 0;
|
pub static crate_node_id: node_id = 0;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
// The AST represents all type param bounds as types.
|
// The AST represents all type param bounds as types.
|
||||||
// typeck::collect::compute_bounds matches these against
|
// typeck::collect::compute_bounds matches these against
|
||||||
// the "special" built-in traits (see middle::lang_items) and
|
// the "special" built-in traits (see middle::lang_items) and
|
||||||
@ -153,14 +136,14 @@ pub enum TyParamBound {
|
|||||||
RegionTyParamBound
|
RegionTyParamBound
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct TyParam {
|
pub struct TyParam {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
id: node_id,
|
id: node_id,
|
||||||
bounds: @OptVec<TyParamBound>
|
bounds: @OptVec<TyParamBound>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct Generics {
|
pub struct Generics {
|
||||||
lifetimes: OptVec<Lifetime>,
|
lifetimes: OptVec<Lifetime>,
|
||||||
ty_params: OptVec<TyParam>
|
ty_params: OptVec<TyParam>
|
||||||
@ -178,7 +161,7 @@ impl Generics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum def {
|
pub enum def {
|
||||||
def_fn(def_id, purity),
|
def_fn(def_id, purity),
|
||||||
def_static_method(/* method */ def_id,
|
def_static_method(/* method */ def_id,
|
||||||
@ -216,7 +199,7 @@ pub type crate_cfg = ~[@meta_item];
|
|||||||
|
|
||||||
pub type crate = spanned<crate_>;
|
pub type crate = spanned<crate_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct crate_ {
|
pub struct crate_ {
|
||||||
module: _mod,
|
module: _mod,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -225,7 +208,7 @@ pub struct crate_ {
|
|||||||
|
|
||||||
pub type meta_item = spanned<meta_item_>;
|
pub type meta_item = spanned<meta_item_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum meta_item_ {
|
pub enum meta_item_ {
|
||||||
meta_word(@str),
|
meta_word(@str),
|
||||||
meta_list(@str, ~[@meta_item]),
|
meta_list(@str, ~[@meta_item]),
|
||||||
@ -234,7 +217,7 @@ pub enum meta_item_ {
|
|||||||
|
|
||||||
pub type blk = spanned<blk_>;
|
pub type blk = spanned<blk_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct blk_ {
|
pub struct blk_ {
|
||||||
view_items: ~[@view_item],
|
view_items: ~[@view_item],
|
||||||
stmts: ~[@stmt],
|
stmts: ~[@stmt],
|
||||||
@ -243,40 +226,26 @@ pub struct blk_ {
|
|||||||
rules: blk_check_mode,
|
rules: blk_check_mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct pat {
|
pub struct pat {
|
||||||
id: node_id,
|
id: node_id,
|
||||||
node: pat_,
|
node: pat_,
|
||||||
span: span,
|
span: span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct field_pat {
|
pub struct field_pat {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
pat: @pat,
|
pat: @pat,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum binding_mode {
|
pub enum binding_mode {
|
||||||
bind_by_ref(mutability),
|
bind_by_ref(mutability),
|
||||||
bind_infer
|
bind_infer
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for binding_mode {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
match *self {
|
|
||||||
bind_by_ref(ref m) => {
|
|
||||||
0u8.iter_bytes(lsb0, f) && m.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
bind_infer => {
|
|
||||||
1u8.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum pat_ {
|
pub enum pat_ {
|
||||||
pat_wild,
|
pat_wild,
|
||||||
// A pat_ident may either be a new bound variable,
|
// A pat_ident may either be a new bound variable,
|
||||||
@ -301,28 +270,16 @@ pub enum pat_ {
|
|||||||
pat_vec(~[@pat], Option<@pat>, ~[@pat])
|
pat_vec(~[@pat], Option<@pat>, ~[@pat])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum mutability { m_mutbl, m_imm, m_const, }
|
pub enum mutability { m_mutbl, m_imm, m_const, }
|
||||||
|
|
||||||
impl to_bytes::IterBytes for mutability {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as u8).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum Sigil {
|
pub enum Sigil {
|
||||||
BorrowedSigil,
|
BorrowedSigil,
|
||||||
OwnedSigil,
|
OwnedSigil,
|
||||||
ManagedSigil
|
ManagedSigil
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for Sigil {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as uint).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToStr for Sigil {
|
impl ToStr for Sigil {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
match *self {
|
match *self {
|
||||||
@ -333,7 +290,7 @@ impl ToStr for Sigil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum vstore {
|
pub enum vstore {
|
||||||
// FIXME (#3469): Change uint to @expr (actually only constant exprs)
|
// FIXME (#3469): Change uint to @expr (actually only constant exprs)
|
||||||
vstore_fixed(Option<uint>), // [1,2,3,4]
|
vstore_fixed(Option<uint>), // [1,2,3,4]
|
||||||
@ -342,7 +299,7 @@ pub enum vstore {
|
|||||||
vstore_slice(Option<@Lifetime>) // &'foo? [1,2,3,4]
|
vstore_slice(Option<@Lifetime>) // &'foo? [1,2,3,4]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum expr_vstore {
|
pub enum expr_vstore {
|
||||||
expr_vstore_uniq, // ~[1,2,3,4]
|
expr_vstore_uniq, // ~[1,2,3,4]
|
||||||
expr_vstore_box, // @[1,2,3,4]
|
expr_vstore_box, // @[1,2,3,4]
|
||||||
@ -351,7 +308,7 @@ pub enum expr_vstore {
|
|||||||
expr_vstore_mut_slice, // &mut [1,2,3,4]
|
expr_vstore_mut_slice, // &mut [1,2,3,4]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum binop {
|
pub enum binop {
|
||||||
add,
|
add,
|
||||||
subtract,
|
subtract,
|
||||||
@ -373,7 +330,7 @@ pub enum binop {
|
|||||||
gt,
|
gt,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum unop {
|
pub enum unop {
|
||||||
box(mutability),
|
box(mutability),
|
||||||
uniq(mutability),
|
uniq(mutability),
|
||||||
@ -384,7 +341,7 @@ pub enum unop {
|
|||||||
|
|
||||||
pub type stmt = spanned<stmt_>;
|
pub type stmt = spanned<stmt_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum stmt_ {
|
pub enum stmt_ {
|
||||||
// could be an item or a local (let) binding:
|
// could be an item or a local (let) binding:
|
||||||
stmt_decl(@decl, node_id),
|
stmt_decl(@decl, node_id),
|
||||||
@ -401,7 +358,7 @@ pub enum stmt_ {
|
|||||||
|
|
||||||
// FIXME (pending discussion of #1697, #2178...): local should really be
|
// FIXME (pending discussion of #1697, #2178...): local should really be
|
||||||
// a refinement on pat.
|
// a refinement on pat.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct local_ {
|
pub struct local_ {
|
||||||
is_mutbl: bool,
|
is_mutbl: bool,
|
||||||
ty: @Ty,
|
ty: @Ty,
|
||||||
@ -414,7 +371,7 @@ pub type local = spanned<local_>;
|
|||||||
|
|
||||||
pub type decl = spanned<decl_>;
|
pub type decl = spanned<decl_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum decl_ {
|
pub enum decl_ {
|
||||||
// a local (let) binding:
|
// a local (let) binding:
|
||||||
decl_local(@local),
|
decl_local(@local),
|
||||||
@ -422,14 +379,14 @@ pub enum decl_ {
|
|||||||
decl_item(@item),
|
decl_item(@item),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct arm {
|
pub struct arm {
|
||||||
pats: ~[@pat],
|
pats: ~[@pat],
|
||||||
guard: Option<@expr>,
|
guard: Option<@expr>,
|
||||||
body: blk,
|
body: blk,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct field_ {
|
pub struct field_ {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
expr: @expr,
|
expr: @expr,
|
||||||
@ -437,10 +394,10 @@ pub struct field_ {
|
|||||||
|
|
||||||
pub type field = spanned<field_>;
|
pub type field = spanned<field_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum blk_check_mode { default_blk, unsafe_blk, }
|
pub enum blk_check_mode { default_blk, unsafe_blk, }
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct expr {
|
pub struct expr {
|
||||||
id: node_id,
|
id: node_id,
|
||||||
node: expr_,
|
node: expr_,
|
||||||
@ -460,14 +417,14 @@ impl expr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum CallSugar {
|
pub enum CallSugar {
|
||||||
NoSugar,
|
NoSugar,
|
||||||
DoSugar,
|
DoSugar,
|
||||||
ForSugar
|
ForSugar
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum expr_ {
|
pub enum expr_ {
|
||||||
expr_vstore(@expr, expr_vstore),
|
expr_vstore(@expr, expr_vstore),
|
||||||
expr_vec(~[@expr], mutability),
|
expr_vec(~[@expr], mutability),
|
||||||
@ -538,7 +495,7 @@ pub enum expr_ {
|
|||||||
// else knows what to do with them, so you'll probably get a syntax
|
// else knows what to do with them, so you'll probably get a syntax
|
||||||
// error.
|
// error.
|
||||||
//
|
//
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
#[doc="For macro invocations; parsing is delegated to the macro"]
|
#[doc="For macro invocations; parsing is delegated to the macro"]
|
||||||
pub enum token_tree {
|
pub enum token_tree {
|
||||||
// a single token
|
// a single token
|
||||||
@ -611,7 +568,7 @@ pub enum token_tree {
|
|||||||
//
|
//
|
||||||
pub type matcher = spanned<matcher_>;
|
pub type matcher = spanned<matcher_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum matcher_ {
|
pub enum matcher_ {
|
||||||
// match one token
|
// match one token
|
||||||
match_tok(::parse::token::Token),
|
match_tok(::parse::token::Token),
|
||||||
@ -624,14 +581,14 @@ pub enum matcher_ {
|
|||||||
|
|
||||||
pub type mac = spanned<mac_>;
|
pub type mac = spanned<mac_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum mac_ {
|
pub enum mac_ {
|
||||||
mac_invoc_tt(@Path,~[token_tree]), // new macro-invocation
|
mac_invoc_tt(@Path,~[token_tree]), // new macro-invocation
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type lit = spanned<lit_>;
|
pub type lit = spanned<lit_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum lit_ {
|
pub enum lit_ {
|
||||||
lit_str(@str),
|
lit_str(@str),
|
||||||
lit_int(i64, int_ty),
|
lit_int(i64, int_ty),
|
||||||
@ -645,13 +602,13 @@ pub enum lit_ {
|
|||||||
|
|
||||||
// NB: If you change this, you'll probably want to change the corresponding
|
// NB: If you change this, you'll probably want to change the corresponding
|
||||||
// type structure in middle/ty.rs as well.
|
// type structure in middle/ty.rs as well.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct mt {
|
pub struct mt {
|
||||||
ty: @Ty,
|
ty: @Ty,
|
||||||
mutbl: mutability,
|
mutbl: mutability,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct ty_field_ {
|
pub struct ty_field_ {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
mt: mt,
|
mt: mt,
|
||||||
@ -659,7 +616,7 @@ pub struct ty_field_ {
|
|||||||
|
|
||||||
pub type ty_field = spanned<ty_field_>;
|
pub type ty_field = spanned<ty_field_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct ty_method {
|
pub struct ty_method {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -671,7 +628,7 @@ pub struct ty_method {
|
|||||||
span: span,
|
span: span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
// A trait method is either required (meaning it doesn't have an
|
// A trait method is either required (meaning it doesn't have an
|
||||||
// implementation, just a signature) or provided (meaning it has a default
|
// implementation, just a signature) or provided (meaning it has a default
|
||||||
// implementation).
|
// implementation).
|
||||||
@ -680,7 +637,7 @@ pub enum trait_method {
|
|||||||
provided(@method),
|
provided(@method),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
|
pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
|
||||||
|
|
||||||
impl ToStr for int_ty {
|
impl ToStr for int_ty {
|
||||||
@ -689,13 +646,7 @@ impl ToStr for int_ty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for int_ty {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as u8).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
|
pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
|
||||||
|
|
||||||
impl ToStr for uint_ty {
|
impl ToStr for uint_ty {
|
||||||
@ -704,13 +655,7 @@ impl ToStr for uint_ty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for uint_ty {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as u8).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum float_ty { ty_f, ty_f32, ty_f64, }
|
pub enum float_ty { ty_f, ty_f32, ty_f64, }
|
||||||
|
|
||||||
impl ToStr for float_ty {
|
impl ToStr for float_ty {
|
||||||
@ -719,14 +664,8 @@ impl ToStr for float_ty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for float_ty {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as u8).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NB Eq method appears below.
|
// NB Eq method appears below.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct Ty {
|
pub struct Ty {
|
||||||
id: node_id,
|
id: node_id,
|
||||||
node: ty_,
|
node: ty_,
|
||||||
@ -734,7 +673,7 @@ pub struct Ty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not represented directly in the AST, referred to by name through a ty_path.
|
// Not represented directly in the AST, referred to by name through a ty_path.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum prim_ty {
|
pub enum prim_ty {
|
||||||
ty_int(int_ty),
|
ty_int(int_ty),
|
||||||
ty_uint(uint_ty),
|
ty_uint(uint_ty),
|
||||||
@ -743,12 +682,13 @@ pub enum prim_ty {
|
|||||||
ty_bool,
|
ty_bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum Onceness {
|
pub enum Onceness {
|
||||||
Once,
|
Once,
|
||||||
Many
|
Many
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving(IterBytes)]
|
||||||
impl ToStr for Onceness {
|
impl ToStr for Onceness {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
match *self {
|
match *self {
|
||||||
@ -758,13 +698,7 @@ impl ToStr for Onceness {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for Onceness {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as uint).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub struct TyClosure {
|
pub struct TyClosure {
|
||||||
sigil: Sigil,
|
sigil: Sigil,
|
||||||
region: Option<@Lifetime>,
|
region: Option<@Lifetime>,
|
||||||
@ -779,7 +713,7 @@ pub struct TyClosure {
|
|||||||
bounds: Option<OptVec<TyParamBound>>,
|
bounds: Option<OptVec<TyParamBound>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct TyBareFn {
|
pub struct TyBareFn {
|
||||||
purity: purity,
|
purity: purity,
|
||||||
abis: AbiSet,
|
abis: AbiSet,
|
||||||
@ -787,7 +721,7 @@ pub struct TyBareFn {
|
|||||||
decl: fn_decl
|
decl: fn_decl
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum ty_ {
|
pub enum ty_ {
|
||||||
ty_nil,
|
ty_nil,
|
||||||
ty_bot, /* bottom type */
|
ty_bot, /* bottom type */
|
||||||
@ -808,19 +742,13 @@ pub enum ty_ {
|
|||||||
ty_infer,
|
ty_infer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for Ty {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.span.lo.iter_bytes(lsb0, f) && self.span.hi.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum asm_dialect {
|
pub enum asm_dialect {
|
||||||
asm_att,
|
asm_att,
|
||||||
asm_intel
|
asm_intel
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct inline_asm {
|
pub struct inline_asm {
|
||||||
asm: @str,
|
asm: @str,
|
||||||
clobbers: @str,
|
clobbers: @str,
|
||||||
@ -831,7 +759,7 @@ pub struct inline_asm {
|
|||||||
dialect: asm_dialect
|
dialect: asm_dialect
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct arg {
|
pub struct arg {
|
||||||
is_mutbl: bool,
|
is_mutbl: bool,
|
||||||
ty: @Ty,
|
ty: @Ty,
|
||||||
@ -839,20 +767,21 @@ pub struct arg {
|
|||||||
id: node_id,
|
id: node_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct fn_decl {
|
pub struct fn_decl {
|
||||||
inputs: ~[arg],
|
inputs: ~[arg],
|
||||||
output: @Ty,
|
output: @Ty,
|
||||||
cf: ret_style,
|
cf: ret_style,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum purity {
|
pub enum purity {
|
||||||
unsafe_fn, // declared with "unsafe fn"
|
unsafe_fn, // declared with "unsafe fn"
|
||||||
impure_fn, // declared with "fn"
|
impure_fn, // declared with "fn"
|
||||||
extern_fn, // declared with "extern fn"
|
extern_fn, // declared with "extern fn"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving(IterBytes)]
|
||||||
impl ToStr for purity {
|
impl ToStr for purity {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
match *self {
|
match *self {
|
||||||
@ -863,26 +792,14 @@ impl ToStr for purity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for purity {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as u8).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum ret_style {
|
pub enum ret_style {
|
||||||
noreturn, // functions with return type _|_ that always
|
noreturn, // functions with return type _|_ that always
|
||||||
// raise an error or exit (i.e. never return to the caller)
|
// raise an error or exit (i.e. never return to the caller)
|
||||||
return_val, // everything else
|
return_val, // everything else
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ret_style {
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(*self as u8).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
|
||||||
pub enum explicit_self_ {
|
pub enum explicit_self_ {
|
||||||
sty_static, // no self
|
sty_static, // no self
|
||||||
sty_value, // `self`
|
sty_value, // `self`
|
||||||
@ -891,27 +808,9 @@ pub enum explicit_self_ {
|
|||||||
sty_uniq(mutability) // `~self`
|
sty_uniq(mutability) // `~self`
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for explicit_self_ {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
match *self {
|
|
||||||
sty_static => 0u8.iter_bytes(lsb0, f),
|
|
||||||
sty_value => 1u8.iter_bytes(lsb0, f),
|
|
||||||
sty_region(ref lft, ref mutbl) => {
|
|
||||||
2u8.iter_bytes(lsb0, f) && lft.iter_bytes(lsb0, f) && mutbl.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
sty_box(ref mutbl) => {
|
|
||||||
3u8.iter_bytes(lsb0, f) && mutbl.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
sty_uniq(ref mutbl) => {
|
|
||||||
4u8.iter_bytes(lsb0, f) && mutbl.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type explicit_self = spanned<explicit_self_>;
|
pub type explicit_self = spanned<explicit_self_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct method {
|
pub struct method {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -926,17 +825,17 @@ pub struct method {
|
|||||||
vis: visibility,
|
vis: visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct _mod {
|
pub struct _mod {
|
||||||
view_items: ~[@view_item],
|
view_items: ~[@view_item],
|
||||||
items: ~[@item],
|
items: ~[@item],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Foreign mods can be named or anonymous
|
// Foreign mods can be named or anonymous
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum foreign_mod_sort { named, anonymous }
|
pub enum foreign_mod_sort { named, anonymous }
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct foreign_mod {
|
pub struct foreign_mod {
|
||||||
sort: foreign_mod_sort,
|
sort: foreign_mod_sort,
|
||||||
abis: AbiSet,
|
abis: AbiSet,
|
||||||
@ -944,24 +843,24 @@ pub struct foreign_mod {
|
|||||||
items: ~[@foreign_item],
|
items: ~[@foreign_item],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct variant_arg {
|
pub struct variant_arg {
|
||||||
ty: @Ty,
|
ty: @Ty,
|
||||||
id: node_id,
|
id: node_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum variant_kind {
|
pub enum variant_kind {
|
||||||
tuple_variant_kind(~[variant_arg]),
|
tuple_variant_kind(~[variant_arg]),
|
||||||
struct_variant_kind(@struct_def),
|
struct_variant_kind(@struct_def),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct enum_def {
|
pub struct enum_def {
|
||||||
variants: ~[variant],
|
variants: ~[variant],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct variant_ {
|
pub struct variant_ {
|
||||||
name: ident,
|
name: ident,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -973,7 +872,7 @@ pub struct variant_ {
|
|||||||
|
|
||||||
pub type variant = spanned<variant_>;
|
pub type variant = spanned<variant_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct path_list_ident_ {
|
pub struct path_list_ident_ {
|
||||||
name: ident,
|
name: ident,
|
||||||
id: node_id,
|
id: node_id,
|
||||||
@ -983,7 +882,7 @@ pub type path_list_ident = spanned<path_list_ident_>;
|
|||||||
|
|
||||||
pub type view_path = spanned<view_path_>;
|
pub type view_path = spanned<view_path_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum view_path_ {
|
pub enum view_path_ {
|
||||||
|
|
||||||
// quux = foo::bar::baz
|
// quux = foo::bar::baz
|
||||||
@ -1000,7 +899,7 @@ pub enum view_path_ {
|
|||||||
view_path_list(@Path, ~[path_list_ident], node_id)
|
view_path_list(@Path, ~[path_list_ident], node_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct view_item {
|
pub struct view_item {
|
||||||
node: view_item_,
|
node: view_item_,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -1008,7 +907,7 @@ pub struct view_item {
|
|||||||
span: span,
|
span: span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum view_item_ {
|
pub enum view_item_ {
|
||||||
view_item_extern_mod(ident, ~[@meta_item], node_id),
|
view_item_extern_mod(ident, ~[@meta_item], node_id),
|
||||||
view_item_use(~[@view_path]),
|
view_item_use(~[@view_path]),
|
||||||
@ -1020,11 +919,11 @@ pub type attribute = spanned<attribute_>;
|
|||||||
// Distinguishes between attributes that decorate items and attributes that
|
// Distinguishes between attributes that decorate items and attributes that
|
||||||
// are contained as statements within items. These two cases need to be
|
// are contained as statements within items. These two cases need to be
|
||||||
// distinguished for pretty-printing.
|
// distinguished for pretty-printing.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum attr_style { attr_outer, attr_inner, }
|
pub enum attr_style { attr_outer, attr_inner, }
|
||||||
|
|
||||||
// doc-comments are promoted to attributes that have is_sugared_doc = true
|
// doc-comments are promoted to attributes that have is_sugared_doc = true
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct attribute_ {
|
pub struct attribute_ {
|
||||||
style: attr_style,
|
style: attr_style,
|
||||||
value: @meta_item,
|
value: @meta_item,
|
||||||
@ -1038,13 +937,13 @@ pub struct attribute_ {
|
|||||||
If this impl is an item_impl, the impl_id is redundant (it could be the
|
If this impl is an item_impl, the impl_id is redundant (it could be the
|
||||||
same as the impl's node id).
|
same as the impl's node id).
|
||||||
*/
|
*/
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct trait_ref {
|
pub struct trait_ref {
|
||||||
path: @Path,
|
path: @Path,
|
||||||
ref_id: node_id,
|
ref_id: node_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum visibility { public, private, inherited }
|
pub enum visibility { public, private, inherited }
|
||||||
|
|
||||||
impl visibility {
|
impl visibility {
|
||||||
@ -1056,7 +955,7 @@ impl visibility {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct struct_field_ {
|
pub struct struct_field_ {
|
||||||
kind: struct_field_kind,
|
kind: struct_field_kind,
|
||||||
id: node_id,
|
id: node_id,
|
||||||
@ -1066,13 +965,13 @@ pub struct struct_field_ {
|
|||||||
|
|
||||||
pub type struct_field = spanned<struct_field_>;
|
pub type struct_field = spanned<struct_field_>;
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum struct_field_kind {
|
pub enum struct_field_kind {
|
||||||
named_field(ident, visibility),
|
named_field(ident, visibility),
|
||||||
unnamed_field // element of a tuple-like struct
|
unnamed_field // element of a tuple-like struct
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct struct_def {
|
pub struct struct_def {
|
||||||
fields: ~[@struct_field], /* fields, not including ctor */
|
fields: ~[@struct_field], /* fields, not including ctor */
|
||||||
/* ID of the constructor. This is only used for tuple- or enum-like
|
/* ID of the constructor. This is only used for tuple- or enum-like
|
||||||
@ -1084,7 +983,7 @@ pub struct struct_def {
|
|||||||
FIXME (#3300): Should allow items to be anonymous. Right now
|
FIXME (#3300): Should allow items to be anonymous. Right now
|
||||||
we just use dummy names for anon items.
|
we just use dummy names for anon items.
|
||||||
*/
|
*/
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct item {
|
pub struct item {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -1094,7 +993,7 @@ pub struct item {
|
|||||||
span: span,
|
span: span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum item_ {
|
pub enum item_ {
|
||||||
item_static(@Ty, mutability, @expr),
|
item_static(@Ty, mutability, @expr),
|
||||||
item_fn(fn_decl, purity, AbiSet, Generics, blk),
|
item_fn(fn_decl, purity, AbiSet, Generics, blk),
|
||||||
@ -1112,7 +1011,7 @@ pub enum item_ {
|
|||||||
item_mac(mac),
|
item_mac(mac),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct foreign_item {
|
pub struct foreign_item {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
attrs: ~[attribute],
|
attrs: ~[attribute],
|
||||||
@ -1122,7 +1021,7 @@ pub struct foreign_item {
|
|||||||
vis: visibility,
|
vis: visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum foreign_item_ {
|
pub enum foreign_item_ {
|
||||||
foreign_item_fn(fn_decl, purity, Generics),
|
foreign_item_fn(fn_decl, purity, Generics),
|
||||||
foreign_item_static(@Ty, /* is_mutbl */ bool),
|
foreign_item_static(@Ty, /* is_mutbl */ bool),
|
||||||
@ -1131,7 +1030,7 @@ pub enum foreign_item_ {
|
|||||||
// The data we save and restore about an inlined item or method. This is not
|
// 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
|
// part of the AST that we parse from a file, but it becomes part of the tree
|
||||||
// that we trans.
|
// that we trans.
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub enum inlined_item {
|
pub enum inlined_item {
|
||||||
ii_item(@item),
|
ii_item(@item),
|
||||||
ii_method(def_id /* impl id */, @method),
|
ii_method(def_id /* impl id */, @method),
|
||||||
|
@ -19,7 +19,6 @@ use visit;
|
|||||||
use std::hashmap::HashMap;
|
use std::hashmap::HashMap;
|
||||||
use std::int;
|
use std::int;
|
||||||
use std::option;
|
use std::option;
|
||||||
use std::to_bytes;
|
|
||||||
use std::cast;
|
use std::cast;
|
||||||
use std::local_data;
|
use std::local_data;
|
||||||
|
|
||||||
@ -194,14 +193,6 @@ pub fn is_call_expr(e: @expr) -> bool {
|
|||||||
match e.node { expr_call(*) => true, _ => false }
|
match e.node { expr_call(*) => true, _ => false }
|
||||||
}
|
}
|
||||||
|
|
||||||
// This makes def_id hashable
|
|
||||||
impl to_bytes::IterBytes for def_id {
|
|
||||||
#[inline]
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.crate.iter_bytes(lsb0, f) && self.node.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn block_from_expr(e: @expr) -> blk {
|
pub fn block_from_expr(e: @expr) -> blk {
|
||||||
let blk_ = default_block(~[], option::Some::<@expr>(e), e.id);
|
let blk_ = default_block(~[], option::Some::<@expr>(e), e.id);
|
||||||
return spanned {node: blk_, span: e.span};
|
return spanned {node: blk_, span: e.span};
|
||||||
|
@ -22,7 +22,6 @@ source code snippets, etc.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::to_bytes;
|
|
||||||
use std::uint;
|
use std::uint;
|
||||||
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
|
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
||||||
@ -32,12 +31,12 @@ pub trait Pos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A byte offset
|
/// A byte offset
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq,IterBytes)]
|
||||||
pub struct BytePos(uint);
|
pub struct BytePos(uint);
|
||||||
/// A character offset. Because of multibyte utf8 characters, a byte offset
|
/// A character offset. Because of multibyte utf8 characters, a byte offset
|
||||||
/// is not equivalent to a character offset. The CodeMap will convert BytePos
|
/// is not equivalent to a character offset. The CodeMap will convert BytePos
|
||||||
/// values to CharPos values as necessary.
|
/// values to CharPos values as necessary.
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq,IterBytes)]
|
||||||
pub struct CharPos(uint);
|
pub struct CharPos(uint);
|
||||||
|
|
||||||
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix
|
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix
|
||||||
@ -67,12 +66,6 @@ impl Sub<BytePos, BytePos> for BytePos {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for BytePos {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(**self).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Pos for CharPos {
|
impl Pos for CharPos {
|
||||||
fn from_uint(n: uint) -> CharPos { CharPos(n) }
|
fn from_uint(n: uint) -> CharPos { CharPos(n) }
|
||||||
fn to_uint(&self) -> uint { **self }
|
fn to_uint(&self) -> uint { **self }
|
||||||
@ -85,12 +78,6 @@ impl cmp::Ord for CharPos {
|
|||||||
fn gt(&self, other: &CharPos) -> bool { **self > **other }
|
fn gt(&self, other: &CharPos) -> bool { **self > **other }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for CharPos {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
(**self).iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Add<CharPos,CharPos> for CharPos {
|
impl Add<CharPos,CharPos> for CharPos {
|
||||||
fn add(&self, rhs: &CharPos) -> CharPos {
|
fn add(&self, rhs: &CharPos) -> CharPos {
|
||||||
CharPos(**self + **rhs)
|
CharPos(**self + **rhs)
|
||||||
@ -109,13 +96,14 @@ are *absolute* positions from the beginning of the codemap, not positions
|
|||||||
relative to FileMaps. Methods on the CodeMap can be used to relate spans back
|
relative to FileMaps. Methods on the CodeMap can be used to relate spans back
|
||||||
to the original source.
|
to the original source.
|
||||||
*/
|
*/
|
||||||
|
#[deriving(IterBytes)]
|
||||||
pub struct span {
|
pub struct span {
|
||||||
lo: BytePos,
|
lo: BytePos,
|
||||||
hi: BytePos,
|
hi: BytePos,
|
||||||
expn_info: Option<@ExpnInfo>
|
expn_info: Option<@ExpnInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq, Encodable, Decodable)]
|
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||||
pub struct spanned<T> { node: T, span: span }
|
pub struct spanned<T> { node: T, span: span }
|
||||||
|
|
||||||
impl cmp::Eq for span {
|
impl cmp::Eq for span {
|
||||||
@ -138,14 +126,6 @@ impl<D:Decoder> Decodable<D> for span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for span {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.lo.iter_bytes(lsb0, f) &&
|
|
||||||
self.hi.iter_bytes(lsb0, f) &&
|
|
||||||
self.expn_info.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> spanned<T> {
|
pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> spanned<T> {
|
||||||
respan(mk_sp(lo, hi), t)
|
respan(mk_sp(lo, hi), t)
|
||||||
}
|
}
|
||||||
@ -191,40 +171,21 @@ pub struct LocWithOpt {
|
|||||||
// used to be structural records. Better names, anyone?
|
// used to be structural records. Better names, anyone?
|
||||||
pub struct FileMapAndLine {fm: @FileMap, line: uint}
|
pub struct FileMapAndLine {fm: @FileMap, line: uint}
|
||||||
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
|
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
|
||||||
|
#[deriving(IterBytes)]
|
||||||
pub struct NameAndSpan {name: @str, span: Option<span>}
|
pub struct NameAndSpan {name: @str, span: Option<span>}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for NameAndSpan {
|
#[deriving(IterBytes)]
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.name.iter_bytes(lsb0, f) && self.span.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct CallInfo {
|
pub struct CallInfo {
|
||||||
call_site: span,
|
call_site: span,
|
||||||
callee: NameAndSpan
|
callee: NameAndSpan
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for CallInfo {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
self.call_site.iter_bytes(lsb0, f) && self.callee.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extra information for tracking macro expansion of spans
|
/// Extra information for tracking macro expansion of spans
|
||||||
|
#[deriving(IterBytes)]
|
||||||
pub enum ExpnInfo {
|
pub enum ExpnInfo {
|
||||||
ExpandedFrom(CallInfo)
|
ExpandedFrom(CallInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ExpnInfo {
|
|
||||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
|
||||||
match *self {
|
|
||||||
ExpandedFrom(ref call_info) => {
|
|
||||||
0u8.iter_bytes(lsb0, f) && call_info.iter_bytes(lsb0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type FileName = @str;
|
pub type FileName = @str;
|
||||||
|
|
||||||
pub struct FileLines
|
pub struct FileLines
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use std::vec::VecIterator;
|
use std::vec::VecIterator;
|
||||||
|
|
||||||
#[deriving(Encodable, Decodable)]
|
#[deriving(Encodable, Decodable,IterBytes)]
|
||||||
pub enum OptVec<T> {
|
pub enum OptVec<T> {
|
||||||
Empty,
|
Empty,
|
||||||
Vec(~[T])
|
Vec(~[T])
|
||||||
|
@ -22,7 +22,7 @@ use std::local_data;
|
|||||||
use std::rand;
|
use std::rand;
|
||||||
use std::rand::RngUtil;
|
use std::rand::RngUtil;
|
||||||
|
|
||||||
#[deriving(Encodable, Decodable, Eq)]
|
#[deriving(Encodable, Decodable, Eq, IterBytes)]
|
||||||
pub enum binop {
|
pub enum binop {
|
||||||
PLUS,
|
PLUS,
|
||||||
MINUS,
|
MINUS,
|
||||||
@ -36,7 +36,7 @@ pub enum binop {
|
|||||||
SHR,
|
SHR,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Encodable, Decodable, Eq)]
|
#[deriving(Encodable, Decodable, Eq, IterBytes)]
|
||||||
pub enum Token {
|
pub enum Token {
|
||||||
/* Expression-operator symbols. */
|
/* Expression-operator symbols. */
|
||||||
EQ,
|
EQ,
|
||||||
@ -97,7 +97,7 @@ pub enum Token {
|
|||||||
EOF,
|
EOF,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Encodable, Decodable, Eq)]
|
#[deriving(Encodable, Decodable, Eq, IterBytes)]
|
||||||
/// For interpolation during macro expansion.
|
/// For interpolation during macro expansion.
|
||||||
pub enum nonterminal {
|
pub enum nonterminal {
|
||||||
nt_item(@ast::item),
|
nt_item(@ast::item),
|
||||||
|
Loading…
Reference in New Issue
Block a user