|
1 |
| -#include <ansi-c/ansi_c_language.h> |
| 1 | +#include "api.h" |
| 2 | + |
| 3 | +#include <util/cmdline.h> |
| 4 | +#include <util/config.h> |
| 5 | +#include <util/message.h> |
| 6 | +#include <util/options.h> |
2 | 7 |
|
3 | 8 | #include <goto-programs/goto_model.h>
|
4 | 9 | #include <goto-programs/initialize_goto_model.h>
|
5 | 10 |
|
| 11 | +#include <ansi-c/ansi_c_language.h> |
6 | 12 | #include <langapi/mode.h>
|
7 | 13 |
|
8 |
| -#include <util/cmdline.h> |
9 |
| -#include <util/message.h> |
10 |
| -#include <util/options.h> |
11 |
| - |
12 |
| -#include "api.h" |
| 14 | +#include <memory> |
13 | 15 |
|
14 |
| -api_depst api_deps; |
15 | 16 | extern configt config;
|
16 | 17 |
|
17 |
| -void initialize() { |
18 |
| - // Initialise a null-message handler (we don't print anything in the API) |
19 |
| - api_deps.msg_handler = new null_message_handlert(); |
20 |
| - // Initialise default options |
21 |
| - api_deps.opts = new optionst(); |
22 |
| - // Needed to initialise the language options correctly |
23 |
| - cmdlinet cmdline; |
24 |
| - // config is global in config.cpp |
25 |
| - config.set(cmdline); |
26 |
| - // Initialise C language mode |
27 |
| - register_language(new_ansi_c_language); |
| 18 | +// Default initialise the api_dependencies object |
| 19 | +api_dependenciest::api_dependenciest() |
| 20 | + : // We don't print anything to the console as part of the API |
| 21 | + message_handler(new null_message_handlert()), |
| 22 | + // We create a default options object which we are going to |
| 23 | + // customise later. |
| 24 | + options(new optionst()) |
| 25 | +{ |
28 | 26 | }
|
29 | 27 |
|
30 |
| -goto_modelt load_model_from_files( |
31 |
| - const std::vector<std::string> &files, |
32 |
| - const optionst &options) |
| 28 | +api_dependenciest::~api_dependenciest() = default; |
| 29 | + |
| 30 | +cbmc_api::cbmc_api() : dependencies(new api_dependenciest()) |
| 31 | +{ |
| 32 | + // Needed to initialise the language options correctly |
| 33 | + cmdlinet cmdline; |
| 34 | + // config is global in config.cpp |
| 35 | + config.set(cmdline); |
| 36 | + // Initialise C language mode |
| 37 | + register_language(new_ansi_c_language); |
| 38 | +} |
| 39 | + |
| 40 | +cbmc_api::~cbmc_api() = default; |
| 41 | + |
| 42 | +void cbmc_api::load_model_from_files(const std::vector<std::string> &files) |
33 | 43 | {
|
34 |
| - // This could be nested inside a try/catch, but for now let's leave it alone. |
35 |
| - return initialize_goto_model(files, *api_deps.msg_handler, options); |
| 44 | + model = util_make_unique<goto_modelt>(initialize_goto_model( |
| 45 | + files, *dependencies->message_handler, *dependencies->options)); |
36 | 46 | }
|
0 commit comments