Skip to content

Commit 80c6726

Browse files
committed
Pass correct lliterbody; can compile and run no-put iters.
1 parent 34c60b6 commit 80c6726

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/comp/middle/trans.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,7 @@ fn trans_for_each(@block_ctxt cx,
22382238
// escape. This could be determined upstream, and probably ought
22392239
// to be so, eventualy. For first cut, skip this. Null env.
22402240

2241-
auto env_ty = T_struct(vec(T_ptr(T_i8())));
2241+
auto env_ty = T_opaque_closure_ptr(cx.fcx.ccx.tn);
22422242

22432243

22442244
// Step 2: Declare foreach body function.
@@ -2283,11 +2283,19 @@ fn trans_for_each(@block_ctxt cx,
22832283
// Step 3: Call iter passing [lliterbody, llenv], plus other args.
22842284

22852285
alt (seq.node) {
2286+
22862287
case (ast.expr_call(?f, ?args, ?ann)) {
22872288

2289+
auto pair = cx.build.Alloca(T_fn_pair(cx.fcx.ccx.tn,
2290+
iter_body_llty));
2291+
auto code_cell = cx.build.GEP(pair,
2292+
vec(C_int(0),
2293+
C_int(abi.fn_field_code)));
2294+
cx.build.Store(lliterbody, code_cell);
2295+
22882296
// log "lliterbody: " + val_str(cx.fcx.ccx.tn, lliterbody);
22892297
ret trans_call(cx, f,
2290-
some[ValueRef](lliterbody),
2298+
some[ValueRef](cx.build.Load(pair)),
22912299
args,
22922300
ann);
22932301
}
@@ -3364,7 +3372,7 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
33643372
ret trans_ret(cx, e);
33653373
}
33663374

3367-
case (ast.expr_ret(?e)) {
3375+
case (ast.expr_put(?e)) {
33683376
ret trans_put(cx, e);
33693377
}
33703378

0 commit comments

Comments
 (0)