Shader: Add support for for-each statements and improve arrays

This commit is contained in:
Jérôme Leclercq
2022-01-02 22:02:11 +01:00
parent aac6e38da2
commit 4fe44339c5
30 changed files with 712 additions and 93 deletions

View File

@@ -340,6 +340,18 @@ namespace Nz::ShaderAst
ExpressionPtr expression;
};
struct NAZARA_SHADER_API ForEachStatement : Statement
{
NodeType GetType() const override;
void Visit(AstStatementVisitor& visitor) override;
std::optional<std::size_t> varIndex;
std::string varName;
ExpressionPtr expression;
StatementPtr statement;
bool isConst = false;
};
struct NAZARA_SHADER_API MultiStatement : Statement
{
NodeType GetType() const override;
@@ -371,7 +383,12 @@ namespace Nz::ShaderAst
StatementPtr body;
};
#define NAZARA_SHADERAST_NODE(X) using X##Ptr = std::unique_ptr<X>;
#include <Nazara/Shader/Ast/AstNodeList.hpp>
inline const ShaderAst::ExpressionType& GetExpressionType(ShaderAst::Expression& expr);
inline ShaderAst::ExpressionType& GetExpressionTypeMut(ShaderAst::Expression& expr);
inline bool IsExpression(NodeType nodeType);
inline bool IsStatement(NodeType nodeType);
}