|
| 1 | +use std::collections::HashMap; |
1 | 2 | use std::io::{self, Write};
|
2 | 3 |
|
3 | 4 | use cast::u64;
|
@@ -40,11 +41,12 @@ pub fn device(d: &Device, items: &mut Vec<Tokens>) -> Result<()> {
|
40 | 41 |
|
41 | 42 | /// Generates code for `src/interrupt.rs`
|
42 | 43 | pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
|
43 |
| - let mut interrupts = |
44 |
| - peripherals.iter().flat_map(|p| p.interrupt.iter()).collect::<Vec<_>>(); |
| 44 | + let interrupts = peripherals.iter() |
| 45 | + .flat_map(|p| p.interrupt.iter()) |
| 46 | + .map(|i| (i.value, i)) |
| 47 | + .collect::<HashMap<_, _>>(); |
45 | 48 |
|
46 |
| - interrupts.sort_by_key(|i| i.value); |
47 |
| - interrupts.dedup_by_key(|i| i.value); |
| 49 | + let interrupts = interrupts.into_iter().map(|(_, v)| v).collect::<Vec<_>>(); |
48 | 50 |
|
49 | 51 | let mut fields = vec![];
|
50 | 52 | let mut exprs = vec![];
|
@@ -492,12 +494,12 @@ pub fn fields(
|
492 | 494 | description.push_str(&*util::respace(d));
|
493 | 495 | }
|
494 | 496 | Ok(F {
|
495 |
| - _pc_w, |
496 |
| - _sc, |
497 |
| - description, |
498 |
| - pc_r, |
499 |
| - pc_w, |
500 |
| - width, |
| 497 | + _pc_w: _pc_w, |
| 498 | + _sc: _sc, |
| 499 | + description: description, |
| 500 | + pc_r: pc_r, |
| 501 | + pc_w: pc_w, |
| 502 | + width: width, |
501 | 503 | access: f.access,
|
502 | 504 | evs: &f.enumerated_values,
|
503 | 505 | sc: Ident::new(&*sc),
|
@@ -560,11 +562,11 @@ pub fn fields(
|
560 | 562 | ev.name)
|
561 | 563 | })?);
|
562 | 564 | Ok(Variant {
|
563 |
| - description, |
564 |
| - sc, |
| 565 | + description: description, |
| 566 | + sc: sc, |
565 | 567 | pc: Ident::new(&*ev.name
|
566 | 568 | .to_sanitized_pascal_case()),
|
567 |
| - value, |
| 569 | + value: value, |
568 | 570 | })
|
569 | 571 | })
|
570 | 572 | .collect::<Result<Vec<_>>>()?;
|
|
0 commit comments