@@ -6,11 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com
66
77\*******************************************************************/
88
9- #include < util/xml.h>
10- #include < util/xml_irep.h>
11-
129#include " show_modules.h"
1310
11+ #include < util/json_irep.h>
12+ #include < util/xml_irep.h>
13+
1414/* ******************************************************************\
1515
1616Function: show_modules_xml
@@ -91,3 +91,38 @@ void show_modules(const symbol_table_baset &symbol_table, std::ostream &out)
9191 }
9292 }
9393}
94+
95+ /* ******************************************************************\
96+
97+ Function: json_modules
98+
99+ Inputs:
100+
101+ Outputs:
102+
103+ Purpose:
104+
105+ \*******************************************************************/
106+
107+ void json_modules (const symbol_table_baset &symbol_table, std::ostream &out)
108+ {
109+ json_arrayt json_modules;
110+
111+ for (const auto &s : symbol_table.symbols )
112+ {
113+ const symbolt &symbol = s.second ;
114+
115+ if (symbol.type .id () == ID_module)
116+ {
117+ json_objectt json_module;
118+ json_module[" location" ] = json (symbol.location );
119+ json_module[" identifier" ] = json_stringt{id2string (symbol.name )};
120+ json_module[" mode" ] = json_stringt{id2string (symbol.mode )};
121+ json_module[" name" ] = json_stringt{id2string (symbol.display_name ())};
122+
123+ json_modules.push_back (std::move (json_module));
124+ }
125+ }
126+
127+ out << json_modules;
128+ }
0 commit comments