package org.simantics.scl.compiler.elaboration.java; import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; 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.exceptions.MatchException; import org.simantics.scl.compiler.types.kinds.Kinds; public class FreezeMVector extends FunctionValue { private static final TVar A = Types.var(Kinds.STAR); public FreezeMVector() { super(new TVar[] {A}, Types.PROC, Types.vector(A), Types.mvector(A)); } @Override public Type applyExact(MethodBuilder mb, Val[] parameters) { Val vectorVar = parameters[0]; vectorVar.push(mb); try { Type elementType = Types.canonical( Types.matchApply(Types.MVECTOR, vectorVar.getType())); return Types.vector(elementType); } catch (MatchException e) { throw new InternalCompilerError(e); } } }