| 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/stl_util.h" | 8 #include "base/stl_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" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // FLags set in the mode_flags_ of a scope. If a bit is set, it applies | 14 // FLags set in the mode_flags_ of a scope. If a bit is set, it applies |
| 15 // recursively to all dependent scopes. | 15 // recursively to all dependent scopes. |
| 16 const unsigned kProcessingBuildConfigFlag = 1; | 16 const unsigned kProcessingBuildConfigFlag = 1; |
| 17 const unsigned kProcessingImportFlag = 2; | 17 const unsigned kProcessingImportFlag = 2; |
| 18 | 18 |
| 19 // Returns true if this variable name should be considered private. Private | 19 // Returns true if this variable name should be considered private. Private |
| 20 // values start with an underscore, and are not imported from "gni" files | 20 // values start with an underscore, and are not imported from "gni" files |
| 21 // when processing an import. | 21 // when processing an import. |
| 22 bool IsPrivateVar(const base::StringPiece& name) { | 22 bool IsPrivateVar(const base::StringPiece& name) { |
| 23 return name.empty() || name[0] == '_'; | 23 return name.empty() || name[0] == '_'; |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 |
| 29 Scope::ProgrammaticProvider::~ProgrammaticProvider() { |
| 30 scope_->RemoveProvider(this); |
| 31 } |
| 32 |
| 28 Scope::Scope(const Settings* settings) | 33 Scope::Scope(const Settings* settings) |
| 29 : const_containing_(nullptr), | 34 : const_containing_(nullptr), |
| 30 mutable_containing_(nullptr), | 35 mutable_containing_(nullptr), |
| 31 settings_(settings), | 36 settings_(settings), |
| 32 mode_flags_(0), | 37 mode_flags_(0), |
| 33 item_collector_(nullptr) { | 38 item_collector_(nullptr) { |
| 34 } | 39 } |
| 35 | 40 |
| 36 Scope::Scope(Scope* parent) | 41 Scope::Scope(Scope* parent) |
| 37 : const_containing_(nullptr), | 42 : const_containing_(nullptr), |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 468 } |
| 464 | 469 |
| 465 void Scope::AddProvider(ProgrammaticProvider* p) { | 470 void Scope::AddProvider(ProgrammaticProvider* p) { |
| 466 programmatic_providers_.insert(p); | 471 programmatic_providers_.insert(p); |
| 467 } | 472 } |
| 468 | 473 |
| 469 void Scope::RemoveProvider(ProgrammaticProvider* p) { | 474 void Scope::RemoveProvider(ProgrammaticProvider* p) { |
| 470 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); | 475 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); |
| 471 programmatic_providers_.erase(p); | 476 programmatic_providers_.erase(p); |
| 472 } | 477 } |
| OLD | NEW |