librustc: Update the serializer to work properly with INHTWAMA, removing mutable fields in the process

This commit is contained in:
Patrick Walton
2013-05-01 17:54:54 -07:00
parent 6f2e429041
commit dc5df61bc1
20 changed files with 5290 additions and 504 deletions

View File

@@ -70,19 +70,37 @@ pub type Name = uint;
// with a macro expansion
pub type Mrk = uint;
#[cfg(stage0)]
impl<S:Encoder> Encodable<S> for ident {
fn encode(&self, s: &S) {
let intr = match unsafe {
task::local_data::local_data_get(interner_key!())
} {
None => fail!(~"encode: TLS interner not set up"),
Some(intr) => intr
};
unsafe {
let intr =
match task::local_data::local_data_get(interner_key!()) {
None => fail!(~"encode: TLS interner not set up"),
Some(intr) => intr
};
s.emit_str(*(*intr).get(*self));
s.emit_str(*(*intr).get(*self));
}
}
}
#[cfg(not(stage0))]
impl<S:Encoder> Encodable<S> for ident {
fn encode(&self, s: &mut S) {
unsafe {
let intr =
match task::local_data::local_data_get(interner_key!()) {
None => fail!(~"encode: TLS interner not set up"),
Some(intr) => intr
};
s.emit_str(*(*intr).get(*self));
}
}
}
#[cfg(stage0)]
impl<D:Decoder> Decodable<D> for ident {
fn decode(d: &D) -> ident {
let intr = match unsafe {
@@ -96,6 +114,20 @@ impl<D:Decoder> Decodable<D> for ident {
}
}
#[cfg(not(stage0))]
impl<D:Decoder> Decodable<D> for ident {
fn decode(d: &mut D) -> ident {
let intr = match unsafe {
task::local_data::local_data_get(interner_key!())
} {
None => fail!(~"decode: TLS interner not set up"),
Some(intr) => intr
};
(*intr).intern(@d.read_str())
}
}
impl to_bytes::IterBytes for ident {
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
self.repr.iter_bytes(lsb0, f)