// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Shader module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #include namespace Nz::ShaderAst { template ExpressionValue::ExpressionValue(T value) : m_value(std::move(value)) { } template ExpressionValue::ExpressionValue(ExpressionPtr expr) { assert(expr); m_value = std::move(expr); } template ExpressionPtr&& ExpressionValue::GetExpression() && { if (!IsExpression()) throw std::runtime_error("excepted expression"); return std::get(std::move(m_value)); } template const ExpressionPtr& ExpressionValue::GetExpression() const & { if (!IsExpression()) throw std::runtime_error("excepted expression"); assert(std::get(m_value)); return std::get(m_value); } template const T& ExpressionValue::GetResultingValue() const { if (!IsResultingValue()) throw std::runtime_error("excepted resulting value"); return std::get(m_value); } template bool ExpressionValue::IsExpression() const { return std::holds_alternative(m_value); } template bool ExpressionValue::IsResultingValue() const { return std::holds_alternative(m_value); } template bool ExpressionValue::HasValue() const { return !std::holds_alternative(m_value); } template void ExpressionValue::Reset() { m_value = {}; } } #include