Skip to content

Commit b166aa0

Browse files
committed
---
yaml --- r: 1451 b: refs/heads/master c: 86309ed h: refs/heads/master i: 1449: e3c7ec1 1447: 28a4c4c v: v3
1 parent ce55116 commit b166aa0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
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: a172f5aef5f7d26fba9dbf94a1ade60d6d62ba74
2+
refs/heads/master: 86309ed3ea896473641c9cdeadf16b02931b8ac8

trunk/src/comp/middle/trans.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4609,12 +4609,26 @@ fn trans_constant(&@crate_ctxt cx, @ast.item it) -> @crate_ctxt {
46094609
auto n_variants = _vec.len[ast.variant](variants);
46104610
while (i < n_variants) {
46114611
auto variant = variants.(i);
4612+
4613+
auto discrim_val = C_int(i as int);
4614+
4615+
// FIXME: better name.
4616+
auto discrim_gvar = llvm.LLVMAddGlobal(cx.llmod, T_int(),
4617+
_str.buf("tag_discrim"));
4618+
4619+
// FIXME: Eventually we do want to export these, but we need
4620+
// to figure out what name they get first!
4621+
llvm.LLVMSetInitializer(discrim_gvar, discrim_val);
4622+
llvm.LLVMSetGlobalConstant(discrim_gvar, True);
4623+
llvm.LLVMSetLinkage(discrim_gvar, lib.llvm.LLVMPrivateLinkage
4624+
as llvm.Linkage);
4625+
46124626
if (_vec.len[ast.variant_arg](variant.args) == 0u) {
46134627
// Nullary tags become constants. (N-ary tags are treated
46144628
// as functions and generated later.)
46154629

46164630
auto union_val = C_zero_byte_arr(info.size as uint);
4617-
auto val = C_struct(vec(C_int(i as int), union_val));
4631+
auto val = C_struct(vec(discrim_val, union_val));
46184632

46194633
// FIXME: better name
46204634
auto gvar = llvm.LLVMAddGlobal(cx.llmod, val_ty(val),

0 commit comments

Comments
 (0)