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

Unified Diff: tools/gn/parse_tree.cc

Issue 591373002: gn: start of format command (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-more-comment-stuff
Patch Set: change 'copyright header block' to 'standard header block' for android_webview/tools/check_licenses… Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/parse_tree.h ('k') | tools/gn/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parse_tree.cc
diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc
index fe26c15cdc8fec87d5db6c0e05754fd55b413b5b..35dccee9eb3cd0aef1a4029f83ca0a1223ac148f 100644
--- a/tools/gn/parse_tree.cc
+++ b/tools/gn/parse_tree.cc
@@ -47,6 +47,7 @@ const IdentifierNode* ParseNode::AsIdentifier() const { return NULL; }
const ListNode* ParseNode::AsList() const { return NULL; }
const LiteralNode* ParseNode::AsLiteral() const { return NULL; }
const UnaryOpNode* ParseNode::AsUnaryOp() const { return NULL; }
+const BlockCommentNode* ParseNode::AsBlockComment() const { return NULL; }
Comments* ParseNode::comments_mutable() {
if (!comments_)
@@ -457,14 +458,16 @@ const ListNode* ListNode::AsList() const {
Value ListNode::Execute(Scope* scope, Err* err) const {
Value result_value(this, Value::LIST);
std::vector<Value>& results = result_value.list_value();
- results.resize(contents_.size());
+ results.reserve(contents_.size());
for (size_t i = 0; i < contents_.size(); i++) {
const ParseNode* cur = contents_[i];
- results[i] = cur->Execute(scope, err);
+ if (cur->AsBlockComment())
+ continue;
+ results.push_back(cur->Execute(scope, err));
if (err->has_error())
return Value();
- if (results[i].type() == Value::NONE) {
+ if (results.back().type() == Value::NONE) {
*err = cur->MakeErrorDescribing(
"This does not evaluate to a value.",
"I can't do something with nothing.");
@@ -577,3 +580,33 @@ void UnaryOpNode::Print(std::ostream& out, int indent) const {
PrintComments(out, indent);
operand_->Print(out, indent + 1);
}
+
+// BlockCommentNode ------------------------------------------------------------
+
+BlockCommentNode::BlockCommentNode() {
+}
+
+BlockCommentNode::~BlockCommentNode() {
+}
+
+const BlockCommentNode* BlockCommentNode::AsBlockComment() const {
+ return this;
+}
+
+Value BlockCommentNode::Execute(Scope* scope, Err* err) const {
+ return Value();
+}
+
+LocationRange BlockCommentNode::GetRange() const {
+ return comment_.range();
+}
+
+Err BlockCommentNode::MakeErrorDescribing(const std::string& msg,
+ const std::string& help) const {
+ return Err(comment_, msg, help);
+}
+
+void BlockCommentNode::Print(std::ostream& out, int indent) const {
+ out << IndentFor(indent) << "BLOCK_COMMENT(" << comment_.value() << ")\n";
+ PrintComments(out, indent);
+}
« no previous file with comments | « tools/gn/parse_tree.h ('k') | tools/gn/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698