aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorSébastien Doeraene <sjrdoeraene@gmail.com>2016-02-26 16:30:39 +0100
committerSébastien Doeraene <sjrdoeraene@gmail.com>2016-03-01 15:47:56 +0100
commitcd4004a82d9713bbb0b120aba83b3ed8fc9f1372 (patch)
tree309f090cb79fba02746b7b8a0109e171881d5d27 /src/dotty/tools/dotc
parent0ebf36b394b00f3f432d8fdedeaa15e7d4df2b06 (diff)
downloaddotty-cd4004a82d9713bbb0b120aba83b3ed8fc9f1372.tar.gz
dotty-cd4004a82d9713bbb0b120aba83b3ed8fc9f1372.tar.bz2
dotty-cd4004a82d9713bbb0b120aba83b3ed8fc9f1372.zip
Initial infrastructure and hello world for the Scala.js back-end.
The Scala.js back-end can be enabled with the `-scalajs` command-line option. Currently, it adds one phase to the pipeline, which emits .sjsir files from trees. A sandbox project `sjsSandbox`, in `sandbox/scalajs/`, can be used to easily test Scala.js compilation. One can run the `main()` method of the `hello.world` object with > sjsSandbox/run The back-end only contains the bare mimimum to compile the hello world application in the sandbox. Anything else will blow up (for example, primitive method calls). It is a work-in-progress.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala13
-rw-r--r--src/dotty/tools/dotc/config/ScalaSettings.scala1
2 files changed, 13 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index d526903b8..2a3346486 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -16,6 +16,7 @@ import core.DenotTransformers.DenotTransformer
import core.Denotations.SingleDenotation
import dotty.tools.backend.jvm.{LabelDefs, GenBCode}
+import dotty.tools.backend.sjs.GenSJSIR
class Compiler {
@@ -83,6 +84,7 @@ class Compiler {
List(new ExpandPrivate,
new CollectEntryPoints,
new LabelDefs),
+ List(new GenSJSIR),
List(new GenBCode)
)
@@ -101,7 +103,16 @@ class Compiler {
*/
def rootContext(implicit ctx: Context): Context = {
ctx.definitions.init(ctx)
- ctx.setPhasePlan(phases)
+ val actualPhases = if (ctx.settings.scalajs.value) {
+ phases
+ } else {
+ // Remove Scala.js-related phases
+ phases.mapConserve(_.filter {
+ case _: GenSJSIR => false
+ case _ => true
+ }).filter(_.nonEmpty)
+ }
+ ctx.setPhasePlan(actualPhases)
val rootScope = new MutableScope
val bootstrap = ctx.fresh
.setPeriod(Period(nextRunId, FirstPhaseId))
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala
index 65bc9ba23..aa264329c 100644
--- a/src/dotty/tools/dotc/config/ScalaSettings.scala
+++ b/src/dotty/tools/dotc/config/ScalaSettings.scala
@@ -29,6 +29,7 @@ class ScalaSettings extends Settings.SettingGroup {
val target = ChoiceSetting("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.",
List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "jvm-1.8", "msil"),
"jvm-1.8")
+ val scalajs = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).")
val unchecked = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.")
val uniqid = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.")
val usejavacp = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.")