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

Unified Diff: tools/gn/parse_node_value_adapter.cc

Issue 2095043005: Add GN split_list function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 6 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_node_value_adapter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parse_node_value_adapter.cc
diff --git a/tools/gn/parse_node_value_adapter.cc b/tools/gn/parse_node_value_adapter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..82f6f799e3f2dc49479cdd1d82a8f56577542b6c
--- /dev/null
+++ b/tools/gn/parse_node_value_adapter.cc
@@ -0,0 +1,47 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/gn/parse_node_value_adapter.h"
+
+#include "tools/gn/parse_tree.h"
+#include "tools/gn/scope.h"
+
+ParseNodeValueAdapter::ParseNodeValueAdapter() : ref_(nullptr) {
+}
+
+ParseNodeValueAdapter::~ParseNodeValueAdapter() {
+}
+
+
+bool ParseNodeValueAdapter::Init(Scope* scope,
+ const ParseNode* node,
+ Err* err) {
+ const IdentifierNode* identifier = node->AsIdentifier();
+ if (identifier) {
+ ref_ = scope->GetValue(identifier->value().value(), true);
+ if (!ref_) {
+ identifier->MakeErrorDescribing("Undefined identifier");
+ return false;
+ }
+ return true;
+ }
+
+ temporary_ = node->Execute(scope, err);
+ return !err->has_error();
+}
+
+bool ParseNodeValueAdapter::InitForType(Scope* scope,
+ const ParseNode* node,
+ Value::Type type,
+ Err* err) {
+ if (!Init(scope, node, err))
+ return false;
+ if (get().VerifyTypeIs(type, err))
+ return true;
+
+ // Fix up the error range (see class comment in the header file) to be the
+ // identifier node rather than the original value.
+ *err = Err(node, err->message(), err->help_text());
+ return false;
+}
« no previous file with comments | « tools/gn/parse_node_value_adapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698