31 #define NOT_POSTFIX 'N'
37 #define OPERAND_SEPARATOR ' '
40 #define LINE_SEPARATOR ";\n"
44 #define NESTING_OPEN_LINE_SEPARATOR "(;\n"
48 #define NESTING_CLOSED_LINE_SEPARATOR ");\n"
51 #define REFERENCE_FLAG '#'
54 #define SCOPE_SEPARATOR "::"
63 static std::vector<exprt>
66 std::vector<exprt> result;
67 if(ID_not != lhs.
id() && ID_not != rhs.
id())
70 result.push_back(lhs);
73 else if(ID_not != lhs.
id() && ID_not == rhs.
id())
76 result.push_back(lhs);
79 else if(ID_not == lhs.
id() && ID_not != rhs.
id())
83 result.push_back(rhs);
89 result.push_back(rhs);
134 if(ID_and == expr.
id())
136 else if(ID_or == expr.
id())
138 else if(ID_xor == expr.
id())
140 else if(ID_notequal == expr.
id())
142 else if(ID_equal == expr.
id())
144 else if(ID_symbol == expr.
id())
146 else if(ID_not == expr.
id() &&
to_not_expr(expr).op().is_boolean())
156 std::vector<exprt> operands = expr.
operands();
162 std::vector<exprt> operands = expr.
operands();
168 std::vector<exprt> operands = expr.
operands();
174 std::vector<exprt> operands = expr.
operands();
180 std::vector<exprt> operands =
191 if(ID_symbol == expr.
op().
id())
218 std::vector<exprt> &operands,
219 const char operation)
231 const std::vector<exprt> &operands,
232 const char operation)
234 for(
const exprt &op : operands)
236 if(ID_not == op.id())
251 if(op.
id() == ID_symbol)
269 exprt non_trivial_op;
270 for(
auto it{begin(operands)}; it != end(operands); ++it)
273 (ID_symbol == it->id()) ||
278 non_trivial_op = *it;
294 std::string shorthand =
id2string(identifier);
301 if(
pos != std::string::npos)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Class for saving the internal state of the conversion process.
void convert_multiary_bool(std::vector< exprt > &operands, const char operation)
Iterates through all the given operands and converts them depending on the operation.
void convert_bool_operand(const exprt &op)
Converts a single boolean operand and introduces an additional nesting layer if needed.
std::string convert(const exprt &expr)
Invokes the conversion process for the given expression and calls itself recursively in the process.
void convert_multiary_bool_operands(const std::vector< exprt > &operands, const char operation)
Iterates through all the given operands and converts them depending on the operation.
void convert_first_non_trivial_operand(std::vector< exprt > &operands)
Iterates through all the given operands in search for the first non-trivial operand (that encloses al...
bool is_reference
Flag to specify if the next symbol to convert is a reference to a variable.
expr2stlt(const namespacet &ns)
Creates a new instance of the converter.
const namespacet & ns
Contains the symbol table of the current program to convert.
irep_idt id_shorthand(const irep_idt &identifier)
Returns the given identifier in a form that is compatible with STL by looking up the symbol or cuttin...
std::stringstream result
Used for saving intermediate results of the conversion process.
bool inside_bit_string
Internal representation of the FC bit in STL.
Base class for all expressions.
bool is_boolean() const
Return whether the expression represents a Boolean.
const irep_idt & id() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
irep_idt base_name
Base (non-scoped) name.
The type of an expression, extends irept.
std::string expr2c(const exprt &expr, const namespacet &ns, const expr2c_configurationt &configuration)
std::string type2c(const typet &type, const namespacet &ns, const expr2c_configurationt &configuration)
#define NESTING_OPEN_LINE_SEPARATOR
Separator for the end of an instruction that introduces a new layer of nesting.
#define SCOPE_SEPARATOR
CBMC-internal separator for variable scopes.
#define NOT_POSTFIX
Postfix for any negated boolean instruction.
#define REFERENCE_FLAG
Prefix for the reference to any variable.
#define OPERAND_SEPARATOR
Separator between the instruction code and it's operand.
#define OR
STL code for an OR instruction.
#define XOR
STL code for a XOR instruction.
static std::vector< exprt > instrument_equal_operands(const exprt &lhs, const exprt &rhs)
Modifies the parameters of a binary equal expression with the help of its symmetry properties.
std::string expr2stl(const exprt &expr, const namespacet &ns)
Converts a given expression to human-readable STL code.
std::string type2stl(const typet &type, const namespacet &ns)
Converts a given type to human-readable STL code.
#define LINE_SEPARATOR
Separator between the end of an instruction and the next one.
#define NESTING_CLOSED_LINE_SEPARATOR
Separator for the end of an instruction that closes a nesting layer.
#define AND
STL code for an AND instruction.
#define NOT
STL code for a NOT instruction.
static bool is_not_bool(const exprt &expr)
Checks if the expression or one of its parameters is not of type bool.
const std::string & id2string(const irep_idt &d)
bool is_reference(const typet &type)
Returns true if the type is a reference.
#define PRECONDITION(CONDITION)
API to expression classes.
const xor_exprt & to_xor_expr(const exprt &expr)
Cast an exprt to a xor_exprt.
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
const or_exprt & to_or_expr(const exprt &expr)
Cast an exprt to a or_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const and_exprt & to_and_expr(const exprt &expr)
Cast an exprt to a and_exprt.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
size_t strlen(const char *s)
bool has_suffix(const std::string &s, const std::string &suffix)