Revert "librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc"

This reverts commit a8d37af247.
This commit is contained in:
Patrick Walton 2013-01-08 19:29:16 -08:00
parent a8d37af247
commit 44ab00ee37
250 changed files with 453 additions and 1342 deletions

View file

@ -45,9 +45,9 @@ trait word_reader {
fn read_word() -> Option<~str>;
}
// These used to be in task, but they disappeared.
pub type joinable_task = Port<()>;
pub fn spawn_joinable(+f: fn~()) -> joinable_task {
// These used to be in task, but they disappeard.
type joinable_task = Port<()>;
fn spawn_joinable(+f: fn~()) -> joinable_task {
let p = Port();
let c = Chan(&p);
do task::spawn() |move f| {
@ -57,7 +57,7 @@ pub fn spawn_joinable(+f: fn~()) -> joinable_task {
p
}
pub fn join(t: joinable_task) {
fn join(t: joinable_task) {
t.recv()
}
@ -90,11 +90,11 @@ fn reduce(word: &~str, get: map_reduce::getter<int>) {
io::println(fmt!("%s\t%?", *word, count));
}
pub struct box<T> {
struct box<T> {
mut contents: Option<T>,
}
pub impl<T> box<T> {
impl<T> box<T> {
fn swap(f: fn(+v: T) -> T) {
let mut tmp = None;
self.contents <-> tmp;
@ -108,16 +108,13 @@ pub impl<T> box<T> {
}
}
pub fn box<T>(+x: T) -> box<T> {
fn box<T>(+x: T) -> box<T> {
box {
contents: Some(move x)
}
}
mod map_reduce {
use core::oldcomm::*;
use std::map::HashMap;
use std::map;
pub type putter<K: Owned, V: Owned> = fn(&K, V);
@ -129,7 +126,7 @@ mod map_reduce {
pub type reducer<K: Copy Owned, V: Copy Owned> = fn~(&K, getter<V>);
enum ctrl_proto<K: Copy Owned, V: Copy Owned> {
find_reducer(K, Chan<Chan<::map_reduce::reduce_proto<V>>>),
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
mapper_done
}
@ -141,32 +138,26 @@ mod map_reduce {
}
reducer_response: recv<K: Copy Owned, V: Copy Owned> {
reducer(::core::oldcomm::Chan<::map_reduce::reduce_proto<V>>)
-> open<K, V>
reducer(Chan<reduce_proto<V>>) -> open<K, V>
}
)
pub enum reduce_proto<V: Copy Owned> {
emit_val(V),
done,
addref,
release
}
enum reduce_proto<V: Copy Owned> { emit_val(V), done, addref, release }
fn start_mappers<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned,
V: Copy Owned>(
map: &mapper<K1, K2, V>,
ctrls: &mut ~[ctrl_proto::server::open<K2, V>],
inputs: &~[K1])
-> ~[::joinable_task]
-> ~[joinable_task]
{
let mut tasks = ~[];
for inputs.each |i| {
let (ctrl, ctrl_server) = ctrl_proto::init();
let ctrl = ::box(move ctrl);
let ctrl = box(move ctrl);
let i = copy *i;
let m = copy *map;
tasks.push(::spawn_joinable(|move ctrl, move i| map_task(copy m, &ctrl, i)));
tasks.push(spawn_joinable(|move ctrl, move i| map_task(copy m, &ctrl, i)));
ctrls.push(move ctrl_server);
}
move tasks
@ -174,16 +165,16 @@ mod map_reduce {
fn map_task<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned, V: Copy Owned>(
map: mapper<K1, K2, V>,
ctrl: &::box<ctrl_proto::client::open<K2, V>>,
ctrl: &box<ctrl_proto::client::open<K2, V>>,
input: K1)
{
// log(error, "map_task " + input);
let intermediates: HashMap<K2, Chan<::map_reduce::reduce_proto<V>>>
let intermediates: HashMap<K2, Chan<reduce_proto<V>>>
= map::HashMap();
do map(input) |key: &K2, val| {
let mut c = None;
let found: Option<Chan<::map_reduce::reduce_proto<V>>>
let found: Option<Chan<reduce_proto<V>>>
= intermediates.find(*key);
match found {
Some(_c) => { c = Some(_c); }
@ -204,8 +195,7 @@ mod map_reduce {
send(c.get(), emit_val(val));
}
fn finish<K: Copy Owned, V: Copy Owned>(
_k: K, v: Chan<::map_reduce::reduce_proto<V>>)
fn finish<K: Copy Owned, V: Copy Owned>(_k: K, v: Chan<reduce_proto<V>>)
{
send(v, release);
}
@ -216,7 +206,7 @@ mod map_reduce {
fn reduce_task<K: Copy Owned, V: Copy Owned>(
reduce: ~reducer<K, V>,
key: K,
out: Chan<Chan<::map_reduce::reduce_proto<V>>>)
out: Chan<Chan<reduce_proto<V>>>)
{
let p = Port();
@ -225,7 +215,7 @@ mod map_reduce {
let mut ref_count = 0;
let mut is_done = false;
fn get<V: Copy Owned>(p: Port<::map_reduce::reduce_proto<V>>,
fn get<V: Copy Owned>(p: Port<reduce_proto<V>>,
ref_count: &mut int, is_done: &mut bool)
-> Option<V> {
while !*is_done || *ref_count > 0 {
@ -284,7 +274,7 @@ mod map_reduce {
let p = Port();
let ch = Chan(&p);
let r = copy reduce, kk = k;
tasks.push(::spawn_joinable(|move r|
tasks.push(spawn_joinable(|move r|
reduce_task(~copy r, kk, ch)
));
c = recv(p);
@ -300,7 +290,7 @@ mod map_reduce {
for reducers.each_value |v| { send(v, done) }
for tasks.each |t| { ::join(*t); }
for tasks.each |t| { join(*t); }
}
}