27 unsigned width_suffix=0;
30 for(
unsigned i=0; i<src.size(); i++)
34 if(ch==
'u' || ch==
'U')
36 else if(ch==
'l' || ch==
'L')
38 else if(ch==
'i' || ch==
'I')
43 if((i+1)<src.size() && isdigit(src[i+1]))
48 else if(ch==
'j' || ch==
'J')
54 if(src.size()>=2 && src[0]==
'0' && tolower(src[1])==
'x')
58 std::string without_prefix(src, 2, std::string::npos);
61 else if(src.size()>=2 && src[0]==
'0' && tolower(src[1])==
'b')
66 std::string without_prefix(src, 2, std::string::npos);
69 else if(src.size()>=2 && src[0]==
'0' && isdigit(src[1]))
89 c_type=
is_unsigned?ID_unsigned_long_int:ID_signed_long_int;
91 c_type=
is_unsigned?ID_unsigned_long_long_int:ID_signed_long_long_int;
94 type.
set(ID_width, width_suffix);
95 type.
set(ID_C_c_type, c_type);
107 bool is_hex_or_oct_or_bin=(base==8) || (base==16) || (base==2);
109 #define FITS(width, signed) \ 110 ((signed?!is_unsigned:(is_unsigned || is_hex_or_oct_or_bin)) && \ 111 (power(2, signed?width-1:width)>value_abs)) 121 c_type=ID_signed_int;
127 c_type=ID_unsigned_int;
133 c_type=ID_signed_long_int;
140 c_type=ID_unsigned_long_int;
146 c_type=ID_signed_long_long_int;
153 c_type=ID_unsigned_long_long_int;
163 c_type=ID_unsigned_long_long_int;
166 c_type=ID_signed_long_long_int;
171 type.
set(ID_width, width);
172 type.
set(ID_C_c_type, c_type);
180 result=
exprt(ID_complex, complex_type);
188 result.
set(ID_C_base, base);
The type of an expression.
bool is_signed(const typet &t)
Convenience function – is the type signed?
struct configt::ansi_ct ansi_c
const mp_integer string2integer(const std::string &n, unsigned base)
#define FITS(width, signed)
unsigned unsafe_string2unsigned(const std::string &str, int base)
std::size_t long_long_int_width
API to expression classes.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
bool is_unsigned(const typet &t)
Convenience function – is the type unsigned?
Complex numbers made of pair of given subtype.
Base class for all expressions.
exprt convert_integer_literal(const std::string &src)
const typet & subtype() const
std::size_t long_int_width
void set(const irep_namet &name, const irep_idt &value)