File tree Expand file tree Collapse file tree 5 files changed +30
-22
lines changed Expand file tree Collapse file tree 5 files changed +30
-22
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,9 @@ static smv_parse_treet::modulet &new_module(YYSTYPE &module_name)
181181{
182182 auto base_name = stack_expr (module_name).id_string ();
183183 const std::string identifier=smv_module_symbol (base_name);
184- auto &module =PARSER.parse_tree .modules [identifier];
184+ PARSER.parse_tree .module_list .push_back (smv_parse_treet::modulet{});
185+ auto &module =PARSER.parse_tree .module_list .back ();
186+ PARSER.parse_tree .module_map [identifier] = --PARSER.parse_tree .module_list .end ();
185187 module .name = identifier;
186188 module .base_name = base_name;
187189 PARSER.module = &module ;
Original file line number Diff line number Diff line change @@ -62,12 +62,12 @@ void smv_languaget::dependencies(
6262 const std::string &module ,
6363 std::set<std::string> &module_set)
6464{
65- smv_parse_treet::modulest::const_iterator
66- m_it=smv_parse_tree.modules .find (module );
65+ auto m_it = smv_parse_tree.module_map .find (module );
6766
68- if (m_it==smv_parse_tree.modules .end ()) return ;
67+ if (m_it == smv_parse_tree.module_map .end ())
68+ return ;
6969
70- const smv_parse_treet::modulet &smv_module= m_it->second ;
70+ const smv_parse_treet::modulet &smv_module = * m_it->second ;
7171
7272 for (auto &element : smv_module.elements )
7373 if (element.is_var () && element.expr .type ().id () == ID_smv_submodule)
@@ -89,10 +89,8 @@ Function: smv_languaget::modules_provided
8989
9090void smv_languaget::modules_provided (std::set<std::string> &module_set)
9191{
92- for (smv_parse_treet::modulest::const_iterator
93- it=smv_parse_tree.modules .begin ();
94- it!=smv_parse_tree.modules .end (); it++)
95- module_set.insert (id2string (it->second .name ));
92+ for (const auto &module : smv_parse_tree.module_list )
93+ module_set.insert (id2string (module .name ));
9694}
9795
9896/* ******************************************************************\
Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ Function: smv_parse_treet::swap
2828
2929void smv_parse_treet::swap (smv_parse_treet &smv_parse_tree)
3030{
31- smv_parse_tree.modules .swap (modules);
31+ smv_parse_tree.module_list .swap (module_list);
32+ smv_parse_tree.module_map .swap (module_map);
3233}
3334
3435/* ******************************************************************\
@@ -45,7 +46,8 @@ Function: smv_parse_treet::clear
4546
4647void smv_parse_treet::clear ()
4748{
48- modules.clear ();
49+ module_map.clear ();
50+ module_list.clear ();
4951}
5052
5153/* ******************************************************************\
@@ -105,10 +107,8 @@ void smv_parse_treet::modulet::elementt::show(std::ostream &out) const
105107
106108void smv_parse_treet::show (std::ostream &out) const
107109{
108- for (auto &module_it : modules )
110+ for (auto &module : module_list )
109111 {
110- auto &module = module_it.second ;
111-
112112 out << " Module: " << module .base_name << ' \n ' << ' \n ' ;
113113
114114 out << " PARAMETERS:\n " ;
Original file line number Diff line number Diff line change 1919class smv_parse_treet
2020{
2121public:
22+ smv_parse_treet () = default ;
23+
24+ // don't copy, contains pointers
25+ smv_parse_treet (const smv_parse_treet &) = delete ;
26+
2227 typedef std::unordered_set<irep_idt, irep_id_hash> enum_sett;
2328
2429 struct modulet
@@ -289,11 +294,14 @@ class smv_parse_treet
289294
290295 enum_sett enum_set;
291296 };
292-
293- typedef std::unordered_map<irep_idt, modulet, irep_id_hash> modulest;
294-
295- modulest modules;
296-
297+
298+ using module_listt = std::list<modulet>;
299+ module_listt module_list;
300+
301+ using module_mapt =
302+ std::unordered_map<irep_idt, module_listt::iterator, irep_id_hash>;
303+ module_mapt module_map;
304+
297305 void swap (smv_parse_treet &smv_parse_tree);
298306 void clear ();
299307
Original file line number Diff line number Diff line change @@ -2631,14 +2631,14 @@ Function: smv_typecheckt::typecheck
26312631
26322632void smv_typecheckt::typecheck ()
26332633{
2634- smv_parse_treet::modulest::iterator it= smv_parse_tree.modules .find (module );
2634+ auto it = smv_parse_tree.module_map .find (module );
26352635
2636- if (it== smv_parse_tree.modules .end ())
2636+ if (it == smv_parse_tree.module_map .end ())
26372637 {
26382638 throw errort () << " failed to find module " << module ;
26392639 }
26402640
2641- convert (it->second );
2641+ convert (* it->second );
26422642}
26432643
26442644/* ******************************************************************\
You can’t perform that action at this time.
0 commit comments