diff --git a/hazardflow-designs/src/std/interface.rs b/hazardflow-designs/src/std/interface.rs index 06b7c66..85b4fd9 100644 --- a/hazardflow-designs/src/std/interface.rs +++ b/hazardflow-designs/src/std/interface.rs @@ -3,6 +3,7 @@ use hazardflow_macro::magic; use super::*; +use crate::prelude::*; /// Interface trait. #[must_use] @@ -61,7 +62,7 @@ pub trait Interface: Sized { _init_state: S, _f: impl Fn(Self::Fwd, E::Bwd, S) -> (E::Fwd, Self::Bwd, S), ) -> E { - panic!("compiler magic") + compiler_magic!() } /// Combines the module to the given interface and returns the egress interface. diff --git a/hazardflow-designs/src/std/module.rs b/hazardflow-designs/src/std/module.rs index 93056bd..a1b7fba 100644 --- a/hazardflow-designs/src/std/module.rs +++ b/hazardflow-designs/src/std/module.rs @@ -6,6 +6,7 @@ use hazardflow_macro::magic; use super::*; +use crate::prelude::*; /// Splits a module into two modules. // TODO: Can we make return type `FnOnce(I1) -> O1`? @@ -13,7 +14,7 @@ use super::*; pub fn module_split( _m: impl FnOnce(I1, I2) -> (O1, O2), ) -> (fn(I1) -> O1, fn(I2) -> O2) { - panic!("compiler magic") + compiler_magic!() } /// Splits a module into three modules. @@ -35,7 +36,7 @@ pub fn module_split3(f: T) -> [fn(I, J) -> (O, J); N] where T: FnOnce(I, J) -> (O, J) { - panic!("compiler magic") + compiler_magic!() } /// Generates a 1D systolic array from an array of modules. @@ -52,7 +53,7 @@ pub fn seq( ms: [fn(I, J) -> (O, J); N], ) -> impl FnOnce([I; N], J) -> ([O; N], J) { // This should be primitive? - |is, j| panic!("compiler magic") + |is, j| compiler_magic!() } /// Applies `f` to the given interfaces. diff --git a/hazardflow-designs/src/std/utils.rs b/hazardflow-designs/src/std/utils.rs index 6bd8fba..4b21e93 100644 --- a/hazardflow-designs/src/std/utils.rs +++ b/hazardflow-designs/src/std/utils.rs @@ -2,6 +2,8 @@ use hazardflow_macro::magic; +use crate::prelude::*; + /// Returns ceiling log2. pub const fn clog2(value: usize) -> usize { if value == 0 { @@ -34,7 +36,7 @@ pub const fn max(lhs: usize, rhs: usize) -> usize { /// Display function #[magic(system::display)] pub fn display(_fstring: &str, _args: V) { - panic!("compiler magic") + compiler_magic!() } /// Display macro @@ -53,7 +55,7 @@ macro_rules! display { /// Assertion function #[magic(system::assert)] pub fn assert(_cond: bool, _fstring: &str, _args: V) { - panic!("compiler magic") + compiler_magic!() } /// Assert macro diff --git a/hazardflow-designs/src/std/value/mod.rs b/hazardflow-designs/src/std/value/mod.rs index 58114a0..32e6ecc 100644 --- a/hazardflow-designs/src/std/value/mod.rs +++ b/hazardflow-designs/src/std/value/mod.rs @@ -2,6 +2,8 @@ use hazardflow_macro::magic; +use crate::prelude::*; + mod array; mod bounded; mod integer; @@ -19,5 +21,5 @@ pub use option::*; /// TODO: Write safety condition #[magic(x)] pub unsafe fn x() -> T { - panic!("compiler magic") + compiler_magic!() } diff --git a/hazardflow-macro/src/lib.rs b/hazardflow-macro/src/lib.rs index fa985f5..94f9d40 100644 --- a/hazardflow-macro/src/lib.rs +++ b/hazardflow-macro/src/lib.rs @@ -81,12 +81,12 @@ pub fn heq(input: proc_macro::TokenStream) -> proc_macro::TokenStream { impl #impl_generics ::core::cmp::PartialEq for #name #ty_generics #where_clause { #[magic(adt::enum_eq)] fn eq(&self, other: &Self) -> bool { - ::core::todo!("compiler magic") + crate::prelude::compiler_magic!() } #[allow(clippy::partialeq_ne_impl)] #[magic(adt::enum_ne)] fn ne(&self, other: &Self) -> bool { - ::core::todo!("compiler magic") + crate::prelude::compiler_magic!() } } impl #impl_generics ::core::cmp::Eq for #name #ty_generics #where_clause {