Shader: Handle type as expressions

This commit is contained in:
Jérôme Leclercq
2022-02-08 17:03:34 +01:00
parent 5ce8120a0c
commit 402e16bd2b
53 changed files with 1746 additions and 1141 deletions

View File

@@ -8,20 +8,25 @@
namespace Nz::ShaderAst
{
template<typename T>
AttributeValue<T> AstCloner::Clone(const AttributeValue<T>& attribute)
ExpressionValue<T> AstCloner::Clone(const ExpressionValue<T>& expressionValue)
{
if (!attribute.HasValue())
if (!expressionValue.HasValue())
return {};
if (attribute.IsExpression())
return CloneExpression(attribute.GetExpression());
if (expressionValue.IsExpression())
return CloneExpression(expressionValue.GetExpression());
else
{
assert(attribute.IsResultingValue());
return attribute.GetResultingValue();
assert(expressionValue.IsResultingValue());
return expressionValue.GetResultingValue();
}
}
inline ExpressionValue<ExpressionType> AstCloner::Clone(const ExpressionValue<ExpressionType>& expressionValue)
{
return CloneType(expressionValue);
}
ExpressionPtr AstCloner::CloneExpression(const ExpressionPtr& expr)
{
if (!expr)
@@ -40,7 +45,7 @@ namespace Nz::ShaderAst
template<typename T>
AttributeValue<T> Clone(const AttributeValue<T>& attribute)
ExpressionValue<T> Clone(const ExpressionValue<T>& attribute)
{
AstCloner cloner;
return cloner.Clone(attribute);