]> gerrit.simantics Code Review - simantics/platform.git/blob
10f36193e9c27773b7a5cd0d46ddbb9dbaa4f37e
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.java;
2
3 import org.simantics.scl.compiler.elaboration.expressions.EApply;
4 import org.simantics.scl.compiler.elaboration.expressions.Expression;
5 import org.simantics.scl.compiler.elaboration.expressions.Expressions;
6 import org.simantics.scl.compiler.elaboration.expressions.Variable;
7 import org.simantics.scl.compiler.elaboration.query.compilation.EnforcingContext;
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;
14
15 public class ExecuteRelation extends AbstractRelation {
16     int phase;
17     
18     public ExecuteRelation(int phase) {
19         this.phase = phase;
20     }
21     
22     private static TVar A = Types.var(Kinds.STAR);
23     private static TVar E = Types.var(Kinds.EFFECT);
24     private static TVar[] TYPE_VARIABLES = new TVar[] {A, E};
25     
26     @Override
27     public TVar[] getTypeVariables() {
28         return TYPE_VARIABLES;
29     }
30     
31     private static final Type[] PARAMETER_TYPES = new Type[] {Types.functionE(Types.PUNIT, E, A)};
32
33     @Override
34     public Type[] getParameterTypes() {
35         return PARAMETER_TYPES;
36     }
37
38     @Override
39     public int getPhase() {
40         return phase;
41     }
42     
43     @Override
44     public double getSelectivity(int boundVariables) {
45         return Double.POSITIVE_INFINITY;
46     }
47     
48     @Override
49     public int getRequiredVariablesMask() {
50         return B;
51     }
52
53     @Override
54     public void generate(long location,
55             QueryCompilationContext context,
56             Type[] typeParameters, Variable[] parameters, int boundVariables) {
57         throw new IllegalArgumentException();
58     }
59
60     @Override
61     public Expression generateEnforce(long location, EnforcingContext context,
62             Type[] typeParameters,
63             Variable[] parameters) {
64         return new EApply(
65                 Expressions.var(parameters[0]),
66                 Expressions.punit());
67     }
68     
69     @Override
70     public String toString() {
71         return "Execute";
72     }
73     
74 }