1 // 2 // visit.cs: Visitors for parsed dom 3 // 4 // Authors: Mike Kr�ger (mkrueger@novell.com) 5 // Marek Safar (marek.safar@gmail.com) 6 // 7 // Dual licensed under the terms of the MIT X11 or GNU GPL 8 // 9 // Copyright (c) 2010 Novell, Inc (http://www.novell.com) 10 // Copyright 2011 Xamarin Inc 11 // 12 13 using System; 14 using System.Diagnostics; 15 16 namespace Mono.CSharp 17 { 18 public abstract class StructuralVisitor 19 { Visit(MemberCore member)20 public virtual void Visit (MemberCore member) 21 { 22 Debug.Fail ("unknown member type: " + member.GetType ()); 23 } 24 VisitTypeContainer(TypeContainer tc)25 void VisitTypeContainer (TypeContainer tc) 26 { 27 foreach (var container in tc.Containers) { 28 container.Accept (this); 29 } 30 } 31 VisitTypeContainer(TypeDefinition tc)32 void VisitTypeContainer (TypeDefinition tc) 33 { 34 foreach (var member in tc.Members) { 35 member.Accept (this); 36 } 37 } 38 Visit(ModuleContainer module)39 public virtual void Visit (ModuleContainer module) 40 { 41 VisitTypeContainer (module); 42 } 43 Visit(UsingNamespace un)44 public virtual void Visit (UsingNamespace un) 45 { 46 } 47 Visit(UsingAliasNamespace uan)48 public virtual void Visit (UsingAliasNamespace uan) 49 { 50 } 51 Visit(UsingExternAlias uea)52 public virtual void Visit (UsingExternAlias uea) 53 { 54 } 55 Visit(NamespaceContainer ns)56 public virtual void Visit (NamespaceContainer ns) 57 { 58 VisitTypeContainer (ns); 59 } 60 Visit(CompilationSourceFile csf)61 public virtual void Visit (CompilationSourceFile csf) 62 { 63 VisitTypeContainer (csf); 64 } 65 Visit(Class c)66 public virtual void Visit (Class c) 67 { 68 VisitTypeContainer (c); 69 } 70 Visit(Struct s)71 public virtual void Visit (Struct s) 72 { 73 VisitTypeContainer (s); 74 } 75 76 Visit(Interface i)77 public virtual void Visit (Interface i) 78 { 79 VisitTypeContainer (i); 80 } 81 Visit(Delegate d)82 public virtual void Visit (Delegate d) 83 { 84 } 85 Visit(Enum e)86 public virtual void Visit (Enum e) 87 { 88 VisitTypeContainer (e); 89 } 90 Visit(FixedField f)91 public virtual void Visit (FixedField f) 92 { 93 } 94 Visit(Const c)95 public virtual void Visit (Const c) 96 { 97 } 98 Visit(Field f)99 public virtual void Visit (Field f) 100 { 101 } 102 Visit(Operator o)103 public virtual void Visit (Operator o) 104 { 105 } 106 Visit(Indexer i)107 public virtual void Visit (Indexer i) 108 { 109 } 110 Visit(Method m)111 public virtual void Visit (Method m) 112 { 113 } 114 Visit(Property p)115 public virtual void Visit (Property p) 116 { 117 } 118 Visit(Constructor c)119 public virtual void Visit (Constructor c) 120 { 121 } 122 Visit(Destructor d)123 public virtual void Visit (Destructor d) 124 { 125 } 126 Visit(EventField e)127 public virtual void Visit (EventField e) 128 { 129 } Visit(EventProperty ep)130 public virtual void Visit (EventProperty ep) 131 { 132 } 133 Visit(EnumMember em)134 public virtual void Visit (EnumMember em) 135 { 136 } 137 Visit(Statement stmt)138 public virtual object Visit (Statement stmt) 139 { 140 Debug.Fail ("unknown statement:" + stmt); 141 return null; 142 } 143 Visit(BlockVariable blockVariableDeclaration)144 public virtual object Visit (BlockVariable blockVariableDeclaration) 145 { 146 return null; 147 } 148 Visit(BlockConstant blockConstantDeclaration)149 public virtual object Visit (BlockConstant blockConstantDeclaration) 150 { 151 return null; 152 } 153 Visit(EmptyStatement emptyStatement)154 public virtual object Visit (EmptyStatement emptyStatement) 155 { 156 return null; 157 } 158 Visit(EmptyExpressionStatement emptyExpressionStatement)159 public virtual object Visit (EmptyExpressionStatement emptyExpressionStatement) 160 { 161 return null; 162 } 163 Visit(EmptyExpression emptyExpression)164 public virtual object Visit (EmptyExpression emptyExpression) 165 { 166 return null; 167 } 168 Visit(ErrorExpression errorExpression)169 public virtual object Visit (ErrorExpression errorExpression) 170 { 171 return null; 172 } 173 Visit(If ifStatement)174 public virtual object Visit (If ifStatement) 175 { 176 return null; 177 } 178 179 Visit(Do doStatement)180 public virtual object Visit (Do doStatement) 181 { 182 return null; 183 } 184 Visit(While whileStatement)185 public virtual object Visit (While whileStatement) 186 { 187 return null; 188 } 189 Visit(For forStatement)190 public virtual object Visit (For forStatement) 191 { 192 return null; 193 } 194 Visit(StatementExpression statementExpression)195 public virtual object Visit (StatementExpression statementExpression) 196 { 197 return null; 198 } 199 Visit(StatementErrorExpression errorStatement)200 public virtual object Visit (StatementErrorExpression errorStatement) 201 { 202 return null; 203 } 204 Visit(Return returnStatement)205 public virtual object Visit (Return returnStatement) 206 { 207 return null; 208 } 209 Visit(Goto gotoStatement)210 public virtual object Visit (Goto gotoStatement) 211 { 212 return null; 213 } 214 Visit(LabeledStatement labeledStatement)215 public virtual object Visit (LabeledStatement labeledStatement) 216 { 217 return null; 218 } 219 Visit(SwitchLabel switchLabel)220 public virtual object Visit (SwitchLabel switchLabel) 221 { 222 return null; 223 } 224 Visit(GotoDefault gotoDefault)225 public virtual object Visit (GotoDefault gotoDefault) 226 { 227 return null; 228 } 229 Visit(GotoCase gotoCase)230 public virtual object Visit (GotoCase gotoCase) 231 { 232 return null; 233 } 234 Visit(Throw throwStatement)235 public virtual object Visit (Throw throwStatement) 236 { 237 return null; 238 } 239 Visit(Break breakStatement)240 public virtual object Visit (Break breakStatement) 241 { 242 return null; 243 } 244 Visit(Continue continueStatement)245 public virtual object Visit (Continue continueStatement) 246 { 247 return null; 248 } 249 Visit(Block blockStatement)250 public virtual object Visit (Block blockStatement) 251 { 252 return null; 253 } 254 Visit(Switch switchStatement)255 public virtual object Visit (Switch switchStatement) 256 { 257 return null; 258 } 259 Visit(StatementList statementList)260 public virtual object Visit (StatementList statementList) 261 { 262 return null; 263 } 264 Visit(Lock lockStatement)265 public virtual object Visit (Lock lockStatement) 266 { 267 return null; 268 } 269 Visit(Unchecked uncheckedStatement)270 public virtual object Visit (Unchecked uncheckedStatement) 271 { 272 return null; 273 } 274 Visit(Checked checkedStatement)275 public virtual object Visit (Checked checkedStatement) 276 { 277 return null; 278 } 279 Visit(Unsafe unsafeStatement)280 public virtual object Visit (Unsafe unsafeStatement) 281 { 282 return null; 283 } 284 285 Visit(Fixed fixedStatement)286 public virtual object Visit (Fixed fixedStatement) 287 { 288 return null; 289 } 290 291 Visit(TryFinally tryFinallyStatement)292 public virtual object Visit (TryFinally tryFinallyStatement) 293 { 294 return null; 295 } 296 Visit(TryCatch tryCatchStatement)297 public virtual object Visit (TryCatch tryCatchStatement) 298 { 299 return null; 300 } 301 Visit(Using usingStatement)302 public virtual object Visit (Using usingStatement) 303 { 304 return null; 305 } 306 Visit(Foreach foreachStatement)307 public virtual object Visit (Foreach foreachStatement) 308 { 309 return null; 310 } 311 Visit(Yield yieldStatement)312 public virtual object Visit (Yield yieldStatement) 313 { 314 return null; 315 } 316 Visit(YieldBreak yieldBreakStatement)317 public virtual object Visit (YieldBreak yieldBreakStatement) 318 { 319 return null; 320 } 321 Visit(Expression expression)322 public virtual object Visit (Expression expression) 323 { 324 Debug.Fail ("Visit unknown expression:" + expression); 325 return null; 326 } 327 Visit(MemberAccess memberAccess)328 public virtual object Visit (MemberAccess memberAccess) 329 { 330 return null; 331 } 332 Visit(QualifiedAliasMember qualifiedAliasMember)333 public virtual object Visit (QualifiedAliasMember qualifiedAliasMember) 334 { 335 return null; 336 } 337 Visit(LocalVariableReference localVariableReference)338 public virtual object Visit (LocalVariableReference localVariableReference) 339 { 340 return null; 341 } 342 Visit(Constant constant)343 public virtual object Visit (Constant constant) 344 { 345 return null; 346 } 347 Visit(BooleanExpression booleanExpression)348 public virtual object Visit (BooleanExpression booleanExpression) 349 { 350 return null; 351 } 352 Visit(SimpleName simpleName)353 public virtual object Visit (SimpleName simpleName) 354 { 355 return null; 356 } 357 Visit(ParenthesizedExpression parenthesizedExpression)358 public virtual object Visit (ParenthesizedExpression parenthesizedExpression) 359 { 360 return null; 361 } 362 Visit(Unary unaryExpression)363 public virtual object Visit (Unary unaryExpression) 364 { 365 return null; 366 } 367 Visit(UnaryMutator unaryMutatorExpression)368 public virtual object Visit (UnaryMutator unaryMutatorExpression) 369 { 370 return null; 371 } 372 373 // *expr Visit(Indirection indirectionExpression)374 public virtual object Visit (Indirection indirectionExpression) 375 { 376 return null; 377 } 378 Visit(Is isExpression)379 public virtual object Visit (Is isExpression) 380 { 381 return null; 382 } 383 Visit(As asExpression)384 public virtual object Visit (As asExpression) 385 { 386 return null; 387 } 388 Visit(Cast castExpression)389 public virtual object Visit (Cast castExpression) 390 { 391 return null; 392 } 393 Visit(ComposedCast composedCast)394 public virtual object Visit (ComposedCast composedCast) 395 { 396 return null; 397 } 398 Visit(DefaultValueExpression defaultValueExpression)399 public virtual object Visit (DefaultValueExpression defaultValueExpression) 400 { 401 return null; 402 } 403 Visit(DefaultParameterValueExpression defaultParameterValueExpression)404 public virtual object Visit (DefaultParameterValueExpression defaultParameterValueExpression) 405 { 406 return null; 407 } 408 Visit(Binary binaryExpression)409 public virtual object Visit (Binary binaryExpression) 410 { 411 return null; 412 } 413 Visit(Nullable.NullCoalescingOperator nullCoalescingOperator)414 public virtual object Visit (Nullable.NullCoalescingOperator nullCoalescingOperator) 415 { 416 return null; 417 } 418 Visit(Conditional conditionalExpression)419 public virtual object Visit (Conditional conditionalExpression) 420 { 421 return null; 422 } 423 Visit(Invocation invocationExpression)424 public virtual object Visit (Invocation invocationExpression) 425 { 426 return null; 427 } 428 Visit(New newExpression)429 public virtual object Visit (New newExpression) 430 { 431 return null; 432 } 433 Visit(NewAnonymousType newAnonymousType)434 public virtual object Visit (NewAnonymousType newAnonymousType) 435 { 436 return null; 437 } 438 Visit(NewInitialize newInitializeExpression)439 public virtual object Visit (NewInitialize newInitializeExpression) 440 { 441 return null; 442 } 443 Visit(ArrayCreation arrayCreationExpression)444 public virtual object Visit (ArrayCreation arrayCreationExpression) 445 { 446 return null; 447 } 448 Visit(This thisExpression)449 public virtual object Visit (This thisExpression) 450 { 451 return null; 452 } 453 Visit(ArglistAccess argListAccessExpression)454 public virtual object Visit (ArglistAccess argListAccessExpression) 455 { 456 return null; 457 } 458 Visit(Arglist argListExpression)459 public virtual object Visit (Arglist argListExpression) 460 { 461 return null; 462 } 463 Visit(TypeOf typeOfExpression)464 public virtual object Visit (TypeOf typeOfExpression) 465 { 466 return null; 467 } 468 Visit(SizeOf sizeOfExpression)469 public virtual object Visit (SizeOf sizeOfExpression) 470 { 471 return null; 472 } 473 Visit(CheckedExpr checkedExpression)474 public virtual object Visit (CheckedExpr checkedExpression) 475 { 476 return null; 477 } 478 Visit(UnCheckedExpr uncheckedExpression)479 public virtual object Visit (UnCheckedExpr uncheckedExpression) 480 { 481 return null; 482 } 483 Visit(ElementAccess elementAccessExpression)484 public virtual object Visit (ElementAccess elementAccessExpression) 485 { 486 return null; 487 } 488 Visit(BaseThis baseAccessExpression)489 public virtual object Visit (BaseThis baseAccessExpression) 490 { 491 return null; 492 } 493 Visit(StackAlloc stackAllocExpression)494 public virtual object Visit (StackAlloc stackAllocExpression) 495 { 496 return null; 497 } 498 Visit(SimpleAssign simpleAssign)499 public virtual object Visit (SimpleAssign simpleAssign) 500 { 501 return null; 502 } 503 Visit(CompoundAssign compoundAssign)504 public virtual object Visit (CompoundAssign compoundAssign) 505 { 506 return null; 507 } 508 Visit(TypeExpression typeExpression)509 public virtual object Visit (TypeExpression typeExpression) 510 { 511 return null; 512 } 513 Visit(AnonymousMethodExpression anonymousMethodExpression)514 public virtual object Visit (AnonymousMethodExpression anonymousMethodExpression) 515 { 516 return null; 517 } 518 Visit(LambdaExpression lambdaExpression)519 public virtual object Visit (LambdaExpression lambdaExpression) 520 { 521 return null; 522 } 523 Visit(ConstInitializer constInitializer)524 public virtual object Visit (ConstInitializer constInitializer) 525 { 526 return null; 527 } 528 Visit(ArrayInitializer arrayInitializer)529 public virtual object Visit (ArrayInitializer arrayInitializer) 530 { 531 return null; 532 } 533 Visit(Linq.QueryExpression queryExpression)534 public virtual object Visit (Linq.QueryExpression queryExpression) 535 { 536 return null; 537 } 538 Visit(Linq.QueryStartClause queryExpression)539 public virtual object Visit (Linq.QueryStartClause queryExpression) 540 { 541 return null; 542 } 543 Visit(Linq.SelectMany selectMany)544 public virtual object Visit (Linq.SelectMany selectMany) 545 { 546 return null; 547 } 548 Visit(Linq.Select select)549 public virtual object Visit (Linq.Select select) 550 { 551 return null; 552 } 553 Visit(Linq.GroupBy groupBy)554 public virtual object Visit (Linq.GroupBy groupBy) 555 { 556 return null; 557 } 558 Visit(Linq.Let let)559 public virtual object Visit (Linq.Let let) 560 { 561 return null; 562 } 563 Visit(Linq.Where where)564 public virtual object Visit (Linq.Where where) 565 { 566 return null; 567 } 568 Visit(Linq.Join join)569 public virtual object Visit (Linq.Join join) 570 { 571 return null; 572 } 573 Visit(Linq.GroupJoin groupJoin)574 public virtual object Visit (Linq.GroupJoin groupJoin) 575 { 576 return null; 577 } 578 Visit(Linq.OrderByAscending orderByAscending)579 public virtual object Visit (Linq.OrderByAscending orderByAscending) 580 { 581 return null; 582 } 583 Visit(Linq.OrderByDescending orderByDescending)584 public virtual object Visit (Linq.OrderByDescending orderByDescending) 585 { 586 return null; 587 } 588 Visit(Linq.ThenByAscending thenByAscending)589 public virtual object Visit (Linq.ThenByAscending thenByAscending) 590 { 591 return null; 592 } 593 Visit(Linq.ThenByDescending thenByDescending)594 public virtual object Visit (Linq.ThenByDescending thenByDescending) 595 { 596 return null; 597 } 598 599 // undocumented expressions Visit(RefValueExpr refValueExpr)600 public virtual object Visit (RefValueExpr refValueExpr) 601 { 602 return null; 603 } 604 Visit(RefTypeExpr refTypeExpr)605 public virtual object Visit (RefTypeExpr refTypeExpr) 606 { 607 return null; 608 } 609 Visit(MakeRefExpr makeRefExpr)610 public virtual object Visit (MakeRefExpr makeRefExpr) 611 { 612 return null; 613 } 614 Visit(Await awaitExpr)615 public virtual object Visit (Await awaitExpr) 616 { 617 return null; 618 } 619 } 620 }