Skip to content

Commit 2ddeef8

Browse files
committed
---
yaml --- r: 1444 b: refs/heads/master c: b5081a6 h: refs/heads/master v: v3
1 parent 2f4b931 commit 2ddeef8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-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: 2cd7fbbdf1edf84d962c62e9990acc0906998413
2+
refs/heads/master: b5081a6a825f23b45920cf72896076039f30386d

trunk/src/comp/middle/trans.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,8 @@ fn decr_refcnt_and_if_zero(@block_ctxt cx,
14421442
ret res(next_cx, phi);
14431443
}
14441444

1445+
// Tag information
1446+
14451447
fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
14461448
let vec[TypeRef] lltys = vec();
14471449
alt (ty.ann_to_type(v.ann).struct) {
@@ -1455,6 +1457,17 @@ fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
14551457
ret T_struct(lltys);
14561458
}
14571459

1460+
// Returns the number of variants in a tag.
1461+
fn tag_variant_count(@crate_ctxt cx, ast.def_id id) -> uint {
1462+
check (cx.items.contains_key(id));
1463+
alt (cx.items.get(id).node) {
1464+
case (ast.item_tag(_, ?variants, _, _)) {
1465+
ret _vec.len[ast.variant](variants);
1466+
}
1467+
}
1468+
fail; // not reached
1469+
}
1470+
14581471
type val_and_ty_fn = fn(@block_ctxt cx, ValueRef v, @ty.t t) -> result;
14591472

14601473
// Iterates through the elements of a structural type.
@@ -1506,7 +1519,7 @@ fn iter_structural_ty(@block_ctxt cx,
15061519
case (ty.ty_tag(?tid, ?tps)) {
15071520
check (cx.fcx.ccx.tags.contains_key(tid));
15081521
auto info = cx.fcx.ccx.tags.get(tid);
1509-
auto n_variants = _vec.len[tup(ast.def_id,arity)](info.variants);
1522+
auto n_variants = tag_variant_count(cx.fcx.ccx, tid);
15101523

15111524
// Look up the tag in the typechecked AST.
15121525
check (cx.fcx.ccx.items.contains_key(tid));

0 commit comments

Comments
 (0)