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