Modernized a few more types in syntax::ast
This commit is contained in:
parent
58decdd7a1
commit
7419085337
114 changed files with 3795 additions and 3790 deletions
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue