Shader: Serialize cached expression type
This commit is contained in:
@@ -41,6 +41,7 @@ namespace Nz::ShaderAst
|
||||
void Serialize(SwizzleExpression& node);
|
||||
void Serialize(VariableValueExpression& node);
|
||||
void Serialize(UnaryExpression& node);
|
||||
void SerializeExpressionCommon(Expression& expr);
|
||||
|
||||
void Serialize(BranchStatement& node);
|
||||
void Serialize(ConditionalStatement& node);
|
||||
@@ -67,6 +68,7 @@ namespace Nz::ShaderAst
|
||||
template<typename T> void Enum(T& enumVal);
|
||||
template<typename T> void ExprValue(ExpressionValue<T>& attribute);
|
||||
template<typename T> void OptEnum(std::optional<T>& optVal);
|
||||
inline void OptType(std::optional<ExpressionType>& optType);
|
||||
template<typename T> void OptVal(std::optional<T>& optVal);
|
||||
|
||||
virtual bool IsWriting() const = 0;
|
||||
|
||||
@@ -126,6 +126,23 @@ namespace Nz::ShaderAst
|
||||
Enum(optVal.value());
|
||||
}
|
||||
|
||||
inline void AstSerializerBase::OptType(std::optional<ExpressionType>& optType)
|
||||
{
|
||||
bool isWriting = IsWriting();
|
||||
|
||||
bool hasValue;
|
||||
if (isWriting)
|
||||
hasValue = optType.has_value();
|
||||
|
||||
Value(hasValue);
|
||||
|
||||
if (!isWriting && hasValue)
|
||||
optType.emplace();
|
||||
|
||||
if (optType.has_value())
|
||||
Type(optType.value());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void AstSerializerBase::OptVal(std::optional<T>& optVal)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user