]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/TypeOfConstant.java
b0a0639b274f0ee3a1116d116f25efc182c4b466
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / singletons / TypeOfConstant.java
1 package org.simantics.scl.compiler.constants.singletons;
2
3 import org.simantics.scl.compiler.constants.FunctionValue;
4 import org.simantics.scl.compiler.internal.codegen.references.Val;
5 import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
6 import org.simantics.scl.compiler.types.TCon;
7 import org.simantics.scl.compiler.types.TVar;
8 import org.simantics.scl.compiler.types.Type;
9 import org.simantics.scl.compiler.types.Types;
10 import org.simantics.scl.compiler.types.kinds.Kinds;
11
12 public class TypeOfConstant extends FunctionValue {
13     private static final TVar A = Types.var(Kinds.STAR);
14     private static final TCon Type = Types.con(Types.BUILTIN, "Type");
15     public static final TypeOfConstant INSTANCE = new TypeOfConstant();
16     
17     private TypeOfConstant() {
18         super(new TVar[] {A}, Types.NO_EFFECTS, Type, 
19                 Types.pred(Types.TYPEABLE, A), A);
20     }
21     
22     @Override
23     public Type applyExact(MethodBuilder mb, Val[] parameters) {
24         mb.push(parameters[0], Type);
25         return getReturnType();
26     }
27     
28     @Override
29     public String toString() {
30         return "typeOf";
31     }
32 }