aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-05-26 11:04:45 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-05-26 11:04:45 +0200
commit3c95f2613cc7030576f28dae73129dffc1962b96 (patch)
tree431d93211bb98b2b845c4828880ea59c33351e3a /lib/compiler
parent40052e19a6bbebdf1af89d19245a7abb1d32d1f8 (diff)
parent839f8fea41003883681188dfb09eebbfbd351094 (diff)
downloadotp-3c95f2613cc7030576f28dae73129dffc1962b96.tar.gz
otp-3c95f2613cc7030576f28dae73129dffc1962b96.tar.bz2
otp-3c95f2613cc7030576f28dae73129dffc1962b96.zip
Merge branch 'egil/fix-maps-pretty-layout/OTP-11947' into maint
* egil/fix-maps-pretty-layout/OTP-11947: dialyzer: Add Maps type mismatch test hipe,compiler: Fix Map literals pretty printing
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/cerl.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/compiler/src/cerl.erl b/lib/compiler/src/cerl.erl
index b7e1f0b70b..9d6768b157 100644
--- a/lib/compiler/src/cerl.erl
+++ b/lib/compiler/src/cerl.erl
@@ -126,9 +126,11 @@
map_es/1,
map_arg/1,
update_c_map/3,
+ c_map/1, is_c_map_empty/1,
ann_c_map/2, ann_c_map/3,
map_pair_op/1,map_pair_key/1,map_pair_val/1,
update_c_map_pair/4,
+ c_map_pair/2,
ann_c_map_pair/4
]).
@@ -1582,9 +1584,20 @@ map_es(#c_map{es = Es}) ->
-spec map_arg(c_map()) -> c_map() | c_literal().
-map_arg(#c_map{arg = M}) ->
+map_arg(#c_map{arg=M}) ->
M.
+-spec c_map([c_map_pair()]) -> c_map().
+
+c_map(Pairs) ->
+ #c_map{es=Pairs}.
+
+-spec is_c_map_empty(c_map() | c_literal()) -> boolean().
+
+is_c_map_empty(#c_map{ es=[] }) -> true;
+is_c_map_empty(#c_literal{val=M}) when is_map(M),map_size(M) =:= 0 -> true;
+is_c_map_empty(_) -> false.
+
-spec ann_c_map([term()], [cerl()]) -> c_map() | c_literal().
ann_c_map(As,Es) ->
@@ -1644,6 +1657,11 @@ map_pair_key(#c_map_pair{key=K}) -> K.
map_pair_val(#c_map_pair{val=V}) -> V.
map_pair_op(#c_map_pair{op=Op}) -> Op.
+-spec c_map_pair(cerl(), cerl()) -> c_map_pair().
+
+c_map_pair(Key,Val) ->
+ #c_map_pair{op=#c_literal{val=assoc},key=Key,val=Val}.
+
-spec ann_c_map_pair([term()], cerl(), cerl(), cerl()) ->
c_map_pair().