24 if(expr_type.
id()==ID_array)
26 std::size_t op_width=width/expr.
operands().size();
33 if(tmp.size()!=op_width)
36 error() <<
"convert_constant: unexpected operand width" <<
eom;
40 for(std::size_t j=0; j<op_width; j++)
48 else if(expr_type.
id()==ID_string)
54 else if(expr_type.
id()==ID_range)
62 for(std::size_t i=0; i<width; i++)
64 bool bit=(binary[binary.size()-i-1]==
'1');
70 else if(expr_type.
id()==ID_unsignedbv ||
71 expr_type.
id()==ID_signedbv ||
72 expr_type.
id()==ID_bv ||
73 expr_type.
id()==ID_fixedbv ||
74 expr_type.
id()==ID_floatbv ||
75 expr_type.
id()==ID_c_enum ||
76 expr_type.
id()==ID_c_enum_tag ||
77 expr_type.
id()==ID_c_bool ||
78 expr_type.
id()==ID_c_bit_field ||
79 expr_type.
id()==ID_incomplete_c_enum)
83 if(binary.size()!=width)
86 error() <<
"wrong value length in constant: " 91 for(std::size_t i=0; i<width; i++)
93 bool bit=(binary[binary.size()-i-1]==
'1');
99 else if(expr_type.
id()==ID_enumeration)
104 for(std::size_t i=0; i<elements.size(); i++)
105 if(elements[i].
id()==value)
108 else if(expr_type.
id()==ID_verilog_signedbv ||
109 expr_type.
id()==ID_verilog_unsignedbv)
113 if(binary.size()*2!=width)
116 error() <<
"wrong value length in constant: " 121 for(std::size_t i=0; i<binary.size(); i++)
123 char bit=binary[binary.size()-i-1];
150 error() <<
"unknown character in Verilog constant:" The type of an expression.
const std::string & id2string(const irep_idt &d)
const mp_integer string2integer(const std::string &n, unsigned base)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
std::vector< irept > subt
boolbv_widtht boolbv_width
const irep_idt & get_value() const
A constant literal expression.
static mstreamt & eom(mstreamt &m)
virtual bvt convert_constant(const constant_exprt &expr)
const irep_idt & id() const
virtual const bvt & convert_bv(const exprt &expr)
const enumeration_typet & to_enumeration_type(const typet &type)
Cast a generic typet to a enumeration_typet.
const source_locationt & find_source_location() const
source_locationt source_location
void conversion_failed(const exprt &expr, bvt &bv)
numbering< irep_idt > string_numbering
#define forall_operands(it, expr)
const irept::subt & elements() const
literalt const_literal(bool value)
const std::string integer2binary(const mp_integer &n, std::size_t width)
const range_typet & to_range_type(const typet &type)
Cast a generic typet to a range_typet.
std::vector< literalt > bvt
bvt build_constant(const mp_integer &i, std::size_t width)
mp_integer get_from() const