提交 6bcdb48e 编写于 作者: M Michael Sullivan

Disallow block as a variable name in preparation for it becoming a keyword.

上级 01675f34
......@@ -103,11 +103,11 @@ fn visit_expr(&@ctx cx, &@ast::expr ex, &scope sc, &vt[scope] v) {
case (_) { }
}
}
ast::expr_for_each(?decl, ?call, ?block) {
check_for_each(*cx, decl, call, block, sc, v);
ast::expr_for_each(?decl, ?call, ?blk) {
check_for_each(*cx, decl, call, blk, sc, v);
}
ast::expr_for(?decl, ?seq, ?block) {
check_for(*cx, decl, seq, block, sc, v);
ast::expr_for(?decl, ?seq, ?blk) {
check_for(*cx, decl, seq, blk, sc, v);
}
ast::expr_path(?pt) {
check_var(*cx, ex, pt, ex.id, false, sc);
......@@ -326,7 +326,7 @@ fn walk_pat(&mutable node_id[] found, &@ast::pat p) {
}
fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
&ast::block block, &scope sc, &vt[scope] v) {
&ast::block blk, &scope sc, &vt[scope] v) {
visit::visit_expr(call, sc, v);
alt (call.node) {
case (ast::expr_call(?f, ?args)) {
......@@ -339,12 +339,12 @@ fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
tys=data.unsafe_ts,
depends_on=deps(sc, data.root_vars),
mutable ok=valid);
visit::visit_block(block, @(*sc + ~[new_sc]), v);
visit::visit_block(blk, @(*sc + ~[new_sc]), v);
}
}
}
fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block block,
fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block blk,
&scope sc, &vt[scope] v) {
visit::visit_expr(seq, sc, v);
auto defnum = local.node.id;
......@@ -374,7 +374,7 @@ fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block block,
tys=unsafe,
depends_on=deps(sc, root_def),
mutable ok=valid);
visit::visit_block(block, @(*sc + ~[new_sc]), v);
visit::visit_block(blk, @(*sc + ~[new_sc]), v);
}
fn check_var(&ctx cx, &@ast::expr ex, &ast::path p, ast::node_id id,
......
......@@ -446,14 +446,14 @@ fn trans_recv(&@block_ctxt bcx, &dest dest, &@ast::expr expr) -> @block_ctxt {
ret bcx; // TODO
}
fn trans_block(&@block_ctxt cx, &dest dest, &ast::block block)
fn trans_block(&@block_ctxt cx, &dest dest, &ast::block blk)
-> @block_ctxt {
auto bcx = cx;
for each (@ast::local local in trans::block_locals(block)) {
for each (@ast::local local in trans::block_locals(blk)) {
bcx = trans::alloc_local(bcx, local).bcx;
}
for (@ast::stmt stmt in block.node.stmts) {
for (@ast::stmt stmt in blk.node.stmts) {
bcx = trans_stmt(bcx, stmt);
// If we hit a terminator, control won't go any further so
......@@ -461,7 +461,7 @@ fn trans_block(&@block_ctxt cx, &dest dest, &ast::block block)
if trans::is_terminated(bcx) { ret bcx; }
}
alt (block.node.expr) {
alt (blk.node.expr) {
some(?e) { bcx = trans_expr(bcx, dest, e); }
none { /* no-op */ }
}
......
......@@ -1147,7 +1147,7 @@ fn visit_fn_post(@wb_ctxt wbcx, &ast::_fn f,
}
fn keep_going(@wb_ctxt wbcx) -> bool { !wbcx.ignore && wbcx.success }
fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block block) -> bool {
fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block blk) -> bool {
auto wbcx = @rec(fcx = fcx,
mutable ignore = false,
mutable success = true);
......@@ -1163,7 +1163,7 @@ fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block block) -> bool {
visit_pat_pre=bind visit_pat_pre(wbcx, _),
visit_local_pre=bind visit_local_pre(wbcx, _)
with walk::default_visitor());
walk::walk_block(visit, block);
walk::walk_block(visit, blk);
ret wbcx.success;
}
}
......@@ -2598,14 +2598,14 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) {
write::nil_ty(fcx.ccx.tcx, node_id);
}
fn check_block(&@fn_ctxt fcx, &ast::block block) {
for (@ast::stmt s in block.node.stmts) { check_stmt(fcx, s); }
alt (block.node.expr) {
case (none) { write::nil_ty(fcx.ccx.tcx, block.node.id); }
fn check_block(&@fn_ctxt fcx, &ast::block blk) {
for (@ast::stmt s in blk.node.stmts) { check_stmt(fcx, s); }
alt (blk.node.expr) {
case (none) { write::nil_ty(fcx.ccx.tcx, blk.node.id); }
case (some(?e)) {
check_expr(fcx, e);
auto ety = expr_ty(fcx.ccx.tcx, e);
write::ty_only_fixup(fcx, block.node.id, ety);
write::ty_only_fixup(fcx, blk.node.id, ety);
}
}
}
......
......@@ -138,8 +138,8 @@ fn fold_mac_(&mac m, ast_fold fld) -> mac {
case (mac_embed_type(?ty)) {
mac_embed_type(fld.fold_ty(ty))
}
case (mac_embed_block(?block)) {
mac_embed_block(fld.fold_block(block))
case (mac_embed_block(?blk)) {
mac_embed_block(fld.fold_block(blk))
}
case (mac_ellipsis) { mac_ellipsis }
},
......@@ -388,16 +388,16 @@ fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
case (expr_while(?cond, ?body)) {
expr_while(fld.fold_expr(cond), fld.fold_block(body))
}
case (expr_for(?decl, ?expr, ?block)) {
case (expr_for(?decl, ?expr, ?blk)) {
expr_for(fld.fold_local(decl), fld.fold_expr(expr),
fld.fold_block(block))
fld.fold_block(blk))
}
case (expr_for_each(?decl, ?expr, ?block)) {
case (expr_for_each(?decl, ?expr, ?blk)) {
expr_for_each(fld.fold_local(decl), fld.fold_expr(expr),
fld.fold_block(block))
fld.fold_block(blk))
}
case (expr_do_while(?block, ?expr)) {
expr_do_while(fld.fold_block(block), fld.fold_expr(expr))
case (expr_do_while(?blk, ?expr)) {
expr_do_while(fld.fold_block(blk), fld.fold_expr(expr))
}
case (expr_alt(?expr, ?arms)) {
expr_alt(fld.fold_expr(expr), ivec::map(fld.fold_arm, arms))
......@@ -405,8 +405,8 @@ fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
case (expr_fn(?f)) {
expr_fn(fld.fold_fn(f))
}
case (expr_block(?block)) {
expr_block(fld.fold_block(block))
case (expr_block(?blk)) {
expr_block(fld.fold_block(blk))
}
case (expr_move(?el, ?er)) {
expr_move(fld.fold_expr(el), fld.fold_expr(er))
......
......@@ -174,6 +174,7 @@ fn bad_expr_word_table() -> hashmap[str, ()] {
words.insert("fn", ());
words.insert("pred", ());
words.insert("iter", ());
words.insert("block", ());
words.insert("import", ());
words.insert("export", ());
words.insert("let", ());
......@@ -1407,8 +1408,8 @@ fn parse_alt_expr(&parser p) -> @ast::expr {
if (p.peek() == token::LPAREN) { parens = true; p.bump(); }
auto pats = parse_pats(p);
if (parens) { expect(p, token::RPAREN); }
auto block = parse_block(p);
arms += ~[rec(pats=pats, block=block)];
auto blk = parse_block(p);
arms += ~[rec(pats=pats, block=blk)];
}
auto hi = p.get_hi_pos();
p.bump();
......
......@@ -601,7 +601,7 @@ fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded,
s.ann.post(ann_node);
}
fn print_if(&ps s, &@ast::expr test, &ast::block block,
fn print_if(&ps s, &@ast::expr test, &ast::block blk,
&option::t[@ast::expr] elseopt, bool chk) {
head(s, "if");
if (chk) {
......@@ -609,7 +609,7 @@ fn print_if(&ps s, &@ast::expr test, &ast::block block,
}
print_expr(s, test);
space(s.s);
print_block(s, block);
print_block(s, blk);
fn do_else(&ps s, option::t[@ast::expr] els) {
alt (els) {
case (some(?_else)) {
......@@ -773,11 +773,11 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
word_space(s, "as");
print_type(s, *ty);
}
case (ast::expr_if(?test, ?block, ?elseopt)) {
print_if(s, test, block, elseopt, false);
case (ast::expr_if(?test, ?blk, ?elseopt)) {
print_if(s, test, blk, elseopt, false);
}
case (ast::expr_if_check(?test, ?block, ?elseopt)) {
print_if(s, test, block, elseopt, true);
case (ast::expr_if_check(?test, ?blk, ?elseopt)) {
print_if(s, test, blk, elseopt, true);
}
case (ast::expr_ternary(?test, ?then, ?els)) {
print_expr(s, test);
......@@ -788,13 +788,13 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
word_space(s, ":");
print_expr(s, els);
}
case (ast::expr_while(?test, ?block)) {
case (ast::expr_while(?test, ?blk)) {
head(s, "while");
print_expr(s, test);
space(s.s);
print_block(s, block);
print_block(s, blk);
}
case (ast::expr_for(?decl, ?expr, ?block)) {
case (ast::expr_for(?decl, ?expr, ?blk)) {
head(s, "for");
popen(s);
print_for_decl(s, decl);
......@@ -803,9 +803,9 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
print_expr(s, expr);
pclose(s);
space(s.s);
print_block(s, block);
print_block(s, blk);
}
case (ast::expr_for_each(?decl, ?expr, ?block)) {
case (ast::expr_for_each(?decl, ?expr, ?blk)) {
head(s, "for each");
popen(s);
print_for_decl(s, decl);
......@@ -814,12 +814,12 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
print_expr(s, expr);
pclose(s);
space(s.s);
print_block(s, block);
print_block(s, blk);
}
case (ast::expr_do_while(?block, ?expr)) {
case (ast::expr_do_while(?blk, ?expr)) {
head(s, "do");
space(s.s);
print_block(s, block);
print_block(s, blk);
space(s.s);
word_space(s, "while");
print_expr(s, expr);
......@@ -853,14 +853,14 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
space(s.s);
print_block(s, f.body);
}
case (ast::expr_block(?block)) {
case (ast::expr_block(?blk)) {
// containing cbox, will be closed by print-block at }
cbox(s, indent_unit);
// head-box, will be closed by print-block after {
ibox(s, 0u);
print_block(s, block);
print_block(s, blk);
}
case (ast::expr_move(?lhs, ?rhs)) {
print_expr(s, lhs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册