Skip to content

Commit d976534

Browse files
committed
Wrap incoming symbol tables in suffix-aware versions
1 parent a85bc5d commit d976534

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 15 additions & 5 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"
@@ -787,8 +788,11 @@ bool java_bytecode_languaget::typecheck(
787788
break;
788789
case LAZY_METHODS_MODE_EAGER:
789790
{
791+
symbol_table_buildert symbol_table_builder =
792+
symbol_table_buildert::wrap(symbol_table);
793+
790794
journalling_symbol_tablet journalling_symbol_table =
791-
journalling_symbol_tablet::wrap(symbol_table);
795+
journalling_symbol_tablet::wrap(symbol_table_builder);
792796

793797
// Convert all synthetic methods:
794798
for(const auto &function_id_and_type : synthetic_methods)
@@ -839,18 +843,21 @@ bool java_bytecode_languaget::generate_support_functions(
839843
{
840844
PRECONDITION(language_options_initialized);
841845

846+
symbol_table_buildert symbol_table_builder =
847+
symbol_table_buildert::wrap(symbol_table);
848+
842849
main_function_resultt res=
843850
get_main_symbol(symbol_table, main_class, get_message_handler());
844851
if(!res.is_success())
845852
return res.is_error();
846853

847854
// Load the main function into the symbol table to get access to its
848855
// parameter names
849-
convert_lazy_method(res.main_function.name, symbol_table);
856+
convert_lazy_method(res.main_function.name, symbol_table_builder);
850857

851858
// generate the test harness in __CPROVER__start and a call the entry point
852859
return java_entry_point(
853-
symbol_table,
860+
symbol_table_builder,
854861
main_class,
855862
get_message_handler(),
856863
assume_inputs_non_null,
@@ -877,12 +884,15 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
877884
symbol_tablet &symbol_table,
878885
method_bytecodet &method_bytecode)
879886
{
887+
symbol_table_buildert symbol_table_builder =
888+
symbol_table_buildert::wrap(symbol_table);
889+
880890
const method_convertert method_converter =
881-
[this, &symbol_table]
891+
[this, &symbol_table_builder]
882892
(const irep_idt &function_id, ci_lazy_methods_neededt lazy_methods_needed)
883893
{
884894
return convert_single_method(
885-
function_id, symbol_table, std::move(lazy_methods_needed));
895+
function_id, symbol_table_builder, std::move(lazy_methods_needed));
886896
};
887897

888898
ci_lazy_methodst method_gather(

src/goto-cc/compile.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Date: June 2006
2525
#include <util/tempdir.h>
2626
#include <util/unicode.h>
2727
#include <util/version.h>
28+
#include <util/symbol_table_builder.h>
2829

2930
#include <ansi-c/ansi_c_language.h>
3031
#include <ansi-c/ansi_c_entry_point.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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Author: Daniel Kroening, kroening@kroening.com
2020
#include <util/simplify_expr.h>
2121
#include <util/std_expr.h>
2222
#include <util/symbol_table.h>
23-
23+
#include <util/symbol_table_builder.h>
2424
#include <util/c_types.h>
2525

2626
#include "goto_convert_class.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

0 commit comments

Comments
 (0)