auto merge of #4795 : catamorphism/rust/less-copy, r=catamorphism
This commit is contained in:
commit
f13ea4121e
2 changed files with 16 additions and 14 deletions
|
@ -137,7 +137,7 @@ pub fn log_fn_time(ccx: @crate_ctxt, +name: ~str, start: time::Timespec,
|
|||
ccx.stats.fn_times.push({ident: name, time: elapsed});
|
||||
}
|
||||
|
||||
pub fn decl_fn(llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv,
|
||||
pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
|
||||
llty: TypeRef) -> ValueRef {
|
||||
let llfn: ValueRef = str::as_c_str(name, |buf| {
|
||||
unsafe {
|
||||
|
@ -150,7 +150,7 @@ pub fn decl_fn(llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv,
|
|||
return llfn;
|
||||
}
|
||||
|
||||
pub fn decl_cdecl_fn(llmod: ModuleRef, +name: ~str, llty: TypeRef)
|
||||
pub fn decl_cdecl_fn(llmod: ModuleRef, name: &str, llty: TypeRef)
|
||||
-> ValueRef {
|
||||
return decl_fn(llmod, name, lib::llvm::CCallConv, llty);
|
||||
}
|
||||
|
@ -164,20 +164,19 @@ pub fn decl_internal_cdecl_fn(llmod: ModuleRef, +name: ~str, llty: TypeRef) ->
|
|||
return llfn;
|
||||
}
|
||||
|
||||
pub fn get_extern_fn(externs: HashMap<~str, ValueRef>,
|
||||
pub fn get_extern_fn(externs: ExternMap,
|
||||
llmod: ModuleRef,
|
||||
+name: ~str,
|
||||
name: @str,
|
||||
cc: lib::llvm::CallConv,
|
||||
ty: TypeRef) -> ValueRef {
|
||||
if externs.contains_key_ref(&name) { return externs.get(&name); }
|
||||
// XXX: Bad copy.
|
||||
let f = decl_fn(llmod, copy name, cc, ty);
|
||||
let f = decl_fn(llmod, name, cc, ty);
|
||||
externs.insert(name, f);
|
||||
return f;
|
||||
}
|
||||
|
||||
pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef,
|
||||
+name: ~str, ty: TypeRef) -> ValueRef {
|
||||
pub fn get_extern_const(externs: ExternMap, llmod: ModuleRef,
|
||||
name: @str, ty: TypeRef) -> ValueRef {
|
||||
unsafe {
|
||||
if externs.contains_key_ref(&name) { return externs.get(&name); }
|
||||
let c = str::as_c_str(name, |buf| {
|
||||
|
@ -189,9 +188,9 @@ pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef,
|
|||
}
|
||||
|
||||
fn get_simple_extern_fn(cx: block,
|
||||
externs: HashMap<~str, ValueRef>,
|
||||
externs: ExternMap,
|
||||
llmod: ModuleRef,
|
||||
+name: ~str,
|
||||
name: @str,
|
||||
n_args: int) -> ValueRef {
|
||||
let _icx = cx.insn_ctxt("get_simple_extern_fn");
|
||||
let ccx = cx.fcx.ccx;
|
||||
|
@ -201,8 +200,8 @@ pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef,
|
|||
return get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t);
|
||||
}
|
||||
|
||||
pub fn trans_foreign_call(cx: block, externs: HashMap<~str, ValueRef>,
|
||||
llmod: ModuleRef, +name: ~str, args: ~[ValueRef]) ->
|
||||
pub fn trans_foreign_call(cx: block, externs: ExternMap,
|
||||
llmod: ModuleRef, name: @str, args: ~[ValueRef]) ->
|
||||
ValueRef {
|
||||
let _icx = cx.insn_ctxt("trans_foreign_call");
|
||||
let n = args.len() as int;
|
||||
|
@ -474,6 +473,7 @@ pub fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id,
|
|||
let class_ty = ty::subst_tps(tcx, substs, None,
|
||||
ty::lookup_item_type(tcx, parent_id).ty);
|
||||
let llty = type_of_dtor(ccx, class_ty);
|
||||
let name = name.to_managed(); // :-(
|
||||
get_extern_fn(ccx.externs, ccx.llmod, name, lib::llvm::CCallConv,
|
||||
llty)
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ pub fn null_env_ptr(bcx: block) -> ValueRef {
|
|||
|
||||
pub fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t)
|
||||
-> ValueRef {
|
||||
let name = csearch::get_symbol(ccx.sess.cstore, did);
|
||||
let name = csearch::get_symbol(ccx.sess.cstore, did).to_managed(); // Sad
|
||||
match ty::get(t).sty {
|
||||
ty::ty_fn(_) => {
|
||||
let llty = type_of_fn_from_ty(ccx, t);
|
||||
|
|
|
@ -152,13 +152,15 @@ pub fn BuilderRef_res(B: BuilderRef) -> BuilderRef_res {
|
|||
}
|
||||
}
|
||||
|
||||
type ExternMap = HashMap<@str, ValueRef>;
|
||||
|
||||
// Crate context. Every crate we compile has one of these.
|
||||
pub struct crate_ctxt {
|
||||
sess: session::Session,
|
||||
llmod: ModuleRef,
|
||||
td: target_data,
|
||||
tn: type_names,
|
||||
externs: HashMap<~str, ValueRef>,
|
||||
externs: ExternMap,
|
||||
intrinsics: HashMap<~str, ValueRef>,
|
||||
item_vals: HashMap<ast::node_id, ValueRef>,
|
||||
exp_map2: resolve::ExportMap2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue