From 15bc304bb69aff5581515433f2340c56990087d5 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 4 Dec 2024 20:57:44 -0800 Subject: [PATCH] impl ToExpr for TargetBase --- crates/fayalite/src/expr/target.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/fayalite/src/expr/target.rs b/crates/fayalite/src/expr/target.rs index 8f39e13..c8c55e9 100644 --- a/crates/fayalite/src/expr/target.rs +++ b/crates/fayalite/src/expr/target.rs @@ -3,7 +3,7 @@ use crate::{ array::Array, bundle::{Bundle, BundleField}, - expr::Flow, + expr::{Expr, Flow, ToExpr}, intern::{Intern, Interned}, memory::{DynPortType, MemPort}, module::{Instance, ModuleIO, TargetName}, @@ -195,6 +195,16 @@ macro_rules! impl_target_base { } } } + + impl ToExpr for $TargetBase { + type Type = CanonicalType; + + fn to_expr(&self) -> Expr { + match self { + $(Self::$Variant(v) => Expr::canonical(v.to_expr()),)* + } + } + } }; }