Compiler
Compiler
Source code
Source code
Source
File Source code
Source code
.NET
Assembly
Class
Field
public Foo
private
string
X
Language
Object Model Read-Eval-Print Loop
Hosting in
other contexts DSL Embedding
• Includes:− Managed compilers + language services
− Code analysis APIs
− Language service extensibility
− Read-Eval-Print-Loop (REPL)
Symbol Table
Binder IL
Emitter Parser
Metadata
Import
Compiler
Pipeline
Symbol
Table Binder
IL
Emitter Parser
Metadata
Import
Compiler
Pipeline
Compiler
API
Binding & Flow
Analysis APIs
Symbol
API
Syntax
Tree API
Emit
API
Compiler
Pipeline Binding & Flow
Analysis APIs
Symbol
API
Syntax
Tree API
Emit
API
Language
Service
CompilationUnit
TypeDeclaration
MethodDeclaration
class C { void M() { } }// C ▫
ParameterList Block
CompilationUnit
TypeDeclaration
class C { MethodDeclaration }
EOF
void M
class C { void M() { } }// C ▫
ParameterList Block
( ) { }
CompilationUnit
TypeDeclaration
class C { MethodDeclaration }
EOF
void M ParameterList Block
( )
{ }
SP EOL EOL // C
SPx4 SP
EOL
EOL
EOL SPx4 EOL SPx4
class∙C { ∙∙∙∙void∙M() ∙∙∙∙{ ∙∙∙∙} } // C ▫
CompilationUnit
TypeDeclaration
class C { MethodDeclaration }
EOF
void M
class C { void M() { } }// C ▫
ParameterList Block
( ) { }
CompilationUnit
TypeDeclaration
class C { MethodDeclaration }
EOF
void M ParameterList Block
( ) { }
class C { void M(int x) { } }// C ▫
CompilationUnit
TypeDeclaration
class C { MethodDeclaration }
EOF
void M
class C { void M(int x) { } }// C ▫
ParameterList Block
( ) { } Parameter
int
x PredefinedType
CompilationUnit
TypeDeclaration
class C { MethodDeclaration }
EOF
void M
class C { void M(int x) { } }// C ▫
ParameterList Block
( ) { } Parameter
int
x PredefinedType
Trees
References
Compilation
• Symbols
• Binding
• Flow Analysis
• Diagnostics
• Emit