]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/TypeValueConstant.java
(refs #7767) SafeDynamic module
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / singletons / TypeValueConstant.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/TypeValueConstant.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/TypeValueConstant.java
new file mode 100644 (file)
index 0000000..4966a8c
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.scl.compiler.constants.singletons;
+
+import org.simantics.scl.compiler.constants.FunctionValue;
+import org.simantics.scl.compiler.internal.codegen.references.Val;
+import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
+import org.simantics.scl.compiler.types.TVar;
+import org.simantics.scl.compiler.types.Type;
+import org.simantics.scl.compiler.types.Types;
+import org.simantics.scl.compiler.types.kinds.Kinds;
+
+public class TypeValueConstant extends FunctionValue {
+    private static final TVar A = Types.var(Kinds.STAR);
+    public static final TypeValueConstant INSTANCE = new TypeValueConstant();
+    
+    private TypeValueConstant() {
+        super(new TVar[] {A}, Types.NO_EFFECTS, Types.TYPE,
+                Types.pred(Types.TYPEABLE, A));
+    }
+    
+    @Override
+    public Type applyExact(MethodBuilder mb, Val[] parameters) {
+        mb.push(parameters[0], Types.TYPE);
+        return getReturnType();
+    }
+    
+    @Override
+    public String toString() {
+        return "typeValue";
+    }
+}
\ No newline at end of file