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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 mode_flags_(0), | 62 mode_flags_(0), |
63 item_collector_(nullptr) { | 63 item_collector_(nullptr) { |
64 } | 64 } |
65 | 65 |
66 Scope::~Scope() { | 66 Scope::~Scope() { |
67 } | 67 } |
68 | 68 |
69 const Value* Scope::GetValue(const base::StringPiece& ident, | 69 const Value* Scope::GetValue(const base::StringPiece& ident, |
70 bool counts_as_used) { | 70 bool counts_as_used) { |
71 // First check for programmatically-provided values. | 71 // First check for programmatically-provided values. |
72 for (const auto& provider : programmatic_providers_) { | 72 for (auto* provider : programmatic_providers_) { |
73 const Value* v = provider->GetProgrammaticValue(ident); | 73 const Value* v = provider->GetProgrammaticValue(ident); |
74 if (v) | 74 if (v) |
75 return v; | 75 return v; |
76 } | 76 } |
77 | 77 |
78 RecordMap::iterator found = values_.find(ident); | 78 RecordMap::iterator found = values_.find(ident); |
79 if (found != values_.end()) { | 79 if (found != values_.end()) { |
80 if (counts_as_used) | 80 if (counts_as_used) |
81 found->second.used = true; | 81 found->second.used = true; |
82 return &found->second.value; | 82 return &found->second.value; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 507 } |
508 | 508 |
509 void Scope::AddProvider(ProgrammaticProvider* p) { | 509 void Scope::AddProvider(ProgrammaticProvider* p) { |
510 programmatic_providers_.insert(p); | 510 programmatic_providers_.insert(p); |
511 } | 511 } |
512 | 512 |
513 void Scope::RemoveProvider(ProgrammaticProvider* p) { | 513 void Scope::RemoveProvider(ProgrammaticProvider* p) { |
514 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); | 514 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); |
515 programmatic_providers_.erase(p); | 515 programmatic_providers_.erase(p); |
516 } | 516 } |
OLD | NEW |