Skip to content

Commit a4f5d77

Browse files
committed
goto_modelt: implement abstract_goto_modelt
1 parent 311ca9c commit a4f5d77

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

src/goto-programs/goto_model.h

+68-1
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ Author: Daniel Kroening, [email protected]
1515
#include <util/symbol_table.h>
1616
#include <util/journalling_symbol_table.h>
1717

18+
#include "abstract_goto_model.h"
1819
#include "goto_functions.h"
1920

2021
// A model is a pair consisting of a symbol table
2122
// and the CFGs for the functions.
2223

23-
class goto_modelt
24+
class goto_modelt : public abstract_goto_modelt
2425
{
2526
public:
27+
/// Symbol table. Direct access is deprecated; use the abstract_goto_modelt
28+
/// interface instead if possible.
2629
symbol_tablet symbol_table;
30+
/// GOTO functions. Direct access is deprecated; use the abstract_goto_modelt
31+
/// interface instead if possible.
2732
goto_functionst goto_functions;
2833

2934
void clear()
@@ -66,6 +71,68 @@ class goto_modelt
6671
}
6772

6873
void unload(const irep_idt &name) { goto_functions.unload(name); }
74+
75+
// Implement the abstract goto model interface:
76+
77+
const goto_functionst &get_goto_functions() const override
78+
{
79+
return goto_functions;
80+
}
81+
82+
const symbol_tablet &get_symbol_table() const override
83+
{
84+
return symbol_table;
85+
}
86+
87+
const goto_functionst::goto_functiont &get_goto_function(
88+
const irep_idt &id) override
89+
{
90+
return goto_functions.function_map.at(id);
91+
}
92+
93+
bool can_produce_function(const irep_idt &id) const override
94+
{
95+
return goto_functions.function_map.count(id);
96+
}
97+
};
98+
99+
/// Class providing the abstract GOTO model interface onto an unrelated
100+
/// symbol table and goto_functionst.
101+
class wrapper_goto_modelt : public abstract_goto_modelt
102+
{
103+
public:
104+
wrapper_goto_modelt(
105+
const symbol_tablet &symbol_table,
106+
const goto_functionst &goto_functions) :
107+
symbol_table(symbol_table),
108+
goto_functions(goto_functions)
109+
{
110+
}
111+
112+
const goto_functionst &get_goto_functions() const override
113+
{
114+
return goto_functions;
115+
}
116+
117+
const symbol_tablet &get_symbol_table() const override
118+
{
119+
return symbol_table;
120+
}
121+
122+
const goto_functionst::goto_functiont &get_goto_function(
123+
const irep_idt &id) override
124+
{
125+
return goto_functions.function_map.at(id);
126+
}
127+
128+
bool can_produce_function(const irep_idt &id) const override
129+
{
130+
return goto_functions.function_map.count(id);
131+
}
132+
133+
private:
134+
const symbol_tablet &symbol_table;
135+
const goto_functionst &goto_functions;
69136
};
70137

71138
/// Interface providing access to a single function in a GOTO model, plus its

0 commit comments

Comments
 (0)