Go to the documentation of this file.
39 static inline bool failed(
bool error_indicator)
41 return error_indicator;
45 const std::vector<std::string> &symtab_filenames,
46 const std::string &gb_filename)
51 if(!out_file.is_open())
55 std::vector<std::ifstream> symtab_files;
56 for(
auto const &symtab_filename : symtab_filenames)
58 std::ifstream symtab_file{symtab_filename};
59 if(!symtab_file.is_open())
64 symtab_files.emplace_back(std::move(symtab_file));
70 symtab_language->set_message_handler(message_handler);
74 for(std::size_t ix = 0; ix < symtab_files.size(); ++ix)
76 auto const &symtab_filename = symtab_filenames[ix];
77 auto &symtab_file = symtab_files[ix];
78 if(
failed(symtab_language->parse(symtab_file, symtab_filename)))
81 source_location.
set_file(symtab_filename);
83 "failed to parse symbol table", source_location};
86 if(
failed(symtab_language->typecheck(symtab,
"<unused>")))
89 source_location.
set_file(symtab_filename);
91 "failed to typecheck symbol table", source_location};
95 if(
failed(
linking(linked_symbol_table, symtab, message_handler)))
98 "failed to link `" + symtab_filename +
"'"};
131 "expect at least one input file",
"<json-symtab-file>"};
133 std::vector<std::string> symtab_filenames =
cmdline.
args;
134 std::string gb_filename =
"a.out";
154 <<
"Usage: Purpose:\n"
156 <<
"symtab2gb [-?] [-h] [--help] show help\n"
157 "symtab2gb compile .json_symtabs\n"
158 " <json-symtab-file>+ to a single goto-binary\n"
159 " [--out <outfile>]\n\n"
160 "<json-symtab-file> a CBMC symbol table in\n"
162 "--out <outfile> specify the filename of\n"
163 " the resulting binary\n"
164 " (default: a.out)\n"
bool linking(symbol_tablet &dest_symbol_table, const symbol_tablet &new_symbol_table, message_handlert &message_handler)
Merges the symbol table new_symbol_table into dest_symbol_table, renaming symbols from new_symbol_tab...
virtual bool isset(char option) const
mstreamt & status() const
bool write_goto_binary(std::ostream &out, const symbol_tablet &symbol_table, const goto_functionst &goto_functions, irep_serializationt &irepconverter)
Writes a goto program to disc, using goto binary format.
Thrown when we can't handle something in an input source file.
void goto_convert(const codet &code, symbol_table_baset &symbol_table, goto_programt &dest, message_handlert &message_handler, const irep_idt &mode)
const char * CBMC_VERSION
std::unique_ptr< languaget > new_json_symtab_language()
symtab2gb_parse_optionst(int argc, const char *argv[])
std::string banner_string(const std::string &front_end, const std::string &version)
static bool failed(bool error_indicator)
void set_file(const irep_idt &file)
std::string get_value(char option) const
Thrown when some external system fails unexpectedly.
#define SYMTAB2GB_OPTIONS
void set_from_symbol_table(const symbol_tablet &)
void register_languages() override
void register_language(language_factoryt factory)
Register a language Note: registering a language is required for using the functions in language_util...
void swap(symbol_tablet &other)
Swap symbol maps between two symbol tables.
bool set(const cmdlinet &cmdline)
std::unique_ptr< languaget > new_ansi_c_language()
static std::string binary(const constant_exprt &src)
static void run_symtab2gb(const std::vector< std::string > &symtab_filenames, const std::string &gb_filename)
#define CPROVER_EXIT_SUCCESS
Success indicates the required analysis has been performed without error.
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
symbol_tablet symbol_table
Symbol table.
std::string align_center_with_border(const std::string &text)
Utility for displaying help centered messages borderered by "* *".
#define SYMTAB2GB_OUT_FILE_OPT