@@ -5394,17 +5394,17 @@ fn c_stack_tys(ccx: @crate_ctxt,
5394
5394
//
5395
5395
fn trans_native_mod ( lcx : @local_ctxt , native_mod : ast:: native_mod ) {
5396
5396
fn build_shim_fn ( lcx : @local_ctxt ,
5397
- link_name : str ,
5398
5397
native_item : @ast:: native_item ,
5399
5398
llshimfn : ValueRef ,
5400
5399
cc : uint ) {
5400
+ let lname = link_name ( native_item) ;
5401
5401
let ccx = lcx_ccx ( lcx) ;
5402
5402
let span = native_item. span ;
5403
5403
let id = native_item. id ;
5404
5404
let tys = c_stack_tys ( ccx, span, id) ;
5405
5405
5406
5406
// Declare the "prototype" for the base function F:
5407
- let llbasefn = decl_fn ( ccx. llmod , link_name , cc, tys. base_fn_ty ) ;
5407
+ let llbasefn = decl_fn ( ccx. llmod , lname , cc, tys. base_fn_ty ) ;
5408
5408
5409
5409
// Declare the body of the shim function:
5410
5410
let fcx = new_fn_ctxt ( lcx, span, llshimfn) ;
@@ -5432,13 +5432,6 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
5432
5432
finish_fn ( fcx, lltop) ;
5433
5433
}
5434
5434
5435
- fn select_link_name ( user_name : option:: t < str > , rust_name : str ) -> str {
5436
- ret alt user_name {
5437
- some( n) { n }
5438
- none. { rust_name }
5439
- } ;
5440
- }
5441
-
5442
5435
let ccx = lcx_ccx ( lcx) ;
5443
5436
let cc: uint = lib:: llvm:: LLVMCCallConv ;
5444
5437
alt native_mod. abi {
@@ -5450,12 +5443,11 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
5450
5443
for native_item in native_mod. items {
5451
5444
alt native_item. node {
5452
5445
ast:: native_item_ty. { }
5453
- ast:: native_item_fn ( name , fn_decl, _) {
5446
+ ast:: native_item_fn ( fn_decl, _) {
5454
5447
let id = native_item. id ;
5455
5448
alt ccx. item_ids . find ( id) {
5456
5449
some ( llshimfn) {
5457
- let link_name = select_link_name ( name, native_item. ident ) ;
5458
- build_shim_fn ( lcx, link_name, native_item, llshimfn, cc) ;
5450
+ build_shim_fn ( lcx, native_item, llshimfn, cc) ;
5459
5451
}
5460
5452
5461
5453
none. {
@@ -5753,16 +5745,20 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, _path: [str], name: str,
5753
5745
5754
5746
fn item_path ( item : @ast:: item ) -> [ str ] { ret [ item. ident ] ; }
5755
5747
5748
+ fn link_name ( i : @ast:: native_item ) -> str {
5749
+ alt attr:: get_meta_item_value_str_by_name ( i. attrs , "link_name" ) {
5750
+ none. { ret i . ident ; }
5751
+ option:: some ( ln) { ret ln; }
5752
+ }
5753
+ }
5754
+
5755
+
5756
5756
fn collect_native_item ( ccx : @crate_ctxt , i : @ast:: native_item , & & pt: [ str ] ,
5757
5757
_v : vt < [ str ] > ) {
5758
5758
alt i. node {
5759
5759
ast:: native_item_fn ( _, _) {
5760
5760
if !ccx. obj_methods . contains_key ( i. id ) {
5761
- let name = i. ident ;
5762
- alt attr:: get_meta_item_value_str_by_name ( i. attrs , "link_name" ) {
5763
- none. { }
5764
- option:: some ( ln) { name = ln; }
5765
- }
5761
+ let name = link_name ( i) ;
5766
5762
register_native_fn ( ccx, i. span , pt, name, i. id ) ;
5767
5763
}
5768
5764
}
@@ -6163,6 +6159,5 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
6163
6159
// indent-tabs-mode: nil
6164
6160
// c-basic-offset: 4
6165
6161
// buffer-file-coding-system: utf-8-unix
6166
- // compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
6167
6162
// End:
6168
6163
//
0 commit comments