@@ -7,48 +7,48 @@ previous-page: arch-intro
7
7
next-page : arch-phases
8
8
---
9
9
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,
11
11
first by verifying its input is a valid Scala program, and then transforming it into a
12
12
representation that can run on one of Scala's target platforms.
13
13
14
14
## Introducing the Compiler's Lifecycle
15
15
16
16
#### 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 ] .
19
19
A run is a complete iteration of the compiler's phases over a list of input sources.
20
20
A compiler is designed to be reusable and can create many runs over its lifetime.
21
21
22
22
#### 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
24
24
compiler state associated with each input source); then iteratively: a single phase is applied to
25
25
every compilation unit before progressing to the next phase.
26
26
27
27
#### Phases
28
28
A phase is an abstract transformation over a compilation unit, it is usually responsible
29
29
for transforming the trees and types representing the code of a source file. Some phases of
30
- the compiler include
30
+ the compiler include:
31
31
- ` parser ` , which converts text that matches Scala's
32
- [ syntax] [ 10 ] into abstract syntax trees, ASTs
32
+ [ syntax] into abstract syntax trees, ASTs
33
33
- ` typer ` , which checks that trees conform to expected types
34
34
- ` erasure ` , which retypes a more simplified program into one that has the same types as the JVM.
35
35
- ` genBCode ` , the JVM backend, which converts erased compiler trees into Java bytecode format.
36
36
37
- [ You can read more about phases here] [ 9 ] .
37
+ [ You can read more about phases here] [ phase-categories ] .
38
38
39
39
#### Drivers
40
40
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
43
43
configuring the compiler and invoking it programatically. The object [ Main] inherits from ` Driver `
44
44
and is invoked by the ` scalac ` script.
45
45
46
46
<!-- #### Further Reading -->
47
- > [ Read more about a compiler's lifecyle] [ 6 ] .
47
+ > [ Read more about a compiler's lifecyle] [ time ] .
48
48
49
49
## Code Structure
50
50
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] ,
52
52
containing the following sub-packages:
53
53
``` scala
54
54
tools // contains helpers and the `scala` generic runner
@@ -82,18 +82,16 @@ tools // contains helpers and the `scala` generic runner
82
82
└── scripting // scala runner for the -script argument
83
83
```
84
84
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 %}
95
93
[ Main ] : https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Main.scala
96
94
[ Driver ] : https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Driver.scala
97
95
[ Compiler ] : https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/Compiler.scala
98
96
[ 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 %}
0 commit comments