@@ -799,6 +799,43 @@ void java_bytecode_languaget::convert_lazy_method(
799
799
800
800
/* ******************************************************************\
801
801
802
+ Function: java_bytecode_languaget::replace_string_methods
803
+
804
+ Inputs:
805
+ context - a symbol table
806
+
807
+ Purpose: Replace methods of the String library that are in the symbol table
808
+ by code generated by string_preprocess.
809
+
810
+ \*******************************************************************/
811
+
812
+ void java_bytecode_languaget::replace_string_methods (
813
+ symbol_tablet &context)
814
+ {
815
+ // Symbols that have code type are potentialy to be replaced
816
+ std::list<symbolt> code_symbols;
817
+ forall_symbols (symbol, context.symbols )
818
+ {
819
+ if (symbol->second .type .id ()==ID_code)
820
+ code_symbols.push_back (symbol->second );
821
+ }
822
+
823
+ for (const auto &symbol : code_symbols)
824
+ {
825
+ const irep_idt &id=symbol.name ;
826
+ exprt generated_code=string_preprocess.code_for_function (
827
+ id, to_code_type (symbol.type ), symbol.location , context);
828
+ if (generated_code.is_not_nil ())
829
+ {
830
+ // Replace body of the function by code generated by string preprocess
831
+ symbolt &symbol=context.lookup (id);
832
+ symbol.value =generated_code;
833
+ }
834
+ }
835
+ }
836
+
837
+ /* ******************************************************************\
838
+
802
839
Function: java_bytecode_languaget::final
803
840
804
841
Inputs:
@@ -816,6 +853,9 @@ bool java_bytecode_languaget::final(symbol_tablet &symbol_table)
816
853
*/
817
854
java_internal_additions (symbol_table);
818
855
856
+ // Replace code of String methods calls by code we generate
857
+ replace_string_methods (symbol_table);
858
+
819
859
main_function_resultt res=
820
860
get_main_symbol (symbol_table, main_class, get_message_handler ());
821
861
if (res.stop_convert )
0 commit comments