@@ -38,6 +38,7 @@ void dump_ct::operator()(std::ostream &os)
38
38
std::stringstream func_decl_stream;
39
39
std::stringstream compound_body_stream;
40
40
std::stringstream global_var_stream;
41
+ std::stringstream global_decl_stream;
41
42
std::stringstream func_body_stream;
42
43
local_static_declst local_static_decls;
43
44
@@ -175,13 +176,14 @@ void dump_ct::operator()(std::ostream &os)
175
176
{
176
177
if (!ignore (symbol))
177
178
{
178
- os << " // " << symbol.name << ' \n ' ;
179
- os << " // " << symbol.location << ' \n ' ;
179
+ global_decl_stream << " // " << symbol.name << ' \n ' ;
180
+ global_decl_stream << " // " << symbol.location << ' \n ' ;
180
181
181
182
if (type_id==ID_c_enum)
182
- convert_compound_enum (symbol.type , os );
183
+ convert_compound_enum (symbol.type , global_decl_stream );
183
184
else
184
- os << type_to_string (symbol_typet (symbol.name )) << " ;\n\n " ;
185
+ global_decl_stream << type_to_string (symbol_typet (symbol.name ))
186
+ << " ;\n\n " ;
185
187
}
186
188
}
187
189
else if (symbol.is_static_lifetime && symbol.type .id ()!=ID_code)
@@ -240,6 +242,8 @@ void dump_ct::operator()(std::ostream &os)
240
242
compound_body_stream);
241
243
}
242
244
245
+ // Dump the code to the target stream;
246
+ // the statements before to this point collect the code to dump!
243
247
for (std::set<std::string>::const_iterator
244
248
it=system_headers.begin ();
245
249
it!=system_headers.end ();
@@ -271,6 +275,9 @@ void dump_ct::operator()(std::ostream &os)
271
275
<< " #endif\n\n " ;
272
276
}
273
277
278
+ if (!global_decl_stream.str ().empty ())
279
+ os << global_decl_stream.str () << ' \n ' ;
280
+
274
281
dump_typedefs (os);
275
282
276
283
if (!func_decl_stream.str ().empty ())
0 commit comments