| // 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() = default; |
| bool ParseNodeValueAdapter::Init(Scope* scope, |
| const IdentifierNode* identifier = node->AsIdentifier(); |
| ref_ = scope->GetValue(identifier->value().value(), true); |
| identifier->MakeErrorDescribing("Undefined identifier"); |
| temporary_ = node->Execute(scope, err); |
| return !err->has_error(); |
| bool ParseNodeValueAdapter::InitForType(Scope* scope, |
| if (!Init(scope, node, err)) |
| if (get().VerifyTypeIs(type, err)) |
| // 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()); |