Skip to content

Commit 75e8d34

Browse files
committed
---
yaml --- r: 2468 b: refs/heads/master c: 5405f45 h: refs/heads/master v: v3
1 parent 9d0664b commit 75e8d34

File tree

7 files changed

+63
-117
lines changed

7 files changed

+63
-117
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: 7d086df0954263c2667fb4af65ab82b7e39d51ca
2+
refs/heads/master: 5405f45274dc6dce53743092dc0679a5f43482d9

trunk/src/comp/front/ast.rs

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,8 @@ type meta_item = spanned[meta_item_];
9494
type meta_item_ = rec(ident name, str value);
9595

9696
type block = spanned[block_];
97-
type block_index = hashmap[ident, block_index_entry];
98-
tag block_index_entry {
99-
bie_item(@item);
100-
bie_local(@local);
101-
bie_tag_variant(@item /* tag item */, uint /* variant index */);
102-
}
10397
type block_ = rec(vec[@stmt] stmts,
10498
Option.t[@expr] expr,
105-
hashmap[ident,block_index_entry] index,
10699
ann a); /* ann is only meaningful for the ts_ann field */
107100

108101
type variant_def = tup(def_id /* tag */, def_id /* variant */);
@@ -421,6 +414,18 @@ tag item_ {
421414
item_obj(ident, _obj, vec[ty_param], obj_def_ids, ann);
422415
}
423416

417+
fn item_ident(@item it) -> ident {
418+
ret alt (it.node) {
419+
case (item_const(?ident, _, _, _, _)) { ident }
420+
case (item_fn(?ident, _, _, _, _)) { ident }
421+
case (item_mod(?ident, _, _)) { ident }
422+
case (item_native_mod(?ident, _, _)) { ident }
423+
case (item_ty(?ident, _, _, _, _)) { ident }
424+
case (item_tag(?ident, _, _, _, _)) { ident }
425+
case (item_obj(?ident, _, _, _, _)) { ident }
426+
}
427+
}
428+
424429
type native_item = spanned[native_item_];
425430
tag native_item_ {
426431
native_item_ty(ident, def_id);
@@ -500,44 +505,6 @@ fn index_native_view_item(native_mod_index index, @view_item it) {
500505
}
501506
}
502507

503-
fn index_stmt(block_index index, @stmt s) {
504-
alt (s.node) {
505-
case (ast.stmt_decl(?d,_)) {
506-
alt (d.node) {
507-
case (ast.decl_local(?loc)) {
508-
index.insert(loc.ident, ast.bie_local(loc));
509-
}
510-
case (ast.decl_item(?it)) {
511-
alt (it.node) {
512-
case (ast.item_fn(?i, _, _, _, _)) {
513-
index.insert(i, ast.bie_item(it));
514-
}
515-
case (ast.item_mod(?i, _, _)) {
516-
index.insert(i, ast.bie_item(it));
517-
}
518-
case (ast.item_ty(?i, _, _, _, _)) {
519-
index.insert(i, ast.bie_item(it));
520-
}
521-
case (ast.item_tag(?i, ?variants, _, _, _)) {
522-
index.insert(i, ast.bie_item(it));
523-
let uint vid = 0u;
524-
for (ast.variant v in variants) {
525-
auto t = ast.bie_tag_variant(it, vid);
526-
index.insert(v.node.name, t);
527-
vid += 1u;
528-
}
529-
}
530-
case (ast.item_obj(?i, _, _, _, _)) {
531-
index.insert(i, ast.bie_item(it));
532-
}
533-
}
534-
}
535-
}
536-
}
537-
case (_) { /* fall through */ }
538-
}
539-
}
540-
541508
fn is_exported(ident i, _mod m) -> bool {
542509
auto count = 0;
543510
for (@ast.view_item vi in m.view_items) {

trunk/src/comp/front/parser.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,15 +1626,6 @@ fn parse_source_stmt(parser p) -> @ast.stmt {
16261626
fail;
16271627
}
16281628

1629-
fn index_block(parser p, vec[@ast.stmt] stmts, Option.t[@ast.expr] expr)
1630-
-> ast.block_ {
1631-
auto index = new_str_hash[ast.block_index_entry]();
1632-
for (@ast.stmt s in stmts) {
1633-
ast.index_stmt(index, s);
1634-
}
1635-
ret rec(stmts=stmts, expr=expr, index=index, a=p.get_ann());
1636-
}
1637-
16381629
fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] {
16391630
fn do_index_arm(&hashmap[ast.ident,ast.def_id] index, @ast.pat pat) {
16401631
alt (pat.node) {
@@ -1770,7 +1761,7 @@ fn parse_block(parser p) -> ast.block {
17701761
auto hi = p.get_hi_pos();
17711762
p.bump();
17721763

1773-
auto bloc = index_block(p, stmts, expr);
1764+
auto bloc = rec(stmts=stmts, expr=expr, a=p.get_ann());
17741765
ret spanned[ast.block_](lo, hi, bloc);
17751766
}
17761767

trunk/src/comp/middle/fold.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,6 @@ fn fold_stmt[ENV](&ENV env, &ast_fold[ENV] fld, &@stmt s) -> @stmt {
862862

863863
fn fold_block[ENV](&ENV env, &ast_fold[ENV] fld, &block blk) -> block {
864864

865-
auto index = new_str_hash[ast.block_index_entry]();
866865
let ENV env_ = fld.update_env_for_block(env, blk);
867866

868867
if (!fld.keep_going(env_)) {
@@ -873,7 +872,6 @@ fn fold_block[ENV](&ENV env, &ast_fold[ENV] fld, &block blk) -> block {
873872
for (@ast.stmt s in blk.node.stmts) {
874873
auto new_stmt = fold_stmt[ENV](env_, fld, s);
875874
Vec.push[@ast.stmt](stmts, new_stmt);
876-
ast.index_stmt(index, new_stmt);
877875
}
878876

879877
auto expr = none[@ast.expr];
@@ -887,7 +885,7 @@ fn fold_block[ENV](&ENV env, &ast_fold[ENV] fld, &block blk) -> block {
887885
}
888886

889887
auto aa = fld.fold_ann(env, blk.node.a);
890-
ret respan(blk.span, rec(stmts=stmts, expr=expr, index=index, a=aa));
888+
ret respan(blk.span, rec(stmts=stmts, expr=expr, a=aa));
891889
}
892890

893891
fn fold_arm[ENV](&ENV env, &ast_fold[ENV] fld, &arm a) -> arm {

trunk/src/comp/middle/resolve.rs

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -500,82 +500,77 @@ fn lookup_in_obj(ident id, &ast._obj ob, &vec[ast.ty_param] ty_params,
500500

501501
fn lookup_in_block(ident id, &ast.block_ b, namespace ns)
502502
-> Option.t[def] {
503-
alt (b.index.find(id)) {
504-
case (some[ast.block_index_entry](?ix)) {
505-
alt (ix) {
506-
case (ast.bie_item(?it)) {
507-
ret found_def_item(it, ns);
508-
}
509-
case (ast.bie_local(?l)) {
510-
if (ns == ns_value) {
511-
ret some(ast.def_local(l.id));
503+
for (@ast.stmt st in b.stmts) {
504+
alt (st.node) {
505+
case (ast.stmt_decl(?d,_)) {
506+
alt (d.node) {
507+
case (ast.decl_local(?loc)) {
508+
if (ns == ns_value && Str.eq(id, loc.ident)) {
509+
ret some(ast.def_local(loc.id));
510+
}
512511
}
513-
}
514-
case (ast.bie_tag_variant(?item, ?variant_idx)) {
515-
if (ns == ns_value) {
516-
ret some(found_def_tag(item, variant_idx));
512+
case (ast.decl_item(?it)) {
513+
alt (it.node) {
514+
case (ast.item_tag(?name, ?variants, _,
515+
?defid, _)) {
516+
if (ns == ns_type) {
517+
if (Str.eq(name, id)) {
518+
ret some(ast.def_ty(defid));
519+
}
520+
} else {
521+
for (ast.variant v in variants) {
522+
if (Str.eq(v.node.name, id)) {
523+
ret some(ast.def_variant(
524+
defid, v.node.id));
525+
}
526+
}
527+
}
528+
}
529+
case (_) {
530+
if (Str.eq(ast.item_ident(it), id)) {
531+
auto found = found_def_item(it, ns);
532+
if (found != none[def]) { ret found; }
533+
}
534+
}
535+
}
517536
}
518537
}
519538
}
539+
case (_) {}
520540
}
521-
case (_) { }
522541
}
523542
ret none[def];
524543
}
525544

526545
fn found_def_item(@ast.item i, namespace ns) -> Option.t[def] {
527546
alt (i.node) {
528-
case (ast.item_const(_, _, _, ?id, _)) {
529-
if (ns == ns_value) {
530-
ret some(ast.def_const(id));
531-
}
547+
case (ast.item_const(_, _, _, ?defid, _)) {
548+
if (ns == ns_value) { ret some(ast.def_const(defid)); }
532549
}
533-
case (ast.item_fn(_, _, _, ?id, _)) {
534-
if (ns == ns_value) {
535-
ret some(ast.def_fn(id));
536-
}
550+
case (ast.item_fn(_, _, _, ?defid, _)) {
551+
if (ns == ns_value) { ret some(ast.def_fn(defid)); }
537552
}
538-
case (ast.item_mod(_, _, ?id)) {
539-
ret some(ast.def_mod(id));
553+
case (ast.item_mod(_, _, ?defid)) {
554+
ret some(ast.def_mod(defid));
540555
}
541-
case (ast.item_native_mod(_, _, ?id)) {
542-
ret some(ast.def_native_mod(id));
556+
case (ast.item_native_mod(_, _, ?defid)) {
557+
ret some(ast.def_native_mod(defid));
543558
}
544-
case (ast.item_ty(_, _, _, ?id, _)) {
545-
if (ns == ns_type) {
546-
ret some(ast.def_ty(id));
547-
}
559+
case (ast.item_ty(_, _, _, ?defid, _)) {
560+
if (ns == ns_type) { ret some(ast.def_ty(defid)); }
548561
}
549-
case (ast.item_tag(_, _, _, ?id, _)) {
550-
if (ns == ns_type) {
551-
ret some(ast.def_ty(id));
552-
}
562+
case (ast.item_tag(_, _, _, ?defid, _)) {
563+
if (ns == ns_type) { ret some(ast.def_ty(defid)); }
553564
}
554565
case (ast.item_obj(_, _, _, ?odid, _)) {
555-
if (ns == ns_value) {
556-
ret some(ast.def_obj(odid.ctor));
557-
} else {
558-
ret some(ast.def_obj(odid.ty));
559-
}
566+
if (ns == ns_value) { ret some(ast.def_obj(odid.ctor)); }
567+
else { ret some(ast.def_obj(odid.ty)); }
560568
}
561569
case (_) { }
562570
}
563571
ret none[def];
564572
}
565573

566-
fn found_def_tag(@ast.item item, uint variant_idx) -> def {
567-
alt (item.node) {
568-
case (ast.item_tag(_, ?variants, _, ?tid, _)) {
569-
auto vid = variants.(variant_idx).node.id;
570-
ret ast.def_variant(tid, vid);
571-
}
572-
case (_) {
573-
log_err "tag item not actually a tag";
574-
fail;
575-
}
576-
}
577-
}
578-
579574
fn lookup_in_mod_strict(&env e, def m, &span sp, ident id,
580575
namespace ns, dir dr) -> def {
581576
alt (lookup_in_mod(e, m, id, ns, dr)) {

trunk/src/comp/middle/typeck.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,6 @@ mod Pushdown {
15071507
auto e_1 = pushdown_expr(fcx, expected, e_0);
15081508
auto block_ = rec(stmts=bloc.node.stmts,
15091509
expr=some[@ast.expr](e_1),
1510-
index=bloc.node.index,
15111510
a=plain_ann(fcx.ccx.tcx));
15121511
ret fold.respan[ast.block_](bloc.span, block_);
15131512
}
@@ -2806,7 +2805,6 @@ fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
28062805

28072806
ret fold.respan[ast.block_](block.span,
28082807
rec(stmts=stmts, expr=expr,
2809-
index=block.node.index,
28102808
a=plain_ann(fcx.ccx.tcx)));
28112809
}
28122810

trunk/src/comp/middle/typestate_check.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import front.ast.mutability;
66
import front.ast.item;
77
import front.ast.block;
88
import front.ast.block_;
9-
import front.ast.block_index_entry;
109
import front.ast.mod_index_entry;
1110
import front.ast.obj_field;
1211
import front.ast.decl;
@@ -2337,12 +2336,10 @@ fn annotate_stmt(&fn_info_map fm, &@stmt s) -> @stmt {
23372336
}
23382337
fn annotate_block(&fn_info_map fm, &block b) -> block {
23392338
let vec[@stmt] new_stmts = vec();
2340-
auto new_index = new_str_hash[block_index_entry]();
23412339

23422340
for (@stmt s in b.node.stmts) {
23432341
auto new_s = annotate_stmt(fm, s);
23442342
Vec.push[@stmt](new_stmts, new_s);
2345-
ast.index_stmt(new_index, new_s);
23462343
}
23472344
fn ann_e(fn_info_map fm, &@expr e) -> @expr {
23482345
ret annotate_expr(fm, e);
@@ -2352,7 +2349,7 @@ fn annotate_block(&fn_info_map fm, &block b) -> block {
23522349
auto new_e = Option.map[@expr, @expr](f, b.node.expr);
23532350

23542351
ret respan(b.span,
2355-
rec(stmts=new_stmts, expr=new_e, index=new_index with b.node));
2352+
rec(stmts=new_stmts, expr=new_e with b.node));
23562353
}
23572354
fn annotate_fn(&fn_info_map fm, &ast._fn f) -> ast._fn {
23582355
// subexps have *already* been annotated based on

0 commit comments

Comments
 (0)