Skip to content

Commit b2a1532

Browse files
committed
---
yaml --- r: 1844 b: refs/heads/master c: 4e49ca8 h: refs/heads/master v: v3
1 parent 826c8fc commit b2a1532

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: af3d0d1848116f0e29dcaf8859d27fd4555f3444
2+
refs/heads/master: 4e49ca8abd31d7cbe087acb8a3aeb6fe1b2ee5ee

trunk/src/comp/front/creader.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,18 @@ fn read_crates(session.session sess,
274274
ret fold.fold_crate[env](e, fld, crate);
275275
}
276276

277+
fn lookup_def(&span sp,
278+
@ast.external_crate_info cinfo,
279+
vec[ast.ident] path) -> ast.def {
280+
// FIXME: fill in.
281+
fail;
282+
}
283+
284+
// Local Variables:
285+
// mode: rust
286+
// fill-column: 78;
287+
// indent-tabs-mode: nil
288+
// c-basic-offset: 4
289+
// buffer-file-coding-system: utf-8-unix
290+
// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
291+
// End:

trunk/src/comp/middle/resolve.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import front.ast;
22
import front.ast.ident;
33
import front.ast.def;
44
import front.ast.ann;
5+
import front.creader;
56
import driver.session;
67
import util.common.new_def_hash;
78
import util.common.span;
@@ -107,9 +108,9 @@ fn find_final_def(&env e, import_map index,
107108
&span sp, vec[ident] idents,
108109
option.t[ast.def_id] import_id) -> def_wrap {
109110

110-
// We are given a series of identifiers (a.b.c.d) and we know that
111-
// in the environment 'e' the identifier 'a' was resolved to 'd'. We
112-
// should return what a.b.c.d points to in the end.
111+
// We are given a series of identifiers (p.q.r) and we know that
112+
// in the environment 'e' the identifier 'p' was resolved to 'd'. We
113+
// should return what p.q.r points to in the end.
113114
fn found_something(&env e, import_map index,
114115
&span sp, vec[ident] idents, def_wrap d) -> def_wrap {
115116

@@ -135,6 +136,15 @@ fn find_final_def(&env e, import_map index,
135136
}
136137
}
137138

139+
fn found_crate(&env e, &import_map index, &span sp,
140+
vec[ident] idents,
141+
@ast.external_crate_info cinfo) -> def_wrap {
142+
auto len = _vec.len[ident](idents);
143+
auto rest_idents = _vec.slice[ident](idents, 1u, len);
144+
auto def = creader.lookup_def(sp, cinfo, rest_idents);
145+
ret def_wrap_other(def);
146+
}
147+
138148
alt (d) {
139149
case (def_wrap_import(?imp)) {
140150
alt (imp.node) {
@@ -159,8 +169,16 @@ fn find_final_def(&env e, import_map index,
159169
case (def_wrap_native_mod(?i)) {
160170
ret found_mod(e, index, sp, idents, i);
161171
}
162-
case (def_wrap_use(?c)) {
163-
e.sess.span_err(sp, "Crate access is not implemented");
172+
case (def_wrap_use(?vi)) {
173+
alt (vi.node) {
174+
case (ast.view_item_use(_, _, _, ?ann)) {
175+
alt (ann) {
176+
case (ast.ann_crate(?cinfo)) {
177+
ret found_crate(e, index, sp, idents, cinfo);
178+
}
179+
}
180+
}
181+
}
164182
}
165183
case (def_wrap_other(?d)) {
166184
let uint l = _vec.len[ident](idents);

0 commit comments

Comments
 (0)