// 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 #include namespace Nz::ShaderBuilder { inline std::unique_ptr Impl::Binary::operator()(ShaderAst::BinaryType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const { auto constantNode = std::make_unique(); constantNode->op = op; constantNode->left = std::move(left); constantNode->right = std::move(right); return constantNode; } inline std::unique_ptr Impl::Branch::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr truePath, ShaderAst::StatementPtr falsePath) const { auto branchNode = std::make_unique(); auto& condStatement = branchNode->condStatements.emplace_back(); condStatement.condition = std::move(condition); condStatement.statement = std::move(truePath); branchNode->elseStatement = std::move(falsePath); return branchNode; } inline std::unique_ptr Impl::Branch::operator()(std::vector condStatements, ShaderAst::StatementPtr elseStatement) const { auto branchNode = std::make_unique(); branchNode->condStatements = std::move(condStatements); branchNode->elseStatement = std::move(elseStatement); return branchNode; } inline std::unique_ptr Impl::Constant::operator()(ShaderConstantValue value) const { auto constantNode = std::make_unique(); constantNode->value = std::move(value); return constantNode; } inline std::unique_ptr Impl::DeclareFunction::operator()(std::string name, std::vector parameters, std::vector statements, ShaderAst::ShaderExpressionType returnType) const { auto declareFunctionNode = std::make_unique(); declareFunctionNode->name = std::move(name); declareFunctionNode->parameters = std::move(parameters); declareFunctionNode->returnType = std::move(returnType); declareFunctionNode->statements = std::move(statements); return declareFunctionNode; } inline std::unique_ptr Nz::ShaderBuilder::Impl::DeclareVariable::operator()(std::string name, ShaderAst::ShaderExpressionType type, ShaderAst::ExpressionPtr initialValue) const { auto declareVariableNode = std::make_unique(); declareVariableNode->varName = std::move(name); declareVariableNode->varType = std::move(type); declareVariableNode->initialExpression = std::move(initialValue); return declareVariableNode; } inline std::unique_ptr Impl::Identifier::operator()(std::string name) const { auto identifierNode = std::make_unique(); identifierNode->identifier = std::move(name); return identifierNode; } inline std::unique_ptr Impl::Return::operator()(ShaderAst::ExpressionPtr expr) const { auto returnNode = std::make_unique(); returnNode->returnExpr = std::move(expr); return returnNode; } template std::unique_ptr Impl::NoParam::operator()() const { return std::make_unique(); } } #include