Skip to content

Commit b24e668

Browse files
authored
First step in transferring to ClairV2 (#224)
1 parent 8483b6d commit b24e668

File tree

10 files changed

+883
-172
lines changed

10 files changed

+883
-172
lines changed

clair/src/main/scala-3/FrontEndMirror.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ inline def getConstraint[T <: Attribute | AttributeFE]: IRDLConstraint = {
100100
}
101101

102102
inline def inputVariadicity[Elem] = inline erasedValue[Elem] match
103-
case _: Variadic[t] => Variadic
104-
case _ => Single
103+
case _: Variadic[t] => Variadicity.Variadic
104+
case _ => Variadicity.Single
105105

106106
type unwrappedInput[Elem] = Elem match
107107
case Variadic[t] => t

clairV2/src/main/scala-3/CV2Mirror.scala

+27-7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ inline def inputVariadicity[Elem] = inline erasedValue[Elem] match
3333
case _: Variadic[t] => Variadicity.Variadic
3434
case _ => Variadicity.Single
3535

36+
// for some reason match types do not work here, as an inline erasedValue[unwrappedInput[Elem]]
37+
// tries to match on that type exactly (ie. unwrappedType[Value[IntegerType]] for example) rather than the matched type...
38+
// very weird things going on
39+
3640
/** Produces an OpInput to OperationDef given a definition of a Type.
3741
*
3842
* @return
@@ -43,29 +47,43 @@ inline def getDefInput[Label, Elem]: OpInput = {
4347

4448
val name = inline erasedValue[Label] match
4549
case _: String => constValue[Label].asInstanceOf[String]
46-
case _ => throw new Exception("Internal error!")
50+
case _ =>
51+
throw new Exception("Internal error!")
52+
4753
inline erasedValue[Elem] match
54+
case _: Variadic[Operand[t]] =>
55+
OperandDef(
56+
id = name,
57+
typeString = typeToString[t],
58+
Variadicity.Variadic
59+
)
60+
case _: Variadic[Result[t]] =>
61+
OperandDef(
62+
id = name,
63+
typeString = typeToString[t],
64+
Variadicity.Variadic
65+
)
4866
case _: Result[t] =>
4967
ResultDef(
5068
id = name,
5169
typeString = typeToString[t],
52-
inputVariadicity[Elem]
70+
Variadicity.Single
5371
)
5472
case _: Operand[t] =>
5573
OperandDef(
5674
id = name,
5775
typeString = typeToString[t],
58-
inputVariadicity[Elem]
76+
Variadicity.Single
5977
)
6078
case _: Region =>
6179
RegionDef(
6280
id = name,
63-
inputVariadicity[Elem]
81+
Variadicity.Single
6482
)
6583
case _: Successor =>
6684
SuccessorDef(
6785
id = name,
68-
inputVariadicity[Elem]
86+
Variadicity.Single
6987
)
7088
case _: Property[t] =>
7189
OpPropertyDef(
@@ -77,8 +95,10 @@ inline def getDefInput[Label, Elem]: OpInput = {
7795
id = name,
7896
typeString = typeToString[t]
7997
)
80-
case shennanigan =>
81-
throw new Exception(f"Unsupported shennaigans with field $name")
98+
case _ =>
99+
throw new Exception(
100+
s"Unsupported shennaigans here with field $name of type ${typeToString[Elem]}"
101+
)
82102
}
83103

84104
/** Loops through a Tuple of Input definitions and produces a List of inputs to

0 commit comments

Comments
 (0)