Skip to content

Commit

Permalink
Move visitors into a package
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Sep 25, 2024
1 parent ff0d824 commit 52716cf
Show file tree
Hide file tree
Showing 24 changed files with 288 additions and 55 deletions.
8 changes: 5 additions & 3 deletions compiler/src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -1571,10 +1571,12 @@ auto sourceFiles()
dtemplate.d dtoh.d dversion.d enumsem.d escape.d expression.d expressionsem.d func.d funcsem.d hdrgen.d iasm.d iasmgcc.d
impcnvtab.d imphint.d importc.d init.d initsem.d inline.d inlinecost.d intrange.d json.d lambdacomp.d
mtype.d mustuse.d nogc.d nspace.d ob.d objc.d opover.d optimize.d
parse.d parsetimevisitor.d permissivevisitor.d postordervisitor.d pragmasem.d printast.d rootobject.d safe.d
semantic2.d semantic3.d sideeffect.d statement.d statement_rewrite_walker.d
parse.d pragmasem.d printast.d rootobject.d safe.d
semantic2.d semantic3.d sideeffect.d statement.d
statementsem.d staticassert.d staticcond.d stmtstate.d target.d templatesem.d templateparamsem.d traits.d
transitivevisitor.d typesem.d typinf.d utils.d visitor.d foreachvar.d
typesem.d typinf.d utils.d
visitor/package.d visitor/foreachvar.d visitor/parsetime.d visitor/permissive.d visitor/postorder.d visitor/statement_rewrite_walker.d
visitor/strict.d visitor/transitive.d
cparse.d
"),
backendHeaders: fileArray(env["C"], "
Expand Down
17 changes: 9 additions & 8 deletions compiler/src/dmd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ Note that these groups have no strict meaning, the category assignments are a bi

| File | Purpose |
|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [parsetimevisitor.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/parsetimevisitor.d) | General [visitor](https://en.wikipedia.org/wiki/Visitor_pattern) for AST nodes |
| [permissivevisitor.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/permissivevisitor.d) | Subclass of ParseTimeVisitor that does not `assert(0)` on unimplemented nodes |
| [strictvisitor.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/strictvisitor.d) | Visitor that forces derived classes to implement `visit` for every possible node |
| [visitor.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor.d) | A visitor implementing `visit` for all nodes present in the compiler |
| [transitivevisitor.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/transitivevisitor.d) | Provide a mixin template with visit methods for the parse time AST |
| [postordervisitor.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/postordervisitor.d) | Depth-first expression visitor |
| [statement_rewrite_walker.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/statement_rewrite_walker.d) | Statement visitor that allows replacing the currently visited node |
| [visitor/parsetime.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/parsetime.d) | General [visitor](https://en.wikipedia.org/wiki/Visitor_pattern) for AST nodes |
| [visitor/permissive.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/permissive.d) | Subclass of ParseTimeVisitor that does not `assert(0)` on unimplemented nodes |
| [visitor/strict.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/strict.d) | Visitor that forces derived classes to implement `visit` for every possible node |
| [visitor/package.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/package.d) | A visitor implementing `visit` for all nodes present in the compiler |
| [visitor/transitive.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/transitive.d) | Provide a mixin template with visit methods for the parse time AST |
| [visitor/postorder.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/postorder.d) | Depth-first expression & statement visitor |
| [visitor/statement_rewrite_walker.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/statement_rewrite_walker.d) | Statement visitor that allows replacing the currently visited node |
| [visitor/foreachvar.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/visitor/foreachvar.d) | Used in `ob.d` to iterate over all variables in an expression |

**Semantic passes**

Expand Down Expand Up @@ -269,4 +270,4 @@ Note: many other utilities are in [dmd/root](https://github.com/dlang/dmd/tree/m
|---------------------------------------------------------------------------------|---------------------------------------------------------------|
| [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) |
| [printast.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/printast.d) | Print the AST data structure |
| [foreachvar.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/foreachvar.d) | Used in `ob.d` to iterate over all variables in an expression |

2 changes: 1 addition & 1 deletion compiler/src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
module dmd.astbase;

import dmd.astenums;
import dmd.parsetimevisitor;
import dmd.visitor.parsetime;
import dmd.tokens : EXP;

/** The ASTBase family defines a family of AST nodes appropriate for parsing with
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/canthrow.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import dmd.func;
import dmd.globals;
import dmd.init;
import dmd.mtype;
import dmd.postordervisitor;
import dmd.tokens;
import dmd.visitor;
import dmd.visitor.postorder;

/**
* Status indicating what kind of throwable might be caused by an expression.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/delegatize.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import dmd.init;
import dmd.initsem;
import dmd.location;
import dmd.mtype;
import dmd.postordervisitor;
import dmd.statement;
import dmd.tokens;
import dmd.visitor;
import dmd.visitor.postorder;


/*********************************
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ import dmd.opover;
import dmd.optimize;
import dmd.parse;
import dmd.printast;
import dmd.postordervisitor;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.root.filename;
Expand All @@ -89,6 +88,7 @@ import dmd.typinf;
import dmd.utils;
import dmd.utils : arrayCastBigEndian;
import dmd.visitor;
import dmd.visitor.postorder;

enum LOGSEMANTIC = false;

Expand Down
Loading

0 comments on commit 52716cf

Please sign in to comment.