Shader: Add compiler and AST errors (WIP)

I'm so afraid to lose all this work
This commit is contained in:
SirLynix
2022-03-30 20:21:36 +02:00
committed by Jérôme Leclercq
parent 52d0c5b0bc
commit ac9e7207ac
6 changed files with 707 additions and 556 deletions

View File

@@ -811,6 +811,7 @@ namespace Nz::ShaderAst
auto binary = ShaderBuilder::Binary(node.op, std::move(lhs), std::move(rhs));
binary->cachedExpressionType = node.cachedExpressionType;
binary->sourceLocation = node.sourceLocation;
return binary;
}
@@ -931,6 +932,7 @@ namespace Nz::ShaderAst
auto cast = ShaderBuilder::Cast(node.targetType.GetResultingValue(), std::move(expressions));
cast->cachedExpressionType = node.cachedExpressionType;
cast->sourceLocation = node.sourceLocation;
return cast;
}
@@ -996,7 +998,10 @@ namespace Nz::ShaderAst
if (!elseStatement)
elseStatement = CloneStatement(node.elseStatement);
return ShaderBuilder::Branch(std::move(statements), std::move(elseStatement));
auto branchStatement = ShaderBuilder::Branch(std::move(statements), std::move(elseStatement));
branchStatement->sourceLocation = node.sourceLocation;
return branchStatement;
}
ExpressionPtr AstConstantPropagationVisitor::Clone(ConditionalExpression& node)
@@ -1031,6 +1036,7 @@ namespace Nz::ShaderAst
auto constant = ShaderBuilder::Constant(*constantValue);
constant->cachedExpressionType = GetConstantType(constant->value);
constant->sourceLocation = node.sourceLocation;
return constant;
}
@@ -1082,6 +1088,7 @@ namespace Nz::ShaderAst
auto swizzle = ShaderBuilder::Swizzle(std::move(expr), node.components, node.componentCount);
swizzle->cachedExpressionType = node.cachedExpressionType;
swizzle->sourceLocation = node.sourceLocation;
return swizzle;
}
@@ -1116,6 +1123,7 @@ namespace Nz::ShaderAst
auto unary = ShaderBuilder::Unary(node.op, std::move(expr));
unary->cachedExpressionType = node.cachedExpressionType;
unary->sourceLocation = node.sourceLocation;
return unary;
}

View File

@@ -21,7 +21,7 @@ namespace Nz::ShaderAst
m_callbacks->onAliasDeclaration(node);
if (m_callbacks->onAliasIndex && node.aliasIndex)
m_callbacks->onAliasIndex(node.name, *node.aliasIndex);
m_callbacks->onAliasIndex(node.name, *node.aliasIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}
@@ -33,7 +33,7 @@ namespace Nz::ShaderAst
m_callbacks->onConstDeclaration(node);
if (m_callbacks->onConstIndex && node.constIndex)
m_callbacks->onConstIndex(node.name, *node.constIndex);
m_callbacks->onConstIndex(node.name, *node.constIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}
@@ -49,7 +49,7 @@ namespace Nz::ShaderAst
for (const auto& extVar : node.externalVars)
{
if (extVar.varIndex)
m_callbacks->onVariableIndex(extVar.name, *extVar.varIndex);
m_callbacks->onVariableIndex(extVar.name, *extVar.varIndex, extVar.sourceLocation);
}
}
@@ -76,7 +76,7 @@ namespace Nz::ShaderAst
for (const auto& parameter : node.parameters)
{
if (parameter.varIndex)
m_callbacks->onVariableIndex(parameter.name, *parameter.varIndex);
m_callbacks->onVariableIndex(parameter.name, *parameter.varIndex, parameter.sourceLocation);
}
}
@@ -90,7 +90,7 @@ namespace Nz::ShaderAst
m_callbacks->onOptionDeclaration(node);
if (m_callbacks->onOptionIndex && node.optIndex)
m_callbacks->onOptionIndex(node.optName, *node.optIndex);
m_callbacks->onOptionIndex(node.optName, *node.optIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}
@@ -102,7 +102,7 @@ namespace Nz::ShaderAst
m_callbacks->onStructDeclaration(node);
if (m_callbacks->onStructIndex && node.structIndex)
m_callbacks->onStructIndex(node.description.name, *node.structIndex);
m_callbacks->onStructIndex(node.description.name, *node.structIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}
@@ -114,7 +114,7 @@ namespace Nz::ShaderAst
m_callbacks->onVariableDeclaration(node);
if (m_callbacks->onVariableIndex && node.varIndex)
m_callbacks->onVariableIndex(node.varName, *node.varIndex);
m_callbacks->onVariableIndex(node.varName, *node.varIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}
@@ -123,7 +123,7 @@ namespace Nz::ShaderAst
{
assert(m_callbacks);
if (m_callbacks->onVariableIndex && node.varIndex)
m_callbacks->onVariableIndex(node.varName, *node.varIndex);
m_callbacks->onVariableIndex(node.varName, *node.varIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}
@@ -132,7 +132,7 @@ namespace Nz::ShaderAst
{
assert(m_callbacks);
if (m_callbacks->onVariableIndex && node.varIndex)
m_callbacks->onVariableIndex(node.varName, *node.varIndex);
m_callbacks->onVariableIndex(node.varName, *node.varIndex, node.sourceLocation);
AstRecursiveVisitor::Visit(node);
}

File diff suppressed because it is too large Load Diff