aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-11 15:10:24 +0200
committerMarijn Haverbeke <[email protected]>2011-05-11 15:10:24 +0200
commit5405f45274dc6dce53743092dc0679a5f43482d9 (patch)
treed1417d56ca0770e3cbf7abf1273ed1f2fce3fe4c /src/comp/front
parentStop depending on block indices in capture.rs (diff)
downloadrust-5405f45274dc6dce53743092dc0679a5f43482d9.tar.xz
rust-5405f45274dc6dce53743092dc0679a5f43482d9.zip
Get rid of block indices
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs57
-rw-r--r--src/comp/front/parser.rs11
2 files changed, 13 insertions, 55 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index e7328d7a..01dea8d8 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -94,15 +94,8 @@ type meta_item = spanned[meta_item_];
type meta_item_ = rec(ident name, str value);
type block = spanned[block_];
-type block_index = hashmap[ident, block_index_entry];
-tag block_index_entry {
- bie_item(@item);
- bie_local(@local);
- bie_tag_variant(@item /* tag item */, uint /* variant index */);
-}
type block_ = rec(vec[@stmt] stmts,
Option.t[@expr] expr,
- hashmap[ident,block_index_entry] index,
ann a); /* ann is only meaningful for the ts_ann field */
type variant_def = tup(def_id /* tag */, def_id /* variant */);
@@ -421,6 +414,18 @@ tag item_ {
item_obj(ident, _obj, vec[ty_param], obj_def_ids, ann);
}
+fn item_ident(@item it) -> ident {
+ ret alt (it.node) {
+ case (item_const(?ident, _, _, _, _)) { ident }
+ case (item_fn(?ident, _, _, _, _)) { ident }
+ case (item_mod(?ident, _, _)) { ident }
+ case (item_native_mod(?ident, _, _)) { ident }
+ case (item_ty(?ident, _, _, _, _)) { ident }
+ case (item_tag(?ident, _, _, _, _)) { ident }
+ case (item_obj(?ident, _, _, _, _)) { ident }
+ }
+}
+
type native_item = spanned[native_item_];
tag native_item_ {
native_item_ty(ident, def_id);
@@ -500,44 +505,6 @@ fn index_native_view_item(native_mod_index index, @view_item it) {
}
}
-fn index_stmt(block_index index, @stmt s) {
- alt (s.node) {
- case (ast.stmt_decl(?d,_)) {
- alt (d.node) {
- case (ast.decl_local(?loc)) {
- index.insert(loc.ident, ast.bie_local(loc));
- }
- case (ast.decl_item(?it)) {
- alt (it.node) {
- case (ast.item_fn(?i, _, _, _, _)) {
- index.insert(i, ast.bie_item(it));
- }
- case (ast.item_mod(?i, _, _)) {
- index.insert(i, ast.bie_item(it));
- }
- case (ast.item_ty(?i, _, _, _, _)) {
- index.insert(i, ast.bie_item(it));
- }
- case (ast.item_tag(?i, ?variants, _, _, _)) {
- index.insert(i, ast.bie_item(it));
- let uint vid = 0u;
- for (ast.variant v in variants) {
- auto t = ast.bie_tag_variant(it, vid);
- index.insert(v.node.name, t);
- vid += 1u;
- }
- }
- case (ast.item_obj(?i, _, _, _, _)) {
- index.insert(i, ast.bie_item(it));
- }
- }
- }
- }
- }
- case (_) { /* fall through */ }
- }
-}
-
fn is_exported(ident i, _mod m) -> bool {
auto count = 0;
for (@ast.view_item vi in m.view_items) {
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 46cad2fd..69f0e054 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1626,15 +1626,6 @@ fn parse_source_stmt(parser p) -> @ast.stmt {
fail;
}
-fn index_block(parser p, vec[@ast.stmt] stmts, Option.t[@ast.expr] expr)
- -> ast.block_ {
- auto index = new_str_hash[ast.block_index_entry]();
- for (@ast.stmt s in stmts) {
- ast.index_stmt(index, s);
- }
- ret rec(stmts=stmts, expr=expr, index=index, a=p.get_ann());
-}
-
fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] {
fn do_index_arm(&hashmap[ast.ident,ast.def_id] index, @ast.pat pat) {
alt (pat.node) {
@@ -1770,7 +1761,7 @@ fn parse_block(parser p) -> ast.block {
auto hi = p.get_hi_pos();
p.bump();
- auto bloc = index_block(p, stmts, expr);
+ auto bloc = rec(stmts=stmts, expr=expr, a=p.get_ann());
ret spanned[ast.block_](lo, hi, bloc);
}