/
Object.scala
64 lines (50 loc) · 2.03 KB
/
Object.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package java.lang
import scala.scalanative.unsafe._
import scala.scalanative.runtime, runtime.ClassTypeOps
import scala.scalanative.runtime
import scala.scalanative.runtime.libc
import scala.scalanative.runtime.Intrinsics._
class _Object {
@inline def __equals(that: _Object): scala.Boolean =
this eq that
@inline def __hashCode(): scala.Int = {
val addr = castRawPtrToLong(castObjectToRawPtr(this))
addr.toInt ^ (addr >> 32).toInt
}
@inline def __toString(): String =
getClass.getName + "@" + Integer.toHexString(hashCode)
@inline def __getClass(): _Class[_] =
new _Class(runtime.getRawType(this))
@inline def __notify(): Unit =
runtime.getMonitor(this)._notify
@inline def __notifyAll(): Unit =
runtime.getMonitor(this)._notifyAll
@inline def __wait(): Unit =
runtime.getMonitor(this)._wait
@inline def __wait(timeout: scala.Long): Unit =
runtime.getMonitor(this)._wait(timeout)
@inline def __wait(timeout: scala.Long, nanos: Int): Unit =
runtime.getMonitor(this)._wait(timeout, nanos)
@inline def __scala_==(that: _Object): scala.Boolean = {
// This implementation is only called for classes that don't override
// equals. Otherwise, whenever equals is overriden, we also update the
// vtable entry for scala_== to point to the override directly.
this eq that
}
@inline def __scala_## : scala.Int = {
// This implementation is only called for classes that don't override
// hashCode. Otherwise, whenever hashCode is overriden, we also update the
// vtable entry for scala_## to point to the override directly.
val addr = castRawPtrToLong(castObjectToRawPtr(this))
addr.toInt ^ (addr >> 32).toInt
}
protected def __clone(): _Object = {
val rawty = runtime.getRawType(this)
val size = loadInt(elemRawPtr(rawty, sizeof[runtime.Type]))
val clone = runtime.GC.alloc(rawty, size)
val src = castObjectToRawPtr(this)
libc.memcpy(clone, src, size)
castRawPtrToObject(clone).asInstanceOf[_Object]
}
protected def __finalize(): Unit = ()
}