syntax: Move the AST from @T to Gc<T>
This commit is contained in:
@@ -21,7 +21,7 @@ use visit;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::cmp;
|
||||
use std::string::String;
|
||||
use std::gc::Gc;
|
||||
use std::u32;
|
||||
|
||||
pub fn path_name_i(idents: &[Ident]) -> String {
|
||||
@@ -93,7 +93,7 @@ pub fn is_shift_binop(b: BinOp) -> bool {
|
||||
|
||||
pub fn unop_to_str(op: UnOp) -> &'static str {
|
||||
match op {
|
||||
UnBox => "@",
|
||||
UnBox => "box(GC) ",
|
||||
UnUniq => "box() ",
|
||||
UnDeref => "*",
|
||||
UnNot => "!",
|
||||
@@ -101,7 +101,7 @@ pub fn unop_to_str(op: UnOp) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_path(e: @Expr) -> bool {
|
||||
pub fn is_path(e: Gc<Expr>) -> bool {
|
||||
return match e.node { ExprPath(_) => true, _ => false };
|
||||
}
|
||||
|
||||
@@ -181,11 +181,11 @@ pub fn float_ty_to_str(t: FloatTy) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_call_expr(e: @Expr) -> bool {
|
||||
pub fn is_call_expr(e: Gc<Expr>) -> bool {
|
||||
match e.node { ExprCall(..) => true, _ => false }
|
||||
}
|
||||
|
||||
pub fn block_from_expr(e: @Expr) -> P<Block> {
|
||||
pub fn block_from_expr(e: Gc<Expr>) -> P<Block> {
|
||||
P(Block {
|
||||
view_items: Vec::new(),
|
||||
stmts: Vec::new(),
|
||||
@@ -210,8 +210,8 @@ pub fn ident_to_path(s: Span, identifier: Ident) -> Path {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> @Pat {
|
||||
@ast::Pat { id: id,
|
||||
pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> Gc<Pat> {
|
||||
box(GC) ast::Pat { id: id,
|
||||
node: PatIdent(BindByValue(MutImmutable), ident_to_path(s, i), None),
|
||||
span: s }
|
||||
}
|
||||
@@ -229,7 +229,7 @@ pub fn is_unguarded(a: &Arm) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unguarded_pat(a: &Arm) -> Option<Vec<@Pat> > {
|
||||
pub fn unguarded_pat(a: &Arm) -> Option<Vec<Gc<Pat>>> {
|
||||
if is_unguarded(a) {
|
||||
Some(/* FIXME (#2543) */ a.pats.clone())
|
||||
} else {
|
||||
@@ -254,7 +254,7 @@ pub fn impl_pretty_name(trait_ref: &Option<TraitRef>, ty: &Ty) -> Ident {
|
||||
token::gensym_ident(pretty.as_slice())
|
||||
}
|
||||
|
||||
pub fn public_methods(ms: Vec<@Method> ) -> Vec<@Method> {
|
||||
pub fn public_methods(ms: Vec<Gc<Method>> ) -> Vec<Gc<Method>> {
|
||||
ms.move_iter().filter(|m| {
|
||||
match m.vis {
|
||||
Public => true,
|
||||
@@ -285,7 +285,7 @@ pub fn trait_method_to_ty_method(method: &TraitMethod) -> TypeMethod {
|
||||
}
|
||||
|
||||
pub fn split_trait_methods(trait_methods: &[TraitMethod])
|
||||
-> (Vec<TypeMethod> , Vec<@Method> ) {
|
||||
-> (Vec<TypeMethod> , Vec<Gc<Method>> ) {
|
||||
let mut reqd = Vec::new();
|
||||
let mut provd = Vec::new();
|
||||
for trt_method in trait_methods.iter() {
|
||||
@@ -610,7 +610,7 @@ pub fn compute_id_range_for_fn_body(fk: &visit::FnKind,
|
||||
visitor.result.get()
|
||||
}
|
||||
|
||||
pub fn is_item_impl(item: @ast::Item) -> bool {
|
||||
pub fn is_item_impl(item: Gc<ast::Item>) -> bool {
|
||||
match item.node {
|
||||
ItemImpl(..) => true,
|
||||
_ => false
|
||||
@@ -623,20 +623,20 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool {
|
||||
}
|
||||
|
||||
match pat.node {
|
||||
PatIdent(_, _, Some(p)) => walk_pat(p, it),
|
||||
PatIdent(_, _, Some(ref p)) => walk_pat(&**p, it),
|
||||
PatStruct(_, ref fields, _) => {
|
||||
fields.iter().advance(|f| walk_pat(f.pat, |p| it(p)))
|
||||
fields.iter().advance(|f| walk_pat(&*f.pat, |p| it(p)))
|
||||
}
|
||||
PatEnum(_, Some(ref s)) | PatTup(ref s) => {
|
||||
s.iter().advance(|&p| walk_pat(p, |p| it(p)))
|
||||
s.iter().advance(|p| walk_pat(&**p, |p| it(p)))
|
||||
}
|
||||
PatBox(s) | PatRegion(s) => {
|
||||
walk_pat(s, it)
|
||||
PatBox(ref s) | PatRegion(ref s) => {
|
||||
walk_pat(&**s, it)
|
||||
}
|
||||
PatVec(ref before, ref slice, ref after) => {
|
||||
before.iter().advance(|&p| walk_pat(p, |p| it(p))) &&
|
||||
slice.iter().advance(|&p| walk_pat(p, |p| it(p))) &&
|
||||
after.iter().advance(|&p| walk_pat(p, |p| it(p)))
|
||||
before.iter().advance(|p| walk_pat(&**p, |p| it(p))) &&
|
||||
slice.iter().advance(|p| walk_pat(&**p, |p| it(p))) &&
|
||||
after.iter().advance(|p| walk_pat(&**p, |p| it(p)))
|
||||
}
|
||||
PatMac(_) => fail!("attempted to analyze unexpanded pattern"),
|
||||
PatWild | PatWildMulti | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |
|
||||
@@ -685,7 +685,7 @@ pub fn struct_def_is_tuple_like(struct_def: &ast::StructDef) -> bool {
|
||||
|
||||
/// Returns true if the given pattern consists solely of an identifier
|
||||
/// and false otherwise.
|
||||
pub fn pat_is_ident(pat: @ast::Pat) -> bool {
|
||||
pub fn pat_is_ident(pat: Gc<ast::Pat>) -> bool {
|
||||
match pat.node {
|
||||
ast::PatIdent(..) => true,
|
||||
_ => false,
|
||||
@@ -720,7 +720,7 @@ pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> boo
|
||||
}
|
||||
|
||||
// Returns true if this literal is a string and false otherwise.
|
||||
pub fn lit_is_str(lit: @Lit) -> bool {
|
||||
pub fn lit_is_str(lit: Gc<Lit>) -> bool {
|
||||
match lit.node {
|
||||
LitStr(..) => true,
|
||||
_ => false,
|
||||
|
||||
Reference in New Issue
Block a user