1 package org.simantics.scl.compiler.elaboration.java;
3 import org.simantics.scl.compiler.common.names.Names;
4 import org.simantics.scl.compiler.elaboration.expressions.EApply;
5 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
6 import org.simantics.scl.compiler.elaboration.expressions.Expression;
7 import org.simantics.scl.compiler.elaboration.expressions.Variable;
8 import org.simantics.scl.compiler.elaboration.query.compilation.QueryCompilationContext;
9 import org.simantics.scl.compiler.elaboration.relations.AbstractRelation;
10 import org.simantics.scl.compiler.types.TVar;
11 import org.simantics.scl.compiler.types.Type;
12 import org.simantics.scl.compiler.types.Types;
13 import org.simantics.scl.compiler.types.kinds.Kinds;
15 public class MemberRelation extends AbstractRelation {
16 public static final MemberRelation INSTANCE = new MemberRelation();
18 private MemberRelation() {}
20 private static final TVar A = Types.var(Kinds.STAR);
22 private static final TVar[] TYPE_VARIABLES = new TVar[] {A};
25 public TVar[] getTypeVariables() {
26 return TYPE_VARIABLES;
29 private static final Type[] PARAMETER_TYPES = new Type[] {A, Types.list(A)};
32 public Type[] getParameterTypes() {
33 return PARAMETER_TYPES;
37 public int getPhase() {
42 public double getSelectivity(int boundVariables) {
43 switch(boundVariables) {
45 case BF: return Double.POSITIVE_INFINITY;
48 default: throw new IllegalArgumentException();
53 public int getRequiredVariablesMask() {
58 public void generate(long location,
59 QueryCompilationContext context,
60 Type[] typeParameters, Variable[] parameters, int boundVariables) {
61 switch(boundVariables) {
63 context.iterateList(parameters[0], new EVariable(parameters[1]));
68 context.getConstant(Names.Prelude_elem, typeParameters),
70 new EVariable(parameters[0]),
71 new EVariable(parameters[1])
75 default: throw new IllegalArgumentException();
80 public String toString() {