From 4bca87b1cb044a47c19965bb29cac43da927eb51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 14 Apr 2021 17:58:15 +0200 Subject: [PATCH] Shader: Add IsExpression/IsStatement --- include/Nazara/Shader/ShaderNodes.hpp | 2 ++ include/Nazara/Shader/ShaderNodes.inl | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/Nazara/Shader/ShaderNodes.hpp b/include/Nazara/Shader/ShaderNodes.hpp index e5663c5d1..0e84c8d1f 100644 --- a/include/Nazara/Shader/ShaderNodes.hpp +++ b/include/Nazara/Shader/ShaderNodes.hpp @@ -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 diff --git a/include/Nazara/Shader/ShaderNodes.inl b/include/Nazara/Shader/ShaderNodes.inl index d8b320b72..c9c3b875b 100644 --- a/include/Nazara/Shader/ShaderNodes.inl +++ b/include/Nazara/Shader/ShaderNodes.inl @@ -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 + + default: + return false; + } + } + + inline bool IsStatement(NodeType nodeType) + { + switch (nodeType) + { +#define NAZARA_SHADERAST_STATEMENT(Node) case NodeType::Node: return true; +#include + + default: + return false; + } + } } #include