]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/ListElement.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / singletons / ListElement.java
1 package org.simantics.scl.compiler.constants.singletons;
2
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.MethodBuilder;
7 import org.simantics.scl.compiler.types.TVar;
8 import org.simantics.scl.compiler.types.Type;
9 import org.simantics.scl.compiler.types.Types;
10 import org.simantics.scl.compiler.types.kinds.Kinds;
11
12 public class ListElement extends FunctionValue {    
13     private static TVar A = Types.var(Kinds.STAR);
14     public static final ListElement INSTANCE = new ListElement();
15     
16     private ListElement() {
17         super(new TVar[] {A}, Types.NO_EFFECTS, A, Types.list(A), Types.INTEGER);
18     }
19     
20     @Override
21     public Type applyExact(MethodBuilder mb, Val[] parameters) {
22         parameters[0].push(mb);
23         parameters[1].push(mb);
24         mb.invokeInterface("java/util/List", "get", TypeDesc.OBJECT, new TypeDesc[] {TypeDesc.INT});
25         return getReturnType();
26     }
27
28     @Override
29     public String toString() {
30         return "get";
31     }
32 }