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/operators.h" | 5 #include "tools/gn/operators.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
9 #include "tools/gn/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/scope.h" | 10 #include "tools/gn/scope.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // list item. This is to detect the case where you write | 120 // list item. This is to detect the case where you write |
121 // defines = ["FOO"] | 121 // defines = ["FOO"] |
122 // and you overwrote inherited ones, when instead you mean to append: | 122 // and you overwrote inherited ones, when instead you mean to append: |
123 // defines += ["FOO"] | 123 // defines += ["FOO"] |
124 if (old_value->type() == Value::LIST && | 124 if (old_value->type() == Value::LIST && |
125 !old_value->list_value().empty() && | 125 !old_value->list_value().empty() && |
126 right.type() == Value::LIST && | 126 right.type() == Value::LIST && |
127 !right.list_value().empty()) { | 127 !right.list_value().empty()) { |
128 *err = Err(op_node->left()->GetRange(), "Replacing nonempty list.", | 128 *err = Err(op_node->left()->GetRange(), "Replacing nonempty list.", |
129 std::string("This overwrites a previously-defined nonempty list ") + | 129 std::string("This overwrites a previously-defined nonempty list ") + |
130 "(length " + base::IntToString(old_value->list_value().size()) + | 130 "(length " + |
131 ")."); | 131 base::IntToString(static_cast<int>(old_value->list_value().size())) |
| 132 + ")."); |
132 err->AppendSubErr(Err(*old_value, "for previous definition", | 133 err->AppendSubErr(Err(*old_value, "for previous definition", |
133 "with another one (length " + | 134 "with another one (length " + |
134 base::IntToString(right.list_value().size()) + "). Did you mean " + | 135 base::IntToString(static_cast<int>(right.list_value().size())) + |
| 136 "). Did you mean " + |
135 "\"+=\" to append instead? If you\nreally want to do this, do\n " + | 137 "\"+=\" to append instead? If you\nreally want to do this, do\n " + |
136 left.value().as_string() + " = []\nbefore reassigning.")); | 138 left.value().as_string() + " = []\nbefore reassigning.")); |
137 return Value(); | 139 return Value(); |
138 } | 140 } |
139 } | 141 } |
140 } | 142 } |
141 if (err->has_error()) | 143 if (err->has_error()) |
142 return Value(); | 144 return Value(); |
143 | 145 |
144 if (right.type() == Value::LIST && left.value() == kSourcesName) { | 146 if (right.type() == Value::LIST && left.value() == kSourcesName) { |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 return ExecuteLess(scope, op_node, left_value, right_value, err); | 582 return ExecuteLess(scope, op_node, left_value, right_value, err); |
581 | 583 |
582 // ||, &&. | 584 // ||, &&. |
583 if (op.type() == Token::BOOLEAN_OR) | 585 if (op.type() == Token::BOOLEAN_OR) |
584 return ExecuteOr(scope, op_node, left_value, right_value, err); | 586 return ExecuteOr(scope, op_node, left_value, right_value, err); |
585 if (op.type() == Token::BOOLEAN_AND) | 587 if (op.type() == Token::BOOLEAN_AND) |
586 return ExecuteAnd(scope, op_node, left_value, right_value, err); | 588 return ExecuteAnd(scope, op_node, left_value, right_value, err); |
587 | 589 |
588 return Value(); | 590 return Value(); |
589 } | 591 } |
OLD | NEW |