abstract class ScalaPrimitives extends AnyRef
Scala primitive operations are represented as methods in Any
and
AnyVal
subclasses. Here we demultiplex them by providing a mapping
from their symbols to integers. Different methods exist for
different value types, but with the same meaning (like plus, minus,
etc.). They will all be mapped to the same int.
Note: The three equal methods have the following semantics:
"=="
checks fornull
, and if non-null, callsjava.lang.Object.equals
(class: Any; modifier: final)
. Primitive:EQ
"eq"
usual reference comparison(class: AnyRef; modifier: final)
. Primitive:ID
"equals"
user-defined equality (Java semantics)(class: Object; modifier: none)
. Primitive:EQUALS
Inspired from the scalac
compiler.
- Source
- ScalaPrimitives.scala
- Alphabetic
- By Inheritance
- ScalaPrimitives
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ScalaPrimitives()
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toany2stringadd[ScalaPrimitives] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (ScalaPrimitives, B)
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toArrowAssoc[ScalaPrimitives] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final val ADD: Int(10)
- final val AND: Int(22)
- final val APPLY: Int(71)
- final val AS: Int(81)
- final val ASR: Int(32)
- final val B2B: Int(200)
- final val B2C: Int(202)
- final val B2D: Int(206)
- final val B2F: Int(205)
- final val B2I: Int(203)
- final val B2L: Int(204)
- final val B2S: Int(201)
- final val BARRAY_GET: Int(141)
- final val BARRAY_LENGTH: Int(132)
- final val BARRAY_SET: Int(151)
- final val BOX: Int(110)
- final val C2B: Int(220)
- final val C2C: Int(222)
- final val C2D: Int(226)
- final val C2F: Int(225)
- final val C2I: Int(223)
- final val C2L: Int(224)
- final val C2S: Int(221)
- final val CARRAY_GET: Int(143)
- final val CARRAY_LENGTH: Int(134)
- final val CARRAY_SET: Int(153)
- final val COERCE: Int(101)
- final val CONCAT: Int(100)
- final val D2B: Int(260)
- final val D2C: Int(262)
- final val D2D: Int(266)
- final val D2F: Int(265)
- final val D2I: Int(263)
- final val D2L: Int(264)
- final val D2S: Int(261)
- final val DARRAY_GET: Int(147)
- final val DARRAY_LENGTH: Int(138)
- final val DARRAY_SET: Int(157)
- final val DIV: Int(13)
- final val EQ: Int(42)
- final val F2B: Int(250)
- final val F2C: Int(252)
- final val F2D: Int(256)
- final val F2F: Int(255)
- final val F2I: Int(253)
- final val F2L: Int(254)
- final val F2S: Int(251)
- final val FARRAY_GET: Int(146)
- final val FARRAY_LENGTH: Int(137)
- final val FARRAY_SET: Int(156)
- final val GE: Int(47)
- final val GT: Int(46)
- final val HASH: Int(87)
- final val I2B: Int(230)
- final val I2C: Int(232)
- final val I2D: Int(236)
- final val I2F: Int(235)
- final val I2I: Int(233)
- final val I2L: Int(234)
- final val I2S: Int(231)
- final val IARRAY_GET: Int(144)
- final val IARRAY_LENGTH: Int(135)
- final val IARRAY_SET: Int(154)
- final val ID: Int(40)
- final val IS: Int(80)
- final val L2B: Int(240)
- final val L2C: Int(242)
- final val L2D: Int(246)
- final val L2F: Int(245)
- final val L2I: Int(243)
- final val L2L: Int(244)
- final val L2S: Int(241)
- final val LARRAY_GET: Int(145)
- final val LARRAY_LENGTH: Int(136)
- final val LARRAY_SET: Int(155)
- final val LE: Int(45)
- final val LENGTH: Int(70)
- final val LSL: Int(30)
- final val LSR: Int(31)
- final val LT: Int(44)
- final val MOD: Int(14)
- final val MUL: Int(12)
- final val NE: Int(43)
- final val NEG: Int(2)
- final val NEW_BARRAY: Int(113)
- final val NEW_CARRAY: Int(115)
- final val NEW_DARRAY: Int(119)
- final val NEW_FARRAY: Int(118)
- final val NEW_IARRAY: Int(116)
- final val NEW_LARRAY: Int(117)
- final val NEW_OARRAY: Int(120)
- final val NEW_SARRAY: Int(114)
- final val NEW_ZARRAY: Int(112)
- final val NI: Int(41)
- final val NOT: Int(3)
- final val OARRAY_GET: Int(148)
- final val OARRAY_LENGTH: Int(139)
- final val OARRAY_SET: Int(158)
- final val OR: Int(20)
- final val POS: Int(1)
- final val S2B: Int(210)
- final val S2C: Int(212)
- final val S2D: Int(216)
- final val S2F: Int(215)
- final val S2I: Int(213)
- final val S2L: Int(214)
- final val S2S: Int(211)
- final val SARRAY_GET: Int(142)
- final val SARRAY_LENGTH: Int(133)
- final val SARRAY_SET: Int(152)
- final val SUB: Int(11)
- final val SYNCHRONIZED: Int(90)
- final val UNBOX: Int(111)
- final val UPDATE: Int(72)
- final val XOR: Int(21)
- final val ZAND: Int(61)
- final val ZARRAY_GET: Int(140)
- final val ZARRAY_LENGTH: Int(131)
- final val ZARRAY_SET: Int(150)
- final val ZNOT: Int(50)
- final val ZOR: Int(60)
- def addPrimitive(s: Global.Symbol, code: Int): Unit
Add a primitive operation to the map
- def addPrimitives(cls: Global.Symbol, method: Global.Name, code: Int): Unit
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def ensuring(cond: (ScalaPrimitives) => Boolean, msg: => Any): ScalaPrimitives
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toEnsuring[ScalaPrimitives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (ScalaPrimitives) => Boolean): ScalaPrimitives
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toEnsuring[ScalaPrimitives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): ScalaPrimitives
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toEnsuring[ScalaPrimitives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): ScalaPrimitives
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toEnsuring[ScalaPrimitives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toStringFormat[ScalaPrimitives] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getPrimitive(fun: Global.Symbol, tpe: Global.Type): Int
Return the primitive code of the given operation.
Return the primitive code of the given operation. If the operation is an array get/set, we inspect the type of the receiver to demux the operation.
- fun
The method symbol
- tpe
The type of the receiver object. It is used only for array operations
- def getPrimitive(sym: Global.Symbol): Int
Return the code for the given symbol.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def init(): Unit
Initialize the primitive map
- def isArithmeticOp(code: Int): Boolean
- def isArrayGet(code: Int): Boolean
- def isArrayLength(code: Int): Boolean
- def isArrayNew(code: Int): Boolean
- def isArrayOp(code: Int): Boolean
Check whether the given operation code is an array operation.
- def isArraySet(code: Int): Boolean
- def isBitwiseOp(code: Int): Boolean
- def isCoercion(code: Int): Boolean
- def isComparisonOp(code: Int): Boolean
Check whether the given code is a comparison operator
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isLogicalOp(code: Int): Boolean
- def isPrimitive(sym: Global.Symbol): Boolean
- def isReferenceEqualityOp(code: Int): Boolean
- def isShiftOp(code: Int): Boolean
- def isUniversalEqualityOp(code: Int): Boolean
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def →[B](y: B): (ScalaPrimitives, B)
- Implicit
- This member is added by an implicit conversion from ScalaPrimitives toArrowAssoc[ScalaPrimitives] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
The Scala compiler and reflection APIs.