Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0afd356

Browse files
Use -from-tasty flag to enable/disable some phases
Also some classes were extending FrontEnd when they only needed to extends Phase
1 parent 9b192c4 commit 0afd356

File tree

11 files changed

+72
-84
lines changed

11 files changed

+72
-84
lines changed

‎compiler/src/dotty/tools/dotc/core/Phases.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ object Phases {
262262
final def isAfterTyper(phase: Phase): Boolean = phase.id > typerPhase.id
263263
}
264264

265-
trait Phase {
265+
abstractclass Phase {
266266

267267
/** A name given to the `Phase` that can be used to debug the compiler. For
268268
* instance, it is possible to print trees after a given phase using:

‎compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import Decorators._
77
import Contexts.Context
88
import Symbols.{Symbol, ClassSymbol}
99
import SymDenotations.ClassDenotation
10-
import typer.FrontEnd
1110
import NameOps._
1211
import ast.Trees.Tree
1312
import CompilationUnit.mkCompilationUnit
13+
import Phases.Phase
1414

15-
class ReadTastyTreesFromClasses extends FrontEnd {
15+
class ReadTastyTreesFromClasses extends Phase {
1616

17-
override def isTyper: Boolean = false
17+
def phaseName: String = "tastyFrontend"
18+
19+
override def isRunnable(implicit ctx: Context): Boolean =
20+
ctx.settings.fromTasty.value
1821

1922
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] =
2023
units.flatMap(readTASTY(_)(ctx.addMode(Mode.ReadPositions)))
@@ -71,4 +74,6 @@ class ReadTastyTreesFromClasses extends FrontEnd {
7174
case unit =>
7275
Some(unit)
7376
}
77+
78+
def run(implicit ctx: Context): Unit = unsupported("run")
7479
}

‎compiler/src/dotty/tools/dotc/fromtasty/TASTYCompiler.scala‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ class TASTYCompiler extends Compiler {
1212
override protected def frontendPhases: List[List[Phase]] =
1313
List(new ReadTastyTreesFromClasses) :: Nil
1414

15-
override protected def picklerPhases: List[List[Phase]] =
16-
super.picklerPhases.map(_.filterNot(_.isInstanceOf[Pickler])) // No need to repickle
17-
1815
override def newRun(implicit ctx: Context): Run = {
1916
reset()
2017
new TASTYRun(this, ctx.addMode(Mode.ReadPositions))

‎compiler/src/dotty/tools/dotc/quoted/QuoteCompiler.scala‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package dotty.tools.dotc
1+
package dotty.tools
2+
package dotc
23
package quoted
34

45
import dotty.tools.dotc.ast.tpd
@@ -14,7 +15,6 @@ import dotty.tools.dotc.core.Symbols.defn
1415
import dotty.tools.dotc.core.Types.ExprType
1516
import dotty.tools.dotc.core.quoted.PickledQuotes
1617
import dotty.tools.dotc.transform.Staging
17-
import dotty.tools.dotc.typer.FrontEnd
1818
import dotty.tools.dotc.util.Positions.Position
1919
import dotty.tools.dotc.util.SourceFile
2020
import dotty.tools.io.{Path, VirtualFile}
@@ -40,10 +40,10 @@ class QuoteCompiler extends Compiler {
4040
def outputClassName: TypeName = "Quoted".toTypeName
4141

4242
/** Frontend that receives a scala.quoted.Expr or scala.quoted.Type as input */
43-
class QuotedFrontend(putInClass: Boolean) extends FrontEnd {
43+
class QuotedFrontend(putInClass: Boolean) extends Phase {
4444
import tpd._
4545

46-
overridedef isTyper:Boolean = false
46+
def phaseName:String = "quotedFrontend"
4747

4848
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = {
4949
units.map {
@@ -80,6 +80,8 @@ class QuoteCompiler extends Compiler {
8080
val classTree = ClassDef(cls, DefDef(cls.primaryConstructor.asTerm), run :: Nil)
8181
PackageDef(ref(defn.RootPackage).asInstanceOf[Ident], classTree :: Nil).withPos(pos)
8282
}
83+
84+
def run(implicit ctx: Context): Unit = unsupported("run")
8385
}
8486

8587
class ExprRun(comp: Compiler, ictx: Context) extends Run(comp, ictx) {
@@ -92,5 +94,4 @@ class QuoteCompiler extends Compiler {
9294
compileUnits(units)
9395
}
9496
}
95-
9697
}

‎compiler/src/dotty/tools/dotc/transform/Pickler.scala‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class Pickler extends Phase {
2424

2525
override def phaseName: String = Pickler.name
2626

27+
// No need to repickle trees comming from TASTY
28+
override def isRunnable(implicit ctx: Context): Boolean =
29+
super.isRunnable && !ctx.settings.fromTasty.value
30+
2731
private def output(name: String, msg: String) = {
2832
val s = new PrintStream(name)
2933
s.print(msg)

‎compiler/src/dotty/tools/dotc/transform/TreeChecker.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class TreeChecker extends Phase with SymTransformer {
9090
def run(implicit ctx: Context): Unit = {
9191
if (ctx.settings.YtestPickler.value && ctx.phase.prev.isInstanceOf[Pickler])
9292
ctx.echo("Skipping Ycheck after pickling with -Ytest-pickler, the returned tree contains stale symbols")
93-
else
93+
elseif (ctx.phase.prev.isCheckable)
9494
check(ctx.base.allPhases, ctx)
9595
}
9696

‎compiler/src/dotty/tools/dotc/typer/FrontEnd.scala‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package dotty.tools.dotc
1+
package dotty.tools
2+
package dotc
23
package typer
34

45
import core._
@@ -90,11 +91,7 @@ class FrontEnd extends Phase {
9091
unitContexts.map(_.compilationUnit).filterNot(discardAfterTyper)
9192
}
9293

93-
override def run(implicit ctx: Context): Unit = {
94-
parse
95-
enterSyms
96-
typeCheck
97-
}
94+
def run(implicit ctx: Context): Unit = unsupported("run")
9895
}
9996

10097
object FrontEnd {

‎doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala‎

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import core.transform._
66
import dotc.core.Contexts.Context
77
import dotc.core.Phases.Phase
88
import dotc.core.Mode
9-
import dotc.{Compiler, Run}
9+
import dotc.{Compiler, CompilationUnit, Run}
10+
import dotc.typer.FrontEnd
1011

1112
import dotty.tools.dotc.fromtasty.{ReadTastyTreesFromClasses, TASTYRun}
1213
import dotty.tools.dotc.transform.CookComments
@@ -29,36 +30,48 @@ class DocCompiler extends Compiler {
2930
if (ctx.settings.fromTasty.value) {
3031
reset()
3132
new TASTYRun(this, ctx.addMode(Mode.ReadPositions).addMode(Mode.ReadComments))
32-
} else {
33-
super.newRun
3433
}
34+
else
35+
super.newRun
3536
}
3637

37-
override protected def frontendPhases: List[List[Phase]] =
38-
List(new ReadTastyTreesFromClasses) ::
39-
List(new DocFrontEnd) :: Nil
40-
41-
override protected def picklerPhases: List[List[Phase]] =
42-
Nil
38+
/** `DocFrontEnd` uses the Dotty `FrontEnd` without discarding the AnyVal
39+
* interfaces for Boolean, Int, Char, Long, Byte etc.
40+
*
41+
* If `-from-tasty` is set, then the trees and documentation will be loaded
42+
* from TASTY. The comments will be cooked after being unpickled.
43+
*
44+
* It currently still throws away Java sources by overriding
45+
* `discardAfterTyper`.
46+
*/
47+
private class DocFrontEnd extends FrontEnd {
48+
override protected def discardAfterTyper(unit: CompilationUnit)(implicit ctx: Context) =
49+
unit.isJava
4350

44-
override protected def transformPhases: List[List[Phase]] =
45-
List(new CookComments) ::
46-
List(new DocImplicitsPhase) ::
47-
List(new DocASTPhase) ::
48-
List(DocMiniTransformations(new UsecasePhase,
49-
new DocstringPhase)) ::
50-
List(DocMiniTransformations(new PackageObjectsPhase,
51-
new LinkReturnTypes,
52-
new LinkParamListTypes,
53-
new LinkImplicitlyAddedTypes,
54-
new LinkSuperTypes,
55-
new LinkCompanions,
56-
new AlternateConstructors,
57-
new SortMembers)) ::
58-
List(DocMiniTransformations(new RemoveEmptyPackages)) ::
59-
Nil
60-
61-
override protected def backendPhases: List[List[Phase]] =
62-
List(new StatisticsPhase) :: Nil
51+
override def isRunnable(implicit ctx: Context): Boolean =
52+
super.isRunnable && !ctx.settings.fromTasty.value
53+
}
6354

55+
override def phases: List[List[Phase]] = List(
56+
List(new DocFrontEnd),
57+
List(new ReadTastyTreesFromClasses),
58+
List(new CookComments),
59+
List(new DocImplicitsPhase),
60+
List(new DocASTPhase),
61+
List(DocMiniTransformations(
62+
new UsecasePhase,
63+
new DocstringPhase)),
64+
List(DocMiniTransformations(
65+
new PackageObjectsPhase,
66+
new LinkReturnTypes,
67+
new LinkParamListTypes,
68+
new LinkImplicitlyAddedTypes,
69+
new LinkSuperTypes,
70+
new LinkCompanions,
71+
new AlternateConstructors,
72+
new SortMembers)),
73+
List(DocMiniTransformations(
74+
new RemoveEmptyPackages)),
75+
List(new StatisticsPhase)
76+
)
6477
}

‎doc-tool/src/dotty/tools/dottydoc/DocFrontEnd.scala‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎doc-tool/src/dotty/tools/dottydoc/core/transform.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object transform {
4444
* -------------------------
4545
* To delete a node in the AST, simply return an empty list from transforming method
4646
*/
47-
trait DocMiniTransformations extends Phase {
47+
abstractclass DocMiniTransformations extends Phase {
4848
def transformations: List[DocMiniPhase]
4949

5050
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /