Extract ast.is_exported from the resolve module

This commit is contained in:
Brian Anderson 2011-05-02 20:29:39 -04:00
parent 3014a5887d
commit ed40c85af5
2 changed files with 23 additions and 18 deletions

View file

@ -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(_, _, _)) {

View file

@ -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)) {