Skip to content

Commit 235fd05

Browse files
author
Daniel Kroening
committed
symbol_typet is now a tag_typet
1 parent f4d8ef7 commit 235fd05

File tree

1 file changed

+53
-61
lines changed

1 file changed

+53
-61
lines changed

src/util/std_types.h

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,19 @@ class real_typet:public typet
105105
}
106106
};
107107

108-
/*! \brief A reference into the symbol table
108+
/*! \brief A generic tag-based type
109109
*/
110-
class symbol_typet:public typet
110+
111+
class tag_typet:public typet
111112
{
112113
public:
113-
symbol_typet():typet(ID_symbol)
114+
explicit tag_typet(const irep_idt &_id):typet(_id)
114115
{
115116
}
116117

117-
explicit symbol_typet(const irep_idt &identifier):typet(ID_symbol)
118+
explicit tag_typet(
119+
const irep_idt &_id,
120+
const irep_idt &identifier):typet(_id)
118121
{
119122
set_identifier(identifier);
120123
}
@@ -130,6 +133,52 @@ class symbol_typet:public typet
130133
}
131134
};
132135

136+
/*! \brief Cast a generic typet to a \ref tag_typet
137+
*
138+
* This is an unchecked conversion. \a type must be known to be \ref
139+
* tag_typet.
140+
*
141+
* \param type Source type
142+
* \return Object of type \ref tag_typet
143+
*
144+
* \ingroup gr_std_types
145+
*/
146+
inline const tag_typet &to_tag_type(const typet &type)
147+
{
148+
PRECONDITION(type.id()==ID_symbol ||
149+
type.id()==ID_c_enum_tag ||
150+
type.id()==ID_struct_tag ||
151+
type.id()==ID_union_tag);
152+
return static_cast<const tag_typet &>(type);
153+
}
154+
155+
/*! \copydoc to_tag_type(const typet &)
156+
* \ingroup gr_std_types
157+
*/
158+
inline tag_typet &to_tag_type(typet &type)
159+
{
160+
PRECONDITION(type.id()==ID_symbol ||
161+
type.id()==ID_c_enum_tag ||
162+
type.id()==ID_struct_tag ||
163+
type.id()==ID_union_tag);
164+
return static_cast<tag_typet &>(type);
165+
}
166+
167+
/*! \brief A reference into the symbol table, used for typedefs
168+
*/
169+
class symbol_typet:public tag_typet
170+
{
171+
public:
172+
symbol_typet():tag_typet(ID_symbol)
173+
{
174+
}
175+
176+
explicit symbol_typet(const irep_idt &identifier):tag_typet(ID_symbol)
177+
{
178+
set_identifier(identifier);
179+
}
180+
};
181+
133182
/*! \brief Cast a generic typet to a \ref symbol_typet
134183
*
135184
* This is an unchecked conversion. \a type must be known to be \ref
@@ -486,63 +535,6 @@ inline union_typet &to_union_type(typet &type)
486535
return static_cast<union_typet &>(type);
487536
}
488537

489-
/*! \brief A generic tag-based type
490-
*/
491-
492-
class tag_typet:public typet
493-
{
494-
public:
495-
explicit tag_typet(const irep_idt &_id):typet(_id)
496-
{
497-
}
498-
499-
explicit tag_typet(
500-
const irep_idt &_id,
501-
const irep_idt &identifier):typet(_id)
502-
{
503-
set_identifier(identifier);
504-
}
505-
506-
void set_identifier(const irep_idt &identifier)
507-
{
508-
set(ID_identifier, identifier);
509-
}
510-
511-
const irep_idt &get_identifier() const
512-
{
513-
return get(ID_identifier);
514-
}
515-
};
516-
517-
/*! \brief Cast a generic typet to a \ref tag_typet
518-
*
519-
* This is an unchecked conversion. \a type must be known to be \ref
520-
* tag_typet.
521-
*
522-
* \param type Source type
523-
* \return Object of type \ref tag_typet
524-
*
525-
* \ingroup gr_std_types
526-
*/
527-
inline const tag_typet &to_tag_type(const typet &type)
528-
{
529-
PRECONDITION(type.id()==ID_c_enum_tag ||
530-
type.id()==ID_struct_tag ||
531-
type.id()==ID_union_tag);
532-
return static_cast<const tag_typet &>(type);
533-
}
534-
535-
/*! \copydoc to_tag_type(const typet &)
536-
* \ingroup gr_std_types
537-
*/
538-
inline tag_typet &to_tag_type(typet &type)
539-
{
540-
PRECONDITION(type.id()==ID_c_enum_tag ||
541-
type.id()==ID_struct_tag ||
542-
type.id()==ID_union_tag);
543-
return static_cast<tag_typet &>(type);
544-
}
545-
546538
/*! \brief A struct tag type
547539
*/
548540

0 commit comments

Comments
 (0)