Skip to content

Commit 08e7e33

Browse files
committed
adjust links
1 parent 009d52c commit 08e7e33

File tree

4 files changed

+36
-35
lines changed

4 files changed

+36
-35
lines changed

_overviews/scala3-contribution/arch-lifecycle.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,48 @@ previous-page: arch-intro
77
next-page: arch-phases
88
---
99

10-
As mentioned in [what is a compiler?][1] `dotc` produces programs that can run on your machine,
10+
As mentioned in [what is a compiler?][whats-a-compiler] `dotc` produces programs that can run on your machine,
1111
first by verifying its input is a valid Scala program, and then transforming it into a
1212
representation that can run on one of Scala's target platforms.
1313

1414
## Introducing the Compiler's Lifecycle
1515

1616
#### Core
17-
At a high level, `dotc` centers its work around a [Compiler][4], which maintains an ordered
18-
list of [phases][3], and is responsible for creating new [runs][2].
17+
At a high level, `dotc` centers its work around a [Compiler], which maintains an ordered
18+
list of [phases][Phases], and is responsible for creating new [runs][Run].
1919
A run is a complete iteration of the compiler's phases over a list of input sources.
2020
A compiler is designed to be reusable and can create many runs over its lifetime.
2121

2222
#### Runs
23-
During a run, the input sources are converted to [compilation units][5] (i.e. the abstraction of
23+
During a run, the input sources are converted to [compilation units][CompilationUnit] (i.e. the abstraction of
2424
compiler state associated with each input source); then iteratively: a single phase is applied to
2525
every compilation unit before progressing to the next phase.
2626

2727
#### Phases
2828
A phase is an abstract transformation over a compilation unit, it is usually responsible
2929
for transforming the trees and types representing the code of a source file. Some phases of
30-
the compiler include
30+
the compiler include:
3131
- `parser`, which converts text that matches Scala's
32-
[syntax][10] into abstract syntax trees, ASTs
32+
[syntax] into abstract syntax trees, ASTs
3333
- `typer`, which checks that trees conform to expected types
3434
- `erasure`, which retypes a more simplified program into one that has the same types as the JVM.
3535
- `genBCode`, the JVM backend, which converts erased compiler trees into Java bytecode format.
3636

37-
[You can read more about phases here][9].
37+
[You can read more about phases here][phase-categories].
3838

3939
#### Drivers
4040

41-
The core compiler also requires a lot of state to be initialised before use, such as [settings][8]
42-
and the [Context]. For convenience, the [Driver] class contains high level functions for
41+
The core compiler also requires a lot of state to be initialised before use, such as [settings][ScalaSettings]
42+
and the [Context][contexts]. For convenience, the [Driver] class contains high level functions for
4343
configuring the compiler and invoking it programatically. The object [Main] inherits from `Driver`
4444
and is invoked by the `scalac` script.
4545

4646
<!-- #### Further Reading -->
47-
> [Read more about a compiler's lifecyle][6].
47+
> [Read more about a compiler's lifecyle][time].
4848
4949
## Code Structure
5050

51-
The code of the compiler is found in the package [dotty.tools][7],
51+
The code of the compiler is found in the package [dotty.tools],
5252
containing the following sub-packages:
5353
```scala
5454
tools // contains helpers and the `scala` generic runner
@@ -82,18 +82,16 @@ tools // contains helpers and the `scala` generic runner
8282
└── scripting // scala runner for the -script argument
8383
```
8484

85-
[1]: {% link _overviews/scala3-contribution/contribution-intro.md %}#what-is-a-compiler
86-
[2]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Run.scala
87-
[3]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/Phases.scala
88-
[4]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Compiler.scala
89-
[5]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/CompilationUnit.scala
90-
[6]: {% link _overviews/scala3-contribution/arch-time.md %}
91-
[7]: https://github.com/lampepfl/dotty/tree/master/compiler/src/dotty/tools
92-
[8]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
93-
[9]: {% link _overviews/scala3-contribution/arch-phases.md %}
94-
[10]: {% link _scala3-reference/syntax.md %}
85+
[whats-a-compiler]: {% link _overviews/scala3-contribution/contribution-intro.md %}#what-is-a-compiler
86+
[Phases]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/Phases.scala
87+
[CompilationUnit]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/CompilationUnit.scala
88+
[time]: {% link _overviews/scala3-contribution/arch-time.md %}
89+
[dotty.tools]: https://github.com/lampepfl/dotty/tree/master/compiler/src/dotty/tools
90+
[ScalaSettings]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
91+
[phase-categories]: {% link _overviews/scala3-contribution/arch-phases.md %}#phase-categories
92+
[syntax]: {% link _scala3-reference/syntax.md %}
9593
[Main]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Main.scala
9694
[Driver]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Driver.scala
9795
[Compiler]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Compiler.scala
9896
[Run]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Run.scala
99-
[Context]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/Contexts.scala
97+
[contexts]: {% link _overviews/scala3-contribution/arch-context.md %}

_overviews/scala3-contribution/arch-phases.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ previous-page: arch-lifecycle
77
next-page: arch-types
88
---
99

10-
As described in the [compiler overview][1], `dotc` is divided into a list of [phases][Phase],
10+
As described in the [compiler overview][lifecycle], `dotc` is divided into a list of [phases][Phase],
1111
specified in the [Compiler] class.
1212

1313
#### Printing the phases of the Compiler
@@ -52,7 +52,7 @@ In particular, it
5252
- creates super accessors representing `super` calls in traits
5353
- creates implementations of compiler-implemented methods,
5454
such as `equals` and `hashCode` for case classes.
55-
- marks [compilation units][2] that require inline expansion, or quote pickling
55+
- marks [compilation units][CompilationUnit] that require inline expansion, or quote pickling
5656
- simplifies trees of erased definitions
5757
- checks variance of type parameters
5858
- mark parameters passed unchanged from subclass to superclass for later pruning.
@@ -72,6 +72,9 @@ suitable for the runtime system, with two sub-groupings:
7272
- High-level transformations: All phases from [firstTransform] to [erasure].
7373
Most of these phases transform syntax trees, expanding high-level constructs
7474
to more primitive ones.
75+
- An important transform phase is [patternMatcher], which converts match
76+
trees and patterns into lower level forms, as well as checking the
77+
exhaustivity of sealed types, and unreachability of pattern cases.
7578
- Some phases perform further checks on more primitive trees,
7679
e.g. [refchecks] verifies that no abstract methods exist in concrete classes,
7780
and [initChecker] checks that fields are not used before initialisation.
@@ -86,8 +89,8 @@ suitable for the runtime system, with two sub-groupings:
8689
### `backendPhases`
8790
These map the transformed trees to Java classfiles or SJSIR files.
8891

89-
[1]: {% link _overviews/scala3-contribution/arch-lifecycle.md %}#phases
90-
[2]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/CompilationUnit.scala
92+
[lifecycle]: {% link _overviews/scala3-contribution/arch-lifecycle.md %}#phases
93+
[CompilationUnit]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/CompilationUnit.scala
9194
[Compiler]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Compiler.scala
9295
[Phase]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/Phases.scala
9396
[MiniPhase]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/MegaPhase.scala
@@ -104,6 +107,7 @@ These map the transformed trees to Java classfiles or SJSIR files.
104107
[refchecks]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
105108
[initChecker]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/init/Checker.scala
106109
[firstTransform]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala
110+
[patternMatcher]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
107111
[erasure]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/Erasure.scala
108112
[Mirror]: https://github.com/lampepfl/dotty/blob/master/library/src/scala/deriving/Mirror.scala
109113
[PCP]: {% link _scala3-reference/metaprogramming/macros.md %}#the-phase-consistency-principle

_overviews/scala3-contribution/arch-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ defined in [Types.scala]. The `toString` method on `Type` will display types in
1414
format corresponding to the backing data structure, e.g. `ExprType(...)`
1515
corresponds to `class ExprType`, defined in [Types.scala].
1616

17-
> You can inspect the representation of any type using the [dotty.tools.printTypes][2]
18-
> script, its usage and integration into your debugging workflow is [described here][3].
17+
> You can inspect the representation of any type using the [dotty.tools.printTypes][DottyTypeStealer]
18+
> script, its usage and integration into your debugging workflow is [described here][inspecting-types].
1919
2020
### Types of Definitions
2121

@@ -148,5 +148,5 @@ Type -+- proxy_type --+- NamedType --------+- TypeRef
148148
```
149149

150150
[Types.scala]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/Types.scala
151-
[2]: https://github.com/lampepfl/dotty/blob/master/compiler/test/dotty/tools/DottyTypeStealer.scala
152-
[3]: {% link _overviews/scala3-contribution/procedures-inspection.md %}#inspecting-representation-of-types
151+
[DottyTypeStealer]: https://github.com/lampepfl/dotty/blob/master/compiler/test/dotty/tools/DottyTypeStealer.scala
152+
[inspecting-types]: {% link _overviews/scala3-contribution/procedures-inspection.md %}#inspecting-the-representation-of-types

_overviews/scala3-contribution/procedures-inspection.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ and so on.
9898

9999
## Inspecting The Representation of Types
100100

101-
> [click here][2] to learn more about types in `dotc`.
101+
> [learn more about types][types] in `dotc`.
102102
103103
If you are curious about the representation of a type, say `[T] =>> List[T]`,
104-
you can use a helper program [dotty.tools.printTypes][1],
104+
you can use a helper program [dotty.tools.printTypes][DottyTypeStealer],
105105
it prints the internal representation of types, along with their class. It can be
106106
invoked from the sbt shell with three arguments as follows:
107107
```bash
@@ -178,9 +178,8 @@ class StealBox:
178178
assert(empty.name.toString == "<empty>")
179179
```
180180

181-
[1]: https://github.com/lampepfl/dotty/blob/master/compiler/test/dotty/tools/DottyTypeStealer.scala
182-
[2]: {% link _overviews/scala3-contribution/arch-types.md %}
183-
[3]: {% link _overviews/scala3-contribution/arch-lifecycle.md %}#phases
181+
[DottyTypeStealer]: https://github.com/lampepfl/dotty/blob/master/compiler/test/dotty/tools/DottyTypeStealer.scala
182+
[types]: {% link _overviews/scala3-contribution/arch-types.md %}
184183
[ScalaSettings]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
185184
[symbols]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
186185
[reproduce]: {% link _overviews/scala3-contribution/procedures-reproduce.md %}#dotty-issue-workspace

0 commit comments

Comments
 (0)