From 5eb6d19803ebcb5279f8a42b584a4d81152fa82d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 May 2013 18:33:33 -0400 Subject: syntax: Use the new `for` protocol --- src/libsyntax/ext/pipes/proto.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libsyntax/ext/pipes') diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 647c7741bd8..7c78ec066d0 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -100,6 +100,7 @@ pub impl state_ { /// Iterate over the states that can be reached in one message /// from this state. + #[cfg(stage0)] fn reachable(&self, f: &fn(state) -> bool) { for self.messages.each |m| { match *m { @@ -111,6 +112,21 @@ pub impl state_ { } } } + /// Iterate over the states that can be reached in one message + /// from this state. + #[cfg(not(stage0))] + fn reachable(&self, f: &fn(state) -> bool) -> bool { + for self.messages.each |m| { + match *m { + message(_, _, _, _, Some(next_state { state: ref id, _ })) => { + let state = self.proto.get_state((*id)); + if !f(state) { return false; } + } + _ => () + } + } + return true; + } } pub type protocol = @mut protocol_; -- cgit 1.4.1-3-g733a5