CBMC
typedef_type.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_ANSI_C_TYPEDEF_TYPE_H
10 #define CPROVER_ANSI_C_TYPEDEF_TYPE_H
11 
12 #include <util/type.h>
13 
15 class typedef_typet : public typet
16 {
17 public:
18  explicit typedef_typet(const irep_idt &identifier) : typet(ID_typedef_type)
19  {
20  set_identifier(identifier);
21  }
22 
23  void set_identifier(const irep_idt &identifier)
24  {
25  set(ID_identifier, identifier);
26  }
27 
28  const irep_idt &get_identifier() const
29  {
30  return get(ID_identifier);
31  }
32 };
33 
39 inline const typedef_typet &to_typedef_type(const typet &type)
40 {
41  PRECONDITION(type.id() == ID_typedef_type);
42  return static_cast<const typedef_typet &>(type);
43 }
44 
48 {
49  PRECONDITION(type.id() == ID_typedef_type);
50  return static_cast<typedef_typet &>(type);
51 }
52 
53 template <>
54 inline bool can_cast_type<typedef_typet>(const typet &type)
55 {
56  return type.id() == ID_typedef_type;
57 }
58 
59 #endif // CPROVER_ANSI_C_TYPEDEF_TYPE_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
typedef_typet
A typedef.
Definition: typedef_type.h:15
typet
The type of an expression, extends irept.
Definition: type.h:28
typedef_typet::set_identifier
void set_identifier(const irep_idt &identifier)
Definition: typedef_type.h:23
typedef_typet::get_identifier
const irep_idt & get_identifier() const
Definition: typedef_type.h:28
irept::get
const irep_idt & get(const irep_idt &name) const
Definition: irep.cpp:45
type.h
can_cast_type< typedef_typet >
bool can_cast_type< typedef_typet >(const typet &type)
Definition: typedef_type.h:54
irept::set
void set(const irep_idt &name, const irep_idt &value)
Definition: irep.h:420
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
irept::id
const irep_idt & id() const
Definition: irep.h:396
to_typedef_type
const typedef_typet & to_typedef_type(const typet &type)
Cast a generic typet to a typedef_typet.
Definition: typedef_type.h:39
typedef_typet::typedef_typet
typedef_typet(const irep_idt &identifier)
Definition: typedef_type.h:18