From 0da6b578845f0799b8b1610f2cf6768f64cadcfc Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 5 Dec 2005 14:33:30 +0000 Subject: Added primitive operations to (Byte|Char|Short|... Added primitive operations to (Byte|Char|Short|Int).java so that less boxing is done. --- sources/scala/Byte.java | 45 +++++++++++++ sources/scala/Char.java | 46 ++++++++++++++ sources/scala/Int.java | 46 ++++++++++++++ sources/scala/Short.java | 45 +++++++++++++ sources/scalac/backend/Primitives.java | 112 ++++++++++++++++----------------- 5 files changed, 238 insertions(+), 56 deletions(-) (limited to 'sources') diff --git a/sources/scala/Byte.java b/sources/scala/Byte.java index e998662800..2a841225dc 100644 --- a/sources/scala/Byte.java +++ b/sources/scala/Byte.java @@ -141,4 +141,49 @@ public abstract class Byte extends AnyVal implements java.io.Serializable { /** @meta method []scala.Short ; */ public short coerce ( ) { return value ; } + + public boolean $eq$eq (char that) { return value == that; } + public boolean $bang$eq (char that) { return value != that; } + public boolean $less (char that) { return value < that; } + public boolean $greater (char that) { return value > that; } + public boolean $less$eq (char that) { return value <= that; } + public boolean $greater$eq(char that) { return value >= that; } + public int $plus (char that) { return value + that; } + public int $minus (char that) { return value - that; } + public int $times (char that) { return value * that; } + public int $div (char that) { return value / that; } + public int $percent (char that) { return value % that; } + public int $bar (char that) { return value | that; } + public int $amp (char that) { return value & that; } + public int $up (char that) { return value ^ that; } + + public boolean $eq$eq (short that) { return value == that; } + public boolean $bang$eq (short that) { return value != that; } + public boolean $less (short that) { return value < that; } + public boolean $greater (short that) { return value > that; } + public boolean $less$eq (short that) { return value <= that; } + public boolean $greater$eq(short that) { return value >= that; } + public int $plus (short that) { return value + that; } + public int $minus (short that) { return value - that; } + public int $times (short that) { return value * that; } + public int $div (short that) { return value / that; } + public int $percent (short that) { return value % that; } + public int $bar (short that) { return value | that; } + public int $amp (short that) { return value & that; } + public int $up (short that) { return value ^ that; } + + public boolean $eq$eq (byte that) { return value == that; } + public boolean $bang$eq (byte that) { return value != that; } + public boolean $less (byte that) { return value < that; } + public boolean $greater (byte that) { return value > that; } + public boolean $less$eq (byte that) { return value <= that; } + public boolean $greater$eq(byte that) { return value >= that; } + public int $plus (byte that) { return value + that; } + public int $minus (byte that) { return value - that; } + public int $times (byte that) { return value * that; } + public int $div (byte that) { return value / that; } + public int $percent (byte that) { return value % that; } + public int $bar (byte that) { return value | that; } + public int $amp (byte that) { return value & that; } + public int $up (byte that) { return value ^ that; } } diff --git a/sources/scala/Char.java b/sources/scala/Char.java index 3a92fc6799..a875e717df 100644 --- a/sources/scala/Char.java +++ b/sources/scala/Char.java @@ -135,6 +135,52 @@ public abstract class Char extends AnyVal implements java.io.Serializable { public int $amp (int that) { return value & that; } public int $up (int that) { return value ^ that; } + public boolean $eq$eq (char that) { return value == that; } + public boolean $bang$eq (char that) { return value != that; } + public boolean $less (char that) { return value < that; } + public boolean $greater (char that) { return value > that; } + public boolean $less$eq (char that) { return value <= that; } + public boolean $greater$eq(char that) { return value >= that; } + public int $plus (char that) { return value + that; } + public int $minus (char that) { return value - that; } + public int $times (char that) { return value * that; } + public int $div (char that) { return value / that; } + public int $percent (char that) { return value % that; } + public int $bar (char that) { return value | that; } + public int $amp (char that) { return value & that; } + public int $up (char that) { return value ^ that; } + + public boolean $eq$eq (short that) { return value == that; } + public boolean $bang$eq (short that) { return value != that; } + public boolean $less (short that) { return value < that; } + public boolean $greater (short that) { return value > that; } + public boolean $less$eq (short that) { return value <= that; } + public boolean $greater$eq(short that) { return value >= that; } + public int $plus (short that) { return value + that; } + public int $minus (short that) { return value - that; } + public int $times (short that) { return value * that; } + public int $div (short that) { return value / that; } + public int $percent (short that) { return value % that; } + public int $bar (short that) { return value | that; } + public int $amp (short that) { return value & that; } + public int $up (short that) { return value ^ that; } + + public boolean $eq$eq (byte that) { return value == that; } + public boolean $bang$eq (byte that) { return value != that; } + public boolean $less (byte that) { return value < that; } + public boolean $greater (byte that) { return value > that; } + public boolean $less$eq (byte that) { return value <= that; } + public boolean $greater$eq(byte that) { return value >= that; } + public int $plus (byte that) { return value + that; } + public int $minus (byte that) { return value - that; } + public int $times (byte that) { return value * that; } + public int $div (byte that) { return value / that; } + public int $percent (byte that) { return value % that; } + public int $bar (byte that) { return value | that; } + public int $amp (byte that) { return value & that; } + public int $up (byte that) { return value ^ that; } + + /** @meta method []scala.Int ; */ public int coerce ( ) { return value ; } diff --git a/sources/scala/Int.java b/sources/scala/Int.java index 8e0187773f..5c5d95a63e 100644 --- a/sources/scala/Int.java +++ b/sources/scala/Int.java @@ -135,4 +135,50 @@ public abstract class Int extends AnyVal implements java.io.Serializable { public int $bar (int that) { return value | that; } public int $amp (int that) { return value & that; } public int $up (int that) { return value ^ that; } + + + public boolean $eq$eq (char that) { return value == that; } + public boolean $bang$eq (char that) { return value != that; } + public boolean $less (char that) { return value < that; } + public boolean $greater (char that) { return value > that; } + public boolean $less$eq (char that) { return value <= that; } + public boolean $greater$eq(char that) { return value >= that; } + public int $plus (char that) { return value + that; } + public int $minus (char that) { return value - that; } + public int $times (char that) { return value * that; } + public int $div (char that) { return value / that; } + public int $percent (char that) { return value % that; } + public int $bar (char that) { return value | that; } + public int $amp (char that) { return value & that; } + public int $up (char that) { return value ^ that; } + + public boolean $eq$eq (short that) { return value == that; } + public boolean $bang$eq (short that) { return value != that; } + public boolean $less (short that) { return value < that; } + public boolean $greater (short that) { return value > that; } + public boolean $less$eq (short that) { return value <= that; } + public boolean $greater$eq(short that) { return value >= that; } + public int $plus (short that) { return value + that; } + public int $minus (short that) { return value - that; } + public int $times (short that) { return value * that; } + public int $div (short that) { return value / that; } + public int $percent (short that) { return value % that; } + public int $bar (short that) { return value | that; } + public int $amp (short that) { return value & that; } + public int $up (short that) { return value ^ that; } + + public boolean $eq$eq (byte that) { return value == that; } + public boolean $bang$eq (byte that) { return value != that; } + public boolean $less (byte that) { return value < that; } + public boolean $greater (byte that) { return value > that; } + public boolean $less$eq (byte that) { return value <= that; } + public boolean $greater$eq(byte that) { return value >= that; } + public int $plus (byte that) { return value + that; } + public int $minus (byte that) { return value - that; } + public int $times (byte that) { return value * that; } + public int $div (byte that) { return value / that; } + public int $percent (byte that) { return value % that; } + public int $bar (byte that) { return value | that; } + public int $amp (byte that) { return value & that; } + public int $up (byte that) { return value ^ that; } } diff --git a/sources/scala/Short.java b/sources/scala/Short.java index b704fb88ed..e800678202 100644 --- a/sources/scala/Short.java +++ b/sources/scala/Short.java @@ -138,4 +138,49 @@ public abstract class Short extends AnyVal implements java.io.Serializable { /** @meta method []scala.Int ; */ public int coerce ( ) { return value ; } + + public boolean $eq$eq (char that) { return value == that; } + public boolean $bang$eq (char that) { return value != that; } + public boolean $less (char that) { return value < that; } + public boolean $greater (char that) { return value > that; } + public boolean $less$eq (char that) { return value <= that; } + public boolean $greater$eq(char that) { return value >= that; } + public int $plus (char that) { return value + that; } + public int $minus (char that) { return value - that; } + public int $times (char that) { return value * that; } + public int $div (char that) { return value / that; } + public int $percent (char that) { return value % that; } + public int $bar (char that) { return value | that; } + public int $amp (char that) { return value & that; } + public int $up (char that) { return value ^ that; } + + public boolean $eq$eq (short that) { return value == that; } + public boolean $bang$eq (short that) { return value != that; } + public boolean $less (short that) { return value < that; } + public boolean $greater (short that) { return value > that; } + public boolean $less$eq (short that) { return value <= that; } + public boolean $greater$eq(short that) { return value >= that; } + public int $plus (short that) { return value + that; } + public int $minus (short that) { return value - that; } + public int $times (short that) { return value * that; } + public int $div (short that) { return value / that; } + public int $percent (short that) { return value % that; } + public int $bar (short that) { return value | that; } + public int $amp (short that) { return value & that; } + public int $up (short that) { return value ^ that; } + + public boolean $eq$eq (byte that) { return value == that; } + public boolean $bang$eq (byte that) { return value != that; } + public boolean $less (byte that) { return value < that; } + public boolean $greater (byte that) { return value > that; } + public boolean $less$eq (byte that) { return value <= that; } + public boolean $greater$eq(byte that) { return value >= that; } + public int $plus (byte that) { return value + that; } + public int $minus (byte that) { return value - that; } + public int $times (byte that) { return value * that; } + public int $div (byte that) { return value / that; } + public int $percent (byte that) { return value % that; } + public int $bar (byte that) { return value | that; } + public int $amp (byte that) { return value & that; } + public int $up (byte that) { return value ^ that; } } diff --git a/sources/scalac/backend/Primitives.java b/sources/scalac/backend/Primitives.java index b2cef185dd..6a67e123e6 100644 --- a/sources/scalac/backend/Primitives.java +++ b/sources/scalac/backend/Primitives.java @@ -502,25 +502,25 @@ public class Primitives { // scala.Byte addAll(defs.BYTE_CLASS, Names.coerce, Primitive.COERCE, 5); //addAll(defs.BYTE_CLASS, Names.EQ, Primitive.EQ, 5); - addAllPrimitive(defs.BYTE_CLASS, Names.EQ, Primitive.EQ, 4); + addAllPrimitive(defs.BYTE_CLASS, Names.EQ, Primitive.EQ, 7); //addAll(defs.BYTE_CLASS, Names.NE, Primitive.NE, 5); - addAllPrimitive(defs.BYTE_CLASS, Names.NE, Primitive.NE, 4); + addAllPrimitive(defs.BYTE_CLASS, Names.NE, Primitive.NE, 7); //addAll(defs.BYTE_CLASS, Names.equals, Primitive.EQUALS, 1); addAll(defs.BYTE_CLASS, Names.hashCode, Primitive.HASHCODE, 1); addAll(defs.BYTE_CLASS, Names.toString, Primitive.TOSTRING, 1); addAll(defs.BYTE_CLASS, Names.NOT, Primitive.NOT, 1); - addAdd(defs.BYTE_CLASS, 4); - addSub(defs.BYTE_CLASS, 4); - addAll(defs.BYTE_CLASS, Names.MUL, Primitive.MUL, 4); - addAll(defs.BYTE_CLASS, Names.DIV, Primitive.DIV, 4); - addAll(defs.BYTE_CLASS, Names.MOD, Primitive.MOD, 4); - addAll(defs.BYTE_CLASS, Names.LT, Primitive.LT, 4); - addAll(defs.BYTE_CLASS, Names.LE, Primitive.LE, 4); - addAll(defs.BYTE_CLASS, Names.GT, Primitive.GT, 4); - addAll(defs.BYTE_CLASS, Names.GE, Primitive.GE, 4); - addAll(defs.BYTE_CLASS, Names.OR, Primitive.OR, 2); - addAll(defs.BYTE_CLASS, Names.XOR, Primitive.XOR, 2); - addAll(defs.BYTE_CLASS, Names.AND, Primitive.AND, 2); + addAdd(defs.BYTE_CLASS, 7); + addSub(defs.BYTE_CLASS, 7); + addAll(defs.BYTE_CLASS, Names.MUL, Primitive.MUL, 7); + addAll(defs.BYTE_CLASS, Names.DIV, Primitive.DIV, 7); + addAll(defs.BYTE_CLASS, Names.MOD, Primitive.MOD, 7); + addAll(defs.BYTE_CLASS, Names.LT, Primitive.LT, 7); + addAll(defs.BYTE_CLASS, Names.LE, Primitive.LE, 7); + addAll(defs.BYTE_CLASS, Names.GT, Primitive.GT, 7); + addAll(defs.BYTE_CLASS, Names.GE, Primitive.GE, 7); + addAll(defs.BYTE_CLASS, Names.OR, Primitive.OR, 5); + addAll(defs.BYTE_CLASS, Names.XOR, Primitive.XOR, 5); + addAll(defs.BYTE_CLASS, Names.AND, Primitive.AND, 5); addAll(defs.BYTE_CLASS, Names.LSL, Primitive.LSL, 2); addAll(defs.BYTE_CLASS, Names.LSR, Primitive.LSR, 2); addAll(defs.BYTE_CLASS, Names.ASR, Primitive.ASR, 2); @@ -528,25 +528,25 @@ public class Primitives { // scala.Short addAll(defs.SHORT_CLASS, Names.coerce, Primitive.COERCE, 4); //addAll(defs.SHORT_CLASS, Names.EQ, Primitive.EQ, 5); - addAllPrimitive(defs.SHORT_CLASS, Names.EQ, Primitive.EQ, 4); + addAllPrimitive(defs.SHORT_CLASS, Names.EQ, Primitive.EQ, 7); //addAll(defs.SHORT_CLASS, Names.NE, Primitive.NE, 5); - addAllPrimitive(defs.SHORT_CLASS, Names.NE, Primitive.NE, 4); + addAllPrimitive(defs.SHORT_CLASS, Names.NE, Primitive.NE, 7); //addAll(defs.SHORT_CLASS, Names.equals, Primitive.EQUALS, 1); addAll(defs.SHORT_CLASS, Names.hashCode, Primitive.HASHCODE, 1); addAll(defs.SHORT_CLASS, Names.toString, Primitive.TOSTRING, 1); addAll(defs.SHORT_CLASS, Names.NOT, Primitive.NOT, 1); - addAdd(defs.SHORT_CLASS, 4); - addSub(defs.SHORT_CLASS, 4); - addAll(defs.SHORT_CLASS, Names.MUL, Primitive.MUL, 4); - addAll(defs.SHORT_CLASS, Names.DIV, Primitive.DIV, 4); - addAll(defs.SHORT_CLASS, Names.MOD, Primitive.MOD, 4); - addAll(defs.SHORT_CLASS, Names.LT, Primitive.LT, 4); - addAll(defs.SHORT_CLASS, Names.LE, Primitive.LE, 4); - addAll(defs.SHORT_CLASS, Names.GT, Primitive.GT, 4); - addAll(defs.SHORT_CLASS, Names.GE, Primitive.GE, 4); - addAll(defs.SHORT_CLASS, Names.OR, Primitive.OR, 2); - addAll(defs.SHORT_CLASS, Names.XOR, Primitive.XOR, 2); - addAll(defs.SHORT_CLASS, Names.AND, Primitive.AND, 2); + addAdd(defs.SHORT_CLASS, 7); + addSub(defs.SHORT_CLASS, 7); + addAll(defs.SHORT_CLASS, Names.MUL, Primitive.MUL, 7); + addAll(defs.SHORT_CLASS, Names.DIV, Primitive.DIV, 7); + addAll(defs.SHORT_CLASS, Names.MOD, Primitive.MOD, 7); + addAll(defs.SHORT_CLASS, Names.LT, Primitive.LT, 7); + addAll(defs.SHORT_CLASS, Names.LE, Primitive.LE, 7); + addAll(defs.SHORT_CLASS, Names.GT, Primitive.GT, 7); + addAll(defs.SHORT_CLASS, Names.GE, Primitive.GE, 7); + addAll(defs.SHORT_CLASS, Names.OR, Primitive.OR, 5); + addAll(defs.SHORT_CLASS, Names.XOR, Primitive.XOR, 5); + addAll(defs.SHORT_CLASS, Names.AND, Primitive.AND, 5); addAll(defs.SHORT_CLASS, Names.LSL, Primitive.LSL, 2); addAll(defs.SHORT_CLASS, Names.LSR, Primitive.LSR, 2); addAll(defs.SHORT_CLASS, Names.ASR, Primitive.ASR, 2); @@ -554,25 +554,25 @@ public class Primitives { // scala.Char addAll(defs.CHAR_CLASS, Names.coerce, Primitive.COERCE, 4); //addAll(defs.CHAR_CLASS, Names.EQ, Primitive.EQ, 5); - addAllPrimitive(defs.CHAR_CLASS, Names.EQ, Primitive.EQ, 4); + addAllPrimitive(defs.CHAR_CLASS, Names.EQ, Primitive.EQ, 7); //addAll(defs.CHAR_CLASS, Names.NE, Primitive.NE, 5); - addAllPrimitive(defs.CHAR_CLASS, Names.NE, Primitive.NE, 4); + addAllPrimitive(defs.CHAR_CLASS, Names.NE, Primitive.NE, 7); //addAll(defs.CHAR_CLASS, Names.equals, Primitive.EQUALS, 1); addAll(defs.CHAR_CLASS, Names.hashCode, Primitive.HASHCODE, 1); addAll(defs.CHAR_CLASS, Names.toString, Primitive.TOSTRING, 1); addAll(defs.CHAR_CLASS, Names.NOT, Primitive.NOT, 1); - addAdd(defs.CHAR_CLASS, 4); - addSub(defs.CHAR_CLASS, 4); - addAll(defs.CHAR_CLASS, Names.MUL, Primitive.MUL, 4); - addAll(defs.CHAR_CLASS, Names.DIV, Primitive.DIV, 4); - addAll(defs.CHAR_CLASS, Names.MOD, Primitive.MOD, 4); - addAll(defs.CHAR_CLASS, Names.LT, Primitive.LT, 4); - addAll(defs.CHAR_CLASS, Names.LE, Primitive.LE, 4); - addAll(defs.CHAR_CLASS, Names.GT, Primitive.GT, 4); - addAll(defs.CHAR_CLASS, Names.GE, Primitive.GE, 4); - addAll(defs.CHAR_CLASS, Names.OR, Primitive.OR, 2); - addAll(defs.CHAR_CLASS, Names.XOR, Primitive.XOR, 2); - addAll(defs.CHAR_CLASS, Names.AND, Primitive.AND, 2); + addAdd(defs.CHAR_CLASS, 7); + addSub(defs.CHAR_CLASS, 7); + addAll(defs.CHAR_CLASS, Names.MUL, Primitive.MUL, 7); + addAll(defs.CHAR_CLASS, Names.DIV, Primitive.DIV, 7); + addAll(defs.CHAR_CLASS, Names.MOD, Primitive.MOD, 7); + addAll(defs.CHAR_CLASS, Names.LT, Primitive.LT, 7); + addAll(defs.CHAR_CLASS, Names.LE, Primitive.LE, 7); + addAll(defs.CHAR_CLASS, Names.GT, Primitive.GT, 7); + addAll(defs.CHAR_CLASS, Names.GE, Primitive.GE, 7); + addAll(defs.CHAR_CLASS, Names.OR, Primitive.OR, 5); + addAll(defs.CHAR_CLASS, Names.XOR, Primitive.XOR, 5); + addAll(defs.CHAR_CLASS, Names.AND, Primitive.AND, 5); addAll(defs.CHAR_CLASS, Names.LSL, Primitive.LSL, 2); addAll(defs.CHAR_CLASS, Names.LSR, Primitive.LSR, 2); addAll(defs.CHAR_CLASS, Names.ASR, Primitive.ASR, 2); @@ -580,25 +580,25 @@ public class Primitives { // scala.Int addAll(defs.INT_CLASS, Names.coerce, Primitive.COERCE, 3); //addAll(defs.INT_CLASS, Names.EQ, Primitive.EQ, 5); - addAllPrimitive(defs.INT_CLASS, Names.EQ, Primitive.EQ, 4); + addAllPrimitive(defs.INT_CLASS, Names.EQ, Primitive.EQ, 7); //addAll(defs.INT_CLASS, Names.NE, Primitive.NE, 5); - addAllPrimitive(defs.INT_CLASS, Names.NE, Primitive.NE, 4); + addAllPrimitive(defs.INT_CLASS, Names.NE, Primitive.NE, 7); //addAll(defs.INT_CLASS, Names.equals, Primitive.EQUALS, 1); addAll(defs.INT_CLASS, Names.hashCode, Primitive.HASHCODE, 1); addAll(defs.INT_CLASS, Names.toString, Primitive.TOSTRING, 1); addAll(defs.INT_CLASS, Names.NOT, Primitive.NOT, 1); - addAdd(defs.INT_CLASS, 4); - addSub(defs.INT_CLASS, 4); - addAll(defs.INT_CLASS, Names.MUL, Primitive.MUL, 4); - addAll(defs.INT_CLASS, Names.DIV, Primitive.DIV, 4); - addAll(defs.INT_CLASS, Names.MOD, Primitive.MOD, 4); - addAll(defs.INT_CLASS, Names.LT, Primitive.LT, 4); - addAll(defs.INT_CLASS, Names.LE, Primitive.LE, 4); - addAll(defs.INT_CLASS, Names.GT, Primitive.GT, 4); - addAll(defs.INT_CLASS, Names.GE, Primitive.GE, 4); - addAll(defs.INT_CLASS, Names.OR, Primitive.OR, 2); - addAll(defs.INT_CLASS, Names.XOR, Primitive.XOR, 2); - addAll(defs.INT_CLASS, Names.AND, Primitive.AND, 2); + addAdd(defs.INT_CLASS, 7); + addSub(defs.INT_CLASS, 7); + addAll(defs.INT_CLASS, Names.MUL, Primitive.MUL, 7); + addAll(defs.INT_CLASS, Names.DIV, Primitive.DIV, 7); + addAll(defs.INT_CLASS, Names.MOD, Primitive.MOD, 7); + addAll(defs.INT_CLASS, Names.LT, Primitive.LT, 7); + addAll(defs.INT_CLASS, Names.LE, Primitive.LE, 7); + addAll(defs.INT_CLASS, Names.GT, Primitive.GT, 7); + addAll(defs.INT_CLASS, Names.GE, Primitive.GE, 7); + addAll(defs.INT_CLASS, Names.OR, Primitive.OR, 5); + addAll(defs.INT_CLASS, Names.XOR, Primitive.XOR, 5); + addAll(defs.INT_CLASS, Names.AND, Primitive.AND, 5); addAll(defs.INT_CLASS, Names.LSL, Primitive.LSL, 2); addAll(defs.INT_CLASS, Names.LSR, Primitive.LSR, 2); addAll(defs.INT_CLASS, Names.ASR, Primitive.ASR, 2); -- cgit v1.2.3