Start hooking resolve into creater.

This commit is contained in:
Graydon Hoare 2011-03-24 17:35:27 -07:00
parent af3d0d1848
commit 4e49ca8abd
2 changed files with 38 additions and 5 deletions

View file

@ -274,3 +274,18 @@ fn read_crates(session.session sess,
ret fold.fold_crate[env](e, fld, crate);
}
fn lookup_def(&span sp,
@ast.external_crate_info cinfo,
vec[ast.ident] path) -> ast.def {
// FIXME: fill in.
fail;
}
// Local Variables:
// mode: rust
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:

View file

@ -2,6 +2,7 @@ import front.ast;
import front.ast.ident;
import front.ast.def;
import front.ast.ann;
import front.creader;
import driver.session;
import util.common.new_def_hash;
import util.common.span;
@ -107,9 +108,9 @@ fn find_final_def(&env e, import_map index,
&span sp, vec[ident] idents,
option.t[ast.def_id] import_id) -> def_wrap {
// We are given a series of identifiers (a.b.c.d) and we know that
// in the environment 'e' the identifier 'a' was resolved to 'd'. We
// should return what a.b.c.d points to in the end.
// We are given a series of identifiers (p.q.r) and we know that
// in the environment 'e' the identifier 'p' was resolved to 'd'. We
// should return what p.q.r points to in the end.
fn found_something(&env e, import_map index,
&span sp, vec[ident] idents, def_wrap d) -> def_wrap {
@ -135,6 +136,15 @@ fn find_final_def(&env e, import_map index,
}
}
fn found_crate(&env e, &import_map index, &span sp,
vec[ident] idents,
@ast.external_crate_info cinfo) -> def_wrap {
auto len = _vec.len[ident](idents);
auto rest_idents = _vec.slice[ident](idents, 1u, len);
auto def = creader.lookup_def(sp, cinfo, rest_idents);
ret def_wrap_other(def);
}
alt (d) {
case (def_wrap_import(?imp)) {
alt (imp.node) {
@ -159,8 +169,16 @@ fn find_final_def(&env e, import_map index,
case (def_wrap_native_mod(?i)) {
ret found_mod(e, index, sp, idents, i);
}
case (def_wrap_use(?c)) {
e.sess.span_err(sp, "Crate access is not implemented");
case (def_wrap_use(?vi)) {
alt (vi.node) {
case (ast.view_item_use(_, _, _, ?ann)) {
alt (ann) {
case (ast.ann_crate(?cinfo)) {
ret found_crate(e, index, sp, idents, cinfo);
}
}
}
}
}
case (def_wrap_other(?d)) {
let uint l = _vec.len[ident](idents);