1 package org.simantics.scl.compiler.elaboration.java;
3 import org.cojen.classfile.TypeDesc;
4 import org.objectweb.asm.Label;
5 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
6 import org.simantics.scl.compiler.constants.Constant;
7 import org.simantics.scl.compiler.internal.codegen.continuations.Cont;
8 import org.simantics.scl.compiler.internal.codegen.references.IVal;
9 import org.simantics.scl.compiler.internal.codegen.utils.Constants;
10 import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
11 import org.simantics.scl.compiler.types.TVar;
12 import org.simantics.scl.compiler.types.Types;
13 import org.simantics.scl.compiler.types.kinds.Kinds;
16 public class EmptyListConstructor extends Constant {
18 private static final TVar A = Types.var(Kinds.STAR);
20 public EmptyListConstructor() {
21 super(Types.forAll(A, Types.list(A)));
25 public void push(MethodBuilder mb) {
26 mb.loadStaticField("java/util/Collections", "EMPTY_LIST", Constants.LIST);
30 public void deconstruct(MethodBuilder mb, IVal parameter, Cont success,
33 throw new InternalCompilerError("List deconstruction may always fail");
36 mb.invokeInterface(Constants.LIST, "size", TypeDesc.INT, Constants.EMPTY_TYPEDESC_ARRAY);
37 mb.ifZeroComparisonBranch(failure, "!=");
42 public int constructorTag() {