From acf1b303555082af9cc769034b5c2c7e5fd1b595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Mar 2022 13:19:19 +0100 Subject: [PATCH] Shader/AstCompare: Fix missing ConditionalStatement compare --- include/Nazara/Shader/Ast/AstCompare.inl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Shader/Ast/AstCompare.inl b/include/Nazara/Shader/Ast/AstCompare.inl index 94fcc742a..900ae3bdf 100644 --- a/include/Nazara/Shader/Ast/AstCompare.inl +++ b/include/Nazara/Shader/Ast/AstCompare.inl @@ -15,12 +15,12 @@ namespace Nz::ShaderAst switch (lhs.GetType()) { - case NodeType::None: break; + case NodeType::None: break; #define NAZARA_SHADERAST_EXPRESSION(Node) case NodeType::Node: return Compare(static_cast(lhs), static_cast(lhs)); #include - default: throw std::runtime_error("unexpected node type"); + default: throw std::runtime_error("unexpected node type"); } return true; @@ -33,12 +33,12 @@ namespace Nz::ShaderAst switch (lhs.GetType()) { - case NodeType::None: break; + case NodeType::None: break; #define NAZARA_SHADERAST_STATEMENT(Node) case NodeType::Node: return Compare(static_cast(lhs), static_cast(lhs)); #include - default: throw std::runtime_error("unexpected node type"); + default: throw std::runtime_error("unexpected node type"); } return false; @@ -358,6 +358,17 @@ namespace Nz::ShaderAst return true; } + inline bool Compare(const ConditionalStatement& lhs, const ConditionalStatement& rhs) + { + if (!Compare(lhs.condition, rhs.condition)) + return false; + + if (!Compare(lhs.statement, rhs.statement)) + return false; + + return true; + } + inline bool Compare(const DeclareConstStatement& lhs, const DeclareConstStatement& rhs) { if (!Compare(lhs.name, rhs.name))