提交 913f7bda 编写于 作者: B Brian Anderson

Modify pipec to not emit calls to some and none

上级 e1b11aaf
...@@ -97,6 +97,9 @@ ...@@ -97,6 +97,9 @@
export oneshot, chan_one, port_one; export oneshot, chan_one, port_one;
export recv_one, try_recv_one, send_one, try_send_one; export recv_one, try_recv_one, send_one, try_send_one;
// Functions used by the protocol compiler
export rt;
#[doc(hidden)] #[doc(hidden)]
const SPIN_COUNT: uint = 0; const SPIN_COUNT: uint = 0;
...@@ -1194,6 +1197,13 @@ fn try_send_one<T: send>(+chan: chan_one<T>, +data: T) ...@@ -1194,6 +1197,13 @@ fn try_send_one<T: send>(+chan: chan_one<T>, +data: T)
oneshot::client::try_send(chan, data).is_some() oneshot::client::try_send(chan, data).is_some()
} }
mod rt {
// These are used to hide the option constructors from the
// compiler because their names are changing
fn make_some<T>(+val: T) -> option<T> { some(val) }
fn make_none<T>() -> option<T> { none }
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#[test] #[test]
......
...@@ -104,8 +104,8 @@ fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item { ...@@ -104,8 +104,8 @@ fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item {
} }
else { else {
body += fmt!("if pipes::send(pipe, message) {\n \ body += fmt!("if pipes::send(pipe, message) {\n \
some(c) \ pipes::rt::make_some(c) \
} else { none } }"); } else { pipes::rt::make_none() } }");
} }
let body = cx.parse_expr(body); let body = cx.parse_expr(body);
...@@ -163,8 +163,8 @@ fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item { ...@@ -163,8 +163,8 @@ fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item {
body += ~" }"; body += ~" }";
} else { } else {
body += fmt!("if pipes::send(pipe, message) { \ body += fmt!("if pipes::send(pipe, message) { \
some(()) \ pipes::rt::make_some(()) \
} else { none } }"); } else { pipes::rt::make_none() } }");
} }
let body = cx.parse_expr(body); let body = cx.parse_expr(body);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册