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" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 // Be careful to delete any pointer we're about to clobber. | 376 // Be careful to delete any pointer we're about to clobber. |
377 dest->templates_[current_name] = pair.second; | 377 dest->templates_[current_name] = pair.second; |
378 } | 378 } |
379 | 379 |
380 return true; | 380 return true; |
381 } | 381 } |
382 | 382 |
383 scoped_ptr<Scope> Scope::MakeClosure() const { | 383 std::unique_ptr<Scope> Scope::MakeClosure() const { |
384 scoped_ptr<Scope> result; | 384 std::unique_ptr<Scope> result; |
385 if (const_containing_) { | 385 if (const_containing_) { |
386 // We reached the top of the mutable scope stack. The result scope just | 386 // We reached the top of the mutable scope stack. The result scope just |
387 // references the const scope (which will never change). | 387 // references the const scope (which will never change). |
388 result.reset(new Scope(const_containing_)); | 388 result.reset(new Scope(const_containing_)); |
389 } else if (mutable_containing_) { | 389 } else if (mutable_containing_) { |
390 // There are more nested mutable scopes. Recursively go up the stack to | 390 // There are more nested mutable scopes. Recursively go up the stack to |
391 // get the closure. | 391 // get the closure. |
392 result = mutable_containing_->MakeClosure(); | 392 result = mutable_containing_->MakeClosure(); |
393 } else { | 393 } else { |
394 // This is a standalone scope, just copy it. | 394 // This is a standalone scope, just copy it. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 512 } |
513 | 513 |
514 void Scope::AddProvider(ProgrammaticProvider* p) { | 514 void Scope::AddProvider(ProgrammaticProvider* p) { |
515 programmatic_providers_.insert(p); | 515 programmatic_providers_.insert(p); |
516 } | 516 } |
517 | 517 |
518 void Scope::RemoveProvider(ProgrammaticProvider* p) { | 518 void Scope::RemoveProvider(ProgrammaticProvider* p) { |
519 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); | 519 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); |
520 programmatic_providers_.erase(p); | 520 programmatic_providers_.erase(p); |
521 } | 521 } |
OLD | NEW |