syntex_syntax 0.9.0

Export of libsyntax for code generation
b0VIM 7.4��U�\~ericktErick-Tryzelaar-MBP.local~erickt/projects/rust/rust-syntex/syntex_syntax/src/ast_util.rsutf-8
3210#"! Utp���s�k"mad\��{XU��M)(�
�
�
�
�
�
�
x
w
i
[
Z
)
����a1/.�����uX�
�
�
�
�
o
Y
B
,

�	�	�	�	�	�	s	]	G	3	-	+	*		��������ydO>865���s:'!�����E�������u_K71/.	����G�����{tsc���e_]\^}    }        None => s.to_string()        Some(n) => format!("{}{}", n as u64, s),        // sign.        // are parsed as u64, so we wouldn't want to print an extra negative        // cast to a u64 so we can correctly print INT64_MIN. All integral types    match val {    };        TyI64 => "i64"        TyI32 => "i32",        TyI16 => "i16",        TyI8 => "i8",        TyIs => "isize",    let s = match t {pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {/// We want to avoid "45int" and "-3int" in favor of "45" and "-3"/// Get a string representation of a signed int type, with its value.}    match e.node { ExprPath(..) => true, _ => false }pub fn is_path(e: P<Expr>) -> bool {}    }      UnNeg => "-",      UnNot => "!",      UnDeref => "*",      UnUniq => "box() ",    match op {pub fn unop_to_string(op: UnOp) -> &'static str {}    }        _ => false,        UnNeg | UnNot => true,    match u {pub fn is_by_value_unop(u: UnOp) -> bool {/// Returns `true` if the unary operator takes its argument by value}    !is_comparison_binop(b)pub fn is_by_value_binop(b: BinOp_) -> bool {/// Returns `true` if the binary operator takes its arguments by value}    }            false,        BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr =>        BiAnd | BiOr | BiAdd | BiSub | BiMul | BiDiv | BiRem |            true,        BiEq | BiLt | BiLe | BiNe | BiGt | BiGe =>    match b {pub fn is_comparison_binop(b: BinOp_) -> bool {}    }      _ => false      BiShr => true,      BiShl => true,    match b {pub fn is_shift_binop(b: BinOp_) -> bool {}    }      _ => false      BiOr => true,      BiAnd => true,    match b {pub fn lazy_binop(b: BinOp_) -> bool {}    }        BiGt => ">"        BiGe => ">=",        BiNe => "!=",        BiLe => "<=",        BiLt => "<",        BiEq => "==",        BiShr => ">>",        BiShl => "<<",        BiBitOr => "|",        BiBitAnd => "&",        BiBitXor => "^",        BiOr => "||",        BiAnd => "&&",        BiRem => "%",        BiDiv => "/",        BiMul => "*",        BiSub => "-",        BiAdd => "+",    match op {pub fn binop_to_string(op: BinOp_) -> &'static str {}    }      StmtMac(..) => panic!("attempted to analyze unexpanded stmt")      StmtSemi(_, id) => id,      StmtExpr(_, id) => id,      StmtDecl(_, id) => id,    match s.node {pub fn stmt_id(s: &Stmt) -> NodeId {pub fn is_local(did: ast::DefId) -> bool { did.krate == LOCAL_CRATE }}    ast::DefId { krate: LOCAL_CRATE, node: id }pub fn local_def(id: NodeId) -> DefId {}    idents.iter().map(|i| i.to_string()).collect::<Vec<String>>().connect("::")    // FIXME: Bad copies (#2543 -- same for everything else that says "bad")pub fn path_name_i(idents: &[Ident]) -> String {use std::u32;use std::cmp;use visit;use visit::Visitor;use ptr::P;use print::pprust;use parse::token;use owned_slice::OwnedSlice;use codemap::Span;use codemap;use ast_util;use ast;use ast::*;// 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�
�"�����x\HB@?2&��ga`9�
�
7
��}0�����}    }                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>()));            &[Ident{name:Name(3),ctxt:104}, Ident{name:Name(77),ctxt:182}]                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>(),            &[Ident{name:Name(3),ctxt:4}, Ident{name:Name(78),ctxt:82}]        assert!(!segments_name_eq(                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>()));            &[Ident{name:Name(3),ctxt:104}, Ident{name:Name(78),ctxt:182}]                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>(),            &[Ident{name:Name(3),ctxt:4}, Ident{name:Name(78),ctxt:82}]        assert!(segments_name_eq(    #[test] fn idents_name_eq_test() {    }                     parameters: PathParameters::none()}        PathSegment {identifier: id.clone(),    fn ident_to_segment(id : &Ident) -> PathSegment {    use super::*;    use ast::*;mod tests {#[cfg(test)]}    }        _ => false,        LitStr(..) => true,    match lit.node {pub fn lit_is_str(lit: &Lit) -> bool {/// Returns true if this literal is a string and false otherwise.}    })ad����`<643��bL3�
�
�
�
�
�
v
p
n
m
F
8
"
	
�����l^:
���wfO7�
�
h
8

�	�	�	�	�	�	�	w	B	 				�����~|{<0 �����sQ)

��>���tH%���vc]865������a0#���g@      BiBitOr                   =>  6,      BiBitXor                  =>  7,      BiBitAnd                  =>  8,      BiShl | BiShr             =>  9,      BiAdd | BiSub             => 10,      BiMul | BiDiv | BiRem     => 11,      // 'as' sits here with 12  match op {pub fn operator_prec(op: ast::BinOp_) -> usize {/// Maps a binary operator to its precedence}    }        ast::NamedField(_, v) | ast::UnnamedField(v) => v    match field.node.kind {pub fn struct_field_visibility(field: ast::StructField) -> Visibility {}    token::gensym_ident(&pretty[..])    }        None => {}        }            pretty.push_str(&pprust::path_to_string(&trait_ref.path));            pretty.push('.');        Some(ref trait_ref) => {    match *trait_ref {    };        None => String::from("..")        Some(t) => pprust::ty_to_string(t),    let mut pretty = match ty {pub fn impl_pretty_name(trait_ref: &Option<TraitRef>, ty: Option<&Ty>) -> Ident {/// of the type)./// listed as `__extensions__::method_name::hash`, with no indication/// hint of where they came from, (previously they would all just be/// This is designed so that symbols of `impl`'d methods give some/// Generate a "pretty" name for an `impl` from its type and trait.}               name: name }               span: codemap::DUMMY_SP,    Lifetime { id: DUMMY_NODE_ID,pub fn name_to_dummy_lifetime(name: Name) -> Lifetime {}    })        span: s        node: PatIdent(BindByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None),        id: id,    P(Pat {pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> {}    Some(segment.identifier)    }        return None;    if !segment.parameters.is_empty() {    let segment = &path.segments[0];    }        return None;    if path.segments.len() != 1 {pub fn path_to_ident(path: &Path) -> Option<Ident> {// None.// If path is a single segment ident path, return that ident. Otherwise, return}    }        ),            }                })                    bindings: OwnedSlice::empty(),                    types: OwnedSlice::empty(),                    lifetimes: Vec::new(),                parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {                identifier: identifier,            ast::PathSegment {        segments: vec!(        global: false,        span: s,    ast::Path {pub fn ident_to_path(s: Span, identifier: Ident) -> Path {// 1-segment path// convert a span and an identifier to the corresponding}    }        TyF64 => "f64".to_string(),        TyF32 => "f32".to_string(),    match t {pub fn float_ty_to_string(t: FloatTy) -> String {}    }        TyU64 => 0xffffffffffffffff        TyUs | TyU32 => 0xffffffff, // actually ni about TyUs        TyU16 => 0xffff,        TyU8 => 0xff,    match t {pub fn uint_ty_max(t: UintTy) -> u64 {}    }        None => s.to_string()        Some(n) => format!("{}{}", n, s),    match val {    };        TyU64 => "u64"        TyU32 => "u32",        TyU16 => "u16",        TyU8 => "u8",        TyUs => "usize",    let s = match t {pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {/// We want to avoid "42u" in favor of "42us". "42uint" is right out./// Get a string representation of an unsigned int type, with its value.}    }        TyI64 => 0x8000000000000000        TyIs | TyI32 => 0x80000000, // actually ni about TyIs        TyI16 => 0x8000,        TyI8 => 0x80,    match t {pub fn int_ty_max(t: IntTy) -> u64 {ad3���{yx8�����vR3�
�
�
�
�
�
E
0




������~}[>87������_]\�
�
�

}
|
H
	
�	�	�	`	&					���vR(����QKJ����vh^]3���uA�����O������rqJDC�����a:432    }        visit::walk_block(self, block)        self.operation.visit_id(block.id);    fn visit_block(&mut self, block: &Block) {    }        visit::walk_local(self, local)        self.operation.visit_id(local.id);    fn visit_local(&mut self, local: &Local) {    }        self.visited_outermost = false        visit::walk_item(self, item);        }            _ => {}            }                }                    self.operation.visit_id(variant.node.id)                for variant in &enum_definition.variants {            ItemEnum(ref enum_definition, _) => {            }                }                    }                        }                            self.operation.visit_id(path.node.id())                        for path in paths {                    ViewPathList(_, ref paths) => {                    ViewPathGlob(_) => {}                    ViewPathSimple(_, _) |                match view_path.node {            ItemUse(ref view_path) => {        match item.node {        self.operation.visit_id(item.id);        }            }                self.visited_outermost = true            } else {                return            if self.visited_outermost {        if !self.pass_through_items {    fn visit_item(&mut self, item: &Item) {    }        visit::walk_foreign_item(self, foreign_item)        self.operation.visit_id(foreign_item.id);    fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {    }        visit::walk_mod(self, module)        self.operation.visit_id(node_id);                 node_id: NodeId) {                 _: Span,                 module: &Mod,    fn visit_mod(&mut self,impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {}    }        }            self.operation.visit_id(lifetime.lifetime.id)        for lifetime in &generics.lifetimes {        }            self.operation.visit_id(type_parameter.id)        for type_parameter in generics.ty_params.iter() {    fn visit_generics_helper(&mut self, generics: &Generics) {impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> {}    pub visited_outermost: bool,    pub pass_through_items: bool,    pub operation: &'a mut O,pub struct IdVisitor<'a, O:'a> {/// in a visitable thing./// A visitor that applies its operation to all of the node IDs}    fn visit_id(&mut self, node_id: NodeId);pub trait IdVisitingOperation {}    }        self.max = cmp::max(self.max, id + 1);        self.min = cmp::min(self.min, id);    pub fn add(&mut self, id: NodeId) {    }        self.min >= self.max    pub fn empty(&self) -> bool {    }        }            max: u32::MIN,            min: u32::MAX,        IdRange {    pub fn max() -> IdRange {impl IdRange {}    pub max: NodeId,    pub min: NodeId,pub struct IdRange {#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]// Enumerating the IDs which appear in an AST// ______________________________________________________________________}    }        }            predicates: Vec::new(),            id: DUMMY_NODE_ID,        where_clause: WhereClause {        ty_params: OwnedSlice::empty(),        lifetimes: Vec::new(),    Generics {pub fn empty_generics() -> Generics {pub const AS_PREC: usize = 12;/// not appearing in the prior table./// Precedence of the `as` operator, which is a binary operator}  }      BiOr                      =>  1      BiAnd                     =>  2,      BiLt | BiLe | BiGe | BiGt | BiEq | BiNe => 3,ad(s��f`_2����uJDC�
�
�
�
�
d
7
1
0

���sP*�yaSIH�
�
�
�
V


�	�	�	�	x	n	m	P	*	�����a1#��c]\9	���l �����[UT�����ZTS����uE?=<��z\:    };        visited_outermost: false,        pass_through_items: true,        operation: operation,    let mut id_visitor = IdVisitor {                                                          operation: &mut O) {pub fn visit_ids_for_inlined_item<O: IdVisitingOperation>(item: &InlinedItem,}    }        visit::walk_trait_ref(self, trait_ref);        self.operation.visit_id(trait_ref.ref_id);    fn visit_trait_ref(&mut self, trait_ref: &TraitRef) {    }        self.visit_lifetime_ref(&def.lifetime);    fn visit_lifetime_def(&mut self, def: &LifetimeDef) {    }        self.operation.visit_id(lifetime.id);    fn visit_lifetime_ref(&mut self, lifetime: &Lifetime) {    }        visit::walk_impl_item(self, ii);        self.operation.visit_id(ii.id);    fn visit_impl_item(&mut self, ii: &ast::ImplItem) {    }        visit::walk_trait_item(self, ti);        self.operation.visit_id(ti.id);    fn visit_trait_item(&mut self, ti: &ast::TraitItem) {    }        visit::walk_struct_def(self, struct_def);        struct_def.ctor_id.map(|ctor_id| self.operation.visit_id(ctor_id));        self.operation.visit_id(id);                        id: NodeId) {                        _: &ast::Generics,                        _: ast::Ident,                        struct_def: &StructDef,    fn visit_struct_def(&mut self,    }        visit::walk_struct_field(self, struct_field)        self.operation.visit_id(struct_field.node.id);    fn visit_struct_field(&mut self, struct_field: &StructField) {    }        }            }                self.visited_outermost = false;            if let visit::FkMethod(..) = function_kind {        if !self.pass_through_items {                       span);                       block,                       function_declaration,                       function_kind,        visit::walk_fn(self,        }            self.operation.visit_id(argument.id)        for argument in &function_declaration.inputs {        }            visit::FkFnBlock => {}            }                self.visit_generics_helper(&sig.generics)            visit::FkMethod(_, sig, _) => {            }                self.visit_generics_helper(generics)            visit::FkItemFn(_, generics, _, _, _, _) => {        match function_kind {        self.operation.visit_id(node_id);        }            }                _ => {}                visit::FkMethod(..) => self.visited_outermost = true,                visit::FkMethod(..) if self.visited_outermost => return,            match function_kind {        if !self.pass_through_items {                node_id: NodeId) {                span: Span,                block: &'v Block,                function_declaration: &'v FnDecl,                function_kind: visit::FnKind<'v>,    fn visit_fn(&mut self,    }        visit::walk_generics(self, generics)        self.visit_generics_helper(generics);    fn visit_generics(&mut self, generics: &Generics) {    }        visit::walk_ty(self, typ)        self.operation.visit_id(typ.id);    fn visit_ty(&mut self, typ: &Ty) {    }        visit::walk_expr(self, expression)        self.operation.visit_id(expression.id);    fn visit_expr(&mut self, expression: &Expr) {    }        visit::walk_pat(self, pattern)        self.operation.visit_id(pattern.id);    fn visit_pat(&mut self, pattern: &Pat) {    }        visit::walk_stmt(self, statement)        self.operation.visit_id(ast_util::stmt_id(statement));    fn visit_stmt(&mut self, statement: &Stmt) {ad�k�������X/
	��pi5" �
�
n
<

���}^W2����trq!�
�
j
P
F
E
,
�	�	t	f	-	�����H
���9�������oml����\C�������M���igf$���a���        s.parameters == t.parameters        // can types contain idents?        // FIXME #7743: ident -> name problems in lifetime comparison?        s.identifier.name == t.identifier.name &&    a.iter().zip(b).all(|(s, t)| {    a.len() == b.len() &&pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> bool {// are two arrays of segments equal when compared unhygienically?}    && (segments_name_eq(&a.segments[..], &b.segments[..]))    && (a.global == b.global)    (a.span == b.span)pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool {// to compare the span, global, etc. fields as well.// since I'm using this to replace ==, it seems appropriate// are two paths equal when compared unhygienically?}    }        _ => false,        ast::PatIdent(..) => true,    match pat.node {pub fn pat_is_ident(pat: P<ast::Pat>) -> bool {/// and false otherwise./// Returns true if the given pattern consists solely of an identifier}    struct_def.ctor_id.is_some()pub fn struct_def_is_tuple_like(struct_def: &ast::StructDef) -> bool {/// are unnamed./// Returns true if the given struct def is tuple-like; i.e. that its fields}    walk_pat_(pat, &mut it)    }        }            }                true            PatEnum(_, _) | PatQPath(_, _) => {            PatWild(_) | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |            PatMac(_) => panic!("attempted to analyze unexpanded pattern"),            }                after.iter().all(|p| walk_pat_(&**p, it))                slice.iter().all(|p| walk_pat_(&**p, it)) &&                before.iter().all(|p| walk_pat_(&**p, it)) &&            PatVec(ref before, ref slice, ref after) => {            }                walk_pat_(&**s, it)            PatBox(ref s) | PatRegion(ref s, _) => {            }                s.iter().all(|p| walk_pat_(&**p, it))            PatEnum(_, Some(ref s)) | PatTup(ref s) => {            }                fields.iter().all(|field| walk_pat_(&*field.node.pat, it))            PatStruct(_, ref fields, _) => {            PatIdent(_, _, Some(ref p)) => walk_pat_(&**p, it),        match pat.node {        }            return false;        if !(*it)(pat) {    fn walk_pat_<G>(pat: &Pat, it: &mut G) -> bool where G: FnMut(&Pat) -> bool {    // FIXME(#19596) this is a workaround, but there should be a better waypub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool where F: FnMut(&Pat) -> bool {}    id_visitor.operation.result    id_visitor.visit_fn(fk, decl, body, sp, id);    };        visited_outermost: false,        pass_through_items: false,        operation: &mut visitor,    let mut id_visitor = IdVisitor {    };        result: IdRange::max()    let mut visitor = IdRangeComputingVisitor {{                                    -> IdRange                                    id: NodeId)                                    sp: Span,                                    body: &Block,                                    decl: &FnDecl,pub fn compute_id_range_for_fn_body(fk: visit::FnKind,/// Computes the id range for a single fn body, ignoring nested items.}    visitor.result    visit_ids_for_inlined_item(item, &mut visitor);    };        result: IdRange::max()    let mut visitor = IdRangeComputingVisitor {pub fn compute_id_range_for_inlined_item(item: &InlinedItem) -> IdRange {}    }        self.result.add(id);    fn visit_id(&mut self, id: NodeId) {impl IdVisitingOperation for IdRangeComputingVisitor {}    result: IdRange,struct IdRangeComputingVisitor {}    visit::walk_inlined_item(&mut id_visitor, item);