From e412652f0027dd0da270f802d894d910736a9f23 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 1 Sep 2011 16:31:18 -0700 Subject: [PATCH] Make GEP_tag take a uint instead of an int Seems to make more sense and avoids the need for some casts. --- src/comp/middle/trans.rs | 16 ++++++++-------- src/comp/middle/trans_alt.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 3cf955eba109..7bd39752be17 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -776,7 +776,8 @@ fn GEP_tup_like(cx: &@block_ctxt, t: ty::t, base: ValueRef, ixs: &[int]) -> // appropriate. @llblobptr is the data part of a tag value; its actual type is // meaningless, as it will be cast away. fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id, - variant_id: &ast::def_id, ty_substs: &[ty::t], ix: int) -> result { + variant_id: &ast::def_id, ty_substs: &[ty::t], ix: uint) + -> result { let variant = ty::tag_variant_with_id(bcx_tcx(cx), tag_id, variant_id); // Synthesize a tuple type so that GEP_tup_like() can work its magic. // Separately, store the type of the element we're interested in. @@ -784,13 +785,13 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id, let arg_tys = variant.args; let elem_ty = ty::mk_nil(bcx_tcx(cx)); // typestate infelicity - let i = 0; + let i = 0u; let true_arg_tys: [ty::t] = []; for aty: ty::t in arg_tys { let arg_ty = ty::substitute_type_params(bcx_tcx(cx), ty_substs, aty); true_arg_tys += [arg_ty]; if i == ix { elem_ty = arg_ty; } - i += 1; + i += 1u; } let tup_ty = ty::mk_tup(bcx_tcx(cx), true_arg_tys); // Cast the blob pointer to the appropriate type, if we need to (i.e. if @@ -803,7 +804,7 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id, } else { llunionptr = llblobptr; } // Do the GEP_tup_like(). - let rs = GEP_tup_like(cx, tup_ty, llunionptr, [0, ix]); + let rs = GEP_tup_like(cx, tup_ty, llunionptr, [0, ix as int]); // Cast the result to the appropriate type, if necessary. let val; @@ -1668,14 +1669,14 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t, let ccx = bcx_ccx(cx); alt ty::struct(ccx.tcx, fn_ty) { ty::ty_fn(_, args, _, _, _) { - let j = 0; + let j = 0u; for a: ty::arg in args { let rslt = GEP_tag(cx, a_tup, tid, variant.id, tps, j); let llfldp_a = rslt.val; cx = rslt.bcx; let ty_subst = ty::substitute_type_params(ccx.tcx, tps, a.ty); cx = f(cx, llfldp_a, ty_subst); - j += 1; + j += 1u; } } } @@ -5354,8 +5355,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id, for va: ast::variant_arg in variant.node.args { let rslt = GEP_tag(bcx, llblobptr, ast_util::local_def(tag_id), - ast_util::local_def(variant.node.id), ty_param_substs, - i as int); + ast_util::local_def(variant.node.id), ty_param_substs, i); bcx = rslt.bcx; let lldestptr = rslt.val; // If this argument to this function is a tag, it'll have come in to diff --git a/src/comp/middle/trans_alt.rs b/src/comp/middle/trans_alt.rs index e8fc3f33c0f1..73a49a04c5fc 100644 --- a/src/comp/middle/trans_alt.rs +++ b/src/comp/middle/trans_alt.rs @@ -219,7 +219,7 @@ fn extract_variant_args(bcx: @block_ctxt, pat_id: ast::node_id, while i < size { let r = trans::GEP_tag(bcx, blobptr, vdefs.tg, vdefs.var, ty_param_substs, - i as int); + i); bcx = r.bcx; args += [r.val]; i += 1u;