rustc: Allow arguments to be captured as upvars. std.rc compiles now, except for the lack of a main fn.

This commit is contained in:
Patrick Walton 2011-03-19 14:26:12 -07:00
parent c710c9a1b8
commit 8e597b295f

View File

@ -3002,7 +3002,12 @@ fn trans_for_each(@block_ctxt cx,
auto llbinding; auto llbinding;
alt (cx.fcx.lllocals.find(did)) { alt (cx.fcx.lllocals.find(did)) {
case (none[ValueRef]) { case (none[ValueRef]) {
llbinding = cx.fcx.llupvars.get(did); alt (cx.fcx.llupvars.find(did)) {
case (none[ValueRef]) {
llbinding = cx.fcx.llargs.get(did);
}
case (some[ValueRef](?llval)) { llbinding = llval; }
}
} }
case (some[ValueRef](?llval)) { llbinding = llval; } case (some[ValueRef](?llval)) { llbinding = llval; }
} }
@ -3384,8 +3389,15 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
case (some[ast.def](?def)) { case (some[ast.def](?def)) {
alt (def) { alt (def) {
case (ast.def_arg(?did)) { case (ast.def_arg(?did)) {
check (cx.fcx.llargs.contains_key(did)); alt (cx.fcx.llargs.find(did)) {
ret lval_mem(cx, cx.fcx.llargs.get(did)); case (none[ValueRef]) {
check (cx.fcx.llupvars.contains_key(did));
ret lval_mem(cx, cx.fcx.llupvars.get(did));
}
case (some[ValueRef](?llval)) {
ret lval_mem(cx, llval);
}
}
} }
case (ast.def_local(?did)) { case (ast.def_local(?did)) {
alt (cx.fcx.lllocals.find(did)) { alt (cx.fcx.lllocals.find(did)) {