From 16d475249f98dc590ed12ecce7256d7ae62b704f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 7 Apr 2011 15:45:29 +0200 Subject: [PATCH] long cmp --- idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java | 2 +- idea/src/org/jetbrains/jet/codegen/StackValue.java | 3 +++ idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index ce04ffe872c..dbffb44e2c7 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -512,7 +512,7 @@ public class ExpressionCodegen extends JetVisitor { private static boolean isNumberPrimitive(Type type) { return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE || type == Type.CHAR_TYPE || - type == Type.FLOAT_TYPE || type == Type.DOUBLE_TYPE; + type == Type.FLOAT_TYPE || type == Type.DOUBLE_TYPE || type == Type.LONG_TYPE; } private static int opcodeForMethod(final String name) { diff --git a/idea/src/org/jetbrains/jet/codegen/StackValue.java b/idea/src/org/jetbrains/jet/codegen/StackValue.java index 4cb972aa873..e42d41fd471 100644 --- a/idea/src/org/jetbrains/jet/codegen/StackValue.java +++ b/idea/src/org/jetbrains/jet/codegen/StackValue.java @@ -166,6 +166,9 @@ public abstract class StackValue { v.cmpl(type); } } + else if (type == Type.LONG_TYPE) { + v.lcmp(); + } else { opcode += (Opcodes.IF_ICMPEQ - Opcodes.IFEQ); } diff --git a/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 3cb21f12249..0c7bff80f21 100644 --- a/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -237,11 +237,11 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase { } public void testLongCmp() throws Exception { - loadText("fun foo(a: Long, b: Long): Long = if (a == b) 0xffffffff else 0.lng"); + loadText("fun foo(a: Long, b: Long): Long = if (a == b) 0xffffffff else 0xfffffffe"); System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(0xffffffffL, main.invoke(null, 1, 1)); - assertEquals(0L, main.invoke(null, 1, 0)); + assertEquals(0xfffffffeL, main.invoke(null, 1, 0)); } public void testShort() throws Exception { @@ -266,7 +266,7 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase { public void testByteLess() throws Exception { binOpTest("fun foo(a: Byte, b: Byte): Boolean = a < b", - Byte.valueOf((byte) 126), Byte.valueOf((byte) 127), 1); + Byte.valueOf((byte) 126), Byte.valueOf((byte) 127), true); } public void testBooleanConstant() throws Exception {