Shader: Rework scope handling
This commit is contained in:
@@ -9,13 +9,12 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Shader/Config.hpp>
|
||||
#include <Nazara/Shader/ShaderAstCache.hpp>
|
||||
#include <Nazara/Shader/ShaderAstRecursiveVisitor.hpp>
|
||||
#include <Nazara/Shader/ShaderAstScopedVisitor.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
namespace Nz::ShaderAst
|
||||
{
|
||||
class NAZARA_SHADER_API AstValidator : public AstRecursiveVisitor
|
||||
class NAZARA_SHADER_API AstValidator final : public AstScopedVisitor
|
||||
{
|
||||
public:
|
||||
inline AstValidator();
|
||||
@@ -23,28 +22,24 @@ namespace Nz::ShaderAst
|
||||
AstValidator(AstValidator&&) = delete;
|
||||
~AstValidator() = default;
|
||||
|
||||
bool Validate(StatementPtr& node, std::string* error = nullptr, AstCache* cache = nullptr);
|
||||
bool Validate(StatementPtr& node, std::string* error = nullptr);
|
||||
|
||||
private:
|
||||
const ExpressionType& GetExpressionType(Expression& expression);
|
||||
Expression& MandatoryExpr(ExpressionPtr& node);
|
||||
Statement& MandatoryStatement(StatementPtr& node);
|
||||
void TypeMustMatch(ExpressionPtr& left, ExpressionPtr& right);
|
||||
void TypeMustMatch(const ExpressionType& left, const ExpressionType& right);
|
||||
|
||||
ExpressionType CheckField(const std::string& structName, const std::string* memberIdentifier, std::size_t remainingMembers);
|
||||
|
||||
AstCache::Scope& EnterScope();
|
||||
void ExitScope();
|
||||
|
||||
void RegisterExpressionType(Expression& node, ExpressionType expressionType);
|
||||
void RegisterScope(Node& node);
|
||||
const ExpressionType& ResolveAlias(const ExpressionType& expressionType);
|
||||
|
||||
void Visit(AccessMemberExpression& node) override;
|
||||
void Visit(AssignExpression& node) override;
|
||||
void Visit(BinaryExpression& node) override;
|
||||
void Visit(CastExpression& node) override;
|
||||
void Visit(ConditionalExpression& node) override;
|
||||
void Visit(ConstantExpression& node) override;
|
||||
void Visit(ConditionalExpression& node) override;
|
||||
void Visit(IdentifierExpression& node) override;
|
||||
void Visit(IntrinsicExpression& node) override;
|
||||
void Visit(SwizzleExpression& node) override;
|
||||
@@ -54,17 +49,15 @@ namespace Nz::ShaderAst
|
||||
void Visit(DeclareExternalStatement& node) override;
|
||||
void Visit(DeclareFunctionStatement& node) override;
|
||||
void Visit(DeclareStructStatement& node) override;
|
||||
void Visit(DeclareVariableStatement& node) override;
|
||||
void Visit(ExpressionStatement& node) override;
|
||||
void Visit(MultiStatement& node) override;
|
||||
void Visit(ReturnStatement& node) override;
|
||||
|
||||
struct Context;
|
||||
|
||||
Context* m_context;
|
||||
};
|
||||
|
||||
NAZARA_SHADER_API bool ValidateAst(StatementPtr& node, std::string* error = nullptr, AstCache* cache = nullptr);
|
||||
NAZARA_SHADER_API bool ValidateAst(StatementPtr& node, std::string* error = nullptr);
|
||||
}
|
||||
|
||||
#include <Nazara/Shader/ShaderAstValidator.inl>
|
||||
|
||||
Reference in New Issue
Block a user