convert ast::expr into a struct
This commit is contained in:
parent
1280a64089
commit
8a3a1fc148
15 changed files with 222 additions and 148 deletions
|
@ -76,7 +76,12 @@ fn find_rust_files(files: &mut ~[Path], path: &Path) {
|
|||
|
||||
fn common_exprs() -> ~[ast::expr] {
|
||||
fn dse(e: ast::expr_) -> ast::expr {
|
||||
{ id: 0, callee_id: -1, node: e, span: ast_util::dummy_sp() }
|
||||
ast::expr {
|
||||
id: 0,
|
||||
callee_id: -1,
|
||||
node: e,
|
||||
span: ast_util::dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn dsl(l: ast::lit_) -> ast::lit {
|
||||
|
|
|
@ -351,14 +351,19 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
|
|||
descs.push(mk_test_desc_rec(cx, *test));
|
||||
}
|
||||
|
||||
let inner_expr = @{id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_vec(descs, ast::m_imm),
|
||||
span: dummy_sp()};
|
||||
return @{id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_vstore(inner_expr, ast::expr_vstore_uniq),
|
||||
span: dummy_sp()};
|
||||
let inner_expr = @ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_vec(descs, ast::m_imm),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
@ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_vstore(inner_expr, ast::expr_vstore_uniq),
|
||||
span: dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
||||
|
@ -371,17 +376,20 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
|||
let name_lit: ast::lit =
|
||||
nospan(ast::lit_str(@ast_util::path_name_i(
|
||||
path, cx.sess.parse_sess.interner)));
|
||||
let name_expr_inner: @ast::expr =
|
||||
@{id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_lit(@name_lit),
|
||||
span: span};
|
||||
let name_expr = {id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_vstore(name_expr_inner,
|
||||
ast::expr_vstore_uniq),
|
||||
span: dummy_sp()};
|
||||
|
||||
let name_expr_inner = @ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_lit(@name_lit),
|
||||
span: span,
|
||||
};
|
||||
|
||||
let name_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_vstore(name_expr_inner, ast::expr_vstore_uniq),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
let name_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
|
@ -391,11 +399,12 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
|||
|
||||
let fn_path = path_node_global(path);
|
||||
|
||||
let fn_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_path(fn_path),
|
||||
span: span};
|
||||
let fn_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_path(fn_path),
|
||||
span: span,
|
||||
};
|
||||
|
||||
let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span);
|
||||
|
||||
|
@ -407,11 +416,12 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
|||
|
||||
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
|
||||
|
||||
let ignore_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_lit(@ignore_lit),
|
||||
span: span};
|
||||
let ignore_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_lit(@ignore_lit),
|
||||
span: span,
|
||||
};
|
||||
|
||||
let ignore_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
|
@ -421,11 +431,12 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
|||
|
||||
let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail));
|
||||
|
||||
let fail_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_lit(@fail_lit),
|
||||
span: span};
|
||||
let fail_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_lit(@fail_lit),
|
||||
span: span,
|
||||
};
|
||||
|
||||
let fail_field = nospan(ast::field_ {
|
||||
mutbl: ast::m_imm,
|
||||
|
@ -437,14 +448,19 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
|||
mk_path(cx, ~[cx.sess.ident_of(~"test"),
|
||||
cx.sess.ident_of(~"TestDesc")]);
|
||||
|
||||
let desc_rec_: ast::expr_ =
|
||||
ast::expr_struct(
|
||||
test_desc_path,
|
||||
~[name_field, fn_field, ignore_field, fail_field],
|
||||
option::None);
|
||||
let desc_rec: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: desc_rec_, span: span};
|
||||
let desc_rec_ = ast::expr_struct(
|
||||
test_desc_path,
|
||||
~[name_field, fn_field, ignore_field, fail_field],
|
||||
option::None
|
||||
);
|
||||
|
||||
let desc_rec = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: desc_rec_,
|
||||
span: span,
|
||||
};
|
||||
|
||||
return @desc_rec;
|
||||
}
|
||||
|
||||
|
@ -454,11 +470,11 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
|
|||
fn mk_test_wrapper(cx: test_ctxt,
|
||||
+fn_path_expr: ast::expr,
|
||||
span: span) -> @ast::expr {
|
||||
let call_expr: ast::expr = {
|
||||
let call_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_call(@fn_path_expr, ~[], false),
|
||||
span: span
|
||||
span: span,
|
||||
};
|
||||
|
||||
let call_stmt: ast::stmt = nospan(
|
||||
|
@ -478,11 +494,10 @@ fn mk_test_wrapper(cx: test_ctxt,
|
|||
rules: ast::default_blk
|
||||
});
|
||||
|
||||
let wrapper_expr: ast::expr = {
|
||||
let wrapper_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_fn(ast::ProtoBare, wrapper_decl,
|
||||
wrapper_body, @~[]),
|
||||
node: ast::expr_fn(ast::ProtoBare, wrapper_decl, wrapper_body, @~[]),
|
||||
span: span
|
||||
};
|
||||
|
||||
|
@ -525,51 +540,59 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
|
|||
cx.sess.ident_of(~"args")
|
||||
]);
|
||||
|
||||
let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
|
||||
let args_path_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_path(args_path),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
let args_path_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: args_path_expr_, span: dummy_sp()};
|
||||
|
||||
let args_call_expr_ = ast::expr_call(@args_path_expr, ~[], false);
|
||||
|
||||
let args_call_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: args_call_expr_, span: dummy_sp()};
|
||||
let args_call_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_call(@args_path_expr, ~[], false),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
// Call __test::test to generate the vector of test_descs
|
||||
let test_path = path_node(~[cx.sess.ident_of(~"tests")]);
|
||||
|
||||
let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
|
||||
let test_path_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_path(test_path),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
let test_path_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: test_path_expr_, span: dummy_sp()};
|
||||
|
||||
let test_call_expr_ = ast::expr_call(@test_path_expr, ~[], false);
|
||||
|
||||
let test_call_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: test_call_expr_, span: dummy_sp()};
|
||||
let test_call_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_call(@test_path_expr, ~[], false),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
// Call std::test::test_main
|
||||
let test_main_path =
|
||||
mk_path(cx, ~[cx.sess.ident_of(~"test"),
|
||||
cx.sess.ident_of(~"test_main")]);
|
||||
|
||||
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);
|
||||
let test_main_path_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_path(test_main_path),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
let test_main_path_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: test_main_path_expr_, span: dummy_sp()};
|
||||
|
||||
let test_main_call_expr_: ast::expr_ =
|
||||
ast::expr_call(@test_main_path_expr,
|
||||
~[@args_call_expr, @test_call_expr], false);
|
||||
|
||||
let test_main_call_expr: ast::expr =
|
||||
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
|
||||
node: test_main_call_expr_, span: dummy_sp()};
|
||||
let test_main_call_expr = ast::expr {
|
||||
id: cx.sess.next_node_id(),
|
||||
callee_id: cx.sess.next_node_id(),
|
||||
node: ast::expr_call(
|
||||
@test_main_path_expr,
|
||||
~[@args_call_expr, @test_call_expr],
|
||||
false
|
||||
),
|
||||
span: dummy_sp(),
|
||||
};
|
||||
|
||||
return @test_main_call_expr;
|
||||
}
|
||||
|
|
|
@ -57,10 +57,11 @@ fn check_item(sess: Session, ast_map: ast_map::map,
|
|||
fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
|
||||
fn is_str(e: @expr) -> bool {
|
||||
match e.node {
|
||||
expr_vstore(@{node: expr_lit(@spanned { node: lit_str(_),
|
||||
_}), _},
|
||||
expr_vstore_uniq) => true,
|
||||
_ => false
|
||||
expr_vstore(
|
||||
@expr { node: expr_lit(@spanned { node: lit_str(_), _}), _ },
|
||||
expr_vstore_uniq
|
||||
) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
match p.node {
|
||||
|
|
|
@ -38,7 +38,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
expr_fn_block(_, ref b, _) => {
|
||||
(v.visit_block)((*b), {in_loop: false, can_ret: false}, v);
|
||||
}
|
||||
expr_loop_body(@{node: expr_fn_block(_, ref b, _), _}) => {
|
||||
expr_loop_body(@expr {node: expr_fn_block(_, ref b, _), _}) => {
|
||||
let proto = ty::ty_fn_proto(ty::expr_ty(tcx, e));
|
||||
let blk = (proto == ProtoBorrowed);
|
||||
(v.visit_block)((*b), {in_loop: true, can_ret: blk}, v);
|
||||
|
|
|
@ -693,7 +693,7 @@ fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool {
|
|||
is_refutable(cx, sub)
|
||||
}
|
||||
pat_wild | pat_ident(_, _, None) => { false }
|
||||
pat_lit(@{node: expr_lit(@spanned { node: lit_nil, _}), _}) => {
|
||||
pat_lit(@expr {node: expr_lit(@spanned { node: lit_nil, _}), _}) => {
|
||||
// "()"
|
||||
false
|
||||
}
|
||||
|
|
|
@ -799,10 +799,10 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
|
|||
visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
visit_stmt: |s: @ast::stmt| {
|
||||
match s.node {
|
||||
ast::stmt_semi(@{id: id,
|
||||
callee_id: _,
|
||||
node: ast::expr_path(_),
|
||||
span: _}, _) => {
|
||||
ast::stmt_semi(
|
||||
@ast::expr { id: id, node: ast::expr_path(_), _ },
|
||||
_
|
||||
) => {
|
||||
cx.sess.span_lint(
|
||||
path_statement, id, it.id,
|
||||
s.span,
|
||||
|
|
|
@ -421,7 +421,7 @@ fn trans_call_inner(
|
|||
let ret_in_loop = match /*bad*/copy args {
|
||||
ArgExprs(args) => {
|
||||
args.len() > 0u && match vec::last(args).node {
|
||||
ast::expr_loop_body(@{
|
||||
ast::expr_loop_body(@ast::expr {
|
||||
node: ast::expr_fn_block(_, ref body, _),
|
||||
_
|
||||
}) => body_contains_ret((*body)),
|
||||
|
@ -628,7 +628,7 @@ fn trans_arg_expr(bcx: block,
|
|||
match arg_expr.node {
|
||||
ast::expr_loop_body(
|
||||
// XXX: Bad copy.
|
||||
blk@@{
|
||||
blk@@ast::expr {
|
||||
node: ast::expr_fn_block(copy decl, ref body, cap),
|
||||
_
|
||||
}) =>
|
||||
|
|
|
@ -696,8 +696,14 @@ impl blk_check_mode : cmp::Eq {
|
|||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type expr = {id: node_id, callee_id: node_id, node: expr_, span: span};
|
||||
// Extra node ID is only used for index, assign_op, unary, binary, method call
|
||||
struct expr {
|
||||
id: node_id,
|
||||
// Extra node ID is only used for index, assign_op, unary, binary, method
|
||||
// call
|
||||
callee_id: node_id,
|
||||
node: expr_,
|
||||
span: span,
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
|
|
|
@ -263,8 +263,12 @@ priv impl ext_ctxt {
|
|||
}
|
||||
|
||||
fn expr(span: span, node: ast::expr_) -> @ast::expr {
|
||||
@{id: self.next_id(), callee_id: self.next_id(),
|
||||
node: node, span: span}
|
||||
@ast::expr {
|
||||
id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: node,
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
|
||||
fn path(span: span, strs: ~[ast::ident]) -> @ast::path {
|
||||
|
|
|
@ -19,10 +19,13 @@ use ext::build;
|
|||
use core::dvec;
|
||||
use core::option;
|
||||
|
||||
fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) ->
|
||||
fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) -> @ast::expr {
|
||||
@ast::expr {
|
||||
return @{id: cx.next_id(), callee_id: cx.next_id(),
|
||||
node: expr, span: sp};
|
||||
id: cx.next_id(),
|
||||
callee_id: cx.next_id(),
|
||||
node: expr,
|
||||
span: sp,
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
|
||||
|
|
|
@ -34,13 +34,19 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
|
|||
}
|
||||
let res = cx.parse_sess().interner.intern(@res_str);
|
||||
|
||||
let e = @{id: cx.next_id(),
|
||||
callee_id: cx.next_id(),
|
||||
node: ast::expr_path(@ast::path { span: sp,
|
||||
global: false,
|
||||
idents: ~[res],
|
||||
rp: None,
|
||||
types: ~[] }),
|
||||
span: sp};
|
||||
let e = @ast::expr {
|
||||
id: cx.next_id(),
|
||||
callee_id: cx.next_id(),
|
||||
node: ast::expr_path(
|
||||
@ast::path {
|
||||
span: sp,
|
||||
global: false,
|
||||
idents: ~[res],
|
||||
rp: None,
|
||||
types: ~[],
|
||||
}
|
||||
),
|
||||
span: sp,
|
||||
};
|
||||
mr_expr(e)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,10 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, tt: ~[ast::token_tree])
|
|||
print::pprust::tt_to_str(ast::tt_delim(tt),cx.parse_sess().interner));
|
||||
|
||||
//trivial expression
|
||||
return mr_expr(@{id: cx.next_id(), callee_id: cx.next_id(),
|
||||
node: ast::expr_rec(~[], option::None), span: sp});
|
||||
mr_expr(@ast::expr {
|
||||
id: cx.next_id(),
|
||||
callee_id: cx.next_id(),
|
||||
node: ast::expr_rec(~[], option::None),
|
||||
span: sp,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -122,17 +122,21 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
|||
}
|
||||
|
||||
fn block_expr(b: ast::blk) -> @ast::expr {
|
||||
@{id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: ast::expr_block(b),
|
||||
span: dummy_sp()}
|
||||
@expr {
|
||||
id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: ast::expr_block(b),
|
||||
span: dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn move_expr(e: @ast::expr) -> @ast::expr {
|
||||
@{id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: ast::expr_unary_move(e),
|
||||
span: e.span}
|
||||
@expr {
|
||||
id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: ast::expr_unary_move(e),
|
||||
span: e.span,
|
||||
}
|
||||
}
|
||||
|
||||
fn stmt_expr(e: @ast::expr) -> @ast::stmt {
|
||||
|
@ -153,10 +157,12 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
|||
}
|
||||
|
||||
fn rec(+fields: ~[ast::field]) -> @ast::expr {
|
||||
@{id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: ast::expr_rec(fields, None),
|
||||
span: dummy_sp()}
|
||||
@expr {
|
||||
id: self.next_id(),
|
||||
callee_id: self.next_id(),
|
||||
node: ast::expr_rec(fields, None),
|
||||
span: dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field {
|
||||
|
|
|
@ -761,10 +761,12 @@ impl ast_fold_fns: ast_fold {
|
|||
}
|
||||
fn fold_expr(&&x: @expr) -> @expr {
|
||||
let (n, s) = (self.fold_expr)(x.node, x.span, self as ast_fold);
|
||||
return @{id: (self.new_id)(x.id),
|
||||
callee_id: (self.new_id)(x.callee_id),
|
||||
node: n,
|
||||
span: (self.new_span)(s)};
|
||||
@expr {
|
||||
id: (self.new_id)(x.id),
|
||||
callee_id: (self.new_id)(x.callee_id),
|
||||
node: n,
|
||||
span: (self.new_span)(s),
|
||||
}
|
||||
}
|
||||
fn fold_ty(&&x: @Ty) -> @Ty {
|
||||
let (n, s) = (self.fold_ty)(x.node, x.span, self as ast_fold);
|
||||
|
|
|
@ -888,15 +888,21 @@ impl Parser {
|
|||
}
|
||||
|
||||
fn mk_expr(+lo: BytePos, +hi: BytePos, +node: expr_) -> @expr {
|
||||
return @{id: self.get_id(), callee_id: self.get_id(),
|
||||
node: node, span: mk_sp(lo, hi)};
|
||||
@expr {
|
||||
id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: node,
|
||||
span: mk_sp(lo, hi),
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_mac_expr(+lo: BytePos, +hi: BytePos, m: mac_) -> @expr {
|
||||
return @{id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: expr_mac(spanned {node: m, span: mk_sp(lo, hi)}),
|
||||
span: mk_sp(lo, hi)};
|
||||
@expr {
|
||||
id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: expr_mac(spanned {node: m, span: mk_sp(lo, hi)}),
|
||||
span: mk_sp(lo, hi),
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_lit_u32(i: u32) -> @expr {
|
||||
|
@ -904,8 +910,12 @@ impl Parser {
|
|||
let lv_lit = @spanned { node: lit_uint(i as u64, ty_u32),
|
||||
span: span };
|
||||
|
||||
return @{id: self.get_id(), callee_id: self.get_id(),
|
||||
node: expr_lit(lv_lit), span: span};
|
||||
@expr {
|
||||
id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: expr_lit(lv_lit),
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_bottom_expr() -> @expr {
|
||||
|
@ -1625,23 +1635,21 @@ impl Parser {
|
|||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
let args = vec::append(args, ~[last_arg]);
|
||||
@{node: expr_call(f, args, true),
|
||||
.. *e}
|
||||
@expr {node: expr_call(f, args, true), .. *e}
|
||||
}
|
||||
expr_method_call(f, i, tps, args, false) => {
|
||||
let block = self.parse_lambda_block_expr();
|
||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
let args = vec::append(args, ~[last_arg]);
|
||||
@{node: expr_method_call(f, i, tps, args, true),
|
||||
.. *e}
|
||||
@expr {node: expr_method_call(f, i, tps, args, true), .. *e}
|
||||
}
|
||||
expr_field(f, i, tps) => {
|
||||
let block = self.parse_lambda_block_expr();
|
||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
@{node: expr_method_call(f, i, tps, ~[last_arg], true),
|
||||
.. *e}
|
||||
@expr {node: expr_method_call(f, i, tps, ~[last_arg], true),
|
||||
.. *e}
|
||||
}
|
||||
expr_path(*) | expr_call(*) | expr_method_call(*) |
|
||||
expr_paren(*) => {
|
||||
|
@ -1916,12 +1924,15 @@ impl Parser {
|
|||
hi = sub.span.hi;
|
||||
// HACK: parse @"..." as a literal of a vstore @str
|
||||
pat = match sub.node {
|
||||
pat_lit(e@@{
|
||||
pat_lit(e@@expr {
|
||||
node: expr_lit(@spanned {node: lit_str(_), span: _}), _
|
||||
}) => {
|
||||
let vst = @{id: self.get_id(), callee_id: self.get_id(),
|
||||
node: expr_vstore(e, expr_vstore_box),
|
||||
span: mk_sp(lo, hi)};
|
||||
let vst = @expr {
|
||||
id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: expr_vstore(e, expr_vstore_box),
|
||||
span: mk_sp(lo, hi),
|
||||
};
|
||||
pat_lit(vst)
|
||||
}
|
||||
_ => pat_box(sub)
|
||||
|
@ -1933,12 +1944,15 @@ impl Parser {
|
|||
hi = sub.span.hi;
|
||||
// HACK: parse ~"..." as a literal of a vstore ~str
|
||||
pat = match sub.node {
|
||||
pat_lit(e@@{
|
||||
pat_lit(e@@expr {
|
||||
node: expr_lit(@spanned {node: lit_str(_), span: _}), _
|
||||
}) => {
|
||||
let vst = @{id: self.get_id(), callee_id: self.get_id(),
|
||||
node: expr_vstore(e, expr_vstore_uniq),
|
||||
span: mk_sp(lo, hi)};
|
||||
let vst = @expr {
|
||||
id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: expr_vstore(e, expr_vstore_uniq),
|
||||
span: mk_sp(lo, hi),
|
||||
};
|
||||
pat_lit(vst)
|
||||
}
|
||||
_ => pat_uniq(sub)
|
||||
|
@ -1952,10 +1966,10 @@ impl Parser {
|
|||
hi = sub.span.hi;
|
||||
// HACK: parse &"..." as a literal of a borrowed str
|
||||
pat = match sub.node {
|
||||
pat_lit(e@@{
|
||||
pat_lit(e@@expr {
|
||||
node: expr_lit(@spanned {node: lit_str(_), span: _}), _
|
||||
}) => {
|
||||
let vst = @{
|
||||
let vst = @expr {
|
||||
id: self.get_id(),
|
||||
callee_id: self.get_id(),
|
||||
node: expr_vstore(e, expr_vstore_slice),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue