1 package org.simantics.scl.compiler.constants.singletons;
\r
3 import org.cojen.classfile.TypeDesc;
\r
4 import org.simantics.scl.compiler.constants.FunctionValue;
\r
5 import org.simantics.scl.compiler.internal.codegen.references.Val;
\r
6 import org.simantics.scl.compiler.internal.codegen.utils.Constants;
\r
7 import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
\r
8 import org.simantics.scl.compiler.types.TVar;
\r
9 import org.simantics.scl.compiler.types.Type;
\r
10 import org.simantics.scl.compiler.types.Types;
\r
11 import org.simantics.scl.compiler.types.kinds.Kinds;
\r
13 public class ListLength extends FunctionValue {
\r
14 private static TVar A = Types.var(Kinds.STAR);
\r
15 public static final ListLength INSTANCE = new ListLength();
\r
17 private ListLength() {
\r
18 super(new TVar[] {A}, Types.NO_EFFECTS, Types.INTEGER, Types.list(A));
\r
22 public Type applyExact(MethodBuilder mb, Val[] parameters) {
\r
23 parameters[0].push(mb);
\r
24 mb.invokeInterface("java/util/List", "size", TypeDesc.INT, Constants.EMPTY_TYPEDESC_ARRAY);
\r
25 return getReturnType();
\r
29 public String toString() {
\r