|
8 | 8 |
|
9 | 9 | #include <langapi/language_file.h>
|
10 | 10 |
|
| 11 | +#include "abstract_goto_model.h" |
11 | 12 | #include "goto_model.h"
|
12 | 13 | #include "lazy_goto_functions_map.h"
|
13 | 14 | #include "goto_convert_functions.h"
|
14 | 15 |
|
15 | 16 | class cmdlinet;
|
16 | 17 | class optionst;
|
17 | 18 |
|
18 |
| -/// Interface for a provider of function definitions to report whether or not it |
19 |
| -/// can provide a definition (function body) for a given function ID. |
20 |
| -struct can_produce_functiont |
21 |
| -{ |
22 |
| - /// Determines if this function provider can produce a body for the given |
23 |
| - /// function |
24 |
| - /// \param id: function ID to query |
25 |
| - /// \return true if we can produce a function body, or false if we would leave |
26 |
| - /// it a bodyless stub. |
27 |
| - virtual bool can_produce_function(const irep_idt &id) const = 0; |
28 |
| -}; |
29 |
| - |
30 | 19 | /// Model that holds partially loaded map of functions
|
31 |
| -class lazy_goto_modelt : public can_produce_functiont |
| 20 | +class lazy_goto_modelt : public abstract_goto_modelt |
32 | 21 | {
|
33 | 22 | public:
|
34 | 23 | typedef std::function<
|
35 |
| - void(goto_model_functiont &function, const can_produce_functiont &)> |
| 24 | + void(goto_model_functiont &function, const abstract_goto_modelt &)> |
36 | 25 | post_process_functiont;
|
37 | 26 | typedef std::function<bool(goto_modelt &goto_model)> post_process_functionst;
|
38 | 27 |
|
@@ -65,8 +54,8 @@ class lazy_goto_modelt : public can_produce_functiont
|
65 | 54 | {
|
66 | 55 | return lazy_goto_modelt(
|
67 | 56 | [&handler, &options]
|
68 |
| - (goto_model_functiont &fun, const can_produce_functiont &cpf) { // NOLINT(*) |
69 |
| - handler.process_goto_function(fun, cpf, options); |
| 57 | + (goto_model_functiont &fun, const abstract_goto_modelt &model) { // NOLINT(*) |
| 58 | + handler.process_goto_function(fun, model, options); |
70 | 59 | },
|
71 | 60 | [&handler, &options] (goto_modelt &goto_model) -> bool { // NOLINT(*)
|
72 | 61 | return handler.process_goto_functions(goto_model, options);
|
@@ -100,7 +89,29 @@ class lazy_goto_modelt : public can_produce_functiont
|
100 | 89 | return std::move(model.goto_model);
|
101 | 90 | }
|
102 | 91 |
|
103 |
| - virtual bool can_produce_function(const irep_idt &id) const; |
| 92 | + // Implement the abstract_goto_modelt interface: |
| 93 | + |
| 94 | + /// Accessor to retrieve the internal goto_functionst. |
| 95 | + /// Use with care; concurrent use of get_goto_function will have side-effects |
| 96 | + /// on this map which may surprise users, including invalidating any iterators |
| 97 | + /// they have stored. |
| 98 | + const goto_functionst &get_goto_functions() const override |
| 99 | + { |
| 100 | + return goto_model->goto_functions; |
| 101 | + } |
| 102 | + |
| 103 | + const symbol_tablet &get_symbol_table() const override |
| 104 | + { |
| 105 | + return symbol_table; |
| 106 | + } |
| 107 | + |
| 108 | + bool can_produce_function(const irep_idt &id) const override; |
| 109 | + |
| 110 | + const goto_functionst::goto_functiont &get_goto_function(const irep_idt &id) |
| 111 | + override |
| 112 | + { |
| 113 | + return goto_functions.at(id); |
| 114 | + } |
104 | 115 |
|
105 | 116 | private:
|
106 | 117 | std::unique_ptr<goto_modelt> goto_model;
|
|
0 commit comments