-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathstatic_show_domain.cpp
73 lines (64 loc) · 1.99 KB
/
static_show_domain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*******************************************************************\
Module: goto-analyzer
Author: Martin Brain, [email protected]
\*******************************************************************/
#include "static_show_domain.h"
#include <util/options.h>
#include <analyses/dependence_graph.h>
#include <analyses/variable-sensitivity/variable_sensitivity_dependence_graph.h>
/// Runs the analyzer and then prints out the domain
/// \param goto_model: the program analyzed
/// \param ai: the abstract interpreter after it has been run to fix point
/// \param options: the parsed user options
/// \param out: output stream for the printing
void static_show_domain(
const goto_modelt &goto_model,
const ai_baset &ai,
const optionst &options,
std::ostream &out)
{
if(options.get_bool_option("json"))
{
out << ai.output_json(goto_model);
}
else if(options.get_bool_option("xml"))
{
out << ai.output_xml(goto_model);
}
else if(
options.get_bool_option("dot") &&
(options.get_bool_option("dependence-graph") ||
options.get_bool_option("dependence-graph-vs")))
{
// It would be nice to cast this to a grapht but C++ templates and
// inheritance need some care to work together.
if(options.get_bool_option("dependence-graph"))
{
auto d = dynamic_cast<const dependence_grapht *>(&ai);
INVARIANT(
d != nullptr,
"--dependence-graph should set ai to be a dependence_grapht");
out << "digraph g {\n";
d->output_dot(out);
out << "}\n";
}
else if(options.get_bool_option("dependence-graph-vs"))
{
auto d =
dynamic_cast<const variable_sensitivity_dependence_grapht *>(&ai);
INVARIANT(
d != nullptr,
"--dependence-graph-vsd should set ai to be a "
"variable_sensitivity_dependence_grapht");
out << "digraph g {\n";
d->output_dot(out);
out << "}\n";
}
UNREACHABLE;
}
else
{
// 'text' or console output
ai.output(goto_model, out);
}
}