Skip to content

Commit e6b7b4f

Browse files
committed
---
yaml --- r: 1448 b: refs/heads/master c: 0120571 h: refs/heads/master v: v3
1 parent 28a4c4c commit e6b7b4f

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
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: e37db13b02557b887de295a63b4b96021042ccde
2+
refs/heads/master: 0120571e90a68befb03892c63c470d0923d425c4

trunk/src/comp/middle/trans.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ state type crate_ctxt = rec(session.session sess,
7474
hashmap[ast.def_id, @ast.item] items,
7575
hashmap[ast.def_id,
7676
@ast.native_item] native_items,
77-
hashmap[ast.def_id, @tag_info] tags,
77+
hashmap[@ty.t, @tag_info] tags,
7878
hashmap[ast.def_id, ValueRef] fn_pairs,
7979
hashmap[ast.def_id, ValueRef] consts,
8080
hashmap[ast.def_id,()] obj_methods,
@@ -543,7 +543,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t) -> TypeRef {
543543
case (ty.ty_char) { llty = T_char(); }
544544
case (ty.ty_str) { llty = T_ptr(T_str()); }
545545
case (ty.ty_tag(?tag_id, _)) {
546-
llty = llvm.LLVMResolveTypeHandle(cx.tags.get(tag_id).th.llth);
546+
llty = llvm.LLVMResolveTypeHandle(cx.tags.get(t).th.llth);
547547
}
548548
case (ty.ty_box(?t)) {
549549
llty = T_ptr(T_box(type_of_inner(cx, t)));
@@ -1472,6 +1472,14 @@ fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[ast.variant] {
14721472
fail; // not reached
14731473
}
14741474

1475+
// Returns a new plain tag type of the given ID with no type parameters. Don't
1476+
// use this function in new code; it's a hack to keep things working for now.
1477+
fn mk_plain_tag(ast.def_id tid) -> @ty.t {
1478+
let vec[@ty.t] tps = vec();
1479+
ret ty.plain_ty(ty.ty_tag(tid, tps));
1480+
}
1481+
1482+
14751483
type val_and_ty_fn = fn(@block_ctxt cx, ValueRef v, @ty.t t) -> result;
14761484

14771485
// Iterates through the elements of a structural type.
@@ -1521,8 +1529,7 @@ fn iter_structural_ty(@block_ctxt cx,
15211529
}
15221530
}
15231531
case (ty.ty_tag(?tid, ?tps)) {
1524-
check (cx.fcx.ccx.tags.contains_key(tid));
1525-
auto info = cx.fcx.ccx.tags.get(tid);
1532+
auto info = cx.fcx.ccx.tags.get(mk_plain_tag(tid));
15261533

15271534
auto variants = tag_variants(cx.fcx.ccx, tid);
15281535
auto n_variants = _vec.len[ast.variant](variants);
@@ -2591,7 +2598,6 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
25912598
ret lval_generic_fn(cx, ty.item_ty(fn_item), did, ann);
25922599
}
25932600
case (ast.def_variant(?tid, ?vid)) {
2594-
check (cx.fcx.ccx.tags.contains_key(tid));
25952601
if (cx.fcx.ccx.fn_pairs.contains_key(vid)) {
25962602
check (cx.fcx.ccx.items.contains_key(tid));
25972603
auto tag_item = cx.fcx.ccx.items.get(tid);
@@ -4247,7 +4253,9 @@ fn trans_tag_variant(@crate_ctxt cx, ast.def_id tag_id,
42474253
auto arg_tys = arg_tys_of_fn(variant.ann);
42484254
copy_args_to_allocas(bcx, none[TypeRef], fn_args, arg_tys);
42494255

4250-
auto info = cx.tags.get(tag_id);
4256+
// FIXME: This is wrong for generic tags. We should be dynamically
4257+
// computing "size" below based on the tydescs passed in.
4258+
auto info = cx.tags.get(mk_plain_tag(tag_id));
42514259

42524260
auto lltagty = T_struct(vec(T_int(), T_array(T_i8(), info.size)));
42534261

@@ -4445,8 +4453,8 @@ fn collect_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
44454453
case (ast.item_tag(_, ?variants, ?tps, ?tag_id)) {
44464454
auto vi = new_def_hash[uint]();
44474455
auto navi = new_def_hash[uint]();
4448-
cx.tags.insert(tag_id, @rec(th=mk_type_handle(),
4449-
mutable size=0u));
4456+
cx.tags.insert(mk_plain_tag(tag_id), @rec(th=mk_type_handle(),
4457+
mutable size=0u));
44504458
cx.items.insert(tag_id, i);
44514459
}
44524460

@@ -4507,7 +4515,7 @@ fn resolve_tag_types_for_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
45074515
auto max_align = 0u;
45084516
auto max_size = 0u;
45094517

4510-
auto info = cx.tags.get(tag_id);
4518+
auto info = cx.tags.get(mk_plain_tag(tag_id));
45114519

45124520
for (ast.variant variant in variants) {
45134521
if (_vec.len[ast.variant_arg](variant.args) > 0u) {
@@ -4528,7 +4536,7 @@ fn resolve_tag_types_for_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
45284536
// FIXME: alignment is wrong here, manually insert padding I
45294537
// guess :(
45304538
auto tag_ty = T_struct(vec(T_int(), T_array(T_i8(), max_size)));
4531-
auto th = cx.tags.get(tag_id).th.llth;
4539+
auto th = info.th.llth;
45324540
llvm.LLVMRefineType(llvm.LLVMResolveTypeHandle(th), tag_ty);
45334541
}
45344542
case (_) {
@@ -4554,7 +4562,7 @@ fn resolve_tag_types(@crate_ctxt cx, @ast.crate crate) {
45544562
fn trans_constant(&@crate_ctxt cx, @ast.item it) -> @crate_ctxt {
45554563
alt (it.node) {
45564564
case (ast.item_tag(_, ?variants, _, ?tag_id)) {
4557-
auto info = cx.tags.get(tag_id);
4565+
auto info = cx.tags.get(mk_plain_tag(tag_id));
45584566

45594567
auto tag_ty = llvm.LLVMResolveTypeHandle(info.th.llth);
45604568
check (llvm.LLVMCountStructElementTypes(tag_ty) == 2u);
@@ -4924,6 +4932,7 @@ fn trans_crate(session.session sess, @ast.crate crate, str output,
49244932
auto glues = make_glues(llmod, tn);
49254933
auto hasher = ty.hash_ty;
49264934
auto eqer = ty.eq_ty;
4935+
auto tags = map.mk_hashmap[@ty.t,@tag_info](hasher, eqer);
49274936
auto tydescs = map.mk_hashmap[@ty.t,ValueRef](hasher, eqer);
49284937
let vec[ast.ty_param] obj_typarams = vec();
49294938
let vec[ast.obj_field] obj_fields = vec();
@@ -4939,7 +4948,7 @@ fn trans_crate(session.session sess, @ast.crate crate, str output,
49394948
item_ids = new_def_hash[ValueRef](),
49404949
items = new_def_hash[@ast.item](),
49414950
native_items = new_def_hash[@ast.native_item](),
4942-
tags = new_def_hash[@tag_info](),
4951+
tags = tags,
49434952
fn_pairs = new_def_hash[ValueRef](),
49444953
consts = new_def_hash[ValueRef](),
49454954
obj_methods = new_def_hash[()](),

trunk/src/comp/middle/ty.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ fn ty_to_str(&@t typ) -> str {
247247
s = "rec(" + _str.connect(strs, ",") + ")";
248248
}
249249

250-
case (ty_tag(_, ?tps)) {
250+
case (ty_tag(?id, ?tps)) {
251251
// The user should never see this if the cname is set properly!
252-
s = "<tag>";
252+
s = "<tag#" + util.common.istr(id._0) + ":" +
253+
util.common.istr(id._1) + ">";
253254
if (_vec.len[@t](tps) > 0u) {
254255
auto f = ty_to_str;
255256
auto strs = _vec.map[@t,str](f, tps);

0 commit comments

Comments
 (0)