about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorBrian Anderson <andersrb@gmail.com>2011-05-02 20:29:39 -0400
committerBrian Anderson <andersrb@gmail.com>2011-05-02 22:07:36 -0400
commited40c85af5c6eec82746696d3ce2d0e7ae22c1d4 (patch)
tree787c5ee833fe2604c7914a60e6b5b2f43abf382b /src/comp
parent3014a5887d4785285a3f42e19f2de24e141e3eb8 (diff)
downloadrust-ed40c85af5c6eec82746696d3ce2d0e7ae22c1d4.tar.gz
rust-ed40c85af5c6eec82746696d3ce2d0e7ae22c1d4.zip
Extract ast.is_exported from the resolve module
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/front/ast.rs22
-rw-r--r--src/comp/middle/resolve.rs19
2 files changed, 23 insertions, 18 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 13b5739e8df..82b6d81303f 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -1,6 +1,7 @@
 
 import std.map.hashmap;
 import std.option;
+import std._str;
 import std._vec;
 import util.common.span;
 import util.common.spanned;
@@ -529,6 +530,27 @@ fn index_stmt(block_index index, @stmt s) {
     }
 }
 
+fn is_exported(ident i, _mod m) -> bool {
+    auto count = 0;
+    for (@ast.view_item vi in m.view_items) {
+        alt (vi.node) {
+            case (ast.view_item_export(?id)) {
+                if (_str.eq(i, id)) {
+                    ret true;
+                }
+                count += 1;
+            }
+            case (_) { /* fall through */ }
+        }
+    }
+    // If there are no declared exports then everything is exported
+    if (count == 0) {
+        ret true;
+    } else {
+        ret false;
+    }
+}
+
 fn is_call_expr(@expr e) -> bool {
     alt (e.node) {
         case (expr_call(_, _, _)) {
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index c045413c2db..5320389db9a 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -370,24 +370,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir)
                 }
             }
 
-            auto count = 0;
-            for (@ast.view_item vi in m.view_items) {
-                alt (vi.node) {
-                    case (ast.view_item_export(?id)) {
-                        if (_str.eq(i, id)) {
-                            ret true;
-                        }
-                        count += 1;
-                    }
-                    case (_) { /* fall through */ }
-                }
-            }
-            // If there are no declared exports then everything is exported
-            if (count == 0) {
-                ret true;
-            } else {
-                ret false;
-            }
+            ret ast.is_exported(i, m);
         }
 
         alt (m.index.find(i)) {