-
Notifications
You must be signed in to change notification settings - Fork 37
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
Implement skip
handling for fields of fixed size
#1646
Conversation
1feb1e1
to
8731132
Compare
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.
Good stuff. A further future extension could be inferring static sizes for units that don't have an explicit &size
: if all their fields are fixed size, the unit is so too.
8731132
to
1b175d1
Compare
@@ -30,3 +33,30 @@ std::optional<std::pair<const Expression, std::optional<const Type>>> spicy::typ | |||
|
|||
return {}; | |||
} | |||
|
|||
std::optional<const Expression> spicy::type::unit::item::Field::size() 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.
Couple things:
Good point that the size can depend not just on types, but also on field attributes, I didn't think about that. Given that, I'm now wondering if the type-side size()
method is really as helpful as I originally thought because we now have two levels of size()
, each with just a couple of cases/implementations (Type::size()
and (Field::size
). So maybe putting it all here into Field::size()
is the better approach.
And then I think I'd use a visitor instead of the if/else-chain, both for readability/consistency-in-style and (I believe ...) performance.
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 changed this as suggested. PTAL.
This patch adds `skip` support for fields with `&size` attribute or of builtin type with known size. If a unit has a known size and it is specified in a `&size` attribute this also allows to skip over unit fields. Closes #1640.
5c96c06
to
ed937e4
Compare
I backported 2559ed4) to |
Closes #1640.