-
Notifications
You must be signed in to change notification settings - Fork 228
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 wrappers around the Architecture ID types #5431
Conversation
@@ -2010,13 +2010,13 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { | |||
self.log(|| format!("Register {:?} ==> {:?}", reg, xreg)); | |||
self.arch | |||
.register_by_name(xreg.to_string().to_lowercase()) | |||
.map(|reg| reg.id() as i64) | |||
.map(|reg| reg.id().0 as i64) |
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.
id().into()
?
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.
Maybe, but not using Into
. Maybe something like reg.id().into_inner()
or reg.raw_id()
.
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.
The as i64
can be replaced with .into()
. But the .0
can only be replaced with a appropriated named function.
This is available with ace9ba8 However I didn't add that field helper, I find that a little useless, maybe I misunderstand the purpose but it seems unnecessary. Please correct me if I'm wrong. |
Do you mean the |
Instead of using naked ids (u32) for types like: Register, Flag, Intrinsic, etc. This PR replaces those types with wrappers like: RegisterId, FlagId, IntrinsicId, etc.
The objective is to provide a more clear API for the user, once the type RegisterId can't be confused with any other u32.
This pattern also allow the creation of the
ArchitectureExt::get_field
that can receive any kind of id an return the corresponding type, eg: