Merge pull request #283 from xoviat/sort-ir

metapac-gen: sort ir
This commit is contained in:
xoviat 2023-10-14 02:57:03 +00:00 committed by GitHub
commit 0df3b9cbb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,11 +12,11 @@ pub mod ir {
impl IR { impl IR {
pub fn from_chiptool(ir: chiptool::ir::IR) -> Self { pub fn from_chiptool(ir: chiptool::ir::IR) -> Self {
let blocks: Vec<Block> = ir let mut blocks: Vec<Block> = ir
.blocks .blocks
.iter() .iter()
.map(|(name, block)| { .map(|(name, block)| {
let items = block let mut items: Vec<_> = block
.items .items
.iter() .iter()
.map(|item| BlockItem { .map(|item| BlockItem {
@ -54,6 +54,8 @@ pub mod ir {
}) })
.collect(); .collect();
items.sort_by_key(|i| i.name.clone());
Block { Block {
name: name.to_string(), name: name.to_string(),
items: items, items: items,
@ -62,7 +64,10 @@ pub mod ir {
} }
}) })
.collect(); .collect();
let fieldsets: Vec<FieldSet> = ir
blocks.sort_by_key(|b| b.name.clone());
let mut fieldsets: Vec<FieldSet> = ir
.fieldsets .fieldsets
.iter() .iter()
.map(|(name, fieldset)| { .map(|(name, fieldset)| {
@ -99,7 +104,10 @@ pub mod ir {
} }
}) })
.collect(); .collect();
let enums: Vec<Enum> = ir
fieldsets.sort_by_key(|f| f.name.clone());
let mut enums: Vec<Enum> = ir
.enums .enums
.iter() .iter()
.map(|(name, enumm)| { .map(|(name, enumm)| {
@ -122,6 +130,8 @@ pub mod ir {
}) })
.collect(); .collect();
enums.sort_by_key(|e| e.name.clone());
Self { Self {
blocks, blocks,
fieldsets, fieldsets,