diff options
Diffstat (limited to 'src/libsyntax/ext/pipes/proto.rs')
| -rw-r--r-- | src/libsyntax/ext/pipes/proto.rs | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index e9070c79b55..8a535e85188 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -98,23 +98,23 @@ impl methods for state { } } -enum protocol { - protocol_(@{ - name: ident, - states: dvec<state>, - }), -} +type protocol = @protocol_; -fn protocol(name: ident) -> protocol { - protocol_(@{name: name, states: dvec()}) -} +fn protocol(name: ident) -> protocol { @protocol_(name) } -impl methods for protocol { - fn add_state(name: ident, dir: direction) -> state { - self.add_state_poly(name, dir, ~[]) +class protocol_ { + let name: ident; + let states: dvec<state>; + + let mut bounded: option<bool>; + + new(name: ident) { + self.name = name; + self.states = dvec(); + self.bounded = none; } - /// Get or create a state. + /// Get a state. fn get_state(name: ident) -> state { self.states.find(|i| i.name == name).get() } @@ -125,6 +125,20 @@ impl methods for protocol { self.states.find(|i| i.name == name) != none } + fn filename() -> ~str { + ~"proto://" + *self.name + } + + fn num_states() -> uint { self.states.len() } + + fn is_bounded() -> bool { self.bounded.get() } +} + +impl methods for protocol { + fn add_state(name: ident, dir: direction) -> state { + self.add_state_poly(name, dir, ~[]) + } + fn add_state_poly(name: ident, dir: direction, +ty_params: ~[ast::ty_param]) -> state { let messages = dvec(); @@ -141,12 +155,6 @@ impl methods for protocol { self.states.push(state); state } - - fn filename() -> ~str { - ~"proto://" + *self.name - } - - fn num_states() -> uint { self.states.len() } } trait visitor<Tproto, Tstate, Tmessage> { |
