about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-01-03 18:22:39 -0800
committerGraydon Hoare <graydon@mozilla.com>2011-01-03 18:22:39 -0800
commit771d76e5520bb886624e4541ff3b74f2d6513bd6 (patch)
tree58a697ab7ce187de1270f6d0e005e3d009fd5084
parent0040a31076f750992ad903b2ae2b7a724808f028 (diff)
downloadrust-771d76e5520bb886624e4541ff3b74f2d6513bd6.tar.gz
rust-771d76e5520bb886624e4541ff3b74f2d6513bd6.zip
Add type accessors for fn types.
-rw-r--r--src/comp/middle/ty.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index d54f7436e00..12d174432f9 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -518,6 +518,29 @@ fn count_ty_params(@t ty) -> uint {
     ret _vec.len[ast.def_id](*param_ids);
 }
 
+// Type accessors for substructures of types
+
+fn ty_fn_args(@t fty) -> vec[arg] {
+  alt (fty.struct) {
+    case (ty.ty_fn(?a, _)) { ret a; }
+  }
+}
+
+fn ty_fn_ret(@t fty) -> @t {
+  alt (fty.struct) {
+    case (ty.ty_fn(_, ?r)) { ret r; }
+  }
+}
+
+fn is_fn_ty(@t fty) -> bool {
+  alt (fty.struct) {
+    case (ty.ty_fn(_, _)) { ret true; }
+    case (_) { ret false; }
+  }
+  ret false;
+}
+
+
 // Type accessors for AST nodes
 
 fn stmt_ty(@ast.stmt s) -> @t {
@@ -552,6 +575,7 @@ fn expr_ty(@ast.expr expr) -> @t {
         case (ast.expr_vec(_, ?ann))          { ret ann_to_type(ann); }
         case (ast.expr_tup(_, ?ann))          { ret ann_to_type(ann); }
         case (ast.expr_rec(_, ?ann))          { ret ann_to_type(ann); }
+        case (ast.expr_bind(_, _, ?ann))      { ret ann_to_type(ann); }
         case (ast.expr_call(_, _, ?ann))      { ret ann_to_type(ann); }
         case (ast.expr_binary(_, _, _, ?ann)) { ret ann_to_type(ann); }
         case (ast.expr_unary(_, _, ?ann))     { ret ann_to_type(ann); }