diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cldc-library/scala/runtime/ScalaRunTime.scala | 30 | ||||
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 27 |
2 files changed, 30 insertions, 27 deletions
diff --git a/src/cldc-library/scala/runtime/ScalaRunTime.scala b/src/cldc-library/scala/runtime/ScalaRunTime.scala index f69524be52..8cabf9c623 100644 --- a/src/cldc-library/scala/runtime/ScalaRunTime.scala +++ b/src/cldc-library/scala/runtime/ScalaRunTime.scala @@ -24,13 +24,13 @@ object ScalaRunTime { val CharTag = ".Char" val IntTag = ".Int" val LongTag = ".Long" - val FloatTag = ".Float" - val DoubleTag = ".Double" val BooleanTag = ".Boolean" - def isArray(x: AnyRef): Boolean = (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray]) + def isArray(x: AnyRef): Boolean = + (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray]) + def isValueTag(tag: String) = tag.charAt(0) == '.' - //def isValueClass(clazz: Class) = clazz.isPrimitive() + def isValueClass(clazz: Class) = (clazz == classOf[Boolean] || clazz == classOf[Byte] || clazz == classOf[Short] @@ -41,20 +41,20 @@ object ScalaRunTime { def checkInitialized[T <: AnyRef](x: T): T = if (x == null) throw new UninitializedError else x - abstract class Try[a] { - def Catch[b >: a](handler: PartialFunction[Throwable, b]): b - def Finally(handler: Unit): a + abstract class Try[A] { + def Catch[B >: A](handler: PartialFunction[Throwable, B]): B + def Finally(handler: Unit): A } - def Try[a](block: => a): Try[a] = new Try[a] with Runnable { - var result: a = _ + def Try[A](block: => A): Try[A] = new Try[A] with Runnable { + var result: A = _ var exception: Throwable = ExceptionHandling.tryCatch(this) - def run(): Unit = result = block + def run() { result = block } - def Catch[b >: a](handler: PartialFunction[Throwable, b]): b = + def Catch[B >: A](handler: PartialFunction[Throwable, B]): B = if (exception eq null) - result.asInstanceOf[b] + result.asInstanceOf[B] // !!! else if (exception is LocalReturn) // !!! // ... else if (handler isDefinedAt exception) @@ -62,9 +62,9 @@ object ScalaRunTime { else throw exception - def Finally(handler: Unit): a = + def Finally(handler: Unit): A = if (exception eq null) - result.asInstanceOf[a] + result.asInstanceOf[A] else throw exception } @@ -123,7 +123,7 @@ object ScalaRunTime { //def checkDefined[T >: Null](x: T): T = // if (x == null) throw new UndefinedException else x - def Seq[a](xs: a*): Seq[a] = null // interpreted specially by new backend. + def Seq[A](xs: A*): Seq[A] = null // interpreted specially by new backend. def arrayValue(x: BoxedArray, elemTag: String): AnyRef = if (x eq null) null else x.unbox(elemTag) diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index f631a2688a..c88aed2326 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -28,27 +28,30 @@ object ScalaRunTime { val DoubleTag = ".Double" val BooleanTag = ".Boolean" - def isArray(x: AnyRef): Boolean = (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray]) + def isArray(x: AnyRef): Boolean = + (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray]) + def isValueTag(tag: String) = tag.charAt(0) == '.' + def isValueClass(clazz: Class) = clazz.isPrimitive() def checkInitialized[T <: AnyRef](x: T): T = if (x == null) throw new UninitializedError else x - abstract class Try[a] { - def Catch[b >: a](handler: PartialFunction[Throwable, b]): b - def Finally(handler: Unit): a + abstract class Try[A] { + def Catch[B >: A](handler: PartialFunction[Throwable, B]): B + def Finally(handler: Unit): A } - def Try[a](block: => a): Try[a] = new Try[a] with Runnable { - var result: a = _ + def Try[A](block: => A): Try[A] = new Try[A] with Runnable { + var result: A = _ var exception: Throwable = ExceptionHandling.tryCatch(this) - def run(): Unit = result = block + def run() { result = block } - def Catch[b >: a](handler: PartialFunction[Throwable, b]): b = + def Catch[B >: A](handler: PartialFunction[Throwable, B]): B = if (exception eq null) - result.asInstanceOf[b] + result.asInstanceOf[B] // !!! else if (exception is LocalReturn) // !!! // ... else if (handler isDefinedAt exception) @@ -56,9 +59,9 @@ object ScalaRunTime { else throw exception - def Finally(handler: Unit): a = + def Finally(handler: Unit): A = if (exception eq null) - result.asInstanceOf[a] + result.asInstanceOf[A] else throw exception } @@ -117,7 +120,7 @@ object ScalaRunTime { //def checkDefined[T >: Null](x: T): T = // if (x == null) throw new UndefinedException else x - def Seq[a](xs: a*): Seq[a] = null // interpreted specially by new backend. + def Seq[A](xs: A*): Seq[A] = null // interpreted specially by new backend. def arrayValue(x: BoxedArray, elemTag: String): AnyRef = if (x eq null) null else x.unbox(elemTag) |