This source file includes following definitions.
- definition_
- definition_
- Clone
- Invoke
- GetDefinitionRange
#include "tools/gn/template.h"
#include "tools/gn/err.h"
#include "tools/gn/functions.h"
#include "tools/gn/parse_tree.h"
#include "tools/gn/scope.h"
#include "tools/gn/value.h"
Template::Template(const Scope* scope, const FunctionCallNode* def)
: closure_(scope->MakeClosure()),
definition_(def) {
}
Template::Template(scoped_ptr<Scope> scope, const FunctionCallNode* def)
: closure_(scope.Pass()),
definition_(def) {
}
Template::~Template() {
}
scoped_ptr<Template> Template::Clone() const {
return scoped_ptr<Template>(
new Template(closure_->MakeClosure(), definition_));
}
Value Template::Invoke(Scope* scope,
const FunctionCallNode* invocation,
const std::vector<Value>& args,
BlockNode* block,
Err* err) const {
if (!EnsureNotProcessingImport(invocation, scope, err))
return Value();
Scope invocation_scope(scope);
if (!FillTargetBlockScope(scope, invocation,
invocation->function().value().as_string(),
block, args, &invocation_scope, err))
return Value();
block->ExecuteBlockInScope(&invocation_scope, err);
if (err->has_error())
return Value();
Scope template_scope(closure_.get());
template_scope.SetValue("invoker", Value(NULL, &invocation_scope),
invocation);
template_scope.set_source_dir(scope->GetSourceDir());
const base::StringPiece target_name("target_name");
template_scope.SetValue(target_name,
Value(invocation, args[0].string_value()),
invocation);
return definition_->block()->ExecuteBlockInScope(&template_scope, err);
}
LocationRange Template::GetDefinitionRange() const {
return definition_->GetRange();
}