| 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 <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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 statements_[i]->Print(out, indent + 1); | 186 statements_[i]->Print(out, indent + 1); |
| 187 } | 187 } |
| 188 | 188 |
| 189 Value BlockNode::ExecuteBlockInScope(Scope* our_scope, Err* err) const { | 189 Value BlockNode::ExecuteBlockInScope(Scope* our_scope, Err* err) const { |
| 190 for (size_t i = 0; i < statements_.size() && !err->has_error(); i++) { | 190 for (size_t i = 0; i < statements_.size() && !err->has_error(); i++) { |
| 191 // Check for trying to execute things with no side effects in a block. | 191 // Check for trying to execute things with no side effects in a block. |
| 192 const ParseNode* cur = statements_[i]; | 192 const ParseNode* cur = statements_[i]; |
| 193 if (cur->AsList() || cur->AsLiteral() || cur->AsUnaryOp() || | 193 if (cur->AsList() || cur->AsLiteral() || cur->AsUnaryOp() || |
| 194 cur->AsIdentifier()) { | 194 cur->AsIdentifier()) { |
| 195 *err = cur->MakeErrorDescribing( | 195 *err = cur->MakeErrorDescribing( |
| 196 "This statment has no effect.", | 196 "This statement has no effect.", |
| 197 "Either delete it or do something with the result."); | 197 "Either delete it or do something with the result."); |
| 198 return Value(); | 198 return Value(); |
| 199 } | 199 } |
| 200 cur->Execute(our_scope, err); | 200 cur->Execute(our_scope, err); |
| 201 } | 201 } |
| 202 return Value(); | 202 return Value(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // ConditionNode -------------------------------------------------------------- | 205 // ConditionNode -------------------------------------------------------------- |
| 206 | 206 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 461 |
| 462 Err UnaryOpNode::MakeErrorDescribing(const std::string& msg, | 462 Err UnaryOpNode::MakeErrorDescribing(const std::string& msg, |
| 463 const std::string& help) const { | 463 const std::string& help) const { |
| 464 return Err(op_, msg, help); | 464 return Err(op_, msg, help); |
| 465 } | 465 } |
| 466 | 466 |
| 467 void UnaryOpNode::Print(std::ostream& out, int indent) const { | 467 void UnaryOpNode::Print(std::ostream& out, int indent) const { |
| 468 out << IndentFor(indent) << "UNARY(" << op_.value() << ")\n"; | 468 out << IndentFor(indent) << "UNARY(" << op_.value() << ")\n"; |
| 469 operand_->Print(out, indent + 1); | 469 operand_->Print(out, indent + 1); |
| 470 } | 470 } |
| OLD | NEW |