-
Notifications
You must be signed in to change notification settings - Fork 274
introduce index_type and element_type for arrays and vectors #6552
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "std_types.h" | ||
|
||
#include "c_types.h" | ||
#include "namespace.h" | ||
#include "std_expr.h" | ||
|
||
|
@@ -28,6 +29,12 @@ void array_typet::check(const typet &type, const validation_modet vm) | |
} | ||
} | ||
|
||
typet array_typet::index_type() const | ||
{ | ||
// we may wish to make the index type part of the array type | ||
return ::index_type(); | ||
} | ||
|
||
/// Return the sequence number of the component with given name. | ||
std::size_t struct_union_typet::component_number( | ||
const irep_idt &component_name) const | ||
|
@@ -236,6 +243,12 @@ vector_typet::vector_typet(const typet &_subtype, const constant_exprt &_size) | |
size() = _size; | ||
} | ||
|
||
typet vector_typet::index_type() const | ||
{ | ||
// we may wish to make the index type part of the vector type | ||
return ::index_type(); | ||
} | ||
|
||
const constant_exprt &vector_typet::size() const | ||
{ | ||
return static_cast<const constant_exprt &>(find(ID_size)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -768,6 +768,17 @@ class array_typet:public type_with_subtypet | |
add(ID_size, std::move(_size)); | ||
} | ||
|
||
/// The type of the index expressions into any instance of this type. | ||
typet index_type() const; | ||
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. I am concerned that this may be confusing: we could end up in a situation where 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. I'd like to enforce that, going forward, using a precondition. |
||
|
||
/// The type of the elements of the array. | ||
/// This method is preferred over .subtype(), | ||
/// which will eventually be deprecated. | ||
const typet &element_type() const | ||
{ | ||
return subtype(); | ||
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. Should we actually hide 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. Yes, that will improve readability. |
||
} | ||
|
||
const exprt &size() const | ||
{ | ||
return static_cast<const exprt &>(find(ID_size)); | ||
|
@@ -976,6 +987,17 @@ class vector_typet:public type_with_subtypet | |
public: | ||
vector_typet(const typet &_subtype, const constant_exprt &_size); | ||
|
||
/// The type of any index expression into an instance of this type. | ||
typet index_type() const; | ||
|
||
/// The type of the elements of the vector. | ||
/// This method is preferred over .subtype(), | ||
/// which will eventually be deprecated. | ||
const typet &element_type() const | ||
{ | ||
return subtype(); | ||
} | ||
|
||
const constant_exprt &size() const; | ||
constant_exprt &size(); | ||
}; | ||
|
Uh oh!
There was an error while loading. Please reload this page.