1 package org.simantics.scl.compiler.constants;
4 import org.objectweb.asm.Label;
5 import org.simantics.scl.compiler.internal.codegen.references.Val;
6 import org.simantics.scl.compiler.internal.codegen.types.JavaTypeTranslator;
7 import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
8 import org.simantics.scl.compiler.types.TVar;
9 import org.simantics.scl.compiler.types.Type;
10 import org.simantics.scl.compiler.types.Types;
12 public class JavaComparisonOperation extends FunctionValue {
16 public JavaComparisonOperation(String op, Type type) {
17 super(TVar.EMPTY_ARRAY, Types.NO_EFFECTS, Types.BOOLEAN, type, type);
22 public Type applyExact(MethodBuilder mb, Val[] parameters) {
23 JavaTypeTranslator tt = mb.getJavaTypeTranslator();
24 Label thenBranch = mb.createLabel();
25 Label joinPoint = mb.createLabel();
27 mb.push(parameters[0], type);
28 mb.push(parameters[1], type);
29 mb.ifComparisonBranch(thenBranch, op, tt.toTypeDesc(parameterTypes[0]));
31 mb.loadConstant(false);
34 mb.setLocation(thenBranch);
35 mb.loadConstant(true);
36 mb.setLocation(joinPoint);
38 return getReturnType();
42 public String toString() {
43 return "(" + op + ")";