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

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

Issue 439513003: Improve GN value origins for error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/gn/parse_tree_unittest.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/parse_tree.h" 5 #include "tools/gn/parse_tree.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 366 }
367 367
368 IdentifierNode::~IdentifierNode() { 368 IdentifierNode::~IdentifierNode() {
369 } 369 }
370 370
371 const IdentifierNode* IdentifierNode::AsIdentifier() const { 371 const IdentifierNode* IdentifierNode::AsIdentifier() const {
372 return this; 372 return this;
373 } 373 }
374 374
375 Value IdentifierNode::Execute(Scope* scope, Err* err) const { 375 Value IdentifierNode::Execute(Scope* scope, Err* err) const {
376 const Value* result = scope->GetValue(value_.value(), true); 376 const Value* value = scope->GetValue(value_.value(), true);
377 if (!result) { 377 Value result;
378 if (!value) {
378 *err = MakeErrorDescribing("Undefined identifier"); 379 *err = MakeErrorDescribing("Undefined identifier");
379 return Value(); 380 return result;
380 } 381 }
381 return *result; 382
383 result = *value;
384 result.set_origin(this);
385 return result;
382 } 386 }
383 387
384 LocationRange IdentifierNode::GetRange() const { 388 LocationRange IdentifierNode::GetRange() const {
385 return value_.range(); 389 return value_.range();
386 } 390 }
387 391
388 Err IdentifierNode::MakeErrorDescribing(const std::string& msg, 392 Err IdentifierNode::MakeErrorDescribing(const std::string& msg,
389 const std::string& help) const { 393 const std::string& help) const {
390 return Err(value_, msg, help); 394 return Err(value_, msg, help);
391 } 395 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 524
521 Err UnaryOpNode::MakeErrorDescribing(const std::string& msg, 525 Err UnaryOpNode::MakeErrorDescribing(const std::string& msg,
522 const std::string& help) const { 526 const std::string& help) const {
523 return Err(op_, msg, help); 527 return Err(op_, msg, help);
524 } 528 }
525 529
526 void UnaryOpNode::Print(std::ostream& out, int indent) const { 530 void UnaryOpNode::Print(std::ostream& out, int indent) const {
527 out << IndentFor(indent) << "UNARY(" << op_.value() << ")\n"; 531 out << IndentFor(indent) << "UNARY(" << op_.value() << ")\n";
528 operand_->Print(out, indent + 1); 532 operand_->Print(out, indent + 1);
529 } 533 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/parse_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698