38 static inline bool failed(
bool error_indicator)
40 return error_indicator;
44 const std::vector<std::string> &symtab_filenames,
45 const std::string &gb_filename,
46 const std::string &cmdline_verbosity)
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));
75 for(std::size_t ix = 0; ix < symtab_files.size(); ++ix)
77 auto const &symtab_filename = symtab_filenames[ix];
78 auto &symtab_file = symtab_files[ix];
80 symtab_language->parse(symtab_file, symtab_filename, message_handler)))
83 source_location.
set_file(symtab_filename);
85 "failed to parse symbol table", source_location};
88 if(
failed(symtab_language->typecheck(symtab,
"<unused>", message_handler)))
91 source_location.
set_file(symtab_filename);
93 "failed to typecheck symbol table", source_location};
97 if(
failed(
linking(linked_symbol_table, symtab, message_handler)))
100 "failed to link `" + symtab_filename +
"'"};
133 "expect at least one input file",
"<json-symtab-file>"};
135 std::vector<std::string> symtab_filenames =
cmdline.
args;
136 std::string gb_filename =
"a.out";
157 "Usage: \tPurpose:\n"
159 " {bsymtab2gb} [{y-?}] [{y-h}] [{y--help}] \t show this help\n"
160 " {bsymtab2gb} [options] {ujson-symtab-file...} \t compile CBMC symbol"
161 " table(s) in JSON format to a single goto-binary\n"
164 " {y--out} {uoutfile} \t specify the filename of the resulting binary"
165 " (default: a.out)\n"
166 " {y--verbosity} {u#} \t verbosity level\n");
std::unique_ptr< languaget > new_ansi_c_language()
std::string get_value(char option) const
virtual bool isset(char option) const
bool set(const cmdlinet &cmdline)
void set_from_symbol_table(const symbol_table_baset &)
symbol_tablet symbol_table
Symbol table.
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
Thrown when we can't handle something in an input source file.
static unsigned eval_verbosity(const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest.
mstreamt & status() const
void set_file(const irep_idt &file)
void swap(symbol_tablet &other)
Swap symbol maps between two symbol tables.
symtab2gb_parse_optionst(int argc, const char *argv[])
void register_languages() override
Thrown when some external system fails unexpectedly.
Document and give macros for the exit codes of CPROVER binaries.
#define CPROVER_EXIT_SUCCESS
Success indicates the required analysis has been performed without error.
void goto_convert(const codet &code, symbol_table_baset &symbol_table, goto_programt &dest, message_handlert &message_handler, const irep_idt &mode)
Goto Programs with Functions.
static std::string binary(const constant_exprt &src)
std::unique_ptr< languaget > new_json_symtab_language()
bool linking(symbol_table_baset &dest_symbol_table, const symbol_table_baset &new_symbol_table, message_handlert &message_handler)
Merges the symbol table new_symbol_table into dest_symbol_table, renaming symbols from new_symbol_tab...
void register_language(language_factoryt factory)
Register a language Note: registering a language is required for using the functions in language_util...
std::string align_center_with_border(const std::string &text)
Utility for displaying help centered messages borderered by "* *".
std::string banner_string(const std::string &front_end, const std::string &version)
static void run_symtab2gb(const std::vector< std::string > &symtab_filenames, const std::string &gb_filename, const std::string &cmdline_verbosity)
static bool failed(bool error_indicator)
#define SYMTAB2GB_OPTIONS
#define SYMTAB2GB_OUT_FILE_OPT
const char * CBMC_VERSION
static void write_goto_binary(std::ostream &out, const symbol_table_baset &symbol_table, const goto_functionst &goto_functions, irep_serializationt &irepconverter)
Writes a goto program to disc, using goto binary format.