Skip to content

Commit 3040b56

Browse files
committed
---
yaml --- r: 2472 b: refs/heads/master c: 14f1fe0 h: refs/heads/master v: v3
1 parent 3c55e87 commit 3040b56

File tree

7 files changed

+166
-203
lines changed

7 files changed

+166
-203
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: 5bea22d75c5427db76978f4f1e644b4ba37c3dc8
2+
refs/heads/master: 14f1fe0e29d5f4d832ef622b7a1a49e5c591e1c0

trunk/src/comp/front/ast.rs

Lines changed: 2 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -360,21 +360,8 @@ type _obj = rec(vec[obj_field] fields,
360360
vec[@method] methods,
361361
Option.t[@method] dtor);
362362

363-
tag mod_index_entry {
364-
mie_view_item(@view_item);
365-
mie_item(@item);
366-
mie_tag_variant(@item /* tag item */, uint /* variant index */);
367-
}
368-
369-
tag native_mod_index_entry {
370-
nmie_view_item(@view_item);
371-
nmie_item(@native_item);
372-
}
373-
374-
type mod_index = hashmap[ident,mod_index_entry];
375363
type _mod = rec(vec[@view_item] view_items,
376-
vec[@item] items,
377-
mod_index index);
364+
vec[@item] items);
378365

379366
tag native_abi {
380367
native_abi_rust;
@@ -386,9 +373,7 @@ tag native_abi {
386373
type native_mod = rec(str native_name,
387374
native_abi abi,
388375
vec[@view_item] view_items,
389-
vec[@native_item] items,
390-
native_mod_index index);
391-
type native_mod_index = hashmap[ident,native_mod_index_entry];
376+
vec[@native_item] items);
392377

393378
type variant_arg = rec(@ty ty, def_id id);
394379
type variant_ = rec(str name, vec[variant_arg] args, def_id id, ann ann);
@@ -433,78 +418,6 @@ tag native_item_ {
433418
fn_decl, vec[ty_param], def_id, ann);
434419
}
435420

436-
fn index_view_item(mod_index index, @view_item it) {
437-
alt (it.node) {
438-
case(ast.view_item_use(?id, _, _, _)) {
439-
index.insert(id, ast.mie_view_item(it));
440-
}
441-
case(ast.view_item_import(?def_ident,_,_)) {
442-
index.insert(def_ident, ast.mie_view_item(it));
443-
}
444-
case(ast.view_item_export(_)) {
445-
// NB: don't index these, they might collide with
446-
// the import or use that they're exporting. Have
447-
// to do linear search for exports.
448-
}
449-
}
450-
}
451-
452-
fn index_item(mod_index index, @item it) {
453-
alt (it.node) {
454-
case (ast.item_const(?id, _, _, _, _)) {
455-
index.insert(id, ast.mie_item(it));
456-
}
457-
case (ast.item_fn(?id, _, _, _, _)) {
458-
index.insert(id, ast.mie_item(it));
459-
}
460-
case (ast.item_mod(?id, _, _)) {
461-
index.insert(id, ast.mie_item(it));
462-
}
463-
case (ast.item_native_mod(?id, _, _)) {
464-
index.insert(id, ast.mie_item(it));
465-
}
466-
case (ast.item_ty(?id, _, _, _, _)) {
467-
index.insert(id, ast.mie_item(it));
468-
}
469-
case (ast.item_tag(?id, ?variants, _, _, _)) {
470-
index.insert(id, ast.mie_item(it));
471-
let uint variant_idx = 0u;
472-
for (ast.variant v in variants) {
473-
index.insert(v.node.name,
474-
ast.mie_tag_variant(it, variant_idx));
475-
variant_idx += 1u;
476-
}
477-
}
478-
case (ast.item_obj(?id, _, _, _, _)) {
479-
index.insert(id, ast.mie_item(it));
480-
}
481-
}
482-
}
483-
484-
fn index_native_item(native_mod_index index, @native_item it) {
485-
alt (it.node) {
486-
case (ast.native_item_ty(?id, _)) {
487-
index.insert(id, ast.nmie_item(it));
488-
}
489-
case (ast.native_item_fn(?id, _, _, _, _, _)) {
490-
index.insert(id, ast.nmie_item(it));
491-
}
492-
}
493-
}
494-
495-
fn index_native_view_item(native_mod_index index, @view_item it) {
496-
alt (it.node) {
497-
case(ast.view_item_import(?def_ident,_,_)) {
498-
index.insert(def_ident, ast.nmie_view_item(it));
499-
}
500-
case(ast.view_item_export(_)) {
501-
// NB: don't index these, they might collide with
502-
// the import or use that they're exporting. Have
503-
// to do linear search for exports.
504-
}
505-
}
506-
}
507-
508421
fn is_exported(ident i, _mod m) -> bool {
509422
auto count = 0;
510423
for (@ast.view_item vi in m.view_items) {

trunk/src/comp/front/eval.rs

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,11 @@ fn eval_crate_directives(ctx cx,
236236
vec[@ast.crate_directive] cdirs,
237237
str prefix,
238238
&mutable vec[@ast.view_item] view_items,
239-
&mutable vec[@ast.item] items,
240-
hashmap[ast.ident,
241-
ast.mod_index_entry] index) {
239+
&mutable vec[@ast.item] items) {
242240

243241
for (@ast.crate_directive sub_cdir in cdirs) {
244242
eval_crate_directive(cx, e, sub_cdir, prefix,
245-
view_items, items, index);
243+
view_items, items);
246244
}
247245
}
248246

@@ -252,12 +250,11 @@ fn eval_crate_directives_to_mod(ctx cx, env e,
252250
str prefix) -> ast._mod {
253251
let vec[@ast.view_item] view_items = vec();
254252
let vec[@ast.item] items = vec();
255-
auto index = new_str_hash[ast.mod_index_entry]();
256253

257254
eval_crate_directives(cx, e, cdirs, prefix,
258-
view_items, items, index);
255+
view_items, items);
259256

260-
ret rec(view_items=view_items, items=items, index=index);
257+
ret rec(view_items=view_items, items=items);
261258
}
262259

263260

@@ -266,15 +263,13 @@ fn eval_crate_directive_block(ctx cx,
266263
&ast.block blk,
267264
str prefix,
268265
&mutable vec[@ast.view_item] view_items,
269-
&mutable vec[@ast.item] items,
270-
hashmap[ast.ident,
271-
ast.mod_index_entry] index) {
266+
&mutable vec[@ast.item] items) {
272267

273268
for (@ast.stmt s in blk.node.stmts) {
274269
alt (s.node) {
275270
case (ast.stmt_crate_directive(?cdir)) {
276271
eval_crate_directive(cx, e, cdir, prefix,
277-
view_items, items, index);
272+
view_items, items);
278273
}
279274
case (_) {
280275
cx.sess.span_err(s.span,
@@ -289,9 +284,7 @@ fn eval_crate_directive_expr(ctx cx,
289284
@ast.expr x,
290285
str prefix,
291286
&mutable vec[@ast.view_item] view_items,
292-
&mutable vec[@ast.item] items,
293-
hashmap[ast.ident,
294-
ast.mod_index_entry] index) {
287+
&mutable vec[@ast.item] items) {
295288
alt (x.node) {
296289

297290
case (ast.expr_if(?cond, ?thn, ?elopt, _)) {
@@ -302,15 +295,13 @@ fn eval_crate_directive_expr(ctx cx,
302295

303296
if (val_as_bool(cv)) {
304297
ret eval_crate_directive_block(cx, e, thn, prefix,
305-
view_items, items,
306-
index);
298+
view_items, items);
307299
}
308300

309301
alt (elopt) {
310302
case (some[@ast.expr](?els)) {
311303
ret eval_crate_directive_expr(cx, e, els, prefix,
312-
view_items, items,
313-
index);
304+
view_items, items);
314305
}
315306
case (_) {
316307
// Absent-else is ok.
@@ -326,14 +317,13 @@ fn eval_crate_directive_expr(ctx cx,
326317
auto pv = eval_lit(cx, arm.pat.span, lit);
327318
if (val_eq(cx.sess, arm.pat.span, vv, pv)) {
328319
ret eval_crate_directive_block
329-
(cx, e, arm.block, prefix,
330-
view_items, items, index);
320+
(cx, e, arm.block, prefix, view_items, items);
331321
}
332322
}
333323
case (ast.pat_wild(_)) {
334324
ret eval_crate_directive_block
335325
(cx, e, arm.block, prefix,
336-
view_items, items, index);
326+
view_items, items);
337327
}
338328
case (_) {
339329
cx.sess.span_err(arm.pat.span,
@@ -346,8 +336,7 @@ fn eval_crate_directive_expr(ctx cx,
346336

347337
case (ast.expr_block(?block, _)) {
348338
ret eval_crate_directive_block(cx, e, block, prefix,
349-
view_items, items,
350-
index);
339+
view_items, items);
351340
}
352341

353342
case (_) {
@@ -361,21 +350,19 @@ fn eval_crate_directive(ctx cx,
361350
@ast.crate_directive cdir,
362351
str prefix,
363352
&mutable vec[@ast.view_item] view_items,
364-
&mutable vec[@ast.item] items,
365-
hashmap[ast.ident,
366-
ast.mod_index_entry] index) {
353+
&mutable vec[@ast.item] items) {
367354
alt (cdir.node) {
368355

369356
case (ast.cdir_let(?id, ?x, ?cdirs)) {
370357
auto v = eval_expr(cx, e, x);
371358
auto e0 = vec(tup(id, v)) + e;
372359
eval_crate_directives(cx, e0, cdirs, prefix,
373-
view_items, items, index);
360+
view_items, items);
374361
}
375362

376363
case (ast.cdir_expr(?x)) {
377364
eval_crate_directive_expr(cx, e, x, prefix,
378-
view_items, items, index);
365+
view_items, items);
379366
}
380367

381368
case (ast.cdir_src_mod(?id, ?file_opt)) {
@@ -404,7 +391,6 @@ fn eval_crate_directive(ctx cx,
404391
cx.chpos = p0.get_chpos();
405392
auto im = ast.item_mod(id, m0, next_id);
406393
auto i = @spanned(cdir.span.lo, cdir.span.hi, im);
407-
ast.index_item(index, i);
408394
Vec.push[@ast.item](items, i);
409395
}
410396

@@ -422,13 +408,11 @@ fn eval_crate_directive(ctx cx,
422408
auto m0 = eval_crate_directives_to_mod(cx, e, cdirs, full_path);
423409
auto im = ast.item_mod(id, m0, cx.p.next_def_id());
424410
auto i = @spanned(cdir.span.lo, cdir.span.hi, im);
425-
ast.index_item(index, i);
426411
Vec.push[@ast.item](items, i);
427412
}
428413

429414
case (ast.cdir_view_item(?vi)) {
430415
Vec.push[@ast.view_item](view_items, vi);
431-
ast.index_view_item(index, vi);
432416
}
433417

434418
case (ast.cdir_meta(?mi)) {

trunk/src/comp/front/parser.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,17 +1889,12 @@ fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
18891889
}
18901890

18911891
fn parse_mod_items(parser p, token.token term) -> ast._mod {
1892-
auto index = new_str_hash[ast.mod_index_entry]();
1893-
auto view_items = parse_view(p, index);
1892+
auto view_items = parse_view(p);
18941893
let vec[@ast.item] items = vec();
18951894
while (p.peek() != term) {
1896-
auto item = parse_item(p);
1897-
items += vec(item);
1898-
1899-
// Index the item.
1900-
ast.index_item(index, item);
1895+
items += vec(parse_item(p));
19011896
}
1902-
ret rec(view_items=view_items, items=items, index=index);
1897+
ret rec(view_items=view_items, items=items);
19031898
}
19041899

19051900
fn parse_item_const(parser p) -> @ast.item {
@@ -1972,22 +1967,16 @@ fn parse_native_item(parser p) -> @ast.native_item {
19721967
fn parse_native_mod_items(parser p,
19731968
str native_name,
19741969
ast.native_abi abi) -> ast.native_mod {
1975-
auto index = new_str_hash[ast.native_mod_index_entry]();
19761970
let vec[@ast.native_item] items = vec();
19771971

1978-
auto view_items = parse_native_view(p, index);
1972+
auto view_items = parse_native_view(p);
19791973

19801974
while (p.peek() != token.RBRACE) {
1981-
auto item = parse_native_item(p);
1982-
items += vec(item);
1983-
1984-
// Index the item.
1985-
ast.index_native_item(index, item);
1975+
items += vec(parse_native_item(p));
19861976
}
19871977
ret rec(native_name=native_name, abi=abi,
19881978
view_items=view_items,
1989-
items=items,
1990-
index=index);
1979+
items=items);
19911980
}
19921981

19931982
fn default_native_name(session.session sess, str id) -> str {
@@ -2353,25 +2342,18 @@ fn is_view_item(token.token t) -> bool {
23532342
ret false;
23542343
}
23552344

2356-
fn parse_view(parser p, ast.mod_index index) -> vec[@ast.view_item] {
2345+
fn parse_view(parser p) -> vec[@ast.view_item] {
23572346
let vec[@ast.view_item] items = vec();
23582347
while (is_view_item(p.peek())) {
2359-
auto item = parse_view_item(p);
2360-
items += vec(item);
2361-
2362-
ast.index_view_item(index, item);
2348+
items += vec(parse_view_item(p));
23632349
}
23642350
ret items;
23652351
}
23662352

2367-
fn parse_native_view(parser p, ast.native_mod_index index)
2368-
-> vec[@ast.view_item] {
2353+
fn parse_native_view(parser p) -> vec[@ast.view_item] {
23692354
let vec[@ast.view_item] items = vec();
23702355
while (is_view_item(p.peek())) {
2371-
auto item = parse_view_item(p);
2372-
items += vec(item);
2373-
2374-
ast.index_native_view_item(index, item);
2356+
items += vec(parse_view_item(p));
23752357
}
23762358
ret items;
23772359
}

trunk/src/comp/middle/fold.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,21 +1057,18 @@ fn fold_mod[ENV](&ENV e, &ast_fold[ENV] fld, &ast._mod m) -> ast._mod {
10571057

10581058
let vec[@view_item] view_items = vec();
10591059
let vec[@item] items = vec();
1060-
auto index = new_str_hash[ast.mod_index_entry]();
10611060

10621061
for (@view_item vi in m.view_items) {
10631062
auto new_vi = fold_view_item[ENV](e, fld, vi);
10641063
Vec.push[@view_item](view_items, new_vi);
1065-
ast.index_view_item(index, new_vi);
10661064
}
10671065

10681066
for (@item i in m.items) {
10691067
auto new_item = fold_item[ENV](e, fld, i);
10701068
Vec.push[@item](items, new_item);
1071-
ast.index_item(index, new_item);
10721069
}
10731070

1074-
ret fld.fold_mod(e, rec(view_items=view_items, items=items, index=index));
1071+
ret fld.fold_mod(e, rec(view_items=view_items, items=items));
10751072
}
10761073

10771074
fn fold_native_item[ENV](&ENV env, &ast_fold[ENV] fld,
@@ -1098,7 +1095,6 @@ fn fold_native_mod[ENV](&ENV e, &ast_fold[ENV] fld,
10981095
&ast.native_mod m) -> ast.native_mod {
10991096
let vec[@view_item] view_items = vec();
11001097
let vec[@native_item] items = vec();
1101-
auto index = new_str_hash[ast.native_mod_index_entry]();
11021098

11031099
for (@view_item vi in m.view_items) {
11041100
auto new_vi = fold_view_item[ENV](e, fld, vi);
@@ -1108,14 +1104,12 @@ fn fold_native_mod[ENV](&ENV e, &ast_fold[ENV] fld,
11081104
for (@native_item i in m.items) {
11091105
auto new_item = fold_native_item[ENV](e, fld, i);
11101106
Vec.push[@native_item](items, new_item);
1111-
ast.index_native_item(index, new_item);
11121107
}
11131108

11141109
ret fld.fold_native_mod(e, rec(native_name=m.native_name,
11151110
abi=m.abi,
11161111
view_items=view_items,
1117-
items=items,
1118-
index=index));
1112+
items=items));
11191113
}
11201114

11211115
fn fold_crate[ENV](&ENV env, &ast_fold[ENV] fld,

0 commit comments

Comments
 (0)