Skip to content

Commit 30e6f09

Browse files
committed
---
yaml --- r: 146304 b: refs/heads/try2 c: fcfbfde h: refs/heads/master v: v3
1 parent 173ba87 commit 30e6f09

File tree

9 files changed

+45
-41
lines changed

9 files changed

+45
-41
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 92109b12029b21e27f9f12a2b4faf4abc0627b64
8+
refs/heads/try2: fcfbfde0b71d2470cb544d3d216eaf61ceb348bf
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ pub fn C_i64(i: i64) -> ValueRef {
868868
return C_integral(Type::i64(), i as u64, true);
869869
}
870870

871+
pub fn C_u64(i: u64) -> ValueRef {
872+
return C_integral(Type::i64(), i, false);
873+
}
874+
871875
pub fn C_int(cx: &CrateContext, i: int) -> ValueRef {
872876
return C_integral(cx.int_type, i as u64, true);
873877
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ impl Reflector {
292292
sub_path,
293293
"get_disr");
294294

295-
let llfdecl = decl_internal_rust_fn(ccx, [opaqueptrty], ty::mk_int(), sym);
295+
let llfdecl = decl_internal_rust_fn(ccx, [opaqueptrty], ty::mk_u64(), sym);
296296
let fcx = new_fn_ctxt(ccx,
297297
~[],
298298
llfdecl,
299-
ty::mk_uint(),
299+
ty::mk_u64(),
300300
None);
301301
let arg = unsafe {
302302
//
@@ -308,7 +308,7 @@ impl Reflector {
308308
};
309309
let mut bcx = fcx.entry_bcx.unwrap();
310310
let arg = BitCast(bcx, arg, llptrty);
311-
let ret = adt::trans_get_discr(bcx, repr, arg, Some(ccx.int_type));
311+
let ret = adt::trans_get_discr(bcx, repr, arg, Some(Type::i64()));
312312
Store(bcx, ret, fcx.llretptr.unwrap());
313313
match fcx.llreturn {
314314
Some(llreturn) => cleanup_and_Br(bcx, bcx, llreturn),
@@ -324,7 +324,7 @@ impl Reflector {
324324
for (i, v) in variants.iter().enumerate() {
325325
let name = ccx.sess.str_of(v.name);
326326
let variant_args = ~[this.c_uint(i),
327-
C_integral(self.bcx.ccx().int_type, v.disr_val, false),
327+
C_u64(v.disr_val),
328328
this.c_uint(v.args.len()),
329329
this.c_slice(name)];
330330
do this.bracketed("enum_variant", variant_args) |this| {

branches/try2/src/libstd/reflect.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Runtime type reflection
1616

1717
#[allow(missing_doc)];
1818

19-
use unstable::intrinsics::{Opaque, TyDesc, TyVisitor};
19+
use unstable::intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
2020
use libc::c_void;
2121
use mem;
2222
use unstable::raw;
@@ -396,7 +396,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
396396
}
397397

398398
fn visit_enter_enum(&mut self, n_variants: uint,
399-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
399+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
400400
sz: uint, align: uint)
401401
-> bool {
402402
self.align(align);
@@ -407,7 +407,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
407407
}
408408

409409
fn visit_enter_enum_variant(&mut self, variant: uint,
410-
disr_val: int,
410+
disr_val: Disr,
411411
n_fields: uint,
412412
name: &str) -> bool {
413413
if ! self.inner.visit_enter_enum_variant(variant, disr_val,
@@ -426,7 +426,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
426426
}
427427

428428
fn visit_leave_enum_variant(&mut self, variant: uint,
429-
disr_val: int,
429+
disr_val: Disr,
430430
n_fields: uint,
431431
name: &str) -> bool {
432432
if ! self.inner.visit_leave_enum_variant(variant, disr_val,
@@ -437,7 +437,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
437437
}
438438

439439
fn visit_leave_enum(&mut self, n_variants: uint,
440-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
440+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
441441
sz: uint, align: uint) -> bool {
442442
if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) {
443443
return false;

branches/try2/src/libstd/repr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use reflect::{MovePtr, align};
2929
use str::StrSlice;
3030
use to_str::ToStr;
3131
use vec::OwnedVector;
32-
use unstable::intrinsics::{Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
32+
use unstable::intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
3333
use unstable::raw;
3434

3535
/// Representations
@@ -92,7 +92,7 @@ num_repr!(f64, "f64")
9292
// New implementation using reflect::MovePtr
9393

9494
enum VariantState {
95-
SearchingFor(int),
95+
SearchingFor(Disr),
9696
Matched,
9797
AlreadyFound
9898
}
@@ -473,7 +473,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
473473

474474
fn visit_enter_enum(&mut self,
475475
_n_variants: uint,
476-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
476+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
477477
_sz: uint,
478478
_align: uint) -> bool {
479479
let disr = unsafe {
@@ -484,7 +484,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
484484
}
485485

486486
fn visit_enter_enum_variant(&mut self, _variant: uint,
487-
disr_val: int,
487+
disr_val: Disr,
488488
n_fields: uint,
489489
name: &str) -> bool {
490490
let mut write = false;
@@ -531,7 +531,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
531531
}
532532

533533
fn visit_leave_enum_variant(&mut self, _variant: uint,
534-
_disr_val: int,
534+
_disr_val: Disr,
535535
n_fields: uint,
536536
_name: &str) -> bool {
537537
match self.var_stk[self.var_stk.len() - 1] {
@@ -547,7 +547,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
547547

548548
fn visit_leave_enum(&mut self,
549549
_n_variants: uint,
550-
_get_disr: extern unsafe fn(ptr: *Opaque) -> int,
550+
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
551551
_sz: uint,
552552
_align: uint)
553553
-> bool {

branches/try2/src/libstd/unstable/intrinsics.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ pub struct TyDesc {
7575
#[cfg(not(test))]
7676
pub enum Opaque { }
7777

78+
#[cfg(stage0)]
79+
pub type Disr = int;
80+
#[cfg(not(stage0))]
81+
pub type Disr = u64;
82+
7883
#[lang="ty_visitor"]
7984
#[cfg(not(test))]
8085
pub trait TyVisitor {
@@ -140,19 +145,19 @@ pub trait TyVisitor {
140145
sz: uint, align: uint) -> bool;
141146

142147
fn visit_enter_enum(&mut self, n_variants: uint,
143-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
148+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
144149
sz: uint, align: uint) -> bool;
145150
fn visit_enter_enum_variant(&mut self, variant: uint,
146-
disr_val: int,
151+
disr_val: Disr,
147152
n_fields: uint,
148153
name: &str) -> bool;
149154
fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool;
150155
fn visit_leave_enum_variant(&mut self, variant: uint,
151-
disr_val: int,
156+
disr_val: Disr,
152157
n_fields: uint,
153158
name: &str) -> bool;
154159
fn visit_leave_enum(&mut self, n_variants: uint,
155-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
160+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
156161
sz: uint, align: uint) -> bool;
157162

158163
fn visit_enter_fn(&mut self, purity: uint, proto: uint,

branches/try2/src/test/run-pass/enum-discrim-width-stuff.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ use std::mem;
1313
pub fn main() {
1414
enum E { V = 0x1717171717171717 }
1515
static C: E = V;
16-
let expected: u64 = if mem::size_of::<uint>() < 8 {
17-
0x17171717
18-
} else {
19-
0x1717171717171717
20-
};
21-
assert_eq!(expected, V as u64);
22-
assert_eq!(expected, C as u64);
16+
assert_eq!(V as u64, 0x1717171717171717u64);
17+
assert_eq!(C as u64, 0x1717171717171717u64);
2318
assert_eq!(format!("{:?}", V), ~"V");
2419
assert_eq!(format!("{:?}", C), ~"V");
2520
}

branches/try2/src/test/run-pass/reflect-visit-data.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use std::libc::c_void;
1616
use std::ptr;
1717
use std::mem;
18-
use std::unstable::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Opaque};
18+
use std::unstable::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque};
1919
use std::unstable::raw::Vec;
2020

2121
#[doc = "High-level interfaces to `std::unstable::intrinsics::visit_ty` reflection system."]
@@ -380,7 +380,7 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
380380
}
381381

382382
fn visit_enter_enum(&mut self, n_variants: uint,
383-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
383+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
384384
sz: uint, align: uint)
385385
-> bool {
386386
self.align(align);
@@ -389,7 +389,7 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
389389
}
390390

391391
fn visit_enter_enum_variant(&mut self, variant: uint,
392-
disr_val: int,
392+
disr_val: Disr,
393393
n_fields: uint,
394394
name: &str) -> bool {
395395
if ! self.inner.visit_enter_enum_variant(variant, disr_val,
@@ -405,7 +405,7 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
405405
}
406406

407407
fn visit_leave_enum_variant(&mut self, variant: uint,
408-
disr_val: int,
408+
disr_val: Disr,
409409
n_fields: uint,
410410
name: &str) -> bool {
411411
if ! self.inner.visit_leave_enum_variant(variant, disr_val,
@@ -416,7 +416,7 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
416416
}
417417

418418
fn visit_leave_enum(&mut self, n_variants: uint,
419-
get_disr: extern unsafe fn(ptr: *Opaque) -> int,
419+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
420420
sz: uint, align: uint)
421421
-> bool {
422422
if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) { return false; }
@@ -578,24 +578,24 @@ impl TyVisitor for my_visitor {
578578
_sz: uint, _align: uint) -> bool { true }
579579

580580
fn visit_enter_enum(&mut self, _n_variants: uint,
581-
_get_disr: extern unsafe fn(ptr: *Opaque) -> int,
581+
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
582582
_sz: uint, _align: uint) -> bool {
583583
// FIXME (#3732): this needs to rewind between enum variants, or something.
584584
true
585585
}
586586
fn visit_enter_enum_variant(&mut self, _variant: uint,
587-
_disr_val: int,
587+
_disr_val: Disr,
588588
_n_fields: uint,
589589
_name: &str) -> bool { true }
590590
fn visit_enum_variant_field(&mut self, _i: uint, _offset: uint, inner: *TyDesc) -> bool {
591591
self.visit_inner(inner)
592592
}
593593
fn visit_leave_enum_variant(&mut self, _variant: uint,
594-
_disr_val: int,
594+
_disr_val: Disr,
595595
_n_fields: uint,
596596
_name: &str) -> bool { true }
597597
fn visit_leave_enum(&mut self, _n_variants: uint,
598-
_get_disr: extern unsafe fn(ptr: *Opaque) -> int,
598+
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
599599
_sz: uint, _align: uint) -> bool { true }
600600

601601
fn visit_enter_fn(&mut self, _purity: uint, _proto: uint,

branches/try2/src/test/run-pass/reflect-visit-type.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#[feature(managed_boxes)];
1212

13-
use std::unstable::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Opaque};
13+
use std::unstable::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque};
1414

1515
struct MyVisitor {
1616
types: @mut ~[~str],
@@ -114,22 +114,22 @@ impl TyVisitor for MyVisitor {
114114
_sz: uint, _align: uint) -> bool { true }
115115

116116
fn visit_enter_enum(&mut self, _n_variants: uint,
117-
_get_disr: extern unsafe fn(ptr: *Opaque) -> int,
117+
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
118118
_sz: uint, _align: uint) -> bool { true }
119119
fn visit_enter_enum_variant(&mut self,
120120
_variant: uint,
121-
_disr_val: int,
121+
_disr_val: Disr,
122122
_n_fields: uint,
123123
_name: &str) -> bool { true }
124124
fn visit_enum_variant_field(&mut self, _i: uint, _offset: uint, _inner: *TyDesc) -> bool { true }
125125
fn visit_leave_enum_variant(&mut self,
126126
_variant: uint,
127-
_disr_val: int,
127+
_disr_val: Disr,
128128
_n_fields: uint,
129129
_name: &str) -> bool { true }
130130
fn visit_leave_enum(&mut self,
131131
_n_variants: uint,
132-
_get_disr: extern unsafe fn(ptr: *Opaque) -> int,
132+
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
133133
_sz: uint, _align: uint) -> bool { true }
134134

135135
fn visit_enter_fn(&mut self, _purity: uint, _proto: uint,

0 commit comments

Comments
 (0)