diff options
author | Björn Gustavsson <[email protected]> | 2011-12-30 16:54:37 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-01-11 08:39:57 +0100 |
commit | aaa6dd328d6062064295664392e751a6a51ce93e (patch) | |
tree | 08a5358f071b6084e3eb9c528a042527167c42cd /lib | |
parent | 70630b0d1e8216bb0d59ae3c66b99ae5df7367b5 (diff) | |
download | otp-aaa6dd328d6062064295664392e751a6a51ce93e.tar.gz otp-aaa6dd328d6062064295664392e751a6a51ce93e.tar.bz2 otp-aaa6dd328d6062064295664392e751a6a51ce93e.zip |
v3_kernel: Introduce is_in_guard/1
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/src/v3_kernel.erl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl index de568eef25..f6f84c38dc 100644 --- a/lib/compiler/src/v3_kernel.erl +++ b/lib/compiler/src/v3_kernel.erl @@ -1412,9 +1412,10 @@ ubody(#ivalues{anno=A,args=As}, return, St) -> {#k_return{anno=#k{us=Au,ns=[],a=A},args=As},Au,St}; ubody(#ivalues{anno=A,args=As}, {break,_Vbs}, St) -> Au = lit_list_vars(As), - if St#kern.guard_refc > 0 -> + case is_in_guard(St) of + true -> {#k_guard_break{anno=#k{us=Au,ns=[],a=A},args=As},Au,St}; - true -> + false -> {#k_break{anno=#k{us=Au,ns=[],a=A},args=As},Au,St} end; ubody(#ivalues{anno=A,args=As}, {guard_break,_Vbs}, St) -> @@ -1584,10 +1585,11 @@ uexpr(#k_match{anno=A,vars=Vs0,body=B0}, Br, St0) -> Vs = handle_reuse_annos(Vs0, St0), Rs = break_rets(Br), {B1,Bu,St1} = umatch(B0, Br, St0), - if St0#kern.guard_refc > 0 -> + case is_in_guard(St1) of + true -> {#k_guard_match{anno=#k{us=Bu,ns=lit_list_vars(Rs),a=A}, vars=Vs,body=B1,ret=Rs},Bu,St1}; - true -> + false -> {#k_match{anno=#k{us=Bu,ns=lit_list_vars(Rs),a=A}, vars=Vs,body=B1,ret=Rs},Bu,St1} end; @@ -1852,6 +1854,11 @@ integers(N, M) when N =< M -> [N|integers(N + 1, M)]; integers(_, _) -> []. +%% is_in_guard(State) -> true|false. + +is_in_guard(#kern{guard_refc=Refc}) -> + Refc > 0. + %%% %%% Handling of errors and warnings. %%% |