Skip to content

Commit c416339

Browse files
committed
---
yaml --- r: 935 b: refs/heads/master c: 6fcf553 h: refs/heads/master i: 933: e2ab838 931: 5984ebc 927: 755cb7e v: v3
1 parent 2586792 commit c416339

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
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: fdac6ffa7c818f5902173cbf9227bd3def5956a5
2+
refs/heads/master: 6fcf55347e913b632c98725543c24296b67c191c

trunk/src/comp/middle/resolve.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import std.option;
1212
import std.option.some;
1313
import std.option.none;
1414
import std._str;
15+
import std._vec;
1516

1617
tag scope {
1718
scope_crate(@ast.crate);
@@ -105,6 +106,10 @@ fn lookup_name(&env e, ast.ident i) -> option.t[def] {
105106
fn fold_expr_name(&env e, &span sp, &ast.name n,
106107
&option.t[def] d, ann a) -> @ast.expr {
107108

109+
if (_vec.len[@ast.ty](n.node.types) > 0u) {
110+
e.sess.unimpl("resoling name expr with ty params");
111+
}
112+
108113
auto d_ = lookup_name(e, n.node.ident);
109114

110115
alt (d_) {
@@ -119,6 +124,35 @@ fn fold_expr_name(&env e, &span sp, &ast.name n,
119124
ret @fold.respan[ast.expr_](sp, ast.expr_name(n, d_, a));
120125
}
121126

127+
fn fold_ty_path(&env e, &span sp, ast.path p,
128+
&option.t[def] d) -> @ast.ty {
129+
130+
let uint len = _vec.len[ast.name](p);
131+
check (len != 0u);
132+
if (len > 1u) {
133+
e.sess.unimpl("resoling path ty with >1 component");
134+
}
135+
136+
let ast.name n = p.(0);
137+
138+
if (_vec.len[@ast.ty](n.node.types) > 0u) {
139+
e.sess.unimpl("resoling path ty with ty params");
140+
}
141+
142+
auto d_ = lookup_name(e, n.node.ident);
143+
144+
alt (d_) {
145+
case (some[def](_)) {
146+
// log "resolved name " + n.node.ident;
147+
}
148+
case (none[def]) {
149+
e.sess.err("unresolved name: " + n.node.ident);
150+
}
151+
}
152+
153+
ret @fold.respan[ast.ty_](sp, ast.ty_path(p, d_));
154+
}
155+
122156
fn update_env_for_crate(&env e, @ast.crate c) -> env {
123157
ret rec(scopes = cons[scope](scope_crate(c), @e.scopes) with e);
124158
}
@@ -136,6 +170,7 @@ fn resolve_crate(session.session sess, @ast.crate crate) -> @ast.crate {
136170
let fold.ast_fold[env] fld = fold.new_identity_fold[env]();
137171

138172
fld = @rec( fold_expr_name = bind fold_expr_name(_,_,_,_,_),
173+
fold_ty_path = bind fold_ty_path(_,_,_,_),
139174
update_env_for_crate = bind update_env_for_crate(_,_),
140175
update_env_for_item = bind update_env_for_item(_,_),
141176
update_env_for_block = bind update_env_for_block(_,_)

0 commit comments

Comments
 (0)