@@ -5010,8 +5010,8 @@ fn trans_item(cx: @local_ctxt, item: ast::item) {
5010
5010
with * extend_path ( cx, item. ident ) } ;
5011
5011
trans_obj ( sub_cx, item. span , ob, ctor_id, tps) ;
5012
5012
}
5013
- ast:: item_impl ( tps, _ , _, ms) {
5014
- trans_impl:: trans_impl ( cx, item. ident , ms, item. id , tps) ;
5013
+ ast:: item_impl ( tps, ifce , _, ms) {
5014
+ trans_impl:: trans_impl ( cx, item. ident , ms, item. id , tps, ifce ) ;
5015
5015
}
5016
5016
ast:: item_res ( decl, tps, body, dtor_id, ctor_id) {
5017
5017
trans_res_ctor ( cx, item. span , decl, ctor_id, tps) ;
@@ -5249,56 +5249,55 @@ fn collect_native_item(ccx: @crate_ctxt,
5249
5249
_v : vt < [ str ] > ) {
5250
5250
alt i. node {
5251
5251
ast:: native_item_fn ( _, tps) {
5252
- if !ccx. obj_methods . contains_key ( i. id ) {
5253
- let sp = i. span ;
5254
- let id = i. id ;
5255
- let node_type = node_id_type ( ccx, id) ;
5256
- let fn_abi =
5257
- alt attr:: get_meta_item_value_str_by_name ( i. attrs , "abi" ) {
5258
- option:: none. {
5252
+ let sp = i. span ;
5253
+ let id = i. id ;
5254
+ let node_type = node_id_type ( ccx, id) ;
5255
+ let fn_abi =
5256
+ alt attr:: get_meta_item_value_str_by_name ( i. attrs , "abi" ) {
5257
+ option:: none. {
5259
5258
// if abi isn't specified for this function, inherit from
5260
- // its enclosing native module
5261
- option:: get ( * abi)
5259
+ // its enclosing native module
5260
+ option:: get ( * abi)
5262
5261
}
5263
- _ {
5264
- alt attr:: native_abi ( i. attrs ) {
5265
- either:: right ( abi_) { abi_ }
5266
- either:: left ( msg) { ccx. sess . span_fatal ( i. span , msg) }
5262
+ _ {
5263
+ alt attr:: native_abi ( i. attrs ) {
5264
+ either:: right ( abi_) { abi_ }
5265
+ either:: left ( msg) { ccx. sess . span_fatal ( i. span , msg) }
5266
+ }
5267
5267
}
5268
- }
5269
5268
} ;
5270
- alt fn_abi {
5271
- ast : : native_abi_rust_intrinsic. {
5272
- // For intrinsics: link the function directly to the intrinsic
5273
- // function itself.
5274
- check returns_non_ty_var ( ccx, node_type) ;
5275
- let fn_type = type_of_fn_from_ty (
5276
- ccx, sp, node_type,
5277
- vec:: map ( tps, { |p| param_bounds ( ccx, p) } ) ) ;
5278
- let ri_name = "rust_intrinsic_" + link_name ( i) ;
5279
- let llnativefn = get_extern_fn (
5280
- ccx. externs , ccx. llmod , ri_name,
5281
- lib:: llvm:: LLVMCCallConv , fn_type) ;
5282
- ccx. item_ids . insert ( id, llnativefn) ;
5283
- ccx. item_symbols . insert ( id, ri_name) ;
5284
- }
5269
+ alt fn_abi {
5270
+ ast : : native_abi_rust_intrinsic. {
5271
+ // For intrinsics: link the function directly to the intrinsic
5272
+ // function itself.
5273
+ check returns_non_ty_var ( ccx, node_type) ;
5274
+ let fn_type = type_of_fn_from_ty (
5275
+ ccx, sp, node_type,
5276
+ vec:: map ( tps, { |p| param_bounds ( ccx, p) } ) ) ;
5277
+ let ri_name = "rust_intrinsic_" + link_name ( i) ;
5278
+ let llnativefn = get_extern_fn (
5279
+ ccx. externs , ccx. llmod , ri_name,
5280
+ lib:: llvm:: LLVMCCallConv , fn_type) ;
5281
+ ccx. item_ids . insert ( id, llnativefn) ;
5282
+ ccx. item_symbols . insert ( id, ri_name) ;
5283
+ }
5285
5284
5286
- ast:: native_abi_cdecl. | ast:: native_abi_stdcall. {
5287
- // For true external functions: create a rust wrapper
5288
- // and link to that. The rust wrapper will handle
5289
- // switching to the C stack.
5290
- let new_pt = pt + [ i. ident ] ;
5291
- register_fn ( ccx, i. span , new_pt, "native fn" , tps, i. id ) ;
5292
- }
5293
- }
5285
+ ast:: native_abi_cdecl. | ast:: native_abi_stdcall. {
5286
+ // For true external functions: create a rust wrapper
5287
+ // and link to that. The rust wrapper will handle
5288
+ // switching to the C stack.
5289
+ let new_pt = pt + [ i. ident ] ;
5290
+ register_fn ( ccx, i. span , new_pt, "native fn" , tps, i. id ) ;
5291
+ }
5294
5292
}
5295
5293
}
5296
5294
_ { }
5297
5295
}
5298
5296
}
5299
5297
5300
- fn collect_item_1 ( ccx : @crate_ctxt , abi : @mutable option:: t < ast:: native_abi > ,
5301
- i : @ast:: item , & & pt: [ str ] , v : vt < [ str ] > ) {
5298
+ fn collect_item ( ccx : @crate_ctxt , abi : @mutable option:: t < ast:: native_abi > ,
5299
+ i : @ast:: item , & & pt: [ str ] , v : vt < [ str ] > ) {
5300
+ let new_pt = pt + [ i. ident ] ;
5302
5301
alt i. node {
5303
5302
ast:: item_const ( _, _) {
5304
5303
let typ = node_id_type ( ccx, i. id ) ;
@@ -5323,26 +5322,11 @@ fn collect_item_1(ccx: @crate_ctxt, abi: @mutable option::t<ast::native_abi>,
5323
5322
}
5324
5323
}
5325
5324
}
5326
- _ { }
5327
- }
5328
- visit:: visit_item ( i, pt + [ i. ident ] , v) ;
5329
- }
5330
-
5331
- fn collect_item_2 ( ccx : @crate_ctxt , i : @ast:: item , & & pt: [ str ] ,
5332
- v : vt < [ str ] > ) {
5333
- let new_pt = pt + [ i. ident ] ;
5334
- visit:: visit_item ( i, new_pt, v) ;
5335
- alt i. node {
5336
5325
ast:: item_fn ( _, tps, _) {
5337
- if !ccx. obj_methods . contains_key ( i. id ) {
5338
- register_fn ( ccx, i. span , new_pt, "fn" , tps, i. id ) ;
5339
- }
5326
+ register_fn ( ccx, i. span , new_pt, "fn" , tps, i. id ) ;
5340
5327
}
5341
5328
ast:: item_obj ( ob, tps, ctor_id) {
5342
5329
register_fn ( ccx, i. span , new_pt, "obj_ctor" , tps, ctor_id) ;
5343
- for m: @ast:: method in ob. methods {
5344
- ccx. obj_methods . insert ( m. id , ( ) ) ;
5345
- }
5346
5330
}
5347
5331
ast:: item_impl ( tps, _, _, methods) {
5348
5332
let name = ccx. names . next ( i. ident ) ;
@@ -5362,47 +5346,28 @@ fn collect_item_2(ccx: @crate_ctxt, i: @ast::item, &&pt: [str],
5362
5346
check returns_non_ty_var ( ccx, t) ;
5363
5347
register_fn_full ( ccx, i. span , new_pt, "res_dtor" , tps, i. id , t) ;
5364
5348
}
5365
- _ { }
5366
- }
5367
- }
5368
-
5369
- fn collect_items ( ccx : @crate_ctxt , crate : @ast:: crate ) {
5370
- let abi = @mutable none :: < ast:: native_abi > ;
5371
- let visitor0 = visit:: default_visitor ( ) ;
5372
- let visitor1 =
5373
- @{ visit_native_item: bind collect_native_item ( ccx, abi, _, _, _) ,
5374
- visit_item: bind collect_item_1 ( ccx, abi, _, _, _) with * visitor0} ;
5375
- let visitor2 =
5376
- @{ visit_item: bind collect_item_2 ( ccx, _, _, _) with * visitor0} ;
5377
- visit:: visit_crate ( * crate , [ ] , visit:: mk_vt ( visitor1) ) ;
5378
- visit:: visit_crate ( * crate , [ ] , visit:: mk_vt ( visitor2) ) ;
5379
- }
5380
-
5381
- fn collect_tag_ctor ( ccx : @crate_ctxt , i : @ast:: item , & & pt: [ str ] ,
5382
- v : vt < [ str ] > ) {
5383
- let new_pt = pt + [ i. ident ] ;
5384
- visit:: visit_item ( i, new_pt, v) ;
5385
- alt i. node {
5386
5349
ast:: item_tag ( variants, tps) {
5387
- for variant: ast :: variant in variants {
5350
+ for variant in variants {
5388
5351
if vec:: len ( variant. node . args ) != 0 u {
5389
5352
register_fn ( ccx, i. span , new_pt + [ variant. node . name ] ,
5390
5353
"tag" , tps, variant. node . id ) ;
5391
5354
}
5392
5355
}
5393
5356
}
5394
- _ { /* fall through */ }
5357
+ _ { }
5395
5358
}
5359
+ visit:: visit_item ( i, new_pt, v) ;
5396
5360
}
5397
5361
5398
- fn collect_tag_ctors ( ccx : @crate_ctxt , crate : @ast:: crate ) {
5399
- let visitor =
5400
- @{ visit_item: bind collect_tag_ctor ( ccx, _, _, _)
5401
- with * visit:: default_visitor ( ) } ;
5402
- visit:: visit_crate ( * crate , [ ] , visit:: mk_vt ( visitor) ) ;
5362
+ fn collect_items ( ccx : @crate_ctxt , crate : @ast:: crate ) {
5363
+ let abi = @mutable none :: < ast:: native_abi > ;
5364
+ visit:: visit_crate ( * crate , [ ] , visit:: mk_vt ( @{
5365
+ visit_native_item: bind collect_native_item ( ccx, abi, _, _, _) ,
5366
+ visit_item: bind collect_item ( ccx, abi, _, _, _)
5367
+ with * visit:: default_visitor ( )
5368
+ } ) ) ;
5403
5369
}
5404
5370
5405
-
5406
5371
// The constant translation pass.
5407
5372
fn trans_constant ( ccx : @crate_ctxt , it : @ast:: item , & & pt: [ str ] ,
5408
5373
v : vt < [ str ] > ) {
@@ -5411,15 +5376,12 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item, &&pt: [str],
5411
5376
alt it. node {
5412
5377
ast:: item_tag ( variants, _) {
5413
5378
let i = 0 u;
5414
- let n_variants = vec:: len :: < ast:: variant > ( variants) ;
5415
- while i < n_variants {
5416
- let variant = variants[ i] ;
5379
+ for variant in variants {
5417
5380
let p = new_pt + [ it. ident , variant. node . name , "discrim" ] ;
5418
5381
let s = mangle_exported_name ( ccx, p, ty:: mk_int ( ccx. tcx ) ) ;
5419
- let discrim_gvar =
5420
- str:: as_buf ( s, { |buf|
5421
- llvm:: LLVMAddGlobal ( ccx. llmod , ccx. int_type , buf)
5422
- } ) ;
5382
+ let discrim_gvar = str:: as_buf ( s, { |buf|
5383
+ llvm:: LLVMAddGlobal ( ccx. llmod , ccx. int_type , buf)
5384
+ } ) ;
5423
5385
llvm:: LLVMSetInitializer ( discrim_gvar, C_int ( ccx, i as int ) ) ;
5424
5386
llvm:: LLVMSetGlobalConstant ( discrim_gvar, True ) ;
5425
5387
ccx. discrims . insert (
@@ -5670,7 +5632,6 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
5670
5632
discrims: ast_util:: new_def_id_hash :: < ValueRef > ( ) ,
5671
5633
discrim_symbols: new_int_hash :: < str > ( ) ,
5672
5634
consts: new_int_hash :: < ValueRef > ( ) ,
5673
- obj_methods: new_int_hash :: < ( ) > ( ) ,
5674
5635
tydescs: ty:: new_ty_hash ( ) ,
5675
5636
module_data: new_str_hash :: < ValueRef > ( ) ,
5676
5637
lltypes: ty:: new_ty_hash ( ) ,
@@ -5706,7 +5667,6 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
5706
5667
dbg_cx: dbg_cx} ;
5707
5668
let cx = new_local_ctxt ( ccx) ;
5708
5669
collect_items ( ccx, crate ) ;
5709
- collect_tag_ctors ( ccx, crate ) ;
5710
5670
trans_constants ( ccx, crate ) ;
5711
5671
trans_mod ( cx, crate . node. module ) ;
5712
5672
fill_crate_map ( ccx, crate_map) ;
@@ -5724,7 +5684,6 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
5724
5684
#error ( "n_null_glues: %u" , ccx. stats . n_null_glues ) ;
5725
5685
#error ( "n_real_glues: %u" , ccx. stats . n_real_glues ) ;
5726
5686
5727
-
5728
5687
for timing: { ident: str , time: int} in * ccx. stats . fn_times {
5729
5688
#error ( "time: %s took %d ms" , timing. ident , timing. time ) ;
5730
5689
}
0 commit comments