Switch private linkage to local, re-indent trans.rs.

This commit is contained in:
Graydon Hoare 2011-04-01 15:01:46 -07:00
parent 3a8b0be1cb
commit 7d88e63ec8

View File

@ -161,7 +161,7 @@ fn sep() -> str {
} }
fn extend_path(@crate_ctxt cx, str name) -> @crate_ctxt { fn extend_path(@crate_ctxt cx, str name) -> @crate_ctxt {
ret @rec(path = cx.path + vec(name) with *cx); ret @rec(path = cx.path + vec(name) with *cx);
} }
fn path_name(vec[str] path) -> str { fn path_name(vec[str] path) -> str {
@ -529,7 +529,7 @@ fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef {
} }
fn type_of_explicit_args(@crate_ctxt cx, fn type_of_explicit_args(@crate_ctxt cx,
vec[ty.arg] inputs) -> vec[TypeRef] { vec[ty.arg] inputs) -> vec[TypeRef] {
let vec[TypeRef] atys = vec(); let vec[TypeRef] atys = vec();
for (ty.arg arg in inputs) { for (ty.arg arg in inputs) {
if (ty.type_has_dynamic_size(arg.ty)) { if (ty.type_has_dynamic_size(arg.ty)) {
@ -765,7 +765,7 @@ fn type_of_arg(@crate_ctxt cx, &ty.arg arg) -> TypeRef {
} }
fn type_of_ty_params_opt_and_ty(@crate_ctxt ccx, ty.ty_params_opt_and_ty tpt) fn type_of_ty_params_opt_and_ty(@crate_ctxt ccx, ty.ty_params_opt_and_ty tpt)
-> TypeRef { -> TypeRef {
alt (tpt._1.struct) { alt (tpt._1.struct) {
case (ty.ty_fn(?proto, ?inputs, ?output)) { case (ty.ty_fn(?proto, ?inputs, ?output)) {
auto ty_params = option.get[vec[ast.def_id]](tpt._0); auto ty_params = option.get[vec[ast.def_id]](tpt._0);
@ -859,7 +859,7 @@ fn C_cstr(@crate_ctxt cx, str s) -> ValueRef {
_str.buf(cx.names.next("str"))); _str.buf(cx.names.next("str")));
llvm.LLVMSetInitializer(g, sc); llvm.LLVMSetInitializer(g, sc);
llvm.LLVMSetGlobalConstant(g, True); llvm.LLVMSetGlobalConstant(g, True);
llvm.LLVMSetLinkage(g, lib.llvm.LLVMPrivateLinkage llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
as llvm.Linkage); as llvm.Linkage);
ret g; ret g;
} }
@ -876,7 +876,7 @@ fn C_str(@crate_ctxt cx, str s) -> ValueRef {
_str.buf(cx.names.next("str"))); _str.buf(cx.names.next("str")));
llvm.LLVMSetInitializer(g, box); llvm.LLVMSetInitializer(g, box);
llvm.LLVMSetGlobalConstant(g, True); llvm.LLVMSetGlobalConstant(g, True);
llvm.LLVMSetLinkage(g, lib.llvm.LLVMPrivateLinkage llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
as llvm.Linkage); as llvm.Linkage);
ret llvm.LLVMConstPointerCast(g, T_ptr(T_str())); ret llvm.LLVMConstPointerCast(g, T_ptr(T_str()));
} }
@ -913,10 +913,10 @@ fn decl_fastcall_fn(ModuleRef llmod, str name, TypeRef llty) -> ValueRef {
ret decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty); ret decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty);
} }
fn decl_private_fastcall_fn(ModuleRef llmod, fn decl_internal_fastcall_fn(ModuleRef llmod,
str name, TypeRef llty) -> ValueRef { str name, TypeRef llty) -> ValueRef {
auto llfn = decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty); auto llfn = decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty);
llvm.LLVMSetLinkage(llfn, lib.llvm.LLVMPrivateLinkage as llvm.Linkage); llvm.LLVMSetLinkage(llfn, lib.llvm.LLVMInternalLinkage as llvm.Linkage);
ret llfn; ret llfn;
} }
@ -963,7 +963,7 @@ fn get_extern_const(&hashmap[str, ValueRef] externs,
} }
fn get_simple_extern_fn(&hashmap[str, ValueRef] externs, fn get_simple_extern_fn(&hashmap[str, ValueRef] externs,
ModuleRef llmod, str name, int n_args) -> ValueRef { ModuleRef llmod, str name, int n_args) -> ValueRef {
auto inputs = _vec.init_elt[TypeRef](T_int(), n_args as uint); auto inputs = _vec.init_elt[TypeRef](T_int(), n_args as uint);
auto output = T_int(); auto output = T_int();
auto t = T_fn(inputs, output); auto t = T_fn(inputs, output);
@ -1361,7 +1361,7 @@ fn GEP_tag(@block_ctxt cx,
&ast.def_id variant_id, &ast.def_id variant_id,
vec[@ty.t] ty_substs, vec[@ty.t] ty_substs,
int ix) int ix)
-> result { -> result {
auto ty_params = tag_ty_params(cx.fcx.ccx, tag_id); auto ty_params = tag_ty_params(cx.fcx.ccx, tag_id);
auto variant = tag_variant_with_id(cx.fcx.ccx, tag_id, variant_id); auto variant = tag_variant_with_id(cx.fcx.ccx, tag_id, variant_id);
@ -1410,7 +1410,7 @@ fn GEP_tag(@block_ctxt cx,
fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize) fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
-> result { -> result {
// FIXME: need a table to collect tydesc globals. // FIXME: need a table to collect tydesc globals.
auto tydesc = C_int(0); auto tydesc = C_int(0);
auto rslt = trans_upcall(cx, "upcall_malloc", vec(llsize, tydesc)); auto rslt = trans_upcall(cx, "upcall_malloc", vec(llsize, tydesc));
@ -1596,14 +1596,14 @@ fn declare_tydesc(@crate_ctxt cx, @ty.t t) {
llvm.LLVMSetInitializer(gvar, tydesc); llvm.LLVMSetInitializer(gvar, tydesc);
llvm.LLVMSetGlobalConstant(gvar, True); llvm.LLVMSetGlobalConstant(gvar, True);
llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMPrivateLinkage llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage
as llvm.Linkage); as llvm.Linkage);
auto info = rec( auto info = rec(
tydesc=gvar, tydesc=gvar,
take_glue=take_glue, take_glue=take_glue,
drop_glue=drop_glue drop_glue=drop_glue
); );
cx.tydescs.insert(t, @info); cx.tydescs.insert(t, @info);
} }
@ -1627,7 +1627,7 @@ fn declare_generic_glue(@crate_ctxt cx, @ty.t t, str name) -> ValueRef {
auto gcx = @rec(path=vec("glue", name) with *cx); auto gcx = @rec(path=vec("glue", name) with *cx);
auto fn_name = mangle_name_by_type(gcx, t); auto fn_name = mangle_name_by_type(gcx, t);
fn_name = sanitize(fn_name); fn_name = sanitize(fn_name);
auto llfn = decl_private_fastcall_fn(cx.llmod, fn_name, llfnty); auto llfn = decl_internal_fastcall_fn(cx.llmod, fn_name, llfnty);
ret llfn; ret llfn;
} }
@ -2098,17 +2098,17 @@ fn iter_structural_ty_full(@block_ctxt cx,
auto v = vec(C_int(0), C_int(j as int)); auto v = vec(C_int(0), C_int(j as int));
auto rslt = GEP_tag(variant_cx, llunion_a_ptr, auto rslt = GEP_tag(variant_cx, llunion_a_ptr,
tid, variant.id, tps, j); tid, variant.id, tps, j);
auto llfldp_a = rslt.val; auto llfldp_a = rslt.val;
variant_cx = rslt.bcx; variant_cx = rslt.bcx;
rslt = GEP_tag(variant_cx, llunion_b_ptr, tid, rslt = GEP_tag(variant_cx, llunion_b_ptr, tid,
variant.id, tps, j); variant.id, tps, j);
auto llfldp_b = rslt.val; auto llfldp_b = rslt.val;
variant_cx = rslt.bcx; variant_cx = rslt.bcx;
auto ty_subst = ty.substitute_ty_params( auto ty_subst = ty.substitute_ty_params(
ty_params, tps, a.ty); ty_params, tps, a.ty);
auto llfld_a = auto llfld_a =
load_scalar_or_boxed(variant_cx, load_scalar_or_boxed(variant_cx,
@ -2330,8 +2330,8 @@ fn call_tydesc_glue(@block_ctxt cx, ValueRef v, @ty.t t, int field) {
} }
fn take_ty(@block_ctxt cx, fn take_ty(@block_ctxt cx,
ValueRef v, ValueRef v,
@ty.t t) -> result { @ty.t t) -> result {
if (!ty.type_is_scalar(t)) { if (!ty.type_is_scalar(t)) {
call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue_off); call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue_off);
} }
@ -3163,11 +3163,11 @@ fn trans_for(@block_ctxt cx,
// Searches through a block for all references to locals or upvars in this // Searches through a block for all references to locals or upvars in this
// frame and returns the list of definition IDs thus found. // frame and returns the list of definition IDs thus found.
fn collect_upvars(@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl) fn collect_upvars(@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
-> vec[ast.def_id] { -> vec[ast.def_id] {
type env = @rec( type env = @rec(
mutable vec[ast.def_id] refs, mutable vec[ast.def_id] refs,
hashmap[ast.def_id,()] decls hashmap[ast.def_id,()] decls
); );
fn fold_expr_path(&env e, &common.span sp, &ast.path p, fn fold_expr_path(&env e, &common.span sp, &ast.path p,
&option.t[ast.def] d, ast.ann a) -> @ast.expr { &option.t[ast.def] d, ast.ann a) -> @ast.expr {
@ -3182,7 +3182,7 @@ fn collect_upvars(@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
} }
fn fold_decl_local(&env e, &common.span sp, @ast.local local) fn fold_decl_local(&env e, &common.span sp, @ast.local local)
-> @ast.decl { -> @ast.decl {
e.decls.insert(local.id, ()); e.decls.insert(local.id, ());
ret @fold.respan[ast.decl_](sp, ast.decl_local(local)); ret @fold.respan[ast.decl_](sp, ast.decl_local(local));
} }
@ -3190,10 +3190,10 @@ fn collect_upvars(@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
auto fep = fold_expr_path; auto fep = fold_expr_path;
auto fdl = fold_decl_local; auto fdl = fold_decl_local;
auto fld = @rec( auto fld = @rec(
fold_expr_path=fep, fold_expr_path=fep,
fold_decl_local=fdl fold_decl_local=fdl
with *fold.new_identity_fold[env]() with *fold.new_identity_fold[env]()
); );
let vec[ast.def_id] refs = vec(); let vec[ast.def_id] refs = vec();
let hashmap[ast.def_id,()] decls = new_def_hash[()](); let hashmap[ast.def_id,()] decls = new_def_hash[()]();
@ -3319,8 +3319,8 @@ fn trans_for_each(@block_ctxt cx,
vec(rec(mode=ast.val, ty=decl_ty)), vec(rec(mode=ast.val, ty=decl_ty)),
plain_ty(ty.ty_nil), 0u); plain_ty(ty.ty_nil), 0u);
let ValueRef lliterbody = decl_private_fastcall_fn(cx.fcx.ccx.llmod, let ValueRef lliterbody = decl_internal_fastcall_fn(cx.fcx.ccx.llmod,
s, iter_body_llty); s, iter_body_llty);
// FIXME: handle ty params properly. // FIXME: handle ty params properly.
let vec[ast.ty_param] ty_params = vec(); let vec[ast.ty_param] ty_params = vec();
@ -3332,7 +3332,7 @@ fn trans_for_each(@block_ctxt cx,
// Populate the upvars from the environment. // Populate the upvars from the environment.
auto llremoteenvptr = bcx.build.PointerCast(fcx.llenv, llenvptrty); auto llremoteenvptr = bcx.build.PointerCast(fcx.llenv, llenvptrty);
auto llremotebindingsptrptr = bcx.build.GEP(llremoteenvptr, auto llremotebindingsptrptr = bcx.build.GEP(llremoteenvptr,
vec(C_int(0), C_int(abi.box_rc_field_body), C_int(2))); vec(C_int(0), C_int(abi.box_rc_field_body), C_int(2)));
auto llremotebindingsptr = bcx.build.Load(llremotebindingsptrptr); auto llremotebindingsptr = bcx.build.Load(llremotebindingsptrptr);
auto i = 0u; auto i = 0u;
@ -3377,7 +3377,7 @@ fn trans_for_each(@block_ctxt cx,
auto env_cell = cx.build.GEP(pair, vec(C_int(0), auto env_cell = cx.build.GEP(pair, vec(C_int(0),
C_int(abi.fn_field_box))); C_int(abi.fn_field_box)));
auto llenvblobptr = cx.build.PointerCast(llenvptr, auto llenvblobptr = cx.build.PointerCast(llenvptr,
T_opaque_closure_ptr(cx.fcx.ccx.tn)); T_opaque_closure_ptr(cx.fcx.ccx.tn));
cx.build.Store(llenvblobptr, env_cell); cx.build.Store(llenvblobptr, env_cell);
// log "lliterbody: " + val_str(cx.fcx.ccx.tn, lliterbody); // log "lliterbody: " + val_str(cx.fcx.ccx.tn, lliterbody);
@ -3448,7 +3448,7 @@ fn trans_pat_match(@block_ctxt cx, @ast.pat pat, ValueRef llval,
case (ast.pat_tag(?id, ?subpats, ?vdef_opt, ?ann)) { case (ast.pat_tag(?id, ?subpats, ?vdef_opt, ?ann)) {
auto lltagptr = cx.build.PointerCast(llval, auto lltagptr = cx.build.PointerCast(llval,
T_opaque_tag_ptr(cx.fcx.ccx.tn)); T_opaque_tag_ptr(cx.fcx.ccx.tn));
auto lldiscrimptr = cx.build.GEP(lltagptr, auto lldiscrimptr = cx.build.GEP(lltagptr,
vec(C_int(0), C_int(0))); vec(C_int(0), C_int(0)));
@ -3479,7 +3479,7 @@ fn trans_pat_match(@block_ctxt cx, @ast.pat pat, ValueRef llval,
if (_vec.len[@ast.pat](subpats) > 0u) { if (_vec.len[@ast.pat](subpats) > 0u) {
auto llblobptr = matched_cx.build.GEP(lltagptr, auto llblobptr = matched_cx.build.GEP(lltagptr,
vec(C_int(0), C_int(1))); vec(C_int(0), C_int(1)));
auto i = 0; auto i = 0;
for (@ast.pat subpat in subpats) { for (@ast.pat subpat in subpats) {
auto rslt = GEP_tag(matched_cx, llblobptr, vdef._0, auto rslt = GEP_tag(matched_cx, llblobptr, vdef._0,
@ -3529,7 +3529,7 @@ fn trans_pat_binding(@block_ctxt cx, @ast.pat pat, ValueRef llval)
auto vdef = option.get[ast.variant_def](vdef_opt); auto vdef = option.get[ast.variant_def](vdef_opt);
auto lltagptr = cx.build.PointerCast(llval, auto lltagptr = cx.build.PointerCast(llval,
T_opaque_tag_ptr(cx.fcx.ccx.tn)); T_opaque_tag_ptr(cx.fcx.ccx.tn));
auto llblobptr = cx.build.GEP(lltagptr, vec(C_int(0), C_int(1))); auto llblobptr = cx.build.GEP(lltagptr, vec(C_int(0), C_int(1)));
auto ty_param_substs = node_ann_ty_params(ann); auto ty_param_substs = node_ann_ty_params(ann);
@ -3625,7 +3625,7 @@ fn lval_generic_fn(@block_ctxt cx,
ty.ty_params_and_ty tpt, ty.ty_params_and_ty tpt,
ast.def_id fn_id, ast.def_id fn_id,
&ast.ann ann) &ast.ann ann)
-> lval_result { -> lval_result {
auto lv; auto lv;
if (cx.fcx.ccx.sess.get_targ_crate_num() == fn_id._0) { if (cx.fcx.ccx.sess.get_targ_crate_num() == fn_id._0) {
// Internal reference. // Internal reference.
@ -3704,12 +3704,12 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
} }
case (ast.def_fn(?did)) { case (ast.def_fn(?did)) {
auto tyt = ty.lookup_generic_item_type(cx.fcx.ccx.sess, auto tyt = ty.lookup_generic_item_type(cx.fcx.ccx.sess,
cx.fcx.ccx.type_cache, did); cx.fcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann); ret lval_generic_fn(cx, tyt, did, ann);
} }
case (ast.def_obj(?did)) { case (ast.def_obj(?did)) {
auto tyt = ty.lookup_generic_item_type(cx.fcx.ccx.sess, auto tyt = ty.lookup_generic_item_type(cx.fcx.ccx.sess,
cx.fcx.ccx.type_cache, did); cx.fcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann); ret lval_generic_fn(cx, tyt, did, ann);
} }
case (ast.def_variant(?tid, ?vid)) { case (ast.def_variant(?tid, ?vid)) {
@ -3746,10 +3746,10 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
lltagty = type_of(cx.fcx.ccx, tag_ty); lltagty = type_of(cx.fcx.ccx, tag_ty);
} }
auto lltagptr = alloc_result.bcx.build.PointerCast( auto lltagptr = alloc_result.bcx.build.PointerCast(
lltagblob, T_ptr(lltagty)); lltagblob, T_ptr(lltagty));
auto lldiscrimptr = alloc_result.bcx.build.GEP( auto lldiscrimptr = alloc_result.bcx.build.GEP(
lltagptr, vec(C_int(0), C_int(0))); lltagptr, vec(C_int(0), C_int(0)));
alloc_result.bcx.build.Store(lldiscrim, lldiscrimptr); alloc_result.bcx.build.Store(lldiscrim, lldiscrimptr);
ret lval_val(alloc_result.bcx, lltagptr); ret lval_val(alloc_result.bcx, lltagptr);
@ -3762,7 +3762,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
} }
case (ast.def_native_fn(?did)) { case (ast.def_native_fn(?did)) {
auto tyt = ty.lookup_generic_item_type(cx.fcx.ccx.sess, auto tyt = ty.lookup_generic_item_type(cx.fcx.ccx.sess,
cx.fcx.ccx.type_cache, did); cx.fcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann); ret lval_generic_fn(cx, tyt, did, ann);
} }
case (_) { case (_) {
@ -3898,7 +3898,7 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
} else if (ty.type_is_native(t)) { } else if (ty.type_is_native(t)) {
e_res.val = e_res.bcx.build.IntToPtr(e_res.val, lldsttype); e_res.val = e_res.bcx.build.IntToPtr(e_res.val, lldsttype);
} else if (llvm.LLVMGetIntTypeWidth(lldsttype) > } else if (llvm.LLVMGetIntTypeWidth(lldsttype) >
llvm.LLVMGetIntTypeWidth(llsrctype)) { llvm.LLVMGetIntTypeWidth(llsrctype)) {
if (ty.type_is_signed(t)) { if (ty.type_is_signed(t)) {
// Widening signed cast. // Widening signed cast.
e_res.val = e_res.val =
@ -3934,7 +3934,7 @@ fn trans_bind_thunk(@crate_ctxt cx,
let str s = mangle_name_by_seq(cx, "thunk"); let str s = mangle_name_by_seq(cx, "thunk");
let TypeRef llthunk_ty = get_pair_fn_ty(type_of(cx, incoming_fty)); let TypeRef llthunk_ty = get_pair_fn_ty(type_of(cx, incoming_fty));
let ValueRef llthunk = decl_private_fastcall_fn(cx.llmod, s, llthunk_ty); let ValueRef llthunk = decl_internal_fastcall_fn(cx.llmod, s, llthunk_ty);
auto fcx = new_fn_ctxt(cx, llthunk); auto fcx = new_fn_ctxt(cx, llthunk);
auto bcx = new_top_block_ctxt(fcx); auto bcx = new_top_block_ctxt(fcx);
@ -4435,11 +4435,11 @@ fn trans_call(@block_ctxt cx, @ast.expr f,
auto llretslot = args_res._2; auto llretslot = args_res._2;
/* /*
log "calling: " + val_str(cx.fcx.ccx.tn, faddr); log "calling: " + val_str(cx.fcx.ccx.tn, faddr);
for (ValueRef arg in llargs) { for (ValueRef arg in llargs) {
log "arg: " + val_str(cx.fcx.ccx.tn, arg); log "arg: " + val_str(cx.fcx.ccx.tn, arg);
} }
*/ */
bcx.build.FastCall(faddr, llargs); bcx.build.FastCall(faddr, llargs);
@ -4499,11 +4499,11 @@ fn trans_call_self(@block_ctxt cx, @ast.expr f,
auto llretslot = args_res._2; auto llretslot = args_res._2;
/* /*
log "calling: " + val_str(cx.fcx.ccx.tn, faddr); log "calling: " + val_str(cx.fcx.ccx.tn, faddr);
for (ValueRef arg in llargs) { for (ValueRef arg in llargs) {
log "arg: " + val_str(cx.fcx.ccx.tn, arg); log "arg: " + val_str(cx.fcx.ccx.tn, arg);
} }
*/ */
bcx.build.FastCall(faddr, llargs); bcx.build.FastCall(faddr, llargs);
@ -5152,7 +5152,7 @@ fn trans_recv(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs,
// FIXME: calculate copy init-ness in typestate. // FIXME: calculate copy init-ness in typestate.
ret recv_val(bcx, data.res.val, rhs, unit_ty, DROP_EXISTING); ret recv_val(bcx, data.res.val, rhs, unit_ty, DROP_EXISTING);
} }
fn recv_val(@block_ctxt cx, ValueRef lhs, @ast.expr rhs, fn recv_val(@block_ctxt cx, ValueRef lhs, @ast.expr rhs,
@ty.t unit_ty, copy_action action) -> result { @ty.t unit_ty, copy_action action) -> result {
@ -5629,14 +5629,14 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, ValueRef llself) {
box_ptr = bcx.build.PointerCast(box_ptr, llobj_box_ty); box_ptr = bcx.build.PointerCast(box_ptr, llobj_box_ty);
auto obj_typarams = bcx.build.GEP(box_ptr, auto obj_typarams = bcx.build.GEP(box_ptr,
vec(C_int(0), vec(C_int(0),
C_int(abi.box_rc_field_body), C_int(abi.box_rc_field_body),
C_int(abi.obj_body_elt_typarams))); C_int(abi.obj_body_elt_typarams)));
// The object fields immediately follow the type parameters, so we skip // The object fields immediately follow the type parameters, so we skip
// over them to get the pointer. // over them to get the pointer.
auto obj_fields = bcx.build.Add(vp2i(bcx, obj_typarams), auto obj_fields = bcx.build.Add(vp2i(bcx, obj_typarams),
llsize_of(llvm.LLVMGetElementType(val_ty(obj_typarams)))); llsize_of(llvm.LLVMGetElementType(val_ty(obj_typarams))));
// If we can (i.e. the type is statically sized), then cast the resulting // If we can (i.e. the type is statically sized), then cast the resulting
// fields pointer to the appropriate LLVM type. If not, just leave it as // fields pointer to the appropriate LLVM type. If not, just leave it as
@ -5735,7 +5735,7 @@ fn trans_vtbl(@crate_ctxt cx, TypeRef self_ty,
let @crate_ctxt mcx = extend_path(cx, m.node.ident); let @crate_ctxt mcx = extend_path(cx, m.node.ident);
let str s = mangle_name_by_seq(mcx, "method"); let str s = mangle_name_by_seq(mcx, "method");
let ValueRef llfn = decl_private_fastcall_fn(cx.llmod, s, llfnty); let ValueRef llfn = decl_internal_fastcall_fn(cx.llmod, s, llfnty);
cx.item_ids.insert(m.node.id, llfn); cx.item_ids.insert(m.node.id, llfn);
cx.item_symbols.insert(m.node.id, s); cx.item_symbols.insert(m.node.id, s);
@ -5749,7 +5749,7 @@ fn trans_vtbl(@crate_ctxt cx, TypeRef self_ty,
_str.buf(vtbl_name)); _str.buf(vtbl_name));
llvm.LLVMSetInitializer(gvar, vtbl); llvm.LLVMSetInitializer(gvar, vtbl);
llvm.LLVMSetGlobalConstant(gvar, True); llvm.LLVMSetGlobalConstant(gvar, True);
llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMPrivateLinkage llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage
as llvm.Linkage); as llvm.Linkage);
ret gvar; ret gvar;
} }
@ -5938,12 +5938,12 @@ fn trans_tag_variant(@crate_ctxt cx, ast.def_id tag_id,
// this function as an opaque blob due to the way that type_of() // this function as an opaque blob due to the way that type_of()
// works. So we have to cast to the destination's view of the type. // works. So we have to cast to the destination's view of the type.
auto llargptr = bcx.build.PointerCast(fcx.llargs.get(va.id), auto llargptr = bcx.build.PointerCast(fcx.llargs.get(va.id),
val_ty(lldestptr)); val_ty(lldestptr));
auto arg_ty = arg_tys.(i).ty; auto arg_ty = arg_tys.(i).ty;
auto llargval; auto llargval;
if (ty.type_is_structural(arg_ty) || if (ty.type_is_structural(arg_ty) ||
ty.type_has_dynamic_size(arg_ty)) { ty.type_has_dynamic_size(arg_ty)) {
llargval = llargptr; llargval = llargptr;
} else { } else {
llargval = bcx.build.Load(llargptr); llargval = bcx.build.Load(llargptr);
@ -6054,7 +6054,7 @@ fn decl_fn_and_pair(@crate_ctxt cx,
// Declare the function itself. // Declare the function itself.
let str s = mangle_name_by_seq(cx, flav); let str s = mangle_name_by_seq(cx, flav);
let ValueRef llfn = decl_private_fastcall_fn(cx.llmod, s, llfty); let ValueRef llfn = decl_internal_fastcall_fn(cx.llmod, s, llfty);
// Declare the global constant pair that points to it. // Declare the global constant pair that points to it.
let str ps = mangle_name_by_type(cx, node_ann_type(cx, ann)); let str ps = mangle_name_by_type(cx, node_ann_type(cx, ann));
@ -6098,7 +6098,7 @@ fn native_fn_ty_param_count(@crate_ctxt cx, &ast.def_id id) -> uint {
} }
fn native_fn_wrapper_type(@crate_ctxt cx, uint ty_param_count, &ast.ann ann) fn native_fn_wrapper_type(@crate_ctxt cx, uint ty_param_count, &ast.ann ann)
-> TypeRef { -> TypeRef {
auto x = node_ann_type(cx, ann); auto x = node_ann_type(cx, ann);
alt (x.struct) { alt (x.struct) {
case (ty.ty_native_fn(?abi, ?args, ?out)) { case (ty.ty_native_fn(?abi, ?args, ?out)) {
@ -6117,8 +6117,8 @@ fn decl_native_fn_and_pair(@crate_ctxt cx,
// Declare the wrapper. // Declare the wrapper.
auto wrapper_type = native_fn_wrapper_type(cx, num_ty_param, ann); auto wrapper_type = native_fn_wrapper_type(cx, num_ty_param, ann);
let str s = mangle_name_by_seq(cx, "wrapper"); let str s = mangle_name_by_seq(cx, "wrapper");
let ValueRef wrapper_fn = decl_private_fastcall_fn(cx.llmod, s, let ValueRef wrapper_fn = decl_internal_fastcall_fn(cx.llmod, s,
wrapper_type); wrapper_type);
// Declare the global constant pair that points to it. // Declare the global constant pair that points to it.
auto wrapper_pair_type = T_fn_pair(cx.tn, wrapper_type); auto wrapper_pair_type = T_fn_pair(cx.tn, wrapper_type);
@ -6248,7 +6248,7 @@ fn collect_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
auto typ = node_ann_type(cx, ann); auto typ = node_ann_type(cx, ann);
auto g = llvm.LLVMAddGlobal(cx.llmod, type_of(cx, typ), auto g = llvm.LLVMAddGlobal(cx.llmod, type_of(cx, typ),
_str.buf(cx.names.next(name))); _str.buf(cx.names.next(name)));
llvm.LLVMSetLinkage(g, lib.llvm.LLVMPrivateLinkage llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
as llvm.Linkage); as llvm.Linkage);
cx.items.insert(cid, i); cx.items.insert(cid, i);
cx.consts.insert(cid, g); cx.consts.insert(cid, g);
@ -6378,7 +6378,7 @@ fn trans_constant(&@crate_ctxt cx, @ast.item it) -> @crate_ctxt {
// to figure out what name they get first! // to figure out what name they get first!
llvm.LLVMSetInitializer(discrim_gvar, discrim_val); llvm.LLVMSetInitializer(discrim_gvar, discrim_val);
llvm.LLVMSetGlobalConstant(discrim_gvar, True); llvm.LLVMSetGlobalConstant(discrim_gvar, True);
llvm.LLVMSetLinkage(discrim_gvar, lib.llvm.LLVMPrivateLinkage llvm.LLVMSetLinkage(discrim_gvar, lib.llvm.LLVMInternalLinkage
as llvm.Linkage); as llvm.Linkage);
cx.discrims.insert(variant.node.id, discrim_gvar); cx.discrims.insert(variant.node.id, discrim_gvar);
@ -6873,7 +6873,7 @@ fn trans_vec_append_glue(@crate_ctxt cx) {
put_vec_fill(copy_src_cx, llnew_vec, put_vec_fill(copy_src_cx, llnew_vec,
copy_src_cx.build.Add(vec_fill(copy_src_cx, copy_src_cx.build.Add(vec_fill(copy_src_cx,
llnew_vec), llnew_vec),
n_bytes)); n_bytes));
// Write new_vec back through the alias we were given. // Write new_vec back through the alias we were given.
copy_src_cx.build.Store(llnew_vec, lldst_vec_ptr); copy_src_cx.build.Store(llnew_vec, lldst_vec_ptr);