aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <[email protected]>2011-03-11 17:29:53 -0500
committerRafael Ávila de Espíndola <[email protected]>2011-03-11 17:35:33 -0500
commit74d891517be8f6299b0626c26400dd54dd1aac6c (patch)
treeef74eac61cfca9c57973a41622ac35a5cd164d25 /src/comp/front
parentRe-XFAIL size-and-align.rs to put out burning tinderbox (diff)
downloadrust-74d891517be8f6299b0626c26400dd54dd1aac6c.tar.xz
rust-74d891517be8f6299b0626c26400dd54dd1aac6c.zip
reindex the block index.
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs38
-rw-r--r--src/comp/front/parser.rs36
2 files changed, 39 insertions, 35 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index c17eddee..b39f3d4c 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -435,6 +435,44 @@ 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.name, t);
+ vid += 1u;
+ }
+ }
+ case (ast.item_obj(?i, _, _, _, _)) {
+ index.insert(i, ast.bie_item(it));
+ }
+ }
+ }
+ }
+ }
+ case (_) { /* fall through */ }
+ }
+}
+
fn is_call_expr(@expr e) -> bool {
alt (e.node) {
case (expr_call(_, _, _)) {
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 58cbac00..cdd65539 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1480,41 +1480,7 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt {
fn index_block(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) {
- 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.name, t);
- vid += 1u;
- }
- }
- case (ast.item_obj(?i, _, _, _, _)) {
- index.insert(i, ast.bie_item(it));
- }
- }
- }
- }
- }
- case (_) { /* fall through */ }
- }
+ ast.index_stmt(index, s);
}
ret rec(stmts=stmts, expr=expr, index=index);
}