From 0d9abac065b4a12c158ecef20d36b924f1ff67b1 Mon Sep 17 00:00:00 2001 From: NotAFile Date: Sun, 23 Jan 2022 22:52:06 +0100 Subject: [PATCH] cargo fmt --- src/builtin_cells.rs | 17 ++++------------- src/frontend/types.rs | 14 +++++++------- src/main.rs | 8 ++++++-- src/package.rs | 15 +++++++++------ 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/builtin_cells.rs b/src/builtin_cells.rs index 84af1d7..e60da9d 100644 --- a/src/builtin_cells.rs +++ b/src/builtin_cells.rs @@ -1,5 +1,5 @@ -use crate::frontend::{Callable}; use crate::frontend::types::{Type, TypeStruct}; +use crate::frontend::Callable; use crate::rtlil; use crate::rtlil::SigSpec; @@ -43,14 +43,8 @@ fn make_binop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ct // FIXME: CRIMES CRIMES CRIMES let logic_type: &'static TypeStruct = Box::leak(Box::new(TypeStruct::logic_infer())); let args = vec![ - ( - Some("a".to_owned()), - logic_type, - ), - ( - Some("b".to_owned()), - logic_type, - ), + (Some("a".to_owned()), logic_type), + (Some("b".to_owned()), logic_type), ]; Callable { name: name.to_owned(), @@ -62,10 +56,7 @@ fn make_binop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ct fn make_unnop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ctx> { // FIXME: CRIMES CRIMES CRIMES let logic_type: &'static TypeStruct = Box::leak(Box::new(TypeStruct::logic_infer())); - let args = vec![( - Some("A".to_owned()), - logic_type, - )]; + let args = vec![(Some("A".to_owned()), logic_type)]; Callable { name: name.to_owned(), args, diff --git a/src/frontend/types.rs b/src/frontend/types.rs index a53b1a5..7ef306c 100644 --- a/src/frontend/types.rs +++ b/src/frontend/types.rs @@ -38,7 +38,7 @@ enum ElabValueData<'ty> { /// Types that are only valid during Elaboration enum ElabKind { /// general, unsized number type - Num + Num, } /// Helper functions to create primitive types @@ -48,24 +48,24 @@ impl<'ty> TypeStruct<'ty> { Self { kind: TypeKind::Logic(ElabData { typ: &TypeStruct { - kind: TypeKind::ElabType(ElabKind::Num) + kind: TypeKind::ElabType(ElabKind::Num), }, value: ElabValue::Infer, - }) + }), } } /// a logic signal with known width pub fn logic_width(width: u32) -> Self { Self { - kind: TypeKind::Logic(ElabData::u32(width)) + kind: TypeKind::Logic(ElabData::u32(width)), } } /// return an elaboration number type pub fn elab_num() -> Self { Self { - kind: TypeKind::ElabType(ElabKind::Num) + kind: TypeKind::ElabType(ElabKind::Num), } } } @@ -76,9 +76,9 @@ impl<'ty> ElabData<'ty> { pub fn u32(val: u32) -> Self { Self { typ: &TypeStruct { - kind: TypeKind::ElabType(ElabKind::Num) + kind: TypeKind::ElabType(ElabKind::Num), }, - value: ElabValue::Concrete(ElabValueData::U32(val)) + value: ElabValue::Concrete(ElabValueData::U32(val)), } } } diff --git a/src/main.rs b/src/main.rs index e58f95c..345c6f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ mod builtin_cells; mod frontend; mod literals; +mod package; mod parser; mod rtlil; -mod package; use std::fs::File; use std::io::prelude::*; @@ -28,7 +28,11 @@ fn main() { let opt = Opt::from_args(); // let mut infile = File::open(opt.input).expect("could not open file"); let packages = package::PackageRegistry::new(); - let mut infile = packages.get("builtins").expect("no package").open().expect("could not open file"); + let mut infile = packages + .get("builtins") + .expect("no package") + .open() + .expect("could not open file"); let mut input = String::new(); infile diff --git a/src/package.rs b/src/package.rs index ad4a1d0..b7ae510 100644 --- a/src/package.rs +++ b/src/package.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use std::path::PathBuf; use std::fs::File; +use std::path::PathBuf; pub struct Package { name: String, @@ -15,16 +15,19 @@ impl Package { } pub struct PackageRegistry { - packages: BTreeMap + packages: BTreeMap, } impl PackageRegistry { pub fn new() -> Self { let mut packages = BTreeMap::new(); - packages.insert("builtins".to_string(), Package { - name: "builtins".to_string(), - path: "./lib/builtins/".into(), - }); + packages.insert( + "builtins".to_string(), + Package { + name: "builtins".to_string(), + path: "./lib/builtins/".into(), + }, + ); Self { packages } }