pslang/libs/ast/source/expression.cpp

69 lines
1.1 KiB
C++

#include <pslang/ast/expression.hpp>
#include <pslang/ast/expression_visitor.hpp>
namespace pslang::ast
{
namespace
{
struct get_location_visitor
: const_expression_visitor<get_location_visitor>
{
using const_expression_visitor::apply;
template <typename T>
location apply(primitive_literal_base<T> const & node)
{
return node.location;
}
location apply(identifier const & node)
{
return node.location;
}
location apply(unary_operation const & node)
{
return node.location;
}
location apply(binary_operation const & node)
{
return node.location;
}
location apply(cast_operation const & node)
{
return node.location;
}
location apply(function_call const & node)
{
return node.location;
}
location apply(array const & node)
{
return node.location;
}
location apply(array_access const & node)
{
return node.location;
}
location apply(field_access const & node)
{
return node.location;
}
};
}
location get_location(expression const & expression)
{
return get_location_visitor{}.apply(expression);
}
}