@@ -5847,8 +5847,8 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
5847
5847
case ( ast:: expr_spawn( ?dom, ?name, ?func, ?args) ) {
5848
5848
ret trans_spawn( cx, dom, name, func, args, e. id) ;
5849
5849
}
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) ;
5852
5852
}
5853
5853
case ( _) {
5854
5854
// The expression is an lvalue. Fall through.
@@ -6222,15 +6222,9 @@ fn trans_be(&@block_ctxt cx, &@ast::expr e) -> result {
6222
6222
// instead "inlining" the construction of the object and returning the object
6223
6223
// itself.
6224
6224
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 {
6226
6226
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.
6232
6227
6233
- assert ( std:: ivec:: len( ty_params) == 0 u) ;
6234
6228
auto ccx = bcx. fcx. lcx. ccx;
6235
6229
6236
6230
// Fields.
@@ -6286,7 +6280,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
6286
6280
// is that, since *all* of the methods are "additional", we can
6287
6281
// get away with acting like none of them are.
6288
6282
vtbl = create_vtbl( bcx. fcx. lcx, sp, outer_obj_ty,
6289
- wrapper_obj, ty_params , none,
6283
+ wrapper_obj, ~ [ ] , none,
6290
6284
additional_field_tys) ;
6291
6285
}
6292
6286
case ( some( ?e) ) {
@@ -6304,8 +6298,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
6304
6298
// create a forwarding slot. And, of course, we need to create a
6305
6299
// normal vtable entry for every method being added.
6306
6300
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) ,
6309
6302
additional_field_tys) ;
6310
6303
}
6311
6304
}
@@ -6333,27 +6326,22 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
6333
6326
// typarams, fields, and a pointer to our with_obj.
6334
6327
let TypeRef llbox_ty = T_ptr ( T_empty_struct ( ) ) ;
6335
6328
6336
- if ( std:: ivec:: len[ ast:: ty_param] ( ty_params) == 0 u &&
6337
- std:: ivec:: len[ ast:: anon_obj_field] ( additional_fields) == 0 u &&
6329
+ if ( std:: ivec:: len[ ast:: anon_obj_field] ( additional_fields) == 0 u &&
6338
6330
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.
6341
6333
bcx. build. Store ( C_null ( llbox_ty) , pair_box) ;
6342
6334
} else {
6343
6335
6344
6336
// Synthesize a tuple type for fields: [field, ...]
6345
6337
let ty:: t fields_ty = ty:: mk_imm_tup( ccx. tcx, additional_field_tys) ;
6346
6338
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.
6350
6340
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, ~[ ] ) ;
6357
6345
6358
6346
// Tuple type for body:
6359
6347
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
@@ -6402,35 +6390,15 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
6402
6390
bcx = body_td. bcx;
6403
6391
bcx. build. Store ( body_td. val, body_tydesc. val) ;
6404
6392
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.
6429
6397
auto body_fields =
6430
6398
GEP_tup_like ( bcx, body_ty, body. val,
6431
6399
~[ 0 , abi:: obj_body_elt_fields] ) ;
6432
6400
bcx = body_fields. bcx;
6433
- i = 0 ;
6401
+ let int i = 0 ;
6434
6402
for ( ast:: anon_obj_field f in additional_fields) {
6435
6403
// FIXME (part of issue #538): make this work eventually, when we
6436
6404
// have additional field exprs in the AST.
@@ -7182,16 +7150,11 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
7182
7150
// Synthesize a tuple type for fields: [field, ...]
7183
7151
let ty:: t fields_ty = ty:: mk_imm_tup( cx. ccx. tcx, additional_field_tys) ;
7184
7152
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.
7188
7154
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, ~[ ] ) ;
7195
7158
7196
7159
// Tuple type for body:
7197
7160
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
0 commit comments