cond: &'self sync::Condvar<'self>
}
-pub impl<'self> Condvar<'self> {
+impl<'self> Condvar<'self> {
/// Atomically exit the associated ARC and block until a signal is sent.
#[inline(always)]
- fn wait(&self) { self.wait_on(0) }
+ pub fn wait(&self) { self.wait_on(0) }
/**
* Atomically exit the associated ARC and block on a specified condvar
* wait() is equivalent to wait_on(0).
*/
#[inline(always)]
- fn wait_on(&self, condvar_id: uint) {
+ pub fn wait_on(&self, condvar_id: uint) {
assert!(!*self.failed);
self.cond.wait_on(condvar_id);
// This is why we need to wrap sync::condvar.
/// Wake up a blocked task. Returns false if there was no blocked task.
#[inline(always)]
- fn signal(&self) -> bool { self.signal_on(0) }
+ pub fn signal(&self) -> bool { self.signal_on(0) }
/**
* Wake up a blocked task on a specified condvar (as
* sync::cond.signal_on). Returns false if there was no blocked task.
*/
#[inline(always)]
- fn signal_on(&self, condvar_id: uint) -> bool {
+ pub fn signal_on(&self, condvar_id: uint) -> bool {
assert!(!*self.failed);
self.cond.signal_on(condvar_id)
}
/// Wake up all blocked tasks. Returns the number of tasks woken.
#[inline(always)]
- fn broadcast(&self) -> uint { self.broadcast_on(0) }
+ pub fn broadcast(&self) -> uint { self.broadcast_on(0) }
/**
* Wake up all blocked tasks on a specified condvar (as
* sync::cond.broadcast_on). Returns Returns the number of tasks woken.
*/
#[inline(always)]
- fn broadcast_on(&self, condvar_id: uint) -> uint {
+ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
assert!(!*self.failed);
self.cond.broadcast_on(condvar_id)
}
* Access the underlying data in an atomically reference counted
* wrapper.
*/
-pub impl<T:Const+Owned> ARC<T> {
- fn get<'a>(&'a self) -> &'a T {
+impl<T:Const+Owned> ARC<T> {
+ pub fn get<'a>(&'a self) -> &'a T {
unsafe { &*self.x.get_immut() }
}
}
}
}
-pub impl<T:Owned> MutexARC<T> {
+impl<T:Owned> MutexARC<T> {
/**
* Access the underlying mutable data with mutual exclusion from other
* blocked on the mutex) will also fail immediately.
*/
#[inline(always)]
- unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
+ pub unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
unsafe {
let state = self.x.get();
// Borrowck would complain about this if the function were
/// As access(), but with a condvar, as sync::mutex.lock_cond().
#[inline(always)]
- unsafe fn access_cond<'x, 'c, U>(
- &self,
- blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U
- {
+ pub unsafe fn access_cond<'x, 'c, U>(&self,
+ blk: &fn(x: &'x mut T,
+ c: &'c Condvar) -> U)
+ -> U {
let state = self.x.get();
do (&(*state).lock).lock_cond |cond| {
check_poison(true, (*state).failed);
RWARC { x: UnsafeAtomicRcBox::new(data), cant_nest: () }
}
-pub impl<T:Const + Owned> RWARC<T> {
+impl<T:Const + Owned> RWARC<T> {
/// Duplicate a rwlock-protected ARC, as arc::clone.
- fn clone(&self) -> RWARC<T> {
- RWARC { x: self.x.clone(),
- cant_nest: () }
+ pub fn clone(&self) -> RWARC<T> {
+ RWARC {
+ x: self.x.clone(),
+ cant_nest: (),
+ }
}
}
-pub impl<T:Const + Owned> RWARC<T> {
+impl<T:Const + Owned> RWARC<T> {
/**
* Access the underlying data mutably. Locks the rwlock in write mode;
* other readers and writers will block.
* poison the ARC, so subsequent readers and writers will both also fail.
*/
#[inline(always)]
- fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
+ pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
unsafe {
let state = self.x.get();
do (*borrow_rwlock(state)).write {
}
}
}
+
/// As write(), but with a condvar, as sync::rwlock.write_cond().
#[inline(always)]
- fn write_cond<'x, 'c, U>(&self,
- blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
- -> U {
+ pub fn write_cond<'x, 'c, U>(&self,
+ blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
+ -> U {
unsafe {
let state = self.x.get();
do (*borrow_rwlock(state)).write_cond |cond| {
}
}
}
+
/**
* Access the underlying data immutably. May run concurrently with other
* reading tasks.
* Failing will unlock the ARC while unwinding. However, unlike all other
* access modes, this will not poison the ARC.
*/
- fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
+ pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
unsafe {
let state = self.x.get();
do (*state).lock.read {
* }
* ~~~
*/
- fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
+ pub fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
unsafe {
let state = self.x.get();
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
}
/// To be called inside of the write_downgrade block.
- fn downgrade<'a>(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> {
+ pub fn downgrade<'a>(&self, token: RWWriteMode<'a, T>)
+ -> RWReadMode<'a, T> {
unsafe {
// The rwlock should assert that the token belongs to us for us.
let state = self.x.get();
token: sync::RWlockReadMode<'self>,
}
-pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
+impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
/// Access the pre-downgrade RWARC in write mode.
- fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
+ pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
match *self {
RWWriteMode {
data: &ref mut data,
}
}
}
+
/// Access the pre-downgrade RWARC in write mode with a condvar.
- fn write_cond<'x, 'c, U>(&mut self,
- blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
- -> U {
+ pub fn write_cond<'x, 'c, U>(&mut self,
+ blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
+ -> U {
match *self {
RWWriteMode {
data: &ref mut data,
}
}
-pub impl<'self, T:Const + Owned> RWReadMode<'self, T> {
+impl<'self, T:Const + Owned> RWReadMode<'self, T> {
/// Access the post-downgrade rwlock in read mode.
- fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
+ pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
match *self {
RWReadMode {
data: data,
(transmute(p & !1), p & 1 == 1)
}
-pub impl Arena {
+impl Arena {
// Functions for the POD part of the arena
- priv fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
+ fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.pod_head.data);
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
}
#[inline(always)]
- priv fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
+ fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
unsafe {
// XXX: Borrow check
let head = transmute_mut_region(&mut self.pod_head);
}
#[inline(always)]
- priv fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
+ fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
unsafe {
let tydesc = sys::get_type_desc::<T>();
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
}
// Functions for the non-POD part of the arena
- priv fn alloc_nonpod_grow(&mut self, n_bytes: uint, align: uint)
- -> (*u8, *u8) {
+ fn alloc_nonpod_grow(&mut self, n_bytes: uint, align: uint)
+ -> (*u8, *u8) {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.head.data);
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
}
#[inline(always)]
- priv fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
- -> (*u8, *u8) {
+ fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
+ -> (*u8, *u8) {
unsafe {
let head = transmute_mut_region(&mut self.head);
}
#[inline(always)]
- priv fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
+ fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
unsafe {
let tydesc = sys::get_type_desc::<T>();
let (ty_ptr, ptr) =
// The external interface
#[inline(always)]
- fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
+ pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
unsafe {
// XXX: Borrow check
let this = transmute_mut_region(self);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#[allow(missing_doc)];
+
use core::prelude::*;
use core::cmp;
(1 << nbits) - 1
}
-pub impl SmallBitv {
- fn new(bits: uint) -> SmallBitv {
+impl SmallBitv {
+ pub fn new(bits: uint) -> SmallBitv {
SmallBitv {bits: bits}
}
#[inline(always)]
- fn bits_op(&mut self, right_bits: uint, nbits: uint,
- f: &fn(uint, uint) -> uint) -> bool {
+ pub fn bits_op(&mut self,
+ right_bits: uint,
+ nbits: uint,
+ f: &fn(uint, uint) -> uint)
+ -> bool {
let mask = small_mask(nbits);
let old_b: uint = self.bits;
let new_b = f(old_b, right_bits);
}
#[inline(always)]
- fn union(&mut self, s: &SmallBitv, nbits: uint) -> bool {
+ pub fn union(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |u1, u2| u1 | u2)
}
#[inline(always)]
- fn intersect(&mut self, s: &SmallBitv, nbits: uint) -> bool {
+ pub fn intersect(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |u1, u2| u1 & u2)
}
#[inline(always)]
- fn become(&mut self, s: &SmallBitv, nbits: uint) -> bool {
+ pub fn become(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |_u1, u2| u2)
}
#[inline(always)]
- fn difference(&mut self, s: &SmallBitv, nbits: uint) -> bool {
+ pub fn difference(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |u1, u2| u1 & !u2)
}
#[inline(always)]
- fn get(&self, i: uint) -> bool {
+ pub fn get(&self, i: uint) -> bool {
(self.bits & (1 << i)) != 0
}
#[inline(always)]
- fn set(&mut self, i: uint, x: bool) {
+ pub fn set(&mut self, i: uint, x: bool) {
if x {
self.bits |= 1<<i;
}
}
#[inline(always)]
- fn equals(&self, b: &SmallBitv, nbits: uint) -> bool {
+ pub fn equals(&self, b: &SmallBitv, nbits: uint) -> bool {
let mask = small_mask(nbits);
mask & self.bits == mask & b.bits
}
#[inline(always)]
- fn clear(&mut self) { self.bits = 0; }
+ pub fn clear(&mut self) { self.bits = 0; }
#[inline(always)]
- fn set_all(&mut self) { self.bits = !0; }
+ pub fn set_all(&mut self) { self.bits = !0; }
#[inline(always)]
- fn is_true(&self, nbits: uint) -> bool {
+ pub fn is_true(&self, nbits: uint) -> bool {
small_mask(nbits) & !self.bits == 0
}
#[inline(always)]
- fn is_false(&self, nbits: uint) -> bool {
+ pub fn is_false(&self, nbits: uint) -> bool {
small_mask(nbits) & self.bits == 0
}
#[inline(always)]
- fn invert(&mut self) { self.bits = !self.bits; }
-
+ pub fn invert(&mut self) { self.bits = !self.bits; }
}
struct BigBitv {
}
}
-pub impl BigBitv {
- fn new(storage: ~[uint]) -> BigBitv {
+impl BigBitv {
+ pub fn new(storage: ~[uint]) -> BigBitv {
BigBitv {storage: storage}
}
#[inline(always)]
- fn process(&mut self, b: &BigBitv, nbits: uint,
- op: &fn(uint, uint) -> uint) -> bool {
+ pub fn process(&mut self,
+ b: &BigBitv,
+ nbits: uint,
+ op: &fn(uint, uint) -> uint)
+ -> bool {
let len = b.storage.len();
assert_eq!(self.storage.len(), len);
let mut changed = false;
}
#[inline(always)]
- fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
+ pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
uint::range(0, self.storage.len(), |i| op(&mut self.storage[i]))
}
#[inline(always)]
- fn invert(&mut self) { for self.each_storage |w| { *w = !*w } }
+ pub fn invert(&mut self) { for self.each_storage |w| { *w = !*w } }
#[inline(always)]
- fn union(&mut self, b: &BigBitv, nbits: uint) -> bool {
+ pub fn union(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |w1, w2| w1 | w2)
}
#[inline(always)]
- fn intersect(&mut self, b: &BigBitv, nbits: uint) -> bool {
+ pub fn intersect(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |w1, w2| w1 & w2)
}
#[inline(always)]
- fn become(&mut self, b: &BigBitv, nbits: uint) -> bool {
+ pub fn become(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |_, w| w)
}
#[inline(always)]
- fn difference(&mut self, b: &BigBitv, nbits: uint) -> bool {
+ pub fn difference(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |w1, w2| w1 & !w2)
}
#[inline(always)]
- fn get(&self, i: uint) -> bool {
+ pub fn get(&self, i: uint) -> bool {
let w = i / uint::bits;
let b = i % uint::bits;
let x = 1 & self.storage[w] >> b;
}
#[inline(always)]
- fn set(&mut self, i: uint, x: bool) {
+ pub fn set(&mut self, i: uint, x: bool) {
let w = i / uint::bits;
let b = i % uint::bits;
let flag = 1 << b;
}
#[inline(always)]
- fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
+ pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
let len = b.storage.len();
for uint::iterate(0, len) |i| {
let mask = big_mask(nbits, i);
}
return true;
}
-
}
enum BitvVariant { Big(~BigBitv), Small(~SmallBitv) }
fail!("Tried to do operation on bit vectors with different sizes");
}
-priv impl Bitv {
-
+impl Bitv {
#[inline(always)]
fn do_op(&mut self, op: Op, other: &Bitv) -> bool {
if self.nbits != other.nbits {
}
-pub impl Bitv {
- fn new(nbits: uint, init: bool) -> Bitv {
+impl Bitv {
+ pub fn new(nbits: uint, init: bool) -> Bitv {
let rep = if nbits <= uint::bits {
Small(~SmallBitv::new(if init {!0} else {0}))
}
* the same length. Returns 'true' if `self` changed.
*/
#[inline(always)]
- fn union(&mut self, v1: &Bitv) -> bool { self.do_op(Union, v1) }
+ pub fn union(&mut self, v1: &Bitv) -> bool { self.do_op(Union, v1) }
/**
* Calculates the intersection of two bitvectors
* must be the same length. Returns 'true' if `self` changed.
*/
#[inline(always)]
- fn intersect(&mut self, v1: &Bitv) -> bool { self.do_op(Intersect, v1) }
+ pub fn intersect(&mut self, v1: &Bitv) -> bool {
+ self.do_op(Intersect, v1)
+ }
/**
* Assigns the value of `v1` to `self`
* changed
*/
#[inline(always)]
- fn assign(&mut self, v: &Bitv) -> bool { self.do_op(Assign, v) }
+ pub fn assign(&mut self, v: &Bitv) -> bool { self.do_op(Assign, v) }
/// Retrieve the value at index `i`
#[inline(always)]
- fn get(&self, i: uint) -> bool {
- assert!((i < self.nbits));
- match self.rep {
- Big(ref b) => b.get(i),
- Small(ref s) => s.get(i)
- }
+ pub fn get(&self, i: uint) -> bool {
+ assert!((i < self.nbits));
+ match self.rep {
+ Big(ref b) => b.get(i),
+ Small(ref s) => s.get(i)
+ }
}
/**
* `i` must be less than the length of the bitvector.
*/
#[inline(always)]
- fn set(&mut self, i: uint, x: bool) {
+ pub fn set(&mut self, i: uint, x: bool) {
assert!((i < self.nbits));
match self.rep {
Big(ref mut b) => b.set(i, x),
* bitvectors contain identical elements.
*/
#[inline(always)]
- fn equal(&self, v1: &Bitv) -> bool {
+ pub fn equal(&self, v1: &Bitv) -> bool {
if self.nbits != v1.nbits { return false; }
match self.rep {
Small(ref b) => match v1.rep {
/// Set all bits to 0
#[inline(always)]
- fn clear(&mut self) {
+ pub fn clear(&mut self) {
match self.rep {
Small(ref mut b) => b.clear(),
Big(ref mut s) => for s.each_storage() |w| { *w = 0u }
/// Set all bits to 1
#[inline(always)]
- fn set_all(&mut self) {
+ pub fn set_all(&mut self) {
match self.rep {
Small(ref mut b) => b.set_all(),
Big(ref mut s) => for s.each_storage() |w| { *w = !0u } }
/// Invert all bits
#[inline(always)]
- fn invert(&mut self) {
+ pub fn invert(&mut self) {
match self.rep {
Small(ref mut b) => b.invert(),
Big(ref mut s) => for s.each_storage() |w| { *w = !*w } }
* Returns `true` if `v0` was changed.
*/
#[inline(always)]
- fn difference(&mut self, v: &Bitv) -> bool { self.do_op(Difference, v) }
+ pub fn difference(&mut self, v: &Bitv) -> bool {
+ self.do_op(Difference, v)
+ }
/// Returns true if all bits are 1
#[inline(always)]
- fn is_true(&self) -> bool {
+ pub fn is_true(&self) -> bool {
match self.rep {
Small(ref b) => b.is_true(self.nbits),
_ => {
}
#[inline(always)]
- fn each(&self, f: &fn(bool) -> bool) -> bool {
+ pub fn each(&self, f: &fn(bool) -> bool) -> bool {
let mut i = 0;
while i < self.nbits {
if !f(self.get(i)) { return false; }
}
/// Returns true if all bits are 0
- fn is_false(&self) -> bool {
+ pub fn is_false(&self) -> bool {
match self.rep {
Small(ref b) => b.is_false(self.nbits),
Big(_) => {
}
}
- fn init_to_vec(&self, i: uint) -> uint {
+ pub fn init_to_vec(&self, i: uint) -> uint {
return if self.get(i) { 1 } else { 0 };
}
*
* Each uint in the resulting vector has either value 0u or 1u.
*/
- fn to_vec(&self) -> ~[uint] {
+ pub fn to_vec(&self) -> ~[uint] {
vec::from_fn(self.nbits, |x| self.init_to_vec(x))
}
* size of the bitv is not a multiple of 8 then trailing bits
* will be filled-in with false/0
*/
- fn to_bytes(&self) -> ~[u8] {
-
+ pub fn to_bytes(&self) -> ~[u8] {
fn bit (bitv: &Bitv, byte: uint, bit: uint) -> u8 {
let offset = byte * 8 + bit;
if offset >= bitv.nbits {
/**
* Transform self into a [bool] by turning each bit into a bool
*/
- fn to_bools(&self) -> ~[bool] {
+ pub fn to_bools(&self) -> ~[bool] {
vec::from_fn(self.nbits, |i| self[i])
}
* The resulting string has the same length as `self`, and each
* character is either '0' or '1'.
*/
- fn to_str(&self) -> ~str {
+ pub fn to_str(&self) -> ~str {
let mut rs = ~"";
for self.each() |i| { if i { rs += "1"; } else { rs += "0"; } };
rs
* The uint vector is expected to only contain the values 0u and 1u. Both
* the bitvector and vector must have the same length
*/
- fn eq_vec(&self, v: ~[uint]) -> bool {
+ pub fn eq_vec(&self, v: ~[uint]) -> bool {
assert_eq!(self.nbits, v.len());
let mut i = 0;
while i < self.nbits {
true
}
- fn ones(&self, f: &fn(uint) -> bool) -> bool {
+ pub fn ones(&self, f: &fn(uint) -> bool) -> bool {
uint::range(0, self.nbits, |i| !self.get(i) || f(i))
}
}
}
}
-
}
/**
priv bitv: BigBitv
}
-pub impl BitvSet {
+impl BitvSet {
/// Creates a new bit vector set with initially no contents
- fn new() -> BitvSet {
+ pub fn new() -> BitvSet {
BitvSet{ size: 0, bitv: BigBitv::new(~[0]) }
}
/// Creates a new bit vector set from the given bit vector
- fn from_bitv(bitv: Bitv) -> BitvSet {
+ pub fn from_bitv(bitv: Bitv) -> BitvSet {
let mut size = 0;
for bitv.ones |_| {
size += 1;
/// Returns the capacity in bits for this bit vector. Inserting any
/// element less than this amount will not trigger a resizing.
- fn capacity(&self) -> uint { self.bitv.storage.len() * uint::bits }
+ pub fn capacity(&self) -> uint { self.bitv.storage.len() * uint::bits }
/// Consumes this set to return the underlying bit vector
- fn unwrap(self) -> Bitv {
+ pub fn unwrap(self) -> Bitv {
let cap = self.capacity();
let BitvSet{bitv, _} = self;
return Bitv{ nbits:cap, rep: Big(~bitv) };
}
#[inline(always)]
- priv fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
+ fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
fn nbits(mut w: uint) -> uint {
let mut bits = 0;
for uint::bits.times {
}
/// Union in-place with the specified other bit vector
- fn union_with(&mut self, other: &BitvSet) {
+ pub fn union_with(&mut self, other: &BitvSet) {
self.other_op(other, |w1, w2| w1 | w2);
}
/// Intersect in-place with the specified other bit vector
- fn intersect_with(&mut self, other: &BitvSet) {
+ pub fn intersect_with(&mut self, other: &BitvSet) {
self.other_op(other, |w1, w2| w1 & w2);
}
/// Difference in-place with the specified other bit vector
- fn difference_with(&mut self, other: &BitvSet) {
+ pub fn difference_with(&mut self, other: &BitvSet) {
self.other_op(other, |w1, w2| w1 & !w2);
}
/// Symmetric difference in-place with the specified other bit vector
- fn symmetric_difference_with(&mut self, other: &BitvSet) {
+ pub fn symmetric_difference_with(&mut self, other: &BitvSet) {
self.other_op(other, |w1, w2| w1 ^ w2);
}
}
}
}
-priv impl BitvSet {
+impl BitvSet {
/// Visits each of the words that the two bit vectors (self and other)
/// both have in common. The three yielded arguments are (bit location,
/// w1, w2) where the bit location is the number of bits offset so far,
*/
+#[allow(missing_doc)];
+
use core::prelude::*;
use core::comm::{GenericChan, GenericSmartChan, GenericPort};
}
// Allow these methods to be used without import:
-pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
- fn send(&self, x: T) {
+impl<T:Owned,U:Owned> DuplexStream<T, U> {
+ pub fn send(&self, x: T) {
self.chan.send(x)
}
- fn try_send(&self, x: T) -> bool {
+ pub fn try_send(&self, x: T) -> bool {
self.chan.try_send(x)
}
- fn recv(&self, ) -> U {
+ pub fn recv(&self, ) -> U {
self.port.recv()
}
- fn try_recv(&self) -> Option<U> {
+ pub fn try_recv(&self) -> Option<U> {
self.port.try_recv()
}
- fn peek(&self) -> bool {
+ pub fn peek(&self) -> bool {
self.port.peek()
}
}
}
}
-pub impl<T> Deque<T> {
+impl<T> Deque<T> {
/// Create an empty Deque
- fn new() -> Deque<T> {
+ pub fn new() -> Deque<T> {
Deque{nelts: 0, lo: 0, hi: 0,
elts: vec::from_fn(initial_capacity, |_| None)}
}
/// Return a reference to the first element in the deque
///
/// Fails if the deque is empty
- fn peek_front<'a>(&'a self) -> &'a T { get(self.elts, self.lo) }
+ pub fn peek_front<'a>(&'a self) -> &'a T { get(self.elts, self.lo) }
/// Return a reference to the last element in the deque
///
/// Fails if the deque is empty
- fn peek_back<'a>(&'a self) -> &'a T { get(self.elts, self.hi - 1u) }
+ pub fn peek_back<'a>(&'a self) -> &'a T { get(self.elts, self.hi - 1u) }
/// Retrieve an element in the deque by index
///
/// Fails if there is no element with the given index
- fn get<'a>(&'a self, i: int) -> &'a T {
+ pub fn get<'a>(&'a self, i: int) -> &'a T {
let idx = (self.lo + (i as uint)) % self.elts.len();
get(self.elts, idx)
}
/// Iterate over the elements in the deque
- fn each(&self, f: &fn(&T) -> bool) -> bool {
+ pub fn each(&self, f: &fn(&T) -> bool) -> bool {
self.eachi(|_i, e| f(e))
}
/// Iterate over the elements in the deque by index
- fn eachi(&self, f: &fn(uint, &T) -> bool) -> bool {
+ pub fn eachi(&self, f: &fn(uint, &T) -> bool) -> bool {
uint::range(0, self.nelts, |i| f(i, self.get(i as int)))
}
/// Remove and return the first element in the deque
///
/// Fails if the deque is empty
- fn pop_front(&mut self) -> T {
+ pub fn pop_front(&mut self) -> T {
let result = self.elts[self.lo].swap_unwrap();
self.lo = (self.lo + 1u) % self.elts.len();
self.nelts -= 1u;
/// Remove and return the last element in the deque
///
/// Fails if the deque is empty
- fn pop_back(&mut self) -> T {
+ pub fn pop_back(&mut self) -> T {
if self.hi == 0u {
self.hi = self.elts.len() - 1u;
} else { self.hi -= 1u; }
}
/// Prepend an element to the deque
- fn add_front(&mut self, t: T) {
+ pub fn add_front(&mut self, t: T) {
let oldlo = self.lo;
if self.lo == 0u {
self.lo = self.elts.len() - 1u;
}
/// Append an element to the deque
- fn add_back(&mut self, t: T) {
+ pub fn add_back(&mut self, t: T) {
if self.lo == self.hi && self.nelts != 0u {
self.elts = grow(self.nelts, self.lo, self.elts);
self.lo = 0u;
/// # Arguments
///
/// * n - The number of elements to reserve space for
- fn reserve(&mut self, n: uint) {
+ pub fn reserve(&mut self, n: uint) {
vec::reserve(&mut self.elts, n);
}
/// # Arguments
///
/// * n - The number of elements to reserve space for
- fn reserve_at_least(&mut self, n: uint) {
+ pub fn reserve_at_least(&mut self, n: uint) {
vec::reserve_at_least(&mut self.elts, n);
}
}
tl: DListLink<T>,
}
-priv impl<T> DListNode<T> {
+impl<T> DListNode<T> {
fn assert_links(@mut self) {
match self.next {
Some(neighbour) => match neighbour.prev {
}
}
-pub impl<T> DListNode<T> {
+impl<T> DListNode<T> {
/// Get the next node in the list, if there is one.
- fn next_link(@mut self) -> DListLink<T> {
+ pub fn next_link(@mut self) -> DListLink<T> {
self.assert_links();
self.next
}
/// Get the next node in the list, failing if there isn't one.
- fn next_node(@mut self) -> @mut DListNode<T> {
+ pub fn next_node(@mut self) -> @mut DListNode<T> {
match self.next_link() {
Some(nobe) => nobe,
None => fail!("This dlist node has no next neighbour.")
}
}
/// Get the previous node in the list, if there is one.
- fn prev_link(@mut self) -> DListLink<T> {
+ pub fn prev_link(@mut self) -> DListLink<T> {
self.assert_links();
self.prev
}
/// Get the previous node in the list, failing if there isn't one.
- fn prev_node(@mut self) -> @mut DListNode<T> {
+ pub fn prev_node(@mut self) -> @mut DListNode<T> {
match self.prev_link() {
Some(nobe) => nobe,
None => fail!("This dlist node has no previous neighbour.")
result
}
-priv impl<T> DList<T> {
+impl<T> DList<T> {
fn new_link(data: T) -> DListLink<T> {
Some(@mut DListNode {
data: data,
}
}
-pub impl<T> DList<T> {
+impl<T> DList<T> {
/// Get the size of the list. O(1).
- fn len(@mut self) -> uint { self.size }
+ pub fn len(@mut self) -> uint { self.size }
/// Returns true if the list is empty. O(1).
- fn is_empty(@mut self) -> bool { self.len() == 0 }
+ pub fn is_empty(@mut self) -> bool { self.len() == 0 }
/// Add data to the head of the list. O(1).
- fn push_head(@mut self, data: T) {
+ pub fn push_head(@mut self, data: T) {
self.add_head(DList::new_link(data));
}
/**
* Add data to the head of the list, and get the new containing
* node. O(1).
*/
- fn push_head_n(@mut self, data: T) -> @mut DListNode<T> {
+ pub fn push_head_n(@mut self, data: T) -> @mut DListNode<T> {
let nobe = DList::new_link(data);
self.add_head(nobe);
nobe.get()
}
/// Add data to the tail of the list. O(1).
- fn push(@mut self, data: T) {
+ pub fn push(@mut self, data: T) {
self.add_tail(DList::new_link(data));
}
/**
* Add data to the tail of the list, and get the new containing
* node. O(1).
*/
- fn push_n(@mut self, data: T) -> @mut DListNode<T> {
+ pub fn push_n(@mut self, data: T) -> @mut DListNode<T> {
let nobe = DList::new_link(data);
self.add_tail(nobe);
nobe.get()
* Insert data into the middle of the list, left of the given node.
* O(1).
*/
- fn insert_before(@mut self, data: T, neighbour: @mut DListNode<T>) {
+ pub fn insert_before(@mut self, data: T, neighbour: @mut DListNode<T>) {
self.insert_left(DList::new_link(data), neighbour);
}
/**
* Insert an existing node in the middle of the list, left of the
* given node. O(1).
*/
- fn insert_n_before(@mut self,
- nobe: @mut DListNode<T>,
- neighbour: @mut DListNode<T>) {
+ pub fn insert_n_before(@mut self,
+ nobe: @mut DListNode<T>,
+ neighbour: @mut DListNode<T>) {
self.make_mine(nobe);
self.insert_left(Some(nobe), neighbour);
}
* Insert data in the middle of the list, left of the given node,
* and get its containing node. O(1).
*/
- fn insert_before_n(
- @mut self,
- data: T,
- neighbour: @mut DListNode<T>
- ) -> @mut DListNode<T> {
+ pub fn insert_before_n(@mut self,
+ data: T,
+ neighbour: @mut DListNode<T>)
+ -> @mut DListNode<T> {
let nobe = DList::new_link(data);
self.insert_left(nobe, neighbour);
nobe.get()
* Insert data into the middle of the list, right of the given node.
* O(1).
*/
- fn insert_after(@mut self, data: T, neighbour: @mut DListNode<T>) {
+ pub fn insert_after(@mut self, data: T, neighbour: @mut DListNode<T>) {
self.insert_right(neighbour, DList::new_link(data));
}
/**
* Insert an existing node in the middle of the list, right of the
* given node. O(1).
*/
- fn insert_n_after(@mut self,
- nobe: @mut DListNode<T>,
- neighbour: @mut DListNode<T>) {
+ pub fn insert_n_after(@mut self,
+ nobe: @mut DListNode<T>,
+ neighbour: @mut DListNode<T>) {
self.make_mine(nobe);
self.insert_right(neighbour, Some(nobe));
}
* Insert data in the middle of the list, right of the given node,
* and get its containing node. O(1).
*/
- fn insert_after_n(
- @mut self,
- data: T,
- neighbour: @mut DListNode<T>
- ) -> @mut DListNode<T> {
+ pub fn insert_after_n(@mut self,
+ data: T,
+ neighbour: @mut DListNode<T>)
+ -> @mut DListNode<T> {
let nobe = DList::new_link(data);
self.insert_right(neighbour, nobe);
nobe.get()
}
/// Remove a node from the head of the list. O(1).
- fn pop_n(@mut self) -> DListLink<T> {
+ pub fn pop_n(@mut self) -> DListLink<T> {
let hd = self.peek_n();
hd.map(|nobe| self.unlink(*nobe));
hd
}
/// Remove a node from the tail of the list. O(1).
- fn pop_tail_n(@mut self) -> DListLink<T> {
+ pub fn pop_tail_n(@mut self) -> DListLink<T> {
let tl = self.peek_tail_n();
tl.map(|nobe| self.unlink(*nobe));
tl
}
/// Get the node at the list's head. O(1).
- fn peek_n(@mut self) -> DListLink<T> { self.hd }
+ pub fn peek_n(@mut self) -> DListLink<T> { self.hd }
/// Get the node at the list's tail. O(1).
- fn peek_tail_n(@mut self) -> DListLink<T> { self.tl }
+ pub fn peek_tail_n(@mut self) -> DListLink<T> { self.tl }
/// Get the node at the list's head, failing if empty. O(1).
- fn head_n(@mut self) -> @mut DListNode<T> {
+ pub fn head_n(@mut self) -> @mut DListNode<T> {
match self.hd {
Some(nobe) => nobe,
None => fail!("Attempted to get the head of an empty dlist.")
}
}
/// Get the node at the list's tail, failing if empty. O(1).
- fn tail_n(@mut self) -> @mut DListNode<T> {
+ pub fn tail_n(@mut self) -> @mut DListNode<T> {
match self.tl {
Some(nobe) => nobe,
None => fail!("Attempted to get the tail of an empty dlist.")
}
/// Remove a node from anywhere in the list. O(1).
- fn remove(@mut self, nobe: @mut DListNode<T>) { self.unlink(nobe); }
+ pub fn remove(@mut self, nobe: @mut DListNode<T>) { self.unlink(nobe); }
/**
* Empty another list onto the end of this list, joining this list's tail
* to the other list's head. O(1).
*/
- fn append(@mut self, them: @mut DList<T>) {
+ pub fn append(@mut self, them: @mut DList<T>) {
if managed::mut_ptr_eq(self, them) {
fail!("Cannot append a dlist to itself!")
}
* Empty another list onto the start of this list, joining the other
* list's tail to this list's head. O(1).
*/
- fn prepend(@mut self, them: @mut DList<T>) {
+ pub fn prepend(@mut self, them: @mut DList<T>) {
if managed::mut_ptr_eq(self, them) {
fail!("Cannot prepend a dlist to itself!")
}
}
/// Reverse the list's elements in place. O(n).
- fn reverse(@mut self) {
+ pub fn reverse(@mut self) {
do self.hd.while_some |nobe| {
let next_nobe = nobe.next;
self.remove(nobe);
* Remove everything from the list. This is important because the cyclic
* links won't otherwise be automatically refcounted-collected. O(n).
*/
- fn clear(@mut self) {
+ pub fn clear(@mut self) {
// Cute as it would be to simply detach the list and proclaim "O(1)!",
// the GC would still be a hidden O(n). Better to be honest about it.
while !self.is_empty() {
}
/// Iterate over nodes.
- fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) -> bool {
+ pub fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) -> bool {
let mut link = self.peek_n();
while link.is_some() {
let nobe = link.get();
}
/// Check data structure integrity. O(n).
- fn assert_consistent(@mut self) {
+ pub fn assert_consistent(@mut self) {
if self.hd.is_none() || self.tl.is_none() {
assert!(self.hd.is_none() && self.tl.is_none());
}
}
}
-pub impl<T:Copy> DList<T> {
+impl<T:Copy> DList<T> {
/// Remove data from the head of the list. O(1).
- fn pop(@mut self) -> Option<T> {
+ pub fn pop(@mut self) -> Option<T> {
self.pop_n().map(|nobe| nobe.data)
}
/// Remove data from the tail of the list. O(1).
- fn pop_tail(@mut self) -> Option<T> {
+ pub fn pop_tail(@mut self) -> Option<T> {
self.pop_tail_n().map(|nobe| nobe.data)
}
/// Get data at the list's head. O(1).
- fn peek(@mut self) -> Option<T> {
+ pub fn peek(@mut self) -> Option<T> {
self.peek_n().map(|nobe| nobe.data)
}
/// Get data at the list's tail. O(1).
- fn peek_tail(@mut self) -> Option<T> {
+ pub fn peek_tail(@mut self) -> Option<T> {
self.peek_tail_n().map (|nobe| nobe.data)
}
/// Get data at the list's head, failing if empty. O(1).
- fn head(@mut self) -> T { self.head_n().data }
+ pub fn head(@mut self) -> T { self.head_n().data }
/// Get data at the list's tail, failing if empty. O(1).
- fn tail(@mut self) -> T { self.tail_n().data }
+ pub fn tail(@mut self) -> T { self.tail_n().data }
/// Get the elements of the list as a vector. O(n).
- fn to_vec(@mut self) -> ~[T] {
+ pub fn to_vec(@mut self) -> ~[T] {
let mut v = vec::with_capacity(self.size);
for old_iter::eachi(&self) |index,data| {
v[index] = *data;
// ebml reading
- pub impl Doc {
- fn get(&self, tag: uint) -> Doc {
+ impl Doc {
+ pub fn get(&self, tag: uint) -> Doc {
get_doc(*self, tag)
}
}
}
}
- priv impl Decoder {
+ impl Decoder {
fn _check_label(&mut self, lbl: &str) {
if self.pos < self.parent.end {
let TaggedDoc { tag: r_tag, doc: r_doc } =
}
}
- pub impl Decoder {
- fn read_opaque<R>(&mut self, op: &fn(&mut Decoder, Doc) -> R) -> R {
+ impl Decoder {
+ pub fn read_opaque<R>(&mut self, op: &fn(&mut Decoder, Doc) -> R)
+ -> R {
let doc = self.next_doc(EsOpaque);
let (old_parent, old_pos) = (self.parent, self.pos);
}
// FIXME (#2741): Provide a function to write the standard ebml header.
- pub impl Encoder {
- fn start_tag(&mut self, tag_id: uint) {
+ impl Encoder {
+ pub fn start_tag(&mut self, tag_id: uint) {
debug!("Start tag %u", tag_id);
// Write the enum ID:
self.writer.write(zeroes);
}
- fn end_tag(&mut self) {
+ pub fn end_tag(&mut self) {
let last_size_pos = self.size_positions.pop();
let cur_pos = self.writer.tell();
self.writer.seek(last_size_pos as int, io::SeekSet);
debug!("End tag (size = %u)", size);
}
- fn wr_tag(&mut self, tag_id: uint, blk: &fn()) {
+ pub fn wr_tag(&mut self, tag_id: uint, blk: &fn()) {
self.start_tag(tag_id);
blk();
self.end_tag();
}
- fn wr_tagged_bytes(&mut self, tag_id: uint, b: &[u8]) {
+ pub fn wr_tagged_bytes(&mut self, tag_id: uint, b: &[u8]) {
write_vuint(self.writer, tag_id);
write_vuint(self.writer, b.len());
self.writer.write(b);
}
- fn wr_tagged_u64(&mut self, tag_id: uint, v: u64) {
+ pub fn wr_tagged_u64(&mut self, tag_id: uint, v: u64) {
do io::u64_to_be_bytes(v, 8u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
- fn wr_tagged_u32(&mut self, tag_id: uint, v: u32) {
+ pub fn wr_tagged_u32(&mut self, tag_id: uint, v: u32) {
do io::u64_to_be_bytes(v as u64, 4u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
- fn wr_tagged_u16(&mut self, tag_id: uint, v: u16) {
+ pub fn wr_tagged_u16(&mut self, tag_id: uint, v: u16) {
do io::u64_to_be_bytes(v as u64, 2u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
- fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) {
+ pub fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) {
self.wr_tagged_bytes(tag_id, &[v]);
}
- fn wr_tagged_i64(&mut self, tag_id: uint, v: i64) {
+ pub fn wr_tagged_i64(&mut self, tag_id: uint, v: i64) {
do io::u64_to_be_bytes(v as u64, 8u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
- fn wr_tagged_i32(&mut self, tag_id: uint, v: i32) {
+ pub fn wr_tagged_i32(&mut self, tag_id: uint, v: i32) {
do io::u64_to_be_bytes(v as u64, 4u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
- fn wr_tagged_i16(&mut self, tag_id: uint, v: i16) {
+ pub fn wr_tagged_i16(&mut self, tag_id: uint, v: i16) {
do io::u64_to_be_bytes(v as u64, 2u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
- fn wr_tagged_i8(&mut self, tag_id: uint, v: i8) {
+ pub fn wr_tagged_i8(&mut self, tag_id: uint, v: i8) {
self.wr_tagged_bytes(tag_id, &[v as u8]);
}
- fn wr_tagged_str(&mut self, tag_id: uint, v: &str) {
+ pub fn wr_tagged_str(&mut self, tag_id: uint, v: &str) {
str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b));
}
- fn wr_bytes(&mut self, b: &[u8]) {
+ pub fn wr_bytes(&mut self, b: &[u8]) {
debug!("Write %u bytes", b.len());
self.writer.write(b);
}
- fn wr_str(&mut self, s: &str) {
+ pub fn wr_str(&mut self, s: &str) {
debug!("Write str: %?", s);
self.writer.write(str::to_bytes(s));
}
// Totally lame approach.
static debug: bool = true;
- priv impl Encoder {
+ impl Encoder {
// used internally to emit things like the vector length and so on
fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) {
assert!(v <= 0xFFFF_FFFF_u);
}
}
- pub impl Encoder {
- fn emit_opaque(&mut self, f: &fn(&mut Encoder)) {
+ impl Encoder {
+ pub fn emit_opaque(&mut self, f: &fn(&mut Encoder)) {
self.start_tag(EsOpaque as uint);
f(self);
self.end_tag();
}
}
-pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P> {
- fn new(u: U, p: P) -> FlatPort<T, U, P> {
+impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P> {
+ pub fn new(u: U, p: P) -> FlatPort<T, U, P> {
FlatPort {
unflattener: u,
byte_port: p
}
}
-pub impl<T,F:Flattener<T>,C:ByteChan> FlatChan<T, F, C> {
- fn new(f: F, c: C) -> FlatChan<T, F, C> {
+impl<T,F:Flattener<T>,C:ByteChan> FlatChan<T, F, C> {
+ pub fn new(f: F, c: C) -> FlatChan<T, F, C> {
FlatChan {
flattener: f,
byte_chan: c
}
}
- pub impl<T:Copy + Owned> PodUnflattener<T> {
- fn new() -> PodUnflattener<T> {
+ impl<T:Copy + Owned> PodUnflattener<T> {
+ pub fn new() -> PodUnflattener<T> {
PodUnflattener {
bogus: ()
}
}
}
- pub impl<T:Copy + Owned> PodFlattener<T> {
- fn new() -> PodFlattener<T> {
+ impl<T:Copy + Owned> PodFlattener<T> {
+ pub fn new() -> PodFlattener<T> {
PodFlattener {
bogus: ()
}
}
}
- pub impl<D:Decoder,T:Decodable<D>> DeserializingUnflattener<D, T> {
- fn new(deserialize_buffer: DeserializeBuffer<T>)
+ impl<D:Decoder,T:Decodable<D>> DeserializingUnflattener<D, T> {
+ pub fn new(deserialize_buffer: DeserializeBuffer<T>)
-> DeserializingUnflattener<D, T> {
DeserializingUnflattener {
deserialize_buffer: deserialize_buffer
}
}
- pub impl<S:Encoder,T:Encodable<S>> SerializingFlattener<S, T> {
- fn new(serialize_value: SerializeValue<T>)
+ impl<S:Encoder,T:Encodable<S>> SerializingFlattener<S, T> {
+ pub fn new(serialize_value: SerializeValue<T>)
-> SerializingFlattener<S, T> {
SerializingFlattener {
serialize_value: serialize_value
}
}
- pub impl<R:Reader> ReaderBytePort<R> {
- fn new(r: R) -> ReaderBytePort<R> {
+ impl<R:Reader> ReaderBytePort<R> {
+ pub fn new(r: R) -> ReaderBytePort<R> {
ReaderBytePort {
reader: r
}
}
}
- pub impl<W:Writer> WriterByteChan<W> {
- fn new(w: W) -> WriterByteChan<W> {
+ impl<W:Writer> WriterByteChan<W> {
+ pub fn new(w: W) -> WriterByteChan<W> {
WriterByteChan {
writer: w
}
}
}
- pub impl PipeBytePort {
- fn new(p: Port<~[u8]>) -> PipeBytePort {
+ impl PipeBytePort {
+ pub fn new(p: Port<~[u8]>) -> PipeBytePort {
PipeBytePort {
port: p,
buf: @mut ~[]
}
}
- pub impl PipeByteChan {
- fn new(c: Chan<~[u8]>) -> PipeByteChan {
+ impl PipeByteChan {
+ pub fn new(c: Chan<~[u8]>) -> PipeByteChan {
PipeByteChan {
chan: c
}
}
/// Methods on the `future` type
-pub impl<A:Copy> Future<A> {
- fn get(&mut self) -> A {
+impl<A:Copy> Future<A> {
+ pub fn get(&mut self) -> A {
//! Get the value of the future.
*(self.get_ref())
}
}
-pub impl<A> Future<A> {
- fn get_ref<'a>(&'a mut self) -> &'a A {
+impl<A> Future<A> {
+ pub fn get_ref<'a>(&'a mut self) -> &'a A {
/*!
* Executes the future's closure and then returns a borrowed
* pointer to the result. The borrowed pointer lasts as long as
// Rust JSON serialization library
// Copyright (c) 2011 Google Inc.
+
#[forbid(non_camel_case_types)];
+#[allow(missing_doc)];
//! json serialization
}
}
-pub impl Parser {
- fn parse(&mut self) -> Result<Json, Error> {
+impl Parser {
+ pub fn parse(&mut self) -> Result<Json, Error> {
match self.parse_value() {
Ok(value) => {
// Skip trailing whitespaces.
}
}
-priv impl Parser {
+impl Parser {
fn eof(&self) -> bool { self.ch == -1 as char }
fn bump(&mut self) {
}
/// Convenience methods extending `net::tcp::TcpSocket`
-pub impl TcpSocket {
+impl TcpSocket {
pub fn read_start(&self) -> result::Result<@Port<
result::Result<~[u8], TcpErrData>>, TcpErrData> {
read_start(self)
result::Result<(), TcpErrData> {
read_stop(self)
}
- fn read(&self, timeout_msecs: uint) ->
+ pub fn read(&self, timeout_msecs: uint) ->
result::Result<~[u8], TcpErrData> {
read(self, timeout_msecs)
}
- fn read_future(&self, timeout_msecs: uint) ->
+ pub fn read_future(&self, timeout_msecs: uint) ->
future::Future<result::Result<~[u8], TcpErrData>> {
read_future(self, timeout_msecs)
}
pub type Query = ~[(~str, ~str)];
-pub impl Url {
- fn new(
- scheme: ~str,
- user: Option<UserInfo>,
- host: ~str,
- port: Option<~str>,
- path: ~str,
- query: Query,
- fragment: Option<~str>
- ) -> Url {
+impl Url {
+ pub fn new(scheme: ~str,
+ user: Option<UserInfo>,
+ host: ~str,
+ port: Option<~str>,
+ path: ~str,
+ query: Query,
+ fragment: Option<~str>)
+ -> Url {
Url {
scheme: scheme,
user: user,
}
}
-pub impl UserInfo {
- fn new(user: ~str, pass: Option<~str>) -> UserInfo {
+impl UserInfo {
+ pub fn new(user: ~str, pass: Option<~str>) -> UserInfo {
UserInfo { user: user, pass: pass }
}
}
A BigInt is a combination of BigUint and Sign.
*/
+#[allow(missing_doc)];
+
use core::prelude::*;
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
}
}
-pub impl BigInt {
+impl BigInt {
/// Creates and initializes an BigInt.
-
pub fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
BigInt::from_biguint(sign, BigUint::new(v))
}
.map_consume(|bu| BigInt::from_biguint(sign, bu));
}
-
- fn to_uint(&self) -> uint {
+ pub fn to_uint(&self) -> uint {
match self.sign {
Plus => self.data.to_uint(),
Zero => 0,
//! A priority queue implemented with a binary heap
+#[allow(missing_doc)];
+
use core::prelude::*;
use core::old_iter::BaseIter;
fn clear(&mut self) { self.data.truncate(0) }
}
-pub impl <T:Ord> PriorityQueue<T> {
+impl<T:Ord> PriorityQueue<T> {
/// Returns the greatest item in the queue - fails if empty
- fn top<'a>(&'a self) -> &'a T { &self.data[0] }
+ pub fn top<'a>(&'a self) -> &'a T { &self.data[0] }
/// Returns the greatest item in the queue - None if empty
- fn maybe_top<'a>(&'a self) -> Option<&'a T> {
+ pub fn maybe_top<'a>(&'a self) -> Option<&'a T> {
if self.is_empty() { None } else { Some(self.top()) }
}
/// Returns the number of elements the queue can hold without reallocating
- fn capacity(&self) -> uint { vec::capacity(&self.data) }
+ pub fn capacity(&self) -> uint { vec::capacity(&self.data) }
- fn reserve(&mut self, n: uint) { vec::reserve(&mut self.data, n) }
+ pub fn reserve(&mut self, n: uint) { vec::reserve(&mut self.data, n) }
- fn reserve_at_least(&mut self, n: uint) {
+ pub fn reserve_at_least(&mut self, n: uint) {
vec::reserve_at_least(&mut self.data, n)
}
/// Pop the greatest item from the queue - fails if empty
- fn pop(&mut self) -> T {
+ pub fn pop(&mut self) -> T {
let mut item = self.data.pop();
if !self.is_empty() {
swap(&mut item, &mut self.data[0]);
}
/// Pop the greatest item from the queue - None if empty
- fn maybe_pop(&mut self) -> Option<T> {
+ pub fn maybe_pop(&mut self) -> Option<T> {
if self.is_empty() { None } else { Some(self.pop()) }
}
/// Push an item onto the queue
- fn push(&mut self, item: T) {
+ pub fn push(&mut self, item: T) {
self.data.push(item);
let new_len = self.len() - 1;
self.siftup(0, new_len);
}
/// Optimized version of a push followed by a pop
- fn push_pop(&mut self, mut item: T) -> T {
+ pub fn push_pop(&mut self, mut item: T) -> T {
if !self.is_empty() && self.data[0] > item {
swap(&mut item, &mut self.data[0]);
self.siftdown(0);
}
/// Optimized version of a pop followed by a push - fails if empty
- fn replace(&mut self, mut item: T) -> T {
+ pub fn replace(&mut self, mut item: T) -> T {
swap(&mut item, &mut self.data[0]);
self.siftdown(0);
item
}
/// Consume the PriorityQueue and return the underlying vector
- fn to_vec(self) -> ~[T] { let PriorityQueue{data: v} = self; v }
+ pub fn to_vec(self) -> ~[T] { let PriorityQueue{data: v} = self; v }
/// Consume the PriorityQueue and return a vector in sorted
/// (ascending) order
- fn to_sorted_vec(self) -> ~[T] {
+ pub fn to_sorted_vec(self) -> ~[T] {
let mut q = self;
let mut end = q.len();
while end > 1 {
}
/// Create an empty PriorityQueue
- fn new() -> PriorityQueue<T> { PriorityQueue{data: ~[],} }
+ pub fn new() -> PriorityQueue<T> { PriorityQueue{data: ~[],} }
/// Create a PriorityQueue from a vector (heapify)
- fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
+ pub fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
let mut q = PriorityQueue{data: xs,};
let mut n = q.len() / 2;
while n > 0 {
// zeroed element), shift along the others and move it back into the
// vector over the junk element. This reduces the constant factor
// compared to using swaps, which involves twice as many moves.
-
- priv fn siftup(&mut self, start: uint, mut pos: uint) {
+ fn siftup(&mut self, start: uint, mut pos: uint) {
unsafe {
let new = replace(&mut self.data[pos], init());
}
}
- priv fn siftdown_range(&mut self, mut pos: uint, end: uint) {
+ fn siftdown_range(&mut self, mut pos: uint, end: uint) {
unsafe {
let start = pos;
let new = replace(&mut self.data[pos], init());
}
}
- priv fn siftdown(&mut self, pos: uint) {
+ fn siftdown(&mut self, pos: uint) {
let len = self.len();
self.siftdown_range(pos, len);
}
priv ptr: *mut RcBox<T>,
}
-priv impl<T> Rc<T> {
+impl<T> Rc<T> {
unsafe fn new(value: T) -> Rc<T> {
let ptr = malloc(sys::size_of::<RcBox<T>>() as size_t) as *mut RcBox<T>;
assert!(!ptr::is_null(ptr));
unsafe { Rc::new(value) }
}
-pub impl<T> Rc<T> {
+impl<T> Rc<T> {
#[inline(always)]
- fn borrow<'r>(&'r self) -> &'r T {
+ pub fn borrow<'r>(&'r self) -> &'r T {
unsafe { cast::copy_lifetime(self, &(*self.ptr).value) }
}
}
priv ptr: *mut RcMutBox<T>,
}
-priv impl<T> RcMut<T> {
+impl<T> RcMut<T> {
unsafe fn new(value: T) -> RcMut<T> {
let ptr = malloc(sys::size_of::<RcMutBox<T>>() as size_t) as *mut RcMutBox<T>;
assert!(!ptr::is_null(ptr));
unsafe { RcMut::new(value) }
}
-pub impl<T> RcMut<T> {
+impl<T> RcMut<T> {
/// Fails if there is already a mutable borrow of the box
#[inline]
- fn with_borrow<U>(&self, f: &fn(&T) -> U) -> U {
+ pub fn with_borrow<U>(&self, f: &fn(&T) -> U) -> U {
unsafe {
assert!((*self.ptr).borrow != Mutable);
let previous = (*self.ptr).borrow;
/// Fails if there is already a mutable or immutable borrow of the box
#[inline]
- fn with_mut_borrow<U>(&self, f: &fn(&mut T) -> U) -> U {
+ pub fn with_mut_borrow<U>(&self, f: &fn(&mut T) -> U) -> U {
unsafe {
assert_eq!((*self.ptr).borrow, Nothing);
(*self.ptr).borrow = Mutable;
* are O(highest integer key).
*/
+#[allow(missing_doc)];
+
use core::prelude::*;
use core::cmp;
}
}
-pub impl<V> SmallIntMap<V> {
+impl<V> SmallIntMap<V> {
/// Create an empty SmallIntMap
- fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} }
+ pub fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} }
/// Visit all key-value pairs in reverse order
- fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool {
+ pub fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool {
for uint::range_rev(self.v.len(), 0) |i| {
match self.v[i - 1] {
Some(ref elt) => if !it(i - 1, elt) { return false; },
return true;
}
- fn get<'a>(&'a self, key: &uint) -> &'a V {
+ pub fn get<'a>(&'a self, key: &uint) -> &'a V {
self.find(key).expect("key not present")
}
}
-pub impl<V:Copy> SmallIntMap<V> {
- fn update_with_key(&mut self, key: uint, val: V,
- ff: &fn(uint, V, V) -> V) -> bool {
+impl<V:Copy> SmallIntMap<V> {
+ pub fn update_with_key(&mut self, key: uint, val: V,
+ ff: &fn(uint, V, V) -> V) -> bool {
let new_val = match self.find(&key) {
None => val,
Some(orig) => ff(key, *orig, val)
self.insert(key, new_val)
}
- fn update(&mut self, key: uint, newval: V, ff: &fn(V, V) -> V) -> bool {
+ pub fn update(&mut self, key: uint, newval: V, ff: &fn(V, V) -> V)
+ -> bool {
self.update_with_key(key, newval, |_k, v, v1| ff(v,v1))
}
}
}
}
-pub impl SmallIntSet {
+impl SmallIntSet {
/// Create an empty SmallIntSet
- fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }
+ pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }
}
#[cfg(test)]
}
#[doc(hidden)]
-pub impl<Q:Owned> Sem<Q> {
- fn acquire(&self) {
+impl<Q:Owned> Sem<Q> {
+ pub fn acquire(&self) {
unsafe {
let mut waiter_nobe = None;
do (**self).with |state| {
}
}
}
- fn release(&self) {
+
+ pub fn release(&self) {
unsafe {
do (**self).with |state| {
state.count += 1;
}
// FIXME(#3154) move both copies of this into Sem<Q>, and unify the 2 structs
#[doc(hidden)]
-pub impl Sem<()> {
- fn access<U>(&self, blk: &fn() -> U) -> U {
+impl Sem<()> {
+ pub fn access<U>(&self, blk: &fn() -> U) -> U {
let mut release = None;
unsafe {
do task::unkillable {
blk()
}
}
+
#[doc(hidden)]
-pub impl Sem<~[Waitqueue]> {
- fn access<U>(&self, blk: &fn() -> U) -> U {
+impl Sem<~[Waitqueue]> {
+ pub fn access<U>(&self, blk: &fn() -> U) -> U {
let mut release = None;
unsafe {
do task::unkillable {
#[unsafe_destructor]
impl<'self> Drop for Condvar<'self> { fn finalize(&self) {} }
-pub impl<'self> Condvar<'self> {
+impl<'self> Condvar<'self> {
/**
* Atomically drop the associated lock, and block until a signal is sent.
*
* while waiting on a condition variable will wake up, fail, and unlock
* the associated lock as it unwinds.
*/
- fn wait(&self) { self.wait_on(0) }
+ pub fn wait(&self) { self.wait_on(0) }
/**
* As wait(), but can specify which of multiple condition variables to
*
* wait() is equivalent to wait_on(0).
*/
- fn wait_on(&self, condvar_id: uint) {
+ pub fn wait_on(&self, condvar_id: uint) {
// Create waiter nobe.
let (WaitEnd, SignalEnd) = comm::oneshot();
let mut WaitEnd = Some(WaitEnd);
}
/// Wake up a blocked task. Returns false if there was no blocked task.
- fn signal(&self) -> bool { self.signal_on(0) }
+ pub fn signal(&self) -> bool { self.signal_on(0) }
/// As signal, but with a specified condvar_id. See wait_on.
- fn signal_on(&self, condvar_id: uint) -> bool {
+ pub fn signal_on(&self, condvar_id: uint) -> bool {
unsafe {
let mut out_of_bounds = None;
let mut result = false;
}
/// Wake up all blocked tasks. Returns the number of tasks woken.
- fn broadcast(&self) -> uint { self.broadcast_on(0) }
+ pub fn broadcast(&self) -> uint { self.broadcast_on(0) }
/// As broadcast, but with a specified condvar_id. See wait_on.
- fn broadcast_on(&self, condvar_id: uint) -> uint {
+ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
let mut out_of_bounds = None;
let mut queue = None;
unsafe {
}
#[doc(hidden)]
-pub impl Sem<~[Waitqueue]> {
+impl Sem<~[Waitqueue]> {
// The only other place that condvars get built is rwlock_write_mode.
- fn access_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+ pub fn access_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
do self.access { blk(&Condvar { sem: self }) }
}
}
}
}
-pub impl Semaphore {
+impl Semaphore {
/**
* Acquire a resource represented by the semaphore. Blocks if necessary
* until resource(s) become available.
*/
- fn acquire(&self) { (&self.sem).acquire() }
+ pub fn acquire(&self) { (&self.sem).acquire() }
/**
* Release a held resource represented by the semaphore. Wakes a blocked
* contending task, if any exist. Won't block the caller.
*/
- fn release(&self) { (&self.sem).release() }
+ pub fn release(&self) { (&self.sem).release() }
/// Run a function with ownership of one of the semaphore's resources.
- fn access<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) }
+ pub fn access<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) }
}
/****************************************************************************
fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } }
}
-pub impl Mutex {
+impl Mutex {
/// Run a function with ownership of the mutex.
- fn lock<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) }
+ pub fn lock<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) }
/// Run a function with ownership of the mutex and a handle to a condvar.
- fn lock_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+ pub fn lock_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
(&self.sem).access_cond(blk)
}
}
read_count: 0 }) }
}
-pub impl RWlock {
+impl RWlock {
/// Create a new handle to the rwlock.
- fn clone(&self) -> RWlock {
+ pub fn clone(&self) -> RWlock {
RWlock { order_lock: (&(self.order_lock)).clone(),
access_lock: Sem((*self.access_lock).clone()),
state: self.state.clone() }
* Run a function with the rwlock in read mode. Calls to 'read' from other
* tasks may run concurrently with this one.
*/
- fn read<U>(&self, blk: &fn() -> U) -> U {
+ pub fn read<U>(&self, blk: &fn() -> U) -> U {
let mut release = None;
unsafe {
do task::unkillable {
* Run a function with the rwlock in write mode. No calls to 'read' or
* 'write' from other tasks will run concurrently with this one.
*/
- fn write<U>(&self, blk: &fn() -> U) -> U {
+ pub fn write<U>(&self, blk: &fn() -> U) -> U {
unsafe {
do task::unkillable {
(&self.order_lock).acquire();
* the waiting task is signalled. (Note: a writer that waited and then
* was signalled might reacquire the lock before other waiting writers.)
*/
- fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+ pub fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
// NB: You might think I should thread the order_lock into the cond
// wait call, so that it gets waited on before access_lock gets
// reacquired upon being woken up. However, (a) this would be not
* }
* ~~~
*/
- fn write_downgrade<U>(&self, blk: &fn(v: RWlockWriteMode) -> U) -> U {
+ pub fn write_downgrade<U>(&self, blk: &fn(v: RWlockWriteMode) -> U) -> U {
// Implementation slightly different from the slicker 'write's above.
// The exit path is conditional on whether the caller downgrades.
let mut _release = None;
}
/// To be called inside of the write_downgrade block.
- fn downgrade<'a>(&self,
- token: RWlockWriteMode<'a>)
- -> RWlockReadMode<'a> {
+ pub fn downgrade<'a>(&self, token: RWlockWriteMode<'a>)
+ -> RWlockReadMode<'a> {
if !ptr::ref_eq(self, token.lock) {
fail!("Can't downgrade() with a different rwlock's write_mode!");
}
#[unsafe_destructor]
impl<'self> Drop for RWlockReadMode<'self> { fn finalize(&self) {} }
-pub impl<'self> RWlockWriteMode<'self> {
+impl<'self> RWlockWriteMode<'self> {
/// Access the pre-downgrade rwlock in write mode.
- fn write<U>(&self, blk: &fn() -> U) -> U { blk() }
+ pub fn write<U>(&self, blk: &fn() -> U) -> U { blk() }
/// Access the pre-downgrade rwlock in write mode with a condvar.
- fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+ pub fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
blk(&Condvar { sem: &self.lock.access_lock })
}
}
-pub impl<'self> RWlockReadMode<'self> {
+impl<'self> RWlockReadMode<'self> {
/// Access the post-downgrade rwlock in read mode.
- fn read<U>(&self, blk: &fn() -> U) -> U { blk() }
+ pub fn read<U>(&self, blk: &fn() -> U) -> U { blk() }
}
/****************************************************************************
}
}
-pub impl<T> TaskPool<T> {
+impl<T> TaskPool<T> {
/// Spawns a new task pool with `n_tasks` tasks. If the `sched_mode`
/// is None, the tasks run on this scheduler; otherwise, they run on a
/// new scheduler with the given mode. The provided `init_fn_factory`
/// returns a function which, given the index of the task, should return
/// local data to be kept around in that task.
- fn new(n_tasks: uint,
- opt_sched_mode: Option<SchedMode>,
- init_fn_factory: ~fn() -> ~fn(uint) -> T)
- -> TaskPool<T> {
+ pub fn new(n_tasks: uint,
+ opt_sched_mode: Option<SchedMode>,
+ init_fn_factory: ~fn() -> ~fn(uint) -> T)
+ -> TaskPool<T> {
assert!(n_tasks >= 1);
let channels = do vec::from_fn(n_tasks) |i| {
/// Executes the function `f` on a task in the pool. The function
/// receives a reference to the local data returned by the `init_fn`.
- fn execute(&mut self, f: ~fn(&T)) {
+ pub fn execute(&mut self, f: ~fn(&T)) {
self.channels[self.next_index].send(Execute(f));
self.next_index += 1;
if self.next_index == self.channels.len() { self.next_index = 0; }
use test::{BenchHarness, BenchSamples};
use time::precise_time_ns;
- pub impl BenchHarness {
-
+ impl BenchHarness {
/// Callback for benchmark functions to run in their body.
pub fn iter(&mut self, inner:&fn()) {
self.ns_start = precise_time_ns();
self.ns_end = precise_time_ns();
}
- fn ns_elapsed(&mut self) -> u64 {
+ pub fn ns_elapsed(&mut self) -> u64 {
if self.ns_start == 0 || self.ns_end == 0 {
0
} else {
}
}
- fn ns_per_iter(&mut self) -> u64 {
+ pub fn ns_per_iter(&mut self) -> u64 {
if self.iterations == 0 {
0
} else {
}
}
- fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) {
+ pub fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) {
self.iterations = n;
debug!("running benchmark for %u iterations",
n as uint);
* -1.2 seconds before the epoch is represented by `Timespec { sec: -2_i64,
* nsec: 800_000_000_i32 }`.
*/
-pub impl Timespec {
- fn new(sec: i64, nsec: i32) -> Timespec {
+impl Timespec {
+ pub fn new(sec: i64, nsec: i32) -> Timespec {
assert!(nsec >= 0 && nsec < NSEC_PER_SEC);
Timespec { sec: sec, nsec: nsec }
}
do_strftime(format, tm)
}
-pub impl Tm {
+impl Tm {
/// Convert time to the seconds from January 1, 1970
- fn to_timespec(&self) -> Timespec {
+ pub fn to_timespec(&self) -> Timespec {
unsafe {
let sec = match self.tm_gmtoff {
0_i32 => rustrt::rust_timegm(self),
}
/// Convert time to the local timezone
- fn to_local(&self) -> Tm {
+ pub fn to_local(&self) -> Tm {
at(self.to_timespec())
}
/// Convert time to the UTC
- fn to_utc(&self) -> Tm {
+ pub fn to_utc(&self) -> Tm {
at_utc(self.to_timespec())
}
* Return a string of the current time in the form
* "Thu Jan 1 00:00:00 1970".
*/
- fn ctime(&self) -> ~str { self.strftime("%c") }
+ pub fn ctime(&self) -> ~str { self.strftime("%c") }
/// Formats the time according to the format string.
- fn strftime(&self, format: &str) -> ~str {
+ pub fn strftime(&self, format: &str) -> ~str {
strftime(format, self)
}
* local: "Thu, 22 Mar 2012 07:53:18 PST"
* utc: "Thu, 22 Mar 2012 14:53:18 UTC"
*/
- fn rfc822(&self) -> ~str {
+ pub fn rfc822(&self) -> ~str {
if self.tm_gmtoff == 0_i32 {
self.strftime("%a, %d %b %Y %T GMT")
} else {
* local: "Thu, 22 Mar 2012 07:53:18 -0700"
* utc: "Thu, 22 Mar 2012 14:53:18 -0000"
*/
- fn rfc822z(&self) -> ~str {
+ pub fn rfc822z(&self) -> ~str {
self.strftime("%a, %d %b %Y %T %z")
}
* local: "2012-02-22T07:53:18-07:00"
* utc: "2012-02-22T14:53:18Z"
*/
- fn rfc3339(&self) -> ~str {
+ pub fn rfc3339(&self) -> ~str {
if self.tm_gmtoff == 0_i32 {
self.strftime("%Y-%m-%dT%H:%M:%SZ")
} else {
}
}
-pub impl<K: TotalOrd, V> TreeMap<K, V> {
+impl<K: TotalOrd, V> TreeMap<K, V> {
/// Create an empty TreeMap
- fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
+ pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
/// Visit all key-value pairs in reverse order
- fn each_reverse<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) -> bool {
+ pub fn each_reverse<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) -> bool {
each_reverse(&self.root, f)
}
/// Visit all keys in reverse order
- fn each_key_reverse(&self, f: &fn(&K) -> bool) -> bool {
+ pub fn each_key_reverse(&self, f: &fn(&K) -> bool) -> bool {
self.each_reverse(|k, _| f(k))
}
/// Visit all values in reverse order
- fn each_value_reverse(&self, f: &fn(&V) -> bool) -> bool {
+ pub fn each_value_reverse(&self, f: &fn(&V) -> bool) -> bool {
self.each_reverse(|_, v| f(v))
}
/// Get a lazy iterator over the key-value pairs in the map.
/// Requires that it be frozen (immutable).
- fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
+ pub fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
TreeMapIterator{stack: ~[], node: &self.root}
}
}
}
}
-pub impl <T: TotalOrd> TreeSet<T> {
+impl<T: TotalOrd> TreeSet<T> {
/// Create an empty TreeSet
#[inline(always)]
- fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
+ pub fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
/// Get a lazy iterator over the values in the set.
/// Requires that it be frozen (immutable).
#[inline(always)]
- fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> {
+ pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> {
TreeSetIterator{iter: self.map.iter()}
}
}
level: uint
}
-pub impl<K: TotalOrd, V> TreeNode<K, V> {
+impl<K: TotalOrd, V> TreeNode<K, V> {
+ /// Creates a new tree node.
#[inline(always)]
- fn new(key: K, value: V) -> TreeNode<K, V> {
+ pub fn new(key: K, value: V) -> TreeNode<K, V> {
TreeNode{key: key, value: value, left: None, right: None, level: 1}
}
}
}
}
-pub impl WorkKey {
- fn new(kind: &str, name: &str) -> WorkKey {
- WorkKey { kind: kind.to_owned(), name: name.to_owned() }
+impl WorkKey {
+ pub fn new(kind: &str, name: &str) -> WorkKey {
+ WorkKey {
+ kind: kind.to_owned(),
+ name: name.to_owned(),
+ }
}
}
db_dirty: bool
}
-pub impl Database {
- fn prepare(&mut self,
- fn_name: &str,
- declared_inputs: &WorkMap)
- -> Option<(WorkMap, WorkMap, ~str)> {
+impl Database {
+ pub fn prepare(&mut self,
+ fn_name: &str,
+ declared_inputs: &WorkMap)
+ -> Option<(WorkMap, WorkMap, ~str)> {
let k = json_encode(&(fn_name, declared_inputs));
match self.db_cache.find(&k) {
None => None,
}
}
- fn cache(&mut self,
- fn_name: &str,
- declared_inputs: &WorkMap,
- discovered_inputs: &WorkMap,
- discovered_outputs: &WorkMap,
- result: &str) {
+ pub fn cache(&mut self,
+ fn_name: &str,
+ declared_inputs: &WorkMap,
+ discovered_inputs: &WorkMap,
+ discovered_outputs: &WorkMap,
+ result: &str) {
let k = json_encode(&(fn_name, declared_inputs));
let v = json_encode(&(discovered_inputs,
discovered_outputs,
a: ()
}
-pub impl Logger {
- fn info(&self, i: &str) {
+impl Logger {
+ pub fn info(&self, i: &str) {
io::println(~"workcache: " + i);
}
}
sha.result_str()
}
-pub impl Context {
-
- fn new(db: @mut Database,
- lg: @mut Logger,
- cfg: @json::Object) -> Context {
+impl Context {
+ pub fn new(db: @mut Database, lg: @mut Logger, cfg: @json::Object)
+ -> Context {
Context {
db: db,
logger: lg,
}
}
- fn prep<T:Owned +
- Encodable<json::Encoder> +
- Decodable<json::Decoder>>( // FIXME(#5121)
- @self,
- fn_name:&str,
- blk: &fn(@mut Prep)->Work<T>) -> Work<T> {
+ pub fn prep<T:Owned +
+ Encodable<json::Encoder> +
+ Decodable<json::Decoder>>(@self, // FIXME(#5121)
+ fn_name:&str,
+ blk: &fn(@mut Prep)->Work<T>)
+ -> Work<T> {
let p = @mut Prep {
ctxt: self,
fn_name: fn_name.to_owned(),
}
}
-pub impl<T:Owned +
- Encodable<json::Encoder> +
- Decodable<json::Decoder>> Work<T> { // FIXME(#5121)
- fn new(p: @mut Prep, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
+impl<T:Owned +
+ Encodable<json::Encoder> +
+ Decodable<json::Decoder>> Work<T> { // FIXME(#5121)
+ pub fn new(p: @mut Prep, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
Work { prep: p, res: Some(e) }
}
}
pub type Session = @Session_;
-pub impl Session_ {
- fn span_fatal(@self, sp: span, msg: &str) -> ! {
+impl Session_ {
+ pub fn span_fatal(@self, sp: span, msg: &str) -> ! {
self.span_diagnostic.span_fatal(sp, msg)
}
- fn fatal(@self, msg: &str) -> ! {
+ pub fn fatal(@self, msg: &str) -> ! {
self.span_diagnostic.handler().fatal(msg)
}
- fn span_err(@self, sp: span, msg: &str) {
+ pub fn span_err(@self, sp: span, msg: &str) {
self.span_diagnostic.span_err(sp, msg)
}
- fn err(@self, msg: &str) {
+ pub fn err(@self, msg: &str) {
self.span_diagnostic.handler().err(msg)
}
- fn err_count(@self) -> uint {
+ pub fn err_count(@self) -> uint {
self.span_diagnostic.handler().err_count()
}
- fn has_errors(@self) -> bool {
+ pub fn has_errors(@self) -> bool {
self.span_diagnostic.handler().has_errors()
}
- fn abort_if_errors(@self) {
+ pub fn abort_if_errors(@self) {
self.span_diagnostic.handler().abort_if_errors()
}
- fn span_warn(@self, sp: span, msg: &str) {
+ pub fn span_warn(@self, sp: span, msg: &str) {
self.span_diagnostic.span_warn(sp, msg)
}
- fn warn(@self, msg: &str) {
+ pub fn warn(@self, msg: &str) {
self.span_diagnostic.handler().warn(msg)
}
- fn span_note(@self, sp: span, msg: &str) {
+ pub fn span_note(@self, sp: span, msg: &str) {
self.span_diagnostic.span_note(sp, msg)
}
- fn note(@self, msg: &str) {
+ pub fn note(@self, msg: &str) {
self.span_diagnostic.handler().note(msg)
}
- fn span_bug(@self, sp: span, msg: &str) -> ! {
+ pub fn span_bug(@self, sp: span, msg: &str) -> ! {
self.span_diagnostic.span_bug(sp, msg)
}
- fn bug(@self, msg: &str) -> ! {
+ pub fn bug(@self, msg: &str) -> ! {
self.span_diagnostic.handler().bug(msg)
}
- fn span_unimpl(@self, sp: span, msg: &str) -> ! {
+ pub fn span_unimpl(@self, sp: span, msg: &str) -> ! {
self.span_diagnostic.span_unimpl(sp, msg)
}
- fn unimpl(@self, msg: &str) -> ! {
+ pub fn unimpl(@self, msg: &str) -> ! {
self.span_diagnostic.handler().unimpl(msg)
}
- fn add_lint(@self, lint: lint::lint, id: ast::node_id, sp: span, msg: ~str) {
+ pub fn add_lint(@self,
+ lint: lint::lint,
+ id: ast::node_id,
+ sp: span,
+ msg: ~str) {
match self.lints.find_mut(&id) {
Some(arr) => { arr.push((lint, sp, msg)); return; }
None => {}
}
self.lints.insert(id, ~[(lint, sp, msg)]);
}
- fn next_node_id(@self) -> ast::node_id {
+ pub fn next_node_id(@self) -> ast::node_id {
return syntax::parse::next_node_id(self.parse_sess);
}
- fn diagnostic(@self) -> @diagnostic::span_handler {
+ pub fn diagnostic(@self) -> @diagnostic::span_handler {
self.span_diagnostic
}
- fn debugging_opt(@self, opt: uint) -> bool {
+ pub fn debugging_opt(@self, opt: uint) -> bool {
(self.opts.debugging_opts & opt) != 0u
}
// This exists to help with refactoring to eliminate impossible
// cases later on
- fn impossible_case(@self, sp: span, msg: &str) -> ! {
+ pub fn impossible_case(@self, sp: span, msg: &str) -> ! {
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
}
- fn verbose(@self) -> bool { self.debugging_opt(verbose) }
- fn time_passes(@self) -> bool { self.debugging_opt(time_passes) }
- fn count_llvm_insns(@self) -> bool {
+ pub fn verbose(@self) -> bool { self.debugging_opt(verbose) }
+ pub fn time_passes(@self) -> bool { self.debugging_opt(time_passes) }
+ pub fn count_llvm_insns(@self) -> bool {
self.debugging_opt(count_llvm_insns)
}
- fn count_type_sizes(@self) -> bool {
+ pub fn count_type_sizes(@self) -> bool {
self.debugging_opt(count_type_sizes)
}
- fn time_llvm_passes(@self) -> bool {
+ pub fn time_llvm_passes(@self) -> bool {
self.debugging_opt(time_llvm_passes)
}
- fn trans_stats(@self) -> bool { self.debugging_opt(trans_stats) }
- fn meta_stats(@self) -> bool { self.debugging_opt(meta_stats) }
- fn asm_comments(@self) -> bool { self.debugging_opt(asm_comments) }
- fn no_verify(@self) -> bool { self.debugging_opt(no_verify) }
- fn lint_llvm(@self) -> bool { self.debugging_opt(lint_llvm) }
- fn trace(@self) -> bool { self.debugging_opt(trace) }
- fn coherence(@self) -> bool { self.debugging_opt(coherence) }
- fn borrowck_stats(@self) -> bool { self.debugging_opt(borrowck_stats) }
- fn borrowck_note_pure(@self) -> bool {
+ pub fn trans_stats(@self) -> bool { self.debugging_opt(trans_stats) }
+ pub fn meta_stats(@self) -> bool { self.debugging_opt(meta_stats) }
+ pub fn asm_comments(@self) -> bool { self.debugging_opt(asm_comments) }
+ pub fn no_verify(@self) -> bool { self.debugging_opt(no_verify) }
+ pub fn lint_llvm(@self) -> bool { self.debugging_opt(lint_llvm) }
+ pub fn trace(@self) -> bool { self.debugging_opt(trace) }
+ pub fn coherence(@self) -> bool { self.debugging_opt(coherence) }
+ pub fn borrowck_stats(@self) -> bool { self.debugging_opt(borrowck_stats) }
+ pub fn borrowck_note_pure(@self) -> bool {
self.debugging_opt(borrowck_note_pure)
}
- fn borrowck_note_loan(@self) -> bool {
+ pub fn borrowck_note_loan(@self) -> bool {
self.debugging_opt(borrowck_note_loan)
}
- fn no_monomorphic_collapse(@self) -> bool {
+ pub fn no_monomorphic_collapse(@self) -> bool {
self.debugging_opt(no_monomorphic_collapse)
}
- fn debug_borrows(@self) -> bool {
+ pub fn debug_borrows(@self) -> bool {
self.opts.optimize == No && !self.debugging_opt(no_debug_borrows)
}
- fn str_of(@self, id: ast::ident) -> @~str {
+ pub fn str_of(@self, id: ast::ident) -> @~str {
self.parse_sess.interner.get(id)
}
- fn ident_of(@self, st: &str) -> ast::ident {
+ pub fn ident_of(@self, st: &str) -> ast::ident {
self.parse_sess.interner.intern(st)
}
- fn intr(@self) -> @syntax::parse::token::ident_interner {
+ pub fn intr(@self) -> @syntax::parse::token::ident_interner {
self.parse_sess.interner
}
}
ast_util::id_range { min: to_id_min, max: to_id_min }
}
-pub impl ExtendedDecodeContext {
- fn tr_id(&self, id: ast::node_id) -> ast::node_id {
+impl ExtendedDecodeContext {
+ pub fn tr_id(&self, id: ast::node_id) -> ast::node_id {
/*!
* Translates an internal id, meaning a node id that is known
* to refer to some part of the item currently being inlined,
assert!(!self.from_id_range.empty());
(id - self.from_id_range.min + self.to_id_range.min)
}
- fn tr_def_id(&self, did: ast::def_id) -> ast::def_id {
+ pub fn tr_def_id(&self, did: ast::def_id) -> ast::def_id {
/*!
* Translates an EXTERNAL def-id, converting the crate number
* from the one used in the encoded data to the current crate
decoder::translate_def_id(self.dcx.cdata, did)
}
- fn tr_intern_def_id(&self, did: ast::def_id) -> ast::def_id {
+ pub fn tr_intern_def_id(&self, did: ast::def_id) -> ast::def_id {
/*!
* Translates an INTERNAL def-id, meaning a def-id that is
* known to refer to some part of the item currently being
assert_eq!(did.crate, ast::local_crate);
ast::def_id { crate: ast::local_crate, node: self.tr_id(did.node) }
}
- fn tr_span(&self, _span: span) -> span {
+ pub fn tr_span(&self, _span: span) -> span {
codemap::dummy_sp() // FIXME (#1972): handle span properly
}
}
MoveWhileBorrowed(/*move*/@LoanPath, /*loan*/@LoanPath, /*loan*/span)
}
-pub impl<'self> CheckLoanCtxt<'self> {
- fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
+impl<'self> CheckLoanCtxt<'self> {
+ pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
- fn each_issued_loan(&self,
- scope_id: ast::node_id,
- op: &fn(&Loan) -> bool) -> bool
- {
+ pub fn each_issued_loan(&self,
+ scope_id: ast::node_id,
+ op: &fn(&Loan) -> bool)
+ -> bool {
//! Iterates over each loan that that has been issued
//! on entrance to `scope_id`, regardless of whether it is
//! actually *in scope* at that point. Sometimes loans
return true;
}
- fn each_in_scope_loan(&self,
- scope_id: ast::node_id,
- op: &fn(&Loan) -> bool) -> bool
- {
+ pub fn each_in_scope_loan(&self,
+ scope_id: ast::node_id,
+ op: &fn(&Loan) -> bool)
+ -> bool {
//! Like `each_issued_loan()`, but only considers loans that are
//! currently in scope.
return true;
}
- fn each_in_scope_restriction(&self,
- scope_id: ast::node_id,
- loan_path: @LoanPath,
- op: &fn(&Loan, &Restriction) -> bool) -> bool
- {
+ pub fn each_in_scope_restriction(&self,
+ scope_id: ast::node_id,
+ loan_path: @LoanPath,
+ op: &fn(&Loan, &Restriction) -> bool)
+ -> bool {
//! Iterates through all the in-scope restrictions for the
//! given `loan_path`
return true;
}
- fn loans_generated_by(&self, scope_id: ast::node_id) -> ~[uint] {
+ pub fn loans_generated_by(&self, scope_id: ast::node_id) -> ~[uint] {
//! Returns a vector of the loans that are generated as
//! we encounter `scope_id`.
return result;
}
- fn check_for_conflicting_loans(&mut self, scope_id: ast::node_id) {
+ pub fn check_for_conflicting_loans(&mut self, scope_id: ast::node_id) {
//! Checks to see whether any of the loans that are issued
//! by `scope_id` conflict with loans that have already been
//! issued when we enter `scope_id` (for example, we do not
}
}
- fn report_error_if_loans_conflict(&self,
- old_loan: &Loan,
- new_loan: &Loan) {
+ pub fn report_error_if_loans_conflict(&self,
+ old_loan: &Loan,
+ new_loan: &Loan) {
//! Checks whether `old_loan` and `new_loan` can safely be issued
//! simultaneously.
new_loan, old_loan, old_loan, new_loan);
}
- fn report_error_if_loan_conflicts_with_restriction(&self,
- loan1: &Loan,
- loan2: &Loan,
- old_loan: &Loan,
- new_loan: &Loan) -> bool {
+ pub fn report_error_if_loan_conflicts_with_restriction(&self,
+ loan1: &Loan,
+ loan2: &Loan,
+ old_loan: &Loan,
+ new_loan: &Loan)
+ -> bool {
//! Checks whether the restrictions introduced by `loan1` would
//! prohibit `loan2`. Returns false if an error is reported.
true
}
- fn is_local_variable(&self, cmt: mc::cmt) -> bool {
+ pub fn is_local_variable(&self, cmt: mc::cmt) -> bool {
match cmt.cat {
mc::cat_local(_) => true,
_ => false
}
}
- fn check_if_path_is_moved(&self,
- id: ast::node_id,
- span: span,
- use_kind: MovedValueUseKind,
- lp: @LoanPath) {
+ pub fn check_if_path_is_moved(&self,
+ id: ast::node_id,
+ span: span,
+ use_kind: MovedValueUseKind,
+ lp: @LoanPath) {
/*!
* Reports an error if `expr` (which should be a path)
* is using a moved/uninitialized value
}
}
- fn check_assignment(&self, expr: @ast::expr) {
+ pub fn check_assignment(&self, expr: @ast::expr) {
// We don't use cat_expr() here because we don't want to treat
// auto-ref'd parameters in overloaded operators as rvalues.
let cmt = match self.bccx.tcx.adjustments.find(&expr.id) {
}
}
- fn report_illegal_mutation(&self,
- expr: @ast::expr,
- loan_path: &LoanPath,
- loan: &Loan) {
+ pub fn report_illegal_mutation(&self,
+ expr: @ast::expr,
+ loan_path: &LoanPath,
+ loan: &Loan) {
self.bccx.span_err(
expr.span,
fmt!("cannot assign to `%s` because it is borrowed",
self.bccx.loan_path_to_str(loan_path)));
}
- fn check_move_out_from_expr(&self, ex: @ast::expr) {
+ pub fn check_move_out_from_expr(&self, ex: @ast::expr) {
match ex.node {
ast::expr_paren(*) => {
/* In the case of an expr_paren(), the expression inside
}
}
- fn analyze_move_out_from_cmt(&self, cmt: mc::cmt) -> MoveError {
+ pub fn analyze_move_out_from_cmt(&self, cmt: mc::cmt) -> MoveError {
debug!("analyze_move_out_from_cmt(cmt=%s)", cmt.repr(self.tcx()));
// FIXME(#4384) inadequare if/when we permit `move a.b`
return MoveOk;
}
- fn check_call(&mut self,
- _expr: @ast::expr,
- _callee: Option<@ast::expr>,
- _callee_id: ast::node_id,
- _callee_span: span,
- _args: &[@ast::expr])
- {
+ pub fn check_call(&mut self,
+ _expr: @ast::expr,
+ _callee: Option<@ast::expr>,
+ _callee_id: ast::node_id,
+ _callee_span: span,
+ _args: &[@ast::expr]) {
// NB: This call to check for conflicting loans is not truly
// necessary, because the callee_id never issues new loans.
// However, I added it for consistency and lest the system
}
}
-pub impl GatherLoanCtxt {
- fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
+impl GatherLoanCtxt {
+ pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
- fn push_repeating_id(&mut self, id: ast::node_id) {
+ pub fn push_repeating_id(&mut self, id: ast::node_id) {
self.repeating_ids.push(id);
}
- fn pop_repeating_id(&mut self, id: ast::node_id) {
+ pub fn pop_repeating_id(&mut self, id: ast::node_id) {
let popped = self.repeating_ids.pop();
assert_eq!(id, popped);
}
- fn guarantee_adjustments(&mut self,
- expr: @ast::expr,
- adjustment: &ty::AutoAdjustment) {
+ pub fn guarantee_adjustments(&mut self,
+ expr: @ast::expr,
+ adjustment: &ty::AutoAdjustment) {
debug!("guarantee_adjustments(expr=%s, adjustment=%?)",
expr.repr(self.tcx()), adjustment);
let _i = indenter();
// out loans, which will be added to the `req_loan_map`. This can
// also entail "rooting" GC'd pointers, which means ensuring
// dynamically that they are not freed.
- fn guarantee_valid(&mut self,
- borrow_id: ast::node_id,
- borrow_span: span,
- cmt: mc::cmt,
- req_mutbl: ast::mutability,
- loan_region: ty::Region)
- {
+ pub fn guarantee_valid(&mut self,
+ borrow_id: ast::node_id,
+ borrow_span: span,
+ cmt: mc::cmt,
+ req_mutbl: ast::mutability,
+ loan_region: ty::Region) {
debug!("guarantee_valid(borrow_id=%?, cmt=%s, \
req_mutbl=%?, loan_region=%?)",
borrow_id,
}
}
- fn restriction_set(&self, req_mutbl: ast::mutability) -> RestrictionSet {
+ pub fn restriction_set(&self, req_mutbl: ast::mutability)
+ -> RestrictionSet {
match req_mutbl {
m_const => RESTR_EMPTY,
m_imm => RESTR_EMPTY | RESTR_MUTATE | RESTR_CLAIM,
}
}
- fn mark_loan_path_as_mutated(&self, loan_path: @LoanPath) {
+ pub fn mark_loan_path_as_mutated(&self, loan_path: @LoanPath) {
//! For mutable loans of content whose mutability derives
//! from a local variable, mark the mutability decl as necessary.
}
}
- fn compute_gen_scope(&self,
- borrow_id: ast::node_id,
- loan_scope: ast::node_id) -> ast::node_id {
+ pub fn compute_gen_scope(&self,
+ borrow_id: ast::node_id,
+ loan_scope: ast::node_id)
+ -> ast::node_id {
//! Determine when to introduce the loan. Typically the loan
//! is introduced at the point of the borrow, but in some cases,
//! notably method arguments, the loan may be introduced only
}
}
- fn compute_kill_scope(&self,
- loan_scope: ast::node_id,
- lp: @LoanPath) -> ast::node_id {
+ pub fn compute_kill_scope(&self, loan_scope: ast::node_id, lp: @LoanPath)
+ -> ast::node_id {
//! Determine when the loan restrictions go out of scope.
//! This is either when the lifetime expires or when the
//! local variable which roots the loan-path goes out of scope,
}
}
- fn gather_pat(&mut self,
- discr_cmt: mc::cmt,
- root_pat: @ast::pat,
- arm_body_id: ast::node_id,
- match_id: ast::node_id) {
+ pub fn gather_pat(&mut self,
+ discr_cmt: mc::cmt,
+ root_pat: @ast::pat,
+ arm_body_id: ast::node_id,
+ match_id: ast::node_id) {
do self.bccx.cat_pattern(discr_cmt, root_pat) |cmt, pat| {
match pat.node {
ast::pat_ident(bm, _, _) if self.pat_is_binding(pat) => {
}
}
- fn vec_slice_info(&self,
- pat: @ast::pat,
- slice_ty: ty::t) -> (ast::mutability, ty::Region) {
+ pub fn vec_slice_info(&self, pat: @ast::pat, slice_ty: ty::t)
+ -> (ast::mutability, ty::Region) {
/*!
*
* In a pattern like [a, b, ..c], normally `c` has slice type,
}
}
- fn pat_is_variant_or_struct(&self, pat: @ast::pat) -> bool {
+ pub fn pat_is_variant_or_struct(&self, pat: @ast::pat) -> bool {
pat_util::pat_is_variant_or_struct(self.bccx.tcx.def_map, pat)
}
- fn pat_is_binding(&self, pat: @ast::pat) -> bool {
+ pub fn pat_is_binding(&self, pat: @ast::pat) -> bool {
pat_util::pat_is_binding(self.bccx.tcx.def_map, pat)
}
}
LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
}
-pub impl LoanPath {
- fn node_id(&self) -> ast::node_id {
+impl LoanPath {
+ pub fn node_id(&self) -> ast::node_id {
match *self {
LpVar(local_id) => local_id,
LpExtend(base, _, _) => base.node_id()
pub static RESTR_FREEZE: RestrictionSet = RestrictionSet {bits: 0b0100};
pub static RESTR_ALIAS: RestrictionSet = RestrictionSet {bits: 0b1000};
-pub impl RestrictionSet {
- fn intersects(&self, restr: RestrictionSet) -> bool {
+impl RestrictionSet {
+ pub fn intersects(&self, restr: RestrictionSet) -> bool {
(self.bits & restr.bits) != 0
}
- fn contains_all(&self, restr: RestrictionSet) -> bool {
+ pub fn contains_all(&self, restr: RestrictionSet) -> bool {
(self.bits & restr.bits) == restr.bits
}
}
///////////////////////////////////////////////////////////////////////////
// Misc
-pub impl BorrowckCtxt {
- fn is_subregion_of(&self, r_sub: ty::Region, r_sup: ty::Region) -> bool {
+impl BorrowckCtxt {
+ pub fn is_subregion_of(&self, r_sub: ty::Region, r_sup: ty::Region)
+ -> bool {
self.tcx.region_maps.is_subregion_of(r_sub, r_sup)
}
- fn is_subscope_of(&self, r_sub: ast::node_id, r_sup: ast::node_id) -> bool {
+ pub fn is_subscope_of(&self, r_sub: ast::node_id, r_sup: ast::node_id)
+ -> bool {
self.tcx.region_maps.is_subscope_of(r_sub, r_sup)
}
- fn is_move(&self, id: ast::node_id) -> bool {
+ pub fn is_move(&self, id: ast::node_id) -> bool {
self.moves_map.contains(&id)
}
- fn cat_expr(&self, expr: @ast::expr) -> mc::cmt {
+ pub fn cat_expr(&self, expr: @ast::expr) -> mc::cmt {
mc::cat_expr(self.tcx, self.method_map, expr)
}
- fn cat_expr_unadjusted(&self, expr: @ast::expr) -> mc::cmt {
+ pub fn cat_expr_unadjusted(&self, expr: @ast::expr) -> mc::cmt {
mc::cat_expr_unadjusted(self.tcx, self.method_map, expr)
}
- fn cat_expr_autoderefd(&self, expr: @ast::expr,
- adj: @ty::AutoAdjustment) -> mc::cmt {
+ pub fn cat_expr_autoderefd(&self,
+ expr: @ast::expr,
+ adj: @ty::AutoAdjustment)
+ -> mc::cmt {
match *adj {
ty::AutoAddEnv(*) => {
// no autoderefs
}
}
- fn cat_def(&self,
- id: ast::node_id,
- span: span,
- ty: ty::t,
- def: ast::def) -> mc::cmt {
+ pub fn cat_def(&self,
+ id: ast::node_id,
+ span: span,
+ ty: ty::t,
+ def: ast::def)
+ -> mc::cmt {
mc::cat_def(self.tcx, self.method_map, id, span, ty, def)
}
- fn cat_discr(&self, cmt: mc::cmt, match_id: ast::node_id) -> mc::cmt {
+ pub fn cat_discr(&self, cmt: mc::cmt, match_id: ast::node_id) -> mc::cmt {
@mc::cmt_ {cat:mc::cat_discr(cmt, match_id),
mutbl:cmt.mutbl.inherit(),
..*cmt}
}
- fn mc_ctxt(&self) -> mc::mem_categorization_ctxt {
+ pub fn mc_ctxt(&self) -> mc::mem_categorization_ctxt {
mc::mem_categorization_ctxt {tcx: self.tcx,
method_map: self.method_map}
}
- fn cat_pattern(&self,
- cmt: mc::cmt,
- pat: @ast::pat,
- op: &fn(mc::cmt, @ast::pat)) {
+ pub fn cat_pattern(&self,
+ cmt: mc::cmt,
+ pat: @ast::pat,
+ op: &fn(mc::cmt, @ast::pat)) {
let mc = self.mc_ctxt();
mc.cat_pattern(cmt, pat, op);
}
- fn report(&self, err: BckError) {
+ pub fn report(&self, err: BckError) {
self.span_err(
err.span,
self.bckerr_to_str(err));
self.note_and_explain_bckerr(err);
}
- fn report_use_of_moved_value(&self,
- use_span: span,
- use_kind: MovedValueUseKind,
- lp: @LoanPath,
- move: &move_data::Move,
- moved_lp: @LoanPath) {
+ pub fn report_use_of_moved_value(&self,
+ use_span: span,
+ use_kind: MovedValueUseKind,
+ lp: @LoanPath,
+ move: &move_data::Move,
+ moved_lp: @LoanPath) {
let verb = match use_kind {
MovedInUse => "use",
MovedInCapture => "capture",
}
}
- fn report_reassigned_immutable_variable(&self,
- span: span,
- lp: @LoanPath,
- assign: &move_data::Assignment) {
+ pub fn report_reassigned_immutable_variable(&self,
+ span: span,
+ lp: @LoanPath,
+ assign:
+ &move_data::Assignment) {
self.tcx.sess.span_err(
span,
fmt!("re-assignment of immutable variable `%s`",
fmt!("prior assignment occurs here"));
}
- fn span_err(&self, s: span, m: &str) {
+ pub fn span_err(&self, s: span, m: &str) {
self.tcx.sess.span_err(s, m);
}
- fn span_note(&self, s: span, m: &str) {
+ pub fn span_note(&self, s: span, m: &str) {
self.tcx.sess.span_note(s, m);
}
- fn bckerr_to_str(&self, err: BckError) -> ~str {
+ pub fn bckerr_to_str(&self, err: BckError) -> ~str {
match err.code {
err_mutbl(lk) => {
fmt!("cannot borrow %s %s as %s",
}
}
- fn report_aliasability_violation(&self,
- span: span,
- kind: AliasableViolationKind,
- cause: mc::AliasableReason) {
+ pub fn report_aliasability_violation(&self,
+ span: span,
+ kind: AliasableViolationKind,
+ cause: mc::AliasableReason) {
let prefix = match kind {
MutabilityViolation => "cannot assign to an `&mut`",
BorrowViolation => "cannot borrow an `&mut`"
}
}
- fn note_and_explain_bckerr(&self, err: BckError) {
+ pub fn note_and_explain_bckerr(&self, err: BckError) {
let code = err.code;
match code {
err_mutbl(*) | err_freeze_aliasable_const(*) => {}
}
}
- fn append_loan_path_to_str_from_interior(&self,
- loan_path: &LoanPath,
- out: &mut ~str) {
+ pub fn append_loan_path_to_str_from_interior(&self,
+ loan_path: &LoanPath,
+ out: &mut ~str) {
match *loan_path {
LpExtend(_, _, LpDeref) => {
str::push_char(out, '(');
}
}
- fn append_loan_path_to_str(&self, loan_path: &LoanPath, out: &mut ~str) {
+ pub fn append_loan_path_to_str(&self,
+ loan_path: &LoanPath,
+ out: &mut ~str) {
match *loan_path {
LpVar(id) => {
match self.tcx.items.find(&id) {
}
}
- fn loan_path_to_str(&self, loan_path: &LoanPath) -> ~str {
+ pub fn loan_path_to_str(&self, loan_path: &LoanPath) -> ~str {
let mut result = ~"";
self.append_loan_path_to_str(loan_path, &mut result);
result
}
- fn cmt_to_str(&self, cmt: mc::cmt) -> ~str {
+ pub fn cmt_to_str(&self, cmt: mc::cmt) -> ~str {
let mc = &mc::mem_categorization_ctxt {tcx: self.tcx,
method_map: self.method_map};
mc.cmt_to_str(cmt)
}
- fn mut_to_str(&self, mutbl: ast::mutability) -> ~str {
+ pub fn mut_to_str(&self, mutbl: ast::mutability) -> ~str {
let mc = &mc::mem_categorization_ctxt {tcx: self.tcx,
method_map: self.method_map};
mc.mut_to_str(mutbl)
}
- fn mut_to_keyword(&self, mutbl: ast::mutability) -> &'static str {
+ pub fn mut_to_keyword(&self, mutbl: ast::mutability) -> &'static str {
match mutbl {
ast::m_imm => "",
ast::m_const => "const",
items: [Option<def_id>, ..38]
}
-pub impl LanguageItems {
+impl LanguageItems {
pub fn new() -> LanguageItems {
LanguageItems {
items: [ None, ..38 ]
}
}
- fn each_item(&self, f: &fn(def_id: def_id, i: uint) -> bool) -> bool {
+ pub fn each_item(&self, f: &fn(def_id: def_id, i: uint) -> bool) -> bool {
self.items.eachi(|i, &item| f(item.get(), i))
}
item_refs: HashMap<@~str, uint>,
}
-pub impl LanguageItemCollector {
- fn match_and_collect_meta_item(&mut self, item_def_id: def_id,
- meta_item: @meta_item) {
+impl LanguageItemCollector {
+ pub fn match_and_collect_meta_item(&mut self,
+ item_def_id: def_id,
+ meta_item: @meta_item) {
match meta_item.node {
meta_name_value(key, literal) => {
match literal.node {
}
}
- fn collect_item(&mut self, item_index: uint, item_def_id: def_id) {
+ pub fn collect_item(&mut self, item_index: uint, item_def_id: def_id) {
// Check for duplicates.
match self.items.items[item_index] {
Some(original_def_id) if original_def_id != item_def_id => {
self.items.items[item_index] = Some(item_def_id);
}
- fn match_and_collect_item(&mut self,
- item_def_id: def_id, key: @~str, value: @~str) {
+ pub fn match_and_collect_item(&mut self,
+ item_def_id: def_id,
+ key: @~str,
+ value: @~str) {
if *key != ~"lang" {
return; // Didn't match.
}
}
}
- fn collect_local_language_items(&mut self) {
+ pub fn collect_local_language_items(&mut self) {
let this: *mut LanguageItemCollector = &mut *self;
visit_crate(self.crate, (), mk_simple_visitor(@SimpleVisitor {
visit_item: |item| {
}));
}
- fn collect_external_language_items(&mut self) {
+ pub fn collect_external_language_items(&mut self) {
let crate_store = self.session.cstore;
do iter_crate_data(crate_store) |crate_number, _crate_metadata| {
for each_lang_item(crate_store, crate_number)
}
}
- fn check_completeness(&self) {
+ pub fn check_completeness(&self) {
for self.item_refs.each |&key, &item_ref| {
match self.items.items[item_ref] {
None => {
}
}
- fn collect(&mut self) {
+ pub fn collect(&mut self) {
self.collect_local_language_items();
self.collect_external_language_items();
self.check_completeness();
// variable must not be assigned if there is some successor
// assignment. And so forth.
-pub impl LiveNode {
- fn is_valid(&self) -> bool { **self != uint::max_value }
+impl LiveNode {
+ pub fn is_valid(&self) -> bool {
+ **self != uint::max_value
+ }
}
fn invalid_node() -> LiveNode { LiveNode(uint::max_value) }
}
}
-pub impl IrMaps {
- fn add_live_node(&mut self, lnk: LiveNodeKind) -> LiveNode {
+impl IrMaps {
+ pub fn add_live_node(&mut self, lnk: LiveNodeKind) -> LiveNode {
let ln = LiveNode(self.num_live_nodes);
self.lnks.push(lnk);
self.num_live_nodes += 1;
ln
}
- fn add_live_node_for_node(&mut self,
- node_id: node_id,
- lnk: LiveNodeKind) {
+ pub fn add_live_node_for_node(&mut self,
+ node_id: node_id,
+ lnk: LiveNodeKind) {
let ln = self.add_live_node(lnk);
self.live_node_map.insert(node_id, ln);
debug!("%s is node %d", ln.to_str(), node_id);
}
- fn add_variable(&mut self, vk: VarKind) -> Variable {
+ pub fn add_variable(&mut self, vk: VarKind) -> Variable {
let v = Variable(self.num_vars);
self.var_kinds.push(vk);
self.num_vars += 1;
v
}
- fn variable(&mut self, node_id: node_id, span: span) -> Variable {
+ pub fn variable(&mut self, node_id: node_id, span: span) -> Variable {
match self.variable_map.find(&node_id) {
Some(&var) => var,
None => {
}
}
- fn variable_name(&mut self, var: Variable) -> @~str {
+ pub fn variable_name(&mut self, var: Variable) -> @~str {
match self.var_kinds[*var] {
Local(LocalInfo { ident: nm, _ }) | Arg(_, nm) => {
self.tcx.sess.str_of(nm)
}
}
- fn set_captures(&mut self, node_id: node_id, cs: ~[CaptureInfo]) {
+ pub fn set_captures(&mut self, node_id: node_id, cs: ~[CaptureInfo]) {
self.capture_info_map.insert(node_id, @cs);
}
- fn captures(&mut self, expr: @expr) -> @~[CaptureInfo] {
+ pub fn captures(&mut self, expr: @expr) -> @~[CaptureInfo] {
match self.capture_info_map.find(&expr.id) {
Some(&caps) => caps,
None => {
}
}
- fn lnk(&mut self, ln: LiveNode) -> LiveNodeKind {
+ pub fn lnk(&mut self, ln: LiveNode) -> LiveNodeKind {
self.lnks[*ln]
}
}
}
}
-pub impl Liveness {
- fn live_node(&self, node_id: node_id, span: span) -> LiveNode {
+impl Liveness {
+ pub fn live_node(&self, node_id: node_id, span: span) -> LiveNode {
let ir: &mut IrMaps = self.ir;
match ir.live_node_map.find(&node_id) {
Some(&ln) => ln,
}
}
- fn variable_from_path(&self, expr: @expr) -> Option<Variable> {
+ pub fn variable_from_path(&self, expr: @expr) -> Option<Variable> {
match expr.node {
expr_path(_) => {
let def = self.tcx.def_map.get_copy(&expr.id);
}
}
- fn variable(&self, node_id: node_id, span: span) -> Variable {
+ pub fn variable(&self, node_id: node_id, span: span) -> Variable {
self.ir.variable(node_id, span)
}
- fn variable_from_def_map(&self, node_id: node_id,
- span: span) -> Option<Variable> {
+ pub fn variable_from_def_map(&self, node_id: node_id, span: span)
+ -> Option<Variable> {
match self.tcx.def_map.find(&node_id) {
Some(&def) => {
moves::moved_variable_node_id_from_def(def).map(
}
}
- fn pat_bindings(&self, pat: @pat,
- f: &fn(LiveNode, Variable, span, node_id)) {
+ pub fn pat_bindings(&self,
+ pat: @pat,
+ f: &fn(LiveNode, Variable, span, node_id)) {
let def_map = self.tcx.def_map;
do pat_util::pat_bindings(def_map, pat) |_bm, p_id, sp, _n| {
let ln = self.live_node(p_id, sp);
}
}
- fn arm_pats_bindings(&self,
- pats: &[@pat],
- f: &fn(LiveNode, Variable, span, node_id)) {
+ pub fn arm_pats_bindings(&self,
+ pats: &[@pat],
+ f: &fn(LiveNode, Variable, span, node_id)) {
// only consider the first pattern; any later patterns must have
// the same bindings, and we also consider the first pattern to be
// the "authoratative" set of ids
}
}
- fn define_bindings_in_pat(&self, pat: @pat, succ: LiveNode) -> LiveNode {
+ pub fn define_bindings_in_pat(&self, pat: @pat, succ: LiveNode)
+ -> LiveNode {
self.define_bindings_in_arm_pats([pat], succ)
}
- fn define_bindings_in_arm_pats(&self, pats: &[@pat],
- succ: LiveNode) -> LiveNode {
+ pub fn define_bindings_in_arm_pats(&self, pats: &[@pat], succ: LiveNode)
+ -> LiveNode {
let mut succ = succ;
do self.arm_pats_bindings(pats) |ln, var, _sp, _id| {
self.init_from_succ(ln, succ);
succ
}
- fn idx(&self, ln: LiveNode, var: Variable) -> uint {
+ pub fn idx(&self, ln: LiveNode, var: Variable) -> uint {
*ln * self.ir.num_vars + *var
}
- fn live_on_entry(&self, ln: LiveNode, var: Variable)
- -> Option<LiveNodeKind> {
-
+ pub fn live_on_entry(&self, ln: LiveNode, var: Variable)
+ -> Option<LiveNodeKind> {
assert!(ln.is_valid());
let reader = self.users[self.idx(ln, var)].reader;
if reader.is_valid() {Some(self.ir.lnk(reader))} else {None}
/*
Is this variable live on entry to any of its successor nodes?
*/
- fn live_on_exit(&self, ln: LiveNode, var: Variable)
- -> Option<LiveNodeKind> {
-
+ pub fn live_on_exit(&self, ln: LiveNode, var: Variable)
+ -> Option<LiveNodeKind> {
self.live_on_entry(copy self.successors[*ln], var)
}
- fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool {
+ pub fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool {
assert!(ln.is_valid());
self.users[self.idx(ln, var)].used
}
- fn assigned_on_entry(&self, ln: LiveNode, var: Variable)
- -> Option<LiveNodeKind> {
-
+ pub fn assigned_on_entry(&self, ln: LiveNode, var: Variable)
+ -> Option<LiveNodeKind> {
assert!(ln.is_valid());
let writer = self.users[self.idx(ln, var)].writer;
if writer.is_valid() {Some(self.ir.lnk(writer))} else {None}
}
- fn assigned_on_exit(&self, ln: LiveNode, var: Variable)
- -> Option<LiveNodeKind> {
-
+ pub fn assigned_on_exit(&self, ln: LiveNode, var: Variable)
+ -> Option<LiveNodeKind> {
self.assigned_on_entry(copy self.successors[*ln], var)
}
- fn indices(&self, ln: LiveNode, op: &fn(uint)) {
+ pub fn indices(&self, ln: LiveNode, op: &fn(uint)) {
let node_base_idx = self.idx(ln, Variable(0));
for uint::range(0, self.ir.num_vars) |var_idx| {
op(node_base_idx + var_idx)
}
}
- fn indices2(&self, ln: LiveNode, succ_ln: LiveNode, op: &fn(uint, uint)) {
+ pub fn indices2(&self,
+ ln: LiveNode,
+ succ_ln: LiveNode,
+ op: &fn(uint, uint)) {
let node_base_idx = self.idx(ln, Variable(0u));
let succ_base_idx = self.idx(succ_ln, Variable(0u));
for uint::range(0u, self.ir.num_vars) |var_idx| {
}
}
- fn write_vars(&self,
- wr: @io::Writer,
- ln: LiveNode,
- test: &fn(uint) -> LiveNode) {
+ pub fn write_vars(&self,
+ wr: @io::Writer,
+ ln: LiveNode,
+ test: &fn(uint) -> LiveNode) {
let node_base_idx = self.idx(ln, Variable(0));
for uint::range(0, self.ir.num_vars) |var_idx| {
let idx = node_base_idx + var_idx;
}
}
- fn find_loop_scope(&self, opt_label: Option<ident>, id: node_id, sp: span)
- -> node_id {
+ pub fn find_loop_scope(&self,
+ opt_label: Option<ident>,
+ id: node_id,
+ sp: span)
+ -> node_id {
match opt_label {
Some(_) => // Refers to a labeled loop. Use the results of resolve
// to find with one
}
}
- fn last_loop_scope(&self) -> node_id {
+ pub fn last_loop_scope(&self) -> node_id {
let loop_scope = &mut *self.loop_scope;
*loop_scope.last()
}
- fn ln_str(&self, ln: LiveNode) -> ~str {
+ pub fn ln_str(&self, ln: LiveNode) -> ~str {
do io::with_str_writer |wr| {
wr.write_str("[ln(");
wr.write_uint(*ln);
}
}
- fn init_empty(&self, ln: LiveNode, succ_ln: LiveNode) {
+ pub fn init_empty(&self, ln: LiveNode, succ_ln: LiveNode) {
self.successors[*ln] = succ_ln;
// It is not necessary to initialize the
// }
}
- fn init_from_succ(&self, ln: LiveNode, succ_ln: LiveNode) {
+ pub fn init_from_succ(&self, ln: LiveNode, succ_ln: LiveNode) {
// more efficient version of init_empty() / merge_from_succ()
self.successors[*ln] = succ_ln;
self.indices2(ln, succ_ln, |idx, succ_idx| {
self.ln_str(ln), self.ln_str(succ_ln));
}
- fn merge_from_succ(&self, ln: LiveNode, succ_ln: LiveNode,
- first_merge: bool) -> bool {
+ pub fn merge_from_succ(&self,
+ ln: LiveNode,
+ succ_ln: LiveNode,
+ first_merge: bool)
+ -> bool {
if ln == succ_ln { return false; }
let mut changed = false;
// Indicates that a local variable was *defined*; we know that no
// uses of the variable can precede the definition (resolve checks
// this) so we just clear out all the data.
- fn define(&self, writer: LiveNode, var: Variable) {
+ pub fn define(&self, writer: LiveNode, var: Variable) {
let idx = self.idx(writer, var);
self.users[idx].reader = invalid_node();
self.users[idx].writer = invalid_node();
}
// Either read, write, or both depending on the acc bitset
- fn acc(&self, ln: LiveNode, var: Variable, acc: uint) {
+ pub fn acc(&self, ln: LiveNode, var: Variable, acc: uint) {
let idx = self.idx(ln, var);
let users = &mut *self.users;
let user = &mut users[idx];
// _______________________________________________________________________
- fn compute(&self, decl: &fn_decl, body: &blk) -> LiveNode {
+ pub fn compute(&self, decl: &fn_decl, body: &blk) -> LiveNode {
// if there is a `break` or `again` at the top level, then it's
// effectively a return---this only occurs in `for` loops,
// where the body is really a closure.
entry_ln
}
- fn propagate_through_fn_block(&self, _: &fn_decl, blk: &blk)
- -> LiveNode {
+ pub fn propagate_through_fn_block(&self, _: &fn_decl, blk: &blk)
+ -> LiveNode {
// the fallthrough exit is only for those cases where we do not
// explicitly return:
self.init_from_succ(self.s.fallthrough_ln, self.s.exit_ln);
self.propagate_through_block(blk, self.s.fallthrough_ln)
}
- fn propagate_through_block(&self, blk: &blk, succ: LiveNode) -> LiveNode {
+ pub fn propagate_through_block(&self, blk: &blk, succ: LiveNode)
+ -> LiveNode {
let succ = self.propagate_through_opt_expr(blk.node.expr, succ);
do blk.node.stmts.foldr(succ) |stmt, succ| {
self.propagate_through_stmt(*stmt, succ)
}
}
- fn propagate_through_stmt(&self, stmt: @stmt, succ: LiveNode)
- -> LiveNode {
+ pub fn propagate_through_stmt(&self, stmt: @stmt, succ: LiveNode)
+ -> LiveNode {
match stmt.node {
stmt_decl(decl, _) => {
return self.propagate_through_decl(decl, succ);
}
}
- fn propagate_through_decl(&self, decl: @decl, succ: LiveNode)
- -> LiveNode {
+ pub fn propagate_through_decl(&self, decl: @decl, succ: LiveNode)
+ -> LiveNode {
match decl.node {
decl_local(ref locals) => {
do locals.foldr(succ) |local, succ| {
}
}
- fn propagate_through_local(&self, local: @local, succ: LiveNode)
- -> LiveNode {
+ pub fn propagate_through_local(&self, local: @local, succ: LiveNode)
+ -> LiveNode {
// Note: we mark the variable as defined regardless of whether
// there is an initializer. Initially I had thought to only mark
// the live variable as defined if it was initialized, and then we
self.define_bindings_in_pat(local.node.pat, succ)
}
- fn propagate_through_exprs(&self, exprs: &[@expr],
- succ: LiveNode) -> LiveNode {
+ pub fn propagate_through_exprs(&self, exprs: &[@expr], succ: LiveNode)
+ -> LiveNode {
do exprs.foldr(succ) |expr, succ| {
self.propagate_through_expr(*expr, succ)
}
}
- fn propagate_through_opt_expr(&self, opt_expr: Option<@expr>,
- succ: LiveNode) -> LiveNode {
+ pub fn propagate_through_opt_expr(&self,
+ opt_expr: Option<@expr>,
+ succ: LiveNode)
+ -> LiveNode {
do old_iter::foldl(&opt_expr, succ) |succ, expr| {
self.propagate_through_expr(*expr, *succ)
}
}
- fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
- -> LiveNode {
+ pub fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
+ -> LiveNode {
debug!("propagate_through_expr: %s",
expr_to_str(expr, self.tcx.sess.intr()));
}
}
- fn propagate_through_lvalue_components(&self, expr: @expr,
- succ: LiveNode) -> LiveNode {
+ pub fn propagate_through_lvalue_components(&self,
+ expr: @expr,
+ succ: LiveNode)
+ -> LiveNode {
// # Lvalues
//
// In general, the full flow graph structure for an
}
// see comment on propagate_through_lvalue()
- fn write_lvalue(&self, expr: @expr,
- succ: LiveNode,
- acc: uint) -> LiveNode {
+ pub fn write_lvalue(&self, expr: @expr, succ: LiveNode, acc: uint)
+ -> LiveNode {
match expr.node {
expr_path(_) => self.access_path(expr, succ, acc),
}
}
- fn access_path(&self, expr: @expr, succ: LiveNode, acc: uint)
- -> LiveNode {
+ pub fn access_path(&self, expr: @expr, succ: LiveNode, acc: uint)
+ -> LiveNode {
let def = self.tcx.def_map.get_copy(&expr.id);
match moves::moved_variable_node_id_from_def(def) {
Some(nid) => {
}
}
- fn propagate_through_loop(&self, expr: @expr,
- cond: Option<@expr>,
- body: &blk,
- succ: LiveNode) -> LiveNode {
+ pub fn propagate_through_loop(&self,
+ expr: @expr,
+ cond: Option<@expr>,
+ body: &blk,
+ succ: LiveNode)
+ -> LiveNode {
/*
cond_ln
}
- fn with_loop_nodes<R>(&self, loop_node_id: node_id,
- break_ln: LiveNode,
- cont_ln: LiveNode,
- f: &fn() -> R) -> R {
+ pub fn with_loop_nodes<R>(&self,
+ loop_node_id: node_id,
+ break_ln: LiveNode,
+ cont_ln: LiveNode,
+ f: &fn() -> R)
+ -> R {
debug!("with_loop_nodes: %d %u", loop_node_id, *break_ln);
self.loop_scope.push(loop_node_id);
self.break_ln.insert(loop_node_id, break_ln);
PartiallyMovedValue
}
-pub impl Liveness {
- fn check_ret(&self, id: node_id, sp: span, _fk: &visit::fn_kind,
- entry_ln: LiveNode) {
+impl Liveness {
+ pub fn check_ret(&self,
+ id: node_id,
+ sp: span,
+ _fk: &visit::fn_kind,
+ entry_ln: LiveNode) {
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
// if no_ret_var is live, then we fall off the end of the
// function without any kind of return expression:
}
}
- fn check_lvalue(@self, expr: @expr, vt: vt<@Liveness>) {
+ pub fn check_lvalue(@self, expr: @expr, vt: vt<@Liveness>) {
match expr.node {
expr_path(_) => {
match self.tcx.def_map.get_copy(&expr.id) {
}
}
- fn report_illegal_read(&self,
- chk_span: span,
- lnk: LiveNodeKind,
- var: Variable,
- rk: ReadKind) {
+ pub fn report_illegal_read(&self,
+ chk_span: span,
+ lnk: LiveNodeKind,
+ var: Variable,
+ rk: ReadKind) {
let msg = match rk {
PossiblyUninitializedVariable => "possibly uninitialized \
variable",
}
}
- fn should_warn(&self, var: Variable) -> Option<@~str> {
+ pub fn should_warn(&self, var: Variable) -> Option<@~str> {
let name = self.ir.variable_name(var);
if name[0] == ('_' as u8) { None } else { Some(name) }
}
- fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) {
+ pub fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) {
for decl.inputs.each |arg| {
do pat_util::pat_bindings(self.tcx.def_map, arg.pat)
|_bm, p_id, sp, _n| {
}
}
- fn warn_about_unused_or_dead_vars_in_pat(&self, pat: @pat) {
+ pub fn warn_about_unused_or_dead_vars_in_pat(&self, pat: @pat) {
do self.pat_bindings(pat) |ln, var, sp, id| {
if !self.warn_about_unused(sp, id, ln, var) {
self.warn_about_dead_assign(sp, id, ln, var);
}
}
- fn warn_about_unused(&self, sp: span, id: node_id,
- ln: LiveNode, var: Variable) -> bool {
+ pub fn warn_about_unused(&self,
+ sp: span,
+ id: node_id,
+ ln: LiveNode,
+ var: Variable)
+ -> bool {
if !self.used_on_entry(ln, var) {
for self.should_warn(var).each |name| {
return false;
}
- fn warn_about_dead_assign(&self, sp: span, id: node_id,
- ln: LiveNode, var: Variable) {
+ pub fn warn_about_dead_assign(&self,
+ sp: span,
+ id: node_id,
+ ln: LiveNode,
+ var: Variable) {
if self.live_on_exit(ln, var).is_none() {
for self.should_warn(var).each |name| {
self.tcx.sess.add_lint(dead_assignment, id, sp,
}
}
-pub impl MutabilityCategory {
- fn from_mutbl(m: ast::mutability) -> MutabilityCategory {
+impl MutabilityCategory {
+ pub fn from_mutbl(m: ast::mutability) -> MutabilityCategory {
match m {
m_imm => McImmutable,
m_const => McReadOnly,
}
}
- fn inherit(&self) -> MutabilityCategory {
+ pub fn inherit(&self) -> MutabilityCategory {
match *self {
McImmutable => McImmutable,
McReadOnly => McReadOnly,
}
}
- fn is_mutable(&self) -> bool {
+ pub fn is_mutable(&self) -> bool {
match *self {
McImmutable | McReadOnly => false,
McDeclared | McInherited => true
}
}
- fn is_immutable(&self) -> bool {
+ pub fn is_immutable(&self) -> bool {
match *self {
McImmutable => true,
McReadOnly | McDeclared | McInherited => false
}
}
- fn to_user_str(&self) -> &'static str {
+ pub fn to_user_str(&self) -> &'static str {
match *self {
McDeclared | McInherited => "mutable",
McImmutable => "immutable",
}
}
-pub impl mem_categorization_ctxt {
- fn expr_ty(&self, expr: @ast::expr) -> ty::t {
+impl mem_categorization_ctxt {
+ pub fn expr_ty(&self, expr: @ast::expr) -> ty::t {
ty::expr_ty(self.tcx, expr)
}
- fn pat_ty(&self, pat: @ast::pat) -> ty::t {
+ pub fn pat_ty(&self, pat: @ast::pat) -> ty::t {
ty::node_id_to_type(self.tcx, pat.id)
}
- fn cat_expr(&self, expr: @ast::expr) -> cmt {
+ pub fn cat_expr(&self, expr: @ast::expr) -> cmt {
match self.tcx.adjustments.find(&expr.id) {
None => {
// No adjustments.
}
}
- fn cat_expr_autoderefd(&self,
- expr: @ast::expr,
- autoderefs: uint) -> cmt {
+ pub fn cat_expr_autoderefd(&self, expr: @ast::expr, autoderefs: uint)
+ -> cmt {
let mut cmt = self.cat_expr_unadjusted(expr);
for uint::range(1, autoderefs+1) |deref| {
cmt = self.cat_deref(expr, cmt, deref);
return cmt;
}
- fn cat_expr_unadjusted(&self, expr: @ast::expr) -> cmt {
+ pub fn cat_expr_unadjusted(&self, expr: @ast::expr) -> cmt {
debug!("cat_expr: id=%d expr=%s",
expr.id, pprust::expr_to_str(expr, self.tcx.sess.intr()));
}
}
- fn cat_def(&self,
- id: ast::node_id,
- span: span,
- expr_ty: ty::t,
- def: ast::def) -> cmt {
+ pub fn cat_def(&self,
+ id: ast::node_id,
+ span: span,
+ expr_ty: ty::t,
+ def: ast::def)
+ -> cmt {
match def {
ast::def_fn(*) | ast::def_static_method(*) | ast::def_mod(_) |
ast::def_foreign_mod(_) | ast::def_const(_) |
}
}
- fn cat_rvalue<N:ast_node>(&self, elt: N, expr_ty: ty::t) -> cmt {
+ pub fn cat_rvalue<N:ast_node>(&self, elt: N, expr_ty: ty::t) -> cmt {
@cmt_ {
id:elt.id(),
span:elt.span(),
/// component is inherited from the base it is a part of. For
/// example, a record field is mutable if it is declared mutable
/// or if the container is mutable.
- fn inherited_mutability(&self,
- base_m: MutabilityCategory,
- interior_m: ast::mutability) -> MutabilityCategory
- {
+ pub fn inherited_mutability(&self,
+ base_m: MutabilityCategory,
+ interior_m: ast::mutability)
+ -> MutabilityCategory {
match interior_m {
m_imm => base_m.inherit(),
m_const => McReadOnly,
}
}
- fn cat_field<N:ast_node>(&self,
- node: N,
- base_cmt: cmt,
- f_name: ast::ident,
- f_ty: ty::t) -> cmt {
+ pub fn cat_field<N:ast_node>(&self,
+ node: N,
+ base_cmt: cmt,
+ f_name: ast::ident,
+ f_ty: ty::t)
+ -> cmt {
@cmt_ {
id: node.id(),
span: node.span(),
}
}
- fn cat_deref_fn<N:ast_node>(&self,
- node: N,
- base_cmt: cmt,
- deref_cnt: uint) -> cmt
- {
+ pub fn cat_deref_fn<N:ast_node>(&self,
+ node: N,
+ base_cmt: cmt,
+ deref_cnt: uint)
+ -> cmt {
// Bit of a hack: the "dereference" of a function pointer like
// `@fn()` is a mere logical concept. We interpret it as
// dereferencing the environment pointer; of course, we don't
return self.cat_deref_common(node, base_cmt, deref_cnt, mt);
}
- fn cat_deref<N:ast_node>(&self,
- node: N,
- base_cmt: cmt,
- deref_cnt: uint) -> cmt
- {
+ pub fn cat_deref<N:ast_node>(&self,
+ node: N,
+ base_cmt: cmt,
+ deref_cnt: uint)
+ -> cmt {
let mt = match ty::deref(self.tcx, base_cmt.ty, true) {
Some(mt) => mt,
None => {
return self.cat_deref_common(node, base_cmt, deref_cnt, mt);
}
- fn cat_deref_common<N:ast_node>(&self,
- node: N,
- base_cmt: cmt,
- deref_cnt: uint,
- mt: ty::mt) -> cmt
- {
+ pub fn cat_deref_common<N:ast_node>(&self,
+ node: N,
+ base_cmt: cmt,
+ deref_cnt: uint,
+ mt: ty::mt)
+ -> cmt {
match deref_kind(self.tcx, base_cmt.ty) {
deref_ptr(ptr) => {
// for unique ptrs, we inherit mutability from the
}
}
- fn cat_index<N:ast_node>(&self,
- elt: N,
- base_cmt: cmt,
- derefs: uint) -> cmt {
+ pub fn cat_index<N:ast_node>(&self,
+ elt: N,
+ base_cmt: cmt,
+ derefs: uint)
+ -> cmt {
//! Creates a cmt for an indexing operation (`[]`); this
//! indexing operation may occurs as part of an
//! AutoBorrowVec, which when converting a `~[]` to an `&[]`
}
}
- fn cat_imm_interior<N:ast_node>(&self,
- node: N,
- base_cmt: cmt,
- interior_ty: ty::t,
- interior: InteriorKind) -> cmt {
+ pub fn cat_imm_interior<N:ast_node>(&self,
+ node: N,
+ base_cmt: cmt,
+ interior_ty: ty::t,
+ interior: InteriorKind)
+ -> cmt {
@cmt_ {
id: node.id(),
span: node.span(),
}
}
- fn cat_downcast<N:ast_node>(&self,
- node: N,
- base_cmt: cmt,
- downcast_ty: ty::t) -> cmt {
+ pub fn cat_downcast<N:ast_node>(&self,
+ node: N,
+ base_cmt: cmt,
+ downcast_ty: ty::t)
+ -> cmt {
@cmt_ {
id: node.id(),
span: node.span(),
}
}
- fn cat_pattern(&self,
- cmt: cmt,
- pat: @ast::pat,
- op: &fn(cmt, @ast::pat))
- {
+ pub fn cat_pattern(&self,
+ cmt: cmt,
+ pat: @ast::pat,
+ op: &fn(cmt, @ast::pat)) {
// Here, `cmt` is the categorization for the value being
// matched and pat is the pattern it is being matched against.
//
}
}
- fn mut_to_str(&self, mutbl: ast::mutability) -> ~str {
+ pub fn mut_to_str(&self, mutbl: ast::mutability) -> ~str {
match mutbl {
m_mutbl => ~"mutable",
m_const => ~"const",
}
}
- fn cmt_to_str(&self, cmt: cmt) -> ~str {
+ pub fn cmt_to_str(&self, cmt: cmt) -> ~str {
match cmt.cat {
cat_static_item => {
~"static item"
}
}
- fn region_to_str(&self, r: ty::Region) -> ~str {
+ pub fn region_to_str(&self, r: ty::Region) -> ~str {
region_to_str(self.tcx, r)
}
}
AliasableOther
}
-pub impl cmt_ {
- fn guarantor(@self) -> cmt {
+impl cmt_ {
+ pub fn guarantor(@self) -> cmt {
//! Returns `self` after stripping away any owned pointer derefs or
//! interior content. The return value is basically the `cmt` which
//! determines how long the value in `self` remains live.
}
}
- fn is_freely_aliasable(&self) -> bool {
+ pub fn is_freely_aliasable(&self) -> bool {
self.freely_aliasable().is_some()
}
- fn freely_aliasable(&self) -> Option<AliasableReason> {
+ pub fn freely_aliasable(&self) -> Option<AliasableReason> {
//! True if this lvalue resides in an area that is
//! freely aliasable, meaning that rustc cannot track
//! the alias//es with precision.
cx.consume_expr(expr, v);
}
-pub impl VisitContext {
- fn consume_exprs(&self,
- exprs: &[@expr],
- visitor: vt<VisitContext>)
- {
+impl VisitContext {
+ pub fn consume_exprs(&self, exprs: &[@expr], visitor: vt<VisitContext>) {
for exprs.each |expr| {
self.consume_expr(*expr, visitor);
}
}
- fn consume_expr(&self,
- expr: @expr,
- visitor: vt<VisitContext>)
- {
+ pub fn consume_expr(&self, expr: @expr, visitor: vt<VisitContext>) {
/*!
* Indicates that the value of `expr` will be consumed,
* meaning either copied or moved depending on its type.
};
}
- fn consume_block(&self,
- blk: &blk,
- visitor: vt<VisitContext>)
- {
+ pub fn consume_block(&self, blk: &blk, visitor: vt<VisitContext>) {
/*!
* Indicates that the value of `blk` will be consumed,
* meaning either copied or moved depending on its type.
}
}
- fn use_expr(&self,
- expr: @expr,
- expr_mode: UseMode,
- visitor: vt<VisitContext>)
- {
+ pub fn use_expr(&self,
+ expr: @expr,
+ expr_mode: UseMode,
+ visitor: vt<VisitContext>) {
/*!
* Indicates that `expr` is used with a given mode. This will
* in turn trigger calls to the subcomponents of `expr`.
}
}
- fn use_overloaded_operator(&self,
- expr: @expr,
- receiver_expr: @expr,
- arg_exprs: &[@expr],
- visitor: vt<VisitContext>) -> bool
- {
+ pub fn use_overloaded_operator(&self,
+ expr: @expr,
+ receiver_expr: @expr,
+ arg_exprs: &[@expr],
+ visitor: vt<VisitContext>)
+ -> bool {
if !self.method_map.contains_key(&expr.id) {
return false;
}
return true;
}
- fn consume_arm(&self,
- arm: &arm,
- visitor: vt<VisitContext>)
- {
+ pub fn consume_arm(&self, arm: &arm, visitor: vt<VisitContext>) {
for arm.pats.each |pat| {
self.use_pat(*pat);
}
self.consume_block(&arm.body, visitor);
}
- fn use_pat(&self,
- pat: @pat)
- {
+ pub fn use_pat(&self, pat: @pat) {
/*!
*
* Decides whether each binding in a pattern moves the value
}
}
- fn use_receiver(&self,
- receiver_expr: @expr,
- visitor: vt<VisitContext>)
- {
+ pub fn use_receiver(&self,
+ receiver_expr: @expr,
+ visitor: vt<VisitContext>) {
self.use_fn_arg(receiver_expr, visitor);
}
- fn use_fn_args(&self,
- _: node_id,
- arg_exprs: &[@expr],
- visitor: vt<VisitContext>) {
+ pub fn use_fn_args(&self,
+ _: node_id,
+ arg_exprs: &[@expr],
+ visitor: vt<VisitContext>) {
//! Uses the argument expressions.
for arg_exprs.each |arg_expr| {
self.use_fn_arg(*arg_expr, visitor);
}
}
- fn use_fn_arg(&self, arg_expr: @expr, visitor: vt<VisitContext>) {
+ pub fn use_fn_arg(&self, arg_expr: @expr, visitor: vt<VisitContext>) {
//! Uses the argument.
self.consume_expr(arg_expr, visitor)
}
- fn arms_have_by_move_bindings(&self,
- moves_map: MovesMap,
- arms: &[arm]) -> Option<@pat>
- {
+ pub fn arms_have_by_move_bindings(&self,
+ moves_map: MovesMap,
+ arms: &[arm])
+ -> Option<@pat> {
for arms.each |arm| {
for arm.pats.each |&pat| {
for ast_util::walk_pat(pat) |p| {
return None;
}
- fn compute_captures(&self, fn_expr_id: node_id) -> @[CaptureVar] {
+ pub fn compute_captures(&self, fn_expr_id: node_id) -> @[CaptureVar] {
debug!("compute_capture_vars(fn_expr_id=%?)", fn_expr_id);
let _indenter = indenter();
parent: parent,
}
-pub impl RegionMaps {
- fn relate_free_regions(&mut self,
- sub: FreeRegion,
- sup: FreeRegion)
- {
+impl RegionMaps {
+ pub fn relate_free_regions(&mut self, sub: FreeRegion, sup: FreeRegion) {
match self.free_region_map.find_mut(&sub) {
Some(sups) => {
if !sups.contains(&sup) {
self.free_region_map.insert(sub, ~[sup]);
}
- fn record_parent(&mut self,
- sub: ast::node_id,
- sup: ast::node_id)
- {
+ pub fn record_parent(&mut self, sub: ast::node_id, sup: ast::node_id) {
debug!("record_parent(sub=%?, sup=%?)", sub, sup);
assert!(sub != sup);
self.scope_map.insert(sub, sup);
}
- pub fn record_cleanup_scope(&mut self,
- scope_id: ast::node_id)
- {
+ pub fn record_cleanup_scope(&mut self, scope_id: ast::node_id) {
//! Records that a scope is a CLEANUP SCOPE. This is invoked
//! from within regionck. We wait until regionck because we do
//! not know which operators are overloaded until that point,
self.cleanup_scopes.insert(scope_id);
}
- fn opt_encl_scope(&self,
- id: ast::node_id) -> Option<ast::node_id>
- {
+ pub fn opt_encl_scope(&self, id: ast::node_id) -> Option<ast::node_id> {
//! Returns the narrowest scope that encloses `id`, if any.
self.scope_map.find(&id).map(|&x| *x)
}
- fn encl_scope(&self,
- id: ast::node_id) -> ast::node_id
- {
+ pub fn encl_scope(&self, id: ast::node_id) -> ast::node_id {
//! Returns the narrowest scope that encloses `id`, if any.
match self.scope_map.find(&id) {
}
}
- fn is_cleanup_scope(&self, scope_id: ast::node_id) -> bool {
+ pub fn is_cleanup_scope(&self, scope_id: ast::node_id) -> bool {
self.cleanup_scopes.contains(&scope_id)
}
- fn cleanup_scope(&self,
- expr_id: ast::node_id) -> ast::node_id
- {
+ pub fn cleanup_scope(&self, expr_id: ast::node_id) -> ast::node_id {
//! Returns the scope when temps in expr will be cleaned up
let mut id = self.encl_scope(expr_id);
return id;
}
- fn encl_region(&self,
- id: ast::node_id) -> ty::Region
- {
+ pub fn encl_region(&self, id: ast::node_id) -> ty::Region {
//! Returns the narrowest scope region that encloses `id`, if any.
ty::re_scope(self.encl_scope(id))
}
- pub fn scopes_intersect(&self,
- scope1: ast::node_id,
- scope2: ast::node_id) -> bool
- {
- self.is_subscope_of(scope1, scope2) || self.is_subscope_of(scope2, scope1)
+ pub fn scopes_intersect(&self, scope1: ast::node_id, scope2: ast::node_id)
+ -> bool {
+ self.is_subscope_of(scope1, scope2) ||
+ self.is_subscope_of(scope2, scope1)
}
- fn is_subscope_of(&self,
- subscope: ast::node_id,
- superscope: ast::node_id) -> bool
- {
+ pub fn is_subscope_of(&self,
+ subscope: ast::node_id,
+ superscope: ast::node_id)
+ -> bool {
/*!
* Returns true if `subscope` is equal to or is lexically
* nested inside `superscope` and false otherwise.
return true;
}
- fn sub_free_region(&self,
- sub: FreeRegion,
- sup: FreeRegion) -> bool
- {
+ pub fn sub_free_region(&self, sub: FreeRegion, sup: FreeRegion) -> bool {
/*!
* Determines whether two free regions have a subregion relationship
* by walking the graph encoded in `free_region_map`. Note that
return false;
}
- fn is_subregion_of(&self,
- sub_region: ty::Region,
- super_region: ty::Region) -> bool
- {
+ pub fn is_subregion_of(&self,
+ sub_region: ty::Region,
+ super_region: ty::Region)
+ -> bool {
/*!
* Determines whether one region is a subregion of another. This is
* intended to run *after inference* and sadly the logic is somewhat
}
}
- fn nearest_common_ancestor(&self,
- scope_a: ast::node_id,
- scope_b: ast::node_id) -> Option<ast::node_id>
- {
+ pub fn nearest_common_ancestor(&self,
+ scope_a: ast::node_id,
+ scope_b: ast::node_id)
+ -> Option<ast::node_id> {
/*!
* Finds the nearest common ancestor (if any) of two scopes. That
* is, finds the smallest scope which is greater than or equal to
}
}
-pub impl DetermineRpCtxt {
- fn add_variance(&self, variance: region_variance) -> region_variance {
+impl DetermineRpCtxt {
+ pub fn add_variance(&self, variance: region_variance) -> region_variance {
add_variance(self.ambient_variance, variance)
}
/// Records that item `id` is region-parameterized with the
/// variance `variance`. If `id` was already parameterized, then
/// the new variance is joined with the old variance.
- fn add_rp(&mut self, id: ast::node_id, variance: region_variance) {
+ pub fn add_rp(&mut self, id: ast::node_id, variance: region_variance) {
assert!(id != 0);
let old_variance = self.region_paramd_items.find(&id).
map_consume(|x| *x);
/// `from`. Put another way, it indicates that the current item
/// contains a value of type `from`, so if `from` is
/// region-parameterized, so is the current item.
- fn add_dep(&mut self, from: ast::node_id) {
+ pub fn add_dep(&mut self, from: ast::node_id) {
debug!("add dependency from %d -> %d (%s -> %s) with variance %?",
from, self.item_id,
ast_map::node_id_to_str(self.ast_map, from,
// with &self type, &self is also bound. We detect those last two
// cases via flags (anon_implies_rp and self_implies_rp) that are
// true when the anon or self region implies RP.
- fn region_is_relevant(&self, r: Option<@ast::Lifetime>) -> bool {
+ pub fn region_is_relevant(&self, r: Option<@ast::Lifetime>) -> bool {
match r {
None => {
self.anon_implies_rp
}
}
- fn with(@mut self,
- item_id: ast::node_id,
- anon_implies_rp: bool,
- f: &fn()) {
+ pub fn with(@mut self,
+ item_id: ast::node_id,
+ anon_implies_rp: bool,
+ f: &fn()) {
let old_item_id = self.item_id;
let old_anon_implies_rp = self.anon_implies_rp;
self.item_id = item_id;
self.anon_implies_rp = old_anon_implies_rp;
}
- fn with_ambient_variance(@mut self, variance: region_variance, f: &fn()) {
+ pub fn with_ambient_variance(@mut self,
+ variance: region_variance,
+ f: &fn()) {
let old_ambient_variance = self.ambient_variance;
self.ambient_variance = self.add_variance(variance);
f();
BoundResult(@mut Module, @mut NameBindings)
}
-pub impl NamespaceResult {
- fn is_unknown(&self) -> bool {
+impl NamespaceResult {
+ pub fn is_unknown(&self) -> bool {
match *self {
UnknownResult => true,
_ => false
Success(T) // Successfully resolved the import.
}
-pub impl<T> ResolveResult<T> {
- fn failed(&self) -> bool {
+impl<T> ResolveResult<T> {
+ pub fn failed(&self) -> bool {
match *self { Failed => true, _ => false }
}
- fn indeterminate(&self) -> bool {
+ pub fn indeterminate(&self) -> bool {
match *self { Indeterminate => true, _ => false }
}
}
}
}
-pub impl ImportResolution {
- fn target_for_namespace(&self, namespace: Namespace) -> Option<Target> {
+impl ImportResolution {
+ pub fn target_for_namespace(&self, namespace: Namespace)
+ -> Option<Target> {
match namespace {
TypeNS => return copy self.type_target,
ValueNS => return copy self.value_target
}
}
-pub impl Module {
- fn all_imports_resolved(&self) -> bool {
+impl Module {
+ pub fn all_imports_resolved(&self) -> bool {
let imports = &mut *self.imports;
return imports.len() == self.resolved_import_count;
}
value_def: Option<ValueNsDef>, //< Meaning in value namespace.
}
-pub impl NameBindings {
+impl NameBindings {
/// Creates a new module in this set of name bindings.
- fn define_module(@mut self,
- privacy: Privacy,
- parent_link: ParentLink,
- def_id: Option<def_id>,
- kind: ModuleKind,
- sp: span) {
+ pub fn define_module(@mut self,
+ privacy: Privacy,
+ parent_link: ParentLink,
+ def_id: Option<def_id>,
+ kind: ModuleKind,
+ sp: span) {
// Merges the module with the existing type def or creates a new one.
let module_ = @mut Module(parent_link, def_id, kind);
match self.type_def {
}
/// Sets the kind of the module, creating a new one if necessary.
- fn set_module_kind(@mut self,
- privacy: Privacy,
- parent_link: ParentLink,
- def_id: Option<def_id>,
- kind: ModuleKind,
- _sp: span) {
+ pub fn set_module_kind(@mut self,
+ privacy: Privacy,
+ parent_link: ParentLink,
+ def_id: Option<def_id>,
+ kind: ModuleKind,
+ _sp: span) {
match self.type_def {
None => {
let module = @mut Module(parent_link, def_id, kind);
}
/// Records a type definition.
- fn define_type(@mut self, privacy: Privacy, def: def, sp: span) {
+ pub fn define_type(@mut self, privacy: Privacy, def: def, sp: span) {
// Merges the type with the existing type def or creates a new one.
match self.type_def {
None => {
}
/// Records a value definition.
- fn define_value(@mut self, privacy: Privacy, def: def, sp: span) {
+ pub fn define_value(@mut self, privacy: Privacy, def: def, sp: span) {
self.value_def = Some(ValueNsDef { privacy: privacy, def: def, value_span: Some(sp) });
}
/// Returns the module node if applicable.
- fn get_module_if_available(&self) -> Option<@mut Module> {
+ pub fn get_module_if_available(&self) -> Option<@mut Module> {
match self.type_def {
Some(ref type_def) => (*type_def).module_def,
None => None
* Returns the module node. Fails if this node does not have a module
* definition.
*/
- fn get_module(@mut self) -> @mut Module {
+ pub fn get_module(@mut self) -> @mut Module {
match self.get_module_if_available() {
None => {
fail!("get_module called on a node with no module \
}
}
- fn defined_in_namespace(&self, namespace: Namespace) -> bool {
+ pub fn defined_in_namespace(&self, namespace: Namespace) -> bool {
match namespace {
TypeNS => return self.type_def.is_some(),
ValueNS => return self.value_def.is_some()
}
}
- fn defined_in_public_namespace(&self, namespace: Namespace) -> bool {
+ pub fn defined_in_public_namespace(&self, namespace: Namespace) -> bool {
match namespace {
TypeNS => match self.type_def {
Some(def) => def.privacy != Private,
}
}
- fn def_for_namespace(&self, namespace: Namespace) -> Option<def> {
+ pub fn def_for_namespace(&self, namespace: Namespace) -> Option<def> {
match namespace {
TypeNS => {
match self.type_def {
}
}
- fn privacy_for_namespace(&self, namespace: Namespace) -> Option<Privacy> {
+ pub fn privacy_for_namespace(&self, namespace: Namespace)
+ -> Option<Privacy> {
match namespace {
TypeNS => {
match self.type_def {
}
}
- fn span_for_namespace(&self, namespace: Namespace) -> Option<span> {
+ pub fn span_for_namespace(&self, namespace: Namespace) -> Option<span> {
if self.defined_in_namespace(namespace) {
match namespace {
TypeNS => {
primitive_types: HashMap<ident,prim_ty>,
}
-pub impl PrimitiveTypeTable {
- fn intern(&mut self, intr: @ident_interner, string: &str,
- primitive_type: prim_ty) {
+impl PrimitiveTypeTable {
+ pub fn intern(&mut self,
+ intr: @ident_interner,
+ string: &str,
+ primitive_type: prim_ty) {
let ident = intr.intern(string);
self.primitive_types.insert(ident, primitive_type);
}
used_imports: HashSet<node_id>,
}
-pub impl Resolver {
+impl Resolver {
/// The main name resolution procedure.
- fn resolve(@mut self) {
+ pub fn resolve(@mut self) {
self.build_reduced_graph();
self.session.abort_if_errors();
//
/// Constructs the reduced graph for the entire crate.
- fn build_reduced_graph(@mut self) {
+ pub fn build_reduced_graph(@mut self) {
let initial_parent =
ModuleReducedGraphParent(self.graph_root.get_module());
visit_crate(self.crate, initial_parent, mk_vt(@Visitor {
}
/// Returns the current module tracked by the reduced graph parent.
- fn get_module_from_parent(@mut self,
- reduced_graph_parent: ReducedGraphParent)
- -> @mut Module {
+ pub fn get_module_from_parent(@mut self,
+ reduced_graph_parent: ReducedGraphParent)
+ -> @mut Module {
match reduced_graph_parent {
ModuleReducedGraphParent(module_) => {
return module_;
* If this node does not have a module definition and we are not inside
* a block, fails.
*/
- fn add_child(@mut self,
- name: ident,
- reduced_graph_parent: ReducedGraphParent,
- duplicate_checking_mode: DuplicateCheckingMode,
- // For printing errors
- sp: span)
- -> (@mut NameBindings, ReducedGraphParent) {
-
+ pub fn add_child(@mut self,
+ name: ident,
+ reduced_graph_parent: ReducedGraphParent,
+ duplicate_checking_mode: DuplicateCheckingMode,
+ // For printing errors
+ sp: span)
+ -> (@mut NameBindings, ReducedGraphParent) {
// If this is the immediate descendant of a module, then we add the
// child name directly. Otherwise, we create or reuse an anonymous
// module and add the child to that.
}
}
- fn block_needs_anonymous_module(@mut self, block: &blk) -> bool {
+ pub fn block_needs_anonymous_module(@mut self, block: &blk) -> bool {
// If the block has view items, we need an anonymous module.
if block.node.view_items.len() > 0 {
return true;
return false;
}
- fn get_parent_link(@mut self,
- parent: ReducedGraphParent,
- name: ident)
- -> ParentLink {
+ pub fn get_parent_link(@mut self, parent: ReducedGraphParent, name: ident)
+ -> ParentLink {
match parent {
ModuleReducedGraphParent(module_) => {
return ModuleParentLink(module_, name);
}
/// Constructs the reduced graph for one item.
- fn build_reduced_graph_for_item(@mut self,
- item: @item,
- parent: ReducedGraphParent,
- visitor: vt<ReducedGraphParent>) {
+ pub fn build_reduced_graph_for_item(@mut self,
+ item: @item,
+ parent: ReducedGraphParent,
+ visitor: vt<ReducedGraphParent>) {
let ident = item.ident;
let sp = item.span;
let privacy = visibility_to_privacy(item.vis);
// Constructs the reduced graph for one variant. Variants exist in the
// type and/or value namespaces.
- fn build_reduced_graph_for_variant(@mut self,
- variant: &variant,
- item_id: def_id,
- parent_privacy: Privacy,
- parent: ReducedGraphParent,
- _visitor: vt<ReducedGraphParent>) {
+ pub fn build_reduced_graph_for_variant(@mut self,
+ variant: &variant,
+ item_id: def_id,
+ parent_privacy: Privacy,
+ parent: ReducedGraphParent,
+ _visitor: vt<ReducedGraphParent>) {
let ident = variant.node.name;
let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues,
variant.span);
/// Constructs the reduced graph for one 'view item'. View items consist
/// of imports and use directives.
- fn build_reduced_graph_for_view_item(@mut self,
- view_item: @view_item,
- parent: ReducedGraphParent,
- _visitor: vt<ReducedGraphParent>) {
+ pub fn build_reduced_graph_for_view_item(@mut self,
+ view_item: @view_item,
+ parent: ReducedGraphParent,
+ _: vt<ReducedGraphParent>) {
let privacy = visibility_to_privacy(view_item.vis);
match view_item.node {
view_item_use(ref view_paths) => {
}
/// Constructs the reduced graph for one foreign item.
- fn build_reduced_graph_for_foreign_item(@mut self,
- foreign_item: @foreign_item,
- parent: ReducedGraphParent,
- visitor:
+ pub fn build_reduced_graph_for_foreign_item(@mut self,
+ foreign_item: @foreign_item,
+ parent: ReducedGraphParent,
+ visitor:
vt<ReducedGraphParent>) {
let name = foreign_item.ident;
let (name_bindings, new_parent) =
}
}
- fn build_reduced_graph_for_block(@mut self,
- block: &blk,
- parent: ReducedGraphParent,
- visitor: vt<ReducedGraphParent>) {
+ pub fn build_reduced_graph_for_block(@mut self,
+ block: &blk,
+ parent: ReducedGraphParent,
+ visitor: vt<ReducedGraphParent>) {
let new_parent;
if self.block_needs_anonymous_module(block) {
let block_id = block.node.id;
visit_block(block, new_parent, visitor);
}
- fn handle_external_def(@mut self,
- def: def,
- visibility: ast::visibility,
- modules: &mut HashMap<def_id, @mut Module>,
- child_name_bindings: @mut NameBindings,
- final_ident: &str,
- ident: ident,
- new_parent: ReducedGraphParent) {
+ pub fn handle_external_def(@mut self,
+ def: def,
+ visibility: ast::visibility,
+ modules: &mut HashMap<def_id, @mut Module>,
+ child_name_bindings: @mut NameBindings,
+ final_ident: &str,
+ ident: ident,
+ new_parent: ReducedGraphParent) {
let privacy = visibility_to_privacy(visibility);
match def {
def_mod(def_id) | def_foreign_mod(def_id) => {
* Builds the reduced graph rooted at the 'use' directive for an external
* crate.
*/
- fn build_reduced_graph_for_external_crate(@mut self, root: @mut Module) {
+ pub fn build_reduced_graph_for_external_crate(@mut self,
+ root: @mut Module) {
let mut modules = HashMap::new();
// Create all the items reachable by paths.
}
/// Creates and adds an import directive to the given module.
- fn build_import_directive(@mut self,
- privacy: Privacy,
- module_: @mut Module,
- module_path: ~[ident],
- subclass: @ImportDirectiveSubclass,
- span: span,
- id: node_id) {
+ pub fn build_import_directive(@mut self,
+ privacy: Privacy,
+ module_: @mut Module,
+ module_path: ~[ident],
+ subclass: @ImportDirectiveSubclass,
+ span: span,
+ id: node_id) {
let directive = @ImportDirective(privacy, module_path,
subclass, span, id);
module_.imports.push(directive);
/// Resolves all imports for the crate. This method performs the fixed-
/// point iteration.
- fn resolve_imports(@mut self) {
+ pub fn resolve_imports(@mut self) {
let mut i = 0;
let mut prev_unresolved_imports = 0;
loop {
/// Attempts to resolve imports for the given module and all of its
/// submodules.
- fn resolve_imports_for_module_subtree(@mut self, module_: @mut Module) {
+ pub fn resolve_imports_for_module_subtree(@mut self,
+ module_: @mut Module) {
debug!("(resolving imports for module subtree) resolving %s",
self.module_to_str(module_));
self.resolve_imports_for_module(module_);
}
/// Attempts to resolve imports for the given module only.
- fn resolve_imports_for_module(@mut self, module: @mut Module) {
+ pub fn resolve_imports_for_module(@mut self, module: @mut Module) {
if module.all_imports_resolved() {
debug!("(resolving imports for module) all imports resolved for \
%s",
}
}
- fn idents_to_str(@mut self, idents: &[ident]) -> ~str {
+ pub fn idents_to_str(@mut self, idents: &[ident]) -> ~str {
let mut first = true;
let mut result = ~"";
for idents.each |ident| {
return result;
}
- fn import_directive_subclass_to_str(@mut self,
- subclass: ImportDirectiveSubclass)
- -> @~str {
+ pub fn import_directive_subclass_to_str(@mut self,
+ subclass: ImportDirectiveSubclass)
+ -> @~str {
match subclass {
SingleImport(_target, source) => self.session.str_of(source),
GlobImport => @~"*"
}
}
- fn import_path_to_str(@mut self,
- idents: &[ident],
- subclass: ImportDirectiveSubclass)
- -> @~str {
+ pub fn import_path_to_str(@mut self,
+ idents: &[ident],
+ subclass: ImportDirectiveSubclass)
+ -> @~str {
if idents.is_empty() {
self.import_directive_subclass_to_str(subclass)
} else {
/// don't know whether the name exists at the moment due to other
/// currently-unresolved imports, or success if we know the name exists.
/// If successful, the resolved bindings are written into the module.
- fn resolve_import_for_module(@mut self,
- module_: @mut Module,
- import_directive: @ImportDirective)
- -> ResolveResult<()> {
+ pub fn resolve_import_for_module(@mut self,
+ module_: @mut Module,
+ import_directive: @ImportDirective)
+ -> ResolveResult<()> {
let mut resolution_result = Failed;
let module_path = &import_directive.module_path;
return resolution_result;
}
- fn create_name_bindings_from_module(module: @mut Module) -> NameBindings {
+ pub fn create_name_bindings_from_module(module: @mut Module)
+ -> NameBindings {
NameBindings {
type_def: Some(TypeNsDef {
privacy: Public,
}
}
- fn resolve_single_import(@mut self,
- module_: @mut Module,
- containing_module: @mut Module,
- target: ident,
- source: ident,
- span: span)
- -> ResolveResult<()> {
+ pub fn resolve_single_import(@mut self,
+ module_: @mut Module,
+ containing_module: @mut Module,
+ target: ident,
+ source: ident,
+ span: span)
+ -> ResolveResult<()> {
debug!("(resolving single import) resolving `%s` = `%s::%s` from \
`%s`",
*self.session.str_of(target),
// Resolves a glob import. Note that this function cannot fail; it either
// succeeds or bails out (as importing * from an empty module or a module
// that exports nothing is valid).
- fn resolve_glob_import(@mut self,
- privacy: Privacy,
- module_: @mut Module,
- containing_module: @mut Module,
- id: node_id)
- -> ResolveResult<()> {
+ pub fn resolve_glob_import(@mut self,
+ privacy: Privacy,
+ module_: @mut Module,
+ containing_module: @mut Module,
+ id: node_id)
+ -> ResolveResult<()> {
// This function works in a highly imperative manner; it eagerly adds
// everything it can to the list of import resolutions of the module
// node.
}
/// Resolves the given module path from the given root `module_`.
- fn resolve_module_path_from_root(@mut self,
- module_: @mut Module,
- module_path: &[ident],
- index: uint,
- span: span,
- mut name_search_type: NameSearchType)
- -> ResolveResult<@mut Module> {
+ pub fn resolve_module_path_from_root(@mut self,
+ module_: @mut Module,
+ module_path: &[ident],
+ index: uint,
+ span: span,
+ mut name_search_type: NameSearchType)
+ -> ResolveResult<@mut Module> {
let mut search_module = module_;
let mut index = index;
let module_path_len = module_path.len();
/// Attempts to resolve the module part of an import directive or path
/// rooted at the given module.
- fn resolve_module_path(@mut self,
- module_: @mut Module,
- module_path: &[ident],
- use_lexical_scope: UseLexicalScopeFlag,
- span: span,
- name_search_type: NameSearchType)
- -> ResolveResult<@mut Module> {
+ pub fn resolve_module_path(@mut self,
+ module_: @mut Module,
+ module_path: &[ident],
+ use_lexical_scope: UseLexicalScopeFlag,
+ span: span,
+ name_search_type: NameSearchType)
+ -> ResolveResult<@mut Module> {
let module_path_len = module_path.len();
assert!(module_path_len > 0);
/// Invariant: This must only be called during main resolution, not during
/// import resolution.
- fn resolve_item_in_lexical_scope(@mut self,
- module_: @mut Module,
- name: ident,
- namespace: Namespace,
- search_through_modules:
- SearchThroughModulesFlag)
- -> ResolveResult<Target> {
+ pub fn resolve_item_in_lexical_scope(@mut self,
+ module_: @mut Module,
+ name: ident,
+ namespace: Namespace,
+ search_through_modules:
+ SearchThroughModulesFlag)
+ -> ResolveResult<Target> {
debug!("(resolving item in lexical scope) resolving `%s` in \
namespace %? in `%s`",
*self.session.str_of(name),
}
}
- /** Resolves a module name in the current lexical scope. */
- fn resolve_module_in_lexical_scope(@mut self,
- module_: @mut Module,
- name: ident)
- -> ResolveResult<@mut Module> {
+ /// Resolves a module name in the current lexical scope.
+ pub fn resolve_module_in_lexical_scope(@mut self,
+ module_: @mut Module,
+ name: ident)
+ -> ResolveResult<@mut Module> {
// If this module is an anonymous module, resolve the item in the
// lexical scope. Otherwise, resolve the item from the crate root.
let resolve_result = self.resolve_item_in_lexical_scope(
}
}
- /**
- * Returns the nearest normal module parent of the given module.
- */
- fn get_nearest_normal_module_parent(@mut self, module_: @mut Module)
- -> Option<@mut Module> {
+ /// Returns the nearest normal module parent of the given module.
+ pub fn get_nearest_normal_module_parent(@mut self, module_: @mut Module)
+ -> Option<@mut Module> {
let mut module_ = module_;
loop {
match module_.parent_link {
}
}
- /**
- * Returns the nearest normal module parent of the given module, or the
- * module itself if it is a normal module.
- */
- fn get_nearest_normal_module_parent_or_self(@mut self,
- module_: @mut Module)
- -> @mut Module {
+ /// Returns the nearest normal module parent of the given module, or the
+ /// module itself if it is a normal module.
+ pub fn get_nearest_normal_module_parent_or_self(@mut self,
+ module_: @mut Module)
+ -> @mut Module {
match module_.kind {
NormalModuleKind => return module_,
ExternModuleKind |
}
}
- /**
- * Resolves a "module prefix". A module prefix is one of (a) `self::`;
- * (b) some chain of `super::`.
- */
- fn resolve_module_prefix(@mut self,
- module_: @mut Module,
- module_path: &[ident])
- -> ResolveResult<ModulePrefixResult> {
+ /// Resolves a "module prefix". A module prefix is one of (a) `self::`;
+ /// (b) some chain of `super::`.
+ pub fn resolve_module_prefix(@mut self,
+ module_: @mut Module,
+ module_path: &[ident])
+ -> ResolveResult<ModulePrefixResult> {
let interner = self.session.parse_sess.interner;
// Start at the current module if we see `self` or `super`, or at the
/// Attempts to resolve the supplied name in the given module for the
/// given namespace. If successful, returns the target corresponding to
/// the name.
- fn resolve_name_in_module(@mut self,
- module_: @mut Module,
- name: ident,
- namespace: Namespace,
- name_search_type: NameSearchType)
- -> ResolveResult<Target> {
+ pub fn resolve_name_in_module(@mut self,
+ module_: @mut Module,
+ name: ident,
+ namespace: Namespace,
+ name_search_type: NameSearchType)
+ -> ResolveResult<Target> {
debug!("(resolving name in module) resolving `%s` in `%s`",
*self.session.str_of(name),
self.module_to_str(module_));
return Failed;
}
- fn report_unresolved_imports(@mut self, module_: @mut Module) {
+ pub fn report_unresolved_imports(@mut self, module_: @mut Module) {
let index = module_.resolved_import_count;
let imports: &mut ~[@ImportDirective] = &mut *module_.imports;
let import_count = imports.len();
// Then this operation can simply be performed as part of item (or import)
// processing.
- fn record_exports(@mut self) {
+ pub fn record_exports(@mut self) {
let root_module = self.graph_root.get_module();
self.record_exports_for_module_subtree(root_module);
}
- fn record_exports_for_module_subtree(@mut self, module_: @mut Module) {
+ pub fn record_exports_for_module_subtree(@mut self,
+ module_: @mut Module) {
// If this isn't a local crate, then bail out. We don't need to record
// exports for nonlocal crates.
}
}
- fn record_exports_for_module(@mut self, module_: @mut Module) {
+ pub fn record_exports_for_module(@mut self, module_: @mut Module) {
let mut exports2 = ~[];
self.add_exports_for_module(&mut exports2, module_);
}
}
- fn add_exports_of_namebindings(@mut self,
- exports2: &mut ~[Export2],
- ident: ident,
- namebindings: @mut NameBindings,
- ns: Namespace,
- reexport: bool) {
+ pub fn add_exports_of_namebindings(@mut self,
+ exports2: &mut ~[Export2],
+ ident: ident,
+ namebindings: @mut NameBindings,
+ ns: Namespace,
+ reexport: bool) {
match (namebindings.def_for_namespace(ns),
namebindings.privacy_for_namespace(ns)) {
(Some(d), Some(Public)) => {
}
}
- fn add_exports_for_module(@mut self,
- exports2: &mut ~[Export2],
- module_: @mut Module) {
+ pub fn add_exports_for_module(@mut self,
+ exports2: &mut ~[Export2],
+ module_: @mut Module) {
for module_.children.each |ident, namebindings| {
debug!("(computing exports) maybe export '%s'",
*self.session.str_of(*ident));
// generate a fake "implementation scope" containing all the
// implementations thus found, for compatibility with old resolve pass.
- fn with_scope(@mut self, name: Option<ident>, f: &fn()) {
+ pub fn with_scope(@mut self, name: Option<ident>, f: &fn()) {
let orig_module = self.current_module;
// Move down in the graph.
self.current_module = orig_module;
}
- // Wraps the given definition in the appropriate number of `def_upvar`
- // wrappers.
-
- fn upvarify(@mut self,
- ribs: &mut ~[@Rib],
- rib_index: uint,
- def_like: def_like,
- span: span,
- allow_capturing_self: AllowCapturingSelfFlag)
- -> Option<def_like> {
+ /// Wraps the given definition in the appropriate number of `def_upvar`
+ /// wrappers.
+ pub fn upvarify(@mut self,
+ ribs: &mut ~[@Rib],
+ rib_index: uint,
+ def_like: def_like,
+ span: span,
+ allow_capturing_self: AllowCapturingSelfFlag)
+ -> Option<def_like> {
let mut def;
let is_ty_param;
return Some(dl_def(def));
}
- fn search_ribs(@mut self,
- ribs: &mut ~[@Rib],
- name: ident,
- span: span,
- allow_capturing_self: AllowCapturingSelfFlag)
- -> Option<def_like> {
+ pub fn search_ribs(@mut self,
+ ribs: &mut ~[@Rib],
+ name: ident,
+ span: span,
+ allow_capturing_self: AllowCapturingSelfFlag)
+ -> Option<def_like> {
// FIXME #4950: This should not use a while loop.
// FIXME #4950: Try caching?
return None;
}
- fn resolve_crate(@mut self) {
+ pub fn resolve_crate(@mut self) {
debug!("(resolving crate) starting");
visit_crate(self.crate, (), mk_vt(@Visitor {
}));
}
- fn resolve_item(@mut self, item: @item, visitor: ResolveVisitor) {
+ pub fn resolve_item(@mut self, item: @item, visitor: ResolveVisitor) {
debug!("(resolving item) resolving %s",
*self.session.str_of(item.ident));
self.xray_context = orig_xray_flag;
}
- fn with_type_parameter_rib(@mut self,
- type_parameters: TypeParameters,
- f: &fn()) {
+ pub fn with_type_parameter_rib(@mut self,
+ type_parameters: TypeParameters,
+ f: &fn()) {
match type_parameters {
HasTypeParameters(generics, node_id, initial_index,
rib_kind) => {
}
}
- fn with_label_rib(@mut self, f: &fn()) {
+ pub fn with_label_rib(@mut self, f: &fn()) {
self.label_ribs.push(@Rib(NormalRibKind));
f();
self.label_ribs.pop();
}
- fn with_constant_rib(@mut self, f: &fn()) {
+ pub fn with_constant_rib(@mut self, f: &fn()) {
self.value_ribs.push(@Rib(ConstantItemRibKind));
f();
self.value_ribs.pop();
}
- fn resolve_function(@mut self,
- rib_kind: RibKind,
- optional_declaration: Option<&fn_decl>,
- type_parameters: TypeParameters,
- block: &blk,
- self_binding: SelfBinding,
- visitor: ResolveVisitor) {
+ pub fn resolve_function(@mut self,
+ rib_kind: RibKind,
+ optional_declaration: Option<&fn_decl>,
+ type_parameters: TypeParameters,
+ block: &blk,
+ self_binding: SelfBinding,
+ visitor: ResolveVisitor) {
// Create a value rib for the function.
let function_value_rib = @Rib(rib_kind);
self.value_ribs.push(function_value_rib);
self.value_ribs.pop();
}
- fn resolve_type_parameters(@mut self,
- type_parameters: &OptVec<TyParam>,
- visitor: ResolveVisitor) {
+ pub fn resolve_type_parameters(@mut self,
+ type_parameters: &OptVec<TyParam>,
+ visitor: ResolveVisitor) {
for type_parameters.each |type_parameter| {
for type_parameter.bounds.each |bound| {
self.resolve_type_parameter_bound(bound, visitor);
}
}
- fn resolve_type_parameter_bound(@mut self,
- type_parameter_bound: &TyParamBound,
- visitor: ResolveVisitor) {
+ pub fn resolve_type_parameter_bound(@mut self,
+ type_parameter_bound: &TyParamBound,
+ visitor: ResolveVisitor) {
match *type_parameter_bound {
TraitTyParamBound(tref) => {
self.resolve_trait_reference(tref, visitor)
}
}
- fn resolve_trait_reference(@mut self,
- trait_reference: &trait_ref,
- visitor: ResolveVisitor) {
+ pub fn resolve_trait_reference(@mut self,
+ trait_reference: &trait_ref,
+ visitor: ResolveVisitor) {
match self.resolve_path(trait_reference.path, TypeNS, true, visitor) {
None => {
self.session.span_err(trait_reference.path.span,
}
}
- fn resolve_struct(@mut self,
- id: node_id,
- generics: &Generics,
- fields: &[@struct_field],
- visitor: ResolveVisitor) {
+ pub fn resolve_struct(@mut self,
+ id: node_id,
+ generics: &Generics,
+ fields: &[@struct_field],
+ visitor: ResolveVisitor) {
// If applicable, create a rib for the type parameters.
do self.with_type_parameter_rib(HasTypeParameters
(generics, id, 0,
// Does this really need to take a RibKind or is it always going
// to be NormalRibKind?
- fn resolve_method(@mut self,
- rib_kind: RibKind,
- method: @method,
- outer_type_parameter_count: uint,
- visitor: ResolveVisitor) {
+ pub fn resolve_method(@mut self,
+ rib_kind: RibKind,
+ method: @method,
+ outer_type_parameter_count: uint,
+ visitor: ResolveVisitor) {
let method_generics = &method.generics;
let type_parameters =
HasTypeParameters(method_generics,
visitor);
}
- fn resolve_implementation(@mut self,
- id: node_id,
- generics: &Generics,
- opt_trait_reference: Option<@trait_ref>,
- self_type: @Ty,
- methods: &[@method],
- visitor: ResolveVisitor) {
+ pub fn resolve_implementation(@mut self,
+ id: node_id,
+ generics: &Generics,
+ opt_trait_reference: Option<@trait_ref>,
+ self_type: @Ty,
+ methods: &[@method],
+ visitor: ResolveVisitor) {
// If applicable, create a rib for the type parameters.
let outer_type_parameter_count = generics.ty_params.len();
do self.with_type_parameter_rib(HasTypeParameters
}
}
- fn resolve_module(@mut self,
- module_: &_mod,
- span: span,
- _name: ident,
- id: node_id,
- visitor: ResolveVisitor) {
+ pub fn resolve_module(@mut self,
+ module_: &_mod,
+ span: span,
+ _name: ident,
+ id: node_id,
+ visitor: ResolveVisitor) {
// Write the implementations in scope into the module metadata.
debug!("(resolving module) resolving module ID %d", id);
visit_mod(module_, span, id, (), visitor);
}
- fn resolve_local(@mut self, local: @local, visitor: ResolveVisitor) {
+ pub fn resolve_local(@mut self, local: @local, visitor: ResolveVisitor) {
let mutability = if local.node.is_mutbl {Mutable} else {Immutable};
// Resolve the type.
None, visitor);
}
- fn binding_mode_map(@mut self, pat: @pat) -> BindingMap {
+ pub fn binding_mode_map(@mut self, pat: @pat) -> BindingMap {
let mut result = HashMap::new();
do pat_bindings(self.def_map, pat) |binding_mode, _id, sp, path| {
let ident = path_to_ident(path);
return result;
}
- fn check_consistent_bindings(@mut self, arm: &arm) {
+ pub fn check_consistent_bindings(@mut self, arm: &arm) {
if arm.pats.len() == 0 { return; }
let map_0 = self.binding_mode_map(arm.pats[0]);
for arm.pats.eachi() |i, p| {
}
}
- fn resolve_arm(@mut self, arm: &arm, visitor: ResolveVisitor) {
+ pub fn resolve_arm(@mut self, arm: &arm, visitor: ResolveVisitor) {
self.value_ribs.push(@Rib(NormalRibKind));
let bindings_list = @mut HashMap::new();
self.value_ribs.pop();
}
- fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) {
+ pub fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) {
debug!("(resolving block) entering block");
self.value_ribs.push(@Rib(NormalRibKind));
debug!("(resolving block) leaving block");
}
- fn resolve_type(@mut self, ty: @Ty, visitor: ResolveVisitor) {
+ pub fn resolve_type(@mut self, ty: @Ty, visitor: ResolveVisitor) {
match ty.node {
// Like path expressions, the interpretation of path types depends
// on whether the path has multiple elements in it or not.
}
}
- fn resolve_pattern(@mut self,
- pattern: @pat,
- mode: PatternBindingMode,
- mutability: Mutability,
- // Maps idents to the node ID for the (outermost)
- // pattern that binds them
- bindings_list: Option<@mut HashMap<ident,node_id>>,
- visitor: ResolveVisitor) {
+ pub fn resolve_pattern(@mut self,
+ pattern: @pat,
+ mode: PatternBindingMode,
+ mutability: Mutability,
+ // Maps idents to the node ID for the (outermost)
+ // pattern that binds them
+ bindings_list: Option<@mut HashMap<ident,node_id>>,
+ visitor: ResolveVisitor) {
let pat_id = pattern.id;
for walk_pat(pattern) |pattern| {
match pattern.node {
}
}
- fn resolve_bare_identifier_pattern(@mut self, name: ident)
- -> BareIdentifierPatternResolution {
+ pub fn resolve_bare_identifier_pattern(@mut self, name: ident)
+ ->
+ BareIdentifierPatternResolution {
match self.resolve_item_in_lexical_scope(self.current_module,
name,
ValueNS,
/// If `check_ribs` is true, checks the local definitions first; i.e.
/// doesn't skip straight to the containing module.
- fn resolve_path(@mut self,
- path: @Path,
- namespace: Namespace,
- check_ribs: bool,
- visitor: ResolveVisitor)
- -> Option<def> {
+ pub fn resolve_path(@mut self,
+ path: @Path,
+ namespace: Namespace,
+ check_ribs: bool,
+ visitor: ResolveVisitor)
+ -> Option<def> {
// First, resolve the types.
for path.types.each |ty| {
self.resolve_type(*ty, visitor);
path.span);
}
- fn resolve_identifier(@mut self,
- identifier: ident,
- namespace: Namespace,
- check_ribs: bool,
- span: span)
- -> Option<def> {
+ pub fn resolve_identifier(@mut self,
+ identifier: ident,
+ namespace: Namespace,
+ check_ribs: bool,
+ span: span)
+ -> Option<def> {
if check_ribs {
match self.resolve_identifier_in_local_ribs(identifier,
namespace,
}
// FIXME #4952: Merge me with resolve_name_in_module?
- fn resolve_definition_of_name_in_module(@mut self,
- containing_module: @mut Module,
- name: ident,
- namespace: Namespace,
- xray: XrayFlag)
- -> NameDefinition {
+ pub fn resolve_definition_of_name_in_module(@mut self,
+ containing_module: @mut Module,
+ name: ident,
+ namespace: Namespace,
+ xray: XrayFlag)
+ -> NameDefinition {
// First, search children.
match containing_module.children.find(&name) {
Some(child_name_bindings) => {
return NoNameDefinition;
}
- fn intern_module_part_of_path(@mut self, path: @Path) -> ~[ident] {
+ pub fn intern_module_part_of_path(@mut self, path: @Path) -> ~[ident] {
let mut module_path_idents = ~[];
for path.idents.eachi |index, ident| {
if index == path.idents.len() - 1 {
return module_path_idents;
}
- fn resolve_module_relative_path(@mut self,
- path: @Path,
- xray: XrayFlag,
- namespace: Namespace)
- -> Option<def> {
+ pub fn resolve_module_relative_path(@mut self,
+ path: @Path,
+ xray: XrayFlag,
+ namespace: Namespace)
+ -> Option<def> {
let module_path_idents = self.intern_module_part_of_path(path);
let containing_module;
/// Invariant: This must be called only during main resolution, not during
/// import resolution.
- fn resolve_crate_relative_path(@mut self,
- path: @Path,
- xray: XrayFlag,
- namespace: Namespace)
- -> Option<def> {
+ pub fn resolve_crate_relative_path(@mut self,
+ path: @Path,
+ xray: XrayFlag,
+ namespace: Namespace)
+ -> Option<def> {
let module_path_idents = self.intern_module_part_of_path(path);
let root_module = self.graph_root.get_module();
}
}
- fn resolve_identifier_in_local_ribs(@mut self,
- ident: ident,
- namespace: Namespace,
- span: span)
- -> Option<def> {
+ pub fn resolve_identifier_in_local_ribs(@mut self,
+ ident: ident,
+ namespace: Namespace,
+ span: span)
+ -> Option<def> {
// Check the local set of ribs.
let search_result;
match namespace {
}
}
- fn resolve_self_value_in_local_ribs(@mut self, span: span)
- -> Option<def> {
+ pub fn resolve_self_value_in_local_ribs(@mut self, span: span)
+ -> Option<def> {
// FIXME #4950: This should not use a while loop.
let ribs = &mut self.value_ribs;
let mut i = ribs.len();
None
}
- fn resolve_item_by_identifier_in_lexical_scope(@mut self,
- ident: ident,
- namespace: Namespace)
- -> Option<def> {
+ pub fn resolve_item_by_identifier_in_lexical_scope(@mut self,
+ ident: ident,
+ namespace: Namespace)
+ -> Option<def> {
// Check the items.
match self.resolve_item_in_lexical_scope(self.current_module,
ident,
}
}
- fn find_best_match_for_name(@mut self, name: &str, max_distance: uint) -> Option<~str> {
+ pub fn find_best_match_for_name(@mut self,
+ name: &str,
+ max_distance: uint)
+ -> Option<~str> {
let this = &mut *self;
let mut maybes: ~[~str] = ~[];
}
}
- fn name_exists_in_scope_struct(@mut self, name: &str) -> bool {
+ pub fn name_exists_in_scope_struct(@mut self, name: &str) -> bool {
let this = &mut *self;
let mut i = this.type_ribs.len();
return false;
}
- fn resolve_expr(@mut self, expr: @expr, visitor: ResolveVisitor) {
+ pub fn resolve_expr(@mut self, expr: @expr, visitor: ResolveVisitor) {
// First, record candidate traits for this expression if it could
// result in the invocation of a method call.
}
}
- fn record_candidate_traits_for_expr_if_necessary(@mut self, expr: @expr) {
+ pub fn record_candidate_traits_for_expr_if_necessary(@mut self,
+ expr: @expr) {
match expr.node {
expr_field(_, ident, _) => {
let traits = self.search_for_traits_containing_method(ident);
}
}
- fn search_for_traits_containing_method(@mut self,
- name: ident)
- -> ~[def_id] {
+ pub fn search_for_traits_containing_method(@mut self, name: ident)
+ -> ~[def_id] {
debug!("(searching for traits containing method) looking for '%s'",
*self.session.str_of(name));
return found_traits;
}
- fn add_trait_info(&self,
- found_traits: &mut ~[def_id],
- trait_def_id: def_id,
- name: ident) {
+ pub fn add_trait_info(&self,
+ found_traits: &mut ~[def_id],
+ trait_def_id: def_id,
+ name: ident) {
debug!("(adding trait info) found trait %d:%d for method '%s'",
trait_def_id.crate,
trait_def_id.node,
found_traits.push(trait_def_id);
}
- fn add_fixed_trait_for_expr(@mut self,
- expr_id: node_id,
- trait_id: def_id) {
+ pub fn add_fixed_trait_for_expr(@mut self,
+ expr_id: node_id,
+ trait_id: def_id) {
self.trait_map.insert(expr_id, @mut ~[trait_id]);
}
- fn record_def(@mut self, node_id: node_id, def: def) {
+ pub fn record_def(@mut self, node_id: node_id, def: def) {
debug!("(recording def) recording %? for %?", def, node_id);
self.def_map.insert(node_id, def);
}
- fn enforce_default_binding_mode(@mut self,
- pat: @pat,
- pat_binding_mode: binding_mode,
- descr: &str) {
+ pub fn enforce_default_binding_mode(@mut self,
+ pat: @pat,
+ pat_binding_mode: binding_mode,
+ descr: &str) {
match pat_binding_mode {
bind_infer => {}
bind_by_ref(*) => {
// resolve data structures.
//
- fn check_for_unused_imports(@mut self) {
+ pub fn check_for_unused_imports(@mut self) {
let vt = mk_simple_visitor(@SimpleVisitor {
visit_view_item: |vi| self.check_for_item_unused_imports(vi),
.. *default_simple_visitor()
visit_crate(self.crate, (), vt);
}
- fn check_for_item_unused_imports(&mut self, vi: @view_item) {
+ pub fn check_for_item_unused_imports(&mut self, vi: @view_item) {
// Ignore public import statements because there's no way to be sure
// whether they're used or not. Also ignore imports with a dummy span
// because this means that they were generated in some fashion by the
//
/// A somewhat inefficient routine to obtain the name of a module.
- fn module_to_str(@mut self, module_: @mut Module) -> ~str {
+ pub fn module_to_str(@mut self, module_: @mut Module) -> ~str {
let mut idents = ~[];
let mut current_module = module_;
loop {
return self.idents_to_str(vec::reversed(idents));
}
- fn dump_module(@mut self, module_: @mut Module) {
+ pub fn dump_module(@mut self, module_: @mut Module) {
debug!("Dump of module `%s`:", self.module_to_str(module_));
debug!("Children:");
sret: bool
}
-pub impl FnType {
- fn decl_fn(&self, decl: &fn(fnty: TypeRef) -> ValueRef) -> ValueRef {
+impl FnType {
+ pub fn decl_fn(&self, decl: &fn(fnty: TypeRef) -> ValueRef) -> ValueRef {
let atys = vec::map(self.arg_tys, |t| t.ty);
let rty = self.ret_ty.ty;
let fnty = T_fn(atys, rty);
return llfn;
}
- fn build_shim_args(&self, bcx: block,
- arg_tys: &[TypeRef],
- llargbundle: ValueRef) -> ~[ValueRef] {
+ pub fn build_shim_args(&self,
+ bcx: block,
+ arg_tys: &[TypeRef],
+ llargbundle: ValueRef)
+ -> ~[ValueRef] {
let mut atys: &[LLVMType] = self.arg_tys;
let mut attrs: &[option::Option<Attribute>] = self.attrs;
return llargvals;
}
- fn build_shim_ret(&self,
- bcx: block,
- arg_tys: &[TypeRef],
- ret_def: bool,
- llargbundle: ValueRef,
- llretval: ValueRef) {
+ pub fn build_shim_ret(&self,
+ bcx: block,
+ arg_tys: &[TypeRef],
+ ret_def: bool,
+ llargbundle: ValueRef,
+ llretval: ValueRef) {
for vec::eachi(self.attrs) |i, a| {
match *a {
option::Some(attr) => {
};
}
- fn build_wrap_args(&self,
- bcx: block,
- ret_ty: TypeRef,
- llwrapfn: ValueRef,
- llargbundle: ValueRef) {
+ pub fn build_wrap_args(&self,
+ bcx: block,
+ ret_ty: TypeRef,
+ llwrapfn: ValueRef,
+ llargbundle: ValueRef) {
let mut atys: &[LLVMType] = self.arg_tys;
let mut attrs: &[option::Option<Attribute>] = self.attrs;
let mut j = 0u;
store_inbounds(bcx, llretptr, llargbundle, [0u, n]);
}
- fn build_wrap_ret(&self,
- bcx: block,
- arg_tys: &[TypeRef],
- llargbundle: ValueRef) {
+ pub fn build_wrap_ret(&self,
+ bcx: block,
+ arg_tys: &[TypeRef],
+ llargbundle: ValueRef) {
unsafe {
if llvm::LLVMGetTypeKind(self.ret_ty.ty) == Void {
return;
datum: Datum
}
-pub impl EnvAction {
- fn to_str(&self) -> ~str {
+impl EnvAction {
+ pub fn to_str(&self) -> ~str {
match *self {
EnvCopy => ~"EnvCopy",
EnvMove => ~"EnvMove",
}
}
-pub impl EnvValue {
- fn to_str(&self, ccx: @CrateContext) -> ~str {
+impl EnvValue {
+ pub fn to_str(&self, ccx: @CrateContext) -> ~str {
fmt!("%s(%s)", self.action.to_str(), self.datum.to_str(ccx))
}
}
self_ty: Option<ty::t>
}
-pub impl param_substs {
- fn validate(&self) {
+impl param_substs {
+ pub fn validate(&self) {
for self.tys.each |t| { assert!(!ty::type_needs_infer(*t)); }
for self.self_ty.each |t| { assert!(!ty::type_needs_infer(*t)); }
}
ccx: @@CrateContext
}
-pub impl fn_ctxt_ {
+impl fn_ctxt_ {
pub fn arg_pos(&self, arg: uint) -> uint {
if self.has_immediate_return_value {
arg + 1u
landing_pad: Option<BasicBlockRef>,
}
-pub impl scope_info {
- fn empty_cleanups(&mut self) -> bool {
+impl scope_info {
+ pub fn empty_cleanups(&mut self) -> bool {
self.cleanups.is_empty()
}
}
Result {bcx: bcx, val: val}
}
-pub impl Result {
- fn unpack(&self, bcx: &mut block) -> ValueRef {
+impl Result {
+ pub fn unpack(&self, bcx: &mut block) -> ValueRef {
*bcx = self.bcx;
return self.val;
}
// Accessors
-pub impl block_ {
- fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
- fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
- fn sess(@mut self) -> Session { self.fcx.ccx.sess }
+impl block_ {
+ pub fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
+ pub fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
+ pub fn sess(@mut self) -> Session { self.fcx.ccx.sess }
- fn node_id_to_str(@mut self, id: ast::node_id) -> ~str {
+ pub fn node_id_to_str(@mut self, id: ast::node_id) -> ~str {
ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
}
- fn expr_to_str(@mut self, e: @ast::expr) -> ~str {
+ pub fn expr_to_str(@mut self, e: @ast::expr) -> ~str {
e.repr(self.tcx())
}
- fn expr_is_lval(@mut self, e: @ast::expr) -> bool {
+ pub fn expr_is_lval(@mut self, e: @ast::expr) -> bool {
ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e)
}
- fn expr_kind(@mut self, e: @ast::expr) -> ty::ExprKind {
+ pub fn expr_kind(@mut self, e: @ast::expr) -> ty::ExprKind {
ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e)
}
- fn def(@mut self, nid: ast::node_id) -> ast::def {
+ pub fn def(@mut self, nid: ast::node_id) -> ast::def {
match self.tcx().def_map.find(&nid) {
Some(&v) => v,
None => {
}
}
- fn val_str(@mut self, val: ValueRef) -> @str {
+ pub fn val_str(@mut self, val: ValueRef) -> @str {
val_str(self.ccx().tn, val)
}
- fn llty_str(@mut self, llty: TypeRef) -> @str {
+ pub fn llty_str(@mut self, llty: TypeRef) -> @str {
ty_str(self.ccx().tn, llty)
}
- fn ty_to_str(@mut self, t: ty::t) -> ~str {
+ pub fn ty_to_str(@mut self, t: ty::t) -> ~str {
t.repr(self.tcx())
}
- fn to_str(@mut self) -> ~str {
+
+ pub fn to_str(@mut self) -> ~str {
unsafe {
match self.node_info {
Some(node_info) => fmt!("[block %d]", node_info.id),
ByValue,
}
-pub impl DatumMode {
- fn is_by_ref(&self) -> bool {
+impl DatumMode {
+ pub fn is_by_ref(&self) -> bool {
match *self { ByRef(_) => true, ByValue => false }
}
- fn is_by_value(&self) -> bool {
+ pub fn is_by_value(&self) -> bool {
match *self { ByRef(_) => false, ByValue => true }
}
}
}
}
-pub impl Datum {
- fn store_to(&self, bcx: block, id: ast::node_id,
- action: CopyAction, dst: ValueRef) -> block {
+impl Datum {
+ pub fn store_to(&self,
+ bcx: block,
+ id: ast::node_id,
+ action: CopyAction,
+ dst: ValueRef)
+ -> block {
/*!
*
* Stores this value into its final home. This moves if
}
}
- fn store_to_dest(&self, bcx: block, id: ast::node_id,
- dest: expr::Dest) -> block {
+ pub fn store_to_dest(&self,
+ bcx: block,
+ id: ast::node_id,
+ dest: expr::Dest)
+ -> block {
match dest {
expr::Ignore => {
return bcx;
}
}
- fn store_to_datum(&self, bcx: block, id: ast::node_id,
- action: CopyAction, datum: Datum) -> block {
+ pub fn store_to_datum(&self,
+ bcx: block,
+ id: ast::node_id,
+ action: CopyAction,
+ datum: Datum)
+ -> block {
debug!("store_to_datum(self=%s, action=%?, datum=%s)",
self.to_str(bcx.ccx()), action, datum.to_str(bcx.ccx()));
assert!(datum.mode.is_by_ref());
self.store_to(bcx, id, action, datum.val)
}
- fn move_to_datum(&self, bcx: block, action: CopyAction, datum: Datum)
- -> block {
+ pub fn move_to_datum(&self, bcx: block, action: CopyAction, datum: Datum)
+ -> block {
assert!(datum.mode.is_by_ref());
self.move_to(bcx, action, datum.val)
}
- fn copy_to_datum(&self, bcx: block, action: CopyAction, datum: Datum)
- -> block {
+ pub fn copy_to_datum(&self, bcx: block, action: CopyAction, datum: Datum)
+ -> block {
assert!(datum.mode.is_by_ref());
self.copy_to(bcx, action, datum.val)
}
- fn copy_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
- -> block {
+ pub fn copy_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
+ -> block {
/*!
*
* Copies the value into `dst`, which should be a pointer to a
}
}
- fn copy_to_no_check(&self, bcx: block, action: CopyAction,
- dst: ValueRef) -> block
- {
+ pub fn copy_to_no_check(&self,
+ bcx: block,
+ action: CopyAction,
+ dst: ValueRef)
+ -> block {
/*!
*
* A helper for `copy_to()` which does not check to see if we
// This works like copy_val, except that it deinitializes the source.
// Since it needs to zero out the source, src also needs to be an lval.
//
- fn move_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
- -> block {
+ pub fn move_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
+ -> block {
let _icx = bcx.insn_ctxt("move_to");
let mut bcx = bcx;
return bcx;
}
- fn add_clean(&self, bcx: block) {
+ pub fn add_clean(&self, bcx: block) {
/*!
* Schedules this datum for cleanup in `bcx`. The datum
* must be an rvalue.
}
}
- fn cancel_clean(&self, bcx: block) {
+ pub fn cancel_clean(&self, bcx: block) {
if ty::type_needs_drop(bcx.tcx(), self.ty) {
match self.mode {
ByValue |
}
}
- fn to_str(&self, ccx: &CrateContext) -> ~str {
+ pub fn to_str(&self, ccx: &CrateContext) -> ~str {
fmt!("Datum { val=%s, ty=%s, mode=%? }",
val_str(ccx.tn, self.val),
ty_to_str(ccx.tcx, self.ty),
self.mode)
}
- fn to_value_datum(&self, bcx: block) -> Datum {
+ pub fn to_value_datum(&self, bcx: block) -> Datum {
/*!
*
* Yields a by-ref form of this datum. This may involve
}
}
- fn to_value_llval(&self, bcx: block) -> ValueRef {
+ pub fn to_value_llval(&self, bcx: block) -> ValueRef {
/*!
*
* Yields the value itself. */
}
}
- fn to_ref_datum(&self, bcx: block) -> Datum {
+ pub fn to_ref_datum(&self, bcx: block) -> Datum {
/*!
* Yields a by-ref form of this datum. This may involve
* creation of a temporary stack slot. The value returned by
}
}
- fn to_ref_llval(&self, bcx: block) -> ValueRef {
+ pub fn to_ref_llval(&self, bcx: block) -> ValueRef {
match self.mode {
ByRef(_) => self.val,
ByValue => {
}
}
- fn to_zeroable_ref_llval(&self, bcx: block) -> ValueRef {
+ pub fn to_zeroable_ref_llval(&self, bcx: block) -> ValueRef {
/*!
* Returns a by-ref llvalue that can be zeroed in order to
* cancel cleanup. This is a kind of hokey bridge used
}
}
- fn appropriate_mode(&self) -> DatumMode {
+ pub fn appropriate_mode(&self) -> DatumMode {
/*! See the `appropriate_mode()` function */
appropriate_mode(self.ty)
}
- fn to_appropriate_llval(&self, bcx: block) -> ValueRef {
+ pub fn to_appropriate_llval(&self, bcx: block) -> ValueRef {
/*!
*
* Yields an llvalue with the `appropriate_mode()`. */
}
}
- fn to_appropriate_datum(&self, bcx: block) -> Datum {
+ pub fn to_appropriate_datum(&self, bcx: block) -> Datum {
/*!
*
* Yields a datum with the `appropriate_mode()`. */
}
}
- fn get_element(&self, bcx: block,
- ty: ty::t,
- source: DatumCleanup,
- gep: &fn(ValueRef) -> ValueRef) -> Datum {
+ pub fn get_element(&self,
+ bcx: block,
+ ty: ty::t,
+ source: DatumCleanup,
+ gep: &fn(ValueRef) -> ValueRef)
+ -> Datum {
let base_val = self.to_ref_llval(bcx);
Datum {
val: gep(base_val),
}
}
- fn drop_val(&self, bcx: block) -> block {
+ pub fn drop_val(&self, bcx: block) -> block {
if !ty::type_needs_drop(bcx.tcx(), self.ty) {
return bcx;
}
};
}
- fn box_body(&self, bcx: block) -> Datum {
+ pub fn box_body(&self, bcx: block) -> Datum {
/*!
*
* This datum must represent an @T or ~T box. Returns a new
Datum {val: body, ty: content_ty, mode: ByRef(ZeroMem)}
}
- fn to_rptr(&self, bcx: block) -> Datum {
+ pub fn to_rptr(&self, bcx: block) -> Datum {
//! Returns a new datum of region-pointer type containing the
//! the same ptr as this datum (after converting to by-ref
//! using `to_ref_llval()`).
Datum {val: llval, ty: rptr_ty, mode: ByValue}
}
- fn try_deref(&self,
- bcx: block, // block wherein to generate insn's
- span: span, // location where deref occurs
- expr_id: ast::node_id, // id of deref expr
- derefs: uint, // number of times deref'd already
- is_auto: bool) // if true, only deref if auto-derefable
- -> (Option<Datum>, block)
- {
+ /// bcx: Block wherein to generate insns.
+ /// span: Location where deref occurs.
+ /// expr_id: ID of deref expr.
+ /// derefs: Number of times deref'd already.
+ /// is_auto: If true, only deref if auto-derefable.
+ pub fn try_deref(&self,
+ bcx: block,
+ span: span,
+ expr_id: ast::node_id,
+ derefs: uint,
+ is_auto: bool)
+ -> (Option<Datum>, block) {
let ccx = bcx.ccx();
debug!("try_deref(expr_id=%?, derefs=%?, is_auto=%b, self=%?)",
}
}
- fn deref(&self, bcx: block,
- expr: @ast::expr, // the deref expression
- derefs: uint)
- -> DatumBlock {
+ /// expr: The deref expression.
+ pub fn deref(&self, bcx: block, expr: @ast::expr, derefs: uint)
+ -> DatumBlock {
match self.try_deref(bcx, expr.span, expr.id, derefs, false) {
(Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres },
(None, _) => {
}
}
- fn autoderef(&self, bcx: block,
- span: span,
- expr_id: ast::node_id,
- max: uint)
- -> DatumBlock {
+ pub fn autoderef(&self,
+ bcx: block,
+ span: span,
+ expr_id: ast::node_id,
+ max: uint)
+ -> DatumBlock {
let _icx = bcx.insn_ctxt("autoderef");
debug!("autoderef(expr_id=%d, max=%?, self=%?)",
DatumBlock { bcx: bcx, datum: datum }
}
- fn get_vec_base_and_len(&self,
- mut bcx: block,
- span: span,
- expr_id: ast::node_id,
- derefs: uint)
- -> (block, ValueRef, ValueRef) {
+ pub fn get_vec_base_and_len(&self,
+ mut bcx: block,
+ span: span,
+ expr_id: ast::node_id,
+ derefs: uint)
+ -> (block, ValueRef, ValueRef) {
//! Converts a vector into the slice pair. Performs rooting
//! and write guards checks.
(bcx, base, len)
}
- fn get_vec_base_and_len_no_root(&self, bcx: block) -> (ValueRef, ValueRef) {
+ pub fn get_vec_base_and_len_no_root(&self, bcx: block)
+ -> (ValueRef, ValueRef) {
//! Converts a vector into the slice pair. Des not root
//! nor perform write guard checks.
tvec::get_base_and_len(bcx, llval, self.ty)
}
- fn root_and_write_guard(&self,
- bcx: block,
- span: span,
- expr_id: ast::node_id,
- derefs: uint) -> block {
+ pub fn root_and_write_guard(&self,
+ bcx: block,
+ span: span,
+ expr_id: ast::node_id,
+ derefs: uint)
+ -> block {
write_guard::root_and_write_guard(self, bcx, span, expr_id, derefs)
}
- fn to_result(&self, bcx: block) -> common::Result {
+ pub fn to_result(&self, bcx: block) -> common::Result {
rslt(bcx, self.to_appropriate_llval(bcx))
}
}
-pub impl DatumBlock {
- fn unpack(&self, bcx: &mut block) -> Datum {
+impl DatumBlock {
+ pub fn unpack(&self, bcx: &mut block) -> Datum {
*bcx = self.bcx;
return self.datum;
}
- fn assert_by_ref(&self) -> DatumBlock {
+ pub fn assert_by_ref(&self) -> DatumBlock {
assert!(self.datum.mode.is_by_ref());
*self
}
- fn drop_val(&self) -> block {
+ pub fn drop_val(&self) -> block {
self.datum.drop_val(self.bcx)
}
- fn store_to(&self, id: ast::node_id, action: CopyAction,
- dst: ValueRef) -> block {
+ pub fn store_to(&self,
+ id: ast::node_id,
+ action: CopyAction,
+ dst: ValueRef)
+ -> block {
self.datum.store_to(self.bcx, id, action, dst)
}
- fn copy_to(&self, action: CopyAction, dst: ValueRef) -> block {
+ pub fn copy_to(&self, action: CopyAction, dst: ValueRef) -> block {
self.datum.copy_to(self.bcx, action, dst)
}
- fn move_to(&self, action: CopyAction, dst: ValueRef) -> block {
+ pub fn move_to(&self, action: CopyAction, dst: ValueRef) -> block {
self.datum.move_to(self.bcx, action, dst)
}
- fn to_value_llval(&self) -> ValueRef {
+ pub fn to_value_llval(&self) -> ValueRef {
self.datum.to_value_llval(self.bcx)
}
- fn to_result(&self) -> common::Result {
+ pub fn to_result(&self) -> common::Result {
rslt(self.bcx, self.datum.to_appropriate_llval(self.bcx))
}
- fn ccx(&self) -> @CrateContext {
+ pub fn ccx(&self) -> @CrateContext {
self.bcx.ccx()
}
- fn tcx(&self) -> ty::ctxt {
+ pub fn tcx(&self) -> ty::ctxt {
self.bcx.tcx()
}
- fn to_str(&self) -> ~str {
+ pub fn to_str(&self) -> ~str {
self.datum.to_str(self.ccx())
}
}
Ignore,
}
-pub impl Dest {
- fn to_str(&self, ccx: @CrateContext) -> ~str {
+impl Dest {
+ pub fn to_str(&self, ccx: @CrateContext) -> ~str {
match *self {
SaveIn(v) => fmt!("SaveIn(%s)", val_str(ccx.tn, v)),
Ignore => ~"Ignore"
bcx: block
}
-pub impl Reflector {
- fn c_uint(&mut self, u: uint) -> ValueRef {
+impl Reflector {
+ pub fn c_uint(&mut self, u: uint) -> ValueRef {
C_uint(self.bcx.ccx(), u)
}
- fn c_int(&mut self, i: int) -> ValueRef {
+ pub fn c_int(&mut self, i: int) -> ValueRef {
C_int(self.bcx.ccx(), i)
}
- fn c_slice(&mut self, s: @~str) -> ValueRef {
+ pub fn c_slice(&mut self, s: @~str) -> ValueRef {
// We're careful to not use first class aggregates here because that
// will kick us off fast isel. (Issue #4352.)
let bcx = self.bcx;
scratch.val
}
- fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] {
+ pub fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] {
let tr = type_of(self.bcx.ccx(), t);
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
let a = machine::llalign_of_min(self.bcx.ccx(), tr);
self.c_uint(a)];
}
- fn c_tydesc(&mut self, t: ty::t) -> ValueRef {
+ pub fn c_tydesc(&mut self, t: ty::t) -> ValueRef {
let bcx = self.bcx;
let static_ti = get_tydesc(bcx.ccx(), t);
glue::lazily_emit_all_tydesc_glue(bcx.ccx(), static_ti);
PointerCast(bcx, static_ti.tydesc, T_ptr(self.tydesc_ty))
}
- fn c_mt(&mut self, mt: &ty::mt) -> ~[ValueRef] {
+ pub fn c_mt(&mut self, mt: &ty::mt) -> ~[ValueRef] {
~[self.c_uint(mt.mutbl as uint),
self.c_tydesc(mt.ty)]
}
- fn visit(&mut self, ty_name: ~str, args: &[ValueRef]) {
+ pub fn visit(&mut self, ty_name: ~str, args: &[ValueRef]) {
let tcx = self.bcx.tcx();
let mth_idx = ty::method_idx(
tcx.sess.ident_of(~"visit_" + ty_name),
self.bcx = next_bcx
}
- fn bracketed(&mut self,
- bracket_name: ~str,
- extra: &[ValueRef],
- inner: &fn(&mut Reflector)) {
+ pub fn bracketed(&mut self,
+ bracket_name: ~str,
+ extra: &[ValueRef],
+ inner: &fn(&mut Reflector)) {
self.visit(~"enter_" + bracket_name, extra);
inner(self);
self.visit(~"leave_" + bracket_name, extra);
}
- fn vstore_name_and_extra(&mut self,
- t: ty::t,
- vstore: ty::vstore) -> (~str, ~[ValueRef])
- {
+ pub fn vstore_name_and_extra(&mut self,
+ t: ty::t,
+ vstore: ty::vstore)
+ -> (~str, ~[ValueRef]) {
match vstore {
ty::vstore_fixed(n) => {
let extra = vec::append(~[self.c_uint(n)],
}
}
- fn leaf(&mut self, name: ~str) {
+ pub fn leaf(&mut self, name: ~str) {
self.visit(name, []);
}
// Entrypoint
- fn visit_ty(&mut self, t: ty::t) {
+ pub fn visit_ty(&mut self, t: ty::t) {
let bcx = self.bcx;
debug!("reflect::visit_ty %s",
ty_to_str(bcx.ccx().tcx, t));
}
}
- fn visit_sig(&mut self, retval: uint, sig: &ty::FnSig) {
+ pub fn visit_sig(&mut self, retval: uint, sig: &ty::FnSig) {
for sig.inputs.eachi |i, arg| {
let modeval = 5u; // "by copy"
let extra = ~[self.c_uint(i),
llunit_size: ValueRef
}
-pub impl VecTypes {
- fn to_str(&self, ccx: @CrateContext) -> ~str {
+impl VecTypes {
+ pub fn to_str(&self, ccx: @CrateContext) -> ~str {
fmt!("VecTypes {vec_ty=%s, unit_ty=%s, llunit_ty=%s, llunit_size=%s}",
ty_to_str(ccx.tcx, self.vec_ty),
ty_to_str(ccx.tcx, self.unit_ty),
def_id: ast::def_id
}
-pub impl Method {
- fn new(ident: ast::ident,
- generics: ty::Generics,
- transformed_self_ty: Option<ty::t>,
- fty: BareFnTy,
- explicit_self: ast::explicit_self_,
- vis: ast::visibility,
- def_id: ast::def_id) -> Method {
+impl Method {
+ pub fn new(ident: ast::ident,
+ generics: ty::Generics,
+ transformed_self_ty: Option<ty::t>,
+ fty: BareFnTy,
+ explicit_self: ast::explicit_self_,
+ vis: ast::visibility,
+ def_id: ast::def_id)
+ -> Method {
// Check the invariants.
if explicit_self == ast::sty_static {
assert!(transformed_self_ty.is_none());
re_empty,
}
-pub impl Region {
- fn is_bound(&self) -> bool {
+impl Region {
+ pub fn is_bound(&self) -> bool {
match self {
&re_bound(*) => true,
_ => false
region_param: Option<region_variance>,
}
-pub impl Generics {
- fn has_type_params(&self) -> bool {
+impl Generics {
+ pub fn has_type_params(&self) -> bool {
!self.type_param_defs.is_empty()
}
}
bits: u32
}
-pub impl TypeContents {
- fn meets_bounds(&self, cx: ctxt, bbs: BuiltinBounds) -> bool {
+impl TypeContents {
+ pub fn meets_bounds(&self, cx: ctxt, bbs: BuiltinBounds) -> bool {
iter::all(|bb| self.meets_bound(cx, bb), |f| bbs.each(f))
}
- fn meets_bound(&self, cx: ctxt, bb: BuiltinBound) -> bool {
+ pub fn meets_bound(&self, cx: ctxt, bb: BuiltinBound) -> bool {
match bb {
BoundCopy => self.is_copy(cx),
BoundStatic => self.is_static(cx),
}
}
- fn intersects(&self, tc: TypeContents) -> bool {
+ pub fn intersects(&self, tc: TypeContents) -> bool {
(self.bits & tc.bits) != 0
}
- fn is_copy(&self, cx: ctxt) -> bool {
+ pub fn is_copy(&self, cx: ctxt) -> bool {
!self.intersects(TypeContents::noncopyable(cx))
}
- fn noncopyable(_cx: ctxt) -> TypeContents {
+ pub fn noncopyable(_cx: ctxt) -> TypeContents {
TC_DTOR + TC_BORROWED_MUT + TC_ONCE_CLOSURE + TC_OWNED_CLOSURE +
TC_EMPTY_ENUM
}
- fn is_static(&self, cx: ctxt) -> bool {
+ pub fn is_static(&self, cx: ctxt) -> bool {
!self.intersects(TypeContents::nonstatic(cx))
}
- fn nonstatic(_cx: ctxt) -> TypeContents {
+ pub fn nonstatic(_cx: ctxt) -> TypeContents {
TC_BORROWED_POINTER
}
- fn is_owned(&self, cx: ctxt) -> bool {
+ pub fn is_owned(&self, cx: ctxt) -> bool {
!self.intersects(TypeContents::nonowned(cx))
}
- fn nonowned(_cx: ctxt) -> TypeContents {
+ pub fn nonowned(_cx: ctxt) -> TypeContents {
TC_MANAGED + TC_BORROWED_POINTER + TC_NON_OWNED
}
- fn contains_managed(&self) -> bool {
+ pub fn contains_managed(&self) -> bool {
self.intersects(TC_MANAGED)
}
- fn is_const(&self, cx: ctxt) -> bool {
+ pub fn is_const(&self, cx: ctxt) -> bool {
!self.intersects(TypeContents::nonconst(cx))
}
- fn nonconst(_cx: ctxt) -> TypeContents {
+ pub fn nonconst(_cx: ctxt) -> TypeContents {
TC_MUTABLE
}
- fn is_sized(&self, cx: ctxt) -> bool {
+ pub fn is_sized(&self, cx: ctxt) -> bool {
!self.intersects(TypeContents::dynamically_sized(cx))
}
- fn dynamically_sized(_cx: ctxt) -> TypeContents {
+ pub fn dynamically_sized(_cx: ctxt) -> TypeContents {
TC_DYNAMIC_SIZE
}
- fn moves_by_default(&self, cx: ctxt) -> bool {
+ pub fn moves_by_default(&self, cx: ctxt) -> bool {
self.intersects(TypeContents::nonimplicitly_copyable(cx))
}
- fn nonimplicitly_copyable(cx: ctxt) -> TypeContents {
+ pub fn nonimplicitly_copyable(cx: ctxt) -> TypeContents {
TypeContents::noncopyable(cx) + TC_OWNED_POINTER + TC_OWNED_VEC
}
- fn needs_drop(&self, cx: ctxt) -> bool {
+ pub fn needs_drop(&self, cx: ctxt) -> bool {
let tc = TC_MANAGED + TC_DTOR + TypeContents::owned(cx);
self.intersects(tc)
}
- fn owned(_cx: ctxt) -> TypeContents {
+ pub fn owned(_cx: ctxt) -> TypeContents {
//! Any kind of owned contents.
TC_OWNED_CLOSURE + TC_OWNED_POINTER + TC_OWNED_VEC
}
}
}
-pub impl AutoRef {
- fn map_region(&self, f: &fn(Region) -> Region) -> AutoRef {
+impl AutoRef {
+ pub fn map_region(&self, f: &fn(Region) -> Region) -> AutoRef {
match *self {
ty::AutoPtr(r, m) => ty::AutoPtr(f(r), m),
ty::AutoBorrowVec(r, m) => ty::AutoBorrowVec(f(r), m),
TraitDtor(def_id)
}
-pub impl DtorKind {
- fn is_not_present(&const self) -> bool {
+impl DtorKind {
+ pub fn is_not_present(&const self) -> bool {
match *self {
NoDtor => true,
_ => false
}
}
- fn is_present(&const self) -> bool {
+
+ pub fn is_present(&const self) -> bool {
!self.is_not_present()
}
}
origin: method_origin,
}
-pub impl<'self> LookupContext<'self> {
- fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
+impl<'self> LookupContext<'self> {
+ pub fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
let self_ty = structurally_resolved_type(self.fcx,
self.self_expr.span,
self_ty);
self.search_for_autosliced_method(self_ty, autoderefs)
}
- fn deref(&self, ty: ty::t, enum_dids: &mut ~[ast::def_id])
- -> Option<ty::t> {
+ pub fn deref(&self, ty: ty::t, enum_dids: &mut ~[ast::def_id])
+ -> Option<ty::t> {
match ty::get(ty).sty {
ty_enum(did, _) => {
// Watch out for newtype'd enums like "enum t = @T".
// ______________________________________________________________________
// Candidate collection (see comment at start of file)
- fn push_inherent_candidates(&self, self_ty: ty::t) {
+ pub fn push_inherent_candidates(&self, self_ty: ty::t) {
/*!
* Collect all inherent candidates into
* `self.inherent_candidates`. See comment at the start of
}
}
- fn push_extension_candidates(&self, self_ty: ty::t) {
+ pub fn push_extension_candidates(&self, self_ty: ty::t) {
// If the method being called is associated with a trait, then
// find all the impls of that trait. Each of those are
// candidates.
}
}
- fn push_inherent_candidates_from_param(&self,
- rcvr_ty: ty::t,
- param_ty: param_ty) {
+ pub fn push_inherent_candidates_from_param(&self,
+ rcvr_ty: ty::t,
+ param_ty: param_ty) {
debug!("push_inherent_candidates_from_param(param_ty=%?)",
param_ty);
let _indenter = indenter();
}
}
- fn push_inherent_candidates_from_trait(&self,
- self_ty: ty::t,
- did: def_id,
- substs: &ty::substs,
- store: ty::TraitStore) {
+ pub fn push_inherent_candidates_from_trait(&self,
+ self_ty: ty::t,
+ did: def_id,
+ substs: &ty::substs,
+ store: ty::TraitStore) {
debug!("push_inherent_candidates_from_trait(did=%s, substs=%s)",
self.did_to_str(did),
substs_to_str(self.tcx(), substs));
});
}
- fn push_inherent_candidates_from_self(&self,
- self_ty: ty::t,
- did: def_id,
- substs: &ty::substs) {
+ pub fn push_inherent_candidates_from_self(&self,
+ self_ty: ty::t,
+ did: def_id,
+ substs: &ty::substs) {
struct MethodInfo {
method_ty: @ty::Method,
trait_def_id: ast::def_id,
}
}
- fn push_inherent_impl_candidates_for_type(&self, did: def_id) {
+ pub fn push_inherent_impl_candidates_for_type(&self, did: def_id) {
let opt_impl_infos =
self.fcx.ccx.coherence_info.inherent_methods.find(&did);
for opt_impl_infos.each |impl_infos| {
}
}
- fn push_candidates_from_impl(&self, candidates: &mut ~[Candidate],
- impl_info: &resolve::Impl) {
+ pub fn push_candidates_from_impl(&self,
+ candidates: &mut ~[Candidate],
+ impl_info: &resolve::Impl) {
if !self.impl_dups.insert(impl_info.did) {
return; // already visited
}
});
}
- fn push_candidates_from_provided_methods(
- &self,
- candidates: &mut ~[Candidate],
- self_ty: ty::t,
- trait_def_id: def_id,
- methods: &mut ~[@ProvidedMethodInfo]) {
+ pub fn push_candidates_from_provided_methods(&self,
+ candidates:
+ &mut ~[Candidate],
+ self_ty: ty::t,
+ trait_def_id: def_id,
+ methods:
+ &mut ~[@ProvidedMethodInfo])
+ {
debug!("(pushing candidates from provided methods) considering trait \
id %d:%d",
trait_def_id.crate,
// ______________________________________________________________________
// Candidate selection (see comment at start of file)
- fn search_for_autoderefd_method(
- &self,
- self_ty: ty::t,
- autoderefs: uint)
- -> Option<method_map_entry>
- {
+ pub fn search_for_autoderefd_method(&self,
+ self_ty: ty::t,
+ autoderefs: uint)
+ -> Option<method_map_entry> {
let (self_ty, autoadjust) =
self.consider_reborrow(self_ty, autoderefs);
match self.search_for_method(self_ty) {
}
}
- fn consider_reborrow(&self,
- self_ty: ty::t,
- autoderefs: uint) -> (ty::t, ty::AutoAdjustment)
- {
+ pub fn consider_reborrow(&self,
+ self_ty: ty::t,
+ autoderefs: uint)
+ -> (ty::t, ty::AutoAdjustment) {
/*!
*
* In the event that we are invoking a method with a receiver
}
}
- fn search_for_autosliced_method(
- &self,
- self_ty: ty::t,
- autoderefs: uint)
- -> Option<method_map_entry>
- {
+ pub fn search_for_autosliced_method(&self,
+ self_ty: ty::t,
+ autoderefs: uint)
+ -> Option<method_map_entry> {
/*!
*
* Searches for a candidate by converting things like
}
}
- fn search_for_autoptrd_method(
- &self,
- self_ty: ty::t,
- autoderefs: uint)
- -> Option<method_map_entry>
- {
+ pub fn search_for_autoptrd_method(&self, self_ty: ty::t, autoderefs: uint)
+ -> Option<method_map_entry> {
/*!
*
* Converts any type `T` to `&M T` where `M` is an
}
}
- fn search_for_some_kind_of_autorefd_method(
+ pub fn search_for_some_kind_of_autorefd_method(
&self,
kind: &fn(Region, ast::mutability) -> ty::AutoRef,
autoderefs: uint,
mutbls: &[ast::mutability],
mk_autoref_ty: &fn(ast::mutability, ty::Region) -> ty::t)
- -> Option<method_map_entry>
- {
+ -> Option<method_map_entry> {
// This is hokey. We should have mutability inference as a
// variable. But for now, try &const, then &, then &mut:
let region = self.infcx().next_region_var_nb(self.expr.span);
return None;
}
- fn search_for_method(&self,
- rcvr_ty: ty::t)
- -> Option<method_map_entry>
- {
+ pub fn search_for_method(&self, rcvr_ty: ty::t)
+ -> Option<method_map_entry> {
debug!("search_for_method(rcvr_ty=%s)", self.ty_to_str(rcvr_ty));
let _indenter = indenter();
}
}
- fn consider_candidates(&self,
- rcvr_ty: ty::t,
- candidates: &mut ~[Candidate])
- -> Option<method_map_entry>
- {
+ pub fn consider_candidates(&self,
+ rcvr_ty: ty::t,
+ candidates: &mut ~[Candidate])
+ -> Option<method_map_entry> {
let relevant_candidates =
candidates.filter_to_vec(|c| self.is_relevant(rcvr_ty, c));
Some(self.confirm_candidate(rcvr_ty, &relevant_candidates[0]))
}
- fn merge_candidates(&self, candidates: &[Candidate]) -> ~[Candidate] {
+ pub fn merge_candidates(&self, candidates: &[Candidate]) -> ~[Candidate] {
let mut merged = ~[];
let mut i = 0;
while i < candidates.len() {
return merged;
}
- fn confirm_candidate(&self,
- rcvr_ty: ty::t,
- candidate: &Candidate)
- -> method_map_entry
- {
+ pub fn confirm_candidate(&self, rcvr_ty: ty::t, candidate: &Candidate)
+ -> method_map_entry {
let tcx = self.tcx();
let fty = self.fn_ty_from_origin(&candidate.origin);
}
}
- fn enforce_trait_instance_limitations(&self,
- method_fty: ty::t,
- candidate: &Candidate)
- {
+ pub fn enforce_trait_instance_limitations(&self,
+ method_fty: ty::t,
+ candidate: &Candidate) {
/*!
*
* There are some limitations to calling functions through a
}
}
- fn enforce_drop_trait_limitations(&self, candidate: &Candidate) {
+ pub fn enforce_drop_trait_limitations(&self, candidate: &Candidate) {
// No code can call the finalize method explicitly.
let bad;
match candidate.origin {
// `rcvr_ty` is the type of the expression. It may be a subtype of a
// candidate method's `self_ty`.
- fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
+ pub fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
debug!("is_relevant(rcvr_ty=%s, candidate=%s)",
self.ty_to_str(rcvr_ty), self.cand_to_str(candidate));
}
}
- fn fn_ty_from_origin(&self, origin: &method_origin) -> ty::t {
+ pub fn fn_ty_from_origin(&self, origin: &method_origin) -> ty::t {
return match *origin {
method_static(did) => {
ty::lookup_item_type(self.tcx(), did).ty
}
}
- fn report_candidate(&self, idx: uint, origin: &method_origin) {
+ pub fn report_candidate(&self, idx: uint, origin: &method_origin) {
match *origin {
method_static(impl_did) => {
self.report_static_candidate(idx, impl_did)
}
}
- fn report_static_candidate(&self, idx: uint, did: def_id) {
+ pub fn report_static_candidate(&self, idx: uint, did: def_id) {
let span = if did.crate == ast::local_crate {
match self.tcx().items.find(&did.node) {
Some(&ast_map::node_method(m, _, _)) => m.span,
ty::item_path_str(self.tcx(), did)));
}
- fn report_param_candidate(&self, idx: uint, did: def_id) {
+ pub fn report_param_candidate(&self, idx: uint, did: def_id) {
self.tcx().sess.span_note(
self.expr.span,
fmt!("candidate #%u derives from the bound `%s`",
ty::item_path_str(self.tcx(), did)));
}
- fn report_trait_candidate(&self, idx: uint, did: def_id) {
+ pub fn report_trait_candidate(&self, idx: uint, did: def_id) {
self.tcx().sess.span_note(
self.expr.span,
fmt!("candidate #%u derives from the type of the receiver, \
ty::item_path_str(self.tcx(), did)));
}
- fn infcx(&self) -> @mut infer::InferCtxt {
+ pub fn infcx(&self) -> @mut infer::InferCtxt {
self.fcx.inh.infcx
}
- fn tcx(&self) -> ty::ctxt {
+ pub fn tcx(&self) -> ty::ctxt {
self.fcx.tcx()
}
- fn ty_to_str(&self, t: ty::t) -> ~str {
+ pub fn ty_to_str(&self, t: ty::t) -> ~str {
self.fcx.infcx().ty_to_str(t)
}
- fn cand_to_str(&self, cand: &Candidate) -> ~str {
+ pub fn cand_to_str(&self, cand: &Candidate) -> ~str {
fmt!("Candidate(rcvr_ty=%s, rcvr_substs=%s, origin=%?)",
self.ty_to_str(cand.rcvr_ty),
ty::substs_to_str(self.tcx(), &cand.rcvr_substs),
cand.origin)
}
- fn did_to_str(&self, did: def_id) -> ~str {
+ pub fn did_to_str(&self, did: def_id) -> ~str {
ty::item_path_str(self.tcx(), did)
}
- fn bug(&self, s: ~str) -> ! {
+ pub fn bug(&self, s: ~str) -> ! {
self.tcx().sess.bug(s)
}
}
priv from_fn: bool
}
-pub impl PurityState {
+impl PurityState {
pub fn function(purity: ast::purity, def: ast::node_id) -> PurityState {
PurityState { def: def, purity: purity, from_fn: true }
}
}
}
-pub impl FnCtxt {
- fn infcx(&self) -> @mut infer::InferCtxt {
+impl FnCtxt {
+ pub fn infcx(&self) -> @mut infer::InferCtxt {
self.inh.infcx
}
- fn err_count_since_creation(&self) -> uint {
+ pub fn err_count_since_creation(&self) -> uint {
self.ccx.tcx.sess.err_count() - self.err_count_on_creation
}
- fn search_in_scope_regions(
- &self,
- span: span,
- br: ty::bound_region) -> Result<ty::Region, RegionError>
- {
+ pub fn search_in_scope_regions(&self,
+ span: span,
+ br: ty::bound_region)
+ -> Result<ty::Region, RegionError> {
let in_scope_regions = self.in_scope_regions;
match in_scope_regions.find(br) {
Some(r) => result::Ok(r),
}
}
-pub impl FnCtxt {
- fn tag(&self) -> ~str {
+impl FnCtxt {
+ pub fn tag(&self) -> ~str {
unsafe {
fmt!("%x", transmute(self))
}
}
- fn local_ty(&self, span: span, nid: ast::node_id) -> ty::t {
+ pub fn local_ty(&self, span: span, nid: ast::node_id) -> ty::t {
match self.inh.locals.find(&nid) {
Some(&t) => t,
None => {
}
}
- fn expr_to_str(&self, expr: @ast::expr) -> ~str {
+ pub fn expr_to_str(&self, expr: @ast::expr) -> ~str {
fmt!("expr(%?:%s)", expr.id,
pprust::expr_to_str(expr, self.tcx().sess.intr()))
}
- fn block_region(&self) -> ty::Region {
+ pub fn block_region(&self) -> ty::Region {
ty::re_scope(self.region_lb)
}
#[inline(always)]
- fn write_ty(&self, node_id: ast::node_id, ty: ty::t) {
+ pub fn write_ty(&self, node_id: ast::node_id, ty: ty::t) {
debug!("write_ty(%d, %s) in fcx %s",
node_id, ppaux::ty_to_str(self.tcx(), ty), self.tag());
self.inh.node_types.insert(node_id, ty);
}
- fn write_substs(&self, node_id: ast::node_id, substs: ty::substs) {
+ pub fn write_substs(&self, node_id: ast::node_id, substs: ty::substs) {
if !ty::substs_is_noop(&substs) {
debug!("write_substs(%d, %s) in fcx %s",
node_id,
}
}
- fn write_ty_substs(&self,
- node_id: ast::node_id,
- ty: ty::t,
- substs: ty::substs) {
+ pub fn write_ty_substs(&self,
+ node_id: ast::node_id,
+ ty: ty::t,
+ substs: ty::substs) {
let ty = ty::subst(self.tcx(), &substs, ty);
self.write_ty(node_id, ty);
self.write_substs(node_id, substs);
}
- fn write_autoderef_adjustment(&self,
- node_id: ast::node_id,
- derefs: uint) {
+ pub fn write_autoderef_adjustment(&self,
+ node_id: ast::node_id,
+ derefs: uint) {
if derefs == 0 { return; }
self.write_adjustment(
node_id,
);
}
- fn write_adjustment(&self,
- node_id: ast::node_id,
- adj: @ty::AutoAdjustment) {
+ pub fn write_adjustment(&self,
+ node_id: ast::node_id,
+ adj: @ty::AutoAdjustment) {
debug!("write_adjustment(node_id=%?, adj=%?)", node_id, adj);
self.inh.adjustments.insert(node_id, adj);
}
- fn write_nil(&self, node_id: ast::node_id) {
+ pub fn write_nil(&self, node_id: ast::node_id) {
self.write_ty(node_id, ty::mk_nil());
}
- fn write_bot(&self, node_id: ast::node_id) {
+ pub fn write_bot(&self, node_id: ast::node_id) {
self.write_ty(node_id, ty::mk_bot());
}
- fn write_error(@mut self, node_id: ast::node_id) {
+ pub fn write_error(@mut self, node_id: ast::node_id) {
self.write_ty(node_id, ty::mk_err());
}
- fn to_ty(&self, ast_t: @ast::Ty) -> ty::t {
+ pub fn to_ty(&self, ast_t: @ast::Ty) -> ty::t {
ast_ty_to_ty(self, self, ast_t)
}
- fn expr_to_str(&self, expr: @ast::expr) -> ~str {
+ pub fn expr_to_str(&self, expr: @ast::expr) -> ~str {
expr.repr(self.tcx())
}
- fn pat_to_str(&self, pat: @ast::pat) -> ~str {
+ pub fn pat_to_str(&self, pat: @ast::pat) -> ~str {
pat.repr(self.tcx())
}
- fn expr_ty(&self, ex: @ast::expr) -> ty::t {
+ pub fn expr_ty(&self, ex: @ast::expr) -> ty::t {
match self.inh.node_types.find(&ex.id) {
Some(&t) => t,
None => {
}
}
}
- fn node_ty(&self, id: ast::node_id) -> ty::t {
+
+ pub fn node_ty(&self, id: ast::node_id) -> ty::t {
match self.inh.node_types.find(&id) {
Some(&t) => t,
None => {
}
}
}
- fn node_ty_substs(&self, id: ast::node_id) -> ty::substs {
+
+ pub fn node_ty_substs(&self, id: ast::node_id) -> ty::substs {
match self.inh.node_type_substs.find(&id) {
Some(ts) => (/*bad*/copy *ts),
None => {
}
}
- fn opt_node_ty_substs(&self, id: ast::node_id,
- f: &fn(&ty::substs) -> bool) -> bool {
+ pub fn opt_node_ty_substs(&self,
+ id: ast::node_id,
+ f: &fn(&ty::substs) -> bool)
+ -> bool {
match self.inh.node_type_substs.find(&id) {
Some(s) => f(s),
None => true
}
}
- fn mk_subty(&self,
- a_is_expected: bool,
- span: span,
- sub: ty::t,
- sup: ty::t)
- -> Result<(), ty::type_err> {
+ pub fn mk_subty(&self,
+ a_is_expected: bool,
+ span: span,
+ sub: ty::t,
+ sup: ty::t)
+ -> Result<(), ty::type_err> {
infer::mk_subty(self.infcx(), a_is_expected, span, sub, sup)
}
- fn can_mk_subty(&self,
- sub: ty::t,
- sup: ty::t)
- -> Result<(), ty::type_err> {
+ pub fn can_mk_subty(&self, sub: ty::t, sup: ty::t)
+ -> Result<(), ty::type_err> {
infer::can_mk_subty(self.infcx(), sub, sup)
}
- fn mk_assignty(&self, expr: @ast::expr, sub: ty::t, sup: ty::t)
- -> Result<(), ty::type_err> {
+ pub fn mk_assignty(&self, expr: @ast::expr, sub: ty::t, sup: ty::t)
+ -> Result<(), ty::type_err> {
match infer::mk_coercety(self.infcx(), false, expr.span, sub, sup) {
Ok(None) => result::Ok(()),
Err(ref e) => result::Err((*e)),
}
}
- fn can_mk_assignty(&self,
- sub: ty::t,
- sup: ty::t)
- -> Result<(), ty::type_err> {
+ pub fn can_mk_assignty(&self, sub: ty::t, sup: ty::t)
+ -> Result<(), ty::type_err> {
infer::can_mk_coercety(self.infcx(), sub, sup)
}
- fn mk_eqty(&self,
- a_is_expected: bool,
- span: span,
- sub: ty::t,
- sup: ty::t)
- -> Result<(), ty::type_err> {
+ pub fn mk_eqty(&self,
+ a_is_expected: bool,
+ span: span,
+ sub: ty::t,
+ sup: ty::t)
+ -> Result<(), ty::type_err> {
infer::mk_eqty(self.infcx(), a_is_expected, span, sub, sup)
}
- fn mk_subr(&self,
- a_is_expected: bool,
- span: span,
- sub: ty::Region,
- sup: ty::Region)
- -> Result<(), ty::type_err> {
+ pub fn mk_subr(&self,
+ a_is_expected: bool,
+ span: span,
+ sub: ty::Region,
+ sup: ty::Region)
+ -> Result<(), ty::type_err> {
infer::mk_subr(self.infcx(), a_is_expected, span, sub, sup)
}
- fn with_region_lb<R>(@mut self, lb: ast::node_id, f: &fn() -> R) -> R {
+ pub fn with_region_lb<R>(@mut self, lb: ast::node_id, f: &fn() -> R)
+ -> R {
let old_region_lb = self.region_lb;
self.region_lb = lb;
let v = f();
v
}
- fn region_var_if_parameterized(&self,
- rp: Option<ty::region_variance>,
- span: span)
- -> Option<ty::Region> {
+ pub fn region_var_if_parameterized(&self,
+ rp: Option<ty::region_variance>,
+ span: span)
+ -> Option<ty::Region> {
rp.map(|_rp| self.infcx().next_region_var_nb(span))
}
- fn type_error_message(&self,
- sp: span,
- mk_msg: &fn(~str) -> ~str,
- actual_ty: ty::t,
- err: Option<&ty::type_err>) {
+ pub fn type_error_message(&self,
+ sp: span,
+ mk_msg: &fn(~str) -> ~str,
+ actual_ty: ty::t,
+ err: Option<&ty::type_err>) {
self.infcx().type_error_message(sp, mk_msg, actual_ty, err);
}
- fn report_mismatched_return_types(&self,
- sp: span,
- e: ty::t,
- a: ty::t,
- err: &ty::type_err) {
+ pub fn report_mismatched_return_types(&self,
+ sp: span,
+ e: ty::t,
+ a: ty::t,
+ err: &ty::type_err) {
// Derived error
if ty::type_is_error(e) || ty::type_is_error(a) {
return;
}
}
- fn report_mismatched_types(&self,
- sp: span,
- e: ty::t,
- a: ty::t,
- err: &ty::type_err) {
+ pub fn report_mismatched_types(&self,
+ sp: span,
+ e: ty::t,
+ a: ty::t,
+ err: &ty::type_err) {
self.infcx().report_mismatched_types(sp, e, a, err)
}
}
}
}
-pub impl Rcx {
- fn tcx(&self) -> ty::ctxt {
+impl Rcx {
+ pub fn tcx(&self) -> ty::ctxt {
self.fcx.ccx.tcx
}
- fn resolve_type(&mut self, unresolved_ty: ty::t) -> ty::t {
+ pub fn resolve_type(&mut self, unresolved_ty: ty::t) -> ty::t {
/*!
* Try to resolve the type for the given node, returning
* t_err if an error results. Note that we never care
}
/// Try to resolve the type for the given node.
- fn resolve_node_type(@mut self, id: ast::node_id) -> ty::t {
+ pub fn resolve_node_type(@mut self, id: ast::node_id) -> ty::t {
self.resolve_type(self.fcx.node_ty(id))
}
/// Try to resolve the type for the given node.
- fn resolve_expr_type_adjusted(@mut self, expr: @ast::expr) -> ty::t {
+ pub fn resolve_expr_type_adjusted(@mut self, expr: @ast::expr) -> ty::t {
let ty_unadjusted = self.resolve_node_type(expr.id);
if ty::type_is_error(ty_unadjusted) || ty::type_is_bot(ty_unadjusted) {
ty_unadjusted
infcx: @mut infer::InferCtxt
}
-pub impl VtableContext {
- fn tcx(&const self) -> ty::ctxt { self.ccx.tcx }
+impl VtableContext {
+ pub fn tcx(&const self) -> ty::ctxt { self.ccx.tcx }
}
fn has_trait_bounds(type_param_defs: &[ty::TypeParameterDef]) -> bool {
base_type_def_ids: @mut HashMap<def_id,def_id>,
}
-pub impl CoherenceChecker {
- fn check_coherence(self, crate: @crate) {
+impl CoherenceChecker {
+ pub fn check_coherence(self, crate: @crate) {
// Check implementations and traits. This populates the tables
// containing the inherent methods and extension methods. It also
// builds up the trait inheritance table.
self.populate_destructor_table();
}
- fn check_implementation(&self,
- item: @item, associated_traits: ~[@trait_ref]) {
+ pub fn check_implementation(&self,
+ item: @item,
+ associated_traits: ~[@trait_ref]) {
let tcx = self.crate_context.tcx;
let self_type = ty::lookup_item_type(tcx, local_def(item.id));
// Creates default method IDs and performs type substitutions for an impl
// and trait pair. Then, for each provided method in the trait, inserts a
// `ProvidedMethodInfo` instance into the `provided_method_sources` map.
- fn instantiate_default_methods(&self,
- impl_id: ast::node_id,
- trait_ref: &ty::TraitRef) {
+ pub fn instantiate_default_methods(&self,
+ impl_id: ast::node_id,
+ trait_ref: &ty::TraitRef) {
let tcx = self.crate_context.tcx;
debug!("instantiate_default_methods(impl_id=%?, trait_ref=%s)",
impl_id, trait_ref.repr(tcx));
}
}
- fn add_inherent_method(&self,
- base_def_id: def_id, implementation: @Impl) {
+ pub fn add_inherent_method(&self,
+ base_def_id: def_id,
+ implementation: @Impl) {
let implementation_list;
match self.crate_context.coherence_info.inherent_methods
.find(&base_def_id) {
implementation_list.push(implementation);
}
- fn add_trait_method(&self, trait_id: def_id, implementation: @Impl) {
+ pub fn add_trait_method(&self, trait_id: def_id, implementation: @Impl) {
let implementation_list;
match self.crate_context.coherence_info.extension_methods
.find(&trait_id) {
implementation_list.push(implementation);
}
- fn check_implementation_coherence(&self) {
+ pub fn check_implementation_coherence(&self) {
let coherence_info = self.crate_context.coherence_info;
for coherence_info.extension_methods.each_key |&trait_id| {
self.check_implementation_coherence_of(trait_id);
}
}
- fn check_implementation_coherence_of(&self, trait_def_id: def_id) {
-
+ pub fn check_implementation_coherence_of(&self, trait_def_id: def_id) {
// Unify pairs of polytypes.
do self.iter_impls_of_trait(trait_def_id) |a| {
let implementation_a = a;
// Adds an impl of trait trait_t for self type self_t; that impl
// is the_impl
- fn add_impl_for_trait(&self,
- trait_t: def_id, self_t: t, the_impl: @Impl) {
+ pub fn add_impl_for_trait(&self,
+ trait_t: def_id,
+ self_t: t,
+ the_impl: @Impl) {
debug!("Adding impl %? of %? for %s",
the_impl.did, trait_t,
ty_to_str(self.crate_context.tcx, self_t));
}
}
- fn iter_impls_of_trait(&self, trait_def_id: def_id, f: &fn(@Impl)) {
+ pub fn iter_impls_of_trait(&self, trait_def_id: def_id, f: &fn(@Impl)) {
let coherence_info = self.crate_context.coherence_info;
let extension_methods = &*coherence_info.extension_methods;
}
}
- fn each_provided_trait_method(&self,
- trait_did: ast::def_id,
- f: &fn(x: @ty::Method) -> bool) -> bool {
+ pub fn each_provided_trait_method(&self,
+ trait_did: ast::def_id,
+ f: &fn(x: @ty::Method) -> bool)
+ -> bool {
// Make a list of all the names of the provided methods.
// XXX: This is horrible.
let mut provided_method_idents = HashSet::new();
return true;
}
- fn polytypes_unify(&self, polytype_a: ty_param_bounds_and_ty,
- polytype_b: ty_param_bounds_and_ty)
- -> bool {
+ pub fn polytypes_unify(&self,
+ polytype_a: ty_param_bounds_and_ty,
+ polytype_b: ty_param_bounds_and_ty)
+ -> bool {
let universally_quantified_a =
self.universally_quantify_polytype(polytype_a);
let universally_quantified_b =
// Converts a polytype to a monotype by replacing all parameters with
// type variables. Returns the monotype and the type variables created.
- fn universally_quantify_polytype(&self, polytype: ty_param_bounds_and_ty)
- -> UniversalQuantificationResult {
+ pub fn universally_quantify_polytype(&self,
+ polytype: ty_param_bounds_and_ty)
+ -> UniversalQuantificationResult {
// NDM--this span is bogus.
let self_region =
polytype.generics.region_param.map(
}
}
- fn can_unify_universally_quantified<'a>
- (&self,
- a: &'a UniversalQuantificationResult,
- b: &'a UniversalQuantificationResult)
- -> bool {
+ pub fn can_unify_universally_quantified<'a>(&self,
+ a: &'a
+ UniversalQuantificationResult,
+ b: &'a
+ UniversalQuantificationResult)
+ -> bool {
let mut might_unify = true;
let _ = do self.inference_context.probe {
let result = self.inference_context.sub(true, dummy_sp())
might_unify
}
- fn get_self_type_for_implementation(&self, implementation: @Impl)
- -> ty_param_bounds_and_ty {
+ pub fn get_self_type_for_implementation(&self, implementation: @Impl)
+ -> ty_param_bounds_and_ty {
return self.crate_context.tcx.tcache.get_copy(&implementation.did);
}
// Privileged scope checking
- fn check_privileged_scopes(self, crate: @crate) {
+ pub fn check_privileged_scopes(self, crate: @crate) {
visit_crate(crate, (), mk_vt(@Visitor {
visit_item: |item, _context, visitor| {
match item.node {
}));
}
- fn trait_ref_to_trait_def_id(&self, trait_ref: @trait_ref) -> def_id {
+ pub fn trait_ref_to_trait_def_id(&self, trait_ref: @trait_ref) -> def_id {
let def_map = self.crate_context.tcx.def_map;
let trait_def = def_map.get_copy(&trait_ref.ref_id);
let trait_id = def_id_of_def(trait_def);
// This check doesn't really have anything to do with coherence. It's
// here for historical reasons
- fn please_check_that_trait_methods_are_implemented(&self,
- all_methods: &mut ~[@MethodInfo],
- trait_did: def_id,
- trait_ref_span: span) {
+ pub fn please_check_that_trait_methods_are_implemented(&self,
+ all_methods:
+ &mut
+ ~[@MethodInfo],
+ trait_did: def_id,
+ trait_ref_span:
+ span) {
let tcx = self.crate_context.tcx;
}
// Converts an implementation in the AST to an Impl structure.
- fn create_impl_from_item(&self, item: @item) -> @Impl {
+ pub fn create_impl_from_item(&self, item: @item) -> @Impl {
fn add_provided_methods(all_methods: &mut ~[@MethodInfo],
all_provided_methods: &mut ~[@ProvidedMethodInfo],
sess: driver::session::Session) {
}
}
- fn span_of_impl(&self, implementation: @Impl) -> span {
+ pub fn span_of_impl(&self, implementation: @Impl) -> span {
assert_eq!(implementation.did.crate, local_crate);
match self.crate_context.tcx.items.find(&implementation.did.node) {
Some(&node_item(item, _)) => {
// External crate handling
- fn add_impls_for_module(&self, impls_seen: &mut HashSet<def_id>,
- crate_store: @mut CStore,
- module_def_id: def_id) {
+ pub fn add_impls_for_module(&self,
+ impls_seen: &mut HashSet<def_id>,
+ crate_store: @mut CStore,
+ module_def_id: def_id) {
let implementations = get_impls_for_mod(crate_store,
module_def_id,
None);
}
}
- fn add_default_methods_for_external_trait(&self,
- trait_def_id: ast::def_id) {
+ pub fn add_default_methods_for_external_trait(&self,
+ trait_def_id: ast::def_id) {
let tcx = self.crate_context.tcx;
let pmm = tcx.provided_methods;
// Adds implementations and traits from external crates to the coherence
// info.
- fn add_external_crates(&self) {
+ pub fn add_external_crates(&self) {
let mut impls_seen = HashSet::new();
let crate_store = self.crate_context.tcx.sess.cstore;
// Destructors
//
- fn populate_destructor_table(&self) {
+ pub fn populate_destructor_table(&self) {
let coherence_info = self.crate_context.coherence_info;
let tcx = self.crate_context.tcx;
let drop_trait = tcx.lang_items.drop_trait();
}
}
-fn subst_receiver_types_in_method_ty(
- tcx: ty::ctxt,
- impl_id: ast::node_id,
- trait_ref: &ty::TraitRef,
- new_def_id: ast::def_id,
- method: &ty::Method) -> ty::Method
-{
+fn subst_receiver_types_in_method_ty(tcx: ty::ctxt,
+ impl_id: ast::node_id,
+ trait_ref: &ty::TraitRef,
+ new_def_id: ast::def_id,
+ method: &ty::Method)
+ -> ty::Method {
/*!
* Substitutes the values for the receiver's type parameters
* that are found in method, leaving the method's type parameters
// function.
pub struct Coerce(CombineFields);
-pub impl Coerce {
- fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
+impl Coerce {
+ pub fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
debug!("Coerce.tys(%s => %s)",
a.inf_str(self.infcx),
b.inf_str(self.infcx));
}
}
- fn subtype(&self, a: ty::t, b: ty::t) -> CoerceResult {
+ pub fn subtype(&self, a: ty::t, b: ty::t) -> CoerceResult {
match Sub(**self).tys(a, b) {
Ok(_) => Ok(None), // No coercion required.
Err(ref e) => Err(*e)
}
}
- fn unpack_actual_value(&self,
- a: ty::t,
- f: &fn(&ty::sty) -> CoerceResult) -> CoerceResult
- {
+ pub fn unpack_actual_value(&self,
+ a: ty::t,
+ f: &fn(&ty::sty) -> CoerceResult)
+ -> CoerceResult {
match resolve_type(self.infcx, a, try_resolve_tvar_shallow) {
Ok(t) => {
f(&ty::get(t).sty)
}
}
- fn coerce_borrowed_pointer(&self,
- a: ty::t,
- sty_a: &ty::sty,
- b: ty::t,
- mt_b: ty::mt) -> CoerceResult
- {
+ pub fn coerce_borrowed_pointer(&self,
+ a: ty::t,
+ sty_a: &ty::sty,
+ b: ty::t,
+ mt_b: ty::mt)
+ -> CoerceResult {
debug!("coerce_borrowed_pointer(a=%s, sty_a=%?, b=%s, mt_b=%?)",
a.inf_str(self.infcx), sty_a,
b.inf_str(self.infcx), mt_b);
})))
}
- fn coerce_borrowed_string(&self,
- a: ty::t,
- sty_a: &ty::sty,
- b: ty::t) -> CoerceResult
- {
+ pub fn coerce_borrowed_string(&self,
+ a: ty::t,
+ sty_a: &ty::sty,
+ b: ty::t)
+ -> CoerceResult {
debug!("coerce_borrowed_string(a=%s, sty_a=%?, b=%s)",
a.inf_str(self.infcx), sty_a,
b.inf_str(self.infcx));
})))
}
- fn coerce_borrowed_vector(&self,
- a: ty::t,
- sty_a: &ty::sty,
- b: ty::t,
- mt_b: ty::mt) -> CoerceResult
- {
+ pub fn coerce_borrowed_vector(&self,
+ a: ty::t,
+ sty_a: &ty::sty,
+ b: ty::t,
+ mt_b: ty::mt)
+ -> CoerceResult {
debug!("coerce_borrowed_vector(a=%s, sty_a=%?, b=%s)",
a.inf_str(self.infcx), sty_a,
b.inf_str(self.infcx));
})))
}
- fn coerce_borrowed_fn(&self,
- a: ty::t,
- sty_a: &ty::sty,
- b: ty::t) -> CoerceResult
- {
+ pub fn coerce_borrowed_fn(&self,
+ a: ty::t,
+ sty_a: &ty::sty,
+ b: ty::t)
+ -> CoerceResult {
debug!("coerce_borrowed_fn(a=%s, sty_a=%?, b=%s)",
a.inf_str(self.infcx), sty_a,
b.inf_str(self.infcx));
})))
}
- fn coerce_from_bare_fn(&self,
- a: ty::t,
- fn_ty_a: &ty::BareFnTy,
- b: ty::t) -> CoerceResult
- {
+ pub fn coerce_from_bare_fn(&self,
+ a: ty::t,
+ fn_ty_a: &ty::BareFnTy,
+ b: ty::t)
+ -> CoerceResult {
do self.unpack_actual_value(b) |sty_b| {
self.coerce_from_bare_fn_post_unpack(a, fn_ty_a, b, sty_b)
}
}
- fn coerce_from_bare_fn_post_unpack(&self,
- a: ty::t,
- fn_ty_a: &ty::BareFnTy,
- b: ty::t,
- sty_b: &ty::sty) -> CoerceResult
- {
+ pub fn coerce_from_bare_fn_post_unpack(&self,
+ a: ty::t,
+ fn_ty_a: &ty::BareFnTy,
+ b: ty::t,
+ sty_b: &ty::sty)
+ -> CoerceResult {
/*!
*
* Attempts to coerce from a bare Rust function (`extern
Ok(Some(adj))
}
- fn coerce_unsafe_ptr(&self,
- a: ty::t,
- sty_a: &ty::sty,
- b: ty::t,
- mt_b: ty::mt) -> CoerceResult
- {
+ pub fn coerce_unsafe_ptr(&self,
+ a: ty::t,
+ sty_a: &ty::sty,
+ b: ty::t,
+ mt_b: ty::mt)
+ -> CoerceResult {
debug!("coerce_unsafe_ptr(a=%s, sty_a=%?, b=%s)",
a.inf_str(self.infcx), sty_a,
b.inf_str(self.infcx));
}
}
-pub impl CombineFields {
- fn var_sub_var<T:Copy + InferStr + LatticeValue,
- V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
- &self,
- a_id: V,
- b_id: V) -> ures
- {
+impl CombineFields {
+ pub fn var_sub_var<T:Copy + InferStr + LatticeValue,
+ V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(&self,
+ a_id:
+ V,
+ b_id:
+ V)
+ ->
+ ures {
/*!
*
* Make one variable a subtype of another variable. This is a
}
/// make variable a subtype of T
- fn var_sub_t<T:Copy + InferStr + LatticeValue,
- V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
- &self,
- a_id: V,
- b: T) -> ures
- {
+ pub fn var_sub_t<T:Copy + InferStr + LatticeValue,
+ V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(&self,
+ a_id: V,
+ b: T)
+ -> ures
+ {
/*!
*
* Make a variable (`a_id`) a subtype of the concrete type `b` */
a_id, a_bounds, b_bounds, node_a.rank)
}
- fn t_sub_var<T:Copy + InferStr + LatticeValue,
- V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
- &self,
- a: T,
- b_id: V) -> ures
- {
+ pub fn t_sub_var<T:Copy + InferStr + LatticeValue,
+ V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(&self,
+ a: T,
+ b_id: V)
+ -> ures
+ {
/*!
*
* Make a concrete type (`a`) a subtype of the variable `b_id` */
b_id, a_bounds, b_bounds, node_b.rank)
}
- fn merge_bnd<T:Copy + InferStr + LatticeValue>(
- &self,
- a: &Bound<T>,
- b: &Bound<T>,
- lattice_op: LatticeOp<T>)
- -> cres<Bound<T>>
- {
+ pub fn merge_bnd<T:Copy + InferStr + LatticeValue>(&self,
+ a: &Bound<T>,
+ b: &Bound<T>,
+ lattice_op:
+ LatticeOp<T>)
+ -> cres<Bound<T>> {
/*!
*
* Combines two bounds into a more general bound. */
}
}
- fn set_var_to_merged_bounds<T:Copy + InferStr + LatticeValue,
- V:Copy+Eq+ToStr+Vid+UnifyVid<Bounds<T>>>(
- &self,
- v_id: V,
- a: &Bounds<T>,
- b: &Bounds<T>,
- rank: uint) -> ures
- {
+ pub fn set_var_to_merged_bounds<T:Copy + InferStr + LatticeValue,
+ V:Copy+Eq+ToStr+Vid+UnifyVid<Bounds<T>>>(
+ &self,
+ v_id: V,
+ a: &Bounds<T>,
+ b: &Bounds<T>,
+ rank: uint)
+ -> ures {
/*!
*
* Updates the bounds for the variable `v_id` to be the intersection
uok()
}
- fn bnds<T:Copy + InferStr + LatticeValue>(
- &self,
- a: &Bound<T>,
- b: &Bound<T>) -> ures
- {
+ pub fn bnds<T:Copy + InferStr + LatticeValue>(&self,
+ a: &Bound<T>,
+ b: &Bound<T>)
+ -> ures {
debug!("bnds(%s <: %s)", a.inf_str(self.infcx),
b.inf_str(self.infcx));
let _r = indenter();
pub struct Lub(CombineFields); // least-upper-bound: common supertype
-pub impl Lub {
- fn bot_ty(&self, b: ty::t) -> cres<ty::t> { Ok(b) }
- fn ty_bot(&self, b: ty::t)
- -> cres<ty::t> { self.bot_ty(b) } // commutative
+impl Lub {
+ pub fn bot_ty(&self, b: ty::t) -> cres<ty::t> { Ok(b) }
+ pub fn ty_bot(&self, b: ty::t) -> cres<ty::t> {
+ self.bot_ty(b) // commutative
+ }
}
impl Combine for Lub {
region_vars_snapshot: uint,
}
-pub impl InferCtxt {
- fn combine_fields(@mut self,
- a_is_expected: bool,
- span: span) -> CombineFields {
+impl InferCtxt {
+ pub fn combine_fields(@mut self, a_is_expected: bool, span: span)
+ -> CombineFields {
CombineFields {infcx: self,
a_is_expected: a_is_expected,
span: span}
}
- fn sub(@mut self, a_is_expected: bool, span: span) -> Sub {
+ pub fn sub(@mut self, a_is_expected: bool, span: span) -> Sub {
Sub(self.combine_fields(a_is_expected, span))
}
- fn in_snapshot(&self) -> bool {
+ pub fn in_snapshot(&self) -> bool {
self.region_vars.in_snapshot()
}
- fn start_snapshot(&mut self) -> Snapshot {
+ pub fn start_snapshot(&mut self) -> Snapshot {
Snapshot {
ty_var_bindings_len:
self.ty_var_bindings.bindings.len(),
}
}
- fn rollback_to(&mut self, snapshot: &Snapshot) {
+ pub fn rollback_to(&mut self, snapshot: &Snapshot) {
debug!("rollback!");
rollback_to(&mut self.ty_var_bindings, snapshot.ty_var_bindings_len);
}
/// Execute `f` and commit the bindings if successful
- fn commit<T,E>(@mut self, f: &fn() -> Result<T,E>) -> Result<T,E> {
+ pub fn commit<T,E>(@mut self, f: &fn() -> Result<T,E>) -> Result<T,E> {
assert!(!self.in_snapshot());
debug!("commit()");
}
/// Execute `f`, unroll bindings on failure
- fn try<T,E>(@mut self, f: &fn() -> Result<T,E>) -> Result<T,E> {
+ pub fn try<T,E>(@mut self, f: &fn() -> Result<T,E>) -> Result<T,E> {
debug!("try()");
do indent {
let snapshot = self.start_snapshot();
}
/// Execute `f` then unroll any bindings it creates
- fn probe<T,E>(@mut self, f: &fn() -> Result<T,E>) -> Result<T,E> {
+ pub fn probe<T,E>(@mut self, f: &fn() -> Result<T,E>) -> Result<T,E> {
debug!("probe()");
do indent {
let snapshot = self.start_snapshot();
return id;
}
-pub impl InferCtxt {
- fn next_ty_var_id(&mut self) -> TyVid {
+impl InferCtxt {
+ pub fn next_ty_var_id(&mut self) -> TyVid {
let id = self.ty_var_counter;
self.ty_var_counter += 1;
{
return TyVid(id);
}
- fn next_ty_var(&mut self) -> ty::t {
+ pub fn next_ty_var(&mut self) -> ty::t {
ty::mk_var(self.tcx, self.next_ty_var_id())
}
- fn next_ty_vars(&mut self, n: uint) -> ~[ty::t] {
+ pub fn next_ty_vars(&mut self, n: uint) -> ~[ty::t] {
vec::from_fn(n, |_i| self.next_ty_var())
}
- fn next_int_var_id(&mut self) -> IntVid {
+ pub fn next_int_var_id(&mut self) -> IntVid {
IntVid(next_simple_var(&mut self.int_var_counter,
&mut self.int_var_bindings))
}
- fn next_int_var(&mut self) -> ty::t {
+ pub fn next_int_var(&mut self) -> ty::t {
ty::mk_int_var(self.tcx, self.next_int_var_id())
}
- fn next_float_var_id(&mut self) -> FloatVid {
+ pub fn next_float_var_id(&mut self) -> FloatVid {
FloatVid(next_simple_var(&mut self.float_var_counter,
&mut self.float_var_bindings))
}
- fn next_float_var(&mut self) -> ty::t {
+ pub fn next_float_var(&mut self) -> ty::t {
ty::mk_float_var(self.tcx, self.next_float_var_id())
}
- fn next_region_var_nb(&mut self, span: span) -> ty::Region {
+ pub fn next_region_var_nb(&mut self, span: span) -> ty::Region {
ty::re_infer(ty::ReVar(self.region_vars.new_region_var(span)))
}
- fn next_region_var_with_lb(&mut self, span: span,
- lb_region: ty::Region) -> ty::Region {
+ pub fn next_region_var_with_lb(&mut self,
+ span: span,
+ lb_region: ty::Region)
+ -> ty::Region {
let region_var = self.next_region_var_nb(span);
// add lb_region as a lower bound on the newly built variable
return region_var;
}
- fn next_region_var(&mut self, span: span, scope_id: ast::node_id)
- -> ty::Region {
+ pub fn next_region_var(&mut self, span: span, scope_id: ast::node_id)
+ -> ty::Region {
self.next_region_var_with_lb(span, ty::re_scope(scope_id))
}
- fn resolve_regions(&mut self) {
+ pub fn resolve_regions(&mut self) {
self.region_vars.resolve_regions();
}
- fn ty_to_str(@mut self, t: ty::t) -> ~str {
+ pub fn ty_to_str(@mut self, t: ty::t) -> ~str {
ty_to_str(self.tcx,
self.resolve_type_vars_if_possible(t))
}
- fn trait_ref_to_str(@mut self, t: &ty::TraitRef) -> ~str {
+ pub fn trait_ref_to_str(@mut self, t: &ty::TraitRef) -> ~str {
let t = self.resolve_type_vars_in_trait_ref_if_possible(t);
trait_ref_to_str(self.tcx, &t)
}
- fn resolve_type_vars_if_possible(@mut self, typ: ty::t) -> ty::t {
+ pub fn resolve_type_vars_if_possible(@mut self, typ: ty::t) -> ty::t {
match resolve_type(self, typ, resolve_nested_tvar | resolve_ivar) {
result::Ok(new_type) => new_type,
result::Err(_) => typ
}
}
- fn resolve_type_vars_in_trait_ref_if_possible(@mut self,
- trait_ref: &ty::TraitRef)
- -> ty::TraitRef
- {
+
+ pub fn resolve_type_vars_in_trait_ref_if_possible(@mut self,
+ trait_ref:
+ &ty::TraitRef)
+ -> ty::TraitRef {
// make up a dummy type just to reuse/abuse the resolve machinery
let dummy0 = ty::mk_trait(self.tcx,
trait_ref.def_id,
}
}
- fn type_error_message_str(@mut self,
- sp: span,
- mk_msg: &fn(Option<~str>, ~str) -> ~str,
- actual_ty: ~str, err: Option<&ty::type_err>) {
+ pub fn type_error_message_str(@mut self,
+ sp: span,
+ mk_msg: &fn(Option<~str>, ~str) -> ~str,
+ actual_ty: ~str,
+ err: Option<&ty::type_err>) {
self.type_error_message_str_with_expected(sp, mk_msg, None, actual_ty, err)
}
- fn type_error_message_str_with_expected(@mut self,
- sp: span,
- mk_msg: &fn(Option<~str>, ~str) -> ~str,
- expected_ty: Option<ty::t>, actual_ty: ~str,
- err: Option<&ty::type_err>) {
+ pub fn type_error_message_str_with_expected(@mut self,
+ sp: span,
+ mk_msg:
+ &fn(Option<~str>, ~str) ->
+ ~str,
+ expected_ty: Option<ty::t>,
+ actual_ty: ~str,
+ err: Option<&ty::type_err>) {
debug!("hi! expected_ty = %?, actual_ty = %s", expected_ty, actual_ty);
let error_str = err.map_default(~"", |t_err|
}
}
- fn type_error_message(@mut self,
- sp: span,
- mk_msg: &fn(~str) -> ~str,
- actual_ty: ty::t,
- err: Option<&ty::type_err>) {
+ pub fn type_error_message(@mut self,
+ sp: span,
+ mk_msg: &fn(~str) -> ~str,
+ actual_ty: ty::t,
+ err: Option<&ty::type_err>) {
let actual_ty = self.resolve_type_vars_if_possible(actual_ty);
// Don't report an error if actual type is ty_err.
self.type_error_message_str(sp, |_e, a| { mk_msg(a) }, self.ty_to_str(actual_ty), err);
}
- fn report_mismatched_types(@mut self, sp: span, e: ty::t, a: ty::t,
- err: &ty::type_err) {
+ pub fn report_mismatched_types(@mut self,
+ sp: span,
+ e: ty::t,
+ a: ty::t,
+ err: &ty::type_err) {
let resolved_expected =
self.resolve_type_vars_if_possible(e);
let mk_msg = match ty::get(resolved_expected).sty {
self.type_error_message(sp, mk_msg, a, Some(err));
}
- fn replace_bound_regions_with_fresh_regions(&mut self,
- span: span,
- fsig: &ty::FnSig)
- -> (ty::FnSig, isr_alist) {
+ pub fn replace_bound_regions_with_fresh_regions(&mut self,
+ span: span,
+ fsig: &ty::FnSig)
+ -> (ty::FnSig,
+ isr_alist) {
let(isr, _, fn_sig) =
replace_bound_regions_in_fn_sig(self.tcx, @Nil, None, fsig, |br| {
// N.B.: The name of the bound region doesn't have anything to
}
}
-pub impl RegionVarBindings {
- fn in_snapshot(&self) -> bool {
+impl RegionVarBindings {
+ pub fn in_snapshot(&self) -> bool {
self.undo_log.len() > 0
}
- fn start_snapshot(&mut self) -> uint {
+ pub fn start_snapshot(&mut self) -> uint {
debug!("RegionVarBindings: snapshot()=%u", self.undo_log.len());
if self.in_snapshot() {
self.undo_log.len()
}
}
- fn commit(&mut self) {
+ pub fn commit(&mut self) {
debug!("RegionVarBindings: commit()");
while self.undo_log.len() > 0 {
self.undo_log.pop();
}
}
- fn rollback_to(&mut self, snapshot: uint) {
+ pub fn rollback_to(&mut self, snapshot: uint) {
debug!("RegionVarBindings: rollback_to(%u)", snapshot);
while self.undo_log.len() > snapshot {
let undo_item = self.undo_log.pop();
}
}
- fn num_vars(&mut self) -> uint {
+ pub fn num_vars(&mut self) -> uint {
self.var_spans.len()
}
- fn new_region_var(&mut self, span: span) -> RegionVid {
+ pub fn new_region_var(&mut self, span: span) -> RegionVid {
let id = self.num_vars();
self.var_spans.push(span);
let vid = RegionVid { id: id };
return vid;
}
- fn new_skolemized(&mut self, br: ty::bound_region) -> Region {
+ pub fn new_skolemized(&mut self, br: ty::bound_region) -> Region {
let sc = self.skolemization_count;
self.skolemization_count += 1;
re_infer(ReSkolemized(sc, br))
}
- fn new_bound(&mut self) -> Region {
+ pub fn new_bound(&mut self) -> Region {
// Creates a fresh bound variable for use in GLB computations.
// See discussion of GLB computation in the large comment at
// the top of this file for more details.
re_bound(br_fresh(sc))
}
- fn add_constraint(&mut self, constraint: Constraint, span: span) {
+ pub fn add_constraint(&mut self, constraint: Constraint, span: span) {
// cannot add constraints once regions are resolved
assert!(self.values.is_empty());
}
}
- fn make_subregion(&mut self,
- span: span,
- sub: Region,
- sup: Region) -> cres<()> {
+ pub fn make_subregion(&mut self, span: span, sub: Region, sup: Region)
+ -> cres<()> {
// cannot add constraints once regions are resolved
assert!(self.values.is_empty());
}
}
- fn lub_regions(&mut self,
- span: span,
- a: Region,
- b: Region)
- -> cres<Region> {
+ pub fn lub_regions(&mut self, span: span, a: Region, b: Region)
+ -> cres<Region> {
// cannot add constraints once regions are resolved
assert!(self.values.is_empty());
}
}
- fn glb_regions(&mut self,
- span: span,
- a: Region,
- b: Region)
- -> cres<Region> {
+ pub fn glb_regions(&mut self, span: span, a: Region, b: Region)
+ -> cres<Region> {
// cannot add constraints once regions are resolved
assert!(self.values.is_empty());
}
}
- fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
+ pub fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
if self.values.is_empty() {
self.tcx.sess.span_bug(
self.var_spans[rid.to_uint()],
}
}
- fn combine_vars(&mut self,
- t: CombineMapType,
- a: Region,
- b: Region,
- span: span,
- relate: &fn(this: &mut RegionVarBindings,
- old_r: Region,
- new_r: Region) -> cres<()>)
- -> cres<Region> {
+ pub fn combine_vars(&mut self,
+ t: CombineMapType,
+ a: Region,
+ b: Region,
+ span: span,
+ relate: &fn(this: &mut RegionVarBindings,
+ old_r: Region,
+ new_r: Region) -> cres<()>)
+ -> cres<Region> {
let vars = TwoRegions { a: a, b: b };
let c;
{
}
}
- fn vars_created_since_snapshot(&mut self,
- snapshot: uint)
- -> ~[RegionVid] {
+ pub fn vars_created_since_snapshot(&mut self, snapshot: uint)
+ -> ~[RegionVid] {
do vec::build |push| {
for uint::range(snapshot, self.undo_log.len()) |i| {
match self.undo_log[i] {
}
}
- fn tainted(&mut self, snapshot: uint, r0: Region) -> ~[Region] {
+ pub fn tainted(&mut self, snapshot: uint, r0: Region) -> ~[Region] {
/*!
*
* Computes all regions that have been related to `r0` in any
constraints, assuming such values can be found; if they cannot,
errors are reported.
*/
- fn resolve_regions(&mut self) {
+ pub fn resolve_regions(&mut self) {
debug!("RegionVarBindings: resolve_regions()");
let v = self.infer_variable_values();
self.values.put_back(v);
}
}
-priv impl RegionVarBindings {
+impl RegionVarBindings {
fn is_subregion_of(&self, sub: Region, sup: Region) -> bool {
let rm = self.tcx.region_maps;
rm.is_subregion_of(sub, sup)
span: span,
}
-pub impl RegionVarBindings {
- fn infer_variable_values(&mut self) -> ~[GraphNodeValue] {
+impl RegionVarBindings {
+ pub fn infer_variable_values(&mut self) -> ~[GraphNodeValue] {
let mut graph = self.construct_graph();
self.expansion(&mut graph);
self.contraction(&mut graph);
self.extract_values_and_report_conflicts(&graph)
}
- fn construct_graph(&mut self) -> Graph {
+ pub fn construct_graph(&mut self) -> Graph {
let num_vars = self.num_vars();
let num_edges = self.constraints.len();
}
}
- fn expansion(&mut self, graph: &mut Graph) {
+ pub fn expansion(&mut self, graph: &mut Graph) {
do iterate_until_fixed_point(~"Expansion", graph) |nodes, edge| {
match edge.constraint {
ConstrainRegSubVar(a_region, b_vid) => {
}
}
- fn expand_node(&mut self,
- a_region: Region,
- b_vid: RegionVid,
- b_node: &mut GraphNode)
- -> bool {
+ pub fn expand_node(&mut self,
+ a_region: Region,
+ b_vid: RegionVid,
+ b_node: &mut GraphNode)
+ -> bool {
debug!("expand_node(%?, %? == %?)",
a_region, b_vid, b_node.value);
}
}
- fn contraction(&mut self, graph: &mut Graph) {
+ pub fn contraction(&mut self, graph: &mut Graph) {
do iterate_until_fixed_point(~"Contraction", graph) |nodes, edge| {
match edge.constraint {
ConstrainRegSubVar(*) => {
}
}
- fn contract_node(&mut self,
- a_vid: RegionVid,
- a_node: &mut GraphNode,
- b_region: Region)
- -> bool {
+ pub fn contract_node(&mut self,
+ a_vid: RegionVid,
+ a_node: &mut GraphNode,
+ b_region: Region)
+ -> bool {
debug!("contract_node(%? == %?/%?, %?)",
a_vid, a_node.value, a_node.classification, b_region);
}
}
- fn extract_values_and_report_conflicts(
- &mut self,
- graph: &Graph) -> ~[GraphNodeValue]
- {
+ pub fn extract_values_and_report_conflicts(&mut self, graph: &Graph)
+ -> ~[GraphNodeValue] {
debug!("extract_values_and_report_conflicts()");
// This is the best way that I have found to suppress
})
}
- fn report_error_for_expanding_node(&mut self,
- graph: &Graph,
- dup_vec: &mut [uint],
- node_idx: RegionVid) {
+ pub fn report_error_for_expanding_node(&mut self,
+ graph: &Graph,
+ dup_vec: &mut [uint],
+ node_idx: RegionVid) {
// Errors in expanding nodes result from a lower-bound that is
// not contained by an upper-bound.
let (lower_bounds, lower_dup) =
upper_bounds.map(|x| x.region).repr(self.tcx)));
}
- fn report_error_for_contracting_node(&mut self,
- graph: &Graph,
- dup_vec: &mut [uint],
- node_idx: RegionVid) {
+ pub fn report_error_for_contracting_node(&mut self,
+ graph: &Graph,
+ dup_vec: &mut [uint],
+ node_idx: RegionVid) {
// Errors in contracting nodes result from two upper-bounds
// that have no intersection.
let (upper_bounds, dup_found) =
upper_bounds.map(|x| x.region).repr(self.tcx)));
}
- fn collect_concrete_regions(&mut self,
- graph: &Graph,
- orig_node_idx: RegionVid,
- dir: Direction,
- dup_vec: &mut [uint])
- -> (~[SpannedRegion], bool) {
+ pub fn collect_concrete_regions(&mut self,
+ graph: &Graph,
+ orig_node_idx: RegionVid,
+ dir: Direction,
+ dup_vec: &mut [uint])
+ -> (~[SpannedRegion], bool) {
struct WalkState {
set: HashSet<RegionVid>,
stack: ~[RegionVid],
}
}
- fn each_edge(&mut self,
- graph: &Graph,
- node_idx: RegionVid,
- dir: Direction,
- op: &fn(edge: &GraphEdge) -> bool) -> bool {
+ pub fn each_edge(&mut self,
+ graph: &Graph,
+ node_idx: RegionVid,
+ dir: Direction,
+ op: &fn(edge: &GraphEdge) -> bool)
+ -> bool {
let mut edge_idx =
graph.nodes[node_idx.to_uint()].head_edge[dir as uint];
while edge_idx != uint::max_value {
}
}
-pub impl ResolveState {
- fn should(&mut self, mode: uint) -> bool {
+impl ResolveState {
+ pub fn should(&mut self, mode: uint) -> bool {
(self.modes & mode) == mode
}
- fn resolve_type_chk(&mut self, typ: ty::t) -> fres<ty::t> {
+ pub fn resolve_type_chk(&mut self, typ: ty::t) -> fres<ty::t> {
self.err = None;
debug!("Resolving %s (modes=%x)",
}
}
- fn resolve_region_chk(&mut self, orig: ty::Region) -> fres<ty::Region> {
+ pub fn resolve_region_chk(&mut self, orig: ty::Region)
+ -> fres<ty::Region> {
self.err = None;
let resolved = indent(|| self.resolve_region(orig) );
match self.err {
}
}
- fn resolve_type(&mut self, typ: ty::t) -> ty::t {
+ pub fn resolve_type(&mut self, typ: ty::t) -> ty::t {
debug!("resolve_type(%s)", typ.inf_str(self.infcx));
let _i = indenter();
}
}
- fn resolve_region(&mut self, orig: ty::Region) -> ty::Region {
+ pub fn resolve_region(&mut self, orig: ty::Region) -> ty::Region {
debug!("Resolve_region(%s)", orig.inf_str(self.infcx));
match orig {
ty::re_infer(ty::ReVar(rid)) => self.resolve_region_var(rid),
}
}
- fn resolve_region_var(&mut self, rid: RegionVid) -> ty::Region {
+ pub fn resolve_region_var(&mut self, rid: RegionVid) -> ty::Region {
if !self.should(resolve_rvar) {
return ty::re_infer(ty::ReVar(rid));
}
self.infcx.region_vars.resolve_var(rid)
}
- fn assert_not_rvar(&mut self, rid: RegionVid, r: ty::Region) {
+ pub fn assert_not_rvar(&mut self, rid: RegionVid, r: ty::Region) {
match r {
ty::re_infer(ty::ReVar(rid2)) => {
self.err = Some(region_var_bound_by_region_var(rid, rid2));
}
}
- fn resolve_ty_var(&mut self, vid: TyVid) -> ty::t {
+ pub fn resolve_ty_var(&mut self, vid: TyVid) -> ty::t {
if vec::contains(self.v_seen, &vid) {
self.err = Some(cyclic_ty(vid));
return ty::mk_var(self.infcx.tcx, vid);
}
}
- fn resolve_int_var(&mut self, vid: IntVid) -> ty::t {
+ pub fn resolve_int_var(&mut self, vid: IntVid) -> ty::t {
if !self.should(resolve_ivar) {
return ty::mk_int_var(self.infcx.tcx, vid);
}
}
}
- fn resolve_float_var(&mut self, vid: FloatVid) -> ty::t {
+ pub fn resolve_float_var(&mut self, vid: FloatVid) -> ty::t {
if !self.should(resolve_fvar) {
return ty::mk_float_var(self.infcx.tcx, vid);
}
err_messages: messages};
}
-pub impl Env {
- fn create_region_hierarchy(&self, rh: &RH) {
+impl Env {
+ pub fn create_region_hierarchy(&self, rh: &RH) {
for rh.sub.each |child_rh| {
self.create_region_hierarchy(child_rh);
self.tcx.region_map.insert(child_rh.id, rh.id);
}
}
- fn create_simple_region_hierarchy(&self) {
+ pub fn create_simple_region_hierarchy(&self) {
// creates a region hierarchy where 1 is root, 10 and 11 are
// children of 1, etc
self.create_region_hierarchy(
sub: &[]}]});
}
- fn lookup_item(&self, names: &[~str]) -> ast::node_id {
+ pub fn lookup_item(&self, names: &[~str]) -> ast::node_id {
return match search_mod(self, &self.crate.node.module, 0, names) {
Some(id) => id,
None => {
}
}
- fn is_subtype(&self, a: ty::t, b: ty::t) -> bool {
+ pub fn is_subtype(&self, a: ty::t, b: ty::t) -> bool {
match infer::can_mk_subty(self.infcx, a, b) {
Ok(_) => true,
Err(_) => false
}
}
- fn assert_subtype(&self, a: ty::t, b: ty::t) {
+ pub fn assert_subtype(&self, a: ty::t, b: ty::t) {
if !self.is_subtype(a, b) {
fail!("%s is not a subtype of %s, but it should be",
self.ty_to_str(a),
}
}
- fn assert_not_subtype(&self, a: ty::t, b: ty::t) {
+ pub fn assert_not_subtype(&self, a: ty::t, b: ty::t) {
if self.is_subtype(a, b) {
fail!("%s is a subtype of %s, but it shouldn't be",
self.ty_to_str(a),
}
}
- fn assert_strict_subtype(&self, a: ty::t, b: ty::t) {
+ pub fn assert_strict_subtype(&self, a: ty::t, b: ty::t) {
self.assert_subtype(a, b);
self.assert_not_subtype(b, a);
}
- fn assert_eq(&self, a: ty::t, b: ty::t) {
+ pub fn assert_eq(&self, a: ty::t, b: ty::t) {
self.assert_subtype(a, b);
self.assert_subtype(b, a);
}
- fn ty_to_str(&self, a: ty::t) -> ~str {
+ pub fn ty_to_str(&self, a: ty::t) -> ~str {
ty_to_str(self.tcx, a)
}
- fn t_fn(&self, input_tys: &[ty::t], output_ty: ty::t) -> ty::t {
+ pub fn t_fn(&self, input_tys: &[ty::t], output_ty: ty::t) -> ty::t {
let inputs = input_tys.map(|t| {mode: ast::expl(ast::by_copy),
ty: *t});
ty::mk_fn(self.tcx, FnTyBase {
})
}
- fn t_int(&self) -> ty::t {
+ pub fn t_int(&self) -> ty::t {
ty::mk_int(self.tcx)
}
- fn t_rptr_bound(&self, id: uint) -> ty::t {
+ pub fn t_rptr_bound(&self, id: uint) -> ty::t {
ty::mk_imm_rptr(self.tcx, ty::re_bound(ty::br_anon(id)), self.t_int())
}
- fn t_rptr_scope(&self, id: ast::node_id) -> ty::t {
+ pub fn t_rptr_scope(&self, id: ast::node_id) -> ty::t {
ty::mk_imm_rptr(self.tcx, ty::re_scope(id), self.t_int())
}
- fn t_rptr_free(&self, nid: ast::node_id, id: uint) -> ty::t {
+ pub fn t_rptr_free(&self, nid: ast::node_id, id: uint) -> ty::t {
ty::mk_imm_rptr(self.tcx,
ty::re_free(ty::FreeRegion {scope_id: nid,
bound_region: ty::br_anon(id)}),
self.t_int())
}
- fn t_rptr_static(&self) -> ty::t {
+ pub fn t_rptr_static(&self) -> ty::t {
ty::mk_imm_rptr(self.tcx, ty::re_static, self.t_int())
}
- fn lub() -> Lub { Lub(self.infcx.combine_fields(true, dummy_sp())) }
+ pub fn lub() -> Lub { Lub(self.infcx.combine_fields(true, dummy_sp())) }
- fn glb() -> Glb { Glb(self.infcx.combine_fields(true, dummy_sp())) }
+ pub fn glb() -> Glb { Glb(self.infcx.combine_fields(true, dummy_sp())) }
- fn resolve_regions(exp_count: uint) {
+ pub fn resolve_regions(exp_count: uint) {
debug!("resolve_regions(%u)", exp_count);
self.infcx.resolve_regions();
}
/// Checks that `LUB(t1,t2) == t_lub`
- fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) {
+ pub fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) {
match self.lub().tys(t1, t2) {
Err(e) => {
fail!("Unexpected error computing LUB: %?", e)
}
/// Checks that `GLB(t1,t2) == t_glb`
- fn check_glb(&self, t1: ty::t, t2: ty::t, t_glb: ty::t) {
+ pub fn check_glb(&self, t1: ty::t, t2: ty::t, t_glb: ty::t) {
debug!("check_glb(t1=%s, t2=%s, t_glb=%s)",
self.ty_to_str(t1),
self.ty_to_str(t2),
}
/// Checks that `LUB(t1,t2)` is undefined
- fn check_no_lub(&self, t1: ty::t, t2: ty::t) {
+ pub fn check_no_lub(&self, t1: ty::t, t2: ty::t) {
match self.lub().tys(t1, t2) {
Err(_) => {}
Ok(t) => {
}
/// Checks that `GLB(t1,t2)` is undefined
- fn check_no_glb(&self, t1: ty::t, t2: ty::t) {
+ pub fn check_no_glb(&self, t1: ty::t, t2: ty::t) {
match self.glb().tys(t1, t2) {
Err(_) => {}
Ok(t) => {
-> &'v mut ValsAndBindings<Self, T>;
}
-pub impl InferCtxt {
- fn get<T:Copy, V:Copy+Eq+Vid+UnifyVid<T>>(
- &mut self,
- vid: V) -> Node<V, T>
- {
+impl InferCtxt {
+ pub fn get<T:Copy, V:Copy+Eq+Vid+UnifyVid<T>>(&mut self, vid: V)
+ -> Node<V, T> {
/*!
*
* Find the root node for `vid`. This uses the standard
}
}
- fn set<T:Copy + InferStr,V:Copy + Vid + ToStr + UnifyVid<T>>(
- &mut self,
- vid: V,
- new_v: VarValue<V, T>) {
+ pub fn set<T:Copy + InferStr,
+ V:Copy + Vid + ToStr + UnifyVid<T>>(&mut self,
+ vid: V,
+ new_v: VarValue<V, T>) {
/*!
*
* Sets the value for `vid` to `new_v`. `vid` MUST be a root node!
}
}
- fn unify<T:Copy + InferStr,V:Copy + Vid + ToStr + UnifyVid<T>>(
- &mut self,
- node_a: &Node<V, T>,
- node_b: &Node<V, T>) -> (V, uint)
- {
+ pub fn unify<T:Copy + InferStr,
+ V:Copy + Vid + ToStr + UnifyVid<T>>(&mut self,
+ node_a: &Node<V, T>,
+ node_b: &Node<V, T>)
+ -> (V, uint) {
// Rank optimization: if you don't know what it is, check
// out <http://en.wikipedia.org/wiki/Disjoint-set_data_structure>
}
}
-pub impl InferCtxt {
- fn simple_vars<T:Copy + Eq + InferStr + SimplyUnifiable,
- V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
- &mut self,
- a_is_expected: bool,
- a_id: V,
- b_id: V)
- -> ures {
+impl InferCtxt {
+ pub fn simple_vars<T:Copy+Eq+InferStr+SimplyUnifiable,
+ V:Copy+Eq+Vid+ToStr+UnifyVid<Option<T>>>(&mut self,
+ a_is_expected:
+ bool,
+ a_id: V,
+ b_id: V)
+ -> ures {
/*!
*
* Unifies two simple variables. Because simple variables do
return uok();
}
- fn simple_var_t<T:Copy + Eq + InferStr + SimplyUnifiable,
- V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
- &mut self,
- a_is_expected: bool,
- a_id: V,
- b: T)
- -> ures {
+ pub fn simple_var_t<T:Copy+Eq+InferStr+SimplyUnifiable,
+ V:Copy+Eq+Vid+ToStr+UnifyVid<Option<T>>>(&mut self,
+ a_is_expected
+ : bool,
+ a_id: V,
+ b: T)
+ -> ures {
/*!
*
* Sets the value of the variable `a_id` to `b`. Because
1 << e.to_uint()
}
-pub impl<E:CLike> EnumSet<E> {
- fn empty() -> EnumSet<E> {
+impl<E:CLike> EnumSet<E> {
+ pub fn empty() -> EnumSet<E> {
EnumSet {bits: 0}
}
- fn is_empty(&self) -> bool {
+ pub fn is_empty(&self) -> bool {
self.bits == 0
}
- fn intersects(&self, e: EnumSet<E>) -> bool {
+ pub fn intersects(&self, e: EnumSet<E>) -> bool {
(self.bits & e.bits) != 0
}
- fn intersection(&self, e: EnumSet<E>) -> EnumSet<E> {
+ pub fn intersection(&self, e: EnumSet<E>) -> EnumSet<E> {
EnumSet {bits: self.bits & e.bits}
}
- fn contains(&self, e: EnumSet<E>) -> bool {
+ pub fn contains(&self, e: EnumSet<E>) -> bool {
(self.bits & e.bits) == e.bits
}
- fn union(&self, e: EnumSet<E>) -> EnumSet<E> {
+ pub fn union(&self, e: EnumSet<E>) -> EnumSet<E> {
EnumSet {bits: self.bits | e.bits}
}
- fn add(&mut self, e: E) {
+ pub fn add(&mut self, e: E) {
self.bits |= bit(e);
}
- fn contains_elem(&self, e: E) -> bool {
+ pub fn contains_elem(&self, e: E) -> bool {
(self.bits & bit(e)) != 0
}
- fn each(&self, f: &fn(E) -> bool) -> bool {
+ pub fn each(&self, f: &fn(E) -> bool) -> bool {
let mut bits = self.bits;
let mut index = 0;
while bits != 0 {
link: ~str
}
-pub impl Doc {
- fn CrateDoc(&self) -> CrateDoc {
+impl Doc {
+ pub fn CrateDoc(&self) -> CrateDoc {
vec::foldl(None, self.pages, |_m, page| {
match copy *page {
doc::CratePage(doc) => Some(doc),
}).get()
}
- fn cratemod(&self) -> ModDoc {
+ pub fn cratemod(&self) -> ModDoc {
copy self.CrateDoc().topmod
}
}
/// Some helper methods on ModDoc, mostly for testing
-pub impl ModDoc {
- fn mods(&self) -> ~[ModDoc] {
+impl ModDoc {
+ pub fn mods(&self) -> ~[ModDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
ModTag(ModDoc) => Some(ModDoc),
}
}
- fn nmods(&self) -> ~[NmodDoc] {
+ pub fn nmods(&self) -> ~[NmodDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
NmodTag(nModDoc) => Some(nModDoc),
}
}
- fn fns(&self) -> ~[FnDoc] {
+ pub fn fns(&self) -> ~[FnDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
FnTag(FnDoc) => Some(FnDoc),
}
}
- fn consts(&self) -> ~[ConstDoc] {
+ pub fn consts(&self) -> ~[ConstDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
ConstTag(ConstDoc) => Some(ConstDoc),
}
}
- fn enums(&self) -> ~[EnumDoc] {
+ pub fn enums(&self) -> ~[EnumDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
EnumTag(EnumDoc) => Some(EnumDoc),
}
}
- fn traits(&self) -> ~[TraitDoc] {
+ pub fn traits(&self) -> ~[TraitDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
TraitTag(TraitDoc) => Some(TraitDoc),
}
}
- fn impls(&self) -> ~[ImplDoc] {
+ pub fn impls(&self) -> ~[ImplDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
ImplTag(ImplDoc) => Some(ImplDoc),
}
}
- fn types(&self) -> ~[TyDoc] {
+ pub fn types(&self) -> ~[TyDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
TyTag(TyDoc) => Some(TyDoc),
}
}
- fn structs(&self) -> ~[StructDoc] {
+ pub fn structs(&self) -> ~[StructDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
StructTag(StructDoc) => Some(StructDoc),
#[test]
fn should_prune_priv_associated_methods_on_pub_impls() {
let doc = mk_doc(
- ~"pub impl Foo {\
- fn bar() { }\
+ ~"impl Foo {\
+ pub fn bar() { }\
priv fn baz() { }\
}");
assert_eq!(doc.cratemod().impls()[0].methods.len(), 1);
#[test]
fn should_prune_associated_methods_without_vis_modifier_on_priv_impls() {
let doc = mk_doc(
- ~"priv impl Foo {\
+ ~"impl Foo {\
pub fn bar() { }\
fn baz() { }\
}");
#[test]
fn should_prune_priv_associated_methods_on_priv_impls() {
let doc = mk_doc(
- ~"priv impl Foo {\
+ ~"impl Foo {\
pub fn bar() { }\
priv fn baz() { }\
}");
#[test]
fn should_prune_associated_impls_with_no_pub_methods() {
let doc = mk_doc(
- ~"priv impl Foo {\
+ ~"impl Foo {\
fn baz() { }\
}");
assert!(doc.cratemod().impls().is_empty());
fn ifn() { } \
enum ienum { ivar } \
trait itrait { fn a(); } \
- pub impl int { fn a() { } } \
+ impl int { fn a() { } } \
type itype = int; \
struct istruct { f: () }";
do astsrv::from_str(source) |srv| {
cfgs: ~[~str]
}
-pub impl Crate {
-
- fn new(p: &Path) -> Crate {
+impl Crate {
+ pub fn new(p: &Path) -> Crate {
Crate {
file: copy *p,
flags: ~[],
}
}
- fn flag(&self, flag: ~str) -> Crate {
+ pub fn flag(&self, flag: ~str) -> Crate {
Crate {
flags: vec::append(copy self.flags, [flag]),
.. copy *self
}
}
- fn flags(&self, flags: ~[~str]) -> Crate {
+ pub fn flags(&self, flags: ~[~str]) -> Crate {
Crate {
flags: vec::append(copy self.flags, flags),
.. copy *self
}
}
- fn cfg(&self, cfg: ~str) -> Crate {
+ pub fn cfg(&self, cfg: ~str) -> Crate {
Crate {
cfgs: vec::append(copy self.cfgs, [cfg]),
.. copy *self
}
}
- fn cfgs(&self, cfgs: ~[~str]) -> Crate {
+ pub fn cfgs(&self, cfgs: ~[~str]) -> Crate {
Crate {
cfgs: vec::append(copy self.cfgs, cfgs),
.. copy *self
version: Version
}
-pub impl PkgId {
- fn new(s: &str) -> PkgId {
+impl PkgId {
+ pub fn new(s: &str) -> PkgId {
use conditions::bad_pkg_id::cond;
let p = Path(s);
}
}
- fn hash(&self) -> ~str {
+ pub fn hash(&self) -> ~str {
fmt!("%s-%s-%s", self.remote_path.to_str(),
hash(self.remote_path.to_str() + self.version.to_str()),
self.version.to_str())
}
- fn short_name_with_version(&self) -> ~str {
+ pub fn short_name_with_version(&self) -> ~str {
fmt!("%s-%s", self.short_name, self.version.to_str())
}
}
//! A mutable, nullable memory location
+#[missing_doc];
+
use cast::transmute_mut;
use prelude::*;
use util::replace;
Cell { value: None }
}
-pub impl<T> Cell<T> {
+impl<T> Cell<T> {
/// Yields the value, failing if the cell is empty.
- fn take(&self) -> T {
+ pub fn take(&self) -> T {
let this = unsafe { transmute_mut(self) };
if this.is_empty() {
fail!("attempt to take an empty cell");
}
/// Returns the value, failing if the cell is full.
- fn put_back(&self, value: T) {
+ pub fn put_back(&self, value: T) {
let this = unsafe { transmute_mut(self) };
if !this.is_empty() {
fail!("attempt to put a value back into a full cell");
}
/// Returns true if the cell is empty and false if the cell is full.
- fn is_empty(&self) -> bool {
+ pub fn is_empty(&self) -> bool {
self.value.is_none()
}
- // Calls a closure with a reference to the value.
- fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R {
+ /// Calls a closure with a reference to the value.
+ pub fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R {
let v = self.take();
let r = op(&v);
self.put_back(v);
r
}
- // Calls a closure with a mutable reference to the value.
- fn with_mut_ref<R>(&self, op: &fn(v: &mut T) -> R) -> R {
+ /// Calls a closure with a mutable reference to the value.
+ pub fn with_mut_ref<R>(&self, op: &fn(v: &mut T) -> R) -> R {
let mut v = self.take();
let r = op(&mut v);
self.put_back(v);
ports: ~[pipesy::Port<T>],
}
-pub impl<T: Owned> PortSet<T> {
- fn new() -> PortSet<T> {
+impl<T: Owned> PortSet<T> {
+ pub fn new() -> PortSet<T> {
PortSet {
ports: ~[]
}
}
- fn add(&self, port: Port<T>) {
+ pub fn add(&self, port: Port<T>) {
let Port { inner } = port;
let port = match inner {
Left(p) => p,
}
}
- fn chan(&self) -> Chan<T> {
+ pub fn chan(&self) -> Chan<T> {
let (po, ch) = stream();
self.add(po);
ch
(PortOne::new(port), ChanOne::new(chan))
}
- pub impl<T: Owned> PortOne<T> {
- fn recv(self) -> T { recv_one(self) }
- fn try_recv(self) -> Option<T> { try_recv_one(self) }
- fn unwrap(self) -> oneshot::server::Oneshot<T> {
+ impl<T: Owned> PortOne<T> {
+ pub fn recv(self) -> T { recv_one(self) }
+ pub fn try_recv(self) -> Option<T> { try_recv_one(self) }
+ pub fn unwrap(self) -> oneshot::server::Oneshot<T> {
match self {
PortOne { contents: s } => s
}
}
}
- pub impl<T: Owned> ChanOne<T> {
- fn send(self, data: T) { send_one(self, data) }
- fn try_send(self, data: T) -> bool { try_send_one(self, data) }
- fn unwrap(self) -> oneshot::client::Oneshot<T> {
+ impl<T: Owned> ChanOne<T> {
+ pub fn send(self, data: T) { send_one(self, data) }
+ pub fn try_send(self, data: T) -> bool { try_send_one(self, data) }
+ pub fn unwrap(self) -> oneshot::client::Oneshot<T> {
match self {
ChanOne { contents: s } => s
}
key: local_data::LocalDataKey<'self, Handler<T, U>>
}
-pub impl<'self, T, U> Condition<'self, T, U> {
- fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
+impl<'self, T, U> Condition<'self, T, U> {
+ pub fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
unsafe {
let p : *RustClosure = ::cast::transmute(&h);
let prev = local_data::local_data_get(self.key);
}
}
- fn raise(&self, t: T) -> U {
+ pub fn raise(&self, t: T) -> U {
let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
self.raise_default(t, || fail!(copy msg))
}
- fn raise_default(&self, t: T, default: &fn() -> U) -> U {
+ pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
unsafe {
match local_data_pop(self.key) {
None => {
handler: @Handler<T, U>
}
-pub impl<'self, T, U> Trap<'self, T, U> {
- fn in<V>(&self, inner: &'self fn() -> V) -> V {
+impl<'self, T, U> Trap<'self, T, U> {
+ pub fn in<V>(&self, inner: &'self fn() -> V) -> V {
unsafe {
let _g = Guard { cond: self.cond };
debug!("Trap: pushing handler to TLS");
//! A type that represents one of two alternatives
+#[allow(missing_doc)];
+
use container::Container;
use cmp::Eq;
use kinds::Copy;
}
}
-pub impl<T, U> Either<T, U> {
+impl<T, U> Either<T, U> {
#[inline(always)]
- fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V {
+ pub fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V {
either(f_left, f_right, self)
}
#[inline(always)]
- fn flip(self) -> Either<U, T> { flip(self) }
+ pub fn flip(self) -> Either<U, T> { flip(self) }
#[inline(always)]
- fn to_result(self) -> Result<U, T> { to_result(self) }
+ pub fn to_result(self) -> Result<U, T> { to_result(self) }
#[inline(always)]
- fn is_left(&self) -> bool { is_left(self) }
+ pub fn is_left(&self) -> bool { is_left(self) }
#[inline(always)]
- fn is_right(&self) -> bool { is_right(self) }
+ pub fn is_right(&self) -> bool { is_right(self) }
#[inline(always)]
- fn unwrap_left(self) -> T { unwrap_left(self) }
+ pub fn unwrap_left(self) -> T { unwrap_left(self) }
#[inline(always)]
- fn unwrap_right(self) -> U { unwrap_right(self) }
+ pub fn unwrap_right(self) -> U { unwrap_right(self) }
}
#[test]
//! The tables use a keyed hash with new random keys generated for each container, so the ordering
//! of a set of keys in a hash table is randomized.
+#[mutable_doc];
+
use container::{Container, Mutable, Map, Set};
use cmp::{Eq, Equiv};
use hash::Hash;
}
}
-priv impl<K:Hash + Eq,V> HashMap<K, V> {
+impl<K:Hash + Eq,V> HashMap<K, V> {
#[inline(always)]
fn to_bucket(&self, h: uint) -> uint {
// A good hash function with entropy spread over all of the
}
}
-pub impl<K: Hash + Eq, V> HashMap<K, V> {
+impl<K: Hash + Eq, V> HashMap<K, V> {
/// Create an empty HashMap
- fn new() -> HashMap<K, V> {
+ pub fn new() -> HashMap<K, V> {
HashMap::with_capacity(INITIAL_CAPACITY)
}
/// Create an empty HashMap with space for at least `n` elements in
/// the hash table.
- fn with_capacity(capacity: uint) -> HashMap<K, V> {
+ pub fn with_capacity(capacity: uint) -> HashMap<K, V> {
linear_map_with_capacity(capacity)
}
/// Reserve space for at least `n` elements in the hash table.
- fn reserve_at_least(&mut self, n: uint) {
+ pub fn reserve_at_least(&mut self, n: uint) {
if n > self.buckets.len() {
let buckets = n * 4 / 3 + 1;
self.resize(uint::next_power_of_two(buckets));
/// Return the value corresponding to the key in the map, or insert
/// and return the value if it doesn't exist.
- fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V {
+ pub fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V {
if self.size >= self.resize_at {
// n.b.: We could also do this after searching, so
// that we do not resize if this call to insert is
/// Return the value corresponding to the key in the map, or create,
/// insert, and return a new value if it doesn't exist.
- fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V {
+ pub fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V)
+ -> &'a V {
if self.size >= self.resize_at {
// n.b.: We could also do this after searching, so
// that we do not resize if this call to insert is
self.value_for_bucket(idx)
}
- fn consume(&mut self, f: &fn(K, V)) {
+ /// Calls a function on each element of a hash map, destroying the hash
+ /// map in the process.
+ pub fn consume(&mut self, f: &fn(K, V)) {
let buckets = replace(&mut self.buckets,
vec::from_fn(INITIAL_CAPACITY, |_| None));
self.size = 0;
}
}
- fn get<'a>(&'a self, k: &K) -> &'a V {
+ /// Retrieves a value for the given key, failing if the key is not
+ /// present.
+ pub fn get<'a>(&'a self, k: &K) -> &'a V {
match self.find(k) {
Some(v) => v,
None => fail!("No entry found for key: %?", k),
/// Return true if the map contains a value for the specified key,
/// using equivalence
- fn contains_key_equiv<Q:Hash + Equiv<K>>(&self, key: &Q) -> bool {
+ pub fn contains_key_equiv<Q:Hash + Equiv<K>>(&self, key: &Q) -> bool {
match self.bucket_for_key_equiv(key) {
FoundEntry(_) => {true}
TableFull | FoundHole(_) => {false}
/// Return the value corresponding to the key in the map, using
/// equivalence
- fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q) -> Option<&'a V> {
+ pub fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q)
+ -> Option<&'a V> {
match self.bucket_for_key_equiv(k) {
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
TableFull | FoundHole(_) => None,
}
}
-pub impl<K: Hash + Eq, V: Copy> HashMap<K, V> {
+impl<K: Hash + Eq, V: Copy> HashMap<K, V> {
/// Like `find`, but returns a copy of the value.
- fn find_copy(&self, k: &K) -> Option<V> {
+ pub fn find_copy(&self, k: &K) -> Option<V> {
self.find(k).map_consume(|v| copy *v)
}
/// Like `get`, but returns a copy of the value.
- fn get_copy(&self, k: &K) -> V {
+ pub fn get_copy(&self, k: &K) -> V {
copy *self.get(k)
}
}
}
}
-pub impl <T:Hash + Eq> HashSet<T> {
+impl<T:Hash + Eq> HashSet<T> {
/// Create an empty HashSet
- fn new() -> HashSet<T> {
+ pub fn new() -> HashSet<T> {
HashSet::with_capacity(INITIAL_CAPACITY)
}
/// Create an empty HashSet with space for at least `n` elements in
/// the hash table.
- fn with_capacity(capacity: uint) -> HashSet<T> {
+ pub fn with_capacity(capacity: uint) -> HashSet<T> {
HashSet { map: HashMap::with_capacity(capacity) }
}
/// Reserve space for at least `n` elements in the hash table.
- fn reserve_at_least(&mut self, n: uint) {
+ pub fn reserve_at_least(&mut self, n: uint) {
self.map.reserve_at_least(n)
}
/// Consumes all of the elements in the set, emptying it out
- fn consume(&mut self, f: &fn(T)) {
+ pub fn consume(&mut self, f: &fn(T)) {
self.map.consume(|k, _| f(k))
}
- fn contains_equiv<Q:Hash + Equiv<T>>(&self, value: &Q) -> bool {
+ /// Returns true if the hash set contains a value equivalent to the
+ /// given query value.
+ pub fn contains_equiv<Q:Hash + Equiv<T>>(&self, value: &Q) -> bool {
self.map.contains_key_equiv(value)
}
}
}
}
-pub impl<T> Option<T> {
+impl<T> Option<T> {
/// Returns true if the option equals `none`
- fn is_none(&const self) -> bool {
+ pub fn is_none(&const self) -> bool {
match *self { None => true, Some(_) => false }
}
/// Returns true if the option contains some value
#[inline(always)]
- fn is_some(&const self) -> bool { !self.is_none() }
+ pub fn is_some(&const self) -> bool { !self.is_none() }
/// Update an optional value by optionally running its content through a
/// function that returns an option.
#[inline(always)]
- fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> {
-
+ pub fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> {
match self {
Some(t) => f(t),
None => None
/// Returns the leftmost Some() value, or None if both are None.
#[inline(always)]
- fn or(self, optb: Option<T>) -> Option<T> {
+ pub fn or(self, optb: Option<T>) -> Option<T> {
match self {
Some(opta) => Some(opta),
_ => optb
/// Update an optional value by optionally running its content by reference
/// through a function that returns an option.
#[inline(always)]
- fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) -> Option<U> {
- match *self { Some(ref x) => f(x), None => None }
+ pub fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>)
+ -> Option<U> {
+ match *self {
+ Some(ref x) => f(x),
+ None => None
+ }
}
/// Maps a `some` value from one type to another by reference
#[inline(always)]
- fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> {
+ pub fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> {
match *self { Some(ref x) => Some(f(x)), None => None }
}
/// As `map`, but consumes the option and gives `f` ownership to avoid
/// copying.
#[inline(always)]
- fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
+ pub fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
match self { None => None, Some(v) => Some(f(v)) }
}
/// Applies a function to the contained value or returns a default
#[inline(always)]
- fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U {
+ pub fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U {
match *self { None => def, Some(ref t) => f(t) }
}
/// As `map_default`, but consumes the option and gives `f`
/// ownership to avoid copying.
#[inline(always)]
- fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U {
+ pub fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U {
match self { None => def, Some(v) => f(v) }
}
/// Apply a function to the contained value or do nothing
- fn mutate(&mut self, f: &fn(T) -> T) {
+ pub fn mutate(&mut self, f: &fn(T) -> T) {
if self.is_some() {
*self = Some(f(self.swap_unwrap()));
}
}
/// Apply a function to the contained value or set it to a default
- fn mutate_default(&mut self, def: T, f: &fn(T) -> T) {
+ pub fn mutate_default(&mut self, def: T, f: &fn(T) -> T) {
if self.is_some() {
*self = Some(f(self.swap_unwrap()));
} else {
case explicitly.
*/
#[inline(always)]
- fn get_ref<'a>(&'a self) -> &'a T {
+ pub fn get_ref<'a>(&'a self) -> &'a T {
match *self {
Some(ref x) => x,
None => fail!("option::get_ref none")
case explicitly.
*/
#[inline(always)]
- fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
+ pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
match *self {
Some(ref mut x) => x,
None => fail!("option::get_mut_ref none")
}
#[inline(always)]
- fn unwrap(self) -> T {
+ pub fn unwrap(self) -> T {
/*!
Moves a value out of an option type and returns it.
* Fails if the value equals `None`.
*/
#[inline(always)]
- fn swap_unwrap(&mut self) -> T {
+ pub fn swap_unwrap(&mut self) -> T {
if self.is_none() { fail!("option::swap_unwrap none") }
util::replace(self, None).unwrap()
}
* Fails if the value equals `none`
*/
#[inline(always)]
- fn expect(self, reason: &str) -> T {
+ pub fn expect(self, reason: &str) -> T {
match self {
Some(val) => val,
None => fail!(reason.to_owned()),
}
}
-pub impl<T:Copy> Option<T> {
+impl<T:Copy> Option<T> {
/**
Gets the value out of an option
case explicitly.
*/
#[inline(always)]
- fn get(self) -> T {
+ pub fn get(self) -> T {
match self {
Some(x) => return x,
None => fail!("option::get none")
/// Returns the contained value or a default
#[inline(always)]
- fn get_or_default(self, def: T) -> T {
+ pub fn get_or_default(self, def: T) -> T {
match self { Some(x) => x, None => def }
}
/// Applies a function zero or more times until the result is none.
#[inline(always)]
- fn while_some(self, blk: &fn(v: T) -> Option<T>) {
+ pub fn while_some(self, blk: &fn(v: T) -> Option<T>) {
let mut opt = self;
while opt.is_some() {
opt = blk(opt.unwrap());
}
}
-pub impl<T:Copy + Zero> Option<T> {
+impl<T:Copy + Zero> Option<T> {
/// Returns the contained value or zero (for this type)
#[inline(always)]
- fn get_or_zero(self) -> T {
- match self { Some(x) => x, None => Zero::zero() }
+ pub fn get_or_zero(self) -> T {
+ match self {
+ Some(x) => x,
+ None => Zero::zero()
+ }
}
}
}
-pub impl Path {
- fn stat(&self) -> Option<libc::stat> {
+impl Path {
+ pub fn stat(&self) -> Option<libc::stat> {
unsafe {
do str::as_c_str(self.to_str()) |buf| {
let mut st = stat::arch::default_stat();
}
#[cfg(unix)]
- fn lstat(&self) -> Option<libc::stat> {
+ pub fn lstat(&self) -> Option<libc::stat> {
unsafe {
do str::as_c_str(self.to_str()) |buf| {
let mut st = stat::arch::default_stat();
}
}
- fn exists(&self) -> bool {
+ pub fn exists(&self) -> bool {
match self.stat() {
None => false,
Some(_) => true,
}
}
- fn get_size(&self) -> Option<i64> {
+ pub fn get_size(&self) -> Option<i64> {
match self.stat() {
None => None,
Some(ref st) => Some(st.st_size as i64),
}
}
- fn get_mode(&self) -> Option<uint> {
+ pub fn get_mode(&self) -> Option<uint> {
match self.stat() {
None => None,
Some(ref st) => Some(st.st_mode as uint),
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
-pub impl Path {
- fn get_atime(&self) -> Option<(i64, int)> {
+impl Path {
+ pub fn get_atime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
}
}
- fn get_mtime(&self) -> Option<(i64, int)> {
+ pub fn get_mtime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
}
}
- fn get_ctime(&self) -> Option<(i64, int)> {
+ pub fn get_ctime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "macos")]
-pub impl Path {
- fn get_birthtime(&self) -> Option<(i64, int)> {
+impl Path {
+ pub fn get_birthtime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
}
#[cfg(target_os = "win32")]
-pub impl Path {
- fn get_atime(&self) -> Option<(i64, int)> {
+impl Path {
+ pub fn get_atime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
}
}
- fn get_mtime(&self) -> Option<(i64, int)> {
+ pub fn get_mtime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
}
}
- fn get_ctime(&self) -> Option<(i64, int)> {
+ pub fn get_ctime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
Some(ref st) => {
}
}
-pub impl PacketHeader {
+impl PacketHeader {
// Returns the old state.
- unsafe fn mark_blocked(&mut self, this: *rust_task) -> State {
+ pub unsafe fn mark_blocked(&mut self, this: *rust_task) -> State {
rustrt::rust_task_ref(this);
let old_task = swap_task(&mut self.blocked_task, this);
assert!(old_task.is_null());
swap_state_acq(&mut self.state, Blocked)
}
- unsafe fn unblock(&mut self) {
+ pub unsafe fn unblock(&mut self) {
let old_task = swap_task(&mut self.blocked_task, ptr::null());
if !old_task.is_null() {
rustrt::rust_task_deref(old_task)
// unsafe because this can do weird things to the space/time
// continuum. It ends making multiple unique pointers to the same
// thing. You'll probably want to forget them when you're done.
- unsafe fn buf_header(&mut self) -> ~BufferHeader {
+ pub unsafe fn buf_header(&mut self) -> ~BufferHeader {
assert!(self.buffer.is_not_null());
transmute_copy(&self.buffer)
}
- fn set_buffer<T:Owned>(&mut self, b: ~Buffer<T>) {
+ pub fn set_buffer<T:Owned>(&mut self, b: ~Buffer<T>) {
unsafe {
self.buffer = transmute_copy(&b);
}
}
}
-pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
- fn unwrap(&mut self) -> *mut Packet<T> {
+impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
+ pub fn unwrap(&mut self) -> *mut Packet<T> {
replace(&mut self.p, None).unwrap()
}
- fn header(&mut self) -> *mut PacketHeader {
+ pub fn header(&mut self) -> *mut PacketHeader {
match self.p {
Some(packet) => unsafe {
let packet = &mut *packet;
}
}
- fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> {
+ pub fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> {
//error!("send reuse_buffer");
replace(&mut self.buffer, None).unwrap()
}
}
}
-pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
- fn unwrap(&mut self) -> *mut Packet<T> {
+impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
+ pub fn unwrap(&mut self) -> *mut Packet<T> {
replace(&mut self.p, None).unwrap()
}
- fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> {
+ pub fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> {
replace(&mut self.buffer, None).unwrap()
}
}
priv c: u32
}
-pub impl IsaacRng {
+impl IsaacRng {
/// Create an ISAAC random number generator with a random seed.
- fn new() -> IsaacRng {
+ pub fn new() -> IsaacRng {
IsaacRng::new_seeded(seed())
}
/// will be silently ignored. A generator constructed with a given seed
/// will generate the same sequence of values as all other generators
/// constructed with the same seed.
- fn new_seeded(seed: &[u8]) -> IsaacRng {
+ pub fn new_seeded(seed: &[u8]) -> IsaacRng {
let mut rng = IsaacRng {
cnt: 0,
rsl: [0, .. RAND_SIZE],
/// Create an ISAAC random number generator using the default
/// fixed seed.
- fn new_unseeded() -> IsaacRng {
+ pub fn new_unseeded() -> IsaacRng {
let mut rng = IsaacRng {
cnt: 0,
rsl: [0, .. RAND_SIZE],
/// Initialises `self`. If `use_rsl` is true, then use the current value
/// of `rsl` as a seed, otherwise construct one algorithmically (not
/// randomly).
- priv fn init(&mut self, use_rsl: bool) {
+ fn init(&mut self, use_rsl: bool) {
macro_rules! init_mut_many (
($( $var:ident ),* = $val:expr ) => {
let mut $( $var = $val ),*;
/// Refills the output buffer (`self.rsl`)
#[inline]
- priv fn isaac(&mut self) {
+ fn isaac(&mut self) {
self.c += 1;
// abbreviations
let mut a = self.a, b = self.b + self.c;
}
}
-pub impl XorShiftRng {
+impl XorShiftRng {
/// Create an xor shift random number generator with a default seed.
- fn new() -> XorShiftRng {
+ pub fn new() -> XorShiftRng {
// constants taken from http://en.wikipedia.org/wiki/Xorshift
XorShiftRng::new_seeded(123456789u32,
362436069u32,
/**
* Create a random number generator using the specified seed. A generator
- * constructed with a given seed will generate the same sequence of values as
- * all other generators constructed with the same seed.
+ * constructed with a given seed will generate the same sequence of values
+ * as all other generators constructed with the same seed.
*/
- fn new_seeded(x: u32, y: u32, z: u32, w: u32) -> XorShiftRng {
+ pub fn new_seeded(x: u32, y: u32, z: u32, w: u32) -> XorShiftRng {
XorShiftRng {
x: x,
y: y,
MovePtrAdaptor { inner: v }
}
-pub impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
+impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
#[inline(always)]
- fn bump(&self, sz: uint) {
- do self.inner.move_ptr() |p| {
+ pub fn bump(&self, sz: uint) {
+ do self.inner.move_ptr() |p| {
((p as uint) + sz) as *c_void
- };
+ };
}
#[inline(always)]
- fn align(&self, a: uint) {
- do self.inner.move_ptr() |p| {
+ pub fn align(&self, a: uint) {
+ do self.inner.move_ptr() |p| {
align(p as uint, a) as *c_void
- };
+ };
}
#[inline(always)]
- fn align_to<T>(&self) {
+ pub fn align_to<T>(&self) {
self.align(sys::min_align_of::<T>());
}
#[inline(always)]
- fn bump_past<T>(&self) {
+ pub fn bump_past<T>(&self) {
self.bump(sys::size_of::<T>());
}
}
}
}
-pub impl ReprVisitor {
-
+impl ReprVisitor {
// Various helpers for the TyVisitor impl
#[inline(always)]
- fn get<T>(&self, f: &fn(&T)) -> bool {
+ pub fn get<T>(&self, f: &fn(&T)) -> bool {
unsafe {
f(transmute::<*c_void,&T>(*self.ptr));
}
}
#[inline(always)]
- fn visit_inner(&self, inner: *TyDesc) -> bool {
+ pub fn visit_inner(&self, inner: *TyDesc) -> bool {
self.visit_ptr_inner(*self.ptr, inner)
}
#[inline(always)]
- fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool {
+ pub fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool {
unsafe {
let u = ReprVisitor(ptr, self.writer);
let v = reflect::MovePtrAdaptor(u);
}
#[inline(always)]
- fn write<T:Repr>(&self) -> bool {
+ pub fn write<T:Repr>(&self) -> bool {
do self.get |v:&T| {
v.write_repr(self.writer);
}
}
- fn write_escaped_slice(&self, slice: &str) {
+ pub fn write_escaped_slice(&self, slice: &str) {
self.writer.write_char('"');
for slice.each_char |ch| {
self.writer.write_escaped_char(ch);
self.writer.write_char('"');
}
- fn write_mut_qualifier(&self, mtbl: uint) {
+ pub fn write_mut_qualifier(&self, mtbl: uint) {
if mtbl == 0 {
self.writer.write_str("mut ");
} else if mtbl == 1 {
}
}
- fn write_vec_range(&self, mtbl: uint, ptr: *u8, len: uint,
- inner: *TyDesc) -> bool {
+ pub fn write_vec_range(&self,
+ mtbl: uint,
+ ptr: *u8,
+ len: uint,
+ inner: *TyDesc)
+ -> bool {
let mut p = ptr;
let end = ptr::offset(p, len);
let (sz, al) = unsafe { ((*inner).size, (*inner).align) };
true
}
- fn write_unboxed_vec_repr(&self, mtbl: uint, v: &UnboxedVecRepr,
- inner: *TyDesc) -> bool {
+ pub fn write_unboxed_vec_repr(&self,
+ mtbl: uint,
+ v: &UnboxedVecRepr,
+ inner: *TyDesc)
+ -> bool {
self.write_vec_range(mtbl, ptr::to_unsafe_ptr(&v.data),
v.fill, inner)
}
-
-
}
impl TyVisitor for ReprVisitor {
//! A type representing either success or failure
-// NB: transitionary, de-mode-ing.
+#[allow(missing_doc)];
use cmp::Eq;
use either;
}
}
-pub impl<T, E> Result<T, E> {
+impl<T, E> Result<T, E> {
#[inline(always)]
- fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) }
+ pub fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) }
#[inline(always)]
- fn is_ok(&self) -> bool { is_ok(self) }
+ pub fn is_ok(&self) -> bool { is_ok(self) }
#[inline(always)]
- fn is_err(&self) -> bool { is_err(self) }
+ pub fn is_err(&self) -> bool { is_err(self) }
#[inline(always)]
- fn iter(&self, f: &fn(&T)) { iter(self, f) }
+ pub fn iter(&self, f: &fn(&T)) { iter(self, f) }
#[inline(always)]
- fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) }
+ pub fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) }
#[inline(always)]
- fn unwrap(self) -> T { unwrap(self) }
+ pub fn unwrap(self) -> T { unwrap(self) }
#[inline(always)]
- fn unwrap_err(self) -> E { unwrap_err(self) }
+ pub fn unwrap_err(self) -> E { unwrap_err(self) }
#[inline(always)]
- fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> {
+ pub fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> {
chain(self, op)
}
#[inline(always)]
- fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> {
+ pub fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> {
chain_err(self, op)
}
}
-pub impl<T:Copy,E> Result<T, E> {
+impl<T:Copy,E> Result<T, E> {
#[inline(always)]
- fn get(&self) -> T { get(self) }
+ pub fn get(&self) -> T { get(self) }
#[inline(always)]
- fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> {
+ pub fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> {
map_err(self, op)
}
}
-pub impl<T, E: Copy> Result<T, E> {
+impl<T, E: Copy> Result<T, E> {
#[inline(always)]
- fn get_err(&self) -> E { get_err(self) }
+ pub fn get_err(&self) -> E { get_err(self) }
#[inline(always)]
- fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> {
+ pub fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> {
map(self, op)
}
}
regs: ~Registers
}
-pub impl Context {
- fn empty() -> Context {
+impl Context {
+ pub fn empty() -> Context {
Context {
start: None,
regs: new_regs()
}
/// Create a new context that will resume execution by running ~fn()
- fn new(start: ~fn(), stack: &mut StackSegment) -> Context {
+ pub fn new(start: ~fn(), stack: &mut StackSegment) -> Context {
// XXX: Putting main into a ~ so it's a thin pointer and can
// be passed to the spawn function. Another unfortunate
// allocation
saving the registers values of the executing thread to a Context
then loading the registers from a previously saved Context.
*/
- fn swap(out_context: &mut Context, in_context: &Context) {
+ pub fn swap(out_context: &mut Context, in_context: &Context) {
let out_regs: &mut Registers = match out_context {
&Context { regs: ~ref mut r, _ } => r
};
GiveTask(~Coroutine, UnsafeTaskReceiver)
}
-pub impl Scheduler {
+impl Scheduler {
+ pub fn in_task_context(&self) -> bool { self.current_task.is_some() }
- fn in_task_context(&self) -> bool { self.current_task.is_some() }
-
- fn new(event_loop: ~EventLoopObject) -> Scheduler {
+ pub fn new(event_loop: ~EventLoopObject) -> Scheduler {
// Lazily initialize the runtime TLS key
local_ptr::init_tls_key();
// the scheduler itself doesn't have to call event_loop.run.
// That will be important for embedding the runtime into external
// event loops.
- fn run(~self) -> ~Scheduler {
+ pub fn run(~self) -> ~Scheduler {
assert!(!self.in_task_context());
let mut self_sched = self;
/// Pushes the task onto the work stealing queue and tells the event loop
/// to run it later. Always use this instead of pushing to the work queue
/// directly.
- fn enqueue_task(&mut self, task: ~Coroutine) {
+ pub fn enqueue_task(&mut self, task: ~Coroutine) {
self.work_queue.push(task);
self.event_loop.callback(resume_task_from_queue);
// * Scheduler-context operations
- fn resume_task_from_queue(~self) {
+ pub fn resume_task_from_queue(~self) {
assert!(!self.in_task_context());
rtdebug!("looking in work queue for task to schedule");
/// Called by a running task to end execution, after which it will
/// be recycled by the scheduler for reuse in a new task.
- fn terminate_current_task(~self) {
+ pub fn terminate_current_task(~self) {
assert!(self.in_task_context());
rtdebug!("ending running task");
abort!("control reached end of task");
}
- fn schedule_new_task(~self, task: ~Coroutine) {
+ pub fn schedule_new_task(~self, task: ~Coroutine) {
assert!(self.in_task_context());
do self.switch_running_tasks_and_then(task) |last_task| {
}
}
- fn schedule_task(~self, task: ~Coroutine) {
+ pub fn schedule_task(~self, task: ~Coroutine) {
assert!(self.in_task_context());
do self.switch_running_tasks_and_then(task) |last_task| {
// Core scheduling ops
- fn resume_task_immediately(~self, task: ~Coroutine) {
+ pub fn resume_task_immediately(~self, task: ~Coroutine) {
let mut this = self;
assert!(!this.in_task_context());
/// The closure here is a *stack* closure that lives in the
/// running task. It gets transmuted to the scheduler's lifetime
/// and called while the task is blocked.
- fn deschedule_running_task_and_then(~self, f: &fn(~Coroutine)) {
+ pub fn deschedule_running_task_and_then(~self, f: &fn(~Coroutine)) {
let mut this = self;
assert!(this.in_task_context());
/// Switch directly to another task, without going through the scheduler.
/// You would want to think hard about doing this, e.g. if there are
/// pending I/O events it would be a bad idea.
- fn switch_running_tasks_and_then(~self, next_task: ~Coroutine, f: &fn(~Coroutine)) {
+ pub fn switch_running_tasks_and_then(~self,
+ next_task: ~Coroutine,
+ f: &fn(~Coroutine)) {
let mut this = self;
assert!(this.in_task_context());
// * Other stuff
- fn enqueue_cleanup_job(&mut self, job: CleanupJob) {
+ pub fn enqueue_cleanup_job(&mut self, job: CleanupJob) {
assert!(self.cleanup_job.is_none());
self.cleanup_job = Some(job);
}
- fn run_cleanup_job(&mut self) {
+ pub fn run_cleanup_job(&mut self) {
rtdebug!("running cleanup job");
assert!(self.cleanup_job.is_some());
/// callers should first arrange for that task to be located in the
/// Scheduler's current_task slot and set up the
/// post-context-switch cleanup job.
- fn get_contexts<'a>(&'a mut self) -> (&'a mut Context,
- Option<&'a mut Context>,
- Option<&'a mut Context>) {
+ pub fn get_contexts<'a>(&'a mut self) -> (&'a mut Context,
+ Option<&'a mut Context>,
+ Option<&'a mut Context>) {
let last_task = match self.cleanup_job {
Some(GiveTask(~ref task, _)) => {
Some(task)
task: ~Task
}
-pub impl Coroutine {
- fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine {
+impl Coroutine {
+ pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine {
Coroutine::with_task(stack_pool, ~Task::new(), start)
}
- fn with_task(stack_pool: &mut StackPool,
- task: ~Task,
- start: ~fn()) -> Coroutine {
+ pub fn with_task(stack_pool: &mut StackPool,
+ task: ~Task,
+ start: ~fn()) -> Coroutine {
let start = Coroutine::build_start_wrapper(start);
let mut stack = stack_pool.take_segment(MIN_STACK_SIZE);
// NB: Context holds a pointer to that ~fn
};
}
- priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
+ fn build_start_wrapper(start: ~fn()) -> ~fn() {
// XXX: The old code didn't have this extra allocation
let wrapper: ~fn() = || {
// This is the first code to execute after the initial
}
/// Destroy the task and try to reuse its components
- fn recycle(~self, stack_pool: &mut StackPool) {
+ pub fn recycle(~self, stack_pool: &mut StackPool) {
match self {
~Coroutine {current_stack_segment, _} => {
stack_pool.give_segment(current_stack_segment);
valgrind_id: c_uint
}
-pub impl StackSegment {
- fn new(size: uint) -> StackSegment {
+impl StackSegment {
+ pub fn new(size: uint) -> StackSegment {
unsafe {
// Crate a block of uninitialized values
let mut stack = vec::with_capacity(size);
}
/// Point to the low end of the allocated stack
- fn start(&self) -> *uint {
- vec::raw::to_ptr(self.buf) as *uint
+ pub fn start(&self) -> *uint {
+ vec::raw::to_ptr(self.buf) as *uint
}
/// Point one word beyond the high end of the allocated stack
- fn end(&self) -> *uint {
+ pub fn end(&self) -> *uint {
vec::raw::to_ptr(self.buf).offset(self.buf.len()) as *uint
}
}
raw_thread: *raw_thread
}
-pub impl Thread {
- fn start(main: ~fn()) -> Thread {
+impl Thread {
+ pub fn start(main: ~fn()) -> Thread {
fn substart(main: &~fn()) -> *raw_thread {
unsafe { rust_raw_thread_start(main) }
}
pub struct IdleWatcher(*uvll::uv_idle_t);
impl Watcher for IdleWatcher { }
-pub impl IdleWatcher {
- fn new(loop_: &mut Loop) -> IdleWatcher {
+impl IdleWatcher {
+ pub fn new(loop_: &mut Loop) -> IdleWatcher {
unsafe {
let handle = uvll::idle_new();
assert!(handle.is_not_null());
}
}
- fn start(&mut self, cb: IdleCallback) {
+ pub fn start(&mut self, cb: IdleCallback) {
{
let data = self.get_watcher_data();
data.idle_cb = Some(cb);
}
}
- fn stop(&mut self) {
- // NB: Not resetting the Rust idle_cb to None here because `stop` is likely
- // called from *within* the idle callback, causing a use after free
+ pub fn stop(&mut self) {
+ // NB: Not resetting the Rust idle_cb to None here because `stop` is
+ // likely called from *within* the idle callback, causing a use after
+ // free
unsafe {
assert!(0 == uvll::idle_stop(self.native_handle()));
}
}
- fn close(self, cb: NullCallback) {
+ pub fn close(self, cb: NullCallback) {
{
let mut this = self;
let data = this.get_watcher_data();
pub fn native_handle(&self) -> T;
}
-pub impl Loop {
- fn new() -> Loop {
+impl Loop {
+ pub fn new() -> Loop {
let handle = unsafe { uvll::loop_new() };
assert!(handle.is_not_null());
NativeHandle::from_native_handle(handle)
}
- fn run(&mut self) {
+ pub fn run(&mut self) {
unsafe { uvll::run(self.native_handle()) };
}
- fn close(&mut self) {
+ pub fn close(&mut self) {
unsafe { uvll::loop_delete(self.native_handle()) };
}
}
pub struct UvError(uvll::uv_err_t);
-pub impl UvError {
-
- fn name(&self) -> ~str {
+impl UvError {
+ pub fn name(&self) -> ~str {
unsafe {
let inner = match self { &UvError(ref a) => a };
let name_str = uvll::err_name(inner);
}
}
- fn desc(&self) -> ~str {
+ pub fn desc(&self) -> ~str {
unsafe {
let inner = match self { &UvError(ref a) => a };
let desc_str = uvll::strerror(inner);
}
}
- fn is_eof(&self) -> bool {
+ pub fn is_eof(&self) -> bool {
self.code == uvll::EOF
}
}
pub struct StreamWatcher(*uvll::uv_stream_t);
impl Watcher for StreamWatcher { }
-pub impl StreamWatcher {
-
- fn read_start(&mut self, alloc: AllocCallback, cb: ReadCallback) {
+impl StreamWatcher {
+ pub fn read_start(&mut self, alloc: AllocCallback, cb: ReadCallback) {
{
let data = self.get_watcher_data();
data.alloc_cb = Some(alloc);
}
}
- fn read_stop(&mut self) {
+ pub fn read_stop(&mut self) {
// It would be nice to drop the alloc and read callbacks here,
// but read_stop may be called from inside one of them and we
// would end up freeing the in-use environment
unsafe { uvll::read_stop(handle); }
}
- fn write(&mut self, buf: Buf, cb: ConnectionCallback) {
+ pub fn write(&mut self, buf: Buf, cb: ConnectionCallback) {
{
let data = self.get_watcher_data();
assert!(data.write_cb.is_none());
}
}
- fn accept(&mut self, stream: StreamWatcher) {
+ pub fn accept(&mut self, stream: StreamWatcher) {
let self_handle = self.native_handle() as *c_void;
let stream_handle = stream.native_handle() as *c_void;
unsafe {
}
}
- fn close(self, cb: NullCallback) {
+ pub fn close(self, cb: NullCallback) {
{
let mut this = self;
let data = this.get_watcher_data();
pub struct TcpWatcher(*uvll::uv_tcp_t);
impl Watcher for TcpWatcher { }
-pub impl TcpWatcher {
- fn new(loop_: &mut Loop) -> TcpWatcher {
+impl TcpWatcher {
+ pub fn new(loop_: &mut Loop) -> TcpWatcher {
unsafe {
let handle = malloc_handle(UV_TCP);
assert!(handle.is_not_null());
}
}
- fn bind(&mut self, address: IpAddr) -> Result<(), UvError> {
+ pub fn bind(&mut self, address: IpAddr) -> Result<(), UvError> {
match address {
Ipv4(*) => {
do ip4_as_uv_ip4(address) |addr| {
}
}
- fn connect(&mut self, address: IpAddr, cb: ConnectionCallback) {
+ pub fn connect(&mut self, address: IpAddr, cb: ConnectionCallback) {
unsafe {
assert!(self.get_watcher_data().connect_cb.is_none());
self.get_watcher_data().connect_cb = Some(cb);
}
}
- fn listen(&mut self, cb: ConnectionCallback) {
+ pub fn listen(&mut self, cb: ConnectionCallback) {
{
let data = self.get_watcher_data();
assert!(data.connect_cb.is_none());
}
}
- fn as_stream(&self) -> StreamWatcher {
+ pub fn as_stream(&self) -> StreamWatcher {
NativeHandle::from_native_handle(self.native_handle() as *uvll::uv_stream_t)
}
}
impl Request for WriteRequest { }
-pub impl WriteRequest {
-
- fn new() -> WriteRequest {
+impl WriteRequest {
+ pub fn new() -> WriteRequest {
let write_handle = unsafe {
malloc_req(UV_WRITE)
};
WriteRequest(write_handle)
}
- fn stream(&self) -> StreamWatcher {
+ pub fn stream(&self) -> StreamWatcher {
unsafe {
let stream_handle = uvll::get_stream_handle_from_write_req(self.native_handle());
NativeHandle::from_native_handle(stream_handle)
}
}
- fn delete(self) {
+ pub fn delete(self) {
unsafe { free_req(self.native_handle() as *c_void) }
}
}
uvio: UvIoFactory
}
-pub impl UvEventLoop {
- fn new() -> UvEventLoop {
+impl UvEventLoop {
+ pub fn new() -> UvEventLoop {
UvEventLoop {
uvio: UvIoFactory(Loop::new())
}
}
/// A convenience constructor
- fn new_scheduler() -> Scheduler {
+ pub fn new_scheduler() -> Scheduler {
Scheduler::new(~UvEventLoop::new())
}
}
}
impl EventLoop for UvEventLoop {
-
fn run(&mut self) {
self.uvio.uv_loop().run();
}
pub struct UvIoFactory(Loop);
-pub impl UvIoFactory {
- fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
+impl UvIoFactory {
+ pub fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
match self { &UvIoFactory(ref mut ptr) => ptr }
}
}
uvio: UvIoFactory
}
-pub impl UvEventLoop {
- fn new() -> UvEventLoop {
+impl UvEventLoop {
+ pub fn new() -> UvEventLoop {
UvEventLoop {
uvio: UvIoFactory(Loop::new())
}
}
/// A convenience constructor
- fn new_scheduler() -> Scheduler {
+ pub fn new_scheduler() -> Scheduler {
Scheduler::new(~UvEventLoop::new())
}
}
pub struct UvIoFactory(Loop);
-pub impl UvIoFactory {
- fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
+impl UvIoFactory {
+ pub fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
match self { &UvIoFactory(ref mut ptr) => ptr }
}
}
priv queue: ~Exclusive<~[T]>
}
-pub impl<T: Owned> WorkQueue<T> {
- fn new() -> WorkQueue<T> {
+impl<T: Owned> WorkQueue<T> {
+ pub fn new() -> WorkQueue<T> {
WorkQueue {
queue: ~exclusive(~[])
}
}
- fn push(&mut self, value: T) {
+ pub fn push(&mut self, value: T) {
unsafe {
let value = Cell(value);
self.queue.with(|q| q.unshift(value.take()) );
}
}
- fn pop(&mut self) -> Option<T> {
+ pub fn pop(&mut self) -> Option<T> {
unsafe {
do self.queue.with |q| {
if !q.is_empty() {
}
}
- fn steal(&mut self) -> Option<T> {
+ pub fn steal(&mut self) -> Option<T> {
unsafe {
do self.queue.with |q| {
if !q.is_empty() {
}
}
- fn is_empty(&self) -> bool {
+ pub fn is_empty(&self) -> bool {
unsafe {
self.queue.with_imm(|q| q.is_empty() )
}
error: ~[u8],
}
-pub impl Process {
-
+impl Process {
/**
* Spawns a new Process.
*
* * options - Options to configure the environment of the process,
* the working directory and the standard IO streams.
*/
- pub fn new(prog: &str, args: &[~str], options: ProcessOptions) -> Process {
-
+ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
+ -> Process {
let (in_pipe, in_fd) = match options.in_fd {
None => {
let pipe = os::pipe();
}
/// Returns the unique id of the process
- fn get_id(&self) -> pid_t { self.pid }
+ pub fn get_id(&self) -> pid_t { self.pid }
- priv fn input_fd(&mut self) -> c_int {
+ fn input_fd(&mut self) -> c_int {
match self.input {
Some(fd) => fd,
None => fail!("This Process's stdin was redirected to an \
}
}
- priv fn output_file(&mut self) -> *libc::FILE {
+ fn output_file(&mut self) -> *libc::FILE {
match self.output {
Some(file) => file,
None => fail!("This Process's stdout was redirected to an \
}
}
- priv fn error_file(&mut self) -> *libc::FILE {
+ fn error_file(&mut self) -> *libc::FILE {
match self.error {
Some(file) => file,
None => fail!("This Process's stderr was redirected to an \
*
* If this method returns true then self.input() will fail.
*/
- fn input_redirected(&self) -> bool {
+ pub fn input_redirected(&self) -> bool {
self.input.is_none()
}
*
* If this method returns true then self.output() will fail.
*/
- fn output_redirected(&self) -> bool {
+ pub fn output_redirected(&self) -> bool {
self.output.is_none()
}
*
* If this method returns true then self.error() will fail.
*/
- fn error_redirected(&self) -> bool {
+ pub fn error_redirected(&self) -> bool {
self.error.is_none()
}
*
* Fails if this Process's stdin was redirected to an existing file descriptor.
*/
- fn input(&mut self) -> @io::Writer {
+ pub fn input(&mut self) -> @io::Writer {
// FIXME: the Writer can still be used after self is destroyed: #2625
io::fd_writer(self.input_fd(), false)
}
*
* Fails if this Process's stdout was redirected to an existing file descriptor.
*/
- fn output(&mut self) -> @io::Reader {
+ pub fn output(&mut self) -> @io::Reader {
// FIXME: the Reader can still be used after self is destroyed: #2625
io::FILE_reader(self.output_file(), false)
}
*
* Fails if this Process's stderr was redirected to an existing file descriptor.
*/
- fn error(&mut self) -> @io::Reader {
+ pub fn error(&mut self) -> @io::Reader {
// FIXME: the Reader can still be used after self is destroyed: #2625
io::FILE_reader(self.error_file(), false)
}
* If this process is reading its stdin from an existing file descriptor, then this
* method does nothing.
*/
- fn close_input(&mut self) {
+ pub fn close_input(&mut self) {
match self.input {
Some(-1) | None => (),
Some(fd) => {
}
}
- priv fn close_outputs(&mut self) {
+ fn close_outputs(&mut self) {
fclose_and_null(&mut self.output);
fclose_and_null(&mut self.error);
*
* If the child has already been finished then the exit code is returned.
*/
- fn finish(&mut self) -> int {
+ pub fn finish(&mut self) -> int {
for self.exit_code.each |&code| {
return code;
}
* This method will fail if the child process's stdout or stderr streams were
* redirected to existing file descriptors.
*/
- fn finish_with_output(&mut self) -> ProcessOutput {
-
+ pub fn finish_with_output(&mut self) -> ProcessOutput {
let output_file = self.output_file();
let error_file = self.error_file();
error: errs};
}
- priv fn destroy_internal(&mut self, force: bool) {
-
+ fn destroy_internal(&mut self, force: bool) {
// if the process has finished, and therefore had waitpid called,
// and we kill it, then on unix we might ending up killing a
// newer process that happens to have the same (re-used) id
* On Posix OSs SIGTERM will be sent to the process. On Win32
* TerminateProcess(..) will be called.
*/
- fn destroy(&mut self) { self.destroy_internal(false); }
+ pub fn destroy(&mut self) { self.destroy_internal(false); }
/**
* Terminates the process as soon as possible without giving it a
* On Posix OSs SIGKILL will be sent to the process. On Win32
* TerminateProcess(..) will be called.
*/
- fn force_destroy(&mut self) { self.destroy_internal(true); }
+ pub fn force_destroy(&mut self) { self.destroy_internal(true); }
}
impl Drop for Process {
#[deriving(Clone, Eq)]
pub struct Ascii { priv chr: u8 }
-pub impl Ascii {
+impl Ascii {
/// Converts a ascii character into a `u8`.
#[inline(always)]
- fn to_byte(self) -> u8 {
+ pub fn to_byte(self) -> u8 {
self.chr
}
/// Converts a ascii character into a `char`.
#[inline(always)]
- fn to_char(self) -> char {
+ pub fn to_char(self) -> char {
self.chr as char
}
/// Convert to lowercase.
#[inline(always)]
- fn to_lower(self) -> Ascii {
+ pub fn to_lower(self) -> Ascii {
if self.chr >= 65 && self.chr <= 90 {
Ascii{chr: self.chr | 0x20 }
} else {
/// Convert to uppercase.
#[inline(always)]
- fn to_upper(self) -> Ascii {
+ pub fn to_upper(self) -> Ascii {
if self.chr >= 97 && self.chr <= 122 {
Ascii{chr: self.chr & !0x20 }
} else {
}
}
- // Compares two ascii characters of equality, ignoring case.
+ /// Compares two ascii characters of equality, ignoring case.
#[inline(always)]
- fn eq_ignore_case(self, other: Ascii) -> bool {
+ pub fn eq_ignore_case(self, other: Ascii) -> bool {
self.to_lower().chr == other.to_lower().chr
}
}
}
}
-priv impl TaskBuilder {
+impl TaskBuilder {
fn consume(&mut self) -> TaskBuilder {
if self.consumed {
fail!("Cannot copy a task_builder"); // Fake move mode on self
}
}
-pub impl TaskBuilder {
+impl TaskBuilder {
/// Decouple the child task's failure from the parent's. If either fails,
/// the other will not be killed.
- fn unlinked(&mut self) {
+ pub fn unlinked(&mut self) {
self.opts.linked = false;
}
/// Unidirectionally link the child task's failure with the parent's. The
/// child's failure will not kill the parent, but the parent's will kill
/// the child.
- fn supervised(&mut self) {
+ pub fn supervised(&mut self) {
self.opts.supervised = true;
self.opts.linked = false;
}
/// Link the child task's and parent task's failures. If either fails, the
/// other will be killed.
- fn linked(&mut self) {
+ pub fn linked(&mut self) {
self.opts.linked = true;
self.opts.supervised = false;
}
* # Failure
* Fails if a future_result was already set for this task.
*/
- fn future_result(&mut self, blk: &fn(v: Port<TaskResult>)) {
+ pub fn future_result(&mut self, blk: &fn(v: Port<TaskResult>)) {
// FIXME (#3725): Once linked failure and notification are
// handled in the library, I can imagine implementing this by just
// registering an arbitrary number of task::on_exit handlers and
}
/// Configure a custom scheduler mode for the task.
- fn sched_mode(&mut self, mode: SchedMode) {
+ pub fn sched_mode(&mut self, mode: SchedMode) {
self.opts.sched.mode = mode;
}
* generator by applying the task body which results from the
* existing body generator to the new body generator.
*/
- fn add_wrapper(&mut self, wrapper: ~fn(v: ~fn()) -> ~fn()) {
+ pub fn add_wrapper(&mut self, wrapper: ~fn(v: ~fn()) -> ~fn()) {
let prev_gen_body = replace(&mut self.gen_body, None);
let prev_gen_body = match prev_gen_body {
Some(gen) => gen,
* When spawning into a new scheduler, the number of threads requested
* must be greater than zero.
*/
- fn spawn(&mut self, f: ~fn()) {
+ pub fn spawn(&mut self, f: ~fn()) {
let gen_body = replace(&mut self.gen_body, None);
let notify_chan = replace(&mut self.opts.notify_chan, None);
let x = self.consume();
}
/// Runs a task, while transfering ownership of one argument to the child.
- fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) {
+ pub fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) {
let arg = Cell(arg);
do self.spawn {
f(arg.take());
* # Failure
* Fails if a future_result was already set for this task.
*/
- fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> {
+ pub fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> {
let (po, ch) = stream::<T>();
let mut result = None;
}
}
-pub impl<T> TrieMap<T> {
+impl<T> TrieMap<T> {
/// Create an empty TrieMap
#[inline(always)]
- fn new() -> TrieMap<T> {
+ pub fn new() -> TrieMap<T> {
TrieMap{root: TrieNode::new(), length: 0}
}
/// Visit all key-value pairs in reverse order
#[inline(always)]
- fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
+ pub fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
self.root.each_reverse(f)
}
/// Visit all keys in reverse order
#[inline(always)]
- fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool {
+ pub fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool {
self.each_reverse(|k, _| f(k))
}
/// Visit all values in reverse order
#[inline(always)]
- fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool {
+ pub fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool {
self.each_reverse(|_, v| f(v))
}
}
fn clear(&mut self) { self.map.clear() }
}
-pub impl TrieSet {
+impl TrieSet {
/// Create an empty TrieSet
#[inline(always)]
- fn new() -> TrieSet {
+ pub fn new() -> TrieSet {
TrieSet{map: TrieMap::new()}
}
/// Return true if the set contains a value
#[inline(always)]
- fn contains(&self, value: &uint) -> bool {
+ pub fn contains(&self, value: &uint) -> bool {
self.map.contains_key(value)
}
/// Add a value to the set. Return true if the value was not already
/// present in the set.
#[inline(always)]
- fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
+ pub fn insert(&mut self, value: uint) -> bool {
+ self.map.insert(value, ())
+ }
/// Remove a value from the set. Return true if the value was
/// present in the set.
#[inline(always)]
- fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
+ pub fn remove(&mut self, value: &uint) -> bool {
+ self.map.remove(value)
+ }
}
struct TrieNode<T> {
next: uint
}
- pub impl<T> Parsed<T> {
- fn new(val: T, next: uint) -> Parsed<T> {
+ impl<T> Parsed<T> {
+ pub fn new(val: T, next: uint) -> Parsed<T> {
Parsed {val: val, next: next}
}
}
}
}
-pub impl LittleLock {
+impl LittleLock {
#[inline(always)]
- unsafe fn lock<T>(&self, f: &fn() -> T) -> T {
+ pub unsafe fn lock<T>(&self, f: &fn() -> T) -> T {
do atomically {
rust_lock_little_lock(self.l);
do (|| {
}
}
-pub impl<T:Owned> Exclusive<T> {
+impl<T:Owned> Exclusive<T> {
// Exactly like std::arc::mutex_arc,access(), but with the little_lock
// instead of a proper mutex. Same reason for being unsafe.
//
// accessing the provided condition variable) are prohibited while inside
// the exclusive. Supporting that is a work in progress.
#[inline(always)]
- unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U {
+ pub unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U {
let rec = self.x.get();
do (*rec).lock.lock {
if (*rec).failed {
}
#[inline(always)]
- unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U {
+ pub unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U {
do self.with |x| {
f(cast::transmute_immut(x))
}
/// A type with no inhabitants
pub enum Void { }
-pub impl Void {
+impl Void {
/// A utility function for ignoring this uninhabited type
- fn uninhabited(self) -> ! {
+ pub fn uninhabited(self) -> ! {
match self {
// Nothing to match on
}
AbiDatas.map(|d| d.name)
}
-pub impl Abi {
+impl Abi {
#[inline]
- fn index(&self) -> uint {
+ pub fn index(&self) -> uint {
*self as uint
}
#[inline]
- fn data(&self) -> &'static AbiData {
+ pub fn data(&self) -> &'static AbiData {
&AbiDatas[self.index()]
}
- fn name(&self) -> &'static str {
+ pub fn name(&self) -> &'static str {
self.data().name
}
}
}
}
-pub impl AbiSet {
- fn from(abi: Abi) -> AbiSet {
+impl AbiSet {
+ pub fn from(abi: Abi) -> AbiSet {
AbiSet { bits: (1 << abi.index()) }
}
#[inline]
- fn Rust() -> AbiSet {
+ pub fn Rust() -> AbiSet {
AbiSet::from(Rust)
}
#[inline]
- fn C() -> AbiSet {
+ pub fn C() -> AbiSet {
AbiSet::from(C)
}
#[inline]
- fn Intrinsic() -> AbiSet {
+ pub fn Intrinsic() -> AbiSet {
AbiSet::from(RustIntrinsic)
}
- fn default() -> AbiSet {
+ pub fn default() -> AbiSet {
AbiSet::C()
}
- fn empty() -> AbiSet {
+ pub fn empty() -> AbiSet {
AbiSet { bits: 0 }
}
#[inline]
- fn is_rust(&self) -> bool {
+ pub fn is_rust(&self) -> bool {
self.bits == 1 << Rust.index()
}
#[inline]
- fn is_c(&self) -> bool {
+ pub fn is_c(&self) -> bool {
self.bits == 1 << C.index()
}
#[inline]
- fn is_intrinsic(&self) -> bool {
+ pub fn is_intrinsic(&self) -> bool {
self.bits == 1 << RustIntrinsic.index()
}
- fn contains(&self, abi: Abi) -> bool {
+ pub fn contains(&self, abi: Abi) -> bool {
(self.bits & (1 << abi.index())) != 0
}
- fn subset_of(&self, other_abi_set: AbiSet) -> bool {
+ pub fn subset_of(&self, other_abi_set: AbiSet) -> bool {
(self.bits & other_abi_set.bits) == self.bits
}
- fn add(&mut self, abi: Abi) {
+ pub fn add(&mut self, abi: Abi) {
self.bits |= (1 << abi.index());
}
- fn each(&self, op: &fn(abi: Abi) -> bool) -> bool {
+ pub fn each(&self, op: &fn(abi: Abi) -> bool) -> bool {
each_abi(|abi| !self.contains(abi) || op(abi))
}
- fn is_empty(&self) -> bool {
+ pub fn is_empty(&self) -> bool {
self.bits == 0
}
- fn for_arch(&self, arch: Architecture) -> Option<Abi> {
+ pub fn for_arch(&self, arch: Architecture) -> Option<Abi> {
// NB---Single platform ABIs come first
for self.each |abi| {
let data = abi.data();
None
}
- fn check_valid(&self) -> Option<(Abi, Abi)> {
+ pub fn check_valid(&self) -> Option<(Abi, Abi)> {
let mut abis = ~[];
for self.each |abi| { abis.push(abi); }
ty_params: OptVec<TyParam>
}
-pub impl Generics {
- fn is_parameterized(&self) -> bool {
+impl Generics {
+ pub fn is_parameterized(&self) -> bool {
self.lifetimes.len() + self.ty_params.len() > 0
}
- fn is_lt_parameterized(&self) -> bool {
+ pub fn is_lt_parameterized(&self) -> bool {
self.lifetimes.len() > 0
}
- fn is_type_parameterized(&self) -> bool {
+ pub fn is_type_parameterized(&self) -> bool {
self.ty_params.len() > 0
}
}
max: node_id,
}
-pub impl id_range {
- fn max() -> id_range {
- id_range {min: int::max_value,
- max: int::min_value}
+impl id_range {
+ pub fn max() -> id_range {
+ id_range {
+ min: int::max_value,
+ max: int::min_value,
+ }
}
- fn empty(&self) -> bool {
+ pub fn empty(&self) -> bool {
self.min >= self.max
}
- fn add(&mut self, id: node_id) {
+ pub fn add(&mut self, id: node_id) {
self.min = int::min(self.min, id);
self.max = int::max(self.max, id + 1);
}
multibyte_chars: @mut ~[MultiByteChar],
}
-pub impl FileMap {
+impl FileMap {
// EFFECT: register a start-of-line offset in the
// table of line-beginnings.
// UNCHECKED INVARIANT: these offsets must be added in the right
// order and must be in the right places; there is shared knowledge
// about what ends a line between this file and parse.rs
- fn next_line(&self, pos: BytePos) {
+ pub fn next_line(&self, pos: BytePos) {
// the new charpos must be > the last one (or it's the first one).
let lines = &mut *self.lines;
assert!((lines.len() == 0) || (lines[lines.len() - 1] < pos))
files: @mut ~[@FileMap]
}
-pub impl CodeMap {
+impl CodeMap {
pub fn new() -> CodeMap {
CodeMap {
files: @mut ~[],
}
/// Add a new FileMap to the CodeMap and return it
- fn new_filemap(&self, filename: FileName, src: @~str) -> @FileMap {
+ pub fn new_filemap(&self, filename: FileName, src: @~str) -> @FileMap {
return self.new_filemap_w_substr(filename, FssNone, src);
}
- fn new_filemap_w_substr(
- &self,
- filename: FileName,
- substr: FileSubstr,
- src: @~str
- ) -> @FileMap {
+ pub fn new_filemap_w_substr(&self,
+ filename: FileName,
+ substr: FileSubstr,
+ src: @~str)
+ -> @FileMap {
let files = &mut *self.files;
let start_pos = if files.len() == 0 {
0
return self.lookup_pos(pos);
}
- pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt
- {
+ pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
let loc = self.lookup_char_pos(pos);
match (loc.file.substr) {
FssNone =>
// (or expected function, found _|_)
fail!(); // ("asking for " + filename + " which we don't know about");
}
-
}
-priv impl CodeMap {
-
+impl CodeMap {
fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
let files = &*self.files;
let len = files.len();
trace_mac: @mut bool
}
-pub impl ExtCtxt {
- fn new(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg) -> @ExtCtxt {
+impl ExtCtxt {
+ pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg)
+ -> @ExtCtxt {
@ExtCtxt {
parse_sess: parse_sess,
cfg: cfg,
}
}
- fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
- fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
- fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
- fn call_site(&self) -> span {
+ pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
+ pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
+ pub fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
+ pub fn call_site(&self) -> span {
match *self.backtrace {
Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs,
None => self.bug("missing top span")
}
}
- fn print_backtrace(&self) { }
- fn backtrace(&self) -> Option<@ExpnInfo> { *self.backtrace }
- fn mod_push(&self, i: ast::ident) { self.mod_path.push(i); }
- fn mod_pop(&self) { self.mod_path.pop(); }
- fn mod_path(&self) -> ~[ast::ident] { copy *self.mod_path }
- fn bt_push(&self, ei: codemap::ExpnInfo) {
+ pub fn print_backtrace(&self) { }
+ pub fn backtrace(&self) -> Option<@ExpnInfo> { *self.backtrace }
+ pub fn mod_push(&self, i: ast::ident) { self.mod_path.push(i); }
+ pub fn mod_pop(&self) { self.mod_path.pop(); }
+ pub fn mod_path(&self) -> ~[ast::ident] { copy *self.mod_path }
+ pub fn bt_push(&self, ei: codemap::ExpnInfo) {
match ei {
ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => {
*self.backtrace =
}
}
}
- fn bt_pop(&self) {
+ pub fn bt_pop(&self) {
match *self.backtrace {
Some(@ExpandedFrom(
CallInfo {
_ => self.bug("tried to pop without a push")
}
}
- fn span_fatal(&self, sp: span, msg: &str) -> ! {
+ pub fn span_fatal(&self, sp: span, msg: &str) -> ! {
self.print_backtrace();
self.parse_sess.span_diagnostic.span_fatal(sp, msg);
}
- fn span_err(&self, sp: span, msg: &str) {
+ pub fn span_err(&self, sp: span, msg: &str) {
self.print_backtrace();
self.parse_sess.span_diagnostic.span_err(sp, msg);
}
- fn span_warn(&self, sp: span, msg: &str) {
+ pub fn span_warn(&self, sp: span, msg: &str) {
self.print_backtrace();
self.parse_sess.span_diagnostic.span_warn(sp, msg);
}
- fn span_unimpl(&self, sp: span, msg: &str) -> ! {
+ pub fn span_unimpl(&self, sp: span, msg: &str) -> ! {
self.print_backtrace();
self.parse_sess.span_diagnostic.span_unimpl(sp, msg);
}
- fn span_bug(&self, sp: span, msg: &str) -> ! {
+ pub fn span_bug(&self, sp: span, msg: &str) -> ! {
self.print_backtrace();
self.parse_sess.span_diagnostic.span_bug(sp, msg);
}
- fn bug(&self, msg: &str) -> ! {
+ pub fn bug(&self, msg: &str) -> ! {
self.print_backtrace();
self.parse_sess.span_diagnostic.handler().bug(msg);
}
- fn next_id(&self) -> ast::node_id {
+ pub fn next_id(&self) -> ast::node_id {
parse::next_node_id(self.parse_sess)
}
- fn trace_macros(&self) -> bool {
+ pub fn trace_macros(&self) -> bool {
*self.trace_mac
}
- fn set_trace_macros(&self, x: bool) {
+ pub fn set_trace_macros(&self, x: bool) {
*self.trace_mac = x
}
- fn str_of(&self, id: ast::ident) -> ~str {
+ pub fn str_of(&self, id: ast::ident) -> ~str {
copy *self.parse_sess.interner.get(id)
}
- fn ident_of(&self, st: &str) -> ast::ident {
+ pub fn ident_of(&self, st: &str) -> ast::ident {
self.parse_sess.interner.intern(st)
}
}
}
// traits just don't work anywhere...?
-//pub impl Map<Name,SyntaxExtension> for MapChain {
+//impl Map<Name,SyntaxExtension> for MapChain {
fn contains_key (&self, key: &K) -> bool {
match *self {
global: bool
}
-pub impl<'self> Path<'self> {
- fn new<'r>(path: ~[&'r str]) -> Path<'r> {
+impl<'self> Path<'self> {
+ pub fn new<'r>(path: ~[&'r str]) -> Path<'r> {
Path::new_(path, None, ~[], true)
}
- fn new_local<'r>(path: &'r str) -> Path<'r> {
+ pub fn new_local<'r>(path: &'r str) -> Path<'r> {
Path::new_(~[ path ], None, ~[], false)
}
- fn new_<'r>(path: ~[&'r str], lifetime: Option<&'r str>, params: ~[~Ty<'r>], global: bool)
- -> Path<'r> {
+ pub fn new_<'r>(path: ~[&'r str],
+ lifetime: Option<&'r str>,
+ params: ~[~Ty<'r>],
+ global: bool)
+ -> Path<'r> {
Path {
path: path,
lifetime: lifetime,
}
}
- fn to_ty(&self, cx: @ExtCtxt, span: span,
- self_ty: ident, self_generics: &Generics) -> @ast::Ty {
+ pub fn to_ty(&self,
+ cx: @ExtCtxt,
+ span: span,
+ self_ty: ident,
+ self_generics: &Generics)
+ -> @ast::Ty {
cx.ty_path(self.to_path(cx, span,
self_ty, self_generics))
}
- fn to_path(&self, cx: @ExtCtxt, span: span,
- self_ty: ident, self_generics: &Generics) -> @ast::Path {
+ pub fn to_path(&self,
+ cx: @ExtCtxt,
+ span: span,
+ self_ty: ident,
+ self_generics: &Generics)
+ -> @ast::Path {
let idents = self.path.map(|s| cx.ident_of(*s) );
let lt = mk_lifetime(cx, span, &self.lifetime);
let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics));
}
}
-pub impl<'self> Ty<'self> {
- fn to_ty(&self, cx: @ExtCtxt, span: span,
- self_ty: ident, self_generics: &Generics) -> @ast::Ty {
+impl<'self> Ty<'self> {
+ pub fn to_ty(&self,
+ cx: @ExtCtxt,
+ span: span,
+ self_ty: ident,
+ self_generics: &Generics)
+ -> @ast::Ty {
match *self {
Ptr(ref ty, ref ptr) => {
let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);
}
}
- fn to_path(&self, cx: @ExtCtxt, span: span,
- self_ty: ident, self_generics: &Generics) -> @ast::Path {
+ pub fn to_path(&self,
+ cx: @ExtCtxt,
+ span: span,
+ self_ty: ident,
+ self_generics: &Generics)
+ -> @ast::Path {
match *self {
Self => {
let self_params = do self_generics.ty_params.map |ty_param| {
bounds: ~[(&'self str, ~[Path<'self>])]
}
-pub impl<'self> LifetimeBounds<'self> {
- fn empty() -> LifetimeBounds<'static> {
+impl<'self> LifetimeBounds<'self> {
+ pub fn empty() -> LifetimeBounds<'static> {
LifetimeBounds {
lifetimes: ~[], bounds: ~[]
}
}
- fn to_generics(&self, cx: @ExtCtxt, span: span,
- self_ty: ident, self_generics: &Generics) -> Generics {
+ pub fn to_generics(&self,
+ cx: @ExtCtxt,
+ span: span,
+ self_ty: ident,
+ self_generics: &Generics)
+ -> Generics {
let lifetimes = do self.lifetimes.map |lt| {
cx.lifetime(span, cx.ident_of(*lt))
};
}
}
-pub impl direction {
- fn reverse(&self) -> direction {
+impl direction {
+ pub fn reverse(&self) -> direction {
match *self {
send => recv,
recv => send
// name, span, data, current state, next state
pub struct message(~str, span, ~[@ast::Ty], state, Option<next_state>);
-pub impl message {
- fn name(&mut self) -> ~str {
+impl message {
+ pub fn name(&mut self) -> ~str {
match *self {
message(ref id, _, _, _, _) => copy *id
}
}
- fn span(&mut self) -> span {
+ pub fn span(&mut self) -> span {
match *self {
message(_, span, _, _, _) => span
}
}
/// Return the type parameters actually used by this message
- fn get_generics(&self) -> ast::Generics {
+ pub fn get_generics(&self) -> ast::Generics {
match *self {
message(_, _, _, this, _) => copy this.generics
}
proto: protocol
}
-pub impl state_ {
- fn add_message(@self, name: ~str, span: span,
- data: ~[@ast::Ty], next: Option<next_state>) {
+impl state_ {
+ pub fn add_message(@self,
+ name: ~str,
+ span: span,
+ data: ~[@ast::Ty],
+ next: Option<next_state>) {
self.messages.push(message(name, span, data, self,
next));
}
- fn filename(&self) -> ~str {
+ pub fn filename(&self) -> ~str {
self.proto.filename()
}
- fn data_name(&self) -> ast::ident {
+ pub fn data_name(&self) -> ast::ident {
self.ident
}
/// Returns the type that is used for the messages.
- fn to_ty(&self, cx: @ExtCtxt) -> @ast::Ty {
+ pub fn to_ty(&self, cx: @ExtCtxt) -> @ast::Ty {
cx.ty_path
(path(~[cx.ident_of(self.name)],self.span).add_tys(
cx.ty_vars(&self.generics.ty_params)))
/// Iterate over the states that can be reached in one message
/// from this state.
- fn reachable(&self, f: &fn(state) -> bool) -> bool {
+ pub fn reachable(&self, f: &fn(state) -> bool) -> bool {
for self.messages.each |m| {
match *m {
message(_, _, _, _, Some(next_state { state: ref id, _ })) => {
bounded: Option<bool>,
}
-pub impl protocol_ {
+impl protocol_ {
/// Get a state.
- fn get_state(&self, name: &str) -> state {
+ pub fn get_state(&self, name: &str) -> state {
self.states.find(|i| name == i.name).get()
}
- fn get_state_by_id(&self, id: uint) -> state { self.states[id] }
+ pub fn get_state_by_id(&self, id: uint) -> state { self.states[id] }
- fn has_state(&self, name: &str) -> bool {
+ pub fn has_state(&self, name: &str) -> bool {
self.states.find(|i| name == i.name).is_some()
}
- fn filename(&self) -> ~str {
+ pub fn filename(&self) -> ~str {
~"proto://" + self.name
}
- fn num_states(&self) -> uint {
+ pub fn num_states(&self) -> uint {
let states = &mut *self.states;
states.len()
}
- fn has_ty_params(&self) -> bool {
+ pub fn has_ty_params(&self) -> bool {
for self.states.each |s| {
if s.generics.ty_params.len() > 0 {
return true;
}
false
}
- fn is_bounded(&self) -> bool {
+
+ pub fn is_bounded(&self) -> bool {
let bounded = self.bounded.get();
bounded
}
}
-pub impl protocol_ {
- fn add_state_poly(@mut self,
- name: ~str,
- ident: ast::ident,
- dir: direction,
- generics: ast::Generics)
- -> state {
+impl protocol_ {
+ pub fn add_state_poly(@mut self,
+ name: ~str,
+ ident: ast::ident,
+ dir: direction,
+ generics: ast::Generics)
+ -> state {
let messages = @mut ~[];
let states = &mut *self.states;
token::to_str(reader.interner(), token)
}
-pub impl Parser {
+impl Parser {
// convert a token to a string using self's reader
- fn token_to_str(&self, token: &token::Token) -> ~str {
+ pub fn token_to_str(&self, token: &token::Token) -> ~str {
token::to_str(self.reader.interner(), token)
}
// convert the current token to a string using self's reader
- fn this_token_to_str(&self) -> ~str {
+ pub fn this_token_to_str(&self) -> ~str {
self.token_to_str(self.token)
}
- fn unexpected_last(&self, t: &token::Token) -> ! {
+ pub fn unexpected_last(&self, t: &token::Token) -> ! {
self.span_fatal(
*self.last_span,
fmt!(
);
}
- fn unexpected(&self) -> ! {
+ pub fn unexpected(&self) -> ! {
self.fatal(
fmt!(
"unexpected token: `%s`",
// expect and consume the token t. Signal an error if
// the next token is not t.
- fn expect(&self, t: &token::Token) {
+ pub fn expect(&self, t: &token::Token) {
if *self.token == *t {
self.bump();
} else {
}
}
- fn parse_ident(&self) -> ast::ident {
+ pub fn parse_ident(&self) -> ast::ident {
self.check_strict_keywords();
self.check_reserved_keywords();
match *self.token {
}
}
- fn parse_path_list_ident(&self) -> ast::path_list_ident {
+ pub fn parse_path_list_ident(&self) -> ast::path_list_ident {
let lo = self.span.lo;
let ident = self.parse_ident();
let hi = self.last_span.hi;
// consume token 'tok' if it exists. Returns true if the given
// token was present, false otherwise.
- fn eat(&self, tok: &token::Token) -> bool {
+ pub fn eat(&self, tok: &token::Token) -> bool {
return if *self.token == *tok { self.bump(); true } else { false };
}
- fn is_keyword(&self, kw: keywords::Keyword) -> bool {
+ pub fn is_keyword(&self, kw: keywords::Keyword) -> bool {
token::is_keyword(kw, self.token)
}
// if the next token is the given keyword, eat it and return
// true. Otherwise, return false.
- fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
+ pub fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
let is_kw = match *self.token {
token::IDENT(sid, false) => kw.to_ident().repr == sid.repr,
_ => false
// if the given word is not a keyword, signal an error.
// if the next token is not the given word, signal an error.
// otherwise, eat it.
- fn expect_keyword(&self, kw: keywords::Keyword) {
+ pub fn expect_keyword(&self, kw: keywords::Keyword) {
if !self.eat_keyword(kw) {
self.fatal(
fmt!(
}
// signal an error if the given string is a strict keyword
- fn check_strict_keywords(&self) {
+ pub fn check_strict_keywords(&self) {
if token::is_strict_keyword(self.token) {
self.span_err(*self.last_span,
fmt!("found `%s` in ident position", self.this_token_to_str()));
}
// signal an error if the current token is a reserved keyword
- fn check_reserved_keywords(&self) {
+ pub fn check_reserved_keywords(&self) {
if token::is_reserved_keyword(self.token) {
self.fatal(fmt!("`%s` is a reserved keyword", self.this_token_to_str()));
}
// expect and consume a GT. if a >> is seen, replace it
// with a single > and continue. If a GT is not seen,
// signal an error.
- fn expect_gt(&self) {
+ pub fn expect_gt(&self) {
if *self.token == token::GT {
self.bump();
} else if *self.token == token::BINOP(token::SHR) {
// parse a sequence bracketed by '<' and '>', stopping
// before the '>'.
- fn parse_seq_to_before_gt<T: Copy>(
- &self,
- sep: Option<token::Token>,
- f: &fn(&Parser) -> T
- ) -> OptVec<T> {
+ pub fn parse_seq_to_before_gt<T: Copy>(&self,
+ sep: Option<token::Token>,
+ f: &fn(&Parser) -> T)
+ -> OptVec<T> {
let mut first = true;
let mut v = opt_vec::Empty;
while *self.token != token::GT
return v;
}
- fn parse_seq_to_gt<T: Copy>(
- &self,
- sep: Option<token::Token>,
- f: &fn(&Parser) -> T
- ) -> OptVec<T> {
+ pub fn parse_seq_to_gt<T: Copy>(&self,
+ sep: Option<token::Token>,
+ f: &fn(&Parser) -> T)
+ -> OptVec<T> {
let v = self.parse_seq_to_before_gt(sep, f);
self.expect_gt();
return v;
// parse a sequence, including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.
- fn parse_seq_to_end<T: Copy>(
- &self,
- ket: &token::Token,
- sep: SeqSep,
- f: &fn(&Parser) -> T
- ) -> ~[T] {
+ pub fn parse_seq_to_end<T: Copy>(&self,
+ ket: &token::Token,
+ sep: SeqSep,
+ f: &fn(&Parser) -> T)
+ -> ~[T] {
let val = self.parse_seq_to_before_end(ket, sep, f);
self.bump();
val
// parse a sequence, not including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.
- fn parse_seq_to_before_end<T: Copy>(
- &self,
- ket: &token::Token,
- sep: SeqSep,
- f: &fn(&Parser) -> T
- ) -> ~[T] {
+ pub fn parse_seq_to_before_end<T: Copy>(&self,
+ ket: &token::Token,
+ sep: SeqSep,
+ f: &fn(&Parser) -> T)
+ -> ~[T] {
let mut first: bool = true;
let mut v: ~[T] = ~[];
while *self.token != *ket {
// parse a sequence, including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.
- fn parse_unspanned_seq<T: Copy>(
- &self,
- bra: &token::Token,
- ket: &token::Token,
- sep: SeqSep,
- f: &fn(&Parser) -> T
- ) -> ~[T] {
+ pub fn parse_unspanned_seq<T: Copy>(&self,
+ bra: &token::Token,
+ ket: &token::Token,
+ sep: SeqSep,
+ f: &fn(&Parser) -> T)
+ -> ~[T] {
self.expect(bra);
let result = self.parse_seq_to_before_end(ket, sep, f);
self.bump();
// NB: Do not use this function unless you actually plan to place the
// spanned list in the AST.
- fn parse_seq<T: Copy>(
- &self,
- bra: &token::Token,
- ket: &token::Token,
- sep: SeqSep,
- f: &fn(&Parser) -> T
- ) -> spanned<~[T]> {
+ pub fn parse_seq<T: Copy>(&self,
+ bra: &token::Token,
+ ket: &token::Token,
+ sep: SeqSep,
+ f: &fn(&Parser) -> T)
+ -> spanned<~[T]> {
let lo = self.span.lo;
self.expect(bra);
let result = self.parse_seq_to_before_end(ket, sep, f);
}
}
-pub impl Parser {
+impl Parser {
/// Reports an obsolete syntax non-fatal error.
- fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
+ pub fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
let (kind_str, desc) = match kind {
ObsoleteLowerCaseKindBounds => (
"lower-case kind bounds",
// Reports an obsolete syntax non-fatal error, and returns
// a placeholder expression
- fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr {
+ pub fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr {
self.obsolete(sp, kind);
self.mk_expr(sp.lo, sp.hi, expr_lit(@respan(sp, lit_nil)))
}
- priv fn report(&self, sp: span, kind: ObsoleteSyntax, kind_str: &str,
- desc: &str) {
+ fn report(&self,
+ sp: span,
+ kind: ObsoleteSyntax,
+ kind_str: &str,
+ desc: &str) {
self.span_err(sp, fmt!("obsolete syntax: %s", kind_str));
if !self.obsolete_set.contains(&kind) {
}
}
- fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool {
+ pub fn token_is_obsolete_ident(&self, ident: &str, token: &Token)
+ -> bool {
match *token {
token::IDENT(sid, _) => {
str::eq_slice(*self.id_to_str(sid), ident)
}
}
- fn is_obsolete_ident(&self, ident: &str) -> bool {
+ pub fn is_obsolete_ident(&self, ident: &str) -> bool {
self.token_is_obsolete_ident(ident, self.token)
}
- fn eat_obsolete_ident(&self, ident: &str) -> bool {
+ pub fn eat_obsolete_ident(&self, ident: &str) -> bool {
if self.is_obsolete_ident(ident) {
self.bump();
true
}
}
- fn try_parse_obsolete_struct_ctor(&self) -> bool {
+ pub fn try_parse_obsolete_struct_ctor(&self) -> bool {
if self.eat_obsolete_ident("new") {
self.obsolete(*self.last_span, ObsoleteStructCtor);
self.parse_fn_decl();
}
}
- fn try_parse_obsolete_with(&self) -> bool {
+ pub fn try_parse_obsolete_with(&self) -> bool {
if *self.token == token::COMMA
&& self.token_is_obsolete_ident("with",
&self.look_ahead(1u)) {
}
}
- fn try_parse_obsolete_priv_section(&self, attrs: &[attribute]) -> bool {
+ pub fn try_parse_obsolete_priv_section(&self, attrs: &[attribute])
+ -> bool {
if self.is_keyword(keywords::Priv) && self.look_ahead(1) == token::LBRACE {
self.obsolete(copy *self.span, ObsoletePrivSection);
self.eat_keyword(keywords::Priv);
fn finalize(&self) {}
}
-pub impl Parser {
+impl Parser {
// advance the parser by one token
- fn bump(&self) {
+ pub fn bump(&self) {
*self.last_span = copy *self.span;
let next = if *self.buffer_start == *self.buffer_end {
self.reader.next_token()
*self.tokens_consumed += 1u;
}
// EFFECT: replace the current token and span with the given one
- fn replace_token(&self, next: token::Token, lo: BytePos, hi: BytePos) {
+ pub fn replace_token(&self,
+ next: token::Token,
+ lo: BytePos,
+ hi: BytePos) {
*self.token = next;
*self.span = mk_sp(lo, hi);
}
- fn buffer_length(&self) -> int {
+ pub fn buffer_length(&self) -> int {
if *self.buffer_start <= *self.buffer_end {
return *self.buffer_end - *self.buffer_start;
}
return (4 - *self.buffer_start) + *self.buffer_end;
}
- fn look_ahead(&self, distance: uint) -> token::Token {
+ pub fn look_ahead(&self, distance: uint) -> token::Token {
let dist = distance as int;
while self.buffer_length() < dist {
self.buffer[*self.buffer_end] = self.reader.next_token();
}
return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok;
}
- fn fatal(&self, m: &str) -> ! {
+ pub fn fatal(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(*copy self.span, m)
}
- fn span_fatal(&self, sp: span, m: &str) -> ! {
+ pub fn span_fatal(&self, sp: span, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(sp, m)
}
- fn span_note(&self, sp: span, m: &str) {
+ pub fn span_note(&self, sp: span, m: &str) {
self.sess.span_diagnostic.span_note(sp, m)
}
- fn bug(&self, m: &str) -> ! {
+ pub fn bug(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(*copy self.span, m)
}
- fn warn(&self, m: &str) {
+ pub fn warn(&self, m: &str) {
self.sess.span_diagnostic.span_warn(*copy self.span, m)
}
- fn span_err(&self, sp: span, m: &str) {
+ pub fn span_err(&self, sp: span, m: &str) {
self.sess.span_diagnostic.span_err(sp, m)
}
- fn abort_if_errors(&self) {
+ pub fn abort_if_errors(&self) {
self.sess.span_diagnostic.handler().abort_if_errors();
}
- fn get_id(&self) -> node_id { next_node_id(self.sess) }
+ pub fn get_id(&self) -> node_id { next_node_id(self.sess) }
- fn id_to_str(&self, id: ident) -> @~str {
+ pub fn id_to_str(&self, id: ident) -> @~str {
self.sess.interner.get(id)
}
// is this one of the keywords that signals a closure type?
- fn token_is_closure_keyword(&self, tok: &token::Token) -> bool {
+ pub fn token_is_closure_keyword(&self, tok: &token::Token) -> bool {
token::is_keyword(keywords::Pure, tok) ||
token::is_keyword(keywords::Unsafe, tok) ||
token::is_keyword(keywords::Once, tok) ||
token::is_keyword(keywords::Fn, tok)
}
- fn token_is_lifetime(&self, tok: &token::Token) -> bool {
+ pub fn token_is_lifetime(&self, tok: &token::Token) -> bool {
match *tok {
token::LIFETIME(*) => true,
_ => false,
}
}
- fn get_lifetime(&self, tok: &token::Token) -> ast::ident {
+ pub fn get_lifetime(&self, tok: &token::Token) -> ast::ident {
match *tok {
token::LIFETIME(ref ident) => copy *ident,
_ => self.bug("not a lifetime"),
}
// parse a ty_bare_fun type:
- fn parse_ty_bare_fn(&self) -> ty_
- {
+ pub fn parse_ty_bare_fn(&self) -> ty_ {
/*
extern "ABI" [pure|unsafe] fn <'lt> (S) -> T
}
// parse a ty_closure type
- fn parse_ty_closure(&self,
- sigil: ast::Sigil,
- region: Option<@ast::Lifetime>)
- -> ty_ {
+ pub fn parse_ty_closure(&self,
+ sigil: ast::Sigil,
+ region: Option<@ast::Lifetime>)
+ -> ty_ {
/*
(&|~|@) ['r] [pure|unsafe] [once] fn [:Bounds] <'lt> (S) -> T
}
// looks like this should be called parse_unsafety
- fn parse_unsafety(&self) -> purity {
+ pub fn parse_unsafety(&self) -> purity {
if self.eat_keyword(keywords::Pure) {
self.obsolete(*self.last_span, ObsoletePurity);
return impure_fn;
}
// parse a function type (following the 'fn')
- fn parse_ty_fn_decl(&self) -> (fn_decl, OptVec<ast::Lifetime>) {
+ pub fn parse_ty_fn_decl(&self) -> (fn_decl, OptVec<ast::Lifetime>) {
/*
(fn) <'lt> (S) -> T
}
// parse the methods in a trait declaration
- fn parse_trait_methods(&self) -> ~[trait_method] {
+ pub fn parse_trait_methods(&self) -> ~[trait_method] {
do self.parse_unspanned_seq(
&token::LBRACE,
&token::RBRACE,
}
}
-
// parse a possibly mutable type
- fn parse_mt(&self) -> mt {
+ pub fn parse_mt(&self) -> mt {
let mutbl = self.parse_mutability();
let t = self.parse_ty(false);
mt { ty: t, mutbl: mutbl }
// parse [mut/const/imm] ID : TY
// now used only by obsolete record syntax parser...
- fn parse_ty_field(&self) -> ty_field {
+ pub fn parse_ty_field(&self) -> ty_field {
let lo = self.span.lo;
let mutbl = self.parse_mutability();
let id = self.parse_ident();
}
// parse optional return type [ -> TY ] in function decl
- fn parse_ret_ty(&self) -> (ret_style, @Ty) {
+ pub fn parse_ret_ty(&self) -> (ret_style, @Ty) {
return if self.eat(&token::RARROW) {
let lo = self.span.lo;
if self.eat(&token::NOT) {
// parse a type.
// Useless second parameter for compatibility with quasiquote macros.
// Bleh!
- fn parse_ty(&self, _: bool) -> @Ty {
+ pub fn parse_ty(&self, _: bool) -> @Ty {
maybe_whole!(self, nt_ty);
let lo = self.span.lo;
}
// parse the type following a @ or a ~
- fn parse_box_or_uniq_pointee(
- &self,
- sigil: ast::Sigil,
- ctor: &fn(v: mt) -> ty_) -> ty_
- {
+ pub fn parse_box_or_uniq_pointee(&self,
+ sigil: ast::Sigil,
+ ctor: &fn(v: mt) -> ty_) -> ty_ {
// @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types:
match *self.token {
token::LIFETIME(*) => {
ctor(mt)
}
- fn parse_borrowed_pointee(&self) -> ty_ {
+ pub fn parse_borrowed_pointee(&self) -> ty_ {
// look for `&'lt` or `&'foo ` and interpret `foo` as the region name:
let opt_lifetime = self.parse_opt_lifetime();
}
// parse an optional, obsolete argument mode.
- fn parse_arg_mode(&self) {
+ pub fn parse_arg_mode(&self) {
if self.eat(&token::BINOP(token::MINUS)) {
self.obsolete(*self.span, ObsoleteMode);
} else if self.eat(&token::ANDAND) {
}
}
- fn is_named_argument(&self) -> bool {
+ pub fn is_named_argument(&self) -> bool {
let offset = if *self.token == token::BINOP(token::AND) {
1
} else if *self.token == token::BINOP(token::MINUS) {
// This version of parse arg doesn't necessarily require
// identifier names.
- fn parse_arg_general(&self, require_name: bool) -> arg {
+ pub fn parse_arg_general(&self, require_name: bool) -> arg {
let mut is_mutbl = false;
let pat = if require_name || self.is_named_argument() {
self.parse_arg_mode();
}
// parse a single function argument
- fn parse_arg(&self) -> arg_or_capture_item {
+ pub fn parse_arg(&self) -> arg_or_capture_item {
either::Left(self.parse_arg_general(true))
}
// parse an argument in a lambda header e.g. |arg, arg|
- fn parse_fn_block_arg(&self) -> arg_or_capture_item {
+ pub fn parse_fn_block_arg(&self) -> arg_or_capture_item {
self.parse_arg_mode();
let is_mutbl = self.eat_keyword(keywords::Mut);
let pat = self.parse_pat();
})
}
- fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> {
+ pub fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> {
if self.eat(&token::BINOP(token::STAR)) {
self.obsolete(*self.last_span, ObsoleteFixedLengthVectorType);
Some(self.parse_expr())
}
// matches token_lit = LIT_INT | ...
- fn lit_from_token(&self, tok: &token::Token) -> lit_ {
+ pub fn lit_from_token(&self, tok: &token::Token) -> lit_ {
match *tok {
token::LIT_INT(i, it) => lit_int(i, it),
token::LIT_UINT(u, ut) => lit_uint(u, ut),
}
// matches lit = true | false | token_lit
- fn parse_lit(&self) -> lit {
+ pub fn parse_lit(&self) -> lit {
let lo = self.span.lo;
let lit = if self.eat_keyword(keywords::True) {
lit_bool(true)
}
// matches '-' lit | lit
- fn parse_literal_maybe_minus(&self) -> @expr {
+ pub fn parse_literal_maybe_minus(&self) -> @expr {
let minus_lo = self.span.lo;
let minus_present = self.eat(&token::BINOP(token::MINUS));
// parse a path into a vector of idents, whether the path starts
// with ::, and a span.
- fn parse_path(&self) -> (~[ast::ident],bool,span) {
+ pub fn parse_path(&self) -> (~[ast::ident],bool,span) {
let lo = self.span.lo;
let is_global = self.eat(&token::MOD_SEP);
let (ids,span{lo:_,hi,expn_info}) = self.parse_path_non_global();
}
// parse a path beginning with an identifier into a vector of idents and a span
- fn parse_path_non_global(&self) -> (~[ast::ident],span) {
+ pub fn parse_path_non_global(&self) -> (~[ast::ident],span) {
let lo = self.span.lo;
let mut ids = ~[];
// must be at least one to begin:
}
// parse a path that doesn't have type parameters attached
- fn parse_path_without_tps(&self)
- -> @ast::Path {
+ pub fn parse_path_without_tps(&self) -> @ast::Path {
maybe_whole!(self, nt_path);
let (ids,is_global,sp) = self.parse_path();
@ast::Path { span: sp,
// parse a path optionally with type parameters. If 'colons'
// is true, then type parameters must be preceded by colons,
// as in a::t::<t1,t2>
- fn parse_path_with_tps(&self, colons: bool) -> @ast::Path {
+ pub fn parse_path_with_tps(&self, colons: bool) -> @ast::Path {
debug!("parse_path_with_tps(colons=%b)", colons);
maybe_whole!(self, nt_path);
}
/// parses 0 or 1 lifetime
- fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> {
+ pub fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> {
match *self.token {
token::LIFETIME(*) => {
Some(@self.parse_lifetime())
}
}
- fn token_is_lifetime(&self, tok: &token::Token) -> bool {
+ pub fn token_is_lifetime(&self, tok: &token::Token) -> bool {
match *tok {
token::LIFETIME(_) => true,
_ => false
/// Parses a single lifetime
// matches lifetime = ( LIFETIME ) | ( IDENT / )
- fn parse_lifetime(&self) -> ast::Lifetime {
+ pub fn parse_lifetime(&self) -> ast::Lifetime {
match *self.token {
token::LIFETIME(i) => {
let span = copy self.span;
// matches lifetimes = ( lifetime ) | ( lifetime , lifetimes )
// actually, it matches the empty one too, but putting that in there
// messes up the grammar....
- fn parse_lifetimes(&self) -> OptVec<ast::Lifetime> {
+ pub fn parse_lifetimes(&self) -> OptVec<ast::Lifetime> {
/*!
*
* Parses zero or more comma separated lifetimes.
}
}
- fn token_is_mutability(&self, tok: &token::Token) -> bool {
+ pub fn token_is_mutability(&self, tok: &token::Token) -> bool {
token::is_keyword(keywords::Mut, tok) ||
token::is_keyword(keywords::Const, tok)
}
// parse mutability declaration (mut/const/imm)
- fn parse_mutability(&self) -> mutability {
+ pub fn parse_mutability(&self) -> mutability {
if self.eat_keyword(keywords::Mut) {
m_mutbl
} else if self.eat_keyword(keywords::Const) {
}
// parse ident COLON expr
- fn parse_field(&self) -> field {
+ pub fn parse_field(&self) -> field {
let lo = self.span.lo;
let i = self.parse_ident();
self.expect(&token::COLON);
})
}
- fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {
+ pub fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {
@expr {
id: self.get_id(),
callee_id: self.get_id(),
}
}
- fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @expr {
+ pub fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @expr {
@expr {
id: self.get_id(),
callee_id: self.get_id(),
}
}
- fn mk_lit_u32(&self, i: u32) -> @expr {
+ pub fn mk_lit_u32(&self, i: u32) -> @expr {
let span = self.span;
let lv_lit = @codemap::spanned {
node: lit_uint(i as u64, ty_u32),
// at the bottom (top?) of the precedence hierarchy,
// parse things like parenthesized exprs,
// macros, return, etc.
- fn parse_bottom_expr(&self) -> @expr {
+ pub fn parse_bottom_expr(&self) -> @expr {
maybe_whole_expr!(self);
let lo = self.span.lo;
}
// parse a block or unsafe block
- fn parse_block_expr(
- &self,
- lo: BytePos,
- blk_mode: blk_check_mode
- ) -> @expr {
+ pub fn parse_block_expr(&self, lo: BytePos, blk_mode: blk_check_mode)
+ -> @expr {
self.expect(&token::LBRACE);
let blk = self.parse_block_tail(lo, blk_mode);
return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk));
}
// parse a.b or a(13) or a[4] or just a
- fn parse_dot_or_call_expr(&self) -> @expr {
+ pub fn parse_dot_or_call_expr(&self) -> @expr {
let b = self.parse_bottom_expr();
self.parse_dot_or_call_expr_with(b)
}
- fn parse_dot_or_call_expr_with(&self, e0: @expr) -> @expr {
+ pub fn parse_dot_or_call_expr_with(&self, e0: @expr) -> @expr {
let mut e = e0;
let lo = e.span.lo;
let mut hi;
// parse an optional separator followed by a kleene-style
// repetition token (+ or *).
- fn parse_sep_and_zerok(&self) -> (Option<token::Token>, bool) {
+ pub fn parse_sep_and_zerok(&self) -> (Option<token::Token>, bool) {
if *self.token == token::BINOP(token::STAR)
|| *self.token == token::BINOP(token::PLUS) {
let zerok = *self.token == token::BINOP(token::STAR);
}
// parse a single token tree from the input.
- fn parse_token_tree(&self) -> token_tree {
+ pub fn parse_token_tree(&self) -> token_tree {
maybe_whole!(deref self, nt_tt);
// this is the fall-through for the 'match' below.
// parse a stream of tokens into a list of token_trees,
// up to EOF.
- fn parse_all_token_trees(&self) -> ~[token_tree] {
+ pub fn parse_all_token_trees(&self) -> ~[token_tree] {
let mut tts = ~[];
while *self.token != token::EOF {
tts.push(self.parse_token_tree());
tts
}
- fn parse_matchers(&self) -> ~[matcher] {
+ pub fn parse_matchers(&self) -> ~[matcher] {
// unification of matchers and token_trees would vastly improve
// the interpolation of matchers
maybe_whole!(self, nt_matchers);
// This goofy function is necessary to correctly match parens in matchers.
// Otherwise, `$( ( )` would be a valid matcher, and `$( () )` would be
// invalid. It's similar to common::parse_seq.
- fn parse_matcher_subseq(
- &self,
- name_idx: @mut uint,
- bra: token::Token,
- ket: token::Token
- ) -> ~[matcher] {
+ pub fn parse_matcher_subseq(&self,
+ name_idx: @mut uint,
+ bra: token::Token,
+ ket: token::Token)
+ -> ~[matcher] {
let mut ret_val = ~[];
let mut lparens = 0u;
return ret_val;
}
- fn parse_matcher(&self, name_idx: @mut uint) -> matcher {
+ pub fn parse_matcher(&self, name_idx: @mut uint) -> matcher {
let lo = self.span.lo;
let m = if *self.token == token::DOLLAR {
}
// parse a prefix-operator expr
- fn parse_prefix_expr(&self) -> @expr {
+ pub fn parse_prefix_expr(&self) -> @expr {
let lo = self.span.lo;
let hi;
}
// parse an expression of binops
- fn parse_binops(&self) -> @expr {
+ pub fn parse_binops(&self) -> @expr {
self.parse_more_binops(self.parse_prefix_expr(), 0)
}
// parse an expression of binops of at least min_prec precedence
- fn parse_more_binops(&self, lhs: @expr, min_prec: uint) ->
- @expr {
+ pub fn parse_more_binops(&self, lhs: @expr, min_prec: uint) -> @expr {
if self.expr_is_complete(lhs) { return lhs; }
let peeked = copy *self.token;
if peeked == token::BINOP(token::OR) &&
// parse an assignment expression....
// actually, this seems to be the main entry point for
// parsing an arbitrary expression.
- fn parse_assign_expr(&self) -> @expr {
+ pub fn parse_assign_expr(&self) -> @expr {
let lo = self.span.lo;
let lhs = self.parse_binops();
match *self.token {
}
// parse an 'if' expression ('if' token already eaten)
- fn parse_if_expr(&self) -> @expr {
+ pub fn parse_if_expr(&self) -> @expr {
let lo = self.last_span.lo;
let cond = self.parse_expr();
let thn = self.parse_block();
}
// `|args| { ... }` or `{ ...}` like in `do` expressions
- fn parse_lambda_block_expr(&self) -> @expr {
+ pub fn parse_lambda_block_expr(&self) -> @expr {
self.parse_lambda_expr_(
|| {
match *self.token {
}
// `|args| expr`
- fn parse_lambda_expr(&self) -> @expr {
+ pub fn parse_lambda_expr(&self) -> @expr {
self.parse_lambda_expr_(|| self.parse_fn_block_decl(),
|| self.parse_expr())
}
// parse something of the form |args| expr
// this is used both in parsing a lambda expr
// and in parsing a block expr as e.g. in for...
- fn parse_lambda_expr_(
- &self,
- parse_decl: &fn() -> fn_decl,
- parse_body: &fn() -> @expr
- ) -> @expr {
+ pub fn parse_lambda_expr_(&self,
+ parse_decl: &fn() -> fn_decl,
+ parse_body: &fn() -> @expr)
+ -> @expr {
let lo = self.last_span.lo;
let decl = parse_decl();
let body = parse_body();
expr_fn_block(decl, fakeblock));
}
- fn parse_else_expr(&self) -> @expr {
+ pub fn parse_else_expr(&self) -> @expr {
if self.eat_keyword(keywords::If) {
return self.parse_if_expr();
} else {
// parse a 'for' or 'do'.
// the 'for' and 'do' expressions parse as calls, but look like
// function calls followed by a closure expression.
- fn parse_sugary_call_expr(&self, keyword: ~str,
- sugar: CallSugar,
- ctor: &fn(v: @expr) -> expr_) -> @expr {
+ pub fn parse_sugary_call_expr(&self,
+ keyword: ~str,
+ sugar: CallSugar,
+ ctor: &fn(v: @expr) -> expr_)
+ -> @expr {
let lo = self.last_span;
// Parse the callee `foo` in
// for foo || {
}
}
- fn parse_while_expr(&self) -> @expr {
+ pub fn parse_while_expr(&self) -> @expr {
let lo = self.last_span.lo;
let cond = self.parse_expr();
let body = self.parse_block();
return self.mk_expr(lo, hi, expr_while(cond, body));
}
- fn parse_loop_expr(&self, opt_ident: Option<ast::ident>) -> @expr {
+ pub fn parse_loop_expr(&self, opt_ident: Option<ast::ident>) -> @expr {
// loop headers look like 'loop {' or 'loop unsafe {'
let is_loop_header =
*self.token == token::LBRACE
}
// parse an expression
- fn parse_expr(&self) -> @expr {
+ pub fn parse_expr(&self) -> @expr {
return self.parse_expr_res(UNRESTRICTED);
}
}
// parse a pattern.
- fn parse_pat(&self) -> @pat {
+ pub fn parse_pat(&self) -> @pat {
maybe_whole!(self, nt_pat);
let lo = self.span.lo;
// parse a statement. may include decl.
// precondition: any attributes are parsed already
- fn parse_stmt(&self, item_attrs: ~[attribute]) -> @stmt {
+ pub fn parse_stmt(&self, item_attrs: ~[attribute]) -> @stmt {
maybe_whole!(self, nt_stmt);
fn check_expected_item(p: &Parser, current_attrs: &[attribute]) {
}
// parse a block. No inner attrs are allowed.
- fn parse_block(&self) -> blk {
+ pub fn parse_block(&self) -> blk {
maybe_whole!(self, nt_block);
let lo = self.span.lo;
// matches generics = ( ) | ( < > ) | ( < typaramseq ( , )? > ) | ( < lifetimes ( , )? > )
// | ( < lifetimes , typaramseq ( , )? > )
// where typaramseq = ( typaram ) | ( typaram , typaramseq )
- fn parse_generics(&self) -> ast::Generics {
+ pub fn parse_generics(&self) -> ast::Generics {
if self.eat(&token::LT) {
let lifetimes = self.parse_lifetimes();
let ty_params = self.parse_seq_to_gt(
}
// parse the argument list and result type of a function declaration
- fn parse_fn_decl(&self)
- -> fn_decl
- {
+ pub fn parse_fn_decl(&self) -> fn_decl {
let args_or_capture_items: ~[arg_or_capture_item] =
self.parse_unspanned_seq(
&token::LPAREN,
}
// parse a structure field declaration
- fn parse_single_struct_field(&self,
- vis: visibility,
- attrs: ~[attribute]) -> @struct_field {
+ pub fn parse_single_struct_field(&self,
+ vis: visibility,
+ attrs: ~[attribute])
+ -> @struct_field {
if self.eat_obsolete_ident("let") {
self.obsolete(*self.last_span, ObsoleteLet);
}
return iovi_none;
}
- fn parse_item(&self, attrs: ~[attribute]) -> Option<@ast::item> {
+ pub fn parse_item(&self, attrs: ~[attribute]) -> Option<@ast::item> {
match self.parse_item_or_view_item(attrs, true) {
iovi_none =>
None,
// Parses a source module as a crate. This is the main
// entry point for the parser.
- fn parse_crate_mod(&self) -> @crate {
+ pub fn parse_crate_mod(&self) -> @crate {
let lo = self.span.lo;
// parse the crate's inner attrs, maybe (oops) one
// of the attrs of an item:
config: copy self.cfg })
}
- fn parse_str(&self) -> @~str {
+ pub fn parse_str(&self) -> @~str {
match *self.token {
token::LIT_STR(s) => {
self.bump();
priv interner: StrInterner,
}
-pub impl ident_interner {
- fn intern(&self, val: &str) -> ast::ident {
+impl ident_interner {
+ pub fn intern(&self, val: &str) -> ast::ident {
ast::ident { repr: self.interner.intern(val), ctxt: 0 }
}
- fn gensym(&self, val: &str) -> ast::ident {
+ pub fn gensym(&self, val: &str) -> ast::ident {
ast::ident { repr: self.interner.gensym(val), ctxt: 0 }
}
- fn get(&self, idx: ast::ident) -> @~str {
+ pub fn get(&self, idx: ast::ident) -> @~str {
self.interner.get(idx.repr)
}
- fn len(&self) -> uint {
+ pub fn len(&self) -> uint {
self.interner.len()
}
- fn find_equiv<Q:Hash + IterBytes + Equiv<@~str>>(&self, val: &Q)
- -> Option<ast::ident> {
+ pub fn find_equiv<Q:Hash +
+ IterBytes +
+ Equiv<@~str>>(&self, val: &Q) -> Option<ast::ident> {
match self.interner.find_equiv(val) {
Some(v) => Some(ast::ident { repr: v, ctxt: 0 }),
None => None,
Be,
}
- pub impl Keyword {
- fn to_ident(&self) -> ident {
+ impl Keyword {
+ pub fn to_ident(&self) -> ident {
match *self {
As => ident { repr: 35, ctxt: 0 },
Break => ident { repr: 36, ctxt: 0 },
EOF,
}
-pub impl token {
- fn is_eof(&self) -> bool {
+impl token {
+ pub fn is_eof(&self) -> bool {
match *self { EOF => true, _ => false }
}
- fn is_hardbreak_tok(&self) -> bool {
+
+ pub fn is_hardbreak_tok(&self) -> bool {
match *self {
BREAK(break_t {
offset: 0,
pending_indentation: int,
}
-pub impl Printer {
- fn last_token(&mut self) -> token { self.token[self.right] }
+impl Printer {
+ pub fn last_token(&mut self) -> token { self.token[self.right] }
// be very careful with this!
- fn replace_last_token(&mut self, t: token) { self.token[self.right] = t; }
- fn pretty_print(&mut self, t: token) {
+ pub fn replace_last_token(&mut self, t: token) {
+ self.token[self.right] = t;
+ }
+ pub fn pretty_print(&mut self, t: token) {
debug!("pp ~[%u,%u]", self.left, self.right);
match t {
EOF => {
}
}
}
- fn check_stream(&mut self) {
+ pub fn check_stream(&mut self) {
debug!("check_stream ~[%u, %u] with left_total=%d, right_total=%d",
self.left, self.right, self.left_total, self.right_total);
if self.right_total - self.left_total > self.space {
if self.left != self.right { self.check_stream(); }
}
}
- fn scan_push(&mut self, x: uint) {
+ pub fn scan_push(&mut self, x: uint) {
debug!("scan_push %u", x);
if self.scan_stack_empty {
self.scan_stack_empty = false;
}
self.scan_stack[self.top] = x;
}
- fn scan_pop(&mut self) -> uint {
+ pub fn scan_pop(&mut self) -> uint {
assert!((!self.scan_stack_empty));
let x = self.scan_stack[self.top];
if self.top == self.bottom {
} else { self.top += self.buf_len - 1u; self.top %= self.buf_len; }
return x;
}
- fn scan_top(&mut self) -> uint {
+ pub fn scan_top(&mut self) -> uint {
assert!((!self.scan_stack_empty));
return self.scan_stack[self.top];
}
- fn scan_pop_bottom(&mut self) -> uint {
+ pub fn scan_pop_bottom(&mut self) -> uint {
assert!((!self.scan_stack_empty));
let x = self.scan_stack[self.bottom];
if self.top == self.bottom {
} else { self.bottom += 1u; self.bottom %= self.buf_len; }
return x;
}
- fn advance_right(&mut self) {
+ pub fn advance_right(&mut self) {
self.right += 1u;
self.right %= self.buf_len;
assert!((self.right != self.left));
}
- fn advance_left(&mut self, x: token, L: int) {
+ pub fn advance_left(&mut self, x: token, L: int) {
debug!("advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right,
self.left, L);
if L >= 0 {
}
}
}
- fn check_stack(&mut self, k: int) {
+ pub fn check_stack(&mut self, k: int) {
if !self.scan_stack_empty {
let x = self.scan_top();
match copy self.token[x] {
}
}
}
- fn print_newline(&mut self, amount: int) {
+ pub fn print_newline(&mut self, amount: int) {
debug!("NEWLINE %d", amount);
(*self.out).write_str("\n");
self.pending_indentation = 0;
self.indent(amount);
}
- fn indent(&mut self, amount: int) {
+ pub fn indent(&mut self, amount: int) {
debug!("INDENT %d", amount);
self.pending_indentation += amount;
}
- fn get_top(&mut self) -> print_stack_elt {
+ pub fn get_top(&mut self) -> print_stack_elt {
let print_stack = &mut *self.print_stack;
let n = print_stack.len();
if n != 0u {
}
}
}
- fn print_str(&mut self, s: &str) {
+ pub fn print_str(&mut self, s: &str) {
while self.pending_indentation > 0 {
(*self.out).write_str(" ");
self.pending_indentation -= 1;
}
(*self.out).write_str(s);
}
- fn print(&mut self, x: token, L: int) {
+ pub fn print(&mut self, x: token, L: int) {
debug!("print %s %d (remaining line space=%d)", tok_str(x), L,
self.space);
debug!("%s", buf_str(copy self.token,
}
// when traits can extend traits, we should extend index<uint,T> to get []
-pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
- fn new() -> Interner<T> {
+impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
+ pub fn new() -> Interner<T> {
Interner {
map: @mut HashMap::new(),
vect: @mut ~[],
}
}
- fn prefill(init: &[T]) -> Interner<T> {
+ pub fn prefill(init: &[T]) -> Interner<T> {
let rv = Interner::new();
for init.each() |v| { rv.intern(*v); }
rv
}
- fn intern(&self, val: T) -> uint {
+ pub fn intern(&self, val: T) -> uint {
match self.map.find(&val) {
Some(&idx) => return idx,
None => (),
new_idx
}
- fn gensym(&self, val: T) -> uint {
+ pub fn gensym(&self, val: T) -> uint {
let new_idx = {
let vect = &*self.vect;
vect.len()
// this isn't "pure" in the traditional sense, because it can go from
// failing to returning a value as items are interned. But for typestate,
// where we first check a pred and then rely on it, ceasing to fail is ok.
- fn get(&self, idx: uint) -> T { self.vect[idx] }
+ pub fn get(&self, idx: uint) -> T { self.vect[idx] }
- fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
+ pub fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
- fn find_equiv<Q:Hash + IterBytes + Equiv<T>>(&self, val: &Q)
+ pub fn find_equiv<Q:Hash + IterBytes + Equiv<T>>(&self, val: &Q)
-> Option<uint> {
match self.map.find_equiv(val) {
Some(v) => Some(*v),
}
// when traits can extend traits, we should extend index<uint,T> to get []
-pub impl StrInterner {
- fn new() -> StrInterner {
+impl StrInterner {
+ pub fn new() -> StrInterner {
StrInterner {
map: @mut HashMap::new(),
vect: @mut ~[],
}
}
- fn prefill(init: &[&str]) -> StrInterner {
+ pub fn prefill(init: &[&str]) -> StrInterner {
let rv = StrInterner::new();
for init.each() |v| { rv.intern(*v); }
rv
}
- fn intern(&self, val: &str) -> uint {
+ pub fn intern(&self, val: &str) -> uint {
match self.map.find_equiv(&StringRef(val)) {
Some(&idx) => return idx,
None => (),
new_idx
}
- fn gensym(&self, val: &str) -> uint {
+ pub fn gensym(&self, val: &str) -> uint {
let new_idx = self.len();
// leave out of .map to avoid colliding
self.vect.push(@val.to_owned());
// this isn't "pure" in the traditional sense, because it can go from
// failing to returning a value as items are interned. But for typestate,
// where we first check a pred and then rely on it, ceasing to fail is ok.
- fn get(&self, idx: uint) -> @~str { self.vect[idx] }
+ pub fn get(&self, idx: uint) -> @~str { self.vect[idx] }
- fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
+ pub fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
- fn find_equiv<Q:Hash + IterBytes + Equiv<@~str>>(&self, val: &Q)
- -> Option<uint> {
+ pub fn find_equiv<Q:Hash + IterBytes + Equiv<@~str>>(&self, val: &Q)
+ -> Option<uint> {
match self.map.find_equiv(val) {
Some(v) => Some(*v),
None => None,
x: int
}
-pub impl Foo {
- fn new() -> Foo {
+impl Foo {
+ pub fn new() -> Foo {
Foo { x: 3 }
}
}
}
- pub impl cat {
- fn speak(&self) {}
+ impl cat {
+ pub fn speak(&self) {}
}
pub fn cat(in_x : uint, in_y : int) -> cat {
how_hungry : int,
}
- pub impl cat {
- fn speak(&mut self) { self.meows += 1u; }
- fn meow_count(&mut self) -> uint { self.meows }
+ impl cat {
+ pub fn speak(&mut self) { self.meows += 1u; }
+ pub fn meow_count(&mut self) -> uint { self.meows }
}
pub fn cat(in_x : uint, in_y : int) -> cat {
name : ~str,
}
- pub impl cat {
- fn speak(&mut self) { self.meow(); }
+ impl cat {
+ pub fn speak(&mut self) { self.meow(); }
- fn eat(&mut self) -> bool {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
}
}
- pub impl cat {
- fn meow(&mut self) {
+ impl cat {
+ pub fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
how_hungry : int,
}
- pub impl cat {
- priv fn nap(&self) { for uint::range(1, 10000u) |_i|{}}
+ impl cat {
+ priv fn nap(&self) { for uint::range(1, 10000u) |_i|{}}
}
pub fn cat(in_x : uint, in_y : int) -> cat {
how_hungry : int,
}
- pub impl<U> cat<U> {
- fn speak<T>(&mut self, stuff: ~[T]) {
+ impl<U> cat<U> {
+ pub fn speak<T>(&mut self, stuff: ~[T]) {
self.meows += stuff.len();
}
- fn meow_count(&mut self) -> uint { self.meows }
+
+ pub fn meow_count(&mut self) -> uint { self.meows }
}
pub fn cat<U>(in_x : uint, in_y : int, in_info: ~[U]) -> cat<U> {
fn to_str(&self) -> ~str { copy self.name }
}
- priv impl cat {
+ impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
}
- pub impl cat {
- fn speak(&mut self) { self.meow(); }
+ impl cat {
+ pub fn speak(&mut self) { self.meow(); }
- fn eat(&mut self) -> bool {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
x: int
}
-pub impl Fish {
- fn swim(&self) {}
+impl Fish {
+ pub fn swim(&self) {}
}
pub struct S(());
-pub impl S {
- fn foo(&self) { }
+impl S {
+ pub fn foo(&self) { }
}
pub trait T {
*result = (end - start);
}
-pub impl Results {
- fn bench_int<T:Set<uint>,
+impl Results {
+ pub fn bench_int<T:Set<uint>,
R: rand::Rng>(
&mut self,
rng: &mut R,
}
}
- fn bench_str<T:Set<~str>,
+ pub fn bench_str<T:Set<~str>,
R:rand::Rng>(
&mut self,
rng: &mut R,
permutations: [int, ..256],
}
-pub impl Noise2DContext {
- fn new() -> Noise2DContext {
+impl Noise2DContext {
+ pub fn new() -> Noise2DContext {
let mut r = rand::rng();
let mut rgradients = [ Vec2 { x: 0.0, y: 0.0 }, ..256 ];
for int::range(0, 256) |i| {
}
#[inline(always)]
- fn get_gradient(&self, x: int, y: int) -> Vec2 {
+ pub fn get_gradient(&self, x: int, y: int) -> Vec2 {
let idx = self.permutations[x & 255] + self.permutations[y & 255];
self.rgradients[idx & 255]
}
#[inline]
- fn get_gradients(&self,
- gradients: &mut [Vec2, ..4],
- origins: &mut [Vec2, ..4],
- x: f32,
- y: f32) {
+ pub fn get_gradients(&self,
+ gradients: &mut [Vec2, ..4],
+ origins: &mut [Vec2, ..4],
+ x: f32,
+ y: f32) {
let x0f = f32::floor(x);
let y0f = f32::floor(y);
let x0 = x0f as int;
}
#[inline]
- fn get(&self, x: f32, y: f32) -> f32 {
+ pub fn get(&self, x: f32, y: f32) -> f32 {
let p = Vec2 {x: x, y: y};
let mut gradients = [ Vec2 { x: 0.0, y: 0.0 }, ..4 ];
let mut origins = [ Vec2 { x: 0.0, y: 0.0 }, ..4 ];
grid: grid
}
-pub impl Sudoku {
+impl Sudoku {
pub fn new(g: grid) -> Sudoku {
return Sudoku { grid: g }
}
how_hungry : int,
}
-pub impl cat {
-
- fn speak(&self) { self.meows += 1u; }
+impl cat {
+ pub fn speak(&self) { self.meows += 1u; }
}
fn cat(in_x : uint, in_y : int) -> cat {
x: int
}
-pub impl Foo {
- fn printme(&mut self) {
+impl Foo {
+ pub fn printme(&mut self) {
io::println(fmt!("%d", self.x));
}
}
struct X(Either<(uint,uint),extern fn()>);
-pub impl X {
- fn with(&self, blk: &fn(x: &Either<(uint,uint),extern fn()>)) {
+impl X {
+ pub fn with(&self, blk: &fn(x: &Either<(uint,uint),extern fn()>)) {
blk(&**self)
}
}
+
fn main() {
let mut x = X(Right(main));
do (&mut x).with |opt| {
x: int,
}
-pub impl Foo {
- fn f(&self) {}
- fn g(&const self) {}
- fn h(&mut self) {}
+impl Foo {
+ pub fn f(&self) {}
+ pub fn g(&const self) {}
+ pub fn h(&mut self) {}
}
fn a(x: &mut Foo) {
n: HashSet<int>,
}
-pub impl Foo {
- fn foo(&mut self, fun: &fn(&int)) {
- for self.n.each |f| {
- fun(f);
+impl Foo {
+ pub fn foo(&mut self, fun: &fn(&int)) {
+ for self.n.each |f| {
+ fun(f);
+ }
}
- }
}
fn bar(f: &mut Foo) {
}
}
-pub impl Point {
- fn times(&self, z: int) -> int {
+impl Point {
+ pub fn times(&self, z: int) -> int {
self.x * self.y * z
}
}
name : ~str,
}
-pub impl cat {
-
- fn eat(&self) -> bool {
+impl cat {
+ pub fn eat(&self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
}
-priv impl cat {
+impl cat {
fn meow(&self) {
error!("Meow");
self.meows += 1;
priv meows : uint,
}
-priv impl cat {
+impl cat {
fn sleep(&self) { loop{} }
fn meow(&self) {
error!("Meow");
tail: int,
}
-pub impl cat {
- fn meow() { tail += 1; } //~ ERROR: Did you mean: `self.tail`
+impl cat {
+ pub fn meow() { tail += 1; } //~ ERROR: Did you mean: `self.tail`
}
use std::option;
use std::pipes;
- pub impl<T:Owned> Stream<T> {
+ impl<T:Owned> Stream<T> {
pub fn recv() -> extern fn(v: Stream<T>) -> ::stream::Stream<T> {
// resolve really should report just one error here.
// Change the test case when it changes.
v0: u64,
}
- pub impl siphash {
- fn reset(&mut self) {
+ impl siphash {
+ pub fn reset(&mut self) {
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
//~^ ERROR unresolved name `k0`.
}
// xfail-test
struct x(());
-pub impl x {
- unsafe fn with() { } // This should fail
+impl x {
+ pub unsafe fn with() { } // This should fail
}
fn main() {
member: uint
}
-pub impl Obj {
- fn boom() -> bool {
+impl Obj {
+ pub fn boom() -> bool {
return 1+1 == 2
}
- fn chirp(&self) {
+ pub fn chirp(&self) {
self.boom(); //~ ERROR `&Obj` does not implement any method in scope named `boom`
}
}
pub fn MyStruct () -> MyStruct {
MyStruct {priv_field: 4}
}
- pub impl MyStruct {
+ impl MyStruct {
priv fn happyfun(&self) {}
}
}
how_hungry : int,
}
-pub impl cat {
- fn eat(&self) {
+impl cat {
+ pub fn eat(&self) {
self.how_hungry -= 5; //~ ERROR cannot assign
}
x: int
}
- pub impl Foo {
+ impl Foo {
priv fn foo(&self) {}
}
}
how_hungry : int,
}
- pub impl cat {
+ impl cat {
priv fn nap(&self) { uint::range(1u, 10000u, |_i| false); }
}
cats_chased: uint,
}
-pub impl dog {
- fn chase_cat(&mut self) {
+impl dog {
+ pub fn chase_cat(&mut self) {
let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
*p += 1u;
}
- fn chase_cat_2(&mut self) {
+ pub fn chase_cat_2(&mut self) {
let p: &'blk mut uint = &mut self.cats_chased;
*p += 1u;
}
food: uint,
}
-pub impl dog {
- fn chase_cat(&mut self) {
+impl dog {
+ pub fn chase_cat(&mut self) {
for uint::range(0u, 10u) |_i| {
let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
*p = 3u;
Flag { name: name, desc: desc, max_count: 1, value: 0 }
}
- pub impl<'self> Flag<'self> {
- fn set_desc(self, s: &str) -> Flag<'self> {
+ impl<'self> Flag<'self> {
+ pub fn set_desc(self, s: &str) -> Flag<'self> {
Flag { //~ ERROR cannot infer an appropriate lifetime
name: self.name,
desc: s,
// except according to those terms.
// error-pattern: implement a trait or new type instead
-pub impl <T> Option<T> {
- fn foo(&self) { }
+impl<T> Option<T> {
+ pub fn foo(&self) { }
}
fn main() { }
fn finalize(&self) {}
}
-pub impl S {
- fn foo(self) -> int {
+impl S {
+ pub fn foo(self) -> int {
self.bar();
return self.x; //~ ERROR use of moved value: `self`
}
- fn bar(self) {}
+ pub fn bar(self) {}
}
fn main() {
x: ~int
}
-pub impl S {
- fn foo(self) -> int {
+impl S {
+ pub fn foo(self) -> int {
self.bar();
return *self.x; //~ ERROR use of moved value: `self`
}
- fn bar(self) {}
+ pub fn bar(self) {}
}
fn main() {
x: int
}
-pub impl Foo {
- fn new() -> Foo {
+impl Foo {
+ pub fn new() -> Foo {
Foo { x: 3 }
}
}
struct Foo(uint);
-pub impl Foo {
- fn len(&self) -> uint { **self }
+impl Foo {
+ pub fn len(&self) -> uint { **self }
}
pub fn main() {
x: int,
}
-pub impl Foo {
- fn f(&const self) {}
+impl Foo {
+ pub fn f(&const self) {}
}
fn g(x: &mut Foo) {
struct Foo {a: uint, b: uint}
-pub impl Foo {
- fn inc_a(&mut self, v: uint) { self.a += v; }
+impl Foo {
+ pub fn inc_a(&mut self, v: uint) { self.a += v; }
- fn next_b(&mut self) -> uint {
+ pub fn next_b(&mut self) -> uint {
let b = self.b;
self.b += 1;
b
spells: ~[&'static str]
}
-pub impl Wizard {
- fn cast(&mut self) {
+impl Wizard {
+ pub fn cast(&mut self) {
for self.spells.each |&spell| {
println(spell);
}
volume : @mut int,
}
-pub impl dog {
+impl dog {
priv fn bark(&self) -> int {
debug!("Woof %u %d", *self.barks, *self.volume);
*self.barks += 1u;
fn speak(&self) -> int { self.meow() as int }
}
-pub impl cat {
- fn meow_count(&self) -> uint { *self.meows }
+impl cat {
+ pub fn meow_count(&self) -> uint { *self.meows }
}
-priv impl cat {
+impl cat {
fn meow(&self) -> uint {
debug!("Meow");
*self.meows += 1u;
fn speak(&mut self) { self.meow(); }
}
-pub impl cat {
- fn eat(&mut self) -> bool {
+impl cat {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
}
}
-priv impl cat {
+impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
name: ~str,
}
- pub impl cat {
- fn get_name(&self) -> ~str { self.name.clone() }
+ impl cat {
+ pub fn get_name(&self) -> ~str { self.name.clone() }
}
pub fn cat(in_name: ~str) -> cat {
name : T,
}
-pub impl<T> cat<T> {
- fn speak(&mut self) { self.meow(); }
+impl<T> cat<T> {
+ pub fn speak(&mut self) { self.meow(); }
- fn eat(&mut self) -> bool {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
fn swap(&mut self, _k: int, _v: T) -> Option<T> { fail!() }
}
-pub impl<T> cat<T> {
- fn get<'a>(&'a self, k: &int) -> &'a T {
+impl<T> cat<T> {
+ pub fn get<'a>(&'a self, k: &int) -> &'a T {
match self.find(k) {
Some(v) => { v }
None => { fail!("epic fail"); }
}
}
- fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
+ pub fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
cat{meows: in_x, how_hungry: in_y, name: in_name }
}
}
-priv impl<T> cat<T> {
+impl<T> cat<T> {
fn meow(&mut self) {
self.meows += 1;
error!("Meow %d", self.meows);
name : ~str,
}
-pub impl cat {
- fn eat(&mut self) -> bool {
+impl cat {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
fn speak(&mut self) { self.meow(); }
}
-priv impl cat {
+impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
name : ~str,
}
-priv impl cat {
+impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
}
}
-pub impl cat {
- fn eat(&mut self) -> bool {
+impl cat {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
how_hungry : int,
}
-pub impl cat {
- fn speak(&mut self) { self.meows += 1u; }
- fn meow_count(&mut self) -> uint { self.meows }
+impl cat {
+ pub fn speak(&mut self) { self.meows += 1u; }
+ pub fn meow_count(&mut self) -> uint { self.meows }
}
fn cat(in_x: uint, in_y: int) -> cat {
how_hungry : int,
}
-pub impl<U> cat<U> {
- fn speak<T>(&mut self, stuff: ~[T]) {
+impl<U> cat<U> {
+ pub fn speak<T>(&mut self, stuff: ~[T]) {
self.meows += stuff.len();
}
- fn meow_count(&mut self) -> uint { self.meows }
+ pub fn meow_count(&mut self) -> uint { self.meows }
}
fn cat<U>(in_x : uint, in_y : int, in_info: ~[U]) -> cat<U> {
name : ~str,
}
-pub impl cat {
- fn speak(&mut self) { self.meow(); }
+impl cat {
+ pub fn speak(&mut self) { self.meow(); }
- fn eat(&mut self) -> bool {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
}
}
-priv impl cat {
+impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
how_hungry : int,
}
-pub impl<U> cat<U> {
- fn speak(&mut self) { self.meows += 1u; }
- fn meow_count(&mut self) -> uint { self.meows }
+impl<U> cat<U> {
+ pub fn speak(&mut self) { self.meows += 1u; }
+ pub fn meow_count(&mut self) -> uint { self.meows }
}
fn cat<U>(in_x : uint, in_y : int) -> cat<U> {
how_hungry : int,
}
-pub impl cat {
- fn speak(&mut self) {}
+impl cat {
+ pub fn speak(&mut self) {}
}
fn cat(in_x : uint, in_y : int) -> cat {
name : ~str,
}
-pub impl cat {
- fn speak(&mut self) { self.meow(); }
+impl cat {
+ pub fn speak(&mut self) { self.meow(); }
- fn eat(&mut self) -> bool {
+ pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
}
}
-priv impl cat {
+impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
speeches: uint
}
-pub impl SpeechMaker {
- fn how_many(&const self) -> uint { self.speeches }
+impl SpeechMaker {
+ pub fn how_many(&const self) -> uint { self.speeches }
}
fn foo(speaker: &const SpeechMaker) -> uint {
speeches: uint
}
-pub impl SpeechMaker {
- fn talk(&mut self) {
+impl SpeechMaker {
+ pub fn talk(&mut self) {
self.speeches += 1;
}
}
enum E { V, VV(int) }
static C: E = V;
-pub impl E {
- fn method(&self) {
+impl E {
+ pub fn method(&self) {
match *self {
V => {}
VV(*) => fail!()
x: uint
}
-pub impl Box {
- fn set_many(&mut self, xs: &[uint]) {
+impl Box {
+ pub fn set_many(&mut self, xs: &[uint]) {
for xs.each |x| { self.x = *x; }
}
- fn set_many2(@mut self, xs: &[uint]) {
+ pub fn set_many2(@mut self, xs: &[uint]) {
for xs.each |x| { self.x = *x; }
}
}
size: 0})
}
-pub impl<K,V> HashMap<K,V> {
- fn len(&mut self) -> uint {
+impl<K,V> HashMap<K,V> {
+ pub fn len(&mut self) -> uint {
self.size
}
}
}
}
-pub impl shape {
+impl shape {
// self is in the implicit self region
- fn select<'r, T>(&self, threshold: float,
- a: &'r T, b: &'r T) -> &'r T {
+ pub fn select<'r, T>(&self, threshold: float, a: &'r T, b: &'r T)
+ -> &'r T {
if compute_area(self) > threshold {a} else {b}
}
}
}
}
-pub impl thing {
- fn foo(@self) -> int { *self.x.a }
- fn bar(~self) -> int { *self.x.a }
- fn quux(&self) -> int { *self.x.a }
- fn baz<'a>(&'a self) -> &'a A { &self.x }
- fn spam(self) -> int { *self.x.a }
+impl thing {
+ pub fn foo(@self) -> int { *self.x.a }
+ pub fn bar(~self) -> int { *self.x.a }
+ pub fn quux(&self) -> int { *self.x.a }
+ pub fn baz<'a>(&'a self) -> &'a A { &self.x }
+ pub fn spam(self) -> int { *self.x.a }
}
trait Nus { fn f(&self); }
some_(T),
}
-pub impl<T> option_<T> {
- fn foo(&self) -> bool { true }
+impl<T> option_<T> {
+ pub fn foo(&self) -> bool { true }
}
enum option__ {
some__(int)
}
-pub impl option__ {
- fn foo(&self) -> bool { true }
+impl option__ {
+ pub fn foo(&self) -> bool { true }
}
pub fn main() {
x: A,
}
-pub impl<A:Copy> foo<A> {
- fn bar<B,C:clam<A>>(&self, c: C) -> B {
+impl<A:Copy> foo<A> {
+ pub fn bar<B,C:clam<A>>(&self, c: C) -> B {
fail!();
}
}
struct foo(int);
-pub impl foo {
- fn bar<B,C:clam<B>>(&self, c: C) -> B { fail!(); }
+impl foo {
+ pub fn bar<B,C:clam<B>>(&self, c: C) -> B { fail!(); }
}
pub fn main() { }
x: T,
}
-pub impl<T:Copy> c1<T> {
- fn f1(&self, x: int) {
+impl<T:Copy> c1<T> {
+ pub fn f1(&self, x: int) {
}
}
}
}
-pub impl<T:Copy> c1<T> {
- fn f2(&self, x: int) {
+impl<T:Copy> c1<T> {
+ pub fn f2(&self, x: int) {
}
}
x: T,
}
-pub impl<T:Copy> c1<T> {
- fn f1(&self, x: T) {}
+impl<T:Copy> c1<T> {
+ pub fn f1(&self, x: T) {}
}
fn c1<T:Copy>(x: T) -> c1<T> {
}
}
-pub impl<T:Copy> c1<T> {
- fn f2(&self, x: T) {}
+impl<T:Copy> c1<T> {
+ pub fn f2(&self, x: T) {}
}
fn finalize(&self) {}
}
-pub impl socket {
- fn set_identity(&self) {
+impl socket {
+ pub fn set_identity(&self) {
do closure {
setsockopt_bytes(self.sock.clone())
}
fontbuf: &'self ~[u8],
}
-pub impl<'self> font<'self> {
- fn buf(&self) -> &'self ~[u8] {
+impl<'self> font<'self> {
+ pub fn buf(&self) -> &'self ~[u8] {
self.fontbuf
}
}
}
}
- pub impl<T:Owned> send_packet<T> {
- fn unwrap(&mut self) -> *packet<T> {
+ impl<T:Owned> send_packet<T> {
+ pub fn unwrap(&mut self) -> *packet<T> {
util::replace(&mut self.p, None).unwrap()
}
}
}
}
- pub impl<T:Owned> recv_packet<T> {
- fn unwrap(&mut self) -> *packet<T> {
+ impl<T:Owned> recv_packet<T> {
+ pub fn unwrap(&mut self) -> *packet<T> {
util::replace(&mut self.p, None).unwrap()
}
}
x: 0
}
}
-pub impl thing { fn f(self) {} }
+
+impl thing {
+ pub fn f(self) {}
+}
pub fn main() {
let z = thing();
next: Option<@mut list<'self, T>>
}
-pub impl<'self, T> list<'self, T>{
- fn addEnd(&mut self, element: &'self T) {
+impl<'self, T> list<'self, T>{
+ pub fn addEnd(&mut self, element: &'self T) {
let newList = list {
element: element,
next: None
Rectangle(Point, Point)
}
-pub impl Shape {
+impl Shape {
pub fn area(&self, sh: Shape) -> float {
match sh {
Circle(_, size) => float::consts::pi * size * size,
struct Foo { x: int }
-pub impl Foo {
- fn stuff<'a>(&'a mut self) -> &'a mut Foo {
+impl Foo {
+ pub fn stuff<'a>(&'a mut self) -> &'a mut Foo {
return self;
}
}
err: ErrPrinter
}
-pub impl X {
- fn boom() {
+impl X {
+ pub fn boom() {
exit(self.err, "prog", "arg");
}
}
y: int,
}
-pub impl Foo {
- fn sum(&self) -> int {
+impl Foo {
+ pub fn sum(&self) -> int {
self.x + self.y
}
}
x: ~str
}
-pub impl S {
- fn foo(self) {
+impl S {
+ pub fn foo(self) {
self.bar();
}
- fn bar(self) {
+ pub fn bar(self) {
println(self.x);
}
}
i: int,
}
- pub impl b {
- fn do_stuff(&self) -> int { return 37; }
+ impl b {
+ pub fn do_stuff(&self) -> int { return 37; }
}
fn b(i:int) -> b {
how_hungry : int,
}
-pub impl cat {
- fn meow_count(&mut self) -> uint { self.meows }
+impl cat {
+ pub fn meow_count(&mut self) -> uint { self.meows }
}
fn cat(in_x : uint, in_y : int) -> cat {
how_hungry : int,
}
-pub impl cat {
- fn play(&mut self) {
+impl cat {
+ pub fn play(&mut self) {
self.meows += 1u;
self.nap();
}
}
-priv impl cat {
+impl cat {
fn nap(&mut self) { for uint::range(1u, 10u) |_i| { }}
}
struct ptr_visit_adaptor<V>(Inner<V>);
-pub impl<V:TyVisitor + movable_ptr> ptr_visit_adaptor<V> {
+impl<V:TyVisitor + movable_ptr> ptr_visit_adaptor<V> {
#[inline(always)]
- fn bump(&self, sz: uint) {
+ pub fn bump(&self, sz: uint) {
do self.inner.move_ptr() |p| {
((p as uint) + sz) as *c_void
};
}
#[inline(always)]
- fn align(&self, a: uint) {
+ pub fn align(&self, a: uint) {
do self.inner.move_ptr() |p| {
align(p as uint, a) as *c_void
};
}
#[inline(always)]
- fn align_to<T>(&self) {
+ pub fn align_to<T>(&self) {
self.align(sys::min_align_of::<T>());
}
#[inline(always)]
- fn bump_past<T>(&self) {
+ pub fn bump_past<T>(&self) {
self.bump(sys::size_of::<T>());
}
vals: ~[~str]
}
-pub impl my_visitor {
- fn get<T>(&self, f: &fn(T)) {
+impl my_visitor {
+ pub fn get<T>(&self, f: &fn(T)) {
unsafe {
f(*(self.ptr1 as *T));
}
}
- fn visit_inner(&self, inner: *TyDesc) -> bool {
+ pub fn visit_inner(&self, inner: *TyDesc) -> bool {
unsafe {
let u = my_visitor(**self);
let v = ptr_visit_adaptor::<my_visitor>(Inner {inner: u});
f: uint
}
-pub impl Foo {
- fn foo<'a>(&'a self) {}
+impl Foo {
+ pub fn foo<'a>(&'a self) {}
}
-pub fn main() {}
\ No newline at end of file
+pub fn main() {}
}
}
-pub impl shrinky_pointer {
- fn look_at(&self) -> int { return **(self.i); }
+impl shrinky_pointer {
+ pub fn look_at(&self) -> int { return **(self.i); }
}
fn shrinky_pointer(i: @@mut int) -> shrinky_pointer {