diff options
author | Fredrik Gustafsson <[email protected]> | 2013-04-19 14:22:29 +0200 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-04-19 14:22:29 +0200 |
commit | 420cf1511ade9b979dc11eb9b07efb1959522e11 (patch) | |
tree | 2b1867b242dcb6ddca4b22c1b4fb26de29606d86 | |
parent | 3d3ad2bce531b0661a24b41cbe9b45d728d0685a (diff) | |
parent | 16f820be15674f81f9fa5bb61b221eee9deff15d (diff) | |
download | otp-420cf1511ade9b979dc11eb9b07efb1959522e11.tar.gz otp-420cf1511ade9b979dc11eb9b07efb1959522e11.tar.bz2 otp-420cf1511ade9b979dc11eb9b07efb1959522e11.zip |
Merge branch 'nox/move-let-into-seq/OTP-11056'
* nox/move-let-into-seq/OTP-11056:
Move let expressions into sequences
-rw-r--r-- | lib/compiler/src/sys_core_fold.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index cda3f7d81e..6b0ae87172 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -2342,6 +2342,25 @@ move_let_into_expr(#c_let{vars=Lvs0,body=Lbody0}=Let, Case#c_case{arg=Cexpr,clauses=[Ca,Cb]}; {_,_,_} -> impossible end; +move_let_into_expr(#c_let{vars=Lvs0,body=Lbody0}=Let, + #c_seq{arg=Sarg0,body=Sbody0}=Seq, Sub0) -> + %% + %% let <Lvars> = do <Seq-arg> + %% <Seq-body> + %% in <Let-body> + %% + %% ==> + %% + %% do <Seq-arg> + %% let <Lvars> = <Seq-body> + %% in <Let-body> + %% + Sarg = body(Sarg0, Sub0), + Sbody1 = body(Sbody0, Sub0), + {Lvs,Sbody,Sub} = let_substs(Lvs0, Sbody1, Sub0), + Lbody = body(Lbody0, Sub), + Seq#c_seq{arg=Sarg,body=Let#c_let{vars=Lvs,arg=core_lib:make_values(Sbody), + body=Lbody}}; move_let_into_expr(_Let, _Expr, _Sub) -> impossible. is_failing_clause(#c_clause{body=B}) -> |