1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include "builtins/builtins.h"
using namespace empathy::sema;
namespace empathy::builtins
{
class OverloadSetInvocationRule : public InvocationRule
{
public:
optional< Value > resolveInvocation( const Context& c, const Value& callee, const Value& args ) const final
{
auto pOvlSet = *FromValue< ptr< OverloadSet > >( callee );
UnificationContext uc( c );
optional< UnificationContext > bestUC;
optional< Term > bestSol;
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include "builtins/builtins.h"
using namespace empathy::sema;
namespace empathy::builtins
{
class OverloadSetInvocationRule : public InvocationRule
{
public:
optional< Value > resolveInvocation( const Context& c, uint32_t loc, const Value& callee, const Value& args ) const final
{
auto pOvlSet = *FromValue< ptr< OverloadSet > >( callee );
UnificationContext uc( c );
optional< UnificationContext > bestUC;
optional< Term > bestSol;
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
if( bestOvl != &ovl )
ambiguous = true;
}
if( ambiguous )
{
// TODO error mgmt
cout << "ambiguous function call.\n";
return nullopt;
}
if( !bestSol )
{
// TODO error mgmt
cout << "function arguments mismatch.\n";
return nullopt;
}
return bestOvl->pInvRule->invoke( c, *bestOvl->callee, *bestSol, *bestUC );
}
};
ptr< InvocationRule >& GetOverloadSetInvocationRule()
{
static ptr< InvocationRule > pRule = make_shared< OverloadSetInvocationRule >();
return pRule;
|
|
>
|
|
>
|
|
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
if( bestOvl != &ovl )
ambiguous = true;
}
if( ambiguous )
{
// TODO display details
DiagnosticsManager::GetInstance().emitErrorMessage( loc,
"ambiguous function call." );
return nullopt;
}
if( !bestSol )
{
// TODO display details
DiagnosticsManager::GetInstance().emitErrorMessage( loc,
"function arguments mismatch." );
return nullopt;
}
return bestOvl->pInvRule->invoke( c, loc, *bestOvl->callee, *bestSol, *bestUC );
}
};
ptr< InvocationRule >& GetOverloadSetInvocationRule()
{
static ptr< InvocationRule > pRule = make_shared< OverloadSetInvocationRule >();
return pRule;
|