Skip to content

Commit cc14fd8

Browse files
committed
---
yaml --- r: 5896 b: refs/heads/master c: 4ebbbe5 h: refs/heads/master v: v3
1 parent 974fca1 commit cc14fd8

File tree

10 files changed

+83
-87
lines changed

10 files changed

+83
-87
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: 9bb4595c534ffcd0731ed778beb62bb80d7f9217
2+
refs/heads/master: 4ebbbe597e44dbed0da3027fbf4e564390e0daeb

trunk/src/comp/metadata/cstore.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ fn have_crate_data(cstore: cstore, cnum: ast::crate_num) -> bool {
7272
ret p(cstore).metas.contains_key(cnum);
7373
}
7474

75-
iter iter_crate_data(cstore: cstore) ->
76-
@{key: ast::crate_num, val: crate_metadata} {
77-
for each kv: @{key: ast::crate_num, val: crate_metadata} in
78-
p(cstore).metas.items() {
79-
put kv;
80-
}
75+
fn iter_crate_data(cstore: cstore, i: block(ast::crate_num, crate_metadata)) {
76+
p(cstore).metas.items {|k,v| i(k, v);};
8177
}
8278

8379
fn add_used_crate_file(cstore: cstore, lib: str) {

trunk/src/comp/metadata/encoder.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,20 +371,19 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer) ->
371371
[entry<int>] {
372372
let index: [entry<int>] = [];
373373
ebml::start_tag(ebml_w, tag_items_data);
374-
for each kvp: @{key: node_id, val: middle::ast_map::ast_node} in
375-
ecx.ccx.ast_map.items() {
376-
alt kvp.val {
374+
ecx.ccx.ast_map.items {|key, val|
375+
alt val {
377376
middle::ast_map::node_item(i) {
378-
index += [{val: kvp.key, pos: ebml_w.writer.tell()}];
377+
index += [{val: key, pos: ebml_w.writer.tell()}];
379378
encode_info_for_item(ecx, ebml_w, i, index);
380379
}
381380
middle::ast_map::node_native_item(i) {
382-
index += [{val: kvp.key, pos: ebml_w.writer.tell()}];
381+
index += [{val: key, pos: ebml_w.writer.tell()}];
383382
encode_info_for_native_item(ecx, ebml_w, i);
384383
}
385384
_ { }
386385
}
387-
}
386+
};
388387
ebml::end_tag(ebml_w);
389388
ret index;
390389
}
@@ -544,9 +543,9 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
544543

545544
// Pull the cnums and names out of cstore
546545
let pairs: [mutable numname] = [mutable];
547-
for each hashkv: hashkv in cstore::iter_crate_data(cstore) {
548-
pairs += [mutable {crate: hashkv.key, ident: hashkv.val.name}];
549-
}
546+
cstore::iter_crate_data(cstore) {|key, val|
547+
pairs += [mutable {crate: key, ident: val.name}];
548+
};
550549

551550
// Sort by cnum
552551
fn lteq(kv1: numname, kv2: numname) -> bool { kv1.crate <= kv2.crate }

trunk/src/comp/middle/ast_map.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,13 @@ fn new_smallintmap_int_adapter<@V>() -> std::map::hashmap<int, V> {
8686
// the entire codebase adapting all the callsites to the different
8787
// interface.
8888
// FIXME: hashmap and smallintmap should support the same interface.
89-
fn new_smallintmap_adapter<@K,
90-
@V>(key_idx: fn(K) -> uint, idx_key: fn(uint) -> K)
91-
-> std::map::hashmap<K, V> {
89+
fn new_smallintmap_adapter<@K, @V>(key_idx: fn(K) -> uint,
90+
idx_key: fn(uint) -> K)
91+
-> std::map::hashmap<K, V> {
9292

93-
obj adapter<@K,
94-
@V>(map: smallintmap::smallintmap<V>,
95-
key_idx: fn(K) -> uint,
96-
idx_key: fn(uint) -> K) {
93+
obj adapter<@K, @V>(map: smallintmap::smallintmap<V>,
94+
key_idx: fn(K) -> uint,
95+
idx_key: fn(uint) -> K) {
9796

9897
fn size() -> uint { fail }
9998

@@ -117,22 +116,29 @@ fn new_smallintmap_adapter<@K,
117116

118117
fn rehash() { fail }
119118

120-
iter items() -> @{key: K, val: V} {
119+
fn items(it: block(K, V)) {
121120
let idx = 0u;
122-
for item: option::t<V> in map.v {
121+
for item in map.v {
123122
alt item {
124123
option::some(elt) {
125-
let value = elt;
126-
let key = idx_key(idx);
127-
put @{key: key, val: value};
124+
it(idx_key(idx), elt);
128125
}
129126
option::none. { }
130127
}
131128
idx += 1u;
132129
}
133130
}
134-
iter keys() -> K {
135-
for each p: @{key: K, val: V} in self.items() { put p.key; }
131+
fn keys(it: block(K)) {
132+
let idx = 0u;
133+
for item in map.v {
134+
if item != option::none { it(idx_key(idx)); }
135+
idx += 1u;
136+
}
137+
}
138+
fn values(it: block(V)) {
139+
for item in map.v {
140+
alt item { option::some(elt) { it(elt); } _ {} }
141+
}
136142
}
137143
}
138144

trunk/src/comp/middle/resolve.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ type scopes = list<scope>;
4848
tag import_state {
4949
todo(ast::node_id, ast::ident, [ast::ident], codemap::span, scopes);
5050
resolving(span);
51-
resolved(option::t<def>,
52-
53-
/* value */
54-
option::t<def>,
55-
56-
/* type */
51+
resolved(option::t<def>, /* value */
52+
option::t<def>, /* type */
5753
option::t<def>); /* module */
5854
}
5955

@@ -241,15 +237,14 @@ fn map_crate(e: @env, c: @ast::crate) {
241237
}
242238

243239
fn resolve_imports(e: env) {
244-
for each it: @{key: ast::node_id, val: import_state} in e.imports.items()
245-
{
246-
alt it.val {
240+
e.imports.values {|v|
241+
alt v {
247242
todo(node_id, name, path, span, scopes) {
248243
resolve_import(e, local_def(node_id), name, path, span, scopes);
249244
}
250245
resolved(_, _, _) { }
251246
}
252-
}
247+
};
253248
e.sess.abort_if_errors();
254249
}
255250

@@ -1188,12 +1183,9 @@ fn lookup_external(e: env, cnum: int, ids: [ident], ns: namespace) ->
11881183
fn check_for_collisions(e: @env, c: ast::crate) {
11891184
// Module indices make checking those relatively simple -- just check each
11901185
// name for multiple entities in the same namespace.
1191-
for each m: @{key: ast::node_id, val: @indexed_mod} in e.mod_map.items() {
1192-
for each name: @{key: ident, val: list<mod_index_entry>} in
1193-
m.val.index.items() {
1194-
check_mod_name(*e, name.key, name.val);
1195-
}
1196-
}
1186+
e.mod_map.values {|val|
1187+
val.index.items {|k, v| check_mod_name(*e, k, v); };
1188+
};
11971189
// Other scopes have to be checked the hard way.
11981190
let v =
11991191
@{visit_item: bind check_item(e, _, _, _),
@@ -1426,7 +1418,7 @@ fn check_bad_exports(e: @env) {
14261418
ns_type, inside));
14271419
}
14281420

1429-
for each @{val: val, _} in e.mod_map.items() {
1421+
e.mod_map.values {|val|
14301422
alt val.m {
14311423
some(m) {
14321424
for vi in m.view_items {
@@ -1447,7 +1439,7 @@ fn check_bad_exports(e: @env) {
14471439
}
14481440
none. { }
14491441
}
1450-
}
1442+
};
14511443
}
14521444

14531445
// Local Variables:

trunk/src/comp/middle/trans.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,10 +1249,10 @@ fn make_generic_glue(cx: @local_ctxt, sp: span, t: ty::t, llfn: ValueRef,
12491249
}
12501250

12511251
fn emit_tydescs(ccx: @crate_ctxt) {
1252-
for each pair: @{key: ty::t, val: @tydesc_info} in ccx.tydescs.items() {
1252+
ccx.tydescs.items {|key, val|
12531253
let glue_fn_ty = T_ptr(T_glue_fn(*ccx));
12541254
let cmp_fn_ty = T_ptr(T_cmp_glue_fn(*ccx));
1255-
let ti = pair.val;
1255+
let ti = val;
12561256
let take_glue =
12571257
alt ti.take_glue {
12581258
none. { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
@@ -1274,7 +1274,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
12741274
some(v) { ccx.stats.n_real_glues += 1u; v }
12751275
};
12761276

1277-
let shape = shape::shape_of(ccx, pair.key, ti.ty_params,
1277+
let shape = shape::shape_of(ccx, key, ti.ty_params,
12781278
ti.is_obj_body);
12791279
let shape_tables =
12801280
llvm::LLVMConstPointerCast(ccx.shape_cx.llshapetables,
@@ -1303,7 +1303,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
13031303
llvm::LLVMSetGlobalConstant(gvar, True);
13041304
llvm::LLVMSetLinkage(gvar,
13051305
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
1306-
}
1306+
};
13071307
}
13081308

13091309
fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
@@ -6144,10 +6144,10 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
61446144
llvm::LLVMSetLinkage(map,
61456145
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
61466146
let elts: [ValueRef] = [];
6147-
for each item: @{key: str, val: ValueRef} in ccx.module_data.items() {
6148-
let elt = C_struct([p2i(C_cstr(ccx, item.key)), p2i(item.val)]);
6147+
ccx.module_data.items {|key, val|
6148+
let elt = C_struct([p2i(C_cstr(ccx, key)), p2i(val)]);
61496149
elts += [elt];
6150-
}
6150+
};
61516151
let term = C_struct([C_int(0), C_int(0)]);
61526152
elts += [term];
61536153
llvm::LLVMSetInitializer(map, C_array(elttype, elts));

trunk/src/comp/middle/trans_alt.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
356356
Br(bcx, guard_cx.llbb);
357357
// Temporarily set bindings. They'll be rewritten to PHI nodes for
358358
// the actual arm block.
359-
for each @{key: key, val: val} in data.id_map.items() {
359+
data.id_map.items {|key, val|
360360
let local = local_mem(option::get(assoc(key, m[0].bound)));
361361
bcx.fcx.lllocals.insert(val, local);
362-
}
362+
};
363363
let {bcx: guard_bcx, val: guard_val} =
364364
trans::trans_temp_expr(guard_cx, e);
365365
guard_bcx = trans::trans_block_cleanups(guard_bcx, guard_cx);
@@ -582,7 +582,7 @@ fn make_phi_bindings(bcx: @block_ctxt, map: [exit_node],
582582
ids: ast_util::pat_id_map) -> bool {
583583
let our_block = bcx.llbb as uint;
584584
let success = true;
585-
for each @{key: name, val: node_id} in ids.items() {
585+
ids.items {|name, node_id|
586586
let llbbs = [];
587587
let vals = [];
588588
for ex: exit_node in map {
@@ -597,10 +597,10 @@ fn make_phi_bindings(bcx: @block_ctxt, map: [exit_node],
597597
let local = Phi(bcx, val_ty(vals[0]), vals, llbbs);
598598
bcx.fcx.lllocals.insert(node_id, local_mem(local));
599599
} else { success = false; }
600-
}
600+
};
601601
if success {
602602
// Copy references that the alias analysis considered unsafe
603-
for each @{val: node_id, _} in ids.items() {
603+
ids.values {|node_id|
604604
if bcx_ccx(bcx).copy_map.contains_key(node_id) {
605605
let local = alt bcx.fcx.lllocals.get(node_id) {
606606
local_mem(x) { x }
@@ -613,7 +613,7 @@ fn make_phi_bindings(bcx: @block_ctxt, map: [exit_node],
613613
add_clean(bcx, alloc, e_ty);
614614
bcx.fcx.lllocals.insert(node_id, local_mem(alloc));
615615
}
616-
}
616+
};
617617
} else {
618618
Unreachable(bcx);
619619
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,9 @@ fn norm_a_constraint(id: def_id, c: constraint) -> [norm_constraint] {
539539
// non-exhaustive match in trans.
540540
fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
541541
let rslt: [norm_constraint] = [];
542-
for each p: @{key: def_id, val: constraint} in
543-
fcx.enclosing.constrs.items() {
544-
rslt += norm_a_constraint(p.key, p.val);
545-
}
542+
fcx.enclosing.constrs.items {|key, val|
543+
rslt += norm_a_constraint(key, val);
544+
};
546545
ret rslt;
547546
}
548547

@@ -861,17 +860,16 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
861860
}
862861

863862

864-
for each p: @{key: def_id, val: constraint} in
865-
fcx.enclosing.constrs.items() {
863+
fcx.enclosing.constrs.values {|val|
866864
// replace any occurrences of the src def_id with the
867865
// dest def_id
868-
let insts = find_instances(fcx, subst, p.val);
866+
let insts = find_instances(fcx, subst, val);
869867
for p: {from: uint, to: uint} in insts {
870868
if promises_(p.from, src_post) {
871869
set_in_poststate_(p.to, target_post);
872870
}
873871
}
874-
}
872+
};
875873
}
876874

877875

trunk/src/comp/syntax/ext/simplext.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> option::t<bindings> {
172172
alt sel(match_expr(e)) { none. { ret none; } _ { } }
173173
}
174174
let never_mind: bool = false;
175-
for each pair: @{key: ident, val: selector} in b.real_binders.items() {
176-
alt pair.val(match_expr(e)) {
175+
b.real_binders.items {|key, val|
176+
alt val(match_expr(e)) {
177177
none. { never_mind = true; }
178-
some(mtc) { res.insert(pair.key, mtc); }
178+
some(mtc) { res.insert(key, mtc); }
179179
}
180-
}
180+
};
181181
//HACK: `ret` doesn't work in `for each`
182182
if never_mind { ret none; }
183183
ret some(res);
@@ -243,7 +243,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option::t<arb_depth<matchable>>,
243243
}
244244

245245
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */
246-
iter free_vars(b: bindings, e: @expr) -> ident {
246+
fn free_vars(b: bindings, e: @expr, it: block(ident)) {
247247
let idents: hashmap<ident, ()> = new_str_hash::<()>();
248248
fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
249249
idents: hashmap<ident, ()>) -> ident {
@@ -257,7 +257,7 @@ iter free_vars(b: bindings, e: @expr) -> ident {
257257
with *default_ast_fold()};
258258
let f = make_fold(f_pre);
259259
f.fold_expr(e); // ignore result
260-
for each id: ident in idents.keys() { put id; }
260+
idents.keys {|x| it(x); };
261261
}
262262

263263

@@ -273,7 +273,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
273273
let repeat: option::t<{rep_count: uint, name: ident}> = none;
274274
/* we need to walk over all the free vars in lockstep, except for
275275
the leaves, which are just duplicated */
276-
for each fv: ident in free_vars(b, repeat_me) {
276+
free_vars(b, repeat_me) {|fv|
277277
let cur_pos = follow(b.get(fv), idx_path);
278278
alt cur_pos {
279279
leaf(_) { }
@@ -295,7 +295,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
295295
}
296296
}
297297
}
298-
}
298+
};
299299
alt repeat {
300300
none. {
301301
cx.span_fatal(repeat_me.span,

0 commit comments

Comments
 (0)