summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/pipes/liveness.rs3
-rw-r--r--src/libsyntax/ext/pipes/proto.rs46
2 files changed, 30 insertions, 19 deletions
diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs
index 4f803992520..d8467e36c84 100644
--- a/src/libsyntax/ext/pipes/liveness.rs
+++ b/src/libsyntax/ext/pipes/liveness.rs
@@ -84,8 +84,11 @@ fn analyze(proto: protocol, _cx: ext_ctxt) {
         //                    involving these states: %s",
         //                   *proto.name,
         //                   states));
+
+        proto.bounded = some(false);
     }
     else {
         #debug("protocol %s is bounded. yay!", *proto.name);
+        proto.bounded = some(true);
     }
 }
\ No newline at end of file
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> {