@@ -101,34 +101,6 @@ object DFType:
101101 type Supported = DFTypeAny | FieldsOrTuple | DFEncoding | DFOpaqueA | Byte | Int | Long |
102102 Boolean | Double | String | Object | Unit
103103
104- given evPortVarConstructor [
105- T <: Supported ,
106- A ,
107- C ,
108- I ,
109- P ,
110- M <: Modifier [A , C , I , P ]
111- ](using
112- tc : DFType .TC [T ],
113- checkLocal : AssertGiven [DFC .Scope .Local , " Port/Variable declarations cannot be global" ],
114- ck : DFC .Scope ,
115- dt : DomainType
116- ): ExactOp2Aux [" <>" , DFC , Any , T , M , DFVal [
117- tc.Type ,
118- Modifier [A & ck.type & dt.type , C , I , P ]
119- ]] = new ExactOp2 [" <>" , DFC , Any , T , M ]:
120- type Out = DFVal [tc.Type , Modifier [A & ck.type & dt.type , C , I , P ]]
121- def apply (t : T , modifier : M )(using DFC ): Out = trydf {
122- if (modifier.value.isPort)
123- dfc.owner.asIR match
124- case _ : ir.DFDomainOwner =>
125- case _ =>
126- throw new IllegalArgumentException (
127- " Ports can only be directly owned by a design, a domain or an interface."
128- )
129- DFVal .Dcl (tc(t), modifier.asInstanceOf [Modifier [A & ck.type & dt.type , C , I , P ]])
130- }(using dfc, CTName (" Port/Variable constructor" ))
131- end evPortVarConstructor
132104 object Ops :
133105 extension [T <: Supported ](t : T )
134106 infix def <> [A , C , I , P ](modifier : Modifier [A , C , I , P ])(using
@@ -163,6 +135,11 @@ object DFType:
163135 ]
164136 object TC extends TCLP :
165137 type Aux [T , OT <: DFTypeAny ] = TC [T ] { type Type = OT }
138+ def apply [T , OT <: DFTypeAny ](value : OT ): Aux [T , OT ] =
139+ new TC [T ]:
140+ type Type = OT
141+ def apply (t : T )(using DFC ): Type = value
142+
166143 given ofDFType [T <: DFTypeAny ]: TC [T ] with
167144 type Type = T
168145 def apply (t : T )(using DFC ): Type = t
@@ -206,25 +183,16 @@ object DFType:
206183 )
207184 val clsTpe = compPrefix.select(clsSym)
208185 clsTpe.asType match
209- case ' [t & DFEncoding ] =>
210- ' {
211- new TC [T ]:
212- type Type = DFEnum [t & DFEncoding ]
213- def apply (t : T )(using DFC ): Type = summonInline[DFEnum [t & DFEncoding ]]
214- }
215- case ' [t & DFStruct .Fields ] =>
216- ' {
217- new TC [T ]:
218- type Type = DFStruct [t & DFStruct .Fields ]
219- def apply (t : T )(using DFC ): Type =
220- summonInline[DFStruct [t & DFStruct .Fields ]]
221- }
222- case ' [t & DFOpaque .Abstract ] =>
186+ case ' [DFEncoding ] =>
187+ val clsType = clsTpe.asTypeOf[DFEncoding ]
188+ ' { apply[T , DFEnum [clsType.Underlying ]](summonInline[DFEnum [clsType.Underlying ]]) }
189+ case ' [DFStruct .Fields ] =>
190+ val clsType = clsTpe.asTypeOf[DFStruct .Fields ]
191+ ' { apply[T , DFStruct [clsType.Underlying ]](summonInline[DFStruct [clsType.Underlying ]]) }
192+ case ' [DFOpaque .Abstract ] =>
193+ val clsType = clsTpe.asTypeOf[DFOpaque .Abstract ]
223194 ' {
224- new TC [T ]:
225- type Type = DFOpaque [t & DFOpaque .Abstract ]
226- def apply (t : T )(using DFC ): Type =
227- summonInline[DFOpaque [t & DFOpaque .Abstract ]]
195+ apply[T , DFOpaque [clsType.Underlying ]](summonInline[DFOpaque [clsType.Underlying ]])
228196 }
229197 case _ =>
230198 val badTypeStr = clsTpe.show
0 commit comments