8#include <unordered_map>
53 using entry = std::pair<std::string, typet>;
57 const std::string &
id,
58 const std::string &elem_id,
59 const typet &elem_type,
64 const std::string &
id,
66 const typet &elem_type,
72 const std::string &
id,
73 const typet &elem_type,
79 const std::string &from,
80 const std::string &to,
87 const std::string &from,
88 const std::string &to,
104 const std::string &
id,
106 const std::string &elem_id,
107 const typet &elem_type,
120 const std::string &
id,
126 const std::string &
id,
132 const std::string &
id,
138 const std::string &
id,
144 const std::string &
id,
150 const std::string &
id,
158 const std::string &
id,
167 const std::string &
id,
168 const std::string &func_name,
186 const std::string &
id,
189 size_t &float_type_id,
193 using slot_map = std::unordered_map<std::string, entries>;
198 return maps_[
static_cast<size_t>(slot)];
201 const slot_map &map_for(
type_slot slot)
const
204 return maps_[
static_cast<size_t>(slot)];
210 std::unordered_map<std::string, typet> pop_memo_;
The single owner of per-instance element-type tracking for the Python frontend: "which types does thi...
Definition element_type_registry.h:49
std::vector< entry > entries
Definition element_type_registry.h:54
void reverse(const std::string &id, type_slot slot=type_slot::elements)
Mirrors an in-place reversal so later index-based lookups stay correct.
Definition element_type_registry.cpp:104
const entries * find(const std::string &id, type_slot slot=type_slot::elements) const
The recorded entries, or nullptr when nothing is recorded.
Definition element_type_registry.cpp:131
void replace(const std::string &id, size_t index, const std::string &elem_id, const typet &elem_type, type_slot slot=type_slot::elements)
Mirrors a store of elem_id, of type elem_type, into element index.
Definition element_type_registry.cpp:113
void assign(const std::string &id, const typet &elem_type, type_slot slot=type_slot::elements)
Replaces id's entries with one entry of elem_type, which index lookups past it reuse as the type of e...
Definition element_type_registry.cpp:33
void pop_last(const std::string &id, type_slot slot=type_slot::elements)
Removes the most recently recorded entry, mirroring a pop from the end.
Definition element_type_registry.cpp:92
bool mixes_str_and_number(const std::string &id, type_slot slot=type_slot::elements) const
True when both a string and a number (int, float or bool) are recorded: no single static type reads e...
Definition element_type_registry.cpp:199
void record(const std::string &id, const std::string &elem_id, const typet &elem_type, type_slot slot=type_slot::elements)
Definition element_type_registry.cpp:24
typet last_element_type(const std::string &id, type_slot slot=type_slot::elements) const
The last recorded element's type; nil when nothing is recorded.
Definition element_type_registry.cpp:161
void set_element_type(const std::string &id, size_t index, const typet &elem_type, type_slot slot=type_slot::elements)
Updates the type of the element at index.
Definition element_type_registry.cpp:41
void assign_from(const std::string &from, const std::string &to, type_slot slot=type_slot::elements)
Replaces to's entries with from's, leaving to untouched when from has nothing recorded.
Definition element_type_registry.cpp:57
typet homogeneous_element_type(const std::string &id, const std::string &func_name, type_slot slot=type_slot::elements) const
The common element type for an operation requiring one, promoting an int/float mix to double_type() a...
Definition element_type_registry.cpp:262
bool has_mixed_numeric(const std::string &id, type_slot slot=type_slot::elements) const
True when both integer and floating-point elements are recorded.
Definition element_type_registry.cpp:180
typet numeric_element_type(const std::string &id, type_slot slot=type_slot::elements) const
Non-throwing element type of an all-numeric instance: double_type() when int and float mix (Python pr...
Definition element_type_registry.cpp:237
size_t size(const std::string &id, type_slot slot=type_slot::elements) const
Definition element_type_registry.cpp:140
typet uniform_element_type(const std::string &id, type_slot slot=type_slot::elements) const
The shared type of every recorded element, or nil when nothing is recorded or the elements disagree.
Definition element_type_registry.cpp:221
std::pair< std::string, typet > entry
A recorded element: its symbol id, empty when the type came from an annotation rather than a concrete...
Definition element_type_registry.h:53
typet element_type(const std::string &id, size_t index=0, type_slot slot=type_slot::elements) const
The type at index, falling back to the first element's type when index is out of bounds.
Definition element_type_registry.cpp:146
void append_from(const std::string &from, const std::string &to, size_t times=1, type_slot slot=type_slot::elements)
Appends from's entries onto to's, times over.
Definition element_type_registry.cpp:72
std::string element_id(const std::string &id, size_t index, type_slot slot=type_slot::elements) const
The symbol id at index; empty when out of bounds or unrecorded.
Definition element_type_registry.cpp:169
void memoize_pop_type(const std::string &site, const typet &elem_type)
Definition element_type_registry.cpp:318
void type_flags(const std::string &id, const type_handler &th, int &type_flag, size_t &float_type_id, type_slot slot=type_slot::elements) const
Computes the type_flag and float_type_id encoding shared with __ESBMC_list_sort and __ESBMC_list_lt: ...
Definition element_type_registry.cpp:325
typet memoized_pop_type(const std::string &site) const
The element type already answered for one syntactic pop() site, or nil when that site has not been an...
Definition element_type_registry.cpp:312
Definition type_handler.h:113
type_slot
Selects which per-instance element-type sequence a registry query addresses.
Definition element_type_registry.h:21
@ slot_count
Number of slots. Not a slot itself.
Definition element_type_registry.h:32
@ elements
The container's own elements: lists, sets, tuples, and a dict's internal keys/values lists.
Definition element_type_registry.h:24
@ dict_value_list_elems
The uniform element type of a literal dict's list-typed values, keyed by its values-list symbol id,...
Definition element_type_registry.h:30
@ dict_value_types
A literal dict's per-value types, keyed by its values-list symbol id.
Definition element_type_registry.h:27