From fa99242159242f676b6b234693060d422762cebd Mon Sep 17 00:00:00 2001 From: paltherr Date: Mon, 11 Apr 2005 14:57:26 +0000 Subject: - Added method "ne" in class AnyRef --- sources/scalac/atree/ATreeFromSTree.java | 6 ++++++ sources/scalac/backend/Primitive.java | 1 + sources/scalac/backend/Primitives.java | 1 + sources/scalac/backend/jvm/GenJVM.java | 11 +++++++---- sources/scalac/backend/msil/GenMSIL.java | 4 ++-- sources/scalac/symtab/Definitions.java | 4 ++++ sources/scalac/util/Names.java | 1 + 7 files changed, 22 insertions(+), 6 deletions(-) (limited to 'sources/scalac') diff --git a/sources/scalac/atree/ATreeFromSTree.java b/sources/scalac/atree/ATreeFromSTree.java index 43944c47c2..83e50eb7e1 100644 --- a/sources/scalac/atree/ATreeFromSTree.java +++ b/sources/scalac/atree/ATreeFromSTree.java @@ -364,6 +364,10 @@ public class ATreeFromSTree { assert targs.length == 0 && vargs.length == 1: tree; return make.EQ(tree, ATypeKind.REF, object, expression(vargs[0])); + case ANYNI: + assert targs.length == 0 && vargs.length == 1: tree; + return make.NE(tree, ATypeKind.REF, object, expression(vargs[0])); + case ANYEQ: Symbol lf = newLocal(tree, definitions.ANY_TYPE()); Symbol rg = newLocal(tree, definitions.ANY_TYPE()); @@ -481,6 +485,7 @@ public class ATreeFromSTree { } if (clasz == definitions.OBJECT_CLASS) { addGenerator(definitions.OBJECT_EQ, Generator.ANYID); + addGenerator(definitions.OBJECT_NE, Generator.ANYNI); addGenerator(definitions.OBJECT_SYNCHRONIZED, Generator.SYNCHRONIZED); } if (clasz == definitions.STRING_CLASS) { @@ -535,6 +540,7 @@ public class ATreeFromSTree { /** Code generators for primitive methods. */ private static class Generator { case ANYID; + case ANYNI; case ANYEQ; case ANYNE; case ISAS(boolean cast); diff --git a/sources/scalac/backend/Primitive.java b/sources/scalac/backend/Primitive.java index 5cc6f49106..2c55a68dc8 100644 --- a/sources/scalac/backend/Primitive.java +++ b/sources/scalac/backend/Primitive.java @@ -47,6 +47,7 @@ public class Primitive { // Comparison operations public case ID; // x eq y + public case NI; // x ne y public case EQ; // x == y public case NE; // x != y public case LT; // x < y diff --git a/sources/scalac/backend/Primitives.java b/sources/scalac/backend/Primitives.java index 76869c2f78..b2cef185dd 100644 --- a/sources/scalac/backend/Primitives.java +++ b/sources/scalac/backend/Primitives.java @@ -668,6 +668,7 @@ public class Primitives { // scala.Object addPrimitive(defs.OBJECT_EQ, Primitive.ID); + addPrimitive(defs.OBJECT_NE, Primitive.NI); addPrimitive(defs.OBJECT_SYNCHRONIZED, Primitive.SYNCHRONIZED); // scala.String diff --git a/sources/scalac/backend/jvm/GenJVM.java b/sources/scalac/backend/jvm/GenJVM.java index 9ba9b67939..037b66b423 100644 --- a/sources/scalac/backend/jvm/GenJVM.java +++ b/sources/scalac/backend/jvm/GenJVM.java @@ -348,7 +348,7 @@ public class GenJVM { generatedType = resType; break; - case ID: + case ID: case NI: case EQ: case NE: case LT: case LE: case GE: case GT: case ZNOT: case ZOR: case ZAND: JCode.Label falseLabel = ctx.code.newLabel(); @@ -711,7 +711,7 @@ public class GenJVM { Tree[] allArgs = extractPrimitiveArgs((Tree.Apply)tree); switch (prim) { - case ID: case EQ: case NE: + case ID: case NI: case EQ: case NE: assert allArgs.length == 2; Tree unbox1 = unbox(allArgs[0]); Tree unbox2 = unbox(allArgs[1]); @@ -864,6 +864,9 @@ public class GenJVM { if (prim == Primitive.ID) { if (when) ctx.code.emitIF_ACMPEQ(target); else ctx.code.emitIF_ACMPNE(target); + } else if (prim == Primitive.NI) { + if (!when) ctx.code.emitIF_ACMPEQ(target); + else ctx.code.emitIF_ACMPNE(target); } else { // Comparison between two references. We inline the code // for the predefined (and final) "=="/"!=" operators, @@ -1193,7 +1196,7 @@ public class GenJVM { protected boolean isJumpingPrimitive(Symbol sym) { if (prims.isPrimitive(sym)) { switch (prims.getPrimitive(sym)) { - case ID : case EQ : case NE : + case ID : case NI : case EQ : case NE : case LT : case LE : case GE : case GT : case ZNOT : case ZOR : case ZAND : return true; @@ -1228,7 +1231,7 @@ public class GenJVM { case ZARRAY_LENGTH : case BARRAY_LENGTH : case SARRAY_LENGTH : case CARRAY_LENGTH : case IARRAY_LENGTH : case LARRAY_LENGTH : case FARRAY_LENGTH : case DARRAY_LENGTH : case OARRAY_LENGTH : - case IS : case AS : case ID : + case IS : case AS : case ID : case NI : case CONCAT : case THROW : case SYNCHRONIZED: case B2B: case B2S: case B2C: case B2I: case B2L: case B2F: case B2D: case S2B: case S2S: case S2C: case S2I: case S2L: case S2F: case S2D: diff --git a/sources/scalac/backend/msil/GenMSIL.java b/sources/scalac/backend/msil/GenMSIL.java index eae9c7cf4a..ec490359d9 100644 --- a/sources/scalac/backend/msil/GenMSIL.java +++ b/sources/scalac/backend/msil/GenMSIL.java @@ -1011,7 +1011,7 @@ public final class GenMSIL { case ADD: case SUB: case MUL: case DIV: case MOD: case OR: case XOR: case AND: case LSL: case LSR: case ASR: - case ID: case EQ: case NE: case LT: case LE: case GT: case GE: + case ID: case NI: case EQ: case NE: case LT: case LE: case GT: case GE: case ZNOT: case ZOR: case ZAND: case IS: case AS: case CONCAT: @@ -1246,7 +1246,7 @@ public final class GenMSIL { case ID: case EQ: // FIXME?: should ID be treated as EQ? res = items.CondItem(Test.Binary(Test.EQ, toType), null, null); break; - case NE: + case NI: case NE: // FIXME?: should NI be treated as NE? res = items.CondItem(Test.Binary(Test.NE, toType), null, null); break; case LT: diff --git a/sources/scalac/symtab/Definitions.java b/sources/scalac/symtab/Definitions.java index 00e37cc2a4..a6286853da 100644 --- a/sources/scalac/symtab/Definitions.java +++ b/sources/scalac/symtab/Definitions.java @@ -330,6 +330,7 @@ public class Definitions { /** Some java.lang.Object methods */ public final Symbol OBJECT_EQ; + public final Symbol OBJECT_NE; public final Symbol OBJECT_SYNCHRONIZED; /** Some java.lang.String methods */ @@ -877,10 +878,13 @@ public class Definitions { // add members to java.lang.Object OBJECT_EQ = newMethod(OBJECT_CLASS, Names.eq, Modifiers.FINAL); + OBJECT_NE = + newMethod(OBJECT_CLASS, Names.ne, Modifiers.FINAL); OBJECT_SYNCHRONIZED = newMethod(OBJECT_CLASS, Names.synchronized_, Modifiers.FINAL); initMethod(OBJECT_EQ, new Type[]{ANYREF_TYPE()}, boolean_TYPE()); + initMethod(OBJECT_NE, new Type[]{ANYREF_TYPE()}, boolean_TYPE()); Symbol OBJECT_SYNCHRONIZED_TPARAM = newTParam(OBJECT_SYNCHRONIZED,0,ANY_TYPE()); Symbol OBJECT_SYNCHRONIZED_VPARAM = diff --git a/sources/scalac/util/Names.java b/sources/scalac/util/Names.java index f1d15c414d..7bfc3d17f0 100644 --- a/sources/scalac/util/Names.java +++ b/sources/scalac/util/Names.java @@ -197,6 +197,7 @@ public class Names { public static final Name _match = Name.fromString("match"); public static final Name map = Name.fromString("map"); public static final Name n = Name.fromString("n"); + public static final Name ne = Name.fromString("ne"); public static final Name nobinding = Name.fromString("nobinding"); public static final Name next = Name.fromString("next"); public static final Name newArray = Name.fromString("newArray"); -- cgit v1.2.3