reindex the block index.
This commit is contained in:
@@ -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 {
|
fn is_call_expr(@expr e) -> bool {
|
||||||
alt (e.node) {
|
alt (e.node) {
|
||||||
case (expr_call(_, _, _)) {
|
case (expr_call(_, _, _)) {
|
||||||
|
|||||||
@@ -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_ {
|
fn index_block(vec[@ast.stmt] stmts, option.t[@ast.expr] expr) -> ast.block_ {
|
||||||
auto index = new_str_hash[ast.block_index_entry]();
|
auto index = new_str_hash[ast.block_index_entry]();
|
||||||
for (@ast.stmt s in stmts) {
|
for (@ast.stmt s in stmts) {
|
||||||
alt (s.node) {
|
ast.index_stmt(index, s);
|
||||||
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 */ }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ret rec(stmts=stmts, expr=expr, index=index);
|
ret rec(stmts=stmts, expr=expr, index=index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -734,6 +734,7 @@ fn fold_stmt[ENV](&ENV env, ast_fold[ENV] fld, &@stmt s) -> @stmt {
|
|||||||
|
|
||||||
fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block {
|
fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block {
|
||||||
|
|
||||||
|
auto index = new_str_hash[ast.block_index_entry]();
|
||||||
let ENV env_ = fld.update_env_for_block(env, blk);
|
let ENV env_ = fld.update_env_for_block(env, blk);
|
||||||
|
|
||||||
if (!fld.keep_going(env_)) {
|
if (!fld.keep_going(env_)) {
|
||||||
@@ -742,7 +743,9 @@ fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block {
|
|||||||
|
|
||||||
let vec[@ast.stmt] stmts = vec();
|
let vec[@ast.stmt] stmts = vec();
|
||||||
for (@ast.stmt s in blk.node.stmts) {
|
for (@ast.stmt s in blk.node.stmts) {
|
||||||
append[@ast.stmt](stmts, fold_stmt[ENV](env_, fld, s));
|
auto new_stmt = fold_stmt[ENV](env_, fld, s);
|
||||||
|
append[@ast.stmt](stmts, new_stmt);
|
||||||
|
ast.index_stmt(index, new_stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto expr = none[@ast.expr];
|
auto expr = none[@ast.expr];
|
||||||
@@ -755,8 +758,7 @@ fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: should we reindex?
|
ret respan(blk.span, rec(stmts=stmts, expr=expr, index=index));
|
||||||
ret respan(blk.span, rec(stmts=stmts, expr=expr, index=blk.node.index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_arm[ENV](&ENV env, ast_fold[ENV] fld, &arm a) -> arm {
|
fn fold_arm[ENV](&ENV env, ast_fold[ENV] fld, &arm a) -> arm {
|
||||||
|
|||||||
Reference in New Issue
Block a user