OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/parser.h" | 5 #include "tools/gn/parser.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 pre->push_back(root); | 664 pre->push_back(root); |
665 | 665 |
666 if (const AccessorNode* accessor = root->AsAccessor()) { | 666 if (const AccessorNode* accessor = root->AsAccessor()) { |
667 TraverseOrder(accessor->index(), pre, post); | 667 TraverseOrder(accessor->index(), pre, post); |
668 TraverseOrder(accessor->member(), pre, post); | 668 TraverseOrder(accessor->member(), pre, post); |
669 } else if (const BinaryOpNode* binop = root->AsBinaryOp()) { | 669 } else if (const BinaryOpNode* binop = root->AsBinaryOp()) { |
670 TraverseOrder(binop->left(), pre, post); | 670 TraverseOrder(binop->left(), pre, post); |
671 TraverseOrder(binop->right(), pre, post); | 671 TraverseOrder(binop->right(), pre, post); |
672 } else if (const BlockNode* block = root->AsBlock()) { | 672 } else if (const BlockNode* block = root->AsBlock()) { |
673 for (const auto& statement : block->statements()) | 673 for (const auto& statement : block->statements()) |
674 TraverseOrder(statement, pre, post); | 674 TraverseOrder(statement.get(), pre, post); |
675 TraverseOrder(block->End(), pre, post); | 675 TraverseOrder(block->End(), pre, post); |
676 } else if (const ConditionNode* condition = root->AsConditionNode()) { | 676 } else if (const ConditionNode* condition = root->AsConditionNode()) { |
677 TraverseOrder(condition->condition(), pre, post); | 677 TraverseOrder(condition->condition(), pre, post); |
678 TraverseOrder(condition->if_true(), pre, post); | 678 TraverseOrder(condition->if_true(), pre, post); |
679 TraverseOrder(condition->if_false(), pre, post); | 679 TraverseOrder(condition->if_false(), pre, post); |
680 } else if (const FunctionCallNode* func_call = root->AsFunctionCall()) { | 680 } else if (const FunctionCallNode* func_call = root->AsFunctionCall()) { |
681 TraverseOrder(func_call->args(), pre, post); | 681 TraverseOrder(func_call->args(), pre, post); |
682 TraverseOrder(func_call->block(), pre, post); | 682 TraverseOrder(func_call->block(), pre, post); |
683 } else if (root->AsIdentifier()) { | 683 } else if (root->AsIdentifier()) { |
684 // Nothing. | 684 // Nothing. |
685 } else if (const ListNode* list = root->AsList()) { | 685 } else if (const ListNode* list = root->AsList()) { |
686 for (const auto& node : list->contents()) | 686 for (const auto& node : list->contents()) |
687 TraverseOrder(node, pre, post); | 687 TraverseOrder(node.get(), pre, post); |
688 TraverseOrder(list->End(), pre, post); | 688 TraverseOrder(list->End(), pre, post); |
689 } else if (root->AsLiteral()) { | 689 } else if (root->AsLiteral()) { |
690 // Nothing. | 690 // Nothing. |
691 } else if (const UnaryOpNode* unaryop = root->AsUnaryOp()) { | 691 } else if (const UnaryOpNode* unaryop = root->AsUnaryOp()) { |
692 TraverseOrder(unaryop->operand(), pre, post); | 692 TraverseOrder(unaryop->operand(), pre, post); |
693 } else if (root->AsBlockComment()) { | 693 } else if (root->AsBlockComment()) { |
694 // Nothing. | 694 // Nothing. |
695 } else if (root->AsEnd()) { | 695 } else if (root->AsEnd()) { |
696 // Nothing. | 696 // Nothing. |
697 } else { | 697 } else { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 break; | 761 break; |
762 } | 762 } |
763 } | 763 } |
764 | 764 |
765 // Suffix comments were assigned in reverse, so if there were multiple on | 765 // Suffix comments were assigned in reverse, so if there were multiple on |
766 // the same node, they need to be reversed. | 766 // the same node, they need to be reversed. |
767 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) | 767 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) |
768 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); | 768 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); |
769 } | 769 } |
770 } | 770 } |
OLD | NEW |