1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "builtins/builtins.h"
using namespace empathy::sema;
namespace empathy::builtins
{
class OverloadSetInvocationRule : public InvocationRule
{
public:
virtual optional< Value > resolveInvocation( const Context& c, const Value& callee, const Value& args ) const final
{
const auto& env = c.env();
auto pOvlSet = FromValue< ptr< OverloadSet > >( callee );
assert( pOvlSet );
UnificationContext uc( env );
optional< UnificationContext > bestUC;
optional< Term > bestSol;
optional< OverloadSet::Overload > bestOvl;
bool ambiguous = false;
auto rtPat = sema::MkHole( "_"_sid );
for( auto&& [s,ovl,uc] : pOvlSet->unify( args.val(), rtPat, uc ) )
{
if( uc.numUnknownValues() )
continue;
auto ssol = Substitute( s, uc );
|
<
<
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "builtins/builtins.h"
using namespace empathy::sema;
namespace empathy::builtins
{
class OverloadSetInvocationRule : public InvocationRule
{
public:
virtual optional< Value > resolveInvocation( const Context& c, const Value& callee, const Value& args ) const final
{
auto pOvlSet = FromValue< ptr< OverloadSet > >( callee );
assert( pOvlSet );
UnificationContext uc( c );
optional< UnificationContext > bestUC;
optional< Term > bestSol;
optional< OverloadSet::Overload > bestOvl;
bool ambiguous = false;
auto rtPat = MkHole( "_"_sid );
for( auto&& [s,ovl,uc] : pOvlSet->unify( args.val(), rtPat, uc ) )
{
if( uc.numUnknownValues() )
continue;
auto ssol = Substitute( s, uc );
|