Allow generator expressions to require literals.

This commit is contained in:
Stephen Kelly 2012-12-10 11:31:59 +01:00
parent b2f1700bc7
commit 77475fe61d
1 changed files with 17 additions and 0 deletions

View File

@ -47,6 +47,8 @@ struct cmGeneratorExpressionNode
virtual bool GeneratesContent() const { return true; } virtual bool GeneratesContent() const { return true; }
virtual bool RequiresLiteralInput() const { return false; }
virtual bool AcceptsSingleArbitraryContentParameter() const virtual bool AcceptsSingleArbitraryContentParameter() const
{ return false; } { return false; }
@ -692,6 +694,15 @@ std::string GeneratorExpressionContent::Evaluate(
= pit->end(); = pit->end();
for ( ; it != end; ++it) for ( ; it != end; ++it)
{ {
if (node->RequiresLiteralInput())
{
if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
{
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires literal input.");
return std::string();
}
}
result += (*it)->Evaluate(context, dagChecker); result += (*it)->Evaluate(context, dagChecker);
if (context->HadError) if (context->HadError)
{ {
@ -699,6 +710,12 @@ std::string GeneratorExpressionContent::Evaluate(
} }
} }
} }
if (node->RequiresLiteralInput())
{
std::vector<std::string> parameters;
parameters.push_back(result);
return node->Evaluate(parameters, context, this, dagChecker);
}
return result; return result;
} }