@@ -12,6 +12,7 @@ import std.option;
12
12
import std. option . some ;
13
13
import std. option . none ;
14
14
import std. _str ;
15
+ import std. _vec ;
15
16
16
17
tag scope {
17
18
scope_crate( @ast. crate ) ;
@@ -105,6 +106,10 @@ fn lookup_name(&env e, ast.ident i) -> option.t[def] {
105
106
fn fold_expr_name ( & env e, & span sp, & ast. name n ,
106
107
& option. t[ def] d , ann a) -> @ast . expr {
107
108
109
+ if ( _vec. len [ @ast. ty ] ( n. node . types ) > 0 u) {
110
+ e. sess . unimpl ( "resoling name expr with ty params" ) ;
111
+ }
112
+
108
113
auto d_ = lookup_name ( e, n. node . ident ) ;
109
114
110
115
alt ( d_) {
@@ -119,6 +124,35 @@ fn fold_expr_name(&env e, &span sp, &ast.name n,
119
124
ret @fold. respan [ ast. expr_ ] ( sp, ast. expr_name ( n, d_, a) ) ;
120
125
}
121
126
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 != 0 u) ;
132
+ if ( len > 1 u) {
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 ) > 0 u) {
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
+
122
156
fn update_env_for_crate ( & env e, @ast. crate c ) -> env {
123
157
ret rec ( scopes = cons[ scope] ( scope_crate ( c) , @e. scopes ) with e) ;
124
158
}
@@ -136,6 +170,7 @@ fn resolve_crate(session.session sess, @ast.crate crate) -> @ast.crate {
136
170
let fold. ast_fold[ env] fld = fold. new_identity_fold [ env] ( ) ;
137
171
138
172
fld = @rec ( fold_expr_name = bind fold_expr_name ( _, _, _, _, _) ,
173
+ fold_ty_path = bind fold_ty_path ( _, _, _, _) ,
139
174
update_env_for_crate = bind update_env_for_crate ( _, _) ,
140
175
update_env_for_item = bind update_env_for_item ( _, _) ,
141
176
update_env_for_block = bind update_env_for_block ( _, _)
0 commit comments