-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiler: Continue multipass implementation (WIP)
- Loading branch information
Showing
20 changed files
with
1,244 additions
and
272 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
include/NZSL/Ast/Transformations/AssignmentTransformer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
#pragma once | ||
|
||
#ifndef NZSL_AST_TRANSFORMATIONS_ASSIGNMENTTRANSFORMER_HPP | ||
#define NZSL_AST_TRANSFORMATIONS_ASSIGNMENTTRANSFORMER_HPP | ||
|
||
#include <NZSL/Ast/Transformations/Transformer.hpp> | ||
|
||
namespace nzsl::Ast | ||
{ | ||
class NZSL_API AssignmentTransformer final : public Transformer | ||
{ | ||
public: | ||
struct Options; | ||
|
||
inline AssignmentTransformer(); | ||
|
||
inline bool Transform(Module& module, Context& context, std::string* error = nullptr); | ||
bool Transform(Module& module, Context& context, const Options& options, std::string* error = nullptr); | ||
|
||
struct Options | ||
{ | ||
bool allowPartialSanitization = false; | ||
bool removeCompoundAssignment = false; | ||
}; | ||
|
||
private: | ||
using Transformer::Transform; | ||
ExpressionPtr Transform(AssignExpression&& assign) override; | ||
|
||
const Options* m_options; | ||
}; | ||
} | ||
|
||
#include <NZSL/Ast/Transformations/AssignmentTransformer.inl> | ||
|
||
#endif // NZSL_AST_TRANSFORMATIONS_ASSIGNMENTTRANSFORMER_HPP |
16 changes: 16 additions & 0 deletions
16
include/NZSL/Ast/Transformations/AssignmentTransformer.inl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
namespace nzsl::Ast | ||
{ | ||
inline AssignmentTransformer::AssignmentTransformer() : | ||
Transformer(true) | ||
{ | ||
} | ||
|
||
inline bool AssignmentTransformer::Transform(Module& module, Context& context, std::string* error) | ||
{ | ||
return Transform(module, context, {}, error); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
include/NZSL/Ast/Transformations/BranchSplitterTransformer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
#pragma once | ||
|
||
#ifndef NZSL_AST_TRANSFORMATIONS_BRANCHSPLITTERTRANSFORMER_HPP | ||
#define NZSL_AST_TRANSFORMATIONS_BRANCHSPLITTERTRANSFORMER_HPP | ||
|
||
#include <NZSL/Ast/Transformations/Transformer.hpp> | ||
|
||
namespace nzsl::Ast | ||
{ | ||
class NZSL_API BranchSplitterTransformer final : public Transformer | ||
{ | ||
public: | ||
struct Options; | ||
|
||
inline BranchSplitterTransformer(); | ||
|
||
inline bool Transform(Module& module, Context& context, std::string* error = nullptr); | ||
bool Transform(Module& module, Context& context, const Options& options, std::string* error = nullptr); | ||
|
||
struct Options | ||
{ | ||
bool allowPartialSanitization = false; | ||
}; | ||
|
||
private: | ||
using Transformer::Transform; | ||
StatementPtr Transform(BranchStatement&& statement) override; | ||
|
||
const Options* m_options; | ||
}; | ||
} | ||
|
||
#include <NZSL/Ast/Transformations/BranchSplitterTransformer.inl> | ||
|
||
#endif // NZSL_AST_TRANSFORMATIONS_BRANCHSPLITTERTRANSFORMER_HPP |
16 changes: 16 additions & 0 deletions
16
include/NZSL/Ast/Transformations/BranchSplitterTransformer.inl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
namespace nzsl::Ast | ||
{ | ||
inline BranchSplitterTransformer::BranchSplitterTransformer() : | ||
Transformer(false) | ||
{ | ||
} | ||
|
||
inline bool BranchSplitterTransformer::Transform(Module& module, Context& context, std::string* error) | ||
{ | ||
return Transform(module, context, {}, error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
#pragma once | ||
|
||
#ifndef NZSL_AST_TRANSFORMATIONS_MATRIXTRANSFORMER_HPP | ||
#define NZSL_AST_TRANSFORMATIONS_MATRIXTRANSFORMER_HPP | ||
|
||
#include <NZSL/Ast/Transformations/Transformer.hpp> | ||
|
||
namespace nzsl::Ast | ||
{ | ||
class NZSL_API MatrixTransformer final : public Transformer | ||
{ | ||
public: | ||
struct Options; | ||
|
||
inline MatrixTransformer(); | ||
|
||
inline bool Transform(Module& module, Context& context, std::string* error = nullptr); | ||
bool Transform(Module& module, Context& context, const Options& options, std::string* error = nullptr); | ||
|
||
struct Options | ||
{ | ||
bool removeMatrixBinaryAddSub = false; | ||
bool removeMatrixCast = false; | ||
}; | ||
|
||
private: | ||
using Transformer::Transform; | ||
|
||
ExpressionPtr Transform(BinaryExpression&& binExpr) override; | ||
ExpressionPtr Transform(CastExpression&& castExpr) override; | ||
|
||
const Options* m_options; | ||
}; | ||
} | ||
|
||
#include <NZSL/Ast/Transformations/MatrixTransformer.inl> | ||
|
||
#endif // NZSL_AST_TRANSFORMATIONS_MATRIXTRANSFORMER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
#pragma once | ||
|
||
#ifndef NZSL_AST_TRANSFORMATIONS_SWIZZLETRANSFORMER_HPP | ||
#define NZSL_AST_TRANSFORMATIONS_SWIZZLETRANSFORMER_HPP | ||
|
||
#include <NZSL/Ast/Transformations/Transformer.hpp> | ||
|
||
namespace nzsl::Ast | ||
{ | ||
class NZSL_API SwizzleTransformer final : public Transformer | ||
{ | ||
public: | ||
struct Options; | ||
|
||
inline SwizzleTransformer(); | ||
|
||
inline bool Transform(Module& module, Context& context, std::string* error = nullptr); | ||
bool Transform(Module& module, Context& context, const Options& options, std::string* error = nullptr); | ||
|
||
struct Options | ||
{ | ||
bool allowPartialSanitization = false; | ||
bool removeScalarSwizzling = false; | ||
}; | ||
|
||
private: | ||
using Transformer::Transform; | ||
ExpressionPtr Transform(SwizzleExpression&& swizzle) override; | ||
|
||
const Options* m_options; | ||
}; | ||
} | ||
|
||
#include <NZSL/Ast/Transformations/SwizzleTransformer.inl> | ||
|
||
#endif // NZSL_AST_TRANSFORMATIONS_SWIZZLETRANSFORMER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) | ||
// This file is part of the "Nazara Shading Language" project | ||
// For conditions of distribution and use, see copyright notice in Config.hpp | ||
|
||
namespace nzsl::Ast | ||
{ | ||
inline SwizzleTransformer::SwizzleTransformer() : | ||
Transformer(true) | ||
{ | ||
} | ||
|
||
inline bool SwizzleTransformer::Transform(Module& module, Context& context, std::string* error) | ||
{ | ||
return Transform(module, context, {}, error); | ||
} | ||
} |
Oops, something went wrong.