1 32 package org.jruby.ast.visitor; 33 34 import java.util.Iterator ; 35 36 import org.jruby.ast.AliasNode; 37 import org.jruby.ast.AndNode; 38 import org.jruby.ast.ArgsCatNode; 39 import org.jruby.ast.ArgsNode; 40 import org.jruby.ast.ArgsPushNode; 41 import org.jruby.ast.ArrayNode; 42 import org.jruby.ast.AttrAssignNode; 43 import org.jruby.ast.BackRefNode; 44 import org.jruby.ast.BeginNode; 45 import org.jruby.ast.BignumNode; 46 import org.jruby.ast.BlockArgNode; 47 import org.jruby.ast.BlockNode; 48 import org.jruby.ast.BlockPassNode; 49 import org.jruby.ast.BreakNode; 50 import org.jruby.ast.CallNode; 51 import org.jruby.ast.CaseNode; 52 import org.jruby.ast.ClassNode; 53 import org.jruby.ast.ClassVarAsgnNode; 54 import org.jruby.ast.ClassVarDeclNode; 55 import org.jruby.ast.ClassVarNode; 56 import org.jruby.ast.Colon2Node; 57 import org.jruby.ast.Colon3Node; 58 import org.jruby.ast.ConstDeclNode; 59 import org.jruby.ast.ConstNode; 60 import org.jruby.ast.DAsgnNode; 61 import org.jruby.ast.DRegexpNode; 62 import org.jruby.ast.DStrNode; 63 import org.jruby.ast.DSymbolNode; 64 import org.jruby.ast.DVarNode; 65 import org.jruby.ast.DXStrNode; 66 import org.jruby.ast.DefinedNode; 67 import org.jruby.ast.DefnNode; 68 import org.jruby.ast.DefsNode; 69 import org.jruby.ast.DotNode; 70 import org.jruby.ast.EnsureNode; 71 import org.jruby.ast.EvStrNode; 72 import org.jruby.ast.FCallNode; 73 import org.jruby.ast.FalseNode; 74 import org.jruby.ast.FixnumNode; 75 import org.jruby.ast.FlipNode; 76 import org.jruby.ast.FloatNode; 77 import org.jruby.ast.ForNode; 78 import org.jruby.ast.GlobalAsgnNode; 79 import org.jruby.ast.GlobalVarNode; 80 import org.jruby.ast.HashNode; 81 import org.jruby.ast.IfNode; 82 import org.jruby.ast.InstAsgnNode; 83 import org.jruby.ast.InstVarNode; 84 import org.jruby.ast.IterNode; 85 import org.jruby.ast.LocalAsgnNode; 86 import org.jruby.ast.LocalVarNode; 87 import org.jruby.ast.Match2Node; 88 import org.jruby.ast.Match3Node; 89 import org.jruby.ast.MatchNode; 90 import org.jruby.ast.ModuleNode; 91 import org.jruby.ast.MultipleAsgnNode; 92 import org.jruby.ast.NewlineNode; 93 import org.jruby.ast.NextNode; 94 import org.jruby.ast.NilNode; 95 import org.jruby.ast.Node; 96 import org.jruby.ast.NotNode; 97 import org.jruby.ast.NthRefNode; 98 import org.jruby.ast.OpAsgnAndNode; 99 import org.jruby.ast.OpAsgnNode; 100 import org.jruby.ast.OpAsgnOrNode; 101 import org.jruby.ast.OpElementAsgnNode; 102 import org.jruby.ast.OptNNode; 103 import org.jruby.ast.OrNode; 104 import org.jruby.ast.PostExeNode; 105 import org.jruby.ast.RedoNode; 106 import org.jruby.ast.RegexpNode; 107 import org.jruby.ast.RescueBodyNode; 108 import org.jruby.ast.RescueNode; 109 import org.jruby.ast.RetryNode; 110 import org.jruby.ast.ReturnNode; 111 import org.jruby.ast.RootNode; 112 import org.jruby.ast.SClassNode; 113 import org.jruby.ast.SValueNode; 114 import org.jruby.ast.SelfNode; 115 import org.jruby.ast.SplatNode; 116 import org.jruby.ast.StrNode; 117 import org.jruby.ast.SuperNode; 118 import org.jruby.ast.SymbolNode; 119 import org.jruby.ast.ToAryNode; 120 import org.jruby.ast.TrueNode; 121 import org.jruby.ast.UndefNode; 122 import org.jruby.ast.UntilNode; 123 import org.jruby.ast.VAliasNode; 124 import org.jruby.ast.VCallNode; 125 import org.jruby.ast.WhenNode; 126 import org.jruby.ast.WhileNode; 127 import org.jruby.ast.XStrNode; 128 import org.jruby.ast.YieldNode; 129 import org.jruby.ast.ZArrayNode; 130 import org.jruby.ast.ZSuperNode; 131 import org.jruby.evaluator.Instruction; 132 133 142 public class DefaultIteratorVisitor implements NodeVisitor { 143 protected NodeVisitor _Payload; 144 145 152 public DefaultIteratorVisitor(NodeVisitor iPayload) { 153 _Payload = iPayload; 154 } 155 156 public Instruction visitAliasNode(AliasNode iVisited) { 157 iVisited.accept(_Payload); 158 return null; 159 } 160 161 public Instruction visitAndNode(AndNode iVisited) { 162 iVisited.getFirstNode().accept(this); 163 iVisited.accept(_Payload); 164 iVisited.getSecondNode().accept(this); 165 return null; 166 } 167 168 public Instruction visitArgsNode(ArgsNode iVisited) { 169 iVisited.accept(_Payload); 170 if (iVisited.getOptArgs() != null) { 171 iVisited.getOptArgs().accept(this); 172 } 173 return null; 174 } 175 176 public Instruction visitArgsCatNode(ArgsCatNode iVisited) { 177 iVisited.accept(_Payload); 178 if (iVisited.getFirstNode() != null) { 179 iVisited.getFirstNode().accept(this); 180 } 181 if (iVisited.getSecondNode() != null) { 182 iVisited.getSecondNode().accept(this); 183 } 184 return null; 185 } 186 187 public Instruction visitArgsPushNode(ArgsPushNode iVisited) { 188 iVisited.accept(_Payload); 189 if (iVisited.getFirstNode() != null) { 190 iVisited.getFirstNode().accept(this); 191 } 192 if (iVisited.getSecondNode() != null) { 193 iVisited.getSecondNode().accept(this); 194 } 195 return null; 196 } 197 198 public Instruction visitAttrAssignNode(AttrAssignNode iVisited) { 199 iVisited.accept(_Payload); 200 if(iVisited.getArgsNode() != null) { 201 iVisited.getArgsNode().accept(this); 202 } 203 if(iVisited.getReceiverNode() != null) { 204 iVisited.getReceiverNode().accept(this); 205 } 206 return null; 207 } 208 209 public Instruction visitArrayNode(ArrayNode iVisited) { 210 iVisited.accept(_Payload); 211 Iterator iterator = iVisited.iterator(); 212 while (iterator.hasNext()) { 213 ((Node) iterator.next()).accept(this); 214 } 215 216 return null; 217 } 218 219 public Instruction visitBackRefNode(BackRefNode iVisited) { 220 iVisited.accept(_Payload); 221 return null; 222 } 223 224 public Instruction visitBeginNode(BeginNode iVisited) { 225 iVisited.accept(_Payload); 226 return null; 227 } 228 229 public Instruction visitBlockArgNode(BlockArgNode iVisited) { 230 iVisited.accept(_Payload); 231 return null; 232 } 233 234 public Instruction visitBlockNode(BlockNode iVisited) { 235 iVisited.accept(_Payload); 236 Iterator iterator = iVisited.iterator(); 237 while (iterator.hasNext()) { 238 ((Node) iterator.next()).accept(this); 239 } 240 return null; 241 } 242 243 public Instruction visitBlockPassNode(BlockPassNode iVisited) { 244 iVisited.accept(_Payload); 245 return null; 246 } 247 248 public Instruction visitBreakNode(BreakNode iVisited) { 249 iVisited.accept(_Payload); 250 return null; 251 } 252 253 public Instruction visitConstDeclNode(ConstDeclNode iVisited) { 254 iVisited.accept(_Payload); 255 iVisited.getValueNode().accept(this); 256 return null; 257 } 258 259 public Instruction visitClassVarAsgnNode(ClassVarAsgnNode iVisited) { 260 iVisited.accept(_Payload); 261 iVisited.getValueNode().accept(this); 262 return null; 263 } 264 265 public Instruction visitClassVarDeclNode(ClassVarDeclNode iVisited) { 266 iVisited.accept(_Payload); 267 return null; 268 } 269 270 public Instruction visitClassVarNode(ClassVarNode iVisited) { 271 iVisited.accept(_Payload); 272 return null; 273 } 274 275 public Instruction visitCallNode(CallNode iVisited) { 276 iVisited.getReceiverNode().accept(this); 277 if(iVisited.getArgsNode() != null) { 278 iVisited.getArgsNode().accept(this); 279 } 280 if(iVisited.getIterNode() != null) { 281 iVisited.getIterNode().accept(this); 282 } 283 iVisited.accept(_Payload); 284 return null; 285 } 286 287 public Instruction visitCaseNode(CaseNode iVisited) { 288 iVisited.accept(_Payload); 289 return null; 290 } 291 292 public Instruction visitClassNode(ClassNode iVisited) { 293 iVisited.accept(_Payload); 294 if (iVisited.getSuperNode() != null) { 295 iVisited.getSuperNode().accept(this); 296 } 297 iVisited.getBodyNode().accept(this); 300 return null; 301 } 302 303 public Instruction visitColon2Node(Colon2Node iVisited) { 304 if (iVisited.getLeftNode() != null) { 305 iVisited.getLeftNode().accept(this); 306 } 307 iVisited.accept(_Payload); 308 return null; 309 } 310 311 public Instruction visitColon3Node(Colon3Node iVisited) { 312 iVisited.accept(_Payload); 313 return null; 314 } 315 316 public Instruction visitConstNode(ConstNode iVisited) { 317 iVisited.accept(_Payload); 318 return null; 319 } 320 321 public Instruction visitDAsgnNode(DAsgnNode iVisited) { 322 iVisited.accept(_Payload); 323 iVisited.getValueNode().accept(this); 324 return null; 325 } 326 327 public Instruction visitDRegxNode(DRegexpNode iVisited) { 328 iVisited.accept(_Payload); 329 return null; 330 } 331 332 public Instruction visitDStrNode(DStrNode iVisited) { 333 iVisited.accept(_Payload); 334 return null; 335 } 336 337 340 public Instruction visitDSymbolNode(DSymbolNode iVisited) { 341 iVisited.accept(_Payload); 342 return null; 343 } 344 345 public Instruction visitDVarNode(DVarNode iVisited) { 346 iVisited.accept(_Payload); 347 return null; 348 } 349 350 public Instruction visitDXStrNode(DXStrNode iVisited) { 351 iVisited.accept(_Payload); 352 return null; 353 } 354 355 public Instruction visitDefinedNode(DefinedNode iVisited) { 356 iVisited.accept(_Payload); 357 return null; 358 } 359 360 public Instruction visitDefnNode(DefnNode iVisited) { 361 iVisited.accept(_Payload); 362 iVisited.getBodyNode().accept(this); 363 return null; 364 } 365 366 public Instruction visitDefsNode(DefsNode iVisited) { 367 iVisited.accept(_Payload); 368 iVisited.getReceiverNode().accept(this); 369 iVisited.getBodyNode().accept(this); 370 return null; 371 } 372 373 public Instruction visitDotNode(DotNode iVisited) { 374 iVisited.accept(_Payload); 375 return null; 376 } 377 378 public Instruction visitEnsureNode(EnsureNode iVisited) { 379 iVisited.accept(_Payload); 380 return null; 381 } 382 383 public Instruction visitEvStrNode(EvStrNode iVisited) { 384 iVisited.accept(_Payload); 385 return null; 386 } 387 388 public Instruction visitFCallNode(FCallNode iVisited) { 389 iVisited.accept(_Payload); 390 if(iVisited.getArgsNode() != null) { 391 iVisited.getArgsNode().accept(this); 392 } 393 if(iVisited.getIterNode() != null) { 394 iVisited.getIterNode().accept(this); 395 } 396 return null; 397 } 398 399 public Instruction visitFalseNode(FalseNode iVisited) { 400 iVisited.accept(_Payload); 401 return null; 402 } 403 404 public Instruction visitFlipNode(FlipNode iVisited) { 405 iVisited.accept(_Payload); 406 return null; 407 } 408 409 public Instruction visitForNode(ForNode iVisited) { 410 iVisited.accept(_Payload); 411 return null; 412 } 413 414 public Instruction visitGlobalAsgnNode(GlobalAsgnNode iVisited) { 415 iVisited.accept(_Payload); 416 iVisited.getValueNode().accept(this); 417 return null; 418 } 419 420 public Instruction visitGlobalVarNode(GlobalVarNode iVisited) { 421 iVisited.accept(_Payload); 422 return null; 423 } 424 425 public Instruction visitHashNode(HashNode iVisited) { 426 iVisited.accept(_Payload); 427 return null; 428 } 429 430 public Instruction visitInstAsgnNode(InstAsgnNode iVisited) { 431 iVisited.accept(_Payload); 432 iVisited.getValueNode().accept(this); 433 return null; 434 } 435 436 public Instruction visitInstVarNode(InstVarNode iVisited) { 437 iVisited.accept(_Payload); 438 return null; 439 } 440 441 public Instruction visitIfNode(IfNode iVisited) { 442 iVisited.accept(_Payload); 443 iVisited.getCondition().accept(this); 444 iVisited.getThenBody().accept(this); 445 if (iVisited.getElseBody() != null) { 446 iVisited.getElseBody().accept(this); 447 } 448 return null; 449 } 450 451 public Instruction visitIterNode(IterNode iVisited) { 452 iVisited.accept(_Payload); 453 return null; 454 } 455 456 public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) { 457 iVisited.accept(_Payload); 458 iVisited.getValueNode().accept(this); 459 return null; 460 } 461 462 public Instruction visitLocalVarNode(LocalVarNode iVisited) { 463 iVisited.accept(_Payload); 464 return null; 465 } 466 467 public Instruction visitMultipleAsgnNode(MultipleAsgnNode iVisited) { 468 iVisited.accept(_Payload); 469 return null; 470 } 471 472 public Instruction visitMatch2Node(Match2Node iVisited) { 473 iVisited.accept(_Payload); 474 return null; 475 } 476 477 public Instruction visitMatch3Node(Match3Node iVisited) { 478 iVisited.accept(_Payload); 479 return null; 480 } 481 482 public Instruction visitMatchNode(MatchNode iVisited) { 483 iVisited.accept(_Payload); 484 return null; 485 } 486 487 public Instruction visitModuleNode(ModuleNode iVisited) { 488 iVisited.accept(_Payload); 489 iVisited.getBodyNode().accept(this); 490 return null; 491 } 492 493 public Instruction visitNewlineNode(NewlineNode iVisited) { 494 iVisited.accept(_Payload); 495 iVisited.getNextNode().accept(this); 496 return null; 497 } 498 499 public Instruction visitNextNode(NextNode iVisited) { 500 iVisited.accept(_Payload); 501 return null; 502 } 503 504 public Instruction visitNilNode(NilNode iVisited) { 505 iVisited.accept(_Payload); 506 return null; 507 } 508 509 public Instruction visitNotNode(NotNode iVisited) { 510 iVisited.accept(_Payload); 511 iVisited.getConditionNode().accept(this); 512 return null; 513 } 514 515 public Instruction visitNthRefNode(NthRefNode iVisited) { 516 iVisited.accept(_Payload); 517 return null; 518 } 519 520 public Instruction visitOpElementAsgnNode(OpElementAsgnNode iVisited) { 521 iVisited.accept(_Payload); 522 return null; 523 } 524 525 public Instruction visitOpAsgnNode(OpAsgnNode iVisited) { 526 iVisited.accept(_Payload); 527 return null; 528 } 529 530 public Instruction visitOpAsgnAndNode(OpAsgnAndNode iVisited) { 531 iVisited.accept(_Payload); 532 return null; 533 } 534 535 public Instruction visitOpAsgnOrNode(OpAsgnOrNode iVisited) { 536 iVisited.accept(_Payload); 537 return null; 538 } 539 540 public Instruction visitOptNNode(OptNNode iVisited) { 541 iVisited.accept(_Payload); 542 iVisited.getBodyNode().accept(this); 543 return null; 544 } 545 546 public Instruction visitOrNode(OrNode iVisited) { 547 iVisited.getFirstNode().accept(this); 548 iVisited.accept(_Payload); 549 iVisited.getSecondNode().accept(this); 550 return null; 551 } 552 553 public Instruction visitPostExeNode(PostExeNode iVisited) { 554 iVisited.accept(_Payload); 555 return null; 556 } 557 558 public Instruction visitRedoNode(RedoNode iVisited) { 559 iVisited.accept(_Payload); 560 return null; 561 } 562 563 public Instruction visitRescueBodyNode(RescueBodyNode iVisited) { 564 iVisited.accept(_Payload); 565 return null; 567 } 568 569 public Instruction visitRescueNode(RescueNode iVisited) { 570 iVisited.accept(_Payload); 571 580 return null; 581 } 582 583 public Instruction visitRetryNode(RetryNode iVisited) { 584 iVisited.accept(_Payload); 585 return null; 586 } 587 588 public Instruction visitRootNode(RootNode iVisited) { 589 iVisited.accept(_Payload); 590 iVisited.getBodyNode().accept(this); 591 return null; 592 } 593 594 public Instruction visitReturnNode(ReturnNode iVisited) { 595 iVisited.accept(_Payload); 596 return null; 597 } 598 599 public Instruction visitSClassNode(SClassNode iVisited) { 600 iVisited.accept(_Payload); 601 return null; 602 } 603 604 public Instruction visitSelfNode(SelfNode iVisited) { 605 iVisited.accept(_Payload); 606 return null; 607 } 608 609 public Instruction visitSplatNode(SplatNode iVisited) { 610 iVisited.accept(_Payload); 611 return null; 612 } 613 614 public Instruction visitStrNode(StrNode iVisited) { 615 iVisited.accept(_Payload); 616 return null; 617 } 618 619 public Instruction visitSValueNode(SValueNode iVisited) { 620 iVisited.accept(_Payload); 621 return null; 622 } 623 624 public Instruction visitSuperNode(SuperNode iVisited) { 625 iVisited.accept(_Payload); 626 return null; 627 } 628 629 public Instruction visitToAryNode(ToAryNode iVisited) { 630 iVisited.accept(_Payload); 631 return null; 632 } 633 634 public Instruction visitTrueNode(TrueNode iVisited) { 635 iVisited.accept(_Payload); 636 return null; 637 } 638 639 public Instruction visitUndefNode(UndefNode iVisited) { 640 iVisited.accept(_Payload); 641 return null; 642 } 643 644 public Instruction visitUntilNode(UntilNode iVisited) { 645 iVisited.accept(_Payload); 646 return null; 647 } 648 649 public Instruction visitVAliasNode(VAliasNode iVisited) { 650 iVisited.accept(_Payload); 651 return null; 652 } 653 654 public Instruction visitVCallNode(VCallNode iVisited) { 655 iVisited.accept(_Payload); 656 return null; 657 } 658 659 public Instruction visitWhenNode(WhenNode iVisited) { 660 iVisited.accept(_Payload); 661 665 return null; 666 } 667 668 public Instruction visitWhileNode(WhileNode iVisited) { 669 iVisited.accept(_Payload); 670 return null; 671 } 672 673 public Instruction visitXStrNode(XStrNode iVisited) { 674 iVisited.accept(_Payload); 675 return null; 676 } 677 678 public Instruction visitYieldNode(YieldNode iVisited) { 679 iVisited.accept(_Payload); 680 return null; 681 } 682 683 public Instruction visitZArrayNode(ZArrayNode iVisited) { 684 iVisited.accept(_Payload); 685 return null; 686 } 687 688 public Instruction visitZSuperNode(ZSuperNode iVisited) { 689 iVisited.accept(_Payload); 690 return null; 691 } 692 693 696 public Instruction visitBignumNode(BignumNode iVisited) { 697 iVisited.accept(_Payload); 698 return null; 699 } 700 701 704 public Instruction visitFixnumNode(FixnumNode iVisited) { 705 iVisited.accept(_Payload); 706 return null; 707 } 708 709 712 public Instruction visitFloatNode(FloatNode iVisited) { 713 iVisited.accept(_Payload); 714 return null; 715 } 716 717 720 public Instruction visitRegexpNode(RegexpNode iVisited) { 721 iVisited.accept(_Payload); 722 return null; 723 } 724 725 728 public Instruction visitSymbolNode(SymbolNode iVisited) { 729 iVisited.accept(_Payload); 730 return null; 731 } 732 } | Popular Tags |