Skip to content

Commit 5221592

Browse files
committed
---
yaml --- r: 3055 b: refs/heads/master c: d65ad8c h: refs/heads/master i: 3053: 63a2e57 3051: 5fd2398 3047: eb7f952 3039: f534350 v: v3
1 parent f1e7e65 commit 5221592

File tree

16 files changed

+150
-223
lines changed

16 files changed

+150
-223
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ff8af3c2db5e778dc9d8dad16538a2c38a124df7
2+
refs/heads/master: d65ad8c31c47a14a2b23e9991a34c02e79ec741e

trunk/src/comp/front/ast.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,17 @@ tag init_op {
221221
type initializer = rec(init_op op,
222222
@expr expr);
223223
224-
type local = rec(option::t[@ty] ty,
224+
type local_ = rec(option::t[@ty] ty,
225225
bool infer,
226226
ident ident,
227227
option::t[initializer] init,
228228
def_id id,
229229
ann ann);
230+
type local = spanned[@local_];
230231
231232
type decl = spanned[decl_];
232233
tag decl_ {
233-
decl_local(@local);
234+
decl_local(@local_);
234235
decl_item(@item);
235236
}
236237
@@ -266,8 +267,8 @@ tag expr_ {
266267
expr_cast(@expr, @ty, ann);
267268
expr_if(@expr, block, option::t[@expr], ann);
268269
expr_while(@expr, block, ann);
269-
expr_for(@decl, @expr, block, ann);
270-
expr_for_each(@decl, @expr, block, ann);
270+
expr_for(@local, @expr, block, ann);
271+
expr_for_each(@local, @expr, block, ann);
271272
expr_do_while(block, @expr, ann);
272273
expr_alt(@expr, vec[arm], ann);
273274
expr_block(block, ann);

trunk/src/comp/front/parser.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,15 +1367,14 @@ fn parse_else_expr(&parser p) -> @ast::expr {
13671367
}
13681368
}
13691369

1370-
fn parse_head_local(&parser p) -> @ast::decl {
1370+
fn parse_head_local(&parser p) -> @ast::local {
13711371
auto lo = p.get_lo_pos();
1372-
let @ast::local local;
1373-
if (is_word(p, "auto")) {
1374-
local = parse_auto_local(p);
1375-
} else {
1376-
local = parse_typed_local(p);
1377-
}
1378-
ret @spanned(lo, p.get_hi_pos(), ast::decl_local(local));
1372+
let @ast::local_ l = if (is_word(p, "auto")) {
1373+
parse_auto_local(p)
1374+
} else {
1375+
parse_typed_local(p)
1376+
};
1377+
ret @spanned(lo, p.get_hi_pos(), l);
13791378
}
13801379

13811380

@@ -1567,7 +1566,7 @@ fn parse_pat(&parser p) -> @ast::pat {
15671566
}
15681567

15691568
fn parse_local_full(&option::t[@ast::ty] tyopt,
1570-
&parser p) -> @ast::local {
1569+
&parser p) -> @ast::local_ {
15711570
auto ident = parse_value_ident(p);
15721571
auto init = parse_initializer(p);
15731572
ret @rec(ty = tyopt,
@@ -1578,12 +1577,12 @@ fn parse_local_full(&option::t[@ast::ty] tyopt,
15781577
ann = p.get_ann());
15791578
}
15801579

1581-
fn parse_typed_local(&parser p) -> @ast::local {
1580+
fn parse_typed_local(&parser p) -> @ast::local_ {
15821581
auto ty = parse_ty(p);
15831582
ret parse_local_full(some(ty), p);
15841583
}
15851584

1586-
fn parse_auto_local(&parser p) -> @ast::local {
1585+
fn parse_auto_local(&parser p) -> @ast::local_ {
15871586
ret parse_local_full(none[@ast::ty], p);
15881587
}
15891588

trunk/src/comp/middle/alias.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,13 @@ fn arm_defnums(&ast::arm arm) -> vec[def_num] {
247247
ret dnums;
248248
}
249249

250-
fn check_for_each(&ctx cx, &@ast::decl decl, &@ast::expr call,
250+
fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
251251
&ast::block block, &scope sc, &vt[scope] v) {
252252
visit::visit_expr(call, sc, v);
253253
alt (call.node) {
254254
case (ast::expr_call(?f, ?args, _)) {
255255
auto data = check_call(cx, f, args, sc);
256-
auto defnum = alt (decl.node) {
257-
case (ast::decl_local(?l)) { l.id._1 }
258-
};
256+
auto defnum = local.node.id._1;
259257

260258
auto new_sc = @rec(root_vars=data.root_vars,
261259
block_defnum=defnum,
@@ -268,12 +266,10 @@ fn check_for_each(&ctx cx, &@ast::decl decl, &@ast::expr call,
268266
}
269267
}
270268

271-
fn check_for(&ctx cx, &@ast::decl decl, &@ast::expr seq,
269+
fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq,
272270
&ast::block block, &scope sc, &vt[scope] v) {
273271
visit::visit_expr(seq, sc, v);
274-
auto defnum = alt (decl.node) {
275-
case (ast::decl_local(?l)) { l.id._1 }
276-
};
272+
auto defnum = local.node.id._1;
277273

278274
auto root = expr_root(cx, seq, false);
279275
auto root_def = alt (path_def_id(cx, root.ex)) {

trunk/src/comp/middle/resolve.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tag scope {
3939
scope_item(@ast::item);
4040
scope_fn(ast::fn_decl, vec[ast::ty_param]);
4141
scope_native_item(@ast::native_item);
42-
scope_loop(@ast::decl); // there's only 1 decl per loop.
42+
scope_loop(@ast::local_); // there's only 1 decl per loop.
4343
scope_block(ast::block);
4444
scope_arm(ast::arm);
4545
}
@@ -341,10 +341,10 @@ fn visit_arm_with_scope(&ast::arm a, &scopes sc, &vt[scopes] v) {
341341
fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
342342
auto new_sc = alt (x.node) {
343343
case (ast::expr_for(?d, _, _, _)) {
344-
cons[scope](scope_loop(d), @sc)
344+
cons[scope](scope_loop(d.node), @sc)
345345
}
346346
case (ast::expr_for_each(?d, _, _, _)) {
347-
cons[scope](scope_loop(d), @sc)
347+
cons[scope](scope_loop(d.node), @sc)
348348
}
349349
case (_) { sc }
350350
};
@@ -540,14 +540,10 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident id, namespace ns)
540540
case (scope_fn(?decl, ?ty_params)) {
541541
ret lookup_in_fn(id, decl, ty_params, ns);
542542
}
543-
case (scope_loop(?d)) {
543+
case (scope_loop(?local)) {
544544
if (ns == ns_value) {
545-
alt (d.node) {
546-
case (ast::decl_local(?local)) {
547-
if (str::eq(local.ident, id)) {
548-
ret some(ast::def_local(local.id));
549-
}
550-
}
545+
if (str::eq(local.ident, id)) {
546+
ret some(ast::def_local(local.id));
551547
}
552548
}
553549
}

trunk/src/comp/middle/trans.rs

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,11 +4004,11 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond,
40044004
}
40054005

40064006
fn trans_for(&@block_ctxt cx,
4007-
&@ast::decl decl,
4007+
&@ast::local local,
40084008
&@ast::expr seq,
40094009
&ast::block body) -> result {
40104010
fn inner(&@block_ctxt cx,
4011-
@ast::local local, ValueRef curr,
4011+
@ast::local_ local, ValueRef curr,
40124012
ty::t t, ast::block body,
40134013
@block_ctxt outer_next_cx) -> result {
40144014

@@ -4027,19 +4027,11 @@ fn trans_for(&@block_ctxt cx,
40274027
ret res(next_cx, C_nil());
40284028
}
40294029

4030-
4031-
let @ast::local local;
4032-
alt (decl.node) {
4033-
case (ast::decl_local(?loc)) {
4034-
local = loc;
4035-
}
4036-
}
4037-
40384030
auto next_cx = new_sub_block_ctxt(cx, "next");
40394031
auto seq_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, seq);
40404032
auto seq_res = trans_expr(cx, seq);
40414033
auto it = iter_sequence(seq_res.bcx, seq_res.val, seq_ty,
4042-
bind inner(_, local, _, _, body, next_cx));
4034+
bind inner(_, local.node, _, _, body, next_cx));
40434035
it.bcx.build.Br(next_cx.llbb);
40444036
ret res(next_cx, it.val);
40454037
}
@@ -4074,13 +4066,8 @@ fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
40744066
}
40754067
}
40764068

4077-
fn walk_decl(env e, &@ast::decl decl) {
4078-
alt (decl.node) {
4079-
case (ast::decl_local(?local)) {
4080-
e.decls.insert(local.id, ());
4081-
}
4082-
case (_) {}
4083-
}
4069+
fn walk_local(env e, &@ast::local local) {
4070+
e.decls.insert(local.node.id, ());
40844071
}
40854072

40864073
let vec[ast::def_id] refs = [];
@@ -4090,7 +4077,7 @@ fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
40904077
decls=decls,
40914078
def_map=cx.fcx.lcx.ccx.tcx.def_map);
40924079

4093-
auto visitor = @rec(visit_decl_pre = bind walk_decl(e, _),
4080+
auto visitor = @rec(visit_local_pre = bind walk_local(e, _),
40944081
visit_expr_pre = bind walk_expr(e, _)
40954082
with walk::default_visitor());
40964083
walk::walk_block(*visitor, bloc);
@@ -4108,7 +4095,7 @@ fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
41084095
}
41094096

41104097
fn trans_for_each(&@block_ctxt cx,
4111-
&@ast::decl decl,
4098+
&@ast::local local,
41124099
&@ast::expr seq,
41134100
&ast::block body) -> result {
41144101
/*
@@ -4139,14 +4126,8 @@ fn trans_for_each(&@block_ctxt cx,
41394126

41404127
auto lcx = cx.fcx.lcx;
41414128
// FIXME: possibly support alias-mode here?
4142-
auto decl_ty = ty::mk_nil(lcx.ccx.tcx);
4143-
auto decl_id;
4144-
alt (decl.node) {
4145-
case (ast::decl_local(?local)) {
4146-
decl_ty = node_ann_type(lcx.ccx, local.ann);
4147-
decl_id = local.id;
4148-
}
4149-
}
4129+
auto decl_ty = node_ann_type(lcx.ccx, local.node.ann);
4130+
auto decl_id = local.node.id;
41504131

41514132
auto upvars = collect_upvars(cx, body, decl_id);
41524133
auto upvar_count = vec::len[ast::def_id](upvars);
@@ -6901,7 +6882,7 @@ fn trans_anon_obj(@block_ctxt cx, &span sp,
69016882
ret res(bcx, pair);
69026883
}
69036884

6904-
fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
6885+
fn init_local(&@block_ctxt cx, &@ast::local_ local) -> result {
69056886

69066887
// Make a note to drop this slot on the way out.
69076888
assert (cx.fcx.lllocals.contains_key(local.id));
@@ -7064,7 +7045,7 @@ fn trans_block_cleanups(&@block_ctxt cx,
70647045
ret bcx;
70657046
}
70667047

7067-
iter block_locals(&ast::block b) -> @ast::local {
7048+
iter block_locals(&ast::block b) -> @ast::local_ {
70687049
// FIXME: putting from inside an iter block doesn't work, so we can't
70697050
// use the index here.
70707051
for (@ast::stmt s in b.node.stmts) {
@@ -7117,7 +7098,7 @@ fn alloc_ty(&@block_ctxt cx, &ty::t t) -> result {
71177098
ret res(cx, val);
71187099
}
71197100

7120-
fn alloc_local(&@block_ctxt cx, &@ast::local local) -> result {
7101+
fn alloc_local(&@block_ctxt cx, &@ast::local_ local) -> result {
71217102
auto t = node_ann_type(cx.fcx.lcx.ccx, local.ann);
71227103
auto r = alloc_ty(cx, t);
71237104
r.bcx.fcx.lllocals.insert(local.id, r.val);
@@ -7126,7 +7107,7 @@ fn alloc_local(&@block_ctxt cx, &@ast::local local) -> result {
71267107

71277108
fn trans_block(&@block_ctxt cx, &ast::block b, &out_method output) -> result {
71287109
auto bcx = cx;
7129-
for each (@ast::local local in block_locals(b)) {
7110+
for each (@ast::local_ local in block_locals(b)) {
71307111
*bcx = rec(sp=local_rhs_span(local, cx.sp) with *bcx);
71317112
bcx = alloc_local(bcx, local).bcx;
71327113
}

trunk/src/comp/middle/tstate/annotate.rs

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,7 @@ import std::option;
33
import std::option::some;
44
import std::option::none;
55

6-
import front::ast;
7-
import front::ast::ident;
8-
import front::ast::def_id;
9-
import front::ast::ann;
10-
import front::ast::item;
11-
import front::ast::_fn;
12-
import front::ast::_mod;
13-
import front::ast::crate;
14-
import front::ast::_obj;
15-
import front::ast::ty_param;
16-
import front::ast::item_fn;
17-
import front::ast::item_obj;
18-
import front::ast::item_ty;
19-
import front::ast::item_tag;
20-
import front::ast::item_const;
21-
import front::ast::item_mod;
22-
import front::ast::item_native_mod;
23-
import front::ast::expr;
24-
import front::ast::elt;
25-
import front::ast::field;
26-
import front::ast::decl;
27-
import front::ast::decl_local;
28-
import front::ast::decl_item;
29-
import front::ast::initializer;
30-
import front::ast::local;
31-
import front::ast::arm;
32-
import front::ast::stmt;
33-
import front::ast::stmt_decl;
34-
import front::ast::stmt_expr;
35-
import front::ast::block;
36-
import front::ast::block_;
37-
import front::ast::method;
38-
6+
import front::ast::*;
397
import middle::ty::expr_ann;
408

419
import util::common::uistr;
@@ -82,13 +50,8 @@ fn collect_ids_stmt(&@stmt s, @mutable vec[uint] res) -> () {
8250
}
8351
}
8452

85-
fn collect_ids_decl(&@decl d, @mutable vec[uint] res) -> () {
86-
alt (d.node) {
87-
case (decl_local(?l)) {
88-
vec::push(*res, l.ann.id);
89-
}
90-
case (_) {}
91-
}
53+
fn collect_ids_local(&@local l, @mutable vec[uint] res) -> () {
54+
vec::push(*res, l.node.ann.id);
9255
}
9356

9457
fn node_ids_in_fn(&_fn f, &span sp, &ident i, &def_id d, &ann a,
@@ -97,7 +60,7 @@ fn node_ids_in_fn(&_fn f, &span sp, &ident i, &def_id d, &ann a,
9760
collect_ids = rec(visit_expr_pre = bind collect_ids_expr(_,res),
9861
visit_block_pre = bind collect_ids_block(_,res),
9962
visit_stmt_pre = bind collect_ids_stmt(_,res),
100-
visit_decl_pre = bind collect_ids_decl(_,res)
63+
visit_local_pre = bind collect_ids_local(_,res)
10164
with collect_ids);
10265
walk::walk_fn(collect_ids, f, sp, i, d, a);
10366
}

trunk/src/comp/middle/tstate/collect_locals.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,10 @@ import util::common::respan;
3131
type ctxt = rec(@mutable vec[constr] cs,
3232
ty::ctxt tcx);
3333

34-
fn collect_local(&ctxt cx, &@decl d) -> () {
35-
alt (d.node) {
36-
case (decl_local(?loc)) {
37-
log("collect_local: pushing " + loc.ident);
38-
vec::push[constr](*cx.cs, respan(d.span,
39-
ninit(loc.ident, loc.id)));
40-
}
41-
case (_) { ret; }
42-
}
34+
fn collect_local(&ctxt cx, &@local loc) -> () {
35+
log("collect_local: pushing " + loc.node.ident);
36+
vec::push[constr](*cx.cs, respan(loc.span,
37+
ninit(loc.node.ident, loc.node.id)));
4338
}
4439

4540
fn collect_pred(&ctxt cx, &@expr e) -> () {
@@ -77,7 +72,7 @@ fn find_locals(&ty::ctxt tcx, &_fn f, &span sp, &ident i, &def_id d, &ann a)
7772
-> ctxt {
7873
let ctxt cx = rec(cs=@mutable vec::alloc[constr](0u), tcx=tcx);
7974
auto visitor = walk::default_visitor();
80-
visitor = rec(visit_decl_pre=bind collect_local(cx,_),
75+
visitor = rec(visit_local_pre=bind collect_local(cx,_),
8176
visit_expr_pre=bind collect_pred(cx,_)
8277
with visitor);
8378
walk_fn(visitor, f, sp, i, d, a);

0 commit comments

Comments
 (0)