diff options
| author | Brian Anderson <[email protected]> | 2011-05-02 20:29:39 -0400 |
|---|---|---|
| committer | Brian Anderson <[email protected]> | 2011-05-02 22:07:36 -0400 |
| commit | ed40c85af5c6eec82746696d3ce2d0e7ae22c1d4 (patch) | |
| tree | 787c5ee833fe2604c7914a60e6b5b2f43abf382b /src/comp | |
| parent | Add some tests of tag-export interaction (diff) | |
| download | rust-ed40c85af5c6eec82746696d3ce2d0e7ae22c1d4.tar.xz rust-ed40c85af5c6eec82746696d3ce2d0e7ae22c1d4.zip | |
Extract ast.is_exported from the resolve module
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/front/ast.rs | 22 | ||||
| -rw-r--r-- | src/comp/middle/resolve.rs | 19 |
2 files changed, 23 insertions, 18 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 13b5739e..82b6d813 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 c045413c..5320389d 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)) { |