diff options
author | odersky <odersky@gmail.com> | 2016-03-18 11:29:21 +0100 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2016-03-18 11:29:21 +0100 |
commit | d875fef31d984198489a3f94bdb4894698ad0cdb (patch) | |
tree | c1bde010d9911206003f4eeea2862fed814a1945 /src/dotty/tools/dotc/config | |
parent | cdbc1631d1eda5a1a3eaa708b585a6a052852646 (diff) | |
parent | 122b0351e3e5d0fbacf2aab9bbcc7cd57a4f7dc9 (diff) | |
download | dotty-d875fef31d984198489a3f94bdb4894698ad0cdb.tar.gz dotty-d875fef31d984198489a3f94bdb4894698ad0cdb.tar.bz2 dotty-d875fef31d984198489a3f94bdb4894698ad0cdb.zip |
Merge pull request #1148 from sjrd/scalajs-gen-exprs
Implement most of the Scala.js IR code generator.
Diffstat (limited to 'src/dotty/tools/dotc/config')
-rw-r--r-- | src/dotty/tools/dotc/config/JavaPlatform.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/config/Platform.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/config/SJSPlatform.scala | 5 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/config/JavaPlatform.scala b/src/dotty/tools/dotc/config/JavaPlatform.scala index 432a9a0b7..433b5b3f0 100644 --- a/src/dotty/tools/dotc/config/JavaPlatform.scala +++ b/src/dotty/tools/dotc/config/JavaPlatform.scala @@ -7,6 +7,7 @@ import ClassPath.{ JavaContext, DefaultJavaContext } import core._ import Symbols._, Types._, Contexts._, Denotations._, SymDenotations._, StdNames._, Names._ import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._ +import transform.ExplicitOuter, transform.SymUtils._ class JavaPlatform extends Platform { @@ -38,6 +39,14 @@ class JavaPlatform extends Platform { def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = new ctx.base.loaders.PackageLoader(root, classPath) + /** Is the SAMType `cls` also a SAM under the rules of the JVM? */ + def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean = + cls.is(NoInitsTrait) && + cls.superClass == defn.ObjectClass && + cls.directlyInheritedTraits.forall(_.is(NoInits)) && + !ExplicitOuter.needsOuterIfReferenced(cls) && + cls.typeRef.fields.isEmpty // Superaccessors already show up as abstract methods here, so no test necessary + /** We could get away with excluding BoxedBooleanClass for the * purpose of equality testing since it need not compare equal * to anything but other booleans, but it should be present in diff --git a/src/dotty/tools/dotc/config/Platform.scala b/src/dotty/tools/dotc/config/Platform.scala index 972892d12..062d9002d 100644 --- a/src/dotty/tools/dotc/config/Platform.scala +++ b/src/dotty/tools/dotc/config/Platform.scala @@ -27,6 +27,9 @@ abstract class Platform { /** Any platform-specific phases. */ //def platformPhases: List[SubComponent] + /** Is the SAMType `cls` also a SAM under the rules of the platform? */ + def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean + /** The various ways a boxed primitive might materialize at runtime. */ def isMaybeBoxed(sym: ClassSymbol)(implicit ctx: Context): Boolean diff --git a/src/dotty/tools/dotc/config/SJSPlatform.scala b/src/dotty/tools/dotc/config/SJSPlatform.scala index fec9c25a1..3ec8049ae 100644 --- a/src/dotty/tools/dotc/config/SJSPlatform.scala +++ b/src/dotty/tools/dotc/config/SJSPlatform.scala @@ -2,6 +2,7 @@ package dotty.tools.dotc.config import dotty.tools.dotc.core._ import Contexts._ +import Symbols._ import dotty.tools.backend.sjs.JSDefinitions @@ -10,4 +11,8 @@ class SJSPlatform()(implicit ctx: Context) extends JavaPlatform { /** Scala.js-specific definitions. */ val jsDefinitions: JSDefinitions = new JSDefinitions() + /** Is the SAMType `cls` also a SAM under the rules of the Scala.js back-end? */ + override def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean = + defn.isFunctionClass(cls) || jsDefinitions.isJSFunctionClass(cls) + } |