| 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/parse_tree.h" | 5 #include "tools/gn/parse_tree.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 } | 480 } |
| 481 | 481 |
| 482 IdentifierNode::~IdentifierNode() { | 482 IdentifierNode::~IdentifierNode() { |
| 483 } | 483 } |
| 484 | 484 |
| 485 const IdentifierNode* IdentifierNode::AsIdentifier() const { | 485 const IdentifierNode* IdentifierNode::AsIdentifier() const { |
| 486 return this; | 486 return this; |
| 487 } | 487 } |
| 488 | 488 |
| 489 Value IdentifierNode::Execute(Scope* scope, Err* err) const { | 489 Value IdentifierNode::Execute(Scope* scope, Err* err) const { |
| 490 const Value* value = scope->GetValue(value_.value(), true); | 490 const Scope* found_in_scope = nullptr; |
| 491 const Value* value = scope->GetValueWithScope(value_.value(), true, |
| 492 &found_in_scope); |
| 491 Value result; | 493 Value result; |
| 492 if (!value) { | 494 if (!value) { |
| 493 *err = MakeErrorDescribing("Undefined identifier"); | 495 *err = MakeErrorDescribing("Undefined identifier"); |
| 494 return result; | 496 return result; |
| 495 } | 497 } |
| 496 | 498 |
| 499 if (!EnsureNotReadingFromSameDeclareArgs(this, scope, found_in_scope, err)) |
| 500 return result; |
| 501 |
| 497 result = *value; | 502 result = *value; |
| 498 result.set_origin(this); | 503 result.set_origin(this); |
| 499 return result; | 504 return result; |
| 500 } | 505 } |
| 501 | 506 |
| 502 LocationRange IdentifierNode::GetRange() const { | 507 LocationRange IdentifierNode::GetRange() const { |
| 503 return value_.range(); | 508 return value_.range(); |
| 504 } | 509 } |
| 505 | 510 |
| 506 Err IdentifierNode::MakeErrorDescribing(const std::string& msg, | 511 Err IdentifierNode::MakeErrorDescribing(const std::string& msg, |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 872 |
| 868 Err EndNode::MakeErrorDescribing(const std::string& msg, | 873 Err EndNode::MakeErrorDescribing(const std::string& msg, |
| 869 const std::string& help) const { | 874 const std::string& help) const { |
| 870 return Err(value_, msg, help); | 875 return Err(value_, msg, help); |
| 871 } | 876 } |
| 872 | 877 |
| 873 void EndNode::Print(std::ostream& out, int indent) const { | 878 void EndNode::Print(std::ostream& out, int indent) const { |
| 874 out << IndentFor(indent) << "END(" << value_.value() << ")\n"; | 879 out << IndentFor(indent) << "END(" << value_.value() << ")\n"; |
| 875 PrintComments(out, indent); | 880 PrintComments(out, indent); |
| 876 } | 881 } |
| OLD | NEW |