Skip to content

Commit 311ca9c

Browse files
committed
Add abstract_goto_modelt
This provides an interface satisfiable by both goto_modelt and lazy_goto_modelt. It exposes the symbol table and function map, but with the caution that get_goto_function may produce functions on demand, and thereby have side-effects on either of them.
1 parent 7f3ba30 commit 311ca9c

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*******************************************************************\
2+
3+
Module: Abstract GOTO Model
4+
5+
Author: Diffblue Ltd.
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Abstract interface to eager or lazy GOTO models
11+
12+
#ifndef CPROVER_GOTO_PROGRAMS_ABSTRACT_GOTO_MODEL_H
13+
#define CPROVER_GOTO_PROGRAMS_ABSTRACT_GOTO_MODEL_H
14+
15+
#include "goto_functions.h"
16+
#include <util/symbol_table.h>
17+
18+
/// Abstract interface to eager or lazy GOTO models
19+
class abstract_goto_modelt
20+
{
21+
public:
22+
virtual ~abstract_goto_modelt()
23+
{
24+
}
25+
26+
/// Determines if this model can produce a body for the given function
27+
/// \param id: function ID to query
28+
/// \return true if we can produce a function body, or false if we would leave
29+
/// it a bodyless stub.
30+
virtual bool can_produce_function(const irep_idt &id) const = 0;
31+
32+
/// Get a GOTO function by name, or throw if no such function exists.
33+
/// May have side-effects on the GOTO function map provided by
34+
/// get_goto_functions, or the symbol table returned by get_symbol_table,
35+
/// so iterators pointing into either may be invalidated.
36+
/// \param id: function to get
37+
/// \return function body
38+
virtual const goto_functionst::goto_functiont &get_goto_function(
39+
const irep_idt &id) = 0;
40+
41+
/// Accessor to get a raw goto_functionst. Concurrent use of get_goto_function
42+
/// may invalidate iterators or otherwise surprise users by modifying the map
43+
/// underneath them, so this should only be used to lend a reference to code
44+
/// that cannot also call get_goto_function.
45+
virtual const goto_functionst &get_goto_functions() const = 0;
46+
47+
/// Accessor to get the symbol table. Concurrent use of get_goto_function
48+
/// may invalidate iterators or otherwise surprise users by modifying the map
49+
/// underneath them, so this should only be used to lend a reference to code
50+
/// that cannot also call get_goto_function.
51+
virtual const symbol_tablet &get_symbol_table() const = 0;
52+
};
53+
54+
#endif

0 commit comments

Comments
 (0)