-
Notifications
You must be signed in to change notification settings - Fork 269
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
introduce index_type and element_type for arrays and vectors #6552
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #6552 +/- ##
===========================================
- Coverage 75.98% 75.98% -0.01%
===========================================
Files 1578 1578
Lines 181058 181070 +12
===========================================
+ Hits 137579 137585 +6
- Misses 43479 43485 +6
Continue to review full report at Codecov.
|
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.
Shouldn't we rather strive towards a situation where an array index can be of an arbitrary numeric type?
/// The type of the elements of the array. | ||
const typet &element_type() const | ||
{ | ||
return subtype(); |
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.
Should we actually hide subtype()
for array_typet
and vector_typet
?
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, that will improve readability.
@@ -768,6 +768,15 @@ 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 comment
The 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 array.index().type() != array.index_type()
!
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.
I'd like to enforce that, going forward, using a precondition.
I did consider it, but I don't think it's a good idea.
|
bd9f103
to
de7ed5b
Compare
Will it always be possible to have the same index type, even when linking together objects from different source languages, for example C and Java? |
The plan is to make the index type part of the array type; you can then mix as you see fit. |
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.
My concerns/comments that I've left unresolved remain in place, but approving nonetheless.
Both of these won't be easy -- look at the branch typet_subtype |
This commit introduces convenience methods for retrieving the type of the elements and of the indices for array and vector types. This avoids using a global, architecture-dependent function to generate the index type.
This commit introduces convenience methods for retrieving the type of the
elements and of the indices for array and vector types. This avoids using a
global, architecture-dependent function to generate the index type.