Simplify AST for expr_anon_obj.
This commit is contained in:
parent
23bae67f4c
commit
e30d2c82ae
@ -6268,7 +6268,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
|
||||
case (ast::expr_spawn(?dom, ?name, ?func, ?args)) {
|
||||
ret trans_spawn(cx, dom, name, func, args, e.id);
|
||||
}
|
||||
case (ast::expr_anon_obj(?anon_obj, ?tps, _)) {
|
||||
case (ast::expr_anon_obj(?anon_obj, ?tps)) {
|
||||
ret trans_anon_obj(cx, e.span, anon_obj, tps, e.id);
|
||||
}
|
||||
case (_) {
|
||||
|
@ -571,7 +571,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
||||
find_pre_post_expr(fcx, expanded);
|
||||
copy_pre_post(fcx.ccx, e.id, expanded);
|
||||
}
|
||||
case (expr_anon_obj(?anon_obj, _, _)) {
|
||||
case (expr_anon_obj(?anon_obj, _)) {
|
||||
alt (anon_obj.with_obj) {
|
||||
case (some(?ex)) {
|
||||
find_pre_post_expr(fcx, ex);
|
||||
|
@ -570,7 +570,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
||||
case (expr_cont) { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
case (expr_port(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
case (expr_self_method(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
case (expr_anon_obj(?anon_obj, _, _)) {
|
||||
case (expr_anon_obj(?anon_obj, _)) {
|
||||
alt (anon_obj.with_obj) {
|
||||
case (some(?wt)) {
|
||||
ret find_pre_post_state_sub(fcx, pres, wt, e.id, none);
|
||||
|
@ -2202,7 +2202,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case (ast::expr_anon_obj(?anon_obj, ?tps, ?obj_def_ids)) {
|
||||
case (ast::expr_anon_obj(?anon_obj, ?tps)) {
|
||||
// TODO: We probably need to do more work here to be able to
|
||||
// handle additional methods that use 'self'
|
||||
|
||||
@ -2221,12 +2221,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
|
||||
}
|
||||
|
||||
let ast::node_id di = obj_def_ids.ty;
|
||||
vec::push[obj_info](fcx.ccx.obj_infos,
|
||||
rec(obj_fields=
|
||||
vec::map(anon_obj_field_to_obj_field,
|
||||
fields),
|
||||
this_obj=di));
|
||||
this_obj=id));
|
||||
|
||||
// FIXME: These next three functions are largely ripped off from
|
||||
// similar ones in collect::. Is there a better way to do this?
|
||||
|
@ -296,7 +296,7 @@ tag expr_ {
|
||||
expr_if_check(@expr, block, option::t[@expr]);
|
||||
expr_port(option::t[@ty]);
|
||||
expr_chan(@expr);
|
||||
expr_anon_obj(anon_obj, vec[ty_param], obj_def_ids);
|
||||
expr_anon_obj(anon_obj, vec[ty_param]);
|
||||
}
|
||||
|
||||
type lit = spanned[lit_];
|
||||
|
@ -429,8 +429,8 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||
})
|
||||
}
|
||||
case (expr_chan(?e)) { expr_chan(fld.fold_expr(e)) }
|
||||
case (expr_anon_obj(?ao, ?typms, ?odis)) {
|
||||
expr_anon_obj(fold_anon_obj(ao), typms, odis)
|
||||
case (expr_anon_obj(?ao, ?typms)) {
|
||||
expr_anon_obj(fold_anon_obj(ao), typms)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -801,8 +801,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
||||
// "spanned".
|
||||
let ast::anon_obj ob =
|
||||
rec(fields=fields, methods=meths, with_obj=with_obj);
|
||||
auto odid = rec(ty=p.get_id(), ctor=p.get_id());
|
||||
ex = ast::expr_anon_obj(ob, ty_params, odid);
|
||||
ex = ast::expr_anon_obj(ob, ty_params);
|
||||
} else if (eat_word(p, "rec")) {
|
||||
expect(p, token::LPAREN);
|
||||
auto fields = [parse_field(p)];
|
||||
@ -1592,7 +1591,7 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
|
||||
case (ast::expr_if_check(_, _, _)) { false }
|
||||
case (ast::expr_port(_)) { true }
|
||||
case (ast::expr_chan(_)) { true }
|
||||
case (ast::expr_anon_obj(_,_,_)) { false }
|
||||
case (ast::expr_anon_obj(_,_)) { false }
|
||||
case (ast::expr_assert(_)) { true }
|
||||
}
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
||||
print_expr(s, expr);
|
||||
pclose(s);
|
||||
}
|
||||
case (ast::expr_anon_obj(_, _, _)) {
|
||||
case (ast::expr_anon_obj(_, _)) {
|
||||
word(s.s, "anon obj");
|
||||
// FIXME (issue #499): nicer pretty-printing of anon objs
|
||||
|
||||
|
@ -371,7 +371,7 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
|
||||
case (expr_assert(?x)) { vt(v).visit_expr(x, e, v); }
|
||||
case (expr_port(_)) { }
|
||||
case (expr_chan(?x)) { vt(v).visit_expr(x, e, v); }
|
||||
case (expr_anon_obj(?anon_obj, _, _)) {
|
||||
case (expr_anon_obj(?anon_obj, _)) {
|
||||
alt (anon_obj.fields) {
|
||||
case (none) { }
|
||||
case (some(?fields)) {
|
||||
|
@ -380,7 +380,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
||||
case (ast::expr_assert(?x)) { walk_expr(v, x); }
|
||||
case (ast::expr_port(_)) { }
|
||||
case (ast::expr_chan(?x)) { walk_expr(v, x); }
|
||||
case (ast::expr_anon_obj(?anon_obj, _, _)) {
|
||||
case (ast::expr_anon_obj(?anon_obj, _)) {
|
||||
// Fields
|
||||
|
||||
alt (anon_obj.fields) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user