@@ -799,6 +799,36 @@ 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
+ for (auto &id_symbol_pair : context.symbols )
816
+ {
817
+ const irep_idt &id=id_symbol_pair.first ;
818
+ symbolt &symbol=id_symbol_pair.second ;
819
+ if (symbol.type .id ()==ID_code)
820
+ {
821
+ exprt generated_code=string_preprocess.code_for_function (
822
+ id, to_code_type (symbol.type ), symbol.location , context);
823
+ if (generated_code.is_not_nil ())
824
+ // Replace body of the function by code generated by string preprocess
825
+ symbol.value =generated_code;
826
+ }
827
+ }
828
+ }
829
+
830
+ /* ******************************************************************\
831
+
802
832
Function: java_bytecode_languaget::final
803
833
804
834
Inputs:
@@ -816,6 +846,9 @@ bool java_bytecode_languaget::final(symbol_tablet &symbol_table)
816
846
*/
817
847
java_internal_additions (symbol_table);
818
848
849
+ // Replace code of String methods calls by code we generate
850
+ replace_string_methods (symbol_table);
851
+
819
852
main_function_resultt res=
820
853
get_main_symbol (symbol_table, main_class, get_message_handler ());
821
854
if (res.stop_convert )
0 commit comments