Skip to content

Commit fae4d65

Browse files
committed
---
yaml --- r: 139773 b: refs/heads/try2 c: 04b2c26 h: refs/heads/master i: 139771: 1cd2f1b v: v3
1 parent e2b20ee commit fae4d65

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2589eba957ee5632dc9060022b5ca09cbfb782f9
8+
refs/heads/try2: 04b2c26f39782ba30ad8868f971d5d8a606fcf88
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/reflect.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -275,26 +275,27 @@ pub impl Reflector {
275275
let variants = ty::substd_enum_variants(ccx.tcx, did, substs);
276276
let llptrty = T_ptr(type_of(ccx, t));
277277

278-
// Build the get_disr function. (XXX: break this out into a function)
279-
let sub_path = bcx.fcx.path + ~[path_name(special_idents::anon)];
280-
let get_disr_sym = mangle_internal_name_by_path_and_seq(ccx, sub_path, ~"get_disr");
281-
let get_disr_args = [ty::arg { mode: ast::expl(ast::by_copy),
282-
ty: ty::mk_nil_ptr(ccx.tcx) }];
283-
let get_disr_llfty = type_of_fn(ccx, get_disr_args, ty::mk_int(ccx.tcx));
284-
let get_disr_llfdecl = decl_internal_cdecl_fn(ccx.llmod, get_disr_sym, get_disr_llfty);
285-
let get_disr_arg = unsafe {
286-
llvm::LLVMGetParam(get_disr_llfdecl, first_real_arg as c_uint)
278+
let make_get_disr = || {
279+
let sub_path = bcx.fcx.path + ~[path_name(special_idents::anon)];
280+
let sym = mangle_internal_name_by_path_and_seq(ccx, sub_path, ~"get_disr");
281+
let args = [ty::arg { mode: ast::expl(ast::by_copy),
282+
ty: ty::mk_nil_ptr(ccx.tcx) }];
283+
let llfty = type_of_fn(ccx, args, ty::mk_int(ccx.tcx));
284+
let llfdecl = decl_internal_cdecl_fn(ccx.llmod, sym, llfty);
285+
let arg = unsafe {
286+
llvm::LLVMGetParam(llfdecl, first_real_arg as c_uint)
287+
};
288+
let fcx = new_fn_ctxt(ccx, ~[], llfdecl, None);
289+
let bcx = top_scope_block(fcx, None);
290+
let arg = BitCast(bcx, arg, llptrty);
291+
let ret = adt::trans_get_discr(bcx, repr, arg);
292+
Store(bcx, ret, fcx.llretptr);
293+
cleanup_and_Br(bcx, bcx, fcx.llreturn);
294+
finish_fn(fcx, bcx.llbb);
295+
llfdecl
287296
};
288-
let get_disr_fcx = new_fn_ctxt(ccx, ~[], get_disr_llfdecl, None);
289-
let get_disr_bcx = top_scope_block(get_disr_fcx, None);
290-
let get_disr_arg = BitCast(get_disr_bcx, get_disr_arg, llptrty);
291-
let get_disr_ret = adt::trans_get_discr(get_disr_bcx, repr, get_disr_arg);
292-
Store(get_disr_bcx, get_disr_ret, get_disr_fcx.llretptr);
293-
cleanup_and_Br(get_disr_bcx, get_disr_bcx, get_disr_fcx.llreturn);
294-
finish_fn(get_disr_fcx, get_disr_bcx.llbb);
295297

296-
let enum_args = ~[self.c_uint(vec::len(variants)),
297-
get_disr_llfdecl]
298+
let enum_args = ~[self.c_uint(vec::len(variants)), make_get_disr()]
298299
+ self.c_size_and_align(t);
299300
do self.bracketed(~"enum", enum_args) |this| {
300301
for variants.eachi |i, v| {

0 commit comments

Comments
 (0)