diff options
Diffstat (limited to 'lib/compiler/src/cerl.erl')
-rw-r--r-- | lib/compiler/src/cerl.erl | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/compiler/src/cerl.erl b/lib/compiler/src/cerl.erl index 3c121f3b04..744ebc7aca 100644 --- a/lib/compiler/src/cerl.erl +++ b/lib/compiler/src/cerl.erl @@ -126,7 +126,7 @@ map_es/1, map_val/1, update_c_map/3, - ann_c_map/3, + 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, ann_c_map_pair/4 @@ -1584,8 +1584,24 @@ map_es(#c_map{es = Es}) -> map_val(#c_map{var = M}) -> M. +ann_c_map(As,Es) -> + ann_c_map(As, #c_literal{val=[]}, Es). + +ann_c_map(As,#c_literal{val=[]}=M,Es) -> + Pairs = [[K,V]||#c_map_pair{key=K,val=V}<-Es], + IsLit = lists:foldl(fun(Pair,Res) -> + Res andalso is_lit_list(Pair) + end, true, Pairs), + Fun = fun(Pair) -> [K,V] = lit_list_vals(Pair), {K,V} end, + case IsLit of + false -> + #c_map{var=M, es=Es, anno=As }; + true -> + #c_literal{anno=As, val=maps:from_list(lists:map(Fun, Pairs))} + end; ann_c_map(As,M,Es) -> - #c_map{var=M,es = Es, anno = As }. + #c_map{var=M, es = Es, anno = As }. + update_c_map(Old,M,Es) -> #c_map{var=M, es = Es, anno = get_ann(Old)}. |