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 24, 2024
1 parent 6f1b331 commit c042e32
Show file tree
Hide file tree
Showing 21 changed files with 275 additions and 43 deletions.
5 changes: 3 additions & 2 deletions compiler/src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -1571,10 +1571,11 @@ 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
parse.d pragmasem.d printast.d rootobject.d safe.d
semantic2.d semantic3.d sideeffect.d statement.d statement_rewrite_walker.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/strict.d visitor/transitive.d
cparse.d
"),
backendHeaders: fileArray(env["C"], "
Expand Down
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
260 changes: 245 additions & 15 deletions compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -7485,21 +7485,6 @@ class Objc
virtual void checkTupleof(Expression* expression, TypeClass* type) const = 0;
};

template <typename AST>
class PermissiveVisitor : public ParseTimeVisitor<AST >
{
public:
typedef ParseTimeVisitor<AST > visit;
virtual void visit(typename AST::Dsymbol ) override;
virtual void visit(typename AST::Parameter ) override;
virtual void visit(typename AST::Statement ) override;
virtual void visit(typename AST::Type ) override;
virtual void visit(typename AST::Expression ) override;
virtual void visit(typename AST::TemplateParameter ) override;
virtual void visit(typename AST::Condition ) override;
virtual void visit(typename AST::Initializer ) override;
};

struct Target final
{
enum class OS : uint8_t
Expand Down Expand Up @@ -7811,6 +7796,251 @@ class SemanticTimeTransitiveVisitor : public SemanticTimePermissiveVisitor
void visit(LoweredAssignExp* e) override;
};

template <typename AST>
class PermissiveVisitor : public ParseTimeVisitor<AST >
{
public:
typedef ParseTimeVisitor<AST > visit;
virtual void visit(typename AST::Dsymbol ) override;
virtual void visit(typename AST::Parameter ) override;
virtual void visit(typename AST::Statement ) override;
virtual void visit(typename AST::Type ) override;
virtual void visit(typename AST::Expression ) override;
virtual void visit(typename AST::TemplateParameter ) override;
virtual void visit(typename AST::Condition ) override;
virtual void visit(typename AST::Initializer ) override;
};

template <typename AST>
class StrictVisitor : public ParseTimeVisitor<AST >
{
public:
typedef ParseTimeVisitor<AST > visit;
virtual void visit(typename AST::Dsymbol ) override;
virtual void visit(typename AST::AliasThis ) override;
virtual void visit(typename AST::Declaration ) override;
virtual void visit(typename AST::ScopeDsymbol ) override;
virtual void visit(typename AST::Import ) override;
virtual void visit(typename AST::AttribDeclaration ) override;
virtual void visit(typename AST::StaticAssert ) override;
virtual void visit(typename AST::DebugSymbol ) override;
virtual void visit(typename AST::VersionSymbol ) override;
virtual void visit(typename AST::VarDeclaration ) override;
virtual void visit(typename AST::FuncDeclaration ) override;
virtual void visit(typename AST::AliasDeclaration ) override;
virtual void visit(typename AST::AliasAssign ) override;
virtual void visit(typename AST::TupleDeclaration ) override;
virtual void visit(typename AST::FuncLiteralDeclaration ) override;
virtual void visit(typename AST::PostBlitDeclaration ) override;
virtual void visit(typename AST::CtorDeclaration ) override;
virtual void visit(typename AST::DtorDeclaration ) override;
virtual void visit(typename AST::InvariantDeclaration ) override;
virtual void visit(typename AST::UnitTestDeclaration ) override;
virtual void visit(typename AST::NewDeclaration ) override;
virtual void visit(typename AST::StaticCtorDeclaration ) override;
virtual void visit(typename AST::StaticDtorDeclaration ) override;
virtual void visit(typename AST::SharedStaticCtorDeclaration ) override;
virtual void visit(typename AST::SharedStaticDtorDeclaration ) override;
virtual void visit(typename AST::Package ) override;
virtual void visit(typename AST::EnumDeclaration ) override;
virtual void visit(typename AST::AggregateDeclaration ) override;
virtual void visit(typename AST::TemplateDeclaration ) override;
virtual void visit(typename AST::TemplateInstance ) override;
virtual void visit(typename AST::Nspace ) override;
virtual void visit(typename AST::MixinDeclaration ) override;
virtual void visit(typename AST::UserAttributeDeclaration ) override;
virtual void visit(typename AST::LinkDeclaration ) override;
virtual void visit(typename AST::AnonDeclaration ) override;
virtual void visit(typename AST::AlignDeclaration ) override;
virtual void visit(typename AST::CPPMangleDeclaration ) override;
virtual void visit(typename AST::VisibilityDeclaration ) override;
virtual void visit(typename AST::PragmaDeclaration ) override;
virtual void visit(typename AST::StorageClassDeclaration ) override;
virtual void visit(typename AST::ConditionalDeclaration ) override;
virtual void visit(typename AST::DeprecatedDeclaration ) override;
virtual void visit(typename AST::StaticIfDeclaration ) override;
virtual void visit(typename AST::EnumMember ) override;
virtual void visit(typename AST::Module ) override;
virtual void visit(typename AST::StructDeclaration ) override;
virtual void visit(typename AST::UnionDeclaration ) override;
virtual void visit(typename AST::ClassDeclaration ) override;
virtual void visit(typename AST::InterfaceDeclaration ) override;
virtual void visit(typename AST::TemplateMixin ) override;
virtual void visit(typename AST::Parameter ) override;
virtual void visit(typename AST::Statement ) override;
virtual void visit(typename AST::ImportStatement ) override;
virtual void visit(typename AST::ScopeStatement ) override;
virtual void visit(typename AST::ReturnStatement ) override;
virtual void visit(typename AST::LabelStatement ) override;
virtual void visit(typename AST::StaticAssertStatement ) override;
virtual void visit(typename AST::MixinStatement ) override;
virtual void visit(typename AST::WhileStatement ) override;
virtual void visit(typename AST::ForStatement ) override;
virtual void visit(typename AST::DoStatement ) override;
virtual void visit(typename AST::ForeachRangeStatement ) override;
virtual void visit(typename AST::ForeachStatement ) override;
virtual void visit(typename AST::IfStatement ) override;
virtual void visit(typename AST::ScopeGuardStatement ) override;
virtual void visit(typename AST::ConditionalStatement ) override;
virtual void visit(typename AST::PragmaStatement ) override;
virtual void visit(typename AST::SwitchStatement ) override;
virtual void visit(typename AST::CaseRangeStatement ) override;
virtual void visit(typename AST::CaseStatement ) override;
virtual void visit(typename AST::DefaultStatement ) override;
virtual void visit(typename AST::BreakStatement ) override;
virtual void visit(typename AST::ContinueStatement ) override;
virtual void visit(typename AST::GotoDefaultStatement ) override;
virtual void visit(typename AST::GotoCaseStatement ) override;
virtual void visit(typename AST::GotoStatement ) override;
virtual void visit(typename AST::SynchronizedStatement ) override;
virtual void visit(typename AST::WithStatement ) override;
virtual void visit(typename AST::TryCatchStatement ) override;
virtual void visit(typename AST::TryFinallyStatement ) override;
virtual void visit(typename AST::ThrowStatement ) override;
virtual void visit(typename AST::AsmStatement ) override;
virtual void visit(typename AST::ExpStatement ) override;
virtual void visit(typename AST::CompoundStatement ) override;
virtual void visit(typename AST::CompoundDeclarationStatement ) override;
virtual void visit(typename AST::CompoundAsmStatement ) override;
virtual void visit(typename AST::InlineAsmStatement ) override;
virtual void visit(typename AST::Type ) override;
virtual void visit(typename AST::TypeBasic ) override;
virtual void visit(typename AST::TypeError ) override;
virtual void visit(typename AST::TypeNull ) override;
virtual void visit(typename AST::TypeNoreturn ) override;
virtual void visit(typename AST::TypeVector ) override;
virtual void visit(typename AST::TypeEnum ) override;
virtual void visit(typename AST::TypeTuple ) override;
virtual void visit(typename AST::TypeClass ) override;
virtual void visit(typename AST::TypeStruct ) override;
virtual void visit(typename AST::TypeNext ) override;
virtual void visit(typename AST::TypeReference ) override;
virtual void visit(typename AST::TypeSlice ) override;
virtual void visit(typename AST::TypeDelegate ) override;
virtual void visit(typename AST::TypePointer ) override;
virtual void visit(typename AST::TypeFunction ) override;
virtual void visit(typename AST::TypeArray ) override;
virtual void visit(typename AST::TypeDArray ) override;
virtual void visit(typename AST::TypeAArray ) override;
virtual void visit(typename AST::TypeSArray ) override;
virtual void visit(typename AST::TypeQualified ) override;
virtual void visit(typename AST::TypeTraits ) override;
virtual void visit(typename AST::TypeMixin ) override;
virtual void visit(typename AST::TypeIdentifier ) override;
virtual void visit(typename AST::TypeReturn ) override;
virtual void visit(typename AST::TypeTypeof ) override;
virtual void visit(typename AST::TypeInstance ) override;
virtual void visit(typename AST::Expression ) override;
virtual void visit(typename AST::DeclarationExp ) override;
virtual void visit(typename AST::IntegerExp ) override;
virtual void visit(typename AST::NewAnonClassExp ) override;
virtual void visit(typename AST::IsExp ) override;
virtual void visit(typename AST::RealExp ) override;
virtual void visit(typename AST::NullExp ) override;
virtual void visit(typename AST::TypeidExp ) override;
virtual void visit(typename AST::TraitsExp ) override;
virtual void visit(typename AST::StringExp ) override;
virtual void visit(typename AST::InterpExp ) override;
virtual void visit(typename AST::NewExp ) override;
virtual void visit(typename AST::AssocArrayLiteralExp ) override;
virtual void visit(typename AST::ArrayLiteralExp ) override;
virtual void visit(typename AST::FuncExp ) override;
virtual void visit(typename AST::IntervalExp ) override;
virtual void visit(typename AST::TypeExp ) override;
virtual void visit(typename AST::ScopeExp ) override;
virtual void visit(typename AST::IdentifierExp ) override;
virtual void visit(typename AST::UnaExp ) override;
virtual void visit(typename AST::DefaultInitExp ) override;
virtual void visit(typename AST::BinExp ) override;
virtual void visit(typename AST::DsymbolExp ) override;
virtual void visit(typename AST::TemplateExp ) override;
virtual void visit(typename AST::SymbolExp ) override;
virtual void visit(typename AST::VarExp ) override;
virtual void visit(typename AST::TupleExp ) override;
virtual void visit(typename AST::DollarExp ) override;
virtual void visit(typename AST::ThisExp ) override;
virtual void visit(typename AST::SuperExp ) override;
virtual void visit(typename AST::AddrExp ) override;
virtual void visit(typename AST::PreExp ) override;
virtual void visit(typename AST::PtrExp ) override;
virtual void visit(typename AST::NegExp ) override;
virtual void visit(typename AST::UAddExp ) override;
virtual void visit(typename AST::NotExp ) override;
virtual void visit(typename AST::ComExp ) override;
virtual void visit(typename AST::DeleteExp ) override;
virtual void visit(typename AST::CastExp ) override;
virtual void visit(typename AST::CallExp ) override;
virtual void visit(typename AST::DotIdExp ) override;
virtual void visit(typename AST::AssertExp ) override;
virtual void visit(typename AST::ThrowExp ) override;
virtual void visit(typename AST::MixinExp ) override;
virtual void visit(typename AST::ImportExp ) override;
virtual void visit(typename AST::DotTemplateInstanceExp ) override;
virtual void visit(typename AST::ArrayExp ) override;
virtual void visit(typename AST::FuncInitExp ) override;
virtual void visit(typename AST::PrettyFuncInitExp ) override;
virtual void visit(typename AST::FileInitExp ) override;
virtual void visit(typename AST::LineInitExp ) override;
virtual void visit(typename AST::ModuleInitExp ) override;
virtual void visit(typename AST::CommaExp ) override;
virtual void visit(typename AST::PostExp ) override;
virtual void visit(typename AST::PowExp ) override;
virtual void visit(typename AST::MulExp ) override;
virtual void visit(typename AST::DivExp ) override;
virtual void visit(typename AST::ModExp ) override;
virtual void visit(typename AST::AddExp ) override;
virtual void visit(typename AST::MinExp ) override;
virtual void visit(typename AST::CatExp ) override;
virtual void visit(typename AST::ShlExp ) override;
virtual void visit(typename AST::ShrExp ) override;
virtual void visit(typename AST::UshrExp ) override;
virtual void visit(typename AST::EqualExp ) override;
virtual void visit(typename AST::InExp ) override;
virtual void visit(typename AST::IdentityExp ) override;
virtual void visit(typename AST::CmpExp ) override;
virtual void visit(typename AST::AndExp ) override;
virtual void visit(typename AST::XorExp ) override;
virtual void visit(typename AST::OrExp ) override;
virtual void visit(typename AST::LogicalExp ) override;
virtual void visit(typename AST::CondExp ) override;
virtual void visit(typename AST::AssignExp ) override;
virtual void visit(typename AST::BinAssignExp ) override;
virtual void visit(typename AST::AddAssignExp ) override;
virtual void visit(typename AST::MinAssignExp ) override;
virtual void visit(typename AST::MulAssignExp ) override;
virtual void visit(typename AST::DivAssignExp ) override;
virtual void visit(typename AST::ModAssignExp ) override;
virtual void visit(typename AST::PowAssignExp ) override;
virtual void visit(typename AST::AndAssignExp ) override;
virtual void visit(typename AST::OrAssignExp ) override;
virtual void visit(typename AST::XorAssignExp ) override;
virtual void visit(typename AST::ShlAssignExp ) override;
virtual void visit(typename AST::ShrAssignExp ) override;
virtual void visit(typename AST::UshrAssignExp ) override;
virtual void visit(typename AST::CatAssignExp ) override;
virtual void visit(typename AST::CatElemAssignExp ) override;
virtual void visit(typename AST::CatDcharAssignExp ) override;
virtual void visit(typename AST::GenericExp ) override;
virtual void visit(typename AST::TemplateParameter ) override;
virtual void visit(typename AST::TemplateAliasParameter ) override;
virtual void visit(typename AST::TemplateTypeParameter ) override;
virtual void visit(typename AST::TemplateTupleParameter ) override;
virtual void visit(typename AST::TemplateValueParameter ) override;
virtual void visit(typename AST::TemplateThisParameter ) override;
virtual void visit(typename AST::Condition ) override;
virtual void visit(typename AST::StaticIfCondition ) override;
virtual void visit(typename AST::DVCondition ) override;
virtual void visit(typename AST::DebugCondition ) override;
virtual void visit(typename AST::VersionCondition ) override;
virtual void visit(typename AST::Initializer ) override;
virtual void visit(typename AST::ExpInitializer ) override;
virtual void visit(typename AST::StructInitializer ) override;
virtual void visit(typename AST::ArrayInitializer ) override;
virtual void visit(typename AST::VoidInitializer ) override;
virtual void visit(typename AST::DefaultInitializer ) override;
virtual void visit(typename AST::CInitializer ) override;
};

extern _d_real creall(complex_t x);

extern _d_real cimagl(complex_t x);
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ import dmd.location;
import dmd.mtype;
import dmd.opover;
import dmd.printast;
import dmd.postordervisitor;
import dmd.statement;
import dmd.tokens;
import dmd.typesem : pointerTo, sarrayOf;
import dmd.visitor;
import dmd.visitor.postorder;
import dmd.inlinecost;

/***********************************************************
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/inlinecost.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import dmd.identifier;
import dmd.init;
import dmd.mtype;
import dmd.opover;
import dmd.postordervisitor;
import dmd.statement;
import dmd.tokens;
import dmd.visitor;
import dmd.visitor.postorder;

enum COST_MAX = 250;

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/nogc.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import dmd.globals;
import dmd.init;
import dmd.location;
import dmd.mtype;
import dmd.postordervisitor;
import dmd.rootobject : RootObject, DYNCAST;
import dmd.semantic2;
import dmd.semantic3;
import dmd.tokens;
import dmd.visitor;
import dmd.visitor.postorder;

/**************************************
* Look for GC-allocations
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dmd/ob.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import dmd.dtemplate;
import dmd.errors;
import dmd.escape;
import dmd.expression;
import dmd.foreachvar;

import dmd.func;
import dmd.globals;
import dmd.hdrgen;
Expand All @@ -46,6 +46,7 @@ import dmd.stmtstate;
import dmd.tokens;
import dmd.typesem;
import dmd.visitor;
import dmd.visitor.foreachvar;

import dmd.root.bitarray;
import dmd.common.outbuffer;
Expand Down
Loading

0 comments on commit c042e32

Please sign in to comment.