Modules are workings \o/

This commit is contained in:
Jérôme Leclercq
2022-03-08 20:26:02 +01:00
parent 83d26e209e
commit be9bdc4705
29 changed files with 742 additions and 256 deletions

View File

@@ -315,7 +315,7 @@ namespace Nz::ShaderBuilder
return expressionStatementNode;
}
inline std::unique_ptr<ShaderAst::ForStatement> Nz::ShaderBuilder::Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::StatementPtr statement) const
inline std::unique_ptr<ShaderAst::ForStatement> Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::StatementPtr statement) const
{
auto forNode = std::make_unique<ShaderAst::ForStatement>();
forNode->fromExpr = std::move(fromExpression);
@@ -326,7 +326,7 @@ namespace Nz::ShaderBuilder
return forNode;
}
inline std::unique_ptr<ShaderAst::ForStatement> Nz::ShaderBuilder::Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::ExpressionPtr stepExpression, ShaderAst::StatementPtr statement) const
inline std::unique_ptr<ShaderAst::ForStatement> Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::ExpressionPtr stepExpression, ShaderAst::StatementPtr statement) const
{
auto forNode = std::make_unique<ShaderAst::ForStatement>();
forNode->fromExpr = std::move(fromExpression);
@@ -348,6 +348,15 @@ namespace Nz::ShaderBuilder
return forEachNode;
}
inline std::unique_ptr<ShaderAst::FunctionExpression> Impl::Function::operator()(std::size_t funcId) const
{
auto intrinsicTypeExpr = std::make_unique<ShaderAst::FunctionExpression>();
intrinsicTypeExpr->cachedExpressionType = ShaderAst::FunctionType{ funcId };
intrinsicTypeExpr->funcId = funcId;
return intrinsicTypeExpr;
}
inline std::unique_ptr<ShaderAst::IdentifierExpression> Impl::Identifier::operator()(std::string name) const
{
auto identifierNode = std::make_unique<ShaderAst::IdentifierExpression>();
@@ -373,6 +382,15 @@ namespace Nz::ShaderBuilder
return intrinsicExpression;
}
inline std::unique_ptr<ShaderAst::IntrinsicFunctionExpression> Impl::IntrinsicFunction::operator()(std::size_t intrinsicFunctionId, ShaderAst::IntrinsicType intrinsicType) const
{
auto intrinsicTypeExpr = std::make_unique<ShaderAst::IntrinsicFunctionExpression>();
intrinsicTypeExpr->cachedExpressionType = ShaderAst::IntrinsicFunctionType{ intrinsicType };
intrinsicTypeExpr->intrinsicId = intrinsicFunctionId;
return intrinsicTypeExpr;
}
inline std::unique_ptr<ShaderAst::MultiStatement> Impl::Multi::operator()(std::vector<ShaderAst::StatementPtr> statements) const
{
auto multiStatement = std::make_unique<ShaderAst::MultiStatement>();
@@ -403,6 +421,15 @@ namespace Nz::ShaderBuilder
return scopedNode;
}
inline std::unique_ptr<ShaderAst::StructTypeExpression> Impl::StructType::operator()(std::size_t structTypeId) const
{
auto structTypeExpr = std::make_unique<ShaderAst::StructTypeExpression>();
structTypeExpr->cachedExpressionType = ShaderAst::StructType{ structTypeId };
structTypeExpr->structTypeId = structTypeId;
return structTypeExpr;
}
inline std::unique_ptr<ShaderAst::SwizzleExpression> Impl::Swizzle::operator()(ShaderAst::ExpressionPtr expression, std::array<UInt32, 4> swizzleComponents, std::size_t componentCount) const
{
assert(componentCount > 0);