1 package org.simantics.scl.compiler.elaboration.java;
3 import org.simantics.scl.compiler.constants.BooleanConstant;
4 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
5 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
6 import org.simantics.scl.compiler.elaboration.expressions.Variable;
7 import org.simantics.scl.compiler.elaboration.query.compilation.QueryCompilationContext;
8 import org.simantics.scl.compiler.elaboration.relations.AbstractRelation;
9 import org.simantics.scl.compiler.types.TVar;
10 import org.simantics.scl.compiler.types.Type;
11 import org.simantics.scl.compiler.types.Types;
13 public class CheckRelation extends AbstractRelation {
14 public static final CheckRelation INSTANCE = new CheckRelation();
16 private CheckRelation() {}
19 public TVar[] getTypeVariables() {
20 return TVar.EMPTY_ARRAY;
23 private static final Type[] PARAMETER_TYPES = new Type[] {Types.BOOLEAN};
26 public Type[] getParameterTypes() {
27 return PARAMETER_TYPES;
31 public int getPhase() {
36 public double getSelectivity(int boundVariables) {
37 switch(boundVariables) {
40 default: throw new IllegalArgumentException();
45 public int getRequiredVariablesMask() {
50 public void generate(long location,
51 QueryCompilationContext context,
52 Type[] typeParameters, Variable[] parameters, int boundVariables) {
53 switch(boundVariables) {
55 context.let(parameters[0], new ELiteral(new BooleanConstant(true)));
58 context.condition(new EVariable(parameters[0]));
60 default: throw new IllegalArgumentException();
65 public String toString() {