Skip to content

Commit 54b20ff

Browse files
committed
---
yaml --- r: 4046 b: refs/heads/master c: 55acc73 h: refs/heads/master v: v3
1 parent 6b5316a commit 54b20ff

File tree

11 files changed

+36
-78
lines changed

11 files changed

+36
-78
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f33309502a10bc41685e08a23f282b74f61b7f89
2+
refs/heads/master: 55acc737a88f3084f68bac55b681a4016292e5b1

trunk/src/comp/middle/trans.rs

+22-59
Original file line numberDiff line numberDiff line change
@@ -5847,8 +5847,8 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
58475847
case (ast::expr_spawn(?dom, ?name, ?func, ?args)) {
58485848
ret trans_spawn(cx, dom, name, func, args, e.id);
58495849
}
5850-
case (ast::expr_anon_obj(?anon_obj, ?tps)) {
5851-
ret trans_anon_obj(cx, e.span, anon_obj, tps, e.id);
5850+
case (ast::expr_anon_obj(?anon_obj)) {
5851+
ret trans_anon_obj(cx, e.span, anon_obj, e.id);
58525852
}
58535853
case (_) {
58545854
// The expression is an lvalue. Fall through.
@@ -6222,15 +6222,9 @@ fn trans_be(&@block_ctxt cx, &@ast::expr e) -> result {
62226222
// instead "inlining" the construction of the object and returning the object
62236223
// itself.
62246224
fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
6225-
&ast::ty_param[] ty_params, ast::node_id id) -> result {
6225+
ast::node_id id) -> result {
62266226

6227-
// Right now, we're assuming that anon objs don't take ty params, even
6228-
// though the AST supports it. It's nonsensical to write an expression
6229-
// like "obj[T](){ ... with ... }", since T is never instantiated;
6230-
// nevertheless, such an expression will parse. Idea for the future:
6231-
// support typarams.
62326227

6233-
assert (std::ivec::len(ty_params) == 0u);
62346228
auto ccx = bcx.fcx.lcx.ccx;
62356229

62366230
// Fields.
@@ -6286,7 +6280,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
62866280
// is that, since *all* of the methods are "additional", we can
62876281
// get away with acting like none of them are.
62886282
vtbl = create_vtbl(bcx.fcx.lcx, sp, outer_obj_ty,
6289-
wrapper_obj, ty_params, none,
6283+
wrapper_obj, ~[], none,
62906284
additional_field_tys);
62916285
}
62926286
case (some(?e)) {
@@ -6304,8 +6298,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
63046298
// create a forwarding slot. And, of course, we need to create a
63056299
// normal vtable entry for every method being added.
63066300
vtbl = create_vtbl(bcx.fcx.lcx, sp, outer_obj_ty,
6307-
wrapper_obj, ty_params,
6308-
some(with_obj_ty),
6301+
wrapper_obj, ~[], some(with_obj_ty),
63096302
additional_field_tys);
63106303
}
63116304
}
@@ -6333,27 +6326,22 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
63336326
// typarams, fields, and a pointer to our with_obj.
63346327
let TypeRef llbox_ty = T_ptr(T_empty_struct());
63356328

6336-
if (std::ivec::len[ast::ty_param](ty_params) == 0u &&
6337-
std::ivec::len[ast::anon_obj_field](additional_fields) == 0u &&
6329+
if (std::ivec::len[ast::anon_obj_field](additional_fields) == 0u &&
63386330
anon_obj.with_obj == none) {
6339-
// If the object we're translating has no fields or type parameters
6340-
// and no with_obj, there's not much to do.
6331+
// If the object we're translating has no fields and no with_obj,
6332+
// there's not much to do.
63416333
bcx.build.Store(C_null(llbox_ty), pair_box);
63426334
} else {
63436335

63446336
// Synthesize a tuple type for fields: [field, ...]
63456337
let ty::t fields_ty = ty::mk_imm_tup(ccx.tcx, additional_field_tys);
63466338

6347-
// Tydescs are run-time instantiations of typarams. We're not
6348-
// actually supporting typarams for anon objs yet, but let's
6349-
// create space for them in case we ever want them.
6339+
// Type for tydescs.
63506340
let ty::t tydesc_ty = ty::mk_type(ccx.tcx);
6351-
let ty::t[] tps = ~[];
6352-
for (ast::ty_param tp in ty_params) {
6353-
tps += ~[tydesc_ty];
6354-
}
6355-
// Synthesize a tuple type for typarams: [typaram, ...]
6356-
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
6341+
6342+
// Placeholder for non-existent typarams, since anon objs don't have
6343+
// them.
6344+
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, ~[]);
63576345

63586346
// Tuple type for body:
63596347
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
@@ -6402,35 +6390,15 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
64026390
bcx = body_td.bcx;
64036391
bcx.build.Store(body_td.val, body_tydesc.val);
64046392

6405-
// Copy the object's type parameters and fields into the space we
6406-
// allocated for the object body. (This is something like saving the
6407-
// lexical environment of a function in its closure: the "captured
6408-
// typarams" are any type parameters that are passed to the object
6409-
// constructor and are then available to the object's methods.
6410-
// Likewise for the object's fields.)
6411-
6412-
// Copy typarams into captured typarams.
6413-
auto body_typarams =
6414-
GEP_tup_like(bcx, body_ty, body.val,
6415-
~[0, abi::obj_body_elt_typarams]);
6416-
bcx = body_typarams.bcx;
6417-
let int i = 0;
6418-
for (ast::ty_param tp in ty_params) {
6419-
auto typaram = bcx.fcx.lltydescs.(i);
6420-
auto capture =
6421-
GEP_tup_like(bcx, typarams_ty, body_typarams.val, ~[0, i]);
6422-
bcx = capture.bcx;
6423-
bcx = copy_val(bcx, INIT, capture.val, typaram,
6424-
tydesc_ty).bcx;
6425-
i += 1;
6426-
}
6427-
6428-
// Copy additional fields into the object's body.
6393+
// Copy the object's fields into the space we allocated for the object
6394+
// body. (This is something like saving the lexical environment of a
6395+
// function in its closure: the fields were passed to the object
6396+
// constructor and are now available to the object's methods.
64296397
auto body_fields =
64306398
GEP_tup_like(bcx, body_ty, body.val,
64316399
~[0, abi::obj_body_elt_fields]);
64326400
bcx = body_fields.bcx;
6433-
i = 0;
6401+
let int i = 0;
64346402
for (ast::anon_obj_field f in additional_fields) {
64356403
// FIXME (part of issue #538): make this work eventually, when we
64366404
// have additional field exprs in the AST.
@@ -7182,16 +7150,11 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
71827150
// Synthesize a tuple type for fields: [field, ...]
71837151
let ty::t fields_ty = ty::mk_imm_tup(cx.ccx.tcx, additional_field_tys);
71847152

7185-
// Tydescs are run-time instantiations of typarams. We're not
7186-
// actually supporting typarams for anon objs yet, but let's
7187-
// create space for them in case we ever want them.
7153+
// Type for tydescs.
71887154
let ty::t tydesc_ty = ty::mk_type(cx.ccx.tcx);
7189-
let ty::t[] tps = ~[];
7190-
for (ast::ty_param tp in ty_params) {
7191-
tps += ~[tydesc_ty];
7192-
}
7193-
// Synthesize a tuple type for typarams: [typaram, ...]
7194-
let ty::t typarams_ty = ty::mk_imm_tup(cx.ccx.tcx, tps);
7155+
7156+
// Placeholder for non-existent typarams, since anon objs don't have them.
7157+
let ty::t typarams_ty = ty::mk_imm_tup(cx.ccx.tcx, ~[]);
71957158

71967159
// Tuple type for body:
71977160
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]

trunk/src/comp/middle/tstate/pre_post_conditions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
567567
case (expr_mac(_)) {
568568
fcx.ccx.tcx.sess.bug("unexpanded macro");
569569
}
570-
case (expr_anon_obj(?anon_obj, _)) {
570+
case (expr_anon_obj(?anon_obj)) {
571571
alt (anon_obj.with_obj) {
572572
case (some(?ex)) {
573573
find_pre_post_expr(fcx, ex);

trunk/src/comp/middle/tstate/states.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
564564
case (expr_cont) { ret pure_exp(fcx.ccx, e.id, pres); }
565565
case (expr_port(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
566566
case (expr_self_method(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
567-
case (expr_anon_obj(?anon_obj, _)) {
567+
case (expr_anon_obj(?anon_obj)) {
568568
alt (anon_obj.with_obj) {
569569
case (some(?wt)) {
570570
ret find_pre_post_state_sub(fcx, pres, wt, e.id, none);

trunk/src/comp/middle/typeck.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
23952395
}
23962396
}
23972397
}
2398-
case (ast::expr_anon_obj(?ao, ?tps)) {
2398+
case (ast::expr_anon_obj(?ao)) {
23992399

24002400
let ast::anon_obj_field[] fields = ~[];
24012401
alt (ao.fields) {
@@ -2432,8 +2432,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
24322432

24332433
fn get_anon_obj_method_types(@fn_ctxt fcx,
24342434
&ast::anon_obj ao,
2435-
&ast::anon_obj_field[] fields,
2436-
&ast::ty_param[] tps)
2435+
&ast::anon_obj_field[] fields)
24372436
-> ty::method[] {
24382437

24392438
let ty::method[] methods = ~[];
@@ -2495,7 +2494,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
24952494
}
24962495

24972496
auto method_types = get_anon_obj_method_types(fcx, ao,
2498-
fields, tps);
2497+
fields);
24992498
auto ot = ty::mk_obj(fcx.ccx.tcx, ty::sort_methods(method_types));
25002499

25012500
write::ty_only_fixup(fcx, id, ot);

trunk/src/comp/syntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ tag expr_ {
325325
expr_if_check(@expr, block, option::t[@expr]);
326326
expr_port(option::t[@ty]);
327327
expr_chan(@expr);
328-
expr_anon_obj(anon_obj, ty_param[]);
328+
expr_anon_obj(anon_obj);
329329
expr_mac(mac);
330330
}
331331

trunk/src/comp/syntax/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
458458
})
459459
}
460460
case (expr_chan(?e)) { expr_chan(fld.fold_expr(e)) }
461-
case (expr_anon_obj(?ao, ?typms)) {
462-
expr_anon_obj(fold_anon_obj(ao), typms)
461+
case (expr_anon_obj(?ao)) {
462+
expr_anon_obj(fold_anon_obj(ao))
463463
}
464464
case (expr_mac(?mac)) {
465465
expr_mac(fold_mac(mac))

trunk/src/comp/syntax/parse/parser.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,6 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
833833
} else if (eat_word(p, "obj")) {
834834
// Anonymous object
835835

836-
// FIXME: Can anonymous objects have ty params?
837-
auto ty_params = parse_ty_params(p);
838-
839836
// Only make people type () if they're actually adding new fields
840837
let option::t[ast::anon_obj_field[]] fields = none;
841838
if (p.peek() == token::LPAREN) {
@@ -864,7 +861,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
864861
// "spanned".
865862
let ast::anon_obj ob =
866863
rec(fields=fields, methods=meths, with_obj=with_obj);
867-
ex = ast::expr_anon_obj(ob, ty_params);
864+
ex = ast::expr_anon_obj(ob);
868865
} else if (eat_word(p, "rec")) {
869866
expect(p, token::LPAREN);
870867
auto fields = ~[parse_field(p)];
@@ -1686,7 +1683,7 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
16861683
case (ast::expr_if_check(_, _, _)) { false }
16871684
case (ast::expr_port(_)) { true }
16881685
case (ast::expr_chan(_)) { true }
1689-
case (ast::expr_anon_obj(_,_)) { false }
1686+
case (ast::expr_anon_obj(_)) { false }
16901687
case (ast::expr_assert(_)) { true }
16911688
}
16921689
}

trunk/src/comp/syntax/print/pprust.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,8 @@ fn print_expr(&ps s, &@ast::expr expr) {
986986
print_expr(s, expr);
987987
pclose(s);
988988
}
989-
case (ast::expr_anon_obj(?anon_obj, ?tps)) {
989+
case (ast::expr_anon_obj(?anon_obj)) {
990990
head(s, "obj");
991-
print_type_params(s, tps);
992991

993992
// Fields
994993
popen(s);

trunk/src/comp/syntax/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
395395
case (expr_assert(?x)) { v.visit_expr(x, e, v); }
396396
case (expr_port(?t)) { visit_ty_opt(t, e, v); }
397397
case (expr_chan(?x)) { v.visit_expr(x, e, v); }
398-
case (expr_anon_obj(?anon_obj, _)) {
398+
case (expr_anon_obj(?anon_obj)) {
399399
alt (anon_obj.fields) {
400400
case (none) { }
401401
case (some(?fields)) {

trunk/src/comp/syntax/walk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
388388
case (ast::expr_assert(?x)) { walk_expr(v, x); }
389389
case (ast::expr_port(_)) { }
390390
case (ast::expr_chan(?x)) { walk_expr(v, x); }
391-
case (ast::expr_anon_obj(?anon_obj, _)) {
391+
case (ast::expr_anon_obj(?anon_obj)) {
392392
// Fields
393393

394394
alt (anon_obj.fields) {

0 commit comments

Comments
 (0)