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

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

Issue 2187523003: Allow creation and modification of scopes in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments 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
« no previous file with comments | « tools/gn/command_help.cc ('k') | tools/gn/function_forward_variables_from.cc » ('j') | 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/err.h" 5 #include "tools/gn/err.h"
6 #include "tools/gn/functions.h" 6 #include "tools/gn/functions.h"
7 #include "tools/gn/parse_node_value_adapter.h" 7 #include "tools/gn/parse_node_value_adapter.h"
8 #include "tools/gn/parse_tree.h" 8 #include "tools/gn/parse_tree.h"
9 #include "tools/gn/scope.h" 9 #include "tools/gn/scope.h"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 scope->SetValue(loop_var, cur, function); 88 scope->SetValue(loop_var, cur, function);
89 block->Execute(scope, err); 89 block->Execute(scope, err);
90 if (err->has_error()) 90 if (err->has_error())
91 return Value(); 91 return Value();
92 } 92 }
93 93
94 // Put back loop var. 94 // Put back loop var.
95 if (old_loop_value_ptr) { 95 if (old_loop_value_ptr) {
96 // Put back old value. Use the copy we made, rather than use the pointer, 96 // Put back old value. Use the copy we made, rather than use the pointer,
97 // which will probably point to the new value now in the scope. 97 // which will probably point to the new value now in the scope.
98 scope->SetValue(loop_var, old_loop_value, old_loop_value.origin()); 98 scope->SetValue(loop_var, std::move(old_loop_value),
99 old_loop_value.origin());
99 } else { 100 } else {
100 // Loop variable was undefined before loop, delete it. 101 // Loop variable was undefined before loop, delete it.
101 scope->RemoveIdentifier(loop_var); 102 scope->RemoveIdentifier(loop_var);
102 } 103 }
103 104
104 return Value(); 105 return Value();
105 } 106 }
106 107
107 } // namespace functions 108 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/command_help.cc ('k') | tools/gn/function_forward_variables_from.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698