Shader: Add IsExpression/IsStatement

This commit is contained in:
Jérôme Leclercq 2021-04-14 17:58:15 +02:00
parent b234134abc
commit 4bca87b1cb
2 changed files with 26 additions and 0 deletions

View File

@ -296,6 +296,8 @@ namespace Nz::ShaderAst
};
inline const ShaderAst::ExpressionType& GetExpressionType(ShaderAst::Expression& expr);
inline bool IsExpression(NodeType nodeType);
inline bool IsStatement(NodeType nodeType);
}
#include <Nazara/Shader/ShaderNodes.inl>

View File

@ -12,6 +12,30 @@ namespace Nz::ShaderAst
assert(expr.cachedExpressionType);
return expr.cachedExpressionType.value();
}
inline bool IsExpression(NodeType nodeType)
{
switch (nodeType)
{
#define NAZARA_SHADERAST_EXPRESSION(Node) case NodeType::Node: return true;
#include <Nazara/Shader/ShaderAstNodes.hpp>
default:
return false;
}
}
inline bool IsStatement(NodeType nodeType)
{
switch (nodeType)
{
#define NAZARA_SHADERAST_STATEMENT(Node) case NodeType::Node: return true;
#include <Nazara/Shader/ShaderAstNodes.hpp>
default:
return false;
}
}
}
#include <Nazara/Shader/DebugOff.hpp>