Yume
hash_visitor.cpp
Go to the documentation of this file.
1#include "hash_visitor.hpp"
2#include "ast/ast.hpp"
3#include <cstddef>
4
5namespace yume::diagnostic {
6inline auto HashVisitor::visit(const ast::AST& expr, string_view label) -> HashVisitor& {
7 hash_combine(m_seed, label);
8 hash_combine(m_seed, expr.kind_name());
9 hash_combine(m_seed, expr.describe());
10 expr.visit(*this);
11
12 return *this;
13}
14
15inline auto HashVisitor::visit(const string& str, string_view label) -> HashVisitor& {
16 hash_combine(m_seed, label);
17 hash_combine(m_seed, str);
18
19 return *this;
20}
21
22inline auto HashVisitor::visit(std::nullptr_t, string_view label) -> HashVisitor& {
23 hash_combine(m_seed, label);
24 hash_combine(m_seed, nullptr);
25
26 return *this;
27}
28} // namespace yume::diagnostic
All nodes in the AST tree of the program inherit from this class.
Definition: ast.hpp:224
auto visit(const ast::AST &expr, string_view label) -> HashVisitor &override
Definition: hash_visitor.cpp:6
static void hash_combine(uint64_t &seed, const T &v)
Definition: util.hpp:112