Packages

c

scala.tools.nsc.backend

ScalaPrimitives

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 for null, and if non-null, calls java.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
Linear Supertypes
Known Subclasses
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ScalaPrimitives
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ScalaPrimitives()

Abstract Value Members

  1. abstract val global: Global

Concrete Value Members

  1. final val ADD: Int(10)
  2. final val AND: Int(22)
  3. final val APPLY: Int(71)
  4. final val AS: Int(81)
  5. final val ASR: Int(32)
  6. final val B2B: Int(200)
  7. final val B2C: Int(202)
  8. final val B2D: Int(206)
  9. final val B2F: Int(205)
  10. final val B2I: Int(203)
  11. final val B2L: Int(204)
  12. final val B2S: Int(201)
  13. final val BARRAY_GET: Int(141)
  14. final val BARRAY_LENGTH: Int(132)
  15. final val BARRAY_SET: Int(151)
  16. final val BOX: Int(110)
  17. final val C2B: Int(220)
  18. final val C2C: Int(222)
  19. final val C2D: Int(226)
  20. final val C2F: Int(225)
  21. final val C2I: Int(223)
  22. final val C2L: Int(224)
  23. final val C2S: Int(221)
  24. final val CARRAY_GET: Int(143)
  25. final val CARRAY_LENGTH: Int(134)
  26. final val CARRAY_SET: Int(153)
  27. final val COERCE: Int(101)
  28. final val CONCAT: Int(100)
  29. final val D2B: Int(260)
  30. final val D2C: Int(262)
  31. final val D2D: Int(266)
  32. final val D2F: Int(265)
  33. final val D2I: Int(263)
  34. final val D2L: Int(264)
  35. final val D2S: Int(261)
  36. final val DARRAY_GET: Int(147)
  37. final val DARRAY_LENGTH: Int(138)
  38. final val DARRAY_SET: Int(157)
  39. final val DIV: Int(13)
  40. final val EQ: Int(42)
  41. final val F2B: Int(250)
  42. final val F2C: Int(252)
  43. final val F2D: Int(256)
  44. final val F2F: Int(255)
  45. final val F2I: Int(253)
  46. final val F2L: Int(254)
  47. final val F2S: Int(251)
  48. final val FARRAY_GET: Int(146)
  49. final val FARRAY_LENGTH: Int(137)
  50. final val FARRAY_SET: Int(156)
  51. final val GE: Int(47)
  52. final val GT: Int(46)
  53. final val HASH: Int(87)
  54. final val I2B: Int(230)
  55. final val I2C: Int(232)
  56. final val I2D: Int(236)
  57. final val I2F: Int(235)
  58. final val I2I: Int(233)
  59. final val I2L: Int(234)
  60. final val I2S: Int(231)
  61. final val IARRAY_GET: Int(144)
  62. final val IARRAY_LENGTH: Int(135)
  63. final val IARRAY_SET: Int(154)
  64. final val ID: Int(40)
  65. final val IS: Int(80)
  66. final val L2B: Int(240)
  67. final val L2C: Int(242)
  68. final val L2D: Int(246)
  69. final val L2F: Int(245)
  70. final val L2I: Int(243)
  71. final val L2L: Int(244)
  72. final val L2S: Int(241)
  73. final val LARRAY_GET: Int(145)
  74. final val LARRAY_LENGTH: Int(136)
  75. final val LARRAY_SET: Int(155)
  76. final val LE: Int(45)
  77. final val LENGTH: Int(70)
  78. final val LSL: Int(30)
  79. final val LSR: Int(31)
  80. final val LT: Int(44)
  81. final val MOD: Int(14)
  82. final val MUL: Int(12)
  83. final val NE: Int(43)
  84. final val NEG: Int(2)
  85. final val NEW_BARRAY: Int(113)
  86. final val NEW_CARRAY: Int(115)
  87. final val NEW_DARRAY: Int(119)
  88. final val NEW_FARRAY: Int(118)
  89. final val NEW_IARRAY: Int(116)
  90. final val NEW_LARRAY: Int(117)
  91. final val NEW_OARRAY: Int(120)
  92. final val NEW_SARRAY: Int(114)
  93. final val NEW_ZARRAY: Int(112)
  94. final val NI: Int(41)
  95. final val NOT: Int(3)
  96. final val OARRAY_GET: Int(148)
  97. final val OARRAY_LENGTH: Int(139)
  98. final val OARRAY_SET: Int(158)
  99. final val OR: Int(20)
  100. final val POS: Int(1)
  101. final val S2B: Int(210)
  102. final val S2C: Int(212)
  103. final val S2D: Int(216)
  104. final val S2F: Int(215)
  105. final val S2I: Int(213)
  106. final val S2L: Int(214)
  107. final val S2S: Int(211)
  108. final val SARRAY_GET: Int(142)
  109. final val SARRAY_LENGTH: Int(133)
  110. final val SARRAY_SET: Int(152)
  111. final val SUB: Int(11)
  112. final val SYNCHRONIZED: Int(90)
  113. final val UNBOX: Int(111)
  114. final val UPDATE: Int(72)
  115. final val XOR: Int(21)
  116. final val ZAND: Int(61)
  117. final val ZARRAY_GET: Int(140)
  118. final val ZARRAY_LENGTH: Int(131)
  119. final val ZARRAY_SET: Int(150)
  120. final val ZNOT: Int(50)
  121. final val ZOR: Int(60)
  122. def addPrimitive(s: Global.Symbol, code: Int): Unit

    Add a primitive operation to the map

  123. def addPrimitives(cls: Global.Symbol, method: Global.Name, code: Int): Unit
  124. 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

  125. def getPrimitive(sym: Global.Symbol): Int

    Return the code for the given symbol.

  126. def init(): Unit

    Initialize the primitive map

  127. def isArithmeticOp(code: Int): Boolean
  128. def isArrayGet(code: Int): Boolean
  129. def isArrayLength(code: Int): Boolean
  130. def isArrayNew(code: Int): Boolean
  131. def isArrayOp(code: Int): Boolean

    Check whether the given operation code is an array operation.

  132. def isArraySet(code: Int): Boolean
  133. def isBitwiseOp(code: Int): Boolean
  134. def isCoercion(code: Int): Boolean
  135. def isComparisonOp(code: Int): Boolean

    Check whether the given code is a comparison operator

  136. def isLogicalOp(code: Int): Boolean
  137. def isPrimitive(sym: Global.Symbol): Boolean
  138. def isReferenceEqualityOp(code: Int): Boolean
  139. def isShiftOp(code: Int): Boolean
  140. def isUniversalEqualityOp(code: Int): Boolean