When we cons up vector asts, generate evecs.

This commit is contained in:
Michael Sullivan 2012-06-25 20:00:39 -07:00
parent a71a49faa8
commit c087aaf56b
4 changed files with 28 additions and 8 deletions

View File

@ -61,6 +61,16 @@ fn mk_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]) ->
let vecexpr = ast::expr_vec(exprs, ast::m_imm);
ret @{id: cx.next_id(), node: vecexpr, span: sp};
}
fn mk_vstore_e(cx: ext_ctxt, sp: span, expr: @ast::expr, vst: ast::vstore) ->
@ast::expr {
let vstoreexpr = ast::expr_vstore(expr, vst);
ret @{id: cx.next_id(), node: vstoreexpr, span: sp};
}
fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]/~) ->
@ast::expr {
mk_vstore_e(cx, sp, mk_vec_e(cx, sp, exprs), ast::vstore_uniq)
}
fn mk_rec_e(cx: ext_ctxt, sp: span,
fields: [{ident: ast::ident, ex: @ast::expr}]) ->
@ast::expr {

View File

@ -61,7 +61,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
}
flagexprs += [make_rt_path_expr(cx, sp, @fstr)];
}
ret mk_vec_e(cx, sp, flagexprs);
ret mk_uniq_vec_e(cx, sp, flagexprs);
}
fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr {
alt cnt {

View File

@ -258,7 +258,7 @@ fn finish<T: qq_helper>
rcall = mk_call(cx,sp,
[@"syntax", @"ext", @"qquote", @"replace"],
[pcall,
mk_vec_e(cx,sp, qcx.gather.map_to_vec {|g|
mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec {|g|
mk_call(cx,sp,
[@"syntax", @"ext",
@"qquote", @g.constr],

View File

@ -265,8 +265,11 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
let vec_mt: ast::mt = {ty: @test_desc_ty, mutbl: ast::m_imm};
let inner_ty = @{id: cx.sess.next_node_id(),
node: ast::ty_vec(vec_mt),
span: dummy_sp()};
ret @{id: cx.sess.next_node_id(),
node: ast::ty_vec(vec_mt),
node: ast::ty_vstore(inner_ty, ast::vstore_uniq),
span: dummy_sp()};
}
@ -277,8 +280,11 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
descs += [mk_test_desc_rec(cx, test)];
}
let inner_expr = @{id: cx.sess.next_node_id(),
node: ast::expr_vec(descs, ast::m_imm),
span: dummy_sp()};
ret @{id: cx.sess.next_node_id(),
node: ast::expr_vec(descs, ast::m_imm),
node: ast::expr_vstore(inner_expr, ast::vstore_uniq),
span: dummy_sp()};
}
@ -384,10 +390,14 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
let str_ty = @{id: cx.sess.next_node_id(),
node: ast::ty_path(str_pt, cx.sess.next_node_id()),
span: dummy_sp()};
let args_mt: ast::mt = {ty: str_ty, mutbl: ast::m_imm};
let args_ty: ast::ty = {id: cx.sess.next_node_id(),
node: ast::ty_vec(args_mt),
span: dummy_sp()};
let args_mt = {ty: str_ty, mutbl: ast::m_imm};
let args_ty_inner = @{id: cx.sess.next_node_id(),
node: ast::ty_vec(args_mt),
span: dummy_sp()};
let args_ty = {id: cx.sess.next_node_id(),
node: ast::ty_vstore(args_ty_inner, ast::vstore_uniq),
span: dummy_sp()};
let args_arg: ast::arg =
{mode: ast::expl(ast::by_val),