]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/ListElement.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / singletons / ListElement.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/ListElement.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/ListElement.java
new file mode 100644 (file)
index 0000000..aaba3de
--- /dev/null
@@ -0,0 +1,32 @@
+package org.simantics.scl.compiler.constants.singletons;\r
+\r
+import org.cojen.classfile.TypeDesc;\r
+import org.simantics.scl.compiler.constants.FunctionValue;\r
+import org.simantics.scl.compiler.internal.codegen.references.Val;\r
+import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;\r
+import org.simantics.scl.compiler.types.TVar;\r
+import org.simantics.scl.compiler.types.Type;\r
+import org.simantics.scl.compiler.types.Types;\r
+import org.simantics.scl.compiler.types.kinds.Kinds;\r
+\r
+public class ListElement extends FunctionValue {    \r
+    private static TVar A = Types.var(Kinds.STAR);\r
+    public static final ListElement INSTANCE = new ListElement();\r
+    \r
+    private ListElement() {\r
+        super(new TVar[] {A}, Types.NO_EFFECTS, A, Types.list(A), Types.INTEGER);\r
+    }\r
+    \r
+    @Override\r
+    public Type applyExact(MethodBuilder mb, Val[] parameters) {\r
+        parameters[0].push(mb);\r
+        parameters[1].push(mb);\r
+        mb.invokeInterface("java/util/List", "get", TypeDesc.OBJECT, new TypeDesc[] {TypeDesc.INT});\r
+        return getReturnType();\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return "get";\r
+    }\r
+}\r