Skip to content

Commit a8fb18f

Browse files
committed
---
yaml --- r: 67301 b: refs/heads/master c: 7cc8f4b h: refs/heads/master i: 67299: c1a3fca v: v3
1 parent 0fea676 commit a8fb18f

File tree

17 files changed

+267
-106
lines changed

17 files changed

+267
-106
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c3417b88aa20f835a5c19dc5d8539eb33f2802b9
2+
refs/heads/master: 7cc8f4bae0ed20aad04e03e5f3812fb7b8288f78
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/librustc/metadata/decoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use metadata::tydecode::{parse_ty_data, parse_def_id,
2323
use middle::ty;
2424

2525
use std::hash::HashUtil;
26-
use std::uint;
26+
use std::int;
2727
use std::io::WriterUtil;
2828
use std::io;
2929
use std::option;
@@ -200,9 +200,9 @@ fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) -> bool {
200200
return true;
201201
}
202202

203-
fn variant_disr_val(d: ebml::Doc) -> Option<uint> {
203+
fn variant_disr_val(d: ebml::Doc) -> Option<int> {
204204
do reader::maybe_get_doc(d, tag_disr_val).chain |val_doc| {
205-
do reader::with_doc_data(val_doc) |data| { uint::parse_bytes(data, 10u) }
205+
do reader::with_doc_data(val_doc) |data| { int::parse_bytes(data, 10u) }
206206
}
207207
}
208208

trunk/src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use middle;
2121

2222
use std::hash::HashUtil;
2323
use std::hashmap::{HashMap, HashSet};
24+
use std::int;
2425
use std::io;
2526
use std::str;
2627
use std::uint;
@@ -289,9 +290,9 @@ fn encode_discriminant(ecx: &EncodeContext,
289290

290291
fn encode_disr_val(_: &EncodeContext,
291292
ebml_w: &mut writer::Encoder,
292-
disr_val: uint) {
293+
disr_val: int) {
293294
ebml_w.start_tag(tag_disr_val);
294-
let s = uint::to_str(disr_val);
295+
let s = int::to_str(disr_val);
295296
ebml_w.writer.write(s.as_bytes());
296297
ebml_w.end_tag();
297298
}

trunk/src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub enum Lit {
193193
// range)
194194
pub enum Opt {
195195
lit(Lit),
196-
var(/* disr val */ uint, @adt::Repr),
196+
var(/* disr val */int, @adt::Repr),
197197
range(@ast::expr, @ast::expr),
198198
vec_len_eq(uint),
199199
vec_len_ge(uint, /* slice */uint)
@@ -874,7 +874,7 @@ pub struct ExtractedBlock {
874874

875875
pub fn extract_variant_args(bcx: @mut Block,
876876
repr: &adt::Repr,
877-
disr_val: uint,
877+
disr_val: int,
878878
val: ValueRef)
879879
-> ExtractedBlock {
880880
let _icx = push_ctxt("match::extract_variant_args");

trunk/src/librustc/middle/trans/adt.rs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use middle::trans::type_::Type;
6464
/// Representations.
6565
pub enum Repr {
6666
/// C-like enums; basically an int.
67-
CEnum(uint, uint), // discriminant range
67+
CEnum(int, int), // discriminant range
6868
/**
6969
* Single-case variants, and structs/tuples/records.
7070
*
@@ -89,7 +89,7 @@ pub enum Repr {
8989
* is represented such that `None` is a null pointer and `Some` is the
9090
* identity function.
9191
*/
92-
NullablePointer{ nonnull: Struct, nndiscr: uint, ptrfield: uint,
92+
NullablePointer{ nonnull: Struct, nndiscr: int, ptrfield: uint,
9393
nullfields: ~[ty::t] }
9494
}
9595

@@ -140,7 +140,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
140140
return Univariant(mk_struct(cx, ftys, packed), dtor)
141141
}
142142
ty::ty_enum(def_id, ref substs) => {
143-
struct Case { discr: uint, tys: ~[ty::t] };
143+
struct Case { discr: int, tys: ~[ty::t] };
144144
impl Case {
145145
fn is_zerolen(&self, cx: &mut CrateContext) -> bool {
146146
mk_struct(cx, self.tys, false).size == 0
@@ -177,7 +177,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
177177
// Since there's at least one
178178
// non-empty body, explicit discriminants should have
179179
// been rejected by a checker before this point.
180-
if !cases.iter().enumerate().all(|(i,c)| c.discr == i) {
180+
if !cases.iter().enumerate().all(|(i,c)| c.discr == (i as int)) {
181181
cx.sess.bug(fmt!("non-C-like enum %s with specified \
182182
discriminants",
183183
ty::item_path_str(cx.tcx, def_id)))
@@ -206,7 +206,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
206206
}
207207

208208
// The general case.
209-
let discr = ~[ty::mk_uint()];
209+
let discr = ~[ty::mk_int()];
210210
return General(cases.map(|c| mk_struct(cx, discr + c.tys, false)))
211211
}
212212
_ => cx.sess.bug("adt::represent_type called on non-ADT type")
@@ -305,16 +305,17 @@ pub fn trans_get_discr(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
305305
-> ValueRef {
306306
match *r {
307307
CEnum(min, max) => load_discr(bcx, scrutinee, min, max),
308-
Univariant(*) => C_uint(bcx.ccx(), 0),
309-
General(ref cases) => load_discr(bcx, scrutinee, 0, cases.len() - 1),
308+
Univariant(*) => C_int(bcx.ccx(), 0),
309+
General(ref cases) => load_discr(bcx, scrutinee, 0,
310+
(cases.len() - 1) as int),
310311
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
311312
ZExt(bcx, nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee),
312313
Type::enum_discrim(bcx.ccx()))
313314
}
314315
}
315316
}
316317

317-
fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: uint, ptrfield: uint,
318+
fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: int, ptrfield: uint,
318319
scrutinee: ValueRef) -> ValueRef {
319320
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
320321
let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
@@ -323,7 +324,7 @@ fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: uint, ptrfield:
323324
}
324325

325326
/// Helper for cases where the discriminant is simply loaded.
326-
fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: uint, max: uint)
327+
fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: int, max: int)
327328
-> ValueRef {
328329
let ptr = GEPi(bcx, scrutinee, [0, 0]);
329330
if max + 1 == min {
@@ -347,16 +348,16 @@ fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: uint, max: uint)
347348
*
348349
* This should ideally be less tightly tied to `_match`.
349350
*/
350-
pub fn trans_case(bcx: @mut Block, r: &Repr, discr: uint) -> _match::opt_result {
351+
pub fn trans_case(bcx: @mut Block, r: &Repr, discr: int) -> _match::opt_result {
351352
match *r {
352353
CEnum(*) => {
353-
_match::single_result(rslt(bcx, C_uint(bcx.ccx(), discr)))
354+
_match::single_result(rslt(bcx, C_int(bcx.ccx(), discr)))
354355
}
355356
Univariant(*) => {
356357
bcx.ccx().sess.bug("no cases for univariants or structs")
357358
}
358359
General(*) => {
359-
_match::single_result(rslt(bcx, C_uint(bcx.ccx(), discr)))
360+
_match::single_result(rslt(bcx, C_int(bcx.ccx(), discr)))
360361
}
361362
NullablePointer{ _ } => {
362363
assert!(discr == 0 || discr == 1);
@@ -370,11 +371,11 @@ pub fn trans_case(bcx: @mut Block, r: &Repr, discr: uint) -> _match::opt_result
370371
* representation. The fields, if any, should then be initialized via
371372
* `trans_field_ptr`.
372373
*/
373-
pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint) {
374+
pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: int) {
374375
match *r {
375376
CEnum(min, max) => {
376377
assert!(min <= discr && discr <= max);
377-
Store(bcx, C_uint(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
378+
Store(bcx, C_int(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
378379
}
379380
Univariant(ref st, true) => {
380381
assert_eq!(discr, 0);
@@ -385,7 +386,7 @@ pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint) {
385386
assert_eq!(discr, 0);
386387
}
387388
General(*) => {
388-
Store(bcx, C_uint(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
389+
Store(bcx, C_int(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
389390
}
390391
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
391392
if discr != nndiscr {
@@ -401,22 +402,22 @@ pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint) {
401402
* The number of fields in a given case; for use when obtaining this
402403
* information from the type or definition is less convenient.
403404
*/
404-
pub fn num_args(r: &Repr, discr: uint) -> uint {
405+
pub fn num_args(r: &Repr, discr: int) -> uint {
405406
match *r {
406407
CEnum(*) => 0,
407408
Univariant(ref st, dtor) => {
408409
assert_eq!(discr, 0);
409410
st.fields.len() - (if dtor { 1 } else { 0 })
410411
}
411-
General(ref cases) => cases[discr].fields.len() - 1,
412+
General(ref cases) => cases[discr as uint].fields.len() - 1,
412413
NullablePointer{ nonnull: ref nonnull, nndiscr, nullfields: ref nullfields, _ } => {
413414
if discr == nndiscr { nonnull.fields.len() } else { nullfields.len() }
414415
}
415416
}
416417
}
417418

418419
/// Access a field, at a point when the value's case is known.
419-
pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint,
420+
pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: int,
420421
ix: uint) -> ValueRef {
421422
// Note: if this ever needs to generate conditionals (e.g., if we
422423
// decide to do some kind of cdr-coding-like non-unique repr
@@ -430,7 +431,7 @@ pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint,
430431
struct_field_ptr(bcx, st, val, ix, false)
431432
}
432433
General(ref cases) => {
433-
struct_field_ptr(bcx, &cases[discr], val, ix + 1, true)
434+
struct_field_ptr(bcx, &cases[discr as uint], val, ix + 1, true)
434435
}
435436
NullablePointer{ nonnull: ref nonnull, nullfields: ref nullfields, nndiscr, _ } => {
436437
if (discr == nndiscr) {
@@ -494,22 +495,22 @@ pub fn trans_drop_flag_ptr(bcx: @mut Block, r: &Repr, val: ValueRef) -> ValueRef
494495
* this could be changed in the future to avoid allocating unnecessary
495496
* space after values of shorter-than-maximum cases.
496497
*/
497-
pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: uint,
498+
pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: int,
498499
vals: &[ValueRef]) -> ValueRef {
499500
match *r {
500501
CEnum(min, max) => {
501502
assert_eq!(vals.len(), 0);
502503
assert!(min <= discr && discr <= max);
503-
C_uint(ccx, discr)
504+
C_int(ccx, discr)
504505
}
505506
Univariant(ref st, _dro) => {
506507
assert_eq!(discr, 0);
507508
C_struct(build_const_struct(ccx, st, vals))
508509
}
509510
General(ref cases) => {
510-
let case = &cases[discr];
511+
let case = &cases[discr as uint];
511512
let max_sz = cases.iter().transform(|x| x.size).max().unwrap();
512-
let discr_ty = C_uint(ccx, discr);
513+
let discr_ty = C_int(ccx, discr);
513514
let contents = build_const_struct(ccx, case,
514515
~[discr_ty] + vals);
515516
C_struct(contents + &[padding(max_sz - case.size)])
@@ -581,18 +582,13 @@ fn roundup(x: u64, a: u64) -> u64 { ((x + (a - 1)) / a) * a }
581582

582583
/// Get the discriminant of a constant value. (Not currently used.)
583584
pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef)
584-
-> uint {
585+
-> int {
585586
match *r {
586-
CEnum(*) => const_to_uint(val) as uint,
587+
CEnum(*) => const_to_int(val) as int,
587588
Univariant(*) => 0,
588-
General(*) => const_to_uint(const_get_elt(ccx, val, [0])) as uint,
589+
General(*) => const_to_int(const_get_elt(ccx, val, [0])) as int,
589590
NullablePointer{ nndiscr, ptrfield, _ } => {
590-
if is_null(const_struct_field(ccx, val, ptrfield)) {
591-
/* subtraction as uint is ok because nndiscr is either 0 or 1 */
592-
(1 - nndiscr) as uint
593-
} else {
594-
nndiscr
595-
}
591+
if is_null(const_struct_field(ccx, val, ptrfield)) { 1 - nndiscr } else { nndiscr }
596592
}
597593
}
598594
}
@@ -605,7 +601,7 @@ pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef)
605601
* raw LLVM-level structs and arrays.)
606602
*/
607603
pub fn const_get_field(ccx: &mut CrateContext, r: &Repr, val: ValueRef,
608-
_discr: uint, ix: uint) -> ValueRef {
604+
_discr: int, ix: uint) -> ValueRef {
609605
match *r {
610606
CEnum(*) => ccx.sess.bug("element access in C-like enum const"),
611607
Univariant(*) => const_struct_field(ccx, val, ix),

trunk/src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ use middle::trans::type_::Type;
6767

6868
use std::hash;
6969
use std::hashmap::{HashMap, HashSet};
70+
use std::int;
7071
use std::io;
7172
use std::libc::c_uint;
7273
use std::uint;
@@ -731,7 +732,7 @@ pub fn iter_structural_ty(cx: @mut Block, av: ValueRef, t: ty::t,
731732
for (*variants).iter().advance |variant| {
732733
let variant_cx =
733734
sub_block(cx, ~"enum-iter-variant-" +
734-
uint::to_str(variant.disr_val));
735+
int::to_str(variant.disr_val));
735736
let variant_cx =
736737
iter_variant(variant_cx, repr, av, *variant,
737738
substs.tps, |x,y,z| f(x,y,z));
@@ -1978,7 +1979,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext,
19781979
_enum_id: ast::node_id,
19791980
variant: &ast::variant,
19801981
args: &[ast::variant_arg],
1981-
disr: uint,
1982+
disr: int,
19821983
param_substs: Option<@param_substs>,
19831984
llfndecl: ValueRef) {
19841985
let _icx = push_ctxt("trans_enum_variant");
@@ -2027,7 +2028,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
20272028
ccx: @mut CrateContext,
20282029
ctor_id: ast::node_id,
20292030
args: &[A],
2030-
disr: uint,
2031+
disr: int,
20312032
param_substs: Option<@param_substs>,
20322033
llfndecl: ValueRef)
20332034
{
@@ -2627,7 +2628,7 @@ pub fn trans_constant(ccx: &mut CrateContext, it: @ast::item) {
26272628
}
26282629
};
26292630
unsafe {
2630-
llvm::LLVMSetInitializer(discrim_gvar, C_uint(ccx, disr_val));
2631+
llvm::LLVMSetInitializer(discrim_gvar, C_int(ccx, disr_val));
26312632
llvm::LLVMSetGlobalConstant(discrim_gvar, True);
26322633
}
26332634
ccx.discrims.insert(

trunk/src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
446446
(expr::cast_enum, expr::cast_float) => {
447447
let repr = adt::represent_type(cx, basety);
448448
let discr = adt::const_get_discrim(cx, repr, v);
449-
let iv = C_uint(cx, discr);
449+
let iv = C_int(cx, discr);
450450
let ety_cast = expr::cast_type_kind(ety);
451451
match ety_cast {
452452
expr::cast_integral => {

trunk/src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ pub fn trans_local_var(bcx: @mut Block, def: ast::def) -> Datum {
10831083
pub fn with_field_tys<R>(tcx: ty::ctxt,
10841084
ty: ty::t,
10851085
node_id_opt: Option<ast::node_id>,
1086-
op: &fn(uint, (&[ty::field])) -> R) -> R {
1086+
op: &fn(int, (&[ty::field])) -> R) -> R {
10871087
match ty::get(ty).sty {
10881088
ty::ty_struct(did, ref substs) => {
10891089
op(0, struct_fields(tcx, did, substs))
@@ -1200,7 +1200,7 @@ struct StructBaseInfo {
12001200
* - `optbase` contains information on the base struct (if any) from
12011201
* which remaining fields are copied; see comments on `StructBaseInfo`.
12021202
*/
1203-
fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: uint,
1203+
fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: int,
12041204
fields: &[(uint, @ast::expr)],
12051205
optbase: Option<StructBaseInfo>,
12061206
dest: Dest) -> @mut Block {

trunk/src/librustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl Reflector {
321321
for variants.iter().enumerate().advance |(i, v)| {
322322
let name = ccx.sess.str_of(v.name);
323323
let variant_args = ~[this.c_uint(i),
324-
this.c_uint(v.disr_val),
324+
this.c_int(v.disr_val),
325325
this.c_uint(v.args.len()),
326326
this.c_slice(name)];
327327
do this.bracketed("enum_variant", variant_args) |this| {

0 commit comments

Comments
 (0)