aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/Compiler.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2016-03-04 23:52:48 +0100
committerDmitry Petrashko <dark@d-d.me>2016-03-04 23:52:48 +0100
commita50926701ef5171779aa025d2d307751d166cabe (patch)
tree3504781b16b133544752b52ef11338097379d6e4 /src/dotty/tools/dotc/Compiler.scala
parent6f82c225625916f9c855be1470faaa8e73093e5a (diff)
parent902479264127c7aa9f478e1145ad0e037bf83665 (diff)
downloaddotty-a50926701ef5171779aa025d2d307751d166cabe.tar.gz
dotty-a50926701ef5171779aa025d2d307751d166cabe.tar.bz2
dotty-a50926701ef5171779aa025d2d307751d166cabe.zip
Merge pull request #1126 from sjrd/scalajs
Initial infrastructure and hello world for the Scala.js back-end.
Diffstat (limited to 'src/dotty/tools/dotc/Compiler.scala')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index f12ab66c5..be4477ee2 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 {
@@ -82,6 +83,7 @@ class Compiler {
List(new ExpandPrivate,
new CollectEntryPoints,
new LabelDefs),
+ List(new GenSJSIR),
List(new GenBCode)
)
@@ -99,8 +101,17 @@ class Compiler {
* imports For each element of RootImports, an import context
*/
def rootContext(implicit ctx: Context): Context = {
- ctx.definitions.init(ctx)
- ctx.setPhasePlan(phases)
+ ctx.initialize()(ctx)
+ 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))
@@ -111,7 +122,7 @@ class Compiler {
.setTyper(new Typer)
.setMode(Mode.ImplicitsEnabled)
.setTyperState(new MutableTyperState(ctx.typerState, ctx.typerState.reporter, isCommittable = true))
- ctx.definitions.init(start) // set context of definitions to start
+ ctx.initialize()(start) // re-initialize the base context with start
def addImport(ctx: Context, refFn: () => TermRef) =
ctx.fresh.setImportInfo(ImportInfo.rootImport(refFn)(ctx))
(start.setRunInfo(new RunInfo(start)) /: defn.RootImportFns)(addImport)