File tree 6 files changed +74
-7
lines changed 6 files changed +74
-7
lines changed Original file line number Diff line number Diff line change 1
1
# This step builds a binary driving the API (to be used for testing)
2
- add_executable (api-binary-driver call_bmc.cpp api.cpp)
2
+ add_executable (api-binary-driver call_bmc.cpp api.cpp options .cpp )
3
3
target_link_libraries (api-binary-driver goto-programs util langapi ansi-c)
4
4
5
5
# This step builds the API in the form of a statically linked library (libcprover-api.a)
6
- add_library (cprover-api api.cpp)
6
+ add_library (cprover-api api.cpp options .cpp )
7
7
target_link_libraries (cprover-api goto-programs util langapi ansi-c)
8
8
9
9
install (TARGETS cprover-api RUNTIME DESTINATION lib)
Original file line number Diff line number Diff line change 12
12
#include < langapi/mode.h>
13
13
14
14
#include < memory>
15
+ #include < options.h>
15
16
16
17
extern configt config;
17
18
@@ -25,6 +26,13 @@ cbmc_api::api_dependenciest::api_dependenciest()
25
26
{
26
27
}
27
28
29
+ cbmc_api::api_dependenciest::api_dependenciest (const optionst options)
30
+ : // We don't print anything to the console as part of the API
31
+ message_handler(new null_message_handlert()),
32
+ options(util_make_unique<optionst>(options))
33
+ {
34
+ }
35
+
28
36
cbmc_api::api_dependenciest::~api_dependenciest () = default ;
29
37
30
38
cbmc_api::cbmc_api () : dependencies(new api_dependenciest())
@@ -37,6 +45,17 @@ cbmc_api::cbmc_api() : dependencies(new api_dependenciest())
37
45
register_language (new_ansi_c_language);
38
46
}
39
47
48
+ cbmc_api::cbmc_api (const api_optionst &options)
49
+ : dependencies(new api_dependenciest(options.to_engine_options()))
50
+ {
51
+ // Needed to initialise the language options correctly
52
+ cmdlinet cmdline;
53
+ // config is global in config.cpp
54
+ config.set (cmdline);
55
+ // Initialise C language mode
56
+ register_language (new_ansi_c_language);
57
+ }
58
+
40
59
cbmc_api::~cbmc_api () = default ;
41
60
42
61
void cbmc_api::load_model_from_files (const std::vector<std::string> &files)
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ class goto_modelt;
6
6
class message_handlert ;
7
7
class optionst ;
8
8
9
+ #include " options.h"
9
10
10
11
// An object in the pattern of Session Facade - owning all of the memory
11
12
// the API is using and being responsible for the management of that.
12
13
struct cbmc_api
13
14
{
14
15
// Initialising constructor
15
16
explicit cbmc_api ();
17
+ cbmc_api (const api_optionst &options);
16
18
~cbmc_api ();
17
19
18
20
// / Load a goto_model from a given vector of filenames.
@@ -25,7 +27,8 @@ struct cbmc_api
25
27
// A struct containing the API dependencies (some of them, at least)
26
28
struct api_dependenciest
27
29
{
28
- api_dependenciest ();
30
+ explicit api_dependenciest ();
31
+ api_dependenciest (const optionst options);
29
32
~api_dependenciest ();
30
33
31
34
std::unique_ptr<message_handlert> message_handler;
Original file line number Diff line number Diff line change 1
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
2
#include < util/exception_utils.h>
6
3
7
4
#include " api.h"
5
+ #include " options.h"
6
+
7
+ #include < iostream>
8
+ #include < vector>
8
9
9
10
int main (int argc, char *argv[])
10
11
{
@@ -14,8 +15,11 @@ int main(int argc, char *argv[])
14
15
// Convert argv to vector of strings for initialize_goto_model
15
16
std::vector<std::string> arguments (argv + 1 , argv + argc);
16
17
18
+ // Create API options object, to pass to initialiser of API object.
19
+ auto api_options = api_optionst::create ().simplify (false );
20
+
17
21
// Initialise API dependencies and global configuration in one step.
18
- cbmc_api api;
22
+ cbmc_api api (api_options) ;
19
23
20
24
// Demonstrate the loading of a goto-model from the command line arguments
21
25
api.load_model_from_files (arguments);
Original file line number Diff line number Diff line change
1
+ #include " options.h"
2
+
3
+ #include < util/options.h>
4
+
5
+ api_optionst api_optionst::create ()
6
+ {
7
+ return api_optionst{};
8
+ }
9
+
10
+ api_optionst &api_optionst::simplify (bool on)
11
+ {
12
+ simplify_enabled = on;
13
+ return *this ;
14
+ }
15
+
16
+ optionst api_optionst::to_engine_options () const
17
+ {
18
+ optionst engine_options;
19
+ engine_options.set_option (" simplify" , simplify_enabled);
20
+ return engine_options;
21
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ class optionst ;
4
+
5
+ class api_optionst
6
+ {
7
+ // Options for the verification engine
8
+ bool simplify_enabled;
9
+
10
+ // Private interface methods
11
+ api_optionst () = default ;
12
+
13
+ public:
14
+ ~api_optionst () = default ;
15
+ static api_optionst create ();
16
+
17
+ api_optionst &simplify (bool on);
18
+
19
+ optionst to_engine_options () const ;
20
+ };
You can’t perform that action at this time.
0 commit comments