Renderer/ShaderAst: Add BinaryFunc

This commit is contained in:
Lynix
2020-06-04 18:29:50 +02:00
parent 41b50eeac3
commit 25562a5856
4 changed files with 75 additions and 1 deletions

View File

@@ -243,6 +243,29 @@ namespace Nz
if (coordinates->GetExpressionType() != ExpressionType::Float2)
throw std::runtime_error("Coordinates must be a Float2");
}
inline BinaryFunc::BinaryFunc(BinaryIntrinsic Op, ExpressionPtr Left, ExpressionPtr Right) :
intrinsic(Op),
left(Left),
right(Right)
{
ExpressionType leftType = left->GetExpressionType();
ExpressionType rightType = right->GetExpressionType();
if (leftType != rightType)
//TODO: AstParseError
throw std::runtime_error("Left expression type must match right expression type");
switch (intrinsic)
{
case BinaryIntrinsic::CrossProduct:
{
if (leftType != ExpressionType::Float3)
//TODO: AstParseError
throw std::runtime_error("CrossProduct only works with Float3 expressions");
}
}
}
}
}