Skip to content

Commit e366ca2

Browse files
committed
---
yaml --- r: 60117 b: refs/heads/master c: 5650779 h: refs/heads/master i: 60115: 73884d7 v: v3
1 parent 12319e1 commit e366ca2

File tree

2 files changed

+59
-14
lines changed

2 files changed

+59
-14
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: 6a44482b175a5486039fd5f2fd32f1051ce80e50
2+
refs/heads/master: 56507798d9eb7bcf95bfca15b3c6f18997adae63
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/libcore/repr.rs

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,30 @@ enum VariantState {
144144
}
145145

146146
pub struct ReprVisitor {
147-
mut ptr: *c_void,
148-
mut ptr_stk: ~[*c_void],
149-
mut var_stk: ~[VariantState],
147+
ptr: @mut *c_void,
148+
ptr_stk: @mut ~[*c_void],
149+
var_stk: @mut ~[VariantState],
150150
writer: @Writer
151151
}
152152
pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor {
153-
ReprVisitor { ptr: ptr,
154-
ptr_stk: ~[],
155-
var_stk: ~[],
156-
writer: writer }
153+
ReprVisitor {
154+
ptr: @mut ptr,
155+
ptr_stk: @mut ~[],
156+
var_stk: @mut ~[],
157+
writer: writer,
158+
}
157159
}
158160

159161
impl MovePtr for ReprVisitor {
160162
#[inline(always)]
161163
fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) {
162-
self.ptr = adjustment(self.ptr);
164+
*self.ptr = adjustment(*self.ptr);
163165
}
164166
fn push_ptr(&self) {
165-
self.ptr_stk.push(self.ptr);
167+
self.ptr_stk.push(*self.ptr);
166168
}
167169
fn pop_ptr(&self) {
168-
self.ptr = self.ptr_stk.pop();
170+
*self.ptr = self.ptr_stk.pop();
169171
}
170172
}
171173

@@ -176,14 +178,14 @@ pub impl ReprVisitor {
176178
#[inline(always)]
177179
fn get<T>(&self, f: &fn(&T)) -> bool {
178180
unsafe {
179-
f(transmute::<*c_void,&T>(copy self.ptr));
181+
f(transmute::<*c_void,&T>(*self.ptr));
180182
}
181183
true
182184
}
183185

184186
#[inline(always)]
185187
fn visit_inner(&self, inner: *TyDesc) -> bool {
186-
self.visit_ptr_inner(self.ptr, inner)
188+
self.visit_ptr_inner(*self.ptr, inner)
187189
}
188190

189191
#[inline(always)]
@@ -482,8 +484,31 @@ impl TyVisitor for ReprVisitor {
482484
true
483485
}
484486

487+
<<<<<<< HEAD
485488
fn visit_enum_variant_field(&self, i: uint, _offset: uint, inner: *TyDesc) -> bool {
486489
match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] {
490+
=======
491+
#[cfg(stage0)]
492+
fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool {
493+
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
494+
Degenerate | TagMatch => {
495+
if i != 0 {
496+
self.writer.write_str(", ");
497+
}
498+
if ! self.visit_inner(inner) {
499+
return false;
500+
}
501+
}
502+
TagMismatch => ()
503+
}
504+
true
505+
}
506+
507+
#[cfg(not(stage0))]
508+
fn visit_enum_variant_field(&self, i: uint, _: uint, inner: *TyDesc)
509+
-> bool {
510+
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
511+
>>>>>>> libcore: Remove mutable fields from repr
487512
Matched => {
488513
if i != 0 {
489514
self.writer.write_str(", ");
@@ -497,11 +522,31 @@ impl TyVisitor for ReprVisitor {
497522
true
498523
}
499524

525+
<<<<<<< HEAD
526+
=======
527+
#[cfg(stage0)]
500528
fn visit_leave_enum_variant(&self, _variant: uint,
501529
_disr_val: int,
502530
n_fields: uint,
503531
_name: &str) -> bool {
504-
match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] {
532+
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
533+
Degenerate | TagMatch => {
534+
if n_fields > 0 {
535+
self.writer.write_char(')');
536+
}
537+
}
538+
TagMismatch => ()
539+
}
540+
true
541+
}
542+
543+
#[cfg(not(stage0))]
544+
>>>>>>> libcore: Remove mutable fields from repr
545+
fn visit_leave_enum_variant(&self, _variant: uint,
546+
_disr_val: int,
547+
n_fields: uint,
548+
_name: &str) -> bool {
549+
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
505550
Matched => {
506551
if n_fields > 0 {
507552
self.writer.write_char(')');

0 commit comments

Comments
 (0)