summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-07-01 09:46:49 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-07-01 09:46:49 -0700
commite2fbbb28fa0200d4799ed81a4c93dcb224f6564b (patch)
tree706f5020c22393e207b02b598b7cac71b7dcdc24 /src/reflect
parentbfda11426f9c908831489bb9173bc88dec5c4ce8 (diff)
parented7f488465a036d55959a7136fffa9c622d43eac (diff)
downloadscala-e2fbbb28fa0200d4799ed81a4c93dcb224f6564b.tar.gz
scala-e2fbbb28fa0200d4799ed81a4c93dcb224f6564b.tar.bz2
scala-e2fbbb28fa0200d4799ed81a4c93dcb224f6564b.zip
Merge pull request #2620 from magarciaEPFL/backendish33
new bytecode emitter, GenBCode (11th attempt)
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala6
-rw-r--r--src/reflect/scala/reflect/internal/Names.scala35
2 files changed, 41 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 3470b05495..bf8ef79a63 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -870,6 +870,12 @@ trait Definitions extends api.StandardDefinitions {
lazy val BoxedNumberClass = getClassByName(sn.BoxedNumber)
lazy val BoxedCharacterClass = getClassByName(sn.BoxedCharacter)
lazy val BoxedBooleanClass = getClassByName(sn.BoxedBoolean)
+ lazy val BoxedByteClass = requiredClass[java.lang.Byte]
+ lazy val BoxedShortClass = requiredClass[java.lang.Short]
+ lazy val BoxedIntClass = requiredClass[java.lang.Integer]
+ lazy val BoxedLongClass = requiredClass[java.lang.Long]
+ lazy val BoxedFloatClass = requiredClass[java.lang.Float]
+ lazy val BoxedDoubleClass = requiredClass[java.lang.Double]
lazy val Boxes_isNumberOrBool = getDecl(BoxesRunTimeClass, nme.isBoxedNumberOrBoolean)
lazy val Boxes_isNumber = getDecl(BoxesRunTimeClass, nme.isBoxedNumber)
diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala
index ed5b92565d..0d78e24548 100644
--- a/src/reflect/scala/reflect/internal/Names.scala
+++ b/src/reflect/scala/reflect/internal/Names.scala
@@ -121,6 +121,41 @@ trait Names extends api.Names {
def newTypeName(bs: Array[Byte], offset: Int, len: Int): TypeName =
newTermName(bs, offset, len).toTypeName
+ /**
+ * Used only by the GenBCode backend, to represent bytecode-level types in a way that makes equals() and hashCode() efficient.
+ * For bytecode-level types of OBJECT sort, its internal name (not its descriptor) is stored.
+ * For those of ARRAY sort, its descriptor is stored ie has a leading '['
+ * For those of METHOD sort, its descriptor is stored ie has a leading '('
+ *
+ * can-multi-thread
+ */
+ final def lookupTypeName(cs: Array[Char]): TypeName = { lookupTypeNameIfExisting(cs, true) }
+
+ final def lookupTypeNameIfExisting(cs: Array[Char], failOnNotFound: Boolean): TypeName = {
+
+ val hterm = hashValue(cs, 0, cs.size) & HASH_MASK
+ var nterm = termHashtable(hterm)
+ while ((nterm ne null) && (nterm.length != cs.size || !equals(nterm.start, cs, 0, cs.size))) {
+ nterm = nterm.next
+ }
+ if (nterm eq null) {
+ if (failOnNotFound) { assert(false, "TermName not yet created: " + new String(cs)) }
+ return null
+ }
+
+ val htype = hashValue(chrs, nterm.start, nterm.length) & HASH_MASK
+ var ntype = typeHashtable(htype)
+ while ((ntype ne null) && ntype.start != nterm.start) {
+ ntype = ntype.next
+ }
+ if (ntype eq null) {
+ if (failOnNotFound) { assert(false, "TypeName not yet created: " + new String(cs)) }
+ return null
+ }
+
+ ntype
+ }
+
// Classes ----------------------------------------------------------------------
/** The name class.