| 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/scope.h" | 5 #include "tools/gn/scope.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "tools/gn/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
| 10 #include "tools/gn/template.h" | 10 #include "tools/gn/template.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 Scope::~Scope() { | 66 Scope::~Scope() { |
| 67 } | 67 } |
| 68 | 68 |
| 69 void Scope::DetachFromContaining() { | 69 void Scope::DetachFromContaining() { |
| 70 const_containing_ = nullptr; | 70 const_containing_ = nullptr; |
| 71 mutable_containing_ = nullptr; | 71 mutable_containing_ = nullptr; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool Scope::HasValues(SearchNested search_nested) const { |
| 75 DCHECK(search_nested == SEARCH_CURRENT); |
| 76 return !values_.empty(); |
| 77 } |
| 78 |
| 74 const Value* Scope::GetValue(const base::StringPiece& ident, | 79 const Value* Scope::GetValue(const base::StringPiece& ident, |
| 75 bool counts_as_used) { | 80 bool counts_as_used) { |
| 76 // First check for programmatically-provided values. | 81 // First check for programmatically-provided values. |
| 77 for (auto* provider : programmatic_providers_) { | 82 for (auto* provider : programmatic_providers_) { |
| 78 const Value* v = provider->GetProgrammaticValue(ident); | 83 const Value* v = provider->GetProgrammaticValue(ident); |
| 79 if (v) | 84 if (v) |
| 80 return v; | 85 return v; |
| 81 } | 86 } |
| 82 | 87 |
| 83 RecordMap::iterator found = values_.find(ident); | 88 RecordMap::iterator found = values_.find(ident); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return false; | 519 return false; |
| 515 for (const auto& pair : a) { | 520 for (const auto& pair : a) { |
| 516 const auto& found_b = b.find(pair.first); | 521 const auto& found_b = b.find(pair.first); |
| 517 if (found_b == b.end()) | 522 if (found_b == b.end()) |
| 518 return false; // Item in 'a' but not 'b'. | 523 return false; // Item in 'a' but not 'b'. |
| 519 if (pair.second.value != found_b->second.value) | 524 if (pair.second.value != found_b->second.value) |
| 520 return false; // Values for variable in 'a' and 'b' are different. | 525 return false; // Values for variable in 'a' and 'b' are different. |
| 521 } | 526 } |
| 522 return true; | 527 return true; |
| 523 } | 528 } |
| OLD | NEW |