cprover
irep_ids.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Internal Representation
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
11
12#include "irep_ids.h"
13
14#include "invariant.h"
15
16#include "string_container.h"
17
18const char *irep_ids_table[]=
19{
20#define IREP_ID_ONE(id) #id,
21#define IREP_ID_TWO(id, str) #str,
22
23#include "irep_ids.def"
24
25 nullptr,
26};
27
28#ifdef USE_DSTRING
29
30enum class idt:unsigned
31{
32#define IREP_ID_ONE(the_id) id_##the_id,
33#define IREP_ID_TWO(the_id, str) id_##the_id,
34
35#include "irep_ids.def" // NOLINT(build/include)
36};
37
38#define IREP_ID_ONE(the_id) \
39 const dstringt ID_##the_id=dstringt::make_from_table_index( \
40 static_cast<unsigned>(idt::id_##the_id));
41#define IREP_ID_TWO(the_id, str) \
42 const dstringt ID_##the_id=dstringt::make_from_table_index( \
43 static_cast<unsigned>(idt::id_##the_id));
44
45#else
46
47#define IREP_ID_ONE(the_id) const std::string ID_##the_id(#the_id);
48#define IREP_ID_TWO(the_id, str) const std::string ID_##the_id(#the_id);
49
50#endif
51
52#include "irep_ids.def" // NOLINT(build/include)
53
55{
56 // pre-allocate empty string -- this gets index 0
57 get("");
58
59 // allocate strings
60 for(unsigned i=0; irep_ids_table[i]!=nullptr; i++)
61 {
62 unsigned x=operator[](irep_ids_table[i]);
63 INVARIANT(x==i, "i-th element is inserted at position i"); // sanity check
64 }
65}
unsigned get(const char *s)
unsigned operator[](const char *s)
const char * irep_ids_table[]
Definition: irep_ids.cpp:18
idt
Definition: irep_ids.cpp:31
Container for C-Strings.