cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
get_goto_model_from_c.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Get goto model
4
5
Author: Daniel Poetzl
6
7
\*******************************************************************/
8
9
#include "
get_goto_model_from_c.h
"
10
11
#include <
util/cmdline.h
>
12
#include <
util/config.h
>
13
#include <
util/exception_utils.h
>
14
#include <
util/invariant.h
>
15
#include <
util/message.h
>
16
#include <
util/symbol_table.h
>
17
18
#include <
ansi-c/ansi_c_language.h
>
19
#include <
ansi-c/goto-conversion/goto_convert_functions.h
>
20
#include <
langapi/language_file.h
>
21
#include <
langapi/mode.h
>
22
#include <
testing-utils/message.h
>
23
24
goto_modelt
get_goto_model_from_c
(std::istream &in)
25
{
26
{
27
const
bool
has_language =
get_language_from_mode
(ID_C) !=
nullptr
;
28
29
if
(!has_language)
30
{
31
register_language
(
new_ansi_c_language
);
32
}
33
}
34
35
{
36
cmdlinet
cmdline;
37
38
config
=
configt
{};
39
config
.main = std::string(
"main"
);
40
config
.set(cmdline);
41
}
42
43
language_filest
language_files;
44
45
language_filet
&language_file = language_files.
add_file
(
""
);
46
47
language_file.
language
=
get_language_from_mode
(ID_C);
48
CHECK_RETURN
(language_file.
language
);
49
50
languaget
&language = *language_file.
language
;
51
52
{
53
const
bool
error = language.
parse
(in,
""
,
null_message_handler
);
54
55
if
(error)
56
throw
invalid_input_exceptiont
(
"parsing failed"
);
57
}
58
59
language_file.
get_modules
();
60
61
goto_modelt
goto_model;
62
63
{
64
const
bool
error =
65
language_files.
typecheck
(goto_model.
symbol_table
,
null_message_handler
);
66
67
if
(error)
68
throw
invalid_input_exceptiont
(
"typechecking failed"
);
69
}
70
71
{
72
const
bool
error = language_files.
generate_support_functions
(
73
goto_model.
symbol_table
,
null_message_handler
);
74
75
if
(error)
76
throw
invalid_input_exceptiont
(
"support function generation failed"
);
77
}
78
79
goto_convert
(
80
goto_model.
symbol_table
, goto_model.
goto_functions
,
null_message_handler
);
81
82
return
goto_model;
83
}
84
85
goto_modelt
get_goto_model_from_c
(
const
std::string &code)
86
{
87
std::istringstream in(code);
88
return
get_goto_model_from_c
(in);
89
}
new_ansi_c_language
std::unique_ptr< languaget > new_ansi_c_language()
Definition
ansi_c_language.cpp:155
ansi_c_language.h
config
configt config
Definition
config.cpp:25
cmdlinet
Definition
cmdline.h:20
configt
Globally accessible architectural configuration.
Definition
config.h:144
goto_modelt
Definition
goto_model.h:27
goto_modelt::symbol_table
symbol_tablet symbol_table
Symbol table.
Definition
goto_model.h:31
goto_modelt::goto_functions
goto_functionst goto_functions
GOTO functions.
Definition
goto_model.h:34
invalid_input_exceptiont
Thrown when user-provided input cannot be processed.
Definition
exception_utils.h:163
language_filest
Definition
language_file.h:63
language_filest::typecheck
bool typecheck(symbol_table_baset &symbol_table, const bool keep_file_local, message_handlert &message_handler)
Definition
language_file.cpp:90
language_filest::generate_support_functions
bool generate_support_functions(symbol_table_baset &symbol_table, message_handlert &message_handler)
Definition
language_file.cpp:173
language_filest::add_file
language_filet & add_file(const std::string &filename)
Definition
language_file.h:77
language_filet
Definition
language_file.h:41
language_filet::get_modules
void get_modules()
Definition
language_file.cpp:35
language_filet::language
std::unique_ptr< languaget > language
Definition
language_file.h:46
languaget
Definition
language.h:37
languaget::parse
virtual bool parse(std::istream &instream, const std::string &path, message_handlert &message_handler)=0
cmdline.h
config.h
exception_utils.h
get_goto_model_from_c
goto_modelt get_goto_model_from_c(std::istream &in)
Definition
get_goto_model_from_c.cpp:24
get_goto_model_from_c.h
goto_convert
void goto_convert(const codet &code, symbol_table_baset &symbol_table, goto_programt &dest, message_handlert &message_handler, const irep_idt &mode)
Definition
goto_convert.cpp:2189
goto_convert_functions.h
Goto Programs with Functions.
language_file.h
get_language_from_mode
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
Definition
mode.cpp:51
register_language
void register_language(language_factoryt factory)
Register a language Note: registering a language is required for using the functions in language_util...
Definition
mode.cpp:39
mode.h
invariant.h
CHECK_RETURN
#define CHECK_RETURN(CONDITION)
Definition
invariant.h:495
message.h
symbol_table.h
Author: Diffblue Ltd.
null_message_handler
null_message_handlert null_message_handler
Definition
message.cpp:14
message.h
unit
testing-utils
get_goto_model_from_c.cpp
Generated by
1.17.0