Skip to content

Commit eebe1ad

Browse files
committed
---
yaml --- r: 78782 b: refs/heads/try c: da08b02 h: refs/heads/master v: v3
1 parent 3af1569 commit eebe1ad

File tree

23 files changed

+461
-380
lines changed

23 files changed

+461
-380
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 25ed29a0edb3d48fef843a0b818ee68faf2252da
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 60fba4d7d677ec098e6a43014132fe99f7547363
5-
refs/heads/try: 0db2b198f2ff3e5353acbc477a47592d1f43480e
5+
refs/heads/try: da08b0244a6bfec980ed2152a963886749886472
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/metadata/decoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use middle::astencode::vtable_decoder_helpers;
2626

2727

2828
use std::hash::HashUtil;
29-
use std::u64;
29+
use std::uint;
3030
use std::io::WriterUtil;
3131
use std::io;
3232
use std::option;
@@ -207,9 +207,9 @@ fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) -> bool {
207207
reader::tagged_docs(d, tag_items_data_item_reexport, f)
208208
}
209209

210-
fn variant_disr_val(d: ebml::Doc) -> Option<ty::Disr> {
210+
fn variant_disr_val(d: ebml::Doc) -> Option<uint> {
211211
do reader::maybe_get_doc(d, tag_disr_val).chain |val_doc| {
212-
do reader::with_doc_data(val_doc) |data| { u64::parse_bytes(data, 10u) }
212+
do reader::with_doc_data(val_doc) |data| { uint::parse_bytes(data, 10u) }
213213
}
214214
}
215215

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn encode_symbol(ecx: &EncodeContext,
292292

293293
fn encode_disr_val(_: &EncodeContext,
294294
ebml_w: &mut writer::Encoder,
295-
disr_val: ty::Disr) {
295+
disr_val: uint) {
296296
ebml_w.start_tag(tag_disr_val);
297297
let s = disr_val.to_str();
298298
ebml_w.writer.write(s.as_bytes());

branches/try/src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub enum VecLenOpt {
245245
// range)
246246
enum Opt {
247247
lit(Lit),
248-
var(ty::Disr, @adt::Repr),
248+
var(/* disr val */ uint, @adt::Repr),
249249
range(@ast::expr, @ast::expr),
250250
vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint))
251251
}
@@ -992,7 +992,7 @@ struct ExtractedBlock {
992992

993993
fn extract_variant_args(bcx: @mut Block,
994994
repr: &adt::Repr,
995-
disr_val: ty::Disr,
995+
disr_val: uint,
996996
val: ValueRef)
997997
-> ExtractedBlock {
998998
let _icx = push_ctxt("match::extract_variant_args");

branches/try/src/librustc/middle/trans/adt.rs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ use middle::trans::common::*;
5555
use middle::trans::machine;
5656
use middle::trans::type_of;
5757
use middle::ty;
58-
use middle::ty::Disr;
5958
use syntax::ast;
6059
use util::ppaux::ty_to_str;
6160

@@ -65,7 +64,7 @@ use middle::trans::type_::Type;
6564
/// Representations.
6665
pub enum Repr {
6766
/// C-like enums; basically an int.
68-
CEnum(Disr, Disr), // discriminant range
67+
CEnum(uint, uint), // discriminant range
6968
/**
7069
* Single-case variants, and structs/tuples/records.
7170
*
@@ -90,7 +89,7 @@ pub enum Repr {
9089
* is represented such that `None` is a null pointer and `Some` is the
9190
* identity function.
9291
*/
93-
NullablePointer{ nonnull: Struct, nndiscr: Disr, ptrfield: uint,
92+
NullablePointer{ nonnull: Struct, nndiscr: uint, ptrfield: uint,
9493
nullfields: ~[ty::t] }
9594
}
9695

@@ -141,7 +140,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
141140
return Univariant(mk_struct(cx, ftys, packed), dtor)
142141
}
143142
ty::ty_enum(def_id, ref substs) => {
144-
struct Case { discr: Disr, tys: ~[ty::t] };
143+
struct Case { discr: uint, tys: ~[ty::t] };
145144
impl Case {
146145
fn is_zerolen(&self, cx: &mut CrateContext) -> bool {
147146
mk_struct(cx, self.tys, false).size == 0
@@ -178,7 +177,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
178177
// Since there's at least one
179178
// non-empty body, explicit discriminants should have
180179
// been rejected by a checker before this point.
181-
if !cases.iter().enumerate().all(|(i,c)| c.discr == (i as Disr)) {
180+
if !cases.iter().enumerate().all(|(i,c)| c.discr == i) {
182181
cx.sess.bug(fmt!("non-C-like enum %s with specified \
183182
discriminants",
184183
ty::item_path_str(cx.tcx, def_id)))
@@ -306,16 +305,16 @@ pub fn trans_get_discr(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
306305
-> ValueRef {
307306
match *r {
308307
CEnum(min, max) => load_discr(bcx, scrutinee, min, max),
309-
Univariant(*) => C_disr(bcx.ccx(), 0),
310-
General(ref cases) => load_discr(bcx, scrutinee, 0, (cases.len() - 1) as Disr),
308+
Univariant(*) => C_uint(bcx.ccx(), 0),
309+
General(ref cases) => load_discr(bcx, scrutinee, 0, cases.len() - 1),
311310
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
312311
ZExt(bcx, nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee),
313312
Type::enum_discrim(bcx.ccx()))
314313
}
315314
}
316315
}
317316

318-
fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
317+
fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: uint, ptrfield: uint,
319318
scrutinee: ValueRef) -> ValueRef {
320319
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
321320
let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
@@ -324,7 +323,7 @@ fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: Disr, ptrfield:
324323
}
325324

326325
/// Helper for cases where the discriminant is simply loaded.
327-
fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: Disr, max: Disr)
326+
fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: uint, max: uint)
328327
-> ValueRef {
329328
let ptr = GEPi(bcx, scrutinee, [0, 0]);
330329
if max + 1 == min {
@@ -348,16 +347,16 @@ fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: Disr, max: Disr)
348347
*
349348
* This should ideally be less tightly tied to `_match`.
350349
*/
351-
pub fn trans_case(bcx: @mut Block, r: &Repr, discr: Disr) -> _match::opt_result {
350+
pub fn trans_case(bcx: @mut Block, r: &Repr, discr: uint) -> _match::opt_result {
352351
match *r {
353352
CEnum(*) => {
354-
_match::single_result(rslt(bcx, C_disr(bcx.ccx(), discr)))
353+
_match::single_result(rslt(bcx, C_uint(bcx.ccx(), discr)))
355354
}
356355
Univariant(*) => {
357356
bcx.ccx().sess.bug("no cases for univariants or structs")
358357
}
359358
General(*) => {
360-
_match::single_result(rslt(bcx, C_disr(bcx.ccx(), discr)))
359+
_match::single_result(rslt(bcx, C_uint(bcx.ccx(), discr)))
361360
}
362361
NullablePointer{ _ } => {
363362
assert!(discr == 0 || discr == 1);
@@ -371,11 +370,11 @@ pub fn trans_case(bcx: @mut Block, r: &Repr, discr: Disr) -> _match::opt_result
371370
* representation. The fields, if any, should then be initialized via
372371
* `trans_field_ptr`.
373372
*/
374-
pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr) {
373+
pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint) {
375374
match *r {
376375
CEnum(min, max) => {
377376
assert!(min <= discr && discr <= max);
378-
Store(bcx, C_disr(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
377+
Store(bcx, C_uint(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
379378
}
380379
Univariant(ref st, true) => {
381380
assert_eq!(discr, 0);
@@ -386,7 +385,7 @@ pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr) {
386385
assert_eq!(discr, 0);
387386
}
388387
General(*) => {
389-
Store(bcx, C_disr(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
388+
Store(bcx, C_uint(bcx.ccx(), discr), GEPi(bcx, val, [0, 0]))
390389
}
391390
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
392391
if discr != nndiscr {
@@ -402,7 +401,7 @@ pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr) {
402401
* The number of fields in a given case; for use when obtaining this
403402
* information from the type or definition is less convenient.
404403
*/
405-
pub fn num_args(r: &Repr, discr: Disr) -> uint {
404+
pub fn num_args(r: &Repr, discr: uint) -> uint {
406405
match *r {
407406
CEnum(*) => 0,
408407
Univariant(ref st, dtor) => {
@@ -417,7 +416,7 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint {
417416
}
418417

419418
/// Access a field, at a point when the value's case is known.
420-
pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr,
419+
pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: uint,
421420
ix: uint) -> ValueRef {
422421
// Note: if this ever needs to generate conditionals (e.g., if we
423422
// decide to do some kind of cdr-coding-like non-unique repr
@@ -495,13 +494,13 @@ pub fn trans_drop_flag_ptr(bcx: @mut Block, r: &Repr, val: ValueRef) -> ValueRef
495494
* this could be changed in the future to avoid allocating unnecessary
496495
* space after values of shorter-than-maximum cases.
497496
*/
498-
pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
497+
pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: uint,
499498
vals: &[ValueRef]) -> ValueRef {
500499
match *r {
501500
CEnum(min, max) => {
502501
assert_eq!(vals.len(), 0);
503502
assert!(min <= discr && discr <= max);
504-
C_disr(ccx, discr)
503+
C_uint(ccx, discr)
505504
}
506505
Univariant(ref st, _dro) => {
507506
assert_eq!(discr, 0);
@@ -510,7 +509,7 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
510509
General(ref cases) => {
511510
let case = &cases[discr];
512511
let max_sz = cases.iter().map(|x| x.size).max().unwrap();
513-
let discr_ty = C_disr(ccx, discr);
512+
let discr_ty = C_uint(ccx, discr);
514513
let contents = build_const_struct(ccx, case,
515514
~[discr_ty] + vals);
516515
C_struct(contents + &[padding(max_sz - case.size)])
@@ -582,15 +581,15 @@ fn roundup(x: u64, a: u64) -> u64 { ((x + (a - 1)) / a) * a }
582581

583582
/// Get the discriminant of a constant value. (Not currently used.)
584583
pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef)
585-
-> Disr {
584+
-> uint {
586585
match *r {
587-
CEnum(*) => const_to_uint(val) as Disr,
586+
CEnum(*) => const_to_uint(val) as uint,
588587
Univariant(*) => 0,
589-
General(*) => const_to_uint(const_get_elt(ccx, val, [0])) as Disr,
588+
General(*) => const_to_uint(const_get_elt(ccx, val, [0])) as uint,
590589
NullablePointer{ nndiscr, ptrfield, _ } => {
591590
if is_null(const_struct_field(ccx, val, ptrfield)) {
592591
/* subtraction as uint is ok because nndiscr is either 0 or 1 */
593-
(1 - nndiscr) as Disr
592+
(1 - nndiscr) as uint
594593
} else {
595594
nndiscr
596595
}
@@ -606,7 +605,7 @@ pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef)
606605
* raw LLVM-level structs and arrays.)
607606
*/
608607
pub fn const_get_field(ccx: &mut CrateContext, r: &Repr, val: ValueRef,
609-
_discr: Disr, ix: uint) -> ValueRef {
608+
_discr: uint, ix: uint) -> ValueRef {
610609
match *r {
611610
CEnum(*) => ccx.sess.bug("element access in C-like enum const"),
612611
Univariant(*) => const_struct_field(ccx, val, ix),
@@ -645,7 +644,3 @@ pub fn is_newtypeish(r: &Repr) -> bool {
645644
_ => false
646645
}
647646
}
648-
649-
fn C_disr(cx: &CrateContext, i: Disr) -> ValueRef {
650-
return C_integral(cx.int_type, i, false);
651-
}

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext,
20142014
_enum_id: ast::NodeId,
20152015
variant: &ast::variant,
20162016
args: &[ast::variant_arg],
2017-
disr: ty::Disr,
2017+
disr: uint,
20182018
param_substs: Option<@param_substs>,
20192019
llfndecl: ValueRef) {
20202020
let _icx = push_ctxt("trans_enum_variant");
@@ -2063,7 +2063,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
20632063
ccx: @mut CrateContext,
20642064
ctor_id: ast::NodeId,
20652065
args: &[A],
2066-
disr: ty::Disr,
2066+
disr: uint,
20672067
param_substs: Option<@param_substs>,
20682068
llfndecl: ValueRef)
20692069
{

branches/try/src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
453453
(expr::cast_enum, expr::cast_float) => {
454454
let repr = adt::represent_type(cx, basety);
455455
let discr = adt::const_get_discrim(cx, repr, v);
456-
let iv = C_integral(cx.int_type, discr, false);
456+
let iv = C_uint(cx, discr);
457457
let ety_cast = expr::cast_type_kind(ety);
458458
match ety_cast {
459459
expr::cast_integral => {

branches/try/src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ pub fn trans_local_var(bcx: @mut Block, def: ast::def) -> Datum {
11181118
pub fn with_field_tys<R>(tcx: ty::ctxt,
11191119
ty: ty::t,
11201120
node_id_opt: Option<ast::NodeId>,
1121-
op: &fn(ty::Disr, (&[ty::field])) -> R) -> R {
1121+
op: &fn(uint, (&[ty::field])) -> R) -> R {
11221122
match ty::get(ty).sty {
11231123
ty::ty_struct(did, ref substs) => {
11241124
op(0, struct_fields(tcx, did, substs))
@@ -1235,7 +1235,7 @@ struct StructBaseInfo {
12351235
* - `optbase` contains information on the base struct (if any) from
12361236
* which remaining fields are copied; see comments on `StructBaseInfo`.
12371237
*/
1238-
fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: ty::Disr,
1238+
fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: uint,
12391239
fields: &[(uint, @ast::expr)],
12401240
optbase: Option<StructBaseInfo>,
12411241
dest: Dest) -> @mut Block {

branches/try/src/librustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl Reflector {
317317
for (i, v) in variants.iter().enumerate() {
318318
let name = ccx.sess.str_of(v.name);
319319
let variant_args = ~[this.c_uint(i),
320-
C_integral(self.bcx.ccx().int_type, v.disr_val, false),
320+
this.c_uint(v.disr_val),
321321
this.c_uint(v.args.len()),
322322
this.c_slice(name)];
323323
do this.bracketed("enum_variant", variant_args) |this| {

branches/try/src/librustc/middle/ty.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ use syntax::abi::AbiSet;
4848
use syntax;
4949
use extra::enum_set::{EnumSet, CLike};
5050

51-
pub type Disr = u64;
52-
53-
pub static INITIAL_DISCRIMINANT_VALUE: Disr = 0;
51+
pub static INITIAL_DISCRIMINANT_VALUE: uint = 0;
5452

5553
// Data types
5654

@@ -3805,7 +3803,7 @@ pub struct VariantInfo {
38053803
ctor_ty: t,
38063804
name: ast::ident,
38073805
id: ast::def_id,
3808-
disr_val: Disr,
3806+
disr_val: uint,
38093807
vis: visibility
38103808
}
38113809

@@ -3816,7 +3814,7 @@ impl VariantInfo {
38163814
/// Does not do any caching of the value in the type context.
38173815
pub fn from_ast_variant(cx: ctxt,
38183816
ast_variant: &ast::variant,
3819-
discriminant: Disr) -> VariantInfo {
3817+
discriminant: uint) -> VariantInfo {
38203818

38213819
let ctor_ty = node_id_to_type(cx, ast_variant.node.id);
38223820

@@ -4010,7 +4008,7 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[@VariantInfo] {
40104008
node: ast::item_enum(ref enum_definition, _),
40114009
_
40124010
}, _) => {
4013-
let mut last_discriminant: Option<Disr> = None;
4011+
let mut last_discriminant: Option<uint> = None;
40144012
@enum_definition.variants.iter().map(|variant| {
40154013

40164014
let mut discriminant = match last_discriminant {
@@ -4020,8 +4018,8 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[@VariantInfo] {
40204018

40214019
match variant.node.disr_expr {
40224020
Some(e) => match const_eval::eval_const_expr_partial(&cx, e) {
4023-
Ok(const_eval::const_int(val)) => discriminant = val as Disr,
4024-
Ok(const_eval::const_uint(val)) => discriminant = val as Disr,
4021+
Ok(const_eval::const_int(val)) => discriminant = val as uint,
4022+
Ok(const_eval::const_uint(val)) => discriminant = val as uint,
40254023
Ok(_) => {
40264024
cx.sess.span_err(e.span, "expected signed integer constant");
40274025
}

branches/try/src/librustc/middle/typeck/check/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use middle::pat_util;
8383
use middle::lint::unreachable_code;
8484
use middle::ty::{FnSig, VariantInfo};
8585
use middle::ty::{ty_param_bounds_and_ty, ty_param_substs_and_ty};
86-
use middle::ty::{substs, param_ty, Disr, ExprTyProvider};
86+
use middle::ty::{substs, param_ty, ExprTyProvider};
8787
use middle::ty;
8888
use middle::typeck::astconv::AstConv;
8989
use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty};
@@ -3000,8 +3000,8 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
30003000

30013001
let rty = ty::node_id_to_type(ccx.tcx, id);
30023002
let mut variants: ~[@ty::VariantInfo] = ~[];
3003-
let mut disr_vals: ~[ty::Disr] = ~[];
3004-
let mut prev_disr_val: Option<ty::Disr> = None;
3003+
let mut disr_vals: ~[uint] = ~[];
3004+
let mut prev_disr_val: Option<uint> = None;
30053005

30063006
for v in vs.iter() {
30073007

@@ -3024,8 +3024,8 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
30243024
// handle, so we may still get an internal compiler error
30253025

30263026
match const_eval::eval_const_expr_partial(&ccx.tcx, e) {
3027-
Ok(const_eval::const_int(val)) => current_disr_val = val as Disr,
3028-
Ok(const_eval::const_uint(val)) => current_disr_val = val as Disr,
3027+
Ok(const_eval::const_int(val)) => current_disr_val = val as uint,
3028+
Ok(const_eval::const_uint(val)) => current_disr_val = val as uint,
30293029
Ok(_) => {
30303030
ccx.tcx.sess.span_err(e.span, "expected signed integer constant");
30313031
}

0 commit comments

Comments
 (0)