@@ -12,25 +12,40 @@ Author: Daniel Kroening, kroening@kroening.com
1212#include " c_types.h"
1313#include " std_expr.h"
1414
15+ static array_typet make_type (const irep_idt &value)
16+ {
17+ exprt size_expr = from_integer (value.size () + 1 , c_index_type ());
18+ return array_typet (char_type (), size_expr);
19+ }
20+
1521string_constantt::string_constantt (const irep_idt &_value)
16- : nullary_exprt(ID_string_constant, typet( ))
22+ : nullary_exprt(ID_string_constant, make_type(_value ))
1723{
18- set_value (_value);
24+ value (_value);
1925}
2026
21- void string_constantt::set_value (const irep_idt &value )
27+ void string_constantt::value (const irep_idt &_value )
2228{
23- exprt size_expr = from_integer (value.size () + 1 , c_index_type ());
24- type ()=array_typet (char_type (), size_expr);
25- set (ID_value, value);
29+ exprt::type () = make_type (_value);
30+ set (ID_value, _value);
31+ }
32+
33+ const array_typet &string_constantt::type () const
34+ {
35+ return to_array_type (exprt::type ());
36+ }
37+
38+ array_typet &string_constantt::type ()
39+ {
40+ return to_array_type (exprt::type ());
2641}
2742
2843// / convert string into array constant
2944array_exprt string_constantt::to_array_expr () const
3045{
3146 const std::string &str=get_string (ID_value);
3247 std::size_t string_size=str.size ()+1 ; // we add the zero
33- const typet &char_type = to_array_type ( type ()). element_type ();
48+ const typet &char_type = string_constantt::char_type ();
3449 bool char_is_unsigned=char_type.id ()==ID_unsignedbv;
3550
3651 exprt size = from_integer (string_size, c_index_type ());
0 commit comments