Chromium Code Reviews| 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/functions.h" | 5 #include "tools/gn/functions.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1029 const ListNode* args_list, | 1029 const ListNode* args_list, |
| 1030 BlockNode* block, | 1030 BlockNode* block, |
| 1031 Err* err) { | 1031 Err* err) { |
| 1032 const Token& name = function->function(); | 1032 const Token& name = function->function(); |
| 1033 | 1033 |
| 1034 const FunctionInfoMap& function_map = GetFunctions(); | 1034 const FunctionInfoMap& function_map = GetFunctions(); |
| 1035 FunctionInfoMap::const_iterator found_function = | 1035 FunctionInfoMap::const_iterator found_function = |
| 1036 function_map.find(name.value()); | 1036 function_map.find(name.value()); |
| 1037 if (found_function == function_map.end()) { | 1037 if (found_function == function_map.end()) { |
| 1038 // No built-in function matching this, check for a template. | 1038 // No built-in function matching this, check for a template. |
| 1039 const Template* templ = | 1039 std::string template_name = function->function().value().as_string(); |
|
brucedawson
2016/07/14 17:39:26
Should be const std::string - or maybe const auto?
brettw
2016/07/14 19:26:38
I don't actually like "const" for local variables
| |
| 1040 scope->GetTemplate(function->function().value().as_string()); | 1040 const Template* templ = scope->GetTemplate(template_name); |
| 1041 if (templ) { | 1041 if (templ) { |
| 1042 Value args = args_list->Execute(scope, err); | 1042 Value args = args_list->Execute(scope, err); |
| 1043 if (err->has_error()) | 1043 if (err->has_error()) |
| 1044 return Value(); | 1044 return Value(); |
| 1045 return templ->Invoke(scope, function, args.list_value(), block, err); | 1045 return templ->Invoke(scope, function, template_name, args.list_value(), |
| 1046 block, err); | |
| 1046 } | 1047 } |
| 1047 | 1048 |
| 1048 *err = Err(name, "Unknown function."); | 1049 *err = Err(name, "Unknown function."); |
| 1049 return Value(); | 1050 return Value(); |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1052 if (found_function->second.self_evaluating_args_runner) { | 1053 if (found_function->second.self_evaluating_args_runner) { |
| 1053 // Self evaluating args functions are special weird built-ins like foreach. | 1054 // Self evaluating args functions are special weird built-ins like foreach. |
| 1054 // Rather than force them all to check that they have a block or no block | 1055 // Rather than force them all to check that they have a block or no block |
| 1055 // and risk bugs for new additions, check a whitelist here. | 1056 // and risk bugs for new additions, check a whitelist here. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 } | 1098 } |
| 1098 | 1099 |
| 1099 // Otherwise it's a no-block function. | 1100 // Otherwise it's a no-block function. |
| 1100 if (!VerifyNoBlockForFunctionCall(function, block, err)) | 1101 if (!VerifyNoBlockForFunctionCall(function, block, err)) |
| 1101 return Value(); | 1102 return Value(); |
| 1102 return found_function->second.no_block_runner(scope, function, | 1103 return found_function->second.no_block_runner(scope, function, |
| 1103 args.list_value(), err); | 1104 args.list_value(), err); |
| 1104 } | 1105 } |
| 1105 | 1106 |
| 1106 } // namespace functions | 1107 } // namespace functions |
| OLD | NEW |