Skip to content

Commit 90f8ed4

Browse files
committed
Move AST files into a package
1 parent 35b7815 commit 90f8ed4

144 files changed

Lines changed: 7189 additions & 6846 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/include/dmd/declaration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace dmd
4848
bool isVirtual(const FuncDeclaration * const fd);
4949
}
5050

51-
//enum STC : ulong from astenums.d:
51+
//enum STC : ulong from ast/enums.d:
5252

5353
#define STCundefined 0ULL
5454

compiler/src/.dscanner.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ unused_result="disabled"
119119
trust_too_much="-dmd.root.longdouble"
120120
builtin_property_names_check="-dmd.backend.obj,-dmd.backend.code,-dmd.backend.cc"
121121
object_const_check="-dmd.dtemplate"
122-
enum_array_literal_check="-dmd.astbase,-dmd.backend.oper,-dmd.backend.oper,-dmd.backend.var,-dmd.tokens,-dmd.expression"
122+
enum_array_literal_check="-dmd.ast.base,-dmd.backend.oper,-dmd.backend.oper,-dmd.backend.var,-dmd.tokens,-dmd.ast.expression"
123123
unused_variable_check="-dmd.backend.aarray,\
124124
-dmd.backend.blockopt,\
125125
-dmd.backend.cg,\

compiler/src/build.d

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ alias html = makeRule!((htmlBuilder, htmlRule) {
962962
}
963963
const stddocs = env.get("STDDOC", "").split();
964964
auto docSources = .sources.common ~ .sources.root ~ .sources.lexer ~ .sources.dmd.all
965-
~ env["D"].buildPath("astbase.d")
965+
~ env["D"].buildPath("ast/base.d")
966966
~ env["D"].buildPath("cxxfrontend.d")
967967
~ env["D"].buildPath("frontend.d");
968968
htmlBuilder.deps(docSources.chunks(1).map!(sourceArray =>
@@ -1574,24 +1574,29 @@ auto sourceFiles()
15741574
link.d mars.d main.d sarif.d lib/scanelf.d lib/scanmach.d lib/scanmscoff.d timetrace.d vsoptions.d
15751575
"),
15761576
frontend: fileArray(env["D"], "
1577-
access.d aggregate.d aliasthis.d argtypes_x86.d argtypes_sysv_x64.d argtypes_aarch64.d arrayop.d
1578-
arraytypes.d astenums.d ast_node.d astcodegen.d asttypename.d attrib.d attribsem.d blockexit.d builtin.d canthrow.d chkformat.d
1579-
cli.d clone.d compiler.d cond.d constfold.d cpreprocess.d ctfeexpr.d
1580-
ctorflow.d dcast.d dclass.d declaration.d delegatize.d denum.d deps.d dimport.d
1581-
dinterpret.d dmacro.d dmodule.d doc.d dscope.d dstruct.d dsymbol.d dsymbolsem.d
1582-
dtemplate.d dtoh.d dversion.d enumsem.d escape.d expression.d expressionsem.d func.d funcsem.d hdrgen.d
1583-
impcnvtab.d imphint.d importc.d init.d initsem.d inline.d inlinecost.d intrange.d json.d lambdacomp.d
1584-
mtype.d mustuse.d nogc.d nspace.d ob.d objc.d opover.d optimize.d
1585-
parse.d pragmasem.d printast.d rootobject.d safe.d
1586-
semantic2.d semantic3.d sideeffect.d statement.d
1587-
statementsem.d staticassert.d staticcond.d stmtstate.d target.d targetcompiler.d templatesem.d templateparamsem.d traits.d
1577+
access.d argtypes_x86.d argtypes_sysv_x64.d argtypes_aarch64.d arrayop.d
1578+
arraytypes.d attribsem.d blockexit.d builtin.d canthrow.d chkformat.d
1579+
cli.d clone.d compiler.d constfold.d cpreprocess.d ctfeexpr.d
1580+
ctorflow.d dcast.d delegatize.d deps.d
1581+
dinterpret.d dmacro.d doc.d dscope.d dsymbolsem.d
1582+
dtoh.d enumsem.d escape.d expressionsem.d funcsem.d hdrgen.d
1583+
impcnvtab.d imphint.d importc.d initsem.d inline.d inlinecost.d intrange.d json.d lambdacomp.d
1584+
mustuse.d nogc.d ob.d objc.d opover.d optimize.d
1585+
parse.d pragmasem.d rootobject.d safe.d
1586+
semantic2.d semantic3.d sideeffect.d
1587+
statementsem.d stmtstate.d target.d targetcompiler.d templatesem.d templateparamsem.d traits.d
15881588
typesem.d typinf.d utils.d
1589+
ast/aggregate.d ast/aliasthis.d ast/codegen.d ast/attrib.d ast/cond.d ast/dclass.d ast/declaration.d
1590+
ast/denum.d ast/dimport.d ast/dmodule.d ast/dstruct.d ast/dsymbol.d ast/dtemplate.d ast/dversion.d ast/enums.d
1591+
ast/expression.d ast/func.d ast/init.d ast/mtype.d ast/node.d ast/nspace.d ast/print.d ast/statement.d
1592+
ast/staticassert.d ast/staticcond.d ast/typename.d
1593+
dfa/entry.d dfa/utils.d dfa/fast/structure.d dfa/fast/analysis.d dfa/fast/report.d dfa/fast/expression.d dfa/fast/statement.d
15891594
iasm/package.d iasm/gcc.d
15901595
mangle/package.d mangle/basic.d mangle/cpp.d mangle/cppwin.d
15911596
visitor/package.d visitor/foreachvar.d visitor/parsetime.d visitor/permissive.d visitor/postorder.d visitor/statement_rewrite_walker.d
15921597
visitor/strict.d visitor/transitive.d
15931598
cparse.d
1594-
dfa/entry.d dfa/utils.d dfa/fast/structure.d dfa/fast/analysis.d dfa/fast/report.d dfa/fast/expression.d dfa/fast/statement.d
1599+
15951600
"),
15961601
backendHeaders: fileArray(env["C"], "
15971602
cc.d cdef.d cgcv.d code.d dt.d el.d global.d

compiler/src/dmd/README.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,40 +62,38 @@ Note that these groups have no strict meaning, the category assignments are a bi
6262

6363
### Semantic analysis
6464

65-
**Symbols and declarations**
65+
**AST Nodes, Symbols and declarations**
6666

6767
| File | Purpose |
6868
|---------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
69-
| [dsymbol.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dsymbol.d) | Base class for a D symbol, e.g. a variable, function, module, enum etc. |
69+
| [dsymbol.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dsymbol.d) | Base class for a D symbol, e.g. a variable, function, module, enum etc. |
7070
| [identifier.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/identifier.d) | Represents the name of a `Dsymbol` |
7171
| [id.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/id.d) | Define strings for pre-defined identifiers (e.g. `sizeof`, `string`) |
72-
| [dscope.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dscope.d) | Define a 'scope' on which symbol lookup can be performed |
73-
| [dtemplate.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dtemplate.d) | A template declaration or instance |
74-
| [dmodule.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dmodule.d) | Define a package and module |
75-
| [mtype.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mtype.d) | Define expression types such as `int`, `char[]`, `void function()` |
72+
| [dscope.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dscope.d) | Define a 'scope' on which symbol lookup can be performed |
73+
| [dtemplate.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dtemplate.d) | A template declaration or instance |
74+
| [dmodule.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dmodule.d) | Define a package and module |
75+
| [mtype.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/mtype.d) | Define expression types such as `int`, `char[]`, `void function()` |
7676
| [arraytypes.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/arraytypes.d) | For certain Declaration nodes of type `T`, provides aliases for `Array!T` |
77-
| [declaration.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/declaration.d) | Misc. declarations of `alias`, variables, type tuples, `ClassInfo` etc. |
78-
| [denum.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/denum.d) | Defines `enum` declarations and enum members |
77+
| [declaration.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/declaration.d) | Misc. declarations of `alias`, variables, type tuples, `ClassInfo` etc. |
78+
| [denum.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/denum.d) | Defines `enum` declarations and enum members |
7979
| [attrib.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/nogc.d) | Declarations of 'attributes' such as `private`, `pragma()`, `immutable`, `@UDA`, `align`, `extern(C++)` and more |
80-
| [func.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/func.d) | Define a function declaration (includes function literals, `invariant`, `unittest`) |
81-
| [dversion.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dversion.d) | Defines a version symbol, e.g. `version = ident`, `debug = ident` |
82-
83-
**AST nodes**
84-
85-
| File | Purpose |
86-
|-----------------------------------------------------------------------------------|-------------------------------------------------------------|
87-
| [ast_node.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast_node.d) | Define an abstract AST node class |
88-
| [astbase.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/astbase.d) | Namespace of AST nodes that can be produced by the parser |
89-
| [astcodegen.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/astcodegen.d) | Namespace of AST nodes of a AST ready for code generation |
90-
| [astenums.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/astenums.d) | Enums common to DMD and AST |
91-
| [expression.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/expression.d) | Define expression AST nodes |
80+
| [func.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/func.d) | Define a function declaration (includes function literals, `invariant`, `unittest`) |
81+
| [dversion.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dversion.d) | Defines a version symbol, e.g. `version = ident`, `debug = ident` |
82+
| [node.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/node.d) | Define an abstract AST node class |
83+
| [base.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/base.d) | Namespace of AST nodes that can be produced by the parser |
84+
| [codegen.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/codegen.d) | Namespace of AST nodes of a AST ready for code generation |
85+
| [enums.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/enums.d) | Enums common to DMD and AST |
86+
| [cond.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/cond.d) | AST nodes for `static if`, `version` `debug ` |
87+
| [expression.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/expression.d) | Define expression AST nodes |
9288
| [rootobject.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/rootobject.d) | Define an abstract root class |
93-
| [statement.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/statement.d) | Define statement AST nodes |
94-
| [staticassert.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/staticassert.d) | Define a `static assert` AST node |
95-
| [aggregate.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/aggregate.d) | Define an aggregate (`struct`, `union` or `class`) AST node |
96-
| [dclass.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dclass.d) | Define a `class` AST node |
97-
| [dstruct.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dstruct.d) | Define a `struct` or `union` AST node |
98-
| [init.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/init.d) | Define variable initializers |
89+
| [dimport.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dimport.d) | Renamed imports (`import aliasSymbol = pkg1.pkg2.symbol`) |
90+
| [nspace.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/nspace.d) | Namespace for `extern (C++, Module)` |
91+
| [statement.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/statement.d) | Define statement AST nodes |
92+
| [staticassert.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/staticassert.d) | Define a `static assert` AST node |
93+
| [aggregate.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/aggregate.d) | Define an aggregate (`struct`, `union` or `class`) AST node |
94+
| [dclass.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dclass.d) | Define a `class` AST node |
95+
| [dstruct.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/dstruct.d) | Define a `struct` or `union` AST node |
96+
| [init.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/init.d) | Define variable initializers |
9997

10098
**AST visitors**
10199

@@ -184,12 +182,9 @@ Note that these groups have no strict meaning, the category assignments are a bi
184182
| [aliasthis.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/aliasthis.d) | Resolve implicit conversions for `alias X this` |
185183
| [traits.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/traits.d) | `__traits()` |
186184
| [lambdacomp.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/lambdacomp.d) | `__traits(isSame, x => y, z => w)` |
187-
| [cond.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cond.d) | Evaluate `static if`, `version` `debug ` |
188185
| [staticcond.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/staticcond.d) | Lazily evaluate static conditions for `static if`, `static assert` and template constraints |
189186
| [delegatize.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/delegatize.d) | Converts expression to delegates for `lazy` parameters |
190-
| [nspace.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/nspace.d) | Namespace for `extern (C++, Module)` |
191187
| [intrange.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/intrange.d) | [Value range propagation](https://digitalmars.com/articles/b62.html) |
192-
| [dimport.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dimport.d) | Renamed imports (`import aliasSymbol = pkg1.pkg2.symbol`) |
193188
| [arrayop.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/arrayop.d) | Array operations (`a[] = b[] + c[]`) |
194189
| [cpreprocess.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cpreprocess.d)| Run the C preprocessor on C source files |
195190
| [typinf.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/typinf.d) | Generate typeinfo for `typeid()` (as well as internals) |
@@ -273,5 +268,5 @@ Note: many other utilities are in [dmd/root](https://github.com/dlang/dmd/tree/m
273268

274269
| File | Purpose |
275270
|---------------------------------------------------------------------------------|---------------------------------------------------------------|
276-
| [asttypename.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/asttypename.d) | Print the internal name of an AST node (for debugging only) |
271+
| [asttypename.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ast/typename.d) | Print the internal name of an AST node (for debugging only) |
277272
| [printast.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/printast.d) | Print the AST data structure |

compiler/src/dmd/access.d

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313

1414
module dmd.access;
1515

16-
import dmd.aggregate;
17-
import dmd.astenums;
18-
import dmd.dclass;
19-
import dmd.dmodule;
16+
import dmd.ast.aggregate;
17+
import dmd.ast.enums;
18+
import dmd.ast.dclass;
19+
import dmd.ast.dmodule;
20+
import dmd.ast.dstruct;
21+
import dmd.ast.dsymbol;
22+
import dmd.ast.expression;
23+
2024
import dmd.dscope;
21-
import dmd.dstruct;
22-
import dmd.dsymbol;
2325
import dmd.dsymbolsem : toAlias;
2426
import dmd.errors;
25-
import dmd.expression;
2627
import dmd.funcsem : overloadApply;
2728
import dmd.location;
2829
import dmd.tokens;

compiler/src/dmd/argtypes_aarch64.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
module dmd.argtypes_aarch64;
1313

14+
import dmd.ast.enums;
15+
import dmd.ast.mtype;
16+
1417
import core.stdc.stdio;
15-
import dmd.astenums;
1618
import dmd.dsymbolsem : isPOD;
17-
import dmd.mtype;
1819
import dmd.typesem;
1920
import dmd.expressionsem : toUInteger;
2021

compiler/src/dmd/argtypes_sysv_x64.d

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
module dmd.argtypes_sysv_x64;
1313

1414
import core.stdc.stdio;
15-
import dmd.astenums;
16-
import dmd.declaration;
15+
16+
import dmd.ast.enums;
17+
import dmd.ast.declaration;
18+
import dmd.ast.mtype;
19+
1720
import dmd.dsymbolsem : isPOD;
18-
import dmd.mtype;
1921
import dmd.typesem;
2022
import dmd.expressionsem : toInteger;
2123
import dmd.target;

compiler/src/dmd/argtypes_x86.d

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ module dmd.argtypes_x86;
1414
import core.stdc.stdio;
1515
import core.checkedint;
1616

17-
import dmd.astenums;
18-
import dmd.declaration;
17+
import dmd.ast.enums;
18+
import dmd.ast.declaration;
19+
import dmd.ast.mtype;
20+
1921
import dmd.dsymbolsem : isPOD;
2022
import dmd.expressionsem : toInteger;
2123
import dmd.location;
22-
import dmd.mtype;
2324
import dmd.typesem;
2425
import dmd.target;
2526
import dmd.visitor;

compiler/src/dmd/arrayop.d

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@
1414
module dmd.arrayop;
1515

1616
import core.stdc.stdio;
17+
18+
import dmd.ast.enums;
19+
import dmd.ast.declaration;
20+
import dmd.ast.expression;
21+
import dmd.ast.mtype;
22+
1723
import dmd.arraytypes;
18-
import dmd.astenums;
1924
import dmd.dcast : implicitConvTo;
20-
import dmd.declaration;
2125
import dmd.dscope;
2226
import dmd.errors;
23-
import dmd.expression;
2427
import dmd.expressionsem;
2528
import dmd.funcsem;
2629
import dmd.hdrgen;
2730
import dmd.id;
2831
import dmd.identifier;
2932
import dmd.location;
30-
import dmd.mtype;
3133
import dmd.common.outbuffer;
3234
import dmd.tokens;
3335
import dmd.typesem : isAssignable, nextOf, toBasetype;
@@ -132,7 +134,7 @@ Expression arrayOp(BinExp e, Scope* sc)
132134
auto tiargs = new Objects();
133135
auto args = buildArrayOp(sc, e, tiargs);
134136

135-
import dmd.dtemplate : TemplateDeclaration;
137+
import dmd.ast.dtemplate : TemplateDeclaration;
136138
__gshared TemplateDeclaration arrayOp;
137139
if (arrayOp is null)
138140
{

0 commit comments

Comments
 (0)