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/input_conversion.h" | 5 #include "tools/gn/input_conversion.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 *parse_root_ptr = Parser::Parse(*tokens, err); // Will return a Block. | 67 *parse_root_ptr = Parser::Parse(*tokens, err); // Will return a Block. |
68 if (err->has_error()) | 68 if (err->has_error()) |
69 return Value(); | 69 return Value(); |
70 ParseNode* parse_root = parse_root_ptr->get(); // For nicer syntax below. | 70 ParseNode* parse_root = parse_root_ptr->get(); // For nicer syntax below. |
71 | 71 |
72 // It's valid for the result to be a null pointer, this just means that the | 72 // It's valid for the result to be a null pointer, this just means that the |
73 // script returned nothing. | 73 // script returned nothing. |
74 if (!parse_root) | 74 if (!parse_root) |
75 return Value(); | 75 return Value(); |
76 | 76 |
77 std::unique_ptr<Scope> scope(new Scope(settings)); | 77 std::unique_ptr<Scope> scope(new Scope(settings, {input_file})); |
78 Value result = parse_root->Execute(scope.get(), err); | 78 Value result = parse_root->Execute(scope.get(), err); |
79 if (err->has_error()) | 79 if (err->has_error()) |
80 return Value(); | 80 return Value(); |
81 | 81 |
82 // When we want the result as a scope, the result is actually the scope | 82 // When we want the result as a scope, the result is actually the scope |
83 // we made, rather than the result of running the block (which will be empty). | 83 // we made, rather than the result of running the block (which will be empty). |
84 if (what == PARSE_SCOPE) { | 84 if (what == PARSE_SCOPE) { |
85 DCHECK(result.type() == Value::NONE); | 85 DCHECK(result.type() == Value::NONE); |
86 result = Value(origin, std::move(scope)); | 86 result = Value(origin, std::move(scope)); |
87 } | 87 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const ParseNode* origin, | 204 const ParseNode* origin, |
205 const Value& input_conversion_value, | 205 const Value& input_conversion_value, |
206 Err* err) { | 206 Err* err) { |
207 if (input_conversion_value.type() == Value::NONE) | 207 if (input_conversion_value.type() == Value::NONE) |
208 return Value(); // Allow null inputs to mean discard the result. | 208 return Value(); // Allow null inputs to mean discard the result. |
209 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) | 209 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) |
210 return Value(); | 210 return Value(); |
211 return DoConvertInputToValue(settings, input, origin, input_conversion_value, | 211 return DoConvertInputToValue(settings, input, origin, input_conversion_value, |
212 input_conversion_value.string_value(), err); | 212 input_conversion_value.string_value(), err); |
213 } | 213 } |
OLD | NEW |