Goose  Artifact [d92b79f184]

Artifact d92b79f184321d9a84a458cb63d719822f53c9ad582e2f0a2848f5868564e0f6:

  • File bs/ir/compare.cpp — part of check-in [afb316dee6] at 2018-11-11 20:11:57 on branch trunk —
    • Remove Or term, they just complicate term/term pattern matching because they can generate multiple solutions and aren't actually useful.
    • Implemented Match for term/term.
    (user: achavasse size: 815)

#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;
    }
}