Skip to content

Commit de7f3b6

Browse files
author
Daniel Kroening
committed
format_expr now does index, c_bool constants, string constants
1 parent a06503b commit de7f3b6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/util/format_expr.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717
#include "format_type.h"
1818
#include "ieee_float.h"
1919
#include "invariant.h"
20+
#include "lispexpr.h"
2021
#include "mp_arith.h"
2122
#include "rational.h"
2223
#include "rational_tools.h"
@@ -128,12 +129,18 @@ static std::ostream &format_rec(
128129
else
129130
return os << src.pretty();
130131
}
131-
else if(type == ID_unsignedbv || type == ID_signedbv)
132+
else if(type == ID_unsignedbv ||
133+
type == ID_signedbv ||
134+
type == ID_c_bool)
132135
return os << *numeric_cast<mp_integer>(src);
133136
else if(type == ID_integer)
134137
return os << src.get_value();
138+
else if(type == ID_string)
139+
return os << '"' << escape(id2string(src.get_value())) << '"';
135140
else if(type == ID_floatbv)
136141
return os << ieee_floatt(src);
142+
else if(type == ID_pointer && src.is_zero())
143+
return os << src.get_value();
137144
else
138145
return os << src.pretty();
139146
}
@@ -165,6 +172,12 @@ std::ostream &format_rec(
165172
<< to_member_expr(expr).get_component_name();
166173
else if(id == ID_symbol)
167174
return os << to_symbol_expr(expr).get_identifier();
175+
else if(id == ID_index)
176+
{
177+
const auto &index_expr=to_index_expr(expr);
178+
return os << format(index_expr.array()) << '['
179+
<< format(index_expr.index()) << ']';
180+
}
168181
else if(id == ID_type)
169182
return format_rec(os, expr.type());
170183
else if(id == ID_forall || id == ID_exists)

src/util/json.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ class jsont
112112

113113
static const jsont null_json_object;
114114

115-
protected:
116115
static void escape_string(const std::string &, std::ostream &);
117116

117+
protected:
118118
explicit jsont(kindt _kind):kind(_kind)
119119
{
120120
}

0 commit comments

Comments
 (0)