syntex_syntax 0.11.0

Export of libsyntax for code generation
b0VIM 7.4���U�ϣY�ericktErick-Tryzelaar-MBP.local~erickt/projects/rust/rust-syntex/syntex_syntax/src/attr.rsutf-8	3210#"! Utp+J,xui�dV`�	`*zadr	:
+�{XU��M)(�
�
�
�
�
�
�
<

���h.�����mkjE"�
�
�
t
:
,
�	�	

�	�	�	z	]		�������~:���|I�����P �����^>8������oH.�����W=����t^TNM
�        match self.node {    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {    }        }            _ => None            },                }                    _ => None,                    ast::LitStr(ref s, _) => Some((*s).clone()),                match v.node {            MetaNameValue(_, ref v) => {        match self.node {    fn value_str(&self) -> Option<InternedString> {    }        }            MetaList(ref n, _) => (*n).clone(),            MetaNameValue(ref n, _) => (*n).clone(),            MetaWord(ref n) => (*n).clone(),        match self.node {    fn name(&self) -> InternedString {impl AttrMetaMethods for MetaItem {}    fn span(&self) -> Span { self.meta().span }    }        self.node.value.meta_item_list()    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {    }        self.meta().value_str()    fn value_str(&self) -> Option<InternedString> {    fn name(&self) -> InternedString { self.meta().name() }    }        matches        }            mark_used(self);        if matches {        let matches = name == &self.name()[..];    fn check_name(&self, name: &str) -> bool {impl AttrMetaMethods for Attribute {}    fn span(&self) -> Span;    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]>;    /// Gets a list of inner meta items from a list MetaItem type.    fn value_str(&self) -> Option<InternedString>;    /// containing a string, otherwise None.    /// Gets the string value if self is a MetaNameValue variant    fn name(&self) -> InternedString;    /// `#[foo="bar"]` and `#[foo(bar)]`    /// Retrieve the name of the meta item, e.g. `foo` in `#[foo]`,    }        name == &self.name()[..]    fn check_name(&self, name: &str) -> bool {pub trait AttrMetaMethods {}    })            .unwrap_or(false)        slot.borrow().get(idx).map(|bits| bits & (1 << shift) != 0)        let shift = id % 64;        let idx = (id / 64) as usize;    USED_ATTRS.with(|slot| {    let At                   }                slot.borrow_mut().a            }                slot.borrow_mut            }                (slot.borrow().len() .. idx).map(|_| 0));            slot.borrow_mut().extend(        if slot.borrow().len() <= idx {        let shift = id % 64;        let idx = (id / 64) as usize;    USED_ATTRS.with(|slot| {    let AttrId(id) = attr.node.id;pub fn mark_used(attr: &Attribute) {}    static USED_ATTRS: RefCell<Vec<u64>> = RefCell::new(Vec::new())thread_local! {use std::fmt;use std::collections::HashSet;use std::cell::{RefCell, Cell};use ptr::P;use parse::token;use parse::token::{InternedString, intern_and_get_ident};use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};use feature_gate::GatedCfg;use diagnostic::SpanHandler;use codemap::BytePos;use codemap::{Span, Spanned, spanned, dummy_spanned};use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};use ast;pub use self::IntType::*;pub use self::ReprAttr::*;pub use self::StabilityLevel::*;// Functions dealing with attributes and meta items// except according to those terms.// option. This file may not be copied, modified, or distributed// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or//// http://rust-lang.org/COPYRIGHT.// file at the top-level directory of this distribution and at// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHTad�*�������{eG�������N; �
�
�
�
�
a
W
Q
.

��a�����}    }        }            SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false            SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true,            SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) |            SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) |            SignedInt(ast::TyI8) | UnsignedInt(ast::TyU8) |        match self {    fn is_ffi_safe(self) -> bool {    }        }            UnsignedInt(..) => false            SignedInt(..) => true,        match self {    pub fn is_signed(self) -> bool {    #[inline]impl IntType {}    UnsignedInt(ast::UintTy)    SignedInt(ast::IntTy),pub enum IntType {#[derive(Eq, Hash, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)]}    }        }            ReprSimd => true,            ReprPacked => false,            ReprExtern => true,            ReprInt(_sp, ity) => ity.is_ffi_safe(),            ReprAny => false,        match *self {    pub fn is_ffi_safe(&self) -> bool {impl ReprAttr {}    ReprSimd,    ReprPacked,    ReprExtern,    ReprInt(Span, IntType),ad^�J������oR,������X710�
�
�
�
[
.
��vuYWV1������D�
�
�
~
x
H
F
E
!
�	�	�	~	N	D	>	=			���fG5&���p        match self.node {    fn meta_item_list<'a        match self.node {    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {    }        }            _ => None            },                }                    _ => None,                    ast::LitStr(ref s, _) => Some((*s).clone()),                match v.node {            MetaNameValue(_, ref v) => {        match self.node {    fn value_str(&self) -> Option<InternedString> {    }        }            MetaList(ref n, _) => (*n).clone(),            MetaNameValue(ref n, _) => (*n).clone(),            MetaWord(ref n) => (*n).clone(),        match self.node {    fn name(&self) -> InternedString {impl AttrMetaMethods for MetaItem {}    fn span(&self) -> Span { self.meta().span }    }        self.node.value.meta_item_list()    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {    }        self.meta().value_str()    fn value_str(&self) -> Option<InternedString> {    fn name(&self) -> InternedString { self.meta().name() }    }        matches        }            mark_used(self);        if matches {        let matches = name == &self.name()[..];    fn check_name(&self, name: &str) -> bool {impl AttrMetaMethods for Attribute {}    fn span(&self) -> Span;    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]>;    /// Gets a list of inner meta items from a list MetaItem type.    fn value_str(&self) -> Option<InternedString>;    /// containing a string, otherwise None.    /// Gets the string value if self is a MetaNameValue variant    fn name(&self) -> InternedString;    /// `#[foo="bar"]` and `#[foo(bar)]`    /// Retrieve the name of the meta item, e.g. `foo` in `#[foo]`,    }        name == &self.name()[..]    fn check_name(&self, name: &str) -> bool {pub trait AttrMetaMethods {}    })            .unwrap_or(false)        slot.borrow().get(idx).map(|bits| bits & (1 << shift) != 0)        let shift = id % 64;        let idx = (id / 64) as usize;    USED_ATTRS.with(|slot| {    let AttrId(id) = attr.node.id;pub fn is_used(attr: &Attribute) -> bool {}    });        slot.borrow_mut()[idx] |= 1 << shift;        }adx�����~L%��^<6�
�
�
_
]
\
6
�����n*���}H�
�
}
J

�	�	�	�	�	�	�	�	�	p	o	$	�����B����ca`%�����rV=3+���rS>��~nO:��uK	���|E(!}    spanned(lo, hi, attr)    };        is_sugared_doc: true                                               lit))),        value: P(spanned(lo, hi, MetaNameValue(InternedString::new("doc"),        style: style,        id: id,    let attr = Attribute_ {    let lit = spanned(lo, hi, ast::LitStr(text, ast::CookedStr));    let style = doc_comment_style(&text);                           -> Attribute {                           hi: BytePos)pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos,}    })        is_sugared_doc: false,        value: item,        style: ast::AttrOuter,        id: id,    dummy_spanned(Attribute_ {pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {/// Returns an outer attribute with the given value.}    })        is_sugared_doc: false,        value: item,        style: ast::AttrInner,        id: id,    dummy_spanned(Attribute_ {pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {/// Returns an inner attribute with the given value.}    AttrId(id)    });        r        slot.set(r + 1);        let r = slot.get();    let id = NEXT_ATTR_ID.with(|slot| {pub fn mk_attr_id() -> AttrId {thread_local! { static NEXT_ATTR_ID: Cell<usize> = Cell::new(0) }}    P(dummy_spanned(MetaWord(name)))pub fn mk_word_item(name: InternedString) -> P<MetaItem> {}    P(dummy_spanned(MetaList(name, items)))pub fn mk_list_item(name: InternedString, items: Vec<P<MetaItem>>) -> P<MetaItem> {}    P(dummy_spanned(MetaNameValue(name, value)))                          -> P<MetaItem> {pub fn mk_name_value_item(name: InternedString, value: ast::Lit)}    mk_name_value_item(name, value_lit)    let value_lit = dummy_spanned(ast::LitStr(value, ast::CookedStr));                              -> P<MetaItem> {pub fn mk_name_value_item_str(name: InternedString, value: InternedString)/* Constructors */}    }        }            f(self)        } else {            }                f(&mk_attr_inner(self.node.id, meta))            } else {                f(&mk_attr_outer(self.node.id, meta))            if self.node.style == ast::AttrOuter {                        &comment)));                token::intern_and_get_ident(&strip_doc_comment_decoration(                InternedString::new("doc"),            let meta = mk_name_value_item_str(            let comment = self.value_str().unwrap();        if self.node.is_sugared_doc {    {        F: FnOnce(&Attribute) -> T,    fn with_desugared_doc<T, F>(&self, f: F) -> T where    /// non-sugared doc attributes.)    /// comment like `///` or `/** */`. (Returns self unchanged for    /// Convert self to a normal #[doc="foo"] comment, if it is a    }        &*self.node.value    fn meta<'a>(&'a self) -> &'a MetaItem {    /// Extract the MetaItem from inside this Attribute.impl AttributeMethods for Attribute {}        F: FnOnce(&Attribute) -> T;    fn with_desugared_doc<T, F>(&self, f: F) -> T where    fn meta<'a>(&'a self) -> &'a MetaItem;pub trait AttributeMethods {}    fn span(&self) -> Span { (**self).span() }    }        (**self).meta_item_list()    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {    fn value_str(&self) -> Option<InternedString> { (**self).value_str() }    fn name(&self) -> InternedString { (**self).name() }impl AttrMetaMethods for P<MetaItem> {// Annoying, but required to get test_cfg to work}    fn span(&self) -> Span { self.span }    }        }            _ => None            MetaList(_, ref l) => Some(&l[..]),ad�i��q6���iHA?>�
�
�
q
S
L
J
I

���ged����hfeED�
�
�
�
_
%
$
�	�	�	s	a	B	��������T�pH���m.����������trq)��Q,����kJ$��c<���                    InlineAttr::Never                } else if contains_name(&items[..], "never") {                    InlineAttr::Always                } else if contains_name(&items[..], "always") {                    InlineAttr::None                    diagnostic.map(|d|{ d.span_err(attr.span, "expected one argument"); });                if items.len() != 1 {                mark_used(attr);            MetaList(ref n, ref items) if *n == "inline" => {            }                InlineAttr::Hint                mark_used(attr);            MetaWord(ref n) if *n == "inline" => {        match attr.node.value.node {    attrs.iter().fold(InlineAttr::None, |ia,attr| {    // FIXME (#2809)---validate the usage of #[inline] and #[inline]pub fn find_inline_attr(diagnostic: Option<&SpanHandler>, attrs: &[Attribute]) -> InlineAttr {/// Determine what `#[inline]` attribute is present in `attrs`, if any.}    Never,    Always,    Hint,    None,pub enum InlineAttr {#[derive(Copy, Clone, PartialEq)]}    })        }            ia        } else {            }                None                diag.handler.help("use #[export_name=\"*\"]");                diag.span_err(attr.span, "export_name attribute has invalid format");            } else {                s            if let s@Some(_) = attr.value_str() {        if attr.check_name("export_name") {    attrs.iter().fold(None, |ia,attr| {pub fn find_export_name_attr(diag: &SpanHandler, attrs: &[Attribute]) -> Option<InternedString> {/// Find the value of #[export_name=*] attribute and check its validity.}    first_attr_value_str_by_name(attrs, "crate_name")pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> {}    })).collect()        }            span: span            },                _ => node                MetaList(n, mis) => MetaList(n, sort_meta_items(mis)),            node: match node {        Spanned {    v.into_iter().map(|(_, m)| m.map(|Spanned {node, span}| {    // There doesn't seem to be a more optimal way to do this    v.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b));        .collect::<Vec<(InternedString, P<MetaItem>)>>();        .map(|mi| (mi.name(), mi))    let mut v = items.into_iter()    // human-readable strings.    // This is sort of stupid here, but we need to sort bypub fn sort_meta_items(items: Vec<P<MetaItem>>) -> Vec<P<MetaItem>> {/* Higher-level applications */}         .and_then(|i| i.value_str())         .find(|mi| mi.check_name(name))         .rev()    items.iter()                                     -> Option<InternedString> {pub fn last_meta_item_value_str_by_name(items: &[P<MetaItem>], name: &str)}        .and_then(|at| at.value_str())        .find(|at| at.check_name(name))    attrs.iter()                                 -> Option<InternedString> {pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str)}    })        item.check_name(name)        debug!("  testing: {}", item.name());    metas.iter().any(|item| {    debug!("attr::contains_name (name={})", name);pub fn contains_name<AM: AttrMetaMethods>(metas: &[AM], name: &str) -> bool {}    })        item.node == needle.node        debug!("  testing: {}", item.name());    haystack.iter().any(|item| {    debug!("attr::contains (name={})", needle.name());pub fn contains(haystack: &[P<MetaItem>], needle: &MetaItem) -> bool {/// span included in the `==` comparison a plain MetaItem./// comparison. This is slightly subtle, and relies on ignoring the/// Check if `needle` occurs in `haystack` by a structural/* Searching */ad�d��dRD0&��v?�
�
x
3

��?���7�
�
�
;
)

�	�	�	�	{	y	x	?	����tB����vtsO�������W60.-��S��\[;��~_^����Z6��                            match meta.value_str() {                        "feature" => {                    match &*meta.name() {                for meta in metas {                let mut issue = None;                let mut reason = None;                let mut since = None;                let mut feature = None;            Some(metas) => {        let (feature, since, reason, issue) = match attr.meta_item_list() {        used_attrs.push(attr);        }            continue // not a stability level        if tag != "deprecated" && tag != "unstable" && tag != "stable" {        let tag = &tag[..];        let tag = attr.name();    'outer: for attr in attrs {    let mut used_attrs: Vec<&'a AM> = vec![];    let mut deprecated: Option<(Option<InternedString>, Option<InternedString>)> = None;    let mut stab: Option<Stability> = None;                             -> (Option<Stability>, Vec<&'a AM>) {                             (diagnostic: &SpanHandler, attrs: I, item_sp: Span)                              I: Iterator<Item=&'a AM>>                              AM: AttrMetaMethods,fn find_stability_generic<'a,}    }        fmt::Debug::fmt(self, f)    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {impl fmt::Display for StabilityLevel {}    Stable,    Unstable,pub enum StabilityLevel {#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Debug, Copy, Eq, Hash)]/// The available stability levels.}    pub issue: Option<u32>    // The relevant rust-lang issue    pub reason: Option<InternedString>,    // reason for deprecation.    // The reason for the current stability level. If deprecated, the    pub deprecated_since: Option<InternedString>,    pub since: Option<InternedString>,    pub feature: InternedString,    pub level: StabilityLevel,pub struct Stability {#[derive(RustcEncodable, RustcDecodable, Clone, Debug, PartialEq, Eq, Hash)]/// Represents the #[deprecated] and friends attributes.}    }        }            contains(cfgs, cfg)            feature_gated_cfgs.extend(GatedCfg::gate(cfg));        ast::MetaWord(_) | ast::MetaNameValue(..) => {        },            false            diagnostic.span_err(cfg.span, &format!("invalid predicate `{}`", pred));        ast::MetaList(ref pred, _) => {        }            !cfg_matches(diagnostic, cfgs, &*mis[0], feature_gated_cfgs)            }                return false;                diagnostic.span_err(cfg.span, "expected 1 cfg-pattern");            if mis.len() != 1 {        ast::MetaList(ref pred, ref mis) if &pred[..] == "not" => {            mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi, feature_gated_cfgs)),        ast::MetaList(ref pred, ref mis) if &pred[..] == "all" =>            mis.iter().any(|mi| cfg_matches(diagnostic, cfgs, &**mi, feature_gated_cfgs)),        ast::MetaList(ref pred, ref mis) if &pred[..] == "any" =>    match cfg.node {                   feature_gated_cfgs: &mut Vec<GatedCfg>) -> bool {pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::MetaItem,/// Tests if a cfg-pattern matches the cfg set}    }        InlineAttr::None | InlineAttr::Never => false,        InlineAttr::Hint | InlineAttr::Always => true,    match find_inline_attr(None, attrs) {pub fn requests_inline(attrs: &[Attribute]) -> bool {/// True if `#[inline]` or `#[inline(always)]` is present in `attrs`.}    })        }            _ => ia            }                }                    InlineAttr::None                    diagnostic.map(|d|{ d.span_err((*items[0]).span, "invalid argument"); });                } else {ad�`��=����T�
�
^
<


��lB���rX3�
�
{
 
�	�	�	�	q	[	I			���vkj3�����P��gYX4�����r'	����rL�������rT?����p����        }            }                                              either stable or unstable attribute");                diagnostic.span_err(item_sp, "deprecated attribute must be paired with \            None => {            }                s.reason = reason;                s.deprecated_since = since;                let (since, reason) = deprecated.unwrap();            Some(ref mut s) => {        match stab {    if deprecated.is_some() {    // Merge the deprecation info into the stability info    }        }            deprecated = Some((since, reason));            }                diagnostic.span_err(item_sp, "multiple deprecated attributes");            if deprecated.is_some() {        } else { // "deprecated"            });                issue: issue,                reason: reason,                deprecated_since: None,                since: since,                feature: feature.unwrap_or(intern_and_get_ident("bogus")),                level: level,            stab = Some(Stability {            };                _ => unreachable!()                "stable" => Stable,                "unstable" => Unstable,            let level = match tag {            }                diagnostic.span_err(item_sp, "multiple stability levels");            if stab.is_some() {        if tag == "unstable" || tag == "stable" {        }            diagnostic.span_err(attr.span(), "missing 'since'");        if since == None && tag != "unstable" {        // Unstable tags don't require a version        }            diagnostic.span_err(attr.span(), "missing 'feature'");        if feature == None && tag != "deprecated" {        // Deprecated tags don't require feature names        };            }                continue                diagnostic.span_err(attr.span(), "incorrect stability attribute type");            None => {            }                (feature, since, reason, issue)                }                    }                        _ => {}                        }                            }                                }                                    continue 'outer;                                    diagnostic.span_err(meta.span, "incorrect meta item");                                None => {                                Some(v) => issue = Some(v),                            match meta.value_str().and_then(|s| s.parse().ok()) {                        "issue" => {                        }                            }                                }                                    continue 'outer;                                    diagnostic.span_err(meta.span, "incorrect meta item");                                None => {                                Some(v) => reason = Some(v),                            match meta.value_str() {                        "reason" => {                        }                            }                                }                                    continue 'outer;                                    diagnostic.span_err(meta.span, "incorrect meta item");                                None => {                                Some(v) => since = Some(v),                            match meta.value_str() {                        "since" => {                        }                            }                                }                                    continue 'outer;                                    diagnostic.span_err(meta.span, "incorrect meta item");                                None => {                                Some(v) => feature = Some(v),ad�`�d?�������Q�
�
X
J
H
G
�����vB��������u'�
�
S
5

�	�	�	x	G		��J��]�~U3����x^H%����tc]USR ���Z,���o>,&$#����    ReprAny,pub enum ReprAttr {#[derive(PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)]}    }        _ => None        "usize" => Some(UnsignedInt(ast::TyUs)),        "isize" => Some(SignedInt(ast::TyIs)),        "u64" => Some(UnsignedInt(ast::TyU64)),        "i64" => Some(SignedInt(ast::TyI64)),        "u32" => Some(UnsignedInt(ast::TyU32)),        "i32" => Some(SignedInt(ast::TyI32)),        "u16" => Some(UnsignedInt(ast::TyU16)),        "i16" => Some(SignedInt(ast::TyI16)),        "u8" => Some(UnsignedInt(ast::TyU8)),        "i8" => Some(SignedInt(ast::TyI8)),    match s {fn int_type_of_word(s: &str) -> Option<IntType> {}    acc    }        _ => { }        // Not a "repr" hint: ignore.        }            }                }                    _ => diagnostic.span_err(item.span, "unrecognized enum representation hint")                    // Not a word:                    }                        }                            None => { }                            Some(h) => acc.push(h),                        match hint {                        };                            }                                }                                    None                                                        "unrecognized representation hint");                                    diagnostic.span_err(item.span,                                    // Not a word we recognize                                None => {                                Some(ity) => Some(ReprInt(item.span, ity)),                            _ => match int_type_of_word(&word) {                            "simd" => Some(ReprSimd),                            "packed" => Some(ReprPacked),                            "C" => Some(ReprExtern),                            // Can't use "extern" because it's not a lexical identifier.                        let hint = match &word[..] {                    ast::MetaWord(ref word) => {                match item.node {            for item in items {            mark_used(attr);        ast::MetaList(ref s, ref items) if *s == "repr" => {    match attr.node.value.node {    let mut acc = Vec::new();pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAttr> {/// structure layout, and `packed` to remove padding./// the same discriminant size that the corresponding C enum would or C/// `int_type_of_word`, below) to specify enum discriminant type; `C`, to use/// Valid repr contents: any of the primitive integral type names (see////// Parse #[repr(...)] forms.}    }        }                                  &format!("duplicate meta item `{}`", name)));            panic!(diagnostic.span_fatal(meta.span,        if !set.insert(name.clone()) {        let name = meta.name();    for meta in metas {    let mut set = HashSet::new();pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[P<MetaItem>]) {}    return s;    for used in used { mark_used(used) }    let (s, used) = find_stability_generic(diagnostic, attrs.iter(), item_sp);                      item_sp: Span) -> Option<Stability> {pub fn find_stability(diagnostic: &SpanHandler, attrs: &[Attribute],/// Find the first stability attribute. `None` if none exists.}    (stab, used_attrs)    }                             to an issue with `issue = \"NNN\"`");                            "non-deprecated unstable items need to point \        diagnostic.span_err(item_sp,        // non-deprecated unstable items need to point to issues.    } else if stab.as_ref().map_or(false, |s| s.level == Unstable && s.issue.is_none()) {