about summary refs log tree commit diff
path: root/src/comp/util
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-07-19 17:52:34 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2011-07-19 18:57:28 -0700
commitbd4aeef78bcc8e03ef9275e7652f91b936f5dec6 (patch)
treedebdaf33fc8968b764b2782ea05fdea5cd5e4ae3 /src/comp/util
parentda2a7e5bd25055de1573a7f862986522213ed1ca (diff)
Beginnings of support for constrained types
Programs with constrained types now parse and typecheck, but
typestate doesn't check them specially, so the one relevant test
case so far is XFAILed.

Also rewrote all of the constraint-related data structures in the
process (again), for some reason. I got rid of a superfluous
data structure in the context that was mapping front-end constraints
to resolved constraints, instead handling constraints in the same
way in which everything else gets resolved.
Diffstat (limited to 'src/comp/util')
-rw-r--r--src/comp/util/ppaux.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs
index c1fb0798c0e..da76e7822ae 100644
--- a/src/comp/util/ppaux.rs
+++ b/src/comp/util/ppaux.rs
@@ -9,6 +9,8 @@ import middle::ty::*;
 import metadata::encoder;
 import syntax::print::pp;
 import syntax::print::pprust;
+import syntax::print::pprust::path_to_str;
+import syntax::print::pprust::constr_args_to_str;
 import pp::word;
 import pp::eof;
 import pp::zerobreak;
@@ -46,7 +48,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
     }
     fn fn_to_str(&ctxt cx, ast::proto proto, option::t[ast::ident] ident,
                  &arg[] inputs, t output, ast::controlflow cf,
-                 &(@constr_def)[] constrs) -> str {
+                 &(@constr)[] constrs) -> str {
         auto s;
         alt (proto) {
             case (ast::proto_iter) { s = "iter"; }
@@ -154,21 +156,27 @@ fn ty_to_short_str(&ctxt cx, t typ) -> str {
     ret s;
 }
 
-fn constr_to_str(&@constr_def c) -> str {
-    ret ast::path_to_str(c.node.path) +
+fn constr_to_str(&@constr c) -> str {
+    ret path_to_str(c.node.path) +
         pprust::constr_args_to_str(pprust::uint_to_str, c.node.args);
 }
 
-fn constrs_str(&(@constr_def)[] constrs) -> str {
+fn constrs_str(&(@constr)[] constrs) -> str {
     auto s = "";
     auto colon = true;
-    for (@constr_def c in constrs) {
+    for (@constr c in constrs) {
         if (colon) { s += " : "; colon = false; } else { s += ", "; }
         s += constr_to_str(c);
     }
     ret s;
 }
 
+fn ty_constr_to_str[Q](&@ast::spanned[ast::constr_general_[ast::path,Q]]
+                       c) -> str {
+    ret path_to_str(c.node.path) +
+          constr_args_to_str[ast::path](path_to_str, c.node.args);
+}
+
 // Local Variables:
 // mode: rust
 // fill-column: 78;