Skip to content

Commit

Permalink
Merge remote-tracking branches 'soc/fix-todos' and 'axel22/feature/pc…
Browse files Browse the repository at this point in the history
…-execution-contexts' into develop
  • Loading branch information
paulp committed Mar 14, 2012
2 parents fbeceb8 + 57475a8 commit 0c9ffe5
Show file tree
Hide file tree
Showing 18 changed files with 698 additions and 602 deletions.
4 changes: 2 additions & 2 deletions src/compiler/scala/reflect/internal/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
)
/** These should be moved somewhere like JavaPlatform.
*/
def javaSimpleName: String = addModuleSuffix(nme.dropLocalSuffix(simpleName)).toString
def javaBinaryName: String = addModuleSuffix(fullNameInternal('/')).toString
def javaSimpleName: Name = addModuleSuffix(nme.dropLocalSuffix(simpleName))
def javaBinaryName: Name = addModuleSuffix(fullNameInternal('/'))
def javaClassName: String = addModuleSuffix(fullNameInternal('.')).toString

/** The encoded full path name of this symbol, where outer names and inner names
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,15 @@ trait Opcodes { self: ICodes =>
}

case class BOX(boxType: TypeKind) extends Instruction {
assert(boxType.isValueType && (boxType ne UNIT)) // documentation
override def toString(): String = "BOX " + boxType
override def consumed = 1
override def consumedTypes = boxType :: Nil
override def produced = 1
}

case class UNBOX(boxType: TypeKind) extends Instruction {
assert(boxType.isValueType && (boxType ne UNIT)) // documentation
override def toString(): String = "UNBOX " + boxType
override def consumed = 1
override def consumedTypes = ObjectReference :: Nil
Expand Down
53 changes: 28 additions & 25 deletions src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,47 +120,50 @@ trait Primitives { self: ICodes =>


/** This class represents a test operation. */
class TestOp {
sealed abstract class TestOp {

/** Returns the negation of this operation. */
def negate(): TestOp = this match {
case EQ => NE
case NE => EQ
case LT => GE
case GE => LT
case LE => GT
case GT => LE
case _ => throw new RuntimeException("TestOp unknown case")
}
def negate(): TestOp

/** Returns a string representation of this operation. */
override def toString(): String = this match {
case EQ => "EQ"
case NE => "NE"
case LT => "LT"
case GE => "GE"
case LE => "LE"
case GT => "GT"
case _ => throw new RuntimeException("TestOp unknown case")
}
override def toString(): String
}

/** An equality test */
case object EQ extends TestOp
case object EQ extends TestOp {
def negate() = NE
override def toString() = "EQ"
}

/** A non-equality test */
case object NE extends TestOp
case object NE extends TestOp {
def negate() = EQ
override def toString() = "NE"
}

/** A less-than test */
case object LT extends TestOp
case object LT extends TestOp {
def negate() = GE
override def toString() = "LT"
}

/** A greater-than-or-equal test */
case object GE extends TestOp
case object GE extends TestOp {
def negate() = LT
override def toString() = "GE"
}

/** A less-than-or-equal test */
case object LE extends TestOp
case object LE extends TestOp {
def negate() = GT
override def toString() = "LE"
}

/** A greater-than test */
case object GT extends TestOp
case object GT extends TestOp {
def negate() = LE
override def toString() = "GT"
}

/** This class represents an arithmetic operation. */
class ArithmeticOp {
Expand Down
48 changes: 28 additions & 20 deletions src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,28 @@ trait TypeKinds { self: ICodes =>
case _ => false
}

/** On the JVM, these types are like Ints for the
* purposes of calculating the lub.
/** On the JVM,
* BOOL, BYTE, CHAR, SHORT, and INT
* are like Ints for the purposes of calculating the lub.
*/
def isIntSizedType: Boolean = this match {
case BOOL | CHAR | BYTE | SHORT | INT => true
case _ => false
}
def isIntegralType: Boolean = this match {
case BYTE | SHORT | INT | LONG | CHAR => true
case _ => false
}
def isRealType: Boolean = this match {
case FLOAT | DOUBLE => true
case _ => false
}
def isNumericType: Boolean = isIntegralType | isRealType
def isIntSizedType: Boolean = false

/** On the JVM, similar to isIntSizedType except that BOOL isn't integral while LONG is. */
def isIntegralType: Boolean = false

/** On the JVM, FLOAT and DOUBLE. */
def isRealType: Boolean = false

final def isNumericType: Boolean = isIntegralType | isRealType

/** Simple subtyping check */
def <:<(other: TypeKind): Boolean = (this eq other) || (this match {
case BOOL | BYTE | SHORT | CHAR => other == INT || other == LONG
case _ => this eq other
})

/** Is this type a category 2 type in JVM terms? */
def isWideType: Boolean = this match {
case DOUBLE | LONG => true
case _ => false
}
/** Is this type a category 2 type in JVM terms? (ie, is it LONG or DOUBLE?) */
def isWideType: Boolean = false

/** The number of dimensions for array types. */
def dimensions: Int = 0
Expand Down Expand Up @@ -182,6 +176,7 @@ trait TypeKinds { self: ICodes =>

/** A boolean value */
case object BOOL extends ValueTypeKind {
override def isIntSizedType = true
def maxType(other: TypeKind) = other match {
case BOOL | REFERENCE(NothingClass) => BOOL
case _ => uncomparable(other)
Expand All @@ -195,6 +190,8 @@ trait TypeKinds { self: ICodes =>

/** A 1-byte signed integer */
case object BYTE extends ValueTypeKind {
override def isIntSizedType = true
override def isIntegralType = true
def maxType(other: TypeKind) = {
if (other == BYTE || other.isNothingType) BYTE
else if (other == CHAR) INT
Expand All @@ -205,6 +202,8 @@ trait TypeKinds { self: ICodes =>

/** A 2-byte signed integer */
case object SHORT extends ValueTypeKind {
override def isIntSizedType = true
override def isIntegralType = true
override def maxType(other: TypeKind) = other match {
case BYTE | SHORT | REFERENCE(NothingClass) => SHORT
case CHAR => INT
Expand All @@ -215,6 +214,8 @@ trait TypeKinds { self: ICodes =>

/** A 2-byte UNSIGNED integer */
case object CHAR extends ValueTypeKind {
override def isIntSizedType = true
override def isIntegralType = true
override def maxType(other: TypeKind) = other match {
case CHAR | REFERENCE(NothingClass) => CHAR
case BYTE | SHORT => INT
Expand All @@ -225,6 +226,8 @@ trait TypeKinds { self: ICodes =>

/** A 4-byte signed integer */
case object INT extends ValueTypeKind {
override def isIntSizedType = true
override def isIntegralType = true
override def maxType(other: TypeKind) = other match {
case BYTE | SHORT | CHAR | INT | REFERENCE(NothingClass) => INT
case LONG | FLOAT | DOUBLE => other
Expand All @@ -234,6 +237,8 @@ trait TypeKinds { self: ICodes =>

/** An 8-byte signed integer */
case object LONG extends ValueTypeKind {
override def isIntegralType = true
override def isWideType = true
override def maxType(other: TypeKind): TypeKind =
if (other.isIntegralType || other.isNothingType) LONG
else if (other.isRealType) DOUBLE
Expand All @@ -242,6 +247,7 @@ trait TypeKinds { self: ICodes =>

/** A 4-byte floating point number */
case object FLOAT extends ValueTypeKind {
override def isRealType = true
override def maxType(other: TypeKind): TypeKind =
if (other == DOUBLE) DOUBLE
else if (other.isNumericType || other.isNothingType) FLOAT
Expand All @@ -250,6 +256,8 @@ trait TypeKinds { self: ICodes =>

/** An 8-byte floating point number */
case object DOUBLE extends ValueTypeKind {
override def isRealType = true
override def isWideType = true
override def maxType(other: TypeKind): TypeKind =
if (other.isNumericType || other.isNothingType) DOUBLE
else uncomparable(other)
Expand Down
Loading

0 comments on commit 0c9ffe5

Please sign in to comment.