#ifndef EMPATHY_BUILTINS_TYPES_OVERLOADSET_H
#define EMPATHY_BUILTINS_TYPES_OVERLOADSET_H
namespace empathy::builtins
{
void SetupOverloadSetInvocationRule( Env& e );
class OverloadSet
{
public:
struct Overload
{
ptr< InvocationRule > pInvRule;
optional< Value > callee;
};
OverloadSet( const StringId& name ) :
m_name( name )
{}
const auto& name() const { return m_name; }
bool add( const sema::Context& context, const Value& callee );
using UniGen = Generator< tuple<
Term,
const Overload&,
UnificationContext
> >;
UniGen unify( const Term& argsPat, const Term& rtPat, UnificationContext& uc ) const;
private:
StringId m_name;
using utrie_type = UTrie< Trie< Overload > >;
ptr< utrie_type > m_trie = make_shared< utrie_type >();
};
extern bool IsOverloadSet( const Value& os );
}
namespace empathy::ir
{
template<>
struct Bridge< ptr< builtins::OverloadSet > >
{
static const Term& Type();
static Value ToValue( const ptr< builtins::OverloadSet >& os );
static ptr< builtins::OverloadSet > FromValue( const Value& v );
};
}
#endif