Skip to content

Commit 69fbaa2

Browse files
author
Daniel Kroening
committed
compilet no longer uses language_uit
1 parent 7de9df8 commit 69fbaa2

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

src/goto-cc/compile.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Date: June 2006
3434
#include <goto-programs/read_goto_binary.h>
3535
#include <goto-programs/write_goto_binary.h>
3636

37+
#include <langapi/language_file.h>
3738
#include <langapi/mode.h>
3839

3940
#include <linking/static_lifetime_init.h>
@@ -80,8 +81,8 @@ bool compilet::doit()
8081
add_compiler_specific_defines(config);
8182

8283
// Parse command line for source and object file names
83-
for(std::size_t i=0; i<_cmdline.args.size(); i++)
84-
if(add_input_file(_cmdline.args[i]))
84+
for(std::size_t i = 0; i < cmdline.args.size(); i++)
85+
if(add_input_file(cmdline.args[i]))
8586
return true;
8687

8788
for(std::list<std::string>::const_iterator it = libraries.begin();
@@ -456,7 +457,9 @@ bool compilet::compile()
456457

457458
/// parses a source file (low-level parsing)
458459
/// \return true on error, false otherwise
459-
bool compilet::parse(const std::string &file_name)
460+
bool compilet::parse(
461+
const std::string &file_name,
462+
language_filest &language_files)
460463
{
461464
if(file_name=="-")
462465
return parse_stdin();
@@ -527,8 +530,7 @@ bool compilet::parse(const std::string &file_name)
527530

528531
if(lf.language->parse(infile, file_name))
529532
{
530-
if(get_ui()==ui_message_handlert::uit::PLAIN)
531-
error() << "PARSING ERROR" << eom;
533+
error() << "PARSING ERROR" << eom;
532534
return true;
533535
}
534536
}
@@ -571,8 +573,7 @@ bool compilet::parse_stdin()
571573
{
572574
if(language.parse(std::cin, ""))
573575
{
574-
if(get_ui()==ui_message_handlert::uit::PLAIN)
575-
error() << "PARSING ERROR" << eom;
576+
error() << "PARSING ERROR" << eom;
576577
return true;
577578
}
578579
}
@@ -634,29 +635,32 @@ bool compilet::write_bin_object_file(
634635
/// \return true on error, false otherwise
635636
bool compilet::parse_source(const std::string &file_name)
636637
{
637-
if(parse(file_name))
638+
language_filest language_files;
639+
language_files.set_message_handler(get_message_handler());
640+
641+
if(parse(file_name, language_files))
638642
return true;
639643

640-
if(typecheck()) // we just want to typecheck this one file here
644+
// we just typecheck one file here
645+
if(language_files.typecheck(symbol_table))
646+
{
647+
error() << "CONVERSION ERROR" << eom;
641648
return true;
649+
}
642650

643-
if((has_suffix(file_name, ".class") ||
644-
has_suffix(file_name, ".jar")) &&
645-
final())
651+
if(language_files.final(symbol_table))
652+
{
653+
error() << "CONVERSION ERROR" << eom;
646654
return true;
655+
}
647656

648-
// so we remove it from the list afterwards
649-
language_files.remove_file(file_name);
650657
return false;
651658
}
652659

653660
/// constructor
654661
/// \return nothing
655-
compilet::compilet(cmdlinet &_cmdline, ui_message_handlert &mh, bool Werror):
656-
language_uit(_cmdline, mh),
657-
ns(symbol_table),
658-
cmdline(_cmdline),
659-
warning_is_fatal(Werror)
662+
compilet::compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)
663+
: messaget(mh), ns(symbol_table), cmdline(_cmdline), warning_is_fatal(Werror)
660664
{
661665
mode=COMPILE_LINK_EXECUTABLE;
662666
echo_file_name=false;

src/goto-cc/compile.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@ Date: June 2006
1414
#ifndef CPROVER_GOTO_CC_COMPILE_H
1515
#define CPROVER_GOTO_CC_COMPILE_H
1616

17-
#include <util/symbol.h>
17+
#include <util/cmdline.h>
18+
#include <util/message.h>
1819
#include <util/rename_symbol.h>
20+
#include <util/symbol_table.h>
1921

20-
#include <langapi/language_ui.h>
2122
#include <goto-programs/goto_model.h>
2223

23-
class compilet:public language_uit
24+
class language_filest;
25+
26+
class compilet : public messaget
2427
{
2528
public:
29+
// compilation results
2630
namespacet ns;
31+
symbol_tablet symbol_table;
2732
goto_functionst compiled_functions;
33+
34+
// configuration
2835
bool echo_file_name;
2936
std::string working_directory;
3037
std::string override_language;
@@ -50,15 +57,15 @@ class compilet:public language_uit
5057
// the two options below are mutually exclusive -- use either or
5158
std::string output_file_object, output_directory_object;
5259

53-
compilet(cmdlinet &_cmdline, ui_message_handlert &mh, bool Werror);
60+
compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror);
5461

5562
~compilet();
5663

5764
bool add_input_file(const std::string &);
5865
bool find_library(const std::string &);
5966
bool add_files_from_archive(const std::string &file_name, bool thin_archive);
6067

61-
bool parse(const std::string &filename);
68+
bool parse(const std::string &filename, language_filest &);
6269
bool parse_stdin();
6370
bool doit();
6471
bool compile();

0 commit comments

Comments
 (0)