aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/ast.rs
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/ast.rs
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/ast.rs')
-rw-r--r--src/comp/front/ast.rs57
1 files changed, 12 insertions, 45 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) {