|
| 1 | +// Test file to try loading a GOTO-model into memory and running a sample verification run on it. |
| 2 | +#include <iostream> |
| 3 | +#include <vector> |
| 4 | + |
| 5 | +#include <ansi-c/ansi_c_language.h> |
| 6 | + |
| 7 | +#include <langapi/mode.h> |
| 8 | + |
| 9 | +#include <goto-programs/goto_model.h> |
| 10 | +#include <goto-programs/initialize_goto_model.h> |
| 11 | + |
| 12 | +#include <util/config.h> |
| 13 | +#include <util/cmdline.h> |
| 14 | +#include <util/message.h> |
| 15 | +#include <util/options.h> |
| 16 | + |
| 17 | +int main(int argc, char *argv[]) |
| 18 | +{ |
| 19 | + try { |
| 20 | + std::cout << "Hello from API stub" << std::endl; |
| 21 | + |
| 22 | + // Convert argv to vector of strings for initialize_goto_model |
| 23 | + std::vector<std::string> arguments(argv + 1, argv + argc); |
| 24 | + |
| 25 | + // Initialise a null-message handler (we don't print anything yet) |
| 26 | + null_message_handlert null_msg_hnd; |
| 27 | + // Default options |
| 28 | + optionst opts; |
| 29 | + // Needed to initialise the language options correctly |
| 30 | + cmdlinet cmdline; |
| 31 | + |
| 32 | + // config is global in config.cpp |
| 33 | + config.set(cmdline); |
| 34 | + |
| 35 | + // Initialise C language mode |
| 36 | + register_language(new_ansi_c_language); |
| 37 | + |
| 38 | + std::cout << "[DEBUG] arguments is "; |
| 39 | + for (auto opt : arguments) { |
| 40 | + std::cout << " [] " << opt << std::endl; |
| 41 | + } |
| 42 | + |
| 43 | + // Assume that argv[] is a list of files passed |
| 44 | + goto_modelt model = initialize_goto_model(arguments, null_msg_hnd, opts); |
| 45 | + |
| 46 | + std::cout << "Successfully initialised goto_model" << std::endl; |
| 47 | + return 0; |
| 48 | + } catch (invalid_command_line_argument_exceptiont e) { |
| 49 | + std::cout << e.what() << std::endl; |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | + |
0 commit comments