Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: tools/gn/scope.cc

Issue 2224343003: GN: Throw an error overwriting a nonempty scope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« tools/gn/operators.cc ('K') | « tools/gn/scope.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« tools/gn/operators.cc ('K') | « tools/gn/scope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698