--- /dev/null
+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.Constants;\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 ListLength extends FunctionValue { \r
+ private static TVar A = Types.var(Kinds.STAR);\r
+ public static final ListLength INSTANCE = new ListLength();\r
+ \r
+ private ListLength() {\r
+ super(new TVar[] {A}, Types.NO_EFFECTS, Types.INTEGER, Types.list(A));\r
+ }\r
+ \r
+ @Override\r
+ public Type applyExact(MethodBuilder mb, Val[] parameters) {\r
+ parameters[0].push(mb);\r
+ mb.invokeInterface("java/util/List", "size", TypeDesc.INT, Constants.EMPTY_TYPEDESC_ARRAY);\r
+ return getReturnType();\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "length";\r
+ }\r
+}\r