Skip to content

Commit a732eb4

Browse files
committed
Move magic "compiled" string behind an API in symbolt
1 parent e39ea2e commit a732eb4

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/goto-cc/compile.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,15 +718,13 @@ void compilet::convert_symbols(goto_functionst &dest)
718718
symbol_table.symbols.find(*it);
719719
assert(s_it!=symbol_table.symbols.end());
720720

721-
if(s_it->second.type.id()==ID_code &&
722-
!s_it->second.is_macro &&
723-
!s_it->second.is_type &&
724-
s_it->second.value.id()!="compiled" &&
725-
s_it->second.value.is_not_nil())
721+
if(
722+
s_it->second.is_function() && !s_it->second.is_compiled() &&
723+
s_it->second.value.is_not_nil())
726724
{
727725
debug() << "Compiling " << s_it->first << eom;
728726
converter.convert_function(s_it->first, dest.function_map[s_it->first]);
729-
symbol_table.get_writeable_ref(*it).value=exprt("compiled");
727+
symbol_table.get_writeable_ref(*it).mark_compiled();
730728
}
731729
}
732730
}

src/goto-programs/goto_convert_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void goto_convert_functionst::convert_function(
152152
f.type=to_code_type(symbol.type);
153153

154154
if(symbol.value.is_nil() ||
155-
symbol.value.id()=="compiled") /* goto_inline may have removed the body */
155+
symbol.is_compiled()) /* goto_inline may have removed the body */
156156
return;
157157

158158
if(symbol.value.id()!=ID_code)

src/util/irep_ids.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ IREP_ID_ONE(r_ok)
697697
IREP_ID_ONE(w_ok)
698698
IREP_ID_ONE(super_class)
699699
IREP_ID_ONE(exceptions_thrown_list)
700+
IREP_ID_ONE(compiled)
700701

701702
// Projects depending on this code base that wish to extend the list of
702703
// available ids should provide a file local_irep_ids.def in their source tree

src/util/symbol.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include <iosfwd>
2121

2222
#include "expr.h"
23+
#include "invariant.h"
2324

2425
/*! \brief Symbol table entry.
2526
\ingroup gr_symbol_table
@@ -107,6 +108,21 @@ class symbolt
107108
{
108109
return !is_type && !is_macro && type.id()==ID_code;
109110
}
111+
112+
/// Returns true iff the the symbol's value has been compiled to a goto
113+
/// program.
114+
bool is_compiled() const
115+
{
116+
return type.id() == ID_code && value == exprt(ID_compiled);
117+
}
118+
119+
/// Set the symbol's value to "compiled"; to be used once the code-typed value
120+
/// has been converted to a goto program.
121+
void mark_compiled()
122+
{
123+
PRECONDITION(type.id() == ID_code);
124+
value = exprt(ID_compiled);
125+
}
110126
};
111127

112128
std::ostream &operator<<(std::ostream &out, const symbolt &symbol);

0 commit comments

Comments
 (0)