83 lines
1.3 KiB
C++
83 lines
1.3 KiB
C++
#include <pslang/ast/statement.hpp>
|
|
#include <pslang/ast/statement_visitor.hpp>
|
|
|
|
namespace pslang::ast
|
|
{
|
|
|
|
namespace
|
|
{
|
|
|
|
struct get_location_visitor
|
|
: const_statement_visitor<get_location_visitor>
|
|
{
|
|
using const_statement_visitor::apply;
|
|
|
|
location apply(expression_ptr const & node)
|
|
{
|
|
return get_location(*node);
|
|
}
|
|
|
|
location apply(assignment const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(variable_declaration const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(if_block const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(else_block const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(else_if_block const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(if_chain const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(while_block const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(function_definition const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(return_statement const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(field_definition const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
|
|
location apply(struct_definition const & node)
|
|
{
|
|
return node.location;
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
location get_location(statement const & statement)
|
|
{
|
|
return get_location_visitor{}.apply(statement);
|
|
}
|
|
|
|
}
|