Modify pipec to not emit calls to some and none

This commit is contained in:
Brian Anderson 2012-08-15 16:22:40 -07:00
parent e1b11aaf4b
commit 913f7bdae7
2 changed files with 14 additions and 4 deletions

View File

@ -97,6 +97,9 @@ export stream, port, chan, shared_chan, port_set, channel;
export oneshot, chan_one, port_one;
export recv_one, try_recv_one, send_one, try_send_one;
// Functions used by the protocol compiler
export rt;
#[doc(hidden)]
const SPIN_COUNT: uint = 0;
@ -1194,6 +1197,13 @@ fn try_send_one<T: send>(+chan: chan_one<T>, +data: T)
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)]
mod test {
#[test]

View File

@ -104,8 +104,8 @@ impl message: gen_send {
}
else {
body += fmt!("if pipes::send(pipe, message) {\n \
some(c) \
} else { none } }");
pipes::rt::make_some(c) \
} else { pipes::rt::make_none() } }");
}
let body = cx.parse_expr(body);
@ -163,8 +163,8 @@ impl message: gen_send {
body += ~" }";
} else {
body += fmt!("if pipes::send(pipe, message) { \
some(()) \
} else { none } }");
pipes::rt::make_some(()) \
} else { pipes::rt::make_none() } }");
}
let body = cx.parse_expr(body);