cargo fmt

This commit is contained in:
Luke Street 2023-01-14 13:30:08 -05:00
parent 5b022f12f1
commit 9ae36eef34
2 changed files with 18 additions and 17 deletions

View File

@ -205,9 +205,9 @@ impl From<&DolHeaderData> for DolHeader {
impl DolHeader { impl DolHeader {
pub fn section_at(&self, addr: u32) -> Option<&DolSection> { pub fn section_at(&self, addr: u32) -> Option<&DolSection> {
self.sections.iter() self.sections
.find(|&section| (section.target..(section.target + section.size)) .iter()
.contains(&addr)) .find(|&section| (section.target..(section.target + section.size)).contains(&addr))
} }
} }

View File

@ -74,8 +74,8 @@ pub(crate) struct BitRange(Range<u8>);
impl<'de> Deserialize<'de> for BitRange { impl<'de> Deserialize<'de> for BitRange {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,
{ {
let range_str: String = Deserialize::deserialize(deserializer)?; let range_str: String = Deserialize::deserialize(deserializer)?;
if let Some((start_str, stop_str)) = range_str.split_once("..") { if let Some((start_str, stop_str)) = range_str.split_once("..") {
@ -253,10 +253,7 @@ impl Modifier {
let modifier_bit = self.bit as usize; let modifier_bit = self.bit as usize;
Ok(quote!(self.bit(#modifier_bit))) Ok(quote!(self.bit(#modifier_bit)))
} else { } else {
compile_mnemonic_condition( compile_mnemonic_condition(field_by_name, &self.condition)
field_by_name,
&self.condition,
)
} }
} }
@ -576,10 +573,7 @@ impl Isa {
.get(field_name) .get(field_name)
.unwrap_or_else(|| panic!("field not found: {}", arg)); .unwrap_or_else(|| panic!("field not found: {}", arg));
let variant = Ident::new(field.arg.as_ref().unwrap(), Span::call_site()); let variant = Ident::new(field.arg.as_ref().unwrap(), Span::call_site());
let value = compile_mnemonic_condition( let value = compile_mnemonic_condition(&field_by_name, expression)?;
&field_by_name,
expression,
)?;
args.push(quote!(Argument::#variant(#variant((#value) as _)),)); args.push(quote!(Argument::#variant(#variant((#value) as _)),));
} }
let args = token_stream!(args); let args = token_stream!(args);
@ -609,9 +603,11 @@ impl Isa {
let simplified_ins_match_arms = token_stream!(simplified_ins_match_arms); let simplified_ins_match_arms = token_stream!(simplified_ins_match_arms);
let field_accessors = let field_accessors =
TokenStream::from_iter(self.fields.iter().map(|field| field.construct_accessor())); TokenStream::from_iter(self.fields.iter().map(|field| field.construct_accessor()));
let modifiers: Vec<TokenStream> = self.modifiers let modifiers: Vec<TokenStream> = self
.modifiers
.iter() .iter()
.map(|modifier| modifier.construct_accessor(&field_by_name)).try_collect()?; .map(|modifier| modifier.construct_accessor(&field_by_name))
.try_collect()?;
let modifier_accessors = TokenStream::from_iter(modifiers); let modifier_accessors = TokenStream::from_iter(modifiers);
// Generate final fields function. // Generate final fields function.
let ins_impl = quote! { let ins_impl = quote! {
@ -725,7 +721,10 @@ fn compile_mnemonic_condition(
} }
} }
TokenTree::Group(ref group) => { TokenTree::Group(ref group) => {
let iter = group.stream().into_iter().flat_map(|token| map_ident(field_by_name, token)); let iter = group
.stream()
.into_iter()
.flat_map(|token| map_ident(field_by_name, token));
let stream = TokenStream::from_iter(iter); let stream = TokenStream::from_iter(iter);
return TokenStream::from(TokenTree::Group(Group::new(group.delimiter(), stream))); return TokenStream::from(TokenTree::Group(Group::new(group.delimiter(), stream)));
} }
@ -733,7 +732,9 @@ fn compile_mnemonic_condition(
} }
token.into() token.into()
} }
let token_iter = src_stream.into_iter().flat_map(|token| map_ident(field_by_name, token)); let token_iter = src_stream
.into_iter()
.flat_map(|token| map_ident(field_by_name, token));
Ok(TokenStream::from_iter(token_iter)) Ok(TokenStream::from_iter(token_iter))
} }