#include #include #include namespace pslang::ast { namespace { struct get_location_visitor : const_expression_visitor { using const_expression_visitor::apply; template location apply(primitive_literal_base 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; } }; struct get_type_visitor : const_expression_visitor { using const_expression_visitor::apply; template types::type_ptr apply(primitive_literal_base const & node) { return std::make_unique(types::primitive_type{types::primitive_type_base{}}); } types::type_ptr apply(identifier const & node) { return node.inferred_type; } types::type_ptr apply(unary_operation const & node) { return node.inferred_type; } types::type_ptr apply(binary_operation const & node) { return node.inferred_type; } types::type_ptr apply(cast_operation const & node) { return node.inferred_type; } types::type_ptr apply(function_call const & node) { return node.inferred_type; } types::type_ptr apply(array const & node) { return node.inferred_type; } types::type_ptr apply(array_access const & node) { return node.inferred_type; } types::type_ptr apply(field_access const & node) { return node.inferred_type; } }; } location get_location(expression const & expression) { return get_location_visitor{}.apply(expression); } types::type_ptr get_type(expression const & expression) { return get_type_visitor{}.apply(expression); } }