aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/v3_kernel.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-10-03 12:58:54 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-01-28 15:56:28 +0100
commit760ed909f8e2a655100ea773829c7d0e7dd40088 (patch)
tree1b79bd3c8076bac00a1cf7f609b9f63820686fad /lib/compiler/src/v3_kernel.erl
parentc0bb7f866257168e0a05110767fc7096a93d351d (diff)
downloadotp-760ed909f8e2a655100ea773829c7d0e7dd40088.tar.gz
otp-760ed909f8e2a655100ea773829c7d0e7dd40088.tar.bz2
otp-760ed909f8e2a655100ea773829c7d0e7dd40088.zip
Pass the map pair operators through to the v3_codegen pass
Diffstat (limited to 'lib/compiler/src/v3_kernel.erl')
-rw-r--r--lib/compiler/src/v3_kernel.erl25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl
index 44f853ec2b..14e776fd3c 100644
--- a/lib/compiler/src/v3_kernel.erl
+++ b/lib/compiler/src/v3_kernel.erl
@@ -503,11 +503,11 @@ map_pairs(Es, Sub, St) ->
(#c_map_pair_assoc{key=K0,val=V0}, {Kes,Esp,St0}) ->
{K,[],St1} = expr(K0, Sub, St0),
{V,Ep,St2} = atomic(V0, Sub, St1),
- {[#k_map_pair{key=K,val=V}|Kes],Ep ++ Esp,St2};
+ {[#k_map_pair_assoc{key=K,val=V}|Kes],Ep ++ Esp,St2};
(#c_map_pair_exact{key=K0,val=V0}, {Kes,Esp,St0}) ->
{K,[],St1} = expr(K0, Sub, St0),
{V,Ep,St2} = atomic(V0, Sub, St1),
- {[#k_map_pair{key=K,val=V}|Kes],Ep ++ Esp,St2}
+ {[#k_map_pair_exact{key=K,val=V}|Kes],Ep ++ Esp,St2}
end, {[],[],St}, Es).
%% call_type(Module, Function, Arity) -> call | bif | apply | error.
@@ -668,10 +668,14 @@ pattern(#c_tuple{anno=A,es=Ces}, Isub, Osub0, St0) ->
pattern(#c_map{anno=A,es=Ces}, Isub, Osub0, St0) ->
{Kes,Osub1,St1} = pattern_list(Ces, Isub, Osub0, St0),
{#k_map{anno=A,es=Kes},Osub1,St1};
+pattern(#c_map_pair_assoc{anno=A,key=Ck,val=Cv},Isub, Osub0, St0) ->
+ {Kk,Osub1,St1} = pattern(Ck, Isub, Osub0, St0),
+ {Kv,Osub2,St2} = pattern(Cv, Isub, Osub1, St1),
+ {#k_map_pair_assoc{anno=A,key=Kk,val=Kv},Osub2,St2};
pattern(#c_map_pair_exact{anno=A,key=Ck,val=Cv},Isub, Osub0, St0) ->
{Kk,Osub1,St1} = pattern(Ck, Isub, Osub0, St0),
{Kv,Osub2,St2} = pattern(Cv, Isub, Osub1, St1),
- {#k_map_pair{anno=A,key=Kk,val=Kv},Osub2,St2};
+ {#k_map_pair_assoc{anno=A,key=Kk,val=Kv},Osub2,St2};
pattern(#c_binary{anno=A,segments=Cv}, Isub, Osub0, St0) ->
{Kv,Osub1,St1} = pattern_bin(Cv, Isub, Osub0, St0),
{#k_binary{anno=A,segs=Kv},Osub1,St1};
@@ -1347,8 +1351,8 @@ get_match(#k_tuple{es=Es}, St0) ->
{#k_tuple{es=Mes},Mes,St1};
get_match(#k_map{es=Es0}, St0) ->
{Mes,St1} = new_vars(length(Es0), St0),
- {Es,_} = mapfoldl(fun(#k_map_pair{}=Pair, [V|Vs]) ->
- {Pair#k_map_pair{val=V},Vs}
+ {Es,_} = mapfoldl(fun(#k_map_pair_assoc{}=Pair, [V|Vs]) ->
+ {Pair#k_map_pair_assoc{val=V},Vs}
end, Mes, Es0),
{#k_map{es=Es},Mes,St1};
get_match(M, St) ->
@@ -1368,7 +1372,8 @@ new_clauses(Cs0, U, St) ->
#k_bin_int{next=N} ->
[N|As];
#k_map{es=Es} ->
- Vals = [V || #k_map_pair{val=V} <- Es],
+ Vals = [V ||
+ #k_map_pair_assoc{val=V} <- Es],
Vals ++ As;
_Other ->
As
@@ -1470,7 +1475,7 @@ arg_val(Arg, C) ->
end;
#k_map{es=Es} ->
Keys = [begin
- #k_map_pair{key=#k_literal{val=Key}} = Pair,
+ #k_map_pair_assoc{key=#k_literal{val=Key}} = Pair,
Key
end || Pair <- Es],
%% multiple keys may have the same name
@@ -1846,7 +1851,9 @@ lit_vars(#k_cons{hd=H,tl=T}) ->
union(lit_vars(H), lit_vars(T));
lit_vars(#k_map{var=Var,es=Es}) ->
lit_list_vars([Var|Es]);
-lit_vars(#k_map_pair{key=K,val=V}) ->
+lit_vars(#k_map_pair_assoc{key=K,val=V}) ->
+ union(lit_vars(K), lit_vars(V));
+lit_vars(#k_map_pair_exact{key=K,val=V}) ->
union(lit_vars(K), lit_vars(V));
lit_vars(#k_binary{segs=V}) -> lit_vars(V);
lit_vars(#k_bin_end{}) -> [];
@@ -1886,7 +1893,7 @@ pat_vars(#k_tuple{es=Es}) ->
pat_list_vars(Es);
pat_vars(#k_map{es=Es}) ->
pat_list_vars(Es);
-pat_vars(#k_map_pair{val=V}) ->
+pat_vars(#k_map_pair_assoc{val=V}) ->
pat_vars(V).
pat_list_vars(Ps) ->