librustc: Remove pure from libsyntax and librustc.

This commit is contained in:
Patrick Walton 2013-03-22 11:09:13 -07:00
parent ec59ce5796
commit e7c60c141b
31 changed files with 251 additions and 252 deletions

View file

@ -30,8 +30,8 @@ use core::uint;
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
pub trait Pos {
pure fn from_uint(n: uint) -> Self;
pure fn to_uint(&self) -> uint;
fn from_uint(n: uint) -> Self;
fn to_uint(&self) -> uint;
}
/// A byte offset
@ -45,71 +45,71 @@ pub struct CharPos(uint);
// have been unsuccessful
impl Pos for BytePos {
pure fn from_uint(n: uint) -> BytePos { BytePos(n) }
pure fn to_uint(&self) -> uint { **self }
fn from_uint(n: uint) -> BytePos { BytePos(n) }
fn to_uint(&self) -> uint { **self }
}
impl cmp::Eq for BytePos {
pure fn eq(&self, other: &BytePos) -> bool { **self == **other }
pure fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
fn eq(&self, other: &BytePos) -> bool { **self == **other }
fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
}
impl cmp::Ord for BytePos {
pure fn lt(&self, other: &BytePos) -> bool { **self < **other }
pure fn le(&self, other: &BytePos) -> bool { **self <= **other }
pure fn ge(&self, other: &BytePos) -> bool { **self >= **other }
pure fn gt(&self, other: &BytePos) -> bool { **self > **other }
fn lt(&self, other: &BytePos) -> bool { **self < **other }
fn le(&self, other: &BytePos) -> bool { **self <= **other }
fn ge(&self, other: &BytePos) -> bool { **self >= **other }
fn gt(&self, other: &BytePos) -> bool { **self > **other }
}
impl Add<BytePos, BytePos> for BytePos {
pure fn add(&self, rhs: &BytePos) -> BytePos {
fn add(&self, rhs: &BytePos) -> BytePos {
BytePos(**self + **rhs)
}
}
impl Sub<BytePos, BytePos> for BytePos {
pure fn sub(&self, rhs: &BytePos) -> BytePos {
fn sub(&self, rhs: &BytePos) -> BytePos {
BytePos(**self - **rhs)
}
}
impl to_bytes::IterBytes for BytePos {
pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f)
}
}
impl Pos for CharPos {
pure fn from_uint(n: uint) -> CharPos { CharPos(n) }
pure fn to_uint(&self) -> uint { **self }
fn from_uint(n: uint) -> CharPos { CharPos(n) }
fn to_uint(&self) -> uint { **self }
}
impl cmp::Eq for CharPos {
pure fn eq(&self, other: &CharPos) -> bool { **self == **other }
pure fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
fn eq(&self, other: &CharPos) -> bool { **self == **other }
fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
}
impl cmp::Ord for CharPos {
pure fn lt(&self, other: &CharPos) -> bool { **self < **other }
pure fn le(&self, other: &CharPos) -> bool { **self <= **other }
pure fn ge(&self, other: &CharPos) -> bool { **self >= **other }
pure fn gt(&self, other: &CharPos) -> bool { **self > **other }
fn lt(&self, other: &CharPos) -> bool { **self < **other }
fn le(&self, other: &CharPos) -> bool { **self <= **other }
fn ge(&self, other: &CharPos) -> bool { **self >= **other }
fn gt(&self, other: &CharPos) -> bool { **self > **other }
}
impl to_bytes::IterBytes for CharPos {
pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f)
}
}
impl Add<CharPos,CharPos> for CharPos {
pure fn add(&self, rhs: &CharPos) -> CharPos {
fn add(&self, rhs: &CharPos) -> CharPos {
CharPos(**self + **rhs)
}
}
impl Sub<CharPos,CharPos> for CharPos {
pure fn sub(&self, rhs: &CharPos) -> CharPos {
fn sub(&self, rhs: &CharPos) -> CharPos {
CharPos(**self - **rhs)
}
}
@ -132,10 +132,10 @@ pub struct span {
pub struct spanned<T> { node: T, span: span }
impl cmp::Eq for span {
pure fn eq(&self, other: &span) -> bool {
fn eq(&self, other: &span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
}
pure fn ne(&self, other: &span) -> bool { !(*self).eq(other) }
fn ne(&self, other: &span) -> bool { !(*self).eq(other) }
}
impl<S:Encoder> Encodable<S> for span {
@ -149,25 +149,25 @@ impl<D:Decoder> Decodable<D> for span {
}
}
pub pure fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
pub fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
respan(mk_sp(lo, hi), t)
}
pub pure fn respan<T>(sp: span, +t: T) -> spanned<T> {
pub fn respan<T>(sp: span, +t: T) -> spanned<T> {
spanned {node: t, span: sp}
}
pub pure fn dummy_spanned<T>(+t: T) -> spanned<T> {
pub fn dummy_spanned<T>(+t: T) -> spanned<T> {
respan(dummy_sp(), t)
}
/* assuming that we're not in macro expansion */
pub pure fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
pub fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
span {lo: lo, hi: hi, expn_info: None}
}
// make this a const, once the compiler supports it
pub pure fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); }
pub fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); }