diff options
Diffstat (limited to 'src/dotty/tools/dotc/Compiler.scala')
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index c2f21f639..286ed3456 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -5,6 +5,7 @@ import core._ import Contexts._ import Periods._ import Symbols._ +import Scopes._ import typer.{FrontEnd, Typer, Mode, ImportInfo} import reporting.ConsoleReporter import dotty.tools.dotc.core.Phases.Phase @@ -28,16 +29,28 @@ class Compiler { runId += 1; runId } + /** Produces the following contexts, from outermost to innermost + * + * bootStrap: A context with next available runId and a scope consisting of + * the RootPackage _root_ + * start A context with RootClass as owner and the necessary initializations + * for type checking. + * imports For each element of RootImports, an import context + */ def rootContext(implicit ctx: Context): Context = { ctx.definitions.init(ctx) ctx.usePhases(phases) - val start = ctx.fresh + val rootScope = new MutableScope + val bootstrap = ctx.fresh .withPeriod(Period(nextRunId, FirstPhaseId)) + .withScope(rootScope) + rootScope.enter(ctx.definitions.RootPackage)(bootstrap) + val start = bootstrap.fresh .withOwner(defn.RootClass) .withTyper(new Typer) .withNewMode(Mode.ImplicitsEnabled) .withTyperState(new MutableTyperState(ctx.typerState, new ConsoleReporter()(ctx), isCommittable = true)) - ctx.definitions.init(start) + ctx.definitions.init(start) // set context of definitions to start def addImport(ctx: Context, sym: Symbol) = ctx.fresh.withImportInfo(ImportInfo.rootImport(sym)(ctx)) (start.withRunInfo(new RunInfo(start)) /: defn.RootImports)(addImport) |