X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2Fsingletons%2FListElement.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2Fsingletons%2FListElement.java;h=aaba3de5bb6a4fc248d0c14e20600dd01fb76bdf;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hp=0000000000000000000000000000000000000000;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b;p=simantics%2Fplatform.git 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 index 000000000..aaba3de5b --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/ListElement.java @@ -0,0 +1,32 @@ +package org.simantics.scl.compiler.constants.singletons; + +import org.cojen.classfile.TypeDesc; +import org.simantics.scl.compiler.constants.FunctionValue; +import org.simantics.scl.compiler.internal.codegen.references.Val; +import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder; +import org.simantics.scl.compiler.types.TVar; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.Types; +import org.simantics.scl.compiler.types.kinds.Kinds; + +public class ListElement extends FunctionValue { + private static TVar A = Types.var(Kinds.STAR); + public static final ListElement INSTANCE = new ListElement(); + + private ListElement() { + super(new TVar[] {A}, Types.NO_EFFECTS, A, Types.list(A), Types.INTEGER); + } + + @Override + public Type applyExact(MethodBuilder mb, Val[] parameters) { + parameters[0].push(mb); + parameters[1].push(mb); + mb.invokeInterface("java/util/List", "get", TypeDesc.OBJECT, new TypeDesc[] {TypeDesc.INT}); + return getReturnType(); + } + + @Override + public String toString() { + return "get"; + } +}