Skip to content

Commit 63ce813

Browse files
committed
---
yaml --- r: 6325 b: refs/heads/master c: 319f3b0 h: refs/heads/master i: 6323: 9839267 v: v3
1 parent 0bfce4f commit 63ce813

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: c572b793feb8ddf4900f76f4f5700e6d704826e9
2+
refs/heads/master: 319f3b02f3272ce5b58b04bc3d2abfc5b33991f0

trunk/src/comp/back/upcall.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import driver::session;
33
import middle::trans;
44
import middle::trans_common::{T_fn, T_i1, T_i8, T_i32,
5-
T_i64, T_int, T_nil,
5+
T_int, T_nil,
66
T_opaque_vec, T_ptr,
7-
T_size_t, T_void, T_float};
7+
T_size_t, T_void};
88
import lib::llvm::type_names;
99
import lib::llvm::llvm::ModuleRef;
1010
import lib::llvm::llvm::ValueRef;

trunk/src/comp/middle/trans.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import back::{link, abi, upcall};
2424
import syntax::{ast, ast_util};
2525
import syntax::visit;
2626
import syntax::codemap::span;
27-
import syntax::print::pprust::{expr_to_str, path_to_str, stmt_to_str};
27+
import syntax::print::pprust::{expr_to_str, stmt_to_str};
2828
import visit::vt;
2929
import util::common::*;
3030
import lib::llvm::{llvm, mk_target_data, mk_type_names};
@@ -5393,16 +5393,17 @@ fn c_stack_tys(ccx: @crate_ctxt,
53935393
// }
53945394
//
53955395
fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
5396-
fn build_shim_fn(lcx: @local_ctxt, native_item: @ast::native_item,
5396+
fn build_shim_fn(lcx: @local_ctxt,
5397+
link_name: str,
5398+
native_item: @ast::native_item,
53975399
llshimfn: ValueRef) {
53985400
let ccx = lcx_ccx(lcx);
53995401
let span = native_item.span;
54005402
let id = native_item.id;
54015403
let tys = c_stack_tys(ccx, span, id);
54025404

54035405
// Declare the "prototype" for the base function F:
5404-
let name = native_item.ident;
5405-
let llbasefn = decl_cdecl_fn(ccx.llmod, name, tys.base_fn_ty);
5406+
let llbasefn = decl_cdecl_fn(ccx.llmod, link_name, tys.base_fn_ty);
54065407

54075408
// Declare the body of the shim function:
54085409
let fcx = new_fn_ctxt(lcx, span, llshimfn);
@@ -5430,17 +5431,25 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) {
54305431
finish_fn(fcx, lltop);
54315432
}
54325433

5434+
fn select_link_name(user_name: option::t<str>, rust_name: str) -> str {
5435+
ret alt user_name {
5436+
some(n) { n }
5437+
none. { rust_name }
5438+
};
5439+
}
5440+
54335441
let ccx = lcx_ccx(lcx);
54345442
alt native_mod.abi {
54355443
ast::native_abi_cdecl. {
54365444
for native_item in native_mod.items {
54375445
alt native_item.node {
54385446
ast::native_item_ty. {}
5439-
ast::native_item_fn(_, fn_decl, _) {
5447+
ast::native_item_fn(name, fn_decl, _) {
54405448
let id = native_item.id;
54415449
alt ccx.item_ids.find(id) {
54425450
some(llshimfn) {
5443-
build_shim_fn(lcx, native_item, llshimfn);
5451+
let link_name = select_link_name(name, native_item.ident);
5452+
build_shim_fn(lcx, link_name, native_item, llshimfn);
54445453
}
54455454

54465455
none. {

trunk/src/comp/middle/trans_build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import lib::llvm::llvm;
44
import syntax::codemap::span;
55
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, Opcode,
66
ModuleRef};
7-
import trans_common::{block_ctxt, T_ptr, T_nil, T_int, T_i8, T_i1, T_void,
7+
import trans_common::{block_ctxt, T_ptr, T_nil, T_i8, T_i1, T_void,
88
T_fn, val_ty, bcx_ccx, C_i32};
99

1010
fn B(cx: @block_ctxt) -> BuilderRef {

0 commit comments

Comments
 (0)