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/parse_tree.h" | 5 #include "tools/gn/parse_tree.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "tools/gn/functions.h" | 11 #include "tools/gn/functions.h" |
12 #include "tools/gn/operators.h" | 12 #include "tools/gn/operators.h" |
13 #include "tools/gn/scope.h" | 13 #include "tools/gn/scope.h" |
14 #include "tools/gn/string_utils.h" | 14 #include "tools/gn/string_utils.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 std::string IndentFor(int value) { | 18 std::string IndentFor(int value) { |
19 return std::string(value, ' '); | 19 return std::string(value, ' '); |
20 } | 20 } |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 Comments::Comments() { | 24 Comments::Comments() { |
25 } | 25 } |
26 | 26 |
27 Comments::~Comments() { | 27 Comments::~Comments() { |
28 } | 28 } |
29 | 29 |
| 30 void Comments::ReverseSuffix() { |
| 31 for (int i = 0, j = static_cast<int>(suffix_.size() - 1); i < j; ++i, --j) |
| 32 std::swap(suffix_[i], suffix_[j]); |
| 33 } |
| 34 |
30 ParseNode::ParseNode() { | 35 ParseNode::ParseNode() { |
31 } | 36 } |
32 | 37 |
33 ParseNode::~ParseNode() { | 38 ParseNode::~ParseNode() { |
34 } | 39 } |
35 | 40 |
36 const AccessorNode* ParseNode::AsAccessor() const { return NULL; } | 41 const AccessorNode* ParseNode::AsAccessor() const { return NULL; } |
37 const BinaryOpNode* ParseNode::AsBinaryOp() const { return NULL; } | 42 const BinaryOpNode* ParseNode::AsBinaryOp() const { return NULL; } |
38 const BlockNode* ParseNode::AsBlock() const { return NULL; } | 43 const BlockNode* ParseNode::AsBlock() const { return NULL; } |
39 const ConditionNode* ParseNode::AsConditionNode() const { return NULL; } | 44 const ConditionNode* ParseNode::AsConditionNode() const { return NULL; } |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 Err UnaryOpNode::MakeErrorDescribing(const std::string& msg, | 570 Err UnaryOpNode::MakeErrorDescribing(const std::string& msg, |
566 const std::string& help) const { | 571 const std::string& help) const { |
567 return Err(op_, msg, help); | 572 return Err(op_, msg, help); |
568 } | 573 } |
569 | 574 |
570 void UnaryOpNode::Print(std::ostream& out, int indent) const { | 575 void UnaryOpNode::Print(std::ostream& out, int indent) const { |
571 out << IndentFor(indent) << "UNARY(" << op_.value() << ")\n"; | 576 out << IndentFor(indent) << "UNARY(" << op_.value() << ")\n"; |
572 PrintComments(out, indent); | 577 PrintComments(out, indent); |
573 operand_->Print(out, indent + 1); | 578 operand_->Print(out, indent + 1); |
574 } | 579 } |
OLD | NEW |