diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-04-28 15:56:08 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-04-28 16:50:51 +0200 |
commit | a53bcf79429c73bce86d57a47ecfcc4acf0fbd70 (patch) | |
tree | 4ba130f4df64e2fc0856a009c15704393845f02c /lib/compiler/src | |
parent | 4d957870d4e5ae98e91b9118f8b2e8319ab4fa33 (diff) | |
download | otp-a53bcf79429c73bce86d57a47ecfcc4acf0fbd70.tar.gz otp-a53bcf79429c73bce86d57a47ecfcc4acf0fbd70.tar.bz2 otp-a53bcf79429c73bce86d57a47ecfcc4acf0fbd70.zip |
hipe,compiler: Fix Map literals pretty printing
Diffstat (limited to 'lib/compiler/src')
-rw-r--r-- | lib/compiler/src/cerl.erl | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/compiler/src/cerl.erl b/lib/compiler/src/cerl.erl index 54eac20ac4..ef8bddae52 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(). |