Skip to content

Commit f48ca75

Browse files
committed
Wrap incoming symbol tables in suffix-aware versions
1 parent b45f56d commit f48ca75

File tree

5 files changed

+57
-29
lines changed

5 files changed

+57
-29
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Author: Daniel Kroening, kroening@kroening.com
2323
#include <json/json_parser.h>
2424

2525
#include <goto-programs/class_hierarchy.h>
26+
#include <util/symbol_table_builder.h>
2627

2728
#include "java_bytecode_concurrency_instrumentation.h"
2829
#include "java_bytecode_convert_class.h"
@@ -790,8 +791,11 @@ bool java_bytecode_languaget::typecheck(
790791
break;
791792
case LAZY_METHODS_MODE_EAGER:
792793
{
794+
symbol_table_buildert symbol_table_builder =
795+
symbol_table_buildert::wrap(symbol_table);
796+
793797
journalling_symbol_tablet journalling_symbol_table =
794-
journalling_symbol_tablet::wrap(symbol_table);
798+
journalling_symbol_tablet::wrap(symbol_table_builder);
795799

796800
// Convert all synthetic methods:
797801
for(const auto &function_id_and_type : synthetic_methods)
@@ -842,18 +846,21 @@ bool java_bytecode_languaget::generate_support_functions(
842846
{
843847
PRECONDITION(language_options_initialized);
844848

849+
symbol_table_buildert symbol_table_builder =
850+
symbol_table_buildert::wrap(symbol_table);
851+
845852
main_function_resultt res=
846853
get_main_symbol(symbol_table, main_class, get_message_handler());
847854
if(!res.is_success())
848855
return res.is_error();
849856

850857
// Load the main function into the symbol table to get access to its
851858
// parameter names
852-
convert_lazy_method(res.main_function.name, symbol_table);
859+
convert_lazy_method(res.main_function.name, symbol_table_builder);
853860

854861
// generate the test harness in __CPROVER__start and a call the entry point
855862
return java_entry_point(
856-
symbol_table,
863+
symbol_table_builder,
857864
main_class,
858865
get_message_handler(),
859866
assume_inputs_non_null,
@@ -880,13 +887,14 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
880887
symbol_tablet &symbol_table,
881888
method_bytecodet &method_bytecode)
882889
{
883-
const method_convertert method_converter =
884-
[this, &symbol_table]
885-
(const irep_idt &function_id, ci_lazy_methods_neededt lazy_methods_needed)
886-
{
887-
return convert_single_method(
888-
function_id, symbol_table, std::move(lazy_methods_needed));
889-
};
890+
symbol_table_buildert symbol_table_builder =
891+
symbol_table_buildert::wrap(symbol_table);
892+
893+
const method_convertert method_converter = [this, &symbol_table_builder](
894+
const irep_idt &function_id, ci_lazy_methods_neededt lazy_methods_needed) {
895+
return convert_single_method(
896+
function_id, symbol_table_builder, std::move(lazy_methods_needed));
897+
};
890898

891899
ci_lazy_methodst method_gather(
892900
symbol_table,

src/goto-cc/compile.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Date: June 2006
2222
#include <util/file_util.h>
2323
#include <util/get_base_name.h>
2424
#include <util/suffix.h>
25+
#include <util/symbol_table_builder.h>
2526
#include <util/tempdir.h>
2627
#include <util/unicode.h>
2728
#include <util/version.h>
@@ -692,37 +693,40 @@ void compilet::add_compiler_specific_defines(configt &config) const
692693

693694
void compilet::convert_symbols(goto_functionst &dest)
694695
{
696+
symbol_table_buildert symbol_table_builder =
697+
symbol_table_buildert::wrap(goto_model.symbol_table);
698+
695699
goto_convert_functionst converter(
696-
goto_model.symbol_table, get_message_handler());
700+
symbol_table_builder, get_message_handler());
697701

698702
// the compilation may add symbols!
699703

700704
symbol_tablet::symbolst::size_type before=0;
701705

702-
while(before != goto_model.symbol_table.symbols.size())
706+
while(before != symbol_table_builder.symbols.size())
703707
{
704-
before = goto_model.symbol_table.symbols.size();
708+
before = symbol_table_builder.symbols.size();
705709

706710
typedef std::set<irep_idt> symbols_sett;
707711
symbols_sett symbols;
708712

709-
for(const auto &named_symbol : goto_model.symbol_table.symbols)
713+
for(const auto &named_symbol : symbol_table_builder.symbols)
710714
symbols.insert(named_symbol.first);
711715

712716
// the symbol table iterators aren't stable
713717
for(const auto &symbol : symbols)
714718
{
715719
symbol_tablet::symbolst::const_iterator s_it =
716-
goto_model.symbol_table.symbols.find(symbol);
717-
CHECK_RETURN(s_it != goto_model.symbol_table.symbols.end());
720+
symbol_table_builder.symbols.find(symbol);
721+
CHECK_RETURN(s_it != symbol_table_builder.symbols.end());
718722

719723
if(
720724
s_it->second.is_function() && !s_it->second.is_compiled() &&
721725
s_it->second.value.is_not_nil())
722726
{
723727
debug() << "Compiling " << s_it->first << eom;
724728
converter.convert_function(s_it->first, dest.function_map[s_it->first]);
725-
goto_model.symbol_table.get_writeable_ref(symbol).set_compiled();
729+
symbol_table_builder.get_writeable_ref(symbol).set_compiled();
726730
}
727731
}
728732
}

src/goto-programs/goto_convert.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Daniel Kroening, kroening@kroening.com
1212
#include "goto_convert.h"
1313

1414
#include <util/arith_tools.h>
15+
#include <util/c_types.h>
1516
#include <util/cprover_prefix.h>
1617
#include <util/exception_utils.h>
1718
#include <util/expr_util.h>
@@ -20,8 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com
2021
#include <util/simplify_expr.h>
2122
#include <util/std_expr.h>
2223
#include <util/symbol_table.h>
23-
24-
#include <util/c_types.h>
24+
#include <util/symbol_table_builder.h>
2525

2626
#include "goto_convert_class.h"
2727
#include "destructor.h"
@@ -1939,7 +1939,9 @@ void goto_convert(
19391939
message_handlert &message_handler,
19401940
const irep_idt &mode)
19411941
{
1942-
goto_convertt goto_convert(symbol_table, message_handler);
1942+
symbol_table_buildert symbol_table_builder =
1943+
symbol_table_buildert::wrap(symbol_table);
1944+
goto_convertt goto_convert(symbol_table_builder, message_handler);
19431945
goto_convert.goto_convert(code, dest, mode);
19441946
}
19451947

src/goto-programs/goto_convert_functions.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ Date: June 2003
1111
#include "goto_convert_functions.h"
1212

1313
#include <util/base_type.h>
14+
#include <util/fresh_symbol.h>
15+
#include <util/prefix.h>
1416
#include <util/std_code.h>
1517
#include <util/symbol_table.h>
16-
#include <util/prefix.h>
17-
#include <util/fresh_symbol.h>
18+
#include <util/symbol_table_builder.h>
1819

1920
#include "goto_inline.h"
2021

@@ -217,18 +218,23 @@ void goto_convert(
217218
goto_modelt &goto_model,
218219
message_handlert &message_handler)
219220
{
221+
symbol_table_buildert symbol_table_builder =
222+
symbol_table_buildert::wrap(goto_model.symbol_table);
223+
220224
goto_convert(
221-
goto_model.symbol_table,
222-
goto_model.goto_functions,
223-
message_handler);
225+
symbol_table_builder, goto_model.goto_functions, message_handler);
224226
}
225227

226228
void goto_convert(
227229
symbol_table_baset &symbol_table,
228230
goto_functionst &functions,
229231
message_handlert &message_handler)
230232
{
231-
goto_convert_functionst goto_convert_functions(symbol_table, message_handler);
233+
symbol_table_buildert symbol_table_builder =
234+
symbol_table_buildert::wrap(symbol_table);
235+
236+
goto_convert_functionst goto_convert_functions(
237+
symbol_table_builder, message_handler);
232238

233239
goto_convert_functions.goto_convert(functions);
234240
}
@@ -239,7 +245,11 @@ void goto_convert(
239245
goto_functionst &functions,
240246
message_handlert &message_handler)
241247
{
242-
goto_convert_functionst goto_convert_functions(symbol_table, message_handler);
248+
symbol_table_buildert symbol_table_builder =
249+
symbol_table_buildert::wrap(symbol_table);
250+
251+
goto_convert_functionst goto_convert_functions(
252+
symbol_table_builder, message_handler);
243253

244254
goto_convert_functions.convert_function(
245255
identifier, functions.function_map[identifier]);

src/goto-programs/lazy_goto_functions_map.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#include "goto_functions.h"
1212
#include "goto_convert_functions.h"
1313

14-
#include <util/message.h>
1514
#include <langapi/language_file.h>
1615
#include <util/journalling_symbol_table.h>
16+
#include <util/message.h>
17+
#include <util/symbol_table_builder.h>
1718

1819
/// Provides a wrapper for a map of lazily loaded goto_functiont.
1920
/// This incrementally builds a goto-functions object, while permitting
@@ -142,8 +143,11 @@ class lazy_goto_functions_mapt final
142143
// const first
143144
reference ensure_function_loaded_internal(const key_type &name) const
144145
{
146+
symbol_table_buildert symbol_table_builder =
147+
symbol_table_buildert::wrap(symbol_table);
148+
145149
journalling_symbol_tablet journalling_table =
146-
journalling_symbol_tablet::wrap(symbol_table);
150+
journalling_symbol_tablet::wrap(symbol_table_builder);
147151
reference named_function=ensure_entry_converted(name, journalling_table);
148152
mapped_type function=named_function.second;
149153
if(processed_functions.count(name)==0)

0 commit comments

Comments
 (0)