Skip to content

Commit

Permalink
Safeguard type builders
Browse files Browse the repository at this point in the history
  • Loading branch information
RipplB committed Mar 13, 2024
1 parent 4d16f15 commit a755b6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ public class ExplStrategy extends BuilderStrategy<ExplState, ExplPrec> {

public ExplStrategy(XSTS xsts) {
super(xsts);
if (domain != Domain.EXPL) {
throw new UnsupportedOperationException(domain + " does not support EXPL builder strategy");
}
}

@Override
Expand Down Expand Up @@ -418,6 +421,9 @@ public ExplPrec getInitPrec() {
public class PredStrategy extends BuilderStrategy<PredState, PredPrec> {
public PredStrategy(XSTS xsts) {
super(xsts);
if (domain != Domain.PRED_BOOL && domain != Domain.PRED_SPLIT && domain != Domain.PRED_CART) {
throw new UnsupportedOperationException(domain + " does not support PRED builder strategy");
}
}

@Override
Expand Down Expand Up @@ -453,6 +459,10 @@ public class ProdStrategy extends BuilderStrategy<Prod2State<ExplState, PredStat

public ProdStrategy(XSTS xsts) {
super(xsts);
if (domain != Domain.EXPL_PRED_BOOL && domain != Domain.EXPL_PRED_SPLIT
&& domain != Domain.EXPL_PRED_CART && domain != Domain.EXPL_PRED_COMBINED) {
throw new UnsupportedOperationException(domain + " does not support PROD builder strategy");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ fun <S : ExprState> xstsExtractFromState(xstsState: XstsState<S>): S {

val xstsStripPrec: (Prec) -> Prec = { it }

fun <P: Prec> xstsStripPrecFun(p: P): P {
return p
}
fun <P: Prec> xstsStripPrecFun(p: P) = p

0 comments on commit a755b6c

Please sign in to comment.