Skip to content

Commit 329114a

Browse files
committed
---
yaml --- r: 3278 b: refs/heads/master c: 40db3aa h: refs/heads/master v: v3
1 parent 87422a4 commit 329114a

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
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: 77af54bf6f7d5e7cb704e08689ea96746bc57819
2+
refs/heads/master: 40db3aa6fbe2f0d8d7f9bb85a9fd47b8cca2938b

trunk/src/comp/driver/rustc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ fn compile_input(session::session sess, eval::env env, str input,
8080
auto crate =
8181
time(time_passes, "parsing", bind parse_input(sess, p, input));
8282
if (sess.get_opts().output_type == link::output_type_none) { ret; }
83+
auto ast_map = time(time_passes, "ast indexing",
84+
bind middle::ast_map::map_crate(*crate));
8385
auto d =
8486
time(time_passes, "resolution",
85-
bind resolve::resolve_crate(sess, crate));
87+
bind resolve::resolve_crate(sess, ast_map, crate));
8688
auto ty_cx = ty::mk_ctxt(sess, d._0, d._1);
8789
time[()](time_passes, "typechecking",
8890
bind typeck::check_crate(ty_cx, crate));
@@ -107,7 +109,8 @@ fn pretty_print_input(session::session sess, eval::env env, str input,
107109
auto mode;
108110
alt (ppm) {
109111
case (ppm_typed) {
110-
auto d = resolve::resolve_crate(sess, crate);
112+
auto amap = middle::ast_map::map_crate(*crate);
113+
auto d = resolve::resolve_crate(sess, amap, crate);
111114
auto ty_cx = ty::mk_ctxt(sess, d._0, d._1);
112115
typeck::check_crate(ty_cx, crate);
113116
mode = ppaux::mo_typed(ty_cx);

trunk/src/comp/middle/resolve.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type env =
116116
rec(crate_map crate_map,
117117
def_map def_map,
118118
constr_table fn_constrs,
119-
hashmap[ast::node_id, @ast::item] ast_map,
119+
ast_map::map ast_map,
120120
hashmap[ast::node_id, import_state] imports,
121121
hashmap[ast::node_id, @indexed_mod] mod_map,
122122
hashmap[def_id, vec[ident]] ext_map,
@@ -130,13 +130,13 @@ tag dir { inside; outside; }
130130

131131
tag namespace { ns_value; ns_type; ns_module; }
132132

133-
fn resolve_crate(session sess, @ast::crate crate) ->
133+
fn resolve_crate(session sess, &ast_map::map amap, @ast::crate crate) ->
134134
tup(def_map, constr_table) {
135135
auto e =
136136
@rec(crate_map=new_int_hash[ast::crate_num](),
137137
def_map=new_int_hash[def](),
138138
fn_constrs = new_int_hash[vec[ty::constr_def]](),
139-
ast_map=new_int_hash[@ast::item](),
139+
ast_map=amap,
140140
imports=new_int_hash[import_state](),
141141
mod_map=new_int_hash[@indexed_mod](),
142142
ext_map=new_def_hash[vec[ident]](),
@@ -187,7 +187,6 @@ fn map_crate(&@env e, &@ast::crate c) {
187187
index=index_mod(md),
188188
mutable glob_imports=vec::empty[def](),
189189
glob_imported_names=s));
190-
e.ast_map.insert(i.id, i);
191190
}
192191
case (ast::item_native_mod(?nmd)) {
193192
auto s = new_str_hash[import_state]();
@@ -196,13 +195,8 @@ fn map_crate(&@env e, &@ast::crate c) {
196195
index=index_nmod(nmd),
197196
mutable glob_imports=vec::empty[def](),
198197
glob_imported_names=s));
199-
e.ast_map.insert(i.id, i);
200198
}
201-
case (ast::item_obj(_, _, ?ctor_id)) {
202-
e.ast_map.insert(i.id, i);
203-
e.ast_map.insert(ctor_id, i);
204-
}
205-
case (_) { e.ast_map.insert(i.id, i); }
199+
case (_) { }
206200
}
207201
}
208202
// Next, assemble the links for globbed imports.
@@ -969,16 +963,12 @@ fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id,
969963
ret some[def](matches.(0));
970964
} else {
971965
for (def match in matches) {
972-
alt (e.ast_map.find(ast::def_id_of_def(match)._1)) {
973-
case (some(?it)) {
974-
e.sess.span_note(it.span,
975-
"'" + id + "' is defined here.");
976-
}
977-
case (_) {
978-
e.sess.bug("Internal error: imports and matches " +
979-
"don't agree");
980-
}
981-
}
966+
auto span = alt (e.ast_map.get(ast::def_id_of_def(match)._1)){
967+
case (ast_map::node_item(?it)) { it.span }
968+
case (ast_map::node_obj_ctor(?it)) { it.span }
969+
case (ast_map::node_native_item(?it)) { it.span }
970+
};
971+
e.sess.span_note(span, "'" + id + "' is defined here.");
982972
}
983973
e.sess.span_fatal(sp,
984974
"'" + id + "' is glob-imported from" +

trunk/src/comp/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod middle {
1919
mod walk;
2020
mod visit;
2121
mod metadata;
22+
mod ast_map;
2223
mod resolve;
2324
mod typeck;
2425
mod alias;

0 commit comments

Comments
 (0)