@@ -76,7 +76,7 @@ Date: June 2006
76
76
// / \return true on error, false otherwise
77
77
bool compilet::doit ()
78
78
{
79
- compiled_functions .clear ();
79
+ goto_model. goto_functions .clear ();
80
80
81
81
add_compiler_specific_defines (config);
82
82
@@ -346,13 +346,12 @@ bool compilet::link()
346
346
{
347
347
// "compile" hitherto uncompiled functions
348
348
statistics () << " Compiling functions" << eom;
349
- convert_symbols (compiled_functions );
349
+ convert_symbols (goto_model. goto_functions );
350
350
351
351
// parse object files
352
352
for (const auto &file_name : object_files)
353
353
{
354
- if (read_object_and_link (file_name, symbol_table,
355
- compiled_functions, get_message_handler ()))
354
+ if (read_object_and_link (file_name, goto_model, get_message_handler ()))
356
355
return true ;
357
356
}
358
357
@@ -363,23 +362,23 @@ bool compilet::link()
363
362
// new symbols may have been added to a previously linked file
364
363
// make sure a new entry point is created that contains all
365
364
// static initializers
366
- compiled_functions .function_map .erase (INITIALIZE_FUNCTION);
365
+ goto_model. goto_functions .function_map .erase (INITIALIZE_FUNCTION);
367
366
368
- symbol_table.remove (goto_functionst::entry_point ());
369
- compiled_functions.function_map .erase (goto_functionst::entry_point ());
367
+ goto_model.symbol_table .remove (goto_functionst::entry_point ());
368
+ goto_model.goto_functions .function_map .erase (
369
+ goto_functionst::entry_point ());
370
370
371
- if (ansi_c_entry_point (symbol_table, get_message_handler ()))
371
+ if (ansi_c_entry_point (goto_model. symbol_table , get_message_handler ()))
372
372
return true ;
373
373
374
374
// entry_point may (should) add some more functions.
375
- convert_symbols (compiled_functions );
375
+ convert_symbols (goto_model. goto_functions );
376
376
}
377
377
378
- if (write_object_file (
379
- output_file_executable, symbol_table, compiled_functions))
378
+ if (write_object_file (output_file_executable, goto_model))
380
379
return true ;
381
380
382
- return add_written_cprover_symbols (symbol_table);
381
+ return add_written_cprover_symbols (goto_model. symbol_table );
383
382
}
384
383
385
384
// / parses source files and writes object files, or keeps the symbols in the
@@ -419,7 +418,7 @@ bool compilet::compile()
419
418
// output an object file for every source file
420
419
421
420
// "compile" functions
422
- convert_symbols (compiled_functions );
421
+ convert_symbols (goto_model. goto_functions );
423
422
424
423
std::string cfn;
425
424
@@ -436,14 +435,13 @@ bool compilet::compile()
436
435
else
437
436
cfn = output_file_object;
438
437
439
- if (write_object_file (cfn, symbol_table, compiled_functions ))
438
+ if (write_object_file (cfn, goto_model ))
440
439
return true ;
441
440
442
- if (add_written_cprover_symbols (symbol_table))
441
+ if (add_written_cprover_symbols (goto_model. symbol_table ))
443
442
return true ;
444
443
445
- symbol_table.clear (); // clean symbol table for next source file.
446
- compiled_functions.clear ();
444
+ goto_model.clear (); // clean symbol table for next source file.
447
445
}
448
446
}
449
447
@@ -582,10 +580,9 @@ bool compilet::parse_stdin()
582
580
// / \return true on error, false otherwise
583
581
bool compilet::write_object_file (
584
582
const std::string &file_name,
585
- const symbol_tablet &lsymbol_table,
586
- goto_functionst &functions)
583
+ const goto_modelt &goto_model)
587
584
{
588
- return write_bin_object_file (file_name, lsymbol_table, functions );
585
+ return write_bin_object_file (file_name, goto_model );
589
586
}
590
587
591
588
// / writes the goto functions in the function table to a binary format object
@@ -594,15 +591,14 @@ bool compilet::write_object_file(
594
591
// / \return true on error, false otherwise
595
592
bool compilet::write_bin_object_file (
596
593
const std::string &file_name,
597
- const symbol_tablet &lsymbol_table,
598
- goto_functionst &functions)
594
+ const goto_modelt &goto_model)
599
595
{
600
596
statistics () << " Writing binary format object `"
601
597
<< file_name << " '" << eom;
602
598
603
599
// symbols
604
- statistics () << " Symbols in table: "
605
- << lsymbol_table. symbols . size () << eom;
600
+ statistics () << " Symbols in table: " << goto_model. symbol_table . symbols . size ()
601
+ << eom;
606
602
607
603
std::ofstream outfile (file_name, std::ios::binary);
608
604
@@ -612,12 +608,12 @@ bool compilet::write_bin_object_file(
612
608
return true ;
613
609
}
614
610
615
- if (write_goto_binary (outfile, lsymbol_table, functions ))
611
+ if (write_goto_binary (outfile, goto_model ))
616
612
return true ;
617
613
618
- const auto cnt = function_body_count (functions );
614
+ const auto cnt = function_body_count (goto_model. goto_functions );
619
615
620
- statistics () << " Functions: " << functions .function_map .size ()
616
+ statistics () << " Functions: " << goto_model. goto_functions .function_map .size ()
621
617
<< " ; " << cnt << " have a body." << eom;
622
618
623
619
outfile.close ();
@@ -637,13 +633,13 @@ bool compilet::parse_source(const std::string &file_name)
637
633
return true ;
638
634
639
635
// we just typecheck one file here
640
- if (language_files.typecheck (symbol_table))
636
+ if (language_files.typecheck (goto_model. symbol_table ))
641
637
{
642
638
error () << " CONVERSION ERROR" << eom;
643
639
return true ;
644
640
}
645
641
646
- if (language_files.final (symbol_table))
642
+ if (language_files.final (goto_model. symbol_table ))
647
643
{
648
644
error () << " CONVERSION ERROR" << eom;
649
645
return true ;
@@ -655,7 +651,10 @@ bool compilet::parse_source(const std::string &file_name)
655
651
// / constructor
656
652
// / \return nothing
657
653
compilet::compilet (cmdlinet &_cmdline, message_handlert &mh, bool Werror)
658
- : messaget(mh), ns(symbol_table), cmdline(_cmdline), warning_is_fatal(Werror)
654
+ : messaget(mh),
655
+ ns(goto_model.symbol_table),
656
+ cmdline(_cmdline),
657
+ warning_is_fatal(Werror)
659
658
{
660
659
mode=COMPILE_LINK_EXECUTABLE;
661
660
echo_file_name=false ;
@@ -693,28 +692,29 @@ void compilet::add_compiler_specific_defines(configt &config) const
693
692
694
693
void compilet::convert_symbols (goto_functionst &dest)
695
694
{
696
- goto_convert_functionst converter (symbol_table, get_message_handler ());
695
+ goto_convert_functionst converter (
696
+ goto_model.symbol_table , get_message_handler ());
697
697
698
698
// the compilation may add symbols!
699
699
700
700
symbol_tablet::symbolst::size_type before=0 ;
701
701
702
- while (before!= symbol_table.symbols .size ())
702
+ while (before != goto_model. symbol_table .symbols .size ())
703
703
{
704
- before= symbol_table.symbols .size ();
704
+ before = goto_model. symbol_table .symbols .size ();
705
705
706
706
typedef std::set<irep_idt> symbols_sett;
707
707
symbols_sett symbols;
708
708
709
- for (const auto &named_symbol : symbol_table.symbols )
709
+ for (const auto &named_symbol : goto_model. symbol_table .symbols )
710
710
symbols.insert (named_symbol.first );
711
711
712
712
// the symbol table iterators aren't stable
713
713
for (const auto &symbol : symbols)
714
714
{
715
715
symbol_tablet::symbolst::const_iterator s_it =
716
- symbol_table.symbols .find (symbol);
717
- CHECK_RETURN (s_it != symbol_table.symbols .end ());
716
+ goto_model. symbol_table .symbols .find (symbol);
717
+ CHECK_RETURN (s_it != goto_model. symbol_table .symbols .end ());
718
718
719
719
if (s_it->second .type .id ()==ID_code &&
720
720
!s_it->second .is_macro &&
@@ -724,7 +724,8 @@ void compilet::convert_symbols(goto_functionst &dest)
724
724
{
725
725
debug () << " Compiling " << s_it->first << eom;
726
726
converter.convert_function (s_it->first , dest.function_map [s_it->first ]);
727
- symbol_table.get_writeable_ref (symbol).value = exprt (" compiled" );
727
+ goto_model.symbol_table .get_writeable_ref (symbol).value =
728
+ exprt (" compiled" );
728
729
}
729
730
}
730
731
}
0 commit comments