Modernized a few more types in syntax::ast

This commit is contained in:
Marvin Löbel 2013-09-02 03:45:37 +02:00
parent 58decdd7a1
commit 7419085337
114 changed files with 3795 additions and 3790 deletions

View file

@ -29,7 +29,7 @@ pub struct Ident { name: Name, ctxt: SyntaxContext }
impl Ident {
/// Construct an identifier with the given name and an empty context:
pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: empty_ctxt}}
pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}}
}
/// A SyntaxContext represents a chain of macro-expandings
@ -52,9 +52,10 @@ pub struct SCTable {
mark_memo : HashMap<(SyntaxContext,Mrk),SyntaxContext>,
rename_memo : HashMap<(SyntaxContext,Ident,Name),SyntaxContext>
}
// NB: these must be placed in any SCTable...
pub static empty_ctxt : uint = 0;
pub static illegal_ctxt : uint = 1;
pub static EMPTY_CTXT : uint = 0;
pub static ILLEGAL_CTXT : uint = 1;
#[deriving(Eq, Encodable, Decodable,IterBytes)]
pub enum SyntaxContext_ {
@ -69,7 +70,7 @@ pub enum SyntaxContext_ {
// in the "from" slot. In essence, they're all
// pointers to a single "rename" event node.
Rename (Ident,Name,SyntaxContext),
IllegalCtxt()
IllegalCtxt
}
/// A name is a part of an identifier, representing a string or gensym. It's
@ -92,7 +93,7 @@ impl<D:Decoder> Decodable<D> for Ident {
}
/// Function name (not all functions have names)
pub type fn_ident = Option<Ident>;
pub type FnIdent = Option<Ident>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct Lifetime {
@ -133,7 +134,7 @@ pub type CrateNum = int;
pub type NodeId = int;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes, ToStr)]
pub struct def_id {
pub struct DefId {
crate: CrateNum,
node: NodeId,
}
@ -178,40 +179,39 @@ impl Generics {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum MethodProvenance {
FromTrait(def_id),
FromImpl(def_id),
FromTrait(DefId),
FromImpl(DefId),
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum def {
def_fn(def_id, purity),
def_static_method(/* method */ def_id, MethodProvenance, purity),
def_self(NodeId),
def_self_ty(/* trait id */ NodeId),
def_mod(def_id),
def_foreign_mod(def_id),
def_static(def_id, bool /* is_mutbl */),
def_arg(NodeId, bool /* is_mutbl */),
def_local(NodeId, bool /* is_mutbl */),
def_variant(def_id /* enum */, def_id /* variant */),
def_ty(def_id),
def_trait(def_id),
def_prim_ty(prim_ty),
def_ty_param(def_id, uint),
def_binding(NodeId, binding_mode),
def_use(def_id),
def_upvar(NodeId, // id of closed over var
@def, // closed over def
pub enum Def {
DefFn(DefId, purity),
DefStaticMethod(/* method */ DefId, MethodProvenance, purity),
DefSelf(NodeId),
DefSelfTy(/* trait id */ NodeId),
DefMod(DefId),
DefForeignMod(DefId),
DefStatic(DefId, bool /* is_mutbl */),
DefArg(NodeId, bool /* is_mutbl */),
DefLocal(NodeId, bool /* is_mutbl */),
DefVariant(DefId /* enum */, DefId /* variant */),
DefTy(DefId),
DefTrait(DefId),
DefPrimTy(prim_ty),
DefTyParam(DefId, uint),
DefBinding(NodeId, BindingMode),
DefUse(DefId),
DefUpvar(NodeId, // id of closed over var
@Def, // closed over def
NodeId, // expr node that creates the closure
NodeId), // id for the block/body of the closure expr
def_struct(def_id),
def_typaram_binder(NodeId), /* struct, impl or trait with ty params */
def_region(NodeId),
def_label(NodeId),
def_method(def_id /* method */, Option<def_id> /* trait */),
DefStruct(DefId),
DefTyParamBinder(NodeId), /* struct, impl or trait with ty params */
DefRegion(NodeId),
DefLabel(NodeId),
DefMethod(DefId /* method */, Option<DefId> /* trait */),
}
// The set of MetaItems that define the compilation environment of the crate,
// used to drive conditional compilation
pub type CrateConfig = ~[@MetaItem];
@ -261,35 +261,35 @@ impl Eq for MetaItem_ {
#[deriving(Clone, Eq, Encodable, Decodable,IterBytes)]
pub struct Block {
view_items: ~[view_item],
stmts: ~[@stmt],
expr: Option<@expr>,
stmts: ~[@Stmt],
expr: Option<@Expr>,
id: NodeId,
rules: BlockCheckMode,
span: Span,
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct pat {
pub struct Pat {
id: NodeId,
node: pat_,
node: Pat_,
span: Span,
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct field_pat {
pub struct FieldPat {
ident: Ident,
pat: @pat,
pat: @Pat,
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum binding_mode {
bind_by_ref(mutability),
bind_infer
pub enum BindingMode {
BindByRef(Mutability),
BindInfer
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum pat_ {
pat_wild,
pub enum Pat_ {
PatWild,
// A pat_ident may either be a new bound variable,
// or a nullary enum (in which case the second field
// is None).
@ -297,25 +297,25 @@ pub enum pat_ {
// which it is. The resolver determines this, and
// records this pattern's NodeId in an auxiliary
// set (of "pat_idents that refer to nullary enums")
pat_ident(binding_mode, Path, Option<@pat>),
pat_enum(Path, Option<~[@pat]>), /* "none" means a * pattern where
PatIdent(BindingMode, Path, Option<@Pat>),
PatEnum(Path, Option<~[@Pat]>), /* "none" means a * pattern where
* we don't bind the fields to names */
pat_struct(Path, ~[field_pat], bool),
pat_tup(~[@pat]),
pat_box(@pat),
pat_uniq(@pat),
pat_region(@pat), // borrowed pointer pattern
pat_lit(@expr),
pat_range(@expr, @expr),
PatStruct(Path, ~[FieldPat], bool),
PatTup(~[@Pat]),
PatBox(@Pat),
PatUniq(@Pat),
PatRegion(@Pat), // borrowed pointer pattern
PatLit(@Expr),
PatRange(@Expr, @Expr),
// [a, b, ..i, y, z] is represented as
// pat_vec(~[a, b], Some(i), ~[y, z])
pat_vec(~[@pat], Option<@pat>, ~[@pat])
PatVec(~[@Pat], Option<@Pat>, ~[@Pat])
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum mutability {
m_mutbl,
m_imm,
pub enum Mutability {
MutMutable,
MutImmutable,
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
@ -336,69 +336,69 @@ impl ToStr for Sigil {
}
#[deriving(Eq, Encodable, Decodable, IterBytes)]
pub enum vstore {
pub enum Vstore {
// FIXME (#3469): Change uint to @expr (actually only constant exprs)
vstore_fixed(Option<uint>), // [1,2,3,4]
vstore_uniq, // ~[1,2,3,4]
vstore_box, // @[1,2,3,4]
vstore_slice(Option<Lifetime>) // &'foo? [1,2,3,4]
VstoreFixed(Option<uint>), // [1,2,3,4]
VstoreUniq, // ~[1,2,3,4]
VstoreBox, // @[1,2,3,4]
VstoreSlice(Option<Lifetime>) // &'foo? [1,2,3,4]
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum expr_vstore {
expr_vstore_uniq, // ~[1,2,3,4]
expr_vstore_box, // @[1,2,3,4]
expr_vstore_mut_box, // @mut [1,2,3,4]
expr_vstore_slice, // &[1,2,3,4]
expr_vstore_mut_slice, // &mut [1,2,3,4]
pub enum ExprVstore {
ExprVstoreUniq, // ~[1,2,3,4]
ExprVstoreBox, // @[1,2,3,4]
ExprVstoreMutBox, // @mut [1,2,3,4]
ExprVstoreSlice, // &[1,2,3,4]
ExprVstoreMutSlice, // &mut [1,2,3,4]
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum binop {
add,
subtract,
mul,
div,
rem,
and,
or,
bitxor,
bitand,
bitor,
shl,
shr,
eq,
lt,
le,
ne,
ge,
gt,
pub enum BinOp {
BiAdd,
BiSub,
BiMul,
BiDiv,
BiRem,
BiAnd,
BiOr,
BiBitXor,
BiBitAnd,
BiBitOr,
BiShl,
BiShr,
BiEq,
BiLt,
BiLe,
BiNe,
BiGe,
BiGt,
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum unop {
box(mutability),
uniq,
deref,
not,
neg
pub enum UnOp {
UnBox(Mutability),
UnUniq,
UnDeref,
UnNot,
UnNeg
}
pub type stmt = Spanned<stmt_>;
pub type Stmt = Spanned<Stmt_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum stmt_ {
pub enum Stmt_ {
// could be an item or a local (let) binding:
stmt_decl(@decl, NodeId),
StmtDecl(@Decl, NodeId),
// expr without trailing semi-colon (must have unit type):
stmt_expr(@expr, NodeId),
StmtExpr(@Expr, NodeId),
// expr with trailing semi-colon (may have any type):
stmt_semi(@expr, NodeId),
StmtSemi(@Expr, NodeId),
// bool: is there a trailing sem-colon?
stmt_mac(mac, bool),
StmtMac(mac, bool),
}
// FIXME (pending discussion of #1697, #2178...): local should really be
@ -407,33 +407,33 @@ pub enum stmt_ {
pub struct Local {
is_mutbl: bool,
ty: Ty,
pat: @pat,
init: Option<@expr>,
pat: @Pat,
init: Option<@Expr>,
id: NodeId,
span: Span,
}
pub type decl = Spanned<decl_>;
pub type Decl = Spanned<Decl_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)]
pub enum decl_ {
pub enum Decl_ {
// a local (let) binding:
decl_local(@Local),
DeclLocal(@Local),
// an item binding:
decl_item(@item),
DeclItem(@item),
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct arm {
pats: ~[@pat],
guard: Option<@expr>,
pub struct Arm {
pats: ~[@Pat],
guard: Option<@Expr>,
body: Block,
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct Field {
ident: Ident,
expr: @expr,
expr: @Expr,
span: Span,
}
@ -444,20 +444,20 @@ pub enum BlockCheckMode {
}
#[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct expr {
pub struct Expr {
id: NodeId,
node: expr_,
node: Expr_,
span: Span,
}
impl expr {
impl Expr {
pub fn get_callee_id(&self) -> Option<NodeId> {
match self.node {
expr_method_call(callee_id, _, _, _, _, _) |
expr_index(callee_id, _, _) |
expr_binary(callee_id, _, _, _) |
expr_assign_op(callee_id, _, _, _) |
expr_unary(callee_id, _, _) => Some(callee_id),
ExprMethodCall(callee_id, _, _, _, _, _) |
ExprIndex(callee_id, _, _) |
ExprBinary(callee_id, _, _, _) |
ExprAssignOp(callee_id, _, _, _) |
ExprUnary(callee_id, _, _) => Some(callee_id),
_ => None,
}
}
@ -471,54 +471,54 @@ pub enum CallSugar {
}
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum expr_ {
expr_vstore(@expr, expr_vstore),
expr_vec(~[@expr], mutability),
expr_call(@expr, ~[@expr], CallSugar),
expr_method_call(NodeId, @expr, Ident, ~[Ty], ~[@expr], CallSugar),
expr_tup(~[@expr]),
expr_binary(NodeId, binop, @expr, @expr),
expr_unary(NodeId, unop, @expr),
expr_lit(@lit),
expr_cast(@expr, Ty),
expr_if(@expr, Block, Option<@expr>),
expr_while(@expr, Block),
expr_for_loop(@pat, @expr, Block),
pub enum Expr_ {
ExprVstore(@Expr, ExprVstore),
ExprVec(~[@Expr], Mutability),
ExprCall(@Expr, ~[@Expr], CallSugar),
ExprMethodCall(NodeId, @Expr, Ident, ~[Ty], ~[@Expr], CallSugar),
ExprTup(~[@Expr]),
ExprBinary(NodeId, BinOp, @Expr, @Expr),
ExprUnary(NodeId, UnOp, @Expr),
ExprLit(@lit),
ExprCast(@Expr, Ty),
ExprIf(@Expr, Block, Option<@Expr>),
ExprWhile(@Expr, Block),
ExprForLoop(@Pat, @Expr, Block),
/* Conditionless loop (can be exited with break, cont, or ret)
Same semantics as while(true) { body }, but typestate knows that the
(implicit) condition is always true. */
expr_loop(Block, Option<Ident>),
expr_match(@expr, ~[arm]),
expr_fn_block(fn_decl, Block),
expr_do_body(@expr),
expr_block(Block),
ExprLoop(Block, Option<Ident>),
ExprMatch(@Expr, ~[Arm]),
ExprFnBlock(fn_decl, Block),
ExprDoBody(@Expr),
ExprBlock(Block),
expr_assign(@expr, @expr),
expr_assign_op(NodeId, binop, @expr, @expr),
expr_field(@expr, Ident, ~[Ty]),
expr_index(NodeId, @expr, @expr),
expr_path(Path),
ExprAssign(@Expr, @Expr),
ExprAssignOp(NodeId, BinOp, @Expr, @Expr),
ExprField(@Expr, Ident, ~[Ty]),
ExprIndex(NodeId, @Expr, @Expr),
ExprPath(Path),
/// The special identifier `self`.
expr_self,
expr_addr_of(mutability, @expr),
expr_break(Option<Ident>),
expr_again(Option<Ident>),
expr_ret(Option<@expr>),
expr_log(@expr, @expr),
ExprSelf,
ExprAddrOf(Mutability, @Expr),
ExprBreak(Option<Ident>),
ExprAgain(Option<Ident>),
ExprRet(Option<@Expr>),
ExprLog(@Expr, @Expr),
expr_inline_asm(inline_asm),
ExprInlineAsm(inline_asm),
expr_mac(mac),
ExprMac(mac),
// A struct literal expression.
expr_struct(Path, ~[Field], Option<@expr> /* base */),
ExprStruct(Path, ~[Field], Option<@Expr> /* base */),
// A vector literal constructed from one repeated element.
expr_repeat(@expr /* element */, @expr /* count */, mutability),
ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability),
// No-op: used solely so we can pretty-print faithfully
expr_paren(@expr)
ExprParen(@Expr)
}
// When the main rust parser encounters a syntax-extension invocation, it
@ -646,7 +646,7 @@ pub enum lit_ {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct mt {
ty: ~Ty,
mutbl: mutability,
mutbl: Mutability,
}
#[deriving(Eq, Encodable, Decodable,IterBytes)]
@ -785,7 +785,7 @@ pub enum ty_ {
ty_box(mt),
ty_uniq(mt),
ty_vec(mt),
ty_fixed_length_vec(mt, @expr),
ty_fixed_length_vec(mt, @Expr),
ty_ptr(mt),
ty_rptr(Option<Lifetime>, mt),
ty_closure(@TyClosure),
@ -793,7 +793,7 @@ pub enum ty_ {
ty_tup(~[Ty]),
ty_path(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above
ty_mac(mac),
ty_typeof(@expr),
ty_typeof(@Expr),
// ty_infer means the type should be inferred instead of it having been
// specified. This should only appear at the "top level" of a type and not
// nested in one.
@ -810,8 +810,8 @@ pub enum asm_dialect {
pub struct inline_asm {
asm: @str,
clobbers: @str,
inputs: ~[(@str, @expr)],
outputs: ~[(@str, @expr)],
inputs: ~[(@str, @Expr)],
outputs: ~[(@str, @Expr)],
volatile: bool,
alignstack: bool,
dialect: asm_dialect
@ -821,7 +821,7 @@ pub struct inline_asm {
pub struct arg {
is_mutbl: bool,
ty: Ty,
pat: @pat,
pat: @Pat,
id: NodeId,
}
@ -861,8 +861,8 @@ pub enum ret_style {
pub enum explicit_self_ {
sty_static, // no self
sty_value, // `self`
sty_region(Option<Lifetime>, mutability), // `&'lt self`
sty_box(mutability), // `@self`
sty_region(Option<Lifetime>, Mutability), // `&'lt self`
sty_box(Mutability), // `@self`
sty_uniq // `~self`
}
@ -927,7 +927,7 @@ pub struct variant_ {
attrs: ~[Attribute],
kind: variant_kind,
id: NodeId,
disr_expr: Option<@expr>,
disr_expr: Option<@Expr>,
vis: visibility,
}
@ -1067,7 +1067,7 @@ pub struct item {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum item_ {
item_static(Ty, mutability, @expr),
item_static(Ty, Mutability, @Expr),
item_fn(fn_decl, purity, AbiSet, Generics, Block),
item_mod(_mod),
item_foreign_mod(foreign_mod),
@ -1105,7 +1105,7 @@ pub enum foreign_item_ {
#[deriving(Eq, Encodable, Decodable,IterBytes)]
pub enum inlined_item {
ii_item(@item),
ii_method(def_id /* impl id */, bool /* is provided */, @method),
ii_method(DefId /* impl id */, bool /* is provided */, @method),
ii_foreign(@foreign_item),
}

View file

@ -67,17 +67,17 @@ pub fn path_elt_to_str(pe: path_elt, itr: @ident_interner) -> ~str {
pub enum ast_node {
node_item(@item, @path),
node_foreign_item(@foreign_item, AbiSet, visibility, @path),
node_trait_method(@trait_method, def_id /* trait did */,
node_trait_method(@trait_method, DefId /* trait did */,
@path /* path to the trait */),
node_method(@method, def_id /* impl did */, @path /* path to the impl */),
node_method(@method, DefId /* impl did */, @path /* path to the impl */),
node_variant(variant, @item, @path),
node_expr(@expr),
node_stmt(@stmt),
node_expr(@Expr),
node_stmt(@Stmt),
node_arg,
node_local(Ident),
node_block(Block),
node_struct_ctor(@struct_def, @item, @path),
node_callee_scope(@expr)
node_callee_scope(@Expr)
}
pub type map = @mut HashMap<NodeId, ast_node>;
@ -94,7 +94,7 @@ impl Ctx {
}
fn map_method(&mut self,
impl_did: def_id,
impl_did: DefId,
impl_path: @path,
m: @method,
is_provided: bool) {
@ -130,7 +130,7 @@ impl Ctx {
}
}
fn map_expr(&mut self, ex: @expr) {
fn map_expr(&mut self, ex: @Expr) {
self.map.insert(ex.id, node_expr(ex));
// Expressions which are or might be calls:
@ -156,7 +156,7 @@ impl Ctx {
visit::walk_fn(self, fk, decl, body, sp, id, ());
}
fn map_stmt(&mut self, stmt: @stmt) {
fn map_stmt(&mut self, stmt: @Stmt) {
self.map.insert(stmt_id(stmt), node_stmt(stmt));
visit::walk_stmt(self, stmt, ());
}
@ -167,9 +167,9 @@ impl Ctx {
visit::walk_block(self, b, ());
}
fn map_pat(&mut self, pat: @pat) {
fn map_pat(&mut self, pat: @Pat) {
match pat.node {
pat_ident(_, ref path, _) => {
PatIdent(_, ref path, _) => {
// Note: this is at least *potentially* a pattern...
self.map.insert(pat.id,
node_local(ast_util::path_to_ident(path)));
@ -265,16 +265,16 @@ impl Visitor<()> for Ctx {
self.path.pop();
}
fn visit_pat(&mut self, pat: @pat, _: ()) {
fn visit_pat(&mut self, pat: @Pat, _: ()) {
self.map_pat(pat);
visit::walk_pat(self, pat, ())
}
fn visit_expr(&mut self, expr: @expr, _: ()) {
fn visit_expr(&mut self, expr: @Expr, _: ()) {
self.map_expr(expr)
}
fn visit_stmt(&mut self, stmt: @stmt, _: ()) {
fn visit_stmt(&mut self, stmt: @Stmt, _: ()) {
self.map_stmt(stmt)
}
@ -310,15 +310,15 @@ impl Visitor<()> for Ctx {
visit::walk_local(self, local, ())
}
fn visit_arm(&mut self, arm: &arm, _: ()) {
fn visit_arm(&mut self, arm: &Arm, _: ()) {
visit::walk_arm(self, arm, ())
}
fn visit_decl(&mut self, decl: @decl, _: ()) {
fn visit_decl(&mut self, decl: @Decl, _: ()) {
visit::walk_decl(self, decl, ())
}
fn visit_expr_post(&mut self, _: @expr, _: ()) {
fn visit_expr_post(&mut self, _: @Expr, _: ()) {
// Empty!
}

View file

@ -32,121 +32,121 @@ pub fn path_to_ident(path: &Path) -> Ident {
path.segments.last().identifier
}
pub fn local_def(id: NodeId) -> def_id {
ast::def_id { crate: LOCAL_CRATE, node: id }
pub fn local_def(id: NodeId) -> DefId {
ast::DefId { crate: LOCAL_CRATE, node: id }
}
pub fn is_local(did: ast::def_id) -> bool { did.crate == LOCAL_CRATE }
pub fn is_local(did: ast::DefId) -> bool { did.crate == LOCAL_CRATE }
pub fn stmt_id(s: &stmt) -> NodeId {
pub fn stmt_id(s: &Stmt) -> NodeId {
match s.node {
stmt_decl(_, id) => id,
stmt_expr(_, id) => id,
stmt_semi(_, id) => id,
stmt_mac(*) => fail!("attempted to analyze unexpanded stmt")
StmtDecl(_, id) => id,
StmtExpr(_, id) => id,
StmtSemi(_, id) => id,
StmtMac(*) => fail!("attempted to analyze unexpanded stmt")
}
}
pub fn variant_def_ids(d: def) -> Option<(def_id, def_id)> {
pub fn variant_def_ids(d: Def) -> Option<(DefId, DefId)> {
match d {
def_variant(enum_id, var_id) => {
DefVariant(enum_id, var_id) => {
Some((enum_id, var_id))
}
_ => None
}
}
pub fn def_id_of_def(d: def) -> def_id {
pub fn def_id_of_def(d: Def) -> DefId {
match d {
def_fn(id, _) | def_static_method(id, _, _) | def_mod(id) |
def_foreign_mod(id) | def_static(id, _) |
def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
def_use(id) | def_struct(id) | def_trait(id) | def_method(id, _) => {
DefFn(id, _) | DefStaticMethod(id, _, _) | DefMod(id) |
DefForeignMod(id) | DefStatic(id, _) |
DefVariant(_, id) | DefTy(id) | DefTyParam(id, _) |
DefUse(id) | DefStruct(id) | DefTrait(id) | DefMethod(id, _) => {
id
}
def_arg(id, _) | def_local(id, _) | def_self(id) | def_self_ty(id)
| def_upvar(id, _, _, _) | def_binding(id, _) | def_region(id)
| def_typaram_binder(id) | def_label(id) => {
DefArg(id, _) | DefLocal(id, _) | DefSelf(id) | DefSelfTy(id)
| DefUpvar(id, _, _, _) | DefBinding(id, _) | DefRegion(id)
| DefTyParamBinder(id) | DefLabel(id) => {
local_def(id)
}
def_prim_ty(_) => fail!()
DefPrimTy(_) => fail!()
}
}
pub fn binop_to_str(op: binop) -> ~str {
pub fn binop_to_str(op: BinOp) -> ~str {
match op {
add => return ~"+",
subtract => return ~"-",
mul => return ~"*",
div => return ~"/",
rem => return ~"%",
and => return ~"&&",
or => return ~"||",
bitxor => return ~"^",
bitand => return ~"&",
bitor => return ~"|",
shl => return ~"<<",
shr => return ~">>",
eq => return ~"==",
lt => return ~"<",
le => return ~"<=",
ne => return ~"!=",
ge => return ~">=",
gt => return ~">"
BiAdd => return ~"+",
BiSub => return ~"-",
BiMul => return ~"*",
BiDiv => return ~"/",
BiRem => return ~"%",
BiAnd => return ~"&&",
BiOr => return ~"||",
BiBitXor => return ~"^",
BiBitAnd => return ~"&",
BiBitOr => return ~"|",
BiShl => return ~"<<",
BiShr => return ~">>",
BiEq => return ~"==",
BiLt => return ~"<",
BiLe => return ~"<=",
BiNe => return ~"!=",
BiGe => return ~">=",
BiGt => return ~">"
}
}
pub fn binop_to_method_name(op: binop) -> Option<~str> {
pub fn binop_to_method_name(op: BinOp) -> Option<~str> {
match op {
add => return Some(~"add"),
subtract => return Some(~"sub"),
mul => return Some(~"mul"),
div => return Some(~"div"),
rem => return Some(~"rem"),
bitxor => return Some(~"bitxor"),
bitand => return Some(~"bitand"),
bitor => return Some(~"bitor"),
shl => return Some(~"shl"),
shr => return Some(~"shr"),
lt => return Some(~"lt"),
le => return Some(~"le"),
ge => return Some(~"ge"),
gt => return Some(~"gt"),
eq => return Some(~"eq"),
ne => return Some(~"ne"),
and | or => return None
BiAdd => return Some(~"add"),
BiSub => return Some(~"sub"),
BiMul => return Some(~"mul"),
BiDiv => return Some(~"div"),
BiRem => return Some(~"rem"),
BiBitXor => return Some(~"bitxor"),
BiBitAnd => return Some(~"bitand"),
BiBitOr => return Some(~"bitor"),
BiShl => return Some(~"shl"),
BiShr => return Some(~"shr"),
BiLt => return Some(~"lt"),
BiLe => return Some(~"le"),
BiGe => return Some(~"ge"),
BiGt => return Some(~"gt"),
BiEq => return Some(~"eq"),
BiNe => return Some(~"ne"),
BiAnd | BiOr => return None
}
}
pub fn lazy_binop(b: binop) -> bool {
pub fn lazy_binop(b: BinOp) -> bool {
match b {
and => true,
or => true,
BiAnd => true,
BiOr => true,
_ => false
}
}
pub fn is_shift_binop(b: binop) -> bool {
pub fn is_shift_binop(b: BinOp) -> bool {
match b {
shl => true,
shr => true,
BiShl => true,
BiShr => true,
_ => false
}
}
pub fn unop_to_str(op: unop) -> ~str {
pub fn unop_to_str(op: UnOp) -> ~str {
match op {
box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" },
uniq => ~"~",
deref => ~"*",
not => ~"!",
neg => ~"-"
UnBox(mt) => if mt == MutMutable { ~"@mut " } else { ~"@" },
UnUniq => ~"~",
UnDeref => ~"*",
UnNot => ~"!",
UnNeg => ~"-"
}
}
pub fn is_path(e: @expr) -> bool {
return match e.node { expr_path(_) => true, _ => false };
pub fn is_path(e: @Expr) -> bool {
return match e.node { ExprPath(_) => true, _ => false };
}
pub fn int_ty_to_str(t: int_ty) -> ~str {
@ -192,19 +192,19 @@ pub fn float_ty_to_str(t: float_ty) -> ~str {
match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" }
}
pub fn is_call_expr(e: @expr) -> bool {
match e.node { expr_call(*) => true, _ => false }
pub fn is_call_expr(e: @Expr) -> bool {
match e.node { ExprCall(*) => true, _ => false }
}
pub fn block_from_expr(e: @expr) -> Block {
let mut blk = default_block(~[], option::Some::<@expr>(e), e.id);
pub fn block_from_expr(e: @Expr) -> Block {
let mut blk = default_block(~[], option::Some::<@Expr>(e), e.id);
blk.span = e.span;
return blk;
}
pub fn default_block(
stmts1: ~[@stmt],
expr1: Option<@expr>,
stmts1: ~[@Stmt],
expr1: Option<@Expr>,
id1: NodeId
) -> Block {
ast::Block {
@ -231,20 +231,20 @@ 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,
node: pat_ident(bind_infer, ident_to_path(s, i), None),
pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> @Pat {
@ast::Pat { id: id,
node: PatIdent(BindInfer, ident_to_path(s, i), None),
span: s }
}
pub fn is_unguarded(a: &arm) -> bool {
pub fn is_unguarded(a: &Arm) -> bool {
match a.guard {
None => true,
_ => false
}
}
pub fn unguarded_pat(a: &arm) -> Option<~[@pat]> {
pub fn unguarded_pat(a: &Arm) -> Option<~[@Pat]> {
if is_unguarded(a) {
Some(/* FIXME (#2543) */ a.pats.clone())
} else {
@ -335,28 +335,28 @@ impl inlined_item_utils for inlined_item {
/* True if d is either a def_self, or a chain of def_upvars
referring to a def_self */
pub fn is_self(d: ast::def) -> bool {
pub fn is_self(d: ast::Def) -> bool {
match d {
def_self(*) => true,
def_upvar(_, d, _, _) => is_self(*d),
DefSelf(*) => true,
DefUpvar(_, d, _, _) => is_self(*d),
_ => false
}
}
/// Maps a binary operator to its precedence
pub fn operator_prec(op: ast::binop) -> uint {
pub fn operator_prec(op: ast::BinOp) -> uint {
match op {
// 'as' sits here with 12
mul | div | rem => 11u,
add | subtract => 10u,
shl | shr => 9u,
bitand => 8u,
bitxor => 7u,
bitor => 6u,
lt | le | ge | gt => 4u,
eq | ne => 3u,
and => 2u,
or => 1u
BiMul | BiDiv | BiRem => 11u,
BiAdd | BiSub => 10u,
BiShl | BiShr => 9u,
BiBitAnd => 8u,
BiBitXor => 7u,
BiBitOr => 6u,
BiLt | BiLe | BiGe | BiGt => 4u,
BiEq | BiNe => 3u,
BiAnd => 2u,
BiOr => 1u
}
}
@ -497,27 +497,27 @@ impl Visitor<()> for IdVisitor {
visit::walk_block(self, block, env)
}
fn visit_stmt(&mut self, statement: @stmt, env: ()) {
fn visit_stmt(&mut self, statement: @Stmt, env: ()) {
(self.visit_callback)(ast_util::stmt_id(statement));
visit::walk_stmt(self, statement, env)
}
// XXX: Default
fn visit_arm(&mut self, arm: &arm, env: ()) {
fn visit_arm(&mut self, arm: &Arm, env: ()) {
visit::walk_arm(self, arm, env)
}
fn visit_pat(&mut self, pattern: @pat, env: ()) {
fn visit_pat(&mut self, pattern: @Pat, env: ()) {
(self.visit_callback)(pattern.id);
visit::walk_pat(self, pattern, env)
}
// XXX: Default
fn visit_decl(&mut self, declaration: @decl, env: ()) {
fn visit_decl(&mut self, declaration: @Decl, env: ()) {
visit::walk_decl(self, declaration, env)
}
fn visit_expr(&mut self, expression: @expr, env: ()) {
fn visit_expr(&mut self, expression: @Expr, env: ()) {
{
let optional_callee_id = expression.get_callee_id();
for callee_id in optional_callee_id.iter() {
@ -529,7 +529,7 @@ impl Visitor<()> for IdVisitor {
}
// XXX: Default
fn visit_expr_post(&mut self, _: @expr, _: ()) {
fn visit_expr_post(&mut self, _: @Expr, _: ()) {
// Empty!
}
@ -654,29 +654,29 @@ pub fn is_item_impl(item: @ast::item) -> bool {
}
}
pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool {
pub fn walk_pat(pat: @Pat, it: &fn(@Pat) -> bool) -> bool {
if !it(pat) {
return false;
}
match pat.node {
pat_ident(_, _, Some(p)) => walk_pat(p, it),
pat_struct(_, ref fields, _) => {
PatIdent(_, _, Some(p)) => walk_pat(p, it),
PatStruct(_, ref fields, _) => {
fields.iter().advance(|f| walk_pat(f.pat, |p| it(p)))
}
pat_enum(_, Some(ref s)) | pat_tup(ref s) => {
PatEnum(_, Some(ref s)) | PatTup(ref s) => {
s.iter().advance(|&p| walk_pat(p, |p| it(p)))
}
pat_box(s) | pat_uniq(s) | pat_region(s) => {
PatBox(s) | PatUniq(s) | PatRegion(s) => {
walk_pat(s, it)
}
pat_vec(ref before, ref slice, ref after) => {
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)))
}
pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _) |
pat_enum(_, _) => {
PatWild | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |
PatEnum(_, _) => {
true
}
}
@ -709,22 +709,22 @@ impl SimpleVisitor for EachViewItemData {
fn visit_block(&mut self, _: &Block) {
// XXX: Default method.
}
fn visit_stmt(&mut self, _: @stmt) {
fn visit_stmt(&mut self, _: @Stmt) {
// XXX: Default method.
}
fn visit_arm(&mut self, _: &arm) {
fn visit_arm(&mut self, _: &Arm) {
// XXX: Default method.
}
fn visit_pat(&mut self, _: @pat) {
fn visit_pat(&mut self, _: @Pat) {
// XXX: Default method.
}
fn visit_decl(&mut self, _: @decl) {
fn visit_decl(&mut self, _: @Decl) {
// XXX: Default method.
}
fn visit_expr(&mut self, _: @expr) {
fn visit_expr(&mut self, _: @Expr) {
// XXX: Default method.
}
fn visit_expr_post(&mut self, _: @expr) {
fn visit_expr_post(&mut self, _: @Expr) {
// XXX: Default method.
}
fn visit_ty(&mut self, _: &Ty) {
@ -817,9 +817,9 @@ pub enum Privacy {
/// 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: @ast::Pat) -> bool {
match pat.node {
ast::pat_ident(*) => true,
ast::PatIdent(*) => true,
_ => false,
}
}
@ -1015,7 +1015,7 @@ mod test {
// convert a list of uints to an @[ident]
// (ignores the interner completely)
fn uints_to_idents (uints: &~[uint]) -> @~[Ident] {
@uints.map(|u| Ident {name:*u, ctxt: empty_ctxt})
@uints.map(|u| Ident {name:*u, ctxt: EMPTY_CTXT})
}
fn id (u : uint, s: SyntaxContext) -> Ident {
@ -1065,7 +1065,7 @@ mod test {
let mut t = new_sctable_internal();
let test_sc = ~[M(3),R(id(101,0),14),M(9)];
assert_eq!(unfold_test_sc(test_sc.clone(),empty_ctxt,&mut t),4);
assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4);
assert_eq!(t.table[2],Mark(9,0));
assert_eq!(t.table[3],Rename(id(101,0),14,2));
assert_eq!(t.table[4],Mark(3,3));
@ -1082,7 +1082,7 @@ mod test {
#[test] fn unfold_marks_test() {
let mut t = new_sctable_internal();
assert_eq!(unfold_marks(~[3,7],empty_ctxt,&mut t),3);
assert_eq!(unfold_marks(~[3,7],EMPTY_CTXT,&mut t),3);
assert_eq!(t.table[2],Mark(7,0));
assert_eq!(t.table[3],Mark(3,2));
}
@ -1091,31 +1091,31 @@ mod test {
let stopname = 242;
let name1 = 243;
let mut t = new_sctable_internal();
assert_eq!(marksof (empty_ctxt,stopname,&t),~[]);
assert_eq!(marksof (EMPTY_CTXT,stopname,&t),~[]);
// FIXME #5074: ANF'd to dodge nested calls
{ let ans = unfold_marks(~[4,98],empty_ctxt,&mut t);
{ let ans = unfold_marks(~[4,98],EMPTY_CTXT,&mut t);
assert_eq! (marksof (ans,stopname,&t),~[4,98]);}
// does xoring work?
{ let ans = unfold_marks(~[5,5,16],empty_ctxt,&mut t);
{ let ans = unfold_marks(~[5,5,16],EMPTY_CTXT,&mut t);
assert_eq! (marksof (ans,stopname,&t), ~[16]);}
// does nested xoring work?
{ let ans = unfold_marks(~[5,10,10,5,16],empty_ctxt,&mut t);
{ let ans = unfold_marks(~[5,10,10,5,16],EMPTY_CTXT,&mut t);
assert_eq! (marksof (ans, stopname,&t), ~[16]);}
// rename where stop doesn't match:
{ let chain = ~[M(9),
R(id(name1,
new_mark_internal (4, empty_ctxt,&mut t)),
new_mark_internal (4, EMPTY_CTXT,&mut t)),
100101102),
M(14)];
let ans = unfold_test_sc(chain,empty_ctxt,&mut t);
let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t);
assert_eq! (marksof (ans, stopname, &t), ~[9,14]);}
// rename where stop does match
{ let name1sc = new_mark_internal(4, empty_ctxt, &mut t);
{ let name1sc = new_mark_internal(4, EMPTY_CTXT, &mut t);
let chain = ~[M(9),
R(id(name1, name1sc),
stopname),
M(14)];
let ans = unfold_test_sc(chain,empty_ctxt,&mut t);
let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t);
assert_eq! (marksof (ans, stopname, &t), ~[9]); }
}
@ -1124,38 +1124,38 @@ mod test {
let a = 40;
let mut t = new_sctable_internal();
// - ctxt is MT
assert_eq!(resolve_internal(id(a,empty_ctxt),&mut t),a);
assert_eq!(resolve_internal(id(a,EMPTY_CTXT),&mut t),a);
// - simple ignored marks
{ let sc = unfold_marks(~[1,2,3],empty_ctxt,&mut t);
{ let sc = unfold_marks(~[1,2,3],EMPTY_CTXT,&mut t);
assert_eq!(resolve_internal(id(a,sc),&mut t),a);}
// - orthogonal rename where names don't match
{ let sc = unfold_test_sc(~[R(id(50,empty_ctxt),51),M(12)],empty_ctxt,&mut t);
{ let sc = unfold_test_sc(~[R(id(50,EMPTY_CTXT),51),M(12)],EMPTY_CTXT,&mut t);
assert_eq!(resolve_internal(id(a,sc),&mut t),a);}
// - rename where names do match, but marks don't
{ let sc1 = new_mark_internal(1,empty_ctxt,&mut t);
{ let sc1 = new_mark_internal(1,EMPTY_CTXT,&mut t);
let sc = unfold_test_sc(~[R(id(a,sc1),50),
M(1),
M(2)],
empty_ctxt,&mut t);
EMPTY_CTXT,&mut t);
assert_eq!(resolve_internal(id(a,sc),&mut t), a);}
// - rename where names and marks match
{ let sc1 = unfold_test_sc(~[M(1),M(2)],empty_ctxt,&mut t);
let sc = unfold_test_sc(~[R(id(a,sc1),50),M(1),M(2)],empty_ctxt,&mut t);
{ let sc1 = unfold_test_sc(~[M(1),M(2)],EMPTY_CTXT,&mut t);
let sc = unfold_test_sc(~[R(id(a,sc1),50),M(1),M(2)],EMPTY_CTXT,&mut t);
assert_eq!(resolve_internal(id(a,sc),&mut t), 50); }
// - rename where names and marks match by literal sharing
{ let sc1 = unfold_test_sc(~[M(1),M(2)],empty_ctxt,&mut t);
{ let sc1 = unfold_test_sc(~[M(1),M(2)],EMPTY_CTXT,&mut t);
let sc = unfold_test_sc(~[R(id(a,sc1),50)],sc1,&mut t);
assert_eq!(resolve_internal(id(a,sc),&mut t), 50); }
// - two renames of the same var.. can only happen if you use
// local-expand to prevent the inner binding from being renamed
// during the rename-pass caused by the first:
io::println("about to run bad test");
{ let sc = unfold_test_sc(~[R(id(a,empty_ctxt),50),
R(id(a,empty_ctxt),51)],
empty_ctxt,&mut t);
{ let sc = unfold_test_sc(~[R(id(a,EMPTY_CTXT),50),
R(id(a,EMPTY_CTXT),51)],
EMPTY_CTXT,&mut t);
assert_eq!(resolve_internal(id(a,sc),&mut t), 51); }
// the simplest double-rename:
{ let a_to_a50 = new_rename_internal(id(a,empty_ctxt),50,empty_ctxt,&mut t);
{ let a_to_a50 = new_rename_internal(id(a,EMPTY_CTXT),50,EMPTY_CTXT,&mut t);
let a50_to_a51 = new_rename_internal(id(a,a_to_a50),51,a_to_a50,&mut t);
assert_eq!(resolve_internal(id(a,a50_to_a51),&mut t),51);
// mark on the outside doesn't stop rename:
@ -1171,10 +1171,10 @@ mod test {
#[test] fn hashing_tests () {
let mut t = new_sctable_internal();
assert_eq!(new_mark_internal(12,empty_ctxt,&mut t),2);
assert_eq!(new_mark_internal(13,empty_ctxt,&mut t),3);
assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2);
assert_eq!(new_mark_internal(13,EMPTY_CTXT,&mut t),3);
// using the same one again should result in the same index:
assert_eq!(new_mark_internal(12,empty_ctxt,&mut t),2);
assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2);
// I'm assuming that the rename table will behave the same....
}

View file

@ -75,10 +75,10 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
let out = p.parse_expr();
p.expect(&token::RPAREN);
let out = @ast::expr {
let out = @ast::Expr {
id: cx.next_id(),
span: out.span,
node: ast::expr_addr_of(ast::m_mutbl, out)
node: ast::ExprAddrOf(ast::MutMutable, out)
};
outputs.push((constraint, out));
@ -171,9 +171,9 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
}
}
MRExpr(@ast::expr {
MRExpr(@ast::Expr {
id: cx.next_id(),
node: ast::expr_inline_asm(ast::inline_asm {
node: ast::ExprInlineAsm(ast::inline_asm {
asm: asm,
clobbers: cons.to_managed(),
inputs: inputs,

View file

@ -62,11 +62,11 @@ pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt,
-> MacResult;
pub enum MacResult {
MRExpr(@ast::expr),
MRExpr(@ast::Expr),
MRItem(@ast::item),
MRAny(@fn() -> @ast::expr,
MRAny(@fn() -> @ast::Expr,
@fn() -> Option<@ast::item>,
@fn() -> @ast::stmt),
@fn() -> @ast::Stmt),
MRDef(MacroDef)
}
@ -319,9 +319,9 @@ impl ExtCtxt {
}
}
pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::expr, err_msg: &str) -> @str {
pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::Expr, err_msg: &str) -> @str {
match expr.node {
ast::expr_lit(l) => match l.node {
ast::ExprLit(l) => match l.node {
ast::lit_str(s) => s,
_ => cx.span_fatal(l.span, err_msg)
},
@ -353,7 +353,7 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt,
pub fn get_exprs_from_tts(cx: @ExtCtxt,
sp: Span,
tts: &[ast::token_tree]) -> ~[@ast::expr] {
tts: &[ast::token_tree]) -> ~[@ast::Expr] {
let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(),
tts.to_owned());

View file

@ -21,7 +21,7 @@ use opt_vec::OptVec;
pub struct Field {
ident: ast::Ident,
ex: @ast::expr
ex: @ast::Expr
}
// Transitional reexports so qquote can find the paths it is looking for
@ -43,7 +43,7 @@ pub trait AstBuilder {
-> ast::Path;
// types
fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt;
fn ty_mt(&self, ty: ast::Ty, mutbl: ast::Mutability) -> ast::mt;
fn ty(&self, span: Span, ty: ast::ty_) -> ast::Ty;
fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> ast::Ty;
@ -52,9 +52,9 @@ pub trait AstBuilder {
fn ty_rptr(&self, span: Span,
ty: ast::Ty,
lifetime: Option<ast::Lifetime>,
mutbl: ast::mutability) -> ast::Ty;
mutbl: ast::Mutability) -> ast::Ty;
fn ty_uniq(&self, span: Span, ty: ast::Ty) -> ast::Ty;
fn ty_box(&self, span: Span, ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty;
fn ty_box(&self, span: Span, ty: ast::Ty, mutbl: ast::Mutability) -> ast::Ty;
fn ty_option(&self, ty: ast::Ty) -> ast::Ty;
fn ty_infer(&self, sp: Span) -> ast::Ty;
@ -72,101 +72,101 @@ pub trait AstBuilder {
fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime;
// statements
fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt;
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::expr) -> @ast::stmt;
fn stmt_expr(&self, expr: @ast::Expr) -> @ast::Stmt;
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::Expr) -> @ast::Stmt;
fn stmt_let_typed(&self,
sp: Span,
mutbl: bool,
ident: ast::Ident,
typ: ast::Ty,
ex: @ast::expr)
-> @ast::stmt;
ex: @ast::Expr)
-> @ast::Stmt;
// blocks
fn block(&self, span: Span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::Block;
fn block_expr(&self, expr: @ast::expr) -> ast::Block;
fn block(&self, span: Span, stmts: ~[@ast::Stmt], expr: Option<@ast::Expr>) -> ast::Block;
fn block_expr(&self, expr: @ast::Expr) -> ast::Block;
fn block_all(&self, span: Span,
view_items: ~[ast::view_item],
stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> ast::Block;
stmts: ~[@ast::Stmt],
expr: Option<@ast::Expr>) -> ast::Block;
// expressions
fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr;
fn expr_path(&self, path: ast::Path) -> @ast::expr;
fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::expr;
fn expr(&self, span: Span, node: ast::Expr_) -> @ast::Expr;
fn expr_path(&self, path: ast::Path) -> @ast::Expr;
fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::Expr;
fn expr_self(&self, span: Span) -> @ast::expr;
fn expr_binary(&self, sp: Span, op: ast::binop,
lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr;
fn expr_deref(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_unary(&self, sp: Span, op: ast::unop, e: @ast::expr) -> @ast::expr;
fn expr_self(&self, span: Span) -> @ast::Expr;
fn expr_binary(&self, sp: Span, op: ast::BinOp,
lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr;
fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr;
fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) -> @ast::Expr;
fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_field_access(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr;
fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr;
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::expr]) -> @ast::expr;
fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr;
fn expr_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr;
fn expr_mut_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr;
fn expr_field_access(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr;
fn expr_call(&self, span: Span, expr: @ast::Expr, args: ~[@ast::Expr]) -> @ast::Expr;
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr;
fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident],
args: ~[@ast::expr]) -> @ast::expr;
args: ~[@ast::Expr]) -> @ast::Expr;
fn expr_method_call(&self, span: Span,
expr: @ast::expr, ident: ast::Ident,
args: ~[@ast::expr]) -> @ast::expr;
fn expr_block(&self, b: ast::Block) -> @ast::expr;
expr: @ast::Expr, ident: ast::Ident,
args: ~[@ast::Expr]) -> @ast::Expr;
fn expr_block(&self, b: ast::Block) -> @ast::Expr;
fn field_imm(&self, span: Span, name: Ident, e: @ast::expr) -> ast::Field;
fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr;
fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: ~[ast::Field]) -> @ast::expr;
fn field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field;
fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::Expr;
fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: ~[ast::Field]) -> @ast::Expr;
fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr;
fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::Expr;
fn expr_uint(&self, span: Span, i: uint) -> @ast::expr;
fn expr_int(&self, sp: Span, i: int) -> @ast::expr;
fn expr_u8(&self, sp: Span, u: u8) -> @ast::expr;
fn expr_bool(&self, sp: Span, value: bool) -> @ast::expr;
fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr;
fn expr_int(&self, sp: Span, i: int) -> @ast::Expr;
fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr;
fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr;
fn expr_vstore(&self, sp: Span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr;
fn expr_vec(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr;
fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr;
fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr;
fn expr_str(&self, sp: Span, s: @str) -> @ast::expr;
fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::expr;
fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr;
fn expr_vec(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr;
fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr;
fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr;
fn expr_str(&self, sp: Span, s: @str) -> @ast::Expr;
fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::Expr;
fn expr_unreachable(&self, span: Span) -> @ast::expr;
fn expr_unreachable(&self, span: Span) -> @ast::Expr;
fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat;
fn pat_wild(&self, span: Span) -> @ast::pat;
fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat;
fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::pat;
fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat;
fn pat_wild(&self, span: Span) -> @ast::Pat;
fn pat_lit(&self, span: Span, expr: @ast::Expr) -> @ast::Pat;
fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::Pat;
fn pat_ident_binding_mode(&self,
span: Span,
ident: ast::Ident,
bm: ast::binding_mode) -> @ast::pat;
fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat;
bm: ast::BindingMode) -> @ast::Pat;
fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::Pat]) -> @ast::Pat;
fn pat_struct(&self, span: Span,
path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat;
path: ast::Path, field_pats: ~[ast::FieldPat]) -> @ast::Pat;
fn arm(&self, span: Span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm;
fn arm_unreachable(&self, span: Span) -> ast::arm;
fn arm(&self, span: Span, pats: ~[@ast::Pat], expr: @ast::Expr) -> ast::Arm;
fn arm_unreachable(&self, span: Span) -> ast::Arm;
fn expr_match(&self, span: Span, arg: @ast::expr, arms: ~[ast::arm]) -> @ast::expr;
fn expr_match(&self, span: Span, arg: @ast::Expr, arms: ~[ast::Arm]) -> @ast::Expr;
fn expr_if(&self, span: Span,
cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr;
cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr;
fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr;
fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::Expr;
fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::expr;
fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::expr;
fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr;
fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::Expr;
fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::Expr;
fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::Expr;
fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], blk: @ast::expr) -> @ast::expr;
fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr;
fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr;
fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], blk: @ast::Expr) -> @ast::Expr;
fn lambda_expr_0(&self, span: Span, expr: @ast::Expr) -> @ast::Expr;
fn lambda_expr_1(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr;
fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], blk: ~[@ast::stmt]) -> @ast::expr;
fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr;
fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::Ident) -> @ast::expr;
fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], blk: ~[@ast::Stmt]) -> @ast::Expr;
fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::Stmt]) -> @ast::Expr;
fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::Stmt], ident: ast::Ident) -> @ast::Expr;
// items
fn item(&self, span: Span,
@ -268,7 +268,7 @@ impl AstBuilder for @ExtCtxt {
}
}
fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt {
fn ty_mt(&self, ty: ast::Ty, mutbl: ast::Mutability) -> ast::mt {
ast::mt {
ty: ~ty,
mutbl: mutbl
@ -300,16 +300,16 @@ impl AstBuilder for @ExtCtxt {
span: Span,
ty: ast::Ty,
lifetime: Option<ast::Lifetime>,
mutbl: ast::mutability)
mutbl: ast::Mutability)
-> ast::Ty {
self.ty(span,
ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl)))
}
fn ty_uniq(&self, span: Span, ty: ast::Ty) -> ast::Ty {
self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::m_imm)))
self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::MutImmutable)))
}
fn ty_box(&self, span: Span,
ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty {
ty: ast::Ty, mutbl: ast::Mutability) -> ast::Ty {
self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl)))
}
@ -329,7 +329,7 @@ impl AstBuilder for @ExtCtxt {
fn ty_field_imm(&self, span: Span, name: Ident, ty: ast::Ty) -> ast::TypeField {
ast::TypeField {
ident: name,
mt: ast::mt { ty: ~ty, mutbl: ast::m_imm },
mt: ast::mt { ty: ~ty, mutbl: ast::MutImmutable },
span: span,
}
}
@ -389,11 +389,11 @@ impl AstBuilder for @ExtCtxt {
ast::Lifetime { id: self.next_id(), span: span, ident: ident }
}
fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt {
@respan(expr.span, ast::stmt_semi(expr, self.next_id()))
fn stmt_expr(&self, expr: @ast::Expr) -> @ast::Stmt {
@respan(expr.span, ast::StmtSemi(expr, self.next_id()))
}
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::expr) -> @ast::stmt {
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::Expr) -> @ast::Stmt {
let pat = self.pat_ident(sp, ident);
let local = @ast::Local {
is_mutbl: mutbl,
@ -403,8 +403,8 @@ impl AstBuilder for @ExtCtxt {
id: self.next_id(),
span: sp,
};
let decl = respan(sp, ast::decl_local(local));
@respan(sp, ast::stmt_decl(@decl, self.next_id()))
let decl = respan(sp, ast::DeclLocal(local));
@respan(sp, ast::StmtDecl(@decl, self.next_id()))
}
fn stmt_let_typed(&self,
@ -412,8 +412,8 @@ impl AstBuilder for @ExtCtxt {
mutbl: bool,
ident: ast::Ident,
typ: ast::Ty,
ex: @ast::expr)
-> @ast::stmt {
ex: @ast::Expr)
-> @ast::Stmt {
let pat = self.pat_ident(sp, ident);
let local = @ast::Local {
is_mutbl: mutbl,
@ -423,22 +423,22 @@ impl AstBuilder for @ExtCtxt {
id: self.next_id(),
span: sp,
};
let decl = respan(sp, ast::decl_local(local));
@respan(sp, ast::stmt_decl(@decl, self.next_id()))
let decl = respan(sp, ast::DeclLocal(local));
@respan(sp, ast::StmtDecl(@decl, self.next_id()))
}
fn block(&self, span: Span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::Block {
fn block(&self, span: Span, stmts: ~[@ast::Stmt], expr: Option<@Expr>) -> ast::Block {
self.block_all(span, ~[], stmts, expr)
}
fn block_expr(&self, expr: @ast::expr) -> ast::Block {
fn block_expr(&self, expr: @ast::Expr) -> ast::Block {
self.block_all(expr.span, ~[], ~[], Some(expr))
}
fn block_all(&self,
span: Span,
view_items: ~[ast::view_item],
stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> ast::Block {
stmts: ~[@ast::Stmt],
expr: Option<@ast::Expr>) -> ast::Block {
ast::Block {
view_items: view_items,
stmts: stmts,
@ -449,122 +449,122 @@ impl AstBuilder for @ExtCtxt {
}
}
fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr {
@ast::expr {
fn expr(&self, span: Span, node: ast::Expr_) -> @ast::Expr {
@ast::Expr {
id: self.next_id(),
node: node,
span: span,
}
}
fn expr_path(&self, path: ast::Path) -> @ast::expr {
self.expr(path.span, ast::expr_path(path))
fn expr_path(&self, path: ast::Path) -> @ast::Expr {
self.expr(path.span, ast::ExprPath(path))
}
fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::expr {
fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::Expr {
self.expr_path(self.path_ident(span, id))
}
fn expr_self(&self, span: Span) -> @ast::expr {
self.expr(span, ast::expr_self)
fn expr_self(&self, span: Span) -> @ast::Expr {
self.expr(span, ast::ExprSelf)
}
fn expr_binary(&self, sp: Span, op: ast::binop,
lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr {
self.expr(sp, ast::expr_binary(self.next_id(), op, lhs, rhs))
fn expr_binary(&self, sp: Span, op: ast::BinOp,
lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr {
self.expr(sp, ast::ExprBinary(self.next_id(), op, lhs, rhs))
}
fn expr_deref(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr_unary(sp, ast::deref, e)
fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
self.expr_unary(sp, ast::UnDeref, e)
}
fn expr_unary(&self, sp: Span, op: ast::unop, e: @ast::expr)
-> @ast::expr {
self.expr(sp, ast::expr_unary(self.next_id(), op, e))
fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr)
-> @ast::Expr {
self.expr(sp, ast::ExprUnary(self.next_id(), op, e))
}
fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr_unary(sp, ast::box(ast::m_imm), e)
fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
self.expr_unary(sp, ast::UnBox(ast::MutImmutable), e)
}
fn expr_field_access(&self, sp: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr {
self.expr(sp, ast::expr_field(expr, ident, ~[]))
fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr {
self.expr(sp, ast::ExprField(expr, ident, ~[]))
}
fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr(sp, ast::expr_addr_of(ast::m_imm, e))
fn expr_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
self.expr(sp, ast::ExprAddrOf(ast::MutImmutable, e))
}
fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr {
self.expr(sp, ast::expr_addr_of(ast::m_mutbl, e))
fn expr_mut_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
self.expr(sp, ast::ExprAddrOf(ast::MutMutable, e))
}
fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr {
self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
fn expr_call(&self, span: Span, expr: @ast::Expr, args: ~[@ast::Expr]) -> @ast::Expr {
self.expr(span, ast::ExprCall(expr, args, ast::NoSugar))
}
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::expr]) -> @ast::expr {
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr {
self.expr(span,
ast::expr_call(self.expr_ident(span, id), args, ast::NoSugar))
ast::ExprCall(self.expr_ident(span, id), args, ast::NoSugar))
}
fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident],
args: ~[@ast::expr]) -> @ast::expr {
args: ~[@ast::Expr]) -> @ast::Expr {
let pathexpr = self.expr_path(self.path_global(sp, fn_path));
self.expr_call(sp, pathexpr, args)
}
fn expr_method_call(&self, span: Span,
expr: @ast::expr,
expr: @ast::Expr,
ident: ast::Ident,
args: ~[@ast::expr]) -> @ast::expr {
args: ~[@ast::Expr]) -> @ast::Expr {
self.expr(span,
ast::expr_method_call(self.next_id(), expr, ident, ~[], args, ast::NoSugar))
ast::ExprMethodCall(self.next_id(), expr, ident, ~[], args, ast::NoSugar))
}
fn expr_block(&self, b: ast::Block) -> @ast::expr {
self.expr(b.span, ast::expr_block(b))
fn expr_block(&self, b: ast::Block) -> @ast::Expr {
self.expr(b.span, ast::ExprBlock(b))
}
fn field_imm(&self, span: Span, name: Ident, e: @ast::expr) -> ast::Field {
fn field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field {
ast::Field { ident: name, expr: e, span: span }
}
fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr {
self.expr(span, ast::expr_struct(path, fields, None))
fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::Expr {
self.expr(span, ast::ExprStruct(path, fields, None))
}
fn expr_struct_ident(&self, span: Span,
id: ast::Ident, fields: ~[ast::Field]) -> @ast::expr {
id: ast::Ident, fields: ~[ast::Field]) -> @ast::Expr {
self.expr_struct(span, self.path_ident(span, id), fields)
}
fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr {
self.expr(sp, ast::expr_lit(@respan(sp, lit)))
fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::Expr {
self.expr(sp, ast::ExprLit(@respan(sp, lit)))
}
fn expr_uint(&self, span: Span, i: uint) -> @ast::expr {
fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr {
self.expr_lit(span, ast::lit_uint(i as u64, ast::ty_u))
}
fn expr_int(&self, sp: Span, i: int) -> @ast::expr {
fn expr_int(&self, sp: Span, i: int) -> @ast::Expr {
self.expr_lit(sp, ast::lit_int(i as i64, ast::ty_i))
}
fn expr_u8(&self, sp: Span, u: u8) -> @ast::expr {
fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr {
self.expr_lit(sp, ast::lit_uint(u as u64, ast::ty_u8))
}
fn expr_bool(&self, sp: Span, value: bool) -> @ast::expr {
fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr {
self.expr_lit(sp, ast::lit_bool(value))
}
fn expr_vstore(&self, sp: Span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr {
self.expr(sp, ast::expr_vstore(expr, vst))
fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr {
self.expr(sp, ast::ExprVstore(expr, vst))
}
fn expr_vec(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr {
self.expr(sp, ast::expr_vec(exprs, ast::m_imm))
fn expr_vec(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr {
self.expr(sp, ast::ExprVec(exprs, ast::MutImmutable))
}
fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr {
self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_uniq)
fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr {
self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::ExprVstoreUniq)
}
fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr {
self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_slice)
fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr {
self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::ExprVstoreSlice)
}
fn expr_str(&self, sp: Span, s: @str) -> @ast::expr {
fn expr_str(&self, sp: Span, s: @str) -> @ast::Expr {
self.expr_lit(sp, ast::lit_str(s))
}
fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::expr {
self.expr_vstore(sp, self.expr_str(sp, s), ast::expr_vstore_uniq)
fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::Expr {
self.expr_vstore(sp, self.expr_str(sp, s), ast::ExprVstoreUniq)
}
fn expr_unreachable(&self, span: Span) -> @ast::expr {
fn expr_unreachable(&self, span: Span) -> @ast::Expr {
let loc = self.codemap().lookup_char_pos(span.lo);
self.expr_call_global(
span,
@ -582,110 +582,110 @@ impl AstBuilder for @ExtCtxt {
}
fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat {
@ast::pat { id: self.next_id(), node: pat, span: span }
fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat {
@ast::Pat { id: self.next_id(), node: pat, span: span }
}
fn pat_wild(&self, span: Span) -> @ast::pat {
self.pat(span, ast::pat_wild)
fn pat_wild(&self, span: Span) -> @ast::Pat {
self.pat(span, ast::PatWild)
}
fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat {
self.pat(span, ast::pat_lit(expr))
fn pat_lit(&self, span: Span, expr: @ast::Expr) -> @ast::Pat {
self.pat(span, ast::PatLit(expr))
}
fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::pat {
self.pat_ident_binding_mode(span, ident, ast::bind_infer)
fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::Pat {
self.pat_ident_binding_mode(span, ident, ast::BindInfer)
}
fn pat_ident_binding_mode(&self,
span: Span,
ident: ast::Ident,
bm: ast::binding_mode) -> @ast::pat {
bm: ast::BindingMode) -> @ast::Pat {
let path = self.path_ident(span, ident);
let pat = ast::pat_ident(bm, path, None);
let pat = ast::PatIdent(bm, path, None);
self.pat(span, pat)
}
fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat {
let pat = ast::pat_enum(path, Some(subpats));
fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::Pat]) -> @ast::Pat {
let pat = ast::PatEnum(path, Some(subpats));
self.pat(span, pat)
}
fn pat_struct(&self, span: Span,
path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat {
let pat = ast::pat_struct(path, field_pats, false);
path: ast::Path, field_pats: ~[ast::FieldPat]) -> @ast::Pat {
let pat = ast::PatStruct(path, field_pats, false);
self.pat(span, pat)
}
fn arm(&self, _span: Span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm {
ast::arm {
fn arm(&self, _span: Span, pats: ~[@ast::Pat], expr: @ast::Expr) -> ast::Arm {
ast::Arm {
pats: pats,
guard: None,
body: self.block_expr(expr)
}
}
fn arm_unreachable(&self, span: Span) -> ast::arm {
fn arm_unreachable(&self, span: Span) -> ast::Arm {
self.arm(span, ~[self.pat_wild(span)], self.expr_unreachable(span))
}
fn expr_match(&self, span: Span, arg: @ast::expr, arms: ~[ast::arm]) -> @expr {
self.expr(span, ast::expr_match(arg, arms))
fn expr_match(&self, span: Span, arg: @ast::Expr, arms: ~[ast::Arm]) -> @Expr {
self.expr(span, ast::ExprMatch(arg, arms))
}
fn expr_if(&self, span: Span,
cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr {
cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr {
let els = els.map_move(|x| self.expr_block(self.block_expr(x)));
self.expr(span, ast::expr_if(cond, self.block_expr(then), els))
self.expr(span, ast::ExprIf(cond, self.block_expr(then), els))
}
fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr {
self.expr(span, ast::expr_fn_block(fn_decl, blk))
fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::Expr {
self.expr(span, ast::ExprFnBlock(fn_decl, blk))
}
fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::expr {
fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::Expr {
let fn_decl = self.fn_decl(
ids.map(|id| self.arg(span, *id, self.ty_infer(span))),
self.ty_infer(span));
self.expr(span, ast::expr_fn_block(fn_decl, blk))
self.expr(span, ast::ExprFnBlock(fn_decl, blk))
}
#[cfg(stage0)]
fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::expr {
fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::Expr {
let ext_cx = *self;
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone()));
quote_expr!(|| $blk_e )
}
#[cfg(not(stage0))]
fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::expr {
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::Expr {
let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone()));
quote_expr!(*self, || $blk_e )
}
#[cfg(stage0)]
fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr {
fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::Expr {
let ext_cx = *self;
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone()));
quote_expr!(|$ident| $blk_e )
}
#[cfg(not(stage0))]
fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr {
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::Expr {
let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone()));
quote_expr!(*self, |$ident| $blk_e )
}
fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], expr: @ast::expr) -> @ast::expr {
fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], expr: @ast::Expr) -> @ast::Expr {
self.lambda(span, ids, self.block_expr(expr))
}
fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr {
fn lambda_expr_0(&self, span: Span, expr: @ast::Expr) -> @ast::Expr {
self.lambda0(span, self.block_expr(expr))
}
fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr {
fn lambda_expr_1(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr {
self.lambda1(span, self.block_expr(expr), ident)
}
fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], stmts: ~[@ast::stmt]) -> @ast::expr {
fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], stmts: ~[@ast::Stmt]) -> @ast::Expr {
self.lambda(span, ids, self.block(span, stmts, None))
}
fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr {
fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::Stmt]) -> @ast::Expr {
self.lambda0(span, self.block(span, stmts, None))
}
fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::Ident) -> @ast::expr {
fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::Stmt], ident: ast::Ident) -> @ast::Expr {
self.lambda1(span, self.block(span, stmts, None), ident)
}
@ -889,8 +889,8 @@ pub trait Duplicate {
fn duplicate(&self, cx: @ExtCtxt) -> Self;
}
impl Duplicate for @ast::expr {
fn duplicate(&self, cx: @ExtCtxt) -> @ast::expr {
impl Duplicate for @ast::Expr {
fn duplicate(&self, cx: @ExtCtxt) -> @ast::Expr {
let folder = fold::default_ast_fold();
let folder = @fold::AstFoldFns {
new_id: |_| cx.next_id(),

View file

@ -24,7 +24,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> bas
for expr in exprs.iter() {
match expr.node {
// expression is a literal
ast::expr_lit(lit) => match lit.node {
ast::ExprLit(lit) => match lit.node {
// string literal, push each byte to vector expression
ast::lit_str(s) => {
for byte in s.byte_iter() {

View file

@ -34,9 +34,9 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
}
let res = str_to_ident(res_str);
let e = @ast::expr {
let e = @ast::Expr {
id: cx.next_id(),
node: ast::expr_path(
node: ast::ExprPath(
ast::Path {
span: sp,
global: false,

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -69,7 +69,7 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
fn cs_clone(
name: &str,
cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr {
substr: &Substructure) -> @Expr {
let clone_ident = substr.method_ident;
let ctor_ident;
let all_fields;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -20,11 +20,11 @@ pub fn expand_deriving_eq(cx: @ExtCtxt,
in_items: ~[@item]) -> ~[@item] {
// structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different
fn cs_eq(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn cs_eq(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span, substr)
}
fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_or(|cx, span, _, _| cx.expr_bool(span, true),
cx, span, substr)
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
use ast;
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -48,8 +48,8 @@ pub fn expand_deriving_ord(cx: @ExtCtxt,
}
/// Strict inequality.
fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
let op = if less {ast::lt} else {ast::gt};
fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
let op = if less {ast::BiLt} else {ast::BiGt};
cs_fold(
false, // need foldr,
|cx, span, subexpr, self_f, other_fs| {
@ -79,13 +79,13 @@ fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructur
cx.expr_deref(span, self_f),
cx.expr_deref(span, other_f));
let not_cmp = cx.expr_unary(span, ast::not,
let not_cmp = cx.expr_unary(span, ast::UnNot,
cx.expr_binary(span, op,
cx.expr_deref(span, other_f),
cx.expr_deref(span, self_f)));
let and = cx.expr_binary(span, ast::and, not_cmp, subexpr);
cx.expr_binary(span, ast::or, cmp, and)
let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr);
cx.expr_binary(span, ast::BiOr, cmp, and)
},
cx.expr_bool(span, equal),
|cx, span, args, _| {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -18,7 +18,7 @@ pub fn expand_deriving_totaleq(cx: @ExtCtxt,
span: Span,
mitem: @MetaItem,
in_items: ~[@item]) -> ~[@item] {
fn cs_equals(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn cs_equals(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span, substr)
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
use ast;
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -54,7 +54,7 @@ pub fn ordering_const(cx: @ExtCtxt, span: Span, cnst: Ordering) -> ast::Path {
}
pub fn cs_cmp(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr {
substr: &Substructure) -> @Expr {
let test_id = cx.ident_of("__test");
let equals_path = ordering_const(cx, span, Equal);
@ -89,7 +89,7 @@ pub fn cs_cmp(cx: @ExtCtxt, span: Span,
let assign = cx.stmt_let(span, false, test_id, new);
let cond = cx.expr_binary(span, ast::eq,
let cond = cx.expr_binary(span, ast::BiEq,
cx.expr_ident(span, test_id),
cx.expr_path(equals_path.clone()));
let if_ = cx.expr_if(span,

View file

@ -15,7 +15,7 @@ encodable.rs for more.
use std::vec;
use ast::{MetaItem, item, expr, m_mutbl};
use ast::{MetaItem, item, Expr, MutMutable};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -39,7 +39,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt,
generics: LifetimeBounds::empty(),
explicit_self: None,
args: ~[Ptr(~Literal(Path::new_local("__D")),
Borrowed(None, m_mutbl))],
Borrowed(None, MutMutable))],
ret_ty: Self,
const_nonmatching: true,
combine_substructure: decodable_substructure,
@ -51,7 +51,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt,
}
fn decodable_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr {
substr: &Substructure) -> @Expr {
let decoder = substr.nonself_args[0];
let recurse = ~[cx.ident_of("extra"),
cx.ident_of("serialize"),

View file

@ -75,7 +75,7 @@ would yield functions like:
}
*/
use ast::{MetaItem, item, expr, m_imm, m_mutbl};
use ast::{MetaItem, item, Expr, MutImmutable, MutMutable};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -97,9 +97,9 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt,
MethodDef {
name: "encode",
generics: LifetimeBounds::empty(),
explicit_self: Some(Some(Borrowed(None, m_imm))),
explicit_self: Some(Some(Borrowed(None, MutImmutable))),
args: ~[Ptr(~Literal(Path::new_local("__E")),
Borrowed(None, m_mutbl))],
Borrowed(None, MutMutable))],
ret_ty: nil_ty(),
const_nonmatching: true,
combine_substructure: encodable_substructure,
@ -111,7 +111,7 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt,
}
fn encodable_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr {
substr: &Substructure) -> @Expr {
let encoder = substr.nonself_args[0];
// throw an underscore in front to suppress unused variable warnings
let blkarg = cx.ident_of("_e");

View file

@ -163,7 +163,7 @@ StaticEnum(<ast::enum_def of C>, ~[(<ident of C0>, Left(1)),
*/
use ast;
use ast::{enum_def, expr, Ident, Generics, struct_def};
use ast::{enum_def, Expr, Ident, Generics, struct_def};
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -220,9 +220,9 @@ pub struct Substructure<'self> {
/// ident of the method
method_ident: Ident,
/// dereferenced access to any Self or Ptr(Self, _) arguments
self_args: &'self [@expr],
self_args: &'self [@Expr],
/// verbatim access to any other arguments
nonself_args: &'self [@expr],
nonself_args: &'self [@Expr],
fields: &'self SubstructureFields<'self>
}
@ -234,21 +234,21 @@ pub enum SubstructureFields<'self> {
ident is the ident of the current field (`None` for all fields in tuple
structs).
*/
Struct(~[(Option<Ident>, @expr, ~[@expr])]),
Struct(~[(Option<Ident>, @Expr, ~[@Expr])]),
/**
Matching variants of the enum: variant index, ast::variant,
fields: `(field ident, self, [others])`, where the field ident is
only non-`None` in the case of a struct variant.
*/
EnumMatching(uint, &'self ast::variant, ~[(Option<Ident>, @expr, ~[@expr])]),
EnumMatching(uint, &'self ast::variant, ~[(Option<Ident>, @Expr, ~[@Expr])]),
/**
non-matching variants of the enum, [(variant index, ast::variant,
[field ident, fields])] (i.e. all fields for self are in the
first tuple, for other1 are in the second tuple, etc.)
*/
EnumNonMatching(&'self [(uint, ast::variant, ~[(Option<Ident>, @expr)])]),
EnumNonMatching(&'self [(uint, ast::variant, ~[(Option<Ident>, @Expr)])]),
/// A static method where Self is a struct
StaticStruct(&'self ast::struct_def, Either<uint, ~[Ident]>),
@ -263,7 +263,7 @@ Combine the values of all the fields together. The last argument is
all the fields of all the structures, see above for details.
*/
pub type CombineSubstructureFunc<'self> =
&'self fn(@ExtCtxt, Span, &Substructure) -> @expr;
&'self fn(@ExtCtxt, Span, &Substructure) -> @Expr;
/**
Deal with non-matching enum variants, the arguments are a list
@ -273,8 +273,8 @@ representing each variant: (variant index, ast::variant instance,
pub type EnumNonMatchFunc<'self> =
&'self fn(@ExtCtxt, Span,
&[(uint, ast::variant,
~[(Option<Ident>, @expr)])],
&[@expr]) -> @expr;
~[(Option<Ident>, @Expr)])],
&[@Expr]) -> @Expr;
impl<'self> TraitDef<'self> {
@ -440,10 +440,10 @@ impl<'self> MethodDef<'self> {
cx: @ExtCtxt,
span: Span,
type_ident: Ident,
self_args: &[@expr],
nonself_args: &[@expr],
self_args: &[@Expr],
nonself_args: &[@Expr],
fields: &SubstructureFields)
-> @expr {
-> @Expr {
let substructure = Substructure {
type_ident: type_ident,
method_ident: cx.ident_of(self.name),
@ -466,7 +466,7 @@ impl<'self> MethodDef<'self> {
fn split_self_nonself_args(&self, cx: @ExtCtxt, span: Span,
type_ident: Ident, generics: &Generics)
-> (ast::explicit_self, ~[@expr], ~[@expr], ~[(Ident, ast::Ty)]) {
-> (ast::explicit_self, ~[@Expr], ~[@Expr], ~[(Ident, ast::Ty)]) {
let mut self_args = ~[];
let mut nonself_args = ~[];
@ -515,7 +515,7 @@ impl<'self> MethodDef<'self> {
generics: &Generics,
explicit_self: ast::explicit_self,
arg_types: ~[(Ident, ast::Ty)],
body: @expr) -> @ast::method {
body: @Expr) -> @ast::method {
// create the generics that aren't for Self
let fn_generics = self.generics.to_generics(cx, span, type_ident, generics);
@ -572,9 +572,9 @@ impl<'self> MethodDef<'self> {
span: Span,
struct_def: &struct_def,
type_ident: Ident,
self_args: &[@expr],
nonself_args: &[@expr])
-> @expr {
self_args: &[@Expr],
nonself_args: &[@Expr])
-> @Expr {
let mut raw_fields = ~[]; // ~[[fields of self],
// [fields of next Self arg], [etc]]
@ -582,7 +582,7 @@ impl<'self> MethodDef<'self> {
for i in range(0u, self_args.len()) {
let (pat, ident_expr) = create_struct_pattern(cx, span,
type_ident, struct_def,
fmt!("__self_%u", i), ast::m_imm);
fmt!("__self_%u", i), ast::MutImmutable);
patterns.push(pat);
raw_fields.push(ident_expr);
}
@ -626,9 +626,9 @@ impl<'self> MethodDef<'self> {
span: Span,
struct_def: &struct_def,
type_ident: Ident,
self_args: &[@expr],
nonself_args: &[@expr])
-> @expr {
self_args: &[@Expr],
nonself_args: &[@Expr])
-> @Expr {
let summary = summarise_struct(cx, span, struct_def);
self.call_substructure_method(cx, span,
@ -668,9 +668,9 @@ impl<'self> MethodDef<'self> {
span: Span,
enum_def: &enum_def,
type_ident: Ident,
self_args: &[@expr],
nonself_args: &[@expr])
-> @expr {
self_args: &[@Expr],
nonself_args: &[@Expr])
-> @Expr {
let mut matches = ~[];
self.build_enum_match(cx, span, enum_def, type_ident,
self_args, nonself_args,
@ -703,12 +703,12 @@ impl<'self> MethodDef<'self> {
cx: @ExtCtxt, span: Span,
enum_def: &enum_def,
type_ident: Ident,
self_args: &[@expr],
nonself_args: &[@expr],
self_args: &[@Expr],
nonself_args: &[@Expr],
matching: Option<uint>,
matches_so_far: &mut ~[(uint, ast::variant,
~[(Option<Ident>, @expr)])],
match_count: uint) -> @expr {
~[(Option<Ident>, @Expr)])],
match_count: uint) -> @Expr {
if match_count == self_args.len() {
// we've matched against all arguments, so make the final
// expression at the bottom of the match tree
@ -787,7 +787,7 @@ impl<'self> MethodDef<'self> {
let (pattern, idents) = create_enum_variant_pattern(cx, span,
variant,
current_match_str,
ast::m_imm);
ast::MutImmutable);
matches_so_far.push((index,
/*bad*/ (*variant).clone(),
@ -818,7 +818,7 @@ impl<'self> MethodDef<'self> {
let (pattern, idents) = create_enum_variant_pattern(cx, span,
variant,
current_match_str,
ast::m_imm);
ast::MutImmutable);
matches_so_far.push((index,
/*bad*/ (*variant).clone(),
@ -853,9 +853,9 @@ impl<'self> MethodDef<'self> {
span: Span,
enum_def: &enum_def,
type_ident: Ident,
self_args: &[@expr],
nonself_args: &[@expr])
-> @expr {
self_args: &[@Expr],
nonself_args: &[@Expr])
-> @Expr {
let summary = do enum_def.variants.map |v| {
let ident = v.node.name;
let summary = match v.node.kind {
@ -898,11 +898,11 @@ fn summarise_struct(cx: @ExtCtxt, span: Span,
pub fn create_subpatterns(cx: @ExtCtxt,
span: Span,
field_paths: ~[ast::Path],
mutbl: ast::mutability)
-> ~[@ast::pat] {
mutbl: ast::Mutability)
-> ~[@ast::Pat] {
do field_paths.map |path| {
cx.pat(span,
ast::pat_ident(ast::bind_by_ref(mutbl), (*path).clone(), None))
ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None))
}
}
@ -916,12 +916,12 @@ fn create_struct_pattern(cx: @ExtCtxt,
struct_ident: Ident,
struct_def: &struct_def,
prefix: &str,
mutbl: ast::mutability)
-> (@ast::pat, ~[(Option<Ident>, @expr)]) {
mutbl: ast::Mutability)
-> (@ast::Pat, ~[(Option<Ident>, @Expr)]) {
if struct_def.fields.is_empty() {
return (
cx.pat_ident_binding_mode(
span, struct_ident, ast::bind_infer),
span, struct_ident, ast::BindInfer),
~[]);
}
@ -961,7 +961,7 @@ fn create_struct_pattern(cx: @ExtCtxt,
let field_pats = do vec::build |push| {
for (&pat, &(id, _)) in subpats.iter().zip(ident_expr.iter()) {
// id is guaranteed to be Some
push(ast::field_pat { ident: id.unwrap(), pat: pat })
push(ast::FieldPat { ident: id.unwrap(), pat: pat })
}
};
cx.pat_struct(span, matching_path, field_pats)
@ -976,15 +976,15 @@ fn create_enum_variant_pattern(cx: @ExtCtxt,
span: Span,
variant: &ast::variant,
prefix: &str,
mutbl: ast::mutability)
-> (@ast::pat, ~[(Option<Ident>, @expr)]) {
mutbl: ast::Mutability)
-> (@ast::Pat, ~[(Option<Ident>, @Expr)]) {
let variant_ident = variant.node.name;
match variant.node.kind {
ast::tuple_variant_kind(ref variant_args) => {
if variant_args.is_empty() {
return (cx.pat_ident_binding_mode(
span, variant_ident, ast::bind_infer), ~[]);
span, variant_ident, ast::BindInfer), ~[]);
}
let matching_path = cx.path_ident(span, variant_ident);
@ -1023,13 +1023,13 @@ left-to-right (`true`) or right-to-left (`false`).
*/
pub fn cs_fold(use_foldl: bool,
f: &fn(@ExtCtxt, Span,
old: @expr,
self_f: @expr,
other_fs: &[@expr]) -> @expr,
base: @expr,
old: @Expr,
self_f: @Expr,
other_fs: &[@Expr]) -> @Expr,
base: @Expr,
enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr {
substructure: &Substructure) -> @Expr {
match *substructure.fields {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
if use_foldl {
@ -1064,10 +1064,10 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
~~~
*/
#[inline]
pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@expr]) -> @expr,
pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@Expr]) -> @Expr,
enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr {
substructure: &Substructure) -> @Expr {
match *substructure.fields {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
// call self_n.method(other_1_n, other_2_n, ...)
@ -1097,11 +1097,11 @@ fields. `use_foldl` controls whether this is done left-to-right
*/
#[inline]
pub fn cs_same_method_fold(use_foldl: bool,
f: &fn(@ExtCtxt, Span, @expr, @expr) -> @expr,
base: @expr,
f: &fn(@ExtCtxt, Span, @Expr, @Expr) -> @Expr,
base: @Expr,
enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr {
substructure: &Substructure) -> @Expr {
cs_same_method(
|cx, span, vals| {
if use_foldl {
@ -1124,10 +1124,10 @@ Use a given binop to combine the result of calling the derived method
on all the fields.
*/
#[inline]
pub fn cs_binop(binop: ast::binop, base: @expr,
pub fn cs_binop(binop: ast::BinOp, base: @Expr,
enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr {
substructure: &Substructure) -> @Expr {
cs_same_method_fold(
true, // foldl is good enough
|cx, span, old, new| {
@ -1145,8 +1145,8 @@ pub fn cs_binop(binop: ast::binop, base: @expr,
#[inline]
pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr {
cs_binop(ast::or, cx.expr_bool(span, false),
substructure: &Substructure) -> @Expr {
cs_binop(ast::BiOr, cx.expr_bool(span, false),
enum_nonmatch_f,
cx, span, substructure)
}
@ -1154,8 +1154,8 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
#[inline]
pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: Span,
substructure: &Substructure) -> @expr {
cs_binop(ast::and, cx.expr_bool(span, true),
substructure: &Substructure) -> @Expr {
cs_binop(ast::BiAnd, cx.expr_bool(span, true),
enum_nonmatch_f,
cx, span, substructure)
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{MetaItem, item, expr, and};
use ast::{MetaItem, item, Expr, BiAnd};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -42,7 +42,7 @@ pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items)
}
fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
let (lsb0, f)= match substr.nonself_args {
[l, f] => (l, f),
_ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`")
@ -90,6 +90,6 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @
}
do exprs.slice(1, exprs.len()).iter().fold(exprs[0]) |prev, me| {
cx.expr_binary(span, and, prev, *me)
cx.expr_binary(span, BiAnd, prev, *me)
}
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
use ast;
use ast::{MetaItem, item, expr, Ident};
use ast::{MetaItem, item, Expr, Ident};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::{AstBuilder, Duplicate};
@ -37,7 +37,7 @@ pub fn expand_deriving_rand(cx: @ExtCtxt,
explicit_self: None,
args: ~[
Ptr(~Literal(Path::new_local("R")),
Borrowed(None, ast::m_mutbl))
Borrowed(None, ast::MutMutable))
],
ret_ty: Self,
const_nonmatching: false,
@ -48,7 +48,7 @@ pub fn expand_deriving_rand(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items)
}
fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
let rng = match substr.nonself_args {
[rng] => ~[ rng ],
_ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`")
@ -100,7 +100,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
// rand() % variants.len()
let value_ref = cx.expr_ident(span, value_ident);
let rand_variant = cx.expr_binary(span,
ast::rem,
ast::BiRem,
value_ref,
variant_count);
@ -115,7 +115,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
rand_thing(cx, span, ident, summary, || rand_call()))
}
}
}.collect::<~[ast::arm]>();
}.collect::<~[ast::Arm]>();
// _ => {} at the end. Should never occur
arms.push(cx.arm_unreachable(span));
@ -131,7 +131,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn rand_thing(cx: @ExtCtxt, span: Span,
ctor_ident: Ident,
summary: &Either<uint, ~[Ident]>,
rand_call: &fn() -> @expr) -> @expr {
rand_call: &fn() -> @Expr) -> @Expr {
match *summary {
Left(count) => {
if count == 0 {

View file

@ -9,7 +9,7 @@
// except according to those terms.
use ast;
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -44,11 +44,11 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt,
// to_str() method on each field. Hence we mirror the logic of the log_str()
// method, but with tweaks to call to_str() on sub-fields.
fn to_str_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr {
substr: &Substructure) -> @Expr {
let to_str = cx.ident_of("to_str");
let doit = |start: &str, end: @str, name: ast::Ident,
fields: &[(Option<ast::Ident>, @expr, ~[@expr])]| {
fields: &[(Option<ast::Ident>, @Expr, ~[@Expr])]| {
if fields.len() == 0 {
cx.expr_str_uniq(span, cx.str_of(name))
} else {
@ -58,7 +58,7 @@ fn to_str_substructure(cx: @ExtCtxt, span: Span,
let mut stmts = ~[cx.stmt_let(span, true, buf, init)];
let push_str = cx.ident_of("push_str");
let push = |s: @expr| {
let push = |s: @Expr| {
let ebuf = cx.expr_ident(span, buf);
let call = cx.expr_method_call(span, ebuf, push_str, ~[s]);
stmts.push(cx.stmt_expr(call));

View file

@ -14,7 +14,7 @@ explicit `Self` type to use when specifying impls to be derived.
*/
use ast;
use ast::{expr,Generics,Ident};
use ast::{Expr,Generics,Ident};
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use codemap::{Span,respan};
@ -23,8 +23,8 @@ use opt_vec;
/// The types of pointers
pub enum PtrTy<'self> {
Send, // ~
Managed(ast::mutability), // @[mut]
Borrowed(Option<&'self str>, ast::mutability), // &['lifetime] [mut]
Managed(ast::Mutability), // @[mut]
Borrowed(Option<&'self str>, ast::Mutability), // &['lifetime] [mut]
}
/// A path, e.g. `::std::option::Option::<int>` (global). Has support
@ -91,7 +91,7 @@ pub enum Ty<'self> {
}
pub fn borrowed_ptrty<'r>() -> PtrTy<'r> {
Borrowed(None, ast::m_imm)
Borrowed(None, ast::MutImmutable)
}
pub fn borrowed<'r>(ty: ~Ty<'r>) -> Ty<'r> {
Ptr(ty, borrowed_ptrty())
@ -236,7 +236,7 @@ impl<'self> LifetimeBounds<'self> {
pub fn get_explicit_self(cx: @ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
-> (@expr, ast::explicit_self) {
-> (@Expr, ast::explicit_self) {
let self_path = cx.expr_self(span);
match *self_ptr {
None => {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{MetaItem, item, expr};
use ast::{MetaItem, item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
@ -55,7 +55,7 @@ pub fn expand_deriving_zero(cx: @ExtCtxt,
trait_def.expand(cx, span, mitem, in_items)
}
fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
let zero_ident = ~[
cx.ident_of("std"),
cx.ident_of("num"),

View file

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{Block, Crate, NodeId, expr_, expr_mac, Ident, mac_invoc_tt};
use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
use ast::{illegal_ctxt};
use ast::{Block, Crate, NodeId, Expr_, ExprMac, Ident, mac_invoc_tt};
use ast::{item_mac, Stmt_, StmtMac, StmtExpr, StmtSemi};
use ast::{ILLEGAL_CTXT};
use ast;
use ast_util::{new_rename, new_mark, resolve};
use attr;
@ -31,15 +31,15 @@ use std::vec;
pub fn expand_expr(extsbox: @mut SyntaxEnv,
cx: @ExtCtxt,
e: &expr_,
e: &Expr_,
s: Span,
fld: @ast_fold,
orig: @fn(&expr_, Span, @ast_fold) -> (expr_, Span))
-> (expr_, Span) {
orig: @fn(&Expr_, Span, @ast_fold) -> (Expr_, Span))
-> (Expr_, Span) {
match *e {
// expr_mac should really be expr_ext or something; it's the
// entry-point for all syntax extensions.
expr_mac(ref mac) => {
ExprMac(ref mac) => {
match (*mac).node {
// Token-tree macros:
mac_invoc_tt(ref pth, ref tts) => {
@ -104,7 +104,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
// Desugar expr_for_loop
// From: `for <src_pat> in <src_expr> <src_loop_block>`
ast::expr_for_loop(src_pat, src_expr, ref src_loop_block) => {
ast::ExprForLoop(src_pat, src_expr, ref src_loop_block) => {
let src_pat = src_pat.clone();
let src_expr = src_expr.clone();
@ -118,8 +118,8 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
let hi = s.hi;
pub fn mk_expr(cx: @ExtCtxt, span: Span,
node: expr_) -> @ast::expr {
@ast::expr {
node: Expr_) -> @ast::Expr {
@ast::Expr {
id: cx.next_id(),
node: node,
span: span,
@ -127,8 +127,8 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
}
fn mk_block(cx: @ExtCtxt,
stmts: &[@ast::stmt],
expr: Option<@ast::expr>,
stmts: &[@ast::Stmt],
expr: Option<@ast::Expr>,
span: Span) -> ast::Block {
ast::Block {
view_items: ~[],
@ -186,33 +186,33 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
let local = @ast::Local {
is_mutbl: false,
ty: ty,
pat: @ast::pat {
pat: @ast::Pat {
id: cx.next_id(),
node: ast::pat_ident(ast::bind_infer, local_path_1, None),
node: ast::PatIdent(ast::BindInfer, local_path_1, None),
span: src_expr.span
},
init: Some(mk_expr(cx, src_expr.span,
ast::expr_addr_of(ast::m_mutbl, src_expr))),
ast::ExprAddrOf(ast::MutMutable, src_expr))),
id: cx.next_id(),
span: src_expr.span,
};
let e = @spanned(src_expr.span.lo,
src_expr.span.hi,
ast::decl_local(local));
@spanned(lo, hi, ast::stmt_decl(e, cx.next_id()))
ast::DeclLocal(local));
@spanned(lo, hi, ast::StmtDecl(e, cx.next_id()))
};
// `None => break;`
let none_arm = {
let break_expr = mk_expr(cx, span, ast::expr_break(None));
let break_stmt = @spanned(lo, hi, ast::stmt_expr(break_expr, cx.next_id()));
let break_expr = mk_expr(cx, span, ast::ExprBreak(None));
let break_stmt = @spanned(lo, hi, ast::StmtExpr(break_expr, cx.next_id()));
let none_block = mk_block(cx, [break_stmt], None, span);
let none_pat = @ast::pat {
let none_pat = @ast::Pat {
id: cx.next_id(),
node: ast::pat_ident(ast::bind_infer, none_path, None),
node: ast::PatIdent(ast::BindInfer, none_path, None),
span: span
};
ast::arm {
ast::Arm {
pats: ~[none_pat],
guard: None,
body: none_block
@ -221,12 +221,12 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
// `Some(<src_pat>) => <src_loop_block>`
let some_arm = {
let pat = @ast::pat {
let pat = @ast::Pat {
id: cx.next_id(),
node: ast::pat_enum(some_path, Some(~[src_pat])),
node: ast::PatEnum(some_path, Some(~[src_pat])),
span: src_pat.span
};
ast::arm {
ast::Arm {
pats: ~[pat],
guard: None,
body: src_loop_block
@ -235,27 +235,27 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
// `match i.next() { ... }`
let match_stmt = {
let local_expr = mk_expr(cx, span, ast::expr_path(local_path_2));
let local_expr = mk_expr(cx, span, ast::ExprPath(local_path_2));
let next_call_expr = mk_expr(cx, span,
ast::expr_method_call(cx.next_id(),
ast::ExprMethodCall(cx.next_id(),
local_expr, next_ident,
~[], ~[], ast::NoSugar));
let match_expr = mk_expr(cx, span, ast::expr_match(next_call_expr,
let match_expr = mk_expr(cx, span, ast::ExprMatch(next_call_expr,
~[none_arm, some_arm]));
@spanned(lo, hi, ast::stmt_expr(match_expr, cx.next_id()))
@spanned(lo, hi, ast::StmtExpr(match_expr, cx.next_id()))
};
// `loop { ... }`
let loop_block = {
let loop_body_block = mk_block(cx, [match_stmt], None, span);
let loop_body_expr = mk_expr(cx, span, ast::expr_loop(loop_body_block, None));
let loop_body_stmt = @spanned(lo, hi, ast::stmt_expr(loop_body_expr, cx.next_id()));
let loop_body_expr = mk_expr(cx, span, ast::ExprLoop(loop_body_block, None));
let loop_body_stmt = @spanned(lo, hi, ast::StmtExpr(loop_body_expr, cx.next_id()));
mk_block(cx, [iter_decl_stmt,
loop_body_stmt],
None, span)
};
(ast::expr_block(loop_block), span)
(ast::ExprBlock(loop_block), span)
}
_ => orig(e, s, fld)
@ -448,14 +448,14 @@ fn insert_macro(exts: SyntaxEnv, name: ast::Name, transformer: @Transformer) {
// expand a stmt
pub fn expand_stmt(extsbox: @mut SyntaxEnv,
cx: @ExtCtxt,
s: &stmt_,
s: &Stmt_,
sp: Span,
fld: @ast_fold,
orig: @fn(&stmt_, Span, @ast_fold)
-> (Option<stmt_>, Span))
-> (Option<stmt_>, Span) {
orig: @fn(&Stmt_, Span, @ast_fold)
-> (Option<Stmt_>, Span))
-> (Option<Stmt_>, Span) {
let (mac, pth, tts, semi) = match *s {
stmt_mac(ref mac, semi) => {
StmtMac(ref mac, semi) => {
match mac.node {
mac_invoc_tt(ref pth, ref tts) => {
((*mac).clone(), pth, (*tts).clone(), semi)
@ -484,7 +484,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
});
let expanded = match exp(cx, mac.span, tts) {
MRExpr(e) =>
@codemap::Spanned { node: stmt_expr(e, cx.next_id()),
@codemap::Spanned { node: StmtExpr(e, cx.next_id()),
span: e.span},
MRAny(_,_,stmt_mkr) => stmt_mkr(),
_ => cx.span_fatal(
@ -515,7 +515,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
};
(match fully_expanded {
stmt_expr(e, stmt_id) if semi => Some(stmt_semi(e, stmt_id)),
StmtExpr(e, stmt_id) if semi => Some(StmtSemi(e, stmt_id)),
_ => { Some(fully_expanded) } /* might already have a semi */
}, sp)
@ -527,12 +527,12 @@ struct NewNameFinderContext {
}
impl Visitor<()> for NewNameFinderContext {
fn visit_pat(&mut self, pattern: @ast::pat, _: ()) {
fn visit_pat(&mut self, pattern: @ast::Pat, _: ()) {
match *pattern {
// we found a pat_ident!
ast::pat {
ast::Pat {
id: _,
node: ast::pat_ident(_, ref path, ref inner),
node: ast::PatIdent(_, ref path, ref inner),
span: _
} => {
match path {
@ -589,23 +589,23 @@ impl Visitor<()> for NewNameFinderContext {
visit::walk_block(self, block, ())
}
fn visit_stmt(&mut self, stmt: @ast::stmt, _: ()) {
fn visit_stmt(&mut self, stmt: @ast::Stmt, _: ()) {
visit::walk_stmt(self, stmt, ())
}
fn visit_arm(&mut self, arm: &ast::arm, _: ()) {
fn visit_arm(&mut self, arm: &ast::Arm, _: ()) {
visit::walk_arm(self, arm, ())
}
fn visit_decl(&mut self, decl: @ast::decl, _: ()) {
fn visit_decl(&mut self, decl: @ast::Decl, _: ()) {
visit::walk_decl(self, decl, ())
}
fn visit_expr(&mut self, expr: @ast::expr, _: ()) {
fn visit_expr(&mut self, expr: @ast::Expr, _: ()) {
visit::walk_expr(self, expr, ())
}
fn visit_expr_post(&mut self, _: @ast::expr, _: ()) {
fn visit_expr_post(&mut self, _: @ast::Expr, _: ()) {
// Empty!
}
@ -714,7 +714,7 @@ fn renames_to_fold(renames : @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold {
}
// perform a bunch of renames
fn apply_pending_renames(folder : @ast_fold, stmt : ast::stmt) -> @ast::stmt {
fn apply_pending_renames(folder : @ast_fold, stmt : ast::Stmt) -> @ast::Stmt {
match folder.fold_stmt(&stmt) {
Some(s) => s,
None => fail!(fmt!("renaming of stmt produced None"))
@ -1182,7 +1182,7 @@ pub fn new_ident_resolver() ->
|id : ast::Ident|
ast::Ident {
name : resolve(id),
ctxt : illegal_ctxt
ctxt : ILLEGAL_CTXT
}
}
@ -1191,7 +1191,7 @@ pub fn new_ident_resolver() ->
mod test {
use super::*;
use ast;
use ast::{Attribute_, AttrOuter, MetaWord, empty_ctxt};
use ast::{Attribute_, AttrOuter, MetaWord, EMPTY_CTXT};
use codemap;
use codemap::Spanned;
use parse;
@ -1304,7 +1304,7 @@ mod test {
};
let a_name = intern("a");
let a2_name = intern("a2");
let renamer = new_ident_renamer(ast::Ident{name:a_name,ctxt:empty_ctxt},
let renamer = new_ident_renamer(ast::Ident{name:a_name,ctxt:EMPTY_CTXT},
a2_name);
let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).unwrap();
let resolver = new_ident_resolver();

View file

@ -48,8 +48,8 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
// expressions. Also: Cleanup the naming of these functions.
// Note: Moved many of the common ones to build.rs --kevina
fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
pieces: ~[Piece], args: ~[@ast::expr])
-> @ast::expr {
pieces: ~[Piece], args: ~[@ast::Expr])
-> @ast::Expr {
fn make_path_vec(ident: &str) -> ~[ast::Ident] {
return ~[str_to_ident("std"),
str_to_ident("unstable"),
@ -57,15 +57,15 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
str_to_ident("rt"),
str_to_ident(ident)];
}
fn make_rt_path_expr(cx: @ExtCtxt, sp: Span, nm: &str) -> @ast::expr {
fn make_rt_path_expr(cx: @ExtCtxt, sp: Span, nm: &str) -> @ast::Expr {
let path = make_path_vec(nm);
cx.expr_path(cx.path_global(sp, path))
}
// Produces an AST expression that represents a RT::conv record,
// which tells the RT::conv* functions how to perform the conversion
fn make_rt_conv_expr(cx: @ExtCtxt, sp: Span, cnv: &Conv) -> @ast::expr {
fn make_flags(cx: @ExtCtxt, sp: Span, flags: &[Flag]) -> @ast::expr {
fn make_rt_conv_expr(cx: @ExtCtxt, sp: Span, cnv: &Conv) -> @ast::Expr {
fn make_flags(cx: @ExtCtxt, sp: Span, flags: &[Flag]) -> @ast::Expr {
let mut tmp_expr = make_rt_path_expr(cx, sp, "flag_none");
for f in flags.iter() {
let fstr = match *f {
@ -75,12 +75,12 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
FlagSignAlways => "flag_sign_always",
FlagAlternate => "flag_alternate"
};
tmp_expr = cx.expr_binary(sp, ast::bitor, tmp_expr,
tmp_expr = cx.expr_binary(sp, ast::BiBitOr, tmp_expr,
make_rt_path_expr(cx, sp, fstr));
}
return tmp_expr;
}
fn make_count(cx: @ExtCtxt, sp: Span, cnt: Count) -> @ast::expr {
fn make_count(cx: @ExtCtxt, sp: Span, cnt: Count) -> @ast::Expr {
match cnt {
CountImplied => {
return make_rt_path_expr(cx, sp, "CountImplied");
@ -94,7 +94,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
_ => cx.span_unimpl(sp, "unimplemented fmt! conversion")
}
}
fn make_ty(cx: @ExtCtxt, sp: Span, t: Ty) -> @ast::expr {
fn make_ty(cx: @ExtCtxt, sp: Span, t: Ty) -> @ast::Expr {
let rt_type = match t {
TyHex(c) => match c {
CaseUpper => "TyHexUpper",
@ -106,9 +106,9 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
};
return make_rt_path_expr(cx, sp, rt_type);
}
fn make_conv_struct(cx: @ExtCtxt, sp: Span, flags_expr: @ast::expr,
width_expr: @ast::expr, precision_expr: @ast::expr,
ty_expr: @ast::expr) -> @ast::expr {
fn make_conv_struct(cx: @ExtCtxt, sp: Span, flags_expr: @ast::Expr,
width_expr: @ast::Expr, precision_expr: @ast::Expr,
ty_expr: @ast::Expr) -> @ast::Expr {
cx.expr_struct(
sp,
cx.path_global(sp, make_path_vec("Conv")),
@ -128,7 +128,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
rt_conv_precision, rt_conv_ty)
}
fn make_conv_call(cx: @ExtCtxt, sp: Span, conv_type: &str, cnv: &Conv,
arg: @ast::expr, buf: @ast::expr) -> @ast::expr {
arg: @ast::Expr, buf: @ast::Expr) -> @ast::Expr {
let fname = ~"conv_" + conv_type;
let path = make_path_vec(fname);
let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
@ -137,7 +137,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
}
fn make_new_conv(cx: @ExtCtxt, sp: Span, cnv: &Conv,
arg: @ast::expr, buf: @ast::expr) -> @ast::expr {
arg: @ast::Expr, buf: @ast::Expr) -> @ast::Expr {
fn is_signed_type(cnv: &Conv) -> bool {
match cnv.ty {
TyInt(s) => match s {

View file

@ -34,14 +34,14 @@ struct Context {
// Parsed argument expressions and the types that we've found so far for
// them.
args: ~[@ast::expr],
args: ~[@ast::Expr],
arg_types: ~[Option<ArgumentType>],
// Parsed named expressions and the types that we've found for them so far
names: HashMap<@str, @ast::expr>,
names: HashMap<@str, @ast::Expr>,
name_types: HashMap<@str, ArgumentType>,
// Collection of the compiled `rt::Piece` structures
pieces: ~[@ast::expr],
pieces: ~[@ast::Expr],
name_positions: HashMap<@str, uint>,
method_statics: ~[@ast::item],
@ -55,8 +55,8 @@ impl Context {
/// there's a parse error so we can continue parsing other fmt! expressions.
fn parse_args(&mut self, sp: Span,
leading_expr: bool,
tts: &[ast::token_tree]) -> (Option<@ast::expr>,
Option<@ast::expr>) {
tts: &[ast::token_tree]) -> (Option<@ast::Expr>,
Option<@ast::Expr>) {
let p = rsparse::new_parser_from_tts(self.ecx.parse_sess(),
self.ecx.cfg(),
tts.to_owned());
@ -327,7 +327,7 @@ impl Context {
}
/// Translate a `parse::Piece` to a static `rt::Piece`
fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::expr {
fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::Expr {
let sp = self.fmtsp;
let parsepath = |s: &str| {
~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"),
@ -345,7 +345,7 @@ impl Context {
let p = self.ecx.path(sp, ~[self.ecx.ident_of("None")]);
self.ecx.expr_path(p)
};
let some = |e: @ast::expr| {
let some = |e: @ast::Expr| {
self.ecx.expr_call_ident(sp, self.ecx.ident_of("Some"), ~[e])
};
let trans_count = |c: parse::Count| {
@ -444,7 +444,7 @@ impl Context {
Some(life),
~[]
), None);
let st = ast::item_static(ty, ast::m_imm, method);
let st = ast::item_static(ty, ast::MutImmutable, method);
let static_name = self.ecx.ident_of(fmt!("__static_method_%u",
self.method_statics.len()));
// Flag these statics as `address_insignificant` so LLVM can
@ -542,16 +542,16 @@ impl Context {
/// Actually builds the expression which the ifmt! block will be expanded
/// to
fn to_expr(&self, extra: Option<@ast::expr>, f: &str) -> @ast::expr {
fn to_expr(&self, extra: Option<@ast::Expr>, f: &str) -> @ast::Expr {
let mut lets = ~[];
let mut locals = ~[];
let mut names = vec::from_fn(self.name_positions.len(), |_| None);
// First, declare all of our methods that are statics
for &method in self.method_statics.iter() {
let decl = respan(self.fmtsp, ast::decl_item(method));
let decl = respan(self.fmtsp, ast::DeclItem(method));
lets.push(@respan(self.fmtsp,
ast::stmt_decl(@decl, self.ecx.next_id())));
ast::StmtDecl(@decl, self.ecx.next_id())));
}
// Next, build up the static array which will become our precompiled
@ -570,19 +570,19 @@ impl Context {
Some(self.ecx.lifetime(self.fmtsp, self.ecx.ident_of("static"))),
~[]
), None),
ast::m_imm
ast::MutImmutable
),
self.ecx.expr_uint(self.fmtsp, self.pieces.len())
);
let ty = self.ecx.ty(self.fmtsp, ty);
let st = ast::item_static(ty, ast::m_imm, fmt);
let st = ast::item_static(ty, ast::MutImmutable, fmt);
let static_name = self.ecx.ident_of("__static_fmtstr");
// see above comment for `address_insignificant` and why we do it
let unnamed = self.ecx.meta_word(self.fmtsp, @"address_insignificant");
let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
let item = self.ecx.item(self.fmtsp, static_name, ~[unnamed], st);
let decl = respan(self.fmtsp, ast::decl_item(item));
lets.push(@respan(self.fmtsp, ast::stmt_decl(@decl, self.ecx.next_id())));
let decl = respan(self.fmtsp, ast::DeclItem(item));
lets.push(@respan(self.fmtsp, ast::StmtDecl(@decl, self.ecx.next_id())));
// Right now there is a bug such that for the expression:
// foo(bar(&1))
@ -637,7 +637,7 @@ impl Context {
}
fn format_arg(&self, sp: Span, arg: Either<uint, @str>,
ident: ast::Ident) -> @ast::expr {
ident: ast::Ident) -> @ast::Expr {
let ty = match arg {
Left(i) => self.arg_types[i].unwrap(),
Right(s) => *self.name_types.get(&s)

View file

@ -29,9 +29,9 @@ pub fn expand_syntax_ext(cx: @ExtCtxt,
get_ident_interner()));
//trivial expression
MRExpr(@ast::expr {
MRExpr(@ast::Expr {
id: cx.next_id(),
node: ast::expr_lit(@codemap::Spanned {
node: ast::ExprLit(@codemap::Spanned {
node: ast::lit_nil,
span: sp
}),

View file

@ -104,7 +104,7 @@ pub mod rt {
}
}
impl ToSource for @ast::expr {
impl ToSource for @ast::Expr {
fn to_source(&self) -> @str {
pprust::expr_to_str(*self, get_ident_interner()).to_managed()
}
@ -222,7 +222,7 @@ pub mod rt {
impl_to_tokens!(ast::Ty)
impl_to_tokens_self!(&'self [ast::Ty])
impl_to_tokens!(Generics)
impl_to_tokens!(@ast::expr)
impl_to_tokens!(@ast::Expr)
impl_to_tokens!(ast::Block)
impl_to_tokens_self!(&'self str)
impl_to_tokens!(int)
@ -238,8 +238,8 @@ pub mod rt {
pub trait ExtParseUtils {
fn parse_item(&self, s: @str) -> @ast::item;
fn parse_expr(&self, s: @str) -> @ast::expr;
fn parse_stmt(&self, s: @str) -> @ast::stmt;
fn parse_expr(&self, s: @str) -> @ast::Expr;
fn parse_stmt(&self, s: @str) -> @ast::Stmt;
fn parse_tts(&self, s: @str) -> ~[ast::token_tree];
}
@ -261,7 +261,7 @@ pub mod rt {
}
}
fn parse_stmt(&self, s: @str) -> @ast::stmt {
fn parse_stmt(&self, s: @str) -> @ast::Stmt {
parse::parse_stmt_from_source_str(
@"<quote expansion>",
s,
@ -270,7 +270,7 @@ pub mod rt {
self.parse_sess())
}
fn parse_expr(&self, s: @str) -> @ast::expr {
fn parse_expr(&self, s: @str) -> @ast::Expr {
parse::parse_expr_from_source_str(
@"<quote expansion>",
s,
@ -343,7 +343,7 @@ fn id_ext(str: &str) -> ast::Ident {
}
// Lift an ident to the expr that evaluates to that ident.
fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::expr {
fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr {
let e_str = cx.expr_str(sp, cx.str_of(ident));
cx.expr_method_call(sp,
cx.expr_ident(sp, id_ext("ext_cx")),
@ -351,13 +351,13 @@ fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::expr {
~[e_str])
}
fn mk_bytepos(cx: @ExtCtxt, sp: Span, bpos: BytePos) -> @ast::expr {
fn mk_bytepos(cx: @ExtCtxt, sp: Span, bpos: BytePos) -> @ast::Expr {
let path = id_ext("BytePos");
let arg = cx.expr_uint(sp, bpos.to_uint());
cx.expr_call_ident(sp, path, ~[arg])
}
fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::expr {
fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::Expr {
let name = match bop {
PLUS => "PLUS",
MINUS => "MINUS",
@ -373,7 +373,7 @@ fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::expr {
cx.expr_ident(sp, id_ext(name))
}
fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::expr {
fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
match *tok {
BINOP(binop) => {
@ -515,7 +515,7 @@ fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::expr {
fn mk_tt(cx: @ExtCtxt, sp: Span, tt: &ast::token_tree)
-> ~[@ast::stmt] {
-> ~[@ast::Stmt] {
match *tt {
@ -557,7 +557,7 @@ fn mk_tt(cx: @ExtCtxt, sp: Span, tt: &ast::token_tree)
}
fn mk_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> ~[@ast::stmt] {
-> ~[@ast::Stmt] {
let mut ss = ~[];
for tt in tts.iter() {
ss.push_all_move(mk_tt(cx, sp, tt));
@ -567,7 +567,7 @@ fn mk_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
fn expand_tts(cx: @ExtCtxt,
sp: Span,
tts: &[ast::token_tree]) -> (@ast::expr, @ast::expr) {
tts: &[ast::token_tree]) -> (@ast::Expr, @ast::Expr) {
// NB: It appears that the main parser loses its mind if we consider
// $foo as a tt_nonterminal during the main parse, so we have to re-parse
@ -640,8 +640,8 @@ fn expand_tts(cx: @ExtCtxt,
fn expand_wrapper(cx: @ExtCtxt,
sp: Span,
cx_expr: @ast::expr,
expr: @ast::expr) -> @ast::expr {
cx_expr: @ast::Expr,
expr: @ast::Expr) -> @ast::Expr {
let uses = ~[ cx.view_use_glob(sp, ast::public,
ids_ext(~[~"syntax",
~"ext",
@ -656,8 +656,8 @@ fn expand_wrapper(cx: @ExtCtxt,
fn expand_parse_call(cx: @ExtCtxt,
sp: Span,
parse_method: &str,
arg_exprs: ~[@ast::expr],
tts: &[ast::token_tree]) -> @ast::expr {
arg_exprs: ~[@ast::Expr],
tts: &[ast::token_tree]) -> @ast::Expr {
let (cx_expr, tts_expr) = expand_tts(cx, sp, tts);
let cfg_call = || cx.expr_method_call(

View file

@ -105,7 +105,7 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
result::Ok(src) => {
let u8_exprs: ~[@ast::expr] = src.iter().map(|char| cx.expr_u8(sp, *char)).collect();
let u8_exprs: ~[@ast::Expr] = src.iter().map(|char| cx.expr_u8(sp, *char)).collect();
base::MRExpr(cx.expr_vec(sp, u8_exprs))
}
result::Err(ref e) => {

View file

@ -23,11 +23,11 @@ pub trait ast_fold {
fn fold_item_underscore(@self, &item_) -> item_;
fn fold_method(@self, @method) -> @method;
fn fold_block(@self, &Block) -> Block;
fn fold_stmt(@self, &stmt) -> Option<@stmt>;
fn fold_arm(@self, &arm) -> arm;
fn fold_pat(@self, @pat) -> @pat;
fn fold_decl(@self, @decl) -> Option<@decl>;
fn fold_expr(@self, @expr) -> @expr;
fn fold_stmt(@self, &Stmt) -> Option<@Stmt>;
fn fold_arm(@self, &Arm) -> Arm;
fn fold_pat(@self, @Pat) -> @Pat;
fn fold_decl(@self, @Decl) -> Option<@Decl>;
fn fold_expr(@self, @Expr) -> @Expr;
fn fold_ty(@self, &Ty) -> Ty;
fn fold_mod(@self, &_mod) -> _mod;
fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod;
@ -35,7 +35,7 @@ pub trait ast_fold {
fn fold_ident(@self, Ident) -> Ident;
fn fold_path(@self, &Path) -> Path;
fn fold_local(@self, @Local) -> @Local;
fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr];
fn map_exprs(@self, @fn(@Expr) -> @Expr, &[@Expr]) -> ~[@Expr];
fn new_id(@self, NodeId) -> NodeId;
fn new_span(@self, Span) -> Span;
}
@ -52,11 +52,11 @@ pub struct AstFoldFns {
fold_item_underscore: @fn(&item_, @ast_fold) -> item_,
fold_method: @fn(@method, @ast_fold) -> @method,
fold_block: @fn(&Block, @ast_fold) -> Block,
fold_stmt: @fn(&stmt_, Span, @ast_fold) -> (Option<stmt_>, Span),
fold_arm: @fn(&arm, @ast_fold) -> arm,
fold_pat: @fn(&pat_, Span, @ast_fold) -> (pat_, Span),
fold_decl: @fn(&decl_, Span, @ast_fold) -> (Option<decl_>, Span),
fold_expr: @fn(&expr_, Span, @ast_fold) -> (expr_, Span),
fold_stmt: @fn(&Stmt_, Span, @ast_fold) -> (Option<Stmt_>, Span),
fold_arm: @fn(&Arm, @ast_fold) -> Arm,
fold_pat: @fn(&Pat_, Span, @ast_fold) -> (Pat_, Span),
fold_decl: @fn(&Decl_, Span, @ast_fold) -> (Option<Decl_>, Span),
fold_expr: @fn(&Expr_, Span, @ast_fold) -> (Expr_, Span),
fold_ty: @fn(&ty_, Span, @ast_fold) -> (ty_, Span),
fold_mod: @fn(&_mod, @ast_fold) -> _mod,
fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod,
@ -64,7 +64,7 @@ pub struct AstFoldFns {
fold_ident: @fn(Ident, @ast_fold) -> Ident,
fold_path: @fn(&Path, @ast_fold) -> Path,
fold_local: @fn(@Local, @ast_fold) -> @Local,
map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr],
map_exprs: @fn(@fn(@Expr) -> @Expr, &[@Expr]) -> ~[@Expr],
new_id: @fn(NodeId) -> NodeId,
new_span: @fn(Span) -> Span
}
@ -395,69 +395,69 @@ pub fn noop_fold_block(b: &Block, fld: @ast_fold) -> Block {
}
}
fn noop_fold_stmt(s: &stmt_, fld: @ast_fold) -> Option<stmt_> {
fn noop_fold_stmt(s: &Stmt_, fld: @ast_fold) -> Option<Stmt_> {
let fold_mac = |x| fold_mac_(x, fld);
match *s {
stmt_decl(d, nid) => {
StmtDecl(d, nid) => {
match fld.fold_decl(d) {
Some(d) => Some(stmt_decl(d, fld.new_id(nid))),
Some(d) => Some(StmtDecl(d, fld.new_id(nid))),
None => None,
}
}
stmt_expr(e, nid) => {
Some(stmt_expr(fld.fold_expr(e), fld.new_id(nid)))
StmtExpr(e, nid) => {
Some(StmtExpr(fld.fold_expr(e), fld.new_id(nid)))
}
stmt_semi(e, nid) => {
Some(stmt_semi(fld.fold_expr(e), fld.new_id(nid)))
StmtSemi(e, nid) => {
Some(StmtSemi(fld.fold_expr(e), fld.new_id(nid)))
}
stmt_mac(ref mac, semi) => Some(stmt_mac(fold_mac(mac), semi))
StmtMac(ref mac, semi) => Some(StmtMac(fold_mac(mac), semi))
}
}
fn noop_fold_arm(a: &arm, fld: @ast_fold) -> arm {
arm {
fn noop_fold_arm(a: &Arm, fld: @ast_fold) -> Arm {
Arm {
pats: a.pats.map(|x| fld.fold_pat(*x)),
guard: a.guard.map_move(|x| fld.fold_expr(x)),
body: fld.fold_block(&a.body),
}
}
pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
pub fn noop_fold_pat(p: &Pat_, fld: @ast_fold) -> Pat_ {
match *p {
pat_wild => pat_wild,
pat_ident(binding_mode, ref pth, ref sub) => {
pat_ident(
PatWild => PatWild,
PatIdent(binding_mode, ref pth, ref sub) => {
PatIdent(
binding_mode,
fld.fold_path(pth),
sub.map_move(|x| fld.fold_pat(x))
)
}
pat_lit(e) => pat_lit(fld.fold_expr(e)),
pat_enum(ref pth, ref pats) => {
pat_enum(
PatLit(e) => PatLit(fld.fold_expr(e)),
PatEnum(ref pth, ref pats) => {
PatEnum(
fld.fold_path(pth),
pats.map(|pats| pats.map(|x| fld.fold_pat(*x)))
)
}
pat_struct(ref pth, ref fields, etc) => {
PatStruct(ref pth, ref fields, etc) => {
let pth_ = fld.fold_path(pth);
let fs = do fields.map |f| {
ast::field_pat {
ast::FieldPat {
ident: f.ident,
pat: fld.fold_pat(f.pat)
}
};
pat_struct(pth_, fs, etc)
PatStruct(pth_, fs, etc)
}
pat_tup(ref elts) => pat_tup(elts.map(|x| fld.fold_pat(*x))),
pat_box(inner) => pat_box(fld.fold_pat(inner)),
pat_uniq(inner) => pat_uniq(fld.fold_pat(inner)),
pat_region(inner) => pat_region(fld.fold_pat(inner)),
pat_range(e1, e2) => {
pat_range(fld.fold_expr(e1), fld.fold_expr(e2))
PatTup(ref elts) => PatTup(elts.map(|x| fld.fold_pat(*x))),
PatBox(inner) => PatBox(fld.fold_pat(inner)),
PatUniq(inner) => PatUniq(fld.fold_pat(inner)),
PatRegion(inner) => PatRegion(fld.fold_pat(inner)),
PatRange(e1, e2) => {
PatRange(fld.fold_expr(e1), fld.fold_expr(e2))
},
pat_vec(ref before, ref slice, ref after) => {
pat_vec(
PatVec(ref before, ref slice, ref after) => {
PatVec(
before.map(|x| fld.fold_pat(*x)),
slice.map_move(|x| fld.fold_pat(x)),
after.map(|x| fld.fold_pat(*x))
@ -466,12 +466,12 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
}
}
fn noop_fold_decl(d: &decl_, fld: @ast_fold) -> Option<decl_> {
fn noop_fold_decl(d: &Decl_, fld: @ast_fold) -> Option<Decl_> {
match *d {
decl_local(ref l) => Some(decl_local(fld.fold_local(*l))),
decl_item(it) => {
DeclLocal(ref l) => Some(DeclLocal(fld.fold_local(*l))),
DeclItem(it) => {
match fld.fold_item(it) {
Some(it_folded) => Some(decl_item(it_folded)),
Some(it_folded) => Some(DeclItem(it_folded)),
None => None,
}
}
@ -486,7 +486,7 @@ pub fn wrap<T>(f: @fn(&T, @ast_fold) -> T)
result
}
pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
pub fn noop_fold_expr(e: &Expr_, fld: @ast_fold) -> Expr_ {
fn fold_field_(field: Field, fld: @ast_fold) -> Field {
ast::Field {
ident: fld.fold_ident(field.ident),
@ -499,25 +499,25 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
let fold_mac = |x| fold_mac_(x, fld);
match *e {
expr_vstore(e, v) => {
expr_vstore(fld.fold_expr(e), v)
ExprVstore(e, v) => {
ExprVstore(fld.fold_expr(e), v)
}
expr_vec(ref exprs, mutt) => {
expr_vec(fld.map_exprs(|x| fld.fold_expr(x), *exprs), mutt)
ExprVec(ref exprs, mutt) => {
ExprVec(fld.map_exprs(|x| fld.fold_expr(x), *exprs), mutt)
}
expr_repeat(expr, count, mutt) => {
expr_repeat(fld.fold_expr(expr), fld.fold_expr(count), mutt)
ExprRepeat(expr, count, mutt) => {
ExprRepeat(fld.fold_expr(expr), fld.fold_expr(count), mutt)
}
expr_tup(ref elts) => expr_tup(elts.map(|x| fld.fold_expr(*x))),
expr_call(f, ref args, blk) => {
expr_call(
ExprTup(ref elts) => ExprTup(elts.map(|x| fld.fold_expr(*x))),
ExprCall(f, ref args, blk) => {
ExprCall(
fld.fold_expr(f),
fld.map_exprs(|x| fld.fold_expr(x), *args),
blk
)
}
expr_method_call(callee_id, f, i, ref tps, ref args, blk) => {
expr_method_call(
ExprMethodCall(callee_id, f, i, ref tps, ref args, blk) => {
ExprMethodCall(
fld.new_id(callee_id),
fld.fold_expr(f),
fld.fold_ident(i),
@ -526,118 +526,118 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
blk
)
}
expr_binary(callee_id, binop, lhs, rhs) => {
expr_binary(
ExprBinary(callee_id, binop, lhs, rhs) => {
ExprBinary(
fld.new_id(callee_id),
binop,
fld.fold_expr(lhs),
fld.fold_expr(rhs)
)
}
expr_unary(callee_id, binop, ohs) => {
expr_unary(
ExprUnary(callee_id, binop, ohs) => {
ExprUnary(
fld.new_id(callee_id),
binop,
fld.fold_expr(ohs)
)
}
expr_do_body(f) => expr_do_body(fld.fold_expr(f)),
expr_lit(_) => (*e).clone(),
expr_cast(expr, ref ty) => {
expr_cast(fld.fold_expr(expr), (*ty).clone())
ExprDoBody(f) => ExprDoBody(fld.fold_expr(f)),
ExprLit(_) => (*e).clone(),
ExprCast(expr, ref ty) => {
ExprCast(fld.fold_expr(expr), (*ty).clone())
}
expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)),
expr_if(cond, ref tr, fl) => {
expr_if(
ExprAddrOf(m, ohs) => ExprAddrOf(m, fld.fold_expr(ohs)),
ExprIf(cond, ref tr, fl) => {
ExprIf(
fld.fold_expr(cond),
fld.fold_block(tr),
fl.map_move(|x| fld.fold_expr(x))
)
}
expr_while(cond, ref body) => {
expr_while(fld.fold_expr(cond), fld.fold_block(body))
ExprWhile(cond, ref body) => {
ExprWhile(fld.fold_expr(cond), fld.fold_block(body))
}
expr_for_loop(pat, iter, ref body) => {
expr_for_loop(fld.fold_pat(pat),
ExprForLoop(pat, iter, ref body) => {
ExprForLoop(fld.fold_pat(pat),
fld.fold_expr(iter),
fld.fold_block(body))
}
expr_loop(ref body, opt_ident) => {
expr_loop(
ExprLoop(ref body, opt_ident) => {
ExprLoop(
fld.fold_block(body),
opt_ident.map_move(|x| fld.fold_ident(x))
)
}
expr_match(expr, ref arms) => {
expr_match(
ExprMatch(expr, ref arms) => {
ExprMatch(
fld.fold_expr(expr),
arms.map(|x| fld.fold_arm(x))
)
}
expr_fn_block(ref decl, ref body) => {
expr_fn_block(
ExprFnBlock(ref decl, ref body) => {
ExprFnBlock(
fold_fn_decl(decl, fld),
fld.fold_block(body)
)
}
expr_block(ref blk) => expr_block(fld.fold_block(blk)),
expr_assign(el, er) => {
expr_assign(fld.fold_expr(el), fld.fold_expr(er))
ExprBlock(ref blk) => ExprBlock(fld.fold_block(blk)),
ExprAssign(el, er) => {
ExprAssign(fld.fold_expr(el), fld.fold_expr(er))
}
expr_assign_op(callee_id, op, el, er) => {
expr_assign_op(
ExprAssignOp(callee_id, op, el, er) => {
ExprAssignOp(
fld.new_id(callee_id),
op,
fld.fold_expr(el),
fld.fold_expr(er)
)
}
expr_field(el, id, ref tys) => {
expr_field(
ExprField(el, id, ref tys) => {
ExprField(
fld.fold_expr(el), fld.fold_ident(id),
tys.map(|x| fld.fold_ty(x))
)
}
expr_index(callee_id, el, er) => {
expr_index(
ExprIndex(callee_id, el, er) => {
ExprIndex(
fld.new_id(callee_id),
fld.fold_expr(el),
fld.fold_expr(er)
)
}
expr_path(ref pth) => expr_path(fld.fold_path(pth)),
expr_self => expr_self,
expr_break(ref opt_ident) => {
expr_break(opt_ident.map_move(|x| fld.fold_ident(x)))
ExprPath(ref pth) => ExprPath(fld.fold_path(pth)),
ExprSelf => ExprSelf,
ExprBreak(ref opt_ident) => {
ExprBreak(opt_ident.map_move(|x| fld.fold_ident(x)))
}
expr_again(ref opt_ident) => {
expr_again(opt_ident.map_move(|x| fld.fold_ident(x)))
ExprAgain(ref opt_ident) => {
ExprAgain(opt_ident.map_move(|x| fld.fold_ident(x)))
}
expr_ret(ref e) => {
expr_ret(e.map_move(|x| fld.fold_expr(x)))
ExprRet(ref e) => {
ExprRet(e.map_move(|x| fld.fold_expr(x)))
}
expr_log(lv, e) => {
expr_log(
ExprLog(lv, e) => {
ExprLog(
fld.fold_expr(lv),
fld.fold_expr(e)
)
}
expr_inline_asm(ref a) => {
expr_inline_asm(inline_asm {
ExprInlineAsm(ref a) => {
ExprInlineAsm(inline_asm {
inputs: a.inputs.map(|&(c, input)| (c, fld.fold_expr(input))),
outputs: a.outputs.map(|&(c, out)| (c, fld.fold_expr(out))),
.. (*a).clone()
})
}
expr_mac(ref mac) => expr_mac(fold_mac(mac)),
expr_struct(ref path, ref fields, maybe_expr) => {
expr_struct(
ExprMac(ref mac) => ExprMac(fold_mac(mac)),
ExprStruct(ref path, ref fields, maybe_expr) => {
ExprStruct(
fld.fold_path(path),
fields.map(|x| fold_field(*x)),
maybe_expr.map_move(|x| fld.fold_expr(x))
)
},
expr_paren(ex) => expr_paren(fld.fold_expr(ex))
ExprParen(ex) => ExprParen(fld.fold_expr(ex))
}
}
@ -787,7 +787,7 @@ fn noop_fold_local(l: @Local, fld: @ast_fold) -> @Local {
/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
value */
fn noop_map_exprs(f: @fn(@expr) -> @expr, es: &[@expr]) -> ~[@expr] {
fn noop_map_exprs(f: @fn(@Expr) -> @Expr, es: &[@Expr]) -> ~[@Expr] {
es.map(|x| f(*x))
}
@ -862,34 +862,34 @@ impl ast_fold for AstFoldFns {
fn fold_block(@self, x: &Block) -> Block {
(self.fold_block)(x, self as @ast_fold)
}
fn fold_stmt(@self, x: &stmt) -> Option<@stmt> {
fn fold_stmt(@self, x: &Stmt) -> Option<@Stmt> {
let (n_opt, s) = (self.fold_stmt)(&x.node, x.span, self as @ast_fold);
match n_opt {
Some(n) => Some(@Spanned { node: n, span: (self.new_span)(s) }),
None => None,
}
}
fn fold_arm(@self, x: &arm) -> arm {
fn fold_arm(@self, x: &Arm) -> Arm {
(self.fold_arm)(x, self as @ast_fold)
}
fn fold_pat(@self, x: @pat) -> @pat {
fn fold_pat(@self, x: @Pat) -> @Pat {
let (n, s) = (self.fold_pat)(&x.node, x.span, self as @ast_fold);
@pat {
@Pat {
id: (self.new_id)(x.id),
node: n,
span: (self.new_span)(s),
}
}
fn fold_decl(@self, x: @decl) -> Option<@decl> {
fn fold_decl(@self, x: @Decl) -> Option<@Decl> {
let (n_opt, s) = (self.fold_decl)(&x.node, x.span, self as @ast_fold);
match n_opt {
Some(n) => Some(@Spanned { node: n, span: (self.new_span)(s) }),
None => None,
}
}
fn fold_expr(@self, x: @expr) -> @expr {
fn fold_expr(@self, x: @Expr) -> @Expr {
let (n, s) = (self.fold_expr)(&x.node, x.span, self as @ast_fold);
@expr {
@Expr {
id: (self.new_id)(x.id),
node: n,
span: (self.new_span)(s),
@ -923,9 +923,9 @@ impl ast_fold for AstFoldFns {
(self.fold_local)(x, self as @ast_fold)
}
fn map_exprs(@self,
f: @fn(@expr) -> @expr,
e: &[@expr])
-> ~[@expr] {
f: @fn(@Expr) -> @Expr,
e: &[@Expr])
-> ~[@Expr] {
(self.map_exprs)(f, e)
}
fn new_id(@self, node_id: ast::NodeId) -> NodeId {

View file

@ -77,12 +77,12 @@ pub struct Visitor<E> {
visit_item: @fn(@item, (E, vt<E>)),
visit_local: @fn(@Local, (E, vt<E>)),
visit_block: @fn(&Block, (E, vt<E>)),
visit_stmt: @fn(@stmt, (E, vt<E>)),
visit_arm: @fn(&arm, (E, vt<E>)),
visit_pat: @fn(@pat, (E, vt<E>)),
visit_decl: @fn(@decl, (E, vt<E>)),
visit_expr: @fn(@expr, (E, vt<E>)),
visit_expr_post: @fn(@expr, (E, vt<E>)),
visit_stmt: @fn(@Stmt, (E, vt<E>)),
visit_arm: @fn(&Arm, (E, vt<E>)),
visit_pat: @fn(@Pat, (E, vt<E>)),
visit_decl: @fn(@Decl, (E, vt<E>)),
visit_expr: @fn(@Expr, (E, vt<E>)),
visit_expr_post: @fn(@Expr, (E, vt<E>)),
visit_ty: @fn(&Ty, (E, vt<E>)),
visit_generics: @fn(&Generics, (E, vt<E>)),
visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId, (E, vt<E>)),
@ -294,9 +294,9 @@ pub fn visit_path<E:Clone>(p: &Path, (e, v): (E, vt<E>)) {
}
}
pub fn visit_pat<E:Clone>(p: &pat, (e, v): (E, vt<E>)) {
pub fn visit_pat<E:Clone>(p: &Pat, (e, v): (E, vt<E>)) {
match p.node {
pat_enum(ref path, ref children) => {
PatEnum(ref path, ref children) => {
visit_path(path, (e.clone(), v));
for children in children.iter() {
for child in children.iter() {
@ -304,33 +304,33 @@ pub fn visit_pat<E:Clone>(p: &pat, (e, v): (E, vt<E>)) {
}
}
}
pat_struct(ref path, ref fields, _) => {
PatStruct(ref path, ref fields, _) => {
visit_path(path, (e.clone(), v));
for f in fields.iter() {
(v.visit_pat)(f.pat, (e.clone(), v));
}
}
pat_tup(ref elts) => {
PatTup(ref elts) => {
for elt in elts.iter() {
(v.visit_pat)(*elt, (e.clone(), v))
}
},
pat_box(inner) | pat_uniq(inner) | pat_region(inner) => {
PatBox(inner) | PatUniq(inner) | PatRegion(inner) => {
(v.visit_pat)(inner, (e, v))
},
pat_ident(_, ref path, ref inner) => {
PatIdent(_, ref path, ref inner) => {
visit_path(path, (e.clone(), v));
for subpat in inner.iter() {
(v.visit_pat)(*subpat, (e.clone(), v))
}
}
pat_lit(ex) => (v.visit_expr)(ex, (e, v)),
pat_range(e1, e2) => {
PatLit(ex) => (v.visit_expr)(ex, (e, v)),
PatRange(e1, e2) => {
(v.visit_expr)(e1, (e.clone(), v));
(v.visit_expr)(e2, (e, v));
}
pat_wild => (),
pat_vec(ref before, ref slice, ref after) => {
PatWild => (),
PatVec(ref before, ref slice, ref after) => {
for elt in before.iter() {
(v.visit_pat)(*elt, (e.clone(), v));
}
@ -446,27 +446,27 @@ pub fn visit_block<E:Clone>(b: &Block, (e, v): (E, vt<E>)) {
visit_expr_opt(b.expr, (e, v));
}
pub fn visit_stmt<E>(s: &stmt, (e, v): (E, vt<E>)) {
pub fn visit_stmt<E>(s: &Stmt, (e, v): (E, vt<E>)) {
match s.node {
stmt_decl(d, _) => (v.visit_decl)(d, (e, v)),
stmt_expr(ex, _) => (v.visit_expr)(ex, (e, v)),
stmt_semi(ex, _) => (v.visit_expr)(ex, (e, v)),
stmt_mac(ref mac, _) => visit_mac(mac, (e, v))
StmtDecl(d, _) => (v.visit_decl)(d, (e, v)),
StmtExpr(ex, _) => (v.visit_expr)(ex, (e, v)),
StmtSemi(ex, _) => (v.visit_expr)(ex, (e, v)),
StmtMac(ref mac, _) => visit_mac(mac, (e, v))
}
}
pub fn visit_decl<E:Clone>(d: &decl, (e, v): (E, vt<E>)) {
pub fn visit_decl<E:Clone>(d: &Decl, (e, v): (E, vt<E>)) {
match d.node {
decl_local(ref loc) => (v.visit_local)(*loc, (e, v)),
decl_item(it) => (v.visit_item)(it, (e, v))
DeclLocal(ref loc) => (v.visit_local)(*loc, (e, v)),
DeclItem(it) => (v.visit_item)(it, (e, v))
}
}
pub fn visit_expr_opt<E>(eo: Option<@expr>, (e, v): (E, vt<E>)) {
pub fn visit_expr_opt<E>(eo: Option<@Expr>, (e, v): (E, vt<E>)) {
match eo { None => (), Some(ex) => (v.visit_expr)(ex, (e, v)) }
}
pub fn visit_exprs<E:Clone>(exprs: &[@expr], (e, v): (E, vt<E>)) {
pub fn visit_exprs<E:Clone>(exprs: &[@Expr], (e, v): (E, vt<E>)) {
for ex in exprs.iter() { (v.visit_expr)(*ex, (e.clone(), v)); }
}
@ -474,66 +474,66 @@ pub fn visit_mac<E>(_m: &mac, (_e, _v): (E, vt<E>)) {
/* no user-serviceable parts inside */
}
pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
pub fn visit_expr<E:Clone>(ex: @Expr, (e, v): (E, vt<E>)) {
match ex.node {
expr_vstore(x, _) => (v.visit_expr)(x, (e.clone(), v)),
expr_vec(ref es, _) => visit_exprs(*es, (e.clone(), v)),
expr_repeat(element, count, _) => {
ExprVstore(x, _) => (v.visit_expr)(x, (e.clone(), v)),
ExprVec(ref es, _) => visit_exprs(*es, (e.clone(), v)),
ExprRepeat(element, count, _) => {
(v.visit_expr)(element, (e.clone(), v));
(v.visit_expr)(count, (e.clone(), v));
}
expr_struct(ref p, ref flds, base) => {
ExprStruct(ref p, ref flds, base) => {
visit_path(p, (e.clone(), v));
for f in flds.iter() {
(v.visit_expr)(f.expr, (e.clone(), v));
}
visit_expr_opt(base, (e.clone(), v));
}
expr_tup(ref elts) => {
ExprTup(ref elts) => {
for el in elts.iter() { (v.visit_expr)(*el, (e.clone(), v)) }
}
expr_call(callee, ref args, _) => {
ExprCall(callee, ref args, _) => {
visit_exprs(*args, (e.clone(), v));
(v.visit_expr)(callee, (e.clone(), v));
}
expr_method_call(_, callee, _, ref tys, ref args, _) => {
ExprMethodCall(_, callee, _, ref tys, ref args, _) => {
visit_exprs(*args, (e.clone(), v));
for tp in tys.iter() {
(v.visit_ty)(tp, (e.clone(), v));
}
(v.visit_expr)(callee, (e.clone(), v));
}
expr_binary(_, _, a, b) => {
ExprBinary(_, _, a, b) => {
(v.visit_expr)(a, (e.clone(), v));
(v.visit_expr)(b, (e.clone(), v));
}
expr_addr_of(_, x) | expr_unary(_, _, x) |
expr_do_body(x) => (v.visit_expr)(x, (e.clone(), v)),
expr_lit(_) => (),
expr_cast(x, ref t) => {
ExprAddrOf(_, x) | ExprUnary(_, _, x) |
ExprDoBody(x) => (v.visit_expr)(x, (e.clone(), v)),
ExprLit(_) => (),
ExprCast(x, ref t) => {
(v.visit_expr)(x, (e.clone(), v));
(v.visit_ty)(t, (e.clone(), v));
}
expr_if(x, ref b, eo) => {
ExprIf(x, ref b, eo) => {
(v.visit_expr)(x, (e.clone(), v));
(v.visit_block)(b, (e.clone(), v));
visit_expr_opt(eo, (e.clone(), v));
}
expr_while(x, ref b) => {
ExprWhile(x, ref b) => {
(v.visit_expr)(x, (e.clone(), v));
(v.visit_block)(b, (e.clone(), v));
}
expr_for_loop(pattern, subexpression, ref block) => {
ExprForLoop(pattern, subexpression, ref block) => {
(v.visit_pat)(pattern, (e.clone(), v));
(v.visit_expr)(subexpression, (e.clone(), v));
(v.visit_block)(block, (e.clone(), v))
}
expr_loop(ref b, _) => (v.visit_block)(b, (e.clone(), v)),
expr_match(x, ref arms) => {
ExprLoop(ref b, _) => (v.visit_block)(b, (e.clone(), v)),
ExprMatch(x, ref arms) => {
(v.visit_expr)(x, (e.clone(), v));
for a in arms.iter() { (v.visit_arm)(a, (e.clone(), v)); }
}
expr_fn_block(ref decl, ref body) => {
ExprFnBlock(ref decl, ref body) => {
(v.visit_fn)(
&fk_fn_block,
decl,
@ -543,37 +543,37 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
(e.clone(), v)
);
}
expr_block(ref b) => (v.visit_block)(b, (e.clone(), v)),
expr_assign(a, b) => {
ExprBlock(ref b) => (v.visit_block)(b, (e.clone(), v)),
ExprAssign(a, b) => {
(v.visit_expr)(b, (e.clone(), v));
(v.visit_expr)(a, (e.clone(), v));
}
expr_assign_op(_, _, a, b) => {
ExprAssignOp(_, _, a, b) => {
(v.visit_expr)(b, (e.clone(), v));
(v.visit_expr)(a, (e.clone(), v));
}
expr_field(x, _, ref tys) => {
ExprField(x, _, ref tys) => {
(v.visit_expr)(x, (e.clone(), v));
for tp in tys.iter() {
(v.visit_ty)(tp, (e.clone(), v));
}
}
expr_index(_, a, b) => {
ExprIndex(_, a, b) => {
(v.visit_expr)(a, (e.clone(), v));
(v.visit_expr)(b, (e.clone(), v));
}
expr_path(ref p) => visit_path(p, (e.clone(), v)),
expr_self => (),
expr_break(_) => (),
expr_again(_) => (),
expr_ret(eo) => visit_expr_opt(eo, (e.clone(), v)),
expr_log(lv, x) => {
ExprPath(ref p) => visit_path(p, (e.clone(), v)),
ExprSelf => (),
ExprBreak(_) => (),
ExprAgain(_) => (),
ExprRet(eo) => visit_expr_opt(eo, (e.clone(), v)),
ExprLog(lv, x) => {
(v.visit_expr)(lv, (e.clone(), v));
(v.visit_expr)(x, (e.clone(), v));
}
expr_mac(ref mac) => visit_mac(mac, (e.clone(), v)),
expr_paren(x) => (v.visit_expr)(x, (e.clone(), v)),
expr_inline_asm(ref a) => {
ExprMac(ref mac) => visit_mac(mac, (e.clone(), v)),
ExprParen(x) => (v.visit_expr)(x, (e.clone(), v)),
ExprInlineAsm(ref a) => {
for &(_, input) in a.inputs.iter() {
(v.visit_expr)(input, (e.clone(), v));
}
@ -585,7 +585,7 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
(v.visit_expr_post)(ex, (e, v));
}
pub fn visit_arm<E:Clone>(a: &arm, (e, v): (E, vt<E>)) {
pub fn visit_arm<E:Clone>(a: &Arm, (e, v): (E, vt<E>)) {
for p in a.pats.iter() { (v.visit_pat)(*p, (e.clone(), v)); }
visit_expr_opt(a.guard, (e.clone(), v));
(v.visit_block)(&a.body, (e.clone(), v));
@ -601,12 +601,12 @@ pub struct SimpleVisitor {
visit_item: @fn(@item),
visit_local: @fn(@Local),
visit_block: @fn(&Block),
visit_stmt: @fn(@stmt),
visit_arm: @fn(&arm),
visit_pat: @fn(@pat),
visit_decl: @fn(@decl),
visit_expr: @fn(@expr),
visit_expr_post: @fn(@expr),
visit_stmt: @fn(@Stmt),
visit_arm: @fn(&Arm),
visit_pat: @fn(@Pat),
visit_decl: @fn(@Decl),
visit_expr: @fn(@Expr),
visit_expr_post: @fn(@Expr),
visit_ty: @fn(&Ty),
visit_generics: @fn(&Generics),
visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId),
@ -677,27 +677,27 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
f(bl);
visit_block(bl, (e, v));
}
fn v_stmt(f: @fn(@stmt), st: @stmt, (e, v): ((), vt<()>)) {
fn v_stmt(f: @fn(@Stmt), st: @Stmt, (e, v): ((), vt<()>)) {
f(st);
visit_stmt(st, (e, v));
}
fn v_arm(f: @fn(&arm), a: &arm, (e, v): ((), vt<()>)) {
fn v_arm(f: @fn(&Arm), a: &Arm, (e, v): ((), vt<()>)) {
f(a);
visit_arm(a, (e, v));
}
fn v_pat(f: @fn(@pat), p: @pat, (e, v): ((), vt<()>)) {
fn v_pat(f: @fn(@Pat), p: @Pat, (e, v): ((), vt<()>)) {
f(p);
visit_pat(p, (e, v));
}
fn v_decl(f: @fn(@decl), d: @decl, (e, v): ((), vt<()>)) {
fn v_decl(f: @fn(@Decl), d: @Decl, (e, v): ((), vt<()>)) {
f(d);
visit_decl(d, (e, v));
}
fn v_expr(f: @fn(@expr), ex: @expr, (e, v): ((), vt<()>)) {
fn v_expr(f: @fn(@Expr), ex: @Expr, (e, v): ((), vt<()>)) {
f(ex);
visit_expr(ex, (e, v));
}
fn v_expr_post(f: @fn(@expr), ex: @expr, (_e, _v): ((), vt<()>)) {
fn v_expr_post(f: @fn(@Expr), ex: @Expr, (_e, _v): ((), vt<()>)) {
f(ex);
}
fn v_ty(f: @fn(&Ty), ty: &Ty, (e, v): ((), vt<()>)) {

View file

@ -21,25 +21,25 @@ use ast;
// 'if true {...} else {...}
// |x| 5 '
// isn't parsed as (if true {...} else {...} | x) | 5
pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
pub fn expr_requires_semi_to_be_stmt(e: @ast::Expr) -> bool {
match e.node {
ast::expr_if(*)
| ast::expr_match(*)
| ast::expr_block(_)
| ast::expr_while(*)
| ast::expr_loop(*)
| ast::expr_for_loop(*)
| ast::expr_call(_, _, ast::DoSugar)
| ast::expr_call(_, _, ast::ForSugar)
| ast::expr_method_call(_, _, _, _, _, ast::DoSugar)
| ast::expr_method_call(_, _, _, _, _, ast::ForSugar) => false,
ast::ExprIf(*)
| ast::ExprMatch(*)
| ast::ExprBlock(_)
| ast::ExprWhile(*)
| ast::ExprLoop(*)
| ast::ExprForLoop(*)
| ast::ExprCall(_, _, ast::DoSugar)
| ast::ExprCall(_, _, ast::ForSugar)
| ast::ExprMethodCall(_, _, _, _, _, ast::DoSugar)
| ast::ExprMethodCall(_, _, _, _, _, ast::ForSugar) => false,
_ => true
}
}
pub fn expr_is_simple_block(e: @ast::expr) -> bool {
pub fn expr_is_simple_block(e: @ast::Expr) -> bool {
match e.node {
ast::expr_block(
ast::ExprBlock(
ast::Block { rules: ast::DefaultBlock, _ }
) => true,
_ => false
@ -49,16 +49,16 @@ pub fn expr_is_simple_block(e: @ast::expr) -> bool {
// this statement requires a semicolon after it.
// note that in one case (stmt_semi), we've already
// seen the semicolon, and thus don't need another.
pub fn stmt_ends_with_semi(stmt: &ast::stmt) -> bool {
pub fn stmt_ends_with_semi(stmt: &ast::Stmt) -> bool {
return match stmt.node {
ast::stmt_decl(d, _) => {
ast::StmtDecl(d, _) => {
match d.node {
ast::decl_local(_) => true,
ast::decl_item(_) => false
ast::DeclLocal(_) => true,
ast::DeclItem(_) => false
}
}
ast::stmt_expr(e, _) => { expr_requires_semi_to_be_stmt(e) }
ast::stmt_semi(*) => { false }
ast::stmt_mac(*) => { false }
ast::StmtExpr(e, _) => { expr_requires_semi_to_be_stmt(e) }
ast::StmtSemi(*) => { false }
ast::StmtMac(*) => { false }
}
}

View file

@ -101,7 +101,7 @@ pub fn parse_expr_from_source_str(
source: @str,
cfg: ast::CrateConfig,
sess: @mut ParseSess
) -> @ast::expr {
) -> @ast::Expr {
let p = new_parser_from_source_str(
sess,
cfg,
@ -148,7 +148,7 @@ pub fn parse_stmt_from_source_str(
cfg: ast::CrateConfig,
attrs: ~[ast::Attribute],
sess: @mut ParseSess
) -> @ast::stmt {
) -> @ast::Stmt {
let p = new_parser_from_source_str(
sess,
cfg,
@ -363,9 +363,9 @@ mod test {
#[test] fn path_exprs_1() {
assert_eq!(string_to_expr(@"a"),
@ast::expr{
@ast::Expr{
id: 1,
node: ast::expr_path(ast::Path {
node: ast::ExprPath(ast::Path {
span: sp(0, 1),
global: false,
segments: ~[
@ -382,9 +382,9 @@ mod test {
#[test] fn path_exprs_2 () {
assert_eq!(string_to_expr(@"::a::b"),
@ast::expr {
@ast::Expr {
id:1,
node: ast::expr_path(ast::Path {
node: ast::ExprPath(ast::Path {
span: sp(0, 6),
global: true,
segments: ~[
@ -440,11 +440,11 @@ mod test {
#[test] fn ret_expr() {
assert_eq!(string_to_expr(@"return d"),
@ast::expr{
@ast::Expr{
id:2,
node:ast::expr_ret(Some(@ast::expr{
node:ast::ExprRet(Some(@ast::Expr{
id:1,
node:ast::expr_path(ast::Path{
node:ast::ExprPath(ast::Path{
span: sp(7, 8),
global: false,
segments: ~[
@ -464,9 +464,9 @@ mod test {
#[test] fn parse_stmt_1 () {
assert_eq!(string_to_stmt(@"b;"),
@Spanned{
node: ast::stmt_expr(@ast::expr {
node: ast::StmtExpr(@ast::Expr {
id: 1,
node: ast::expr_path(ast::Path {
node: ast::ExprPath(ast::Path {
span:sp(0,1),
global:false,
segments: ~[
@ -490,9 +490,9 @@ mod test {
#[test] fn parse_ident_pat () {
let parser = string_to_parser(@"b");
assert_eq!(parser.parse_pat(),
@ast::pat{id:1, // fixme
node: ast::pat_ident(
ast::bind_infer,
@ast::Pat{id:1, // fixme
node: ast::PatIdent(
ast::BindInfer,
ast::Path {
span:sp(0,1),
global:false,
@ -536,10 +536,10 @@ mod test {
}, None, 2),
span:sp(10,13)
},
pat: @ast::pat {
pat: @ast::Pat {
id:1, // fixme
node: ast::pat_ident(
ast::bind_infer,
node: ast::PatIdent(
ast::BindInfer,
ast::Path {
span:sp(6,7),
global:false,
@ -572,9 +572,9 @@ mod test {
ast::Block {
view_items: ~[],
stmts: ~[@Spanned{
node: ast::stmt_semi(@ast::expr{
node: ast::StmtSemi(@ast::Expr{
id: 6,
node: ast::expr_path(
node: ast::ExprPath(
ast::Path{
span:sp(17,18),
global:false,

View file

@ -17,7 +17,7 @@ Obsolete syntax that becomes too hard to parse can be
removed.
*/
use ast::{expr, expr_lit, lit_nil, Attribute};
use ast::{Expr, ExprLit, lit_nil, Attribute};
use ast;
use codemap::{Span, respan};
use parse::parser::Parser;
@ -79,7 +79,7 @@ pub trait ParserObsoleteMethods {
fn obsolete(&self, sp: Span, kind: ObsoleteSyntax);
// Reports an obsolete syntax non-fatal error, and returns
// a placeholder expression
fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @expr;
fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @Expr;
fn report(&self,
sp: Span,
kind: ObsoleteSyntax,
@ -263,9 +263,9 @@ impl ParserObsoleteMethods for Parser {
// Reports an obsolete syntax non-fatal error, and returns
// a placeholder expression
fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @expr {
fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @Expr {
self.obsolete(sp, kind);
self.mk_expr(sp.lo, sp.hi, expr_lit(@respan(sp, lit_nil)))
self.mk_expr(sp.lo, sp.hi, ExprLit(@respan(sp, lit_nil)))
}
fn report(&self,

File diff suppressed because it is too large Load diff

View file

@ -100,9 +100,9 @@ pub enum Token {
pub enum nonterminal {
nt_item(@ast::item),
nt_block(~ast::Block),
nt_stmt(@ast::stmt),
nt_pat( @ast::pat),
nt_expr(@ast::expr),
nt_stmt(@ast::Stmt),
nt_pat( @ast::Pat),
nt_expr(@ast::Expr),
nt_ty( ~ast::Ty),
nt_ident(~ast::Ident, bool),
nt_attr(@ast::Attribute), // #[foo]
@ -353,26 +353,26 @@ pub mod special_idents {
* Maps a token to a record specifying the corresponding binary
* operator
*/
pub fn token_to_binop(tok: &Token) -> Option<ast::binop> {
pub fn token_to_binop(tok: &Token) -> Option<ast::BinOp> {
match *tok {
BINOP(STAR) => Some(ast::mul),
BINOP(SLASH) => Some(ast::div),
BINOP(PERCENT) => Some(ast::rem),
BINOP(PLUS) => Some(ast::add),
BINOP(MINUS) => Some(ast::subtract),
BINOP(SHL) => Some(ast::shl),
BINOP(SHR) => Some(ast::shr),
BINOP(AND) => Some(ast::bitand),
BINOP(CARET) => Some(ast::bitxor),
BINOP(OR) => Some(ast::bitor),
LT => Some(ast::lt),
LE => Some(ast::le),
GE => Some(ast::ge),
GT => Some(ast::gt),
EQEQ => Some(ast::eq),
NE => Some(ast::ne),
ANDAND => Some(ast::and),
OROR => Some(ast::or),
BINOP(STAR) => Some(ast::BiMul),
BINOP(SLASH) => Some(ast::BiDiv),
BINOP(PERCENT) => Some(ast::BiRem),
BINOP(PLUS) => Some(ast::BiAdd),
BINOP(MINUS) => Some(ast::BiSub),
BINOP(SHL) => Some(ast::BiShl),
BINOP(SHR) => Some(ast::BiShr),
BINOP(AND) => Some(ast::BiBitAnd),
BINOP(CARET) => Some(ast::BiBitXor),
BINOP(OR) => Some(ast::BiBitOr),
LT => Some(ast::BiLt),
LE => Some(ast::BiLe),
GE => Some(ast::BiGe),
GT => Some(ast::BiGt),
EQEQ => Some(ast::BiEq),
NE => Some(ast::BiNe),
ANDAND => Some(ast::BiAnd),
OROR => Some(ast::BiOr),
_ => None
}
}

View file

@ -33,8 +33,8 @@ use std::io;
pub enum ann_node<'self> {
node_block(@ps, &'self ast::Block),
node_item(@ps, &'self ast::item),
node_expr(@ps, &'self ast::expr),
node_pat(@ps, &'self ast::pat),
node_expr(@ps, &'self ast::Expr),
node_pat(@ps, &'self ast::Pat),
}
pub struct pp_ann {
pre: @fn(ann_node),
@ -148,11 +148,11 @@ pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str {
to_str(ty, print_type, intr)
}
pub fn pat_to_str(pat: &ast::pat, intr: @ident_interner) -> ~str {
pub fn pat_to_str(pat: &ast::Pat, intr: @ident_interner) -> ~str {
to_str(pat, print_pat, intr)
}
pub fn expr_to_str(e: &ast::expr, intr: @ident_interner) -> ~str {
pub fn expr_to_str(e: &ast::Expr, intr: @ident_interner) -> ~str {
to_str(e, print_expr, intr)
}
@ -168,7 +168,7 @@ pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str {
to_str(&tts, print_tts, intr)
}
pub fn stmt_to_str(s: &ast::stmt, intr: @ident_interner) -> ~str {
pub fn stmt_to_str(s: &ast::Stmt, intr: @ident_interner) -> ~str {
to_str(s, print_stmt, intr)
}
@ -346,7 +346,7 @@ pub fn commasep_cmnt<T>(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T),
end(s);
}
pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) {
pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::Expr]) {
commasep_cmnt(s, b, exprs, |p, &e| print_expr(p, e), |e| e.span);
}
@ -385,8 +385,8 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
ast::ty_vec(ref mt) => {
word(s.s, "[");
match mt.mutbl {
ast::m_mutbl => word_space(s, "mut"),
ast::m_imm => ()
ast::MutMutable => word_space(s, "mut"),
ast::MutImmutable => ()
}
print_type(s, mt.ty);
word(s.s, "]");
@ -427,8 +427,8 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
ast::ty_fixed_length_vec(ref mt, v) => {
word(s.s, "[");
match mt.mutbl {
ast::m_mutbl => word_space(s, "mut"),
ast::m_imm => ()
ast::MutMutable => word_space(s, "mut"),
ast::MutImmutable => ()
}
print_type(s, mt.ty);
word(s.s, ", ..");
@ -487,7 +487,7 @@ pub fn print_item(s: @ps, item: &ast::item) {
match item.node {
ast::item_static(ref ty, m, expr) => {
head(s, visibility_qualified(item.vis, "static"));
if m == ast::m_mutbl {
if m == ast::MutMutable {
word_space(s, "mut");
}
print_ident(s, item.ident);
@ -886,22 +886,22 @@ pub fn print_attribute(s: @ps, attr: &ast::Attribute) {
}
pub fn print_stmt(s: @ps, st: &ast::stmt) {
pub fn print_stmt(s: @ps, st: &ast::Stmt) {
maybe_print_comment(s, st.span.lo);
match st.node {
ast::stmt_decl(decl, _) => {
ast::StmtDecl(decl, _) => {
print_decl(s, decl);
}
ast::stmt_expr(expr, _) => {
ast::StmtExpr(expr, _) => {
space_if_not_bol(s);
print_expr(s, expr);
}
ast::stmt_semi(expr, _) => {
ast::StmtSemi(expr, _) => {
space_if_not_bol(s);
print_expr(s, expr);
word(s.s, ";");
}
ast::stmt_mac(ref mac, semi) => {
ast::StmtMac(ref mac, semi) => {
space_if_not_bol(s);
print_mac(s, mac);
if semi { word(s.s, ";"); }
@ -978,19 +978,19 @@ pub fn print_possibly_embedded_block_(s: @ps,
(s.ann.post)(ann_node);
}
pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::Block,
elseopt: Option<@ast::expr>, chk: bool) {
pub fn print_if(s: @ps, test: &ast::Expr, blk: &ast::Block,
elseopt: Option<@ast::Expr>, chk: bool) {
head(s, "if");
if chk { word_nbsp(s, "check"); }
print_expr(s, test);
space(s.s);
print_block(s, blk);
fn do_else(s: @ps, els: Option<@ast::expr>) {
fn do_else(s: @ps, els: Option<@ast::Expr>) {
match els {
Some(_else) => {
match _else.node {
// "another else-if"
ast::expr_if(i, ref t, e) => {
ast::ExprIf(i, ref t, e) => {
cbox(s, indent_unit - 1u);
ibox(s, 0u);
word(s.s, " else if ");
@ -1000,7 +1000,7 @@ pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::Block,
do_else(s, e);
}
// "final else"
ast::expr_block(ref b) => {
ast::ExprBlock(ref b) => {
cbox(s, indent_unit - 1u);
ibox(s, 0u);
word(s.s, " else ");
@ -1030,29 +1030,29 @@ pub fn print_mac(s: @ps, m: &ast::mac) {
}
}
pub fn print_vstore(s: @ps, t: ast::vstore) {
pub fn print_vstore(s: @ps, t: ast::Vstore) {
match t {
ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)),
ast::vstore_fixed(None) => word(s.s, "_"),
ast::vstore_uniq => word(s.s, "~"),
ast::vstore_box => word(s.s, "@"),
ast::vstore_slice(ref r) => {
ast::VstoreFixed(Some(i)) => word(s.s, fmt!("%u", i)),
ast::VstoreFixed(None) => word(s.s, "_"),
ast::VstoreUniq => word(s.s, "~"),
ast::VstoreBox => word(s.s, "@"),
ast::VstoreSlice(ref r) => {
word(s.s, "&");
print_opt_lifetime(s, r);
}
}
}
pub fn print_expr_vstore(s: @ps, t: ast::expr_vstore) {
pub fn print_expr_vstore(s: @ps, t: ast::ExprVstore) {
match t {
ast::expr_vstore_uniq => word(s.s, "~"),
ast::expr_vstore_box => word(s.s, "@"),
ast::expr_vstore_mut_box => {
ast::ExprVstoreUniq => word(s.s, "~"),
ast::ExprVstoreBox => word(s.s, "@"),
ast::ExprVstoreMutBox => {
word(s.s, "@");
word(s.s, "mut");
}
ast::expr_vstore_slice => word(s.s, "&"),
ast::expr_vstore_mut_slice => {
ast::ExprVstoreSlice => word(s.s, "&"),
ast::ExprVstoreMutSlice => {
word(s.s, "&");
word(s.s, "mut");
}
@ -1061,8 +1061,8 @@ pub fn print_expr_vstore(s: @ps, t: ast::expr_vstore) {
pub fn print_call_pre(s: @ps,
sugar: ast::CallSugar,
base_args: &mut ~[@ast::expr])
-> Option<@ast::expr> {
base_args: &mut ~[@ast::Expr])
-> Option<@ast::Expr> {
match sugar {
ast::DoSugar => {
head(s, "do");
@ -1078,8 +1078,8 @@ pub fn print_call_pre(s: @ps,
pub fn print_call_post(s: @ps,
sugar: ast::CallSugar,
blk: &Option<@ast::expr>,
base_args: &mut ~[@ast::expr]) {
blk: &Option<@ast::Expr>,
base_args: &mut ~[@ast::Expr]) {
if sugar == ast::NoSugar || !base_args.is_empty() {
popen(s);
commasep_exprs(s, inconsistent, *base_args);
@ -1089,7 +1089,7 @@ pub fn print_call_post(s: @ps,
nbsp(s);
match blk.unwrap().node {
// need to handle closures specifically
ast::expr_do_body(e) => {
ast::ExprDoBody(e) => {
end(s); // we close our head box; closure
// will create it's own.
print_expr(s, e);
@ -1103,7 +1103,7 @@ pub fn print_call_post(s: @ps,
}
}
pub fn print_expr(s: @ps, expr: &ast::expr) {
pub fn print_expr(s: @ps, expr: &ast::Expr) {
fn print_field(s: @ps, field: &ast::Field) {
ibox(s, indent_unit);
print_ident(s, field.ident);
@ -1118,14 +1118,14 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
let ann_node = node_expr(s, expr);
(s.ann.pre)(ann_node);
match expr.node {
ast::expr_vstore(e, v) => {
ast::ExprVstore(e, v) => {
print_expr_vstore(s, v);
print_expr(s, e);
},
ast::expr_vec(ref exprs, mutbl) => {
ast::ExprVec(ref exprs, mutbl) => {
ibox(s, indent_unit);
word(s.s, "[");
if mutbl == ast::m_mutbl {
if mutbl == ast::MutMutable {
word(s.s, "mut");
if exprs.len() > 0u { nbsp(s); }
}
@ -1134,10 +1134,10 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
end(s);
}
ast::expr_repeat(element, count, mutbl) => {
ast::ExprRepeat(element, count, mutbl) => {
ibox(s, indent_unit);
word(s.s, "[");
if mutbl == ast::m_mutbl {
if mutbl == ast::MutMutable {
word(s.s, "mut");
nbsp(s);
}
@ -1149,7 +1149,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
end(s);
}
ast::expr_struct(ref path, ref fields, wth) => {
ast::ExprStruct(ref path, ref fields, wth) => {
print_path(s, path, true);
word(s.s, "{");
commasep_cmnt(s, consistent, (*fields), print_field, get_span);
@ -1166,7 +1166,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
}
word(s.s, "}");
}
ast::expr_tup(ref exprs) => {
ast::ExprTup(ref exprs) => {
popen(s);
commasep_exprs(s, inconsistent, *exprs);
if exprs.len() == 1 {
@ -1174,13 +1174,13 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
}
pclose(s);
}
ast::expr_call(func, ref args, sugar) => {
ast::ExprCall(func, ref args, sugar) => {
let mut base_args = (*args).clone();
let blk = print_call_pre(s, sugar, &mut base_args);
print_expr(s, func);
print_call_post(s, sugar, &blk, &mut base_args);
}
ast::expr_method_call(_, func, ident, ref tys, ref args, sugar) => {
ast::ExprMethodCall(_, func, ident, ref tys, ref args, sugar) => {
let mut base_args = (*args).clone();
let blk = print_call_pre(s, sugar, &mut base_args);
print_expr(s, func);
@ -1193,43 +1193,43 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
}
print_call_post(s, sugar, &blk, &mut base_args);
}
ast::expr_binary(_, op, lhs, rhs) => {
ast::ExprBinary(_, op, lhs, rhs) => {
print_expr(s, lhs);
space(s.s);
word_space(s, ast_util::binop_to_str(op));
print_expr(s, rhs);
}
ast::expr_unary(_, op, expr) => {
ast::ExprUnary(_, op, expr) => {
word(s.s, ast_util::unop_to_str(op));
print_expr(s, expr);
}
ast::expr_addr_of(m, expr) => {
ast::ExprAddrOf(m, expr) => {
word(s.s, "&");
print_mutability(s, m);
// Avoid `& &e` => `&&e`.
match (m, &expr.node) {
(ast::m_imm, &ast::expr_addr_of(*)) => space(s.s),
(ast::MutImmutable, &ast::ExprAddrOf(*)) => space(s.s),
_ => { }
}
print_expr(s, expr);
}
ast::expr_lit(lit) => print_literal(s, lit),
ast::expr_cast(expr, ref ty) => {
ast::ExprLit(lit) => print_literal(s, lit),
ast::ExprCast(expr, ref ty) => {
print_expr(s, expr);
space(s.s);
word_space(s, "as");
print_type(s, ty);
}
ast::expr_if(test, ref blk, elseopt) => {
ast::ExprIf(test, ref blk, elseopt) => {
print_if(s, test, blk, elseopt, false);
}
ast::expr_while(test, ref blk) => {
ast::ExprWhile(test, ref blk) => {
head(s, "while");
print_expr(s, test);
space(s.s);
print_block(s, blk);
}
ast::expr_for_loop(pat, iter, ref blk) => {
ast::ExprForLoop(pat, iter, ref blk) => {
head(s, "for");
print_pat(s, pat);
space(s.s);
@ -1238,7 +1238,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
space(s.s);
print_block(s, blk);
}
ast::expr_loop(ref blk, opt_ident) => {
ast::ExprLoop(ref blk, opt_ident) => {
for ident in opt_ident.iter() {
word(s.s, "'");
print_ident(s, *ident);
@ -1248,7 +1248,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
space(s.s);
print_block(s, blk);
}
ast::expr_match(expr, ref arms) => {
ast::ExprMatch(expr, ref arms) => {
cbox(s, indent_unit);
ibox(s, 4);
word_nbsp(s, "match");
@ -1288,7 +1288,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
match arm.body.expr {
Some(expr) => {
match expr.node {
ast::expr_block(ref blk) => {
ast::ExprBlock(ref blk) => {
// the block will close the pattern's ibox
print_block_unclosed_indent(
s, blk, indent_unit);
@ -1313,7 +1313,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
}
bclose_(s, expr.span, indent_unit);
}
ast::expr_fn_block(ref decl, ref body) => {
ast::ExprFnBlock(ref decl, ref body) => {
// in do/for blocks we don't want to show an empty
// argument list, but at this point we don't know which
// we are inside.
@ -1326,7 +1326,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
assert!(body.expr.is_some());
// we extract the block, so as not to create another set of boxes
match body.expr.unwrap().node {
ast::expr_block(ref blk) => {
ast::ExprBlock(ref blk) => {
print_block_unclosed(s, blk);
}
_ => {
@ -1340,30 +1340,30 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
// empty box to satisfy the close.
ibox(s, 0);
}
ast::expr_do_body(body) => {
ast::ExprDoBody(body) => {
print_expr(s, body);
}
ast::expr_block(ref blk) => {
ast::ExprBlock(ref blk) => {
// containing cbox, will be closed by print-block at }
cbox(s, indent_unit);
// head-box, will be closed by print-block after {
ibox(s, 0u);
print_block(s, blk);
}
ast::expr_assign(lhs, rhs) => {
ast::ExprAssign(lhs, rhs) => {
print_expr(s, lhs);
space(s.s);
word_space(s, "=");
print_expr(s, rhs);
}
ast::expr_assign_op(_, op, lhs, rhs) => {
ast::ExprAssignOp(_, op, lhs, rhs) => {
print_expr(s, lhs);
space(s.s);
word(s.s, ast_util::binop_to_str(op));
word_space(s, "=");
print_expr(s, rhs);
}
ast::expr_field(expr, id, ref tys) => {
ast::ExprField(expr, id, ref tys) => {
print_expr(s, expr);
word(s.s, ".");
print_ident(s, id);
@ -1373,15 +1373,15 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
word(s.s, ">");
}
}
ast::expr_index(_, expr, index) => {
ast::ExprIndex(_, expr, index) => {
print_expr(s, expr);
word(s.s, "[");
print_expr(s, index);
word(s.s, "]");
}
ast::expr_path(ref path) => print_path(s, path, true),
ast::expr_self => word(s.s, "self"),
ast::expr_break(opt_ident) => {
ast::ExprPath(ref path) => print_path(s, path, true),
ast::ExprSelf => word(s.s, "self"),
ast::ExprBreak(opt_ident) => {
word(s.s, "break");
space(s.s);
for ident in opt_ident.iter() {
@ -1390,7 +1390,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
space(s.s);
}
}
ast::expr_again(opt_ident) => {
ast::ExprAgain(opt_ident) => {
word(s.s, "loop");
space(s.s);
for ident in opt_ident.iter() {
@ -1399,14 +1399,14 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
space(s.s)
}
}
ast::expr_ret(result) => {
ast::ExprRet(result) => {
word(s.s, "return");
match result {
Some(expr) => { word(s.s, " "); print_expr(s, expr); }
_ => ()
}
}
ast::expr_log(lexp, expr) => {
ast::ExprLog(lexp, expr) => {
word(s.s, "__log");
popen(s);
print_expr(s, lexp);
@ -1415,7 +1415,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
print_expr(s, expr);
pclose(s);
}
ast::expr_inline_asm(ref a) => {
ast::ExprInlineAsm(ref a) => {
if a.volatile {
word(s.s, "__volatile__ asm!");
} else {
@ -1443,8 +1443,8 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
print_string(s, a.clobbers);
pclose(s);
}
ast::expr_mac(ref m) => print_mac(s, m),
ast::expr_paren(e) => {
ast::ExprMac(ref m) => print_mac(s, m),
ast::ExprParen(e) => {
popen(s);
print_expr(s, e);
pclose(s);
@ -1462,10 +1462,10 @@ pub fn print_local_decl(s: @ps, loc: &ast::Local) {
}
}
pub fn print_decl(s: @ps, decl: &ast::decl) {
pub fn print_decl(s: @ps, decl: &ast::Decl) {
maybe_print_comment(s, decl.span.lo);
match decl.node {
ast::decl_local(ref loc) => {
ast::DeclLocal(ref loc) => {
space_if_not_bol(s);
ibox(s, indent_unit);
word_nbsp(s, "let");
@ -1491,7 +1491,7 @@ pub fn print_decl(s: @ps, decl: &ast::decl) {
print_local(s, *loc);
end(s);
}
ast::decl_item(item) => print_item(s, item)
ast::DeclItem(item) => print_item(s, item)
}
}
@ -1499,7 +1499,7 @@ pub fn print_ident(s: @ps, ident: ast::Ident) {
word(s.s, ident_to_str(&ident));
}
pub fn print_for_decl(s: @ps, loc: &ast::Local, coll: &ast::expr) {
pub fn print_for_decl(s: @ps, loc: &ast::Local, coll: &ast::Expr) {
print_local_decl(s, loc);
space(s.s);
word_space(s, "in");
@ -1565,21 +1565,21 @@ pub fn print_bounded_path(s: @ps, path: &ast::Path,
print_path_(s, path, false, bounds)
}
pub fn print_pat(s: @ps, pat: &ast::pat) {
pub fn print_pat(s: @ps, pat: &ast::Pat) {
maybe_print_comment(s, pat.span.lo);
let ann_node = node_pat(s, pat);
(s.ann.pre)(ann_node);
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match pat.node {
ast::pat_wild => word(s.s, "_"),
ast::pat_ident(binding_mode, ref path, sub) => {
ast::PatWild => word(s.s, "_"),
ast::PatIdent(binding_mode, ref path, sub) => {
match binding_mode {
ast::bind_by_ref(mutbl) => {
ast::BindByRef(mutbl) => {
word_nbsp(s, "ref");
print_mutability(s, mutbl);
}
ast::bind_infer => {}
ast::BindInfer => {}
}
print_path(s, path, true);
match sub {
@ -1590,7 +1590,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat) {
None => ()
}
}
ast::pat_enum(ref path, ref args_) => {
ast::PatEnum(ref path, ref args_) => {
print_path(s, path, true);
match *args_ {
None => word(s.s, "(*)"),
@ -1604,17 +1604,17 @@ pub fn print_pat(s: @ps, pat: &ast::pat) {
}
}
}
ast::pat_struct(ref path, ref fields, etc) => {
ast::PatStruct(ref path, ref fields, etc) => {
print_path(s, path, true);
word(s.s, "{");
fn print_field(s: @ps, f: &ast::field_pat) {
fn print_field(s: @ps, f: &ast::FieldPat) {
cbox(s, indent_unit);
print_ident(s, f.ident);
word_space(s, ":");
print_pat(s, f.pat);
end(s);
}
fn get_span(f: &ast::field_pat) -> codemap::Span { return f.pat.span; }
fn get_span(f: &ast::FieldPat) -> codemap::Span { return f.pat.span; }
commasep_cmnt(s, consistent, *fields,
|s, f| print_field(s,f),
get_span);
@ -1624,7 +1624,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat) {
}
word(s.s, "}");
}
ast::pat_tup(ref elts) => {
ast::PatTup(ref elts) => {
popen(s);
commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p));
if elts.len() == 1 {
@ -1632,26 +1632,26 @@ pub fn print_pat(s: @ps, pat: &ast::pat) {
}
pclose(s);
}
ast::pat_box(inner) => {
ast::PatBox(inner) => {
word(s.s, "@");
print_pat(s, inner);
}
ast::pat_uniq(inner) => {
ast::PatUniq(inner) => {
word(s.s, "~");
print_pat(s, inner);
}
ast::pat_region(inner) => {
ast::PatRegion(inner) => {
word(s.s, "&");
print_pat(s, inner);
}
ast::pat_lit(e) => print_expr(s, e),
ast::pat_range(begin, end) => {
ast::PatLit(e) => print_expr(s, e),
ast::PatRange(begin, end) => {
print_expr(s, begin);
space(s.s);
word(s.s, "..");
print_expr(s, end);
}
ast::pat_vec(ref before, slice, ref after) => {
ast::PatVec(ref before, slice, ref after) => {
word(s.s, "[");
do commasep(s, inconsistent, *before) |s, &p| {
print_pat(s, p);
@ -1900,10 +1900,10 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
end(s); // end outer head-block
}
pub fn print_mutability(s: @ps, mutbl: ast::mutability) {
pub fn print_mutability(s: @ps, mutbl: ast::Mutability) {
match mutbl {
ast::m_mutbl => word_nbsp(s, "mut"),
ast::m_imm => {/* nothing */ }
ast::MutMutable => word_nbsp(s, "mut"),
ast::MutImmutable => {/* nothing */ }
}
}
@ -1921,7 +1921,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) {
ast::ty_infer => print_pat(s, input.pat),
_ => {
match input.pat.node {
ast::pat_ident(_, ref path, _) if
ast::PatIdent(_, ref path, _) if
path.segments.len() == 1 &&
path.segments[0].identifier ==
parse::token::special_idents::invalid => {

View file

@ -47,7 +47,7 @@ pub fn string_to_crate (source_str : @str) -> @ast::Crate {
}
// parse a string, return an expr
pub fn string_to_expr (source_str : @str) -> @ast::expr {
pub fn string_to_expr (source_str : @str) -> @ast::Expr {
do with_error_checking_parse(source_str) |p| {
p.parse_expr()
}
@ -69,7 +69,7 @@ pub fn string_to_item_and_sess (source_str : @str) -> (Option<@ast::item>,@mut P
}
// parse a string, return a stmt
pub fn string_to_stmt(source_str : @str) -> @ast::stmt {
pub fn string_to_stmt(source_str : @str) -> @ast::Stmt {
do with_error_checking_parse(source_str) |p| {
p.parse_stmt(~[])
}
@ -77,7 +77,7 @@ pub fn string_to_stmt(source_str : @str) -> @ast::stmt {
// parse a string, return a pat. Uses "irrefutable"... which doesn't
// (currently) affect parsing.
pub fn string_to_pat(source_str : @str) -> @ast::pat {
pub fn string_to_pat(source_str : @str) -> @ast::Pat {
string_to_parser(source_str).parse_pat()
}

View file

@ -73,12 +73,12 @@ pub trait Visitor<E:Clone> {
fn visit_item(&mut self, i:@item, e:E) { walk_item(self, i, e) }
fn visit_local(&mut self, l:@Local, e:E) { walk_local(self, l, e) }
fn visit_block(&mut self, b:&Block, e:E) { walk_block(self, b, e) }
fn visit_stmt(&mut self, s:@stmt, e:E) { walk_stmt(self, s, e) }
fn visit_arm(&mut self, a:&arm, e:E) { walk_arm(self, a, e) }
fn visit_pat(&mut self, p:@pat, e:E) { walk_pat(self, p, e) }
fn visit_decl(&mut self, d:@decl, e:E) { walk_decl(self, d, e) }
fn visit_expr(&mut self, ex:@expr, e:E) { walk_expr(self, ex, e) }
fn visit_expr_post(&mut self, _ex:@expr, _e:E) { }
fn visit_stmt(&mut self, s:@Stmt, e:E) { walk_stmt(self, s, e) }
fn visit_arm(&mut self, a:&Arm, e:E) { walk_arm(self, a, e) }
fn visit_pat(&mut self, p:@Pat, e:E) { walk_pat(self, p, e) }
fn visit_decl(&mut self, d:@Decl, e:E) { walk_decl(self, d, e) }
fn visit_expr(&mut self, ex:@Expr, e:E) { walk_expr(self, ex, e) }
fn visit_expr_post(&mut self, _ex:@Expr, _e:E) { }
fn visit_ty(&mut self, _t:&Ty, _e:E) { }
fn visit_generics(&mut self, g:&Generics, e:E) { walk_generics(self, g, e) }
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:E) {
@ -111,22 +111,22 @@ impl<E:Clone> Visitor<E> for @mut Visitor<E> {
fn visit_block(&mut self, a:&Block, e:E) {
(*self).visit_block(a, e)
}
fn visit_stmt(&mut self, a:@stmt, e:E) {
fn visit_stmt(&mut self, a:@Stmt, e:E) {
(*self).visit_stmt(a, e)
}
fn visit_arm(&mut self, a:&arm, e:E) {
fn visit_arm(&mut self, a:&Arm, e:E) {
(*self).visit_arm(a, e)
}
fn visit_pat(&mut self, a:@pat, e:E) {
fn visit_pat(&mut self, a:@Pat, e:E) {
(*self).visit_pat(a, e)
}
fn visit_decl(&mut self, a:@decl, e:E) {
fn visit_decl(&mut self, a:@Decl, e:E) {
(*self).visit_decl(a, e)
}
fn visit_expr(&mut self, a:@expr, e:E) {
fn visit_expr(&mut self, a:@Expr, e:E) {
(*self).visit_expr(a, e)
}
fn visit_expr_post(&mut self, a:@expr, e:E) {
fn visit_expr_post(&mut self, a:@Expr, e:E) {
(*self).visit_expr_post(a, e)
}
fn visit_ty(&mut self, a:&Ty, e:E) {
@ -329,9 +329,9 @@ pub fn walk_path<E:Clone, V:Visitor<E>>(visitor: &mut V, path: &Path, env: E) {
}
}
pub fn walk_pat<E:Clone, V:Visitor<E>>(visitor: &mut V, pattern: &pat, env: E) {
pub fn walk_pat<E:Clone, V:Visitor<E>>(visitor: &mut V, pattern: &Pat, env: E) {
match pattern.node {
pat_enum(ref path, ref children) => {
PatEnum(ref path, ref children) => {
walk_path(visitor, path, env.clone());
for children in children.iter() {
for child in children.iter() {
@ -339,36 +339,36 @@ pub fn walk_pat<E:Clone, V:Visitor<E>>(visitor: &mut V, pattern: &pat, env: E) {
}
}
}
pat_struct(ref path, ref fields, _) => {
PatStruct(ref path, ref fields, _) => {
walk_path(visitor, path, env.clone());
for field in fields.iter() {
visitor.visit_pat(field.pat, env.clone())
}
}
pat_tup(ref tuple_elements) => {
PatTup(ref tuple_elements) => {
for tuple_element in tuple_elements.iter() {
visitor.visit_pat(*tuple_element, env.clone())
}
}
pat_box(subpattern) |
pat_uniq(subpattern) |
pat_region(subpattern) => {
PatBox(subpattern) |
PatUniq(subpattern) |
PatRegion(subpattern) => {
visitor.visit_pat(subpattern, env)
}
pat_ident(_, ref path, ref optional_subpattern) => {
PatIdent(_, ref path, ref optional_subpattern) => {
walk_path(visitor, path, env.clone());
match *optional_subpattern {
None => {}
Some(subpattern) => visitor.visit_pat(subpattern, env),
}
}
pat_lit(expression) => visitor.visit_expr(expression, env),
pat_range(lower_bound, upper_bound) => {
PatLit(expression) => visitor.visit_expr(expression, env),
PatRange(lower_bound, upper_bound) => {
visitor.visit_expr(lower_bound, env.clone());
visitor.visit_expr(upper_bound, env)
}
pat_wild => (),
pat_vec(ref prepattern, ref slice_pattern, ref postpatterns) => {
PatWild => (),
PatVec(ref prepattern, ref slice_pattern, ref postpatterns) => {
for prepattern in prepattern.iter() {
visitor.visit_pat(*prepattern, env.clone())
}
@ -501,25 +501,25 @@ pub fn walk_block<E:Clone, V:Visitor<E>>(visitor: &mut V, block: &Block, env: E)
walk_expr_opt(visitor, block.expr, env)
}
pub fn walk_stmt<E:Clone, V:Visitor<E>>(visitor: &mut V, statement: &stmt, env: E) {
pub fn walk_stmt<E:Clone, V:Visitor<E>>(visitor: &mut V, statement: &Stmt, env: E) {
match statement.node {
stmt_decl(declaration, _) => visitor.visit_decl(declaration, env),
stmt_expr(expression, _) | stmt_semi(expression, _) => {
StmtDecl(declaration, _) => visitor.visit_decl(declaration, env),
StmtExpr(expression, _) | StmtSemi(expression, _) => {
visitor.visit_expr(expression, env)
}
stmt_mac(ref macro, _) => walk_mac(visitor, macro, env),
StmtMac(ref macro, _) => walk_mac(visitor, macro, env),
}
}
pub fn walk_decl<E:Clone, V:Visitor<E>>(visitor: &mut V, declaration: &decl, env: E) {
pub fn walk_decl<E:Clone, V:Visitor<E>>(visitor: &mut V, declaration: &Decl, env: E) {
match declaration.node {
decl_local(ref local) => visitor.visit_local(*local, env),
decl_item(item) => visitor.visit_item(item, env),
DeclLocal(ref local) => visitor.visit_local(*local, env),
DeclItem(item) => visitor.visit_item(item, env),
}
}
pub fn walk_expr_opt<E:Clone, V:Visitor<E>>(visitor: &mut V,
optional_expression: Option<@expr>,
optional_expression: Option<@Expr>,
env: E) {
match optional_expression {
None => {}
@ -528,7 +528,7 @@ pub fn walk_expr_opt<E:Clone, V:Visitor<E>>(visitor: &mut V,
}
pub fn walk_exprs<E:Clone, V:Visitor<E>>(visitor: &mut V,
expressions: &[@expr],
expressions: &[@Expr],
env: E) {
for expression in expressions.iter() {
visitor.visit_expr(*expression, env.clone())
@ -539,79 +539,79 @@ pub fn walk_mac<E, V:Visitor<E>>(_: &mut V, _: &mac, _: E) {
// Empty!
}
pub fn walk_expr<E:Clone, V:Visitor<E>>(visitor: &mut V, expression: @expr, env: E) {
pub fn walk_expr<E:Clone, V:Visitor<E>>(visitor: &mut V, expression: @Expr, env: E) {
match expression.node {
expr_vstore(subexpression, _) => {
ExprVstore(subexpression, _) => {
visitor.visit_expr(subexpression, env.clone())
}
expr_vec(ref subexpressions, _) => {
ExprVec(ref subexpressions, _) => {
walk_exprs(visitor, *subexpressions, env.clone())
}
expr_repeat(element, count, _) => {
ExprRepeat(element, count, _) => {
visitor.visit_expr(element, env.clone());
visitor.visit_expr(count, env.clone())
}
expr_struct(ref path, ref fields, optional_base) => {
ExprStruct(ref path, ref fields, optional_base) => {
walk_path(visitor, path, env.clone());
for field in fields.iter() {
visitor.visit_expr(field.expr, env.clone())
}
walk_expr_opt(visitor, optional_base, env.clone())
}
expr_tup(ref subexpressions) => {
ExprTup(ref subexpressions) => {
for subexpression in subexpressions.iter() {
visitor.visit_expr(*subexpression, env.clone())
}
}
expr_call(callee_expression, ref arguments, _) => {
ExprCall(callee_expression, ref arguments, _) => {
for argument in arguments.iter() {
visitor.visit_expr(*argument, env.clone())
}
visitor.visit_expr(callee_expression, env.clone())
}
expr_method_call(_, callee, _, ref types, ref arguments, _) => {
ExprMethodCall(_, callee, _, ref types, ref arguments, _) => {
walk_exprs(visitor, *arguments, env.clone());
for typ in types.iter() {
visitor.visit_ty(typ, env.clone())
}
visitor.visit_expr(callee, env.clone())
}
expr_binary(_, _, left_expression, right_expression) => {
ExprBinary(_, _, left_expression, right_expression) => {
visitor.visit_expr(left_expression, env.clone());
visitor.visit_expr(right_expression, env.clone())
}
expr_addr_of(_, subexpression) |
expr_unary(_, _, subexpression) |
expr_do_body(subexpression) => {
ExprAddrOf(_, subexpression) |
ExprUnary(_, _, subexpression) |
ExprDoBody(subexpression) => {
visitor.visit_expr(subexpression, env.clone())
}
expr_lit(_) => {}
expr_cast(subexpression, ref typ) => {
ExprLit(_) => {}
ExprCast(subexpression, ref typ) => {
visitor.visit_expr(subexpression, env.clone());
visitor.visit_ty(typ, env.clone())
}
expr_if(head_expression, ref if_block, optional_else) => {
ExprIf(head_expression, ref if_block, optional_else) => {
visitor.visit_expr(head_expression, env.clone());
visitor.visit_block(if_block, env.clone());
walk_expr_opt(visitor, optional_else, env.clone())
}
expr_while(subexpression, ref block) => {
ExprWhile(subexpression, ref block) => {
visitor.visit_expr(subexpression, env.clone());
visitor.visit_block(block, env.clone())
}
expr_for_loop(pattern, subexpression, ref block) => {
ExprForLoop(pattern, subexpression, ref block) => {
visitor.visit_pat(pattern, env.clone());
visitor.visit_expr(subexpression, env.clone());
visitor.visit_block(block, env.clone())
}
expr_loop(ref block, _) => visitor.visit_block(block, env.clone()),
expr_match(subexpression, ref arms) => {
ExprLoop(ref block, _) => visitor.visit_block(block, env.clone()),
ExprMatch(subexpression, ref arms) => {
visitor.visit_expr(subexpression, env.clone());
for arm in arms.iter() {
visitor.visit_arm(arm, env.clone())
}
}
expr_fn_block(ref function_declaration, ref body) => {
ExprFnBlock(ref function_declaration, ref body) => {
visitor.visit_fn(&fk_fn_block,
function_declaration,
body,
@ -619,39 +619,39 @@ pub fn walk_expr<E:Clone, V:Visitor<E>>(visitor: &mut V, expression: @expr, env:
expression.id,
env.clone())
}
expr_block(ref block) => visitor.visit_block(block, env.clone()),
expr_assign(left_hand_expression, right_hand_expression) => {
ExprBlock(ref block) => visitor.visit_block(block, env.clone()),
ExprAssign(left_hand_expression, right_hand_expression) => {
visitor.visit_expr(right_hand_expression, env.clone());
visitor.visit_expr(left_hand_expression, env.clone())
}
expr_assign_op(_, _, left_expression, right_expression) => {
ExprAssignOp(_, _, left_expression, right_expression) => {
visitor.visit_expr(right_expression, env.clone());
visitor.visit_expr(left_expression, env.clone())
}
expr_field(subexpression, _, ref types) => {
ExprField(subexpression, _, ref types) => {
visitor.visit_expr(subexpression, env.clone());
for typ in types.iter() {
visitor.visit_ty(typ, env.clone())
}
}
expr_index(_, main_expression, index_expression) => {
ExprIndex(_, main_expression, index_expression) => {
visitor.visit_expr(main_expression, env.clone());
visitor.visit_expr(index_expression, env.clone())
}
expr_path(ref path) => walk_path(visitor, path, env.clone()),
expr_self | expr_break(_) | expr_again(_) => {}
expr_ret(optional_expression) => {
ExprPath(ref path) => walk_path(visitor, path, env.clone()),
ExprSelf | ExprBreak(_) | ExprAgain(_) => {}
ExprRet(optional_expression) => {
walk_expr_opt(visitor, optional_expression, env.clone())
}
expr_log(level, subexpression) => {
ExprLog(level, subexpression) => {
visitor.visit_expr(level, env.clone());
visitor.visit_expr(subexpression, env.clone());
}
expr_mac(ref macro) => walk_mac(visitor, macro, env.clone()),
expr_paren(subexpression) => {
ExprMac(ref macro) => walk_mac(visitor, macro, env.clone()),
ExprParen(subexpression) => {
visitor.visit_expr(subexpression, env.clone())
}
expr_inline_asm(ref assembler) => {
ExprInlineAsm(ref assembler) => {
for &(_, input) in assembler.inputs.iter() {
visitor.visit_expr(input, env.clone())
}
@ -664,7 +664,7 @@ pub fn walk_expr<E:Clone, V:Visitor<E>>(visitor: &mut V, expression: @expr, env:
visitor.visit_expr_post(expression, env.clone())
}
pub fn walk_arm<E:Clone, V:Visitor<E>>(visitor: &mut V, arm: &arm, env: E) {
pub fn walk_arm<E:Clone, V:Visitor<E>>(visitor: &mut V, arm: &Arm, env: E) {
for pattern in arm.pats.iter() {
visitor.visit_pat(*pattern, env.clone())
}
@ -682,12 +682,12 @@ pub trait SimpleVisitor {
fn visit_item(&mut self, @item);
fn visit_local(&mut self, @Local);
fn visit_block(&mut self, &Block);
fn visit_stmt(&mut self, @stmt);
fn visit_arm(&mut self, &arm);
fn visit_pat(&mut self, @pat);
fn visit_decl(&mut self, @decl);
fn visit_expr(&mut self, @expr);
fn visit_expr_post(&mut self, @expr);
fn visit_stmt(&mut self, @Stmt);
fn visit_arm(&mut self, &Arm);
fn visit_pat(&mut self, @Pat);
fn visit_decl(&mut self, @Decl);
fn visit_expr(&mut self, @Expr);
fn visit_expr_post(&mut self, @Expr);
fn visit_ty(&mut self, &Ty);
fn visit_generics(&mut self, &Generics);
fn visit_fn(&mut self, &fn_kind, &fn_decl, &Block, Span, NodeId);
@ -731,27 +731,27 @@ impl Visitor<()> for SimpleVisitorVisitor {
self.simple_visitor.visit_block(block);
walk_block(self, block, env)
}
fn visit_stmt(&mut self, statement: @stmt, env: ()) {
fn visit_stmt(&mut self, statement: @Stmt, env: ()) {
self.simple_visitor.visit_stmt(statement);
walk_stmt(self, statement, env)
}
fn visit_arm(&mut self, arm: &arm, env: ()) {
fn visit_arm(&mut self, arm: &Arm, env: ()) {
self.simple_visitor.visit_arm(arm);
walk_arm(self, arm, env)
}
fn visit_pat(&mut self, pattern: @pat, env: ()) {
fn visit_pat(&mut self, pattern: @Pat, env: ()) {
self.simple_visitor.visit_pat(pattern);
walk_pat(self, pattern, env)
}
fn visit_decl(&mut self, declaration: @decl, env: ()) {
fn visit_decl(&mut self, declaration: @Decl, env: ()) {
self.simple_visitor.visit_decl(declaration);
walk_decl(self, declaration, env)
}
fn visit_expr(&mut self, expression: @expr, env: ()) {
fn visit_expr(&mut self, expression: @Expr, env: ()) {
self.simple_visitor.visit_expr(expression);
walk_expr(self, expression, env)
}
fn visit_expr_post(&mut self, expression: @expr, _: ()) {
fn visit_expr_post(&mut self, expression: @Expr, _: ()) {
self.simple_visitor.visit_expr_post(expression)
}
fn visit_ty(&mut self, typ: &Ty, env: ()) {