-package org.simantics.scl.compiler.constants;
-
-import org.cojen.classfile.TypeDesc;
-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 FailFunction extends FunctionValue {
-
- private static final TVar A = Types.var(Kinds.STAR);
- public static final FailFunction INSTANCE =
- new FailFunction();
-
- private FailFunction() {
- super(new TVar[] {A}, Types.NO_EFFECTS, A, Types.STRING);
- }
-
- private static final TypeDesc RuntimeException =
- TypeDesc.forClass(RuntimeException.class);
-
- @Override
- public Type applyExact(MethodBuilder mb, Val[] parameters) {
- mb.newObject(RuntimeException);
- mb.dup();
- mb.push(parameters, parameterTypes);
- mb.invokeConstructor(RuntimeException,
- new TypeDesc[] {TypeDesc.STRING});
- mb.throwObject();
- return getReturnType();
- }
-
- @Override
- public String toString() {
- return "fail";
- }
-}