Skip to content

Commit a7b397d

Browse files
committed
First version of new binary being added.
1 parent d932d6f commit a7b397d

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ option(WITH_MEMORY_ANALYZER
206206
add_subdirectory(src)
207207
add_subdirectory(regression)
208208
add_subdirectory(unit)
209+
add_subdirectory(cpp_api)
209210

210211
cprover_default_properties(
211212
analyses
@@ -215,6 +216,7 @@ cprover_default_properties(
215216
cbmc
216217
cbmc-lib
217218
cpp
219+
bmc_api
218220
cprover
219221
cprover-lib
220222
crangler

cpp_api/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
add_executable(bmc_api call_bmc.cpp)
4+
5+
target_link_libraries(bmc_api goto-programs util langapi ansi-c)

cpp_api/call_bmc.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)