提交 7ad07162 编写于 作者: B Brian Anderson

rustc: Convert to pipes

上级 02e907b6
...@@ -357,24 +357,27 @@ fails without recording a fatal error then we've encountered a compiler ...@@ -357,24 +357,27 @@ fails without recording a fatal error then we've encountered a compiler
bug and need to present an error. bug and need to present an error.
*/ */
pub fn monitor(+f: fn~(diagnostic::emitter)) { pub fn monitor(+f: fn~(diagnostic::emitter)) {
let p = oldcomm::Port(); use core::pipes::*;
let ch = oldcomm::Chan(&p); use std::cell::Cell;
let (p, ch) = stream();
let ch = SharedChan(ch);
let ch_capture = ch.clone();
match do task::try |move f| { match do task::try |move f| {
let ch = ch_capture.clone();
let ch_capture = ch.clone();
// The 'diagnostics emitter'. Every error, warning, etc. should // The 'diagnostics emitter'. Every error, warning, etc. should
// go through this function. // go through this function.
let demitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>, let demitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>,
msg: &str, lvl: diagnostic::level) { msg: &str, lvl: diagnostic::level) {
if lvl == diagnostic::fatal { if lvl == diagnostic::fatal {
oldcomm::send(ch, fatal); ch_capture.send(fatal);
} }
diagnostic::emit(cmsp, msg, lvl); diagnostic::emit(cmsp, msg, lvl);
}; };
struct finally { struct finally {
ch: oldcomm::Chan<monitor_msg>, ch: SharedChan<monitor_msg>,
drop { oldcomm::send(self.ch, done); } drop { self.ch.send(done); }
} }
let _finally = finally { ch: ch }; let _finally = finally { ch: ch };
...@@ -384,7 +387,7 @@ pub fn monitor(+f: fn~(diagnostic::emitter)) { ...@@ -384,7 +387,7 @@ pub fn monitor(+f: fn~(diagnostic::emitter)) {
result::Ok(_) => { /* fallthrough */ } result::Ok(_) => { /* fallthrough */ }
result::Err(_) => { result::Err(_) => {
// Task failed without emitting a fatal diagnostic // Task failed without emitting a fatal diagnostic
if oldcomm::recv(p) == done { if p.recv() == done {
diagnostic::emit( diagnostic::emit(
None, None,
diagnostic::ice_msg(~"unexpected failure"), diagnostic::ice_msg(~"unexpected failure"),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册