Skip to content

Commit e6b62aa

Browse files
committed
Remove ICode's TypeKinds, use BTypes in the backend instead
1 parent d38d31b commit e6b62aa

File tree

3 files changed

+8
-482
lines changed

3 files changed

+8
-482
lines changed

src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ abstract class ScalaPrimitives {
3131

3232
import global._
3333
import definitions._
34-
import global.icodes.{TypeKind, toTypeKind}
35-
import global.icodes.{BOOL, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT, REFERENCE, ARRAY}
3634

3735
// Arithmetic unary operations
3836
final val POS = 1 // +x
@@ -458,18 +456,6 @@ abstract class ScalaPrimitives {
458456

459457
def isCoercion(code: Int): Boolean = (code >= B2B) && (code <= D2D)
460458

461-
final val typeOfArrayOp: Map[Int, TypeKind] = Map(
462-
(List(ZARRAY_LENGTH, ZARRAY_GET, ZARRAY_SET) map (_ -> BOOL)) ++
463-
(List(BARRAY_LENGTH, BARRAY_GET, BARRAY_SET) map (_ -> BYTE)) ++
464-
(List(SARRAY_LENGTH, SARRAY_GET, SARRAY_SET) map (_ -> SHORT)) ++
465-
(List(CARRAY_LENGTH, CARRAY_GET, CARRAY_SET) map (_ -> CHAR)) ++
466-
(List(IARRAY_LENGTH, IARRAY_GET, IARRAY_SET) map (_ -> INT)) ++
467-
(List(LARRAY_LENGTH, LARRAY_GET, LARRAY_SET) map (_ -> LONG)) ++
468-
(List(FARRAY_LENGTH, FARRAY_GET, FARRAY_SET) map (_ -> FLOAT)) ++
469-
(List(DARRAY_LENGTH, DARRAY_GET, DARRAY_SET) map (_ -> DOUBLE)) ++
470-
(List(OARRAY_LENGTH, OARRAY_GET, OARRAY_SET) map (_ -> REFERENCE(AnyRefClass))) : _*
471-
)
472-
473459
/** Check whether the given operation code is an array operation. */
474460
def isArrayOp(code: Int): Boolean =
475461
isArrayNew(code) | isArrayLength(code) | isArrayGet(code) | isArraySet(code)
@@ -536,17 +522,6 @@ abstract class ScalaPrimitives {
536522
case _ => false
537523
}
538524

539-
/** If code is a coercion primitive, the result type */
540-
def generatedKind(code: Int): TypeKind = code match {
541-
case B2B | C2B | S2B | I2B | L2B | F2B | D2B => BYTE
542-
case B2C | C2C | S2C | I2C | L2C | F2C | D2C => CHAR
543-
case B2S | C2S | S2S | I2S | L2S | F2S | D2S => SHORT
544-
case B2I | C2I | S2I | I2I | L2I | F2I | D2I => INT
545-
case B2L | C2L | S2L | I2L | L2L | F2L | D2L => LONG
546-
case B2F | C2F | S2F | I2F | L2F | F2F | D2F => FLOAT
547-
case B2D | C2D | S2D | I2D | L2D | F2D | D2D => DOUBLE
548-
}
549-
550525
def isPrimitive(sym: Symbol): Boolean = primitives contains sym
551526

552527
/** Return the code for the given symbol. */
@@ -564,6 +539,7 @@ abstract class ScalaPrimitives {
564539
*/
565540
def getPrimitive(fun: Symbol, tpe: Type): Int = {
566541
import definitions._
542+
import genBCode.bTypes._
567543
val code = getPrimitive(fun)
568544

569545
def elementType = enteringTyper {
@@ -576,7 +552,7 @@ abstract class ScalaPrimitives {
576552
code match {
577553

578554
case APPLY =>
579-
toTypeKind(elementType) match {
555+
typeToBType(elementType) match {
580556
case BOOL => ZARRAY_GET
581557
case BYTE => BARRAY_GET
582558
case SHORT => SARRAY_GET
@@ -585,13 +561,13 @@ abstract class ScalaPrimitives {
585561
case LONG => LARRAY_GET
586562
case FLOAT => FARRAY_GET
587563
case DOUBLE => DARRAY_GET
588-
case REFERENCE(_) | ARRAY(_) => OARRAY_GET
564+
case _: ClassBType | _: ArrayBType => OARRAY_GET
589565
case _ =>
590566
abort("Unexpected array element type: " + elementType)
591567
}
592568

593569
case UPDATE =>
594-
toTypeKind(elementType) match {
570+
typeToBType(elementType) match {
595571
case BOOL => ZARRAY_SET
596572
case BYTE => BARRAY_SET
597573
case SHORT => SARRAY_SET
@@ -600,13 +576,13 @@ abstract class ScalaPrimitives {
600576
case LONG => LARRAY_SET
601577
case FLOAT => FARRAY_SET
602578
case DOUBLE => DARRAY_SET
603-
case REFERENCE(_) | ARRAY(_) => OARRAY_SET
579+
case _: ClassBType | _: ArrayBType => OARRAY_SET
604580
case _ =>
605581
abort("Unexpected array element type: " + elementType)
606582
}
607583

608584
case LENGTH =>
609-
toTypeKind(elementType) match {
585+
typeToBType(elementType) match {
610586
case BOOL => ZARRAY_LENGTH
611587
case BYTE => BARRAY_LENGTH
612588
case SHORT => SARRAY_LENGTH
@@ -615,7 +591,7 @@ abstract class ScalaPrimitives {
615591
case LONG => LARRAY_LENGTH
616592
case FLOAT => FARRAY_LENGTH
617593
case DOUBLE => DARRAY_LENGTH
618-
case REFERENCE(_) | ARRAY(_) => OARRAY_LENGTH
594+
case _: ClassBType | _: ArrayBType => OARRAY_LENGTH
619595
case _ =>
620596
abort("Unexpected array element type: " + elementType)
621597
}

src/compiler/scala/tools/nsc/backend/icode/ICodes.scala

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,7 @@ package icode
1111
*
1212
* @author Iulian Dragos
1313
*/
14-
abstract class ICodes extends AnyRef
15-
with Members
16-
with TypeKinds
17-
with Primitives
18-
{
14+
abstract class ICodes extends AnyRef with Members with Primitives {
1915
val global: Global
20-
import global.definitions
21-
22-
lazy val AnyRefReference: TypeKind = REFERENCE(definitions.AnyRefClass)
23-
lazy val BoxedUnitReference: TypeKind = REFERENCE(definitions.BoxedUnitClass)
24-
lazy val NothingReference: TypeKind = REFERENCE(definitions.NothingClass)
25-
lazy val NullReference: TypeKind = REFERENCE(definitions.NullClass)
26-
lazy val ObjectReference: TypeKind = REFERENCE(definitions.ObjectClass)
27-
lazy val StringReference: TypeKind = REFERENCE(definitions.StringClass)
2816
}
2917

0 commit comments

Comments
 (0)