#include "ir.h"

namespace empathy::ir
{
    bool Compare( const Trie<>& lhs, const Trie<>& rhs )
    {
        return Compare<>( lhs, rhs, []( auto&&, auto&& ){ return true; } );
    }

    bool Term::operator==( const Term& rhs ) const
    {
        if( m_content.index() != rhs.m_content.index() )
            return false;

        return visit( [&]( auto&& l )
        {
            using T = remove_constref_t< decltype( l ) >;
            const auto& r = get< T >( rhs.m_content );

            if constexpr( is_same_v< pvec, T > )
                return *l == *r;
            else
                return l == r;
        }, m_content );
    }

    bool Vector::operator==( const Vector& rhs ) const
    {
        return m_repetitionTerm == rhs.m_repetitionTerm
            && m_terms == rhs.m_terms;
    }
}
