Shader: Add SourceLocation members

TODO: Fill from Parser and use them for error throwing in SanitizeVisitor
This commit is contained in:
SirLynix
2022-03-27 14:06:58 +02:00
committed by Jérôme Leclercq
parent b8bf19f8cd
commit 960ab64d98
15 changed files with 329 additions and 137 deletions

View File

@@ -13,6 +13,9 @@ namespace Nz::ShaderAst
if (lhs.GetType() != rhs.GetType())
return false;
if (!Compare(lhs.sourceLocation, rhs.sourceLocation))
return false;
switch (lhs.GetType())
{
case NodeType::None: break;
@@ -70,6 +73,9 @@ namespace Nz::ShaderAst
if (lhs.GetType() != rhs.GetType())
return false;
if (!Compare(lhs.sourceLocation, rhs.sourceLocation))
return false;
switch (lhs.GetType())
{
case NodeType::None: break;
@@ -101,6 +107,17 @@ namespace Nz::ShaderAst
return true;
}
template<typename T>
bool Compare(const std::shared_ptr<T>& lhs, const std::shared_ptr<T>& rhs)
{
if (lhs == nullptr)
return rhs == nullptr;
else if (rhs == nullptr)
return false;
return Compare(*lhs, *rhs);
}
template<typename T>
bool Compare(const std::vector<T>& lhs, const std::vector<T>& rhs)
{
@@ -153,6 +170,17 @@ namespace Nz::ShaderAst
return true;
}
bool Compare(const AccessIdentifierExpression::Identifier& lhs, const AccessIdentifierExpression::Identifier& rhs)
{
if (!Compare(lhs.identifier, rhs.identifier))
return false;
if (!Compare(lhs.sourceLocation, rhs.sourceLocation))
return false;
return true;
}
inline bool Compare(const BranchStatement::ConditionalStatement& lhs, const BranchStatement::ConditionalStatement& rhs)
{
if (!Compare(lhs.condition, rhs.condition))
@@ -178,6 +206,9 @@ namespace Nz::ShaderAst
if (!Compare(lhs.type, rhs.type))
return false;
if (!Compare(lhs.sourceLocation, rhs.sourceLocation))
return false;
return true;
}
@@ -189,6 +220,29 @@ namespace Nz::ShaderAst
if (!Compare(lhs.type, rhs.type))
return false;
if (!Compare(lhs.sourceLocation, rhs.sourceLocation))
return false;
return true;
}
bool Compare(const ShaderLang::SourceLocation& lhs, const ShaderLang::SourceLocation& rhs)
{
if (!Compare(lhs.endColumn, rhs.endColumn))
return false;
if (!Compare(lhs.endLine, rhs.endLine))
return false;
if (!Compare(lhs.startColumn, rhs.startColumn))
return false;
if (!Compare(lhs.startLine, rhs.startLine))
return false;
if (!Compare(lhs.file, rhs.file))
return false;
return true;
}
@@ -223,6 +277,9 @@ namespace Nz::ShaderAst
if (!Compare(lhs.type, rhs.type))
return false;
if (!Compare(lhs.sourceLocation, rhs.sourceLocation))
return false;
return true;
}