1 /** 2 * Defines a visitor for the AST. 3 * 4 * Other visitors derive from this class. 5 * 6 * Documentation: https://dlang.org/phobos/dmd_parsetimevisitor.html 7 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/parsetimevisitor.d 8 */ 9 10 module dmd.parsetimevisitor; 11 12 /** Basic and dumm visitor which implements a visit method for each AST node 13 * implemented in AST. This visitor is the parent of strict, transitive 14 * and permissive visitors. 15 */ ParseTimeVisitor(AST)16extern (C++) class ParseTimeVisitor(AST) 17 { 18 public: 19 void visit(AST.Dsymbol) { assert(0); } 20 void visit(AST.Parameter) { assert(0); } 21 void visit(AST.Statement) { assert(0); } 22 void visit(AST.Type) { assert(0); } 23 void visit(AST.Expression) { assert(0); } 24 void visit(AST.TemplateParameter) { assert(0); } 25 void visit(AST.Condition) { assert(0); } 26 void visit(AST.Initializer) { assert(0); } 27 28 //======================================================================================= 29 // Dsymbols 30 void visit(AST.AliasThis s) { visit(cast(AST.Dsymbol)s); } 31 void visit(AST.Declaration s) { visit(cast(AST.Dsymbol)s); } 32 void visit(AST.ScopeDsymbol s) { visit(cast(AST.Dsymbol)s); } 33 void visit(AST.Import s) { visit(cast(AST.Dsymbol)s); } 34 void visit(AST.AttribDeclaration s) { visit(cast(AST.Dsymbol)s); } 35 void visit(AST.StaticAssert s) { visit(cast(AST.Dsymbol)s); } 36 void visit(AST.DebugSymbol s) { visit(cast(AST.Dsymbol)s); } 37 void visit(AST.VersionSymbol s) { visit(cast(AST.Dsymbol)s); } 38 void visit(AST.AliasAssign s) { visit(cast(AST.Dsymbol)s); } 39 40 // ScopeDsymbols 41 void visit(AST.Package s) { visit(cast(AST.ScopeDsymbol)s); } 42 void visit(AST.EnumDeclaration s) { visit(cast(AST.ScopeDsymbol)s); } 43 void visit(AST.AggregateDeclaration s) { visit(cast(AST.ScopeDsymbol)s); } 44 void visit(AST.TemplateDeclaration s) { visit(cast(AST.ScopeDsymbol)s); } 45 void visit(AST.TemplateInstance s) { visit(cast(AST.ScopeDsymbol)s); } 46 void visit(AST.Nspace s) { visit(cast(AST.ScopeDsymbol)s); } 47 48 //========================================================================================= 49 // Declarations 50 void visit(AST.VarDeclaration s) { visit(cast(AST.Declaration)s); } 51 void visit(AST.FuncDeclaration s) { visit(cast(AST.Declaration)s); } 52 void visit(AST.AliasDeclaration s) { visit(cast(AST.Declaration)s); } 53 void visit(AST.TupleDeclaration s) { visit(cast(AST.Declaration)s); } 54 55 // FuncDeclarations 56 void visit(AST.FuncLiteralDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 57 void visit(AST.PostBlitDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 58 void visit(AST.CtorDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 59 void visit(AST.DtorDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 60 void visit(AST.InvariantDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 61 void visit(AST.UnitTestDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 62 void visit(AST.NewDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 63 void visit(AST.StaticCtorDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 64 void visit(AST.StaticDtorDeclaration s) { visit(cast(AST.FuncDeclaration)s); } 65 void visit(AST.SharedStaticCtorDeclaration s) { visit(cast(AST.StaticCtorDeclaration)s); } 66 void visit(AST.SharedStaticDtorDeclaration s) { visit(cast(AST.StaticDtorDeclaration)s); } 67 68 // AttribDeclarations 69 void visit(AST.CompileDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 70 void visit(AST.UserAttributeDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 71 void visit(AST.LinkDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 72 void visit(AST.AnonDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 73 void visit(AST.AlignDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 74 void visit(AST.CPPMangleDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 75 void visit(AST.CPPNamespaceDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 76 void visit(AST.VisibilityDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 77 void visit(AST.PragmaDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 78 void visit(AST.StorageClassDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 79 void visit(AST.ConditionalDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 80 void visit(AST.StaticForeachDeclaration s) { visit(cast(AST.AttribDeclaration)s); } 81 82 //============================================================================================== 83 // Miscellaneous 84 void visit(AST.DeprecatedDeclaration s) { visit(cast(AST.StorageClassDeclaration)s); } 85 void visit(AST.StaticIfDeclaration s) { visit(cast(AST.ConditionalDeclaration)s); } 86 void visit(AST.EnumMember s) { visit(cast(AST.VarDeclaration)s); } 87 void visit(AST.Module s) { visit(cast(AST.Package)s); } 88 void visit(AST.StructDeclaration s) { visit(cast(AST.AggregateDeclaration)s); } 89 void visit(AST.UnionDeclaration s) { visit(cast(AST.StructDeclaration)s); } 90 void visit(AST.ClassDeclaration s) { visit(cast(AST.AggregateDeclaration)s); } 91 void visit(AST.InterfaceDeclaration s) { visit(cast(AST.ClassDeclaration)s); } 92 void visit(AST.TemplateMixin s) { visit(cast(AST.TemplateInstance)s); } 93 void visit(AST.BitFieldDeclaration s) { visit(cast(AST.VarDeclaration)s); } 94 95 //============================================================================================ 96 // Statements 97 void visit(AST.ImportStatement s) { visit(cast(AST.Statement)s); } 98 void visit(AST.ScopeStatement s) { visit(cast(AST.Statement)s); } 99 void visit(AST.ReturnStatement s) { visit(cast(AST.Statement)s); } 100 void visit(AST.LabelStatement s) { visit(cast(AST.Statement)s); } 101 void visit(AST.StaticAssertStatement s) { visit(cast(AST.Statement)s); } 102 void visit(AST.CompileStatement s) { visit(cast(AST.Statement)s); } 103 void visit(AST.WhileStatement s) { visit(cast(AST.Statement)s); } 104 void visit(AST.ForStatement s) { visit(cast(AST.Statement)s); } 105 void visit(AST.DoStatement s) { visit(cast(AST.Statement)s); } 106 void visit(AST.ForeachRangeStatement s) { visit(cast(AST.Statement)s); } 107 void visit(AST.ForeachStatement s) { visit(cast(AST.Statement)s); } 108 void visit(AST.IfStatement s) { visit(cast(AST.Statement)s); } 109 void visit(AST.ScopeGuardStatement s) { visit(cast(AST.Statement)s); } 110 void visit(AST.ConditionalStatement s) { visit(cast(AST.Statement)s); } 111 void visit(AST.StaticForeachStatement s) { visit(cast(AST.Statement)s); } 112 void visit(AST.PragmaStatement s) { visit(cast(AST.Statement)s); } 113 void visit(AST.SwitchStatement s) { visit(cast(AST.Statement)s); } 114 void visit(AST.CaseRangeStatement s) { visit(cast(AST.Statement)s); } 115 void visit(AST.CaseStatement s) { visit(cast(AST.Statement)s); } 116 void visit(AST.DefaultStatement s) { visit(cast(AST.Statement)s); } 117 void visit(AST.BreakStatement s) { visit(cast(AST.Statement)s); } 118 void visit(AST.ContinueStatement s) { visit(cast(AST.Statement)s); } 119 void visit(AST.GotoDefaultStatement s) { visit(cast(AST.Statement)s); } 120 void visit(AST.GotoCaseStatement s) { visit(cast(AST.Statement)s); } 121 void visit(AST.GotoStatement s) { visit(cast(AST.Statement)s); } 122 void visit(AST.SynchronizedStatement s) { visit(cast(AST.Statement)s); } 123 void visit(AST.WithStatement s) { visit(cast(AST.Statement)s); } 124 void visit(AST.TryCatchStatement s) { visit(cast(AST.Statement)s); } 125 void visit(AST.TryFinallyStatement s) { visit(cast(AST.Statement)s); } 126 void visit(AST.ThrowStatement s) { visit(cast(AST.Statement)s); } 127 void visit(AST.AsmStatement s) { visit(cast(AST.Statement)s); } 128 void visit(AST.ExpStatement s) { visit(cast(AST.Statement)s); } 129 void visit(AST.CompoundStatement s) { visit(cast(AST.Statement)s); } 130 131 // CompoundStatements 132 void visit(AST.CompoundDeclarationStatement s) { visit(cast(AST.CompoundStatement)s); } 133 void visit(AST.CompoundAsmStatement s) { visit(cast(AST.CompoundStatement)s); } 134 135 // AsmStatements 136 void visit(AST.InlineAsmStatement s) { visit(cast(AST.AsmStatement)s); } 137 void visit(AST.GccAsmStatement s) { visit(cast(AST.AsmStatement)s); } 138 139 //========================================================================================= 140 // Types 141 void visit(AST.TypeBasic t) { visit(cast(AST.Type)t); } 142 void visit(AST.TypeError t) { visit(cast(AST.Type)t); } 143 void visit(AST.TypeNull t) { visit(cast(AST.Type)t); } 144 void visit(AST.TypeNoreturn t) { visit(cast(AST.Type)t); } 145 void visit(AST.TypeVector t) { visit(cast(AST.Type)t); } 146 void visit(AST.TypeEnum t) { visit(cast(AST.Type)t); } 147 void visit(AST.TypeTuple t) { visit(cast(AST.Type)t); } 148 void visit(AST.TypeClass t) { visit(cast(AST.Type)t); } 149 void visit(AST.TypeStruct t) { visit(cast(AST.Type)t); } 150 void visit(AST.TypeNext t) { visit(cast(AST.Type)t); } 151 void visit(AST.TypeQualified t) { visit(cast(AST.Type)t); } 152 void visit(AST.TypeTraits t) { visit(cast(AST.Type)t); } 153 void visit(AST.TypeMixin t) { visit(cast(AST.Type)t); } 154 void visit(AST.TypeTag t) { visit(cast(AST.Type)t); } 155 156 // TypeNext 157 void visit(AST.TypeReference t) { visit(cast(AST.TypeNext)t); } 158 void visit(AST.TypeSlice t) { visit(cast(AST.TypeNext)t); } 159 void visit(AST.TypeDelegate t) { visit(cast(AST.TypeNext)t); } 160 void visit(AST.TypePointer t) { visit(cast(AST.TypeNext)t); } 161 void visit(AST.TypeFunction t) { visit(cast(AST.TypeNext)t); } 162 void visit(AST.TypeArray t) { visit(cast(AST.TypeNext)t); } 163 164 // TypeArray 165 void visit(AST.TypeDArray t) { visit(cast(AST.TypeArray)t); } 166 void visit(AST.TypeAArray t) { visit(cast(AST.TypeArray)t); } 167 void visit(AST.TypeSArray t) { visit(cast(AST.TypeArray)t); } 168 169 // TypeQualified 170 void visit(AST.TypeIdentifier t) { visit(cast(AST.TypeQualified)t); } 171 void visit(AST.TypeReturn t) { visit(cast(AST.TypeQualified)t); } 172 void visit(AST.TypeTypeof t) { visit(cast(AST.TypeQualified)t); } 173 void visit(AST.TypeInstance t) { visit(cast(AST.TypeQualified)t); } 174 175 //================================================================================= 176 // Expressions 177 void visit(AST.DeclarationExp e) { visit(cast(AST.Expression)e); } 178 void visit(AST.IntegerExp e) { visit(cast(AST.Expression)e); } 179 void visit(AST.NewAnonClassExp e) { visit(cast(AST.Expression)e); } 180 void visit(AST.IsExp e) { visit(cast(AST.Expression)e); } 181 void visit(AST.RealExp e) { visit(cast(AST.Expression)e); } 182 void visit(AST.NullExp e) { visit(cast(AST.Expression)e); } 183 void visit(AST.TypeidExp e) { visit(cast(AST.Expression)e); } 184 void visit(AST.TraitsExp e) { visit(cast(AST.Expression)e); } 185 void visit(AST.StringExp e) { visit(cast(AST.Expression)e); } 186 void visit(AST.NewExp e) { visit(cast(AST.Expression)e); } 187 void visit(AST.AssocArrayLiteralExp e) { visit(cast(AST.Expression)e); } 188 void visit(AST.ArrayLiteralExp e) { visit(cast(AST.Expression)e); } 189 void visit(AST.MixinExp e) { visit(cast(AST.Expression)e); } 190 void visit(AST.FuncExp e) { visit(cast(AST.Expression)e); } 191 void visit(AST.IntervalExp e) { visit(cast(AST.Expression)e); } 192 void visit(AST.TypeExp e) { visit(cast(AST.Expression)e); } 193 void visit(AST.ScopeExp e) { visit(cast(AST.Expression)e); } 194 void visit(AST.IdentifierExp e) { visit(cast(AST.Expression)e); } 195 void visit(AST.UnaExp e) { visit(cast(AST.Expression)e); } 196 void visit(AST.DefaultInitExp e) { visit(cast(AST.Expression)e); } 197 void visit(AST.BinExp e) { visit(cast(AST.Expression)e); } 198 void visit(AST.DsymbolExp e) { visit(cast(AST.Expression)e); } 199 void visit(AST.TemplateExp e) { visit(cast(AST.Expression)e); } 200 void visit(AST.SymbolExp e) { visit(cast(AST.Expression)e); } 201 void visit(AST.TupleExp e) { visit(cast(AST.Expression)e); } 202 void visit(AST.ThisExp e) { visit(cast(AST.Expression)e); } 203 void visit(AST.GenericExp e) { visit(cast(AST.Expression)e); } 204 205 // Miscellaneous 206 void visit(AST.VarExp e) { visit(cast(AST.SymbolExp)e); } 207 void visit(AST.DollarExp e) { visit(cast(AST.IdentifierExp)e); } 208 void visit(AST.SuperExp e) { visit(cast(AST.ThisExp)e); } 209 210 // UnaExp 211 void visit(AST.AddrExp e) { visit(cast(AST.UnaExp)e); } 212 void visit(AST.PreExp e) { visit(cast(AST.UnaExp)e); } 213 void visit(AST.PtrExp e) { visit(cast(AST.UnaExp)e); } 214 void visit(AST.NegExp e) { visit(cast(AST.UnaExp)e); } 215 void visit(AST.UAddExp e) { visit(cast(AST.UnaExp)e); } 216 void visit(AST.NotExp e) { visit(cast(AST.UnaExp)e); } 217 void visit(AST.ComExp e) { visit(cast(AST.UnaExp)e); } 218 void visit(AST.DeleteExp e) { visit(cast(AST.UnaExp)e); } 219 void visit(AST.CastExp e) { visit(cast(AST.UnaExp)e); } 220 void visit(AST.CallExp e) { visit(cast(AST.UnaExp)e); } 221 void visit(AST.DotIdExp e) { visit(cast(AST.UnaExp)e); } 222 void visit(AST.AssertExp e) { visit(cast(AST.UnaExp)e); } 223 void visit(AST.ThrowExp e) { visit(cast(AST.UnaExp)e); } 224 void visit(AST.ImportExp e) { visit(cast(AST.UnaExp)e); } 225 void visit(AST.DotTemplateInstanceExp e) { visit(cast(AST.UnaExp)e); } 226 void visit(AST.ArrayExp e) { visit(cast(AST.UnaExp)e); } 227 228 // DefaultInitExp 229 void visit(AST.FuncInitExp e) { visit(cast(AST.DefaultInitExp)e); } 230 void visit(AST.PrettyFuncInitExp e) { visit(cast(AST.DefaultInitExp)e); } 231 void visit(AST.FileInitExp e) { visit(cast(AST.DefaultInitExp)e); } 232 void visit(AST.LineInitExp e) { visit(cast(AST.DefaultInitExp)e); } 233 void visit(AST.ModuleInitExp e) { visit(cast(AST.DefaultInitExp)e); } 234 235 // BinExp 236 void visit(AST.CommaExp e) { visit(cast(AST.BinExp)e); } 237 void visit(AST.PostExp e) { visit(cast(AST.BinExp)e); } 238 void visit(AST.PowExp e) { visit(cast(AST.BinExp)e); } 239 void visit(AST.MulExp e) { visit(cast(AST.BinExp)e); } 240 void visit(AST.DivExp e) { visit(cast(AST.BinExp)e); } 241 void visit(AST.ModExp e) { visit(cast(AST.BinExp)e); } 242 void visit(AST.AddExp e) { visit(cast(AST.BinExp)e); } 243 void visit(AST.MinExp e) { visit(cast(AST.BinExp)e); } 244 void visit(AST.CatExp e) { visit(cast(AST.BinExp)e); } 245 void visit(AST.ShlExp e) { visit(cast(AST.BinExp)e); } 246 void visit(AST.ShrExp e) { visit(cast(AST.BinExp)e); } 247 void visit(AST.UshrExp e) { visit(cast(AST.BinExp)e); } 248 void visit(AST.EqualExp e) { visit(cast(AST.BinExp)e); } 249 void visit(AST.InExp e) { visit(cast(AST.BinExp)e); } 250 void visit(AST.IdentityExp e) { visit(cast(AST.BinExp)e); } 251 void visit(AST.CmpExp e) { visit(cast(AST.BinExp)e); } 252 void visit(AST.AndExp e) { visit(cast(AST.BinExp)e); } 253 void visit(AST.XorExp e) { visit(cast(AST.BinExp)e); } 254 void visit(AST.OrExp e) { visit(cast(AST.BinExp)e); } 255 void visit(AST.LogicalExp e) { visit(cast(AST.BinExp)e); } 256 void visit(AST.CondExp e) { visit(cast(AST.BinExp)e); } 257 void visit(AST.AssignExp e) { visit(cast(AST.BinExp)e); } 258 void visit(AST.BinAssignExp e) { visit(cast(AST.BinExp)e); } 259 260 // BinAssignExp 261 void visit(AST.AddAssignExp e) { visit(cast(AST.BinAssignExp)e); } 262 void visit(AST.MinAssignExp e) { visit(cast(AST.BinAssignExp)e); } 263 void visit(AST.MulAssignExp e) { visit(cast(AST.BinAssignExp)e); } 264 void visit(AST.DivAssignExp e) { visit(cast(AST.BinAssignExp)e); } 265 void visit(AST.ModAssignExp e) { visit(cast(AST.BinAssignExp)e); } 266 void visit(AST.PowAssignExp e) { visit(cast(AST.BinAssignExp)e); } 267 void visit(AST.AndAssignExp e) { visit(cast(AST.BinAssignExp)e); } 268 void visit(AST.OrAssignExp e) { visit(cast(AST.BinAssignExp)e); } 269 void visit(AST.XorAssignExp e) { visit(cast(AST.BinAssignExp)e); } 270 void visit(AST.ShlAssignExp e) { visit(cast(AST.BinAssignExp)e); } 271 void visit(AST.ShrAssignExp e) { visit(cast(AST.BinAssignExp)e); } 272 void visit(AST.UshrAssignExp e) { visit(cast(AST.BinAssignExp)e); } 273 void visit(AST.CatAssignExp e) { visit(cast(AST.BinAssignExp)e); } 274 275 //=============================================================================== 276 // TemplateParameter 277 void visit(AST.TemplateAliasParameter tp) { visit(cast(AST.TemplateParameter)tp); } 278 void visit(AST.TemplateTypeParameter tp) { visit(cast(AST.TemplateParameter)tp); } 279 void visit(AST.TemplateTupleParameter tp) { visit(cast(AST.TemplateParameter)tp); } 280 void visit(AST.TemplateValueParameter tp) { visit(cast(AST.TemplateParameter)tp); } 281 282 void visit(AST.TemplateThisParameter tp) { visit(cast(AST.TemplateTypeParameter)tp); } 283 284 //=============================================================================== 285 // Condition 286 void visit(AST.StaticIfCondition c) { visit(cast(AST.Condition)c); } 287 void visit(AST.DVCondition c) { visit(cast(AST.Condition)c); } 288 void visit(AST.DebugCondition c) { visit(cast(AST.DVCondition)c); } 289 void visit(AST.VersionCondition c) { visit(cast(AST.DVCondition)c); } 290 291 //=============================================================================== 292 // Initializer 293 void visit(AST.ExpInitializer i) { visit(cast(AST.Initializer)i); } 294 void visit(AST.StructInitializer i) { visit(cast(AST.Initializer)i); } 295 void visit(AST.ArrayInitializer i) { visit(cast(AST.Initializer)i); } 296 void visit(AST.VoidInitializer i) { visit(cast(AST.Initializer)i); } 297 void visit(AST.CInitializer i) { visit(cast(AST.CInitializer)i); } 298 } 299