libcore: Remove mutable fields from repr
This commit is contained in:
parent
6a44482b17
commit
56507798d9
@ -144,28 +144,30 @@ enum VariantState {
|
||||
}
|
||||
|
||||
pub struct ReprVisitor {
|
||||
mut ptr: *c_void,
|
||||
mut ptr_stk: ~[*c_void],
|
||||
mut var_stk: ~[VariantState],
|
||||
ptr: @mut *c_void,
|
||||
ptr_stk: @mut ~[*c_void],
|
||||
var_stk: @mut ~[VariantState],
|
||||
writer: @Writer
|
||||
}
|
||||
pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor {
|
||||
ReprVisitor { ptr: ptr,
|
||||
ptr_stk: ~[],
|
||||
var_stk: ~[],
|
||||
writer: writer }
|
||||
ReprVisitor {
|
||||
ptr: @mut ptr,
|
||||
ptr_stk: @mut ~[],
|
||||
var_stk: @mut ~[],
|
||||
writer: writer,
|
||||
}
|
||||
}
|
||||
|
||||
impl MovePtr for ReprVisitor {
|
||||
#[inline(always)]
|
||||
fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) {
|
||||
self.ptr = adjustment(self.ptr);
|
||||
*self.ptr = adjustment(*self.ptr);
|
||||
}
|
||||
fn push_ptr(&self) {
|
||||
self.ptr_stk.push(self.ptr);
|
||||
self.ptr_stk.push(*self.ptr);
|
||||
}
|
||||
fn pop_ptr(&self) {
|
||||
self.ptr = self.ptr_stk.pop();
|
||||
*self.ptr = self.ptr_stk.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,14 +178,14 @@ pub impl ReprVisitor {
|
||||
#[inline(always)]
|
||||
fn get<T>(&self, f: &fn(&T)) -> bool {
|
||||
unsafe {
|
||||
f(transmute::<*c_void,&T>(copy self.ptr));
|
||||
f(transmute::<*c_void,&T>(*self.ptr));
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn visit_inner(&self, inner: *TyDesc) -> bool {
|
||||
self.visit_ptr_inner(self.ptr, inner)
|
||||
self.visit_ptr_inner(*self.ptr, inner)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@ -482,8 +484,31 @@ impl TyVisitor for ReprVisitor {
|
||||
true
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
fn visit_enum_variant_field(&self, i: uint, _offset: uint, inner: *TyDesc) -> bool {
|
||||
match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] {
|
||||
=======
|
||||
#[cfg(stage0)]
|
||||
fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool {
|
||||
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
|
||||
Degenerate | TagMatch => {
|
||||
if i != 0 {
|
||||
self.writer.write_str(", ");
|
||||
}
|
||||
if ! self.visit_inner(inner) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
TagMismatch => ()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn visit_enum_variant_field(&self, i: uint, _: uint, inner: *TyDesc)
|
||||
-> bool {
|
||||
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
|
||||
>>>>>>> libcore: Remove mutable fields from repr
|
||||
Matched => {
|
||||
if i != 0 {
|
||||
self.writer.write_str(", ");
|
||||
@ -497,11 +522,31 @@ impl TyVisitor for ReprVisitor {
|
||||
true
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#[cfg(stage0)]
|
||||
fn visit_leave_enum_variant(&self, _variant: uint,
|
||||
_disr_val: int,
|
||||
n_fields: uint,
|
||||
_name: &str) -> bool {
|
||||
match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] {
|
||||
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
|
||||
Degenerate | TagMatch => {
|
||||
if n_fields > 0 {
|
||||
self.writer.write_char(')');
|
||||
}
|
||||
}
|
||||
TagMismatch => ()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
>>>>>>> libcore: Remove mutable fields from repr
|
||||
fn visit_leave_enum_variant(&self, _variant: uint,
|
||||
_disr_val: int,
|
||||
n_fields: uint,
|
||||
_name: &str) -> bool {
|
||||
match self.var_stk[vec::uniq_len(&const *self.var_stk) - 1] {
|
||||
Matched => {
|
||||
if n_fields > 0 {
|
||||
self.writer.write_char(')');
|
||||
|
Loading…
x
Reference in New Issue
Block a user