Skip to content

Commit f54a801

Browse files
committed
Add stub unsigned integers.
1 parent f7d27ff commit f54a801

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/library/scala/UInts.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package scala
2+
3+
class UByte(val underlying: Byte) extends AnyVal
4+
class UShort(val underlying: Short) extends AnyVal
5+
class UInt(val underlying: Int) extends AnyVal
6+
class ULong(val underlying: Long) extends AnyVal

src/library/scala/runtime/BoxesRunTime.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ public static boolean equals2(Object x, Object y) {
129129
return equalsNumObject((java.lang.Number)x, y);
130130
if (x instanceof java.lang.Character)
131131
return equalsCharObject((java.lang.Character)x, y);
132+
if (x instanceof scala.runtime.UnsignedInteger)
133+
return equalsUNumObject(x, y);
132134
if (y instanceof scala.math.ScalaNumber)
133135
return y.equals(x);
134136

@@ -198,6 +200,37 @@ public static boolean equalsNumChar(java.lang.Number xn, java.lang.Character yc)
198200
return equalsNumObject(xn, yc);
199201
}
200202

203+
public static boolean equalsUNumObject(Object x, Object y) {
204+
if (x instanceof scala.UInt) {
205+
if (y instanceof scala.UInt)
206+
return ((scala.UInt)x).underlying() == ((scala.UInt)y).underlying();
207+
return slowEqualsUNumObject(x, y);
208+
}
209+
210+
if (x instanceof scala.ULong) {
211+
if (y instanceof scala.ULong)
212+
return ((scala.ULong)x).underlying() == ((scala.ULong)y).underlying();
213+
return slowEqualsUNumObject(x, y);
214+
}
215+
216+
if (x instanceof scala.UByte) {
217+
if (y instanceof scala.UByte)
218+
return ((scala.UByte)x).underlying() == ((scala.UByte)y).underlying();
219+
return slowEqualsUNumObject(x, y);
220+
}
221+
222+
if (x instanceof scala.UShort) {
223+
if (y instanceof scala.UShort)
224+
return ((scala.UShort)x).underlying() == ((scala.UShort)y).underlying();
225+
return slowEqualsUNumObject(x, y);
226+
}
227+
228+
if (y instanceof scala.math.ScalaNumber)
229+
return y.equals(x);
230+
231+
return x.equals(y);
232+
}
233+
201234
private static boolean slowEqualsLongObject(Object x, long xn, Object y) {
202235
if (y instanceof java.lang.Byte)
203236
return ((java.lang.Byte)y).byteValue() == xn;
@@ -242,6 +275,10 @@ private static boolean slowEqualsDoubleObject(Object x, double xn, Object y) {
242275
return false;
243276
}
244277

278+
private static boolean slowEqualsUNumObject(Object x, Object y) {
279+
return false;
280+
}
281+
245282
private static int unboxCharOrInt(Object arg1, int code) {
246283
if (code == CHAR)
247284
return ((java.lang.Character) arg1).charValue();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* __ *\
2+
** ________ ___ / / ___ Scala API **
3+
** / __/ __// _ | / / / _ | (c) 2006-2015, LAMP/EPFL **
4+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5+
** /____/\___/_/ |_/____/_/ | | **
6+
** |/ **
7+
\* */
8+
9+
10+
11+
package scala.runtime
12+
13+
/** Marker trait for primitive unsigned integer types.
14+
*
15+
* You should not extend this trait in user code.
16+
*/
17+
trait UnsignedInteger extends Any

0 commit comments

Comments
 (0)