aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/backend/jvm/scalaPrimitives.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-12-01 16:58:53 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-12-16 13:15:01 +0100
commitd23cab1dcff8c28d4817f3dccfefbc8cb58f017f (patch)
treec8807828b910bc8953079d1e00619d6cbb12e8b9 /src/dotty/tools/backend/jvm/scalaPrimitives.scala
parent6446bbb41c48c91388373e5221b9874c676ccbfd (diff)
downloaddotty-d23cab1dcff8c28d4817f3dccfefbc8cb58f017f.tar.gz
dotty-d23cab1dcff8c28d4817f3dccfefbc8cb58f017f.tar.bz2
dotty-d23cab1dcff8c28d4817f3dccfefbc8cb58f017f.zip
Handle Arrays in backend.
Diffstat (limited to 'src/dotty/tools/backend/jvm/scalaPrimitives.scala')
-rwxr-xr-xsrc/dotty/tools/backend/jvm/scalaPrimitives.scala23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/dotty/tools/backend/jvm/scalaPrimitives.scala b/src/dotty/tools/backend/jvm/scalaPrimitives.scala
index 150e672c7..feb74faf5 100755
--- a/src/dotty/tools/backend/jvm/scalaPrimitives.scala
+++ b/src/dotty/tools/backend/jvm/scalaPrimitives.scala
@@ -7,8 +7,11 @@ package dotty.tools.dotc
package backend.jvm
import dotty.tools.backend.jvm.GenBCodePipeline
+import dotty.tools.dotc.ast.Trees.{Select, Apply}
+import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.core.Names.TermName
-import dotty.tools.dotc.core.Types.{ErrorType, Type}
+import dotty.tools.dotc.core.StdNames._
+import dotty.tools.dotc.core.Types.{JavaArrayType, ErrorType, Type}
import scala.collection.{ mutable, immutable }
@@ -52,12 +55,22 @@ class DottyPrimitives(ctx: Context) {
* @param tpe The type of the receiver object. It is used only for array
* operations
*/
- def getPrimitive(fun: Symbol, tpe: Type)(implicit ctx: Context): Int = {
+ def getPrimitive(app: tpd.Apply, tpe: Type)(implicit ctx: Context): Int = {
+ val fun = app.fun.symbol
val defn = ctx.definitions
- val code = getPrimitive(fun)
+ val code = app.fun match {
+ case Select(_, nme.primitive.arrayLength) =>
+ LENGTH
+ case Select(_, nme.primitive.arrayUpdate) =>
+ UPDATE
+ case Select(_, nme.primitive.arrayApply) =>
+ APPLY
+ case _ => getPrimitive(fun)
+ }
def elementType: Type = tpe.widenDealias match {
case defn.ArrayType(el) => el
+ case JavaArrayType(el) => el
case _ =>
ctx.error(s"expected Array $tpe")
ErrorType
@@ -391,7 +404,9 @@ class DottyPrimitives(ctx: Context) {
primitives.toMap
}
- def isPrimitive(sym: Symbol): Boolean = primitives contains sym
+ def isPrimitive(sym: Symbol): Boolean = {
+ (primitives contains sym) || sym == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length}
+ }
}