syntax: add support for #[deriving(Decodable)]
This commit is contained in:
parent
5841564bf9
commit
441df26f5a
3 changed files with 510 additions and 7 deletions
|
@ -279,10 +279,10 @@ pub fn mk_lambda_(cx: @ext_ctxt,
|
|||
mk_expr(cx, span, ast::expr_fn_block(fn_decl, blk))
|
||||
}
|
||||
pub fn mk_lambda(cx: @ext_ctxt,
|
||||
span: span,
|
||||
fn_decl: ast::fn_decl,
|
||||
expr: @ast::expr)
|
||||
-> @ast::expr {
|
||||
span: span,
|
||||
fn_decl: ast::fn_decl,
|
||||
expr: @ast::expr)
|
||||
-> @ast::expr {
|
||||
let blk = mk_simple_block(cx, span, expr);
|
||||
mk_lambda_(cx, span, fn_decl, blk)
|
||||
}
|
||||
|
@ -294,6 +294,13 @@ pub fn mk_lambda_stmts(cx: @ext_ctxt,
|
|||
let blk = mk_block(cx, span, ~[], stmts, None);
|
||||
mk_lambda(cx, span, fn_decl, blk)
|
||||
}
|
||||
pub fn mk_lambda_no_args(cx: @ext_ctxt,
|
||||
span: span,
|
||||
expr: @ast::expr)
|
||||
-> @ast::expr {
|
||||
let fn_decl = mk_fn_decl(~[], mk_ty_infer(cx, span));
|
||||
mk_lambda(cx, span, fn_decl, expr)
|
||||
}
|
||||
pub fn mk_copy(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
||||
mk_expr(cx, sp, ast::expr_copy(e))
|
||||
}
|
||||
|
@ -303,11 +310,20 @@ pub fn mk_managed(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
|||
pub fn mk_pat(cx: @ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat {
|
||||
@ast::pat { id: cx.next_id(), node: pat, span: span }
|
||||
}
|
||||
pub fn mk_pat_wild(cx: @ext_ctxt, span: span) -> @ast::pat {
|
||||
mk_pat(cx, span, ast::pat_wild)
|
||||
}
|
||||
pub fn mk_pat_lit(cx: @ext_ctxt,
|
||||
span: span,
|
||||
expr: @ast::expr) -> @ast::pat {
|
||||
mk_pat(cx, span, ast::pat_lit(expr))
|
||||
}
|
||||
pub fn mk_pat_ident(cx: @ext_ctxt,
|
||||
span: span,
|
||||
ident: ast::ident) -> @ast::pat {
|
||||
mk_pat_ident_with_binding_mode(cx, span, ident, ast::bind_by_copy)
|
||||
}
|
||||
|
||||
pub fn mk_pat_ident_with_binding_mode(cx: @ext_ctxt,
|
||||
span: span,
|
||||
ident: ast::ident,
|
||||
|
@ -435,8 +451,38 @@ pub fn mk_ty_param(cx: @ext_ctxt,
|
|||
}
|
||||
pub fn mk_lifetime(cx: @ext_ctxt,
|
||||
span: span,
|
||||
ident: ast::ident) -> ast::Lifetime
|
||||
{
|
||||
ident: ast::ident)
|
||||
-> ast::Lifetime {
|
||||
ast::Lifetime { id: cx.next_id(), span: span, ident: ident }
|
||||
}
|
||||
|
||||
pub fn mk_arm(cx: @ext_ctxt,
|
||||
span: span,
|
||||
pats: ~[@ast::pat],
|
||||
expr: @ast::expr)
|
||||
-> ast::arm {
|
||||
ast::arm {
|
||||
pats: pats,
|
||||
guard: None,
|
||||
body: mk_simple_block(cx, span, expr)
|
||||
}
|
||||
}
|
||||
pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr {
|
||||
let loc = cx.codemap().lookup_char_pos(span.lo);
|
||||
mk_call_global(
|
||||
cx,
|
||||
span,
|
||||
~[
|
||||
cx.ident_of(~"core"),
|
||||
cx.ident_of(~"sys"),
|
||||
cx.ident_of(~"begin_unwind"),
|
||||
],
|
||||
~[
|
||||
mk_uniq_str(cx, span, ~"internal error: entered unreachable code"),
|
||||
mk_uniq_str(cx, span, loc.file.name),
|
||||
mk_uint(cx, span, loc.line),
|
||||
]
|
||||
)
|
||||
}
|
||||
pub fn mk_unreachable_arm(cx: @ext_ctxt, span: span) -> ast::arm {
|
||||
mk_arm(cx, span, ~[mk_pat_wild(cx, span)], mk_unreachable(cx, span))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue