11% %
22% % %CopyrightBegin%
3+ % %
4+ % % Copyright Ericsson AB 1998-2016. All Rights Reserved.
5+ % %
6+ % % Licensed under the Apache License, Version 2.0 (the "License");
7+ % % you may not use this file except in compliance with the License.
8+ % % You may obtain a copy of the License at
39% %
4- % % Copyright Ericsson AB 1998-2013. All Rights Reserved.
5- % %
6- % % The contents of this file are subject to the Erlang Public License,
7- % % Version 1.1, (the "License"); you may not use this file except in
8- % % compliance with the License. You should have received a copy of the
9- % % Erlang Public License along with this software. If not, it can be
10- % % retrieved online at http://www.erlang.org/.
11- % %
12- % % Software distributed under the License is distributed on an "AS IS"
13- % % basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14- % % the License for the specific language governing rights and limitations
15- % % under the License.
10+ % % http://www.apache.org/licenses/LICENSE-2.0
1611% %
12+ % % Unless required by applicable law or agreed to in writing, software
13+ % % distributed under the License is distributed on an "AS IS" BASIS,
14+ % % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ % % See the License for the specific language governing permissions and
16+ % % limitations under the License.
17+ % %
1718% % %CopyrightEnd%
1819% %
1920-module (dbg_ieval ).
@@ -568,7 +569,7 @@ get_function(Mod, Name, Args, extern) ->
568569 end .
569570
570571db_ref (Mod ) ->
571- case get ([ Mod | db ] ) of
572+ case get (? DB_REF_KEY ( Mod ) ) of
572573 undefined ->
573574 case dbg_iserver :call (get (int ),
574575 {get_module_db , Mod , get (self )}) of
@@ -580,7 +581,7 @@ db_ref(Mod) ->
580581 Node =/= node () -> {Node ,ModDb };
581582 true -> ModDb
582583 end ,
583- put ([ Mod | db ] , DbRef ),
584+ put (? DB_REF_KEY ( Mod ) , DbRef ),
584585 DbRef
585586 end ;
586587 DbRef ->
@@ -659,20 +660,19 @@ expr({tuple,Line,Es0}, Bs0, Ieval) ->
659660 {value ,list_to_tuple (Vs ),Bs };
660661
661662% % Map
662- expr ({map ,Line ,Fs0 }, Bs0 , Ieval ) ->
663- {Fs ,Bs } = eval_map_fields (Fs0 , Bs0 , Ieval # ieval {line = Line ,top = false }),
664- Value = lists :foldl (fun ({map_assoc ,K ,V }, Mi ) -> maps :put (K ,V ,Mi ) end ,
665- #{}, Fs ),
666- {value ,Value ,Bs };
663+ expr ({map ,Line ,Fs }, Bs0 , Ieval ) ->
664+ {Map ,Bs } = eval_new_map_fields (Fs , Bs0 , Ieval # ieval {line = Line ,top = false },
665+ fun expr /3 ),
666+ {value ,Map ,Bs };
667667expr ({map ,Line ,E0 ,Fs0 }, Bs0 , Ieval0 ) ->
668668 Ieval = Ieval0 # ieval {line = Line ,top = false },
669669 {value ,E ,Bs1 } = expr (E0 , Bs0 , Ieval ),
670- {Fs ,Bs2 } = eval_map_fields (Fs0 , Bs1 , Ieval ),
670+ {Fs ,Bs2 } = eval_map_fields (Fs0 , Bs0 , Ieval ),
671+ _ = maps :put (k , v , E ), % Validate map.
671672 Value = lists :foldl (fun ({map_assoc ,K ,V }, Mi ) -> maps :put (K ,V ,Mi );
672- ({map_exact ,K ,V }, Mi ) -> maps :update (K ,V ,Mi ) end ,
673- E , Fs ),
674- {value ,Value ,Bs2 };
675-
673+ ({map_exact ,K ,V }, Mi ) -> maps :update (K ,V ,Mi )
674+ end , E , Fs ),
675+ {value ,Value ,merge_bindings (Bs2 , Bs1 , Ieval )};
676676% % A block of statements
677677expr ({block ,Line ,Es },Bs ,Ieval ) ->
678678 seq (Es , Bs , Ieval # ieval {line = Line });
@@ -1487,11 +1487,13 @@ guard_expr({cons,_,H0,T0}, Bs) ->
14871487guard_expr ({tuple ,_ ,Es0 }, Bs ) ->
14881488 {values ,Es } = guard_exprs (Es0 , Bs ),
14891489 {value ,list_to_tuple (Es )};
1490- guard_expr ({map ,_ ,Fs0 }, Bs ) ->
1491- Fs = eval_map_fields_guard (Fs0 , Bs ),
1492- Value = lists :foldl (fun ({map_assoc ,K ,V }, Mi ) -> maps :put (K ,V ,Mi ) end ,
1493- #{}, Fs ),
1494- {value ,Value };
1490+ guard_expr ({map ,_ ,Fs }, Bs0 ) ->
1491+ F = fun (G0 , B0 , _ ) ->
1492+ {value ,G } = guard_expr (G0 , B0 ),
1493+ {value ,G ,B0 }
1494+ end ,
1495+ {Map ,_ } = eval_new_map_fields (Fs , Bs0 , # ieval {top = false }, F ),
1496+ {value ,Map };
14951497guard_expr ({map ,_ ,E0 ,Fs0 }, Bs ) ->
14961498 {value ,E } = guard_expr (E0 , Bs ),
14971499 Fs = eval_map_fields_guard (Fs0 , Bs ),
@@ -1540,6 +1542,17 @@ eval_map_fields([{map_field_exact,Line,K0,V0}|Fs], Bs0, Ieval0, F, Acc) ->
15401542eval_map_fields ([], Bs , _Ieval , _F , Acc ) ->
15411543 {lists :reverse (Acc ),Bs }.
15421544
1545+ eval_new_map_fields (Fs , Bs0 , Ieval , F ) ->
1546+ eval_new_map_fields (Fs , Bs0 , Ieval , F , []).
1547+
1548+ eval_new_map_fields ([{Line ,K0 ,V0 }|Fs ], Bs0 , Ieval0 , F , Acc ) ->
1549+ Ieval = Ieval0 # ieval {line = Line },
1550+ {value ,K ,Bs1 } = F (K0 , Bs0 , Ieval ),
1551+ {value ,V ,Bs2 } = F (V0 , Bs1 , Ieval ),
1552+ eval_new_map_fields (Fs , Bs2 , Ieval0 , F , [{K ,V }|Acc ]);
1553+ eval_new_map_fields ([], Bs , _ , _ , Acc ) ->
1554+ {maps :from_list (lists :reverse (Acc )),Bs }.
1555+
15431556% % match(Pattern,Term,Bs) -> {match,Bs} | nomatch
15441557match (Pat , Term , Bs ) ->
15451558 try match1 (Pat , Term , Bs , Bs )
0 commit comments