Shader: Remove ShaderNode::GetExpressionType (replaced by visitor) and minor stuff
This commit is contained in:
54
include/Nazara/Shader/ShaderAstUtils.hpp
Normal file
54
include/Nazara/Shader/ShaderAstUtils.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Shader generator"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADERASTUTILS_HPP
|
||||
#define NAZARA_SHADERASTUTILS_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Shader/Config.hpp>
|
||||
#include <Nazara/Shader/ShaderEnums.hpp>
|
||||
#include <Nazara/Shader/ShaderAstVisitorExcept.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ShaderAst;
|
||||
|
||||
class NAZARA_SHADER_API ShaderAstValueCategory final : public ShaderAstVisitorExcept
|
||||
{
|
||||
public:
|
||||
ShaderAstValueCategory() = default;
|
||||
ShaderAstValueCategory(const ShaderAstValueCategory&) = delete;
|
||||
ShaderAstValueCategory(ShaderAstValueCategory&&) = delete;
|
||||
~ShaderAstValueCategory() = default;
|
||||
|
||||
ShaderNodes::ExpressionCategory GetExpressionCategory(const ShaderNodes::ExpressionPtr& expression);
|
||||
|
||||
ShaderAstValueCategory& operator=(const ShaderAstValueCategory&) = delete;
|
||||
ShaderAstValueCategory& operator=(ShaderAstValueCategory&&) = delete;
|
||||
|
||||
private:
|
||||
using ShaderAstVisitorExcept::Visit;
|
||||
void Visit(ShaderNodes::AccessMember& node) override;
|
||||
void Visit(ShaderNodes::AssignOp& node) override;
|
||||
void Visit(ShaderNodes::BinaryOp& node) override;
|
||||
void Visit(ShaderNodes::Cast& node) override;
|
||||
void Visit(ShaderNodes::ConditionalExpression& node) override;
|
||||
void Visit(ShaderNodes::Constant& node) override;
|
||||
void Visit(ShaderNodes::Identifier& node) override;
|
||||
void Visit(ShaderNodes::IntrinsicCall& node) override;
|
||||
void Visit(ShaderNodes::Sample2D& node) override;
|
||||
void Visit(ShaderNodes::SwizzleOp& node) override;
|
||||
|
||||
ShaderNodes::ExpressionCategory m_expressionCategory;
|
||||
};
|
||||
|
||||
inline ShaderNodes::ExpressionCategory GetExpressionCategory(const ShaderNodes::ExpressionPtr& expression);
|
||||
}
|
||||
|
||||
#include <Nazara/Shader/ShaderAstUtils.inl>
|
||||
|
||||
#endif
|
||||
17
include/Nazara/Shader/ShaderAstUtils.inl
Normal file
17
include/Nazara/Shader/ShaderAstUtils.inl
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Shader generator"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Shader/ShaderAstUtils.hpp>
|
||||
#include <Nazara/Shader/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
ShaderNodes::ExpressionCategory GetExpressionCategory(const ShaderNodes::ExpressionPtr& expression)
|
||||
{
|
||||
ShaderAstValueCategory visitor;
|
||||
return visitor.GetExpressionCategory(expression);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Shader/DebugOff.hpp>
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Nazara/Shader/ShaderExpressionType.hpp>
|
||||
#include <Nazara/Shader/ShaderVariables.hpp>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
@@ -55,12 +56,11 @@ namespace Nz
|
||||
|
||||
using ExpressionPtr = std::shared_ptr<Expression>;
|
||||
|
||||
class NAZARA_SHADER_API Expression : public Node
|
||||
class NAZARA_SHADER_API Expression : public Node, public std::enable_shared_from_this<Expression>
|
||||
{
|
||||
public:
|
||||
inline Expression(NodeType type);
|
||||
|
||||
virtual ExpressionCategory GetExpressionCategory() const;
|
||||
virtual ShaderExpressionType GetExpressionType() const = 0;
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Nz
|
||||
|
||||
using StatementPtr = std::shared_ptr<Statement>;
|
||||
|
||||
class NAZARA_SHADER_API Statement : public Node
|
||||
class NAZARA_SHADER_API Statement : public Node, public std::enable_shared_from_this<Statement>
|
||||
{
|
||||
public:
|
||||
inline Statement(NodeType type);
|
||||
@@ -136,7 +136,6 @@ namespace Nz
|
||||
{
|
||||
inline Identifier();
|
||||
|
||||
ExpressionCategory GetExpressionCategory() const override;
|
||||
ShaderExpressionType GetExpressionType() const override;
|
||||
void Visit(ShaderAstVisitor& visitor) override;
|
||||
|
||||
@@ -149,7 +148,6 @@ namespace Nz
|
||||
{
|
||||
inline AccessMember();
|
||||
|
||||
ExpressionCategory GetExpressionCategory() const override;
|
||||
ShaderExpressionType GetExpressionType() const override;
|
||||
void Visit(ShaderAstVisitor& visitor) override;
|
||||
|
||||
@@ -265,7 +263,6 @@ namespace Nz
|
||||
{
|
||||
inline SwizzleOp();
|
||||
|
||||
ExpressionCategory GetExpressionCategory() const override;
|
||||
ShaderExpressionType GetExpressionType() const override;
|
||||
void Visit(ShaderAstVisitor& visitor) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user