This is the source code to the DMD compiler
for the D Programming Language defined in the documents at
https://dlang.org/
These sources are free, they are redistributable and modifiable
under the terms of the Boost Software License, Version 1.0.
The terms of this license are in the file boostlicense.txt,
or see https://www.boost.org/LICENSE_1_0.txt.
If a particular file has a different license in it, that overrides
this license for that file.
-Walter Bright
DMD has a mostly flat directory structure, so this section aims to divide all source files into logical groups for easier navigation.
The groups are roughly ordered by how late they appear in the compilation process.
Note that these groups have no strict meaning, the category assignments are a bit subjective.
File |
Purpose |
mars.d |
The entry point. Contains main . |
cli.d |
Define the command line interface |
dmdparams.d |
DMD-specific parameters |
globals.d |
Define a structure storing command line options |
dinifile.d |
Parse settings from .ini file (sc.ini / dmd.conf ) |
vsoptions.d |
Detect the Microsoft Visual Studio toolchain for linking |
frontend.d |
An interface for using DMD as a library |
errors.d |
Error reporting implementation |
errorsink.d |
Error reporting interface |
target.d |
Manage target-specific parameters for cross-compiling (for LDC/GDC) |
compiler.d |
Describe a back-end compiler and implements compiler-specific actions |
File |
Purpose |
lexer.d |
Convert source code into tokens for the D and ImportC parsers |
location.d |
Encapsulate file/line/column info for error messages, etc. |
entity.d |
Define "\&Entity;" escape sequence for strings / character literals |
tokens.d |
Define lexical tokens. |
parse.d |
D parser, converting tokens into an Abstract Syntax Tree (AST) |
cparse.d |
ImportC parser, converting tokens into an Abstract Syntax Tree (AST) |
Symbols and declarations
File |
Purpose |
dsymbol.d |
Base class for a D symbol, e.g. a variable, function, module, enum etc. |
identifier.d |
Represents the name of a Dsymbol |
id.d |
Define strings for pre-defined identifiers (e.g. sizeof , string ) |
dscope.d |
Define a 'scope' on which symbol lookup can be performed |
dtemplate.d |
A template declaration or instance |
dmodule.d |
Define a package and module |
mtype.d |
Define expression types such as int , char[] , void function() |
arraytypes.d |
For certain Declaration nodes of type T , provides aliases for Array!T |
declaration.d |
Misc. declarations of alias , variables, type tuples, ClassInfo etc. |
denum.d |
Defines enum declarations and enum members |
attrib.d |
Declarations of 'attributes' such as private , pragma() , immutable , @UDA , align , extern(C++) and more |
func.d |
Define a function declaration (includes function literals, invariant , unittest ) |
dversion.d |
Defines a version symbol, e.g. version = ident , debug = ident |
AST nodes
AST visitors
Semantic passes
Semantic helpers
File |
Purpose |
opover.d |
Operator overloading |
clone.d |
Generate automatic opEquals , opAssign and constructors for structs |
blockexit.d |
Find out in what ways control flow can exit a block |
ctorflow.d |
Control flow in constructors |
constfold.d |
Do constant folding of arithmetic expressions |
optimize.d |
Do constant folding more generally |
dcast.d |
Implicit or explicit cast(), finding common types e.g. in x ? a : b , integral promotions |
impcnvtab.d |
Define an implicit conversion table for basic types |
importc.d |
Helpers specific to ImportC |
sideeffect.d |
Extract side-effects of expressions for certain lowerings. |
mustuse.d |
Helpers related to the @mustuse attribute |
Compile Time Function Execution (CTFE)
File |
Purpose |
dinterpret.d |
CTFE entry point |
ctfeexpr.d |
CTFE for expressions involving pointers, slices, array concatenation etc. |
builtin.d |
Allow CTFE of certain external functions (core.math , std.math and core.bitop ) |
Attribute checks
Inline Assembly
File |
Purpose |
iasm.d |
Inline assembly depending on the compiler |
iasmdmd.d |
Inline assembly for DMD |
iasmgcc.d |
Inline assembly for GDC |
Other
File |
Purpose |
chkformat.d |
Validate arguments with format specifiers for printf / scanf etc. |
imphint.d |
Give a suggestion to e.g. import std.stdio when writeln could not be resolved. |
File |
Purpose |
lib.d |
Abstract library class |
libelf.d |
Library in ELF format (Unix) |
libmach.d |
Library in Mach-O format (macOS) |
libmscoff.d |
Library in COFF format (32/64-bit Windows) |
libomf.d |
Library in OMF format (legacy 32-bit Windows) |
scanelf.d |
Extract symbol names from a library in ELF format |
scanmach.d |
Extract symbol names from a library in Mach-O format |
scanmscoff.d |
Extract symbol names from a library in COFF format |
scanomf.d |
Extract symbol names from a library in OMF format |
File |
Purpose |
dmsc.d |
Configures and initializes the back-end |
toobj.d |
Convert an AST that went through all semantic phases into an object file |
toir.d |
Convert Dsymbols intermediate representation |
e2ir.d |
Convert Expressions to intermediate representation |
s2ir.d |
Convert Statements to intermediate representation |
stmtstate.d |
Used to help transform statement AST into flow graph |
toctype.d |
Convert a D type to a type the back-end understands |
tocsym.d |
Convert a D symbol to a symbol the linker understands (with mangled name) |
argtypes_x86.d |
Convert a D type into simple (register) types for the 32-bit x86 ABI |
argtypes_sysv_x64.d |
'argtypes' for the x86_64 System V ABI |
argtypes_aarch64.d |
'argtypes' for the AArch64 ABI |
glue.d |
Generate the object file for function declarations |
gluelayer.d |
Declarations for back-end functions that the front-end invokes |
todt.d |
Convert initializers into structures that the back-end will add to the data segment |
tocvdebug.d |
Generate debug info in the CV4 debug format. |
objc.d |
Objective-C interfacing |
objc_glue.d |
Glue code for Objective-C interop. |
Name mangling
File |
Purpose |
link.d |
Invoke the linker as a separate process |
File |
Purpose |
doc.d |
Documentation generation |
dmacro.d |
DDoc macro processing |
hdrgen.d |
Convert an AST into D source code for .di header generation, as well as -vcg-ast and error messages |
json.d |
Describe the module in a .json file for the -X flag |
dtoh.d |
C++ header generation from D source files |
Note: many other utilities are in dmd/root.
File |
Purpose |
console.d |
Print error messages in color |
file_manager.d |
Keep file contents in memory |
utils.d |
Utility functions related to files and file paths |
File |
Purpose |
asttypename.d |
Print the internal name of an AST node (for debugging only) |
printast.d |
Print the AST data structure |
foreachvar.d |
Used in ob.d to iterate over all variables in an expression |