Created
August 31, 2012 00:17
-
-
Save nikomatsakis/3546224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before: | |
``` | |
match bv { | |
env_copy(val, ty, lv_owned) => { | |
let val1 = load_if_immediate(bcx, val, ty); | |
bcx = base::copy_val(bcx, INIT, bound_data, val1, ty); | |
} | |
env_copy(val, ty, lv_owned_imm) => { | |
bcx = base::copy_val(bcx, INIT, bound_data, val, ty); | |
} | |
env_copy(_, _, lv_temporary) => { | |
fail ~"cannot capture temporary upvar"; | |
} | |
env_move(val, ty, kind) => { | |
let src = {bcx:bcx, val:val, kind:kind}; | |
bcx = move_val(bcx, INIT, bound_data, src, ty); | |
} | |
env_ref(val, _, lv_owned) => { | |
debug!("> storing %s into %s", | |
val_str(bcx.ccx().tn, val), | |
val_str(bcx.ccx().tn, bound_data)); | |
Store(bcx, val, bound_data); | |
} | |
env_ref(val, _, lv_owned_imm) => { | |
let addr = do_spill_noroot(bcx, val); | |
Store(bcx, addr, bound_data); | |
} | |
env_ref(_, _, lv_temporary) => { | |
fail ~"cannot capture temporary upvar"; | |
} | |
} | |
``` | |
After: | |
``` | |
match bv.action { | |
EnvCopy => { | |
bcx = bv.datum.copy_to(bcx, INIT, bound_data); | |
} | |
EnvMove => { | |
bcx = bv.datum.move_to(bcx, INIT, bound_data); | |
} | |
EnvRef => { | |
assert bv.datum.mode == datum::ByRef; | |
Store(bcx, bv.datum.val, bound_data); | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment