|
31 | 31 | #include <solvers/floatbv/float_utils.h>
|
32 | 32 | #include <solvers/lowering/expr_lowering.h>
|
33 | 33 |
|
34 |
| -bool boolbvt::literal( |
35 |
| - const exprt &expr, |
36 |
| - const std::size_t bit, |
37 |
| - literalt &dest) const |
38 |
| -{ |
39 |
| - if(expr.type().id()==ID_bool) |
40 |
| - { |
41 |
| - INVARIANT( |
42 |
| - bit == 0, |
43 |
| - "boolean expressions shall be represented by a single bit and hence the " |
44 |
| - "only valid bit index is 0"); |
45 |
| - return prop_conv_solvert::literal(to_symbol_expr(expr), dest); |
46 |
| - } |
47 |
| - else |
48 |
| - { |
49 |
| - if(expr.id()==ID_symbol || |
50 |
| - expr.id()==ID_nondet_symbol) |
51 |
| - { |
52 |
| - const irep_idt &identifier=expr.get(ID_identifier); |
53 |
| - |
54 |
| - boolbv_mapt::mappingt::const_iterator it_m= |
55 |
| - map.mapping.find(identifier); |
56 |
| - |
57 |
| - if(it_m==map.mapping.end()) |
58 |
| - return true; |
59 |
| - |
60 |
| - const boolbv_mapt::map_entryt &map_entry=it_m->second; |
61 |
| - |
62 |
| - INVARIANT( |
63 |
| - bit < map_entry.literal_map.size(), "bit index shall be within bounds"); |
64 |
| - if(!map_entry.literal_map[bit].is_set) |
65 |
| - return true; |
66 |
| - |
67 |
| - dest=map_entry.literal_map[bit].l; |
68 |
| - return false; |
69 |
| - } |
70 |
| - else if(expr.id()==ID_index) |
71 |
| - { |
72 |
| - const index_exprt &index_expr=to_index_expr(expr); |
73 |
| - |
74 |
| - std::size_t element_width=boolbv_width(index_expr.type()); |
75 |
| - CHECK_RETURN(element_width != 0); |
76 |
| - |
77 |
| - const auto &index = index_expr.index(); |
78 |
| - PRECONDITION(index.id() == ID_constant); |
79 |
| - mp_integer index_int = |
80 |
| - numeric_cast_v<mp_integer>(to_constant_expr(index)); |
81 |
| - |
82 |
| - std::size_t offset = |
83 |
| - numeric_cast_v<std::size_t>(index_int * element_width); |
84 |
| - |
85 |
| - return literal(index_expr.array(), bit+offset, dest); |
86 |
| - } |
87 |
| - else if(expr.id()==ID_member) |
88 |
| - { |
89 |
| - const member_exprt &member_expr=to_member_expr(expr); |
90 |
| - |
91 |
| - const struct_typet::componentst &components= |
92 |
| - to_struct_type(expr.type()).components(); |
93 |
| - const irep_idt &component_name=member_expr.get_component_name(); |
94 |
| - |
95 |
| - std::size_t offset=0; |
96 |
| - |
97 |
| - for(const auto &c : components) |
98 |
| - { |
99 |
| - const typet &subtype = c.type(); |
100 |
| - |
101 |
| - if(c.get_name() == component_name) |
102 |
| - return literal(member_expr.struct_op(), bit + offset, dest); |
103 |
| - |
104 |
| - std::size_t element_width=boolbv_width(subtype); |
105 |
| - CHECK_RETURN(element_width != 0); |
106 |
| - |
107 |
| - offset+=element_width; |
108 |
| - } |
109 |
| - |
110 |
| - INVARIANT(false, "struct type should have accessed component"); |
111 |
| - } |
112 |
| - } |
113 |
| - |
114 |
| - INVARIANT(false, "expression should have a corresponding literal"); |
115 |
| -} |
116 |
| - |
117 | 34 | /// Convert expression to vector of literalts, using an internal
|
118 | 35 | /// cache to speed up conversion if available. Also assert the resultant
|
119 | 36 | /// vector is of a specific size, and freeze any elements if appropriate.
|
|
0 commit comments