Skip to content

Move magic "compiled" string behind an API in symbolt #2717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/goto-cc/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,15 +724,13 @@ void compilet::convert_symbols(goto_functionst &dest)
symbol_table.symbols.find(*it);
assert(s_it!=symbol_table.symbols.end());

if(s_it->second.type.id()==ID_code &&
!s_it->second.is_macro &&
!s_it->second.is_type &&
s_it->second.value.id()!="compiled" &&
s_it->second.value.is_not_nil())
if(
s_it->second.is_function() && !s_it->second.is_compiled() &&
s_it->second.value.is_not_nil())
{
debug() << "Compiling " << s_it->first << eom;
converter.convert_function(s_it->first, dest.function_map[s_it->first]);
symbol_table.get_writeable_ref(*it).value=exprt("compiled");
symbol_table.get_writeable_ref(*it).set_compiled();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-programs/goto_convert_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void goto_convert_functionst::convert_function(
f.type=to_code_type(symbol.type);

if(symbol.value.is_nil() ||
symbol.value.id()=="compiled") /* goto_inline may have removed the body */
symbol.is_compiled()) /* goto_inline may have removed the body */
return;

if(symbol.value.id()!=ID_code)
Expand Down
1 change: 1 addition & 0 deletions src/util/irep_ids.def
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ IREP_ID_ONE(w_ok)
IREP_ID_ONE(super_class)
IREP_ID_ONE(exceptions_thrown_list)
IREP_ID_TWO(C_java_method_type, #java_method_type)
IREP_ID_ONE(compiled)

// Projects depending on this code base that wish to extend the list of
// available ids should provide a file local_irep_ids.def in their source tree
Expand Down
16 changes: 16 additions & 0 deletions src/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
#include <iosfwd>

#include "expr.h"
#include "invariant.h"

/*! \brief Symbol table entry.
\ingroup gr_symbol_table
Expand Down Expand Up @@ -107,6 +108,21 @@ class symbolt
{
return !is_type && !is_macro && type.id()==ID_code;
}

/// Returns true iff the the symbol's value has been compiled to a goto
/// program.
bool is_compiled() const
{
return type.id() == ID_code && value == exprt(ID_compiled);
}

/// Set the symbol's value to "compiled"; to be used once the code-typed value
/// has been converted to a goto program.
void set_compiled()
{
PRECONDITION(type.id() == ID_code);
value = exprt(ID_compiled);
}
};

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