-
Notifications
You must be signed in to change notification settings - Fork 273
Added can_cast_type implementation for code_typet #2605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -974,6 +974,12 @@ class code_typet:public typet | |
} | ||
}; | ||
|
||
template <> | ||
inline bool can_cast_type<code_typet>(const typet &type) | ||
{ | ||
return type.id() == ID_code; | ||
} | ||
|
||
/*! \brief Cast a generic typet to a \ref code_typet | ||
* | ||
* This is an unchecked conversion. \a type must be known to be \ref | ||
|
@@ -986,7 +992,8 @@ class code_typet:public typet | |
*/ | ||
inline const code_typet &to_code_type(const typet &type) | ||
{ | ||
PRECONDITION(type.id()==ID_code); | ||
PRECONDITION(can_cast_type<code_typet>(type)); | ||
validate_type(type); | ||
return static_cast<const code_typet &>(type); | ||
} | ||
|
||
|
@@ -995,10 +1002,12 @@ inline const code_typet &to_code_type(const typet &type) | |
*/ | ||
inline code_typet &to_code_type(typet &type) | ||
{ | ||
PRECONDITION(type.id()==ID_code); | ||
PRECONDITION(can_cast_type<code_typet>(type)); | ||
validate_type(type); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh - never heard of this before - any reason not to stick this in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this fails it doesn't mean that the type is not the right type, it means that there's an internal inconsistency. |
||
return static_cast<code_typet &>(type); | ||
} | ||
|
||
|
||
/*! \brief arrays with given size | ||
*/ | ||
class array_typet:public type_with_subtypet | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is what I meant